Mercurial > pidgin
changeset 985:056bd26615ea
[gaim-migrate @ 995]
The patch *still* broke other things.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 13 Oct 2000 18:17:50 +0000 |
parents | 7ec6b092f227 |
children | ca8f1d02630a |
files | src/gtkhtml.c |
diffstat | 1 files changed, 40 insertions(+), 121 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkhtml.c Fri Oct 13 08:45:42 2000 +0000 +++ b/src/gtkhtml.c Fri Oct 13 18:17:50 2000 +0000 @@ -44,7 +44,7 @@ #include "pixmaps/admin_icon.xpm" #include "pixmaps/free_icon.xpm" #include "pixmaps/dt_icon.xpm" -#define MAX_SIZE 7 +#define MAX_SIZE 7 #define MIN_HTML_WIDTH_LINES 20 #define MIN_HTML_HEIGHT_LINES 10 #define BORDER_WIDTH 2 @@ -53,7 +53,6 @@ #define KEY_SCROLL_PIXELS 10 int font_sizes[] = { 80, 100, 120, 140, 200, 300, 400 }; -GtkHtmlBit *start_of_line = NULL; /* GdkFont *fixed_font[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; @@ -169,8 +168,7 @@ static void draw_cursor(GtkHtml * html); static void undraw_cursor(GtkHtml * html); -static int get_line_max_height(GtkHtml *, GtkHtmlBit *); -static void get_line_max_extents(GtkHtml *, GtkHtmlBit *, int *, int *); +static int get_line_height(GtkHtml *, GtkHtmlBit *); static GtkWidgetClass *parent_class = NULL; @@ -1846,6 +1844,8 @@ if (html->frozen > 0) return; + hbits = g_list_find(html->html_bits, hb); + if (hb->type == HTML_BIT_TEXT) { @@ -2046,43 +2046,22 @@ /*end my stuff*/ if (hb->text && hb->back != NULL) { - int hwidth, hheight, tmpcnt, max_ascent, max_descent; - - /* get the gtkhtmlbit at the start of each line, and use it as the starting point to calculate the - max height of each line and set the background-rectangle's size accordingly */ - /* FIXME: should also include a method of eliminating 'gaps' between different line using - different text sizes */ - if (!start_of_line) - start_of_line = hb; - else - { - hbits = g_list_find(html->html_bits, hb); - if (hbits->prev) - { - hbit = hbits->prev->data; - if (hbit && hbit->newline) - start_of_line = hb; - } - else - start_of_line = hb; - } - - get_line_max_extents(html, start_of_line, &max_ascent, &max_descent); + int hwidth, hheight, hei, tmpcnt; + hei = get_line_height(html, hb); gdk_window_get_size(html->html_area, &hwidth, &hheight); gdk_gc_set_foreground(gc, hb->back); /* we use a 2-pixel window border */ if (hb->x < 2) hb->x = 2; - gdk_draw_rectangle(html->html_area, gc, TRUE /* filled */, - hb->x, hb->y - html->yoffset - max_ascent - max_descent - 2, - hwidth - shift - hb->x + 1, max_ascent + max_descent + 8); + hb->x, hb->y - html->yoffset - hei - 6, + hwidth - shift - hb->x + 1, hei + hei + 2); for (tmpcnt = 1; tmpcnt < hb->newline; tmpcnt++) { - int eoff = max_ascent + max_descent + 2; + int eoff = hei + hei + 2; eoff *= tmpcnt; gdk_draw_rectangle(html->html_area, gc, TRUE, - 2, hb->y - html->yoffset - max_ascent - max_descent - 2 + eoff, - hwidth, max_ascent + max_descent + 2); + 2, hb->y - html->yoffset - hei - 6 + eoff, + hwidth, hei + hei + 2); } } @@ -2095,7 +2074,6 @@ gdk_draw_string(html->html_area, hb->font, gc, shift + hb->x, hb->y - html->yoffset, hb->text); - if (hb->uline) gdk_draw_line(html->html_area, gc, shift + hb->x, hb->y - html->yoffset, @@ -2114,24 +2092,7 @@ { if (hb->back != NULL) { int hwidth, hheight, hei, tmpcnt; - - if (!start_of_line) - start_of_line = hb; - else - { - hbits = g_list_find(html->html_bits, hb); - if (hbits && hbits->prev) - { - hbit = hbits->prev->data; - if (hbit && hbit->newline) - start_of_line = hb; - } - else - start_of_line = hb; - } - - hei = get_line_max_height(html, start_of_line); - + 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, @@ -2167,24 +2128,7 @@ clear_area(html, &area); if (hb->back != NULL) { int hwidth, hheight, hei, tmpcnt; - - if (!start_of_line) - start_of_line = hb; - else - { - hbits = g_list_find(html->html_bits, hb); - if (hbits && hbits->prev) - { - hbit = hbits->prev->data; - if (hbit && hbit->newline) - start_of_line = hb; - } - else - start_of_line = hb; - } - - hei = get_line_max_height(html, start_of_line); - + hei = get_line_height(html, hb); gdk_window_get_size(html->html_area, &hwidth, &hheight); gdk_gc_set_foreground(gc, hb->back); for (tmpcnt = 0; tmpcnt < hb->newline; tmpcnt++) { @@ -2913,7 +2857,7 @@ GdkGC *gc; int nl = 0, nl2 = 0; - int maxwidth, ascent, descent; + int maxwidth; gint lb; GList *hbits; size_t num = 0; @@ -3031,8 +2975,7 @@ if (!count) { /* FIXME : sometimes we need to add newline, sometimes we don't */ hbits = g_list_last(html->html_bits); - if (!hbits) - return; /* does this ever happen? */ + if (!hbits) return; /* does this ever happen? */ hb = (GtkHtmlBit *)hbits->data; hb->newline++; } @@ -3062,9 +3005,9 @@ } - gdk_text_extents(cfont, "yG", strlen("yG"), NULL, NULL, NULL, &ascent, &descent); - height = ascent + descent + 2; - + height = cfont->ascent + cfont->descent + 2; + + if ((int) (html->vadj->upper - html->current_y) < (int) (height * 2)) { int val; @@ -3076,7 +3019,7 @@ if (html->current_x == 0) { - html->current_y += height + 6; + html->current_y += height + 3; gdk_text_extents(cfont, text, 1, &lb, NULL, NULL, NULL, NULL); html->current_x += (2 - lb); } @@ -3488,7 +3431,9 @@ { d += strlen("COLOR="); if (*d == '\"') + { d++; + } if (*d == '#') d++; if (d[strlen(d) - 1] == '\"') @@ -3499,12 +3444,17 @@ current->color = get_color(colorv, map); current->owncolor = 1; } + else + { + } } if (!strncasecmp(d, "FACE=", strlen("FACE="))) { d += strlen("FACE="); if (*d == '\"') + { d++; + } if (d[strlen(d) - 1] == '\"') d[strlen(d) - 1] = 0; strcpy(current->font, d); @@ -3524,6 +3474,9 @@ current->bgcol = get_color(colorv, map); current->ownbg = 1; } + else + { + } } else if (!strncasecmp(d, "SIZE=", strlen("SIZE="))) { @@ -3533,7 +3486,12 @@ if (*d == '+') d++; if (sscanf(d, "%d", &colorv)) + { current->size = colorv; + } + else + { + } } else if (strncasecmp(d, "PTSIZE=", strlen("PTSIZE="))) { @@ -3542,6 +3500,7 @@ } else if (!strncasecmp(tag, "BODY", strlen("BODY"))) { + char *d; current = push_state(current); html_strtok(tag, ' '); @@ -4432,7 +4391,7 @@ } } -static int get_line_max_height(GtkHtml *html, GtkHtmlBit *start) +static int get_line_height(GtkHtml *html, GtkHtmlBit *start) { int height, max_height = 0; GList *hbits = html->html_bits; @@ -4442,11 +4401,10 @@ while (hbits) { - hbit = (GtkHtmlBit *)hbits->data; + hbit = hbits->data; if (hbit->font) height = gdk_text_height(hbit->font, "C", 1); - else if(hbit->type == HTML_BIT_PIXMAP) - height = 19; + if (max_height < height) max_height = height; if (hbit->newline) @@ -4454,47 +4412,8 @@ hbits = hbits->next; } - if (!max_height) + if (max_height == 0) max_height = gdk_text_height(hbit->font, "C", 1); - + return max_height; } - -static void get_line_max_extents(GtkHtml *html, GtkHtmlBit *start, int *max_acsent, int *max_descent) -{ - int acsent, descent; - GList *hbits = html->html_bits; - GtkHtmlBit *hbit = start; /* default this in case hbits is NULL */ - - *max_acsent = 0; - *max_descent = 0; - - hbits = g_list_find(hbits, start); - - while (hbits) - { - hbit = (GtkHtmlBit *)hbits->data; - if (hbit->font) - gdk_text_extents(hbit->font, "yG", strlen("yG"), NULL, NULL, NULL, &acsent, &descent); - else if (hbit->type == HTML_BIT_PIXMAP) - { - acsent =9; - descent = 8; - } - - if (*max_acsent < acsent) - *max_acsent = acsent; - if (*max_descent < descent) - *max_descent =descent; - if (hbit->newline) - break; - hbits = hbits->next; - } - - if (!*max_acsent) - gdk_text_extents(hbit->font, "yG", strlen("yG"), NULL, NULL, NULL, max_acsent, NULL); - if (!*max_descent) - gdk_text_extents(hbit->font, "yG", strlen("yG"), NULL, NULL, NULL, NULL, max_descent); - - return; -} \ No newline at end of file