Merged GSOC Ribbon work from SOC2009_RIBBON branch into trunk.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61944 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Peter Cawley
2009-09-16 12:06:02 +00:00
parent 1a2df6a75b
commit 3c3ead1d15
126 changed files with 25113 additions and 251 deletions

867
include/wx/ribbon/art.h Normal file
View File

@@ -0,0 +1,867 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/art.h
// Purpose: Art providers for ribbon-bar-style interface
// Author: Peter Cawley
// Modified by:
// Created: 2009-05-25
// RCS-ID: $Id$
// 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/pen.h>
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_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_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_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,
};
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,
};
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_STATE_MASK = 0xF8,
};
enum wxRibbonGalleryButtonState
{
wxRIBBON_GALLERY_BUTTON_NORMAL,
wxRIBBON_GALLERY_BUTTON_HOVERED,
wxRIBBON_GALLERY_BUTTON_ACTIVE,
wxRIBBON_GALLERY_BUTTON_DISABLED,
};
class wxRibbonPage;
class wxRibbonPanel;
class wxRibbonGallery;
class wxRibbonGalleryItem;
class wxRibbonPageTabInfo;
class wxRibbonPageTabInfoArray;
class WXDLLIMPEXP_RIBBON wxRibbonArtProvider
{
public:
wxRibbonArtProvider();
virtual ~wxRibbonArtProvider();
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 GetBarTabWidth(
wxDC& 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(
wxDC& dc,
wxWindow* wnd,
const wxRibbonPageTabInfoArray& pages) = 0;
virtual wxSize GetScrollButtonMinimumSize(
wxDC& dc,
wxWindow* wnd,
long style) = 0;
virtual wxSize GetPanelSize(
wxDC& dc,
const wxRibbonPanel* wnd,
wxSize client_size,
wxPoint* client_offset) = 0;
virtual wxSize GetPanelClientSize(
wxDC& dc,
const wxRibbonPanel* wnd,
wxSize size,
wxPoint* client_offset) = 0;
virtual wxSize GetGallerySize(
wxDC& dc,
const wxRibbonGallery* wnd,
wxSize client_size) = 0;
virtual wxSize GetGalleryClientSize(
wxDC& dc,
const wxRibbonGallery* wnd,
wxSize size,
wxPoint* client_offset,
wxRect* scroll_up_button,
wxRect* scroll_down_button,
wxRect* extension_button) = 0;
virtual wxRect GetPageBackgroundRedrawArea(
wxDC& dc,
const wxRibbonPage* wnd,
wxSize page_old_size,
wxSize page_new_size) = 0;
virtual bool GetButtonBarButtonSize(
wxDC& dc,
wxWindow* wnd,
wxRibbonButtonKind kind,
wxRibbonButtonBarButtonState size,
const wxString& label,
wxSize bitmap_size_large,
wxSize bitmap_size_small,
wxSize* button_size,
wxRect* normal_region,
wxRect* dropdown_region) = 0;
virtual wxSize GetMinimisedPanelMinimumSize(
wxDC& dc,
const wxRibbonPanel* wnd,
wxSize* desired_bitmap_size,
wxDirection* expanded_panel_direction) = 0;
virtual wxSize GetToolSize(
wxDC& dc,
wxWindow* wnd,
wxSize bitmap_size,
wxRibbonButtonKind kind,
bool is_first,
bool is_last,
wxRect* dropdown_region) = 0;
};
class WXDLLIMPEXP_RIBBON wxRibbonMSWArtProvider : public wxRibbonArtProvider
{
public:
wxRibbonMSWArtProvider(bool set_colour_scheme = true);
virtual ~wxRibbonMSWArtProvider();
wxRibbonArtProvider* Clone() const;
void SetFlags(long flags);
long GetFlags() const;
int GetMetric(int id) const;
void SetMetric(int id, int new_val);
void SetFont(int id, const wxFont& font);
wxFont GetFont(int id) const;
wxColour GetColour(int id) const;
void SetColour(int id, const wxColor& colour);
void GetColourScheme(wxColour* primary,
wxColour* secondary,
wxColour* tertiary) const;
void SetColourScheme(const wxColour& primary,
const wxColour& secondary,
const wxColour& tertiary);
int GetTabCtrlHeight(
wxDC& dc,
wxWindow* wnd,
const wxRibbonPageTabInfoArray& pages);
void DrawTabCtrlBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
void DrawTab(wxDC& dc,
wxWindow* wnd,
const wxRibbonPageTabInfo& tab);
void DrawTabSeparator(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
double visibility);
void DrawPageBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
void DrawScrollButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
long style);
void DrawPanelBackground(
wxDC& dc,
wxRibbonPanel* wnd,
const wxRect& rect);
void DrawGalleryBackground(
wxDC& dc,
wxRibbonGallery* wnd,
const wxRect& rect);
void DrawGalleryItemBackground(
wxDC& dc,
wxRibbonGallery* wnd,
const wxRect& rect,
wxRibbonGalleryItem* item);
void DrawMinimisedPanel(
wxDC& dc,
wxRibbonPanel* wnd,
const wxRect& rect,
wxBitmap& bitmap);
void DrawButtonBarBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
void DrawButtonBarButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
wxRibbonButtonKind kind,
long state,
const wxString& label,
const wxBitmap& bitmap_large,
const wxBitmap& bitmap_small);
void DrawToolBarBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
void DrawToolGroupBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
void DrawTool(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
const wxBitmap& bitmap,
wxRibbonButtonKind kind,
long state);
void GetBarTabWidth(
wxDC& dc,
wxWindow* wnd,
const wxString& label,
const wxBitmap& bitmap,
int* ideal,
int* small_begin_need_separator,
int* small_must_have_separator,
int* minimum);
wxSize GetScrollButtonMinimumSize(
wxDC& dc,
wxWindow* wnd,
long style);
wxSize GetPanelSize(
wxDC& dc,
const wxRibbonPanel* wnd,
wxSize client_size,
wxPoint* client_offset);
wxSize GetPanelClientSize(
wxDC& dc,
const wxRibbonPanel* wnd,
wxSize size,
wxPoint* client_offset);
wxSize GetGallerySize(
wxDC& dc,
const wxRibbonGallery* wnd,
wxSize client_size);
wxSize GetGalleryClientSize(
wxDC& dc,
const wxRibbonGallery* wnd,
wxSize size,
wxPoint* client_offset,
wxRect* scroll_up_button,
wxRect* scroll_down_button,
wxRect* extension_button);
wxRect GetPageBackgroundRedrawArea(
wxDC& dc,
const wxRibbonPage* wnd,
wxSize page_old_size,
wxSize page_new_size);
bool GetButtonBarButtonSize(
wxDC& dc,
wxWindow* wnd,
wxRibbonButtonKind kind,
wxRibbonButtonBarButtonState size,
const wxString& label,
wxSize bitmap_size_large,
wxSize bitmap_size_small,
wxSize* button_size,
wxRect* normal_region,
wxRect* dropdown_region);
wxSize GetMinimisedPanelMinimumSize(
wxDC& dc,
const wxRibbonPanel* wnd,
wxSize* desired_bitmap_size,
wxDirection* expanded_panel_direction);
wxSize GetToolSize(
wxDC& dc,
wxWindow* wnd,
wxSize bitmap_size,
wxRibbonButtonKind kind,
bool is_first,
bool is_last,
wxRect* dropdown_region);
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;
wxColour m_primary_scheme_colour;
wxColour m_secondary_scheme_colour;
wxColour m_tertiary_scheme_colour;
wxColour m_button_bar_label_colour;
wxColour m_tab_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_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_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_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;
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_minimised_border_pen;
wxPen m_panel_minimised_border_gradient_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;
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;
};
class WXDLLIMPEXP_RIBBON wxRibbonAUIArtProvider : public wxRibbonMSWArtProvider
{
public:
wxRibbonAUIArtProvider();
virtual ~wxRibbonAUIArtProvider();
wxRibbonArtProvider* Clone() const;
wxColour GetColour(int id) const;
void SetColour(int id, const wxColor& colour);
void SetColourScheme(const wxColour& primary,
const wxColour& secondary,
const wxColour& tertiary);
void SetFont(int id, const wxFont& font);
wxSize GetScrollButtonMinimumSize(
wxDC& dc,
wxWindow* wnd,
long style);
void DrawScrollButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
long style);
wxSize GetPanelSize(
wxDC& dc,
const wxRibbonPanel* wnd,
wxSize client_size,
wxPoint* client_offset);
wxSize GetPanelClientSize(
wxDC& dc,
const wxRibbonPanel* wnd,
wxSize size,
wxPoint* client_offset);
void DrawTabCtrlBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
int GetTabCtrlHeight(
wxDC& dc,
wxWindow* wnd,
const wxRibbonPageTabInfoArray& pages);
void GetBarTabWidth(
wxDC& dc,
wxWindow* wnd,
const wxString& label,
const wxBitmap& bitmap,
int* ideal,
int* small_begin_need_separator,
int* small_must_have_separator,
int* minimum);
void DrawTab(wxDC& dc,
wxWindow* wnd,
const wxRibbonPageTabInfo& tab);
void DrawTabSeparator(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
double visibility);
void DrawPageBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
void DrawPanelBackground(
wxDC& dc,
wxRibbonPanel* wnd,
const wxRect& rect);
void DrawMinimisedPanel(
wxDC& dc,
wxRibbonPanel* wnd,
const wxRect& rect,
wxBitmap& bitmap);
void DrawGalleryBackground(
wxDC& dc,
wxRibbonGallery* wnd,
const wxRect& rect);
void DrawGalleryItemBackground(
wxDC& dc,
wxRibbonGallery* wnd,
const wxRect& rect,
wxRibbonGalleryItem* item);
void DrawButtonBarBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
void DrawButtonBarButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
wxRibbonButtonKind kind,
long state,
const wxString& label,
const wxBitmap& bitmap_large,
const wxBitmap& bitmap_small);
void DrawToolBarBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
void DrawToolGroupBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
void DrawTool(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
const wxBitmap& bitmap,
wxRibbonButtonKind kind,
long state);
protected:
void DrawPartialPanelBackground(wxDC& dc, wxWindow* wnd,
const wxRect& rect);
void DrawGalleryButton(wxDC& dc, wxRect rect,
wxRibbonGalleryButtonState state, wxBitmap* bitmaps);
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_CARBON__) || \
defined(__WXOSX_COCOA__) || \
defined(__WXOSX_IPHONE__) || \
defined(__WXCOCOA__)
// 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,82 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/art_internal.h
// Purpose: Helper functions & classes used by ribbon art providers
// Author: Peter Cawley
// Modified by:
// Created: 2009-08-04
// RCS-ID: $Id$
// 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
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;
wxRibbonHSLColour& MakeDarker(float 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_

224
include/wx/ribbon/bar.h Normal file
View File

@@ -0,0 +1,224 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/bar.h
// Purpose: Top-level component of the ribbon-bar-style interface
// Author: Peter Cawley
// Modified by:
// Created: 2009-05-23
// RCS-ID: $Id$
// Copyright: (C) Peter Cawley
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RIBBON_BAR_H_
#define _WX_RIBBON_BAR_H_
#include "wx/defs.h"
#if wxUSE_RIBBON
#include "wx/ribbon/control.h"
#include "wx/ribbon/page.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_DEFAULT_STYLE = wxRIBBON_BAR_FLOW_HORIZONTAL
| wxRIBBON_BAR_SHOW_PAGE_LABELS
| wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS,
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,
};
class WXDLLIMPEXP_RIBBON wxRibbonBarEvent : public wxNotifyEvent
{
public:
wxRibbonBarEvent(wxEventType command_type = wxEVT_NULL,
int win_id = 0,
wxRibbonPage* page = NULL)
: wxNotifyEvent(command_type, win_id)
, m_page(page)
{
}
#ifndef SWIG
wxRibbonBarEvent(const wxRibbonBarEvent& c) : wxNotifyEvent(c)
{
m_page = c.m_page;
}
#endif
wxEvent *Clone() const { return new wxRibbonBarEvent(*this); }
wxRibbonPage* GetPage() {return m_page;}
void SetPage(wxRibbonPage* page) {m_page = page;}
protected:
wxRibbonPage* m_page;
#ifndef SWIG
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonBarEvent)
#endif
};
class WXDLLIMPEXP_RIBBON wxRibbonPageTabInfo
{
public:
wxRect rect;
wxRibbonPage *page;
int ideal_width;
int small_begin_need_separator_width;
int small_must_have_separator_width;
int minimum_width;
bool active;
bool hovered;
};
#ifndef SWIG
WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRibbonPageTabInfo, wxRibbonPageTabInfoArray, WXDLLIMPEXP_RIBBON);
#endif
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);
bool SetActivePage(size_t page);
bool SetActivePage(wxRibbonPage* page);
int GetActivePage() const;
wxRibbonPage* GetPage(int n);
bool DismissExpandedPanel();
virtual wxSize DoGetBestSize() const;
virtual bool HasMultiplePages() const { return true; }
void SetWindowStyleFlag(long style);
long GetWindowStyleFlag() const;
virtual bool Realize();
protected:
friend class wxRibbonPage;
wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
wxRibbonPageTabInfo* HitTestTabs(wxPoint position, int* index = NULL);
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 DoMouseButtonCommon(wxMouseEvent& evt, wxEventType tab_event_type);
wxRibbonPageTabInfoArray m_pages;
wxRect m_tab_scroll_left_button_rect;
wxRect m_tab_scroll_right_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;
#ifndef SWIG
DECLARE_CLASS(wxRibbonBar)
DECLARE_EVENT_TABLE()
#endif
};
#ifndef SWIG
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, wxRibbonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, 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_COMMAND_RIBBONBAR_PAGE_CHANGED, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_PAGE_CHANGING(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_TAB_MIDDLE_DOWN(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_TAB_MIDDLE_UP(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_TAB_RIGHT_DOWN(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, winid, wxRibbonBarEventHandler(fn))
#define EVT_RIBBONBAR_TAB_RIGHT_UP(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, winid, wxRibbonBarEventHandler(fn))
#else
// wxpython/swig event work
%constant wxEventType wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED;
%constant wxEventType wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING;
%constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN;
%constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP;
%constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN;
%constant wxEventType wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP;
%pythoncode {
EVT_RIBBONBAR_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, 1 )
EVT_RIBBONBAR_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, 1 )
EVT_RIBBONBAR_TAB_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, 1 )
EVT_RIBBONBAR_TAB_MIDDLE_UP = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, 1 )
EVT_RIBBONBAR_TAB_RIGHT_DOWN = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, 1 )
EVT_RIBBONBAR_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, 1 )
}
#endif
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_BAR_H_

View File

@@ -0,0 +1,194 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/buttonbar.h
// Purpose: Ribbon control similar to a tool bar
// Author: Peter Cawley
// Modified by:
// Created: 2009-07-01
// RCS-ID: $Id$
// 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 wxRibbonButtonBarButtonBase;
class wxRibbonButtonBarLayout;
class wxRibbonButtonBarButtonInstance;
WX_DEFINE_USER_EXPORTED_ARRAY(wxRibbonButtonBarLayout*, wxArrayRibbonButtonBarLayout, class WXDLLIMPEXP_RIBBON);
WX_DEFINE_USER_EXPORTED_ARRAY(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* 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,
wxObject* client_data = NULL);
virtual bool Realize();
virtual void ClearButtons();
virtual bool DeleteButton(int button_id);
virtual void EnableButton(int button_id, bool enable = true);
virtual void SetArtProvider(wxRibbonArtProvider* art);
virtual bool IsSizingContinuous() const;
virtual wxSize GetMinSize() const;
virtual wxSize DoGetBestSize() const;
protected:
friend class wxRibbonButtonBarEvent;
wxBorder GetDefaultBorder() const { 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;
virtual wxSize DoGetNextLargerSize(wxOrientation direction,
wxSize relative_to) const;
void CommonInit(long style);
void MakeLayouts();
bool TryCollapseLayout(wxRibbonButtonBarLayout* original, size_t first_btn, size_t* last_button);
static wxBitmap MakeResizedBitmap(const wxBitmap& original, wxSize size);
static wxBitmap MakeDisabledBitmap(const wxBitmap& original);
void FetchButtonSizeInfo(wxRibbonButtonBarButtonBase* button,
wxRibbonButtonBarButtonState size, wxDC& dc);
wxArrayRibbonButtonBarLayout m_layouts;
wxArrayRibbonButtonBarButtonBase m_buttons;
wxRibbonButtonBarButtonInstance* m_hovered_button;
wxRibbonButtonBarButtonInstance* m_active_button;
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;
#ifndef SWIG
DECLARE_CLASS(wxRibbonButtonBar)
DECLARE_EVENT_TABLE()
#endif
};
class WXDLLIMPEXP_RIBBON wxRibbonButtonBarEvent : public wxCommandEvent
{
public:
wxRibbonButtonBarEvent(wxEventType command_type = wxEVT_NULL,
int win_id = 0,
wxRibbonButtonBar* bar = NULL)
: wxCommandEvent(command_type, win_id)
, m_bar(bar)
{
}
#ifndef SWIG
wxRibbonButtonBarEvent(const wxRibbonButtonBarEvent& e) : wxCommandEvent(e)
{
m_bar = e.m_bar;
}
#endif
wxEvent *Clone() const { return new wxRibbonButtonBarEvent(*this); }
wxRibbonButtonBar* GetBar() {return m_bar;}
void SetBar(wxRibbonButtonBar* bar) {m_bar = bar;}
bool PopupMenu(wxMenu* menu);
protected:
wxRibbonButtonBar* m_bar;
#ifndef SWIG
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonButtonBarEvent)
#endif
};
#ifndef SWIG
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, wxRibbonButtonBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONBUTTON_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_COMMAND_RIBBONBUTTON_CLICKED, winid, wxRibbonButtonBarEventHandler(fn))
#define EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED, winid, wxRibbonButtonBarEventHandler(fn))
#else
// wxpython/swig event work
%constant wxEventType wxEVT_COMMAND_RIBBONBUTTON_CLICKED;
%constant wxEventType wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED;
%pythoncode {
EVT_RIBBONBUTTONBAR_CLICKED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBUTTON_CLICKED, 1 )
EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED, 1 )
}
#endif
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_BUTTON_BAR_H_

View File

@@ -0,0 +1,64 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/control.h
// Purpose: Extension of wxControl with common ribbon methods
// Author: Peter Cawley
// Modified by:
// Created: 2009-06-05
// RCS-ID: $Id$
// 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 wxRibbonArtProvider;
class WXDLLIMPEXP_RIBBON wxRibbonControl : public wxControl
{
public:
wxRibbonControl() { m_art = NULL; }
wxRibbonControl(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = 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();}
protected:
wxRibbonArtProvider* m_art;
virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
wxSize relative_to) const;
virtual wxSize DoGetNextLargerSize(wxOrientation direction,
wxSize relative_to) const;
#ifndef SWIG
DECLARE_CLASS(wxRibbonControl)
#endif
};
WX_DEFINE_USER_EXPORTED_ARRAY(wxRibbonControl*, wxArrayRibbonControl, class WXDLLIMPEXP_RIBBON);
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_CONTROL_H_

186
include/wx/ribbon/gallery.h Normal file
View File

@@ -0,0 +1,186 @@
///////////////////////////////////////////////////////////////////////////////
// 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
// RCS-ID: $Id$
// 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(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;
virtual bool Realize();
virtual bool Layout();
virtual bool ScrollLines(int lines);
void EnsureVisible(const wxRibbonGalleryItem* item);
protected:
wxBorder GetDefaultBorder() const { 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 OnPaint(wxPaintEvent& evt);
void OnSize(wxSizeEvent& evt);
virtual wxSize DoGetBestSize() const;
virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
wxSize relative_to) const;
virtual wxSize DoGetNextLargerSize(wxOrientation direction,
wxSize relative_to) const;
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
DECLARE_CLASS(wxRibbonGallery)
DECLARE_EVENT_TABLE()
#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
wxEvent *Clone() const { 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;
wxRibbonGalleryItem* m_item;
#ifndef SWIG
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonGalleryEvent)
#endif
};
#ifndef SWIG
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, wxRibbonGalleryEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONGALLERY_SELECTED, 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_COMMAND_RIBBONGALLERY_HOVER_CHANGED, winid, wxRibbonGalleryEventHandler(fn))
#define EVT_RIBBONGALLERY_SELECTED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONGALLERY_SELECTED, winid, wxRibbonGalleryEventHandler(fn))
#else
// wxpython/swig event work
%constant wxEventType wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED;
%constant wxEventType wxEVT_COMMAND_RIBBONGALLERY_SELECTED;
%pythoncode {
EVT_RIBBONGALLERY_HOVER_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, 1 )
EVT_RIBBONGALLERY_SELECTED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONGALLERY_SELECTED, 1 )
}
#endif
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_GALLERY_H_

99
include/wx/ribbon/page.h Normal file
View File

@@ -0,0 +1,99 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/page.h
// Purpose: Container for ribbon-bar-style interface panels
// Author: Peter Cawley
// Modified by:
// Created: 2009-05-25
// RCS-ID: $Id$
// 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);
wxBitmap& GetIcon() {return m_icon;}
virtual wxSize GetMinSize() const;
virtual wxSize DoGetBestSize() const;
void SetSizeWithScrollButtonAdjustment(int x, int y, int width, int height);
void AdjustRectToIncludeScrollButtons(wxRect* rect) const;
bool DismissExpandedPanel();
virtual bool Realize();
virtual bool Show(bool show = true);
virtual bool Layout();
virtual bool ScrollLines(int lines);
bool ScrollPixels(int pixels);
wxOrientation GetMajorAxis() const;
virtual void RemoveChild(wxWindowBase *child);
protected:
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
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);
void ShowScrollButtons();
void HideScrollButtons();
void CommonInit(const wxString& label, const wxBitmap& icon);
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;
wxRibbonPageScrollButton* m_scroll_right_btn;
int m_scroll_amount;
int m_scroll_amount_limit;
int m_size_in_major_axis_for_children;
bool m_scroll_buttons_visible;
#ifndef SWIG
DECLARE_CLASS(wxRibbonPage)
DECLARE_EVENT_TABLE()
#endif
};
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_PAGE_H_

128
include/wx/ribbon/panel.h Normal file
View File

@@ -0,0 +1,128 @@
///////////////////////////////////////////////////////////////////////////////
// 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
// RCS-ID: $Id$
// 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_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 CanAutoMinimise() const;
bool ShowExpanded();
bool HideExpanded();
void SetArtProvider(wxRibbonArtProvider* art);
virtual bool Realize();
virtual bool Layout();
virtual wxSize GetMinSize() const;
virtual wxSize DoGetBestSize() const;
virtual bool IsSizingContinuous() const;
virtual void AddChild(wxWindowBase *child);
virtual void RemoveChild(wxWindowBase *child);
wxRibbonPanel* GetExpandedDummy();
wxRibbonPanel* GetExpandedPanel();
protected:
wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
wxSize GetMinNotMinimisedSize() const;
virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
wxSize relative_to) const;
virtual wxSize DoGetNextLargerSize(wxOrientation direction,
wxSize relative_to) const;
void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
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 OnKillFocus(wxFocusEvent& evt);
void OnChildKillFocus(wxFocusEvent& evt);
void TestPositionForHover(const wxPoint& pos);
bool ShouldSendEventToDummy(wxEvent& evt);
virtual bool TryAfter(wxEvent& evt);
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;
#ifndef SWIG
DECLARE_CLASS(wxRibbonPanel)
DECLARE_EVENT_TABLE()
#endif
};
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_PANEL_H_

189
include/wx/ribbon/toolbar.h Normal file
View File

@@ -0,0 +1,189 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/ribbon/toolbar.h
// Purpose: Ribbon-style tool bar
// Author: Peter Cawley
// Modified by:
// Created: 2009-07-06
// RCS-ID: $Id$
// 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(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_STATE_MASK = 0xF8,
};
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* 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 = NULL);
virtual wxRibbonToolBarToolBase* AddSeparator();
virtual bool Realize();
virtual void SetRows(int nMin, int nMax = -1);
virtual bool IsSizingContinuous() const;
virtual wxSize DoGetBestSize() const;
protected:
friend class wxRibbonToolBarEvent;
wxBorder GetDefaultBorder() const { 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;
virtual wxSize DoGetNextLargerSize(wxOrientation direction,
wxSize relative_to) const;
void CommonInit(long style);
void AppendGroup();
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
DECLARE_CLASS(wxRibbonToolBar)
DECLARE_EVENT_TABLE()
#endif
};
class WXDLLIMPEXP_RIBBON wxRibbonToolBarEvent : public wxCommandEvent
{
public:
wxRibbonToolBarEvent(wxEventType command_type = wxEVT_NULL,
int win_id = 0,
wxRibbonToolBar* bar = NULL)
: wxCommandEvent(command_type, win_id)
, m_bar(bar)
{
}
#ifndef SWIG
wxRibbonToolBarEvent(const wxRibbonToolBarEvent& e) : wxCommandEvent(e)
{
m_bar = e.m_bar;
}
#endif
wxEvent *Clone() const { 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:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonToolBarEvent)
#endif
};
#ifndef SWIG
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONTOOL_CLICKED, wxRibbonToolBarEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONTOOL_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_COMMAND_RIBBONTOOL_CLICKED, winid, wxRibbonToolBarEventHandler(fn))
#define EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED, winid, wxRibbonToolBarEventHandler(fn))
#else
// wxpython/swig event work
%constant wxEventType wxEVT_COMMAND_RIBBONTOOL_CLICKED;
%constant wxEventType wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED;
%pythoncode {
EVT_RIBBONTOOLBAR_CLICKED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONTOOL_CLICKED, 1 )
EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED, 1 )
}
#endif
#endif // wxUSE_RIBBON
#endif // _WX_RIBBON_TOOLBAR_H_