]> git.saurik.com Git - wxWidgets.git/blame - include/wx/ribbon/bar.h
Generate tags for ribbon headers and sources too.
[wxWidgets.git] / include / wx / ribbon / bar.h
CommitLineData
3c3ead1d
PC
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
22enum 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
2f6b64a9 39 | wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS
3c3ead1d
PC
40};
41
42class WXDLLIMPEXP_RIBBON wxRibbonBarEvent : public wxNotifyEvent
43{
44public:
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
63protected:
64 wxRibbonPage* m_page;
65
66#ifndef SWIG
67private:
68 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonBarEvent)
69#endif
70};
71
72class WXDLLIMPEXP_RIBBON wxRibbonPageTabInfo
73{
74public:
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
86WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRibbonPageTabInfo, wxRibbonPageTabInfoArray, WXDLLIMPEXP_RIBBON);
87#endif
88
89class WXDLLIMPEXP_RIBBON wxRibbonBar : public wxRibbonControl
90{
91public:
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);
c21b99e0 116 size_t GetPageCount() const;
3c3ead1d
PC
117 bool DismissExpandedPanel();
118
c21b99e0
VZ
119 void DeletePage(size_t n);
120 void ClearPages();
121
3603e565
VZ
122 void ShowPanels(bool show = true);
123 void HidePanels() { ShowPanels(false); }
124 bool ArePanelsShown() const { return m_arePanelsShown; }
125
3c3ead1d
PC
126 virtual bool HasMultiplePages() const { return true; }
127
128 void SetWindowStyleFlag(long style);
129 long GetWindowStyleFlag() const;
130 virtual bool Realize();
131
132protected:
133 friend class wxRibbonPage;
134
cff9681b 135 virtual wxSize DoGetBestSize() const;
3c3ead1d
PC
136 wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
137 wxRibbonPageTabInfo* HitTestTabs(wxPoint position, int* index = NULL);
138
139 void CommonInit(long style);
140 void AddPage(wxRibbonPage *page);
141 void RecalculateTabSizes();
142 void RecalculateMinSize();
143 void ScrollTabBar(int npixels);
144 void RefreshTabBar();
145 void RepositionPage(wxRibbonPage *page);
146
147 void OnPaint(wxPaintEvent& evt);
148 void OnEraseBackground(wxEraseEvent& evt);
149 void DoEraseBackground(wxDC& dc);
150 void OnSize(wxSizeEvent& evt);
151 void OnMouseLeftDown(wxMouseEvent& evt);
152 void OnMouseLeftUp(wxMouseEvent& evt);
153 void OnMouseMiddleDown(wxMouseEvent& evt);
154 void OnMouseMiddleUp(wxMouseEvent& evt);
155 void OnMouseRightDown(wxMouseEvent& evt);
156 void OnMouseRightUp(wxMouseEvent& evt);
157 void OnMouseMove(wxMouseEvent& evt);
158 void OnMouseLeave(wxMouseEvent& evt);
a65b84f4 159 void OnMouseDoubleClick(wxMouseEvent& evt);
3c3ead1d
PC
160 void DoMouseButtonCommon(wxMouseEvent& evt, wxEventType tab_event_type);
161
162 wxRibbonPageTabInfoArray m_pages;
163 wxRect m_tab_scroll_left_button_rect;
164 wxRect m_tab_scroll_right_button_rect;
165 long m_flags;
166 int m_tabs_total_width_ideal;
167 int m_tabs_total_width_minimum;
168 int m_tab_margin_left;
169 int m_tab_margin_right;
170 int m_tab_height;
171 int m_tab_scroll_amount;
172 int m_current_page;
173 int m_current_hovered_page;
174 int m_tab_scroll_left_button_state;
175 int m_tab_scroll_right_button_state;
176 bool m_tab_scroll_buttons_shown;
3603e565 177 bool m_arePanelsShown;
3c3ead1d
PC
178
179#ifndef SWIG
180 DECLARE_CLASS(wxRibbonBar)
181 DECLARE_EVENT_TABLE()
182#endif
183};
184
185#ifndef SWIG
186
187wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, wxRibbonBarEvent);
188wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, wxRibbonBarEvent);
189wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, wxRibbonBarEvent);
190wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, wxRibbonBarEvent);
191wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, wxRibbonBarEvent);
192wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, wxRibbonBarEvent);
a65b84f4 193wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, wxRibbonBarEvent);
3c3ead1d
PC
194
195typedef void (wxEvtHandler::*wxRibbonBarEventFunction)(wxRibbonBarEvent&);
196
197#define wxRibbonBarEventHandler(func) \
198 wxEVENT_HANDLER_CAST(wxRibbonBarEventFunction, func)
199
200#define EVT_RIBBONBAR_PAGE_CHANGED(winid, fn) \
201 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, winid, wxRibbonBarEventHandler(fn))
202#define EVT_RIBBONBAR_PAGE_CHANGING(winid, fn) \
203 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, winid, wxRibbonBarEventHandler(fn))
204#define EVT_RIBBONBAR_TAB_MIDDLE_DOWN(winid, fn) \
205 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, winid, wxRibbonBarEventHandler(fn))
206#define EVT_RIBBONBAR_TAB_MIDDLE_UP(winid, fn) \
207 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, winid, wxRibbonBarEventHandler(fn))
208#define EVT_RIBBONBAR_TAB_RIGHT_DOWN(winid, fn) \
209 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, winid, wxRibbonBarEventHandler(fn))
210#define EVT_RIBBONBAR_TAB_RIGHT_UP(winid, fn) \
211 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, winid, wxRibbonBarEventHandler(fn))
a65b84f4
VZ
212#define EVT_RIBBONBAR_TAB_LEFT_DCLICK(winid, fn) \
213 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, winid, wxRibbonBarEventHandler(fn))
3c3ead1d
PC
214#else
215
216// wxpython/swig event work
217%constant wxEventType wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED;
218%constant wxEventType wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING;
219%constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN;
220%constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP;
221%constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN;
222%constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP;
a65b84f4 223%constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK;
3c3ead1d
PC
224
225%pythoncode {
226 EVT_RIBBONBAR_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, 1 )
227 EVT_RIBBONBAR_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, 1 )
228 EVT_RIBBONBAR_TAB_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, 1 )
229 EVT_RIBBONBAR_TAB_MIDDLE_UP = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, 1 )
230 EVT_RIBBONBAR_TAB_RIGHT_DOWN = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, 1 )
231 EVT_RIBBONBAR_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, 1 )
a65b84f4 232 EVT_RIBBONBAR_TAB_LEFT_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, 1 )
3c3ead1d
PC
233}
234#endif
235
236#endif // wxUSE_RIBBON
237
238#endif // _WX_RIBBON_BAR_H_
239