00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef OANDXAPPVIEW_H
00031 #define OANDXAPPVIEW_H
00032
00033 #include <coecntrl.h>
00034 #include <coedef.h>
00035 #include <aknview.h>
00036 #include "oandxdefs.h"
00037
00038 class COandXAppViewContainer;
00039 class COandXTile;
00040
00041
00042 class COandXGameView : public CAknView
00043 {
00044 public:
00045 static COandXGameView* NewLC();
00046 ~COandXGameView();
00047
00048
00049 TUid Id() const;
00050 void HandleCommandL(TInt aCommand);
00051 void HandleViewRectChange();
00052 void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
00053 COandXAppViewContainer* Container();
00054
00055 private:
00056 COandXGameView();
00057 void ConstructL();
00058
00059 void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
00060 const TDesC8& aCustomMessage);
00061 void DoDeactivate();
00062
00063 private:
00064 COandXAppViewContainer* iContainer;
00065
00066 TBool iGameViewStacked;
00067 };
00068
00069 class COandXSymbolControl : public CCoeControl
00070 {
00071 protected:
00072 void DrawSymbol(CWindowGc& aGc, const TRect& aRect, TBool aDrawCross) const;
00073 };
00074
00075 class MViewCmdHandler
00076 {
00077 public:
00078 virtual TBool TryHitSquareL(const COandXTile* aControl)=0;
00079 virtual TTileState TileStatus(const COandXTile* aControl) const =0;
00080 };
00081
00082 class COandXTile : public COandXSymbolControl
00083 {
00084 public:
00085 COandXTile();
00086 ~COandXTile();
00087 void ConstructL(RWindow& aWindow);
00088
00089
00090 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
00091 TCoeInputCapabilities InputCapabilities() const;
00092
00093
00094 void SetOwnerAndObserver(COandXAppViewContainer* aControl);
00095
00096 protected:
00097 void HandlePointerEventL(const TPointerEvent& aPointerEvent);
00098 void FocusChanged(TDrawNow aDrawNow);
00099
00100 private:
00101
00102 void Draw(const TRect& aRect) const;
00103
00104
00105 void TryHitL();
00106
00107 private:
00108 MViewCmdHandler* iCmdHandler;
00109 };
00110
00111 class COandXStatusWin : public COandXSymbolControl
00112 {
00113 public:
00114 static COandXStatusWin* NewL(RWindow& aWindow);
00115 ~COandXStatusWin();
00116
00117 private:
00118 COandXStatusWin();
00119 void ConstructL(RWindow& aWindow);
00120 void Draw(const TRect& aRect) const;
00121 };
00122
00123
00124
00125 class COandXAppViewContainer : public CCoeControl, public MCoeControlObserver, public MViewCmdHandler
00126 {
00127 public:
00128 static COandXAppViewContainer* NewL(const TRect& aRect);
00129 virtual ~COandXAppViewContainer();
00130
00131
00132 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
00133
00134
00135 void MoveFocusTo(const TInt aIndex);
00136 TInt IdOfFocusControl();
00137 void ShowTurn();
00138 void ResetView();
00139
00140 private:
00141 COandXAppViewContainer();
00142 void ConstructL(const TRect& aRect);
00143
00144 void SwitchFocus(TInt aFromIndex, CCoeControl* aToControl);
00145 void DrawComps(TRect& aRect) const;
00146 COandXTile * CreateTileL();
00147
00148
00149 void Draw(const TRect& aRect) const;
00150 void SizeChanged();
00151 TInt CountComponentControls() const;
00152 CCoeControl* ComponentControl(TInt aIndex) const;
00153
00154
00155 void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType);
00156
00157
00158 TBool TryHitSquareL(const COandXTile* aControl);
00159 TTileState TileStatus(const COandXTile* aControl) const;
00160
00161 private:
00162 RPointerArray<COandXTile> iTiles;
00163 COandXStatusWin* iStatusWin;
00164 TRect iBoardRect;
00165 TRect iBorderRect;
00166 TInt iTileSide;
00167 };
00168
00169 #endif // OANDXAPPVIEW_H