mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-06 07:11:10 +00:00
* Ignore Clipper, libpng, mcut and Boost.Polygon Internals in clang-tidy Each only works through a wrapper or umbrella header: libslic3r/clipper.hpp or clipper_z.hpp configure Clipper before including it, png.h pulls in libpng's config headers, and Boost.Polygon's headers only compile through polygon.hpp or voronoi.hpp. * Ignore minilzo's Config Headers in clang-tidy lzoconf.h and lzodefs.h are internal to minilzo.h, which is what the code includes. * Add Missing Includes Across the Remaining Sources and Tests Covers src/slic3r/Utils, src/slic3r/plugin, src/slic3r/Config, src/libvgcode, src/dev-utils, src/OrcaSlicer.cpp and tests/, the directories left after src/slic3r/GUI and src/libslic3r. Generated with clang-tidy misc-include-cleaner. libvgcode's own headers are included by relative path as in the rest of that library, and Catch2 and pybind11 with angle brackets as elsewhere in the repo. * Make the GUI and Test Headers Compile on Their Own Each now includes, or forward-declares, what it uses instead of relying on what its includers happened to include first. Headers that only compile on one platform, or that nothing built includes, are left alone. * Keep Windows and nanosvg Setup Ahead of the Added Includes OrcaSlicer.cpp and several tests set _WIN32_WINNT, WIN32_LEAN_AND_MEAN or NOMINMAX before including Windows.h, and the profile validator defines NANOSVG_IMPLEMENTATION before any libslic3r header. The added includes had landed above those blocks, which broke the Windows build. * Add the GUI Includes the First Pass Missed Covers headers that only became editable once they compiled on their own, and wx symbols whose suggested header changed as the clang-tidy ignore list grew after the src/slic3r/GUI pass. * Keep the Added Test Includes Below the NOMINMAX Guard test_marchingsquares.cpp and test_texture_displacement.cpp had includes inside #ifndef NOMINMAX, which the tests inherit as defined on Windows from libslic3r, so those were skipped there. .clang-tidy also ignores the MSVC STL and UCRT internals, Boost.Multiprecision's fwd.hpp and CPython's Windows include directory, as in #16068.
140 lines
3.6 KiB
C++
140 lines
3.6 KiB
C++
#include "CheckBox.hpp"
|
|
|
|
#include "../wxExtensions.hpp"
|
|
#include <wx/anybutton.h>
|
|
#include <wx/gdicmn.h>
|
|
#include <wx/checklst.h>
|
|
#include <wx/tglbtn.h>
|
|
|
|
#ifdef __WXGTK__
|
|
#include "../GUI_Utils.hpp"
|
|
#endif
|
|
|
|
CheckBox::CheckBox(wxWindow *parent, int id)
|
|
: wxBitmapToggleButton(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE)
|
|
, m_on(this, "check_on", 18)
|
|
, m_half(this, "check_half", 18)
|
|
, m_off(this, "check_off", 18)
|
|
, m_on_disabled(this, "check_on_disabled", 18)
|
|
, m_half_disabled(this, "check_half_disabled", 18)
|
|
, m_off_disabled(this, "check_off_disabled", 18)
|
|
, m_on_focused(this, "check_on_focused", 18)
|
|
, m_half_focused(this, "check_half_focused", 18)
|
|
, m_off_focused(this, "check_off_focused", 18)
|
|
{
|
|
//SetBackgroundStyle(wxBG_STYLE_TRANSPARENT);
|
|
if (parent)
|
|
SetBackgroundColour(parent->GetBackgroundColour());
|
|
Bind(wxEVT_TOGGLEBUTTON, [this](auto& e) { m_half_checked = false; update(); e.Skip(); });
|
|
#ifdef __WXOSX__ // State not fully implement on MacOS
|
|
Bind(wxEVT_SET_FOCUS, &CheckBox::updateBitmap, this);
|
|
Bind(wxEVT_KILL_FOCUS, &CheckBox::updateBitmap, this);
|
|
Bind(wxEVT_ENTER_WINDOW, &CheckBox::updateBitmap, this);
|
|
Bind(wxEVT_LEAVE_WINDOW, &CheckBox::updateBitmap, this);
|
|
#endif
|
|
|
|
#ifdef __WXGTK__
|
|
Slic3r::GUI::RemoveButtonBorder(this);
|
|
#endif
|
|
|
|
Rescale();
|
|
}
|
|
|
|
void CheckBox::SetValue(bool value)
|
|
{
|
|
if (wxBitmapToggleButton::GetValue() != value) {
|
|
wxBitmapToggleButton::SetValue(value);
|
|
update();
|
|
}
|
|
}
|
|
|
|
void CheckBox::SetHalfChecked(bool value)
|
|
{
|
|
m_half_checked = value;
|
|
update();
|
|
}
|
|
|
|
void CheckBox::Rescale()
|
|
{
|
|
m_on.msw_rescale();
|
|
m_half.msw_rescale();
|
|
m_off.msw_rescale();
|
|
m_on_disabled.msw_rescale();
|
|
m_half_disabled.msw_rescale();
|
|
m_off_disabled.msw_rescale();
|
|
m_on_focused.msw_rescale();
|
|
m_half_focused.msw_rescale();
|
|
m_off_focused.msw_rescale();
|
|
SetSize(m_on.GetBmpSize());
|
|
SetMinSize(m_on.GetBmpSize());
|
|
update();
|
|
}
|
|
|
|
void CheckBox::update()
|
|
{
|
|
SetBitmapLabel((m_half_checked ? m_half : GetValue() ? m_on : m_off).bmp());
|
|
SetBitmapDisabled((m_half_checked ? m_half_disabled : GetValue() ? m_on_disabled : m_off_disabled).bmp());
|
|
#ifdef __WXMSW__
|
|
SetBitmapFocus((m_half_checked ? m_half_focused : GetValue() ? m_on_focused : m_off_focused).bmp());
|
|
#endif
|
|
SetBitmapCurrent((m_half_checked ? m_half_focused : GetValue() ? m_on_focused : m_off_focused).bmp());
|
|
#ifdef __WXOSX__
|
|
wxCommandEvent e(wxEVT_UPDATE_UI);
|
|
updateBitmap(e);
|
|
#endif
|
|
}
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
CheckBox::State CheckBox::GetNormalState() const { return State_Normal; }
|
|
|
|
#endif
|
|
|
|
|
|
#ifdef __WXOSX__
|
|
|
|
bool CheckBox::Enable(bool enable)
|
|
{
|
|
bool result = wxBitmapToggleButton::Enable(enable);
|
|
if (result) {
|
|
m_disable = !enable;
|
|
wxCommandEvent e(wxEVT_ACTIVATE);
|
|
updateBitmap(e);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
wxBitmap CheckBox::DoGetBitmap(State which) const
|
|
{
|
|
if (m_disable) {
|
|
return wxBitmapToggleButton::DoGetBitmap(State_Disabled);
|
|
}
|
|
if (m_focus) {
|
|
return wxBitmapToggleButton::DoGetBitmap(State_Current);
|
|
}
|
|
return wxBitmapToggleButton::DoGetBitmap(which);
|
|
}
|
|
|
|
void CheckBox::updateBitmap(wxEvent & evt)
|
|
{
|
|
evt.Skip();
|
|
if (evt.GetEventType() == wxEVT_ENTER_WINDOW) {
|
|
m_hover = true;
|
|
} else if (evt.GetEventType() == wxEVT_LEAVE_WINDOW) {
|
|
m_hover = false;
|
|
} else {
|
|
if (evt.GetEventType() == wxEVT_SET_FOCUS) {
|
|
m_focus = true;
|
|
} else if (evt.GetEventType() == wxEVT_KILL_FOCUS) {
|
|
m_focus = false;
|
|
}
|
|
wxMouseEvent e;
|
|
if (m_hover)
|
|
OnEnterWindow(e);
|
|
else
|
|
OnLeaveWindow(e);
|
|
}
|
|
}
|
|
|
|
#endif
|