OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
CenteredTitle Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/BBLTopbar.hpp>

Inheritance diagram for CenteredTitle:
Collaboration diagram for CenteredTitle:

Public Member Functions

 CenteredTitle (wxWindow *parent)
void SetTitle (const wxString &title)
wxSize DoGetBestSize () const override

Private Attributes

wxString m_title

Detailed Description

Constructor & Destructor Documentation

◆ CenteredTitle()

CenteredTitle::CenteredTitle ( wxWindow * parent)
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) // is ellipsized
79 ? FromDIP(4) // align to left when clipped
80 : (rect.width - dc.GetTextExtent(m_title).GetWidth()) / 2); // centered when has available space
81
82 dc.DrawText(ellipsized, x, y);
83 });
84
85 // repaint for Ellipsize
86 Bind(wxEVT_SIZE, [this](wxSizeEvent& e) {
87 Refresh();
88 e.Skip();
89 });
90
91 auto forwardMouseEvent = [this](wxMouseEvent& e) {
92 if (e.LeftDown() && e.GetClickCount() > 1) return; // prevent duplicate event
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

References m_title, and Slic3r::GUI::wxMouseEvent.

Member Function Documentation

◆ DoGetBestSize()

wxSize CenteredTitle::DoGetBestSize ( ) const
override
108{
109 return wxSize(10, FromDIP(30));
110}

◆ SetTitle()

void CenteredTitle::SetTitle ( const wxString & title)
101 {
102 m_title = title;
103 Refresh();
104}

References m_title.

Member Data Documentation

◆ m_title

wxString CenteredTitle::m_title
private

Referenced by CenteredTitle(), and SetTitle().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/BBLTopbar.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/BBLTopbar.cpp