buttonbar.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/generic/buttonbar.h
  3. // Purpose: wxButtonToolBar declaration
  4. // Author: Julian Smart, after Robert Roebling, Vadim Zeitlin, SciTech
  5. // Modified by:
  6. // Created: 2006-04-13
  7. // Copyright: (c) Julian Smart, Robert Roebling, Vadim Zeitlin,
  8. // SciTech Software, Inc.
  9. // Licence: wxWindows licence
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #ifndef _WX_BUTTONBAR_H_
  12. #define _WX_BUTTONBAR_H_
  13. #include "wx/bmpbuttn.h"
  14. #include "wx/toolbar.h"
  15. class WXDLLIMPEXP_FWD_CORE wxButtonToolBarTool;
  16. // ----------------------------------------------------------------------------
  17. // wxButtonToolBar
  18. // ----------------------------------------------------------------------------
  19. class WXDLLIMPEXP_CORE wxButtonToolBar : public wxToolBarBase
  20. {
  21. public:
  22. // construction/destruction
  23. wxButtonToolBar() { Init(); }
  24. wxButtonToolBar(wxWindow *parent,
  25. wxWindowID id,
  26. const wxPoint& pos = wxDefaultPosition,
  27. const wxSize& size = wxDefaultSize,
  28. long style = 0,
  29. const wxString& name = wxToolBarNameStr)
  30. {
  31. Init();
  32. Create(parent, id, pos, size, style, name);
  33. }
  34. bool Create( wxWindow *parent,
  35. wxWindowID id,
  36. const wxPoint& pos = wxDefaultPosition,
  37. const wxSize& size = wxDefaultSize,
  38. long style = 0,
  39. const wxString& name = wxToolBarNameStr );
  40. virtual ~wxButtonToolBar();
  41. virtual bool Realize();
  42. virtual void SetToolShortHelp(int id, const wxString& helpString);
  43. virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
  44. protected:
  45. // common part of all ctors
  46. void Init();
  47. // implement base class pure virtuals
  48. virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
  49. virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
  50. virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
  51. virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
  52. virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
  53. virtual wxToolBarToolBase *CreateTool(int id,
  54. const wxString& label,
  55. const wxBitmap& bmpNormal,
  56. const wxBitmap& bmpDisabled,
  57. wxItemKind kind,
  58. wxObject *clientData,
  59. const wxString& shortHelp,
  60. const wxString& longHelp);
  61. virtual wxToolBarToolBase *CreateTool(wxControl *control,
  62. const wxString& label);
  63. virtual wxSize DoGetBestClientSize() const;
  64. // calculate layout
  65. void DoLayout();
  66. // get the bounding rect for the given tool
  67. wxRect GetToolRect(wxToolBarToolBase *tool) const;
  68. // get the rect limits depending on the orientation: top/bottom for a
  69. // vertical toolbar, left/right for a horizontal one
  70. void GetRectLimits(const wxRect& rect, wxCoord *start, wxCoord *end) const;
  71. // receives button commands
  72. void OnCommand(wxCommandEvent& event);
  73. // paints a border
  74. void OnPaint(wxPaintEvent& event);
  75. // detects mouse clicks outside buttons
  76. void OnLeftUp(wxMouseEvent& event);
  77. private:
  78. // have we calculated the positions of our tools?
  79. bool m_needsLayout;
  80. // the width of a separator
  81. wxCoord m_widthSeparator;
  82. // the total size of all toolbar elements
  83. wxCoord m_maxWidth,
  84. m_maxHeight;
  85. // the height of a label
  86. int m_labelHeight;
  87. // the space above the label
  88. int m_labelMargin;
  89. private:
  90. DECLARE_DYNAMIC_CLASS(wxButtonToolBar)
  91. DECLARE_EVENT_TABLE()
  92. };
  93. #endif
  94. // _WX_BUTTONBAR_H_