]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/ribbon/panel.h
Fix wrong tab order in wxAuiNotebook after dragging.
[wxWidgets.git] / include / wx / ribbon / panel.h
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/ribbon/panel.h
3// Purpose: Ribbon-style container for a group of related tools / controls
4// Author: Peter Cawley
5// Modified by:
6// Created: 2009-05-25
7// RCS-ID: $Id$
8// Copyright: (C) Peter Cawley
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11#ifndef _WX_RIBBON_PANEL_H_
12#define _WX_RIBBON_PANEL_H_
13
14#include "wx/defs.h"
15
16#if wxUSE_RIBBON
17
18#include "wx/bitmap.h"
19#include "wx/ribbon/control.h"
20
21enum wxRibbonPanelOption
22{
23 wxRIBBON_PANEL_NO_AUTO_MINIMISE = 1 << 0,
24 wxRIBBON_PANEL_EXT_BUTTON = 1 << 3,
25 wxRIBBON_PANEL_MINIMISE_BUTTON = 1 << 4,
26 wxRIBBON_PANEL_STRETCH = 1 << 5,
27 wxRIBBON_PANEL_FLEXIBLE = 1 << 6,
28
29 wxRIBBON_PANEL_DEFAULT_STYLE = 0
30};
31
32class WXDLLIMPEXP_RIBBON wxRibbonPanel : public wxRibbonControl
33{
34public:
35 wxRibbonPanel();
36
37 wxRibbonPanel(wxWindow* parent,
38 wxWindowID id = wxID_ANY,
39 const wxString& label = wxEmptyString,
40 const wxBitmap& minimised_icon = wxNullBitmap,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 long style = wxRIBBON_PANEL_DEFAULT_STYLE);
44
45 virtual ~wxRibbonPanel();
46
47 bool Create(wxWindow* parent,
48 wxWindowID id = wxID_ANY,
49 const wxString& label = wxEmptyString,
50 const wxBitmap& icon = wxNullBitmap,
51 const wxPoint& pos = wxDefaultPosition,
52 const wxSize& size = wxDefaultSize,
53 long style = wxRIBBON_PANEL_DEFAULT_STYLE);
54
55 wxBitmap& GetMinimisedIcon() {return m_minimised_icon;}
56 const wxBitmap& GetMinimisedIcon() const {return m_minimised_icon;}
57 bool IsMinimised() const;
58 bool IsMinimised(wxSize at_size) const;
59 bool IsHovered() const;
60 bool IsExtButtonHovered() const;
61 bool CanAutoMinimise() const;
62
63 bool ShowExpanded();
64 bool HideExpanded();
65
66 void SetArtProvider(wxRibbonArtProvider* art);
67
68 virtual bool Realize();
69 virtual bool Layout();
70 virtual wxSize GetMinSize() const;
71
72 virtual bool IsSizingContinuous() const;
73
74 virtual void AddChild(wxWindowBase *child);
75 virtual void RemoveChild(wxWindowBase *child);
76
77 virtual bool HasExtButton() const;
78
79 wxRibbonPanel* GetExpandedDummy();
80 wxRibbonPanel* GetExpandedPanel();
81
82 // Finds the best width and height given the parent's width and height
83 virtual wxSize GetBestSizeForParentSize(const wxSize& parentSize) const;
84
85 long GetFlags() { return m_flags; }
86
87 void HideIfExpanded();
88
89protected:
90 virtual wxSize DoGetBestSize() const;
91 virtual wxSize GetPanelSizerBestSize() const;
92 wxSize GetPanelSizerMinSize() const;
93 wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
94 wxSize GetMinNotMinimisedSize() const;
95
96 virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
97 wxSize relative_to) const;
98 virtual wxSize DoGetNextLargerSize(wxOrientation direction,
99 wxSize relative_to) const;
100
101 void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
102 void OnSize(wxSizeEvent& evt);
103 void OnEraseBackground(wxEraseEvent& evt);
104 void OnPaint(wxPaintEvent& evt);
105 void OnMouseEnter(wxMouseEvent& evt);
106 void OnMouseEnterChild(wxMouseEvent& evt);
107 void OnMouseLeave(wxMouseEvent& evt);
108 void OnMouseLeaveChild(wxMouseEvent& evt);
109 void OnMouseClick(wxMouseEvent& evt);
110 void OnMotion(wxMouseEvent& evt);
111 void OnKillFocus(wxFocusEvent& evt);
112 void OnChildKillFocus(wxFocusEvent& evt);
113
114 void TestPositionForHover(const wxPoint& pos);
115 bool ShouldSendEventToDummy(wxEvent& evt);
116 virtual bool TryAfter(wxEvent& evt);
117
118 void CommonInit(const wxString& label, const wxBitmap& icon, long style);
119 static wxRect GetExpandedPosition(wxRect panel,
120 wxSize expanded_size,
121 wxDirection direction);
122
123 wxBitmap m_minimised_icon;
124 wxBitmap m_minimised_icon_resized;
125 wxSize m_smallest_unminimised_size;
126 wxSize m_minimised_size;
127 wxDirection m_preferred_expand_direction;
128 wxRibbonPanel* m_expanded_dummy;
129 wxRibbonPanel* m_expanded_panel;
130 wxWindow* m_child_with_focus;
131 long m_flags;
132 bool m_minimised;
133 bool m_hovered;
134 bool m_ext_button_hovered;
135 wxRect m_ext_button_rect;
136
137#ifndef SWIG
138 DECLARE_CLASS(wxRibbonPanel)
139 DECLARE_EVENT_TABLE()
140#endif
141};
142
143
144class WXDLLIMPEXP_RIBBON wxRibbonPanelEvent : public wxCommandEvent
145{
146public:
147 wxRibbonPanelEvent(wxEventType command_type = wxEVT_NULL,
148 int win_id = 0,
149 wxRibbonPanel* panel = NULL)
150 : wxCommandEvent(command_type, win_id)
151 , m_panel(panel)
152 {
153 }
154#ifndef SWIG
155 wxRibbonPanelEvent(const wxRibbonPanelEvent& e) : wxCommandEvent(e)
156 {
157 m_panel = e.m_panel;
158 }
159#endif
160 wxEvent *Clone() const { return new wxRibbonPanelEvent(*this); }
161
162 wxRibbonPanel* GetPanel() {return m_panel;}
163 void SetPanel(wxRibbonPanel* panel) {m_panel = panel;}
164
165protected:
166 wxRibbonPanel* m_panel;
167
168#ifndef SWIG
169private:
170 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonPanelEvent)
171#endif
172};
173
174#ifndef SWIG
175
176wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED, wxRibbonPanelEvent);
177
178typedef void (wxEvtHandler::*wxRibbonPanelEventFunction)(wxRibbonPanelEvent&);
179
180#define wxRibbonPanelEventHandler(func) \
181 wxEVENT_HANDLER_CAST(wxRibbonPanelEventFunction, func)
182
183#define EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED(winid, fn) \
184 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED, winid, wxRibbonPanelEventHandler(fn))
185#else
186
187// wxpython/swig event work
188%constant wxEventType wxEVT_COMMAND_RIBBONPANEL_ACTIVATED;
189
190%pythoncode {
191 EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED, 1 )
192}
193#endif
194
195#endif // wxUSE_RIBBON
196
197#endif // _WX_RIBBON_PANEL_H_