Commit a425e6b5 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Edited section on the ScrolledWindow.

Tue Nov 24 11:31:06 1998  Owen Taylor  <otaylor@redhat.com>

	* docs/Changes-1.2.txt: Edited section on the ScrolledWindow.

	* gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
	some code duplication.

	* gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
	and child widgets when scrolling greater than 32k pixels.

	* testgtk.c: Modified layout test to test scrolling over
	long distances.

	* gtk/gtkplug.c: Added a few blank lines.
parent 1bb0d4c0
Tue Nov 24 11:31:06 1998 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
* gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
some code duplication.
* gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
and child widgets when scrolling greater than 32k pixels.
* testgtk.c: Modified layout test to test scrolling over
long distances.
Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com> Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.[ch]: Fixed up copyright message. * gtk/gtklayout.[ch]: Fixed up copyright message.
......
Tue Nov 24 11:31:06 1998 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
* gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
some code duplication.
* gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
and child widgets when scrolling greater than 32k pixels.
* testgtk.c: Modified layout test to test scrolling over
long distances.
Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com> Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.[ch]: Fixed up copyright message. * gtk/gtklayout.[ch]: Fixed up copyright message.
......
Tue Nov 24 11:31:06 1998 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
* gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
some code duplication.
* gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
and child widgets when scrolling greater than 32k pixels.
* testgtk.c: Modified layout test to test scrolling over
long distances.
Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com> Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.[ch]: Fixed up copyright message. * gtk/gtklayout.[ch]: Fixed up copyright message.
......
Tue Nov 24 11:31:06 1998 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
* gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
some code duplication.
* gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
and child widgets when scrolling greater than 32k pixels.
* testgtk.c: Modified layout test to test scrolling over
long distances.
Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com> Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.[ch]: Fixed up copyright message. * gtk/gtklayout.[ch]: Fixed up copyright message.
......
Tue Nov 24 11:31:06 1998 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
* gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
some code duplication.
* gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
and child widgets when scrolling greater than 32k pixels.
* testgtk.c: Modified layout test to test scrolling over
long distances.
Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com> Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.[ch]: Fixed up copyright message. * gtk/gtklayout.[ch]: Fixed up copyright message.
......
Tue Nov 24 11:31:06 1998 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
* gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
some code duplication.
* gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
and child widgets when scrolling greater than 32k pixels.
* testgtk.c: Modified layout test to test scrolling over
long distances.
Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com> Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.[ch]: Fixed up copyright message. * gtk/gtklayout.[ch]: Fixed up copyright message.
......
Tue Nov 24 11:31:06 1998 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
* gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
some code duplication.
* gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
and child widgets when scrolling greater than 32k pixels.
* testgtk.c: Modified layout test to test scrolling over
long distances.
Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com> Tue Nov 24 11:11:05 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtklayout.[ch]: Fixed up copyright message. * gtk/gtklayout.[ch]: Fixed up copyright message.
......
...@@ -60,24 +60,28 @@ Incompatible Changes from GTK+-1.0 to GTK+-1.2: ...@@ -60,24 +60,28 @@ Incompatible Changes from GTK+-1.0 to GTK+-1.2:
If you need to do that, use a GtkDrawingArea or (for a If you need to do that, use a GtkDrawingArea or (for a
toplevel) the new GtkDrawWindow widget. toplevel) the new GtkDrawWindow widget.
* Scrolled windows do not create an automatic viewport anymore, and * The ScrolledWindow widget no longer creates a Viewport
self scrolling widgets do not provide their own scrollbars any automatically. Instead, it has been generalized to accept
further. Self scrolling widgets of the Gtk+ core currently are any "self-scrolling" widget.
GtkViewport, GtkCList, GtkCTree, GtkText and GtkLayout. All of
these widgets can be added to a scrolled window as normal children The self-scrolling widgets in the Gtk+ core are GtkViewport,
with gtk_container_add() and their scrolling abilities will be setup GtkCList, GtkCTree, GtkText, and GtkLayout. All of these widgets can
appropriatedly in an automatic manner. be added to a scrolled window as normal children with
Widgets that do not implement own scrolling abilities but get added gtk_container_add() and scrollbars will be set up automatically.
to a scrolled window in order to have their allocations scrollable
inside of the scrolled window (e.g. a GtkList) have first to be added To add scrollbars to a non self-scrolling widget, (such as a GtkList),
to a GtkViewport, and then the viewport needs to be added to the first add it to a viewport, then add the viewport to a scrolled window.
scrolled window. The scrolled window code provides a convenience function to do this:
However, the scrolled window code provides a convenience function to
achive this: void gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrollwin,
gtk_scrolled_window_add_with_viewport() which will do exactly what GtkWidget *child);
it says, add a child widget to a viewport and put that viewport into
the scrolled window. This does exactly what it says - it creates a Viewport, adds the child
Scrollbar policy adjustment needs to be perfomed on the scrolled window widget to it, then adds the Viewport to the scrolled window.
with gtk_scrolled_window_set_policy() and is not longer maintained for
the child widgets (e.g. GtkCList's gtk_clist_set_policy() got removed). The scrollbars have been removed from the GtkCList and GtkCTree,
because they are now scrolled by simply adding them to a Scrolled
Window. The scrollbar policy is set on the scrolled window with
gtk_scrolled_window_set_policy() and not on the child widgets
(e.g. GtkCList's gtk_clist_set_policy() was removed).
...@@ -90,8 +90,7 @@ gtk_layout_new (GtkAdjustment *hadjustment, ...@@ -90,8 +90,7 @@ gtk_layout_new (GtkAdjustment *hadjustment,
layout = gtk_type_new (gtk_layout_get_type()); layout = gtk_type_new (gtk_layout_get_type());
gtk_layout_set_hadjustment (layout, hadjustment); gtk_layout_set_adjustments (layout, hadjustment, vadjustment);
gtk_layout_set_vadjustment (layout, vadjustment);
return GTK_WIDGET (layout); return GTK_WIDGET (layout);
} }
...@@ -118,6 +117,8 @@ gtk_layout_set_adjustments (GtkLayout *layout, ...@@ -118,6 +117,8 @@ gtk_layout_set_adjustments (GtkLayout *layout,
GtkAdjustment *hadj, GtkAdjustment *hadj,
GtkAdjustment *vadj) GtkAdjustment *vadj)
{ {
gboolean need_adjust = FALSE;
g_return_if_fail (layout != NULL); g_return_if_fail (layout != NULL);
g_return_if_fail (GTK_IS_LAYOUT (layout)); g_return_if_fail (GTK_IS_LAYOUT (layout));
...@@ -151,7 +152,7 @@ gtk_layout_set_adjustments (GtkLayout *layout, ...@@ -151,7 +152,7 @@ gtk_layout_set_adjustments (GtkLayout *layout,
gtk_signal_connect (GTK_OBJECT (layout->hadjustment), "value_changed", gtk_signal_connect (GTK_OBJECT (layout->hadjustment), "value_changed",
(GtkSignalFunc) gtk_layout_adjustment_changed, (GtkSignalFunc) gtk_layout_adjustment_changed,
layout); layout);
gtk_layout_adjustment_changed (hadj, layout); need_adjust = TRUE;
} }
if (layout->vadjustment != vadj) if (layout->vadjustment != vadj)
...@@ -163,8 +164,11 @@ gtk_layout_set_adjustments (GtkLayout *layout, ...@@ -163,8 +164,11 @@ gtk_layout_set_adjustments (GtkLayout *layout,
gtk_signal_connect (GTK_OBJECT (layout->vadjustment), "value_changed", gtk_signal_connect (GTK_OBJECT (layout->vadjustment), "value_changed",
(GtkSignalFunc) gtk_layout_adjustment_changed, (GtkSignalFunc) gtk_layout_adjustment_changed,
layout); layout);
gtk_layout_adjustment_changed (vadj, layout); need_adjust = TRUE;
} }
if (need_adjust)
gtk_layout_adjustment_changed (NULL, layout);
} }
void void
...@@ -174,19 +178,7 @@ gtk_layout_set_hadjustment (GtkLayout *layout, ...@@ -174,19 +178,7 @@ gtk_layout_set_hadjustment (GtkLayout *layout,
g_return_if_fail (layout != NULL); g_return_if_fail (layout != NULL);
g_return_if_fail (GTK_IS_LAYOUT (layout)); g_return_if_fail (GTK_IS_LAYOUT (layout));
if (layout->hadjustment) gtk_layout_set_adjustments (layout, adjustment, layout->vadjustment);
gtk_object_unref (GTK_OBJECT (layout->hadjustment));
if (!adjustment)
adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 10.0, 0.0, 0.0));
else
gtk_object_ref (GTK_OBJECT (adjustment));
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (gtk_layout_adjustment_changed),
layout);
layout->hadjustment = adjustment;
} }
...@@ -197,19 +189,7 @@ gtk_layout_set_vadjustment (GtkLayout *layout, ...@@ -197,19 +189,7 @@ gtk_layout_set_vadjustment (GtkLayout *layout,
g_return_if_fail (layout != NULL); g_return_if_fail (layout != NULL);
g_return_if_fail (GTK_IS_LAYOUT (layout)); g_return_if_fail (GTK_IS_LAYOUT (layout));
if (layout->vadjustment) gtk_layout_set_adjustments (layout, layout->hadjustment, adjustment);
gtk_object_unref (GTK_OBJECT (layout->hadjustment));
if (!adjustment)
adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 10.0, 0.0, 0.0));
else
gtk_object_ref (GTK_OBJECT (adjustment));
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (gtk_layout_adjustment_changed),
layout);
layout->vadjustment = adjustment;
} }
...@@ -232,6 +212,7 @@ gtk_layout_put (GtkLayout *layout, ...@@ -232,6 +212,7 @@ gtk_layout_put (GtkLayout *layout,
child->y = y; child->y = y;
child->widget->requisition.width = 0; child->widget->requisition.width = 0;
child->widget->requisition.height = 0; child->widget->requisition.height = 0;
child->mapped = FALSE;
layout->children = g_list_append (layout->children, child); layout->children = g_list_append (layout->children, child);
...@@ -481,12 +462,14 @@ gtk_layout_map (GtkWidget *widget) ...@@ -481,12 +462,14 @@ gtk_layout_map (GtkWidget *widget)
{ {
GtkLayoutChild *child = tmp_list->data; GtkLayoutChild *child = tmp_list->data;
if (GTK_WIDGET_VISIBLE (child->widget) && if (child->mapped && GTK_WIDGET_VISIBLE (child->widget))
!GTK_WIDGET_MAPPED (child->widget)) {
gtk_widget_map (child->widget); if (!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
if (child->window)
gdk_window_show (child->window); if (child->window)
gdk_window_show (child->window);
}
tmp_list = tmp_list->next; tmp_list = tmp_list->next;
} }
...@@ -761,12 +744,21 @@ gtk_layout_position_child (GtkLayout *layout, ...@@ -761,12 +744,21 @@ gtk_layout_position_child (GtkLayout *layout,
if ((x >= G_MINSHORT) && (x <= G_MAXSHORT) && if ((x >= G_MINSHORT) && (x <= G_MAXSHORT) &&
(y >= G_MINSHORT) && (y <= G_MAXSHORT)) (y >= G_MINSHORT) && (y <= G_MAXSHORT))
{ {
if (GTK_WIDGET_VISIBLE (child->widget) && if (!child->mapped)
GTK_WIDGET_MAPPED (layout) &&
!GTK_WIDGET_MAPPED (child->widget))
{ {
gtk_widget_map (child->widget); child->mapped = TRUE;
force_allocate = TRUE;
if (GTK_WIDGET_MAPPED (layout) &&
GTK_WIDGET_VISIBLE (child->widget))
{
if (child->window)
gdk_window_show (child->window);
if (!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
child->mapped = TRUE;
force_allocate = TRUE;
}
} }
if (force_allocate) if (force_allocate)
...@@ -800,10 +792,14 @@ gtk_layout_position_child (GtkLayout *layout, ...@@ -800,10 +792,14 @@ gtk_layout_position_child (GtkLayout *layout,
} }
else else
{ {
if (child->window) if (child->mapped)
gdk_window_hide (child->window); {
else if (GTK_WIDGET_MAPPED (child->widget)) child->mapped = FALSE;
gtk_widget_unmap (child->widget); if (child->window)
gdk_window_hide (child->window);
else if (GTK_WIDGET_MAPPED (child->widget))
gtk_widget_unmap (child->widget);
}
} }
} }
...@@ -914,10 +910,11 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment, ...@@ -914,10 +910,11 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
if (layout->frozen) if (layout->frozen)
return; return;
gtk_layout_position_children (layout);
if (!GTK_WIDGET_MAPPED (layout)) if (!GTK_WIDGET_MAPPED (layout))
return; {
gtk_layout_position_children (layout);
return;
}
if (dx > 0) if (dx > 0)
{ {
...@@ -1016,6 +1013,8 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment, ...@@ -1016,6 +1013,8 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
-dy); -dy);
} }
gtk_layout_position_children (layout);
/* We have to make sure that all exposes from this scroll get /* We have to make sure that all exposes from this scroll get
* processed before we scroll again, or the expose events will * processed before we scroll again, or the expose events will
* have invalid coordinates. * have invalid coordinates.
......
...@@ -45,6 +45,7 @@ struct _GtkLayoutChild { ...@@ -45,6 +45,7 @@ struct _GtkLayoutChild {
GdkWindow *window; /* For NO_WINDOW widgets */ GdkWindow *window; /* For NO_WINDOW widgets */
gint x; gint x;
gint y; gint y;
gboolean mapped : 1;
}; };
struct _GtkLayout { struct _GtkLayout {
......
...@@ -88,6 +88,7 @@ gtk_plug_init (GtkPlug *plug) ...@@ -88,6 +88,7 @@ gtk_plug_init (GtkPlug *plug)
window->type = GTK_WINDOW_TOPLEVEL; window->type = GTK_WINDOW_TOPLEVEL;
window->auto_shrink = TRUE; window->auto_shrink = TRUE;
} }
void void
gtk_plug_construct (GtkPlug *plug, guint32 socket_id) gtk_plug_construct (GtkPlug *plug, guint32 socket_id)
{ {
...@@ -100,6 +101,7 @@ gtk_plug_construct (GtkPlug *plug, guint32 socket_id) ...@@ -100,6 +101,7 @@ gtk_plug_construct (GtkPlug *plug, guint32 socket_id)
plug->same_app = FALSE; plug->same_app = FALSE;
} }
} }
GtkWidget* GtkWidget*
gtk_plug_new (guint32 socket_id) gtk_plug_new (guint32 socket_id)
{ {
......
...@@ -7994,7 +7994,6 @@ void create_layout (void) ...@@ -7994,7 +7994,6 @@ void create_layout (void)
gtk_widget_set_usize (window, 200, 200); gtk_widget_set_usize (window, 200, 200);
scrolledwindow = gtk_scrolled_window_new (NULL, NULL); scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow);
gtk_container_add (GTK_CONTAINER (window), scrolledwindow); gtk_container_add (GTK_CONTAINER (window), scrolledwindow);
...@@ -8005,8 +8004,7 @@ void create_layout (void) ...@@ -8005,8 +8004,7 @@ void create_layout (void)
gtk_signal_connect (GTK_OBJECT (layout), "expose_event", gtk_signal_connect (GTK_OBJECT (layout), "expose_event",
GTK_SIGNAL_FUNC (layout_expose_handler), NULL); GTK_SIGNAL_FUNC (layout_expose_handler), NULL);
gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 1600); gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 64000);
gtk_widget_show (layout);
for (i=0 ; i < 16 ; i++) for (i=0 ; i < 16 ; i++)
for (j=0 ; j < 16 ; j++) for (j=0 ; j < 16 ; j++)
...@@ -8016,14 +8014,26 @@ void create_layout (void) ...@@ -8016,14 +8014,26 @@ void create_layout (void)
button = gtk_button_new_with_label (buf); button = gtk_button_new_with_label (buf);
else else
button = gtk_label_new (buf); button = gtk_label_new (buf);
gtk_layout_put (GTK_LAYOUT (layout), button, gtk_layout_put (GTK_LAYOUT (layout), button,
j*100, i*100); j*100, i*100);
gtk_widget_show (button);
} }
for (i=16; i < 640; i++)
{
sprintf(buf, "Button %d, %d", i, 0);
if (i % 2)
button = gtk_button_new_with_label (buf);
else
button = gtk_label_new (buf);
gtk_layout_put (GTK_LAYOUT (layout), button,
0, i*100);
}
} }
if (!GTK_WIDGET_VISIBLE (window)) if (!GTK_WIDGET_VISIBLE (window))
gtk_widget_show (window); gtk_widget_show_all (window);
else else
gtk_widget_destroy (window); gtk_widget_destroy (window);
} }
......
...@@ -7994,7 +7994,6 @@ void create_layout (void) ...@@ -7994,7 +7994,6 @@ void create_layout (void)
gtk_widget_set_usize (window, 200, 200); gtk_widget_set_usize (window, 200, 200);
scrolledwindow = gtk_scrolled_window_new (NULL, NULL); scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow);
gtk_container_add (GTK_CONTAINER (window), scrolledwindow); gtk_container_add (GTK_CONTAINER (window), scrolledwindow);
...@@ -8005,8 +8004,7 @@ void create_layout (void) ...@@ -8005,8 +8004,7 @@ void create_layout (void)
gtk_signal_connect (GTK_OBJECT (layout), "expose_event", gtk_signal_connect (GTK_OBJECT (layout), "expose_event",
GTK_SIGNAL_FUNC (layout_expose_handler), NULL); GTK_SIGNAL_FUNC (layout_expose_handler), NULL);
gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 1600); gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 64000);
gtk_widget_show (layout);
for (i=0 ; i < 16 ; i++) for (i=0 ; i < 16 ; i++)
for (j=0 ; j < 16 ; j++) for (j=0 ; j < 16 ; j++)
...@@ -8016,14 +8014,26 @@ void create_layout (void) ...@@ -8016,14 +8014,26 @@ void create_layout (void)
button = gtk_button_new_with_label (buf); button = gtk_button_new_with_label (buf);
else else
button = gtk_label_new (buf); button = gtk_label_new (buf);
gtk_layout_put (GTK_LAYOUT (layout), button, gtk_layout_put (GTK_LAYOUT (layout), button,
j*100, i*100); j*100, i*100);
gtk_widget_show (button);
} }
for (i=16; i < 640; i++)
{
sprintf(buf, "Button %d, %d", i, 0);
if (i % 2)
button = gtk_button_new_with_label (buf);
else
button = gtk_label_new (buf);
gtk_layout_put (GTK_LAYOUT (layout), button,
0, i*100);
}
} }
if (!GTK_WIDGET_VISIBLE (window)) if (!GTK_WIDGET_VISIBLE (window))
gtk_widget_show (window); gtk_widget_show_all (window);
else else
gtk_widget_destroy (window); gtk_widget_destroy (window);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment