home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / prtsampl.zip / PRTSAMP.H < prev    next >
Text File  |  1998-04-20  |  13KB  |  288 lines

  1. /**************************************************************************
  2.  *  File name  :  prtsamp.h
  3.  *
  4.  *  Description:  The PRTSAMP include file defines symbolic constants
  5.  *                and data structures used by print sample.
  6.  *
  7.  *  Concepts   :  [none]
  8.  *
  9.  *  API's      :  [none]
  10.  *
  11.  *  Copyright (C) 1991 IBM Corporation
  12.  *
  13.  *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  14.  *      sample code created by IBM Corporation. This sample code is not
  15.  *      part of any standard or IBM product and is provided to you solely
  16.  *      for  the purpose of assisting you in the development of your
  17.  *      applications.  The code is provided "AS IS", without
  18.  *      warranty of any kind.  IBM shall not be liable for any damages
  19.  *      arising out of your use of the sample code, even if they have been
  20.  *      advised of the possibility of such damages.                                                    *
  21.  *************************************************************************/
  22.  
  23. /* constants */
  24.  
  25. #define QUEUENAME_LENGTH    10
  26. #define QUEUEDESC_LENGTH    64
  27. #define DEVICENAME_LENGTH   32
  28. #define DRIVERNAME_LENGTH   128
  29.  
  30.  
  31. /* string definitions */
  32.  
  33. #define CLASSNAME            "PRTSAMP_CLIENTWINDOW"
  34. #define OBJECTCLASSNAME      "PRTSAMP_OBJECTWINDOW"
  35. #define HELP_FILE            "PRTSAMP.HLP"
  36.  
  37.  
  38.  
  39. /* length definitions */
  40.  
  41. #define LEN_STACK             6*4096
  42. #define LEN_WORKSTRING        256
  43. #define LEN_PLAYMETAFILEOPTS  PMF_DEFAULTS+1
  44. #define LEN_PLAYMETAFILEDESCS 256
  45. #define LEN_DEATH_TIMER       12000        /* milliseconds */
  46. #define LEN_SIZE_TIMER         250         /* milliseconds */
  47.  
  48.  
  49. #define ID_SIZE_TIMER           1
  50. #define ID_DEATH_TIMER         13
  51.  
  52.  
  53. /* translation offset in twips for default view matrix for both x, y */
  54. #define OFFSET_XY_TWIPS        360
  55.  
  56. /* maximum number of forms that can be handled in page setup dialog */
  57. #define MAX_FORMS              20
  58.  
  59. /* categories */
  60.  
  61. #define FLAGS_SCREEN     0
  62. #define FLAGS_PRINTER    1
  63. #define FLAGS_INFO       2
  64.  
  65. #define PAGINATE_EOF              0    /* drew nothing on the page, eof   */
  66. #define PAGINATE_NOT_EOF          1    /* drew something, and not eof yet */
  67. #define PAGINATE_EOF_PART_PAGE    2    /* drew something, and eof         */
  68.  
  69. #define VIEW_FULLSIZE             0   /* default */
  70. #define VIEW_HALFSIZE             1
  71.  
  72. #define MODE_TEXT            0
  73. #define MODE_BITMAP          1
  74. #define MODE_METAFILE        2
  75. #define MODE_UNKNOWN         3
  76.  
  77. /* user-defined messages */
  78.  
  79. #define WM_USER_CLOSE                  (  WM_USER +  0 )
  80. #define WM_USER_ACK                    (  WM_USER +  1 )
  81. #define WM_USER_ENABLE_CLIENT          (  WM_USER +  2 )
  82. #define WM_USER_DISABLE_CLIENT         (  WM_USER +  3 )
  83. #define WM_USER_SLEEP                  (  WM_USER +  4 )
  84. #define WM_USER_NEW_MODE               (  WM_USER +  5 )
  85. #define WM_USER_LOAD_TEXT              (  WM_USER +  6 )
  86. #define WM_USER_LOAD_BITMAP            (  WM_USER +  7 )
  87. #define WM_USER_LOAD_METAFILE          (  WM_USER +  8 )
  88. #define WM_USER_PAINT_BITMAP           (  WM_USER +  9 )
  89. #define WM_USER_PAINT_METAFILE         (  WM_USER + 10 )
  90. #define WM_USER_PAGINATE               (  WM_USER + 11 )
  91. #define WM_USER_PRINT                  (  WM_USER + 12 )
  92. #define WM_USER_NEW_PAGE               (  WM_USER + 13 )
  93. #define WM_USER_SKIP_PAGE              (  WM_USER + 14 )
  94. #define WM_USER_PAINT_DEFAULT_SCREEN   (  WM_USER + 15 )
  95.  
  96.  
  97. #define WM_NACK_FILE_READING_ERROR     (  WM_USER +  50 )
  98. #define WM_NACK_BITMAP_NOT_SUPPORTED   (  WM_USER +  51 )
  99. #define WM_NACK_BITMAP_ERROR           (  WM_USER +  52 )
  100.  
  101. /* user-defined structures */
  102.  
  103. /*
  104.  * Structure of form
  105.  */
  106. typedef struct _FORM {
  107.    CHAR        achFormName[32];
  108.    FIXED       fxxWidth;         /* form width in fractional inches */
  109.    FIXED       fxyHeight;        /* form height */
  110.    FIXED       fxLeftMargin;     /* left margin in fractional inches */
  111.                                  /* always multiple of 1/20 inch */
  112.    FIXED       fxRightMargin;
  113.    FIXED       fxTopMargin;
  114.    FIXED       fxBottomMargin;
  115. } FORM;
  116. typedef FORM PFORM;
  117.  
  118.  
  119. /*
  120.  * Structure of program settings that are saved in the INI.
  121.  * They are used as default setting upon the next invocation of the program.
  122.  */
  123.  
  124. typedef struct _PRTSAMP_PROFILE {
  125.  
  126.     ULONG       flOptions;
  127.     ULONG       cy;
  128.     ULONG       cx;
  129.     ULONG       y;
  130.     ULONG       x;
  131.  
  132.     FIXED       fxPointSize;
  133.     FATTRS      fAttrs;
  134.  
  135.     ULONG       ulNextMode;                     /* next mode to use     */
  136.     CHAR        szNextFilename[ CCHMAXPATH ];   /* next filename to use */
  137.  
  138.     FORM        form;                           /* next form to use     */
  139.  
  140.     CHAR        achQueueName[QUEUENAME_LENGTH];
  141.     CHAR        achDriverName[DRIVERNAME_LENGTH];
  142.     LONG        cbDriverDataLen;
  143.  
  144.     USHORT      usCopies;                          /* number of copies       */
  145.     BOOL        fPrintAllPages;       /* flag is all pages are to be printed */
  146.     USHORT      usFirstPage;                       /* first page to print    */
  147.     USHORT      usLastPage;                        /* last page to print     */
  148. } PRTSAMP_PROFILE;
  149. typedef PRTSAMP_PROFILE PPRTSAMP_PROFILE;
  150.  
  151.  
  152. /*
  153.  * block of main program parameters
  154.  * the variable that points to this block is usually named pmp
  155.  */
  156.  
  157. typedef  struct _MAIN_PARM {
  158.     HAB        hab;               /* hab obtained on thread 1                */
  159.  
  160.     HWND       hwndFrame;         /* frame handle                            */
  161.     HWND       hwndClient;        /* client window handle                    */
  162.     HWND       hwndMenubar;       /* menu handle, child of frame             */
  163.     HWND       hwndTitlebar;      /* title bar handle, child of frame        */
  164.     HWND       hwndObject;        /* object window handle on thread 2        */
  165.     HWND       hwndHScroll;       /* horizontal scroll bar handle            */
  166.     HWND       hwndVScroll;       /* vertical scroll bar handle              */
  167.     HWND       hwndHelp;          /* help instance window handle             */
  168.  
  169.     HDC        hdcClient;         /* client window device-context handle     */
  170.     HPS        hpsClient;         /* client window presentation space handle */
  171.  
  172.     HDC        hdcMemory;         /* memory dc to hold bitmap                */
  173.     HPS        hpsMemory;         /* memory ps to hold bitmap                */
  174.     HDC        hdcMem4Printer;    /* memory dc to hold bitmap when printing  */
  175.     HPS        hpsMem4Printer;    /* memory ps to hold bitmap when printing  */
  176.  
  177.     HDC        hdcPrinter;        /* current printer dc                      */
  178.     HPS        hpsPrinter;        /* current printer ps                      */
  179.  
  180.     HDC        hdcPrinterInfo;    /* dc for printer info: type OD_INFO       */
  181.     HPS        hpsPrinterInfo;    /* ps for printer info                     */
  182.  
  183.     HBITMAP    hbm;               /* handle to current bitmap in use         */
  184.     HBITMAP    hbm4Printer;       /* handle to bitmap in use when printing   */
  185.     FILE *     f;                 /* handle to current text file in use      */
  186.     HMF        hmf;               /* handle to current metafile in use       */
  187.  
  188.     BOOL       fBusy;               /* object window is busy with a task     */
  189.     BOOL       fVisitedFontDialog;  /* just visited the font dialog          */
  190.  
  191.     ULONG      ulMode;                        /* current operating mode      */
  192.     CHAR       szFilename[ CCHMAXPATH ];      /* current drive/path/filename */
  193.  
  194.     ULONG      ulNextMode;                    /* next mode to use            */
  195.     CHAR       szNextFilename[ CCHMAXPATH ];  /* next filename to use        */
  196.  
  197.     FILEDLG     filedlg;        /* for WinFileDlg                            */
  198.     FONTDLG     fontdlg;        /* for WinFontDlg                            */
  199.  
  200.     PRTSAMP_PROFILE Profile;    /* settings read/written from/to os2.ini     */
  201.  
  202.     PSZ         pszTitle;       /* app title initialized in prtcreat.c       */
  203.  
  204.     CHAR        szFamilyname[LEN_WORKSTRING]; /* fontdlg.pszFamilyname core  */
  205.  
  206.     MATRIXLF    matlfDefView;   /* default view matrix for zooming text pages */
  207.  
  208.     SIZEL       sizelPage;      /* size of page user wants, in twips          */
  209.     SIZEL       sizelClient;    /* size of client in twips; see WM_SIZE       */
  210.  
  211.     SHORT       sHScrollPos;    /* horizontal scroll bar position             */
  212.     SHORT       sHScrollRange;  /* horizontal scroll bar range                */
  213.     SHORT       sVScrollPos;    /* vertical scroll bar position               */
  214.     SHORT       sVScrollRange;  /* vertical scroll bar range                  */
  215.     float       floatScale;     /* current scaling factor for screen viewing  */
  216.  
  217.     /* current bitmap information */
  218.     ULONG       cxBitmap;
  219.     ULONG       cyBitmap;
  220.     ULONG       cxBitmapRes;
  221.     ULONG       cyBitmapRes;
  222.  
  223.     /* variables used by print queue selection/printing dialogs */
  224.     BOOL        fCancel;    /* flag to indicate user wants to cancel printing */
  225.     PPRQINFO3   pQueueInfo;               /* temp work space for a dialog */
  226.     LONG        lQueueCount;              /* temp work space for a dialog */
  227.     USHORT      usCopies;
  228.     CHAR        achQueueName[QUEUENAME_LENGTH];    /* currently-selected queue*/
  229.     CHAR        achQueueDesc[QUEUEDESC_LENGTH];    /* and description        */
  230.     CHAR        achDriverName[DRIVERNAME_LENGTH];  /* and driver             */
  231.     LONG        cbDriverDataLen;                   /* driver data length     */
  232.     PDRIVDATA   pDriverData;                       /* driver data            */
  233.     HWND        hwndPrinting;                      /* print confirmation hwnd*/
  234.  
  235.     FORM        form;                              /* form to use            */
  236.     LONG        cForms;                            /* number of forms defined*/
  237.     HCINFO      hcinfo[MAX_FORMS];                 /* form names from printer*/
  238.     ULONG       iForm;                             /* index to form chosen   */
  239.     ULONG       cLinesinFile;         /* number of lines in the text file    */
  240.     ULONG       cLinesonPage;         /* number of lines on a page           */
  241.     BOOL        fPrintAllPages;       /* flag is all pages are to be printed */
  242.     USHORT      usFirstPage;                       /* first page to print    */
  243.     USHORT      usLastPage;                        /* last page to print     */
  244.     TID         tidObjectThread;      /* thread id for object window         */
  245.     CHAR        szArgFilename[LEN_WORKSTRING];     /* filename from main args*/
  246. } MAIN_PARM;
  247. typedef MAIN_PARM *PMAIN_PARM;
  248.  
  249. /* Function prototypes used throughout print sample */
  250. void _Optlink threadmain( void * );
  251. PMAIN_PARM Create( HWND hwnd );
  252. MRESULT EXPENTRY ObjectWinProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
  253. MRESULT EXPENTRY WinProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
  254. MRESULT Menu( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
  255. ULONG APIENTRY FileTypeDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
  256. ULONG GetEAFileType( HFILE hfile, HAB hab);
  257. MRESULT APIENTRY MyFileDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
  258. MRESULT APIENTRY MyFontDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
  259. PSZ trim( PSZ s );
  260. MRESULT EXPENTRY ProdInfoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  261. VOID SetSysMenu( HWND hwnd );
  262.  
  263. BOOL QueryPrintQueue( PMAIN_PARM pmp, BOOL fNeedDialog );
  264. BOOL Print(HWND hwnd, PMAIN_PARM pmp);
  265. VOID ProcessUserPrint(HWND hwnd, PMAIN_PARM pmp);
  266. VOID GetProfile(PMAIN_PARM pmp);
  267. VOID SaveProfile(PMAIN_PARM pmp);
  268.  
  269. VOID CalibrateVerticalScrollBar( PMAIN_PARM pmp );
  270. VOID CalibrateHorizontalScrollBar( PMAIN_PARM pmp );
  271. LONG FindForm( PSZ pszFormName, PHCINFO pForms, LONG lCount);
  272. ULONG FixedInchesToTwips(FIXED fxInch);
  273. FIXED FixedPointsToTwips(FIXED fxPointSize);
  274. VOID PaintBitmap( PMAIN_PARM pmp, ULONG flag );
  275. VOID PaintMetaFile( PMAIN_PARM pmp, ULONG flag );
  276. BOOL QueryForm( PMAIN_PARM pmp, BOOL fNeedDialog );
  277. LONG QueryPrinterForms( PMAIN_PARM pmp, HCINFO hcinfo[], ULONG cMaxForms );
  278. BOOL ValidateFilename( PMAIN_PARM pmp, PSZ pszFilename, HWND hwndOwner);
  279.  
  280. #ifndef max
  281. #define max(a,b) (((a) > (b))?(a):(b))
  282. #endif
  283.  
  284. #ifndef min
  285. #define min(a,b) (((a) < (b))?(a):(b))
  286. #endif
  287. /***************************  End of prtsamp.h ****************************/
  288.