OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
ScalableButton Class Reference

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

Inheritance diagram for ScalableButton:
Collaboration diagram for ScalableButton:

Public Member Functions

 ScalableButton ()
 ScalableButton (wxWindow *parent, wxWindowID id, const std::string &icon_name="", const wxString &label=wxEmptyString, const wxSize &size=wxDefaultSize, const wxPoint &pos=wxDefaultPosition, long style=wxBU_EXACTFIT|wxNO_BORDER, bool use_default_disabled_bitmap=false, int bmp_px_cnt=16)
 ScalableButton (wxWindow *parent, wxWindowID id, const ScalableBitmap &bitmap, const wxString &label=wxEmptyString, long style=wxBU_EXACTFIT|wxNO_BORDER)
 ~ScalableButton ()
void SetBitmap_ (const ScalableBitmap &bmp)
bool SetBitmap_ (const std::string &bmp_name)
void SetBitmapDisabled_ (const ScalableBitmap &bmp)
int GetBitmapHeight ()
void UseDefaultBitmapDisabled ()
void msw_rescale ()
void UpdateDarkUI ()

Private Attributes

wxWindow * m_parent { nullptr }
std::string m_current_icon_name
std::string m_disabled_icon_name
int m_width {-1}
int m_height {-1}
bool m_use_default_disabled_bitmap {false}
int m_px_cnt { 16 }
bool m_has_border {false}

Detailed Description

Constructor & Destructor Documentation

◆ ScalableButton() [1/3]

ScalableButton::ScalableButton ( )
inline
251{}

Referenced by Slic3r::GUI::ObjectLayers::PlusMinusButton::PlusMinusButton().

Here is the caller graph for this function:

◆ ScalableButton() [2/3]

ScalableButton::ScalableButton ( wxWindow * parent,
wxWindowID id,
const std::string & icon_name = "",
const wxString & label = wxEmptyString,
const wxSize & size = wxDefaultSize,
const wxPoint & pos = wxDefaultPosition,
long style = wxBU_EXACTFIT | wxNO_BORDER,
bool use_default_disabled_bitmap = false,
int bmp_px_cnt = 16 )
1018 :
1019 m_parent(parent),
1020 m_current_icon_name(icon_name),
1021 m_use_default_disabled_bitmap (use_default_disabled_bitmap),
1022 m_px_cnt(bmp_px_cnt),
1023 m_has_border(!(style & wxNO_BORDER))
1024{
1025 SetBackgroundColour(StaticBox::GetParentBackgroundColor(parent));
1026 Create(parent, id, label, pos, size, style);
1027 Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
1028
1029 if (!icon_name.empty()) {
1030 SetBitmap(create_scaled_bitmap(icon_name, parent, m_px_cnt));
1032 SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
1033 if (!label.empty())
1034 SetBitmapMargins(int(0.5* em_unit(parent)), 0);
1035 }
1036
1037 if (size != wxDefaultSize)
1038 {
1039 const int em = em_unit(parent);
1040 m_width = size.x * 10 / em;
1041 m_height= size.y * 10 / em;
1042 }
1043
1044#ifdef __WXGTK__
1045 Slic3r::GUI::RemoveButtonBorder(this);
1046#endif
1047}
#define style
Definition WipeTowerDialog.cpp:101
bool m_use_default_disabled_bitmap
Definition wxExtensions.hpp:288
std::string m_current_icon_name
Definition wxExtensions.hpp:283
int m_height
Definition wxExtensions.hpp:286
int m_px_cnt
Definition wxExtensions.hpp:291
wxWindow * m_parent
Definition wxExtensions.hpp:282
int m_width
Definition wxExtensions.hpp:285
bool m_has_border
Definition wxExtensions.hpp:292
static wxColor GetParentBackgroundColor(wxWindow *parent)
Definition StaticBox.cpp:122
int em_unit(wxWindow *win)
Definition wxExtensions.cpp:424
wxBitmap create_scaled_bitmap(const std::string &bmp_name, wxWindow *win=nullptr, const int px_cnt=16, const bool grayscale=false, const std::string &new_color=std::string(), const bool menu_bitmap=false, const bool resize=false, const bool bitmap2=false, const std::vector< std::string > &array_new_color=std::vector< std::string >())
Definition wxExtensions.cpp:448

References create_scaled_bitmap(), em_unit(), StaticBox::GetParentBackgroundColor(), m_current_icon_name, m_has_border, m_height, m_parent, m_px_cnt, m_use_default_disabled_bitmap, m_width, and style.

Here is the call graph for this function:

◆ ScalableButton() [3/3]

ScalableButton::ScalableButton ( wxWindow * parent,
wxWindowID id,
const ScalableBitmap & bitmap,
const wxString & label = wxEmptyString,
long style = wxBU_EXACTFIT | wxNO_BORDER )
1054 :
1055 m_parent(parent),
1056 m_current_icon_name(bitmap.name()),
1057 m_px_cnt(bitmap.px_cnt()),
1058 m_has_border(!(style& wxNO_BORDER))
1059{
1060 Create(parent, id, label, wxDefaultPosition, wxDefaultSize, style);
1061 Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
1062
1063 SetBitmap(bitmap.bmp());
1064}
const std::string & name() const
Definition wxExtensions.hpp:191
int px_cnt() const
Definition wxExtensions.hpp:193
const wxBitmap & bmp() const
Definition wxExtensions.hpp:189

References ScalableBitmap::bmp(), m_current_icon_name, m_has_border, m_parent, m_px_cnt, and style.

Here is the call graph for this function:

◆ ~ScalableButton()

ScalableButton::~ScalableButton ( )
inline
270{}

Member Function Documentation

◆ GetBitmapHeight()

int ScalableButton::GetBitmapHeight ( )
1100{
1101#ifdef __APPLE__
1102 return GetBitmap().GetScaledHeight();
1103#else
1104 return GetBitmap().GetHeight();
1105#endif
1106}

◆ msw_rescale()

void ScalableButton::msw_rescale ( )
1115{
1116 Slic3r::GUI::wxGetApp().UpdateDarkUI(this, m_has_border);
1117
1118 if (!m_current_icon_name.empty()) {
1120 SetBitmap(bmp);
1121 // BBS: why disappear on hover? why current HBITMAP differ from other
1122 //SetBitmapCurrent(bmp);
1123 //SetBitmapPressed(bmp);
1124 //SetBitmapFocus(bmp);
1125 if (!m_disabled_icon_name.empty())
1128 SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
1129 }
1130
1131 if (m_width > 0 || m_height>0)
1132 {
1133 const int em = em_unit(m_parent);
1134 wxSize size(m_width * em / 10, m_height * em / 10);
1135 SetMinSize(size);
1136 }
1137}
std::string m_disabled_icon_name
Definition wxExtensions.hpp:284

References create_scaled_bitmap(), em_unit(), m_current_icon_name, m_disabled_icon_name, m_has_border, m_height, m_parent, m_px_cnt, m_use_default_disabled_bitmap, and m_width.

Referenced by Slic3r::GUI::ConfigOptionsGroup::msw_rescale(), and UpdateDarkUI().

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

◆ SetBitmap_() [1/2]

void ScalableButton::SetBitmap_ ( const ScalableBitmap & bmp)
1067{
1068 SetBitmap(bmp.bmp());
1069 m_current_icon_name = bmp.name();
1070}

References ScalableBitmap::bmp(), m_current_icon_name, and ScalableBitmap::name().

Referenced by Slic3r::GUI::IMEXModesCtrl::refresh_reset_buttons(), Slic3r::GUI::ObjectSettings::update_settings_list(), and Slic3r::GUI::ObjectTableSettings::update_settings_list().

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

◆ SetBitmap_() [2/2]

bool ScalableButton::SetBitmap_ ( const std::string & bmp_name)
1073{
1074 if (m_current_icon_name == bmp_name)
1075 {
1076 return true;
1077 }
1078
1079 m_current_icon_name = bmp_name;
1080 if (m_current_icon_name.empty())
1081 return false;
1082
1084 SetBitmap(bmp);
1085 SetBitmapCurrent(bmp);
1086 SetBitmapPressed(bmp);
1087 SetBitmapFocus(bmp);
1089 SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
1090 return true;
1091}

References create_scaled_bitmap(), m_current_icon_name, m_parent, m_px_cnt, and m_use_default_disabled_bitmap.

Here is the call graph for this function:

◆ SetBitmapDisabled_()

void ScalableButton::SetBitmapDisabled_ ( const ScalableBitmap & bmp)
1094{
1095 SetBitmapDisabled(bmp.bmp());
1096 m_disabled_icon_name = bmp.name();
1097}

References ScalableBitmap::bmp(), m_disabled_icon_name, and ScalableBitmap::name().

Here is the call graph for this function:

◆ UpdateDarkUI()

void ScalableButton::UpdateDarkUI ( )
inline
279{ msw_rescale(); };
void msw_rescale()
Definition wxExtensions.cpp:1114

References msw_rescale().

Here is the call graph for this function:

◆ UseDefaultBitmapDisabled()

void ScalableButton::UseDefaultBitmapDisabled ( )
1109{
1111 SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
1112}

References create_scaled_bitmap(), m_current_icon_name, m_parent, m_px_cnt, and m_use_default_disabled_bitmap.

Here is the call graph for this function:

Member Data Documentation

◆ m_current_icon_name

std::string ScalableButton::m_current_icon_name
private

◆ m_disabled_icon_name

std::string ScalableButton::m_disabled_icon_name
private

Referenced by msw_rescale(), and SetBitmapDisabled_().

◆ m_has_border

bool ScalableButton::m_has_border {false}
private
292{false};

Referenced by ScalableButton(), ScalableButton(), and msw_rescale().

◆ m_height

int ScalableButton::m_height {-1}
private
286{-1}; // should be multiplied to em_unit

Referenced by ScalableButton(), and msw_rescale().

◆ m_parent

wxWindow* ScalableButton::m_parent { nullptr }
private

◆ m_px_cnt

int ScalableButton::m_px_cnt { 16 }
private

◆ m_use_default_disabled_bitmap

bool ScalableButton::m_use_default_disabled_bitmap {false}
private

◆ m_width

int ScalableButton::m_width {-1}
private
285{-1}; // should be multiplied to em_unit

Referenced by ScalableButton(), and msw_rescale().


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