OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::UiStyledSwitchPanel Class Reference

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

Inheritance diagram for Slic3r::GUI::UiStyledSwitchPanel:
Collaboration diagram for Slic3r::GUI::UiStyledSwitchPanel:

Public Member Functions

 UiStyledSwitchPanel (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxColour &borderColor, const wxColour &bgColor, bool borderDashed, int borderWidth, int radius, bool isTop)
void AddToLeft (wxWindow *window, int proportion=0, int flag=wxEXPAND, int border=0)
void AddToRight (wxWindow *window, int proportion=0, int flag=wxEXPAND, int border=0)
void Clear (bool deleteWindows)
wxSizer * GetLeftSizer ()
wxSizer * GetRightSizer ()
void LayoutAndFit ()

Protected Member Functions

void OnPaint (wxPaintEvent &event)

Private Attributes

bool m_borderDashed
int m_borderWidth
int m_radius
wxColour m_borderColor
wxColour m_bgColor
bool m_isTop
wxBoxSizer * m_mainSizer {nullptr}
wxBoxSizer * m_contentSizer {nullptr}
wxBoxSizer * m_splitSizer {nullptr}
wxSizer * m_leftSizer {nullptr}
wxSizer * m_rightSizer {nullptr}

Static Private Attributes

static constexpr int labelHeight = 30

Detailed Description

Constructor & Destructor Documentation

◆ UiStyledSwitchPanel()

Slic3r::GUI::UiStyledSwitchPanel::UiStyledSwitchPanel ( wxWindow * parent,
wxWindowID id = wxID_ANY,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
const wxColour & borderColor = wxColour("#EEEEEE"),
const wxColour & bgColor = wxColour("#FFFFFF"),
bool borderDashed = true,
int borderWidth = 2,
int radius = 1,
bool isTop = true )
145 : wxPanel(parent, id, pos, size),
146 m_borderDashed(borderDashed),
147 m_borderWidth(borderWidth),
148 m_radius(radius),
149 m_borderColor(borderColor),
150 m_bgColor(bgColor),
151 m_isTop(isTop)
152{
153
154 SetDoubleBuffered(true);
155 SetBackgroundStyle(wxBG_STYLE_PAINT);
156
157 Bind(wxEVT_PAINT, &UiStyledSwitchPanel::OnPaint, this);
158
159
160
161 m_mainSizer = new wxBoxSizer(wxVERTICAL);
162
163
164 m_mainSizer->AddSpacer(labelHeight);
165
166
167 m_contentSizer = new wxBoxSizer(wxVERTICAL);
168
169
170 m_splitSizer = new wxBoxSizer(wxHORIZONTAL);
171
172
173 m_leftSizer = new wxBoxSizer(wxVERTICAL);
174 m_splitSizer->Add(m_leftSizer, 1, wxEXPAND | wxALL, 0);
175
176
177 m_rightSizer = new wxBoxSizer(wxVERTICAL);
178 m_splitSizer->Add(m_rightSizer, 1, wxEXPAND | wxALL, 0);
179
180
181 m_contentSizer->Add(m_splitSizer, 1, wxEXPAND | wxALL, 0);
182
183
184 m_mainSizer->Add(m_contentSizer, 1, wxEXPAND | wxALL, FromDIP(1));
185
186 SetSizer(m_mainSizer);
187}
wxSizer * m_leftSizer
Definition uiAMSBestPositionPopup.hpp:111
bool m_borderDashed
Definition uiAMSBestPositionPopup.hpp:101
int m_borderWidth
Definition uiAMSBestPositionPopup.hpp:102
wxBoxSizer * m_splitSizer
Definition uiAMSBestPositionPopup.hpp:110
void OnPaint(wxPaintEvent &event)
Definition uiAMSBestPositionPopup.cpp:222
int m_radius
Definition uiAMSBestPositionPopup.hpp:103
wxBoxSizer * m_mainSizer
Definition uiAMSBestPositionPopup.hpp:108
wxSizer * m_rightSizer
Definition uiAMSBestPositionPopup.hpp:112
static constexpr int labelHeight
Definition uiAMSBestPositionPopup.hpp:114
wxColour m_bgColor
Definition uiAMSBestPositionPopup.hpp:105
wxBoxSizer * m_contentSizer
Definition uiAMSBestPositionPopup.hpp:109
bool m_isTop
Definition uiAMSBestPositionPopup.hpp:106
wxColour m_borderColor
Definition uiAMSBestPositionPopup.hpp:104

References labelHeight, m_bgColor, m_borderColor, m_borderDashed, m_borderWidth, m_contentSizer, m_isTop, m_leftSizer, m_mainSizer, m_radius, m_rightSizer, m_splitSizer, and OnPaint().

Here is the call graph for this function:

Member Function Documentation

◆ AddToLeft()

void Slic3r::GUI::UiStyledSwitchPanel::AddToLeft ( wxWindow * window,
int proportion = 0,
int flag = wxEXPAND,
int border = 0 )
210{
211 m_leftSizer->Add(window, proportion, flag, border);
212 Layout();
213}

References m_leftSizer.

◆ AddToRight()

void Slic3r::GUI::UiStyledSwitchPanel::AddToRight ( wxWindow * window,
int proportion = 0,
int flag = wxEXPAND,
int border = 0 )
216{
217 m_rightSizer->Add(window, proportion, flag, border);
218 Layout();
219}

References m_rightSizer.

◆ Clear()

void Slic3r::GUI::UiStyledSwitchPanel::Clear ( bool deleteWindows)
190{
191 if (m_leftSizer)
192 {
193 m_leftSizer->Clear(deleteWindows);
194 m_leftSizer->Layout();
195 }
196
197 if (m_rightSizer)
198 {
199 m_rightSizer->Clear(deleteWindows);
200 m_rightSizer->Layout();
201 }
202
203 LayoutAndFit();
204
205 Refresh();
206 Update();
207}
void LayoutAndFit()
Definition uiAMSBestPositionPopup.hpp:83

References LayoutAndFit(), m_leftSizer, and m_rightSizer.

Here is the call graph for this function:

◆ GetLeftSizer()

wxSizer * Slic3r::GUI::UiStyledSwitchPanel::GetLeftSizer ( )
inline
81{ return m_leftSizer; }

References m_leftSizer.

◆ GetRightSizer()

wxSizer * Slic3r::GUI::UiStyledSwitchPanel::GetRightSizer ( )
inline
82{ return m_rightSizer; }

References m_rightSizer.

◆ LayoutAndFit()

void Slic3r::GUI::UiStyledSwitchPanel::LayoutAndFit ( )
inline
84 {
85 m_leftSizer->Layout();
86 // m_leftSizer->Fit();
87 m_rightSizer->Layout();
88 // m_rightSizer->Fit();
89 m_splitSizer->Layout();
90 // m_splitSizer->Fit();
91 m_contentSizer->Layout();
92 // m_contentSizer->Fit();
93 m_mainSizer->Layout();
94 // m_mainSizer->Fit();
95 Fit();
96 }

References m_contentSizer, m_leftSizer, m_mainSizer, m_rightSizer, and m_splitSizer.

Referenced by Clear().

Here is the caller graph for this function:

◆ OnPaint()

void Slic3r::GUI::UiStyledSwitchPanel::OnPaint ( wxPaintEvent & event)
protected
223{
224 wxPaintDC dc(this);
225 dc.Clear();
226 wxSize clientSize = GetClientSize();
227 int width = clientSize.GetWidth();
228 int height = clientSize.GetHeight() - FromDIP(90); // for selector space
229
230 dc.SetBrush(wxBrush(m_bgColor));
231 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
232 dc.DrawRectangle(wxRect(0, 0, width, height + FromDIP(90)));
233
234 dc.SetBrush(wxBrush(m_bgColor));
235 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
236 dc.DrawRoundedRectangle(wxRect(0, 0, width, height), m_radius);
237
238 wxPen borderPen;
239 if (m_borderDashed)
240 {
241 borderPen = wxPen(wxColour("#ACACAC"), m_borderWidth, wxPENSTYLE_SHORT_DASH);
242 }
243 else
244 {
245 borderPen = wxPen(wxColour("#ACACAC"), m_borderWidth, wxPENSTYLE_SOLID);
246 }
247 dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
248 dc.SetPen(borderPen);
249 // dc.DrawRoundedRectangle(wxRect(offset, offset, width - 2 * offset, height - 2 * offset), m_radius);
250 dc.DrawRoundedRectangle(wxRect(FromDIP(1), FromDIP(1), width - FromDIP(1), height), m_radius);
251
252 int offset = m_borderWidth;
253 int labelX = offset;
254 int labelY = m_isTop ? offset : (height - offset - labelHeight); // true=top, false=bottom
255 labelX += FromDIP(1);
256 labelY += FromDIP(1);
257
258 wxRect labelRoundRect(labelX, labelY, width - 2 * offset - FromDIP(2), FromDIP(labelHeight));
259 wxRect labelRect(labelX, labelY + m_radius, width - 2 * offset - FromDIP(2), FromDIP(labelHeight) - m_radius);
260 dc.SetBrush(wxBrush(m_borderColor));
261 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
262 dc.DrawRoundedRectangle(labelRoundRect, m_radius);
263 dc.DrawRectangle(labelRect);
264
265 // dc.SetPen(wxPen(m_borderColor, m_borderWidth, wxPENSTYLE_SHORT_DASH));
266 dc.SetPen(wxPen(wxColour("#ACACAC"), m_borderWidth, wxPENSTYLE_SHORT_DASH));
267 dc.SetBrush(*wxTRANSPARENT_BRUSH);
268 dc.DrawLine(width / 2, offset, width / 2, height - offset);
269
270 wxFont font12(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
271 dc.SetTextForeground(wxColour("#000000"));
272 // dc.SetFont(font12);
273 dc.SetFont(::Label::Body_14);
274 wxCoord textWidth, textHeight;
275 dc.GetTextExtent(_L("Filament Inlet A"), &textWidth, &textHeight);
276
277 int aTextPosX = labelX + 4 * offset;
278 int aTextPosY = labelY + (labelHeight - textHeight ) / 2;
279 dc.DrawText(_L("Filament Inlet A"), aTextPosX, aTextPosY);
280
281 int bTextPosX = labelX + 4 * offset + width / 2;
282 int bTextPosY = aTextPosY;
283 dc.DrawText(_L("Filament Inlet B"), bTextPosX, bTextPosY);
284
285 height += FromDIP(90); //total height
286
287 dc.SetBrush(wxBrush(m_bgColor));
288 dc.SetPen(wxPen(m_borderColor, m_borderWidth, wxPENSTYLE_SOLID));
289 wxCoord selTextWidth, selTextHeight;
290 dc.GetTextExtent(_L("Filament Track Switch"), &selTextWidth, &selTextHeight);
291
292 int selWidth = selTextWidth + FromDIP(20);
293 int selHeight = FromDIP(44);
294 int selBaseX = (width - selWidth) / 2;
295 int selBaseY = height - FromDIP(56);
296 dc.DrawRoundedRectangle(wxRect(selBaseX, selBaseY, selWidth, selHeight), FromDIP(4));
297 // wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
298 dc.SetTextForeground(wxColour("#262E30"));
299 // dc.SetFont(font);
300 int selTextPosX = selBaseX + (selWidth - selTextWidth) / 2;
301 int selTextPosY = selBaseY + (selHeight - selTextHeight) / 2;
302 dc.DrawText(_L("Filament Track Switch"), selTextPosX, selTextPosY);
303
304 //draw Horizontal
305 int hLBaseX = (width - FromDIP(184)) / 2;
306 int hLBaseY = selBaseY - FromDIP(17);
307 int hWidth = FromDIP(76);
308 int hHeight = FromDIP(5);
309 int hGap = FromDIP(32);
310 wxRect HL(hLBaseX, hLBaseY + FromDIP(1), hWidth, hHeight);
311 wxRect HR(hLBaseX + hWidth + hGap, hLBaseY + FromDIP(1), hWidth, hHeight);
312 dc.SetBrush(wxBrush(wxColour("#D9D9D9")));
313 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
314 dc.DrawRectangle(HL);
315 dc.DrawRectangle(HR);
316 //draw vertical
317 int vLTopBaseX = hLBaseX;
318 int vLTopBaseY = height - FromDIP(90);
319 int vWidht = FromDIP(5);
320 int vHeight = FromDIP(23);
321 // vtopL vtopR
322 dc.DrawRectangle(wxRect(vLTopBaseX, vLTopBaseY, vWidht, vHeight));
323 dc.DrawRectangle(wxRect(vLTopBaseX + FromDIP(184) - vWidht, vLTopBaseY, vWidht, vHeight));
324
325 // vmidL vmidR
326 dc.DrawRectangle(wxRect(vLTopBaseX + hWidth - vWidht, vLTopBaseY + vHeight - vWidht, vWidht, FromDIP(17)));
327 dc.DrawRectangle(wxRect(vLTopBaseX + hWidth + hGap, vLTopBaseY + vHeight - vWidht, vWidht, FromDIP(17)));
328
329 //vbotL vbotR
330 dc.DrawRectangle(wxRect(vLTopBaseX + hWidth - vWidht, height - FromDIP(12), vWidht, FromDIP(12)));
331 dc.DrawRectangle(wxRect(vLTopBaseX + hWidth + hGap, height - FromDIP(12), vWidht, FromDIP(12)));
332 // event.Skip();
333}
#define _L(s)
Definition OBJ.cpp:34
static wxFont Body_14
Definition Label.hpp:53
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582

References _L, Label::Body_14, labelHeight, m_bgColor, m_borderColor, m_borderDashed, m_borderWidth, m_isTop, m_radius, and Slic3r::offset().

Referenced by UiStyledSwitchPanel().

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

Member Data Documentation

◆ labelHeight

int Slic3r::GUI::UiStyledSwitchPanel::labelHeight = 30
staticconstexprprivate

Referenced by UiStyledSwitchPanel(), and OnPaint().

◆ m_bgColor

wxColour Slic3r::GUI::UiStyledSwitchPanel::m_bgColor
private

Referenced by UiStyledSwitchPanel(), and OnPaint().

◆ m_borderColor

wxColour Slic3r::GUI::UiStyledSwitchPanel::m_borderColor
private

Referenced by UiStyledSwitchPanel(), and OnPaint().

◆ m_borderDashed

bool Slic3r::GUI::UiStyledSwitchPanel::m_borderDashed
private

Referenced by UiStyledSwitchPanel(), and OnPaint().

◆ m_borderWidth

int Slic3r::GUI::UiStyledSwitchPanel::m_borderWidth
private

Referenced by UiStyledSwitchPanel(), and OnPaint().

◆ m_contentSizer

wxBoxSizer* Slic3r::GUI::UiStyledSwitchPanel::m_contentSizer {nullptr}
private
109{nullptr};

Referenced by UiStyledSwitchPanel(), and LayoutAndFit().

◆ m_isTop

bool Slic3r::GUI::UiStyledSwitchPanel::m_isTop
private

Referenced by UiStyledSwitchPanel(), and OnPaint().

◆ m_leftSizer

wxSizer* Slic3r::GUI::UiStyledSwitchPanel::m_leftSizer {nullptr}
private

◆ m_mainSizer

wxBoxSizer* Slic3r::GUI::UiStyledSwitchPanel::m_mainSizer {nullptr}
private
108{nullptr};

Referenced by UiStyledSwitchPanel(), and LayoutAndFit().

◆ m_radius

int Slic3r::GUI::UiStyledSwitchPanel::m_radius
private

Referenced by UiStyledSwitchPanel(), and OnPaint().

◆ m_rightSizer

wxSizer* Slic3r::GUI::UiStyledSwitchPanel::m_rightSizer {nullptr}
private

◆ m_splitSizer

wxBoxSizer* Slic3r::GUI::UiStyledSwitchPanel::m_splitSizer {nullptr}
private
110{nullptr};

Referenced by UiStyledSwitchPanel(), and LayoutAndFit().


The documentation for this class was generated from the following files: