home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / msysjour / vol04 / 01b / macsl / macpmh.h < prev    next >
C/C++ Source or Header  |  1988-10-03  |  10KB  |  278 lines

  1. /*-----------------------------------------------------------------*/
  2. /* MacPM.h                                                         */
  3. /* Header file for all MacPM internal modules.                     */
  4. /* Precompile this into "MacPM.h" before compiling the C files.    */
  5. /*-----------------------------------------------------------------*/
  6.  
  7. #include <MacHeaders>
  8.  
  9. #include <string.h>
  10. #include <stdio.h>
  11.  
  12. #define memzero( pDest )  memset( (pDest), 0, sizeof(*(pDest)) )
  13.  
  14. /* OS/2 stuff */
  15.  
  16. #define MACPM_INTERNAL
  17.  
  18. #include "Os2h.h"
  19.  
  20. #define MPM_DEBUG 1
  21.  
  22. /* Stuff specific to Lightspeed C */
  23.  
  24. #include "MacPrototypes.h"
  25.  
  26. /*-----------------------------------------------------------------*/
  27. /* Stuff for DosXXXXX functions                                    */
  28. /*-----------------------------------------------------------------*/
  29.  
  30. #define MY_PID  9  /* This is a hack - there is only one PID */
  31.  
  32. /*-----------------------------------------------------------------*/
  33. /* temp hacks                                                      */
  34. /*-----------------------------------------------------------------*/
  35.  
  36. char * strncpy( char *, char *, short );
  37.  
  38. /*-----------------------------------------------------------------*/
  39. /* Define our two special Mac events                               */
  40. /*-----------------------------------------------------------------*/
  41.  
  42. #define postedEvt     app1Evt  /* WinPostMsg event */
  43. #define mouseMove     app2Evt  /* (not used at this time) */
  44.  
  45. /*-----------------------------------------------------------------*/
  46. /* Any of these bits force frame window to use documentProc        */
  47. /*-----------------------------------------------------------------*/
  48.  
  49. #define FCF_DOCBITS  \
  50.     ( FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX | FCF_SIZEBORDER |  \
  51.       FCF_HORZSCROLL | FCF_VERTSCROLL )
  52.  
  53. /*-----------------------------------------------------------------*/
  54. /* "nano-PS" data structure.  Not much here, other than a way to   */
  55. /* get to the Mac's GrafPort.                                      */
  56. /*-----------------------------------------------------------------*/
  57.  
  58. #define PSF_INUSE       0x0001
  59.  
  60. typedef struct _PS {
  61.     USHORT        signature;          /* Validation signature */
  62.     USHORT        flags;              /* PSF_ flags */
  63.     HWND          hwnd;               /* Owning window handle */
  64.     GrafPort      port;               /* Mac's port structure */
  65. } PS;
  66.  
  67. typedef PS * PPS;
  68.  
  69. #define PPSOFHPS( hps )  (  *(PPS *)(hps) )
  70. #define PSOFHPS( hps )  (  *PPSOFHPS(hps) )
  71.  
  72. #define HWNDOFHPS( hps )  ( PSOFHPS(hps).hwnd )
  73. #define GRAFOFHPS( hps )  ( PSOFHPS(hps).port )
  74. #define PGRAFOFHPS( hps )  ( &GRAFOFHPS(hps) )
  75.  
  76. /*-----------------------------------------------------------------*/
  77. /* Window class structure                                          */
  78. /*-----------------------------------------------------------------*/
  79.  
  80. #define WC_DESKTOP    ( (PSZ)0xFFFF8088L )
  81.  
  82. typedef struct _MYCLASS {
  83.     USHORT            usHash;         /* Hash of name */
  84.     struct _MYCLASS **hNextClass;     /* handle to next MYCLASS */
  85.     CLASSINFO         class;          /* PM class structure */
  86.     CHAR              szName[1];      /* Name text begins here */
  87. } MYCLASS;
  88.  
  89. typedef MYCLASS  *    PMYCLASS;       /* pcl */
  90. typedef PMYCLASS *    HMYCLASS;       /* hcl */
  91.  
  92. #define CLASSWINDOWBITS  \
  93.     ( CS_CLIPCHILDREN & CS_CLIPSIBLINGS & CS_PARENTCLIP & CS_SAVEBITS )
  94.  
  95. /*-----------------------------------------------------------------*/
  96. /* Window structure                                                */
  97. /* WK_ definitions are order dependent!                            */
  98. /*-----------------------------------------------------------------*/
  99.  
  100. #define WK_OBJECT       1             /* Object window */
  101. #define WK_DESKTOP      2             /* Desktop window */
  102. #define WK_MAIN         3             /* Top level (Mac) window */
  103. #define WK_CHILD        4             /* Child window */
  104.  
  105. typedef struct _MYWND {
  106.     /* MacPM private data */
  107.     USHORT        signature;          /* Validation signature */
  108.     UCHAR         ucKind;             /* WK_ value */
  109.     UCHAR         ucFiller1;          /* (fill to word boundary) */
  110.     /* PM-style data */
  111.     PFNWP         pfnwp;              /* Window function pointer */
  112.     HMYCLASS      hclass;             /* MYCLASS handle */
  113.     ULONG         flStyle;            /* Window style */
  114.     USHORT        id;                 /* Window ID */
  115.     HWND          hwndOwner;          /* Various kin of the window */
  116.     HWND          hwndParent;
  117.     HWND          hwndTopChild;
  118.     HWND          hwndBottomChild;
  119.     HWND          hwndPrevSibling;
  120.     HWND          hwndNextSibling;
  121.     SHORT         x;                  /* coords relative to parent */
  122.     SHORT         y;
  123.     SHORT         cx;
  124.     SHORT         cy;
  125.     ULONG         flFrameFlags;       /* Should be in frame "extra"! */
  126.     /* Mac-style data */
  127.     WindowPeek    pwin;               /* Mac window */
  128.     ControlHandle hctl;               /* Mac control handle */
  129.     Rect          rectAdj;            /* Mac client area adjustment */
  130.     /* Application data */
  131.     BYTE          bExtra[1];          /* window "extra" data */
  132. } MYWND;
  133.  
  134. typedef MYWND *PMYWND;
  135.  
  136. #define PMYWNDOF( hwnd )  ( *(hwnd) )
  137. #define MYWNDOF( hwnd )   ( *PMYWNDOF(hwnd) )
  138.  
  139. #define HMYCLASSOF( hwnd )  ( MYWNDOF(hwnd).hclass )
  140. #define PMYCLASSOF( hwnd )  ( *HMYCLASSOF(hwnd) )
  141. #define MYCLASSOF( hwnd )   ( *PMYCLASSOF(hwnd) )
  142.  
  143. #define WND_SIGNATURE   0x4D47
  144.  
  145. #define ISDESKTOPWINDOW( hwnd )  \
  146.     ( MYWNDOF(hwnd).ucKind == WK_DESKTOP )
  147.  
  148. #define ISOBJECTWINDOW( hwnd )  \
  149.     ( MYWNDOF(hwnd).ucKind == WK_OBJECT )
  150.  
  151. #define ISCHILDWINDOW( hwnd )  \
  152.     ( MYWNDOF(hwnd).ucKind == WK_CHILD )
  153.  
  154. #define ISMAINWINDOW( hwnd )  \
  155.     ( MYWNDOF(hwnd).ucKind == WK_MAIN )
  156.  
  157. #define HWNDOFPWIN( pwin )  ( (HWND)(/*(WindowPeek)*/(pwin))->refCon )
  158. #define PWINOFHWND( hwnd )  ( MYWNDOF(hwnd).pwin )
  159.  
  160. #define MAINHWND( hwnd )  \
  161.     ( PWINOFHWND(hwnd) ? HWNDOFPWIN(PWINOFHWND(hwnd)) : (hwnd) )
  162.  
  163. /*-----------------------------------------------------------------*/
  164. /* Definitions for frame controls                                  */
  165. /*-----------------------------------------------------------------*/
  166.  
  167. #define FID_CTL_MIN   FID_SIZEBORDER      /* 0x8001 */
  168. #define FID_CTL_MAX   FID_CLIENT          /* 0x8008 */
  169.  
  170. #define FID_CTL_COUNT ( FID_CTL_MAX - FID_CTL_MIN + 1 )
  171. #define FID_INDEX( fid ) ( (fid) - FID_CTL_MIN )
  172.  
  173. #define I_SIZEBORDER    ( FID_SIZEBORDER  - FID_CTL_MIN )
  174. #define I_SYSMENU       ( FID_SYSMENU     - FID_CTL_MIN )
  175. #define I_TITLEBAR      ( FID_TITLEBAR    - FID_CTL_MIN )
  176. #define I_MINMAX        ( FID_MINMAX      - FID_CTL_MIN )
  177. #define I_MENU          ( FID_MENU        - FID_CTL_MIN )
  178. #define I_VERTSCROLL    ( FID_VERTSCROLL  - FID_CTL_MIN )
  179. #define I_HORZSCROLL    ( FID_HORZSCROLL  - FID_CTL_MIN )
  180. #define I_CLIENT        ( FID_CLIENT      - FID_CTL_MIN )
  181.  
  182. /*-----------------------------------------------------------------*/
  183. /* Debugging stuff                                                 */
  184. /*-----------------------------------------------------------------*/
  185.  
  186. #ifdef MPM_DEBUG
  187.  
  188. #define ERROR( pszMsg )  MpmErrorBox( pszMsg )
  189.  
  190. #define ASSERT( expr, pszMsg )  if( ! (expr) )  ERROR( pszMsg );
  191.  
  192. #else
  193.  
  194. #define ERROR( pszMsg )
  195.  
  196. #define ASSERT( expr, pszMsg )
  197.  
  198. #endif
  199.  
  200. /*-----------------------------------------------------------------*/
  201. /* Global variables                                                */
  202. /*-----------------------------------------------------------------*/
  203.  
  204. #ifndef _EXTERN
  205. #define _EXTERN extern
  206. #endif
  207.  
  208. _EXTERN CHAR      _szNull[1];
  209.  
  210. _EXTERN LONG      _alSysVal[SV_CSYSVALUES];
  211.  
  212. _EXTERN SHORT     _sSetFocusDepth;
  213.  
  214. _EXTERN HWND      _hwndObject;
  215. _EXTERN HWND      _hwndDesktop;
  216. _EXTERN HWND      _hwndActive;
  217. _EXTERN HWND      _hwndFocus;
  218. _EXTERN HWND      _hwndMenu;
  219.  
  220. _EXTERN PS        _ps1;
  221. _EXTERN PPS       _pps1;
  222. _EXTERN HPS       _hps1;
  223.  
  224. /*-----------------------------------------------------------------*/
  225. /* Function prototypes for internal functions                      */
  226. /*-----------------------------------------------------------------*/
  227.  
  228. #define P pascal
  229.  
  230. #define LOCAL
  231.  
  232. #define WinMapWindowRect( hwndFrom, hwndTo, prcl )  \
  233.     WinMapWindowPoints( (hwndFrom), (hwndTo), (PPOINTL)(prcl), 2 )
  234.  
  235. LOCAL VOID      MpmActivateScrollBars( HWND hwnd, BOOL fActive );
  236. LOCAL VOID      MpmDrawGrowIcon( HWND hwnd );
  237. LOCAL VOID      MpmErrorBox( PSZ pszMsg );
  238. LOCAL BOOL      MpmIsFrameClass( PSZ pszClassName );
  239. LOCAL VOID      MpmMapAbsOfWin( HWND hwnd, PPOINTL pptl,
  240.                                   SHORT sCount );
  241. LOCAL VOID      MpmMapMacOfPtl( HWND hwnd, Point* ppoint,
  242.                                   PPOINTL pptl );
  243. LOCAL VOID      MpmMapMacOfRcl( HWND hwnd, Rect* prect,
  244.                                   PRECTL prcl );
  245. LOCAL VOID      MpmMapPtlOfMac( HWND hwnd, PPOINTL pptl,
  246.                                   Point* ppoint );
  247. LOCAL VOID      MpmMapRclOfMac( HWND hwnd, PRECTL prcl,
  248.                                   Rect* prectl );
  249. LOCAL VOID      MpmMapWinOfAbs( HWND hwnd, PPOINTL pptl,
  250.                                   SHORT sCount );
  251. LOCAL BOOL      MpmMenuLoad( HWND hwndFrame, USHORT idResources );
  252. LOCAL PVOID     MpmNewHandleZ( USHORT usLen );
  253. LOCAL PVOID     MpmNewPtrZ( USHORT usLen );
  254. LOCAL VOID      MpmQueryMacRect( HWND hwnd, Rect* prect );
  255. LOCAL BOOL      MpmValidateWindow( HWND hwnd );
  256. LOCAL BOOL      MpmValidatePS( HPS hps );
  257. LOCAL BOOL      MpmValidateWindowNull( HWND hwnd );
  258.  
  259. #define DCLFNWP( fnwp )  \
  260.     MRESULT EXPENTRY fnwp( HWND, USHORT, MPARAM, MPARAM );
  261.  
  262. DCLFNWP( MpmFnwpButton );
  263. DCLFNWP( MpmFnwpDesktop );
  264. DCLFNWP( MpmFnwpDialog );
  265. DCLFNWP( MpmFnwpEntryField );
  266. DCLFNWP( MpmFnwpFrame );
  267. DCLFNWP( MpmFnwpListBox );
  268. DCLFNWP( MpmFnwpMenu );
  269. DCLFNWP( MpmFnwpObject );
  270. DCLFNWP( MpmFnwpScrollBar );
  271. DCLFNWP( MpmFnwpSizeBorder );
  272. DCLFNWP( MpmFnwpStatic );
  273. DCLFNWP( MpmFnwpTitleBar );
  274.  
  275. #undef P
  276.  
  277. /*-----------------------------------------------------------------*/
  278.