home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 266 / PYRAMID.SIS / PYRAMID.H < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-27  |  4.4 KB  |  198 lines

  1. // PYRAMID.H
  2. //
  3. // Written in 1997 by Frederic Bouvry
  4.  
  5. #ifndef __PYRAMID_H
  6. #define __PYRAMID_H
  7.  
  8. #pragma warning(disable : 4100)
  9. // disable "parameter not used"
  10.  
  11. #include <coemain.h>
  12. #include <coeaui.h>
  13. #include <coecntrl.h>
  14. #include <coeccntx.h>
  15.  
  16. #include <eikappui.h>
  17. #include <eikapp.h>
  18. #include <eikdoc.h>
  19.  
  20.   // Convenient TInt used in the pragma data_seg.
  21.   // See definition of symbol KNarrowReleaseUid defined in E32UID.H
  22. const TInt KExampleNarrowRelUidValue = 0x10000079; //268435577
  23.  
  24. // UID of app
  25.  
  26. const TUid KUidPyramidApp= { 0x1000055D } ;
  27.  
  28.  
  29.  
  30. //
  31. // TPyramidModel
  32. //
  33.  
  34. class TPyramidModel
  35.     {
  36. public:
  37.     TPyramidModel();
  38.     TBool Differs(const TPyramidModel* aCompare) const;
  39. public:
  40.     TFileName iLibrary; // active control
  41.     };
  42.  
  43.  
  44. class CPyramidControl : public CCoeControl,  public MCoeControlObserver
  45.     {
  46. public:
  47.     void Draw(const TRect& aRect) const;
  48.     // construct/destruct
  49.     void ConstructL(RWindowTreeNode& parent, const TRect& aRect);
  50.     void Restart();
  51.     ~CPyramidControl();
  52.     virtual void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
  53.     TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
  54.     int Score;
  55.     int MaxRedeals;
  56.     int Redeals;
  57.     TInt GamesPlayed[4];
  58.     TInt GamesWon[4];
  59.     TInt MaxScore[4];
  60.     TInt TotalScore[4];
  61.     CFbsBitmapDevice* MemBitmap;
  62.     CGraphicsContext* MemContext;
  63.     void MyActivateGc(){ActivateGc();}
  64.     void MyDeactivateGc(){DeactivateGc();}
  65. protected:
  66.     int state;
  67.     TInt64 seed;
  68.     int Tapis[28];
  69.     CFbsBitmap *iUnderTapis[28];
  70.     int TapisState[28];
  71.     int Stock[24];
  72.     int StockSize;
  73.     int Waste[24];
  74.     int WasteSize;
  75.     int Tallon;
  76.     int DragCard;
  77.     int DragCardHit;
  78.     int DropCardHit;
  79.     int DragCardValue;
  80.     CFbsBitmap *iCardsMsBmp; // Mask
  81.     CFbsBitmap *iCardsNoBmp; // Empty slot
  82.     CFbsBitmap *iCardsBkBmp; // Card's back
  83.     CFbsBitmap *iCards52Bmp[52]; // 52 game cards
  84.     CFont *MyFont,*MyFont2;
  85.     MGraphicsDeviceMap* iDeviceMap;
  86.     TZoomFactor iZoomFactor;
  87.  
  88.     void LoadBitmapL(CFbsBitmap* aBitMap,TDesC& aPathAndFile,TInt aId);
  89.     void UpdateModelL();
  90.     void DrawTapis(CWindowGc& gc) const;
  91.     void DrawTallon(CWindowGc& gc) const;
  92.     void DrawStock(CWindowGc& gc) const;
  93.     void DrawWaste(CWindowGc& gc) const;
  94.     void DrawLabels(CWindowGc& gc) const;
  95.     void Random();
  96. private:
  97.     // functions provided for CCoeControl protocol
  98.     void HandlePointerEventL(const TPointerEvent& aPointerEvent);
  99.     };
  100.  
  101. //
  102. // class CPyramidContainer
  103. //
  104.  
  105. class CPyramidContainer : public CCoeControl,
  106.         public MCoeControlBrushContext
  107.     {
  108. public:
  109.     CPyramidControl* iPyramidControl; // example control
  110.     void ConstructL(const TRect& aRect, TPyramidModel* aModel);
  111.     ~CPyramidContainer();
  112. private:
  113.     void Draw(const TRect& /*aRect*/) const;
  114.     TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
  115.     TInt CountComponentControls() const;
  116.     CCoeControl* ComponentControl(TInt aIndex) const;
  117. private: // data
  118.     TPyramidModel* iModel;
  119.     };
  120.  
  121. //
  122. // CPyramidDocument
  123. //
  124.  
  125. class CPyramidDocument : public CEikDocument
  126.     {
  127. public:
  128.     CPyramidDocument(CEikApplication& aApp): CEikDocument(aApp) { }
  129.     TPyramidModel* Model() { return(&iModel); }
  130. private: // from CEikDocument
  131.     CEikAppUi* CreateAppUiL();
  132. private:
  133.     TPyramidModel iModel;
  134.     };
  135.  
  136. //
  137. // CPyramidAppUi
  138. //
  139.  
  140. class CPyramidAppUi : public CEikAppUi
  141.     {
  142. public:
  143.     void ConstructL();
  144.     ~CPyramidAppUi();
  145. private: // from CEikAppUi
  146.     void HandleCommandL(TInt aCommand);
  147. private:
  148.     void UpdateProfile();
  149.     void ReadProfile();
  150.     CPyramidContainer* iContainer;
  151.     TPyramidModel* iModel;
  152.     };
  153.  
  154. class CExampleAboutDialog : public CEikDialog
  155.     {
  156. public:
  157.       // Construction
  158.     CExampleAboutDialog(){};
  159.     };
  160.  
  161. class CPrefDialog : public CEikDialog
  162.     {
  163. public:
  164.       // Construction
  165.     virtual void PreLayoutDynInitL();
  166.     virtual TBool OkToExitL(TInt aKeycode);
  167.     TInt *dlgpref;
  168.     CPrefDialog(TInt *val){dlgpref = val;};
  169.     };
  170.  
  171. class CStatDialog : public CEikDialog
  172.     {
  173. public:
  174.       // Construction
  175.     virtual void PreLayoutDynInitL();
  176.     TInt *gamesp;
  177.     TInt *gamesw;
  178.     TInt *mscore;
  179.     TInt *tscore;
  180.     CStatDialog(TInt *gplayed, TInt *gwon, TInt *maxscore, TInt *totalscore)
  181.      {
  182.      gamesp = gplayed; gamesw = gwon;
  183.      mscore = maxscore; tscore = totalscore;
  184.      };
  185.     };
  186. //
  187. // CPyramidApplication
  188. //
  189.  
  190. class CPyramidApplication : public CEikApplication
  191.     {
  192. private: // from CApaApplication
  193.     CApaDocument* CreateDocumentL();
  194.     TUid AppDllUid() const;
  195.     };
  196.  
  197. #endif
  198.