2009-09-16 08:06:02 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/ribbon/gallery.h
|
|
|
|
// Purpose: Ribbon control which displays a gallery of items to choose from
|
|
|
|
// Author: Peter Cawley
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2009-07-22
|
|
|
|
// Copyright: (C) Peter Cawley
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _WX_RIBBON_GALLERY_H_
|
|
|
|
#define _WX_RIBBON_GALLERY_H_
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_RIBBON
|
|
|
|
|
|
|
|
#include "wx/ribbon/art.h"
|
|
|
|
#include "wx/ribbon/control.h"
|
|
|
|
|
|
|
|
class wxRibbonGalleryItem;
|
|
|
|
|
2011-10-27 17:10:51 -04:00
|
|
|
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxRibbonGalleryItem*, wxArrayRibbonGalleryItem, class WXDLLIMPEXP_RIBBON);
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
class WXDLLIMPEXP_RIBBON wxRibbonGallery : public wxRibbonControl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxRibbonGallery();
|
|
|
|
|
|
|
|
wxRibbonGallery(wxWindow* parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0);
|
|
|
|
|
|
|
|
virtual ~wxRibbonGallery();
|
|
|
|
|
|
|
|
bool Create(wxWindow* parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0);
|
|
|
|
|
|
|
|
void Clear();
|
|
|
|
|
|
|
|
bool IsEmpty() const;
|
|
|
|
unsigned int GetCount() const;
|
|
|
|
wxRibbonGalleryItem* GetItem(unsigned int n);
|
|
|
|
wxRibbonGalleryItem* Append(const wxBitmap& bitmap, int id);
|
|
|
|
wxRibbonGalleryItem* Append(const wxBitmap& bitmap, int id, void* clientData);
|
|
|
|
wxRibbonGalleryItem* Append(const wxBitmap& bitmap, int id, wxClientData* clientData);
|
|
|
|
|
|
|
|
void SetItemClientObject(wxRibbonGalleryItem* item, wxClientData* data);
|
|
|
|
wxClientData* GetItemClientObject(const wxRibbonGalleryItem* item) const;
|
|
|
|
void SetItemClientData(wxRibbonGalleryItem* item, void* data);
|
|
|
|
void* GetItemClientData(const wxRibbonGalleryItem* item) const;
|
|
|
|
|
|
|
|
void SetSelection(wxRibbonGalleryItem* item);
|
|
|
|
wxRibbonGalleryItem* GetSelection() const;
|
|
|
|
wxRibbonGalleryItem* GetHoveredItem() const;
|
|
|
|
wxRibbonGalleryItem* GetActiveItem() const;
|
|
|
|
wxRibbonGalleryButtonState GetUpButtonState() const;
|
|
|
|
wxRibbonGalleryButtonState GetDownButtonState() const;
|
|
|
|
wxRibbonGalleryButtonState GetExtensionButtonState() const;
|
|
|
|
|
|
|
|
bool IsHovered() const;
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool IsSizingContinuous() const wxOVERRIDE;
|
|
|
|
virtual bool Realize() wxOVERRIDE;
|
|
|
|
virtual bool Layout() wxOVERRIDE;
|
2009-09-16 08:06:02 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool ScrollLines(int lines) wxOVERRIDE;
|
2010-11-06 19:46:25 -04:00
|
|
|
bool ScrollPixels(int pixels);
|
2009-09-16 08:06:02 -04:00
|
|
|
void EnsureVisible(const wxRibbonGalleryItem* item);
|
|
|
|
|
|
|
|
protected:
|
2014-03-29 20:02:23 -04:00
|
|
|
wxBorder GetDefaultBorder() const wxOVERRIDE { return wxBORDER_NONE; }
|
2009-09-16 08:06:02 -04:00
|
|
|
void CommonInit(long style);
|
|
|
|
void CalculateMinSize();
|
|
|
|
bool TestButtonHover(const wxRect& rect, wxPoint pos,
|
|
|
|
wxRibbonGalleryButtonState* state);
|
|
|
|
|
|
|
|
void OnEraseBackground(wxEraseEvent& evt);
|
|
|
|
void OnMouseEnter(wxMouseEvent& evt);
|
|
|
|
void OnMouseMove(wxMouseEvent& evt);
|
|
|
|
void OnMouseLeave(wxMouseEvent& evt);
|
|
|
|
void OnMouseDown(wxMouseEvent& evt);
|
|
|
|
void OnMouseUp(wxMouseEvent& evt);
|
2010-11-06 19:46:25 -04:00
|
|
|
void OnMouseDClick(wxMouseEvent& evt);
|
2009-09-16 08:06:02 -04:00
|
|
|
void OnPaint(wxPaintEvent& evt);
|
|
|
|
void OnSize(wxSizeEvent& evt);
|
2010-11-06 19:46:25 -04:00
|
|
|
int GetScrollLineSize() const;
|
2009-09-16 08:06:02 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
2009-09-16 08:06:02 -04:00
|
|
|
virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
|
2014-03-29 20:02:23 -04:00
|
|
|
wxSize relative_to) const wxOVERRIDE;
|
2009-09-16 08:06:02 -04:00
|
|
|
virtual wxSize DoGetNextLargerSize(wxOrientation direction,
|
2014-03-29 20:02:23 -04:00
|
|
|
wxSize relative_to) const wxOVERRIDE;
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
wxArrayRibbonGalleryItem m_items;
|
|
|
|
wxRibbonGalleryItem* m_selected_item;
|
|
|
|
wxRibbonGalleryItem* m_hovered_item;
|
|
|
|
wxRibbonGalleryItem* m_active_item;
|
|
|
|
wxSize m_bitmap_size;
|
|
|
|
wxSize m_bitmap_padded_size;
|
|
|
|
wxSize m_best_size;
|
|
|
|
wxRect m_client_rect;
|
|
|
|
wxRect m_scroll_up_button_rect;
|
|
|
|
wxRect m_scroll_down_button_rect;
|
|
|
|
wxRect m_extension_button_rect;
|
|
|
|
const wxRect* m_mouse_active_rect;
|
|
|
|
int m_item_separation_x;
|
|
|
|
int m_item_separation_y;
|
|
|
|
int m_scroll_amount;
|
|
|
|
int m_scroll_limit;
|
|
|
|
wxRibbonGalleryButtonState m_up_button_state;
|
|
|
|
wxRibbonGalleryButtonState m_down_button_state;
|
|
|
|
wxRibbonGalleryButtonState m_extension_button_state;
|
|
|
|
bool m_hovered;
|
|
|
|
|
|
|
|
#ifndef SWIG
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_CLASS(wxRibbonGallery);
|
|
|
|
wxDECLARE_EVENT_TABLE();
|
2009-09-16 08:06:02 -04:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_RIBBON wxRibbonGalleryEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxRibbonGalleryEvent(wxEventType command_type = wxEVT_NULL,
|
|
|
|
int win_id = 0,
|
|
|
|
wxRibbonGallery* gallery = NULL,
|
|
|
|
wxRibbonGalleryItem* item = NULL)
|
|
|
|
: wxCommandEvent(command_type, win_id)
|
|
|
|
, m_gallery(gallery), m_item(item)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#ifndef SWIG
|
|
|
|
wxRibbonGalleryEvent(const wxRibbonGalleryEvent& e) : wxCommandEvent(e)
|
|
|
|
{
|
|
|
|
m_gallery = e.m_gallery;
|
|
|
|
m_item = e.m_item;
|
|
|
|
}
|
|
|
|
#endif
|
2014-03-29 20:02:23 -04:00
|
|
|
wxEvent *Clone() const wxOVERRIDE { return new wxRibbonGalleryEvent(*this); }
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
wxRibbonGallery* GetGallery() {return m_gallery;}
|
|
|
|
wxRibbonGalleryItem* GetGalleryItem() {return m_item;}
|
|
|
|
void SetGallery(wxRibbonGallery* gallery) {m_gallery = gallery;}
|
|
|
|
void SetGalleryItem(wxRibbonGalleryItem* item) {m_item = item;}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wxRibbonGallery* m_gallery;
|
|
|
|
wxRibbonGalleryItem* m_item;
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
private:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonGalleryEvent);
|
2009-09-16 08:06:02 -04:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONGALLERY_HOVER_CHANGED, wxRibbonGalleryEvent);
|
|
|
|
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONGALLERY_SELECTED, wxRibbonGalleryEvent);
|
|
|
|
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONGALLERY_CLICKED, wxRibbonGalleryEvent);
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
typedef void (wxEvtHandler::*wxRibbonGalleryEventFunction)(wxRibbonGalleryEvent&);
|
|
|
|
|
|
|
|
#define wxRibbonGalleryEventHandler(func) \
|
|
|
|
wxEVENT_HANDLER_CAST(wxRibbonGalleryEventFunction, func)
|
|
|
|
|
|
|
|
#define EVT_RIBBONGALLERY_HOVER_CHANGED(winid, fn) \
|
2013-04-25 06:11:03 -04:00
|
|
|
wx__DECLARE_EVT1(wxEVT_RIBBONGALLERY_HOVER_CHANGED, winid, wxRibbonGalleryEventHandler(fn))
|
2009-09-16 08:06:02 -04:00
|
|
|
#define EVT_RIBBONGALLERY_SELECTED(winid, fn) \
|
2013-04-25 06:11:03 -04:00
|
|
|
wx__DECLARE_EVT1(wxEVT_RIBBONGALLERY_SELECTED, winid, wxRibbonGalleryEventHandler(fn))
|
2010-07-24 08:27:25 -04:00
|
|
|
#define EVT_RIBBONGALLERY_CLICKED(winid, fn) \
|
2013-04-25 06:11:03 -04:00
|
|
|
wx__DECLARE_EVT1(wxEVT_RIBBONGALLERY_CLICKED, winid, wxRibbonGalleryEventHandler(fn))
|
2009-09-16 08:06:02 -04:00
|
|
|
#else
|
|
|
|
|
|
|
|
// wxpython/swig event work
|
2013-04-25 06:11:03 -04:00
|
|
|
%constant wxEventType wxEVT_RIBBONGALLERY_HOVER_CHANGED;
|
|
|
|
%constant wxEventType wxEVT_RIBBONGALLERY_SELECTED;
|
2016-06-21 17:07:56 -04:00
|
|
|
%constant wxEventType wxEVT_RIBBONGALLERY_CLICKED;
|
|
|
|
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
%pythoncode {
|
2013-04-25 06:11:03 -04:00
|
|
|
EVT_RIBBONGALLERY_HOVER_CHANGED = wx.PyEventBinder( wxEVT_RIBBONGALLERY_HOVER_CHANGED, 1 )
|
|
|
|
EVT_RIBBONGALLERY_SELECTED = wx.PyEventBinder( wxEVT_RIBBONGALLERY_SELECTED, 1 )
|
2016-06-21 17:07:56 -04:00
|
|
|
EVT_RIBBONGALLERY_CLICKED = wx.PyEventBinder( wxEVT_RIBBONGALLERY_CLICKED, 1 )
|
2009-09-16 08:06:02 -04:00
|
|
|
}
|
2010-07-24 08:27:25 -04:00
|
|
|
#endif // SWIG
|
2009-09-16 08:06:02 -04:00
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
// old wxEVT_COMMAND_* constants
|
|
|
|
#define wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED wxEVT_RIBBONGALLERY_HOVER_CHANGED
|
|
|
|
#define wxEVT_COMMAND_RIBBONGALLERY_SELECTED wxEVT_RIBBONGALLERY_SELECTED
|
|
|
|
#define wxEVT_COMMAND_RIBBONGALLERY_CLICKED wxEVT_RIBBONGALLERY_CLICKED
|
|
|
|
|
2009-09-16 08:06:02 -04:00
|
|
|
#endif // wxUSE_RIBBON
|
|
|
|
|
|
|
|
#endif // _WX_RIBBON_GALLERY_H_
|