/* * editIcon.c * * Edit icon dialogue box * * © 1994-1998 Straylight */ /*----- Licensing note ----------------------------------------------------* * * This file is part of Straylight's Glass. * * Glass is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Glass is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Glass. If not, write to the Free Software Foundation, * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /*----- Header files ------------------------------------------------------*/ /* * ANSI standard headers */ #include #include #include /* * Steel headers */ #define _STDAPP #define _LOWLVL #include "steel/Steel.h" #include "steel/buttons.h" #include "steel/fontMenu.h" #include "steel/akbd.h" #include "steel/bbc.h" #include "steel/buffer.h" #include "steel/font.h" /* * Glass headers */ #include "gStruct.h" #include "gMenus.h" #include "gIcons.h" #include "glass.h" #include "tfile.h" #include "window.h" #include "intMsgs.h" #include "editIcon.h" #include "colSelect.h" #include "indir.h" #include "gPrefs.h" /*----- Static variables --------------------------------------------------*/ static char *editIcon__panels[]= { "iconData", "iconAppear", "iconActions", "iconColours", "iconPos", "iconSize", }; /*----- Support routines --------------------------------------------------*/ #define max2(a,b) ((a)>(b) ? (a) : (b)) #define min2(a,b) ((a)<(b) ? (a) : (b)) /* * void editIcon__setupPanel(glass_editIcon *ed) * * Use * Sets up a panel from the icon description given. * * Parameters * glass_editIcon *ed == the edit to handle. */ static void editIcon__setupPanel(glass_editIcon *ed) { char *p; switch (ed->e.panel) { case glass_EIDATA: dbox_setfield(ed->e.pd,glass_EIDVALSTRING,"%s",ed->valid); dbox_setfield(ed->e.pd,glass_EIDDATA,"%s",ed->data); if (!(ed->idef.flags&3)) { dbox_shadeicon(ed->e.pd,glass_EIDINDIR,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDDATA,TRUE); dbox_selecticon(ed->e.pd,glass_EIDINDIR,FALSE); dbox_selecticon(ed->e.pd,glass_EIDVALID,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDVALSTRING,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDVALID,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDSIZE,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDUP,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDDOWN,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDMINIMISE,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDPART,TRUE); dbox_setfield(ed->e.pd,glass_EIDINDSIZE,"%i",12); } else if (ed->idef.flags & wimp_INDIRECT) { dbox_shadeicon(ed->e.pd,glass_EIDINDIR,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDDATA,FALSE); dbox_selecticon(ed->e.pd,glass_EIDINDIR,TRUE); dbox_selecticon(ed->e.pd,glass_EIDVALID,ed->hasValid); dbox_shadeicon(ed->e.pd,glass_EIDVALSTRING,!ed->hasValid); dbox_shadeicon(ed->e.pd,glass_EIDVALID, !(ed->idef.flags&wimp_ITEXT)); dbox_shadeicon(ed->e.pd,glass_EIDINDSIZE,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDINDUP,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDINDDOWN,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDMINIMISE,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDINDPART,FALSE); dbox_setfield(ed->e.pd,glass_EIDINDSIZE,"%i",ed->indLen); } else { dbox_shadeicon(ed->e.pd,glass_EIDINDIR,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDDATA,FALSE); dbox_selecticon(ed->e.pd,glass_EIDINDIR,FALSE); dbox_selecticon(ed->e.pd,glass_EIDVALID,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDVALSTRING,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDVALID,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDSIZE,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDUP,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDDOWN,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDMINIMISE,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDPART,TRUE); dbox_setfield(ed->e.pd,glass_EIDINDSIZE,"%i",12); } dbox_selecticon(ed->e.pd,glass_EIDTEXT, !!(ed->idef.flags&wimp_ITEXT)); dbox_selecticon(ed->e.pd,glass_EIDSPRITE, !!(ed->idef.flags&wimp_ISPRITE)); break; case glass_EIAPPEARANCE: dbox_setfield(ed->e.pd,glass_EIAFONTNAME,"%.%s",ed->font); dbox_setfield(ed->e.pd,glass_EIAFSIZEWRITE,"%i",ed->fontSize); if (ed->idef.flags & wimp_ITEXT) { if (ed->idef.flags & wimp_IFONT) { dbox_selecticon(ed->e.pd,glass_EIAFONT,TRUE); dbox_shadeicon(ed->e.pd,glass_EIAFONTNAME,FALSE); dbox_shadeicon(ed->e.pd,glass_EIAFONTMENU,FALSE); dbox_shadeicon(ed->e.pd,glass_EIAFONT,FALSE); dbox_shadeicon(ed->e.pd,glass_EIAFSIZEUP,FALSE); dbox_shadeicon(ed->e.pd,glass_EIAFSIZEDOWN,FALSE); dbox_shadeicon(ed->e.pd,glass_EIAFSIZEWRITE,FALSE); } else { dbox_selecticon(ed->e.pd,glass_EIAFONT,FALSE); dbox_shadeicon(ed->e.pd,glass_EIAFONT,FALSE); dbox_shadeicon(ed->e.pd,glass_EIAFONTNAME,TRUE); dbox_shadeicon(ed->e.pd,glass_EIAFONTMENU,TRUE); dbox_shadeicon(ed->e.pd,glass_EIAFSIZEUP,TRUE); dbox_shadeicon(ed->e.pd,glass_EIAFSIZEDOWN,TRUE); dbox_shadeicon(ed->e.pd,glass_EIAFSIZEWRITE,TRUE); } } else { dbox_selecticon(ed->e.pd,glass_EIAFONT,FALSE); dbox_shadeicon(ed->e.pd,glass_EIAFONT,TRUE); dbox_shadeicon(ed->e.pd,glass_EIAFONTNAME,TRUE); dbox_shadeicon(ed->e.pd,glass_EIAFONTMENU,TRUE); dbox_shadeicon(ed->e.pd,glass_EIAFSIZEUP,TRUE); dbox_shadeicon(ed->e.pd,glass_EIAFSIZEDOWN,TRUE); dbox_shadeicon(ed->e.pd,glass_EIAFSIZEWRITE,TRUE); } dbox_selecticon(ed->e.pd,glass_EIAHCENTRE, !!(ed->idef.flags & wimp_IHCENTRE)); dbox_selecticon(ed->e.pd,glass_EIAVCENTRE, !!(ed->idef.flags & wimp_IVCENTRE)); dbox_selecticon(ed->e.pd,glass_EIARALIGN, !!(ed->idef.flags & wimp_IRJUST)); dbox_selecticon(ed->e.pd,glass_EIABORDER, !!(ed->idef.flags & wimp_IBORDER)); dbox_selecticon(ed->e.pd,glass_EIAFILL, !!(ed->idef.flags & wimp_IFILLED)); if (ed->idef.flags & wimp_ISPRITE) { dbox_selecticon(ed->e.pd,glass_EIAHALFSIZE, !!(ed->idef.flags & wimp_IHALVESPRITE)); dbox_shadeicon(ed->e.pd,glass_EIAHALFSIZE,FALSE); } else { dbox_selecticon(ed->e.pd,glass_EIAHALFSIZE,FALSE); dbox_shadeicon(ed->e.pd,glass_EIAHALFSIZE,TRUE); } dbox_selecticon(ed->e.pd,glass_EIANEEDSHELP, !!(ed->idef.flags & wimp_IREDRAW)); break; case glass_EIACTIONS: p=buffer_find(); sprintf(p,"eiBTYPE%i",(ed->idef.flags>>12) & 0x0f); dbox_setfield(ed->e.pd,glass_EIABTYPE,"%s",msgs_lookup(p)); dbox_setfield(ed->e.pd,glass_EIAESGWRITE,"%i", (ed->idef.flags>>16) & 0x1f); dbox_selecticon(ed->e.pd,glass_EIAADJUST, !!(ed->idef.flags & wimp_IESG_NOC)); dbox_selecticon(ed->e.pd,glass_EIASELECT, !!(ed->idef.flags & wimp_ISELECTED)); dbox_selecticon(ed->e.pd,glass_EIASHADE, !!(ed->idef.flags & wimp_INOSELECT)); break; case glass_EICOLOURS: colSelect_setColourButton(ed->e.pd,glass_EICFORE, (ed->idef.flags>>24) & 15); colSelect_setColourButton(ed->e.pd,glass_EICBACK, (ed->idef.flags>>28) & 15); break; case glass_EISIZE: dbox_setfield(ed->e.pd, glass_EIPWRITE, "%i,%i", ed->idef.box.x1-ed->idef.box.x0, ed->idef.box.y1-ed->idef.box.y0); dbox_shadeicon(ed->e.pd,glass_EIPSETSIZE,!(ed->idef.flags & 3)); break; case glass_EIPOSITION: dbox_setfield(ed->e.pd, glass_EIPWRITE, "%i,%i", ed->idef.box.x0, ed->idef.box.y0); break; } } /* * BOOL editIcon__getSpriteSize(char *name,sprite_area *a,int *x,int *y) * * Use * Attempts to read the size of a sprite in OS units. * * Returns * TRUE if it really worked */ static BOOL editIcon__getSpriteSize(char *name,sprite_area *a,int *x,int *y) { os_error *e; os_regset r; /* --- First look in the given area --- */ e=os_swivr(OS_SpriteOp,&r,40+256,a,name); /* --- Now, OS version permitting, look in the WIMP area --- */ if (e && wimpt_getVersion()>=300) e=os_swivr(Wimp_SpriteOp,&r,40,0,name); /* --- If it worked, read out all the info and return it --- */ if (!e) { *x=r.r[3]<e.pd,glass_EIPWRITE,"%d,%d",&w,&h); /* --- Find out if this is going to be easy --- */ switch (ed->idef.flags & 3) { /* --- No icon data -- ignore this operation --- */ case 0: break; /* --- Only text -- work it out (assuming system font size) --- */ case 1: h=48; w=16*(strlen(ed->data)+1); break; /* --- Only a sprite -- use the size of the sprite --- */ case 2: if (!editIcon__getSpriteSize(ed->data,ed->w->t->s,&w,&h)) note(msgs_lookup("eiSPRGONE"),ed->data); break; /* --- Text and sprite together --- */ case 3: sprname=ed->data; if ((ed->idef.flags & 0x100) && ed->hasValid) { /* --- Parse the validation string to find the sprite name --- */ int state=1; char *p=ed->valid; char *q=sname; for (;*p>31 && state!=3;p++) { switch (*p) { case '\\': if (p[1]>31) p++; if (state==1) state=0; else if (state==2) *q++=*p; break; case ';': if (state>1) { *q++=0; state=3; } else state=1; break; case 'S': case 's': if (state==1) state=2; else if (state==2) *q++=*p; break; case ',': switch (state) { case 2: *q++=0; state++; } break; default: switch (state) { case 1: state=0; break; case 2: *q++=*p; break; } break; } } if (state==2) { *q++=0; state=3; } if (state==3) sprname=sname; } if (editIcon__getSpriteSize(sprname,ed->w->t->s,&sw,&sh)) { if (ed->data[0]) { h=48; w=16*(strlen(ed->data)+1); f=posns[(tst(ed->idef.flags,3)<<2) | (tst(ed->idef.flags,4)<<1) | (tst(ed->idef.flags,9)<<0)]; if (f & 2) h=max2(h,sh); else h+=sh; if (f & 1) w=max2(w,sw); else w+=sw; } else { h=sh; w=sw; } } else note(msgs_lookup("eiSPRGONE"),sprname); break; } dbox_setfield(ed->e.pd,glass_EIPWRITE,"%i,%i",w,h); } /* * void editIcon__closePanel(glass_editIcon *ed) * * Use * Records the settings in a panel for future reference, for example when * the panel is being replaced by a different one. * * Parameters * glass_editIcon *ed == the edit box we're talking about */ #define Q dbox_READSTATE static void editIcon__closePanel(glass_editIcon *ed) { int esg; int x,y; switch (ed->e.panel) { case glass_EIDATA: dbox_getfield(ed->e.pd,glass_EIDDATA,ed->data,256); dbox_getfield(ed->e.pd,glass_EIDVALSTRING,ed->valid,256); dbox_scanfield(ed->e.pd,glass_EIDINDSIZE,"%d",&ed->indLen); ed->hasValid=dbox_selecticon(ed->e.pd,glass_EIDVALID,Q); ed->idef.flags&=~0x00000103; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIDTEXT,Q)<<0; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIDSPRITE,Q)<<1; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIDINDIR,Q)<<8; break; case glass_EIAPPEARANCE: ed->idef.flags&=~0x00000afc; dbox_scanfield(ed->e.pd,glass_EIAFSIZEWRITE,"%d",&ed->fontSize); ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIAHCENTRE,Q)<<3; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIAVCENTRE,Q)<<4; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIABORDER,Q)<<2; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIAFILL,Q)<<5; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIAFONT,Q)<<6; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIANEEDSHELP,Q)<<7; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIARALIGN,Q)<<9; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIAHALFSIZE,Q)<<11; break; case glass_EIACTIONS: ed->idef.flags&=~0x007f0400; dbox_scanfield(ed->e.pd,glass_EIAESGWRITE,"%d",&esg); ed->idef.flags|=esg<<16; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIAADJUST,Q)<<10; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIASELECT,Q)<<21; ed->idef.flags|=dbox_selecticon(ed->e.pd,glass_EIASHADE,Q)<<22; break; case glass_EISIZE: dbox_scanfield(ed->e.pd,glass_EIPWRITE,"%d,%d",&x,&y); ed->idef.box.x1=ed->idef.box.x0+x; ed->idef.box.y1=ed->idef.box.y0+y; break; case glass_EIPOSITION: dbox_scanfield(ed->e.pd,glass_EIPWRITE,"%d,%d",&x,&y); ed->idef.box.x1+=x-ed->idef.box.x0; ed->idef.box.y1+=y-ed->idef.box.y0; ed->idef.box.x0=x; ed->idef.box.y0=y; break; } } #undef Q /* * void editIcon__setPanel(glass_editIcon *ed,dbox_field f) * * Use * Creates a new panel based on a radio button click or some-such. * * Parameters * glass_editIcon *ed == the edit window to change panel * dbox_field f == the radio button associated with the desired panel */ static void editIcon__panelHandler(dbox d,dbox_field f,void *handle); static BOOL editIcon__panelRaw(dbox d,wimp_eventstr *e,void *handle); static void editIcon__setPanel(glass_editIcon *ed,dbox_field f) { dbox d; wimp_wstate s; wimp_icon i; int width,height; int ox,oy; wimp_w behind; wimp_caretstr c; BOOL ownCaret=TRUE; if (f==ed->e.panel) return; editIcon__closePanel(ed); wimpt_noerr(wimp_get_wind_state(dbox_syshandle(ed->e.d),&s)); wimpt_noerr(wimp_get_icon_info(dbox_syshandle(ed->e.d), glass_EIPOSN,&i)); ox=s.o.box.x0-s.o.x; oy=s.o.box.y1-s.o.y; mem_useUser(indir_alloc,indir_free); if (f==-1) d=dbox_create("iconNowt"); else d=dbox_create(editIcon__panels[f-glass_EIDATA]); if (!d) { mem_useMalloc(); return; } dbox_eventHandler(d,editIcon__panelHandler,ed); dbox_rawEventHandler(d,editIcon__panelRaw,ed); if (ed->e.panel) { wimpt_noerr(wimp_get_caret_pos(&c)); ownCaret=(c.w==dbox_syshandle(ed->e.pd)); dbox_selecticon(ed->e.d,ed->e.panel,dbox_RESETSTATE); wimpt_noerr(wimp_get_wind_state(dbox_syshandle(ed->e.pd),&s)); pane_removePane(ed->e.p,dbox_syshandle(ed->e.pd)); dbox_delete(ed->e.pd); } dbox_selecticon(ed->e.d,f,dbox_SETSTATE); behind=s.o.behind; wimpt_noerr(wimp_get_wind_state(dbox_syshandle(d),&s)); width=s.o.box.x1-s.o.box.x0; height=s.o.box.y1-s.o.box.y0; s.o.box.x0=i.box.x0+ox+wimpt_dx(); s.o.box.y0=i.box.y0+oy+wimpt_dy(); s.o.box.x1=s.o.box.x0+width; s.o.box.y1=s.o.box.y0+height; s.o.y=10000; s.o.behind=behind; ed->e.pd=d; ed->e.panel=f; editIcon__setupPanel(ed); wimpt_noerr(wimp_open_wind(&s.o)); if (ownCaret) { c.w=dbox_syshandle(d); c.i=-1; c.x=-500000; c.y=0; c.height=0x02000000; wimpt_noerr(wimp_set_caret_pos(&c)); } pane_addPane(ed->e.p,dbox_syshandle(d)); mem_useMalloc(); } /* * void editIcon__recreate(glass_editIcon *ed) * * Use * Recreates the icon from the dialogue box settings * * Parameters * glass_editIcon *ed == info about the edit */ static void editIcon__recreate(glass_editIcon *ed) { char *p=0; char *q=0; int inum; int fhandle; ed->w->def->i[ed->i].edit=0; /* Delink temporarily */ window_redrawIcon(ed->w,ed->i); /* Force redraw of old icon */ if (!(ed->idef.flags & wimp_INDIRECT)) { ed->indLen=12; ed->hasValid=FALSE; } if (strlen(ed->data)>=ed->indLen) { ed->idef.flags|=wimp_INDIRECT; ed->indLen=strlen(ed->data)+1; } if (ed->idef.flags & wimp_INDIRECT) { if (p=indir_alloc(ed->indLen),!p) { werr(FALSE,msgs_lookup("eiNEMUI")); return; } if (ed->hasValid && (ed->idef.flags & wimp_ITEXT)) { if (q=indir_alloc(strlen(ed->valid)+1),!q) { indir_free(p); werr(FALSE,msgs_lookup("eiNEMUI")); return; } strcpy(q,ed->valid); ed->w->size+=strlen(ed->valid)+1; } strcpy(p,ed->data); ed->w->size+=ed->indLen; } if (ed->w->def->i[ed->i].i.flags & wimp_IFONT) /* Was old anti? */ { fhandle=(ed->w->def->i[ed->i].i.flags >> 24) & 255; wimpt_noerr(font_lose(fhandle)); ed->w->fonts[fhandle]--; } if (ed->idef.flags & wimp_IFONT) /* Is new icon antialiased? */ { if (font_find(ed->font,ed->fontSize*16,ed->fontSize*16,0,0,&fhandle)) { werr(FALSE,msgs_lookup("eiCFF"),ed->font); ed->idef.flags&=~wimp_IFONT; } else { ed->w->antiAliased=TRUE; ed->w->fonts[fhandle]++; ed->idef.flags=(ed->idef.flags & 0x00ffffff) | (fhandle<<24); } } if (ed->w->def->i[ed->i].i.flags & wimp_INDIRECT) { indir_free(ed->w->def->i[ed->i].i.data.indirecttext.buffer); ed->w->size-=ed->w->def->i[ed->i].i.data.indirecttext.bufflen; if ((ed->w->def->i[ed->i].i.flags & wimp_ITEXT) && (ed->w->def->i[ed->i].i.data.indirecttext.validstring!=(char *)-1)) { utils_ctermToNterm(ed->w->def->i[ed->i]. i.data.indirecttext.validstring); ed->w->size-= strlen(ed->w->def->i[ed->i].i.data.indirecttext.validstring)+1; indir_free(ed->w->def->i[ed->i].i.data.indirecttext.validstring); } } if (p) { ed->idef.data.indirecttext.buffer=p; ed->idef.data.indirecttext.bufflen=ed->indLen; if (q) ed->idef.data.indirecttext.validstring=q; else if (ed->idef.flags & wimp_ITEXT) ed->idef.data.indirecttext.validstring=(char *)-1; else ed->idef.data.indirectsprite.spritearea=ed->w->t->s; } else memcpy(ed->idef.data.text,ed->data,12); ed->w->def->i[ed->i].i=ed->idef; dbox_scanfield(ed->e.d,glass_EINUMWRITE,"%d",&inum); if (!window_renumber(ed->w,ed->i,inum)) dbox_setfield(ed->e.d,glass_EINUMWRITE,"%i",ed->i); else ed->i=inum; window_redrawIcon(ed->w,ed->i); /* Force redraw of new icon */ ed->w->def->i[ed->i].edit=ed; /* Relink again */ tfile_markAsAltered(ed->w->t); } /* * void editIcon__nextPanel(glass_editIcon *ed,int dir) * * Use * Changes panel to the next one in the given direction. Skips shaded * panels and handles everything nicely. * * Parameters * glass_editIcon *ed == the edit dialogue box to move about in * int dir == the direction (-1 for up, 1 for down) */ static void editIcon__nextPanel(glass_editIcon *ed,int dir) { int i=ed->e.panel; if (i==-1) i=(dir==1 ? glass_EIDATA : glass_EISIZE); else i+=dir; for (;i>=glass_EIDATA && i<=glass_EISIZE;i+=dir) { if (!dbox_shadeicon(ed->e.d,i,dbox_READSTATE)) { editIcon__setPanel(ed,i); break; } } } /*----- Event handlers ----------------------------------------------------*/ /* * void editIcon__dboxHandler(dbox d,dbox_field f,void *handle) * * Use * Handles any and all events directed at the dbox. Well, almost all... * * Parameters * dbox d == the dbox handle * dbox_field f == the event that happened * void *handle == pointer to the dialogue box control info */ static void editIcon__dboxHandler(dbox d,dbox_field f,void *handle) { glass_editIcon *ed=handle; buttons_simpleArrow sa={0,9999,FALSE}; switch (f) { case dbox_CLOSE: if (ed->e.pd) dbox_deleteNoUpdate(ed->e.pd); pane_delete(ed->e.p); dbox_delete(ed->e.d); ed->w->def->i[ed->i].edit=0; mem_free(ed); break; case dbox_HELP: help_startHelp(); help_addLine(msgs_lookup("eihEIDB")); help_readFromIcon(); help_endHelp(); break; case glass_EICAN: dbox_clickicon(d,f); if (!dbox_wasAdjustClick()) pane_close(ed->e.p); else { /* --- set up for old icon --- */ ed->idef=ed->w->def->i[ed->i].i; editIcon_readData(ed->w,ed->i); dbox_setfield(ed->e.d,glass_EINUMWRITE,"%i",ed->i); editIcon__setupPanel(ed); } dbox_unclick(); if (!dbox_wasAdjustClick()) editIcon_close(ed->w,ed->i); break; case glass_EIOK: dbox_clickicon(d,f); editIcon__closePanel(ed); if (!dbox_wasAdjustClick()) { pane_close(ed->e.p); editIcon__recreate(ed); dbox_unclick(); editIcon_close(ed->w,ed->i); } else { editIcon__recreate(ed); editIcon_readData(ed->w,ed->i); editIcon__setupPanel(ed); dbox_unclick(); } break; case glass_EIDELETE: dbox_clickicon(d,f); if (gPrefs_current()->cDelIcon) { if (!warning(msgs_lookup("eiCDIP"), msgs_lookup("eiCDI"))) { dbox_unclick(); return; } } pane_close(ed->e.p); dbox_unclick(); window_deleteIcon(ed->w,ed->i); /* Closes the edit for us */ break; case glass_EIDATA: case glass_EIAPPEARANCE: case glass_EIACTIONS: case glass_EICOLOURS: case glass_EIPOSITION: case glass_EISIZE: editIcon__setPanel(ed,f); break; case glass_EINUMUP: buttons_arrow(d,f,d,glass_EINUMWRITE,0,+1,&sa); break; case glass_EINUMDOWN: buttons_arrow(d,f,d,glass_EINUMWRITE,0,-1,&sa); break; } } /* * BOOL editIcon__dboxRaw(dbox d,wimp_eventstr *e,void *handle) * * Use * Handles open window requests and things for the main Preferences dbox. * * Parameters * dbox d == the dbox handle * wimp_eventstr *e == the event that happened * void *handle == a unused pointer * * Returns * TRUE if the event has been handled; */ static BOOL editIcon__dboxRaw(dbox d,wimp_eventstr *e,void *handle) { BOOL handled=FALSE; glass_editIcon *ed=handle; glass_intMsgstr *m; unused(d); switch (e->e) { case wimp_EOPEN: pane_moved(ed->e.p); handled=TRUE; break; case wimp_EKEY: switch (e->data.key.chcode) { case akbd_UpK+akbd_Sh: editIcon__nextPanel(ed,-1); handled=TRUE; break; case akbd_DownK+akbd_Sh: editIcon__nextPanel(ed,+1); handled=TRUE; break; } break; case wimp_ESEND: case wimp_ESENDWANTACK: switch (e->data.msg.hdr.action) { case wimp_MINTERNAL: m=intMsgs_receive(e); switch(e->data.msg.data.words[0]) { case glass_DELETEFILE: if (m->df.t==ed->w->t) editIcon_close(ed->w,ed->i); break; case glass_DELETEWINDOW: if (m->dw.w==ed->w) editIcon_close(ed->w,ed->i); break; case glass_RENAME: if (m->rn.w==ed->w) dbox_setfield(ed->e.d,glass_EIWINDISP,"%s",ed->w->id); break; } break; } break; } return (handled); } /* * menu editIcon__fontMaker(void *handle) * * Use * Sets up the font menu. * * Parameters * void *handle == pointer to this edit * * Returns * A menu to display */ static menu editIcon__fontMaker(void *handle) { glass_editIcon *ed=handle; menu m=fontMenu_createFontMenu(FALSE); fontMenu_tickGivenName(ed->font); return (m); } /* * void editIcon__fontHandler(int hit[],void *handle) * * Use * Gets the font chosen from the font menu. * * Parameters * int hit[] == the hit string * void *handle == pointer to this edit */ static void editIcon__fontHandler(int hit[],void *handle) { glass_editIcon *ed=handle; if (hit[0]) { strcpy(ed->font,fontMenu_fontname(hit[0],hit[1])); dbox_setfield(ed->e.pd,glass_EIAFONTNAME,"%.%s",ed->font); } } /* * void editIcon__fontHelp(int hit[],void *handle) * * Use * Gives help on a font menu item * * Parameters * int hit[] == the hit string * void *handle == pointer to this edit */ static void editIcon__fontHelp(int hit[],void *handle) { unused(handle); if (hit[0]) { help_startHelp(); help_addLine(msgs_lookup("eimhFONT"),fontMenu_fontname(hit[0],hit[1])); help_endHelp(); } } /* * menu editIcon__btypeMaker(void *handle) * * Use * Generates and sets up a button type menu for an edit dialogue box * * Parameters * void *handle == pointer to the edit * * Returns * The menu to use */ static menu editIcon__btypeMaker(void *handle) { static menu m; static int ticked; glass_editIcon *ed=handle; int i; char *buf=buffer_find(); if (!m) { m=menu_new(msgs_lookup("eiBTMT"),msgs_lookup("eiBTYPE0")); for (i=1;i<=15;i++) { sprintf(buf,"eiBTYPE%i",i); menu_extend(m,msgs_lookup(buf)); } } if (ticked) menu_setflags(m,ticked,FALSE,FALSE); ticked=((ed->idef.flags>>12)&0x0f)+1; menu_setflags(m,ticked,TRUE,FALSE); return (m); } /* * void editIcon__btypeHandler(int hit[],void *handle) * * Use * Handles a click on the button type menu. * * Parameters * int hit[] == the mouse click info * void *handle == pointer to edit information */ static void editIcon__btypeHandler(int hit[],void *handle) { glass_editIcon *ed=handle; char *buf=buffer_find(); if (hit[0]) { ed->idef.flags&=~0x0000f000; ed->idef.flags+=(hit[0]-1)<<12; sprintf(buf,"eiBTYPE%i",hit[0]-1); dbox_setfield(ed->e.pd,glass_EIABTYPE,"%s",msgs_lookup(buf)); } } /* * void editIcon__colProc(dbox d,dbox_field f,int colour, void *handle) * * Use * This routine is called when a colour is selected in the colours panel. * * Parameters * dbox d == the panel's handle * dbox_field f == the colour button that has changed * int colour == the new colour for the button * void *handle == pointer to this edit */ static void editIcon__colProc(dbox d,dbox_field f,int colour,void *handle) { glass_editIcon *ed=handle; unused(d); switch (f) { case glass_EICFORE: ed->idef.flags=(ed->idef.flags & ~0x0f000000)+(colour<<24); break; case glass_EICBACK: ed->idef.flags=(ed->idef.flags & ~0xf0000000)+(colour<<28); break; } } /* * void editIcon__btypeHelp(int hit[],void *handle) * * Use * Handles a help request for the button type menu. * * Parameters * int hit[] == the helpq info * void *handle == pointer to edit information */ static void editIcon__btypeHelp(int hit[],void *handle) { char *buf=buffer_find(); unused(handle); if (hit[0]) { help_startHelp(); sprintf(buf,"eiBTYPE%i",hit[0]-1); help_addLine(msgs_lookup("eimhBTYPE"),msgs_lookup(buf)); help_endHelp(); } } /* * void editIcon__posSizeArrows(dbox d,dbox_field f,int diff,void *handle) * * Use * Handles a click event on one of the position or size arrow buttons in * the dialogue box. See the structure definition below for a description * of the data structure required. */ typedef struct { BOOL xOrY; BOOL sizing; } editIcon__posSizeArrowstr; static void editIcon__posSizeArrows(dbox d, dbox_field f, int diff, void *handle) { editIcon__posSizeArrowstr *s=handle; int x,y; int *v; dbox_scanfield(d,f,"%d,%d",&x,&y); v=s->xOrY ? &x : &y; *v+=diff; if (s->sizing && *v<0) *v=0; dbox_setfield(d,f,"%i,%i",x,y); } /* * void editIcon__panelHandler(dbox d,dbox_field f,void *handle) * * Use * Handles simple click events for the current panel in an edit dbox * * Parameters * dbox d == the panel's dbox handle * dbox_field f == the icon that was clicked * void *handle == pointer to edit information */ static void editIcon__panelHandler(dbox d,dbox_field f,void *handle) { glass_editIcon *ed=handle; buttons_simpleArrow sa={0,9999,FALSE}; buttons_simpleArrow esga={0,31,FALSE}; editIcon__posSizeArrowstr psa={0,FALSE}; BOOL indon; switch (f) { case dbox_CLOSE: case dbox_HELP: case glass_EIOK: case glass_EICAN: editIcon__dboxHandler(ed->e.d,f,ed); return; break; } switch (ed->e.panel) { case glass_EIDATA: switch (f) { case glass_EIDINDIR: if (dbox_selecticon(d,f,dbox_READSTATE)) { if (dbox_selecticon(ed->e.pd,glass_EIDTEXT,dbox_READSTATE)) { dbox_shadeicon(ed->e.pd,glass_EIDVALID,FALSE); dbox_shadeicon(ed->e.pd, glass_EIDVALSTRING, !dbox_selecticon(ed->e.pd, glass_EIDVALID, dbox_READSTATE)); } dbox_shadeicon(ed->e.pd,glass_EIDINDSIZE,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDINDUP,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDINDDOWN,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDMINIMISE,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDINDPART,FALSE); } else { dbox_shadeicon(ed->e.pd,glass_EIDVALSTRING,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDVALID,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDSIZE,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDUP,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDDOWN,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDMINIMISE,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDPART,TRUE); } break; case glass_EIDINDUP: buttons_arrow(ed->e.pd,f,ed->e.pd,glass_EIDINDSIZE,0,+1,&sa); break; case glass_EIDINDDOWN: buttons_arrow(ed->e.pd,f,ed->e.pd,glass_EIDINDSIZE,0,-1,&sa); break; case glass_EIDVALID: dbox_shadeicon(ed->e.pd,glass_EIDVALSTRING,dbox_TOGGLESTATE); break; case glass_EIDMINIMISE: dbox_clickicon(d,f); dbox_getfield(d,glass_EIDDATA,ed->data,256); dbox_setfield(d,glass_EIDINDSIZE,"%i",strlen(ed->data)+1); dbox_unclick(); break; case glass_EIDTEXT: if (dbox_selecticon(ed->e.pd,glass_EIDTEXT,dbox_READSTATE)) { dbox_shadeicon(ed->e.pd,glass_EIDDATA,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDINDIR,FALSE); if (dbox_selecticon(d,glass_EIDINDIR,dbox_READSTATE)) { dbox_shadeicon(ed->e.pd,glass_EIDVALID,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDVALSTRING, !dbox_selecticon(ed->e.pd,glass_EIDVALID,dbox_READSTATE)); dbox_shadeicon(ed->e.pd,glass_EIDINDSIZE,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDINDUP,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDINDDOWN,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDMINIMISE,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDINDPART,FALSE); } else { dbox_shadeicon(ed->e.pd,glass_EIDVALID,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDVALSTRING,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDSIZE,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDUP,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDDOWN,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDMINIMISE,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDPART,TRUE); } dbox_shadeicon(ed->e.d,glass_EICOLOURS, !!(ed->idef.flags & wimp_IFONT)); } else { dbox_shadeicon(ed->e.pd,glass_EIDVALID,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDVALSTRING,TRUE); if (dbox_selecticon(d,glass_EIDSPRITE,dbox_READSTATE)) { dbox_shadeicon(ed->e.pd,glass_EIDDATA,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDINDIR,FALSE); indon=dbox_selecticon(d,glass_EIDINDIR,dbox_READSTATE); dbox_shadeicon(ed->e.pd,glass_EIDINDSIZE,!indon); dbox_shadeicon(ed->e.pd,glass_EIDINDUP,!indon); dbox_shadeicon(ed->e.pd,glass_EIDINDDOWN,!indon); dbox_shadeicon(ed->e.pd,glass_EIDMINIMISE,!indon); dbox_shadeicon(ed->e.pd,glass_EIDINDPART,!indon); } else { dbox_shadeicon(ed->e.pd,glass_EIDDATA,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDSIZE,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDUP,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDDOWN,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDPART,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDIR,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDMINIMISE,TRUE); } dbox_shadeicon(ed->e.d,glass_EICOLOURS,FALSE); } break; case glass_EIDSPRITE: if (dbox_selecticon(ed->e.pd,glass_EIDSPRITE,dbox_READSTATE)) { dbox_shadeicon(ed->e.pd,glass_EIDDATA,FALSE); dbox_shadeicon(ed->e.pd,glass_EIDINDIR,FALSE); indon=dbox_selecticon(d,glass_EIDINDIR,dbox_READSTATE); dbox_shadeicon(ed->e.pd,glass_EIDINDSIZE,!indon); dbox_shadeicon(ed->e.pd,glass_EIDINDUP,!indon); dbox_shadeicon(ed->e.pd,glass_EIDINDDOWN,!indon); dbox_shadeicon(ed->e.pd,glass_EIDMINIMISE,!indon); dbox_shadeicon(ed->e.pd,glass_EIDINDPART,!indon); } else if (!dbox_selecticon(ed->e.pd,glass_EIDTEXT,dbox_READSTATE)) { dbox_shadeicon(ed->e.pd,glass_EIDDATA,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDIR,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDSIZE,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDUP,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDDOWN,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDMINIMISE,TRUE); dbox_shadeicon(ed->e.pd,glass_EIDINDPART,TRUE); } break; } break; case glass_EIAPPEARANCE: switch (f) { case glass_EIAFONT: if (dbox_selecticon(d,f,dbox_READSTATE) || fontMenu_createFontMenu(FALSE)) { dbox_selecticon(d,f,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_EIAFONTNAME,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_EIAFONTMENU,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_EIAFSIZEUP,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_EIAFSIZEDOWN,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_EIAFSIZEWRITE,dbox_TOGGLESTATE); dbox_shadeicon(ed->e.d,glass_EICOLOURS,dbox_TOGGLESTATE); } break; case glass_EIAFSIZEUP: buttons_arrow(ed->e.pd,f,ed->e.pd,glass_EIAFSIZEWRITE,0,+1,&sa); break; case glass_EIAFSIZEDOWN: buttons_arrow(ed->e.pd,f,ed->e.pd,glass_EIAFSIZEWRITE,0,-1,&sa); break; } break; case glass_EIACTIONS: switch (f) { case glass_EIAESGUP: buttons_arrow(d,f,d,glass_EIAESGWRITE,0,+1,&esga); break; case glass_EIAESGDOWN: buttons_arrow(d,f,d,glass_EIAESGWRITE,0,-1,&esga); break; } break; case glass_EICOLOURS: /* Nothin' doing */ break; case glass_EISIZE: psa.sizing=TRUE; /* Drop through */ case glass_EIPOSITION: switch (f) { case glass_EIPUP: psa.xOrY=FALSE; buttons_arrow(d,f,d,glass_EIPWRITE, editIcon__posSizeArrows, +wimpt_dy(), &psa); break; case glass_EIPDOWN: psa.xOrY=FALSE; buttons_arrow(d,f,d,glass_EIPWRITE, editIcon__posSizeArrows, -wimpt_dy(), &psa); break; case glass_EIPLEFT: psa.xOrY=TRUE; buttons_arrow(d,f,d,glass_EIPWRITE, editIcon__posSizeArrows, -wimpt_dx(), &psa); break; case glass_EIPRIGHT: psa.xOrY=TRUE; buttons_arrow(d,f,d,glass_EIPWRITE, editIcon__posSizeArrows, +wimpt_dx(), &psa); break; case glass_EIPSETSIZE: dbox_clickicon(d,f); editIcon__setSize(ed); dbox_unclick(); break; } break; } } /* * BOOL editIcon__panelRaw(dbox d,wimp_eventstr *e,void *handle) * * Use * Handles the more wierd events for a particular panel. * * Parameters * dbox d == the dbox handle of the panel * wimp_eventstr *e == the event to look at * void *handle == pointer to the current edit * * Returns * TRUE if the event is dead (long live the event...) */ static BOOL editIcon__panelRaw(dbox d,wimp_eventstr *e,void *handle) { BOOL handled=FALSE; glass_editIcon *ed=handle; BOOL cursor=FALSE; if (e->e==wimp_EKEY) { switch (e->data.key.chcode) { case akbd_UpK+akbd_Sh: editIcon__nextPanel(ed,-1); handled=TRUE; break; case akbd_DownK+akbd_Sh: editIcon__nextPanel(ed,+1); handled=TRUE; break; } } if (!handled) switch (ed->e.panel) { case glass_EIDATA: /* Nothin' doing */ break; case glass_EIAPPEARANCE: switch (e->e) { case wimp_EBUT: switch (e->data.but.m.i) { case glass_EIAFONTNAME: menu_make(editIcon__fontMaker,editIcon__fontHandler, editIcon__fontHelp,ed); handled=TRUE; break; case glass_EIAFONTMENU: dbox_clickicon(d,glass_EIAFONTMENU); menu_make(editIcon__fontMaker,editIcon__fontHandler, editIcon__fontHelp,ed); dbox_unclick(); handled=TRUE; break; } break; } break; case glass_EIACTIONS: switch (e->e) { case wimp_EBUT: switch (e->data.but.m.i) { case glass_EIABTYPE: menu_make(editIcon__btypeMaker,editIcon__btypeHandler, editIcon__btypeHelp,ed); handled=TRUE; break; case glass_EIABTMENU: dbox_clickicon(d,glass_EIABTMENU); menu_make(editIcon__btypeMaker,editIcon__btypeHandler, editIcon__btypeHelp,ed); dbox_unclick(); handled=TRUE; break; } break; case wimp_EKEY: switch (e->data.key.c.i) { case glass_EIAESGWRITE: switch (e->data.key.chcode) { case akbd_DownK: case akbd_UpK: case akbd_TabK: case akbd_TabK+akbd_Sh: case akbd_UpK+akbd_Ctl: case akbd_DownK+akbd_Ctl: cursor=TRUE; break; } handled=buttons_insertChar(d,e->data.key.chcode,'0','9'); if (handled || cursor) buttons_arrowClick(d,glass_EIAESGWRITE,0,31,0,FALSE); break; } break; } break; case glass_EICOLOURS: switch (e->e) { case wimp_EBUT: switch (e->data.but.m.i) { case glass_EICFORE: colSelect(ed->e.pd,glass_EICFORE,e->data.but.m.bbits, msgs_lookup("eiFGC"),FALSE, editIcon__colProc,ed); break; case glass_EICBACK: colSelect(ed->e.pd,glass_EICBACK,e->data.but.m.bbits, msgs_lookup("eiBGC"),FALSE, editIcon__colProc,ed); break; } break; } break; case glass_EISIZE: case glass_EIPOSITION: /* Nothin' doin' */ break; } return (FALSE); } /*----- External routines -------------------------------------------------*/ /* * void editIcon_renumber(glass_windPointer *w,int icon,int new) * * Use * Informs an edit dialogue that an icon has been renumbered. * * Parameters * glass_windPointer *w == the window containing the icon * int icon == the icon number * int new == the new number for the icon */ void editIcon_renumber(glass_windPointer *w,int icon,int new) { glass_editIcon *ed=w->def->i[icon].edit; if (!ed) return; ed->i=new; dbox_setfield(ed->e.d,glass_EINUMWRITE,"%i",new); } /* * void editIcon_iconMoved(glass_windPointer *w,int icon) * * Use * Informs an edit dialogue that an icon has been moved. * * Parameters * glass_windPointer *w == the window containing the icon * int icon == the icon number. This may not be the same during the edit... */ void editIcon_iconMoved(glass_windPointer *w,int icon) { glass_editIcon *ed=w->def->i[icon].edit; if (!ed) return; ed->idef.box=ed->w->def->i[ed->i].i.box; if (ed->e.panel==glass_EIPOSITION || ed->e.panel==glass_EISIZE) editIcon__setupPanel(ed); } /* * void editIcon_readData(glass_windPointer *w,int icon) * * Use * Forces a re-read of the icon data for the given icon edit * * Parameters * glass_windPointer *w == the window containing the icon * int icon == the icon number. This may not be the same during the edit... */ void editIcon_readData(glass_windPointer *w,int icon) { glass_editIcon *ed=w->def->i[icon].edit; if (!ed) return; ed->idef.data=ed->w->def->i[ed->i].i.data; if (ed->idef.flags & wimp_INDIRECT) { utils_ctermToNterm(ed->idef.data.indirecttext.buffer); strcpy(ed->data,ed->idef.data.indirecttext.buffer); ed->indLen=ed->idef.data.indirecttext.bufflen; if (ed->idef.flags & wimp_ITEXT && ed->idef.data.indirecttext.validstring!=(char *)-1) { utils_ctermToNterm(ed->idef.data.indirecttext.validstring); strcpy(ed->valid,ed->idef.data.indirecttext.validstring); ed->hasValid=TRUE; } else { ed->valid[0]=0; ed->hasValid=FALSE; } } else { ed->data[12]=0; memcpy(ed->data,ed->idef.data.text,12); utils_ctermToNterm(ed->data); ed->valid[0]=0; ed->indLen=12; } if (ed->e.panel==glass_EIDATA) editIcon__setupPanel(ed); if (ed->idef.flags & wimp_IFONT) { if (ed->e.panel==glass_EICOLOURS) editIcon__setPanel(ed,-1); dbox_shadeicon(ed->e.d,glass_EICOLOURS,TRUE); } else dbox_shadeicon(ed->e.d,glass_EICOLOURS,FALSE); } /* * void editIcon_close(glass_windPointer *w,int icon) * * Use * Closes an edit window * * Parameters * glass_windPointer *w == the window containing the icon * int icon == the icon number. This may not be the same during the edit... */ void editIcon_close(glass_windPointer *w,int icon) { glass_editIcon *ed=w->def->i[icon].edit; if (ed) { if (ed->e.pd) dbox_deleteNoUpdate(ed->e.pd); pane_delete(ed->e.p); dbox_deleteNoUpdate(ed->e.d); ed->w->def->i[ed->i].edit=0; mem_free(ed); } } /* * void editIcon(glass_windPointer *w,int icon) * * Use * Edits the given icon in a dialogue box. * * Parameters * glass_windPointer *w == the window containing the icon * int icon == the icon number. This may not be the same during the edit... */ void editIcon(glass_windPointer *w,int icon) { glass_editIcon *ed; os_regset r; if (w->def->i[icon].edit) { dbox_display(w->def->i[icon].edit->e.d,TRUE); pane_front(w->def->i[icon].edit->e.p); return; } mem_useUser(indir_alloc,indir_free); ed=mem_alloc(sizeof(glass_editIcon)); if (!ed) { werr(FALSE,msgs_lookup("eiNEM")); mem_useMalloc(); return; } if (ed->e.d=dbox_create("editIcon"),!ed->e.d) { mem_free(ed); mem_useMalloc(); return; } if (ed->e.p=pane_create(dbox_syshandle(ed->e.d)),!ed->e.p) { dbox_delete(ed->e.d); mem_free(ed); mem_useMalloc(); return; } mem_useMalloc(); ed->w=w; ed->i=icon; ed->idef=w->def->i[icon].i; w->def->i[icon].edit=ed; ed->e.panel=0; /* --- Set up icon data now --- */ editIcon_readData(w,icon); if (ed->idef.flags & wimp_IFONT) { r.r[0]=ed->idef.flags >> 24; r.r[1]=(int)(ed->font); wimpt_noerr(os_swix(XFont_ReadDefn,&r)); utils_ctermToNterm(ed->font); ed->fontSize=r.r[2]/16; dbox_shadeicon(ed->e.d,glass_EICOLOURS,TRUE); } else { strcpy(ed->font,"Homerton.Medium"); ed->fontSize=12; dbox_shadeicon(ed->e.d,glass_EICOLOURS,FALSE); } /* --- Now do handlers, and final setting up --- */ dbox_setfield(ed->e.d,glass_EINUMWRITE,"%i",icon); dbox_setfield(ed->e.d,glass_EIWINDISP,"%s",w->id); dbox_eventHandler(ed->e.d,editIcon__dboxHandler,ed); dbox_rawEventHandler(ed->e.d,editIcon__dboxRaw,ed); dbox_openDisplaced(ed->e.d); editIcon__setPanel(ed,glass_EIDATA); }