elipsis for oversized pane captions
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43164 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -815,12 +815,12 @@ MyFrame::MyFrame(wxWindow* parent,
|
||||
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
||||
Name(wxT("test2")).Caption(wxT("Client Size Reporter")).
|
||||
Bottom().Position(1).
|
||||
PinButton(true).CloseButton(true).MaximizeButton(true));
|
||||
CloseButton(true).MaximizeButton(true));
|
||||
|
||||
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
||||
Name(wxT("test3")).Caption(wxT("Client Size Reporter")).
|
||||
Bottom().
|
||||
PinButton(true).CloseButton(true).MaximizeButton(true));
|
||||
CloseButton(true).MaximizeButton(true));
|
||||
|
||||
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
||||
Name(wxT("test4")).Caption(wxT("Pane Caption")).
|
||||
@@ -833,12 +833,12 @@ MyFrame::MyFrame(wxWindow* parent,
|
||||
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
||||
Name(wxT("test6")).Caption(wxT("Client Size Reporter")).
|
||||
Right().Row(1).
|
||||
PinButton(true).CloseButton(true).MaximizeButton(true));
|
||||
CloseButton(true).MaximizeButton(true));
|
||||
|
||||
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
||||
Name(wxT("test7")).Caption(wxT("Client Size Reporter")).
|
||||
Left().Layer(1).
|
||||
PinButton(true).CloseButton(true).MaximizeButton(true));
|
||||
CloseButton(true).MaximizeButton(true));
|
||||
|
||||
m_mgr.AddPane(CreateTreeCtrl(), wxAuiPaneInfo().
|
||||
Name(wxT("test8")).Caption(wxT("Tree Pane")).
|
||||
@@ -1328,7 +1328,7 @@ void MyFrame::OnCreateSizeReport(wxCommandEvent& WXUNUSED(event))
|
||||
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
||||
Name(wxT("Test")).Caption(wxT("Client Size Reporter")).
|
||||
Float().FloatingPosition(GetStartPosition()).
|
||||
PinButton(true).CloseButton(true).MaximizeButton(true));
|
||||
CloseButton(true).MaximizeButton(true));
|
||||
m_mgr.Update();
|
||||
}
|
||||
|
||||
|
@@ -129,6 +129,34 @@ static void DrawGradientRectangle(wxDC& dc,
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
wxAuiDefaultDockArt::wxAuiDefaultDockArt()
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
@@ -522,8 +550,20 @@ void wxAuiDefaultDockArt::DrawCaption(wxDC& dc, wxWindow *WXUNUSED(window),
|
||||
wxCoord w,h;
|
||||
dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h);
|
||||
|
||||
dc.SetClippingRegion(rect);
|
||||
dc.DrawText(text, rect.x+3, rect.y+(rect.height/2)-(h/2)-1);
|
||||
wxRect clip_rect = rect;
|
||||
clip_rect.width -= 3; // text offset
|
||||
clip_rect.width -= 2; // button padding
|
||||
if (pane.HasCloseButton())
|
||||
clip_rect.width -= m_button_size;
|
||||
if (pane.HasPinButton())
|
||||
clip_rect.width -= m_button_size;
|
||||
if (pane.HasMaximizeButton())
|
||||
clip_rect.width -= m_button_size;
|
||||
|
||||
wxString draw_text = ChopText(dc, text, clip_rect.width);
|
||||
|
||||
dc.SetClippingRegion(clip_rect);
|
||||
dc.DrawText(draw_text, rect.x+3, rect.y+(rect.height/2)-(h/2)-1);
|
||||
dc.DestroyClippingRegion();
|
||||
}
|
||||
|
||||
|
@@ -834,7 +834,14 @@ bool wxAuiManager::AddPane(wxWindow* window, const wxAuiPaneInfo& pane_info)
|
||||
button.button_id = wxAUI_BUTTON_MAXIMIZE_RESTORE;
|
||||
pinfo.buttons.Add(button);
|
||||
}
|
||||
|
||||
|
||||
if (pinfo.HasPinButton())
|
||||
{
|
||||
wxAuiPaneButton button;
|
||||
button.button_id = wxAUI_BUTTON_PIN;
|
||||
pinfo.buttons.Add(button);
|
||||
}
|
||||
|
||||
if (pinfo.HasCloseButton())
|
||||
{
|
||||
wxAuiPaneButton button;
|
||||
|
Reference in New Issue
Block a user