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); }
static void GroupWExpose(struct groupdlg *grp,GWindow pixmap,GRect *rect) { int depth, y, len; Group *group; GRect r; Color fg; GDrawFillRect(pixmap,rect,GDrawGetDefaultBackground(NULL)); GDrawSetLineWidth(pixmap,0); r.height = r.width = grp->as; y = (rect->y/grp->fh) * grp->fh + grp->as; depth=0; group = GroupFindLPos(grp->root,rect->y/grp->fh+grp->off_top,&depth); GDrawSetFont(pixmap,grp->font); while ( group!=NULL ) { r.y = y-grp->as+1; r.x = 5+8*depth - grp->off_left; fg = group->selected ? 0xff0000 : 0x000000; if ( group->glyphs==NULL ) { GDrawDrawRect(pixmap,&r,fg); GDrawDrawLine(pixmap,r.x+2,r.y+grp->as/2,r.x+grp->as-2,r.y+grp->as/2, fg); if ( !group->open ) GDrawDrawLine(pixmap,r.x+grp->as/2,r.y+2,r.x+grp->as/2,r.y+grp->as-2, fg); } len = GDrawDrawText8(pixmap,r.x+r.width+5,y,group->name,-1,fg); if ( group->glyphs ) GDrawDrawText8(pixmap,r.x+r.width+5+len+5,y,group->glyphs,-1,fg); group = GroupNext(group,&depth); y += grp->fh; if ( y-grp->fh>rect->y+rect->height ) break; } }
static int GProgressProcess(GProgress *p) { int width, amount; int tenpt; if ( !p->visible ) GProgressTimeCheck(); tenpt = GDrawPointsToPixels(p->gw,10); width = p->width-2*tenpt; if ( p->tot==0 ) amount = 0; else amount = width * (p->stage*p->tot + p->sofar)/(p->stages*p->tot); if ( amount!=p->last_amount ) { if ( amount<p->last_amount || p->last_amount==0 ) GDrawRequestExpose(p->gw,NULL,false); else { GRect r; r.height = tenpt-1; r.width = amount - p->last_amount; r.x = tenpt + p->last_amount; r.y = p->boxy+1; GDrawFillRect(p->gw,&r,progress_fillcol); } p->last_amount = amount; } GDrawProcessPendingEvents(NULL); return( !p->aborted ); }
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); }
static int DrawTab(GWindow pixmap, GTabSet *gts, int i, int x, int y ) { Color fg = gts->tabs[i].disabled?gts->g.box->disabled_foreground:gts->g.box->main_foreground; if ( fg==COLOR_DEFAULT ) fg = GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap)); GBoxDrawTabOutline(pixmap,>s->g,x,y,gts->tabs[i].width,gts->rowh,i==gts->sel); if ( (i==gts->sel) && (gts->g.box->flags&box_active_border_inner) ) { GRect r; r.x = x+2; r.y = y+1; r.width = gts->tabs[i].width-4; r.height = gts->rowh-2; GDrawFillRect(pixmap,&r,gts->g.box->active_border); } GDrawDrawText(pixmap,x+(gts->tabs[i].width-gts->tabs[i].tw)/2,y+gts->rowh-gts->ds, gts->tabs[i].name,-1,fg); gts->tabs[i].x = x; x += gts->tabs[i].width; return( x ); }
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 ); }
static int warningsv_e_h(GWindow gw, GEvent *event) { int i; extern GBox _ggadget_Default_Box; if (( event->type==et_mouseup || event->type==et_mousedown ) && (event->u.mouse.button>=4 && event->u.mouse.button<=7) ) { return( GGadgetDispatchEvent(errdata.vsb,event)); } switch ( event->type ) { case et_expose: /*GDrawFillRect(gw,&event->u.expose.rect,GDrawGetDefaultBackground(NULL));*/ GDrawSetFont(gw,errdata.font); for ( i=0; i<errdata.linecnt && i+errdata.offtop<errdata.cnt; ++i ) { int xs, xe; int s_l = errdata.start_l, s_c = errdata.start_c, e_l = errdata.end_l, e_c = errdata.end_c; GRect r; if ( s_l>e_l ) { s_l = e_l; s_c = e_c; e_l = errdata.start_l; e_c = errdata.start_c; } if ( GDrawHasCairo(gw)&gc_pango ) GDrawLayoutInit(gw,errdata.errlines[i+errdata.offtop],-1,NULL); if ( i+errdata.offtop >= s_l && i+errdata.offtop <= e_l ) { if ( i+errdata.offtop > s_l ) xs = 0; else if ( GDrawHasCairo(gw)&gc_pango ) { GRect pos; GDrawLayoutIndexToPos(gw,s_c,&pos); xs = pos.x+3; } else xs = GDrawGetText8Width(gw,errdata.errlines[i+errdata.offtop],s_c,NULL); if ( i+errdata.offtop < e_l ) xe = 3000; else if ( GDrawHasCairo(gw)&gc_pango ) { GRect pos; GDrawLayoutIndexToPos(gw,s_c,&pos); xe = pos.x+pos.width+3; } else xe = GDrawGetText8Width(gw,errdata.errlines[i+errdata.offtop],e_c,NULL); r.x = xs+3; r.width = xe-xs; r.y = i*errdata.fh; r.height = errdata.fh; GDrawFillRect(gw,&r,ACTIVE_BORDER); } if ( GDrawHasCairo(gw)&gc_pango ) GDrawLayoutDraw(gw,3,i*errdata.fh+errdata.as,MAIN_FOREGROUND); else GDrawDrawBiText8(gw,3,i*errdata.fh+errdata.as,errdata.errlines[i+errdata.offtop],-1,NULL,MAIN_FOREGROUND); } break; case et_char: return( ErrChar(event)); break; case et_mousedown: if ( event->u.mouse.button==3 ) { warnpopupmenu[1].ti.disabled = errdata.start_l == -1; warnpopupmenu[3].ti.disabled = errdata.cnt == 0; GMenuCreatePopupMenu(gw,event, warnpopupmenu); } else { if ( errdata.down ) return( true ); MouseToPos(event,&errdata.start_l,&errdata.start_c); errdata.down = true; } case et_mousemove: case et_mouseup: if ( !errdata.down ) return( true ); MouseToPos(event,&errdata.end_l,&errdata.end_c); GDrawRequestExpose(gw,NULL,false); if ( event->type==et_mouseup ) { errdata.down = false; if ( errdata.start_l == errdata.end_l && errdata.start_c == errdata.end_c ) { errdata.start_l = errdata.end_l = -1; } else { GDrawGrabSelection(gw,sn_primary); GDrawAddSelectionType(gw,sn_primary,"UTF8_STRING",&errdata,1, sizeof(char), genutf8data,noop); GDrawAddSelectionType(gw,sn_primary,"STRING",&errdata,1, sizeof(char), genutf8data,noop); } } break; case et_selclear: errdata.start_l = errdata.end_l = -1; GDrawRequestExpose(gw,NULL,false); break; case et_timer: break; case et_focus: break; } return( true ); }
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 ); }
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); }