- GtkRequisition req;
- req.width = 2;
- req.height = 2;
- (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
- (m_widget, &req );
-
- wxSize best(req.width, req.height);
+ wxSize best;
+ if (m_wxwindow)
+ {
+ // this is not a native control, size_request is likely to be (0,0)
+ best = wxControlBase::DoGetBestSize();
+ }
+ else
+ {
+ GtkRequisition req;
+#ifdef __WXGTK3__
+ if (gtk_widget_get_request_mode(m_widget) != GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
+ {
+ gtk_widget_get_preferred_height(m_widget, NULL, &req.height);
+ gtk_widget_get_preferred_width_for_height(m_widget, req.height, NULL, &req.width);
+ }
+ else
+ {
+ gtk_widget_get_preferred_width(m_widget, NULL, &req.width);
+ gtk_widget_get_preferred_height_for_width(m_widget, req.width, NULL, &req.height);
+ }
+#else
+ GTK_WIDGET_GET_CLASS(m_widget)->size_request(m_widget, &req);
+#endif
+ best.Set(req.width, req.height);
+ }