auibar.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/aui/toolbar.h
  3. // Purpose: wxaui: wx advanced user interface - docking window manager
  4. // Author: Benjamin I. Williams
  5. // Modified by:
  6. // Created: 2008-08-04
  7. // Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
  8. // Licence: wxWindows Library Licence, Version 3.1
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_AUIBAR_H_
  11. #define _WX_AUIBAR_H_
  12. #include "wx/defs.h"
  13. #if wxUSE_AUI
  14. #include "wx/control.h"
  15. #include "wx/sizer.h"
  16. #include "wx/pen.h"
  17. class WXDLLIMPEXP_FWD_CORE wxClientDC;
  18. class WXDLLIMPEXP_FWD_AUI wxAuiPaneInfo;
  19. enum wxAuiToolBarStyle
  20. {
  21. wxAUI_TB_TEXT = 1 << 0,
  22. wxAUI_TB_NO_TOOLTIPS = 1 << 1,
  23. wxAUI_TB_NO_AUTORESIZE = 1 << 2,
  24. wxAUI_TB_GRIPPER = 1 << 3,
  25. wxAUI_TB_OVERFLOW = 1 << 4,
  26. // using this style forces the toolbar to be vertical and
  27. // be only dockable to the left or right sides of the window
  28. // whereas by default it can be horizontal or vertical and
  29. // be docked anywhere
  30. wxAUI_TB_VERTICAL = 1 << 5,
  31. wxAUI_TB_HORZ_LAYOUT = 1 << 6,
  32. // analogous to wxAUI_TB_VERTICAL, but forces the toolbar
  33. // to be horizontal
  34. wxAUI_TB_HORIZONTAL = 1 << 7,
  35. wxAUI_TB_PLAIN_BACKGROUND = 1 << 8,
  36. wxAUI_TB_HORZ_TEXT = (wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_TEXT),
  37. wxAUI_ORIENTATION_MASK = (wxAUI_TB_VERTICAL | wxAUI_TB_HORIZONTAL),
  38. wxAUI_TB_DEFAULT_STYLE = 0
  39. };
  40. enum wxAuiToolBarArtSetting
  41. {
  42. wxAUI_TBART_SEPARATOR_SIZE = 0,
  43. wxAUI_TBART_GRIPPER_SIZE = 1,
  44. wxAUI_TBART_OVERFLOW_SIZE = 2
  45. };
  46. enum wxAuiToolBarToolTextOrientation
  47. {
  48. wxAUI_TBTOOL_TEXT_LEFT = 0, // unused/unimplemented
  49. wxAUI_TBTOOL_TEXT_RIGHT = 1,
  50. wxAUI_TBTOOL_TEXT_TOP = 2, // unused/unimplemented
  51. wxAUI_TBTOOL_TEXT_BOTTOM = 3
  52. };
  53. // aui toolbar event class
  54. class WXDLLIMPEXP_AUI wxAuiToolBarEvent : public wxNotifyEvent
  55. {
  56. public:
  57. wxAuiToolBarEvent(wxEventType commandType = wxEVT_NULL,
  58. int winId = 0)
  59. : wxNotifyEvent(commandType, winId)
  60. {
  61. m_isDropdownClicked = false;
  62. m_clickPt = wxPoint(-1, -1);
  63. m_rect = wxRect(-1,-1, 0, 0);
  64. m_toolId = -1;
  65. }
  66. #ifndef SWIG
  67. wxAuiToolBarEvent(const wxAuiToolBarEvent& c) : wxNotifyEvent(c)
  68. {
  69. m_isDropdownClicked = c.m_isDropdownClicked;
  70. m_clickPt = c.m_clickPt;
  71. m_rect = c.m_rect;
  72. m_toolId = c.m_toolId;
  73. }
  74. #endif
  75. wxEvent *Clone() const { return new wxAuiToolBarEvent(*this); }
  76. bool IsDropDownClicked() const { return m_isDropdownClicked; }
  77. void SetDropDownClicked(bool c) { m_isDropdownClicked = c; }
  78. wxPoint GetClickPoint() const { return m_clickPt; }
  79. void SetClickPoint(const wxPoint& p) { m_clickPt = p; }
  80. wxRect GetItemRect() const { return m_rect; }
  81. void SetItemRect(const wxRect& r) { m_rect = r; }
  82. int GetToolId() const { return m_toolId; }
  83. void SetToolId(int toolId) { m_toolId = toolId; }
  84. private:
  85. bool m_isDropdownClicked;
  86. wxPoint m_clickPt;
  87. wxRect m_rect;
  88. int m_toolId;
  89. private:
  90. DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiToolBarEvent)
  91. };
  92. class WXDLLIMPEXP_AUI wxAuiToolBarItem
  93. {
  94. friend class wxAuiToolBar;
  95. public:
  96. wxAuiToolBarItem()
  97. {
  98. m_window = NULL;
  99. m_sizerItem = NULL;
  100. m_spacerPixels = 0;
  101. m_toolId = 0;
  102. m_kind = wxITEM_NORMAL;
  103. m_state = 0; // normal, enabled
  104. m_proportion = 0;
  105. m_active = true;
  106. m_dropDown = true;
  107. m_sticky = true;
  108. m_userData = 0;
  109. m_alignment = wxALIGN_CENTER;
  110. }
  111. wxAuiToolBarItem(const wxAuiToolBarItem& c)
  112. {
  113. Assign(c);
  114. }
  115. wxAuiToolBarItem& operator=(const wxAuiToolBarItem& c)
  116. {
  117. Assign(c);
  118. return *this;
  119. }
  120. void Assign(const wxAuiToolBarItem& c)
  121. {
  122. m_window = c.m_window;
  123. m_label = c.m_label;
  124. m_bitmap = c.m_bitmap;
  125. m_disabledBitmap = c.m_disabledBitmap;
  126. m_hoverBitmap = c.m_hoverBitmap;
  127. m_shortHelp = c.m_shortHelp;
  128. m_longHelp = c.m_longHelp;
  129. m_sizerItem = c.m_sizerItem;
  130. m_minSize = c.m_minSize;
  131. m_spacerPixels = c.m_spacerPixels;
  132. m_toolId = c.m_toolId;
  133. m_kind = c.m_kind;
  134. m_state = c.m_state;
  135. m_proportion = c.m_proportion;
  136. m_active = c.m_active;
  137. m_dropDown = c.m_dropDown;
  138. m_sticky = c.m_sticky;
  139. m_userData = c.m_userData;
  140. m_alignment = c.m_alignment;
  141. }
  142. void SetWindow(wxWindow* w) { m_window = w; }
  143. wxWindow* GetWindow() { return m_window; }
  144. void SetId(int newId) { m_toolId = newId; }
  145. int GetId() const { return m_toolId; }
  146. void SetKind(int newKind) { m_kind = newKind; }
  147. int GetKind() const { return m_kind; }
  148. void SetState(int newState) { m_state = newState; }
  149. int GetState() const { return m_state; }
  150. void SetSizerItem(wxSizerItem* s) { m_sizerItem = s; }
  151. wxSizerItem* GetSizerItem() const { return m_sizerItem; }
  152. void SetLabel(const wxString& s) { m_label = s; }
  153. const wxString& GetLabel() const { return m_label; }
  154. void SetBitmap(const wxBitmap& bmp) { m_bitmap = bmp; }
  155. const wxBitmap& GetBitmap() const { return m_bitmap; }
  156. void SetDisabledBitmap(const wxBitmap& bmp) { m_disabledBitmap = bmp; }
  157. const wxBitmap& GetDisabledBitmap() const { return m_disabledBitmap; }
  158. void SetHoverBitmap(const wxBitmap& bmp) { m_hoverBitmap = bmp; }
  159. const wxBitmap& GetHoverBitmap() const { return m_hoverBitmap; }
  160. void SetShortHelp(const wxString& s) { m_shortHelp = s; }
  161. const wxString& GetShortHelp() const { return m_shortHelp; }
  162. void SetLongHelp(const wxString& s) { m_longHelp = s; }
  163. const wxString& GetLongHelp() const { return m_longHelp; }
  164. void SetMinSize(const wxSize& s) { m_minSize = s; }
  165. const wxSize& GetMinSize() const { return m_minSize; }
  166. void SetSpacerPixels(int s) { m_spacerPixels = s; }
  167. int GetSpacerPixels() const { return m_spacerPixels; }
  168. void SetProportion(int p) { m_proportion = p; }
  169. int GetProportion() const { return m_proportion; }
  170. void SetActive(bool b) { m_active = b; }
  171. bool IsActive() const { return m_active; }
  172. void SetHasDropDown(bool b)
  173. {
  174. wxCHECK_RET( !b || m_kind == wxITEM_NORMAL,
  175. wxS("Only normal tools can have drop downs") );
  176. m_dropDown = b;
  177. }
  178. bool HasDropDown() const { return m_dropDown; }
  179. void SetSticky(bool b) { m_sticky = b; }
  180. bool IsSticky() const { return m_sticky; }
  181. void SetUserData(long l) { m_userData = l; }
  182. long GetUserData() const { return m_userData; }
  183. void SetAlignment(int l) { m_alignment = l; }
  184. int GetAlignment() const { return m_alignment; }
  185. private:
  186. wxWindow* m_window; // item's associated window
  187. wxString m_label; // label displayed on the item
  188. wxBitmap m_bitmap; // item's bitmap
  189. wxBitmap m_disabledBitmap; // item's disabled bitmap
  190. wxBitmap m_hoverBitmap; // item's hover bitmap
  191. wxString m_shortHelp; // short help (for tooltip)
  192. wxString m_longHelp; // long help (for status bar)
  193. wxSizerItem* m_sizerItem; // sizer item
  194. wxSize m_minSize; // item's minimum size
  195. int m_spacerPixels; // size of a spacer
  196. int m_toolId; // item's id
  197. int m_kind; // item's kind
  198. int m_state; // state
  199. int m_proportion; // proportion
  200. bool m_active; // true if the item is currently active
  201. bool m_dropDown; // true if the item has a dropdown button
  202. bool m_sticky; // overrides button states if true (always active)
  203. long m_userData; // user-specified data
  204. int m_alignment; // sizer alignment flag, defaults to wxCENTER, may be wxEXPAND or any other
  205. };
  206. #ifndef SWIG
  207. WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiToolBarItem, wxAuiToolBarItemArray, WXDLLIMPEXP_AUI);
  208. #endif
  209. // tab art class
  210. class WXDLLIMPEXP_AUI wxAuiToolBarArt
  211. {
  212. public:
  213. wxAuiToolBarArt() { }
  214. virtual ~wxAuiToolBarArt() { }
  215. virtual wxAuiToolBarArt* Clone() = 0;
  216. virtual void SetFlags(unsigned int flags) = 0;
  217. virtual unsigned int GetFlags() = 0;
  218. virtual void SetFont(const wxFont& font) = 0;
  219. virtual wxFont GetFont() = 0;
  220. virtual void SetTextOrientation(int orientation) = 0;
  221. virtual int GetTextOrientation() = 0;
  222. virtual void DrawBackground(
  223. wxDC& dc,
  224. wxWindow* wnd,
  225. const wxRect& rect) = 0;
  226. virtual void DrawPlainBackground(
  227. wxDC& dc,
  228. wxWindow* wnd,
  229. const wxRect& rect) = 0;
  230. virtual void DrawLabel(
  231. wxDC& dc,
  232. wxWindow* wnd,
  233. const wxAuiToolBarItem& item,
  234. const wxRect& rect) = 0;
  235. virtual void DrawButton(
  236. wxDC& dc,
  237. wxWindow* wnd,
  238. const wxAuiToolBarItem& item,
  239. const wxRect& rect) = 0;
  240. virtual void DrawDropDownButton(
  241. wxDC& dc,
  242. wxWindow* wnd,
  243. const wxAuiToolBarItem& item,
  244. const wxRect& rect) = 0;
  245. virtual void DrawControlLabel(
  246. wxDC& dc,
  247. wxWindow* wnd,
  248. const wxAuiToolBarItem& item,
  249. const wxRect& rect) = 0;
  250. virtual void DrawSeparator(
  251. wxDC& dc,
  252. wxWindow* wnd,
  253. const wxRect& rect) = 0;
  254. virtual void DrawGripper(
  255. wxDC& dc,
  256. wxWindow* wnd,
  257. const wxRect& rect) = 0;
  258. virtual void DrawOverflowButton(
  259. wxDC& dc,
  260. wxWindow* wnd,
  261. const wxRect& rect,
  262. int state) = 0;
  263. virtual wxSize GetLabelSize(
  264. wxDC& dc,
  265. wxWindow* wnd,
  266. const wxAuiToolBarItem& item) = 0;
  267. virtual wxSize GetToolSize(
  268. wxDC& dc,
  269. wxWindow* wnd,
  270. const wxAuiToolBarItem& item) = 0;
  271. virtual int GetElementSize(int elementId) = 0;
  272. virtual void SetElementSize(int elementId, int size) = 0;
  273. virtual int ShowDropDown(
  274. wxWindow* wnd,
  275. const wxAuiToolBarItemArray& items) = 0;
  276. };
  277. class WXDLLIMPEXP_AUI wxAuiDefaultToolBarArt : public wxAuiToolBarArt
  278. {
  279. public:
  280. wxAuiDefaultToolBarArt();
  281. virtual ~wxAuiDefaultToolBarArt();
  282. virtual wxAuiToolBarArt* Clone();
  283. virtual void SetFlags(unsigned int flags);
  284. virtual unsigned int GetFlags();
  285. virtual void SetFont(const wxFont& font);
  286. virtual wxFont GetFont();
  287. virtual void SetTextOrientation(int orientation);
  288. virtual int GetTextOrientation();
  289. virtual void DrawBackground(
  290. wxDC& dc,
  291. wxWindow* wnd,
  292. const wxRect& rect);
  293. virtual void DrawPlainBackground(wxDC& dc,
  294. wxWindow* wnd,
  295. const wxRect& rect);
  296. virtual void DrawLabel(
  297. wxDC& dc,
  298. wxWindow* wnd,
  299. const wxAuiToolBarItem& item,
  300. const wxRect& rect);
  301. virtual void DrawButton(
  302. wxDC& dc,
  303. wxWindow* wnd,
  304. const wxAuiToolBarItem& item,
  305. const wxRect& rect);
  306. virtual void DrawDropDownButton(
  307. wxDC& dc,
  308. wxWindow* wnd,
  309. const wxAuiToolBarItem& item,
  310. const wxRect& rect);
  311. virtual void DrawControlLabel(
  312. wxDC& dc,
  313. wxWindow* wnd,
  314. const wxAuiToolBarItem& item,
  315. const wxRect& rect);
  316. virtual void DrawSeparator(
  317. wxDC& dc,
  318. wxWindow* wnd,
  319. const wxRect& rect);
  320. virtual void DrawGripper(
  321. wxDC& dc,
  322. wxWindow* wnd,
  323. const wxRect& rect);
  324. virtual void DrawOverflowButton(
  325. wxDC& dc,
  326. wxWindow* wnd,
  327. const wxRect& rect,
  328. int state);
  329. virtual wxSize GetLabelSize(
  330. wxDC& dc,
  331. wxWindow* wnd,
  332. const wxAuiToolBarItem& item);
  333. virtual wxSize GetToolSize(
  334. wxDC& dc,
  335. wxWindow* wnd,
  336. const wxAuiToolBarItem& item);
  337. virtual int GetElementSize(int element);
  338. virtual void SetElementSize(int elementId, int size);
  339. virtual int ShowDropDown(wxWindow* wnd,
  340. const wxAuiToolBarItemArray& items);
  341. protected:
  342. wxBitmap m_buttonDropDownBmp;
  343. wxBitmap m_disabledButtonDropDownBmp;
  344. wxBitmap m_overflowBmp;
  345. wxBitmap m_disabledOverflowBmp;
  346. wxColour m_baseColour;
  347. wxColour m_highlightColour;
  348. wxFont m_font;
  349. unsigned int m_flags;
  350. int m_textOrientation;
  351. wxPen m_gripperPen1;
  352. wxPen m_gripperPen2;
  353. wxPen m_gripperPen3;
  354. int m_separatorSize;
  355. int m_gripperSize;
  356. int m_overflowSize;
  357. };
  358. class WXDLLIMPEXP_AUI wxAuiToolBar : public wxControl
  359. {
  360. public:
  361. wxAuiToolBar() { Init(); }
  362. wxAuiToolBar(wxWindow* parent,
  363. wxWindowID id = wxID_ANY,
  364. const wxPoint& pos = wxDefaultPosition,
  365. const wxSize& size = wxDefaultSize,
  366. long style = wxAUI_TB_DEFAULT_STYLE)
  367. {
  368. Init();
  369. Create(parent, id, pos, size, style);
  370. }
  371. virtual ~wxAuiToolBar();
  372. bool Create(wxWindow* parent,
  373. wxWindowID id = wxID_ANY,
  374. const wxPoint& pos = wxDefaultPosition,
  375. const wxSize& size = wxDefaultSize,
  376. long style = wxAUI_TB_DEFAULT_STYLE);
  377. virtual void SetWindowStyleFlag(long style);
  378. void SetArtProvider(wxAuiToolBarArt* art);
  379. wxAuiToolBarArt* GetArtProvider() const;
  380. bool SetFont(const wxFont& font);
  381. wxAuiToolBarItem* AddTool(int toolId,
  382. const wxString& label,
  383. const wxBitmap& bitmap,
  384. const wxString& shortHelpString = wxEmptyString,
  385. wxItemKind kind = wxITEM_NORMAL);
  386. wxAuiToolBarItem* AddTool(int toolId,
  387. const wxString& label,
  388. const wxBitmap& bitmap,
  389. const wxBitmap& disabledBitmap,
  390. wxItemKind kind,
  391. const wxString& shortHelpString,
  392. const wxString& longHelpString,
  393. wxObject* clientData);
  394. wxAuiToolBarItem* AddTool(int toolId,
  395. const wxBitmap& bitmap,
  396. const wxBitmap& disabledBitmap,
  397. bool toggle = false,
  398. wxObject* clientData = NULL,
  399. const wxString& shortHelpString = wxEmptyString,
  400. const wxString& longHelpString = wxEmptyString)
  401. {
  402. return AddTool(toolId,
  403. wxEmptyString,
  404. bitmap,
  405. disabledBitmap,
  406. toggle ? wxITEM_CHECK : wxITEM_NORMAL,
  407. shortHelpString,
  408. longHelpString,
  409. clientData);
  410. }
  411. wxAuiToolBarItem* AddLabel(int toolId,
  412. const wxString& label = wxEmptyString,
  413. const int width = -1);
  414. wxAuiToolBarItem* AddControl(wxControl* control,
  415. const wxString& label = wxEmptyString);
  416. wxAuiToolBarItem* AddSeparator();
  417. wxAuiToolBarItem* AddSpacer(int pixels);
  418. wxAuiToolBarItem* AddStretchSpacer(int proportion = 1);
  419. bool Realize();
  420. wxControl* FindControl(int windowId);
  421. wxAuiToolBarItem* FindToolByPosition(wxCoord x, wxCoord y) const;
  422. wxAuiToolBarItem* FindToolByIndex(int idx) const;
  423. wxAuiToolBarItem* FindTool(int toolId) const;
  424. void ClearTools() { Clear() ; }
  425. void Clear();
  426. bool DeleteTool(int toolId);
  427. bool DeleteByIndex(int toolId);
  428. size_t GetToolCount() const;
  429. int GetToolPos(int toolId) const { return GetToolIndex(toolId); }
  430. int GetToolIndex(int toolId) const;
  431. bool GetToolFits(int toolId) const;
  432. wxRect GetToolRect(int toolId) const;
  433. bool GetToolFitsByIndex(int toolId) const;
  434. bool GetToolBarFits() const;
  435. void SetMargins(const wxSize& size) { SetMargins(size.x, size.x, size.y, size.y); }
  436. void SetMargins(int x, int y) { SetMargins(x, x, y, y); }
  437. void SetMargins(int left, int right, int top, int bottom);
  438. void SetToolBitmapSize(const wxSize& size);
  439. wxSize GetToolBitmapSize() const;
  440. bool GetOverflowVisible() const;
  441. void SetOverflowVisible(bool visible);
  442. bool GetGripperVisible() const;
  443. void SetGripperVisible(bool visible);
  444. void ToggleTool(int toolId, bool state);
  445. bool GetToolToggled(int toolId) const;
  446. void EnableTool(int toolId, bool state);
  447. bool GetToolEnabled(int toolId) const;
  448. void SetToolDropDown(int toolId, bool dropdown);
  449. bool GetToolDropDown(int toolId) const;
  450. void SetToolBorderPadding(int padding);
  451. int GetToolBorderPadding() const;
  452. void SetToolTextOrientation(int orientation);
  453. int GetToolTextOrientation() const;
  454. void SetToolPacking(int packing);
  455. int GetToolPacking() const;
  456. void SetToolProportion(int toolId, int proportion);
  457. int GetToolProportion(int toolId) const;
  458. void SetToolSeparation(int separation);
  459. int GetToolSeparation() const;
  460. void SetToolSticky(int toolId, bool sticky);
  461. bool GetToolSticky(int toolId) const;
  462. wxString GetToolLabel(int toolId) const;
  463. void SetToolLabel(int toolId, const wxString& label);
  464. wxBitmap GetToolBitmap(int toolId) const;
  465. void SetToolBitmap(int toolId, const wxBitmap& bitmap);
  466. wxString GetToolShortHelp(int toolId) const;
  467. void SetToolShortHelp(int toolId, const wxString& helpString);
  468. wxString GetToolLongHelp(int toolId) const;
  469. void SetToolLongHelp(int toolId, const wxString& helpString);
  470. void SetCustomOverflowItems(const wxAuiToolBarItemArray& prepend,
  471. const wxAuiToolBarItemArray& append);
  472. // get size of hint rectangle for a particular dock location
  473. wxSize GetHintSize(int dockDirection) const;
  474. bool IsPaneValid(const wxAuiPaneInfo& pane) const;
  475. // Override to call DoIdleUpdate().
  476. virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
  477. protected:
  478. void Init();
  479. virtual void OnCustomRender(wxDC& WXUNUSED(dc),
  480. const wxAuiToolBarItem& WXUNUSED(item),
  481. const wxRect& WXUNUSED(rect)) { }
  482. protected:
  483. void DoIdleUpdate();
  484. void SetOrientation(int orientation);
  485. void SetHoverItem(wxAuiToolBarItem* item);
  486. void SetPressedItem(wxAuiToolBarItem* item);
  487. void RefreshOverflowState();
  488. int GetOverflowState() const;
  489. wxRect GetOverflowRect() const;
  490. wxSize GetLabelSize(const wxString& label);
  491. wxAuiToolBarItem* FindToolByPositionWithPacking(wxCoord x, wxCoord y) const;
  492. void DoSetSize(int x,
  493. int y,
  494. int width,
  495. int height,
  496. int sizeFlags = wxSIZE_AUTO);
  497. protected: // handlers
  498. void OnSize(wxSizeEvent& evt);
  499. void OnIdle(wxIdleEvent& evt);
  500. void OnPaint(wxPaintEvent& evt);
  501. void OnEraseBackground(wxEraseEvent& evt);
  502. void OnLeftDown(wxMouseEvent& evt);
  503. void OnLeftUp(wxMouseEvent& evt);
  504. void OnRightDown(wxMouseEvent& evt);
  505. void OnRightUp(wxMouseEvent& evt);
  506. void OnMiddleDown(wxMouseEvent& evt);
  507. void OnMiddleUp(wxMouseEvent& evt);
  508. void OnMotion(wxMouseEvent& evt);
  509. void OnLeaveWindow(wxMouseEvent& evt);
  510. void OnCaptureLost(wxMouseCaptureLostEvent& evt);
  511. void OnSetCursor(wxSetCursorEvent& evt);
  512. protected:
  513. wxAuiToolBarItemArray m_items; // array of toolbar items
  514. wxAuiToolBarArt* m_art; // art provider
  515. wxBoxSizer* m_sizer; // main sizer for toolbar
  516. wxAuiToolBarItem* m_actionItem; // item that's being acted upon (pressed)
  517. wxAuiToolBarItem* m_tipItem; // item that has its tooltip shown
  518. wxBitmap m_bitmap; // double-buffer bitmap
  519. wxSizerItem* m_gripperSizerItem;
  520. wxSizerItem* m_overflowSizerItem;
  521. wxSize m_absoluteMinSize;
  522. wxPoint m_actionPos; // position of left-mouse down
  523. wxAuiToolBarItemArray m_customOverflowPrepend;
  524. wxAuiToolBarItemArray m_customOverflowAppend;
  525. int m_buttonWidth;
  526. int m_buttonHeight;
  527. int m_sizerElementCount;
  528. int m_leftPadding;
  529. int m_rightPadding;
  530. int m_topPadding;
  531. int m_bottomPadding;
  532. int m_toolPacking;
  533. int m_toolBorderPadding;
  534. int m_toolTextOrientation;
  535. int m_overflowState;
  536. bool m_dragging;
  537. bool m_gripperVisible;
  538. bool m_overflowVisible;
  539. bool RealizeHelper(wxClientDC& dc, bool horizontal);
  540. static bool IsPaneValid(long style, const wxAuiPaneInfo& pane);
  541. bool IsPaneValid(long style) const;
  542. void SetArtFlags() const;
  543. wxOrientation m_orientation;
  544. wxSize m_horzHintSize;
  545. wxSize m_vertHintSize;
  546. private:
  547. // Common part of OnLeaveWindow() and OnCaptureLost().
  548. void DoResetMouseState();
  549. DECLARE_EVENT_TABLE()
  550. DECLARE_CLASS(wxAuiToolBar)
  551. };
  552. // wx event machinery
  553. #ifndef SWIG
  554. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUITOOLBAR_TOOL_DROPDOWN, wxAuiToolBarEvent );
  555. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUITOOLBAR_OVERFLOW_CLICK, wxAuiToolBarEvent );
  556. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUITOOLBAR_RIGHT_CLICK, wxAuiToolBarEvent );
  557. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUITOOLBAR_MIDDLE_CLICK, wxAuiToolBarEvent );
  558. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUITOOLBAR_BEGIN_DRAG, wxAuiToolBarEvent );
  559. typedef void (wxEvtHandler::*wxAuiToolBarEventFunction)(wxAuiToolBarEvent&);
  560. #define wxAuiToolBarEventHandler(func) \
  561. wxEVENT_HANDLER_CAST(wxAuiToolBarEventFunction, func)
  562. #define EVT_AUITOOLBAR_TOOL_DROPDOWN(winid, fn) \
  563. wx__DECLARE_EVT1(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, winid, wxAuiToolBarEventHandler(fn))
  564. #define EVT_AUITOOLBAR_OVERFLOW_CLICK(winid, fn) \
  565. wx__DECLARE_EVT1(wxEVT_AUITOOLBAR_OVERFLOW_CLICK, winid, wxAuiToolBarEventHandler(fn))
  566. #define EVT_AUITOOLBAR_RIGHT_CLICK(winid, fn) \
  567. wx__DECLARE_EVT1(wxEVT_AUITOOLBAR_RIGHT_CLICK, winid, wxAuiToolBarEventHandler(fn))
  568. #define EVT_AUITOOLBAR_MIDDLE_CLICK(winid, fn) \
  569. wx__DECLARE_EVT1(wxEVT_AUITOOLBAR_MIDDLE_CLICK, winid, wxAuiToolBarEventHandler(fn))
  570. #define EVT_AUITOOLBAR_BEGIN_DRAG(winid, fn) \
  571. wx__DECLARE_EVT1(wxEVT_AUITOOLBAR_BEGIN_DRAG, winid, wxAuiToolBarEventHandler(fn))
  572. #else
  573. // wxpython/swig event work
  574. %constant wxEventType wxEVT_AUITOOLBAR_TOOL_DROPDOWN;
  575. %constant wxEventType wxEVT_AUITOOLBAR_OVERFLOW_CLICK;
  576. %constant wxEventType wxEVT_AUITOOLBAR_RIGHT_CLICK;
  577. %constant wxEventType wxEVT_AUITOOLBAR_MIDDLE_CLICK;
  578. %constant wxEventType wxEVT_AUITOOLBAR_BEGIN_DRAG;
  579. %pythoncode {
  580. EVT_AUITOOLBAR_TOOL_DROPDOWN = wx.PyEventBinder( wxEVT_AUITOOLBAR_TOOL_DROPDOWN, 1 )
  581. EVT_AUITOOLBAR_OVERFLOW_CLICK = wx.PyEventBinder( wxEVT_AUITOOLBAR_OVERFLOW_CLICK, 1 )
  582. EVT_AUITOOLBAR_RIGHT_CLICK = wx.PyEventBinder( wxEVT_AUITOOLBAR_RIGHT_CLICK, 1 )
  583. EVT_AUITOOLBAR_MIDDLE_CLICK = wx.PyEventBinder( wxEVT_AUITOOLBAR_MIDDLE_CLICK, 1 )
  584. EVT_AUITOOLBAR_BEGIN_DRAG = wx.PyEventBinder( wxEVT_AUITOOLBAR_BEGIN_DRAG, 1 )
  585. }
  586. #endif // SWIG
  587. // old wxEVT_COMMAND_* constants
  588. #define wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN wxEVT_AUITOOLBAR_TOOL_DROPDOWN
  589. #define wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK wxEVT_AUITOOLBAR_OVERFLOW_CLICK
  590. #define wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK wxEVT_AUITOOLBAR_RIGHT_CLICK
  591. #define wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK wxEVT_AUITOOLBAR_MIDDLE_CLICK
  592. #define wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG wxEVT_AUITOOLBAR_BEGIN_DRAG
  593. #endif // wxUSE_AUI
  594. #endif // _WX_AUIBAR_H_