home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
odtlktv4.zip
/
ODTLKT
/
TOOLKIT
/
BETA
/
SAMPLES
/
OPENDOC
/
PARTS
/
CNTNRPRT
/
CNTNRPRT.CPP
< prev
next >
Wrap
Text File
|
1995-12-13
|
295KB
|
7,949 lines
/*
* This file was generated by the SOM Compiler.
* Generated using:
* SOM incremental update: 2.41
*/
/*
* File: CntnrPrt.cpp
*
* Contains: IDL description of Container Part
*
* Written by: The OpenDoc Development Team
*
* Copyright: (c) 1994 by IBM Corp., all rights reserved.
*
* Change History (most recent first):
*
* 146974 12/12/95 ced Rework to fix Open As Window
* 146357 12/11/95 ced Validation changes
* 146397 12/10/95 st Fix for details view with no embeds (inf loop)
* 145808 12/07/95 jso Fix for extra page when printing
* 145816 12/06/95 aht Update Send method of message interface for DR4 parm change
* 145698 12/06/95 BLG Container view display returns TRUE.
* 132158 12/05/95 ced Normalize frame shape to zero offset in RequestFrameShape
* 126751 12/04/95 faa Avoid bundling when scaling to zero
* 142961 12/03/95 aml Imaging operations performance improvement in ClipEmbeddedFacets
* 145687 12/02/95 jso Fix externalize for saved embedded frames
* 145672 12/02/95 st caused regr with icon/tree/details view
* 144010 11/28/95 st Adjust menus for show as when root part vs embedded part
* 144742 11/28/95 ced Use containing frame when requesting status line focus in
* HandleButton1DownInEmbeddedFrame
* 144299 11/28/95 jso Added document name to print job
* 144010 11/27/95 st AdjustMenus/HandleMenuEvent for DOC_OPENAS items
* 137691 11/25/95 ced Get rid of common.hpp & use AltPoint classes for ODPoint & ODRect.
* Fix up exception handling.
* 144744 11/22/95 ced Remove unnessecary frame->SetPartInfo calls
* 144532 11/21/95 ced Fix internalization/externalization, change type of BGColor to long
* 144408 11/21/95 aml Update AdjustMenus: enable Paste submenu instead of Paste items
* 140231 11/20/95 aht Initialize AEDesc's before using them.
* 143870 11/18/95 st Use WinMessageBox for implementing HELP menu items
* 142798 11/18/95 ced Fix some printing bugs. Use existing root frame for printing
* if it has no facets. Remove proxy for frame being closed in
* DisplayFrameClosed.
* 143654 11/13/95 ced Apple DR4 IDL changes; ODObject::IsInitialized() removed,
* param added to ODWindowState::RegisterWindow.
* 143568 11/10/95 st remove dead code
* 133692 11/03/95 ced Fix bug causing trap when ESC out of scale or rotate
* 142637 11/02/95 ced Fix some ref-counting bugs
* 140007 10/31/95 aml Use new DragDrop and Clipboard APIs
* 141717 10/27/95 BLG Container releases statusline focus when deleted.
* 141477 10/26/95 jso Check rc for WinLoadString in categoryDisplayName
* 139790 10/11/95 aml Fix refcounting bug in BeginPrinting
* 139395 10/06/95 blg Have Container part release statusline focus on request.
* 139092 10/03/95 st Changes for new menus
* 137664 09/21/95 aml Some API changes for ODShape, ODTransform
* 123247 09/21/95 jso Added partCategoryUserString
* 137097 09/15/95 aml Added code for DisplayFrameConnected
* 137002 09/15/95 jso Added GetBGColor method for notebook to call
* 128682 09/14/95 faa Implement cut/copy/paste functions
* 134597 9/27/95 ced Remove content drawing on another thread for now
* 131406 8/16/95 st separate MRI into its own DLL
* 131094 08/14/95 faa When Container focus is lost, selected items remain
* selected and show again when focus is regained
* 127685 08/08/95 map Content drawing is on another thread
* 128683 07/25/95 faa Implement select all/deselect all function
* 130872 07/25/95 st Excetp. 22 with context menu and selected part that has no menu ext.
* 123248 07/21/95 BLG Get part display name and category from .rc file
* 129449 07/21/95 st only pass selected menu commands to selected part
* 127858 07/20/95 aht Add scripting support: change background color via osa event
* 130083 07/19/95 BLG Use menubar methods to store statusline text
* for menu items. The docshell will handle displaying it.
* 126008 07/17/95 faa Changed lines on FocustLost to remove code
* that deselected a part when focus was lost
* 124806 07/13/95 aml Changed MotionEnd to leave the embedded frame shape unchanged for
* illegal resizing operations (dragging a corner of the selection
* border past its opposite edges)
* 120365 07/12/95 map Fix up #define INCL for OD.H
* 129011 07/12/95 aml Fixed CloneInto to properly store embedded frames data
* 128305 07/07/95 st put samples of adding to popup menus
* 128494 07/06/95 ced check ODWindow ptr not null before dereferencing.
* 127387 06/26/95 ced code for possibility that status line extension is not
* available.
* 126859 06/24/95 st more menu code-adjusting popup/selected phase I
* 117197 06/21/95 BLG open from file in same position/properties as was saved
* 125708 06/20/95 st Change to AddDefaultMenuItemBefore
* 126017 06/19/95 pfe Fixed breaks in printing/part window
* 125718 06/16/95 pfe Fixed OpenAsWindow breaks
* 125697 06/14/95 ced Use new support for kODNULL invalidShape when updating
* embedded facets in Draw method.
* 124864 06/14/95 ced Fix divide by zero bug when scaling embedded facets.
* 124235 06/12/95 ced Clip single selection handles from embedded facets. Draw
* selection border after updating embedded frames.
* 124689 06/12/95 ced Fix trap in start drag with no selection.
* 124927 06/10/95 st MB1 over part with viewtype not frame should select it
* 124283 06/07/95 BLG remove dependency of help panels on menu id's
* 124281 06/06/95 BLG Changes in StatusLine - need Statusline focus to display
* text, have to pass Frame ptr to SetStatusLineText.
* 124667 06/06/95 st Menus and multiple selection
* 108305 06/05/95 aml Invalidate selection border when a frame shape changes.
* 124243 06/05/95 aml Introduce the FacetInfoRec structure for container facets
* to be used with GetPartInfo and SetPartInfo methods
* 124328 06/03/95 st fixes for view extension types/classes
* 124293 06/03/95 st menu code in HandleButton1ClickInBorder causes SOM trap
* 124371 06/02/95 ced Rework selection, scaling & rotation of embedded frames,
* improve performance of InvertDragHighlight with non-linear
* frame transforms.
* 123945 05/31/95 pfe OpenAsWindow fixes and changes
* 122740 05/26/95 st get selected part's menu over and over and over.....
* 123386 05/24/95 ced use window clip region to clip selection border from
* embedded parts. Add support for scaling embedded frames.
* 123239 05/23/95 jv added Tree/Icon/Details views
* 122741 05/23/95 st wrong frame* passed to selected part
* 123149 05/22/95 ced Add support for multiple selection of embedded frames
* 122943 05/21/95 map Method name changes for multi-threading
* 122707 05/18/95 BLG Implement example of part doing Undo/Redo
* 121968 05/15/95 ced Use RegisterWindowForFrame when opening a root frame
* 122322 05/15/95 st added popup/accelerator support
* 122244 05/13/95 rlt added DevCon7 changes (grid enable/disable & view type supp)
* 121968 05/12/95 ced fix drop target location bug
* 121161 05/10/95 aml some optimization for container part drawing:
* clip out embedded facets; embedded facets clip
* shape fix; remove unnecessary code in GeometryChanged
* 121073 05/03/95 map changed includes of xih to xh for OD UI classes
* 119388 04/29/95 st new menu code
* 119548 04/25/95 jso removed private byte array/storage functions
* 120017 04/22/95 ced Move storage utils to common header file.
* 119471 04/18/95 pfe added support for OpenAsWindow
* 119447 04/18/95 ced Add ODPlatformPrintJob setup
* 117472 04/17/95 ced Create root frame for facet to be printed.
* 118227 04/10/95 pfe changed HandleMouseDownInEmbeddedFrame to activate window
* 117544 04/03/95 map replaced true/false with kODTrue/kODFalse
* 117472 04/01/95 ced Add printing (without dialogs)
*
* <5> 01/16/95 jso b1c7 port
*
* <4> 12/08/94 rlt Changed su->focus to use property/value instead of
* using index
* <3> 11/05/94 ced Modifications required because root facet
* external transform now scales from OpenDoc
* 72 dpi coordinate space to device coordinate
* space. Changes are labed with (CED - 110594).
* <2> 10/7/94 ced Added example code for using mouse focus
* to draw rubber-band tracking rectangle.
* <1> 7/6/94 jlc first checked in
*
* To Do:
*
* Copyright: (c) 1993-1994 by IBM Corp., all rights reserved.
*
*/
/*
* This file was generated by the SOM Compiler and Emitter Framework.
* Generated using:
* SOM Emitter emitxtm: 2.41
*/
#ifndef _ALTPOINT_
#include "AltPoint.h"
#endif
#ifndef _ALTPOLY_
#include "AltPoly.h"
#endif
#ifndef _EXCEPT_
#include "Except.h"
#endif
#ifndef SOM_Module_cntnrprt_Source
#define SOM_Module_cntnrprt_Source
#endif
#define ContainerPart_Class_Source
#define VARIABLE_MACROS
#define INCL_DOSMODULEMGR
#define INCL_DOSPROCESS // [127685]
#define INCL_DOSRESOURCES
#define INCL_GPIBITMAPS
#define INCL_GPICONTROL
#define INCL_GPIDEFAULTS // [127685]
#define INCL_GPIPRIMITIVES
#define INCL_GPIREGIONS
#define INCL_GPIPOLYGON
#define INCL_GPITRANSFORMS
#define INCL_GPIPATHS
#define INCL_WINACCELERATORS
#define INCL_WINFRAMEMGR
#define INCL_WININPUT
#define INCL_WINMENUS
#define INCL_WINMESSAGEMGR
#define INCL_WINPOINTERS
#define INCL_WINSTDDLGS
#define INCL_WINDIALOGS
#define INCL_WINSTDDRAG
#define INCL_WINTRACKRECT
#define INCL_WINWINDOWMGR
#define INCL_WINSHELLDATA
#define INCL_DEV
#define INCL_WINSYS
#define INCL_SPL
#define INCL_SPLDOSPRINT
#define INCL_ODAPI
#define INCL_ODARBITRATOR
#define INCL_ODCANVAS
#define INCL_ODCLIPBOARD
#define INCL_ODDRAGANDDROP
#define INCL_ODDRAFT
#define INCL_ODERRORS
#define INCL_ODFACET
#define INCL_ODFOCUSSET
#define INCL_ODFRAME
#define INCL_ODINFO
#define INCL_ODPARTHANDLERINFO
#define INCL_ODPARTHANDLERREGISTRY
#define INCL_ODREGISTERMANAGER
#define INCL_ODSESSION
#define INCL_OSAAPI //@143928
#define INCL_OSA //@127858
#define INCL_ODOSA //@127858
#define INCL_ODSHAPE
#define INCL_ODSTORAGEUNIT
#define INCL_ODTRANSFORM
#define INCL_ODUI
#define INCL_ODUNDO
#define INCL_ODWINDOW
#define INCL_ODWINDOWSTATE
#define INCL_ODDOCUMENT
#define INCL_ODCONTAINER //[144299]
#include <os2.h>
#include <math.h>
#include "cntnrprt.xih"
#include <CNNotebk.xh>
#ifndef _FOCUSLIB_
#include "focuslib.h"
#endif
#ifndef _TEMPOBJ_
#include "TempObj.h"
#endif
#ifndef _WINUTILS_
#include "winutils.h"
#endif
#ifndef _STDTYPIO_
#include "stdtypio.h"
#endif
#ifndef _ODDEBUG_
#include "ODDebug.h"
#endif
#ifndef _ODUTILS_
#include "ODUtils.h"
#endif
#ifndef _ODMATH_
#include "ODMath.h"
#endif
#ifndef SOM_XEmbeddedFramesIterator_xh
#include <XFrmIter.xh>
#endif
#ifndef _ORDCOLL_
#include "OrdColl.h"
#endif
#define USE_PARTINFO_TO_RECALL_AMENU
#define ODUnused(s) s
#include "debug.hpp"
#include "cntnrprt.h"
#include "partinfo.h"
#include "cntnrhlp.h" // 124283
#include "cntnrprp.h" //@127858
#define THISDLL "cntmri"
static const ODPropertyName kPropEmbeddedFrames = "+//ISO 9070/ANSI::113722::US::CI LABS::IBM:ContainerPart:Property:EmbeddedFrames";
static const ODPropertyName kPropBGColor = "+//ISO 9070/ANSI::113722::US::CI LABS::IBM:ContainerPart:Property:BackgroundColor";
// SetBGColorRec is used for Undo/Redo.
struct SetBGColorRec
{
SetBGColorRec(long oldColor, long newColor, ODFrame* frame)
{_fOldColor = oldColor; _fNewColor = newColor;
_fFrame = frame;}
long _fOldColor;
long _fNewColor;
ODFrame* _fFrame;
};
#ifndef _CNTMRI_
#include "cntmri.h"
#endif
const double pi = 3.14159265358979;
const int YGRID = 72;
const int XGRID = 72;
const ULONG SLEEPTIME = 50; // [127685]
const ODSLong kODBorderWidth = MAKEFIXED(1,0);
const ODSLong kODBorderHandleWidth = MAKEFIXED(8, 0);
const ODSLong kODHandleLenMultiplier = 1;
const ODSLong kSelectionHandleWidth = MAKEFIXED(6,0);
MATRIXLF mtxIdentity = { 0x10000, 0, 0, 0, 0x10000, 0, 0, 0, 1};
static const ODPropertyName kPropFrameInfo = "+//ISO 9070/ANSI::113722::US::CI LABS::IBM:ContainerPart:Property:FrameInfo";
static const ODPropertyName kPropMouseDownOffset = "+//ISO 9070/ANSI::113722::US::CI LABS::IBM:ContainerPart:Property:MouseDownOffset";
#define kKindTestContainer "+//ISO 9070/ANSI::113722::US::CI LABS::IBM:Kind:TestContainer"
static const ODValueType kFrameRef = "+//ISO 9070/ANSI::113722::US::CI LABS::IBM:ContainerPart:Type:FrameReference";
// registration types
// 123248 const ODType kContainerPartKindDisplayName = "Container Part Kind";
const ODType kPartHandlerName = "ContainerPart";
// 123248 const ODType kContainerPartCategory = "Test Container";
struct Proxy : public ODxOrderedCollection {
ODTransform* transform;
ODShape* shape;
ODPart* part;
ODBoolean settingFrameShapes;
Proxy(ODTransform* t, ODShape* s, ODPart* p) {
transform = t; shape = s; part = p;
settingFrameShapes = kODFalse;
}
};
/*
* The FacetClip struct is used to save the clip shapes of embedded facets
* when we modify the original clip shape to clip out sizing handles of the
* selected part. We do this so that we can restore the original
* clip shape when the selection is changed without having to recalculate
* the clipping of all our embedded facets. Pointers to FacetClip structs
* for facet's who's clip shapes we're saving are kept in the
* _fSavedFacetClipShapes collection.
*/
struct FacetClip {
ODFacet* facet;
ODShape* clip;
};
#include <stdio.h>
//------------------------------------------------------------------------------
// Ñ PRINTING Ñ PRINTING Ñ PRINTING Ñ PRINTING Ñ PRINTING Ñ PRINTING Ñ PRINTING
//------------------------------------------------------------------------------
struct PRNINFO {
HDC hdc;
HPS hps;
PHCINFO phcInfo;
PRINTDEST printDest;
ODRect bounds;
};
typedef PRNINFO* PPRNINFO;
#define PRINT_QUEUE_LENGTH 100
#define QUEUENAME_LENGTH 10
#define DRIVERNAME_LENGTH 125
#define LEN_WORKSTRING 256
#define LEN_TITLE 256
#define ulmm2fxPt(mm) ((ODCoordinate)(((float)(mm) / 25.4) * 72 * 65536));
#define PtInRect(pt, rect) (pt.x >= rect.left && \
pt.x < rect.right && \
pt.y >= rect.bottom && \
pt.y < rect.top)
ODUShort DetermineNumberOfPagesinDoc(Environment* ev, ODFrame* frame, ODRect page);
MRESULT EXPENTRY CntnrPartInfoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
VOID SetSysMenu(HWND hDlg);
// The following properties are defined for View->Details handling. It is just a TEST.
// You can find the same #defines in cntnrprt.cpp as well.
static const ODPropertyName kSimplePartAddProps = "SimplePart:Property:AddProps";
const ODType kSimplePartAddProp1 = "Test AddProp1";
const ODType kSimplePartAddProp2 = "Test AddProp2";
const ODType kSimplePartAddProp3 = "Test AddProp3";
const ODType kSimplePartAddProp4 = "Test AddProp4";
const ODType kSimplePartKind = "IBM:Kind:SimplePart";
ODBoolean Test_AddDetailsColumns(ContainerPart *somSelf, Environment *ev,
ODViewExtension *ViewExt);
ODType GetPartKind(ODPart* part);
//@127858 begin
void GetDirectParam(ODSession* session, OSAEvent* message, AEDesc* evtDp);
void CreatePropObjSpec(ContainerPart* somSelf, Environment* ev, ODFrame* frame,
DescType form, DescType prop, AEDesc& objSpec);
void SendSetDataEvent(ContainerPart *somSelf, Environment* ev, AEDesc& objSpec, AEDesc& data);
static ODError APIENTRY GetPropertyFromNULL( ODPart* part,
DescType desiredClass,
ODOSLToken* container,
DescType containerClass,
DescType form,
ODDesc* selectionData,
ODOSLToken* value,
ODSLong refCon);
static ODError APIENTRY HandleSetData(ODPart* part,
ODOSAEvent* message,
ODOSAEvent* reply,
ODSLong handlerRefcon);
static ODError APIENTRY HandleGetData(ODPart* part,
ODOSAEvent* message,
ODOSAEvent* reply,
ODSLong handlerRefcon);
//@127858 end
//==============================================================================
// Non Som functions for colors
//==============================================================================
long ColorIndexFromMenuColor( ODUShort whichColor )
{
switch (whichColor)
{
case IDMA_COLOR_GRAY : return CLR_DARKGRAY ; break;
case IDMA_COLOR_RED : return CLR_RED ; break;
case IDMA_COLOR_GREEN : return CLR_GREEN ; break;
case IDMA_COLOR_YELLOW : return CLR_YELLOW ; break;
case IDMA_COLOR_BLUE : return CLR_BLUE ; break;
case IDMA_COLOR_MAGENTA: return CLR_DARKPINK ; break;
case IDMA_COLOR_CYAN : return CLR_CYAN ; break;
case IDMA_COLOR_WHITE : return CLR_WHITE ; break;
default: break;
}
return CLR_PINK;
}
ODUShort MenuColorFromColorIndex( long inColor )
{
switch (inColor)
{
case CLR_DARKGRAY : return IDMA_COLOR_GRAY ; break;
case CLR_RED : return IDMA_COLOR_RED ; break;
case CLR_GREEN : return IDMA_COLOR_GREEN ; break;
case CLR_YELLOW : return IDMA_COLOR_YELLOW ; break;
case CLR_BLUE : return IDMA_COLOR_BLUE ; break;
case CLR_DARKPINK : return IDMA_COLOR_MAGENTA; break;
case CLR_CYAN : return IDMA_COLOR_CYAN ; break;
case CLR_WHITE : return IDMA_COLOR_WHITE ; break;
default: break;
}
return IDMA_COLOR_GRAY;
}
/*
* Calculate the angle in radians of the slope dx/dy
* relative to the positive x-axis.
*/
double CalcAngleRadians(double dx, double dy)
{
double theta;
theta = dx ? atan(fabs(dy/dx)) : (asin((dy > 0) ? 1 : -1));
theta = (dx*dy > 0) ? (dx>0 ? theta : theta+pi) :
(dx>0 ? 2.0*pi-theta : pi-theta);
return theta;
}
double CalcAngleRadians(POINTL &ptlRef, POINTL &ptl)
{
return CalcAngleRadians((double)(ptl.x - ptlRef.x),
(double)(ptl.y - ptlRef.y));
}
double CalcAngleRadians(ODPoint &ptRef, ODPoint &pt)
{
return CalcAngleRadians(ODFixedToFloat(pt.x - ptRef.x),
ODFixedToFloat(pt.y - ptRef.y));
}
FIXED CalcAngleDegrees(POINTL &ptlRef, POINTL &ptl)
{
return ODFloatToFixed(CalcAngleRadians(ptlRef, ptl) * 180.0 / pi);
}
FIXED CalcAngleDegrees(ODPoint &ptRef, ODPoint &pt)
{
return ODFloatToFixed(CalcAngleRadians(ptRef, pt) * 180.0 / pi);
}
SOM_Scope ODSemanticInterface* SOMLINK ContainerPartGetSemanticInterface(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartGetSemanticInterface");
return _fSemtIntf;
}
SOM_Scope Proxy* SOMLINK ContainerPartProxyForFrame(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartProxyForFrame");
SOM_TRY
if (_fEmbeddedFrames->Contains(frame))
{
Proxy* p;
ODxOrderedCollectionIterator i(_fContents);
for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
{
ODFrame* testFrame;
ODxOrderedCollectionIterator frames(p);
for (testFrame = (ODFrame*)frames.First();
frames.IsNotComplete();
testFrame = (ODFrame*)frames.Next())
{
if (testFrame == frame)
return p;
}
}
}
else
THROW(kODErrInvalidFrame);
SOM_CATCH_ALL
SOM_ENDTRY
return kODNULL;
}
SOM_Scope ODFrame* SOMLINK ContainerPartFrameFromProxyForContainingFrame(ContainerPart *somSelf,
Environment *ev,
Proxy* proxy,
ODFrame* containingFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartFrameFromProxyForContainingFrame");
SOM_TRY
ODxOrderedCollectionIterator i(proxy);
for (ODFrame* frame = (ODFrame*)i.First();
i.IsNotComplete();
frame = (ODFrame*)i.Next())
{
TempODFrame cntFrame = frame->AcquireContainingFrame(ev);
if (cntFrame == containingFrame)
return frame;
}
SOM_CATCH_ALL
SOM_ENDTRY
return kODNULL;
}
SOM_Scope ODBoolean SOMLINK ContainerPartNormalizeProxyGeometry(ContainerPart *somSelf,
Environment *ev,
Proxy* p)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartNormalizeProxyGeometry");
ODBoolean geometryChanged = kODFalse;
SOM_TRY
ODRect bbox;
ODPoint offset;
p->shape->GetBoundingBox(ev, &bbox);
offset = bbox.BotLeft();
if (offset.x != 0 || offset.y != 0)
{
geometryChanged = kODTrue;
// normalize frame shape and adjust external transform
TempODTransform xform = p->transform->NewTransform(ev);
xform->SetOffset(ev, &offset);
p->transform->PreCompose(ev, xform);
offset.x = -offset.x;
offset.y = -offset.y;
xform->SetOffset(ev, &offset);
p->shape->Transform(ev, xform);
}
SOM_CATCH_ALL
SOM_ENDTRY
return geometryChanged;
}
SOM_Scope void SOMLINK ContainerPartSetProxyFrameShapes(ContainerPart *somSelf,
Environment *ev,
Proxy* p)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartSetProxyFrameShapes");
SOM_TRY
p->settingFrameShapes = kODTrue;
ODxOrderedCollectionIterator i(p);
for (ODFrame* frame = (ODFrame*)i.First();
i.IsNotComplete();
frame = (ODFrame*)i.Next())
{
frame->ChangeFrameShape(ev, p->shape, kODNULL);
}
p->settingFrameShapes = kODFalse;
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartInvalidateProxy(ContainerPart *somSelf,
Environment *ev,
Proxy* proxy)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartInvalidateProxy");
SOM_TRY
ODxOrderedCollectionIterator i(proxy);
for (ODFrame* frame = (ODFrame*)i.First();
i.IsNotComplete();
frame = (ODFrame*)i.Next())
{
frame->Invalidate(ev, kODNULL, kODNULL);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartInvalidate(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartInvalidate");
SOM_TRY
// Invalidate all display frames.
ODxOrderedCollectionIterator i(_fDisplayFrames);
for (ODFrame* frame = (ODFrame*)i.First();
i.IsNotComplete();
frame = (ODFrame*)i.Next())
{
frame->Invalidate(ev, kODNULL, kODNULL);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartRemoveProxyObject(ContainerPart *somSelf,
Environment *ev,
Proxy* p)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerRemoveProxyObject");
while (p->Count())
{
ODFrame* frame = (ODFrame*)p->First();
frame->Invalidate(ev, kODNULL, kODNULL);
ODxOrderedCollection tempFacets;
TempODFrameFacetIterator facets = frame->CreateFacetIterator(ev);
for (ODFacet* f1 = facets->First(ev);
facets->IsNotComplete(ev);
f1 = facets->Next(ev))
{
if ( f1->GetFrame(ev) == frame )
tempFacets.AddLast(f1);
}
ODxOrderedCollectionIterator t(&tempFacets);
for (ODFacet* f2 = (ODFacet*)t.First();
t.IsNotComplete();
f2 = (ODFacet*)t.Next())
{
f2->GetContainingFacet(ev)->RemoveFacet(ev, f2);
ODDeleteObject(f2);
}
// Remove our proxy for the moved frame
somSelf->RemoveEmbeddedFrame(ev, frame);
}
_fContents->Remove(p);
ODReleaseObject(ev, p->transform);
ODReleaseObject(ev, p->shape);
ODReleaseObject(ev, p->part);
delete p;
}
SOM_Scope void SOMLINK ContainerPartCreateProxySelectionBorder(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCreateProxySelectionBorder");
SOM_TRY
_fSelectShape->Reset(ev);
if (_fSelection->Count())
{
ODRect bbox;
ODPoint ptCorners[4];
Proxy* p;
ODxOrderedCollectionIterator iter(_fSelection);
TempODShape tempShape = _fSelectShape->Copy(ev);
for (p = (Proxy*) iter.First(); iter.IsNotComplete(); p = (Proxy*) iter.Next())
{
p->shape->GetBoundingBox(ev, &bbox);
ptCorners[0].x = bbox.left; ptCorners[0].y = bbox.bottom;
ptCorners[1].x = bbox.left; ptCorners[1].y = bbox.top;
ptCorners[2].x = bbox.right; ptCorners[2].y = bbox.top;
ptCorners[3].x = bbox.right; ptCorners[3].y = bbox.bottom;
ODByteArray baPoints;
UseByteArray(&baPoints, ptCorners, 4 * sizeof(ODPoint));
p->transform->TransformPoints(ev, &baPoints, 4);
for (int i=0; i<4; i++)
{
bbox.left = ptCorners[i].x - kSelectionHandleWidth / 2;
bbox.top = ptCorners[i].y + kSelectionHandleWidth / 2;
bbox.right = ptCorners[i].x + kSelectionHandleWidth / 2;
bbox.bottom = ptCorners[i].y - kSelectionHandleWidth / 2;
tempShape->SetRectangle(ev, &bbox);
_fSelectShape->Union(ev, tempShape);
}
}
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartSetFrameSelected(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame,
ODBoolean isSelected)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartSetFrameSelected");
SOM_TRY
TempODFrameFacetIterator facets = frame->CreateFacetIterator(ev);
for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
{
facet->SetSelected(ev, isSelected);
facet->ChangeHighlight(ev, isSelected ? kODFullHighlight : kODNoHighlight);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartFreezeEmbeddedFrames(ContainerPart *somSelf,
Environment *ev,
ODBoolean isFrozen)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartFreezeEmbeddedFrames");
SOM_TRY
ODFrame* frame;
ODxOrderedCollectionIterator i(_fEmbeddedFrames);
for (frame = (ODFrame*) i.First(); i.IsNotComplete(); frame = (ODFrame*) i.Next())
frame->SetFrozen(ev, isFrozen);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartInvalidateSelection(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartInvalidateSelection");
SOM_TRY
if (frame)
frame->Invalidate(ev, kODNULL, kODNULL);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartClipEmbeddedFrames(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartClipEmbeddedFrames");
SOM_TRY
if (frame == kODNULL) // Do all our display frames
{
ODxOrderedCollectionIterator dispFrames(_fDisplayFrames);
for (ODFrame* dispFrame = (ODFrame*)dispFrames.First();
dispFrames.IsNotComplete();
dispFrame = (ODFrame*)dispFrames.Next())
{
TempODFrameFacetIterator facets = dispFrame->CreateFacetIterator(ev);
for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
somSelf->ClipEmbeddedFacets(ev, facet);
}
}
else
{
TempODFrameFacetIterator facets = frame->CreateFacetIterator(ev);
for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
somSelf->ClipEmbeddedFacets(ev, facet);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartClipSelectionFromEmbeddedFrames(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartClipSelectionFromEmbeddedFrames");
SOM_TRY
ODReleaseObject(ev, _fSelectionFrame);
_fSelectionFrame = frame;
_fSelectionFrame->Acquire(ev);
TempODFrameFacetIterator facets = frame->CreateFacetIterator(ev);
for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
somSelf->ClipSelectionFromEmbeddedFacets(ev, facet);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartUnClipSelectionFromEmbeddedFrames(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerUnPartClipSelectionFromEmbeddedFrames");
SOM_TRY
if (frame != _fSelectionFrame)
return;
TempODFrameFacetIterator facets = frame->CreateFacetIterator(ev);
for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
somSelf->UnClipSelectionFromEmbeddedFacets(ev, facet);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartClipSelectionFromEmbeddedFacets(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartClipSelectionFromEmbeddedFacets");
SOM_TRY
if (facet->GetFrame(ev) != _fSelectionFrame)
return;
TempODFrame activeFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
if (activeFrame != _fSelectionFrame)
return;
ODRect bbox;
ODPoint ptHandles[4];
if (_fSelection->Count() == 1)
{
/*
* Transform the coordinates of the selection handles for the selected
* frame to our local coordinates.
*/
ODRect bbox;
Proxy* p = (Proxy*)_fSelection->First();
p->shape->GetBoundingBox(ev, &bbox);
ptHandles[0].x = bbox.left; ptHandles[0].y = bbox.bottom;
ptHandles[1].x = bbox.left; ptHandles[1].y = bbox.top;
ptHandles[2].x = bbox.right; ptHandles[2].y = bbox.top;
ptHandles[3].x = bbox.right; ptHandles[3].y = bbox.bottom;
ODByteArray baPoints;
UseByteArray(&baPoints, ptHandles, 4 * sizeof(ODPoint));
p->transform->TransformPoints(ev, &baPoints, 4);
}
ODFacet* embFacet;
ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
for (embFacet = facets->First(ev); facets->IsNotComplete(ev); embFacet = facets->Next(ev))
{
/*
* We only clip the selection handles from embedded facets for the
* single selection case since for multiple selection, the handle are
* just adornments and do not respond to mouse input.
*/
ODBoolean clipHandles = kODFalse;
if (_fSelection->Count() == 1)
{
/*
* Instead of blindly subtracting the handle shape from each
* embedded frame, we'll attempt to be intelegent about it and
* only subtract the handle shape from those frames that we determine
* overlap the handles.
*/
int i;
ODFrame* embFrame = embFacet->GetFrame(ev);
ODPoint ptHandlesLocal[4];
memcpy(ptHandlesLocal, ptHandles, sizeof(ptHandles));
Proxy* p = somSelf->ProxyForFrame(ev, embFrame);
/* need to implement transform->InvertPoints - ced */
for (i = 0; i < 4; i++)
p->transform->InvertPoint(ev, &ptHandlesLocal[i]); // [137664]
/*
* Determine if any of the sizing handles might overlap the frame
* rectangle. We inflate the frame rectangle by half the width of
* the handles multiplied by 1.5 to approximate the diagonal from
* the center point of the handle to a corner since the frame might
* be rotated with respect to the handles.
*/
p->shape->GetBoundingBox(ev, &bbox);
ODCoordinate width = kSelectionHandleWidth >> 1; // divide by 2
width = width + (width >> 1); // multiply by 1.5
bbox.Inset(-width, -width);
for (i = 0; i < 4; i++)
{
/*
* Does the rectangle contain the point.
*/
if (ptHandlesLocal[i].x >= bbox.left &&
ptHandlesLocal[i].x < bbox.right &&
ptHandlesLocal[i].y >= bbox.bottom &&
ptHandlesLocal[i].y < bbox.top)
{
clipHandles = kODTrue;
break;
}
}
}
FacetClip* facetClip = somSelf->FindFacetClip(ev, embFacet);
if (clipHandles)
{
if (!facetClip)
{
facetClip = new FacetClip;
facetClip->facet = embFacet;
facetClip->clip = ODCopyAndRelease(ev, embFacet->AcquireClipShape(ev, kODNULL));
_fSavedFacetClipShapes->AddFirst(facetClip);
}
TempODShape newClipShape = facetClip->clip->Copy(ev);
Proxy* p = somSelf->ProxyForFrame(ev, embFacet->GetFrame(ev));
newClipShape->Transform(ev, p->transform);
newClipShape->Subtract(ev, _fSelectShape);
TempODTransform invert = p->transform->Copy(ev)->Invert(ev);
newClipShape->Transform(ev, invert);
embFacet->ChangeGeometry(ev, newClipShape, kODNULL, kODNULL);
}
else
{
if (facetClip)
{
embFacet->ChangeGeometry(ev, facetClip->clip, kODNULL, kODNULL);
ODReleaseObject(ev, facetClip->clip);
_fSavedFacetClipShapes->Remove(facetClip);
delete facetClip;
}
}
}
delete facets;
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartUnClipSelectionFromEmbeddedFacets(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartUnClipSelectionFromEmbeddedFacets");
SOM_TRY
ODFacet* embFacet;
ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
for (embFacet = facets->First(ev); facets->IsNotComplete(ev); embFacet = facets->Next(ev))
{
FacetClip* facetClip = somSelf->FindFacetClip(ev, embFacet);
if (facetClip)
embFacet->ChangeGeometry(ev, facetClip->clip, kODNULL, kODNULL);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartCommonInitContainerPart(ContainerPart *somSelf,
Environment *ev )
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCommonInitContainerPart");
SOM_TRY
CHAR Error[256] = ""; //used in DosLoadModule
_fDisplayFrames = new ODxOrderedCollection;
_fEmbeddedFrames = new ODxOrderedCollection;
_fContents = new ODxOrderedCollection;
_fSelection = new ODxOrderedCollection;
_fSavedFacetClipShapes = new ODxOrderedCollection;
SIZEL sizlPage = {0, 0};
_hdcMem = DevOpenDC (1 , OD_MEMORY, "*", 0L, NULL, (HDC)0) ;
_hpsMem = GpiCreatePS (1 , _hdcMem, &sizlPage, PU_PELS | GPIF_DEFAULT |
GPIT_MICRO | GPIA_ASSOC) ;
ODRect initRect(0,0,0,0);
_fSelectShape = new ODShape;
_fSelectShape->SetRectangle(ev, &initRect);
_fSelectShape->Acquire(ev);
_fSession = somSelf->GetStorageUnit(ev)->GetSession(ev);
_fSelectionFocus = _fSession->Tokenize(ev, kODSelectionFocus);
_fMenuFocus = _fSession->Tokenize(ev, kODMenuFocus);
_fKeyFocus = _fSession->Tokenize(ev, kODKeyFocus);
_fMouseFocus = _fSession->Tokenize(ev, kODMouseFocus);
_fClipboardFocus = _fSession->Tokenize(ev, kODClipboardFocus);
if (_fSession->HasExtension(ev, kODExtStatusLine))
{
_fStatusLn =(ODStatusLineExtension*) _fSession->AcquireExtension(ev,kODExtStatusLine); // 124281
_fStatusFocus = _fSession->Tokenize(ev, kODStatusLineFocus);
}
_fFocusSet = _fSession->GetArbitrator(ev)->CreateFocusSet(ev);
_fFocusSet->Add(ev, _fSelectionFocus);
_fFocusSet->Add(ev, _fMenuFocus);
_fFocusSet->Add(ev, _fKeyFocus);
if (_hmod == kODNULL)
{
if(DosLoadModule(Error,sizeof(Error),"CNTMRI",&_hmod))
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Unable to load Container Part's resource file!",
NULL, 0, MB_ENTER | MB_ERROR); // 141477
}
//@127858 begin
_fSemtIntf = new ODSemanticInterface();
_fSemtIntf->InitSemanticInterface(ev, somSelf, _fSession);
ODObjectAccessorUPP theAccessorUPP;
theAccessorUPP = NewODObjectAccessorProc( GetPropertyFromNULL );
_fSemtIntf->InstallObjectAccessor(ev, cProperty, typeNull, theAccessorUPP,
(ODSLong)somSelf);
ODEventHandlerUPP newHandler;
newHandler = NewODEventHandlerProc( HandleSetData ) ;
_fSemtIntf->InstallEventHandler(ev, kAECoreSuite, kAESetData,
newHandler,
(ODSLong)somSelf);
newHandler = NewODEventHandlerProc( HandleGetData ) ;
_fSemtIntf->InstallEventHandler(ev, kAECoreSuite, kAEGetData,
newHandler,
(ODSLong)somSelf);
//@127858 end
_fNotebook = kODNULL;
_fMenuBar = _fSession->GetWindowState(ev)->CopyBaseMenuBar(ev);
// It is required that parts instantiate their menu bars from
// the base OpenDoc menu bar. This maintains consistency in the
// default menu items and their placement.
// Since the object is a copy, we can add and subtract menus and
// items without affecting other running parts.
if ( _fMenuBar ) {
_fPopup = _fSession->GetWindowState(ev)->CopyBasePopup(ev);
somSelf->InstallMenus(ev);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODxOrderedCollection* SOMLINK ContainerPartGetEmbeddedFrames(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartGetEmbeddedFrames");
return _fEmbeddedFrames;
}
SOM_Scope ODxOrderedCollection* SOMLINK ContainerPartGetDisplayFrames(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartGetDisplayFrames");
return _fDisplayFrames;
}
SOM_Scope FacetClip* SOMLINK ContainerPartFindFacetClip(ContainerPart* somSelf,
Environment* ev,
ODFacet* facet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartFindFacetClip");
FacetClip* p = kODNULL;
SOM_TRY
if (_fSavedFacetClipShapes->Count())
{
ODxOrderedCollectionIterator i(_fSavedFacetClipShapes);
for (p = (FacetClip*) i.First(); i.IsNotComplete(); p = (FacetClip*) i.Next())
if (p->facet == facet) break;
}
SOM_CATCH_ALL
p = kODNULL;
SOM_ENDTRY
return p;
}
SOM_Scope Proxy* SOMLINK ContainerPartProxyForFrameID(ContainerPart *somSelf,
Environment *ev,
ODID frameID)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartProxyForFrameID");
Proxy* p = kODNULL;
SOM_TRY
TempODFrame tempFrame = somSelf->GetStorageUnit(ev)->GetDraft(ev)->AcquireFrame(ev, frameID);
p = somSelf->ProxyForFrame(ev, tempFrame);
SOM_CATCH_ALL
SOM_ENDTRY
return p;
}
SOM_Scope void SOMLINK ContainerPartHighlightSelection(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHighlightSelection");
SOM_TRY
if (facet->GetCanvas(ev)->IsDynamic(ev))
{
switch (_fSelection->Count())
{
case 0: // no selection
break;
case 1: // single selection
{ ODxOrderedCollectionIterator i(_fSelection);
somSelf->HighlightProxyBorder(ev, (Proxy*)i.First(), facet);
};
break;
default: // multiple selection
{ Proxy* p;
ODxOrderedCollectionIterator i(_fSelection);
somSelf->HighlightProxyBorder(ev, (Proxy*)i.First(), facet);
for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
{ if (_fSelection->Contains(p))
somSelf->HighlightContentObject(ev, p, facet);
};
};
};
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartHighlightProxyBorder(ContainerPart *somSelf,
Environment *ev,
Proxy* p,
ODFacet* facet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHighlightProxyBorder");
SOM_TRY
if (_fSelection->Count())
{
AREABUNDLE areaBundle;
LINEBUNDLE lineBundle;
MATRIXLF mtx, mtxSave;
HPS hps = facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODGPI)->GetPS(ev, facet);
areaBundle.lColor = (_fSelection->Count() == 1) ? CLR_BLACK : CLR_PALEGRAY;
GpiSetAttrs(hps, PRIM_AREA, ABB_COLOR, 0, &areaBundle);
GpiQueryModelTransformMatrix(hps, 9, &mtxSave);
Proxy* p;
ODxOrderedCollectionIterator i(_fSelection);
for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
{
ODRect bbox;
ODPoint pt[4];
POINTL ptl;
RECTL rclBox;
p->shape->GetBoundingBox(ev, &bbox);
pt[0].x = bbox.left; pt[0].y = bbox.bottom;
pt[1].x = bbox.left; pt[1].y = bbox.top;
pt[2].x = bbox.right; pt[2].y = bbox.top;
pt[3].x = bbox.right; pt[3].y = bbox.bottom;
ODByteArray baPoints;
UseByteArray(&baPoints, pt, 4 * sizeof(ODPoint));
p->transform->TransformPoints(ev, &baPoints, 4);
lineBundle.lColor = CLR_WHITE;
lineBundle.usMixMode = FM_OVERPAINT;
GpiSetAttrs(hps, PRIM_LINE, LBB_COLOR | LBB_MIX_MODE, 0, &lineBundle);
GpiSetLineType(hps, LINETYPE_SOLID);
for (int i = 0; i < 4; i++)
{
ODPoint point = pt[i];
point.Offset(-kSelectionHandleWidth / 2, -kSelectionHandleWidth / 2);
ptl = point.AsPOINTL();
GpiMove(hps, &ptl);
point.Offset(kSelectionHandleWidth, kSelectionHandleWidth);
ptl = point.AsPOINTL();
GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
}
p->transform->GetMATRIXLF(ev, &mtx);
GpiSetModelTransformMatrix(hps, 9, &mtx, TRANSFORM_PREEMPT);
lineBundle.lColor = CLR_BLACK;
lineBundle.usMixMode = FM_INVERT;
GpiSetAttrs(hps, PRIM_LINE, LBB_COLOR | LBB_MIX_MODE, 0, &lineBundle);
GpiSetLineType(hps, LINETYPE_LONGDASH);
bbox.Inset(-kSelectionHandleWidth / 2, -kSelectionHandleWidth / 2);
bbox.AsRECTL(rclBox);
ptl.x = rclBox.xLeft; ptl.y = rclBox.yBottom;
GpiMove(hps, &ptl);
ptl.x = rclBox.xRight; ptl.y = rclBox.yTop;
GpiBox(hps, DRO_OUTLINE, &ptl, (kSelectionHandleWidth * 6) >> 16,
(kSelectionHandleWidth * 6) >> 16);
GpiSetModelTransformMatrix(hps, 9, &mtxSave, TRANSFORM_REPLACE);
}
facet->GetCanvas(ev)->GetPlatformCanvas(ev, kODGPI)->ReleasePS(ev, facet);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartHighlightContentObject(ContainerPart *somSelf,
Environment *ev,
Proxy* p,
ODFacet* facet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHighlightContentObject");
}
SOM_Scope void SOMLINK ContainerPartClipEmbeddedFacets(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartClipEmbeddedFacets");
SOM_TRY
FacetInfoRec* pInfo = (FacetInfoRec *)facet->GetPartInfo(ev);
ODShape* workingClip = (ODShape *)pInfo->fClipShape;
workingClip->Reset(ev);
ODFacet* embFacet;
ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
for (embFacet = facets->First(ev);
facets->IsNotComplete(ev);
embFacet = facets->Next(ev))
{
Proxy* p = somSelf->ProxyForFrame(ev, embFacet->GetFrame(ev));
TempODShape usedShape = ODCopyAndRelease(ev, embFacet->GetFrame(ev)->AcquireUsedShape(ev, kODNULL));
TempODShape clipShape = usedShape->Copy(ev); // 142961 - aml
workingClip->InverseTransform(ev, p->transform); // now in embedded frame's coordinates
clipShape->Subtract(ev, workingClip);
workingClip->Union(ev, usedShape); // 142961 - aml
workingClip->Transform(ev, p->transform); // content coordinates
embFacet->ChangeGeometry(ev, clipShape, p->transform, kODNULL);
}
delete facets;
while (_fSavedFacetClipShapes->Count())
{
FacetClip* facetClip = (FacetClip*)_fSavedFacetClipShapes->First();
ODReleaseObject(ev, facetClip->clip);
_fSavedFacetClipShapes->RemoveFirst();
delete facetClip;
}
somSelf->ClipSelectionFromEmbeddedFacets(ev, facet);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartAdjustPopupMenu(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartAdjustPopupMenu");
}
SOM_Scope void SOMLINK ContainerPartAdjustSelectedMenu(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartAdjustSSelectedMenu");
}
SOM_Scope void SOMLINK ContainerPartClearSelectedMenu(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartRestoreSelectedMenu");
}
SOM_Scope void SOMLINK ContainerPartClearPopupMenu(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartRestoreSelectedMenu");
}
SOM_Scope void SOMLINK ContainerPartEmptySelection(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartEmptySelection");
SOM_TRY
if (_fSelection->Count())
{
Proxy* p = kODNULL;
for(ODULong i = _fSelection->Count(); i > 0; i--)
{
p = (Proxy*)_fSelection->First();
ODxOrderedCollectionIterator i(p);
for (ODFrame* frame = (ODFrame*)i.First();
i.IsNotComplete();
frame = (ODFrame*)i.Next())
{
somSelf->SetFrameSelected(ev, frame, kODFalse);
}
_fSelection->RemoveFirst();
}
_fSelectShape->Reset(ev);
ODReleaseObject(ev, _fSelectionFrame);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleButton1Click(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet,
ODPoint* where,
ODEventData* event)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1Click");
ODBoolean handled = kODFalse;
SOM_TRY
if (_fMouseMode == kNormal)
{
if (!facet->GetWindow(ev)->IsActive(ev))
facet->GetWindow(ev)->Select(ev);
if (event->msg == WM_BUTTON1CLICK)
{
// [126751] if scaling to zero, unbundle
if ( _fTrackingMode == kSelectScaleOrigin )
{
_fTrackingMode = 0; // default value
somSelf->FreezeEmbeddedFrames(ev, kODFalse); // unbundle frame
}
ODBoolean bActive = kODFalse; // [131094]
PartInfoRec* pInfo = (PartInfoRec*) facet->GetFrame(ev)->GetPartInfo(ev);
if ( pInfo->fIsActive )
bActive = kODTrue; // [131094]
if ( bActive )
{
somSelf->DoDeSelectAll(ev, facet->GetFrame(ev));
} else
somSelf->ActivateFrame(ev, facet->GetFrame(ev));
if ( _fPasteESC ) // we abort the paste operation
{
_fPasteOn = kODFalse;
}
else
{
if ( _fPasteOn )
{
if ( _fPasteFrame == facet->GetFrame(ev) )
{
somSelf->PasteFrameFromClipboard(ev, facet, where);
somSelf->DisplayStatusLineText(ev, "Paste completed", facet->GetFrame(ev));
}
else
{
somSelf->DisplayStatusLineText(ev,
"Click again to complete Paste operation",
facet->GetFrame(ev));
_fPasteFrame = facet->GetFrame(ev);
}
}
// 128682 - faa - ends
}
handled = kODTrue;
}
}
else
handled = kODTrue;
SOM_CATCH_ALL
SOM_ENDTRY
return handled;
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleButton1Down(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet,
ODPoint* where,
ODEventData* event)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1Down");
ODBoolean handled = kODFalse;
SOM_TRY
ODPoint mouse = *where;
TempODTransform xform = ((_fMouseMode == kTracking) ? _fTrackingFacet : facet)->
AcquireWindowContentTransform(ev, kODNULL);
xform->InvertPoint(ev, &mouse); // [137664]
switch(_fMouseMode)
{
case kRotateSelectCenter:
if (somSelf->BeginTrackingMouse(ev, facet))
{
_fTrackingMode = kSelectRotateOrigin;
_ptRef = _ptOrigin = _ptEnd = mouse;
somSelf->UpdateTrackRect(ev, &mouse, facet, kUpdateModeStart);
ODFrame* frame = facet->GetFrame(ev); // 124281
somSelf->DisplayStatusLineText(ev,"Btn1 drag to rotate; ESC or Btn2 Click to cancel.",frame); // 124281
}
handled = kODTrue;
break;
case kScaleSelectRefPoint:
if (somSelf->BeginTrackingMouse(ev, facet))
{
_fTrackingMode = kSelectScaleOrigin;
_ptRef = _ptOrigin = _ptEnd = mouse;
somSelf->UpdateTrackRect(ev, &mouse, facet, kUpdateModeStart);
ODFrame* frame = facet->GetFrame(ev); // 124281
somSelf->DisplayStatusLineText(ev,"Btn1 drag to scale; ESC or Btn2 Click to cancel.",frame); // 124281
}
handled = kODTrue;
break;
case kTracking:
{
if (_fTrackingMode == kSelectRotateOrigin || _fTrackingMode == kSelectScaleOrigin)
{
POINTL ptlMouse = mouse.AsPOINTL(),
ptlRef = _ptRef.AsPOINTL();
if (_fTrackingMode == kSelectScaleOrigin && (ptlMouse.x == ptlRef.x ||
ptlMouse.y == ptlRef.y ))
{
somSelf->ResetMouseMode(ev);
}
else
{
somSelf->UpdateTrackRect(ev, &_ptOrigin, _fTrackingFacet, kUpdateModeEnd);
_ptOrigin = _ptEnd = mouse;
_fTrackingMode = (_fTrackingMode == kSelectScaleOrigin) ?
kScaleSelection : kRotateSelection;
somSelf->FreezeEmbeddedFrames(ev, kODFalse);
somSelf->CreateTrackingPolygons(ev, kODTrue);
somSelf->UpdateTrackRect(ev, &_ptOrigin, _fTrackingFacet, kUpdateModeStart);
}
handled = kODTrue;
break;
}
}
}
SOM_CATCH_ALL
SOM_ENDTRY
return handled;
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleButton1MotionStart(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet,
ODPoint* where,
ODEventData* event)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1MotionStart");
ODBoolean handled = kODFalse;
SOM_TRY
ODFrame* frame = ((_fMouseMode == kTracking) ? _fTrackingFacet : facet)->GetFrame(ev); // [133692] - ced
PartInfoRec* pInfo = (PartInfoRec*)frame->GetPartInfo(ev);
if (pInfo->fIsActive && _fMouseMode == kNormal)
{
ODPoint mouse = *where;
TempODTransform xform = facet->AcquireWindowContentTransform(ev, kODNULL);
xform->InvertPoint(ev, &mouse); // [137664]
if (facet->GetFrame(ev) == _fSelectionFrame &&
_fSelection->Count() == 1 && _fSelectShape->ContainsPoint(ev, &mouse))
{
Proxy* p = (Proxy*)_fSelection->First();
ODRect bbox;
ODPoint ptCorners[4], ptSelMouse, ptSelCenter;
p->shape->GetBoundingBox(ev, &bbox);
ptSelMouse = mouse; // [137664]
p->transform->InvertPoint(ev, &ptSelMouse); // in selections frame coords
ptSelCenter.x = (bbox.left + bbox.right) / 2;
ptSelCenter.y = (bbox.top + bbox.bottom) / 2;
ptCorners[0].x = bbox.left; ptCorners[0].y = bbox.bottom;
ptCorners[1].x = bbox.left; ptCorners[1].y = bbox.top;
ptCorners[2].x = bbox.right; ptCorners[2].y = bbox.top;
ptCorners[3].x = bbox.right; ptCorners[3].y = bbox.bottom;
ODByteArray baPoints;
UseByteArray(&baPoints, ptCorners, 4 * sizeof(ODPoint));
p->transform->TransformPoints(ev, &baPoints, 4);
if (ptSelMouse.x < ptSelCenter.x && ptSelMouse.y < ptSelCenter.y)
{
_fTrackingMode = kBotLeftResize;
_ptRef = ptCorners[2];
_ptMouseOffset.x = ptCorners[0].x - mouse.x;
_ptMouseOffset.y = ptCorners[0].y - mouse.y;
}
else if (ptSelMouse.x < ptSelCenter.x && ptSelMouse.y > ptSelCenter.y)
{
_fTrackingMode = kTopLeftResize;
_ptRef = ptCorners[3];
_ptMouseOffset.x = ptCorners[1].x - mouse.x;
_ptMouseOffset.y = ptCorners[1].y - mouse.y;
}
else if (ptSelMouse.x > ptSelCenter.x && ptSelMouse.y > ptSelCenter.y)
{
_fTrackingMode = kTopRightResize;
_ptRef = ptCorners[0];
_ptMouseOffset.x = ptCorners[2].x - mouse.x;
_ptMouseOffset.y = ptCorners[2].y - mouse.y;
}
else if (ptSelMouse.x > ptSelCenter.x && ptSelMouse.y < ptSelCenter.y)
{
_fTrackingMode = kBotRightResize;
_ptRef = ptCorners[1];
_ptMouseOffset.x = ptCorners[3].x - mouse.x;
_ptMouseOffset.y = ptCorners[3].y - mouse.y;
}
_ptEnd = _ptOrigin = mouse;
somSelf->CreateTrackingPolygons(ev, kODFalse);
}
else
{
_fTrackingMode = kRubberBandSelection;
_ptEnd = _ptOrigin = mouse;
if (_fSelection->Count())
{
somSelf->DoDeSelectAll(ev, facet->GetFrame(ev));
/*
* Force updating now since we're about to lock window updating
*/
WinUpdateWindow(facet->GetWindow(ev)->GetPlatformWindow(ev));
}
}
somSelf->BeginTrackingMouse(ev, facet);
_ptEnd = mouse;
handled = kODTrue;
}
SOM_CATCH_ALL
SOM_ENDTRY
return handled;
}
SOM_Scope void SOMLINK ContainerPartCreateTrackingPolygons(ContainerPart *somSelf,
Environment *ev,
ODBoolean transformPoints)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCreateTrackingPolygons");
SOM_TRY
_fNumPolygons = _fSelection->Count();
_fPolygons = new POLYGON[_fNumPolygons];
Proxy* p;
int i;
ODxOrderedCollectionIterator iter(_fSelection);
for (i = 0, p = (Proxy*) iter.First(); iter.IsNotComplete(); i++, p = (Proxy*) iter.Next())
{
ODRect bbox;
p->shape->GetBoundingBox(ev, &bbox);
_fPolygons[i].ulPoints = 4;
_fPolygons[i].aPointl = new POINTL[4];
ODPoint apt[4];
apt[0].x = bbox.left; apt[0].y = bbox.bottom;
apt[1].x = bbox.left; apt[1].y = bbox.top;
apt[2].x = bbox.right; apt[2].y = bbox.top;
apt[3].x = bbox.right; apt[3].y = bbox.bottom;
for (int j=0; j<4; j++)
{
if (transformPoints)
p->transform->TransformPoint(ev, &apt[j]); // [137664]
_fPolygons[i].aPointl[j] = apt[j].AsPOINTL();
}
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartResetMouseMode(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartResetMouseMode");
SOM_TRY
if (_fMouseMode == kTracking)
{
ODFrame* frame = _fTrackingFacet->GetFrame(ev);
_fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fMouseFocus, frame);
somSelf->FocusLost(ev, _fMouseFocus, frame);
somSelf->DisplayStatusLineText(ev,"",frame); // 124281
}
else if (_fMouseMode != kNormal)
{
somSelf->FreezeEmbeddedFrames(ev, kODFalse);
WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE));
somSelf->DisplayStatusLineText(ev,"",_fSelectionFrame); // [133692] - ced
}
_fMouseMode = kNormal;
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODBoolean SOMLINK ContainerPartBeginTrackingMouse(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartBeginTrackingMouse");
ODBoolean handled = kODFalse;
SOM_TRY
HWND hwndFrame = facet->GetWindow(ev)->GetPlatformWindow(ev);
HWND hwnd = WinWindowFromID(hwndFrame, FID_CLIENT);
ODFrame* frame = facet->GetFrame(ev);
if (_fSession->GetArbitrator(ev)->RequestFocus(ev, _fMouseFocus, frame))
{
if (WinSetCapture(HWND_DESKTOP, hwnd))
{
if (WinLockWindowUpdate(HWND_DESKTOP, hwnd))
{
_fTrackingFacet = facet;
_fMouseMode = kTracking;
handled = kODTrue;
}
else
{
WinSetCapture(HWND_DESKTOP, 0);
_fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fMouseFocus,
frame);
}
}
else
{
_fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fMouseFocus,
frame);
}
}
SOM_CATCH_ALL
SOM_ENDTRY
return handled;
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleMouseDrag(ContainerPart *somSelf,
Environment *ev,
ODFacet* container,
ODFacet* facet,
ODPoint* mouse,
ODEventData* event)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMouseDownDrag");
RECTL* arcl = 0;
POINTL* aptl = 0;
ODBoolean handled = kODFalse;
SOM_TRY
TempODPart destPart = kODNULL;
ODPoint pt(0,0);
ODShape* scratch;
Point mdOffset = {0,0};
HRGN dragRgn, tempRgn;
ODID frameInfoData;
ODDragAndDrop* dad;
ODStorageUnit* unit;
ODDropResult dropResult;
ODFrame* containingFrame = container->GetFrame(ev);
ODxOrderedCollectionIterator embFrames(_fEmbeddedFrames);
ODxOrderedCollectionIterator dspFrames(_fDisplayFrames);
Proxy *p;
int i;
TempODFrame activeFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
if (containingFrame != activeFrame)
return kODFalse; // Not handled
if (containingFrame != _fSelectionFrame || !_fSelection->Count())
return kODTrue; // Handled
POINTL ptlMouse = {SHORT1FROMMP(event->mp1), SHORT2FROMMP(event->mp1)};
// *** Fill DAD SU with Props n' Vals
dad = _fSession->GetDragAndDrop(ev);
dad->Clear(ev);
Rect shapeRect;
ODULong numRects = _fSelection->Count(),
numPoints = numRects * 6 + 2;
arcl = new RECTL[numRects];
aptl = new POINTL[numPoints];
TempODTransform xform = containingFrame->CreateTransform(ev),
contentTransform = container->AcquireWindowContentTransform(ev, kODNULL);
ODxOrderedCollectionIterator iter(_fSelection);
ODPoint ptNegMouse(-mouse->x, -mouse->y);
PPOINTL pptl = &aptl[0];
pptl->x = 0;
(pptl++)->y = 0;
for (i = 0, p = (Proxy*) iter.First(); iter.IsNotComplete(); i++, p = (Proxy*) iter.Next())
{
ODRect bbox;
ODPoint pt[5];
p->shape->GetBoundingBox(ev, &bbox);
xform->CopyFrom(ev, p->transform);
xform->PostCompose(ev, contentTransform);
xform->MoveBy(ev, &ptNegMouse);
pt[0].x = bbox.left; pt[0].y = bbox.bottom;
pt[1].x = bbox.left; pt[1].y = bbox.top;
pt[2].x = bbox.right; pt[2].y = bbox.top;
pt[3].x = bbox.right; pt[3].y = bbox.bottom;
pt[4].x = bbox.left; pt[4].y = bbox.bottom;
ODByteArray baPoints;
UseByteArray(&baPoints, pt, 5 * sizeof(ODPoint));
xform->TransformPoints(ev, &baPoints, 5);
for (int j=0; j<5; j++)
*(pptl++) = pt[j].AsPOINTL();
}
for (i = numRects * 5 - 4; i > 0; i -= 5)
*(pptl++) = aptl[i];
pptl->x = pptl->y = 0;
delete[] arcl;
DRAGIMAGE dimg; /* DRAGIMAGE structure */
HBITMAP hbm; /* Bit-map handle */
/*************************************************************/
/* Initialize the DRAGIMAGE structure */
/*************************************************************/
dimg.cb = sizeof(DRAGIMAGE); /* Size control block */
// jlc changed the following code to use a polygon rather than
// a bitmap because he wanted to put something on the screen
// quickly and didn't want to take the time to code up a
// bitmap. The following code should be changed to
// actually provide an outline of the object, or an icon.
dimg.cptl = numPoints; // number of points
dimg.hImage = (ULONG)aptl; /* Image handle passed to */
/* DrgDrag */
dimg.fl = DRG_POLYGON; /* Flags passed to DrgDrag */
dimg.cxOffset = 0; /* Offset of the origin of */
dimg.cyOffset = 0; /* the image from the pointer */
/* hotspot */
for (p = (Proxy*) iter.First(); iter.IsNotComplete(); p = (Proxy*) iter.Next())
{
unit = dad->GetContentStorageUnit(ev);
// *** (optional) save offset between mousedown pt and topLeft pt of selection
// assuming event->where is in window coordinates.
_mouseStart = ODPoint(ptlMouse);
ODPoint botLeft; // elsewhere refered to as topLeft (Mac heratige)
ODPoint offset(ptlMouse); // offset of mouse in window coords
p->transform->GetOffset(ev, &botLeft);
// botLeft contains offset of frame being dragged in my frame coords.
contentTransform->InvertPoint(ev, &offset); // [137664]
// offset contains the offset of the mouse in my frame coords
offset.x -= botLeft.x;
offset.y -= botLeft.y;
// offset contains offset of mouse relative to position of frame
// being dragged in my frame coords (same coords as frame shape).
unit->AddProperty(ev, kPropMouseDownOffset)->AddValue(ev, kODPoint);
StorageUnitSetValue(unit, ev, sizeof(mdOffset), (ODValue) &offset);
// *** (optional) if dragging one frame, save its external transform (not aggregate)
ODMatrix m;
p->transform->GetMatrix(ev, &m);
unit->AddProperty(ev, kODPropExternalTransform)->AddValue(ev, kODTransform);
StorageUnitSetValue(unit, ev, sizeof(m), (ODValue) &m);
// *** if dragging one frame, write its shape [jpa]
unit->AddProperty(ev, kODPropFrameShape);
p->shape->WriteShape(ev, unit);
ODDraft* fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
ODDraftKey key = fromDraft->BeginClone(ev, unit->GetDraft(ev),
kODNULL, kODCloneCut);
ODFrame* drgFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, containingFrame);
p->part->CloneInto(ev, key, unit, drgFrame);
fromDraft->EndClone(ev, key);
// *** save ID of frame being dragged
// WRite out the frame info in case it is dropped back to this part.
frameInfoData = drgFrame->GetID(ev);
unit->AddProperty(ev, kPropFrameInfo)->AddValue(ev, kFrameRef);
StorageUnitSetValue(unit, ev, sizeof(ODID), (ODValue) &frameInfoData);
ODxOrderedCollectionIterator i(p);
for (ODFrame* f = (ODFrame*)i.First();
i.IsNotComplete();
f = (ODFrame*)i.Next())
{
f->SetDragging(ev, kODTrue);
}
}
// Prevent the user from dropping into one of our other display frames.
for (ODFrame* dspFrame = (ODFrame*)dspFrames.First();
dspFrames.IsNotComplete();
dspFrame = (ODFrame*)dspFrames.Next())
{
if (dspFrame != containingFrame)
{
PartInfoRec* pInfo = (PartInfoRec*)dspFrame->GetPartInfo(ev);
pInfo->fAcceptDrop = kODFalse;
}
}
delete[] aptl;
ODByteArray dragImgBA = CreateByteArrayStruct(&dimg, sizeof(DRAGIMAGE));
ODByteArray eventBA = CreateByteArrayStruct(&event, sizeof(ODEventData*));
{
ODPart* tempPart = kODNULL;
dropResult = dad->StartDrag(ev, containingFrame, 0,
&dragImgBA, &tempPart, &eventBA);
destPart = tempPart;
}
DisposeByteArrayStruct(&dragImgBA); // [119548]
DisposeByteArrayStruct(&eventBA);
for (ODFrame* embFrame = (ODFrame*) embFrames.First();
embFrames.IsNotComplete();
embFrame = (ODFrame*) embFrames.Next())
{
embFrame->SetDragging(ev, kODFalse);
}
for (dspFrame = (ODFrame*)dspFrames.First();
dspFrames.IsNotComplete();
dspFrame = (ODFrame*)dspFrames.Next())
{
PartInfoRec* pInfo = (PartInfoRec*)dspFrame->GetPartInfo(ev);
pInfo->fAcceptDrop = kODTrue;
}
if ((dropResult == kODDropCopy) || (dropResult == kODDropMove))
{
if (destPart == _fPartWrapper)
{
// The frame was dropped within the same part
// Handled in Drop method.
}
else if (dropResult == kODDropMove)
{
// The frame was moved out
somSelf->DoClear(ev, containingFrame);
}
}
handled = kODTrue;
SOM_CATCH_ALL
delete arcl;
delete aptl;
SOM_ENDTRY
return handled;
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleButton1ClickInEmbeddedFrame(ContainerPart *somSelf,
Environment *ev,
ODFacet* container,
ODFacet* facet,
ODPoint* where,
ODEventData* event)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1ClickInEmbeddedFrame");
ODBoolean handled = kODFalse;
SOM_TRY
somSelf->DisplayStatusLineText(ev, "HandleButton1ClickInEmbedded", container->GetFrame(ev));
if (!container->GetWindow(ev)->IsActive(ev))
container->GetWindow(ev)->Select(ev);
somSelf->ActivateFrame(ev, container->GetFrame(ev));
// 128682 - faa - starts
if ( _fPasteOn )
{
somSelf->DisplayStatusLineText(ev,
"Frame must be activated prior to pasting",
container->GetFrame(ev));
DosBeep(1500, 500);
handled = kODFalse;
}
// 128682 - faa - ends
else
{
Proxy* p = somSelf->ProxyForFrame(ev, facet->GetFrame(ev));
PartInfoRec* pInfo = (PartInfoRec*) container->GetFrame(ev)->GetPartInfo(ev);
if (event->msg == WM_BUTTON1CLICK || event->msg == WM_BUTTON1CLICK &&
(SHORT2FROMMP(event->mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)))
{
if (container->GetFrame(ev) != _fSelectionFrame)
somSelf->DoDeSelectAll(ev, _fSelectionFrame);
if (_fSelection->Count() == 0) {
somSelf->SetFrameSelected(ev, facet->GetFrame(ev), kODTrue);
_fSelection->AddFirst((ElementType)p);
}
else
{
somSelf->InvalidateSelection(ev, container->GetFrame(ev));
/*
* If frame is already in selection then remove it from selection
* else add it to selection.
*/
Proxy* proxy;
ODxOrderedCollectionIterator i(_fSelection);
ODFrame* frame = facet->GetFrame(ev);
for (proxy = (Proxy*) i.First(); i.IsNotComplete(); proxy = (Proxy*) i.Next())
if (proxy == p) break;
if (i.IsNotComplete())
{
somSelf->SetFrameSelected(ev, frame, kODFalse);
_fSelection->Remove((ElementType)p);
}
else
{
somSelf->SetFrameSelected(ev, frame, kODTrue);
_fSelection->AddFirst((ElementType)p);
}
}
somSelf->CreateProxySelectionBorder(ev);
somSelf->ClipSelectionFromEmbeddedFrames(ev, container->GetFrame(ev));
somSelf->InvalidateSelection(ev, container->GetFrame(ev));
}
handled = kODTrue;
}
SOM_CATCH_ALL
SOM_ENDTRY
return handled;
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleButton1ClickInBorder(ContainerPart *somSelf,
Environment *ev,
ODFacet* container,
ODFacet* facet,
ODPoint* where,
ODEventData* event)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1ClickDownInBorder");
ODBoolean handled = kODFalse;
SOM_TRY
somSelf->DoDeSelectAll(ev, container->GetFrame(ev));
if (!container->GetWindow(ev)->IsActive(ev))
container->GetWindow(ev)->Select(ev);
somSelf->ActivateFrame(ev, container->GetFrame(ev));
Proxy* p = somSelf->ProxyForFrame(ev, facet->GetFrame(ev));
somSelf->SetFrameSelected(ev, facet->GetFrame(ev), kODTrue);
_fSelection->AddFirst((ElementType)p);
somSelf->CreateProxySelectionBorder(ev);
somSelf->ClipSelectionFromEmbeddedFrames(ev, container->GetFrame(ev));
somSelf->InvalidateSelection(ev, container->GetFrame(ev));
handled = kODTrue;
SOM_CATCH_ALL
SOM_ENDTRY
return handled;
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleKeyDown(ContainerPart *somSelf,
Environment *ev,
ODFrame* focusFrame,
ODEventData* event)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleKeyDown");
ODBoolean handled = kODFalse;
SOM_TRY
if ((SHORT1FROMMP(event->mp1) & KC_VIRTUALKEY) &&
SHORT2FROMMP(event->mp2) == VK_ESC)
{
if (_fMouseMode != kNormal)
somSelf->ResetMouseMode(ev);
else
{
_fPasteESC = kODTrue; // abort cut and paste
WinSetPointer(HWND_DESKTOP,
WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE));
}
}
handled = kODTrue;
SOM_CATCH_ALL
SOM_ENDTRY
return handled;
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleMenuEvent(ContainerPart *somSelf,
Environment *ev,
ODFrame* focusFrame,
ODEventData* event)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMenuEvent");
ODBoolean handled = kODFalse;
SOM_TRY
PartInfoRec* pInfo = (PartInfoRec*) focusFrame->GetPartInfo(ev);
ODCommandID command = LONGFROMMP(event->mp1);
if (pInfo->fIsActive) {
switch (command)
{
case IDMA_COLOR_GRAY :
case IDMA_COLOR_RED :
case IDMA_COLOR_GREEN :
case IDMA_COLOR_YELLOW :
case IDMA_COLOR_BLUE :
case IDMA_COLOR_MAGENTA :
case IDMA_COLOR_CYAN :
case IDMA_COLOR_WHITE :
somSelf->HandleColorMenu(ev, focusFrame, command); //@127858 change color via an OSA event now
handled = kODTrue;
break;
case EDIT_DELETE :
somSelf->DoClear(ev, focusFrame);
break;
case EDIT_CUT :
somSelf->DoCut(ev, focusFrame);
break;
case EDIT_COPY :
somSelf->DoCopy(ev, focusFrame);
break;
case EDIT_PASTE :
// 128682 - faa - starts
if ( somSelf->AllowPaste(ev, focusFrame) )
{
_fPasteOn = kODTrue;
_fPasteESC = kODFalse;
somSelf->FreezeEmbeddedFrames(ev, kODTrue);
WinSetPointer(HWND_DESKTOP,
WinQuerySysPointer(HWND_DESKTOP, SPTR_MOVE, FALSE));
somSelf->DisplayStatusLineText(ev,
"Btn1 Click to Paste; ESC to cancel.",focusFrame);
handled = kODTrue;
}
// 128682 - faa - ends
break;
case EDIT_SELECTALL :
somSelf->DoSelectAll(ev, focusFrame);
break;
case EDIT_DESELECTALL :
somSelf->DoDeSelectAll(ev, focusFrame);
break;
case IDMA_MOVETOFRONT :
somSelf->MoveToFront(ev, focusFrame);
break;
case IDMA_MOVETOBACK :
somSelf->MoveToBack(ev, focusFrame);
break;
case IDMA_MOVEFORWARD :
somSelf->MoveForward(ev, focusFrame);
break;
case IDMA_MOVEBACKWARD:
somSelf->MoveBackward(ev, focusFrame);
break;
case IDMA_PRINT :
{
ODEventData printEvent;
memset(&printEvent, 0, sizeof(printEvent));
printEvent.hwnd = event->hwnd;
printEvent.msg = OD_PRINT;
somSelf->HandleEvent(ev, &printEvent, focusFrame, kODNULL, kODNULL);
}
break;
case IDMA_PARTINFO:
{
HMODULE hMod;
int rc;
DosQueryModuleHandle(THISDLL, &hMod);
rc = WinDlgBox(HWND_DESKTOP, event->hwnd,
(PFNWP)CntnrPartInfoDlgProc, hMod, DL_PARTINFO, NULL );
}
break;
case IDMA_TOGGLE_GRID:
{
PartInfoRec* pInfo = (PartInfoRec*) focusFrame->GetPartInfo(ev);
if (pInfo->fGridOn)
pInfo->fGridOn = kODFalse;
else
pInfo->fGridOn = kODTrue;
focusFrame->SetPartInfo(ev, (ODInfoType) pInfo);
focusFrame->Invalidate(ev, kODNULL, kODNULL);
}
break;
case IDMA_ROTATE:
_fMouseMode = kRotateSelectCenter;
somSelf->FreezeEmbeddedFrames(ev, kODTrue);
WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_MOVE, FALSE));
somSelf->DisplayStatusLineText(ev,"Btn1 Click to select center; ESC or Btn2 Click to cancel.",focusFrame); // 124281
break;
case IDMA_SCALE:
_fMouseMode = kScaleSelectRefPoint;
somSelf->FreezeEmbeddedFrames(ev, kODTrue);
WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_MOVE, FALSE));
somSelf->DisplayStatusLineText(ev,"Btn1 Click to select ref point; ESC or Btn2 Click to cancel.",focusFrame); // 124281
break;
case HELP_GENERAL:
WinMessageBox(HWND_DESKTOP,
HWND_DESKTOP,
"General Help goes here",
"Container Part Help",
0L,
MB_OK);
break;
case HELP_INDEX:
WinMessageBox(HWND_DESKTOP,
HWND_DESKTOP,
"Help Index goes here",
"Container Part Help",
0L,
MB_OK);
break;
case VIEW_SALARGEICON:
{
Proxy* p;
ODxOrderedCollectionIterator i(_fSelection);
for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
{
ODxOrderedCollectionIterator emb(_fEmbeddedFrames);
for (ODFrame* frame = (ODFrame*)emb.First(); emb.IsNotComplete(); frame = (ODFrame*)emb.Next())
if (somSelf->ProxyForFrame(ev, frame) == p)
frame->ChangeViewType(ev, _fSession->Tokenize(ev, kODViewAsLargeIcon));
}
}
break;
case VIEW_SASMALLICON:
{
Proxy* p;
ODxOrderedCollectionIterator i(_fSelection);
for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
{
ODxOrderedCollectionIterator emb(_fEmbeddedFrames);
for (ODFrame* frame = (ODFrame*)emb.First(); emb.IsNotComplete(); frame = (ODFrame*)emb.Next())
if (somSelf->ProxyForFrame(ev, frame) == p)
frame->ChangeViewType(ev, _fSession->Tokenize(ev, kODViewAsSmallIcon));
}
}
break;
case VIEW_SATHUMBNAIL:
{
Proxy* p;
ODxOrderedCollectionIterator i(_fSelection);
for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
{
ODxOrderedCollectionIterator emb(_fEmbeddedFrames);
for (ODFrame* frame = (ODFrame*)emb.First(); emb.IsNotComplete(); frame = (ODFrame*)emb.Next())
if (somSelf->ProxyForFrame(ev, frame) == p)
frame->ChangeViewType(ev, _fSession->Tokenize(ev, kODViewAsThumbnail));
}
}
break;
case VIEW_SAFRAME:
{
Proxy* p;
ODxOrderedCollectionIterator i(_fSelection);
for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
{
ODxOrderedCollectionIterator emb(_fEmbeddedFrames);
for (ODFrame* frame = (ODFrame*)emb.First(); emb.IsNotComplete(); frame = (ODFrame*)emb.Next())
if (somSelf->ProxyForFrame(ev, frame) == p)
frame->ChangeViewType(ev, _fSession->Tokenize(ev, kODViewAsFrame));
}
}
break;
case VIEW_OAWINDOW:
somSelf->Open(ev, focusFrame);
break;
case VIEW_OATREE:
case VIEW_OAICON:
case VIEW_OADETAILS:
case DOC_OATREE:
case DOC_OAICON:
case DOC_OADETAILS:
{
ODULong vType;
ODBoolean retVal = kODFalse;
if(_fViewExtension == kODNULL)
{
_fViewExtension = new ODViewExtension;
_fViewExtension->InitViewExtension(ev,somSelf);
}
if ((command == VIEW_OATREE) ||(command == DOC_OATREE)) vType = OD_TREEVIEW;
else if ((command == VIEW_OAICON) || (command == DOC_OAICON)) vType = OD_ICONVIEW;
else vType = OD_DETAILSVIEW;
if(vType == OD_DETAILSVIEW)
retVal = Test_AddDetailsColumns(somSelf, ev,_fViewExtension);
_fViewExtension->DisplayView(ev,somSelf,vType);
if((vType == OD_DETAILSVIEW) && (retVal))
{
//remove the z-order info we wrote to the embedded
//part(s)...we only did it to show additional columns
ODEmbeddedFramesIterator *CurrentFrameIter = kODNULL;
ODFrame *ChildFrame = kODNULL;
ODStorageUnit* su; // = ChildFrame->GetStorageUnit(ev);
CurrentFrameIter=somSelf->CreateEmbeddedFramesIterator(ev,kODNULL);
if (CurrentFrameIter)
ChildFrame=CurrentFrameIter->First(ev);
while (ChildFrame) { // remove property from all frames
TempODPart ChildPart = ChildFrame->AcquirePart( ev );
su = ChildPart->GetStorageUnit(ev);
if(su->Exists(ev,kZOrderProp, kZOrder , 0)) {
su->Focus(ev,kZOrderProp , kODPosUndefined, kZOrder,
0, kODPosUndefined);
su->Remove(ev);
}
ChildFrame = kODNULL;
if (CurrentFrameIter->IsNotComplete(ev)) {
ChildFrame = CurrentFrameIter->Next(ev);
}
} // end while
delete CurrentFrameIter;
}
}
handled = kODTrue;
break;
case VIEW_PROPERTIES:
{
TempODFrameFacetIterator facets = focusFrame->CreateFacetIterator(ev);
_fSession->GetInfo(ev)->ShowPartFrameInfo(ev,facets->First(ev), kODFalse);
handled = kODTrue;
}
break;
default:
break;
}
} //end ifactive
SOM_CATCH_ALL
SOM_ENDTRY
return handled;
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleMouseMove(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet,
ODFrame* frame,
ODPoint* where,
ODEventData* event)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleMouseMove");
ODBoolean handled = kODFalse;
SOM_TRY
RECTL rclBox;
PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
switch (_fMouseMode)
{
// 128682 - faa - starts
case kNormal:
if ( _fPasteOn )
{
if ( somSelf->AllowPaste(ev, frame) )
{
WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_MOVE, FALSE));
handled = kODTrue;
}
else
{
// been emptied in another docshell
handled = kODFalse;
}
}
break;
// 128682 - faa - ends
case kRotateSelectCenter:
case kScaleSelectRefPoint:
WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_MOVE, FALSE));
handled = kODTrue;
break;
case kTracking:
if (_fTrackingFacet)
{
if (!SHORT1FROMMP(event->mp2)) // Mouse still captured?
{
TempODTransform xform = _fTrackingFacet->AcquireWindowFrameTransform(ev, _fTrackingFacet->GetCanvas(ev));
ODPoint localPoint = *where; // [137664]
xform->InvertPoint(ev, &localPoint); // window to frame coords
somSelf->UpdateTrackRect(ev, &localPoint, _fTrackingFacet, kUpdateModeContinue);
_ptEnd = localPoint;
}
else // mouse is no longer captured
{
somSelf->ResetMouseMode(ev);
}
}
else if (facet->GetWindow(ev)->IsActive(ev) )
{
if (_fSelection->Count() >= 1)
{
ODPoint mouse = *where;
TempODTransform xform = facet->AcquireWindowContentTransform(ev, facet->GetCanvas(ev));
ODRect bbox;
xform->InvertPoint(ev, &mouse); // [137664]
}
}
break;
}
SOM_CATCH_ALL
SOM_ENDTRY
return handled;
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleButton1MotionEnd(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet,
ODFrame* frame,
ODPoint* where,
ODEventData* event)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1MotionEnd");
SOM_TRY
PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
if (_fMouseMode == kTracking &&
(_fTrackingMode == kRubberBandSelection ||
_fTrackingMode == kBotLeftResize ||
_fTrackingMode == kTopLeftResize ||
_fTrackingMode == kTopRightResize ||
_fTrackingMode == kBotRightResize))
{
/*
* _fTrackingFacet is cleared in ResetMouseMode so save the pointer
*/
ODFacet* trackingFacet = _fTrackingFacet;
somSelf->ResetMouseMode(ev);
TempODTransform xform = trackingFacet->AcquireWindowContentTransform(ev, kODNULL);
ODPoint localPoint = *where; // [137664]
xform->InvertPoint(ev, &localPoint); // window to content coords
switch (_fTrackingMode)
{
case kRubberBandSelection:
{
somSelf->DoDeSelectAll(ev, _fSelectionFrame);
/* select the embedded frames within the tracking rectangle */
ODRect trackRect;
trackRect.left = min(_ptOrigin.x, localPoint.x);
trackRect.bottom = min(_ptOrigin.y, localPoint.y);
trackRect.right = max(_ptOrigin.x, localPoint.x);
trackRect.top = max(_ptOrigin.y, localPoint.y);
TempODShape trackShape = trackingFacet->GetFrame(ev)->CreateShape(ev);
trackShape->SetRectangle(ev, &trackRect);
TempODTransform contentXform = trackingFacet->AcquireContentTransform(ev, kODNULL);
trackShape->Transform(ev, contentXform);
/*
* Iterate thru the embedded facets of the tracking facet and add
* those embedded facets that are contained within the tracking
* shape to the selection.
*/
ODFacetIterator* facets = trackingFacet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
for (ODFacet* embFacet = facets->First(ev);
facets->IsNotComplete(ev);
embFacet = facets->Next(ev))
{
if (!embFacet) break;
ODFrame* embFrame = embFacet->GetFrame(ev);
//below 2 lines only used when selection is 1 embed
ODReleaseObject( ev, pInfo->fSelectedPart);
pInfo->fSelectedPart = embFrame->AcquirePart( ev);
pInfo->fSelPartFrame = embFrame;
TempODShape usedShape = ODCopyAndRelease(ev, embFrame->AcquireUsedShape(ev, kODNULL));
TempODTransform xform = embFacet->AcquireFrameTransform(ev, kODNULL);
usedShape->Transform(ev, xform);
usedShape->Subtract(ev, trackShape);
if (usedShape->IsEmpty(ev))
{
somSelf->SetFrameSelected(ev, embFrame, kODTrue);
Proxy* p = somSelf->ProxyForFrame(ev, embFrame);
_fSelection->AddFirst((ElementType)p);
}
}
if (_fSelection->Count())
{
somSelf->CreateProxySelectionBorder(ev);
somSelf->ClipSelectionFromEmbeddedFrames(ev, trackingFacet->GetFrame(ev));
somSelf->InvalidateSelection(ev, trackingFacet->GetFrame(ev));
}
break;
}
case kBotLeftResize:
case kTopLeftResize:
case kTopRightResize:
case kBotRightResize:
{
ODPoint ptNewEnd, ptSelMouse, ptOffset;
ODRect bbox;
ptNewEnd.x = localPoint.x - _ptMouseOffset.x;
ptNewEnd.y = localPoint.y - _ptMouseOffset.y;
Proxy* p = (Proxy*)_fSelection->First();
p->shape->GetBoundingBox(ev, &bbox);
ptSelMouse = ptNewEnd; // [137664]
p->transform->InvertPoint(ev, &ptSelMouse); // in selections frame coords
switch (_fTrackingMode)
{
case kBotLeftResize:
if(ptSelMouse.x > bbox.right || ptSelMouse.y > bbox.top) return kODTrue; // [124806]
bbox.right += (-ptSelMouse.x);
bbox.top += (-ptSelMouse.y);
ptOffset = ptSelMouse;
break;
case kTopLeftResize:
if(ptSelMouse.x > bbox.right || ptSelMouse.y < bbox.bottom) return kODTrue; // [124806]
bbox.right += (-ptSelMouse.x);
bbox.top = ptSelMouse.y;
ptOffset.x = ptSelMouse.x;
ptOffset.y = 0;
break;
case kTopRightResize:
if(ptSelMouse.x < bbox.left || ptSelMouse.y < bbox.bottom) return kODTrue; // [124806]
bbox.right = ptSelMouse.x;
bbox.top = ptSelMouse.y;
ptOffset.x = ptOffset.y = 0;
break;
case kBotRightResize:
if(ptSelMouse.x < bbox.left || ptSelMouse.y > bbox.top) return kODTrue; // [124806]
bbox.right = ptSelMouse.x;
bbox.top += (-ptSelMouse.y);
ptOffset.x = 0;
ptOffset.y = ptSelMouse.y;
break;
}
p->shape->SetRectangle(ev, &bbox);
ODxOrderedCollectionIterator i(_fEmbeddedFrames);
for (ODFrame* frame = (ODFrame*)i.First(); i.IsNotComplete(); frame = (ODFrame*)i.Next())
{
if (somSelf->ProxyForFrame(ev, frame) == p)
{
frame->ChangeFrameShape(ev, p->shape, kODNULL);
if (ptOffset.x || ptOffset.y)
{
TempODTransform xform = frame->CreateTransform(ev);
xform->SetOffset(ev, &ptOffset);
p->transform->PreCompose(ev, xform);
}
}
}
break;
}
}
somSelf->CreateProxySelectionBorder(ev);
somSelf->ClipEmbeddedFrames(ev, kODNULL);
somSelf->Invalidate(ev);
somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
}
SOM_CATCH_ALL
SOM_ENDTRY
return kODTrue;
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleButton1Up(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet,
ODFrame* frame,
ODPoint* where,
ODEventData* event)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleButton1Up");
SOM_TRY
if (_fMouseMode == kTracking &&
(_fTrackingMode == kRotateSelection ||
_fTrackingMode == kScaleSelection))
{
/*
* _fTrackingFacet is cleared in ResetMouseMode so save the pointer
*/
ODFacet* trackingFacet = _fTrackingFacet;
somSelf->ResetMouseMode(ev);
TempODTransform xform = trackingFacet->AcquireWindowContentTransform(ev, kODNULL);
ODPoint localPoint = *where; // [137664]
xform->InvertPoint(ev, &localPoint); // window to content coords
switch (_fTrackingMode)
{
case kScaleSelection:
{
ODPoint ptScale;
ptScale.x = (localPoint.x - _ptRef.x) / ((_ptOrigin.x - _ptRef.x) >> 16);
ptScale.y = (localPoint.y - _ptRef.y) / ((_ptOrigin.y - _ptRef.y) >> 16);
TempODTransform xScale = frame->CreateTransform(ev);
xScale->ScaleBy(ev,&ptScale);
Proxy* p;
ODxOrderedCollectionIterator iter(_fSelection);
for (p = (Proxy*) iter.First(); iter.IsNotComplete(); p = (Proxy*) iter.Next())
{
ODPoint ptNegRef(-_ptRef.x,-_ptRef.y);
p->transform->MoveBy(ev, &ptNegRef);
p->transform->PostCompose(ev, xScale);
p->transform->MoveBy(ev, &_ptRef);
}
break;
}
case kRotateSelection:
{
double theta;
ODFixed fxSin, fxCos;
ODMatrix m;
theta = CalcAngleRadians(_ptRef, localPoint) -
CalcAngleRadians(_ptRef, _ptOrigin);
fxSin = ODFloatToFixed(sin(theta));
fxCos = ODFloatToFixed(cos(theta));
TempODTransform rxform = trackingFacet->GetFrame(ev)->CreateTransform(ev);
rxform->GetMatrix(ev, &m);
m.m[0][0] = fxCos;
m.m[0][1] = fxSin;
m.m[1][0] = -fxSin;
m.m[1][1] = fxCos;
rxform->SetMatrix(ev, &m);
Proxy* p;
ODxOrderedCollectionIterator iter(_fSelection);
for (p = (Proxy*) iter.First(); iter.IsNotComplete(); p = (Proxy*) iter.Next())
{
ODPoint ptNegRef(-_ptRef.x,-_ptRef.y);
p->transform->MoveBy(ev, &ptNegRef);
p->transform->PostCompose(ev, rxform);
p->transform->MoveBy(ev, &_ptRef);
}
break;
}
}
somSelf->CreateProxySelectionBorder(ev);
somSelf->ClipEmbeddedFrames(ev, kODNULL);
somSelf->Invalidate(ev);
somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
}
SOM_CATCH_ALL
SOM_ENDTRY
return kODTrue;
}
SOM_Scope void SOMLINK ContainerPartUpdateTrackRect(ContainerPart *somSelf,
Environment *ev,
ODPoint* ptMouse,
ODFacet* facet,
TrackingUpdateMode updateMode)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartUpdateTrackRect");
SOM_TRY
HPS hps;
POINTL ptlOrigin = _ptOrigin.AsPOINTL(),
ptlEnd = _ptEnd.AsPOINTL(),
ptlMouse = ptMouse->AsPOINTL(),
ptlMouseOffset = _ptMouseOffset.AsPOINTL(),
ptlRef = _ptRef.AsPOINTL(),
ptl;
MATRIXLF mtx;
int i;
CFocusWindow f(ev, facet, (ODShape*)kODNULL, &hps, (HWND*)kODNULL, CFocusWindow::LockedWindowUpdatePS);
GpiSetMix(hps, FM_INVERT);
switch (_fTrackingMode)
{
case kBotLeftResize:
case kTopLeftResize:
case kTopRightResize:
case kBotRightResize:
{
ODPoint pt, ptSelEnd, ptSelMouse, ptSelMouseOffset, ptSelOrigin, ptSelRef;
FIXED afxScale[2];
int i;
Proxy* p = (Proxy*)_fSelection->First();
/* Adjust end-points for mouse offset */
ptSelEnd.x = _ptEnd.x - _ptMouseOffset.x;
ptSelEnd.y = _ptEnd.y - _ptMouseOffset.y;
ptSelOrigin.x = _ptOrigin.x - _ptMouseOffset.x;
ptSelOrigin.y = _ptOrigin.y - _ptMouseOffset.y;
ptSelMouse.x = ptMouse->x - _ptMouseOffset.x;
ptSelMouse.y = ptMouse->y - _ptMouseOffset.y;
/* convert end-points to selected frames local coords */
p->transform->InvertPoint(ev, &ptSelEnd); // [137664]
p->transform->InvertPoint(ev, &ptSelMouse); // [137664]
p->transform->InvertPoint(ev, &ptSelOrigin); // [137664]
ptSelRef = _ptRef; // [137664]
p->transform->InvertPoint(ev, &ptSelRef); // [137664]
POINTL ptlSelRef = ptSelRef.AsPOINTL();
for (i = 0, pt = ptSelEnd; i < 2; i++, pt = ptSelMouse)
{
if (pt.x != ptSelOrigin.x && pt.y != ptSelOrigin.y)
{
afxScale[0] = (pt.x - ptSelRef.x) /
((ptSelOrigin.x - ptSelRef.x) >> 16);
afxScale[1] = (pt.y - ptSelRef.y) /
((ptSelOrigin.y - ptSelRef.y) >> 16);
if (afxScale[0] <= 0 || afxScale[1] <= 0)
afxScale[0] = afxScale[1] = 0x10000;
p->transform->GetMATRIXLF(ev, &mtx);
GpiSetModelTransformMatrix(hps, 9, &mtx, TRANSFORM_REPLACE);
GpiScale(hps, &mtx, TRANSFORM_REPLACE, afxScale, &ptlSelRef);
GpiSetModelTransformMatrix(hps, 9, &mtx, TRANSFORM_PREEMPT);
somSelf->DrawPolygons(ev, hps);
}
}
}
break;
case kRubberBandSelection:
case kSelectScaleOrigin:
GpiSetLineType(hps, LINETYPE_SOLID);
GpiMove(hps, &ptlOrigin);
GpiBox(hps, DRO_OUTLINE, &ptlEnd, 0, 0);
GpiMove(hps, &ptlOrigin);
GpiBox(hps, DRO_OUTLINE, &ptlMouse, 0, 0);
break;
case kSelectRotateOrigin:
GpiSetLineType(hps, LINETYPE_SOLID);
if (updateMode == kUpdateModeStart || updateMode == kUpdateModeEnd)
{
ULONG ulHandleWidth = kSelectionHandleWidth >> 16;
ptl.x = ptlOrigin.x - ulHandleWidth / 2;
ptl.y = ptlOrigin.y - ulHandleWidth / 2;
GpiMove(hps, &ptl);
ptl.x += ulHandleWidth;
ptl.y += ulHandleWidth;
GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
}
for (i = 0, ptl = ptlEnd; i < 2; i++, ptl = ptlMouse)
{
double dx, dy, rad;
FIXED fxAngle;
ARCPARAMS arcparams;
dx = (double)(ptl.x - ptlOrigin.x);
dy = (double)(ptl.y - ptlOrigin.y);
rad = sqrt(dx*dx + dy*dy);
arcparams.lP = arcparams.lQ = rad;
arcparams.lR = arcparams.lS = 0;
GpiSetArcParams(hps, &arcparams);
fxAngle = CalcAngleDegrees(ptlOrigin, ptl);
GpiMove(hps, &ptlOrigin);
GpiPartialArc(hps, &ptlOrigin, 0x10000, fxAngle, MAKEFIXED(360,0));
}
break;
case kScaleSelection:
for (i = 0, ptl = ptlEnd;
i < ((updateMode == kUpdateModeContinue) ? 2 : 1);
i++, ptl = ptlMouse)
{
FIXED afxScale[2];
afxScale[0] = MAKEFIXED((ptl.x - ptlRef.x),0) / (ptlOrigin.x - ptlRef.x);
afxScale[1] = MAKEFIXED((ptl.y - ptlRef.y),0) / (ptlOrigin.y - ptlRef.y);
GpiScale(hps, &mtx, TRANSFORM_REPLACE, afxScale, &ptlRef);
GpiMove(hps, &ptlRef);
GpiSetLineWidth(hps, LINEWIDTH_NORMAL);
GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
GpiSetModelTransformMatrix(hps, 9, &mtx, TRANSFORM_REPLACE);
somSelf->DrawPolygons(ev, hps);
GpiSetModelTransformMatrix(hps, 9, &mtxIdentity, TRANSFORM_REPLACE);
}
break;
case kRotateSelection:
{
ARCPARAMS arcparams;
double dx, dy, rad, theta1, theta2;
dx = ptlOrigin.x - ptlRef.x;
dy = ptlOrigin.y - ptlRef.y;
rad = sqrt(dx*dx + dy*dy);
arcparams.lP = arcparams.lQ = rad;
arcparams.lR = arcparams.lS = 0;
GpiSetArcParams(hps, &arcparams);
if (updateMode == kUpdateModeStart || updateMode == kUpdateModeEnd)
{
ULONG ulHandleWidth = kSelectionHandleWidth >> 16;
GpiSetLineType(hps, LINETYPE_SOLID);
for (i = 0, ptl = ptlRef; i < 2; i++, ptl = ptlOrigin)
{
POINTL ptlCorner;
ptlCorner.x = ptl.x - ulHandleWidth / 2;
ptlCorner.y = ptl.y - ulHandleWidth / 2;
GpiMove(hps, &ptlCorner);
ptlCorner.x += ulHandleWidth;
ptlCorner.y += ulHandleWidth;
GpiBox(hps, DRO_OUTLINE, &ptlCorner, 0, 0);
}
GpiSetLineType(hps, LINETYPE_DASHDOT);
GpiMove(hps, &ptlRef);
GpiFullArc(hps, DRO_OUTLINE, 0x10000);
GpiMove(hps, &ptlRef);
GpiLine(hps, &ptlOrigin);
}
for (i = 0, ptl = ptlEnd;
i < ((updateMode == kUpdateModeContinue) ? 2 : 1);
i++, ptl = ptlMouse)
{
FIXED fxAngle;
POINTL ptlCurrentPos;
fxAngle = CalcAngleDegrees(ptlRef, ptl);
GpiMove(hps, &ptlRef);
GpiSetLineType(hps, LINETYPE_INVISIBLE);
GpiPartialArc(hps, &ptlRef, 0x10000, fxAngle, 0);
GpiQueryCurrentPosition(hps, &ptlCurrentPos);
if (ptlCurrentPos.x != ptlOrigin.x || ptlCurrentPos.y != ptlOrigin.y)
{
GpiSetLineType(hps, LINETYPE_DASHDOT);
GpiSetLineWidth(hps, LINEWIDTH_NORMAL);
GpiLine(hps, &ptlRef);
}
fxAngle = CalcAngleDegrees(ptlRef, ptl) - CalcAngleDegrees(ptlRef, ptlOrigin);
GpiRotate(hps, &mtx, TRANSFORM_REPLACE, fxAngle, &ptlRef);
GpiSetModelTransformMatrix(hps, 9, &mtx, TRANSFORM_REPLACE);
somSelf->DrawPolygons(ev, hps);
GpiSetModelTransformMatrix(hps, 9, &mtxIdentity, TRANSFORM_REPLACE);
}
break;
}
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartDrawPolygons(ContainerPart *somSelf,
Environment *ev,
HPS hps)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDrawPolygons");
GpiSetLineWidth(hps, LINEWIDTH_THICK);
GpiSetLineType(hps, LINETYPE_SOLID);
for (int i=0; i<_fNumPolygons; i++)
{
GpiMove(hps, &_fPolygons[i].aPointl[_fPolygons[i].ulPoints-1]);
GpiPolyLine(hps, _fPolygons[i].ulPoints, &_fPolygons[i].aPointl[0]);
}
}
SOM_Scope void SOMLINK ContainerPartMouseFocusLost(ContainerPart *somSelf,
Environment *ev,
ODFrame* ownerFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartMouseFocusLost");
SOM_TRY
if (_fMouseMode == kTracking)
{
TempODWindow window = ownerFrame->AcquireWindow(ev);
HWND hwndFrame = window->GetPlatformWindow(ev);
somSelf->UpdateTrackRect(ev, &_ptOrigin, _fTrackingFacet, kUpdateModeEnd);
_fTrackingFacet = kODNULL;
_fMouseMode = kNormal;
WinSetCapture(HWND_DESKTOP, 0);
WinLockWindowUpdate(HWND_DESKTOP, 0);
}
if (_fPolygons)
{
for (int i = 0; i < _fNumPolygons; i++)
delete[] _fPolygons[i].aPointl;
delete[] _fPolygons;
_fPolygons = kODNULL;
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandlePrinting(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame,
char *pszQueueName)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandlePrinting");
PHCINFO phcInfo = 0, phc = 0;
PPRQINFO3 pqi = 0;
char *pszTitle = 0;
SOM_TRY
ULONG ul, cReturned, cTotal, cbNeeded, cForms;
DEVOPENSTRUC dos;
LONG i, rc;
BOOL fResult, bOK;
CHAR szWork[LEN_WORKSTRING], *pch, achQueueName[QUEUENAME_LENGTH], achDriverName[DRIVERNAME_LENGTH],
achSpoolerParams[40], achQueueProcParams[8];
HWND hwndFrame = 0;
HAB hab = WinQueryAnchorBlock(HWND_DESKTOP);
HDC hdcPrinter, hdcPrinterInfo;
HPS hpsPrinter, hpsPrinterInfo;
SIZEL sizel;
PRNINFO prnInfo;
ODRect bounds;
TempODWindow window = frame->AcquireWindow(ev);
if (window)
hwndFrame = window->GetPlatformWindow(ev);
ODDocumentName title = somSelf->GetStorageUnit(ev)->GetDraft(ev) //[144299]
->GetDocument(ev)->GetContainer(ev)->GetName(ev);
if (title.text._length)
{
pszTitle = (char*)malloc(title.text._length + 1);
pszTitle = GetITextCString((ODIText *)&title, pszTitle); //[144299]
}
else
pszTitle = strdup("Untitled");
/*
* Get system default queue
*/
if (pszQueueName)
strncpy(achQueueName, pszQueueName, sizeof(achQueueName)-1);
else {
ul = PrfQueryProfileString (HINI_PROFILE, "PM_SPOOLER", "QUEUE", NULL, szWork, LEN_WORKSTRING);
if (ul) {
/* truncate queuename at terminating semicolon */
pch = strchr (szWork, ';');
if (pch) {
*pch = 0;
strcpy( achQueueName, szWork );
}
}
if (!achQueueName[0]) {
WinMessageBox( HWND_DESKTOP,
hwndFrame ? hwndFrame : HWND_DESKTOP,
"Error: No Default Print Queue",
pszTitle,
(USHORT)0,
MB_OK | MB_MOVEABLE | MB_CUAWARNING | MB_APPLMODAL);
free(pszTitle);
return kODFalse;
}
}
/* get queue settings including the driver data info */
SplQueryQueue("", achQueueName, 3, NULL, 0, &cbNeeded);
pqi = (PPRQINFO3)malloc(cbNeeded);
rc = SplQueryQueue("", achQueueName, 3, pqi, cbNeeded, &cbNeeded);
if (rc != 0) {
sprintf(szWork, "Error opening printer queue: %s", achQueueName);
WinMessageBox( HWND_DESKTOP,
hwndFrame ? hwndFrame : HWND_DESKTOP,
szWork,
pszTitle,
(USHORT)0,
MB_OK | MB_MOVEABLE | MB_CUAWARNING | MB_APPLMODAL);
free(pszTitle);
free(pqi);
return kODFalse;
}
/* Open an info device context and presentation space for the printer */
memset( &dos, 0, sizeof(dos));
memset( &sizel, 0, sizeof(sizel));
dos.pszLogAddress = achQueueName;
strcpy( achDriverName, pqi->pszDriverName);
achDriverName[strcspn(achDriverName, ".")] = '\0';
dos.pszDriverName = (PSZ)achDriverName;
dos.pdriv = pqi->pDriverData;
/* Create an OD_QUEUED device context and presentation space for the printer */
hdcPrinterInfo = DevOpenDC(hab, OD_INFO, "*", 3, (PDEVOPENDATA)&dos, 0);
hpsPrinterInfo = GpiCreatePS(hab, hdcPrinterInfo, (PSIZEL)&sizel, PU_PELS | GPIA_ASSOC);
/* Query available forms and use the currently selected form */
cForms = DevQueryHardcopyCaps( hdcPrinterInfo, 0, 0, 0);
phcInfo = (PHCINFO)malloc(sizeof(HCINFO) * cForms);
DevQueryHardcopyCaps( hdcPrinterInfo, 0, cForms, phcInfo);
/* Find the first currently selected form */
for (i=0; i< cForms; i++)
if (phcInfo[i].flAttributes & HCAPS_CURRENT) break;
phc = &phcInfo[i];
GpiAssociate(hpsPrinterInfo, 0);
GpiDestroyPS(hpsPrinterInfo);
DevCloseDC(hdcPrinterInfo);
/* determine the bounds of the root facet in OD coords */
bounds.left = bounds.bottom = 0;
bounds.right = ulmm2fxPt(phc->xRightClip - phc->xLeftClip);
bounds.top = ulmm2fxPt(phc->yTopClip - phc->yBottomClip);
/* Build the device context data for DevOpenDC */
sprintf(achQueueProcParams, "COP=%d", 1);
sprintf(achSpoolerParams, "FORM=%s", phc->szFormname);
memset( &dos, 0, sizeof(dos));
dos.pszLogAddress = achQueueName;
strcpy( achDriverName, pqi->pszDriverName);
achDriverName[strcspn(achDriverName, ".")] = '\0';
dos.pszDriverName = (PSZ)achDriverName;
dos.pdriv = pqi->pDriverData;
dos.pszDataType = "PM_Q_STD";
dos.pszComment = pszTitle;
dos.pszQueueProcParams = achQueueProcParams;
dos.pszSpoolerParams = achSpoolerParams;
hdcPrinter = DevOpenDC( hab, OD_QUEUED, "*", 9, (PDEVOPENDATA)&dos, 0);
hpsPrinter = GpiCreatePS( hab, hdcPrinter, &sizel, PU_PELS | GPIA_ASSOC);
DevEscape(hdcPrinter, DEVESC_STARTDOC, strlen(pszTitle), pszTitle, 0, 0);
prnInfo.hps = hpsPrinter;
prnInfo.hdc = hdcPrinter;
prnInfo.phcInfo = phc;
prnInfo.bounds = bounds;
prnInfo.printDest.cb = sizeof(PRINTDEST);
prnInfo.printDest.lType = OD_QUEUED;
prnInfo.printDest.pszToken = "*";
prnInfo.printDest.pdopData = (PDEVOPENDATA)&dos;
prnInfo.printDest.fl = 0;
prnInfo.printDest.pszPrinter = pqi->pszPrinters;
somSelf->PrintPages(ev, frame, &prnInfo);
DevEscape( hdcPrinter, DEVESC_ENDDOC, 0, 0, 0, 0);
GpiAssociate(hpsPrinter, 0);
GpiDestroyPS(hpsPrinter);
DevCloseDC(hdcPrinter);
/* free the buffer allocated for SplEnumQueue call */
free(phcInfo);
free(pqi);
free(pszTitle);
SOM_CATCH_ALL
if (phcInfo) free(phcInfo);
if (pqi) free(pqi);
if (pszTitle) free(pszTitle);
SOM_ENDTRY
return kODTrue;
}
SOM_Scope ODFacet* SOMLINK ContainerPartBeginPrinting(ContainerPart *somSelf,
Environment *ev,
ODFrame* prFrame,
PRNINFO* pPI)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartBeginPrinting");
ODFacet* prFacet = kODNULL;
SOM_TRY
TempODTransform xtransform = prFrame->CreateTransform(ev);
TempODShape clipshape = prFrame->CreateShape(ev);
clipshape->SetRectangle(ev, &pPI->bounds);
prFacet = _fSession->GetWindowState(ev)->
CreateFacet(ev, prFrame, clipshape, xtransform, kODNULL, kODNULL);
ODPlatformCanvas* platformCanvas = prFacet->CreatePlatformCanvas(ev, pPI->hps);
ODCanvas* prCanvas = prFacet->CreateCanvas(ev, kODGPI,
platformCanvas, kODFalse, kODFalse);
prCanvas->SetPlatformPrintJob(ev, kODGPI, &pPI->printDest);
prFacet->ChangeCanvas(ev, prCanvas);
prFrame->FacetAdded(ev, prFacet);
SOM_CATCH_ALL
prFacet = kODNULL;
SOM_ENDTRY
return prFacet;
}
SOM_Scope void SOMLINK ContainerPartPrintPage(ContainerPart *somSelf,
Environment *ev,
ODFacet* prFacet,
ODUShort pagenum,
PRNINFO* pPI)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartPrintPage");
SOM_TRY
ODRect bbox;
TempODShape frameShape = prFacet->GetFrame(ev)->AcquireFrameShape(ev, kODNULL);
frameShape->GetBoundingBox(ev, &bbox);
ODULong height = bbox.top;
ODULong width = bbox.right;
ODPoint scale(0,0);
ODPoint offset(0,0);
ODUShort locator = pagenum-1;
/**************************************************************************/
/* Calculate scaling factor for extenal transform of root facet. Scale */
/* calcualted using the following formula (for the x factor): */
/* */
/* (pel) xPels (pel) 25.4 (mm/inch) */
/* scaling factor ----- = ------------------------ ----- * ---- --------- */
/* (pt) (xRightClip - xLeftClip) (mm) 72.0 (pt/inch) */
/* */
/**************************************************************************/
scale.x = (ODCoordinate)((float)pPI->phcInfo->xPels
/ (float)(pPI->phcInfo->xRightClip -
pPI->phcInfo->xLeftClip)
* 25.4 / 72.0 * 65536.0);
scale.y = (ODCoordinate)((float)pPI->phcInfo->yPels
/ (float)(pPI->phcInfo->yTopClip -
pPI->phcInfo->yBottomClip)
* 25.4 / 72.0 * 65536.0);
while (locator) {
offset.y += (pPI->bounds.top);
locator--;
if (PtInRect(offset,bbox))
continue;
else {
offset.y = 0;
offset.x += (pPI->bounds.right + 1);
}
}
offset.y = bbox.top - offset.y - pPI->bounds.top;
TempODTransform xtransform = prFacet->CreateTransform(ev);
TempODShape clipshape = prFacet->CreateShape(ev);
clipshape->SetRectangle(ev, &pPI->bounds);
xtransform->SetOffset(ev, &offset);
clipshape->Transform(ev, xtransform);
clipshape->Intersect(ev, frameShape);
TempODShape invalshape = clipshape->Copy(ev);
xtransform->Invert(ev);
xtransform->ScaleBy(ev, &scale);
prFacet->ChangeGeometry(ev, clipshape, xtransform, kODNULL);
prFacet->Update(ev, invalshape, kODNULL);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope long SOMLINK ContainerPartPrintPages(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame,
PRNINFO* pPI)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartPrintPages");
SOM_TRY
ODUShort
firstPage,
lastPage,
realNumberOfPagesinDoc,
pageNumber;
ODFacet* prFacet;
ODFrame* prFrame;
ODBoolean shouldCloseFrame;
realNumberOfPagesinDoc = DetermineNumberOfPagesinDoc(ev, frame, pPI->bounds );
//numberOfCopies = 1;
firstPage = 1;
lastPage = realNumberOfPagesinDoc;
if (realNumberOfPagesinDoc < lastPage)
lastPage = realNumberOfPagesinDoc;
TempODFrameFacetIterator facets = frame->CreateFacetIterator(ev);
ODFacet* facet = facets->First(ev);
if (facet) // If this frame already has a facet, create another frame for printing
{ // to allow formatting for printer without affecting on-screen display [142798] - ced
TempODShape frameShape = ODCopyAndRelease(ev, frame->AcquireFrameShape( ev, kODNULL )); // [121801]
prFrame = somSelf->GetStorageUnit(ev)->GetDraft(ev)-> // [139790]
CreateFrame(ev,
kODNonPersistentFrameObject,
kODNULL,
frameShape,
kODNULL,
_fPartWrapper,
frame->GetViewType(ev),
frame->GetPresentation(ev),
kODTrue,
kODFalse);
TempODPart tempPart = prFrame->AcquirePart(ev);
tempPart->AttachSourceFrame(ev, prFrame, frame);
shouldCloseFrame = kODTrue;
}
else
{
prFrame = frame;
shouldCloseFrame = kODFalse;
}
prFacet = somSelf->BeginPrinting(ev, prFrame, pPI);
pageNumber = firstPage;
while (pageNumber <= lastPage /*&& PrError() == noErr*/)
{
LONG lOut=0;
LONG rc = 0;
somSelf->PrintPage(ev, prFacet, pageNumber, pPI);
if (pageNumber != lastPage) // [145808]
{
DevEscape( pPI->hdc, DEVESC_NEWFRAME, 0, 0, 0, 0 );
}
pageNumber++;
}
somSelf->EndPrinting(ev, prFacet);
if (shouldCloseFrame)
prFrame->Close(ev);
SOM_CATCH_ALL
SOM_ENDTRY
return 0; // no error
}
SOM_Scope void SOMLINK ContainerPartEndPrinting(ContainerPart *somSelf,
Environment *ev,
ODFacet* prFacet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartEndPrinting");
SOM_TRY
ODCanvas* prCanvas = prFacet->GetCanvas(ev);
ODFrame* prFrame = prFacet->GetFrame(ev);
prFrame->FacetRemoved(ev, prFacet);
delete prCanvas;
delete prFacet;
SOM_CATCH_ALL
SOM_ENDTRY
}
ODUShort DetermineNumberOfPagesinDoc(Environment* ev, ODFrame* frame, ODRect page)
{
ODRect bbox;
ODShape* frameShape = frame->AcquireFrameShape(ev, kODNULL);
frameShape->GetBoundingBox(ev, &bbox);
frameShape->Release(ev); frameShape = kODNULL;
ODSLong height = bbox.top-bbox.bottom;
ODSLong width = bbox.right-bbox.left;
ODUShort pages = 0;
ODSLong wt = width;
while (wt > 0)
{
ODSLong ht = height;
while (ht > 0)
{
ht -= (page.top-page.bottom);
pages++;
}
wt -= (page.right-page.left);
}
return pages;
}
SOM_Scope ODBoolean SOMLINK ContainerPartDoCut(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDoCut");
ODBoolean result = kODFalse;
SOM_TRY
result = somSelf->CloneSelectionToClipboard( ev, frame, kODCloneCut );
if (result)
somSelf->DoClear( ev, frame);
SOM_CATCH_ALL
SOM_ENDTRY
return kODTrue;
}
SOM_Scope ODBoolean SOMLINK ContainerPartDoCopy(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDoCopy");
ODBoolean result = kODFalse;
SOM_TRY
result = somSelf->CloneSelectionToClipboard( ev, frame, kODCloneCopy );
SOM_CATCH_ALL
SOM_ENDTRY
return result;
}
SOM_Scope ODBoolean SOMLINK ContainerPartCloneSelectionToClipboard(ContainerPart *somSelf,
Environment *ev,
ODFrame* ownerFrame,
ODCloneKind cloneKind)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCloneSelectionToClipboard");
ODBoolean result = kODTrue;
SOM_TRY
ODFrame* embFrame; // contains embedded frames
ODClipboard* clipboard = _fSession->GetClipboard(ev);
ODArbitrator *arbitrator = _fSession->GetArbitrator( ev );
ODTypeToken clipboardFocus = _fSession->Tokenize( ev, kODClipboardFocus );
if (arbitrator->RequestFocus( ev, clipboardFocus, ownerFrame ))
{
// Container part currently supports copying only a single selected
// frame to the clipboard. For multiple selection, we should create
// a root frame of our part kind with our selection embedded in it
// and put that frame on the clipboard. For now, we only enable Copy
// and Cut for single selection.
clipboard->Clear( ev );
// Find selected frame
ODFrame* embFrame = somSelf->FrameFromProxyForContainingFrame(ev,
(Proxy*)_fSelection->First(), ownerFrame);
// gets root su for clipboard
if (embFrame)
{
ODStorageUnit* clipRootSU = clipboard->GetContentStorageUnit(ev);
ODDraft* fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
ODDraft* toDraft = clipRootSU->GetDraft(ev);
ODDraftKey key = 0;
// modify clipboard
key = fromDraft->BeginClone(ev, toDraft, kODNULL, cloneKind);
// when transfering frame, add content frame property
clipRootSU->AddProperty(ev, kODPropContentFrame);
TempODPart selectedPart = embFrame->AcquirePart(ev);
selectedPart->CloneInto( ev, key, clipRootSU, embFrame);
clipRootSU->AddProperty(ev, kODPropFrameShape);
TempODShape tempShape = embFrame->AcquireFrameShape( ev, kODNULL);
tempShape->WriteShape(ev, clipRootSU);
fromDraft->EndClone(ev, key);
key = kODNULL;
}
clipboard->ExportClipboard( ev);
arbitrator->RelinquishFocus( ev, clipboardFocus, ownerFrame );
somSelf->DisplayStatusLineText(ev,"To Paste, activate frame, then select Paste from Menu Bar", ownerFrame);
}
SOM_CATCH_ALL
SOM_ENDTRY
return result;
}
SOM_Scope ODBoolean SOMLINK ContainerPartAllowPaste(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartAllowPaste");
ODBoolean result = kODFalse;
SOM_TRY
// [140007] :
ODClipboard* clipboard = _fSession->GetClipboard(ev);
result = clipboard->CanEmbed(ev);
SOM_CATCH_ALL
SOM_ENDTRY
return result;
}
SOM_Scope void SOMLINK ContainerPartPasteFrameFromClipboard(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet,
ODPoint* where)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartPasteFrameFromClipboard");
SOM_TRY
ODTransform *newExternalXForm;
ODFrame *frame = facet->GetFrame(ev);
ODFrame *newFrame = kODNULL;
ODShape *newFrameShape;
ODFrame *newFrame2 = kODNULL;
_fMouseMode = kNormal;
somSelf->FreezeEmbeddedFrames(ev, kODFalse);
_fPasteOn = kODFalse;
_fPasteESC = kODFalse;
ODTransform *contentXform = facet->AcquireWindowContentTransform(ev,
facet->GetCanvas(ev));
ODPoint pastePoint = *where; // [137664]
contentXform->InvertPoint(ev, &pastePoint);
ODReleaseObject(ev, contentXform);
ODArbitrator *arbitrator = _fSession->GetArbitrator( ev );
ODTypeToken clipboardFocus = _fSession->Tokenize( ev, kODClipboardFocus );
arbitrator->RequestFocus( ev, clipboardFocus, frame );
ODClipboard* clipboard = _fSession->GetClipboard(ev);
ODDraft* theDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
ODDraft* fromDraft = kODNULL;
ODDraftKey key = kODNULL;
TRY
ODStorageUnit* su = clipboard->GetContentStorageUnit(ev);
fromDraft = su->GetDraft( ev );
ODID newPartID;
key = fromDraft->BeginClone(ev, theDraft, kODNULL, kODClonePaste);
newPartID = fromDraft->Clone(ev, key, su->GetID(ev), 0, 0);
fromDraft->EndClone(ev, key);
key = kODNULL;
// using temp variable because memory gets freed
// when we go out of scope
ODPoint newTransPt = *where;
newTransPt.x = pastePoint.x;
newTransPt.y = pastePoint.y;
// xtransform
newExternalXForm = new ODTransform;
newExternalXForm->MoveBy(ev, &newTransPt );
if (su->Exists(ev, kODPropFrameShape, kODNULL, 0))
{
su->Focus(ev, kODPropFrameShape, kODPosUndefined, kODNULL, 1,
kODPosUndefined);
newFrameShape = facet->CreateShape(ev);
newFrameShape->ReadShape(ev, su);
}
else
{
newFrameShape = kODNULL; // use default size {80,80}
} /* endif */
ODPart *newPart = theDraft->AcquirePart(ev, newPartID);
Proxy* p = somSelf->CreateProxyObject(ev,
newFrameShape,
newExternalXForm,
newPart,
kODFalse);
newPart->Release(ev);
CATCH_ALL
if (key!=kODNULL)
{
fromDraft->AbortClone(ev, key);
clipboard->Clear( ev );
} /* endif */
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Clipboard error!",
NULL, 0, MB_ENTER | MB_ERROR);
ENDTRY
clipboard->Clear( ev );
arbitrator->RelinquishFocus( ev, clipboardFocus, frame );
SOM_CATCH_ALL
SOM_ENDTRY
}
/****
***** 128682 - faa - ends
****/
SOM_Scope ODBoolean SOMLINK ContainerPartDoPaste(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDoPaste");
return kODFalse;
}
SOM_Scope ODBoolean SOMLINK ContainerPartDoPasteLink(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDoPasteLink");
return kODFalse;
}
SOM_Scope ODBoolean SOMLINK ContainerPartDoDeSelectAll(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDoDeSelectAll");
SOM_TRY
if (frame && frame == _fSelectionFrame)
{
TempODFrame activeFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
if (frame == activeFrame)
somSelf->InvalidateSelection(ev, frame);
somSelf->UnClipSelectionFromEmbeddedFrames(ev, frame);
somSelf->EmptySelection(ev);
}
SOM_CATCH_ALL
SOM_ENDTRY
return kODTrue;
}
SOM_Scope ODBoolean SOMLINK ContainerPartDoClear(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDoClear");
SOM_TRY
if (frame == _fSelectionFrame)
{
Proxy* p;
ODULong seqnum;
ODULong frgrp;
ODxOrderedCollectionIterator i(_fSelection);
/* copy the selection list */
ODxOrderedCollection s;
for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
s.AddLast(p);
somSelf->InvalidateSelection(ev, frame);
somSelf->EmptySelection(ev);
ODxOrderedCollectionIterator iter(&s);
for (p = (Proxy*) iter.First(); iter.IsNotComplete(); p = (Proxy*) iter.Next())
{
somSelf->RemoveProxyObject(ev, p);
}
somSelf->ClipEmbeddedFrames(ev, kODNULL);
somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
// clear the undo actions list Defect 122707
ODUndo * theUndo = _fSession->GetUndo(ev);
theUndo->ClearActionHistory (ev,kODRespectMarks);
}
SOM_CATCH_ALL
SOM_ENDTRY
return kODTrue;
}
SOM_Scope ODBoolean SOMLINK ContainerPartDoSelectAll(ContainerPart *somSelf,
Environment *ev,
ODFrame* ContFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDoSelectAll");
SOM_TRY
ODFrame* embFrame; // contains embedded frames
USHORT NumSelected = 0;
if (_fSelectionFrame != ContFrame)
somSelf->DoDeSelectAll(ev, _fSelectionFrame);
ODxOrderedCollectionIterator i(_fEmbeddedFrames);
for (embFrame = (ODFrame*) i.First();
i.IsNotComplete();
embFrame = (ODFrame*) i.Next() )
{
TempODFrame contFrame = embFrame->AcquireContainingFrame(ev);
if (contFrame == ContFrame)
{
Proxy* p = somSelf->ProxyForFrame(ev, embFrame);
somSelf->SetFrameSelected(ev, embFrame, kODTrue);
_fSelection->AddFirst(ElementType(p));
}
}
somSelf->CreateProxySelectionBorder(ev);
somSelf->ClipSelectionFromEmbeddedFrames(ev, ContFrame);
somSelf->InvalidateSelection(ev, ContFrame);
SOM_CATCH_ALL
SOM_ENDTRY
return kODTrue;
}
SOM_Scope ODBoolean SOMLINK ContainerPartActivateFrame(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartActivateFrame");
ODBoolean succeeded = kODFalse;
SOM_TRY
succeeded = _fSession->GetArbitrator(ev)->RequestFocusSet(ev, _fFocusSet,frame);
if (succeeded)
somSelf->PartActivated(ev, frame);
SOM_CATCH_ALL
succeeded = kODFalse;
SOM_ENDTRY
return succeeded;
}
SOM_Scope void SOMLINK ContainerPartPartActivated(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartPartActivated");
// Display our menu bar.
_fMenuBar->Display(ev);
// And set our "active" state.
PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
pInfo->fIsActive = kODTrue;
if (frame == _fSelectionFrame)
somSelf->ShowSelection(ev, frame, kODTrue);
}
SOM_Scope void SOMLINK ContainerPartActivatingWindow(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartActivatingWindow");
SOM_TRY
PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
if (pInfo->fNeedsActivating)
{
somSelf->ActivateFrame(ev, frame);
//somSelf->ShowPalette(ev);
pInfo->fNeedsActivating = kODFalse;
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartDeActivatingWindow(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDeActivatingWindow");
SOM_TRY
PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
TempODFrame tempFrame =
_fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
if (frame == tempFrame)
{
pInfo->fNeedsActivating = kODTrue;
if (_fMouseMode != kNormal)
somSelf->ResetMouseMode(ev);
}
else
pInfo->fNeedsActivating = kODFalse;
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartInstallMenus(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartInstallMenus");
SOM_TRY
HMODULE hmod = NULLHANDLE;
HWND hwndMenu = NULLHANDLE;
HWND hwndMenu2 = NULLHANDLE;
HWND hwndMoveSubmenu = NULLHANDLE;
ODPlatformMenuItem mi;
ODACCEL PartAccel;
memset((PCH)&PartAccel, 0, sizeof(ODACCEL));
//load up our background color menu
hwndMenu = WinLoadMenu(HWND_OBJECT,
_hmod,
RESID_BACKGROUNDMENU);
_fMenuBar->AddMenuLast(ev, RESID_BACKGROUNDMENU, hwndMenu, somSelf);
_fMenuBar->SetMenuItemText(ev, RESID_BACKGROUNDMENU, kODNULL, "Background");
memset((PCH)&mi, 0, sizeof(MENUITEM));
mi.id = IDMA_TOGGLE_GRID;
mi.afStyle = MIS_TEXT;
_fMenuBar->AddMenuItemLast(ev, IDMS_VIEW, kODNULL, &mi);
_fMenuBar->SetMenuItemText(ev, IDMS_VIEW, IDMA_TOGGLE_GRID, "Grid on");
memset((PCH)&mi, 0, sizeof(MENUITEM));
mi.id = ID_SEPARATOR;
mi.afStyle = MIS_SEPARATOR;
_fMenuBar->AddMenuItemLast(ev, IDMS_EDIT, kODNULL, &mi);
memset((PCH)&mi, 0, sizeof(MENUITEM));
mi.id = IDMA_SCALE;
mi.afStyle = MIS_TEXT;
_fMenuBar->AddMenuItemLast(ev, IDMS_EDIT, kODNULL, &mi);
_fMenuBar->SetMenuItemText(ev, IDMS_EDIT, IDMA_SCALE, "Scale");
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_SCALE, kODFalse);
memset((PCH)&mi, 0, sizeof(MENUITEM));
mi.id = IDMA_ROTATE;
mi.afStyle = MIS_TEXT;
_fMenuBar->AddMenuItemLast(ev, IDMS_EDIT, kODNULL, &mi);
_fMenuBar->SetMenuItemText(ev, IDMS_VIEW, IDMA_ROTATE, "Rotate");
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_ROTATE, kODFalse);
memset((PCH)&mi, 0, sizeof(MENUITEM));
mi.id = IDMA_PRINT;
mi.afStyle = MIS_TEXT;
_fMenuBar->AddMenuItemLast(ev, IDMS_VIEW, kODNULL, &mi);
_fMenuBar->SetMenuItemText(ev, IDMS_VIEW, IDMA_PRINT, "Print part");
memset((PCH)&mi, 0, sizeof(MENUITEM));
mi.id = ID_SEPARATOR;
mi.afStyle = MIS_SEPARATOR;
_fMenuBar->AddMenuItemLast(ev, IDMS_HELP, kODNULL, &mi);
memset((PCH)&mi, 0, sizeof(MENUITEM));
mi.id = IDMA_PARTINFO;
mi.afStyle = MIS_TEXT;
_fMenuBar->AddMenuItemLast(ev, IDMS_HELP, kODNULL, &mi);
_fMenuBar->SetMenuItemText(ev, IDMS_HELP, IDMA_PARTINFO,"~Container part information");
memset((PCH)&mi, 0, sizeof(MENUITEM));
mi.id = IDMA_MOVE;
mi.afStyle = MIS_TEXT;
_fMenuBar->AddMenuItemLast(ev, IDMS_EDIT, kODNULL, &mi);
_fMenuBar->SetMenuItemText(ev, IDMS_EDIT, IDMA_MOVE,"Move");
//now we'll add a submenu to EDIT->MOVE
hwndMoveSubmenu = WinLoadMenu(HWND_OBJECT,
_hmod,
RESID_ARRANGE);
_fMenuBar->InsertSubmenu(ev, IDMS_EDIT, IDMA_MOVE, hwndMoveSubmenu);
//now lets add an accelerator table for our MOVE menu items.
//This can also be done by defining an accelerator table in the resource
//file, loading it in, copying it to an ACCELTABLE structure and copying
//the ACCEL items in the table to an ODACCEL structure. Then you can use
//a FOR loop for copying. Since we only have 4 accelerators to add, we
//will construct our ODACCEL structure like this.
PartAccel.aAccel[0].fs = AF_SHIFT | AF_VIRTUALKEY;
PartAccel.aAccel[0].key = VK_UP;
PartAccel.aAccel[0].cmd = IDMA_MOVETOFRONT;
PartAccel.aAccel[1].fs = AF_SHIFT | AF_VIRTUALKEY;
PartAccel.aAccel[1].key = VK_DOWN;
PartAccel.aAccel[1].cmd = IDMA_MOVETOBACK;
PartAccel.aAccel[2].fs = AF_ALT | AF_VIRTUALKEY;
PartAccel.aAccel[2].key = VK_UP;
PartAccel.aAccel[2].cmd = IDMA_MOVEFORWARD;
PartAccel.aAccel[3].fs = AF_ALT | AF_VIRTUALKEY;
PartAccel.aAccel[3].key = VK_DOWN;
PartAccel.aAccel[3].cmd = IDMA_MOVEBACKWARD;
_fMenuBar->AddToAccelTable(ev, 4, &PartAccel);
//insert our print item - on the popup menu
memset((PCH)&mi, 0, sizeof(MENUITEM));
mi.id = IDMA_PRINT;
mi.afStyle = MIS_TEXT;
_fPopup->AddMenuItemLast(ev, kODNULL, kODNULL, &mi);
_fPopup->SetMenuItemText(ev, kODNULL, IDMA_PRINT, "Print part");
_fPopup->AddDefaultMenuItemBefore(ev,
EDIT_DELETE,
IDMA_PRINT);
// *********************************************************************
// *** 130083 - set statusline text for menu items ******
// *********************************************************************
int id []= { IDMA_SCALE, IDMA_ROTATE,IDMA_PARTINFO, EDIT_SELPROPERTIES,
IDMA_COLOR_GRAY , IDMA_COLOR_BLUE ,IDMA_PRINT, EDIT_SEL_SAFRAME,
RESID_BACKGROUNDMENU,
IDMA_MOVETOFRONT,IDMA_MOVETOBACK,IDMA_MOVEFORWARD,IDMA_MOVEBACKWARD,
IDMA_COLOR_RED , IDMA_COLOR_MAGENTA,
IDMA_COLOR_GREEN , IDMA_COLOR_CYAN , EDIT_SEL_SASMALLICON,
EDIT_SEL_SALARGEICON, EDIT_SEL_SATHUMBNAIL,EDIT_SEL_SHOWAS,
IDMA_COLOR_YELLOW , IDMA_COLOR_WHITE , EDIT_OPENSEL };
int *p = id; // ptr to array of menu items having statusline text.
char string[256];
while(*p) {
USHORT rc = WinLoadString( (HAB)0,_hmod,(*p),255,string);// read string table
if (rc) { // have sting to load
_fMenuBar->SetMenuItemStatusText(ev,*p,string);
} /* endif */
(*p++);
} // endwhile
// end 130083 stuff
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartRemoveMenus(ContainerPart *somSelf,
Environment *ev,
ODFrame* aFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartRemoveMenus");
}
SOM_Scope void SOMLINK ContainerPartUserSetBGColor(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame,
long whichColor)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartUserSetBGColor");
SOM_TRY
if (whichColor != _fBGColor)
{
ODIText* undoActionName;
ODIText* redoActionName;
undoActionName = CreateITextCString(0,0,"Undo Set Color");
redoActionName = CreateITextCString(0,0,"Redo Set Color");
SetBGColorRec* undoRec = new SetBGColorRec(_fBGColor, whichColor,
frame);
ODActionData *undoer = (ODActionData *)CreateByteArray(undoRec, sizeof(SetBGColorRec));
ODUndo * theUndo = _fSession->GetUndo(ev);
theUndo->AddActionToHistory(ev, somSelf, undoer,
kODSingleAction,
(ODName*)undoActionName,
(ODName*)redoActionName);
DisposeByteArray(undoer); // remove byte array
somSelf->SetBGColor2(ev, frame, whichColor);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope long SOMLINK ContainerPartGetBGColor(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
/* ContainerPartMethodDebug("ContainerPart","ContainerPartGetBGColor"); */
return _fBGColor;
}
SOM_Scope void SOMLINK ContainerPartSetBGColor1(ContainerPart *somSelf,
Environment *ev,
ODFrame* aFrame,
long whichColor) //@127858
//@127858 ODUShort whichColor)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartSetBGColor1");
SOM_TRY
PartInfoRec* pInfo = (PartInfoRec *) aFrame->GetPartInfo(ev);
if (!pInfo)
{ pInfo = new PartInfoRec;
aFrame->SetPartInfo(ev, (ODInfoType) pInfo);
};
somSelf->UserSetBGColor(ev, aFrame,whichColor);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartSetBGColor2(ContainerPart *somSelf,
Environment *ev,
ODFrame* aFrame,
long whichColor)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartSetBGColor2");
SOM_TRY
if (whichColor != _fBGColor)
{
_fBGColor = whichColor;
somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
aFrame->Invalidate(ev, NULL, kODNULL);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartEmbed(ContainerPart *somSelf,
Environment *ev,
short item, ODFrame* frame,
ODPart** newPart)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartEmbed");
}
SOM_Scope Proxy* SOMLINK ContainerPartCreateProxyObject(ContainerPart *somSelf,
Environment *ev,
ODShape* frameShape,
ODTransform* externalTransform,
ODPart* embedPart,
ODBoolean isOverlaid)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCreateProxyObject");
Proxy* p = kODNULL;
SOM_TRY
ODxOrderedCollectionIterator dispFrames(_fDisplayFrames);
ODShape* newShape = kODNULL;
// decide what newShape should be - for now, give it what it asked for
if (frameShape)
{
newShape = frameShape;
newShape->Acquire(ev);
}
else
{ // no frameShape specified, use a default size
ODRect rect(0, MAKEFIXED(200,0), MAKEFIXED(200,0), 0);
newShape = ((ODFrame*)dispFrames.First())->CreateShape(ev);
newShape->SetRectangle(ev, &rect);
};
externalTransform->Acquire(ev);
embedPart->Acquire(ev);
p = new Proxy(externalTransform, newShape, embedPart);
_fContents->AddFirst(p);
// create the new frame
// kODNullTypeToken
for (ODFrame* dispFrame = (ODFrame*)dispFrames.First();
dispFrames.IsNotComplete();
dispFrame = (ODFrame*)dispFrames.Next())
{
ODFrame* newFrame = somSelf->MakeEmbeddedFrame(ev, dispFrame, p, isOverlaid);
ODReleaseObject(ev, newFrame);
}
if (somSelf->NormalizeProxyGeometry(ev, p))
somSelf->SetProxyFrameShapes(ev, p);
SOM_CATCH_ALL
SOM_ENDTRY
return p;
}
SOM_Scope ODFrame* SOMLINK ContainerPartMakeEmbeddedFrame(ContainerPart *somSelf,
Environment *ev,
ODFrame* containingFrame,
Proxy* p,
ODBoolean isOverlaid)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartMakeEmbeddedFrame");
ODFrame* newFrame = kODNULL;
SOM_TRY
newFrame = somSelf->GetStorageUnit(ev)->GetDraft(ev)->
CreateFrame(ev,
(containingFrame->GetStorageUnit(ev)) ? kODFrameObject :
kODNonPersistentFrameObject,
containingFrame, p->shape, (ODCanvas*)kODNULL,
p->part,
_fSession->Tokenize(ev, kODViewAsFrame),
_fSession->Tokenize(ev, kODPresDefault),
kODFalse, isOverlaid);
newFrame->Acquire(ev);
_fEmbeddedFrames->AddFirst(newFrame);
p->AddFirst(newFrame);
newFrame->SetPropagateEvents(ev, kODTrue);
TempODFrameFacetIterator facets = containingFrame->CreateFacetIterator(ev);
for (ODFacet* facet = facets->First(ev);
facets->IsNotComplete(ev);
facet = facets->Next(ev))
{
ODFacet* newFacet = facet->CreateEmbeddedFacet(ev,
newFrame,
p->shape,
p->transform,
kODNULL,
kODNULL,
kODNULL,
kODFrameInFront);
ODHighlight highlight = facet->GetHighlight(ev);
if( highlight != kODNoHighlight)
newFacet->ChangeHighlight(ev, highlight);
}
somSelf->ClipEmbeddedFrames(ev, containingFrame);
newFrame->Invalidate(ev, kODNULL, kODNULL);
_fNeedToExternalize = kODTrue;
SOM_CATCH_ALL
SOM_ENDTRY
return newFrame;
}
SOM_Scope ODWindow* SOMLINK ContainerPartCreateWindow(ContainerPart *somSelf,
Environment *ev,
ODFrame* sourceFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCreateWindow");
ODWindow* window = kODNULL;
SOM_TRY
Rect windRect;
ODPlatformWindow platformWindow = kODNULL;
// need to check if root frame
if (sourceFrame && !sourceFrame->IsRoot(ev)) {
SWP swp;
swp.x = 100;
swp.y = 100;
swp.cx = 400;
swp.cy = 400;
platformWindow = _fSession->CreatePlatformWindow(ev, ODPlatformWindowDefaultCreateOptions | FCF_HORZSCROLL | FCF_VERTSCROLL);
WinSetWindowPos(platformWindow, HWND_TOP,
swp.x, swp.y, swp.cx, swp.cy,
SWP_SIZE | SWP_MOVE);
} else {
platformWindow = _fSession->CreatePlatformWindow(ev, ODPlatformWindowDefaultCreateOptions);
} /* endif */
window = _fSession->GetWindowState(ev)->
RegisterWindow(ev, platformWindow,
kODFrameObject,
(sourceFrame==kODNULL), // is root
kODTrue, // Is resizable
kODFalse, // Is floating
kODTrue, // should save
kODTrue, // should dispose
_fPartWrapper,
_fSession->Tokenize(ev, kODViewAsFrame),
_fSession->Tokenize(ev, kODPresDefault),
sourceFrame);
SOM_CATCH_ALL
SOM_ENDTRY
return window;
}
SOM_Scope ODBoolean SOMLINK ContainerPartMoveToFront(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartMoveToFront");
SOM_TRY
if (_fSelection->Count() == 1 && frame == _fSelectionFrame)
{
ODxOrderedCollectionIterator i(_fSelection);
Proxy* p = (Proxy*) i.First();
_fContents->Remove(p);
_fContents->AddFirst(p);
ODxOrderedCollectionIterator dispFrames(_fDisplayFrames);
for (ODFrame* dispFrame = (ODFrame*)dispFrames.First();
dispFrames.IsNotComplete();
dispFrame = (ODFrame*)dispFrames.Next())
{
ODFrame* moveFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, dispFrame);
ODxOrderedCollection tempFacets;
TempODFrameFacetIterator facets = moveFrame->CreateFacetIterator(ev);
for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
{
tempFacets.AddFirst(facet);
}
ODxOrderedCollectionIterator iter(&tempFacets);
for (facet = (ODFacet*)iter.First();
iter.IsNotComplete();
facet = (ODFacet*)iter.Next())
{
facet->GetContainingFacet(ev)->MoveBefore(ev, facet, kODNULL);
}
somSelf->ClipEmbeddedFrames(ev, dispFrame);
moveFrame->Invalidate(ev, kODNULL, kODNULL);
}
somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
_fNeedToExternalize = kODTrue;
}
SOM_CATCH_ALL
SOM_ENDTRY
return kODTrue;
}
SOM_Scope ODBoolean SOMLINK ContainerPartMoveToBack(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartMoveToBack");
SOM_TRY
if (_fSelection->Count() == 1 && frame == _fSelectionFrame)
{
ODxOrderedCollectionIterator i(_fSelection);
Proxy* p = (Proxy*) i.First();
_fContents->Remove(p);
_fContents->AddLast(p);
ODxOrderedCollectionIterator dispFrames(_fDisplayFrames);
for (ODFrame* dispFrame = (ODFrame*)dispFrames.First();
dispFrames.IsNotComplete();
dispFrame = (ODFrame*)dispFrames.Next())
{
ODFrame* moveFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, dispFrame);
moveFrame->Invalidate(ev, kODNULL, kODNULL);
ODxOrderedCollection tempFacets;
TempODFrameFacetIterator facets = moveFrame->CreateFacetIterator(ev);
for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
{
tempFacets.AddLast(facet);
}
ODxOrderedCollectionIterator iter(&tempFacets);
for (facet = (ODFacet*)iter.First();
iter.IsNotComplete();
facet = (ODFacet*)iter.Next())
{
facet->GetContainingFacet(ev)->MoveBehind(ev, facet, kODNULL);
}
somSelf->ClipEmbeddedFrames(ev, dispFrame);
}
somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
_fNeedToExternalize = kODTrue;
}
SOM_CATCH_ALL
SOM_ENDTRY
return kODTrue;
}
SOM_Scope ODBoolean SOMLINK ContainerPartMoveForward(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartMoveForward");
SOM_TRY
if (_fSelection->Count() == 1 && frame == _fSelectionFrame)
{
ODxOrderedCollectionIterator i(_fSelection);
ODxOrderedCollection tempFacets;
Proxy* p = (Proxy*) i.First();
Proxy* siblingProxy = (Proxy*)_fContents->Before(p);
if (siblingProxy)
{
_fContents->Remove(p);
_fContents->AddBefore(siblingProxy, p);
ODxOrderedCollectionIterator dispFrames(_fDisplayFrames);
for (ODFrame* dispFrame = (ODFrame*)dispFrames.First();
dispFrames.IsNotComplete();
dispFrame = (ODFrame*)dispFrames.Next())
{
ODFrame* moveFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, dispFrame);
ODFrame* siblingFrame = somSelf->FrameFromProxyForContainingFrame(ev, siblingProxy, dispFrame);
TempODFrameFacetIterator facets = moveFrame->CreateFacetIterator(ev);
for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
{
tempFacets.AddLast(facet);
}
ODxOrderedCollectionIterator iter(&tempFacets);
TempODFrameFacetIterator siblingFacets = siblingFrame->CreateFacetIterator(ev);
ODFacet* siblingFacet = siblingFacets->First(ev);
for (facet = (ODFacet*)iter.First();
iter.IsNotComplete();
facet = (ODFacet*)iter.Next())
{
facet->GetContainingFacet(ev)->MoveBefore(ev, facet, siblingFacet);
}
somSelf->ClipEmbeddedFrames(ev, dispFrame);
moveFrame->Invalidate(ev, kODNULL, kODNULL);
}
somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
_fNeedToExternalize = kODTrue;
}
}
SOM_CATCH_ALL
SOM_ENDTRY
return kODTrue;
}
SOM_Scope ODBoolean SOMLINK ContainerPartMoveBackward(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartMoveBackward");
SOM_TRY
if (_fSelection->Count() == 1 && frame == _fSelectionFrame)
{
ODxOrderedCollectionIterator i(_fSelection);
ODxOrderedCollection tempFacets;
Proxy* p = (Proxy*) i.First();
Proxy* siblingProxy = (Proxy*)_fContents->After(p);
if (siblingProxy)
{
_fContents->Remove(p);
_fContents->AddAfter(siblingProxy, p);
ODxOrderedCollectionIterator dispFrames(_fDisplayFrames);
for (ODFrame* dispFrame = (ODFrame*)dispFrames.First();
dispFrames.IsNotComplete();
dispFrame = (ODFrame*)dispFrames.Next())
{
ODFrame* moveFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, dispFrame);
ODFrame* siblingFrame = somSelf->FrameFromProxyForContainingFrame(ev, siblingProxy, dispFrame);
moveFrame->Invalidate(ev, kODNULL, kODNULL);
TempODFrameFacetIterator facets = moveFrame->CreateFacetIterator(ev);
for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev); facet = facets->Next(ev))
{
tempFacets.AddLast(facet);
}
ODxOrderedCollectionIterator iter(&tempFacets);
TempODFrameFacetIterator siblingFacets = siblingFrame->CreateFacetIterator(ev);
ODFacet* siblingFacet = siblingFacets->First(ev);
for (facet = (ODFacet*)iter.First();
iter.IsNotComplete();
facet = (ODFacet*)iter.Next())
{
facet->GetContainingFacet(ev)->MoveBehind(ev, facet, siblingFacet);
}
somSelf->ClipEmbeddedFrames(ev, dispFrame);
}
somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
_fNeedToExternalize = kODTrue;
}
}
SOM_CATCH_ALL
SOM_ENDTRY
return kODTrue;
}
SOM_Scope void SOMLINK ContainerPartClearAccelTable(ContainerPart *somSelf,
Environment *ev,
ODFrame* oldOwner)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartClearAccelTable");
}
SOM_Scope void SOMLINK ContainerPartSetAccelTable(ContainerPart *somSelf,
Environment *ev,
ODFrame* newOwner)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartSetAccelTable");
}
SOM_Scope ODBoolean SOMLINK ContainerPartDisplayStatusLineText(ContainerPart *somSelf, Environment *ev,
string str, ODFrame * curFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDisplayStatusLineText");
SOM_TRY
ODBoolean haveFocus = kODFalse;
if (_fStatusLn)
{ // 139395 start
ODArbitrator * arbit = _fSession->GetArbitrator(ev);
ODFrame * OwnerFrame = arbit->AcquireFocusOwner(ev,_fStatusFocus);
if (OwnerFrame != curFrame) {
if (arbit->RequestFocus(ev, _fStatusFocus, curFrame))
haveFocus = kODTrue; // part has focus
} else {
haveFocus = kODTrue;
} /* endif */
if (OwnerFrame) {
OwnerFrame->Release(ev);
} /* endif */
if ( haveFocus) {
_fStatusLn->SetStatusLineText(ev,str,curFrame);
return kODTrue;
}
} // 139395 end
SOM_CATCH_ALL
SOM_ENDTRY
return kODFalse;
}
SOM_Scope long SOMLINK ContainerPartGetDemoState(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartGetDemoState");
/* Return statement to be customized: */
return _DemoState;
}
SOM_Scope void SOMLINK ContainerPartsomInit(ContainerPart *somSelf)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartsomInit");
ContainerPart_parent_ODPart_somInit(somSelf);
_fDisplayFrames = kODNULL;
_fEmbeddedFrames = kODNULL;
_fWindowID = 0;
_fSequence = 0; //[pfe] 123945
_fContents = kODNULL;
_fSelection = kODNULL;
_fSelectionFrame = kODNULL;
_fPasteFrame = kODNULL;
_fNeedToExternalize = kODFalse;
_fContainerSU = kODNULL;
_fSelectShape = kODNULL;
_fFocusSet = kODNULL;
_fSemtIntf = kODNULL;
_fViewExtension = kODNULL;
_fSPEMenuOfSelection = kODNULL;
_fRemappedSPEMenuOfSelection = kODNULL;
_DemoState = 0;
_DemoOpenCount = 0;
_fMenuBar = kODNULL;
_fBGColor = 0;
_fSession = kODNULL;
_fPartWrapper = kODNULL;
_fPasteOn = kODFalse;
_fPasteESC = kODFalse;
_fMouseMode = kNormal;
_fTrackingMode = 0;
_fIgnoreContextMenu = kODFalse;
_fStatusLn = 0;
}
SOM_Scope void SOMLINK ContainerPartsomUninit(ContainerPart *somSelf)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartsomUninit");
Environment* ev = somGetGlobalEnvironment();
SOM_TRY
if (_fContents != kODNULL)
delete _fContents;
if (_fSelection != kODNULL)
delete _fSelection;
if (_fSavedFacetClipShapes)
{
while (_fSavedFacetClipShapes->Count())
{
FacetClip* facetClip = (FacetClip*)_fSavedFacetClipShapes->First();
ODReleaseObject(ev, facetClip->clip);
_fSavedFacetClipShapes->Remove(facetClip);
delete facetClip;
}
delete _fSavedFacetClipShapes;
}
ODReleaseObject(ev, _fSelectShape);
if (_hpsMem) GpiDestroyPS(_hpsMem);
if (_hdcMem) DevCloseDC(_hdcMem);
if (_fViewExtension != kODNULL)
delete _fViewExtension;
if (_fDisplayFrames != kODNULL)
delete _fDisplayFrames; // make sure it's empty first
if (_fEmbeddedFrames != kODNULL)
delete _fEmbeddedFrames; // make sure it's empty first
#define SEMANTIC_INTERFACES_NOT_DONE
#ifndef SEMANTIC_INTERFACES_NOT_DONE
if (_fSemtIntf != kODNULL)
delete _fSemtIntf;
#endif
ODReleaseObject(ev, _fStatusLn);
ODReleaseObject(ev, _fSelectionFrame);
ODReleaseObject(ev, _fContainerSU);
if (_hmod)
DosFreeModule(_hmod);
SOM_CATCH_ALL
SOM_ENDTRY
ContainerPart_parent_ODPart_somUninit(somSelf);
}
SOM_Scope void SOMLINK ContainerPartFulfillPromise(ContainerPart *somSelf,
Environment *ev,
ODStorageUnitView* promiseSUView)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartFulfillPromise");
}
SOM_Scope void SOMLINK ContainerPartDropCompleted(ContainerPart *somSelf,
Environment *ev,
ODPart* destPart,
ODDropResult dropResult)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDropCompleted");
ODUnused(destPart);
ODUnused(dropResult);
}
void InvertDragHilite( Environment * ev, ODFacet* facet)
{
SOM_TRY
HPS hps;
CFocusWindow f(ev, facet, (ODShape*)kODNULL, &hps, (HWND*)kODNULL, CFocusWindow::DragPS);
ODTempPolygon poly;
POLYGON polygon;
ODContour *pContour;
int i;
TempODShape clipShape = facet->AcquireAggregateClipShape(ev, kODNULL);
clipShape->CopyPolygon(ev,&poly); // [137664]
GpiSetMix( hps, FM_INVERT );
GpiBeginPath(hps, 1);
for (pContour = poly.FirstContour(), i = 0;
i < poly.GetNContours();
pContour = pContour->NextContour(), i++)
{
pContour->AsPOLYGON(polygon);
GpiMove(hps, &polygon.aPointl[polygon.ulPoints-1]);
GpiPolyLine(hps, polygon.ulPoints, polygon.aPointl);
SOMFree(polygon.aPointl);
}
GpiEndPath(hps);
GpiSetLineWidthGeom(hps, 8);
GpiStrokePath(hps, 1, 0);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODDragResult SOMLINK ContainerPartDragEnter(ContainerPart *somSelf,
Environment *ev,
ODDragItemIterator* dragInfo,
ODFacet* facet,
ODPoint* where)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDragEnter");
SOM_TRY
// [140007] :
ODStorageUnit* dragSU;
_fDropAccepted = kODTrue;
PartInfoRec* pInfo = (PartInfoRec*)facet->GetFrame(ev)->GetPartInfo(ev);
if (!pInfo->fAcceptDrop)
_fDropAccepted = kODFalse;
else
{
for (dragSU = dragInfo->First(ev); dragSU ; dragSU = dragInfo->Next(ev))
{
if ( ! _fSession->GetDragAndDrop(ev)->CanEmbed(ev,dragSU)) {
_fDropAccepted = kODFalse;
break;
}
}
}
if(_fDropAccepted) {
InvertDragHilite( ev, facet );
return MRFROM2SHORT (DOR_DROP, DO_MOVE);
}
SOM_CATCH_ALL
SOM_ENDTRY
return MRFROM2SHORT (DOR_NODROP, 0);
}
SOM_Scope ODDragResult SOMLINK ContainerPartDragWithin(ContainerPart *somSelf,
Environment *ev,
ODDragItemIterator* dragInfo,
ODFacet* facet,
ODPoint* where)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDragWithin");
// [140007] :
if(_fDropAccepted)
return MRFROM2SHORT (DOR_DROP, DO_MOVE);
return MRFROM2SHORT (DOR_NODROP, 0);
}
SOM_Scope void SOMLINK ContainerPartDragLeave(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet,
ODPoint* where)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDragLeave");
SOM_TRY
// [140007] :
if(_fDropAccepted)
InvertDragHilite( ev, facet );
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODDropResult SOMLINK ContainerPartDrop(ContainerPart *somSelf,
Environment *ev,
ODDragItemIterator* dropInfo,
ODFacet* facet,
ODPoint* where)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDrop");
ODDropResult dropResult = kODDropMove;
SOM_TRY
ODDraft *theDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
ODULong attributes;
ODPoint delta;
ODStorageUnit *dropSU;
ODID draggedFrameID;
ODPart *newPart;
ODShape *clipShape;
ODTransform *newExternalXForm;
short movePart;
ODStorageUnitView *dropView;
ODStorageUnit *renderedSU;
ODBoolean notDone = kODTrue;
InvertDragHilite(ev, facet); // presumably I've highlighted myself, so turn it off now.
for (dropSU = dropInfo->First(ev); dropSU && notDone; dropSU = dropInfo->Next(ev))
{
// first thing is to check for dragitem value, can't do anything
// more if it is not present...
if ( !dropSU->Exists(ev, kODPropContents, (ODValueType)kODDragitem, 0))
{
// nothing to process... (bug)
continue;
}
// get the dragitem (actual pm structure)
dropSU->Focus(ev, kODPropContents, kODPosUndefined,
(ODValueType)kODDragitem, 0, kODPosUndefined);
// create a view of our focused value for the drag manager
ODStorageUnitView *dropView = dropSU->CreateView(ev);
// ask the drag manager to get it for us
ODBoolean success =
_fSession->GetDragAndDrop(ev)->
GetDataFromDragManager(ev,
dropView,
/* szSelectedRMF, */ // [140007]
&renderedSU );
// ODDeleteObject(dropView); // We should be able to do this, but it causes a trap.
// This problem is under investigation.
if (!success)
{
continue;
}
// NOTE: the target part must not free / release the renderedSU.
// it will be cleaned up when we return from Drop() by the drag
// manager.
// Determine whether this is a Move/Copy operation. The drag manager
// will have checked with PM to determine if the CTL key was depressed.
attributes = _fSession->GetDragAndDrop(ev)->GetDragAttributes(ev);
movePart = (attributes & kODDropIsInSourceFrame) &&
(attributes & kODDropIsMove); // 132586 - allow copy op.
if (movePart)
{
// Get where drag started and tweak our own structures to do the move.
TempODTransform tempTrans = facet->AcquireWindowFrameTransform(ev, kODNULL); // [121802]
ODPoint ms = _mouseStart; // [137664]
tempTrans->InvertPoint(ev, &ms);
delta.x = where->x - ms.x;
delta.y = where->y - ms.y;
renderedSU->Focus(ev, kPropFrameInfo, kODPosUndefined, kFrameRef,
0, kODPosFirstSib);
StorageUnitGetValue(renderedSU, ev, sizeof(ODID), (ODValue) &draggedFrameID);
Proxy* p = somSelf->ProxyForFrameID(ev, draggedFrameID);
somSelf->InvalidateProxy(ev, p);
p->transform->MoveBy(ev, &delta);
_fNeedToExternalize = kODTrue;
somSelf->CreateProxySelectionBorder(ev);
somSelf->ClipEmbeddedFrames(ev, kODNULL );
somSelf->InvalidateProxy(ev, p);
}
else
{
ODDraft *fromDraft = renderedSU->GetDraft( ev );
ODDraftKey key;
ODID newPartID;
ODCloneKind cloneKind;
if (attributes & kODDropIsMove) {
cloneKind = kODCloneDropMove;
dropResult = kODDropMove;
}
else {
cloneKind = kODCloneDropCopy;
dropResult = kODDropCopy;
}
TRY
key = fromDraft->BeginClone(ev, theDraft,
facet->GetFrame(ev), cloneKind);
newPartID = fromDraft->Clone(ev, key, renderedSU->GetID(ev), 0, 0);
fromDraft->EndClone(ev, key);
CATCH_ALL
fromDraft->AbortClone(ev, key);
RERAISE;
ENDTRY
ODPoint newTransPt = *where;
// 146814 - use kODPropMouseDownOffset
if (renderedSU->Exists(ev, kODPropMouseDownOffset, kODPoint, 0))
{
ODPoint offset;
renderedSU->Focus(ev, kODPropMouseDownOffset, kODPosUndefined, kODPoint, 0, kODPosFirstSib);
StorageUnitGetValue(renderedSU, ev, sizeof(offset), (ODValue) &offset);
newTransPt.x -= offset.x;
newTransPt.y -= offset.y;
}
newExternalXForm = facet->GetFrame(ev)->CreateTransform(ev);
newExternalXForm->MoveBy(ev, &newTransPt );
TempODShape newFrameShape = kODNULL;
if (renderedSU->Exists(ev, kODPropFrameShape, NULL, 0))
{
renderedSU->Focus(ev, kODPropFrameShape, kODPosUndefined, NULL, 1, kODPosUndefined);
newFrameShape = facet->CreateShape(ev);
newFrameShape->ReadShape(ev, renderedSU);
}
newPart = theDraft->AcquirePart(ev, newPartID );
// We should be internalizing the frame from the storage unit
somSelf->CreateProxyObject(ev,
newFrameShape,
newExternalXForm,
newPart,
kODFalse);
newPart->Release(ev);
}
}
somSelf->InvalidateSelection(ev, _fSelectionFrame);
somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
SOM_CATCH_ALL
SOM_ENDTRY
return dropResult;
}
SOM_Scope ODExtension* SOMLINK ContainerPartAcquireExtension(ContainerPart *somSelf,
Environment *ev,
ODType extensionName)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartAcquireExtension");
SOM_TRY
if(!strcmp(extensionName, kODSettingsExtension) ){
if (!_fNotebook) {
_fNotebook = new CNNotebook;
_fNotebook->InitSettingsExtension( ev, _fPartWrapper);
} /* endif */
_fNotebook->Acquire(ev);
return _fNotebook;
}
else if(!strcmp(extensionName, kODExtSemanticInterface) ){ //@127858
_fSemtIntf->Acquire(ev);
return _fSemtIntf; //@127858
} //@127858
else {
return ContainerPart_parent_ODPart_AcquireExtension(somSelf, ev, extensionName);
} /* endif */
SOM_CATCH_ALL
SOM_ENDTRY
return kODNULL;
}
SOM_Scope void SOMLINK ContainerPartReleaseExtension(ContainerPart *somSelf,
Environment *ev,
ODExtension* extension)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartReleaseExtension");
SOM_TRY
if ( !extension ) return;
if(_fNotebook == extension) {
_fNotebook->Release( ev);
_fNotebook = 0;
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODBoolean SOMLINK ContainerPartHasExtension(ContainerPart *somSelf,
Environment *ev,
ODType extensionName)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHasExtension");
SOM_TRY
if( !strcmp(extensionName, kODSettingsExtension) || //@127858
!strcmp(extensionName, kODExtSemanticInterface) ) { //@127858
return kODTrue;
}
else {
return ContainerPart_parent_ODPart_HasExtension(somSelf, ev, extensionName);
} /* endif */
SOM_CATCH_ALL
SOM_ENDTRY
return kODFalse;
}
SOM_Scope void SOMLINK ContainerPartContainingPartPropertiesUpdated(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame,
ODStorageUnit* propertyUnit)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartContainingPartPropertiesUpdated");
// nothing to do yet
}
SOM_Scope ODStorageUnit* SOMLINK ContainerPartAcquireContainingPartProperties(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartAcquireContainingPartProperties");
// this part has no properties to return
return kODNULL;
}
SOM_Scope ODMenuBar* SOMLINK ContainerPartCreateRootMenuBar(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCreateRootMenuBar");
ODMenuBar * mb = new ODMenuBar;
mb = kODNULL;
return mb;
}
SOM_Scope ODBoolean SOMLINK ContainerPartRevealFrame(ContainerPart *somSelf,
Environment *ev,
ODFrame* embeddedFrame,
ODShape* revealShape)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartRevealFrame");
ODUnused(embeddedFrame);
ODUnused(revealShape);
return kODFalse;
}
SOM_Scope void SOMLINK ContainerPartEmbeddedFrameSpec(ContainerPart *somSelf,
Environment *ev,
ODFrame* embeddedFrame,
ODObjectSpec* spec)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartEmbeddedFrameSpec");
SOM_TRY
ODUnused(embeddedFrame);
ODUnused(spec);
THROW(kODErrCannotEmbed);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODEmbeddedFramesIterator* SOMLINK ContainerPartCreateEmbeddedFramesIterator(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCreateEmbeddedFramesIterator");
XEmbeddedFramesIterator *xefi = kODNULL;
SOM_TRY
xefi = new XEmbeddedFramesIterator();
xefi->InitXEmbeddedFramesIterator( ev, _fEmbeddedFrames );
return xefi;
SOM_CATCH_ALL
delete xefi;
SOM_ENDTRY
return kODNULL;
}
SOM_Scope void SOMLINK ContainerPartDisplayFrameAdded(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDisplayFrameAdded");
SOM_TRY
TempODPart tempPart = frame->AcquirePart(ev);
if (tempPart == _fPartWrapper) // frame belongs to me
{
// make an ebmedded frame in our new display frame for each proxy object.
// Since MakeEmbeddedFrame always puts the new frame at the top in the
// Z-order, we'll create a collection with proxie elements in reverse
// order and iterate through that.
ODxOrderedCollection proxies;
ODxOrderedCollectionIterator aIter(_fContents);
for (Proxy* p = (Proxy*)aIter.First(); aIter.IsNotComplete(); p = (Proxy*)aIter.Next())
{
proxies.AddFirst(p);
}
ODxOrderedCollectionIterator bIter(&proxies);
for (p = (Proxy*)bIter.First(); bIter.IsNotComplete(); p = (Proxy*)bIter.Next())
{
ODFrame* newFrame = somSelf->MakeEmbeddedFrame(ev, frame, p, kODFalse);
ODReleaseObject(ev, newFrame);
}
// !!! do something with viewType and partInfo...
PartInfoRec* pInfo = new PartInfoRec;
pInfo->fGridOn = kODFalse; //Default is grid off
pInfo->partwindowID = (ODID)kODNULL;
if (frame->IsRoot(ev))
pInfo->fNeedsActivating = kODTrue;
frame->SetPartInfo(ev, (ODInfoType) pInfo);
_fDisplayFrames->AddLast(frame);
frame->Acquire(ev);
frame->SetDroppable(ev, kODTrue);
_fNeedToExternalize = kODTrue;
if (frame->GetViewType(ev) == kODNullTypeToken) // if frame view is set don't change it
frame->SetViewType(ev, _fSession->Tokenize(ev, kODViewAsFrame)); // if not, make it viewasframe
if (frame->GetPresentation(ev) == kODNullTypeToken)
frame->SetPresentation(ev, _fSession->Tokenize(ev, kODPresDefault ));
}
else
{
THROW(kODErrInvalidFrame);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartAttachSourceFrame(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame,
ODFrame* sourceFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartAttachSourceFrame");
SOM_TRY
if (_fDisplayFrames->Contains(frame)
&& sourceFrame && _fDisplayFrames->Contains(sourceFrame))
{
ODxOrderedCollectionIterator i(_fContents);
for (Proxy* p = (Proxy*)i.First();
i.IsNotComplete();
p = (Proxy*)i.Next())
{
ODFrame* embFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, frame);
ODFrame* embSourceFrame = somSelf->FrameFromProxyForContainingFrame(ev, p, sourceFrame);
p->part->AttachSourceFrame(ev, embFrame, embSourceFrame);
}
}
else
THROW(kODErrInvalidFrame);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartDisplayFrameRemoved(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDisplayFrameRemoved");
SOM_TRY
if (frame != kODNULL ) {
if (_fDisplayFrames->Contains(frame))
{
if (frame == _fSelectionFrame)
somSelf->EmptySelection(ev);
ODxOrderedCollection embeddedFrames;
{
ODxOrderedCollectionIterator iter(_fEmbeddedFrames);
for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
iter.IsNotComplete();
embeddedFrame = (ODFrame*) iter.Next())
{
embeddedFrames.AddLast(embeddedFrame);
}
}
ODxOrderedCollectionIterator iter(&embeddedFrames);
for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
iter.IsNotComplete();
embeddedFrame = (ODFrame*) iter.Next())
{
TempODFrame tempFrame = embeddedFrame->AcquireContainingFrame(ev);
if (tempFrame == frame)
{
somSelf->RemoveEmbeddedFrame(ev, embeddedFrame);
}
}
_fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet,frame);
TempODFrame tempFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fClipboardFocus);
if ( frame == tempFrame )
{
_fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fClipboardFocus, frame);
somSelf->FocusLost(ev, _fClipboardFocus, frame);
}
TempODFrame tempF = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fStatusFocus);
if ( frame == tempF ) // if have focus release it.
{
somSelf->FocusLost(ev, _fStatusFocus, frame);
}
PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
frame->SetPartInfo(ev, (ODInfoType) kODNULL);
delete pInfo;
_fDisplayFrames->Remove(frame);
ODReleaseObject(ev, frame);
_fNeedToExternalize = kODTrue;
ODxOrderedCollectionIterator dIter(_fDisplayFrames);
ODFrame* displayFrame = (ODFrame*) dIter.First();
if (dIter.IsNotComplete() == kODFalse) {
//somSelf->DestroyPalette(ev);
}
}
else
THROW(kODErrInvalidFrame);
}
// any display frames left?
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartDisplayFrameConnected(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDisplayFrameConnected");
SOM_TRY
// $$$$$ add frame to fDisplayFrames if reference lazily internalized
// 137097 - aml
if ( !_fDisplayFrames->Contains(frame) )
{
_fDisplayFrames->AddLast(frame);
frame->Acquire(ev);
frame->SetDroppable(ev, kODTrue);
}
PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
if (frame->IsRoot(ev))
pInfo->fNeedsActivating = kODTrue;
// end 137097
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartDisplayFrameClosed(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDisplayFrameClosed");
SOM_TRY
if (_fDisplayFrames->Contains(frame))
{
if (frame == _fSelectionFrame)
somSelf->EmptySelection(ev);
ODxOrderedCollection embeddedFrames;
{
ODxOrderedCollectionIterator iter(_fEmbeddedFrames);
for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
iter.IsNotComplete();
embeddedFrame = (ODFrame*) iter.Next())
{
embeddedFrames.AddLast(embeddedFrame);
}
}
ODxOrderedCollectionIterator iter(&embeddedFrames);
for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
iter.IsNotComplete();
embeddedFrame = (ODFrame*) iter.Next())
{
TempODFrame tempFrame = embeddedFrame->AcquireContainingFrame(ev);
if (tempFrame == frame)
{
somSelf->CloseEmbeddedFrame(ev, embeddedFrame);
}
}
_fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet, frame);
TempODFrame tempFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fClipboardFocus);
if ( frame == tempFrame )
{
_fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fClipboardFocus, frame);
somSelf->FocusLost(ev, _fClipboardFocus, frame);
}
PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
delete pInfo;
_fDisplayFrames->Remove(frame);
ODReleaseObject(ev,frame);
_fNeedToExternalize = kODTrue;
}
else
THROW(kODErrInvalidFrame);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartFrameShapeChanged(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartFrameShapeChanged");
SOM_TRY
if (_fDisplayFrames->Contains(frame))
{
/// !!! should leave UsedShape and ActiveShape null to inherit FrameShape
frame->ChangeUsedShape(ev, kODNULL, kODNULL);
}
else
THROW(kODErrInvalidFrame);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartViewTypeChanged(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartViewTypeChanged");
SOM_TRY
if (_fDisplayFrames->Contains(frame))
{ /* $$$$$ change viewType of frame */ }
else
THROW(kODErrInvalidFrame);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartPresentationChanged(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartPresentationChanged");
SOM_TRY
if (_fDisplayFrames->Contains(frame))
{ /* $$$$$ change presentation of frame */ }
else
THROW(kODErrInvalidFrame);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartSequenceChanged(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartSequenceChanged");
SOM_TRY
ContainerPart_parent_ODPart_SequenceChanged(somSelf, ev,
frame);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartWritePartInfo(ContainerPart *somSelf,
Environment *ev,
ODInfoType partInfo,
ODStorageUnitView* storageUnitView)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartWritePartInfo");
SOM_TRY
if (partInfo)
{
ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
ODPropertyName propName = storageUnitView->GetProperty(ev);
ODSUForceFocus(ev, su, propName, kKindTestContainer);
ODBoolean needsGrid = ((PartInfoRec*)partInfo)->fGridOn;
StorageUnitSetValue(su, ev, sizeof(ODBoolean),
(ODValue)&needsGrid);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODInfoType SOMLINK ContainerPartReadPartInfo(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame,
ODStorageUnitView* storageUnitView)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartReadPartInfo");
PartInfoRec* partInfo = kODNULL;
SOM_TRY
ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
ODPropertyName propName = storageUnitView->GetProperty(ev);
partInfo = new PartInfoRec;
ODBoolean needsGrid = kODTrue;
if ( ODSUExistsThenFocus(ev, su, propName, kKindTestContainer) )
{
StorageUnitGetValue(su, ev, sizeof(ODBoolean),
(ODValue)&(needsGrid));
}
else
{
WARN("Persistent partInfo is missing from this frame. Making one up.");
}
partInfo->fGridOn = needsGrid;
SOM_CATCH_ALL
ODDeleteObject(partInfo);
SOM_ENDTRY
return (ODInfoType) partInfo;
}
SOM_Scope void SOMLINK ContainerPartClonePartInfo(ContainerPart *somSelf, Environment *ev,
ODDraftKey key,
ODInfoType partInfo,
ODStorageUnitView* storageUnitView,
ODFrame* scopeFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartClonePartInfo");
SOM_TRY
if (partInfo)
{
ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
ODPropertyName propName = storageUnitView->GetProperty(ev);
ODSUForceFocus(ev, su, propName, kKindTestContainer);
ODBoolean needsGrid = ((PartInfoRec*)partInfo)->fGridOn;
StorageUnitSetValue(su, ev, sizeof(ODBoolean),
(ODValue)&needsGrid);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODID SOMLINK ContainerPartOpen(ContainerPart *somSelf,
Environment *ev, ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartOpen");
ODID windowID = 0;
SOM_TRY
TempODWindow window = kODNULL;
if (frame) // Doing a View As Window or Open Root
{
if (frame->IsRoot(ev)) // Create Window For Root Frame
{
WindowProperties props;
BeginGetWindowProperties(ev, frame, &props);
ODULong flCreateFlags = props.createFlags ? props.createFlags :
ODPlatformWindowDefaultCreateOptions;
HWND hwndFrame = _fSession->CreatePlatformWindow(ev, flCreateFlags);
// position the window to shape it was closed in
// defect 117197 open from file in some position/properties as was saved
WinSetWindowPos(hwndFrame, HWND_TOP, props.boundsRect.xLeft,
props.boundsRect.yBottom,
props.boundsRect.xRight,
props.boundsRect.yTop,(SWP_SIZE | SWP_MOVE|props.swpFlags ));
// defect 117197 end code added
window = _fSession->GetWindowState(ev)->RegisterWindowForFrame(ev, hwndFrame,
frame,
props.isRootWindow, // Keeps draft open
kODTrue, // Is resizable
kODFalse, // Is floating
kODTrue, // should save
kODTrue, // should dispose
props.sourceFrame);
EndGetWindowProperties(ev, &props); // Release source frame
window->Open(ev);
window->Show(ev);
}
else // View In Window
{
window = _fSession->GetWindowState(ev)->AcquireWindow(ev, _fWindowID);
if (window)
window->Select(ev);
else
{
window = somSelf->CreateWindow(ev, frame);
_fWindowID = window->GetID(ev);
window->Open(ev);
window->Show(ev);
window->Select(ev);
}
}
}
else
{
window = somSelf->CreateWindow(ev, frame);
_fWindowID = window->GetID(ev);
window->Open(ev);
window->Show(ev);
window->Select(ev);
}
windowID = window->GetID(ev);
SOM_CATCH_ALL
SOM_ENDTRY
return windowID;
}
SOM_Scope ODFrame* SOMLINK ContainerPartRequestEmbeddedFrame(ContainerPart *somSelf,
Environment *ev,
ODFrame* containingFrame,
ODFrame* baseFrame,
ODShape* frameShape,
ODPart* embedPart,
ODTypeToken viewType,
ODTypeToken presentation,
ODBoolean isOverlaid)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartRequestEmbeddedFrame");
return kODNULL;
}
SOM_Scope void SOMLINK ContainerPartRemoveEmbeddedFrame(ContainerPart *somSelf,
Environment *ev,
ODFrame* embeddedFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartRemoveEmbeddedFrame");
SOM_TRY
if (_fEmbeddedFrames->Contains(embeddedFrame))
{
TempODFrame containingFrame = embeddedFrame->AcquireContainingFrame(ev);
Proxy* p = somSelf->ProxyForFrame(ev, embeddedFrame);
if (p)
{
_fNeedToExternalize = kODTrue;
_fEmbeddedFrames->Remove(embeddedFrame);
p->Remove(embeddedFrame);
embeddedFrame->Remove(ev);
}
if (containingFrame) {
containingFrame->Invalidate(ev,NULL,kODNULL);
} /* endif */
}
else
THROW(kODErrInvalidFrame);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartCloseEmbeddedFrame(ContainerPart *somSelf,
Environment *ev,
ODFrame* embeddedFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCloseEmbeddedFrame");
SOM_TRY
if (_fEmbeddedFrames->Contains(embeddedFrame))
{
TempODFrame containingFrame = embeddedFrame->AcquireContainingFrame(ev);
Proxy* p = somSelf->ProxyForFrame(ev, embeddedFrame);
if (p)
{
_fNeedToExternalize = kODTrue;
_fEmbeddedFrames->Remove(embeddedFrame);
p->Remove(embeddedFrame);
embeddedFrame->Close(ev);
}
if (containingFrame) {
containingFrame->Invalidate(ev,NULL,kODNULL);
} /* endif */
}
else
THROW(kODErrInvalidFrame);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODShape* SOMLINK ContainerPartRequestFrameShape(ContainerPart *somSelf,
Environment *ev,
ODFrame* embeddedFrame,
ODShape* frameShape)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartRequestFrameShape");
SOM_TRY
if (_fEmbeddedFrames->Contains(embeddedFrame))
{ // find frame proxy
Proxy* p = somSelf->ProxyForFrame(ev, embeddedFrame);
if (p && !p->settingFrameShapes)
{
p->shape->CopyFrom(ev, frameShape);
if (somSelf->NormalizeProxyGeometry(ev, p))
frameShape->CopyFrom(ev, p->shape);
}
}
else
THROW(kODErrInvalidFrame);
SOM_CATCH_ALL
SOM_ENDTRY
return frameShape;
}
SOM_Scope void SOMLINK ContainerPartUsedShapeChanged(ContainerPart *somSelf,
Environment *ev,
ODFrame* embeddedFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartUsedShapeChanged");
SOM_TRY
if (_fEmbeddedFrames->Contains(embeddedFrame))
{
Proxy* p = somSelf->ProxyForFrame(ev, embeddedFrame);
if (p->settingFrameShapes == kODFalse)
{
// prevent recursion problems in case part tries
// to engage in frame negotiation.
p->settingFrameShapes = kODTrue;
ODxOrderedCollectionIterator i(p);
for (ODFrame* frame = (ODFrame*)i.First();
i.IsNotComplete();
frame = (ODFrame*)i.Next())
{
TempODShape shape = frame->AcquireFrameShape(ev, kODNULL);
if (!shape->IsSameAs(ev, p->shape))
frame->ChangeFrameShape(ev, p->shape, kODNULL);
}
p->settingFrameShapes = kODFalse;
}
embeddedFrame->Invalidate(ev, kODNULL, kODNULL);
// AML: [108305]
if (_fSelection->Contains(p)) {
TempODFrame ownerFrame = embeddedFrame->AcquireContainingFrame(ev);
somSelf->InvalidateSelection(ev, ownerFrame);
somSelf->CreateProxySelectionBorder(ev);
somSelf->InvalidateSelection(ev, ownerFrame);
}
// end [108305]
TempODFrame tempFrame = embeddedFrame->AcquireContainingFrame(ev);
somSelf->ClipEmbeddedFrames(ev, kODNULL);
somSelf->Invalidate(ev);
}
else
THROW(kODErrInvalidFrame);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODShape* SOMLINK ContainerPartAdjustBorderShape(ContainerPart *somSelf,
Environment *ev,
ODFacet* embeddedFacet,
ODShape* shape)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartAdjustBorderShape");
SOM_TRY
ODFacet* containingFacet = embeddedFacet->GetContainingFacet(ev);
ODFacetIterator* facets = containingFacet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
TempODTransform transform = embeddedFacet->AcquireFrameTransform(ev, kODNULL);
shape->Transform(ev, transform);
ODBoolean above = kODFalse;
for (ODFacet* embFacet = facets->First(ev);
facets->IsNotComplete(ev) && embFacet != embeddedFacet;
embFacet = facets->Next(ev))
{
TempODShape usedShape = ODCopyAndRelease(ev, embFacet->GetFrame(ev)->AcquireUsedShape(ev, kODNULL));
TempODTransform xform = embFacet->AcquireFrameTransform(ev, kODNULL);
usedShape->Transform(ev, xform);
shape->Subtract(ev, usedShape);
}
delete facets;
shape->InverseTransform(ev, transform);
shape->Acquire(ev);
SOM_CATCH_ALL
SOM_ENDTRY
return shape;
}
SOM_Scope void SOMLINK ContainerPartFacetAdded(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartFacetAdded");
SOM_TRY
ODFrame* dispFrame = facet->GetFrame(ev);
if (!_fDisplayFrames->Contains(dispFrame))
THROW(kODErrInvalidFacet);
// 121161 :
FacetInfoRec* pInfo = new FacetInfoRec(); // 124243
pInfo->fClipShape = facet->CreateShape(ev);
ODRect emptyRect(0,0,0,0);
pInfo->fClipShape->SetRectangle(ev,&emptyRect);
facet->SetPartInfo(ev, (ODInfoType)pInfo);
// end 121161
ODxOrderedCollectionIterator frames(_fEmbeddedFrames);
for (ODFrame* frame = (ODFrame*) frames.First();
frames.IsNotComplete();
frame = (ODFrame*) frames.Next())
{
TempODFrame tempFrame = frame->AcquireContainingFrame(ev);
if (tempFrame == dispFrame)
{
TempODShape frameShape = frame->AcquireFrameShape(ev, kODNULL);
TempODShape clip = frameShape->Copy(ev);
TempODTransform xform = somSelf->ProxyForFrame(ev, frame)->transform->Copy(ev);
ODFacet * newFacet = facet->CreateEmbeddedFacet(ev, frame, clip, xform,
kODNULL, kODNULL, kODNULL, kODFrameBehind);
ODHighlight highlight = facet->GetHighlight(ev);
if( highlight != kODNoHighlight)
newFacet->ChangeHighlight(ev, highlight);
}
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartFacetRemoved(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartFacetRemoved");
SOM_TRY
ODFrame* dispFrame = facet->GetFrame(ev);
if (!_fDisplayFrames->Contains(dispFrame))
THROW(kODErrInvalidFacet);
// 121161 :
FacetInfoRec *pInfo = (FacetInfoRec *)facet->GetPartInfo(ev); // 124243
if(pInfo) {
ODReleaseObject(ev,pInfo->fClipShape);
delete pInfo;
facet->SetPartInfo(ev, (ODInfoType) kODNULL);
}
// end 121161
ODxOrderedCollection children;
ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
for (ODFacet* childFacet = facets->First(ev);
facets->IsNotComplete(ev);
childFacet = facets->Next(ev))
{
children.AddLast(childFacet);
}
delete facets;
ODxOrderedCollectionIterator iter(&children);
for (childFacet = (ODFacet*)iter.First();
iter.IsNotComplete();
childFacet = (ODFacet*)iter.Next())
{
facet->RemoveFacet(ev, childFacet);
delete childFacet;
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartCanvasChanged(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCanvasChanged");
}
SOM_Scope void SOMLINK ContainerPartGeometryChanged(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet,
ODBoolean clipShapeChanged,
ODBoolean externalTransformChanged)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartGeometryChanged");
}
SOM_Scope void SOMLINK ContainerPartDraw(ContainerPart *somSelf,
Environment *ev, ODFacet* facet,
ODShape* invalidShape)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartDraw");
SOM_TRY
ODFrame* displayFrame = facet->GetFrame(ev);
if (_fDisplayFrames->Contains(displayFrame))
{
PartInfoRec* pInfo = (PartInfoRec*) displayFrame->GetPartInfo(ev);
if (facet->GetFrame(ev)->GetPresentation(ev) == _fSession->Tokenize(ev, kODPresDefault))
{
ODTypeToken curView = displayFrame->GetViewType(ev);
if (curView == _fSession->Tokenize(ev, kODViewAsFrame) ||
curView == _fSession->Tokenize(ev, kODViewAsThumbnail ))
{
// Get the frame rectangle
ODRect rect;
TempODShape shape = displayFrame->AcquireFrameShape(ev, facet->GetCanvas(ev)); // [121801]
shape->GetBoundingBox(ev, &rect);
RECTL frameRect;
rect.AsRECTL(frameRect);
// Set up the drawing environment
// 121161:
FacetInfoRec *facetInfo = (FacetInfoRec *)facet->GetPartInfo(ev); // 124243
// end 121161
ODBoolean bActive = kODFalse; // [131094] starts
PartInfoRec* pInfo1 = (PartInfoRec*) facet->GetFrame(ev)->GetPartInfo(ev);
if ( pInfo1->fIsActive )
bActive = kODTrue; // [131094] ends
HPS hpsDraw;
HRGN hrgnClip, hrgnOld, hrgnAggClip;
CFocus f(ev, facet, invalidShape, &hpsDraw, &hrgnAggClip);
ODShape* clipShape = (facetInfo) ? facetInfo->fClipShape : kODNULL;
hrgnClip = GpiCreateRegion(hpsDraw, 0, 0);
GpiCombineRegion(hpsDraw, hrgnClip, hrgnAggClip, 0, CRGN_COPY);
if (clipShape)
{
TempODTransform xform = facet->AcquireContentTransform(ev, kODNULL);
TempODShape tempShape = clipShape->Copy(ev);
tempShape->Transform(ev, xform);
GpiCombineRegion(hpsDraw, hrgnClip, hrgnClip, tempShape->GetRegion(ev), CRGN_DIFF);
}
GpiSetClipRegion(hpsDraw, hrgnClip, &hrgnOld);
// paint the background
GpiSetColor(hpsDraw, _fBGColor);
POINTL ptl = {0, 0};
GpiMove(hpsDraw, &ptl);
ptl.x = frameRect.xRight;
ptl.y = frameRect.yTop;
GpiBox(hpsDraw, DRO_FILL, &ptl, 0, 0);
GpiSetLineType(hpsDraw, LINETYPE_DOT);
GpiSetColor(hpsDraw, CLR_BLACK);
GpiBox(hpsDraw, DRO_OUTLINE, &ptl, 0, 0);
if (pInfo->fGridOn){
for (int y = YGRID / 2; y < frameRect.yTop; y += YGRID) {
ptl.y = y;
ptl.x = 0;
GpiMove(hpsDraw, &ptl);
ptl.x = frameRect.xRight;
GpiLine(hpsDraw, &ptl);
}
for (int x = XGRID / 2; x < frameRect.xRight; x += XGRID) {
ptl.x = x;
ptl.y = 0;
GpiMove(hpsDraw, &ptl);
ptl.y = frameRect.yTop;
GpiLine(hpsDraw, &ptl);
}
} /* endif fGridOn (rlt) 4-26-95 */
// highlite the selected frame.
if (displayFrame == _fSelectionFrame )
{ // drawing active frame - highlight selection
if ( bActive )
{
GpiSetClipRegion(hpsDraw, hrgnAggClip, &hrgnOld);
ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODBackToFront);
for (ODFacet* embFacet = facets->First(ev);
facets->IsNotComplete(ev);
embFacet = facets->Next(ev))
{
embFacet->Update(ev, kODNULL, kODNULL);
}
somSelf->HighlightSelection(ev, facet);
}
}
else
{ // drawing inactive frame - do nothing for now
}
GpiSetClipRegion(hpsDraw, 0, &hrgnOld);
GpiDestroyRegion(hpsDraw, hrgnClip);
GpiDestroyRegion(hpsDraw, hrgnAggClip);
}
else if (curView == _fSession->Tokenize(ev, kODViewAsLargeIcon))
{
/* Render as large Icon */
}
else if (curView == _fSession->Tokenize(ev, kODViewAsSmallIcon))
{
/* Render as small icon */
}
}
}
else
{
// !!! signal error: invalid frame
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartCanvasUpdated(ContainerPart *somSelf,
Environment *ev,
ODCanvas* canvas)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCanvasUpdated");
}
SOM_Scope void SOMLINK ContainerPartHighlightChanged(ContainerPart *somSelf,
Environment *ev,
ODFacet* facet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHighlightChanged");
SOM_TRY
ODHighlight highlight = facet->GetHighlight(ev);
ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
for (ODFacet* embFacet = facets->First(ev);
facets->IsNotComplete(ev);
embFacet = facets->Next(ev))
{
embFacet->ChangeHighlight(ev, highlight);
}
/*
* cause ourselves to be redrawn. FocusLib will take care of setting the
* default mix mode so that we paint properly.
*/
facet->Invalidate(ev, kODNULL, kODNULL);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope ODULong SOMLINK ContainerPartGetPrintResolution(ContainerPart *somSelf, Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","GetPrintResolution");
ODUnused(frame);
return 0;
}
SOM_Scope ODLinkSource* SOMLINK ContainerPartCreateLink(ContainerPart *somSelf,
Environment *ev,
ODByteArray* data)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCreateLink");
return kODNULL;
}
SOM_Scope void SOMLINK ContainerPartLinkUpdated(ContainerPart *somSelf,
Environment *ev,
ODLink* updatedLink,
ODUpdateID id)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartLinkUpdated");
}
SOM_Scope void SOMLINK ContainerPartRevealLink(ContainerPart *somSelf,
Environment *ev,
ODLinkSource* linkSource)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartRevealLink");
}
SOM_Scope void SOMLINK ContainerPartBreakLink(ContainerPart *somSelf,
Environment *ev,
ODLink* link)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartBreakLink");
}
SOM_Scope void SOMLINK ContainerPartBreakLinkSource(ContainerPart *somSelf,
Environment *ev,
ODLinkSource* linkSource)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartBreakLinkSource");
}
SOM_Scope void SOMLINK ContainerPartLinkBroken(ContainerPart *somSelf,
Environment *ev,
ODLink* link)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartLinkBroken");
}
SOM_Scope void SOMLINK ContainerPartUpdateFromLinkSource(ContainerPart *somSelf,
Environment *ev,
ODLinkSource* linkSource)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartUpdateFromLinkSource");
}
SOM_Scope void SOMLINK ContainerPartShowLink(ContainerPart *somSelf,
Environment *ev,
ODLink* link)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartShowLink");
}
SOM_Scope void SOMLINK ContainerPartEmbeddedFrameUpdated(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame,
ODUpdateID change)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartEmbeddedFrameUpdated");
}
SOM_Scope void SOMLINK ContainerPartLinkStatusChanged(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartLinkStatusChanged");
}
SOM_Scope ODBoolean SOMLINK ContainerPartBeginRelinquishFocus(ContainerPart *somSelf,
Environment *ev,
ODTypeToken focus,
ODFrame* ownerFrame,
ODFrame* proposedFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartBeginRelinquishFocus");
return kODTrue;
}
SOM_Scope void SOMLINK ContainerPartCommitRelinquishFocus(ContainerPart *somSelf,
Environment *ev,
ODTypeToken focus,
ODFrame* ownerFrame,
ODFrame* proposedFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCommitRelinquishFocus");
SOM_TRY
somSelf->FocusLost(ev, focus, ownerFrame);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartAbortRelinquishFocus(ContainerPart *somSelf,
Environment *ev,
ODTypeToken focus,
ODFrame* ownerFrame,
ODFrame* proposedFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartAbortRelinquishFocus");
}
SOM_Scope void SOMLINK ContainerPartFocusAcquired(ContainerPart *somSelf,
Environment *ev,
ODTypeToken focus,
ODFrame* ownerFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartFocusAcquired");
SOM_TRY
ODArbitrator* arbitrator = somSelf->GetStorageUnit(ev)->GetSession(ev)
->GetArbitrator(ev);
if ( focus == _fMenuFocus || focus == _fSelectionFocus )
{
if ( arbitrator->RequestFocusSet(ev, _fFocusSet, ownerFrame) )
{
somSelf->PartActivated(ev, ownerFrame);
}
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartFocusLost(ContainerPart *somSelf,
Environment *ev,
ODTypeToken focus,
ODFrame* ownerFrame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartFocusLost");
SOM_TRY
if (focus == _fSelectionFocus)
{
if (_fMouseMode != kNormal)
somSelf->ResetMouseMode(ev);
PartInfoRec* pInfo = (PartInfoRec*) ownerFrame->GetPartInfo(ev);
pInfo->fIsActive = kODFalse;
somSelf->InvalidateSelection(ev, ownerFrame);
if (_fSelection->Count()) // [131094] starts
{
if (ownerFrame == _fSelectionFrame)
somSelf->ShowSelection(ev, ownerFrame, kODFalse);
}
// [131094] ends
_fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fStatusFocus, ownerFrame);
}
else if (focus == _fMouseFocus)
{
somSelf->MouseFocusLost(ev, ownerFrame);
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartCloneInto(ContainerPart *somSelf,
Environment *ev,
ODDraftKey key,
ODStorageUnit* toSU,
ODFrame* scope)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartCloneInto");
SOM_TRY
ODID scopeFrameID = 0;
ODDraft* fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
ODDraft* toDraft = toSU->GetDraft(ev);
ODStorageUnitRef aSURef;
ODULong offset;
ODFrame* frame;
Proxy* proxy;
ODxOrderedCollectionIterator aIter(_fDisplayFrames);
ODxOrderedCollectionIterator cIter(_fContents);
ODSUAddPropValue(ev, toSU, kODPropContents, kKindTestContainer);
ODStorageUnit* su = toSU->GetDraft(ev)->CreateStorageUnit(ev);
// [129011] - aml:
// Use the destination storage unit to store display frames and embedded frames references
ODSUAddPropValue(ev, toSU, kODPropDisplayFrames, kODWeakStorageUnitRef);
offset = 0;
for (frame = (ODFrame*)aIter.First(); aIter.IsNotComplete();
frame = (ODFrame*)aIter.Next(), offset+=sizeof(ODStorageUnitRef))
{
ODStorageUnit* suFrame = frame->GetStorageUnit(ev);
if (suFrame)
{
ODID toFrameID = fromDraft->WeakClone(ev, key, frame->GetID(ev), 0, 0);
toSU->GetWeakStorageUnitRef(ev, toFrameID, aSURef);
toSU->SetOffset(ev, offset);
StorageUnitSetValue(toSU, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
}
}
ODSetULongProp(ev, su, kODPropFrameGroup, kODULong, _fFrameGroupIDCounter);
ODSUAddPropValue(ev, su, kPropEmbeddedFrames, kODStrongStorageUnitRefs);
// $$$$$ should be something DrawPart specific, not kODStrongStorageUnitRef
// since it is storing StorageUnitRefs and xforms in the same stream.
offset = 0;
for (Proxy* p = (Proxy*)cIter.First();
cIter.IsNotComplete();
p = (Proxy*)cIter.Next())
{
ODxOrderedCollectionIterator i(p);
for (frame = (ODFrame*)i.First();
i.IsNotComplete();
frame = (ODFrame*)i.Next())
{
ODStorageUnit* suFrame = frame->GetStorageUnit(ev);
if (suFrame)
{
Proxy* proxy = somSelf->ProxyForFrame(ev, frame);
ODID toFrameID = fromDraft->Clone(ev, key, frame->GetID(ev), 0, 0);
su->GetStrongStorageUnitRef(ev, toFrameID, aSURef);
su->SetOffset(ev, offset);
StorageUnitSetValue(su, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
offset += sizeof(ODStorageUnitRef);
ODMatrix mtx;
proxy->transform->GetMatrix(ev, &mtx);
su->SetOffset(ev,offset);
StorageUnitSetValue(su, ev, sizeof(ODMatrix), (ODValue)&mtx);
offset += sizeof(ODMatrix);
}
}
}
// end [129011]
ODSetULongProp(ev, su, kPropBGColor, kODULong, _fBGColor);
ODSetStrongSURefProp(ev, toSU, kODPropContents, kKindTestContainer, su->GetID(ev));
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartExternalizeKinds(ContainerPart *somSelf,
Environment *ev,
ODTypeList* kindset)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartExternalizeKinds");
SOM_TRY
// This part only supports one kind and always externalizes it
somSelf->Externalize(ev);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartExternalize(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartExternalize");
SOM_TRY
ODStorageUnit* su = somSelf->GetStorageUnit(ev);
ODStorageUnitRef aSURef;
ODULong offset;
ODFrame* frame;
Proxy* proxy;
ODxOrderedCollectionIterator aIter(_fDisplayFrames);
ODxOrderedCollectionIterator cIter(_fContents);
POINTL xform;
if ( _fNeedToExternalize ) {
ODSetULongProp(ev, _fContainerSU, kODPropFrameGroup, kODULong, _fFrameGroupIDCounter);
// iterate through the embedded display frames and store a strong reference to them
if (_fNeedToExternalize) { // 145687
ODSURemoveProperty(ev, _fContainerSU, kPropEmbeddedFrames);
ODSUAddPropValue(ev, _fContainerSU, kPropEmbeddedFrames, kODStrongStorageUnitRefs);
// $$$$$ should be something DrawPart specific, not kODStrongStorageUnitRef
// since it is storing StorageUnitRefs and xforms in the same stream.
offset = 0;
ODMatrix mtx;
for (Proxy* p = (Proxy*)cIter.First();
cIter.IsNotComplete();
p = (Proxy*)cIter.Next())
{
ODxOrderedCollectionIterator i(p);
for (ODFrame* frame = (ODFrame*)i.First();
i.IsNotComplete();
frame = (ODFrame*)i.Next())
{
ODStorageUnit* suFrame = frame->GetStorageUnit(ev);
if (suFrame)
{
Proxy* proxy = somSelf->ProxyForFrame(ev, frame);
frame->Externalize(ev);
_fContainerSU->GetStrongStorageUnitRef(ev, suFrame->GetID(ev), aSURef);
_fContainerSU->SetOffset(ev, offset);
StorageUnitSetValue(_fContainerSU, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
offset += sizeof(ODStorageUnitRef);
proxy->transform->GetMatrix(ev, &mtx);
_fContainerSU->SetOffset(ev, offset);
StorageUnitSetValue(_fContainerSU, ev, sizeof(ODMatrix), (ODValue)&mtx);
offset += sizeof(ODMatrix);
}
}
}
}
ODSetULongProp(ev, _fContainerSU, kPropBGColor, kODULong, _fBGColor);
ODSetStrongSURefProp(ev, su, kODPropContents, kKindTestContainer, _fContainerSU->GetID(ev));
// iterate through our displayframes and store a the weak reference to them
ODSURemoveProperty(ev, su, kODPropDisplayFrames);
ODSUAddPropValue(ev, su, kODPropDisplayFrames, kODWeakStorageUnitRef);
offset = 0;
for (frame = (ODFrame*)aIter.First(); aIter.IsNotComplete();
frame = (ODFrame*)aIter.Next(), offset+=sizeof(ODStorageUnitRef))
{
ODStorageUnit* suFrame = frame->GetStorageUnit(ev);
if (suFrame)
{
frame->Externalize(ev);
su->GetWeakStorageUnitRef(ev, suFrame->GetID(ev), aSURef);
su->SetOffset(ev, offset);
StorageUnitSetValue(su, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
}
}
_fNeedToExternalize = kODFalse;
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartChangeKind(ContainerPart *somSelf,
Environment *ev,
ODType kind)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartChangeKind");
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleEvent(ContainerPart *somSelf,
Environment *ev,
ODEventData* event,
ODFrame* frame,
ODFacet* facet,
ODEventInfo* eventInfo)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleEvent");
ODBoolean handled = kODFalse;
SOM_TRY
switch (event->msg)
{
case WM_BUTTON1MOTIONSTART:
if (!eventInfo->flags)
{
ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
ODIntToFixed(SHORT2FROMMP(event->mp1)));
handled = somSelf->HandleButton1MotionStart(ev, facet, &windowPt, event);
break;
}
case WM_BUTTON1DOWN:
{
ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
ODIntToFixed(SHORT2FROMMP(event->mp1)));
handled = somSelf->HandleButton1Down(ev, facet, &windowPt, event);
break;
}
case WM_BUTTON1CLICK:
{
ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
ODIntToFixed(SHORT2FROMMP(event->mp1)));
if (eventInfo->flags == kODInEmbedded)
{
handled = somSelf->HandleButton1ClickInEmbeddedFrame(ev, facet,
eventInfo->embeddedFacet, &windowPt, event);
}
else if (eventInfo->flags == kODInBorder)
{
handled = somSelf->HandleButton1ClickInBorder(ev, facet,
eventInfo->embeddedFacet, &windowPt, event);
}
else
{
handled = somSelf->HandleButton1Click(ev, facet, &windowPt, event);
}
break;
}
case WM_BEGINDRAG:
{
ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
ODIntToFixed(SHORT2FROMMP(event->mp1)));
return somSelf->HandleMouseDrag(ev, facet,
(eventInfo->flags == kODInEmbedded || eventInfo->flags == kODPropagated) ?
eventInfo->embeddedFacet : kODNULL,
&windowPt, event);
}
case WM_CONTEXTMENU:
handled = kODTrue;
if (_fIgnoreContextMenu && !SHORT2FROMMP(event->mp2))
break; // ignore if mouse event
else
{
PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
if (!(pInfo->fIsActive))
somSelf->ActivateFrame(ev, frame);
_fPopup->Display(ev);
}
break;
case WM_MOUSEMOVE:
{
ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
ODIntToFixed(SHORT2FROMMP(event->mp1)));
handled = somSelf->HandleMouseMove(ev, facet, frame, &windowPt, event);
}
break;
case WM_BUTTON1MOTIONEND:
{
ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
ODIntToFixed(SHORT2FROMMP(event->mp1)));
handled = somSelf->HandleButton1MotionEnd(ev, facet, frame, &windowPt, event);
}
break;
case WM_BUTTON2DOWN:
if (_fMouseMode != kNormal)
{
somSelf->ResetMouseMode(ev);
_fIgnoreContextMenu = kODTrue;
handled = TRUE;
}
else
_fIgnoreContextMenu = kODFalse;
break;
case WM_BUTTON1UP:
{
ODPoint windowPt(ODIntToFixed(SHORT1FROMMP(event->mp1)),
ODIntToFixed(SHORT2FROMMP(event->mp1)));
handled = somSelf->HandleButton1Up(ev, facet, frame, &windowPt, event);
}
break;
case WM_CHAR:
if (!((SHORT1FROMMP(event->mp1) & KC_KEYUP)))
{
handled = somSelf->HandleKeyDown(ev, frame, event);
}
break;
case WM_ACTIVATE:
handled = kODTrue; // actually ignored by dispatcher
if (SHORT1FROMMP(event->mp1) != 0)
somSelf->ActivatingWindow(ev, frame);
else
somSelf->DeActivatingWindow(ev, frame);
break;
case OD_HELP:
{
ODHelp * helpme = _fSession->GetHelp(ev);
SHORT con = SHORT1FROMMP(event->mp1);
USHORT idTopic= SHORT1FROMMP(event->mp2);
USHORT idSubTopic = SHORT2FROMMP(event->mp2);
// help panel ids now defined in cntnrhlp.h - if menu ids
// change help will still work. panels in .hlp file hard coded.
if( (idSubTopic >= IDMA_COLOR_GRAY) && (idSubTopic<=IDMA_COLOR_WHITE)){
handled = kODTrue;
switch (idSubTopic) {
case IDMA_COLOR_GRAY:
helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_GRAY_PANEL);
break;
case IDMA_COLOR_RED:
helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_RED_PANEL);
break;
case IDMA_COLOR_GREEN:
helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_GREEN_PANEL);
break;
case IDMA_COLOR_YELLOW:
helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_YELLOW_PANEL);
break;
case IDMA_COLOR_BLUE:
helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_BLUE_PANEL);
break;
case IDMA_COLOR_MAGENTA:
helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_MAGENTA_PANEL);
break;
case IDMA_COLOR_CYAN:
helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_CYAN_PANEL);
break;
case IDMA_COLOR_WHITE:
helpme->DisplayHelp(ev,"cnt.hlp",IDMA_COLOR_WHITE_PANEL);
break;
default:
handled = kODFalse;
break;
} /* endswitch */
} else {
handled = kODFalse;
} /* endif */
break;
}
case WM_COMMAND:
if (SHORT1FROMMP(event->mp2) & CMDSRC_MENU ||
SHORT1FROMMP(event->mp2) & CMDSRC_ACCELERATOR)
{
handled = somSelf->HandleMenuEvent(ev, frame, event);
}
break;
case OD_PRINT:
somSelf->HandlePrinting(ev, frame, (char *)event->mp1 );
handled = kODTrue;
break;
default:
return kODFalse;
}
SOM_CATCH_ALL
SOM_ENDTRY
return handled;
}
SOM_Scope ODBoolean SOMLINK ContainerPartHandleEventInEmbedded(ContainerPart *somSelf,
Environment *ev,
ODEventData* event,
ODFrame* frame,
ODFacet* facet,
ODFrame* embeddedFrame,
ODFacet* embeddedFacet)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleEventInEmbedded");
return kODFalse;
}
SOM_Scope void SOMLINK ContainerPartAdjustMenus(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartAdjustMenus");
SOM_TRY
PartInfoRec* pInfo = (PartInfoRec *) frame->GetPartInfo(ev);
/**********************************************************************
* Be careful what you do in this method. AdjustMenus gets called
* everytime the user presses MB1 down on the menu control.
* This method is more for adjusting the current menu. If you want
* to add items, surround them with a flag so they only get added once.
* Also, if you are the root part, but not the active part, you will
* also get called to adjust the current menubar for items on the
* Document menu (like Open as) if you support them.
**********************************************************************/
//if we are the root part, but not active ,
//get the current active menu and adjust for Open As
TempODFrame tempFrame = frame->AcquireContainingFrame(ev);
if ((tempFrame == kODNULL) && (!pInfo->fIsActive))
{
ODMenuBar *TempMenu = (_fSession->GetWindowState(ev))->AcquireCurrentMenuBar(ev);
TempMenu->EnableMenuItem(ev,IDMS_DOCUMENT,DOC_OPENAS,kODTrue);
TempMenu->Release(ev);
}
if (pInfo->fIsActive) {
char string[256];
//enable the menu items that we support
if (frame->IsRoot(ev)) {
_fMenuBar->EnableMenuItem(ev, IDMS_DOCUMENT, DOC_OPENAS, kODTrue);
} /* endif */
//enable the VIEW->Show as
_fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_SHOWAS,kODTrue);
//we enable these only IFF we are not the root part
//views we don't support yet
_fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_SASMALLICON, !(frame->IsRoot(ev)));
_fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_SALARGEICON, !(frame->IsRoot(ev)));
_fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_SATHUMBNAIL, !(frame->IsRoot(ev)));
//put a check next to our default (and only) view type
_fMenuBar->CheckMenuItem(ev,IDMS_VIEW,VIEW_SAFRAME,kODTrue);
//enable the view properties menu item
_fMenuBar->EnableMenuItem(ev,IDMS_VIEW, VIEW_PROPERTIES, kODTrue);
//enable the help menu items
_fMenuBar->EnableMenuItem(ev,IDMS_HELP, HELP_GENERAL, kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_HELP, HELP_INDEX, kODTrue);
//enable the VIEW->Open As
_fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_OPENAS,kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_OATREE, kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_OADETAILS, kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_OAICON, kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_VIEW,VIEW_OAWINDOW, !(frame->IsRoot(ev)));
if (pInfo->fGridOn) {
_fMenuBar->SetMenuItemText(ev,IDMS_VIEW, IDMA_TOGGLE_GRID, "Grid off");
if (WinLoadString( (HAB)0,_hmod,IDMA_TOGGLE_GRID_OFF,255,string))// read string table
_fMenuBar->SetMenuItemStatusText(ev,IDMA_TOGGLE_GRID,string);
}
else {
_fMenuBar->SetMenuItemText(ev, IDMS_VIEW, IDMA_TOGGLE_GRID, "Grid on");
if(WinLoadString( (HAB)0,_hmod,IDMA_TOGGLE_GRID_ON,255,string))// read string table
_fMenuBar->SetMenuItemStatusText(ev,IDMA_TOGGLE_GRID,string);// have string to load
}
//enable menu items based on single/multiple/no selection
switch (_fSelection->Count() && frame == _fSelectionFrame)
{
case 0: // no selection
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_SCALE, kODFalse);
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_ROTATE, kODFalse);
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_SELECTALL, kODTrue);
if ( somSelf->AllowPaste(ev, frame) )
{
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_PASTE_MENU, kODTrue); // [144408]
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_PASTEAS, kODFalse);
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_PASTELINK, kODFalse);
}
break;
case 1: // single selection
{
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_COPY, kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_CUT, kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_DELETE, kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_DESELECTALL, kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_SCALE, kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_ROTATE, kODTrue);
if ( somSelf->AllowPaste(ev, frame) )
{
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_PASTE_MENU, kODTrue); // [144408]
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_PASTEAS, kODFalse);
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_PASTELINK, kODFalse);
}
};
break;
default: // multiple selection
{
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_DELETE, kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, EDIT_DESELECTALL, kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_SCALE, kODTrue);
_fMenuBar->EnableMenuItem(ev,IDMS_EDIT, IDMA_ROTATE, kODTrue);
};
};
} /* endif fIsActive */
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartUndoAction(ContainerPart *somSelf,
Environment *ev,
ODActionData* actionState)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartUndoAction");
SOM_TRY
// FOR NOW, WE JUST HAVE ONE ACTION THAT CAN BE UNDONE OR REDONE.
SetBGColorRec* undoRec = (SetBGColorRec*)actionState->_buffer;
somSelf->SetBGColor2(ev, undoRec->_fFrame, undoRec->_fOldColor);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartRedoAction(ContainerPart *somSelf,
Environment *ev,
ODActionData* actionState)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartRedoAction");
SOM_TRY
// FOR NOW, WE JUST HAVE ONE ACTION THAT CAN BE UNDONE OR REDONE.
SetBGColorRec* undoRec = (SetBGColorRec*)actionState->_buffer;
somSelf->SetBGColor2(ev, undoRec->_fFrame, undoRec->_fNewColor);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartDisposeActionState(ContainerPart *somSelf,
Environment *ev,
ODActionData* actionState,
ODDoneState doneState)
{
/* ContainerPartData *somThis = ContainerPartGetData(somSelf); */
ContainerPartMethodDebug("ContainerPart","ContainerPartDisposeActionState");
// FOR NOW, WE JUST HAVE ONE ACTION THAT CAN BE UNDONE OR REDONE.
delete (SetBGColorRec*)actionState->_buffer;
}
SOM_Scope void SOMLINK ContainerPartWriteActionState(ContainerPart *somSelf,
Environment *ev,
ODActionData* actionState,
ODStorageUnitView* storageUnitView)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartWriteActionState");
}
SOM_Scope ODActionData SOMLINK ContainerPartReadActionState(ContainerPart *somSelf,
Environment *ev,
ODStorageUnitView* storageUnitView)
{
/* ContainerPartData *somThis = ContainerPartGetData(somSelf); */
ContainerPartMethodDebug("ContainerPart","ContainerPartReadActionState");
ODActionData data;
data._maximum = 0;
data._length = 0;
data._buffer = kODNULL;
return data;
}
SOM_Scope void SOMLINK ContainerPartInitPart(ContainerPart *somSelf,
Environment *ev,
ODStorageUnit* storageUnit,
ODPart* partWrapper)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartInitPart");
SOM_TRY
parent_InitPart(somSelf, ev, storageUnit, partWrapper);
_fPartWrapper = partWrapper;
somSelf->CommonInitContainerPart(ev);
ODStorageUnit* msu = somSelf->GetStorageUnit(ev);
ODSUAddPropValue(ev, msu, kODPropContents, kKindTestContainer);
_fContainerSU = msu->GetDraft(ev)->CreateStorageUnit(ev);
ODSUAddPropValue(ev, msu, kODPropDisplayFrames, kODWeakStorageUnitRefs);
ODSUAddPropValue(ev, _fContainerSU, kODPropFrameGroup, kODULong);
ODSUAddPropValue(ev, _fContainerSU, kPropEmbeddedFrames, kODStrongStorageUnitRefs);
ODSUAddPropValue(ev, _fContainerSU, kPropBGColor, kODULong);
// $$$$$ The type should be something ContainerPart specific, not kODStrongStorageUnitRefs
// since it is storing StorageUnitRefs and xforms in the same stream.
static int defcolor = 0;
_fBGColor = (defcolor++) % 8; // pick semi random color
_fNeedToExternalize = kODTrue;
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartInitPartFromStorage(ContainerPart *somSelf,
Environment *ev,
ODStorageUnit* storageUnit,
ODPart* partWrapper)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartInitPartFromStorage");
SOM_TRY
parent_InitPartFromStorage(somSelf, ev, storageUnit, partWrapper);
_fPartWrapper = partWrapper;
somSelf->CommonInitContainerPart(ev);
ODStorageUnit* su;
ODStorageUnitRef aSURef;
ODULong offset, offsetLimit;
ODMatrix mtx;
su = somSelf->GetStorageUnit(ev);
_fContainerSU = su->GetDraft(ev)->AcquireStorageUnit(ev,
ODGetStrongSURefProp(ev, su, kODPropContents, kKindTestContainer));
su->Focus(ev, kODPropDisplayFrames, kODPosSame, 0, 1, kODPosFirstSib);
offsetLimit = su->GetSize(ev);
for (offset = 0; offset < offsetLimit; offset += sizeof(ODStorageUnitRef))
{
su->SetOffset(ev, offset);
StorageUnitGetValue(su, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
if (su->IsValidStorageUnitRef(ev, aSURef))
{
ODFrame* frame = su->GetDraft(ev)->AcquireFrame(ev, su->GetIDFromStorageUnitRef(ev, aSURef));
frame->SetDroppable(ev, kODTrue);
}
}
_fFrameGroupIDCounter = ODGetULongProp(ev, _fContainerSU, kODPropFrameGroup, kODULong);
_fContainerSU->Focus(ev, kPropEmbeddedFrames,kODPosSame,0,1,kODPosFirstSib);
offsetLimit = _fContainerSU->GetSize(ev);
for (offset = 0; offset < offsetLimit;)
{
_fContainerSU->SetOffset(ev, offset);
StorageUnitGetValue(_fContainerSU, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
offset += sizeof(ODStorageUnitRef);
ODFrame *frame = _fContainerSU->GetDraft(ev)->AcquireFrame(ev, _fContainerSU->GetIDFromStorageUnitRef(ev, aSURef));
_fEmbeddedFrames->AddLast((ElementType)frame);
_fContainerSU->SetOffset(ev, offset);
StorageUnitGetValue(_fContainerSU, ev, sizeof(ODMatrix), (ODValue)&mtx);
offset += sizeof(ODMatrix);
Proxy* p = somSelf->ProxyForFrame(ev, frame);
if (!p)
{
ODTransform* transform = frame->CreateTransform(ev)->SetMatrix(ev, &mtx);
ODShape* shape = frame->AcquireFrameShape(ev, kODNULL);
ODPart* part = frame->AcquirePart(ev);
p = new Proxy(transform, shape, part);
_fContents->AddLast(p);
}
p->AddFirst(frame);
}
_fBGColor = ODGetULongProp(ev, _fContainerSU, kPropBGColor, kODULong);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartRelease(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartRelease");
SOM_TRY
ContainerPart_parent_ODPart_Release(somSelf, ev);
if (somSelf->GetRefCount(ev) == 0)
somSelf->GetStorageUnit(ev)->GetDraft(ev)->ReleasePart(ev, somSelf);
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ContainerPartReleaseAll(ContainerPart *somSelf,
Environment *ev)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartReleaseAll");
SOM_TRY
Proxy* p;
ODFrame* frame;
frame = (ODFrame*) _fDisplayFrames->First();
while (frame != kODNULL) {
_fDisplayFrames->Remove(frame);
ODReleaseObject(ev,frame);
frame = (ODFrame*) _fDisplayFrames->First();
}
frame = (ODFrame*) _fEmbeddedFrames->First();
while (frame != kODNULL) {
p = somSelf->ProxyForFrame(ev, frame);
p->Remove(frame);
_fEmbeddedFrames->Remove(frame);
ODReleaseObject(ev,frame);
frame = (ODFrame*) _fEmbeddedFrames->First();
}
p = (Proxy*) _fContents->First();
while (p != kODNULL) {
_fContents->Remove(p);
ODReleaseObject(ev, p->transform);
ODReleaseObject(ev, p->shape);
ODReleaseObject(ev, p->part);
delete p;
p = (Proxy*) _fContents->First();
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOMEXTERN void SOMLINK SOMInitModule (long majorVersion, long minorVersion,
string className)
{
SOM_IgnoreWarning (majorVersion); /* This function makes */
SOM_IgnoreWarning (minorVersion); /* no use of the passed */
SOM_IgnoreWarning (className); /* arguments. */
ContainerPartNewClass ( ContainerPart_MajorVersion, ContainerPart_MinorVersion);
}
void EXPENTRY AddMenuResourceLast( Environment *ev, HMODULE hmodDLL, long resid, ODMenuBar *menubar, ODMenuID menuid)
{
}
SOM_Scope ISOString SOMLINK M_ContainerPartclsGetODPartHandlerName(M_ContainerPart *somSelf,
Environment *ev)
{
/* M_ContainerPartData *somThis = M_ContainerPartGetData(somSelf); */
M_ContainerPartMethodDebug("M_ContainerPart","M_ContainerPartclsGetODPartHandlerName");
string handlerName = kPartHandlerName;
return (ISOString) handlerName;
}
SOM_Scope string SOMLINK M_ContainerPartclsGetODPartHandlerDisplayName(M_ContainerPart *somSelf,
Environment *ev)
{
/* M_ContainerPartData *somThis = M_ContainerPartGetData(somSelf); */
M_ContainerPartMethodDebug("M_ContainerPart","M_ContainerPartclsGetODPartHandlerDisplayName");
char str[256]; // 123248
CHAR Error[256] = ""; //used in DosLoadModule
HMODULE hmod = NULLHANDLE;
string handleDisplayName;
USHORT rc = DosLoadModule(Error,sizeof(Error),"CNTMRI",&hmod);
if(rc != 0) // 141477
{
#ifdef ODDebug
beepprintf("Unable to load Container Part's resources!");
#endif
}
rc = WinLoadString( (HAB)0,hmod,IDMA_PARTHANDLERDISPLAYNAME,255,str);// read string table 123248
if(rc) // 141477 - We have a valid string
{
handleDisplayName = (string)SOMMalloc(strlen(str)+1);
strcpy(handleDisplayName, str);
}
else
{
handleDisplayName = (string)SOMMalloc(strlen("Container Part")+1);
strcpy(handleDisplayName, "Container Part");
}
if(hmod);
DosFreeModule(hmod);
return handleDisplayName; // 123248 displayName;
}
SOM_Scope _IDL_SEQUENCE_PartKindInfo SOMLINK M_ContainerPartclsGetODPartKinds(M_ContainerPart *somSelf,
Environment *ev)
{
/* M_ContainerPartData *somThis = M_ContainerPartGetData(somSelf); */
M_ContainerPartMethodDebug("M_ContainerPart","M_ContainerPartclsGetODPartKinds");
_IDL_SEQUENCE_PartKindInfo ContainerPartInfo;
CHAR Error[256] = ""; //used in DosLoadModule
HMODULE hmod = NULLHANDLE;
DosLoadModule(Error,sizeof(Error),"CNTMRI",&hmod);
// Create structure PartKindInfo and allocate memory for variable
PartKindInfo * info = (PartKindInfo *)SOMMalloc(sizeof(PartKindInfo));
// ******************************************************************
// 123248 load part kind displayname and part category from rc file
// *****************************************************************
char str[256]; //
char emptystring[2] = {' ', '\0'};
char *pempty;
pempty = &emptystring[0];
USHORT rc = WinLoadString( (HAB)0,hmod,IDMA_PARTKINDDISPLAYSTRING,255,str);// read string table
if (rc) { // have sting to load
info->partKindDisplayName = (string)SOMMalloc(strlen(str)+1);
strcpy(info->partKindDisplayName, str);
} else {
info->partKindDisplayName = (string)SOMMalloc(strlen(emptystring)+1);
strcpy(info->partKindDisplayName, pempty);
} // endif
rc = WinLoadString( (HAB)0,hmod,IDMA_PARTCATEGORYSTRING,255,str);// read string table
if (rc) {
info->categoryDisplayName = (string)SOMMalloc(strlen(str)+1);
strcpy(info->categoryDisplayName, str);
} else { // 141477
info->categoryDisplayName = (string)SOMMalloc(strlen(emptystring)+1);
strcpy(info->categoryDisplayName,pempty);
} /* endif */
// ***********************************************************************
// ** end 123248 code
// ***********************************************************************
info->partKindName = (ISOString) SOMMalloc(strlen(kKindTestContainer) + 1);
info->categories = (string)SOMMalloc(strlen(kODCategoryDrawing)+1);
info->filenameFilters = (string)SOMMalloc(strlen("")+1);
info->filenameTypes = (string)SOMMalloc(strlen("")+1);
info->objectID = (string)SOMMalloc(strlen("")+1);
// Copy the information into the structure
strcpy(info->partKindName , kKindTestContainer);
strcpy(info->categories , kODCategoryDrawing);
strcpy(info->filenameFilters, "");
strcpy(info->filenameTypes, "");
strcpy(info->objectID, "");
ContainerPartInfo._maximum = 1;
ContainerPartInfo._length = 1;
ContainerPartInfo._buffer = info;
DosFreeModule(hmod);
return ContainerPartInfo;
}
SOM_Scope string SOMLINK M_ContainerPartclsGetOLE2ClassId(M_ContainerPart *somSelf,
Environment *ev)
{
/* M_ContainerPartData *somThis = M_ContainerPartGetData(somSelf); */
M_ContainerPartMethodDebug("M_ContainerPart","M_ContainerPartclsGetOLE2ClassId");
string classID = "";
return classID;
}
SOM_Scope string SOMLINK M_ContainerPartclsGetWindowsIconFileName(M_ContainerPart *somSelf,
Environment *ev)
{
/* M_ContainerPartData *somThis = M_ContainerPartGetData(somSelf); */
M_ContainerPartMethodDebug("M_ContainerPart","M_ContainerPartclsGetWindowsIconFileName");
string fileName = "";
return fileName;
}
MRESULT EXPENTRY CntnrPartInfoDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
switch(msg)
{
case WM_INITDLG:
SetSysMenu(hwnd); /* system menu for this dialog */
return MRFROMSHORT(FALSE);
case WM_COMMAND:
/*
* No matter what the command, close the dialog
*/
WinDismissDlg(hwnd, TRUE);
break;
default:
return(WinDefDlgProc(hwnd, msg, mp1, mp2));
}
return (MRESULT)NULL;
} /* end of ODProdInfoDlgProc() */
/* We only want Move and Close in the system menu. */
VOID SetSysMenu(HWND hDlg)
{
HWND hSysMenu;
MENUITEM Mi;
ULONG Pos;
MRESULT Id;
SHORT cItems;
hSysMenu = WinWindowFromID(hDlg, FID_SYSMENU);
WinSendMsg( hSysMenu, MM_QUERYITEM
, MPFROM2SHORT(SC_SYSMENU, FALSE), MPFROMP((PCH) & Mi));
Pos = 0L;
cItems=SHORT1FROMMR(WinSendMsg(Mi.hwndSubMenu, MM_QUERYITEMCOUNT, MPVOID, MPVOID));
while (cItems--)
{
Id = WinSendMsg( Mi.hwndSubMenu, MM_ITEMIDFROMPOSITION
, MPFROMLONG(Pos), MPVOID);
switch (SHORT1FROMMR(Id))
{
case SC_MOVE:
case SC_CLOSE:
Pos++; /* Don't delete that one. */
break;
default:
WinSendMsg( Mi.hwndSubMenu, MM_DELETEITEM
, MPARAM(Id), MPVOID);
}
}
} /* End of SetSysMenu */
// This is a test routine to check the implementation of additional
// columns in the details view. --> UI Team.
ODBoolean Test_AddDetailsColumns(ContainerPart *somSelf, Environment *ev,
ODViewExtension *ViewExt)
{
SOM_TRY
ODEmbeddedFramesIterator *CurrentFrameIter = kODNULL;
ODFrame *ChildFrame = kODNULL;
ODType kind;
ODBoolean bInLoop = TRUE ; // 128689 // flag for embeddeds all simple parts.
ODStorageUnit* su; // 128689
ULONG cnt = 0; // 128689 - Z-Ordering counter.
CurrentFrameIter=somSelf->CreateEmbeddedFramesIterator(ev,kODNULL);
if (CurrentFrameIter) {
ChildFrame=CurrentFrameIter->First(ev);
if (!ChildFrame) {
delete CurrentFrameIter;
return kODFalse;
} /* endif */
while (ChildFrame) {
TempODPart tempPart = ChildFrame->AcquirePart( ev );
kind = GetPartKind(tempPart);
su = tempPart->GetStorageUnit(ev); // 128689
cnt++; // "
// add Z-Order property to each embedded parts Storage unit - Numeric. 128689
if(!su->Exists(ev, kZOrderProp, kZOrder, 0)) {
ODStorageUnit* tst = su->AddProperty(ev,kZOrderProp);
su->Focus(ev, kZOrderProp, kODPosUndefined, kODNULL, 0, kODPosUndefined);
su->AddValue(ev,kZOrder);
StorageUnitSetValue(su, ev, sizeof(ODULong) ,&cnt);
}
if (strcmp(kind, kSimplePartKind)) {
bInLoop = FALSE;
}
ChildFrame = kODNULL;
if (CurrentFrameIter->IsNotComplete(ev))
ChildFrame = CurrentFrameIter->Next(ev);
}
if (bInLoop) {
// We add columns one by one.
char *PropName, *ValName, *ColDataType;
ODFIELDINFO fInf;
PropName = new char[256];
strcpy(PropName, kSimplePartAddProps);
ValName = new char[256];
strcpy(ValName, kSimplePartAddProp1);
ColDataType = new char[256];
strcpy(ColDataType, kODISOStr);
fInf.cb = sizeof(ODFIELDINFO);
fInf.flDataAttrs = CFA_HORZSEPARATOR | CFA_LEFT | CFA_SEPARATOR | CFA_STRING;
fInf.flTitleAttrs = CFA_CENTER;
fInf.sTitleText = new char[20];
strcpy(fInf.sTitleText, "My Column1");
ViewExt->AddDetailsColumns(ev, &fInf, &ColDataType, &PropName, &ValName, 1);
delete ValName;
delete ColDataType;
ValName = new char[256];
strcpy(ValName, kSimplePartAddProp2);
ColDataType = new char[256];
strcpy(ColDataType, kODULong);
fInf.sTitleText = new char[20];
fInf.flDataAttrs = CFA_HORZSEPARATOR | CFA_CENTER | CFA_SEPARATOR | CFA_ULONG;
strcpy(fInf.sTitleText, "My Column2");
ViewExt->AddDetailsColumns(ev, &fInf, &ColDataType, &PropName, &ValName, 1);
delete ValName;
delete ColDataType;
ValName = new char[256];
strcpy(ValName, kSimplePartAddProp3);
ColDataType = new char[256];
strcpy(ColDataType, kODTime_T);
fInf.sTitleText = new char[20];
fInf.flDataAttrs = CFA_HORZSEPARATOR | CFA_CENTER | CFA_SEPARATOR | CFA_TIME;
strcpy(fInf.sTitleText, "My Column3");
ViewExt->AddDetailsColumns(ev, &fInf, &ColDataType, &PropName, &ValName, 1);
delete ValName;
delete ColDataType;
ValName = new char[256];
strcpy(ValName, kSimplePartAddProp3);
ColDataType = new char[256];
strcpy(ColDataType, kODDate);
fInf.sTitleText = new char[20];
fInf.flDataAttrs = CFA_HORZSEPARATOR | CFA_LEFT | CFA_SEPARATOR | CFA_DATE;
strcpy(fInf.sTitleText, "My Column4");
ViewExt->AddDetailsColumns(ev, &fInf, &ColDataType, &PropName, &ValName, 1);
delete PropName; // added
delete ValName; // by
delete ColDataType; // BLG
}
// add a column for the Z-order to details container view - 128689
{
char *PropName, *ValName, *ColDataType;
ODFIELDINFO fInf;
PropName = new char[256];
strcpy(PropName, kZOrderProp );
ValName = new char[256];
strcpy(ValName, kZOrder );
ColDataType = new char[256];
strcpy(ColDataType, kODULong);
fInf.cb = sizeof(ODFIELDINFO);
fInf.flDataAttrs = CFA_HORZSEPARATOR | CFA_CENTER | CFA_SEPARATOR | CFA_ULONG;
fInf.flTitleAttrs = CFA_CENTER;
fInf.sTitleText = new char[20];
strcpy(fInf.sTitleText, "Z-order");
ViewExt->AddDetailsColumns(ev, &fInf, &ColDataType, &PropName, &ValName, 1);
delete PropName;
delete ValName;
delete ColDataType;
}
// end adding additional column to Container View detail - 128689
}
delete CurrentFrameIter;
SOM_CATCH_ALL
SOM_ENDTRY
return TRUE;
}
ODType GetPartKind(ODPart* part)
{
Environment* ev = somGetGlobalEnvironment();
SOM_TRY
ODStorageUnit* su = part->GetStorageUnit(ev);
if (su->Exists(ev, kODPropContents,(ODValueType)kODNULL,1))
{
su->Focus(ev, kODPropContents,kODPosSame,(ODValueType)kODNULL,1,kODPosSame);
return(su->GetType(ev));
}
SOM_CATCH_ALL
SOM_ENDTRY
return kODNULL;
}
//@127858 begin
SOM_Scope void SOMLINK ContainerPartHandleColorMenu(ContainerPart *somSelf,
Environment *ev,
ODFrame* frame,
ODCommandID command)
{
SOM_TRY
AEDesc objspec = {typeNull, kODNULL}; //@140231
AEDesc color = {typeNull, kODNULL}; //@140231
long newColor;
ODError err = noErr;
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartHandleColorMenu");
// Convert menu id to color index
newColor = ColorIndexFromMenuColor(command);
// Create a desc for the color
THROW_IF_ERROR( AECreateDesc(typeInteger, &newColor, sizeof(long), &color) );
// create objspec
CreatePropObjSpec(somSelf, ev, frame, formUniqueID, pBackgroundColor, objspec);
TRY
// Send the SetData event to change background color to "color"
SendSetDataEvent(somSelf, ev, objspec, color);
CATCH_ALL
err = ErrorCode();
ENDTRY
AEDisposeDesc(&color);
AEDisposeDesc(&objspec);
THROW_IF_ERROR(err);
SOM_CATCH_ALL
SOM_ENDTRY
}
void GetDirectParam(ODSession* session, OSAEvent* message, AEDesc* evtDp)
{
Environment* ev = somGetGlobalEnvironment();
SOM_TRY
AEDesc localDP = {typeNull, kODNULL}; //@140231
THROW_IF_ERROR(AEGetParamDesc(message, keyDirectObject, typeWildCard,
&localDP));
ODNameResolver* resolver = session->GetNameResolver(ev);
ODOSLToken* tmpWrapper = new ODOSLToken();
tmpWrapper->InitODOSLToken(ev);
THROW_IF_ERROR( AEDescToODDesc(&localDP, tmpWrapper ) );
ODBoolean isToken = resolver->IsODToken(ev, tmpWrapper);
ODDeleteObject( tmpWrapper );
if ( isToken )
{
*evtDp = localDP;
}
else
{
THROW( errAEEventNotHandled );
}
SOM_CATCH_ALL
SOM_ENDTRY
} // GetDirectParam()
void CreatePropObjSpec(ContainerPart *somSelf, Environment* ev, ODFrame* frame,
DescType form, DescType prop, AEDesc& objSpec)
{
AEDesc nullDesc = {typeNull, kODNULL};
AEDesc id = {typeNull, kODNULL}; //@140231
AEDesc pr = {typeNull, kODNULL}; //@140231
SOM_TRY
ODPersistentObjectID foo;
ODDraft* draft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
foo = draft->GetPersistentObjectID( ev, frame, kODFrameObject);
THROW_IF_ERROR( AECreateDesc(typeInteger, (Ptr) &foo, sizeof(foo), &id) );
THROW_IF_ERROR( AECreateDesc(typeType, (Ptr) &prop, sizeof(prop), &pr) );
// Create object specifier for this part
THROW_IF_ERROR( AECreateObjSpecifier(cPart, &nullDesc, form, &id, kODTrue, &objSpec) );
// Create object specifier for background color
THROW_IF_ERROR( AECreateObjSpecifier(cProperty, &objSpec, formPropertyID, &pr, kODTrue, &objSpec) );
SOM_CATCH_ALL
AEDisposeDesc(&id);
AEDisposeDesc(&pr);
SOM_ENDTRY
}
void SendSetDataEvent(ContainerPart *somSelf, Environment *ev, AEDesc& objSpec, AEDesc& data)
{
ODOSAEvent* event = kODNULL;
SOM_TRY
ODSession* session = somSelf->GetStorageUnit(ev)->GetSession(ev);
ODMessageInterface* msg = session->GetMessageInterface(ev);
AEDesc tempReply = {typeNull, kODNULL}; //@140231
ODOSAEvent* reply = new ODOSAEvent;
OSAEvent tempEvent = {typeNull, kODNULL}; //@140231
ODAddressDesc* address;
// Create an address descriptor for this document
msg->CreatePartAddrDesc(ev,&address, somSelf);
// Create the OSA event
msg->CreateEvent(ev, kAECoreSuite, kAESetData, address, kAnyTransactionID, &event);
ODDeleteObject(address);
// Add parms to event
ODDescToAEDesc(event, &tempEvent);
AEPutParamDesc(&tempEvent, keyDirectObject, &objSpec);
AEPutParamDesc(&tempEvent, keyAEData, &data);
// Update event with tempEvent
AEDescToODDesc(&tempEvent, (ODDesc *) event);
// Reply must have an AEDesc even though were not using it
AEDescToODDesc(&tempReply, (ODDesc *) reply);
// Send the event
msg->Send(ev, kODNULL, somSelf, event, reply, kAENoReply, kAENormalPriority, kAEDefaultTimeout);
// Delete the event
ODDeleteObject(event);
SOM_CATCH_ALL
// Delete the event
ODDeleteObject(event);
SOM_ENDTRY
}
//------------------------------------------------------------------------------
// GetPropertyFromNULL
//------------------------------------------------------------------------------
static ODError APIENTRY GetPropertyFromNULL( ODPart* part,
DescType desiredClass,
ODOSLToken* container,
DescType containerClass,
DescType form,
ODDesc* selectionData,
ODOSLToken* value,
ODSLong refCon)
{
ODError error = noErr;
TRY
Environment* ev = somGetGlobalEnvironment();
ODSession* session = ((ODPart *)refCon)->GetStorageUnit(ev)->GetSession(ev);
ODNameResolver* resolver = session->GetNameResolver(ev);
DescType propID;
ContainerPropAccessor* accessorObj;
if (form != formPropertyID)
THROW(errAEWrongDataType);
AEDesc realData = {typeNull, kODNULL}; //@140231
DescType typeCode;
Size dataSize = sizeof(DescType);
THROW_IF_ERROR( ODDescToAEDesc( selectionData, &realData ) );
AEGetDescData(&realData, &typeCode, (Ptr) &propID,
(Size)sizeof(DescType), &dataSize);
switch(propID)
{
case pBackgroundColor:
{
if ( !resolver->IsODToken( ev, value ) )
THROW( errAENoSuchObject );
AEDesc tokenDesc = {typeNull, kODNULL}; //@140231
accessorObj = new ContainerPropAccessor(propID, (ContainerPart *)refCon);
THROW_IF_ERROR( AECreateDesc(cProperty, &accessorObj, sizeof(accessorObj), &tokenDesc) );
ODDesc *userODDesc;
userODDesc = resolver->GetUserToken(ev, value);
THROW_IF_ERROR( AEDescToODDesc( &tokenDesc, userODDesc ) );
AEDisposeDesc(&tokenDesc);
}
break;
default:
THROW(errAECantSupplyType);
break;
}
CATCH_ALL
error = ErrorCode();
ENDTRY
return error;
} // GetPropertyFromNULL()
//------------------------------------------------------------------------------
// HandleSetData
//------------------------------------------------------------------------------
static ODError APIENTRY HandleSetData(ODPart* part,
ODOSAEvent* message,
ODOSAEvent* reply,
ODSLong handlerRefcon)
{
ODError error = noErr;
ODOSLToken* tmpWrapper = kODNULL;
TRY
AEDesc theData = {typeNull, kODNULL}; //@140231
Environment* ev = somGetGlobalEnvironment();
ODSession* session = ((ODPart *)handlerRefcon)->GetStorageUnit(ev)->GetSession(ev);
ODNameResolver* resolver = session->GetNameResolver(ev);
OSAEvent realMessage = {typeNull, kODNULL}; //@140231
OSAEvent realReply = {typeNull, kODNULL}; //@140231
THROW_IF_ERROR( ODDescToAEDesc(message, &realMessage) );
THROW_IF_ERROR( ODDescToAEDesc(reply, &realReply ));
THROW_IF_ERROR(AEGetKeyDesc(&realMessage, keyAEData,
typeWildCard, &theData));
AEDesc evtDp = {typeNull, kODNULL}; //@140231
GetDirectParam( session, &realMessage, &evtDp);
tmpWrapper = new ODOSLToken();
tmpWrapper->InitODOSLToken(ev);
THROW_IF_ERROR( AEDescToODDesc(&evtDp, tmpWrapper ) );
if ( !resolver->IsODToken( ev, tmpWrapper ) )
THROW( errAENoSuchObject );
ODDesc* myTokenODDesc;
myTokenODDesc = resolver->GetUserToken(ev, tmpWrapper);
AEDesc theToken = {typeNull, kODNULL}; //@140231
error = ODDescToAEDesc(myTokenODDesc, &theToken );
if (error == noErr)
{
switch (theToken.descriptorType)
{
case typeProperty:
{
DescType typeCode;
ContainerPropAccessor* embedPropAccessorObj;
Size dataSize = sizeof(embedPropAccessorObj);
// get prop accessor obj ptr
AEGetDescData(&theToken, &typeCode, (Ptr) &embedPropAccessorObj,
(Size)sizeof(embedPropAccessorObj), &dataSize);
embedPropAccessorObj->SetData(&theData);
delete embedPropAccessorObj;
}
break;
}
}
AEDisposeDesc(&theData);
THROW_IF_ERROR(error);
CATCH_ALL
error = ErrorCode();
ENDTRY
ODDeleteObject( tmpWrapper );
return error;
} // HandleSetData()
//------------------------------------------------------------------------------
// HandleGetData
//------------------------------------------------------------------------------
static ODError APIENTRY HandleGetData(ODPart* part,
ODOSAEvent* message,
ODOSAEvent* reply,
ODSLong handlerRefcon)
{
ODError error = noErr;
ODOSLToken* tmpWrapper = kODNULL;
TRY
DescType reqType;
Size theSize;
AEDesc objectData = {typeNull, kODNULL}; //@140231
Environment* ev = somGetGlobalEnvironment();
ODSession* session = ((ODPart *)handlerRefcon)->GetStorageUnit(ev)->GetSession(ev);
ODNameResolver* resolver = session->GetNameResolver(ev);
OSAEvent realMessage = {typeNull, kODNULL}; //@140231
OSAEvent realReply = {typeNull, kODNULL}; //@140231
THROW_IF_ERROR( ODDescToAEDesc(message, &realMessage));
THROW_IF_ERROR( ODDescToAEDesc(reply, &realReply));
AEDesc evtDp = {typeNull, kODNULL}; //@140231
GetDirectParam( session, &realMessage, &evtDp);
tmpWrapper = new ODOSLToken();
tmpWrapper->InitODOSLToken(ev);
THROW_IF_ERROR( AEDescToODDesc(&evtDp, tmpWrapper ) );
if ( !resolver->IsODToken( ev, tmpWrapper ) )
THROW( errAENoSuchObject );
ODDesc* myTokenODDesc;
myTokenODDesc = resolver->GetUserToken(ev, tmpWrapper);
AEDesc token = {typeNull, kODNULL}; //@140231
THROW_IF_ERROR( ODDescToAEDesc(myTokenODDesc, &token ) );
// Next, get the requested return type, if it exists.
error = AEGetParamPtr(&realMessage, keyAERequestedType, typeType,
&reqType, (Ptr)&reqType, sizeof(reqType), &theSize);
if (error == errAEDescNotFound) // Not an error if return type is not found.
{
error = noErr;
reqType = typeWildCard;
}
THROW_IF_ERROR(error);
switch (token.descriptorType)
{
case typeProperty:
{
DescType typeCode;
ContainerPropAccessor* embedPropAccessorObj;
Size dataSize = sizeof(embedPropAccessorObj);
AEGetDescData(&token, &typeCode, (Ptr) &embedPropAccessorObj,
(Size)sizeof(embedPropAccessorObj), &dataSize);
embedPropAccessorObj->GetData(&objectData);
delete embedPropAccessorObj;
}
break;
}
error = AEPutParamDesc( &realReply, keyAEResult, &objectData );
AEDisposeDesc( &objectData );
THROW_IF_ERROR(error);
THROW_IF_ERROR( AEDescToODDesc( &realReply, reply ) );
CATCH_ALL
error = ErrorCode();
ENDTRY
ODDeleteObject( tmpWrapper );
return error;
} // HandleGetData()
//==============================================================================
// ContainerPropAccessor
//==============================================================================
//------------------------------------------------------------------------------
// ContainerPropAccessor::ContainterPropAccessor
//------------------------------------------------------------------------------
ContainerPropAccessor::ContainerPropAccessor(DescType property, ContainerPart* part)
{
fProperty = property;
fPart = part;
}
//------------------------------------------------------------------------------
// ContainerPropAccessor::SetData
//------------------------------------------------------------------------------
void ContainerPropAccessor::SetData(AEDesc* data)
{
Environment* ev = somGetGlobalEnvironment();
SOM_TRY
ContainerPartData *somThis = ContainerPartGetData(fPart);
switch(fProperty)
{
case pBackgroundColor:
{
DescType typeCode;
AEDesc numDesc = {typeNull, kODNULL}; //@140231 ;
long newColor;
Size dataSize = sizeof(long);
THROW_IF_ERROR( AECoerceDesc(data, typeInteger, &numDesc) );
AEGetDescData(&numDesc, &typeCode, (Ptr) &newColor,
(Size)sizeof(long), &dataSize);
//!!! This whole method do with some cleanup
// Change SetBGColor to use a command number
ODxOrderedCollectionIterator aIter(_fDisplayFrames);
for (ODFrame *frame = (ODFrame*)aIter.First();aIter.IsNotComplete() ;frame = (ODFrame*)aIter.Next() )
{
fPart->SetBGColor1(ev, frame, newColor);
frame->Invalidate(ev,NULL,kODNULL);
}
THROW_IF_ERROR( AEDisposeDesc(&numDesc) );
break;
}
default:
THROW(errAENotModifiable);
break;
}
SOM_CATCH_ALL
SOM_ENDTRY
} // ContainerPropAccessor::SetData
//------------------------------------------------------------------------------
// ContainerPropAccessor::GetData
//------------------------------------------------------------------------------
void ContainerPropAccessor::GetData(AEDesc* objectData)
{
Environment* ev = somGetGlobalEnvironment();
SOM_TRY
ContainerPartData *somThis = ContainerPartGetData(fPart);
ODError result;
switch(fProperty)
{
case pBackgroundColor:
{
THROW_IF_ERROR( AECreateDesc(typeInteger, &_fBGColor, sizeof(long), objectData) );
break;
}
default:
THROW(errAENoSuchObject);
break;
}
SOM_CATCH_ALL
SOM_ENDTRY
} // ContainerPropAccessor::GetData
//@127858 end
// [131094] starts
SOM_Scope void SOMLINK ContainerPartShowSelection(ContainerPart *somSelf,
Environment *ev,
ODFrame* ownerFrame,
ODBoolean show)
{
ContainerPartData *somThis = ContainerPartGetData(somSelf);
ContainerPartMethodDebug("ContainerPart","ContainerPartShowSelection");
SOM_TRY
ODFacet* facet;
if (_fSelection->Count() && ownerFrame == _fSelectionFrame)
{
ODxOrderedCollectionIterator i(_fEmbeddedFrames);
for (ODFrame* frame = (ODFrame*)i.First();
i.IsNotComplete();
frame = (ODFrame*)i.Next())
{
TempODFrame containingFrame = frame->AcquireContainingFrame(ev);
if (containingFrame == ownerFrame)
{
Proxy* p = somSelf->ProxyForFrame(ev, frame);
if (_fSelection->Contains(p))
{
somSelf->SetFrameSelected(ev, frame, show);
frame->Invalidate(ev, kODNULL, kODNULL);
}
}
}
}
somSelf->InvalidateSelection(ev, ownerFrame);
if (show)
somSelf->ClipSelectionFromEmbeddedFrames(ev, ownerFrame);
else
somSelf->UnClipSelectionFromEmbeddedFrames(ev, ownerFrame);
SOM_CATCH_ALL
SOM_ENDTRY
}
// [131094] ends