#ifndef _PUZZLE_
#define _PUZZLE_

#ifndef _PART_
#include "Part.idl"
#endif 

//==============================================================================
// OpenDoc types
//==============================================================================
interface ODWindow;
interface OrderedCollection;
interface ODSession;
interface ODFocusSet;
interface ODMenuBar;
interface ODPartWrapper;

#ifdef __PRIVATE__
//==============================================================================
// Implementation Types
//==============================================================================

typedef somToken  OrderedCollection;
typedef somToken  RgnHandle;
typedef somToken  MenuHandle;
typedef somToken  SndChannelPtr;
typedef somToken  Handle;
typedef somToken  Proxy;
typedef somToken  PuzzleFacetInfo;

#endif 

//==============================================================================
// Puzzle
//==============================================================================

interface Puzzle : ODPart
{
#ifdef __PRIVATE__
	ODWindow ODCreateWindow(in ODFrame sourceFrame);
	void ClipShapeChanged(in ODFacet facet);
	void ExternalTransformChanged(in ODFacet facet);
	ODBoolean HandleMouseDown(in ODFacet facet, in ODPoint where, in ODEventData event);
	ODBoolean HandleMouseDownDrag(in ODFacet facet, in Proxy* selection, in ODEventData event);
	ODBoolean HandleMouseDownEdgeResize(in ODFacet facet, in Proxy* selection, in POINT mouse);
	ODBoolean HandleMouseDownCornerResize(in ODFacet facet, in Proxy* selection, in POINT mouse);
	ODBoolean HandleMenuEvent(in ODFrame focusFrame, in ODEventData event);
	ODBoolean HandleMouseDownInPuzzlePiece(in ODFacet containingFacet, in ODFacet facetClickedIn);
	void DoIdle();
	void ActivateFrame(in ODFrame frame);
	void CommonInitPuzzle();
	void ActivatingWindow(in ODFrame frame);
	void DeActivatingWindow(in ODFrame frame);
	void InstallMenus(in ODFrame aFrame);
	void InvalidateSelection(in ODFrame frame);
	void EmptySelection();
	void ClipEmbeddedFrames(in ODFrame frame);
	void ClipEmbeddedFacets(in ODFacet facet);
	Proxy* ProxyForFrame(in ODFrame frame);
	void CreateSelectionBorder(in Proxy* theProxy);
	void UpdateProxyRegion(in Proxy* proxy);
	void DrawPuzzlePartText(in ODFacet facet);
	void ToggleHilite(in ODFacet facet);
	ODShape CalcEmbeddedPartShape(in ODFrame parentFrame);
	ODFrame CreateAnEmbeddedFrame(in ODFrame containingFrame,
	 in ODPart embedPart,
	 in ODTypeToken viewType,
	 in ODTypeToken presentation,
	 in ODBoolean isOverlaid);
	void CreatePuzzleFacets(in ODFacet facetDroppedInto, in ODFrame newFrame);
	void FreezeFrames(in ODBoolean YeahOrNay);
	void ScramblePuzzle();
	ODBoolean IsPuzzleSolved();
	void MoveThisPuzzlePiece(in PuzzleFacetInfo* thisPieceInfo, in ODFacet thisPiece, in ODSShort xAmount, in ODSShort yAmount);
	void DoPuzzleSolvedThing();
	void PlayAPuzzleSound();
	ODBoolean DoAbout();
	void InvalEmbedFrameAfterResize(in ODFacet facet, in Proxy* selection,
								  in ODShape oldShape, in ODShape newShape,
								  in POINT transOffset);
	RECT* GetSelectionRectLocal(in Proxy* selection);

#endif 

#ifdef __SOMIDL__
  implementation
	{
	override:
		somInit,
		somUninit,
		Externalize,
		Release,
		ReleaseAll,
		HasExtension,
		GetExtension,
		FulfillPromise,
		DropCompleted,
		DragEnter,
		DragWithin,
		DragLeave,
		Drop,
		ContainingPartPropertiesChanged,
		GetContainingPartProperties,
		RevealFrame,
		EmbeddedFrameSpec,
		CreateEmbeddedFramesIterator,
		DisplayFrameAdded,
		DisplayFrameRemoved,
		DisplayFrameConnected,
		DisplayFrameClosed,
		AttachSourceFrame,
		GeometryChanged,
		FrameShapeChanged,
		ViewTypeChanged,
		PresentationChanged,
		SequenceChanged,
		WritePartInfo,
		ReadPartInfo,
		Open,
		RequestEmbeddedFrame,
		RemoveEmbeddedFrame,
		RequestFrameShape,
		UsedShapeChanged,
		AdjustBorderShape,
		FacetAdded,
		FacetRemoved,
		CanvasChanged,
		Draw,
		CanvasUpdated,
		HighlightChanged,
		GetPrintResolution,
		CreateLink,
		LinkUpdated,
		RevealLink,
		EmbeddedFrameChanged,
		LinkStatusChanged,
		BeginRelinquishFocus,
		CommitRelinquishFocus,
		AbortRelinquishFocus,
		FocusAcquired,
		FocusLost,
		CloneInto,
		ExternalizeKinds,
		ChangeKind,
		HandleEvent,
		HandleEventInEmbedded,
		MouseEnter,
		MouseWithin,
		MouseLeave,
		AdjustMenus,
		UndoAction,
		RedoAction,
		DisposeActionState,
		WriteActionState,
		ReadActionState,
		InitPart,
		InitPartFromStorage;

	releaseorder:
#ifdef __PRIVATE__
		ODCreateWindow,
		ClipShapeChanged,
		ExternalTransformChanged,
		HandleMouseDown,
		HandleMouseDownDrag,
		HandleMouseDownEdgeResize,
		HandleMouseDownCornerResize,
		HandleMenuEvent,
		HandleMouseDownInPuzzlePiece,
		DoIdle,
		ActivateFrame,
		CommonInitPuzzle,
		ActivatingWindow,
		DeActivatingWindow,
		InstallMenus,
		InvalidateSelection,
		EmptySelection,
		ClipEmbeddedFrames,
		ClipEmbeddedFacets,
		ProxyForFrame,
		CreateSelectionBorder,
		UpdateProxyRegion,
		DrawPuzzlePartText,
		ToggleHilite,
		CalcEmbeddedPartShape,
		CreateAnEmbeddedFrame,
		CreatePuzzleFacets,
		FreezeFrames,
		ScramblePuzzle,
		IsPuzzleSolved,
		MoveThisPuzzlePiece,
		DoPuzzleSolvedThing,
		PlayAPuzzleSound,
		DoAbout,
		InvalEmbedFrameAfterResize,
		GetSelectionRectLocal;
#else

		reserved1,
		reserved2,
		reserved3,
		reserved4,
		reserved5,
		reserved6,
		reserved7,
		reserved8,
		reserved9,
		reserved10,
		reserved11,
		reserved12,
		reserved13,
		reserved14,
		reserved15,
		reserved16,
		reserved17,
		reserved18,
		reserved19,
		reserved20,
		reserved21,
		reserved22,
		reserved23,
		reserved24,
		reserved25,
		reserved26,
		reserved27,
		reserved28,
		reserved29,
		reserved30,
		reserved31,
		reserved32,
		reserved33,
		reserved34,
		reserved35;

#endif 

	majorversion = 1; minorversion = 0;
#ifdef __PRIVATE__
	// instance variables
		ODSession 				fSession;
		ODPartWrapper 			fPartWrapper;
		OrderedCollection* 		fDisplayFrames;
		OrderedCollection* 		fEmbeddedFrames;
		OrderedCollection* 		fContents;
		OrderedCollection* 		fSelection;
		OrderedCollection* 		fPuzzleFacets;
		ODULong 				fFrameGroupIDCounter;
		ODRgnHandle 			fSelectRgn;
		ODRgnHandle 			fCornerHandleRgn;
		ODRgnHandle 			fEdgeHandleRgn;
		ODFocusSet	 			fFocusSet;
		ODMenuBar 				fMenuBar;
		ODPlatformMenu			fPuzzleMenu;
		ODTypeToken				fSelectionFocus,
								fMenuFocus,
								fKeyFocus,
								fkODViewAsSmallIcon,
								fkODViewAsLargeIcon,
								fkODViewAsThumbnail,
								fkODViewAsFrame;
		ODBoolean 				fDraggingAcceptableItem;
		ODBoolean 				fAlreadyContainAPart;
		ODBoolean 				fDoClickSounds;
		ODSShort 				fMode; // EditInPlace or Solve
		POINT					fEmptyPieceGridLocation; // value ranging from {0, 0} to {3, 3}

	#endif 


  };
#endif 
};

#endif //_PUZZLE_

