wxListView doesn't draw a border with GTK (Issue #23236)

48 views
Skip to first unread message

Will Cosgrove

unread,
Feb 7, 2023, 7:19:31 PM2/7/23
to wx-...@googlegroups.com, Subscribed

wxListView using GTK doesn't draw a border by default, passing wxBORDER_THEME also has no effect.

Expected vs observed behaviour:

  • wxListBox has a border, wxDataViewCtrl has a border. wxListView does not.
  • The list also doesn't update its theme color if you change themes while the application is running.

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);

Platform and version information

  • wxWidgets version you use: 3.2.1
  • wxWidgets port you use: wxGTK
  • OS and its version: Fedora 37
  • GTK version: 3.24.36
  • Which GDK backend is used: Wayland
  • Current theme: adwaita-dark


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/23236@github.com>

VZ

unread,
Feb 14, 2023, 5:57:16 PM2/14/23
to wx-...@googlegroups.com, Subscribed

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.Message ID: <wxWidgets/wxWidgets/issues/23236/1430501076@github.com>

paulcor

unread,
Feb 15, 2023, 12:24:45 PM2/15/23
to wx-...@googlegroups.com, Subscribed

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.Message ID: <wxWidgets/wxWidgets/issues/23236/1431736763@github.com>

VZ

unread,
Feb 15, 2023, 5:10:56 PM2/15/23
to wx-...@googlegroups.com, Subscribed

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.Message ID: <wxWidgets/wxWidgets/issues/23236/1432112211@github.com>

VZ

unread,
Feb 25, 2023, 8:28:52 PM2/25/23
to wx-...@googlegroups.com, Subscribed

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.Message ID: <wxWidgets/wxWidgets/issues/23236/1445242470@github.com>

VZ

unread,
Feb 28, 2023, 12:32:00 PM2/28/23
to wx-...@googlegroups.com, Subscribed

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.Message ID: <wxWidgets/wxWidgets/issue/23236/issue_event/8629597048@github.com>

Reply all
Reply to author
Forward
0 new messages