]> git.saurik.com Git - wxWidgets.git/blame - include/wx/ribbon/gallery.h
Use wxWebKitCtrlNameStr to adhere to the convention used by other wx classes.
[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
23WX_DEFINE_USER_EXPORTED_ARRAY(wxRibbonGalleryItem*, wxArrayRibbonGalleryItem, class WXDLLIMPEXP_RIBBON);
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);
72 void EnsureVisible(const wxRibbonGalleryItem* item);
73
74protected:
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 OnPaint(wxPaintEvent& evt);
88 void OnSize(wxSizeEvent& evt);
89
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;
95
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;
102 wxSize m_best_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;
110 int m_scroll_amount;
111 int m_scroll_limit;
112 wxRibbonGalleryButtonState m_up_button_state;
113 wxRibbonGalleryButtonState m_down_button_state;
114 wxRibbonGalleryButtonState m_extension_button_state;
115 bool m_hovered;
116
117#ifndef SWIG
118 DECLARE_CLASS(wxRibbonGallery)
119 DECLARE_EVENT_TABLE()
120#endif
121};
122
123class WXDLLIMPEXP_RIBBON wxRibbonGalleryEvent : public wxCommandEvent
124{
125public:
126 wxRibbonGalleryEvent(wxEventType command_type = wxEVT_NULL,
127 int win_id = 0,
128 wxRibbonGallery* gallery = NULL,
129 wxRibbonGalleryItem* item = NULL)
130 : wxCommandEvent(command_type, win_id)
131 , m_gallery(gallery), m_item(item)
132 {
133 }
134#ifndef SWIG
135 wxRibbonGalleryEvent(const wxRibbonGalleryEvent& e) : wxCommandEvent(e)
136 {
137 m_gallery = e.m_gallery;
138 m_item = e.m_item;
139 }
140#endif
141 wxEvent *Clone() const { return new wxRibbonGalleryEvent(*this); }
142
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;}
147
148protected:
149 wxRibbonGallery* m_gallery;
150 wxRibbonGalleryItem* m_item;
151
152#ifndef SWIG
153private:
154 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonGalleryEvent)
155#endif
156};
157
158#ifndef SWIG
159
160wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, wxRibbonGalleryEvent);
161wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONGALLERY_SELECTED, wxRibbonGalleryEvent);
162
163typedef void (wxEvtHandler::*wxRibbonGalleryEventFunction)(wxRibbonGalleryEvent&);
164
165#define wxRibbonGalleryEventHandler(func) \
166 wxEVENT_HANDLER_CAST(wxRibbonGalleryEventFunction, func)
167
168#define EVT_RIBBONGALLERY_HOVER_CHANGED(winid, fn) \
169 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, winid, wxRibbonGalleryEventHandler(fn))
170#define EVT_RIBBONGALLERY_SELECTED(winid, fn) \
171 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONGALLERY_SELECTED, winid, wxRibbonGalleryEventHandler(fn))
172#else
173
174// wxpython/swig event work
175%constant wxEventType wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED;
176%constant wxEventType wxEVT_COMMAND_RIBBONGALLERY_SELECTED;
177
178%pythoncode {
179 EVT_RIBBONGALLERY_HOVER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, 1 )
180 EVT_RIBBONGALLERY_SELECTED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONGALLERY_SELECTED, 1 )
181}
182#endif
183
184#endif // wxUSE_RIBBON
185
186#endif // _WX_RIBBON_GALLERY_H_