static void CreateErrorWindow(void) { GWindowAttrs wattrs; FontRequest rq; GRect pos,size; int as, ds, ld; GWindow gw; GGadgetData gd; extern int _GScrollBar_Width; GDrawGetSize(GDrawGetRoot(NULL),&size); memset(&wattrs,0,sizeof(wattrs)); wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_isdlg|wam_positioned; wattrs.event_masks = ~(1<<et_charup); wattrs.is_dlg = true; wattrs.cursor = ct_pointer; wattrs.positioned = true; wattrs.utf8_window_title = _("Warnings"); pos.width = GDrawPointsToPixels(NULL,GGadgetScale(400)); pos.height = GDrawPointsToPixels(NULL,GGadgetScale(100)); pos.x = size.width - pos.width - 10; pos.y = size.height - pos.height - 30; errdata.gw = gw = GDrawCreateTopWindow(NULL,&pos,warnings_e_h,&errdata,&wattrs); memset(&rq,0,sizeof(rq)); rq.utf8_family_name = SANS_UI_FAMILIES; rq.point_size = 10; rq.weight = 400; errdata.font = GDrawInstanciateFont(NULL,&rq); errdata.font = GResourceFindFont("Warnings.Font",errdata.font); GDrawWindowFontMetrics(errdata.gw,errdata.font,&as,&ds,&ld); errdata.as = as; errdata.fh = as+ds; memset(&gd,0,sizeof(gd)); gd.pos.y = 0; gd.pos.height = pos.height; gd.pos.width = GDrawPointsToPixels(gw,_GScrollBar_Width); gd.pos.x = pos.width-gd.pos.width; gd.flags = gg_visible|gg_enabled|gg_pos_in_pixels|gg_sb_vert; errdata.vsb = GScrollBarCreate(gw,&gd,&errdata); pos.width -= gd.pos.width; pos.x = pos.y = 0; wattrs.mask = wam_events|wam_cursor; errdata.v = GWidgetCreateSubWindow(gw,&pos,warningsv_e_h,&errdata,&wattrs); GDrawSetVisible(errdata.v,true); errdata.linecnt = pos.height/errdata.fh; errdata.start_l = errdata.end_l = -1; }
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); }