expose the child widgets in here (gtk_text_view_realize): set parent

2001-11-05  Havoc Pennington  <hp@redhat.com>

	* gtk/gtktextview.c (gtk_text_view_paint): expose the child
	widgets in here
	(gtk_text_view_realize): set parent window of child widgets
	(gtk_text_view_size_request): use child req to decide whether
	to invalidate layout, not widget->requisition

	* gtk/gtktextdisplay.c (render_layout_line): set
	shaped_width_pixels for NULL shape objects, so that we properly
	draw the "missing pixbuf/widget" thing
	(render_layout_line): don't draw the widget here
	(gtk_text_layout_draw): pass out a list of widgets that need exposing

	* demos/gtk-demo/textview.c (insert_text): add demo of child
	widgets

	* gtk/gtktextlayout.c (add_child_attrs): remove debug spew

	* gtk/gtktextdisplay.c (render_layout_line): remove debug spew

	* gtk/gtktextview.c (gtk_text_view_update_child_allocation): add
	scroll offsets
	(gtk_text_view_value_changed): poke new X and Y into child allocations
This commit is contained in:
Havoc Pennington 2001-11-06 00:54:24 +00:00 committed by Havoc Pennington
parent 9af1351da5
commit 604eebd380
12 changed files with 445 additions and 123 deletions

View File

@ -1,3 +1,28 @@
2001-11-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): expose the child
widgets in here
(gtk_text_view_realize): set parent window of child widgets
(gtk_text_view_size_request): use child req to decide whether
to invalidate layout, not widget->requisition
* gtk/gtktextdisplay.c (render_layout_line): set
shaped_width_pixels for NULL shape objects, so that we properly
draw the "missing pixbuf/widget" thing
(render_layout_line): don't draw the widget here
(gtk_text_layout_draw): pass out a list of widgets that need exposing
* demos/gtk-demo/textview.c (insert_text): add demo of child
widgets
* gtk/gtktextlayout.c (add_child_attrs): remove debug spew
* gtk/gtktextdisplay.c (render_layout_line): remove debug spew
* gtk/gtktextview.c (gtk_text_view_update_child_allocation): add
scroll offsets
(gtk_text_view_value_changed): poke new X and Y into child allocations
2001-11-06 Tor Lillqvist <tml@iki.fi>
* gtk/gtkmain.c (find_module): Do search GTK_BINARY_VERSION

View File

@ -1,3 +1,28 @@
2001-11-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): expose the child
widgets in here
(gtk_text_view_realize): set parent window of child widgets
(gtk_text_view_size_request): use child req to decide whether
to invalidate layout, not widget->requisition
* gtk/gtktextdisplay.c (render_layout_line): set
shaped_width_pixels for NULL shape objects, so that we properly
draw the "missing pixbuf/widget" thing
(render_layout_line): don't draw the widget here
(gtk_text_layout_draw): pass out a list of widgets that need exposing
* demos/gtk-demo/textview.c (insert_text): add demo of child
widgets
* gtk/gtktextlayout.c (add_child_attrs): remove debug spew
* gtk/gtktextdisplay.c (render_layout_line): remove debug spew
* gtk/gtktextview.c (gtk_text_view_update_child_allocation): add
scroll offsets
(gtk_text_view_value_changed): poke new X and Y into child allocations
2001-11-06 Tor Lillqvist <tml@iki.fi>
* gtk/gtkmain.c (find_module): Do search GTK_BINARY_VERSION

View File

@ -1,3 +1,28 @@
2001-11-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): expose the child
widgets in here
(gtk_text_view_realize): set parent window of child widgets
(gtk_text_view_size_request): use child req to decide whether
to invalidate layout, not widget->requisition
* gtk/gtktextdisplay.c (render_layout_line): set
shaped_width_pixels for NULL shape objects, so that we properly
draw the "missing pixbuf/widget" thing
(render_layout_line): don't draw the widget here
(gtk_text_layout_draw): pass out a list of widgets that need exposing
* demos/gtk-demo/textview.c (insert_text): add demo of child
widgets
* gtk/gtktextlayout.c (add_child_attrs): remove debug spew
* gtk/gtktextdisplay.c (render_layout_line): remove debug spew
* gtk/gtktextview.c (gtk_text_view_update_child_allocation): add
scroll offsets
(gtk_text_view_value_changed): poke new X and Y into child allocations
2001-11-06 Tor Lillqvist <tml@iki.fi>
* gtk/gtkmain.c (find_module): Do search GTK_BINARY_VERSION

View File

@ -1,3 +1,28 @@
2001-11-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): expose the child
widgets in here
(gtk_text_view_realize): set parent window of child widgets
(gtk_text_view_size_request): use child req to decide whether
to invalidate layout, not widget->requisition
* gtk/gtktextdisplay.c (render_layout_line): set
shaped_width_pixels for NULL shape objects, so that we properly
draw the "missing pixbuf/widget" thing
(render_layout_line): don't draw the widget here
(gtk_text_layout_draw): pass out a list of widgets that need exposing
* demos/gtk-demo/textview.c (insert_text): add demo of child
widgets
* gtk/gtktextlayout.c (add_child_attrs): remove debug spew
* gtk/gtktextdisplay.c (render_layout_line): remove debug spew
* gtk/gtktextview.c (gtk_text_view_update_child_allocation): add
scroll offsets
(gtk_text_view_value_changed): poke new X and Y into child allocations
2001-11-06 Tor Lillqvist <tml@iki.fi>
* gtk/gtkmain.c (find_module): Do search GTK_BINARY_VERSION

View File

@ -1,3 +1,28 @@
2001-11-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): expose the child
widgets in here
(gtk_text_view_realize): set parent window of child widgets
(gtk_text_view_size_request): use child req to decide whether
to invalidate layout, not widget->requisition
* gtk/gtktextdisplay.c (render_layout_line): set
shaped_width_pixels for NULL shape objects, so that we properly
draw the "missing pixbuf/widget" thing
(render_layout_line): don't draw the widget here
(gtk_text_layout_draw): pass out a list of widgets that need exposing
* demos/gtk-demo/textview.c (insert_text): add demo of child
widgets
* gtk/gtktextlayout.c (add_child_attrs): remove debug spew
* gtk/gtktextdisplay.c (render_layout_line): remove debug spew
* gtk/gtktextview.c (gtk_text_view_update_child_allocation): add
scroll offsets
(gtk_text_view_value_changed): poke new X and Y into child allocations
2001-11-06 Tor Lillqvist <tml@iki.fi>
* gtk/gtkmain.c (find_module): Do search GTK_BINARY_VERSION

View File

@ -1,3 +1,28 @@
2001-11-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): expose the child
widgets in here
(gtk_text_view_realize): set parent window of child widgets
(gtk_text_view_size_request): use child req to decide whether
to invalidate layout, not widget->requisition
* gtk/gtktextdisplay.c (render_layout_line): set
shaped_width_pixels for NULL shape objects, so that we properly
draw the "missing pixbuf/widget" thing
(render_layout_line): don't draw the widget here
(gtk_text_layout_draw): pass out a list of widgets that need exposing
* demos/gtk-demo/textview.c (insert_text): add demo of child
widgets
* gtk/gtktextlayout.c (add_child_attrs): remove debug spew
* gtk/gtktextdisplay.c (render_layout_line): remove debug spew
* gtk/gtktextview.c (gtk_text_view_update_child_allocation): add
scroll offsets
(gtk_text_view_value_changed): poke new X and Y into child allocations
2001-11-06 Tor Lillqvist <tml@iki.fi>
* gtk/gtkmain.c (find_module): Do search GTK_BINARY_VERSION

View File

@ -1,3 +1,28 @@
2001-11-05 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_paint): expose the child
widgets in here
(gtk_text_view_realize): set parent window of child widgets
(gtk_text_view_size_request): use child req to decide whether
to invalidate layout, not widget->requisition
* gtk/gtktextdisplay.c (render_layout_line): set
shaped_width_pixels for NULL shape objects, so that we properly
draw the "missing pixbuf/widget" thing
(render_layout_line): don't draw the widget here
(gtk_text_layout_draw): pass out a list of widgets that need exposing
* demos/gtk-demo/textview.c (insert_text): add demo of child
widgets
* gtk/gtktextlayout.c (add_child_attrs): remove debug spew
* gtk/gtktextdisplay.c (render_layout_line): remove debug spew
* gtk/gtktextview.c (gtk_text_view_update_child_allocation): add
scroll offsets
(gtk_text_view_value_changed): poke new X and Y into child allocations
2001-11-06 Tor Lillqvist <tml@iki.fi>
* gtk/gtkmain.c (find_module): Do search GTK_BINARY_VERSION

View File

@ -8,36 +8,7 @@
*/
#include <gtk/gtk.h>
/* Don't copy this bad example; inline RGB data is always a better
* idea than inline XPMs.
*/
static char *book_closed_xpm[] = {
"16 16 6 1",
" c None s None",
". c black",
"X c red",
"o c yellow",
"O c #808080",
"# c white",
" ",
" .. ",
" ..XX. ",
" ..XXXXX. ",
" ..XXXXXXXX. ",
".ooXXXXXXXXX. ",
"..ooXXXXXXXXX. ",
".X.ooXXXXXXXXX. ",
".XX.ooXXXXXX.. ",
" .XX.ooXXX..#O ",
" .XX.oo..##OO. ",
" .XX..##OO.. ",
" .X.#OO.. ",
" ..O.. ",
" .. ",
" "
};
#include <stdlib.h> /* for exit() */
#define gray50_width 2
#define gray50_height 2
@ -71,7 +42,7 @@ create_tags (GtkTextBuffer *buffer)
gtk_text_buffer_create_tag (buffer, "heading",
"weight", PANGO_WEIGHT_BOLD,
"size", 20 * PANGO_SCALE,
"size", 15 * PANGO_SCALE,
NULL);
gtk_text_buffer_create_tag (buffer, "italic",
@ -82,7 +53,7 @@ create_tags (GtkTextBuffer *buffer)
gtk_text_buffer_create_tag (buffer, "big",
/* points times the PANGO_SCALE factor */
"size", 30 * PANGO_SCALE, NULL);
"size", 20 * PANGO_SCALE, NULL);
gtk_text_buffer_create_tag (buffer, "xx-small",
"scale", PANGO_SCALE_XX_SMALL, NULL);
@ -176,8 +147,22 @@ insert_text (GtkTextBuffer *buffer)
GtkTextIter iter;
GtkTextIter start, end;
GdkPixbuf *pixbuf;
GdkPixbuf *scaled;
GtkTextChildAnchor *anchor;
pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) book_closed_xpm);
pixbuf = gdk_pixbuf_new_from_file ("./gtk-logo-rgb.gif", NULL);
if (pixbuf == NULL)
gdk_pixbuf_new_from_file (DEMOCODEDIR"/gtk-logo-rgb.gif", NULL);
if (pixbuf == NULL)
{
g_printerr ("Failed to load image file gtk-logo-rgb.gif\n");
exit (1);
}
scaled = gdk_pixbuf_scale_simple (pixbuf, 32, 32, GDK_INTERP_BILINEAR);
g_object_unref (G_OBJECT (pixbuf));
pixbuf = scaled;
/* get start of buffer; each insertion will revalidate the
* iterator to point to just after the inserted text.
@ -336,9 +321,21 @@ insert_text (GtkTextBuffer *buffer)
gtk_text_buffer_insert (buffer, &iter,
"You can put all sorts of Unicode text in the buffer.\n\nGerman (Deutsch Süd) Grüß Gott\nGreek (Ελληνικά) Γειά σας\nHebrew שלום\nJapanese (日本語)\n\nThe widget properly handles bidirectional text, word wrapping, DOS/UNIX/Unicode paragraph separators, grapheme boundaries, and so on using the Pango internationalization framework.\n", -1);
gtk_text_buffer_insert (buffer, &iter, "Here's a word-wrapped quote in a right-to-left language:\n", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "وقد بدأ ثلاث من أكثر المؤسسات تقدما في شبكة اكسيون برامجها كمنظمات لا تسعى للربح، ثم تحولت في السنوات الخمس الماضية إلى مؤسسات مالية منظمة، وباتت جزءا من النظام المالي في بلدانها، ولكنها تتخصص في خدمة قطاع المشروعات الصغيرة. وأحد أكثر هذه المؤسسات نجاحا هو »بانكوسول« في بوليفيا.\n\n", -1,
gtk_text_buffer_insert (buffer, &iter, "Here's a word-wrapped quote in a right-to-left language:\n", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "وقد بدأ ثلاث من أكثر المؤسسات تقدما في شبكة اكسيون برامجها كمنظمات لا تسعى للربح، ثم تحولت في السنوات الخمس الماضية إلى مؤسسات مالية منظمة، وباتت جزءا من النظام المالي في بلدانها، ولكنها تتخصص في خدمة قطاع المشروعات الصغيرة. وأحد أكثر هذه المؤسسات نجاحا هو »بانكوسول« في بوليفيا.\n\n", -1,
"rtl_quote", NULL);
gtk_text_buffer_insert (buffer, &iter, "You can put widgets in the buffer: Here's a button: ", -1);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, " and a menu: ", -1);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, " and a scale: ", -1);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, " and an animation: ", -1);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, " finally a text entry: ", -1);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, ".\n", -1);
gtk_text_buffer_insert (buffer, &iter, "\n\nThis demo doesn't demonstrate all the GtkTextBuffer features; it leaves out, for example: invisible/hidden text (doesn't work in GTK 2, but planned), tab stops, application-drawn areas on the sides of the widget for displaying breakpoints and such...", -1);
@ -349,6 +346,91 @@ insert_text (GtkTextBuffer *buffer)
g_object_unref (G_OBJECT (pixbuf));
}
static gboolean
find_anchor (GtkTextIter *iter)
{
while (gtk_text_iter_forward_char (iter))
{
if (gtk_text_iter_get_child_anchor (iter))
return TRUE;
}
return FALSE;
}
static void
attach_widgets (GtkTextView *text_view)
{
GtkTextIter iter;
GtkTextBuffer *buffer;
int i;
buffer = gtk_text_view_get_buffer (text_view);
gtk_text_buffer_get_start_iter (buffer, &iter);
i = 0;
while (find_anchor (&iter))
{
GtkTextChildAnchor *anchor;
GtkWidget *widget;
anchor = gtk_text_iter_get_child_anchor (&iter);
if (i == 0)
{
widget = gtk_button_new_with_label ("Click Me");
}
else if (i == 1)
{
GtkWidget *menu_item;
GtkWidget *menu;
menu = gtk_menu_new ();
widget = gtk_option_menu_new ();
menu_item = gtk_menu_item_new_with_label ("Option 1");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
menu_item = gtk_menu_item_new_with_label ("Option 2");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
menu_item = gtk_menu_item_new_with_label ("Option 3");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu);
}
else if (i == 2)
{
widget = gtk_hscale_new (NULL);
gtk_range_set_range (GTK_RANGE (widget), 0, 100);
gtk_widget_set_size_request (widget, 70, -1);
}
else if (i == 3)
{
if (g_file_test ("./floppybuddy.gif", G_FILE_TEST_EXISTS))
widget = gtk_image_new_from_file ("./floppybuddy.gif");
else
widget = gtk_image_new_from_file (DEMOCODEDIR"/floppybuddy.gif");
}
else if (i == 4)
{
widget = gtk_entry_new ();
}
else
{
widget = NULL; /* avoids a compiler warning */
g_assert_not_reached ();
}
gtk_text_view_add_child_at_anchor (text_view,
widget,
anchor);
gtk_widget_show_all (widget);
++i;
}
}
GtkWidget *
do_textview (void)
{
@ -403,6 +485,9 @@ do_textview (void)
create_tags (buffer);
insert_text (buffer);
attach_widgets (GTK_TEXT_VIEW (view1));
attach_widgets (GTK_TEXT_VIEW (view2));
gtk_widget_show_all (vpaned);
}

View File

@ -96,9 +96,9 @@ Creates a new #GtkMenu.
Adds a new #GtkMenuItem to the end of the menu's item list.
</para>
<!-- # Unused Parameters # -->
@menu: a #GtkMenu.
@child: The #GtkMenuItem to add.
<!-- # Unused Parameters # -->
@m:
@c:
@ -108,9 +108,9 @@ Adds a new #GtkMenuItem to the end of the menu's item list.
Adds a new #GtkMenuItem to the beginning of the menu's item list.
</para>
<!-- # Unused Parameters # -->
@menu: a #GtkMenu.
@child: The #GtkMenuItem to add.
<!-- # Unused Parameters # -->
@menu_child:
@m:
@c:
@ -122,10 +122,10 @@ Adds a new #GtkMenuItem to the menu's item list at the position
indicated by @position.
</para>
<!-- # Unused Parameters # -->
@menu: a #GtkMenu.
@child: The #GtkMenuItem to add.
@pos:
<!-- # Unused Parameters # -->
@position: The position in the item list where @child is added.
Positions are numbered from 0 to n-1.

View File

@ -222,7 +222,8 @@ render_layout_line (GdkDrawable *drawable,
GSList **shaped_pointer,
int x,
int y,
gboolean selected)
gboolean selected,
GList **widgets)
{
GSList *tmp_list = line->runs;
PangoRectangle overall_rect;
@ -331,6 +332,8 @@ render_layout_line (GdkDrawable *drawable,
shape_rect.x,
shape_rect.y + shape_rect.height);
}
shaped_width_pixels = shape_rect.width;
}
else if (GDK_IS_PIXBUF (shaped))
{
@ -398,37 +401,17 @@ render_layout_line (GdkDrawable *drawable,
}
else if (GTK_IS_WIDGET (shaped))
{
gint width, height;
GdkRectangle draw_rect;
GtkWidget *widget;
widget = GTK_WIDGET (shaped);
width = widget->allocation.width;
height = widget->allocation.height;
g_print ("widget allocation at %d,%d %d x %d\n",
widget->allocation.x,
widget->allocation.y,
widget->allocation.width,
widget->allocation.height);
if (GTK_WIDGET_DRAWABLE (widget) &&
gdk_rectangle_intersect (&widget->allocation,
&render_state->clip_rect,
&draw_rect))
shaped_width_pixels = widget->allocation.width;
if (widgets)
{
g_print ("drawing widget area %d,%d %d x %d\n",
draw_rect.x,
draw_rect.y,
draw_rect.width,
draw_rect.height);
gtk_widget_draw (widget, &draw_rect);
g_object_ref (G_OBJECT (widget));
*widgets = g_list_prepend (*widgets, widget);
}
shaped_width_pixels = width;
}
else
g_assert_not_reached (); /* not a pixbuf or widget */
@ -490,7 +473,8 @@ render_para (GdkDrawable *drawable,
int x,
int y,
int selection_start_index,
int selection_end_index)
int selection_end_index,
GList **widgets)
{
GSList *shaped_pointer = line_display->shaped_objects;
PangoLayout *layout = line_display->layout;
@ -571,7 +555,8 @@ render_para (GdkDrawable *drawable,
render_layout_line (drawable, render_state, line, &shaped_pointer,
x + PANGO_PIXELS (line_rect.x),
y + PANGO_PIXELS (baseline),
TRUE);
TRUE,
widgets);
}
else
{
@ -581,7 +566,8 @@ render_para (GdkDrawable *drawable,
line, &shaped_pointer,
x + PANGO_PIXELS (line_rect.x),
y + PANGO_PIXELS (baseline),
FALSE);
FALSE,
widgets);
if (selection_start_index <= byte_offset + line->length &&
selection_end_index > byte_offset) /* Some selected */
@ -605,7 +591,8 @@ render_para (GdkDrawable *drawable,
render_layout_line (drawable, render_state, line, &shaped_pointer_tmp,
x + PANGO_PIXELS (line_rect.x),
y + PANGO_PIXELS (baseline),
TRUE);
TRUE,
widgets);
gdk_gc_set_clip_region (fg_gc, NULL);
gdk_gc_set_clip_region (bg_gc, NULL);
@ -727,7 +714,9 @@ gtk_text_layout_draw (GtkTextLayout *layout,
gint x,
gint y,
gint width,
gint height)
gint height,
/* widgets to expose */
GList **widgets)
{
GdkRectangle clip;
gint current_y;
@ -821,8 +810,8 @@ gtk_text_layout_draw (GtkTextLayout *layout,
render_para (drawable, render_state, line_display,
- x_offset,
current_y,
selection_start_index, selection_end_index);
selection_start_index, selection_end_index,
widgets);
/* We paint the cursors last, because they overlap another chunk
and need to appear on top. */

View File

@ -94,6 +94,7 @@ extern "C" {
* x_offset/y_offset - Position of the drawable in layout coordinates
* x/y/width/height - Region of the layout to render. x,y must be inside
* the drawable.
* widgets - list of widgets that need exposing
*/
void gtk_text_layout_draw (GtkTextLayout *layout,
GtkWidget *widget,
@ -104,7 +105,8 @@ void gtk_text_layout_draw (GtkTextLayout *layout,
gint x,
gint y,
gint width,
gint height);
gint height,
GList **widgets);

View File

@ -2401,10 +2401,13 @@ gtk_text_view_size_request (GtkWidget *widget,
GtkRequisition child_req;
GtkRequisition old_req;
old_req = child->widget->requisition;
gtk_widget_get_child_requisition (child->widget, &old_req);
gtk_widget_size_request (child->widget, &child_req);
gtk_widget_get_child_requisition (child->widget, &child_req);
/* Invalidate layout lines if required */
if (text_view->layout &&
(old_req.width != child_req.width ||
old_req.height != child_req.height))
@ -2421,12 +2424,13 @@ gtk_text_view_size_request (GtkWidget *widget,
}
static void
gtk_text_view_update_child_allocation (GtkTextView *text_view,
GtkTextViewChild *vc)
gtk_text_view_compute_child_allocation (GtkTextView *text_view,
GtkTextViewChild *vc,
GtkAllocation *allocation)
{
gint buffer_y;
GtkTextIter iter;
GtkAllocation allocation;
GtkRequisition req;
gtk_text_buffer_get_iter_at_child_anchor (get_buffer (text_view),
&iter,
@ -2437,12 +2441,31 @@ gtk_text_view_update_child_allocation (GtkTextView *text_view,
buffer_y += vc->from_top_of_line;
allocation.x = vc->from_left_of_buffer;
allocation.y = buffer_y;
allocation.width = vc->widget->requisition.width;
allocation.height = vc->widget->requisition.height;
allocation->x = vc->from_left_of_buffer - text_view->xoffset;
allocation->y = buffer_y - text_view->yoffset;
gtk_widget_get_child_requisition (vc->widget, &req);
allocation->width = req.width;
allocation->height = req.height;
}
static void
gtk_text_view_update_child_allocation (GtkTextView *text_view,
GtkTextViewChild *vc)
{
GtkAllocation allocation;
gtk_text_view_compute_child_allocation (text_view, vc, &allocation);
gtk_widget_size_allocate (vc->widget, &allocation);
#if 0
g_print ("allocation for %p allocated to %d,%d yoffset = %d\n",
vc->widget,
vc->widget->allocation.x,
vc->widget->allocation.y,
text_view->yoffset);
#endif
}
static void
@ -2461,11 +2484,11 @@ gtk_text_view_child_allocated (GtkTextLayout *layout,
*/
vc = g_object_get_data (G_OBJECT (child),
"gtk-text-view-child");
"gtk-text-view-child");
g_assert (vc != NULL);
g_print ("child allocated at %d,%d\n", x, y);
DV (g_print ("child allocated at %d,%d\n", x, y));
vc->from_left_of_buffer = x;
vc->from_top_of_line = y;
@ -2976,6 +2999,7 @@ gtk_text_view_realize (GtkWidget *widget)
GtkTextView *text_view;
GdkWindowAttr attributes;
gint attributes_mask;
GSList *tmp_list;
text_view = GTK_TEXT_VIEW (widget);
GTK_WIDGET_SET_FLAGS (text_view, GTK_REALIZED);
@ -3027,6 +3051,16 @@ gtk_text_view_realize (GtkWidget *widget)
if (text_view->buffer)
gtk_text_buffer_add_selection_clipboard (text_view->buffer,
gtk_clipboard_get (GDK_SELECTION_PRIMARY));
tmp_list = text_view->children;
while (tmp_list != NULL)
{
GtkTextViewChild *vc = tmp_list->data;
text_view_child_set_parent_window (text_view, vc);
tmp_list = tmp_list->next;
}
}
static void
@ -3625,10 +3659,14 @@ gtk_text_view_motion_event (GtkWidget *widget, GdkEventMotion *event)
}
static void
gtk_text_view_paint (GtkWidget *widget, GdkRectangle *area)
gtk_text_view_paint (GtkWidget *widget,
GdkRectangle *area,
GdkEventExpose *event)
{
GtkTextView *text_view;
GList *child_exposes;
GList *tmp_list;
text_view = GTK_TEXT_VIEW (widget);
g_return_if_fail (text_view->layout != NULL);
@ -3649,7 +3687,8 @@ gtk_text_view_paint (GtkWidget *widget, GdkRectangle *area)
area->x, area->y,
area->width, area->height);
#endif
child_exposes = NULL;
gtk_text_layout_draw (text_view->layout,
widget,
text_view->text_window->bin_window,
@ -3657,31 +3696,34 @@ gtk_text_view_paint (GtkWidget *widget, GdkRectangle *area)
text_view->xoffset,
text_view->yoffset,
area->x, area->y,
area->width, area->height);
area->width, area->height,
&child_exposes);
tmp_list = child_exposes;
while (tmp_list != NULL)
{
GtkWidget *child = tmp_list->data;
gtk_container_propagate_expose (GTK_CONTAINER (text_view),
child,
event);
g_object_unref (G_OBJECT (child));
tmp_list = tmp_list->next;
}
g_list_free (child_exposes);
}
static gint
gtk_text_view_expose_event (GtkWidget *widget, GdkEventExpose *event)
{
#if 0
{
GdkWindow *win = event->window;
GdkColor color = { 0, 0, 0, 65535 };
GdkGC *gc = gdk_gc_new (win);
gdk_gc_set_rgb_fg_color (gc, &color);
gdk_draw_rectangle (win,
gc, TRUE,
event->area.x, event->area.y,
event->area.width, event->area.height);
gdk_gc_unref (gc);
}
#endif
{
if (event->window == gtk_text_view_get_window (GTK_TEXT_VIEW (widget),
GTK_TEXT_WINDOW_TEXT))
{
DV(g_print (">Exposed ("G_STRLOC")\n"));
gtk_text_view_paint (widget, &event->area);
gtk_text_view_paint (widget, &event->area, event);
}
if (event->window == widget->window)
@ -5166,7 +5208,7 @@ gtk_text_view_value_changed (GtkAdjustment *adj,
gint line_top;
gint dx = 0;
gint dy = 0;
/* Note that we oddly call this function with adj == NULL
* sometimes
*/
@ -5197,30 +5239,59 @@ gtk_text_view_value_changed (GtkAdjustment *adj,
}
}
if (GTK_WIDGET_REALIZED (text_view) && (dx != 0 || dy != 0))
if (dx != 0 || dy != 0)
{
if (dy != 0)
{
if (text_view->left_window)
text_window_scroll (text_view->left_window, 0, dy);
if (text_view->right_window)
text_window_scroll (text_view->right_window, 0, dy);
}
GSList *tmp_list;
if (dx != 0)
if (GTK_WIDGET_REALIZED (text_view))
{
if (text_view->top_window)
text_window_scroll (text_view->top_window, dx, 0);
if (text_view->bottom_window)
text_window_scroll (text_view->bottom_window, dx, 0);
if (dy != 0)
{
if (text_view->left_window)
text_window_scroll (text_view->left_window, 0, dy);
if (text_view->right_window)
text_window_scroll (text_view->right_window, 0, dy);
}
if (dx != 0)
{
if (text_view->top_window)
text_window_scroll (text_view->top_window, dx, 0);
if (text_view->bottom_window)
text_window_scroll (text_view->bottom_window, dx, 0);
}
/* It looks nicer to scroll the main area last, because
* it takes a while, and making the side areas update
* afterward emphasizes the slowness of scrolling the
* main area.
*/
text_window_scroll (text_view->text_window, dx, dy);
}
/* It looks nicer to scroll the main area last, because
* it takes a while, and making the side areas update
* afterward emphasizes the slowness of scrolling the
* main area.
/* Children are now "moved" in the text window, poke
* into widget->allocation for each child
*/
text_window_scroll (text_view->text_window, dx, dy);
tmp_list = text_view->children;
while (tmp_list != NULL)
{
GtkTextViewChild *child = tmp_list->data;
if (child->anchor)
{
child->widget->allocation.x -= dx;
child->widget->allocation.y -= dy;
#if 0
g_print ("allocation for %p tweaked to %d,%d\n",
child->widget,
child->widget->allocation.x,
child->widget->allocation.y);
#endif
}
tmp_list = g_slist_next (tmp_list);
}
}
/* This could result in invalidation, which would install the
@ -5236,7 +5307,7 @@ gtk_text_view_value_changed (GtkAdjustment *adj,
* that, or shouldn't be.
*/
gtk_text_view_validate_onscreen (text_view);
/* process exposes */
if (GTK_WIDGET_REALIZED (text_view))
{