diff options
author | Tim Janik <timj@gtk.org> | 1998-07-16 02:47:15 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 1998-07-16 02:47:15 +0000 |
commit | af24aef782056e52eb4d39c2880da648578c2728 (patch) | |
tree | 14e2d310c6aae8e7b23b1f343018e277665d1436 /gtk/gtkviewport.c | |
parent | 8b9b7b9d04c1f11118f28a9ec7b4c65a7a3f967c (diff) | |
download | gtk+-af24aef782056e52eb4d39c2880da648578c2728.tar.gz |
handle negative values similar to gtk_widget_set_uposition(). that is:
Thu Jul 16 01:27:15 1998 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.h:
* gtk/gtkwidget.c (gtk_widget_set_usize): handle negative values
similar to gtk_widget_set_uposition(). that is: -1=unspecified,
-2=leave untouched. changed the width/height field of GtkWidgetAuxInfo
to be gint16s rather than guint16s, since that's what the code expected
(for a long time actually).
* gtk/gtkviewport.c:
added support for object arguments: GtkViewport::shadow_type,
GtkViewport::vadjustment and GtkViewport::hadjustment.
(gtk_viewport_add): chain gtk_bin_add.
* gtk/gtkscrolledwindow.c:
added support for object argument: GtkScrolledWindow::hscrollbar_policy,
GtkScrolledWindow::vscrollbar_policy and GtkScrolledWindow::viewport.
* gtk/gtkadjustment.h:
* gtk/gtkadjustment.c:
* gtk/gtkctree.h:
* gtk/gtkclist.h:
* gtk/gtkctree.c:
* gtk/gtkclist.c:
* gtk/gtkscrolledwindow.h:
* gtk/gtkscrolledwindow.c:
* gtk/gtkviewport.h:
* gtk/gtkviewport.c:
GtkType and macro fixups.
Diffstat (limited to 'gtk/gtkviewport.c')
-rw-r--r-- | gtk/gtkviewport.c | 141 |
1 files changed, 109 insertions, 32 deletions
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index 7cea71787c..ffc3088adf 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -19,10 +19,24 @@ #include "gtksignal.h" #include "gtkviewport.h" +enum { + ARG_0, + ARG_HADJUSTMENT, + ARG_VADJUSTMENT, + ARG_SHADOW_TYPE +}; + + static void gtk_viewport_class_init (GtkViewportClass *klass); static void gtk_viewport_init (GtkViewport *viewport); static void gtk_viewport_finalize (GtkObject *object); +static void gtk_viewport_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void gtk_viewport_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); static void gtk_viewport_map (GtkWidget *widget); static void gtk_viewport_unmap (GtkWidget *widget); static void gtk_viewport_realize (GtkWidget *widget); @@ -46,10 +60,10 @@ static void gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment, static GtkBinClass *parent_class; -guint +GtkType gtk_viewport_get_type (void) { - static guint viewport_type = 0; + static GtkType viewport_type = 0; if (!viewport_type) { @@ -65,7 +79,7 @@ gtk_viewport_get_type (void) (GtkClassInitFunc) NULL, }; - viewport_type = gtk_type_unique (gtk_bin_get_type (), &viewport_info); + viewport_type = gtk_type_unique (GTK_TYPE_BIN, &viewport_info); } return viewport_type; @@ -81,8 +95,23 @@ gtk_viewport_class_init (GtkViewportClass *class) object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; container_class = (GtkContainerClass*) class; - parent_class = (GtkBinClass*) gtk_type_class (gtk_bin_get_type ()); - + parent_class = (GtkBinClass*) gtk_type_class (GTK_TYPE_BIN); + + gtk_object_add_arg_type ("GtkViewport::hadjustment", + GTK_TYPE_ADJUSTMENT, + GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT, + ARG_HADJUSTMENT); + gtk_object_add_arg_type ("GtkViewport::vadjustment", + GTK_TYPE_ADJUSTMENT, + GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT, + ARG_VADJUSTMENT); + gtk_object_add_arg_type ("GtkViewport::shadow_type", + GTK_TYPE_SHADOW_TYPE, + GTK_ARG_READWRITE, + ARG_SHADOW_TYPE); + + object_class->set_arg = gtk_viewport_set_arg; + object_class->get_arg = gtk_viewport_get_arg; object_class->finalize = gtk_viewport_finalize; widget_class->map = gtk_viewport_map; @@ -98,6 +127,66 @@ gtk_viewport_class_init (GtkViewportClass *class) } static void +gtk_viewport_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ + GtkViewport *viewport; + + viewport = GTK_VIEWPORT (object); + + switch (arg_id) + { + GtkAdjustment *adjustment; + + case ARG_HADJUSTMENT: + g_return_if_fail (viewport->hadjustment == NULL); + adjustment = GTK_VALUE_POINTER (*arg); + if (!adjustment) + adjustment = (GtkAdjustment*) gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + gtk_viewport_set_hadjustment (viewport, adjustment); + break; + case ARG_VADJUSTMENT: + g_return_if_fail (viewport->vadjustment == NULL); + adjustment = GTK_VALUE_POINTER (*arg); + if (!adjustment) + adjustment = (GtkAdjustment*) gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + gtk_viewport_set_vadjustment (viewport, adjustment); + break; + case ARG_SHADOW_TYPE: + gtk_viewport_set_shadow_type (viewport, GTK_VALUE_ENUM (*arg)); + default: + break; + } +} + +static void +gtk_viewport_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ + GtkViewport *viewport; + + viewport = GTK_VIEWPORT (object); + + switch (arg_id) + { + case ARG_HADJUSTMENT: + GTK_VALUE_POINTER (*arg) = viewport->hadjustment; + break; + case ARG_VADJUSTMENT: + GTK_VALUE_POINTER (*arg) = viewport->vadjustment; + break; + case ARG_SHADOW_TYPE: + GTK_VALUE_ENUM (*arg) = viewport->shadow_type; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + +static void gtk_viewport_init (GtkViewport *viewport) { GTK_WIDGET_UNSET_FLAGS (viewport, GTK_NO_WINDOW); @@ -183,13 +272,13 @@ gtk_viewport_set_hadjustment (GtkViewport *viewport, gtk_object_sink (GTK_OBJECT (viewport->hadjustment)); gtk_signal_connect (GTK_OBJECT (adjustment), "changed", - (GtkSignalFunc) gtk_viewport_adjustment_changed, - (gpointer) viewport); + gtk_viewport_adjustment_changed, + viewport); gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", - (GtkSignalFunc)gtk_viewport_adjustment_value_changed, - (gpointer) viewport); + gtk_viewport_adjustment_value_changed, + viewport); - gtk_viewport_adjustment_changed (adjustment, (gpointer) viewport); + gtk_viewport_adjustment_changed (adjustment, viewport); } } @@ -215,13 +304,13 @@ gtk_viewport_set_vadjustment (GtkViewport *viewport, gtk_object_sink (GTK_OBJECT (viewport->vadjustment)); gtk_signal_connect (GTK_OBJECT (adjustment), "changed", - (GtkSignalFunc) gtk_viewport_adjustment_changed, - (gpointer) viewport); + gtk_viewport_adjustment_changed, + viewport); gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", - (GtkSignalFunc)gtk_viewport_adjustment_value_changed, - (gpointer) viewport); + gtk_viewport_adjustment_value_changed, + viewport); - gtk_viewport_adjustment_changed (adjustment, (gpointer) viewport); + gtk_viewport_adjustment_changed (adjustment, viewport); } } @@ -468,32 +557,20 @@ gtk_viewport_expose (GtkWidget *widget, static void gtk_viewport_add (GtkContainer *container, - GtkWidget *widget) + GtkWidget *child) { GtkBin *bin; g_return_if_fail (container != NULL); g_return_if_fail (GTK_IS_VIEWPORT (container)); - g_return_if_fail (widget != NULL); + g_return_if_fail (child != NULL); bin = GTK_BIN (container); + g_return_if_fail (bin->child == NULL); - if (!bin->child) - { - gtk_widget_set_parent (widget, GTK_WIDGET (container)); - gtk_widget_set_parent_window (widget, GTK_VIEWPORT (container)->bin_window); - if (GTK_WIDGET_VISIBLE (widget)) - { - if (GTK_WIDGET_MAPPED (widget->parent) && - !GTK_WIDGET_MAPPED (widget)) - gtk_widget_map (widget); - } - - bin->child = widget; + gtk_widget_set_parent_window (child, GTK_VIEWPORT (bin)->bin_window); - if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (container)) - gtk_widget_queue_resize (widget); - } + GTK_CONTAINER_CLASS (parent_class)->add (container, child); } static void |