Пример #1
0
static void GProgressDraw(GProgress *p,GWindow pixmap,GRect *rect) {
    GRect r, old;
    int width, amount;

    GDrawPushClip(pixmap,rect,&old);
    GDrawSetFont(pixmap,p->font);
    if ( p->line1!=NULL )
	GDrawDrawText(pixmap, (p->width-p->l1width)/2, p->l1y, p->line1, -1,
		progress_foreground );
    if ( p->line2!=NULL )
	GDrawDrawText(pixmap, (p->width-p->l2width)/2, p->l2y, p->line2, -1,
		progress_foreground );

    r.x = GDrawPointsToPixels(pixmap,10);
    r.y = p->boxy;
    r.height = r.x;
    width = p->width-2*r.x;
    
    if ( p->tot==0 )
	amount = 0;
    else
	amount = width * (p->stage*p->tot + p->sofar)/(p->stages*p->tot);
    if ( amount>0 ) {
	r.width = amount;
	GDrawFillRect(pixmap,&r,progress_fillcol);
    } else if ( p->tot==0 ) {
	r.width = width;
	GDrawSetStippled(pixmap,1,0,0);
	GDrawFillRect(pixmap,&r,progress_fillcol);
	GDrawSetStippled(pixmap,0,0,0);
    }
    r.width = width;
    GDrawDrawRect(pixmap,&r,progress_foreground);
    GDrawPopClip(pixmap,&old);
}
Пример #2
0
static void QGDrawWindow(GWindow pixmap, QGData *qg, GEvent *e) {
    int l, y, depth;
    char buffer[200];
    GRect old, r;
    struct navigate where;
    struct qgnode *parent;

    GDrawPushClip(pixmap,&e->u.expose.rect,&old);
    r.width = r.height = qg->as;
    y = qg->as;
    memset(&where,0,sizeof(where));
    QG_FindLine(&qg->list,qg->loff_top,&where);

    for ( l=0; l<qg->vlcnt && where.parent!=NULL; ++l ) {
	for ( parent=where.parent, depth= -2; parent!=NULL; parent=parent->parent, ++depth );
	if ( where.offset==-1 ) {
	    r.x = 2+depth*qg->fh;   r.y = y-qg->as+1;
	    GDrawDrawRect(pixmap,&r,0x000000);
	    GDrawDrawLine(pixmap,r.x+2,r.y+qg->as/2,r.x+qg->as-2,r.y+qg->as/2,
		    0x000000);
	    if ( !where.parent->open )
		GDrawDrawLine(pixmap,r.x+qg->as/2,r.y+2,r.x+qg->as/2,r.y+qg->as-2,
			0x000000);
	    GDrawDrawText8(pixmap,r.x+qg->fh,y,where.parent->name,-1, 0x000000);
	} else {
	    QuestionableGrid *q = &where.parent->first[where.offset];
	    sprintf( buffer, _("\"%.40s\" size=%d point=%d (%d,%d) distance=%g"),
		    q->sc->name, q->size, q->nearestpt, q->x, q->y, q->distance );
	    GDrawDrawText8(pixmap,2+(depth+1)*qg->fh,y,buffer,-1, 0x000000);
	}
	y += qg->fh;
	QG_NextLine(&where);
    }
    GDrawPopClip(pixmap,&old);
}
Пример #3
0
static void BdfP_Expose(struct bdf_dlg *bd, GWindow pixmap) {
    struct bdf_dlg_font *cur = bd->cur;
    BDFFont *bdf = cur->bdf;
    int i;
    int page = bd->vheight/(bd->fh+1);
    GRect clip, old, r;
    char buffer[40];
    extern GBox _ggadget_Default_Box;

    GDrawSetFont(pixmap,bd->font);
    clip.x = 4; clip.width = bd->value_x-4-2; clip.height = bd->fh;
    for ( i=0; i<page && i+cur->top_prop<bdf->prop_cnt; ++i ) {
	int sel = i+cur->top_prop==cur->sel_prop;
	clip.y = i*(bd->fh+1);
	if ( sel ) {
	    r.x = 0; r.width = bd->width;
	    r.y = clip.y; r.height = clip.height;
	    GDrawFillRect(pixmap,&r,ACTIVE_BORDER);
	}
	GDrawPushClip(pixmap,&clip,&old);
	GDrawDrawBiText8(pixmap,4,i*(bd->fh+1)+bd->as,bdf->props[i+cur->top_prop].name,-1,NULL,MAIN_FOREGROUND);
	GDrawPopClip(pixmap,&old);
	switch ( bdf->props[i+cur->top_prop].type&~prt_property ) {
	  case prt_string: case prt_atom:
	    GDrawDrawBiText8(pixmap,bd->value_x+2,i*(bd->fh+1)+bd->as,bdf->props[i+cur->top_prop].u.str,-1,NULL,MAIN_FOREGROUND);
	  break;
	  case prt_int:
	    sprintf( buffer, "%d", bdf->props[i+cur->top_prop].u.val );
	    GDrawDrawBiText8(pixmap,bd->value_x+2,i*(bd->fh+1)+bd->as,buffer,-1,NULL,MAIN_FOREGROUND);
	  break;
	  case prt_uint:
	    sprintf( buffer, "%u", (unsigned) bdf->props[i+cur->top_prop].u.val );
	    GDrawDrawBiText8(pixmap,bd->value_x+2,i*(bd->fh+1)+bd->as,buffer,-1,NULL,MAIN_FOREGROUND);
	  break;
	}
	GDrawDrawLine(pixmap,0,i*(bd->fh+1)+bd->fh,bd->vwidth,i*(bd->fh+1)+bd->fh,0x808080);
    }
    if ( i<page ) {
/* GT: I am told that the use of "|" to provide contextual information in a */
/* GT: gettext string is non-standard. However it is documented in section */
/* GT: 10.2.6 of http://www.gnu.org/software/gettext/manual/html_mono/gettext.html */
/* GT: */
/* GT: Anyway here the word "Property" is used to provide context for "New..." and */
/* GT: the translator should only translate "New...". This is necessary because in */
/* GT: French (or any language where adjectives agree in gender/number with their */
/* GT: nouns) there are several different forms of "New" and the one chose depends */
/* GT: on the noun in question. */
/* GT: A french translation might be either msgstr "Nouveau..." or msgstr "Nouvelle..." */
/* GT: */
/* GT: I expect there are more cases where one english word needs to be translated */
/* GT: by several different words in different languages (in Japanese a different */
/* GT: word is used for the latin script and the latin language) and that you, as */
/* GT: a translator may need to ask me to disambiguate more strings. Please do so: */
/* GT:      <*****@*****.**> */
	GDrawDrawBiText8(pixmap,4,i*(bd->fh+1)+bd->as,S_("Property|New..."),-1,NULL,0xff0000);
	GDrawDrawLine(pixmap,0,i*(bd->fh+1)+bd->fh,bd->vwidth,i*(bd->fh+1)+bd->fh, _ggadget_Default_Box.border_darker);
    }
    GDrawDrawLine(pixmap,bd->value_x,0,bd->value_x,bd->vheight, _ggadget_Default_Box.border_darker);
}
Пример #4
0
static int glist_expose(GWindow pixmap, GGadget *g, GEvent *event) {
    GDList *gl = (GDList *) g;
    GRect old0, old1, old2;
    Color fg, dfg;
    int y, l, ymax;

    if ( g->state == gs_invisible )
return( false );

    GDrawPushClip(pixmap,&event->u.expose.rect,&old0);
    GDrawPushClip(pixmap,&g->r,&old1);

    GBoxDrawBackground(pixmap,&g->r,g->box, g->state,false);
    if ( g->box->border_type!=bt_none ||
	    (g->box->flags&(box_foreground_border_inner|box_foreground_border_outer|box_active_border_inner))!=0 ) {
	GBoxDrawBorder(pixmap,&g->r,g->box,g->state,false);

	GDrawPushClip(pixmap,&g->inner,&old2);
    }

    fg = g->state==gs_disabled?g->box->disabled_foreground:g->box->main_foreground;
    dfg = g->box->disabled_foreground;
    y = g->inner.y;
    ymax = g->inner.y+g->inner.height;
    if ( ymax>event->u.expose.rect.y+event->u.expose.rect.height )
	ymax = event->u.expose.rect.y+event->u.expose.rect.height;
    for ( l = gl->loff; y<ymax && l<gl->ltot; ++l ) {
	if ( y+gl->hmax > event->u.expose.rect.y )
	    y += GTextInfoDraw(pixmap,g->inner.x-gl->xoff,y,gl->ti[l],
		    gl->font,gl->ti[l]->disabled?dfg:fg,g->box->active_border,
		    ymax);
	else if ( gl->sameheight )
	    y += gl->hmax;
	else
	    y += GTextInfoGetHeight(pixmap,gl->ti[l],gl->font);
    }
    if ( g->box->border_type!=bt_none ||
	    (g->box->flags&(box_foreground_border_inner|box_foreground_border_outer|box_active_border_inner))!=0 )
	GDrawPopClip(pixmap,&old2);
    GDrawPopClip(pixmap,&old1);
    GDrawPopClip(pixmap,&old0);
return( true );
}
Пример #5
0
static int gline_expose(GWindow pixmap, GGadget *g, GEvent *event) {
    GRect old1;

    if ( g->state == gs_invisible )
return( false );

    GDrawPushClip(pixmap,&g->r,&old1);
    if ( g->vert )
	GBoxDrawVLine(pixmap,&g->r,g->box);
    else
	GBoxDrawHLine(pixmap,&g->r,g->box);
    GDrawPopClip(pixmap,&old1);
return( true );
}
Пример #6
0
static void draw_thumb(GWindow pixmap, GScrollBar *gsb) {
    GRect thumbrect, thumbinner, old;
    int lw, skip, i;

    GDrawPushClip(pixmap,&gsb->g.inner,&old);
    thumbrect = gsb->g.inner;
    if ( gsb->g.vert ) {
	thumbrect.y = gsb->g.inner.y+gsb->thumbpos;
	thumbrect.height = gsb->thumbsize;
    } else {
	thumbrect.x = gsb->g.inner.x+gsb->thumbpos;
	thumbrect.width = gsb->thumbsize;
    }
    thumbinner.x = thumbrect.x+gsb->thumbborder;
    thumbinner.y = thumbrect.y+gsb->thumbborder;
    thumbinner.width = thumbrect.width-2*gsb->thumbborder;
    thumbinner.height = thumbrect.height-2*gsb->thumbborder;

    GBoxDrawBackground(pixmap,&thumbrect,gsb->thumbbox, gsb->g.state,false);
    GBoxDrawBorder(pixmap,&thumbrect,gsb->thumbbox,gsb->g.state,false);

    lw = GDrawPointsToPixels(gsb->g.base,1);
    skip = GDrawPointsToPixels(gsb->g.base,3);
    GDrawSetLineWidth(pixmap,lw);
    if ( gsb->g.vert ) {
	for ( i = thumbinner.y + skip; i<thumbinner.y+thumbinner.height-skip;
		i += skip+2*lw ) {
	    GDrawDrawLine(pixmap,thumbinner.x+lw, i, thumbinner.x+thumbinner.width-2*lw, i,
		    gsb->thumbbox->border_brightest );
	    GDrawDrawLine(pixmap,thumbinner.x+lw, i+lw, thumbinner.x+thumbinner.width-2*lw, i+lw,
		    gsb->thumbbox->border_darkest );
	}
    } else {
	for ( i = thumbinner.x + skip; i<thumbinner.x+thumbinner.width-skip;
		i += skip+2*lw ) {
	    GDrawDrawLine(pixmap,i, thumbinner.y+lw, i, thumbinner.y+thumbinner.height-2*lw,
		    gsb->thumbbox->border_brightest );
	    GDrawDrawLine(pixmap,i+lw, thumbinner.y+lw, i+lw, thumbinner.y+thumbinner.height-2*lw, 
		    gsb->thumbbox->border_darkest );
	}
    }
    GDrawPopClip(pixmap,&old);
}
Пример #7
0
static int ggroup_expose(GWindow pixmap, GGadget *g, GEvent *event) {
    GRect old1, border;

    if ( g->state == gs_invisible )
return( false );

    GDrawPushClip(pixmap,&g->r,&old1);
    /* Background should be transpearant */
    /*GBoxDrawBackground(pixmap,&g->r,g->box, g->state,false);*/
    border = g->r;
    if ( g->prevlabel ) {
	int off = (g->prev->r.height-GBoxBorderWidth(g->base,g->box))/2;
	border.y += off; border.height -= off;
    }
    GBoxDrawBorder(pixmap,&border,g->box,g->state,false);

    GDrawPopClip(pixmap,&old1);
return( true );
}
Пример #8
0
static int gscrollbar_expose(GWindow pixmap, GGadget *g, GEvent *event) {
    GScrollBar *gsb = (GScrollBar *) g;
    GBox box = *(g->box);
    GRect old1;
    GRect r;
    int ar;

    if ( g->state == gs_invisible )
return( false );

    /* In case border was changed in resource editor, */
    /* the scrollbar thumb inside must be refitted. */
    GScrollBarFit(gsb);

    GDrawPushClip(pixmap,&g->r,&old1);

    r = g->r;
    ar = gsb->arrowsize - gsb->sbborder;
    if ( gsb->g.vert ) { r.y += ar ; r.height -= 2*ar; }
    else { r.x += ar; r.width -= 2*ar; }

    /* Mimick old border behavior to retain compatibility with older themes, */
    /* but match border shape with that of background. */
    box.flags = box_foreground_border_outer;
    box.border_width = 0;
    GBoxDrawBackground(pixmap,&g->r,g->box,g->state,false);
    GBoxDrawBackground(pixmap,&r,g->box,gs_pressedactive,false);
    GBoxDrawBorder(pixmap,&g->r,&box,g->state,false);
    GBoxDrawBorder(pixmap,&r,g->box,g->state,false);

    draw_thumb(pixmap,gsb); /* sets line width for arrows too */
    draw_arrow(pixmap,gsb,gsb->g.vert);
    draw_arrow(pixmap,gsb,gsb->g.vert|2);

    GDrawPopClip(pixmap,&old1);
return( true );
}
Пример #9
0
static int growcol_expose(GWindow pixmap, GGadget *g, GEvent *event) {
    GRowCol *grc = (GRowCol *) g;
    GRect old1, old2;
    Color fg, dfg;
    int y, l, ymax, i;

    if ( g->state == gs_invisible )
return( false );

    GDrawPushClip(pixmap,&g->r,&old1);

    GBoxDrawBackground(pixmap,&g->r,g->box, g->state,false);
    if ( g->box->border_type!=bt_none ||
	    (g->box->flags&(box_foreground_border_inner|box_foreground_border_outer|box_active_border_inner))!=0 ) {
	GBoxDrawBorder(pixmap,&g->r,g->box,g->state,false);

	GDrawPushClip(pixmap,&g->inner,&old2);
    }

    fg = g->state==gs_disabled?g->box->disabled_foreground:g->box->main_foreground;
    dfg = g->box->disabled_foreground;
    y = g->inner.y;
    ymax = g->inner.y+g->inner.height;
    if ( ymax>event->u.expose.rect.y+event->u.expose.rect.height )
	ymax = event->u.expose.rect.y+event->u.expose.rect.height;
    if ( grc->labels!=NULL ) {
	if ( y+grc->fh > event->u.expose.rect.y ) {
	    GRect r;
	    r = g->inner; r.height = fh;
	    GDrawFillRect(pixmap,&r,GRowColLabelBg);
	    for ( i=0; i<grc->cols; ++i ) {
		GTextInfoDraw(pixmap,g->inner.x+grc->colx[i]+grc->hpad-grc->xoff,y,grc->labels[i],
			grc->font,grc->labels[l]->disabled?dfg:dfg,g->box->active_border
			g->inner.y+g->inner.height);
	    }
	}
	y += grc->fh;
	if ( grc->hrules )
	    GDrawDrawLine(pixmap,g->inner.x,y-1,g->inner.x+g->inner.width,y-1,fg);
    }
    for ( l = grc->loff; y<ymax && l<grc->rows; ++l ) {
	if ( y+grc->fh > event->u.expose.rect.y ) {
	    for ( i=0; i<grc->cols; ++i ) {
		if ( l!=grc->tfr || i!=grc->tfc ) {
		    GTextInfo *ti = grc->ti[l*grc->cols+i];
		    GTextInfoDraw(pixmap,g->inner.x+grc->colx[i]-grc->xoff+grc->hpad,y,ti,
			    grc->font,ti->disabled?dfg:dfg,g->box->active_border,
			    g->inner.y+g->inner.height);
		} else {
		    /* now we can draw the text field */
		    grc->tf->dontdraw = false;
		    (grc->tf->g.gfuncs->handle_expose)(pixmap,&grc->tf->g,event);
		    grc->tf->dontdraw = true;
		}
	    }
	}
	y += grc->fh;
	if ( grc->hrules )
	    GDrawDrawLine(pixmap,g->inner.x,y-1,g->inner.x+g->inner.width,y-1,fg);
    }
    if ( grc->vrules ) {
	for ( i=1; i<grc->cols; ++i ) 
	    GDrawDrawLine(pixmap,grc->colx[i]-grc->xoff,g->inner.y,
		    grc->colx[i]-grc->xoff,g->inner.y+g->inner.height,fg);
    }
    if ( g->box->border_type!=bt_none ||
	    (g->box->flags&(box_foreground_border_inner|box_foreground_border_outer|box_active_border_inner))!=0 )
	GDrawPopClip(pixmap,&old2);
    GDrawPopClip(pixmap,&old1);
return( true );
}
Пример #10
0
static int gradio_expose(GWindow pixmap, GGadget *g, GEvent *event) {
    GRadio *gr = (GRadio *) g;
    int x;
    GImage *img = gr->image;
    GResImage *mark;
    GRect old1, old2, old3;
    int yoff = (g->inner.height-(gr->fh))/2;

    if ( g->state == gs_invisible )
return( false );

    GDrawPushClip(pixmap,&g->r,&old1);

    GBoxDrawBackground(pixmap,&g->r,g->box,
	    g->state==gs_enabled? gs_pressedactive: g->state,false);
    GBoxDrawBorder(pixmap,&g->r,g->box,g->state,false);

    GDrawPushClip(pixmap,&gr->onoffrect,&old2);
    GBoxDrawBackground(pixmap,&gr->onoffrect,gr->ison?gr->onbox:gr->offbox,
	    gs_pressedactive,false);
    GBoxDrawBorder(pixmap,&gr->onoffrect,gr->ison?gr->onbox:gr->offbox,
	    gs_pressedactive,false);

    mark = NULL;
    if ( g->state == gs_disabled )
	mark = gr->ison ? gr->ondis : gr->offdis;
    if ( mark==NULL || mark->image==NULL )
	mark = gr->ison ? gr->on : gr->off;
    if ( mark!=NULL && mark->image==NULL )
	mark = NULL;
    if ( mark!=NULL ) {
	GDrawPushClip(pixmap,&gr->onoffinner,&old3);
	GDrawDrawScaledImage(pixmap,mark->image,
		gr->onoffinner.x,gr->onoffinner.y);
	GDrawPopClip(pixmap,&old3);
    } else if ( gr->ison && gr->onbox == &checkbox_on_box ) {
	Color fg = g->state==gs_disabled?g->box->disabled_foreground:
			g->box->main_foreground==COLOR_DEFAULT?GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap)):
			g->box->main_foreground;
	int bp = GDrawPointsToPixels(pixmap,gr->onbox->border_width);
	GDrawDrawLine(pixmap, gr->onoffrect.x+bp,gr->onoffrect.y+bp,
				gr->onoffrect.x+gr->onoffrect.width-1-bp,gr->onoffrect.y+gr->onoffrect.height-1-bp,
			        fg);
	GDrawDrawLine(pixmap, gr->onoffrect.x+gr->onoffrect.width-1-bp,gr->onoffrect.y+bp,
				gr->onoffrect.x+bp,gr->onoffrect.y+gr->onoffrect.height-1-bp,
			        fg);
    }
    GDrawPopClip(pixmap,&old2);
    x = gr->onoffrect.x + gr->onoffrect.width + GDrawPointsToPixels(pixmap,4);

    GDrawPushClip(pixmap,&g->inner,&old2);
    if ( gr->font!=NULL )
	GDrawSetFont(pixmap,gr->font);
    if ( gr->image_precedes && img!=NULL ) {
	GDrawDrawScaledImage(pixmap,img,x,g->inner.y);
	x += GImageGetScaledWidth(pixmap,img) + GDrawPointsToPixels(pixmap,_GGadget_TextImageSkip);
    }
    if ( gr->label!=NULL ) {
	Color fg = g->state==gs_disabled?g->box->disabled_foreground:
			g->box->main_foreground==COLOR_DEFAULT?GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap)):
			g->box->main_foreground;
	int lcnt = gradio_linecount(gr);
	if ( lcnt>1 )
	    yoff = (g->inner.height-lcnt*gr->fh)/2;
	_ggadget_underlineMnemonic(pixmap,x,g->inner.y + gr->as + yoff,gr->label,
		g->mnemonic,fg,g->inner.y+g->inner.height);
	x += GDrawDrawBiText(pixmap,x,g->inner.y + gr->as + yoff,gr->label,-1,NULL,
		fg );
	x += GDrawPointsToPixels(pixmap,_GGadget_TextImageSkip);
    }
    if ( !gr->image_precedes && img!=NULL )
	GDrawDrawScaledImage(pixmap,img,x,g->inner.y);

    GDrawPopClip(pixmap,&old2);
    GDrawPopClip(pixmap,&old1);
return( true );
}
Пример #11
0
static int _GWidget_Container_eh(GWindow gw, GEvent *event) {
/* Gadgets can get mouse, char and expose events */
/* Widgets might need char events redirected to them */
/* If a gadget doesn't want an event it returns false from its eh */
/* If a subwidget doesn't want an event it may send it up to us */
    int handled = false;
    GGadget *gadget;
    GContainerD *gd = (GContainerD *) (gw->widget_data);
    GWindow pixmap;
    GWindow parent;
    GTopLevelD *topd;

    if ( gd==NULL )			/* dying */
return(true);

    for ( parent = gw; parent->parent!=NULL && parent->parent->widget_data!=NULL &&
	    !parent->is_toplevel; parent = parent->parent );
    topd = (GTopLevelD *) (parent->widget_data);
    if ( topd==NULL )
	fprintf( stderr, "No top level window found\n" );

    GGadgetPopupExternalEvent(event);
    if ( event->type == et_expose ) {
	GRect old;

	pixmap = _GWidget_GetPixmap(gw,&event->u.expose.rect);
	pixmap->ggc->bg = gw->ggc->bg;
	GDrawPushClip(pixmap,&event->u.expose.rect,&old);
	pixmap->user_data = gw->user_data;

	if ( gd->e_h!=NULL ) {
	    (gd->e_h)(pixmap,event);
	}
	for ( gadget = gd->gadgets; gadget!=NULL ; gadget=gadget->prev )
	    if ( ! ( gadget->r.x>event->u.expose.rect.x+event->u.expose.rect.width ||
		    gadget->r.y>event->u.expose.rect.y+event->u.expose.rect.height ||
		    gadget->r.x+gadget->r.width<event->u.expose.rect.x ||
		    gadget->r.y+gadget->r.height<event->u.expose.rect.y ) &&
		    gadget->state!=gs_invisible )
		(gadget->funcs->handle_expose)(pixmap,gadget,event);

	GDrawPopClip(pixmap,&old);
	_GWidget_RestorePixmap(gw,pixmap,&event->u.expose.rect);

return( true );
    } else if ( event->type >= et_mousemove && event->type <= et_crossing ) {
	if ( topd!=NULL && topd->popupowner!=NULL ) {
	    handled = (topd->popupowner->funcs->handle_mouse)(topd->popupowner,event);
return( handled );
	}
	if ( gd->grabgadget && event->type==et_mousedown &&
		(event->u.mouse.state&ksm_buttons)==0 )
	    gd->grabgadget = NULL;		/* Happens if a gadget invokes a popup menu. Gadget remains grabbed because menu gets the mouse up */
	if ( gd->grabgadget!=NULL ) {
	    handled = (gd->grabgadget->funcs->handle_mouse)(gd->grabgadget,event);
	    if ( !GDrawNativeWindowExists(NULL,event->native_window) ||
		    gw->is_dying || gw->widget_data==NULL )
return( true );
	    if ( event->type==et_mouseup )
		gd->grabgadget = NULL;
	} else if ( event->type==et_mousedown ) {
	    if ( !parent->is_popup )
		last_input_window = parent;
	    for ( gadget = gd->gadgets; gadget!=NULL && !handled ; gadget=gadget->prev ) {
		if ( gadget->state!=gs_disabled && gadget->state!=gs_invisible &&
			gadget->takes_input &&
			GGadgetWithin(gadget,event->u.mouse.x,event->u.mouse.y)) {
		    handled = (gadget->funcs->handle_mouse)(gadget,event);
		    if ( !GDrawNativeWindowExists(NULL,event->native_window) ||
			    gw->is_dying || gw->widget_data==NULL )
return( true );
		    gd->grabgadget = gadget;
		    if ( gadget->focusable && handled )
			GWidgetIndicateFocusGadget(gadget);
		}
	    }
	} else {
	    for ( gadget = gd->gadgets; gadget!=NULL && !handled ; gadget=gadget->prev ) {
		if ( !gadget->state!=gs_disabled && gadget->state!=gs_invisible &&
			/*gadget->takes_input &&*/	/* everybody needs mouse moves for popups, even labels */
			GGadgetWithin(gadget,event->u.mouse.x,event->u.mouse.y)) {
		    if ( gd->lastwiggle!=NULL && gd->lastwiggle!=gadget )
			(gd->lastwiggle->funcs->handle_mouse)(gd->lastwiggle,event);
		    handled = (gadget->funcs->handle_mouse)(gadget,event);
		    if ( !GDrawNativeWindowExists(NULL,event->native_window) ||
			    gw->is_dying || gw->widget_data==NULL )
return( true );
		    gd->lastwiggle = gadget;
		}
	    }
	    if ( !handled && gd->lastwiggle!=NULL ) {
		(gd->lastwiggle->funcs->handle_mouse)(gd->lastwiggle,event);
		if ( !GDrawNativeWindowExists(NULL,event->native_window) ||
			gw->is_dying )
return( true );
	    }
	}
    } else if ( event->type == et_char || event->type == et_charup ) {
	if ( topd!=NULL ) {
	    handled = (topd->handle_key)(parent,gw,event);
	}
    } else if ( event->type == et_drag || event->type == et_dragout || event->type==et_drop ) {
	GGadget *lastdd = NULL;
	GEvent e;
	for ( gadget = gd->gadgets; gadget!=NULL && !handled ; gadget=gadget->prev ) {
	    if ( gadget->funcs->handle_sel &&
		    GGadgetWithin(gadget,event->u.drag_drop.x,event->u.drag_drop.y))
		if (( handled = (gadget->funcs->handle_sel)(gadget,event) )) {
		    lastdd = gadget;
		    if ( !GDrawNativeWindowExists(NULL,event->native_window) ||
			    gw->is_dying )
return( true );
		    }
	}
	if ( !handled && gd->e_h!=NULL ) {
	    handled = (gd->e_h)(gw,event);
	    if ( !GDrawNativeWindowExists(NULL,event->native_window) ||
		    gw->is_dying )
return( true );
	    lastdd = (GGadget *) -1;
	}
	e.type = et_dragout;
	e.w = gw;
	if ( lastdd!=gd->lastddgadget ) {
	    if ( gd->lastddgadget==(GGadget *) -1 )
		(gd->e_h)(gw,&e);
	    else if ( gd->lastddgadget!=NULL )
		(gd->lastddgadget->funcs->handle_sel)(gd->lastddgadget,&e);
	    if ( !GDrawNativeWindowExists(NULL,event->native_window) ||
		    gw->is_dying )
return( true );
	}
	if ( event->type==et_drag )
	    gd->lastddgadget = lastdd;
	else
	    gd->lastddgadget = NULL;
return( handled );
    } else if ( event->type == et_selclear ) {
	for ( gadget = gd->gadgets; gadget!=NULL && !handled ; gadget=gadget->prev ) {
	    if ( gadget->funcs->handle_sel ) {
		if ( (handled = (gadget->funcs->handle_sel)(gadget,event)) )
	break;
	    }
	}
    } else if ( event->type == et_timer ) {
	for ( gadget = gd->gadgets; gadget!=NULL && !handled ; gadget=gadget->prev ) {
	    if ( gadget->funcs->handle_timer ) {
		if ( (handled = (gadget->funcs->handle_timer)(gadget,event)) )
	break;
	    }
	}
    } else if ( event->type == et_resize ) {
	GWidgetFlowGadgets(gw);
    }
    if ( gd->e_h!=NULL && (!handled || event->type==et_mousemove ))
	handled = (gd->e_h)(gw,event);
    if ( event->type == et_destroy ) {
	GGadget *prev;
	for ( gadget = gd->gadgets; gadget!=NULL ; gadget=prev ) {
	    prev = gadget->prev;
	    if ( !gadget->contained )
		(gadget->funcs->destroy)(gadget);
	    /* contained ggadgets will be destroyed when their owner is destroyed */
	}
	/* Widgets are windows and should get their own destroy events and free themselves */
	/* remove us from our parent */
	parent = gw->parent;
	if ( parent!=NULL && parent->widget_data!=NULL ) {
	    GContainerD *pgd = (GContainerD *) (parent->widget_data);
	    struct gwidgetdata *wd, *pwd;
	    for ( pwd=NULL, wd=pgd->widgets; wd!=NULL && wd!=(struct gwidgetdata *) gd; pwd = wd, wd = wd->next );
	    if ( pwd==NULL )
		pgd->widgets = gd->next;
	    else
		pwd->next = gd->next;
	}
	free(gd);
	gw->widget_data = NULL;
    }
return( handled );
}
Пример #12
0
static int splash_e_h(GWindow gw, GEvent *event) {
    static int splash_cnt;
    GRect old;
    int i, y, x;
    static char *foolishness[] = {
/* GT: These strings are for fun. If they are offensive or incomprehensible */
/* GT: simply translate them as something dull like: "FontForge" */
/* GT: This is a spoof of political slogans, designed to point out how foolish they are */
	    N_("A free press discriminates\nagainst the illiterate."),
	    N_("A free press discriminates\nagainst the illiterate."),
/* GT: This is a pun on the old latin drinking song "Gaudeamus igature!" */
	    N_("Gaudeamus Ligature!"),
	    N_("Gaudeamus Ligature!"),
/* GT: Spoof on the bible */
	    N_("In the beginning was the letter..."),
/* GT: Some wit at MIT came up with this ("ontology recapitulates phylogony" is the original) */
	    N_("fontology recapitulates file-ogeny")
    };

    switch ( event->type ) {
      case et_create:
	GDrawGrabSelection(gw,sn_user1);
      break;
      case et_expose:
	GDrawPushClip(gw,&event->u.expose.rect,&old);
	GDrawDrawImage(gw,&splashimage,NULL,0,0);
	GDrawSetFont(gw,splash_font);
	y = splashimage.u.image->height + as + fh/2;
	for ( i=1; i<linecnt; ++i ) {
	    if ( is>=lines[i-1]+1 && is<lines[i] ) {
		x = 8+GDrawDrawText(gw,8,y,lines[i-1]+1,is-lines[i-1]-1,0x000000);
		GDrawSetFont(gw,splash_italic);
		GDrawDrawText(gw,x,y,is,lines[i]-is,0x000000);
	    } else if ( ie>=lines[i-1]+1 && ie<lines[i] ) {
		x = 8+GDrawDrawText(gw,8,y,lines[i-1]+1,ie-lines[i-1]-1,0x000000);
		GDrawSetFont(gw,splash_font);
		GDrawDrawText(gw,x,y,ie,lines[i]-ie,0x000000);
	    } else
		GDrawDrawText(gw,8,y,lines[i-1]+1,lines[i]-lines[i-1]-1,0x000000);
	    y += fh;
	}
	GDrawPopClip(gw,&old);
      break;
      case et_map:
	splash_cnt = 0;
      break;
      case et_timer:
	if ( event->u.timer.timer==autosave_timer ) {
	    DoAutoSaves();
	} else if ( event->u.timer.timer==splasht ) {
	    if ( ++splash_cnt==1 )
		GDrawResize(gw,splashimage.u.image->width,splashimage.u.image->height-30);
	    else if ( splash_cnt==2 )
		GDrawResize(gw,splashimage.u.image->width,splashimage.u.image->height);
	    else if ( splash_cnt>=7 ) {
		GGadgetEndPopup();
		GDrawSetVisible(gw,false);
		GDrawCancelTimer(splasht);
		splasht = NULL;
	    }
	} else {
	    DoDelayedEvents(event);
	}
      break;
      case et_char:
      case et_mousedown:
      case et_close:
	GGadgetEndPopup();
	GDrawSetVisible(gw,false);
      break;
      case et_mousemove:
	GGadgetPreparePopup8(gw,_(foolishness[rand()%(sizeof(foolishness)/sizeof(foolishness[0]))]) );
      break;
      case et_selclear:
	/* If this happens, it means someone wants to send us a message with a*/
	/*  filename to open. So we need to ask for it, process it, and then  */
	/*  take the selection back again */
	if ( event->u.selclear.sel == sn_user1 ) {
	    int len;
	    char *arg;
	    arg = GDrawRequestSelection(splashw,sn_user1,"STRING",&len);
	    if ( arg==NULL )
return( true );
	    if ( strcmp(arg,"-new")==0 || strcmp(arg,"--new")==0 )
		FontNew();
	    else if ( strcmp(arg,"-open")==0 || strcmp(arg,"--open")==0 )
		_FVMenuOpen(NULL);
	    else if ( strcmp(arg,"-quit")==0 || strcmp(arg,"--quit")==0 )
		MenuExit(NULL,NULL,NULL);
	    else
		ViewPostScriptFont(arg,0);
	    free(arg);
	    GDrawGrabSelection(splashw,sn_user1);
	}
      break;
      case et_destroy:
	IError("Who killed the splash screen?");
      break;
    }
return( true );
}
Пример #13
0
static int gtabset_expose(GWindow pixmap, GGadget *g, GEvent *event) {
    GTabSet *gts = (GTabSet *) g;
    int x,y,i,rd, dsel;
    GRect old1, bounds;
    int bw = GBoxBorderWidth(pixmap,g->box);
    int yoff = ( gts->rcnt==1 ? bw : 0 );
    Color fg;
    int ni = GDrawPointsToPixels(pixmap,NEST_INDENT);

    if ( g->state == gs_invisible )
return( false );

    GDrawPushClip(pixmap,&g->r,&old1);

    GBoxDrawBackground(pixmap,&g->r,g->box,g->state,false);
    bounds = g->r;

    if ( !gts->vertical ) {
	/* make room for tabs */
	bounds.y += gts->rcnt*gts->rowh+yoff-1;
	bounds.height -= gts->rcnt*gts->rowh+yoff-1;
	/* draw border around horizontal tabs only */
	GBoxDrawBorder(pixmap,&bounds,g->box,g->state,false);
    }
    else if ( g->state==gs_enabled ) {
	/* background for labels */
	GRect old2, vertListRect = g->r;
	vertListRect.width = gts->vert_list_width+bw-1;
	GDrawPushClip(pixmap,&vertListRect,&old2);
	GBoxDrawBackground(pixmap,&g->r,g->box,gs_pressedactive,false);
	GDrawPopClip(pixmap,&old2);
    }

    GDrawSetFont(pixmap,gts->font);

    if ( gts->vertical ) {
	x = g->r.x + bw + 3;
	y = g->r.y + bw + 3;
	for ( i=gts->offtop; i<gts->tabcnt; ++i ) {
	    fg = gts->tabs[i].disabled?gts->g.box->disabled_foreground:gts->g.box->main_foreground;
	    if ( fg==COLOR_DEFAULT ) fg = GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap));
	    if ( i==gts->sel ) {
		GRect r;
		r.x = x; r.y = y;
		r.width = gts->vert_list_width-10; r.height = gts->fh;
		GDrawFillRect(pixmap,&r,gts->g.box->active_border);
	    }
	    GDrawDrawText(pixmap,x+gts->tabs[i].nesting*ni,y + gts->as,gts->tabs[i].name,-1,fg);
	    y += gts->fh;
	}
	fg = gts->g.box->main_foreground;
	if ( fg==COLOR_DEFAULT ) fg = GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap));
	GDrawDrawLine(pixmap,x + gts->vert_list_width-4, g->r.y + bw,
			     x + gts->vert_list_width-4, g->r.y + g->r.height - (bw+1),
			     fg);
	if ( gts->vsb != NULL )
	    gts->vsb->funcs->handle_expose(pixmap,gts->vsb,event);
    } else {
	gts->haslarrow = gts->hasrarrow = false;
	if ( gts->scrolled ) {
	    x = g->r.x + GBoxBorderWidth(pixmap,gts->g.box);
	    y = g->r.y+yoff;
	    dsel = 0;
	    if ( gts->toff!=0 )
		x = DrawLeftArrowTab(pixmap,gts,x,y);
	    for ( i=gts->toff;
		    (i==gts->tabcnt-1 && x+gts->tabs[i].width < g->r.width) ||
		    (i<gts->tabcnt-1 && x+gts->tabs[i].width < g->r.width-gts->arrow_width ) ;
		    ++i ) {
		if ( i!=gts->sel )
		    x = DrawTab(pixmap,gts,i,x,y);
		else {
		    gts->tabs[i].x = x;
		    x += gts->tabs[i].width;
		    dsel = 1;
		}
	    }
	    if ( i!=gts->tabcnt ) {
		int p = gts->g.inner.x+gts->g.inner.width - gts->arrow_width;
		if ( p>x ) x=p;
		x = DrawRightArrowTab(pixmap,gts,x,y);
		gts->tabs[i].x = 0x7fff;
	    }
	    /* This one draws on top of the others, must come last */
	    if ( dsel )
		DrawTab(pixmap,gts,gts->sel,gts->tabs[gts->sel].x, g->r.y + (gts->rcnt-1) * gts->rowh + yoff );
	} else {
	    /* r is real row, rd is drawn pos */
	    /* rd is 0 at the top of the ggadget */
	    /* r is 0 when it contains tabs[0], (the index in the rowstarts array) */
	    for ( rd = 0; rd<gts->rcnt; ++rd ) {
		int r = (gts->rcnt-1-rd+gts->active_row)%gts->rcnt;
		y = g->r.y + rd * gts->rowh + yoff;
		x = g->r.x + (gts->rcnt-1-rd) * gts->offset_per_row + GBoxBorderWidth(pixmap,gts->g.box);
		for ( i = gts->rowstarts[r]; i<gts->rowstarts[r+1]; ++i )
		    if ( i==gts->sel ) {
			gts->tabs[i].x = x;
			x += gts->tabs[i].width;
		    } else
			x = DrawTab(pixmap,gts,i,x,y);
	    }
	    /* This one draws on top of the others, must come last */
	    DrawTab(pixmap,gts,gts->sel,gts->tabs[gts->sel].x, g->r.y + (gts->rcnt-1) * gts->rowh + yoff );
	}
    }
    if ( gts->nested_expose )
	(gts->nested_expose)(pixmap,g,event);
    GDrawPopClip(pixmap,&old1);
return( true );
}
Пример #14
0
static void KP_ExposeKerns(KPData *kpd,GWindow pixmap,GRect *rect) {
    GRect old, subclip, subold, sel;
    struct _GImage base;
    GImage gi;
    int index1, index2;
    BDFChar *bdfc1, *bdfc2;
    int i, as, x, em = kpd->sf->ascent+kpd->sf->descent, yoff;
    int first, last;
    struct kerns *kern;
    char buffer[140];

    first = rect->y/kpd->uh;
    last = (rect->y+rect->height+kpd->uh-1)/kpd->uh;

    for ( i=first; i<=last && i+kpd->off_top<kpd->kcnt; ++i ) {
	kern = &kpd->kerns[i+kpd->off_top];
	index1 = kern->first->orig_pos;
	if ( kpd->bdf->glyphs[index1]==NULL )
	    BDFPieceMeal(kpd->bdf,index1);
	index2 = kern->second->orig_pos;
	if ( kpd->bdf->glyphs[index2]==NULL )
	    BDFPieceMeal(kpd->bdf,index2);
    }

    as = kpd->vpad + kpd->sf->ascent * kpd->bdf->pixelsize / em;

    memset(&gi,'\0',sizeof(gi));
    memset(&base,'\0',sizeof(base));
    gi.u.image = &base;
    base.image_type = it_index;
    base.clut = kpd->bdf->clut;
    GDrawSetDither(NULL, false);

    GDrawPushClip(pixmap,rect,&old);
    GDrawSetFont(pixmap,kpd->font);
    GDrawSetLineWidth(pixmap,0);
    GDrawFillRect(pixmap,rect,GDrawGetDefaultBackground(NULL));
    subclip = *rect;
    for ( i=first; i<=last && i+kpd->off_top<kpd->kcnt; ++i ) {
	subclip.y = i*kpd->uh; subclip.height = kpd->uh;
	GDrawPushClip(pixmap,&subclip,&subold);

	kern = &kpd->kerns[i+kpd->off_top];
	index1 = kern->first->orig_pos;
	index2 = kern->second->orig_pos;
	bdfc1 = kpd->bdf->glyphs[index1];
	bdfc2 = kpd->bdf->glyphs[index2];

	BaseFillFromBDFC(&base,bdfc1);
	base.trans = base.clut->trans_index = -1;
	/* the peculiar behavior concerning xmin/xmax is because the bitmaps */
	/*  don't contain the side-bearings, we have to add that spacing manually */
	if ( !kern->r2l ) {
	    GDrawDrawImage(pixmap,&gi,NULL, 10,subclip.y+as-bdfc1->ymax);
	    x = 10 + (bdfc1->width-bdfc1->xmin) + bdfc2->xmin +
		    (kern->newoff*kpd->bdf->pixelsize/em);
	} else {
	    x = kpd->vwidth-10-(bdfc1->xmax-bdfc1->xmin);
	    GDrawDrawImage(pixmap,&gi,NULL, x,subclip.y+as-bdfc1->ymax);
	    x -= bdfc1->xmin + (bdfc2->width-bdfc2->xmin) +
		    (kern->newoff*kpd->bdf->pixelsize/em);
	}
	BaseFillFromBDFC(&base,bdfc2);
#ifndef _BrokenBitmapImages
	base.trans = base.clut->trans_index = 0;
#endif
	yoff = (kern->newyoff*kpd->bdf->pixelsize/em);
	GDrawDrawImage(pixmap,&gi,NULL, x,subclip.y+as-bdfc2->ymax-yoff);
	GDrawDrawLine(pixmap,0,subclip.y+kpd->uh-1,
		subclip.x+subclip.width,subclip.y+kpd->uh-1,0x000000);
	if ( kern->kp!=NULL )
	    sprintf( buffer, "%d ", kern->newoff);
	else
	    sprintf( buffer, "%d,%d ", kern->newoff, kern->newyoff );
	if ( kern->ac!=NULL )
	    strncat(buffer,kern->ac->name,sizeof(buffer)-strlen(buffer)-1);
	GDrawDrawBiText8(pixmap,15,subclip.y+kpd->uh-kpd->fh+kpd->as,buffer,-1,NULL,
		kern->kp!=NULL && kern->newoff!=kern->kp->off ? 0xff0000 : 0x000000 );
	if ( i+kpd->off_top==kpd->selected ) {
	    sel.x = 0; sel.width = kpd->vwidth-1;
	    sel.y = subclip.y; sel.height = kpd->uh-2;
	    GDrawDrawRect(pixmap,&sel,0x000000);
	}
	GDrawPopClip(pixmap,&subold);
    }
#ifndef _BrokenBitmapImages
    base.clut->trans_index = -1;
#endif
    GDrawPopClip(pixmap,&old);
    GDrawSetDither(NULL, true);
}
Пример #15
0
static void AnchorD_Expose(AnchorDlg *a,GWindow pixmap,GEvent *event) {
    GRect *area = &event->u.expose.rect;
    GRect clip, old1, old2;
    int expose_end = area->x+area->width;
    int factor = a->magfactor;
    int i,x,y;

    if ( expose_end<a->ctl_len )
return;

    GDrawPushClip(pixmap,area,&old1);

    if ( area->x<a->ctl_len+a->char_size*factor ) {
	GDrawDrawLine(pixmap,a->ctl_len,0,a->ctl_len,a->full_height,0x000000);
	KCD_DrawGlyph(pixmap,a->char_off*factor+a->ctl_len,a->baseline,a->bdfc,factor);
	DrawAnchorPoint(pixmap,
	    a->char_off*factor+a->ctl_len + ((int) rint(a->apos.x*a->scale))*factor,
	    a->baseline - ((int) rint(a->apos.y*a->scale))*factor,
	    false);
	GDrawDrawLine(pixmap,a->ctl_len+a->char_size*factor,0,a->ctl_len+a->char_size*factor,a->full_height,0x000000);
    }

    if ( expose_end>a->ctl_len+a->char_size && area->y<a->sb_base ) {
	int xcor=0, ycor=0;
	unichar_t *end;
	const unichar_t *ret;

	ret = _GGadgetGetTitle(GWidgetGetControl(a->gw,CID_XCor));
	xcor = u_strtol(ret,&end,10);
	while ( *end==' ' ) ++end;
	if ( *end!='\0' || xcor<-128 || xcor>127 )
	    xcor = 0;
	ret = _GGadgetGetTitle(GWidgetGetControl(a->gw,CID_YCor));
	ycor = u_strtol(ret,&end,10);
	while ( *end==' ' ) ++end;
	if ( *end!='\0' || ycor<-128 || ycor>127 )
	    ycor = 0;

	clip = *area;
	if ( area->x<=a->ctl_len+a->char_size ) {
	    clip.width -= a->ctl_len+a->char_size+1 - area->x;
	    clip.x = a->ctl_len+a->char_size+1;
	}
	if ( area->y+area->height > a->sb_base )
	    clip.height = a->sb_base-area->y;
	GDrawPushClip(pixmap,&clip,&old2);
	for ( i=0; i<a->cnt; ++i ) {
	    if ( a->apmatch[i].xstart - a->xoff > clip.x+clip.width )
	break;
	    if ( a->apmatch[i].xstart+a->apmatch[i].size*factor - a->xoff < clip.x )
	continue;

	    y = a->baseline;
	    if ( i!=0 )
		GDrawDrawLine(pixmap,a->apmatch[i].xstart-a->xoff,0,
			a->apmatch[i].xstart-a->xoff,a->sb_base,0x808080);
	    if ( a->ap->type==at_cexit ||
		    a->ap->type==at_basechar || a->ap->type==at_baselig ||
		    a->ap->type==at_basemark ) {
		x = a->apmatch[i].xstart+a->char_off*factor - a->xoff;
		KCD_DrawGlyph(pixmap,x,y,a->bdfc,factor);
		x += ((int) rint((-a->apmatch[i].ap->me.x + a->apos.x)*a->scale) +
			xcor - DevTabFind(&a->apmatch[i].ap->xadjust,a->pixelsize))*factor;
		y += ((int) rint((a->apmatch[i].ap->me.y - a->apos.y)*a->scale) +
			-ycor + DevTabFind(&a->apmatch[i].ap->yadjust,a->pixelsize))*factor;
		KCD_DrawGlyph(pixmap,x,y,a->apmatch[i].bdfc,factor);
	    } else {
		x = a->apmatch[i].xstart+a->apmatch[i].off*factor - a->xoff;
		KCD_DrawGlyph(pixmap,x,y,a->apmatch[i].bdfc,factor);
		x += ((int) rint((a->apmatch[i].ap->me.x - a->apos.x)*a->scale) +
			DevTabFind(&a->apmatch[i].ap->xadjust,a->pixelsize)-xcor)*factor;
		y += ((int) rint((-a->apmatch[i].ap->me.y + a->apos.y)*a->scale) +
			-DevTabFind(&a->apmatch[i].ap->yadjust,a->pixelsize)+ycor)*factor;
		KCD_DrawGlyph(pixmap,x,y,a->bdfc,factor);
	    }
	}
	if ( i>0 )
	    GDrawDrawLine(pixmap,a->apmatch[i-1].xstart+a->apmatch[i-1].size*factor-a->xoff,0,
		    a->apmatch[i-1].xstart+a->apmatch[i-1].size*factor-a->xoff,a->sb_base,0x808080);
	GDrawPopClip(pixmap,&old2);
    }
    GDrawPopClip(pixmap,&old1);
}
Пример #16
0
/* Called on expose events, this renders the button. */
static int gradio_expose(GWindow pixmap, GGadget *g, GEvent *event) {
    GRadio *gr = (GRadio *) g;
    int x;
    GImage *img = gr->image; /* the optional image tied to the label */
    GResImage *mark;
    GRect old1, old2, old3;
    int yoff = (g->inner.height-(gr->fh))/2;

    if ( g->state == gs_invisible )
return( false );

     /* First blank out the button area. */
    GDrawPushClip(pixmap,&g->r,&old1);

    GBoxDrawBackground(pixmap,&g->r,g->box,
	    g->state==gs_enabled? gs_pressedactive: g->state,false);
    GBoxDrawBorder(pixmap,&g->r,g->box,g->state,false);

    GDrawPushClip(pixmap,&gr->onoffrect,&old2);
    GBoxDrawBackground(pixmap,&gr->onoffrect,gr->ison?gr->onbox:gr->offbox,
	    gs_pressedactive,false);
    if (gr->ison && gr->onbox->border_type!=bt_none)
        GBoxDrawBorder(pixmap,&gr->onoffrect,gr->onbox, gs_pressedactive,false);
    else if (!gr->ison && gr->offbox->border_type!=bt_none)
        GBoxDrawBorder(pixmap,&gr->onoffrect,gr->offbox,gs_pressedactive,false);

     /* Next draw either the right image or draw in an on or off indicator. */
    mark = NULL;
    if ( g->state == gs_disabled )
	mark = gr->ison ? gr->ondis : gr->offdis; /* note: ondis or offdis may be NULL! */
    if ( mark==NULL || mark->image==NULL )
	mark = gr->ison ? gr->on : gr->off; /* note: on or off may be NULL! */
    if ( mark!=NULL && mark->image==NULL ) /* when there's a reference to a special image, but no actual image */
	mark = NULL;
    if ( mark!=NULL ) {
	GDrawPushClip(pixmap,&gr->onoffinner,&old3);
	GDrawDrawScaledImage(pixmap,mark->image,
		gr->onoffinner.x,gr->onoffinner.y);
	GDrawPopClip(pixmap,&old3);
    } else if ( gr->ison && gr->onbox == &checkbox_on_box ) {
	 /* for radio buttons where the on is a checkbox style, draw an X */
	Color fg = g->state==gs_disabled?g->box->disabled_foreground:
			g->box->main_foreground==COLOR_DEFAULT?GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap)):
			g->box->main_foreground;
	int bp = GDrawPointsToPixels(pixmap,gr->onbox->border_width);
	GDrawDrawLine(pixmap, gr->onoffrect.x+bp,gr->onoffrect.y+bp,
				gr->onoffrect.x+gr->onoffrect.width-1-bp,gr->onoffrect.y+gr->onoffrect.height-1-bp,
			        fg);
	GDrawDrawLine(pixmap, gr->onoffrect.x+gr->onoffrect.width-1-bp,gr->onoffrect.y+bp,
				gr->onoffrect.x+bp,gr->onoffrect.y+gr->onoffrect.height-1-bp,
			        fg);
    } else if ( gr->ison && gr->onbox == &visibility_on_box ) {
         /* draw open white of eye */
        GPoint pts[15];
        Color fg;
        double angle;
        int c,i;
	int bp = gr->onbox->border_type==bt_none ? 0 : GDrawPointsToPixels(pixmap,gr->onbox->border_width);
        int x=gr->onoffrect.x+bp;
        int y=gr->onoffrect.y+bp;
        int w=gr->onoffrect.width -1-2*bp;
        int h=gr->onoffrect.height-1-2*bp;
        GRect rect;
        for (c=0, i=0; c<7; c++) {
            angle=(30+c/6.*120)*M_PI/180;
            pts[i].x=.5*w*cos(angle)+x+w/2;
            pts[i].y=.5*h*sin(angle)+y+h/4;
            ++i;
        }
        for (c=1; c<6; c++) {
            angle=(180+30+c/6.*120)*M_PI/180;
            pts[i].x=.5*w*cos(angle)+x+w/2;
            pts[i].y=.5*h*sin(angle)+y+h*3/4;
            ++i;
        }
        pts[i].x=pts[0].x;
        pts[i].y=pts[0].y;
        ++i;
        fg=0x00ffffff; /* white */
        GDrawFillPoly(pixmap, pts, i, fg);
	fg = g->state==gs_disabled?g->box->disabled_foreground:
			g->box->main_foreground==COLOR_DEFAULT?GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap)):
			g->box->main_foreground;
        GDrawDrawPoly(pixmap, pts, i, fg);

         /* draw pupil */
        rect.x=gr->onoffrect.x+bp+w*.3;
        rect.y=gr->onoffrect.y+bp+h*.3;
        rect.width =.4*w;
        rect.height=.4*h;
        fg=0; /* black */
        GDrawFillElipse(pixmap, &rect, fg);

    } else if ( (!gr->ison) && gr->onbox == &visibility_on_box ) {
         /* draw closed eye */
        GPoint pts[6];
        int c,i;
        double angle;
	int bp = gr->onbox->border_type==bt_none ? 0 : GDrawPointsToPixels(pixmap,gr->onbox->border_width);
        int x=gr->onoffrect.x+bp;
        int y=gr->onoffrect.y+bp;
        int w=gr->onoffrect.width -1-2*bp;
        int h=gr->onoffrect.height-1-2*bp;
        Color fg = g->state==gs_disabled?g->box->disabled_foreground:
			g->box->main_foreground==COLOR_DEFAULT?GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap)):
			g->box->main_foreground;
        for (c=0, i=0; c<=6; c++) {
            angle=(30+c/6.*120)*M_PI/180;
            pts[i].x=.5*w*cos(angle)+x+w/2;
            pts[i].y=.5*h*sin(angle)+y+h/4;

             /* draw lashes */
            if (i>0 && i<5) GDrawDrawLine(pixmap, pts[i].x,pts[i].y, .75*w*cos(angle)+x+w/2, .75*h*sin(angle)+y+h/4, fg);
            ++i;
        }
        GDrawDrawPoly(pixmap, pts, i, fg);
    }

    GDrawPopClip(pixmap,&old2);
    x = gr->onoffrect.x + gr->onoffrect.width + GDrawPointsToPixels(pixmap,4);

     /* Finally write out the label if any. */
    GDrawPushClip(pixmap,&g->inner,&old2);
    if ( gr->font!=NULL )
	GDrawSetFont(pixmap,gr->font);
    if ( gr->image_precedes && img!=NULL ) {
	GDrawDrawScaledImage(pixmap,img,x,g->inner.y);
	x += GImageGetScaledWidth(pixmap,img) + GDrawPointsToPixels(pixmap,_GGadget_TextImageSkip);
    }
    if ( gr->label!=NULL ) {
	Color fg = g->state==gs_disabled?g->box->disabled_foreground:
			g->box->main_foreground==COLOR_DEFAULT?GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap)):
			g->box->main_foreground;
	int lcnt = gradio_linecount(gr);
	if ( lcnt>1 )
	    yoff = (g->inner.height-lcnt*gr->fh)/2;
	_ggadget_underlineMnemonic(pixmap,x,g->inner.y + gr->as + yoff,gr->label,
		g->mnemonic,fg,g->inner.y+g->inner.height);
	x += GDrawDrawText(pixmap,x,g->inner.y + gr->as + yoff,gr->label,-1,fg);
	x += GDrawPointsToPixels(pixmap,_GGadget_TextImageSkip);
    }
    if ( !gr->image_precedes && img!=NULL )
	GDrawDrawScaledImage(pixmap,img,x,g->inner.y);

    GDrawPopClip(pixmap,&old2);
    GDrawPopClip(pixmap,&old1);
return( true );
}