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

Constructor & Destructor Documentation

◆ TipWindow()

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

Definition at line 173 of file ASlider.cpp.

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

151{}

Member Function Documentation

◆ GetSize()

wxSize TipWindow::GetSize ( ) const

Definition at line 216 of file ASlider.cpp.

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

References mHeight, and mWidth.

◆ OnPaint()

void TipWindow::OnPaint ( wxPaintEvent &  event)
private

Definition at line 231 of file ASlider.cpp.

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

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

227{
228 mLabel = label;
229}

References label, and mLabel.

◆ SetPos()

void TipWindow::SetPos ( const wxPoint &  pos)

Definition at line 221 of file ASlider.cpp.

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

References mHeight, and mWidth.

Member Data Documentation

◆ mFont

wxFont TipWindow::mFont
private

Definition at line 164 of file ASlider.cpp.

Referenced by OnPaint().

◆ mHeight

int TipWindow::mHeight
private

Definition at line 163 of file ASlider.cpp.

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

◆ mLabel

TranslatableString TipWindow::mLabel
private

Definition at line 161 of file ASlider.cpp.

Referenced by OnPaint(), and SetLabel().

◆ mWidth

int TipWindow::mWidth
private

Definition at line 162 of file ASlider.cpp.

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


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