Leaked source code of windows server 2003
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.

221 lines
7.6 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. HDRAGPROXY hDragProxy;
  80. UINT uDrawText;
  81. UINT uDrawTextMask;
  82. COLORSCHEME clrsc;
  83. TBIMAGELISTS* pimgs;
  84. int cPimgs;
  85. int iHot; // Index of the currently Hot Tracked Button
  86. int iPressedDD; // Index of the currently pressed dropdown button
  87. int iInsert; // Index of the insertion mark, or -1 if none
  88. COLORREF clrim; // current insert mark color
  89. RECT rcInvalid; // Saved invalid rectangle
  90. BITBOOL fHimlValid : 1;
  91. BITBOOL fHimlNative : 1;
  92. BITBOOL fFontCreated: 1;
  93. BITBOOL fNoStringPool :1;
  94. BITBOOL fTTNeedsFlush :1;
  95. BITBOOL fMouseTrack: 1; // Are we currently tracking Mouse over this toolbar ?
  96. BITBOOL fActive: 1;
  97. BITBOOL fAnchorHighlight: 1;// TRUE: anchor the highlight to current position
  98. // when mouse goes out of toolbar
  99. BITBOOL fRightDrag: 1; // TRUE if current drag is right drag
  100. BITBOOL fDragOutNotify: 1; // FALSE from start of drag until mouse leaves button
  101. // at which point it is TRUE until next drag
  102. BITBOOL fInsertAfter: 1; // insert after (TRUE) or before (FALSE) button at iInsert?
  103. BITBOOL fRedrawOff : 1; // did we get a WM_SETREDRAW = FALSE
  104. BITBOOL fInvalidate : 1; // did we get any paint messages whilst we were fRedrawOff
  105. BITBOOL fRecalc : 1; // did we try to call TBRecalc while we were fRedrawOff?
  106. BITBOOL fRequeryCapture :1; // app hack see comment on lbutton up
  107. BITBOOL fShowPrefix: 1; // Show the underline of an item. Set with WM_KEYBOARDCUES
  108. BITBOOL fItemRectsValid:1; // Are the cached button item rects valid?
  109. BITBOOL fAntiAlias: 1; // Turn off AntiAliasing durning the create of a drag image.
  110. BITBOOL fForcedDoubleBuffer: 1; // Even though not explicitly set by external, we want to enable it.
  111. // Double buffer has some bagage: It also means "FlickerFree/Efficient drawing"
  112. RECT rc; // cache rc of toolbar. (used only for TBSTYLE_EX_MULTICOL and TBSTYLE_EX_HIDECLIPPEDBUTTONS)
  113. SIZE sizeBound; // largest bounding size in vertical multicolumn mode.
  114. HTHEME hTheme;
  115. int iTracking; // Used for tooltips via keyboard (current item in focus for info display, >= 0 is tracking active)
  116. LPARAM lLastMMove; // Filter out mouse move messages that didn't result in an actual move (for track tooltip canceling)
  117. int cxBarPad;
  118. int cyBarPad;
  119. int cxButtonSpacing;
  120. int cyButtonSpacing;
  121. } TBSTATE, *PTBSTATE;
  122. typedef struct {
  123. /*REVIEW: index, command, flag words, resource ids should be UINT */
  124. int iBitmap; /* index into bitmap of this button's picture */
  125. int idCommand; /* WM_COMMAND menu ID that this button sends */
  126. BYTE fsState; /* button's state */
  127. BYTE fsStyle; /* button's style */
  128. int idsHelp; /* string ID for button's status bar help */
  129. } OLDTBBUTTON,* LPOLDTBBUTTON;
  130. typedef struct _TBDRAWITEM
  131. {
  132. TBSTATE * ptb;
  133. LPTBBUTTONDATA pbutton;
  134. UINT state;
  135. BOOL fHotTrack;
  136. // himl and image index
  137. int iIndex;
  138. int iImage;
  139. DWORD dwCustom;
  140. NMTBCUSTOMDRAW tbcd;
  141. } TBDRAWITEM, * PTBDRAWITEM;
  142. // toolbar keyboard tooltip tracking
  143. #define TBKTT_NOTRACK -1
  144. #define TB_IsKbdTipTracking(ptb) (ptb->iTracking != TBKTT_NOTRACK)
  145. #define IDT_TRACKINGTIP 0
  146. #ifdef __cplusplus
  147. extern "C" {
  148. #endif
  149. HIMAGELIST TBGetImageList(PTBSTATE ptb, int iMode, int iIndex);
  150. HIMAGELIST TBSetImageList(PTBSTATE ptb, int iMode, int iIndex, HIMAGELIST himl);
  151. #define GET_HIML_INDEX GET_Y_LPARAM
  152. #define GET_IMAGE_INDEX GET_X_LPARAM
  153. HBITMAP SelectBM(HDC hDC, PTBSTATE pTBState, int nButton);
  154. void DrawButton(HDC hdc, int x, int y, PTBSTATE pTBState, LPTBBUTTONDATA ptButton, BOOL fActive);
  155. void DrawFace(HDC hdc, PRECT prc, int x, int y, int offx, int offy, int dxText,
  156. int dyText, TBDRAWITEM * ptbdraw, int iListGap, PRECT prcText);
  157. int TBHitTest(PTBSTATE pTBState, int xPos, int yPos);
  158. int PositionFromID(PTBSTATE pTBState, LONG_PTR id);
  159. void BuildButtonTemplates(void);
  160. void TBInputStruct(PTBSTATE ptb, LPTBBUTTONDATA pButtonInt, LPTBBUTTON pButtonExt);
  161. void TBOutputStruct(PTBSTATE ptb, LPTBBUTTONDATA pButtonInt, LPTBBUTTON pButtonExt);
  162. BOOL SaveRestoreFromReg(PTBSTATE ptb, BOOL bWrite, HKEY hkr, LPCTSTR pszSubKey, LPCTSTR pszValueName);
  163. void CustomizeTB(PTBSTATE pTBState, int iPos);
  164. void MoveButton(PTBSTATE pTBState, int nSource);
  165. BOOL DeleteButton(PTBSTATE ptb, UINT uIndex);
  166. BOOL TBReallocButtons(PTBSTATE ptb, UINT uButtons);
  167. BOOL TBInsertButtons(PTBSTATE ptb, UINT uWhere, UINT uButtons, LPTBBUTTON lpButtons, BOOL fNative);
  168. LRESULT SendItemNotify(PTBSTATE ptb, int iItem, int code);
  169. void TBInvalidateItemRects(PTBSTATE ptb);
  170. void ReleaseMonoDC(PTBSTATE ptb);
  171. void InitTBDrawItem(TBDRAWITEM * ptbdraw, PTBSTATE ptb, LPTBBUTTONDATA pbutton,
  172. UINT state, BOOL fHotTrack, int dxText, int dyText);
  173. BOOL TBGetInfoTip(PTBSTATE ptb, LPTOOLTIPTEXT lpttt, LPTBBUTTONDATA pTBButton);
  174. extern const int g_dxButtonSep;
  175. BOOL TB_GetItemRect(PTBSTATE ptb, UINT uButton, LPRECT lpRect);
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179. #endif // _TOOLBAR_H