Steps towards implementing native-style, non-top-level toolbars on Mac
[wxWidgets.git] / include / wx / generic / buttonbar.h
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 // Id: $Id$
8 // Copyright: (c) Julian Smart, Robert Roebling, Vadim Zeitlin,
9 // SciTech Software, Inc.
10 // Licence: wxWindows licence
11 ///////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WX_BUTTONBAR_H_
14 #define _WX_BUTTONBAR_H_
15
16 #include "wx/bmpbuttn.h"
17
18 class WXDLLEXPORT wxButtonToolBarTool;
19
20 // ----------------------------------------------------------------------------
21 // wxButtonToolBar
22 // ----------------------------------------------------------------------------
23
24 class WXDLLEXPORT wxButtonToolBar : public wxToolBarBase
25 {
26 public:
27 // construction/destruction
28 wxButtonToolBar() { Init(); }
29 wxButtonToolBar(wxWindow *parent,
30 wxWindowID id,
31 const wxPoint& pos = wxDefaultPosition,
32 const wxSize& size = wxDefaultSize,
33 long style = 0,
34 const wxString& name = wxToolBarNameStr)
35 {
36 Init();
37
38 Create(parent, id, pos, size, style, name);
39 }
40
41 bool Create( wxWindow *parent,
42 wxWindowID id,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = 0,
46 const wxString& name = wxToolBarNameStr );
47
48 virtual ~wxButtonToolBar();
49
50 virtual bool Realize();
51
52 virtual void SetToolShortHelp(int id, const wxString& helpString);
53 virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
54
55 protected:
56 // common part of all ctors
57 void Init();
58
59 // implement base class pure virtuals
60 virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
61 virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
62
63 virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
64 virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
65 virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
66
67 virtual wxToolBarToolBase *CreateTool(int id,
68 const wxString& label,
69 const wxBitmap& bmpNormal,
70 const wxBitmap& bmpDisabled,
71 wxItemKind kind,
72 wxObject *clientData,
73 const wxString& shortHelp,
74 const wxString& longHelp);
75 virtual wxToolBarToolBase *CreateTool(wxControl *control);
76
77 virtual wxSize DoGetBestClientSize() const;
78
79 // calculate layout
80 void DoLayout();
81
82 // get the bounding rect for the given tool
83 wxRect GetToolRect(wxToolBarToolBase *tool) const;
84
85 // get the rect limits depending on the orientation: top/bottom for a
86 // vertical toolbar, left/right for a horizontal one
87 void GetRectLimits(const wxRect& rect, wxCoord *start, wxCoord *end) const;
88
89 // receives button commands
90 void OnCommand(wxCommandEvent& event);
91
92 private:
93 // have we calculated the positions of our tools?
94 bool m_needsLayout;
95
96 // the width of a separator
97 wxCoord m_widthSeparator;
98
99 // the total size of all toolbar elements
100 wxCoord m_maxWidth,
101 m_maxHeight;
102
103 private:
104 DECLARE_DYNAMIC_CLASS(wxButtonToolBar)
105 DECLARE_EVENT_TABLE()
106 };
107
108 #endif
109 // _WX_BUTTONBAR_H_
110