Added wxRIBBON_PANEL_STRETCH to allow a single panel to stretch to fill the parent...
[wxWidgets.git] / include / wx / ribbon / panel.h
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
21 enum 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
28 wxRIBBON_PANEL_DEFAULT_STYLE = 0
29 };
30
31 class WXDLLIMPEXP_RIBBON wxRibbonPanel : public wxRibbonControl
32 {
33 public:
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;
59 bool CanAutoMinimise() const;
60
61 bool ShowExpanded();
62 bool HideExpanded();
63
64 void SetArtProvider(wxRibbonArtProvider* art);
65
66 virtual bool Realize();
67 virtual bool Layout();
68 virtual wxSize GetMinSize() const;
69
70 virtual bool IsSizingContinuous() const;
71
72 virtual void AddChild(wxWindowBase *child);
73 virtual void RemoveChild(wxWindowBase *child);
74
75 wxRibbonPanel* GetExpandedDummy();
76 wxRibbonPanel* GetExpandedPanel();
77
78 protected:
79 virtual wxSize DoGetBestSize() const;
80 virtual wxSize GetPanelSizerBestSize() const;
81 wxSize GetPanelSizerMinSize() const;
82 wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
83 wxSize GetMinNotMinimisedSize() const;
84
85 virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
86 wxSize relative_to) const;
87 virtual wxSize DoGetNextLargerSize(wxOrientation direction,
88 wxSize relative_to) const;
89
90 void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
91 void OnSize(wxSizeEvent& evt);
92 void OnEraseBackground(wxEraseEvent& evt);
93 void OnPaint(wxPaintEvent& evt);
94 void OnMouseEnter(wxMouseEvent& evt);
95 void OnMouseEnterChild(wxMouseEvent& evt);
96 void OnMouseLeave(wxMouseEvent& evt);
97 void OnMouseLeaveChild(wxMouseEvent& evt);
98 void OnMouseClick(wxMouseEvent& evt);
99 void OnKillFocus(wxFocusEvent& evt);
100 void OnChildKillFocus(wxFocusEvent& evt);
101
102 void TestPositionForHover(const wxPoint& pos);
103 bool ShouldSendEventToDummy(wxEvent& evt);
104 virtual bool TryAfter(wxEvent& evt);
105
106 void CommonInit(const wxString& label, const wxBitmap& icon, long style);
107 static wxRect GetExpandedPosition(wxRect panel,
108 wxSize expanded_size,
109 wxDirection direction);
110
111 wxBitmap m_minimised_icon;
112 wxBitmap m_minimised_icon_resized;
113 wxSize m_smallest_unminimised_size;
114 wxSize m_minimised_size;
115 wxDirection m_preferred_expand_direction;
116 wxRibbonPanel* m_expanded_dummy;
117 wxRibbonPanel* m_expanded_panel;
118 wxWindow* m_child_with_focus;
119 long m_flags;
120 bool m_minimised;
121 bool m_hovered;
122
123 #ifndef SWIG
124 DECLARE_CLASS(wxRibbonPanel)
125 DECLARE_EVENT_TABLE()
126 #endif
127 };
128
129 #endif // wxUSE_RIBBON
130
131 #endif // _WX_RIBBON_PANEL_H_