diff options
author | YuSanka <yusanka@gmail.com> | 2019-04-14 00:46:52 +0300 |
---|---|---|
committer | YuSanka <yusanka@gmail.com> | 2019-04-14 00:46:52 +0300 |
commit | f7ddddcff58b1c3de8740c70e3c297f2734602f5 (patch) | |
tree | 6b268b6e57b89de8a107720f538ed74149d3c3d2 /src/slic3r/GUI/Field.hpp | |
parent | a74c608c7a8eda5c2b5593db7236a6f89374e7f5 (diff) |
Application Scaling for MSW: Next big step
- Added rescale() function for the most of controls
- Created PrusaBitmap and PrusaButton classes like a wrap to wxBitmap and wxButton accordingly
Diffstat (limited to 'src/slic3r/GUI/Field.hpp')
-rw-r--r-- | src/slic3r/GUI/Field.hpp | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index 128d60d47..4dfb4e239 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -19,6 +19,7 @@ #include "libslic3r/Utils.hpp" #include "GUI.hpp" +#include "wxExtensions.hpp" #ifdef __WXMSW__ #define wxMSW true @@ -36,19 +37,24 @@ using t_back_to_init = std::function<void(const std::string&)>; wxString double_to_string(double const value, const int max_precision = 4); -class MyButton : public wxButton +class RevertButton : public /*wxButton*/PrusaButton { bool hidden = false; // never show button if it's hidden ones public: - MyButton() {} - MyButton(wxWindow* parent, wxWindowID id, const wxString& label = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxTextCtrlNameStr) - { - this->Create(parent, id, label, pos, size, style, validator, name); - } +// RevertButton() {} +// RevertButton(wxWindow* parent, wxWindowID id, const wxString& label = wxEmptyString, +// const wxPoint& pos = wxDefaultPosition, +// const wxSize& size = wxDefaultSize, long style = 0, +// const wxValidator& validator = wxDefaultValidator, +// const wxString& name = wxTextCtrlNameStr) +// { +// this->Create(parent, id, label, pos, size, style, validator, name); +// } + RevertButton( + wxWindow *parent, + const std::string& icon_name = "" + ) : + PrusaButton(parent, wxID_ANY, icon_name) {} // overridden from wxWindow base class virtual bool @@ -154,19 +160,19 @@ public: return std::move(p); //!p; } - bool set_undo_bitmap(const wxBitmap *bmp) { + bool set_undo_bitmap(const /*wxBitmap*/PrusaBitmap *bmp) { if (m_undo_bitmap != bmp) { m_undo_bitmap = bmp; - m_Undo_btn->SetBitmap(*bmp); + m_Undo_btn->SetBitmap_(*bmp); return true; } return false; } - bool set_undo_to_sys_bitmap(const wxBitmap *bmp) { + bool set_undo_to_sys_bitmap(const /*wxBitmap*/PrusaBitmap *bmp) { if (m_undo_to_sys_bitmap != bmp) { m_undo_to_sys_bitmap = bmp; - m_Undo_to_sys_btn->SetBitmap(*bmp); + m_Undo_to_sys_btn->SetBitmap_(*bmp); return true; } return false; @@ -211,14 +217,19 @@ public: m_side_text = side_text; } + virtual void rescale() { + m_Undo_to_sys_btn->rescale(); + m_Undo_btn->rescale(); + } + protected: - MyButton* m_Undo_btn = nullptr; + RevertButton* m_Undo_btn = nullptr; // Bitmap and Tooltip text for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. - const wxBitmap* m_undo_bitmap = nullptr; + const /*wxBitmap*/PrusaBitmap* m_undo_bitmap = nullptr; const wxString* m_undo_tooltip = nullptr; - MyButton* m_Undo_to_sys_btn = nullptr; + RevertButton* m_Undo_to_sys_btn = nullptr; // Bitmap and Tooltip text for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. - const wxBitmap* m_undo_to_sys_bitmap = nullptr; + const /*wxBitmap*/PrusaBitmap* m_undo_to_sys_bitmap = nullptr; const wxString* m_undo_to_sys_tooltip = nullptr; wxStaticText* m_Label = nullptr; @@ -273,6 +284,8 @@ public: } boost::any& get_value() override; + + void rescale() override; virtual void enable(); virtual void disable(); @@ -337,6 +350,8 @@ public: return m_value = tmp_value; } + void rescale() override; + void enable() override { dynamic_cast<wxSpinCtrl*>(window)->Enable(); } void disable() override { dynamic_cast<wxSpinCtrl*>(window)->Disable(); } wxWindow* getWindow() override { return window; } @@ -344,6 +359,7 @@ public: class Choice : public Field { using Field::Field; + int m_width{ 15 }; public: Choice(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {} Choice(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {} @@ -363,6 +379,8 @@ public: void set_values(const std::vector<std::string> &values); boost::any& get_value() override; + void rescale() override; + void enable() override { dynamic_cast<wxBitmapComboBox*>(window)->Enable(); }; void disable() override{ dynamic_cast<wxBitmapComboBox*>(window)->Disable(); }; wxWindow* getWindow() override { return window; } @@ -446,6 +464,8 @@ public: boost::any& get_value()override { return m_value; } + void rescale() override; + void enable() override { dynamic_cast<wxStaticText*>(window)->Enable(); }; void disable() override{ dynamic_cast<wxStaticText*>(window)->Disable(); }; wxWindow* getWindow() override { return window; } |