# HG changeset patch # User Todd Kulesza # Date 968876884 0 # Node ID 81a8fb0a565f305dc3859a2f596439b9865e094a # Parent b5b3aa06111d2ecfffe001e30d633d75026ab937 [gaim-migrate @ 905] sorry about that last patch, this one is better tested :) committer: Tailor Script diff -r b5b3aa06111d -r 81a8fb0a565f src/gtkhtml.c --- a/src/gtkhtml.c Wed Sep 13 18:49:33 2000 +0000 +++ b/src/gtkhtml.c Wed Sep 13 20:28:04 2000 +0000 @@ -169,6 +169,8 @@ static void draw_cursor(GtkHtml * html); static void undraw_cursor(GtkHtml * html); +static int get_line_height(GtkHtml *, GtkHtmlBit *); + static GtkWidgetClass *parent_class = NULL; GtkType gtk_html_get_type(void) @@ -1837,10 +1839,14 @@ GtkStateType selected_state; GtkWidget *widget = GTK_WIDGET(html); GdkRectangle area; - + GList *hbits; + GtkHtmlBit *hbit; + if (html->frozen > 0) return; + hbits = g_list_find(html->html_bits, hb); + if (hb->type == HTML_BIT_TEXT) { @@ -1865,7 +1871,6 @@ selected_state = GTK_STATE_SELECTED; } - gdk_text_extents(hb->font, hb->text, 1, &shift, NULL, NULL, NULL, NULL); if (selected_state == GTK_STATE_SELECTED) @@ -1928,7 +1933,6 @@ startx += hb->x; - area.x = hb->x - html->xoffset; area.y = hb->y - hb->height + 3 - html->yoffset; area.width = hb->width + 2; @@ -1957,9 +1961,6 @@ hb->was_selected = 0; } - - - if (selected_state == GTK_STATE_SELECTED && (mypos == epos || mypos == spos)) { @@ -2000,12 +2001,6 @@ else gdk_gc_set_foreground(gc, &widget->style->fg[selected_state]); - if (hb->back != NULL) - gdk_gc_set_background(gc, hb->back); - else - gdk_gc_set_background(gc, - &widget->style->bg[selected_state]); - gdk_gc_set_font(gc, hb->font); @@ -2053,8 +2048,8 @@ if (hb->text && hb->back != NULL && selected_state != GTK_STATE_SELECTED) { - int hwidth, hheight; - int hei = gdk_text_height(hb->font, "C", 1); + int hwidth, hheight, hei; + hei = get_line_height(html, hb); gdk_window_get_size(html->html_area, &hwidth, &hheight); gdk_gc_set_foreground(gc, hb->back); gdk_draw_rectangle(html->html_area, gc, TRUE /* filled */, @@ -2066,15 +2061,9 @@ gdk_gc_set_foreground(gc, hb->fore); else gdk_gc_set_foreground(gc, &widget->style->fg[selected_state]); - if (hb->back != NULL) - gdk_gc_set_background(gc, hb->back); - else - gdk_gc_set_background(gc, &widget->style->bg[selected_state]); - gdk_gc_set_font(gc, hb->font); - gdk_draw_string(html->html_area, hb->font, gc, shift + hb->x, hb->y - html->yoffset, hb->text); if (hb->uline) @@ -2255,7 +2244,7 @@ clear_area(html, &area); - gtk_html_draw_bit(html, html->cursor_hb, 1); + (html, html->cursor_hb, 1); } @@ -2281,6 +2270,11 @@ realy = area->y + html->yoffset; + /* this is needed since background colors draw across the entire window width + if anyone knows of a cleaner way to work bg colors, please submit code =) */ + area->x = 0; + area->width = width; + clear_area(html, area); while (hbits) @@ -4333,3 +4327,27 @@ } } } + +static int get_line_height(GtkHtml *html, GtkHtmlBit *start) +{ + int height, max_height = 0; + GList *hbits = html->html_bits; + GtkHtmlBit *hbit; + + hbits = g_list_find(hbits, start); + + while (TRUE) + { + hbit = hbits->data; + if (hbit->font) + height = gdk_text_height(hbit->font, "C", 1); + + if (max_height < height) + max_height = height; + if (hbit->newline) + break; + hbits = hbits->next; + } + + return max_height; +}