Add help button support to wxRibbonBar.

Optionally show standard "Help" question mark button in the ribbon top right
corner and generate the appropriate event for it.

Closes #14576.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72495 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-09-15 23:19:59 +00:00
parent 66815259f5
commit 42d7394119
13 changed files with 472 additions and 42 deletions

View File

@@ -21,6 +21,7 @@
#include "wx/font.h"
#include "wx/pen.h"
#include "wx/bitmap.h"
#include "wx/ribbon/bar.h"
class WXDLLIMPEXP_FWD_CORE wxDC;
class WXDLLIMPEXP_FWD_CORE wxWindow;
@@ -306,7 +307,12 @@ public:
wxDC& dc,
wxRibbonBar* wnd,
const wxRect& rect,
bool upBitmap) = 0;
wxRibbonDisplayMode mode) = 0;
virtual void DrawHelpButton(
wxDC& dc,
wxRibbonBar* wnd,
const wxRect& rect) = 0;
virtual void GetBarTabWidth(
wxDC& dc,
@@ -392,9 +398,9 @@ public:
bool is_last,
wxRect* dropdown_region) = 0;
virtual wxRect GetBarToggleButtonArea(wxDC& dc,
const wxRibbonBar* wnd,
wxRect rect)= 0;
virtual wxRect GetBarToggleButtonArea(const wxRect& rect)= 0;
virtual wxRect GetRibbonHelpButtonArea(const wxRect& rect) = 0;
};
class WXDLLIMPEXP_RIBBON wxRibbonMSWArtProvider : public wxRibbonArtProvider
@@ -510,7 +516,11 @@ public:
wxDC& dc,
wxRibbonBar* wnd,
const wxRect& rect,
bool upBitmap);
wxRibbonDisplayMode mode);
void DrawHelpButton(wxDC& dc,
wxRibbonBar* wnd,
const wxRect& rect);
void GetBarTabWidth(
wxDC& dc,
@@ -591,9 +601,9 @@ public:
bool is_last,
wxRect* dropdown_region);
wxRect GetBarToggleButtonArea(wxDC& dc,
const wxRibbonBar* wnd,
wxRect rect);
wxRect GetBarToggleButtonArea(const wxRect& rect);
wxRect GetRibbonHelpButtonArea(const wxRect& rect);
protected:
void ReallyDrawTabSeparator(wxWindow* wnd, const wxRect& rect, double visibility);
@@ -632,6 +642,8 @@ protected:
wxBitmap m_panel_extension_bitmap[2];
wxBitmap m_ribbon_toggle_up_bitmap[2];
wxBitmap m_ribbon_toggle_down_bitmap[2];
wxBitmap m_ribbon_toggle_pin_bitmap[2];
wxBitmap m_ribbon_bar_help_button_bitmap[2];
wxColour m_primary_scheme_colour;
wxColour m_secondary_scheme_colour;
@@ -745,6 +757,8 @@ protected:
int m_gallery_bitmap_padding_right_size;
int m_gallery_bitmap_padding_top_size;
int m_gallery_bitmap_padding_bottom_size;
int m_toggle_button_offset;
int m_help_button_offset;
};
class WXDLLIMPEXP_RIBBON wxRibbonAUIArtProvider : public wxRibbonMSWArtProvider

View File

@@ -29,11 +29,13 @@ enum wxRibbonBarOption
wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS = 1 << 4,
wxRIBBON_BAR_ALWAYS_SHOW_TABS = 1 << 5,
wxRIBBON_BAR_SHOW_TOGGLE_BUTTON = 1 << 6,
wxRIBBON_BAR_SHOW_HELP_BUTTON = 1 << 7,
wxRIBBON_BAR_DEFAULT_STYLE = wxRIBBON_BAR_FLOW_HORIZONTAL
| wxRIBBON_BAR_SHOW_PAGE_LABELS
| wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
| wxRIBBON_BAR_SHOW_TOGGLE_BUTTON,
| wxRIBBON_BAR_SHOW_TOGGLE_BUTTON
| wxRIBBON_BAR_SHOW_HELP_BUTTON,
wxRIBBON_BAR_FOLDBAR_STYLE = wxRIBBON_BAR_FLOW_VERTICAL
| wxRIBBON_BAR_SHOW_PAGE_ICONS
@@ -41,6 +43,13 @@ enum wxRibbonBarOption
| wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS
};
enum wxRibbonDisplayMode
{
wxRIBBON_BAR_PINNED,
wxRIBBON_BAR_MINIMIZED,
wxRIBBON_BAR_EXPANDED
};
class WXDLLIMPEXP_RIBBON wxRibbonBarEvent : public wxNotifyEvent
{
public:
@@ -144,6 +153,9 @@ public:
// Implementation only.
bool IsToggleButtonHovered() const { return m_toggle_button_hovered; }
bool IsHelpButtonHovered() const { return m_help_button_hovered; }
void HideIfExpanded();
protected:
friend class wxRibbonPage;
@@ -151,7 +163,7 @@ protected:
virtual wxSize DoGetBestSize() const;
wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
wxRibbonPageTabInfo* HitTestTabs(wxPoint position, int* index = NULL);
void HitTestToggleButton(wxPoint position);
void HitTestRibbonButton(const wxRect& rect, const wxPoint& position, bool &hover_flag);
void CommonInit(long style);
void AddPage(wxRibbonPage *page);
@@ -175,11 +187,13 @@ protected:
void OnMouseLeave(wxMouseEvent& evt);
void OnMouseDoubleClick(wxMouseEvent& evt);
void DoMouseButtonCommon(wxMouseEvent& evt, wxEventType tab_event_type);
void OnKillFocus(wxFocusEvent& evt);
wxRibbonPageTabInfoArray m_pages;
wxRect m_tab_scroll_left_button_rect;
wxRect m_tab_scroll_right_button_rect;
wxRect m_toggle_button_rect;
wxRect m_help_button_rect;
long m_flags;
int m_tabs_total_width_ideal;
int m_tabs_total_width_minimum;
@@ -195,6 +209,9 @@ protected:
bool m_arePanelsShown;
bool m_bar_hovered;
bool m_toggle_button_hovered;
bool m_help_button_hovered;
wxRibbonDisplayMode m_ribbon_state;
#ifndef SWIG
DECLARE_CLASS(wxRibbonBar)
@@ -212,6 +229,7 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_D
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TOGGLED, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_HELP_CLICKED, wxRibbonBarEvent);
typedef void (wxEvtHandler::*wxRibbonBarEventFunction)(wxRibbonBarEvent&);
@@ -234,6 +252,8 @@ typedef void (wxEvtHandler::*wxRibbonBarEventFunction)(wxRibbonBarEvent&);
wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_TOGGLED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TOGGLED, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_HELP_CLICK(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_HELP_CLICKED, winid, wxRibbonBarEventHandler(fn))
#else
// wxpython/swig event work
@@ -245,6 +265,7 @@ typedef void (wxEvtHandler::*wxRibbonBarEventFunction)(wxRibbonBarEvent&);
%constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP;
%constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK;
%constant wxEventType wxEVT_COMMAND_RIBBONBAR_TOGGLED;
%constant wxEventType wxEVT_COMMAND_RIBBONBAR_HELP_CLICKED;
%pythoncode {
EVT_RIBBONBAR_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, 1 )
@@ -255,6 +276,7 @@ typedef void (wxEvtHandler::*wxRibbonBarEventFunction)(wxRibbonBarEvent&);
EVT_RIBBONBAR_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, 1 )
EVT_RIBBONBAR_TAB_LEFT_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, 1 )
EVT_RIBBONBAR_TOGGLED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TOGGLED, 1 )
EVT_RIBBONBAR_HELP_CLICK = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_HELP_CLICKED, 1 )
}
#endif

View File

@@ -61,6 +61,8 @@ public:
virtual void RemoveChild(wxWindowBase *child);
void HideIfExpanded();
protected:
virtual wxSize DoGetBestSize() const;
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }

View File

@@ -84,6 +84,8 @@ public:
long GetFlags() { return m_flags; }
void HideIfExpanded();
protected:
virtual wxSize DoGetBestSize() const;
virtual wxSize GetPanelSizerBestSize() const;