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