Allow customizing AUI tab colours in wxAuiTabArt.

Add wxAuiTabArt::SetColour() and SetActiveColour() methods and provide trivial
default implementation of them in wxAuiDefaultTabArt to allow customizing the
tab colours.

Closes #11411.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67428 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-04-10 15:36:03 +00:00
parent 4bd9bdf33b
commit ceb9b8db81
4 changed files with 65 additions and 6 deletions

View File

@@ -500,6 +500,7 @@ All (GUI):
panel backgrounds, especially on OS X. panel backgrounds, especially on OS X.
- Add WXK_CONTROL_A..WXK_CONTROL_Z constants (Jan van Dijk). - Add WXK_CONTROL_A..WXK_CONTROL_Z constants (Jan van Dijk).
- Add support for alpha channel in colours in wxSVGFileDC (snowleopard). - Add support for alpha channel in colours in wxSVGFileDC (snowleopard).
- Allow customizing AUI tab colours in wxAuiTabArt (snowleopard).
GTK: GTK:

View File

@@ -149,6 +149,8 @@ public:
virtual void SetNormalFont(const wxFont& font) = 0; virtual void SetNormalFont(const wxFont& font) = 0;
virtual void SetSelectedFont(const wxFont& font) = 0; virtual void SetSelectedFont(const wxFont& font) = 0;
virtual void SetMeasuringFont(const wxFont& font) = 0; virtual void SetMeasuringFont(const wxFont& font) = 0;
virtual void SetColour(const wxColour& colour) = 0;
virtual void SetActiveColour(const wxColour& colour) = 0;
virtual void DrawBackground( virtual void DrawBackground(
wxDC& dc, wxDC& dc,
@@ -212,6 +214,8 @@ public:
void SetNormalFont(const wxFont& font); void SetNormalFont(const wxFont& font);
void SetSelectedFont(const wxFont& font); void SetSelectedFont(const wxFont& font);
void SetMeasuringFont(const wxFont& font); void SetMeasuringFont(const wxFont& font);
void SetColour(const wxColour& colour);
void SetActiveColour(const wxColour& colour);
void DrawBackground( void DrawBackground(
wxDC& dc, wxDC& dc,
@@ -265,6 +269,7 @@ protected:
wxPen m_base_colour_pen; wxPen m_base_colour_pen;
wxPen m_border_pen; wxPen m_border_pen;
wxBrush m_base_colour_brush; wxBrush m_base_colour_brush;
wxColour m_active_colour;
wxBitmap m_active_close_bmp; wxBitmap m_active_close_bmp;
wxBitmap m_disabled_close_bmp; wxBitmap m_disabled_close_bmp;
wxBitmap m_active_left_bmp; wxBitmap m_active_left_bmp;
@@ -297,6 +302,8 @@ public:
void SetNormalFont(const wxFont& font); void SetNormalFont(const wxFont& font);
void SetSelectedFont(const wxFont& font); void SetSelectedFont(const wxFont& font);
void SetMeasuringFont(const wxFont& font); void SetMeasuringFont(const wxFont& font);
void SetColour(const wxColour& colour);
void SetActiveColour(const wxColour& colour);
void DrawBackground( void DrawBackground(
wxDC& dc, wxDC& dc,
@@ -404,6 +411,8 @@ public:
void SetNormalFont(const wxFont& normal_font); void SetNormalFont(const wxFont& normal_font);
void SetSelectedFont(const wxFont& selected_font); void SetSelectedFont(const wxFont& selected_font);
void SetMeasuringFont(const wxFont& measuring_font); void SetMeasuringFont(const wxFont& measuring_font);
void SetColour(const wxColour& colour);
void SetActiveColour(const wxColour& colour);
void DoShowHide(); void DoShowHide();
void SetRect(const wxRect& rect); void SetRect(const wxRect& rect);

View File

@@ -340,6 +340,20 @@ public:
*/ */
virtual void SetSelectedFont(const wxFont& font) = 0; virtual void SetSelectedFont(const wxFont& font) = 0;
/**
Sets the colour of the inactive tabs.
@since 2.9.2
*/
virtual void SetColour(const wxColour& colour) = 0;
/**
Sets the colour of the selected tab.
@since 2.9.2
*/
virtual void SetActiveColour(const wxColour& colour) = 0;
/** /**
Sets sizing information. Sets sizing information.
*/ */

View File

@@ -206,6 +206,7 @@ wxAuiDefaultTabArt::wxAuiDefaultTabArt()
base_colour = base_colour.ChangeLightness(92); base_colour = base_colour.ChangeLightness(92);
} }
m_active_colour = base_colour;
m_base_colour = base_colour; m_base_colour = base_colour;
wxColor border_colour = base_colour.ChangeLightness(75); wxColor border_colour = base_colour.ChangeLightness(75);
@@ -438,8 +439,8 @@ void wxAuiDefaultTabArt::DrawTab(wxDC& dc,
// draw base background color // draw base background color
wxRect r(tab_x, tab_y, tab_width, tab_height); wxRect r(tab_x, tab_y, tab_width, tab_height);
dc.SetPen(m_base_colour_pen); dc.SetPen(wxPen(m_active_colour));
dc.SetBrush(m_base_colour_brush); dc.SetBrush(wxBrush(m_active_colour));
dc.DrawRectangle(r.x+1, r.y+1, r.width-1, r.height-4); dc.DrawRectangle(r.x+1, r.y+1, r.width-1, r.height-4);
// this white helps fill out the gradient at the top of the tab // this white helps fill out the gradient at the top of the tab
@@ -448,7 +449,7 @@ void wxAuiDefaultTabArt::DrawTab(wxDC& dc,
dc.DrawRectangle(r.x+2, r.y+1, r.width-3, r.height-4); dc.DrawRectangle(r.x+2, r.y+1, r.width-3, r.height-4);
// these two points help the rounded corners appear more antialiased // these two points help the rounded corners appear more antialiased
dc.SetPen(m_base_colour_pen); dc.SetPen(wxPen(m_active_colour));
dc.DrawPoint(r.x+2, r.y+1); dc.DrawPoint(r.x+2, r.y+1);
dc.DrawPoint(r.x+r.width-2, r.y+1); dc.DrawPoint(r.x+r.width-2, r.y+1);
@@ -461,7 +462,7 @@ void wxAuiDefaultTabArt::DrawTab(wxDC& dc,
// draw gradient background // draw gradient background
wxColor top_color = *wxWHITE; wxColor top_color = *wxWHITE;
wxColor bottom_color = m_base_colour; wxColor bottom_color = m_active_colour;
dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH); dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH);
} }
else else
@@ -831,6 +832,18 @@ void wxAuiDefaultTabArt::SetMeasuringFont(const wxFont& font)
m_measuring_font = font; m_measuring_font = font;
} }
void wxAuiDefaultTabArt::SetColour(const wxColour& colour)
{
m_base_colour = colour;
m_border_pen = wxPen(m_base_colour.ChangeLightness(75));
m_base_colour_pen = wxPen(m_base_colour);
m_base_colour_brush = wxBrush(m_base_colour);
}
void wxAuiDefaultTabArt::SetActiveColour(const wxColour& colour)
{
m_active_colour = colour;
}
// -- wxAuiSimpleTabArt class implementation -- // -- wxAuiSimpleTabArt class implementation --
@@ -876,10 +889,9 @@ wxAuiSimpleTabArt::~wxAuiSimpleTabArt()
wxAuiTabArt* wxAuiSimpleTabArt::Clone() wxAuiTabArt* wxAuiSimpleTabArt::Clone()
{ {
return static_cast<wxAuiTabArt*>(new wxAuiSimpleTabArt); return new wxAuiSimpleTabArt(*this);
} }
void wxAuiSimpleTabArt::SetFlags(unsigned int flags) void wxAuiSimpleTabArt::SetFlags(unsigned int flags)
{ {
m_flags = flags; m_flags = flags;
@@ -913,6 +925,19 @@ void wxAuiSimpleTabArt::SetSizingInfo(const wxSize& tab_ctrl_size,
m_fixed_tab_width = 220; m_fixed_tab_width = 220;
} }
void wxAuiSimpleTabArt::SetColour(const wxColour& colour)
{
m_bkbrush = wxBrush(colour);
m_normal_bkbrush = wxBrush(colour);
m_normal_bkpen = wxPen(colour);
}
void wxAuiSimpleTabArt::SetActiveColour(const wxColour& colour)
{
m_selected_bkbrush = wxBrush(colour);
m_selected_bkpen = wxPen(colour);
}
void wxAuiSimpleTabArt::DrawBackground(wxDC& dc, void wxAuiSimpleTabArt::DrawBackground(wxDC& dc,
wxWindow* WXUNUSED(wnd), wxWindow* WXUNUSED(wnd),
const wxRect& rect) const wxRect& rect)
@@ -1365,6 +1390,16 @@ void wxAuiTabContainer::SetMeasuringFont(const wxFont& font)
m_art->SetMeasuringFont(font); m_art->SetMeasuringFont(font);
} }
void wxAuiTabContainer::SetColour(const wxColour& colour)
{
m_art->SetColour(colour);
}
void wxAuiTabContainer::SetActiveColour(const wxColour& colour)
{
m_art->SetActiveColour(colour);
}
void wxAuiTabContainer::SetRect(const wxRect& rect) void wxAuiTabContainer::SetRect(const wxRect& rect)
{ {
m_rect = rect; m_rect = rect;