wxListView using GTK doesn't draw a border by default, passing wxBORDER_THEME
also has no effect.
Expected vs observed behaviour:
Patch or snippet allowing to reproduce the problem:
Create a stock list view control like so, observe no border on GTK backend:
wxListView *list = new wxListView(this, wxID_ANY, wxDefaultPosition, FromDIP(wxSize(200, 100)), wxLC_SINGLE_SEL | wxLC_LIST | wxBORDER_THEME);
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
I can reproduce this but this isn't really specific to wxListCtrl
, in fact borders don't work for any window with wx[HV]SCROLL
style in wxGTK:
diff --git a/samples/minimal/minimal.cpp b/samples/minimal/minimal.cpp index 501caf9096..f6ccaea55c 100644 --- a/samples/minimal/minimal.cpp +++ b/samples/minimal/minimal.cpp @@ -175,6 +175,15 @@ MyFrame::MyFrame(const wxString& title) CreateStatusBar(2); SetStatusText("Welcome to wxWidgets!"); #endif // wxUSE_STATUSBAR + + wxSizer* s = new wxBoxSizer(wxVERTICAL); + s->Add(new wxWindow(this, wxID_ANY, wxDefaultPosition, wxSize(100, 50), + wxBORDER_THEME), + wxSizerFlags().DoubleBorder()); + s->Add(new wxWindow(this, wxID_ANY, wxDefaultPosition, wxSize(100, 50), + wxHSCROLL | wxBORDER_THEME), + wxSizerFlags().DoubleBorder()); + SetSizer(s); }
shows the border around the first window but not the second one.
Removing the code handling scrolled windows specially from draw_border()
in src/gtk/window.cpp
like this:
diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 338f182fea..809703ac4e 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -516,11 +516,7 @@ draw_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win) { #ifdef __WXGTK3__ //TODO: wxBORDER_RAISED/wxBORDER_SUNKEN - GtkStyleContext* sc; - if (win->HasFlag(wxHSCROLL | wxVSCROLL)) - sc = gtk_widget_get_style_context(wxGTKPrivate::GetTreeWidget()); - else - sc = gtk_widget_get_style_context(wxGTKPrivate::GetEntryWidget()); + GtkStyleContext* sc = gtk_widget_get_style_context(wxGTKPrivate::GetEntryWidget()); gtk_render_frame(sc, cr, x, y, w, h); #else // !__WXGTK3__
fixes it but I don't know if this is really correct. @paulcor Would you remember why was it done like this back in 9dc44ef (support for GTK3, 2012-06-30) and do we do something horrible by always using the entry widget, even for scrolled windows?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
The issue is that the theme says scrolled windows (and most others) don't have a border. So technically it's working correctly.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
Yes, I suspected this was the case, but as we really need the border here, what is the correct fix? Mine works and is very simple, so I'm tempted to use it, but I suspect that some themes might not use a border for the text entries neither and the really correct solution is to create our own GtkStyleContext
with the desired border style. Except that I don't know how to do it and it would still be nice to use the same borders as all the other windows.
Do you know how could we do this or should we just apply the above?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
I'm probably just going to apply the patch above, as I still don't know how to draw a "compatible" border using GTK API/CSS, and any border is arguably better than no border at all.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
Closed #23236 as completed via 937b068.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.