mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-14 00:52:04 +00:00
@@ -13,6 +13,10 @@
|
|||||||
#include <wx/msw/registry.h>
|
#include <wx/msw/registry.h>
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <wx/toplevel.h>
|
#include <wx/toplevel.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
#include <wx/checkbox.h>
|
#include <wx/checkbox.h>
|
||||||
@@ -496,6 +500,60 @@ void fit_in_display(wxTopLevelWindow& window, wxSize desired_size)
|
|||||||
window.SetSize(desired_size);
|
window.SetSize(desired_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
void RemoveButtonBorder(wxWindow* win)
|
||||||
|
{
|
||||||
|
GtkWidget* widget = win->GetHandle();
|
||||||
|
if (!widget) return;
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||||
|
// GTK3+: use CSS provider
|
||||||
|
GtkCssProvider* provider = gtk_css_provider_new();
|
||||||
|
|
||||||
|
const char* css =
|
||||||
|
"button {"
|
||||||
|
" border: none;"
|
||||||
|
" outline: none;"
|
||||||
|
" box-shadow: none;"
|
||||||
|
" padding: 0px;"
|
||||||
|
" margin: 0px;"
|
||||||
|
" min-height: 0px;"
|
||||||
|
" min-width: 0px;"
|
||||||
|
" background: none;"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
// GTK4: no GError argument
|
||||||
|
gtk_css_provider_load_from_data(provider, css, -1);
|
||||||
|
#else
|
||||||
|
// GTK3: has GError argument
|
||||||
|
gtk_css_provider_load_from_data(provider, css, -1, nullptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GtkStyleContext* ctx = gtk_widget_get_style_context(widget);
|
||||||
|
gtk_style_context_add_provider(
|
||||||
|
ctx,
|
||||||
|
GTK_STYLE_PROVIDER(provider),
|
||||||
|
GTK_STYLE_PROVIDER_PRIORITY_USER
|
||||||
|
);
|
||||||
|
g_object_unref(provider);
|
||||||
|
|
||||||
|
#else
|
||||||
|
// GTK2: use rc string, no CSS
|
||||||
|
gtk_rc_parse_string(
|
||||||
|
"style \"no-border\" {"
|
||||||
|
" GtkButton::inner-border = { 0, 0, 0, 0 }"
|
||||||
|
" GtkWidget::focus-line-width = 0"
|
||||||
|
" GtkWidget::focus-padding = 0"
|
||||||
|
" xthickness = 0"
|
||||||
|
" ythickness = 0"
|
||||||
|
"}"
|
||||||
|
"widget \"*.GtkBitmapToggleButton\" style \"no-border\""
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif // __WXGTK__
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
// Detect if the application is running inside a debugger.
|
// Detect if the application is running inside a debugger.
|
||||||
// https://stackoverflow.com/a/69842462/3289421
|
// https://stackoverflow.com/a/69842462/3289421
|
||||||
|
|||||||
@@ -461,6 +461,10 @@ void dataview_remove_insets(wxDataViewCtrl* dv);
|
|||||||
void staticbox_remove_margin(wxStaticBox* sb);
|
void staticbox_remove_margin(wxStaticBox* sb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __WXGTK3__
|
||||||
|
void RemoveButtonBorder(wxWindow* win);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__WXOSX__) || defined(__linux__)
|
#if defined(__WXOSX__) || defined(__linux__)
|
||||||
bool is_debugger_present();
|
bool is_debugger_present();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
#include "../wxExtensions.hpp"
|
#include "../wxExtensions.hpp"
|
||||||
|
|
||||||
|
#ifdef __WXGTK3__
|
||||||
|
#include "../GUI_Utils.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
CheckBox::CheckBox(wxWindow *parent, int id)
|
CheckBox::CheckBox(wxWindow *parent, int id)
|
||||||
: wxBitmapToggleButton(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE)
|
: wxBitmapToggleButton(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE)
|
||||||
, m_on(this, "check_on", 18)
|
, m_on(this, "check_on", 18)
|
||||||
@@ -24,16 +28,12 @@ CheckBox::CheckBox(wxWindow *parent, int id)
|
|||||||
Bind(wxEVT_ENTER_WINDOW, &CheckBox::updateBitmap, this);
|
Bind(wxEVT_ENTER_WINDOW, &CheckBox::updateBitmap, this);
|
||||||
Bind(wxEVT_LEAVE_WINDOW, &CheckBox::updateBitmap, this);
|
Bind(wxEVT_LEAVE_WINDOW, &CheckBox::updateBitmap, this);
|
||||||
#endif
|
#endif
|
||||||
update();
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK3__
|
||||||
wxSize bestSize = GetBestSize();
|
Slic3r::GUI::RemoveButtonBorder(this);
|
||||||
bestSize.IncTo(m_on.GetBmpSize());
|
|
||||||
SetSize(bestSize);
|
|
||||||
SetMinSize(bestSize);
|
|
||||||
#else
|
|
||||||
SetSize(m_on.GetBmpSize());
|
|
||||||
SetMinSize(m_on.GetBmpSize());
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Rescale();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckBox::SetValue(bool value)
|
void CheckBox::SetValue(bool value)
|
||||||
@@ -61,16 +61,9 @@ void CheckBox::Rescale()
|
|||||||
m_on_focused.msw_rescale();
|
m_on_focused.msw_rescale();
|
||||||
m_half_focused.msw_rescale();
|
m_half_focused.msw_rescale();
|
||||||
m_off_focused.msw_rescale();
|
m_off_focused.msw_rescale();
|
||||||
update();
|
|
||||||
#ifdef __WXGTK__
|
|
||||||
wxSize bestSize = GetBestSize();
|
|
||||||
bestSize.IncTo(m_on.GetBmpSize());
|
|
||||||
SetSize(bestSize);
|
|
||||||
SetMinSize(bestSize);
|
|
||||||
#else
|
|
||||||
SetSize(m_on.GetBmpSize());
|
SetSize(m_on.GetBmpSize());
|
||||||
SetMinSize(m_on.GetBmpSize());
|
SetMinSize(m_on.GetBmpSize());
|
||||||
#endif
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckBox::update()
|
void CheckBox::update()
|
||||||
|
|||||||
@@ -11,6 +11,10 @@
|
|||||||
#include "libslic3r/MacUtils.hpp"
|
#include "libslic3r/MacUtils.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __WXGTK3__
|
||||||
|
#include "../GUI_Utils.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <wx/dcmemory.h>
|
#include <wx/dcmemory.h>
|
||||||
#include <wx/dcclient.h>
|
#include <wx/dcclient.h>
|
||||||
#include <wx/dcgraph.h>
|
#include <wx/dcgraph.h>
|
||||||
@@ -28,6 +32,11 @@ SwitchButton::SwitchButton(wxWindow* parent, wxWindowID id)
|
|||||||
SetBackgroundColour(StaticBox::GetParentBackgroundColor(parent));
|
SetBackgroundColour(StaticBox::GetParentBackgroundColor(parent));
|
||||||
Bind(wxEVT_TOGGLEBUTTON, [this](auto& e) { update(); e.Skip(); });
|
Bind(wxEVT_TOGGLEBUTTON, [this](auto& e) { update(); e.Skip(); });
|
||||||
SetFont(Label::Body_12);
|
SetFont(Label::Body_12);
|
||||||
|
|
||||||
|
#ifdef __WXGTK3__
|
||||||
|
Slic3r::GUI::RemoveButtonBorder(this);
|
||||||
|
#endif
|
||||||
|
|
||||||
Rescale();
|
Rescale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user