From b0d17f7c3ff665838417945b661b2f5076a80622 Mon Sep 17 00:00:00 2001 From: Benjamin Williams Date: Tue, 7 Nov 2006 08:10:16 +0000 Subject: [PATCH] new default theme for wxAuiNotebook git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43146 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/aui/auibook.h | 122 +++++- samples/aui/auidemo.cpp | 57 ++- src/aui/auibook.cpp | 858 +++++++++++++++++++++++++++++++++------ 3 files changed, 887 insertions(+), 150 deletions(-) diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index 54048a9955..0dd02f4644 100644 --- a/include/wx/aui/auibook.h +++ b/include/wx/aui/auibook.h @@ -39,11 +39,12 @@ enum wxAuiNotebookOption wxAUI_NB_TAB_SPLIT = 1 << 4, wxAUI_NB_TAB_MOVE = 1 << 5, wxAUI_NB_TAB_EXTERNAL_MOVE = 1 << 6, - wxAUI_NB_SCROLL_BUTTONS = 1 << 7, - wxAUI_NB_WINDOWLIST_BUTTON = 1 << 8, - wxAUI_NB_CLOSE_BUTTON = 1 << 9, - wxAUI_NB_CLOSE_ON_ACTIVE_TAB = 1 << 10, - wxAUI_NB_CLOSE_ON_ALL_TABS = 1 << 11, + wxAUI_NB_TAB_FIXED_WIDTH = 1 << 7, + wxAUI_NB_SCROLL_BUTTONS = 1 << 8, + wxAUI_NB_WINDOWLIST_BUTTON = 1 << 9, + wxAUI_NB_CLOSE_BUTTON = 1 << 10, + wxAUI_NB_CLOSE_ON_ACTIVE_TAB = 1 << 11, + wxAUI_NB_CLOSE_ON_ALL_TABS = 1 << 12, wxAUI_NB_DEFAULT_STYLE = wxAUI_NB_TOP | @@ -56,7 +57,6 @@ enum wxAuiNotebookOption - // tab art class class WXDLLIMPEXP_AUI wxAuiTabArt @@ -66,6 +66,12 @@ public: wxAuiTabArt() { } virtual ~wxAuiTabArt() { } + virtual wxAuiTabArt* Clone() = 0; + virtual void SetFlags(unsigned int flags) = 0; + + virtual void SetSizingInfo(const wxSize& tab_ctrl_size, + size_t tab_count) = 0; + virtual void SetNormalFont(const wxFont& font) = 0; virtual void SetSelectedFont(const wxFont& font) = 0; virtual void SetMeasuringFont(const wxFont& font) = 0; @@ -94,7 +100,9 @@ public: int orientation, const wxBitmap& bitmap_override, wxRect* out_rect) = 0; - + + virtual int GetIndentSize() = 0; + virtual wxSize GetTabSize( wxDC& dc, wxWindow* wnd, @@ -112,6 +120,90 @@ public: }; +class WXDLLIMPEXP_AUI wxAuiSimpleTabArt : public wxAuiTabArt +{ + +public: + + wxAuiSimpleTabArt(); + virtual ~wxAuiSimpleTabArt(); + + wxAuiTabArt* Clone(); + void SetFlags(unsigned int flags); + + void SetSizingInfo(const wxSize& tab_ctrl_size, + size_t tab_count); + + void SetNormalFont(const wxFont& font); + void SetSelectedFont(const wxFont& font); + void SetMeasuringFont(const wxFont& font); + + void DrawBackground( + wxDC& dc, + wxWindow* wnd, + const wxRect& rect); + + void DrawTab(wxDC& dc, + wxWindow* wnd, + const wxRect& in_rect, + const wxString& caption, + bool active, + int close_button_state, + wxRect* out_tab_rect, + wxRect* out_button_rect, + int* x_extent); + + void DrawButton( + wxDC& dc, + wxWindow* wnd, + const wxRect& in_rect, + int bitmap_id, + int button_state, + int orientation, + const wxBitmap& bitmap_override, + wxRect* out_rect); + + int GetIndentSize(); + + wxSize GetTabSize( + wxDC& dc, + wxWindow* wnd, + const wxString& caption, + bool active, + int close_button_state, + int* x_extent); + + int ShowWindowList( + wxWindow* wnd, + const wxArrayString& items, + int active_idx); + + int GetBestTabCtrlSize(wxWindow* wnd); + +private: + + wxFont m_normal_font; + wxFont m_selected_font; + wxFont m_measuring_font; + wxPen m_normal_bkpen; + wxPen m_selected_bkpen; + wxBrush m_normal_bkbrush; + wxBrush m_selected_bkbrush; + wxBrush m_bkbrush; + wxBitmap m_active_close_bmp; + wxBitmap m_disabled_close_bmp; + wxBitmap m_active_left_bmp; + wxBitmap m_disabled_left_bmp; + wxBitmap m_active_right_bmp; + wxBitmap m_disabled_right_bmp; + wxBitmap m_active_windowlist_bmp; + wxBitmap m_disabled_windowlist_bmp; + + int m_fixed_tab_width; + unsigned int m_flags; +}; + + class WXDLLIMPEXP_AUI wxAuiDefaultTabArt : public wxAuiTabArt { @@ -120,16 +212,20 @@ public: wxAuiDefaultTabArt(); virtual ~wxAuiDefaultTabArt(); - void SetWindow(wxWindow* wnd); + wxAuiTabArt* Clone(); + void SetFlags(unsigned int flags); + void SetSizingInfo(const wxSize& tab_ctrl_size, + size_t tab_count); + void SetNormalFont(const wxFont& font); void SetSelectedFont(const wxFont& font); void SetMeasuringFont(const wxFont& font); - + void DrawBackground( wxDC& dc, wxWindow* wnd, const wxRect& rect); - + void DrawTab(wxDC& dc, wxWindow* wnd, const wxRect& in_rect, @@ -149,6 +245,8 @@ public: int orientation, const wxBitmap& bitmap_override, wxRect* out_rect); + + int GetIndentSize(); wxSize GetTabSize( wxDC& dc, @@ -183,10 +281,14 @@ private: wxBitmap m_disabled_right_bmp; wxBitmap m_active_windowlist_bmp; wxBitmap m_disabled_windowlist_bmp; + + int m_fixed_tab_width; + unsigned int m_flags; }; + // event declarations/classes class WXDLLIMPEXP_AUI wxAuiNotebookEvent : public wxNotifyEvent diff --git a/samples/aui/auidemo.cpp b/samples/aui/auidemo.cpp index dec7f39bdd..00986a204b 100644 --- a/samples/aui/auidemo.cpp +++ b/samples/aui/auidemo.cpp @@ -94,6 +94,9 @@ class MyFrame : public wxFrame ID_NotebookAllowTabSplit, ID_NotebookWindowList, ID_NotebookScrollButtons, + ID_NotebookTabFixedWidth, + ID_NotebookArtGloss, + ID_NotebookArtSimple, ID_FirstPerspective = ID_CreatePerspective+1000 }; @@ -155,6 +158,7 @@ private: wxArrayString m_perspectives; wxMenu* m_perspectives_menu; long m_notebook_style; + long m_notebook_theme; DECLARE_EVENT_TABLE() }; @@ -575,6 +579,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(ID_NoVenetianFade, MyFrame::OnManagerFlag) EVT_MENU(ID_TransparentDrag, MyFrame::OnManagerFlag) EVT_MENU(ID_AllowActivePane, MyFrame::OnManagerFlag) + EVT_MENU(ID_NotebookTabFixedWidth, MyFrame::OnNotebookFlag) EVT_MENU(ID_NotebookNoCloseButton, MyFrame::OnNotebookFlag) EVT_MENU(ID_NotebookCloseButton, MyFrame::OnNotebookFlag) EVT_MENU(ID_NotebookCloseButtonAll, MyFrame::OnNotebookFlag) @@ -584,6 +589,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(ID_NotebookAllowTabSplit, MyFrame::OnNotebookFlag) EVT_MENU(ID_NotebookScrollButtons, MyFrame::OnNotebookFlag) EVT_MENU(ID_NotebookWindowList, MyFrame::OnNotebookFlag) + EVT_MENU(ID_NotebookArtGloss, MyFrame::OnNotebookFlag) + EVT_MENU(ID_NotebookArtSimple, MyFrame::OnNotebookFlag) EVT_MENU(ID_NoGradient, MyFrame::OnGradient) EVT_MENU(ID_VerticalGradient, MyFrame::OnGradient) EVT_MENU(ID_HorizontalGradient, MyFrame::OnGradient) @@ -596,6 +603,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(ID_NotebookContent, MyFrame::OnChangeContentPane) EVT_MENU(wxID_EXIT, MyFrame::OnExit) EVT_MENU(wxID_ABOUT, MyFrame::OnAbout) + EVT_UPDATE_UI(ID_NotebookTabFixedWidth, MyFrame::OnUpdateUI) EVT_UPDATE_UI(ID_NotebookNoCloseButton, MyFrame::OnUpdateUI) EVT_UPDATE_UI(ID_NotebookCloseButton, MyFrame::OnUpdateUI) EVT_UPDATE_UI(ID_NotebookCloseButtonAll, MyFrame::OnUpdateUI) @@ -640,7 +648,8 @@ MyFrame::MyFrame(wxWindow* parent, // set up default notebook style m_notebook_style = wxAUI_NB_DEFAULT_STYLE | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER; - + m_notebook_theme = 0; + // create menu wxMenuBar* mb = new wxMenuBar; @@ -681,6 +690,9 @@ MyFrame::MyFrame(wxWindow* parent, options_menu->Append(ID_Settings, _("Settings Pane")); wxMenu* notebook_menu = new wxMenu; + notebook_menu->AppendRadioItem(ID_NotebookArtGloss, _("Glossy Theme (Default)")); + notebook_menu->AppendRadioItem(ID_NotebookArtSimple, _("Simple Theme")); + notebook_menu->AppendSeparator(); notebook_menu->AppendRadioItem(ID_NotebookNoCloseButton, _("No Close Button")); notebook_menu->AppendRadioItem(ID_NotebookCloseButton, _("Close Button at Right")); notebook_menu->AppendRadioItem(ID_NotebookCloseButtonAll, _("Close Button on All Tabs")); @@ -691,6 +703,7 @@ MyFrame::MyFrame(wxWindow* parent, notebook_menu->AppendCheckItem(ID_NotebookAllowTabSplit, _("Allow Notebook Split")); notebook_menu->AppendCheckItem(ID_NotebookScrollButtons, _("Scroll Buttons Visible")); notebook_menu->AppendCheckItem(ID_NotebookWindowList, _("Window List Button Visible")); + notebook_menu->AppendCheckItem(ID_NotebookTabFixedWidth, _("Fixed-width Tabs")); m_perspectives_menu = new wxMenu; m_perspectives_menu->Append(ID_CreatePerspective, _("Create Perspective")); @@ -1069,19 +1082,35 @@ void MyFrame::OnNotebookFlag(wxCommandEvent& event) { m_notebook_style ^= wxAUI_NB_SCROLL_BUTTONS; } - - - + else if (id == ID_NotebookTabFixedWidth) + { + m_notebook_style ^= wxAUI_NB_TAB_FIXED_WIDTH; + } + + size_t i, count; wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes(); for (i = 0, count = all_panes.GetCount(); i < count; ++i) { wxAuiPaneInfo& pane = all_panes.Item(i); - if (pane.window->IsKindOf(CLASSINFO(wxAuiNotebook))) { - pane.window->SetWindowStyleFlag(m_notebook_style); - pane.window->Refresh(); + wxAuiNotebook* nb = (wxAuiNotebook*)pane.window; + + if (id == ID_NotebookArtGloss) + { + nb->SetArtProvider(new wxAuiDefaultTabArt); + m_notebook_theme = 0; + } + else if (id == ID_NotebookArtSimple) + { + nb->SetArtProvider(new wxAuiSimpleTabArt); + m_notebook_theme = 1; + } + + + nb->SetWindowStyleFlag(m_notebook_style); + nb->Refresh(); } } @@ -1158,6 +1187,16 @@ void MyFrame::OnUpdateUI(wxUpdateUIEvent& event) case ID_NotebookWindowList: event.Check((m_notebook_style & wxAUI_NB_WINDOWLIST_BUTTON) != 0); break; + case ID_NotebookTabFixedWidth: + event.Check((m_notebook_style & wxAUI_NB_TAB_FIXED_WIDTH) != 0); + break; + case ID_NotebookArtGloss: + event.Check(m_notebook_style == 0); + break; + case ID_NotebookArtSimple: + event.Check(m_notebook_style == 1); + break; + } } @@ -1409,7 +1448,7 @@ wxAuiNotebook* MyFrame::CreateNotebook() wxSize(430,200), m_notebook_style); - ctrl->AddPage(CreateHTMLCtrl(ctrl), wxT("Welcome")); + ctrl->AddPage(CreateHTMLCtrl(ctrl), wxT("Welcome to wxAUI")); wxPanel *panel = new wxPanel( ctrl, wxID_ANY ); wxFlexGridSizer *flex = new wxFlexGridSizer( 2 ); @@ -1446,7 +1485,7 @@ wxAuiNotebook* MyFrame::CreateNotebook() wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 6") ); ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some more text"), - wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 7") ); + wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 7 (longer title)") ); ctrl->AddPage( new wxTextCtrl( ctrl, wxID_ANY, wxT("Some more text"), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER) , wxT("wxTextCtrl 8") ); diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index f82b57c986..dc55f5e985 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -75,11 +75,11 @@ static wxBitmap BitmapFromBits(const unsigned char bits[], int w, int h, return wxBitmap(img); } -static void DrawButtonS(wxDC& dc, - const wxRect& _rect, - const wxBitmap& bmp, - const wxColour& bkcolour, - int button_state) +static void DrawButtons(wxDC& dc, + const wxRect& _rect, + const wxBitmap& bmp, + const wxColour& bkcolour, + int button_state) { wxRect rect = _rect; @@ -103,19 +103,576 @@ static void DrawButtonS(wxDC& dc, dc.DrawBitmap(bmp, rect.x, rect.y, true); } +static void IndentPressedBitmap(wxRect* rect, int button_state) +{ + if (button_state == wxAUI_BUTTON_STATE_PRESSED) + { + rect->x++; + rect->y++; + } +} + +// chops the text so that it fits within |max_size| pixels. +// Also adds an elipsis if necessary + +static wxString ChopText(wxDC& dc, const wxString& text, int max_size) +{ + wxCoord x,y; + + // first check if the text fits with no problems + dc.GetTextExtent(text, &x, &y); + if (x <= max_size) + return text; + + size_t i, len = text.Length(); + size_t last_good_length = 0; + for (i = 0; i < len; ++i) + { + wxString s = text.Left(i); + s += wxT("..."); + + dc.GetTextExtent(s, &x, &y); + if (x > max_size) + break; + + last_good_length = i; + } + + wxString ret = text.Left(last_good_length); + ret += wxT("..."); + return ret; +} + + +// -- GUI helper classes and functions -- + +class wxAuiCommandCapture : public wxEvtHandler +{ +public: + + wxAuiCommandCapture() { m_last_id = 0; } + int GetCommandId() const { return m_last_id; } + + bool ProcessEvent(wxEvent& evt) + { + if (evt.GetEventType() == wxEVT_COMMAND_MENU_SELECTED) + { + m_last_id = evt.GetId(); + return true; + } + + if (GetNextHandler()) + return GetNextHandler()->ProcessEvent(evt); + + return false; + } + +private: + int m_last_id; +}; + + +// -- bitmaps -- + +#if defined( __WXMAC__ ) + static unsigned char close_bits[]={ + 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0x03, 0xF8, 0x01, 0xF0, 0x19, 0xF3, + 0xB8, 0xE3, 0xF0, 0xE1, 0xE0, 0xE0, 0xF0, 0xE1, 0xB8, 0xE3, 0x19, 0xF3, + 0x01, 0xF0, 0x03, 0xF8, 0x0F, 0xFE, 0xFF, 0xFF }; +#elif defined( __WXGTK__) + static unsigned char close_bits[]={ + 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xfb, 0xef, 0xdb, 0xed, 0x8b, 0xe8, + 0x1b, 0xec, 0x3b, 0xee, 0x1b, 0xec, 0x8b, 0xe8, 0xdb, 0xed, 0xfb, 0xef, + 0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; +#else + static unsigned char close_bits[]={ + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xfb,0xcf,0xf9, + 0x9f,0xfc,0x3f,0xfe,0x3f,0xfe,0x9f,0xfc,0xcf,0xf9,0xef,0xfb, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; +#endif + +static unsigned char left_bits[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x3f, 0xfe, + 0x1f, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x3f, 0xfe, 0x7f, 0xfe, 0xff, 0xfe, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + +static unsigned char right_bits[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x9f, 0xff, 0x1f, 0xff, + 0x1f, 0xfe, 0x1f, 0xfc, 0x1f, 0xfe, 0x1f, 0xff, 0x9f, 0xff, 0xdf, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + +static unsigned char list_bits[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x0f, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f, 0xfe, 0x7f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + + + + + +// -- wxAuiDefaultTabArt class implementation -- + +wxAuiDefaultTabArt::wxAuiDefaultTabArt() +{ + m_normal_font = *wxNORMAL_FONT; + m_selected_font = *wxNORMAL_FONT; + m_selected_font.SetWeight(wxBOLD); + m_measuring_font = m_selected_font; + + m_fixed_tab_width = 100; + + wxColour base_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); + + wxColour background_colour = base_colour; + wxColour normaltab_colour = base_colour; + wxColour selectedtab_colour = base_colour; + + m_bkbrush = wxBrush(background_colour); + m_normal_bkbrush = wxBrush(normaltab_colour); + m_normal_bkpen = wxPen(normaltab_colour); + m_selected_bkbrush = wxBrush(selectedtab_colour); + m_selected_bkpen = wxPen(selectedtab_colour); + + + m_active_close_bmp = BitmapFromBits(close_bits, 16, 16, *wxBLACK); + m_disabled_close_bmp = BitmapFromBits(close_bits, 16, 16, wxColour(128,128,128)); + + m_active_left_bmp = BitmapFromBits(left_bits, 16, 16, *wxBLACK); + m_disabled_left_bmp = BitmapFromBits(left_bits, 16, 16, wxColour(128,128,128)); + + m_active_right_bmp = BitmapFromBits(right_bits, 16, 16, *wxBLACK); + m_disabled_right_bmp = BitmapFromBits(right_bits, 16, 16, wxColour(128,128,128)); + + m_active_windowlist_bmp = BitmapFromBits(list_bits, 16, 16, *wxBLACK); + m_disabled_windowlist_bmp = BitmapFromBits(list_bits, 16, 16, wxColour(128,128,128)); + + m_flags = 0; +} + +wxAuiDefaultTabArt::~wxAuiDefaultTabArt() +{ +} + +wxAuiTabArt* wxAuiDefaultTabArt::Clone() +{ + return static_cast(new wxAuiDefaultTabArt); +} + +void wxAuiDefaultTabArt::SetFlags(unsigned int flags) +{ + m_flags = flags; +} + +void wxAuiDefaultTabArt::SetSizingInfo(const wxSize& tab_ctrl_size, + size_t tab_count) +{ + m_fixed_tab_width = 100; + + int tot_width = tab_ctrl_size.x; + if (tab_count > 0) + { + m_fixed_tab_width = tot_width/(int)tab_count; + } + + + if (m_fixed_tab_width < 100) + m_fixed_tab_width = 100; + + if (m_fixed_tab_width > tot_width/2) + m_fixed_tab_width = tot_width/2; + + if (m_fixed_tab_width > 220) + m_fixed_tab_width = 220; +} + + +void wxAuiDefaultTabArt::DrawBackground(wxDC& dc, + wxWindow* WXUNUSED(wnd), + const wxRect& rect) +{ + // draw background + dc.SetBrush(m_bkbrush); + dc.SetPen(*wxTRANSPARENT_PEN); + dc.DrawRectangle(-1, -1, rect.GetWidth()+2, rect.GetHeight()+2); + + // draw base lines + dc.SetPen(*wxGREY_PEN); + dc.DrawLine(0, rect.GetHeight()-4, rect.GetWidth(), rect.GetHeight()-4); + dc.DrawLine(0, rect.GetHeight()-1, rect.GetWidth(), rect.GetHeight()-1); +} + + +// DrawTab() draws an individual tab. +// +// dc - output dc +// in_rect - rectangle the tab should be confined to +// caption - tab's caption +// active - whether or not the tab is active +// out_rect - actual output rectangle +// x_extent - the advance x; where the next tab should start + +void wxAuiDefaultTabArt::DrawTab(wxDC& dc, + wxWindow* wnd, + const wxRect& in_rect, + const wxString& caption_text, + bool active, + int close_button_state, + wxRect* out_tab_rect, + wxRect* out_button_rect, + int* x_extent) +{ + wxCoord normal_textx, normal_texty; + wxCoord selected_textx, selected_texty; + wxCoord textx, texty; + + // if the caption is empty, measure some temporary text + wxString caption = caption_text; + if (caption_text.empty()) + caption = wxT("Xj"); + + dc.SetFont(m_selected_font); + dc.GetTextExtent(caption, &selected_textx, &selected_texty); + + dc.SetFont(m_normal_font); + dc.GetTextExtent(caption, &normal_textx, &normal_texty); + + // figure out the size of the tab + wxSize tab_size = GetTabSize(dc, wnd, caption, active, close_button_state, x_extent); + + wxCoord tab_height = tab_size.y; + wxCoord tab_width = tab_size.x; + wxCoord tab_x = in_rect.x; + wxCoord tab_y = in_rect.y + in_rect.height - tab_height; + + + //dc.SetClippingRegion(left_buttons_width, 0, + // m_rect.GetWidth() - right_buttons_width - left_buttons_width - 2, + // m_rect.GetHeight()); + + dc.SetClippingRegion(in_rect); + + + + // select pen, brush and font for the tab to be drawn + + if (active) + { + dc.SetPen(m_selected_bkpen); + dc.SetBrush(m_selected_bkbrush); + dc.SetFont(m_selected_font); + textx = selected_textx; + texty = selected_texty; + } + else + { + dc.SetPen(m_normal_bkpen); + dc.SetBrush(m_normal_bkbrush); + dc.SetFont(m_normal_font); + textx = normal_textx; + texty = normal_texty; + } + + + // -- create points that will make the tab outline -- + + wxPoint points[6]; + points[0].x = tab_x; + points[0].y = tab_y + tab_height - 4; + points[1].x = tab_x; + points[1].y = tab_y + 2; + points[2].x = tab_x + 2; + points[2].y = tab_y; + points[3].x = tab_x + tab_width - 2; + points[3].y = tab_y; + points[4].x = tab_x + tab_width; + points[4].y = tab_y + 2; + points[5].x = tab_x + tab_width; + points[5].y = tab_y + tab_height - 4; + + + // -- draw gradient background -- + if (active) + { + wxColour c = m_bkbrush.GetColour(); + dc.SetPen(wxPen(c)); + + int x, y, last_y = -1; + for (y = points[0].y; y > points[2].y; --y) + { + if (y < tab_y+(tab_height*3/5) && y != last_y) + { + last_y = y; + c = StepColour(c, 102); + dc.SetPen(wxPen(c)); + } + + for (x = points[0].x+1; x < points[5].x; ++x) + { + dc.DrawPoint(x,y); + } + } + } + + // -- draw tab outline -- + dc.SetPen(*wxGREY_PEN); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + dc.DrawPolygon(6, points); + + // -- there are two horizontal grey lines at the bottom of the tab control, + // this gets rid of the top one of those lines in the tab control -- + if (active) + { + wxColour c = m_bkbrush.GetColour(); + dc.SetPen(wxPen(c)); + dc.DrawLine(points[0].x+1, points[0].y, points[5].x, points[5].y); + } + + int text_offset; + + int close_button_width = 0; + + if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) + { + close_button_width = m_active_close_bmp.GetWidth(); + } + + text_offset = tab_x + 8; + + + wxString draw_text = ChopText(dc, + caption, + tab_width - (text_offset-tab_x) - close_button_width); + + // draw tab text + dc.DrawText(draw_text, + text_offset, + (tab_y + tab_height)/2 - (texty/2)); + + + + + // draw close button if necessary + if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) + { + wxBitmap bmp = m_disabled_close_bmp; + + if (close_button_state == wxAUI_BUTTON_STATE_HOVER || + close_button_state == wxAUI_BUTTON_STATE_PRESSED) + { + bmp = m_active_close_bmp; + } + + wxRect rect(tab_x + tab_width - close_button_width - 1, + tab_y + (tab_height/2) - (bmp.GetHeight()/2), + close_button_width, + tab_height); + IndentPressedBitmap(&rect, close_button_state); + dc.DrawBitmap(bmp, rect.x, rect.y, true); + + *out_button_rect = rect; + } + + *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height); + + dc.DestroyClippingRegion(); +} + +int wxAuiDefaultTabArt::GetIndentSize() +{ + return 5; +} + +wxSize wxAuiDefaultTabArt::GetTabSize(wxDC& dc, + wxWindow* WXUNUSED(wnd), + const wxString& caption, + bool WXUNUSED(active), + int close_button_state, + int* x_extent) +{ + wxCoord measured_textx, measured_texty, tmp; + + dc.SetFont(m_measuring_font); + dc.GetTextExtent(caption, &measured_textx, &measured_texty); + + dc.GetTextExtent(wxT("ABCDEFXj"), &tmp, &measured_texty); + + wxCoord tab_width = measured_textx + 5; + wxCoord tab_height = measured_texty + 10; + + if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) + tab_width += m_active_close_bmp.GetWidth() + 8; + + + if (m_flags & wxAUI_NB_TAB_FIXED_WIDTH) + { + tab_width = m_fixed_tab_width; + } + + *x_extent = tab_width; + + return wxSize(tab_width, tab_height); +} + + +void wxAuiDefaultTabArt::DrawButton(wxDC& dc, + wxWindow* WXUNUSED(wnd), + const wxRect& in_rect, + int bitmap_id, + int button_state, + int orientation, + const wxBitmap& bitmap_override, + wxRect* out_rect) +{ + wxBitmap bmp; + wxRect rect; + + if (bitmap_override.IsOk()) + { + bmp = bitmap_override; + } + else + { + switch (bitmap_id) + { + case wxAUI_BUTTON_CLOSE: + if (button_state & wxAUI_BUTTON_STATE_DISABLED) + bmp = m_disabled_close_bmp; + else + bmp = m_active_close_bmp; + break; + case wxAUI_BUTTON_LEFT: + if (button_state & wxAUI_BUTTON_STATE_DISABLED) + bmp = m_disabled_left_bmp; + else + bmp = m_active_left_bmp; + break; + case wxAUI_BUTTON_RIGHT: + if (button_state & wxAUI_BUTTON_STATE_DISABLED) + bmp = m_disabled_right_bmp; + else + bmp = m_active_right_bmp; + break; + case wxAUI_BUTTON_WINDOWLIST: + if (button_state & wxAUI_BUTTON_STATE_DISABLED) + bmp = m_disabled_windowlist_bmp; + else + bmp = m_active_windowlist_bmp; + break; + } + } + if (!bmp.IsOk()) + return; + + rect = in_rect; + + if (orientation == wxLEFT) + { + rect.SetX(in_rect.x); + rect.SetY(((in_rect.y + in_rect.height)/2) - (bmp.GetHeight()/2)); + rect.SetWidth(bmp.GetWidth()); + rect.SetHeight(bmp.GetHeight()); + } + else + { + rect = wxRect(in_rect.x + in_rect.width - bmp.GetWidth(), + ((in_rect.y + in_rect.height)/2) - (bmp.GetHeight()/2), + bmp.GetWidth(), bmp.GetHeight()); + } + + IndentPressedBitmap(&rect, button_state); + dc.DrawBitmap(bmp, rect.x, rect.y, true); + + *out_rect = rect; +} +int wxAuiDefaultTabArt::ShowWindowList(wxWindow* wnd, + const wxArrayString& items, + int active_idx) +{ + wxMenu menuPopup; -// -- wxAuiDefaultTabArt class implementation -- + size_t i, count = items.GetCount(); + for (i = 0; i < count; ++i) + { + menuPopup.AppendCheckItem(1000+i, items.Item(i)); + } + + if (active_idx != -1) + { + menuPopup.Check(1000+active_idx, true); + } + + // find out where to put the popup menu of window + // items. Subtract 100 for now to center the menu + // a bit, until a better mechanism can be implemented + wxPoint pt = ::wxGetMousePosition(); + pt = wnd->ScreenToClient(pt); + if (pt.x < 100) + pt.x = 0; + else + pt.x -= 100; + + // find out the screen coordinate at the bottom of the tab ctrl + wxRect cli_rect = wnd->GetClientRect(); + pt.y = cli_rect.y + cli_rect.height; + + wxAuiCommandCapture* cc = new wxAuiCommandCapture; + wnd->PushEventHandler(cc); + wnd->PopupMenu(&menuPopup, pt); + int command = cc->GetCommandId(); + wnd->PopEventHandler(true); + + if (command >= 1000) + return command-1000; + + return -1; +} -wxAuiDefaultTabArt::wxAuiDefaultTabArt() +int wxAuiDefaultTabArt::GetBestTabCtrlSize(wxWindow* wnd) +{ + wxClientDC dc(wnd); + dc.SetFont(m_measuring_font); + int x_ext = 0; + wxSize s = GetTabSize(dc, + wnd, + wxT("ABCDEFGHIj"), + true, + wxAUI_BUTTON_STATE_HIDDEN, + &x_ext); + return s.y+3; +} + +void wxAuiDefaultTabArt::SetNormalFont(const wxFont& font) +{ + m_normal_font = font; +} + +void wxAuiDefaultTabArt::SetSelectedFont(const wxFont& font) +{ + m_selected_font = font; +} + +void wxAuiDefaultTabArt::SetMeasuringFont(const wxFont& font) +{ + m_measuring_font = font; +} + + +// -- wxAuiSimpleTabArt class implementation -- + +wxAuiSimpleTabArt::wxAuiSimpleTabArt() { m_normal_font = *wxNORMAL_FONT; m_selected_font = *wxNORMAL_FONT; m_selected_font.SetWeight(wxBOLD); m_measuring_font = m_selected_font; + m_flags = 0; + m_fixed_tab_width = 100; + wxColour base_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); wxColour background_colour = StepColour(base_colour, 95); @@ -128,40 +685,6 @@ wxAuiDefaultTabArt::wxAuiDefaultTabArt() m_selected_bkbrush = wxBrush(selectedtab_colour); m_selected_bkpen = wxPen(selectedtab_colour); - -#if defined( __WXMAC__ ) - static unsigned char close_bits[]={ - 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0x03, 0xF8, 0x01, 0xF0, 0x19, 0xF3, - 0xB8, 0xE3, 0xF0, 0xE1, 0xE0, 0xE0, 0xF0, 0xE1, 0xB8, 0xE3, 0x19, 0xF3, - 0x01, 0xF0, 0x03, 0xF8, 0x0F, 0xFE, 0xFF, 0xFF }; -#elif defined( __WXGTK__) - static unsigned char close_bits[]={ - 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xfb, 0xef, 0xdb, 0xed, 0x8b, 0xe8, - 0x1b, 0xec, 0x3b, 0xee, 0x1b, 0xec, 0x8b, 0xe8, 0xdb, 0xed, 0xfb, 0xef, - 0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -#else - static unsigned char close_bits[]={ - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xfb,0xcf,0xf9, - 0x9f,0xfc,0x3f,0xfe,0x3f,0xfe,0x9f,0xfc,0xcf,0xf9,0xef,0xfb, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; -#endif - - static unsigned char left_bits[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x3f, 0xfe, - 0x1f, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x3f, 0xfe, 0x7f, 0xfe, 0xff, 0xfe, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - - static unsigned char right_bits[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x9f, 0xff, 0x1f, 0xff, - 0x1f, 0xfe, 0x1f, 0xfc, 0x1f, 0xfe, 0x1f, 0xff, 0x9f, 0xff, 0xdf, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - - static unsigned char list_bits[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x0f, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f, 0xfe, 0x7f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - - m_active_close_bmp = BitmapFromBits(close_bits, 16, 16, *wxBLACK); m_disabled_close_bmp = BitmapFromBits(close_bits, 16, 16, wxColour(128,128,128)); @@ -176,13 +699,46 @@ wxAuiDefaultTabArt::wxAuiDefaultTabArt() } -wxAuiDefaultTabArt::~wxAuiDefaultTabArt() +wxAuiSimpleTabArt::~wxAuiSimpleTabArt() { } -void wxAuiDefaultTabArt::DrawBackground(wxDC& dc, - wxWindow* WXUNUSED(wnd), - const wxRect& rect) +wxAuiTabArt* wxAuiSimpleTabArt::Clone() +{ + return static_cast(new wxAuiSimpleTabArt); +} + + +void wxAuiSimpleTabArt::SetFlags(unsigned int flags) +{ + m_flags = flags; +} + +void wxAuiSimpleTabArt::SetSizingInfo(const wxSize& tab_ctrl_size, + size_t tab_count) +{ + m_fixed_tab_width = 100; + + int tot_width = tab_ctrl_size.x; + if (tab_count > 0) + { + m_fixed_tab_width = tot_width/(int)tab_count; + } + + + if (m_fixed_tab_width < 100) + m_fixed_tab_width = 100; + + if (m_fixed_tab_width > tot_width/2) + m_fixed_tab_width = tot_width/2; + + if (m_fixed_tab_width > 220) + m_fixed_tab_width = 220; +} + +void wxAuiSimpleTabArt::DrawBackground(wxDC& dc, + wxWindow* WXUNUSED(wnd), + const wxRect& rect) { // draw background dc.SetBrush(m_bkbrush); @@ -204,15 +760,15 @@ void wxAuiDefaultTabArt::DrawBackground(wxDC& dc, // out_rect - actual output rectangle // x_extent - the advance x; where the next tab should start -void wxAuiDefaultTabArt::DrawTab(wxDC& dc, - wxWindow* wnd, - const wxRect& in_rect, - const wxString& caption_text, - bool active, - int close_button_state, - wxRect* out_tab_rect, - wxRect* out_button_rect, - int* x_extent) +void wxAuiSimpleTabArt::DrawTab(wxDC& dc, + wxWindow* wnd, + const wxRect& in_rect, + const wxString& caption_text, + bool active, + int close_button_state, + wxRect* out_tab_rect, + wxRect* out_button_rect, + int* x_extent) { wxCoord normal_textx, normal_texty; wxCoord selected_textx, selected_texty; @@ -274,6 +830,7 @@ void wxAuiDefaultTabArt::DrawTab(wxDC& dc, points[5].y = tab_y + tab_height - 1; points[6] = points[0]; + dc.SetClippingRegion(in_rect); dc.DrawPolygon(6, points); @@ -296,9 +853,17 @@ void wxAuiDefaultTabArt::DrawTab(wxDC& dc, text_offset = tab_x + (tab_height/3) + (tab_width/2) - (textx/2); } + // set minimum text offset + if (text_offset < tab_x + tab_height) + text_offset = tab_x + tab_height; + + // chop text if necessary + wxString draw_text = ChopText(dc, + caption, + tab_width - (text_offset-tab_x) - close_button_width); // draw tab text - dc.DrawText(caption, + dc.DrawText(draw_text, text_offset, (tab_y + tab_height)/2 - (texty/2) + 1); @@ -316,22 +881,28 @@ void wxAuiDefaultTabArt::DrawTab(wxDC& dc, tab_y + (tab_height/2) - (bmp.GetHeight()/2) + 1, close_button_width, tab_height - 1); - DrawButtonS(dc, rect, bmp, *wxWHITE, close_button_state); + DrawButtons(dc, rect, bmp, *wxWHITE, close_button_state); *out_button_rect = rect; } *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height); + + dc.DestroyClippingRegion(); } +int wxAuiSimpleTabArt::GetIndentSize() +{ + return 0; +} -wxSize wxAuiDefaultTabArt::GetTabSize(wxDC& dc, - wxWindow* WXUNUSED(wnd), - const wxString& caption, - bool WXUNUSED(active), - int close_button_state, - int* x_extent) +wxSize wxAuiSimpleTabArt::GetTabSize(wxDC& dc, + wxWindow* WXUNUSED(wnd), + const wxString& caption, + bool WXUNUSED(active), + int close_button_state, + int* x_extent) { wxCoord measured_textx, measured_texty; @@ -343,22 +914,26 @@ wxSize wxAuiDefaultTabArt::GetTabSize(wxDC& dc, if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) tab_width += m_active_close_bmp.GetWidth(); - + + if (m_flags & wxAUI_NB_TAB_FIXED_WIDTH) + { + tab_width = m_fixed_tab_width; + } + *x_extent = tab_width - (tab_height/2) - 1; return wxSize(tab_width, tab_height); } -void wxAuiDefaultTabArt::DrawButton( - wxDC& dc, - wxWindow* WXUNUSED(wnd), - const wxRect& in_rect, - int bitmap_id, - int button_state, - int orientation, - const wxBitmap& bitmap_override, - wxRect* out_rect) +void wxAuiSimpleTabArt::DrawButton(wxDC& dc, + wxWindow* WXUNUSED(wnd), + const wxRect& in_rect, + int bitmap_id, + int button_state, + int orientation, + const wxBitmap& bitmap_override, + wxRect* out_rect) { wxBitmap bmp; wxRect rect; @@ -418,46 +993,15 @@ void wxAuiDefaultTabArt::DrawButton( } - DrawButtonS(dc, rect, bmp, *wxWHITE, button_state); + DrawButtons(dc, rect, bmp, *wxWHITE, button_state); *out_rect = rect; } - - -// -- GUI helper classes and functions -- - -class wxAuiCommandCapture : public wxEvtHandler -{ -public: - - wxAuiCommandCapture() { m_last_id = 0; } - int GetCommandId() const { return m_last_id; } - - bool ProcessEvent(wxEvent& evt) - { - if (evt.GetEventType() == wxEVT_COMMAND_MENU_SELECTED) - { - m_last_id = evt.GetId(); - return true; - } - - if (GetNextHandler()) - return GetNextHandler()->ProcessEvent(evt); - - return false; - } - -private: - int m_last_id; -}; - - - -int wxAuiDefaultTabArt::ShowWindowList(wxWindow* wnd, - const wxArrayString& items, - int active_idx) +int wxAuiSimpleTabArt::ShowWindowList(wxWindow* wnd, + const wxArrayString& items, + int active_idx) { wxMenu menuPopup; @@ -498,7 +1042,7 @@ int wxAuiDefaultTabArt::ShowWindowList(wxWindow* wnd, return -1; } -int wxAuiDefaultTabArt::GetBestTabCtrlSize(wxWindow* wnd) +int wxAuiSimpleTabArt::GetBestTabCtrlSize(wxWindow* wnd) { wxClientDC dc(wnd); dc.SetFont(m_measuring_font); @@ -512,17 +1056,17 @@ int wxAuiDefaultTabArt::GetBestTabCtrlSize(wxWindow* wnd) return s.y+3; } -void wxAuiDefaultTabArt::SetNormalFont(const wxFont& font) +void wxAuiSimpleTabArt::SetNormalFont(const wxFont& font) { m_normal_font = font; } -void wxAuiDefaultTabArt::SetSelectedFont(const wxFont& font) +void wxAuiSimpleTabArt::SetSelectedFont(const wxFont& font) { m_selected_font = font; } -void wxAuiDefaultTabArt::SetMeasuringFont(const wxFont& font) +void wxAuiSimpleTabArt::SetMeasuringFont(const wxFont& font) { m_measuring_font = font; } @@ -530,8 +1074,6 @@ void wxAuiDefaultTabArt::SetMeasuringFont(const wxFont& font) - - // -- wxAuiTabContainer class implementation -- @@ -566,6 +1108,11 @@ void wxAuiTabContainer::SetArtProvider(wxAuiTabArt* art) { delete m_art; m_art = art; + + if (m_art) + { + m_art->SetFlags(m_flags); + } } wxAuiTabArt* wxAuiTabContainer::GetArtProvider() @@ -599,6 +1146,11 @@ void wxAuiTabContainer::SetFlags(unsigned int flags) { AddButton(wxAUI_BUTTON_CLOSE, wxRIGHT); } + + if (m_art) + { + m_art->SetFlags(m_flags); + } } unsigned int wxAuiTabContainer::GetFlags() const @@ -625,6 +1177,11 @@ void wxAuiTabContainer::SetMeasuringFont(const wxFont& font) void wxAuiTabContainer::SetRect(const wxRect& rect) { m_rect = rect; + + if (m_art) + { + m_art->SetSizingInfo(rect.GetSize(), m_pages.GetCount()); + } } bool wxAuiTabContainer::AddPage(wxWindow* page, @@ -636,6 +1193,12 @@ bool wxAuiTabContainer::AddPage(wxWindow* page, m_pages.Add(page_info); + // let the art provider know how many pages we have + if (m_art) + { + m_art->SetSizingInfo(m_rect.GetSize(), m_pages.GetCount()); + } + return true; } @@ -652,6 +1215,12 @@ bool wxAuiTabContainer::InsertPage(wxWindow* page, else m_pages.Insert(page_info, idx); + // let the art provider know how many pages we have + if (m_art) + { + m_art->SetSizingInfo(m_rect.GetSize(), m_pages.GetCount()); + } + return true; } @@ -683,6 +1252,13 @@ bool wxAuiTabContainer::RemovePage(wxWindow* wnd) if (page.window == wnd) { m_pages.RemoveAt(i); + + // let the art provider know how many pages we have + if (m_art) + { + m_art->SetSizingInfo(m_rect.GetSize(), m_pages.GetCount()); + } + return true; } } @@ -821,6 +1397,9 @@ void wxAuiTabContainer::SetTabOffset(size_t offset) m_tab_offset = offset; } + + + // Render() renders the tab catalog to the specified DC // It is a virtual function and can be overridden to // provide custom drawing capabilities @@ -878,7 +1457,7 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) } } - if (total_width > m_rect.GetWidth() - 20 || m_tab_offset != 0) + if (total_width > m_rect.GetWidth() || m_tab_offset != 0) { // show left/right buttons for (i = 0; i < button_count; ++i) @@ -996,12 +1575,8 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) offset = left_buttons_width; - // set a clipping region to the tabs don't draw over the buttons - dc.SetClippingRegion(left_buttons_width, 0, - m_rect.GetWidth() - right_buttons_width - left_buttons_width - 2, - m_rect.GetHeight()); - - + if (offset == 0) + offset += m_art->GetIndentSize(); // prepare the tab-close-button array while (m_tab_close_buttons.GetCount() < page_count) @@ -1024,11 +1599,11 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) size_t active = 999; int active_offset = 0; + wxRect active_rect; int x_extent = 0; wxRect rect = m_rect; rect.y = 0; - rect.width = 1000; rect.height = m_rect.height; for (i = m_tab_offset; i < page_count; ++i) @@ -1055,6 +1630,9 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) } rect.x = offset; + rect.width = m_rect.width - right_buttons_width - offset - 2; + + m_art->DrawTab(dc, wnd, @@ -1070,6 +1648,7 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) { active = i; active_offset = offset; + active_rect = rect; } offset += x_extent; @@ -1093,7 +1672,7 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) rect.x = active_offset; m_art->DrawTab(dc, wnd, - rect, + active_rect, page.caption, page.active, tab_button.cur_state, @@ -1102,7 +1681,6 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) &x_extent); } - dc.DestroyClippingRegion(); raw_dc->Blit(m_rect.x, m_rect.y, m_rect.GetWidth(), m_rect.GetHeight(), @@ -1518,10 +2096,9 @@ public: if (!m_tabs) return; - int tab_height = wxMin(m_rect.height, m_tab_ctrl_height); - m_tab_rect = wxRect(m_rect.x, m_rect.y, m_rect.width, tab_height); - m_tabs->SetSize(m_rect.x, m_rect.y, m_rect.width, tab_height); - m_tabs->SetRect(wxRect(0, 0, m_rect.width, tab_height)); + m_tab_rect = wxRect(m_rect.x, m_rect.y, m_rect.width, m_tab_ctrl_height); + m_tabs->SetSize(m_rect.x, m_rect.y, m_rect.width, m_tab_ctrl_height); + m_tabs->SetRect(wxRect(0, 0, m_rect.width, m_tab_ctrl_height)); m_tabs->Refresh(); m_tabs->Update(); @@ -1531,8 +2108,8 @@ public: for (i = 0; i < page_count; ++i) { wxAuiNotebookPage& page = pages.Item(i); - page.window->SetSize(m_rect.x, m_rect.y+tab_height, - m_rect.width, m_rect.height-tab_height); + page.window->SetSize(m_rect.x, m_rect.y + m_tab_ctrl_height, + m_rect.width, m_rect.height - m_tab_ctrl_height); if (page.window->IsKindOf(CLASSINFO(wxAuiMDIChildFrame))) { @@ -1636,8 +2213,7 @@ void wxAuiNotebook::InitNotebook(long style) m_selected_font = *wxNORMAL_FONT; m_selected_font.SetWeight(wxBOLD); - // choose a default for the tab height - m_tab_ctrl_height = m_tabs.GetArtProvider()->GetBestTabCtrlSize(this); + SetArtProvider(new wxAuiDefaultTabArt); m_dummy_wnd = new wxWindow(this, wxID_ANY, wxPoint(0,0), wxSize(0,0)); m_dummy_wnd->SetSize(200, 200); @@ -1659,6 +2235,24 @@ wxAuiNotebook::~wxAuiNotebook() void wxAuiNotebook::SetArtProvider(wxAuiTabArt* art) { m_tabs.SetArtProvider(art); + + // choose a default for the tab height + m_tab_ctrl_height = art->GetBestTabCtrlSize(this); + + wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes(); + size_t i, pane_count = all_panes.GetCount(); + for (i = 0; i < pane_count; ++i) + { + wxAuiPaneInfo& pane = all_panes.Item(i); + if (pane.name == wxT("dummy")) + continue; + wxTabFrame* tab_frame = (wxTabFrame*)pane.window; + wxAuiTabCtrl* tabctrl = tab_frame->m_tabs; + tab_frame->SetTabCtrlHeight(m_tab_ctrl_height); + tabctrl->SetArtProvider(art->Clone()); + tab_frame->DoSizing(); + } + } wxAuiTabArt* wxAuiNotebook::GetArtProvider() @@ -2052,6 +2646,7 @@ wxAuiTabCtrl* wxAuiNotebook::GetActiveTabCtrl() wxDefaultSize, wxNO_BORDER); tabframe->m_tabs->SetFlags(m_flags); + tabframe->m_tabs->SetArtProvider(m_tabs.GetArtProvider()->Clone()); m_mgr.AddPane(tabframe, wxAuiPaneInfo().Center().CaptionVisible(false)); @@ -2374,6 +2969,7 @@ void wxAuiNotebook::OnTabEndDrag(wxCommandEvent& command_evt) wxDefaultPosition, wxDefaultSize, wxNO_BORDER); + new_tabs->m_tabs->SetArtProvider(m_tabs.GetArtProvider()->Clone()); new_tabs->m_tabs->SetFlags(m_flags); m_mgr.AddPane(new_tabs, -- 2.47.2