Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

225 lines
7.5 KiB

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