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().
|
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
||||||
Name(wxT("test2")).Caption(wxT("Client Size Reporter")).
|
Name(wxT("test2")).Caption(wxT("Client Size Reporter")).
|
||||||
Bottom().Position(1).
|
Bottom().Position(1).
|
||||||
PinButton(true).CloseButton(true).MaximizeButton(true));
|
CloseButton(true).MaximizeButton(true));
|
||||||
|
|
||||||
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
||||||
Name(wxT("test3")).Caption(wxT("Client Size Reporter")).
|
Name(wxT("test3")).Caption(wxT("Client Size Reporter")).
|
||||||
Bottom().
|
Bottom().
|
||||||
PinButton(true).CloseButton(true).MaximizeButton(true));
|
CloseButton(true).MaximizeButton(true));
|
||||||
|
|
||||||
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
||||||
Name(wxT("test4")).Caption(wxT("Pane Caption")).
|
Name(wxT("test4")).Caption(wxT("Pane Caption")).
|
||||||
@@ -833,12 +833,12 @@ MyFrame::MyFrame(wxWindow* parent,
|
|||||||
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
||||||
Name(wxT("test6")).Caption(wxT("Client Size Reporter")).
|
Name(wxT("test6")).Caption(wxT("Client Size Reporter")).
|
||||||
Right().Row(1).
|
Right().Row(1).
|
||||||
PinButton(true).CloseButton(true).MaximizeButton(true));
|
CloseButton(true).MaximizeButton(true));
|
||||||
|
|
||||||
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
||||||
Name(wxT("test7")).Caption(wxT("Client Size Reporter")).
|
Name(wxT("test7")).Caption(wxT("Client Size Reporter")).
|
||||||
Left().Layer(1).
|
Left().Layer(1).
|
||||||
PinButton(true).CloseButton(true).MaximizeButton(true));
|
CloseButton(true).MaximizeButton(true));
|
||||||
|
|
||||||
m_mgr.AddPane(CreateTreeCtrl(), wxAuiPaneInfo().
|
m_mgr.AddPane(CreateTreeCtrl(), wxAuiPaneInfo().
|
||||||
Name(wxT("test8")).Caption(wxT("Tree Pane")).
|
Name(wxT("test8")).Caption(wxT("Tree Pane")).
|
||||||
@@ -1328,7 +1328,7 @@ void MyFrame::OnCreateSizeReport(wxCommandEvent& WXUNUSED(event))
|
|||||||
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
|
||||||
Name(wxT("Test")).Caption(wxT("Client Size Reporter")).
|
Name(wxT("Test")).Caption(wxT("Client Size Reporter")).
|
||||||
Float().FloatingPosition(GetStartPosition()).
|
Float().FloatingPosition(GetStartPosition()).
|
||||||
PinButton(true).CloseButton(true).MaximizeButton(true));
|
CloseButton(true).MaximizeButton(true));
|
||||||
m_mgr.Update();
|
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()
|
wxAuiDefaultDockArt::wxAuiDefaultDockArt()
|
||||||
{
|
{
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
@@ -522,8 +550,20 @@ void wxAuiDefaultDockArt::DrawCaption(wxDC& dc, wxWindow *WXUNUSED(window),
|
|||||||
wxCoord w,h;
|
wxCoord w,h;
|
||||||
dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h);
|
dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h);
|
||||||
|
|
||||||
dc.SetClippingRegion(rect);
|
wxRect clip_rect = rect;
|
||||||
dc.DrawText(text, rect.x+3, rect.y+(rect.height/2)-(h/2)-1);
|
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();
|
dc.DestroyClippingRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -835,6 +835,13 @@ bool wxAuiManager::AddPane(wxWindow* window, const wxAuiPaneInfo& pane_info)
|
|||||||
pinfo.buttons.Add(button);
|
pinfo.buttons.Add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pinfo.HasPinButton())
|
||||||
|
{
|
||||||
|
wxAuiPaneButton button;
|
||||||
|
button.button_id = wxAUI_BUTTON_PIN;
|
||||||
|
pinfo.buttons.Add(button);
|
||||||
|
}
|
||||||
|
|
||||||
if (pinfo.HasCloseButton())
|
if (pinfo.HasCloseButton())
|
||||||
{
|
{
|
||||||
wxAuiPaneButton button;
|
wxAuiPaneButton button;
|
||||||
|
Reference in New Issue
Block a user