OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::PrintOption Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/SelectMachine.hpp>

Inheritance diagram for Slic3r::GUI::PrintOption:
Collaboration diagram for Slic3r::GUI::PrintOption:

Public Member Functions

 PrintOption (wxWindow *parent, wxString title, wxString tips, std::vector< POItem > ops, std::string param="")
 ~PrintOption ()
void enable (bool en)
void setValue (std::string value)
std::string getValue ()
int getValueInt ()
std::string getParam () const
bool contain_opt (const std::string &opt_str) const
void update_options (std::vector< POItem > ops, const wxString &tips)
void update_tooltip (const wxString &tips)
void update_title_display ()
void insert_extra_widget (wxWindow *widget)
void msw_rescale ()
bool CanBeFocused () const override

Private Member Functions

void OnPaint (wxPaintEvent &event)
void render (wxDC &dc)
void doRender (wxDC &dc)

Private Attributes

std::string m_param
std::vector< POItem > m_ops
Label * m_printoption_title {nullptr}
ScalableButton * m_printoption_tips { nullptr }
PrintOptionItem * m_printoption_item {nullptr}
wxString m_full_title

Detailed Description

Constructor & Destructor Documentation

◆ PrintOption()

Slic3r::GUI::PrintOption::PrintOption ( wxWindow * parent,
wxString title,
wxString tips,
std::vector< POItem > ops,
std::string param = "" )
6544 : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
6545 {
6546#ifdef __WINDOWS__
6547 SetDoubleBuffered(true);
6548#endif //__WINDOWS__
6549 Bind(wxEVT_PAINT, &PrintOption::OnPaint, this);
6550
6551 SetMinSize(wxSize(-1, FromDIP(28)));
6552 SetMaxSize(wxSize(-1, FromDIP(28)));
6553
6554 m_ops = ops;
6555 m_param = param;
6556 m_full_title = title;
6557
6558 SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
6559 wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
6560
6561 m_printoption_title = new Label(this, title);
6563
6565
6566 m_printoption_tips = new ScalableButton(this, wxID_ANY, "icon_qusetion", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
6567 m_printoption_tips->SetMinSize(wxSize(FromDIP(18), FromDIP(18)));
6568 m_printoption_tips->SetMaxSize(wxSize(FromDIP(18), FromDIP(18)));
6569
6570 m_printoption_item = new PrintOptionItem(this, m_ops, param);
6572
6573 sizer->Add(m_printoption_title, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 0);
6574 sizer->Add(m_printoption_tips, 0, wxLEFT | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, FromDIP(2));
6575 sizer->AddStretchSpacer();
6576 sizer->Add(m_printoption_item, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 0);
6577
6578 SetSizer(sizer);
6579 Layout();
6580 Fit();
6581
6582 update_tooltip(tips);
6583 }
static wxFont Body_13
Definition Label.hpp:54
void update_title_display()
Definition SelectMachine.cpp:6688
std::vector< POItem > m_ops
Definition SelectMachine.hpp:227
void update_tooltip(const wxString &tips)
Definition SelectMachine.cpp:6661
void OnPaint(wxPaintEvent &event)
Definition SelectMachine.cpp:6585
Label * m_printoption_title
Definition SelectMachine.hpp:228
ScalableButton * m_printoption_tips
Definition SelectMachine.hpp:229
PrintOptionItem * m_printoption_item
Definition SelectMachine.hpp:230
std::string m_param
Definition SelectMachine.hpp:226
wxString m_full_title
Definition SelectMachine.hpp:231
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References Label::Body_13, StateColor::darkModeColorFor(), m_full_title, m_ops, m_param, m_printoption_item, m_printoption_tips, m_printoption_title, OnPaint(), update_title_display(), and update_tooltip().

Here is the call graph for this function:

◆ ~PrintOption()

Slic3r::GUI::PrintOption::~PrintOption ( )
inline
235{};

Member Function Documentation

◆ CanBeFocused()

bool Slic3r::GUI::PrintOption::CanBeFocused ( ) const
inlineoverride
255{ return false; }

◆ contain_opt()

bool Slic3r::GUI::PrintOption::contain_opt ( const std::string & opt_str) const
6639{
6640 for (const auto &op : m_ops)
6641 {
6642 if (op.key == opt)
6643 {
6644 return true;
6645 }
6646 }
6647
6648 return false;
6649}

References m_ops.

◆ doRender()

void Slic3r::GUI::PrintOption::doRender ( wxDC & dc)
private
6613{
6614 auto size = GetSize();
6615 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
6616 dc.SetBrush(GetBackgroundColour());
6617 dc.DrawRoundedRectangle(0, 0, size.x, size.y, FromDIP(3));
6618}

Referenced by OnPaint(), and render().

Here is the caller graph for this function:

◆ enable()

void Slic3r::GUI::PrintOption::enable ( bool en)
6621{
6622 if (m_printoption_item->is_enabled() != en)
6623 {
6624 m_printoption_item->enable(en);
6625
6626 if (en) {
6627 m_printoption_title->SetForegroundColour(StateColor::darkModeColorFor("#262E30"));
6628 } else {
6629 m_printoption_title->SetForegroundColour(StateColor::darkModeColorFor(wxColour(144, 144, 144)));
6630 }
6631 }
6632}

References StateColor::darkModeColorFor(), m_printoption_item, and m_printoption_title.

Here is the call graph for this function:

◆ getParam()

std::string Slic3r::GUI::PrintOption::getParam ( ) const
inline
244{ return m_param; }

References m_param.

◆ getValue()

std::string Slic3r::GUI::PrintOption::getValue ( )
6671{
6672 return m_printoption_item->getValue();
6673}

References m_printoption_item.

◆ getValueInt()

int Slic3r::GUI::PrintOption::getValueInt ( )
6676{
6677 if (m_printoption_item->getValue() == "off") {
6678 return 0;
6679 } else if (m_printoption_item->getValue() == "on") {
6680 return 1;
6681 } else if (m_printoption_item->getValue() == "auto") {
6682 return 2;
6683 } else {
6684 return 2;
6685 }
6686}

References m_printoption_item.

◆ insert_extra_widget()

void Slic3r::GUI::PrintOption::insert_extra_widget ( wxWindow * widget)
6717{
6718 // insert after title (index 0), before tips (index 1)
6719 // sizer layout: [title][tips][stretch][item]
6720 // after insert: [title][widget][tips][stretch][item]
6721 wxSizer* sizer = GetSizer();
6722 if (!sizer || !widget) return;
6723 widget->Reparent(this);
6724 sizer->Insert(1, widget, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(4));
6725 Layout();
6726}

◆ msw_rescale()

void Slic3r::GUI::PrintOption::msw_rescale ( )
6710{
6711 m_printoption_item->msw_rescale();
6712 m_printoption_tips->msw_rescale();
6714}

References m_printoption_item, m_printoption_tips, and update_title_display().

Here is the call graph for this function:

◆ OnPaint()

void Slic3r::GUI::PrintOption::OnPaint ( wxPaintEvent & event)
private
6586 {
6587 wxPaintDC dc(this);
6588 doRender(dc);
6589 }
void doRender(wxDC &dc)
Definition SelectMachine.cpp:6612

References doRender().

Referenced by PrintOption().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render()

void Slic3r::GUI::PrintOption::render ( wxDC & dc)
private
6592{
6593#ifdef __WXMSW__
6594 wxSize size = GetSize();
6595 wxMemoryDC memdc;
6596 wxBitmap bmp(size.x, size.y);
6597 memdc.SelectObject(bmp);
6598 memdc.Blit({0, 0}, size, &dc, {0, 0});
6599
6600 {
6601 wxGCDC dc2(memdc);
6602 doRender(dc2);
6603 }
6604
6605 memdc.SelectObject(wxNullBitmap);
6606 dc.DrawBitmap(bmp, 0, 0);
6607#else
6608 doRender(dc);
6609#endif
6610}

References doRender().

Here is the call graph for this function:

◆ setValue()

void Slic3r::GUI::PrintOption::setValue ( std::string value)
6635{
6636 m_printoption_item->setValue(value); }

References m_printoption_item.

◆ update_options()

void Slic3r::GUI::PrintOption::update_options ( std::vector< POItem > ops,
const wxString & tips )
6652{
6653 if (m_ops != ops) {
6654 m_ops = ops;
6655 m_printoption_item->update_options(ops);
6656 }
6657
6658 update_tooltip(tips);
6659}

References m_ops, m_printoption_item, and update_tooltip().

Here is the call graph for this function:

◆ update_title_display()

void Slic3r::GUI::PrintOption::update_title_display ( )
6689{
6690 if (!m_printoption_title || m_full_title.IsEmpty()) {
6691 return;
6692 }
6693
6694 wxGCDC dc;
6695 wxSize titleSize = dc.GetTextExtent(m_full_title);
6696 int maxTitleWidth = FromDIP(150);
6697
6698 wxString displayTitle = m_full_title;
6699 if (titleSize.x > maxTitleWidth) {
6700 displayTitle = wxControl::Ellipsize(m_full_title, dc, wxELLIPSIZE_END, maxTitleWidth);
6701 m_printoption_title->SetToolTip(m_full_title);
6702 } else {
6703 m_printoption_title->SetToolTip(wxEmptyString);
6704 }
6705
6706 m_printoption_title->SetLabel(displayTitle);
6707}

References m_full_title, and m_printoption_title.

Referenced by PrintOption(), and msw_rescale().

Here is the caller graph for this function:

◆ update_tooltip()

void Slic3r::GUI::PrintOption::update_tooltip ( const wxString & tips)
6662{
6663 if (m_printoption_tips->GetToolTipText() != tips) {
6664 m_printoption_tips->SetToolTip(tips);
6665 }
6666
6667 m_printoption_tips->Show(!m_printoption_tips->GetToolTipText().IsEmpty());
6668}

References m_printoption_tips.

Referenced by PrintOption(), and update_options().

Here is the caller graph for this function:

Member Data Documentation

◆ m_full_title

wxString Slic3r::GUI::PrintOption::m_full_title
private

◆ m_ops

std::vector<POItem> Slic3r::GUI::PrintOption::m_ops
private

◆ m_param

std::string Slic3r::GUI::PrintOption::m_param
private

Referenced by PrintOption(), and getParam().

◆ m_printoption_item

PrintOptionItem* Slic3r::GUI::PrintOption::m_printoption_item {nullptr}
private

◆ m_printoption_tips

ScalableButton* Slic3r::GUI::PrintOption::m_printoption_tips { nullptr }
private
229{ nullptr };

Referenced by PrintOption(), msw_rescale(), and update_tooltip().

◆ m_printoption_title

Label* Slic3r::GUI::PrintOption::m_printoption_title {nullptr}
private
228{nullptr};

Referenced by PrintOption(), enable(), and update_title_display().


The documentation for this class was generated from the following files: