home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 33.1 KB | 1,040 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWSView.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWSVIEW_H
- #include "FWSView.h"
- #endif
-
- #ifndef FWAROPER_H
- #include "FWArOper.h"
- #endif
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWWINDOW_H
- #include "FWWindow.h"
- #endif
-
- #ifndef FWCURSOR_H
- #include "FWCursor.h"
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- #ifndef FWRESACC_H
- #include "FWResAcc.h"
- #endif
-
- #ifndef FWRESSIN_H
- #include "FWResSin.h"
- #endif
-
- #ifndef FWSOMENV_H
- #include "FWSOMEnv.h"
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- //========================================================================================
- // Runtime Informations
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwview
- #endif
-
-
- //========================================================================================
- // class FW_CSuperViewCollection
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CSuperViewCollection)
-
- //========================================================================================
- // class FW_CSuperViewCollectionIterator
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CSuperViewCollectionIterator)
-
- //========================================================================================
- // CLASS FW_CSuperView
- //========================================================================================
-
- FW_DEFINE_CLASS_M1(FW_CSuperView, FW_CView)
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::FW_CSuperView
- //----------------------------------------------------------------------------------------
- FW_CSuperView::FW_CSuperView(Environment* ev, FW_CSuperView* container,
- const FW_CRect& bounds, ODID theID, const FW_CPoint& extent,
- FW_EScrollingDirection scrollDir) :
- FW_CView(ev, container, bounds, theID),
- fSubViews(NULL),
- fViewContentToFrameTransform(NULL),
- fScrollingDirection(scrollDir),
- fInternalTransform(NULL),
- fValidBoundsInContent(FALSE)
- {
- // Use the view's size as its default extent
- fExtent = (extent == FW_kZeroPoint) ? fBounds.Size() : extent;
-
- // Unlike FW_CView, by default superviews are not refreshed entirely when resized
- // i.e. FW_CSuperView subclasses must set the flag back to true if their content
- // depends on the size.
- SetResizeInvalidates(ev, false);
-
- // Change the default binding, because this makes more sense for a content view
- SetBindings(ev, FW_kFitToEnclosure);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::FW_CSuperView
- //----------------------------------------------------------------------------------------
-
- FW_CSuperView::FW_CSuperView(Environment* ev) :
- FW_CView(ev),
- fSubViews(NULL),
- fExtent(FW_kZeroPoint),
- fViewContentToFrameTransform(NULL),
- fScrollingDirection(FW_kNoScrolling),
- fInternalTransform(NULL),
- fValidBoundsInContent(FALSE)
- {
- // this ctor should be used by CFrame only, the only CSuperView with a NULL fSuperView
-
- // See comments above
- SetResizeInvalidates(ev, false);
- SetBindings(ev, FW_kFitToEnclosure);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::~FW_CSuperView
- //----------------------------------------------------------------------------------------
-
- FW_CSuperView::~FW_CSuperView()
- {
- FW_SOMEnvironment ev;
-
- DeleteSubViews(ev);
-
- if (fViewContentToFrameTransform)
- {
- fViewContentToFrameTransform->Release(ev);
- fViewContentToFrameTransform = NULL;
- }
-
- if (fInternalTransform)
- fInternalTransform->Release(ev);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::DeleteSubViews
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::DeleteSubViews(Environment* ev)
- {
- FW_UNUSED(ev);
- if (fSubViews)
- {
- FW_CView* view;
- while (fSubViews != NULL && (view = fSubViews->Last()) != NULL)
- {
- // Delete each subview, which in turn will remove it from its parentView
- // fSubViews is deleted after the last view is removed
- delete view;
- }
-
- // delete fSubViews;
- // fSubViews = NULL;
- FW_ASSERT(fSubViews == NULL);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::IsScrolling
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CSuperView::IsScrolling(Environment* ev) const
- {
- return IsScrollingInX(ev) || IsScrollingInY(ev);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::PrivSetContentExtent
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::PrivSetContentExtent(Environment* ev, const FW_CPoint& extent)
- {
- ODPoint odPoint = extent;
-
- FW_CFrame* frame = GetFrame(ev);
- frame->GetODFrame(ev)->ChangeContentExtent(ev, &odPoint);
-
- if (IsScrolling(ev))
- frame->PrivUpdateScrollParameters(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::SetExtent
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::SetExtent(Environment* ev, const FW_CPoint& extent)
- {
- if (fExtent != extent)
- {
- FW_CPoint oldExtent = fExtent;
- fExtent = extent;
-
- // Changing the extent triggers the layout manager
- FW_CViewIterator ite(this);
- for (FW_CView* subview = ite.First(); ite.IsNotComplete(); subview = ite.Next())
- {
- // Resize each subview and update the screen
- subview->AdjustToNewLayout(ev, oldExtent, extent, FW_kInvalidate);
- }
-
- // The Content View must also udpate the ODFrame's extent and adjust scroller
- if (IsContentView(ev))
- PrivSetContentExtent(ev, extent);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::SetSize
- //----------------------------------------------------------------------------------------
- // WARNING: this method should not be called directly by instances of FW_CFrame.
- // FW_CFrame calls it internally in FrameShapeChanged, you cannot control the
- // size of your frame with SetSize, use FW_MProxy::ChangeFrameShapes
-
- void FW_CSuperView::SetSize(Environment* ev, const FW_CPoint& size, FW_ERedrawVerb redraw)
- {
- // Call base class first
- FW_CView::SetSize(ev, size, redraw);
-
- if (IsScrolling(ev) == false)
- {
- // Set the extent to match the new size when the superview is not scrolling
- // SetExtent will in turn adjust the layout of the superview's subviews
- SetExtent(ev, size);
- }
- else
- {
- // There are 3 types of scrolling views:
- // - scrolling only in X -> the extent height is adjusted
- // - scrolling only in Y -> the extent width is adjusted
- // - scrolling in X and Y -> the extent is not changed
- FW_CPoint extent = fExtent;
-
- if (IsScrollingInX(ev) == true && IsScrollingInY(ev) == false)
- extent.y = size.y;
-
- if (IsScrollingInY(ev) == true && IsScrollingInX(ev) == false)
- extent.x = size.x;
-
- SetExtent(ev, extent);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::BecomeContentView
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::BecomeContentView(Environment* ev)
- {
- FW_CFrame* frame = GetFrame(ev);
-
- // Declare ContentView to the CFrame
- frame->SetContentView(ev, this);
-
- // Update the ODFrame's extent and the scrollbars
- PrivSetContentExtent(ev, fExtent);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::AddSubView
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::AddSubView(Environment* ev, FW_CView *subview)
- {
- if (fSubViews == NULL)
- {
- fSubViews = FW_NEW(FW_CViewCollection, ());
- }
- else if (fSubViews->Contains(subview) == true)
- {
- FW_DEBUG_MESSAGE("subview already added");
- return;
- }
-
- // AddSubView can be used to replace an existing parent view
- FW_CSuperView* oldParent = subview->fSuperView;
- if (oldParent != this && oldParent != NULL)
- {
- // This will in turn call PrivInvalidateCachedTransforms
- oldParent->RemoveSubView(ev, subview);
- }
-
- subview->fSuperView = this;
- fSubViews->AddLast(subview);
-
- // Set the subview's fNextEventHandler to its new superview
- subview->SetNextEventHandler(ev, this);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::RemoveSubView
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::RemoveSubView(Environment* ev, FW_CView* subView)
- {
- FW_ASSERT(fSubViews != NULL);
- FW_ASSERT(fSubViews->Contains(subView));
-
- fSubViews->Remove(subView);
-
- // must reset subview's fNextEventHandler which is its superview by default
- if (subView->GetNextEventHandler(ev) == this)
- subView->SetNextEventHandler(ev, 0);
-
- // Reset subview geometry
- subView->PrivInvalidateCachedTransforms(ev);
-
- SubViewWasRemoved(ev, subView);
-
- // Update fSuperView field in case it's added to another superview
- subView->fSuperView = NULL;
-
- if (fSubViews->Last() == NULL)
- {
- delete fSubViews;
- fSubViews = NULL;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::SubViewWasRemoved
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::SubViewWasRemoved(Environment* ev, FW_CView* subView)
- {
- if (fSuperView)
- fSuperView->SubViewWasRemoved(ev, subView);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::AdjustCursor
- //----------------------------------------------------------------------------------------
- // where is in frame coordinate
-
- FW_Handled FW_CSuperView::AdjustCursor(Environment *ev, ODFacet* odFacet, const FW_CPoint& theMousePoint, ODEventInfo* eventInfo)
- {
- // If I am the content view let the frame do the job first
- if (IsContentView(ev))
- return GetFrame(ev)->AdjustCursor(ev, odFacet, theMousePoint, eventInfo);
-
- return FW_kNotHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::CountSubViews
- //----------------------------------------------------------------------------------------
-
- unsigned long FW_CSuperView::CountSubViews(Environment* ev) const
- {
- FW_UNUSED(ev);
- return fSubViews == NULL ? 0 : fSubViews->Count();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::HasSubViews
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CSuperView::HasSubViews(Environment* ev) const
- {
- FW_UNUSED(ev);
- return fSubViews != NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::FindViewByID
- //----------------------------------------------------------------------------------------
-
- FW_CView* FW_CSuperView::FindViewByID(Environment* ev, ODID requestedID) const
- {
- FW_CView* theView = FW_CView::FindViewByID(ev, requestedID);
-
- if (theView == NULL) {
- FW_CViewIterator ite(this);
- for (FW_CView* subview = ite.First(); ite.IsNotComplete(); subview = ite.Next())
- {
- theView = subview->FindViewByID(ev, requestedID);
- if (theView)
- break;
- }
- }
-
- return theView;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::IsContentView
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CSuperView::IsContentView(Environment* ev) const
- {
- FW_CFrame* frame = GetFrame(ev);
- return (frame ? (frame->GetContentView(ev) == this) : false);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::PrivCreateSubViews
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::PrivCreateSubViews(Environment *ev)
- {
- // Create its own subviews first
- CreateSubViews(ev);
-
- // Propagate the call to its children superviews
- FW_CViewIterator ite(this);
- for (FW_CView* subview = ite.First(); ite.IsNotComplete(); subview = ite.Next())
- {
- if (subview->HasSubViews(ev))
- ((FW_CSuperView *)subview)->PrivCreateSubViews(ev);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::CreateSubViews(Environment *ev)
- {
- FW_UNUSED(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::CreateSubViewsFromResource
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::CreateSubViewsFromResource(Environment* ev, FW_ResourceID resourceID)
- {
- FW_TRY
- {
- FW_PSharedLibraryResourceFile resFile(ev, GetFrame(ev)->GetPart(ev)->GetPartInstance(ev));
- FW_PResource viewResource(ev, resFile, resourceID, FW_kViewLayoutResourceType);
- FW_PResourceSink sink(ev, viewResource);
- FW_CReadableStream stream(sink);
- CreateSubViewsFromStream(ev, stream);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, except)
- {
- // We use this try-catch block purely to warn about a common mistake.
- // If one forgets to add the resource containing their views to their project,
- // or passes in the wrong view id, the above code will throw an exception
- // that probably won't get caught until the SOM entry point from OpenDoc.
- // OpenDoc will display an error dialog that isn't particularly helpful
- // in diagnosing the problem.
- FW_DEBUG_MESSAGE("Failed to load view resource.");
- FW_PlatformError error = except.GetPlatformError();
- FW_THROW_SAME();
- }
- FW_CATCH_END
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::CreateSubViewsFromStream
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::CreateSubViewsFromStream(Environment* ev, FW_CReadableStream& stream)
- {
- FW_CPoint realExtent = fExtent;
-
- // Load the extent used in resources to define the layout of subviews
- stream >> fExtent;
-
- // Create the subviews
- PrivCreateSubViewsFromStream(ev, stream);
-
- // Give subclass a chance to complete subviews creation
- PrivPostCreateViewFromStream(ev);
-
- // Reset the superview's extent like it was and adjust the subviews layout in the process
- SetExtent(ev, realExtent);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::WriteSubViewsToStream
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::WriteSubViewsToStream(Environment* ev, FW_CWritableStream& stream)
- {
- stream << fExtent;
-
- FW_PREREGISTER_RUNTIME_OBJECT(stream,
- this,
- FW_kPreregisteredRootViewObject);
-
- short numberSubViews = CountSubViews(ev);
- stream << numberSubViews;
-
- if (numberSubViews > 0)
- {
- FW_CViewCollectionIterator it(fSubViews);
- for (FW_CView* view=it.First(); it.IsNotComplete(); view=it.Next())
- {
- FW_ASSERT(view != NULL);
- FW_WRITE_DYNAMIC_OBJECT(stream, view, FW_CView);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::PrivCreateSubViewsFromStream
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::PrivCreateSubViewsFromStream(Environment* ev, FW_CReadableStream& stream)
- {
- FW_PREREGISTER_RUNTIME_OBJECT(stream,
- this,
- FW_kPreregisteredRootViewObject);
-
- PrivReadSubviewsFromStream(ev, stream);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::PrivPostCreateViewFromStream
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::PrivPostCreateViewFromStream(Environment* ev)
- {
- // Handle this view first
- PostCreateViewFromStream(ev);
-
- // Propagate to subviews
- FW_CViewIterator ite(this);
- for (FW_CView* subview = ite.First(); ite.IsNotComplete(); subview = ite.Next())
- subview->PrivPostCreateViewFromStream(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::GetViewContaining
- //----------------------------------------------------------------------------------------
- // Find the visible & enabled view containing a point (in frame coordinates)
-
- FW_CView* FW_CSuperView::GetViewContaining(Environment* ev,
- ODFacet* odFacet,
- const FW_CPoint& theMousePoint)
- {
- FW_CView* viewUnder = NULL;
-
- if (fVisible && IsEnabled(ev) && IsMouseWithin(ev, odFacet, theMousePoint))
- {
- // iterate on sibling views from top to bottom
- FW_CViewIterator ite(this);
- for (FW_CView* subview = ite.Last(); ite.IsNotComplete() && !viewUnder;
- subview = ite.Previous())
- {
- viewUnder = subview->GetViewContaining(ev, odFacet, theMousePoint);
- }
- if (viewUnder == NULL)
- viewUnder = this;
- }
-
- return viewUnder;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::SizeChanged
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::SizeChanged(Environment* ev, const FW_CPoint& oldSize)
- {
- FW_CView::SizeChanged(ev, oldSize);
-
- // ----- Invalid fBoundsInContent
- fValidBoundsInContent = FALSE;
-
- if (IsContentView(ev))
- {
- FW_CFrame* frame = GetFrame(ev);
- frame->PrivContentShapeChanged(ev);
-
- if (IsScrolling(ev))
- frame->PrivUpdateScrollParameters(ev);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::LocationChanged
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::LocationChanged(Environment* ev, const FW_CPoint& oldLocation)
- {
- FW_CView::LocationChanged(ev, oldLocation);
-
- // ----- Invalid fBoundsInContent
- fValidBoundsInContent = FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::SetLocation
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::SetLocation(Environment* ev,
- const FW_CPoint& location,
- FW_ERedrawVerb redraw)
- {
- FW_CPoint newLocation;
- FW_Boolean isContentView = IsContentView(ev);
-
- if (isContentView)
- {
- newLocation = location;
- FW_CSuperView* parent = GetSuperView(ev);
- if (parent)
- parent->ViewContentToFrame(ev, newLocation);
- }
-
- FW_CView::SetLocation(ev, location, redraw);
-
- if (isContentView)
- GetFrame(ev)->PrivContentViewLocationChanged(ev, newLocation);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::AcquireViewContentToFrameTransform
- //----------------------------------------------------------------------------------------
- // returns the transform to convert view content coordinates to frame coordinates
-
- ODTransform* FW_CSuperView::AcquireViewContentToFrameTransform(Environment* ev) const
- {
- FW_CSuperView* self = (FW_CSuperView*)this;
-
- if (fViewContentToFrameTransform == NULL)
- {
- self->fViewContentToFrameTransform = FW_CopyAndRelease(ev, PrivAcquireViewInternalTransform(ev));
- FW_CAcquiredODTransform aqViewToFrame = AcquireViewToFrameTransform(ev);
- fViewContentToFrameTransform->PostCompose(ev, aqViewToFrame);
- }
-
- self->fViewContentToFrameTransform->Acquire(ev);
-
- return fViewContentToFrameTransform;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::GetBoundsInContent
- //----------------------------------------------------------------------------------------
- // returns the bounds in content coordinates. Note: the BoundsInContent depends on the Bounds
- // (size and location) and on the ViewInternalTransform. fValidBoundsInContent is set to false
- // in LocationChanged, SizeChanged and PrivInvalidateViewIternalTransform
-
- FW_CRect FW_CSuperView::GetBoundsInContent(Environment *ev) const
- {
- if (!fValidBoundsInContent)
- {
- FW_CSuperView* self = (FW_CSuperView*)this;
- self->fBoundsInContent = GetBounds(ev);
- self->fBoundsInContent.Place(FW_kFixed0, FW_kFixed0);
- FW_CAcquiredODTransform aqInternal = PrivAcquireViewInternalTransform(ev);
- self->fBoundsInContent.InverseTransform(ev, aqInternal);
-
- self->fValidBoundsInContent = TRUE;
- }
-
- return fBoundsInContent;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::HandleActivateEvent
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::HandleActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent)
- {
- // Activate this view and then its subviews
- FW_CView::HandleActivateEvent(ev, theActivateEvent);
-
- FW_CViewIterator ite(this);
- for (FW_CView* view = ite.First(); ite.IsNotComplete(); view = ite.Next())
- view->HandleActivateEvent(ev, theActivateEvent);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::HandleMouseDown
- //----------------------------------------------------------------------------------------
-
- FW_Handled FW_CSuperView::HandleMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- FW_CFrame* frame = GetFrame(ev);
- FW_ASSERT(frame);
-
- FW_Boolean isContentView = IsContentView(ev);
- FW_Boolean inActiveWindow = frame->GetWindow(ev)->IsActive(ev);
-
- FW_Boolean activateFrame = isContentView || !frame->IsRoot(ev);
- if (frame->ActivateWindow(ev, theMouseEvent.GetFacet(ev), activateFrame))
- return FW_kHandled;
-
- if (isContentView)
- {
- FW_CSelection* selection = frame->GetPresentation(ev)->GetSelection(ev);
- if (selection)
- selection->UpdateSelectionOnMouseDown(ev, theMouseEvent, NULL, FALSE, FALSE);
- }
-
- if (inActiveWindow)
- {
- if (this->WantsToBeTarget(ev))
- this->BecomeTarget(ev);
-
- FW_MEventHandler::HandleMouseDown(ev, theMouseEvent);
- }
-
- return FW_kHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::HandleDraw
- //----------------------------------------------------------------------------------------
- // invalidShape is in frame coordinate (NULL means redraw everything)
-
- FW_Handled FW_CSuperView::HandleDraw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- if (FW_CView::HandleDraw(ev, odFacet, invalidShape) == FW_kHandled) {
- // Draw its subviews
- FW_CViewIterator ite(this);
- for (FW_CView* subview = ite.First(); ite.IsNotComplete(); subview = ite.Next())
- {
- subview->HandleDraw(ev, odFacet, invalidShape);
- }
- }
-
- return FW_kHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::Draw
- //----------------------------------------------------------------------------------------
- // invalidShape is in content coordinate of this view
-
- void FW_CSuperView::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_UNUSED(ev);
- FW_UNUSED(odFacet);
- FW_UNUSED(invalidShape);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::GetExtent
- //----------------------------------------------------------------------------------------
-
- FW_CPoint FW_CSuperView::GetExtent(Environment* ev) const
- {
- FW_UNUSED(ev);
- return fExtent;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::SetVisible
- //----------------------------------------------------------------------------------------
- // [LSD] use tri-state later
-
- void FW_CSuperView::SetVisible(Environment* ev, FW_Boolean visible, FW_Boolean propagate)
- {
- FW_CView::SetVisible(ev, visible);
-
- if (propagate)
- {
- // propagates to subviews
- FW_CViewIterator ite(this);
- for (FW_CView* subview = ite.First(); ite.IsNotComplete(); subview = ite.Next())
- subview->SetVisible(ev, visible, TRUE);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::Flatten(Environment* ev, FW_CWritableStream& stream) const
- {
- FW_CView::Flatten(ev, stream);
-
- stream << fExtent;
- stream << IsContentView(ev);
- stream << (short)fScrollingDirection;
-
- unsigned long count = CountSubViews(ev);
- short numberSubViews = (short) count;
- FW_ASSERT(count == numberSubViews);
-
- stream << numberSubViews;
- if (numberSubViews > 0)
- {
- FW_CViewIterator ite(this);
- for (FW_CView* view=ite.First(); ite.IsNotComplete(); view=ite.Next())
- FW_WRITE_DYNAMIC_OBJECT(stream, view, FW_CView);
- }
-
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::InitializeFromStream
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::InitializeFromStream(Environment* ev, FW_CReadableStream& stream)
- {
- FW_CView::InitializeFromStream(ev, stream);
-
- FW_CPoint extent;
- FW_Boolean isContentView;
- short scrollDir;
-
- // [LSD] fExtent is set directly instead of calling SetExtent. Subviews are not yet
- // created at this point, and their layout inside this superview is defined in resources
- // anyway. (Adjustement to the frame extent is done later in CreateSubViewsFromStream)
- stream >> fExtent;
- stream >> isContentView;
- stream >> scrollDir;
-
- fScrollingDirection = FW_EScrollingDirection(scrollDir);
-
- // Declare the content view to the frame and update its extent and scrollbars
- if (isContentView)
- BecomeContentView(ev);
-
- // Load the subviews
- PrivReadSubviewsFromStream(ev, stream);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::PrivReadSubviewsFromStream
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::PrivReadSubviewsFromStream(Environment* ev, FW_CReadableStream& stream)
- {
- FW_UNUSED(ev);
- short numberSubViews;
- stream >> numberSubViews;
- for (short i=0; i<numberSubViews; i++)
- {
- FW_CView* view;
- FW_READ_DYNAMIC_OBJECT(stream, &view, FW_CView);
- FW_ASSERT(view != NULL);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::PrivInvalidateCachedTransforms
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::PrivInvalidateCachedTransforms(Environment* ev)
- {
- FW_CView::PrivInvalidateCachedTransforms(ev);
-
- // ----- Invalidate the ViewContent to Frame transform -----
- PrivInvalidateViewContentToFrameTransform(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::PrivInvalidateViewContentToFrameTransform
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::PrivInvalidateViewContentToFrameTransform(Environment* ev)
- {
- // ----- The visible bounds of my subviews is now invalide -----
- PrivInvalidateSubviewsVisibleBounds(ev);
-
- // ----- Invalid my ViewContent to frame transform -----
- if (fViewContentToFrameTransform)
- {
- fViewContentToFrameTransform->Release(ev);
- fViewContentToFrameTransform = NULL;
- }
-
- // ----- Go further down -----
- FW_CViewIterator iter(this);
- for (FW_CView* subview = iter.First(); iter.IsNotComplete(); subview = iter.Next())
- subview->PrivInvalidateCachedTransforms(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::InternalTransformChanged
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::InternalTransformChanged(Environment* ev)
- {
- FW_UNUSED(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::PrivInvalidateViewIternalTransform
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::PrivInvalidateViewIternalTransform(Environment* ev)
- {
- if (IsScrolling(ev))
- {
- // ----- The fBoundsInContent is also invalid -----
- fValidBoundsInContent = FALSE;
-
- // ----- Invalidate my internal transform -------
- if (fInternalTransform)
- {
- fInternalTransform->Release(ev);
- fInternalTransform = NULL;
- }
-
- // ----- Invalidate the ViewContent to Frame transform -----
- PrivInvalidateViewContentToFrameTransform(ev);
-
- // ----- Notify the superview -----
- InternalTransformChanged(ev);
- }
- else
- {
- FW_CViewIterator ite(this);
- for (FW_CView* subview = ite.First(); ite.IsNotComplete(); subview = ite.Next())
- subview->PrivInvalidateViewIternalTransform(ev);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::PrivAcquireViewInternalTransform
- //----------------------------------------------------------------------------------------
-
- ODTransform* FW_CSuperView::PrivAcquireViewInternalTransform(Environment* ev) const
- {
- FW_CSuperView* self = (FW_CSuperView*)this;
- if (fInternalTransform == NULL)
- {
- if (IsScrolling(ev))
- {
- FW_CFrame* frame = GetFrame(ev);
- FW_CPoint contentViewOffset = frame->PrivGetContentViewOffset(ev);
-
- self->fInternalTransform = FW_CopyAndRelease(ev, frame->AcquireInternalTransform(ev));
- self->fInternalTransform->MoveBy(ev, (ODPoint*)&(-contentViewOffset));
-
- FW_CPoint frameInternalTransformOffset, frameInternalTransformScale;
- self->fInternalTransform->GetPreScaleOffset(ev, (ODPoint*)&frameInternalTransformOffset);
- self->fInternalTransform->GetScale(ev, (ODPoint*)&frameInternalTransformScale);
- if (!IsScrollingInX(ev))
- {
- frameInternalTransformOffset.x = FW_kFixed0;
- frameInternalTransformScale.x = FW_kFixedPos1;
- }
- if (!IsScrollingInY(ev))
- {
- frameInternalTransformOffset.y = FW_kFixed0;
- frameInternalTransformScale.y = FW_kFixedPos1;
- }
- self->fInternalTransform->SetOffset(ev, (ODPoint*)&frameInternalTransformOffset);
- self->fInternalTransform->ScaleBy(ev, (ODPoint*)&frameInternalTransformScale);
- }
- else
- {
- self->fInternalTransform = ::FW_NewODTransform(ev);
- }
- }
-
- fInternalTransform->Acquire(ev);
- return fInternalTransform;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::PrivAcquireContentScrollShape
- //----------------------------------------------------------------------------------------
-
- void FW_CSuperView::PrivAcquireContentScrollShape(Environment* ev,
- FW_XYSelector direction,
- ODShape* scrollShape) const
- {
- // Note: If I am scrolling it means that no other subviews can scroll. This is a 'limitation'
- // of ODF because there is only one Internal transform in the ODFrame
- if (IsScrolling(ev))
- {
- if (!IsContentView(ev) && IsVisible(ev)) // ContentView already in scrollShape. See FW_CScroller::AcquireContentScrollShape
- {
- if (((direction == FW_kVertical) && IsScrollingInY(ev)) || ((direction == FW_kHorizontal) && IsScrollingInX(ev)))
- {
- FW_CAcquiredODShape aqScrollShape = ::FW_NewODShape(ev, FW_CRect(FW_kZeroPoint, GetSize(ev)));
- ViewToFrame(ev, aqScrollShape);
-
- scrollShape->Union(ev, aqScrollShape);
- }
- }
- }
- else
- {
- // ----- Look further -----
- FW_CViewIterator ite(this);
- for (FW_CView* subview = ite.First(); ite.IsNotComplete(); subview = ite.Next())
- subview->PrivAcquireContentScrollShape(ev, direction, scrollShape);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::PrivInvalidateVisibleBounds
- //----------------------------------------------------------------------------------------
- // If my visible bounds changed all my subviews visible bounds are also changing
-
- void FW_CSuperView::PrivInvalidateVisibleBounds(Environment *ev)
- {
- FW_CView::PrivInvalidateVisibleBounds(ev);
-
- PrivInvalidateSubviewsVisibleBounds(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuperView::PrivInvalidateSubviewsVisibleBounds
- //----------------------------------------------------------------------------------------
- // Call by FW_CSuperView::PrivInvalidateVisibleBounds and FW_CSuperView::PrivInvalidateCachedTransforms
-
- void FW_CSuperView::PrivInvalidateSubviewsVisibleBounds(Environment *ev)
- {
- FW_CViewIterator ite(this);
- for (FW_CView* view = ite.First(); ite.IsNotComplete(); view = ite.Next())
- view->PrivInvalidateVisibleBounds(ev);
- }
-
-
-