1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/ribbon/panel.h
3 // Purpose: Ribbon-style container for a group of related tools / controls
4 // Author: Peter Cawley
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_RIBBON_PANEL_H_
12 #define _WX_RIBBON_PANEL_H_
18 #include "wx/bitmap.h"
19 #include "wx/ribbon/control.h"
21 enum wxRibbonPanelOption
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,
29 wxRIBBON_PANEL_DEFAULT_STYLE
= 0
32 class WXDLLIMPEXP_RIBBON wxRibbonPanel
: public wxRibbonControl
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
);
45 virtual ~wxRibbonPanel();
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
);
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;
66 void SetArtProvider(wxRibbonArtProvider
* art
);
68 virtual bool Realize();
69 virtual bool Layout();
70 virtual wxSize
GetMinSize() const;
72 virtual bool IsSizingContinuous() const;
74 virtual void AddChild(wxWindowBase
*child
);
75 virtual void RemoveChild(wxWindowBase
*child
);
77 virtual bool HasExtButton() const;
79 wxRibbonPanel
* GetExpandedDummy();
80 wxRibbonPanel
* GetExpandedPanel();
82 // Finds the best width and height given the parent's width and height
83 virtual wxSize
GetBestSizeForParentSize(const wxSize
& parentSize
) const;
85 long GetFlags() { return m_flags
; }
87 void HideIfExpanded();
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;
96 virtual wxSize
DoGetNextSmallerSize(wxOrientation direction
,
97 wxSize relative_to
) const;
98 virtual wxSize
DoGetNextLargerSize(wxOrientation direction
,
99 wxSize relative_to
) const;
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
);
114 void TestPositionForHover(const wxPoint
& pos
);
115 bool ShouldSendEventToDummy(wxEvent
& evt
);
116 virtual bool TryAfter(wxEvent
& evt
);
118 void CommonInit(const wxString
& label
, const wxBitmap
& icon
, long style
);
119 static wxRect
GetExpandedPosition(wxRect panel
,
120 wxSize expanded_size
,
121 wxDirection direction
);
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
;
134 bool m_ext_button_hovered
;
135 wxRect m_ext_button_rect
;
138 DECLARE_CLASS(wxRibbonPanel
)
139 DECLARE_EVENT_TABLE()
144 class WXDLLIMPEXP_RIBBON wxRibbonPanelEvent
: public wxCommandEvent
147 wxRibbonPanelEvent(wxEventType command_type
= wxEVT_NULL
,
149 wxRibbonPanel
* panel
= NULL
)
150 : wxCommandEvent(command_type
, win_id
)
155 wxRibbonPanelEvent(const wxRibbonPanelEvent
& e
) : wxCommandEvent(e
)
160 wxEvent
*Clone() const { return new wxRibbonPanelEvent(*this); }
162 wxRibbonPanel
* GetPanel() {return m_panel
;}
163 void SetPanel(wxRibbonPanel
* panel
) {m_panel
= panel
;}
166 wxRibbonPanel
* m_panel
;
170 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonPanelEvent
)
176 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED
, wxRibbonPanelEvent
);
178 typedef void (wxEvtHandler::*wxRibbonPanelEventFunction
)(wxRibbonPanelEvent
&);
180 #define wxRibbonPanelEventHandler(func) \
181 wxEVENT_HANDLER_CAST(wxRibbonPanelEventFunction, func)
183 #define EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED(winid, fn) \
184 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED, winid, wxRibbonPanelEventHandler(fn))
187 // wxpython/swig event work
188 %constant wxEventType wxEVT_COMMAND_RIBBONPANEL_ACTIVATED
;
191 EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED
, 1 )
195 #endif // wxUSE_RIBBON
197 #endif // _WX_RIBBON_PANEL_H_