| 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 *); |
| 171 |
173 |
| 172 static GtkWidgetClass *parent_class = NULL; |
174 static GtkWidgetClass *parent_class = NULL; |
| 173 |
175 |
| 174 GtkType gtk_html_get_type(void) |
176 GtkType gtk_html_get_type(void) |
| 175 { |
177 { |
| 1835 GdkGC *gc = html->gc; |
1837 GdkGC *gc = html->gc; |
| 1836 int shift; |
1838 int shift; |
| 1837 GtkStateType selected_state; |
1839 GtkStateType selected_state; |
| 1838 GtkWidget *widget = GTK_WIDGET(html); |
1840 GtkWidget *widget = GTK_WIDGET(html); |
| 1839 GdkRectangle area; |
1841 GdkRectangle area; |
| 1840 |
1842 GList *hbits; |
| |
1843 GtkHtmlBit *hbit; |
| |
1844 |
| 1841 if (html->frozen > 0) |
1845 if (html->frozen > 0) |
| 1842 return; |
1846 return; |
| 1843 |
1847 |
| |
1848 hbits = g_list_find(html->html_bits, hb); |
| |
1849 |
| 1844 if (hb->type == HTML_BIT_TEXT) |
1850 if (hb->type == HTML_BIT_TEXT) |
| 1845 { |
1851 { |
| 1846 |
1852 |
| 1847 if (!(hb->text)) |
1853 if (!(hb->text)) |
| 1848 return; |
1854 return; |
| 1862 } |
1868 } |
| 1863 else |
1869 else |
| 1864 { |
1870 { |
| 1865 selected_state = GTK_STATE_SELECTED; |
1871 selected_state = GTK_STATE_SELECTED; |
| 1866 } |
1872 } |
| 1867 |
|
| 1868 |
1873 |
| 1869 gdk_text_extents(hb->font, hb->text, 1, &shift, NULL, NULL, NULL, NULL); |
1874 gdk_text_extents(hb->font, hb->text, 1, &shift, NULL, NULL, NULL, NULL); |
| 1870 |
1875 |
| 1871 if (selected_state == GTK_STATE_SELECTED) |
1876 if (selected_state == GTK_STATE_SELECTED) |
| 1872 { |
1877 { |
| 1926 hb->sel_e = echar; |
1931 hb->sel_e = echar; |
| 1927 hb->sel_s = schar; |
1932 hb->sel_s = schar; |
| 1928 |
1933 |
| 1929 startx += hb->x; |
1934 startx += hb->x; |
| 1930 |
1935 |
| 1931 |
|
| 1932 area.x = hb->x - html->xoffset; |
1936 area.x = hb->x - html->xoffset; |
| 1933 area.y = hb->y - hb->height + 3 - html->yoffset; |
1937 area.y = hb->y - hb->height + 3 - html->yoffset; |
| 1934 area.width = hb->width + 2; |
1938 area.width = hb->width + 2; |
| 1935 area.height = hb->height; |
1939 area.height = hb->height; |
| 1936 clear_area(html, &area); |
1940 clear_area(html, &area); |
| 1998 if (hb->fore != NULL) |
1999 if (hb->fore != NULL) |
| 1999 gdk_gc_set_foreground(gc, hb->fore); |
2000 gdk_gc_set_foreground(gc, hb->fore); |
| 2000 else |
2001 else |
| 2001 gdk_gc_set_foreground(gc, |
2002 gdk_gc_set_foreground(gc, |
| 2002 &widget->style->fg[selected_state]); |
2003 &widget->style->fg[selected_state]); |
| 2003 if (hb->back != NULL) |
|
| 2004 gdk_gc_set_background(gc, hb->back); |
|
| 2005 else |
|
| 2006 gdk_gc_set_background(gc, |
|
| 2007 &widget->style->bg[selected_state]); |
|
| 2008 |
|
| 2009 |
2004 |
| 2010 gdk_gc_set_font(gc, hb->font); |
2005 gdk_gc_set_font(gc, hb->font); |
| 2011 |
2006 |
| 2012 gdk_text_extents(hb->font, s, 1, &lbearing, &rbearing, &w, NULL, |
2007 gdk_text_extents(hb->font, s, 1, &lbearing, &rbearing, &w, NULL, |
| 2013 NULL); |
2008 NULL); |
| 2051 |
2046 |
| 2052 /*end my stuff*/ |
2047 /*end my stuff*/ |
| 2053 |
2048 |
| 2054 |
2049 |
| 2055 if (hb->text && hb->back != NULL && selected_state != GTK_STATE_SELECTED) { |
2050 if (hb->text && hb->back != NULL && selected_state != GTK_STATE_SELECTED) { |
| 2056 int hwidth, hheight; |
2051 int hwidth, hheight, hei; |
| 2057 int hei = gdk_text_height(hb->font, "C", 1); |
2052 hei = get_line_height(html, hb); |
| 2058 gdk_window_get_size(html->html_area, &hwidth, &hheight); |
2053 gdk_window_get_size(html->html_area, &hwidth, &hheight); |
| 2059 gdk_gc_set_foreground(gc, hb->back); |
2054 gdk_gc_set_foreground(gc, hb->back); |
| 2060 gdk_draw_rectangle(html->html_area, gc, TRUE /* filled */, |
2055 gdk_draw_rectangle(html->html_area, gc, TRUE /* filled */, |
| 2061 hb->x, hb->y - html->yoffset - hei - 6, |
2056 hb->x, hb->y - html->yoffset - hei - 6, |
| 2062 hwidth - shift - hb->x + 1, hei + hei + 2); |
2057 hwidth - shift - hb->x + 1, hei + hei + 2); |
| 2064 |
2059 |
| 2065 if (hb->fore != NULL) |
2060 if (hb->fore != NULL) |
| 2066 gdk_gc_set_foreground(gc, hb->fore); |
2061 gdk_gc_set_foreground(gc, hb->fore); |
| 2067 else |
2062 else |
| 2068 gdk_gc_set_foreground(gc, &widget->style->fg[selected_state]); |
2063 gdk_gc_set_foreground(gc, &widget->style->fg[selected_state]); |
| 2069 if (hb->back != NULL) |
|
| 2070 gdk_gc_set_background(gc, hb->back); |
|
| 2071 else |
|
| 2072 gdk_gc_set_background(gc, &widget->style->bg[selected_state]); |
|
| 2073 |
|
| 2074 |
2064 |
| 2075 gdk_gc_set_font(gc, hb->font); |
2065 gdk_gc_set_font(gc, hb->font); |
| 2076 |
|
| 2077 |
2066 |
| 2078 gdk_draw_string(html->html_area, hb->font, gc, shift + hb->x, |
2067 gdk_draw_string(html->html_area, hb->font, gc, shift + hb->x, |
| 2079 hb->y - html->yoffset, hb->text); |
2068 hb->y - html->yoffset, hb->text); |
| 2080 if (hb->uline) |
2069 if (hb->uline) |
| 2081 gdk_draw_line(html->html_area, gc, shift + hb->x, |
2070 gdk_draw_line(html->html_area, gc, shift + hb->x, |
| 2279 |
2268 |
| 2280 gdk_window_get_size(html->html_area, &width, &height); |
2269 gdk_window_get_size(html->html_area, &width, &height); |
| 2281 |
2270 |
| 2282 realy = area->y + html->yoffset; |
2271 realy = area->y + html->yoffset; |
| 2283 |
2272 |
| |
2273 /* this is needed since background colors draw across the entire window width |
| |
2274 if anyone knows of a cleaner way to work bg colors, please submit code =) */ |
| |
2275 area->x = 0; |
| |
2276 area->width = width; |
| |
2277 |
| 2284 clear_area(html, area); |
2278 clear_area(html, area); |
| 2285 |
2279 |
| 2286 while (hbits) |
2280 while (hbits) |
| 2287 { |
2281 { |
| 2288 |
2282 |
| 4331 |
4325 |
| 4332 expose_html(html, &area, TRUE); |
4326 expose_html(html, &area, TRUE); |
| 4333 } |
4327 } |
| 4334 } |
4328 } |
| 4335 } |
4329 } |
| |
4330 |
| |
4331 static int get_line_height(GtkHtml *html, GtkHtmlBit *start) |
| |
4332 { |
| |
4333 int height, max_height = 0; |
| |
4334 GList *hbits = html->html_bits; |
| |
4335 GtkHtmlBit *hbit; |
| |
4336 |
| |
4337 hbits = g_list_find(hbits, start); |
| |
4338 |
| |
4339 while (TRUE) |
| |
4340 { |
| |
4341 hbit = hbits->data; |
| |
4342 if (hbit->font) |
| |
4343 height = gdk_text_height(hbit->font, "C", 1); |
| |
4344 |
| |
4345 if (max_height < height) |
| |
4346 max_height = height; |
| |
4347 if (hbit->newline) |
| |
4348 break; |
| |
4349 hbits = hbits->next; |
| |
4350 } |
| |
4351 |
| |
4352 return max_height; |
| |
4353 } |