toolbar.h
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 7k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. // common stuff for the toolbar control
  2. #ifndef _TOOLBAR_H
  3. #define _TOOLBAR_H
  4. #define TBHIGHLIGHT_BACK
  5. #define TBHIGHLIGHT_GLYPH
  6. typedef struct {        /* info for recreating the bitmaps */
  7.     int nButtons;
  8.     HINSTANCE hInst;
  9.     UINT_PTR wID;
  10. } TBBMINFO, NEAR *PTBBMINFO;
  11. typedef struct _TBBUTTONDATA {
  12.     union
  13.     {
  14.         // Someone wanted to conserve space.  This is a union to make 
  15.         // the code easier to read.
  16.         int iBitmap;
  17.         int cxySep;         // Used by separators
  18.     }DUMMYUNIONNAME;
  19.     int idCommand;
  20.     BYTE fsState;
  21.     BYTE fsStyle;
  22.     WORD cx;                // BUGBUG raymondc: Can we change this INT?
  23.     DWORD_PTR dwData;
  24.     INT_PTR iString;
  25.     POINT pt;               // top left corner of this button
  26. } TBBUTTONDATA, * LPTBBUTTONDATA;
  27. #define HIML_NORMAL 0
  28. #define HIML_HOT    1   // Image list for the hot-tracked image
  29. #define HIML_DISABLED 2 // Image list for the hot-tracked image
  30. #define HIML_MAX        2
  31. typedef struct {
  32.     HIMAGELIST himl[3];
  33. } TBIMAGELISTS, *LPTBIMAGELISTS;
  34. typedef struct {            /* instance data for toolbar window */
  35.     CONTROLINFO ci;
  36.     DWORD dwStyleEx;
  37.     HDC hdcMono;
  38.     HBITMAP hbmMono;
  39.     LPTBBUTTONDATA Buttons;     // Array of actual buttons
  40.     LPTBBUTTONDATA pCaptureButton;
  41.     POINT   ptCapture;
  42.     HWND hwndToolTips;
  43.     LPTSTR      pszTip;         // store current tooltip string.
  44.     HWND hdlgCust;
  45.     HFONT hfontIcon;
  46.     int nBitmaps;
  47. #ifdef GLYPHCACHE
  48.     int nSelectedBM;            // currently selected pBitmaps index
  49. #endif
  50.     PTBBMINFO pBitmaps;
  51. #ifdef FACECACHE
  52.     HBITMAP hbmCache;
  53. #endif
  54.     PTSTR *pStrings;
  55.     int nStrings;
  56.     int nTextRows;              // # Rows of text per button
  57.     UINT uStructSize;
  58.     int iDxBitmap;
  59.     int iDyBitmap;
  60.     int iButWidth;
  61.     int iButHeight;
  62.     int iButMinWidth;           // The min and max width of the button. If the app does not
  63.     int iButMaxWidth;           // have an opinion on what the min and max should be, these will be 0
  64.     int iYPos;
  65.     int iNumButtons;
  66.     int dyIconFont;
  67.     int dxDDArrowChar;
  68.     int xFirstButton;
  69.     int xPad;
  70.     int yPad;
  71.     int iListGap;               // space between icon and text on list-style buttons
  72.     int iDropDownGap;           // padding after text on list-style drop-down buttons
  73.     SIZE szCached;
  74.     
  75. #ifndef UNICODE
  76.     BYTE bLeadByte;             // Save DBCS Lead Byte
  77. #endif
  78.     HDRAGPROXY hDragProxy;
  79.     
  80.     UINT uDrawText;
  81.     UINT uDrawTextMask;
  82.     COLORSCHEME clrsc;
  83.     TBIMAGELISTS* pimgs;
  84.     int cPimgs;
  85.     
  86.     int iHot;                   // Index of the currently Hot Tracked Button
  87.     int iPressedDD;             // Index of the currently pressed dropdown button
  88.     int iInsert;                // Index of the insertion mark, or -1 if none
  89.     COLORREF    clrim;          // current insert mark color
  90.     RECT rcInvalid;             // Saved invalid rectangle
  91.     BITBOOL fHimlValid : 1;
  92.     BITBOOL fHimlNative : 1;
  93.     BITBOOL fFontCreated: 1;
  94.     BITBOOL fNoStringPool :1;
  95.     BITBOOL fTTNeedsFlush :1;
  96.     BITBOOL fMouseTrack: 1;     // Are we currently tracking Mouse over this toolbar ?
  97.     BITBOOL fActive: 1;
  98.     BITBOOL fAnchorHighlight: 1;// TRUE: anchor the highlight to current position 
  99.                                 //       when mouse goes out of toolbar
  100.     BITBOOL fRightDrag: 1;      // TRUE if current drag is right drag
  101.     BITBOOL fDragOutNotify: 1;  // FALSE from start of drag until mouse leaves button
  102.                                 //       at which point it is TRUE until next drag
  103.     BITBOOL fInsertAfter: 1;    // insert after (TRUE) or before (FALSE) button at iInsert?
  104.     BITBOOL fRedrawOff : 1;     // did we get a WM_SETREDRAW = FALSE
  105.     BITBOOL fInvalidate : 1;    // did we get any paint messages whilst we were fRedrawOff
  106.     BITBOOL fRecalc : 1;        // did we try to call TBRecalc while we were fRedrawOff?
  107.     
  108.     BITBOOL fRequeryCapture :1; // app hack see comment on lbutton up
  109.     BITBOOL fShowPrefix: 1;     // Show the underline of an item. Set with WM_KEYBOARDCUES
  110.     BITBOOL fItemRectsValid:1;  // Are the cached button item rects valid?
  111.     BITBOOL fAntiAlias: 1;    // Turn off AntiAliasing durning the create of a drag image.
  112.     
  113.     RECT rc;                    // cache rc of toolbar. (used only for TBSTYLE_EX_MULTICOL and TBSTYLE_EX_HIDECLIPPEDBUTTONS)
  114.     SIZE sizeBound;             // largest bounding size in vertical multicolumn mode.
  115.     
  116. } TBSTATE, NEAR *PTBSTATE;
  117. typedef struct {
  118. /*REVIEW: index, command, flag words, resource ids should be UINT */
  119.     int iBitmap;    /* index into bitmap of this button's picture */
  120.     int idCommand;  /* WM_COMMAND menu ID that this button sends */
  121.     BYTE fsState;   /* button's state */
  122.     BYTE fsStyle;   /* button's style */
  123.     int idsHelp;    /* string ID for button's status bar help */
  124. } OLDTBBUTTON, FAR* LPOLDTBBUTTON;
  125. typedef struct _TBDRAWITEM
  126. {
  127.     TBSTATE * ptb;
  128.     LPTBBUTTONDATA pbutton;
  129.     UINT state;
  130.     BOOL fHotTrack;
  131.     // himl and image index
  132.     int iIndex;
  133.     int iImage;
  134.     DWORD dwCustom;
  135.     NMTBCUSTOMDRAW tbcd;
  136. } TBDRAWITEM, * PTBDRAWITEM;
  137. #ifdef __cplusplus
  138. extern "C" {
  139. #endif
  140.     
  141. HIMAGELIST TBGetImageList(PTBSTATE ptb, int iMode, int iIndex);
  142. HIMAGELIST TBSetImageList(PTBSTATE ptb, int iMode, int iIndex, HIMAGELIST himl);
  143. #define GET_HIML_INDEX GET_Y_LPARAM
  144. #define GET_IMAGE_INDEX GET_X_LPARAM
  145. HBITMAP FAR PASCAL SelectBM(HDC hDC, PTBSTATE pTBState, int nButton);
  146. void FAR PASCAL DrawButton(HDC hdc, int x, int y, PTBSTATE pTBState, LPTBBUTTONDATA ptButton, BOOL fActive);
  147. void DrawFace(HDC hdc, int x, int y, int offx, int offy, int dxText, 
  148.               int dyText, TBDRAWITEM * ptbdraw);
  149. int  FAR PASCAL TBHitTest(PTBSTATE pTBState, int xPos, int yPos);
  150. int  FAR PASCAL PositionFromID(PTBSTATE pTBState, LONG_PTR id);
  151. void FAR PASCAL BuildButtonTemplates(void);
  152. void FAR PASCAL TBInputStruct(PTBSTATE ptb, LPTBBUTTONDATA pButtonInt, LPTBBUTTON pButtonExt);
  153. void NEAR PASCAL TBOutputStruct(PTBSTATE ptb, LPTBBUTTONDATA pButtonInt, LPTBBUTTON pButtonExt);
  154. BOOL FAR PASCAL SaveRestore(PTBSTATE pTBState, BOOL bWrite, LPTSTR FAR *lpNames);
  155. BOOL FAR PASCAL SaveRestoreFromReg(PTBSTATE ptb, BOOL bWrite, HKEY hkr, LPCTSTR pszSubKey, LPCTSTR pszValueName);
  156. void FAR PASCAL CustomizeTB(PTBSTATE pTBState, int iPos);
  157. void FAR PASCAL MoveButton(PTBSTATE pTBState, int nSource);
  158. BOOL FAR PASCAL DeleteButton(PTBSTATE ptb, UINT uIndex);
  159. BOOL FAR PASCAL TBReallocButtons(PTBSTATE ptb, UINT uButtons);
  160. BOOL FAR PASCAL TBInsertButtons(PTBSTATE ptb, UINT uWhere, UINT uButtons, LPTBBUTTON lpButtons, BOOL fNative);
  161. LRESULT FAR PASCAL SendItemNotify(PTBSTATE ptb, int iItem, int code);
  162. void TBInvalidateItemRects(PTBSTATE ptb);
  163. void PASCAL ReleaseMonoDC(PTBSTATE ptb);
  164. void InitTBDrawItem(TBDRAWITEM * ptbdraw, PTBSTATE ptb, LPTBBUTTONDATA pbutton, 
  165.                     UINT state, BOOL fHotTrack, int dxText, int dyText);
  166. BOOL TBGetInfoTip(PTBSTATE ptb, LPTOOLTIPTEXT lpttt, LPTBBUTTONDATA pTBButton);
  167. extern const int g_dxButtonSep;
  168. BOOL TB_GetItemRect(PTBSTATE ptb, UINT uButton, LPRECT lpRect);
  169. #ifdef __cplusplus
  170. }
  171. #endif
  172. #endif // _TOOLBAR_H