1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/ribbon/gallery.h
3 // Purpose: Ribbon control which displays a gallery of items to choose from
4 // Author: Peter Cawley
7 // Copyright: (C) Peter Cawley
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_RIBBON_GALLERY_H_
11 #define _WX_RIBBON_GALLERY_H_
17 #include "wx/ribbon/art.h"
18 #include "wx/ribbon/control.h"
20 class wxRibbonGalleryItem
;
22 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxRibbonGalleryItem
*, wxArrayRibbonGalleryItem
, class WXDLLIMPEXP_RIBBON
);
24 class WXDLLIMPEXP_RIBBON wxRibbonGallery
: public wxRibbonControl
29 wxRibbonGallery(wxWindow
* parent
,
30 wxWindowID id
= wxID_ANY
,
31 const wxPoint
& pos
= wxDefaultPosition
,
32 const wxSize
& size
= wxDefaultSize
,
35 virtual ~wxRibbonGallery();
37 bool Create(wxWindow
* parent
,
38 wxWindowID id
= wxID_ANY
,
39 const wxPoint
& pos
= wxDefaultPosition
,
40 const wxSize
& size
= wxDefaultSize
,
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
);
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;
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;
65 bool IsHovered() const;
66 virtual bool IsSizingContinuous() const;
67 virtual bool Realize();
68 virtual bool Layout();
70 virtual bool ScrollLines(int lines
);
71 bool ScrollPixels(int pixels
);
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 OnMouseDClick(wxMouseEvent
& evt
);
88 void OnPaint(wxPaintEvent
& evt
);
89 void OnSize(wxSizeEvent
& evt
);
90 int GetScrollLineSize() const;
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;
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
;
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
;
114 wxRibbonGalleryButtonState m_up_button_state
;
115 wxRibbonGalleryButtonState m_down_button_state
;
116 wxRibbonGalleryButtonState m_extension_button_state
;
120 DECLARE_CLASS(wxRibbonGallery
)
121 DECLARE_EVENT_TABLE()
125 class WXDLLIMPEXP_RIBBON wxRibbonGalleryEvent
: public wxCommandEvent
128 wxRibbonGalleryEvent(wxEventType command_type
= wxEVT_NULL
,
130 wxRibbonGallery
* gallery
= NULL
,
131 wxRibbonGalleryItem
* item
= NULL
)
132 : wxCommandEvent(command_type
, win_id
)
133 , m_gallery(gallery
), m_item(item
)
137 wxRibbonGalleryEvent(const wxRibbonGalleryEvent
& e
) : wxCommandEvent(e
)
139 m_gallery
= e
.m_gallery
;
143 wxEvent
*Clone() const { return new wxRibbonGalleryEvent(*this); }
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
;}
151 wxRibbonGallery
* m_gallery
;
152 wxRibbonGalleryItem
* m_item
;
156 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonGalleryEvent
)
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
);
166 typedef void (wxEvtHandler::*wxRibbonGalleryEventFunction
)(wxRibbonGalleryEvent
&);
168 #define wxRibbonGalleryEventHandler(func) \
169 wxEVENT_HANDLER_CAST(wxRibbonGalleryEventFunction, func)
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))
179 // wxpython/swig event work
180 %constant wxEventType wxEVT_RIBBONGALLERY_HOVER_CHANGED
;
181 %constant wxEventType wxEVT_RIBBONGALLERY_SELECTED
;
184 EVT_RIBBONGALLERY_HOVER_CHANGED
= wx
.PyEventBinder( wxEVT_RIBBONGALLERY_HOVER_CHANGED
, 1 )
185 EVT_RIBBONGALLERY_SELECTED
= wx
.PyEventBinder( wxEVT_RIBBONGALLERY_SELECTED
, 1 )
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
194 #endif // wxUSE_RIBBON
196 #endif // _WX_RIBBON_GALLERY_H_