home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************
- CSmartTETask.c
-
- see header for information
-
- SUPERCLASS = CTask
- ********************************************************************/
-
-
- #include "CSmartTETask.h"
- #include "CSmartEditText.h"
- #include "CSmartDocument.h"
-
- /*****************************************************************************/
- void CSmartTETask::ISmartTETask( CSmartEditText *theEditText, Int16 firstNameIndex,
- tTE_Command theCommand)
- {
- Handle h;
-
- CTask::ITask( firstNameIndex + (Int16) theCommand);
- itsEditText = theEditText;
- itsCommand = theCommand;
-
- itsEditText->GetSelection( &startSel, &endSel);
- wasDirty = itsEditText->IsDirty();
-
- h = itsEditText->GetTextHandle();
- /*FailNIL( h);*/
- HandToHand( &h);
- /*FailMemError();*/
-
- undoText = h;
-
- } /* CSmartTETask::ISmartTETask */
- /*****************************************************************************/
- void CSmartTETask::Undo( void)
- {
- Handle tmp;
- Boolean tmpDirty;
- Int16 tmpStart, tmpEnd;
-
- /* need to make sure the right edit text is active */
- if (!itsEditText->IsActive() && itsEditText->itsSmartDoc)
- {
- itsEditText->itsSmartDoc->ActivateEditItem( itsEditText);
- }
-
- tmp = itsEditText->GetTextHandle();
- /*FailNIL( tmp);*/
- HandToHand( &tmp);
- /*FailMemError();*/
-
- itsEditText->GetSelection( &tmpStart, &tmpEnd);
-
- itsEditText->SetTextHandle( undoText);
- DisposHandle( undoText); /* CEditText makes a copy */
-
- itsEditText->SetSelection( startSel, endSel);
-
- undoText = tmp;
-
- tmpDirty = itsEditText->IsDirty();
- itsEditText->SetDirty( wasDirty);
- wasDirty = tmpDirty;
-
- startSel = tmpStart;
- endSel = tmpEnd;
-
- } /* CSmartTETask::Undo */
- /*****************************************************************************/
- void CSmartTETask::Dispose( void)
- {
- if (undoText) DisposHandle( undoText);
- inherited::Dispose();
-
- } /* CSmartTETask::Dispose */
- /*****************************************************************************/
-