home *** CD-ROM | disk | FTP | other *** search
- /*
- * PrefsDlg.c
- * (C) SPDsoft, August 13, 1995
- *
- * Prefs Dialog
- */
-
- /*
- * THINK_C 8.0 extra includes (Not in MacHeaders)
- */
-
- #include <Balloons.h>
- #include <Aliases.h>
-
-
- #include "GzErrors.h"
- #include "ErrorStrings.h"
- #include "GzPStrings.h"
-
- #include "PrefsDlg.h"
- #include "Prefs.h"
-
- #include "tailor.h" /* for MAX_SUFFIX */
-
- /*
- * Globals
- */
-
- AliasHandle gOriginalAliasHdl;
-
- /*
- * Prototypes
- */
-
- Boolean DoPrefsDialog(PrefsTypePtr thePrefs, AliasHandle * theFldrAlias);
-
- static void DoItem( DialogPtr DlgPtr, short item,
- DlgInfoPtr myDlgInfo, PrefsTypePtr thePrefs, AliasHandle *FldrAlias );
- static void SetItems( DialogPtr DlgPtr,
- DlgInfoPtr myDlgInfo, PrefsTypePtr thePrefs, AliasHandle *FldrAlias );
-
- static Boolean GetItems( DialogPtr DlgPtr,
- DlgInfoPtr myDlgInfo, PrefsTypePtr thePrefs );
-
- static void SetUpDitl( DialogPtr DlgPtr, DlgInfoPtr myDlgInfo, PrefsTypePtr thePrefs );
- static void CleanDitl( DialogPtr DlgPtr, DlgInfoPtr myDlgInfo );
-
- static Boolean GetItemValue( DialogPtr DlgPtr, short item, short *value);
- static void SetItemValue( DialogPtr DlgPtr, short item, short value);
- static void SetItemText( DialogPtr DlgPtr, short item, Str255 pstr, Boolean quote);
- static void DisableDItem( DialogPtr DlgPtr, short item);
- static void EnableDItem( DialogPtr DlgPtr, short item);
-
- /*
- * main function
- */
-
- Boolean DoPrefsDialog(PrefsTypePtr thePrefs, AliasHandle * theFldrAlias)
- {
- GrafPtr savePort;
- DialogPtr DlgPtr;
- short itemHit;
- Boolean DlgDone;
- Boolean SaveBalloons;
- ModalFilterUPP ModalUPP;
-
- Boolean result = false;
- PrefsType tmpPrefs; /* work on these */
- AliasHandle FldrAlias; /* instead of originals */
- extern PrefsType DefaultPrefs;
-
- static DlgInfo myDlgInfo =
- {
- {
- kPrefgzipDITL_ID,
- kPrefCompDITL_ID,
- kPrefDecoDITL_ID,
- kPrefFoldDITL_ID,
- kPrefMiscDITL_ID
- },
- 0, /* Number of items in layout DITL */
- pmPrefgzip
- };
-
- if ( nil == (DlgPtr = GetNewDialog(kPrefGenPDLOG_ID, nil, (WindowPtr) -1)))
- {
- if ( noErr == (err = ResError())) err = resFNotFound;
- DoError(SYS_ERR,QUIT_ERR,GetErrFmt(RES_MANAGER, RES_NOTFOUND));
- }
-
- BlockMove(thePrefs, &tmpPrefs, sizeof(tmpPrefs));
- gOriginalAliasHdl = *theFldrAlias;
- FldrAlias = *theFldrAlias;
-
- GetPort(&savePort);
- SetPort(DlgPtr);
-
- SetDialogDefaultItem( DlgPtr, kPrefComm_OK_ID);
- SetDialogCancelItem( DlgPtr, kPrefComm_Cancel_ID);
-
- if (noErr != (err = GetStdFilterProc(&ModalUPP)) )
- {
- DoError(SYS_ERR,QUIT_ERR,GetErrFmt(GENERIC, NOT_UPP), 1);
- }
-
- myDlgInfo.BaseDITL = CountDITL( DlgPtr );
- SetItemValue( DlgPtr, kPrefComm_Menu_ID, myDlgInfo.Selection );
- SetUpDitl( DlgPtr, &myDlgInfo, &tmpPrefs);
- SetItems( DlgPtr, &myDlgInfo, &tmpPrefs, &FldrAlias);
-
- /*
- * Initial Dlg values
- */
-
- SaveBalloons = HMGetBalloons();
- SetItemValue( DlgPtr, kPrefComm_Help_ID, (short) SaveBalloons );
-
- for( DlgDone = FALSE; !DlgDone ; )
- {
- ModalDialog(ModalUPP, &itemHit);
-
- switch ( itemHit )
- {
- case kPrefComm_OK_ID:
-
- /*
- * Save Dlg Prefs
- */
- if (GetItems( DlgPtr, &myDlgInfo, &tmpPrefs ))
- {
- BlockMove(&tmpPrefs, thePrefs, sizeof(tmpPrefs));
-
- if (*theFldrAlias != FldrAlias)
- {
- if (*theFldrAlias != nil)
- DisposHandle((Handle) *theFldrAlias);
-
- *theFldrAlias = FldrAlias;
- }
- DlgDone = TRUE;
- result = TRUE;
- }
- break;
-
- case kPrefComm_Cancel_ID:
-
- /*
- * Discard Dlg Prefs
- */
-
- DlgDone = TRUE;
- break;
-
- case kPrefComm_Dflt_ID:
-
- /*
- * Set Defaults
- */
- switch( myDlgInfo.Selection )
- {
- case pmPrefgzip:
- BlockMove(& DefaultPrefs.gzip, & tmpPrefs.gzip, sizeof(gzip_prefs));
- break;
-
- case pmPrefcomp:
- BlockMove(& DefaultPrefs.Compress, & tmpPrefs.Compress, sizeof(Compress_prefs));
- break;
-
- case pmPrefdeco:
- BlockMove(& DefaultPrefs.Decompress, & tmpPrefs.Decompress, sizeof(Decompress_prefs));
- break;
-
- case pmPreffold:
- BlockMove(& DefaultPrefs.Folder, & tmpPrefs.Folder, sizeof(Folder_prefs));
- break;
-
- case pmPrefmisc:
- BlockMove(& DefaultPrefs.Misc, & tmpPrefs.Misc, sizeof(Misc_prefs));
- break;
-
- default:
- break;
- }
- SetItems( DlgPtr, &myDlgInfo, &tmpPrefs, &FldrAlias );
-
- break;
-
- case kPrefComm_Help_ID:
-
- /*
- * Balloon Help on/off
- */
- HMSetBalloons(!HMGetBalloons());
- SetItemValue( DlgPtr, kPrefComm_Help_ID, (short) HMGetBalloons() );
-
- break;
-
- case kPrefComm_Menu_ID:
-
- /*
- * Change DITL
- */
- if (GetItems( DlgPtr, &myDlgInfo, &tmpPrefs ))
- {
- if ( GetItemValue( DlgPtr, kPrefComm_Menu_ID, &(myDlgInfo.Selection)))
- {
- CleanDitl(DlgPtr, &myDlgInfo);
- SetUpDitl(DlgPtr, &myDlgInfo, &tmpPrefs);
- SetItems( DlgPtr, &myDlgInfo, &tmpPrefs, &FldrAlias );
- }
- }
- else
- SetItemValue( DlgPtr, kPrefComm_Menu_ID, myDlgInfo.Selection);
-
- break;
-
- default:
-
- DoItem( DlgPtr, itemHit, &myDlgInfo, &tmpPrefs, &FldrAlias );
- break;
- }
-
- }
-
- HMSetBalloons(SaveBalloons);
-
- SetPort(savePort);
- DisposeRoutineDescriptor (ModalUPP);
- DisposDialog(DlgPtr);
- return result;
- }
-
-
- /*
- * Manage extra DITL's
- */
-
- static void SetUpDitl( DialogPtr DlgPtr, DlgInfoPtr myDlgInfo, PrefsTypePtr thePrefs )
- {
- Handle addDitl;
-
- if (nil == (addDitl =
- GetResource( 'DITL', myDlgInfo->ExtraDITL[myDlgInfo->Selection - 1] )))
- {
- if ( noErr == (err = ResError())) err = resFNotFound;
- DoError(SYS_ERR,QUIT_ERR,GetErrFmt(RES_MANAGER, RES_NOTFOUND));
- }
-
- HLock( addDitl );
- AppendDITL( DlgPtr, addDitl, myDlgInfo->BaseDITL );
- HUnlock( addDitl );
- ReleaseResource( addDitl );
-
- }
-
- static void CleanDitl( DialogPtr DlgPtr, DlgInfoPtr myDlgInfo )
- {
- ShortenDITL( DlgPtr, CountDITL( DlgPtr ) - myDlgInfo->BaseDITL );
- }
-
- /*
- * Set/get values for controls (access by Item ID)
- */
-
- static Boolean GetItemValue( DialogPtr DlgPtr, short item, short *value)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- short newValue;
-
- GetDialogItem( DlgPtr, item, &itemType, &itemHandle, &itemRect);
- newValue = GetControlValue( (ControlHandle)itemHandle);
-
- if ( *value == newValue )
- return FALSE;
- else
- {
- *value = newValue;
- return TRUE;
- }
- }
-
- static void SetItemValue( DialogPtr DlgPtr, short item, short value)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- GetDialogItem( DlgPtr, item, &itemType, &itemHandle, &itemRect);
- SetControlValue( (ControlHandle) itemHandle, value );
- }
-
- static void SetItemText( DialogPtr DlgPtr, short item, Str255 pstr, Boolean quote)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- Str255 sTemp;
-
- if (quote)
- {
- sTemp[0] = 0x00;
- PStrCat( sTemp, "\p ā");
- PStrCat( sTemp, pstr);
- PStrCat( sTemp, "\pā");
- }
- else
- {
- PStrCpy( sTemp, pstr );
- }
-
- GetDialogItem( DlgPtr, item, &itemType, &itemHandle, &itemRect);
- /*
- * OJO: should adjust strlen to item rect...
- */
- SetIText( itemHandle, sTemp );
- }
-
- static void DisableDItem( DialogPtr DlgPtr, short item)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- GetDialogItem( DlgPtr, item, &itemType, &itemHandle, &itemRect);
- HiliteControl( (ControlHandle) itemHandle, 255 );
- }
-
- static void EnableDItem( DialogPtr DlgPtr, short item)
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
-
- GetDialogItem( DlgPtr, item, &itemType, &itemHandle, &itemRect);
- HiliteControl( (ControlHandle) itemHandle, 0 );
- }
- /******************************************************************************/
-
- static void DoItem( DialogPtr DlgPtr, short item,
- DlgInfoPtr myDlgInfo, PrefsTypePtr thePrefs, AliasHandle *FldrAlias )
-
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- short value=-1;
- Str255 sTemp;
-
- extern Boolean SFGetFolder(FSSpec *fSpec);
- FSSpec fSpec;
-
-
-
- GetDialogItem( DlgPtr, item, &itemType, &itemHandle, &itemRect);
-
- switch( myDlgInfo->Selection )
- {
- case pmPrefgzip:
-
- switch( item - myDlgInfo->BaseDITL )
- {
- case kPrefgzip_Force:
-
- value = thePrefs->gzip.Force = !thePrefs->gzip.Force;
- break;
-
- case kPrefgzip_NoName:
-
- value = thePrefs->gzip.NoName = !thePrefs->gzip.NoName;
-
- if ( value && thePrefs->gzip.Name )
- {
- SetItemValue( DlgPtr, kPrefgzip_Name + myDlgInfo->BaseDITL, FALSE);
- thePrefs->gzip.Name = FALSE;
- }
-
- break;
-
- case kPrefgzip_Name:
-
- value = thePrefs->gzip.Name = !thePrefs->gzip.Name;
-
- if ( value && thePrefs->gzip.NoName )
- {
- SetItemValue( DlgPtr, kPrefgzip_NoName + myDlgInfo->BaseDITL, FALSE);
- thePrefs->gzip.NoName = FALSE;
- }
-
- break;
-
- case kPrefgzip_Custom:
-
- value = thePrefs->gzip.UseCustomSuffix = !thePrefs->gzip.UseCustomSuffix;
-
- if ( value )
- {
- ShowDialogItem( DlgPtr, kPrefgzip_Suffix + myDlgInfo->BaseDITL);
- EnableDItem( DlgPtr, kPrefgzip_GunSuff + myDlgInfo->BaseDITL);
- }
- else
- {
- HideDialogItem( DlgPtr, kPrefgzip_Suffix + myDlgInfo->BaseDITL);
- DisableDItem( DlgPtr, kPrefgzip_GunSuff + myDlgInfo->BaseDITL);
- }
-
- break;
-
- case kPrefgzip_GunSuff:
-
- value = thePrefs->gzip.GunzipSuffix = !thePrefs->gzip.GunzipSuffix;
- break;
-
- case kPrefgzip_Up:
-
- if ( thePrefs->gzip.Level < 9 )
- {
- thePrefs->gzip.Level ++;
- InvertRect(&itemRect);
- while (StillDown())
- ;
- InvertRect(&itemRect);
- GetDialogItem( DlgPtr, kPrefgzip_Level + myDlgInfo->BaseDITL, &itemType, &itemHandle, &itemRect);
- NumToString( (long)thePrefs->gzip.Level, sTemp );
- SetIText(itemHandle,sTemp);
- }
- break;
-
- case kPrefgzip_Down:
-
- if ( thePrefs->gzip.Level > 1 )
- {
- thePrefs->gzip.Level --;
- InvertRect(&itemRect);
- while (StillDown())
- ;
- InvertRect(&itemRect);
- GetDialogItem( DlgPtr, kPrefgzip_Level + myDlgInfo->BaseDITL, &itemType, &itemHandle, &itemRect);
- NumToString( (long)thePrefs->gzip.Level, sTemp );
- SetIText(itemHandle,sTemp);
- }
- break;
- }
- break;
-
- case pmPrefcomp:
- switch( item - myDlgInfo->BaseDITL )
- {
- case kPrefComp_Keys:
- value = thePrefs->Compress.Keys = !thePrefs->Compress.Keys;
- break;
- case kPrefComp_IC:
- value = thePrefs->Compress.IC = !thePrefs->Compress.IC;
- if ( thePrefs->Compress.IC )
- {
- EnableDItem( DlgPtr, kPrefComp_ASCII + myDlgInfo->BaseDITL );
- EnableDItem( DlgPtr, kPrefComp_NotMB + myDlgInfo->BaseDITL );
- }
- else
- {
- DisableDItem( DlgPtr, kPrefComp_ASCII + myDlgInfo->BaseDITL );
- DisableDItem( DlgPtr, kPrefComp_NotMB + myDlgInfo->BaseDITL );
- }
-
- break;
- case kPrefComp_ASCII:
- value = thePrefs->Compress.IC_ASCII = !thePrefs->Compress.IC_ASCII;
- break;
- case kPrefComp_NotMB:
- value = thePrefs->Compress.IC_NotMB = !thePrefs->Compress.IC_NotMB;
- break;
- case kPrefComp_RFPopup:
- GetItemValue( DlgPtr, item, &(thePrefs->Compress.ResFork));
- break;
- case kPrefComp_ModePopup:
- if ( GetItemValue( DlgPtr, item, &(thePrefs->Compress.Mode)))
- {
- if ( thePrefs->Compress.Mode == pmPrefComp_MBin )
- ShowDialogItem( DlgPtr, kPrefComp_ModeA + myDlgInfo->BaseDITL);
- else
- HideDialogItem( DlgPtr, kPrefComp_ModeA + myDlgInfo->BaseDITL);
- }
- break;
- case kPrefComp_ModeA:
- value = thePrefs->Compress.Mode_a = !thePrefs->Compress.Mode_a;
- break;
- }
- break;
-
-
- case pmPrefdeco:
- switch( item - myDlgInfo->BaseDITL )
- {
- case kPrefDeco_Keys:
- value = thePrefs->Decompress.Keys = !thePrefs->Decompress.Keys;
- break;
- case kPrefDeco_IC:
- value = thePrefs->Decompress.IC = !thePrefs->Decompress.IC;
-
- if ( value && thePrefs->Decompress.Fetch )
- {
- SetItemValue( DlgPtr, kPrefDeco_Fetch + myDlgInfo->BaseDITL, FALSE);
- thePrefs->Decompress.Fetch = FALSE;
- }
- break;
-
- case kPrefDeco_Fetch:
- value = thePrefs->Decompress.Fetch = !thePrefs->Decompress.Fetch;
-
- if ( value && thePrefs->Decompress.IC )
- {
- SetItemValue( DlgPtr, kPrefDeco_IC + myDlgInfo->BaseDITL, FALSE);
- thePrefs->Decompress.IC = FALSE;
- }
-
- break;
- case kPrefDeco_MB:
- value = thePrefs->Decompress.TryMB = !thePrefs->Decompress.TryMB;
- break;
- case kPrefDeco_MPopup:
- GetItemValue( DlgPtr, item, &(thePrefs->Decompress.Mode));
- break;
- default:
- break;
- }
- break;
-
- case pmPreffold:
- switch( item - myDlgInfo->BaseDITL )
- {
- case kPrefFold_FNot:
- case kPrefFold_FFold:
- case kPrefFold_FAll:
-
- SetItemValue( DlgPtr, thePrefs->Folder.RecurseMode + myDlgInfo->BaseDITL, 0 );
- thePrefs->Folder.RecurseMode = item - myDlgInfo->BaseDITL;
- value = 1;
- break;
-
- case kPrefFold_UseDest:
-
- /*
- * SFGetFolder
- */
-
- SetItemText( DlgPtr, kPrefFold_Dest + myDlgInfo->BaseDITL, "\p", FALSE);
-
- if (!thePrefs->Folder.UseDestFolder)
- {
- if ( SFGetFolder(&fSpec) )
- {
- if ((*FldrAlias != gOriginalAliasHdl) && ( *FldrAlias != nil ))
- DisposHandle((Handle) *FldrAlias);
-
- if ( noErr != (err=NewAlias(nil, &fSpec, FldrAlias)) )
- {
- *FldrAlias = nil;
-
- DoError(SYS_ERR,INFO_ERR,GetErrFmt(GENERIC, NOT_ALIAS));
-
- }
- else
- {
- value = thePrefs->Folder.UseDestFolder = TRUE;
- SetItemText( DlgPtr, kPrefFold_Dest + myDlgInfo->BaseDITL,
- fSpec.name, TRUE);
- }
- }
- }
- else
- value = thePrefs->Folder.UseDestFolder = FALSE;
-
-
-
- break;
- }
- break;
-
- case pmPrefmisc:
- switch( item - myDlgInfo->BaseDITL )
- {
- case kPrefMisc_KeepOrig:
- value = thePrefs->Misc.KeepOriginal = !thePrefs->Misc.KeepOriginal;
- break;
- case kPrefMisc_Beep:
- value = thePrefs->Misc.BeepWhenDone = !thePrefs->Misc.BeepWhenDone;
- break;
- case kPrefMisc_Quit:
- value = thePrefs->Misc.QuitWhenDone = !thePrefs->Misc.QuitWhenDone;
- break;
- case kPrefMisc_Keys:
- value = thePrefs->Misc.Keys = !thePrefs->Misc.Keys;
- break;
- case kPrefMisc_SelPopup:
- GetItemValue( DlgPtr, item, &(thePrefs->Misc.DefaultOp));
- break;
- case kPrefMisc_Reset:
- thePrefs->SavedPos = TRUE;
- thePrefs->SavedPoint.v = 80;
- thePrefs->SavedPoint.h = 80;
- break;
- }
-
- default:
- break;
- }
- if (( itemType & ctrlItem ) && ( value != -1 ))
- SetControlValue( (ControlHandle) itemHandle, value );
- }
-
- static void SetItems( DialogPtr DlgPtr,
- DlgInfoPtr myDlgInfo, PrefsTypePtr thePrefs, AliasHandle *FldrAlias )
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- Str255 sTemp;
-
- switch( myDlgInfo->Selection )
- {
- case pmPrefgzip:
-
- SetItemValue( DlgPtr, kPrefgzip_Force + myDlgInfo->BaseDITL, thePrefs->gzip.Force);
- SetItemValue( DlgPtr, kPrefgzip_NoName + myDlgInfo->BaseDITL, thePrefs->gzip.NoName);
- SetItemValue( DlgPtr, kPrefgzip_Name + myDlgInfo->BaseDITL, thePrefs->gzip.Name);
- SetItemValue( DlgPtr, kPrefgzip_Custom + myDlgInfo->BaseDITL, thePrefs->gzip.UseCustomSuffix);
- if ( thePrefs->gzip.UseCustomSuffix )
- {
- ShowDialogItem( DlgPtr, kPrefgzip_Suffix + myDlgInfo->BaseDITL);
- EnableDItem( DlgPtr, kPrefgzip_GunSuff + myDlgInfo->BaseDITL);
- }
- else
- {
- HideDialogItem( DlgPtr, kPrefgzip_Suffix + myDlgInfo->BaseDITL);
- DisableDItem( DlgPtr, kPrefgzip_GunSuff + myDlgInfo->BaseDITL);
- }
- SetItemValue( DlgPtr, kPrefgzip_GunSuff + myDlgInfo->BaseDITL, thePrefs->gzip.GunzipSuffix);
- GetDialogItem( DlgPtr, kPrefgzip_Level + myDlgInfo->BaseDITL, &itemType, &itemHandle, &itemRect);
- NumToString( (long)thePrefs->gzip.Level, sTemp );
- SetIText(itemHandle,sTemp);
- GetDialogItem(DlgPtr, kPrefgzip_Suffix + myDlgInfo->BaseDITL, &itemType, &itemHandle, &itemRect);
- SetIText(itemHandle, thePrefs->gzip.Suffix);
- if(thePrefs->gzip.Suffix[0]!=0x00)
- SelIText(DlgPtr, kPrefgzip_Suffix + myDlgInfo->BaseDITL, 0, 32767);
- break;
-
- case pmPrefcomp:
-
- SetItemValue( DlgPtr, kPrefComp_Keys + myDlgInfo->BaseDITL, thePrefs->Compress.Keys);
- SetItemValue( DlgPtr, kPrefComp_IC + myDlgInfo->BaseDITL, thePrefs->Compress.IC);
- SetItemValue( DlgPtr, kPrefComp_ASCII + myDlgInfo->BaseDITL, thePrefs->Compress.IC_ASCII);
- SetItemValue( DlgPtr, kPrefComp_NotMB + myDlgInfo->BaseDITL, thePrefs->Compress.IC_NotMB);
- SetItemValue( DlgPtr, kPrefComp_RFPopup + myDlgInfo->BaseDITL, thePrefs->Compress.ResFork);
- SetItemValue( DlgPtr, kPrefComp_ModePopup + myDlgInfo->BaseDITL, thePrefs->Compress.Mode);
- SetItemValue( DlgPtr, kPrefComp_ModeA + myDlgInfo->BaseDITL, thePrefs->Compress.Mode_a);
-
- if ( thePrefs->Compress.IC )
- {
- EnableDItem( DlgPtr, kPrefComp_ASCII + myDlgInfo->BaseDITL );
- EnableDItem( DlgPtr, kPrefComp_NotMB + myDlgInfo->BaseDITL );
- }
- else
- {
- DisableDItem( DlgPtr, kPrefComp_ASCII + myDlgInfo->BaseDITL );
- DisableDItem( DlgPtr, kPrefComp_NotMB + myDlgInfo->BaseDITL );
- }
-
- if ( thePrefs->Compress.Mode == pmPrefComp_MBin )
- ShowDialogItem( DlgPtr, kPrefComp_ModeA + myDlgInfo->BaseDITL);
- else
- HideDialogItem( DlgPtr, kPrefComp_ModeA + myDlgInfo->BaseDITL);
-
- break;
-
- case pmPrefdeco:
-
- SetItemValue( DlgPtr, kPrefDeco_Keys + myDlgInfo->BaseDITL, thePrefs->Decompress.Keys);
- SetItemValue( DlgPtr, kPrefDeco_IC + myDlgInfo->BaseDITL, thePrefs->Decompress.IC);
- SetItemValue( DlgPtr, kPrefDeco_Fetch + myDlgInfo->BaseDITL, thePrefs->Decompress.Fetch);
- SetItemValue( DlgPtr, kPrefDeco_MB + myDlgInfo->BaseDITL, thePrefs->Decompress.TryMB);
-
- OSTypeToStr255( sTemp, &thePrefs->Decompress.TextCreator );
- GetDialogItem(DlgPtr, kPrefDeco_CText + myDlgInfo->BaseDITL, &itemType, &itemHandle, &itemRect);
- SetIText(itemHandle, sTemp);
- SelIText(DlgPtr, kPrefDeco_CText + myDlgInfo->BaseDITL, 0, 32767);
-
- OSTypeToStr255( sTemp, &thePrefs->Decompress.BinType );
- GetDialogItem(DlgPtr, kPrefDeco_TBin + myDlgInfo->BaseDITL, &itemType, &itemHandle, &itemRect);
- SetIText(itemHandle, sTemp);
-
- OSTypeToStr255( sTemp, &thePrefs->Decompress.BinCreator );
- GetDialogItem(DlgPtr, kPrefDeco_CBin + myDlgInfo->BaseDITL, &itemType, &itemHandle, &itemRect);
- SetIText(itemHandle, sTemp);
-
- SetItemValue( DlgPtr, kPrefDeco_MPopup + myDlgInfo->BaseDITL, thePrefs->Decompress.Mode);
-
- break;
-
- case pmPreffold:
-
- SetItemValue( DlgPtr, kPrefFold_FNot + myDlgInfo->BaseDITL, 0 );
- SetItemValue( DlgPtr, kPrefFold_FFold + myDlgInfo->BaseDITL, 0 );
- SetItemValue( DlgPtr, kPrefFold_FAll + myDlgInfo->BaseDITL, 0 );
- SetItemValue( DlgPtr, thePrefs->Folder.RecurseMode + myDlgInfo->BaseDITL, 1 );
-
- SetItemText( DlgPtr, kPrefFold_Dest + myDlgInfo->BaseDITL, "\p", FALSE);
-
- if (( thePrefs->Folder.UseDestFolder ) && (*FldrAlias!=nil))
- {
- FSSpec fSpec;
- Boolean changedFlag;
-
- if( noErr == ResolveAlias(nil, *FldrAlias, &fSpec, &changedFlag))
- SetItemText( DlgPtr, kPrefFold_Dest + myDlgInfo->BaseDITL, fSpec.name, TRUE);
- else
- {
- thePrefs->Folder.UseDestFolder = FALSE;
- }
- }
- else
- {
- thePrefs->Folder.UseDestFolder = FALSE;
- }
-
- SetItemValue( DlgPtr, kPrefFold_UseDest + myDlgInfo->BaseDITL, thePrefs->Folder.UseDestFolder );
-
-
- break;
-
- case pmPrefmisc:
-
- SetItemValue( DlgPtr, kPrefMisc_KeepOrig + myDlgInfo->BaseDITL, thePrefs->Misc.KeepOriginal);
- SetItemValue( DlgPtr, kPrefMisc_Beep + myDlgInfo->BaseDITL, thePrefs->Misc.BeepWhenDone);
- SetItemValue( DlgPtr, kPrefMisc_Quit + myDlgInfo->BaseDITL, thePrefs->Misc.QuitWhenDone);
- SetItemValue( DlgPtr, kPrefMisc_Keys + myDlgInfo->BaseDITL, thePrefs->Misc.Keys);
- SetItemValue( DlgPtr, kPrefMisc_SelPopup + myDlgInfo->BaseDITL, thePrefs->Misc.DefaultOp);
- break;
-
- default:
- break;
- }
- }
-
- /* Get editText fields */
-
- static Boolean GetItems( DialogPtr DlgPtr,
- DlgInfoPtr myDlgInfo, PrefsTypePtr thePrefs )
- {
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- Str255 sTemp;
- Boolean result;
-
- result = TRUE;
-
- switch( myDlgInfo->Selection )
- {
- case pmPrefgzip:
- GetDialogItem(DlgPtr, kPrefgzip_Suffix + myDlgInfo->BaseDITL, &itemType, &itemHandle, &itemRect);
-
- if (thePrefs->gzip.UseCustomSuffix)
- {
- GetIText(itemHandle, thePrefs->gzip.Suffix);
-
- if ((thePrefs->gzip.Suffix[0] == 0) || (thePrefs->gzip.Suffix[0] > MAX_SUFFIX ))
- {
- DoError(INPUT_ERR,INFO_ERR,GetErrFmt(USER_ERROR,BAD_SUFFIX), 1, MAX_SUFFIX);
- if (thePrefs->gzip.Suffix[0] != 0)
- SelIText(DlgPtr, kPrefgzip_Suffix + myDlgInfo->BaseDITL,0,32767);
- result = FALSE;
- }
- }
- break;
-
- case pmPrefcomp:
- break;
-
- case pmPrefdeco:
-
- GetDialogItem(DlgPtr, kPrefDeco_CText + myDlgInfo->BaseDITL, &itemType, &itemHandle, &itemRect);
- GetIText(itemHandle, sTemp);
-
- if (sTemp[0] != 4)
- {
- DoError(INPUT_ERR,INFO_ERR,GetErrFmt(USER_ERROR,BAD_CTEXT));
- if (sTemp[0] != 0)
- SelIText(DlgPtr, kPrefDeco_CText + myDlgInfo->BaseDITL,0,32767);
- result = FALSE;
- break;
- }
-
- thePrefs->Decompress.TextCreator = Str255ToOSType( sTemp );
-
- GetDialogItem(DlgPtr, kPrefDeco_TBin + myDlgInfo->BaseDITL, &itemType, &itemHandle, &itemRect);
- GetIText(itemHandle, sTemp);
-
- if (sTemp[0] != 4)
- {
- DoError(INPUT_ERR,INFO_ERR,GetErrFmt(USER_ERROR,BAD_TBIN));
- if (sTemp[0] != 0)
- SelIText(DlgPtr, kPrefDeco_TBin + myDlgInfo->BaseDITL,0,32767);
- result = FALSE;
- break;
- }
-
- thePrefs->Decompress.BinType = Str255ToOSType( sTemp );
-
- GetDialogItem(DlgPtr, kPrefDeco_CBin + myDlgInfo->BaseDITL, &itemType, &itemHandle, &itemRect);
- GetIText(itemHandle, sTemp);
-
- if (sTemp[0] != 4)
- {
- DoError(INPUT_ERR,INFO_ERR,GetErrFmt(USER_ERROR,BAD_CBIN));
- if (sTemp[0] != 0)
- SelIText(DlgPtr, kPrefDeco_CBin + myDlgInfo->BaseDITL,0,32767);
- result = FALSE;
- break;
- }
-
- thePrefs->Decompress.BinCreator = Str255ToOSType( sTemp );
-
- break;
-
- case pmPreffold:
- break;
-
- case pmPrefmisc:
- break;
-
- default:
- break;
- }
- return result;
- }
-
-
- /******************************************************************************/
-
- PrefsType DefaultPrefs =
- {
- kCurrentPrefsTypeVers,
- TRUE, /* SavedPos */
- 0x00,
- {
- 80, /* v */
- 80 /* h */
- },
- {
- FALSE, /* Force */
- FALSE, /* NoName */
- TRUE, /* Name */
- FALSE, /* UseCustomSuffix */
- FALSE, /* GunzipSuffix */
- 0x00,
- 6, /* Level */
- "\p" /* Suffix */
- },
- {
- TRUE, /* Keys */
- TRUE, /* IC */
- FALSE, /* IC_ASCII */
- FALSE, /* IC_NotMB */
- kComp_RFAsk, /* ResFork */
- kComp_MBin, /* Mode */
- TRUE, /* Modea */
- },
- {
- TRUE, /* Keys */
- TRUE, /* IC */
- FALSE, /* Fetch */
- TRUE, /* TryMB */
- 'ttxt', /* TextCreator */
- '\?\?\?\?', /* BinType */
- '\?\?\?\?', /* BinCreator */
- kDeco_MBin /* Default Mode */
- },
- {
- kFold_FAll, /* RecurseMode */
- FALSE, /* UseDestFolder */
- 0x00,
- kFldrAliasResID /* folderAliasID */
- },
- {
- FALSE, /* KeepOriginal */
- TRUE, /* BeepWhenDone */
- TRUE, /* QuitWhenDone */
- TRUE, /* Keys */
- kMisc_auto /* DefaultCompress */
- }
- };
-
-
-
-
-