home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sdktools / imagedit / imagedit.h < prev    next >
C/C++ Source or Header  |  1996-06-12  |  12KB  |  345 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*                 Copyright (C) 1987-1996 Microsoft Corp.                  */
  4. /*                           All Rights Reserved                            */
  5. /*                                                                          */
  6. /****************************************************************************/
  7. /****************************** Module Header *******************************
  8. * Module Name: imagedit.h
  9. *
  10. * Main header file for the Image Editor.
  11. *
  12. * History:
  13. *
  14. ****************************************************************************/
  15.  
  16. #define WIN31
  17. #define _WINDOWS
  18. #define NOMINMAX
  19. #include <windows.h>
  20.  
  21.  
  22. #ifdef DBG
  23. #define STATICFN
  24. #else
  25. #define STATICFN         static
  26. #endif
  27.  
  28. #define WINDOWPROC      LONG  APIENTRY
  29. #define DIALOGPROC      BOOL  APIENTRY
  30.  
  31. /*
  32.  * Typedef for a drawing proc (a tool).
  33.  */
  34. typedef VOID (*DRAWPROC)(HWND, UINT, POINT);
  35.  
  36. #define CCHTEXTMAX      256
  37.  
  38. /*
  39.  * Maximum size of a file name plus path specification.
  40.  */
  41. #define CCHMAXPATH              260
  42.  
  43.  
  44. /*
  45.  * Defines for the different tools.  These are indexes into
  46.  * the gaTools table.
  47.  */
  48. #define TOOL_FIRST                  0
  49. #define TOOL_PENCIL                 0
  50. #define TOOL_BRUSH                  1
  51. #define TOOL_SELECT                 2
  52. #define TOOL_LINE                   3
  53. #define TOOL_RECT                   4
  54. #define TOOL_SOLIDRECT              5
  55. #define TOOL_CIRCLE                 6
  56. #define TOOL_SOLIDCIRCLE            7
  57. #define TOOL_FLOODFILL              8
  58. #define TOOL_HOTSPOT                9
  59.  
  60. #define CTOOLS                      10      /* Number of tools.             */
  61.  
  62.  
  63. /*
  64.  * Macros to simplify working with menus. */
  65. #define MyEnableMenuItem(hMenu, wIDEnableItem, fEnable) \
  66.     EnableMenuItem((hMenu),(wIDEnableItem),(fEnable)?MF_ENABLED:MF_GRAYED)
  67.  
  68. #define MyCheckMenuItem(hMenu, wIDCheckItem, fCheck) \
  69.     CheckMenuItem((hMenu),(wIDCheckItem),(fCheck)?MF_CHECKED:MF_UNCHECKED)
  70.  
  71.  
  72. /*
  73.  * Defines for strings.
  74.  */
  75. #define IDS_NULL                    0
  76. #define IDS_VERSION                 1
  77. #define IDS_VERSIONMINOR            2
  78. #define IDS_OUTOFMEMORY             3
  79. #define IDS_MEMERROR                4
  80. #define IDS_BADBMPFILE              5
  81. #define IDS_BADICOCURFILE           6
  82. #define IDS_BADPALFILE              7
  83. #define IDS_CANTOPEN                8
  84. #define IDS_READERROR               9
  85. #define IDS_WRITEERROR              10
  86. #define IDS_CANTCREATE              11
  87. #define IDS_NOCLIPBOARDFORMAT       12
  88. #define IDS_NOCLIPBOARD             13
  89. #define IDS_CANTEDITIMAGE           14
  90. #define IDS_SAVEFILE                15
  91. #define IDS_ENTERANUMBER            16
  92. #define IDS_BADDEVICESIZE           17
  93. #define IDS_BADDEVICECOLORS         18
  94. #define IDS_NOTSUPPORT              19
  95. #define IDS_NOIMAGES                20
  96. #define IDS_BADBMPSIZE              21
  97.  
  98. #define IDS_APPNAME                 22
  99. #define IDS_PGMTITLE                23
  100. #define IDS_UNTITLED                24
  101. #define IDS_DOTBMP                  25
  102. #define IDS_HELPFILE                26
  103. #define IDS_IMAGEDITINI             27
  104. #define IDS_ICONIMAGELABEL          28
  105. #define IDS_BITMAPIMAGELABEL        29
  106. #define IDS_CURSORIMAGELABEL        30
  107. #define IDS_ICONDEVNAMEEGAVGA       31
  108. #define IDS_ICONDEVNAMEMONO         32
  109. #define IDS_ICONDEVNAMECGA          33
  110. #define IDS_CURDEVNAMEVGAMONO       34
  111. #define IDS_CURDEVNAMEVGACOLOR      35
  112. #define IDS_ICONINISECTION          36
  113. #define IDS_CURSORINISECTION        37
  114. #define IDS_BMPFILTER               38
  115. #define IDS_BMPFILTEREXT            39
  116. #define IDS_ICOFILTER               40
  117. #define IDS_ICOFILTEREXT            41
  118. #define IDS_CURFILTER               42
  119. #define IDS_CURFILTEREXT            43
  120. #define IDS_PALFILTER               44
  121. #define IDS_PALFILTEREXT            45
  122. #define IDS_ALLFILTER               46
  123. #define IDS_ALLFILTEREXT            47
  124. #define IDS_DEFEXTBMP               48
  125. #define IDS_DEFEXTICO               49
  126. #define IDS_DEFEXTCUR               50
  127. #define IDS_DEFEXTPAL               51
  128. #define IDS_UNKNOWNIMAGEFORMAT      52
  129.  
  130. /*
  131.  * The total number of strings.  This MUST be updated if strings are
  132.  * added or removed.
  133.  */
  134. #define CSTRINGS                    53
  135.  
  136.  
  137. /*
  138.  * Defines for messages.  These are indexes into the gamdMessage table.
  139.  */
  140. #define MSG_OUTOFMEMORY             0
  141. #define MSG_MEMERROR                1
  142. #define MSG_BADBMPFILE              2
  143. #define MSG_BADICOCURFILE           3
  144. #define MSG_BADPALFILE              4
  145. #define MSG_CANTOPEN                5
  146. #define MSG_READERROR               6
  147. #define MSG_WRITEERROR              7
  148. #define MSG_CANTCREATE              8
  149. #define MSG_NOCLIPBOARDFORMAT       9
  150. #define MSG_NOCLIPBOARD             10
  151. #define MSG_CANTEDITIMAGE           11
  152. #define MSG_SAVEFILE                12
  153. #define MSG_ENTERANUMBER            13
  154. #define MSG_BADDEVICESIZE           14
  155. #define MSG_BADDEVICECOLORS         15
  156. #define MSG_NOTSUPPORT              16
  157. #define MSG_NOIMAGES                17
  158. #define MSG_BADBMPSIZE              18
  159.  
  160.  
  161. /*
  162.  * Defines for the different file types.
  163.  */
  164. #define FT_BITMAP                   0
  165. #define FT_ICON                     1
  166. #define FT_CURSOR                   2
  167. #define FT_PALETTE                  3
  168.  
  169.  
  170. /*
  171.  * Macro to properly cast a FAR pointer to a near pointer.
  172.  * Casts a FAR pointer to void, then to an unsigned long integral
  173.  * value, then truncate it to a short integral value, then cast
  174.  * to a near pointer.
  175.  */
  176. #ifdef WIN32
  177. #define FAR2NEAR(lpstr)     (lpstr)
  178. #else
  179. #define FAR2NEAR(lpstr)     ((PSTR)(WORD)(DWORD)(LPVOID)(lpstr))
  180. #endif
  181.  
  182. /*
  183.  * RGB color values.
  184.  */
  185. #define RGB_BLACK               RGB(  0,   0,   0)
  186. #define RGB_WHITE               RGB(255, 255, 255)
  187. #define RGB_LIGHTGRAY           RGB(192, 192, 192)
  188. #define RGB_DARKGRAY            RGB(128, 128, 128)
  189.  
  190.  
  191. /*
  192.  * Maximum rows and columns in the color box.  This includes room for
  193.  * screen/inverse and a separating blank column.
  194.  */
  195. #define COLORCOLS               16
  196. #define COLORROWS               2
  197.  
  198. /*
  199.  * Maximum colors in the palette (not including screen/inverse).
  200.  */
  201. #define COLORSMAX               28
  202.  
  203. /*
  204.  * Defines for the different color modes that the left and right
  205.  * mouse buttons can have.
  206.  */
  207. #define MODE_COLOR              0       // A standard color.
  208. #define MODE_SCREEN             1       // The screen color.
  209. #define MODE_INVERSE            2       // The inverse screen color.
  210.  
  211.  
  212. /*
  213.  * Margin (in pixels) within each of the palette and toolbox windows.
  214.  */
  215. #define PALETTEMARGIN           2
  216.  
  217. /* raster op combination modes */
  218. #define ROP_DSna                0x00220326L
  219. #define ROP_DSPao               0x00EA02E9L
  220.  
  221. #define DEFAULTBITMAPWIDTH      32      // Default bitmap width.
  222. #define DEFAULTBITMAPHEIGHT     32      // Default bitmap height.
  223. #define DEFAULTBITMAPCOLORS     16      // Default bitmap colors.
  224.  
  225. #define MAXIMAGEDIM             256     // Max image width/height (dimension).
  226. #define MAXIMAGES               64      // Maximum images in an ico/cur file.
  227.  
  228. #define CCHDESCRIPTOR        80  /* length of image descriptor string */
  229. #define CCHDEVICENAMEMAX     20  /* maximum length of a device name */
  230.  
  231. /*
  232.  * Maximum sizes of the app window when running ImagEdit for the first time.
  233.  * This makes it so that the editor does not default to a huge size when
  234.  * run on a super-vga resolution monitor.
  235.  */
  236. #define MAXDEFAULTAPPCX         640
  237. #define MAXDEFAULTAPPCY         480
  238.  
  239.  
  240. /*************************************************************************/
  241.  
  242. /* 3.0 icon/cursor header  */
  243. typedef struct {
  244.     WORD iReserved;            /* always 0 */
  245.     WORD iResourceType;
  246.     WORD iResourceCount;       /* number of resources in file */
  247. } ICOCURSORHDR;
  248.  
  249. /* 3.0 icon/cursor descriptor  */
  250. typedef struct {
  251.     BYTE iWidth;               /* width of image (icons only ) */
  252.     BYTE iHeight;              /* height of image(icons only) */
  253.     BYTE iColorCount;          /* number of colors in image */
  254.     BYTE iUnused;              /*  */
  255.     WORD iHotspotX;            /* hotspot x coordinate (CURSORS only) */
  256.     WORD iHotspotY;            /* hotspot y coordinate (CURSORS only) */
  257.     DWORD DIBSize;             /* size of DIB for this image */
  258.     DWORD DIBOffset;           /* offset to DIB for this image */
  259. } ICOCURSORDESC, *PICOCURSORDESC;
  260.  
  261. typedef struct DeviceNode {
  262.     struct DeviceNode *pDeviceNext; // Pointer to next device node.
  263.     INT iType;                      // Type of image (FT_*).
  264.     INT nColors;                    // Number of colors.
  265.     INT cx;                         // Width of image.
  266.     INT cy;                         // Height of image.
  267.     CHAR szName[CCHDEVICENAMEMAX];  // Device name.
  268.     CHAR szDesc[CCHDESCRIPTOR];     // Full description string.
  269. } DEVICE;
  270. typedef DEVICE *PDEVICE;
  271.  
  272. /*
  273.  * Structure that describes a link in the image list.
  274.  */
  275. typedef struct ImageNode {
  276.     struct ImageNode *pImageNext;   // Pointer to next image.
  277.     PDEVICE pDevice;                // Pointer to device structure.
  278.     INT cx;                         // Image width.
  279.     INT cy;                         // Image height.
  280.     INT iHotspotX;                  // Hotspot x coordinate (cursors only).
  281.     INT iHotspotY;                  // Hotspot y coordinate (cursors only).
  282.     INT nColors;                    // Number of colors.
  283.     DWORD DIBSize;                  // Size of DIB for this image.
  284.     HANDLE DIBhandle;               // Handle to DIB bits.
  285.     LPSTR DIBPtr;                   // Pointer to DIB bits.
  286. } IMAGEINFO, *PIMAGEINFO;
  287.  
  288. /*
  289.  * Defines an entry in the gamdMessages table of error and warning messages.
  290.  */
  291. typedef struct {
  292.     UINT ids;                   /* String id for the message text.          */
  293.     UINT fMessageBox;           /* Flags for the MessageBox function.       */
  294. } MESSAGEDATA;
  295.  
  296. /*
  297.  * This structure defines each tool used in the editor.
  298.  */
  299. typedef struct {
  300.     DRAWPROC pfnDrawProc;   /* Drawing procedure for this tool type.        */
  301.     HCURSOR hcur;           /* Handle to the cursor for this tool.          */
  302.     INT idbmToolBtnUp;      /* ID of "up" bmp res. for the Toolbox button.  */
  303.     HBITMAP hbmToolBtnUp;   /* hbm of "up" bitmap for the Toolbox button.   */
  304.     INT idbmToolBtnDown;    /* ID of "down" bmp res. for the Toolbox button.*/
  305.     HBITMAP hbmToolBtnDown; /* hbm of "down" bitmap for the Toolbox button. */
  306.     UINT fDrawOnDown:1;     /* TRUE if tool draws on down click.            */
  307.     UINT fDrawOnUp:1;       /* TRUE if tool draws on up click.              */
  308. } TOOLS;
  309.  
  310. /*
  311.  * One single entry for an environment setting saved in the
  312.  * profile file.  Used by ReadEnv and WriteEnv.
  313.  */
  314. typedef struct _INIENTRY {
  315.     PSTR pstrKeyName;
  316.     PINT pnVar;
  317.     INT nDefault;
  318.     INT nSave;
  319. } INIENTRY;
  320.  
  321. /*
  322.  * Structure that maps a subject (like a menu id or a dialog id) with
  323.  * a help context to pass in to WinHelp.
  324.  */
  325. typedef struct {
  326.     INT idSubject;              // Subject, usually a menu or dialog id.
  327.     INT HelpContext;            // The matching help context.
  328. } HELPMAP;
  329. typedef HELPMAP *PHELPMAP;
  330.  
  331.  
  332. #include "iefuncs.h"
  333.  
  334. #include "globals.h"
  335.  
  336. #ifdef strcmpi
  337. #undef strcmpi
  338. #endif
  339. #define strcmpi     lstrcmpi
  340. #define strtok      My_mbstok
  341. #define strncat     My_mbsncat
  342. unsigned char * _CRTAPI1 My_mbstok(unsigned char *, unsigned char *);
  343. unsigned char * _CRTAPI1 My_mbsncat(
  344.                     unsigned char *, const unsigned char *, size_t);
  345.