📄 bossview.h
字号:
// bossview.h
//
// Copyright (c) 1998 Symbian Ltd. All rights reserved.
#ifndef __BOSSVIEW_H
#define __BOSSVIEW_H
#include <coecntrl.h>
#include "bosseng.h"
class CBossView : public CBase
{
friend class CBossControl;
friend class CBossScroller;
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;
IMPORT_C TSize GetSizeInPixels() 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();
TInt GetTileFromXY(const TPoint& aPoint, TInt& aRow, TInt& aCol);
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 MBossControlObserver
{
public:
virtual void BCOMove(TInt aRow, TInt aCol)=0; // move specified tile
virtual void BCOMove(TBossPuzzle::TMoveType)=0; // move in specified direction
};
class CBossScroller;
class CBossControl : public CCoeControl
{
public:
// construct/destruct
IMPORT_C CBossControl(TBossPuzzle* aModel, CBossView* aView, MBossControlObserver* aObserver);
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;
IMPORT_C void FinishMove() const;
private: // framework
virtual void Draw(const TRect& /* aRect */) const;
IMPORT_C CBossControl();
void HandlePointerEventL(const TPointerEvent& aPointerEvent);
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
private: // data
TBossPuzzle* iModel;
CBossView* iView;
MBossControlObserver* iObserver;
CBossScroller* iScroller;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -