Add minimal support for ellipsization to wxQt wxStaticText
Set the visible label to the ellipsized value, if necessary. Also call AutoResizeIfNecessary() for consistency with the other ports.
This commit is contained in:
@@ -31,10 +31,13 @@ public:
|
||||
const wxString &name = wxStaticTextNameStr );
|
||||
|
||||
virtual void SetLabel(const wxString& label) wxOVERRIDE;
|
||||
virtual wxString GetLabel() const wxOVERRIDE;
|
||||
|
||||
virtual QWidget *GetHandle() const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual wxString WXGetVisibleLabel() const wxOVERRIDE;
|
||||
virtual void WXSetVisibleLabel(const wxString& str) wxOVERRIDE;
|
||||
|
||||
private:
|
||||
QLabel *m_qtLabel;
|
||||
|
||||
|
@@ -59,11 +59,26 @@ bool wxStaticText::Create(wxWindow *parent,
|
||||
}
|
||||
|
||||
void wxStaticText::SetLabel(const wxString& label)
|
||||
{
|
||||
// If the label doesn't really change, avoid flicker by not doing anything.
|
||||
if ( label == m_labelOrig )
|
||||
return;
|
||||
|
||||
// save the label in m_labelOrig with both the markup (if any) and
|
||||
// the mnemonics characters (if any)
|
||||
m_labelOrig = label;
|
||||
|
||||
WXSetVisibleLabel(GetEllipsizedLabel());
|
||||
|
||||
AutoResizeIfNecessary();
|
||||
}
|
||||
|
||||
void wxStaticText::WXSetVisibleLabel(const wxString& label)
|
||||
{
|
||||
m_qtLabel->setText( wxQtConvertString( label ) );
|
||||
}
|
||||
|
||||
wxString wxStaticText::GetLabel() const
|
||||
wxString wxStaticText::WXGetVisibleLabel() const
|
||||
{
|
||||
return wxQtConvertString( m_qtLabel->text() );
|
||||
}
|
||||
|
Reference in New Issue
Block a user