1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/ribbon/panel.h
3 // Purpose: Ribbon-style container for a group of related tools / controls
4 // Author: Peter Cawley
7 // Copyright: (C) Peter Cawley
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_RIBBON_PANEL_H_
11 #define _WX_RIBBON_PANEL_H_
17 #include "wx/bitmap.h"
18 #include "wx/ribbon/control.h"
20 enum wxRibbonPanelOption
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,
26 wxRIBBON_PANEL_FLEXIBLE
= 1 << 6,
28 wxRIBBON_PANEL_DEFAULT_STYLE
= 0
31 class WXDLLIMPEXP_RIBBON wxRibbonPanel
: public wxRibbonControl
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
);
44 virtual ~wxRibbonPanel();
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
);
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 IsExtButtonHovered() const;
60 bool CanAutoMinimise() const;
65 void SetArtProvider(wxRibbonArtProvider
* art
);
67 virtual bool Realize();
68 virtual bool Layout();
69 virtual wxSize
GetMinSize() const;
71 virtual bool IsSizingContinuous() const;
73 virtual void AddChild(wxWindowBase
*child
);
74 virtual void RemoveChild(wxWindowBase
*child
);
76 virtual bool HasExtButton() const;
78 wxRibbonPanel
* GetExpandedDummy();
79 wxRibbonPanel
* GetExpandedPanel();
81 // Finds the best width and height given the parent's width and height
82 virtual wxSize
GetBestSizeForParentSize(const wxSize
& parentSize
) const;
84 long GetFlags() { return m_flags
; }
86 void HideIfExpanded();
89 virtual wxSize
DoGetBestSize() const;
90 virtual wxSize
GetPanelSizerBestSize() const;
91 wxSize
GetPanelSizerMinSize() const;
92 wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
93 wxSize
GetMinNotMinimisedSize() const;
95 virtual wxSize
DoGetNextSmallerSize(wxOrientation direction
,
96 wxSize relative_to
) const;
97 virtual wxSize
DoGetNextLargerSize(wxOrientation direction
,
98 wxSize relative_to
) const;
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
);
109 void OnMotion(wxMouseEvent
& evt
);
110 void OnKillFocus(wxFocusEvent
& evt
);
111 void OnChildKillFocus(wxFocusEvent
& evt
);
113 void TestPositionForHover(const wxPoint
& pos
);
114 bool ShouldSendEventToDummy(wxEvent
& evt
);
115 virtual bool TryAfter(wxEvent
& evt
);
117 void CommonInit(const wxString
& label
, const wxBitmap
& icon
, long style
);
118 static wxRect
GetExpandedPosition(wxRect panel
,
119 wxSize expanded_size
,
120 wxDirection direction
);
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
;
133 bool m_ext_button_hovered
;
134 wxRect m_ext_button_rect
;
137 DECLARE_CLASS(wxRibbonPanel
)
138 DECLARE_EVENT_TABLE()
143 class WXDLLIMPEXP_RIBBON wxRibbonPanelEvent
: public wxCommandEvent
146 wxRibbonPanelEvent(wxEventType command_type
= wxEVT_NULL
,
148 wxRibbonPanel
* panel
= NULL
)
149 : wxCommandEvent(command_type
, win_id
)
154 wxRibbonPanelEvent(const wxRibbonPanelEvent
& e
) : wxCommandEvent(e
)
159 wxEvent
*Clone() const { return new wxRibbonPanelEvent(*this); }
161 wxRibbonPanel
* GetPanel() {return m_panel
;}
162 void SetPanel(wxRibbonPanel
* panel
) {m_panel
= panel
;}
165 wxRibbonPanel
* m_panel
;
169 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonPanelEvent
)
175 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED
, wxRibbonPanelEvent
);
177 typedef void (wxEvtHandler::*wxRibbonPanelEventFunction
)(wxRibbonPanelEvent
&);
179 #define wxRibbonPanelEventHandler(func) \
180 wxEVENT_HANDLER_CAST(wxRibbonPanelEventFunction, func)
182 #define EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED(winid, fn) \
183 wx__DECLARE_EVT1(wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED, winid, wxRibbonPanelEventHandler(fn))
186 // wxpython/swig event work
187 %constant wxEventType wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED
;
190 EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED
= wx
.PyEventBinder( wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED
, 1 )
194 // old wxEVT_COMMAND_* constants
195 #define wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED
197 #endif // wxUSE_RIBBON
199 #endif // _WX_RIBBON_PANEL_H_