]> git.saurik.com Git - wxWidgets.git/blame - include/wx/ribbon/panel.h
default implementation for scaled bitmaps properties
[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
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{
8d3d5f06
JS
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,
98742322 27 wxRIBBON_PANEL_FLEXIBLE = 1 << 6,
ce00f59b 28
8d3d5f06 29 wxRIBBON_PANEL_DEFAULT_STYLE = 0
3c3ead1d
PC
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;
0a7ee6e0 60 bool IsExtButtonHovered() const;
3c3ead1d
PC
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;
3c3ead1d
PC
71
72 virtual bool IsSizingContinuous() const;
73
74 virtual void AddChild(wxWindowBase *child);
75 virtual void RemoveChild(wxWindowBase *child);
76
0a7ee6e0
VZ
77 virtual bool HasExtButton() const;
78
3c3ead1d
PC
79 wxRibbonPanel* GetExpandedDummy();
80 wxRibbonPanel* GetExpandedPanel();
81
98742322
JS
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
42d73941
VZ
87 void HideIfExpanded();
88
3c3ead1d 89protected:
cff9681b 90 virtual wxSize DoGetBestSize() const;
140091e5
PC
91 virtual wxSize GetPanelSizerBestSize() const;
92 wxSize GetPanelSizerMinSize() const;
3c3ead1d
PC
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);
0a7ee6e0 110 void OnMotion(wxMouseEvent& evt);
3c3ead1d
PC
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;
0a7ee6e0
VZ
134 bool m_ext_button_hovered;
135 wxRect m_ext_button_rect;
3c3ead1d
PC
136
137#ifndef SWIG
138 DECLARE_CLASS(wxRibbonPanel)
139 DECLARE_EVENT_TABLE()
140#endif
141};
142
0a7ee6e0
VZ
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
ce7fe42e 176wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED, wxRibbonPanelEvent);
0a7ee6e0
VZ
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) \
ce7fe42e 184 wx__DECLARE_EVT1(wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED, winid, wxRibbonPanelEventHandler(fn))
0a7ee6e0
VZ
185#else
186
187// wxpython/swig event work
ce7fe42e 188%constant wxEventType wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED;
0a7ee6e0
VZ
189
190%pythoncode {
ce7fe42e 191 EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED = wx.PyEventBinder( wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED, 1 )
0a7ee6e0
VZ
192}
193#endif
194
ce7fe42e
VZ
195// old wxEVT_COMMAND_* constants
196#define wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED
197
3c3ead1d
PC
198#endif // wxUSE_RIBBON
199
200#endif // _WX_RIBBON_PANEL_H_