]> git.saurik.com Git - wxWidgets.git/blob - include/wx/ribbon/gallery.h
665c69420dfb0e1f0b9e0f8a64fbb6a025979f28
[wxWidgets.git] / include / wx / ribbon / gallery.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/ribbon/gallery.h
3 // Purpose: Ribbon control which displays a gallery of items to choose from
4 // Author: Peter Cawley
5 // Modified by:
6 // Created: 2009-07-22
7 // Copyright: (C) Peter Cawley
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_RIBBON_GALLERY_H_
11 #define _WX_RIBBON_GALLERY_H_
12
13 #include "wx/defs.h"
14
15 #if wxUSE_RIBBON
16
17 #include "wx/ribbon/art.h"
18 #include "wx/ribbon/control.h"
19
20 class wxRibbonGalleryItem;
21
22 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxRibbonGalleryItem*, wxArrayRibbonGalleryItem, class WXDLLIMPEXP_RIBBON);
23
24 class WXDLLIMPEXP_RIBBON wxRibbonGallery : public wxRibbonControl
25 {
26 public:
27 wxRibbonGallery();
28
29 wxRibbonGallery(wxWindow* parent,
30 wxWindowID id = wxID_ANY,
31 const wxPoint& pos = wxDefaultPosition,
32 const wxSize& size = wxDefaultSize,
33 long style = 0);
34
35 virtual ~wxRibbonGallery();
36
37 bool Create(wxWindow* parent,
38 wxWindowID id = wxID_ANY,
39 const wxPoint& pos = wxDefaultPosition,
40 const wxSize& size = wxDefaultSize,
41 long style = 0);
42
43 void Clear();
44
45 bool IsEmpty() const;
46 unsigned int GetCount() const;
47 wxRibbonGalleryItem* GetItem(unsigned int n);
48 wxRibbonGalleryItem* Append(const wxBitmap& bitmap, int id);
49 wxRibbonGalleryItem* Append(const wxBitmap& bitmap, int id, void* clientData);
50 wxRibbonGalleryItem* Append(const wxBitmap& bitmap, int id, wxClientData* clientData);
51
52 void SetItemClientObject(wxRibbonGalleryItem* item, wxClientData* data);
53 wxClientData* GetItemClientObject(const wxRibbonGalleryItem* item) const;
54 void SetItemClientData(wxRibbonGalleryItem* item, void* data);
55 void* GetItemClientData(const wxRibbonGalleryItem* item) const;
56
57 void SetSelection(wxRibbonGalleryItem* item);
58 wxRibbonGalleryItem* GetSelection() const;
59 wxRibbonGalleryItem* GetHoveredItem() const;
60 wxRibbonGalleryItem* GetActiveItem() const;
61 wxRibbonGalleryButtonState GetUpButtonState() const;
62 wxRibbonGalleryButtonState GetDownButtonState() const;
63 wxRibbonGalleryButtonState GetExtensionButtonState() const;
64
65 bool IsHovered() const;
66 virtual bool IsSizingContinuous() const;
67 virtual bool Realize();
68 virtual bool Layout();
69
70 virtual bool ScrollLines(int lines);
71 bool ScrollPixels(int pixels);
72 void EnsureVisible(const wxRibbonGalleryItem* item);
73
74 protected:
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);
80
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 OnMouseDClick(wxMouseEvent& evt);
88 void OnPaint(wxPaintEvent& evt);
89 void OnSize(wxSizeEvent& evt);
90 int GetScrollLineSize() const;
91
92 virtual wxSize DoGetBestSize() const;
93 virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
94 wxSize relative_to) const;
95 virtual wxSize DoGetNextLargerSize(wxOrientation direction,
96 wxSize relative_to) const;
97
98 wxArrayRibbonGalleryItem m_items;
99 wxRibbonGalleryItem* m_selected_item;
100 wxRibbonGalleryItem* m_hovered_item;
101 wxRibbonGalleryItem* m_active_item;
102 wxSize m_bitmap_size;
103 wxSize m_bitmap_padded_size;
104 wxSize m_best_size;
105 wxRect m_client_rect;
106 wxRect m_scroll_up_button_rect;
107 wxRect m_scroll_down_button_rect;
108 wxRect m_extension_button_rect;
109 const wxRect* m_mouse_active_rect;
110 int m_item_separation_x;
111 int m_item_separation_y;
112 int m_scroll_amount;
113 int m_scroll_limit;
114 wxRibbonGalleryButtonState m_up_button_state;
115 wxRibbonGalleryButtonState m_down_button_state;
116 wxRibbonGalleryButtonState m_extension_button_state;
117 bool m_hovered;
118
119 #ifndef SWIG
120 DECLARE_CLASS(wxRibbonGallery)
121 DECLARE_EVENT_TABLE()
122 #endif
123 };
124
125 class WXDLLIMPEXP_RIBBON wxRibbonGalleryEvent : public wxCommandEvent
126 {
127 public:
128 wxRibbonGalleryEvent(wxEventType command_type = wxEVT_NULL,
129 int win_id = 0,
130 wxRibbonGallery* gallery = NULL,
131 wxRibbonGalleryItem* item = NULL)
132 : wxCommandEvent(command_type, win_id)
133 , m_gallery(gallery), m_item(item)
134 {
135 }
136 #ifndef SWIG
137 wxRibbonGalleryEvent(const wxRibbonGalleryEvent& e) : wxCommandEvent(e)
138 {
139 m_gallery = e.m_gallery;
140 m_item = e.m_item;
141 }
142 #endif
143 wxEvent *Clone() const { return new wxRibbonGalleryEvent(*this); }
144
145 wxRibbonGallery* GetGallery() {return m_gallery;}
146 wxRibbonGalleryItem* GetGalleryItem() {return m_item;}
147 void SetGallery(wxRibbonGallery* gallery) {m_gallery = gallery;}
148 void SetGalleryItem(wxRibbonGalleryItem* item) {m_item = item;}
149
150 protected:
151 wxRibbonGallery* m_gallery;
152 wxRibbonGalleryItem* m_item;
153
154 #ifndef SWIG
155 private:
156 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonGalleryEvent)
157 #endif
158 };
159
160 #ifndef SWIG
161
162 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONGALLERY_HOVER_CHANGED, wxRibbonGalleryEvent);
163 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONGALLERY_SELECTED, wxRibbonGalleryEvent);
164 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONGALLERY_CLICKED, wxRibbonGalleryEvent);
165
166 typedef void (wxEvtHandler::*wxRibbonGalleryEventFunction)(wxRibbonGalleryEvent&);
167
168 #define wxRibbonGalleryEventHandler(func) \
169 wxEVENT_HANDLER_CAST(wxRibbonGalleryEventFunction, func)
170
171 #define EVT_RIBBONGALLERY_HOVER_CHANGED(winid, fn) \
172 wx__DECLARE_EVT1(wxEVT_RIBBONGALLERY_HOVER_CHANGED, winid, wxRibbonGalleryEventHandler(fn))
173 #define EVT_RIBBONGALLERY_SELECTED(winid, fn) \
174 wx__DECLARE_EVT1(wxEVT_RIBBONGALLERY_SELECTED, winid, wxRibbonGalleryEventHandler(fn))
175 #define EVT_RIBBONGALLERY_CLICKED(winid, fn) \
176 wx__DECLARE_EVT1(wxEVT_RIBBONGALLERY_CLICKED, winid, wxRibbonGalleryEventHandler(fn))
177 #else
178
179 // wxpython/swig event work
180 %constant wxEventType wxEVT_RIBBONGALLERY_HOVER_CHANGED;
181 %constant wxEventType wxEVT_RIBBONGALLERY_SELECTED;
182
183 %pythoncode {
184 EVT_RIBBONGALLERY_HOVER_CHANGED = wx.PyEventBinder( wxEVT_RIBBONGALLERY_HOVER_CHANGED, 1 )
185 EVT_RIBBONGALLERY_SELECTED = wx.PyEventBinder( wxEVT_RIBBONGALLERY_SELECTED, 1 )
186 }
187 #endif // SWIG
188
189 // old wxEVT_COMMAND_* constants
190 #define wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED wxEVT_RIBBONGALLERY_HOVER_CHANGED
191 #define wxEVT_COMMAND_RIBBONGALLERY_SELECTED wxEVT_RIBBONGALLERY_SELECTED
192 #define wxEVT_COMMAND_RIBBONGALLERY_CLICKED wxEVT_RIBBONGALLERY_CLICKED
193
194 #endif // wxUSE_RIBBON
195
196 #endif // _WX_RIBBON_GALLERY_H_