1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: ribbon/gallery.h
3 // Purpose: interface of wxRibbonGallery
4 // Author: Peter Cawley
6 // Licence: wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
9 enum wxRibbonGalleryButtonState
11 wxRIBBON_GALLERY_BUTTON_NORMAL
,
12 wxRIBBON_GALLERY_BUTTON_HOVERED
,
13 wxRIBBON_GALLERY_BUTTON_ACTIVE
,
14 wxRIBBON_GALLERY_BUTTON_DISABLED
,
18 @class wxRibbonGallery
20 A ribbon gallery is like a wxListBox, but for bitmaps rather than strings.
21 It displays a collection of bitmaps arranged in a grid and allows the user
22 to choose one. As there are typically more bitmaps in a gallery than can
23 be displayed in the space used for a ribbon, a gallery always has scroll
24 buttons to allow the user to navigate through the entire gallery. It also
25 has an "extension" button, the behaviour of which is outside the scope of
26 the gallery control itself, though it typically displays some kind of
27 dialog related to the gallery.
29 @beginEventEmissionTable{wxRibbonGalleryEvent}
30 @event{EVT_RIBBONGALLERY_SELECTED(id, func)}
31 Triggered when the user selects an item from the gallery. Note that the
32 ID is that of the gallery, not of the item.
33 @event{EVT_RIBBONGALLERY_HOVER_CHANGED(id, func)}
34 Triggered when the item being hovered over by the user changes. The
35 item in the event will be the new item being hovered, or NULL if there
36 is no longer an item being hovered. Note that the ID is that of the
37 gallery, not of the item.
39 @beginEventEmissionTable{wxCommandEvent}
40 @event{EVT_BUTTON(id, func)}
41 Triggered when the "extension" button of the gallery is pressed.
47 class wxRibbonGallery
: public wxRibbonControl
52 With this constructor, Create() should be called in order to create
58 Construct a ribbon gallery with the given parameters.
60 Parent window for the gallery (typically a wxRibbonPanel).
62 Initial position of the gallery.
64 Initial size of the gallery.
66 Gallery style, currently unused.
68 wxRibbonGallery(wxWindow
* parent
,
69 wxWindowID id
= wxID_ANY
,
70 const wxPoint
& pos
= wxDefaultPosition
,
71 const wxSize
& size
= wxDefaultSize
,
77 virtual ~wxRibbonGallery();
80 Create a gallery in two-step gallery construction.
81 Should only be called when the default constructor is used, and
82 arguments have the same meaning as in the full constructor.
84 bool Create(wxWindow
* parent
,
85 wxWindowID id
= wxID_ANY
,
86 const wxPoint
& pos
= wxDefaultPosition
,
87 const wxSize
& size
= wxDefaultSize
,
91 Remove all items from the gallery.
96 Query if the gallery has no items in it.
101 Get the number of items in the gallery.
103 unsigned int GetCount() const;
106 Get an item by index.
108 wxRibbonGalleryItem
* GetItem(unsigned int n
);
111 Add an item to the gallery (with no client data).
113 The bitmap to display for the item. Note that all items must
114 have equally sized bitmaps.
116 ID number to associate with the item. Not currently used for
119 wxRibbonGalleryItem
* Append(const wxBitmap
& bitmap
, int id
);
122 Add an item to the gallery (with simple client data).
124 The bitmap to display for the item. Note that all items must
125 have equally sized bitmaps.
127 ID number to associate with the item. Not currently used for
130 An opaque pointer to associate with the item.
132 wxRibbonGalleryItem
* Append(const wxBitmap
& bitmap
, int id
, void* clientData
);
135 Add an item to the gallery (with complex client data)
137 The bitmap to display for the item. Note that all items must
138 have equally sized bitmaps.
140 ID number to associate with the item. Not currently used for
143 An object which contains data to associate with the item. The item
144 takes ownership of this pointer, and will delete it when the item
145 client data is changed to something else, or when the item is
148 wxRibbonGalleryItem
* Append(const wxBitmap
& bitmap
, int id
, wxClientData
* clientData
);
151 Set the client object associated with a gallery item.
153 void SetItemClientObject(wxRibbonGalleryItem
* item
, wxClientData
* data
);
156 Get the client object associated with a gallery item.
158 wxClientData
* GetItemClientObject(const wxRibbonGalleryItem
* item
) const;
161 Set the client data associated with a gallery item.
163 void SetItemClientData(wxRibbonGalleryItem
* item
, void* data
);
166 Get the client data associated with a gallery item.
168 void* GetItemClientData(const wxRibbonGalleryItem
* item
) const;
171 Set the selection to the given item, or removes the selection if
174 Note that this not cause any events to be emitted.
176 void SetSelection(wxRibbonGalleryItem
* item
);
179 Get the currently selected item, or NULL if there is none.
181 The selected item is set by SetSelection(), or by the user clicking on
184 wxRibbonGalleryItem
* GetSelection() const;
187 Get the currently hovered item, or NULL if there is none.
189 The hovered item is the item underneath the mouse cursor.
191 wxRibbonGalleryItem
* GetHoveredItem() const;
194 Get the currently active item, or NULL if there is none.
196 The active item is the item being pressed by the user, and will thus
197 become the selected item if the user releases the mouse button.
199 wxRibbonGalleryItem
* GetActiveItem() const;
202 Get the state of the scroll up button.
204 wxRibbonGalleryButtonState
GetUpButtonState() const;
207 Get the state of the scroll down button.
209 wxRibbonGalleryButtonState
GetDownButtonState() const;
212 Get the state of the "extension" button.
214 wxRibbonGalleryButtonState
GetExtensionButtonState() const;
217 Query is the mouse is currently hovered over the gallery.
219 @return @true if the cursor is within the bounds of the gallery (not
220 just hovering over an item), @false otherwise.
222 bool IsHovered() const;
225 Scroll the gallery contents by some amount.
228 Positive values scroll toward the end of the gallery, while negative
229 values scroll toward the start.
231 @return @true if the gallery scrolled at least one pixel in the given
232 direction, @false if it did not scroll.
234 virtual bool ScrollLines(int lines
);
237 Scroll the gallery to ensure that the given item is visible.
239 void EnsureVisible(const wxRibbonGalleryItem
* item
);
243 @class wxRibbonGalleryEvent
246 @category{events,ribbon}
250 class wxRibbonButtonBarEvent
: public wxCommandEvent
256 wxRibbonButtonBarEvent(wxEventType command_type
= wxEVT_NULL
,
258 wxRibbonGallery
* gallery
= NULL
,
259 wxRibbonGalleryItem
* item
= NULL
);
262 Returns the gallery which the event relates to.
264 wxRibbonGallery
* GetGallery();
267 Returns the gallery item which the event relates to, or NULL if it does
268 not relate to an item.
270 wxRibbonGalleryItem
* GetGalleryItem();
273 Sets the gallery relating to this event.
275 void SetGallery(wxRibbonGallery
* gallery
);
278 Sets the gallery item relating to this event.
280 void SetGalleryItem(wxRibbonGalleryItem
* item
);