home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 26.8 KB | 971 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Frame.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Table.hpp"
-
- // ----- TablePart Includes -----
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef PROXY_H
- #include "Proxy.h"
- #endif
-
- #ifndef SELECTION_H
- #include "Selection.h"
- #endif
-
- #ifndef TRACKER_H
- #include "Tracker.h"
- #endif
-
- #ifndef COMMANDS_H
- #include "Commands.h"
- #endif
-
- #ifndef LINKING_H
- #include "Linking.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWCLPCMD_H
- #include "FWClpCmd.h"
- #endif
-
- #ifndef FWPROXY_H
- #include "FWProxy.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWFCTCLP_H
- #include "FWFctClp.h"
- #endif
-
- #ifndef FWLNKITE_H
- #include "FWLnkIte.h"
- #endif
-
- #ifndef FWGROWBX_H
- #include "FWGrowBx.h"
- #endif
-
- #ifndef FWSCLBAR_H
- #include "FWSclBar.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- #ifndef FWRGNSHP_H
- #include "FWRgnShp.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWCURSOR_H
- #include "FWCursor.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- #ifndef FWEVEDEF_H
- #include "FWEveDef.h"
- #endif
-
- // ----- Foundation Layer -----
-
- #ifndef FWORDCOL_H
- #include "FWOrdCol.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODClipboard_xh
- #include <Clipbd.xh>
- #endif
-
- #ifndef SOM_ODDragItemIterator_xh
- #include <DgItmIt.xh>
- #endif
-
- #ifndef SOM_ODDragAndDrop_xh
- #include <DragDrp.xh>
- #endif
-
- #ifndef FWODTYPS_H
- #include "FWODTyps.h"
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- // ----- Macintosh Toolbox Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__RESOURCES__)
- #include <Resources.h>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfTable
- #endif
-
- FW_DEFINE_AUTO(CTableFrame)
-
- //========================================================================================
- // class CTableFrame
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::CTableFrame
- //----------------------------------------------------------------------------------------
-
- CTableFrame::CTableFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- CTablePart* tablePart,
- CTableContent* tableContent) :
- FW_CEmbeddingFrame(ev, odFrame, presentation, tablePart),
- FW_MDraggableFrame(ev, this),
- FW_MDroppableFrame(ev, this),
- fTablePart(tablePart),
- fTableContent(tableContent),
- fGridShown(TRUE),
- fHiliteState(FALSE)
- {
- ChangeDroppableState(ev, fGridShown ? FW_kFrameDroppable : FW_kNotDroppable);
- fDraggedCell.fX = fDraggedCell.fY = -1;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::~CTableFrame
- //----------------------------------------------------------------------------------------
-
- CTableFrame::~CTableFrame()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::GetSelection
- //----------------------------------------------------------------------------------------
-
- CTableSelection* CTableFrame::GetSelection(Environment* ev) const
- {
- return (CTableSelection*)GetPresentation(ev)->GetSelection(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::DoMenu
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Boolean result = TRUE;
- ODCommandID commandID = theMenuEvent.GetCommandID(ev);
-
- switch(commandID)
- {
- case cHideShowGrid:
- HideShowGrid(ev);
- break;
-
- default:
- result = FALSE;
- break;
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::HideShowGrid
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::HideShowGrid(Environment* ev)
- {
- fGridShown = !fGridShown;
- ChangeDroppableState(ev, fGridShown ? FW_kFrameDroppable : FW_kNotDroppable);
-
- FW_CFrameFacetIterator ite(ev, this);
- for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
- {
- FW_CViewContext fc(ev, this, facet);
- DrawGrid(ev, fc, fGridShown);
- }
-
- ChangeHiliteState(ev, fGridShown);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawFrame::DoActivateEvent
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::DoActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent)
- {
- // Got an activate(/deactivate) event. If I have the selection focus then redraw the hilite
-
- if (fGridShown && HasSelectionFocus(ev))
- ChangeHiliteState(ev, theActivateEvent.IsActivating(ev));
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_CViewContext fc(ev, this, odFacet, invalidShape);
-
- FW_CRect invalidRect;
- fc.GetClipRect(invalidRect);
-
- // Erase invalid portion of the frame
- FW_CRectShape::RenderRect(fc, invalidRect, FW_kFill, FW_kWhiteEraseInk);
-
- // Draw the table grid
- if (fGridShown)
- DrawGrid(ev, fc, TRUE);
-
- // Draw the selection
- if (HasSelectionFocus(ev) && fGridShown && fHiliteState)
- DrawCellHilite(ev, fc, GetSelection(ev)->GetSelectedCell());
-
- //--- Draw Link borders ---
- FW_CAcquiredODWindow aqODWindow = odFacet->GetFrame(ev)->AcquireWindow(ev);
- if (aqODWindow->ShouldShowLinks(ev))
- {
- //--- Draw borders around links ---
- FW_CLinkIterator it(fTablePart->GetLinkManager(ev));
- for (FW_CLink* link = it.FirstLink(); it.IsNotComplete(); link = it.NextLink())
- {
- link->ShowHideLinkBorder(ev, true, odFacet);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::ChangeHiliteState
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::ChangeHiliteState(Environment* ev, FW_Boolean state)
- {
- if (state == fHiliteState)
- return;
-
- fHiliteState = state;
- CCell cell = GetSelection(ev)->GetSelectedCell();
-
- FW_CFrameFacetIterator ite(ev, this);
- for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
- {
- FW_CViewContext fc(ev, this, facet);
- DrawCellHilite(ev, fc, cell);
- }
-
- CTableProxy* proxy = fTableContent->CellToProxy(cell);
- if (proxy)
- proxy->ChangeHighlight(ev, state ? kODFullHighlight : kODNoHighlight, this);
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::DrawCellHilite
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::DrawCellHilite(Environment* ev, FW_CViewContext& fc, const CCell& cell)
- {
- CTableProxy* proxy = fTableContent->CellToProxy(cell);
- if (proxy == NULL)
- {
- FW_CRect rect;
- fTableContent->FindRect(cell, rect);
- FW_CRectShape::RenderRect(fc, rect, FW_kFill, FW_CInk(FW_kHilite));
- }
- else
- {
- FW_CAcquiredODShape hiliteShape = proxy->AcquireHiliteShape(ev, cell, this);
- FW_CRegionShape::RenderRegion(fc, hiliteShape, FW_kFill, FW_CInk(FW_kHilite));
- }
- }
-
- //---------------------------------------------------------------------------------------
- // CTableFrame::DrawGrid
- //---------------------------------------------------------------------------------------
-
- void CTableFrame::DrawGrid(Environment* ev, FW_CGraphicContext& gc, FW_Boolean gray)
- {
- // Get the frame's rect at (0,0), inset by margins
- FW_CRect rect;
- this->GetRect(ev, rect);
-
- // Draw the table grid
- FW_CLineShape lineShape;
- lineShape.GetStyle().SetPattern(gray ? FW_kGrayPat : FW_kWhitePat);
-
- FW_Fixed xy;
- short rc;
- for(xy = rect.top, rc = 0; xy < rect.bottom; xy += fTableContent->GetHeight(rc++) + kBorderHeight)
- {
- lineShape.SetLineStart(rect.left, xy);
- lineShape.SetLineEnd(rect.right, xy);
- lineShape.Render(gc);
- }
-
- for(xy = rect.left, rc = 0; xy < rect.right; xy += fTableContent->GetWidth(rc++) + kBorderHeight)
- {
- lineShape.SetLineStart(xy, rect.top);
- lineShape.SetLineEnd(xy, rect.bottom);
- lineShape.Render(gc);
- }
- }
-
- //---------------------------------------------------------------------------------------
- // CTableFrame::DoAdjustMenus
- //---------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- if (hasMenuFocus)
- {
- FW_Boolean hasSelection = !GetSelection(ev)->IsEmpty(ev);
- FW_Boolean canEmbedInCell = fGridShown && GetSelection(ev)->IsEmpty(ev);
-
- menuBar->EnableAndToggleCommand(ev, cHideShowGrid, TRUE, fGridShown);
-
- // If an embedded part is selected, change Copy item to "Copy Part"
- #if 0
- // CodeWarrior destructs the temporary before passing it into SetItemString!
- menuBar->SetItemString(ev, kODCommandCopy, hasSelection ? FW_CString32("Copy Part") : FW_CString32("Copy"));
- #else
- FW_CString32 itemName;
- if (hasSelection)
- itemName = "Copy Part";
- else
- itemName = "Copy";
- menuBar->SetItemString(ev, kODCommandCopy, itemName);
- #endif
-
- menuBar->EnableCommand(ev, kODCommandCopy, fGridShown && hasSelection);
- menuBar->EnableCommand(ev, kODCommandClear, fGridShown && hasSelection);
- menuBar->EnableCommand(ev, kODCommandCut, fGridShown && hasSelection);
-
- menuBar->EnableCommand(ev, kODCommandInsert, canEmbedInCell);
-
- // Check clipboard for pastable property
- menuBar->EnableCommand(ev, kODCommandPaste, canEmbedInCell && HasPropertyOnClipboard(ev, kODPropContentFrame, NULL));
- menuBar->EnableCommand(ev, kODCommandPasteAs, canEmbedInCell && HasPropertyOnClipboard(ev, kODPropLinkSpec, kODLinkSpec));
-
- // Because all my embedded frames are always selected I need to do my own enabling
- menuBar->EnableCommand(ev, kODCommandOpen, hasSelection);
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::FrameShapeChanged
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::FrameShapeChanged(Environment* ev)
- {
- FW_CEmbeddingFrame::FrameShapeChanged(ev);
-
- // ----- Recalculate the clip of all my embedded facets -----
- FW_CFacetClipper facetClipper(ev, fTablePart);
- facetClipper.Clip(ev, GetPresentation(ev), NULL);
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::CanAcceptDrop
- //----------------------------------------------------------------------------------------
- // As an embedding frame I can accept anything
-
- ODDragResult CTableFrame::CanAcceptDrop(Environment *ev, ODDragItemIterator* dragInfo)
- {
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::DoVirtualKey
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::DoVirtualKey(Environment* ev, const FW_CVirtualKeyEvent& theVirtualKeyEvent)
- {
- FW_Boolean wasHandled = FALSE;
- CCell cell = this->GetSelection(ev)->GetSelectedCell();
- CCell size = fTableContent->GetSize();
-
- switch (theVirtualKeyEvent.GetKeyCode(ev))
- {
- case FW_kVKLeft:
- if(cell.fX > 0)
- {
- cell.fX -= 1;
- this->SelectCell(ev, cell);
- wasHandled = TRUE;
- }
- break;
- case FW_kVKRight:
- if(cell.fX < size.fX - 1)
- {
- cell.fX += 1;
- this->SelectCell(ev, cell);
- wasHandled = TRUE;
- }
- break;
- case FW_kVKUp:
- if(cell.fY > 0)
- {
- cell.fY -= 1;
- this->SelectCell(ev, cell);
- wasHandled = TRUE;
- }
- break;
- case FW_kVKDown:
- if(cell.fY < size.fY - 1)
- {
- cell.fY += 1;
- this->SelectCell(ev, cell);
- wasHandled = TRUE;
- }
- break;
-
- case FW_kVKBackspace:
- case FW_kVKClear:
- FW_CClipboardCommand* cmd = this->NewClipboardCommand(ev, kODCommandClear);
- if (cmd)
- {
- cmd->Execute(ev);
- wasHandled = TRUE;
- }
- break;
- }
-
- return wasHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::DoMouseDown
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- FW_Boolean result = FALSE;
-
- if (fGridShown)
- {
- if (GetSelection(ev)->IsMouseInDraggableItem(ev, this, theMouseEvent, FALSE))
- {
- result = Drag(ev, theMouseEvent);
- }
- else
- {
- FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
-
- CCell cell;
- ETableLoc tl = HitTest(ev, where, cell);
-
- if (tl != kTLNone && tl != kTLCell)
- this->Resize(ev, theMouseEvent, cell, tl);
-
- result = TRUE;
- }
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::DoMouseDownInEmbeddedFrameBorder
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::DoMouseDownInEmbeddedFrameBorder(Environment* ev, const FW_CBorderMouseEvent& theBorderMouseEvent)
- {
- FW_Boolean result = FALSE;
-
- if (fGridShown)
- result = this->Drag(ev, theBorderMouseEvent);
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::SelectCell
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::SelectCell(Environment* ev, const CCell& cell)
- {
- GetSelection(ev)->Select(ev, cell);
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::Resize
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::Resize(Environment* ev,
- const FW_CMouseEvent& theMouseEvent,
- const CCell& cell,
- ETableLoc tl)
- {
- FW_ASSERT(tl != kTLNone && tl != kTLCell);
- FW_Boolean result = FALSE;
-
- // maximum rectangle
- FW_CRect maxRect;
- this->GetRect(ev, maxRect);
- maxRect.right -= kPenWidth;
- maxRect.bottom -= kPenHeight;
-
- // Location of borders
- FW_CRect cellRect;
- fTableContent->FindRect(cell, cellRect);
-
- FW_CPoint borders;
- if ((tl & kTLLeftBorder) != 0)
- {
- maxRect.left = ((cell.fX == 0) ? cellRect.left : fTableContent->FindLeft(cell.fX - 1)) + kBorderWidth;
- borders.x = cellRect.left;
- }
- else
- {
- maxRect.left = cellRect.left + kBorderWidth;
- borders.x = cellRect.right;
- }
-
- if ((tl & kTLTopBorder) != 0)
- {
- maxRect.top = ((cell.fY == 0) ? cellRect.top : fTableContent->FindTop(cell.fY - 1)) + kBorderHeight;
- borders.y = cellRect.top;
- }
- else
- {
- maxRect.top = cellRect.top + kBorderHeight;
- borders.y = cellRect.bottom;
- }
-
-
- // Create a tracker for the grid lines
- CGridLineTracker tracker(ev, this, theMouseEvent.GetFacet(ev), tl, maxRect, borders);
-
- if (tracker.Track(ev, theMouseEvent))
- {
- // Set the new cell size
- FW_CPoint delta = tracker.GetNewBorders() - tracker.GetOldBorders();
- if (delta.x != FW_kFixed0 || delta.y != FW_kFixed0)
- {
- fTableContent->Resize(ev, cell, tl, delta);
- GetPresentation(ev)->Invalidate(ev);
- result = TRUE;
- }
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::Drag
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::Drag(Environment* ev, const FW_CMouseEvent& event)
- {
- fDraggedCell = GetSelection(ev)->GetSelectedCell();
-
- FW_Boolean result = FW_MDraggableFrame::Drag(ev, event);
-
- fDraggedCell.fX = fDraggedCell.fY = -1;
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::FocusStateChanged
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::FocusStateChanged(Environment* ev, ODTypeToken focus, FW_Boolean newState, ODFrame* newOwner)
- {
- FW_CEmbeddingFrame::FocusStateChanged(ev, focus, newState, newOwner);
-
- if (focus == FW_CPart::gSelectionFocusToken)
- {
- // • If I get the selection focus I redraw the hilite only if the window is not active
- // if the window is active they already have been redrawn by DoActivateEvent
- // • If I am loosing the selection focus I redraw the hilite only if the window is active
- // if the window is not active they already have been redrawn by DoActivateEvent
- // The events order is:
- // - Window 1 deactivated
- // - Frame 1 lose selection focus
- // - Frame 2 gain selection focus
- // - Window 2 activated
- FW_Boolean windowActive = GetWindow(ev)->IsActive(ev);
- FW_Boolean hilite = newState ? !windowActive : windowActive;
- if (hilite && fGridShown)
- ChangeHiliteState(ev, newState);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::AdjustCursor
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::AdjustCursor(Environment* ev, ODFacet* odFacet, const FW_CPoint& where)
- {
- FW_Boolean cursorAdjusted = FALSE;
-
- // I don't want the Open Hand Cursor if I have the grid hidden because I am not supposed to
- // be able to move anything
- if (fGridShown)
- cursorAdjusted = FW_CEmbeddingFrame::AdjustCursor(ev, odFacet, where);
-
- if (!cursorAdjusted && fGridShown)
- {
- CCell cell;
- ETableLoc tl = HitTest(ev, where, cell);
-
- cursorAdjusted = TRUE;
-
- if (tl == kTLCell || tl == kTLNone)
- FW_gArrowCursor.Select();
- else if (tl == kTLLeftBorder || tl == kTLRightBorder)
- FW_gSizeWECursor.Select();
- else if (tl == kTLTopBorder || tl == kTLBottomBorder)
- FW_gSizeNSCursor.Select();
- else
- FW_gSizeNWSECursor.Select();
- }
-
- return cursorAdjusted;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::GetRect
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::GetRect(Environment* ev, FW_CRect& rect) const
- {
- rect = GetBounds(ev);
- rect.left += kHMargin;
- rect.top += kVMargin;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::NewDropCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDropCommand* CTableFrame::NewDropCommand(Environment* ev,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* odFacet,
- const FW_CPoint& dropPoint)
- {
- FW_ASSERT(frame == this);
-
- CCell dropCell;
- HitTest(ev, dropPoint, dropCell);
-
- if (dropCell == fDraggedCell || fTableContent->CellToProxy(dropCell) != NULL) // If alreay a proxy gave up
- return NULL;
- else
- return FW_NEW(CCellDropCommand, (ev, fTablePart, fTableContent, this,
- dropInfo, odFacet, dropPoint,
- dropCell, fDraggedCell));
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::NewDropTracker
- //----------------------------------------------------------------------------------------
-
- FW_CDropTracker* CTableFrame::NewDropTracker(Environment *ev, FW_CView* view, ODFacet* facet)
- {
- return new CTableDropTracker(ev, fTablePart, fTableContent, this, facet, fDraggedCell);
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::CreateEmbeddedFacet
- //----------------------------------------------------------------------------------------
-
- ODFacet* CTableFrame::CreateEmbeddedFacet(Environment* ev,
- ODFacet* embeddingFacet,
- FW_MProxy* proxy,
- ODFrame* embeddedFrame,
- ODShape* proposedClipShape)
- {
- CCell cell = ((CTableProxy*)proxy)->GetCell();
-
- FW_CRect rect;
- fTableContent->FindRect(cell, rect);
-
- FW_CAcquiredODTransform aqExternalTransform = ::FW_NewODTransform(ev, rect.TopLeft());
-
- return embeddingFacet->CreateEmbeddedFacet(ev,
- embeddedFrame,
- proposedClipShape,
- aqExternalTransform,
- NULL, // Canvas
- NULL, // biasCanvas
- NULL, // siblingFacet
- kODFrameInFront);
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::NewClipboardCommand
- //----------------------------------------------------------------------------------------
-
- FW_CClipboardCommand* CTableFrame::NewClipboardCommand(Environment* ev, ODCommandID commandID)
- {
- return FW_NEW(CTableEditCommand, (ev,
- commandID,
- fTablePart,
- fTableContent,
- this,
- this->GetSelection(ev)));
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::NewDragCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDragCommand* CTableFrame::NewDragCommand(Environment* ev,
- FW_CFrame* theFrame,
- const FW_CMouseEvent& theMouseEvent)
- {
- return FW_NEW(CCellDragCommand, (ev, fTableContent, theFrame, this->GetSelection(ev)));
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::NewInsertCommand
- //----------------------------------------------------------------------------------------
- FW_CInsertCommand* CTableFrame::NewInsertCommand(Environment* ev, const FW_PFileSpecification& fileSpec)
- {
- return FW_NEW(CTableInsertCommand, (ev,
- this,
- fileSpec,
- fTablePart,
- GetSelection(ev)->GetSelectedCell()));
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::MoveProxy
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::MoveProxy(Environment* ev, CTableProxy* proxy, const CCell& destCell)
- {
- // Invalidate the source cell
- FW_CRect rect;
- CCell srcCell = proxy->GetCell();
- fTableContent->FindRect(srcCell, rect);
- this->GetPresentation(ev)->Invalidate(ev, rect);
-
- proxy->MoveEmbeddedFrames(ev, destCell);
- proxy->SetCell(destCell);
- this->SelectCell(ev, destCell);
-
- // Invalidate the destination cell
- fTableContent->FindRect(destCell, rect);
- this->GetPresentation(ev)->Invalidate(ev, rect);
-
- // Notify frame
- fTablePart->PartChanged(ev);
- }
-
- //---------------------------------------------------------------------------------------
- // CTableFrame::FacetAdded
- //---------------------------------------------------------------------------------------
-
- void CTableFrame::FacetAdded(Environment* ev, ODFacet* facet, unsigned short facetCount)
- {
- FW_CEmbeddingFrame::FacetAdded(ev, facet, facetCount); // call inherited
-
- // We need to register any link destinations that were just internalized.
- fTablePart->RegisterSubscribers(ev);
- }
-
- //---------------------------------------------------------------------------------------
- // CTableFrame::ShowPartInfo
- //---------------------------------------------------------------------------------------
-
- void CTableFrame::ShowPartInfo(Environment* ev)
- {
- if (fTablePart->ShowLinkInfo(ev, this)) return;
-
- // Table part didn't handle it, so call inherited
- FW_CEmbeddingFrame::ShowPartInfo(ev);
- }
-
- //---------------------------------------------------------------------------------------
- // CTableFrame::RevealFrame
- //---------------------------------------------------------------------------------------
- FW_Boolean CTableFrame::RevealFrame(Environment *ev,
- ODFrame* embeddedFrame,
- ODShape* revealShape)
- {
- FW_UNUSED(revealShape);
-
- // Change table selection to the cell of the embedded frame
- CTableProxy* proxy = (CTableProxy*) this->GetProxy(ev, embeddedFrame);
- if (proxy)
- {
- this->SelectCell(ev, proxy->GetCell());
- return TRUE;
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::HitTest
- //----------------------------------------------------------------------------------------
-
- ETableLoc CTableFrame::HitTest(Environment* ev,
- const FW_CPoint& where,
- CCell& cell) const
- {
- // Verify point is in table area (also exclude the top or left margins)
- FW_CRect rect;
- GetRect(ev, rect);
-
- cell.fX = cell.fY = 0;
-
- if(!rect.Contains(where))
- return kTLNone;
-
- FW_CRect cellRect;
- while (TRUE)
- {
- fTableContent->FindRect(cell, cellRect);
- cellRect.Inset(-kPenWidth, -kPenHeight);
- FW_CPoint testPoint(where.x, cellRect.top);
- if (cellRect.Contains(testPoint))
- break;
- cell.fX += 1;
- }
-
- while (TRUE)
- {
- fTableContent->FindRect(cell, cellRect);
- cellRect.Inset(-kPenWidth, -kPenHeight);
- FW_CPoint testPoint(cellRect.left, where.y);
- if (cellRect.Contains(testPoint))
- break;
- cell.fY += 1;
- }
-
- ETableLoc tl = kTLCell;
-
- fTableContent->FindRect(cell, cellRect);
-
- if (where.x <= cellRect.left + kHMargin)
- tl += kTLLeftBorder;
- else if (cellRect.right - kHMargin <= where.x)
- tl += kTLRightBorder;
-
- if (where.y <= cellRect.top + kVMargin)
- tl += kTLTopBorder;
- else if (cellRect.bottom - kVMargin <= where.y)
- tl += kTLBottomBorder;
-
- if (cell.fY == 0 && ((tl & kTLTopBorder) != 0))
- tl = kTLNone;
-
- if (cell.fX == 0 && ((tl & kTLLeftBorder) != 0))
- tl = kTLNone;
-
- return tl;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::CreateSubViews
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::CreateSubViews(Environment* ev)
- {
- // Create a GrowBox only in root frame
- // Note: you do not need CreateSubViews if the views are defined in resources.
- // See the Container or Form samples.
-
- if (this->IsRoot(ev))
- {
- FW_CRect frameRect = GetBounds(ev);
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
- frameRect.right -= sbSize.x;
- frameRect.bottom -= sbSize.y;
-
- FW_CGrowBox* growBox = new FW_CGrowBox(ev, this, 0, frameRect.BotRight());
- }
- }
-
-
-