Fix wxChoice with items too long to fit into it in wxGTK3
Enable ellipsization to show the items reasonably well even if they're too long to fit into the available space -- without this, just the tail of the long items was shown and shorter items could have been not shown at all, as only the blank part of their label was visible. Closes https://github.com/wxWidgets/wxWidgets/pull/2403 Co-Authored-By: Kent Tessman <kent@generalcoffee.com> Co-Authored-By: Paul Cornett <paulcor@users.noreply.github.com> Co-Authored-By: Vadim Zeitlin <vadim@wxwidgets.org>
This commit is contained in:
committed by
Vadim Zeitlin
parent
b5a9ef543a
commit
fd77020792
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "wx/gtk/private.h"
|
||||
#include "wx/gtk/private/eventsdisabler.h"
|
||||
#include "wx/gtk/private/list.h"
|
||||
#include "wx/gtk/private/value.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -78,6 +79,17 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
|
||||
|
||||
#ifdef __WXGTK3__
|
||||
m_widget = gtk_combo_box_text_new();
|
||||
|
||||
// If any choices don't fit into the available space (in the always visible
|
||||
// part of the control, not the dropdown), GTK shows just the tail of the
|
||||
// string which does fit, which is bad for long strings and even worse for
|
||||
// the shorter ones, as they may end up being shown as completely blank.
|
||||
// Work around this brokenness by enabling ellipsization, especially as it
|
||||
// seems to be safe to do it unconditionally, i.e. there doesn't seem to be
|
||||
// any ill effects from having it on if everything does fit.
|
||||
const wxGtkList cells(gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(m_widget)));
|
||||
if (GTK_IS_CELL_RENDERER_TEXT(cells->data))
|
||||
g_object_set(G_OBJECT(cells->data), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
||||
#else
|
||||
m_widget = gtk_combo_box_new_text();
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user