home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
opendc12.zip
/
od124os2.exe
/
od12osp1.exe
/
src
/
basecntr
/
iodbcobj.cpp
< prev
next >
Wrap
Text File
|
1997-04-02
|
44KB
|
1,214 lines
//====START_GENERATED_PROLOG======================================
//
//
// COMPONENT_NAME: odbasecntr
//
// CLASSES: none
//
// ORIGINS: 82,27
//
//
// (C) COPYRIGHT International Business Machines Corp. 1995,1996
// All Rights Reserved
// Licensed Materials - Property of IBM
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//
// IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
// USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
// OR PERFORMANCE OF THIS SOFTWARE.
//
//====END_GENERATED_PROLOG========================================
//
/* @(#) 1.37 com/src/samples/basecntr/iodbcobj.cpp, odbasepart, od96os2, odos29714c 3/28/97 10:56:26 [4/2/97 17:20:15] */
/*
* This file was generated by the SOM Compiler.
* Generated using:
* SOM incremental update: Development
*/
#define SOM_Module_iodbcobj_Source
#define VARIABLE_MACROS
#define METHOD_MACROS
#define SOM_DONT_IMPORT_CLASS_ALink
#define SOM_DONT_IMPORT_CLASS_ALinkedList
#define SOM_DONT_IMPORT_CLASS_BCIterator
#ifndef _ALTPOINT_
#include <AltPoint.h>
#endif
#ifndef SOM_ODStorageUnit_xh
#include <StorageU.xh>
#endif
#ifndef SOM_ODStorageUnitCursor_xh
#include <SUCursor.xh>
#endif
#ifndef SOM_ODFrame_xh
#include <Frame.xh>
#endif
#ifndef SOM_ODFacet_xh
#include <Facet.xh>
#endif
#ifndef SOM_ODTransform_xh
#include <Trnsform.xh>
#endif
#ifndef SOM_ODShape_xh
#include <Shape.xh>
#endif
#ifndef SOM_ODFrameFacetIterator_xh
#include <FrFaItr.xh>
#endif
#ifndef SOM_ODSession_xh
#include <ODSessn.xh>
#endif
#include <StdProps.xh>
#include <TempObj.h>
#include <ODDebug.h>
#include <StorUtil.h>
#include <ODMath.h>
#include <StdTypIO.h>
#include <bcmain.h> // Remove include when kODFrameList is made public.
#include <iodbcobj.xih>
#ifndef _ALinkedList_
#include <iodbcutl.xh>
#endif
#if defined(_PLATFORM_UNIX_)
#define min(a,b) (a)<(b) ? (a) : (b)
#define max(a,b) (a)>(b) ? (a) : (b)
#endif
extern ODFacet* FirstFacet (Environment *ev, ODFrame *frame);
void ComputeRectAfterResize (ODRect *rect, ODULong resizeFlags,
ODPoint *endPt)
{
ODRect boundingRect = *rect;
if (resizeFlags & COBJ_RESIZE_LEFT)
{
rect->left = min(boundingRect.right, endPt->x);
rect->right = max(boundingRect.right, endPt->x);
}
else if (resizeFlags & COBJ_RESIZE_RIGHT)
{
rect->left = min(boundingRect.left, endPt->x);
rect->right = max(boundingRect.left, endPt->x);
}
#if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
if (resizeFlags & COBJ_RESIZE_TOP)
{
rect->top = min(boundingRect.bottom, endPt->y);
rect->bottom = max(boundingRect.bottom, endPt->y);
}
else if (resizeFlags & COBJ_RESIZE_BOTTOM)
{
rect->top = min(boundingRect.top, endPt->y);
rect->bottom = max(boundingRect.top, endPt->y);
}
#elif defined(_PLATFORM_OS2_)
if (resizeFlags & COBJ_RESIZE_TOP)
{
rect->top = max(boundingRect.bottom, endPt->y);
rect->bottom = min(boundingRect.bottom, endPt->y);
}
else if (resizeFlags & COBJ_RESIZE_BOTTOM)
{
rect->top = max(boundingRect.top, endPt->y);
rect->bottom = min(boundingRect.top, endPt->y);
}
#endif
}
SOM_Scope void SOMLINK ContentObjectWriteContents(ContentObject *somSelf,
Environment *ev,
ODStorageUnit* toSU,
BCTransferKind writeKind,
BCCloneInfo* cloneInfo)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectWriteContents");
ODRect bbox = _boundingRect;
if (cloneInfo->refPoint) {
bbox.left -= cloneInfo->refPoint->x;
bbox.right -= cloneInfo->refPoint->x;
bbox.top -= cloneInfo->refPoint->y;
bbox.bottom -= cloneInfo->refPoint->y;
}
#ifdef _PLATFORM_OS2_
// Modify rectangle coordinates as if the origin was at top-left.
somSelf->ChangeRectBias(ev, &bbox);
#endif
ODSetRectProp (ev, toSU, kODNULL, kODNULL, &bbox);
//PRINT("write contents %lx\n", somSelf);
//_extTransform->WriteTo (ev, toSU);
ODSetULongProp (ev, toSU, kODNULL, kODNULL, _linkStatus);
}
SOM_Scope void SOMLINK ContentObjectReadContents(ContentObject *somSelf,
Environment *ev,
ODStorageUnit* fromSU,
BCTransferKind readKind,
BCCloneInfo* cloneInfo)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectReadContents");
_containingFrame = cloneInfo->myFrame;
ODGetRectProp (ev, fromSU, kODNULL, kODNULL, &_boundingRect);
#ifdef _PLATFORM_OS2_
// Reverse the coordinate modification applied in WriteContents
somSelf->ChangeRectBias(ev, &_boundingRect);
#endif
if (cloneInfo->refPoint) {
_boundingRect.left += cloneInfo->refPoint->x;
_boundingRect.right += cloneInfo->refPoint->x;
_boundingRect.top += cloneInfo->refPoint->y;
_boundingRect.bottom += cloneInfo->refPoint->y;
}
//PRINT("read contents %lx\n", somSelf);
//_extTransform->ReadFrom (ev, fromSU);
_linkStatus = ODGetULongProp (ev, fromSU, kODNULL, kODNULL);
}
SOM_Scope void SOMLINK ContentObjectDeleteContents(ContentObject *somSelf,
Environment *ev,
ODULong type)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectDeleteContents");
memset(&_boundingRect, 0, sizeof(ODRect));
_containingFrame = NULL;
_selectionState = 0;
_linkStatus = kODNotInLink;
}
SOM_Scope void SOMLINK ContentObjectMoveBy(ContentObject *somSelf,
Environment *ev,
ODPoint* offset)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectMoveBy");
_boundingRect.left += offset->x;
_boundingRect.right += offset->x;
_boundingRect.top += offset->y;
_boundingRect.bottom += offset->y;
}
SOM_Scope void SOMLINK ContentObjectResize(ContentObject *somSelf,
Environment *ev,
ODPoint* endPt,
ODULong resizeFlags)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectResize");
ComputeRectAfterResize (&_boundingRect, resizeFlags, endPt);
}
SOM_Scope void SOMLINK ContentObjectMoveToFront(ContentObject *somSelf,
Environment *ev)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectMoveToFront");
}
SOM_Scope void SOMLINK ContentObjectMoveToBack(ContentObject *somSelf,
Environment *ev)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectMoveToBack");
}
SOM_Scope ContentObject* SOMLINK ContentObjectCreateNewView(ContentObject *somSelf,
Environment *ev, ODFrame *viewFrame)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectCreateNewView");
ContentObject *newObj = new ContentObject();
newObj->_set_boundingRect(ev, &_boundingRect);
newObj->_set_containingFrame (ev, viewFrame);
newObj->SetExtTransform (ev, _extTransform);
return newObj;
}
SOM_Scope void SOMLINK ContentObjectChangeExtTransform (ContentObject *somSelf,
Environment *ev, ODTransform *xform, ODULong xformFlags)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectChangeExtTransform");
switch (xformFlags) {
case EXTXFORM_REPLACE:
_extTransform->CopyFrom (ev, xform);
break;
case EXTXFORM_PRECOMPOSE:
_extTransform->PreCompose (ev, xform);
break;
case EXTXFORM_POSTCOMPOSE:
_extTransform->PostCompose (ev, xform);
break;
default:
break;
} /* endswitch */
}
SOM_Scope void SOMLINK ContentObjectSetExtTransform (ContentObject *somSelf,
Environment *ev, ODTransform *extTransform)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectSetExtTransform");
_extTransform->CopyFrom (ev, extTransform);
}
//-----------------------------------------------------------------------------
// ContentObject->ChangePointBias
//
// Changes the coordinates of the given point from a coordinate system with a
// a bottom-left origin to one with a top-left origin, and vice-versa.
//
// point: Point to be modified. It should be specified in
// content coordinates this ContentObject's containing part.
//-----------------------------------------------------------------------------
SOM_Scope void SOMLINK ContentObjectChangePointBias ( ContentObject *somSelf,
Environment *ev,
ODPoint *point)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectChangePointBias");
// Get the height of the container's content.
ODPoint extent(0,0);
__get_containingFrame(ev)->GetContentExtent(ev, &extent);
// Translate the point.
point->y = extent.y - point->y;
}
//-----------------------------------------------------------------------------
// ContentObject->ChangeRectBias
//
// Changes the coordinates of the given rectangle from a coordinate system
// with a bottom-left origin to one with a top-left origin, and vice-versa.
//
// rect: Rectangle to be modified. It should be specified in
// content coordinates of this ContentObject's containing part.
//-----------------------------------------------------------------------------
SOM_Scope void SOMLINK ContentObjectChangeRectBias ( ContentObject *somSelf,
Environment *ev,
ODRect *rect)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectChangeRectBias");
// Get the height of the container's content.
ODPoint extent(0,0);
__get_containingFrame(ev)->GetContentExtent(ev, &extent);
// Modify the rectangle's coordinates.
rect->top = extent.y - rect->top;
rect->bottom = extent.y - rect->bottom;
}
//-----------------------------------------------------------------------------
// ContentObject->ChangeTransformBias
//
// Changes the offset of the given transform from a coordinate system
// with a bottom-left origin to one with a top-left origin, and vice-versa.
//
// xform: External transform to be modified. The offset of this
// transform should specify the position of this
// ContentObject in its containing part's content.
//-----------------------------------------------------------------------------
SOM_Scope void SOMLINK ContentObjectChangeTransformBias ( ContentObject *somSelf,
Environment *ev,
ODTransform *xform)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectChangeTransformBias");
// Get the offset from the transform.
ODPoint offset(0,0);
xform->GetOffset(ev, &offset);
// Get the height of the container's content.
ODPoint extent(0,0);
__get_containingFrame(ev)->GetContentExtent(ev, &extent);
// Get the height of this object.
ODULong myHeight = somSelf->GetHeight(ev);
// The new Y offset will be the container height minus
// the current Y offset, minus the height of this object.
offset.y = extent.y - offset.y - myHeight;
xform->SetOffset(ev, &offset);
}
//-----------------------------------------------------------------------------
// ContentObject->GetHeight
//
// Determines the height of this ContentObject.
//-----------------------------------------------------------------------------
SOM_Scope ODULong SOMLINK ContentObjectGetHeight ( ContentObject *somSelf,
Environment *ev)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectGetHeight");
// Get the bounding rectangle of this object.
ODRect bbox = __get_boundingRect(ev);
// Determine the height of this object.
return abs(bbox.top - bbox.bottom);
}
SOM_Scope void SOMLINK ContentObjectsomInit(ContentObject *somSelf)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectsomInit");
ContentObject_parent_ODObject_somInit(somSelf);
_objType = COBJ_BASECLASS;
memset(&_boundingRect, 0, sizeof(ODRect));
_containingFrame = NULL;
_selectionState = 0;
Environment *ev = somGetGlobalEnvironment();
_extTransform = new ODTransform();
_extTransform->InitTransform(ev);
_linkStatus = kODNotInLink;
}
SOM_Scope void SOMLINK ContentObjectsomUninit(ContentObject *somSelf)
{
ContentObjectData *somThis = ContentObjectGetData(somSelf);
ContentObjectMethodDebug("ContentObject","ContentObjectsomUninit");
if (_extTransform) {
Environment *ev = somGetGlobalEnvironment();
_extTransform->Release(ev);
}
ContentObject_parent_ODObject_somUninit(somSelf);
}
SOM_Scope void SOMLINK ContentFramesomInit(ContentFrame *somSelf)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFramesomInit");
ContentFrame_parent_ContentObject_somInit(somSelf);
__set_objType(somGetGlobalEnvironment(), COBJ_FRAMECLASS);
_myFrame = kODNULL;
}
SOM_Scope void SOMLINK ContentFramesomUninit(ContentFrame *somSelf)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFramesomUninit");
ContentFrame_parent_ContentObject_somUninit(somSelf);
}
SOM_Scope void SOMLINK ContentFrame_set_selectionState(ContentFrame *somSelf,
Environment *ev,
ODULong selectionState)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrame_set_selectionState");
ContentFrame_parent_ContentObject__set_selectionState(somSelf,
ev,
selectionState);
ODFacet *theFacet = NULL;
ODFrameFacetIterator* ffitr =
_myFrame->CreateFacetIterator(ev);
for (theFacet = (ODFacet *)ffitr->First(ev);
ffitr->IsNotComplete(ev);
theFacet = (ODFacet *)ffitr->Next(ev))
{
if (selectionState) {
// Show selected state
theFacet->SetSelected(ev, kODTrue);
theFacet->ChangeHighlight(ev, kODFullHighlight);
}
else {
// Show deselected state
theFacet->SetSelected(ev, kODFalse);
theFacet->ChangeHighlight(ev, kODNoHighlight);
}
}
delete ffitr;
}
SOM_Scope ODRect SOMLINK ContentFrame_get_boundingRect(ContentFrame *somSelf,
Environment *ev)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrame_get_boundingRect");
ODRect tempRect;
TempODShape shape = _myFrame->AcquireFrameShape(ev, kODNULL);
TempODShape newShape = shape->Copy(ev);
ODFrameFacetIterator* ffitr =
_myFrame->CreateFacetIterator(ev);
ODFacet *facet = ffitr->First(ev);
if(facet) {
TempODTransform tf = facet->AcquireExternalTransform (ev, kODNULL);
newShape->Transform(ev, tf);
newShape->GetBoundingBox (ev, &tempRect);
} else {
// This method may be called during internalization before we
// have a facet. In that case return the already internalized
// ContentObject's boundingRect.
tempRect = ContentFrame_parent_ContentObject__get_boundingRect(somSelf, ev);
}
delete ffitr;
return tempRect;
}
SOM_Scope ODFrame* SOMLINK ContentFrame_get_containingFrame(ContentFrame *somSelf,
Environment *ev)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrame_get_containingFrame");
if(_myFrame) {
TempODFrame tf = _myFrame->AcquireContainingFrame(ev);
return tf;
}else{
return ContentFrame_parent_ContentObject__get_containingFrame(somSelf, ev);
}
}
SOM_Scope void SOMLINK ContentFrame_set_containingFrame(ContentFrame *somSelf,
Environment *ev,
ODFrame* containingFrame)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrame_set_containingFrame");
ContentFrame_parent_ContentObject__set_containingFrame(somSelf,
ev,
containingFrame);
_myFrame->SetContainingFrame(ev, containingFrame);
}
SOM_Scope ODULong SOMLINK ContentFrame_get_linkStatus(ContentFrame *somSelf,
Environment *ev)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrame_get_linkStatus");
return _myFrame->GetLinkStatus (ev);
}
SOM_Scope void SOMLINK ContentFrame_set_linkStatus(ContentFrame *somSelf,
Environment *ev,
ODULong linkStatus)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrame_set_linkStatus");
ContentFrame_parent_ContentObject__set_linkStatus(somSelf, ev, linkStatus);
_myFrame->ChangeLinkStatus (ev, linkStatus);
}
SOM_Scope void SOMLINK ContentFrameWriteContents(ContentFrame *somSelf,
Environment *ev,
ODStorageUnit* toSU,
BCTransferKind writeKind,
BCCloneInfo* cloneInfo)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrameWriteContents");
TempODPart myPart = _myFrame->AcquirePart(ev);
ODDraft *fromDraft = myPart->GetStorageUnit(ev)->GetDraft(ev);
ODID frameID = _myFrame->GetStorageUnit (ev) ->GetID (ev);
if (writeKind == EXTERNALIZE)
_myFrame->Externalize(ev);
else
frameID = fromDraft->Clone(ev, cloneInfo->key, frameID, 0, frameID);
// Write contents to frame list standard part kind.
if(toSU->Exists(ev, kODPropContents, kODFrameList, 0) && (cloneInfo->frameListInfo)) {
somSelf->WriteContentsToFrameList(ev, toSU, writeKind, cloneInfo, frameID);
}
// Call parent
ContentFrame_parent_ContentObject_WriteContents(somSelf,
ev,
toSU,
writeKind,
cloneInfo);
ODSetStrongSURefProp (ev, toSU, kODNULL, kODNULL, frameID);
// Store the transform
ODFacet *firstFacet = FirstFacet (ev, _myFrame);
TempODTransform extTransform =
firstFacet->AcquireExternalTransform(ev, kODNULL);
TempODTransform saveTransform = extTransform->Copy(ev);
if (cloneInfo->refPoint) {
ODPoint pt( -(cloneInfo->refPoint->x), -(cloneInfo->refPoint->y));
saveTransform->MoveBy (ev, &pt);
}
#ifdef _PLATFORM_OS2_
// Modify the transform as if the origin was at top-left.
somSelf->ChangeTransformBias(ev, saveTransform);
#endif
ODMatrix m;
saveTransform->GetMatrix(ev, &m);
ODSetMatrixProp (ev, toSU, kODNULL, kODNULL, &m);
// Set parent's attributes which are needed later during
// internalization.
ODRect rect = __get_boundingRect(ev);
__set_boundingRect(ev, &rect);
}
SOM_Scope void SOMLINK ContentFrameWriteContentsToFrameList(ContentFrame *somSelf,
Environment *ev,
ODStorageUnit* toSU,
BCTransferKind writeKind,
BCCloneInfo* cloneInfo,
ODID frameID)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrameWriteContentsToFrameList");
// First, store the current storage unit position.
ODStorageUnitCursor *saveCursor = toSU->CreateCursorWithFocus(ev);
ODULong saveOffset = toSU->GetOffset(ev);
// Move to the end of the kODFrameList value.
toSU->FocusWithCursor(ev, cloneInfo->frameListInfo->cursor);
toSU->SetOffset(ev, toSU->GetSize(ev));
// Calculate the bounding box to write into kODFrameList for this frame.
ODRect bbox = __get_boundingRect(ev);
#ifdef _PLATFORM_OS2_
// The bounding box must be defined assuming top-left origin coordinates.
somSelf->ChangeRectBias(ev, &bbox);
#endif
// Normalize it to aggregate bounding box coordinates.
bbox.Offset(-(cloneInfo->frameListInfo->offset.x),
-(cloneInfo->frameListInfo->offset.y));
// Store the bounding box and a strong reference to the frame.
ODSetRectProp(ev, toSU, kODNULL, kODNULL, &bbox);
ODSetStrongSURefProp (ev, toSU, kODNULL, kODNULL, frameID);
// Restore the focus.
toSU->FocusWithCursor(ev, saveCursor);
toSU->SetOffset(ev, saveOffset);
saveCursor->somFree();
}
SOM_Scope void SOMLINK ContentFrameReadContents(ContentFrame *somSelf,
Environment *ev,
ODStorageUnit* fromSU,
BCTransferKind readKind,
BCCloneInfo* cloneInfo)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrameReadContents");
ODDraft *fromDraft = fromSU->GetDraft(ev);
TempODPart tPart = kODNULL;
ODDraft *toDraft = kODNULL;
ODStorageUnitRef aSURef;
ODFrame *embeddedFrame;
ODID id;
ODMatrix m;
ODRect bbox;
if (_myFrame)
tPart = _myFrame->AcquirePart(ev);
else
tPart = cloneInfo->myFrame->AcquirePart(ev);
toDraft = tPart->GetStorageUnit(ev)->GetDraft(ev);
if(!cloneInfo->frameListInfo) { // Read from kODPropEmbeddedFrames
// Call parent.
ContentFrame_parent_ContentObject_ReadContents(somSelf,
ev,
fromSU,
readKind,
cloneInfo);
// Read in the frame ID.
id = ODGetStrongSURefProp (ev, fromSU, kODNULL, kODNULL);
// Read in the matrix of the external transform
ODGetMatrixProp (ev, fromSU, kODNULL, kODNULL, &m);
} else { // Read from kODFrameList
// Read in the bounding box.
ODGetRectProp(ev, fromSU, kODNULL, kODNULL, &bbox);
// Read in the frame ID.
id = ODGetStrongSURefProp (ev, fromSU, kODNULL, kODNULL);
}
if (id != kODNULLID) {
if (readKind == INTERNALIZE)
_myFrame = fromDraft->AcquireFrame(ev, id);
else {
ODID frameID = fromDraft ->Clone (ev, cloneInfo->key, id, 0,0);
_myFrame = toDraft->AcquireFrame (ev, frameID);
}
if (cloneInfo->myFrame)
{
if (readKind != INTERNALIZE)
__set_containingFrame (ev, cloneInfo->myFrame);
else
{
TempODFrame f = _myFrame->AcquireContainingFrame (ev);
if (f != cloneInfo->myFrame)
{
__set_containingFrame (ev, cloneInfo->myFrame);
PRINT ("** Setting parent in INTERNALIZE\n");
}
}
} // end if setting containing frame
} // end if id
// Create external transform
ODTransform *embedTransform = _myFrame->CreateTransform (ev);
if(!cloneInfo->frameListInfo) {
// Use the information read from the kODPropEmbeddedFrames property
embedTransform->SetMatrix (ev, &m);
#ifdef _PLATFORM_OS2_
// Undo the transformation done in WriteContents
somSelf->ChangeTransformBias(ev, embedTransform);
#endif
// Take care of CLONE_SELECTED case
if (cloneInfo->refPoint) {
embedTransform->MoveBy (ev, cloneInfo->refPoint);
}
} else {
// Use the information read from the kODFrameList kind.
ODPoint refPoint;
if (cloneInfo->refPoint) {
// Place the frame according to where the mouse click occurred.
refPoint = *(cloneInfo->refPoint);
#ifdef _PLATFORM_OS2_
// The following calculations assume all points are defined
// in top-left origin coordinates.
somSelf->ChangePointBias(ev, &refPoint);
#endif
} else {
// Place the frame in the same place it was in the source document.
refPoint = cloneInfo->frameListInfo->offset;
}
bbox.Offset(refPoint);
ODPoint frameOffset = bbox.TopLeft();
embedTransform->SetOffset(ev, &frameOffset);
#ifdef _PLATFORM_OS2_
// Change to bottom-left origin coordinates.
somSelf->ChangeTransformBias(ev, embedTransform);
#endif
}
// Create facet
TempODShape embedShape = _myFrame-> AcquireFrameShape (ev, kODNULL);
ODFacet *containerFacet = FirstFacet (ev, cloneInfo->myFrame);
ODFacet *embedFacet = containerFacet->CreateEmbeddedFacet (ev,
_myFrame, embedShape, embedTransform,
kODNULL, kODNULL, kODNULL, kODFrameInFront);
embedFacet->Invalidate (ev, kODNULL, kODNULL);
}
SOM_Scope void SOMLINK ContentFrameDeleteContents(ContentFrame *somSelf,
Environment *ev,
ODULong type)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrameDeleteContents");
ContentFrame_parent_ContentObject_DeleteContents(somSelf,
ev,
type);
switch (type) {
case FRAME_REMOVED:
// set containing frame to NULL so that all of its open
// windows get closed
_myFrame->SetContainingFrame (ev, kODNULL);
_myFrame->Remove(ev);
break;
case FRAME_CLOSED:
_myFrame->Close(ev);
break;
case OBJECT_DELETED:
{
ODFacet* theFacet = kODNULL;
ODFrameFacetIterator* facets = kODNULL;
ALinkedList *children = kODNULL;
facets = _myFrame->CreateFacetIterator(ev);
children = new ALinkedList();
for (theFacet = (ODFacet*)facets->First(ev);
facets && facets->IsNotComplete(ev);
theFacet = (ODFacet*)facets->Next(ev))
children->AddLast (ev, theFacet);
for (ALink *link = children->First(ev);
link->Content(ev); link = link->Next(ev))
{
ODFacet *childFacet = (ODFacet *) link->Content(ev);
childFacet->GetContainingFacet(ev)->RemoveFacet(ev,childFacet);
delete childFacet;
}
delete facets;
delete children;
_myFrame->SetContainingFrame (ev, kODNULL);
_myFrame->Remove(ev);
}
break;
case OBJECT_DRAGGED:
{
ODFacet* theFacet = kODNULL;
ODFrameFacetIterator* facets = kODNULL;
ALinkedList *children = kODNULL;
ODBoolean isInLimbo = _myFrame->IsInLimbo(ev);
TempODFrame parentFrame = _myFrame->AcquireContainingFrame(ev);
facets = _myFrame->CreateFacetIterator(ev);
children = new ALinkedList();
// this code executes in drag source after the part is at drop side
// if frame is not in limbo then a new frame was created at the destination
// else it was simply reparented. In later case, remove facets that belonged
// to the source frame
for (theFacet = (ODFacet*)facets->First(ev);
facets && facets->IsNotComplete(ev);
theFacet = (ODFacet*)facets->Next(ev))
{
if (isInLimbo)
children->AddLast (ev, theFacet);
else
{
if (theFacet->GetContainingFacet(ev)->GetFrame(ev) != parentFrame)
children->AddLast (ev, theFacet);
else
PRINT("**** Skipping %lx\n", theFacet);
}
}
for (ALink *link = children->First(ev);
link->Content(ev); link = link->Next(ev))
{
ODFacet *childFacet = (ODFacet *) link->Content(ev);
childFacet->GetContainingFacet(ev)->RemoveFacet(ev,childFacet);
delete childFacet;
}
delete facets;
delete children;
if (isInLimbo)
{
_myFrame->SetContainingFrame(ev, kODNULL);
_myFrame->Remove(ev);
PRINT("**** Deleting the frame\n");
}
else
{
_myFrame->Release(ev);
PRINT("**** Releasing the frame, someone has it\n");
}
}
break;
}
_myFrame = 0;
}
SOM_Scope void SOMLINK ContentFrameMoveBy(ContentFrame *somSelf,
Environment *ev,
ODPoint* offset)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrameMoveBy");
ContentFrame_parent_ContentObject_MoveBy(somSelf,
ev,
offset);
ODFrameFacetIterator *ffitr = _myFrame->CreateFacetIterator(ev);
ODFacet *facet;
for (facet = (ODFacet *)ffitr->First(ev);
ffitr->IsNotComplete(ev);
facet = (ODFacet *)ffitr->Next(ev))
{
TempODTransform tf = facet->AcquireExternalTransform(ev, kODNULL);
TempODTransform ft = tf->Copy(ev);
ft->MoveBy(ev, offset);
facet->ChangeGeometry (ev, kODNULL, ft, kODNULL);
facet->Invalidate(ev,kODNULL,kODNULL);
}
delete ffitr;
}
SOM_Scope void SOMLINK ContentFrameResize(ContentFrame *somSelf,
Environment *ev,
ODPoint* endPt,
ODULong resizeFlags)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrameResize");
ContentFrame_parent_ContentObject_Resize(somSelf, ev, endPt, resizeFlags);
// Get new and old bounding box and find scaling factor
ODRect rect, oldRect;
rect = oldRect = somSelf->_get_boundingRect (ev);
ComputeRectAfterResize (&rect, resizeFlags, endPt);
ODPoint scalePt;
scalePt.x = ODFixedDivide (abs (rect.right-rect.left), abs (oldRect.right-oldRect.left));
scalePt.y = ODFixedDivide (abs (rect.bottom-rect.top), abs (oldRect.bottom-oldRect.top));
// scale the existing shape with the scaling factor
TempODShape frameShape = _myFrame->AcquireFrameShape (ev, kODNULL);
ODRect frameRect;
frameShape->GetBoundingBox (ev, &frameRect);
frameRect.right = frameRect.left +
ODFixedMultiply (scalePt.x, abs (frameRect.right-frameRect.left));
#if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
frameRect.bottom = frameRect.top +
ODFixedMultiply (scalePt.y, abs (frameRect.bottom-frameRect.top));
#elif defined(_PLATFORM_OS2_)
frameRect.top = frameRect.bottom +
ODFixedMultiply (scalePt.y, abs (frameRect.top-frameRect.bottom));
#endif
// change frame shape with new shape
ODShape* newShape = _myFrame->CreateShape(ev);
newShape->SetRectangle (ev, &frameRect);
_myFrame->ChangeFrameShape(ev, newShape, kODNULL);
// If the part engaged in frame negotiation in its FrameShapeChanged,
// the frame shape may be different than what we just requested. In that
// case, the containing part's RequestFrameShape would have taken care of
// updating the transform, the active shape and of invalidating the facet.
TempODShape finalFrameShape = _myFrame->AcquireFrameShape (ev, kODNULL);
if(!newShape->IsSameAs(ev, finalFrameShape)){
return;
}
// find the offset for new transform
ODPoint delta;
delta.x = rect.left - oldRect.left;
#if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
delta.y = rect.top - oldRect.top;
#elif defined(_PLATFORM_OS2_)
delta.y = rect.bottom - oldRect.bottom;
#endif
// change facet's geometry with new shape and transform
ODFacet *theFacet = kODNULL;
ODFrameFacetIterator* ffitr = _myFrame->CreateFacetIterator(ev);
for (theFacet = (ODFacet *)ffitr->First(ev);
ffitr->IsNotComplete(ev);
theFacet = (ODFacet *)ffitr->Next(ev))
{
TempODShape facetShape = newShape->Copy (ev);
TempODTransform newTr = kODNULL;
if (delta.x || delta.y)
{
TempODTransform extTr = theFacet->AcquireExternalTransform (ev, kODNULL);
newTr = extTr->Copy(ev);
newTr->MoveBy (ev, &delta);
}
// notify facet that its shape changed
theFacet->ChangeGeometry (ev, facetShape, newTr, kODNULL);
theFacet->Invalidate(ev, kODNULL, kODNULL);
}
delete ffitr;
}
SOM_Scope void SOMLINK ContentFrameMoveToFront(ContentFrame *somSelf,
Environment *ev)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrameMoveToFront");
ODFrameFacetIterator* ffitr = kODNULL;
ODFacet* theFacet = kODNULL;
// Iterate over SelectedFrames and raise all facets to front
ffitr = _myFrame->CreateFacetIterator(ev);
// Iterate over each facet of the selected frame
for (theFacet = (ODFacet *)ffitr->First(ev);
ffitr->IsNotComplete(ev);
theFacet = (ODFacet *)ffitr->Next(ev))
theFacet->GetContainingFacet(ev)->MoveBefore(ev,theFacet,kODNULL);
delete ffitr;
_myFrame->Invalidate (ev, kODNULL, kODNULL);
}
SOM_Scope void SOMLINK ContentFrameMoveToBack(ContentFrame *somSelf,
Environment *ev)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrameMoveToBack");
ODFrameFacetIterator* ffitr = kODNULL;
ODFacet* theFacet = kODNULL;
// Iterate over SelectedFrames and raise all facets to front
ffitr = _myFrame->CreateFacetIterator(ev);
// Iterate over each facet of the selected frame
for (theFacet = (ODFacet *)ffitr->First(ev);
ffitr->IsNotComplete(ev);
theFacet = (ODFacet *)ffitr->Next(ev))
theFacet->GetContainingFacet(ev)->MoveBehind(ev,theFacet,kODNULL);
delete ffitr;
_myFrame->Invalidate (ev, kODNULL, kODNULL);
}
SOM_Scope ODTransform* SOMLINK ContentFrame_get_extTransform (ContentFrame *somSelf,
Environment *ev)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrame_get_extTransform");
ODFacet *myFacet = FirstFacet (ev, _myFrame);
if (myFacet) {
TempODTransform xform = myFacet->AcquireExternalTransform (ev, kODNULL);
return xform;
} else
return ContentFrame_parent_ContentObject__get_extTransform(somSelf, ev);
}
SOM_Scope void SOMLINK ContentFrameSetExtTransform (ContentFrame *somSelf,
Environment *ev, ODTransform *extTransform)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrameSetExtTransform");
ODFrameFacetIterator *ffitr = _myFrame->CreateFacetIterator(ev);
ODFacet *facet;
for (facet = (ODFacet *)ffitr->First(ev);
ffitr->IsNotComplete(ev);
facet = (ODFacet *)ffitr->Next(ev))
{
TempODTransform ft = extTransform->Copy(ev);
facet->ChangeGeometry (ev, kODNULL, ft, kODNULL);
facet->Invalidate(ev,kODNULL,kODNULL);
}
delete ffitr;
ContentFrame_parent_ContentObject_SetExtTransform(somSelf, ev, extTransform);
}
SOM_Scope void SOMLINK ContentFrameChangeExtTransform (ContentFrame *somSelf,
Environment *ev, ODTransform *xform, ODULong xformFlags)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrameChangeExtTransform");
ODFrameFacetIterator *ffitr = _myFrame->CreateFacetIterator(ev);
ODFacet *facet;
for (facet = (ODFacet *)ffitr->First(ev);
ffitr->IsNotComplete(ev);
facet = (ODFacet *)ffitr->Next(ev))
{
TempODTransform tf = facet->AcquireExternalTransform(ev, kODNULL);
TempODTransform ft = tf->Copy(ev);
switch (xformFlags) {
case EXTXFORM_REPLACE:
ft->CopyFrom (ev, xform);
break;
case EXTXFORM_PRECOMPOSE:
ft->PreCompose (ev, xform);
break;
case EXTXFORM_POSTCOMPOSE:
ft->PostCompose (ev, xform);
break;
default:
break;
} /* endswitch */
facet->ChangeGeometry (ev, kODNULL, ft, kODNULL);
facet->Invalidate(ev,kODNULL,kODNULL);
}
delete ffitr;
ContentFrame_parent_ContentObject_ChangeExtTransform(somSelf, ev, xform, xformFlags);
}
SOM_Scope ContentObject* SOMLINK ContentFrameCreateNewView (ContentFrame *somSelf,
Environment *ev, ODFrame *viewFrame)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrameCreateNewView");
TempODPart embeddedPart = _myFrame->AcquirePart(ev);
TempODShape embShape = _myFrame->AcquireFrameShape (ev, kODNULL);
TempODShape newShape = embShape->Copy (ev);
ODStorageUnit *su = embeddedPart->GetStorageUnit(ev);
ODFrame* newFrame = su->GetDraft(ev)->CreateFrame(ev,
(viewFrame->GetStorageUnit(ev)) ? kODFrameObject :
kODNonPersistentFrameObject,
viewFrame, newShape,
(ODCanvas*)kODNULL, // biasCanvas
embeddedPart,
su->GetSession(ev)->Tokenize(ev, kODViewAsFrame),
su->GetSession(ev)->Tokenize(ev, kODPresDefault),
kODFalse, _myFrame->IsOverlaid(ev));
// attach a source frame
embeddedPart->AttachSourceFrame(ev, newFrame, _myFrame);
ContentFrame *contFrame = new ContentFrame();
contFrame->_set_myFrame(ev, newFrame);
ODFacet *myFacet = FirstFacet (ev, _myFrame);
if (myFacet) {
TempODTransform xform = myFacet->AcquireExternalTransform (ev, kODNULL);
contFrame->SetExtTransform (ev, xform);
}
return (ContentObject *) contFrame;
}
//-----------------------------------------------------------------------------
// ContentFrame->GetHeight
//
// Determines the height of this ContentFrame without the need for a
// facet to be present.
//-----------------------------------------------------------------------------
SOM_Scope ODULong SOMLINK ContentFrameGetHeight (ContentFrame *somSelf,
Environment *ev)
{
ContentFrameData *somThis = ContentFrameGetData(somSelf);
ContentFrameMethodDebug("ContentFrame","ContentFrameGetHeight");
// Get the bounding rectangle of this ContentFrame.
TempODShape frameShape = _myFrame->AcquireFrameShape(ev, kODNULL);
ODRect frameRect;
frameShape->GetBoundingBox (ev, &frameRect);
// Determine the height of this object.
return abs(frameRect.top - frameRect.bottom);
}