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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* gtk/gtklayout.[ch]: Fixed up copyright message.
......
......@@ -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
toplevel) the new GtkDrawWindow widget.
* Scrolled windows do not create an automatic viewport anymore, and
self scrolling widgets do not provide their own scrollbars any
further. Self scrolling widgets of the Gtk+ core currently are
GtkViewport, GtkCList, GtkCTree, GtkText and GtkLayout. All of
these widgets can be added to a scrolled window as normal children
with gtk_container_add() and their scrolling abilities will be setup
appropriatedly in an automatic manner.
Widgets that do not implement own scrolling abilities but get added
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 a GtkViewport, and then the viewport needs to be added to the
scrolled window.
However, the scrolled window code provides a convenience function to
achive this:
gtk_scrolled_window_add_with_viewport() which will do exactly what
it says, add a child widget to a viewport and put that viewport into
the scrolled window.
Scrollbar policy adjustment needs to be perfomed on 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 ScrolledWindow widget no longer creates a Viewport
automatically. Instead, it has been generalized to accept
any "self-scrolling" widget.
The self-scrolling widgets in the Gtk+ core are GtkViewport,
GtkCList, GtkCTree, GtkText, and GtkLayout. All of these widgets can
be added to a scrolled window as normal children with
gtk_container_add() and scrollbars will be set up automatically.
To add scrollbars to a non self-scrolling widget, (such as a GtkList),
first add it to a viewport, then add the viewport to a scrolled window.
The scrolled window code provides a convenience function to do this:
void gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrollwin,
GtkWidget *child);
This does exactly what it says - it creates a Viewport, adds the child
widget to it, then adds the Viewport to the scrolled window.
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,
layout = gtk_type_new (gtk_layout_get_type());
gtk_layout_set_hadjustment (layout, hadjustment);
gtk_layout_set_vadjustment (layout, vadjustment);
gtk_layout_set_adjustments (layout, hadjustment, vadjustment);
return GTK_WIDGET (layout);
}
......@@ -118,6 +117,8 @@ gtk_layout_set_adjustments (GtkLayout *layout,
GtkAdjustment *hadj,
GtkAdjustment *vadj)
{
gboolean need_adjust = FALSE;
g_return_if_fail (layout != NULL);
g_return_if_fail (GTK_IS_LAYOUT (layout));
......@@ -151,7 +152,7 @@ gtk_layout_set_adjustments (GtkLayout *layout,
gtk_signal_connect (GTK_OBJECT (layout->hadjustment), "value_changed",
(GtkSignalFunc) gtk_layout_adjustment_changed,
layout);
gtk_layout_adjustment_changed (hadj, layout);
need_adjust = TRUE;
}
if (layout->vadjustment != vadj)
......@@ -163,8 +164,11 @@ gtk_layout_set_adjustments (GtkLayout *layout,
gtk_signal_connect (GTK_OBJECT (layout->vadjustment), "value_changed",
(GtkSignalFunc) gtk_layout_adjustment_changed,
layout);
gtk_layout_adjustment_changed (vadj, layout);
need_adjust = TRUE;
}
if (need_adjust)
gtk_layout_adjustment_changed (NULL, layout);
}
void
......@@ -174,19 +178,7 @@ gtk_layout_set_hadjustment (GtkLayout *layout,
g_return_if_fail (layout != NULL);
g_return_if_fail (GTK_IS_LAYOUT (layout));
if (layout->hadjustment)
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;
gtk_layout_set_adjustments (layout, adjustment, layout->vadjustment);
}
......@@ -197,19 +189,7 @@ gtk_layout_set_vadjustment (GtkLayout *layout,
g_return_if_fail (layout != NULL);
g_return_if_fail (GTK_IS_LAYOUT (layout));
if (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->vadjustment = adjustment;
gtk_layout_set_adjustments (layout, layout->hadjustment, adjustment);
}
......@@ -232,6 +212,7 @@ gtk_layout_put (GtkLayout *layout,
child->y = y;
child->widget->requisition.width = 0;
child->widget->requisition.height = 0;
child->mapped = FALSE;
layout->children = g_list_append (layout->children, child);
......@@ -481,12 +462,14 @@ gtk_layout_map (GtkWidget *widget)
{
GtkLayoutChild *child = tmp_list->data;
if (GTK_WIDGET_VISIBLE (child->widget) &&
!GTK_WIDGET_MAPPED (child->widget))
if (child->mapped && GTK_WIDGET_VISIBLE (child->widget))
{
if (!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
if (child->window)
gdk_window_show (child->window);
}
tmp_list = tmp_list->next;
}
......@@ -761,13 +744,22 @@ gtk_layout_position_child (GtkLayout *layout,
if ((x >= G_MINSHORT) && (x <= G_MAXSHORT) &&
(y >= G_MINSHORT) && (y <= G_MAXSHORT))
{
if (GTK_WIDGET_VISIBLE (child->widget) &&
GTK_WIDGET_MAPPED (layout) &&
!GTK_WIDGET_MAPPED (child->widget))
if (!child->mapped)
{
child->mapped = 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)
{
......@@ -800,11 +792,15 @@ gtk_layout_position_child (GtkLayout *layout,
}
else
{
if (child->mapped)
{
child->mapped = FALSE;
if (child->window)
gdk_window_hide (child->window);
else if (GTK_WIDGET_MAPPED (child->widget))
gtk_widget_unmap (child->widget);
}
}
}
static void
......@@ -914,10 +910,11 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
if (layout->frozen)
return;
gtk_layout_position_children (layout);
if (!GTK_WIDGET_MAPPED (layout))
{
gtk_layout_position_children (layout);
return;
}
if (dx > 0)
{
......@@ -1016,6 +1013,8 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
-dy);
}
gtk_layout_position_children (layout);
/* We have to make sure that all exposes from this scroll get
* processed before we scroll again, or the expose events will
* have invalid coordinates.
......
......@@ -45,6 +45,7 @@ struct _GtkLayoutChild {
GdkWindow *window; /* For NO_WINDOW widgets */
gint x;
gint y;
gboolean mapped : 1;
};
struct _GtkLayout {
......
......@@ -88,6 +88,7 @@ gtk_plug_init (GtkPlug *plug)
window->type = GTK_WINDOW_TOPLEVEL;
window->auto_shrink = TRUE;
}
void
gtk_plug_construct (GtkPlug *plug, guint32 socket_id)
{
......@@ -100,6 +101,7 @@ gtk_plug_construct (GtkPlug *plug, guint32 socket_id)
plug->same_app = FALSE;
}
}
GtkWidget*
gtk_plug_new (guint32 socket_id)
{
......
......@@ -7994,7 +7994,6 @@ void create_layout (void)
gtk_widget_set_usize (window, 200, 200);
scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow);
gtk_container_add (GTK_CONTAINER (window), scrolledwindow);
......@@ -8005,8 +8004,7 @@ void create_layout (void)
gtk_signal_connect (GTK_OBJECT (layout), "expose_event",
GTK_SIGNAL_FUNC (layout_expose_handler), NULL);
gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 1600);
gtk_widget_show (layout);
gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 64000);
for (i=0 ; i < 16 ; i++)
for (j=0 ; j < 16 ; j++)
......@@ -8016,14 +8014,26 @@ void create_layout (void)
button = gtk_button_new_with_label (buf);
else
button = gtk_label_new (buf);
gtk_layout_put (GTK_LAYOUT (layout), button,
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))
gtk_widget_show (window);
gtk_widget_show_all (window);
else
gtk_widget_destroy (window);
}
......
......@@ -7994,7 +7994,6 @@ void create_layout (void)
gtk_widget_set_usize (window, 200, 200);
scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow);
gtk_container_add (GTK_CONTAINER (window), scrolledwindow);
......@@ -8005,8 +8004,7 @@ void create_layout (void)
gtk_signal_connect (GTK_OBJECT (layout), "expose_event",
GTK_SIGNAL_FUNC (layout_expose_handler), NULL);
gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 1600);
gtk_widget_show (layout);
gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 64000);
for (i=0 ; i < 16 ; i++)
for (j=0 ; j < 16 ; j++)
......@@ -8016,14 +8014,26 @@ void create_layout (void)
button = gtk_button_new_with_label (buf);
else
button = gtk_label_new (buf);
gtk_layout_put (GTK_LAYOUT (layout), button,
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))
gtk_widget_show (window);
gtk_widget_show_all (window);
else
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