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 148 of file ASlider.cpp.

Constructor & Destructor Documentation

◆ TipWindow()

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

Definition at line 174 of file ASlider.cpp.

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

152{}

Member Function Documentation

◆ GetSize()

wxSize TipWindow::GetSize ( ) const

Definition at line 217 of file ASlider.cpp.

218{
219 return wxSize(mWidth, mHeight);
220}

References mHeight, and mWidth.

◆ OnPaint()

void TipWindow::OnPaint ( wxPaintEvent &  event)
private

Definition at line 232 of file ASlider.cpp.

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

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 227 of file ASlider.cpp.

228{
229 mLabel = label;
230}

References label, and mLabel.

◆ SetPos()

void TipWindow::SetPos ( const wxPoint &  pos)

Definition at line 222 of file ASlider.cpp.

223{
224 SetSize(pos.x, pos.y, mWidth, mHeight);
225}

References mHeight, and mWidth.

Member Data Documentation

◆ mFont

wxFont TipWindow::mFont
private

Definition at line 165 of file ASlider.cpp.

Referenced by OnPaint().

◆ mHeight

int TipWindow::mHeight
private

Definition at line 164 of file ASlider.cpp.

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

◆ mLabel

TranslatableString TipWindow::mLabel
private

Definition at line 162 of file ASlider.cpp.

Referenced by OnPaint(), and SetLabel().

◆ mWidth

int TipWindow::mWidth
private

Definition at line 163 of file ASlider.cpp.

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


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