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

  1. /* Some extra routines which may be useful...                */
  2. /* They are for implementing a non-standard rectangle type, i.e.    */
  3. /* when you call Shell_AddRectangle yourself instead of         */
  4. /* Shell_AddBarGraph, Shell_AddGeneralArray, ... etc. When you do this    */
  5. /* you have to write a redrawing function, for which many of the     */
  6. /* following functions are useful.                    */
  7. /* The supplied rectangle funtions such as BarGraph, Array etc. use     */
  8. /* these functions, so look at the source for examples.            */
  9.  
  10.  
  11. #ifndef __Shell_Extra_h
  12. #define __Shell_Extra_h
  13.  
  14. #ifndef __Shell_h
  15. #include "Shell.Shell.h"
  16. #endif
  17.  
  18. #ifndef __dl_gfx_h
  19. #include "DeskLib:GFX.h"
  20. #endif
  21.  
  22.  
  23.  
  24.  
  25. BOOL Shell_CheckYScrollIsBottom( window_handle windowhandle);
  26.     /* Returns TRUE if windowhandle y-scrollbar is at bottom    */
  27.  
  28. void Shell_MoveYScrollToBottom( window_handle window);
  29.     /* Moves y-scrollbar to bottom                    */
  30.  
  31. #define Shell_MakeGE( a, b)  if ((b) > (a)) (a) = (b)
  32. #define Shell_MakeLE( a, b)  if ((b) < (a)) (a) = (b)
  33.     /* These macros change the *first* parameter so that it    */
  34.     /* is >= or <= the second parameter.            */
  35.     /* Useful when you are clipping rectangles.        */
  36.  
  37.  
  38. void Shell_ConvertToTextRect( wimp_rect *rect);
  39.     /* divides all x's and y's by Shell_TEXTXSIZE, Shell_TEXTYSIZE    */
  40.  
  41. void Shell_ConvertToSubTextRect( wimp_rect *rect, const wimp_rect *bigrect);
  42.     /* Used in 2D array rectangle routines.                */
  43.     /* bigrect encloses total array, this routine makes *rect     */
  44.     /* contain line and column of rect inside bigrect        */
  45.  
  46. void Shell_ConvertToSubTextRect2( wimp_rect *rect, wimp_point rectsize);
  47.     /* As above, but uses a size for the bigrect, for the new     */
  48.     /* redrawing method where the redrawer works relative to the     */
  49.     /* bottom-left of the rectblock.                */
  50.  
  51.  
  52.  
  53.  
  54. void Shell_CheckWindSizeAndRedraw( window_handle window, const wimp_rect *rect);
  55.     /* Checks that *rect is inside current size of window, and     */
  56.     /* resizes the window if nessary. Then does a Wimp_ForceRedraw     */
  57.     /* if any of rect is currently visible, or the window has been     */
  58.     /* resized.                            */
  59.     /* This is used by Shell_AddRectangle.                */
  60.  
  61. void Shell_CheckWindSizeAndRedrawAndScroll( window_handle window, const wimp_rect *rect);
  62.     /* As above, but also keeps scroll at lower limit if it is     */
  63.     /* already there                        */
  64.  
  65. void Shell_ResizeIconRect( Shell_rectblock *r);
  66.     /* Makes a rect's icon-rect the appropriate size    */
  67.     /* for the rect's rect. This function should be called    */
  68.     /* whenever a rect is resized.                */
  69.     /* When redrawing rects, the iconrect is checked     */
  70.     /* against the redraw rect so that any icon-border    */
  71.     /* is redrawn correctly.                */
  72.  
  73.  
  74.  
  75.  
  76. /* Low level routines for use in rectangle redrawing functions        */
  77. /* -----------------------------------------------------------        */
  78. /* They enable you to print text, fill rectangles etc inside windows,     */
  79. /* but without having to convert everything to screen coors.        */
  80.  
  81.  
  82. /* These next few functions/#defines are equivalent to GFX_ calls,     */
  83. /* except you pass them a convert_block, and they deal with the scroll    */
  84. /* bars, window position, etc.                        */
  85.  
  86.  
  87. #define Shell_ConvertXToScreen( xx, convert)    ( (xx) + (convert).x)
  88. #define Shell_ConvertYToScreen( yy, convert)    ( (yy) + (convert).y)
  89.  
  90. #define Shell_ConvertXToWorkarea( xx, convert)    ( (xx) - (convert).x)
  91. #define Shell_ConvertYToWorkarea( yy, convert)    ( (yy) - (convert).y)
  92.  
  93. #define Shell_ConvertRectToWorkarea( rect, convert)    {    \
  94.     (rect)->min.x -= (convert).x;                \
  95.     (rect)->max.x -= (convert).x;                \
  96.     (rect)->min.y -= (convert).y;                \
  97.     (rect)->max.y -= (convert).y;                \
  98.     }                            \
  99.  
  100. #define Shell_ConvertRectToScreen( rect, convert)    {    \
  101.     (rect)->min.x += (convert).x;                \
  102.     (rect)->max.x += (convert).x;                \
  103.     (rect)->min.y += (convert).y;                \
  104.     (rect)->max.y += (convert).y;                \
  105.     }                            \
  106.  
  107.  
  108. void    Shell_RectangleFill( const wimp_rect *rect, Shell_convertpoint convert);
  109.  
  110. void    Shell_RectangleFill3( int x, int y, int width, int height, Shell_convertpoint convert);
  111.  
  112. void    Shell_RectangleFill2( int xmin, int ymin, int xmax, int ymax, Shell_convertpoint convert);
  113.  
  114.  
  115.  
  116. #define Shell_RectangleFill_16bit( rect, convert)            \
  117.     GFX_RectangleFill(                    \
  118.         Shell_ConvertXToScreen( rect->min.x, convert),    \
  119.         Shell_ConvertYToScreen( rect->min.y, convert),    \
  120.         rect->max.x - rect->min.x,            \
  121.         rect->max.y - rect->min.y            \
  122.         )                        \
  123.  
  124.  
  125.  
  126. #define Shell_RectangleFill2_16bit( xmin, ymin, xmax, ymax, convert)    \
  127.     GFX_RectangleFill(                    \
  128.         Shell_ConvertXToScreen( xmin, convert),        \
  129.         Shell_ConvertYToScreen( ymin, convert),        \
  130.         xmax - xmin,                    \
  131.         ymax - ymin                    \
  132.         )                        \
  133.  
  134.  
  135. #define Shell_RectangleFill3_16bit( xmin, ymin, width, height, convert)    \
  136.     GFX_RectangleFill(                        \
  137.         Shell_ConvertXToScreen( xmin, convert),            \
  138.         Shell_ConvertYToScreen( ymin, convert),            \
  139.         width,                            \
  140.         height                            \
  141.         )                            \
  142.  
  143.  
  144.  
  145.  
  146. #define Shell_Draw2( x, y, convert)            \
  147.     GFX_Draw(                    \
  148.         Shell_ConvertXToScreen( x, convert),     \
  149.         Shell_ConvertYToScreen( y, convert)    \
  150.         )                    \
  151.  
  152. #define Shell_Move( x, y, convert)            \
  153.     GFX_Move(                    \
  154.         Shell_ConvertXToScreen( x, convert),     \
  155.         Shell_ConvertYToScreen( y, convert)    \
  156.         )                    \
  157.  
  158.  
  159.  
  160. #define Shell_PlotPoint( x, y, convert)            \
  161.     GFX_PlotPoint(                    \
  162.         Shell_ConvertXToScreen( x, convert),     \
  163.         Shell_ConvertYToScreen( y, convert)    \
  164.         )                    \
  165.  
  166.  
  167. #define Shell_Circle( x, y, r, convert)            \
  168.     GFX_Circle(                    \
  169.         Shell_ConvertXToScreen( x, convert),     \
  170.         Shell_ConvertYToScreen( y, convert),    \
  171.         r                    \
  172.         )                    \
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179. #define    Shell_Plot( plotcode, x, y, convert)    \
  180.     GFX_Plot(                \
  181.         plotcode,             \
  182.         Shell_ConvertXToScreen( x),    \
  183.         Shell_ConvertYToScreen( y)    \
  184.         )                \
  185.  
  186.     /* A general OS_Plot routine                    */
  187.  
  188.  
  189.  
  190.  
  191. void Shell_PrintString( const char *s, int x, int y, const Shell_convertpoint convert);
  192.     /* Low level non-wimp print routine to print text straight     */
  193.     /* onto screen. x and y should be in work-area coors.        */
  194.     /* Used in rectangle-redrawing routines to print text without     */
  195.     /* having to convert explicitly to screen coors.        */
  196.  
  197. void Shell_ConvertToSubRect( wimp_rect *rect, const wimp_rect *bigrect);
  198.  
  199. void Shell_ConvertToSubRect2( wimp_rect *rect, wimp_point bigsize);
  200.  
  201.  
  202.  
  203. #endif
  204.