mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 10:02:12 +00:00
ENH:add "text to image" function in TextInput
jira: none Change-Id: Ibdb57b74511432e81faa0c556bb6e639d5a174f5 (cherry picked from commit 09323aeed34f29f105b95d3d6a2c7a151e17e42a)
This commit is contained in:
@@ -111,6 +111,17 @@ void TextInput::SetIcon(const wxString &icon)
|
||||
Rescale();
|
||||
}
|
||||
|
||||
void TextInput::SetIcon_1(const wxString &icon) {
|
||||
if (this->icon_1.name() == icon.ToStdString())
|
||||
return;
|
||||
if (icon.empty()) {
|
||||
this->icon_1 = ScalableBitmap();
|
||||
return;
|
||||
}
|
||||
this->icon_1 = ScalableBitmap(this, icon.ToStdString(), 16);
|
||||
Rescale();
|
||||
}
|
||||
|
||||
void TextInput::SetLabelColor(StateColor const &color)
|
||||
{
|
||||
label_color = color;
|
||||
@@ -127,6 +138,8 @@ void TextInput::Rescale()
|
||||
{
|
||||
if (!this->icon.name().empty())
|
||||
this->icon.msw_rescale();
|
||||
if (!this->icon_1.name().empty())
|
||||
this->icon_1.msw_rescale();
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
@@ -166,6 +179,10 @@ void TextInput::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
wxSize szIcon = this->icon.GetBmpSize();
|
||||
textPos.x += szIcon.x;
|
||||
}
|
||||
if (this->icon_1.bmp().IsOk()) {
|
||||
wxSize szIcon = this->icon_1.GetBmpSize();
|
||||
textPos.x += (szIcon.x);
|
||||
}
|
||||
bool align_right = GetWindowStyle() & wxALIGN_RIGHT;
|
||||
if (align_right)
|
||||
textPos.x += labelSize.x;
|
||||
@@ -214,6 +231,16 @@ void TextInput::render(wxDC& dc)
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
pt.x += szIcon.x + 0;
|
||||
}
|
||||
if (icon_1.bmp().IsOk()) {
|
||||
wxSize szIcon = icon_1.GetBmpSize();
|
||||
pt.y = (size.y - szIcon.y) / 2;
|
||||
if (align_center) {
|
||||
if (pt.x * 2 + szIcon.x + 0 + labelSize.x < size.x)
|
||||
pt.x = (size.x - (szIcon.x + 0 + labelSize.x)) / 2;
|
||||
}
|
||||
dc.DrawBitmap(icon_1.bmp(), pt);
|
||||
pt.x += szIcon.x + 0;
|
||||
}
|
||||
auto text = wxWindow::GetLabel();
|
||||
if (!text.IsEmpty()) {
|
||||
wxSize textSize = text_ctrl->GetSize();
|
||||
|
||||
Reference in New Issue
Block a user