Annotation of mstools/samples/sdktools/imagedit/globals.c, revision 1.1

1.1     ! root        1: /****************************************************************************/
        !             2: /*                                                                          */
        !             3: /*                         Microsoft Confidential                           */
        !             4: /*                                                                          */
        !             5: /*                 Copyright (c) Microsoft Corp.  1987, 1991                */
        !             6: /*                           All Rights Reserved                            */
        !             7: /*                                                                          */
        !             8: /****************************************************************************/
        !             9: /****************************** Module Header *******************************
        !            10: * Module Name: globals.c
        !            11: *
        !            12: * Global data for the image editor.
        !            13: *
        !            14: * History:
        !            15: *
        !            16: ****************************************************************************/
        !            17: 
        !            18: #include "imagedit.h"
        !            19: #include "dialogs.h"
        !            20: #include "iehelp.h"
        !            21: #include "ids.h"
        !            22: 
        !            23: 
        !            24: /*
        !            25:  * Initialized data and structures -----------------------------------------
        !            26:  */
        !            27: 
        !            28: /*
        !            29:  * Initialization data structure.  This describes each profile entry
        !            30:  * that is contained in the initialization file.
        !            31:  */
        !            32: INIENTRY gaie[] = {
        !            33:     { "fGrid",          &gfGrid,            FALSE,              0 },
        !            34:     { "fShowColor",     &gfShowColor,       TRUE,               0 },
        !            35:     { "fShowView",      &gfShowView,        TRUE,               0 },
        !            36:     { "fShowToolbox",   &gfShowToolbox,     TRUE,               0 },
        !            37:     { "nBrushSize",     &gnBrushSize,       3,                  0 },
        !            38:     { NULL,             NULL,               0,                  0 }
        !            39: };
        !            40: 
        !            41: BOOL gfGrid;                        // TRUE if the grid is on.
        !            42: BOOL gfShowColor;                   // TRUE if Color palette is to be shown.
        !            43: BOOL gfShowView;                    // TRUE if View window is to be shown.
        !            44: BOOL gfShowToolbox;                 // TRUE if Toolbox is to be shown.
        !            45: INT gnBrushSize;                    // Current brush size.
        !            46: 
        !            47: CHAR szAppPos[] = "AppPos";         // App window's position keyname.
        !            48: CHAR szTBPos[] = "TBPos";           // Toolbox window's position keyname.
        !            49: CHAR szViewPos[] = "ViewPos";       // View window's position keyname.
        !            50: CHAR szColorPos[] = "ColorPos";     // Color palette window's position keyname.
        !            51: CHAR szrgbScreen[] = "rgbScreen";   // Screen color keyname.
        !            52: 
        !            53: 
        !            54: /*
        !            55:  * Instance handles, window handles and class strings ----------------------
        !            56:  */
        !            57: 
        !            58: HANDLE ghInst;                      // App instance handle.
        !            59: HANDLE haccelTbl;                   // Accelerator table handle.
        !            60: HCURSOR hcurWait;                   // Standard hourglass cursor.
        !            61: 
        !            62: HWND ghwndMain;                     // Main app window handle.
        !            63: HWND ghwndWork;                     // Workspace window handle.
        !            64: HWND ghwndPropBar;                  // Properties Bar window handle.
        !            65: HWND ghwndToolbox;                  // Toolbox window handle.
        !            66: HWND ghwndView;                     // View window handle.
        !            67: HWND ghwndColor;                    // Color palette window handle.
        !            68: 
        !            69: CHAR szMainClass[] = "ImagEdit";    // Main window class.
        !            70: CHAR szWorkClass[] = "Work";        // Work window class.
        !            71: CHAR szToolboxClass[] = "Toolbox";  // Toolbox window class.
        !            72: CHAR szToolBtnClass[] = "ToolBtn";  // Toolbox button window class.
        !            73: CHAR szViewClass[] = "View";        // View window class.
        !            74: CHAR szColorBoxClass[] = "ColorBox";// Color box window class.
        !            75: CHAR szColorLRClass[] = "ColorLR";  // Color Left-Right sample class.
        !            76: 
        !            77: 
        !            78: /*
        !            79:  * Device list globals -----------------------------------------------------
        !            80:  */
        !            81: 
        !            82: PDEVICE gpIconDeviceHead = NULL;    // Head of icon device list.
        !            83: INT gnIconDevices = 0;              // Number of icon devices.
        !            84: PDEVICE gpCursorDeviceHead = NULL;  // Head of cursor device list.
        !            85: INT gnCursorDevices = 0;            // Number of cursor devices.
        !            86: 
        !            87: 
        !            88: /*
        !            89:  * Globals that describe the current file and image being edited -----------
        !            90:  */
        !            91: 
        !            92: CHAR gszFullFileName[CCHMAXPATH];   // Full path name of current file.
        !            93: PSTR gpszFileName = NULL;           // Current file name (or NULL).
        !            94: INT giType = FT_BITMAP;             // Type of object being edited currently.
        !            95: PIMAGEINFO gpImageHead = NULL;      // Head of image linked list.
        !            96: INT gnImages = 0;                   // Number of images in the file.
        !            97: BOOL fFileDirty;                    // TRUE if the file is dirty.
        !            98: 
        !            99: PIMAGEINFO gpImageCur = NULL;       // Pointer to current image.
        !           100: INT gcxImage;                       // Width of the image.
        !           101: INT gcyImage;                       // Height of the image.
        !           102: INT gnColors = 16;                  // Number of colors of current image.
        !           103: BOOL fImageDirty;                   // TRUE if the image is dirty.
        !           104: 
        !           105: 
        !           106: /*
        !           107:  * Drawing DC's and bitmaps ------------------------------------------------
        !           108:  */
        !           109: 
        !           110: HDC ghdcImage = NULL;               // Image XOR DC.
        !           111: HBITMAP ghbmImage = NULL;           // Image XOR bitmap.
        !           112: 
        !           113: HDC ghdcANDMask = NULL;             // Image AND mask DC.
        !           114: HBITMAP ghbmANDMask = NULL;         // Image AND mask bitmap.
        !           115: 
        !           116: HBITMAP ghbmUndo = NULL;            // Backup of XOR bitmap for undo.
        !           117: HBITMAP ghbmUndoMask = NULL;        // Backup of AND mask bitmap for undo.
        !           118: 
        !           119: 
        !           120: /*
        !           121:  * Globals for the color palette and drawing -------------------------------
        !           122:  */
        !           123: 
        !           124: INT giColorLeft;                    // Index to the left color in gargbCurrent.
        !           125: INT giColorRight;                   // Index to the right color in gargbCurrent.
        !           126: INT gfModeLeft;                     // Mode of the left color brush.
        !           127: INT gfModeRight;                    // Mode of the right color brush.
        !           128: HBRUSH ghbrLeft = NULL;             // Brush with left mouse button color.
        !           129: HBRUSH ghbrLeftSolid = NULL;        // Brush with solid left button color.
        !           130: HBRUSH ghbrRight = NULL;            // Brush with right mouse button color.
        !           131: HBRUSH ghbrRightSolid = NULL;       // Brush with solid right button color.
        !           132: HBRUSH ghbrScreen = NULL;           // Brush with screen color.
        !           133: HBRUSH ghbrInverse = NULL;          // Brush with inverse screen color.
        !           134: HPEN ghpenLeft = NULL;              // Left color pen.
        !           135: HPEN ghpenRight = NULL;             // Right color pen.
        !           136: DWORD grgbScreenDefault;            // Default screen color.
        !           137: DWORD grgbScreen;                   // RGB of screen color.
        !           138: DWORD grgbInverse;                  // RGB of inverse screen color.
        !           139: DWORD *gargbCurrent;                // Points to the current color table.
        !           140: DWORD gargbColor[COLORSMAX];        // Current color color table.
        !           141: DWORD gargbMono[COLORSMAX];         // Current monochrome color table.
        !           142: HPEN hpenDarkGray = NULL;           // A dark gray pen.
        !           143: 
        !           144: DRAWPROC gpfnDrawProc;              // Current drawing functions.
        !           145: INT gCurTool = -1;                  // Current tool (TOOL_* define).
        !           146: HBRUSH ghbrDraw = NULL;             // Current drawing brush.
        !           147: HBRUSH ghbrDrawSolid = NULL;        // Current solid drawing brush.
        !           148: HPEN ghpenDraw = NULL;              // Current drawing pen.
        !           149: INT gfDrawMode;                     // Mode of current drawing brush.
        !           150: 
        !           151: /*
        !           152:  * The default color palette.
        !           153:  */
        !           154: DWORD gargbDefaultColor[] = {
        !           155:     RGB(255, 255, 255), RGB(0, 0, 0),
        !           156:     RGB(192, 192, 192), RGB(128, 128, 128),
        !           157:     RGB(255, 0, 0),     RGB(128, 0, 0),
        !           158:     RGB(255, 255, 0),   RGB(128, 128, 0),
        !           159:     RGB(0, 255, 0),     RGB(0, 128, 0),
        !           160:     RGB(0, 255, 255),   RGB(0, 128, 128),
        !           161:     RGB(0, 0, 255),     RGB(0, 0, 128),
        !           162:     RGB(255, 0, 255),   RGB(128, 0, 128),
        !           163:     RGB(255, 255, 128), RGB(128, 128, 64),
        !           164:     RGB(0, 255, 128),   RGB(0, 64, 64),
        !           165:     RGB(128, 255, 255), RGB(0, 128, 255),
        !           166:     RGB(128, 128, 255), RGB(0, 64, 128),
        !           167:     RGB(255, 0, 128),   RGB(64, 0, 128),
        !           168:     RGB(255, 128, 64),  RGB(128, 64, 0)
        !           169: };
        !           170: 
        !           171: /*
        !           172:  * The default monochrome palette.
        !           173:  */
        !           174: DWORD gargbDefaultMono[] =   {
        !           175:     RGB(255, 255, 255), RGB(0, 0, 0),
        !           176:     RGB(128, 128, 128), RGB(9, 9, 9),
        !           177:     RGB(137, 137, 137), RGB(18, 18, 18),
        !           178:     RGB(146, 146, 146), RGB(27, 27, 27),
        !           179:     RGB(155, 155, 155), RGB(37, 37, 37),
        !           180:     RGB(164, 164, 164), RGB(46, 46, 46),
        !           181:     RGB(173, 173, 173), RGB(55, 55, 55),
        !           182:     RGB(182, 182, 182), RGB(63, 63, 63),
        !           183:     RGB(191, 191, 191), RGB(73, 73, 73),
        !           184:     RGB(201, 201, 201), RGB(82, 82, 82),
        !           185:     RGB(212, 212, 212), RGB(92, 92, 92),
        !           186:     RGB(222, 222, 222), RGB(101, 101, 101),
        !           187:     RGB(231, 231, 231), RGB(110, 110, 110),
        !           188:     RGB(245, 245, 245), RGB(119, 119, 119)
        !           189: };
        !           190: 
        !           191: /*
        !           192:  * Color table for monochrome DIB's.
        !           193:  */
        !           194: DWORD gargbColorTable2[] = {
        !           195:     RGB(0, 0, 0),
        !           196:     RGB(255, 255, 255)
        !           197: };
        !           198: 
        !           199: /*
        !           200:  * Array that describes each tool used in the editor.  This table
        !           201:  * is indexed by the TOOL_* defines.
        !           202:  */
        !           203: TOOLS gaTools[] = {
        !           204:     { PencilDP,     NULL,   IDBM_TUPENCIL,  NULL,   IDBM_TDPENCIL,  NULL,
        !           205:         TRUE, FALSE },
        !           206:     { BrushDP,      NULL,   IDBM_TUBRUSH,   NULL,   IDBM_TDBRUSH,   NULL,
        !           207:         TRUE, FALSE },
        !           208:     { PickDP,       NULL,   IDBM_TUSELECT,  NULL,   IDBM_TDSELECT,  NULL,
        !           209:         FALSE, FALSE },
        !           210:     { LineDP,       NULL,   IDBM_TULINE,    NULL,   IDBM_TDLINE,    NULL,
        !           211:         FALSE, TRUE },
        !           212:     { RectDP,       NULL,   IDBM_TURECT,    NULL,   IDBM_TDRECT,    NULL,
        !           213:         FALSE, TRUE },
        !           214:     { RectDP,       NULL,   IDBM_TUSRECT,   NULL,   IDBM_TDSRECT,   NULL,
        !           215:         FALSE, TRUE },
        !           216:     { CircleDP,     NULL,   IDBM_TUCIRCLE,  NULL,   IDBM_TDCIRCLE,  NULL,
        !           217:         FALSE, TRUE },
        !           218:     { CircleDP,     NULL,   IDBM_TUSCIRCL,  NULL,   IDBM_TDSCIRCL,  NULL,
        !           219:         FALSE, TRUE },
        !           220:     { FloodDP,      NULL,   IDBM_TUFLOOD,   NULL,   IDBM_TDFLOOD,   NULL,
        !           221:         TRUE, FALSE },
        !           222:     { HotSpotDP,    NULL,   IDBM_TUHOTSPT,  NULL,   IDBM_TDHOTSPT,  NULL,
        !           223:         FALSE, FALSE }
        !           224: };
        !           225: 
        !           226: 
        !           227: /*
        !           228:  * Globals and tables for messages and help --------------------------------
        !           229:  */
        !           230: 
        !           231: /*
        !           232:  * Message box messages, for the Message() function.
        !           233:  */
        !           234: MESSAGEDATA gamdMessages[] = {
        !           235:     { IDS_OUTOFMEMORY,          MB_OK | MB_ICONHAND                 },
        !           236:     { IDS_MEMERROR,             MB_OK | MB_ICONHAND                 },
        !           237:     { IDS_BADBMPFILE,           MB_OK | MB_ICONEXCLAMATION          },
        !           238:     { IDS_BADICOCURFILE,        MB_OK | MB_ICONEXCLAMATION          },
        !           239:     { IDS_BADPALFILE,           MB_OK | MB_ICONEXCLAMATION          },
        !           240:     { IDS_CANTOPEN,             MB_OK | MB_ICONEXCLAMATION          },
        !           241:     { IDS_READERROR,            MB_OK | MB_ICONEXCLAMATION          },
        !           242:     { IDS_WRITEERROR,           MB_OK | MB_ICONEXCLAMATION          },
        !           243:     { IDS_CANTCREATE,           MB_OK | MB_ICONEXCLAMATION          },
        !           244:     { IDS_NOCLIPBOARDFORMAT,    MB_OK | MB_ICONEXCLAMATION          },
        !           245:     { IDS_NOCLIPBOARD,          MB_OK | MB_ICONEXCLAMATION          },
        !           246:     { IDS_CANTEDITIMAGE,        MB_OK | MB_ICONEXCLAMATION          },
        !           247:     { IDS_SAVEFILE,             MB_YESNOCANCEL | MB_ICONEXCLAMATION },
        !           248:     { IDS_ENTERANUMBER,         MB_OK | MB_ICONEXCLAMATION          },
        !           249:     { IDS_BADDEVICESIZE,        MB_OK | MB_ICONEXCLAMATION          },
        !           250:     { IDS_BADDEVICECOLORS,      MB_OK | MB_ICONEXCLAMATION          },
        !           251:     { IDS_NOTSUPPORT,           MB_OK | MB_ICONEXCLAMATION          },
        !           252:     { IDS_NOIMAGES,             MB_OK | MB_ICONEXCLAMATION          },
        !           253:     { IDS_BADBMPSIZE,           MB_OK | MB_ICONEXCLAMATION          }
        !           254: };
        !           255: 
        !           256: INT gidCurrentDlg = 0;              // Current dialog id (null if none).
        !           257: INT gMenuSelected = 0;              // Currently selected menu item.
        !           258: CHAR gszHelpFile[CCHMAXPATH];       // Path to the help file.
        !           259: HHOOK ghhkMsgFilter;                // Hook handle for message filter func.
        !           260: FARPROC lpfnMsgFilterHookFunc;      // The message filter proc instance.
        !           261: 
        !           262: /*
        !           263:  * Table that maps menu items to help context id's for them.
        !           264:  */
        !           265: HELPMAP gahmapMenu[] = {
        !           266:     {MENU_FILE_NEW,             HELPID_FILE_NEW                 },
        !           267:     {MENU_FILE_OPEN,            HELPID_FILE_OPEN                },
        !           268:     {MENU_FILE_SAVE,            HELPID_FILE_SAVE                },
        !           269:     {MENU_FILE_SAVEAS,          HELPID_FILE_SAVEAS              },
        !           270:     {MENU_FILE_LOADCOLORS,      HELPID_FILE_LOADCOLORS          },
        !           271:     {MENU_FILE_SAVECOLORS,      HELPID_FILE_SAVECOLORS          },
        !           272:     {MENU_FILE_DEFAULTCOLORS,   HELPID_FILE_DEFAULTCOLORS       },
        !           273:     {MENU_FILE_EXIT,            HELPID_FILE_EXIT                },
        !           274: 
        !           275:     {MENU_EDIT_UNDO,            HELPID_EDIT_UNDO                },
        !           276:     {MENU_EDIT_RESTORE,         HELPID_EDIT_RESTORE             },
        !           277:     {MENU_EDIT_COPY,            HELPID_EDIT_COPY                },
        !           278:     {MENU_EDIT_PASTE,           HELPID_EDIT_PASTE               },
        !           279:     {MENU_EDIT_CLEAR,           HELPID_EDIT_CLEAR               },
        !           280:     {MENU_EDIT_NEWIMAGE,        HELPID_EDIT_NEWIMAGE            },
        !           281:     {MENU_EDIT_SELECTIMAGE,     HELPID_EDIT_SELECTIMAGE         },
        !           282:     {MENU_EDIT_DELETEIMAGE,     HELPID_EDIT_DELETEIMAGE         },
        !           283: 
        !           284:     {MENU_OPTIONS_GRID,         HELPID_OPTIONS_GRID             },
        !           285:     {MENU_OPTIONS_BRUSH2,       HELPID_OPTIONS_BRUSH2           },
        !           286:     {MENU_OPTIONS_BRUSH3,       HELPID_OPTIONS_BRUSH3           },
        !           287:     {MENU_OPTIONS_BRUSH4,       HELPID_OPTIONS_BRUSH4           },
        !           288:     {MENU_OPTIONS_BRUSH5,       HELPID_OPTIONS_BRUSH5           },
        !           289:     {MENU_OPTIONS_SHOWCOLOR,    HELPID_OPTIONS_SHOWCOLOR        },
        !           290:     {MENU_OPTIONS_SHOWVIEW,     HELPID_OPTIONS_SHOWVIEW         },
        !           291:     {MENU_OPTIONS_SHOWTOOLBOX,  HELPID_OPTIONS_SHOWTOOLBOX      },
        !           292: 
        !           293:     {MENU_HELP_CONTENTS,        HELPID_HELP_CONTENTS            },
        !           294:     {MENU_HELP_SEARCH,          HELPID_HELP_SEARCH              },
        !           295:     // No help for the About menu command.
        !           296: 
        !           297:     {0,                         0                               }
        !           298: };
        !           299: 
        !           300: /*
        !           301:  * Table that maps dialog ids to help context id's for them.
        !           302:  */
        !           303: HELPMAP gahmapDialog[] = {
        !           304:     // No help for the About dialog.
        !           305:     {DID_BITMAPSIZE,            HELPID_BITMAPSIZE               },
        !           306:     {DID_PASTEOPTIONS,          HELPID_PASTEOPTIONS             },
        !           307:     {DID_NEWCURSORIMAGE,        HELPID_NEWCURSORIMAGE           },
        !           308:     {DID_NEWICONIMAGE,          HELPID_NEWICONIMAGE             },
        !           309:     {DID_SELECTCURSORIMAGE,     HELPID_SELECTCURSORIMAGE        },
        !           310:     {DID_SELECTICONIMAGE,       HELPID_SELECTICONIMAGE          },
        !           311:     {DID_RESOURCETYPE,          HELPID_RESOURCETYPE             },
        !           312: 
        !           313:     {DID_COMMONFILEOPEN,        HELPID_COMMONFILEOPEN           },
        !           314:     {DID_COMMONFILESAVE,        HELPID_COMMONFILESAVE           },
        !           315:     {DID_COMMONFILEOPENPAL,     HELPID_COMMONFILEOPENPAL        },
        !           316:     {DID_COMMONFILESAVEPAL,     HELPID_COMMONFILESAVEPAL        },
        !           317:     {DID_COMMONFILECHOOSECOLOR, HELPID_COMMONFILECHOOSECOLOR    },
        !           318: 
        !           319:     {DID_TOOLBOX,               HELPID_TOOLBOX                  },
        !           320:     {DID_PROPBAR,               HELPID_PROPERTIESBAR            },
        !           321:     {DID_COLOR,                 HELPID_COLORPALETTE             },
        !           322:     {DID_VIEW,                  HELPID_VIEW                     },
        !           323: 
        !           324:     {0,                         0                               }
        !           325: };
        !           326: 
        !           327: 
        !           328: /*
        !           329:  * Misc. globals -----------------------------------------------------------
        !           330:  */
        !           331: 
        !           332: INT gcxWorkSpace;                   // Width of workspace window.
        !           333: INT gcyWorkSpace;                   // Height of workspace window.
        !           334: INT gZoomFactor;                    // Magnification factor of image.
        !           335: 
        !           336: RECT grcPick;                       // The current picking rectangle.
        !           337: INT gcxPick;                        // Width of picking rectangle.
        !           338: INT gcyPick;                        // Height of picking rectangle.
        !           339: 
        !           340: UINT ClipboardFormat;               // ID of private clipboard format.
        !           341: BOOL fStretchClipboardData = TRUE;  // TRUE to default to stretch on paste.
        !           342: 
        !           343: INT iNewFileType;                   // New file type the user selected.
        !           344: 
        !           345: INT gcyBorder;                      // System border height.
        !           346: INT gcyPropBar;                     // Height of PropBar window.
        !           347: 
        !           348: WNDPROC lpfnPropBarDlgProc = NULL;  // Proc inst. of PropBar dialog proc.
        !           349: WNDPROC lpfnColorDlgProc = NULL;    // Proc inst. of Color palette dlg proc.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.