mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-22 08:22:58 +00:00
70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
#include "RadioBox.hpp"
|
|
|
|
#include "../wxExtensions.hpp"
|
|
|
|
#ifdef __WXGTK__
|
|
#include "../GUI_Utils.hpp"
|
|
#endif
|
|
|
|
namespace Slic3r {
|
|
namespace GUI {
|
|
RadioBox::RadioBox(wxWindow *parent)
|
|
: wxBitmapToggleButton(parent, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE)
|
|
, m_on(this, "radio_on", 18)
|
|
, m_off(this, "radio_off", 18)
|
|
, m_ban(this, "radio_ban", 18)
|
|
{
|
|
// SetBackgroundStyle(wxBG_STYLE_TRANSPARENT);
|
|
if (parent) SetBackgroundColour(parent->GetBackgroundColour());
|
|
// Bind(wxEVT_TOGGLEBUTTON, [this](auto& e) { update(); e.Skip(); });
|
|
update();
|
|
#ifdef __WXGTK__
|
|
Slic3r::GUI::RemoveButtonBorder(this);
|
|
wxSize bestSize = GetBestSize();
|
|
bestSize.IncTo(m_on.GetBmpSize());
|
|
SetSize(bestSize);
|
|
SetMinSize(bestSize);
|
|
#else
|
|
SetSize(m_on.GetBmpSize());
|
|
SetMinSize(m_on.GetBmpSize());
|
|
#endif
|
|
}
|
|
|
|
void RadioBox::SetValue(bool value)
|
|
{
|
|
wxBitmapToggleButton::SetValue(value);
|
|
update();
|
|
}
|
|
|
|
|
|
void RadioBox::Rescale()
|
|
{
|
|
m_on.msw_rescale();
|
|
m_off.msw_rescale();
|
|
update();
|
|
#ifdef __WXGTK__
|
|
wxSize bestSize = GetBestSize();
|
|
bestSize.IncTo(m_on.GetBmpSize());
|
|
SetSize(bestSize);
|
|
SetMinSize(bestSize);
|
|
#else
|
|
SetSize(m_on.GetBmpSize());
|
|
SetMinSize(m_on.GetBmpSize());
|
|
#endif
|
|
}
|
|
|
|
void RadioBox::update() {
|
|
if (IsEnabled())
|
|
{
|
|
SetBitmap((GetValue() ? m_on : m_off).bmp());
|
|
} else
|
|
{
|
|
SetBitmap(m_ban.bmp());
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|