| 145 | // |
| 146 | |
| 147 | class 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 | |
| 157 | private: |
| 158 | void OnPaint(wxPaintEvent & event); |
| 159 | |
| 160 | private: |
| 161 | TranslatableString mLabel; |
| 162 | int mWidth; |
| 163 | int mHeight; |
| 164 | wxFont mFont; |
| 165 | |
| 166 | DECLARE_EVENT_TABLE() |
| 167 | }; |
| 168 | |
| 169 | BEGIN_EVENT_TABLE(TipWindow, wxFrame) |
| 170 | EVT_PAINT(TipWindow::OnPaint) |
| 171 | END_EVENT_TABLE() |
| 172 | |
| 173 | TipWindow::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); |
no test coverage detected