]> git.saurik.com Git - wxWidgets.git/blob - include/wx/ribbon/toolbar.h
Use wxWebKitCtrlNameStr to adhere to the convention used by other wx classes.
[wxWidgets.git] / include / wx / ribbon / toolbar.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/ribbon/toolbar.h
3 // Purpose: Ribbon-style tool bar
4 // Author: Peter Cawley
5 // Modified by:
6 // Created: 2009-07-06
7 // RCS-ID: $Id$
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_RIBBON_TOOLBAR_H_
12 #define _WX_RIBBON_TOOLBAR_H_
13
14 #include "wx/defs.h"
15
16 #if wxUSE_RIBBON
17
18 #include "wx/ribbon/control.h"
19 #include "wx/ribbon/art.h"
20
21 class wxRibbonToolBarToolBase;
22 class wxRibbonToolBarToolGroup;
23 WX_DEFINE_USER_EXPORTED_ARRAY(wxRibbonToolBarToolGroup*, wxArrayRibbonToolBarToolGroup, class WXDLLIMPEXP_RIBBON);
24
25 enum wxRibbonToolBarToolState
26 {
27 wxRIBBON_TOOLBAR_TOOL_FIRST = 1 << 0,
28 wxRIBBON_TOOLBAR_TOOL_LAST = 1 << 1,
29 wxRIBBON_TOOLBAR_TOOL_POSITION_MASK = wxRIBBON_TOOLBAR_TOOL_FIRST | wxRIBBON_TOOLBAR_TOOL_LAST,
30
31 wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED = 1 << 3,
32 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED = 1 << 4,
33 wxRIBBON_TOOLBAR_TOOL_HOVER_MASK = wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED | wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED,
34 wxRIBBON_TOOLBAR_TOOL_NORMAL_ACTIVE = 1 << 5,
35 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE = 1 << 6,
36 wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK = wxRIBBON_TOOLBAR_TOOL_NORMAL_ACTIVE | wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE,
37 wxRIBBON_TOOLBAR_TOOL_DISABLED = 1 << 7,
38 wxRIBBON_TOOLBAR_TOOL_STATE_MASK = 0xF8,
39 };
40
41
42 class WXDLLIMPEXP_RIBBON wxRibbonToolBar : public wxRibbonControl
43 {
44 public:
45 wxRibbonToolBar();
46
47 wxRibbonToolBar(wxWindow* parent,
48 wxWindowID id = wxID_ANY,
49 const wxPoint& pos = wxDefaultPosition,
50 const wxSize& size = wxDefaultSize,
51 long style = 0);
52
53 virtual ~wxRibbonToolBar();
54
55 bool Create(wxWindow* parent,
56 wxWindowID id = wxID_ANY,
57 const wxPoint& pos = wxDefaultPosition,
58 const wxSize& size = wxDefaultSize,
59 long style = 0);
60
61 virtual wxRibbonToolBarToolBase* AddTool(
62 int tool_id,
63 const wxBitmap& bitmap,
64 const wxString& help_string,
65 wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL);
66
67 virtual wxRibbonToolBarToolBase* AddDropdownTool(
68 int tool_id,
69 const wxBitmap& bitmap,
70 const wxString& help_string = wxEmptyString);
71
72 virtual wxRibbonToolBarToolBase* AddHybridTool(
73 int tool_id,
74 const wxBitmap& bitmap,
75 const wxString& help_string = wxEmptyString);
76
77 virtual wxRibbonToolBarToolBase* AddTool(
78 int tool_id,
79 const wxBitmap& bitmap,
80 const wxBitmap& bitmap_disabled = wxNullBitmap,
81 const wxString& help_string = wxEmptyString,
82 wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL,
83 wxObject* client_data = NULL);
84
85 virtual wxRibbonToolBarToolBase* AddSeparator();
86
87 virtual bool Realize();
88 virtual void SetRows(int nMin, int nMax = -1);
89
90 virtual bool IsSizingContinuous() const;
91 virtual wxSize DoGetBestSize() const;
92
93 protected:
94 friend class wxRibbonToolBarEvent;
95 wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
96
97 void OnEraseBackground(wxEraseEvent& evt);
98 void OnMouseDown(wxMouseEvent& evt);
99 void OnMouseEnter(wxMouseEvent& evt);
100 void OnMouseLeave(wxMouseEvent& evt);
101 void OnMouseMove(wxMouseEvent& evt);
102 void OnMouseUp(wxMouseEvent& evt);
103 void OnPaint(wxPaintEvent& evt);
104 void OnSize(wxSizeEvent& evt);
105
106 virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
107 wxSize relative_to) const;
108 virtual wxSize DoGetNextLargerSize(wxOrientation direction,
109 wxSize relative_to) const;
110
111 void CommonInit(long style);
112 void AppendGroup();
113
114 static wxBitmap MakeDisabledBitmap(const wxBitmap& original);
115
116 wxArrayRibbonToolBarToolGroup m_groups;
117 wxRibbonToolBarToolBase* m_hover_tool;
118 wxRibbonToolBarToolBase* m_active_tool;
119 wxSize* m_sizes;
120 int m_nrows_min;
121 int m_nrows_max;
122
123 #ifndef SWIG
124 DECLARE_CLASS(wxRibbonToolBar)
125 DECLARE_EVENT_TABLE()
126 #endif
127 };
128
129
130 class WXDLLIMPEXP_RIBBON wxRibbonToolBarEvent : public wxCommandEvent
131 {
132 public:
133 wxRibbonToolBarEvent(wxEventType command_type = wxEVT_NULL,
134 int win_id = 0,
135 wxRibbonToolBar* bar = NULL)
136 : wxCommandEvent(command_type, win_id)
137 , m_bar(bar)
138 {
139 }
140 #ifndef SWIG
141 wxRibbonToolBarEvent(const wxRibbonToolBarEvent& e) : wxCommandEvent(e)
142 {
143 m_bar = e.m_bar;
144 }
145 #endif
146 wxEvent *Clone() const { return new wxRibbonToolBarEvent(*this); }
147
148 wxRibbonToolBar* GetBar() {return m_bar;}
149 void SetBar(wxRibbonToolBar* bar) {m_bar = bar;}
150 bool PopupMenu(wxMenu* menu);
151
152 protected:
153 wxRibbonToolBar* m_bar;
154
155 #ifndef SWIG
156 private:
157 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonToolBarEvent)
158 #endif
159 };
160
161 #ifndef SWIG
162
163 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONTOOL_CLICKED, wxRibbonToolBarEvent);
164 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED, wxRibbonToolBarEvent);
165
166 typedef void (wxEvtHandler::*wxRibbonToolBarEventFunction)(wxRibbonToolBarEvent&);
167
168 #define wxRibbonToolBarEventHandler(func) \
169 wxEVENT_HANDLER_CAST(wxRibbonToolBarEventFunction, func)
170
171 #define EVT_RIBBONTOOLBAR_CLICKED(winid, fn) \
172 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONTOOL_CLICKED, winid, wxRibbonToolBarEventHandler(fn))
173 #define EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(winid, fn) \
174 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED, winid, wxRibbonToolBarEventHandler(fn))
175 #else
176
177 // wxpython/swig event work
178 %constant wxEventType wxEVT_COMMAND_RIBBONTOOL_CLICKED;
179 %constant wxEventType wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED;
180
181 %pythoncode {
182 EVT_RIBBONTOOLBAR_CLICKED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONTOOL_CLICKED, 1 )
183 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED, 1 )
184 }
185 #endif
186
187 #endif // wxUSE_RIBBON
188
189 #endif // _WX_RIBBON_TOOLBAR_H_