[RTL]
[reactos.git] / reactos / tools / wrc / wrctypes.h
1 /*
2 * General type definitions
3 *
4 * Copyright 1998 Bertho A. Stultiens (BS)
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #ifndef __WRC_WRCTYPES_H
22 #define __WRC_WRCTYPES_H
23
24 #include <stdarg.h>
25 #include "wrcrostypes.h"
26
27 /* Memory/load flags */
28 #define WRC_MO_MOVEABLE 0x0010
29 #define WRC_MO_PURE 0x0020
30 #define WRC_MO_PRELOAD 0x0040
31 #define WRC_MO_DISCARDABLE 0x1000
32
33 /* Resource type IDs */
34 #define WRC_RT_CURSOR (1)
35 #define WRC_RT_BITMAP (2)
36 #define WRC_RT_ICON (3)
37 #define WRC_RT_MENU (4)
38 #define WRC_RT_DIALOG (5)
39 #define WRC_RT_STRING (6)
40 #define WRC_RT_FONTDIR (7)
41 #define WRC_RT_FONT (8)
42 #define WRC_RT_ACCELERATOR (9)
43 #define WRC_RT_RCDATA (10)
44 #define WRC_RT_MESSAGETABLE (11)
45 #define WRC_RT_GROUP_CURSOR (12)
46 #define WRC_RT_GROUP_ICON (14)
47 #define WRC_RT_VERSION (16)
48 #define WRC_RT_DLGINCLUDE (17)
49 #define WRC_RT_PLUGPLAY (19)
50 #define WRC_RT_VXD (20)
51 #define WRC_RT_ANICURSOR (21)
52 #define WRC_RT_ANIICON (22)
53 #define WRC_RT_HTML (23)
54 #define WRC_RT_DLGINIT (240)
55 #define WRC_RT_TOOLBAR (241)
56
57 /* Default class type IDs */
58 #define CT_BUTTON 0x80
59 #define CT_EDIT 0x81
60 #define CT_STATIC 0x82
61 #define CT_LISTBOX 0x83
62 #define CT_SCROLLBAR 0x84
63 #define CT_COMBOBOX 0x85
64
65 /* Byteordering defines */
66 #define WRC_BO_NATIVE 0x00
67 #define WRC_BO_LITTLE 0x01
68 #define WRC_BO_BIG 0x02
69
70 #define WRC_LOBYTE(w) ((WORD)(w) & 0xff)
71 #define WRC_HIBYTE(w) (((WORD)(w) >> 8) & 0xff)
72 #define WRC_LOWORD(d) ((DWORD)(d) & 0xffff)
73 #define WRC_HIWORD(d) (((DWORD)(d) >> 16) & 0xffff)
74 #define BYTESWAP_WORD(w) ((WORD)(((WORD)WRC_LOBYTE(w) << 8) + (WORD)WRC_HIBYTE(w)))
75 #define BYTESWAP_DWORD(d) ((DWORD)(((DWORD)BYTESWAP_WORD(WRC_LOWORD(d)) << 16) + ((DWORD)BYTESWAP_WORD(WRC_HIWORD(d)))))
76
77 typedef struct
78 {
79 const char *file;
80 int line;
81 int col;
82 } location_t;
83
84 /* Binary resource structure */
85 #define RES_BLOCKSIZE 512
86
87 typedef struct res {
88 unsigned int allocsize; /* Allocated datablock size */
89 unsigned int size; /* Actual size of data */
90 unsigned int dataidx; /* Tag behind the resource-header */
91 char *data;
92 } res_t;
93
94 /* Resource strings are slightly more complex because they include '\0' */
95 enum str_e {str_char, str_unicode};
96
97 typedef struct string {
98 int size;
99 enum str_e type;
100 union {
101 char *cstr;
102 WCHAR *wstr;
103 } str;
104 location_t loc;
105 } string_t;
106
107 /* Resources are identified either by name or by number */
108 enum name_e {name_str, name_ord};
109
110 typedef struct name_id {
111 union {
112 string_t *s_name;
113 int i_name;
114 } name;
115 enum name_e type;
116 } name_id_t;
117
118 /* Language definitions */
119 typedef struct language {
120 int id;
121 int sub;
122 } language_t;
123
124 typedef DWORD characts_t;
125 typedef DWORD version_t;
126
127 typedef struct lvc {
128 language_t *language;
129 version_t *version;
130 characts_t *characts;
131 } lvc_t;
132
133 typedef struct font_id {
134 string_t *name;
135 int size;
136 int weight;
137 int italic;
138 } font_id_t;
139
140 /* control styles */
141 typedef struct style {
142 DWORD or_mask;
143 DWORD and_mask;
144 } style_t;
145
146 /* resource types */
147 /* These are in the same order (and ordinal) as the RT_xxx
148 * defines. This is _required_.
149 * I rolled my own numbers for the win32 extension that are
150 * documented, but generate either old RT_xxx numbers, or
151 * don't have an ordinal associated (user type).
152 * I don't know any specs for those noted such, for that matter,
153 * I don't even know whether they can be generated other than by
154 * using a user-type resource.
155 */
156 enum res_e {
157 res_0 = 0,
158 res_cur,
159 res_bmp,
160 res_ico,
161 res_men,
162 res_dlg,
163 res_stt,
164 res_fntdir,
165 res_fnt,
166 res_acc,
167 res_rdt,
168 res_msg,
169 res_curg,
170 res_13, /* Hm, wonder why its not used... */
171 res_icog,
172 res_15,
173 res_ver,
174 res_dlginc, /* Not implemented, no layout available */
175 res_18,
176 res_pnp, /* Not implemented, no layout available */
177 res_vxd, /* Not implemented, no layout available */
178 res_anicur,
179 res_aniico,
180 res_html, /* Not implemented, no layout available */
181
182 res_dlginit = WRC_RT_DLGINIT, /* 240 */
183 res_toolbar = WRC_RT_TOOLBAR, /* 241 */
184
185 res_usr = 256 + 6
186 };
187
188 /* Raw bytes in a row... */
189 typedef struct raw_data {
190 unsigned int size;
191 char *data;
192 lvc_t lvc; /* Localized data */
193 } raw_data_t;
194
195 /* Dialog structures */
196 typedef struct control {
197 struct control *next; /* List of controls */
198 struct control *prev;
199 name_id_t *ctlclass; /* ControlClass */
200 name_id_t *title; /* Title of control */
201 int id;
202 int x; /* Position */
203 int y;
204 int width; /* Size */
205 int height;
206 style_t *style; /* Style */
207 style_t *exstyle;
208 DWORD helpid; /* EX: */
209 int gotstyle; /* Used to determine whether the default */
210 int gotexstyle; /* styles must be set */
211 int gothelpid;
212 raw_data_t *extra; /* EX: number of extra bytes in resource */
213 } control_t;
214
215 typedef struct dialog {
216 DWORD memopt;
217 int x; /* Position */
218 int y;
219 int width; /* Size */
220 int height;
221 style_t *style; /* Style */
222 style_t *exstyle;
223 DWORD helpid; /* EX: */
224 int gotstyle; /* Used to determine whether the default */
225 int gotexstyle; /* styles must be set */
226 int gothelpid;
227 int is_ex;
228 name_id_t *menu;
229 name_id_t *dlgclass;
230 string_t *title;
231 font_id_t *font;
232 lvc_t lvc;
233 control_t *controls;
234 } dialog_t;
235
236 /* Menu structures */
237 typedef struct menu_item {
238 struct menu_item *next;
239 struct menu_item *prev;
240 struct menu_item *popup;
241 int id;
242 DWORD type;
243 DWORD state;
244 int helpid;
245 string_t *name;
246 int gotid;
247 int gottype;
248 int gotstate;
249 int gothelpid;
250 } menu_item_t;
251
252 typedef struct menu {
253 DWORD memopt;
254 lvc_t lvc;
255 int is_ex;
256 menu_item_t *items;
257 } menu_t;
258
259 typedef struct itemex_opt
260 {
261 int id;
262 DWORD type;
263 DWORD state;
264 int helpid;
265 int gotid;
266 int gottype;
267 int gotstate;
268 int gothelpid;
269 } itemex_opt_t;
270
271 /*
272 * Font resources
273 */
274 typedef struct font {
275 DWORD memopt;
276 raw_data_t *data;
277 } font_t;
278
279 typedef struct fontdir {
280 DWORD memopt;
281 raw_data_t *data;
282 } fontdir_t;
283
284 /*
285 * Icon resources
286 */
287 typedef struct icon_header {
288 WORD reserved; /* Don't know, should be 0 I guess */
289 WORD type; /* Always 1 for icons */
290 WORD count; /* Number of packed icons in resource */
291 } icon_header_t;
292
293 typedef struct icon_dir_entry {
294 BYTE width; /* From the SDK doc. */
295 BYTE height;
296 BYTE nclr;
297 BYTE reserved;
298 WORD planes;
299 WORD bits;
300 DWORD ressize;
301 DWORD offset;
302 } icon_dir_entry_t;
303
304 typedef struct icon {
305 struct icon *next;
306 struct icon *prev;
307 lvc_t lvc;
308 int id; /* Unique icon id within resource file */
309 int width; /* Field from the IconDirEntry */
310 int height;
311 int nclr;
312 int planes;
313 int bits;
314 raw_data_t *data;
315 } icon_t;
316
317 typedef struct icon_group {
318 DWORD memopt;
319 lvc_t lvc;
320 icon_t *iconlist;
321 int nicon;
322 } icon_group_t;
323
324 /*
325 * Cursor resources
326 */
327 typedef struct cursor_header {
328 WORD reserved; /* Don't know, should be 0 I guess */
329 WORD type; /* Always 2 for cursors */
330 WORD count; /* Number of packed cursors in resource */
331 } cursor_header_t;
332
333 typedef struct cursor_dir_entry {
334 BYTE width; /* From the SDK doc. */
335 BYTE height;
336 BYTE nclr;
337 BYTE reserved;
338 WORD xhot;
339 WORD yhot;
340 DWORD ressize;
341 DWORD offset;
342 } cursor_dir_entry_t;
343
344 typedef struct cursor {
345 struct cursor *next;
346 struct cursor *prev;
347 lvc_t lvc;
348 int id; /* Unique icon id within resource file */
349 int width; /* Field from the CursorDirEntry */
350 int height;
351 int nclr;
352 int planes;
353 int bits;
354 int xhot;
355 int yhot;
356 raw_data_t *data;
357 } cursor_t;
358
359 typedef struct cursor_group {
360 DWORD memopt;
361 lvc_t lvc;
362 cursor_t *cursorlist;
363 int ncursor;
364 } cursor_group_t;
365
366 /*
367 * Animated cursors and icons
368 */
369 typedef struct aniheader {
370 DWORD structsize; /* Header size (36 bytes) */
371 DWORD frames; /* Number of unique icons in this cursor */
372 DWORD steps; /* Number of blits before the animation cycles */
373 DWORD cx; /* reserved, must be 0? */
374 DWORD cy; /* reserved, must be 0? */
375 DWORD bitcount; /* reserved, must be 0? */
376 DWORD planes; /* reserved, must be 0? */
377 DWORD rate; /* Default rate (1/60th of a second) if "rate" not present */
378 DWORD flags; /* Animation flag (1==AF_ICON, although both icons and cursors set this) */
379 } aniheader_t;
380
381 typedef struct riff_tag {
382 BYTE tag[4];
383 DWORD size;
384 } riff_tag_t;
385
386 typedef struct ani_curico {
387 DWORD memopt;
388 raw_data_t *data;
389 } ani_curico_t;
390
391 typedef struct ani_any {
392 enum res_e type;
393 union {
394 ani_curico_t *ani;
395 cursor_group_t *curg;
396 icon_group_t *icog;
397 } u;
398 } ani_any_t;
399
400 /*
401 * Bitmaps
402 */
403 typedef struct bitmap {
404 DWORD memopt;
405 raw_data_t *data;
406 } bitmap_t;
407
408 typedef struct html {
409 DWORD memopt;
410 raw_data_t *data;
411 } html_t;
412
413 typedef struct rcdata {
414 DWORD memopt;
415 raw_data_t *data;
416 } rcdata_t;
417
418 typedef struct {
419 DWORD memopt;
420 name_id_t *type;
421 raw_data_t *data;
422 } user_t;
423
424 /*
425 * Messagetables
426 */
427 typedef struct msgtab_block {
428 DWORD idlo; /* Lowest id in the set */
429 DWORD idhi; /* Highest is in the set */
430 DWORD offset; /* Offset from resource start to first entry */
431 } msgtab_block_t;
432
433 typedef struct msgtab_entry {
434 WORD length; /* Length of the data in bytes */
435 WORD flags; /* 0 for char, 1 for WCHAR */
436 /* {char}|{WCHAR} data[...]; */
437 } msgtab_entry_t;
438
439 typedef struct messagetable {
440 DWORD memopt;
441 raw_data_t *data;
442 } messagetable_t;
443
444 /* StringTable structures */
445 typedef struct stt_entry {
446 string_t *str;
447 int id;
448 DWORD memopt;
449 characts_t *characts;
450 version_t *version;
451 } stt_entry_t;
452
453 typedef struct stringtable {
454 struct stringtable *next;
455 struct stringtable *prev;
456 DWORD memopt;
457 lvc_t lvc;
458 int idbase;
459 int nentries;
460 stt_entry_t *entries;
461 } stringtable_t;
462
463 /* VersionInfo structures */
464 enum ver_val_e {val_str, val_words, val_block};
465
466 struct ver_block; /* Forward ref */
467
468 typedef struct ver_words {
469 WORD *words;
470 int nwords;
471 } ver_words_t;
472
473 typedef struct ver_value {
474 struct ver_value *next;
475 struct ver_value *prev;
476 string_t *key;
477 union {
478 string_t *str;
479 ver_words_t *words;
480 struct ver_block *block;
481 } value;
482 enum ver_val_e type;
483 } ver_value_t;
484
485 typedef struct ver_block {
486 struct ver_block *next;
487 struct ver_block *prev;
488 string_t *name;
489 ver_value_t *values;
490 } ver_block_t;
491
492 typedef struct versioninfo {
493 int filever_maj1;
494 int filever_maj2;
495 int filever_min1;
496 int filever_min2;
497 int prodver_maj1;
498 int prodver_maj2;
499 int prodver_min1;
500 int prodver_min2;
501 int fileos;
502 int fileflags;
503 int fileflagsmask;
504 int filetype;
505 int filesubtype;
506 struct {
507 unsigned fv:1;
508 unsigned pv:1;
509 unsigned fo:1;
510 unsigned ff:1;
511 unsigned ffm:1;
512 unsigned ft:1;
513 unsigned fst:1;
514 } gotit;
515 ver_block_t *blocks;
516 lvc_t lvc;
517 DWORD memopt;
518 } versioninfo_t;
519
520 /* Accelerator structures */
521 #define WRC_AF_VIRTKEY 0x0001
522 #define WRC_AF_NOINVERT 0x0002
523 #define WRC_AF_SHIFT 0x0004
524 #define WRC_AF_CONTROL 0x0008
525 #define WRC_AF_ALT 0x0010
526 #define WRC_AF_ASCII 0x4000
527
528 typedef struct event {
529 struct event *next;
530 struct event *prev;
531 int flags;
532 int key;
533 int id;
534 } event_t;
535
536 typedef struct accelerator {
537 DWORD memopt;
538 lvc_t lvc;
539 event_t *events;
540 } accelerator_t;
541
542 /* Toolbar structures */
543 typedef struct toolbar_item {
544 struct toolbar_item *next;
545 struct toolbar_item *prev;
546 int id;
547 } toolbar_item_t;
548
549 typedef struct toolbar {
550 DWORD memopt;
551 lvc_t lvc;
552 int button_width;
553 int button_height;
554 int nitems;
555 toolbar_item_t *items;
556 } toolbar_t;
557
558 typedef struct dlginit {
559 DWORD memopt;
560 raw_data_t *data;
561 } dlginit_t;
562
563
564 /* A top-level resource node */
565 typedef struct resource {
566 struct resource *next;
567 struct resource *prev;
568 enum res_e type;
569 name_id_t *name; /* resource's name */
570 language_t *lan; /* Only used as a sorting key and c-name creation*/
571 union {
572 accelerator_t *acc;
573 ani_curico_t *ani;
574 bitmap_t *bmp;
575 cursor_t *cur;
576 cursor_group_t *curg;
577 dialog_t *dlg;
578 dlginit_t *dlgi;
579 font_t *fnt;
580 fontdir_t *fnd;
581 icon_t *ico;
582 icon_group_t *icog;
583 menu_t *men;
584 messagetable_t *msg;
585 html_t *html;
586 rcdata_t *rdt;
587 stringtable_t *stt;
588 toolbar_t *tbt;
589 user_t *usr;
590 versioninfo_t *ver;
591 void *overlay; /* To catch all types at once... */
592 } res;
593 res_t *binres; /* To binary converted resource */
594 char *c_name; /* BaseName in output */
595 DWORD memopt;
596 } resource_t;
597
598 /* Resource count */
599 typedef struct res32_count {
600 int count;
601 resource_t **rsc;
602 } res32_count_t;
603
604 typedef struct res_count {
605 name_id_t type;
606 int count; /* win16 mode */
607 resource_t **rscarray;
608 int count32;
609 res32_count_t *rsc32array; /* win32 mode */
610 int n_id_entries;
611 int n_name_entries;
612 } res_count_t;
613
614 typedef struct style_pair {
615 style_t *style;
616 style_t *exstyle;
617 } style_pair_t;
618
619 #endif