home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-13 | 48.6 KB | 1,606 lines | [TEXT/MPS ] |
- /*------------------------------------------------------------------------------
-
- File: TextEditorLayout.cpp
-
- Description: TextEditor's layout protocol methods.
-
- Written by: Steve Smith
-
- Copyright: © 1994 - 1995 by Apple Computer, Inc., all rights reserved.
-
- ------------------------------------------------------------------------------*/
-
- // Notification that this is a SOM source file
- #define SampleCode_TextEditor_Class_Prototypes
- // define underscore (_) field names
- #define VARIABLE_MACROS
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- // -- OpenDoc Utilities --
-
- #ifndef _EXCEPT_
- // Exceptions define several important macros (e.g. CHECKENV)
- // which are used in the SOM method dispatch glue. If Except.h
- // is not included early enough, exceptions may not be thrown
- // correctly when returning from a SOM method with "ev" parameter set.
- #include <Except.h>
- #endif
-
- // -- TextEditor Includes
-
- #ifndef SOM_SampleCode_TextEditor_xih
- #include "TextEditor.xih"
- #endif
-
- #ifndef _TEXTEDITORDEF_
- #include "TextEditorDef.h"
- #endif
-
- #ifndef _TEXTEDITORUTILS_
- #include "TextEditorUtils.h"
- #endif
-
- #ifndef _TEXTEDITORGLOBALS_
- #include "TextEditorGlobals.h"
- #endif
-
- // -- OpenDoc Includes --
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_ODCanvas_xh
- #include <Canvas.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
- #ifndef SOM_ODFrameFacetIterator_xh
- #include <FrFaItr.xh>
- #endif
-
- #ifndef SOM_ODNameSpaceManager_xh
- #include <NmSpcMg.xh>
- #endif
-
- #ifndef SOM_ODObjectNameSpace_xh
- #include <ObjectNS.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODPart_xh
- #include <Part.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #ifndef SOM_ODWindowState_xh
- #include <WinStat.xh>
- #endif
-
- // -- OpenDoc Utilities --
-
- #ifndef _BNDNSUTL_
- #include <BndNSUtl.h>
- #endif
-
- #ifndef _ISOSTR_
- #include <ISOStr.h>
- #endif
-
- #ifndef _ITEXT_
- #include <IText.h>
- #endif
-
- #ifndef _ODMEMORY_
- #include <ODMemory.h>
- #endif
-
- #ifndef _ODUTILS_
- #include <ODUtils.h>
- #endif
-
- #ifndef _TEMPITER_
- #include <TempIter.h>
- #endif
-
- #ifndef _TEMPOBJ_
- #include <TempObj.h>
- #endif
-
- #ifndef _USERSRCM_
- #include <UseRsrcM.h>
- #endif
-
- // -- Macintosh Includes --
-
- #ifndef __ICONS__
- #include <Icons.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
-
- // -- Textension Includes --
-
- #ifndef _Textension_
- #include "Textension.h"
- #endif
-
- #ifndef _TSMTextension_
- #include "TSMTextension.h"
- #endif
-
-
- //------------------------------------------------------------------------------
- // Method: DisplayFrameAdded
- // Origin: ODPart
- //
- // Description: This method is called in response to a frame being created for
- // the part.
- //
- // The part records the existence of a new display frame in its
- // internal display frame list, as well as, verify that the frame
- // is "set up" correctly (i.e., valid viewType). The part also
- // creates and stores its "frame info" class in the new frame.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope void
- SOMLINK TextEditor__DisplayFrameAdded
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","DisplayFrameAdded");
-
- SOM_TRY
-
- // If we are being embedded in another part, the presentation field
- // will (most likely) be unset; we need to set it something meaningful.
- // The view field may also be unset, if so, we prefer to be displayed
- // in a frame view.
-
- if ( frame->GetPresentation(ev) != gGlobals->fMainPresentation
- && frame->GetPresentation(ev) != gGlobals->fRulerPresentation)
- frame->SetPresentation(ev, gGlobals->fMainPresentation);
-
- if ( frame->GetViewType(ev) == kODNullTypeToken )
- frame->SetViewType(ev, gGlobals->fFrameView);
-
- if ( frame->GetPresentation(ev) == gGlobals->fMainPresentation )
- {
- // Tell OpenDoc the frame can accept dragged content.
- frame->SetDroppable(ev, kODTrue);
-
- // Hang our "state" info off of the new display frame. We use
- // the CFrameInfo object for activation, updating, and window
- // maintenance.
- CFrameInfo* frameInfo = new CFrameInfo(ODGetSession(ev, somSelf));
- frame->SetPartInfo(ev, (ODInfoType)frameInfo);
-
- // If the frame being added is a root frame, we know that a window
- // is associated with this frame. Notify ourselves that we need to
- // clean it up when the frame goes away.
- if ( frame->IsRoot(ev) )
- frameInfo->SetShouldDisposeWindow(kODTrue);
-
- // The proxy class will refcount the frame passed to it, so we
- // don't need to worry about refcounting the display frame.
- CFrameProxy* proxy = new CFrameProxy;
- proxy->InitFrameProxy(ev,frame);
-
- // Add the proxy to the display frame collection.
- _fDisplayFrames->Add(proxy);
-
- // Since we maintain a persistent list of weak references to our
- // display frames, having one added to the part dirties it.
- somSelf->SetDirty(ev);
-
- // Embedded frames are sequenced.
- if ( !frame->IsRoot(ev) )
- {
- long seqNumber = 1; // $$$$$$
-
- frame->ChangeSequenceNumber(ev, seqNumber);
-
- _fPageMargins.top = _fPageMargins.left = _fPageMargins.bottom =
- _fPageMargins.right = kDefaultEmbeddedMargin; /* pixels */
- // Set default margins
- }
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: DisplayFrameConnected
- // Origin: ODPart
- //
- // Description: This method is called when one of our display frames, previously
- // written out, is internalized. This method is called instead of
- // DisplayFrameAdded because a "new" frame is not being created;
- // an existing one is being reconstituted.
- //
- // The part has nothing special to do, so we just add it to the
- // part's internal display frame list.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope void
- SOMLINK TextEditor__DisplayFrameConnected
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","DisplayFrameConnected");
-
- SOM_TRY
-
- // Iterate over our display collection to match the frame with
- // an existing proxy with the correct frame ID. If we find it,
- // replace the ID with the actual frame. If we don't find it,
- // treat it as a newly "added" frame.
- ODBoolean found = kODFalse;
- CListIterator fiter(_fDisplayFrames);
- for ( CFrameProxy* proxy = (CFrameProxy*) fiter.First();
- fiter.IsNotComplete(); proxy = (CFrameProxy*) fiter.Next() )
- {
- if ( proxy->GetID() == frame->GetID(ev) )
- {
- // The proxy class will refcount the frame passed to it, so we
- // don't need to worry about refcounting the display frame.
- proxy->SetFrame(ev,frame);
- found = kODTrue;
- }
- }
-
- // Parts typically operate under the assumption that they have previous
- // knowledge of a frame before it is connected to it. This knowledge
- // should come from having read in the frame reference when the part
- // was internalized. If the frame is an "unknown", the part was probably
- // bound to another editors storage unit because the editor is missing or
- // the user changed the editor in the Info dialog.
- if ( found )
- {
- // If a display frame is connected to us with an unrecognizable
- // presentation, we need to set it to something meaningful.
- if ( frame->GetPresentation(ev) != gGlobals->fMainPresentation
- && frame->GetPresentation(ev) != gGlobals->fRulerPresentation)
- frame->SetPresentation(ev, gGlobals->fMainPresentation);
-
- // Handle the main presentation.
- if ( frame->GetPresentation(ev) == gGlobals->fMainPresentation )
- {
- // If the frame being added is a root frame, we know that a window
- // is associated with this frame. Notify ourselves that we need to
- // clean it up when the frame goes away.
- if ( frame->IsRoot(ev) )
- {
- CFrameInfo* frameInfo = (CFrameInfo*) frame->GetPartInfo(ev);
- frameInfo->SetShouldDisposeWindow(kODTrue);
-
- // In addition, we need to verify that the frame is in "frame" view.
- // If the user dragged an icon from a document to Finder and then
- // opens the resultant document, the view would be "icon". However
- // displaying a icon is useless, so we need to change the view to
- // frame.
- if ( frame->GetViewType(ev) != gGlobals->fFrameView )
- frame->SetViewType(ev, gGlobals->fFrameView);
- }
-
- // Tell OpenDoc the frame can accept dragged content.
- frame->SetDroppable(ev, kODTrue);
- }
- }
- else
- {
- // If an unrecognizable frame is connected to us, treat it like a "new"
- // frame and call our method to add it.
- somSelf->DisplayFrameAdded(ev, frame);
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: DisplayFrameRemoved
- // Origin: ODPart
- //
- // Description: This method is called in response to a frame being removed from
- // the part.
- //
- // The part removes the frame from its internal display frame list
- // and reliquishes any foci that it still owned. Lastly, if the
- // frame has a source frame (it was the root frame of a part
- // window), we will record the part window bounds so that any
- // subsequent part windows opened on the source frame will appear
- // in the same location.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope void
- SOMLINK TextEditor__DisplayFrameRemoved
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","DisplayFrameRemoved");
-
- if ( frame->GetPresentation(ev) == gGlobals->fRulerPresentation )
- return;
-
- SOM_TRY
- CFrameInfo* frameInfo = (CFrameInfo*) frame->GetPartInfo(ev);
-
- // Make sure the frame going away doesn't own any foci. Forgetting
- // to do this, will cause a "refcounting" error when the frame
- // is deleted by the draft.
- somSelf->RelinquishAllFoci(ev, frame);
-
- // Clean up the display frame.
- somSelf->CleanupDisplayFrame(ev, frame, kFrameRemoved);
-
- // Clean up any associated window.
- somSelf->CleanupWindow(ev, frame);
-
- // Dispose of the frame's runtime state info.
- frame->SetPartInfo(ev, (ODInfoType) kODNULL);
- ODDeleteObject(frameInfo);
-
- // Remove the display frame from our collection.
- CListIterator fiter(_fDisplayFrames);
- for ( CFrameProxy* proxy = (CFrameProxy*) fiter.First();
- fiter.IsNotComplete(); proxy = (CFrameProxy*) fiter.Next() )
- {
- if ( ODObjectsAreEqual(ev, proxy->GetFrame(ev), frame) )
- {
- // Delete the proxy object and its contents. The frame's
- // refcount will be decremented in the proxy destructor.
- fiter.RemoveCurrent();
- delete proxy;
- }
- }
-
- // Since we maintain a persistent list of weak references to our
- // display frames, having one removed from the part dirties it.
- somSelf->SetDirty(ev);
-
- SOM_CATCH_ALL
- // Alert the user of the problem.
- somSelf->DoDialogBox(ev, frame, kErrorBoxID, kErrRemoveFrame);
- // Change the exception value, so the DocShell doesn't display an
- // error dialog.
- SetErrorCode(kODErrAlreadyNotified);
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: DisplayFrameClosed
- // Origin: ODPart
- //
- // Description: This method is called in response to a frame being closed as a
- // result of the document having been closed by the user.
- //
- // The part behaves much the same way that it would if a frame were
- // removed (see above), except that we don't need to cache runtime
- // information.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope void
- SOMLINK TextEditor__DisplayFrameClosed
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","DisplayFrameClosed");
-
- if ( frame->GetPresentation(ev) == gGlobals->fRulerPresentation )
- return;
-
- SOM_TRY
-
- CFrameInfo* frameInfo = (CFrameInfo*) frame->GetPartInfo(ev);
-
- // Make sure the frame going away doesn't own any foci. Forgetting
- // to do this, will cause a "refcounting" error when the frame
- // is deleted by the draft.
- somSelf->RelinquishAllFoci(ev, frame);
-
- // Clean up the display frame.
- somSelf->CleanupDisplayFrame(ev, frame, kFrameClosed);
-
- // Clean up any associated window.
- somSelf->CleanupWindow(ev, frame);
-
- // Dispose of the frame's runtime state info.
- frame->SetPartInfo(ev, (ODInfoType) kODNULL);
- ODDeleteObject(frameInfo);
-
- // Remove the display frame from our collection.
- CListIterator fiter(_fDisplayFrames);
- for ( CFrameProxy* proxy = (CFrameProxy*) fiter.First();
- fiter.IsNotComplete(); proxy = (CFrameProxy*) fiter.Next() )
- {
- if ( proxy->GetID() == frame->GetID(ev) )
- {
- // Release the frame reference, but don't get rid of the
- // proxy object because "closed" frames may be reconnected
- // before the document is closed.
- proxy->Purge(ev);
- }
- }
-
- SOM_CATCH_ALL
- // Alert the user of the problem.
- somSelf->DoDialogBox(ev, frame, kErrorBoxID, kErrRemoveFrame);
- // Change the exception value, so the DocShell doesn't display an
- // error dialog.
- SetErrorCode(kODErrAlreadyNotified);
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: CleanupDisplayFrame
- // Origin: TextEditor
- //
- // Description: This method is called when a frame has been closed or removed.
- // The method cleans up the references and state information stored
- // in the CFrameInfo class.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope void
- SOMLINK TextEditor__CleanupDisplayFrame
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame,
- ODBoolean frameRemoved
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","CleanupDisplayFrame");
-
- if ( frame->GetPresentation(ev) == gGlobals->fRulerPresentation )
- return;
-
- SOM_TRY
-
- ODError error = noErr;
- CFrameInfo* frameInfo = (CFrameInfo*) frame->GetPartInfo(ev);
-
- TRY
- // If we are the root of a child window, we need to notify
- // our source frame that we are going away.
- if ( frameInfo->HasSourceFrame() )
- {
- ODFrame* sourceFrame = frameInfo->GetSourceFrame(ev);
- CFrameInfo* sourceFrameInfo = (CFrameInfo*) sourceFrame->GetPartInfo(ev);
-
- if ( frameRemoved )
- {
- // Invalidate the source frame. We do this because the
- // source frame may have a unique display when it has
- // been opened into a part window. This forces the
- // frame to redraw "not opened".
- sourceFrame->Invalidate(ev, kODNULL, kODNULL);
- }
-
- // Tell the source frame that its dependent is going away.
- sourceFrameInfo->ReleaseDependentFrame(ev);
-
- // Release our reference to the source frame.
- frameInfo->ReleaseSourceFrame(ev);
-
- // If the frame is the root, it is a part window going away
- // and we need to notify our source frame that it no longer
- // has a part window.
- if ( frame->IsRoot(ev) )
- sourceFrameInfo->SetPartWindow(ev, kODNULL);
- }
- CATCH_ALL
- error = ErrorCode();
- ENDTRY
-
- TRY
- // If the frame was removed from the document, we need to remove
- // any child window displaying that frame.
- if ( frameRemoved )
- {
- // If we have a child window, we need to close it.
- ODWindow* window = frameInfo->AcquirePartWindow(ev);
-
- if ( window )
- {
- frameInfo->SetPartWindow(ev, kODNULL);
- window->CloseAndRemove(ev);
- }
- }
- CATCH_ALL
- error = ErrorCode();
- ENDTRY
-
- TRY
- // If we have dependent frames, we need to notify them that we
- // are going away.
-
- if ( frameInfo->HasDependentFrame() )
- {
- // Get the frame that is dependent on this one. We can safely
- // do this because we only reference our own display frames.
- ODFrame* dependentFrame = frameInfo->GetDependentFrame(ev);
- CFrameInfo* dependentFrameInfo = (CFrameInfo*) dependentFrame->GetPartInfo(ev);
-
- // Tell the dependent frame that its source is going away.
- dependentFrameInfo->ReleaseSourceFrame(ev);
-
- // Release our reference to the dependent frame.
- frameInfo->ReleaseDependentFrame(ev);
- }
- CATCH_ALL
- error = ErrorCode();
- ENDTRY
-
- // If anything went wrong, signal an error.
- THROW_IF_ERROR(error);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: AttachSourceFrame
- // Origin: ODPart
- //
- // Description: If the part which we are contained in is opened into a part
- // window, it is required to iterate over its embedded frames and
- // add new display frames in the part window. After each new
- // embedded frame is created, this method will be called.
- //
- // Given all that, and given our lack of interesting
- // content, we just validate the frame and attach it to its source.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope void
- SOMLINK TextEditor__AttachSourceFrame
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame,
- ODFrame* sourceFrame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","AttachSourceFrame");
-
- SOM_TRY
-
- // Tell the new frame about its source.
- CFrameInfo* frameInfo = (CFrameInfo*) frame->GetPartInfo(ev);
- frameInfo->SetSourceFrame(ev, sourceFrame);
-
- // And tell the source about its new dependent.
- frameInfo = (CFrameInfo*) sourceFrame->GetPartInfo(ev);
- frameInfo->SetDependentFrame(ev, frame);
-
- // In both cases, refcounting of the frame and sourceFrame is
- // handled by the CFrameInfo class.
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: ViewTypeChanged
- // Origin: ODPart
- //
- // Description: This method is called in response to one of our display frame's
- // viewType field being modified. We call this method on ourselves
- // when new display frames are added, but it call also be called
- // when the user changes the view in the "part info" dialog.
- //
- // The part first loads the appropriate view icons if needed and
- // then calculates a new "used" shape based on the bounds of the
- // new view type. If any problems occur while changing the view,
- // the part defaults back to frame view (the part's default view).
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope void
- SOMLINK TextEditor__ViewTypeChanged
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","ViewTypeChanged");
-
- SOM_TRY
- Handle iconSuite = kODNULL;
-
- ODTypeToken view = frame->GetViewType(ev);
-
- // Prepare to be displayed in a different view.
- if ( view == gGlobals->fThumbnailView )
- somSelf->GenerateThumbnail(ev, frame);
-
- // Change this frame's used shape to match the new view setting.
- TempODShape newUsedShape = somSelf->CalcNewUsedShape(ev, frame);
-
- frame->Invalidate(ev, kODNULL, kODNULL);
- frame->ChangeUsedShape(ev, newUsedShape, kODNULL);
- frame->Invalidate(ev, kODNULL, kODNULL);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: CalcNewUsedShape
- // Origin: TextEditor
- //
- // Description: This method is called in response to one of display frame's view
- // being changed. The method calculates the appropriate usedShape
- // for the new view type.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope ODShape*
- SOMLINK TextEditor__CalcNewUsedShape
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","CalcNewUsedShape");
-
- ODShape* usedShape = kODNULL;
-
- SOM_TRY
- ODTypeToken view = frame->GetViewType(ev);
-
- // If the view is "frame", we intentionally return a nil shape;
- // doing so, will reset the used shape to equal the frame shape.
-
- if ( view == gGlobals->fLargeIconView
- || view == gGlobals->fSmallIconView
- || view == gGlobals->fThumbnailView )
- {
- TRY
- RgnHandle usedRgn = ODNewRgn();
-
- TRY
- Rect bounds;
- if ( view == gGlobals->fLargeIconView || view == gGlobals->fSmallIconView )
- {
- CUsingLibraryResources res;
-
- // Set the bounds rect for the icon size.
- SetRect(&bounds, 0, 0,
- (view == gGlobals->fLargeIconView) ? kODLargeIconSize : kODSmallIconSize,
- (view == gGlobals->fLargeIconView) ? kODLargeIconSize : kODSmallIconSize);
-
- // Convert the icon mask into a Region.
- THROW_IF_ERROR(IconIDToRgn(usedRgn, &bounds, atAbsoluteCenter, kBaseResourceID));
- }
- else if ( view == gGlobals->fThumbnailView )
- {
- bounds = (**(PicHandle) gGlobals->fThumbnail).picFrame;
- RectRgn(usedRgn,&bounds);
- }
-
- // We use a temp shape here so that in case of an exception, the usedShape
- // will still be NULL and doesn't have to be caught and fixed up.
- TempODShape usedShape = frame->CreateShape(ev);
- usedShape->SetQDRegion(ev, usedRgn);
- CATCH_ALL
- DisposeRgn(usedRgn);
- RERAISE;
- ENDTRY
-
- CATCH_ALL
- ODSafeReleaseObject(usedShape);
- usedShape = kODNULL;
- ENDTRY
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return usedShape;
- }
-
- //------------------------------------------------------------------------------
- // Method: UpdateFrame
- // Origin: TextEditor
- //
- // Description: This method is called in response to one of our
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope void
- SOMLINK TextEditor__UpdateFrame
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame,
- ODTypeToken view,
- ODShape* usedShape
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","UpdateFrame");
-
- SOM_TRY
-
- // Update the frame to have the new view and UsedShape.
- frame->Invalidate(ev, kODNULL, kODNULL);
- frame->SetViewType(ev, view);
- frame->ChangeUsedShape(ev, usedShape, kODNULL);
- frame->Invalidate(ev, kODNULL, kODNULL);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: FrameShapeChanged
- // Origin: ODPart
- //
- // Description: This method is called in response to a frame's shape being
- // altered, either by the user or the part we are embedded in.
- //
- // To keep all attached frames in sync, we need to propogate the
- // new frame shape the frames dependent on the changed frame. This
- // is done by observing the display frames stored in the frame info
- // and calling RequestFrameShape for each.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope void
- SOMLINK TextEditor__FrameShapeChanged
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","FrameShapeChanged");
-
- SOM_TRY
-
- if ( frame->GetPresentation(ev) == gGlobals->fMainPresentation )
- {
- // If the frame is the root frame of a part or document window, it should
- // have no effect on its dependent frames or source frame.
-
- if ( !frame->IsRoot(ev) )
- {
- TempODShape frameShape = frame->AcquireFrameShape(ev, kODNULL);
- CFrameInfo* frameInfo = (CFrameInfo*) frame->GetPartInfo(ev);
-
- if ( frameInfo->HasSourceFrame() )
- {
- ODFrame* displayFrame = frameInfo->GetSourceFrame(ev);
-
- TempODShape frameShapeCopy = frameShape->Copy(ev);
- TempODShape returnShape = displayFrame->RequestFrameShape(ev, frameShapeCopy, kODNULL);
-
- somSelf->CalcTextBounds(ev, displayFrame);
- displayFrame->Invalidate(ev, kODNULL, kODNULL);
- }
-
- if ( frameInfo->HasDependentFrame() )
- {
- ODFrame* displayFrame = frameInfo->GetDependentFrame(ev);
- {
- displayFrame = frameInfo->GetDependentFrame(ev);
-
- TempODShape frameShapeCopy = frameShape->Copy(ev);
- TempODShape returnShape = displayFrame->RequestFrameShape(ev, frameShapeCopy, kODNULL);
-
- somSelf->CalcTextBounds(ev, displayFrame);
- displayFrame->Invalidate(ev, kODNULL, kODNULL);
- }
- }
- }
-
- if ( frame->IsRoot(ev) )
- {
- somSelf->CalcViewRect(ev, frame);
- somSelf->RepositionScrollbars(ev, frame);
- }
- else
- {
- // We disable the drawing because focusing to facets when we are
- // not active is messy. The invalidate call will force redrawing.
- CTextensionDisplay* display = _fTextension->GetDisplayHandler();
- display->DisableDrawing();
-
- // Reset our text bounds.
- somSelf->CalcTextBounds(ev, frame);
-
- display->EnableDrawing();
- frame->Invalidate(ev, kODNULL, kODNULL);
- }
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: Open
- // Origin: ODPart
- //
- // Description: This method is called when OpenDoc, a containing part, or the
- // active editor would like to open a frame into a seperate window.
- // If a source frame is passed into this method, the editor is
- // being asked one of two things. If the frame is the root, we are
- // being asked to open an existing document. If the frame is not
- // the root, we are being asked to open a part window. If a source
- // frame is not specified, the editor is being asked to open a new
- // window.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope ODID
- SOMLINK TextEditor__Open
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","Open");
-
- ODID windowID = kODNULLID;
-
- SOM_TRY
-
- WindowProperties* windowProperties = kODNULL;
- ODVolatile(windowProperties);
-
- TRY
- TempODWindow window = kODNULL;
-
- // Because the frame parameter being passed to us can be one of
- // three things, we must determine what it is; either the root
- // frame of a existing document, the source frame for a part
- // window, or null if we are opening a new document.
-
- if ( frame == kODNULL )
- {
- // Calculate the bounding rectangle for a new window
- Rect windowRect = somSelf->CalcPartWindowSize(ev, kODNULL);
- // Get the default setting for a document window.
- windowProperties = somSelf->GetDefaultWindowProperties(ev, kODNULL, &windowRect);
- // Create a Mac Window and register it with OpenDoc.
- window = somSelf->CreateWindow(ev, kODNULL, kODFrameObject, windowProperties);
- }
- else if ( frame->IsRoot(ev) )
- {
- // Get the previously saved settings for the document window.
- windowProperties = somSelf->GetSavedWindowProperties(ev, frame);
-
- if ( windowProperties == kODNULL )
- {
- // Calculate the bounding rectangle for a new window
- Rect windowRect = somSelf->CalcPartWindowSize(ev, frame);
- // Get the default setting for a document window.
- windowProperties = somSelf->GetDefaultWindowProperties(ev, kODNULL, &windowRect);
- }
-
- // Create a Mac Window and register it with OpenDoc.
- window = somSelf->CreateWindow(ev, frame, kODFrameObject, windowProperties);
-
- // We bumped the ref count of the sourceFrame in GetSavedWindowProperties
- // to prevent it from being released too early. We release it here because
- // we are done accessing it.
- ODReleaseObject(ev, windowProperties->sourceFrame);
- }
- else // frame is a source frame
- {
- /*
- window = somSelf->AcquireFramesWindow(ev, frame);
-
- if ( window == kODNULL )
- {
- // Calculate the bounding rectangle for a new window
- Rect windowRect = this->CalcPartWindowSize(ev, frame);
- // Get the default setting for a document window.
- windowProperties = somSelf->GetDefaultWindowProperties(ev, frame, windowRect);
- // Create a Mac Window and register it with OpenDoc.
- window = somSelf->CreateWindow(ev, kODNULL, kODNonPersistentFrameObject, windowProperties);
-
- // Tell the source frame that it is opened in a part window.
- CFrameInfo* frameInfo = (CFrameInfo*) frame->GetPartInfo(ev);
- frameInfo->SetPartWindow(window);
- }
- */
- // Multiple window support has not yet been implemented.
- somSelf->DoDialogBox(ev, frame, kErrorBoxID, kErrUnimplemented);
- THROW(kODErrAlreadyNotified);
- }
-
- // Creates the root facet for the window and notifies the
- // part.
- window->Open(ev);
- // Makes the window visible.
- window->Show(ev);
- // Activates and selects the window.
- window->Select(ev);
-
- // Cleanup allocated memory.
- ODDeleteObject(windowProperties);
-
- // Get window id to return.
- windowID = (window ? window->GetID(ev) : kODNULLID);
-
- CATCH_ALL
- // If we threw early, the source frame's refcount may be too high.
- if ( windowProperties )
- ODSafeReleaseObject(windowProperties->sourceFrame);
- // Cleanup the created items.
- ODDeleteObject(windowProperties);
- windowID = kODNULLID;
- // Alert the caller.
- RERAISE;
- ENDTRY
-
- SOM_CATCH_ALL
- windowID = kODNULLID;
- SOM_ENDTRY
-
- return windowID;
- }
-
- //------------------------------------------------------------------------------
- // Method: AcquireFramesWindow
- // Origin: TextEditor
- //
- // Description: This method is called by the part when a frame, that has been
- // previously opened, is being opened again.
- //
- // The method retrieves the existing window for the frame and
- // returns it.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope ODWindow*
- SOMLINK TextEditor__AcquireFramesWindow
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","GetFramesWindow");
-
- ODWindow* window = kODNULL;
-
- SOM_TRY
- CFrameInfo* frameInfo = (CFrameInfo*) frame->GetPartInfo(ev);
- ODWindow* window = frameInfo->AcquirePartWindow(ev);
- SOM_CATCH_ALL
- window = kODNULL;
- SOM_ENDTRY
-
- return window;
- }
-
- //------------------------------------------------------------------------------
- // Method: CreateWindow
- // Origin: TextEditor
- //
- // Description: This method is called by the part when a window needs to be
- // created for a frame being opened.
- //
- // The part uses the information passed in windowProperties to
- // create the appropriate window. The generated window is
- // registered with OpenDoc as a new window (RegisterWindow) or as a
- // window from an existing document (RegisterWindowForFrame).
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope ODWindow*
- SOMLINK TextEditor__CreateWindow
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame,
- ODType frameType,
- WindowProperties* windowProperties
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","CreateWindow");
-
- ODWindow* window = kODNULL;
- ODVolatile(window);
-
- SOM_TRY
-
- ODPlatformWindow platformWindow = kODNULL;
-
- // Using the name and the calculated rectangle, create a new window.
- platformWindow = NewCWindow((Ptr) ODNewPtr(sizeof(WindowRecord)),
- &windowProperties->boundsRect,
- windowProperties->title,
- kODFalse, // visible
- windowProperties->procID,
- (WindowPtr) -1L,
- windowProperties->hasCloseBox,
- windowProperties->refCon);
-
- if ( platformWindow )
- {
- TRY
- ODWindowState* windowState = ODGetSession(ev, somSelf)->GetWindowState(ev);
-
- ODBoolean saveWindow = ODISOStrEqual(frameType, kODFrameObject);
-
- // Tell the window object that we will be disposing the window record
- // when the root frame is closed/removed.
- ODBoolean shouldDispose = kODFalse;
-
- // Determine whether we are creating a new window (frame is null),
- // or opening a previous saved window (frame is valid).
-
- if ( frame == kODNULL )
- {
- // Tell OpenDoc about it by creating an OpenDoc window object.
- window = windowState->
- RegisterWindow(ev,
- platformWindow, // Macintosh WindowPtr
- frameType, // Frame type (Persistent/Non-persistent)
- windowProperties->isRootWindow, // Is this a document window?
- windowProperties->isResizable, // Is this window resizeable?
- windowProperties->isFloating, // Is this window floating?
- saveWindow, // Should this window be persistent?
- shouldDispose, // (see comment above)
- _fSelf, // Part reference to us
- gGlobals->fFrameView, // What view should the window have?
- gGlobals->fMainPresentation, // What presentation should the window have?
- windowProperties->sourceFrame); // The display frame being opened, if any
- }
- else
- {
- // Tell OpenDoc about it by creating an OpenDoc window object.
- window = windowState->
- RegisterWindowForFrame(ev,
- platformWindow, // Macintosh WindowPtr
- frame, // Frame type (Persistent/Non-persistent)
- windowProperties->isRootWindow, // Is this a document window?
- windowProperties->isResizable, // Is this window resizeable?
- windowProperties->isFloating, // Is this window floating?
- saveWindow, // Should this window be persistent?
- shouldDispose, // (see comment above)
- windowProperties->sourceFrame); // The display frame being opened, if any
- }
-
- CATCH_ALL
- // Cleanup Macintosh Window.
- CloseWindow(platformWindow);
- ODDisposePtr(platformWindow);
- // Cleanup OpenDoc Window.
- ODSafeReleaseObject(window);
- window = kODNULL;
- // Get the right error message for the problem.
- ODSShort errMsgNum = (!frame && windowProperties->sourceFrame)
- ? kErrCantOpenPartWindow : kErrCantOpenDocWindow;
- // Alert the user of the problem.
- somSelf->DoDialogBox(ev, frame, kErrorBoxID, errMsgNum);
- // Change the exception value, so the DocShell doesn't display an
- // error dialog.
- SetErrorCode(kODErrAlreadyNotified);
- // Alert the caller.
- RERAISE;
- ENDTRY
- }
-
- SOM_CATCH_ALL
- window = kODNULL;
- SOM_ENDTRY
-
- return window;
- }
-
- //------------------------------------------------------------------------------
- // Method: CleanupWindow
- // Origin: TextEditor
- //
- // Description: This method is called by the part when a window needs to be
- // cleaned up for a frame being closed/removed.
- //
- // The part deallocates the window buffer allocated in the
- // CreateWindow() method.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope void
- SOMLINK TextEditor__CleanupWindow
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","CleanupWindow");
-
- SOM_TRY
-
- TRY
- CFrameInfo* frameInfo = (CFrameInfo*) frame->GetPartInfo(ev);
- if ( frameInfo->ShouldDisposeWindow() )
- {
- TempODWindow window = frame->AcquireWindow(ev);
- THROW_IF_NULL(window);
-
- ODPlatformWindow windowPtr = window->GetPlatformWindow(ev);
- CloseWindow(windowPtr);
- ODDisposePtr(windowPtr);
- }
- CATCH_ALL
- somSelf->DoDialogBox(ev, frame, kErrorBoxID, kErrWindowGone);
- // consume excpetion because it's not fatal.
- ENDTRY
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: GetDefaultWindowProperties
- // Origin: TextEditor
- //
- // Description: This method is called by the part when a new window is being
- // created. The method examines the frame which is being opened
- // a generates the default window parameters to pass to the
- // Mac Toolbox.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope WindowProperties*
- SOMLINK TextEditor__GetDefaultWindowProperties
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* sourceFrame,
- Rect* windowRect
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","GetDefaultWindowProperties");
-
- WindowProperties* windowProperties = kODNULL;
- ODVolatile(windowProperties);
-
- SOM_TRY
- windowProperties = new WindowProperties;
-
- // Calculate the offset for the window based on the sourceFrame.
- if ( sourceFrame )
- somSelf->CalcPartWindowPosition(ev, sourceFrame, windowRect);
- else
- OffsetRect(windowRect, kALittleNudge,
- GetMBarHeight() + kMacWindowTitleBarHeight);
-
- windowProperties->boundsRect = *windowRect;
-
- // Get the part's name to use for the new window.
- TempODIText windowName = GetPartName(ev, somSelf, kODCategoryStyledText);
- // Convert the ODIText into a Pascal string.
- GetITextString(windowName, windowProperties->title);
-
- // Fill in the other fields of the Window Properties struct.
- windowProperties->procID = zoomDocProc;
- windowProperties->hasCloseBox = kODTrue;
- windowProperties->refCon = (long) kODNULL;
- windowProperties->wasVisible = kODFalse;
- windowProperties->isResizable = kODTrue;
- windowProperties->isFloating = kODFalse;
- windowProperties->isRootWindow = sourceFrame ? kODFalse : kODTrue;
- windowProperties->shouldShowLinks = kODFalse;
- windowProperties->sourceFrame = sourceFrame;
-
- SOM_CATCH_ALL
- ODDeleteObject(windowProperties);
- SOM_ENDTRY
-
- return windowProperties;
- }
-
- //------------------------------------------------------------------------------
- // Method: GetSavedWindowProperties
- // Origin: TextEditor
- //
- // Description: This method is called by the part to read in saved information
- // for a window from an existing document.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope WindowProperties*
- SOMLINK TextEditor__GetSavedWindowProperties
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SOMMethodDebug("TextEditor","GetSavedWindowProperties");
-
- WindowProperties* windowProperties = kODNULL;
- ODVolatile(windowProperties);
-
- SOM_TRY
-
- windowProperties = new WindowProperties;
-
- // If we fail to load the window properties from storage, delete
- // the structure so the calling code will behave appropriately.
- if ( BeginGetWindowProperties(ev, frame, windowProperties) )
- {
- // Note: We don't call EndGetWindowProperties because it releases the source
- // frame, which we will need after this method returns.
-
- // Get the part's name to use for the new window.
- TempODIText windowName = GetPartName(ev, somSelf, kODCategoryStyledText);
- // Convert the ODIText into a Pascal string.
- GetITextString(windowName, windowProperties->title);
-
- // Verify the window is still visible on a monitor.
-
- RgnHandle windowRgn = ODNewRgn();
- ODBoolean repositionWindow = kODFalse;
-
- // We are only concerned with the window's title bar being
- // visible, so calcuate the titlebar rect from the current
- // window bounds.
- Rect adjustedBounds = windowProperties->boundsRect;
- adjustedBounds.bottom = adjustedBounds.top;
- adjustedBounds.top -= kMacWindowTitleBarHeight;
-
- // Intersect the monitor's region
- RectRgn(windowRgn, &adjustedBounds);
- SectRgn(windowRgn, GetGrayRgn(), windowRgn);
-
- if ( !EmptyRgn(windowRgn) )
- {
- // If the visible portion of the window is too small, we need
- // to reposition it.
- Rect intersectedBounds = (**windowRgn).rgnBBox;
- if ( (intersectedBounds.right - intersectedBounds.left < kMinHorzVisPortion) ||
- (intersectedBounds.bottom - intersectedBounds.top < kMinVertVisPortion) )
- repositionWindow = kODTrue;
- }
- else
- {
- // If the window is completely offscreen, we need to reposition it.
- repositionWindow = kODTrue;
- }
- ODDisposeHandle((ODHandle) windowRgn);
-
- // If not, we need to move it so the user can see it.
- if ( repositionWindow )
- {
- Rect windowRect = (windowProperties->boundsRect);
- // Move the window to {0,0} coordinates.
- OffsetRect(&windowRect, -windowRect.left, -windowRect.top);
- // Now move the window to the default window position.
- OffsetRect(&windowRect, kALittleNudge, GetMBarHeight() + kMacWindowTitleBarHeight);
- // Save the new window position in our windowProperties.
- windowProperties->boundsRect = windowRect;
- }
- }
- else
- {
- // If we were unable to re-load window properties, dispose of the
- // struct.
- ODDeleteObject(windowProperties);
- }
- SOM_CATCH_ALL
- ODDeleteObject(windowProperties);
- SOM_ENDTRY
-
- return windowProperties;
- }
-
- //------------------------------------------------------------------------------
- // Method: CalcPartWindowSize
- // Origin: TextEditor
- //
- // Description: This method is called by the part to determine what size a new
- // window shoud be.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope Rect
- SOMLINK TextEditor__CalcPartWindowSize
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* sourceFrame
- )
- {
- SOMMethodDebug("TextEditor","CalcPartWindowSize");
-
- Rect windowRect = { 0, 0, 0, 0 };
-
- SOM_TRY
-
- const ODSShort kOnePageWidth = 600;
-
- ODRect frameRect;
-
- // If a source frame is given, the part is being asked to open one of
- // its display frames into a part window. Otherwise, we are being opened
- // as the root frame of the current document and should size the window
- // accordingly.
-
- if (sourceFrame)
- {
- // Set up the window's size to be that of the display frame being opened.
-
- // Retrieve the fixed point bounding box for the frame.
- TempODShape frameShape = sourceFrame->AcquireFrameShape(ev, kODNULL);
- frameShape->GetBoundingBox(ev, &frameRect);
-
- // Convert that into a Quickdraw rectangle.
- FixedToIntRect(frameRect, windowRect);
- }
- else
- {
- // (3 * kODLargeIconSize) prevents the window from covering the volume
- // icons on the desktop which is a violation of Macintosh HI Guidelines.
-
- SetRect(&windowRect, 0, 0,
- ODQDGlobals.screenBits.bounds.right - (3 * kODLargeIconSize),
- ODQDGlobals.screenBits.bounds.bottom
- - GetMBarHeight() - kMacWindowTitleBarHeight - kALittleNudge);
-
- if ( windowRect.right - windowRect.left > kOnePageWidth )
- windowRect.right = windowRect.left + kOnePageWidth;
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return windowRect;
- }
-
- //------------------------------------------------------------------------------
- // Method: CalcPartWindowPosition
- // Origin: TextEditor
- //
- // Description: This method is called by the part to determine where to align
- // the new window (top left corner of the screen or tiled to a
- // frame).
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope Rect
- SOMLINK TextEditor__CalcPartWindowPosition
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame,
- Rect* partWindowBounds
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","CalcPartWindowPosition");
-
- SOM_TRY
-
- ODFacet* activeFacet;
- ODRect bbox;
- Rect bounds;
-
- // We need to know which facet of the frame we are opening to position
- // the child window.
- activeFacet = somSelf->GetActiveFacetForFrame(ev, frame);
-
- // This should never occur, but if it did, it would be fatal.
- // So we will just pass back the same rectangle.
- if ( activeFacet == kODNULL )
- return *partWindowBounds;
-
- // For the purposes of tiling, we need the to know the area of the
- // document the frame occupies. We do this by getting the bouding
- // box and offsetting it by the aggregate external window transform
- // of the facet.
-
- TempODShape frameShape = activeFacet->GetFrame(ev)->AcquireFrameShape(ev, kODNULL);
- TempODShape boundsShape = frameShape->Copy(ev);
-
- TempODTransform windowFrameTransform = activeFacet->AcquireWindowFrameTransform(ev, kODNULL);
-
- // Translate the bounds rect into window coordinates.
- boundsShape->Transform(ev, windowFrameTransform);
-
- // Get and convert the bounding box into a QuickDraw rectangle.
- boundsShape->GetBoundingBox(ev, &bbox);
- FixedToIntRect(bbox, bounds);
-
- // We then call our method to tile the child window.
- *partWindowBounds = TilePartWindow(ev, &bounds, partWindowBounds);
-
- // Set the port and origin so we can convert the rect to
- // global Window Mgr coordinates.
- SetPort(activeFacet->GetCanvas(ev)->GetQDPort(ev));
- SetOrigin(0,-kMacWindowTitleBarHeight);
-
- // Convert the local coordinates to global Window Mgr coordinates.
- LocalToGlobal((Point*) &partWindowBounds->top);
- LocalToGlobal((Point*) &partWindowBounds->bottom);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return *partWindowBounds;
- }
-
- //------------------------------------------------------------------------------
- // Method: GetActiveFacetForFrame
- // Origin: TextEditor
- //
- // Description: This method is called by the part when it needs to know what the
- // active facet is for the part, if any.
- //
- // The part uses this method specifically to find the facet of a
- // source frame when opening a part window.
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope ODFacet*
- SOMLINK TextEditor__GetActiveFacetForFrame
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","GetActiveFacetForFrame");
-
- ODFacet* facet = kODNULL;
-
- SOM_TRY
-
- CFrameInfo* frameInfo = (CFrameInfo*) frame->GetPartInfo(ev);
-
- // If the frame is active, and it should be, get the active facet
- // from the frame state info.
- if ( frameInfo->IsFrameActive() )
- {
- facet = frameInfo->GetActiveFacet();
- }
- else
- // Otherwise, iterate over the display frames looking for one
- // that has an active facet... there should be at least one.
- {
- TempODFrameFacetIterator fiter(ev, frame);
- for (ODFacet* selectedFacet = fiter.First(); fiter.IsNotComplete();
- selectedFacet = fiter.Next() )
- {
- if ( selectedFacet->IsSelected(ev) )
- {
- facet = selectedFacet;
- break;
- }
- }
- }
-
- // If there are no active facets anywhere, this method should never
- // have been called, so signal an error.
- if (facet == kODNULL)
- THROW(kODErrInvalidFrame);
-
- SOM_CATCH_ALL
- facet = kODNULL;
- SOM_ENDTRY
-
- return facet;
- }
-
- //------------------------------------------------------------------------------
- // Method: SequenceChanged
- // Origin: ODPart
- //
- // Description: This method is called by
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope void
- SOMLINK TextEditor__SequenceChanged
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","SequenceChanged");
- }
-
- //------------------------------------------------------------------------------
- // Method: ContainingPartPropertiesUpdated
- // Origin: ODPart
- //
- // Description: This method is called by
- //------------------------------------------------------------------------------
- #pragma segment TextEditorLayout
-
- SOM_Scope void
- SOMLINK TextEditor__ContainingPartPropertiesUpdated
- (
- SampleCode_TextEditor* somSelf,
- Environment* ev,
- ODFrame* frame,
- ODStorageUnit* propertyUnit
- )
- {
- SampleCode_TextEditorData *somThis = SampleCode_TextEditorGetData(somSelf);
- SOMMethodDebug("TextEditor","ContainingPartPropertiesUpdated");
- }
-
-
-
-