comparison src/gtkhtml.c @ 871:75b05911234a

[gaim-migrate @ 881] backing out fflew's fix. it isn't correct. the only thing that should need to be drawn is what's prior to it. the way it is with fflew's fix, text gets overwritten with the background color. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 10 Sep 2000 21:38:43 +0000
parents 6cca24db6137
children b5b3aa06111d
comparison
equal deleted inserted replaced
870:9b8b83592bb6 871:75b05911234a
166 static void adjust_adj(GtkHtml * html, GtkAdjustment * adj); 166 static void adjust_adj(GtkHtml * html, GtkAdjustment * adj);
167 static void resize_html(GtkHtml * html); 167 static void resize_html(GtkHtml * html);
168 static gint html_bit_is_onscreen(GtkHtml * html, GtkHtmlBit * hb); 168 static gint html_bit_is_onscreen(GtkHtml * html, GtkHtmlBit * hb);
169 static void draw_cursor(GtkHtml * html); 169 static void draw_cursor(GtkHtml * html);
170 static void undraw_cursor(GtkHtml * html); 170 static void undraw_cursor(GtkHtml * html);
171
172 static int get_line_height(GtkHtml *, GtkHtmlBit *);
173 171
174 static GtkWidgetClass *parent_class = NULL; 172 static GtkWidgetClass *parent_class = NULL;
175 173
176 GtkType gtk_html_get_type(void) 174 GtkType gtk_html_get_type(void)
177 { 175 {
1822 } 1820 }
1823 1821
1824 return TRUE; 1822 return TRUE;
1825 } 1823 }
1826 1824
1825
1827 static void gtk_html_draw_bit(GtkHtml * html, GtkHtmlBit * hb, int redraw) 1826 static void gtk_html_draw_bit(GtkHtml * html, GtkHtmlBit * hb, int redraw)
1828 { 1827 {
1829 int mypos, 1828 int mypos,
1830 epos, 1829 epos,
1831 spos, 1830 spos;
1832 max_height;
1833 GdkGC *gc = html->gc; 1831 GdkGC *gc = html->gc;
1834 int shift; 1832 int shift;
1835 GtkStateType selected_state; 1833 GtkStateType selected_state;
1836 GtkWidget *widget = GTK_WIDGET(html); 1834 GtkWidget *widget = GTK_WIDGET(html);
1837 GdkRectangle area; 1835 GdkRectangle area;
1838 GList *hbits;
1839 GtkHtmlBit *hbit;
1840 1836
1841 if (html->frozen > 0) 1837 if (html->frozen > 0)
1842 return; 1838 return;
1843 1839
1844 hbits = html->html_bits;
1845
1846 hbits = g_list_find(hbits, hb);
1847
1848 if (hb->type == HTML_BIT_TEXT) 1840 if (hb->type == HTML_BIT_TEXT)
1849 { 1841 {
1850 1842
1851 if (!(hb->text)) 1843 if (!(hb->text))
1852 return; 1844 return;
2054 } 2046 }
2055 2047
2056 /*end my stuff*/ 2048 /*end my stuff*/
2057 2049
2058 2050
2059 2051 if (hb->text && hb->back != NULL && selected_state != GTK_STATE_SELECTED) {
2060 2052 int hwidth, hheight;
2061 if (hb->text && hb->back != NULL && selected_state != GTK_STATE_SELECTED) 2053 int hei = gdk_text_height(hb->font, "C", 1);
2062 {
2063 int hwidth, hheight, hei;
2064 if (hbits->prev)
2065 {
2066 hbit = hbits->prev->data;
2067 if (hbit->newline)
2068 hei = get_line_height(html, hb);
2069 }
2070 else
2071 hei = get_line_height(html, hb);
2072 gdk_window_get_size(html->html_area, &hwidth, &hheight); 2054 gdk_window_get_size(html->html_area, &hwidth, &hheight);
2073 gdk_gc_set_foreground(gc, hb->back); 2055 gdk_gc_set_foreground(gc, hb->back);
2074 gdk_draw_rectangle(html->html_area, gc, TRUE /* filled */, 2056 gdk_draw_rectangle(html->html_area, gc, TRUE /* filled */,
2075 hb->x, hb->y - html->yoffset - hei - 6, 2057 hb->x, hb->y - html->yoffset - hei - 6,
2076 hwidth - shift - hb->x + 1, hei + hei + 2); 2058 hwidth - shift - hb->x + 1, hei + hei + 2);
2105 2087
2106 } 2088 }
2107 } 2089 }
2108 else if (hb->type == HTML_BIT_SEP) 2090 else if (hb->type == HTML_BIT_SEP)
2109 { 2091 {
2092
2110 gdk_draw_line(html->html_area, gc, hb->x + 2, 2093 gdk_draw_line(html->html_area, gc, hb->x + 2,
2111 hb->y - html->yoffset - (hb->height / 2 - 1), 2094 hb->y - html->yoffset - (hb->height / 2 - 1),
2112 hb->x + hb->width, 2095 hb->x + hb->width,
2113 hb->y - html->yoffset - (hb->height / 2 - 1)); 2096 hb->y - html->yoffset - (hb->height / 2 - 1));
2114 2097
4344 4327
4345 expose_html(html, &area, TRUE); 4328 expose_html(html, &area, TRUE);
4346 } 4329 }
4347 } 4330 }
4348 } 4331 }
4349
4350 static int get_line_height(GtkHtml *html, GtkHtmlBit *start)
4351 {
4352 int height, max_height = 0;
4353 GList *hbits = html->html_bits;
4354 GtkHtmlBit *hbit;
4355
4356 hbits = g_list_find(hbits, start);
4357
4358 while (TRUE)
4359 {
4360 hbit = hbits->data;
4361 if (hbit->font)
4362 height = gdk_text_height(hbit->font, "C", 1);
4363
4364 if (max_height < height)
4365 max_height = height;
4366 if (hbit->newline)
4367 break;
4368 hbits = hbits->next;
4369 }
4370
4371 return max_height;
4372 }