// BOSSVIEW.H
//
// Copyright (c) 1998 Symbian Ltd.  All rights reserved.
//

#ifndef __BOSSVIEW_H
#define __BOSSVIEW_H

#include <coecntrl.h>

class TBossPuzzle;

class CBossView : public CBase
	{
	friend class CBossControl;
public:
	// construct/destruct
	IMPORT_C CBossView(TBossPuzzle* iModel);
	IMPORT_C void ConstructL(MGraphicsDeviceMap* aDeviceMap);
	~CBossView();
	// drawing
	IMPORT_C void Draw(CGraphicsContext& aGc, const TRect& /* aRect */, const TPoint& aTopLeft) const;
	IMPORT_C void SetDeviceMapL(MGraphicsDeviceMap* aDeviceMap);
	// information
	IMPORT_C void GetOriginalSizeInTwips(TSize& aSize) const;
private:
	void GetBoardRect(TRect& aBoardRect) const;
	void DrawBackground(const TRect& aRect) const;
	void DrawBoard() const;
	void GetTileRect(TRect& aTileRect, TInt aRow, TInt aCol) const;
	void DrawTile(TInt aRow, TInt aCol) const; // tile or blank
	void ReleaseTileFont();
	IMPORT_C CBossView();
private:
	// real property
	TBossPuzzle* iModel;
	MGraphicsDeviceMap* iDeviceMap;
	CFont* iTileFont;
	// sizes
	TPoint iTileSizeInPixels;
	TPoint iTileBorderInPixels;
	TPoint iBoardSizeInPixels;
	TPoint iBoardMarginInPixels;
	// drawing stuff
	CGraphicsContext* iGc;
	TPoint iTopLeft;
	};

class CBossControl : public CCoeControl
	{
public:
	// construct/destruct
	IMPORT_C CBossControl(TBossPuzzle* aModel, CBossView* aView);
	IMPORT_C void ConstructL(const CCoeControl* aParent, const TRect& aRect);
	~CBossControl();
	// incremental update
	IMPORT_C void MoveTile(TInt aOldBlankRow, TInt aOldBlankCol, TInt aNewBlankRow, TInt aNewBlankCol) const;
private: // framework
	virtual void Draw(const TRect& /* aRect */) const;
	IMPORT_C CBossControl();
private: // data
	TBossPuzzle* iModel;
	CBossView* iView;
	};

#endif
