mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-10 23:35:13 -06:00
Implemented possibility to apply conversion from inches/meters to mm for all loaded objects at once
+ Added MessageWithCheckBox dialog + some code refactoring for MessageDlg
This commit is contained in:
parent
fe748ca43b
commit
ef0dae8c97
3 changed files with 115 additions and 48 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <wx/statbmp.h>
|
||||
#include <wx/scrolwin.h>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/html/htmlwin.h>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
@ -75,6 +76,26 @@ void MsgDialog::add_btn(wxWindowID btn_id, bool set_focus /*= false*/)
|
|||
btn->Bind(wxEVT_BUTTON, [this, btn_id](wxCommandEvent&) { this->EndModal(btn_id); });
|
||||
};
|
||||
|
||||
void MsgDialog::apply_style(long style)
|
||||
{
|
||||
if (style & wxOK) add_btn(wxID_OK, true);
|
||||
if (style & wxYES) add_btn(wxID_YES);
|
||||
if (style & wxNO) add_btn(wxID_NO);
|
||||
if (style & wxCANCEL) add_btn(wxID_CANCEL);
|
||||
|
||||
logo->SetBitmap(create_scaled_bitmap(style & wxICON_WARNING ? "exclamation" :
|
||||
style & wxICON_INFORMATION ? "info" :
|
||||
style & wxICON_QUESTION ? "question" : "PrusaSlicer"/*"_192px_grayscale.png"*/, this, 84));
|
||||
}
|
||||
|
||||
void MsgDialog::finalize()
|
||||
{
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
Fit();
|
||||
this->CenterOnParent();
|
||||
}
|
||||
|
||||
|
||||
// Text shown as HTML, so that mouse selection and Ctrl-V to copy will work.
|
||||
static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxString msg, bool monospaced_font = false)
|
||||
{
|
||||
|
@ -156,11 +177,9 @@ ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg, bool monospaced_
|
|||
// Use a small bitmap with monospaced font, as the error text will not be wrapped.
|
||||
logo->SetBitmap(create_scaled_bitmap("PrusaSlicer_192px_grayscale.png", this, monospaced_font ? 48 : /*1*/84));
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
|
||||
SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT*wxGetApp().em_unit()));
|
||||
Fit();
|
||||
this->CenterOnParent();
|
||||
|
||||
finalize();
|
||||
}
|
||||
|
||||
// WarningDialog
|
||||
|
@ -173,16 +192,8 @@ WarningDialog::WarningDialog(wxWindow *parent,
|
|||
wxString::Format(_L("%s has a warning")+":", SLIC3R_APP_NAME), wxID_NONE)
|
||||
{
|
||||
add_msg_content(this, content_sizer, message);
|
||||
|
||||
if (style & wxOK) add_btn(wxID_OK, true);
|
||||
if (style & wxYES) add_btn(wxID_YES);
|
||||
if (style & wxNO) add_btn(wxID_NO);
|
||||
|
||||
logo->SetBitmap(create_scaled_bitmap("PrusaSlicer_192px_grayscale.png", this, 84));
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
Fit();
|
||||
this->CenterOnParent();
|
||||
apply_style(style);
|
||||
finalize();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -195,23 +206,37 @@ MessageDialog::MessageDialog(wxWindow* parent,
|
|||
: MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, wxID_NONE)
|
||||
{
|
||||
add_msg_content(this, content_sizer, message);
|
||||
|
||||
if (style & wxOK) add_btn(wxID_OK, true);
|
||||
if (style & wxYES) add_btn(wxID_YES);
|
||||
if (style & wxNO) add_btn(wxID_NO);
|
||||
if (style & wxCANCEL) add_btn(wxID_CANCEL);
|
||||
|
||||
logo->SetBitmap(create_scaled_bitmap(style & wxICON_WARNING ? "exclamation" :
|
||||
style & wxICON_INFORMATION ? "info" :
|
||||
style & wxICON_QUESTION ? "question" : "PrusaSlicer_192px_grayscale.png", this, 84));
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
Fit();
|
||||
this->CenterOnParent();
|
||||
apply_style(style);
|
||||
finalize();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// MessageWithCheckDialog
|
||||
|
||||
MessageWithCheckDialog::MessageWithCheckDialog( wxWindow* parent,
|
||||
const wxString& message,
|
||||
const wxString& checkbox_label,
|
||||
const wxString& caption/* = wxEmptyString*/,
|
||||
long style/* = wxOK*/)
|
||||
: MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, wxID_NONE)
|
||||
{
|
||||
add_msg_content(this, content_sizer, message);
|
||||
|
||||
m_check = new wxCheckBox(this, wxID_ANY, checkbox_label);
|
||||
content_sizer->Add(m_check, 0, wxTOP, 10);
|
||||
|
||||
apply_style(style);
|
||||
finalize();
|
||||
}
|
||||
|
||||
bool MessageWithCheckDialog::GetCheckVal()
|
||||
{
|
||||
if (m_check)
|
||||
return m_check->GetValue();
|
||||
return false;
|
||||
}
|
||||
|
||||
// InfoDialog
|
||||
|
||||
InfoDialog::InfoDialog(wxWindow* parent, const wxString &title, const wxString& msg)
|
||||
|
@ -222,9 +247,7 @@ InfoDialog::InfoDialog(wxWindow* parent, const wxString &title, const wxString&
|
|||
// Set info bitmap
|
||||
logo->SetBitmap(create_scaled_bitmap("info", this, 84));
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
|
||||
Fit();
|
||||
finalize();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue