Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
ScalableButton Class Reference

#include <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, 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 ()
 
virtual void sys_color_changed ()
 

Protected Attributes

int m_px_cnt { 16 }
 
bool m_has_border {false}
 

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}
 

Detailed Description

Constructor & Destructor Documentation

◆ ScalableButton() [1/3]

ScalableButton::ScalableButton ( )
inline
219{}

◆ 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,
int  bmp_px_cnt = 16 
)
809 :
810 m_parent(parent),
811 m_current_icon_name(icon_name),
812 m_px_cnt(bmp_px_cnt),
813 m_has_border(!(style & wxNO_BORDER))
814{
815 Create(parent, id, label, pos, size, style);
816 Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
817
818 if (!icon_name.empty()) {
819 SetBitmap(*get_bmp_bundle(icon_name, m_px_cnt));
820 if (!label.empty())
821 SetBitmapMargins(int(0.5* em_unit(parent)), 0);
822 }
823
824 if (size != wxDefaultSize)
825 {
826 const int em = em_unit(parent);
827 m_width = size.x/em;
828 m_height= size.y/em;
829 }
830}
#define style
Definition WipeTowerDialog.cpp:68
std::string m_current_icon_name
Definition wxExtensions.hpp:248
int m_height
Definition wxExtensions.hpp:251
int m_px_cnt
Definition wxExtensions.hpp:255
wxWindow * m_parent
Definition wxExtensions.hpp:247
int m_width
Definition wxExtensions.hpp:250
bool m_has_border
Definition wxExtensions.hpp:256
constexpr auto size(const C &c) -> decltype(c.size())
Definition span.hpp:183
int em_unit(wxWindow *win)
Definition wxExtensions.cpp:388
wxBitmapBundle * get_bmp_bundle(const std::string &bmp_name, int px_cnt=16, const std::string &new_color_rgb=std::string())
Definition wxExtensions.cpp:420

References em_unit(), get_bmp_bundle(), m_height, m_px_cnt, 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 
)
837 :
838 m_parent(parent),
839 m_current_icon_name(bitmap.name()),
840 m_px_cnt(bitmap.px_cnt()),
841 m_has_border(!(style& wxNO_BORDER))
842{
843 Create(parent, id, label, wxDefaultPosition, wxDefaultSize, style);
844 Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
845
846 SetBitmap(bitmap.bmp());
847}
const std::string & name() const
Definition wxExtensions.hpp:151
const wxBitmapBundle & bmp() const
Definition wxExtensions.hpp:148
int px_cnt() const
Definition wxExtensions.hpp:152

References ScalableBitmap::bmp(), and style.

+ Here is the call graph for this function:

◆ ~ScalableButton()

ScalableButton::~ScalableButton ( )
inline
237{}

Member Function Documentation

◆ GetBitmapHeight()

int ScalableButton::GetBitmapHeight ( )
877{
878#ifdef __APPLE__
879 return GetBitmap().GetScaledHeight();
880#else
881 return GetBitmap().GetHeight();
882#endif
883}

◆ SetBitmap_() [1/2]

void ScalableButton::SetBitmap_ ( const ScalableBitmap bmp)
850{
851 SetBitmap(bmp.bmp());
853}

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

Referenced by Slic3r::GUI::ObjectSettings::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)
856{
857 m_current_icon_name = bmp_name;
858 if (m_current_icon_name.empty())
859 return false;
860
861 wxBitmapBundle bmp = *get_bmp_bundle(m_current_icon_name, m_px_cnt);
862 SetBitmap(bmp);
863 SetBitmapCurrent(bmp);
864 SetBitmapPressed(bmp);
865 SetBitmapFocus(bmp);
866 SetBitmapDisabled(bmp);
867 return true;
868}

References get_bmp_bundle(), m_current_icon_name, and m_px_cnt.

+ Here is the call graph for this function:

◆ SetBitmapDisabled_()

void ScalableButton::SetBitmapDisabled_ ( const ScalableBitmap bmp)
871{
872 SetBitmapDisabled(bmp.bmp());
874}
std::string m_disabled_icon_name
Definition wxExtensions.hpp:249

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

+ Here is the call graph for this function:

◆ sys_color_changed()

void ScalableButton::sys_color_changed ( )
virtual

Reimplemented in ModeButton.

886{
887 Slic3r::GUI::wxGetApp().UpdateDarkUI(this, m_has_border);
888
889 wxBitmapBundle bmp = *get_bmp_bundle(m_current_icon_name, m_px_cnt);
890 SetBitmap(bmp);
891 SetBitmapCurrent(bmp);
892 SetBitmapPressed(bmp);
893 SetBitmapFocus(bmp);
894 if (!m_disabled_icon_name.empty())
895 SetBitmapDisabled(*get_bmp_bundle(m_disabled_icon_name, m_px_cnt));
896 if (!GetLabelText().IsEmpty())
897 SetBitmapMargins(int(0.5 * em_unit(m_parent)), 0);
898}

References em_unit(), get_bmp_bundle(), m_current_icon_name, m_disabled_icon_name, m_has_border, m_parent, and m_px_cnt.

Referenced by Slic3r::GUI::PresetForPrinter::on_sys_color_changed(), Slic3r::GUI::PhysicalPrinterDialog::on_sys_color_changed(), Slic3r::GUI::ObjectManipulation::sys_color_changed(), and Slic3r::GUI::PlaterPresetComboBox::sys_color_changed().

+ Here is the call graph for this function:
+ Here is the caller 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

◆ m_has_border

bool ScalableButton::m_has_border {false}
protected

◆ m_height

int ScalableButton::m_height {-1}
private

Referenced by ScalableButton().

◆ m_parent

wxWindow* ScalableButton::m_parent { nullptr }
private

Referenced by sys_color_changed().

◆ m_px_cnt

int ScalableButton::m_px_cnt { 16 }
protected

◆ m_width

int ScalableButton::m_width {-1}
private

Referenced by ScalableButton().


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