* Add button styling * Fix dark mode compability * printable area button * Connection dialog icons * Add aligment control * Fix alignment * add new styles * Update BedShapeDialog.cpp * Use darker text color on dark mode * update code * Update * update * Update * Update WipeTowerDialog.cpp * update * Update Button.cpp * update * Update Button.cpp * add enums for style and type * update * Update Button.cpp * fix * update * Update DialogButtons.cpp * Update UnsavedChangesDialog.cpp * update * update * update * Update Button.cpp * cleanup --------- Co-authored-by: Noisyfox <timemanager.rick@gmail.com>
116 lines
2.8 KiB
C++
116 lines
2.8 KiB
C++
#ifndef slic3r_GUI_Button_hpp_
|
|
#define slic3r_GUI_Button_hpp_
|
|
|
|
#include "../wxExtensions.hpp"
|
|
#include "StaticBox.hpp"
|
|
|
|
class ButtonProps
|
|
{
|
|
public:
|
|
static int ChoiceButtonGap(){return 10;};
|
|
static int WindowButtonGap(){return 10;};
|
|
};
|
|
|
|
enum class ButtonStyle{
|
|
Regular,
|
|
Confirm,
|
|
Alert,
|
|
Disabled,
|
|
};
|
|
|
|
enum class ButtonType{
|
|
Compact , // Font10 FullyRounded For spaces with less areas
|
|
Window , // Font12 FullyRounded For regular buttons in windows and not related with parameter boxes
|
|
Choice , // Font14 Semi-Rounded For dialog/window choice buttons
|
|
Parameter, // Font14 Semi-Rounded For buttons that near parameter boxes
|
|
Expanded , // Font14 Semi-Rounded For full length buttons. ex. buttons in static box
|
|
};
|
|
|
|
class Button : public StaticBox
|
|
{
|
|
wxRect textSize;
|
|
wxSize minSize; // set by outer
|
|
wxSize paddingSize;
|
|
ScalableBitmap active_icon;
|
|
ScalableBitmap inactive_icon;
|
|
|
|
StateColor text_color;
|
|
|
|
bool pressedDown = false;
|
|
bool m_selected = true;
|
|
bool canFocus = true;
|
|
bool isCenter = true;
|
|
|
|
static const int buttonWidth = 200;
|
|
static const int buttonHeight = 50;
|
|
|
|
public:
|
|
Button();
|
|
|
|
Button(wxWindow* parent, wxString text, wxString icon = "", long style = 0, int iconSize = 0, wxWindowID btn_id = wxID_ANY);
|
|
|
|
bool Create(wxWindow* parent, wxString text, wxString icon = "", long style = 0, int iconSize = 0, wxWindowID btn_id = wxID_ANY);
|
|
|
|
void SetLabel(const wxString& label) override;
|
|
|
|
bool SetFont(const wxFont& font) override;
|
|
|
|
void SetIcon(const wxString& icon);
|
|
|
|
void SetInactiveIcon(const wxString& icon);
|
|
|
|
void SetMinSize(const wxSize& size) override;
|
|
|
|
void SetPaddingSize(const wxSize& size);
|
|
|
|
void SetStyle(const ButtonStyle style /*= ButtonStyle::Regular*/, const ButtonType type /*= ButtonType::None*/);
|
|
|
|
void SetTextColor(StateColor const &color);
|
|
|
|
void SetTextColorNormal(wxColor const &color);
|
|
|
|
void SetSelected(bool selected = true) { m_selected = selected; }
|
|
|
|
bool Enable(bool enable = true) override;
|
|
|
|
void SetCanFocus(bool canFocus) override;
|
|
|
|
void SetValue(bool state);
|
|
|
|
bool GetValue() const;
|
|
|
|
void SetCenter(bool isCenter);
|
|
|
|
void Rescale();
|
|
|
|
protected:
|
|
#ifdef __WIN32__
|
|
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) override;
|
|
#endif
|
|
|
|
bool AcceptsFocus() const override;
|
|
|
|
private:
|
|
bool m_has_style = false;
|
|
ButtonStyle m_style;
|
|
ButtonType m_type;
|
|
|
|
void paintEvent(wxPaintEvent& evt);
|
|
|
|
void render(wxDC& dc);
|
|
|
|
void messureSize();
|
|
|
|
// some useful events
|
|
void mouseDown(wxMouseEvent& event);
|
|
void mouseReleased(wxMouseEvent& event);
|
|
void mouseCaptureLost(wxMouseCaptureLostEvent &event);
|
|
void keyDownUp(wxKeyEvent &event);
|
|
|
|
void sendButtonEvent();
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
};
|
|
|
|
#endif // !slic3r_GUI_Button_hpp_
|