FILEDIRBTN_OVERRIDES
protected:
- virtual bool GTKShouldConnectSizeRequest() const { return false; }
-
wxDialog *m_dialog;
private:
void GTKResponse(int btnid);
protected:
- virtual bool GTKShouldConnectSizeRequest() const { return false; }
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
private:
static GtkWidget* New(long windowStyle = 0);
static GType type();
- void move(GtkWidget* widget, int x, int y);
- void put(GtkWidget* widget, int x, int y);
+ void move(GtkWidget* widget, int x, int y, int width, int height);
+ void put(GtkWidget* widget, int x, int y, int width, int height);
void scroll(int dx, int dy);
void get_border_widths(int& x, int& y);
GtkFixed m_fixed;
+ GList* m_children;
int m_scroll_x;
int m_scroll_y;
int m_border_style;
// just as it does.
unsigned long GTKConnectWidget(const char *signal, wxGTKCallback callback);
- // Return true from here if PostCreation() should connect to size_request
- // signal: this is done by default but doesn't work for some native
- // controls which override this function to return false
- virtual bool GTKShouldConnectSizeRequest() const { return !IsTopLevel(); }
-
void ConstrainSize();
private:
} // extern "C"
-//-----------------------------------------------------------------------------
-// "size_request" from m_extraControl
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static void extra_widget_size_request(GtkWidget*, GtkRequisition* req, wxWindow* win)
+void wxFileDialog::AddChildGTK(wxWindowGTK* child)
{
// allow dialog to be resized smaller horizontally
- req->width = win->GetMinWidth();
-}
-}
+ gtk_widget_set_size_request(
+ child->m_widget, child->GetMinWidth(), child->m_height);
-void wxFileDialog::AddChildGTK(wxWindowGTK* child)
-{
- g_signal_connect_after(child->m_widget, "size_request",
- G_CALLBACK(extra_widget_size_request), child);
gtk_file_chooser_set_extra_widget(
GTK_FILE_CHOOSER(m_widget), child->m_widget);
}
GTK_BOX(m_mainWidget), menuBar->m_widget, false, false, 0);
gtk_box_reorder_child(GTK_BOX(m_mainWidget), menuBar->m_widget, 0);
- // disconnect wxWindowGTK "size_request" handler,
- // it interferes with sizing of detached GtkHandleBox
- gulong handler_id = g_signal_handler_find(
- menuBar->m_widget,
- GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
- g_signal_lookup("size_request", GTK_TYPE_WIDGET),
- 0, NULL, NULL, menuBar);
- if (handler_id != 0)
- g_signal_handler_disconnect(menuBar->m_widget, handler_id);
-
// reset size request to allow native sizing to work
gtk_widget_set_size_request(menuBar->m_widget, -1, -1);
gtk_box_reorder_child(
GTK_BOX(m_mainWidget), toolbar->m_widget, pos);
}
-
- // disconnect wxWindowGTK "size_request" handler,
- // it interferes with sizing of detached GtkHandleBox
- gulong handler_id = g_signal_handler_find(
- toolbar->m_widget,
- GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
- g_signal_lookup("size_request", GTK_TYPE_WIDGET),
- 0, NULL, NULL, toolbar);
- if (handler_id != 0)
- g_signal_handler_disconnect(toolbar->m_widget, handler_id);
-
// reset size request to allow native sizing to work
gtk_widget_set_size_request(toolbar->m_widget, -1, -1);
}
statbar->m_widget, false, false, 0, GTK_PACK_END);
// make sure next size_allocate on statusbar causes a size event
statbar->m_oldClientWidth = 0;
+ int h = -1;
+ if (statbar->m_wxwindow)
+ {
+ // statusbar is not a native widget, need to set height request
+ h = statbar->m_height;
+ }
+ gtk_widget_set_size_request(statbar->m_widget, -1, h);
}
// make sure next size_allocate causes a wxSizeEvent
m_oldClientWidth = 0;
m_menuBar->Show(false);
gtk_box_pack_start(GTK_BOX(mdi_frame->m_mainWidget), m_menuBar->m_widget, false, false, 0);
gtk_box_reorder_child(GTK_BOX(mdi_frame->m_mainWidget), m_menuBar->m_widget, 0);
-
- gulong handler_id = g_signal_handler_find(
- m_menuBar->m_widget,
- GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
- g_signal_lookup("size_request", GTK_TYPE_WIDGET),
- 0, NULL, NULL, m_menuBar);
- if (handler_id != 0)
- g_signal_handler_disconnect(m_menuBar->m_widget, handler_id);
gtk_widget_set_size_request(m_menuBar->m_widget, -1, -1);
}
}
m_diffX = 0;
m_diffY = 0;
+ // don't allow sizing smaller than decorations
+ int minWidth = 2 * m_miniEdge;
+ int minHeight = 2 * m_miniEdge + m_miniTitle;
+ if (m_minWidth < minWidth)
+ m_minWidth = minWidth;
+ if (m_minHeight < minHeight)
+ m_minHeight = minHeight;
+
wxFrame::Create( parent, id, title, pos, size, style, name );
// Use a GtkEventBox for the title and borders. Using m_widget for this
m_decorSize.Set(0, 0);
m_deferShow = false;
- // don't allow sizing smaller than decorations
- GdkGeometry geom;
- geom.min_width = 2 * m_miniEdge;
- geom.min_height = 2 * m_miniEdge + m_miniTitle;
- gtk_window_set_geometry_hints(GTK_WINDOW(m_widget), NULL, &geom, GDK_HINT_MIN_SIZE);
-
if (m_parent && (GTK_IS_WINDOW(m_parent->m_widget)))
{
gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) );
}
}
-//-----------------------------------------------------------------------------
-// "size_request" from m_toolbar
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static void
-size_request(GtkWidget*, GtkRequisition* req, wxToolBar* win)
-{
- const wxSize margins = win->GetMargins();
- req->width += margins.x;
- req->height += 2 * margins.y;
-}
-}
-
//-----------------------------------------------------------------------------
// "expose_event" from GtkImage inside m_item
//-----------------------------------------------------------------------------
PostCreation(size);
- g_signal_connect_after(m_toolbar, "size_request",
- G_CALLBACK(size_request), this);
-
return true;
}
gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos));
g_object_unref(tool->m_item);
}
- // Inserted items "slide" into place using an animated effect that
- // causes multiple size events on the item. Must set size request
- // to keep item size from getting permanently set too small by the
- // first of these size events.
- const wxSize size = control->GetSize();
- gtk_widget_set_size_request(control->m_widget, size.x, size.y);
break;
}
gtk_widget_show(GTK_WIDGET(tool->m_item));
}
}
-// ----------------------------------------------------------------------------
-// "size_request"
-// ----------------------------------------------------------------------------
-
-extern "C" {
-static
-void wxgtk_tlw_size_request_callback(GtkWidget * WXUNUSED(widget),
- GtkRequisition *requisition,
- wxTopLevelWindowGTK *win)
-{
- // we must return the size of the window without WM decorations, otherwise
- // GTK+ gets confused, so don't call just GetSize() here
- win->GTKDoGetSize(&requisition->width, &requisition->height);
-}
-}
-
//-----------------------------------------------------------------------------
// "delete_event"
//-----------------------------------------------------------------------------
g_signal_connect(m_wxwindow, "size_allocate",
G_CALLBACK(size_allocate), this);
- g_signal_connect (m_widget, "size_request",
- G_CALLBACK (wxgtk_tlw_size_request_callback), this);
PostCreation();
#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
}
}
+ // GTK sometimes chooses very small size if max size hint is not explicitly set
+ int maxWidth = m_maxWidth;
+ int maxHeight = m_maxHeight;
+ if (maxWidth < 0)
+ maxWidth = INT_MAX;
+ if (maxHeight < 0)
+ maxHeight = INT_MAX;
+ DoSetSizeHints(m_minWidth, m_minHeight, maxWidth, maxHeight, -1, -1);
+
m_decorSize = GetCachedDecorSize();
int w, h;
GTKDoGetSize(&w, &h);
For RTL, child widget positions are mirrored in size_allocate.
*/
+struct wxPizzaChild
+{
+ GtkWidget* widget;
+ int x, y, width, height;
+};
+
static GtkWidgetClass* parent_class;
extern "C" {
widget->allocation = *alloc;
// adjust child positions
- for (const GList* list = pizza->m_fixed.children; list; list = list->next)
+ for (const GList* p = pizza->m_children; p; p = p->next)
{
- const GtkFixedChild* child = static_cast<GtkFixedChild*>(list->data);
+ const wxPizzaChild* child = static_cast<wxPizzaChild*>(p->data);
if (gtk_widget_get_visible(child->widget))
{
GtkAllocation child_alloc;
// which has already been adjusted
child_alloc.x = child->x - pizza->m_scroll_x;
child_alloc.y = child->y - pizza->m_scroll_y;
- GtkRequisition req;
- gtk_widget_get_child_requisition(child->widget, &req);
- child_alloc.width = req.width;
- child_alloc.height = req.height;
+ child_alloc.width = child->width;
+ child_alloc.height = child->height;
if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
child_alloc.x = w - child_alloc.x - child_alloc.width;
gtk_widget_size_allocate(child->widget, &child_alloc);
parent_class->hide(widget);
}
+static void pizza_add(GtkContainer* container, GtkWidget* widget)
+{
+ WX_PIZZA(container)->put(widget, 0, 0, 1, 1);
+}
+
+static void pizza_remove(GtkContainer* container, GtkWidget* widget)
+{
+ GTK_CONTAINER_CLASS(parent_class)->remove(container, widget);
+
+ wxPizza* pizza = WX_PIZZA(container);
+ for (GList* p = pizza->m_children; p; p = p->next)
+ {
+ wxPizzaChild* child = static_cast<wxPizzaChild*>(p->data);
+ if (child->widget == widget)
+ {
+ pizza->m_children = g_list_delete_link(pizza->m_children, p);
+ delete child;
+ break;
+ }
+ }
+}
+
// not used, but needs to exist so gtk_widget_set_scroll_adjustments will work
static void set_scroll_adjustments(GtkWidget*, GtkAdjustment*, GtkAdjustment*)
{
widget_class->realize = realize;
widget_class->show = show;
widget_class->hide = hide;
+ GtkContainerClass* container_class = (GtkContainerClass*)g_class;
+ container_class->add = pizza_add;
+ container_class->remove = pizza_remove;
wxPizzaClass* klass = (wxPizzaClass*)g_class;
// needed to make widget appear scrollable to GTK+
{
GtkWidget* widget = GTK_WIDGET(g_object_new(type(), NULL));
wxPizza* pizza = WX_PIZZA(widget);
+ pizza->m_children = NULL;
pizza->m_scroll_x = 0;
pizza->m_scroll_y = 0;
pizza->m_is_scrollable = (windowStyle & (wxHSCROLL | wxVSCROLL)) != 0;
return widget;
}
-// gtk_fixed_move does not check for a change before issuing a queue_resize,
-// we need to avoid that to prevent endless sizing loops, so check first
-void wxPizza::move(GtkWidget* widget, int x, int y)
+void wxPizza::move(GtkWidget* widget, int x, int y, int width, int height)
{
- GtkFixed* fixed = &m_fixed;
- for (const GList* list = fixed->children; list; list = list->next)
+ for (const GList* p = m_children; p; p = p->next)
{
- const GtkFixedChild* child = static_cast<GtkFixedChild*>(list->data);
+ wxPizzaChild* child = static_cast<wxPizzaChild*>(p->data);
if (child->widget == widget)
{
- if (child->x != x || child->y != y)
- gtk_fixed_move(fixed, widget, x, y);
+ child->x = x;
+ child->y = y;
+ child->width = width;
+ child->height = height;
+ // normally a queue-resize would be needed here, but we know
+ // wxWindowGTK::DoMoveWindow() will take care of it
break;
}
}
}
-void wxPizza::put(GtkWidget* widget, int x, int y)
+void wxPizza::put(GtkWidget* widget, int x, int y, int width, int height)
{
- gtk_fixed_put(&m_fixed, widget, x, y);
+ gtk_fixed_put(GTK_FIXED(this), widget, 0, 0);
+
+ wxPizzaChild* child = new wxPizzaChild;
+ child->widget = widget;
+ child->x = x;
+ child->y = y;
+ child->width = width;
+ child->height = height;
+ m_children = g_list_append(m_children, child);
}
struct AdjustData {
// the trace mask used for the focus debugging messages
#define TRACE_FOCUS wxT("focus")
-//-----------------------------------------------------------------------------
-// "size_request" of m_widget
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static void
-wxgtk_window_size_request_callback(GtkWidget * WXUNUSED(widget),
- GtkRequisition *requisition,
- wxWindow * win)
-{
- int w, h;
- win->GetSize( &w, &h );
- if (w < 2)
- w = 2;
- if (h < 2)
- h = 2;
-
- requisition->height = h;
- requisition->width = w;
-}
-}
-
//-----------------------------------------------------------------------------
// "expose_event" of m_wxwindow
//-----------------------------------------------------------------------------
child->m_x += pizza->m_scroll_x;
child->m_y += pizza->m_scroll_y;
- gtk_widget_set_size_request(
- child->m_widget, child->m_width, child->m_height);
- pizza->put(child->m_widget, child->m_x, child->m_y);
+ pizza->put(child->m_widget,
+ child->m_x, child->m_y, child->m_width, child->m_height);
}
//-----------------------------------------------------------------------------
}
#endif // GTK+ >= 2.8
- if ( GTKShouldConnectSizeRequest() )
- {
- // This is needed if we want to add our windows into native
- // GTK controls, such as the toolbar. With this callback, the
- // toolbar gets to know the correct size (the one set by the
- // programmer). Sadly, it misbehaves for wxComboBox.
- g_signal_connect (m_widget, "size_request",
- G_CALLBACK (wxgtk_window_size_request_callback),
- this);
- }
+ if (!WX_IS_PIZZA(gtk_widget_get_parent(m_widget)) && !GTK_IS_WINDOW(m_widget))
+ gtk_widget_set_size_request(m_widget, m_width, m_height);
InheritAttributes();
{
GtkWidget* parent = gtk_widget_get_parent(m_widget);
if (WX_IS_PIZZA(parent))
- {
- WX_PIZZA(parent)->move(m_widget, x, y);
+ WX_PIZZA(parent)->move(m_widget, x, y, width, height);
+ else
gtk_widget_set_size_request(m_widget, width, height);
- }
// With GTK3, gtk_widget_queue_resize() is ignored while a size-allocate
// is in progress. This situation is common in wxWidgets, since