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