137{
138 wxPaintDC dc(this);
139 wxSize size = GetSize();
140
141 int svg_size = size.GetWidth();
142 int type_label_height = FromDIP(10);
143 wxString type_label(
m_type);
144 int type_label_margin = FromDIP(3);
145
146 std::string replace_color =
m_color.GetAsString(wxC2S_HTML_SYNTAX).ToStdString();
147 std::string svg_name = "outlined_rect";
148 if (replace_color == "#FFFFFF00") {
149 svg_name = "outlined_rect_transparent";
150 }
151 static Slic3r::GUI::BitmapCache cache;
152 wxBitmap* bmp = cache.
load_svg(svg_name, 0, svg_size,
false,
false, replace_color, 0.f);
153
154
155 dc.DrawBitmap(*bmp, wxPoint(0,0));
156
157
158
159
161 dc.SetTextForeground(
m_color.GetLuminance() < 0.51 ? *wxWHITE : *wxBLACK);
162 dc.DrawLabel(label, wxRect(0, 0, svg_size, svg_size), wxALIGN_CENTER);
163
165 dc.SetTextForeground(this->
m_parent->GetBackgroundColour().GetLuminance() < 0.51 ? *wxWHITE : *wxBLACK);
166 else
167 dc.SetTextForeground(*wxBLACK);
168 if (type_label.length() > 4) {
169
170 wxString first = type_label.Mid(0, 4);
171 wxString rest = type_label.Mid(4);
172 dc.DrawLabel(first, wxRect(0, svg_size + type_label_margin, svg_size, type_label_height), wxALIGN_CENTER);
173 dc.DrawLabel(rest, wxRect(0, svg_size + type_label_height + type_label_margin, svg_size, type_label_height), wxALIGN_CENTER);
174 }else {
175 dc.DrawLabel(type_label, wxRect(0, svg_size + type_label_margin, svg_size, type_label_height), wxALIGN_CENTER);
176 }
177}
wxBitmap * load_svg(const std::string &bitmap_key, unsigned width=0, unsigned height=0, const bool grayscale=false, const bool dark_mode=false, const std::string &new_color="", const float scale_in_center=0.f)
Definition BitmapCache.cpp:326