wrctypes.h 13 KB

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