Audacity  3.0.3
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 153 of file ASlider.cpp.

Constructor & Destructor Documentation

◆ TipWindow()

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

Definition at line 179 of file ASlider.cpp.

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

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

Here is the call graph for this function:

◆ ~TipWindow()

virtual TipWindow::~TipWindow ( )
inlinevirtual

Definition at line 157 of file ASlider.cpp.

157 {}

Member Function Documentation

◆ GetSize()

wxSize TipWindow::GetSize ( ) const

Definition at line 222 of file ASlider.cpp.

223 {
224  return wxSize(mWidth, mHeight);
225 }

References mHeight, and mWidth.

◆ OnPaint()

void TipWindow::OnPaint ( wxPaintEvent &  event)
private

Definition at line 237 of file ASlider.cpp.

238 {
239  wxAutoBufferedPaintDC dc(this);
240 
241  dc.SetPen(*wxBLACK_PEN);
242  dc.SetBrush(AColor::tooltipBrush);
243  dc.DrawRoundedRectangle(0, 0, mWidth, mHeight, 5);
244 
245  dc.SetFont(mFont);
246  dc.SetTextForeground(AColor::tooltipPen.GetColour());
247 
248  int textWidth, textHeight;
249  const auto visibleLabel = mLabel.Translation();
250  dc.GetTextExtent(visibleLabel, &textWidth, &textHeight);
251  dc.DrawText(visibleLabel, (mWidth - textWidth) / 2, (mHeight - textHeight) / 2);
252 }

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

233 {
234  mLabel = label;
235 }

References label, and mLabel.

◆ SetPos()

void TipWindow::SetPos ( const wxPoint &  pos)

Definition at line 227 of file ASlider.cpp.

228 {
229  SetSize(pos.x, pos.y, mWidth, mHeight);
230 }

References mHeight, and mWidth.

Member Data Documentation

◆ mFont

wxFont TipWindow::mFont
private

Definition at line 170 of file ASlider.cpp.

Referenced by OnPaint().

◆ mHeight

int TipWindow::mHeight
private

Definition at line 169 of file ASlider.cpp.

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

◆ mLabel

TranslatableString TipWindow::mLabel
private

Definition at line 167 of file ASlider.cpp.

Referenced by OnPaint(), and SetLabel().

◆ mWidth

int TipWindow::mWidth
private

Definition at line 168 of file ASlider.cpp.

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


The documentation for this class was generated from the following file:
TipWindow::mFont
wxFont mFont
Definition: ASlider.cpp:170
TipWindow::mWidth
int mWidth
Definition: ASlider.cpp:168
AColor::tooltipBrush
static wxBrush tooltipBrush
Definition: AColor.h:123
label
TranslatableString label
Definition: Tags.cpp:756
AColor::tooltipPen
static wxPen tooltipPen
Definition: AColor.h:122
sliderFontSize
const int sliderFontSize
Definition: ASlider.cpp:142
TipWindow::mHeight
int mHeight
Definition: ASlider.cpp:169
TranslatableString::Translation
wxString Translation() const
Definition: TranslatableString.h:79
TipWindow::mLabel
TranslatableString mLabel
Definition: ASlider.cpp:167