home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- CSmartDocument.c
-
- see header for more information
-
- SUPERCLASS = CSmartDocument
- *****************************************************************************/
-
- #include "CSmartDocument.h"
- #include "CList.h"
-
- extern CBureaucrat *gGopher;
- /*****************************************************************************/
- void CSmartDocument::ISmartDocument(CBureaucrat *aSupervisor,
- Boolean printable, Boolean closeDisposes)
- {
- CDocument::IDocument( aSupervisor, printable);
-
- /* create list for edit text items */
-
- itsEditItems = new( CList);
- itsEditItems->IList();
-
- this->closeDisposes = closeDisposes;
-
- } /* CSmartDocument::ISmartDocument */
- /*****************************************************************************/
- void CSmartDocument::AddEditItem( CSmartEditText *anEditItem)
- {
- /* add item to list of editable text items */
-
- itsEditItems->Append( anEditItem);
-
- } /* CSmartDocument::AddEditItem */
- /*****************************************************************************/
- void CSmartDocument::ActivateEditItem( CSmartEditText *anEditText)
- {
-
- if (itsActiveText) itsActiveText->SetTarget( FALSE);
- itsActiveText = anEditText; /* NOTE: could be NIL */
- if (anEditText)
- {
- anEditText->SetTarget( TRUE);
- itsGopher = anEditText;
- }
- else itsGopher = this; /* if NIL then gopher is the document */
-
- if (active) gGopher = itsGopher; /* if we're active set the
- global gopher */
-
- } /* CSmartDocument::ActivateEditItem */
- /*****************************************************************************/
- void CSmartDocument::ActivateNextEditItem( CSmartEditText *currItem)
- /*
- activate next item in list, as in tabbing thru items.
- */
- { Int32 nextIndex;
- CSmartEditText *nextEdit;
- Boolean foundVisible = false;
-
- /* search list for next editable text item that is visible and editable */
-
- nextEdit = currItem;
- while (!foundVisible)
- {
- nextIndex = itsEditItems->FindIndex( nextEdit) + 1;
- nextEdit = (CSmartEditText *) itsEditItems->NthItem( nextIndex);
- if (nextEdit == currItem)
- { /* we've wrapped around */
-
- nextEdit = NIL;
- break;
- }
- if (!nextEdit) nextEdit = (CSmartEditText *) itsEditItems->FirstItem();
- foundVisible = nextEdit->ReallyVisible() && nextEdit->IsEditable();
-
- }
- if ((nextEdit != NIL)&&(nextEdit != currItem))
- {
- ActivateEditItem( nextEdit);
- nextEdit->SelectAll();
- }
-
- } /* CSmartDocument::ActivateNextEditItem */
- /*****************************************************************************/
- void CSmartDocument::SelectWindow( void)
- {
- if (itsWindow) itsWindow->Select();
-
- } /* CSmartDocument::SelectWindow */
- /*****************************************************************************/
- void CSmartDocument::HideWindow( void)
- {
- if (itsWindow) itsWindow->Hide();
-
- } /* CSmartDocument::HideWindow */
- /*****************************************************************************/
- Boolean CSmartDocument::Close( Boolean Quitting)
- {
- Boolean continueFlag = TRUE;
-
- if (closeDisposes)
- continueFlag = inherited::Close( Quitting);
- else HideWindow();
-
- return continueFlag;
-
- } /* CSmartDocument::CloseWind */
- /*****************************************************************************/
- void CSmartDocument::SetReturnGopher( CBureaucrat *aReturnGopher)
- {
- itsReturnGopher = aReturnGopher;
-
- } /* CSmartDocument::SetReturnGopher */
- /*****************************************************************************/
- void CSmartDocument::DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent)
- {
- if ((theChar == kCR)||(theChar == kEnter))
- {
- if (itsReturnGopher)
- itsReturnGopher->DoKeyDown( theChar, keyCode, macEvent);
- }
-
- } /* CSmartDocument::DoKeyDown */
- /*****************************************************************************/
- void CSmartDocument::Dispose( void)
- {
- itsEditItems->Dispose(); /* dispose list but not items, superclass does that */
- inherited::Dispose();
-
- } /* CSmartDocument::Dispose */
- /*****************************************************************************/
-