home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / macintosh-c / macc-carbon-demos-nonbinhex.sit / macc-carbon-demos-nonbinhex / chap26-demo / MLTENewOpenCloseSave.c < prev    next >
Text File  |  2001-06-05  |  17KB  |  589 lines

  1. // *******************************************************************************************
  2. // MLTENewOpenCloseSave.c
  3. // *******************************************************************************************
  4.  
  5. // ………………………………………………………………………………………………………………………………………………………………………………………………………………………… includes
  6.  
  7. #include "MLTETextEditor.h"
  8.  
  9. // …………………………………………………………………………………………………………………………………………………………………………………………………… global variables
  10.  
  11. SInt16    gCurrentNumberOfWindows = 0;
  12. SInt16    gUntitledWindowNumber = 0;
  13.  
  14. extern Boolean    gRunningOnX = false;
  15. extern SInt16        gAppResFileRefNum;
  16.  
  17. // ****************************************************************************** doNewCommand
  18.  
  19. OSStatus  doNewCommand(void)
  20. {
  21.     OSStatus     osStatus = noErr;
  22.     WindowRef    windowRef;
  23.  
  24.     if(gCurrentNumberOfWindows == kMaxWindows)
  25.         return eMaxWindows;
  26.  
  27.     osStatus = doNewDocWindow(&windowRef,NULL,kTXNTextensionFile);
  28.  
  29.     if(osStatus == noErr)
  30.         SetWindowProxyCreatorAndType(windowRef,kFileCreator,kTXNTextensionFile,kUserDomain);
  31.  
  32.     return osStatus;
  33. }
  34.  
  35. // ***************************************************************************** doOpenCommand
  36.  
  37. OSStatus doOpenCommand(void)
  38. {
  39.     OSStatus                    osStatus = noErr;
  40.     NavDialogOptions    dialogOptions;
  41.     NavTypeListHandle    fileTypeListHdl = NULL;
  42.     NavEventUPP                navEventFunctionUPP;
  43.     NavReplyRecord        navReplyStruc;
  44.     SInt32                        count, index;
  45.     AEKeyword                    theKeyword;
  46.     DescType                    actualType;
  47.     FSSpec                        fileSpec;
  48.     Size                            actualSize;
  49.     FInfo                            fileInfo;
  50.     OSType                        fileType;
  51.  
  52.     osStatus = NavGetDefaultDialogOptions(&dialogOptions);
  53.  
  54.     if(osStatus == noErr)
  55.     {
  56.         GetIndString(dialogOptions.clientName,rMiscellaneousStrings,sApplicationName);
  57.         fileTypeListHdl = (NavTypeListHandle) GetResource('open',rOpenResource);
  58.  
  59.         navEventFunctionUPP = NewNavEventUPP((NavEventProcPtr) navEventFunction);
  60.  
  61.         osStatus = NavGetFile(NULL,&navReplyStruc,&dialogOptions,navEventFunctionUPP,
  62.                                                     NULL,NULL,fileTypeListHdl,NULL);
  63.  
  64.         DisposeNavEventUPP(navEventFunctionUPP);
  65.             
  66.         if(osStatus == noErr && navReplyStruc.validRecord)
  67.         {
  68.             osStatus = AECountItems(&(navReplyStruc.selection),&count);
  69.             if(osStatus == noErr)
  70.             {
  71.                 for(index=1;index<=count;index++)
  72.                 {
  73.                     osStatus = AEGetNthPtr(&(navReplyStruc.selection),index,typeFSS,&theKeyword,
  74.                                                                  &actualType,&fileSpec,sizeof(fileSpec),&actualSize);
  75.  
  76.                     if((osStatus = FSpGetFInfo(&fileSpec,&fileInfo)) == noErr)
  77.                     {
  78.                         fileType = fileInfo.fdType;
  79.                         osStatus = doOpenFile(fileSpec,fileType);
  80.                     }
  81.                 }
  82.             }
  83.  
  84.             osStatus = NavDisposeReply(&navReplyStruc);
  85.         }
  86.  
  87.         if(fileTypeListHdl != NULL)
  88.             ReleaseResource((Handle) fileTypeListHdl);
  89.     }
  90.  
  91.     if(osStatus == userCanceledErr)
  92.         osStatus = noErr;
  93.     
  94.     return osStatus;
  95. }
  96.  
  97. // **************************************************************************** doCloseCommand
  98.  
  99. OSStatus  doCloseCommand(NavAskSaveChangesAction action)
  100. {
  101.     WindowRef                                windowRef;
  102.     TXNObject                                txnObject = NULL;
  103.     OSStatus                                osStatus = noErr;
  104.     NavDialogOptions                dialogOptions;
  105.     NavAskSaveChangesResult    reply = 0;
  106.     NavEventUPP                            navEventFunctionUPP;
  107.     Str255                                    fileName;
  108.  
  109.     osStatus = NavGetDefaultDialogOptions(&dialogOptions);
  110.  
  111.     if(osStatus == noErr)
  112.     {
  113.         windowRef = FrontWindow();
  114.         if(isApplicationWindow(windowRef,&txnObject))
  115.         {
  116.             if(TXNGetChangeCount(txnObject))
  117.             {
  118.                 GetWTitle(windowRef,fileName);
  119.                 BlockMoveData(fileName,dialogOptions.savedFileName,fileName[0] + 1);
  120.                 GetIndString(dialogOptions.clientName,rMiscellaneousStrings,sApplicationName);
  121.  
  122.                 navEventFunctionUPP = NewNavEventUPP((NavEventProcPtr) navEventFunction);
  123.  
  124.                 osStatus = NavAskSaveChanges(&dialogOptions,action,&reply,navEventFunctionUPP,0);
  125.  
  126.                 DisposeNavEventUPP(navEventFunctionUPP);
  127.  
  128.                 if(osStatus == noErr)
  129.                 {
  130.                     switch(reply)
  131.                     {
  132.                         case kNavAskSaveChangesSave:
  133.                             if((osStatus = doSaveCommand()) == noErr)
  134.                                 doCloseWindow(windowRef,txnObject);
  135.                             break;
  136.  
  137.                         case kNavAskSaveChangesDontSave:
  138.                                 doCloseWindow(windowRef,txnObject);
  139.                             break;
  140.  
  141.                         case kNavAskSaveChangesCancel:
  142.                             osStatus = kNavAskSaveChangesCancel;
  143.                             break;
  144.                     }
  145.                 }
  146.             }
  147.             else
  148.             {
  149.                 doCloseWindow(windowRef,txnObject);
  150.             }
  151.         }
  152.     }
  153.  
  154.     return osStatus;
  155. }
  156.  
  157. // ***************************************************************************** doSaveCommand
  158.  
  159. OSStatus  doSaveCommand(void)
  160. {
  161.     WindowRef    windowRef;
  162.     OSStatus    hasNoFileSpec;
  163.     OSStatus    osStatus = noErr;
  164.     FSSpec        fileSpec;
  165.  
  166.     windowRef = FrontWindow();
  167.  
  168.     hasNoFileSpec = GetWindowProperty(windowRef,kFileCreator,'FiSp',sizeof(FSSpec),NULL,
  169.                                                                         &fileSpec);
  170.     if(hasNoFileSpec)
  171.         osStatus = doSaveAsCommand();
  172.     else
  173.         osStatus = doWriteFile(windowRef,false);
  174.  
  175.     if(osStatus == noErr)
  176.         SetWindowModified(windowRef,false);
  177.  
  178.     return osStatus;
  179. }
  180.  
  181. // *************************************************************************** doSaveAsCommand
  182.  
  183. OSStatus  doSaveAsCommand(void)
  184. {
  185.     OSStatus                    osStatus = noErr;
  186.     NavDialogOptions    dialogOptions;
  187.     WindowRef                    windowRef;
  188.     NavEventUPP                navEventFunctionUPP;
  189.     TXNFileType                txnFileType;
  190.     NavReplyRecord        navReplyStruc;
  191.     AEKeyword                    theKeyword;
  192.     DescType                    actualType;
  193.     FSSpec                        fileSpec;
  194.     Size                            actualSize;
  195.     AliasHandle                aliasHdl;
  196.  
  197.     osStatus = NavGetDefaultDialogOptions(&dialogOptions);
  198.  
  199.     if(osStatus == noErr)
  200.     {
  201.         windowRef = FrontWindow();
  202.  
  203.         GetWTitle(windowRef,dialogOptions.savedFileName);
  204.         GetIndString(dialogOptions.clientName,rMiscellaneousStrings,sApplicationName);
  205.  
  206.         navEventFunctionUPP = NewNavEventUPP((NavEventProcPtr) navEventFunction);
  207.  
  208.         GetWindowProperty(windowRef,kFileCreator,'FiTy',sizeof(TXNFileType),NULL,&txnFileType);
  209.  
  210.         osStatus = NavPutFile(NULL,&navReplyStruc,&dialogOptions,navEventFunctionUPP,
  211.                                                     txnFileType,kFileCreator,NULL);
  212.  
  213.         DisposeNavEventUPP(navEventFunctionUPP);
  214.  
  215.         if(navReplyStruc.validRecord && osStatus == noErr)
  216.         {
  217.             if((osStatus = AEGetNthPtr(&(navReplyStruc.selection),1,typeFSS,&theKeyword,
  218.                                                                  &actualType,&fileSpec,sizeof(fileSpec),&actualSize))
  219.                                                                  == noErr)
  220.             {
  221.                 if(!navReplyStruc.replacing)
  222.                 {
  223.                     osStatus = FSpCreate(&fileSpec,kFileCreator,txnFileType,navReplyStruc.keyScript);
  224.                     if(osStatus != noErr)
  225.                     {
  226.                         NavDisposeReply(&navReplyStruc);
  227.                         return osStatus;
  228.                     }
  229.                 }
  230.  
  231.                 if(osStatus == noErr)
  232.                 {
  233.                     SetWTitle(windowRef,fileSpec.name);
  234.  
  235.                     SetWindowProperty(windowRef,kFileCreator,'FiSp',sizeof(FSSpec),&fileSpec);
  236.                     SetPortWindowPort(windowRef);
  237.                     SetWindowProxyFSSpec(windowRef,&fileSpec);
  238.                     GetWindowProxyAlias(windowRef,&aliasHdl);
  239.                     SetWindowProperty(windowRef,kFileCreator,'tALH',sizeof(AliasHandle),&aliasHdl);
  240.                     SetWindowModified(windowRef,false);
  241.  
  242.                     osStatus = doWriteFile(windowRef,!navReplyStruc.replacing);
  243.                 }
  244.  
  245.                 NavCompleteSave(&navReplyStruc,kNavTranslateInPlace);
  246.             }
  247.  
  248.             NavDisposeReply(&navReplyStruc);
  249.         }
  250.     }
  251.  
  252.     if(osStatus == userCanceledErr)
  253.         osStatus = noErr;
  254.  
  255.     return osStatus;
  256. }
  257.  
  258. // *************************************************************************** doRevertCommand
  259.  
  260. OSStatus  doRevertCommand(void)
  261. {
  262.     OSStatus                                osStatus = noErr;
  263.     NavDialogOptions                dialogOptions;
  264.     NavEventUPP                            navEventFunctionUPP;
  265.     WindowRef                                windowRef;
  266.     Str255                                    fileName;
  267.     NavAskSaveChangesResult    reply;
  268.     TXNObject                                txnObject = NULL;
  269.         
  270.     osStatus = NavGetDefaultDialogOptions(&dialogOptions);
  271.  
  272.     if(osStatus == noErr)
  273.     {
  274.         navEventFunctionUPP = NewNavEventUPP((NavEventProcPtr) navEventFunction);
  275.  
  276.         windowRef = FrontWindow();
  277.         GetWTitle(windowRef,fileName);
  278.         BlockMoveData(fileName,dialogOptions.savedFileName,fileName[0] + 1);
  279.  
  280.         osStatus = NavAskDiscardChanges(&dialogOptions,&reply,navEventFunctionUPP,0);
  281.  
  282.         DisposeNavEventUPP(navEventFunctionUPP);
  283.  
  284.         if(osStatus == noErr)
  285.         {
  286.             if(reply == kNavAskDiscardChanges)
  287.             {
  288.                 if(isApplicationWindow(windowRef,&txnObject))
  289.                 {
  290.                     TXNRevert(txnObject);
  291.  
  292.                     if(TXNDataSize(txnObject))
  293.                         SetWindowModified(windowRef,false);
  294.                 }
  295.             }
  296.         }
  297.     }
  298.  
  299.     return osStatus;
  300. }
  301.  
  302. // ***************************************************************************** doQuitCommand
  303.  
  304. OSStatus  doQuitCommand(NavAskSaveChangesAction action)
  305. {
  306.     OSStatus    osStatus = noErr;
  307.  
  308.     while(FrontWindow())
  309.     {
  310.         osStatus = doCloseCommand(action);
  311.         if(osStatus != noErr)
  312.             return osStatus;
  313.     }
  314.  
  315.     return osStatus;
  316. }
  317.  
  318. // **************************************************************************** doNewDocWindow
  319.  
  320. OSStatus  doNewDocWindow(WindowRef *outWindowRef,FSSpec *fileSpec,TXNFileType txnFileType)
  321. {
  322.     WindowRef                windowRef;
  323.     Str255                    numberAsString, titleString = "\puntitled "; 
  324.     Rect                        availableBoundsRect, portRect;
  325.     SInt16                    windowHeight;
  326.     TXNFrameOptions    txnFrameOptions;
  327.     OSStatus                osStatus    = noErr;
  328.     TXNObject                txnObject    = NULL;
  329.     TXNFrameID            txnFrameID;
  330.     RGBColor                frameColour = { 0xEEEE, 0xEEEE, 0xEEEE };
  331.     TXNControlTag        txnControlTag[1];
  332.     TXNControlData    txnControlData[1];
  333.     TXNMargins            txnMargins;
  334.   CGContextRef        cgContextRef;
  335.  
  336.     // ……………………………………………………………………………………………………………………………………………………………………………………………………………… get window
  337.  
  338.     if(!(windowRef = GetNewCWindow(rNewWindow,NULL,(WindowRef) -1)))
  339.         return MemError();
  340.     SetPortWindowPort(windowRef);
  341.  
  342.     ChangeWindowAttributes(windowRef,kWindowInWindowMenuAttribute,0);
  343.  
  344.     gUntitledWindowNumber++;
  345.     if(gUntitledWindowNumber != 1)
  346.     {
  347.         NumToString(gUntitledWindowNumber,numberAsString);
  348.         doConcatPStrings(titleString,numberAsString);
  349.     }
  350.     SetWTitle(windowRef,titleString);
  351.  
  352.     // ………………………………………………………………………………………… extend window bottom to bottom of screen less the dock
  353.  
  354.     GetAvailableWindowPositioningBounds(GetMainDevice(),&availableBoundsRect);
  355.     GetWindowPortBounds(windowRef,&portRect);
  356.     LocalToGlobal(&topLeft(portRect));
  357.     windowHeight = availableBoundsRect.bottom - portRect.top;
  358.     SizeWindow(windowRef,630,windowHeight,false);
  359.  
  360.     // …………………………………………………………………………………………………………………………… get new TXNObject and attach window to it
  361.  
  362.     txnFrameOptions = kTXNWantHScrollBarMask | kTXNWantVScrollBarMask | kTXNShowWindowMask;
  363.  
  364.     osStatus = TXNNewObject(fileSpec,windowRef,NULL,txnFrameOptions,kTXNTextEditStyleFrameType,
  365.                                                     txnFileType,kTXNSystemDefaultEncoding,&txnObject,&txnFrameID,
  366.                                                     NULL);
  367.  
  368.     if(osStatus == noErr)
  369.     {
  370.         // ……………………………………………………………………………………………………………… associate frame ID and TXNObject with window
  371.  
  372.         SetWindowProperty(windowRef,kFileCreator,'tOBJ',sizeof(TXNObject),&txnObject);
  373.         SetWindowProperty(windowRef,kFileCreator,'tFRM',sizeof(TXNFrameID),&txnFrameID);
  374.         if(fileSpec != NULL)
  375.             SetWindowProperty(windowRef,kFileCreator,'FiSp',sizeof(FSSpec),fileSpec);
  376.         SetWindowProperty(windowRef,kFileCreator,'FiTy',sizeof(TXNFileType),&txnFileType);
  377.  
  378.         // ……………………………………………………………………………………………………………………………………………………………………………………………………… set margins
  379.  
  380.         txnControlTag[0] = kTXNMarginsTag;
  381.         txnControlData[0].marginsPtr = &txnMargins;
  382.     
  383.         txnMargins.leftMargin  = txnMargins.topMargin = 10;
  384.         txnMargins.rightMargin = txnMargins.bottomMargin = 10;
  385.         TXNSetTXNObjectControls(txnObject,false,1,txnControlTag,txnControlData);
  386.  
  387.         // …………………………………………………………………………………………………………… create core graphics context and pass to MLTE
  388.  
  389.         if(gRunningOnX)
  390.         {
  391.             CreateCGContextForPort(GetWindowPort(windowRef),&cgContextRef);
  392.             txnControlTag[0] = kATSUCGContextTag;
  393.             txnControlData[0].uValue = (UInt32) cgContextRef;
  394.             TXNSetTXNObjectControls(txnObject,false,1,txnControlTag,txnControlData);
  395.         }
  396.     }
  397.     else
  398.         doErrorAlert(osStatus); 
  399.  
  400.     gCurrentNumberOfWindows ++;
  401.     if(gCurrentNumberOfWindows == 1)
  402.         doEnableDisableMenus(true);
  403.  
  404.     *outWindowRef = windowRef;
  405.  
  406.     return noErr;
  407. }
  408.  
  409. // ******************************************************************************** doOpenFile
  410.  
  411. OSStatus  doOpenFile(FSSpec fileSpec,OSType fileType)
  412. {
  413.     OSStatus        osStatus = noErr;
  414.     WindowRef        windowRef;
  415.     AliasHandle    aliasHdl;
  416.  
  417.     if(osStatus = doNewDocWindow(&windowRef,&fileSpec,fileType))
  418.         return osStatus;
  419.  
  420.     SetWTitle(windowRef,fileSpec.name);
  421.  
  422.     SetWindowProxyFSSpec(windowRef,&fileSpec);
  423.     GetWindowProxyAlias(windowRef,&aliasHdl);
  424.     SetWindowProperty(windowRef,kFileCreator,'tALH',sizeof(AliasHandle),&aliasHdl);
  425.  
  426.     SetWindowModified(windowRef,false);
  427.  
  428.     return noErr;
  429. }
  430.  
  431. // ******************************************************************************* doCloseFile
  432.  
  433. void  doCloseWindow(WindowRef windowRef,TXNObject txnObject)
  434. {
  435.     TXNDeleteObject(txnObject);
  436.     DisposeWindow(windowRef);
  437.     gCurrentNumberOfWindows --;
  438.     if(gCurrentNumberOfWindows == 0)
  439.         doEnableDisableMenus(false);
  440. }
  441.  
  442. // ******************************************************************************* doWriteFile
  443.  
  444. OSStatus  doWriteFile(WindowRef windowRef,Boolean newFile)
  445. {
  446.     TXNPermanentTextEncodingType    encodingType;
  447.     TXNObject        txnObject = NULL;
  448.     FSSpec            fileSpec, fileSpecTemp;
  449.     TXNFileType    txnFileType;
  450.     UInt32            currentTime;
  451.     Str255            tempFileName;
  452.     OSStatus        osStatus    = noErr;
  453.     SInt16            tempFileVolNum, tempFileRefNum, tempResForkRefNum = -1;
  454.     SInt32            tempFileDirID;
  455.     Boolean            hasResFile = false;
  456.  
  457.     GetWindowProperty(windowRef,kFileCreator,'tOBJ',sizeof(TXNObject),NULL,&txnObject);
  458.     GetWindowProperty(windowRef,kFileCreator,'FiSp',sizeof(FSSpec),NULL,&fileSpec);
  459.     GetWindowProperty(windowRef,kFileCreator,'FiTy',sizeof(TXNFileType),NULL,&txnFileType);
  460.  
  461.     encodingType = (txnFileType == kTXNTextFile) ? kTXNMacOSEncoding : kTXNUnicodeEncoding;
  462.  
  463.     GetDateTime(¤tTime);
  464.     NumToString((SInt32) currentTime,tempFileName);
  465.     
  466.     osStatus = FindFolder(fileSpec.vRefNum,kTemporaryFolderType,kCreateFolder,&tempFileVolNum,
  467.                                                 &tempFileDirID);
  468.     if(osStatus == noErr)
  469.         osStatus = FSMakeFSSpec(tempFileVolNum,tempFileDirID,tempFileName,&fileSpecTemp);
  470.     if(osStatus == noErr || osStatus == fnfErr)
  471.         osStatus = FSpCreate(&fileSpecTemp,'trsh','trsh',smSystemScript);
  472.     if(osStatus == noErr)
  473.         osStatus = FSpOpenDF(&fileSpecTemp,fsRdWrPerm,&tempFileRefNum);
  474.  
  475.     if(osStatus == noErr)
  476.     {
  477.         if(txnFileType == kTXNTextFile)
  478.         {
  479.             FSpCreateResFile(&fileSpecTemp,'trsh','trsh',smSystemScript);
  480.             osStatus = ResError();
  481.             if(osStatus == noErr)
  482.                 tempResForkRefNum = FSpOpenResFile(&fileSpecTemp,fsRdWrPerm);
  483.             hasResFile = true;
  484.         }
  485.     }
  486.  
  487.     if(osStatus == noErr)
  488.         osStatus = TXNSave(txnObject,txnFileType,kTXNMultipleStylesPerTextDocumentResType,
  489.                                              encodingType,&fileSpec,tempFileRefNum,tempResForkRefNum);
  490.     
  491.     if(osStatus == noErr)
  492.         osStatus = FSpExchangeFiles(&fileSpecTemp,&fileSpec);
  493.     if(osStatus == noErr)
  494.         osStatus = FSpDelete(&fileSpecTemp);
  495.  
  496.     if(osStatus == noErr)
  497.         osStatus = FSClose(tempFileRefNum);
  498.     if(osStatus == noErr)
  499.         if(tempResForkRefNum != -1)
  500.             CloseResFile(tempResForkRefNum);
  501.  
  502.     osStatus = ResError();
  503.  
  504.     if(osStatus == noErr)
  505.         if(newFile)
  506.             osStatus = doCopyResources(fileSpec,txnFileType,hasResFile);
  507.  
  508.     return osStatus;
  509. }
  510.  
  511. // *************************************************************************** doCopyResources
  512.  
  513. OSStatus  doCopyResources(FSSpec fileSpec,TXNFileType fileType,Boolean hasResFile)
  514. {
  515.     OSStatus    osStatus = noErr;
  516.     SInt16        fileRefNum;
  517.  
  518.     if(!hasResFile)
  519.         FSpCreateResFile(&fileSpec,kFileCreator,fileType,smSystemScript);
  520.  
  521.     osStatus = ResError();
  522.     if(osStatus == noErr)
  523.         fileRefNum = FSpOpenResFile(&fileSpec,fsRdWrPerm);
  524.  
  525.     if(fileRefNum > 0)
  526.         osStatus = doCopyAResource('STR ',-16396,gAppResFileRefNum,fileRefNum);
  527.     else
  528.         osStatus = ResError();
  529.  
  530.     if(osStatus == noErr)
  531.         CloseResFile(fileRefNum); 
  532.  
  533.     osStatus = ResError();
  534.  
  535.     return osStatus;
  536. }
  537.  
  538. // *************************************************************************** doCopyAResource
  539.  
  540. OSStatus  doCopyAResource(ResType resourceType,SInt16 resourceID,SInt16 sourceFileRefNum,
  541.                                             SInt16 destFileRefNum)
  542. {
  543.     Handle    sourceResourceHdl;
  544.     Str255    sourceResourceName;
  545.     ResType    ignoredType;
  546.     SInt16    ignoredID;
  547.  
  548.     UseResFile(sourceFileRefNum);
  549.  
  550.     sourceResourceHdl = GetResource(resourceType,resourceID);
  551.  
  552.     if(sourceResourceHdl != NULL)
  553.     {
  554.         GetResInfo(sourceResourceHdl,&ignoredID,&ignoredType,sourceResourceName);
  555.         DetachResource(sourceResourceHdl);
  556.         UseResFile(destFileRefNum);
  557.         AddResource(sourceResourceHdl,resourceType,resourceID,sourceResourceName);
  558.         if(ResError() == noErr)
  559.             UpdateResFile(destFileRefNum);
  560.     }
  561.  
  562.     ReleaseResource(sourceResourceHdl);
  563.  
  564.     return ResError();
  565. }
  566.  
  567. // ************************************************************************** navEventFunction
  568.  
  569. void  navEventFunction(NavEventCallbackMessage callBackSelector,NavCBRecPtr callBackParms,
  570.                                              NavCallBackUserData callBackUD)
  571. {
  572.     WindowRef    windowRef;
  573.  
  574.     switch(callBackSelector)
  575.     {
  576.         case kNavCBEvent:
  577.             switch(callBackParms->eventData.eventDataParms.event->what)
  578.             {
  579.                 case updateEvt:
  580.                     windowRef = (WindowRef) callBackParms->eventData.eventDataParms.event->message;
  581.                     if(GetWindowKind(windowRef) != kDialogWindowKind)
  582.                         doUpdate((EventRecord *) callBackParms->eventData.eventDataParms.event);
  583.                     break;
  584.             }
  585.             break;
  586.     } 
  587. }
  588.  
  589. // *******************************************************************************************