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
; }
88 virtual wxSize
DoGetBestSize() const;
89 virtual wxSize
GetPanelSizerBestSize() const;
90 wxSize
GetPanelSizerMinSize() const;
91 wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
92 wxSize
GetMinNotMinimisedSize() const;
94 virtual wxSize
DoGetNextSmallerSize(wxOrientation direction
,
95 wxSize relative_to
) const;
96 virtual wxSize
DoGetNextLargerSize(wxOrientation direction
,
97 wxSize relative_to
) const;
99 void DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
100 void OnSize(wxSizeEvent
& evt
);
101 void OnEraseBackground(wxEraseEvent
& evt
);
102 void OnPaint(wxPaintEvent
& evt
);
103 void OnMouseEnter(wxMouseEvent
& evt
);
104 void OnMouseEnterChild(wxMouseEvent
& evt
);
105 void OnMouseLeave(wxMouseEvent
& evt
);
106 void OnMouseLeaveChild(wxMouseEvent
& evt
);
107 void OnMouseClick(wxMouseEvent
& evt
);
108 void OnMotion(wxMouseEvent
& evt
);
109 void OnKillFocus(wxFocusEvent
& evt
);
110 void OnChildKillFocus(wxFocusEvent
& evt
);
112 void TestPositionForHover(const wxPoint
& pos
);
113 bool ShouldSendEventToDummy(wxEvent
& evt
);
114 virtual bool TryAfter(wxEvent
& evt
);
116 void CommonInit(const wxString
& label
, const wxBitmap
& icon
, long style
);
117 static wxRect
GetExpandedPosition(wxRect panel
,
118 wxSize expanded_size
,
119 wxDirection direction
);
121 wxBitmap m_minimised_icon
;
122 wxBitmap m_minimised_icon_resized
;
123 wxSize m_smallest_unminimised_size
;
124 wxSize m_minimised_size
;
125 wxDirection m_preferred_expand_direction
;
126 wxRibbonPanel
* m_expanded_dummy
;
127 wxRibbonPanel
* m_expanded_panel
;
128 wxWindow
* m_child_with_focus
;
132 bool m_ext_button_hovered
;
133 wxRect m_ext_button_rect
;
136 DECLARE_CLASS(wxRibbonPanel
)
137 DECLARE_EVENT_TABLE()
142 class WXDLLIMPEXP_RIBBON wxRibbonPanelEvent
: public wxCommandEvent
145 wxRibbonPanelEvent(wxEventType command_type
= wxEVT_NULL
,
147 wxRibbonPanel
* panel
= NULL
)
148 : wxCommandEvent(command_type
, win_id
)
153 wxRibbonPanelEvent(const wxRibbonPanelEvent
& e
) : wxCommandEvent(e
)
158 wxEvent
*Clone() const { return new wxRibbonPanelEvent(*this); }
160 wxRibbonPanel
* GetPanel() {return m_panel
;}
161 void SetPanel(wxRibbonPanel
* panel
) {m_panel
= panel
;}
164 wxRibbonPanel
* m_panel
;
168 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonPanelEvent
)
174 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED
, wxRibbonPanelEvent
);
176 typedef void (wxEvtHandler::*wxRibbonPanelEventFunction
)(wxRibbonPanelEvent
&);
178 #define wxRibbonPanelEventHandler(func) \
179 wxEVENT_HANDLER_CAST(wxRibbonPanelEventFunction, func)
181 #define EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED(winid, fn) \
182 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED, winid, wxRibbonPanelEventHandler(fn))
185 // wxpython/swig event work
186 %constant wxEventType wxEVT_COMMAND_RIBBONPANEL_ACTIVATED
;
189 EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED
, 1 )
193 #endif // wxUSE_RIBBON
195 #endif // _WX_RIBBON_PANEL_H_