1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/ribbon/gallery.h
3 // Purpose: Ribbon control which displays a gallery of items to choose from
4 // Author: Peter Cawley
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_RIBBON_GALLERY_H_
12 #define _WX_RIBBON_GALLERY_H_
18 #include "wx/ribbon/art.h"
19 #include "wx/ribbon/control.h"
21 class wxRibbonGalleryItem
;
23 WX_DEFINE_USER_EXPORTED_ARRAY(wxRibbonGalleryItem
*, wxArrayRibbonGalleryItem
, class WXDLLIMPEXP_RIBBON
);
25 class WXDLLIMPEXP_RIBBON wxRibbonGallery
: public wxRibbonControl
30 wxRibbonGallery(wxWindow
* parent
,
31 wxWindowID id
= wxID_ANY
,
32 const wxPoint
& pos
= wxDefaultPosition
,
33 const wxSize
& size
= wxDefaultSize
,
36 virtual ~wxRibbonGallery();
38 bool Create(wxWindow
* parent
,
39 wxWindowID id
= wxID_ANY
,
40 const wxPoint
& pos
= wxDefaultPosition
,
41 const wxSize
& size
= wxDefaultSize
,
47 unsigned int GetCount() const;
48 wxRibbonGalleryItem
* GetItem(unsigned int n
);
49 wxRibbonGalleryItem
* Append(const wxBitmap
& bitmap
, int id
);
50 wxRibbonGalleryItem
* Append(const wxBitmap
& bitmap
, int id
, void* clientData
);
51 wxRibbonGalleryItem
* Append(const wxBitmap
& bitmap
, int id
, wxClientData
* clientData
);
53 void SetItemClientObject(wxRibbonGalleryItem
* item
, wxClientData
* data
);
54 wxClientData
* GetItemClientObject(const wxRibbonGalleryItem
* item
) const;
55 void SetItemClientData(wxRibbonGalleryItem
* item
, void* data
);
56 void* GetItemClientData(const wxRibbonGalleryItem
* item
) const;
58 void SetSelection(wxRibbonGalleryItem
* item
);
59 wxRibbonGalleryItem
* GetSelection() const;
60 wxRibbonGalleryItem
* GetHoveredItem() const;
61 wxRibbonGalleryItem
* GetActiveItem() const;
62 wxRibbonGalleryButtonState
GetUpButtonState() const;
63 wxRibbonGalleryButtonState
GetDownButtonState() const;
64 wxRibbonGalleryButtonState
GetExtensionButtonState() const;
66 bool IsHovered() const;
67 virtual bool IsSizingContinuous() const;
68 virtual bool Realize();
69 virtual bool Layout();
71 virtual bool ScrollLines(int lines
);
72 void EnsureVisible(const wxRibbonGalleryItem
* item
);
75 wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
76 void CommonInit(long style
);
77 void CalculateMinSize();
78 bool TestButtonHover(const wxRect
& rect
, wxPoint pos
,
79 wxRibbonGalleryButtonState
* state
);
81 void OnEraseBackground(wxEraseEvent
& evt
);
82 void OnMouseEnter(wxMouseEvent
& evt
);
83 void OnMouseMove(wxMouseEvent
& evt
);
84 void OnMouseLeave(wxMouseEvent
& evt
);
85 void OnMouseDown(wxMouseEvent
& evt
);
86 void OnMouseUp(wxMouseEvent
& evt
);
87 void OnPaint(wxPaintEvent
& evt
);
88 void OnSize(wxSizeEvent
& evt
);
90 virtual wxSize
DoGetBestSize() const;
91 virtual wxSize
DoGetNextSmallerSize(wxOrientation direction
,
92 wxSize relative_to
) const;
93 virtual wxSize
DoGetNextLargerSize(wxOrientation direction
,
94 wxSize relative_to
) const;
96 wxArrayRibbonGalleryItem m_items
;
97 wxRibbonGalleryItem
* m_selected_item
;
98 wxRibbonGalleryItem
* m_hovered_item
;
99 wxRibbonGalleryItem
* m_active_item
;
100 wxSize m_bitmap_size
;
101 wxSize m_bitmap_padded_size
;
103 wxRect m_client_rect
;
104 wxRect m_scroll_up_button_rect
;
105 wxRect m_scroll_down_button_rect
;
106 wxRect m_extension_button_rect
;
107 const wxRect
* m_mouse_active_rect
;
108 int m_item_separation_x
;
109 int m_item_separation_y
;
112 wxRibbonGalleryButtonState m_up_button_state
;
113 wxRibbonGalleryButtonState m_down_button_state
;
114 wxRibbonGalleryButtonState m_extension_button_state
;
118 DECLARE_CLASS(wxRibbonGallery
)
119 DECLARE_EVENT_TABLE()
123 class WXDLLIMPEXP_RIBBON wxRibbonGalleryEvent
: public wxCommandEvent
126 wxRibbonGalleryEvent(wxEventType command_type
= wxEVT_NULL
,
128 wxRibbonGallery
* gallery
= NULL
,
129 wxRibbonGalleryItem
* item
= NULL
)
130 : wxCommandEvent(command_type
, win_id
)
131 , m_gallery(gallery
), m_item(item
)
135 wxRibbonGalleryEvent(const wxRibbonGalleryEvent
& e
) : wxCommandEvent(e
)
137 m_gallery
= e
.m_gallery
;
141 wxEvent
*Clone() const { return new wxRibbonGalleryEvent(*this); }
143 wxRibbonGallery
* GetGallery() {return m_gallery
;}
144 wxRibbonGalleryItem
* GetGalleryItem() {return m_item
;}
145 void SetGallery(wxRibbonGallery
* gallery
) {m_gallery
= gallery
;}
146 void SetGalleryItem(wxRibbonGalleryItem
* item
) {m_item
= item
;}
149 wxRibbonGallery
* m_gallery
;
150 wxRibbonGalleryItem
* m_item
;
154 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonGalleryEvent
)
160 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED
, wxRibbonGalleryEvent
);
161 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONGALLERY_SELECTED
, wxRibbonGalleryEvent
);
162 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONGALLERY_CLICKED
, wxRibbonGalleryEvent
);
164 typedef void (wxEvtHandler::*wxRibbonGalleryEventFunction
)(wxRibbonGalleryEvent
&);
166 #define wxRibbonGalleryEventHandler(func) \
167 wxEVENT_HANDLER_CAST(wxRibbonGalleryEventFunction, func)
169 #define EVT_RIBBONGALLERY_HOVER_CHANGED(winid, fn) \
170 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, winid, wxRibbonGalleryEventHandler(fn))
171 #define EVT_RIBBONGALLERY_SELECTED(winid, fn) \
172 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONGALLERY_SELECTED, winid, wxRibbonGalleryEventHandler(fn))
173 #define EVT_RIBBONGALLERY_CLICKED(winid, fn) \
174 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONGALLERY_CLICKED, winid, wxRibbonGalleryEventHandler(fn))
177 // wxpython/swig event work
178 %constant wxEventType wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED
;
179 %constant wxEventType wxEVT_COMMAND_RIBBONGALLERY_SELECTED
;
182 EVT_RIBBONGALLERY_HOVER_CHANGED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED
, 1 )
183 EVT_RIBBONGALLERY_SELECTED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONGALLERY_SELECTED
, 1 )
187 #endif // wxUSE_RIBBON
189 #endif // _WX_RIBBON_GALLERY_H_