/* ///////////////////////////////////////////////////////////////////////////
// Name: win_gtk.c
-// Purpose: Native GTK+ widget for wxWindows, based on GtkLayout and
+// Purpose: Native GTK+ widget for wxWidgets, based on GtkLayout and
// GtkFixed. It makes use of the gravity window property and
// therefore does not work with GTK 1.0.
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////// */
#ifdef VMS
#endif /* __WXGTK20__ */
static gint gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event);
+static void gtk_pizza_style_set (GtkWidget *widget,
+ GtkStyle *previous_style);
static void gtk_pizza_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_pizza_remove (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
+
static void gtk_pizza_allocate_child (GtkPizza *pizza,
GtkPizzaChild *child);
+static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
+ gpointer cb_data);
+#ifndef __WXGTK20__
static void gtk_pizza_position_child (GtkPizza *pizza,
GtkPizzaChild *child);
-#ifndef __WXGTK20__
static void gtk_pizza_position_children (GtkPizza *pizza);
-static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
- gpointer cb_data);
-static void gtk_pizza_adjust_allocations (GtkPizza *pizza,
- gint dx,
- gint dy);
static GdkFilterReturn gtk_pizza_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data);
widget_class->draw = gtk_pizza_draw;
#endif
widget_class->expose_event = gtk_pizza_expose;
+ widget_class->style_set = gtk_pizza_style_set;
container_class->add = gtk_pizza_add;
container_class->remove = gtk_pizza_remove;
pizza->children = g_list_append (pizza->children, child_info);
- gtk_widget_set_parent (widget, GTK_WIDGET (pizza));
-
if (GTK_WIDGET_REALIZED (pizza))
gtk_widget_set_parent_window (widget, pizza->bin_window);
+ gtk_widget_set_parent (widget, GTK_WIDGET (pizza));
+
#ifndef __WXGTK20__ /* FIXME? */
if (!IS_ONSCREEN (x, y))
GTK_PRIVATE_SET_FLAG (widget, GTK_IS_OFFSCREEN);
child->x = x;
child->y = y;
-
+
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (pizza))
gtk_widget_queue_resize (widget);
break;
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
gtk_style_set_background (widget->style, pizza->bin_window, GTK_STATE_NORMAL );
-
+
/*
gdk_window_set_back_pixmap( widget->window, NULL, FALSE );
gdk_window_set_back_pixmap( pizza->bin_window, NULL, FALSE );
child = children->data;
children = children->next;
+#ifndef __WXGTK20__
gtk_pizza_position_child (pizza, child);
+#endif
gtk_pizza_allocate_child (pizza, child);
}
}
GdkEventExpose *event)
{
GtkPizza *pizza;
+#ifndef __WXGTK20__
GtkPizzaChild *child;
GdkEventExpose child_event;
GList *children;
+#endif
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PIZZA (widget), FALSE);
#endif
}
+static void
+gtk_pizza_style_set(GtkWidget *widget, GtkStyle *previous_style)
+{
+ if (GTK_WIDGET_REALIZED(widget))
+ {
+ gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
+ gtk_style_set_background(widget->style, GTK_PIZZA(widget)->bin_window, GTK_STATE_NORMAL );
+ }
+
+ (* GTK_WIDGET_CLASS (pizza_parent_class)->style_set) (widget, previous_style);
+}
+
static void
gtk_pizza_add (GtkContainer *container,
GtkWidget *widget)
gtk_widget_size_allocate (child->widget, &allocation);
}
-static void
-gtk_pizza_position_child (GtkPizza *pizza,
- GtkPizzaChild *child)
-{
- gint x;
- gint y;
-
- x = child->x - pizza->xoffset;
- y = child->y - pizza->yoffset;
-
-#ifndef __WXGTK20__
- if (IS_ONSCREEN (x,y))
- {
- if (GTK_WIDGET_MAPPED (pizza) &&
- GTK_WIDGET_VISIBLE (child->widget))
- {
- if (!GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_map (child->widget);
- }
-
- if (GTK_WIDGET_IS_OFFSCREEN (child->widget))
- GTK_PRIVATE_UNSET_FLAG (child->widget, GTK_IS_OFFSCREEN);
- }
- else
- {
- if (!GTK_WIDGET_IS_OFFSCREEN (child->widget))
- GTK_PRIVATE_SET_FLAG (child->widget, GTK_IS_OFFSCREEN);
-
- if (GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_unmap (child->widget);
- }
-#endif
-}
-
-#ifndef __WXGTK20__
-
-static void
-gtk_pizza_position_children (GtkPizza *pizza)
-{
- GList *tmp_list;
-
- tmp_list = pizza->children;
- while (tmp_list)
- {
- GtkPizzaChild *child = tmp_list->data;
- tmp_list = tmp_list->next;
-
- gtk_pizza_position_child (pizza, child);
- }
-}
-
static void
gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
gpointer cb_data)
}
}
-/* This function is used to find events to process while scrolling */
+#ifndef __WXGTK20__
+static void
+gtk_pizza_position_child (GtkPizza *pizza,
+ GtkPizzaChild *child)
+{
+ gint x;
+ gint y;
+
+ x = child->x - pizza->xoffset;
+ y = child->y - pizza->yoffset;
+
+ if (IS_ONSCREEN (x,y))
+ {
+ if (GTK_WIDGET_MAPPED (pizza) &&
+ GTK_WIDGET_VISIBLE (child->widget))
+ {
+ if (!GTK_WIDGET_MAPPED (child->widget))
+ gtk_widget_map (child->widget);
+ }
+
+ if (GTK_WIDGET_IS_OFFSCREEN (child->widget))
+ GTK_PRIVATE_UNSET_FLAG (child->widget, GTK_IS_OFFSCREEN);
+ }
+ else
+ {
+ if (!GTK_WIDGET_IS_OFFSCREEN (child->widget))
+ GTK_PRIVATE_SET_FLAG (child->widget, GTK_IS_OFFSCREEN);
+ if (GTK_WIDGET_MAPPED (child->widget))
+ gtk_widget_unmap (child->widget);
+ }
+}
+
+static void
+gtk_pizza_position_children (GtkPizza *pizza)
+{
+ GList *tmp_list;
+
+ tmp_list = pizza->children;
+ while (tmp_list)
+ {
+ GtkPizzaChild *child = tmp_list->data;
+ tmp_list = tmp_list->next;
+
+ gtk_pizza_position_child (pizza, child);
+ }
+}
+
+/* This function is used to find events to process while scrolling */
static Bool
gtk_pizza_expose_predicate (Display *display,
XEvent *xevent,
else
return False;
}
+#endif /* __WXGTK20__ */
/* This is the main routine to do the scrolling. Scrolling is
* done by "Guffaw" scrolling, as in the Mozilla XFE, with
void
gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
{
+#ifdef __WXGTK20__
+ pizza->xoffset += dx;
+ pizza->yoffset += dy;
+
+ gtk_pizza_adjust_allocations (pizza, -dx, -dy);
+
+ if (pizza->bin_window)
+ gdk_window_scroll( pizza->bin_window, -dx, -dy );
+#else
GtkWidget *widget;
XEvent xevent;
XID win;
}
}
}
+#endif /* __WXGTK20__ */
}
+
+#ifndef __WXGTK20__
/* The main event filter. Actually, we probably don't really need
* to install this as a filter at all, since we are calling it
* directly above in the expose-handling hack. But in case scrollbars
return GDK_FILTER_CONTINUE;
}
-
#endif /* __WXGTK20__ */