Added msw_buttons_rescale() - Function for a scaling Dialog's buttons under MSW
This commit is contained in:
parent
3f978f6afe
commit
708037158e
@ -133,13 +133,15 @@ void AboutDialog::on_dpi_changed(const wxRect &suggested_rect)
|
|||||||
|
|
||||||
const int& em = em_unit();
|
const int& em = em_unit();
|
||||||
|
|
||||||
|
msw_buttons_rescale(this, em, { wxID_CLOSE });
|
||||||
|
|
||||||
m_html->SetMinSize(wxSize(-1, 16 * em));
|
m_html->SetMinSize(wxSize(-1, 16 * em));
|
||||||
m_html->Refresh();
|
m_html->Refresh();
|
||||||
|
|
||||||
const wxSize& size = wxSize(65 * em, 30 * em);
|
const wxSize& size = wxSize(65 * em, 30 * em);
|
||||||
|
|
||||||
SetMinSize(size);
|
SetMinSize(size);
|
||||||
SetSize(size);
|
Fit();
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "libslic3r/Utils.hpp"
|
#include "libslic3r/Utils.hpp"
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
|
#include "wxExtensions.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
@ -144,10 +145,12 @@ void ConfigSnapshotDialog::on_dpi_changed(const wxRect &suggested_rect)
|
|||||||
html->Refresh();
|
html->Refresh();
|
||||||
|
|
||||||
const int& em = em_unit();
|
const int& em = em_unit();
|
||||||
const wxSize& size = wxSize(45 * em, 40 * em);
|
|
||||||
|
|
||||||
|
msw_buttons_rescale(this, em, { wxID_CLOSE});
|
||||||
|
|
||||||
|
const wxSize& size = wxSize(45 * em, 40 * em);
|
||||||
SetMinSize(size);
|
SetMinSize(size);
|
||||||
SetSize(size);
|
Fit();
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -194,6 +194,9 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
|
|||||||
title_sizer->Add(sel_all_std, 0, wxRIGHT, BTN_SPACING);
|
title_sizer->Add(sel_all_std, 0, wxRIGHT, BTN_SPACING);
|
||||||
title_sizer->Add(sel_all, 0, wxRIGHT, BTN_SPACING);
|
title_sizer->Add(sel_all, 0, wxRIGHT, BTN_SPACING);
|
||||||
title_sizer->Add(sel_none);
|
title_sizer->Add(sel_none);
|
||||||
|
|
||||||
|
// fill button indexes used later for buttons rescaling
|
||||||
|
m_button_indexes = { sel_all_std->GetId(), sel_all->GetId(), sel_none->GetId() };
|
||||||
}
|
}
|
||||||
|
|
||||||
sizer->Add(title_sizer, 0, wxEXPAND | wxBOTTOM, BTN_SPACING);
|
sizer->Add(title_sizer, 0, wxEXPAND | wxBOTTOM, BTN_SPACING);
|
||||||
@ -1057,8 +1060,8 @@ ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
|
|||||||
topsizer->AddSpacer(INDEX_MARGIN);
|
topsizer->AddSpacer(INDEX_MARGIN);
|
||||||
topsizer->Add(p->hscroll, 1, wxEXPAND);
|
topsizer->Add(p->hscroll, 1, wxEXPAND);
|
||||||
|
|
||||||
auto *btn_sel_all = new wxButton(this, wxID_ANY, _(L("Select all standard printers")));
|
p->btn_sel_all = new wxButton(this, wxID_ANY, _(L("Select all standard printers")));
|
||||||
p->btnsizer->Add(btn_sel_all);
|
p->btnsizer->Add(p->btn_sel_all);
|
||||||
|
|
||||||
p->btn_prev = new wxButton(this, wxID_ANY, _(L("< &Back")));
|
p->btn_prev = new wxButton(this, wxID_ANY, _(L("< &Back")));
|
||||||
p->btn_next = new wxButton(this, wxID_ANY, _(L("&Next >")));
|
p->btn_next = new wxButton(this, wxID_ANY, _(L("&Next >")));
|
||||||
@ -1130,7 +1133,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
|
|||||||
p->btn_finish->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &) { this->EndModal(wxID_OK); });
|
p->btn_finish->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &) { this->EndModal(wxID_OK); });
|
||||||
p->btn_finish->Hide();
|
p->btn_finish->Hide();
|
||||||
|
|
||||||
btn_sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &) {
|
p->btn_sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &) {
|
||||||
p->page_fff->select_all(true, false);
|
p->page_fff->select_all(true, false);
|
||||||
p->page_msla->select_all(true, false);
|
p->page_msla->select_all(true, false);
|
||||||
p->index->go_to(p->page_update);
|
p->index->go_to(p->page_update);
|
||||||
@ -1179,6 +1182,20 @@ const wxString& ConfigWizard::name(const bool from_menu/* = false*/)
|
|||||||
void ConfigWizard::on_dpi_changed(const wxRect &suggested_rect)
|
void ConfigWizard::on_dpi_changed(const wxRect &suggested_rect)
|
||||||
{
|
{
|
||||||
p->index->msw_rescale();
|
p->index->msw_rescale();
|
||||||
|
|
||||||
|
const int& em = em_unit();
|
||||||
|
|
||||||
|
msw_buttons_rescale(this, em, { wxID_APPLY,
|
||||||
|
wxID_CANCEL,
|
||||||
|
p->btn_sel_all->GetId(),
|
||||||
|
p->btn_next->GetId(),
|
||||||
|
p->btn_prev->GetId() });
|
||||||
|
|
||||||
|
for (auto printer_picker: p->page_fff->printer_pickers)
|
||||||
|
msw_buttons_rescale(this, em, printer_picker->get_button_indexes());
|
||||||
|
|
||||||
|
// FIXME VK SetSize(???)
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,11 @@ struct PrinterPicker: wxPanel
|
|||||||
void on_checkbox(const Checkbox *cbox, bool checked);
|
void on_checkbox(const Checkbox *cbox, bool checked);
|
||||||
|
|
||||||
int get_width() const { return width; }
|
int get_width() const { return width; }
|
||||||
|
const std::vector<int>& get_button_indexes() { return m_button_indexes; }
|
||||||
private:
|
private:
|
||||||
int width;
|
int width;
|
||||||
|
|
||||||
|
std::vector<int> m_button_indexes;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConfigWizardPage: wxPanel
|
struct ConfigWizardPage: wxPanel
|
||||||
@ -267,6 +270,7 @@ struct ConfigWizard::priv
|
|||||||
wxBoxSizer *btnsizer = nullptr;
|
wxBoxSizer *btnsizer = nullptr;
|
||||||
ConfigWizardPage *page_current = nullptr;
|
ConfigWizardPage *page_current = nullptr;
|
||||||
ConfigWizardIndex *index = nullptr;
|
ConfigWizardIndex *index = nullptr;
|
||||||
|
wxButton *btn_sel_all = nullptr;
|
||||||
wxButton *btn_prev = nullptr;
|
wxButton *btn_prev = nullptr;
|
||||||
wxButton *btn_next = nullptr;
|
wxButton *btn_next = nullptr;
|
||||||
wxButton *btn_finish = nullptr;
|
wxButton *btn_finish = nullptr;
|
||||||
|
@ -379,8 +379,8 @@ void TextCtrl::change_field_value(wxEvent& event)
|
|||||||
|
|
||||||
void CheckBox::BUILD() {
|
void CheckBox::BUILD() {
|
||||||
auto size = wxSize(wxDefaultSize);
|
auto size = wxSize(wxDefaultSize);
|
||||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height);
|
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);
|
||||||
if (m_opt.width >= 0) size.SetWidth(m_opt.width);
|
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
|
||||||
|
|
||||||
bool check_value = m_opt.type == coBool ?
|
bool check_value = m_opt.type == coBool ?
|
||||||
m_opt.default_value->getBool() : m_opt.type == coBools ?
|
m_opt.default_value->getBool() : m_opt.type == coBools ?
|
||||||
@ -413,6 +413,14 @@ boost::any& CheckBox::get_value()
|
|||||||
return m_value;
|
return m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckBox::msw_rescale()
|
||||||
|
{
|
||||||
|
Field::msw_rescale();
|
||||||
|
|
||||||
|
wxCheckBox* field = dynamic_cast<wxCheckBox*>(window);
|
||||||
|
field->SetMinSize(wxSize(-1, int(1.5f*field->GetFont().GetPixelSize().y +0.5f)));
|
||||||
|
}
|
||||||
|
|
||||||
int undef_spin_val = -9999; //! Probably, It's not necessary
|
int undef_spin_val = -9999; //! Probably, It's not necessary
|
||||||
|
|
||||||
void SpinCtrl::BUILD() {
|
void SpinCtrl::BUILD() {
|
||||||
@ -849,9 +857,11 @@ void Choice::msw_rescale()
|
|||||||
*/
|
*/
|
||||||
field->Clear();
|
field->Clear();
|
||||||
wxSize size(wxDefaultSize);
|
wxSize size(wxDefaultSize);
|
||||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height * m_em_unit);
|
|
||||||
size.SetWidth((m_opt.width > 0 ? m_opt.width : m_width) * m_em_unit);
|
size.SetWidth((m_opt.width > 0 ? m_opt.width : m_width) * m_em_unit);
|
||||||
|
|
||||||
|
// Set rescaled min height to correct layout
|
||||||
|
field->SetMinSize(wxSize(-1, int(1.5f*field->GetFont().GetPixelSize().y + 0.5f)));
|
||||||
|
// Set rescaled size
|
||||||
field->SetSize(size);
|
field->SetSize(size);
|
||||||
|
|
||||||
size_t idx, counter = idx = 0;
|
size_t idx, counter = idx = 0;
|
||||||
|
@ -319,6 +319,8 @@ public:
|
|||||||
}
|
}
|
||||||
boost::any& get_value() override;
|
boost::any& get_value() override;
|
||||||
|
|
||||||
|
void msw_rescale() override;
|
||||||
|
|
||||||
void enable() override { dynamic_cast<wxCheckBox*>(window)->Enable(); }
|
void enable() override { dynamic_cast<wxCheckBox*>(window)->Enable(); }
|
||||||
void disable() override { dynamic_cast<wxCheckBox*>(window)->Disable(); }
|
void disable() override { dynamic_cast<wxCheckBox*>(window)->Disable(); }
|
||||||
wxWindow* getWindow() override { return window; }
|
wxWindow* getWindow() override { return window; }
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "MsgDialog.hpp"
|
#include "MsgDialog.hpp"
|
||||||
#include "../Utils/HexFile.hpp"
|
#include "../Utils/HexFile.hpp"
|
||||||
#include "../Utils/Serial.hpp"
|
#include "../Utils/Serial.hpp"
|
||||||
|
#include "wxExtensions.hpp"
|
||||||
|
|
||||||
// wx includes need to come after asio because of the WinSock.h problem
|
// wx includes need to come after asio because of the WinSock.h problem
|
||||||
#include "FirmwareDialog.hpp"
|
#include "FirmwareDialog.hpp"
|
||||||
@ -118,6 +119,10 @@ struct FirmwareDialog::priv
|
|||||||
|
|
||||||
wxTimer timer_pulse;
|
wxTimer timer_pulse;
|
||||||
|
|
||||||
|
int min_width;
|
||||||
|
int min_height;
|
||||||
|
int min_height_expanded;
|
||||||
|
|
||||||
// Async modal dialog during flashing
|
// Async modal dialog during flashing
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
int modal_response;
|
int modal_response;
|
||||||
@ -735,18 +740,10 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
|
|||||||
GUI::DPIDialog(parent, wxID_ANY, _(L("Firmware flasher")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
|
GUI::DPIDialog(parent, wxID_ANY, _(L("Firmware flasher")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
|
||||||
p(new priv(this))
|
p(new priv(this))
|
||||||
{
|
{
|
||||||
enum {
|
|
||||||
DIALOG_MARGIN = 15,
|
|
||||||
SPACING = 10,
|
|
||||||
MIN_WIDTH = 50,
|
|
||||||
MIN_HEIGHT = 18,
|
|
||||||
MIN_HEIGHT_EXPANDED = 40,
|
|
||||||
};
|
|
||||||
|
|
||||||
const int em = GUI::wxGetApp().em_unit();
|
const int em = GUI::wxGetApp().em_unit();
|
||||||
int min_width = MIN_WIDTH * em;
|
p->min_width = MIN_WIDTH * em;
|
||||||
int min_height = MIN_HEIGHT * em;
|
p->min_height = MIN_HEIGHT * em;
|
||||||
int min_height_expanded = MIN_HEIGHT_EXPANDED * em;
|
p->min_height_expanded = MIN_HEIGHT_EXPANDED * em;
|
||||||
|
|
||||||
/* get current font from application,
|
/* get current font from application,
|
||||||
* because of wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) function
|
* because of wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) function
|
||||||
@ -825,10 +822,10 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
|
|||||||
|
|
||||||
auto *topsizer = new wxBoxSizer(wxVERTICAL);
|
auto *topsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
topsizer->Add(panel, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
|
topsizer->Add(panel, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
|
||||||
SetMinSize(wxSize(min_width, min_height));
|
SetMinSize(wxSize(p->min_width, p->min_height));
|
||||||
SetSizerAndFit(topsizer);
|
SetSizerAndFit(topsizer);
|
||||||
const auto size = GetSize();
|
const auto size = GetSize();
|
||||||
SetSize(std::max(size.GetWidth(), static_cast<int>(min_width)), std::max(size.GetHeight(), static_cast<int>(min_height)));
|
SetSize(std::max(size.GetWidth(), static_cast<int>(p->min_width)), std::max(size.GetHeight(), static_cast<int>(p->min_height)));
|
||||||
Layout();
|
Layout();
|
||||||
|
|
||||||
SetEscapeId(wxID_CLOSE); // To close the dialog using "Esc" button
|
SetEscapeId(wxID_CLOSE); // To close the dialog using "Esc" button
|
||||||
@ -844,11 +841,11 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
|
|||||||
|
|
||||||
p->spoiler->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, [=](wxCollapsiblePaneEvent &evt) {
|
p->spoiler->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, [=](wxCollapsiblePaneEvent &evt) {
|
||||||
if (evt.GetCollapsed()) {
|
if (evt.GetCollapsed()) {
|
||||||
this->SetMinSize(wxSize(min_width, min_height));
|
this->SetMinSize(wxSize(p->min_width, p->min_height));
|
||||||
const auto new_height = this->GetSize().GetHeight() - this->p->txt_stdout->GetSize().GetHeight();
|
const auto new_height = this->GetSize().GetHeight() - this->p->txt_stdout->GetSize().GetHeight();
|
||||||
this->SetSize(this->GetSize().GetWidth(), new_height);
|
this->SetSize(this->GetSize().GetWidth(), new_height);
|
||||||
} else {
|
} else {
|
||||||
this->SetMinSize(wxSize(min_width, min_height_expanded));
|
this->SetMinSize(wxSize(p->min_width, p->min_height_expanded));
|
||||||
}
|
}
|
||||||
|
|
||||||
this->Layout();
|
this->Layout();
|
||||||
@ -903,5 +900,25 @@ void FirmwareDialog::run(wxWindow *parent)
|
|||||||
dialog.ShowModal();
|
dialog.ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FirmwareDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||||
|
{
|
||||||
|
const int& em = em_unit();
|
||||||
|
|
||||||
|
msw_buttons_rescale(this, em, { p->btn_close->GetId(),
|
||||||
|
p->btn_rescan->GetId(),
|
||||||
|
p->btn_flash->GetId(),
|
||||||
|
p->hex_picker->GetPickerCtrl()->GetId()
|
||||||
|
});
|
||||||
|
|
||||||
|
p->min_width = MIN_WIDTH * em;
|
||||||
|
p->min_height = MIN_HEIGHT * em;
|
||||||
|
p->min_height_expanded = MIN_HEIGHT_EXPANDED * em;
|
||||||
|
|
||||||
|
const int min_height = p->spoiler->IsExpanded() ? p->min_height_expanded : p->min_height;
|
||||||
|
SetMinSize(wxSize(p->min_width, min_height));
|
||||||
|
Fit();
|
||||||
|
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,14 @@ namespace Slic3r {
|
|||||||
|
|
||||||
class FirmwareDialog: public GUI::DPIDialog
|
class FirmwareDialog: public GUI::DPIDialog
|
||||||
{
|
{
|
||||||
|
enum {
|
||||||
|
DIALOG_MARGIN = 15,
|
||||||
|
SPACING = 10,
|
||||||
|
MIN_WIDTH = 50,
|
||||||
|
MIN_HEIGHT = /*18*/25,
|
||||||
|
MIN_HEIGHT_EXPANDED = 40,
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FirmwareDialog(wxWindow *parent);
|
FirmwareDialog(wxWindow *parent);
|
||||||
FirmwareDialog(FirmwareDialog &&) = delete;
|
FirmwareDialog(FirmwareDialog &&) = delete;
|
||||||
@ -23,7 +31,7 @@ public:
|
|||||||
static void run(wxWindow *parent);
|
static void run(wxWindow *parent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void on_dpi_changed(const wxRect &suggested_rect) override{;}
|
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||||
private:
|
private:
|
||||||
struct priv;
|
struct priv;
|
||||||
std::unique_ptr<priv> p;
|
std::unique_ptr<priv> p;
|
||||||
|
@ -196,11 +196,14 @@ void KBShortcutsDialog::on_dpi_changed(const wxRect &suggested_rect)
|
|||||||
for (wxStaticBitmap* bmp : m_head_bitmaps)
|
for (wxStaticBitmap* bmp : m_head_bitmaps)
|
||||||
bmp->SetBitmap(m_logo_bmp.bmp());
|
bmp->SetBitmap(m_logo_bmp.bmp());
|
||||||
|
|
||||||
const int& em = em_unit();
|
const int em = em_unit();
|
||||||
|
|
||||||
|
msw_buttons_rescale(this, em, { wxID_OK });
|
||||||
|
|
||||||
const wxSize& size = wxSize(85 * em, 75 * em);
|
const wxSize& size = wxSize(85 * em, 75 * em);
|
||||||
|
|
||||||
SetMinSize(size);
|
SetMinSize(size);
|
||||||
SetSize(size);
|
Fit();
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -516,17 +516,19 @@ void ConfigOptionsGroup::msw_rescale()
|
|||||||
{
|
{
|
||||||
auto label = dynamic_cast<wxStaticText*>(label_item->GetWindow());
|
auto label = dynamic_cast<wxStaticText*>(label_item->GetWindow());
|
||||||
if (label != nullptr) {
|
if (label != nullptr) {
|
||||||
label->SetMinSize(wxSize(label_width*em, -1));
|
const int label_height = int(1.5f*label->GetFont().GetPixelSize().y + 0.5f);
|
||||||
|
label->SetMinSize(wxSize(label_width*em, /*-1*/label_height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (label_item->IsSizer()) // case when we nave near_label_widget
|
else if (label_item->IsSizer()) // case when we have near_label_widget
|
||||||
{
|
{
|
||||||
const wxSizerItem* l_item = label_item->GetSizer()->GetItem(1);
|
const wxSizerItem* l_item = label_item->GetSizer()->GetItem(1);
|
||||||
if (l_item->IsWindow())
|
if (l_item->IsWindow())
|
||||||
{
|
{
|
||||||
auto label = dynamic_cast<wxStaticText*>(l_item->GetWindow());
|
auto label = dynamic_cast<wxStaticText*>(l_item->GetWindow());
|
||||||
if (label != nullptr) {
|
if (label != nullptr) {
|
||||||
label->SetMinSize(wxSize(label_width*em, -1));
|
const int label_height = int(1.5f*label->GetFont().GetPixelSize().y + 0.5f);
|
||||||
|
label->SetMinSize(wxSize(label_width*em, /*-1*/label_height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace GUI {
|
|||||||
|
|
||||||
PreferencesDialog::PreferencesDialog(wxWindow* parent) :
|
PreferencesDialog::PreferencesDialog(wxWindow* parent) :
|
||||||
DPIDialog(parent, wxID_ANY, _(L("Preferences")), wxDefaultPosition,
|
DPIDialog(parent, wxID_ANY, _(L("Preferences")), wxDefaultPosition,
|
||||||
wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
|
||||||
{
|
{
|
||||||
build();
|
build();
|
||||||
}
|
}
|
||||||
@ -146,11 +146,14 @@ void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect)
|
|||||||
{
|
{
|
||||||
m_optgroup->msw_rescale();
|
m_optgroup->msw_rescale();
|
||||||
|
|
||||||
const int& em = em_unit();
|
const int em = em_unit();
|
||||||
const wxSize& size = wxSize(50 * em, 29 * em);
|
|
||||||
|
msw_buttons_rescale(this, em, { wxID_OK, wxID_CANCEL });
|
||||||
|
|
||||||
|
const wxSize& size = wxSize(47 * em, 28 * em);
|
||||||
|
|
||||||
SetMinSize(size);
|
SetMinSize(size);
|
||||||
SetSize(size);
|
Fit();
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "MsgDialog.hpp"
|
#include "MsgDialog.hpp"
|
||||||
#include "I18N.hpp"
|
#include "I18N.hpp"
|
||||||
#include "../Utils/PrintHost.hpp"
|
#include "../Utils/PrintHost.hpp"
|
||||||
|
#include "wxExtensions.hpp"
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
@ -136,8 +137,6 @@ PrintHostQueueDialog::PrintHostQueueDialog(wxWindow *parent)
|
|||||||
, on_error_evt(this, EVT_PRINTHOST_ERROR, &PrintHostQueueDialog::on_error, this)
|
, on_error_evt(this, EVT_PRINTHOST_ERROR, &PrintHostQueueDialog::on_error, this)
|
||||||
, on_cancel_evt(this, EVT_PRINTHOST_CANCEL, &PrintHostQueueDialog::on_cancel, this)
|
, on_cancel_evt(this, EVT_PRINTHOST_CANCEL, &PrintHostQueueDialog::on_cancel, this)
|
||||||
{
|
{
|
||||||
enum { HEIGHT = 60, WIDTH = 30, SPACING = 5 };
|
|
||||||
|
|
||||||
const auto em = GetTextExtent("m").x;
|
const auto em = GetTextExtent("m").x;
|
||||||
|
|
||||||
SetSize(wxSize(HEIGHT * em, WIDTH * em));
|
SetSize(wxSize(HEIGHT * em, WIDTH * em));
|
||||||
@ -202,6 +201,18 @@ void PrintHostQueueDialog::append_job(const PrintHostJob &job)
|
|||||||
job_list->AppendItem(fields, static_cast<wxUIntPtr>(ST_NEW));
|
job_list->AppendItem(fields, static_cast<wxUIntPtr>(ST_NEW));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintHostQueueDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||||
|
{
|
||||||
|
const int& em = em_unit();
|
||||||
|
|
||||||
|
msw_buttons_rescale(this, em, { wxID_DELETE, wxID_CANCEL, btn_error->GetId() });
|
||||||
|
|
||||||
|
SetMinSize(wxSize(HEIGHT * em, WIDTH * em));
|
||||||
|
|
||||||
|
Fit();
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
PrintHostQueueDialog::JobState PrintHostQueueDialog::get_state(int idx)
|
PrintHostQueueDialog::JobState PrintHostQueueDialog::get_state(int idx)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG(idx >= 0 && idx < job_list->GetItemCount(), ST_ERROR, "Out of bounds access to job list");
|
wxCHECK_MSG(idx >= 0 && idx < job_list->GetItemCount(), ST_ERROR, "Out of bounds access to job list");
|
||||||
|
@ -64,7 +64,7 @@ public:
|
|||||||
void append_job(const PrintHostJob &job);
|
void append_job(const PrintHostJob &job);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void on_dpi_changed(const wxRect &suggested_rect) override { Refresh(); }
|
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Column {
|
enum Column {
|
||||||
@ -85,6 +85,8 @@ private:
|
|||||||
ST_COMPLETED,
|
ST_COMPLETED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum { HEIGHT = 60, WIDTH = 30, SPACING = 5 };
|
||||||
|
|
||||||
wxButton *btn_cancel;
|
wxButton *btn_cancel;
|
||||||
wxButton *btn_error;
|
wxButton *btn_error;
|
||||||
wxDataViewListCtrl *job_list;
|
wxDataViewListCtrl *job_list;
|
||||||
|
@ -117,9 +117,10 @@ SysInfoDialog::SysInfoDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxOK);
|
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxOK);
|
||||||
auto btn_copy_to_clipboard = new wxButton(this, wxID_ANY, "Copy to Clipboard", wxDefaultPosition, wxDefaultSize);
|
m_btn_copy_to_clipboard = new wxButton(this, wxID_ANY, "Copy to Clipboard", wxDefaultPosition, wxDefaultSize);
|
||||||
buttons->Insert(0, btn_copy_to_clipboard, 0, wxLEFT, 5);
|
|
||||||
btn_copy_to_clipboard->Bind(wxEVT_BUTTON, &SysInfoDialog::onCopyToClipboard, this);
|
buttons->Insert(0, m_btn_copy_to_clipboard, 0, wxLEFT, 5);
|
||||||
|
m_btn_copy_to_clipboard->Bind(wxEVT_BUTTON, &SysInfoDialog::onCopyToClipboard, this);
|
||||||
|
|
||||||
this->SetEscapeId(wxID_OK);
|
this->SetEscapeId(wxID_OK);
|
||||||
this->Bind(wxEVT_BUTTON, &SysInfoDialog::onCloseDialog, this, wxID_OK);
|
this->Bind(wxEVT_BUTTON, &SysInfoDialog::onCloseDialog, this, wxID_OK);
|
||||||
@ -146,6 +147,8 @@ void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect)
|
|||||||
|
|
||||||
const int& em = em_unit();
|
const int& em = em_unit();
|
||||||
|
|
||||||
|
msw_buttons_rescale(this, em, { wxID_OK, m_btn_copy_to_clipboard->GetId() });
|
||||||
|
|
||||||
m_opengl_info_html->SetMinSize(wxSize(-1, 16 * em));
|
m_opengl_info_html->SetMinSize(wxSize(-1, 16 * em));
|
||||||
m_opengl_info_html->SetFonts(font.GetFaceName(), font.GetFaceName(), font_size);
|
m_opengl_info_html->SetFonts(font.GetFaceName(), font.GetFaceName(), font_size);
|
||||||
m_opengl_info_html->Refresh();
|
m_opengl_info_html->Refresh();
|
||||||
@ -153,7 +156,7 @@ void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect)
|
|||||||
const wxSize& size = wxSize(65 * em, 55 * em);
|
const wxSize& size = wxSize(65 * em, 55 * em);
|
||||||
|
|
||||||
SetMinSize(size);
|
SetMinSize(size);
|
||||||
SetSize(size);
|
Fit();
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ class SysInfoDialog : public DPIDialog
|
|||||||
wxHtmlWindow* m_opengl_info_html;
|
wxHtmlWindow* m_opengl_info_html;
|
||||||
wxHtmlWindow* m_html;
|
wxHtmlWindow* m_html;
|
||||||
|
|
||||||
|
wxButton* m_btn_copy_to_clipboard;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SysInfoDialog();
|
SysInfoDialog();
|
||||||
|
|
||||||
|
@ -267,6 +267,22 @@ void wxDataViewTreeCtrlComboPopup::OnDataViewTreeCtrlSelection(wxCommandEvent& e
|
|||||||
cmb->SetText(selected);
|
cmb->SetText(selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Function for rescale of buttons in Dialog under MSW if dpi is changed.
|
||||||
|
* btn_ids - vector of buttons identifiers
|
||||||
|
*/
|
||||||
|
void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<int>& btn_ids)
|
||||||
|
{
|
||||||
|
const wxSize& btn_size = wxSize(-1, int(2.5f * em_unit + 0.5f));
|
||||||
|
|
||||||
|
for (int btn_id : btn_ids) {
|
||||||
|
// There is a case [FirmwareDialog], when we have wxControl instead of wxButton
|
||||||
|
// so let casting everything to the wxControl
|
||||||
|
wxControl* btn = static_cast<wxControl*>(dlg->FindWindowById(btn_id, dlg));
|
||||||
|
if (btn)
|
||||||
|
btn->SetMinSize(btn_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Function for getting of em_unit value from correct parent.
|
/* Function for getting of em_unit value from correct parent.
|
||||||
* In most of cases it is m_em_unit value from GUI_App,
|
* In most of cases it is m_em_unit value from GUI_App,
|
||||||
* but for DPIDialogs it's its own value.
|
* but for DPIDialogs it's its own value.
|
||||||
|
@ -31,7 +31,8 @@ wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxStrin
|
|||||||
wxMenuItem* append_menu_radio_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
|
wxMenuItem* append_menu_radio_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
|
||||||
std::function<void(wxCommandEvent& event)> cb, wxEvtHandler* event_handler);
|
std::function<void(wxCommandEvent& event)> cb, wxEvtHandler* event_handler);
|
||||||
|
|
||||||
int em_unit(wxWindow* win);
|
void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<int>& btn_ids);
|
||||||
|
int em_unit(wxWindow* win);
|
||||||
|
|
||||||
wxBitmap create_scaled_bitmap(wxWindow *win, const std::string& bmp_name, const int px_cnt = 16, const bool is_horizontal = false);
|
wxBitmap create_scaled_bitmap(wxWindow *win, const std::string& bmp_name, const int px_cnt = 16, const bool is_horizontal = false);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user