diff options
author | Owen Taylor <otaylor@redhat.com> | 1999-01-05 23:46:49 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1999-01-05 23:46:49 +0000 |
commit | 5126b13c0a27f93676e006cd681aea1eca6f88f8 (patch) | |
tree | e65a4866ebfb6a463d7929975d8d2f974725b0c3 /gtk | |
parent | 1fd7a6e491b6b76f9281bb14e6161a75df71bf5e (diff) | |
download | gtk+-5126b13c0a27f93676e006cd681aea1eca6f88f8.tar.gz |
When redrawing the under-cursor character, don't redraw the terminating
Tue Jan 5 11:51:32 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_draw_cursor_on_drawable):
When redrawing the under-cursor character, don't
redraw the terminating NULL.
[ From: dov@imagic.weizmann.ac.il (Dov Grobgeld) ]
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkentry.c | 14 | ||||
-rw-r--r-- | gtk/gtkpreview.c | 65 |
2 files changed, 64 insertions, 15 deletions
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 7271156b0a..cdb06877f0 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -1454,12 +1454,14 @@ gtk_entry_draw_cursor_on_drawable (GtkEntry *entry, GdkDrawable *drawable) NULL, widget, "entry_bg", xoffset, INNER_BORDER, 1, text_area_height - INNER_BORDER); - /* Draw the character under the cursor again */ - - gdk_draw_text_wc (drawable, widget->style->font, - widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - xoffset, yoffset, - entry->text + editable->current_pos, 1); + + /* Draw the character under the cursor again + */ + if (editable->current_pos < entry->text_length) + gdk_draw_text_wc (drawable, widget->style->font, + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + xoffset, yoffset, + entry->text + editable->current_pos, 1); } diff --git a/gtk/gtkpreview.c b/gtk/gtkpreview.c index 05df6d9836..ef546c7784 100644 --- a/gtk/gtkpreview.c +++ b/gtk/gtkpreview.c @@ -34,6 +34,8 @@ static void gtk_preview_class_init (GtkPreviewClass *klass); static void gtk_preview_init (GtkPreview *preview); static void gtk_preview_finalize (GtkObject *object); static void gtk_preview_realize (GtkWidget *widget); +static void gtk_preview_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); static gint gtk_preview_expose (GtkWidget *widget, GdkEventExpose *event); static void gtk_preview_make_buffer (GtkPreview *preview); @@ -84,6 +86,7 @@ gtk_preview_class_init (GtkPreviewClass *klass) object_class->finalize = gtk_preview_finalize; widget_class->realize = gtk_preview_realize; + widget_class->size_allocate = gtk_preview_size_allocate; widget_class->expose_event = gtk_preview_expose; klass->info.visual = NULL; @@ -406,10 +409,21 @@ gtk_preview_realize (GtkWidget *widget) preview = GTK_PREVIEW (widget); attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + + if (preview->expand) + { + attributes.width = widget->allocation.width; + attributes.height = widget->allocation.height; + } + else + { + attributes.width = MIN (widget->requisition.width, widget->allocation.width); + attributes.height = MIN (widget->requisition.height, widget->allocation.height); + } + + attributes.x = widget->allocation.x + (widget->allocation.width - attributes.width) / 2; + attributes.y = widget->allocation.y + (widget->allocation.height - attributes.height) / 2;; + attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = preview_class->info.visual; attributes.colormap = preview_class->info.cmap; @@ -421,7 +435,39 @@ gtk_preview_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); +} + +static void +gtk_preview_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkPreview *preview; + gint width, height; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_PREVIEW (widget)); + + preview = GTK_PREVIEW (widget); + widget->allocation = *allocation; + + if (GTK_WIDGET_REALIZED (widget)) + { + if (preview->expand) + { + width = widget->allocation.width; + height = widget->allocation.height; + } + else + { + width = MIN (widget->allocation.width, widget->requisition.width); + height = MIN (widget->allocation.height, widget->requisition.height); + } + + gdk_window_move_resize (widget->window, + widget->allocation.x + (widget->allocation.width - width) / 2, + widget->allocation.y + (widget->allocation.height - height) / 2, + width, height); + } } static gint @@ -429,6 +475,7 @@ gtk_preview_expose (GtkWidget *widget, GdkEventExpose *event) { GtkPreview *preview; + gint width, height; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_PREVIEW (widget), FALSE); @@ -438,12 +485,12 @@ gtk_preview_expose (GtkWidget *widget, { preview = GTK_PREVIEW (widget); + gdk_window_get_size (widget->window, &width, &height); + gtk_preview_put (GTK_PREVIEW (widget), widget->window, widget->style->black_gc, - event->area.x - - (widget->allocation.width - preview->buffer_width)/2, - event->area.y - - (widget->allocation.height - preview->buffer_height)/2, + event->area.x - (width - preview->buffer_width)/2, + event->area.y - (height - preview->buffer_height)/2, event->area.x, event->area.y, event->area.width, event->area.height); } |