X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=ioncore%2Finfowin.c;h=d23823ea4981384f10096b0e370ebadbda0d16a9;hb=ae4260bb64817c11f9a7140324cd3e3ba113e297;hp=95622b47095a3cad191e1af6dae30c1756638b3f;hpb=8366314611bf30a0f31d25bf5f5023186fa87692;p=ion3.git diff --git a/ioncore/infowin.c b/ioncore/infowin.c index 95622b4..d23823e 100644 --- a/ioncore/infowin.c +++ b/ioncore/infowin.c @@ -1,12 +1,9 @@ /* * ion/ioncore/infowin.h * - * 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 @@ -19,6 +16,7 @@ #include "resize.h" #include "gr.h" #include "event.h" +#include "strings.h" /*{{{ Init/deinit */ @@ -45,7 +43,8 @@ bool infowin_init(WInfoWin *p, WWindow *parent, const WFitParams *fp, goto fail2; p->brush=NULL; - p->attr=NULL; + + gr_stylespec_init(&p->attr); infowin_updategr(p); @@ -62,7 +61,8 @@ bool infowin_init(WInfoWin *p, WWindow *parent, const WFitParams *fp, return TRUE; -fail3: +fail3: + gr_stylespec_unalloc(&p->attr); free(p->style); fail2: free(p->buffer); @@ -86,11 +86,6 @@ void infowin_deinit(WInfoWin *p) p->buffer=NULL; } - if(p->attr!=NULL){ - free(p->attr); - p->attr=NULL; - } - if(p->style!=NULL){ free(p->style); p->style=NULL; @@ -101,6 +96,8 @@ void infowin_deinit(WInfoWin *p) p->brush=NULL; } + gr_stylespec_unalloc(&p->attr); + window_deinit(&(p->wwin)); } @@ -124,7 +121,8 @@ void infowin_draw(WInfoWin *p, bool complete) g.h=REGION_GEOM(p).h; grbrush_begin(p->brush, &g, GRBRUSH_NO_CLEAR_OK); - grbrush_draw_textbox(p->brush, &g, p->buffer, p->attr, TRUE); + grbrush_init_attr(p->brush, &p->attr); + grbrush_draw_textbox(p->brush, &g, p->buffer, TRUE); grbrush_end(p->brush); } @@ -157,25 +155,9 @@ void infowin_updategr(WInfoWin *p) /*{{{ Content-setting */ -bool infowin_set_attr2(WInfoWin *p, const char *attr1, const char *attr2) +GrStyleSpec *infowin_stylespec(WInfoWin *p) { - char *p2=NULL; - - if(attr1!=NULL){ - if(attr2==NULL) - p2=scopy(attr1); - else - libtu_asprintf(&p2, "%s-%s", attr1, attr2); - if(p2==NULL) - return FALSE; - } - - if(p->attr) - free(p->attr); - - p->attr=p2; - - return TRUE; + return &p->attr; } @@ -214,9 +196,21 @@ static void infowin_resize(WInfoWin *p) * Set contents of the info window. */ EXTL_EXPORT_MEMBER -void infowin_set_text(WInfoWin *p, const char *str) +void infowin_set_text(WInfoWin *p, const char *str, int maxw) { - infowin_do_set_text(p, str); + bool set=FALSE; + + if(maxw>0 && p->brush!=NULL){ + char *tmp=grbrush_make_label(p->brush, str, maxw); + if(tmp!=NULL){ + infowin_do_set_text(p, tmp); + free(tmp); + set=TRUE; + } + } + + if(!set) + infowin_do_set_text(p, str); infowin_resize(p);