+ if (m_flags & wxAUI_NB_CLOSE_BUTTON)
+ tot_width -= m_activeCloseBmp.GetWidth();
+ if (m_flags & wxAUI_NB_WINDOWLIST_BUTTON)
+ tot_width -= m_activeWindowListBmp.GetWidth();
+
+ if (tab_count > 0)
+ {
+ m_fixedTabWidth = tot_width/(int)tab_count;
+ }
+
+
+ if (m_fixedTabWidth < 100)
+ m_fixedTabWidth = 100;
+
+ if (m_fixedTabWidth > tot_width/2)
+ m_fixedTabWidth = tot_width/2;
+
+ if (m_fixedTabWidth > 220)
+ m_fixedTabWidth = 220;
+}
+
+void wxAuiSimpleTabArt::SetColour(const wxColour& colour)
+{
+ m_bkBrush = wxBrush(colour);
+ m_normalBkBrush = wxBrush(colour);
+ m_normalBkPen = wxPen(colour);
+}
+
+void wxAuiSimpleTabArt::SetActiveColour(const wxColour& colour)
+{
+ m_selectedBkBrush = wxBrush(colour);
+ m_selectedBkPen = wxPen(colour);
+}
+
+void wxAuiSimpleTabArt::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 line
+ dc.SetPen(*wxGREY_PEN);
+ 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 wxAuiSimpleTabArt::DrawTab(wxDC& dc,
+ wxWindow* wnd,
+ const wxAuiNotebookPage& page,
+ const wxRect& in_rect,
+ 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 = page.caption;
+ if (caption.empty())
+ caption = wxT("Xj");
+
+ dc.SetFont(m_selectedFont);
+ dc.GetTextExtent(caption, &selected_textx, &selected_texty);
+
+ dc.SetFont(m_normalFont);
+ dc.GetTextExtent(caption, &normal_textx, &normal_texty);
+
+ // figure out the size of the tab
+ wxSize tab_size = GetTabSize(dc,
+ wnd,
+ page.caption,
+ page.bitmap,
+ page.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;
+
+ caption = page.caption;
+
+ // select pen, brush and font for the tab to be drawn
+
+ if (page.active)
+ {
+ dc.SetPen(m_selectedBkPen);
+ dc.SetBrush(m_selectedBkBrush);
+ dc.SetFont(m_selectedFont);
+ textx = selected_textx;
+ texty = selected_texty;
+ }
+ else
+ {
+ dc.SetPen(m_normalBkPen);
+ dc.SetBrush(m_normalBkBrush);
+ dc.SetFont(m_normalFont);
+ textx = normal_textx;
+ texty = normal_texty;
+ }
+
+
+ // -- draw line --
+
+ wxPoint points[7];
+ points[0].x = tab_x;
+ points[0].y = tab_y + tab_height - 1;
+ points[1].x = tab_x + tab_height - 3;
+ points[1].y = tab_y + 2;
+ points[2].x = tab_x + tab_height + 3;
+ 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 - 1;
+ points[6] = points[0];
+
+ dc.SetClippingRegion(in_rect);
+
+ dc.DrawPolygon(WXSIZEOF(points) - 1, points);
+
+ dc.SetPen(*wxGREY_PEN);
+
+ //dc.DrawLines(active ? WXSIZEOF(points) - 1 : WXSIZEOF(points), points);
+ dc.DrawLines(WXSIZEOF(points), points);
+
+
+ int text_offset;
+
+ int close_button_width = 0;
+ if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
+ {
+ close_button_width = m_activeCloseBmp.GetWidth();
+ text_offset = tab_x + (tab_height/2) + ((tab_width-close_button_width)/2) - (textx/2);
+ }
+ else
+ {
+ 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 = wxAuiChopText(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) + 1);
+
+
+ // draw focus rectangle
+ if (page.active && (wnd->FindFocus() == wnd))
+ {
+ wxRect focusRect(text_offset, ((tab_y + tab_height)/2 - (texty/2) + 1),
+ selected_textx, selected_texty);
+
+ focusRect.Inflate(2, 2);
+
+ wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0);
+ }
+
+ // draw close button if necessary
+ if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
+ {
+ wxBitmap bmp;
+ if (page.active)
+ bmp = m_activeCloseBmp;
+ else
+ bmp = m_disabledCloseBmp;
+
+ wxRect rect(tab_x + tab_width - close_button_width - 1,
+ tab_y + (tab_height/2) - (bmp.GetHeight()/2) + 1,
+ close_button_width,
+ tab_height - 1);
+ 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 wxAuiSimpleTabArt::GetTabSize(wxDC& dc,
+ wxWindow* WXUNUSED(wnd),
+ const wxString& caption,
+ const wxBitmap& WXUNUSED(bitmap),
+ bool WXUNUSED(active),
+ int close_button_state,
+ int* x_extent)
+{
+ wxCoord measured_textx, measured_texty;
+
+ dc.SetFont(m_measuringFont);
+ dc.GetTextExtent(caption, &measured_textx, &measured_texty);
+
+ wxCoord tab_height = measured_texty + 4;
+ wxCoord tab_width = measured_textx + tab_height + 5;
+
+ if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
+ tab_width += m_activeCloseBmp.GetWidth();
+
+ if (m_flags & wxAUI_NB_TAB_FIXED_WIDTH)
+ {
+ tab_width = m_fixedTabWidth;
+ }
+
+ *x_extent = tab_width - (tab_height/2) - 1;
+
+ return wxSize(tab_width, tab_height);
+}
+
+
+void wxAuiSimpleTabArt::DrawButton(wxDC& dc,
+ wxWindow* WXUNUSED(wnd),
+ const wxRect& in_rect,
+ int bitmap_id,
+ int button_state,
+ int orientation,
+ wxRect* out_rect)
+{
+ wxBitmap bmp;
+ wxRect rect;
+
+ switch (bitmap_id)
+ {
+ case wxAUI_BUTTON_CLOSE:
+ if (button_state & wxAUI_BUTTON_STATE_DISABLED)
+ bmp = m_disabledCloseBmp;
+ else
+ bmp = m_activeCloseBmp;
+ break;
+ case wxAUI_BUTTON_LEFT:
+ if (button_state & wxAUI_BUTTON_STATE_DISABLED)
+ bmp = m_disabledLeftBmp;
+ else
+ bmp = m_activeLeftBmp;
+ break;
+ case wxAUI_BUTTON_RIGHT:
+ if (button_state & wxAUI_BUTTON_STATE_DISABLED)
+ bmp = m_disabledRightBmp;
+ else
+ bmp = m_activeRightBmp;
+ break;
+ case wxAUI_BUTTON_WINDOWLIST:
+ if (button_state & wxAUI_BUTTON_STATE_DISABLED)
+ bmp = m_disabledWindowListBmp;
+ else
+ bmp = m_activeWindowListBmp;
+ 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());
+ }
+
+
+ DrawButtons(dc, rect, bmp, *wxWHITE, button_state);
+
+ *out_rect = rect;
+}
+
+int wxAuiSimpleTabArt::ShowDropDown(wxWindow* wnd,
+ const wxAuiNotebookPageArray& pages,
+ int active_idx)
+{
+ wxMenu menuPopup;
+
+ size_t i, count = pages.GetCount();
+ for (i = 0; i < count; ++i)
+ {
+ const wxAuiNotebookPage& page = pages.Item(i);
+ menuPopup.AppendCheckItem(1000+i, page.caption);
+ }
+
+ 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;
+}
+
+int wxAuiSimpleTabArt::GetBestTabCtrlSize(wxWindow* wnd,
+ const wxAuiNotebookPageArray& WXUNUSED(pages),
+ const wxSize& WXUNUSED(requiredBmp_size))
+{
+ wxClientDC dc(wnd);
+ dc.SetFont(m_measuringFont);
+ int x_ext = 0;
+ wxSize s = GetTabSize(dc,
+ wnd,
+ wxT("ABCDEFGHIj"),
+ wxNullBitmap,
+ true,
+ wxAUI_BUTTON_STATE_HIDDEN,
+ &x_ext);
+ return s.y+3;
+}
+
+void wxAuiSimpleTabArt::SetNormalFont(const wxFont& font)
+{
+ m_normalFont = font;
+}
+
+void wxAuiSimpleTabArt::SetSelectedFont(const wxFont& font)
+{
+ m_selectedFont = font;
+}
+
+void wxAuiSimpleTabArt::SetMeasuringFont(const wxFont& font)
+{
+ m_measuringFont = font;
+}
+
+
+
+
+// -- wxAuiTabContainer class implementation --
+
+
+// wxAuiTabContainer is a class which contains information about each
+// tab. It also can render an entire tab control to a specified DC.
+// It's not a window class itself, because this code will be used by
+// the wxFrameMananger, where it is disadvantageous to have separate
+// windows for each tab control in the case of "docked tabs"
+
+// A derived class, wxAuiTabCtrl, is an actual wxWindow-derived window
+// which can be used as a tab control in the normal sense.
+
+
+wxAuiTabContainer::wxAuiTabContainer()
+{
+ m_tabOffset = 0;
+ m_flags = 0;
+ m_art = new wxAuiDefaultTabArt;
+
+ AddButton(wxAUI_BUTTON_LEFT, wxLEFT);
+ AddButton(wxAUI_BUTTON_RIGHT, wxRIGHT);
+ AddButton(wxAUI_BUTTON_WINDOWLIST, wxRIGHT);
+ AddButton(wxAUI_BUTTON_CLOSE, wxRIGHT);
+}
+
+wxAuiTabContainer::~wxAuiTabContainer()
+{
+ delete m_art;
+}
+
+void wxAuiTabContainer::SetArtProvider(wxAuiTabArt* art)
+{
+ delete m_art;
+ m_art = art;
+
+ if (m_art)
+ {
+ m_art->SetFlags(m_flags);
+ }
+}
+
+wxAuiTabArt* wxAuiTabContainer::GetArtProvider() const
+{
+ return m_art;
+}
+
+void wxAuiTabContainer::SetFlags(unsigned int flags)
+{
+ m_flags = flags;
+
+ // check for new close button settings
+ RemoveButton(wxAUI_BUTTON_LEFT);
+ RemoveButton(wxAUI_BUTTON_RIGHT);
+ RemoveButton(wxAUI_BUTTON_WINDOWLIST);
+ RemoveButton(wxAUI_BUTTON_CLOSE);
+
+
+ if (flags & wxAUI_NB_SCROLL_BUTTONS)
+ {
+ AddButton(wxAUI_BUTTON_LEFT, wxLEFT);
+ AddButton(wxAUI_BUTTON_RIGHT, wxRIGHT);
+ }
+
+ if (flags & wxAUI_NB_WINDOWLIST_BUTTON)
+ {
+ AddButton(wxAUI_BUTTON_WINDOWLIST, wxRIGHT);
+ }
+
+ if (flags & wxAUI_NB_CLOSE_BUTTON)
+ {
+ AddButton(wxAUI_BUTTON_CLOSE, wxRIGHT);
+ }
+
+ if (m_art)
+ {
+ m_art->SetFlags(m_flags);
+ }
+}
+
+unsigned int wxAuiTabContainer::GetFlags() const
+{
+ return m_flags;
+}
+
+
+void wxAuiTabContainer::SetNormalFont(const wxFont& font)
+{
+ m_art->SetNormalFont(font);
+}