Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
auStaticText Class Reference

is like wxStaticText, except it can be themed. wxStaticText can't be. More...

#include <auStaticText.h>

Inheritance diagram for auStaticText:
[legend]
Collaboration diagram for auStaticText:
[legend]

Public Member Functions

 auStaticText (wxWindow *parent, wxString text)
 
void OnPaint (wxPaintEvent &evt)
 
bool AcceptsFocus () const override
 
void OnErase (wxEraseEvent &event)
 
void ScaleFont (double scale)
 
void SetSelected (bool selected)
 
bool GetSelected () const noexcept
 

Private Member Functions

 DECLARE_EVENT_TABLE ()
 

Private Attributes

bool mIsSelected { false }
 

Detailed Description

is like wxStaticText, except it can be themed. wxStaticText can't be.

Definition at line 19 of file auStaticText.h.

Constructor & Destructor Documentation

◆ auStaticText()

auStaticText::auStaticText ( wxWindow *  parent,
wxString  text 
)

Definition at line 33 of file auStaticText.cpp.

33 :
34 wxWindow(parent, wxID_ANY)
35{
36 int textWidth, textHeight;
37
38 int fontSize = 11;
39 #ifdef __WXMSW__
40 fontSize = 9;
41 #endif
42 wxFont font(fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
43 GetTextExtent(textIn, &textWidth, &textHeight, NULL, NULL, &font);
44
45 SetFont( font );
46 SetMinSize( wxSize(textWidth, textHeight) );
47 SetBackgroundColour( theTheme.Colour( clrMedium));
48 SetForegroundColour( theTheme.Colour( clrTrackPanelText));
49 SetName(textIn);
50 SetLabel(textIn);
51}
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxColour & Colour(int iIndex)

References ThemeBase::Colour(), and theTheme.

Here is the call graph for this function:

Member Function Documentation

◆ AcceptsFocus()

bool auStaticText::AcceptsFocus ( ) const
inlineoverride

Definition at line 24 of file auStaticText.h.

24{ return false; }

◆ DECLARE_EVENT_TABLE()

auStaticText::DECLARE_EVENT_TABLE ( )
private

◆ GetSelected()

bool auStaticText::GetSelected ( ) const
noexcept

Definition at line 100 of file auStaticText.cpp.

101{
102 return mIsSelected;
103}
bool mIsSelected
Definition: auStaticText.h:36

References mIsSelected.

◆ OnErase()

void auStaticText::OnErase ( wxEraseEvent &  event)
inline

Definition at line 25 of file auStaticText.h.

25 {
26 static_cast<void>(event);
27 };

◆ OnPaint()

void auStaticText::OnPaint ( wxPaintEvent &  evt)

Definition at line 53 of file auStaticText.cpp.

54{
55 wxPaintDC dc(this);
56 //dc.SetTextForeground( theTheme.Colour( clrTrackPanelText));
57 dc.Clear();
58 dc.DrawText( GetLabel(), 0,0);
59
60 if (mIsSelected)
61 {
62 auto rect = wxRect { GetSize() };
63 AColor::DrawFocus(dc, rect);
64 }
65}
static void DrawFocus(wxDC &dc, wxRect &r)
Definition: AColor.cpp:235

References AColor::DrawFocus(), and mIsSelected.

Here is the call graph for this function:

◆ ScaleFont()

void auStaticText::ScaleFont ( double  scale)
Precondition
scale > 0. Function is a no-op if scale is not positive.

Definition at line 67 of file auStaticText.cpp.

68{
69 if (scale < 0.0)
70 {
71 assert(scale >= 0.0);
72 return;
73 }
74
75 int textWidth, textHeight;
76
77 auto font = GetFont();
78
79 const auto oldFontSize = font.GetPointSize();
80 const auto newFontSize = static_cast<int>(oldFontSize * scale);
81
82 if (newFontSize != oldFontSize)
83 {
84 font.SetPointSize(newFontSize);
85 GetTextExtent(GetLabel(), &textWidth, &textHeight, NULL, NULL, &font);
86 SetFont(font);
87 SetMinSize(wxSize(textWidth, textHeight));
88 }
89}

Referenced by TimeSignatureToolBar::AddTitle().

Here is the caller graph for this function:

◆ SetSelected()

void auStaticText::SetSelected ( bool  selected)

Definition at line 91 of file auStaticText.cpp.

92{
93 if (selected == mIsSelected)
94 return;
95
96 mIsSelected = selected;
97 Refresh();
98}

References mIsSelected.

Member Data Documentation

◆ mIsSelected

bool auStaticText::mIsSelected { false }
private

Definition at line 36 of file auStaticText.h.

Referenced by GetSelected(), OnPaint(), and SetSelected().


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