Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TipWindow Class Referencefinal

A wxPopupWindow used to give the numerical value of an LWSlider or ASlider. More...

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

Public Member Functions

 TipWindow (wxWindow *parent, const TranslatableStrings &labels)
 
virtual ~TipWindow ()
 
wxSize GetSize () const
 
void SetPos (const wxPoint &pos)
 
void SetLabel (const TranslatableString &label)
 

Private Member Functions

void OnPaint (wxPaintEvent &event)
 

Private Attributes

TranslatableString mLabel
 
int mWidth
 
int mHeight
 
wxFont mFont
 

Detailed Description

A wxPopupWindow used to give the numerical value of an LWSlider or ASlider.

Definition at line 146 of file ASlider.cpp.

Constructor & Destructor Documentation

◆ TipWindow()

TipWindow::TipWindow ( wxWindow *  parent,
const TranslatableStrings labels 
)

Definition at line 172 of file ASlider.cpp.

173: wxFrame(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
174 wxFRAME_SHAPED | wxNO_BORDER | wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT )
175{
176 SetBackgroundStyle(wxBG_STYLE_PAINT);
177 SetBackgroundColour(wxTransparentColour);
178
179 mFont.SetPointSize(sliderFontSize);
180 mFont.SetFamily(wxFONTFAMILY_SWISS);
181 mFont.SetStyle(wxFONTSTYLE_NORMAL);
182 mFont.SetWeight(wxFONTWEIGHT_NORMAL);
183
184 mWidth = mHeight = 0;
185 for ( const auto &label : labels ) {
186 int width, height;
187 GetTextExtent(label.Translation(), &width, &height, NULL, NULL, &mFont);
188 mWidth = std::max( mWidth, width );
189 mHeight = std::max( mHeight, height );
190 }
191
192 // Pad to allow for curved corners
193 mWidth += 8;
194 mHeight += 8;
195
196#if defined(__WXMAC__)
197 // Use a bitmap region to set the shape since just adding an unfilled path
198 // will make the window transparent
199 wxBitmap shape(mWidth, mHeight);
200 wxMemoryDC dc(shape);
201
202 dc.SetPen(*wxBLACK_PEN);
203 dc.SetBrush(*wxBLACK_BRUSH);
204 dc.DrawRoundedRectangle(0, 0, mWidth, mHeight, 5);
205 dc.SelectObject(wxNullBitmap);
206
207 SetShape(wxRegion(shape, *wxWHITE));
208#else
209 wxGraphicsPath path = wxGraphicsRenderer::GetDefaultRenderer()->CreatePath();
210 path.AddRoundedRectangle(0, 0, mWidth, mHeight, 5);
211 SetShape(path);
212#endif
213}
const int sliderFontSize
Definition: ASlider.cpp:135
TranslatableString label
Definition: TagsEditor.cpp:165
int mHeight
Definition: ASlider.cpp:162
wxFont mFont
Definition: ASlider.cpp:163
int mWidth
Definition: ASlider.cpp:161
wxString Translation() const

References label, sliderFontSize, and TranslatableString::Translation().

Here is the call graph for this function:

◆ ~TipWindow()

virtual TipWindow::~TipWindow ( )
inlinevirtual

Definition at line 150 of file ASlider.cpp.

150{}

Member Function Documentation

◆ GetSize()

wxSize TipWindow::GetSize ( ) const

Definition at line 215 of file ASlider.cpp.

216{
217 return wxSize(mWidth, mHeight);
218}

References mHeight, and mWidth.

◆ OnPaint()

void TipWindow::OnPaint ( wxPaintEvent &  event)
private

Definition at line 230 of file ASlider.cpp.

231{
232 wxAutoBufferedPaintDC dc(this);
233
234 dc.SetPen(*wxBLACK_PEN);
235 dc.SetBrush(AColor::tooltipBrush);
236 dc.DrawRoundedRectangle(0, 0, mWidth, mHeight, 5);
237
238 dc.SetFont(mFont);
239 dc.SetTextForeground(AColor::tooltipPen.GetColour());
240
241 int textWidth, textHeight;
242 const auto visibleLabel = mLabel.Translation();
243 dc.GetTextExtent(visibleLabel, &textWidth, &textHeight);
244 dc.DrawText(visibleLabel, (mWidth - textWidth) / 2, (mHeight - textHeight) / 2);
245}
static wxPen tooltipPen
Definition: AColor.h:130
static wxBrush tooltipBrush
Definition: AColor.h:131
TranslatableString mLabel
Definition: ASlider.cpp:160

References mFont, mHeight, mLabel, mWidth, AColor::tooltipBrush, AColor::tooltipPen, and TranslatableString::Translation().

Here is the call graph for this function:

◆ SetLabel()

void TipWindow::SetLabel ( const TranslatableString label)

Definition at line 225 of file ASlider.cpp.

226{
227 mLabel = label;
228}

References label, and mLabel.

◆ SetPos()

void TipWindow::SetPos ( const wxPoint &  pos)

Definition at line 220 of file ASlider.cpp.

221{
222 SetSize(pos.x, pos.y, mWidth, mHeight);
223}

References mHeight, and mWidth.

Member Data Documentation

◆ mFont

wxFont TipWindow::mFont
private

Definition at line 163 of file ASlider.cpp.

Referenced by OnPaint().

◆ mHeight

int TipWindow::mHeight
private

Definition at line 162 of file ASlider.cpp.

Referenced by GetSize(), OnPaint(), and SetPos().

◆ mLabel

TranslatableString TipWindow::mLabel
private

Definition at line 160 of file ASlider.cpp.

Referenced by OnPaint(), and SetLabel().

◆ mWidth

int TipWindow::mWidth
private

Definition at line 161 of file ASlider.cpp.

Referenced by GetSize(), OnPaint(), and SetPos().


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