1 /*
2 Copyright (C) 2018-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: WxdkdrawTypes.cpt
12 */
13 
14 #ifndef WXDKDRAWTYPES_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define WXDKDRAWTYPES_H_INCLUDED 1
17 
18 
19 /**	@file	WxdkdrawTypes.h	Data types for the wxd2lat program.
20 
21 	Here we have Wxd_... structures corresponding to the wxd_...
22 	structures from the wxd2lat/wxdtypes.h file.
23 */
24 
25 #ifndef	DK4CONF_H_INCLUDED
26 #include "dk4conf.h"
27 #endif
28 
29 #ifndef	DK4TYPES_H_INCLUDED
30 #include <libdk4base/dk4types.h>
31 #endif
32 
33 #ifndef	DK4BB_H_INCLUDED
34 #include <libdk4gra/dk4bb.h>
35 #endif
36 
37 
38 
39 #if	(DK4_HAVE_WXWIDGETS) && (defined(__cplusplus))
40 
41 
42 #ifndef	WX_WXPREC_H_INCLUDED
43 #include <wx/wxprec.h>
44 #define	WX_WXPREC_H_INCLUDED 1
45 #endif
46 #ifdef __BORLANDC__
47 #pragma hdrstop
48 #endif
49 #ifndef WX_PRECOMP
50 #if	DK4_HAVE_WX_CHARTYPE_H
51 #ifndef	WX_CHARTYPE_H_INCLUDED
52 #include <wx/chartype.h>
53 #define	WX_CHARTYPE_H_INCLUDED 1
54 #endif
55 #else
56 #if	DK4_HAVE_WX_WXCHAR_H
57 #ifndef	WX_WXCHAR_H_INCLUDED
58 #include <wx/wxchar.h>
59 #define	WX_WXCHAR_H_INCLUDED 1
60 #endif
61 #else
62 #ifndef	WX_WX_H_INCLUDED
63 #include <wx/wx.h>
64 #define	WX_WX_H_INCLUDED
65 #endif
66 #endif
67 #endif
68 #endif
69 
70 #ifndef	WX_BITMAP_H_INCLUDED
71 #include <wx/bitmap.h>
72 #define	WX_BITMAP_H_INCLUDED	1
73 #endif
74 
75 #ifndef	DK4STO_H_INCLUDED
76 #include <libdk4c/dk4sto.h>
77 #endif
78 
79 
80 /**	Marker 1: Mouse moved over object or object selected
81 	for copy/move/delete.
82 	Indicated by coloured markup.
83 */
84 #define	OBJ_MARKER_1	((uint8_t)1U)
85 
86 /**	Marker 2: Object selected for grouping or style editing.
87 	Indicated by black markup.
88 */
89 #define	OBJ_MARKER_2	((uint8_t)2U)
90 
91 
92 
93 /**	WXD font description.
94 */
95 typedef struct {
96 	wxFont			*font;		/**< Font to be used for drawing. */
97 	uint16_t		 fsz;		/**< Font size in pt. */
98 	uint8_t			 find;		/**< Font index. */
99 	bool			 used;		/**< Font is used by drawing. */
100 	bool			 attempted;	/**< Already attempted to find font. */
101 } Wxd_font_t;
102 
103 
104 
105 /**	Association of file name suffix and image type.
106 */
107 typedef struct {
108 	wxChar const	*suffix;	/**< File name suffix. */
109 	wxBitmapType	 t;			/**< Corresponding image type. */
110 } Wxd_suffix_and_type_t;
111 
112 
113 
114 /**	Polygon or polyline point.
115 */
116 typedef struct {
117 	int32_t		x;	/**< X position. */
118 	int32_t		y;	/**< Y position. */
119 } Wxd_point_t;
120 
121 
122 
123 /**	X-Spline point.
124 */
125 typedef struct {
126 	double		s;	/**< S parameter. */
127 	int32_t		x;	/**< X position. */
128 	int32_t		y;	/**< Y position. */
129 } Wxd_spline_point_t;
130 
131 
132 
133 /**	Bounding box values.
134 */
135 typedef struct {
136 	int32_t			 xl;		/**< Left x. */
137 	int32_t			 xr;		/**< Right x. */
138 	int32_t			 yb;		/**< Bottom y. */
139 	int32_t			 yt;		/**< Top y. */
140 } Wxd_bb_t;
141 
142 
143 
144 #define	WXD_TEXT_FLAG_NONE		((uint8_t)0U)
145 #define	WXD_TEXT_FLAG_LATEX		((uint8_t)1U)
146 
147 #define	WXD_TEXT_ALIGN_LEFT		((uint8_t)0U)
148 #define	WXD_TEXT_ALIGN_CENTERED	((uint8_t)1U)
149 #define	WXD_TEXT_ALIGN_RIGHT	((uint8_t)2U)
150 
151 /**	Details for a text.
152 	The 4 most significant bits in al represent the vertical
153 	text alignment, the 4 least significant bits represent the
154 	horizontal alignment.
155 */
156 typedef struct {
157 	wxChar		*t;		/**< Text to export. */
158 	wxChar		*tsc;	/**< Text to show on screen. */
159 	Wxd_font_t	*font;	/**< WXD font structure. */
160 	int32_t		 x;		/**< X position. */
161 	int32_t		 y;		/**< Y position. */
162 	uint16_t	 fsz;	/**< Font size. */
163 	int16_t		 a;		/**< Rotation counterclockwise in degree. */
164 	uint8_t		 find;	/**< Font index. */
165 	uint8_t		 al;	/**< Horizontal and vertical align. */
166 	uint8_t		 fl;	/**< Text flags. */
167 } Wxd_det_text_t;
168 
169 
170 
171 /**	Polygon and polyline details.
172 */
173 typedef struct {
174 	Wxd_point_t			*p;	/**< Points. */
175 	uint16_t			 n;	/**< Number of points. */
176 } Wxd_det_pl_t;
177 
178 
179 
180 /**	X-Spline details (opened and closed).
181 */
182 typedef struct {
183 	Wxd_spline_point_t	*p;	/**< Points. */
184 	uint16_t			 n;	/**< Number of points. */
185 } Wxd_det_xs_t;
186 
187 
188 
189 
190 #define	WXD_ARC_DIRECTION_POSITIVE	((int8_t)1)
191 #define	WXD_ARC_DIRECTION_NEGATIVE	((int8_t)-1)
192 #define	WXD_ARC_DIRECTION_UNKNOWN	((int8_t)0)
193 
194 /**	Details for arcs (opened and closed).
195 	The x1, y1, x2, y2, x3, y3 components are read from file, the
196 	other values are calculated from the 3 points after reading
197 	the file and after each point modification.
198 */
199 typedef struct {
200 	double		a;	/**< Start angle alpha counterclockwise in degree. */
201 	double		b;	/**< Angle range beta counterclockwise in degree. */
202 	double		x;	/**< X position of center point. */
203 	double		y;	/**< Y position of center point. */
204 	double		r;	/**< Radius. */
205 	int32_t		x1;	/**< X position of point 1. */
206 	int32_t		y1;	/**< Y position of point 1. */
207 	int32_t		x2;	/**< X position of point 2. */
208 	int32_t		y2;	/**< Y position of point 2. */
209 	int32_t		x3;	/**< X position of point 3. */
210 	int32_t		y3;	/**< Y position of point 3. */
211 	int8_t		d;	/**< Direction, 1=positive, -1=negative, 0=unknown. */
212 } Wxd_det_arc_t;
213 
214 
215 /**	Details for dot.
216 */
217 typedef struct {
218 	int32_t		x;	/**< X position of center point. */
219 	int32_t		y;	/**< Y position of center point. */
220 	uint16_t	d;	/**< Diameter in multiples of the base line width. */
221 } Wxd_det_dot_t;
222 
223 
224 /**	Details for an ellipse or circle.
225 	For a circle ry and a are ignored.
226 */
227 typedef struct {
228 	int32_t		x;	/**< X position of center point. */
229 	int32_t		y;	/**< Y position of center point. */
230 	uint32_t	rx;	/**< X radius for ellipse, radius for circle. */
231 	uint32_t	ry;	/**< Y radius for ellipse. */
232 	int16_t		a;	/**< Rotation counterclockwise in degree. */
233 } Wxd_det_ellipse_t;
234 
235 
236 /**	Radius value to indicate corner is not rounded.
237 */
238 #define	WXD_BOX_CORNER_NONE	((uint32_t)0UL)
239 
240 /**	Details for a box.
241 */
242 typedef struct {
243 	Wxd_bb_t	b;	/**< Box rectangle. */
244 	uint32_t	r;	/**< Corner radius, 0 for no rounded corner. */
245 } Wxd_det_box_t;
246 
247 
248 
249 /**	Details for an embedded image.
250 */
251 typedef struct {
252 	wxChar		*fn;	/**< File name for image. */
253 	wxBitmap	*bm;	/**< Bitmap to draw on screen. */
254 	dk4_bb_t	 pl;	/**< Calculated coordinates for placement. */
255 	Wxd_bb_t	 br;	/**< Box rectangle from file. */
256 	double		 xres;	/**< Image x resolution. */
257 	double		 yres;	/**< Image y resolution. */
258 	uint16_t 	 fl;	/**< Image flags. */
259 	int8_t	 	 r2g;	/**< RGB to gray conversion method. */
260 	int8_t		 r2c;	/**< RGB to CMYK conversion method (unused). */
261 	wxBitmapType t;		/**< Bitmap type. */
262 } Wxd_det_image_t;
263 
264 
265 
266 /**	Details for a group of objects.
267 */
268 typedef struct Wxd_det_group__t {
269 	dk4_sto_t				*s_e;	/**< Elements storage. */
270 	dk4_sto_it_t			*i_e;	/**< Elements iterator. */
271 } Wxd_det_group_t;
272 
273 
274 
275 /**	Union of different details.
276 */
277 typedef union {
278 	Wxd_det_text_t		t;	/**< Text details. */
279 	Wxd_det_pl_t		p;	/**< Polygon and polyline details. */
280 	Wxd_det_xs_t		s;	/**< Spline details. */
281 	Wxd_det_arc_t		a;	/**< Arc and circle details. */
282 	Wxd_det_dot_t		d;	/**< Details for a dot. */
283 	Wxd_det_ellipse_t	e;	/**< Ellipse details. */
284 	Wxd_det_box_t		b;	/**< Box details. */
285 	Wxd_det_image_t		i;	/**< Image details. */
286 	Wxd_det_group_t		g;	/**< Group details. */
287 } Wxd_det_t;
288 
289 
290 
291 /**	Stipple bitmap (fill pattern).
292 */
293 typedef struct Wxd__stipple__t {
294 	uint8_t		 cd[8];	/**< Color data. */
295 	wxBitmap	*bm;	/**< Stipple bit map. */
296 } Wxd_stipple_t;
297 /*
298 	The color data array cd contains the following data:
299 	0	fill style (pattern number)
300 	1	fill red
301 	2	fill green
302 	3	fill blue
303 	4	stroke red
304 	5	stroke green
305 	6	stroke blue
306 	7	Flag: Stipple is in use
307 */
308 
309 
310 
311 /**	Information about a layer.
312 */
313 typedef struct Wxd__layer__t {
314 	int16_t				lay;		/**< Layer number. */
315 	uint8_t				active;		/**< Flag: Layer is active. */
316 	uint8_t				used;		/**< Flag: Layer is used. */
317 } Wxd_layer_t;
318 
319 
320 
321 /**	One drawing element.
322 	The forward arrow and backward arrow components are ignored for
323 	closed objects.
324 */
325 typedef struct Wxd__object__t {
326 	Wxd_det_t				 det;	/**< Graphics element details. */
327 	dk4_bb_t				 bb;	/**< Object bounding box. */
328 	struct Wxd__object__t	*pa;	/**< Parent group. */
329 	Wxd_stipple_t			*psti;	/**< Stipple for some fill patterns. */
330 	Wxd_layer_t				*play;	/**< Layer management information. */
331 	int16_t					 lay;	/**< Layer number. */
332 	uint16_t				 lw;	/**< Line width, multiples of base width. */
333 	uint8_t					 fc[3];	/**< Fill color. */
334 	uint8_t					 sc[3];	/**< Stroke and text color. */
335 	uint8_t					 cs;	/**< Cap style. */
336 	uint8_t					 fs;	/**< Fill style. */
337 	uint8_t					 ls;	/**< Line style. */
338 	uint8_t					 sl;	/**< Style length. */
339 	uint8_t					 js;	/**< Line join style. */
340 	uint8_t					 ml;	/**< Miter limit for mitered line join. */
341 	uint8_t					 aft;	/**< Arrowhead forward type. */
342 	uint8_t					 afl;	/**< Length of arrowhead forward. */
343 	uint8_t					 afw;	/**< Width of arrowhead forward. */
344 	uint8_t					 abt;	/**< Arrowhead backward type. */
345 	uint8_t					 abl;	/**< Length of arrowhead backward. */
346 	uint8_t					 abw;	/**< Width of arrowhead backward. */
347 	uint8_t					 mark;	/**< Markers or-combined.  */
348 	int8_t					 ot;	/**< Object type. */
349 } Wxd_object_t;
350 
351 
352 
353 /**	Entire drawing.
354 	The flattened container contains all objects of the drawing without
355 	any group structure. Elements are sorted by layer number.
356 	A second container s_stru contains the group structure.
357 */
358 typedef struct {
359 	dk4_sto_t		*s_stru;	/**< Structured container of all objects. */
360 	dk4_sto_it_t	*i_stru;	/**< Iterator for structured container. */
361 	dk4_sto_t		*s_flat;	/**< Flattened container of all objects. */
362 	dk4_sto_it_t	*i_flat;	/**< Iterator for flattened container. */
363 	dk4_sto_t		*s_stip;	/**< Stipples container. */
364 	dk4_sto_it_t	*i_stip;	/**< Stipples iterator. */
365 	dk4_sto_t		*s_layers;	/**< Layer management storage. */
366 	dk4_sto_it_t	*i_layers;	/**< Layer management iterator. */
367 	dk4_sto_t		*s_fonts;	/**< Fonts storage. */
368 	dk4_sto_it_t	*i_fonts;	/**< Fonts storage iterator. */
369 	Wxd_bb_t		 bb;		/**< Bounding box. */
370 	size_t			 xsubs;		/**< Sub segments per X-spline segment. */
371 	int32_t			 cx;		/**< X coordinate in center of control. */
372 	int32_t			 cy;		/**< Y coordinate in center of control. */
373 	uint32_t		 baselw;	/**< Base line width in wxd units. */
374 	uint32_t		 bleft;		/**< Left border. */
375 	uint32_t		 bright;	/**< Right border. */
376 	uint32_t		 bbottom;	/**< Bottom border. */
377 	uint32_t		 btop;		/**< Top border. */
378 	int				 redraw;	/**< Required redraw level. */
379 	uint16_t		 fv_maj;	/**< Format version major number. */
380 	uint16_t		 fv_min;	/**< Format version minor number. */
381 	int8_t			 zl;		/**< Zoom level. */
382 	uint8_t			 gridunit;	/**< Grid unit (0=inch, 1=cm). */
383 	uint8_t			 gridbase;	/**< Grid base (0=powers of 2, 1=of 10). */
384 } Wxd_drawing_t;
385 
386 
387 
388 /**	Error codes for reader module.
389 */
390 enum {
391 	WXDRD_E_NONE		=	0,	/**< No error occured. */
392 	WXDRD_E_MEMORY ,			/**< Not enough memory. */
393 	WXDRD_E_TEXT_PARTS ,		/**< Expected number of texts ot found. */
394 	WXDRD_E_NUM_CONV ,			/**< Conversion of text to number failed. */
395 	WXDRD_E_RECODE_TEXT ,		/**< Recoding failed for text label. */
396 	WXDRD_E_RECODE_FILENAME ,	/**< Recoding failed for file name. */
397 	WXDRD_E_INVALID_ARGS ,		/**< Invalid function arguments. */
398 	WXDRD_E_NO_VERSION ,		/**< File format information not found. */
399 	WXDRD_E_NO_BB ,				/**< No bounding box information found. */
400 	WXDRD_E_NO_WXD ,			/**< Not a WXD file. */
401 	WXDRD_E_WRONG_VERSION ,		/**< File format too new. */
402 	WXDRD_E_EXPECTED_OBJSTART ,	/**< Object start line expected. */
403 	WXDRD_E_EXPECTED_DETAILS ,	/**< Details line expected. */
404 	WXDRD_E_READER_STATE ,		/**< Wrong reader state. */
405 	WXDRD_E_OBJTYPE ,			/**< Illegal object or subobject type. */
406 	WXDRD_E_COORD_OVERFLOW ,	/**< Mathematical overflow in coordinates. */
407 	WXDRD_E_NO_GROUP_TO_END ,	/**< No open group to end. */
408 	WXDRD_E_TOO_FEW_POINTS ,	/**< Too few points. */
409 	WXDRD_E_EMPTY_FILENAME ,	/**< Empty image file name. */
410 	WXDRD_E_FILENAME_TOO_LONG ,	/**< Image file name too long. */
411 	WXDRD_E_BOX_NO_AREA ,		/**< Box does not span an area. */
412 };
413 
414 
415 
416 /**	Reader status.
417 */
418 typedef struct {
419 	Wxd_bb_t		 bb;	/**< Drawing bounding box. */
420 	wxChar			*dirn;	/**< Directory file resides in. */
421 	unsigned long	 ln;	/**< Line number error occured in. */
422 	size_t			 te;	/**< Number of text element not convertable. */
423 	int				 ec;	/**< Error code from module. */
424 	int				 wxe;	/**< Encoding used for wxChar. */
425 	int				 mod;	/**< Flag: Modified by corrections. */
426 } wxdrd_status_t;
427 
428 
429 
430 /**	Errors occuring in write operations.
431 */
432 enum {
433 	WXDWR_E_NONE			= 0,	/**< No error occured. */
434 	WXDWR_E_WRITE ,					/**< Error in write operation. */
435 	WXDWR_E_STRING_TOO_LONG ,		/**< String is too long. */
436 	WXDWR_E_RECODE_TEXT ,			/**< Failed to recode a text. */
437 	WXDWR_E_RECODE_FILENAME ,		/**< Failed to recode a file name. */
438 	WXDWR_E_STRING_EMPTY ,			/**< Empty string. */
439 };
440 
441 
442 /**	Writer status.
443 */
444 typedef struct {
445 	int				 ec;	/**< Error code. */
446 	int				 wxe;	/**< Encoding used for wxChar strings. */
447 	wxChar			*str;	/**< String for which conversion failed. */
448 	wxChar			*dirn;	/**< Directory name for output file. */
449 } wxdwr_status_t;
450 
451 
452 
453 #endif
454 /* if (DK4_HAVE_WXWIDGETS) && (defined(__cplusplus)) */
455 
456 
457 /* vim: set ai sw=4 ts=4 : */
458 
459 
460 #endif
461