示例#1
0
/*EXTL_DOC
 * Set contents of the info window.
 */
EXTL_EXPORT_MEMBER
void infowin_set_text(WInfoWin *p, const char *str, int maxw)
{
    bool set=FALSE;
    
    if(str==NULL){
        INFOWIN_BUFFER(p)[0]='\0';
    }else{
        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);
    
    /* sometimes unnecessary */
    window_draw((WWindow*)p, TRUE);
}
示例#2
0
static void infowin_resize(WInfoWin *p)
{
    WRQGeomParams rq=RQGEOMPARAMS_INIT;
    const char *str=INFOWIN_BUFFER(p);
    GrBorderWidths bdw;
    GrFontExtents fnte;
    
    rq.flags=REGION_RQGEOM_WEAK_X|REGION_RQGEOM_WEAK_Y;
    
    rq.geom.x=REGION_GEOM(p).x;
    rq.geom.y=REGION_GEOM(p).y;
    
    grbrush_get_border_widths(p->brush, &bdw);
    grbrush_get_font_extents(p->brush, &fnte);
        
    rq.geom.w=bdw.left+bdw.right;
    rq.geom.w+=grbrush_get_text_width(p->brush, str, strlen(str));
    rq.geom.h=fnte.max_height+bdw.top+bdw.bottom;

    if(rectangle_compare(&rq.geom, &REGION_GEOM(p))!=RECTANGLE_SAME)
        region_rqgeom((WRegion*)p, &rq, NULL);
}
示例#3
0
文件: resize.c 项目: dkogan/notion
static void moveres_draw_infowin(WMoveresMode *mode)
{
    char *buf;

    if(mode->infowin==NULL)
        return;

    buf=INFOWIN_BUFFER(mode->infowin);

    if(buf==NULL)
        return;

    if(mode->mode==MOVERES_SIZE){
        int w, h;

        w=mode->geom.w;
        h=mode->geom.h;

        if(mode->hints.base_set){
            w=MAXOF(0, w-mode->hints.base_width);
            h=MAXOF(0, h-mode->hints.base_height);
        }

        if(mode->hints.inc_set){
            w/=MAXOF(1, mode->hints.width_inc);
            h/=MAXOF(1, mode->hints.height_inc);
        }

        snprintf(buf, INFOWIN_BUFFER_LEN, "%dx%d", w, h);
    }else{
        snprintf(buf, INFOWIN_BUFFER_LEN, "%+d %+d",
                 mode->geom.x, mode->geom.y);
    }

    window_draw((WWindow*)mode->infowin, TRUE);
}
示例#4
0
static void infowin_do_set_text(WInfoWin *p, const char *str)
{
    strncpy(INFOWIN_BUFFER(p), str, INFOWIN_BUFFER_LEN);
    INFOWIN_BUFFER(p)[INFOWIN_BUFFER_LEN-1]='\0';
}