3 * Copyright (C) 2005 A.J. van Os; Released under GNU GPL
6 * Include file to deal with drawfiles
9 * C header file for DrawFile
10 * written by DefMod (May 4 2004) on Tue May 4 13:34:17 2004
11 * Jonathan Coxhead, jonathan@doves.demon.co.uk, 21 Aug 1995
12 * OSLib---efficient, type-safe, transparent, extensible,
13 * register-safe A P I coverage of RISC O S
14 * Copyright (C) 1994 Jonathan Coxhead
16 * All credit should go to him, but all the bugs are mine
19 #if !defined(__drawfile_h)
22 #include "DeskLib:Sprite.h"
23 #include "DeskLib:Wimp.h"
31 /*********************
33 *********************/
34 #define Drawfile_DrawToScreen(i) ((i) / 256)
35 #define Drawfile_ScreenToDraw(i) ((i) * 256)
37 /**********************************
38 * SWI names and SWI reason codes *
39 **********************************/
40 #define DrawFile_Render 0x45540
41 #define DrawFile_BBox 0x45541
42 #define DrawFile_DeclareFonts 0x45542
47 typedef unsigned int bits
;
48 typedef unsigned char byte
;
50 typedef byte drawfile_fontref
;
52 typedef byte drawfile_path_style_flags
;
54 typedef bits drawfile_text_flags
;
56 typedef bits drawfile_render_flags
;
58 typedef bits drawfile_declare_fonts_flags
;
60 typedef bits drawfile_paper_options
;
62 typedef bits drawfile_entry_mode
;
65 drawfile_TYPE_FONT_TABLE
= 0,
66 drawfile_TYPE_TEXT
= 1,
67 drawfile_TYPE_PATH
= 2,
68 drawfile_TYPE_SPRITE
= 5,
69 drawfile_TYPE_GROUP
= 6,
70 drawfile_TYPE_TAGGED
= 7,
71 drawfile_TYPE_TEXT_AREA
= 9,
72 drawfile_TYPE_TEXT_COLUMN
= 10,
73 drawfile_TYPE_OPTIONS
= 11,
74 drawfile_TYPE_TRFM_TEXT
= 12,
75 drawfile_TYPE_TRFM_SPRITE
= 13,
76 drawfile_TYPE_JPEG
= 16
80 drawfile_PATH_END_PATH
= 0,
81 drawfile_PATH_CONTINUATION
= 1,
82 drawfile_PATH_MOVE_TO
= 2,
83 drawfile_PATH_SPECIAL_MOVE_TO
= 3,
84 drawfile_PATH_CLOSE_GAP
= 4,
85 drawfile_PATH_CLOSE_LINE
= 5,
86 drawfile_PATH_BEZIER_TO
= 6,
87 drawfile_PATH_GAP_TO
= 7,
88 drawfile_PATH_LINE_TO
= 8
107 drawfile_fontref font_ref
;
112 drawfile_fontref font_ref
;
114 } drawfile_text_style
;
117 drawfile_path_style_flags flags
;
121 } drawfile_path_style
;
124 drawfile_font_def font_def
[1];
125 } drawfile_font_table
;
130 palette_entry bg_hint
;
131 drawfile_text_style style
;
141 palette_entry outline
;
143 drawfile_path_style style
;
150 palette_entry outline
;
152 drawfile_path_style style
;
153 draw_dash_pattern pattern
;
155 } drawfile_path_with_pattern
;
159 sprite_header header
;
177 } drawfile_text_column
;
183 drawfile_text_column data
;
185 } drawfile_text_column_list
;
191 palette_entry bg_hint
;
193 } drawfile_area_text
;
197 drawfile_text_column_list header
;
198 drawfile_area_text area_text
;
199 } drawfile_text_area
;
204 drawfile_paper_options paper_options
;
216 drawfile_entry_mode entry_mode
;
223 drawfile_text_flags flags
;
225 palette_entry bg_hint
;
226 drawfile_text_style style
;
231 } drawfile_trfm_text
;
236 sprite_header header
;
238 } drawfile_trfm_sprite
;
251 /* ------------------------------------------------------------------------
252 * Type: drawfile_object
254 * Description: This type is used to declare pointers rather than objects
261 drawfile_font_table font_table
;
264 drawfile_path_with_pattern path_with_pattern
;
265 drawfile_sprite sprite
;
266 drawfile_group group
;
267 drawfile_tagged tagged
;
268 drawfile_text_column text_column
;
269 drawfile_text_area text_area
;
270 drawfile_options options
;
271 drawfile_trfm_text trfm_text
;
272 drawfile_trfm_sprite trfm_sprite
;
283 drawfile_object objects
[1];
286 typedef bits drawfile_bbox_flags
;
289 drawfile_object
*object
;
290 drawfile_diagram
*diagram
;
291 drawfile_object
*font_table
;
292 drawfile_declare_fonts_flags flags
;
294 } drawfile_declare_fonts_state
;
296 /************************
297 * Constant definitions *
298 ************************/
299 #define error_DRAW_FILE_NOT_DRAW 0x20C00u
300 #define error_DRAW_FILE_VERSION 0x20C01u
301 #define error_DRAW_FILE_FONT_TAB 0x20C02u
302 #define error_DRAW_FILE_BAD_FONT_NO 0x20C03u
303 #define error_DRAW_FILE_BAD_MODE 0x20C04u
304 #define error_DRAW_FILE_BAD_FILE 0x20C05u
305 #define error_DRAW_FILE_BAD_GROUP 0x20C06u
306 #define error_DRAW_FILE_BAD_TAG 0x20C07u
307 #define error_DRAW_FILE_SYNTAX 0x20C08u
308 #define error_DRAW_FILE_FONT_NO 0x20C09u
309 #define error_DRAW_FILE_AREA_VER 0x20C0Au
310 #define error_DRAW_FILE_NO_AREA_VER 0x20C0Bu
312 #define drawfile_PATH_MITRED ((drawfile_path_style_flags) 0x0u)
313 #define drawfile_PATH_ROUND ((drawfile_path_style_flags) 0x1u)
314 #define drawfile_PATH_BEVELLED ((drawfile_path_style_flags) 0x2u)
315 #define drawfile_PATH_BUTT ((drawfile_path_style_flags) 0x0u)
316 #define drawfile_PATH_SQUARE ((drawfile_path_style_flags) 0x2u)
317 #define drawfile_PATH_TRIANGLE ((drawfile_path_style_flags) 0x3u)
318 #define drawfile_PATH_JOIN_SHIFT 0
319 #define drawfile_PATH_JOIN ((drawfile_path_style_flags) 0x3u)
320 #define drawfile_PATH_END_SHIFT 2
321 #define drawfile_PATH_END ((drawfile_path_style_flags) 0xCu)
322 #define drawfile_PATH_START_SHIFT 4
323 #define drawfile_PATH_START ((drawfile_path_style_flags) 0x30u)
324 #define drawfile_PATH_WINDING_EVEN_ODD ((drawfile_path_style_flags) 0x40u)
325 #define drawfile_PATH_DASHED ((drawfile_path_style_flags) 0x80u)
326 #define drawfile_PATH_CAP_WIDTH_SHIFT 16
327 #define drawfile_PATH_CAP_WIDTH ((drawfile_path_style_flags) 0xFF0000u)
328 #define drawfile_PATH_CAP_LENGTH_SHIFT 24
329 #define drawfile_PATH_CAP_LENGTH ((drawfile_path_style_flags) 0xFF000000u)
330 #define drawfile_TEXT_KERN ((drawfile_text_flags) 0x1u)
331 #define drawfile_TEXT_RIGHT_TO_LEFT ((drawfile_text_flags) 0x2u)
332 #define drawfile_TEXT_UNDERLINE ((drawfile_text_flags) 0x4u)
333 #define drawfile_RENDER_BBOXES ((drawfile_render_flags) 0x1u)
334 #define drawfile_RENDER_SUPPRESS ((drawfile_render_flags) 0x2u)
335 #define drawfile_RENDER_GIVEN_FLATNESS ((drawfile_render_flags) 0x4u)
336 #define drawfile_RENDER_GIVEN_COLOUR_MAPPING ((drawfile_render_flags) 0x8u)
337 #define drawfile_NO_DOWNLOAD ((drawfile_declare_fonts_flags) 0x1u)
338 #define drawfile_PAPER_SHOW ((drawfile_paper_options) 0x1u)
339 #define drawfile_PAPER_LANDSCAPE ((drawfile_paper_options) 0x10u)
340 #define drawfile_PAPER_DEFAULT ((drawfile_paper_options) 0x100u)
341 #define drawfile_ENTRY_MODE_LINE ((drawfile_entry_mode) 0x1u)
342 #define drawfile_ENTRY_MODE_CLOSED_LINE ((drawfile_entry_mode) 0x2u)
343 #define drawfile_ENTRY_MODE_CURVE ((drawfile_entry_mode) 0x4u)
344 #define drawfile_ENTRY_MODE_CLOSED_CURVE ((drawfile_entry_mode) 0x8u)
345 #define drawfile_ENTRY_MODE_RECTANGLE ((drawfile_entry_mode) 0x10u)
346 #define drawfile_ENTRY_MODE_ELLIPSE ((drawfile_entry_mode) 0x20u)
347 #define drawfile_ENTRY_MODE_TEXT_LINE ((drawfile_entry_mode) 0x40u)
348 #define drawfile_ENTRY_MODE_SELECT ((drawfile_entry_mode) 0x80u)
350 /*************************
351 * Function declarations *
352 *************************/
354 #if defined(__cplusplus)
356 #endif /* __cplusplus */
358 /* ------------------------------------------------------------------------
359 * Function: drawfile_render()
361 * Description: Calls SWI 0x45540
363 * Input: flags - value of R0 on entry
364 * diagram - value of R1 on entry
365 * size - value of R2 on entry
366 * trfm - value of R3 on entry
367 * clip - value of R4 on entry
368 * flatness - value of R5 on entry
371 extern os_error
*Drawfile_Render (drawfile_render_flags flags
,
372 drawfile_diagram
const *diagram
,
375 wimp_box
const *clip
,
378 /* ------------------------------------------------------------------------
379 * Function: drawfile_bbox()
381 * Description: Calls SWI 0x45541
383 * Input: flags - value of R0 on entry
384 * diagram - value of R1 on entry
385 * size - value of R2 on entry
386 * trfm - value of R3 on entry
387 * bbox - value of R4 on entry
390 extern os_error
*Drawfile_Bbox (drawfile_bbox_flags flags
,
391 drawfile_diagram
const *diagram
,
396 /* ------------------------------------------------------------------------
397 * Function: Drawfile_DeclareFonts()
399 * Description: Calls SWI 0x45542
401 * Input: flags - value of R0 on entry
402 * diagram - value of R1 on entry
403 * size - value of R2 on entry
406 extern os_error
*Drawfile_DeclareFonts (drawfile_declare_fonts_flags flags
,
407 drawfile_diagram
const *diagram
,
410 /* ------------------------------------------------------------------------
411 * Function: Drawfile_CreateDiagram()
415 extern os_error
* Drawfile_CreateDiagram(drawfile_info
*info
, size_t memory
,
416 const char *creator
, wimp_box box
);
418 extern os_error
*Drawfile_AppendObject(drawfile_info
*info
, size_t memory
,
419 const drawfile_object
*object
, BOOL rebind
);
421 extern os_error
*Drawfile_RenderDiagram(drawfile_info
*info
,
422 window_redrawblock
*redraw
, double scale
);
424 extern os_error
*Drawfile_VerifyDiagram(drawfile_info
*info
);
426 extern void Drawfile_QueryBox(drawfile_info
*info
,
427 wimp_box
*rect
, BOOL screenUnits
);
429 #if defined(__cplusplus)
431 #endif /* __cplusplus */
433 #endif /* __drawfile.h */