60 : wxControl()
61{
62 SetBackgroundStyle(wxBG_STYLE_PAINT);
63 Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
64 Bind(wxEVT_PAINT, [this](wxPaintEvent&) {
65 wxBufferedPaintDC dc(this);
66 dc.SetBackground(wxBrush(wxColour(38, 46, 48)));
67 dc.Clear();
68
69 dc.SetTextForeground(*wxWHITE);
70
71 wxFontMetrics fm = dc.GetFontMetrics();
72 int textHeight = fm.ascent + fm.descent;
73
74 wxRect rect = GetClientRect();
75 wxString ellipsized = wxControl::Ellipsize(
m_title, dc, wxELLIPSIZE_END, wxMax(0, rect.GetWidth() - FromDIP(8)));
76
77 int y = rect.y + (rect.height - textHeight) / 2 + 1;
78 int x = rect.x + ((ellipsized !=
m_title)
79 ? FromDIP(4)
80 : (rect.
width - dc.GetTextExtent(
m_title).GetWidth()) / 2);
81
82 dc.DrawText(ellipsized, x, y);
83 });
84
85
86 Bind(wxEVT_SIZE, [this](wxSizeEvent& e) {
87 Refresh();
88 e.Skip();
89 });
90
92 if (e.LeftDown() && e.GetClickCount() > 1) return;
93 e.SetPosition(GetParent()->ScreenToClient(ClientToScreen(e.GetPosition())));
94 GetParent()->GetEventHandler()->ProcessEvent(e);
95 };
96
97 Bind(wxEVT_LEFT_DOWN, forwardMouseEvent);
98 Bind(wxEVT_LEFT_DCLICK, forwardMouseEvent);
99}
wxString m_title
Definition BBLTopbar.hpp:35
wxMouseEvent
Definition CameraPopup.cpp:47
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184