Files
OrcaSlicer/src/slic3r/GUI/Widgets/RadioBox.cpp
T
yw4z 477208a969 Remove borders and paddings from native controls on Linux (#14873)
* init

* update

* Update SpinInput.cpp

* possible fix for em_unit

* button alignment

* match titlebar height

* revert em_value for macOS and Windows

* Update GUI_Utils.hpp

* Merge branch 'main' into linux-black-borders-2

* Revert "button alignment"

This reverts commit 3fc7461071.

* Revert "match titlebar height"

This reverts commit c4aa1d9f1e.

* revert dpi changes

* match platform tags

* remove radio box borders

* Fix code indent
2026-08-01 11:28:07 +08:00

75 lines
1.5 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();
}
bool RadioBox::GetValue()
{
return wxBitmapToggleButton::GetValue();
}
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());
}
}
}
}