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