]> git.saurik.com Git - wxWidgets.git/blob - include/wx/ribbon/bar.h
fixing warning and compile error against 10.4
[wxWidgets.git] / include / wx / ribbon / bar.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/ribbon/bar.h
3 // Purpose: Top-level component of the ribbon-bar-style interface
4 // Author: Peter Cawley
5 // Modified by:
6 // Created: 2009-05-23
7 // RCS-ID: $Id$
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_RIBBON_BAR_H_
13 #define _WX_RIBBON_BAR_H_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_RIBBON
18
19 #include "wx/ribbon/control.h"
20 #include "wx/ribbon/page.h"
21
22 enum wxRibbonBarOption
23 {
24 wxRIBBON_BAR_SHOW_PAGE_LABELS = 1 << 0,
25 wxRIBBON_BAR_SHOW_PAGE_ICONS = 1 << 1,
26 wxRIBBON_BAR_FLOW_HORIZONTAL = 0,
27 wxRIBBON_BAR_FLOW_VERTICAL = 1 << 2,
28 wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS = 1 << 3,
29 wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS = 1 << 4,
30 wxRIBBON_BAR_ALWAYS_SHOW_TABS = 1 << 5,
31
32 wxRIBBON_BAR_DEFAULT_STYLE = wxRIBBON_BAR_FLOW_HORIZONTAL
33 | wxRIBBON_BAR_SHOW_PAGE_LABELS
34 | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS,
35
36 wxRIBBON_BAR_FOLDBAR_STYLE = wxRIBBON_BAR_FLOW_VERTICAL
37 | wxRIBBON_BAR_SHOW_PAGE_ICONS
38 | wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
39 | wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS,
40 };
41
42 class WXDLLIMPEXP_RIBBON wxRibbonBarEvent : public wxNotifyEvent
43 {
44 public:
45 wxRibbonBarEvent(wxEventType command_type = wxEVT_NULL,
46 int win_id = 0,
47 wxRibbonPage* page = NULL)
48 : wxNotifyEvent(command_type, win_id)
49 , m_page(page)
50 {
51 }
52 #ifndef SWIG
53 wxRibbonBarEvent(const wxRibbonBarEvent& c) : wxNotifyEvent(c)
54 {
55 m_page = c.m_page;
56 }
57 #endif
58 wxEvent *Clone() const { return new wxRibbonBarEvent(*this); }
59
60 wxRibbonPage* GetPage() {return m_page;}
61 void SetPage(wxRibbonPage* page) {m_page = page;}
62
63 protected:
64 wxRibbonPage* m_page;
65
66 #ifndef SWIG
67 private:
68 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonBarEvent)
69 #endif
70 };
71
72 class WXDLLIMPEXP_RIBBON wxRibbonPageTabInfo
73 {
74 public:
75 wxRect rect;
76 wxRibbonPage *page;
77 int ideal_width;
78 int small_begin_need_separator_width;
79 int small_must_have_separator_width;
80 int minimum_width;
81 bool active;
82 bool hovered;
83 };
84
85 #ifndef SWIG
86 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRibbonPageTabInfo, wxRibbonPageTabInfoArray, WXDLLIMPEXP_RIBBON);
87 #endif
88
89 class WXDLLIMPEXP_RIBBON wxRibbonBar : public wxRibbonControl
90 {
91 public:
92 wxRibbonBar();
93
94 wxRibbonBar(wxWindow* parent,
95 wxWindowID id = wxID_ANY,
96 const wxPoint& pos = wxDefaultPosition,
97 const wxSize& size = wxDefaultSize,
98 long style = wxRIBBON_BAR_DEFAULT_STYLE);
99
100 virtual ~wxRibbonBar();
101
102 bool Create(wxWindow* parent,
103 wxWindowID id = wxID_ANY,
104 const wxPoint& pos = wxDefaultPosition,
105 const wxSize& size = wxDefaultSize,
106 long style = wxRIBBON_BAR_DEFAULT_STYLE);
107
108 void SetTabCtrlMargins(int left, int right);
109
110 void SetArtProvider(wxRibbonArtProvider* art);
111
112 bool SetActivePage(size_t page);
113 bool SetActivePage(wxRibbonPage* page);
114 int GetActivePage() const;
115 wxRibbonPage* GetPage(int n);
116 bool DismissExpandedPanel();
117
118 virtual bool HasMultiplePages() const { return true; }
119
120 void SetWindowStyleFlag(long style);
121 long GetWindowStyleFlag() const;
122 virtual bool Realize();
123
124 protected:
125 friend class wxRibbonPage;
126
127 virtual wxSize DoGetBestSize() const;
128 wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
129 wxRibbonPageTabInfo* HitTestTabs(wxPoint position, int* index = NULL);
130
131 void CommonInit(long style);
132 void AddPage(wxRibbonPage *page);
133 void RecalculateTabSizes();
134 void RecalculateMinSize();
135 void ScrollTabBar(int npixels);
136 void RefreshTabBar();
137 void RepositionPage(wxRibbonPage *page);
138
139 void OnPaint(wxPaintEvent& evt);
140 void OnEraseBackground(wxEraseEvent& evt);
141 void DoEraseBackground(wxDC& dc);
142 void OnSize(wxSizeEvent& evt);
143 void OnMouseLeftDown(wxMouseEvent& evt);
144 void OnMouseLeftUp(wxMouseEvent& evt);
145 void OnMouseMiddleDown(wxMouseEvent& evt);
146 void OnMouseMiddleUp(wxMouseEvent& evt);
147 void OnMouseRightDown(wxMouseEvent& evt);
148 void OnMouseRightUp(wxMouseEvent& evt);
149 void OnMouseMove(wxMouseEvent& evt);
150 void OnMouseLeave(wxMouseEvent& evt);
151 void OnMouseDoubleClick(wxMouseEvent& evt);
152 void DoMouseButtonCommon(wxMouseEvent& evt, wxEventType tab_event_type);
153
154 wxRibbonPageTabInfoArray m_pages;
155 wxRect m_tab_scroll_left_button_rect;
156 wxRect m_tab_scroll_right_button_rect;
157 long m_flags;
158 int m_tabs_total_width_ideal;
159 int m_tabs_total_width_minimum;
160 int m_tab_margin_left;
161 int m_tab_margin_right;
162 int m_tab_height;
163 int m_tab_scroll_amount;
164 int m_current_page;
165 int m_current_hovered_page;
166 int m_tab_scroll_left_button_state;
167 int m_tab_scroll_right_button_state;
168 bool m_tab_scroll_buttons_shown;
169
170 #ifndef SWIG
171 DECLARE_CLASS(wxRibbonBar)
172 DECLARE_EVENT_TABLE()
173 #endif
174 };
175
176 #ifndef SWIG
177
178 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, wxRibbonBarEvent);
179 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, wxRibbonBarEvent);
180 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, wxRibbonBarEvent);
181 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, wxRibbonBarEvent);
182 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, wxRibbonBarEvent);
183 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, wxRibbonBarEvent);
184 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, wxRibbonBarEvent);
185
186 typedef void (wxEvtHandler::*wxRibbonBarEventFunction)(wxRibbonBarEvent&);
187
188 #define wxRibbonBarEventHandler(func) \
189 wxEVENT_HANDLER_CAST(wxRibbonBarEventFunction, func)
190
191 #define EVT_RIBBONBAR_PAGE_CHANGED(winid, fn) \
192 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, winid, wxRibbonBarEventHandler(fn))
193 #define EVT_RIBBONBAR_PAGE_CHANGING(winid, fn) \
194 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, winid, wxRibbonBarEventHandler(fn))
195 #define EVT_RIBBONBAR_TAB_MIDDLE_DOWN(winid, fn) \
196 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, winid, wxRibbonBarEventHandler(fn))
197 #define EVT_RIBBONBAR_TAB_MIDDLE_UP(winid, fn) \
198 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, winid, wxRibbonBarEventHandler(fn))
199 #define EVT_RIBBONBAR_TAB_RIGHT_DOWN(winid, fn) \
200 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, winid, wxRibbonBarEventHandler(fn))
201 #define EVT_RIBBONBAR_TAB_RIGHT_UP(winid, fn) \
202 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, winid, wxRibbonBarEventHandler(fn))
203 #define EVT_RIBBONBAR_TAB_LEFT_DCLICK(winid, fn) \
204 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, winid, wxRibbonBarEventHandler(fn))
205 #else
206
207 // wxpython/swig event work
208 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED;
209 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING;
210 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN;
211 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP;
212 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN;
213 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP;
214 %constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK;
215
216 %pythoncode {
217 EVT_RIBBONBAR_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, 1 )
218 EVT_RIBBONBAR_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, 1 )
219 EVT_RIBBONBAR_TAB_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, 1 )
220 EVT_RIBBONBAR_TAB_MIDDLE_UP = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, 1 )
221 EVT_RIBBONBAR_TAB_RIGHT_DOWN = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, 1 )
222 EVT_RIBBONBAR_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, 1 )
223 EVT_RIBBONBAR_TAB_LEFT_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, 1 )
224 }
225 #endif
226
227 #endif // wxUSE_RIBBON
228
229 #endif // _WX_RIBBON_BAR_H_
230