Move GTK3 wxNO_BORDER handling to wxControl
So wxNO_BORDER works with other controls, such as wxBitmapButton. Also use GTK prefix on ApplyCssStyle(), and add an overload that creates the GtkCssProvider.
This commit is contained in:
parent
ef0309c141
commit
21620da3e5
@ -412,7 +412,8 @@ protected:
|
||||
#ifdef __WXGTK3__
|
||||
// Use the given CSS string for styling the widget. The provider must be
|
||||
// allocated, and remains owned, by the caller.
|
||||
void ApplyCssStyle(GtkCssProvider* provider, const char* style);
|
||||
void GTKApplyCssStyle(GtkCssProvider* provider, const char* style);
|
||||
void GTKApplyCssStyle(const char* style);
|
||||
#else // GTK+ < 3
|
||||
// Called by ApplyWidgetStyle (which is called by SetFont() and
|
||||
// SetXXXColour etc to apply style changed to native widgets) to create
|
||||
|
@ -457,7 +457,8 @@ void ButtonWidgetsPage::CreateButton()
|
||||
if ( m_chkUseBitmapClass->GetValue() )
|
||||
{
|
||||
bbtn = new wxBitmapButton(this, ButtonPage_Button,
|
||||
CreateBitmap(wxT("normal")));
|
||||
CreateBitmap(wxT("normal")),
|
||||
wxDefaultPosition, wxDefaultSize, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -97,6 +97,11 @@ void wxControl::PostCreation(const wxSize& size)
|
||||
{
|
||||
wxWindow::PostCreation();
|
||||
|
||||
#ifdef __WXGTK3__
|
||||
if (HasFlag(wxNO_BORDER))
|
||||
GTKApplyCssStyle("*{ border:none; border-radius:0; padding:0 }");
|
||||
#endif
|
||||
|
||||
#ifndef __WXGTK3__
|
||||
// NB: GetBestSize needs to know the style, otherwise it will assume
|
||||
// default font and if the user uses a different font, determined
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "wx/gtk/private.h"
|
||||
#include "wx/gtk/private/gtk2-compat.h"
|
||||
#include "wx/gtk/private/object.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// helpers
|
||||
@ -728,18 +727,10 @@ bool wxTextCtrl::Create( wxWindow *parent,
|
||||
// new, empty control, see https://trac.wxwidgets.org/ticket/11409
|
||||
gtk_entry_get_text((GtkEntry*)m_text);
|
||||
|
||||
#ifndef __WXGTK3__
|
||||
if (style & wxNO_BORDER)
|
||||
{
|
||||
#ifdef __WXGTK3__
|
||||
// this is sort of a workaround for when the builtin theme
|
||||
// won't remove the frame by itself -- see
|
||||
// https://bugzilla.gnome.org/show_bug.cgi?id=789732#c1
|
||||
wxGtkObject<GtkCssProvider> provider(gtk_css_provider_new());
|
||||
ApplyCssStyle(provider, "* { border: none; border-radius: 0; padding: 0 }");
|
||||
#else
|
||||
gtk_entry_set_has_frame((GtkEntry*)m_text, FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
g_object_ref(m_widget);
|
||||
|
@ -4476,7 +4476,7 @@ PangoContext *wxWindowGTK::GTKGetPangoDefaultContext()
|
||||
}
|
||||
|
||||
#ifdef __WXGTK3__
|
||||
void wxWindowGTK::ApplyCssStyle(GtkCssProvider* provider, const char* style)
|
||||
void wxWindowGTK::GTKApplyCssStyle(GtkCssProvider* provider, const char* style)
|
||||
{
|
||||
wxCHECK_RET(m_widget, "invalid window");
|
||||
|
||||
@ -4489,6 +4489,13 @@ void wxWindowGTK::ApplyCssStyle(GtkCssProvider* provider, const char* style)
|
||||
GTK_STYLE_PROVIDER(provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
}
|
||||
|
||||
void wxWindowGTK::GTKApplyCssStyle(const char* style)
|
||||
{
|
||||
GtkCssProvider* provider = gtk_css_provider_new();
|
||||
GTKApplyCssStyle(provider, style);
|
||||
g_object_unref(provider);
|
||||
}
|
||||
#else // GTK+ < 3
|
||||
GtkRcStyle* wxWindowGTK::GTKCreateWidgetStyle()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user