KiCad PCB EDA Suite
WX_ELLIPSIZED_STATIC_TEXT Class Reference

A version of a wxStaticText control that will request a smaller size than the full string. More...

#include <wx_ellipsized_static_text.h>

Inheritance diagram for WX_ELLIPSIZED_STATIC_TEXT:

Public Member Functions

 WX_ELLIPSIZED_STATIC_TEXT (wxWindow *aParent, wxWindowID aID, const wxString &aLabel, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=0)
 
void SetMinimumStringLength (const wxString &aString)
 Set the string that is used for determining the requested size of the control. More...
 

Protected Member Functions

wxSize DoGetBestSize () const override
 

Private Attributes

wxString m_minimumString
 

Detailed Description

A version of a wxStaticText control that will request a smaller size than the full string.

This can be used with the ellipsization styles to ensure that the control will actually ellipsize properly inside sizer elements (since they ask for the best size but GTK reports the best size as being the full string length, even when ellipsization is enabled). This work around is discussed in upstream ticket https://trac.wxwidgets.org/ticket/18992.

Definition at line 37 of file wx_ellipsized_static_text.h.

Constructor & Destructor Documentation

◆ WX_ELLIPSIZED_STATIC_TEXT()

WX_ELLIPSIZED_STATIC_TEXT::WX_ELLIPSIZED_STATIC_TEXT ( wxWindow *  aParent,
wxWindowID  aID,
const wxString &  aLabel,
const wxPoint &  aPos = wxDefaultPosition,
const wxSize &  aSize = wxDefaultSize,
long  aStyle = 0 
)

Definition at line 27 of file wx_ellipsized_static_text.cpp.

30 : wxStaticText( aParent, aID, aLabel, aPos, aSize, aStyle ),
31 m_minimumString( "M...M" )
32{
33}

Member Function Documentation

◆ DoGetBestSize()

wxSize WX_ELLIPSIZED_STATIC_TEXT::DoGetBestSize ( ) const
overrideprotected

Definition at line 36 of file wx_ellipsized_static_text.cpp.

37{
38 // This is slightly awkward because DoGetBestSize is const upstream, but we need the non-const
39 // object to measure the text size in this function.
40 return KIUI::GetTextSize( m_minimumString, const_cast<WX_ELLIPSIZED_STATIC_TEXT*>( this ) );
41}
A version of a wxStaticText control that will request a smaller size than the full string.
wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition: ui_common.cpp:70

References KIUI::GetTextSize(), and m_minimumString.

◆ SetMinimumStringLength()

void WX_ELLIPSIZED_STATIC_TEXT::SetMinimumStringLength ( const wxString &  aString)
inline

Set the string that is used for determining the requested size of the control.

The control will return this string length from GetBestSize(), regardless of what string the control is displaying.

Parameters
aStringis the smallest string to display without ellipses

Definition at line 52 of file wx_ellipsized_static_text.h.

53 {
54 m_minimumString = aString;
55 }

References m_minimumString.

Referenced by LAYER_WIDGET::insertLayerRow().

Member Data Documentation

◆ m_minimumString

wxString WX_ELLIPSIZED_STATIC_TEXT::m_minimumString
private

Definition at line 61 of file wx_ellipsized_static_text.h.

Referenced by DoGetBestSize(), and SetMinimumStringLength().


The documentation for this class was generated from the following files: