home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmstabar.zip / ctrlutil.h < prev    next >
C/C++ Source or Header  |  2002-01-17  |  4KB  |  96 lines

  1. //========================================================================
  2. // ctrlutil.h : structures and definitions used by the ctrlutil.c
  3. //              This code is designed to be shared by the various controls.
  4. //========================================================================
  5.  
  6.  
  7. #ifndef _CTRUTIL_H_
  8.    #define _CTRUTIL_H_
  9.  
  10.  
  11. // Valid WM_SETWINDOWPARAMS flags:
  12. #define WPM_SETFLAGS   (WPM_TEXT | WPM_CTLDATA)
  13.  
  14. // Valid WM_QUERYWINDOWPARAMS flags
  15. #define WPM_QUERYFLAGS (WPM_TEXT | WPM_CTLDATA | WPM_CCHTEXT | WPM_CBCTLDATA)
  16.  
  17. // All controls should typically reserve 8 bytes in the window words.
  18. // The first 4 bytes are reserved for user data (QWL_USER).
  19. // The remaining 4 bytes are reserved for the address of the memory
  20. // used by the control in its procedure.
  21. // Note: this have been redifined just in case we want to port this to
  22. // 64 bit.
  23. #define CB_CTRLWORDS           ((sizeof(PVOID)) << 1)
  24. // Offset to the bytes reserved for the data used by the control
  25. #define QWL_CONTROL            (sizeof(PVOID))
  26.  
  27. // common data structures
  28.  
  29. /*
  30.  Control text data structure
  31.  This is limited to usage in static controls, buttons, etc...
  32.  Multiple line edit boxes, lists, etc., should use other structures.
  33.  The following coordinates are measured and stored (some are used only
  34.  by controls which undeline the mnemonic character) :
  35.    ┌───────────────────────┐ -
  36.    │ text to be _m_easured │   cy    -
  37.    └───────────────────────┘ -       - ydesc
  38.    |<- xmnemo ->| |
  39.               cxmnemo
  40.    |<----- acx[idx] ------>|
  41.  
  42. */
  43.  
  44. // single line control text (max 512 characters)
  45.  
  46. #pragma pack(2)
  47. typedef struct {
  48.    USHORT len;        // control text length
  49.    USHORT usflag;     // flag used by CtrlTextDraw
  50.    USHORT cx;         // text box width
  51.    USHORT cy;         // text box height
  52.    SHORT y;           // font descender
  53.    SHORT mnemo;       // offset to the optional mnemonic character
  54.    USHORT xmnemo;     // distance of mnemonic character from the first one
  55.    USHORT cxmnemo;    // width of the mnemonic character
  56.    CHAR ach[1];       // control text data
  57. } CTRLTXT, * PCTRLTXT;
  58. #pragma pack()
  59.  
  60. // error code used by CtrlTextGet which is called on WM_QUERYWINDOWPARAMS
  61. #define WPM_TEXTERROR 0xffffffff
  62.  
  63. // structure to cache the control size
  64. #pragma pack(2)
  65. typedef struct {
  66.    SHORT cx, cy;
  67. } SIZES, * PSIZES;
  68. #pragma pack()
  69.  
  70. // New DT_* (Draw Text) flags used by CtrlTextDraw():
  71. // See the function comments for more details
  72. #define DT_3DTEXTTOP        0x0004
  73. #define DT_3DTEXTBOTTOM     0x0008
  74.  
  75.  
  76. // The window hwnd gets updated only if part of it is visible on the screen
  77. // If bchildren is TRUE, its children are updated as well
  78. #define CtrlUpdate(hwnd, bchildren) \
  79.    (WinIsWindowShowing(hwnd)? WinInvalidateRect(hwnd, NULL, (bchildren)) : 0)
  80.  
  81.  
  82. // function prototypes:
  83. BOOL CtrlTextSize(HWND hwnd, PCTRLTXT pct);
  84. PCTRLTXT CtrlTextSet(PCTRLTXT pct, PSZ pszText, LONG len, BOOL bmnemo);
  85. ULONG CtrlTextGet(PCTRLTXT pct, PSZ pszBuf, ULONG len, BOOL bmnemo);
  86. ULONG CtrlTextDraw(HPS hps, PCTRLTXT pct, PRECTL pr,
  87.                    LONG clrFgnd, LONG clrBkgnd, LONG clrBktxt);
  88. VOID underlineMnemo(HPS hps, PCTRLTXT pct, PRECTL pr, PPOINTL ppt);
  89. LONG CtrlClrGet(HWND hwnd, ULONG ulid1, ULONG ulid2, LONG ldef, BOOL bi);
  90. BOOL WinIsPointerInWindow(HWND hwnd, PSIZES pszs);
  91. BOOL WinIsMouseMsgInWindow(MPARAM mp, PSIZES pszs);
  92. BOOL WinHalftoneRect(HPS hps, PRECTL pr, LONG clr);
  93. VOID Win3DBorderDraw(HPS hps, PRECTL pr, LONG clrul, LONG clrbr, ULONG cpbrd);
  94.  
  95. #endif // ifndef _CTRUTIL_H_
  96.