home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / languages / progs / shell / h / Shell < prev    next >
Encoding:
Text File  |  1994-06-25  |  6.7 KB  |  256 lines

  1. #ifndef __Shell_h
  2. #define __Shell_h
  3.  
  4. #include <time.h>
  5. #include <stdio.h>
  6.  
  7. #ifndef __dl_wimp_h
  8. #include "DeskLib:Wimp.h"
  9. #endif
  10.  
  11. #ifndef __dl_coord_h
  12. #include "DeskLib:Coord.h"
  13. #endif
  14.  
  15. #ifndef __dl_error_h
  16. #include "DeskLib:Error.h"
  17. #endif
  18.  
  19. #ifndef __dl_linklist_h
  20. #include "DeskLib:LinkList.h"
  21. #endif
  22.  
  23. #ifndef UNUSED
  24. #define UNUSED( x) (x) = (x)
  25. #endif
  26.  
  27. #define Shell_MAXWINDS         4    /* Should convert the list of windows into a     */
  28.                     /* linked list sometime.            */
  29.  
  30. #define Shell_TEXTXSIZE        16    /* width of a system-font character    */
  31. #define Shell_TEXTYSIZE        32    /* height of a system-font character    */
  32.  
  33. #define Shell_PIXELXSIZE     2    /* This should depend on mode, but it     */
  34. #define Shell_PIXELYSIZE     2    /* doesn't yet...            */
  35.  
  36. #define Shell_stringMAX        1023
  37. extern char Shell_string[ 1+Shell_stringMAX];    /* This is used in the Shell_*Printf( ...)    */
  38.                         /* functions.                    */
  39.  
  40.  
  41.  
  42.  
  43. #define Shell_defaulttextrect NULL
  44.     /* This is used to print text to a default output     */
  45.     /* window - when you first print text to this rectblock    */
  46.     /* Shell_ will open a window and define a textrect    */
  47.     /* automatically                    */
  48.  
  49.  
  50.  
  51. typedef wimp_point Shell_convertpoint;    /* The position of origin of a window in screen coors    */
  52.  
  53.  
  54.  
  55. typedef void (*Shell_redrawer)
  56.     (
  57.     Shell_convertpoint    convert,
  58.     wimp_point        rectsize,
  59.     void            *reference,
  60.     const wimp_rect        *redrawrect
  61.     );
  62.  
  63.     /* A fn which deals with a rectangle in a window.    */
  64.     /* rectsize is the size of the rectblock.        */
  65.     /* All redrawing should use convert, with (0,0) being    */
  66.     /* at the bottom-left of the rectblock.            */
  67.     /* redrawrect is relative to the rectblock.        */
  68.  
  69.  
  70.  
  71. typedef struct Shell_rectblock *Shell_rectblockptr;
  72.  
  73. typedef BOOL (*Shell_saver)( char *filename, Shell_rectblockptr r);
  74.     /* A fn which saves the data in a rectangle to        */
  75.     /* 'filename', using whatever format is most         */
  76.     /* appropriate for the rectangle's data.        */
  77.  
  78.  
  79. typedef int (*Shell_ramsaver)(
  80.     task_handle        sourcetask,
  81.     Shell_rectblockptr    rect,
  82.     task_handle        desttask,
  83.     void            *destbuffer,
  84.     unsigned int        buffersize,
  85.     int            progress
  86.     );
  87.  
  88.  
  89. typedef struct    Shell_rectblock    {    /* Info for each rect registered in a window.        */
  90.     linklist_header    header;
  91.     window_handle    window;        /* Window handle of the window this rect is in.        */
  92.     icon_block    icon;
  93.     BOOL        plot_icon;    /* If set, Shell redraw fn will do a Wimp_PlotIcon.    */
  94.     wimp_rect    rect;        /* This is in work area coors.                */
  95.     clock_t        last_update,    /* Time this rect was last redrawn.            */
  96.             update_time;    /* Minimum time between 'Slow' redraws.            */
  97.  
  98.     Shell_redrawer    redrawer;    /* Fn to be called when this rect needs redrawing.    */
  99.     Shell_saver    saver;        /* Fn to be called to print rect to file.        */
  100.     Shell_ramsaver    ramsaver;    /* Fn to be called to ram-transfer a rect.        */
  101.     int        filetype;    /* Filetype to be used when saving this rect.        */
  102.     void        *reference;    /* Info to pass to redrawing fn.            */
  103.     }
  104.     Shell_rectblock;
  105.  
  106.  
  107. typedef struct    {            /* Info for each window that        */
  108.                     /* has been opened.            */
  109.     linklist_header    anchor;        /* Anchor of liked list of rectblocks.    */
  110.     window_handle    window;
  111.     int        numrects;
  112.     }
  113.     Shell_windblock;
  114.  
  115.  
  116. extern int        Shell_numwinds;
  117. extern Shell_windblock    Shell_windows[ Shell_MAXWINDS];
  118.  
  119.  
  120.  
  121.  
  122.  
  123. /* ********************** The Functions ***************************************** */
  124.  
  125.  
  126.  
  127.  
  128. #define Shell_ErrorReportFatal Error_ReportFatal
  129.  
  130.  
  131.  
  132. void Shell_Init( char *progname, char *resourcedir);
  133.     /* Inits DeskLib's Event_, Template_, Resource_, and loads    */
  134.     /* '<'resourcedir'$Dir>.Templates' using DeskLib's template     */
  135.     /* calls. This should contain the template 'ShellWindow'.    */
  136.  
  137.  
  138. void Shell_Poll( void);
  139.     /* Repeatedly calls Event_Poll until a null event is received.     */
  140.  
  141.  
  142. extern BOOL Shell_paused;
  143.     /* This can be changed anytime. Shell_Poll will check it, and if    */
  144.     /* Shell_paused==TRUE, will continue to call Wimp_Poll.            */
  145.  
  146. extern    clock_t    Shell_nextpolltime, Shell_pollinterval;
  147.     /* Used by:                            */
  148.  
  149. #define Shell_PollSlow()    {                \
  150.     clock_t    t = clock();                    \
  151.     if ( t > Shell_nextpolltime)    {            \
  152.         Shell_nextpolltime = t + Shell_pollinterval;    \
  153.         Shell_Poll();                    \
  154.         }                        \
  155.     }
  156.     /* This is a macro that will call Shell_Poll() with minimum     */
  157.     /* interval Shell_pollinterval.                    */
  158.     /* It should hopefuly waste very little time even if called    */
  159.     /* much more frequently than (Shell_pollinterval()^-1.        */
  160.  
  161.  
  162. #define Shell_SetPollInterval( time)    Shell_pollinterval = (clock_t) ( (time)*CLOCKS_PER_SEC)
  163.     /* Sets the minimum interval between polls in Shell_PollSlow().    */
  164.     /* 'time' should be in seconds.                    */
  165.  
  166.  
  167.  
  168. #define Shell_OpenGFXWindow Shell_OpenWindow
  169.     /* For compatibility with the original name.    */
  170.  
  171. Shell_windblock *Shell_OpenWindow( void);
  172.     /* Opens a Shell window. You must have a window called 'ShellWindow'         */
  173.     /* in your application's 'Templates' file.                    */
  174.  
  175.  
  176.  
  177.  
  178. Shell_rectblock *Shell_AddRectangle(
  179.     Shell_windblock    *wind,
  180.     const wimp_rect    *rect,
  181.     Shell_redrawer    redrawfn,
  182.     const void    *reference
  183.     );
  184.  
  185.     /* Adds a rectangle to a graphics window. You supply a         */
  186.     /* Shell_redrawer which is called whenever the    rectangle     */
  187.     /* needs redrawing.                        */
  188.  
  189. Shell_rectblock *Shell_AddRectangle2(
  190.     Shell_windblock    *wind,
  191.     int        xmin,
  192.     int        ymin,
  193.     int        xmax,
  194.     int        ymax,
  195.     Shell_redrawer    redrawfn,
  196.     const void    *reference
  197.     );
  198.  
  199. Shell_rectblock *Shell_AddRectangle3(
  200.     Shell_windblock    *wind,
  201.     int        xmin,
  202.     int        ymin,
  203.     int        xsize,
  204.     int        ysize,
  205.     Shell_redrawer    redrawfn,
  206.     const void    *reference
  207.     );
  208.  
  209.     /* Same as above, except that the rectangle is specified by     */
  210.     /* four integers, rather than a (wimp_rect *). These integers    */
  211.     /* specify either the bottom-left and top-right points, or the     */
  212.     /* bottom left point, and the x and y size of the rectangle    */
  213.  
  214.  
  215.  
  216.  
  217. void Shell_ForceRectRedraw( Shell_rectblock *rect);
  218.     /* Makes this rectangle be redrawn at the next Wimp_Poll.    */
  219.     /* Use this if the data in the rectangle has changed.        */
  220.     /* This call just calls Wimp_ForceRedraw.            */
  221.  
  222. void Shell_ForceRectUpdate( Shell_rectblock *rect);
  223.     /* As above, except the rectangle is not blanked, and the    */
  224.     /* redrawing is done imediately. Use this if the rectangle    */
  225.     /* involves animation.                        */
  226.     /* This call uses Wimp_UpdateWindow                */
  227.  
  228. void Shell_ForceRectRedrawSlow( Shell_rectblock *rect);
  229.     /* This calls Shell_ForceRectRedraw if the time since the    */
  230.     /* rectangle was last redrawn is greater than            */
  231.     /* rectnum->update_time.                    */
  232.  
  233. #define Shell_SetRectUpdateTime( rect, time)                \
  234.     (rect)->update_time = (time_t) ( (time)*CLOCKS_PER_SEC)        \
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241. void Shell_SetWindowTitle( window_handle window, char *text);
  242.     /* This just calls Window_SetTitle.    */
  243.  
  244.  
  245.  
  246.  
  247. void Shell_MakeRectIcon( Shell_rectblock *r, int forecol, int backcol, char *valid);
  248.     /* Use this to make a rect automatically have a background     */
  249.     /* colour and a validation string to specify the border.    */
  250.     /* The string at 'valid' is strcpy-ed, so you can discard it     */
  251.     /* after this call.                        */
  252.  
  253.  
  254.  
  255. #endif
  256.