(Screenshots from wxWidgets 3.1.6 widgets sample, pulled today, built against GTK 3, running on Ubuntu 18.04.)
Note the wxChoice on the right-hand side (after clicking "Insert a few strings".) The left-hand side of the choice is clipped, because the selected item "another one" is much shorter than "and the last very, very, very, very, very, very...long one". (If "another one" was a little longer, you might see the end of it peeking in at the visible left of the wxChoice.)
I've tried a couple of different solutions to this, including specifying the size of the wxChoice (resulting in clipping), or leaving it to wxDefaultSize (resulting in a long, long, long wxChoice in the layout).
As far as I know there's no way to tweak force alignment, or ellipsization, or anything that would help.
This seems to be solely a GTK 3 problem. GTK 2 rendering shows "another one" properly in the wxChoice when selected without oversizing/clipping.
Has anyone successfully worked around this behaviour?
[wxGTK] wxChoice label clipping with long item(s)
Re: [wxGTK] wxChoice label clipping with long item(s)
To answer my own question, this issue has been discussed with a solution proposed here: https://groups.google.com/u/4/g/wx-users/c/CwLLldm1UN4
Essentially the ellipsize mode must be explicitly set; the PR does it in wxChoice::Create().
Essentially the ellipsize mode must be explicitly set; the PR does it in wxChoice::Create().
Code: Select all
// GTK 3 has a sizing issue with long combobox text: it needs ellipsization set
GList* cells = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(m_widget));
if (cells)
{
GtkCellRenderer* cell = (GtkCellRenderer*) cells->data;
if (cell)
g_object_set(G_OBJECT(cell), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
// Only the list of cells must be freed, the renderer isn't ours to free
g_list_free(cells);
}