TweetFollow Us on Twitter

AutoSave
Volume Number:6
Issue Number:5
Column Tag:MacOOPs!

USavedMe Auto-Save Class

By Fred Condo Jr., Covina, CA

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

An Auto-Saving Document Class

[Fred Condo Jr. is a doctoral student of information science at the Claremont Graduate School.]

This article presents a new abstract document class for MacApp, TAutoSaveDocument, which allows the user to specify an interval after which the document automatically saves itself. Such a feature is useful in applications, such as word processing, in which a user is likely to make extensive changes to a document and lose track of time; this feature is definitely not good in applications where the user is likely to want to back out of changes with a Revert command.

TAutoSaveDocument is a subclass of TDocument, which MacApp defines. To use TAutoSaveDocument, you simply make your document class a subclass of it; even a completed MacApp application can be converted to use auto-saving documents in a matter of minutes. This speedy conversion is one of the benefits of object-oriented programming and MacApp.

Design considerations

I designed USavedMe, the Pascal unit that embodies TAutoSaveDocument, with the following results (some interrelated) in mind:

• Auto-saving should impose a minimal encumbrance on the end user.

• The interface to auto-saving should be through a modeless dialog.

• The dialog should be visually distinct from the document.

• The unit should be easy for programmers to use.

• It should take very little time to convert existing code.

• Complex search-and-replace operations on the source code of existing programs should not be needed.

• Program performance should not be degraded.

I used a modeless dialog in order to allow the user to summon the dialog and then decide to forget about it without dismissing it. This style of interface lets the user bring back the document or another window with a single click of the mouse; modal dialogs require the user first to find the Cancel button, then to click it, and finally to shift his or her attention to whatever it was that the dialog intruded upon. MacApp makes it so simple to invoke, use, and program modeless dialogs that there is no excuse for using a modal dialog unnecessarily. In the standard Macintosh Toolbox environment, modal dialogs are seductive, since they are significantly easier to code than are modeless dialogs. This factor is quite abolished under MacApp.

I chose rDocProc as the dialog window. Many designers of commercial applications have taken to using documentProc, the standard document window, for dialogs. Some people have been using documentProc for modal dialogs, which are supposed to be in dBoxProc windows. This is bad interface design. Users should be able to tell at a glance, without having to read a title or scan the contents of a window, what kind of window it is. Using the document window style indiscriminately puts an unnecessary cognitive burden on the user.

The round-cornered, inverse-titled window is fairly uncommon. Among Apple’s standard desk accessories, only the Calculator and the Puzzle use it. Its appearance is strikingly different from a document window’s. Inasmuch as DAs are essentially modeless dialogs, I would like to propose that such windows be used for modeless dialogs, instead of the document-style window. I believe that Apple should incorporate this recommendation into their human interface guidelines. Figure 1 shows a screen dump of Apple’s DrawShapes program as modified to use USavedMe.

Figure 1: Modeless dialogs and document windows

New document behavior

The unit USavedMe defines two classes: TAutoSaveDocument and TAutoSaveDialogView. The latter is the view class that implements the modeless dialog.

Besides its initialization routine, TAutoSaveDocument overrides four methods and implements one new method. The four overridden methods are Free, DoIdle, DoSetUpMenus, and DoMenuCommand. The new method is PoseAutoSaveDialog. In addition, the Fields method is overridden for debugging and inspector use.

The Free method simply checks to see if an associated dialog is open, which it tracks through the new fAutoSaveWindow field. If one exists, the document sends it a Close message, and calls INHERITED Free. Sending Close makes sure no dialogs are left floating around, which can happen with modeless, but not modal, dialogs.

MacApp calls DoIdle for any event handler in the command chain. For objects not installed as cohandlers, this means that the front-most, active document gets called at idle time to get some idle processing done. TAutoSaveDocument.DoIdle contains the code that determines whether the user-specified time has elapsed, and, if so, issues a Save message to itself. If anything were to degrade program performance, it would be this method. However, since it is called at intervals no smaller than 30 seconds, and since it is really a tiny bit of code, no perceptible degradation occurs. If your application’s documents are complex and large, of course, saving takes a while. In such cases, users should be advised not to set auto-saving to unnecessarily short intervals. Usually, 10 to 15 minutes make an adequate interval, balancing the desire to avoid re-doing work against the long time it takes to save.

When you make your application’s document class a descendent of TAutoSaveDocument, you will call INHERITED DoSetUpMenus, calling TAutoSaveDocument’s code (you do this in the normal course of MacApp programming). This allows the auto-save document to set up the two menu commands that it defines--“Auto-saving,” which is a check-mark item determining whether auto-saving is on, and “Set auto-save time,” which invokes the dialog. If you have been looking at the code listings (Listings 6 and 7), you may be wondering what the field fHasEverBeenSet is for. This field causes the “Auto-saving” menu item to be disabled until after the user has invoked and dismissed the dialog at least once. This prevents the user from turning on auto-saving without at least having seen what the default interval is. You may have a different design philosophy, and may want to alter this to allow auto-saving to be turned on regardless of whether the user has looked at the dialog.

You may also be wondering why “Set auto-save time” is disabled for untitled (actually, never-saved) documents. The reason is that, if you allow auto-saving to be invoked for a document that has no disk file, the user is presented with the SFPutFile dialog. If the user presses the Cancel button, the dialog is simply put back up, forcing the user to save the file, which is a rather ugly situation. The solution to this is to simply prevent auto-saving from being turned on before the file has first been saved “manually.” You may want to add a check box to SFPutFile that would allow the user to save and set auto-saving at the same time, or, alternatively, trap SFPutFile’s Cancel button to turn auto-saving off.

TAutoSaveDocument.DoMenuCommand accomplishes two things: first, it handles the two commands that USavedMe defines; second, it intercepts “Save” and “Save as ” commands. The reason for this is that the modeless dialog displays the name of the document to which it applies. Intercepting these commands allows the document to send any associated dialog a message telling it to update its document name.

PoseAutoSaveDialog reads the dialog from a view resource, sets the editable text item to the correct number, and adjusts a static text item so that, if the interval specified is 1 minute, the word “minute” is displayed instead of “minutes.” It then opens the modeless dialog window, which is then on its own.

Modeless dialog action

The other class defined in USavedMe is TAutoSaveDialogView, which has one field (fAutoSaveDocument) to hold a reference to its associated document. It overrides the following methods of TDialogView: Free, Close, DismissDialog, and, of course, Fields. It defines one new method, UpdateDocumentName, which was alluded to above.

Free sets the fAutoSaveWindow reference of TAutoSaveDocument to NIL, so that, when the dialog is freed, the document knows that it is gone. It then calls INHERITED Free.

There are two cases where the modeless dialog may be closed without being dismissed. One is when the user clicks the go-away box; the other is when the dialog’s document is closed. The purpose of overriding Close is to make these situations have the same result as dismissing the dialog by clicking the Cancel button. If this is not done, MacApp crashes when it tries to access the dialog view after it has been freed. The critical thing here is to set the dialog view’s fDismissed field to TRUE.

By the way, you may not agree that clicking the go-away box should be tantamount to pressing Cancel. One alternative to this might be to treat this form of dismissal like pressing the OK button only if the user has typed characters into the editable text item, and treating it like Cancel otherwise. Another alternative is simply to do away with the go-away box, making Cancel and OK the only ways to get rid of the dialog window besides closing the associated document.

DismissDialog is where the dialog gets to take its intended action. If Cancel is pressed, the dialog simply goes away. If OK is pressed, it validates the editable text, sets the appropriate fields of TAutoSaveDocument, and turns auto-saving on. Since the dialog view is enabled (in ViewEdit or in the Rez code), MacApp handles the Return, Enter, -., and Escape keys.

Using USavedMe in your code

As an example of converting an existing MacApp application to use auto-save documents, I chose Apple’s DrawShapes sample program. For the conversion, I had to make minor changes in MDrawShapes.p, UDrawShapes.p, UDrawShapes.inc1.p, and DrawShapes.r. Listings 1-4 show the changes made. Additions are shown in underline type; deletions are shown in strikeout type. DrawShapes doesn’t have a .MAMake (dependency) file, so I had to provide one to show the dependency of DrawShapes on USavedMe and of USavedMe on MacApp. The DrawShapes.MAMake file is shown in Listing 5.

In Listing 1 (changes to MDrawShapes.p), I have added USES specifications for USavedMe and the MacApp building blocks that USavedMe itself uses (UTEView and UDialog). Also, the initialization code now calls the initialization routines for these building blocks. (InitUSavedMe simply prevents the Linker from stripping out the code of TAutoSaveDialogView, which is to be instantiated from templates.)

Listing 3 shows that the only changes to UDrawShapes.p are a repetition of the above-mentioned USES declarations, and the substitution of TAutoSaveDocument for TDocument in the definition of the application’s document object class.

The changes to the implementation section, UDrawShapes.inc1.p, are even smaller, as shown in Listing 4. There, the only change is in the name of the initialization routine called from the IShapeDocument method. In the new case, rather than calling MacApp’s standard document initialization code (IDocument), you call IAutoSaveDocument instead. IAutoSaveDocument calls IDocument for you.

Listing 2 shows the Rez source changes for DrawShapes. Your program probably already uses template views, so you probably don’t have to add the lines to use them. The critical item is the line that includes the resource code for USavedMe. Also, note that the new definition for the File menu is simply MacApp’s default File menu, with USavedMe’s two commands inserted into it. In your code, you will want to simply add the two commands to your existing File menu. The Rez code for UsavedMe, which defines its view resource, is shown in Listing 8.

Idle Conflicts

What if your application wants its documents to get idle time, and your document type already implements DoIdle? In such a case, you would add one statement at the beginning of your DoIdle routine: DoIdle := INHERITED DoIdle(idlePhase);. In addition, IYourDocument, immediately after calling IAutoSaveDocument, should set the field fRespectIdleTime to TRUE. When this field is set, TAutoSaveDocument will not increase the value of fIdleFreq. This is particularly important if your documents are installed as MacApp cohandlers that require frequent idle processing. In the default case, fRespectIdleTime is FALSE, and toggling auto-saving off sets fIdleFreq to MAXLONGINT.

Conclusion

MacApp and object-oriented programming make small, incremental enhancements to existing functions exceedingly simple. This code only took a while to create because I was constantly running into problems with MacApp 2.0b5; under 2.0b9, I was able to finish this project in about a day. And, of course, using the finished code is a snap. What’s more, if you wanted to modify the behavior of auto-saving documents, you could do that extremely fast, too.

As Macintosh applications become more complex to perform more sophisticated tasks, a strict adherence to the philosophy behind the Macintosh user interface becomes ever more critical. The goal is to make using the computer as light a cognitive load on the user as possible. Using one kind of window for a wide variety of interactions can only cause the user to do more cognitive work, and is therefore inexcusable. By sticking to a clear visual expression of the different functions of document windows and dialogs, application designers will ease the load on the users, and automatically make their products more attractive. Visually distinctive, modeless dialogs are one way of accomplishing a good user interface. MacApp makes the production of such an interface very simple.

Listing 1: Changes to MDrawShapes.p
 
USES 
{ • MacApp } 
UMacApp, 
 
{ • Building Blocks } 
UPrinting, UTEView, UDialog, USavedMe, 
 
{ • Implementation Use } 
UDrawShapes; 
 

IF ValidateConfiguration(gConfiguration) THEN       { Make sure we can 
run } 
BEGIN 
{ Continue with remainder of initialization } 
InitUMacApp(10); { Init MacApp; 10 calls to MoreMasters } 
InitUTEView; 
InitUDialog; 
InitUSavedMe; 
InitUPrinting;  { Initialize the printing unit} 
 
Listing 2: Changes to DrawShapes.r
 
#if qDebug 
include “Debug.rsrc”; 
#endif 
include “MacApp.rsrc”; 
include “Printing.rsrc”; 
 
#if qTemplateViews 
#ifndef __ViewTypes__ 
#include “ViewTypes.r” 
#endif 
#endif 
 
#include “USavedMe.r” 
 
include $$Shell(“ObjApp”)”DrawShapes” ‘CODE’; 
 
 
include “Defaults.rsrc” ‘cmnu’ (mApple);      // Grab the default Apple/File 
menus Apple menu 
 
include “Defaults.rsrc” ‘cmnu’ (mFile); 
 
resource ‘cmnu’ (mFile, 
#if qNames 
“mFile”, 
#endif 
nonpurgeable) { 
mFile, 
textMenuProc, 
0x7FFFFFFD, 
enabled, 
“File”, 
{ 
“New”, noIcon, “N”,    noMark, plain, cNew; 
“Open ”, noIcon, “O”,    noMark, plain, cOpen; 
“-”, noIcon, noKey,  noMark, plain, nocommand; 
“Close”, noIcon, “W”,    noMark, plain, cClose; 
“Save”, noIcon, “S”,    noMark, plain, cSave; 
“Save As ”, noIcon, noKey, noMark, plain, cSaveAs; 
“Save a Copy In ”, noIcon, noKey, noMark, plain, cSaveCopy; 
“Revert”, noIcon, noKey,  noMark, plain, cRevert; 
“-”, noIcon, noKey,  noMark, plain, nocommand; 
“Auto-saving”, noIcon, noKey, noMark, plain, cToggleAutoSave; 
“Set auto-save time”, noIcon, noKey, noMark, plain, cSetAutoSave; 
“-”, noIcon, noKey,  noMark, plain, nocommand; 
“Page Setup ”, noIcon, noKey,  noMark, plain, cPageSetup; 
“Print One”, noIcon, noKey,  noMark, plain, cPrintOne; 
“Print ”, noIcon, “P”,    noMark, plain, cPrint; 
“-”, noIcon, noKey,  noMark, plain, nocommand; 
“Quit”, noIcon, “Q”,    noMark, plain, cQuit 
} 
}; 
 
Listing 3: Changes to UDrawShapes.p
 
UNIT UDrawShapes; 
 
INTERFACE 
 
USES 
{ • MacApp } 
UMacApp, 
 
{ • Building Blocks } 
UPrinting, 
 
UTEView, UDialog, USavedMe, 
{ • Implementation Use } 
Picker, ToolUtils, Resources, Fonts; 
 
TYPE 
 
TShapeDocument      = OBJECT (TDocument) (TAutoSaveDocument) 
 
fShapeView:         TShapeView; 
 
Listing 4: Changes to UDrawShapes.inc1.p
PROCEDURE TShapeDocument.IShapeDocument(fileType: OSType); 
 
IDocument IAutoSaveDocument(fileType, kDocType, kUsesDataFork, kUsesRsrcFork, 
NOT kDataOpen, NOT kRsrcOpen); 
 
Listing 5: DrawShapes.MAMake
 

#------------------------------------------------
#    List here the Application’s Name
AppName = DrawShapes

#------------------------------------------------
#    List any additional interfaces that your application is dependent 
on
OtherInterfaces =  
    “{SrcApp}USavedMe.p”

#------------------------------------------------
#    Name any other object files to link in
OtherLinkFiles = 
    “{ObjApp}USavedMe.p.o”

#------------------------------------------------
#    Express any additional dependencies for separate compilations.
#    Include dependencies for the MacApp and Building block interfaces
#    if you are dependent on them
“{ObjApp}USavedMe.p.o”    ƒ 
               “{SrcApp}USavedMe.inc1.p” 
               “{SrcApp}USavedMe.p” 
               {MacAppIntf} 
               {BuildingBlocksIntf}

#------------------------------------------------
Listing 6: USavedMe.p
{ Copyright © 1989 Fred J. Condo Jr. All rights reserved. }

UNIT USavedMe;
 {[f-]}
{ This unit defines the object type
TAutoSaveDocument, a MacApp® abstract type from
which you should descend your application’s
actual document object class(es).

 When a TAutoSaveDocument is in the command
chain, MacApp calls its DoIdle method, which
determines whether auto-saving is on, and, if
so, whether the user-requested interval since the
last auto-save has elapsed. If that is so, the
document is saved by sending itself a
Save message.

 When a TAutoSaveDocument is not in the command
chain, DoIdle is not called. A future version of
this unit may implement auto-saving in the
background. That would install the document as a
cohandler, which would remain installed until
such time as it saved itself, and then de-
install itself as a cohandler. Of course, if
fChangeCount =0, or if auto-saving is off, then
it would not install itself as a cohandler in
the first place, since auto-saving would never be
called for. A de-installed auto-saver would re-
install itself when brought to the front.

 The user interface to this unit is by means of a
modeless dialog.

 If you are already working on your MacApp
application, you need simply change the ancestor
of your document classes from (TDocument) to
(TAutoSaveDocument).

 Be sure to call InitUTEView, InitUDialog, and
InitUSavedMe in your main program.

 Call IAutoSaveDocument in IYourDocument.

 If your document has a DoIdle method, be sure to
call INHERITED DoIdle. Also, to keep your idle
frequency from getting clobbered, set
fRespectsIdleTime to TRUE immediately after
calling IAutoSaveDocument. If you don’t care about
your idle frequency, you can accept the default
(FALSE).

 In the USES clause of your main program, insert
“UTEView, UDialog, USavedMe,” and make the same
insertion in the USES clause of UYourProgram.p.

 The name of this unit is a pun. Sorry. I
couldn’t help it. }
{[f+]}

 INTERFACE

  USES UMacApp,UTEView,UDialog,SANE,Script,
       ToolUtils;

  CONST
   cToggleAutoSave = 5000; { Change these here and
                            in USavedMe.r }
   cSetAutoSave = 5001; { if they conflict with
                         your application. }
   kAutoSaveDialogID = 5000;
   kMinutesID = 18950; { Resource ID of STR# containing
  singular and plural of ‘minute’. }

  TYPE
   TAutoSaveDocument = OBJECT (TDocument)
    fSaving: Boolean; { Whether autosaving is on. }
    fHasEverBeenSet: Boolean; { Whether the dialog
                               has ever been summoned. }
    fRespectIdleTime: Boolean; { Default FALSE. If
        TRUE, TAutoSaveDocument won’t stomp on your idle
        frequency. This is useful if your document is a
  cohandler or otherwise needs idle processing. }
    fLastSave: Longint; { Time that doc was last autosaved. }
    fDesiredInterval: Longint; { Time in ticks set by user. }
    fAutoSaveWindow: TWindow; { AutoSave dialog window. }

                    { Init & Free }

    PROCEDURE TAutoSaveDocument.IAutoSaveDocument(
                  itsFileType, itsCreator: OSType;
              usesDataFork, usesRsrcFork: Boolean;
           keepsDataOpen, keepsRsrcOpen: Boolean);
           
    PROCEDURE TAutoSaveDocument.Free; OVERRIDE;

    { Meat & Potatoes }
    FUNCTION TAutoSaveDocument.DoIdle
    (phase: IdlePhase): Boolean; OVERRIDE;
    
    PROCEDURE TAutoSaveDocument.DoSetupMenus;
     OVERRIDE;
     
    FUNCTION TAutoSaveDocument.DoMenuCommand(
     aCmdNumber: CmdNumber): TCommand; OVERRIDE;
     
    PROCEDURE
     TAutoSaveDocument.PoseAutoSaveDialog;

    { Debugging }
    PROCEDURE TAutoSaveDocument.Fields
    (PROCEDURE DoToField(fieldName: Str255;
      fieldAddr: Ptr; fieldType: Integer));
      OVERRIDE;
    END;

   TAutoSaveDialogView = OBJECT (TDialogView)
    fAutoSaveDocument: TAutoSaveDocument; { The
     autosaver this dialog will modify. }

    { Init & Free }

    PROCEDURE TAutoSaveDialogView.Free;
    OVERRIDE;
    PROCEDURE TAutoSaveDialogView.Close;
    OVERRIDE;

    { A nice fish dinner }
    PROCEDURE TAutoSaveDialogView.DismissDialog
     (dismisser: IDType;
      flashDismisser: Boolean);
     OVERRIDE;
     
    PROCEDURE 
     TAutoSaveDialogView.UpdateDocumentName;

    PROCEDURE TAutoSaveDialogView.Fields
     (PROCEDURE DoToField(fieldName: Str255;
      fieldAddr: Ptr; fieldType: Integer));
      OVERRIDE;
    END;

   { GLOBAL PROCEDURE }

  PROCEDURE InitUSavedMe;

 IMPLEMENTATION

  {$I USavedMe.inc1.p}

END.
Listing 7: USavedMe.inc1.p
{ USavedMe.inc1.p
    Copyright © 1989 Fred J. Condo Jr.
    All rights reserved. }

CONST
 autoSaving = TRUE;

 {$S AOpen}

PROCEDURE TAutoSaveDocument.IAutoSaveDocument(
                  itsFileType, itsCreator: OSType;
              usesDataFork, usesRsrcFork: BOOLEAN;
           keepsDataOpen, keepsRsrcOpen: BOOLEAN);

 BEGIN
  {$IFC qDebug}
  IF gIntenseDebugging THEN
   WriteLn(‘TAutoSaveDocument.IAutoSaveDocument’);
  {$ENDC}
  IDocument(itsFileType,itsCreator,usesDataFork,
            usesRsrcFork,keepsDataOpen,
            keepsRsrcOpen);
  { Initial conditions are... }
  fSaving:=NOT autoSaving;
  fRespectIdleTime:=FALSE;
  fHasEverBeenSet:=FALSE; fLastSave:=0; { never
   saved }
  fDesiredInterval:=MAXLONGINT; { never want it saved. (This
  is 1 yr., 1 mo., 19 days) }
  fAutoSaveWindow:=NIL { no dialog exists }
 END;

{$S AClose}

PROCEDURE TAutoSaveDocument.Free; OVERRIDE;

 BEGIN
{ If this object is being freed and its dialog is
  still open (which can happen because it is a
  modeless dialog), then close the dialog. }

  {$IFC qDebug}
  IF gIntenseDebugging THEN
   WriteLn(‘TAutoSaveDocument.Free’);
  {$ENDC}

  IF fAutoSaveWindow<>NIL THEN
   fAutoSaveWindow.Close;
  INHERITED Free
 END;

{$S ARes}

FUNCTION TAutoSaveDocument.DoIdle(Phase: IdlePhase
                                  ): BOOLEAN;
 OVERRIDE;

 VAR
  dontCare: TCommand;
  currentTicks: LongInt;

 BEGIN
  DoIdle:=FALSE; { I don’t free myself }
  currentTicks:=TickCount;

  {$IFC qDebug}
  IF gIntenseDebugging THEN
   WriteLn(fTitle^^,’ has idled’);
  IF fSaving&(currentTicks-fLastSave>=
     fDesiredInterval) THEN
   WriteLn(‘Enough time has elapsed to save.’);
  {$ENDC}

  IF fSaving&(fChangeCount>0)&(currentTicks-
     fLastSave>=fDesiredInterval) THEN BEGIN
        Save(cSave, FALSE, FALSE);
        fLastSave := currentTicks
  END
 END;

{$S ARes}

PROCEDURE TAutoSaveDocument.DoSetupMenus; OVERRIDE
 ;

 BEGIN
  {$IFC qDebug}
  WriteLn(‘AutoSaveDocument.DoSetupMenus:’);
  {$ENDC}

  INHERITED DoSetupMenus;
  EnableCheck(cToggleAutoSave,fHasEverBeenSet, fSaving);
  Enable(cSetAutoSave,fSaveExists) { Allow auto-saving
            only after the file has a name }
 END;

{$S ARes}

FUNCTION TAutoSaveDocument.DoMenuCommand(
       aCmdNumber: CmdNumber): TCommand; OVERRIDE;

 VAR
  anAutoSaveDialogView: TAutoSaveDialogView;

 BEGIN

  {$IFC qDebug}
  IF gIntenseDebugging THEN
   WriteLn(‘TAutoSaveDocument.DoMenuCommand:’, aCmdNumber);
  {$ENDC}

  DoMenuCommand:=gNoChanges;
  CASE aCmdNumber OF
   cToggleAutoSave: BEGIN
    fSaving:=NOT fSaving;
    IF NOT fSaving&NOT fRespectIdleTime THEN
     fIdleFreq:=MAXLONGINT
   END;

   cSetAutoSave:
    IF fAutoSaveWindow=NIL { Open a dialog only if
                            one is not already open }
       THEN
     PoseAutoSaveDialog
    ELSE fAutoSaveWindow.Select;

   cSave,cSaveAs: BEGIN
 { Intercept cSave and cSaveAs commands to make
   sure that the document name given in the 
   AutoSave Dialog is still correct. If there is
   no dialog open, skip it. }
    Save(aCmdNumber,((aCmdNumber=cSaveAs)|
         (NOT fSaveExists)) { Put up SFPutFile if
                             Save As  } ,FALSE);
    IF (fAutoSaveWindow<>NIL) THEN BEGIN
     anAutoSaveDialogView:=TAutoSaveDialogView(
                            fAutoSaveWindow.FindSubView(‘DLOG’));
     FailNIL(anAutoSaveDialogView);
     anAutoSaveDialogView.UpdateDocumentName
    END
   END; { cSave }
   OTHERWISE
    DoMenuCommand:=INHERITED DoMenuCommand(aCmdNumber)
  END { Case }
 END; { DoMenuCommand }

{$S ANonRes}

PROCEDURE TAutoSaveDocument.PoseAutoSaveDialog;
{ This method creates and opens a modeless dialog }

 VAR
  theDialog: TAutoSaveDialogView;
  theTimeText: TNumberText;
  theWordMinutes: TStaticText;
  minutesStr: Str255;
  whichStr: 1..2;

 BEGIN

  {$IFC qDebug}
  IF gIntenseDebugging THEN
   WriteLn(‘TAutoSaveDocument.PoseAutoSaveDialog’)
           ;
  {$ENDC}

  fAutoSaveWindow { This field will allow the
   auto-save object to keep track of its dialog }
   :=NewTemplateWindow(kAutoSaveDialogID,NIL);
  FailNIL(fAutoSaveWindow);
  theDialog:=TAutoSaveDialogView(fAutoSaveWindow.
                                 FindSubView(‘DLOG’));
  FailNIL(theDialog);

        { Now give the TAutoSaveDialogView a
          reference to the auto-save object so
          that it can update the appropriate
          fields when it is dismissed. }
  theDialog.fAutoSaveDocument:=SELF;
  theDialog.UpdateDocumentName;

    { Now display the proper desired interval, if
      one’s been previously set, or the default;
      and determine whether to use the singular or
      plural of “minute.” }
  theTimeText:=TNumberText(theDialog.FindSubView(‘time’));
  FailNIL(theTimeText);
  IF fHasEverBeenSet THEN
   theTimeText.SetValue(fDesiredInterval DIV 3600,
                        FALSE {no redraw; not open yet} );
  IF theTimeText.GetValue=1 THEN whichStr:=1
  ELSE whichStr:=2;
  theWordMinutes:=TStaticText(theDialog.FindSubView(‘mnut’))
                   ; FailNIL(theWordMinutes);
  GetIndString(minutesStr,kMinutesID,whichStr);
  theWordMinutes.SetText(minutesStr,FALSE);
  fAutoSaveWindow.Open
 END;

{$S AFields}

PROCEDURE TAutoSaveDocument.Fields
 (PROCEDURE DoToField(fieldName: Str255;
 fieldAddr: Ptr; fieldType: Integer));
 OVERRIDE;

 BEGIN
  DoToField(‘TAutoSaveDocument’,NIL,bClass);
  DoToField(‘fSaving’,@fSaving,bBoolean);
  DoToField(‘fHasEverBeenSet’,@fHasEverBeenSet, bBoolean);
  DoToField(‘fRespectIdleTime’,@fRespectIdleTime, bBoolean);
  DoToField(‘fLastSave’,@fLastSave,bLongInt);
  DoToField(‘fDesiredInterval’,@fDesiredInterval, bLongInt);
  DoToField(‘fAutoSaveWindow’,@fAutoSaveWindow, bObject);
  INHERITED Fields(DoToField)
 END;

{$S ANonRes}

PROCEDURE TAutoSaveDialogView.DismissDialog
 (dismisser: IDType;
  flashDismisser: Boolean);
 OVERRIDE;

 BEGIN

  {$IFC qDebug}
  IF gIntenseDebugging THEN
   WriteLn(‘TAutoSaveDialogView.DismissDialog’);
  {$ENDC}

  IF NOT fDismissed AND
     DeselectCurrentEditText THEN BEGIN
   INHERITED DismissDialog(dismisser, flashDismisser);
   IF dismisser=’ok  ‘ THEN BEGIN
    fAutoSaveDocument.fSaving:=autoSaving;
    fAutoSaveDocument.fHasEverBeenSet:=TRUE;
    fAutoSaveDocument.fDesiredInterval:=60*60* {
      The interval is specified in minutes by the
      user. We want ticks. }
     TNumberText(FindSubView(‘time’)).GetValue;
    IF fAutoSaveDocument.fRespectIdleTime THEN
     BEGIN
     IF fAutoSaveDocument.fDesiredInterval<
        fAutoSaveDocument.fIdleFreq THEN
      fAutoSaveDocument.fIdleFreq:=MAX(1,
        fAutoSaveDocument.fDesiredInterval DIV 2)
        { This  way, we don’t stomp on a
          co-handler’s idle frequency. }
    END
    ELSE
     fAutoSaveDocument.fIdleFreq:=
       fAutoSaveDocument.fDesiredInterval
                                   DIV 2
   END;
   fAutoSaveDocument.fAutoSaveWindow:=NIL; { Tell
    the document there’s no dialog to close }
   TWindow(fSuperView).Close
  END
 END;

{$S ANonRes}

PROCEDURE TAutoSaveDialogView.UpdateDocumentName;

 VAR
  theDocName: TStaticText;
  theDocTitle: Str255;

 BEGIN

  {$IFC qDebug}
  IF gIntenseDebugging THEN
   WriteLn(‘TAutoSaveDialogView.UpdateDocumentName’);
  {$ENDC}

{ Get the name of the document so the dialog can
  display it for the user }
  theDocName:=TStaticText(FindSubView(‘docn’));
  FailNIL(theDocName);
  theDocTitle:=fAutoSaveDocument.fTitle^^;
  theDocName.SetText(theDocTitle,TRUE {redraw} )
 END;

{$S AClose}
PROCEDURE TAutoSaveDialogView.Free; OVERRIDE;
{ This is overridden to inform the document that
  it has no dialog available. This is done so
  that, if the user clicks the goAway of the
  dialog, the document is informed. }

 BEGIN
  {$IFC qDebug}
  IF gIntenseDebugging THEN
   WriteLn(‘TAutoSaveDialogView.Free’);
  {$ENDC}

  fAutoSaveDocument.fAutoSaveWindow:=NIL;
  INHERITED Free
 END;

{$S AClose}

PROCEDURE TAutoSaveDialogView.Close; OVERRIDE;

 BEGIN
  fDismissed:=TRUE; { Pretend we’ve dismissed with
                     the Cancel button, }
  fDismisser:=’cncl’; { but without doing any real dismissing, because 
objects may be freed. }
  INHERITED Close
 END;

{$S AFields}

PROCEDURE TAutoSaveDialogView.Fields
 (PROCEDURE DoToField(fieldName: Str255;
  fieldAddr: Ptr; fieldType: Integer));
  OVERRIDE;

 BEGIN
  DoToField(‘TAutoSaveDialogView’,NIL,bClass);
  DoToField(‘fAutoSaveDocument’,
            @fAutoSaveDocument,bObject);
  INHERITED Fields(DoToField)
 END;

{$S AInit}

PROCEDURE InitUSavedMe; { This just makes sure our dialog view classes 
don’t get stripped. }

 VAR
  g: BOOLEAN;

 BEGIN

  {$IFC qDebug}
  IF gIntenseDebugging THEN
   WriteLn(‘InitUSavedMe’);
  {$ENDC}

  IF gDeadStripSuppression THEN
   g:=Member(TObject(NIL),TAutoSaveDialogView)
 END;
Listing 8: USavedMe.r
/* USavedMe.r
  Copyright © 1989 Fred J. Condo Jr.
  All rights reserved.
  INCLUDE USavedMe.r in YourApp.r */

#define kAutoSaveDialogID 5000
#define kAutoSaveMenuID   5000
#define cToggleAutoSave   5000
#define cSetAutoSave 5001
#define kMinutesID 18950

include “dialog.rsrc”;

resource ‘STR#’ (kMinutesID, “Minutes”, purgeable) {
 { /* array StringArray: 2 elements */
 /* [1] */
 “minute.”,
 /* [2] */
 “minutes.”
 }
};

resource ‘view’ (kAutoSaveDialogID, purgeable) {
 { /* array viewArray: 10 elements */
 /* [1] */
 root, ‘root’,
 { /* array: 1 elements */
 /* [1] */
 50, 40
 },
 { /* array: 1 elements */
 /* [1] */
 226, 192
 }, sizeVariable, sizeVariable, notShown, enabled,
 Window {
 “TWindow”,
 16,
 goAwayBox,
 notResizable,
 modeless,
 ignoreFirstClick,
 freeOnClosing,
 disposeOnFree,
 doesntCloseDocument,
 dontOpenWithDocument,
 dontAdaptToScreen,
 dontStagger,
 forceOnScreen,
 dontCenter,
 ‘time’,
 “Auto-save”
 },
 /* [2] */
 ‘root’, ‘DLOG’,
 { /* array: 1 elements */
 /* [1] */
 0, 0
 },
 { /* array: 1 elements */
 /* [1] */
 224, 192
 }, sizeVariable, sizeVariable, shown, enabled,
 DialogView {
 “TAutoSaveDialogView”,
 ‘ok  ‘,
 ‘cncl’
 },
 /* [3] */
 ‘DLOG’, ‘VW06’,
 { /* array: 1 elements */
 /* [1] */
 8, 8
 },
 { /* array: 1 elements */
 /* [1] */
 64, 176
 }, sizeFixed, sizeFixed, shown, disabled,
 Cluster {
 “TCluster”,
 0b0,
 {1, 1},
 sizeable,
 notDimmed,
 notHilited,
 doesntDismiss,
 {0, 0, 0, 0},
 plain, 9,
 { /* array: 3 elements */
 /* [1] */
 0x0,
 /* [2] */
 0x0,
 /* [3] */
 0x0
 },
 “A”,
 “Document to Auto-save”
 },
 /* [4] */
 ‘VW06’, ‘docn’,
 { /* array: 1 elements */
 /* [1] */
 16, 8
 },
 { /* array: 1 elements */
 /* [1] */
 40, 160
 }, sizeFixed, sizeFixed, shown, disabled,
 StaticText {
 “TStaticText”,
 0b0,
 {1, 1},
 sizeable,
 notDimmed,
 notHilited,
 doesntDismiss,
 {0, 0, 0, 0},
 plain, 0,
 { /* array: 3 elements */
 /* [1] */
 0x0,
 /* [2] */
 0x0,
 /* [3] */
 0x0
 },
 “”,
 justLeft,
 “static text”
 },
 /* [5] */
 ‘DLOG’, ‘VW08’,
 { /* array: 1 elements */
 /* [1] */
 80, 8
 },
 { /* array: 1 elements */
 /* [1] */
 88, 176
 }, sizeFixed, sizeFixed, shown, disabled,
 Cluster {
 “TCluster”,
 0b0,
 {1, 1},
 sizeable,
 notDimmed,
 notHilited,
 doesntDismiss,
 {0, 0, 0, 0},
 plain, 9,
 { /* array: 3 elements */
 /* [1] */
 0x0,
 /* [2] */
 0x0,
 /* [3] */
 0x0
 },
 “A”,
 “Set the Auto-save interval”
 },
 /* [6] */
 ‘VW08’, ‘VW03’,
 { /* array: 1 elements */
 /* [1] */
 16, 8
 },
 { /* array: 1 elements */
 /* [1] */
 16, 80
 }, sizeFixed, sizeFixed, shown, disabled,
 StaticText {
 “TStaticText”,
 0b0,
 {1, 1},
 sizeable,
 notDimmed,
 notHilited,
 doesntDismiss,
 {0, 0, 0, 0},
 plain, 0,
 { /* array: 3 elements */
 /* [1] */
 0x0,
 /* [2] */
 0x0,
 /* [3] */
 0x0
 },
 “”,
 justLeft,
 “Save every”
 },
 /* [7] */
 ‘VW08’, ‘time’,
 { /* array: 1 elements */
 /* [1] */
 40, 60
 },
 { /* array: 1 elements */
 /* [1] */
 20, 48
 }, sizeFixed, sizeFixed, shown, enabled,
 NumberText {
 “TNumberText”,
 0b1111,
 {1, 1},
 notSizeable,
 notDimmed,
 notHilited,
 doesntDismiss,
 {2, 2, 2, 2},
 plain, 0,
 { /* array: 3 elements */
 /* [1] */
 0x0,
 /* [2] */
 0x0,
 /* [3] */
 0x0
 },
 “”,
 justLeft,
 “15”,
 5,
 0b110000000000000000000100000000,
 15, 1, 65535
 },
 /* [8] */
 ‘VW08’, ‘mnut’,
 { /* array: 1 elements */
 /* [1] */
 64, 96
 },
 { /* array: 1 elements */
 /* [1] */
 16, 72
 }, sizeFixed, sizeFixed, shown, disabled,
 StaticText {
 “TStaticText”,
 0b0,
 {1, 1},
 sizeable,
 notDimmed,
 notHilited,
 doesntDismiss,
 {0, 0, 0, 0},
 plain, 0,
 { /* array: 3 elements */
 /* [1] */
 0x0,
 /* [2] */
 0x0,
 /* [3] */
 0x0
 },
 “”,
 justLeft,
 “x”
 },
 /* [9] */
 ‘DLOG’, ‘cncl’,
 { /* array: 1 elements */
 /* [1] */
 184, 16
 },
 { /* array: 1 elements */
 /* [1] */
 24, 72
 }, sizeFixed, sizeFixed, shown, enabled,
 Button {
 “TButton”,
 0b0,
 {1, 1},
 sizeable,
 notDimmed,
 notHilited,
 dismisses,
 {0, 0, 0, 0},
 plain, 0,
 { /* array: 3 elements */
 /* [1] */
 0x0,
 /* [2] */
 0x0,
 /* [3] */
 0x0
 },
 “”,
 “Cancel”
 },
 /* [10] */
 ‘DLOG’, ‘ok  ‘,
 { /* array: 1 elements */
 /* [1] */
 182, 94
 },
 { /* array: 1 elements */
 /* [1] */
 28, 80
 }, sizeFixed, sizeFixed, shown, enabled,
 Button {
 “TButton”,
 0b1000000,
 {3, 3},
 sizeable,
 notDimmed,
 notHilited,
 dismisses,
 {4, 4, 4, 4},
 plain, 0,
 { /* array: 3 elements */
 /* [1] */
 0x0,
 /* [2] */
 0x0,
 /* [3] */
 0x0
 },
 “”,
 “OK”
 }
 }
};

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Macs Fan Control 1.3.1.0 - Monitor and c...
Macs Fan Control allows you to monitor and control almost any aspect of your computer's fans, with support for controlling fan speed, temperature sensors pane, menu-bar icon, and autostart with... Read more
NetShade 6.3.1 - Browse privately using...
NetShade is an anonymous proxy and VPN app+service for Mac. Unblock your Internet through NetShade's high-speed proxy and VPN servers spanning seven countries. NetShade masks your IP address as you... Read more
Dragon Dictate 4.0.7 - Premium voice-rec...
With Dragon Dictate speech recognition software, you can use your voice to create and edit text or interact with your favorite Mac applications. Far more than just speech-to-text, Dragon Dictate lets... Read more
Persecond 1.0.2 - Timelapse video made e...
Persecond is the easy, fun way to create a beautiful timelapse video. Import an image sequence from any camera, trim the length of your video, adjust the speed and playback direction, and you’re done... Read more
GIMP 2.8.14p2 - Powerful, free image edi...
GIMP is a multi-platform photo manipulation tool. GIMP is an acronym for GNU Image Manipulation Program. The GIMP is suitable for a variety of image manipulation tasks, including photo retouching,... Read more
Sandvox 2.10.2 - Easily build eye-catchi...
Sandvox is for Mac users who want to create a professional looking website quickly and easily. With Sandvox, you don't need to be a Web genius to build a stylish, feature-rich, standards-compliant... Read more
LibreOffice 5.0.1.2 - Free, open-source...
LibreOffice is an office suite (word processor, spreadsheet, presentations, drawing tool) compatible with other major office suites. The Document Foundation is coordinating development and... Read more
f.lux 36.1 - Adjusts the color of your d...
f.lux makes the color of your computer's display adapt to the time of day, warm at night and like sunlight during the day. Ever notice how people texting at night have that eerie blue glow? Or wake... Read more
VirtualBox 5.0.2 - x86 virtualization so...
VirtualBox is a family of powerful x86 virtualization products for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product for enterprise customers... Read more
File Juicer 4.43 - Extract images, video...
File Juicer is a drag-and-drop can opener and data archaeologist. Its specialty is to find and extract images, video, audio, or text from files which are hard to open in other ways. In computer... Read more

ReBoard: Revolutionary Keyboard (Utilit...
ReBoard: Revolutionary Keyboard 1.0 Device: iOS Universal Category: Utilities Price: $1.99, Version: 1.0 (iTunes) Description: Do everything within the keyboard without switching apps! If you are in WhatsApp, how do you schedule a... | Read more »
Tiny Empire (Games)
Tiny Empire 1.1.3 Device: iOS Universal Category: Games Price: $2.99, Version: 1.1.3 (iTunes) Description: Launch cannonballs and blow tiny orcs into thousands of pieces in this intuitive fantasy-themed puzzle shooter! Embark on an... | Read more »
Astropad Mini (Productivity)
Astropad Mini 1.0 Device: iOS iPhone Category: Productivity Price: $4.99, Version: 1.0 (iTunes) Description: *** 50% off introductory price! ​*** Get the high-end experience of a Wacom tablet at a fraction of the price with Astropad... | Read more »
Emo Chorus (Music)
Emo Chorus 1.0.0 Device: iOS Universal Category: Music Price: $1.99, Version: 1.0.0 (iTunes) Description: Realistic Choir simulator ranging from simple Chorus emulation to full ensemble Choir with 128 members. ### introductory offer... | Read more »
Forest Spirit (Games)
Forest Spirit 1.0.5 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0.5 (iTunes) Description: | Read more »
Ski Safari 2 (Games)
Ski Safari 2 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: The world's most fantastical, fun, family-friendly skiing game is back and better than ever! Play as Sven's sister Evana, share... | Read more »
Lara Croft GO (Games)
Lara Croft GO 1.0.47768 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.47768 (iTunes) Description: Lara Croft GO is a turn based puzzle-adventure set in a long-forgotten world. Explore the ruins of an ancient... | Read more »
Whispering Willows (Games)
Whispering Willows 1.23 Device: iOS Universal Category: Games Price: $4.99, Version: 1.23 (iTunes) Description: **LAUNCH SALE 50% OFF** - Whispering Willows is on sale for 50% off ($4.99) until September 9th. | Read more »
Calvino Noir (Games)
Calvino Noir 1.1 Device: iOS iPhone Category: Games Price: $3.99, Version: 1.1 (iTunes) Description: The film noir stealth game. Calvino Noir is the exploratory, sneaking adventure through the 1930s European criminal underworld.... | Read more »
Angel Sword (Games)
Angel Sword 1.0 Device: iOS Universal Category: Games Price: $6.99, Version: 1.0 (iTunes) Description: Prepare to adventure in the most epic full scale multiplayer 3D RPG for mobile! Experience amazing detailed graphics in full HD.... | Read more »

Price Scanner via MacPrices.net

iPad Air 2 on sale for up to $100 off MSRP
Best Buy has iPad Air 2s on sale for up to $100 off MSRP on their online store for a limited time. Choose free shipping or free local store pickup (if available). Sale prices available for online... Read more
MacBook Airs on sale for $100 off MSRP
Best Buy has MacBook Airs on sale for $100 off MSRP on their online store. Choose free shipping or free local store pickup (if available). Sale prices for online orders only, in-store prices may vary... Read more
Big Grips Lift Handle For iPad Air and iPad A...
KEM Ventures, Inc. which pioneered the extra-large, super-protective iPad case market with the introduction of Big Grips Frame and Stand in 2011, is launching Big Grips Lift featuring a new super-... Read more
Samsung Launches Galaxy Tab S2, Its Most Powe...
Samsung Electronics America, Inc. has announced the U.S. release of the Galaxy Tab S2, its thinnest, lightest, ultra-fast tablet. Blending form and function, elegant design and multitasking power,... Read more
Tablet Screen Sizes Expanding as iPad Pro App...
Larger screen sizes are gaining favor as the tablet transforms into a productivity device, with shipments growing 185 percent year-over-year in 2015. According to a new Strategy Analytics’ Tablet... Read more
Today Only: Save US$50 on Adobe Elements 13;...
Keep the memories. lose the distractions. Summer’s winding down and it’s time to turn almost perfect shots into picture perfect memories with Elements 13. And get the power to edit both photos and... Read more
1.4GHz Mac mini on sale for $449, save $50
Best Buy has the 1.4GHz Mac mini on sale for $50 off MSRP on their online store. Choose free shipping or free local store pickup (if available). Price for online orders only, in-store price may vary... Read more
12-inch 1.1GHz Gold MacBook on sale for $1149...
B&H Photo has the 12″ 1.1GHz Gold Retina MacBook on sale for $1149.99 including free shipping plus NY sales tax only. Their price is $150 off MSRP, and it’s the lowest price available for this... Read more
27-inch 3.3GHz 5K iMac on sale for $1849, sav...
Best Buy has the 27″ 3.3GHz 5K iMac on sale for $1849.99. Their price is $150 off MSRP, and it’s the lowest price available for this model. Choose free shipping or free local store pickup (if... Read more
Worldwide Tablet Shipments Expected to Declin...
Does Apple badly need a touchscreen convertible/hybrid laptop MacBook? Yes, judging from a new market forecast from the International Data Corporation (IDC) Worldwide Quarterly Tablet Tracker, which... Read more

Jobs Board

*Apple* Music, Business Operations - Apple (...
**Job Summary** This role in Apple Music and in iTunes is working with…the songs that we all enjoy listening to in Apple Music. Your job will be to work wit Read more
Hardware Systems Integration Engineer - *App...
**Job Summary** We are seeking an enthusiastic electrical engineer for the Apple Watch team. This is a design engineering position that entails working with Read more
Engineering Project Manager - *Apple* TV -...
**Job Summary** The iTunes Apps project management team oversees iTunes, Apple TV, DRM and iOS Applications. We are looking for a project manager to help manage and Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail Online Store: Customer Insigh...
**Job Summary** Apple Retail (Online Store) is seeking an experienced e-commerce analytics professional to join the Customer Insights Team. The Web e-Commerce Analyst Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.