home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / oslib / h / draw < prev    next >
Encoding:
Text File  |  1994-09-07  |  11.9 KB  |  365 lines

  1. #ifndef draw_H
  2. #define draw_H
  3.  
  4. /* C header file for Draw
  5.  * written by DefMod (Sep  7 1994) on Wed Sep  7 21:24:39 1994
  6.  * Copyright © Acorn Computers Ltd, 1994
  7.  */
  8.  
  9. /*************************************************************************
  10.  * This source file was written by Acorn Computers Limited. It is part   *
  11.  * of the OSLib library for writing applications for RISC OS. It may be  *
  12.  * used freely in the creation of programs for RISC OS.                  *
  13.  *************************************************************************/
  14.  
  15. #ifndef types_H
  16.    #include "types.h"
  17. #endif
  18.  
  19. #ifndef os_H
  20.    #include "os.h"
  21. #endif
  22.  
  23. /**********************************
  24.  * SWI names and SWI reason codes *
  25.  **********************************/
  26. #undef  Draw_ProcessPath
  27. #define Draw_ProcessPath                        0x40700
  28. #undef  XDraw_ProcessPath
  29. #define XDraw_ProcessPath                       0x60700
  30. #undef  Draw_Fill
  31. #define Draw_Fill                               0x40702
  32. #undef  XDraw_Fill
  33. #define XDraw_Fill                              0x60702
  34. #undef  Draw_Stroke
  35. #define Draw_Stroke                             0x40704
  36. #undef  XDraw_Stroke
  37. #define XDraw_Stroke                            0x60704
  38. #undef  Draw_StrokePath
  39. #define Draw_StrokePath                         0x40706
  40. #undef  XDraw_StrokePath
  41. #define XDraw_StrokePath                        0x60706
  42. #undef  Draw_FlattenPath
  43. #define Draw_FlattenPath                        0x40708
  44. #undef  XDraw_FlattenPath
  45. #define XDraw_FlattenPath                       0x60708
  46. #undef  Draw_TransformPath
  47. #define Draw_TransformPath                      0x4070A
  48. #undef  XDraw_TransformPath
  49. #define XDraw_TransformPath                     0x6070A
  50. #undef  DrawV
  51. #define DrawV                                   0x20
  52.  
  53. /************************************
  54.  * Structure and union declarations *
  55.  ************************************/
  56. typedef struct draw_path_element                draw_path_element;
  57. typedef struct draw_line_style                  draw_line_style;
  58. typedef struct draw_dash_pattern                draw_dash_pattern;
  59. typedef struct draw_path                        draw_path;
  60.  
  61. /********************
  62.  * Type definitions *
  63.  ********************/
  64. struct draw_path_element
  65.    {  int tag;
  66.       union
  67.       {  int end_path;
  68.          draw_path_element *continuation;
  69.          os_coord move_to;
  70.          os_coord special_move_to;
  71.          os_coord bezier_to [3];
  72.          os_coord gap_to;
  73.          os_coord line_to;
  74.       }
  75.       data;
  76.    };
  77.  
  78. typedef bits draw_fill_style;
  79.  
  80. struct draw_line_style
  81.    {  byte join_style;
  82.       byte end_cap_style;
  83.       byte start_cap_style;
  84.       byte reserved;
  85.       int mitre_limit;
  86.       short start_cap_width;
  87.       short start_cap_length;
  88.       short end_cap_width;
  89.       short end_cap_length;
  90.    };
  91.  
  92. struct draw_dash_pattern
  93.    {  int start;
  94.       int element_count;
  95.       int elements [UNKNOWN];
  96.    };
  97.  
  98. #define draw_DASH_PATTERN(N) \
  99.    struct \
  100.       {  int start; \
  101.          int element_count; \
  102.          int elements [N]; \
  103.       }
  104.  
  105. #define draw_SIZEOF_DASH_PATTERN(N) \
  106.    (offsetof (draw_dash_pattern, elements) + \
  107.          (N)*sizeof ((draw_dash_pattern *) NULL)->elements)
  108.  
  109. struct draw_path
  110.    {  draw_path_element elements [UNKNOWN];
  111.    };
  112.  
  113. /************************
  114.  * Constant definitions *
  115.  ************************/
  116. #define draw_OS_UNIT                            256
  117. #define draw_INCH                               46080
  118. #define draw_POINT                              640
  119. #define draw_END_PATH                           0
  120. #define draw_CONTINUATION                       1
  121. #define draw_MOVE_TO                            2
  122. #define draw_SPECIAL_MOVE_TO                    3
  123. #define draw_CLOSE_GAP                          4
  124. #define draw_CLOSE_LINE                         5
  125. #define draw_BEZIER_TO                          6
  126. #define draw_GAP_TO                             7
  127. #define draw_LINE_TO                            8
  128. #define draw_FILL_NONZERO                       0
  129. #define draw_FILL_NEGATIVE                      1
  130. #define draw_FILL_EVEN_ODD                      2
  131. #define draw_FILL_POSITIVE                      3
  132. #define draw_FILL_WINDING_RULE_SHIFT            0
  133. #define draw_FILL_WINDING_RULE                  0x3u
  134. #define draw_FILL_FULL_EXTERIOR                 0x4u
  135. #define draw_FILL_EXTERIOR_BOUNDARY             0x8u
  136. #define draw_FILL_INTERIOR_BOUNDARY             0x10u
  137. #define draw_FILL_FULL_INTERIOR                 0x20u
  138. #define draw_FILL_CLOSE_OPEN_SUBPATHS           0x8000000u
  139. #define draw_FILL_FLATTEN                       0x10000000u
  140. #define draw_FILL_THICKEN                       0x20000000u
  141. #define draw_FILL_REFLATTEN                     0x40000000u
  142. #define draw_FILL_FLOAT                         0x80000000u
  143. #define draw_JOIN_MITRED                        0
  144. #define draw_JOIN_ROUND                         1
  145. #define draw_JOIN_BEVELLED                      2
  146. #define draw_CAP_BUTT                           0
  147. #define draw_CAP_ROUND                          1
  148. #define draw_CAP_SQUARE                         2
  149. #define draw_CAP_TRIANGULAR                     3
  150. #define draw_SPECIAL_IN_SITU                    0
  151. #define draw_SPECIAL_FILL                       1
  152. #define draw_SPECIAL_FILL_BY_SUBPATHS           2
  153. #define draw_SPECIAL_COUNT                      3
  154. #define error_DRAW_NO_DRAW_IN_IRQ_MODE          0x980u
  155. #define error_DRAW_BAD_DRAW_REASON_CODE         0x981u
  156. #define error_DRAW_RESERVED_DRAW_BITS           0x982u
  157. #define error_DRAW_INVALID_DRAW_ADDRESS         0x983u
  158. #define error_DRAW_BAD_PATH_ELEMENT             0x984u
  159. #define error_DRAW_BAD_PATH_SEQUENCE            0x985u
  160. #define error_DRAW_MAY_EXPAND_PATH              0x986u
  161. #define error_DRAW_PATH_FULL                    0x987u
  162. #define error_DRAW_PATH_NOT_FLAT                0x988u
  163. #define error_DRAW_BAD_CAPS_OR_JOINS            0x989u
  164. #define error_DRAW_TRANSFORM_OVERFLOW           0x98Au
  165. #define error_DRAW_DRAW_NEEDS_GRAPHICS_MODE     0x98Bu
  166. #define error_DRAW_UNIMPLEMENTED_DRAW           0x9FFu
  167.  
  168. /*************************
  169.  * Function declarations *
  170.  *************************/
  171.  
  172. #ifdef __cplusplus
  173.    extern "C" {
  174. #endif
  175.  
  176. /*************************************************************
  177.  * NOTE: The following functions provide direct access to    *
  178.  *       the SWI's noted in the function description.        *
  179.  *       Please read the relevant PRM section for more       *
  180.  *       information on their input/output parameters.       *
  181.  *************************************************************/
  182.  
  183. /* ------------------------------------------------------------------------
  184.  * Function:      draw_process_path()
  185.  *
  186.  * Description:   Main Draw SWI
  187.  *
  188.  * Input:         path - value of R0 on entry
  189.  *                fill_style - value of R1 on entry
  190.  *                trfm - value of R2 on entry
  191.  *                flatness - value of R3 on entry
  192.  *                thickness - value of R4 on entry
  193.  *                line_style - value of R5 on entry
  194.  *                dash_pattern - value of R6 on entry
  195.  *                processed_path - value of R7 on entry
  196.  *
  197.  * Output:        end_or_used - value of R0 on exit (X version only)
  198.  *
  199.  * Returns:       R0 (non-X version only)
  200.  *
  201.  * Other notes:   Calls SWI 0x40700.
  202.  */
  203.  
  204. extern os_error *xdraw_process_path (draw_path *path,
  205.       draw_fill_style fill_style,
  206.       os_trfm *trfm,
  207.       int flatness,
  208.       int thickness,
  209.       draw_line_style *line_style,
  210.       draw_dash_pattern *dash_pattern,
  211.       draw_path *processed_path,
  212.       byte **end_or_used);
  213. extern byte *draw_process_path (draw_path *path,
  214.       draw_fill_style fill_style,
  215.       os_trfm *trfm,
  216.       int flatness,
  217.       int thickness,
  218.       draw_line_style *line_style,
  219.       draw_dash_pattern *dash_pattern,
  220.       draw_path *processed_path);
  221.  
  222. /* ------------------------------------------------------------------------
  223.  * Function:      draw_fill()
  224.  *
  225.  * Description:   Processes a path and sends it to the VDU, filling the
  226.  *                interior portion
  227.  *
  228.  * Input:         path - value of R0 on entry
  229.  *                fill_style - value of R1 on entry
  230.  *                trfm - value of R2 on entry
  231.  *                flatness - value of R3 on entry
  232.  *
  233.  * Other notes:   Calls SWI 0x40702.
  234.  */
  235.  
  236. extern os_error *xdraw_fill (draw_path *path,
  237.       draw_fill_style fill_style,
  238.       os_trfm *trfm,
  239.       int flatness);
  240. extern void draw_fill (draw_path *path,
  241.       draw_fill_style fill_style,
  242.       os_trfm *trfm,
  243.       int flatness);
  244.  
  245. /* ------------------------------------------------------------------------
  246.  * Function:      draw_stroke()
  247.  *
  248.  * Description:   Processes a path and sends it to the VDU
  249.  *
  250.  * Input:         path - value of R0 on entry
  251.  *                fill_style - value of R1 on entry
  252.  *                trfm - value of R2 on entry
  253.  *                flatness - value of R3 on entry
  254.  *                thickness - value of R4 on entry
  255.  *                line_style - value of R5 on entry
  256.  *                dash_pattern - value of R6 on entry
  257.  *
  258.  * Other notes:   Calls SWI 0x40704.
  259.  */
  260.  
  261. extern os_error *xdraw_stroke (draw_path *path,
  262.       draw_fill_style fill_style,
  263.       os_trfm *trfm,
  264.       int flatness,
  265.       int thickness,
  266.       draw_line_style *line_style,
  267.       draw_dash_pattern *dash_pattern);
  268. extern void draw_stroke (draw_path *path,
  269.       draw_fill_style fill_style,
  270.       os_trfm *trfm,
  271.       int flatness,
  272.       int thickness,
  273.       draw_line_style *line_style,
  274.       draw_dash_pattern *dash_pattern);
  275.  
  276. /* ------------------------------------------------------------------------
  277.  * Function:      draw_stroke_path()
  278.  *
  279.  * Description:   Processes a path and writes its output to another path
  280.  *
  281.  * Input:         path - value of R0 on entry
  282.  *                stroked_path - value of R1 on entry
  283.  *                trfm - value of R2 on entry
  284.  *                flatness - value of R3 on entry
  285.  *                thickness - value of R4 on entry
  286.  *                line_style - value of R5 on entry
  287.  *                dash_pattern - value of R6 on entry
  288.  *
  289.  * Output:        end_or_used - value of R0 on exit (X version only)
  290.  *
  291.  * Returns:       R0 (non-X version only)
  292.  *
  293.  * Other notes:   Calls SWI 0x40706.
  294.  */
  295.  
  296. extern os_error *xdraw_stroke_path (draw_path *path,
  297.       draw_path *stroked_path,
  298.       os_trfm *trfm,
  299.       int flatness,
  300.       int thickness,
  301.       draw_line_style *line_style,
  302.       draw_dash_pattern *dash_pattern,
  303.       byte **end_or_used);
  304. extern byte *draw_stroke_path (draw_path *path,
  305.       draw_path *stroked_path,
  306.       os_trfm *trfm,
  307.       int flatness,
  308.       int thickness,
  309.       draw_line_style *line_style,
  310.       draw_dash_pattern *dash_pattern);
  311.  
  312. /* ------------------------------------------------------------------------
  313.  * Function:      draw_flatten_path()
  314.  *
  315.  * Description:   Flattens a path and writes its output to another path
  316.  *
  317.  * Input:         path - value of R0 on entry
  318.  *                flattened_path - value of R1 on entry
  319.  *                flatness - value of R2 on entry
  320.  *
  321.  * Output:        end_or_used - value of R0 on exit (X version only)
  322.  *
  323.  * Returns:       R0 (non-X version only)
  324.  *
  325.  * Other notes:   Calls SWI 0x40708.
  326.  */
  327.  
  328. extern os_error *xdraw_flatten_path (draw_path *path,
  329.       draw_path *flattened_path,
  330.       int flatness,
  331.       byte **end_or_used);
  332. extern byte *draw_flatten_path (draw_path *path,
  333.       draw_path *flattened_path,
  334.       int flatness);
  335.  
  336. /* ------------------------------------------------------------------------
  337.  * Function:      draw_transform_path()
  338.  *
  339.  * Description:   Transforms a path and writes its output to another path
  340.  *
  341.  * Input:         path - value of R0 on entry
  342.  *                transformed_path - value of R1 on entry
  343.  *                trfm - value of R2 on entry
  344.  *
  345.  * Output:        end_or_used - value of R0 on exit (X version only)
  346.  *
  347.  * Returns:       R0 (non-X version only)
  348.  *
  349.  * Other notes:   Calls SWI 0x4070A with R3 = 0x0.
  350.  */
  351.  
  352. extern os_error *xdraw_transform_path (draw_path *path,
  353.       draw_path *transformed_path,
  354.       os_trfm *trfm,
  355.       byte **end_or_used);
  356. extern byte *draw_transform_path (draw_path *path,
  357.       draw_path *transformed_path,
  358.       os_trfm *trfm);
  359.  
  360. #ifdef __cplusplus
  361.    }
  362. #endif
  363.  
  364. #endif
  365.