Example #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);
}
Example #2
0
void frame_recalc_bar(WFrame *frame, bool complete)
{
    int textw, i;
    WLListIterTmp tmp;
    WRegion *sub;
    char *title;
    bool set_shape;

    if(frame->bar_brush==NULL || frame->titles==NULL)
        return;

    set_shape=frame->tabs_params.alg(frame,complete);

    if(set_shape) {
        if(frame->barmode==FRAME_BAR_SHAPED)
            frame_set_shape(frame);
        else
            frame_clear_shape(frame);
    }

    i=0;

    if(FRAME_MCOUNT(frame)==0){
        free_title(frame, i);
        textw=frame->titles[i].iw;
        if(textw>0){
            title=grbrush_make_label(frame->bar_brush, TR("<empty frame>"),
                                     textw);
            frame->titles[i].text=title;
        }
        return;
    }

    FRAME_MX_FOR_ALL(sub, frame, tmp){
        free_title(frame, i);
        textw=frame->titles[i].iw;
        if(textw>0){
            title=region_make_label(sub, textw, frame->bar_brush);
            frame->titles[i].text=title;
        }
        i++;
    }
Example #3
0
static void menu_calc_size(WMenu *menu, bool maxexact, 
                           int maxw, int maxh, 
                           int *w_ret, int *h_ret)
{
    GrBorderWidths bdw, e_bdw;
    char *str;
    int i;
    int nath, bdh, maxew=menu->max_entry_w;
    
    grbrush_get_border_widths(menu->brush, &bdw);
    grbrush_get_border_widths(menu->entry_brush, &e_bdw);
    
    if(maxexact || maxew>maxw-(int)bdw.left-(int)bdw.right){
        maxew=maxw-bdw.left-bdw.right;
        *w_ret=maxw;
    }else{
        *w_ret=maxew+bdw.left+bdw.right;
    }
    
    bdh=bdw.top+bdw.bottom;
    
    if(menu->n_entries==0){
        *h_ret=(maxexact ? maxh : bdh);
        menu->first_entry=0;
        menu->vis_entries=0;
    }else{
        int vis=(maxh-bdh+e_bdw.spacing)/(e_bdw.spacing+menu->entry_h);
        if(vis>menu->n_entries){
            vis=menu->n_entries;
            menu->first_entry=0;
        }else if(menu->selected_entry>=0){
            if(menu->selected_entry<menu->first_entry)
                menu->first_entry=menu->selected_entry;
            else if(menu->selected_entry>=menu->first_entry+vis)
                menu->first_entry=menu->selected_entry-vis+1;
        }
        if(vis<=0)
            vis=1;
        menu->vis_entries=vis;
        if(maxexact)
            *h_ret=maxh;
        else
            *h_ret=vis*menu->entry_h+(vis-1)*e_bdw.spacing+bdh;
    }

    /* Calculate new shortened entry names */
    maxew-=e_bdw.left+e_bdw.right;
    
    for(i=0; i<menu->n_entries; i++){
        if(menu->entries[i].title){
            free(menu->entries[i].title);
            menu->entries[i].title=NULL;
        }
        if(maxew<=0)
            continue;
        
        if(extl_table_getis(menu->tab, i+1, "name", 's', &str)){
            menu->entries[i].title=grbrush_make_label(menu->entry_brush, 
                                                      str, maxew);
            free(str);
        }
    }
}