Add ellipsization support to wxDataViewCtrl.
Implemented ellipsization in the generic, GTK and both OS X Carbon and Cocoa versions but it currently doesn't work well in GTK as it changes the item alignment unconditionally, this will need to be fixed later. The behaviour for the columns is currently inconsistent between ports too: under MSW they (natively) use wxELLIPSIZE_END, under GTK -- wxELLIPSIZE_NONE and under OS X the same ellipsization mode as the column contents, i.e. wxELLIPSIZE_MIDDLE by default. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62433 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -612,6 +612,7 @@ wxDataViewRenderer::wxDataViewRenderer( const wxString &varianttype,
|
||||
m_dc = NULL;
|
||||
m_align = align;
|
||||
m_mode = mode;
|
||||
m_ellipsizeMode = wxELLIPSIZE_MIDDLE;
|
||||
}
|
||||
|
||||
wxDataViewRenderer::~wxDataViewRenderer()
|
||||
@@ -752,7 +753,22 @@ wxDataViewCustomRenderer::RenderText(wxDC& dc,
|
||||
rectText.x += xoffset;
|
||||
rectText.width -= xoffset;
|
||||
|
||||
dc.DrawLabel(text, rectText, align);
|
||||
// check if we want to ellipsize the text if it doesn't fit
|
||||
wxString ellipsizedText;
|
||||
if ( GetEllipsizeMode() != wxELLIPSIZE_NONE )
|
||||
{
|
||||
ellipsizedText = wxControl::Ellipsize
|
||||
(
|
||||
text,
|
||||
dc,
|
||||
GetEllipsizeMode(),
|
||||
rect.width,
|
||||
wxELLIPSIZE_FLAGS_NONE
|
||||
);
|
||||
}
|
||||
|
||||
dc.DrawLabel(ellipsizedText.empty() ? text : ellipsizedText,
|
||||
rectText, align);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user