2009-09-16 08:06:02 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/ribbon/panel.h
|
|
|
|
// Purpose: Ribbon-style container for a group of related tools / controls
|
|
|
|
// Author: Peter Cawley
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2009-05-25
|
|
|
|
// Copyright: (C) Peter Cawley
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _WX_RIBBON_PANEL_H_
|
|
|
|
#define _WX_RIBBON_PANEL_H_
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_RIBBON
|
|
|
|
|
|
|
|
#include "wx/bitmap.h"
|
|
|
|
#include "wx/ribbon/control.h"
|
|
|
|
|
|
|
|
enum wxRibbonPanelOption
|
|
|
|
{
|
2012-03-09 10:26:37 -05:00
|
|
|
wxRIBBON_PANEL_NO_AUTO_MINIMISE = 1 << 0,
|
|
|
|
wxRIBBON_PANEL_EXT_BUTTON = 1 << 3,
|
|
|
|
wxRIBBON_PANEL_MINIMISE_BUTTON = 1 << 4,
|
|
|
|
wxRIBBON_PANEL_STRETCH = 1 << 5,
|
2012-03-12 15:30:10 -04:00
|
|
|
wxRIBBON_PANEL_FLEXIBLE = 1 << 6,
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2012-03-09 10:26:37 -05:00
|
|
|
wxRIBBON_PANEL_DEFAULT_STYLE = 0
|
2009-09-16 08:06:02 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_RIBBON wxRibbonPanel : public wxRibbonControl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxRibbonPanel();
|
|
|
|
|
|
|
|
wxRibbonPanel(wxWindow* parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxString& label = wxEmptyString,
|
|
|
|
const wxBitmap& minimised_icon = wxNullBitmap,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxRIBBON_PANEL_DEFAULT_STYLE);
|
|
|
|
|
|
|
|
virtual ~wxRibbonPanel();
|
|
|
|
|
|
|
|
bool Create(wxWindow* parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxString& label = wxEmptyString,
|
|
|
|
const wxBitmap& icon = wxNullBitmap,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxRIBBON_PANEL_DEFAULT_STYLE);
|
|
|
|
|
|
|
|
wxBitmap& GetMinimisedIcon() {return m_minimised_icon;}
|
|
|
|
const wxBitmap& GetMinimisedIcon() const {return m_minimised_icon;}
|
|
|
|
bool IsMinimised() const;
|
|
|
|
bool IsMinimised(wxSize at_size) const;
|
|
|
|
bool IsHovered() const;
|
2012-06-03 15:17:09 -04:00
|
|
|
bool IsExtButtonHovered() const;
|
2009-09-16 08:06:02 -04:00
|
|
|
bool CanAutoMinimise() const;
|
|
|
|
|
|
|
|
bool ShowExpanded();
|
|
|
|
bool HideExpanded();
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
void SetArtProvider(wxRibbonArtProvider* art) wxOVERRIDE;
|
2009-09-16 08:06:02 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool Realize() wxOVERRIDE;
|
|
|
|
virtual bool Layout() wxOVERRIDE;
|
|
|
|
virtual wxSize GetMinSize() const wxOVERRIDE;
|
2009-09-16 08:06:02 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool IsSizingContinuous() const wxOVERRIDE;
|
2009-09-16 08:06:02 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void AddChild(wxWindowBase *child) wxOVERRIDE;
|
|
|
|
virtual void RemoveChild(wxWindowBase *child) wxOVERRIDE;
|
2009-09-16 08:06:02 -04:00
|
|
|
|
2012-06-03 15:17:09 -04:00
|
|
|
virtual bool HasExtButton() const;
|
|
|
|
|
2009-09-16 08:06:02 -04:00
|
|
|
wxRibbonPanel* GetExpandedDummy();
|
|
|
|
wxRibbonPanel* GetExpandedPanel();
|
|
|
|
|
2012-03-12 15:30:10 -04:00
|
|
|
// Finds the best width and height given the parent's width and height
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxSize GetBestSizeForParentSize(const wxSize& parentSize) const wxOVERRIDE;
|
2012-03-12 15:30:10 -04:00
|
|
|
|
|
|
|
long GetFlags() { return m_flags; }
|
|
|
|
|
2012-09-15 19:19:59 -04:00
|
|
|
void HideIfExpanded();
|
|
|
|
|
2009-09-16 08:06:02 -04:00
|
|
|
protected:
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
2010-10-20 13:49:42 -04:00
|
|
|
virtual wxSize GetPanelSizerBestSize() const;
|
|
|
|
wxSize GetPanelSizerMinSize() const;
|
2014-03-29 20:02:23 -04:00
|
|
|
wxBorder GetDefaultBorder() const wxOVERRIDE { return wxBORDER_NONE; }
|
2009-09-16 08:06:02 -04:00
|
|
|
wxSize GetMinNotMinimisedSize() const;
|
|
|
|
|
|
|
|
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
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) wxOVERRIDE;
|
2009-09-16 08:06:02 -04:00
|
|
|
void OnSize(wxSizeEvent& evt);
|
|
|
|
void OnEraseBackground(wxEraseEvent& evt);
|
|
|
|
void OnPaint(wxPaintEvent& evt);
|
|
|
|
void OnMouseEnter(wxMouseEvent& evt);
|
|
|
|
void OnMouseEnterChild(wxMouseEvent& evt);
|
|
|
|
void OnMouseLeave(wxMouseEvent& evt);
|
|
|
|
void OnMouseLeaveChild(wxMouseEvent& evt);
|
|
|
|
void OnMouseClick(wxMouseEvent& evt);
|
2012-06-03 15:17:09 -04:00
|
|
|
void OnMotion(wxMouseEvent& evt);
|
2009-09-16 08:06:02 -04:00
|
|
|
void OnKillFocus(wxFocusEvent& evt);
|
|
|
|
void OnChildKillFocus(wxFocusEvent& evt);
|
|
|
|
|
|
|
|
void TestPositionForHover(const wxPoint& pos);
|
|
|
|
bool ShouldSendEventToDummy(wxEvent& evt);
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool TryAfter(wxEvent& evt) wxOVERRIDE;
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
void CommonInit(const wxString& label, const wxBitmap& icon, long style);
|
|
|
|
static wxRect GetExpandedPosition(wxRect panel,
|
|
|
|
wxSize expanded_size,
|
|
|
|
wxDirection direction);
|
|
|
|
|
|
|
|
wxBitmap m_minimised_icon;
|
|
|
|
wxBitmap m_minimised_icon_resized;
|
|
|
|
wxSize m_smallest_unminimised_size;
|
|
|
|
wxSize m_minimised_size;
|
|
|
|
wxDirection m_preferred_expand_direction;
|
|
|
|
wxRibbonPanel* m_expanded_dummy;
|
|
|
|
wxRibbonPanel* m_expanded_panel;
|
|
|
|
wxWindow* m_child_with_focus;
|
|
|
|
long m_flags;
|
|
|
|
bool m_minimised;
|
|
|
|
bool m_hovered;
|
2012-06-03 15:17:09 -04:00
|
|
|
bool m_ext_button_hovered;
|
|
|
|
wxRect m_ext_button_rect;
|
2009-09-16 08:06:02 -04:00
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
DECLARE_CLASS(wxRibbonPanel)
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2012-06-03 15:17:09 -04:00
|
|
|
|
|
|
|
class WXDLLIMPEXP_RIBBON wxRibbonPanelEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxRibbonPanelEvent(wxEventType command_type = wxEVT_NULL,
|
|
|
|
int win_id = 0,
|
|
|
|
wxRibbonPanel* panel = NULL)
|
|
|
|
: wxCommandEvent(command_type, win_id)
|
|
|
|
, m_panel(panel)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#ifndef SWIG
|
|
|
|
wxRibbonPanelEvent(const wxRibbonPanelEvent& e) : wxCommandEvent(e)
|
|
|
|
{
|
|
|
|
m_panel = e.m_panel;
|
|
|
|
}
|
|
|
|
#endif
|
2014-03-29 20:02:23 -04:00
|
|
|
wxEvent *Clone() const wxOVERRIDE { return new wxRibbonPanelEvent(*this); }
|
2012-06-03 15:17:09 -04:00
|
|
|
|
|
|
|
wxRibbonPanel* GetPanel() {return m_panel;}
|
|
|
|
void SetPanel(wxRibbonPanel* panel) {m_panel = panel;}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wxRibbonPanel* m_panel;
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonPanelEvent)
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED, wxRibbonPanelEvent);
|
2012-06-03 15:17:09 -04:00
|
|
|
|
|
|
|
typedef void (wxEvtHandler::*wxRibbonPanelEventFunction)(wxRibbonPanelEvent&);
|
|
|
|
|
|
|
|
#define wxRibbonPanelEventHandler(func) \
|
|
|
|
wxEVENT_HANDLER_CAST(wxRibbonPanelEventFunction, func)
|
|
|
|
|
|
|
|
#define EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED(winid, fn) \
|
2013-04-25 06:11:03 -04:00
|
|
|
wx__DECLARE_EVT1(wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED, winid, wxRibbonPanelEventHandler(fn))
|
2012-06-03 15:17:09 -04:00
|
|
|
#else
|
|
|
|
|
|
|
|
// wxpython/swig event work
|
2013-04-25 06:11:03 -04:00
|
|
|
%constant wxEventType wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED;
|
2012-06-03 15:17:09 -04:00
|
|
|
|
|
|
|
%pythoncode {
|
2013-04-25 06:11:03 -04:00
|
|
|
EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED = wx.PyEventBinder( wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED, 1 )
|
2012-06-03 15:17:09 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
// old wxEVT_COMMAND_* constants
|
|
|
|
#define wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED
|
|
|
|
|
2009-09-16 08:06:02 -04:00
|
|
|
#endif // wxUSE_RIBBON
|
|
|
|
|
|
|
|
#endif // _WX_RIBBON_PANEL_H_
|