examples/SFExamples/games_on_symbian_os_code/oandx/inc/oandxappview.h

00001 // 
00002 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
00003 // All rights reserved.
00004 // This component and the accompanying materials are made available
00005 // under the terms of the License "Eclipse Public License v1.0"
00006 // which accompanies this distribution, and is available
00007 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00008 // 
00009 // Initial Contributors:
00010 // Nokia Corporation - initial contribution.
00011 // 
00012 // Contributors:
00013 // 
00014 // Description:
00015 // 
00016 
00017 #ifndef OANDXAPPVIEW_H
00018 #define OANDXAPPVIEW_H
00019 
00020 #include <coecntrl.h>
00021 #include <coedef.h>
00022 #include "oandxdefs.h"
00023 
00024 class COandXAppView;
00025 class COandXTile;
00026 
00027 class COandXSymbolControl : public CCoeControl
00028         {
00029 protected:
00030         void DrawSymbol(CWindowGc& aGc, const TRect& aRect, TBool aDrawCross) const;
00031         };
00032         
00033 
00034 class MViewCmdHandler
00035     {
00036 public:
00037     virtual TBool TryHitSquareL(const COandXTile* aControl)=0;
00038     virtual TTileState TileStatus(const COandXTile* aControl) const =0;
00039     };
00040     
00041 class COandXTile : public COandXSymbolControl
00042         {
00043 public:
00044         COandXTile();
00045         ~COandXTile();
00046         void ConstructL(RWindow& aWindow);
00047 
00048         // From CCoeControl
00049         TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
00050         TCoeInputCapabilities InputCapabilities() const;
00051 
00052         // New function
00053         void SetOwnerAndObserver(COandXAppView* aControl);
00054 
00055 protected:
00056         void HandlePointerEventL(const TPointerEvent& aPointerEvent);
00057         void FocusChanged(TDrawNow aDrawNow);
00058 
00059 private:
00060         // from CCoeControl
00061         void Draw(const TRect& aRect) const;
00062         
00063         // New function
00064         void TryHitL();
00065 
00066 private:
00067         MViewCmdHandler* iCmdHandler;
00068         };
00069 
00070 class COandXStatusWin : public COandXSymbolControl
00071         {
00072 public:
00073         static COandXStatusWin* NewL(RWindow& aWindow);
00074         ~COandXStatusWin();
00075 
00076 private:
00077         COandXStatusWin();
00078         void ConstructL(RWindow& aWindow);
00079         void Draw(const TRect& aRect) const;
00080         };
00081 
00082 
00083 
00084 class COandXAppView : public CCoeControl, public MCoeControlObserver, public MViewCmdHandler
00085         {
00086 public:
00087         static COandXAppView* NewL(const TRect& aRect);
00088         virtual ~COandXAppView();
00089         
00090         // From CCoeControl
00091         TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
00092 
00093         // new functions        
00094         void MoveFocusTo(const TInt aIndex);
00095         TInt IdOfFocusControl();
00096         void ShowTurn();
00097         void ResetView();
00098 
00099 private:
00100         COandXAppView();
00101         void ConstructL(const TRect& aRect);
00102 
00103         void SwitchFocus(TInt aFromIndex, CCoeControl* aToControl);
00104         void DrawComps(TRect& aRect) const;
00105         COandXTile * CreateTileL();
00106 
00107         // From CCoeControl
00108         void Draw(const TRect& aRect) const;
00109         void SizeChanged();
00110         TInt CountComponentControls() const;
00111         CCoeControl* ComponentControl(TInt aIndex) const;
00112         
00113         // From MCoeControlObserver
00114         void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType);
00115 
00116         // From MViewCmdHandler
00117         TBool TryHitSquareL(const COandXTile* aControl);
00118         TTileState TileStatus(const COandXTile* aControl) const;
00119 
00120 private:
00121         RPointerArray<COandXTile> iTiles; // View owns the tiles
00122         COandXStatusWin* iStatusWin;      // and its own status window.
00123         TRect iBoardRect;  // Board area
00124         TRect iBorderRect; // Bounding rectangle for border
00125         TInt iTileSide;    // Tile dimension, allowing for line widths and border
00126         };
00127 
00128 #endif // OANDXAPPVIEW_H

Generated by  doxygen 1.6.2