Ejemplo n.º 1
0
struct font_name *_GDraw_HashFontFamily(FState *fonts,unichar_t *name, int prop) {
    struct font_name *fn;
    int ch;
    int b,i;

    ch = *name;
    if ( isupper(ch)) ch = tolower(ch);
    if ( ch<'a' ) ch = 'q'; else if ( ch>'z' ) ch='z';
    ch -= 'a';

    fn = fonts->font_names[ch];
    while ( fn!=NULL ) {
	if ( u_strmatch(name,fn->family_name)==0 )
    break;
	fn = fn->next;
    }
    if ( fn==NULL ) {
	fn = gcalloc(1,sizeof(struct font_name));
	fn->family_name = u_copy(name);
	fn->ft = _GDraw_ClassifyFontName(fn->family_name,&b,&i);
	if ( !prop && fn->ft==ft_unknown )
	    fn->ft = ft_mono;
	fn->next = fonts->font_names[ch];
	fonts->font_names[ch] = fn;
    }
return( fn );
}
Ejemplo n.º 2
0
static void GRowColScrollToText(GGadget *g,unichar_t *text,int sel) {
    GRowCol *grc = (GRowCol *) g;
    int pos;

    pos = GRowColFindPosition(grc,text);
    if ( sel && pos<grc->ltot ) {
	GRowColClearSel(grc);
	if ( grc->exactly_one || u_strmatch(text,grc->ti[pos]->text)==0 )
	    grc->ti[pos]->selected = true;
    }
    grc->loff = GRowColAdjustPos(g,pos);
    _ggadget_redraw(g);
}
Ejemplo n.º 3
0
static void GListScrollToText(GGadget *g,const unichar_t *text,int32 sel) {
    GList *gl = (GList *) g;
    int pos;

    pos = GListFindPosition(gl,(unichar_t *) text);
    if ( sel && pos<gl->ltot ) {
	GListClearSel(gl);
	if ( gl->exactly_one || u_strmatch(text,gl->ti[pos]->text)==0 )
	    gl->ti[pos]->selected = true;
    }
    gl->loff = GListAdjustPos(g,pos);
    if ( gl->vsb!=NULL )
	GScrollBarSetPos(&gl->vsb->g,gl->loff);
    _ggadget_redraw(g);
}
Ejemplo n.º 4
0
static int GRowColFindPosition(GRowCol *grc,unichar_t *text) {
    GTextInfo temp, *ptemp=&temp;
    int i, order;

    if ( grc->orderer!=NULL ) {
	memset(&temp,'\0',sizeof(temp));
	temp.text = text;

	/* I don't think I need to write a binary search here... */
	for ( i=0; i<grc->ltot; ++i ) {
	    order = (grc->orderer)(&ptemp,&grc->ti[i]);
	    if (( order<= 0 && !grc->backwards ) || ( order>=0 && grc->backwards ))
return( i );
	}
return( 0 );
    } else {
	for ( i=0; i<grc->ltot; ++i ) {
	    if (u_strmatch(text,grc->ti[i]->text)==0 )
return( i );
	}
    }
return( 0 );
}