wrctypes.h 12 KB

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