home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / pm / graphics / graphic.h < prev    next >
C/C++ Source or Header  |  1999-05-11  |  13KB  |  349 lines

  1. /************ GRAPHIC C Sample Program Header File (.H) ******************
  2.  *  Copyright (C) 1991, 1993 IBM Corporation
  3.  *
  4.  *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  5.  *      sample code created by IBM Corporation. This sample code is not
  6.  *      part of any standard or IBM product and is provided to you solely
  7.  *      for  the purpose of assisting you in the development of your
  8.  *      applications.  The code is provided "AS IS", without
  9.  *      warranty of any kind.  IBM shall not be liable for any damages
  10.  *      arising out of your use of the sample code, even if they have been
  11.  *      advised of the possibility of such damages.                                                    *
  12.  ******************************************************************************/
  13.  
  14. /*  Macros */
  15.  
  16. #define DRIVERNAME_LENGTH    128
  17. #define DESCRIPTION_LENGTH   64
  18.  
  19. #define LOGOTIME_APPLNAME    "PM_ControlPanel"
  20. #define LOGOTIME_KEYNAME     "LogoDisplayTime"
  21.  
  22. #define STACK_SIZE           8192
  23.  
  24. #define MSGBOXID             222      /* message box id */
  25.  
  26. #define HELP_FILE            "GRAPHIC.HLP"
  27.  
  28. #define MAXSTRLEN            200
  29.  
  30. #define WM_USER_DEFINED_CODE (WM_USER + 1)
  31. #define WM_USER_END_ON_ERROR (WM_USER + 2)
  32.  
  33. #define STOP_THREAD          (WM_USER + 3)
  34. #define SET_TRANSFORM        (WM_USER + 4)
  35. #define DRAW_ORDERS          (WM_USER + 5)
  36. #define SIZING               (WM_USER + 6)
  37. #define DUMMY_COMMAND        (WM_USER + 7)
  38. #define FLUSH_COMMAND        (WM_USER + 8)
  39. #define STOP_DRAWING         (WM_USER + 9)
  40. #define SET_PRINT_STATUS     (WM_USER + 10)
  41. #define DRAW_GPI             (WM_USER + 12)
  42. #define DRAW_META            (WM_USER + 13)
  43. #define ENABLE_INFO_WND      (WM_USER + 14)
  44. #define POS_INFO_WND         (WM_USER + 15)
  45. #define ACTIVATE_DRAW_THREAD (WM_USER + 16)
  46. #define DISPLAY_MESSAGE      (WM_USER + 17)
  47.  
  48. #define DEVINFOSIZE 39
  49.  
  50. #define DRAW_OK       GPI_OK
  51. #define DRAW_STOPPED  2
  52.  
  53. #define CHECK_ITEM     0x0001
  54. #define INIT_MLE       0x0003
  55.  
  56. #define ALLOC_STRING    1
  57. #define STATIC_STRING   0
  58.  
  59. /* Structure-Definitions */
  60.  
  61. typedef struct _PRTTXT_DATA {
  62.     PSZ       *Text;
  63.     CHAR       QueueName[12];
  64.     CHAR       DriverName[DRIVERNAME_LENGTH];
  65.     PVOID      DriverData;         /* Driver-Data for DevOpenDC     */
  66.     HWND       hWndFrame;
  67.     CHAR       Jobname[8];
  68. } PRTTXT_DATA;
  69. typedef PRTTXT_DATA *PPRTTXT_DATA;
  70.  
  71. /* Structure for saving defaults */
  72. typedef struct _PPL_DEFAULTS {
  73.     ULONG      cy;
  74.     ULONG      cx;
  75.     CHAR       DriverName[DRIVERNAME_LENGTH];
  76. } APPL_DEFAULTS;
  77. typedef APPL_DEFAULTS *PAPPL_DEFAULTS;
  78.  
  79. typedef struct _RESOLUTION {
  80.     LONG       x;
  81.     LONG       y;
  82. } RESOLUTION;
  83. typedef  RESOLUTION *PRESOLUTION;
  84.  
  85. /* Draw Parameter */
  86. typedef struct _DRAW_PARM {
  87.     RECTL      rclBounds;         /* Bounding rectangle of the picture */
  88.     BOOL       fAllValid;         /* hrgnInvalid is empty          */
  89.     BOOL       fDrawing;          /* Asynchronous thread can draw  */
  90.     HRGN       hrgnInvalid;       /* Region used for accumulating  */
  91.                                   /* invalid regions in the        */
  92.                                   /* client area                   */
  93.     HMF        hmfPicture;
  94.     HAB        hABDraw;
  95. } DRAW_PARM;
  96. typedef DRAW_PARM *PDRAW_PARM;
  97.  
  98. /* Info window structure */
  99. typedef struct _INFO_STRUC {
  100.     HWND       hWnd;
  101.     BOOL       EnableWindow;
  102.     BOOL       Enabled;
  103.     LONG       SizeX;
  104.     LONG       SizeY;
  105.     LONG       DrawLine;
  106. } INFO_STRUC;
  107.  
  108. /* Main Parameter-Structure */
  109. typedef  struct _MAIN_PARM {
  110.     HAB        hAB;
  111.     PSZ        ProgramTitle;
  112.     HWND       hWndFrame;
  113.     HWND       hWndGRAPHICHelp;   /* Handle to Help window         */
  114.     HWND       hWndClient;
  115.     HMQ        hMQPrint;
  116.     HMQ        hMQ;
  117.     HMQ        hMQDraw;
  118.     HPS        hpsPrint;
  119.     HPS        hpsPaint;          /* Presentation space for use    */
  120.                                   /* on the main thread            */
  121.     HPS        hpsClient;         /* Client-area graphics          */
  122.     TID        DrawThreadID;
  123.     TID        PrintThreadID;
  124.     HEV        hevsemPrintEnds;
  125.     HEV        hevsemTerminate;
  126.     HEV        hevsemStop;
  127.     HDC        hdcClient;         /* Window device-context handle  */
  128.     HDC        hdcPrinter;
  129.     HMTX       hmtxsemStoppable;  /* Mutex semaphore "Stoppable"   */
  130.     HPOINTER   hptrGlass;
  131.     HPOINTER   hptrArrow;
  132.     PTIB       ptibMain;          /* Main thread and process IDs   */
  133.     PPIB       ppibMain;          /* Main thread and process IDs   */
  134.     CHAR       ErrorMsg[200];
  135.     CHAR       QueueName[12];
  136.     CHAR       DriverName[DRIVERNAME_LENGTH];
  137.     CHAR       MetafilePath[200];
  138.     CHAR       Message[200];
  139.     PVOID      DriverData;         /* Driver-Data for DevOpenDC     */
  140.     LONG       CheckedItem;
  141.     ULONG      DriverDataLength;   /* Length of DriverData          */
  142.     BOOL       PrintStatus;       /* flag set while printing       */
  143.     BOOL       PrintEnabled;
  144.     BOOL       PrintPropertiesEnabled;
  145.     BOOL       fNotReady;         /* Let the system handle         */
  146.                                   /*    client-area painting       */
  147.     BOOL       fStoppable;        /* Asynchronous thread is        */
  148.                                   /*    stoppable                  */
  149.     BOOL       DrawThreadActivated;
  150.     BOOL       ResizeWindow;
  151.     BOOL       fWaiting;          /* The main thread cannot        */
  152.                                   /*    issue GpiSetStopDraw       */
  153.     BOOL       fBusy;
  154.     DRAW_PARM  DrawParm;
  155.     INFO_STRUC InfoWnd;
  156. } MAIN_PARM;
  157. typedef MAIN_PARM *PMAIN_PARM;
  158.  
  159. /* Structure for Queue-Selection */
  160. typedef struct _QUEUE_SEL {
  161.     CHAR       QueueName[12];
  162.     CHAR       DriverName[DRIVERNAME_LENGTH];
  163.     CHAR       QueueDescription[DESCRIPTION_LENGTH];
  164.     PVOID      DriverData;           /* Pointer to Driver Data ptr */
  165.     ULONG      DriverDataLength;     /* Length of DriverData       */
  166. } QUEUE_SEL;
  167. typedef QUEUE_SEL *PQUEUE_SEL;
  168.  
  169. /* Parameter-Structure for Printer Selection Dialog */
  170. typedef struct _PRINTER_SEL_PARM {
  171.     ULONG      ulLen;                /* length of structure        */
  172.     ULONG      ulType;               /* reserved, must be NULL     */
  173.     PQUEUE_SEL QueueSelTable;        /* Queue Selection Table      */
  174.     ULONG      QueuesCount;          /* Entries in Table           */
  175.     LONG       SelectedItem;         /* Selected item, -1 = none   */
  176.     LONG       SaveSelectedItem;     /* Selected item, -1 = none   */
  177.     HAB        hAB;                  /* handle anchor block        */
  178. } PRINTER_SEL_PARM;
  179. typedef PRINTER_SEL_PARM *PPRINTER_SEL_PARM;
  180.  
  181. /*  Function Prototypes */
  182. MRESULT  EXPENTRY   WndProc(HWND hWnd,
  183.                             ULONG message,
  184.                             MPARAM mp1,
  185.                             MPARAM mp2);
  186.  
  187. MRESULT  EXPENTRY   WndProcI(HWND hWndI,
  188.                              ULONG Msg,
  189.                              MPARAM mp1,
  190.                              MPARAM mp2);
  191. extern VOID            DispErrorMsg(HAB hab,
  192.                                     HWND hwndFrame,
  193.                                     PCH FileName,
  194.                                     LONG LineNum);
  195. #define DispError(a,b) DispErrorMsg(a,b,(PCH)__FILE__,(LONG)__LINE__)
  196.  
  197. VOID       CheckPulldown(PMAIN_PARM,
  198.                          LONG);
  199. BOOL       Initialize(VOID);
  200. VOID       ReportError(VOID);
  201. VOID       EndProgram(VOID);
  202. VOID       AdjustWindowSize(PMAIN_PARM);
  203. VOID       DrawThread(PMAIN_PARM);
  204. VOID       PrintThread(PMAIN_PARM);
  205.  
  206. BOOL       SendCommand(PMAIN_PARM,
  207.                        ULONG,
  208.                        ULONG);
  209. MRESULT    WndProcCreate(HWND hwnd,
  210.                          PMAIN_PARM Parm);
  211. VOID       SetPrintItems(PMAIN_PARM Parm);
  212. VOID       SetTransform(PMAIN_PARM Parm,
  213.                         MPARAM mp1);
  214. MRESULT    WndProcPaint(PMAIN_PARM Parm);
  215. VOID       Transform(PDRAW_PARM Parm,
  216.                      HPS hpsXForm,
  217.                      PRECTL prclXform);
  218. LONG       DoDraw(HPS hpsDraw,
  219.                   PDRAW_PARM Parm,
  220.                   HRGN rgn,
  221.                   HPS InfoWnd);
  222. BOOL       Circles(HPS hpsDraw,
  223.                    PPOINTL pptlCur,
  224.                    FIXED fxSize);
  225. VOID       StopDrawing(PMAIN_PARM Parm);
  226. VOID       PrintGpiMeta(PMAIN_PARM Parm,
  227.                         ULONG Message);
  228. VOID       DisplayMessage(HWND hwndDraw,
  229.                           PSZ Message);
  230. VOID       SetTitleBarText(PMAIN_PARM Parm,
  231.                            PSZ Filename);
  232. PSZ        GetString(HAB hAB,
  233.                      ULONG ID,
  234.                      BOOL Alloc);
  235. PSZ        StringWithVarText(HAB hAB,
  236.                              ULONG ID,
  237.                              PSZ VarText,
  238.                              PSZ Result);
  239. VOID       DisplayHelpPanel(SHORT idPanel);
  240. BOOL       OpenFileDialog(HWND hwndOwner,
  241.                           PSZ pszTitle,
  242.                           PSZ pszFileExt,
  243.                           PSZ pszFilename);
  244. MRESULT EXPENTRY AboutDlg(HWND,
  245.                           USHORT,
  246.                           MPARAM,
  247.                           MPARAM);
  248. MRESULT EXPENTRY TemplateOpenFilterProc(HWND hwnd,
  249.                                         ULONG msg,
  250.                                         MPARAM mp1,
  251.                                         MPARAM mp2);
  252. VOID DisplayErrorMessage(HWND hwndDraw, PSZ Message);
  253.  
  254. extern   BOOL       QueryPrinterQueue(HAB hAB,
  255.                                       HWND hWnd,
  256.                                       PVOID *DriverData,
  257.                                       PULONG DriverDataLength,
  258.                                       PSZ QueueName,
  259.                                       PSZ DriverName);
  260. extern   BOOL       QueryDefaultQueue(PSZ, PSZ);
  261. extern   BOOL       QueryJobProperties(HAB hAB,
  262.                                        PVOID *DriverData,
  263.                                        PULONG DriverDataLength,
  264.                                        PSZ QueueDriverName,
  265.                                        PSZ QueueName,
  266.                                        PSZ PrtName,
  267.                                        BOOL Flag);
  268.  
  269. /*  Standard Dialog box ids */
  270. #define IDD_ABOUTBOX                 1002
  271. #define ID_GRAPHIC                   1001
  272. #define PINFO_ICON                   1019
  273.  
  274. /*  Dialog item ids */
  275. #define ID_ABOUT                     1003
  276. #define DLG_OK                       2010
  277.  
  278. /*  Menu item ids */
  279. #define IDM_FILE                      200
  280. #define IDM_F_GPI                     206
  281. #define IDM_F_METAFILE                208
  282. #define IDM_F_METAFILE_LOAD           210
  283. #define IDM_F_METAFILE_PREVIOUS       211
  284. #define IDM_F_PRINT                   212
  285. #define IDM_F_TEXT_PREVIOUS           216
  286. #define IDM_H_ABOUT                   218
  287. #define IDM_H_HELP                    219
  288. #define IDM_H_HELPINDEX               220
  289. #define IDM_H_HELPGEN                 221
  290. #define IDM_H_HELPUSING               222
  291. #define IDM_H_HELPKEYS                223
  292. #define IDM_INFO_OK                   228
  293.  
  294. /*  Help item ids */
  295. #define HELP_INDEX                  64044
  296. #define HELP_GEN                    20409
  297. #define HELP_KEYS                   20410
  298. #define HELP_USING                  64027
  299. #define PANEL_HELPKEYS              20818
  300. #define HID_FS_OPEN_DLG_HELP_PANEL  20809
  301.  
  302. #define IDM_OPTIONS                   224
  303. #define IDM_O_PRINTPROPERTIES         226
  304.  
  305. /*  Messagetable ids */
  306. #define  ERRMSG_REGISTER_FAILED      3004
  307. #define  ERRMSG_PRINT_THREAD         3005
  308. #define  ERRMSG_CREATE_WINDOW        3006
  309. #define  ERRMSG_INFO_WINDOW          3008
  310. #define  ERRMSG_DRAW_THREAD          3009
  311. #define  ERRMSG_NO_HELP              3010
  312. #define  ERRMSG_METAFILE_FAILED      3011
  313. #define  ERRMSG_HELP_TERMINATED      3012
  314. #define  ERRMSG_HELP_ERROR           3013
  315. #define  ERRMSG_HELPDISPLAYERROR     3014
  316. #define  ERRMSG_DRAWTHR_MSG2         3033
  317. #define  IDS_ERRORMSG                27
  318. #define  IDS_UNKNOWNMSG              28
  319.  
  320. /*  Stringtable ids */
  321. #define  APPLICATION_NAME            3037
  322. #define  FILEDLG_META_HEADER         3039
  323. #define  TEXT_SPOOLING_MESSAGE       3046
  324. #define  TEXT_DRAWTHR_SIZEGPI        3053
  325. #define  TEXT_DRAWTHR_SIZEMETA       3054
  326.  
  327. /*  Help table and subtables */
  328. #define SUBTABLE_MAIN                2000
  329. #define SUBTABLE_INFO                3000
  330.  
  331. /*  Main window help panels */
  332. #define PANEL_MAIN                   2100
  333. #define PANEL_INFO                   3100
  334.  
  335. /*  Main window subtable, includes menu item help */
  336. #define PANEL_FILE                  20801
  337. #define PANEL_FILELOAD              20803
  338. #define PANEL_PRINT                 20804
  339.  
  340. #define PANEL_HELP                  64022
  341. #define PANEL_HELPINDEX             64026
  342. #define PANEL_HELPGENERAL           64024
  343. #define PANEL_HELPUSING             64023
  344. #define PANEL_HELPABOUT             64096
  345.  
  346. /*  Message box help resource entry points */
  347. #define PANEL_INFO_OK               20805
  348. /************************** End of GRAPHIC.H ******************************/
  349.