]> git.saurik.com Git - wxWidgets.git/blame - include/wx/ribbon/gallery.h
synchronize GTK2 minimum version in docs
[wxWidgets.git] / include / wx / ribbon / gallery.h
CommitLineData
3c3ead1d
PC
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// RCS-ID: $Id$
8// Copyright: (C) Peter Cawley
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11#ifndef _WX_RIBBON_GALLERY_H_
12#define _WX_RIBBON_GALLERY_H_
13
14#include "wx/defs.h"
15
16#if wxUSE_RIBBON
17
18#include "wx/ribbon/art.h"
19#include "wx/ribbon/control.h"
20
21class wxRibbonGalleryItem;
22
c155b9b5 23WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxRibbonGalleryItem*, wxArrayRibbonGalleryItem, class WXDLLIMPEXP_RIBBON);
3c3ead1d
PC
24
25class WXDLLIMPEXP_RIBBON wxRibbonGallery : public wxRibbonControl
26{
27public:
28 wxRibbonGallery();
29
30 wxRibbonGallery(wxWindow* parent,
31 wxWindowID id = wxID_ANY,
32 const wxPoint& pos = wxDefaultPosition,
33 const wxSize& size = wxDefaultSize,
34 long style = 0);
35
36 virtual ~wxRibbonGallery();
37
38 bool Create(wxWindow* parent,
39 wxWindowID id = wxID_ANY,
40 const wxPoint& pos = wxDefaultPosition,
41 const wxSize& size = wxDefaultSize,
42 long style = 0);
43
44 void Clear();
45
46 bool IsEmpty() const;
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);
52
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;
57
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;
65
66 bool IsHovered() const;
67 virtual bool IsSizingContinuous() const;
68 virtual bool Realize();
69 virtual bool Layout();
70
71 virtual bool ScrollLines(int lines);
32eb5603 72 bool ScrollPixels(int pixels);
3c3ead1d
PC
73 void EnsureVisible(const wxRibbonGalleryItem* item);
74
75protected:
76 wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
77 void CommonInit(long style);
78 void CalculateMinSize();
79 bool TestButtonHover(const wxRect& rect, wxPoint pos,
80 wxRibbonGalleryButtonState* state);
81
82 void OnEraseBackground(wxEraseEvent& evt);
83 void OnMouseEnter(wxMouseEvent& evt);
84 void OnMouseMove(wxMouseEvent& evt);
85 void OnMouseLeave(wxMouseEvent& evt);
86 void OnMouseDown(wxMouseEvent& evt);
87 void OnMouseUp(wxMouseEvent& evt);
32eb5603 88 void OnMouseDClick(wxMouseEvent& evt);
3c3ead1d
PC
89 void OnPaint(wxPaintEvent& evt);
90 void OnSize(wxSizeEvent& evt);
32eb5603 91 int GetScrollLineSize() const;
3c3ead1d
PC
92
93 virtual wxSize DoGetBestSize() const;
94 virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
95 wxSize relative_to) const;
96 virtual wxSize DoGetNextLargerSize(wxOrientation direction,
97 wxSize relative_to) const;
98
99 wxArrayRibbonGalleryItem m_items;
100 wxRibbonGalleryItem* m_selected_item;
101 wxRibbonGalleryItem* m_hovered_item;
102 wxRibbonGalleryItem* m_active_item;
103 wxSize m_bitmap_size;
104 wxSize m_bitmap_padded_size;
105 wxSize m_best_size;
106 wxRect m_client_rect;
107 wxRect m_scroll_up_button_rect;
108 wxRect m_scroll_down_button_rect;
109 wxRect m_extension_button_rect;
110 const wxRect* m_mouse_active_rect;
111 int m_item_separation_x;
112 int m_item_separation_y;
113 int m_scroll_amount;
114 int m_scroll_limit;
115 wxRibbonGalleryButtonState m_up_button_state;
116 wxRibbonGalleryButtonState m_down_button_state;
117 wxRibbonGalleryButtonState m_extension_button_state;
118 bool m_hovered;
119
120#ifndef SWIG
121 DECLARE_CLASS(wxRibbonGallery)
122 DECLARE_EVENT_TABLE()
123#endif
124};
125
126class WXDLLIMPEXP_RIBBON wxRibbonGalleryEvent : public wxCommandEvent
127{
128public:
129 wxRibbonGalleryEvent(wxEventType command_type = wxEVT_NULL,
130 int win_id = 0,
131 wxRibbonGallery* gallery = NULL,
132 wxRibbonGalleryItem* item = NULL)
133 : wxCommandEvent(command_type, win_id)
134 , m_gallery(gallery), m_item(item)
135 {
136 }
137#ifndef SWIG
138 wxRibbonGalleryEvent(const wxRibbonGalleryEvent& e) : wxCommandEvent(e)
139 {
140 m_gallery = e.m_gallery;
141 m_item = e.m_item;
142 }
143#endif
144 wxEvent *Clone() const { return new wxRibbonGalleryEvent(*this); }
145
146 wxRibbonGallery* GetGallery() {return m_gallery;}
147 wxRibbonGalleryItem* GetGalleryItem() {return m_item;}
148 void SetGallery(wxRibbonGallery* gallery) {m_gallery = gallery;}
149 void SetGalleryItem(wxRibbonGalleryItem* item) {m_item = item;}
150
151protected:
152 wxRibbonGallery* m_gallery;
153 wxRibbonGalleryItem* m_item;
154
155#ifndef SWIG
156private:
157 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonGalleryEvent)
158#endif
159};
160
161#ifndef SWIG
162
163wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, wxRibbonGalleryEvent);
164wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONGALLERY_SELECTED, wxRibbonGalleryEvent);
1aff4201 165wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONGALLERY_CLICKED, wxRibbonGalleryEvent);
3c3ead1d
PC
166
167typedef void (wxEvtHandler::*wxRibbonGalleryEventFunction)(wxRibbonGalleryEvent&);
168
169#define wxRibbonGalleryEventHandler(func) \
170 wxEVENT_HANDLER_CAST(wxRibbonGalleryEventFunction, func)
171
172#define EVT_RIBBONGALLERY_HOVER_CHANGED(winid, fn) \
173 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, winid, wxRibbonGalleryEventHandler(fn))
174#define EVT_RIBBONGALLERY_SELECTED(winid, fn) \
175 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONGALLERY_SELECTED, winid, wxRibbonGalleryEventHandler(fn))
1aff4201
VZ
176#define EVT_RIBBONGALLERY_CLICKED(winid, fn) \
177 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONGALLERY_CLICKED, winid, wxRibbonGalleryEventHandler(fn))
3c3ead1d
PC
178#else
179
180// wxpython/swig event work
181%constant wxEventType wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED;
182%constant wxEventType wxEVT_COMMAND_RIBBONGALLERY_SELECTED;
183
184%pythoncode {
185 EVT_RIBBONGALLERY_HOVER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, 1 )
186 EVT_RIBBONGALLERY_SELECTED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONGALLERY_SELECTED, 1 )
187}
1aff4201 188#endif // SWIG
3c3ead1d
PC
189
190#endif // wxUSE_RIBBON
191
192#endif // _WX_RIBBON_GALLERY_H_