home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-15 | 3.9 KB | 185 lines | [TEXT/CWIE] |
- /*
-
- File: MultiPaneDialogWindow.cp
- Project: Sprocket Framework 1.1 (DR2), released 6/15/96
- Contains: A simple dialog window recipe
- To Do: Whatever your heart desires
-
- Sprocket Major Contributors:
- ----------------------------
- Dave Falkenburg, producer of Sprocket 1.0
- Bill Hayden, producer of Sprocket 1.1
- Steve Sisak, producer of the upcoming Sprocket 2.0
-
- Pete Alexander Steve Falkenburg Randy Thelen
- Eric Berdahl Nitin Ganatra Chris K. Thomas
- Marshall Clow Dave Hershey Leonard Rosenthal
- Tim Craycroft Dave Mark Dean Yu
- David denBoer Gary Powell
- Cameron Esfahani Jon Summers Apple Computer, Inc.
-
- Comments, Additions, or Corrections:
- ------------------------------------
- Bill Hayden, Nikol Software <nikol@codewell.com>
-
- */
-
-
- #include "MultiPanelDialogWindow.h"
- #include "UDialog.h"
- #include "UGuide.h"
-
- #include "Sprocket.h"
-
-
-
- TMultiPanelDialogWindow::TMultiPanelDialogWindow(DialogTemplateID dialogTemplateID) : TDialogWindow(dialogTemplateID)
- {
- fGuideSearchString[0] = 0;
- }
-
-
-
- OSErr TMultiPanelDialogWindow::IMultiPanelDialogWindow(short defaultPanel, short guideItem, short panelSelectorItem)
- {
- fGuideItem = guideItem;
- fPanelSelectorItem = panelSelectorItem;
-
- this->CreateWindow(kModalWindow);
-
- if (fWindow == nil)
- return nilHandleErr;
-
- fOriginalCount = CountDITL((DialogRef)fWindow);
-
- Handle myDITL = GetResource('DITL', fTemplateID + defaultPanel);
- OSErr err = ResError();
-
- if (myDITL && !err)
- {
- AppendDITL((DialogRef)fWindow, myDITL, overlayDITL);
- ReleaseResource(myDITL);
-
- err = ResError();
- }
-
- if (err == noErr)
- {
- SetDialogDefaultItem((DialogRef)fWindow, 1);
- SetDialogCancelItem((DialogRef)fWindow, 1);
- SetDialogTracksCursor((DialogRef)fWindow, true);
-
- fCurrentPanel = defaultPanel;
-
- SetControlSetting((DialogRef)fWindow, panelSelectorItem, defaultPanel);
- }
-
- if (!gHasAppleGuide && !err)
- {
- if (guideItem != 0)
- SetControlActive((DialogRef)fWindow, guideItem, false);
- }
-
- // Your IMultiPanelDialogWindow() subclass _must_ call the following function:
- // this->InitPanel(defaultPanel);
-
- return err;
- }
-
-
-
- void TMultiPanelDialogWindow::ItemHit(short theItem)
- {
- OSErr err;
-
- if (theItem == kStdOkItemIndex)
- {
- this->ExitPanel(fCurrentPanel);
- this->Close();
- delete this; // As evidenced by this, save all your data as you go, or else do some serious work
- // in the destructor to save the data you just received.
- return;
- }
-
- if (theItem == fPanelSelectorItem)
- {
- short panel = GetControlSetting((DialogRef)fWindow, fPanelSelectorItem);
-
- if (panel == fCurrentPanel)
- return;
-
- this->ExitPanel(fCurrentPanel);
-
- ShortenDITL( (DialogRef)fWindow, CountDITL((DialogRef)fWindow) - fOriginalCount );
-
- Handle myDITL = GetResource('DITL', fTemplateID + panel);
- if (myDITL)
- {
- AppendDITL((DialogRef)fWindow, myDITL, overlayDITL);
- ReleaseResource(myDITL);
-
- fCurrentPanel = panel;
-
- this->InitPanel(fCurrentPanel);
- }
-
- return;
- }
-
- if (theItem == fGuideItem)
- {
- if (fGuideSearchString[0] > 0)
- err = OpenGuideFileWithSearch(fGuideSearchString);
- else
- err = OpenGuideFile();
-
- if (err == kAGErrDatabaseNotAvailable)
- ErrorAlert(131, 1, false);
- else if (err)
- ErrorReporter(err, __FILE__, __LINE__);
-
- return;
- }
-
- if (theItem > fOriginalCount)
- {
- short panel = GetControlSetting((DialogRef)fWindow, fPanelSelectorItem);
- this->ClickInPanel(panel, theItem);
- }
- }
-
- /*
-
- // Override this function to setup the dialog panel.
-
- void TMultiPanelDialogWindow::InitPanel(short thePanel)
- {
- switch(thePanel)
- {
- }
- }
-
-
- // Override this function to handle clicks in the active panel.
- // Don't forget to decrement theItem by fOriginalCount to get a true 1-based control ID.
-
- void TMultiPanelDialogWindow::ClickInPanel(short thePanel, short theItem)
- {
- switch(thePanel)
- {
- }
- }
-
-
- // Override this function to save data before switching panels.
-
- void TMultiPanelDialogWindow::ExitPanel(short thePanel)
- {
- switch(thePanel)
- {
- }
- }
- */
-
-
-