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:
@@ -39,8 +39,11 @@ enum wxEllipsizeFlags
|
||||
wxELLIPSIZE_FLAGS_EXPAND_TABS
|
||||
};
|
||||
|
||||
// NB: Don't change the order of these values, they're the same as in
|
||||
// PangoEllipsizeMode enum.
|
||||
enum wxEllipsizeMode
|
||||
{
|
||||
wxELLIPSIZE_NONE,
|
||||
wxELLIPSIZE_START,
|
||||
wxELLIPSIZE_MIDDLE,
|
||||
wxELLIPSIZE_END
|
||||
|
@@ -411,7 +411,7 @@ public:
|
||||
wxDataViewRendererBase( const wxString &varianttype,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
||||
int alignment = wxDVR_DEFAULT_ALIGNMENT );
|
||||
~wxDataViewRendererBase();
|
||||
virtual ~wxDataViewRendererBase();
|
||||
|
||||
virtual bool Validate( wxVariant& WXUNUSED(value) )
|
||||
{ return true; }
|
||||
@@ -435,6 +435,14 @@ public:
|
||||
virtual void SetAlignment( int align ) = 0;
|
||||
virtual int GetAlignment() const = 0;
|
||||
|
||||
// enable or disable (if called with wxELLIPSIZE_NONE) replacing parts of
|
||||
// the item text (hence this only makes sense for renderers showing
|
||||
// text...) with ellipsis in order to make it fit the column width
|
||||
virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE) = 0;
|
||||
void DisableEllipsize() { EnableEllipsize(wxELLIPSIZE_NONE); }
|
||||
|
||||
virtual wxEllipsizeMode GetEllipsizeMode() const = 0;
|
||||
|
||||
// in-place editing
|
||||
virtual bool HasEditorCtrl() const
|
||||
{ return false; }
|
||||
|
@@ -57,6 +57,11 @@ public:
|
||||
virtual void SetAlignment( int align );
|
||||
virtual int GetAlignment() const;
|
||||
|
||||
virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE)
|
||||
{ m_ellipsizeMode = mode; }
|
||||
virtual wxEllipsizeMode GetEllipsizeMode() const
|
||||
{ return m_ellipsizeMode; }
|
||||
|
||||
virtual void SetMode( wxDataViewCellMode mode )
|
||||
{ m_mode=mode; }
|
||||
virtual wxDataViewCellMode GetMode() const
|
||||
@@ -110,6 +115,8 @@ private:
|
||||
int m_align;
|
||||
wxDataViewCellMode m_mode;
|
||||
|
||||
wxEllipsizeMode m_ellipsizeMode;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
|
||||
};
|
||||
|
||||
|
@@ -38,6 +38,8 @@ public:
|
||||
virtual void SetAlignment( int align );
|
||||
virtual int GetAlignment() const;
|
||||
|
||||
virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
|
||||
virtual wxEllipsizeMode GetEllipsizeMode() const;
|
||||
|
||||
// GTK-specific implementation
|
||||
// ---------------------------
|
||||
|
@@ -219,12 +219,16 @@ public:
|
||||
m_origTextColour = [textColour retain];
|
||||
}
|
||||
|
||||
// The ellipsization mode which we need to set for each cell being rendered.
|
||||
void SetEllipsizeMode(wxEllipsizeMode mode) { m_ellipsizeMode = mode; }
|
||||
wxEllipsizeMode GetEllipsizeMode() const { return m_ellipsizeMode; }
|
||||
|
||||
// Set the line break mode for the given cell using our m_ellipsizeMode
|
||||
void ApplyLineBreakMode(NSCell *cell);
|
||||
|
||||
private:
|
||||
void Init()
|
||||
{
|
||||
m_origFont = NULL;
|
||||
m_origTextColour = NULL;
|
||||
}
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
id m_Item; // item NOT owned by renderer
|
||||
id m_Object; // object that can be used by renderer for storing special data (owned by renderer)
|
||||
@@ -237,6 +241,8 @@ private:
|
||||
// we own those if they're non-NULL
|
||||
NSFont *m_origFont;
|
||||
NSColor *m_origTextColour;
|
||||
|
||||
wxEllipsizeMode m_ellipsizeMode;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
|
@@ -61,6 +61,9 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
|
||||
virtual wxEllipsizeMode GetEllipsizeMode() const;
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
|
Reference in New Issue
Block a user