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