BambuStudio/src/slic3r/GUI/Widgets/ImageSwitchButton.hpp

59 lines
1.5 KiB
C++
Raw Normal View History

#ifndef slic3r_GUI_ImageSwitchButton_hpp_
#define slic3r_GUI_ImageSwitchButton_hpp_
#include "../wxExtensions.hpp"
#include "StateColor.hpp"
#include "StateHandler.hpp"
#include "Button.hpp"
#include <wx/tglbtn.h>
class ImageSwitchButton : public StaticBox
{
public:
ImageSwitchButton(wxWindow *parent, ScalableBitmap &img_on, ScalableBitmap &img_off, long style = 0);
void SetLabels(wxString const & lbl_on, wxString const & lbl_off);
void SetImages(ScalableBitmap &img_on, ScalableBitmap &img_off);
void SetTextColor(StateColor const &color);
void SetBorderColor(StateColor const &color);
void SetBgColor(StateColor const &color);
void SetValue(bool value);
void SetPadding(int padding);
bool GetValue() { return m_on_off; }
void Rescale();
private:
void messureSize();
void paintEvent(wxPaintEvent &evt);
void render(wxDC& dc);
void mouseDown(wxMouseEvent &event);
void mouseReleased(wxMouseEvent &event);
void mouseEnterWindow(wxMouseEvent &event);
void mouseLeaveWindow(wxMouseEvent &event);
void sendButtonEvent();
DECLARE_EVENT_TABLE()
private:
ScalableBitmap m_on;
ScalableBitmap m_off;
bool m_on_off;
int m_padding; // size between icon and text
bool pressedDown = false;
bool hover = false;
wxSize textSize;
wxSize minSize;
wxString labels[2];
StateColor text_color;
StateColor bg_color;
StateColor border_color;
StateHandler state_handler;
};
#endif // !slic3r_GUI_SwitchButton_hpp_