fix sidelable font

This commit is contained in:
SoftFever 2023-07-27 22:03:32 +08:00
parent 53688791af
commit ff7fb51f41

View file

@ -1,6 +1,7 @@
#include "TextInput.hpp"
#include "Label.hpp"
#include "TextCtrl.h"
#include "slic3r/GUI/Widgets/Label.hpp"
#include <wx/dcgraph.h>
@ -50,7 +51,7 @@ void TextInput::Create(wxWindow * parent,
const wxSize & size,
long style)
{
text_ctrl = nullptr;
text_ctrl = nullptr;
StaticBox::Create(parent, wxID_ANY, pos, size, style);
wxWindow::SetLabel(label);
style &= ~wxRIGHT;
@ -209,7 +210,10 @@ void TextInput::render(wxDC& dc)
pt.y = (size.y + textSize.y) / 2 - labelSize.y;
}
dc.SetTextForeground(label_color.colorForStates(states));
dc.SetFont(GetFont());
if(align_right)
dc.SetFont(GetFont());
else
dc.SetFont(Label::Body_12);
dc.DrawText(text, pt);
}
}
@ -218,6 +222,11 @@ void TextInput::messureSize()
{
wxSize size = GetSize();
wxClientDC dc(this);
bool align_right = GetWindowStyle() & wxRIGHT;
if (align_right)
dc.SetFont(GetFont());
else
dc.SetFont(Label::Body_12);
labelSize = dc.GetTextExtent(wxWindow::GetLabel());
wxSize textSize = text_ctrl->GetSize();
int h = textSize.y + 8;