1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/ribbon/gallery.h
3 // Purpose: Ribbon control which displays a gallery of items to choose from
4 // Author: Peter Cawley
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_RIBBON_GALLERY_H_
12 #define _WX_RIBBON_GALLERY_H_
18 #include "wx/ribbon/art.h"
19 #include "wx/ribbon/control.h"
21 class wxRibbonGalleryItem
;
23 WX_DEFINE_USER_EXPORTED_ARRAY(wxRibbonGalleryItem
*, wxArrayRibbonGalleryItem
, class WXDLLIMPEXP_RIBBON
);
25 class WXDLLIMPEXP_RIBBON wxRibbonGallery
: public wxRibbonControl
30 wxRibbonGallery(wxWindow
* parent
,
31 wxWindowID id
= wxID_ANY
,
32 const wxPoint
& pos
= wxDefaultPosition
,
33 const wxSize
& size
= wxDefaultSize
,
36 virtual ~wxRibbonGallery();
38 bool Create(wxWindow
* parent
,
39 wxWindowID id
= wxID_ANY
,
40 const wxPoint
& pos
= wxDefaultPosition
,
41 const wxSize
& size
= wxDefaultSize
,
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
);
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;
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;
66 bool IsHovered() const;
67 virtual bool IsSizingContinuous() const;
68 virtual bool Realize();
69 virtual bool Layout();
71 virtual bool ScrollLines(int lines
);
72 bool ScrollPixels(int pixels
);
73 void EnsureVisible(const wxRibbonGalleryItem
* item
);
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
);
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
);
88 void OnMouseDClick(wxMouseEvent
& evt
);
89 void OnPaint(wxPaintEvent
& evt
);
90 void OnSize(wxSizeEvent
& evt
);
91 int GetScrollLineSize() const;
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;
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
;
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
;
115 wxRibbonGalleryButtonState m_up_button_state
;
116 wxRibbonGalleryButtonState m_down_button_state
;
117 wxRibbonGalleryButtonState m_extension_button_state
;
121 DECLARE_CLASS(wxRibbonGallery
)
122 DECLARE_EVENT_TABLE()
126 class WXDLLIMPEXP_RIBBON wxRibbonGalleryEvent
: public wxCommandEvent
129 wxRibbonGalleryEvent(wxEventType command_type
= wxEVT_NULL
,
131 wxRibbonGallery
* gallery
= NULL
,
132 wxRibbonGalleryItem
* item
= NULL
)
133 : wxCommandEvent(command_type
, win_id
)
134 , m_gallery(gallery
), m_item(item
)
138 wxRibbonGalleryEvent(const wxRibbonGalleryEvent
& e
) : wxCommandEvent(e
)
140 m_gallery
= e
.m_gallery
;
144 wxEvent
*Clone() const { return new wxRibbonGalleryEvent(*this); }
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
;}
152 wxRibbonGallery
* m_gallery
;
153 wxRibbonGalleryItem
* m_item
;
157 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonGalleryEvent
)
163 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED
, wxRibbonGalleryEvent
);
164 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONGALLERY_SELECTED
, wxRibbonGalleryEvent
);
165 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONGALLERY_CLICKED
, wxRibbonGalleryEvent
);
167 typedef void (wxEvtHandler::*wxRibbonGalleryEventFunction
)(wxRibbonGalleryEvent
&);
169 #define wxRibbonGalleryEventHandler(func) \
170 wxEVENT_HANDLER_CAST(wxRibbonGalleryEventFunction, func)
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))
176 #define EVT_RIBBONGALLERY_CLICKED(winid, fn) \
177 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONGALLERY_CLICKED, winid, wxRibbonGalleryEventHandler(fn))
180 // wxpython/swig event work
181 %constant wxEventType wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED
;
182 %constant wxEventType wxEVT_COMMAND_RIBBONGALLERY_SELECTED
;
185 EVT_RIBBONGALLERY_HOVER_CHANGED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED
, 1 )
186 EVT_RIBBONGALLERY_SELECTED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONGALLERY_SELECTED
, 1 )
190 #endif // wxUSE_RIBBON
192 #endif // _WX_RIBBON_GALLERY_H_