func gtk_widget_get_preferred_size(widget *C.GtkWidget) (minWidth int, minHeight int, natWidth int, natHeight int) { var minimum, natural C.GtkRequisition C.gtk_widget_get_preferred_size(widget, &minimum, &natural) return int(minimum.width), int(minimum.height), int(natural.width), int(natural.height) }
func (self *Widget) GetPreferredSize() (minimumSize, naturalSize Requisition) { var min, nat C.GtkRequisition C.gtk_widget_get_preferred_size(self.object, &min, &nat) minimumSize = Requisition{int(min.width), int(min.height)} naturalSize = Requisition{int(nat.width), int(nat.height)} return }
//export our_area_get_child_position_callback func our_area_get_child_position_callback(overlay *C.GtkOverlay, widget *C.GtkWidget, rect *C.GdkRectangle, data C.gpointer) C.gboolean { var nat C.GtkRequisition a := (*area)(unsafe.Pointer(data)) rect.x = C.int(a.textfieldx) rect.y = C.int(a.textfieldy) C.gtk_widget_get_preferred_size(a.textfieldw, nil, &nat) rect.width = C.int(nat.width) rect.height = C.int(nat.height) return C.TRUE }
func basepreferredSize(c controlPrivate, d *sizing) (int, int) { // GTK+ 3 makes this easy: controls can tell us what their preferred size is! // ...actually, it tells us two things: the "minimum size" and the "natural size". // The "minimum size" is the smallest size we /can/ display /anything/. The "natural size" is the smallest size we would /prefer/ to display. // The difference? Minimum size takes into account things like truncation with ellipses: the minimum size of a label can allot just the ellipses! // So we use the natural size instead. // There is a warning about height-for-width controls, but in my tests this isn't an issue. var r C.GtkRequisition C.gtk_widget_get_preferred_size(c.widget(), nil, &r) return int(r.width), int(r.height) }