]> git.saurik.com Git - wxWidgets.git/blame - include/wx/ribbon/buttonbar.h
make sure we can override GetModality
[wxWidgets.git] / include / wx / ribbon / buttonbar.h
CommitLineData
3c3ead1d
PC
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/ribbon/buttonbar.h
3// Purpose: Ribbon control similar to a tool bar
4// Author: Peter Cawley
5// Modified by:
6// Created: 2009-07-01
7// RCS-ID: $Id$
8// Copyright: (C) Peter Cawley
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11#ifndef _WX_RIBBON_BUTTON_BAR_H_
12#define _WX_RIBBON_BUTTON_BAR_H_
13
14#include "wx/defs.h"
15
16#if wxUSE_RIBBON
17
18#include "wx/ribbon/art.h"
19#include "wx/ribbon/control.h"
20#include "wx/dynarray.h"
21
22class wxRibbonButtonBarButtonBase;
23class wxRibbonButtonBarLayout;
24class wxRibbonButtonBarButtonInstance;
25
26WX_DEFINE_USER_EXPORTED_ARRAY(wxRibbonButtonBarLayout*, wxArrayRibbonButtonBarLayout, class WXDLLIMPEXP_RIBBON);
27WX_DEFINE_USER_EXPORTED_ARRAY(wxRibbonButtonBarButtonBase*, wxArrayRibbonButtonBarButtonBase, class WXDLLIMPEXP_RIBBON);
28
29class WXDLLIMPEXP_RIBBON wxRibbonButtonBar : public wxRibbonControl
30{
31public:
32 wxRibbonButtonBar();
33
34 wxRibbonButtonBar(wxWindow* parent,
35 wxWindowID id = wxID_ANY,
36 const wxPoint& pos = wxDefaultPosition,
37 const wxSize& size = wxDefaultSize,
38 long style = 0);
39
40 virtual ~wxRibbonButtonBar();
41
42 bool Create(wxWindow* parent,
43 wxWindowID id = wxID_ANY,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize,
46 long style = 0);
47
48 virtual wxRibbonButtonBarButtonBase* AddButton(
49 int button_id,
50 const wxString& label,
51 const wxBitmap& bitmap,
52 const wxString& help_string,
53 wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL);
54 // NB: help_string cannot be optional as that would cause the signature
55 // to be identical to the full version of AddButton when 3 arguments are
56 // given.
57
58 virtual wxRibbonButtonBarButtonBase* AddDropdownButton(
59 int button_id,
60 const wxString& label,
61 const wxBitmap& bitmap,
62 const wxString& help_string = wxEmptyString);
63
64 virtual wxRibbonButtonBarButtonBase* AddHybridButton(
65 int button_id,
66 const wxString& label,
67 const wxBitmap& bitmap,
68 const wxString& help_string = wxEmptyString);
69
70 virtual wxRibbonButtonBarButtonBase* AddButton(
71 int button_id,
72 const wxString& label,
73 const wxBitmap& bitmap,
74 const wxBitmap& bitmap_small = wxNullBitmap,
75 const wxBitmap& bitmap_disabled = wxNullBitmap,
76 const wxBitmap& bitmap_small_disabled = wxNullBitmap,
77 wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL,
78 const wxString& help_string = wxEmptyString,
79 wxObject* client_data = NULL);
80
81 virtual bool Realize();
82 virtual void ClearButtons();
83 virtual bool DeleteButton(int button_id);
84 virtual void EnableButton(int button_id, bool enable = true);
85
86 virtual void SetArtProvider(wxRibbonArtProvider* art);
87 virtual bool IsSizingContinuous() const;
88
89 virtual wxSize GetMinSize() const;
3c3ead1d
PC
90protected:
91 friend class wxRibbonButtonBarEvent;
cff9681b 92 virtual wxSize DoGetBestSize() const;
3c3ead1d
PC
93 wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
94
95 void OnEraseBackground(wxEraseEvent& evt);
96 void OnPaint(wxPaintEvent& evt);
97 void OnSize(wxSizeEvent& evt);
98 void OnMouseMove(wxMouseEvent& evt);
99 void OnMouseEnter(wxMouseEvent& evt);
100 void OnMouseLeave(wxMouseEvent& evt);
101 void OnMouseDown(wxMouseEvent& evt);
102 void OnMouseUp(wxMouseEvent& evt);
103
104 virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
105 wxSize relative_to) const;
106 virtual wxSize DoGetNextLargerSize(wxOrientation direction,
107 wxSize relative_to) const;
108
109 void CommonInit(long style);
110 void MakeLayouts();
111 bool TryCollapseLayout(wxRibbonButtonBarLayout* original, size_t first_btn, size_t* last_button);
112 static wxBitmap MakeResizedBitmap(const wxBitmap& original, wxSize size);
113 static wxBitmap MakeDisabledBitmap(const wxBitmap& original);
114 void FetchButtonSizeInfo(wxRibbonButtonBarButtonBase* button,
115 wxRibbonButtonBarButtonState size, wxDC& dc);
116
117 wxArrayRibbonButtonBarLayout m_layouts;
118 wxArrayRibbonButtonBarButtonBase m_buttons;
119 wxRibbonButtonBarButtonInstance* m_hovered_button;
120 wxRibbonButtonBarButtonInstance* m_active_button;
121
122 wxPoint m_layout_offset;
123 wxSize m_bitmap_size_large;
124 wxSize m_bitmap_size_small;
125 int m_current_layout;
126 bool m_layouts_valid;
127 bool m_lock_active_state;
128
129#ifndef SWIG
130 DECLARE_CLASS(wxRibbonButtonBar)
131 DECLARE_EVENT_TABLE()
132#endif
133};
134
135class WXDLLIMPEXP_RIBBON wxRibbonButtonBarEvent : public wxCommandEvent
136{
137public:
138 wxRibbonButtonBarEvent(wxEventType command_type = wxEVT_NULL,
139 int win_id = 0,
140 wxRibbonButtonBar* bar = NULL)
141 : wxCommandEvent(command_type, win_id)
142 , m_bar(bar)
143 {
144 }
145#ifndef SWIG
146 wxRibbonButtonBarEvent(const wxRibbonButtonBarEvent& e) : wxCommandEvent(e)
147 {
148 m_bar = e.m_bar;
149 }
150#endif
151 wxEvent *Clone() const { return new wxRibbonButtonBarEvent(*this); }
152
153 wxRibbonButtonBar* GetBar() {return m_bar;}
154 void SetBar(wxRibbonButtonBar* bar) {m_bar = bar;}
155 bool PopupMenu(wxMenu* menu);
156
157protected:
158 wxRibbonButtonBar* m_bar;
159
160#ifndef SWIG
161private:
162 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonButtonBarEvent)
163#endif
164};
165
166#ifndef SWIG
167
168wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, wxRibbonButtonBarEvent);
169wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED, wxRibbonButtonBarEvent);
170
171typedef void (wxEvtHandler::*wxRibbonButtonBarEventFunction)(wxRibbonButtonBarEvent&);
172
173#define wxRibbonButtonBarEventHandler(func) \
174 wxEVENT_HANDLER_CAST(wxRibbonButtonBarEventFunction, func)
175
176#define EVT_RIBBONBUTTONBAR_CLICKED(winid, fn) \
177 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBUTTON_CLICKED, winid, wxRibbonButtonBarEventHandler(fn))
178#define EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED(winid, fn) \
179 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED, winid, wxRibbonButtonBarEventHandler(fn))
180#else
181
182// wxpython/swig event work
183%constant wxEventType wxEVT_COMMAND_RIBBONBUTTON_CLICKED;
184%constant wxEventType wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED;
185
186%pythoncode {
187 EVT_RIBBONBUTTONBAR_CLICKED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBUTTON_CLICKED, 1 )
188 EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED, 1 )
189}
190#endif
191
192#endif // wxUSE_RIBBON
193
194#endif // _WX_RIBBON_BUTTON_BAR_H_