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

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

Inheritance diagram for StepCtrl:
Collaboration diagram for StepCtrl:

Public Member Functions

 StepCtrl (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
virtual void Rescale ()
void SetHint (wxString hint)
bool SetTipFont (wxFont const &font)
int AppendItem (const wxString &item, wxString const &tip={})
void DeleteAllItems ()
unsigned int GetCount () const
int GetSelection () const
void SelectItem (int item)
void Idle ()
wxString GetItemText (unsigned int item) const
int GetItemUseText (wxString txt) const
void SetItemText (unsigned int item, wxString const &value)
bool Create (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
void SetCornerRadius (double radius)
void SetBorderWidth (int width)
void SetTopMargin (int margin)
void SetBorderColor (StateColor const &color)
void SetBorderColorNormal (wxColor const &color)
void SetBorderStyle (wxPenStyle style)
void SetBackgroundColor (StateColor const &color)
void SetBackgroundColorNormal (wxColor const &color)
void SetBackgroundColor2 (StateColor const &color)
void ShowBadge (bool show)

Static Public Member Functions

static wxColor GetParentBackgroundColor (wxWindow *parent)

Protected Member Functions

void eraseEvent (wxEraseEvent &evt)
void sizeEvent (wxSizeEvent &evt)
void paintEvent (wxPaintEvent &evt)
void render (wxDC &dc)

Protected Attributes

wxFont font_tip
StateColor clr_bar
StateColor clr_step
StateColor clr_text
StateColor clr_tip
int radius = 7
int bar_width = 4
std::vector< wxString > steps
std::vector< wxString > tips
wxString hint
int step = -1
wxPoint drag_offset
wxPoint pos_thumb
int border_width = 1
int top_margin = 0
wxPenStyle border_style = wxPENSTYLE_SOLID
StateHandler state_handler
StateColor border_color
StateColor background_color
StateColor background_color2
ScalableBitmap badge

Private Member Functions

void mouseDown (wxMouseEvent &event)
void mouseMove (wxMouseEvent &event)
void mouseUp (wxMouseEvent &event)
void mouseCaptureLost (wxMouseCaptureLostEvent &event)
void doRender (wxDC &dc) override
bool sendStepCtrlEvent (bool changing=false)

Private Attributes

ScalableBitmap bmp_thumb

Detailed Description

Constructor & Destructor Documentation

◆ StepCtrl()

StepCtrl::StepCtrl ( wxWindow * parent,
wxWindowID id,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = 0 )
141 : StepCtrlBase(parent, id, pos, size, style)
142 , bmp_thumb(this, "step_thumb", 36)
143{
145 radius = radius * bmp_thumb.GetBmpHeight() / 36;
146 bar_width = bar_width * bmp_thumb.GetBmpHeight() / 36;
147}
#define style
Definition WipeTowerDialog.cpp:101
int border_width
Definition StaticBox.hpp:68
double radius
Definition StaticBox.hpp:67
StepCtrlBase(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
Definition StepCtrl.cpp:32
int bar_width
Definition StepCtrl.hpp:30
ScalableBitmap bmp_thumb
Definition StepCtrl.hpp:78

References StepCtrlBase::StepCtrlBase(), StepCtrlBase::bar_width, bmp_thumb, StaticBox::border_width, StepCtrlBase::radius, and style.

Here is the call graph for this function:

Member Function Documentation

◆ AppendItem()

int StepCtrlBase::AppendItem ( const wxString & item,
wxString const & tip = {} )
inherited
87{
88 steps.push_back(item);
89 tips.push_back(tip);
90 return steps.size() - 1;
91}
std::vector< wxString > steps
Definition StepCtrl.hpp:32
std::vector< wxString > tips
Definition StepCtrl.hpp:33

References steps, and tips.

◆ Create()

bool StaticBox::Create ( wxWindow * parent,
wxWindowID id = wxID_ANY,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = 0 )
inherited
52{
53 if (style & wxBORDER_NONE)
54 border_width = 0;
55 wxWindow::Create(parent, id, pos, size, style);
57 state_handler.update_binds();
58 SetBackgroundColour(GetParentBackgroundColor(parent));
59 return true;
60}
StateColor border_color
Definition StaticBox.hpp:72
static wxColor GetParentBackgroundColor(wxWindow *parent)
Definition StaticBox.cpp:122
StateHandler state_handler
Definition StaticBox.hpp:71
StateColor background_color
Definition StaticBox.hpp:73
StateColor background_color2
Definition StaticBox.hpp:74

References background_color, background_color2, border_color, border_width, GetParentBackgroundColor(), state_handler, and style.

Referenced by FanSwitchButton::FanSwitchButton(), ImageSwitchButton::ImageSwitchButton(), ModeSwitchButton::ModeSwitchButton(), StaticBox(), Button::Create(), SpinInput::Create(), TabButton::Create(), TempInput::Create(), and TextInput::Create().

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

◆ DeleteAllItems()

void StepCtrlBase::DeleteAllItems ( )
inherited
94{
95 steps.clear();
96 tips.clear();
97 if (step >= 0) {
98 step = -1;
100 }
101}
bool sendStepCtrlEvent(bool changing=false)
Definition StepCtrl.cpp:129
int step
Definition StepCtrl.hpp:36

References sendStepCtrlEvent(), step, steps, and tips.

Here is the call graph for this function:

◆ doRender()

void StepCtrl::doRender ( wxDC & dc)
overrideprivatevirtual

Reimplemented from StaticBox.

223{
224 if (steps.empty()) return;
226
227 wxSize size = GetSize();
228 int states = state_handler.states();
229
230 int itemWidth = size.x / steps.size();
231 wxRect rcBar = {itemWidth / 2, (size.y - bar_width) / 2, size.x - itemWidth, bar_width};
232
233 dc.SetPen(wxPen(clr_bar.colorForStates(states)));
234 dc.SetBrush(wxBrush(clr_bar.colorForStates(states)));
235 dc.DrawRectangle(rcBar);
236 int circleX = itemWidth / 2;
237 int circleY = size.y / 2;
238 dc.SetPen(wxPen(clr_step.colorForStates(states)));
239 dc.SetBrush(wxBrush(clr_step.colorForStates(states)));
240 if (!hint.empty()) {
241 dc.SetFont(font_tip);
242 dc.SetTextForeground(clr_tip.colorForStates(states));
243 wxSize sz = dc.GetTextExtent(hint);
244 dc.DrawText(hint, dc.GetCharWidth(), circleY - FromDIP(20) - sz.y);
245 }
246 for (int i = 0; i < steps.size(); ++i) {
247 bool check = (pos_thumb == wxPoint{0, 0} ? step : pos_thumb.y) == i;
248 dc.DrawEllipse(circleX - radius, circleY - radius, radius * 2, radius * 2);
249 dc.SetFont(GetFont());
250 dc.SetTextForeground(clr_text.colorForStates(states | (check ? StateColor::Checked : 0)));
251 wxSize sz = dc.GetTextExtent(steps[i]);
252 dc.DrawText(steps[i], circleX - sz.x / 2, circleY + 20);
253 if (check) {
254 dc.SetFont(font_tip);
255 dc.SetTextForeground(clr_tip.colorForStates(states));
256 wxSize sz = dc.GetTextExtent(tips[i]);
257 dc.DrawText(tips[i], circleX - sz.x / 2, circleY - 20 - sz.y);
258 sz = bmp_thumb.GetBmpSize();
259 dc.DrawBitmap(bmp_thumb.bmp(), circleX - sz.x / 2, circleY - sz.y / 2);
260 }
261 circleX += itemWidth;
262 }
263}
@ Checked
Definition StateColor.hpp:18
virtual void doRender(wxDC &dc)
Definition StaticBox.cpp:214
StateColor clr_bar
Definition StepCtrl.hpp:25
wxFont font_tip
Definition StepCtrl.hpp:24
wxPoint pos_thumb
Definition StepCtrl.hpp:39
StateColor clr_step
Definition StepCtrl.hpp:26
StateColor clr_tip
Definition StepCtrl.hpp:28
wxString hint
Definition StepCtrl.hpp:34
StateColor clr_text
Definition StepCtrl.hpp:27
bool check(ModelVolumeType volume_type)
Definition GLGizmoEmboss.cpp:515

References StepCtrlBase::bar_width, bmp_thumb, StateColor::Checked, StepCtrlBase::clr_bar, StepCtrlBase::clr_step, StepCtrlBase::clr_text, StepCtrlBase::clr_tip, StaticBox::doRender(), StepCtrlBase::font_tip, StepCtrlBase::hint, StepCtrlBase::pos_thumb, StepCtrlBase::radius, StaticBox::state_handler, StepCtrlBase::step, StepCtrlBase::steps, and StepCtrlBase::tips.

Here is the call graph for this function:

◆ eraseEvent()

void StaticBox::eraseEvent ( wxEraseEvent & evt)
protectedinherited
153{
154 // for transparent background, but not work
155#ifdef __WXMSW__
156 wxDC *dc = evt.GetDC();
157 wxSize size = GetSize();
158 wxClientDC dc2(GetParent());
159 dc->Blit({0, 0}, size, &dc2, GetPosition());
160#endif
161}

◆ GetCount()

unsigned int StepCtrlBase::GetCount ( ) const
inherited
103{ return steps.size(); }

References steps.

◆ GetItemText()

wxString StepCtrlBase::GetItemText ( unsigned int item) const
inherited
106{
107 return item < steps.size() ? steps[item] : wxString{};
108}

References steps.

◆ GetItemUseText()

int StepCtrlBase::GetItemUseText ( wxString txt) const
inherited
111{
112 for(int i = 0; i < steps.size(); i++){
113 if (steps[i] == txt) {
114 return i;
115 }
116 else {
117 continue;
118 }
119 }
120 return 0;
121}

References steps.

◆ GetParentBackgroundColor()

wxColor StaticBox::GetParentBackgroundColor ( wxWindow * parent)
staticinherited
123{
124 if (auto box = dynamic_cast<StaticBox*>(parent)) {
125 if (box->background_color.count() > 0) {
126 if (box->background_color2.count() == 0)
127 return box->background_color.defaultColor();
128 auto s = box->background_color.defaultColor();
129 auto e = box->background_color2.defaultColor();
130 int r = (s.Red() + e.Red()) / 2;
131 int g = (s.Green() + e.Green()) / 2;
132 int b = (s.Blue() + e.Blue()) / 2;
133 return wxColor(r, g, b);
134 }
135 }
136 if (parent)
137 return parent->GetBackgroundColour();
138 return *wxWHITE;
139}
StaticBox()
Definition StaticBox.cpp:33

References StaticBox().

Referenced by Label::Label(), ModeSwitchButton::ModeSwitchButton(), ScalableButton::ScalableButton(), SwitchButton::SwitchButton(), Create(), and SwitchButton::Rescale().

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

◆ GetSelection()

int StepCtrlBase::GetSelection ( ) const
inherited
56{ return step; }

References step.

◆ Idle()

void StepCtrlBase::Idle ( )
inherited
68{
69 if (step != -1) {
70 step = -1;
72 Refresh();
73 }
74}

References sendStepCtrlEvent(), and step.

Here is the call graph for this function:

◆ mouseCaptureLost()

void StepCtrl::mouseCaptureLost ( wxMouseCaptureLostEvent & event)
private
217{
218 wxMouseEvent evt;
219 mouseUp(evt);
220}
void mouseUp(wxMouseEvent &event)
Definition StepCtrl.cpp:200
wxMouseEvent
Definition CameraPopup.cpp:47

References mouseUp().

Referenced by wxDEFINE_EVENT().

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

◆ mouseDown()

void StepCtrl::mouseDown ( wxMouseEvent & event)
private
157{
158 wxPoint pt;
159 event.GetPosition(&pt.x, &pt.y);
160 wxSize size = GetSize();
161 int itemWidth = size.x / steps.size();
162 wxRect rcBar = {0, (size.y - 60) / 2, size.x, 60};
163 int circleX = itemWidth / 2 + itemWidth * step;
164 wxRect rcThumb = {{circleX, size.y / 2}, bmp_thumb.GetBmpSize()};
165 rcThumb.x -= rcThumb.width / 2;
166 rcThumb.y -= rcThumb.height / 2;
167 if (rcThumb.Contains(pt)) {
168 pos_thumb = wxPoint{circleX, size.y / 2};
169 drag_offset = pos_thumb - pt;
170 if (!HasCapture())
171 CaptureMouse();
172 } else if (rcBar.Contains(pt)) {
173 if (pt.x < circleX) {
174 if (step > 0) SelectItem(step - 1);
175 } else {
176 if (step < steps.size() - 1) SelectItem(step + 1);
177 }
178 }
179}
void SelectItem(int item)
Definition StepCtrl.cpp:58
wxPoint drag_offset
Definition StepCtrl.hpp:38

References bmp_thumb, StepCtrlBase::drag_offset, StepCtrlBase::pos_thumb, StepCtrlBase::SelectItem(), StepCtrlBase::step, and StepCtrlBase::steps.

Referenced by wxDEFINE_EVENT().

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

◆ mouseMove()

void StepCtrl::mouseMove ( wxMouseEvent & event)
private
182{
183 if (pos_thumb == wxPoint{0, 0}) return;
184 wxPoint pt;
185 event.GetPosition(&pt.x, &pt.y);
186 pos_thumb.x = pt.x + drag_offset.x;
187 wxSize size = GetSize();
188 int itemWidth = size.x / steps.size();
189 int index = pos_thumb.x / itemWidth;
190 if (index < 0)
191 index = 0;
192 else if (index >= steps.size())
193 index = steps.size() - 1;
194 if (index != pos_thumb.y) {
195 pos_thumb.y = index;
196 Refresh();
197 }
198}

References StepCtrlBase::drag_offset, StepCtrlBase::pos_thumb, and StepCtrlBase::steps.

Referenced by wxDEFINE_EVENT().

Here is the caller graph for this function:

◆ mouseUp()

void StepCtrl::mouseUp ( wxMouseEvent & event)
private
201{
202 if (pos_thumb == wxPoint{0, 0}) return;
203 wxSize size = GetSize();
204 int itemWidth = size.x / steps.size();
205 int index = pos_thumb.x / itemWidth;
206 if (index < 0)
207 index = 0;
208 else if (index >= steps.size())
209 index = steps.size() - 1;
210 pos_thumb = {0, 0};
211 SelectItem(index);
212 if (HasCapture())
213 ReleaseMouse();
214}

References StepCtrlBase::pos_thumb, StepCtrlBase::SelectItem(), and StepCtrlBase::steps.

Referenced by mouseCaptureLost(), and wxDEFINE_EVENT().

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

◆ paintEvent()

void StaticBox::paintEvent ( wxPaintEvent & evt)
protectedinherited
170{
171 // depending on your system you may need to look at double-buffered dcs
172 wxPaintDC dc(this);
173 render(dc);
174}
void render(wxDC &dc)
Definition StaticBox.cpp:181

References render().

Here is the call graph for this function:

◆ render()

void StaticBox::render ( wxDC & dc)
protectedinherited
182{
183#ifdef __WXMSW__
184 if (radius == 0) {
185 doRender(dc);
186 return;
187 }
188
189 wxSize size = GetSize();
190 if (size.x <= 0 || size.y <= 0)
191 return;
192 wxMemoryDC memdc(&dc);
193 if (!memdc.IsOk()) {
194 doRender(dc);
195 return;
196 }
197 wxBitmap bmp(size.x, size.y);
198 memdc.SelectObject(bmp);
199 //memdc.Blit({0, 0}, size, &dc, {0, 0});
200 memdc.SetBackground(wxBrush(GetBackgroundColour()));
201 memdc.Clear();
202 {
203 wxGCDC dc2(memdc);
204 doRender(dc2);
205 }
206
207 memdc.SelectObject(wxNullBitmap);
208 dc.DrawBitmap(bmp, 0, 0);
209#else
210 doRender(dc);
211#endif
212}

References doRender(), and radius.

Referenced by paintEvent(), Button::render(), FanSwitchButton::render(), ImageSwitchButton::render(), SpinInput::render(), TabButton::render(), TempInput::render(), and TextInput::render().

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

◆ Rescale()

void StepCtrl::Rescale ( )
virtual
150{
151 bmp_thumb.msw_rescale();
152 radius = radius * bmp_thumb.GetBmpHeight() / 36;
153 bar_width = bar_width * bmp_thumb.GetBmpHeight() / 36;
154}

References StepCtrlBase::bar_width, bmp_thumb, and StepCtrlBase::radius.

◆ SelectItem()

void StepCtrlBase::SelectItem ( int item)
inherited
59{
60 if (item == step || item < -1 || item >= steps.size() || !sendStepCtrlEvent(true))
61 return;
62 step = item;
64 Refresh();
65}

References sendStepCtrlEvent(), step, and steps.

Referenced by StepCtrl::mouseDown(), StepCtrl::mouseUp(), FilamentStepIndicator::SelectNext(), and StepIndicator::SelectNext().

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

◆ sendStepCtrlEvent()

bool StepCtrlBase::sendStepCtrlEvent ( bool changing = false)
privateinherited
130{
131 wxCommandEvent event(changing ? EVT_STEP_CHANGING : EVT_STEP_CHANGED, GetId());
132 event.SetEventObject(this);
133 event.SetInt(step);
134 GetEventHandler()->ProcessEvent(event);
135 return true;
136}

References step.

Referenced by DeleteAllItems(), Idle(), and SelectItem().

Here is the caller graph for this function:

◆ SetBackgroundColor()

◆ SetBackgroundColor2()

void StaticBox::SetBackgroundColor2 ( StateColor const & color)
inherited
116{
117 background_color2 = color;
118 state_handler.update_binds();
119 Refresh();
120}

References background_color2, and state_handler.

◆ SetBackgroundColorNormal()

void StaticBox::SetBackgroundColorNormal ( wxColor const & color)
inherited
110{
111 background_color.setColorForStates(color, 0);
112 Refresh();
113}

References background_color.

Referenced by Slic3r::GUI::ShortcutCaptureDialog::ShortcutCaptureDialog(), and Slic3r::GUI::HotEndTable::CreateNozzleBox().

Here is the caller graph for this function:

◆ SetBorderColor()

◆ SetBorderColorNormal()

void StaticBox::SetBorderColorNormal ( wxColor const & color)
inherited
97{
98 border_color.setColorForStates(color, 0);
99 Refresh();
100}

References border_color.

Referenced by Slic3r::GUI::ShortcutCaptureDialog::ShortcutCaptureDialog(), and Slic3r::GUI::HotEndTable::CreateNozzleBox().

Here is the caller graph for this function:

◆ SetBorderStyle()

void StaticBox::SetBorderStyle ( wxPenStyle style)
inherited
76{
78 Refresh();
79}
wxPenStyle border_style
Definition StaticBox.hpp:70

References border_style, and style.

◆ SetBorderWidth()

void StaticBox::SetBorderWidth ( int width)
inherited
82{
84 Refresh();
85}
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184

References border_width.

Referenced by MultiSwitchButton::MultiSwitchButton(), Slic3r::GUI::KBShortcutsDialog::create_page(), and Button::SetStyle().

Here is the caller graph for this function:

◆ SetCornerRadius()

◆ SetHint()

void StepCtrlBase::SetHint ( wxString hint)
inherited
82 {
83 this->hint = hint;
84}

References hint.

◆ SetItemText()

void StepCtrlBase::SetItemText ( unsigned int item,
wxString const & value )
inherited
124{
125 if (item >= steps.size()) return;
126 steps[item] = value;
127}

References steps.

◆ SetTipFont()

bool StepCtrlBase::SetTipFont ( wxFont const & font)
inherited
77{
78 font_tip = font;
79 return true;
80}

References font_tip.

◆ SetTopMargin()

void StaticBox::SetTopMargin ( int margin)
inherited
70{
71 this->top_margin = margin;
72 Refresh();
73}
int top_margin
Definition StaticBox.hpp:69

References top_margin.

Referenced by Slic3r::GUI::ExtruderGroup::ExtruderGroup().

Here is the caller graph for this function:

◆ ShowBadge()

void StaticBox::ShowBadge ( bool show)
inherited
142{
143 if (show && badge.name() != "badge") {
144 badge = ScalableBitmap(this, "badge", 18);
145 Refresh();
146 } else if (!show && !badge.name().empty()) {
147 badge = ScalableBitmap {};
148 Refresh();
149 }
150}
ScalableBitmap badge
Definition StaticBox.hpp:75

References badge.

Referenced by Slic3r::GUI::ExtruderGroup::ExtruderGroup().

Here is the caller graph for this function:

◆ sizeEvent()

void StaticBox::sizeEvent ( wxSizeEvent & evt)
protectedinherited
164{
165 Refresh();
166 evt.Skip();
167}

Member Data Documentation

◆ background_color

◆ background_color2

StateColor StaticBox::background_color2
protectedinherited

◆ badge

ScalableBitmap StaticBox::badge
protectedinherited

Referenced by doRender(), and ShowBadge().

◆ bar_width

◆ bmp_thumb

ScalableBitmap StepCtrl::bmp_thumb
private

Referenced by StepCtrl(), doRender(), mouseDown(), and Rescale().

◆ border_color

◆ border_style

wxPenStyle StaticBox::border_style = wxPENSTYLE_SOLID
protectedinherited

Referenced by doRender(), and SetBorderStyle().

◆ border_width

◆ clr_bar

◆ clr_step

◆ clr_text

◆ clr_tip

◆ drag_offset

wxPoint StepCtrlBase::drag_offset
protectedinherited

◆ font_tip

◆ hint

wxString StepCtrlBase::hint
protectedinherited

Referenced by StepCtrl::doRender(), and SetHint().

◆ pos_thumb

wxPoint StepCtrlBase::pos_thumb
protectedinherited

◆ radius

◆ state_handler

◆ step

◆ steps

◆ tips

std::vector<wxString> StepCtrlBase::tips
protectedinherited

◆ top_margin

int StaticBox::top_margin = 0
protectedinherited

Referenced by doRender(), and SetTopMargin().


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