亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? oandxappview.cpp

?? Symbian OS C++ for Mobile Phones v3 Example Code
?? CPP
字號:
// Copyright (c) 2004 - 2006, Symbian Software Ltd. All rights reserved.

#include <coemain.h>
#include <gulutil.h>
#include <e32keys.h>

#include "OandXAppView.h"
#include "OandXAppUi.h"
#include "OandX.pan"
#include "oandxdefs.h"
#include "oandxcontroller.h"
#include "oandxengine.h"


// O and X symbol-drawing control member functions

void COandXSymbolControl::DrawSymbol(CWindowGc& aGc, TRect& aRect, TBool aDrawCross) const
    {
    TSize size;
    size.SetSize(aRect.iBr.iX- aRect.iTl.iX, aRect.iBr.iY - aRect.iTl.iY);
    aRect.Shrink(size.iWidth/6,size.iHeight/6); // Shrink by about 15%
    aGc.SetPenStyle(CGraphicsContext::ESolidPen);
    
    size.iWidth /= 9; // Pen size set to just over 10% of the shape's size
    size.iHeight /= 9;
    aGc.SetPenSize(size);
    if (aDrawCross)
        {
        aGc.SetPenColor(KRgbGreen);
        aRect.Shrink(size.iWidth/2,size.iHeight/2); // Cosmetic reduction of cross size by half the line width
        aGc.DrawLine(aRect.iTl, aRect.iBr);
        TInt temp;
        temp = aRect.iTl.iX;
        aRect.iTl.iX = aRect.iBr.iX;
        aRect.iBr.iX = temp;
        aGc.DrawLine(aRect.iTl, aRect.iBr);
        }
    else // draw a circle
        {
        aGc.SetPenColor(KRgbRed);
        aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
        aGc.DrawEllipse(aRect);
        }
    };



COandXTile* COandXTile::NewL(const CCoeControl* aContainer)
/**
	Factory function allocates new initialized instance of COandXTile.
	
	@param	aContainer		Control which will contain the new component control.
	@return					New instance of COandXTile which will be owned by
							the caller.
 */
	{
	COandXTile* self = new(ELeave) COandXTile;
	CleanupStack::PushL(self);
	self->ConstructL(aContainer);
	CleanupStack::Pop(self);
	return self;
	}

COandXTile::COandXTile()
/**
	This private constructor is defined to ensure it is
	implemented exactly once, and to ensure all instances
	are allocated via NewL.
 */
    {
    // empty.
    }

void COandXTile::ConstructL(const CCoeControl* aContainer)
/**
	Perform secondary initialization by registering this control
	as a component of the supplied container control.

	@param	aContainer		Control which will own the new component control.
 */
    {
    SetContainerWindowL(*aContainer);
    }

void COandXTile::Draw(const TRect& aRect) const
/**
	Override CCoeControl by redrawing this tile.  This
	draws a blank square, possibly with a nought or cross on it.
	
	@param	aRect			Area of the control which needs to be redrawn.
							This is not used, and the entire control is
							redrawn.
 */
    {
    (void) aRect;
    
    TInt tileType = iAppView->SquareStatus(this);

    CWindowGc& gc = SystemGc();
    TRect rect = Rect();
    
    if (IsFocused())
        {
        gc.SetBrushColor(KRgbYellow);
        }
    gc.Clear(rect);
    if (tileType!=ETileBlank)
        {
        DrawSymbol(gc, rect, tileType==ETileCross);
        }
    }

void COandXTile::SetOwnerAndObserver(COandXAppView* aControl)
    {
    iAppView = aControl;
    SetObserver(aControl);
    }

void COandXTile::TryHitL()
    {
    iAppView->TryHitSquareL(this);
    }

TKeyResponse COandXTile::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    TKeyResponse keyResponse = EKeyWasNotConsumed;
    if (aType!=EEventKey)
        {
        return keyResponse;
        }
    switch (aKeyEvent.iCode)
        {
    case EKeyOK:
        TryHitL();
        keyResponse = EKeyWasConsumed;
        break;
    default:
        keyResponse = EKeyWasNotConsumed;
        break;        
        }
    return keyResponse;
    }

TCoeInputCapabilities COandXTile::InputCapabilities() const
    {
    return TCoeInputCapabilities::ENavigation;
    }

void COandXTile::HandlePointerEventL(const TPointerEvent& aPointerEvent)
    {
    if (aPointerEvent.iType == TPointerEvent::EButton1Down)
        {
        TryHitL();
        }
    }

void COandXTile::FocusChanged(TDrawNow aDrawNow)
    {
    if (aDrawNow == EDrawNow)
        {
        DrawNow();
        }
    }

// Status window

COandXStatusWin* COandXStatusWin::NewL(RWindow& aWindow)
    {
	COandXStatusWin* self=new(ELeave) COandXStatusWin;
	CleanupStack::PushL(self);
	self->ConstructL(aWindow);
	CleanupStack::Pop(self);
	return self;
    }

COandXStatusWin::COandXStatusWin()
    {
    }
    
void COandXStatusWin::ConstructL(RWindow& aWindow)
    {
    SetContainerWindowL(aWindow);
    // No call to ActivateL() as the window is activated by its container
    }

void COandXStatusWin::Draw(const TRect& /*aRect*/) const
    {
    CWindowGc& gc = SystemGc();
    TRect boxRect = Rect();
    gc.Clear(boxRect);
    TInt boxHeight = boxRect.iBr.iY - boxRect.iTl.iY;
    boxRect.iTl.iX = boxRect.iBr.iX - boxHeight;
    TBool crossTurn = Controller().IsCrossTurn();
    DrawSymbol(gc, boxRect, crossTurn);
    }


// App View member functions

#define KBorderWidth 10
#define KLineWidth ((KTilesPerRow > KTilesPerCol ? KTilesPerRow : KTilesPerCol) > 4 ? 2 : 4)


COandXAppView* COandXAppView::NewL(const TRect& aRect)
	{
	COandXAppView* self = new(ELeave) COandXAppView;
	CleanupStack::PushL(self);
	self->ConstructL(aRect);
	CleanupStack::Pop(self);
	return self;
	}

COandXAppView::COandXAppView()
/**
	
 */
	{
	// empty.
	}

COandXAppView::~COandXAppView()
    {
	iTiles.ResetAndDestroy();
    delete iStatusWin;
    }

void COandXAppView::ConstructL(const TRect& aRect)
    {
    // Create a window for this application view
    CreateWindowL();

    for (TInt i = 0; i < KNumberOfTiles; i++)
        {
		COandXTile* tile = CreateTileL();
		CleanupStack::PushL(tile);		// in case AppendL fails
		iTiles.AppendL(tile);
		CleanupStack::Pop(tile);
        }
    ComponentControl(0)->SetFocus(ETrue);
    iStatusWin = COandXStatusWin::NewL(Window());

    // Set the window's size
    SetRect(aRect); // needs to be after component creation - see SizeChanged()
    // Activate the window, which makes it ready to be drawn
    ActivateL();
    }

COandXTile* COandXAppView::CreateTileL()
    {
    COandXTile* tile = COandXTile::NewL(this);
    tile->SetOwnerAndObserver(this);
    return tile;
    }

void COandXAppView::SizeChanged()
    {
    __ASSERT_DEBUG(iTiles[KNumberOfTiles-1], Panic(EOandXNoTiles)); // all component tiles must already exist

    TRect rect = Rect();
    rect.iTl.iY = rect.iBr.iY - KStatusWinHeight;
    iStatusWin->SetRect(rect);
    rect = Rect();
    rect.iBr.iY -= KStatusWinHeight;
    TSize controlSize = rect.Size();
    TSize tileSize;
    tileSize.iWidth=2*((controlSize.iWidth-2*KBorderWidth-(KTilesPerRow-1)*KLineWidth)/(2*KTilesPerRow));
    tileSize.iHeight=2*((controlSize.iHeight-2*KBorderWidth-(KTilesPerCol-1)*KLineWidth)/(2*KTilesPerCol));
    iTileSide = tileSize.iWidth < tileSize.iHeight ? tileSize.iWidth :tileSize.iHeight;
    TSize boardSize;
    boardSize.iWidth = KTilesPerRow*iTileSide + (KTilesPerRow-1)*KLineWidth;
    boardSize.iHeight = KTilesPerCol*iTileSide + (KTilesPerCol-1)*KLineWidth;
    iBoardRect.iTl.iX = (controlSize.iWidth - boardSize.iWidth)/2;
    iBoardRect.iTl.iY = (controlSize.iHeight - boardSize.iHeight)/2;
    iBoardRect.iBr.iX = iBoardRect.iTl.iX + boardSize.iWidth;
    iBoardRect.iBr.iY = iBoardRect.iTl.iY + boardSize.iHeight;
    iBorderRect = iBoardRect;
    iBorderRect.Grow(KBorderWidth,KBorderWidth);
	
    for (TInt i=0; i<KNumberOfTiles; i++)
        {
        TInt row = i / KTilesPerRow;
        TInt col = i % KTilesPerRow;
        TRect tileRect;
        tileRect.iTl.iX = iBoardRect.iTl.iX + col * (iTileSide + KLineWidth);
        tileRect.iTl.iY = iBoardRect.iTl.iY + row * (iTileSide + KLineWidth);
        tileRect.iBr.iX = tileRect.iTl.iX + iTileSide;
        tileRect.iBr.iY = tileRect.iTl.iY + iTileSide;
        ComponentControl(i)->SetRect(tileRect);
        }
    }
	

void COandXAppView::Draw(const TRect& /*aRect*/) const
    {
    CWindowGc& gc = SystemGc();
    
	// if no current game then print a message and return
	if (! Controller().DrawableGame())
		{
		CWindowGc& gc = SystemGc();
		gc.SetPenColor(KRgbBlack);
		gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
		gc.SetBrushColor(KRgbWhite);
		
		const CFont* pf = CEikonEnv::Static()->DenseFont();
		gc.UseFont(pf);
		
		// write message about 1/4 way down application view
		_LIT(KNoGameMsg, "No current game.");
		const TRect rFull = Rect();
		TInt height = rFull.Height();
		TInt useBase = (height / 4) + pf->BaselineOffsetInPixels();
		gc.DrawText(KNoGameMsg, rFull, useBase, CGraphicsContext::ECenter);
		gc.DiscardFont();

		return;
		}

    TRect rect = Rect();
	
    // Draw outside the border
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.SetBrushColor(KRgbWhite);
    DrawUtils::DrawBetweenRects(gc, rect, iBorderRect);
    
    // Draw a border around the board
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.SetBrushColor(KRgbGray);
    DrawUtils::DrawBetweenRects(gc, iBorderRect, iBoardRect);
    
    //Draw the first vertical line
    gc.SetBrushColor(KRgbBlack);
    TRect line;
    line.iTl.iX = iBoardRect.iTl.iX + iTileSide;
    line.iTl.iY = iBoardRect.iTl.iY;
    line.iBr.iX = line.iTl.iX + KLineWidth;
    line.iBr.iY = iBoardRect.iBr.iY;
    gc.DrawRect(line);
    TInt i;
    // Draw the remaining (KTilesPerRow-2) vertical lines
    for (i = 0; i < KTilesPerRow - 2; i++)
        {
        line .iTl.iX += iTileSide + KLineWidth;
        line .iBr.iX += iTileSide + KLineWidth;
        gc.DrawRect(line);
        }
    // Draw the first horizontal line
    line.iTl.iX = iBoardRect.iTl.iX;
    line.iTl.iY = iBoardRect.iTl.iY + iTileSide;
    line.iBr.iX = iBoardRect.iBr.iX;
    line.iBr.iY = line.iTl.iY + KLineWidth;
    gc.DrawRect(line);
    // Draw the remaining (KTilesPerCol -2) horizontal lines
    for (i = 0; i < KTilesPerCol - 2; i++)
        {
        line .iTl.iY += iTileSide + KLineWidth;
        line .iBr.iY += iTileSide + KLineWidth;
        gc.DrawRect(line);
        }
    }


TInt COandXAppView::CountComponentControls() const
    {
    return KNumberOfTiles +1;
    }

CCoeControl* COandXAppView::ComponentControl(TInt aIndex) const
    {
    if (aIndex==KNumberOfTiles)
        {
    	return iStatusWin;
        }
    else
        {
        return const_cast<COandXTile*>(iTiles[aIndex]);
        }
    }

TKeyResponse COandXAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    TKeyResponse keyResponse = EKeyWasNotConsumed;
    if (aType!=EEventKey)
        {
        return keyResponse;
        }
    TInt index = IdOfFocusControl();
    switch (aKeyEvent.iCode)
        {
    case EKeyLeftArrow: // check not in first column
        if (index % KTilesPerRow)
            {
            MoveFocusTo(index-1);
            keyResponse = EKeyWasConsumed;
            }
        break;
    case EKeyRightArrow: // check not in last column
        if ((index % KTilesPerRow) < KTilesPerRow - 1)
            {
            MoveFocusTo(index+1);
            keyResponse = EKeyWasConsumed;
            }
        break;
    case EKeyUpArrow: // check not on top row
        if (index >= KTilesPerRow)
            {
            MoveFocusTo(index-KTilesPerRow);
            keyResponse = EKeyWasConsumed;
            }
        break;
    case EKeyDownArrow: // check not in bottom row
        if (index < KNumberOfTiles - KTilesPerRow)
            {
            MoveFocusTo(index+KTilesPerRow);
            keyResponse = EKeyWasConsumed;
            }
        break;
    default:
        keyResponse = ComponentControl(index)->OfferKeyEventL(aKeyEvent,aType);
        break;
        }
    return keyResponse;
    }

TInt COandXAppView::IdOfFocusControl()
    {
    TInt ret = -1;
    for (TInt i=0; i<KNumberOfTiles; i++)
        {
        if (ComponentControl(i)->IsFocused())
            {
            ret = i;
            break;
            }
        }
    __ASSERT_ALWAYS(ret>=0, Panic(EOandXNoTileWithFocus));
    return ret;
    }
    
void COandXAppView::SwitchFocus(TInt aFromIndex, CCoeControl* aToControl)
    {
    ComponentControl(aFromIndex)->SetFocus(EFalse, EDrawNow);
    aToControl->SetFocus(ETrue, EDrawNow);
    }
    
void COandXAppView::MoveFocusTo(const TInt index)
    {
    TInt oldIndex = IdOfFocusControl();
    if (index!= oldIndex)
        {
        SwitchFocus(oldIndex, ComponentControl(index));
        }
    }


void COandXAppView::HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType)
    {
    switch (aEventType)
        {
    case EEventRequestFocus:
        SwitchFocus(IdOfFocusControl(), aControl);
        break;
    default:
        break;
        }
    }

void COandXAppView::TryHitSquareL(const COandXTile* aControl)
    {
    TInt tileIndex = Index(aControl);
    Controller().HitSquareL(tileIndex);
    }

TInt COandXAppView::SquareStatus(const COandXTile* aControl)
    {
    return Engine().SquareStatus(Index(aControl));
    }

// implement MOandXGameObserver

void COandXAppView::ResetView()
    {
	TBool drawable = Controller().DrawableGame();

	for (TInt i = 0; i < KNumberOfTiles; ++i)
		ComponentControl(i)->MakeVisible(drawable);
	iStatusWin->MakeVisible(drawable);

	if (drawable)
		MoveFocusTo(0);
	
    DrawDeferred();
    }

void COandXAppView::RedrawSquare(TInt aIndex)
	{
	ComponentControl(aIndex)->DrawDeferred();
	}

void COandXAppView::RedrawCurrentPlayer()
	{
	iStatusWin->DrawDeferred();
	}

void COandXAppView::ReportWinner(TInt aWinner)
	{
	TRAP_IGNORE(OandXAppUi()->ReportWinnerL(aWinner));
	}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品影视天天线| 久久精品国产免费看久久精品| 欧美一区二区高清| 成人性生交大合| 日本不卡123| 亚洲欧美电影院| 国产婷婷色一区二区三区| 欧美日韩一级二级| caoporm超碰国产精品| 免费观看日韩电影| 夜夜亚洲天天久久| 中文字幕av一区二区三区高| 精品三级在线观看| 在线综合视频播放| 欧美日韩国产在线观看| 6080日韩午夜伦伦午夜伦| 五月天婷婷综合| 国产精品久久久久久久久免费樱桃 | 中文字幕第一区综合| 精品对白一区国产伦| 日韩欧美电影一二三| 99re免费视频精品全部| 亚洲欧洲精品一区二区三区不卡| 欧美性大战久久| 欧美日韩一区二区欧美激情| 色婷婷av一区二区三区大白胸 | 一区在线中文字幕| 中文天堂在线一区| 亚洲三级小视频| 亚洲免费观看高清| 五月激情综合网| 精品一区二区三区免费毛片爱| 美女在线视频一区| 国产精品一区二区视频| 成人激情av网| 欧美日韩高清一区二区不卡| 欧美日韩视频在线观看一区二区三区| 欧美色偷偷大香| 精品成a人在线观看| 欧美国产综合色视频| 亚洲国产三级在线| 国产一区二区三区久久悠悠色av| 成人免费毛片app| 欧美亚洲图片小说| 日韩一区二区视频在线观看| 中文字幕的久久| 日本午夜精品一区二区三区电影| 国产传媒欧美日韩成人| 在线观看亚洲a| 国产目拍亚洲精品99久久精品| 有码一区二区三区| 国产成人亚洲综合a∨猫咪| 色94色欧美sute亚洲线路一久| 欧美卡1卡2卡| 国产精品久久久久久久久搜平片| 日本麻豆一区二区三区视频| 91美女视频网站| 久久久精品免费网站| 麻豆成人在线观看| 欧美日韩一区二区三区四区五区| 国产欧美精品在线观看| 精品在线你懂的| 91精品国产全国免费观看| 日韩一区二区三免费高清| 亚洲欧美日韩一区二区三区在线观看 | 午夜精彩视频在线观看不卡| www.在线成人| 国产欧美日韩另类一区| 看片的网站亚洲| 欧美区在线观看| 亚洲成人你懂的| 欧美日韩免费观看一区二区三区 | 国产不卡在线视频| 久久久av毛片精品| 国产激情一区二区三区四区| 精品国产91久久久久久久妲己 | 亚洲电影你懂得| 欧美日本在线看| 五月婷婷久久丁香| 日韩女优视频免费观看| 久草在线在线精品观看| 欧美另类一区二区三区| 亚洲二区视频在线| 日韩视频国产视频| 国产精一区二区三区| 国产免费观看久久| 99久久er热在这里只有精品15| 亚洲人成网站色在线观看| 色丁香久综合在线久综合在线观看| 亚洲一区二区三区国产| 91麻豆精品国产91久久久久| 欧美激情一区二区三区在线| 亚洲第一福利一区| 色美美综合视频| 亚洲va天堂va国产va久| 2024国产精品| 一本色道久久综合亚洲aⅴ蜜桃| 一区二区三区四区乱视频| 4438亚洲最大| 99久久精品费精品国产一区二区| 亚洲一区二区免费视频| 日韩视频免费直播| 国产精品影音先锋| 午夜一区二区三区在线观看| 精品国产麻豆免费人成网站| 色悠悠久久综合| 国精产品一区一区三区mba桃花| 亚洲欧美另类久久久精品| 精品国产乱码久久| 欧美日韩国产精品成人| 粉嫩av一区二区三区在线播放| 亚洲成人激情综合网| 国产精品天美传媒| 欧美精品一区二区三区四区| 欧美午夜一区二区| 99精品1区2区| 成人丝袜高跟foot| 国产一区中文字幕| 国产一二精品视频| 国产在线精品一区二区| 日本欧美大码aⅴ在线播放| 一区二区三区**美女毛片| 综合久久一区二区三区| 国产精品久久久久久亚洲伦| 中日韩av电影| 成人欧美一区二区三区白人| 国产日产欧美一区| 国产无一区二区| 国产精品美女久久久久久2018| 精品三级在线观看| 欧美激情一区二区三区在线| 欧美高清在线一区二区| 国产精品久久久久久久岛一牛影视 | 色美美综合视频| 国产成人在线视频网址| 风间由美中文字幕在线看视频国产欧美 | 亚洲情趣在线观看| 午夜日韩在线电影| 美女网站在线免费欧美精品| 国产一区免费电影| 成人免费av在线| 欧美日韩精品欧美日韩精品一| 欧美精品在线视频| 久久精品人人做人人综合 | 欧美日韩一区视频| 精品入口麻豆88视频| 国产精品传媒视频| 天堂影院一区二区| 国产成人亚洲精品狼色在线| 在线免费观看日本一区| 精品国产欧美一区二区| 亚洲图片欧美激情| 日韩—二三区免费观看av| 国产成人亚洲综合a∨猫咪| 欧美色综合网站| 国产精品麻豆久久久| 美女任你摸久久| 欧美性videosxxxxx| 国产欧美一区在线| 男男gaygay亚洲| 欧美视频一区二区在线观看| 国产精品欧美综合在线| 麻豆精品久久精品色综合| 一本久道中文字幕精品亚洲嫩| 欧美一级欧美三级| 亚洲午夜久久久久久久久电影院| 国产精品亚洲午夜一区二区三区| 欧美二区乱c少妇| 亚洲一区在线观看免费观看电影高清| 国产麻豆91精品| 精品少妇一区二区三区| 天天免费综合色| 欧美日韩视频在线第一区| 久久人人97超碰com| 亚洲国产精品二十页| 中文字幕在线免费不卡| 岛国精品在线观看| 久久综合狠狠综合久久综合88 | 亚洲丰满少妇videoshd| 日本韩国一区二区三区视频| 亚洲欧美日韩综合aⅴ视频| 99精品视频一区| 亚洲精品视频免费看| 日本韩国一区二区三区视频| 亚洲三级在线免费观看| 欧美在线三级电影| 午夜激情久久久| 26uuuu精品一区二区| 丁香六月综合激情| 亚洲视频一区在线| 在线观看亚洲一区| 麻豆成人91精品二区三区| 久久综合精品国产一区二区三区| 国产成人av一区二区三区在线| 国产精品天干天干在线综合| 色网站国产精品| 美腿丝袜在线亚洲一区| 亚洲国产高清不卡| 成人精品视频一区| 五月激情六月综合|