00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00049 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
00050 TCoeInputCapabilities InputCapabilities() const;
00051
00052
00053 void SetOwnerAndObserver(COandXAppView* aControl);
00054
00055 protected:
00056 void HandlePointerEventL(const TPointerEvent& aPointerEvent);
00057 void FocusChanged(TDrawNow aDrawNow);
00058
00059 private:
00060
00061 void Draw(const TRect& aRect) const;
00062
00063
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
00091 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
00092
00093
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
00108 void Draw(const TRect& aRect) const;
00109 void SizeChanged();
00110 TInt CountComponentControls() const;
00111 CCoeControl* ComponentControl(TInt aIndex) const;
00112
00113
00114 void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType);
00115
00116
00117 TBool TryHitSquareL(const COandXTile* aControl);
00118 TTileState TileStatus(const COandXTile* aControl) const;
00119
00120 private:
00121 RPointerArray<COandXTile> iTiles;
00122 COandXStatusWin* iStatusWin;
00123 TRect iBoardRect;
00124 TRect iBorderRect;
00125 TInt iTileSide;
00126 };
00127
00128 #endif // OANDXAPPVIEW_H