frontierconfig.c

Go to the documentation of this file.
00001 
00002 /*  $Id: frontierconfig.c 1271 2006-04-16 17:43:49Z andreradke $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #include "memory.h"
00032 #include "quickdraw.h"
00033 #include "font.h"
00034 #include "resources.h"
00035 #include "strings.h"
00036 #include "dialogs.h"
00037 #include "shell.rsrc.h"
00038 #include "frontierconfig.h"
00039 #include "shell.h"
00040 #include "byteorder.h"  /* 2006-04-16 aradke: swap byte order in loadconfigresource */
00041 
00042 
00043 #ifdef MACVERSION
00044 #define configresourcetype 'cnfg'
00045 #endif
00046 
00047 #ifdef WIN95VERSION
00048 //#define configresourcetype 1000
00049 #define configresourcetype 'cnfg'
00050 #endif
00051 
00052 tyconfigrecord config;
00053 
00054 short iddefaultconfig = idtableconfig;
00055 
00056 
00057 
00058 
00059 static void initconfigrecord (tyconfigrecord *configrecord) {
00060     
00061     register ptrconfigrecord p = configrecord;
00062     
00063     clearbytes (p, longsizeof (tyconfigrecord)); /*initalize all fields to 0*/
00064     
00065     (*p).flhorizscroll = true;
00066     
00067     (*p).flvertscroll = true;
00068     
00069     (*p).flmessagearea = true;
00070     
00071     (*p).flgrowable = true;
00072     
00073     (*p).messageareafraction = 3;
00074     
00075     (*p).filecreator = typeunknown;
00076     
00077     (*p).filetype = typeunknown;
00078 
00079 #ifdef MACVERSION
00080     (*p).defaultfont = systemFont;
00081 #endif
00082 #ifdef WIN95VERSION
00083     (*p).defaultfont = 0;
00084 #endif
00085 
00086     (*p).defaultsize = 12;
00087     } /*initconfigrecord*/
00088 
00089 
00090 void loadconfigresource (short configresnum, tyconfigrecord *cr) {
00091     
00092     /*
00093     2.1b5 dmb: release the config resource when done with it
00094     
00095     2006-04-16 aradke: swap byte-order on Intel Macs
00096     */
00097     
00098     register Handle h;
00099     bigstring bs;
00100     
00101     h = getresourcehandle (configresourcetype, configresnum);
00102 
00103     if (h != nil) {
00104     
00105         moveleft (*h, cr, sizeof (tyconfigrecord)); 
00106     
00107         releaseresourcehandle (h);
00108         
00109         reztomemshort ((*cr).flhorizscroll);
00110     
00111         reztomemshort ((*cr).flvertscroll);
00112     
00113         reztomemshort ((*cr).flwindowfloats);
00114     
00115         reztomemshort ((*cr).flmessagearea);
00116     
00117         reztomemshort ((*cr).flinsetcontentrect);
00118     
00119         reztomemshort ((*cr).flnewonlaunch);
00120     
00121         reztomemshort ((*cr).flopenresfile);
00122     
00123         reztomemshort ((*cr).fldialog);
00124     
00125         reztomemshort ((*cr).flgrowable);
00126     
00127         reztomemshort ((*cr).flcreateonnew);
00128     
00129         reztomemshort ((*cr).flwindoidscrollbars);
00130     
00131         reztomemshort ((*cr).flstoredindatabase);
00132     
00133         reztomemshort ((*cr).flparentwindowhandlessave);
00134     
00135         reztomemshort ((*cr).fleraseonresize);
00136     
00137         reztomemshort ((*cr).fldontconsumefrontclicks);
00138     
00139         reztomemshort ((*cr).flcolorwindow);
00140 
00141         reztomemshort ((*cr).messageareafraction);
00142 
00143         reztomemlong ((*cr).filecreator);   /* OSType */
00144         
00145         reztomemlong ((*cr).filetype);  /* OSType */
00146         
00147         reztomemrect ((*cr).rmin);
00148         
00149         reztomemshort ((*cr).templateresnum);
00150         
00151         reztomemshort ((*cr).defaultfont);
00152         
00153         reztomemshort ((*cr).defaultsize);
00154         
00155         reztomemshort ((*cr).defaultstyle);
00156         
00157         reztomemshort ((*cr).idbuttonstringlist);
00158         
00159         reztomemrect ((*cr).defaultwindowrect);
00160         
00161         getstringlist (fontnamelistnumber, (*cr).defaultfont, bs);
00162         
00163         fontgetnumber (bs, &(*cr).defaultfont);
00164         
00165         centerrectondesktop (&(*cr).defaultwindowrect);
00166         }
00167     else
00168         initconfigrecord (cr);
00169     } /*loadconfigresource*/
00170     
00171     
00172 /*
00173 boolean saveconfigresource (short configresnum, tyconfigrecord *cr) {
00174 
00175     Handle h;
00176     
00177     h = GetResource (configresourcetype, configresnum);
00178     
00179     if (h != nil) { /%resource already exists%/
00180     
00181         moveleft ((ptrchar) cr, (ptrchar) *h, longsizeof (tyconfigrecord)); 
00182         
00183         ChangedResource (h);
00184         }
00185     else {
00186         if (!newfilledhandle ((ptrchar) cr, longsizeof (tyconfigrecord), &h)) 
00187             return (false);
00188         
00189         AddResource (h, configresourcetype, configresnum, emptystring);
00190         }
00191         
00192     return (ResError () == noErr);
00193     } /%saveconfigresource*/
00194     
00195     
00196 boolean getprogramname (bigstring bs) {
00197     
00198     return (getstringlist (defaultlistnumber, programname, bs));
00199     } /*getprogramname*/
00200     
00201     
00202 boolean getuntitledfilename (bigstring bs) {
00203     
00204     /*
00205     5.0d6 dmb: added numeric sequencing
00206     */
00207     
00208     static long untitledsequencer = 0;
00209     
00210     if (!getstringlist (defaultlistnumber, untitledfilename, bs))
00211         return (false);
00212     
00213     if (++untitledsequencer > 1) {
00214     
00215         pushchar ('-', bs);
00216         
00217         pushlong (untitledsequencer, bs);
00218         }
00219     
00220     return (true);
00221     } /*getuntitledfilename*/
00222     
00223     
00224 boolean getdefaultfilename (bigstring bs) {
00225     
00226     return (getstringlist (defaultlistnumber, defaultfilename, bs));
00227     } /*getdefaultfilename*/
00228     
00229 /*
00230 boolean getusername (bigstring bs) {
00231     
00232     return (getstringlist (defaultlistnumber, username, bs));
00233     } /%getusername*/
00234     
00235     
00236 void initconfig (void) {
00237     
00238     initconfigrecord (&config);
00239     } /*initconfig*/
00240     
00241     
00242     

Generated on Wed May 31 18:19:47 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6