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

#include <src/slic3r/GUI/wxExtensions.hpp>

+ Inheritance diagram for ModeButton:
+ Collaboration diagram for ModeButton:

Public Member Functions

 ModeButton (wxWindow *parent, wxWindowID id, const std::string &icon_name="", const wxString &mode=wxEmptyString, const wxSize &size=wxDefaultSize, const wxPoint &pos=wxDefaultPosition)
 
 ModeButton (wxWindow *parent, const wxString &mode=wxEmptyString, const std::string &icon_name="", int px_cnt=16)
 
 ModeButton (wxWindow *parent, int mode_id, const wxString &mode=wxEmptyString, int px_cnt=16)
 
 ~ModeButton ()
 
void Init (const wxString &mode)
 
void OnButton (wxCommandEvent &event)
 
void OnEnterBtn (wxMouseEvent &event)
 
void OnLeaveBtn (wxMouseEvent &event)
 
void SetState (const bool state)
 
void update_bitmap ()
 
bool is_selected ()
 
void sys_color_changed () override
 
void SetBitmap_ (const ScalableBitmap &bmp)
 
bool SetBitmap_ (const std::string &bmp_name)
 
void SetBitmapDisabled_ (const ScalableBitmap &bmp)
 
int GetBitmapHeight ()
 

Protected Member Functions

void focus_button (const bool focus)
 

Protected Attributes

int m_px_cnt { 16 }
 
bool m_has_border {false}
 

Private Attributes

bool m_is_selected {false}
 
int m_mode_id {-1}
 
wxString m_tt_selected
 
wxString m_tt_focused
 
wxBitmapBundle m_bmp
 
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

◆ ModeButton() [1/3]

ModeButton::ModeButton ( wxWindow *  parent,
wxWindowID  id,
const std::string &  icon_name = "",
const wxString &  mode = wxEmptyString,
const wxSize &  size = wxDefaultSize,
const wxPoint &  pos = wxDefaultPosition 
)
600 :
601 ScalableButton(parent, id, icon_name, mode, size, pos, wxBU_EXACTFIT)
602{
603 Init(mode);
604}
void Init(const wxString &mode)
Definition wxExtensions.cpp:626
ScalableButton()
Definition wxExtensions.hpp:219

References Init().

+ Here is the call graph for this function:

◆ ModeButton() [2/3]

ModeButton::ModeButton ( wxWindow *  parent,
const wxString &  mode = wxEmptyString,
const std::string &  icon_name = "",
int  px_cnt = 16 
)
609 :
610 ScalableButton(parent, wxID_ANY, icon_name, mode, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT, px_cnt)
611{
612 Init(mode);
613}

References Init().

+ Here is the call graph for this function:

◆ ModeButton() [3/3]

ModeButton::ModeButton ( wxWindow *  parent,
int  mode_id,
const wxString &  mode = wxEmptyString,
int  px_cnt = 16 
)
618 :
619 ScalableButton(parent, wxID_ANY, "", mode, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT, px_cnt),
620 m_mode_id(mode_id)
621{
623 Init(mode);
624}
int m_mode_id
Definition wxExtensions.hpp:305
void update_bitmap()
Definition wxExtensions.cpp:654

References Init(), and update_bitmap().

+ Here is the call graph for this function:

◆ ~ModeButton()

ModeButton::~ModeButton ( )
inline
287{}

Member Function Documentation

◆ focus_button()

void ModeButton::focus_button ( const bool  focus)
protected
664{
665 const wxFont& new_font = focus ?
666 Slic3r::GUI::wxGetApp().bold_font() :
667 Slic3r::GUI::wxGetApp().normal_font();
668
669 SetFont(new_font);
670#ifdef _WIN32
671 GetParent()->Refresh(); // force redraw a background of the selected mode button
672#else
673 SetForegroundColour(wxSystemSettings::GetColour(focus ? wxSYS_COLOUR_BTNTEXT :
674#if defined (__linux__) && defined (__WXGTK3__)
675 wxSYS_COLOUR_GRAYTEXT
676#elif defined (__linux__) && defined (__WXGTK2__)
677 wxSYS_COLOUR_BTNTEXT
678#else
679 wxSYS_COLOUR_BTNSHADOW
680#endif
681 ));
682#endif /* no _WIN32 */
683
684 Refresh();
685 Update();
686}
if(!(yy_init))
Definition lexer.c:1190

Referenced by OnButton(), OnEnterBtn(), OnLeaveBtn(), and SetState().

+ Here is the caller graph for this function:

◆ GetBitmapHeight()

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

◆ Init()

void ModeButton::Init ( const wxString &  mode)
627{
628 m_tt_focused = Slic3r::GUI::format_wxstr(_L("Switch to the %s mode"), mode);
629 m_tt_selected = Slic3r::GUI::format_wxstr(_L("Current mode is %s"), mode);
630
631 SetBitmapMargins(3, 0);
632
633 //button events
635 Bind(wxEVT_ENTER_WINDOW, &ModeButton::OnEnterBtn, this);
636 Bind(wxEVT_LEAVE_WINDOW, &ModeButton::OnLeaveBtn, this);
637}
void OnLeaveBtn(wxMouseEvent &event)
Definition wxExtensions.hpp:293
void OnEnterBtn(wxMouseEvent &event)
Definition wxExtensions.hpp:292
wxString m_tt_selected
Definition wxExtensions.hpp:307
wxString m_tt_focused
Definition wxExtensions.hpp:308
void OnButton(wxCommandEvent &event)
Definition wxExtensions.cpp:639
wxString format_wxstr(const char *fmt, TArgs &&... args)
Definition format.hpp:42
#define _L(s)
Definition I18N.hpp:3
#define wxEVT_BUTTON
Definition wxinit.h:18

References _L, Slic3r::GUI::format_wxstr(), m_tt_focused, m_tt_selected, OnButton(), OnEnterBtn(), OnLeaveBtn(), and wxEVT_BUTTON.

Referenced by ModeButton(), ModeButton(), and ModeButton().

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

◆ is_selected()

bool ModeButton::is_selected ( )
inline
297{ return m_is_selected; }
bool m_is_selected
Definition wxExtensions.hpp:304

References m_is_selected.

◆ OnButton()

void ModeButton::OnButton ( wxCommandEvent &  event)
640{
641 m_is_selected = true;
643
644 event.Skip();
645}
void focus_button(const bool focus)
Definition wxExtensions.cpp:663

References focus_button(), and m_is_selected.

Referenced by Init().

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

◆ OnEnterBtn()

void ModeButton::OnEnterBtn ( wxMouseEvent &  event)
inline
292{ focus_button(true); event.Skip(); }

References focus_button().

Referenced by Init().

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

◆ OnLeaveBtn()

void ModeButton::OnLeaveBtn ( wxMouseEvent &  event)
inline
293{ focus_button(m_is_selected); event.Skip(); }

References focus_button(), and m_is_selected.

Referenced by Init().

+ 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)
inherited
850{
851 SetBitmap(bmp.bmp());
853}
const std::string & name() const
Definition wxExtensions.hpp:151
const wxBitmapBundle & bmp() const
Definition wxExtensions.hpp:148
std::string m_current_icon_name
Definition wxExtensions.hpp:248

References ScalableBitmap::bmp(), ScalableButton::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)
inherited
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}
int m_px_cnt
Definition wxExtensions.hpp:255
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 get_bmp_bundle(), ScalableButton::m_current_icon_name, and ScalableButton::m_px_cnt.

+ Here is the call graph for this function:

◆ SetBitmapDisabled_()

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

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

+ Here is the call graph for this function:

◆ SetState()

void ModeButton::SetState ( const bool  state)
648{
649 m_is_selected = state;
651 SetToolTip(state ? m_tt_selected : m_tt_focused);
652}

References focus_button(), m_is_selected, m_tt_focused, and m_tt_selected.

+ Here is the call graph for this function:

◆ sys_color_changed()

void ModeButton::sys_color_changed ( )
overridevirtual

Reimplemented from ScalableButton.

689{
690 Slic3r::GUI::wxGetApp().UpdateDarkUI(this, m_has_border);
692}
bool m_has_border
Definition wxExtensions.hpp:256

References ScalableButton::m_has_border, and update_bitmap().

+ Here is the call graph for this function:

◆ update_bitmap()

void ModeButton::update_bitmap ( )
655{
656 m_bmp = *get_bmp_bundle("mode", m_px_cnt, Slic3r::GUI::wxGetApp().get_mode_btn_color(m_mode_id));
657
658 SetBitmap(m_bmp);
659 SetBitmapCurrent(m_bmp);
660 SetBitmapPressed(m_bmp);
661}
wxBitmapBundle m_bmp
Definition wxExtensions.hpp:309

References get_bmp_bundle(), m_bmp, m_mode_id, and ScalableButton::m_px_cnt.

Referenced by ModeButton(), and sys_color_changed().

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

Member Data Documentation

◆ m_bmp

wxBitmapBundle ModeButton::m_bmp
private

Referenced by update_bitmap().

◆ m_current_icon_name

std::string ScalableButton::m_current_icon_name
privateinherited

◆ m_disabled_icon_name

std::string ScalableButton::m_disabled_icon_name
privateinherited

◆ m_has_border

bool ScalableButton::m_has_border {false}
protectedinherited

◆ m_height

int ScalableButton::m_height {-1}
privateinherited

◆ m_is_selected

bool ModeButton::m_is_selected {false}
private

◆ m_mode_id

int ModeButton::m_mode_id {-1}
private

Referenced by update_bitmap().

◆ m_parent

wxWindow* ScalableButton::m_parent { nullptr }
privateinherited

◆ m_px_cnt

int ScalableButton::m_px_cnt { 16 }
protectedinherited

◆ m_tt_focused

wxString ModeButton::m_tt_focused
private

Referenced by Init(), and SetState().

◆ m_tt_selected

wxString ModeButton::m_tt_selected
private

Referenced by Init(), and SetState().

◆ m_width

int ScalableButton::m_width {-1}
privateinherited

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