tictactoeappview.h

来自「symbianOS第三版开发与实用教程部分源码和部分试验」· C头文件 代码 · 共 120 行

H
120
字号
/*
* ==============================================================================
*  Name        : TicTacToeAppView.h
*  Part of     : TicTacToe
*  Interface   : 
*  Description : 
*  Version     : 
*
*  Copyright (c) 2005 Nokia Corporation.
* ==============================================================================
*/

#ifndef __TICTACTOE_APPVIEW_H__
#define __TICTACTOE_APPVIEW_H__

//  INCLUDES

#include "TicTacToeBoard.h"
#include <coecntrl.h>

// CLASS DECLARATION

/**
* An instance of the Application View object for the TicTacToe application.
*/
class CTicTacToeAppView : public CCoeControl
    {
    public:

        /**
        * Create a CTicTacToeAppView object, which will draw itself to aRect.
        * @param aRect the rectangle this view will be drawn to
        * @result a pointer to the created instance of CTicTacToeAppView
        */
        static CTicTacToeAppView* NewL(const TRect& aRect, TInt aGraphicsSet);

        /**
        * Destroy the object.
        */
         ~CTicTacToeAppView();

    public: // New functions

        /**
        * Load a set of graphics.
        * @param aGraphicsSet Which set of graphics to load.
        */
        void LoadIconsL(TInt aGraphicsSet);

        /**
        * Start a new game.
        */
        void NewGame();

    public:  // from CCoeControl

        /**
        * Draw this CTicTacToeAppView to the screen.
        * @param aRect the rectangle of this view that needs updating
        */
        void Draw(const TRect& aRect) const;
      

        /**
        * Handle any user keypresses.
        * @param aKeyEvent holds the data for the event that occurred
        * @param aType holds the type of key event that occured
        * @result a TKeyResponse indicating if the key was consumed or not
        */
        TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
    	
        /**
        * Handle a change in the size of the control.
        */
    	void SizeChanged();

    private:

        /**
        * Perform the second phase construction of a CTicTacToeAppView object.
        * @param aRect the rectangle this view will be drawn to
        */
        void ConstructL(const TRect& aRect, TInt aGraphicsSet);

        /**
        * Perform the first phase of two phase construction.
        */
        CTicTacToeAppView();

        /**
        * Set the sizes of the scalable icons.
        */
        void SetIconSizes();

    private:    // Data

        // The game board
        TTicTacToeBoard iBoard;
        // Player whose turn it is
        TTicTacToePlayer iPlayer;
        // Scalable icons
        CFbsBitmap* iBitmapGrid;
        CFbsBitmap* iBitmapGridMask;
        CFbsBitmap* iBitmapNought;
        CFbsBitmap* iBitmapNoughtMask;
        CFbsBitmap* iBitmapCross;
        CFbsBitmap* iBitmapCrossMask;
        // Rectangle the board occupies
        TRect iBoardRect;
        // Offset of the icons for the cell contents
        TPoint iCellMargin;
        // Size of the icons for the cell contents
        TSize iCellSize;
    };


#endif // __TICTACTOE_APPVIEW_H__

// End of File

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?