mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-07-16 08:54:26 +00:00
First steps
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#include "Field.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
void TextCtrl::BUILD() {
|
||||
wxString default_value = "";
|
||||
// Empty wxString object fails cast, default to "" if
|
||||
// the recast fails from boost::any.
|
||||
try {
|
||||
if (opt.default_value != nullptr) {
|
||||
default_value = boost::any_cast<wxString>(*(opt.default_value));
|
||||
}
|
||||
} catch (const boost::bad_any_cast& e) {
|
||||
//TODO log error
|
||||
}
|
||||
auto size = wxSize(opt.height,opt.width);
|
||||
if (opt.height == 0 || opt.width == 0) { size = wxDefaultSize; }
|
||||
|
||||
wxTextCtrl* temp = new wxTextCtrl(_parent, wxID_ANY, default_value, wxDefaultPosition, size, (opt.multiline ? wxTE_MULTILINE : 0));
|
||||
|
||||
_on_change = [=](wxCommandEvent& a) { this->__on_change(a);};
|
||||
|
||||
// This replaces the generic EVT_TEXT call to set the table up, it works with function objects.
|
||||
temp->Bind(wxEVT_TEXT, _on_change, temp->GetId());
|
||||
if (opt.tooltip.length() > 0) { temp->SetToolTip(opt.tooltip); }
|
||||
|
||||
// recast as a wxWindow to fit the calling convention
|
||||
_window = dynamic_cast<wxWindow*>(temp);
|
||||
}
|
||||
|
||||
// Fixed (temporary) function. We can (and probably should) use lambdas instead.
|
||||
void TextCtrl::__on_change(wxCommandEvent& a) {
|
||||
printf("Calling _on_change for %d.\n", opt.label);
|
||||
}
|
||||
|
||||
} }
|
||||
Reference in New Issue
Block a user