mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-02 23:31:13 -07:00
Revert to WxWidgets 3.1.5 (#3249)
* revert to WxWidgets 3.1.5 * update nanosvg unicode path
This commit is contained in:
parent
cc23ec6626
commit
374f78c768
95 changed files with 6841 additions and 1618 deletions
|
|
@ -230,11 +230,11 @@ void AMSrefresh::paintEvent(wxPaintEvent &evt)
|
|||
auto colour = StateColor::darkModeColorFor(AMS_CONTROL_GRAY700);
|
||||
if (!wxWindow::IsEnabled()) { colour = AMS_CONTROL_GRAY500; }
|
||||
|
||||
auto pot = wxPoint((size.x - m_bitmap_selected.GetSize().x) / 2, (size.y - m_bitmap_selected.GetSize().y) / 2);
|
||||
auto pot = wxPoint((size.x - m_bitmap_selected.GetBmpSize().x) / 2, (size.y - m_bitmap_selected.GetBmpSize().y) / 2);
|
||||
|
||||
if (!m_disable_mode) {
|
||||
if (!m_play_loading) {
|
||||
dc.DrawBitmap(m_selected ? m_bitmap_selected.get_bitmap() : m_bitmap_normal.get_bitmap(), pot);
|
||||
dc.DrawBitmap(m_selected ? m_bitmap_selected.bmp() : m_bitmap_normal.bmp(), pot);
|
||||
}
|
||||
else {
|
||||
/* m_bitmap_rotation = ScalableBitmap(this, "ams_refresh_normal", 30);
|
||||
|
|
@ -249,7 +249,7 @@ void AMSrefresh::paintEvent(wxPaintEvent &evt)
|
|||
m_rotation_angle = 0;
|
||||
}
|
||||
if (m_rfid_bitmap_list.size() <= 0)return;
|
||||
dc.DrawBitmap(m_rfid_bitmap_list[m_rotation_angle].get_bitmap(), pot);
|
||||
dc.DrawBitmap(m_rfid_bitmap_list[m_rotation_angle].bmp(), pot);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -360,7 +360,7 @@ void AMSextruderImage::doRender(wxDC &dc)
|
|||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(m_colour);
|
||||
dc.DrawRectangle(0, FromDIP(18), size.x, size.y - FromDIP(18) - FromDIP(5));
|
||||
dc.DrawBitmap(m_ams_extruder.get_bitmap(), wxPoint((size.x - m_ams_extruder.GetSize().x) / 2, (size.y - m_ams_extruder.GetSize().y) / 2));
|
||||
dc.DrawBitmap(m_ams_extruder.bmp(), wxPoint((size.x - m_ams_extruder.GetBmpSize().x) / 2, (size.y - m_ams_extruder.GetBmpSize().y) / 2));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -688,11 +688,11 @@ void AMSLib::on_left_down(wxMouseEvent &evt)
|
|||
auto bottom = 0;
|
||||
|
||||
if (m_ams_model == AMSModel::GENERIC_AMS) {
|
||||
top = (size.y - FromDIP(15) - m_bitmap_editable_light.GetSize().y);
|
||||
top = (size.y - FromDIP(15) - m_bitmap_editable_light.GetBmpSize().y);
|
||||
bottom = size.y - FromDIP(15);
|
||||
}
|
||||
else if (m_ams_model == AMSModel::EXTRA_AMS) {
|
||||
top = (size.y - FromDIP(20) - m_bitmap_editable_light.GetSize().y);
|
||||
top = (size.y - FromDIP(20) - m_bitmap_editable_light.GetBmpSize().y);
|
||||
bottom = size.y - FromDIP(20);
|
||||
}
|
||||
|
||||
|
|
@ -1022,21 +1022,21 @@ void AMSLib::render_extra_lib(wxDC& dc)
|
|||
if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE)
|
||||
{
|
||||
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL)
|
||||
dc.DrawBitmap(temp_bitmap_third.get_bitmap(), (size.x - temp_bitmap_third.GetSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_third.GetSize().y));
|
||||
dc.DrawBitmap(temp_bitmap_third.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_third.GetBmpSize().y));
|
||||
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND)
|
||||
dc.DrawBitmap(temp_bitmap_brand.get_bitmap(), (size.x - temp_bitmap_brand.GetSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_brand.GetSize().y));
|
||||
dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_brand.GetBmpSize().y));
|
||||
}
|
||||
}
|
||||
|
||||
// selected & hover
|
||||
if (m_selected) {
|
||||
dc.DrawBitmap(tray_bitmap_selected.get_bitmap(), (size.x - tray_bitmap_selected.GetSize().x) / 2, (size.y - tray_bitmap_selected.GetSize().y) / 2);
|
||||
dc.DrawBitmap(tray_bitmap_selected.bmp(), (size.x - tray_bitmap_selected.GetBmpSize().x) / 2, (size.y - tray_bitmap_selected.GetBmpSize().y) / 2);
|
||||
}
|
||||
else if (!m_selected && m_hover) {
|
||||
dc.DrawBitmap(tray_bitmap_hover.get_bitmap(), (size.x - tray_bitmap_hover.GetSize().x) / 2, (size.y - tray_bitmap_hover.GetSize().y) / 2);
|
||||
dc.DrawBitmap(tray_bitmap_hover.bmp(), (size.x - tray_bitmap_hover.GetBmpSize().x) / 2, (size.y - tray_bitmap_hover.GetBmpSize().y) / 2);
|
||||
}
|
||||
else {
|
||||
dc.DrawBitmap(tray_bitmap.get_bitmap(), (size.x - tray_bitmap.GetSize().x) / 2, (size.y - tray_bitmap.GetSize().y) / 2);
|
||||
dc.DrawBitmap(tray_bitmap.bmp(), (size.x - tray_bitmap.GetBmpSize().x) / 2, (size.y - tray_bitmap.GetBmpSize().y) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1116,7 +1116,7 @@ void AMSLib::render_generic_lib(wxDC &dc)
|
|||
//transparent
|
||||
auto alpha = m_info.material_colour.Alpha();
|
||||
if (alpha == 0) {
|
||||
dc.DrawBitmap(m_bitmap_transparent.get_bitmap(), FromDIP(4), FromDIP(4));
|
||||
dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4));
|
||||
}
|
||||
|
||||
//gradient
|
||||
|
|
@ -1187,9 +1187,9 @@ void AMSLib::render_generic_lib(wxDC &dc)
|
|||
if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE)
|
||||
{
|
||||
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL)
|
||||
dc.DrawBitmap(temp_bitmap_third.get_bitmap(), (size.x - temp_bitmap_third.GetSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetSize().y));
|
||||
dc.DrawBitmap(temp_bitmap_third.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetBmpSize().y));
|
||||
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND)
|
||||
dc.DrawBitmap(temp_bitmap_brand.get_bitmap(), (size.x - temp_bitmap_brand.GetSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetSize().y));
|
||||
dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetBmpSize().y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1244,7 +1244,8 @@ void AMSLib::UnSelected()
|
|||
bool AMSLib::Enable(bool enable) { return wxWindow::Enable(enable); }
|
||||
|
||||
void AMSLib::msw_rescale()
|
||||
{ m_bitmap_transparent.sys_color_changed();
|
||||
{
|
||||
m_bitmap_transparent.msw_rescale();
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
|
|
@ -1451,20 +1452,20 @@ void AMSRoad::doRender(wxDC &dc)
|
|||
else {m_show_humidity = false;}
|
||||
|
||||
if (m_amsinfo.ams_humidity == 5) {
|
||||
dc.DrawBitmap(ams_humidity_4.get_bitmap(), wxPoint(size.x - ams_humidity_4.GetSize().x - FromDIP(4), size.y - ams_humidity_4.GetSize().y - FromDIP(8)));
|
||||
dc.DrawBitmap(ams_humidity_4.bmp(), wxPoint(size.x - ams_humidity_4.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_4.GetBmpSize().y - FromDIP(8)));
|
||||
}
|
||||
else if (m_amsinfo.ams_humidity == 4) {
|
||||
dc.DrawBitmap(ams_humidity_3.get_bitmap(), wxPoint(size.x - ams_humidity_3.GetSize().x - FromDIP(4), size.y - ams_humidity_3.GetSize().y - FromDIP(8)));
|
||||
dc.DrawBitmap(ams_humidity_3.bmp(), wxPoint(size.x - ams_humidity_3.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_3.GetBmpSize().y - FromDIP(8)));
|
||||
}
|
||||
else if (m_amsinfo.ams_humidity == 3) {
|
||||
|
||||
dc.DrawBitmap(ams_humidity_2.get_bitmap(), wxPoint(size.x - ams_humidity_2.GetSize().x - FromDIP(4), size.y - ams_humidity_2.GetSize().y - FromDIP(8)));
|
||||
dc.DrawBitmap(ams_humidity_2.bmp(), wxPoint(size.x - ams_humidity_2.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_2.GetBmpSize().y - FromDIP(8)));
|
||||
}
|
||||
else if (m_amsinfo.ams_humidity == 2) {
|
||||
dc.DrawBitmap(ams_humidity_1.get_bitmap(), wxPoint(size.x - ams_humidity_1.GetSize().x - FromDIP(4), size.y - ams_humidity_1.GetSize().y - FromDIP(8)));
|
||||
dc.DrawBitmap(ams_humidity_1.bmp(), wxPoint(size.x - ams_humidity_1.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_1.GetBmpSize().y - FromDIP(8)));
|
||||
}
|
||||
else if (m_amsinfo.ams_humidity == 1) {
|
||||
dc.DrawBitmap(ams_humidity_0.get_bitmap(), wxPoint(size.x - ams_humidity_0.GetSize().x - FromDIP(4), size.y - ams_humidity_0.GetSize().y - FromDIP(8)));
|
||||
dc.DrawBitmap(ams_humidity_0.bmp(), wxPoint(size.x - ams_humidity_0.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_0.GetBmpSize().y - FromDIP(8)));
|
||||
}
|
||||
else {
|
||||
/*dc.DrawBitmap(ams_humidity_4.bmp(), wxPoint(size.x - ams_humidity_4.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_4.GetBmpSize().y - FromDIP(8)));*/
|
||||
|
|
@ -1661,7 +1662,7 @@ void AMSItem::doRender(wxDC &dc)
|
|||
|
||||
}else {
|
||||
if (iter->material_colour.Alpha() == 0) {
|
||||
dc.DrawBitmap(m_ts_bitmap_cube->get_bitmap(),left,(size.y - AMS_ITEM_CUBE_SIZE.y) / 2);
|
||||
dc.DrawBitmap(m_ts_bitmap_cube->bmp(),left,(size.y - AMS_ITEM_CUBE_SIZE.y) / 2);
|
||||
}
|
||||
else {
|
||||
wxRect rect(left, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2, AMS_ITEM_CUBE_SIZE.x, AMS_ITEM_CUBE_SIZE.y);
|
||||
|
|
@ -2091,7 +2092,7 @@ void AmsCans::render(wxDC& dc)
|
|||
void AmsCans::doRender(wxDC& dc)
|
||||
{
|
||||
wxSize size = GetSize();
|
||||
dc.DrawBitmap(m_bitmap_extra_framework.get_bitmap(), (size.x - m_bitmap_extra_framework.GetSize().x) / 2, (size.y - m_bitmap_extra_framework.GetSize().y) / 2);
|
||||
dc.DrawBitmap(m_bitmap_extra_framework.bmp(), (size.x - m_bitmap_extra_framework.GetBmpSize().x) / 2, (size.y - m_bitmap_extra_framework.GetBmpSize().y) / 2);
|
||||
|
||||
//road for extra
|
||||
if (m_ams_model == AMSModel::EXTRA_AMS) {
|
||||
|
|
@ -2981,9 +2982,9 @@ void AMSControl::StopRridLoading(wxString amsid, wxString canid)
|
|||
|
||||
void AMSControl::msw_rescale()
|
||||
{
|
||||
m_button_ams_setting_normal.sys_color_changed();
|
||||
m_button_ams_setting_hover.sys_color_changed();
|
||||
m_button_ams_setting_press.sys_color_changed();
|
||||
m_button_ams_setting_normal.msw_rescale();
|
||||
m_button_ams_setting_hover.msw_rescale();
|
||||
m_button_ams_setting_press.msw_rescale();
|
||||
m_button_ams_setting->SetBitmap(m_button_ams_setting_normal.bmp());
|
||||
|
||||
m_extruder->msw_rescale();
|
||||
|
|
|
|||
|
|
@ -212,8 +212,7 @@ void AxisCtrlButton::render(wxDC& dc)
|
|||
gc->DrawPath(home_path);
|
||||
|
||||
if (m_icon.bmp().IsOk()) {
|
||||
gc->DrawBitmap(m_icon.get_bitmap(), -1 * m_icon.GetWidth() / 2, -1 * m_icon.GetHeight() / 2, m_icon.GetWidth(),
|
||||
m_icon.GetHeight());
|
||||
gc->DrawBitmap(m_icon.bmp(), -1 * m_icon.GetBmpWidth() / 2, -1 * m_icon.GetBmpHeight() / 2, m_icon.GetBmpWidth(), m_icon.GetBmpHeight());
|
||||
}
|
||||
gc->PopState();
|
||||
|
||||
|
|
|
|||
|
|
@ -146,10 +146,10 @@ bool Button::GetValue() const { return state_handler.states() & StateHandler::Ch
|
|||
void Button::Rescale()
|
||||
{
|
||||
if (this->active_icon.bmp().IsOk())
|
||||
this->active_icon.sys_color_changed();
|
||||
this->active_icon.msw_rescale();
|
||||
|
||||
if (this->inactive_icon.bmp().IsOk())
|
||||
this->inactive_icon.sys_color_changed();
|
||||
this->inactive_icon.msw_rescale();
|
||||
|
||||
messureSize();
|
||||
}
|
||||
|
|
@ -187,7 +187,7 @@ void Button::render(wxDC& dc)
|
|||
//BBS norrow size between text and icon
|
||||
szContent.x += padding;
|
||||
}
|
||||
szIcon = icon.GetSize();
|
||||
szIcon = icon.GetBmpSize();
|
||||
szContent.x += szIcon.x;
|
||||
if (szIcon.y > szContent.y)
|
||||
szContent.y = szIcon.y;
|
||||
|
|
@ -206,7 +206,7 @@ void Button::render(wxDC& dc)
|
|||
wxPoint pt = rcContent.GetLeftTop();
|
||||
if (icon.bmp().IsOk()) {
|
||||
pt.y += (rcContent.height - szIcon.y) / 2;
|
||||
dc.DrawBitmap(icon.get_bitmap(), pt);
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
//BBS norrow size between text and icon
|
||||
pt.x += szIcon.x + padding;
|
||||
pt.y = rcContent.y;
|
||||
|
|
@ -239,7 +239,7 @@ void Button::messureSize()
|
|||
//BBS norrow size between text and icon
|
||||
szContent.x += 5;
|
||||
}
|
||||
wxSize szIcon = this->active_icon.GetSize();
|
||||
wxSize szIcon = this->active_icon.GetBmpSize();
|
||||
szContent.x += szIcon.x;
|
||||
if (szIcon.y > szContent.y)
|
||||
szContent.y = szIcon.y;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ CheckBox::CheckBox(wxWindow *parent, int id)
|
|||
Bind(wxEVT_ENTER_WINDOW, &CheckBox::updateBitmap, this);
|
||||
Bind(wxEVT_LEAVE_WINDOW, &CheckBox::updateBitmap, this);
|
||||
#endif
|
||||
SetSize(m_on.GetSize());
|
||||
SetMinSize(m_on.GetSize());
|
||||
SetSize(m_on.GetBmpSize());
|
||||
SetMinSize(m_on.GetBmpSize());
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
@ -43,16 +43,16 @@ void CheckBox::SetHalfChecked(bool value)
|
|||
|
||||
void CheckBox::Rescale()
|
||||
{
|
||||
m_on.sys_color_changed();
|
||||
m_half.sys_color_changed();
|
||||
m_off.sys_color_changed();
|
||||
m_on_disabled.sys_color_changed();
|
||||
m_half_disabled.sys_color_changed();
|
||||
m_off_disabled.sys_color_changed();
|
||||
m_on_focused.sys_color_changed();
|
||||
m_half_focused.sys_color_changed();
|
||||
m_off_focused.sys_color_changed();
|
||||
SetSize(m_on.GetSize());
|
||||
m_on.msw_rescale();
|
||||
m_half.msw_rescale();
|
||||
m_off.msw_rescale();
|
||||
m_on_disabled.msw_rescale();
|
||||
m_half_disabled.msw_rescale();
|
||||
m_off_disabled.msw_rescale();
|
||||
m_on_focused.msw_rescale();
|
||||
m_half_focused.msw_rescale();
|
||||
m_off_focused.msw_rescale();
|
||||
SetSize(m_on.GetBmpSize());
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,13 +98,6 @@ void ComboBox::Rescale()
|
|||
drop.Rescale();
|
||||
}
|
||||
|
||||
bool ComboBox::Enable(bool enable) {
|
||||
bool ret = TextInput::Enable(enable);
|
||||
if (ret && drop.selection >= 0 && drop.iconSize.y > 0)
|
||||
SetIcon(icons[drop.selection]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxString ComboBox::GetValue() const
|
||||
{
|
||||
return drop.GetSelection() >= 0 ? drop.GetValue() : GetLabel();
|
||||
|
|
@ -152,17 +145,13 @@ bool ComboBox::SetFont(wxFont const& font)
|
|||
return TextInput::SetFont(font);
|
||||
}
|
||||
|
||||
void ComboBox::SetIcon(const wxBitmapBundle &icon) {
|
||||
TextInput::SetIcon(m_isEnabled ? icon : icon.GetBitmapFor(this).ConvertToDisabled(128));
|
||||
}
|
||||
|
||||
int ComboBox::Append(const wxString &item, const wxBitmapBundle &bitmap)
|
||||
int ComboBox::Append(const wxString &item, const wxBitmap &bitmap)
|
||||
{
|
||||
return Append(item, bitmap, nullptr);
|
||||
}
|
||||
|
||||
int ComboBox::Append(const wxString &item,
|
||||
const wxBitmapBundle &bitmap,
|
||||
const wxBitmap &bitmap,
|
||||
void * clientData)
|
||||
{
|
||||
texts.push_back(item);
|
||||
|
|
@ -207,9 +196,9 @@ void ComboBox::SetString(unsigned int n, wxString const &value)
|
|||
if (n == drop.GetSelection()) SetLabel(value);
|
||||
}
|
||||
|
||||
wxBitmap ComboBox::GetItemBitmap(unsigned int n) { return icons[n].GetBitmapFor(m_parent); }
|
||||
wxBitmap ComboBox::GetItemBitmap(unsigned int n) { return icons[n]; }
|
||||
|
||||
void ComboBox::SetItemBitmap(unsigned int n, wxBitmapBundle const &bitmap)
|
||||
void ComboBox::SetItemBitmap(unsigned int n, wxBitmap const &bitmap)
|
||||
{
|
||||
if (n >= texts.size()) return;
|
||||
icons[n] = bitmap;
|
||||
|
|
@ -241,7 +230,9 @@ void ComboBox::DoSetItemClientData(unsigned int n, void *data)
|
|||
datas[n] = data;
|
||||
}
|
||||
|
||||
void ComboBox::ToggleDropDown(){
|
||||
void ComboBox::mouseDown(wxMouseEvent &event)
|
||||
{
|
||||
SetFocus();
|
||||
if (drop_down) {
|
||||
drop.Hide();
|
||||
} else if (drop.HasDismissLongTime()) {
|
||||
|
|
@ -253,12 +244,6 @@ void ComboBox::ToggleDropDown(){
|
|||
}
|
||||
}
|
||||
|
||||
void ComboBox::mouseDown(wxMouseEvent &event)
|
||||
{
|
||||
SetFocus();
|
||||
ToggleDropDown();
|
||||
}
|
||||
|
||||
void ComboBox::mouseWheelMoved(wxMouseEvent &event)
|
||||
{
|
||||
event.Skip();
|
||||
|
|
@ -276,7 +261,15 @@ void ComboBox::keyDown(wxKeyEvent& event)
|
|||
switch (event.GetKeyCode()) {
|
||||
case WXK_RETURN:
|
||||
case WXK_SPACE:
|
||||
ToggleDropDown();
|
||||
if (drop_down) {
|
||||
drop.DismissAndNotify();
|
||||
} else if (drop.HasDismissLongTime()) {
|
||||
drop.autoPosition();
|
||||
drop_down = true;
|
||||
drop.Popup();
|
||||
wxCommandEvent e(wxEVT_COMBOBOX_DROPDOWN);
|
||||
GetEventHandler()->ProcessEvent(e);
|
||||
}
|
||||
break;
|
||||
case WXK_UP:
|
||||
case WXK_DOWN:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
class ComboBox : public wxWindowWithItems<TextInput, wxItemContainer>
|
||||
{
|
||||
std::vector<wxString> texts;
|
||||
std::vector<wxBitmapBundle> icons;
|
||||
std::vector<wxBitmap> icons;
|
||||
std::vector<void *> datas;
|
||||
std::vector<wxClientDataType> types;
|
||||
|
||||
|
|
@ -32,9 +32,10 @@ public:
|
|||
|
||||
virtual bool SetFont(wxFont const & font) override;
|
||||
|
||||
int Append(const wxString &item, const wxBitmapBundle &bitmap = wxNullBitmap);
|
||||
public:
|
||||
int Append(const wxString &item, const wxBitmap &bitmap = wxNullBitmap);
|
||||
|
||||
int Append(const wxString &item, const wxBitmapBundle &bitmap, void *clientData);
|
||||
int Append(const wxString &item, const wxBitmap &bitmap, void *clientData);
|
||||
|
||||
unsigned int GetCount() const override;
|
||||
|
||||
|
|
@ -59,12 +60,8 @@ public:
|
|||
void SetString(unsigned int n, wxString const &value) override;
|
||||
|
||||
wxBitmap GetItemBitmap(unsigned int n);
|
||||
void SetItemBitmap(unsigned int n, wxBitmapBundle const &bitmap);
|
||||
|
||||
void ToggleDropDown();
|
||||
bool Enable(bool enable = true) override;
|
||||
void SetIcon(const wxBitmapBundle &icon) override;
|
||||
|
||||
void SetItemBitmap(unsigned int n, wxBitmap const &bitmap);
|
||||
bool is_drop_down(){return drop_down;}
|
||||
protected:
|
||||
virtual int DoInsertItems(const wxArrayStringsAdapter &items,
|
||||
unsigned int pos,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ END_EVENT_TABLE()
|
|||
*/
|
||||
|
||||
DropDown::DropDown(std::vector<wxString> &texts,
|
||||
std::vector<wxBitmapBundle> &icons)
|
||||
std::vector<wxBitmap> &icons)
|
||||
: texts(texts)
|
||||
, icons(icons)
|
||||
, state_handler(this)
|
||||
|
|
@ -44,7 +44,7 @@ DropDown::DropDown(std::vector<wxString> &texts,
|
|||
|
||||
DropDown::DropDown(wxWindow * parent,
|
||||
std::vector<wxString> &texts,
|
||||
std::vector<wxBitmapBundle> &icons,
|
||||
std::vector<wxBitmap> &icons,
|
||||
long style)
|
||||
: DropDown(texts, icons)
|
||||
{
|
||||
|
|
@ -188,6 +188,15 @@ void DropDown::paintNow()
|
|||
Refresh();
|
||||
}
|
||||
|
||||
static wxSize GetBmpSize(wxBitmap & bmp)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
return bmp.GetScaledSize();
|
||||
#else
|
||||
return bmp.GetSize();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Here we do the actual rendering. I put it in a separate
|
||||
* method so that it can work no matter what type of DC
|
||||
|
|
@ -256,13 +265,13 @@ void DropDown::render(wxDC &dc)
|
|||
rcContent.x += 5;
|
||||
rcContent.width -= 5;
|
||||
if (check_bitmap.bmp().IsOk()) {
|
||||
auto szBmp = check_bitmap.GetSize();
|
||||
auto szBmp = check_bitmap.GetBmpSize();
|
||||
if (selection >= 0) {
|
||||
wxPoint pt = rcContent.GetLeftTop();
|
||||
pt.y += (rcContent.height - szBmp.y) / 2;
|
||||
pt.y += rowSize.y * selection;
|
||||
if (pt.y + szBmp.y > 0 && pt.y < size.y)
|
||||
dc.DrawBitmap(check_bitmap.get_bitmap(), pt);
|
||||
dc.DrawBitmap(check_bitmap.bmp(), pt);
|
||||
}
|
||||
rcContent.x += szBmp.x + 5;
|
||||
rcContent.width -= szBmp.x + 5;
|
||||
|
|
@ -277,17 +286,17 @@ void DropDown::render(wxDC &dc)
|
|||
if (rcContent.y > size.y) break;
|
||||
wxPoint pt = rcContent.GetLeftTop();
|
||||
auto & icon = icons[i];
|
||||
auto size2 = get_preferred_size(icon, m_parent);
|
||||
auto size2 = GetBmpSize(icon);
|
||||
if (iconSize.x > 0) {
|
||||
if (icon.IsOk()) {
|
||||
pt.y += (rcContent.height - size2.y) / 2;
|
||||
dc.DrawBitmap(icon.GetBitmapFor(m_parent), pt);
|
||||
dc.DrawBitmap(icon, pt);
|
||||
}
|
||||
pt.x += iconSize.x + 5;
|
||||
pt.y = rcContent.y;
|
||||
} else if (icon.IsOk()) {
|
||||
pt.y += (rcContent.height - size2.y) / 2;
|
||||
dc.DrawBitmap(icon.GetBitmapFor(m_parent), pt);
|
||||
dc.DrawBitmap(icon, pt);
|
||||
pt.x += size2.x + 5;
|
||||
pt.y = rcContent.y;
|
||||
}
|
||||
|
|
@ -317,7 +326,7 @@ void DropDown::messureSize()
|
|||
for (size_t i = 0; i < texts.size(); ++i) {
|
||||
wxSize size1 = text_off ? wxSize() : dc.GetMultiLineTextExtent(texts[i]);
|
||||
if (icons[i].IsOk()) {
|
||||
wxSize size2 = get_preferred_size(icons[i], m_parent);
|
||||
wxSize size2 = GetBmpSize(icons[i]);
|
||||
if (size2.x > iconSize.x) iconSize = size2;
|
||||
if (!align_icon) {
|
||||
size1.x += size2.x + (text_off ? 0 : 5);
|
||||
|
|
@ -329,7 +338,7 @@ void DropDown::messureSize()
|
|||
wxSize szContent = textSize;
|
||||
szContent.x += 10;
|
||||
if (check_bitmap.bmp().IsOk()) {
|
||||
auto szBmp = check_bitmap.GetSize();
|
||||
auto szBmp = check_bitmap.GetBmpSize();
|
||||
szContent.x += szBmp.x + 5;
|
||||
}
|
||||
if (iconSize.x > 0) szContent.x += iconSize.x + (text_off ? 0 : 5);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ wxDECLARE_EVENT(EVT_DISMISS, wxCommandEvent);
|
|||
class DropDown : public PopupWindow
|
||||
{
|
||||
std::vector<wxString> & texts;
|
||||
std::vector<wxBitmapBundle> & icons;
|
||||
std::vector<wxBitmap> & icons;
|
||||
bool need_sync = false;
|
||||
int selection = -1;
|
||||
int hover_item = -1;
|
||||
|
|
@ -44,11 +44,11 @@ class DropDown : public PopupWindow
|
|||
|
||||
public:
|
||||
DropDown(std::vector<wxString> &texts,
|
||||
std::vector<wxBitmapBundle> &icons);
|
||||
std::vector<wxBitmap> &icons);
|
||||
|
||||
DropDown(wxWindow * parent,
|
||||
std::vector<wxString> &texts,
|
||||
std::vector<wxBitmapBundle> &icons,
|
||||
std::vector<wxBitmap> &icons,
|
||||
long style = 0);
|
||||
|
||||
void Create(wxWindow * parent,
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ void Fan::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSi
|
|||
// SetMinSize(wxSize(FromDIP(100), FromDIP(100) + FromDIP(6)));
|
||||
// SetMaxSize(wxSize(FromDIP(100), FromDIP(100) + FromDIP(6)));
|
||||
//#else
|
||||
SetMinSize(wxSize(m_bitmap_bk.GetSize().x, m_bitmap_bk.GetSize().y + FromDIP(6)));
|
||||
SetMaxSize(wxSize(m_bitmap_bk.GetSize().x, m_bitmap_bk.GetSize().y + FromDIP(6)));
|
||||
SetMinSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
|
||||
SetMaxSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
|
||||
//#endif // __APPLE__
|
||||
|
||||
Bind(wxEVT_PAINT, &Fan::paintEvent, this);
|
||||
|
|
@ -115,7 +115,7 @@ void Fan::doRender(wxDC& dc)
|
|||
auto rpm = wxT("rpm");
|
||||
|
||||
wxSize size = GetSize();
|
||||
dc.DrawBitmap(m_bitmap_bk.get_bitmap(), wxPoint(0,0));
|
||||
dc.DrawBitmap(m_bitmap_bk.bmp(), wxPoint(0,0));
|
||||
|
||||
//fan scale
|
||||
/*auto central_point = wxPoint(size.x / 2, size.y / 2 + FromDIP(15));
|
||||
|
|
@ -133,8 +133,8 @@ void Fan::doRender(wxDC& dc)
|
|||
//fan pointer
|
||||
//auto pointer_central_point = wxPoint((size.x - m_img_pointer.GetSize().x) / 2, (size.y - m_img_pointer.GetSize().y) / 2);
|
||||
//auto bmp = m_img_pointer.Rotate(m_rotate_offsets[m_current_speeds].rotate, wxPoint(size.x / 2,size.y / 2));
|
||||
auto central_point = wxPoint((size.x - m_bitmap_scales[m_current_speeds].GetSize().x) / 2, (size.y - m_bitmap_scales[m_current_speeds].GetSize().y) / 2 - FromDIP(4));
|
||||
dc.DrawBitmap(m_bitmap_scales[m_current_speeds].get_bitmap(), central_point.x, central_point.y);
|
||||
auto central_point = wxPoint((size.x - m_bitmap_scales[m_current_speeds].GetBmpSize().x) / 2, (size.y - m_bitmap_scales[m_current_speeds].GetBmpSize().y) / 2 - FromDIP(4));
|
||||
dc.DrawBitmap(m_bitmap_scales[m_current_speeds].bmp(), central_point.x, central_point.y);
|
||||
|
||||
//fan val
|
||||
dc.SetTextForeground(DRAW_TEXT_COLOUR);
|
||||
|
|
@ -147,7 +147,8 @@ void Fan::doRender(wxDC& dc)
|
|||
//dc.DrawText(rpm, (size.x - dc.GetTextExtent(rpm).x) / 2, size.y - dc.GetTextExtent(rpm).y);
|
||||
}
|
||||
|
||||
void Fan::msw_rescale() { m_bitmap_bk.sys_color_changed();
|
||||
void Fan::msw_rescale() {
|
||||
m_bitmap_bk.msw_rescale();
|
||||
}
|
||||
|
||||
void Fan::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
|
|
@ -279,8 +280,8 @@ void FanOperate::doRender(wxDC& dc)
|
|||
dc.DrawLine(left_fir, FromDIP(4), left_fir, size.y - FromDIP(4));
|
||||
dc.DrawLine(left_fir * 2, FromDIP(4), left_fir * 2, size.y - FromDIP(4));
|
||||
|
||||
dc.DrawBitmap(m_bitmap_decrease.get_bitmap(), (left_fir - m_bitmap_decrease.GetSize().x) / 2, (size.y - m_bitmap_decrease.GetSize().y) / 2);
|
||||
dc.DrawBitmap(m_bitmap_add.get_bitmap(), (left_fir * 2 + (left_fir - m_bitmap_decrease.GetSize().x) / 2), (size.y - m_bitmap_add.GetSize().y) / 2);
|
||||
dc.DrawBitmap(m_bitmap_decrease.bmp(), (left_fir - m_bitmap_decrease.GetBmpSize().x) / 2, (size.y - m_bitmap_decrease.GetBmpSize().y) / 2);
|
||||
dc.DrawBitmap(m_bitmap_add.bmp(), (left_fir * 2 + (left_fir - m_bitmap_decrease.GetBmpSize().x) / 2), (size.y - m_bitmap_add.GetBmpSize().y) / 2);
|
||||
|
||||
//txt
|
||||
dc.SetFont(::Label::Body_12);
|
||||
|
|
|
|||
|
|
@ -110,12 +110,12 @@ void ImageSwitchButton::render(wxDC& dc)
|
|||
wxSize szContent = textSize;
|
||||
ScalableBitmap &icon = GetValue() ? m_on : m_off;
|
||||
|
||||
int content_height = icon.GetHeight() + textSize.y + m_padding;
|
||||
int content_height = icon.GetBmpHeight() + textSize.y + m_padding;
|
||||
|
||||
wxPoint pt = wxPoint((size.x - icon.GetWidth()) / 2, (size.y - content_height) / 2);
|
||||
wxPoint pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, (size.y - content_height) / 2);
|
||||
if (icon.bmp().IsOk()) {
|
||||
dc.DrawBitmap(icon.get_bitmap(), pt);
|
||||
pt.y += m_padding + icon.GetHeight();
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
pt.y += m_padding + icon.GetBmpHeight();
|
||||
}
|
||||
pt.x = (size.x - textSize.x) / 2;
|
||||
dc.SetFont(GetFont());
|
||||
|
|
@ -273,7 +273,7 @@ void FanSwitchButton::render(wxDC& dc)
|
|||
//int content_height = icon.GetBmpHeight() + textSize.y + m_padding;
|
||||
int content_height = m_padding;
|
||||
|
||||
wxPoint pt = wxPoint((size.x - icon.GetWidth()) / 2, (size.y - content_height) / 2);
|
||||
wxPoint pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, (size.y - content_height) / 2);
|
||||
|
||||
pt.x = (size.x - textSize.x) / 2;
|
||||
dc.SetFont(GetFont());
|
||||
|
|
@ -298,10 +298,10 @@ void FanSwitchButton::render(wxDC& dc)
|
|||
dc.DrawText(fina_txt, wxPoint(pt.x, content_height));
|
||||
}
|
||||
|
||||
pt = wxPoint((size.x - icon.GetWidth()) / 2, content_height + textSize.y);
|
||||
pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, content_height + textSize.y);
|
||||
if (icon.bmp().IsOk()) {
|
||||
dc.DrawBitmap(icon.get_bitmap(), pt);
|
||||
pt.y += m_padding + icon.GetHeight();
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
pt.y += m_padding + icon.GetBmpHeight();
|
||||
}
|
||||
|
||||
auto speed = wxString::Format("%d%%", m_speed);
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ RadioBox::RadioBox(wxWindow *parent)
|
|||
// SetBackgroundStyle(wxBG_STYLE_TRANSPARENT);
|
||||
if (parent) SetBackgroundColour(parent->GetBackgroundColour());
|
||||
// Bind(wxEVT_TOGGLEBUTTON, [this](auto& e) { update(); e.Skip(); });
|
||||
SetSize(m_on.GetSize());
|
||||
SetMinSize(m_on.GetSize());
|
||||
SetSize(m_on.GetBmpSize());
|
||||
SetMinSize(m_on.GetBmpSize());
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
@ -29,9 +29,9 @@ bool RadioBox::GetValue()
|
|||
|
||||
void RadioBox::Rescale()
|
||||
{
|
||||
m_on.sys_color_changed();
|
||||
m_off.sys_color_changed();
|
||||
SetSize(m_on.GetSize());
|
||||
m_on.msw_rescale();
|
||||
m_off.msw_rescale();
|
||||
SetSize(m_on.GetBmpSize());
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ bool SideButton::Enable(bool enable)
|
|||
void SideButton::Rescale()
|
||||
{
|
||||
if (this->icon.bmp().IsOk())
|
||||
this->icon.sys_color_changed();
|
||||
this->icon.msw_rescale();
|
||||
messureSize();
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +246,7 @@ void SideButton::dorender(wxDC& dc, wxDC& text_dc)
|
|||
//BBS norrow size between text and icon
|
||||
szContent.x += 5;
|
||||
}
|
||||
szIcon = icon.GetSize();
|
||||
szIcon = icon.GetBmpSize();
|
||||
szContent.x += szIcon.x;
|
||||
if (szIcon.y > szContent.y)
|
||||
szContent.y = szIcon.y;
|
||||
|
|
@ -270,7 +270,7 @@ void SideButton::dorender(wxDC& dc, wxDC& text_dc)
|
|||
//BBS extra pixels for icon
|
||||
pt.x += icon_offset;
|
||||
pt.y += (rcContent.height - szIcon.y) / 2;
|
||||
dc.DrawBitmap(icon.get_bitmap(), pt);
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
//BBS norrow size between text and icon
|
||||
pt.x += szIcon.x + 5;
|
||||
pt.y = rcContent.y;
|
||||
|
|
@ -299,7 +299,7 @@ void SideButton::messureSize()
|
|||
if (szContent.y > 0) {
|
||||
szContent.x += 5;
|
||||
}
|
||||
wxSize szIcon = this->icon.GetSize();
|
||||
wxSize szIcon = this->icon.GetBmpSize();
|
||||
szContent.x += szIcon.x;
|
||||
if (szIcon.y > szContent.y)
|
||||
szContent.y = szIcon.y;
|
||||
|
|
|
|||
|
|
@ -150,19 +150,19 @@ void SideToolsPanel::doRender(wxDC &dc)
|
|||
dc.SetBrush(SIDE_TOOLS_BRAND);
|
||||
dc.DrawRectangle(0, 0, size.x, size.y);
|
||||
|
||||
dc.DrawBitmap(m_none_printing_img.get_bitmap(), left, (size.y - m_none_printing_img.GetSize().y) / 2);
|
||||
dc.DrawBitmap(m_none_printing_img.bmp(), left, (size.y - m_none_printing_img.GetBmpSize().y) / 2);
|
||||
|
||||
left += (m_none_printing_img.GetSize().x + FromDIP(15));
|
||||
dc.DrawBitmap(m_none_arrow_img.get_bitmap(), left, (size.y - m_none_arrow_img.GetSize().y) / 2);
|
||||
left += (m_none_printing_img.GetBmpSize().x + FromDIP(15));
|
||||
dc.DrawBitmap(m_none_arrow_img.bmp(), left, (size.y - m_none_arrow_img.GetBmpSize().y) / 2);
|
||||
|
||||
left += (m_none_arrow_img.GetSize().x + FromDIP(6));
|
||||
left += (m_none_arrow_img.GetBmpSize().x + FromDIP(6));
|
||||
dc.SetFont(::Label::Body_14);
|
||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||
dc.SetTextForeground(*wxWHITE);
|
||||
|
||||
wxString no_printer_str = _L("No printer");
|
||||
auto sizet = dc.GetTextExtent(no_printer_str);
|
||||
auto left_add_bitmap = size.x - FromDIP(30) - m_wifi_none_img.GetSize().x - m_none_add_img.GetSize().x;
|
||||
auto left_add_bitmap = size.x - FromDIP(30) - m_wifi_none_img.GetBmpSize().x - m_none_add_img.GetBmpSize().x;
|
||||
auto size_width = left_add_bitmap - left;
|
||||
|
||||
if (sizet.x > size_width) {
|
||||
|
|
@ -181,21 +181,21 @@ void SideToolsPanel::doRender(wxDC &dc)
|
|||
|
||||
dc.DrawText(no_printer_str, wxPoint(left, (size.y - sizet.y) / 2));
|
||||
|
||||
left = size.x - FromDIP(30) - m_wifi_none_img.GetSize().x;
|
||||
dc.DrawBitmap(m_none_add_img.get_bitmap(), left, (size.y - m_none_add_img.GetSize().y) / 2);
|
||||
left = size.x - FromDIP(30) - m_wifi_none_img.GetBmpSize().x;
|
||||
dc.DrawBitmap(m_none_add_img.bmp(), left, (size.y - m_none_add_img.GetBmpSize().y) / 2);
|
||||
} else {
|
||||
dc.DrawBitmap(m_printing_img.get_bitmap(), left, (size.y - m_printing_img.GetSize().y) / 2);
|
||||
dc.DrawBitmap(m_printing_img.bmp(), left, (size.y - m_printing_img.GetBmpSize().y) / 2);
|
||||
|
||||
left += (m_printing_img.GetSize().x + FromDIP(5));
|
||||
dc.DrawBitmap(m_arrow_img.get_bitmap(), left, (size.y - m_arrow_img.GetSize().y) / 2);
|
||||
left += (m_printing_img.GetBmpSize().x + FromDIP(5));
|
||||
dc.DrawBitmap(m_arrow_img.bmp(), left, (size.y - m_arrow_img.GetBmpSize().y) / 2);
|
||||
|
||||
left += (m_arrow_img.GetSize().x + FromDIP(6));
|
||||
left += (m_arrow_img.GetBmpSize().x + FromDIP(6));
|
||||
dc.SetFont(::Label::Body_14);
|
||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||
dc.SetTextForeground(StateColor::darkModeColorFor(SIDE_TOOLS_GREY900));
|
||||
|
||||
auto sizet = dc.GetTextExtent(m_dev_name);
|
||||
auto text_end = size.x - m_wifi_none_img.GetSize().x - 20;
|
||||
auto text_end = size.x - m_wifi_none_img.GetBmpSize().x - 20;
|
||||
|
||||
std::string finally_name = m_dev_name.ToStdString();
|
||||
if (sizet.x > (text_end - left)) {
|
||||
|
|
@ -212,12 +212,12 @@ void SideToolsPanel::doRender(wxDC &dc)
|
|||
|
||||
dc.DrawText(finally_name, wxPoint(left, (size.y - sizet.y) / 2));
|
||||
|
||||
left = size.x - FromDIP(18) - m_wifi_none_img.GetSize().x;
|
||||
if (m_wifi_type == WifiSignal::NONE) dc.DrawBitmap(m_wifi_none_img.get_bitmap(), left, (size.y - m_wifi_none_img.GetSize().y) / 2);
|
||||
if (m_wifi_type == WifiSignal::WEAK) dc.DrawBitmap(m_wifi_weak_img.get_bitmap(), left, (size.y - m_wifi_weak_img.GetSize().y) / 2);
|
||||
if (m_wifi_type == WifiSignal::MIDDLE) dc.DrawBitmap(m_wifi_middle_img.get_bitmap(), left, (size.y - m_wifi_middle_img.GetSize().y) / 2);
|
||||
if (m_wifi_type == WifiSignal::STRONG) dc.DrawBitmap(m_wifi_strong_img.get_bitmap(), left, (size.y - m_wifi_strong_img.GetSize().y) / 2);
|
||||
if (m_wifi_type == WifiSignal::WIRED) dc.DrawBitmap(m_network_wired_img.get_bitmap(), left, (size.y - m_network_wired_img.GetSize().y) / 2);
|
||||
left = size.x - FromDIP(18) - m_wifi_none_img.GetBmpSize().x;
|
||||
if (m_wifi_type == WifiSignal::NONE) dc.DrawBitmap(m_wifi_none_img.bmp(), left, (size.y - m_wifi_none_img.GetBmpSize().y) / 2);
|
||||
if (m_wifi_type == WifiSignal::WEAK) dc.DrawBitmap(m_wifi_weak_img.bmp(), left, (size.y - m_wifi_weak_img.GetBmpSize().y) / 2);
|
||||
if (m_wifi_type == WifiSignal::MIDDLE) dc.DrawBitmap(m_wifi_middle_img.bmp(), left, (size.y - m_wifi_middle_img.GetBmpSize().y) / 2);
|
||||
if (m_wifi_type == WifiSignal::STRONG) dc.DrawBitmap(m_wifi_strong_img.bmp(), left, (size.y - m_wifi_strong_img.GetBmpSize().y) / 2);
|
||||
if (m_wifi_type == WifiSignal::WIRED) dc.DrawBitmap(m_network_wired_img.bmp(), left, (size.y - m_network_wired_img.GetBmpSize().y) / 2);
|
||||
}
|
||||
|
||||
if (m_hover) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void StaticLine::SetLineColour(wxColour color)
|
|||
void StaticLine::Rescale()
|
||||
{
|
||||
if (this->icon.bmp().IsOk())
|
||||
this->icon.sys_color_changed();
|
||||
this->icon.msw_rescale();
|
||||
messureSize();
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ void StaticLine::messureSize()
|
|||
// BBS norrow size between text and icon
|
||||
szContent.x += 5;
|
||||
}
|
||||
wxSize szIcon = this->icon.GetSize();
|
||||
wxSize szIcon = this->icon.GetBmpSize();
|
||||
szContent.x += szIcon.x;
|
||||
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
|
||||
}
|
||||
|
|
@ -90,13 +90,13 @@ void StaticLine::render(wxDC& dc)
|
|||
auto label = GetLabel();
|
||||
if (!label.IsEmpty()) textSize = dc.GetTextExtent(label);
|
||||
wxRect titleRect{{0, 0}, size};
|
||||
titleRect.height = wxMax(icon.GetHeight(), textSize.GetHeight());
|
||||
int contentWidth = icon.GetWidth() + ((icon.bmp().IsOk() && textSize.GetWidth() > 0) ? 5 : 0) +
|
||||
titleRect.height = wxMax(icon.GetBmpHeight(), textSize.GetHeight());
|
||||
int contentWidth = icon.GetBmpWidth() + ((icon.bmp().IsOk() && textSize.GetWidth() > 0) ? 5 : 0) +
|
||||
textSize.GetWidth();
|
||||
if (vertical) titleRect.Deflate((size.GetWidth() - contentWidth) / 2, 0);
|
||||
if (icon.bmp().IsOk()) {
|
||||
dc.DrawBitmap(icon.get_bitmap(), {0, (size.y - icon.GetHeight()) / 2});
|
||||
titleRect.x += icon.GetWidth() + 5;
|
||||
dc.DrawBitmap(icon.bmp(), {0, (size.y - icon.GetBmpHeight()) / 2});
|
||||
titleRect.x += icon.GetBmpWidth() + 5;
|
||||
}
|
||||
if (!label.IsEmpty()) {
|
||||
dc.SetTextForeground(StateColor::darkModeColorFor(GetForegroundColour()));
|
||||
|
|
|
|||
|
|
@ -122,15 +122,15 @@ StepCtrl::StepCtrl(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wx
|
|||
, bmp_thumb(this, "step_thumb", 36)
|
||||
{
|
||||
StaticBox::border_width = 3;
|
||||
radius = radius * bmp_thumb.GetHeight() / 36;
|
||||
bar_width = bar_width * bmp_thumb.GetHeight() / 36;
|
||||
radius = radius * bmp_thumb.GetBmpHeight() / 36;
|
||||
bar_width = bar_width * bmp_thumb.GetBmpHeight() / 36;
|
||||
}
|
||||
|
||||
void StepCtrl::Rescale()
|
||||
{
|
||||
bmp_thumb.sys_color_changed();
|
||||
radius = radius * bmp_thumb.GetHeight() / 36;
|
||||
bar_width = bar_width * bmp_thumb.GetHeight() / 36;
|
||||
bmp_thumb.msw_rescale();
|
||||
radius = radius * bmp_thumb.GetBmpHeight() / 36;
|
||||
bar_width = bar_width * bmp_thumb.GetBmpHeight() / 36;
|
||||
}
|
||||
|
||||
void StepCtrl::mouseDown(wxMouseEvent &event)
|
||||
|
|
@ -141,7 +141,7 @@ void StepCtrl::mouseDown(wxMouseEvent &event)
|
|||
int itemWidth = size.x / steps.size();
|
||||
wxRect rcBar = {0, (size.y - 60) / 2, size.x, 60};
|
||||
int circleX = itemWidth / 2 + itemWidth * step;
|
||||
wxRect rcThumb = {{circleX, size.y / 2}, bmp_thumb.GetSize()};
|
||||
wxRect rcThumb = {{circleX, size.y / 2}, bmp_thumb.GetBmpSize()};
|
||||
rcThumb.x -= rcThumb.width / 2;
|
||||
rcThumb.y -= rcThumb.height / 2;
|
||||
if (rcThumb.Contains(pt)) {
|
||||
|
|
@ -235,8 +235,8 @@ void StepCtrl::doRender(wxDC &dc)
|
|||
dc.SetTextForeground(clr_tip.colorForStates(states));
|
||||
wxSize sz = dc.GetTextExtent(tips[i]);
|
||||
dc.DrawText(tips[i], circleX - sz.x / 2, circleY - 20 - sz.y);
|
||||
sz = bmp_thumb.GetSize();
|
||||
dc.DrawBitmap(bmp_thumb.get_bitmap(), circleX - sz.x / 2, circleY - sz.y / 2);
|
||||
sz = bmp_thumb.GetBmpSize();
|
||||
dc.DrawBitmap(bmp_thumb.bmp(), circleX - sz.x / 2, circleY - sz.y / 2);
|
||||
}
|
||||
circleX += itemWidth;
|
||||
}
|
||||
|
|
@ -260,16 +260,16 @@ StepIndicator::StepIndicator(wxWindow *parent, wxWindowID id, const wxPoint &pos
|
|||
std::make_pair(0x6B6B6B, 0));
|
||||
clr_tip = *wxWHITE;
|
||||
StaticBox::border_width = 0;
|
||||
radius = bmp_ok.GetHeight() / 2;
|
||||
bar_width = bmp_ok.GetHeight() / 20;
|
||||
radius = bmp_ok.GetBmpHeight() / 2;
|
||||
bar_width = bmp_ok.GetBmpHeight() / 20;
|
||||
if (bar_width < 2) bar_width = 2;
|
||||
}
|
||||
|
||||
void StepIndicator::Rescale()
|
||||
{
|
||||
bmp_ok.sys_color_changed();
|
||||
radius = bmp_ok.GetHeight() / 2;
|
||||
bar_width = bmp_ok.GetHeight() / 20;
|
||||
bmp_ok.msw_rescale();
|
||||
radius = bmp_ok.GetBmpHeight() / 2;
|
||||
bar_width = bmp_ok.GetBmpHeight() / 20;
|
||||
if (bar_width < 2) bar_width = 2;
|
||||
}
|
||||
|
||||
|
|
@ -319,8 +319,8 @@ void StepIndicator::doRender(wxDC &dc)
|
|||
dc.DrawEllipse(circleX - radius, circleY - radius, radius * 2, radius * 2);
|
||||
// Draw content ( icon or text ) in circle
|
||||
if (disabled) {
|
||||
wxSize sz = bmp_ok.GetSize();
|
||||
dc.DrawBitmap(bmp_ok.get_bitmap(), circleX - radius, circleY - radius);
|
||||
wxSize sz = bmp_ok.GetBmpSize();
|
||||
dc.DrawBitmap(bmp_ok.bmp(), circleX - radius, circleY - radius);
|
||||
} else {
|
||||
dc.SetFont(font_tip);
|
||||
dc.SetTextForeground(clr_tip.colorForStates(states));
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
SwitchButton::SwitchButton(wxWindow* parent, wxWindowID id)
|
||||
: wxBitmapToggleButton(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxBU_EXACTFIT)
|
||||
, m_on(this, "toggle_on", {28, 16})
|
||||
, m_off(this, "toggle_off", {28, 16})
|
||||
, m_on(this, "toggle_on", 16)
|
||||
, m_off(this, "toggle_off", 16)
|
||||
, text_color(std::pair{0xfffffe, (int) StateColor::Checked}, std::pair{0x6B6B6B, (int) StateColor::Normal})
|
||||
, track_color(0xD9D9D9)
|
||||
, thumb_color(std::pair{0x009688, (int) StateColor::Checked}, std::pair{0xD9D9D9, (int) StateColor::Normal})
|
||||
|
|
@ -58,8 +58,8 @@ void SwitchButton::SetValue(bool value)
|
|||
void SwitchButton::Rescale()
|
||||
{
|
||||
if (labels[0].IsEmpty()) {
|
||||
m_on.sys_color_changed();
|
||||
m_off.sys_color_changed();
|
||||
m_on.msw_rescale();
|
||||
m_off.msw_rescale();
|
||||
}
|
||||
else {
|
||||
SetBackgroundColour(StaticBox::GetParentBackgroundColor(GetParent()));
|
||||
|
|
@ -101,8 +101,7 @@ void SwitchButton::Rescale()
|
|||
for (int i = 0; i < 2; ++i) {
|
||||
wxMemoryDC memdc(&dc);
|
||||
#ifdef __WXMSW__
|
||||
wxBitmap bmp;
|
||||
bmp.CreateWithDIPSize(ToDIP(trackSize), GetDPIScaleFactor());
|
||||
wxBitmap bmp(trackSize.x, trackSize.y);
|
||||
memdc.SelectObject(bmp);
|
||||
memdc.SetBackground(wxBrush(GetBackgroundColour()));
|
||||
memdc.Clear();
|
||||
|
|
@ -139,12 +138,11 @@ void SwitchButton::Rescale()
|
|||
(i == 0 ? m_off : m_on).bmp() = bmp;
|
||||
}
|
||||
}
|
||||
SetSize(m_on.GetSize());
|
||||
SetSize(m_on.GetBmpSize());
|
||||
update();
|
||||
}
|
||||
|
||||
void SwitchButton::update()
|
||||
{
|
||||
SetBitmap((GetValue() ? m_on : m_off).bmp());
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,9 @@ TabCtrl::TabCtrl(wxWindow * parent,
|
|||
}
|
||||
|
||||
TabCtrl::~TabCtrl()
|
||||
{}
|
||||
{
|
||||
delete images;
|
||||
}
|
||||
|
||||
int TabCtrl::GetSelection() const { return sel; }
|
||||
|
||||
|
|
@ -165,6 +167,13 @@ void TabCtrl::SetItemData(unsigned int item, void* clientData)
|
|||
btns[item]->SetClientData(clientData);
|
||||
}
|
||||
|
||||
void TabCtrl::AssignImageList(wxImageList* imageList)
|
||||
{
|
||||
if (images == imageList) return;
|
||||
delete images;
|
||||
images = imageList;
|
||||
}
|
||||
|
||||
void TabCtrl::SetItemTextColour(unsigned int item, const StateColor &col)
|
||||
{
|
||||
if (item >= btns.size()) return;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ wxDECLARE_EVENT( wxEVT_TAB_SEL_CHANGED, wxCommandEvent );
|
|||
class TabCtrl : public StaticBox
|
||||
{
|
||||
std::vector<Button*> btns;
|
||||
wxImageList* images = nullptr;
|
||||
wxBoxSizer * sizer = nullptr;
|
||||
|
||||
int sel = -1;
|
||||
|
|
@ -51,6 +52,8 @@ public:
|
|||
|
||||
void* GetItemData(unsigned int item) const;
|
||||
void SetItemData(unsigned int item, void *clientData);
|
||||
|
||||
void AssignImageList(wxImageList *imageList);
|
||||
|
||||
void SetItemTextColour(unsigned int item, const StateColor& col);
|
||||
|
||||
|
|
|
|||
|
|
@ -280,10 +280,8 @@ void TempInput::SetLabelColor(StateColor const &color)
|
|||
|
||||
void TempInput::Rescale()
|
||||
{
|
||||
if (this->normal_icon.bmp().IsOk())
|
||||
this->normal_icon.sys_color_changed();
|
||||
if (this->degree_icon.bmp().IsOk())
|
||||
this->degree_icon.sys_color_changed();
|
||||
if (this->normal_icon.bmp().IsOk()) this->normal_icon.msw_rescale();
|
||||
if (this->degree_icon.bmp().IsOk()) this->degree_icon.msw_rescale();
|
||||
messureSize();
|
||||
}
|
||||
|
||||
|
|
@ -319,7 +317,7 @@ void TempInput::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||
auto left = padding_left;
|
||||
wxClientDC dc(this);
|
||||
if (normal_icon.bmp().IsOk()) {
|
||||
wxSize szIcon = normal_icon.GetSize();
|
||||
wxSize szIcon = normal_icon.GetBmpSize();
|
||||
left += szIcon.x;
|
||||
}
|
||||
|
||||
|
|
@ -381,18 +379,18 @@ void TempInput::render(wxDC &dc)
|
|||
// start draw
|
||||
wxPoint pt = {padding_left, 0};
|
||||
if (actice_icon.bmp().IsOk() && actice) {
|
||||
wxSize szIcon = actice_icon.GetSize();
|
||||
wxSize szIcon = actice_icon.GetBmpSize();
|
||||
pt.y = (size.y - szIcon.y) / 2;
|
||||
dc.DrawBitmap(actice_icon.get_bitmap(), pt);
|
||||
dc.DrawBitmap(actice_icon.bmp(), pt);
|
||||
pt.x += szIcon.x + 9;
|
||||
} else {
|
||||
actice = false;
|
||||
}
|
||||
|
||||
if (normal_icon.bmp().IsOk() && !actice) {
|
||||
wxSize szIcon = normal_icon.GetSize();
|
||||
wxSize szIcon = normal_icon.GetBmpSize();
|
||||
pt.y = (size.y - szIcon.y) / 2;
|
||||
dc.DrawBitmap(normal_icon.get_bitmap(), pt);
|
||||
dc.DrawBitmap(normal_icon.bmp(), pt);
|
||||
pt.x += szIcon.x + 9;
|
||||
}
|
||||
|
||||
|
|
@ -437,10 +435,10 @@ void TempInput::render(wxDC &dc)
|
|||
// flag
|
||||
if (degree_icon.bmp().IsOk()) {
|
||||
auto pos = text_ctrl->GetPosition();
|
||||
wxSize szIcon = degree_icon.GetSize();
|
||||
wxSize szIcon = degree_icon.GetBmpSize();
|
||||
pt.y = (size.y - szIcon.y) / 2;
|
||||
pt.x = pos.x + text_ctrl->GetSize().x;
|
||||
dc.DrawBitmap(degree_icon.get_bitmap(), pt);
|
||||
dc.DrawBitmap(degree_icon.bmp(), pt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -454,7 +452,7 @@ void TempInput::messureMiniSize()
|
|||
|
||||
wxClientDC dc(this);
|
||||
if (normal_icon.bmp().IsOk()) {
|
||||
wxSize szIcon = normal_icon.GetSize();
|
||||
wxSize szIcon = normal_icon.GetBmpSize();
|
||||
width += szIcon.x;
|
||||
height = szIcon.y;
|
||||
}
|
||||
|
|
@ -483,7 +481,7 @@ void TempInput::messureMiniSize()
|
|||
height = textSize.y > height ? textSize.y : height;
|
||||
|
||||
// flag flag
|
||||
auto flagSize = degree_icon.GetSize();
|
||||
auto flagSize = degree_icon.GetBmpSize();
|
||||
width += flagSize.x;
|
||||
height = flagSize.y > height ? flagSize.y : height;
|
||||
|
||||
|
|
@ -508,7 +506,7 @@ void TempInput::messureSize()
|
|||
|
||||
wxClientDC dc(this);
|
||||
if (normal_icon.bmp().IsOk()) {
|
||||
wxSize szIcon = normal_icon.GetSize();
|
||||
wxSize szIcon = normal_icon.GetBmpSize();
|
||||
width += szIcon.x;
|
||||
height = szIcon.y;
|
||||
}
|
||||
|
|
@ -537,7 +535,7 @@ void TempInput::messureSize()
|
|||
height = textSize.y > height ? textSize.y : height;
|
||||
|
||||
// flag flag
|
||||
auto flagSize = degree_icon.GetSize();
|
||||
auto flagSize = degree_icon.GetBmpSize();
|
||||
width += flagSize.x;
|
||||
height = flagSize.y > height ? flagSize.y : height;
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ void TextInput::Create(wxWindow * parent,
|
|||
});
|
||||
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu
|
||||
if (!icon.IsEmpty()) {
|
||||
this->drop_down_icon = ScalableBitmap(this, icon.ToStdString(), 16);
|
||||
this->icon = ScalableBitmap(this, icon.ToStdString(), 16);
|
||||
}
|
||||
messureSize();
|
||||
}
|
||||
|
|
@ -94,9 +94,11 @@ void TextInput::SetLabel(const wxString& label)
|
|||
Refresh();
|
||||
}
|
||||
|
||||
void TextInput::SetIcon(const wxBitmapBundle &icon_in)
|
||||
void TextInput::SetIcon(const wxBitmap &icon)
|
||||
{
|
||||
icon = icon_in;
|
||||
this->icon = ScalableBitmap();
|
||||
this->icon.bmp() = icon;
|
||||
Rescale();
|
||||
}
|
||||
|
||||
void TextInput::SetLabelColor(StateColor const &color)
|
||||
|
|
@ -113,9 +115,8 @@ void TextInput::SetTextColor(StateColor const& color)
|
|||
|
||||
void TextInput::Rescale()
|
||||
{
|
||||
if (text_ctrl)
|
||||
text_ctrl->SetInitialSize(text_ctrl->GetBestSize());
|
||||
|
||||
if (!this->icon.name().empty())
|
||||
this->icon.msw_rescale();
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
|
@ -151,22 +152,16 @@ void TextInput::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||
if (sizeFlags & wxSIZE_USE_EXISTING) return;
|
||||
wxSize size = GetSize();
|
||||
wxPoint textPos = {5, 0};
|
||||
if (this->icon.IsOk()) {
|
||||
wxSize szIcon = get_preferred_size(icon, m_parent);
|
||||
if (this->icon.bmp().IsOk()) {
|
||||
wxSize szIcon = this->icon.GetBmpSize();
|
||||
textPos.x += szIcon.x;
|
||||
}
|
||||
wxSize dd_icon_size = wxSize(0,0);
|
||||
if (this->drop_down_icon.bmp().IsOk())
|
||||
dd_icon_size = this->drop_down_icon.GetSize();
|
||||
|
||||
bool align_right = GetWindowStyle() & wxRIGHT;
|
||||
if (align_right)
|
||||
textPos.x += labelSize.x;
|
||||
if (text_ctrl) {
|
||||
wxSize textSize = text_ctrl->GetSize();
|
||||
wxClientDC dc(this);
|
||||
const int r_shift = int((dd_icon_size.x == 0 ? 3. : 2.) * dc.GetContentScaleFactor());
|
||||
textSize.x = size.x - textPos.x - labelSize.x - dd_icon_size.x - r_shift;
|
||||
textSize.x = size.x - textPos.x - labelSize.x - 10;
|
||||
text_ctrl->SetSize(textSize);
|
||||
text_ctrl->SetPosition({textPos.x, (size.y - textSize.y) / 2});
|
||||
}
|
||||
|
|
@ -198,26 +193,12 @@ void TextInput::render(wxDC& dc)
|
|||
bool align_right = GetWindowStyle() & wxRIGHT;
|
||||
// start draw
|
||||
wxPoint pt = {5, 0};
|
||||
if (icon.IsOk()) {
|
||||
wxSize szIcon = get_preferred_size(icon, m_parent);
|
||||
if (icon.bmp().IsOk()) {
|
||||
wxSize szIcon = icon.GetBmpSize();
|
||||
pt.y = (size.y - szIcon.y) / 2;
|
||||
#ifdef __WXGTK3__
|
||||
dc.DrawBitmap(icon.GetBitmap(szIcon), pt);
|
||||
#else
|
||||
dc.DrawBitmap(icon.GetBitmapFor(m_parent), pt);
|
||||
#endif
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
pt.x += szIcon.x + 0;
|
||||
}
|
||||
|
||||
// drop_down_icon draw
|
||||
wxPoint pt_r = {size.x, 0};
|
||||
if (drop_down_icon.bmp().IsOk()) {
|
||||
wxSize szIcon = drop_down_icon.GetSize();
|
||||
pt_r.x -= szIcon.x + 2;
|
||||
pt_r.y = (size.y - szIcon.y) / 2;
|
||||
dc.DrawBitmap(drop_down_icon.get_bitmap(), pt_r);
|
||||
}
|
||||
|
||||
auto text = wxWindow::GetLabel();
|
||||
if (!text.IsEmpty()) {
|
||||
wxSize textSize = text_ctrl->GetSize();
|
||||
|
|
|
|||
|
|
@ -8,11 +8,10 @@ class TextInput : public wxNavigationEnabled<StaticBox>
|
|||
{
|
||||
|
||||
wxSize labelSize;
|
||||
wxBitmapBundle icon;
|
||||
ScalableBitmap drop_down_icon;
|
||||
ScalableBitmap icon;
|
||||
StateColor label_color;
|
||||
StateColor text_color;
|
||||
wxTextCtrl* text_ctrl{nullptr};
|
||||
wxTextCtrl * text_ctrl;
|
||||
|
||||
static const int TextInputWidth = 200;
|
||||
static const int TextInputHeight = 50;
|
||||
|
|
@ -41,7 +40,7 @@ public:
|
|||
|
||||
void SetLabel(const wxString& label);
|
||||
|
||||
virtual void SetIcon(const wxBitmapBundle & icon);
|
||||
void SetIcon(const wxBitmap & icon);
|
||||
|
||||
void SetLabelColor(StateColor const &color);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue