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

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/wxInspectorPlugins/CustomWidgetsPlugin.hpp>

Inheritance diagram for CustomWidgetsPlugin:
Collaboration diagram for CustomWidgetsPlugin:

Public Member Functions

wxString GetName () const override
bool CanProvideProperties (wxClassInfo *info) override
wxVector< wxInspector::PropertyDef > GetProperties (wxInspector::InspectableObject &obj) override

Private Member Functions

void addButtonProps (class Button *btn, wxVector< wxInspector::PropertyDef > &props)
void addCheckBoxProps (class CheckBox *cb, wxVector< wxInspector::PropertyDef > &props)
void addTextInputProps (class TextInput *ti, wxVector< wxInspector::PropertyDef > &props)
void addSwitchButtonProps (class SwitchButton *sb, wxVector< wxInspector::PropertyDef > &props)
void addProgressBarProps (class ProgressBar *pb, wxVector< wxInspector::PropertyDef > &props)
void addLabelProps (class Label *lbl, wxVector< wxInspector::PropertyDef > &props)
void addLabeledStaticBoxProps (class LabeledStaticBox *lsb, wxVector< wxInspector::PropertyDef > &props)

Detailed Description

Member Function Documentation

◆ addButtonProps()

void CustomWidgetsPlugin::addButtonProps ( class Button * btn,
wxVector< wxInspector::PropertyDef > & props )
private
60{
61 using namespace wxInspector;
62
63 wxVector<wxString> styleChoices;
64 styleChoices.push_back("Regular");
65 styleChoices.push_back("Confirm");
66 styleChoices.push_back("Alert");
67 styleChoices.push_back("Disabled");
68
69 auto styleToStr = [](ButtonStyle s) -> wxString {
70 switch (s) {
71 case ButtonStyle::Regular: return "Regular";
72 case ButtonStyle::Confirm: return "Confirm";
73 case ButtonStyle::Alert: return "Alert";
74 case ButtonStyle::Disabled: return "Disabled";
75 }
76 return "Regular";
77 };
78
79 props.push_back({"Button Style", "Orca Button", PropertyType::Choice,
80 styleToStr(btn->GetStyle()), false, styleChoices,
81 [btn, styleToStr]() { return styleToStr(btn->GetStyle()); },
82 [btn](const wxString& v) {
84 if (v == "Confirm") s = ButtonStyle::Confirm;
85 else if (v == "Alert") s = ButtonStyle::Alert;
86 else if (v == "Disabled") s = ButtonStyle::Disabled;
87 btn->SetStyle(s, btn->GetType());
88 return true;
89 }});
90
91 wxVector<wxString> typeChoices;
92 typeChoices.push_back("Compact");
93 typeChoices.push_back("Window");
94 typeChoices.push_back("Choice");
95 typeChoices.push_back("Parameter");
96 typeChoices.push_back("Icon");
97 typeChoices.push_back("Expanded");
98
99 auto typeToStr = [](ButtonType t) -> wxString {
100 switch (t) {
101 case ButtonType::Compact: return "Compact";
102 case ButtonType::Window: return "Window";
103 case ButtonType::Choice: return "Choice";
104 case ButtonType::Parameter: return "Parameter";
105 case ButtonType::Icon: return "Icon";
106 case ButtonType::Expanded: return "Expanded";
107 }
108 return "Compact";
109 };
110
111 props.push_back({"Button Type", "Orca Button", PropertyType::Choice,
112 typeToStr(btn->GetType()), false, typeChoices,
113 [btn, typeToStr]() { return typeToStr(btn->GetType()); },
114 [btn](const wxString& v) {
116 if (v == "Window") t = ButtonType::Window;
117 else if (v == "Choice") t = ButtonType::Choice;
118 else if (v == "Parameter") t = ButtonType::Parameter;
119 else if (v == "Icon") t = ButtonType::Icon;
120 else if (v == "Expanded") t = ButtonType::Expanded;
121 btn->SetStyle(btn->GetStyle(), t);
122 return true;
123 }});
124
125 props.push_back({"Selected", "Orca Button", PropertyType::Boolean,
126 btn->IsSelected() ? "true" : "false", false, {},
127 [btn]() { return btn->IsSelected() ? "true" : "false"; },
128 [btn](const wxString& v) {
129 btn->SetSelected(v == "true");
130 btn->Refresh();
131 return true;
132 }});
133}
ButtonStyle
Definition Button.hpp:23
@ Confirm
Definition Button.hpp:25
@ Alert
Definition Button.hpp:26
@ Disabled
Definition Button.hpp:27
@ Regular
Definition Button.hpp:24
ButtonType
Definition Button.hpp:30
@ Choice
Definition Button.hpp:33
@ Expanded
Definition Button.hpp:38
@ Icon
Definition Button.hpp:35
@ Parameter
Definition Button.hpp:34
@ Compact
Definition Button.hpp:31
@ Window
Definition Button.hpp:32

References Alert, Choice, Compact, Confirm, Disabled, Expanded, Button::GetStyle(), Button::GetType(), Icon, Button::IsSelected(), Parameter, Regular, Button::SetSelected(), and Window.

Referenced by GetProperties().

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

◆ addCheckBoxProps()

void CustomWidgetsPlugin::addCheckBoxProps ( class CheckBox * cb,
wxVector< wxInspector::PropertyDef > & props )
private
137{
138 using namespace wxInspector;
139
140 props.push_back({"Half Checked", "Orca CheckBox", PropertyType::Boolean,
141 cb->IsHalfChecked() ? "true" : "false", false, {},
142 [cb]() { return cb->IsHalfChecked() ? "true" : "false"; },
143 [cb](const wxString& v) {
144 cb->SetHalfChecked(v == "true");
145 return true;
146 }});
147}

References CheckBox::IsHalfChecked(), and CheckBox::SetHalfChecked().

Referenced by GetProperties().

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

◆ addLabeledStaticBoxProps()

void CustomWidgetsPlugin::addLabeledStaticBoxProps ( class LabeledStaticBox * lsb,
wxVector< wxInspector::PropertyDef > & props )
private
240{
241 using namespace wxInspector;
242
243 props.push_back({"Corner Radius", "LabeledStaticBox", PropertyType::Integer,
244 wxString::Format("%d", lsb->GetCornerRadius()), false, {},
245 [lsb]() { return wxString::Format("%d", lsb->GetCornerRadius()); },
246 [lsb](const wxString& v) {
247 long val;
248 if (!v.ToLong(&val)) return false;
249 lsb->SetCornerRadius((int) val);
250 return true;
251 }});
252
253 props.push_back({"Border Width", "LabeledStaticBox", PropertyType::Integer,
254 wxString::Format("%d", lsb->GetBorderWidth()), false, {},
255 [lsb]() { return wxString::Format("%d", lsb->GetBorderWidth()); },
256 [lsb](const wxString& v) {
257 long val;
258 if (!v.ToLong(&val)) return false;
259 lsb->SetBorderWidth((int) val);
260 return true;
261 }});
262
263 // Border Color: display as hex string
264 wxColour bc = lsb->GetBorderColor().colorForStates(0);
265 props.push_back({"Border Color", "LabeledStaticBox", PropertyType::String,
266 bc.GetAsString(wxC2S_HTML_SYNTAX), false, {},
267 [lsb]() {
268 return lsb->GetBorderColor()
269 .colorForStates(0)
270 .GetAsString(wxC2S_HTML_SYNTAX);
271 },
272 [lsb](const wxString& v) {
273 wxColour c(v);
274 if (!c.IsOk()) return false;
275 lsb->SetBorderColor(StateColor(c));
276 return true;
277 }});
278
279 props.push_back({"Scale", "LabeledStaticBox", PropertyType::ReadOnly,
280 wxString::Format("%.2f", lsb->GetScale()), true, {},
281 [lsb]() { return wxString::Format("%.2f", lsb->GetScale()); },
282 nullptr});
283}

References StateColor::colorForStates(), LabeledStaticBox::GetBorderColor(), LabeledStaticBox::GetBorderWidth(), LabeledStaticBox::GetCornerRadius(), LabeledStaticBox::GetScale(), LabeledStaticBox::SetBorderColor(), LabeledStaticBox::SetBorderWidth(), and LabeledStaticBox::SetCornerRadius().

Referenced by GetProperties().

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

◆ addLabelProps()

void CustomWidgetsPlugin::addLabelProps ( class Label * lbl,
wxVector< wxInspector::PropertyDef > & props )
private
218{
219 using namespace wxInspector;
220
221 bool isHyperlink = (lbl->GetWindowStyleFlag() & LB_HYPERLINK) != 0;
222
223 props.push_back({"Is Hyperlink", "Orca Label", PropertyType::Boolean,
224 isHyperlink ? "true" : "false", true, {},
225 [lbl]() {
226 return (lbl->GetWindowStyleFlag() & LB_HYPERLINK) ? "true" : "false";
227 },
228 nullptr});
229
230 props.push_back({"Font Point Size", "Orca Label", PropertyType::ReadOnly,
231 wxString::Format("%d", lbl->GetFont().GetPointSize()), true, {},
232 [lbl]() {
233 return wxString::Format("%d", lbl->GetFont().GetPointSize());
234 },
235 nullptr});
236}
#define LB_HYPERLINK
Definition Label.hpp:10

References LB_HYPERLINK.

Referenced by GetProperties().

Here is the caller graph for this function:

◆ addProgressBarProps()

void CustomWidgetsPlugin::addProgressBarProps ( class ProgressBar * pb,
wxVector< wxInspector::PropertyDef > & props )
private
192{
193 using namespace wxInspector;
194
195 props.push_back({"Proportion", "Orca ProgressBar", PropertyType::String,
196 wxString::Format("%.2f", pb->m_proportion), false, {},
197 [pb]() { return wxString::Format("%.2f", pb->m_proportion); },
198 [pb](const wxString& v) {
199 double val;
200 if (wxSscanf(v, "%lf", &val) != 1) return false;
201 pb->m_proportion = val;
202 pb->Refresh();
203 return true;
204 }});
205
206 props.push_back({"Show Number", "Orca ProgressBar", PropertyType::Boolean,
207 pb->m_shownumber ? "true" : "false", false, {},
208 [pb]() { return pb->m_shownumber ? "true" : "false"; },
209 [pb](const wxString& v) {
210 pb->m_shownumber = (v == "true");
211 pb->Refresh();
212 return true;
213 }});
214}

References ProgressBar::m_proportion, and ProgressBar::m_shownumber.

Referenced by GetProperties().

Here is the caller graph for this function:

◆ addSwitchButtonProps()

void CustomWidgetsPlugin::addSwitchButtonProps ( class SwitchButton * sb,
wxVector< wxInspector::PropertyDef > & props )
private
178{
179 using namespace wxInspector;
180
181 props.push_back({"Value", "Orca SwitchButton", PropertyType::Boolean,
182 sb->GetValue() ? "true" : "false", false, {},
183 [sb]() { return sb->GetValue() ? "true" : "false"; },
184 [sb](const wxString& v) {
185 sb->SetValue(v == "true");
186 return true;
187 }});
188}

References SwitchButton::SetValue().

Referenced by GetProperties().

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

◆ addTextInputProps()

void CustomWidgetsPlugin::addTextInputProps ( class TextInput * ti,
wxVector< wxInspector::PropertyDef > & props )
private
151{
152 using namespace wxInspector;
153
154 props.push_back({"Label", "Orca TextInput", PropertyType::String,
155 ti->GetLabel(), false, {},
156 [ti]() { return ti->GetLabel(); },
157 [ti](const wxString& v) { ti->SetLabel(v); return true; }});
158
159 props.push_back({"Text Value", "Orca TextInput", PropertyType::String,
160 ti->GetTextCtrl()->GetValue(), false, {},
161 [ti]() { return ti->GetTextCtrl()->GetValue(); },
162 [ti](const wxString& v) { ti->GetTextCtrl()->SetValue(v); return true; }});
163
164 props.push_back({"Corner Radius", "Orca TextInput", PropertyType::Integer,
165 wxString::Format("%d", ti->GetCornerRadius()), false, {},
166 [ti]() { return wxString::Format("%d", ti->GetCornerRadius()); },
167 [ti](const wxString& v) {
168 long val;
169 if (!v.ToLong(&val)) return false;
170 ti->SetCornerRadius((double) val);
171 ti->Refresh();
172 return true;
173 }});
174}

References TextInput::GetCornerRadius(), TextInput::GetTextCtrl(), TextInput::SetCornerRadius(), and TextInput::SetLabel().

Referenced by GetProperties().

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

◆ CanProvideProperties()

bool CustomWidgetsPlugin::CanProvideProperties ( wxClassInfo * info)
override
29{
30 return info->IsKindOf(CLASSINFO(wxWindow));
31}

◆ GetName()

wxString CustomWidgetsPlugin::GetName ( ) const
override
24{
25 return "OrcaCustomWidgets";
26}

◆ GetProperties()

wxVector< wxInspector::PropertyDef > CustomWidgetsPlugin::GetProperties ( wxInspector::InspectableObject & obj)
override
35{
36 wxVector<wxInspector::PropertyDef> props;
37 wxWindow* win = obj.AsWindow();
38 if (!win) return props;
39
40 if (auto* btn = dynamic_cast<Button*>(win))
41 addButtonProps(btn, props);
42 if (auto* cb = dynamic_cast<CheckBox*>(win))
43 addCheckBoxProps(cb, props);
44 if (auto* ti = dynamic_cast<TextInput*>(win))
45 addTextInputProps(ti, props);
46 if (auto* sb = dynamic_cast<SwitchButton*>(win))
47 addSwitchButtonProps(sb, props);
48 if (auto* pb = dynamic_cast<ProgressBar*>(win))
49 addProgressBarProps(pb, props);
50 if (auto* lbl = dynamic_cast<Label*>(win))
51 addLabelProps(lbl, props);
52 if (auto* lsb = dynamic_cast<LabeledStaticBox*>(win))
53 addLabeledStaticBoxProps(lsb, props);
54
55 return props;
56}
void addCheckBoxProps(class CheckBox *cb, wxVector< wxInspector::PropertyDef > &props)
Definition CustomWidgetsPlugin.cpp:135
void addTextInputProps(class TextInput *ti, wxVector< wxInspector::PropertyDef > &props)
Definition CustomWidgetsPlugin.cpp:149
void addProgressBarProps(class ProgressBar *pb, wxVector< wxInspector::PropertyDef > &props)
Definition CustomWidgetsPlugin.cpp:190
void addSwitchButtonProps(class SwitchButton *sb, wxVector< wxInspector::PropertyDef > &props)
Definition CustomWidgetsPlugin.cpp:176
void addLabelProps(class Label *lbl, wxVector< wxInspector::PropertyDef > &props)
Definition CustomWidgetsPlugin.cpp:216
void addButtonProps(class Button *btn, wxVector< wxInspector::PropertyDef > &props)
Definition CustomWidgetsPlugin.cpp:58
void addLabeledStaticBoxProps(class LabeledStaticBox *lsb, wxVector< wxInspector::PropertyDef > &props)
Definition CustomWidgetsPlugin.cpp:238
@ ProgressBar
Definition NotificationManager.hpp:112

References addButtonProps(), addCheckBoxProps(), addLabeledStaticBoxProps(), addLabelProps(), addProgressBarProps(), addSwitchButtonProps(), and addTextInputProps().

Here is the call graph for this function:

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