MCPcopy Create free account
hub / github.com/audacity/audacity / TipWindow

Class TipWindow

src/widgets/ASlider.cpp:147–617  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145//
146
147class TipWindow final : public wxFrame
148{
149 public:
150 TipWindow(wxWindow *parent, const TranslatableStrings & labels);
151 virtual ~TipWindow() {}
152
153 wxSize GetSize() const;
154 void SetPos(const wxPoint & pos);
155 void SetLabel(const TranslatableString & label);
156
157private:
158 void OnPaint(wxPaintEvent & event);
159
160private:
161 TranslatableString mLabel;
162 int mWidth;
163 int mHeight;
164 wxFont mFont;
165
166 DECLARE_EVENT_TABLE()
167};
168
169BEGIN_EVENT_TABLE(TipWindow, wxFrame)
170 EVT_PAINT(TipWindow::OnPaint)
171END_EVENT_TABLE()
172
173TipWindow::TipWindow(wxWindow *parent, const TranslatableStrings & labels)
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);

Callers 1

CreatePopWinMethod · 0.70

Calls 13

GetFunction · 0.85
InitClass · 0.85
SetFontMethod · 0.80
TranslationMethod · 0.80
DrawTextMethod · 0.80
SendUpdateMethod · 0.80
SkipMethod · 0.80
wxSizeClass · 0.70
GetMethod · 0.45
TransferToWindowMethod · 0.45
SetSelectionMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected