home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / TOOLKIT / PM / BMPSAMP / JIGSAW.H < prev    next >
C/C++ Source or Header  |  1994-11-17  |  13KB  |  365 lines

  1. /******************************************************************************
  2. *
  3. *  File Name   : JIGSAW.H
  4. *
  5. *  Description : Jigsaw's main header file
  6. *
  7. *  Copyright (C) 1992 IBM Corporation
  8. *
  9. *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  10. *      sample code created by IBM Corporation. This sample code is not
  11. *      part of any standard or IBM product and is provided to you solely
  12. *      for  the purpose of assisting you in the development of your
  13. *      applications.  The code is provided "AS IS", without
  14. *      warranty of any kind.  IBM shall not be liable for any damages
  15. *      arising out of your use of the sample code, even if they have been
  16. *      advised of the possibility of such damages.                                                    *
  17. *
  18. ******************************************************************************/
  19.  
  20. #define INCL_BITMAPFILEFORMAT
  21.  
  22. #define INCL_DOSMEMMGR
  23. #define INCL_DOSINFOSEG
  24. #define INCL_DOSPROCESS
  25. #define INCL_DOSSEMAPHORES
  26.  
  27. #define INCL_DEV
  28. #define INCL_BASE
  29.  
  30. #define INCL_WINSYS
  31. #define INCL_WINSTDFILE
  32. #define INCL_WINHELP
  33. #define INCL_WININPUT
  34. #define INCL_WINMENUS
  35. #define INCL_WINDIALOGS
  36. #define INCL_WINFRAMEMGR
  37. #define INCL_WINPOINTERS
  38. #define INCL_WINWINDOWMGR
  39. #define INCL_WINMESSAGEMGR
  40. #define INCL_WINRECTANGLES
  41. #define INCL_WINSCROLLBARS
  42. #define INCL_WINSWITCHLIST
  43. #define INCL_WINENTRYFIELDS
  44.  
  45. #define INCL_GPIPATHS
  46. #define INCL_GPILCIDS
  47. #define INCL_GPIREGIONS
  48. #define INCL_GPICONTROL
  49. #define INCL_GPIBITMAPS
  50. #define INCL_GPIPRIMITIVES
  51. #define INCL_GPITRANSFORMS
  52.  
  53. #define INCL_ERRORS
  54.  
  55. #include <os2.h>
  56.  
  57. #define MSGBOXID                222    /* message box id */
  58. #define IDR_MAIN                1      /* action bar     */
  59.  
  60. /*
  61.  *   Bitmap resource IDs
  62.  */
  63.  
  64. #define IDB_BACK_1      41
  65.  
  66. /*
  67.  *   Menu/Submenu resource IDs
  68.  */
  69.  
  70. #define IDM_FILE                100
  71. #define IDM_LOAD                150
  72. #define IDM_SWITCH              170
  73. #define IDM_OPTIONS             200
  74. #define IDM_HIDE                220
  75. #define IDM_JUMBLE              300
  76.  
  77. #define IDM_SIZE_MENU           930
  78. #define IDM_SIZE_SMALL          940
  79. #define IDM_SIZE_MEDIUM         950
  80. #define IDM_SIZE_LARGE          960
  81. #define IDM_SIZE_FULL           970
  82.  
  83. #define IDM_HELP                90
  84. #define IDM_HELPHELPFORHELP     91
  85. #define IDM_HELPEXTENDED        92
  86. #define IDM_HELPINDEX           93
  87. #define IDM_HELPABOUT           94
  88. #define IDM_HELPTUTORIAL        99
  89.  
  90. /*
  91.  *   String resource IDs
  92.  */
  93.  
  94. #define IDS_TITLEBAR            1
  95. #define IDS_TERMINATE           2
  96. #define IDS_OPENDLGHEADER       7
  97. #define IDS_OPENDLGBUTTON       8
  98. #define IDS_FILEOPENEXTENSION   9
  99. #define IDS_CANNOTLOADSTRING    10
  100. #define IDS_CANNOTRUNFILEDLG    11
  101. #define IDS_HELPLIBRARYNAME     20
  102. #define IDS_HELPWINDOWTITLE     21
  103. #define IDS_HELPLOADERROR       22
  104. #define IDS_HELPDISPLAYERROR    23
  105. #define IDS_HELPMANAGERERROR    24
  106. #define IDS_OPTIONJUMBLE        25
  107. #define IDS_LOADBITMAP          26
  108. #define IDS_ERRORMSG            27
  109. #define IDS_UNKNOWNMSG          28
  110. #define IDS_ERROR_READ          29
  111. #define IDS_ERROR_OUTOFMEMORY   30
  112. #define IDS_ERROR_TITLE         31
  113.  
  114. /*
  115.  *   Dialog Box/Controls IDs
  116.  */
  117.  
  118. #define IDD_ABOUTBOX            1001
  119. #define IDC_OK                  1
  120. #define IDC_CANCEL              2
  121. #define IDC_HELP                3
  122. #define IDC_ICON                4
  123.  
  124. /*
  125.  *   Other defines
  126.  */
  127.  
  128. #define ADD_HEAD_SEG            1
  129. #define ADD_TAIL_SEG            2
  130. #define DEL_SEG                 3
  131. #define MAKE_TAIL_SEG           4
  132. #define MAKE_HEAD_SEG           5
  133. #define PICTURE_CREATE          0
  134. #define PICTURE_UPDATE          1
  135. #define ZOOM_MAX                8
  136. #define UNITY                   65536L         /* resets picture to full size */
  137. #define STACKSIZE               8192           /* async thread stack size     */
  138. #define MESSAGELEN              80             /* length for message buffers  */
  139. #define FILEPROTOSIZE           16             /* length for file prototypes  */
  140.  
  141.  
  142. /*----------------------- helper macros --------------------------------------*/
  143.  
  144.  
  145. /*
  146.  *   Calculate number of colors in bitmap color table based on number of
  147.  *   bits per scan line.
  148.  */
  149.  
  150. #define CCOLORS(bc)  (((bc) == 24) ? 0 : (1 << (bc)))
  151.  
  152. /*
  153.  *   Macros to round numbers up or down for specific byte alignment
  154.  *   for current display.
  155.  */
  156.  
  157. #define ROUND_DOWN_MOD( arg, mod)       \
  158.     {                                       \
  159.         if( arg < 0)                        \
  160.         {                                   \
  161.             arg -= mod - 1;                 \
  162.             arg += arg % mod;               \
  163.         } else                              \
  164.             arg -= arg % mod;               \
  165.     }
  166.  
  167. #define ROUND_UP_MOD( arg, mod)        \
  168.     {                                       \
  169.         if( arg < 0)                        \
  170.         {                                   \
  171.             arg -= arg % mod;               \
  172.         } else                              \
  173.         {                                   \
  174.             arg += mod - 1;                 \
  175.             arg -= arg % mod;               \
  176.         }                                   \
  177.     }
  178.  
  179. /*
  180.  *   shorthand cast of BITMAPFILEHEADER2 to BITMAPFILEHEADER
  181.  */
  182.  
  183. #define PBFH1(A)      ((PBITMAPFILEHEADER) (A))
  184.  
  185. /*
  186.  *   shorthand cast of BITMAPINFOHEADER2 to BITMAPINFOHEADER
  187.  */
  188.  
  189. #define PBMP1(A)      ((PBITMAPINFOHEADER) (A))
  190.  
  191. /*----------------------- inter-thread messages ------------------------------*/
  192.  
  193. #define UM_DIE        WM_USER+1       /* instruct async thread to terminate  */
  194. #define UM_DRAW       WM_USER+2       /* draw the current picture            */
  195. #define UM_VSCROLL    WM_USER+3       /* perform scroll by recalculating the */
  196.                                       /* default viewing transform           */
  197. #define UM_HSCROLL    WM_USER+4       /* perform scroll by recalculating the */
  198.                                       /* default viewing transform           */
  199. #define UM_SIZING     WM_USER+5       /* perform sizing by recalculating the */
  200.                                       /* default viewing transform           */
  201. #define UM_ZOOM       WM_USER+6       /* zoom the picture by recalculating   */
  202.                                       /* the default viewing transform       */
  203. #define UM_REDRAW     WM_USER+8       /* redraw the entire client window     */
  204. #define UM_JUMBLE     WM_USER+9       /* scatter the pieces on the window    */
  205. #define UM_LOAD       WM_USER+10      /* load a bitmap from disk             */
  206. #define UM_LEFTDOWN   WM_USER+11      /* correlate and prepare to drag       */
  207. #define UM_MOUSEMOVE  WM_USER+12      /* remove, reposition, and redraw      */
  208. #define UM_LEFTUP     WM_USER+13      /* stop dragging                       */
  209. #define UM_CHAR       WM_USER+14      /* a keyboard key                      */
  210. #define UM_LAST       WM_USER+15
  211.  
  212.  
  213. /*------------------------- correlation parameters ---------------------------*/
  214.  
  215. #define HITS   1L             /* maximum number of hits to return    */
  216. #define DEPTH   2L            /* max depth of seg calls to return    */
  217.  
  218. /*-------------------------- old-style bitmap header -------------------------*/
  219.  
  220. typedef struct
  221. {
  222.     USHORT    wType;
  223.     ULONG     dwSize;
  224.     int       xHotspot;
  225.     int       yHotspot;
  226.     ULONG     dwBitsOffset;
  227.     USHORT    bmWidth;
  228.     USHORT    bmHeight;
  229.     USHORT    bmPlanes;
  230.     USHORT    bmBitcount;
  231. } RCBITMAP;
  232. typedef RCBITMAP *PRCBITMAP;
  233.  
  234. /*-------------------------- bitmap-related data -----------------------------*/
  235.  
  236. typedef struct _LOADINFO   /* li */
  237. {
  238.    HFILE   hf;
  239.    CHAR    szFileName[CCHMAXPATH];
  240. } LOADINFO, *PLOADINFO;   /* pli */
  241.  
  242.  
  243.  
  244. /*-------------------------- segment list ------------------------------------*/
  245.  
  246. typedef struct _SEGLIST   /* sl */
  247. {
  248.   LONG         lSegId;                 /* unique id for this pseudo-segment  */
  249.   struct _SEGLIST * pslPrev;           /* previous piece in seglist          */
  250.   struct _SEGLIST * pslNext;           /* next piece in seglist              */
  251.   POINTL       ptlLocation;            /* piece location, world coordinates  */
  252.   RECTL        rclCurrent;             /* segment bounding box, model coords */
  253.   RECTL        rclBitBlt;              /* segment bounding box, world coords */
  254.   POINTL       aptlBitBlt[4];          /* BitBlt parameters                  */
  255.   LONG         lAdjacent[8];           /* adjacent segments in original pict */
  256.   struct _SEGLIST * pslNextIsland;     /* next member in island list         */
  257.   BOOL         fIslandMark;            /* used for marking island members    */
  258.   POINTL       aptlSides[12];          /* control points for piece outline   */
  259.   HDC          hdcHole;                /* hdc used to punch hole in target   */
  260.   HPS          hpsHole;                /* hps used to punch hole in target   */
  261.   HBITMAP      hbmHole;                /* hbm used to punch hole in target   */
  262.   HDC          hdcFill;                /* hdc used to fill hole              */
  263.   HPS          hpsFill;                /* hps used to fill hole              */
  264.   HBITMAP      hbmFill;                /* hbm used to fill hole              */
  265.   POINTL       ptlModelXlate;          /* lM31 and lM31 for piece            */
  266.   BOOL         fVisible;               /* TRUE iff should be drawn           */
  267. } SEGLIST ;
  268. typedef SEGLIST *PSEGLIST;     /* psl  */
  269. typedef PSEGLIST *PPSEGLIST;   /* ppsl */
  270.  
  271.  
  272. /*------------------------- Function Prototypes ------------------------------*/
  273.  
  274. /*
  275.  *   External prototypes
  276.  */
  277.  
  278. #pragma linkage (DosGetThreadInfo, system)
  279. APIRET DosGetThreadInfo(PTIB *pptib,PPIB *pppib);
  280.  
  281. /*
  282.  *   Jigsaw funciton prototypes
  283.  */
  284.  
  285. extern  VOID  CalcBounds( VOID);
  286. extern  VOID  CalcSize( MPARAM mp1, MPARAM mp2);
  287. extern  VOID  CalcTransform( HWND hwnd);
  288. extern  VOID  CheckMenu(ULONG id, BOOL fCheck);
  289. extern  VOID  CheckPsl( PSEGLIST psl);
  290. extern  MRESULT EXPENTRY
  291.               ClientWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM  mp2);
  292. extern  PSEGLIST   Correlate( PPOINTL pptl);
  293. extern  BOOL  CreateBitmapHdcHps( PHDC phdc, PHPS phps);
  294. extern  BOOL  CreatePicture( SHORT sUpdate);
  295. extern  VOID  DispErrorMsg(HAB hab, HWND hwndFrame, PCH FileName, LONG LineNum);
  296. extern  VOID  DisplayZoomFactor(LONG lScaleFactor);
  297. extern  BOOL  DoDraw( HPS hps, HRGN hrgn, BOOL fPaint);
  298. extern  VOID  DoHorzScroll( VOID);
  299. extern  VOID  DoVertScroll( VOID);
  300. extern  VOID  DrawPiece( HPS hps, PSEGLIST psl, BOOL fFill);
  301. extern  BOOL  DumpPicture( VOID);
  302. extern  VOID  EnableMenu(ULONG id, BOOL fEnable);
  303. extern  VOID  Finalize( VOID);
  304. extern  VOID  HelpInit(VOID);
  305. extern  BOOL  Initialize( VOID);
  306. extern  VOID  Jumble( VOID);
  307. extern  VOID  LeftDown( MPARAM mp);
  308. extern  VOID  LeftUp( VOID);
  309. extern  VOID  Load( PLOADINFO pli);
  310. extern  VOID  main( VOID);
  311. extern  VOID  MarkIsland( PSEGLIST pslMark, BOOL fMark);
  312. extern  ULONG MessageBox(HWND hwndOwner, ULONG idMsg, ULONG fsStyle, BOOL fBeep);
  313. extern  VOID  MouseMove( MPARAM mp);
  314. extern  VOID  NewThread( VOID);
  315. extern  BOOL  PrepareBitmap( VOID);
  316. extern  BOOL  ReadBitmap( HFILE hfile);
  317. extern  VOID  Redraw( VOID);
  318. extern  VOID  ReportError( HAB hab);
  319. extern  VOID  ResetScrollBars( VOID);
  320. extern  BOOL  SegListCheck( INT iLoc);
  321. extern  PSEGLIST   SegListGet( LONG lSeg);
  322. extern  PSEGLIST   SegListUpdate( USHORT usOperation, PSEGLIST pslUpdate);
  323. extern  BOOL  SendCommand( ULONG ulCommand, MPARAM mp1, MPARAM mp2);
  324. extern  VOID  SetDVTransform(FIXED fx11, FIXED fx12, FIXED fx21,
  325.                              FIXED fx22, FIXED l31,FIXED l32, FIXED lType);
  326. extern  VOID  SetRect( PSEGLIST psl);
  327. extern  VOID  SizeBitmap(LONG);
  328. extern  VOID  ToBottom( PSEGLIST pslDown);
  329. extern  MRESULT    WndProcCommand(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  330. extern  MRESULT    WndProcCreate( HWND hwnd);
  331. extern  MRESULT    WndProcPaint( VOID);
  332. extern  VOID  Zoom(VOID);
  333.  
  334. /*
  335.  *   IPF handling routines and standard dialog front ends
  336.  */
  337.  
  338. extern  VOID  DestroyHelpInstance(VOID);
  339. extern  VOID  DisplayHelpPanel(SHORT nPanelId);
  340. extern  BOOL  FileOpen( VOID );
  341. extern  VOID  HelpAbout(MPARAM mp2);
  342. extern  VOID  HelpExtended( VOID );
  343. extern  VOID  HelpHelpForHelp(MPARAM mp2);
  344. extern  VOID  HelpIndex(MPARAM mp2);
  345. extern  VOID  HelpTutorial(MPARAM mp2);
  346. extern  VOID  InitHelp(VOID);
  347. extern  MRESULT EXPENTRY
  348.               JigsawOpenFilterProc( HWND   hwnd, ULONG message,
  349.                                        MPARAM mp1,  MPARAM mp2);
  350.  
  351. /*
  352.  *   Macro frontend to error message box.  We only want this particular
  353.  *   message box for debugging.  If DEBUG is not defined (when shipped
  354.  *   Jigsaw application is built), the macro expands to nothing, and
  355.  *   the real function isn't called.
  356.  */
  357.  
  358. #if defined(DEBUG)
  359.    #define DispError(a,b)   DispErrorMsg(a,b,(PCH)__FILE__,(LONG)__LINE__)
  360. #else
  361.    #define DispError(a,b)
  362. #endif
  363.  
  364. /******************************** end JIGSAW.H *******************************/
  365.