Esempio n. 1
0
static void AddMI(GMenuItem *mi,GWindow gw,int changed, int top) {
    mi->ti.userdata = gw;
    mi->ti.bg = GDrawGetDefaultBackground(GDrawGetDisplayOfWindow(gw));
    mi->invoke = WindowSelect;
    mi->ti.text = GDrawGetWindowTitle(gw);
    if(mi->ti.text == NULL)
	mi->ti.text = utf82u_copy("(null)");
    if ( u_strlen( mi->ti.text ) > 35 )
	mi->ti.text[35] = '\0';
}
Esempio n. 2
0
static void RulerPlace(CharView *cv, GEvent *event) {
    unichar_t ubuf[80];
    int width, x, y;
    GRect size;
    GPoint pt;
    int i,h,w;
    GWindowAttrs wattrs;
    GRect pos;
    FontRequest rq;
    int as, ds, ld;

    if ( cv->ruler_w==NULL ) {
	memset(&wattrs,0,sizeof(wattrs));
	wattrs.mask = wam_events|wam_cursor|wam_positioned|wam_nodecor|wam_backcol|wam_bordwidth;
	wattrs.event_masks = (1<<et_expose)|(1<<et_resize)|(1<<et_mousedown);
	wattrs.cursor = ct_mypointer;
	wattrs.background_color = 0xe0e0c0;
	wattrs.nodecoration = 1;
	wattrs.border_width = 1;
	pos.x = pos.y = 0; pos.width=pos.height = 20;
	cv->ruler_w = GWidgetCreateTopWindow(NULL,&pos,ruler_e_h,cv,&wattrs);

	if ( rvfont==NULL ) {
	    memset(&rq,0,sizeof(rq));
	    rq.utf8_family_name = FIXED_UI_FAMILIES;
	    rq.point_size = -12;
	    rq.weight = 400;
	    rvfont = GDrawInstanciateFont(GDrawGetDisplayOfWindow(cv->ruler_w),&rq);
	    rvfont = GResourceFindFont("CharView.Measure.Font",rvfont);
	}
	cv->rfont = rvfont;
	GDrawFontMetrics(cv->rfont,&as,&ds,&ld);
	cv->rfh = as+ds; cv->ras = as;
    } else
	GDrawRaise(cv->ruler_w);

    GDrawSetFont(cv->ruler_w,cv->rfont);
    width = h = 0;
    for ( i=0; RulerText(cv,ubuf,i); ++i ) {
	w = GDrawGetBiTextWidth(cv->ruler_w,ubuf,-1,-1,NULL);
	if ( w>width ) width = w;
	h += cv->rfh;
    }
    GDrawGetSize(GDrawGetRoot(NULL),&size);
    pt.x = event->u.mouse.x; pt.y = event->u.mouse.y;
    GDrawTranslateCoordinates(cv->v,GDrawGetRoot(NULL),&pt);
    x = pt.x + infowindowdistance;
    if ( x+width > size.width )
	x = pt.x - width-infowindowdistance;
    y = pt.y -cv->ras-2;
    if ( y+h > size.height )
	y = pt.y - h - cv->ras -10;
    GDrawMoveResize(cv->ruler_w,x,y,width+4,h+4);
}
Esempio n. 3
0
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,&gts->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 );
}
Esempio n. 4
0
static int DrawRightArrowTab(GWindow pixmap, GTabSet *gts, int x, int y ) {
    Color fg = gts->g.box->main_foreground;
    GPoint pts[5];
    int retx = x + gts->arrow_width, cnt;

    if ( fg==COLOR_DEFAULT ) fg = GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap));
    GBoxDrawTabOutline(pixmap,&gts->g,x,y,gts->arrow_width,gts->rowh,false);
    gts->hasrarrow = true;
	y += (gts->rowh-gts->arrow_size)/2;
	x += (gts->arrow_width-gts->arrow_size/2)/2;
	cnt = 4;
	pts[0].y = (y+(gts->arrow_size-1)/2); 	pts[0].x = x + (gts->arrow_size-1)/2;
	pts[1].y = y; 				pts[1].x = x;
	pts[2].y = y+gts->arrow_size-1; 	pts[2].x = pts[1].x;
	pts[3] = pts[0];
	if ( !(gts->arrow_size&1 )) {
	    ++pts[3].y;
	    pts[4] = pts[0];
	    cnt = 5;
	}
	GDrawFillPoly(pixmap,pts,cnt,fg);
return( retx );
}
static int growcol_mouse(GGadget *g, GEvent *event) {
    GRowCol *grc = (GRowCol *) g;
    int pos;

    if ( !g->takes_input || (g->state!=gs_active && g->state!=gs_enabled && g->state!=gs_focused))
return( false );

    if ( event->type == et_crossing )
return( false );
    if ( event->type==et_mousemove && !grc->pressed && !grc->parentpressed ) {
	if ( GGadgetWithin(g,event->u.mouse.x,event->u.mouse.y) && g->popup_msg )
	    GGadgetPreparePopup(g->base,g->popup_msg);
return( true );
    } else if ( event->type==et_mouseup && grc->parentpressed &&
	    !GGadgetInnerWithin(&grc->g,event->u.mouse.x,event->u.mouse.y)) {
	grc->parentpressed = false;
	GDrawPointerUngrab(GDrawGetDisplayOfWindow(grc->g.base));
    } else if ( event->type==et_mousemove && grc->parentpressed &&
	    GGadgetInnerWithin(&grc->g,event->u.mouse.x,event->u.mouse.y)) {
	if ( grc->pressed == NULL )
	    grc->pressed = GDrawRequestTimer(g->base,GRowColScrollTime,GRowColScrollTime,NULL);
	GDrawPointerUngrab(GDrawGetDisplayOfWindow(grc->g.base));
	grc->parentpressed = false;
	growcol_scroll_selbymouse(grc,event);
return( true );
    } else if ( event->type==et_mousemove && grc->pressed ) {
	growcol_scroll_selbymouse(grc,event);
return( true );
    } else if ( event->type==et_mousedown ) {
	if ( grc->pressed == NULL )
	    grc->pressed = GDrawRequestTimer(g->base,GRowColScrollTime,GRowColScrollTime,NULL);
	pos = GRowColIndexFromPos(grc,event->u.mouse.y);
	if ( pos==-1 )
return( true ); /* Do Nothing, nothing selectable */
	else if ( !grc->exactly_one && grc->ti[pos]->selected &&
		(event->u.mouse.state&(ksm_control|ksm_shift))) {
	    grc->ti[pos]->selected = false;
	} else if ( !grc->multiple_sel ||
		!(event->u.mouse.state&(ksm_control|ksm_shift))) {
	    GRowColClearSel(grc);
	    grc->ti[pos]->selected = true;
	    grc->start = grc->end = pos;
	} else if ( event->u.mouse.state&ksm_control ) {
	    grc->ti[pos]->selected = !grc->ti[pos]->selected;
	    grc->start = grc->end = pos;
	} else if ( event->u.mouse.state&ksm_shift ) {
	    GRowColExpandSelection(grc,pos);
	}
	_ggadget_redraw(&grc->g);
    } else if ( event->type==et_mouseup && grc->pressed ) {
	GDrawCancelTimer(grc->pressed); grc->pressed = NULL;
	if ( GGadgetInnerWithin(&grc->g,event->u.mouse.x,event->u.mouse.y) ) {
	    growcol_scroll_selbymouse(grc,event);
	    if ( event->u.mouse.clicks==2 )
		GRowColDoubleClick(grc);
	    else
		GRowColSelected(grc);
	}
    } else
return( false );

return( true );
}
Esempio n. 6
0
void SFBdfProperties(SplineFont *sf, EncMap *map, BDFFont *thisone) {
    struct bdf_dlg bd;
    int i;
    BDFFont *bdf;
    GTextInfo *ti;
    char buffer[40];
    char title[130];
    GRect pos, subpos;
    GWindow gw;
    GWindowAttrs wattrs;
    GGadgetCreateData gcd[10];
    GTextInfo label[9];
    FontRequest rq;
    static GFont *font = NULL;
    extern int _GScrollBar_Width;
    int sbwidth;
    static unichar_t sans[] = { 'h','e','l','v','e','t','i','c','a',',','c','l','e','a','r','l','y','u',',','u','n','i','f','o','n','t',  '\0' };
    static GBox small = { 0 };
    GGadgetData gd;
    /* I don't use a MatrixEdit here because I want to be able to display */
    /*  non-standard properties. And a MatrixEdit can only disply things in */
    /*  its pull-down list */

    memset(&bd,0,sizeof(bd));
    bd.map = map;
    bd.sf = sf;
    for ( bdf = sf->bitmaps, i=0; bdf!=NULL; bdf=bdf->next, ++i );
    if ( i==0 )
return;
    bd.fcnt = i;
    bd.fonts = gcalloc(i,sizeof(struct bdf_dlg_font));
    bd.cur = &bd.fonts[0];
    for ( bdf = sf->bitmaps, i=0; bdf!=NULL; bdf=bdf->next, ++i ) {
	bd.fonts[i].bdf = bdf;
	bd.fonts[i].old_prop_cnt = bdf->prop_cnt;
	bd.fonts[i].old_props = BdfPropsCopy(bdf->props,bdf->prop_cnt);
	bd.fonts[i].sel_prop = -1;
	bdf->prop_max = bdf->prop_cnt;
	if ( bdf==thisone )
	    bd.cur = &bd.fonts[i];
    }

    ti = gcalloc((i+1),sizeof(GTextInfo));
    for ( bdf = sf->bitmaps, i=0; bdf!=NULL; bdf=bdf->next, ++i ) {
	if ( bdf->clut==NULL )
	    sprintf( buffer, "%d", bdf->pixelsize );
	else
	    sprintf( buffer, "%d@%d", bdf->pixelsize, BDFDepth(bdf));
	ti[i].text = (unichar_t *) copy(buffer);
	ti[i].text_is_1byte = true;
    }
    ti[bd.cur-bd.fonts].selected = true;

    memset(&wattrs,0,sizeof(wattrs));
    wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
    wattrs.event_masks = ~(1<<et_charup);
    wattrs.is_dlg = true;
    wattrs.restrict_input_to_me = 1;
    wattrs.undercursor = 1;
    wattrs.cursor = ct_pointer;
    snprintf(title,sizeof(title),_("Strike Information for %.90s"),
	    sf->fontname);
    wattrs.utf8_window_title = title;
    pos.x = pos.y = 0;
    pos.width = GDrawPointsToPixels(NULL,GGadgetScale(268));
    pos.height = GDrawPointsToPixels(NULL,375);
    bd.gw = gw = GDrawCreateTopWindow(NULL,&pos,bdfp_e_h,&bd,&wattrs);

    sbwidth = GDrawPointsToPixels(bd.gw,_GScrollBar_Width);
    subpos.x = 0; subpos.y =  GDrawPointsToPixels(NULL,28);
    subpos.width = pos.width-sbwidth;
    subpos.height = pos.height - subpos.y - GDrawPointsToPixels(NULL,70);
    wattrs.mask = wam_events;
    bd.v = GWidgetCreateSubWindow(gw,&subpos,bdfpv_e_h,&bd,&wattrs);
    bd.vwidth = subpos.width; bd.vheight = subpos.height;
    bd.width = pos.width; bd.height = pos.height;
    bd.value_x = GDrawPointsToPixels(bd.gw,135);

    if ( font==NULL ) {
	memset(&rq,0,sizeof(rq));
	rq.family_name = sans;
	rq.point_size = 10;
	rq.weight = 400;
	font = GDrawInstanciateFont(GDrawGetDisplayOfWindow(gw),&rq);
	font = GResourceFindFont("BDFProperties.Font",font);
    }
    bd.font = font;
    {
	int as, ds, ld;
	GDrawFontMetrics(bd.font,&as,&ds,&ld);
	bd.as = as; bd.fh = as+ds;
    }

    memset(gcd,0,sizeof(gcd));
    memset(label,0,sizeof(label));

    i=0;
    gcd[i].gd.pos.x = 10; gcd[i].gd.pos.y = 3;
    gcd[i].gd.flags = gg_visible | gg_enabled;
    gcd[i].gd.u.list = ti;
    gcd[i].gd.handle_controlevent = BdfP_ChangeBDF;
    gcd[i++].creator = GListButtonCreate;

    gcd[i].gd.pos.x = bd.vwidth; gcd[i].gd.pos.y = subpos.y-1;
    gcd[i].gd.pos.width = sbwidth; gcd[i].gd.pos.height = subpos.height+2;
    gcd[i].gd.flags = gg_visible | gg_enabled | gg_sb_vert | gg_pos_in_pixels;
    gcd[i].gd.handle_controlevent = _BdfP_VScroll;
    gcd[i++].creator = GScrollBarCreate;

    label[i].text = (unichar_t *) _("Delete");
    label[i].text_is_1byte = true;
    gcd[i].gd.label = &label[i];
    gcd[i].gd.pos.x = 4; gcd[i].gd.pos.y = GDrawPixelsToPoints(gw,subpos.y+subpos.height)+6;
    gcd[i].gd.flags = gg_visible | gg_enabled ;
    gcd[i].gd.handle_controlevent = BdfP_DeleteCurrent;
    gcd[i].gd.cid = CID_Delete;
    gcd[i++].creator = GButtonCreate;

    label[i].text = (unichar_t *) _("Default All");
    label[i].text_is_1byte = true;
    gcd[i].gd.label = &label[i];
    gcd[i].gd.pos.x = 80; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y;
    gcd[i].gd.flags = gg_visible | gg_enabled ;
    gcd[i].gd.handle_controlevent = BdfP_DefaultAll;
    gcd[i].gd.cid = CID_DefAll;
    gcd[i++].creator = GButtonCreate;

    label[i].text = (unichar_t *) _("Default This");
    label[i].text_is_1byte = true;
    gcd[i].gd.label = &label[i];
    gcd[i].gd.pos.y = gcd[i-1].gd.pos.y;
    gcd[i].gd.flags = gg_visible | gg_enabled ;
    gcd[i].gd.handle_controlevent = BdfP_DefaultCurrent;
    gcd[i].gd.cid = CID_DefCur;
    gcd[i++].creator = GButtonCreate;

/* I want the 2 pronged arrow, but gdraw can't find a nice one */
/*  label[i].text = (unichar_t *) "⇑";	*//* Up Arrow */
    label[i].text = (unichar_t *) "↑";	/* Up Arrow */
    label[i].text_is_1byte = true;
    gcd[i].gd.label = &label[i];
    gcd[i].gd.pos.y = gcd[i-1].gd.pos.y;
    gcd[i].gd.flags = gg_visible | gg_enabled ;
    gcd[i].gd.handle_controlevent = BdfP_Up;
    gcd[i].gd.cid = CID_Up;
    gcd[i++].creator = GButtonCreate;

/* I want the 2 pronged arrow, but gdraw can't find a nice one */
/*  label[i].text = (unichar_t *) "⇓";	*//* Down Arrow */
    label[i].text = (unichar_t *) "↓";	/* Down Arrow */
    label[i].text_is_1byte = true;
    gcd[i].gd.label = &label[i];
    gcd[i].gd.pos.y = gcd[i-1].gd.pos.y;
    gcd[i].gd.flags = gg_visible | gg_enabled ;
    gcd[i].gd.handle_controlevent = BdfP_Down;
    gcd[i].gd.cid = CID_Down;
    gcd[i++].creator = GButtonCreate;


    gcd[i].gd.pos.x = 30-3; gcd[i].gd.pos.y = GDrawPixelsToPoints(NULL,pos.height)-32-3;
    gcd[i].gd.pos.width = -1; gcd[i].gd.pos.height = 0;
    gcd[i].gd.flags = gg_visible | gg_enabled | gg_but_default;
    label[i].text = (unichar_t *) _("_OK");
    label[i].text_is_1byte = true;
    label[i].text_in_resource = true;
    gcd[i].gd.label = &label[i];
    gcd[i].gd.handle_controlevent = BdfP_OK;
    gcd[i].gd.cid = CID_OK;
    gcd[i++].creator = GButtonCreate;

    gcd[i].gd.pos.x = -30; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y+3;
    gcd[i].gd.pos.width = -1; gcd[i].gd.pos.height = 0;
    gcd[i].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
    label[i].text = (unichar_t *) _("_Cancel");
    label[i].text_is_1byte = true;
    label[i].text_in_resource = true;
    gcd[i].gd.label = &label[i];
    gcd[i].gd.handle_controlevent = BdfP_Cancel;
    gcd[i].gd.cid = CID_Cancel;
    gcd[i++].creator = GButtonCreate;
    
    GGadgetsCreate(gw,gcd);
    GTextInfoListFree(gcd[0].gd.u.list);
    bd.vsb = gcd[1].ret;

    small.main_background = small.main_foreground = COLOR_DEFAULT;
    small.main_foreground = 0x0000ff;
    memset(&gd,'\0',sizeof(gd));
    memset(&label[0],'\0',sizeof(label[0]));

    label[0].text = (unichar_t *) "\0\0\0\0";
    label[0].font = bd.font;
    gd.pos.height = bd.fh;
    gd.pos.width = bd.vwidth-bd.value_x;
    gd.label = &label[0];
    gd.box = &small;
    gd.flags = gg_enabled | gg_pos_in_pixels | gg_dontcopybox | gg_text_xim;
    bd.tf = GTextFieldCreate(bd.v,&gd,&bd);

    bd.press_pos = -1;
    BdfP_EnableButtons(&bd);
    BdfP_RefigureScrollbar(&bd);
    
    GDrawSetVisible(bd.v,true);
    GDrawSetVisible(gw,true);
    while ( !bd.done )
	GDrawProcessOneEvent(NULL);
    GDrawDestroyWindow(gw);
}
Esempio n. 7
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 );
}
Esempio n. 8
0
static int _GWidget_TopLevel_eh(GWindow gw, GEvent *event) {
    GTopLevelD *td;
    int ret;

    if ( !GDrawNativeWindowExists(NULL,event->native_window) )
return( true );

    td = (GTopLevelD *) (gw->widget_data);
    if ( td==NULL )		/* Dying */
return( true );

    GGadgetPopupExternalEvent(event);
    if ( event->type==et_focus ) {
	
	if ( event->u.focus.gained_focus ) {
	    if ( gw->is_toplevel && !gw->is_popup && !gw->is_dying ) {
		if ( last_input_window!=gw )
		    previous_focus_window = last_input_window;
		current_focus_window = gw;
	    }
	} else if ( current_focus_window==gw ) {
	    current_focus_window = NULL;
	}
	if ( !td->ispalette && gw->is_visible && event->u.focus.gained_focus && !gw->is_dying ) {
	    GWindow dlg = GDrawGetRedirectWindow(NULL);
	    if ( dlg==NULL || dlg==gw ) {
		/* If top level window loses the focus all its palettes go invisible */
		/* if it gains focus then all palettes that are supposed to be vis */
		/*  become visible */
		/* But not if we've got an active dialog */
		GTopLevelD *palette;
		if ( last_paletted_focus_window!=NULL && !last_paletted_focus_window->is_dying ) {
		    GTopLevelD *lpfw_td = (GTopLevelD *) (last_paletted_focus_window->widget_data);
		    for ( palette=lpfw_td->palettes; palette!=NULL; palette = palette->nextp ) {
			if ( !palette->w->is_visible && palette->w->visible_request ) {
			    GDrawSetVisible(palette->w,false);
			    palette->w->visible_request = true;
			}
		    }
		}
		for ( palette=td->palettes; palette!=NULL; palette = palette->nextp ) {
		    if ( !palette->w->is_visible && palette->w->visible_request )
			GDrawSetVisible(palette->w,true);
		}
		last_paletted_focus_window = gw;
	    }
	}
	if ( !gw->is_dying && td->gfocus!=NULL && td->gfocus->funcs->handle_focus!=NULL ) {
 { oldtd = td; oldgfocus = td->gfocus; }	/* Debug!!!! */
	    (td->gfocus->funcs->handle_focus)(td->gfocus,event);
	} else if ( !gw->is_dying && td->wfocus!=NULL ) {
	    if ( td->wfocus->widget_data!=NULL ) {
		if ( td->wfocus->widget_data->e_h!=NULL )
		    (td->wfocus->widget_data->e_h)(td->wfocus,event);
	    } else if ( td->wfocus->eh!=NULL )
		(td->wfocus->eh)(td->wfocus,event);
	}
	if ( !gw->is_dying && td->e_h!=NULL )
	    (td->e_h)(gw,event);
return( true );
    } else if ( !gw->is_dying && event->type == et_crossing ) {
	GiveToAll((GContainerD *) td,event);
return( true );
    } else if ( event->type == et_char || event->type == et_charup ) {
return( _GWidget_TopLevel_Key(gw,gw,event));
    } else if ( !gw->is_dying && event->type == et_resize ) {
	GRect r;
	if ( td->gmenubar!=NULL ) {
	    GGadgetGetSize(td->gmenubar,&r);
	    GGadgetResize(td->gmenubar,event->u.resize.size.width,r.height);
	    GGadgetRedraw(td->gmenubar);
	} /* status line, toolbar, etc. */
	if ( td->palettes!=NULL && event->u.resize.moved ) {
	    GTopLevelD *palette;
	    for ( palette=td->palettes; palette!=NULL; palette = palette->nextp ) {
		if ( !broken_palettes || !palette->positioned_yet ) {
		    int x = gw->pos.x + palette->owner_off_x,
			y = gw->pos.y + palette->owner_off_y;
		    if ( x<0 ) x=0;
		    if ( y<0 ) y=0;
		    if ( x+palette->w->pos.width>GDrawGetRoot(NULL)->pos.width )
			x = GDrawGetRoot(NULL)->pos.width-palette->w->pos.width;
		    if ( y+palette->w->pos.height>GDrawGetRoot(NULL)->pos.height )
			y = GDrawGetRoot(NULL)->pos.height-palette->w->pos.height;
		    ++palette->programmove;
		    if ( gw->is_visible )
			GDrawTrueMove(palette->w, x, y);
		    else
			GDrawMove(palette->w, x, y);
		    palette->positioned_yet = true;
		}
	    }
	}
	if ( td->ispalette ) {
	    if ( td->programmove>0 )
		--td->programmove;
	    else {
		td->owner_off_x = gw->pos.x - td->owner->w->pos.x;
		td->owner_off_y = gw->pos.y - td->owner->w->pos.y;
	    }
	}
    } else if ( event->type == et_close && td->ispalette ) {
	GDrawSetVisible(gw,false);
return( true );
    } else if ( !gw->is_dying && event->type == et_visibility ) {
	if ( broken_palettes )
	    /* Do Nothing */;
	else if ( td->ispalette && event->u.visibility.state!=vs_unobscured ) {
	    if ( !GDrawIsAbove(gw,td->owner->w))
		GDrawRaiseAbove(gw,td->owner->w);
	}
    } else if ( !gw->is_dying && event->type == et_map && !td->ispalette ) {
	/* If top level window goes invisible all its palettes follow */
	/* if it goes visible then all palettes that are supposed to be vis */
	/*  follow */
	ManagePalettesVis(td, event->u.map.is_visible );
    }
    if ( event->type == et_destroy ) {
	if ( td->palettes!=NULL ) {
	    struct gtopleveldata *palettes, *next;
	    for ( palettes=td->palettes; palettes!=NULL; palettes = next ) {
		next = palettes->nextp;
		GDrawDestroyWindow(palettes->w);
	    }
	    /* Palettes must die before our widget data are freed */
	    GDrawSync(GDrawGetDisplayOfWindow(gw));
	    GDrawProcessPendingEvents(GDrawGetDisplayOfWindow(gw));
	}
    }
    ret = _GWidget_Container_eh(gw,event);
    if ( event->type == et_destroy ) {
	if ( gw==current_focus_window )
	    current_focus_window = NULL;
	if ( gw==previous_focus_window )
	    previous_focus_window = NULL;
	if ( gw==last_input_window )
	    last_input_window = NULL;
	if ( gw==last_paletted_focus_window )
	    last_paletted_focus_window = NULL;
	ret = true;
    }
return( ret );
}
Esempio n. 9
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 );
}
Esempio n. 10
0
static int glist_mouse(GGadget *g, GEvent *event) {
    GDList *gl = (GDList *) g;
    int pos;

    if ( !g->takes_input || (g->state!=gs_active && g->state!=gs_enabled && g->state!=gs_focused))
return( false );

    if ( event->type == et_crossing )
return( false );
    if (( event->type==et_mouseup || event->type==et_mousedown ) &&
	    (event->u.mouse.button>=4 && event->u.mouse.button<=7)) {
	if ( gl->vsb!=NULL )
return( GGadgetDispatchEvent(&gl->vsb->g,event));
	else
return( true );
    }
    if ( event->type==et_mousemove && !gl->pressed && !gl->parentpressed ) {
	if ( GGadgetWithin(g,event->u.mouse.x,event->u.mouse.y) ) {
	    if ( gl->popup_callback!=NULL )
		(gl->popup_callback)(g,GListIndexFromPos(gl,event->u.mouse.y));
	    else if ( g->popup_msg )
		GGadgetPreparePopup(g->base,g->popup_msg);
	}
return( true );
    } else if ( event->type==et_mouseup && gl->parentpressed /* &&
	    !GGadgetInnerWithin(&gl->g,event->u.mouse.x,event->u.mouse.y)*/ ) {
	gl->parentpressed = false;
	GDrawPointerUngrab(GDrawGetDisplayOfWindow(gl->g.base));
    } else if ( event->type==et_mousemove && gl->parentpressed &&
	    GGadgetInnerWithin(&gl->g,event->u.mouse.x,event->u.mouse.y)) {
	if ( gl->pressed == NULL )
	    gl->pressed = GDrawRequestTimer(g->base,GListScrollTime,GListScrollTime,NULL);
	GDrawPointerUngrab(GDrawGetDisplayOfWindow(gl->g.base));
	gl->parentpressed = false;
	glist_scroll_selbymouse(gl,event);
return( true );
    } else if ( event->type==et_mousemove && gl->pressed ) {
	glist_scroll_selbymouse(gl,event);
return( true );
    } else if ( event->type==et_mousedown ) {
	if ( gl->pressed == NULL )
	    gl->pressed = GDrawRequestTimer(g->base,GListScrollTime,GListScrollTime,NULL);
	pos = GListIndexFromPos(gl,event->u.mouse.y);
	if ( pos==-1 )
return( true ); /* Do Nothing, nothing selectable */
	else if ( !gl->exactly_one && gl->ti[pos]->selected &&
		(event->u.mouse.state&(ksm_control|ksm_shift))) {
	    gl->ti[pos]->selected = false;
	    gl->start = gl->end = 0xffff;
	} else if ( !gl->multiple_sel ||
		(!gl->ti[pos]->selected && !(event->u.mouse.state&(ksm_control|ksm_shift)))) {
	    GListClearSel(gl);
	    gl->ti[pos]->selected = true;
	    gl->start = gl->end = pos;
	} else if ( event->u.mouse.state&ksm_control ||
		((event->u.mouse.state&ksm_shift) && gl->ti[pos]->selected)) {
	    gl->ti[pos]->selected = !gl->ti[pos]->selected;
	    gl->start = gl->end = pos;
	} else if ( event->u.mouse.state&ksm_shift ) {
	    GListExpandSelection(gl,pos);
	} else {
	    gl->ti[pos]->selected = true;
	    gl->start = gl->end = pos;
	}
	_ggadget_redraw(&gl->g);
    } else if ( event->type==et_mouseup && gl->pressed ) {
	GDrawCancelTimer(gl->pressed); gl->pressed = NULL;
	if ( GGadgetInnerWithin(&gl->g,event->u.mouse.x,event->u.mouse.y) ) {
	    pos = GListIndexFromPos(gl,event->u.mouse.y);
	    if ( !(event->u.mouse.state&(ksm_control|ksm_shift)) || gl->start!=0xffff )
		glist_scroll_selbymouse(gl,event);
	    if ( event->u.mouse.clicks==2 )
		GListDoubleClick(gl,true,pos);
	    else
		GListSelected(gl,true,pos);
	}
    } else
return( false );

return( true );
}
Esempio n. 11
0
void SFShowKernPairs(SplineFont *sf,SplineChar *sc,AnchorClass *ac,int layer) {
    KPData kpd;
    GRect pos;
    GWindow gw;
    GWindowAttrs wattrs;
    GGadgetCreateData gcd[9], boxes[6], *hvarray[3][3], *harray[3], *barray[10], *varray[5];
    GTextInfo label[9];
    FontRequest rq;
    int as, ds, ld,i;
    static int done=false;
    static GFont *font=NULL;

    memset(&kpd,0,sizeof(kpd));
    kpd.sf = sf;
    kpd.sc = sc;
    kpd.ac = ac;
    kpd.layer = layer;
    kpd.first = true;
    kpd.last_index = kpd.selected = -1;
    if ( ac==NULL )
	KPBuildKernList(&kpd);
    else
	KPBuildAnchorList(&kpd);
    if ( kpd.kcnt==0 )
return;

    memset(&wattrs,0,sizeof(wattrs));
    wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
    wattrs.event_masks = ~(1<<et_charup);
    wattrs.restrict_input_to_me = 1;
    wattrs.undercursor = 1;
    wattrs.cursor = ct_pointer;
    wattrs.utf8_window_title = ac==NULL?_("Kern Pairs"):_("Anchored Pairs");
    wattrs.is_dlg = true;
    pos.x = pos.y = 0;
    pos.width = GGadgetScale(200);
    pos.height = GDrawPointsToPixels(NULL,500);
    kpd.gw = gw = GDrawCreateTopWindow(NULL,&pos,kpd_e_h,&kpd,&wattrs);

    memset(&label,0,sizeof(label));
    memset(&gcd,0,sizeof(gcd));
    memset(&boxes,0,sizeof(boxes));

    label[0].text = (unichar_t *) _("_Size:");
    label[0].text_is_1byte = true;
    label[0].text_in_resource = true;
    gcd[0].gd.label = &label[0];
    gcd[0].gd.pos.x = 5; gcd[0].gd.pos.y = 5+6; 
    gcd[0].gd.flags = gg_enabled|gg_visible;
    gcd[0].creator = GLabelCreate;
    hvarray[0][0] = &gcd[0];

    gcd[1].gd.label = &sizes[1];  gcd[1].gd.label->selected = true;
    gcd[1].gd.pos.x = 50; gcd[1].gd.pos.y = 5;
    gcd[1].gd.flags = gg_enabled|gg_visible;
    gcd[1].gd.cid = CID_Size;
    gcd[1].gd.u.list = sizes;
    gcd[1].gd.handle_controlevent = KP_ChangeSize;
    gcd[1].creator = GListButtonCreate;
    hvarray[0][1] = &gcd[1]; hvarray[0][2] = NULL;

    label[2].text = (unichar_t *) _("Sort By:");
    label[2].text_is_1byte = true;
    gcd[2].gd.label = &label[2];
    gcd[2].gd.pos.x = gcd[0].gd.pos.x; gcd[2].gd.pos.y = gcd[0].gd.pos.y+25; 
    gcd[2].gd.flags = gg_enabled|gg_visible;
    gcd[2].creator = GLabelCreate;
    hvarray[1][0] = &gcd[2];

    if ( !done ) {
	done = true;
	for ( i=0; sortby[i].text!=NULL; ++i )
	    sortby[i].text = (unichar_t *) _((char *) sortby[i].text);
    }

    gcd[3].gd.label = &sortby[0]; gcd[3].gd.label->selected = true;
    gcd[3].gd.pos.x = 50; gcd[3].gd.pos.y = gcd[1].gd.pos.y+25;
    gcd[3].gd.flags = gg_enabled|gg_visible;
    gcd[3].gd.cid = CID_SortBy;
    gcd[3].gd.u.list = sortby;
    gcd[3].gd.handle_controlevent = KP_ChangeSort;
    gcd[3].creator = GListButtonCreate;
    hvarray[1][1] = &gcd[3]; hvarray[1][2] = NULL; hvarray[2][0] = NULL;

    boxes[2].gd.flags = gg_enabled|gg_visible;
    boxes[2].gd.u.boxelements = hvarray[0];
    boxes[2].creator = GHVBoxCreate;
    varray[0] = &boxes[2];

    gcd[4].gd.pos.width = 40;
    gcd[4].gd.pos.height = 250;
    gcd[4].gd.flags = gg_visible | gg_enabled;
    gcd[4].gd.u.drawable_e_h = kpdv_e_h;
    gcd[4].creator = GDrawableCreate;

    gcd[5].gd.flags = gg_enabled|gg_visible|gg_sb_vert;
    gcd[5].gd.cid = CID_ScrollBar;
    gcd[5].gd.handle_controlevent = KP_Scrolled;
    gcd[5].creator = GScrollBarCreate;
    harray[0] = &gcd[4]; harray[1] = &gcd[5]; harray[2] = NULL;

    boxes[3].gd.flags = gg_enabled|gg_visible;
    boxes[3].gd.u.boxelements = harray;
    boxes[3].creator = GHBoxCreate;
    varray[1] = &boxes[3];

    gcd[6].gd.pos.x = 20-3; gcd[6].gd.pos.y = 17+37;
    gcd[6].gd.pos.width = -1; gcd[6].gd.pos.height = 0;
    gcd[6].gd.flags = gg_visible | gg_enabled | gg_but_default;
    label[6].text = (unichar_t *) _("_OK");
    label[6].text_is_1byte = true;
    label[6].text_in_resource = true;
    gcd[6].gd.label = &label[6];
    gcd[6].gd.cid = CID_OK;
    gcd[6].gd.handle_controlevent = KP_OK;
    gcd[6].creator = GButtonCreate;

    gcd[7].gd.pos.x = -20; gcd[7].gd.pos.y = gcd[6].gd.pos.y+3;
    gcd[7].gd.pos.width = -1; gcd[7].gd.pos.height = 0;
    gcd[7].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
    label[7].text = (unichar_t *) _("_Cancel");
    label[7].text_is_1byte = true;
    label[7].text_in_resource = true;
    gcd[7].gd.label = &label[7];
    gcd[7].gd.cid = CID_Cancel;
    gcd[7].gd.handle_controlevent = KP_Cancel;
    gcd[7].creator = GButtonCreate;
    barray[0] = GCD_Glue; barray[1] = &gcd[6]; barray[2] = GCD_Glue;
    barray[3] = GCD_Glue; barray[4] = &gcd[7]; barray[5] = GCD_Glue; barray[6] = NULL;

    boxes[4].gd.flags = gg_enabled|gg_visible;
    boxes[4].gd.u.boxelements = barray;
    boxes[4].creator = GHBoxCreate;
    varray[2] = &boxes[4];
    varray[3] = NULL;

    boxes[0].gd.flags = gg_enabled|gg_visible;
    boxes[0].gd.u.boxelements = varray;
    boxes[0].creator = GVBoxCreate;


    GGadgetsCreate(gw,boxes);

    GHVBoxSetExpandableRow(boxes[0].ret,1);
    GHVBoxSetExpandableCol(boxes[3].ret,0);
    GHVBoxSetExpandableCol(boxes[4].ret,gb_expandgluesame);
    GHVBoxSetPadding(boxes[0].ret,0,2);
    GHVBoxSetPadding(boxes[3].ret,0,0);
    kpd.v = GDrawableGetWindow(gcd[4].ret);;

    GGadgetGetSize(gcd[4].ret,&pos);
    kpd.sb_width = pos.width;
    GGadgetGetSize(gcd[3].ret,&pos);
    kpd.header_height = pos.y+pos.height+4;

    kpd.bdf = SplineFontPieceMeal(kpd.sf,kpd.layer,(intpt) (gcd[1].gd.label->userdata),72,true,NULL);

    if ( font==NULL ) {
	memset(&rq,'\0',sizeof(rq));
	rq.utf8_family_name = SANS_UI_FAMILIES;
	rq.point_size = -12;
	rq.weight = 400;
	font = GDrawInstanciateFont(GDrawGetDisplayOfWindow(gw),&rq);
	font = GResourceFindFont("Combinations.Font",font);
    }
    kpd.font = font;
    GDrawFontMetrics(kpd.font,&as,&ds,&ld);
    kpd.fh = as+ds; kpd.as = as;

    kpd.uh = (4*kpd.bdf->pixelsize/3)+kpd.fh+6;
    kpd.vpad = kpd.bdf->pixelsize/5 + 3;

    GHVBoxFitWindow(boxes[0].ret);

    GDrawSetVisible(kpd.v,true);
    GDrawSetVisible(kpd.gw,true);
    while ( !kpd.done )
	GDrawProcessOneEvent(NULL);
    free( kpd.kerns );
    GDrawDestroyWindow(gw);
}
Esempio n. 12
0
static void draw_arrow(GWindow pixmap, GScrollBar *gsb, int which) {
    GPoint pts[5];
    int point = GDrawPointsToPixels(gsb->g.base,1);
    int cnt = 4;
    Color fill = gsb->thumbbox->main_foreground;

    if ( fill == COLOR_DEFAULT )
	fill = GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap));

    switch ( which ) {
      case 0:		/* Horizontal left arrow */
	pts[0].y = (gsb->g.r.y+(gsb->g.r.height-1)/2);
		pts[0].x = gsb->g.r.x + 2*point;
	pts[1].y = gsb->g.r.y + point;
		pts[1].x = pts[0].x + (gsb->g.r.height-1)/2-point ;
	pts[2].y = gsb->g.r.y+gsb->g.r.height-1 - point;
		pts[2].x = pts[1].x;
	pts[3] = pts[0];
	if ( !(gsb->g.inner.height&1 )) {
	    ++pts[3].y;
	    pts[4] = pts[0];
	    cnt = 5;
	}
	GDrawFillPoly(pixmap,pts,cnt,fill);
	GDrawDrawLine(pixmap,pts[0].x,pts[0].y,pts[1].x,pts[1].y,
		gsb->thumbbox->border_brightest);
	GDrawDrawLine(pixmap,pts[2].x,pts[2].y,pts[3].x,pts[3].y,
		gsb->thumbbox->border_darker);
	GDrawDrawLine(pixmap,pts[1].x,pts[1].y,pts[2].x,pts[2].y,
		gsb->thumbbox->border_darkest);
      break;
      case 1:		/* Vertical up arrow */
	pts[0].x = (gsb->g.r.x+(gsb->g.r.width-1)/2);
		pts[0].y = gsb->g.r.y + 2*point;
	pts[1].x = gsb->g.r.x + point;
		pts[1].y = pts[0].y + (gsb->g.r.width-1)/2-point ;
	pts[2].x = gsb->g.r.x+gsb->g.r.width-1 - point;
		pts[2].y = pts[1].y;
	pts[3] = pts[0];
	if ( !(gsb->g.inner.width&1 )) {
	    ++pts[3].x;
	    pts[4] = pts[0];
	    cnt = 5;
	}
	GDrawFillPoly(pixmap,pts,cnt,fill);
	GDrawDrawLine(pixmap,pts[0].x,pts[0].y,pts[1].x,pts[1].y,
		gsb->thumbbox->border_brightest);
	GDrawDrawLine(pixmap,pts[2].x,pts[2].y,pts[3].x,pts[3].y,
		gsb->thumbbox->border_darker);
	GDrawDrawLine(pixmap,pts[1].x,pts[1].y,pts[2].x,pts[2].y,
		gsb->thumbbox->border_darkest);
      break;
      case 2:		/* Horizontal right arrow */
	pts[0].y = (gsb->g.r.y+(gsb->g.r.height-1)/2);
		pts[0].x = gsb->g.r.x + gsb->g.r.width-1 - 2*point;
	pts[1].y = gsb->g.r.y + point;
		pts[1].x = pts[0].x - ((gsb->g.r.height-1)/2-point);
	pts[2].y = gsb->g.r.y+gsb->g.r.height-1 - point;
		pts[2].x = pts[1].x;
	pts[3] = pts[0];
	if ( !(gsb->g.inner.height&1 )) {
	    ++pts[3].y;
	    pts[4] = pts[0];
	    cnt = 5;
	}
	GDrawFillPoly(pixmap,pts,cnt,fill);
	GDrawDrawLine(pixmap,pts[0].x,pts[0].y,pts[1].x,pts[1].y,
		gsb->thumbbox->border_darkest);
	GDrawDrawLine(pixmap,pts[2].x,pts[2].y,pts[3].x,pts[3].y,
		gsb->thumbbox->border_darker);
	GDrawDrawLine(pixmap,pts[1].x,pts[1].y,pts[2].x,pts[2].y,
		gsb->thumbbox->border_brightest);
      break;
      case 3:		/* Vertical down arrow */
	pts[0].x = (gsb->g.r.x+(gsb->g.r.width-1)/2);
		pts[0].y = gsb->g.r.y + gsb->g.r.height-1 - 2*point;
	pts[1].x = gsb->g.r.x + point;
		pts[1].y = pts[0].y - ((gsb->g.r.width-1)/2-point);
	pts[2].x = gsb->g.r.x+gsb->g.r.width-1 - point;
		pts[2].y = pts[1].y;
	pts[3] = pts[0];
	if ( !(gsb->g.inner.width&1 )) {
	    ++pts[3].x;
	    pts[4] = pts[0];
	    cnt = 5;
	}
	GDrawFillPoly(pixmap,pts,cnt,fill);
	GDrawDrawLine(pixmap,pts[0].x,pts[0].y,pts[1].x,pts[1].y,
		gsb->thumbbox->border_darkest);
	GDrawDrawLine(pixmap,pts[2].x,pts[2].y,pts[3].x,pts[3].y,
		gsb->thumbbox->border_darker);
	GDrawDrawLine(pixmap,pts[1].x,pts[1].y,pts[2].x,pts[2].y,
		gsb->thumbbox->border_brightest);
      break;
    }
}
Esempio n. 13
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 );
}
Esempio n. 14
0
static void CpInfoPlace(CharView *cv, GEvent *event) {
    char buf[100];
    int line, which;
    int width, x, y;
    GRect size;
    GPoint pt, pt2;
    int h,w;
    GWindowAttrs wattrs;
    GRect pos;
    FontRequest rq;
    int as, ds, ld;
    SplinePoint *sp;

    if ( cv->ruler_w==NULL ) {
	memset(&wattrs,0,sizeof(wattrs));
	wattrs.mask = wam_events|wam_cursor|wam_positioned|wam_nodecor|wam_backcol|wam_bordwidth;
	wattrs.event_masks = (1<<et_expose)|(1<<et_resize)|(1<<et_mousedown);
	wattrs.cursor = ct_mypointer;
	wattrs.background_color = 0xe0e0c0;
	wattrs.nodecoration = 1;
	wattrs.border_width = 1;
	pos.x = pos.y = 0; pos.width=pos.height = 20;
	cv->ruler_w = GWidgetCreateTopWindow(NULL,&pos,cpinfo_e_h,cv,&wattrs);

	if ( rvfont==NULL ) {
	    memset(&rq,0,sizeof(rq));
	    rq.utf8_family_name = FIXED_UI_FAMILIES;
	    rq.point_size = -12;
	    rq.weight = 400;
	    rvfont = GDrawInstanciateFont(GDrawGetDisplayOfWindow(cv->ruler_w),&rq);
	    rvfont = GResourceFindFont("CharView.Measure.Font",rvfont);
	}
	cv->rfont = rvfont;
	GDrawFontMetrics(cv->rfont,&as,&ds,&ld);
	cv->rfh = as+ds; cv->ras = as;
    } else
	GDrawRaise(cv->ruler_w);

    GDrawSetFont(cv->ruler_w,cv->rfont);
    h = 0; width = 0;
    for ( which = 0; which<2; ++which ) {
	for ( line=0; PtInfoText(cv,line,which,buf,sizeof(buf))!=NULL; ++line ) {
	    w = GDrawGetBiText8Width(cv->ruler_w,buf,-1,-1,NULL);
	    if ( w>width ) width = w;
	    h += cv->rfh+1;
	}
	h += 4;
    }
    if ( PtInfoText(cv,0,-1,buf,sizeof(buf))!=NULL ) {
	w = GDrawGetBiText8Width(cv->ruler_w,buf,-1,-1,NULL);
	if ( w>width ) width = w;
	h += cv->rfh+1;
    }
    
    GDrawGetSize(GDrawGetRoot(NULL),&size);
    pt.x = event->u.mouse.x; pt.y = event->u.mouse.y;	/* Address of cp */
    GDrawTranslateCoordinates(cv->v,GDrawGetRoot(NULL),&pt);

    sp = cv->p.sp;
    if ( !cv->p.prevcp && !cv->p.nextcp )
	sp = cv->active_sp;
    if ( sp!=NULL ) {
	x =  cv->xoff + rint(sp->me.x*cv->scale);
	y = -cv->yoff + cv->height - rint(sp->me.y*cv->scale);
	if ( x>=0 && y>=0 && x<cv->width && y<cv->height ) {
	    pt2.x = x; pt2.y = y;
	    GDrawTranslateCoordinates(cv->v,GDrawGetRoot(NULL),&pt2);
	} else
	    sp = NULL;
    }

    x = pt.x + infowindowdistance;
    y = pt.y - cv->ras-2;
    if ( sp!=NULL && x<=pt2.x-4 && x+width>=pt2.x+4 && y<=pt2.y-4 && y+h>=pt2.y+4 )
	x = pt2.x + 4;
    if ( x+width > size.width ) {
	x = pt.x - width-30;
	if ( sp!=NULL && x<=pt2.x-4 && x+width>=pt2.x+4 && y<=pt2.y-4 && y+h>=pt2.y+4 )
	    x = pt2.x - width - 4;
	if ( x<0 ) {
	    x = pt.x + 10;
	    y = pt.y - h - infowindowdistance;
	    if ( sp!=NULL && x<=pt2.x-4 && x+width>=pt2.x+4 && y<=pt2.y-4 && y+h>=pt2.y+4 )
		y = pt2.y - h - 4;
	    if ( y<0 )
		y = pt.y+infowindowdistance;	/* If this doesn't work we have nowhere else to */
				/* try so don't check */
	}
    }
    if ( y+h > size.height )
	y = pt.y - h - cv->ras - 10;
    GDrawMoveResize(cv->ruler_w,x,y,width+4,h+4);
}