- Fixed the long long problem.
[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_DLGINIT          (240)
48 #define WRC_RT_TOOLBAR          (241)  
49
50 /* Default class type IDs */
51 #define CT_BUTTON       0x80
52 #define CT_EDIT         0x81
53 #define CT_STATIC       0x82
54 #define CT_LISTBOX      0x83
55 #define CT_SCROLLBAR    0x84
56 #define CT_COMBOBOX     0x85
57
58
59 /* Binary resource structure */
60 #define RES_BLOCKSIZE   512
61
62 typedef struct res {
63         int     allocsize;      /* Allocated datablock size */
64         int     size;           /* Actual size of data */
65         int     dataidx;        /* Tag behind the resource-header */
66         char    *data;
67 } res_t;
68
69 /* Resource strings are slightly more complex because they include '\0' */
70 enum str_e {str_char, str_unicode};
71
72 typedef struct string {
73         int             size;
74         enum str_e      type;
75         union {
76                 char *cstr;
77                 short *wstr;
78         } str;
79 } string_t;
80
81 /* Resources are identified either by name or by number */
82 enum name_e {name_str, name_ord};
83
84 typedef struct name_id {
85         union {
86                 string_t *s_name;
87                 int     i_name;
88         } name;
89         enum name_e type;
90 } name_id_t;
91
92 /* Language definitions */
93 typedef struct language {
94         int     id;
95         int     sub;
96 } language_t;
97
98 typedef DWORD characts_t;
99 typedef DWORD version_t;
100
101 typedef struct lvc {
102         language_t      *language;
103         version_t       *version;
104         characts_t      *characts;
105 } lvc_t;
106
107 typedef struct font_id {
108         string_t        *name;
109         int             size;
110         int             weight;
111         int             italic;
112 } font_id_t;
113
114 /* resource types */
115 /* These are in the same order (and ordinal) as the RT_xxx
116  * defines. This is _required_.
117  * I rolled my own numbers for the win32 extension that are
118  * documented, but generate either old RT_xxx numbers, or
119  * don't have an ordinal associated (user type).
120  * I don't know any specs for those noted such, for that matter,
121  * I don't even know whether they can be generated other than by
122  * using a user-type resource.
123  */
124 enum res_e {
125         res_0 = 0,
126         res_cur,
127         res_bmp,
128         res_ico,
129         res_men,
130         res_dlg,
131         res_stt,
132         res_fntdir,
133         res_fnt,
134         res_acc,
135         res_rdt,
136         res_msg,
137         res_curg,
138         res_13,         /* Hm, wonder why its not used... */
139         res_icog,
140         res_15,
141         res_ver,
142         res_dlginc,     /* Not implemented, no layout available */
143         res_18,
144         res_pnp,        /* Not implemented, no layout available */
145         res_vxd,        /* Not implemented, no layout available */
146         res_anicur,     /* Not implemented, no layout available */
147         res_aniico,     /* Not implemented, no layout available */
148
149         res_dlginit = WRC_RT_DLGINIT,   /* 240 */
150         res_toolbar = WRC_RT_TOOLBAR,   /* 241 */
151
152         res_menex = 256 + 4,
153         res_dlgex,
154         res_usr
155 };
156
157 /* Raw bytes in a row... */
158 typedef struct raw_data {
159         int     size;
160         char    *data;
161 } raw_data_t;
162
163 /* Dialog structures */
164 typedef struct control {
165         struct control  *next;          /* List of controls */
166         struct control  *prev;
167         name_id_t       *ctlclass;      /* ControlClass */
168         name_id_t       *title;         /* Title of control */
169         int             id;
170         int             x;              /* Position */
171         int             y;
172         int             width;          /* Size */
173         int             height;
174         DWORD           style;          /* Style */
175         DWORD           exstyle;
176         DWORD           helpid;         /* EX: */
177         int             gotstyle;       /* Used to determine whether the default */
178         int             gotexstyle;     /* styles must be set */
179         int             gothelpid;
180         raw_data_t      *extra;         /* EX: number of extra bytes in resource */
181 } control_t;
182
183 typedef struct dialog {
184         DWORD           memopt;
185         int             x;              /* Position */
186         int             y;
187         int             width;          /* Size */
188         int             height;
189         DWORD           style;          /* Style */
190         DWORD           exstyle;
191         int             gotstyle;       /* Used to determine whether the default */
192         int             gotexstyle;     /* styles must be set */
193         name_id_t       *menu;
194         name_id_t       *dlgclass;
195         string_t        *title;
196         font_id_t       *font;
197         lvc_t           lvc;
198         control_t       *controls;
199 } dialog_t;
200
201 /* DialogEx structures */
202 typedef struct dialogex {
203         DWORD           memopt;
204         int             x;              /* Position */
205         int             y;
206         int             width;          /* Size */
207         int             height;
208         DWORD           style;          /* Style */
209         DWORD           exstyle;
210         DWORD           helpid;         /* EX: */
211         int             gotstyle;       /* Used to determine whether the default */
212         int             gotexstyle;     /* styles must be set */
213         int             gothelpid;
214         name_id_t       *menu;
215         name_id_t       *dlgclass;
216         string_t        *title;
217         font_id_t       *font;
218         lvc_t           lvc;
219         control_t       *controls;
220 } dialogex_t;
221
222 /* Menu structures */
223 typedef struct menu_item {
224         struct menu_item *next;
225         struct menu_item *prev;
226         struct menu_item *popup;
227         int             id;
228         DWORD           state;
229         string_t        *name;
230 } menu_item_t;
231
232 typedef struct menu {
233         DWORD           memopt;
234         lvc_t           lvc;
235         menu_item_t     *items;
236 } menu_t;
237
238 /* MenuEx structures */
239 typedef struct menuex_item {
240         struct menuex_item *next;
241         struct menuex_item *prev;
242         struct menuex_item *popup;
243         int             id;
244         DWORD           type;
245         DWORD           state;
246         int             helpid;
247         string_t        *name;
248         int             gotid;
249         int             gottype;
250         int             gotstate;
251         int             gothelpid;
252 } menuex_item_t;
253
254 typedef struct menuex {
255         DWORD           memopt;
256         lvc_t           lvc;
257         menuex_item_t   *items;
258 } menuex_t;
259
260 typedef struct itemex_opt
261 {
262         int     id;
263         DWORD   type;
264         DWORD   state;
265         int     helpid;
266         int     gotid;
267         int     gottype;
268         int     gotstate;
269         int     gothelpid;
270 } itemex_opt_t;
271
272 /* RC structures for types read from file or supplied binary */
273 typedef struct font {
274         DWORD           memopt;
275         raw_data_t      *data;
276 } font_t;
277
278 typedef struct icon_dir_entry {
279     BYTE  width;        /* From the SDK doc. */
280     BYTE  height;
281     BYTE  nclr;
282     BYTE  reserved;
283     WORD  planes;
284     WORD  bits;
285     DWORD ressize;
286     DWORD offset;
287 } icon_dir_entry_t;
288
289 typedef struct icon {
290         struct icon     *next;
291         struct icon     *prev;
292         lvc_t           lvc;
293         int             id;     /* Unique icon id within resource file */
294         int             width;  /* Field from the IconDirEntry */
295         int             height;
296         int             nclr;
297         int             planes;
298         int             bits;
299         raw_data_t      *data;
300 } icon_t;
301
302 typedef struct icon_group {
303         DWORD           memopt;
304         lvc_t           lvc;
305         icon_t          *iconlist;
306         int             nicon;
307 } icon_group_t;
308
309 typedef struct cursor_dir_entry {
310     BYTE  width;        /* From the SDK doc. */
311     BYTE  height;
312     BYTE  nclr;
313     BYTE  reserved;
314     WORD  xhot;
315     WORD  yhot;
316     DWORD ressize;
317     DWORD offset;
318 } cursor_dir_entry_t;
319
320 typedef struct cursor {
321         struct cursor   *next;
322         struct cursor   *prev;
323         lvc_t           lvc;
324         int             id;     /* Unique icon id within resource file */
325         int             width;  /* Field from the CursorDirEntry */
326         int             height;
327         int             nclr;
328         int             planes;
329         int             bits;
330         int             xhot;
331         int             yhot;
332         raw_data_t      *data;
333 } cursor_t;
334
335 typedef struct cursor_group {
336         DWORD           memopt;
337         lvc_t           lvc;
338         cursor_t        *cursorlist;
339         int             ncursor;
340 } cursor_group_t;
341
342 typedef struct bitmap {
343         DWORD           memopt;
344         raw_data_t      *data;
345 } bitmap_t;
346
347 typedef struct rcdata {
348         DWORD           memopt;
349         lvc_t           lvc;
350         raw_data_t      *data;
351 } rcdata_t;
352
353 typedef struct user {
354         DWORD           memopt;
355         name_id_t       *type;
356         raw_data_t      *data;
357 } user_t;
358
359 typedef struct messagetable {
360         raw_data_t      *data;
361 } messagetable_t;
362
363 /* StringTable structures */
364 typedef struct stt_entry {
365         string_t                *str;
366         int                     id;
367         DWORD                   memopt;
368         characts_t              *characts;
369         version_t               *version;
370 } stt_entry_t;
371
372 typedef struct stringtable {
373         struct stringtable      *next;
374         struct stringtable      *prev;
375         DWORD                   memopt;
376         lvc_t                   lvc;
377         int                     idbase;
378         int                     nentries;
379         stt_entry_t             *entries;
380 } stringtable_t;
381
382 /* VersionInfo structures */
383 enum ver_val_e {val_str, val_words, val_block};
384
385 struct ver_block;       /* Forward ref */
386
387 typedef struct ver_words {
388         WORD    *words;
389         int     nwords;
390 } ver_words_t;
391
392 typedef struct ver_value {
393         struct ver_value        *next;
394         struct ver_value        *prev;
395         string_t                *key;
396         union {
397                 string_t                *str;
398                 ver_words_t             *words;
399                 struct ver_block        *block;
400         } value;
401         enum ver_val_e          type;
402 } ver_value_t;
403
404 typedef struct ver_block {
405         struct ver_block        *next;
406         struct ver_block        *prev;
407         string_t                *name;
408         ver_value_t             *values;
409 } ver_block_t;
410
411 typedef struct versioninfo {
412         int     filever_maj1;
413         int     filever_maj2;
414         int     filever_min1;
415         int     filever_min2;
416         int     prodver_maj1;
417         int     prodver_maj2;
418         int     prodver_min1;
419         int     prodver_min2;
420         int     fileos;
421         int     fileflags;
422         int     fileflagsmask;
423         int     filetype;
424         int     filesubtype;
425         struct {
426                 int fv:1;
427                 int pv:1;
428                 int fo:1;
429                 int ff:1;
430                 int ffm:1;
431                 int ft:1;
432                 int fst:1;
433         } gotit;
434         ver_block_t     *blocks;
435 } versioninfo_t;
436
437 /* Accelerator structures */
438 #define WRC_AF_VIRTKEY  0x0001
439 #define WRC_AF_NOINVERT 0x0002
440 #define WRC_AF_SHIFT    0x0004
441 #define WRC_AF_CONTROL  0x0008
442 #define WRC_AF_ALT      0x0010
443 #define WRC_AF_ASCII    0x4000
444
445 typedef struct event {
446         struct event    *next;
447         struct event    *prev;
448         int             flags;
449         int             key;
450         int             id;
451 } event_t;
452
453 typedef struct accelerator {
454         DWORD           memopt;
455         lvc_t           lvc;
456         event_t         *events;
457 } accelerator_t;
458
459 /* Toolbar structures */
460 typedef struct toolbar_item {
461         struct toolbar_item     *next;
462         struct toolbar_item     *prev;        
463         int                     id;
464 } toolbar_item_t;
465
466 typedef struct toolbar {
467         DWORD           memopt;
468         lvc_t           lvc;
469         int             button_width;
470         int             button_height;
471         int             nitems;
472         toolbar_item_t  *items;
473 } toolbar_t;
474
475 typedef struct dlginit {
476         DWORD           memopt;
477         lvc_t           lvc;
478         raw_data_t      *data;
479 } dlginit_t;
480
481
482 /* A top-level resource node */
483 typedef struct resource {
484         struct resource *next;
485         struct resource *prev;
486         enum res_e      type;
487         name_id_t       *name;  /* resource's name */
488         language_t      *lan;   /* Only used as a sorting key and c-name creation*/
489         union {
490                 accelerator_t   *acc;
491                 bitmap_t        *bmp;
492                 cursor_t        *cur;
493                 cursor_group_t  *curg;
494                 dialog_t        *dlg;
495                 dialogex_t      *dlgex;
496                 dlginit_t       *dlgi;
497                 font_t          *fnt;
498                 icon_t          *ico;
499                 icon_group_t    *icog;
500                 menu_t          *men;
501                 menuex_t        *menex;
502                 messagetable_t  *msg;
503                 rcdata_t        *rdt;
504                 stringtable_t   *stt;
505                 toolbar_t       *tbt;
506                 user_t          *usr;
507                 versioninfo_t   *ver;
508                 void            *overlay; /* To catch all types at once... */
509         } res;
510         res_t           *binres;        /* To binary converted resource */
511         char            *c_name;        /* BaseName in output */
512         DWORD           memopt;
513 } resource_t;
514
515 /* Resource count */
516 typedef struct res32_count {
517         int                     count;
518         resource_t              **rsc;
519 } res32_count_t;
520
521 typedef struct res_count {
522         name_id_t               type;
523         int                     count;          /* win16 mode */
524         resource_t              **rscarray;
525         int                     count32;
526         res32_count_t           *rsc32array;    /* win32 mode */
527         int                     n_id_entries;
528         int                     n_name_entries;
529 } res_count_t;
530
531 typedef struct style_pair {
532         int                     style;
533         int                     exstyle;
534 } style_pair_t;
535
536 #endif
537
538