home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 78.3 KB | 2,534 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWFrame.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWPRTITE_H
- #include "FWPrtIte.h"
- #endif
-
- #ifndef FWPRHDLR_H
- #include "FWPrHdlr.h"
- #endif
-
- #ifndef FWCLPCMD_H
- #include "FWClpCmd.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- #ifndef SLMACOS_H
- #include "SLMacOS.h"
- #endif
-
- #ifndef FWFLOWIN_H
- #include "FWFloWin.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWVIEWAS_H
- #include "FWViewAs.h"
- #endif
-
- #ifndef FWCURSOR_H
- #include "FWCursor.h"
- #endif
-
- #ifndef FWBARRAY_H
- #include "FWBArray.h"
- #endif
-
- #ifndef FWSCROLR_H
- #include "FWScrolr.h"
- #endif
-
- #ifndef FWCNTRHW_H
- #include "FWCntrHW.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWIDLE_H
- #include "FWIdle.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- #ifndef FWRESOUR_H
- #include "FWResour.h"
- #endif
-
- #ifndef FWRGNSHP_H
- #include "FWRgnShp.h"
- #endif
-
- #ifndef FWLNKMGR_H
- #include "FWLnkMgr.h"
- #endif
-
- #ifndef FWEVENTU_H
- #include "FWEventU.h"
- #endif
-
- #ifndef SLODFSTR_H
- #include "SLODFStr.h"
- #endif
-
- #ifndef SLODFSTR_K
- #include "SLODFStr.k"
- #endif
-
- #ifndef FWSESION_H
- #include "FWSesion.h"
- #endif
-
- #ifndef SLREGION_H
- #include "SLRegion.h"
- #endif
-
- #ifndef FWSOMENV_H
- #include "FWSOMEnv.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_ODStorageUnitView_xh
- #include <SUView.xh>
- #endif
-
- #ifndef SOM_ODClipboard_xh
- #include <Clipbd.xh>
- #endif
-
- #ifndef SOM_ODFocusSet_xh
- #include <FocusSet.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FW_FrameSegment
- #endif
-
- //========================================================================================
- // Template Instantiations
- //========================================================================================
-
- FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollectionIterator, FW_CFrame)
- FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollection, FW_CFrame)
-
- #ifdef FW_USE_TEMPLATE_PRAGMAS
-
- #pragma template_access public
- #pragma template FW_TOrderedCollection<FW_CFrame>
- #pragma template FW_TOrderedCollectionIterator<FW_CFrame>
-
- #endif
-
- //========================================================================================
- // Constant
- //========================================================================================
-
- typedef long FW_FrameVersion;
- const FW_FrameVersion FW_kFrameVersion = 0;
-
- //========================================================================================
- // class FW_CFrame
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CFrame)
- FW_DEFINE_CLASS_M1(FW_CFrame, FW_CSuperView)
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FW_CFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame::FW_CFrame(Environment *ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_CPart* part) :
- FW_CSuperView(ev),
- fFrameID(odFrame->GetID(ev)),
- fODFrame(odFrame),
- fPart(part),
- fContentView(NULL),
- fGetFrontClicks(TRUE),
- fNeedsFoci(FALSE),
- fNeedsScrollingFocus(FALSE),
- fHasSelectionFocus(FALSE),
- fHasScrollingFocus(FALSE),
- fActiveFacet(NULL),
- fCanBeActiveFrame(TRUE),
- fPresentation(presentation),
- fWindow(NULL),
- fFacetCount(0),
- fPreviousViewType(odFrame->GetViewType(ev)),
- fViewAs(NULL),
- fIdler(NULL),
- fDraggable(NULL),
- fDroppable(NULL),
- fScroller(NULL),
- fViewUnderCursor(NULL),
- fRequestedFrame(FALSE),
- fInSharedWindow(FALSE),
- #ifdef FW_BUILD_WIN
- fShadowWindow(NULL),
- #endif
- fInternalTransformRealigmentNeeded(FALSE),
- fContentViewOffset(FW_kZeroPoint),
- fSubViewsCreated(FALSE),
- fSourceFrame(this),
- fDroppableState(FW_kFrameDroppable),
- fInfoCommandAdjusted(false),
- fShowPaletteOnMouseUp(FALSE),
- fContentShape(NULL),
- fAdoptsContainerProperties(FALSE)
- {
- FW_ASSERT(fODFrame);
- FW_ASSERT(fPart != NULL);
-
- // Frame is the default target of the event handling chain
- // (it will be the Content View later if one is created)
- fTarget = this;
-
- this->SetNextEventHandler(ev, part);
-
- fNeedsFoci = odFrame->IsRoot(ev);
-
- // ----- force to be view as frame if root -----
- // [HLX] I don't use ChangeViewType because I don't want to be notified
- if (fPreviousViewType != FW_CPart::fgViewAsFrameToken && IsRoot(ev))
- fODFrame->SetViewType(ev, FW_CPart::fgViewAsFrameToken);
-
- // ----- Set the frame's view Bounds to its shape bounds
- FW_CRect frameRect;
- PrivGetFrameShapeBounds(ev, frameRect);
- PrivSetBounds(ev, frameRect);
- PrivSetExtent(ev, frameRect.Size());
-
- // ----- By default the frame is the ContentView
- fContentView = (FW_CSuperView*)this;
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::~FW_CFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame::~FW_CFrame()
- {
- FW_START_DESTRUCTOR
-
- FW_SOMEnvironment ev;
-
- FW_ASSERT(fIdler == NULL); // subclass must delete idler it created
-
- FW_ASSERT(fWindow == NULL); // should have been deleted in FrameRemoved
-
- if (fViewAs && fPresentation)
- fPresentation->PrivReleaseViewAs(fViewAs);
-
- // Delete first all subviews before deleting the scroller.
- DeleteSubViews(ev);
-
- // Now I can delete the scroller (if any)
- delete fScroller;
-
- if (fContentShape)
- {
- fContentShape->Release(ev);
- fContentShape = NULL;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FrameRemoved
- //----------------------------------------------------------------------------------------
- // Notification
-
- void FW_CFrame::FrameRemoved(Environment* ev, FW_Boolean toStorage)
- {
- FW_UNUSED(toStorage);
-
- // if (toStorage && fIdler) [LSD] why this test?
- if (fIdler)
- fIdler->UnregisterIdle(ev);
-
- // ----- Relinquish what ever focus we have
- RelinquishFocusSet(ev);
-
- // ----- Check that the window has been deleted -----
- FW_ASSERT(fFacetCount == 0);
- FW_ASSERT(fWindow == NULL); // When the frame is removed it should not have any facets. fWindow
- // should already be null (see FacetRemoved)
-
- fODFrame = NULL; // Don't have an ODFFrame anymore
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FrameAdded
- //----------------------------------------------------------------------------------------
- // Notification
-
- void FW_CFrame::FrameAdded(Environment* ev, ODFrame* odFrame, FW_Boolean fromStorage)
- {
- FW_UNUSED(fromStorage);
-
- // In the case of frame in a shared window fODFrame can be NULL
- FW_ASSERT(fODFrame == odFrame || fODFrame == NULL);
- fODFrame = odFrame;
-
- // ----- Add it to the presentation -----
- fPresentation->PrivAddFrame(ev, this);
-
- // ----- set up the last active frame ------
- if (fPart->GetLastActiveFrame(ev) == NULL)
- {
- ODFocusSet* focusSet = GetFocusSet(ev);
- if (focusSet && focusSet->Contains(ev, FW_CPart::fgSelectionFocusToken))
- fPart->PrivSetLastActiveFrame(this);
- }
-
- // ----- Initialize printing handler -----
- FW_CPrintHandler* printHandler = NewPrintHandler(ev);
- if (printHandler != NULL)
- AdoptEventHandler(ev, printHandler);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetTarget
- //----------------------------------------------------------------------------------------
-
- FW_MEventHandler* FW_CFrame::GetTarget(Environment* ev) const
- {
- FW_UNUSED(ev);
- return fTarget;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SetTarget
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SetTarget(Environment* ev, FW_MEventHandler* newTarget, FW_Boolean tabSelection)
- {
- FW_UNUSED(ev);
- FW_ASSERT(newTarget); // should never set the target to NULL
-
- if (fTarget != newTarget)
- {
- if (fHasSelectionFocus)
- fTarget->DeactivateTarget(ev);
-
- fTarget = newTarget;
-
- if (fHasSelectionFocus)
- fTarget->ActivateTarget(ev, tabSelection);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::WantsToBeTarget
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::WantsToBeTarget(Environment* ev)
- {
- FW_UNUSED(ev);
- return true;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleMenu
- //----------------------------------------------------------------------------------------
-
- FW_Handled FW_CFrame::HandleMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Handled result = FW_kHandled;
- FW_CClipboardCommand* cmd;
- ODCommandID commandID = theMenuEvent.GetCommandID(ev);
-
- switch (commandID)
- {
- case kODCommandViewAsWin:
- GetPart(ev)->OpenPartWindow(ev, this, NULL);
- break;
-
- case kODCommandCut:
- case kODCommandCopy:
- case kODCommandPaste:
- case kODCommandPasteAs:
- case kODCommandClear:
- cmd = this->NewClipboardCommand(ev, commandID);
- if (cmd)
- cmd->Execute(ev);
- break;
-
- case kODCommandSelectAll:
- FW_CSelection* selection = fPresentation->GetSelection(ev);
- if (selection)
- selection->SelectAll(ev);
- break;
-
- case kODCommandGetPartInfo:
- ShowPartInfo(ev); // Link info or selection info
- break;
-
- default:
- result = FW_CSuperView::HandleMenu(ev, theMenuEvent);
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleVirtualKey
- //----------------------------------------------------------------------------------------
-
- FW_Handled FW_CFrame::HandleVirtualKey(Environment* ev, const FW_CVirtualKeyEvent& theVirtualKeyEvent)
- {
- FW_Handled handled = FW_MEventHandler::HandleVirtualKey(ev, theVirtualKeyEvent);
-
- if ((handled == FW_kNotHandled) && fScroller)
- handled = fScroller->HandlePageNavigationKeys(ev, theVirtualKeyEvent);
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::NewPartWindow
- //----------------------------------------------------------------------------------------
-
- FW_CWindow* FW_CFrame::NewPartWindow(Environment* ev,
- const FW_CRect& suggestedWindowRect,
- const FW_CString& suggestedWindowTitle)
- {
- return new FW_CWindow(ev,
- fPart,
- fODFrame,
- FALSE, // persistent frame
- FW_CPart::fgViewAsFrameToken,
- GetPresentation(ev), // Open it with the same presentation
- suggestedWindowTitle,
- suggestedWindowRect.Size(),
- suggestedWindowRect.TopLeft(),
- FW_kDocumentWindow);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::NewClipboardCommand
- //----------------------------------------------------------------------------------------
-
- FW_CClipboardCommand* FW_CFrame::NewClipboardCommand(Environment* ev, ODCommandID commandID)
- {
- FW_UNUSED(ev);
- FW_UNUSED(commandID);
- // [LSD] removed the assert to be more flexible in Form's CEditCmd class
- // user should check the return value before calling command->Execute(ev)
- // FW_DEBUG_MESSAGE("Your need to override FW_CFrame::NewClipboardCommand to create a command");
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ShowPartInfo
- //----------------------------------------------------------------------------------------
- FW_Handled FW_CFrame::ShowPartInfo(Environment* ev)
- {
- FW_Handled handledIt = FW_kNotHandled;
-
- if (GetPart(ev)->GetLinkManager(ev) != NULL)
- if (GetPart(ev)->GetLinkManager(ev)->ShowLinkInfo(ev, this))
- handledIt = FW_kHandled;
-
- if (!handledIt)
- {
- FW_CSelection* selection = fPresentation->GetSelection(ev);
- if (selection)
- handledIt = selection->ShowSelectionInfo(ev);
- }
-
- return handledIt;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::InstallMenus
- //----------------------------------------------------------------------------------------
- // By default call the part with the part menuBar
-
- void FW_CFrame::InstallMenus(Environment *ev)
- {
- GetPart(ev)->InstallMenus(ev, GetPart(ev)->GetMenuBar(ev));
- }
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleWindowEvent
- //----------------------------------------------------------------------------------------
-
- FW_Handled FW_CFrame::HandleWindowEvent(Environment* ev, const FW_CMacWindowEvent& windowEvent)
- {
- FW_Handled handled = FW_kHandled;
-
- unsigned long message = windowEvent.GetMessage();
- switch (windowEvent.GetMessage())
- {
- case inZoomIn:
- case inZoomOut:
- {
- ODPlatformWindow platformWindow = GetWindow(ev)->GetPlatformWindow(ev);
-
- // ----- Get the size of the window border -----
- FW_CRect borderSize;
- FW_PlatformError error;
- FW_GetWindowBorderSize(platformWindow, borderSize, &error);
- FW_FailOnError(error);
-
- // ----- Find out where the window would like to be zoomed out to
- FW_CRect screenRect;
- ::FW_MacGetMaxIntersectedDevice(platformWindow, screenRect, &error);
- FW_FailOnError(error);
- screenRect.Inset(FW_IntToFixed(3), FW_IntToFixed(3)); // leave space around window structure area
-
- // ----- call the part to get a custom size (interior size) -----
- FW_CPoint proposedSize(screenRect.Width() - borderSize.left - borderSize.right,
- screenRect.Height() - borderSize.top - borderSize.bottom);
- this->AdjustZoomedWindowSize(ev, proposedSize);
-
- fWindow->PrivMacDoZoom(ev, proposedSize, borderSize, screenRect, message);
- }
- break;
-
- case inGrow:
- PrivMacInGrowBox(ev, windowEvent);
- break;
-
- case inGoAway:
- if (fWindow->IsFloating(ev))
- fWindow->Hide(ev);
- else
- handled = FW_kNotHandled;
- break;
-
- default:
- handled = FW_kNotHandled;
- }
-
- return handled;
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AdjustZoomedWindowSize
- //----------------------------------------------------------------------------------------
- // proposedSize is the interior size of the window
-
- void FW_CFrame::AdjustZoomedWindowSize(Environment *ev, FW_CPoint& proposedSize)
- {
- FW_UNUSED(ev);
- FW_UNUSED(proposedSize);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AdjustWindowGrowLimits
- //----------------------------------------------------------------------------------------
- // minSize and maxSize are the interior size of the window
-
- void FW_CFrame::AdjustWindowGrowLimits(Environment* ev, FW_CPoint& minSize, FW_CPoint& maxSize)
- {
- FW_UNUSED(ev);
- FW_UNUSED(minSize);
- FW_UNUSED(maxSize);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Handled FW_CFrame::HandleAdjustMenus(Environment* ev, FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- if (hasMenuFocus)
- {
- // ----- Only if the target is the content view -----
- if (GetTarget(ev) == fContentView)
- {
- FW_CSelection* selection = fPresentation->GetSelection(ev);
- FW_Boolean hasSelection = selection && !selection->IsEmpty(ev);
-
- // ----- Edit Menu -----
- // If read only clear, cut past items will be disabled in FW_CPart::HandleAdjustMenus
- menuBar->EnableCommand(ev, kODCommandClear, hasSelection && !GetPart(ev)->IsReadOnly(ev));
- menuBar->EnableCommand(ev, kODCommandCut, hasSelection && !GetPart(ev)->IsReadOnly(ev));
- menuBar->EnableCommand(ev, kODCommandCopy, hasSelection);
-
- if (!fInfoCommandAdjusted) // may have been done by FW_CEmbeddingFrame::HandleAdjustMenus
- {
- FW_CString infoString;
- FW_Boolean gotInfo = PrivGetInfoString(ev, selection, infoString);
-
- if (!gotInfo || infoString.IsEmpty())
- {
- // Load default command string: "Part Info..."
- ::FW_PrivLoadODFString(ev, FW_kPartInfoString, infoString);
- }
-
- //--- Set up the Info item ---
- menuBar->SetItemString(ev, kODCommandGetPartInfo, infoString);
- menuBar->EnableCommand(ev, kODCommandGetPartInfo, gotInfo);
- }
- }
-
- menuBar->EnableCommand(ev, kODCommandViewAsWin, !IsTopFrame(ev));
- }
-
- fInfoCommandAdjusted = false; // reset for next time
-
- return FW_CSuperView::HandleAdjustMenus(ev, menuBar, hasMenuFocus, isRoot);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::IsTopFrame
- //----------------------------------------------------------------------------------------
- // IsTopFrame returns true if this frame is a sub-frame of the root frame
-
- FW_Boolean FW_CFrame::IsTopFrame(Environment* ev) const
- {
- if (IsRoot(ev))
- return TRUE;
-
- FW_CAcquiredODFrame aqContainingFrame = AcquireContainingFrame(ev);
- return IsSubframe(ev) && aqContainingFrame->IsRoot(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::IsSiblingFrameOf
- //----------------------------------------------------------------------------------------
- // Look if both frames are from the same part and have the same presentation. Returns FALSE
- // if otherODFrame is NULL.
-
- FW_Boolean FW_CFrame::IsSiblingFrameOf(Environment *ev, ODFrame* otherODFrame) const
- {
- if (otherODFrame == NULL)
- return FALSE;
-
- FW_CAcquiredODPart otherPart = otherODFrame->AcquirePart(ev);
- if (GetODPart(ev) == otherPart)
- {
- FW_CFrame* otherFrame = FW_CFrame::ODtoFWFrame(ev, otherODFrame);
- return GetPresentation(ev) == otherFrame->GetPresentation(ev);
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HasSamePartEditorAs
- //----------------------------------------------------------------------------------------
- // Look if the presentation of the otherFrame is the same as mine. Returns TRUE even if they
- // have two different instances of the editor.
-
- FW_Boolean FW_CFrame::HasSamePartEditorAs(Environment *ev, ODFrame* otherFrame) const
- {
- if (otherFrame != NULL)
- {
- ODTypeToken proposedToken = otherFrame->GetPresentation(ev);
- FW_CPartPresentationIterator ite(fPart);
- for (FW_CPresentation* presentation = ite.First();
- ite.IsNotComplete();
- presentation = ite.Next())
- {
- if (presentation->GetPresentationType(ev) == proposedToken)
- return TRUE;
- }
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HasSameDraftAs
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::HasSameDraftAs(Environment* ev, ODFrame* otherODFrame) const
- {
- FW_Boolean result = false;
-
- if (otherODFrame)
- {
- ODStorageUnit* su = otherODFrame->GetStorageUnit(ev);
- if (su)
- result = (GetPart(ev)->GetDraft(ev) == su->GetDraft(ev));
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FocusStateChanged
- //----------------------------------------------------------------------------------------
- // When overridden, call inherited::FocusStateChanged FIRST
-
- void FW_CFrame::FocusStateChanged(Environment *ev, ODTypeToken focus, FW_Boolean newState, ODFrame* newOwner)
- {
- if (focus == FW_CPart::fgSelectionFocusToken)
- {
- fPart->PrivSetLastActiveFrame(this);
-
- if (newState)
- {
- fHasSelectionFocus = TRUE;
- GetTarget(ev)->ActivateTarget(ev, false);
-
- // Handle case of multiple parts sharing the same floating windows
- FW_CFloatingWindow::TransferOwnership(ev, fPart->GetODPart(ev));
-
- // Show the floating windows except if frame has modal focus (i.e. Dialogs)
- if (!HasModalFocus(ev))
- FW_CFloatingWindow::HideShowFloatingWindows(ev, TRUE, fPart->GetODPart(ev));
- // fShowPaletteOnMouseUp = TRUE;
- }
- else
- {
- // Close the selection if I become deactive and the newOwner is not NULL and
- // not one of the part frame and there is not drag pending
- FW_CSelection* selection = fPresentation->GetSelection(ev);
- FW_Boolean samePart = FALSE;
- if (newOwner != NULL)
- {
- FW_CAcquiredODPart otherPart = newOwner->AcquirePart(ev);
- samePart = (otherPart == fPart->GetODPart(ev));
- }
- if (selection && !samePart && !fPresentation->PrivIsDragPending())
- selection->CloseSelection(ev);
-
- fHasSelectionFocus = FALSE;
- GetTarget(ev)->DeactivateTarget(ev);
-
- if (!HasSamePartEditorAs(ev, newOwner) || !HasSameDraftAs(ev, newOwner))
- FW_CFloatingWindow::HideShowFloatingWindows(ev, FALSE);
- }
- }
- else if (focus == FW_CPart::fgMenuFocusToken)
- {
- if (newState)
- InstallMenus(ev);
- }
- else if (focus == FW_CPart::fgScrollingFocusToken)
- {
- fHasScrollingFocus = newState;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::CanBeActiveFrame
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::CanBeActiveFrame(Environment* ev) const
- {
- FW_ASSERT(GetWindow(ev) != NULL);
- return fCanBeActiveFrame && !GetWindow(ev)->IsFloating(ev) && !IsFrozen(ev) && (GetViewType(ev) == FW_CPart::fgViewAsFrameToken);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ODtoFWFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame* FW_CFrame::ODtoFWFrame(Environment *ev, ODFrame* odFrame)
- {
- // In certain cases we get passed a bogus ODFrame. Do a (skanky) sanity check
- // to make sure this frame is really ours.
-
- FW_CFrame* frame = kODNULL;
-
- if (odFrame) {
- FW_CFrame* frame = (FW_CFrame*)odFrame->GetPartInfo(ev);
- if (frame) {
- // If odFrame is not ours, frame points to a random spot of memory.
- // Hopefully the fODFrame offset in that memory won't have 4 bytes
- // which are this odFrame*.
- if (frame->GetODFrame(ev) == odFrame)
- return frame;
- }
- }
-
- return kODNULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FrameShapeChanged
- //----------------------------------------------------------------------------------------
- // When overridden, call inherited::FrameShapeChanged first
-
- void FW_CFrame::FrameShapeChanged(Environment* ev)
- {
- FW_CRect frameRect;
- PrivGetFrameShapeBounds(ev, frameRect);
- FW_CPoint newSize = frameRect.Size();
-
- if (GetViewType(ev) == FW_CPart::fgViewAsFrameToken)
- {
- #ifdef FW_BUILD_WIN
- MoveSizeShadowWindow(ev);
- #endif
- // Change the size and refresh modified region. (This will in turn call SetExtent
- // and adjust the layout of subviews if the frame is not the content view)
- SetSize(ev, newSize, FW_kInvalidate);
- }
- else
- {
- // Use the FW_CView method to avoid resizing the frame's subviews
- // when it's not displayed as a frame
- FW_CView::SetSize(ev, newSize, FW_kInvalidate);
- }
-
- UpdateUsedAndActiveShapes(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SetActiveFacet
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SetActiveFacet(Environment* ev, ODFacet* activeFacet)
- {
- FW_UNUSED(ev);
- fActiveFacet = activeFacet;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::UpdateUsedAndActiveShapes
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::UpdateUsedAndActiveShapes(Environment* ev)
- {
- // ----- Used Shape -----
- UpdateUsedShape(ev);
-
- // ----- Update Active Shape for every facets -----
- FW_CFrameFacetIterator iter(ev, this);
- for (ODFacet* facet = iter.First(ev); iter.IsNotComplete(ev); facet = iter.Next(ev))
- {
- UpdateActiveShape(ev, facet);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::UpdateUsedShape
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::UpdateUsedShape(Environment* ev)
- {
- // ----- Used Shape -----
- FW_CAcquiredODShape aqUsedShape;
-
- PrivCreateViewAs(ev);
- if (fViewAs == NULL)
- {
- // ----- By default the used shape is the frame shape
- FW_CAcquiredODShape aqFrameShape = FW_CopyAndRelease(ev, AcquireFrameShape(ev, NULL));
- aqUsedShape = AdjustUsedShape(ev, aqFrameShape);
- }
- else
- {
- aqUsedShape = FW_CopyAndRelease(ev, fViewAs->AcquireUsedShape(ev));
- }
-
- // ----- if aqUsedShape is NULL OpenDoc will use the frame shape
- ChangeUsedShape(ev, aqUsedShape, NULL);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::UpdateActiveShape
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::UpdateActiveShape(Environment* ev, ODFacet* facet)
- {
- FW_CAcquiredODShape aqActiveShape;
-
- // ---- the Active shape is a copy of the Used shape by default
- FW_CAcquiredODShape aqProposedActiveShape = FW_CopyAndRelease(ev, AcquireUsedShape(ev));
-
- PrivCreateViewAs(ev);
- if (fViewAs == NULL)
- aqActiveShape = AdjustActiveShape(ev, facet, aqProposedActiveShape);
- else
- aqActiveShape = aqProposedActiveShape;
-
- facet->ChangeActiveShape(ev, aqActiveShape, NULL);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AdjustUsedShape
- //----------------------------------------------------------------------------------------
- // suggestedUsedShape is the frame shape. The default implementation returns NULL because
- // we don't want to maintain our own used shape.
-
- ODShape* FW_CFrame::AdjustUsedShape(Environment* ev, ODShape* suggestedUsedShape)
- {
- FW_UNUSED(ev);
- FW_UNUSED(suggestedUsedShape);
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AdjustActiveShape
- //----------------------------------------------------------------------------------------
- // suggestedActiveShape is the used shape. The default implementation returns NULL because
- // we don't want to maintain an active shape
-
- ODShape* FW_CFrame::AdjustActiveShape(Environment* ev, ODFacet* facet, ODShape* suggestedActiveShape)
- {
- FW_UNUSED(ev);
- FW_UNUSED(facet);
- FW_UNUSED(suggestedActiveShape);
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::RequestFrameShape
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::RequestFrameShape(Environment *ev, ODShape* shape, ODCanvas* biasCanvas)
- {
- FW_CAcquiredODShape aqOldFrameShape = FW_CopyAndRelease(ev, AcquireFrameShape(ev, biasCanvas));
-
- FW_CAcquiredODShape aqNewFrameShape = fODFrame->RequestFrameShape(ev, shape, biasCanvas);
-
- FW_Boolean changed = !aqNewFrameShape->IsSameAs(ev, aqOldFrameShape);
-
- if (changed)
- FrameShapeChanged(ev);
-
- return changed;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FacetAdded
- //----------------------------------------------------------------------------------------
- // When overridden call inherited::FacetAdded FIRST
-
- void FW_CFrame::FacetAdded(Environment* ev, ODFacet* facet, unsigned short facetCount)
- {
- // ----- Install the newest facet as the active facet of this frame
- this->SetActiveFacet(ev, facet);
-
- // ----- Create the window wrapper -----
- // ----- We have to wait for facet added because
- // ----- at FrameAdded it is too early
- FW_CAcquiredODWindow aqODWindow = fODFrame->AcquireWindow(ev);
- this->PrivCreateWindow(ev, aqODWindow); // Might not create a FW_CWindow if already has one
-
- // ----- for floating windows: remove all the foci by setting an empty set.
- if (aqODWindow->IsFloating(ev))
- {
- GetPresentation(ev)->AdoptFocusSet(ev, NULL);
- }
-
- // ----- Create the Shadow Window for Windows
- #ifdef FW_BUILD_WIN
- CreateShadowWindow(ev);
- #endif
-
- // ----- First facet: update used shape and create the sub-views
- if (facetCount == 1)
- {
- UpdateUsedShape(ev);
-
- // Create views only once during the frame's life!
- if (!fSubViewsCreated)
- PrivInstantiateViews(ev);
-
- if (fInternalTransformRealigmentNeeded)
- PrivRealignInternalTransform(ev);
-
- if (fAdoptsContainerProperties)
- SynchContainingPartProperties(ev);
- }
-
- // ----- Give my frame a chance to update the active shape of the facet -----
- UpdateActiveShape(ev, facet);
-
- // ----- Finally invalidate the content of the facet so it will be redrawn -----
- FW_CAcquiredODShape aqUsedShape = AcquireUsedShape(ev);
- facet->Invalidate(ev, aqUsedShape, NULL);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::FacetRemoved
- //----------------------------------------------------------------------------------------
- // When overridden call inherited::FacetRemoved last
-
- void FW_CFrame::FacetRemoved(Environment* ev, ODFacet* odFacet, unsigned short facetCount)
- {
- if (this->GetActiveFacet(ev) == odFacet)
- {
- FW_CFrameFacetIterator iter(ev, this);
- this->SetActiveFacet(ev, iter.First(ev));
- }
-
- // ----- Delete the fWindow if it was the last facet -----
- if (facetCount == 1)
- {
- FW_ASSERT(fWindow);
-
- DeleteAndResetViews(ev);
-
- if (!fWindow->IsFloating(ev)) // If floating window the part has to release
- delete fWindow;
-
- fWindow = NULL;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetWindow
- //----------------------------------------------------------------------------------------
-
- FW_CWindow* FW_CFrame::GetWindow(Environment* ev) const
- {
- FW_UNUSED(ev);
- return fWindow;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ViewTypeChanged
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::ViewTypeChanged(Environment* ev,
- ODTypeToken newViewType,
- ODTypeToken oldViewType)
- {
- FW_UNUSED(oldViewType);
- Invalidate(ev);
-
- if (fViewAs != NULL)
- fPresentation->PrivReleaseViewAs(fViewAs);
- fViewAs = NULL;
-
- PrivCreateViewAs(ev);
-
- UpdateUsedAndActiveShapes(ev);
-
- Invalidate(ev);
-
- // ----- Only If I have an associated FW_MDroppableFrame -----
- if (fDroppable)
- fODFrame->SetDroppable(ev, FW_MDroppableFrame::PrivDroppableStateToBoolean(fDroppableState, newViewType));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::BuildThumbnail
- //----------------------------------------------------------------------------------------
- // By default does nothing
-
- void FW_CFrame::BuildThumbnail(Environment* ev, FW_CGraphicContext& gc, FW_CRect& usedRect)
- {
- FW_UNUSED(ev);
- FW_UNUSED(gc);
- FW_UNUSED(usedRect);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetIcon
- //----------------------------------------------------------------------------------------
- // By default returns the part icon
-
- FW_CIcon FW_CFrame::GetIcon(Environment* ev, short iconSize) const
- {
- FW_PSharedLibraryResourceFile resourceFile(ev, fPart->GetPartInstance(ev));
- FW_CIcon icon(resourceFile, fPart->GetViewAsIconID(ev), iconSize);
-
- return icon;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::NewViewAs
- //----------------------------------------------------------------------------------------
-
- FW_CViewAs* FW_CFrame::NewViewAs(Environment* ev, ODTypeToken viewAsToken)
- {
- return new FW_CViewAs(ev, viewAsToken);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ChangePresentation
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::ChangePresentation(Environment* ev, FW_CPresentation* presentation)
- {
- FW_ASSERT(presentation);
- if (presentation != fPresentation)
- fODFrame->ChangePresentation(ev, presentation->GetPresentationType(ev));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PresentationChanged
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PresentationChanged(Environment* ev)
- {
- FW_ASSERT(fPresentation != NULL);
-
- FW_CPresentation* newPresentation = GetPart(ev)->PrivGetPresentation(ev, GetODFrame(ev));
- if (newPresentation == NULL)
- return;
-
- if (fViewAs)
- {
- fPresentation->PrivReleaseViewAs(fViewAs);
- fViewAs = NULL;
- }
-
- fPresentation->PrivRemoveFrame(ev, this);
- newPresentation->PrivAddFrame(ev, this);
-
- fPresentation = newPresentation;
-
- if (fSubViewsCreated)
- {
- DeleteAndResetViews(ev);
- PrivInstantiateViews(ev);
- Invalidate(ev);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SequenceChanged
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SequenceChanged(Environment* ev)
- {
- FW_UNUSED(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleActivateEvent
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::HandleActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent)
- {
- if (theActivateEvent.IsActivating(ev))
- {
- if (fNeedsFoci)
- ActivateFrame(ev, theActivateEvent.GetFacet(ev));
-
- // ----- Try scrolling focus -----
- if (fNeedsScrollingFocus)
- PrivRequestScrollingFocus(ev);
- }
- else
- {
- fNeedsFoci = fHasSelectionFocus;
- fNeedsScrollingFocus = fHasScrollingFocus;
- }
-
- FW_CSuperView::HandleActivateEvent(ev, theActivateEvent);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SubViewWasRemoved
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SubViewWasRemoved(Environment* ev, FW_CView* subView)
- {
- // if the view being removed was the content view, set the content view to
- // the frame
- if (subView == GetContentView(ev))
- SetContentView(ev, NULL);
-
- if (subView == fViewUnderCursor)
- fViewUnderCursor = NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame* FW_CFrame::GetFrame(Environment* ev) const
- {
- FW_UNUSED(ev);
- return (FW_CFrame*)this; // cast away const
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::IsFrame
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::IsFrame(Environment* ev) const
- {
- FW_UNUSED(ev);
- return true;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleSuspendResumeEvent
- //----------------------------------------------------------------------------------------
-
- FW_Handled FW_CFrame::HandleSuspendResumeEvent(Environment* ev, const FW_CSuspendResumeEvent& theResumeSuspendEvent)
- {
- FW_Boolean backToForeground = !theResumeSuspendEvent.IsGoingToBackground(ev);
-
- // [LSD] see later to use keyFocus and menuFocus instead for target management
- if (HasSelectionFocus(ev))
- {
- if (backToForeground)
- GetTarget(ev)->ActivateTarget(ev, false);
- else
- GetTarget(ev)->DeactivateTarget(ev);
- }
-
- if (GetWindow(ev)->IsFloating(ev) && IsRoot(ev))
- {
- // ----- We have to test that this frame belongs to the part with the selection focus
- ODArbitrator* arbitrator = FW_CSession::GetArbitrator(ev);
- FW_CAcquiredODFrame aqODFrame = arbitrator->AcquireFocusOwner(ev, FW_CPart::fgSelectionFocusToken);
- if (aqODFrame != NULL)
- {
- FW_CAcquiredODPart aqODPart = aqODFrame->AcquirePart(ev);
- if (aqODPart == fPart->GetODPart(ev))
- FW_CFloatingWindow::HideShowFloatingWindows(ev, backToForeground, aqODPart);
- }
- }
-
- return FW_kNotHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleMouseEnter
- //----------------------------------------------------------------------------------------
- // where is in frame coordinate
-
- FW_Handled FW_CFrame::HandleMouseEnter(Environment *ev, ODFacet* odFacet, const FW_CPoint& where, ODEventInfo* eventInfo)
- {
- fViewUnderCursor = GetViewContaining(ev, odFacet, where);
- if (fViewUnderCursor == NULL)
- return FW_kNotHandled;
-
- if (!fViewUnderCursor->AdjustCursor(ev, odFacet, where, eventInfo))
- FW_gArrowCursor.Select();
-
- return (fViewUnderCursor->IsEnabled(ev)) ?
- fViewUnderCursor->DoMouseEnter(ev, odFacet, where, eventInfo) : FW_kNotHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleMouseLeave
- //----------------------------------------------------------------------------------------
-
- FW_Handled FW_CFrame::HandleMouseLeave(Environment *ev, ODFacet* odFacet, ODEventInfo* eventInfo)
- {
- FW_gArrowCursor.Select();
-
- FW_Handled result = fViewUnderCursor ? fViewUnderCursor->DoMouseLeave(ev, odFacet, eventInfo) : FW_kNotHandled;
-
- fViewUnderCursor = NULL;
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleMouseWithin
- //----------------------------------------------------------------------------------------
- // where is in frame coordinate
-
- FW_Handled FW_CFrame::HandleMouseWithin(Environment *ev, ODFacet* odFacet, const FW_CPoint& theMousePoint, ODEventInfo* eventInfo)
- {
- FW_CView* viewUnderCursor = GetViewContaining(ev, odFacet, theMousePoint);
- if (viewUnderCursor == NULL)
- return FW_kNotHandled;
-
- if (viewUnderCursor != fViewUnderCursor)
- {
- if (fViewUnderCursor != NULL)
- fViewUnderCursor->DoMouseLeave(ev, odFacet, eventInfo);
-
- viewUnderCursor->DoMouseEnter(ev, odFacet, theMousePoint, eventInfo);
- }
- else
- viewUnderCursor->DoMouseWithin(ev, odFacet, theMousePoint, eventInfo);
-
- fViewUnderCursor = viewUnderCursor;
-
- if (!fViewUnderCursor->AdjustCursor(ev, odFacet, theMousePoint, eventInfo))
- FW_gArrowCursor.Select();
-
- return FW_kHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GeometryChanged
- //----------------------------------------------------------------------------------------
- // the geometry (clip shape or external transform) of one of my facet or one of my
- // embedding facet as changed
-
- void FW_CFrame::GeometryChanged(Environment *ev,
- ODFacet* odFacet,
- FW_Boolean clipShapeChanged,
- FW_Boolean transformChanged)
- {
- FW_UNUSED(ev);
- FW_UNUSED(odFacet);
- FW_UNUSED(clipShapeChanged);
- FW_UNUSED(transformChanged);
-
- #ifdef FW_BUILD_WIN
- MoveSizeShadowWindow(ev);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleDraw
- //----------------------------------------------------------------------------------------
- // invalidShape is in frame coordinate
-
- FW_Handled FW_CFrame::HandleDraw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- // if the facet doesn't have a graphicdevice it is not one of my facet anymore
- // That means that FacetRemoved has been called but my container is still trying
- // do draw me.[HLX] Might be a bug in OpenDoc. Might have been fixed in DR4
- if (FW_GetFacetGraphicDevice(ev, odFacet) == NULL)
- return FW_kHandled;
-
- #ifdef FW_BUILD_MAC
- // [HLX] there is a bug in OpenDoc. Sometime the invalidShape is one pixel too small
- invalidShape->Outset(ev, 0x00010000);
- #endif
-
- #ifdef FW_BUILD_WIN
- // [HLX] bug in windows? the invalidShape is in pixels instead of points
- invalidShape->Outset(ev, 0x00010000); // [HLX] Because of rounding errors
- FW_CGraphicDevice *device = FW_GetFacetGraphicDevice(ev, odFacet);
- device->PixelToPoint(ev, aqInvalidShape);
- #endif
-
- // ----- Check if the fViewAs has been created
- PrivCreateViewAs(ev);
- if (fViewAs == NULL)
- {
- FW_CSuperView::HandleDraw(ev, odFacet, invalidShape);
-
- // ----- If hilited state draw the hilite state
- if (odFacet->GetHighlight(ev) == kODFullHighlight)
- DrawFullHighlight(ev, odFacet, invalidShape);
- }
- else
- {
- fViewAs->Draw(ev, this, odFacet, invalidShape);
- }
-
- return FW_kHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::Draw
- //----------------------------------------------------------------------------------------
- // invalidShape is in content coordinate
-
- void FW_CFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_UNUSED(ev);
- FW_UNUSED(odFacet);
- FW_UNUSED(invalidShape);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::DrawFullHighlight
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::DrawFullHighlight(Environment *ev, ODFacet* facet, ODShape* invalidShape)
- {
- FW_CFrameContext fc(ev, facet, invalidShape);
- FW_CAcquiredODShape usedShape = AcquireUsedShape(ev);
- FW_CRegionShape::RenderRegion(fc, usedShape, FW_kFill, FW_CInk(FW_kSystemHilite));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HighlightChanged
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::HighlightChanged(Environment *ev, ODFacet* facet, ODHighlight from, ODHighlight to)
- {
- // In the Icon/Thumbnail case just invalidate the facet
- if (GetViewType(ev) != FW_CPart::fgViewAsFrameToken)
- facet->Invalidate(ev, NULL, NULL); // NULL for the shape is fine
- else
- {
- if ((from == kODNoHighlight || from == kODDimHighlight) && (to == kODFullHighlight))
- DrawFullHighlight(ev, facet , NULL);
- else if ((to == kODNoHighlight || to == kODDimHighlight) && (from == kODFullHighlight))
- DrawFullHighlight(ev, facet, NULL);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AdjustCursor
- //----------------------------------------------------------------------------------------
- // where is in frame coordinate
-
- FW_Handled FW_CFrame::AdjustCursor(Environment *ev, ODFacet* odFacet, const FW_CPoint& theMousePoint, ODEventInfo* eventInfo)
- {
- FW_UNUSED(ev);
- FW_UNUSED(odFacet);
- FW_UNUSED(theMousePoint);
- FW_UNUSED(eventInfo);
-
- return FW_kNotHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetODPart
- //----------------------------------------------------------------------------------------
-
- ODPart* FW_CFrame::GetODPart(Environment* ev) const
- {
- return fPart->GetODPart(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SetContentView
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SetContentView(Environment* ev, FW_CSuperView* view)
- {
- if (fContentView != view)
- {
- fContentView = view;
-
- // Make the content view the default target for menu and keyboard events
- fTarget = GetContentView(ev); // return this if fContentView is null
-
- // ----- if view == NULL I don't try to change the internal transform
- // ----- The frame might be closing down, in this case trying to acquire or change
- // ----- the internal transform is a bad idea
- if (view != NULL)
- {
- FW_CPoint contentViewTopLeft = FW_kZeroPoint;
-
- if (view != this)
- {
- FW_CRect bounds = view->GetBounds(ev);
- FW_CSuperView* superView = view->GetSuperView(ev);
- if (superView)
- superView->ViewContentToFrame(ev, bounds);
- contentViewTopLeft = bounds.TopLeft();
- }
-
- PrivContentViewLocationChanged(ev, contentViewTopLeft);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::DeleteAndResetViews
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::DeleteAndResetViews(Environment* ev)
- {
- // This method allows to reset everything before reloading fresh views (for instance
- // after modifying them with a view editor)
-
- DeleteSubViews(ev);
-
- delete fScroller;
- fScroller = NULL;
-
- fContentView = NULL;
- fViewUnderCursor = NULL;
-
- SetTarget(ev, this);
-
- fSubViewsCreated = false;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AdoptScroller
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::AdoptScroller(Environment* ev, FW_CScroller* scroller)
- {
- // [LSD] Set the content view's scrolling flag in case it wasn't set in ctor
- // To be reviewed.
- FW_CSuperView* contentView = GetContentView(ev); // could be the frame itself
- if (contentView->IsScrolling(ev) == false)
- {
- contentView->SetScrollingInX(ev, true);
- contentView->SetScrollingInY(ev, true);
- }
-
- #ifdef FW_DEBUG
- scroller->PrivCheckFrame(ev);
- #endif
-
- // [LSD] don't allow to change an existing scroller for now
- FW_ASSERT(fScroller == NULL);
- fScroller = scroller;
-
- if (fScroller)
- fScroller->PrivRealignScroller(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ExternalizeFrame
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::ExternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
- {
- FW_UNUSED(ev);
- FW_UNUSED(storageUnitView);
- // For subclasses
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::InternalizeFrame
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::InternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
- {
- FW_UNUSED(ev);
- FW_UNUSED(storageUnitView);
- // For subclasses
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivExternalizeFrame
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivExternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
- {
- // ----- Write first a version number
- FW_CByteArray byteArray(&FW_kFrameVersion, sizeof(FW_FrameVersion));
- storageUnitView->SetValue(ev, byteArray);
-
- // ----- Write content view offset
- byteArray.Set(&fContentViewOffset, sizeof(fContentViewOffset));
- storageUnitView->SetValue(ev, byteArray);
-
- // ----- Write requestedFrame flag
- byteArray.Set(&fRequestedFrame, sizeof(fRequestedFrame));
- storageUnitView->SetValue(ev, byteArray);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivInternalizeFrame
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivInternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
- {
- FW_CByteArray byteArray;
-
- // ----- Read first a version number
- FW_FrameVersion version;
- storageUnitView->GetValue(ev, sizeof(FW_FrameVersion), byteArray);
- byteArray.CopyBuffer(&version, sizeof(FW_FrameVersion));
- FW_ASSERT(version == FW_kFrameVersion);
-
- // ----- Read content view offset
- storageUnitView->GetValue(ev, sizeof(fContentViewOffset), byteArray);
- byteArray.CopyBuffer(&fContentViewOffset, sizeof(fContentViewOffset));
-
- // ----- Read requestedFrame flag
- storageUnitView->GetValue(ev, sizeof(fRequestedFrame), byteArray);
- byteArray.CopyBuffer(&fRequestedFrame, sizeof(fRequestedFrame));
-
- // ----- The Internal transform needs to be realign because
- // the view layout may have changed
- fInternalTransformRealigmentNeeded = TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetContentExtent
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::GetContentExtent(Environment* ev, FW_CPoint& extent) const
- {
- extent = GetContentView(ev)->GetExtent(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AcquireContentShape
- //----------------------------------------------------------------------------------------
- // return the content shape in Frame coordinates
-
- ODShape* FW_CFrame::AcquireContentShape(Environment *ev)
- {
- if (fContentShape == NULL)
- {
- FW_CSuperView* contentView = GetContentView(ev);
-
- FW_CRect contentRect(contentView->GetBounds(ev));
-
- FW_CSuperView* superView = contentView->GetSuperView(ev);
- if (superView)
- superView->ViewContentToFrame(ev, contentRect);
-
- fContentShape = FW_NewODShape(ev, contentRect);
- }
-
- fContentShape->Acquire(ev);
-
- return fContentShape;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivContentShapeChanged
- //----------------------------------------------------------------------------------------
- // The content shape has changed (usually because the content view bounds has changed)
-
- void FW_CFrame::PrivContentShapeChanged(Environment *ev)
- {
- if (fContentShape)
- {
- fContentShape->Release(ev);
- fContentShape = NULL;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::GetFocusSet
- //----------------------------------------------------------------------------------------
-
- ODFocusSet* FW_CFrame::GetFocusSet(Environment* ev) const
- {
- return fPresentation->GetFocusSet(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::BeginRelinquishFocus
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::BeginRelinquishFocus(Environment *ev, ODTypeToken focus, ODFrame* proposedFrame)
- {
- FW_UNUSED(ev);
- FW_UNUSED(focus);
- FW_UNUSED(proposedFrame);
- // Only relinquish the scrolling focus in the proposedFrame is in another window or is one
- // of my parent frame
- FW_Boolean result = TRUE;
-
- if (focus == FW_CPart::fgScrollingFocusToken)
- {
- FW_CAcquiredODWindow proposedODWindow = proposedFrame->AcquireWindow(ev);
- FW_CAcquiredODWindow aqODWindow = this->AcquireODWindow(ev);
- if (proposedODWindow == aqODWindow) // same window try parent frame
- {
- result = FALSE;
- FW_CAcquiredODFrame aFrame = fODFrame->AcquireContainingFrame(ev);
- while ((const void*)aFrame != NULL)
- {
- if (aFrame == proposedFrame)
- {
- result = TRUE;
- break;
- }
-
- aFrame = aFrame->AcquireContainingFrame(ev);
- }
- }
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AbortRelinquishFocus
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::AbortRelinquishFocus(Environment *ev, ODTypeToken focus, ODFrame* proposedFrame)
- {
- FW_UNUSED(ev);
- FW_UNUSED(focus);
- FW_UNUSED(proposedFrame);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ClonePartInfo
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::ClonePartInfo(Environment* ev,
- ODDraftKey key,
- ODInfoType partInfo,
- ODStorageUnitView* storageUnitView,
- ODFrame* scope)
- {
- FW_UNUSED(key);
- FW_UNUSED(partInfo);
- FW_UNUSED(scope);
-
- // ----- By default just call externalizeFrame -----
- ExternalizeFrame(ev, storageUnitView);
- }
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CFrame::CreateShadowWindow
- //----------------------------------------------------------------------------------------
- // Create a transparent Window so that we get a chance to handle messages sent by Windows
- // controls to their parent Window.
-
- void FW_CFrame::CreateShadowWindow(Environment *ev)
- {
- ODPlatformWindow parentHWnd = fWindow->GetPlatformWindow(ev);
- #ifdef FW_BUILD_WIN16
- HINSTANCE hInstance = (HINSTANCE)GetWindowWord(parentHWnd, GWW_HINSTANCE);
- #endif
- #ifdef FW_BUILD_WIN32
- HINSTANCE hInstance = (HINSTANCE)GetWindowLong(parentHWnd, GWL_HINSTANCE);
- #endif
-
- WNDCLASS wc;
-
- if (!GetClassInfo(hInstance, "ShadowWindow", &wc))
- {
- wc.style = CS_DBLCLKS;
- wc.lpfnWndProc = ShadowWindowProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 4;
- wc.hInstance = hInstance;
- wc.hIcon = NULL;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = NULL;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = "ShadowWindow";
-
- if (!RegisterClass(&wc))
- return;
- }
-
- fShadowWindow = CreateWindowEx(WS_EX_TRANSPARENT, "ShadowWindow", "",
- WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
- parentHWnd, NULL, hInstance, (LPSTR) this);
- MoveSizeShadowWindow(ev);
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CFrame::MoveSizeShadowWindow
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::MoveSizeShadowWindow(Environment* ev)
- {
- if (fShadowWindow != NULL)
- {
- ODFacet* facet = GetActiveFacet(ev);
- FW_CAcquiredODShape aqShape(FW_CopyAndRelease(ev, facet->AcquireActiveShape(ev, NULL)));
- FW_CAcquiredODTransform aqExternalTransform = facet->AcquireExternalTransform(ev, NULL);
- aqShape->Transform(ev, aqExternalTransform);
-
- FW_CRect bBox;
- aqShape->GetBoundingBox(ev, &bBox);
-
- // Shape bounding box is in 72dpi, need to convert to pixels
- if(!IsRoot(ev))
- {
- // [KVV] ??? This is only necessary for non-root frames
-
- HDC hDC = ::GetDC(NULL);
- int xRes = ::GetDeviceCaps(hDC, LOGPIXELSX);
- int yRes = ::GetDeviceCaps(hDC, LOGPIXELSY);
- ::ReleaseDC(NULL, hDC);
-
- FW_Fixed xScale = FW_FixDiv(ff(xRes), ff(72));
- FW_Fixed yScale = FW_FixDiv(ff(yRes), ff(72));
-
- bBox.left = FW_FixMul(bBox.left, xScale);
- bBox.top = FW_FixMul(bBox.top, yScale);
- bBox.right = FW_FixMul(bBox.right, xScale);
- bBox.bottom = FW_FixMul(bBox.bottom,yScale);
- }
-
- FW_PlatformRect wndRect = bBox.AsPlatformRect();
-
- ::MoveWindow(fShadowWindow, wndRect.left, wndRect.top,
- wndRect.right - wndRect.left, wndRect.bottom - wndRect.top, TRUE);
- }
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ShadowWindowProc
- //----------------------------------------------------------------------------------------
-
- LRESULT CALLBACK FW_CFrame::ShadowWindowProc(HWND hWnd, UINT msg,
- WPARAM wParam, LPARAM lParam)
- {
- switch (msg)
- {
- #ifdef FW_DEBUG
- // ----- Frame the shadow window for ease of debugging
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hDC = ::BeginPaint(hWnd, &ps);
-
- if(::GetPrivateProfileInt("Debug", "ShadowWindow Outline", FALSE, "ODF.ini"))
- {
- static const char pattern[8][2] =
- {
- { 0xAA, 0x00 },
- { 0x55, 0x00 },
- { 0xAA, 0x00 },
- { 0x55, 0x00 },
- { 0xAA, 0x00 },
- { 0x55, 0x00 },
- { 0xAA, 0x00 },
- { 0x55, 0x00 }
- };
-
- HBITMAP hBitmap = ::CreateBitmap(8, 8, 1, 1, pattern);
-
- HBRUSH hBrush = ::CreatePatternBrush(hBitmap);
-
- ::SetTextColor(hDC, RGB(0xFF, 0x00, 0xFF));
-
- RECT rc;
- ::GetClientRect(hWnd, &rc);
-
- HRGN hRgn = ::CreateRectRgnIndirect(&rc);
-
- ::FrameRgn(hDC, hRgn, hBrush, 3, 3);
-
- ::DeleteObject(hRgn);
- ::DeleteObject(hBrush);
- ::DeleteObject(hBitmap);
- }
-
- ::EndPaint(hWnd, &ps);
- }
- return 0;
- #endif
-
- case WM_CREATE:
- SetWindowLong(hWnd, 0, (long) ((LPCREATESTRUCT) lParam)->lpCreateParams);
- return 0;
-
- case WM_NCHITTEST:
- return HTTRANSPARENT;
-
- case WM_COMMAND:
- switch (HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- HWND hButton = HWND(lParam);
-
- // If this is a window
- if (hButton != NULL && ::IsWindow(hButton))
- {
- // Get the scroll bar helper
- FW_CPrivWinButtonHelper* buttonHelper =
- FW_DYNAMIC_CAST(FW_CPrivWinButtonHelper, FW_CPrivWinControlHelper::HWNDToHelper(hButton));
-
- // Tell the button to update itself and the pane
- buttonHelper->HandleButtonMessage();
- return 0L;
- }
- }
- break;
- }
- break;
-
- case WM_HSCROLL:
- case WM_VSCROLL:
- {
- HWND hBar = HWND(lParam);
-
- // If this is not a scroll bar control, but a Windows
- // window scroll bar, pass it to Windows wndproc
- if (hBar == NULL)
- {
- FW_DEBUG_MESSAGE("Warning: ODF does not use Window scroll bars!");
- break;
- }
-
- // If this is a window
- if (hBar != NULL && ::IsWindow(hBar))
- {
- // Get the scroll bar helper
- FW_CPrivWinScrollBarHelper* sbHelper =
- FW_DYNAMIC_CAST(FW_CPrivWinScrollBarHelper, FW_CPrivWinControlHelper::HWNDToHelper(hBar));
-
- // Tell the scroll bar to update itself and the pane
- if (sbHelper != NULL)
- {
- sbHelper->HandleScrollMessage(LOWORD(wParam), HIWORD(wParam));
- return 0L;
- }
- }
- break;
- }
- }
-
- return DefWindowProc(hWnd, msg, wParam, lParam);
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HasModalFocus
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::HasModalFocus(Environment* ev) const
- {
- FW_CAcquiredODFrame aqODFrame = FW_CSession::GetArbitrator(ev)->AcquireFocusOwner(ev, FW_CPart::fgModalFocusToken);
- return aqODFrame == fODFrame;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HasPropertyOnClipboard
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::HasPropertyOnClipboard(Environment* ev, ODPropertyName propertyName, ODValueType type) const
- {
- FW_Boolean result = FALSE;
- ODArbitrator* arbitrator = FW_CSession::GetArbitrator(ev);
- FW_CAcquiredODFrame aqODFrame = arbitrator->AcquireFocusOwner(ev, FW_CPart::fgClipboardFocusToken);
-
- if ((aqODFrame == fODFrame) || (arbitrator->RequestFocus(ev, FW_CPart::fgClipboardFocusToken, fODFrame)) )
- {
- ODStorageUnit* su = FW_CSession::GetClipboard(ev)->GetContentStorageUnit(ev);
- result = su->Exists(ev, propertyName, type, 0);
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HasSupportedKindOnClipboard
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CFrame::HasSupportedKindOnClipboard(Environment* ev) const
- {
- FW_Boolean result = FALSE;
- ODArbitrator* arbitrator = FW_CSession::GetArbitrator(ev);
- FW_CAcquiredODFrame aqODFrame = arbitrator->AcquireFocusOwner(ev, FW_CPart::fgClipboardFocusToken);
-
- if ((aqODFrame == fODFrame) || (arbitrator->RequestFocus(ev, FW_CPart::fgClipboardFocusToken, fODFrame)) )
- {
- ODStorageUnit* su = FW_CSession::GetClipboard(ev)->GetContentStorageUnit(ev);
- result = (GetPart(ev)->GetSupportedKind(ev, su, FW_kClipboardStorage) != NULL);
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivChangeInternalTransform
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivChangeInternalTransform(Environment* ev, ODTransform* internalTransform, ODCanvas* biasCanvas)
- {
- // *LSD2 hack can be removed after DR4 ?
- #ifdef FW_BUILD_MAC
- // [HLX] Temporary because of a bug in OpenDoc
- // ODFFrame::ChangeInternalTransform changes the clip and the origin and does not restore it
- GrafPtr port;
- ::GetPort(&port);
- Point origin;
- origin.h = port->portRect.left;
- origin.v = port->portRect.top;
- ODRgnHandle clipRgn = ::FW_NewRegion();
- ::GetClip(clipRgn);
- #endif
-
- fODFrame->ChangeInternalTransform(ev, internalTransform, biasCanvas);
-
- #ifdef FW_BUILD_MAC
- // [HLX] Temporary because of a bug in OpenDoc
- ::SetPort(port);
- ::SetClip(clipRgn);
- ::FW_DisposeRegion(clipRgn);
- ::SetOrigin(-origin.h, -origin.v);
- #endif
-
- // Now invalidate all the views Internal transforms
- PrivInvalidateViewIternalTransform(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SynchContainingPartProperties
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SynchContainingPartProperties(Environment* ev)
- {
- if (!IsRoot(ev))
- {
- FW_CAcquiredODStorageUnit aqPropertyUnit;
- FW_CAcquiredODFrame aqContainingFrame = AcquireContainingFrame(ev);
-
- if (aqContainingFrame != NULL)
- {
- FW_CAcquiredODPart aqContainingPart = aqContainingFrame->AcquirePart(ev);
- aqPropertyUnit = aqContainingPart->AcquireContainingPartProperties(ev, GetODFrame(ev));
- }
-
- AdoptContainingPartProperties(ev, aqPropertyUnit);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::AdoptContainingPartProperties
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::AdoptContainingPartProperties(Environment *ev, ODStorageUnit* propertyUnit)
- {
- FW_UNUSED(ev);
- FW_UNUSED(propertyUnit);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::NewPrintHandler
- //----------------------------------------------------------------------------------------
-
- FW_CPrintHandler* FW_CFrame::NewPrintHandler(Environment* ev)
- {
- FW_UNUSED(ev);
-
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::SetLocation
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::SetLocation(Environment* ev, const FW_CPoint& location, FW_ERedrawVerb redraw)
- {
- FW_UNUSED(ev);
- FW_UNUSED(location);
- FW_UNUSED(redraw);
-
- FW_DEBUG_MESSAGE("Can't call SetLocation on a FW_CFrame");
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::RelinquishFocusSet
- //----------------------------------------------------------------------------------------
- // Usually should not have to be overriden. Can be overriden for special case
-
- void FW_CFrame::RelinquishFocusSet(Environment *ev)
- {
- FW_ASSERT(GetFocusSet(ev) != NULL);
-
- ODArbitrator* arbitrator = FW_CSession::GetArbitrator(ev);
- arbitrator->RelinquishFocusSet(ev, GetFocusSet(ev), GetODFrame(ev));
- if (fHasScrollingFocus)
- {
- arbitrator->RelinquishFocus(ev, FW_CPart::fgScrollingFocusToken, GetODFrame(ev));
- fHasScrollingFocus = FALSE;
- fNeedsScrollingFocus = TRUE;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::RequestFocusSet
- //----------------------------------------------------------------------------------------
- // Usually should not have to be overriden. Can be overriden for special case
-
- FW_Boolean FW_CFrame::RequestFocusSet(Environment *ev)
- {
- FW_ASSERT(GetFocusSet(ev) != NULL);
-
- ODArbitrator* arbitrator = FW_CSession::GetArbitrator(ev);
- return arbitrator->RequestFocusSet(ev, GetFocusSet(ev), GetODFrame(ev));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivRequestScrollingFocus
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivRequestScrollingFocus(Environment *ev)
- {
- if (!fHasScrollingFocus)
- {
- ODArbitrator* arbitrator = FW_CSession::GetArbitrator(ev);
- if (arbitrator->RequestFocus(ev, FW_CPart::fgScrollingFocusToken, GetODFrame(ev)))
- {
- fNeedsScrollingFocus = FALSE;
- FocusStateChanged(ev, FW_CPart::fgScrollingFocusToken, TRUE, NULL);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::HandleIdle
- //----------------------------------------------------------------------------------------
-
- FW_Handled FW_CFrame::HandleIdle(Environment* ev, const FW_CNullEvent& theNullEvent)
- {
- if (IsInLimbo(ev))
- return FW_kNotHandled; // don't idle if we're in limbo
-
- return DoIdle(ev, theNullEvent);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::IsFrameInLinkDestination
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CFrame::IsFrameInLinkDestination(Environment* ev)
- {
- FW_Boolean result = GetODFrame(ev)->GetLinkStatus(ev) == kODInLinkDestination;
- if (result)
- {
- // user is trying to edit inside a link destination
- if (GetODFrame(ev)->EditInLink(ev)) // brings up EditInLinkAttempted dialog in containing part
- {
- result = GetODFrame(ev)->GetLinkStatus(ev) == kODInLinkDestination; // changed if user broke the link
- }
- else
- {
- // Inform user that link cannot be edited
- fPart->PrivShowErrorAlert(ev, FW_kLinkingStrings, FW_kCantEditThisLinkMsg);
- }
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::CanvasChanged
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::CanvasChanged(Environment* ev, ODFacet* facet)
- {
- FW_HGDevice graphicDevice = FW_GetFacetGraphicDevice(ev, facet);
- if(graphicDevice != NULL)
- FW_PrivGDev_CanvasChanged(graphicDevice, ev, facet->GetCanvas(ev));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ActivateFrame
- //----------------------------------------------------------------------------------------
- // activatedFacet can be NULL. Will use the current active facet or the firts facet.
-
- void FW_CFrame::ActivateFrame(Environment *ev, ODFacet* activatedFacet)
- {
- // if (fShowPaletteOnMouseUp)
- // {
- // FW_CFloatingWindow::HideShowFloatingWindows(ev, TRUE, fPart->GetODPart(ev));
- // fShowPaletteOnMouseUp = FALSE;
- // }
-
- if (CanBeActiveFrame(ev))
- {
- if (activatedFacet == NULL)
- {
- ODFacet* aFacet = GetActiveFacet(ev);
- if (aFacet == NULL)
- {
- FW_CFrameFacetIterator iter(ev, this); // find a facet
- activatedFacet = iter.First(ev);
- }
- // if aFacet != NULL (there is an active facet already) it means that
- // activatedFacet will be equal to NULL and we are not going to call SetActiveFacet
- }
-
- if (activatedFacet != NULL)
- SetActiveFacet(ev, activatedFacet);
-
- if (fHasSelectionFocus == FALSE)
- {
- if (RequestFocusSet(ev))
- {
- fNeedsFoci = FALSE;
-
- FW_CFocusSetIterator iter(ev, this);
- for( ODTypeToken token=iter.First(ev); iter.IsNotComplete(ev); token=iter.Next(ev) ) {
- FocusStateChanged(ev, token, TRUE, NULL);
- }
-
- // Try the scrolling focus
- if (fScroller && fScroller->IsHandlingPageNavigationKeys(ev))
- PrivRequestScrollingFocus(ev);
-
- ::FW_ForceAdjustCursor(ev);
- }
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::Reveal
- //----------------------------------------------------------------------------------------
- // Reveal will ask the container (if any) to reveal shapeToReveal which is in frame coordinates
-
- FW_Boolean FW_CFrame::Reveal(Environment* ev, ODShape* shapeToReveal)
- {
- FW_CAcquiredODFrame aqContainingFrame = AcquireContainingFrame(ev);
- if ((const void*)aqContainingFrame != NULL)
- {
- FW_CAcquiredODShape tempShape;
- if (shapeToReveal == NULL)
- tempShape = FW_CopyAndRelease(ev, AcquireFrameShape(ev));
- else
- {
- shapeToReveal->Acquire(ev);
- tempShape = shapeToReveal;
- }
-
- FW_CAcquiredODPart containingPart = aqContainingFrame->AcquirePart(ev);
- return containingPart->RevealFrame(ev, GetODFrame(ev), tempShape);
- }
-
- return FALSE;
- }
-
- //========================================================================================
- // Implementation Only API
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivCreateWindow
- //----------------------------------------------------------------------------------------
-
- FW_CWindow* FW_CFrame::PrivCreateWindow(Environment* ev, ODWindow* odWindow)
- {
- FW_ASSERT(odWindow);
- // FW_ASSERT(fWindow == NULL || fWindow->GetID(ev) == odWindow->GetID(ev));
-
- // ----- Test first if this frame was in another window -----
- if (fWindow != NULL && fWindow->GetID(ev) != odWindow->GetID(ev))
- {
- delete fWindow;
- fWindow = NULL;
- }
-
- if (fWindow == NULL)
- {
- ODPlatformWindow platformWindow = odWindow->GetPlatformWindow(ev);
-
- FW_CWindow* fwWindow = NULL;
-
- if (IsRoot(ev))
- {
- #ifdef FW_BUILD_MAC
- fwWindow = (FW_CWindow*) ::GetWRefCon(platformWindow);
- #endif
-
- #ifdef FW_BUILD_WIN
- fwWindow = (FW_CWindow*) ::GetProp(platformWindow, "ODF:Window");
- #endif
- }
-
- if (fwWindow != NULL)
- fWindow = fwWindow;
- else
- fWindow = new FW_CWindow(ev, odWindow->GetID(ev));
- }
-
- fInSharedWindow = IsRoot(ev) && fWindow->IsFloating(ev);
-
- return fWindow;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivSetDroppable
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivSetDroppable(Environment *ev, FW_MDroppableFrame* droppable, FW_Boolean isDroppable)
- {
- fDroppable = droppable;
- fODFrame->SetDroppable(ev, isDroppable);
- }
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivMacInGrowBox
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivMacInGrowBox(Environment* ev, const FW_CMacWindowEvent& windowEvent)
- {
- FW_CRect growLimits(FW_IntToFixed(64), FW_IntToFixed(64), FW_IntToFixed(32000), FW_IntToFixed(32000));
- this->AdjustWindowGrowLimits(ev, growLimits[FW_kTopLeft], growLimits[FW_kBotRight]);
-
- // If minimum is lareger than maximun then do something
- if (growLimits.left > growLimits.right)
- growLimits.left = growLimits.right;
- if (growLimits.top > growLimits.bottom)
- growLimits.top = growLimits.bottom;
-
- ODEventData* eventData = ((FW_CMacWindowEvent&)windowEvent).GetPlatformEvent();
- FW_CAcquiredODWindow aqODWindow = fWindow->AcquireODWindow(ev);
-
- // growLimits.right += FW_kFixedPos1;
- // growLimits.bottom += FW_kFixedPos1;
-
- FW_PlatformError error;
- FW_Boolean result = FW_PrivMacTrackResizeWindow(aqODWindow->GetPlatformWindow(ev),
- growLimits,
- eventData->where,
- &error);
- FW_FailOnError(error);
- if (result)
- aqODWindow->AdjustWindowShape(ev);
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivGetFrameShapeBounds
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivGetFrameShapeBounds(Environment* ev, FW_CRect& rect) const
- {
- FW_CAcquiredODShape aqODShape = AcquireFrameShape(ev, NULL);
- rect = FW_GetShapeBoundingBox(ev, aqODShape);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivFacetRemoved
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivFacetRemoved(Environment* ev, ODFacet* facet)
- {
- FW_ASSERT(fFacetCount > 0);
-
- FacetRemoved(ev, facet, fFacetCount);
-
- // ----- One less facet -----
- fFacetCount--;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivFacetAdded
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivFacetAdded(Environment* ev, ODFacet* facet)
- {
- // ----- One more facet -----
- fFacetCount++;
-
- FacetAdded(ev, facet, fFacetCount);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivAttachSourceFrame
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivAttachSourceFrame should not be called if sourceFrame == NULL
-
- void FW_CFrame::PrivAttachSourceFrame(Environment* ev, FW_CFrame* sourceFrame)
- {
- FW_ASSERT(sourceFrame != NULL);
- FW_ASSERT(fSourceFrame == this); // fSourceFrame is set to this in the constructor
-
- fSourceFrame = sourceFrame->GetSourceFrame(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::ActivateWindow
- //----------------------------------------------------------------------------------------
- // Return TRUE if the frame doesn't handle front click meaning that a mouse down event
- // should not be sent to it.
-
- FW_Boolean FW_CFrame::ActivateWindow(Environment* ev, ODFacet* facet, FW_Boolean activateFrame)
- {
- if (!GetWindow(ev)->IsFloating(ev))
- {
- FW_Boolean windowUnselected = !GetWindow(ev)->IsActive(ev);
-
- // ----- Select the window if not already selected -----
- if (windowUnselected)
- GetWindow(ev)->Select(ev);
-
- // ----- active frame on mousedown only if clicked in the frame -----
- if (activateFrame == TRUE /*&& fHasSelectionFocus == FALSE*/)
- {
- // fShowPaletteOnMouseUp = TRUE;
- ActivateFrame(ev, facet);
- }
-
- // ----- If the window was unselected and I don't want the -----
- // ----- first click just return TRUE;
- if (windowUnselected && !GetFrontClicks(ev))
- return TRUE;
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivUpdateScrollParameters
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivUpdateScrollParameters(Environment* ev)
- {
- if (fScroller && !fInternalTransformRealigmentNeeded)
- fScroller->UpdateScrollParameters(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivContentViewLocationChanged
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivContentViewLocationChanged(Environment* ev, const FW_CPoint& newLocation)
- {
- if (fContentViewOffset != newLocation)
- {
- FW_CAcquiredODTransform aqFrameInternalTransform = AcquireInternalTransform(ev);
- aqFrameInternalTransform->MoveBy(ev, (ODPoint*)&(-fContentViewOffset));
- aqFrameInternalTransform->MoveBy(ev, (ODPoint*)&newLocation);
-
- // fContentViewOffset must be set before calling PrivChangeInternalTransform because
- // it might be used then
- fContentViewOffset = newLocation;
-
- PrivChangeInternalTransform(ev, aqFrameInternalTransform);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivRealignInternalTransform
- //----------------------------------------------------------------------------------------
- // This is call when a document is reopened. Because the internal transform is saved by OpenDoc
- // and the InternalTransform contains the offset of the ContentView, if this offset is not
- // the same when the document is reopened I need to realign the Internal transform
- void FW_CFrame::PrivRealignInternalTransform(Environment* ev)
- {
- FW_ASSERT(fContentView);
-
- FW_CRect bounds = fContentView->GetBounds(ev);
- FW_CSuperView* contentViewParent = fContentView->GetSuperView(ev);
- if (contentViewParent)
- contentViewParent->ViewContentToFrame(ev, bounds);
-
- PrivContentViewLocationChanged(ev, bounds.TopLeft());
-
- fInternalTransformRealigmentNeeded = FALSE;
-
- if (fScroller)
- fScroller->PrivRealignScroller(ev);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CFrame::PrivStartStopDragging
- //---------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivStartStopDragging(Environment *ev, FW_EPrivDraggingFlags dragFlags)
- {
- FW_UNUSED(ev);
- FW_UNUSED(dragFlags);
- // No embedded frames
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivCreateSubViewsFromStream
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivCreateSubViewsFromStream(Environment* ev, FW_CReadableStream& stream)
- {
- FW_PREREGISTER_RUNTIME_OBJECT(stream,
- this,
- FW_kPreregisteredFrameObject);
-
- FW_CSuperView::PrivCreateSubViewsFromStream(ev, stream);
-
- short count;
- stream >> count;
- FW_ASSERT(count >= 0);
- FW_ASSERT(count <= 1);
- if (count == 1)
- {
- FW_CPrivBaseScroller* scroller;
- FW_READ_DYNAMIC_OBJECT(stream, &scroller, FW_CPrivBaseScroller);
-
- // [HLX] I am always dealing with a FW_CScroller
- AdoptScroller(ev, (FW_CScroller*)scroller);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivButtonAttached
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivButtonAttached(Environment* ev, FW_CButton* button)
- {
- FW_UNUSED(ev);
- FW_UNUSED(button);
- // Nothing to do look at FW_CDialogFrame
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivCreateViewAs
- //----------------------------------------------------------------------------------------
- // Call in places where the viewas object might not be yet created
-
- void FW_CFrame::PrivCreateViewAs(Environment* ev)
- {
- ODTypeToken viewType = GetViewType(ev);
- if (viewType != FW_CPart::fgViewAsFrameToken && fViewAs == NULL)
- {
- fViewAs = fPresentation->PrivAcquireViewAs(ev, this, viewType);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivInstantiateViews
- //----------------------------------------------------------------------------------------
-
- void FW_CFrame::PrivInstantiateViews(Environment* ev)
- {
- FW_ResourceID resourceID = GetPresentation(ev)->GetViewResourceID(ev, IsRoot(ev));
- if (resourceID != 0)
- CreateSubViewsFromResource(ev, resourceID); // Automatic view creation from resources
- else
- PrivCreateSubViews(ev); // Manual view creation
-
- fSubViewsCreated = TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFrame::PrivGetInfoString
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CFrame::PrivGetInfoString(Environment* ev, FW_CSelection* selection, FW_CString& infoString)
- {
- FW_Boolean gotInfo = false;
-
- //--- Check for Link Info ---
- if (GetPart(ev)->GetLinkManager(ev) != NULL)
- gotInfo = GetPart(ev)->GetLinkManager(ev)->GetLinkInfoString(ev, infoString);
- if (gotInfo) return true;
-
- //--- Check for Selection Info ---
- if (selection && !selection->IsEmpty(ev))
- gotInfo = selection->GetSelectionInfoString(ev, infoString);
-
- return gotInfo;
- }
-