diff -rwbBpu dillo-0.2.4/src/dw_hruler.c dillo-0.2.4.hruler/src/dw_hruler.c --- dillo-0.2.4/src/dw_hruler.c Tue Jul 11 12:17:08 2000 +++ dillo-0.2.4.hruler/src/dw_hruler.c Sat Aug 26 14:56:19 2000 @@ -15,7 +15,7 @@ /* - * todo: implement this function so the ruler can resize dinamically. + * todo: implement this function so the ruler can resize dynamically. */ static void Dw_hruler_size_nego_y(Dw *dw, DwRect *allocation) { @@ -38,7 +38,17 @@ static void Dw_hruler_size_nego_y(Dw *dw dw->allocation = *allocation; container = a_Dw_find_container(dw); if (container != NULL) { - new_width = container->visible.x1 - container->visible.x0 - 20; + if(dw_hruler->flags & DW_HRULER_FLAG_WIDTH_IN_PERCENT) + { + new_width = container->visible.x1 - container->visible.x0 - 10; + if(dw_hruler->width<=100) + new_width /= 100/dw_hruler->width; + } + else + { + new_width = dw_hruler->width; + } + // - 2 * container->border_width; dw_hruler->dw.req_width_min = dw_hruler->dw.req_width_max = new_width; @@ -71,17 +81,68 @@ static void Dw_hruler_paint(Dw *dw, DwRe container = a_Dw_find_container (dw); if (container != NULL) { widget = container->widget; + +#ifdef VERBOSE + g_print("Dw_hruler_paint: Size=%d Flags=%X Width=%d (%d) L/R=%d\n", + dw_hruler->dw.req_height, + dw_hruler->flags, + dw_hruler->dw.req_width_min, + dw_hruler->width, + dw_hruler->flags&(DW_HRULER_FLAG_ALIGN_LEFT|DW_HRULER_FLAG_ALIGN_RIGHT)); +#endif + a_Dw_paint_to_screen (widget, container, rect, paint); - x = dw->allocation.x0 + container->x_offset; + if(dw_hruler->flags & DW_HRULER_FLAG_ALIGN_LEFT) + { + x = 0; + } + else if(dw_hruler->flags & DW_HRULER_FLAG_ALIGN_RIGHT) + { + x = container->visible.x1 - container->visible.x0 - 10 - dw_hruler->dw.req_width_min; + } + else /* align=center */ + { + x = (container->visible.x1 + container->visible.x0 - dw_hruler->dw.req_width_min)/2 - 5; + } + x += dw->allocation.x0 + container->x_offset; y = dw->allocation.y0 + container->y_offset; + + if(dw_hruler->flags & DW_HRULER_FLAG_NOSHADE) + { + gdk_draw_rectangle (widget->window, + widget->style->dark_gc[widget->state], 1, + x, y, + dw_hruler->dw.req_width_min, dw_hruler->dw.req_height); + } + else + { + gdk_draw_line (widget->window, + widget->style->dark_gc[widget->state], + x, y, + x + dw_hruler->dw.req_width_min - 1, y); + if(dw_hruler->dw.req_width_min>2) + { + gdk_draw_rectangle (widget->window, + widget->style->bg_gc[widget->state], 1, + x+1, y+1, + dw_hruler->dw.req_width_min, dw_hruler->dw.req_height - 1); + } + if(dw_hruler->dw.req_width_min>1) + { gdk_draw_line (widget->window, widget->style->dark_gc[widget->state], x, y, - x + dw_hruler->dw.req_width_min, y); + x, y + dw_hruler->dw.req_height - 1); gdk_draw_line (widget->window, widget->style->light_gc[widget->state], - x, y + 1, - x + dw_hruler->dw.req_width_min, y + 1); + x + dw_hruler->dw.req_width_min - 1, y, + x + dw_hruler->dw.req_width_min - 1, y + dw_hruler->dw.req_height - 1); + } + gdk_draw_line (widget->window, + widget->style->light_gc[widget->state], + x, y + dw_hruler->dw.req_height - 1, + x + dw_hruler->dw.req_width_min - 1, y + dw_hruler->dw.req_height - 1); + } a_Dw_paint_finish_screen (paint); } } @@ -107,18 +168,20 @@ static const DwClass Dw_hruler_class = { /* * ? */ -Dw *a_Dw_hruler_new(int width) +Dw *a_Dw_hruler_new(int width, int size, int flags) { DwHruler *dw_hruler; DwRect null_rect = { 0, 0, 0, 0 }; dw_hruler = g_new(DwHruler, 1); + dw_hruler->flags = flags; + dw_hruler->width = width; dw_hruler->dw.klass = &Dw_hruler_class; dw_hruler->dw.allocation = null_rect; - dw_hruler->dw.req_width_min = width; - dw_hruler->dw.req_width_max = width; + dw_hruler->dw.req_width_min = 0; + dw_hruler->dw.req_width_max = 0; - dw_hruler->dw.req_height = 2; + dw_hruler->dw.req_height = size; dw_hruler->dw.req_ascent = 0; dw_hruler->dw.flags = 0; diff -rwbBpu dillo-0.2.4/src/dw_hruler.h dillo-0.2.4.hruler/src/dw_hruler.h --- dillo-0.2.4/src/dw_hruler.h Tue Jul 11 11:33:18 2000 +++ dillo-0.2.4.hruler/src/dw_hruler.h Sat Aug 26 12:32:57 2000 @@ -5,13 +5,23 @@ extern "C" { #endif /* __cplusplus */ +#define DW_HRULER_FLAG_NOSHADE 0x01 +#define DW_HRULER_FLAG_WIDTH_IN_PERCENT 0x02 +/* to align=center, none set */ +#define DW_HRULER_FLAG_ALIGN_LEFT 0x04 +#define DW_HRULER_FLAG_ALIGN_RIGHT 0x08 + + typedef struct _DwHruler DwHruler; struct _DwHruler { Dw dw; + + guint flags; + guint width; }; -Dw *a_Dw_hruler_new(int width); +Dw *a_Dw_hruler_new(int width, int size, int flags); #ifdef __cplusplus } diff -rwbBpu dillo-0.2.4/src/html.c dillo-0.2.4.hruler/src/html.c --- dillo-0.2.4/src/html.c Mon Aug 21 06:29:23 2000 +++ dillo-0.2.4.hruler/src/html.c Sat Aug 26 14:55:44 2000 @@ -977,10 +977,48 @@ static void Html_tag_open_li (DilloHtml static void Html_tag_open_hr(DilloHtml *html, char *tag, gint tagsize) { gint width; + gint size = 2; + gint flags = 0; + char tmp[80]; Dw *dw; - width = ((DwPage *) html->dw)->width; - dw = a_Dw_hruler_new(width); + if (Html_get_attr(tag, tagsize, "align", tmp, sizeof(tmp))){ + if(strcmp(tmp,"left")==0) + flags |= DW_HRULER_FLAG_ALIGN_LEFT; + else if(strcmp(tmp,"right")==0) + flags |= DW_HRULER_FLAG_ALIGN_RIGHT; + } + if (Html_get_attr(tag, tagsize, "size", tmp, sizeof(tmp))) + size = atoi(tmp); + if(Html_get_attr(tag, tagsize, "width", tmp, sizeof(tmp))){ + width = atoi(tmp); + if(tmp[strlen(tmp)-1]=='%') + flags |= DW_HRULER_FLAG_WIDTH_IN_PERCENT; + if(width>100) + width = 100; + } + else + { + flags |= DW_HRULER_FLAG_WIDTH_IN_PERCENT; + width = 100; + } + if (Html_get_attr(tag, tagsize, "noshade", tmp, sizeof(tmp))){ + flags |= DW_HRULER_FLAG_NOSHADE; + if(size<1) + size = 1; + if(width<1) + width = 1; + } + else + { + if(size<2) + size = 2; + if(width<2) + width = 2; + } + + dw = a_Dw_hruler_new(width,size,flags); + a_Dw_page_linebreak((DwPage *) html->dw); a_Dw_page_add_widget((DwPage *) html->dw, dw, html->stack[html->stack_top].attr); a_Dw_page_linebreak((DwPage *) html->dw);