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