initial commit

Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
2025-10-31 23:37:30 +01:00
commit bf6b52fd94
9654 changed files with 4035664 additions and 0 deletions

View File

@@ -0,0 +1,969 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/art.h
// Purpose: Art providers for ribbon-bar-style interface
// Author: Peter Cawley
// Created: 2009-05-25
// Copyright: (C) Peter Cawley
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RIBBON_ART_H_
#define _WX_RIBBON_ART_H_
#include "wx/defs.h"
#if wxUSE_RIBBON
#include "wx/brush.h"
#include "wx/colour.h"
#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 wxReadOnlyDC;
class WXDLLIMPEXP_FWD_CORE wxWindow;
enum wxRibbonArtSetting
{
wxRIBBON_ART_TAB_SEPARATION_SIZE,
wxRIBBON_ART_PAGE_BORDER_LEFT_SIZE,
wxRIBBON_ART_PAGE_BORDER_TOP_SIZE,
wxRIBBON_ART_PAGE_BORDER_RIGHT_SIZE,
wxRIBBON_ART_PAGE_BORDER_BOTTOM_SIZE,
wxRIBBON_ART_PANEL_X_SEPARATION_SIZE,
wxRIBBON_ART_PANEL_Y_SEPARATION_SIZE,
wxRIBBON_ART_TOOL_GROUP_SEPARATION_SIZE,
wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE,
wxRIBBON_ART_GALLERY_BITMAP_PADDING_RIGHT_SIZE,
wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE,
wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE,
wxRIBBON_ART_PANEL_LABEL_FONT,
wxRIBBON_ART_BUTTON_BAR_LABEL_FONT,
wxRIBBON_ART_TAB_LABEL_FONT,
wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR,
wxRIBBON_ART_BUTTON_BAR_HOVER_BORDER_COLOUR,
wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR,
wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_COLOUR,
wxRIBBON_ART_BUTTON_BAR_HOVER_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_BUTTON_BAR_ACTIVE_BORDER_COLOUR,
wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR,
wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_COLOUR,
wxRIBBON_ART_BUTTON_BAR_ACTIVE_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_GALLERY_BORDER_COLOUR,
wxRIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_FACE_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_HOVER_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_DISABLED_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR,
wxRIBBON_ART_GALLERY_ITEM_BORDER_COLOUR,
wxRIBBON_ART_TAB_LABEL_COLOUR,
wxRIBBON_ART_TAB_ACTIVE_LABEL_COLOUR,
wxRIBBON_ART_TAB_HOVER_LABEL_COLOUR,
wxRIBBON_ART_TAB_SEPARATOR_COLOUR,
wxRIBBON_ART_TAB_SEPARATOR_GRADIENT_COLOUR,
wxRIBBON_ART_TAB_CTRL_BACKGROUND_COLOUR,
wxRIBBON_ART_TAB_CTRL_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_TAB_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR,
wxRIBBON_ART_TAB_HOVER_BACKGROUND_COLOUR,
wxRIBBON_ART_TAB_HOVER_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR,
wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_COLOUR,
wxRIBBON_ART_TAB_ACTIVE_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_TAB_BORDER_COLOUR,
wxRIBBON_ART_PANEL_BORDER_COLOUR,
wxRIBBON_ART_PANEL_BORDER_GRADIENT_COLOUR,
wxRIBBON_ART_PANEL_HOVER_BORDER_COLOUR,
wxRIBBON_ART_PANEL_HOVER_BORDER_GRADIENT_COLOUR,
wxRIBBON_ART_PANEL_MINIMISED_BORDER_COLOUR,
wxRIBBON_ART_PANEL_MINIMISED_BORDER_GRADIENT_COLOUR,
wxRIBBON_ART_PANEL_LABEL_BACKGROUND_COLOUR,
wxRIBBON_ART_PANEL_LABEL_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_PANEL_LABEL_COLOUR,
wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_COLOUR,
wxRIBBON_ART_PANEL_HOVER_LABEL_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR,
wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR,
wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR,
wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_COLOUR,
wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR,
wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR,
wxRIBBON_ART_PAGE_TOGGLE_FACE_COLOUR,
wxRIBBON_ART_PAGE_TOGGLE_HOVER_FACE_COLOUR,
wxRIBBON_ART_PAGE_BORDER_COLOUR,
wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_PAGE_BACKGROUND_TOP_GRADIENT_COLOUR,
wxRIBBON_ART_PAGE_BACKGROUND_COLOUR,
wxRIBBON_ART_PAGE_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_PAGE_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR,
wxRIBBON_ART_PAGE_HOVER_BACKGROUND_COLOUR,
wxRIBBON_ART_PAGE_HOVER_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_TOOLBAR_BORDER_COLOUR,
wxRIBBON_ART_TOOLBAR_HOVER_BORDER_COLOUR,
wxRIBBON_ART_TOOLBAR_FACE_COLOUR,
wxRIBBON_ART_TOOL_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_TOOL_BACKGROUND_TOP_GRADIENT_COLOUR,
wxRIBBON_ART_TOOL_BACKGROUND_COLOUR,
wxRIBBON_ART_TOOL_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_TOOL_HOVER_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_TOOL_HOVER_BACKGROUND_TOP_GRADIENT_COLOUR,
wxRIBBON_ART_TOOL_HOVER_BACKGROUND_COLOUR,
wxRIBBON_ART_TOOL_HOVER_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_TOOL_ACTIVE_BACKGROUND_TOP_COLOUR,
wxRIBBON_ART_TOOL_ACTIVE_BACKGROUND_TOP_GRADIENT_COLOUR,
wxRIBBON_ART_TOOL_ACTIVE_BACKGROUND_COLOUR,
wxRIBBON_ART_TOOL_ACTIVE_BACKGROUND_GRADIENT_COLOUR,
wxRIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR,
wxRIBBON_ART_BUTTON_BAR_LABEL_HIGHLIGHT_COLOUR,
wxRIBBON_ART_BUTTON_BAR_LABEL_HIGHLIGHT_GRADIENT_COLOUR,
wxRIBBON_ART_BUTTON_BAR_LABEL_HIGHLIGHT_TOP_COLOUR,
wxRIBBON_ART_BUTTON_BAR_LABEL_HIGHLIGHT_GRADIENT_TOP_COLOUR
};
enum wxRibbonScrollButtonStyle
{
wxRIBBON_SCROLL_BTN_LEFT = 0,
wxRIBBON_SCROLL_BTN_RIGHT = 1,
wxRIBBON_SCROLL_BTN_UP = 2,
wxRIBBON_SCROLL_BTN_DOWN = 3,
wxRIBBON_SCROLL_BTN_DIRECTION_MASK = 3,
wxRIBBON_SCROLL_BTN_NORMAL = 0,
wxRIBBON_SCROLL_BTN_HOVERED = 4,
wxRIBBON_SCROLL_BTN_ACTIVE = 8,
wxRIBBON_SCROLL_BTN_STATE_MASK = 12,
wxRIBBON_SCROLL_BTN_FOR_OTHER = 0,
wxRIBBON_SCROLL_BTN_FOR_TABS = 16,
wxRIBBON_SCROLL_BTN_FOR_PAGE = 32,
wxRIBBON_SCROLL_BTN_FOR_MASK = 48
};
enum wxRibbonButtonKind
{
wxRIBBON_BUTTON_NORMAL = 1 << 0,
wxRIBBON_BUTTON_DROPDOWN = 1 << 1,
wxRIBBON_BUTTON_HYBRID = wxRIBBON_BUTTON_NORMAL | wxRIBBON_BUTTON_DROPDOWN,
wxRIBBON_BUTTON_TOGGLE = 1 << 2
};
enum wxRibbonButtonBarButtonState
{
wxRIBBON_BUTTONBAR_BUTTON_SMALL = 0 << 0,
wxRIBBON_BUTTONBAR_BUTTON_MEDIUM = 1 << 0,
wxRIBBON_BUTTONBAR_BUTTON_LARGE = 2 << 0,
wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK = 3 << 0,
wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED = 1 << 3,
wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_HOVERED = 1 << 4,
wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK = wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED | wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_HOVERED,
wxRIBBON_BUTTONBAR_BUTTON_NORMAL_ACTIVE = 1 << 5,
wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_ACTIVE = 1 << 6,
wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK = wxRIBBON_BUTTONBAR_BUTTON_NORMAL_ACTIVE | wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_ACTIVE,
wxRIBBON_BUTTONBAR_BUTTON_DISABLED = 1 << 7,
wxRIBBON_BUTTONBAR_BUTTON_TOGGLED = 1 << 8,
wxRIBBON_BUTTONBAR_BUTTON_STATE_MASK = 0x1F8
};
enum wxRibbonGalleryButtonState
{
wxRIBBON_GALLERY_BUTTON_NORMAL,
wxRIBBON_GALLERY_BUTTON_HOVERED,
wxRIBBON_GALLERY_BUTTON_ACTIVE,
wxRIBBON_GALLERY_BUTTON_DISABLED
};
class wxRibbonBar;
class wxRibbonPage;
class wxRibbonPanel;
class wxRibbonGallery;
class wxRibbonGalleryItem;
class wxRibbonPageTabInfo;
class wxRibbonPageTabInfoArray;
class WXDLLIMPEXP_RIBBON wxRibbonArtProvider
{
public:
wxRibbonArtProvider();
virtual ~wxRibbonArtProvider();
wxNODISCARD virtual wxRibbonArtProvider* Clone() const = 0;
virtual void SetFlags(long flags) = 0;
virtual long GetFlags() const = 0;
virtual int GetMetric(int id) const = 0;
virtual void SetMetric(int id, int new_val) = 0;
virtual void SetFont(int id, const wxFont& font) = 0;
virtual wxFont GetFont(int id) const = 0;
virtual wxColour GetColour(int id) const = 0;
virtual void SetColour(int id, const wxColor& colour) = 0;
wxColour GetColor(int id) const { return GetColour(id); }
void SetColor(int id, const wxColour& color) { SetColour(id, color); }
virtual void GetColourScheme(wxColour* primary,
wxColour* secondary,
wxColour* tertiary) const = 0;
virtual void SetColourScheme(const wxColour& primary,
const wxColour& secondary,
const wxColour& tertiary) = 0;
virtual void DrawTabCtrlBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawTab(wxDC& dc,
wxWindow* wnd,
const wxRibbonPageTabInfo& tab) = 0;
virtual void DrawTabSeparator(wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
double visibility) = 0;
virtual void DrawPageBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawScrollButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
long style) = 0;
virtual void DrawPanelBackground(
wxDC& dc,
wxRibbonPanel* wnd,
const wxRect& rect) = 0;
virtual void DrawGalleryBackground(
wxDC& dc,
wxRibbonGallery* wnd,
const wxRect& rect) = 0;
virtual void DrawGalleryItemBackground(
wxDC& dc,
wxRibbonGallery* wnd,
const wxRect& rect,
wxRibbonGalleryItem* item) = 0;
virtual void DrawMinimisedPanel(
wxDC& dc,
wxRibbonPanel* wnd,
const wxRect& rect,
wxBitmap& bitmap) = 0;
virtual void DrawButtonBarBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawButtonBarButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
wxRibbonButtonKind kind,
long state,
const wxString& label,
const wxBitmap& bitmap_large,
const wxBitmap& bitmap_small) = 0;
virtual void DrawToolBarBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawToolGroupBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawTool(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
const wxBitmap& bitmap,
wxRibbonButtonKind kind,
long state) = 0;
virtual void DrawToggleButton(
wxDC& dc,
wxRibbonBar* wnd,
const wxRect& rect,
wxRibbonDisplayMode mode) = 0;
virtual void DrawHelpButton(
wxDC& dc,
wxRibbonBar* wnd,
const wxRect& rect) = 0;
virtual void GetBarTabWidth(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxString& label,
const wxBitmap& bitmap,
int* ideal,
int* small_begin_need_separator,
int* small_must_have_separator,
int* minimum) = 0;
virtual int GetTabCtrlHeight(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxRibbonPageTabInfoArray& pages) = 0;
virtual wxSize GetScrollButtonMinimumSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
long style) = 0;
virtual wxSize GetPanelSize(
wxReadOnlyDC& dc,
const wxRibbonPanel* wnd,
wxSize client_size,
wxPoint* client_offset) = 0;
virtual wxSize GetPanelClientSize(
wxReadOnlyDC& dc,
const wxRibbonPanel* wnd,
wxSize size,
wxPoint* client_offset) = 0;
virtual wxRect GetPanelExtButtonArea(
wxReadOnlyDC& dc,
const wxRibbonPanel* wnd,
wxRect rect) = 0;
virtual wxSize GetGallerySize(
wxReadOnlyDC& dc,
const wxRibbonGallery* wnd,
wxSize client_size) = 0;
virtual wxSize GetGalleryClientSize(
wxReadOnlyDC& dc,
const wxRibbonGallery* wnd,
wxSize size,
wxPoint* client_offset,
wxRect* scroll_up_button,
wxRect* scroll_down_button,
wxRect* extension_button) = 0;
virtual wxRect GetPageBackgroundRedrawArea(
wxReadOnlyDC& dc,
const wxRibbonPage* wnd,
wxSize page_old_size,
wxSize page_new_size) = 0;
virtual bool GetButtonBarButtonSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
wxRibbonButtonKind kind,
wxRibbonButtonBarButtonState size,
const wxString& label,
wxCoord text_min_width,
wxSize bitmap_size_large,
wxSize bitmap_size_small,
wxSize* button_size,
wxRect* normal_region,
wxRect* dropdown_region) = 0;
virtual wxCoord GetButtonBarButtonTextWidth(
wxReadOnlyDC& dc, const wxString& label,
wxRibbonButtonKind kind,
wxRibbonButtonBarButtonState size) = 0;
virtual wxSize GetMinimisedPanelMinimumSize(
wxReadOnlyDC& dc,
const wxRibbonPanel* wnd,
wxSize* desired_bitmap_size,
wxDirection* expanded_panel_direction) = 0;
virtual wxSize GetToolSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
wxSize bitmap_size,
wxRibbonButtonKind kind,
bool is_first,
bool is_last,
wxRect* dropdown_region) = 0;
virtual wxRect GetBarToggleButtonArea(const wxRect& rect)= 0;
virtual wxRect GetRibbonHelpButtonArea(const wxRect& rect) = 0;
};
class WXDLLIMPEXP_RIBBON wxRibbonMSWArtProvider : public wxRibbonArtProvider
{
public:
wxRibbonMSWArtProvider(bool set_colour_scheme = true);
virtual ~wxRibbonMSWArtProvider();
wxNODISCARD wxRibbonArtProvider* Clone() const override;
void SetFlags(long flags) override;
long GetFlags() const override;
int GetMetric(int id) const override;
void SetMetric(int id, int new_val) override;
void SetFont(int id, const wxFont& font) override;
wxFont GetFont(int id) const override;
wxColour GetColour(int id) const override;
void SetColour(int id, const wxColor& colour) override;
void GetColourScheme(wxColour* primary,
wxColour* secondary,
wxColour* tertiary) const override;
void SetColourScheme(const wxColour& primary,
const wxColour& secondary,
const wxColour& tertiary) override;
int GetTabCtrlHeight(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxRibbonPageTabInfoArray& pages) override;
void DrawTabCtrlBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
void DrawTab(wxDC& dc,
wxWindow* wnd,
const wxRibbonPageTabInfo& tab) override;
void DrawTabSeparator(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
double visibility) override;
void DrawPageBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
void DrawScrollButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
long style) override;
void DrawPanelBackground(
wxDC& dc,
wxRibbonPanel* wnd,
const wxRect& rect) override;
void DrawGalleryBackground(
wxDC& dc,
wxRibbonGallery* wnd,
const wxRect& rect) override;
void DrawGalleryItemBackground(
wxDC& dc,
wxRibbonGallery* wnd,
const wxRect& rect,
wxRibbonGalleryItem* item) override;
void DrawMinimisedPanel(
wxDC& dc,
wxRibbonPanel* wnd,
const wxRect& rect,
wxBitmap& bitmap) override;
void DrawButtonBarBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
void DrawButtonBarButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
wxRibbonButtonKind kind,
long state,
const wxString& label,
const wxBitmap& bitmap_large,
const wxBitmap& bitmap_small) override;
void DrawToolBarBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
void DrawToolGroupBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
void DrawTool(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
const wxBitmap& bitmap,
wxRibbonButtonKind kind,
long state) override;
void DrawToggleButton(
wxDC& dc,
wxRibbonBar* wnd,
const wxRect& rect,
wxRibbonDisplayMode mode) override;
void DrawHelpButton(wxDC& dc,
wxRibbonBar* wnd,
const wxRect& rect) override;
void GetBarTabWidth(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxString& label,
const wxBitmap& bitmap,
int* ideal,
int* small_begin_need_separator,
int* small_must_have_separator,
int* minimum) override;
wxSize GetScrollButtonMinimumSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
long style) override;
wxSize GetPanelSize(
wxReadOnlyDC& dc,
const wxRibbonPanel* wnd,
wxSize client_size,
wxPoint* client_offset) override;
wxSize GetPanelClientSize(
wxReadOnlyDC& dc,
const wxRibbonPanel* wnd,
wxSize size,
wxPoint* client_offset) override;
wxRect GetPanelExtButtonArea(
wxReadOnlyDC& dc,
const wxRibbonPanel* wnd,
wxRect rect) override;
wxSize GetGallerySize(
wxReadOnlyDC& dc,
const wxRibbonGallery* wnd,
wxSize client_size) override;
wxSize GetGalleryClientSize(
wxReadOnlyDC& dc,
const wxRibbonGallery* wnd,
wxSize size,
wxPoint* client_offset,
wxRect* scroll_up_button,
wxRect* scroll_down_button,
wxRect* extension_button) override;
wxRect GetPageBackgroundRedrawArea(
wxReadOnlyDC& dc,
const wxRibbonPage* wnd,
wxSize page_old_size,
wxSize page_new_size) override;
bool GetButtonBarButtonSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
wxRibbonButtonKind kind,
wxRibbonButtonBarButtonState size,
const wxString& label,
wxCoord text_min_width,
wxSize bitmap_size_large,
wxSize bitmap_size_small,
wxSize* button_size,
wxRect* normal_region,
wxRect* dropdown_region) override;
wxCoord GetButtonBarButtonTextWidth(
wxReadOnlyDC& dc, const wxString& label,
wxRibbonButtonKind kind,
wxRibbonButtonBarButtonState size) override;
wxSize GetMinimisedPanelMinimumSize(
wxReadOnlyDC& dc,
const wxRibbonPanel* wnd,
wxSize* desired_bitmap_size,
wxDirection* expanded_panel_direction) override;
wxSize GetToolSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
wxSize bitmap_size,
wxRibbonButtonKind kind,
bool is_first,
bool is_last,
wxRect* dropdown_region) override;
wxRect GetBarToggleButtonArea(const wxRect& rect) override;
wxRect GetRibbonHelpButtonArea(const wxRect& rect) override;
protected:
void ReallyDrawTabSeparator(wxWindow* wnd, const wxRect& rect, double visibility);
void DrawPartialPageBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect,
bool allow_hovered = true);
void DrawPartialPageBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect,
wxRibbonPage* page, wxPoint offset, bool hovered = false);
void DrawPanelBorder(wxDC& dc, const wxRect& rect, wxPen& primary_colour,
wxPen& secondary_colour);
void RemovePanelPadding(wxRect* rect);
void DrawDropdownArrow(wxDC& dc, int x, int y, const wxColour& colour);
void DrawGalleryBackgroundCommon(wxDC& dc, wxRibbonGallery* wnd,
const wxRect& rect);
virtual void DrawGalleryButton(wxDC& dc, wxRect rect,
wxRibbonGalleryButtonState state, wxBitmap* bitmaps);
void DrawButtonBarButtonForeground(
wxDC& dc,
const wxRect& rect,
wxRibbonButtonKind kind,
long state,
const wxString& label,
const wxBitmap& bitmap_large,
const wxBitmap& bitmap_small);
void DrawMinimisedPanelCommon(
wxDC& dc,
wxRibbonPanel* wnd,
const wxRect& rect,
wxRect* preview_rect);
void CloneTo(wxRibbonMSWArtProvider* copy) const;
wxBitmap m_cached_tab_separator;
wxBitmap m_gallery_up_bitmap[4];
wxBitmap m_gallery_down_bitmap[4];
wxBitmap m_gallery_extension_bitmap[4];
wxBitmap m_toolbar_drop_bitmap;
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;
wxColour m_tertiary_scheme_colour;
wxColour m_button_bar_label_colour;
wxColour m_button_bar_label_disabled_colour;
wxColour m_tab_label_colour;
wxColour m_tab_active_label_colour;
wxColour m_tab_hover_label_colour;
wxColour m_tab_separator_colour;
wxColour m_tab_separator_gradient_colour;
wxColour m_tab_active_background_colour;
wxColour m_tab_active_background_gradient_colour;
wxColour m_tab_hover_background_colour;
wxColour m_tab_hover_background_gradient_colour;
wxColour m_tab_hover_background_top_colour;
wxColour m_tab_hover_background_top_gradient_colour;
wxColour m_tab_highlight_top_colour;
wxColour m_tab_highlight_top_gradient_colour;
wxColour m_tab_highlight_colour;
wxColour m_tab_highlight_gradient_colour;
wxColour m_panel_label_colour;
wxColour m_panel_minimised_label_colour;
wxColour m_panel_hover_label_colour;
wxColour m_panel_active_background_colour;
wxColour m_panel_active_background_gradient_colour;
wxColour m_panel_active_background_top_colour;
wxColour m_panel_active_background_top_gradient_colour;
wxColour m_panel_button_face_colour;
wxColour m_panel_button_hover_face_colour;
wxColour m_page_toggle_face_colour;
wxColour m_page_toggle_hover_face_colour;
wxColour m_page_background_colour;
wxColour m_page_background_gradient_colour;
wxColour m_page_background_top_colour;
wxColour m_page_background_top_gradient_colour;
wxColour m_page_hover_background_colour;
wxColour m_page_hover_background_gradient_colour;
wxColour m_page_hover_background_top_colour;
wxColour m_page_hover_background_top_gradient_colour;
wxColour m_button_bar_hover_background_colour;
wxColour m_button_bar_hover_background_gradient_colour;
wxColour m_button_bar_hover_background_top_colour;
wxColour m_button_bar_hover_background_top_gradient_colour;
wxColour m_button_bar_active_background_colour;
wxColour m_button_bar_active_background_gradient_colour;
wxColour m_button_bar_active_background_top_colour;
wxColour m_button_bar_active_background_top_gradient_colour;
wxColour m_gallery_button_background_colour;
wxColour m_gallery_button_background_gradient_colour;
wxColour m_gallery_button_hover_background_colour;
wxColour m_gallery_button_hover_background_gradient_colour;
wxColour m_gallery_button_active_background_colour;
wxColour m_gallery_button_active_background_gradient_colour;
wxColour m_gallery_button_disabled_background_colour;
wxColour m_gallery_button_disabled_background_gradient_colour;
wxColour m_gallery_button_face_colour;
wxColour m_gallery_button_hover_face_colour;
wxColour m_gallery_button_active_face_colour;
wxColour m_gallery_button_disabled_face_colour;
wxColour m_tool_face_colour;
wxColour m_tool_background_top_colour;
wxColour m_tool_background_top_gradient_colour;
wxColour m_tool_background_colour;
wxColour m_tool_background_gradient_colour;
wxColour m_tool_hover_background_top_colour;
wxColour m_tool_hover_background_top_gradient_colour;
wxColour m_tool_hover_background_colour;
wxColour m_tool_hover_background_gradient_colour;
wxColour m_tool_active_background_top_colour;
wxColour m_tool_active_background_top_gradient_colour;
wxColour m_tool_active_background_colour;
wxColour m_tool_active_background_gradient_colour;
wxBrush m_tab_ctrl_background_brush;
wxBrush m_panel_label_background_brush;
wxBrush m_panel_hover_label_background_brush;
wxBrush m_panel_hover_button_background_brush;
wxBrush m_gallery_hover_background_brush;
wxBrush m_gallery_button_background_top_brush;
wxBrush m_gallery_button_hover_background_top_brush;
wxBrush m_gallery_button_active_background_top_brush;
wxBrush m_gallery_button_disabled_background_top_brush;
wxBrush m_ribbon_toggle_brush;
wxFont m_tab_label_font;
wxFont m_panel_label_font;
wxFont m_button_bar_label_font;
wxPen m_page_border_pen;
wxPen m_panel_border_pen;
wxPen m_panel_border_gradient_pen;
wxPen m_panel_hover_border_pen;
wxPen m_panel_hover_border_gradient_pen;
wxPen m_panel_minimised_border_pen;
wxPen m_panel_minimised_border_gradient_pen;
wxPen m_panel_hover_button_border_pen;
wxPen m_tab_border_pen;
wxPen m_button_bar_hover_border_pen;
wxPen m_button_bar_active_border_pen;
wxPen m_gallery_border_pen;
wxPen m_gallery_item_border_pen;
wxPen m_toolbar_border_pen;
wxPen m_ribbon_toggle_pen;
double m_cached_tab_separator_visibility;
long m_flags;
int m_tab_separation_size;
int m_page_border_left;
int m_page_border_top;
int m_page_border_right;
int m_page_border_bottom;
int m_panel_x_separation_size;
int m_panel_y_separation_size;
int m_tool_group_separation_size;
int m_gallery_bitmap_padding_left_size;
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
{
public:
wxRibbonAUIArtProvider();
virtual ~wxRibbonAUIArtProvider();
wxNODISCARD wxRibbonArtProvider* Clone() const override;
wxColour GetColour(int id) const override;
void SetColour(int id, const wxColor& colour) override;
void SetColourScheme(const wxColour& primary,
const wxColour& secondary,
const wxColour& tertiary) override;
void SetFont(int id, const wxFont& font) override;
wxSize GetScrollButtonMinimumSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
long style) override;
void DrawScrollButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
long style) override;
wxSize GetPanelSize(
wxReadOnlyDC& dc,
const wxRibbonPanel* wnd,
wxSize client_size,
wxPoint* client_offset) override;
wxSize GetPanelClientSize(
wxReadOnlyDC& dc,
const wxRibbonPanel* wnd,
wxSize size,
wxPoint* client_offset) override;
wxRect GetPanelExtButtonArea(
wxReadOnlyDC& dc,
const wxRibbonPanel* wnd,
wxRect rect) override;
void DrawTabCtrlBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
int GetTabCtrlHeight(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxRibbonPageTabInfoArray& pages) override;
void GetBarTabWidth(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxString& label,
const wxBitmap& bitmap,
int* ideal,
int* small_begin_need_separator,
int* small_must_have_separator,
int* minimum) override;
void DrawTab(wxDC& dc,
wxWindow* wnd,
const wxRibbonPageTabInfo& tab) override;
void DrawTabSeparator(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
double visibility) override;
void DrawPageBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
void DrawPanelBackground(
wxDC& dc,
wxRibbonPanel* wnd,
const wxRect& rect) override;
void DrawMinimisedPanel(
wxDC& dc,
wxRibbonPanel* wnd,
const wxRect& rect,
wxBitmap& bitmap) override;
void DrawGalleryBackground(
wxDC& dc,
wxRibbonGallery* wnd,
const wxRect& rect) override;
void DrawGalleryItemBackground(
wxDC& dc,
wxRibbonGallery* wnd,
const wxRect& rect,
wxRibbonGalleryItem* item) override;
void DrawButtonBarBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
void DrawButtonBarButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
wxRibbonButtonKind kind,
long state,
const wxString& label,
const wxBitmap& bitmap_large,
const wxBitmap& bitmap_small) override;
void DrawToolBarBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
void DrawToolGroupBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
void DrawTool(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
const wxBitmap& bitmap,
wxRibbonButtonKind kind,
long state) override;
protected:
void DrawPartialPanelBackground(wxDC& dc, wxWindow* wnd,
const wxRect& rect);
void DrawGalleryButton(wxDC& dc, wxRect rect,
wxRibbonGalleryButtonState state, wxBitmap* bitmaps) override;
wxColour m_tab_ctrl_background_colour;
wxColour m_tab_ctrl_background_gradient_colour;
wxColour m_panel_label_background_colour;
wxColour m_panel_label_background_gradient_colour;
wxColour m_panel_hover_label_background_colour;
wxColour m_panel_hover_label_background_gradient_colour;
wxBrush m_background_brush;
wxBrush m_tab_active_top_background_brush;
wxBrush m_tab_hover_background_brush;
wxBrush m_button_bar_hover_background_brush;
wxBrush m_button_bar_active_background_brush;
wxBrush m_gallery_button_active_background_brush;
wxBrush m_gallery_button_hover_background_brush;
wxBrush m_gallery_button_disabled_background_brush;
wxBrush m_tool_hover_background_brush;
wxBrush m_tool_active_background_brush;
wxPen m_toolbar_hover_borden_pen;
wxFont m_tab_active_label_font;
};
#if defined(__WXMSW__)
typedef wxRibbonMSWArtProvider wxRibbonDefaultArtProvider;
#elif defined(__WXOSX_COCOA__) || \
defined(__WXOSX_IPHONE__)
// TODO: Once implemented, change typedef to OSX
// typedef wxRibbonOSXArtProvider wxRibbonDefaultArtProvider;
typedef wxRibbonAUIArtProvider wxRibbonDefaultArtProvider;
#else
// TODO: Once implemented, change typedef to AUI
typedef wxRibbonAUIArtProvider wxRibbonDefaultArtProvider;
#endif
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_ART_H_

View File

@@ -0,0 +1,90 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/art_internal.h
// Purpose: Helper functions & classes used by ribbon art providers
// Author: Peter Cawley
// Created: 2009-08-04
// Copyright: (C) Peter Cawley
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RIBBON_ART_INTERNAL_H_
#define _WX_RIBBON_ART_INTERNAL_H_
#include "wx/defs.h"
#if wxUSE_RIBBON
#include "wx/settings.h"
WXDLLIMPEXP_RIBBON wxColour wxRibbonInterpolateColour(
const wxColour& start_colour,
const wxColour& end_colour,
int position,
int start_position,
int end_position);
WXDLLIMPEXP_RIBBON bool wxRibbonCanLabelBreakAtPosition(
const wxString& label,
size_t pos);
WXDLLIMPEXP_RIBBON void wxRibbonDrawParallelGradientLines(
wxDC& dc,
int nlines,
const wxPoint* line_origins,
int stepx,
int stepy,
int numsteps,
int offset_x,
int offset_y,
const wxColour& start_colour,
const wxColour& end_colour);
WXDLLIMPEXP_RIBBON wxBitmap wxRibbonLoadPixmap(
const char* const* bits,
wxColour fore);
/*
HSL colour class, using interface as discussed in wx-dev. Provided mainly
for art providers to perform colour scheme calculations in the HSL colour
space. If such a class makes it into base / core, then this class should be
removed and users switched over to the one in base / core.
0.0 <= Hue < 360.0
0.0 <= Saturation <= 1.0
0.0 <= Luminance <= 1.0
*/
class WXDLLIMPEXP_RIBBON wxRibbonHSLColour
{
public:
wxRibbonHSLColour()
: hue(0.0), saturation(0.0), luminance(0.0) {}
wxRibbonHSLColour(float H, float S, float L)
: hue(H), saturation(S), luminance(L) { }
wxRibbonHSLColour(const wxColour& C);
wxColour ToRGB() const;
// In dark mode, makes the colour darker, while in light mode make it
// lighter.
wxRibbonHSLColour AdjustLuminance(float delta)
{
return wxSystemSettings::GetAppearance().IsDark()
? Darker(delta)
: Lighter(delta);
}
wxRibbonHSLColour Darker(float delta) const;
wxRibbonHSLColour Lighter(float delta) const;
wxRibbonHSLColour Saturated(float delta) const;
wxRibbonHSLColour Desaturated(float delta) const;
wxRibbonHSLColour ShiftHue(float delta) const;
float hue, saturation, luminance;
};
WXDLLIMPEXP_RIBBON wxRibbonHSLColour wxRibbonShiftLuminance(
wxRibbonHSLColour colour, float amount);
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_ART_INTERNAL_H_

View File

@@ -0,0 +1,307 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/bar.h
// Purpose: Top-level component of the ribbon-bar-style interface
// Author: Peter Cawley
// Created: 2009-05-23
// Copyright: (C) Peter Cawley
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RIBBON_BAR_H_
#define _WX_RIBBON_BAR_H_
#include "wx/defs.h"
#if wxUSE_RIBBON
class WXDLLIMPEXP_FWD_CORE wxImageList;
#include "wx/ribbon/control.h"
#include "wx/ribbon/page.h"
#include "wx/vector.h"
enum wxRibbonBarOption
{
wxRIBBON_BAR_SHOW_PAGE_LABELS = 1 << 0,
wxRIBBON_BAR_SHOW_PAGE_ICONS = 1 << 1,
wxRIBBON_BAR_FLOW_HORIZONTAL = 0,
wxRIBBON_BAR_FLOW_VERTICAL = 1 << 2,
wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS = 1 << 3,
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_HELP_BUTTON,
wxRIBBON_BAR_FOLDBAR_STYLE = wxRIBBON_BAR_FLOW_VERTICAL
| wxRIBBON_BAR_SHOW_PAGE_ICONS
| wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
| wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS
};
enum wxRibbonDisplayMode
{
wxRIBBON_BAR_PINNED,
wxRIBBON_BAR_MINIMIZED,
wxRIBBON_BAR_EXPANDED
};
class WXDLLIMPEXP_RIBBON wxRibbonBarEvent : public wxNotifyEvent
{
public:
wxRibbonBarEvent(wxEventType command_type = wxEVT_NULL,
int win_id = 0,
wxRibbonPage* page = nullptr)
: wxNotifyEvent(command_type, win_id)
, m_page(page)
{
}
wxRibbonBarEvent(const wxRibbonBarEvent& e) = default;
wxNODISCARD wxEvent *Clone() const override { return new wxRibbonBarEvent(*this); }
wxRibbonPage* GetPage() {return m_page;}
void SetPage(wxRibbonPage* page) {m_page = page;}
protected:
wxRibbonPage* m_page = nullptr;
#ifndef SWIG
private:
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonBarEvent);
#endif
};
class WXDLLIMPEXP_RIBBON wxRibbonPageTabInfo
{
public:
wxRect rect;
wxRibbonPage* page = nullptr;
int ideal_width;
int small_begin_need_separator_width;
int small_must_have_separator_width;
int minimum_width;
bool active;
bool hovered;
bool highlight;
bool shown;
};
// This must be a class because it's forward declared.
class wxRibbonPageTabInfoArray : public wxBaseArray<wxRibbonPageTabInfo>
{
public:
using wxBaseArray<wxRibbonPageTabInfo>::wxBaseArray;
};
class WXDLLIMPEXP_RIBBON wxRibbonBar : public wxRibbonControl
{
public:
wxRibbonBar();
wxRibbonBar(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxRIBBON_BAR_DEFAULT_STYLE);
virtual ~wxRibbonBar();
bool Create(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxRIBBON_BAR_DEFAULT_STYLE);
void SetTabCtrlMargins(int left, int right);
void SetArtProvider(wxRibbonArtProvider* art) override;
bool SetActivePage(size_t page);
bool SetActivePage(wxRibbonPage* page);
int GetActivePage() const;
wxRibbonPage* GetPage(int n);
wxRibbonPage* GetPageById(wxWindowID id);
size_t GetPageCount() const;
bool DismissExpandedPanel();
int GetPageNumber(wxRibbonPage* page) const;
void DeletePage(size_t n);
void ClearPages();
bool IsPageShown(size_t page) const;
void ShowPage(size_t page, bool show = true);
void HidePage(size_t page) { ShowPage(page, false); }
bool IsPageHighlighted(size_t page) const;
void AddPageHighlight(size_t page, bool highlight = true);
void RemovePageHighlight(size_t page) { AddPageHighlight(page, false); }
void ShowPanels(wxRibbonDisplayMode mode);
void ShowPanels(bool show = true);
void HidePanels() { ShowPanels(wxRIBBON_BAR_MINIMIZED); }
bool ArePanelsShown() const { return m_arePanelsShown; }
wxRibbonDisplayMode GetDisplayMode() const { return m_ribbon_state; }
virtual bool HasMultiplePages() const override { return true; }
void SetWindowStyleFlag(long style) override;
long GetWindowStyleFlag() const override;
virtual bool Realize() override;
// Implementation only.
bool IsToggleButtonHovered() const { return m_toggle_button_hovered; }
bool IsHelpButtonHovered() const { return m_help_button_hovered; }
void HideIfExpanded();
// Return the image list containing images of the given size, creating it
// if necessary.
wxImageList* GetButtonImageList(wxSize size);
protected:
friend class wxRibbonPage;
virtual wxSize DoGetBestSize() const override;
wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
wxRibbonPageTabInfo* HitTestTabs(wxPoint position, int* index = nullptr);
void HitTestRibbonButton(const wxRect& rect, const wxPoint& position, bool &hover_flag);
void CommonInit(long style);
void AddPage(wxRibbonPage *page);
void RecalculateTabSizes();
void RecalculateMinSize();
void ScrollTabBar(int npixels);
void RefreshTabBar();
void RepositionPage(wxRibbonPage *page);
void OnPaint(wxPaintEvent& evt);
void OnEraseBackground(wxEraseEvent& evt);
void DoEraseBackground(wxDC& dc);
void OnSize(wxSizeEvent& evt);
void OnMouseLeftDown(wxMouseEvent& evt);
void OnMouseLeftUp(wxMouseEvent& evt);
void OnMouseMiddleDown(wxMouseEvent& evt);
void OnMouseMiddleUp(wxMouseEvent& evt);
void OnMouseRightDown(wxMouseEvent& evt);
void OnMouseRightUp(wxMouseEvent& evt);
void OnMouseMove(wxMouseEvent& evt);
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;
int m_tab_margin_left;
int m_tab_margin_right;
int m_tab_height;
int m_tab_scroll_amount;
int m_current_page;
int m_current_hovered_page;
int m_tab_scroll_left_button_state;
int m_tab_scroll_right_button_state;
bool m_tab_scroll_buttons_shown;
bool m_arePanelsShown;
bool m_bar_hovered;
bool m_toggle_button_hovered;
bool m_help_button_hovered;
wxRibbonDisplayMode m_ribbon_state;
wxVector<wxImageList*> m_image_lists;
#ifndef SWIG
wxDECLARE_CLASS(wxRibbonBar);
wxDECLARE_EVENT_TABLE();
#endif
};
#ifndef SWIG
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_PAGE_CHANGED, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_PAGE_CHANGING, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_MIDDLE_UP, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_RIGHT_DOWN, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_RIGHT_UP, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TAB_LEFT_DCLICK, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_TOGGLED, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBAR_HELP_CLICK, wxRibbonBarEvent);
typedef void (wxEvtHandler::*wxRibbonBarEventFunction)(wxRibbonBarEvent&);
#define wxRibbonBarEventHandler(func) \
wxEVENT_HANDLER_CAST(wxRibbonBarEventFunction, func)
#define EVT_RIBBONBAR_PAGE_CHANGED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONBAR_PAGE_CHANGED, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_PAGE_CHANGING(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONBAR_PAGE_CHANGING, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_TAB_MIDDLE_DOWN(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_TAB_MIDDLE_UP(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_MIDDLE_UP, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_TAB_RIGHT_DOWN(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_RIGHT_DOWN, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_TAB_RIGHT_UP(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_RIGHT_UP, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_TAB_LEFT_DCLICK(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TAB_LEFT_DCLICK, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_TOGGLED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONBAR_TOGGLED, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_HELP_CLICK(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONBAR_HELP_CLICK, winid, wxRibbonBarEventHandler(fn))
#else
// wxpython/swig event work
%constant wxEventType wxEVT_RIBBONBAR_PAGE_CHANGED;
%constant wxEventType wxEVT_RIBBONBAR_PAGE_CHANGING;
%constant wxEventType wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN;
%constant wxEventType wxEVT_RIBBONBAR_TAB_MIDDLE_UP;
%constant wxEventType wxEVT_RIBBONBAR_TAB_RIGHT_DOWN;
%constant wxEventType wxEVT_RIBBONBAR_TAB_RIGHT_UP;
%constant wxEventType wxEVT_RIBBONBAR_TAB_LEFT_DCLICK;
%constant wxEventType wxEVT_RIBBONBAR_TOGGLED;
%constant wxEventType wxEVT_RIBBONBAR_HELP_CLICK;
%pythoncode {
EVT_RIBBONBAR_PAGE_CHANGED = wx.PyEventBinder( wxEVT_RIBBONBAR_PAGE_CHANGED, 1 )
EVT_RIBBONBAR_PAGE_CHANGING = wx.PyEventBinder( wxEVT_RIBBONBAR_PAGE_CHANGING, 1 )
EVT_RIBBONBAR_TAB_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN, 1 )
EVT_RIBBONBAR_TAB_MIDDLE_UP = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_MIDDLE_UP, 1 )
EVT_RIBBONBAR_TAB_RIGHT_DOWN = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_RIGHT_DOWN, 1 )
EVT_RIBBONBAR_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_RIGHT_UP, 1 )
EVT_RIBBONBAR_TAB_LEFT_DCLICK = wx.PyEventBinder( wxEVT_RIBBONBAR_TAB_LEFT_DCLICK, 1 )
EVT_RIBBONBAR_TOGGLED = wx.PyEventBinder( wxEVT_RIBBONBAR_TOGGLED, 1 )
EVT_RIBBONBAR_HELP_CLICK = wx.PyEventBinder( wxEVT_RIBBONBAR_HELP_CLICK, 1 )
}
#endif
// old wxEVT_COMMAND_* constants
#define wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED wxEVT_RIBBONBAR_PAGE_CHANGED
#define wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING wxEVT_RIBBONBAR_PAGE_CHANGING
#define wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN wxEVT_RIBBONBAR_TAB_MIDDLE_DOWN
#define wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP wxEVT_RIBBONBAR_TAB_MIDDLE_UP
#define wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN wxEVT_RIBBONBAR_TAB_RIGHT_DOWN
#define wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP wxEVT_RIBBONBAR_TAB_RIGHT_UP
#define wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK wxEVT_RIBBONBAR_TAB_LEFT_DCLICK
#define wxEVT_COMMAND_RIBBONBAR_TOGGLED wxEVT_RIBBONBAR_TOGGLED
#define wxEVT_COMMAND_RIBBONBAR_HELP_CLICKED wxEVT_RIBBONBAR_HELP_CLICK
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_BAR_H_

View File

@@ -0,0 +1,283 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/buttonbar.h
// Purpose: Ribbon control similar to a tool bar
// Author: Peter Cawley
// Created: 2009-07-01
// Copyright: (C) Peter Cawley
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RIBBON_BUTTON_BAR_H_
#define _WX_RIBBON_BUTTON_BAR_H_
#include "wx/defs.h"
#if wxUSE_RIBBON
#include "wx/ribbon/art.h"
#include "wx/ribbon/control.h"
#include "wx/dynarray.h"
class wxRibbonButtonBar;
class wxRibbonButtonBarButtonBase;
class wxRibbonButtonBarLayout;
class wxRibbonButtonBarButtonInstance;
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxRibbonButtonBarLayout*, wxArrayRibbonButtonBarLayout, class WXDLLIMPEXP_RIBBON);
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxRibbonButtonBarButtonBase*, wxArrayRibbonButtonBarButtonBase, class WXDLLIMPEXP_RIBBON);
class WXDLLIMPEXP_RIBBON wxRibbonButtonBar : public wxRibbonControl
{
public:
wxRibbonButtonBar();
wxRibbonButtonBar(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
virtual ~wxRibbonButtonBar();
bool Create(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
virtual wxRibbonButtonBarButtonBase* AddButton(
int button_id,
const wxString& label,
const wxBitmap& bitmap,
const wxString& help_string,
wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL);
// NB: help_string cannot be optional as that would cause the signature
// to be identical to the full version of AddButton when 3 arguments are
// given.
virtual wxRibbonButtonBarButtonBase* AddDropdownButton(
int button_id,
const wxString& label,
const wxBitmap& bitmap,
const wxString& help_string = wxEmptyString);
virtual wxRibbonButtonBarButtonBase* AddHybridButton(
int button_id,
const wxString& label,
const wxBitmap& bitmap,
const wxString& help_string = wxEmptyString);
virtual wxRibbonButtonBarButtonBase* AddToggleButton(
int button_id,
const wxString& label,
const wxBitmap& bitmap,
const wxString& help_string = wxEmptyString);
virtual wxRibbonButtonBarButtonBase* AddButton(
int button_id,
const wxString& label,
const wxBitmap& bitmap,
const wxBitmap& bitmap_small = wxNullBitmap,
const wxBitmap& bitmap_disabled = wxNullBitmap,
const wxBitmap& bitmap_small_disabled = wxNullBitmap,
wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL,
const wxString& help_string = wxEmptyString);
virtual wxRibbonButtonBarButtonBase* InsertButton(
size_t pos,
int button_id,
const wxString& label,
const wxBitmap& bitmap,
const wxString& help_string,
wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL);
virtual wxRibbonButtonBarButtonBase* InsertDropdownButton(
size_t pos,
int button_id,
const wxString& label,
const wxBitmap& bitmap,
const wxString& help_string = wxEmptyString);
virtual wxRibbonButtonBarButtonBase* InsertHybridButton(
size_t pos,
int button_id,
const wxString& label,
const wxBitmap& bitmap,
const wxString& help_string = wxEmptyString);
virtual wxRibbonButtonBarButtonBase* InsertToggleButton(
size_t pos,
int button_id,
const wxString& label,
const wxBitmap& bitmap,
const wxString& help_string = wxEmptyString);
virtual wxRibbonButtonBarButtonBase* InsertButton(
size_t pos,
int button_id,
const wxString& label,
const wxBitmap& bitmap,
const wxBitmap& bitmap_small = wxNullBitmap,
const wxBitmap& bitmap_disabled = wxNullBitmap,
const wxBitmap& bitmap_small_disabled = wxNullBitmap,
wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL,
const wxString& help_string = wxEmptyString);
void SetItemClientObject(wxRibbonButtonBarButtonBase* item, wxClientData* data);
wxClientData* GetItemClientObject(const wxRibbonButtonBarButtonBase* item) const;
void SetItemClientData(wxRibbonButtonBarButtonBase* item, void* data);
void* GetItemClientData(const wxRibbonButtonBarButtonBase* item) const;
virtual size_t GetButtonCount() const;
virtual wxRibbonButtonBarButtonBase *GetItem(size_t n) const;
virtual wxRibbonButtonBarButtonBase *GetItemById(int id) const;
virtual int GetItemId(wxRibbonButtonBarButtonBase *button) const;
virtual wxRect GetItemRect(int button_id) const;
virtual bool Realize() override;
virtual void ClearButtons();
virtual bool DeleteButton(int button_id);
virtual void EnableButton(int button_id, bool enable = true);
virtual void ToggleButton(int button_id, bool checked);
virtual void SetButtonIcon(
int button_id,
const wxBitmap& bitmap,
const wxBitmap& bitmap_small = wxNullBitmap,
const wxBitmap& bitmap_disabled = wxNullBitmap,
const wxBitmap& bitmap_small_disabled = wxNullBitmap);
virtual void SetButtonText(int button_id, const wxString& label);
virtual void SetButtonTextMinWidth(int button_id,
int min_width_medium, int min_width_large);
virtual void SetButtonTextMinWidth(int button_id, const wxString& label);
virtual void SetButtonMinSizeClass(int button_id,
wxRibbonButtonBarButtonState min_size_class);
virtual void SetButtonMaxSizeClass(int button_id,
wxRibbonButtonBarButtonState max_size_class);
virtual wxRibbonButtonBarButtonBase *GetActiveItem() const;
virtual wxRibbonButtonBarButtonBase *GetHoveredItem() const;
virtual void SetArtProvider(wxRibbonArtProvider* art) override;
virtual bool IsSizingContinuous() const override;
virtual wxSize GetMinSize() const override;
void SetShowToolTipsForDisabled(bool show);
bool GetShowToolTipsForDisabled() const;
protected:
friend class wxRibbonButtonBarEvent;
virtual wxSize DoGetBestSize() const override;
wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
void OnEraseBackground(wxEraseEvent& evt);
void OnPaint(wxPaintEvent& evt);
void OnSize(wxSizeEvent& evt);
void OnMouseMove(wxMouseEvent& evt);
void OnMouseEnter(wxMouseEvent& evt);
void OnMouseLeave(wxMouseEvent& evt);
void OnMouseDown(wxMouseEvent& evt);
void OnMouseUp(wxMouseEvent& evt);
virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
wxSize relative_to) const override;
virtual wxSize DoGetNextLargerSize(wxOrientation direction,
wxSize relative_to) const override;
void CommonInit(long style);
void MakeLayouts();
void TryCollapseLayout(wxRibbonButtonBarLayout* original,
size_t first_btn, size_t* last_button,
wxRibbonButtonBarButtonState target_size);
void FetchButtonSizeInfo(wxRibbonButtonBarButtonBase* button,
wxRibbonButtonBarButtonState size, wxReadOnlyDC& dc);
virtual void UpdateWindowUI(long flags) override;
wxArrayRibbonButtonBarLayout m_layouts;
wxArrayRibbonButtonBarButtonBase m_buttons;
wxRibbonButtonBarButtonInstance* m_hovered_button = nullptr;
wxRibbonButtonBarButtonInstance* m_active_button = nullptr;
wxPoint m_layout_offset;
wxSize m_bitmap_size_large;
wxSize m_bitmap_size_small;
int m_current_layout;
bool m_layouts_valid;
bool m_lock_active_state;
bool m_show_tooltips_for_disabled;
private:
wxRibbonBar* m_ribbonBar = nullptr;
#ifndef SWIG
wxDECLARE_CLASS(wxRibbonButtonBar);
wxDECLARE_EVENT_TABLE();
#endif
};
class WXDLLIMPEXP_RIBBON wxRibbonButtonBarEvent : public wxCommandEvent
{
public:
wxRibbonButtonBarEvent(wxEventType command_type = wxEVT_NULL,
int win_id = 0,
wxRibbonButtonBar* bar = nullptr,
wxRibbonButtonBarButtonBase* button = nullptr)
: wxCommandEvent(command_type, win_id)
, m_bar(bar), m_button(button)
{
}
wxRibbonButtonBarEvent(const wxRibbonButtonBarEvent& e) = default;
wxNODISCARD wxEvent *Clone() const override { return new wxRibbonButtonBarEvent(*this); }
wxRibbonButtonBar* GetBar() {return m_bar;}
wxRibbonButtonBarButtonBase *GetButton() { return m_button; }
void SetBar(wxRibbonButtonBar* bar) {m_bar = bar;}
void SetButton(wxRibbonButtonBarButtonBase* button) { m_button = button; }
bool PopupMenu(wxMenu* menu);
protected:
wxRibbonButtonBar* m_bar = nullptr;
wxRibbonButtonBarButtonBase* m_button = nullptr;
#ifndef SWIG
private:
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonButtonBarEvent);
#endif
};
#ifndef SWIG
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBUTTONBAR_CLICKED, wxRibbonButtonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED, wxRibbonButtonBarEvent);
typedef void (wxEvtHandler::*wxRibbonButtonBarEventFunction)(wxRibbonButtonBarEvent&);
#define wxRibbonButtonBarEventHandler(func) \
wxEVENT_HANDLER_CAST(wxRibbonButtonBarEventFunction, func)
#define EVT_RIBBONBUTTONBAR_CLICKED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONBUTTONBAR_CLICKED, winid, wxRibbonButtonBarEventHandler(fn))
#define EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED, winid, wxRibbonButtonBarEventHandler(fn))
#else
// wxpython/swig event work
%constant wxEventType wxEVT_RIBBONBUTTONBAR_CLICKED;
%constant wxEventType wxEVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED;
%pythoncode {
EVT_RIBBONBUTTONBAR_CLICKED = wx.PyEventBinder( wxEVT_RIBBONBUTTONBAR_CLICKED, 1 )
EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED = wx.PyEventBinder( wxEVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED, 1 )
}
#endif
// old wxEVT_COMMAND_* constants
#define wxEVT_COMMAND_RIBBONBUTTON_CLICKED wxEVT_RIBBONBUTTONBAR_CLICKED
#define wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED wxEVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_BUTTON_BAR_H_

View File

@@ -0,0 +1,82 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/control.h
// Purpose: Extension of wxControl with common ribbon methods
// Author: Peter Cawley
// Created: 2009-06-05
// Copyright: (C) Peter Cawley
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RIBBON_CONTROL_H_
#define _WX_RIBBON_CONTROL_H_
#include "wx/defs.h"
#if wxUSE_RIBBON
#include "wx/control.h"
#include "wx/dynarray.h"
class wxRibbonBar;
class wxRibbonArtProvider;
class WXDLLIMPEXP_RIBBON wxRibbonControl : public wxControl
{
public:
wxRibbonControl() { Init(); }
wxRibbonControl(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxControlNameStr))
{
Init();
Create(parent, id, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxControlNameStr));
virtual void SetArtProvider(wxRibbonArtProvider* art);
wxRibbonArtProvider* GetArtProvider() const {return m_art;}
virtual bool IsSizingContinuous() const {return true;}
wxSize GetNextSmallerSize(wxOrientation direction, wxSize relative_to) const;
wxSize GetNextLargerSize(wxOrientation direction, wxSize relative_to) const;
wxSize GetNextSmallerSize(wxOrientation direction) const;
wxSize GetNextLargerSize(wxOrientation direction) const;
virtual bool Realize();
bool Realise() {return Realize();}
virtual wxRibbonBar* GetAncestorRibbonBar()const;
// Finds the best width and height given the parent's width and height
virtual wxSize GetBestSizeForParentSize(const wxSize& WXUNUSED(parentSize)) const { return GetBestSize(); }
protected:
wxRibbonArtProvider* m_art;
virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
wxSize relative_to) const;
virtual wxSize DoGetNextLargerSize(wxOrientation direction,
wxSize relative_to) const;
private:
void Init() { m_art = nullptr; }
#ifndef SWIG
wxDECLARE_CLASS(wxRibbonControl);
#endif
};
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxRibbonControl*, wxArrayRibbonControl, class WXDLLIMPEXP_RIBBON);
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_CONTROL_H_

View File

@@ -0,0 +1,198 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/gallery.h
// Purpose: Ribbon control which displays a gallery of items to choose from
// Author: Peter Cawley
// 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;
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxRibbonGalleryItem*, wxArrayRibbonGalleryItem, class WXDLLIMPEXP_RIBBON);
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;
virtual bool IsSizingContinuous() const override;
virtual bool Realize() override;
virtual bool Layout() override;
virtual bool ScrollLines(int lines) override;
bool ScrollPixels(int pixels);
void EnsureVisible(const wxRibbonGalleryItem* item);
protected:
wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
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);
void OnMouseDClick(wxMouseEvent& evt);
void OnPaint(wxPaintEvent& evt);
void OnSize(wxSizeEvent& evt);
int GetScrollLineSize() const;
virtual wxSize DoGetBestSize() const override;
virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
wxSize relative_to) const override;
virtual wxSize DoGetNextLargerSize(wxOrientation direction,
wxSize relative_to) const override;
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 = nullptr;
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
wxDECLARE_CLASS(wxRibbonGallery);
wxDECLARE_EVENT_TABLE();
#endif
};
class WXDLLIMPEXP_RIBBON wxRibbonGalleryEvent : public wxCommandEvent
{
public:
wxRibbonGalleryEvent(wxEventType command_type = wxEVT_NULL,
int win_id = 0,
wxRibbonGallery* gallery = nullptr,
wxRibbonGalleryItem* item = nullptr)
: 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
wxNODISCARD wxEvent *Clone() const override { return new wxRibbonGalleryEvent(*this); }
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 = nullptr;
wxRibbonGalleryItem* m_item = nullptr;
#ifndef SWIG
private:
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonGalleryEvent);
#endif
};
#ifndef SWIG
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);
typedef void (wxEvtHandler::*wxRibbonGalleryEventFunction)(wxRibbonGalleryEvent&);
#define wxRibbonGalleryEventHandler(func) \
wxEVENT_HANDLER_CAST(wxRibbonGalleryEventFunction, func)
#define EVT_RIBBONGALLERY_HOVER_CHANGED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONGALLERY_HOVER_CHANGED, winid, wxRibbonGalleryEventHandler(fn))
#define EVT_RIBBONGALLERY_SELECTED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONGALLERY_SELECTED, winid, wxRibbonGalleryEventHandler(fn))
#define EVT_RIBBONGALLERY_CLICKED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONGALLERY_CLICKED, winid, wxRibbonGalleryEventHandler(fn))
#else
// wxpython/swig event work
%constant wxEventType wxEVT_RIBBONGALLERY_HOVER_CHANGED;
%constant wxEventType wxEVT_RIBBONGALLERY_SELECTED;
%constant wxEventType wxEVT_RIBBONGALLERY_CLICKED;
%pythoncode {
EVT_RIBBONGALLERY_HOVER_CHANGED = wx.PyEventBinder( wxEVT_RIBBONGALLERY_HOVER_CHANGED, 1 )
EVT_RIBBONGALLERY_SELECTED = wx.PyEventBinder( wxEVT_RIBBONGALLERY_SELECTED, 1 )
EVT_RIBBONGALLERY_CLICKED = wx.PyEventBinder( wxEVT_RIBBONGALLERY_CLICKED, 1 )
}
#endif // SWIG
// 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
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_GALLERY_H_

View File

@@ -0,0 +1,108 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/page.h
// Purpose: Container for ribbon-bar-style interface panels
// Author: Peter Cawley
// Created: 2009-05-25
// Copyright: (C) Peter Cawley
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RIBBON_PAGE_H_
#define _WX_RIBBON_PAGE_H_
#include "wx/defs.h"
#if wxUSE_RIBBON
#include "wx/ribbon/control.h"
#include "wx/ribbon/panel.h"
#include "wx/bitmap.h"
class wxRibbonBar;
class wxRibbonPageScrollButton;
class WXDLLIMPEXP_RIBBON wxRibbonPage : public wxRibbonControl
{
public:
wxRibbonPage();
wxRibbonPage(wxRibbonBar* parent,
wxWindowID id = wxID_ANY,
const wxString& label = wxEmptyString,
const wxBitmap& icon = wxNullBitmap,
long style = 0);
virtual ~wxRibbonPage();
bool Create(wxRibbonBar* parent,
wxWindowID id = wxID_ANY,
const wxString& label = wxEmptyString,
const wxBitmap& icon = wxNullBitmap,
long style = 0);
void SetArtProvider(wxRibbonArtProvider* art) override;
wxBitmap& GetIcon() {return m_icon;}
virtual wxSize GetMinSize() const override;
void SetSizeWithScrollButtonAdjustment(int x, int y, int width, int height);
void AdjustRectToIncludeScrollButtons(wxRect* rect) const;
bool DismissExpandedPanel();
virtual bool Realize() override;
virtual bool Show(bool show = true) override;
virtual bool Layout() override;
virtual bool ScrollLines(int lines) override;
bool ScrollPixels(int pixels);
bool ScrollSections(int sections);
wxOrientation GetMajorAxis() const;
virtual void RemoveChild(wxWindowBase *child) override;
void HideIfExpanded();
wxRibbonPanel* GetPanel(int n);
wxRibbonPanel* GetPanelById(wxWindowID id);
size_t GetPanelCount() const;
protected:
virtual wxSize DoGetBestSize() const override;
virtual wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) override;
bool DoActualLayout();
void OnEraseBackground(wxEraseEvent& evt);
void OnPaint(wxPaintEvent& evt);
void OnSize(wxSizeEvent& evt);
bool ExpandPanels(wxOrientation direction, int maximum_amount);
bool CollapsePanels(wxOrientation direction, int minimum_amount);
bool ShowScrollButtons();
void HideScrollButtons();
void CommonInit(const wxString& label, const wxBitmap& icon);
void PopulateSizeCalcArray(wxSize (wxWindow::*get_size)(void) const);
wxArrayRibbonControl m_collapse_stack;
wxBitmap m_icon;
wxSize m_old_size;
// NB: Scroll button windows are siblings rather than children (to get correct clipping of children)
wxRibbonPageScrollButton* m_scroll_left_btn = nullptr;
wxRibbonPageScrollButton* m_scroll_right_btn = nullptr;
wxSize* m_size_calc_array = nullptr;
size_t m_size_calc_array_size;
int m_scroll_amount;
int m_scroll_amount_limit;
int m_size_in_major_axis_for_children;
bool m_scroll_buttons_visible;
#ifndef SWIG
wxDECLARE_CLASS(wxRibbonPage);
wxDECLARE_EVENT_TABLE();
#endif
};
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_PAGE_H_

View File

@@ -0,0 +1,194 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/panel.h
// Purpose: Ribbon-style container for a group of related tools / controls
// Author: Peter Cawley
// 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
{
wxRIBBON_PANEL_NO_AUTO_MINIMISE = 1 << 0,
wxRIBBON_PANEL_EXT_BUTTON = 1 << 3,
wxRIBBON_PANEL_MINIMISE_BUTTON = 1 << 4,
wxRIBBON_PANEL_STRETCH = 1 << 5,
wxRIBBON_PANEL_FLEXIBLE = 1 << 6,
wxRIBBON_PANEL_DEFAULT_STYLE = 0
};
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;
bool IsExtButtonHovered() const;
bool CanAutoMinimise() const;
bool ShowExpanded();
bool HideExpanded();
void SetArtProvider(wxRibbonArtProvider* art) override;
virtual bool Realize() override;
virtual bool Layout() override;
virtual wxSize GetMinSize() const override;
virtual bool IsSizingContinuous() const override;
virtual void AddChild(wxWindowBase *child) override;
virtual void RemoveChild(wxWindowBase *child) override;
virtual bool HasExtButton() const;
wxRibbonPanel* GetExpandedDummy();
wxRibbonPanel* GetExpandedPanel();
// Finds the best width and height given the parent's width and height
virtual wxSize GetBestSizeForParentSize(const wxSize& parentSize) const override;
long GetFlags() { return m_flags; }
void HideIfExpanded();
protected:
virtual wxSize DoGetBestSize() const override;
virtual wxSize GetPanelSizerBestSize() const;
wxSize GetPanelSizerMinSize() const;
wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
wxSize GetMinNotMinimisedSize() const;
virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
wxSize relative_to) const override;
virtual wxSize DoGetNextLargerSize(wxOrientation direction,
wxSize relative_to) const override;
void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) override;
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);
void OnMotion(wxMouseEvent& evt);
void OnKillFocus(wxFocusEvent& evt);
void OnChildKillFocus(wxFocusEvent& evt);
void TestPositionForHover(const wxPoint& pos);
bool ShouldSendEventToDummy(wxEvent& evt);
virtual bool TryAfter(wxEvent& evt) override;
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;
bool m_ext_button_hovered;
wxRect m_ext_button_rect;
#ifndef SWIG
wxDECLARE_CLASS(wxRibbonPanel);
wxDECLARE_EVENT_TABLE();
#endif
};
class WXDLLIMPEXP_RIBBON wxRibbonPanelEvent : public wxCommandEvent
{
public:
wxRibbonPanelEvent(wxEventType command_type = wxEVT_NULL,
int win_id = 0,
wxRibbonPanel* panel = nullptr)
: wxCommandEvent(command_type, win_id)
, m_panel(panel)
{
}
wxRibbonPanelEvent(const wxRibbonPanelEvent& e) = default;
wxNODISCARD wxEvent *Clone() const override { return new wxRibbonPanelEvent(*this); }
wxRibbonPanel* GetPanel() {return m_panel;}
void SetPanel(wxRibbonPanel* panel) {m_panel = panel;}
protected:
wxRibbonPanel* m_panel;
#ifndef SWIG
private:
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonPanelEvent);
#endif
};
#ifndef SWIG
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED, wxRibbonPanelEvent);
typedef void (wxEvtHandler::*wxRibbonPanelEventFunction)(wxRibbonPanelEvent&);
#define wxRibbonPanelEventHandler(func) \
wxEVENT_HANDLER_CAST(wxRibbonPanelEventFunction, func)
#define EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED, winid, wxRibbonPanelEventHandler(fn))
#else
// wxpython/swig event work
%constant wxEventType wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED;
%pythoncode {
EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED = wx.PyEventBinder( wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED, 1 )
}
#endif
// old wxEVT_COMMAND_* constants
#define wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED wxEVT_RIBBONPANEL_EXTBUTTON_ACTIVATED
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_PANEL_H_

View File

@@ -0,0 +1,262 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/toolbar.h
// Purpose: Ribbon-style tool bar
// Author: Peter Cawley
// Created: 2009-07-06
// Copyright: (C) Peter Cawley
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RIBBON_TOOLBAR_H_
#define _WX_RIBBON_TOOLBAR_H_
#include "wx/defs.h"
#if wxUSE_RIBBON
#include "wx/ribbon/control.h"
#include "wx/ribbon/art.h"
class wxRibbonToolBarToolBase;
class wxRibbonToolBarToolGroup;
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxRibbonToolBarToolGroup*, wxArrayRibbonToolBarToolGroup, class WXDLLIMPEXP_RIBBON);
enum wxRibbonToolBarToolState
{
wxRIBBON_TOOLBAR_TOOL_FIRST = 1 << 0,
wxRIBBON_TOOLBAR_TOOL_LAST = 1 << 1,
wxRIBBON_TOOLBAR_TOOL_POSITION_MASK = wxRIBBON_TOOLBAR_TOOL_FIRST | wxRIBBON_TOOLBAR_TOOL_LAST,
wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED = 1 << 3,
wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED = 1 << 4,
wxRIBBON_TOOLBAR_TOOL_HOVER_MASK = wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED | wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED,
wxRIBBON_TOOLBAR_TOOL_NORMAL_ACTIVE = 1 << 5,
wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE = 1 << 6,
wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK = wxRIBBON_TOOLBAR_TOOL_NORMAL_ACTIVE | wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE,
wxRIBBON_TOOLBAR_TOOL_DISABLED = 1 << 7,
wxRIBBON_TOOLBAR_TOOL_TOGGLED = 1 << 8,
wxRIBBON_TOOLBAR_TOOL_STATE_MASK = 0x1F8
};
class WXDLLIMPEXP_RIBBON wxRibbonToolBar : public wxRibbonControl
{
public:
wxRibbonToolBar();
wxRibbonToolBar(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
virtual ~wxRibbonToolBar();
bool Create(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
virtual wxRibbonToolBarToolBase* AddTool(
int tool_id,
const wxBitmap& bitmap,
const wxString& help_string,
wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL);
virtual wxRibbonToolBarToolBase* AddDropdownTool(
int tool_id,
const wxBitmap& bitmap,
const wxString& help_string = wxEmptyString);
virtual wxRibbonToolBarToolBase* AddHybridTool(
int tool_id,
const wxBitmap& bitmap,
const wxString& help_string = wxEmptyString);
virtual wxRibbonToolBarToolBase* AddToggleTool(
int tool_id,
const wxBitmap& bitmap,
const wxString& help_string = wxEmptyString);
virtual wxRibbonToolBarToolBase* AddTool(
int tool_id,
const wxBitmap& bitmap,
const wxBitmap& bitmap_disabled = wxNullBitmap,
const wxString& help_string = wxEmptyString,
wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL,
wxObject* client_data = nullptr);
virtual wxRibbonToolBarToolBase* AddSeparator();
virtual wxRibbonToolBarToolBase* InsertTool(
size_t pos,
int tool_id,
const wxBitmap& bitmap,
const wxString& help_string,
wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL);
virtual wxRibbonToolBarToolBase* InsertDropdownTool(
size_t pos,
int tool_id,
const wxBitmap& bitmap,
const wxString& help_string = wxEmptyString);
virtual wxRibbonToolBarToolBase* InsertHybridTool(
size_t pos,
int tool_id,
const wxBitmap& bitmap,
const wxString& help_string = wxEmptyString);
virtual wxRibbonToolBarToolBase* InsertToggleTool(
size_t pos,
int tool_id,
const wxBitmap& bitmap,
const wxString& help_string = wxEmptyString);
virtual wxRibbonToolBarToolBase* InsertTool(
size_t pos,
int tool_id,
const wxBitmap& bitmap,
const wxBitmap& bitmap_disabled = wxNullBitmap,
const wxString& help_string = wxEmptyString,
wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL,
wxObject* client_data = nullptr);
virtual wxRibbonToolBarToolBase* InsertSeparator(size_t pos);
virtual void ClearTools();
virtual bool DeleteTool(int tool_id);
virtual bool DeleteToolByPos(size_t pos);
virtual wxRibbonToolBarToolBase* FindById(int tool_id)const;
virtual wxRibbonToolBarToolBase* GetToolByPos(size_t pos)const;
virtual wxRibbonToolBarToolBase* GetToolByPos(wxCoord x, wxCoord y)const;
virtual size_t GetToolCount() const;
virtual int GetToolId(const wxRibbonToolBarToolBase* tool)const;
virtual wxRibbonToolBarToolBase* GetActiveTool() const;
virtual wxObject* GetToolClientData(int tool_id)const;
virtual bool GetToolEnabled(int tool_id)const;
virtual wxString GetToolHelpString(int tool_id)const;
virtual wxRibbonButtonKind GetToolKind(int tool_id)const;
virtual int GetToolPos(int tool_id)const;
virtual wxRect GetToolRect(int tool_id)const;
virtual bool GetToolState(int tool_id)const;
virtual bool Realize() override;
virtual void SetRows(int nMin, int nMax = -1);
virtual void SetToolClientData(int tool_id, wxObject* clientData);
virtual void SetToolDisabledBitmap(int tool_id, const wxBitmap &bitmap);
virtual void SetToolHelpString(int tool_id, const wxString& helpString);
virtual void SetToolNormalBitmap(int tool_id, const wxBitmap &bitmap);
virtual bool IsSizingContinuous() const override;
virtual void EnableTool(int tool_id, bool enable = true);
virtual void ToggleTool(int tool_id, bool checked);
// Finds the best width and height given the parent's width and height
virtual wxSize GetBestSizeForParentSize(const wxSize& parentSize) const override;
protected:
friend class wxRibbonToolBarEvent;
virtual wxSize DoGetBestSize() const override;
wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
void OnEraseBackground(wxEraseEvent& evt);
void OnMouseDown(wxMouseEvent& evt);
void OnMouseEnter(wxMouseEvent& evt);
void OnMouseLeave(wxMouseEvent& evt);
void OnMouseMove(wxMouseEvent& evt);
void OnMouseUp(wxMouseEvent& evt);
void OnPaint(wxPaintEvent& evt);
void OnSize(wxSizeEvent& evt);
virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
wxSize relative_to) const override;
virtual wxSize DoGetNextLargerSize(wxOrientation direction,
wxSize relative_to) const override;
void CommonInit(long style);
void AppendGroup();
wxRibbonToolBarToolGroup* InsertGroup(size_t pos);
virtual void UpdateWindowUI(long flags) override;
static wxBitmap MakeDisabledBitmap(const wxBitmap& original);
wxArrayRibbonToolBarToolGroup m_groups;
wxRibbonToolBarToolBase* m_hover_tool;
wxRibbonToolBarToolBase* m_active_tool;
wxSize* m_sizes;
int m_nrows_min;
int m_nrows_max;
#ifndef SWIG
wxDECLARE_CLASS(wxRibbonToolBar);
wxDECLARE_EVENT_TABLE();
#endif
};
class WXDLLIMPEXP_RIBBON wxRibbonToolBarEvent : public wxCommandEvent
{
public:
wxRibbonToolBarEvent(wxEventType command_type = wxEVT_NULL,
int win_id = 0,
wxRibbonToolBar* bar = nullptr)
: wxCommandEvent(command_type, win_id)
, m_bar(bar)
{
}
wxRibbonToolBarEvent(const wxRibbonToolBarEvent& e) = default;
wxNODISCARD wxEvent *Clone() const override { return new wxRibbonToolBarEvent(*this); }
wxRibbonToolBar* GetBar() {return m_bar;}
void SetBar(wxRibbonToolBar* bar) {m_bar = bar;}
bool PopupMenu(wxMenu* menu);
protected:
wxRibbonToolBar* m_bar;
#ifndef SWIG
private:
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonToolBarEvent);
#endif
};
#ifndef SWIG
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONTOOLBAR_CLICKED, wxRibbonToolBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_RIBBONTOOLBAR_DROPDOWN_CLICKED, wxRibbonToolBarEvent);
typedef void (wxEvtHandler::*wxRibbonToolBarEventFunction)(wxRibbonToolBarEvent&);
#define wxRibbonToolBarEventHandler(func) \
wxEVENT_HANDLER_CAST(wxRibbonToolBarEventFunction, func)
#define EVT_RIBBONTOOLBAR_CLICKED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONTOOLBAR_CLICKED, winid, wxRibbonToolBarEventHandler(fn))
#define EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_RIBBONTOOLBAR_DROPDOWN_CLICKED, winid, wxRibbonToolBarEventHandler(fn))
#else
// wxpython/swig event work
%constant wxEventType wxEVT_RIBBONTOOLBAR_CLICKED;
%constant wxEventType wxEVT_RIBBONTOOLBAR_DROPDOWN_CLICKED;
%pythoncode {
EVT_RIBBONTOOLBAR_CLICKED = wx.PyEventBinder( wxEVT_RIBBONTOOLBAR_CLICKED, 1 )
EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED = wx.PyEventBinder( wxEVT_RIBBONTOOLBAR_DROPDOWN_CLICKED, 1 )
}
#endif
// old wxEVT_COMMAND_* constants
#define wxEVT_COMMAND_RIBBONTOOL_CLICKED wxEVT_RIBBONTOOLBAR_CLICKED
#define wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED wxEVT_RIBBONTOOLBAR_DROPDOWN_CLICKED
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_TOOLBAR_H_