examples/SFExamples/OandXViewArch/S60/inc/oandxappview.h

00001 /*
00002 Copyright (c) 2002-2011 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 * Redistributions in binary form must reproduce the above copyright notice,
00010   this list of conditions and the following disclaimer in the documentation
00011   and/or other materials provided with the distribution.
00012 * Neither the name of Nokia Corporation nor the names of its contributors
00013   may be used to endorse or promote products derived from this software
00014   without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 Description:  
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: // Constructor and destructor
00045     static COandXGameView* NewLC();
00046     ~COandXGameView();
00047 
00048     // Functions from base classes
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: // Data
00064     COandXAppViewContainer* iContainer;
00065         // Set if the Game View's container is added to the control stack.
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         // From CCoeControl
00090         TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
00091         TCoeInputCapabilities InputCapabilities() const;
00092 
00093         // New function
00094         void SetOwnerAndObserver(COandXAppViewContainer* aControl);
00095 
00096 protected:
00097         void HandlePointerEventL(const TPointerEvent& aPointerEvent);
00098         void FocusChanged(TDrawNow aDrawNow);
00099 
00100 private:
00101         // from CCoeControl
00102         void Draw(const TRect& aRect) const;
00103         
00104         // New function
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         // From CCoeControl
00132         TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
00133 
00134         // new functions        
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         // From CCoeControl
00149         void Draw(const TRect& aRect) const;
00150         void SizeChanged();
00151         TInt CountComponentControls() const;
00152         CCoeControl* ComponentControl(TInt aIndex) const;
00153         
00154         // From MCoeControlObserver
00155         void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType);
00156 
00157         // From MViewCmdHandler
00158         TBool TryHitSquareL(const COandXTile* aControl);
00159         TTileState TileStatus(const COandXTile* aControl) const;
00160 
00161 private:
00162         RPointerArray<COandXTile> iTiles; // View owns the tiles
00163         COandXStatusWin* iStatusWin;      // and its own status window.
00164         TRect iBoardRect;  // Board area
00165         TRect iBorderRect; // Bounding rectangle for border
00166         TInt iTileSide;    // Tile dimension, allowing for line widths and border
00167         };
00168 
00169 #endif // OANDXAPPVIEW_H

Generated by  doxygen 1.6.2