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

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

Inheritance diagram for TempInput:
Collaboration diagram for TempInput:

Public Types

enum  WarningType { WARNING_TOO_HIGH , WARNING_TOO_LOW , WARNING_UNKNOWN }

Public Member Functions

 TempInput ()
 TempInput (wxWindow *parent, int type, wxString text, TempInputType input_type, wxString label="", wxString normal_icon="", wxString actice_icon="", const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
void Create (wxWindow *parent, wxString text, wxString label="", wxString normal_icon="", wxString actice_icon="", const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
wxString erasePending (wxString &str)
void SetTagTemp (int temp)
void SetTagTemp (wxString temp)
void SetCurrTemp (int temp)
void SetCurrTemp (wxString temp)
void SetCurrType (TempInputType type)
TempInputType GetCurrType ()
bool AllisNum (std::string str)
void SetFinish ()
void Warning (bool warn, WarningType type=WARNING_UNKNOWN)
void SetIconActive ()
void SetIconNormal ()
void SetReadOnly (bool ro)
void SetMaxTemp (int temp)
void SetMinTemp (int temp)
void AddTemp (int temp)
int GetType ()
wxString GetTagTemp ()
wxString GetCurrTemp ()
int get_max_temp ()
void SetLabel (const wxString &label) override
void SetTextColor (StateColor const &color)
void SetLabelColor (StateColor const &color)
virtual void Rescale ()
virtual bool Enable (bool enable=true) override
virtual void SetMinSize (const wxSize &size) override
wxTextCtrl * GetTextCtrl ()
wxTextCtrl const * GetTextCtrl () const
bool IsOnChanging () const
void SetOnChanging ()
void ReSetOnChanging ()

Public Attributes

wxPopupTransientWindow * wdialog {nullptr}
int temp_type
bool actice = false
wxString currentTemp

Protected Member Functions

virtual void DoSetSize (int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO) override
void DoSetToolTipText (wxString const &tip) override

Private Member Functions

void ResetWaringDlg ()
bool CheckIsValidVal (bool show_warning)
void paintEvent (wxPaintEvent &evt)
void render (wxDC &dc)
void messureMiniSize ()
void messureSize ()
void mouseMoved (wxMouseEvent &event)
void mouseWheelMoved (wxMouseEvent &event)
void mouseEnterWindow (wxMouseEvent &event)
void mouseLeaveWindow (wxMouseEvent &event)
void keyPressed (wxKeyEvent &event)
void keyReleased (wxKeyEvent &event)

Private Attributes

bool hover
bool m_read_only {false}
bool m_on_changing {false}
wxSize labelSize
ScalableBitmap normal_icon
ScalableBitmap actice_icon
ScalableBitmap degree_icon
ScalableBitmap round_scale_hint_icon
StateColor label_color
StateColor text_color
wxTextCtrl * text_ctrl
wxStaticText * warning_text
int max_temp = 0
int min_temp = 0
std::unordered_set< int > additional_temps
bool warning_mode = false
TempInputType m_input_type
int padding_left = 0

Static Private Attributes

static const int TempInputWidth = 200
static const int TempInputHeight = 50

Detailed Description

Member Enumeration Documentation

◆ WarningType

Enumerator
WARNING_TOO_HIGH 
WARNING_TOO_LOW 
WARNING_UNKNOWN 
62 {
66 };
@ WARNING_TOO_HIGH
Definition TempInput.hpp:63
@ WARNING_UNKNOWN
Definition TempInput.hpp:65
@ WARNING_TOO_LOW
Definition TempInput.hpp:64

Constructor & Destructor Documentation

◆ TempInput() [1/2]

TempInput::TempInput ( )
37 : label_color(std::make_pair(wxColour(0xAC,0xAC,0xAC), (int) StateColor::Disabled),std::make_pair(0x323A3C, (int) StateColor::Normal))
38 , text_color(std::make_pair(wxColour(0xAC,0xAC,0xAC), (int) StateColor::Disabled), std::make_pair(0x6B6B6B, (int) StateColor::Normal))
39{
40 hover = false;
41 radius = 0;
42 border_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(0x009688, (int) StateColor::Focused), std::make_pair(0x009688, (int) StateColor::Hovered),
43 std::make_pair(*wxWHITE, (int) StateColor::Normal));
44 background_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(*wxWHITE, (int) StateColor::Normal));
45 SetFont(Label::Body_12);
46}
static wxFont Body_12
Definition Label.hpp:55
@ Hovered
Definition StateColor.hpp:20
@ Normal
Definition StateColor.hpp:16
@ Disabled
Definition StateColor.hpp:22
@ Focused
Definition StateColor.hpp:19
StateColor text_color
Definition TempInput.hpp:47
StateColor label_color
Definition TempInput.hpp:46
bool hover
Definition TempInput.hpp:36

References TempInput(), Label::Body_12, StateColor::Disabled, StateColor::Focused, hover, StateColor::Hovered, label_color, StateColor::Normal, and text_color.

Referenced by TempInput(), and TempInput().

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

◆ TempInput() [2/2]

TempInput::TempInput ( wxWindow * parent,
int type,
wxString text,
TempInputType input_type,
wxString label = "",
wxString normal_icon = "",
wxString actice_icon = "",
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = 0 )
49 : TempInput()
50{
51 actice = false;
52 temp_type = type;
53 m_input_type = input_type;
54 Create(parent, text, label, normal_icon, actice_icon, pos, size, style);
55}
#define style
Definition WipeTowerDialog.cpp:101
TempInput()
Definition TempInput.cpp:36
int temp_type
Definition TempInput.hpp:93
ScalableBitmap actice_icon
Definition TempInput.hpp:42
void Create(wxWindow *parent, wxString text, wxString label="", wxString normal_icon="", wxString actice_icon="", const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
Definition TempInput.cpp:96
bool actice
Definition TempInput.hpp:94
ScalableBitmap normal_icon
Definition TempInput.hpp:41
TempInputType m_input_type
Definition TempInput.hpp:56

References TempInput(), actice, actice_icon, Create(), m_input_type, normal_icon, style, and temp_type.

Here is the call graph for this function:

Member Function Documentation

◆ AddTemp()

void TempInput::AddTemp ( int temp)
inline
118{ additional_temps.insert(temp); };
std::unordered_set< int > additional_temps
Definition TempInput.hpp:54

References additional_temps.

◆ AllisNum()

bool TempInput::AllisNum ( std::string str)
170{
171 for (int i = 0; i < str.size(); i++) {
172 int tmp = (int) str[i];
173 if (tmp >= 48 && tmp <= 57) {
174 continue;
175 } else {
176 return false;
177 }
178 }
179 return true;
180}

Referenced by CheckIsValidVal().

Here is the caller graph for this function:

◆ CheckIsValidVal()

bool TempInput::CheckIsValidVal ( bool show_warning)
private
64{
65 auto temp = text_ctrl->GetValue();
66 if (temp.ToStdString().empty())
67 {
68 return false;
69 }
70
71 if (!AllisNum(temp.ToStdString()))
72 {
73 return false;
74 }
75
76 /*show temperature range warnings*/
77 auto tempint = std::stoi(temp.ToStdString());
78 if (additional_temps.count(tempint) == 0)
79 {
80 if (tempint > max_temp)
81 {
82 if (show_warning) { Warning(true, WARNING_TOO_HIGH); }
83 return false;
84 }
85 else if (tempint < min_temp)
86 {
87 if (show_warning) { Warning(true, WARNING_TOO_LOW); }
88 return false;
89 }
90 }
91
92
93 return true;
94}
@ Warning
Definition Auxiliary.hpp:87
wxTextCtrl * text_ctrl
Definition TempInput.hpp:49
int max_temp
Definition TempInput.hpp:52
bool AllisNum(std::string str)
Definition TempInput.cpp:169
int min_temp
Definition TempInput.hpp:53

References additional_temps, AllisNum(), max_temp, min_temp, text_ctrl, Warning, WARNING_TOO_HIGH, and WARNING_TOO_LOW.

Referenced by Create().

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

◆ Create()

void TempInput::Create ( wxWindow * parent,
wxString text,
wxString label = "",
wxString normal_icon = "",
wxString actice_icon = "",
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = 0 )
97{
98 StaticBox::Create(parent, wxID_ANY, pos, size, style);
99 wxWindow::SetLabel(label);
100 style &= ~wxALIGN_CENTER_HORIZONTAL;
101 state_handler.attach({&label_color, &text_color});
102 state_handler.update_binds();
103 text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {5, 5}, wxDefaultSize, wxTE_PROCESS_ENTER | wxBORDER_NONE, wxTextValidator(wxFILTER_NUMERIC), wxTextCtrlNameStr);
104 text_ctrl->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
105 text_ctrl->SetMaxLength(3);
106 state_handler.attach_child(text_ctrl);
107 text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) {
108 e.SetId(GetId());
109 ProcessEventLocally(e);
110 e.Skip();
111 if (m_read_only) return;
112 // enter input mode
113 auto temp = text_ctrl->GetValue();
114 if (temp.length() > 0 && temp[0] == (0x5f)) {
115 text_ctrl->SetValue(wxEmptyString);
116 }
117 if (wdialog != nullptr) { wdialog->Dismiss(); }
118 });
119 text_ctrl->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
120 if (m_read_only) { SetCursor(wxCURSOR_ARROW); }
121 });
122 text_ctrl->Bind(wxEVT_KILL_FOCUS, [this](auto &e) {
123 e.SetId(GetId());
124 ProcessEventLocally(e);
125 e.Skip();
126
127 if (!m_on_changing) /*the wxCUSTOMEVT_SET_TEMP_FINISH event may popup a dialog, which may generate dead loop*/
128 {
130 SetFinish();
131 }
132 });
133 text_ctrl->Bind(wxEVT_TEXT_ENTER, [this](wxCommandEvent &e)
134 {
135 if (!m_on_changing) /*the wxCUSTOMEVT_SET_TEMP_FINISH event may popup a dialog, which may generate dead loop*/
136 {
137 /*clear previous status*/
139
140 /*check the value is valid or not*/
141 if (CheckIsValidVal(true))
142 {
143 SetFinish();
144
145 SetOnChanging();// filter in wxEVT_KILL_FOCUS while navigating
146 text_ctrl->Navigate(); // quit edit mode
148 }
149 }
150 });
151 text_ctrl->Bind(wxEVT_RIGHT_DOWN, [](auto &e) {}); // disable context menu
152 text_ctrl->Bind(wxEVT_LEFT_DOWN, [this](auto &e) {
153 if (m_read_only) {
154 return;
155 } else {
156 e.Skip();
157 }
158 });
159 text_ctrl->SetFont(Label::Body_13);
160 text_ctrl->SetForegroundColour(StateColor::darkModeColorFor(*wxBLACK));
161 if (!normal_icon.IsEmpty()) { this->normal_icon = ScalableBitmap(this, normal_icon.ToStdString(), 16); }
162 if (!actice_icon.IsEmpty()) { this->actice_icon = ScalableBitmap(this, actice_icon.ToStdString(), 16); }
163 this->round_scale_hint_icon = ScalableBitmap(this, "round", 16);
164 this->degree_icon = ScalableBitmap(this, "degree", 16);
165 messureSize();
166}
static wxFont Body_13
Definition Label.hpp:54
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
Definition StaticBox.cpp:51
void SetOnChanging()
Definition TempInput.hpp:142
void ResetWaringDlg()
Definition TempInput.cpp:57
void messureSize()
Definition TempInput.cpp:613
ScalableBitmap degree_icon
Definition TempInput.hpp:43
wxPopupTransientWindow * wdialog
Definition TempInput.hpp:92
bool m_read_only
Definition TempInput.hpp:38
bool CheckIsValidVal(bool show_warning)
Definition TempInput.cpp:63
bool m_on_changing
Definition TempInput.hpp:39
ScalableBitmap round_scale_hint_icon
Definition TempInput.hpp:44
void ReSetOnChanging()
Definition TempInput.hpp:143
void SetFinish()
Definition TempInput.cpp:182

References actice_icon, Label::Body_13, CheckIsValidVal(), StaticBox::Create(), StateColor::darkModeColorFor(), degree_icon, label_color, m_on_changing, m_read_only, messureSize(), normal_icon, ReSetOnChanging(), ResetWaringDlg(), round_scale_hint_icon, SetFinish(), SetOnChanging(), style, text_color, text_ctrl, and wdialog.

Referenced by TempInput().

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

◆ DoSetSize()

void TempInput::DoSetSize ( int x,
int y,
int width,
int height,
int sizeFlags = wxSIZE_AUTO )
overrideprotectedvirtual
377{
378 wxWindow::DoSetSize(x, y, width, height, sizeFlags);
379 if (sizeFlags & wxSIZE_USE_EXISTING) return;
380
381 padding_left = FromDIP(10);
382 auto left = padding_left;
383 wxClientDC dc(this);
384 if (normal_icon.bmp().IsOk()) {
385 wxSize szIcon = normal_icon.GetBmpSize();
386 left += szIcon.x;
387 }
388
389 // interval
390 left += 9;
391
393 wxSize szIcon = round_scale_hint_icon.GetBmpSize();
394 left += szIcon.x + 3;
395 }
396
397 // label
398 dc.SetFont(::Label::Head_14);
399 labelSize = dc.GetMultiLineTextExtent(wxWindow::GetLabel());
400 left += labelSize.x;
401
402 // interval
403 left += 10;
404
405 // separator
406 dc.SetFont(::Label::Body_12);
407 auto sepSize = dc.GetMultiLineTextExtent(wxString("/"));
408 left += sepSize.x;
409
410 // text text
411 auto textSize = text_ctrl->GetTextExtent(wxString("0000"));
412 text_ctrl->SetSize(textSize);
413 text_ctrl->SetPosition({left, (GetSize().y - text_ctrl->GetSize().y) / 2});
414}
@ TEMP_OF_MAIN_NOZZLE_TYPE
Definition TempInput.hpp:29
@ TEMP_OF_DEPUTY_NOZZLE_TYPE
Definition TempInput.hpp:30
static wxFont Head_14
Definition Label.hpp:45
wxSize labelSize
Definition TempInput.hpp:40
int padding_left
Definition TempInput.hpp:58
@ left
Definition MarchingSquares.hpp:188

References Label::Body_12, Label::Head_14, labelSize, m_input_type, normal_icon, padding_left, round_scale_hint_icon, TEMP_OF_DEPUTY_NOZZLE_TYPE, TEMP_OF_MAIN_NOZZLE_TYPE, and text_ctrl.

◆ DoSetToolTipText()

void TempInput::DoSetToolTipText ( wxString const & tip)
overrideprotected
417{
418 wxWindow::DoSetToolTipText(tip);
419 text_ctrl->SetToolTip(tip);
420}

References text_ctrl.

◆ Enable()

bool TempInput::Enable ( bool enable = true)
overridevirtual
353{
354 bool result = wxWindow::Enable(enable);
355 if (result) {
356 wxCommandEvent e(EVT_ENABLE_CHANGED);
357 e.SetEventObject(this);
358 GetEventHandler()->ProcessEvent(e);
359 }
360 return result;
361}

◆ erasePending()

wxString TempInput::erasePending ( wxString & str)
191{
192 wxString tmp = str;
193 int index = tmp.size() - 1;
194 while (index != -1) {
195 if (tmp[index] < '0' || tmp[index] > '9') {
196 tmp.erase(index, 1);
197 index--;
198 } else {
199 break;
200 }
201 }
202 return tmp;
203}

◆ get_max_temp()

int TempInput::get_max_temp ( )
inline
124{ return max_temp; }

References max_temp.

◆ GetCurrTemp()

wxString TempInput::GetCurrTemp ( )
inline
123{ return GetLabel(); }

◆ GetCurrType()

TempInputType TempInput::GetCurrType ( )
inline
106{return m_input_type;};

References m_input_type.

◆ GetTagTemp()

wxString TempInput::GetTagTemp ( )
inline
122{ return text_ctrl->GetValue(); }

References text_ctrl.

◆ GetTextCtrl() [1/2]

wxTextCtrl * TempInput::GetTextCtrl ( )
inline
137{ return text_ctrl; }

References text_ctrl.

◆ GetTextCtrl() [2/2]

wxTextCtrl const * TempInput::GetTextCtrl ( ) const
inline
139{ return text_ctrl; }

References text_ctrl.

◆ GetType()

int TempInput::GetType ( )
inline
120{ return temp_type; }

References temp_type.

◆ IsOnChanging()

bool TempInput::IsOnChanging ( ) const
inline
141{ return m_on_changing; }

References m_on_changing.

◆ keyPressed()

void TempInput::keyPressed ( wxKeyEvent & event)
private
694{}

Referenced by wxDEFINE_EVENT().

Here is the caller graph for this function:

◆ keyReleased()

void TempInput::keyReleased ( wxKeyEvent & event)
private
695{}

Referenced by wxDEFINE_EVENT().

Here is the caller graph for this function:

◆ messureMiniSize()

void TempInput::messureMiniSize ( )
private
554{
555 wxSize size = GetMinSize();
556
557 auto width = 0;
558 auto height = 0;
559
560 wxClientDC dc(this);
561 if (normal_icon.bmp().IsOk()) {
562 wxSize szIcon = normal_icon.GetBmpSize();
563 width += szIcon.x;
564 height = szIcon.y;
565 }
566
567 // interval
568 width += 9;
569
571 wxSize szIcon = round_scale_hint_icon.GetBmpSize();
572 width += szIcon.x;
573 }
574 width += 3;
575
576 // label
577 dc.SetFont(::Label::Head_14);
578 labelSize = dc.GetMultiLineTextExtent(wxWindow::GetLabel());
579 width += labelSize.x;
581
582 // interval
583 width += 10;
584
585 // separator
586 dc.SetFont(::Label::Body_12);
587 auto sepSize = dc.GetMultiLineTextExtent(wxString("/"));
588 width += sepSize.x;
589 height = sepSize.y > height ? sepSize.y : height;
590
591 // text text
592 auto textSize = text_ctrl->GetTextExtent(wxString("0000"));
593 width += textSize.x;
594 height = textSize.y > height ? textSize.y : height;
595
596 // flag flag
597 auto flagSize = degree_icon.GetBmpSize();
598 width += flagSize.x;
599 height = flagSize.y > height ? flagSize.y : height;
600
601 if (size.x < width) {
602 size.x = width;
603 } else {
604 padding_left = (size.x - width) / 2;
605 }
606
607 if (size.y < height) size.y = height;
608
609 SetSize(size);
610}
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185

References Label::Body_12, degree_icon, Label::Head_14, labelSize, m_input_type, normal_icon, padding_left, round_scale_hint_icon, TEMP_OF_DEPUTY_NOZZLE_TYPE, TEMP_OF_MAIN_NOZZLE_TYPE, and text_ctrl.

Referenced by SetMinSize().

Here is the caller graph for this function:

◆ messureSize()

void TempInput::messureSize ( )
private
614{
615 wxSize size = GetSize();
616
617 auto width = 0;
618 auto height = 0;
619
620 wxClientDC dc(this);
621 if (normal_icon.bmp().IsOk()) {
622 wxSize szIcon = normal_icon.GetBmpSize();
623 width += szIcon.x;
624 height = szIcon.y;
625 }
626
627 // interval
628 width += 9;
629
631 wxSize szIcon = round_scale_hint_icon.GetBmpSize();
632 width += szIcon.x;
633 }
634 width += 3;
635
636 // label
637 dc.SetFont(::Label::Head_14);
638 labelSize = dc.GetMultiLineTextExtent(wxWindow::GetLabel());
639 width += labelSize.x;
641
642 // interval
643 width += 10;
644
645 // separator
646 dc.SetFont(::Label::Body_12);
647 auto sepSize = dc.GetMultiLineTextExtent(wxString("/"));
648 width += sepSize.x;
649 height = sepSize.y > height ? sepSize.y : height;
650
651 // text text
652 auto textSize = text_ctrl->GetTextExtent(wxString("0000"));
653 width += textSize.x;
654 height = textSize.y > height ? textSize.y : height;
655
656 // flag flag
657 auto flagSize = degree_icon.GetBmpSize();
658 width += flagSize.x;
659 height = flagSize.y > height ? flagSize.y : height;
660
661 if (size.x < width) {
662 size.x = width;
663 } else {
664 padding_left = (size.x - width) / 2;
665 }
666
667 if (size.y < height) size.y = height;
668
669 wxSize minSize = size;
670 minSize.x = GetMinWidth();
671 SetMinSize(minSize);
672 SetSize(size);
673}
virtual void SetMinSize(const wxSize &size) override
Definition TempInput.cpp:363

References Label::Body_12, degree_icon, Label::Head_14, labelSize, m_input_type, normal_icon, padding_left, round_scale_hint_icon, SetMinSize(), TEMP_OF_DEPUTY_NOZZLE_TYPE, TEMP_OF_MAIN_NOZZLE_TYPE, and text_ctrl.

Referenced by Create(), Rescale(), SetLabel(), SetTagTemp(), and SetTagTemp().

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

◆ mouseEnterWindow()

void TempInput::mouseEnterWindow ( wxMouseEvent & event)
private
676{
677 if (!hover) {
678 hover = true;
679 Refresh();
680 }
681}

References hover.

Referenced by wxDEFINE_EVENT().

Here is the caller graph for this function:

◆ mouseLeaveWindow()

void TempInput::mouseLeaveWindow ( wxMouseEvent & event)
private
684{
685 if (hover) {
686 hover = false;
687 Refresh();
688 }
689}

References hover.

Referenced by wxDEFINE_EVENT().

Here is the caller graph for this function:

◆ mouseMoved()

void TempInput::mouseMoved ( wxMouseEvent & event)
private
692{}

Referenced by wxDEFINE_EVENT().

Here is the caller graph for this function:

◆ mouseWheelMoved()

void TempInput::mouseWheelMoved ( wxMouseEvent & event)
private
693{}

Referenced by wxDEFINE_EVENT().

Here is the caller graph for this function:

◆ paintEvent()

void TempInput::paintEvent ( wxPaintEvent & evt)
private
423{
424 // depending on your system you may need to look at double-buffered dcs
425 wxPaintDC dc(this);
426 render(dc);
427}
void render(wxDC &dc)
Definition TempInput.cpp:434

References render().

Referenced by wxDEFINE_EVENT().

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

◆ render()

void TempInput::render ( wxDC & dc)
private
435{
437 int states = state_handler.states();
438 wxSize size = GetSize();
439 bool align_right = GetWindowStyle() & wxRIGHT;
440
441 if (warning_mode) {
442 border_color = wxColour(255, 111, 0);
443 } else {
444 border_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(0x009688, (int) StateColor::Focused),
445 std::make_pair(0x009688, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal));
446 }
447
448 dc.SetBrush(*wxTRANSPARENT_BRUSH);
449 // start draw
450 padding_left = FromDIP(10);
451 wxPoint pt = {padding_left, 0};
452 wxSize szIcon;
453 if (normal_icon.bmp().IsOk()) szIcon = normal_icon.GetBmpSize();
454 else if (actice_icon.bmp().IsOk()) szIcon = actice_icon.GetBmpSize();
455
456 if (actice_icon.bmp().IsOk() && actice) {
457 szIcon = actice_icon.GetBmpSize();
458 pt.y = (size.y - szIcon.y) / 2;
459 dc.DrawBitmap(actice_icon.bmp(), pt);
460 }
461 else {
462 actice = false;
463 }
464 if (normal_icon.bmp().IsOk() && !actice) {
465 szIcon = normal_icon.GetBmpSize();
466 pt.y = (size.y - szIcon.y) / 2;
467 dc.DrawBitmap(normal_icon.bmp(), pt);
468 }
469
470 pt.x += szIcon.x + 9;
471
472 ScalableBitmap round_icon(this, "round", 16);/*icon diffs in normal and dark mode*/
473 round_icon.msw_rescale();
474 if (round_icon.bmp().IsOk() && m_input_type == TEMP_OF_DEPUTY_NOZZLE_TYPE){
475 wxSize szIcon = round_icon.GetBmpSize();
476 pt.y = (size.y - szIcon.y) / 2;
477 dc.DrawBitmap(round_icon.bmp(), pt);
478
479 dc.SetFont(::Label::Body_12);
480 auto sepSize = dc.GetMultiLineTextExtent(wxString("L"));
481
482 const wxColour& clr = Slic3r::GUI::wxGetApp().dark_mode() ? StateColor::darkModeColorFor(*wxWHITE) : *wxWHITE;
483 dc.SetTextForeground(clr);
484 dc.SetTextBackground(clr);
485 dc.DrawText(wxString("L"), pt.x + (szIcon.x - sepSize.x) / 2, (size.y - sepSize.y) / 2);
486 pt.x += szIcon.x + 3;
487 }
488
489 if (round_icon.bmp().IsOk() && m_input_type == TEMP_OF_MAIN_NOZZLE_TYPE) {
490 wxSize szIcon = round_icon.GetBmpSize();
491 pt.y = (size.y - szIcon.y) / 2;
492 dc.DrawBitmap(round_icon.bmp(), pt);
493
494 dc.SetFont(::Label::Body_12);
495 auto sepSize = dc.GetMultiLineTextExtent(wxString("R"));
496
497 const wxColour& clr = Slic3r::GUI::wxGetApp().dark_mode() ? StateColor::darkModeColorFor(*wxWHITE) : *wxWHITE;
498 dc.SetTextForeground(clr);
499 dc.SetTextBackground(clr);
500 dc.DrawText(wxString("R"), pt.x + (szIcon.x - sepSize.x) / 2, (size.y - sepSize.y) / 2);
501 pt.x += szIcon.x + 3;
502 }
503
504 // label
505 auto text = wxWindow::GetLabel();
506 dc.SetFont(::Label::Head_14);
507 labelSize = dc.GetMultiLineTextExtent(wxWindow::GetLabel());
508
509 if (!IsEnabled()) {
510 dc.SetTextForeground(wxColour(0xAC, 0xAC, 0xAC));
511 dc.SetTextBackground(background_color.colorForStates((int) StateColor::Disabled));
512 }
513 else {
514 dc.SetTextForeground(wxColour(0x32, 0x3A, 0x3D));
515 dc.SetTextBackground(background_color.colorForStates((int) states));
516 }
517
518
519 /*if (!text.IsEmpty()) {
520
521 }*/
522 wxSize textSize = text_ctrl->GetSize();
523 if (align_right) {
524 if (pt.x + labelSize.x > size.x) text = wxControl::Ellipsize(text, dc, wxELLIPSIZE_END, size.x - pt.x);
525 pt.y = (size.y - labelSize.y) / 2;
526 } else {
527 pt.y = (size.y - labelSize.y) / 2;
528 }
529
530 dc.SetTextForeground(StateColor::darkModeColorFor("#323A3C"));
531 dc.DrawText(text, pt);
532
533 // separator
534 dc.SetFont(::Label::Body_12);
535 auto sepSize = dc.GetMultiLineTextExtent(wxString("/"));
536 dc.SetTextForeground(text_color.colorForStates(states));
537 dc.SetTextBackground(background_color.colorForStates(states));
538 pt.x += labelSize.x + 10;
539 pt.y = (size.y - sepSize.y) / 2;
540 dc.DrawText(wxString("/"), pt);
541
542 // flag
543 if (degree_icon.bmp().IsOk()) {
544 auto pos = text_ctrl->GetPosition();
545 wxSize szIcon = degree_icon.GetBmpSize();
546 pt.y = (size.y - szIcon.y) / 2;
547 pt.x = pos.x + text_ctrl->GetSize().x;
548 dc.DrawBitmap(degree_icon.bmp(), pt);
549 }
550}
void render(wxDC &dc)
Definition StaticBox.cpp:181
bool warning_mode
Definition TempInput.hpp:55
bool IsEnabled()
Definition dark_mode.cpp:32
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References actice, actice_icon, ScalableBitmap::bmp(), Label::Body_12, StateColor::darkModeColorFor(), degree_icon, StateColor::Disabled, StateColor::Focused, ScalableBitmap::GetBmpSize(), Label::Head_14, StateColor::Hovered, labelSize, m_input_type, ScalableBitmap::msw_rescale(), StateColor::Normal, normal_icon, padding_left, StaticBox::render(), TEMP_OF_DEPUTY_NOZZLE_TYPE, TEMP_OF_MAIN_NOZZLE_TYPE, text_color, text_ctrl, and warning_mode.

Referenced by paintEvent().

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

◆ Rescale()

void TempInput::Rescale ( )
virtual
344{
345 if (this->normal_icon.bmp().IsOk()) this->normal_icon.msw_rescale();
346 if (this->actice_icon.bmp().IsOk()) this->actice_icon.msw_rescale();
347 if (this->degree_icon.bmp().IsOk()) this->degree_icon.msw_rescale();
348 if (this->round_scale_hint_icon.bmp().IsOk()) this->round_scale_hint_icon.msw_rescale();
349 messureSize();
350}

References actice_icon, degree_icon, messureSize(), normal_icon, and round_scale_hint_icon.

Here is the call graph for this function:

◆ ReSetOnChanging()

void TempInput::ReSetOnChanging ( )
inline
143{ m_on_changing = false; }

References m_on_changing.

Referenced by Create().

Here is the caller graph for this function:

◆ ResetWaringDlg()

void TempInput::ResetWaringDlg ( )
private
58{
59 if (wdialog) { wdialog->Dismiss(); }
60 if (warning_mode) { Warning(false, WARNING_TOO_HIGH); }
61}

References Warning, warning_mode, WARNING_TOO_HIGH, and wdialog.

Referenced by Create().

Here is the caller graph for this function:

◆ SetCurrTemp() [1/2]

void TempInput::SetCurrTemp ( int temp)
225{
226 auto tp = wxString::Format("%d", temp);
227 if (GetLabel() != tp) {
228 SetLabel(tp);
229 Refresh();
230 }
231}
void SetLabel(const wxString &label) override
Definition TempInput.cpp:322

References SetLabel().

Here is the call graph for this function:

◆ SetCurrTemp() [2/2]

void TempInput::SetCurrTemp ( wxString temp)
234{
235 if (GetLabel() != temp) {
236 SetLabel(temp);
237 Refresh();
238 }
239}

References SetLabel().

Here is the call graph for this function:

◆ SetCurrType()

void TempInput::SetCurrType ( TempInputType type)
241 {
242 m_input_type = type;
243}

References m_input_type.

◆ SetFinish()

void TempInput::SetFinish ( )
183{
184 wxCommandEvent event(wxCUSTOMEVT_SET_TEMP_FINISH);
185 event.SetInt(temp_type);
186 event.SetString(wxString::Format("%d", m_input_type));
187 wxPostEvent(this->GetParent(), event);
188}

References m_input_type, and temp_type.

Referenced by Create().

Here is the caller graph for this function:

◆ SetIconActive()

void TempInput::SetIconActive ( )
307{
308 actice = true;
309 Refresh();
310}

References actice.

◆ SetIconNormal()

void TempInput::SetIconNormal ( )
313{
314 actice = false;
315 Refresh();
316}

References actice.

◆ SetLabel()

void TempInput::SetLabel ( const wxString & label)
override
323{
324 if (label != wxWindow::GetLabel()) {
325 wxWindow::SetLabel(label);
326 messureSize();
327 Refresh();
328 }
329}

References messureSize().

Referenced by SetCurrTemp(), and SetCurrTemp().

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

◆ SetLabelColor()

void TempInput::SetLabelColor ( StateColor const & color)
338{
339 label_color = color;
340 state_handler.update_binds();
341}

References label_color.

◆ SetMaxTemp()

void TempInput::SetMaxTemp ( int temp)
318{ max_temp = temp; }

References max_temp.

◆ SetMinSize()

void TempInput::SetMinSize ( const wxSize & size)
overridevirtual
364{
365 wxSize size2 = size;
366 if (size2.y < 0) {
367#ifdef __WXMAC__
368 if (GetPeer()) // peer is not ready in Create on mac
369#endif
370 size2.y = GetSize().y;
371 }
372 wxWindow::SetMinSize(size2);
374}
void messureMiniSize()
Definition TempInput.cpp:553

References messureMiniSize().

Referenced by messureSize().

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

◆ SetMinTemp()

void TempInput::SetMinTemp ( int temp)
320{ min_temp = temp; }

References min_temp.

◆ SetOnChanging()

void TempInput::SetOnChanging ( )
inline
142{ m_on_changing = true; }

References m_on_changing.

Referenced by Create().

Here is the caller graph for this function:

◆ SetReadOnly()

void TempInput::SetReadOnly ( bool ro)
inline
114{ m_read_only = ro; }

References m_read_only.

◆ SetTagTemp() [1/2]

void TempInput::SetTagTemp ( int temp)
206{
207 auto tp = wxString::Format("%d", temp);
208 if (text_ctrl->GetValue() != tp) {
209 text_ctrl->SetValue(tp);
210 messureSize();
211 Refresh();
212 }
213}

References messureSize(), and text_ctrl.

Here is the call graph for this function:

◆ SetTagTemp() [2/2]

void TempInput::SetTagTemp ( wxString temp)
216{
217 if (text_ctrl->GetValue() != temp) {
218 text_ctrl->SetValue(temp);
219 messureSize();
220 Refresh();
221 }
222}

References messureSize(), and text_ctrl.

Here is the call graph for this function:

◆ SetTextColor()

void TempInput::SetTextColor ( StateColor const & color)
332{
333 text_color = color;
334 state_handler.update_binds();
335}

References text_color.

◆ Warning()

void TempInput::Warning ( bool warn,
WarningType type = WARNING_UNKNOWN )
246{
247 warning_mode = warn;
248 //Refresh();
249
250 if (warning_mode) {
251 if (wdialog == nullptr) {
252 wdialog = new PopupWindow(this);
253 wdialog->SetBackgroundColour(wxColour("#FFFFFF"));
254
255 wdialog->SetSizeHints(wxDefaultSize, wxDefaultSize);
256
257 wxBoxSizer *sizer_body = new wxBoxSizer(wxVERTICAL);
258
259 auto body = new wxPanel(wdialog, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
260 body->SetBackgroundColour(wxColour("#FFFFFF"));
261
262
263 wxBoxSizer *sizer_text;
264 sizer_text = new wxBoxSizer(wxHORIZONTAL);
265
266
267
268 warning_text = new wxStaticText(body, wxID_ANY,
269 wxEmptyString,
270 wxDefaultPosition, wxDefaultSize,
271 wxALIGN_CENTER_HORIZONTAL);
273 warning_text->SetForegroundColour(wxColour(255, 111, 0));
274 warning_text->Wrap(-1);
275 sizer_text->Add(warning_text, 1, wxEXPAND | wxTOP | wxBOTTOM, 2);
276
277 body->SetSizer(sizer_text);
278 body->Layout();
279 sizer_body->Add(body, 0, wxEXPAND, 0);
280
281 wdialog->SetSizer(sizer_body);
282 wdialog->Layout();
283 sizer_body->Fit(wdialog);
284 }
285
286 wxPoint pos = this->ClientToScreen(wxPoint(2, 0));
287 pos.y += this->GetRect().height - (this->GetSize().y - this->text_ctrl->GetSize().y) / 2 - 2;
288 wdialog->SetPosition(pos);
289
290 wxString warning_string;
292 warning_string = wxString::Format(_L("The maximum temperature cannot exceed %d"), max_temp);
293 else if (type == WarningType::WARNING_TOO_LOW)
294 warning_string = wxString::Format(_L("The minimum temperature should not be less than %d"), min_temp);
295 warning_text->SetLabel(warning_string);
296 warning_text->Wrap(-1);
297 warning_text->Fit();
298 wdialog->Fit();
299 wdialog->Popup();
300 } else {
301 if (wdialog)
302 wdialog->Dismiss();
303 }
304}
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
wxStaticText * warning_text
Definition TempInput.hpp:50

References _L, Label::Body_12, max_temp, min_temp, text_ctrl, warning_mode, warning_text, WARNING_TOO_HIGH, WARNING_TOO_LOW, wdialog, and wxStaticText.

Member Data Documentation

◆ actice

bool TempInput::actice = false

◆ actice_icon

ScalableBitmap TempInput::actice_icon
private

Referenced by TempInput(), Create(), render(), and Rescale().

◆ additional_temps

std::unordered_set<int> TempInput::additional_temps
private

Referenced by AddTemp(), and CheckIsValidVal().

◆ currentTemp

wxString TempInput::currentTemp

◆ degree_icon

ScalableBitmap TempInput::degree_icon
private

◆ hover

bool TempInput::hover
private

◆ label_color

StateColor TempInput::label_color
private

Referenced by TempInput(), Create(), and SetLabelColor().

◆ labelSize

wxSize TempInput::labelSize
private

◆ m_input_type

◆ m_on_changing

bool TempInput::m_on_changing {false}
private
39{false};

Referenced by Create(), IsOnChanging(), ReSetOnChanging(), and SetOnChanging().

◆ m_read_only

bool TempInput::m_read_only {false}
private
38{false};

Referenced by Create(), and SetReadOnly().

◆ max_temp

int TempInput::max_temp = 0
private

◆ min_temp

int TempInput::min_temp = 0
private

◆ normal_icon

ScalableBitmap TempInput::normal_icon
private

◆ padding_left

int TempInput::padding_left = 0
private

◆ round_scale_hint_icon

ScalableBitmap TempInput::round_scale_hint_icon
private

◆ temp_type

int TempInput::temp_type

Referenced by TempInput(), GetType(), and SetFinish().

◆ TempInputHeight

const int TempInput::TempInputHeight = 50
staticprivate

◆ TempInputWidth

const int TempInput::TempInputWidth = 200
staticprivate

◆ text_color

StateColor TempInput::text_color
private

◆ text_ctrl

◆ warning_mode

bool TempInput::warning_mode = false
private

Referenced by render(), ResetWaringDlg(), and Warning().

◆ warning_text

wxStaticText* TempInput::warning_text
private

Referenced by Warning().

◆ wdialog

wxPopupTransientWindow* TempInput::wdialog {nullptr}
92{nullptr};

Referenced by Create(), ResetWaringDlg(), and Warning().


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