git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42758
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
wxTabArt() { }
virtual ~wxTabArt() { }
wxTabArt() { }
virtual ~wxTabArt() { }
+
+ virtual void SetNormalFont(const wxFont& font) = 0;
+ virtual void SetSelectedFont(const wxFont& font) = 0;
+ virtual void SetMeasuringFont(const wxFont& font) = 0;
virtual void DrawBackground(
wxDC* dc,
virtual void DrawBackground(
wxDC* dc,
const wxString& caption,
bool active,
int* x_extent) = 0;
const wxString& caption,
bool active,
int* x_extent) = 0;
-
- virtual void SetNormalFont(const wxFont& font) = 0;
- virtual void SetSelectedFont(const wxFont& font) = 0;
- virtual void SetMeasuringFont(const wxFont& font) = 0;
+
+ virtual int GetBestTabCtrlSize(wxWindow* wnd) = 0;
wxDefaultTabArt();
virtual ~wxDefaultTabArt();
wxDefaultTabArt();
virtual ~wxDefaultTabArt();
+ void SetNormalFont(const wxFont& font);
+ void SetSelectedFont(const wxFont& font);
+ void SetMeasuringFont(const wxFont& font);
+
void DrawBackground(
wxDC* dc,
const wxRect& rect);
void DrawBackground(
wxDC* dc,
const wxRect& rect);
const wxString& caption,
bool active,
int* x_extent);
const wxString& caption,
bool active,
int* x_extent);
-
- void SetNormalFont(const wxFont& font);
- void SetSelectedFont(const wxFont& font);
- void SetMeasuringFont(const wxFont& font);
-
+
+ int GetBestTabCtrlSize(wxWindow* wnd);
+
private:
wxFont m_normal_font;
private:
wxFont m_normal_font;
{
wxCoord normal_textx, normal_texty;
wxCoord selected_textx, selected_texty;
{
wxCoord normal_textx, normal_texty;
wxCoord selected_textx, selected_texty;
- wxCoord measured_textx, measured_texty;
// if the caption is empty, measure some temporary text
wxString caption = caption_text;
if (caption_text.empty())
caption = wxT("Xj");
// if the caption is empty, measure some temporary text
wxString caption = caption_text;
if (caption_text.empty())
caption = wxT("Xj");
-
- // measure text
- dc->SetFont(m_measuring_font);
- dc->GetTextExtent(caption, &measured_textx, &measured_texty);
-
dc->SetFont(m_selected_font);
dc->GetTextExtent(caption, &selected_textx, &selected_texty);
dc->SetFont(m_selected_font);
dc->GetTextExtent(caption, &selected_textx, &selected_texty);
dc->SetFont(m_normal_font);
dc->GetTextExtent(caption, &normal_textx, &normal_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, caption, active, x_extent);
- caption = caption_text;
-
- wxCoord tab_height = measured_texty + 4;
- wxCoord tab_width = measured_textx + tab_height + 5;
+ 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;
wxCoord tab_x = in_rect.x;
wxCoord tab_y = in_rect.y + in_rect.height - tab_height;
// select pen, brush and font for the tab to be drawn
if (active)
// select pen, brush and font for the tab to be drawn
if (active)
dc->DrawText(caption,
tab_x + (tab_height/3) + (tab_width/2) - (textx/2),
dc->DrawText(caption,
tab_x + (tab_height/3) + (tab_width/2) - (textx/2),
- tab_y + tab_height - texty - 2);
+ (tab_y + tab_height)/2 - (texty/2) + 1);
*out_rect = wxRect(tab_x, tab_y, tab_width, tab_height);
*out_rect = wxRect(tab_x, tab_y, tab_width, tab_height);
- *x_extent = tab_width - (tab_height/2) - 1;
+int wxDefaultTabArt::GetBestTabCtrlSize(wxWindow* wnd)
+{
+ wxClientDC dc(wnd);
+ dc.SetFont(m_measuring_font);
+ int x_ext = 0;
+ wxSize s = GetTabSize(&dc, wxT("ABCDEFGHIj"), true, &x_ext);
+ return s.y+3;
+}
void wxDefaultTabArt::SetNormalFont(const wxFont& font)
{
void wxDefaultTabArt::SetNormalFont(const wxFont& font)
{
m_selected_font.SetWeight(wxBOLD);
// choose a default for the tab height
m_selected_font.SetWeight(wxBOLD);
// choose a default for the tab height
- wxClientDC dc(this);
- int tx, ty;
- dc.SetFont(m_selected_font);
- dc.GetTextExtent(wxT("ABCDEFGHhijklm"), &tx, &ty);
- m_tab_ctrl_height = (ty*150)/100;
+ m_tab_ctrl_height = m_tabs.GetArtProvider()->GetBestTabCtrlSize(this);
m_dummy_wnd = new wxWindow(this, wxID_ANY, wxPoint(0,0), wxSize(0,0));
m_dummy_wnd->SetSize(200, 200);
m_dummy_wnd = new wxWindow(this, wxID_ANY, wxPoint(0,0), wxSize(0,0));
m_dummy_wnd->SetSize(200, 200);