mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-02 15:21:03 -07:00
Update wxWidgets to v3.2.1 (#2905)
* Upgrade wxWidgets to 3.2.1
Based on prusa3d/PrusaSlicer@9a7e024
Co-authored-by: tamasmeszaros <meszaros.q@gmail.com>
* Implement BitmapCache
* update wxExtensions while keeping legacy items
* update dc.DrawBitmap calls to use get_bitmap
* Fix GetSize/Width/Height calls
* update BitmapComboBox
* fix ifndef in wxExtensions.hpp
* update my todos to OcraftyoneTODO
* Get to a compilable state
Everything seems to be working (including the plater). I am not seeing any graphical issues
* fix extruder color icons
* fix crash on opening support tab
* remove GetBmpSize method from DropDown.cpp
* Update TextInput to use bitmap bundles
* update a TODO after testing
* fix the rendering of the icons on combobox
* fix a few todos
* fix WipeTowerDialog.cpp
* Overhaul WipeTowerDialog
Removed simple version of the dialog since BBS removed the functionality but left the code.
Center the table (only seen when the table is smaller than the minimum size of the dialog)
Fix issue where editing a value causes the m_min_flush_label to change colors slightly
Fix an issue where changing a value or running an auto calc changes the disabled value from "-" to "0"
* update a few todos
* Update some todos
* Show dropdown when editing is started
* Update NanoSVG.cmake
Update NanoSVG to work with PR #2780
* Dim the icon on ComboBox when disabled
* solve ObjectDataViewModel todos
leaving colPrint and colEditing cases alone as it does not seem to impact anything
* Update names in wxExtensions
-Rename msw_rescale to sys_color_changed
-Replace GetBmpSize, GetBmpWidth, GetBmpHeight with renamed version (same name without "Bmp")
Both of these changes were also made by PrusaSlicer.
Original Commit: Prusa3D/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>
* update BitmapCache::from_svg
disable finding bundle in the cache to match load_svg
update to match values used in load_svg
* Update ScalableButton
change the signature and remove functions/vars pertaining to a default bmp
fix TODOs in ScalableButton
Original Commit: Prusa3D/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>
* fix up some more todos in wxExtensions
* update ScalableBitmap to use bmp bundles
use wxBitmapBundle by default
add flag to use old scaled bitmap function (specifically to solve issue with advanced toggle)
* attempt to fix macos deps build
* fix ubuntu build
* Revert "attempt to fix macos deps build"
Mistakenly made change to wrong file
This reverts commit d9c20b5121.
* update wxWidgets patch
an attempt to fix macOS build
* Remove duplicate variable from OrcaSlicer.cpp
* Fix macOS build issue
* Fix blank DataViewItem being added to objects list
* Filament ComboBox editor updates
-Add show drop down feature to ObjectTable
-Call finish editing when ComboBox is closed in ObjectList
* remove Apple specific declarations missed during refactor
* delete old wxWidgets patch
* fix ubuntu seg fault
* include patch from #2926
* update patch to include wxWidgets/wxWidgets@991a74c
* fix deps not compiling on Windows
* update WipeTowerDialog
relocates the recalculate button back to its previous position
changes the wording of the tip message label
add spacing below the matrix
* finish patching wxWidgets
from prusa3d/PrusaSlicer@f8477d1 and prusa3d/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>
* fix combobox crash
* revert outside plate changes
---------
Co-authored-by: tamasmeszaros <meszaros.q@gmail.com>
Co-authored-by: YuSanka <yusanka@gmail.com>
This commit is contained in:
parent
0bf65aa217
commit
25a055491e
98 changed files with 1639 additions and 6221 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.GetBmpSize().x) / 2, (size.y - m_bitmap_selected.GetBmpSize().y) / 2);
|
||||
auto pot = wxPoint((size.x - m_bitmap_selected.GetSize().x) / 2, (size.y - m_bitmap_selected.GetSize().y) / 2);
|
||||
|
||||
if (!m_disable_mode) {
|
||||
if (!m_play_loading) {
|
||||
dc.DrawBitmap(m_selected ? m_bitmap_selected.bmp() : m_bitmap_normal.bmp(), pot);
|
||||
dc.DrawBitmap(m_selected ? m_bitmap_selected.get_bitmap() : m_bitmap_normal.get_bitmap(), 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].bmp(), pot);
|
||||
dc.DrawBitmap(m_rfid_bitmap_list[m_rotation_angle].get_bitmap(), 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.bmp(), wxPoint((size.x - m_ams_extruder.GetBmpSize().x) / 2, (size.y - m_ams_extruder.GetBmpSize().y) / 2));
|
||||
dc.DrawBitmap(m_ams_extruder.get_bitmap(), wxPoint((size.x - m_ams_extruder.GetSize().x) / 2, (size.y - m_ams_extruder.GetSize().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.GetBmpSize().y);
|
||||
top = (size.y - FromDIP(15) - m_bitmap_editable_light.GetSize().y);
|
||||
bottom = size.y - FromDIP(15);
|
||||
}
|
||||
else if (m_ams_model == AMSModel::EXTRA_AMS) {
|
||||
top = (size.y - FromDIP(20) - m_bitmap_editable_light.GetBmpSize().y);
|
||||
top = (size.y - FromDIP(20) - m_bitmap_editable_light.GetSize().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.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_third.GetBmpSize().y));
|
||||
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));
|
||||
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND)
|
||||
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));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
// selected & hover
|
||||
if (m_selected) {
|
||||
dc.DrawBitmap(tray_bitmap_selected.bmp(), (size.x - tray_bitmap_selected.GetBmpSize().x) / 2, (size.y - tray_bitmap_selected.GetBmpSize().y) / 2);
|
||||
dc.DrawBitmap(tray_bitmap_selected.get_bitmap(), (size.x - tray_bitmap_selected.GetSize().x) / 2, (size.y - tray_bitmap_selected.GetSize().y) / 2);
|
||||
}
|
||||
else if (!m_selected && m_hover) {
|
||||
dc.DrawBitmap(tray_bitmap_hover.bmp(), (size.x - tray_bitmap_hover.GetBmpSize().x) / 2, (size.y - tray_bitmap_hover.GetBmpSize().y) / 2);
|
||||
dc.DrawBitmap(tray_bitmap_hover.get_bitmap(), (size.x - tray_bitmap_hover.GetSize().x) / 2, (size.y - tray_bitmap_hover.GetSize().y) / 2);
|
||||
}
|
||||
else {
|
||||
dc.DrawBitmap(tray_bitmap.bmp(), (size.x - tray_bitmap.GetBmpSize().x) / 2, (size.y - tray_bitmap.GetBmpSize().y) / 2);
|
||||
dc.DrawBitmap(tray_bitmap.get_bitmap(), (size.x - tray_bitmap.GetSize().x) / 2, (size.y - tray_bitmap.GetSize().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.bmp(), FromDIP(4), FromDIP(4));
|
||||
dc.DrawBitmap(m_bitmap_transparent.get_bitmap(), 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.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetBmpSize().y));
|
||||
dc.DrawBitmap(temp_bitmap_third.get_bitmap(), (size.x - temp_bitmap_third.GetSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetSize().y));
|
||||
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND)
|
||||
dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetBmpSize().y));
|
||||
dc.DrawBitmap(temp_bitmap_brand.get_bitmap(), (size.x - temp_bitmap_brand.GetSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetSize().y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1244,8 +1244,7 @@ void AMSLib::UnSelected()
|
|||
bool AMSLib::Enable(bool enable) { return wxWindow::Enable(enable); }
|
||||
|
||||
void AMSLib::msw_rescale()
|
||||
{
|
||||
m_bitmap_transparent.msw_rescale();
|
||||
{ m_bitmap_transparent.sys_color_changed();
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
|
|
@ -1452,20 +1451,20 @@ void AMSRoad::doRender(wxDC &dc)
|
|||
else {m_show_humidity = false;}
|
||||
|
||||
if (m_amsinfo.ams_humidity == 5) {
|
||||
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)));
|
||||
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)));
|
||||
}
|
||||
else if (m_amsinfo.ams_humidity == 4) {
|
||||
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)));
|
||||
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)));
|
||||
}
|
||||
else if (m_amsinfo.ams_humidity == 3) {
|
||||
|
||||
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)));
|
||||
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)));
|
||||
}
|
||||
else if (m_amsinfo.ams_humidity == 2) {
|
||||
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)));
|
||||
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)));
|
||||
}
|
||||
else if (m_amsinfo.ams_humidity == 1) {
|
||||
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)));
|
||||
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)));
|
||||
}
|
||||
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)));*/
|
||||
|
|
@ -1662,7 +1661,7 @@ void AMSItem::doRender(wxDC &dc)
|
|||
|
||||
}else {
|
||||
if (iter->material_colour.Alpha() == 0) {
|
||||
dc.DrawBitmap(m_ts_bitmap_cube->bmp(),left,(size.y - AMS_ITEM_CUBE_SIZE.y) / 2);
|
||||
dc.DrawBitmap(m_ts_bitmap_cube->get_bitmap(),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);
|
||||
|
|
@ -2092,7 +2091,7 @@ void AmsCans::render(wxDC& dc)
|
|||
void AmsCans::doRender(wxDC& dc)
|
||||
{
|
||||
wxSize size = GetSize();
|
||||
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);
|
||||
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);
|
||||
|
||||
//road for extra
|
||||
if (m_ams_model == AMSModel::EXTRA_AMS) {
|
||||
|
|
@ -2982,9 +2981,9 @@ void AMSControl::StopRridLoading(wxString amsid, wxString canid)
|
|||
|
||||
void AMSControl::msw_rescale()
|
||||
{
|
||||
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_normal.sys_color_changed();
|
||||
m_button_ams_setting_hover.sys_color_changed();
|
||||
m_button_ams_setting_press.sys_color_changed();
|
||||
m_button_ams_setting->SetBitmap(m_button_ams_setting_normal.bmp());
|
||||
|
||||
m_extruder->msw_rescale();
|
||||
|
|
|
|||
|
|
@ -212,7 +212,8 @@ void AxisCtrlButton::render(wxDC& dc)
|
|||
gc->DrawPath(home_path);
|
||||
|
||||
if (m_icon.bmp().IsOk()) {
|
||||
gc->DrawBitmap(m_icon.bmp(), -1 * m_icon.GetBmpWidth() / 2, -1 * m_icon.GetBmpHeight() / 2, m_icon.GetBmpWidth(), m_icon.GetBmpHeight());
|
||||
gc->DrawBitmap(m_icon.get_bitmap(), -1 * m_icon.GetWidth() / 2, -1 * m_icon.GetHeight() / 2, m_icon.GetWidth(),
|
||||
m_icon.GetHeight());
|
||||
}
|
||||
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.msw_rescale();
|
||||
this->active_icon.sys_color_changed();
|
||||
|
||||
if (this->inactive_icon.bmp().IsOk())
|
||||
this->inactive_icon.msw_rescale();
|
||||
this->inactive_icon.sys_color_changed();
|
||||
|
||||
messureSize();
|
||||
}
|
||||
|
|
@ -187,7 +187,7 @@ void Button::render(wxDC& dc)
|
|||
//BBS norrow size between text and icon
|
||||
szContent.x += padding;
|
||||
}
|
||||
szIcon = icon.GetBmpSize();
|
||||
szIcon = icon.GetSize();
|
||||
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.bmp(), pt);
|
||||
dc.DrawBitmap(icon.get_bitmap(), 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.GetBmpSize();
|
||||
wxSize szIcon = this->active_icon.GetSize();
|
||||
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.GetBmpSize());
|
||||
SetMinSize(m_on.GetBmpSize());
|
||||
SetSize(m_on.GetSize());
|
||||
SetMinSize(m_on.GetSize());
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
@ -43,16 +43,16 @@ void CheckBox::SetHalfChecked(bool value)
|
|||
|
||||
void CheckBox::Rescale()
|
||||
{
|
||||
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());
|
||||
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());
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,6 +98,13 @@ 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();
|
||||
|
|
@ -145,13 +152,17 @@ bool ComboBox::SetFont(wxFont const& font)
|
|||
return TextInput::SetFont(font);
|
||||
}
|
||||
|
||||
int ComboBox::Append(const wxString &item, const wxBitmap &bitmap)
|
||||
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)
|
||||
{
|
||||
return Append(item, bitmap, nullptr);
|
||||
}
|
||||
|
||||
int ComboBox::Append(const wxString &item,
|
||||
const wxBitmap &bitmap,
|
||||
const wxBitmapBundle &bitmap,
|
||||
void * clientData)
|
||||
{
|
||||
texts.push_back(item);
|
||||
|
|
@ -196,9 +207,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]; }
|
||||
wxBitmap ComboBox::GetItemBitmap(unsigned int n) { return icons[n].GetBitmapFor(m_parent); }
|
||||
|
||||
void ComboBox::SetItemBitmap(unsigned int n, wxBitmap const &bitmap)
|
||||
void ComboBox::SetItemBitmap(unsigned int n, wxBitmapBundle const &bitmap)
|
||||
{
|
||||
if (n >= texts.size()) return;
|
||||
icons[n] = bitmap;
|
||||
|
|
@ -230,9 +241,7 @@ void ComboBox::DoSetItemClientData(unsigned int n, void *data)
|
|||
datas[n] = data;
|
||||
}
|
||||
|
||||
void ComboBox::mouseDown(wxMouseEvent &event)
|
||||
{
|
||||
SetFocus();
|
||||
void ComboBox::ToggleDropDown(){
|
||||
if (drop_down) {
|
||||
drop.Hide();
|
||||
} else if (drop.HasDismissLongTime()) {
|
||||
|
|
@ -244,6 +253,12 @@ void ComboBox::mouseDown(wxMouseEvent &event)
|
|||
}
|
||||
}
|
||||
|
||||
void ComboBox::mouseDown(wxMouseEvent &event)
|
||||
{
|
||||
SetFocus();
|
||||
ToggleDropDown();
|
||||
}
|
||||
|
||||
void ComboBox::mouseWheelMoved(wxMouseEvent &event)
|
||||
{
|
||||
event.Skip();
|
||||
|
|
@ -261,15 +276,7 @@ void ComboBox::keyDown(wxKeyEvent& event)
|
|||
switch (event.GetKeyCode()) {
|
||||
case WXK_RETURN:
|
||||
case WXK_SPACE:
|
||||
if (drop_down) {
|
||||
drop.DismissAndNotify();
|
||||
} else if (drop.HasDismissLongTime()) {
|
||||
drop.autoPosition();
|
||||
drop_down = true;
|
||||
drop.Popup();
|
||||
wxCommandEvent e(wxEVT_COMBOBOX_DROPDOWN);
|
||||
GetEventHandler()->ProcessEvent(e);
|
||||
}
|
||||
ToggleDropDown();
|
||||
break;
|
||||
case WXK_UP:
|
||||
case WXK_DOWN:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
class ComboBox : public wxWindowWithItems<TextInput, wxItemContainer>
|
||||
{
|
||||
std::vector<wxString> texts;
|
||||
std::vector<wxBitmap> icons;
|
||||
std::vector<wxBitmapBundle> icons;
|
||||
std::vector<void *> datas;
|
||||
std::vector<wxClientDataType> types;
|
||||
|
||||
|
|
@ -32,10 +32,9 @@ public:
|
|||
|
||||
virtual bool SetFont(wxFont const & font) override;
|
||||
|
||||
public:
|
||||
int Append(const wxString &item, const wxBitmap &bitmap = wxNullBitmap);
|
||||
int Append(const wxString &item, const wxBitmapBundle &bitmap = wxNullBitmap);
|
||||
|
||||
int Append(const wxString &item, const wxBitmap &bitmap, void *clientData);
|
||||
int Append(const wxString &item, const wxBitmapBundle &bitmap, void *clientData);
|
||||
|
||||
unsigned int GetCount() const override;
|
||||
|
||||
|
|
@ -60,7 +59,11 @@ public:
|
|||
void SetString(unsigned int n, wxString const &value) override;
|
||||
|
||||
wxBitmap GetItemBitmap(unsigned int n);
|
||||
void SetItemBitmap(unsigned int n, wxBitmap const &bitmap);
|
||||
void SetItemBitmap(unsigned int n, wxBitmapBundle const &bitmap);
|
||||
|
||||
void ToggleDropDown();
|
||||
bool Enable(bool enable = true) override;
|
||||
void SetIcon(const wxBitmapBundle &icon) override;
|
||||
|
||||
protected:
|
||||
virtual int DoInsertItems(const wxArrayStringsAdapter &items,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ END_EVENT_TABLE()
|
|||
*/
|
||||
|
||||
DropDown::DropDown(std::vector<wxString> &texts,
|
||||
std::vector<wxBitmap> &icons)
|
||||
std::vector<wxBitmapBundle> &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<wxBitmap> &icons,
|
||||
std::vector<wxBitmapBundle> &icons,
|
||||
long style)
|
||||
: DropDown(texts, icons)
|
||||
{
|
||||
|
|
@ -188,15 +188,6 @@ 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
|
||||
|
|
@ -265,13 +256,13 @@ void DropDown::render(wxDC &dc)
|
|||
rcContent.x += 5;
|
||||
rcContent.width -= 5;
|
||||
if (check_bitmap.bmp().IsOk()) {
|
||||
auto szBmp = check_bitmap.GetBmpSize();
|
||||
auto szBmp = check_bitmap.GetSize();
|
||||
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.bmp(), pt);
|
||||
dc.DrawBitmap(check_bitmap.get_bitmap(), pt);
|
||||
}
|
||||
rcContent.x += szBmp.x + 5;
|
||||
rcContent.width -= szBmp.x + 5;
|
||||
|
|
@ -286,17 +277,17 @@ void DropDown::render(wxDC &dc)
|
|||
if (rcContent.y > size.y) break;
|
||||
wxPoint pt = rcContent.GetLeftTop();
|
||||
auto & icon = icons[i];
|
||||
auto size2 = GetBmpSize(icon);
|
||||
auto size2 = get_preferred_size(icon, m_parent);
|
||||
if (iconSize.x > 0) {
|
||||
if (icon.IsOk()) {
|
||||
pt.y += (rcContent.height - size2.y) / 2;
|
||||
dc.DrawBitmap(icon, pt);
|
||||
dc.DrawBitmap(icon.GetBitmapFor(m_parent), pt);
|
||||
}
|
||||
pt.x += iconSize.x + 5;
|
||||
pt.y = rcContent.y;
|
||||
} else if (icon.IsOk()) {
|
||||
pt.y += (rcContent.height - size2.y) / 2;
|
||||
dc.DrawBitmap(icon, pt);
|
||||
dc.DrawBitmap(icon.GetBitmapFor(m_parent), pt);
|
||||
pt.x += size2.x + 5;
|
||||
pt.y = rcContent.y;
|
||||
}
|
||||
|
|
@ -326,7 +317,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 = GetBmpSize(icons[i]);
|
||||
wxSize size2 = get_preferred_size(icons[i], m_parent);
|
||||
if (size2.x > iconSize.x) iconSize = size2;
|
||||
if (!align_icon) {
|
||||
size1.x += size2.x + (text_off ? 0 : 5);
|
||||
|
|
@ -338,7 +329,7 @@ void DropDown::messureSize()
|
|||
wxSize szContent = textSize;
|
||||
szContent.x += 10;
|
||||
if (check_bitmap.bmp().IsOk()) {
|
||||
auto szBmp = check_bitmap.GetBmpSize();
|
||||
auto szBmp = check_bitmap.GetSize();
|
||||
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<wxBitmap> & icons;
|
||||
std::vector<wxBitmapBundle> & 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<wxBitmap> &icons);
|
||||
std::vector<wxBitmapBundle> &icons);
|
||||
|
||||
DropDown(wxWindow * parent,
|
||||
std::vector<wxString> &texts,
|
||||
std::vector<wxBitmap> &icons,
|
||||
std::vector<wxBitmapBundle> &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.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
|
||||
SetMaxSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
|
||||
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)));
|
||||
//#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.bmp(), wxPoint(0,0));
|
||||
dc.DrawBitmap(m_bitmap_bk.get_bitmap(), 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].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);
|
||||
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);
|
||||
|
||||
//fan val
|
||||
dc.SetTextForeground(DRAW_TEXT_COLOUR);
|
||||
|
|
@ -147,8 +147,7 @@ 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.msw_rescale();
|
||||
void Fan::msw_rescale() { m_bitmap_bk.sys_color_changed();
|
||||
}
|
||||
|
||||
void Fan::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
|
|
@ -280,8 +279,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.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);
|
||||
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);
|
||||
|
||||
//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.GetBmpHeight() + textSize.y + m_padding;
|
||||
int content_height = icon.GetHeight() + textSize.y + m_padding;
|
||||
|
||||
wxPoint pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, (size.y - content_height) / 2);
|
||||
wxPoint pt = wxPoint((size.x - icon.GetWidth()) / 2, (size.y - content_height) / 2);
|
||||
if (icon.bmp().IsOk()) {
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
pt.y += m_padding + icon.GetBmpHeight();
|
||||
dc.DrawBitmap(icon.get_bitmap(), pt);
|
||||
pt.y += m_padding + icon.GetHeight();
|
||||
}
|
||||
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.GetBmpWidth()) / 2, (size.y - content_height) / 2);
|
||||
wxPoint pt = wxPoint((size.x - icon.GetWidth()) / 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.GetBmpWidth()) / 2, content_height + textSize.y);
|
||||
pt = wxPoint((size.x - icon.GetWidth()) / 2, content_height + textSize.y);
|
||||
if (icon.bmp().IsOk()) {
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
pt.y += m_padding + icon.GetBmpHeight();
|
||||
dc.DrawBitmap(icon.get_bitmap(), pt);
|
||||
pt.y += m_padding + icon.GetHeight();
|
||||
}
|
||||
|
||||
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.GetBmpSize());
|
||||
SetMinSize(m_on.GetBmpSize());
|
||||
SetSize(m_on.GetSize());
|
||||
SetMinSize(m_on.GetSize());
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
@ -29,9 +29,9 @@ bool RadioBox::GetValue()
|
|||
|
||||
void RadioBox::Rescale()
|
||||
{
|
||||
m_on.msw_rescale();
|
||||
m_off.msw_rescale();
|
||||
SetSize(m_on.GetBmpSize());
|
||||
m_on.sys_color_changed();
|
||||
m_off.sys_color_changed();
|
||||
SetSize(m_on.GetSize());
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ bool SideButton::Enable(bool enable)
|
|||
void SideButton::Rescale()
|
||||
{
|
||||
if (this->icon.bmp().IsOk())
|
||||
this->icon.msw_rescale();
|
||||
this->icon.sys_color_changed();
|
||||
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.GetBmpSize();
|
||||
szIcon = icon.GetSize();
|
||||
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.bmp(), pt);
|
||||
dc.DrawBitmap(icon.get_bitmap(), 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.GetBmpSize();
|
||||
wxSize szIcon = this->icon.GetSize();
|
||||
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.bmp(), left, (size.y - m_none_printing_img.GetBmpSize().y) / 2);
|
||||
dc.DrawBitmap(m_none_printing_img.get_bitmap(), left, (size.y - m_none_printing_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_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_arrow_img.GetBmpSize().x + FromDIP(6));
|
||||
left += (m_none_arrow_img.GetSize().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.GetBmpSize().x - m_none_add_img.GetBmpSize().x;
|
||||
auto left_add_bitmap = size.x - FromDIP(30) - m_wifi_none_img.GetSize().x - m_none_add_img.GetSize().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.GetBmpSize().x;
|
||||
dc.DrawBitmap(m_none_add_img.bmp(), left, (size.y - m_none_add_img.GetBmpSize().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);
|
||||
} else {
|
||||
dc.DrawBitmap(m_printing_img.bmp(), left, (size.y - m_printing_img.GetBmpSize().y) / 2);
|
||||
dc.DrawBitmap(m_printing_img.get_bitmap(), left, (size.y - m_printing_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_printing_img.GetSize().x + FromDIP(5));
|
||||
dc.DrawBitmap(m_arrow_img.get_bitmap(), left, (size.y - m_arrow_img.GetSize().y) / 2);
|
||||
|
||||
left += (m_arrow_img.GetBmpSize().x + FromDIP(6));
|
||||
left += (m_arrow_img.GetSize().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.GetBmpSize().x - 20;
|
||||
auto text_end = size.x - m_wifi_none_img.GetSize().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.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);
|
||||
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);
|
||||
}
|
||||
|
||||
if (m_hover) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void StaticLine::SetLineColour(wxColour color)
|
|||
void StaticLine::Rescale()
|
||||
{
|
||||
if (this->icon.bmp().IsOk())
|
||||
this->icon.msw_rescale();
|
||||
this->icon.sys_color_changed();
|
||||
messureSize();
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ void StaticLine::messureSize()
|
|||
// BBS norrow size between text and icon
|
||||
szContent.x += 5;
|
||||
}
|
||||
wxSize szIcon = this->icon.GetBmpSize();
|
||||
wxSize szIcon = this->icon.GetSize();
|
||||
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.GetBmpHeight(), textSize.GetHeight());
|
||||
int contentWidth = icon.GetBmpWidth() + ((icon.bmp().IsOk() && textSize.GetWidth() > 0) ? 5 : 0) +
|
||||
titleRect.height = wxMax(icon.GetHeight(), textSize.GetHeight());
|
||||
int contentWidth = icon.GetWidth() + ((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.bmp(), {0, (size.y - icon.GetBmpHeight()) / 2});
|
||||
titleRect.x += icon.GetBmpWidth() + 5;
|
||||
dc.DrawBitmap(icon.get_bitmap(), {0, (size.y - icon.GetHeight()) / 2});
|
||||
titleRect.x += icon.GetWidth() + 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.GetBmpHeight() / 36;
|
||||
bar_width = bar_width * bmp_thumb.GetBmpHeight() / 36;
|
||||
radius = radius * bmp_thumb.GetHeight() / 36;
|
||||
bar_width = bar_width * bmp_thumb.GetHeight() / 36;
|
||||
}
|
||||
|
||||
void StepCtrl::Rescale()
|
||||
{
|
||||
bmp_thumb.msw_rescale();
|
||||
radius = radius * bmp_thumb.GetBmpHeight() / 36;
|
||||
bar_width = bar_width * bmp_thumb.GetBmpHeight() / 36;
|
||||
bmp_thumb.sys_color_changed();
|
||||
radius = radius * bmp_thumb.GetHeight() / 36;
|
||||
bar_width = bar_width * bmp_thumb.GetHeight() / 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.GetBmpSize()};
|
||||
wxRect rcThumb = {{circleX, size.y / 2}, bmp_thumb.GetSize()};
|
||||
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.GetBmpSize();
|
||||
dc.DrawBitmap(bmp_thumb.bmp(), circleX - sz.x / 2, circleY - sz.y / 2);
|
||||
sz = bmp_thumb.GetSize();
|
||||
dc.DrawBitmap(bmp_thumb.get_bitmap(), 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.GetBmpHeight() / 2;
|
||||
bar_width = bmp_ok.GetBmpHeight() / 20;
|
||||
radius = bmp_ok.GetHeight() / 2;
|
||||
bar_width = bmp_ok.GetHeight() / 20;
|
||||
if (bar_width < 2) bar_width = 2;
|
||||
}
|
||||
|
||||
void StepIndicator::Rescale()
|
||||
{
|
||||
bmp_ok.msw_rescale();
|
||||
radius = bmp_ok.GetBmpHeight() / 2;
|
||||
bar_width = bmp_ok.GetBmpHeight() / 20;
|
||||
bmp_ok.sys_color_changed();
|
||||
radius = bmp_ok.GetHeight() / 2;
|
||||
bar_width = bmp_ok.GetHeight() / 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.GetBmpSize();
|
||||
dc.DrawBitmap(bmp_ok.bmp(), circleX - radius, circleY - radius);
|
||||
wxSize sz = bmp_ok.GetSize();
|
||||
dc.DrawBitmap(bmp_ok.get_bitmap(), 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", 16)
|
||||
, m_off(this, "toggle_off", 16)
|
||||
, m_on(this, "toggle_on", 16, false, false, true)
|
||||
, m_off(this, "toggle_off", 16, false, false, true)
|
||||
, 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.msw_rescale();
|
||||
m_off.msw_rescale();
|
||||
m_on.sys_color_changed();
|
||||
m_off.sys_color_changed();
|
||||
}
|
||||
else {
|
||||
SetBackgroundColour(StaticBox::GetParentBackgroundColor(GetParent()));
|
||||
|
|
@ -138,7 +138,7 @@ void SwitchButton::Rescale()
|
|||
(i == 0 ? m_off : m_on).bmp() = bmp;
|
||||
}
|
||||
}
|
||||
SetSize(m_on.GetBmpSize());
|
||||
SetSize(m_on.GetSize());
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,9 +43,7 @@ TabCtrl::TabCtrl(wxWindow * parent,
|
|||
}
|
||||
|
||||
TabCtrl::~TabCtrl()
|
||||
{
|
||||
delete images;
|
||||
}
|
||||
{}
|
||||
|
||||
int TabCtrl::GetSelection() const { return sel; }
|
||||
|
||||
|
|
@ -167,13 +165,6 @@ 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,7 +9,6 @@ wxDECLARE_EVENT( wxEVT_TAB_SEL_CHANGED, wxCommandEvent );
|
|||
class TabCtrl : public StaticBox
|
||||
{
|
||||
std::vector<Button*> btns;
|
||||
wxImageList* images = nullptr;
|
||||
wxBoxSizer * sizer = nullptr;
|
||||
|
||||
int sel = -1;
|
||||
|
|
@ -52,8 +51,6 @@ 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,8 +280,10 @@ void TempInput::SetLabelColor(StateColor const &color)
|
|||
|
||||
void TempInput::Rescale()
|
||||
{
|
||||
if (this->normal_icon.bmp().IsOk()) this->normal_icon.msw_rescale();
|
||||
if (this->degree_icon.bmp().IsOk()) this->degree_icon.msw_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();
|
||||
messureSize();
|
||||
}
|
||||
|
||||
|
|
@ -317,7 +319,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.GetBmpSize();
|
||||
wxSize szIcon = normal_icon.GetSize();
|
||||
left += szIcon.x;
|
||||
}
|
||||
|
||||
|
|
@ -379,18 +381,18 @@ void TempInput::render(wxDC &dc)
|
|||
// start draw
|
||||
wxPoint pt = {padding_left, 0};
|
||||
if (actice_icon.bmp().IsOk() && actice) {
|
||||
wxSize szIcon = actice_icon.GetBmpSize();
|
||||
wxSize szIcon = actice_icon.GetSize();
|
||||
pt.y = (size.y - szIcon.y) / 2;
|
||||
dc.DrawBitmap(actice_icon.bmp(), pt);
|
||||
dc.DrawBitmap(actice_icon.get_bitmap(), pt);
|
||||
pt.x += szIcon.x + 9;
|
||||
} else {
|
||||
actice = false;
|
||||
}
|
||||
|
||||
if (normal_icon.bmp().IsOk() && !actice) {
|
||||
wxSize szIcon = normal_icon.GetBmpSize();
|
||||
wxSize szIcon = normal_icon.GetSize();
|
||||
pt.y = (size.y - szIcon.y) / 2;
|
||||
dc.DrawBitmap(normal_icon.bmp(), pt);
|
||||
dc.DrawBitmap(normal_icon.get_bitmap(), pt);
|
||||
pt.x += szIcon.x + 9;
|
||||
}
|
||||
|
||||
|
|
@ -435,10 +437,10 @@ void TempInput::render(wxDC &dc)
|
|||
// flag
|
||||
if (degree_icon.bmp().IsOk()) {
|
||||
auto pos = text_ctrl->GetPosition();
|
||||
wxSize szIcon = degree_icon.GetBmpSize();
|
||||
wxSize szIcon = degree_icon.GetSize();
|
||||
pt.y = (size.y - szIcon.y) / 2;
|
||||
pt.x = pos.x + text_ctrl->GetSize().x;
|
||||
dc.DrawBitmap(degree_icon.bmp(), pt);
|
||||
dc.DrawBitmap(degree_icon.get_bitmap(), pt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -452,7 +454,7 @@ void TempInput::messureMiniSize()
|
|||
|
||||
wxClientDC dc(this);
|
||||
if (normal_icon.bmp().IsOk()) {
|
||||
wxSize szIcon = normal_icon.GetBmpSize();
|
||||
wxSize szIcon = normal_icon.GetSize();
|
||||
width += szIcon.x;
|
||||
height = szIcon.y;
|
||||
}
|
||||
|
|
@ -481,7 +483,7 @@ void TempInput::messureMiniSize()
|
|||
height = textSize.y > height ? textSize.y : height;
|
||||
|
||||
// flag flag
|
||||
auto flagSize = degree_icon.GetBmpSize();
|
||||
auto flagSize = degree_icon.GetSize();
|
||||
width += flagSize.x;
|
||||
height = flagSize.y > height ? flagSize.y : height;
|
||||
|
||||
|
|
@ -506,7 +508,7 @@ void TempInput::messureSize()
|
|||
|
||||
wxClientDC dc(this);
|
||||
if (normal_icon.bmp().IsOk()) {
|
||||
wxSize szIcon = normal_icon.GetBmpSize();
|
||||
wxSize szIcon = normal_icon.GetSize();
|
||||
width += szIcon.x;
|
||||
height = szIcon.y;
|
||||
}
|
||||
|
|
@ -535,7 +537,7 @@ void TempInput::messureSize()
|
|||
height = textSize.y > height ? textSize.y : height;
|
||||
|
||||
// flag flag
|
||||
auto flagSize = degree_icon.GetBmpSize();
|
||||
auto flagSize = degree_icon.GetSize();
|
||||
width += flagSize.x;
|
||||
height = flagSize.y > height ? flagSize.y : height;
|
||||
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ void TextInput::SetLabel(const wxString& label)
|
|||
Refresh();
|
||||
}
|
||||
|
||||
void TextInput::SetIcon(const wxBitmap &icon)
|
||||
void TextInput::SetIcon(const wxBitmapBundle &icon_in)
|
||||
{
|
||||
this->icon = ScalableBitmap();
|
||||
this->icon.bmp() = icon;
|
||||
this->icon.bmp() = icon_in;
|
||||
Rescale();
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ void TextInput::SetTextColor(StateColor const& color)
|
|||
void TextInput::Rescale()
|
||||
{
|
||||
if (!this->icon.name().empty())
|
||||
this->icon.msw_rescale();
|
||||
this->icon.sys_color_changed();
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ void TextInput::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||
wxSize size = GetSize();
|
||||
wxPoint textPos = {5, 0};
|
||||
if (this->icon.bmp().IsOk()) {
|
||||
wxSize szIcon = this->icon.GetBmpSize();
|
||||
wxSize szIcon = this->icon.GetSize();
|
||||
textPos.x += szIcon.x;
|
||||
}
|
||||
bool align_right = GetWindowStyle() & wxRIGHT;
|
||||
|
|
@ -194,9 +194,9 @@ void TextInput::render(wxDC& dc)
|
|||
// start draw
|
||||
wxPoint pt = {5, 0};
|
||||
if (icon.bmp().IsOk()) {
|
||||
wxSize szIcon = icon.GetBmpSize();
|
||||
wxSize szIcon = get_preferred_size(icon.bmp(), m_parent);
|
||||
pt.y = (size.y - szIcon.y) / 2;
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
dc.DrawBitmap(icon.get_bitmap(), pt);
|
||||
pt.x += szIcon.x + 0;
|
||||
}
|
||||
auto text = wxWindow::GetLabel();
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
void SetLabel(const wxString& label);
|
||||
|
||||
void SetIcon(const wxBitmap & icon);
|
||||
virtual void SetIcon(const wxBitmapBundle & icon);
|
||||
|
||||
void SetLabelColor(StateColor const &color);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue