Bug 561364

Summary: [GTK] Set size is ignored for checkboxes
Product: [Eclipse Project] Platform Reporter: Thomas Singer <ts-swt>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: alexandr.miloslavskiy, ts-swt
Version: 4.15   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Snippet
none
Screenshot illustrating the problem
none
Screenshot on Windows 10 none

Description Thomas Singer CLA 2020-03-23 08:03:18 EDT
Please execute the attached snippet on Linux. For me the set size of the checkbox is ignored - it is drawn as large as the text is.
Comment 1 Thomas Singer CLA 2020-03-23 08:03:58 EDT
Created attachment 282191 [details]
Snippet
Comment 2 Thomas Singer CLA 2020-03-23 08:04:22 EDT
Created attachment 282192 [details]
Screenshot illustrating the problem
Comment 3 Thomas Singer CLA 2020-03-23 08:05:55 EDT
Created attachment 282193 [details]
Screenshot on Windows 10
Comment 4 Alexandr Miloslavskiy CLA 2020-09-23 11:10:30 EDT
I have studied GTK sources and it seems to be by design:

1) Every widget has two rectangles:
   allocation - this is the designated widget size
   clip       - this is the area where widget is allowed to paint. It
                is often larger than allocation.
2) When a clip rectangle is changed for a widget, all parents that
   share the same GdkWindow have their clip rects adjusted to include
   the child's rect
   * see gtk_widget_set_clip()
3) GtkLabel includes entire text length in its clip rectangle. This
   seems to only be changed by enabling wrapping or ellipsis
   * see gtk_label_get_ink_rect() in gtk_label_size_allocate()
4) GtkLabel also calculates its minimum size as full text length,
   which is again modified by wrapping and ellipsis
   * see gtk_label_get_preferred_layout_size()
5) When GtkBox container performs layout, and there is not enough space
   to fit minimum sizes, it prints a warning and early returns.
   * see gtk_box_gadget_distribute()
6) Checkbox/radio/pushbuton all have a Label with text inside them.

To summarize, when a Label doesn't fit, it still paints remaining text
outside of bounds. SWT Label however is not affected because SWT
wraps it in an intermediate GtkEventBox which creates its own GdkWindow.

The simplest workaround is to wrap overflowing Button into a Composite.
Just like Label, this will wrap the control in an intermediate GdkWindow,
which stops clip rect propagation in gtk_widget_set_clip().