home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / languages / progs / shell / Sources / c / Misc < prev    next >
Encoding:
Text File  |  1994-06-25  |  3.9 KB  |  177 lines

  1. #include <stdarg.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. #include "DeskLib:GFX.h"
  7. #include "DeskLib:Coord.h"
  8. #include "DeskLib:WimpSWIs.h"
  9. #include "DeskLib:Error.h"
  10.  
  11. #include "Shell.Extra.h"
  12.  
  13.  
  14.  
  15. #define _PLOT_MAX 16384
  16.  
  17.  
  18. char Shell_string[ 1 + Shell_stringMAX];
  19.  
  20.  
  21. void    Shell_ConvertToTextRect( wimp_rect *rect)
  22. {    int    y;
  23.  
  24. rect->min.x = rect->min.x / Shell_TEXTXSIZE;
  25. rect->max.x = rect->max.x / Shell_TEXTXSIZE;
  26.  
  27. y        = rect->min.y;
  28. rect->min.y    = ( 0 - rect->max.y) / Shell_TEXTYSIZE;
  29. rect->max.y    = ( 0 - y          ) / Shell_TEXTYSIZE;
  30. }
  31.  
  32.  
  33.  
  34.  
  35.  
  36. void Shell_ConvertToSubRect( wimp_rect *rect, const wimp_rect *bigrect)
  37. {
  38. Shell_MakeGE( rect->min.x, bigrect->min.x);
  39. Shell_MakeGE( rect->min.y, bigrect->min.y);
  40. Shell_MakeLE( rect->max.x, bigrect->max.x);
  41. Shell_MakeLE( rect->max.y, bigrect->max.y);
  42.  
  43. rect->min.x -= bigrect->min.x;
  44. rect->max.x -= bigrect->min.x + 1;
  45. rect->min.y -= bigrect->min.y;
  46. rect->max.y -= bigrect->min.y + 1;
  47.  
  48. return;
  49. }
  50.  
  51.  
  52.  
  53. void Shell_ConvertToSubRect2( wimp_rect *rect, wimp_point bigsize)
  54. {
  55. Shell_MakeGE( rect->min.x, 0);
  56. Shell_MakeGE( rect->min.y, 0);
  57. Shell_MakeLE( rect->max.x, bigsize.x);
  58. Shell_MakeLE( rect->max.y, bigsize.y);
  59.  
  60. rect->max.x -= 1;
  61. rect->max.y -= 1;
  62.  
  63. return;
  64. }
  65.  
  66.  
  67.  
  68.  
  69.  
  70. void    Shell_PrintString( const char *s, int x, int y, const Shell_convertpoint convert)
  71. {
  72. x = Shell_ConvertXToScreen( x, convert);
  73. y = Shell_ConvertYToScreen( y, convert);
  74. GFX_Move( x, y-Shell_PIXELYSIZE);
  75. GFX_Write0( (char *) s);
  76. }
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83. void    Shell_RectangleFill( const wimp_rect *rect, Shell_convertpoint convert)
  84. {    wimp_rect    rect2    = *rect;
  85. Shell_ConvertRectToScreen( &rect2, convert);
  86.  
  87. /*    OS_Plot expects 16 bit numbers    */
  88. Shell_MakeGE( rect2.min.x, -_PLOT_MAX);
  89. Shell_MakeGE( rect2.min.y, -_PLOT_MAX);
  90. Shell_MakeLE( rect2.max.x, _PLOT_MAX);
  91. Shell_MakeLE( rect2.max.y, _PLOT_MAX);
  92.  
  93. /* the '-Shell_PIXELYSIZE's are to exclude the top and right edges, as in Wimp_ForceRedraw etc. */
  94. GFX_RectangleFill(
  95.     rect2.min.x,
  96.     rect2.min.y,
  97.     rect2.max.x - rect2.min.x - Shell_PIXELYSIZE,
  98.     rect2.max.y - rect2.min.y - Shell_PIXELYSIZE
  99.     );
  100. }
  101.  
  102.  
  103.  
  104.  
  105.  
  106. void    Shell_RectangleFill2( int xmin, int ymin, int xmax, int ymax,
  107.     const Shell_convertpoint convert)
  108. {
  109. xmin = Shell_ConvertXToScreen( xmin, convert);
  110. ymin = Shell_ConvertYToScreen( ymin, convert);
  111. xmax = Shell_ConvertXToScreen( xmax, convert);
  112. ymax = Shell_ConvertYToScreen( ymax, convert);
  113.  
  114. /*    OS_Plot expects 16 bit numbers    */
  115. Shell_MakeGE( xmin, -_PLOT_MAX);
  116. Shell_MakeGE( ymin, -_PLOT_MAX);
  117. Shell_MakeLE( xmax, _PLOT_MAX);
  118. Shell_MakeLE( ymax, _PLOT_MAX);
  119.  
  120. GFX_RectangleFill( xmin, ymin, xmax-xmin-Shell_PIXELYSIZE, ymax-ymin-Shell_PIXELYSIZE);
  121. }
  122.  
  123.  
  124.  
  125.  
  126.  
  127. void    Shell_RectangleFill3( int x, int y, int width, int height,
  128.     Shell_convertpoint convert)
  129. {
  130. x = Shell_ConvertXToScreen( x, convert);
  131. y = Shell_ConvertYToScreen( y, convert);
  132.  
  133. /*    OS_Plot expects 16 bit numbers    */
  134. Shell_MakeGE( x, -_PLOT_MAX);
  135. Shell_MakeGE( y, -_PLOT_MAX);
  136. Shell_MakeLE( x, _PLOT_MAX);
  137. Shell_MakeLE( y, _PLOT_MAX);
  138.  
  139. GFX_RectangleFill( x, y, width, height);
  140. }
  141.  
  142.  
  143.  
  144.  
  145. void    Shell_ConvertToSubTextRect( wimp_rect *rect, const wimp_rect *bigrect)
  146. {
  147. Shell_MakeGE( rect->min.x, bigrect->min.x);
  148. Shell_MakeGE( rect->min.y, bigrect->min.y);
  149. Shell_MakeLE( rect->max.x, bigrect->max.x);
  150. Shell_MakeLE( rect->max.y, bigrect->max.y);
  151. rect->min.x = (rect->min.x - bigrect->min.x   ) / Shell_TEXTXSIZE;
  152. rect->max.x = (rect->max.x - bigrect->min.x -1) / Shell_TEXTXSIZE;
  153.     {    int y = rect->min.y;
  154.     rect->min.y = ( bigrect->max.y - rect->max.y ) / Shell_TEXTYSIZE;
  155.     rect->max.y = ( bigrect->max.y - y - 1       ) / Shell_TEXTYSIZE;
  156.     }
  157. return;
  158. }
  159.  
  160. void    Shell_ConvertToSubTextRect2( wimp_rect *rect, wimp_point rectsize)
  161. {
  162. Shell_MakeGE( rect->min.x, 0);
  163. Shell_MakeGE( rect->min.y, 0);
  164. Shell_MakeLE( rect->max.x, rectsize.x);
  165. Shell_MakeLE( rect->max.y, rectsize.y);
  166.  
  167. rect->min.x = rect->min.x / Shell_TEXTXSIZE;
  168. rect->max.x = (rect->max.x - 1) / Shell_TEXTXSIZE;
  169.  
  170.     {    int y = rect->min.y;
  171.     rect->min.y = ( rectsize.y - rect->max.y ) / Shell_TEXTYSIZE;
  172.     rect->max.y = ( rectsize.y - y - 1       ) / Shell_TEXTYSIZE;
  173.     }
  174. return;
  175. }
  176.  
  177.