home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / languages / progs / shell / !Help
Encoding:
Text File  |  1994-07-08  |  12.1 KB  |  312 lines

  1.               The Shell library
  2.               -----------------
  3.  
  4.  
  5. ________________________________________________________________________
  6.  
  7.  
  8.  
  9.  
  10.  
  11. 1. About Shell
  12. --------------
  13.  
  14.  
  15. Shell is a set of C routines which allow you to easily make multi-tasking
  16. programs which can display complicated items like arrays, bar-graphs,
  17. blocks of text etc in windows. It uses the routines in the DeskLib C
  18. lbrary. I wrote the Shell library to enable easy development of
  19. neural-network simulation programs for my PhD, so it is probably of most
  20. use to    people wanting to display large amounts of data in windows. It
  21. also provides lots of example code for writing wimp applications.
  22.  
  23. Most of the routines are not optimised for speed, but for ease of use - for
  24. instance, there are routines which print text in a window using
  25. workarea coordinates, so that window-redrawing routines can work
  26. exclusively in workarea coordinates. There are similar routines (some
  27. macros) for drawing lines/circles/rectangles etc.
  28.  
  29. The header files are fairly well commented, and the example program ShellEG
  30. should provide a clear idear of what Shell routines can do, and how to
  31. use them.
  32.  
  33.  
  34. How Shell works:
  35.  
  36. When you use Shell, you open one or more Shell-windows. The redrawing of
  37. these windows is done entirely by the Shell library using DeskLib's Event_
  38. library - you don't have to worry about redraw rectangles etc. 
  39.  
  40. Each Shell window can have any number of rectangle inside it. Each
  41. rectangle has a structure assciated with it, which contains all the
  42. information needed to redraw the rectangle, i.e. a pointer to a
  43. redrawing function, and various other data like the rectangle's
  44. dimensions. Some simple rectangle redrawing functions are already part
  45. of Shell, to draw a 2D array of text, a bar graph, a block of text etc.
  46. etc. 
  47.  
  48. When a redrawing function is called, it can work in coords relative to
  49. the rectangle, not the window workarea coords or the screen's coords; to
  50. do this, use the supplied strucure Shell_convertpoint 'convert', which
  51. actually represents the screen coords of the bottom-left of the
  52. rectangle. To plot things, use Shell_Plot( plotcode, x, y, convert), or
  53. Shell_Circle( x, y, r, convert) etc. These are macros which will use
  54. 'convert' to find the screen coors. See some of the supplied redraw
  55. functions for examples of using these, e.g. sources.c.BarGraph,
  56. sources.c.TextRect, sources.c.Label.
  57.  
  58. You can add a rectangle to a window with Shell_AddRectangle, supplying a
  59. function which Shell will call when this rectangle needs redrawing. If,
  60. instead, you just want a standard rectangle type, call Shell_Add2DArray,
  61. Shell_AddBarGraph, Shell_AddTextRect or Shell_AddGeneralArray etc. Many
  62. of these higher-level still require a simple function from you; e.g.
  63. Shell_AddGeneralArray needs a function which, given an x and y, returns
  64. a string to display at location (x,y) in the rectangle.
  65.  
  66. The TextRect functions allow you to print to a rectangle using the same
  67. syntax as 'printf'. Thus you can have large amounts of text in a block
  68. in a window providing the functionality of running a program in a
  69. taskwindow, but also allowing the use of the more graphical displays
  70. such as arrays and bar-graphs.
  71.  
  72. You can also force rectangles/arrays etc. to be redrawn, for instance if
  73. their contents have changed.
  74.  
  75. You can still open windows independantly of Shell if you wish - Shell
  76. uses DeskLib's Event_Poll function, so any such window should be redrawn
  77. etc using Event_ handlers. Also, if you register a handler for
  78. event_REDRAW, you can do your own redrawing inside Shell windows.
  79.  
  80. You can use Shell_ to help debug a Wimp application, as long as the
  81. application uses DeskLib's Event_ library. For example, you can output
  82. diagnostic information to a window using Shell_Printf( ...) from within
  83. your code. You shouldn't do this in the middle of redrawing code, for
  84. example, as this will confuse the Wimp. There is now a function
  85. Shell_WaitPrintf( ...) which you can use for this purpose. It is very
  86. useful if you want to find out why your redrawing is not working.
  87.  
  88.  
  89. I wrote Shell for use with programs which are basically mathematical models,
  90. that take hours to run, which I wanted to run in the background. i.e. they
  91. aren't conventional event-driven Wimp application. Because of this, I've
  92. written a very simple front-end to Event_Poll called Shell_Poll which
  93. repeatedly calls Event_Poll until an event_NULL is received. To make a
  94. program multi-tasking, just sprinkle a few Shell_Poll's through a program.
  95. Thus by calling Shell_Poll frequently in your program, the system multitasks
  96. nicely, but your program gets time when there are event_NULL's available.
  97. There is also a macro Shell_PollSlow which calls Shell_Poll only if
  98. sufficient time has elapsed since the last call to Shell_Poll. This time
  99. interval is set with Shell_SetPollInterval. Using small values will
  100. result in a smooth desktop, while larger values will result in fewer
  101. calls to Wimp_Poll giving a jerky desktop but a faster program. 
  102.  
  103. You don't have to use Shell_Poll - if your application is a conventional
  104. event-driven one, you should just call Event_Poll directly.
  105.  
  106.  
  107. You can also set the frequency with which rects are updated so that you
  108. can tell Shell that a rect's contents have changed very frequently, but
  109. Shell won't call Wimp_ForceRedraw each time. This speeds up your program
  110. significantly as it means it's not continually readrawing a window.
  111.  
  112. Many rectangles can be saved in the desktop by Shift-Menu clicking on
  113. them. e.g. you can save the times-table in the example program as text.
  114.  
  115. One very useful feature is a PlainRect. This is just a rectangle inside
  116. a window, but when you save it, it saves its contents as a sprite,
  117. allowing you to extract bar graphs/blockrects etc directly without
  118. grabbing bits of the screen with !Paint.
  119.  
  120. Shell has quite a few rough edges - for e.g. the maximum nuber of
  121. windows is #defined as 4, which is ample for my programs but might not
  122. be enough for everyone. The windows are stored in an array, but they
  123. should really be a linked list (like the rectangles in each window,
  124. which use DeskLib's LinkList functions).
  125.  
  126. Other things which aren't perfect are:
  127.  
  128. FontLabel.c    the font handle is not updated when a mode-change occurs, 
  129.         and the colours don't work very well in 256-colour modes.
  130. BarGraph.c    No facility for negative-height bars.
  131. TextRect.c    The text is not formated - you need to put '\n' in 
  132.         occasionaly if you want the text to be multiline. This is 
  133.         not too bad as printf behaves in the same way.
  134. PlainRect.c    This saves an area of a Shell window as a sprite by 
  135.         redirecting to a sprite, and forcing a redraw of the area.
  136.         Text is half-size (in square pixel modes) and the outlines 
  137.         of Shell rectangles (which are created with Wimp_PlotIcon) 
  138.         don't show up for some reason.
  139.  
  140. No facilities are provided for deleting rectangles and free-ing the memory
  141. they took up.
  142.  
  143. And some more which I've forgotton about.
  144.  
  145.  
  146. The TextRect.c file deals with redrawing text which contains line-feeds
  147. etc. It took a fair while for me to work out how to do this!
  148.  
  149.  
  150. One thing which might make the source files difficult to read for users of
  151. !Edit is the profusion of Tabs. The solution is to use the excellent
  152. freeware !Zap text editor - you won't want to use !Edit again after seeing
  153. !Zap. For users of other text editors, the tabs in Zap tab to 8 spaces so
  154. any other value will result in strange non-aligned text.
  155.  
  156. Any application which uses Shell has to have a window called 'ShellWindow'
  157. in its template file - Shell_OpenGFXWindow assumes this name.
  158.  
  159.  
  160. One of the main uses of Shell is to show how to cope with redrawing windows
  161. in the Wimp enviroment - I found this quite difficult to start with.
  162. Hopefully, the Shell sources will help people understand how the Wimp
  163. redrawing system works.
  164.  
  165.  
  166. _________________________________________________________________________
  167.  
  168.  
  169. 2. Installation.
  170. ----------------
  171.  
  172. You should simply move the whole Shell library directory into your C path.
  173. Don't move any headers into an existing .h. directory. Shell has many header
  174. files, some of which might be the same name as ones you already have; thus
  175. Shell source files have lines like: 
  176.  
  177. #include "Shell.Array.h"
  178.  
  179. which should also be used by any of your code which uses Shell.
  180.  
  181. e.g.., if <C$Path> = ADFS:4.$.CLibs., ...other.libraries... 
  182.  
  183. then you should put the entire Shell directory in ADFS:4.$.CLibs to get a
  184. tree that looks like:
  185.  
  186. ADFS:4.$.CLibs.
  187.                h.
  188.                  header1      /* your existing headers */
  189.                  header2
  190.                  ...
  191.                
  192.                o.
  193.                  RISC_OSLib   /* your existing libraries */
  194.                  ...
  195.                
  196.                Shell.
  197.                      h.
  198.                        Shell
  199.                        Array
  200.                        ...
  201.                     
  202.                      o.ShellLib
  203.                     
  204.                      Sources.
  205.                              c.
  206.                                Array
  207.                                Label
  208.                                ...
  209.                              
  210.                              MakeFile
  211.                              
  212.                              o.
  213.                                Array
  214.                                Label
  215.                                ...
  216.  
  217. You should link with C:Shell.o.ShellLib
  218.  
  219. An alternative to this is to create a Shell application which sets
  220. <Shell$Path> and change all #include lines to #include "Shell:Array.h",
  221. while linking with 'Shell:o.ShellLib'. This approach is used by DeskLib.
  222.  
  223. If you recompile the Shell-lib, or the example program ShellEG, you might
  224. have to alter the makefile so that the the dynamic dependances section points
  225. to the right place on your system, and also change the list of libraries to
  226. again point to where your libraries are.
  227.  
  228. Note that ShellEG requires the extra DeskLib library 'Save' which comes
  229. with DeskLib 2.10. This enables you to save the contents of certain
  230. rectangles as a file or directly into running applications, by clicking
  231. Shift-Menu over a Shell window. See the ShellEG code to see how this is
  232. set up.
  233.  
  234.  
  235.  
  236.  
  237.  
  238. ___________________________________________________________________________
  239.  
  240.  
  241. 3. Things to do
  242. ---------------
  243.  
  244.  
  245. What would be really nice would be to have a command-line input, so that
  246. commands could be typed in and read by a function like Shell_scanf, with
  247. other functions such as Shell_getc etc. You could have input from different
  248. input rectangles, so Shell_scanf( Shell_rectblock *rectblock, "%i", &x).
  249. There could also be a general input rectangle attatched to the general
  250. output textrect, which would be read by Shell_scanf( NULL, ...). This would
  251. make Shell_ completely implement a standard textual input/output system
  252. like taskwindows, but with easy to use graphics facilities as well.
  253.  
  254. Simple x-y graphs. I've got code to do this but it's a bit messy at the mo.
  255.  
  256. Add a saver for blockrects to save as a sprite - Done that now.
  257.  
  258. Add a saver for bargraphs.
  259.  
  260. Have a rect which displays a sprite - I have a messy version of this.
  261.  
  262. At the moment, rectangles have colours and can have an icon-style border.
  263. The default routines add various borders automatically, using
  264. Shell_MakeRectIcon. An alternative way of doing this would be to put a set
  265. of icons in the 'ShellWindow' in the Templates file, called 'Array',
  266. 'RectBlock' ... etc, so that any RectBlocks would have icon charateristics
  267. (such as colours, border) from the templates file.
  268.  
  269. Add facilities to delete rectangles, freeing allocated space etc. I've
  270. never actually needed to do this, but these functions should really be
  271. included in the library.
  272.  
  273.  
  274.  
  275. ___________________________________________________________________________
  276.  
  277.  
  278. 4. Other things
  279. ---------------
  280.  
  281. Shell is freeware. Feel free to distribute it, but please distribute the
  282. original, not altered copies.
  283.  
  284. If you write any routines for extra rectangle types (e.g. to draw a
  285. sprite in a window, or a drawfile in a window), please send them to me
  286. so they can be included in the next release.
  287.  
  288. If you have any queries/suggestions/good ideas/extra routines/complaints
  289. relating to Shell, feel free to contact me at the address below:
  290.  
  291.  
  292.  Julian Smith
  293.  
  294.  
  295.  ------------------------
  296.  julians@cogsci.ed.ac.uk
  297.  ------------------------
  298.  
  299.  or:
  300.  
  301.  ------------------------
  302.  Department of Psychology
  303.  University of Edinburgh
  304.  7 George Square
  305.  Edinburgh 
  306.  EH8 9JZ
  307.  UK
  308.  ------------------------
  309.  
  310.  
  311.  
  312.