aui notebook sizing calculations streamlined
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42758 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -36,6 +36,10 @@ public:
|
||||
|
||||
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,
|
||||
@@ -62,10 +66,8 @@ public:
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
@@ -77,6 +79,10 @@ public:
|
||||
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);
|
||||
@@ -102,11 +108,9 @@ public:
|
||||
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;
|
||||
|
@@ -198,33 +198,27 @@ void wxDefaultTabArt::DrawTab(wxDC* dc,
|
||||
{
|
||||
wxCoord normal_textx, normal_texty;
|
||||
wxCoord selected_textx, selected_texty;
|
||||
wxCoord measured_textx, measured_texty;
|
||||
wxCoord textx, texty;
|
||||
|
||||
|
||||
|
||||
// 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_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;
|
||||
|
||||
|
||||
// select pen, brush and font for the tab to be drawn
|
||||
|
||||
if (active)
|
||||
@@ -274,10 +268,9 @@ void wxDefaultTabArt::DrawTab(wxDC* dc,
|
||||
|
||||
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);
|
||||
*x_extent = tab_width - (tab_height/2) - 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -368,7 +361,14 @@ void wxDefaultTabArt::DrawButton(
|
||||
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -1306,11 +1306,7 @@ void wxAuiMultiNotebook::InitNotebook()
|
||||
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);
|
||||
|
Reference in New Issue
Block a user