wrctypes.h 13.5 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2 3 4 5
/*
 * General type definitions
 *
 * Copyright 1998 Bertho A. Stultiens (BS)
 *
6 7 8 9 10 11 12 13 14 15 16 17
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Alexandre Julliard's avatar
Alexandre Julliard committed
19 20 21 22 23
 */

#ifndef __WRC_WRCTYPES_H
#define __WRC_WRCTYPES_H

24
#include <stdarg.h>
25
#include "windef.h"
26
#include "winbase.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
27 28 29 30 31 32

#ifndef MAKELANGID
#include "winnls.h"
#endif

#ifndef VS_FFI_SIGNATURE
33
#include "winver.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
34 35
#endif

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
/* Memory/load flags */
#define WRC_MO_MOVEABLE		0x0010
#define WRC_MO_PURE		0x0020
#define WRC_MO_PRELOAD		0x0040
#define WRC_MO_DISCARDABLE	0x1000

/* Resource type IDs */
#define WRC_RT_CURSOR		(1)
#define WRC_RT_BITMAP		(2)
#define WRC_RT_ICON		(3)
#define WRC_RT_MENU		(4)
#define WRC_RT_DIALOG		(5)
#define WRC_RT_STRING		(6)
#define WRC_RT_FONTDIR		(7)
#define WRC_RT_FONT		(8)
#define WRC_RT_ACCELERATOR	(9)
#define WRC_RT_RCDATA		(10)
#define WRC_RT_MESSAGETABLE	(11)
#define WRC_RT_GROUP_CURSOR	(12)
#define WRC_RT_GROUP_ICON	(14)
#define WRC_RT_VERSION		(16)
#define WRC_RT_DLGINCLUDE	(17)
#define WRC_RT_PLUGPLAY		(19)
#define WRC_RT_VXD		(20)
#define WRC_RT_ANICURSOR	(21)
#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 67 68 69 70 71 72 73

/* Default class type IDs */
#define CT_BUTTON	0x80
#define CT_EDIT		0x81
#define CT_STATIC 	0x82
#define CT_LISTBOX	0x83
#define CT_SCROLLBAR	0x84
#define CT_COMBOBOX	0x85

74 75 76 77 78 79 80 81 82 83 84
/* Byteordering defines */
#define WRC_BO_NATIVE	0x00
#define WRC_BO_LITTLE	0x01
#define WRC_BO_BIG	0x02

#define WRC_LOBYTE(w)		((WORD)(w) & 0xff)
#define WRC_HIBYTE(w)		(((WORD)(w) >> 8) & 0xff)
#define WRC_LOWORD(d)		((DWORD)(d) & 0xffff)
#define WRC_HIWORD(d)		(((DWORD)(d) >> 16) & 0xffff)
#define BYTESWAP_WORD(w)	((WORD)(((WORD)WRC_LOBYTE(w) << 8) + (WORD)WRC_HIBYTE(w)))
#define BYTESWAP_DWORD(d)	((DWORD)(((DWORD)BYTESWAP_WORD(WRC_LOWORD(d)) << 16) + ((DWORD)BYTESWAP_WORD(WRC_HIWORD(d)))))
Alexandre Julliard's avatar
Alexandre Julliard committed
85 86 87 88 89

/* Binary resource structure */
#define RES_BLOCKSIZE	512

typedef struct res {
90 91 92 93
	unsigned int	allocsize;	/* Allocated datablock size */
	unsigned int	size;		/* Actual size of data */
	unsigned int	dataidx;	/* Tag behind the resource-header */
	char		*data;
Alexandre Julliard's avatar
Alexandre Julliard committed
94 95 96 97 98 99 100 101 102 103
} res_t;

/* Resource strings are slightly more complex because they include '\0' */
enum str_e {str_char, str_unicode};

typedef struct string {
	int 		size;
	enum str_e	type;
	union {
		char *cstr;
104
		WCHAR *wstr;
Alexandre Julliard's avatar
Alexandre Julliard committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
	} str;
} string_t;

/* Resources are identified either by name or by number */
enum name_e {name_str, name_ord};

typedef struct name_id {
	union {
		string_t *s_name;
		int	i_name;
	} name;
	enum name_e type;
} name_id_t;

/* Language definitions */
typedef struct language {
	int	id;
	int	sub;
} language_t;

typedef DWORD characts_t;
typedef DWORD version_t;

typedef struct lvc {
	language_t	*language;
	version_t	*version;
	characts_t	*characts;
} lvc_t;

typedef struct font_id {
	string_t	*name;
	int		size;
	int		weight;
	int		italic;
} font_id_t;

141 142 143 144 145 146
/* control styles */
typedef struct style {
    	DWORD 			or_mask;
	DWORD			and_mask;
} style_t;

Alexandre Julliard's avatar
Alexandre Julliard committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160
/* resource types */
/* These are in the same order (and ordinal) as the RT_xxx
 * defines. This is _required_.
 * I rolled my own numbers for the win32 extension that are
 * documented, but generate either old RT_xxx numbers, or
 * don't have an ordinal associated (user type).
 * I don't know any specs for those noted such, for that matter,
 * I don't even know whether they can be generated other than by
 * using a user-type resource.
 */
enum res_e {
	res_0 = 0,
	res_cur,
	res_bmp,
161
	res_ico,
Alexandre Julliard's avatar
Alexandre Julliard committed
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
	res_men,
	res_dlg,
	res_stt,
	res_fntdir,
	res_fnt,
	res_acc,
	res_rdt,
	res_msg,
	res_curg,
	res_13,		/* Hm, wonder why its not used... */
	res_icog,
	res_15,
	res_ver,
	res_dlginc,	/* Not implemented, no layout available */
	res_18,
	res_pnp,	/* Not implemented, no layout available */
	res_vxd,	/* Not implemented, no layout available */
179 180 181
	res_anicur,
	res_aniico,
	res_html,	/* Not implemented, no layout available */
Alexandre Julliard's avatar
Alexandre Julliard committed
182

183
	res_dlginit = WRC_RT_DLGINIT,	/* 240 */
184 185
	res_toolbar = WRC_RT_TOOLBAR,	/* 241 */

Alexandre Julliard's avatar
Alexandre Julliard committed
186 187
	res_menex = 256 + 4,
	res_dlgex,
188
	res_usr
Alexandre Julliard's avatar
Alexandre Julliard committed
189 190 191 192
};

/* Raw bytes in a row... */
typedef struct raw_data {
193 194 195
	unsigned int	size;
	char		*data;
	lvc_t		lvc;		/* Localized data */
Alexandre Julliard's avatar
Alexandre Julliard committed
196 197 198 199 200 201 202
} raw_data_t;

/* Dialog structures */
typedef struct control {
	struct control	*next;		/* List of controls */
	struct control	*prev;
	name_id_t	*ctlclass;	/* ControlClass */
203
	name_id_t	*title;		/* Title of control */
Alexandre Julliard's avatar
Alexandre Julliard committed
204 205 206 207 208
	int		id;
	int		x;		/* Position */
	int		y;
	int		width;		/* Size */
	int		height;
209 210
	style_t		*style;		/* Style */
	style_t		*exstyle;
Alexandre Julliard's avatar
Alexandre Julliard committed
211 212 213 214 215 216 217 218 219 220 221 222 223
	DWORD		helpid;		/* EX: */
	int		gotstyle;	/* Used to determine whether the default */
	int		gotexstyle;	/* styles must be set */
	int		gothelpid;
	raw_data_t	*extra;		/* EX: number of extra bytes in resource */
} control_t;

typedef struct dialog {
	DWORD		memopt;
	int		x;		/* Position */
	int		y;
	int		width;		/* Size */
	int		height;
224 225
	style_t		*style;		/* Style */
	style_t		*exstyle;
Alexandre Julliard's avatar
Alexandre Julliard committed
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
	int		gotstyle;	/* Used to determine whether the default */
	int		gotexstyle;	/* styles must be set */
	name_id_t	*menu;
	name_id_t	*dlgclass;
	string_t	*title;
	font_id_t	*font;
	lvc_t		lvc;
	control_t	*controls;
} dialog_t;

/* DialogEx structures */
typedef struct dialogex {
	DWORD		memopt;
	int		x;		/* Position */
	int		y;
	int		width;		/* Size */
	int		height;
243 244
	style_t		*style;		/* Style */
	style_t		*exstyle;
Alexandre Julliard's avatar
Alexandre Julliard committed
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
	DWORD		helpid;		/* EX: */
	int		gotstyle;	/* Used to determine whether the default */
	int		gotexstyle;	/* styles must be set */
	int		gothelpid;
	name_id_t	*menu;
	name_id_t	*dlgclass;
	string_t	*title;
	font_id_t	*font;
	lvc_t		lvc;
	control_t	*controls;
} dialogex_t;

/* Menu structures */
typedef struct menu_item {
	struct menu_item *next;
	struct menu_item *prev;
	struct menu_item *popup;
	int		id;
	DWORD		state;
	string_t	*name;
} menu_item_t;

typedef struct menu {
	DWORD		memopt;
	lvc_t		lvc;
	menu_item_t	*items;
} menu_t;

/* MenuEx structures */
typedef struct menuex_item {
	struct menuex_item *next;
	struct menuex_item *prev;
	struct menuex_item *popup;
	int		id;
	DWORD		type;
	DWORD		state;
	int		helpid;
	string_t	*name;
	int		gotid;
	int		gottype;
	int		gotstate;
	int		gothelpid;
} menuex_item_t;

typedef struct menuex {
	DWORD		memopt;
	lvc_t		lvc;
	menuex_item_t	*items;
} menuex_t;

typedef struct itemex_opt
{
	int	id;
	DWORD	type;
	DWORD	state;
	int	helpid;
	int	gotid;
	int	gottype;
	int	gotstate;
	int	gothelpid;
} itemex_opt_t;

307 308 309
/*
 * Font resources
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
310 311 312 313 314
typedef struct font {
	DWORD		memopt;
	raw_data_t	*data;
} font_t;

315 316 317 318 319
typedef struct fontdir {
	DWORD		memopt;
	raw_data_t	*data;
} fontdir_t;

320 321 322 323 324 325 326 327 328
/*
 * Icon resources
 */
typedef struct icon_header {
	WORD	reserved;	/* Don't know, should be 0 I guess */
	WORD	type;		/* Always 1 for icons */
	WORD	count;		/* Number of packed icons in resource */
} icon_header_t;

Alexandre Julliard's avatar
Alexandre Julliard committed
329
typedef struct icon_dir_entry {
330 331 332 333 334 335 336 337
	BYTE	width;		/* From the SDK doc. */
	BYTE	height;
	BYTE	nclr;
	BYTE	reserved;
	WORD	planes;
	WORD	bits;
	DWORD	ressize;
	DWORD	offset;
Alexandre Julliard's avatar
Alexandre Julliard committed
338 339 340 341 342
} icon_dir_entry_t;

typedef struct icon {
	struct icon	*next;
	struct icon	*prev;
Alexandre Julliard's avatar
Alexandre Julliard committed
343
	lvc_t		lvc;
Alexandre Julliard's avatar
Alexandre Julliard committed
344 345 346 347 348 349 350 351 352 353 354
	int		id;	/* Unique icon id within resource file */
	int		width;	/* Field from the IconDirEntry */
	int		height;
	int		nclr;
	int		planes;
	int		bits;
	raw_data_t	*data;
} icon_t;

typedef struct icon_group {
	DWORD		memopt;
Alexandre Julliard's avatar
Alexandre Julliard committed
355
	lvc_t		lvc;
Alexandre Julliard's avatar
Alexandre Julliard committed
356 357 358 359
	icon_t		*iconlist;
	int		nicon;
} icon_group_t;

360 361 362 363 364 365 366 367 368
/*
 * Cursor resources
 */
typedef struct cursor_header {
	WORD	reserved;	/* Don't know, should be 0 I guess */
	WORD	type;		/* Always 2 for cursors */
	WORD	count;		/* Number of packed cursors in resource */
} cursor_header_t;

Alexandre Julliard's avatar
Alexandre Julliard committed
369
typedef struct cursor_dir_entry {
370 371 372 373 374 375 376 377
	BYTE	width;		/* From the SDK doc. */
	BYTE	height;
	BYTE	nclr;
	BYTE	reserved;
	WORD	xhot;
	WORD	yhot;
	DWORD	ressize;
	DWORD	offset;
Alexandre Julliard's avatar
Alexandre Julliard committed
378 379 380 381 382
} cursor_dir_entry_t;

typedef struct cursor {
	struct cursor	*next;
	struct cursor	*prev;
Alexandre Julliard's avatar
Alexandre Julliard committed
383
	lvc_t		lvc;
Alexandre Julliard's avatar
Alexandre Julliard committed
384 385 386 387 388 389 390 391 392 393 394 395 396
	int		id;	/* Unique icon id within resource file */
	int		width;	/* Field from the CursorDirEntry */
	int		height;
	int		nclr;
	int		planes;
	int		bits;
	int		xhot;
	int		yhot;
	raw_data_t	*data;
} cursor_t;

typedef struct cursor_group {
	DWORD		memopt;
Alexandre Julliard's avatar
Alexandre Julliard committed
397
	lvc_t		lvc;
Alexandre Julliard's avatar
Alexandre Julliard committed
398 399 400 401
	cursor_t	*cursorlist;
	int		ncursor;
} cursor_group_t;

402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
/*
 * Animated cursors and icons
 */
typedef struct aniheader {
	DWORD	structsize;	/* Header size (36 bytes) */
	DWORD	frames;		/* Number of unique icons in this cursor */
	DWORD	steps;		/* Number of blits before the animation cycles */
	DWORD	cx;		/* reserved, must be 0? */
	DWORD	cy;		/* reserved, must be 0? */
	DWORD	bitcount;	/* reserved, must be 0? */
	DWORD	planes;		/* reserved, must be 0? */
	DWORD	rate;		/* Default rate (1/60th of a second) if "rate" not present */
	DWORD	flags;		/* Animation flag (1==AF_ICON, although both icons and cursors set this) */
} aniheader_t;

typedef struct riff_tag {
	BYTE	tag[4];
	DWORD	size;
} riff_tag_t;

typedef struct ani_curico {
	DWORD		memopt;
	raw_data_t	*data;
} ani_curico_t;

typedef struct ani_any {
	enum res_e	type;
	union {
		ani_curico_t	*ani;
		cursor_group_t	*curg;
		icon_group_t	*icog;
	} u;
} ani_any_t;

/*
 * Bitmaps
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
439 440 441 442 443
typedef struct bitmap {
	DWORD		memopt;
	raw_data_t	*data;
} bitmap_t;

444 445 446 447 448
typedef struct html {
	DWORD		memopt;
	raw_data_t	*data;
} html_t;

Alexandre Julliard's avatar
Alexandre Julliard committed
449 450 451 452 453
typedef struct rcdata {
	DWORD		memopt;
	raw_data_t	*data;
} rcdata_t;

454
typedef struct {
Alexandre Julliard's avatar
Alexandre Julliard committed
455 456 457 458 459
	DWORD		memopt;
	name_id_t	*type;
	raw_data_t	*data;
} user_t;

460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
/*
 * Messagetables
 */
typedef struct msgtab_block {
	DWORD	idlo;		/* Lowest id in the set */
	DWORD	idhi;		/* Highest is in the set */
	DWORD	offset;		/* Offset from resource start to first entry */
} msgtab_block_t;

typedef struct msgtab_entry {
	WORD	length;		/* Length of the data in bytes */
	WORD	flags;		/* 0 for char, 1 for WCHAR */
/*	{char}|{WCHAR} data[...]; */
} msgtab_entry_t;

Alexandre Julliard's avatar
Alexandre Julliard committed
475
typedef struct messagetable {
476
	DWORD		memopt;
Alexandre Julliard's avatar
Alexandre Julliard committed
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
	raw_data_t	*data;
} messagetable_t;

/* StringTable structures */
typedef struct stt_entry {
	string_t		*str;
	int			id;
	DWORD			memopt;
	characts_t		*characts;
	version_t		*version;
} stt_entry_t;

typedef struct stringtable {
	struct stringtable	*next;
	struct stringtable	*prev;
	DWORD			memopt;
	lvc_t			lvc;
	int			idbase;
	int			nentries;
	stt_entry_t		*entries;
} stringtable_t;

/* VersionInfo structures */
enum ver_val_e {val_str, val_words, val_block};

struct ver_block;	/* Forward ref */

typedef struct ver_words {
	WORD	*words;
	int	nwords;
} ver_words_t;

typedef struct ver_value {
	struct ver_value	*next;
	struct ver_value	*prev;
	string_t		*key;
	union {
		string_t		*str;
		ver_words_t		*words;
		struct ver_block	*block;
	} value;
	enum ver_val_e		type;
} ver_value_t;

typedef struct ver_block {
	struct ver_block	*next;
	struct ver_block	*prev;
	string_t		*name;
	ver_value_t		*values;
} ver_block_t;

typedef struct versioninfo {
	int	filever_maj1;
	int	filever_maj2;
	int	filever_min1;
	int	filever_min2;
	int	prodver_maj1;
	int	prodver_maj2;
	int	prodver_min1;
	int	prodver_min2;
	int	fileos;
	int	fileflags;
	int	fileflagsmask;
	int	filetype;
	int	filesubtype;
	struct {
543 544 545 546 547 548 549
		unsigned fv:1;
		unsigned pv:1;
		unsigned fo:1;
		unsigned ff:1;
		unsigned ffm:1;
		unsigned ft:1;
		unsigned fst:1;
Alexandre Julliard's avatar
Alexandre Julliard committed
550 551
	} gotit;
	ver_block_t	*blocks;
552 553
	lvc_t		lvc;
	DWORD		memopt;
Alexandre Julliard's avatar
Alexandre Julliard committed
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
} versioninfo_t;

/* Accelerator structures */
#define WRC_AF_VIRTKEY	0x0001
#define WRC_AF_NOINVERT	0x0002
#define WRC_AF_SHIFT	0x0004
#define WRC_AF_CONTROL	0x0008
#define WRC_AF_ALT	0x0010
#define WRC_AF_ASCII	0x4000

typedef struct event {
	struct event	*next;
	struct event	*prev;
	int		flags;
	int		key;
	int		id;
} event_t;

typedef struct accelerator {
	DWORD		memopt;
	lvc_t		lvc;
	event_t		*events;
} accelerator_t;

578 579 580
/* Toolbar structures */
typedef struct toolbar_item {
	struct toolbar_item	*next;
581
	struct toolbar_item	*prev;
582 583 584 585 586 587 588 589 590 591 592 593
	int			id;
} toolbar_item_t;

typedef struct toolbar {
	DWORD		memopt;
	lvc_t		lvc;
	int		button_width;
	int		button_height;
	int		nitems;
	toolbar_item_t	*items;
} toolbar_t;

594 595 596 597 598 599
typedef struct dlginit {
	DWORD		memopt;
	raw_data_t	*data;
} dlginit_t;


Alexandre Julliard's avatar
Alexandre Julliard committed
600 601 602 603 604 605 606 607 608
/* A top-level resource node */
typedef struct resource {
	struct resource	*next;
	struct resource *prev;
	enum res_e	type;
	name_id_t	*name;	/* resource's name */
	language_t	*lan;	/* Only used as a sorting key and c-name creation*/
	union {
		accelerator_t	*acc;
609
		ani_curico_t	*ani;
Alexandre Julliard's avatar
Alexandre Julliard committed
610 611 612 613 614
		bitmap_t	*bmp;
		cursor_t	*cur;
		cursor_group_t	*curg;
		dialog_t	*dlg;
		dialogex_t	*dlgex;
615
		dlginit_t       *dlgi;
Alexandre Julliard's avatar
Alexandre Julliard committed
616
		font_t		*fnt;
617
		fontdir_t	*fnd;
Alexandre Julliard's avatar
Alexandre Julliard committed
618 619 620 621 622
		icon_t		*ico;
		icon_group_t	*icog;
		menu_t		*men;
		menuex_t	*menex;
		messagetable_t	*msg;
623
		html_t		*html;
Alexandre Julliard's avatar
Alexandre Julliard committed
624 625
		rcdata_t	*rdt;
		stringtable_t	*stt;
626
		toolbar_t	*tbt;
Alexandre Julliard's avatar
Alexandre Julliard committed
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651
		user_t		*usr;
		versioninfo_t	*ver;
		void		*overlay; /* To catch all types at once... */
	} res;
	res_t		*binres;	/* To binary converted resource */
	char		*c_name;	/* BaseName in output */
	DWORD		memopt;
} resource_t;

/* Resource count */
typedef struct res32_count {
	int			count;
	resource_t		**rsc;
} res32_count_t;

typedef struct res_count {
	name_id_t		type;
	int			count;		/* win16 mode */
	resource_t		**rscarray;
	int			count32;
	res32_count_t		*rsc32array;	/* win32 mode */
	int			n_id_entries;
	int			n_name_entries;
} res_count_t;

652
typedef struct style_pair {
653 654
    	style_t			*style;
	style_t			*exstyle;
655 656
} style_pair_t;

Alexandre Julliard's avatar
Alexandre Julliard committed
657
#endif