X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=mod_query%2Flisting.c;h=598e656626a76355e75bfe28312e7c42df14c006;hb=1cd244db6df1337d594b9e2456c735cbc28aea6c;hp=9ceb41d6cbb2b3348f9dc5a54166a53d797292ad;hpb=8366314611bf30a0f31d25bf5f5023186fa87692;p=ion3.git diff --git a/mod_query/listing.c b/mod_query/listing.c index 9ceb41d..598e656 100644 --- a/mod_query/listing.c +++ b/mod_query/listing.c @@ -1,12 +1,9 @@ /* * ion/mod_query/listing.c * - * Copyright (c) Tuomo Valkonen 1999-2006. + * Copyright (c) Tuomo Valkonen 1999-2007. * - * Ion is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. + * See the included file LICENSE for details. */ #include @@ -141,12 +138,12 @@ static void string_calc_parts(GrBrush *brush, int maxw, char *str, static void draw_multirow(GrBrush *brush, int x, int y, int h, char *str, WListingItemInfo *iinf, - int maxw, int ciw, int wrapw, const char *style) + int maxw, int ciw, int wrapw) { int i, l; if(iinf==NULL){ - grbrush_draw_string(brush, x, y, str, strlen(str), TRUE, style); + grbrush_draw_string(brush, x, y, str, strlen(str), TRUE); return; } @@ -158,10 +155,10 @@ static void draw_multirow(GrBrush *brush, int x, int y, int h, l=iinf->part_lens[0]; } - grbrush_draw_string(brush, x, y, str, l, TRUE, style); + grbrush_draw_string(brush, x, y, str, l, TRUE); for(i=1; in_parts; i++){ - grbrush_draw_string(brush, x+maxw-wrapw, y, "\\", 1, TRUE, style); + grbrush_draw_string(brush, x+maxw-wrapw, y, "\\", 1, TRUE); y+=h; str+=l; @@ -171,7 +168,7 @@ static void draw_multirow(GrBrush *brush, int x, int y, int h, } l=iinf->part_lens[i]; - grbrush_draw_string(brush, x, y, str, l, TRUE, style); + grbrush_draw_string(brush, x, y, str, l, TRUE); } } @@ -348,8 +345,7 @@ void init_listing(WListing *l) static void do_draw_listing(GrBrush *brush, const WRectangle *geom, - WListing *l, const char *style, - const char *selstyle) + WListing *l, GrAttr selattr, int mode) { int wrapw=grbrush_get_text_width(brush, "\\", 1); int ciw=grbrush_get_text_width(brush, CONT_INDENT, CONT_INDENT_LEN); @@ -372,10 +368,20 @@ static void do_draw_listing(GrBrush *brush, const WRectangle *geom, if(i>=l->nstrs) return; - draw_multirow(brush, geom->x+x, y, l->itemh, l->strs[i], - (l->iteminfos!=NULL ? &(l->iteminfos[i]) : NULL), - geom->w-x, ciw, wrapw, - (i==l->selected_str ? selstyle : style)); + if(mode>=0 || + l->selected_str==i || + LISTING_DRAW_GET_SELECTED(mode)==i){ + + if(i==l->selected_str) + grbrush_set_attr(brush, selattr); + + draw_multirow(brush, geom->x+x, y, l->itemh, l->strs[i], + (l->iteminfos!=NULL ? &(l->iteminfos[i]) : NULL), + geom->w-x, ciw, wrapw); + + if(i==l->selected_str) + grbrush_unset_attr(brush, selattr); + } y+=l->itemh*ITEMROWS(l, i); r+=ITEMROWS(l, i); @@ -387,19 +393,27 @@ static void do_draw_listing(GrBrush *brush, const WRectangle *geom, } +static int prevsel=-1; + +static bool filteridx_sel(WListing *l, int i) +{ + return (i==prevsel || i==l->selected_str); +} + + void draw_listing(GrBrush *brush, const WRectangle *geom, - WListing *l, bool complete, const char *style, - const char *selstyle) + WListing *l, int mode, GrAttr selattr) { WRectangle geom2; GrBorderWidths bdw; - - grbrush_begin(brush, geom, GRBRUSH_AMEND|GRBRUSH_NEED_CLIP); - - if(complete) + + grbrush_begin(brush, geom, GRBRUSH_AMEND|GRBRUSH_KEEP_ATTR + |GRBRUSH_NEED_CLIP); + + if(mode==LISTING_DRAW_COMPLETE) grbrush_clear_area(brush, geom); - grbrush_draw_border(brush, geom, style); + grbrush_draw_border(brush, geom); grbrush_get_border_widths(brush, &bdw); @@ -408,7 +422,7 @@ void draw_listing(GrBrush *brush, const WRectangle *geom, geom2.w=geom->w-bdw.left-bdw.right; geom2.h=geom->h-bdw.top-bdw.bottom; - do_draw_listing(brush, &geom2, l, style, selstyle); + do_draw_listing(brush, &geom2, l, selattr, mode); grbrush_end(brush); } @@ -490,14 +504,16 @@ static int listing_first_visible_row(WListing *l) } -bool listing_select(WListing *l, int i) +int listing_select(WListing *l, int i) { int irow, frow, lrow; - bool complredraw=FALSE; + int redraw; + + redraw=LISTING_DRAW_SELECTED(l->selected_str); if(i<0){ l->selected_str=-1; - return FALSE; + return redraw; } assert(instrs); @@ -512,7 +528,7 @@ bool listing_select(WListing *l, int i) while(irowfirstitem), &(l->firstoff)); frow--; - complredraw=TRUE; + redraw=LISTING_DRAW_COMPLETE; } irow+=ITEMROWS(l, i)-1; @@ -521,9 +537,9 @@ bool listing_select(WListing *l, int i) while(irow>lrow){ one_row_down(l, &(l->firstitem), &(l->firstoff)); lrow++; - complredraw=TRUE; + redraw=LISTING_DRAW_COMPLETE; } - return complredraw; + return redraw; }