/* * gPrefs.h * * Loading, saving, alteration and setting of preferences * * © 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 */ /* * Steel headers */ #define _STDAPP #include "steel/Steel.h" #include "steel/prefs.h" #include "steel/pane.h" #include "steel/blinkC.h" #include "steel/buttons.h" #include "steel/akbd.h" /* * Glass headers */ #include "gIcons.h" #include "gMenus.h" #include "glass.h" #include "gPrefs.h" #include "intMsgs.h" #include "colSelect.h" #include "window.h" /*----- Macros ------------------------------------------------------------*/ #define gPrefs__DEFAULTTIME 5 #define gPrefs__DEFAULTCOUNT 50 /*----- Static global variables -------------------------------------------*/ static gPrefs_prefs gPrefs__current= { gPrefs_MINUTES, /* Autosave_TimeUnits */ 10, /* Autosave_Time */ 0, /* Autosave_Alterations */ TRUE, /* Autosave_Prompt */ TRUE, /* Interface_DisplayBorders */ TRUE, /* Interface_SlabIcons */ TRUE, /* Interface_DragboxAroundBorder*/ FALSE, /* Interface_SlabMenu */ TRUE, /* WimpExt_DisplayBorders */ TRUE, /* WimpExt_KeyPress */ TRUE, /* WimpExt_DragboxAroundBorder */ TRUE, /* Sculptrix_DisplayBorders */ TRUE, /* Sculptrix_SlabIcons */ TRUE, /* Sculptrix_DragboxAroundBorder*/ FALSE, /* Sculptrix_SlabMenu */ TRUE, /* Sprites_LoadSprites */ TRUE, /* Sprites_Load!Sprites */ TRUE, /* Sprites_LoadDefaults */ gPrefs_SMALL, /* Files_IconSize */ gPrefs_NAME, /* Files_SortBy */ FALSE, /* Grid_Display */ FALSE, /* Grid_Lock */ 16, /* Grid_Width */ 16, /* Grid_Height */ FALSE, /* Grid_DrawLines */ 8, /* Grid_GridColour */ 14, /* Grid_GuideColour */ 13, /* Grid_SelectedGuideColour */ TRUE, /* Select_DrawBorder */ TRUE, /* Select_DottedBorder */ 3, /* Select_BorderColour */ TRUE, /* Select_EdgeHandles */ 4, /* Select_HandleSize */ 7, /* Select_HandleColour */ 11, /* Select_SpecialColour */ TRUE, /* Confirm_Quit */ TRUE, /* Confirm_Close */ TRUE, /* Confirm_DelWind */ FALSE, /* Confirm_DelIcon */ FALSE, /* Confirm_TestCloseEdit */ TRUE, /* Confirm_Overwrite */ TRUE, /* Toolbar_Display */ FALSE, /* Toolbar_Floating */ {0,0}, /* Toolbar_Position */ TRUE, /* Toolbar_OnLeft */ TRUE, /* Infobar_Display */ FALSE, /* Infobar_Floating */ {0,0}, /* Infobar_Position */ TRUE, /* Infobar_Underneath */ FALSE, /* Misc_DrawHatch */ TRUE, /* Misc_BlinkCursor */ TRUE, /* Misc_VisibleInWork */ TRUE, /* Misc_CreateOnTop */ TRUE, /* Misc_RenumberOnDelete */ FALSE, /* Misc_ControlToEdit */ }; static gPrefs_prefs gPrefs__new; static dbox gPrefs__dbox; static pane gPrefs__pane; static dbox gPrefs__panel; static dbox_field gPrefs__currentPanel; /*----- Interpreters for new preferences data types -----------------------*/ static char *gPrefs__readUnit(char *tag,char *args,void *handle); static char *gPrefs__writeUnit(char *tag,FILE *fp,void *handle); static char *gPrefs__readIconSize(char *tag,char *args,void *handle); static char *gPrefs__writeIconSize(char *tag,FILE *fp,void *handle); static char *gPrefs__readSort(char *tag,char *args,void *handle); static char *gPrefs__writeSort(char *tag,FILE *fp,void *handle); static char *gPrefs__readCoords(char *tag,char *args,void *handle); static char *gPrefs__writeCoords(char *tag,FILE *fp,void *handle); /*----- Preferences file description --------------------------------------*/ static prefs_prefstr gPrefs__prefs[]= { ";\n" "; Glass preferences\n" ";\n" "\n", 0, 0, 0, "Autosave_TimeUnits", gPrefs__readUnit, gPrefs__writeUnit, &gPrefs__current.aUnit, "Autosave_Time", prefs_readNumeric, prefs_writeNumeric, &gPrefs__current.aTime, "Autosave_Alterations", prefs_readNumeric, prefs_writeNumeric, &gPrefs__current.aAlts, "Autosave_Prompt", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.aPrompt, "\n", 0, 0, 0, "Interface_DisplayBorders", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.iDispBorders, "Interface_SlabIcons", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.iSlabIcons, "Interface_DragboxAroundBorder", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.iIncBorder, "Interface_SlabOnMenu", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.iSlabMenu, "\n", 0, 0, 0, "WimpExtension_DisplayBorders", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.wDispBorders, "WimpExtension_KeyPress", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.wKeyPress, "WimpExtension_DragboxAroundBorder", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.wIncBorder, "\n", 0, 0, 0, "Sculptrix_DisplayBorders", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.sDispBorders, "Sculptrix_SlabIcons", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.sSlabIcons, "Sculptrix_DragboxAroundBorder", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.sIncBorder, "Sculptrix_SlabOnMenu", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.sSlabMenu, "\n", 0, 0, 0, "Sprites_LoadSprites", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.sLoadSpr, "Sprites_Load!Sprites", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.sLoadPSpr, "Sprites_LoadDefaults", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.sLoadDef, "\n", 0, 0, 0, "Files_IconSize", gPrefs__readIconSize, gPrefs__writeIconSize, &gPrefs__current.fIcons, "Files_SortBy", gPrefs__readSort, gPrefs__writeSort, &gPrefs__current.fSort, "\n", 0, 0, 0, "Grid_Display", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.gDisp, "Grid_Lock", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.gLock, "Grid_Width", prefs_readNumeric, prefs_writeNumeric, &gPrefs__current.gWidth, "Grid_Height", prefs_readNumeric, prefs_writeNumeric, &gPrefs__current.gHeight, "Grid_DrawLines", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.gLines, "Grid_GridColour", prefs_readNumeric, prefs_writeNumeric, &gPrefs__current.gGridCol, "Grid_GuideColour", prefs_readNumeric, prefs_writeNumeric, &gPrefs__current.gGdeCol, "Grid_SelectedGuideColour", prefs_readNumeric, prefs_writeNumeric, &gPrefs__current.gGdeSelCol, "\n", 0, 0, 0, "Select_DrawBorder", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.sBorder, "Select_DottedBorder", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.sDotted, "Select_BorderColour", prefs_readNumeric, prefs_writeNumeric, &gPrefs__current.sBColour, "Select_EdgeHandles", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.sEdgeHandles, "Select_HandleSize", prefs_readNumeric, prefs_writeNumeric, &gPrefs__current.sHandSize, "Select_HandleColour", prefs_readNumeric, prefs_writeNumeric, &gPrefs__current.sHColour, "Select_SpecialColour", prefs_readNumeric, prefs_writeNumeric, &gPrefs__current.sSColour, "\n", 0, 0, 0, "Confirm_Quit", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.cQuit, "Confirm_Close", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.cClose, "Confirm_DelWind", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.cDelWind, "Confirm_DelIcon", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.cDelIcon, "Confirm_TestCloseEdit", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.cTest, "Confirm_Overwrite", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.cSave, "\n", 0, 0, 0, "Toolbar_Display", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.tDisplay, "Toolbar_Floating", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.tFloating, "Toolbar_Position", gPrefs__readCoords, gPrefs__writeCoords, &gPrefs__current.tPosn, "Toolbar_OnLeft", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.tLeft, "\n", 0, 0, 0, "Infobar_Display", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.iDisplay, "Infobar_Floating", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.iFloating, "Infobar_Position", gPrefs__readCoords, gPrefs__writeCoords, &gPrefs__current.iPosn, "Infobar_Underneath", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.iUnder, "\n", 0, 0, 0, "Misc_DrawHatch", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.mDrawHatch, "Misc_BlinkCursor", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.mBlink, "Misc_VisibleInWork", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.mVisInWork, "Misc_CreateOnTop", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.mCreateTop, "Misc_RenumberOnDelete", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.mDeleteRenum, "Misc_ControlToEdit", prefs_readBoolean, prefs_writeBoolean, &gPrefs__current.mCtrlEdit, 0, 0, 0, 0, }; /*----- Miscelaneous tables -----------------------------------------------*/ static char *gPrefs__panels[]= { "prefSave", "prefIface", "prefSprite", "prefFile", "prefGrid", "prefSel", "prefConf", "prefTool", "prefMisc", }; static char *gPrefs__units[]= { 0, "prHR", "prMI", "prSE", }; /*----- Support routines --------------------------------------------------*/ #define max2(a,b) ((a)>(b) ? (a) : (b)) #define min2(a,b) ((a)<(b) ? (a) : (b)) /* * char *gPrefs__readUnit(char *tag,char *args,void *handle) * * Use * Interprets a time unit variable in preferences file. * * Parameters * char *tag == the name of the tag to interpret * char *args == pointer to args string to interpret * void *handle == pointer to approriately typed variable * * Returns * 0 for success, or pointer to an error string. */ static char *gPrefs__readUnit(char *tag,char *args,void *handle) { unused(tag); if (utils_caselessCmp(args,"hours")==0) *(gPrefs_autoUnits *)handle=gPrefs_HOURS; else if (utils_caselessCmp(args,"minutes")==0) *(gPrefs_autoUnits *)handle=gPrefs_MINUTES; else if (utils_caselessCmp(args,"seconds")==0) *(gPrefs_autoUnits *)handle=gPrefs_SECONDS; else { return (msgs_lookup("prBTU")); } return (0); } /* * char *gPrefs__writeUnit(char *tag,FILE *fp,void *handle) * * Use * Writes a time unit variable to preferences file. * * Parameters * char *tag == the name of the tag to interpret * FILE *fp == the file handle for the file * void *handle == pointer to approriately typed variable * * Returns * 0 for success, or pointer to an error string. */ static char *gPrefs__writeUnit(char *tag,FILE *fp,void *handle) { static char *units[]={0,"hours","minutes","seconds"}; fprintf(fp,"%s=%s\n",tag,units[*(gPrefs_autoUnits *)handle]); return (0); } /* * char *gPrefs__readIconSize(char *tag,char *args,void *handle) * * Use * Interprets an icon size variable in preferences file. * * Parameters * char *tag == the name of the tag to interpret * char *args == pointer to args string to interpret * void *handle == pointer to approriately typed variable * * Returns * 0 for success, or pointer to an error string. */ static char *gPrefs__readIconSize(char *tag,char *args,void *handle) { unused(tag); if (utils_caselessCmp(args,"large")==0) *(gPrefs_iconSize *)handle=gPrefs_LARGE; else if (utils_caselessCmp(args,"small")==0) *(gPrefs_iconSize *)handle=gPrefs_SMALL; else { return (msgs_lookup("prBIS")); } return (0); } /* * char *gPrefs__writeIconSize(char *tag,FILE *fp,void *handle) * * Use * Writes an icon size variable to preferences file. * * Parameters * char *tag == the name of the tag to interpret * FILE *fp == the file handle for the file * void *handle == pointer to approriately typed variable * * Returns * 0 for success, or pointer to an error string. */ static char *gPrefs__writeIconSize(char *tag,FILE *fp,void *handle) { static char *units[]={0,"large","small"}; fprintf(fp,"%s=%s\n",tag,units[*(gPrefs_iconSize *)handle]); return (0); } /* * char *gPrefs__readSort(char *tag,char *args,void *handle) * * Use * Interprets a sort type variable in preferences file. * * Parameters * char *tag == the name of the tag to interpret * char *args == pointer to args string to interpret * void *handle == pointer to approriately typed variable * * Returns * 0 for success, or pointer to an error string. */ static char *gPrefs__readSort(char *tag,char *args,void *handle) { unused(tag); if (utils_caselessCmp(args,"name")==0) *(gPrefs_sortType *)handle=gPrefs_NAME; else if (utils_caselessCmp(args,"size")==0) *(gPrefs_sortType *)handle=gPrefs_SIZE; else if (utils_caselessCmp(args,"icons")==0) *(gPrefs_sortType *)handle=gPrefs_ICONS; else if (utils_caselessCmp(args,"noSort")==0) *(gPrefs_sortType *)handle=gPrefs_NOSORT; else { return (msgs_lookup("prBST")); } return (0); } /* * char *gPrefs__writeSort(char *tag,FILE *fp,void *handle) * * Use * Writes a sort type variable to preferences file. * * Parameters * char *tag == the name of the tag to interpret * FILE *fp == the file handle for the file * void *handle == pointer to approriately typed variable * * Returns * 0 for success, or pointer to an error string. */ static char *gPrefs__writeSort(char *tag,FILE *fp,void *handle) { static char *units[]={0,"name","size","icons","noSort"}; fprintf(fp,"%s %s\n",tag,units[*(gPrefs_sortType *)handle]); return (0); } /* * char *gPrefs__readCoords(char *tag,char *args,void *handle) * * Use * Interprets a coordinates type variable in preferences file. * * Parameters * char *tag == the name of the tag to interpret * char *args == pointer to args string to interpret * void *handle == pointer to approriately typed variable * * Returns * 0 for success, or pointer to an error string. */ static char *gPrefs__readCoords(char *tag,char *args,void *handle) { gPrefs_coords *c=handle; unused(tag); sscanf(args,"%d,%d",&c->x,&c->y); return (0); } /* * char *gPrefs__writeCoords(char *tag,FILE *fp,void *handle) * * Use * Writes a sort type variable to preferences file. * * Parameters * char *tag == the name of the tag to interpret * FILE *fp == the file handle for the file * void *handle == pointer to approriately typed variable * * Returns * 0 for success, or pointer to an error string. */ static char *gPrefs__writeCoords(char *tag,FILE *fp,void *handle) { gPrefs_coords *c=handle; fprintf(fp,"%s=%i,%i\n",tag,c->x,c->y); return (0); } /* * void gPrefs__setupPanel(void) * * Use * Reads the settings in a panel before it is closed. */ static void gPrefs__setupPanel(void) { dbox d=gPrefs__panel; switch (gPrefs__currentPanel) { case glass_PMAUTOSAVE: if (gPrefs__new.aTime) { dbox_selecticon(d,glass_PATIMED,dbox_SETSTATE); dbox_shadeicon(d,glass_PATIMEDOWN,dbox_RESETSTATE); dbox_shadeicon(d,glass_PATIMEWRITE,dbox_RESETSTATE); dbox_shadeicon(d,glass_PATIMEUP,dbox_RESETSTATE); dbox_shadeicon(d,glass_PAUNITSDISP,dbox_RESETSTATE); dbox_shadeicon(d,glass_PAUNITSMENU,dbox_RESETSTATE); dbox_setfield(d,glass_PATIMEWRITE,"%i",gPrefs__new.aTime); } else { dbox_selecticon(d,glass_PATIMED,dbox_RESETSTATE); dbox_shadeicon(d,glass_PATIMEDOWN,dbox_SETSTATE); dbox_shadeicon(d,glass_PATIMEWRITE,dbox_SETSTATE); dbox_shadeicon(d,glass_PATIMEUP,dbox_SETSTATE); dbox_shadeicon(d,glass_PAUNITSDISP,dbox_SETSTATE); dbox_shadeicon(d,glass_PAUNITSMENU,dbox_SETSTATE); dbox_setfield(d,glass_PATIMEWRITE,"%i",gPrefs__DEFAULTTIME); } dbox_setfield(d,glass_PAUNITSDISP,"%s", msgs_lookup(gPrefs__units[gPrefs__new.aUnit])); if (gPrefs__new.aAlts) { dbox_selecticon(d,glass_PACOUNTED,dbox_SETSTATE); dbox_shadeicon(d,glass_PACOUNTDOWN,dbox_RESETSTATE); dbox_shadeicon(d,glass_PACOUNTWRITE,dbox_RESETSTATE); dbox_shadeicon(d,glass_PACOUNTUP,dbox_RESETSTATE); dbox_setfield(d,glass_PACOUNTWRITE,"%i",gPrefs__new.aAlts); } else { dbox_selecticon(d,glass_PACOUNTED,dbox_RESETSTATE); dbox_shadeicon(d,glass_PACOUNTDOWN,dbox_SETSTATE); dbox_shadeicon(d,glass_PACOUNTWRITE,dbox_SETSTATE); dbox_shadeicon(d,glass_PACOUNTUP,dbox_SETSTATE); dbox_setfield(d,glass_PACOUNTWRITE,"%i",gPrefs__DEFAULTCOUNT); } dbox_selecticon(d,glass_PAPROMPT,gPrefs__new.aPrompt); break; case glass_PMINTERFACE: dbox_selecticon(d,glass_PIDISPBORDER,gPrefs__new.iDispBorders); dbox_selecticon(d,glass_PIMOUSECLICK,gPrefs__new.iSlabIcons); dbox_selecticon(d,glass_PIMENUCLICK,gPrefs__new.iSlabMenu); dbox_shadeicon(d,glass_PIMENUCLICK,!gPrefs__new.iSlabIcons); dbox_selecticon(d,glass_PIINCBORDER,gPrefs__new.iIncBorder); dbox_selecticon(d,glass_PWDISPBORDER,gPrefs__new.wDispBorders); dbox_selecticon(d,glass_PWKEYPRESS,gPrefs__new.wKeyPress); dbox_selecticon(d,glass_PWINCBORDER,gPrefs__new.wIncBorder); dbox_selecticon(d,glass_PSDISPBORDER,gPrefs__new.sDispBorders); dbox_selecticon(d,glass_PSMOUSECLICK,gPrefs__new.sSlabIcons); dbox_selecticon(d,glass_PSMENUCLICK,gPrefs__new.sSlabMenu); dbox_shadeicon(d,glass_PSMENUCLICK,!gPrefs__new.sSlabIcons); dbox_selecticon(d,glass_PSINCBORDER,gPrefs__new.sIncBorder); break; case glass_PMSPRITES: dbox_selecticon(d,glass_PSSPRITES,gPrefs__new.sLoadSpr); dbox_selecticon(d,glass_PSPSPRITES,gPrefs__new.sLoadPSpr); dbox_selecticon(d,glass_PSDEFAULTS,gPrefs__new.sLoadDef); break; case glass_PMFILEDISP: dbox_selecticon(d,glass_PFLARGE,gPrefs__new.fIcons==gPrefs_LARGE); dbox_selecticon(d,glass_PFSMALL,gPrefs__new.fIcons==gPrefs_SMALL); dbox_selecticon(d,glass_PFNAME,gPrefs__new.fSort==gPrefs_NAME); dbox_selecticon(d,glass_PFSIZE,gPrefs__new.fSort==gPrefs_SIZE); dbox_selecticon(d,glass_PFICONS,gPrefs__new.fSort==gPrefs_ICONS); dbox_selecticon(d,glass_PFNOSORT,gPrefs__new.fSort==gPrefs_NOSORT); break; case glass_PMGRID: dbox_selecticon(d,glass_PGDISP,gPrefs__new.gDisp); dbox_selecticon(d,glass_PGLOCK,gPrefs__new.gLock); dbox_setfield(d,glass_PGWWRITE,"%i",gPrefs__new.gWidth); dbox_setfield(d,glass_PGHWRITE,"%i",gPrefs__new.gHeight); dbox_selecticon(d,glass_PGLINES,gPrefs__new.gLines); dbox_selecticon(d,glass_PGPOINTS,!gPrefs__new.gLines); colSelect_setColourButton(d,glass_PGGRIDCOL,gPrefs__new.gGridCol); colSelect_setColourButton(d,glass_PGGUIDECOL,gPrefs__new.gGdeCol); colSelect_setColourButton(d, glass_PGGDESELCOL, gPrefs__new.gGdeSelCol); break; case glass_PMSELECTION: dbox_selecticon(d,glass_PSBORDER,gPrefs__new.sBorder); dbox_shadeicon(d,glass_PSDOTTED,!gPrefs__new.sBorder); dbox_shadeicon(d,glass_PSBCOLLABEL,!gPrefs__new.sBorder); dbox_shadeicon(d,glass_PSBCOLOUR,!gPrefs__new.sBorder); dbox_selecticon(d,glass_PSDOTTED,gPrefs__new.sDotted); colSelect_setColourButton(d,glass_PSBCOLOUR,gPrefs__new.sBColour); dbox_selecticon(d,glass_PSCORNEDGE,gPrefs__new.sEdgeHandles); dbox_selecticon(d,glass_PSCORNONLY,!gPrefs__new.sEdgeHandles); dbox_setfield(d,glass_PSSIZEWRITE,"%i",gPrefs__new.sHandSize); colSelect_setColourButton(d,glass_PSHCOLOUR,gPrefs__new.sHColour); colSelect_setColourButton(d,glass_PSSCOLOUR,gPrefs__new.sSColour); break; case glass_PMCONFIRM: dbox_selecticon(d,glass_PCQUIT,gPrefs__new.cQuit); dbox_selecticon(d,glass_PCCLOSE,gPrefs__new.cClose); dbox_selecticon(d,glass_PCDELWIN,gPrefs__new.cDelWind); dbox_selecticon(d,glass_PCDELICON,gPrefs__new.cDelIcon); dbox_selecticon(d,glass_PCTEST,gPrefs__new.cTest); dbox_selecticon(d,glass_PCOVERWRITE,gPrefs__new.cSave); break; case glass_PMTOOLINFO: if (gPrefs__new.tDisplay) { dbox_selecticon(d,glass_PTTOOLDISP,dbox_SETSTATE); dbox_shadeicon(d,glass_PTTOOLFLOAT,dbox_RESETSTATE); } else { dbox_selecticon(d,glass_PTTOOLDISP,dbox_RESETSTATE); dbox_shadeicon(d,glass_PTTOOLFLOAT,dbox_SETSTATE); } dbox_selecticon(d,glass_PTTOOLFLOAT,gPrefs__new.tFloating); if (gPrefs__new.iDisplay) { dbox_selecticon(d,glass_PTINFODISP,dbox_SETSTATE); dbox_shadeicon(d,glass_PTINFOFLOAT,dbox_RESETSTATE); } else { dbox_selecticon(d,glass_PTINFODISP,dbox_RESETSTATE); dbox_shadeicon(d,glass_PTINFOFLOAT,dbox_SETSTATE); } dbox_selecticon(d,glass_PTINFOFLOAT,gPrefs__new.iFloating); break; case glass_PMMISC: dbox_selecticon(d,glass_PMHATCH,gPrefs__new.mDrawHatch); dbox_selecticon(d,glass_PMBLINK,gPrefs__new.mBlink); dbox_selecticon(d,glass_PMVISINWORK,gPrefs__new.mVisInWork); dbox_selecticon(d,glass_PMNEWONTOP,gPrefs__new.mCreateTop); dbox_selecticon(d,glass_PMRENDEL,gPrefs__new.mDeleteRenum); dbox_selecticon(d,glass_PMCTRLEDIT,gPrefs__new.mCtrlEdit); break; } } /* * void gPrefs__closePanel(void) * * Use * Reads the settings in a panel before it is closed. */ #define Q dbox_READSTATE static void gPrefs__closePanel(void) { dbox d=gPrefs__panel; switch (gPrefs__currentPanel) { case glass_PMAUTOSAVE: if (dbox_selecticon(d,glass_PATIMED,Q)) { dbox_scanfield(d,glass_PATIMEWRITE,"%d",&gPrefs__new.aTime); if (!gPrefs__new.aTime) { gPrefs__new.aTime=gPrefs__DEFAULTTIME; dbox_setfield(d,glass_PATIMEWRITE,"%i",gPrefs__new.aTime); note(msgs_lookup("prSILT"), gPrefs__DEFAULTTIME); } } else gPrefs__new.aTime=0; if (dbox_selecticon(d,glass_PACOUNTED,Q)) { dbox_scanfield(d,glass_PACOUNTWRITE,"%d",&gPrefs__new.aAlts); if (!gPrefs__new.aAlts) { gPrefs__new.aAlts=gPrefs__DEFAULTCOUNT; dbox_setfield(d,glass_PACOUNTWRITE,"%i",gPrefs__new.aTime); note(msgs_lookup("prSILC"), gPrefs__DEFAULTCOUNT); } } else gPrefs__new.aAlts=0; gPrefs__new.aPrompt=dbox_selecticon(d,glass_PAPROMPT,Q); break; case glass_PMINTERFACE: gPrefs__new.iDispBorders=dbox_selecticon(d,glass_PIDISPBORDER,Q); gPrefs__new.iSlabIcons=dbox_selecticon(d,glass_PIMOUSECLICK,Q); if (gPrefs__new.iSlabIcons) gPrefs__new.iSlabMenu=dbox_selecticon(d,glass_PIMENUCLICK,Q); else gPrefs__new.iSlabMenu=FALSE; gPrefs__new.iIncBorder=dbox_selecticon(d,glass_PIINCBORDER,Q); gPrefs__new.wDispBorders=dbox_selecticon(d,glass_PWDISPBORDER,Q); gPrefs__new.wKeyPress=dbox_selecticon(d,glass_PWKEYPRESS,Q); gPrefs__new.wIncBorder=dbox_selecticon(d,glass_PWINCBORDER,Q); gPrefs__new.sDispBorders=dbox_selecticon(d,glass_PSDISPBORDER,Q); gPrefs__new.sSlabIcons=dbox_selecticon(d,glass_PSMOUSECLICK,Q); if (gPrefs__new.sSlabIcons) gPrefs__new.sSlabMenu=dbox_selecticon(d,glass_PSMENUCLICK,Q); else gPrefs__new.sSlabMenu=FALSE; gPrefs__new.sIncBorder=dbox_selecticon(d,glass_PSINCBORDER,Q); break; case glass_PMSPRITES: gPrefs__new.sLoadSpr=dbox_selecticon(d,glass_PSSPRITES,Q); gPrefs__new.sLoadPSpr=dbox_selecticon(d,glass_PSPSPRITES,Q); gPrefs__new.sLoadDef=dbox_selecticon(d,glass_PSDEFAULTS,Q); break; case glass_PMFILEDISP: if (dbox_selecticon(d,glass_PFLARGE,Q)) gPrefs__new.fIcons=gPrefs_LARGE; else gPrefs__new.fIcons=gPrefs_SMALL; if (dbox_selecticon(d,glass_PFNAME,Q)) gPrefs__new.fSort=gPrefs_NAME; else if (dbox_selecticon(d,glass_PFSIZE,Q)) gPrefs__new.fSort=gPrefs_SIZE; else if (dbox_selecticon(d,glass_PFICONS,Q)) gPrefs__new.fSort=gPrefs_ICONS; else gPrefs__new.fSort=gPrefs_NOSORT; break; case glass_PMGRID: gPrefs__new.gDisp=dbox_selecticon(d,glass_PGDISP,Q); gPrefs__new.gLock=dbox_selecticon(d,glass_PGLOCK,Q); dbox_scanfield(d,glass_PGWWRITE,"%d",&gPrefs__new.gWidth); dbox_scanfield(d,glass_PGHWRITE,"%d",&gPrefs__new.gHeight); gPrefs__new.gLines=dbox_selecticon(d,glass_PGLINES,Q); break; case glass_PMSELECTION: gPrefs__new.sBorder=dbox_selecticon(d,glass_PSBORDER,Q); gPrefs__new.sDotted=dbox_selecticon(d,glass_PSDOTTED,Q); gPrefs__new.sEdgeHandles=dbox_selecticon(d,glass_PSCORNEDGE,Q); dbox_scanfield(d,glass_PSSIZEWRITE,"%d",&gPrefs__new.sHandSize); break; case glass_PMCONFIRM: gPrefs__new.cQuit=dbox_selecticon(d,glass_PCQUIT,Q); gPrefs__new.cClose=dbox_selecticon(d,glass_PCCLOSE,Q); gPrefs__new.cDelWind=dbox_selecticon(d,glass_PCDELWIN,Q); gPrefs__new.cDelIcon=dbox_selecticon(d,glass_PCDELICON,Q); gPrefs__new.cTest=dbox_selecticon(d,glass_PCTEST,Q); gPrefs__new.cSave=dbox_selecticon(d,glass_PCOVERWRITE,Q); break; case glass_PMTOOLINFO: gPrefs__new.tDisplay=dbox_selecticon(d,glass_PTTOOLDISP,Q); gPrefs__new.tFloating=dbox_selecticon(d,glass_PTTOOLFLOAT,Q); gPrefs__new.iDisplay=dbox_selecticon(d,glass_PTINFODISP,Q); gPrefs__new.iFloating=dbox_selecticon(d,glass_PTINFOFLOAT,Q); break; case glass_PMMISC: gPrefs__new.mDrawHatch=dbox_selecticon(d,glass_PMHATCH,Q); gPrefs__new.mBlink=dbox_selecticon(d,glass_PMBLINK,Q); gPrefs__new.mVisInWork=dbox_selecticon(d,glass_PMVISINWORK,Q); gPrefs__new.mCreateTop=dbox_selecticon(d,glass_PMNEWONTOP,Q); gPrefs__new.mDeleteRenum=dbox_selecticon(d,glass_PMRENDEL,Q); gPrefs__new.mCtrlEdit=dbox_selecticon(d,glass_PMCTRLEDIT,Q); break; } } #undef Q /* * void gPrefs__setPanel(dbox_field f) * * Use * Creates a new panel based on a radio button click or some-such. * * Parameters * dbox_field f == the radio button associated with the desired panel */ static void gPrefs__panelHandler(dbox d,dbox_field f,void *handle); static BOOL gPrefs__panelRaw(dbox d,wimp_eventstr *e,void *handle); static void gPrefs__setPanel(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==gPrefs__currentPanel) return; gPrefs__closePanel(); wimpt_noerr(wimp_get_wind_state(dbox_syshandle(gPrefs__dbox),&s)); wimpt_noerr(wimp_get_icon_info(dbox_syshandle(gPrefs__dbox), glass_PMPOSN,&i)); ox=s.o.box.x0-s.o.x; oy=s.o.box.y1-s.o.y; if (d=dbox_create(gPrefs__panels[f-glass_PMAUTOSAVE]),!d) return; dbox_eventHandler(d,gPrefs__panelHandler,0); dbox_rawEventHandler(d,gPrefs__panelRaw,0); if (gPrefs__currentPanel) { wimpt_noerr(wimp_get_caret_pos(&c)); ownCaret=(c.w==dbox_syshandle(gPrefs__dbox) || c.w==dbox_syshandle(gPrefs__panel)); dbox_selecticon(gPrefs__dbox,gPrefs__currentPanel,dbox_RESETSTATE); wimpt_noerr(wimp_get_wind_state(dbox_syshandle(gPrefs__panel),&s)); pane_removePane(gPrefs__pane,dbox_syshandle(gPrefs__panel)); dbox_delete(gPrefs__panel); } dbox_selecticon(gPrefs__dbox,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; gPrefs__panel=d; gPrefs__currentPanel=f; gPrefs__setupPanel(); 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(gPrefs__pane,dbox_syshandle(d)); } /*----- Event handlers ----------------------------------------------------*/ /* * void gPrefs__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 (gPrefs__dbox) * dbox_field f == the event that happened * void *handle == unused data handle */ static void gPrefs__dboxHandler(dbox d,dbox_field f,void *handle) { BOOL redraw=FALSE; int oldTime; BOOL toolbar=FALSE; BOOL adjust; unused(handle); switch (f) { case dbox_CLOSE: if (gPrefs__panel) dbox_deleteNoUpdate(gPrefs__panel); pane_delete(gPrefs__pane); dbox_delete(gPrefs__dbox); gPrefs__dbox=0; gPrefs__currentPanel=0; break; case dbox_HELP: help_startHelp(); help_addLine(msgs_lookup("prhPREFS")); help_readFromIcon(); help_endHelp(); break; case glass_PMCANCEL: dbox_clickicon(d,f); if (!dbox_wasAdjustClick()) pane_close(gPrefs__pane); else { gPrefs__new=gPrefs__current; gPrefs__setupPanel(); } dbox_unclick(); if (!dbox_wasAdjustClick()) { dbox_deleteNoUpdate(gPrefs__panel); pane_delete(gPrefs__pane); dbox_delete(gPrefs__dbox); gPrefs__dbox=0; gPrefs__currentPanel=0; } break; case glass_PMOK: case glass_PMSAVE: dbox_clickicon(d,f); adjust=dbox_wasAdjustClick(); gPrefs__closePanel(); oldTime=gPrefs_autoTiming(); if ( (gPrefs__new.iDispBorders!=gPrefs__current.iDispBorders) || (gPrefs__new.iIncBorder!=gPrefs__current.iIncBorder) || (gPrefs__new.wDispBorders!=gPrefs__current.wDispBorders) || (gPrefs__new.wIncBorder!=gPrefs__current.wIncBorder) || (gPrefs__new.sDispBorders!=gPrefs__current.sDispBorders) || (gPrefs__new.sIncBorder!=gPrefs__current.sIncBorder) || (gPrefs__new.mDrawHatch!=gPrefs__current.mDrawHatch) || (gPrefs__new.sBorder!=gPrefs__current.sBorder) || (gPrefs__new.sDotted!=gPrefs__current.sDotted) || (gPrefs__new.sEdgeHandles!=gPrefs__current.sEdgeHandles) || (gPrefs__new.sHandSize!=gPrefs__current.sHandSize) || (gPrefs__new.sBColour!=gPrefs__current.sBColour) || (gPrefs__new.sHColour!=gPrefs__current.sHColour) || (gPrefs__new.sSColour!=gPrefs__current.sSColour) || (gPrefs__new.gLines!=gPrefs__current.gLines) || (gPrefs__new.gGridCol!=gPrefs__current.gGridCol) || (gPrefs__new.gGdeCol!=gPrefs__current.gGdeCol) || (gPrefs__new.gGdeSelCol!=gPrefs__current.gGdeSelCol) ) redraw=TRUE; if ( (gPrefs__new.tDisplay!=gPrefs__current.tDisplay) || (gPrefs__new.tFloating!=gPrefs__current.tFloating) || (gPrefs__new.iDisplay!=gPrefs__current.iDisplay) || (gPrefs__new.iFloating!=gPrefs__current.iFloating) ) toolbar=TRUE; if (gPrefs__new.aAlts!=gPrefs__current.aAlts) oldTime=-1; gPrefs__current=gPrefs__new; if (redraw) intMsgs_send(glass_REDRAW,0); if (gPrefs_autoTiming()!=oldTime) intMsgs_send(glass_AUTOSAVE,gPrefs_autoTiming()); if (toolbar) window_updateToolbar(); blinkCursor(gPrefs__current.mBlink); if (f==glass_PMSAVE) prefs_write(); if (!adjust) pane_close(gPrefs__pane); dbox_unclick(); if (!adjust) { dbox_deleteNoUpdate(gPrefs__panel); pane_delete(gPrefs__pane); dbox_delete(gPrefs__dbox); gPrefs__dbox=0; gPrefs__currentPanel=0; } break; case glass_PMAUTOSAVE: case glass_PMINTERFACE: case glass_PMSPRITES: case glass_PMFILEDISP: case glass_PMGRID: case glass_PMSELECTION: case glass_PMCONFIRM: case glass_PMTOOLINFO: case glass_PMMISC: gPrefs__setPanel(f); break; } } /* * BOOL gPrefs__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 gPrefs__dboxRaw(dbox d,wimp_eventstr *e,void *handle) { BOOL handled=FALSE; unused(d); unused(handle); switch (e->e) { case wimp_EOPEN: pane_moved(gPrefs__pane); handled=TRUE; break; case wimp_EKEY: switch (e->data.key.chcode) { case akbd_UpK+akbd_Sh: gPrefs__setPanel(max2(gPrefs__currentPanel-1,glass_PMAUTOSAVE)); handled=TRUE; break; case akbd_DownK+akbd_Sh: gPrefs__setPanel(min2(gPrefs__currentPanel+1,glass_PMMISC)); handled=TRUE; break; } break; } return (handled); } /* * void gPrefs__panelHandler(dbox d,dbox_field f,void *handle) * * Use * Handles normal dbox-type events for the preferences panel. * * Parameters * dbox d == the dbox handle for the panel * dbox_field f == the event type * void *handle == nothing in particular */ static void gPrefs__panelHandler(dbox d,dbox_field f,void *handle) { buttons_simpleArrow ast={1,59,FALSE}; buttons_simpleArrow asc={1,999,FALSE}; buttons_simpleArrow sa={0,999,FALSE}; unused(handle); switch (f) { case dbox_CLOSE: case dbox_HELP: case glass_PMOK: case glass_PMCANCEL: gPrefs__dboxHandler(gPrefs__dbox,f,0); return; } switch (gPrefs__currentPanel) { case glass_PMAUTOSAVE: switch (f) { case glass_PATIMED: dbox_shadeicon(d,glass_PATIMEDOWN,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_PATIMEUP,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_PATIMEWRITE,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_PAUNITSDISP,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_PAUNITSMENU,dbox_TOGGLESTATE); break; case glass_PACOUNTED: dbox_shadeicon(d,glass_PACOUNTUP,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_PACOUNTDOWN,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_PACOUNTWRITE,dbox_TOGGLESTATE); break; case glass_PATIMEDOWN: buttons_arrow(d,f,d,glass_PATIMEWRITE,0,-1,&ast); break; case glass_PATIMEUP: buttons_arrow(d,f,d,glass_PATIMEWRITE,0,+1,&ast); break; case glass_PACOUNTDOWN: buttons_arrow(d,f,d,glass_PACOUNTWRITE,0,-1,&asc); break; case glass_PACOUNTUP: buttons_arrow(d,f,d,glass_PACOUNTWRITE,0,+1,&asc); break; } break; case glass_PMINTERFACE: switch (f) { case glass_PIMOUSECLICK: dbox_shadeicon(d,glass_PIMENUCLICK,dbox_TOGGLESTATE); break; case glass_PSMOUSECLICK: dbox_shadeicon(d,glass_PSMENUCLICK,dbox_TOGGLESTATE); break; } break; case glass_PMTOOLINFO: switch (f) { case glass_PTTOOLDISP: dbox_shadeicon(d,glass_PTTOOLFLOAT,dbox_TOGGLESTATE); break; case glass_PTINFODISP: dbox_shadeicon(d,glass_PTINFOFLOAT,dbox_TOGGLESTATE); break; } break; case glass_PMGRID: switch (f) { case glass_PGWUP: buttons_arrow(d,f,d,glass_PGWWRITE,0,+1,&sa); break; case glass_PGWDOWN: buttons_arrow(d,f,d,glass_PGWWRITE,0,-1,&sa); break; case glass_PGHUP: buttons_arrow(d,f,d,glass_PGHWRITE,0,+1,&sa); break; case glass_PGHDOWN: buttons_arrow(d,f,d,glass_PGHWRITE,0,-1,&sa); break; } break; case glass_PMSELECTION: switch (f) { case glass_PSSIZEUP: buttons_arrow(d,f,d,glass_PSSIZEWRITE,0,+1,&sa); break; case glass_PSSIZEDOWN: buttons_arrow(d,f,d,glass_PSSIZEWRITE,0,-1,&sa); break; case glass_PSBORDER: dbox_shadeicon(d,glass_PSDOTTED,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_PSBCOLLABEL,dbox_TOGGLESTATE); dbox_shadeicon(d,glass_PSBCOLOUR,dbox_TOGGLESTATE); break; } break; } } /* * menu gPrefs__unitsMaker(void *handle) * * Use * Generates the units menu for the autosave panel and put a tick in the * right place. * * Parameters * void *handle == something pointless. * * Returns * A pointer to the menu. */ static menu gPrefs__unitsMaker(void *handle) { static menu m; unused(handle); if (!m) m=menu_new(msgs_lookup("prUNITT"), msgs_lookup("prUNIT")); menu_setflags(m,glass_PUHOURS,FALSE,FALSE); menu_setflags(m,glass_PUMINUTES,FALSE,FALSE); menu_setflags(m,glass_PUSECONDS,FALSE,FALSE); menu_setflags(m,gPrefs__new.aUnit,TRUE,FALSE); return (m); } /* * void gPrefs__unitsHandler(int hit[],void *handle) * * Use * Responds to menu clicks on the units menu * * Parameters * int hit[] == the menu hits * void *handle == an unused data pointer */ static void gPrefs__unitsHandler(int hit[],void *handle) { unused(handle); switch (hit[0]) { case glass_PUHOURS: case glass_PUMINUTES: case glass_PUSECONDS: gPrefs__new.aUnit=hit[0]; if (gPrefs__currentPanel==glass_PMAUTOSAVE) dbox_setfield(gPrefs__panel, glass_PAUNITSDISP, "%s", msgs_lookup(gPrefs__units[hit[0]])); break; } } /* * void gPrefs__unitsHelp(int hit[],void *handle) * * Use * Responds to help requests for the units menu * * Parameters * int hit[] == the menu hits * void *handle == an unused data pointer */ static void gPrefs__unitsHelp(int hit[],void *handle) { unused(handle); help_startHelp(); help_readFromMenu("prhmUN",hit); help_endHelp(); } /* * void gPrefs__colourHandler(dbox d,dbox_field f,int colour,void *handle) * * Use * Handles the colour buttons in the Preferences dialogue (all of them) * * Parameters * dbox d == irrelevant dbox handle * dbox_field f == which colour button has been prodded * int colour == what it has been prodded to * void *handle == a pointer (ignored) */ static void gPrefs__colourHandler(dbox d, dbox_field f, int colour, void *handle) { unused(d); unused(handle); switch (gPrefs__currentPanel) { case glass_PMGRID: switch (f) { case glass_PGGRIDCOL: gPrefs__new.gGridCol=colour; break; case glass_PGGUIDECOL: gPrefs__new.gGdeCol=colour; break; case glass_PGGDESELCOL: gPrefs__new.gGdeSelCol=colour; break; } break; case glass_PMSELECTION: switch (f) { case glass_PSBCOLOUR: gPrefs__new.sBColour=colour; break; case glass_PSHCOLOUR: gPrefs__new.sHColour=colour; break; case glass_PSSCOLOUR: gPrefs__new.sSColour=colour; break; } break; } } /* * BOOL gPrefs__panelRaw(dbox d,wimp_eventstr *e,void *handle) * * Use * Handles more unusual events concerned with dialogue boxes. * * Parameters * dbox d == the panel's handle * wimp_eventstr *e == the full event * void *handle == an unused handle * * Returns * TRUE if the event has been handled */ static BOOL gPrefs__panelRaw(dbox d,wimp_eventstr *e,void *handle) { BOOL handled=FALSE; BOOL cursor=FALSE; unused(handle); if (e->e==wimp_EKEY) { switch (e->data.key.chcode) { case akbd_UpK+akbd_Sh: gPrefs__setPanel(max2(gPrefs__currentPanel-1,glass_PMAUTOSAVE)); handled=TRUE; break; case akbd_DownK+akbd_Sh: gPrefs__setPanel(min2(gPrefs__currentPanel+1,glass_PMMISC)); handled=TRUE; break; } } if (!handled) switch (gPrefs__currentPanel) { case glass_PMAUTOSAVE: switch (e->e) { case wimp_EBUT: switch (e->data.but.m.i) { case glass_PAUNITSDISP: menu_make(gPrefs__unitsMaker, gPrefs__unitsHandler, gPrefs__unitsHelp,0); break; case glass_PAUNITSMENU: dbox_clickicon(d,glass_PAUNITSMENU); menu_make(gPrefs__unitsMaker, gPrefs__unitsHandler, gPrefs__unitsHelp,0); dbox_unclick(); break; } break; case wimp_EKEY: switch (e->data.key.c.i) { case glass_PATIMEWRITE: 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_PATIMEWRITE,1,59,0,FALSE); break; case glass_PACOUNTWRITE: 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_PACOUNTWRITE,1,999,0,FALSE); break; } break; } break; case glass_PMGRID: switch (e->e) { case wimp_EBUT: switch (e->data.but.m.i) { case glass_PGGRIDCOL: colSelect(d, e->data.but.m.i, e->data.but.m.bbits, msgs_lookup("prGCOL"), FALSE, gPrefs__colourHandler, 0); handled=TRUE; break; case glass_PGGUIDECOL: colSelect(d, e->data.but.m.i, e->data.but.m.bbits, msgs_lookup("prGDCOL"), FALSE, gPrefs__colourHandler, 0); handled=TRUE; break; case glass_PGGDESELCOL: colSelect(d, e->data.but.m.i, e->data.but.m.bbits, msgs_lookup("prSGDCOL"), FALSE, gPrefs__colourHandler, 0); handled=TRUE; break; } break; } break; case glass_PMSELECTION: switch (e->e) { case wimp_EBUT: switch (e->data.but.m.i) { case glass_PSBCOLOUR: colSelect(d, e->data.but.m.i, e->data.but.m.bbits, msgs_lookup("prSBCOL"), FALSE, gPrefs__colourHandler, 0); handled=TRUE; break; case glass_PSHCOLOUR: colSelect(d, e->data.but.m.i, e->data.but.m.bbits, msgs_lookup("prSHCOL"), FALSE, gPrefs__colourHandler, 0); handled=TRUE; break; case glass_PSSCOLOUR: colSelect(d, e->data.but.m.i, e->data.but.m.bbits, msgs_lookup("prSSCOL"), FALSE, gPrefs__colourHandler, 0); handled=TRUE; break; } break; } break; } return (handled); } /*----- External routines -------------------------------------------------*/ /* * void gPrefs_init(void) * * Use * Reads preferences file and initialises things accordingly */ void gPrefs_init(void) { prefs_preferences(gPrefs__prefs); prefs_read(); blink_init(); blinkCursor(gPrefs__current.mBlink); } /* * gPrefs_prefs *gPrefs_current(void) * * Use * Returns the current preferences settings. * * Returns * A pointer to the structure as defined above. */ gPrefs_prefs *gPrefs_current(void) { return (&gPrefs__current); } /* * int gPrefs_autoTiming(void) * * Use * Returns the current autosave time in centiseconds, or 0 for no timed * autosave. */ int gPrefs_autoTiming(void) { static int mult[]={0,360000,6000,100}; return (gPrefs__current.aTime*mult[gPrefs__current.aUnit]); } /* * void gPrefs_edit(void) * * Use * Opens the preferences dialogue box to allow editing of preferences. */ void gPrefs_edit(void) { if (gPrefs__dbox) { dbox_display(gPrefs__dbox,dbox_STATIC_LASTPOS); pane_front(gPrefs__pane); } else { if (gPrefs__dbox=dbox_create("preferences"),!gPrefs__dbox) return; else if (gPrefs__pane=pane_create(dbox_syshandle(gPrefs__dbox)), !gPrefs__pane) { dbox_delete(gPrefs__dbox); gPrefs__dbox=0; return; } gPrefs__new=gPrefs__current; dbox_eventHandler(gPrefs__dbox,gPrefs__dboxHandler,0); dbox_rawEventHandler(gPrefs__dbox,gPrefs__dboxRaw,0); dbox_display(gPrefs__dbox,dbox_STATIC_LASTPOS); gPrefs__setPanel(glass_PMAUTOSAVE); } }