mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 10:02:12 +00:00
FIX: use StaticBox for background
Change-Id: I2bba259c53eaf987662a97dd93eac4fb8f73d47b
This commit is contained in:
@@ -5,14 +5,6 @@
|
||||
|
||||
BEGIN_EVENT_TABLE(TextInput, wxPanel)
|
||||
|
||||
EVT_MOTION(TextInput::mouseMoved)
|
||||
EVT_ENTER_WINDOW(TextInput::mouseEnterWindow)
|
||||
EVT_LEAVE_WINDOW(TextInput::mouseLeaveWindow)
|
||||
EVT_KEY_DOWN(TextInput::keyPressed)
|
||||
EVT_KEY_UP(TextInput::keyReleased)
|
||||
EVT_MOUSEWHEEL(TextInput::mouseWheelMoved)
|
||||
|
||||
// catch paint events
|
||||
EVT_PAINT(TextInput::paintEvent)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
@@ -24,19 +16,16 @@ END_EVENT_TABLE()
|
||||
*/
|
||||
|
||||
TextInput::TextInput()
|
||||
: state_handler(this)
|
||||
, border_color(std::make_pair(0xDBDBDB, (int) StateColor::Disabled),
|
||||
std::make_pair(0x00AE42, (int) StateColor::Hovered),
|
||||
std::make_pair(0xDBDBDB, (int) StateColor::Normal))
|
||||
, label_color(std::make_pair(0x909090, (int) StateColor::Disabled),
|
||||
: label_color(std::make_pair(0x909090, (int) StateColor::Disabled),
|
||||
std::make_pair(0x6B6B6B, (int) StateColor::Normal))
|
||||
, text_color(std::make_pair(0x909090, (int) StateColor::Disabled),
|
||||
std::make_pair(0x262E30, (int) StateColor::Normal))
|
||||
, background_color(std::make_pair(0xF0F0F0, (int) StateColor::Disabled),
|
||||
std::make_pair(*wxWHITE, (int) StateColor::Normal))
|
||||
{
|
||||
hover = false;
|
||||
radius = 0;
|
||||
border_width = 1;
|
||||
border_color = StateColor(std::make_pair(0xDBDBDB, (int) StateColor::Disabled), std::make_pair(0x00AE42, (int) StateColor::Hovered),
|
||||
std::make_pair(0xDBDBDB, (int) StateColor::Normal));
|
||||
background_color = StateColor(std::make_pair(0xF0F0F0, (int) StateColor::Disabled), std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||
SetFont(Label::Body_12);
|
||||
}
|
||||
|
||||
@@ -61,10 +50,10 @@ void TextInput::Create(wxWindow * parent,
|
||||
long style)
|
||||
{
|
||||
text_ctrl = nullptr;
|
||||
wxWindow::Create(parent, wxID_ANY, pos, size, style);
|
||||
StaticBox::Create(parent, wxID_ANY, pos, size, style);
|
||||
wxWindow::SetLabel(label);
|
||||
style &= ~wxRIGHT;
|
||||
state_handler.attach({&border_color, &label_color, & text_color, &background_color});
|
||||
state_handler.attach({&label_color, & text_color});
|
||||
state_handler.update_binds();
|
||||
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {4, 4}, wxDefaultSize, style | wxBORDER_NONE);
|
||||
text_ctrl->SetFont(Label::Body_14);
|
||||
@@ -119,12 +108,6 @@ void TextInput::SetIcon(const wxBitmap &icon)
|
||||
Rescale();
|
||||
}
|
||||
|
||||
void TextInput::SetBorderColor(StateColor const& color)
|
||||
{
|
||||
border_color = color;
|
||||
state_handler.update_binds();
|
||||
}
|
||||
|
||||
void TextInput::SetLabelColor(StateColor const &color)
|
||||
{
|
||||
label_color = color;
|
||||
@@ -137,12 +120,6 @@ void TextInput::SetTextColor(StateColor const& color)
|
||||
state_handler.update_binds();
|
||||
}
|
||||
|
||||
void TextInput::SetBackgroundColor(StateColor const& color)
|
||||
{
|
||||
background_color = color;
|
||||
state_handler.update_binds();
|
||||
}
|
||||
|
||||
void TextInput::Rescale()
|
||||
{
|
||||
if (!this->icon.name().empty())
|
||||
@@ -217,13 +194,10 @@ void TextInput::paintEvent(wxPaintEvent &evt)
|
||||
*/
|
||||
void TextInput::render(wxDC& dc)
|
||||
{
|
||||
StaticBox::render(dc);
|
||||
int states = state_handler.states();
|
||||
wxSize size = GetSize();
|
||||
bool align_right = GetWindowStyle() & wxRIGHT;
|
||||
dc.SetPen(wxPen(border_color.colorForStates(states)));
|
||||
dc.SetBrush(wxBrush(background_color.colorForStates(states)));
|
||||
dc.DrawRoundedRectangle(0, 0, size.x, size.y, radius);
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
// start draw
|
||||
wxPoint pt = {5, 0};
|
||||
if (icon.bmp().IsOk()) {
|
||||
@@ -264,27 +238,3 @@ void TextInput::messureSize()
|
||||
SetMinSize(minSize);
|
||||
SetSize(size);
|
||||
}
|
||||
|
||||
void TextInput::mouseEnterWindow(wxMouseEvent& event)
|
||||
{
|
||||
if (!hover)
|
||||
{
|
||||
hover = true;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void TextInput::mouseLeaveWindow(wxMouseEvent& event)
|
||||
{
|
||||
if (hover)
|
||||
{
|
||||
hover = false;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
// currently unused events
|
||||
void TextInput::mouseMoved(wxMouseEvent& event) {}
|
||||
void TextInput::mouseWheelMoved(wxMouseEvent& event) {}
|
||||
void TextInput::keyPressed(wxKeyEvent& event) {}
|
||||
void TextInput::keyReleased(wxKeyEvent& event) {}
|
||||
|
||||
Reference in New Issue
Block a user