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.

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