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