toolbarItem.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef NULLSOFT_WINAMP_OMBROWSER_TOOLBARITEM_HEADER
  2. #define NULLSOFT_WINAMP_OMBROWSER_TOOLBARITEM_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. #define ICON_NONE (-1)
  8. class __declspec(novtable) ToolbarItem
  9. {
  10. public:
  11. typedef enum
  12. {
  13. stateHidden = 0x0001,
  14. stateDisabled = 0x0002,
  15. statePressed = 0x0004,
  16. stateHighlighted = 0x0008,
  17. stateFocused = 0x0010,
  18. stateNoFocusRect = 0x0020,
  19. styleChevronOnly = 0x0100,
  20. styleNoChevron = 0x0200,
  21. stylePopup = 0x0400,
  22. styleFlexible = 0x1000, // item can change it width
  23. styleStatic = 0x2000, // item not reacting on mouse or keyboard events
  24. styleWantKey = 0x4000,
  25. styleTabstop = 0x8000, // item wants to have it's own tabstop (not TBS_TABSTOP)
  26. } Styles;
  27. typedef struct __Template
  28. {
  29. LPCSTR name;
  30. LPCWSTR text;
  31. LPCWSTR description;
  32. INT iconId;
  33. INT commandId;
  34. UINT style;
  35. } Template;
  36. protected:
  37. ToolbarItem(LPCSTR pszName, UINT nStyle, INT nIcon, LPCWSTR pszText, LPCWSTR pszDescription);
  38. virtual ~ToolbarItem();
  39. public:
  40. ULONG AddRef();
  41. ULONG Release();
  42. LPCSTR GetName();
  43. virtual UINT GetStyle();
  44. virtual void SetStyle(HWND hToolbar, UINT newStyle, UINT styleMask); // if NULL != hToolbar - item will be invalidated
  45. virtual BOOL SetRect(const RECT *prc);
  46. BOOL GetRect(RECT *prc);
  47. BOOL OffsetRect(INT dx, INT dy);
  48. virtual BOOL SetRectEmpty();
  49. BOOL IsRectEmpty();
  50. BOOL PtInRect(POINT pt);
  51. BOOL IntersectRect(RECT *prcDst, const RECT *prcSrc);
  52. BOOL IsEqual(LPCSTR pszName, INT cchName);
  53. virtual HRESULT GetText(LPWSTR pszBuffer, UINT cchBufferMax);
  54. virtual HRESULT GetTextLength(size_t *pcchLength) { return E_NOTIMPL; }
  55. virtual HRESULT GetDescription(LPWSTR pszBuffer, UINT cchBufferMax);
  56. virtual BOOL SetDescription(HWND hToolbar, LPCWSTR pszDescription);
  57. virtual BOOL AdjustRect(HWND hToolbar, RECT *proposedRect) { return FALSE; }
  58. virtual BOOL Paint(HWND hToolbar, HDC hdc, const RECT *paintRect, UINT state) { return FALSE;}
  59. virtual INT GetTip(LPTSTR pszBuffer, INT cchBufferMax) { return 0; }
  60. virtual void MouseMove(HWND hToolbar, UINT mouseFlags, POINT pt) {}
  61. virtual void MouseLeave(HWND hToolbar) {}
  62. virtual void LButtonDown(HWND hToolbar, UINT mouseFlags, POINT pt) {}
  63. virtual void LButtonUp(HWND hToolbar, UINT mouseFlags, POINT pt) {}
  64. virtual void Click(HWND hToolbar, UINT mouseFlags, POINT pt) {}
  65. virtual BOOL SetValueInt(HWND hToolbar, INT value) { return FALSE; }
  66. virtual BOOL SetValueStr(HWND hToolbar, LPCWSTR value) { return FALSE; }
  67. virtual INT GetCommandId() { return 0; }
  68. virtual void UpdateSkin(HWND hToolbar) {}
  69. virtual BOOL PtInItem(POINT pt);
  70. virtual BOOL FillMenuInfo(HWND hToolbar, MENUITEMINFO *pmii, LPWSTR pszBuffer, INT cchBufferMax) { return FALSE; }
  71. virtual BOOL KeyDown(HWND hToolbar, INT vKey, UINT flags) { return FALSE; }
  72. virtual BOOL KeyUp(HWND hToolbar, INT vKey, UINT flags) { return FALSE; }
  73. virtual void SetFocus(HWND hToolbar, ToolbarItem *focusItem, BOOL fSet) {}
  74. virtual BOOL SetCursor(HWND hToolbar, HWND hCursor, UINT hitTest, UINT messageId) { return FALSE; }
  75. virtual void CommandSent(HWND hToolbar, INT commandId) {}
  76. virtual BOOL DisplayContextMenu(HWND hToolbar, INT x, INT y) { return FALSE; }
  77. protected:
  78. ULONG ref;
  79. LPSTR name;
  80. UINT style;
  81. RECT rect;
  82. INT iconId;
  83. LPWSTR text;
  84. LPWSTR description;
  85. };
  86. #endif // NULLSOFT_WINAMP_OMBROWSER_TOOLBARITEM_HEADER