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

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

Inheritance diagram for TabButtonsListCtrl:
Collaboration diagram for TabButtonsListCtrl:

Public Member Functions

 TabButtonsListCtrl (wxWindow *parent, wxBoxSizer *side_tools=NULL)
 ~TabButtonsListCtrl ()
void OnPaint (wxPaintEvent &)
void SetSelection (int sel)
void showNewTag (int sel, bool show=false)
void Rescale ()
bool InsertPage (size_t n, const wxString &text, bool bSelect=false, const std::string &bmp_name="")
void RemovePage (size_t n)
bool SetPageImage (size_t n, const std::string &bmp_name)
void SetPageText (size_t n, const wxString &strText)
wxString GetPageText (size_t n) const
const wxSize & GetPaddingSize (size_t n)
void SetPaddingSize (const wxSize &size)
void SetFooterText (const wxString &text)

Public Attributes

TabButton * pageButton

Private Attributes

wxFlexGridSizer * m_buttons_sizer
wxBoxSizer * m_sizer
ScalableBitmap m_arrow_img
std::vector< TabButton * > m_pageButtons
int m_selection {-1}
int m_btn_margin
int m_line_margin
wxStaticText * m_footer_text {nullptr}

Detailed Description

Constructor & Destructor Documentation

◆ TabButtonsListCtrl()

TabButtonsListCtrl::TabButtonsListCtrl ( wxWindow * parent,
wxBoxSizer * side_tools = NULL )
37 :
38 wxControl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxTAB_TRAVERSAL)
39{
40#ifdef __WINDOWS__
41 SetDoubleBuffered(true);
42#endif //__WINDOWS__
43 SetBackgroundColour(TAB_BUTTON_BG);
44
45 int em = em_unit(this);
46 // BBS: no gap
47 m_btn_margin = 0;
48 m_line_margin = std::lround(0.1 * em);
49
50 m_arrow_img = ScalableBitmap(this, "monitor_arrow", 14);
51
52 m_sizer = new wxBoxSizer(wxVERTICAL);
53 this->SetSizer(m_sizer);
54 if (side_tools != NULL) {
55 for (size_t idx = 0; idx < side_tools->GetItemCount(); idx++) {
56 wxSizerItem *item = side_tools->GetItem(idx);
57 wxWindow * item_win = item->GetWindow();
58 if (item_win) { item_win->Reparent(this); }
59 }
60 m_sizer->Add(side_tools, 0, wxEXPAND | wxLEFT | wxTOP, m_btn_margin);
61 }
62
63 m_buttons_sizer = new wxFlexGridSizer(1, m_btn_margin, m_btn_margin);
64 m_sizer->Add(m_buttons_sizer, 0, wxLEFT | wxTOP, m_btn_margin);
65 m_sizer->AddStretchSpacer(1);
66}
static const wxColour TAB_BUTTON_BG
Definition Tabbook.cpp:26
int m_line_margin
Definition Tabbook.hpp:60
wxFlexGridSizer * m_buttons_sizer
Definition Tabbook.hpp:54
wxBoxSizer * m_sizer
Definition Tabbook.hpp:55
ScalableBitmap m_arrow_img
Definition Tabbook.hpp:56
int m_btn_margin
Definition Tabbook.hpp:59
int em_unit(wxWindow *win)
Definition wxExtensions.cpp:424

References em_unit(), m_arrow_img, m_btn_margin, m_buttons_sizer, m_line_margin, m_sizer, and TAB_BUTTON_BG.

Here is the call graph for this function:

◆ ~TabButtonsListCtrl()

TabButtonsListCtrl::~TabButtonsListCtrl ( )
inline
37{}

Member Function Documentation

◆ GetPaddingSize()

const wxSize & TabButtonsListCtrl::GetPaddingSize ( size_t n)
199 {
200 return m_pageButtons[n]->GetPaddingSize();
201}
std::vector< TabButton * > m_pageButtons
Definition Tabbook.hpp:57

References m_pageButtons.

◆ GetPageText()

wxString TabButtonsListCtrl::GetPageText ( size_t n) const
194{
195 TabButton *btn = m_pageButtons[n];
196 return btn->GetLabel();
197}

References m_pageButtons.

Referenced by Tabbook::GetPageText().

Here is the caller graph for this function:

◆ InsertPage()

bool TabButtonsListCtrl::InsertPage ( size_t n,
const wxString & text,
bool bSelect = false,
const std::string & bmp_name = "" )
137{
138 TabButton *btn = new TabButton(this, text, m_arrow_img, wxNO_BORDER);
139 btn->SetCornerRadius(0);
140
141 int em = em_unit(this);
142 btn->SetMinSize({BUTTON_DEF_WIDTH * em / 10, BUTTON_DEF_HEIGHT * em / 10});
143
145 btn->SetTextColor(*wxBLACK);
146 btn->Bind(wxEVT_BUTTON, [this, btn](wxCommandEvent& event) {
147 if (auto it = std::find(m_pageButtons.begin(), m_pageButtons.end(), btn); it != m_pageButtons.end()) {
148 auto sel = it - m_pageButtons.begin();
149 SetSelection(sel);
150 wxCommandEvent evt = wxCommandEvent(wxCUSTOMEVT_TABBOOK_SEL_CHANGED);
151 evt.SetId(sel);
152 wxPostEvent(this->GetParent(), evt);
153 }
154 });
155 Slic3r::GUI::wxGetApp().UpdateDarkUI(btn);
156 m_pageButtons.insert(m_pageButtons.begin() + n, btn);
157 m_buttons_sizer->Insert(n, new wxSizerItem(btn));
158 m_buttons_sizer->SetRows(m_pageButtons.size() + 1);
159 m_sizer->Layout();
160 return true;
161}
static const int BUTTON_DEF_WIDTH
Definition Tabbook.cpp:34
static const int BUTTON_DEF_HEIGHT
Definition Tabbook.cpp:33
void SetCornerRadius(double radius)
Definition StaticBox.cpp:62
void SetBackgroundColor(StateColor const &color)
Definition StaticBox.cpp:102
void SetMinSize(const wxSize &size) override
Definition TabButton.cpp:76
void SetTextColor(StateColor const &color)
Definition TabButton.cpp:93
void SetSelection(int sel)
Definition Tabbook.cpp:111

References BUTTON_DEF_HEIGHT, BUTTON_DEF_WIDTH, em_unit(), m_arrow_img, m_buttons_sizer, m_pageButtons, m_sizer, StaticBox::SetBackgroundColor(), StaticBox::SetCornerRadius(), TabButton::SetMinSize(), SetSelection(), TabButton::SetTextColor(), and TAB_BUTTON_BG.

Referenced by Tabbook::InsertPage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPaint()

void TabButtonsListCtrl::OnPaint ( wxPaintEvent & )
69{
70 Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
71 const wxSize sz = GetSize();
72 wxPaintDC dc(this);
73
75 return;
76
77 const wxColour& btn_marker_color = Slic3r::GUI::wxGetApp().get_color_hovered_btn_label();
78
79 // highlight selected notebook button
80
81 for (int idx = 0; idx < int(m_pageButtons.size()); idx++) {
82 TabButton *btn = m_pageButtons[idx];
84
85 wxPoint pos = btn->GetPosition();
86 wxSize size = btn->GetSize();
87 const wxColour &clr = StateColor::darkModeColorFor(idx == m_selection ? btn_marker_color : TAB_BUTTON_BG);
88 dc.SetPen(clr);
89 dc.SetBrush(clr);
90 dc.DrawRectangle(pos.x, pos.y + size.y, size.x, sz.y - size.y);
91 }
92 dc.SetPen(btn_marker_color);
93 dc.SetBrush(btn_marker_color);
94 dc.DrawRectangle(1, sz.y - m_line_margin, sz.x, m_line_margin);
95}
static const wxColour TAB_BUTTON_SEL
Definition Tabbook.cpp:27
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
int m_selection
Definition Tabbook.hpp:58
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References StateColor::darkModeColorFor(), m_line_margin, m_pageButtons, m_selection, StaticBox::SetBackgroundColor(), TAB_BUTTON_BG, and TAB_BUTTON_SEL.

Here is the call graph for this function:

◆ RemovePage()

void TabButtonsListCtrl::RemovePage ( size_t n)
164{
165 if (n >= m_pageButtons.size()) return;
166 TabButton *btn = m_pageButtons[n];
167 m_pageButtons.erase(m_pageButtons.begin() + n);
168 m_buttons_sizer->Remove(n);
169 btn->Reparent(nullptr);
170 btn->Destroy();
171 m_sizer->Layout();
172}

References m_buttons_sizer, m_pageButtons, and m_sizer.

Referenced by Tabbook::DoRemovePage().

Here is the caller graph for this function:

◆ Rescale()

void TabButtonsListCtrl::Rescale ( )
98{
99 m_arrow_img = ScalableBitmap(this, "monitor_arrow", 14);
100
101 int em = em_unit(this);
102 for (TabButton *btn : m_pageButtons) {
103 btn->SetMinSize({BUTTON_DEF_WIDTH * em / 10, BUTTON_DEF_HEIGHT * em / 10});
104 btn->SetBitmap(m_arrow_img);
105 btn->Rescale();
106 }
107
108 m_sizer->Layout();
109}

References BUTTON_DEF_HEIGHT, BUTTON_DEF_WIDTH, em_unit(), m_arrow_img, m_pageButtons, and m_sizer.

Referenced by Tabbook::Rescale().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFooterText()

void TabButtonsListCtrl::SetFooterText ( const wxString & text)
210{
211 if (!m_footer_text) {
212 m_footer_text = new wxStaticText(this, wxID_ANY, text);
213 m_footer_text->SetForegroundColour(wxColour(128, 128, 128));
215 int em = em_unit(this);
216 m_sizer->Add(m_footer_text, 0, wxALL, FromDIP(18)); // ORCA reduce / match left margin buttons on sidebars
217 } else {
218 m_footer_text->SetLabel(text);
219 }
220 m_sizer->Layout();
221}
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static wxFont Body_10
Definition Label.hpp:56
wxStaticText * m_footer_text
Definition Tabbook.hpp:61

References Label::Body_10, em_unit(), m_footer_text, m_sizer, and wxStaticText.

Referenced by Tabbook::SetFooterText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPaddingSize()

void TabButtonsListCtrl::SetPaddingSize ( const wxSize & size)
203 {
204 for (auto& btn : m_pageButtons) {
205 btn->SetPaddingSize(size);
206 }
207}

References m_pageButtons.

◆ SetPageImage()

bool TabButtonsListCtrl::SetPageImage ( size_t n,
const std::string & bmp_name )
175{
176 if (n >= m_pageButtons.size())
177 return false;
178
179 ScalableBitmap bitmap;
180 if (!bmp_name.empty())
181 bitmap = ScalableBitmap(this, bmp_name, 14);
182 m_pageButtons[n]->SetBitmap(bitmap);
183
184 return true;
185}

References m_pageButtons.

Referenced by Tabbook::SetPageImage().

Here is the caller graph for this function:

◆ SetPageText()

void TabButtonsListCtrl::SetPageText ( size_t n,
const wxString & strText )
188{
189 TabButton *btn = m_pageButtons[n];
190 btn->SetLabel(strText);
191}
void SetLabel(const wxString &label) override
Definition TabButton.cpp:69

References m_pageButtons, and TabButton::SetLabel().

Referenced by Tabbook::SetPageText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetSelection()

void TabButtonsListCtrl::SetSelection ( int sel)
112{
113 if (m_selection == sel)
114 return;
115 if (m_selection >= 0) {
116 m_pageButtons[m_selection]->SetBackgroundColor(TAB_BUTTON_BG);
118 }
119 m_selection = sel;
120 m_pageButtons[m_selection]->SetBackgroundColor(TAB_BUTTON_SEL);
122 Refresh();
123}
static const wxFont & TAB_BUTTON_FONT_SEL
Definition Tabbook.cpp:30
static const wxFont & TAB_BUTTON_FONT
Definition Tabbook.cpp:29

References m_pageButtons, m_selection, TAB_BUTTON_BG, TAB_BUTTON_FONT, TAB_BUTTON_FONT_SEL, and TAB_BUTTON_SEL.

Referenced by Tabbook::ChangeSelection(), InsertPage(), and Tabbook::SetSelection().

Here is the caller graph for this function:

◆ showNewTag()

void TabButtonsListCtrl::showNewTag ( int sel,
bool show = false )
126{
127 if (m_pageButtons[sel]->GetShowNewTag() == tag)
128 {
129 return;
130 }
131
132 m_pageButtons[sel]->ShowNewTag(tag);
133 Refresh();
134}

References m_pageButtons.

Member Data Documentation

◆ m_arrow_img

ScalableBitmap TabButtonsListCtrl::m_arrow_img
private

◆ m_btn_margin

int TabButtonsListCtrl::m_btn_margin
private

Referenced by TabButtonsListCtrl().

◆ m_buttons_sizer

wxFlexGridSizer* TabButtonsListCtrl::m_buttons_sizer
private

◆ m_footer_text

wxStaticText* TabButtonsListCtrl::m_footer_text {nullptr}
private
61{nullptr};

Referenced by SetFooterText().

◆ m_line_margin

int TabButtonsListCtrl::m_line_margin
private

Referenced by TabButtonsListCtrl(), and OnPaint().

◆ m_pageButtons

◆ m_selection

int TabButtonsListCtrl::m_selection {-1}
private
58{-1};

Referenced by OnPaint(), and SetSelection().

◆ m_sizer

wxBoxSizer* TabButtonsListCtrl::m_sizer
private

◆ pageButton

TabButton* TabButtonsListCtrl::pageButton

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