FIX: recalc textsize after set font
Change-Id: Ic4717ffd5b418fa7030659e3e684b0868cca2c61
This commit is contained in:
parent
405444f042
commit
54c5113b79
|
@ -48,9 +48,10 @@ SpinInput::SpinInput(wxWindow * parent,
|
|||
wxWindow::SetLabel(label);
|
||||
state_handler.attach({&border_color, &text_color, &background_color});
|
||||
state_handler.update_binds();
|
||||
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {20, 5}, wxDefaultSize,
|
||||
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {20, 4}, wxDefaultSize,
|
||||
style | wxBORDER_NONE | wxTE_PROCESS_ENTER, wxTextValidator(wxFILTER_DIGITS));
|
||||
text_ctrl->SetFont(Label::Body_14);
|
||||
text_ctrl->SetInitialSize(text_ctrl->GetBestSize());
|
||||
text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
|
@ -199,10 +200,7 @@ void SpinInput::messureSize()
|
|||
{
|
||||
wxSize size = GetSize();
|
||||
wxSize textSize = text_ctrl->GetSize();
|
||||
#ifdef __WXOSX__
|
||||
textSize.y -= 3; // TODO:
|
||||
#endif
|
||||
int h = textSize.y * 24 / 14;
|
||||
int h = textSize.y + 8;
|
||||
if (size.y < h) {
|
||||
size.y = h;
|
||||
SetSize(size);
|
||||
|
|
|
@ -61,13 +61,14 @@ void TextInput::Create(wxWindow * parent,
|
|||
{
|
||||
text_ctrl = nullptr;
|
||||
wxWindow::Create(parent, wxID_ANY, pos, size, style);
|
||||
|
||||
|
||||
wxWindow::SetLabel(label);
|
||||
style &= ~wxRIGHT;
|
||||
state_handler.attach({&border_color, &text_color, &background_color});
|
||||
state_handler.update_binds();
|
||||
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {5, 5}, wxDefaultSize,
|
||||
style | wxBORDER_NONE);
|
||||
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {4, 4}, wxDefaultSize, style | wxBORDER_NONE);
|
||||
text_ctrl->SetFont(Label::Body_14);
|
||||
text_ctrl->SetInitialSize(text_ctrl->GetBestSize());
|
||||
text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
|
@ -91,7 +92,6 @@ void TextInput::Create(wxWindow * parent,
|
|||
ProcessEventLocally(e);
|
||||
});
|
||||
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu
|
||||
text_ctrl->SetFont(Label::Body_14);
|
||||
if (!icon.IsEmpty()) {
|
||||
this->icon = ScalableBitmap(this, icon.ToStdString(), 16);
|
||||
}
|
||||
|
@ -180,10 +180,10 @@ void TextInput::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||
if (align_right)
|
||||
textPos.x += labelSize.x;
|
||||
if (text_ctrl) {
|
||||
wxSize textSize = text_ctrl->GetSize();
|
||||
textSize.x = size.x - textPos.x - labelSize.x - 10;
|
||||
text_ctrl->SetSize(textSize);
|
||||
text_ctrl->SetPosition({textPos.x, (size.y - textSize.y) / 2});
|
||||
wxSize textSize = text_ctrl->GetSize();
|
||||
textSize.x = size.x - textPos.x - labelSize.x - 10;
|
||||
text_ctrl->SetSize(textSize);
|
||||
text_ctrl->SetPosition({textPos.x, (size.y - textSize.y) / 2});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,10 +245,7 @@ void TextInput::messureSize()
|
|||
wxClientDC dc(this);
|
||||
labelSize = dc.GetTextExtent(wxWindow::GetLabel());
|
||||
wxSize textSize = text_ctrl->GetSize();
|
||||
#ifdef __WXOSX__
|
||||
textSize.y -= 3; // TODO:
|
||||
#endif
|
||||
int h = textSize.y * 24 / 14;
|
||||
int h = textSize.y + 8;
|
||||
if (size.y < h) {
|
||||
size.y = h;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue