home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / Epoc / Palmtime / files / Pyramid_src.ZIP / Pyramid.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-15  |  4.9 KB  |  215 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. #define CARD_SIZE_X_TWIPS 869
  12. #define CARD_SIZE_Y_TWIPS 1155
  13.  
  14. #include <coemain.h>
  15. #include <coeaui.h>
  16. #include <coecntrl.h>
  17. #include <coeccntx.h>
  18.  
  19. #include <eikappui.h>
  20. #include <eikapp.h>
  21. #include <eikdoc.h>
  22.  
  23.   // Convenient TInt used in the pragma data_seg.
  24.   // See definition of symbol KNarrowReleaseUid defined in E32UID.H
  25. const TInt KExampleNarrowRelUidValue = 0x10000079; //268435577
  26.  
  27. // UID of app
  28.  
  29. const TUid KUidPyramidApp= { 0x1000055D } ;
  30.  
  31.  
  32.  
  33. //
  34. // TPyramidModel
  35. //
  36.  
  37. class TPyramidModel
  38.     {
  39. public:
  40.     TPyramidModel();
  41.     TBool Differs(const TPyramidModel* aCompare) const;
  42. public:
  43.     TFileName iLibrary; // active control
  44.     };
  45.  
  46.  
  47. class CPyramidControl : public CCoeControl,  public MCoeControlObserver
  48.     {
  49. public:
  50.     void Draw(const TRect& aRect) const;
  51.     // construct/destruct
  52.     void ConstructL(RWindowTreeNode& parent, const TRect& aRect);
  53.     void Restart();
  54.     ~CPyramidControl();
  55.     virtual void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
  56.     TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
  57.     int Score;
  58.     int MaxRedeals;
  59.     int Redeals;
  60.     // Locations of Waste, Tallon, Stock
  61.     TInt WasteCol;
  62.     TInt WasteRow;
  63.     TInt TallonCol;
  64.     TInt TallonRow;
  65.     TInt StockCol;
  66.     TInt StockRow; 
  67.     TInt GamesPlayed[4];
  68.     TInt GamesWon[4];
  69.     TInt MaxScore[4];
  70.     TInt TotalScore[4];
  71.     TSize CardSize;        //Size of the cards in pixels we display
  72.     TSize CardSizeTwips;    //Size of the cards in twips needed for rescaling
  73.     TRect ScreenRect;    //Screen Rectangle to draw into
  74.     double xoff,yoff;    //Offset for different screen sizes
  75.     CFbsBitmapDevice* MemBitmap;
  76.     CGraphicsContext* MemContext;
  77.     void MyActivateGc(){ActivateGc();}
  78.     void MyDeactivateGc(){DeactivateGc();}
  79. protected:
  80.     int state;
  81.     TInt64 seed;
  82.     int Tapis[28];
  83.     CFbsBitmap *iUnderTapis[28];
  84.     int TapisState[28];
  85.     int Stock[24];
  86.     int StockSize;
  87.     int Waste[24];
  88.     int WasteSize;
  89.     int Tallon;
  90.     int DragCard;
  91.     int DragCardHit;
  92.     int DropCardHit;
  93.     int DragCardValue;
  94.     CFbsBitmap *iCardsMsBmp; // Mask
  95.     CFbsBitmap *iCardsNoBmp; // Empty slot
  96.     CFbsBitmap *iCardsBkBmp; // Card's back
  97.     CFbsBitmap *iCards52Bmp[52]; // 52 game cards
  98.     CFont *MyFont,*MyFont2;
  99.     MGraphicsDeviceMap* iDeviceMap;
  100.     TZoomFactor iZoomFactor;
  101.  
  102.     void LoadBitmapL(CFbsBitmap* aBitMap,TDesC& aPathAndFile,TInt aId);
  103.     void UpdateModelL();
  104.     void DrawTapis(CWindowGc& gc) const;
  105.     void DrawTallon(CWindowGc& gc) const;
  106.     void DrawStock(CWindowGc& gc) const;
  107.     void DrawWaste(CWindowGc& gc) const;
  108.     void DrawLabels(CWindowGc& gc) const;
  109.     void Random();
  110. private:
  111.     // functions provided for CCoeControl protocol
  112.     void HandlePointerEventL(const TPointerEvent& aPointerEvent);
  113.     };
  114.  
  115. //
  116. // class CPyramidContainer
  117. //
  118.  
  119. class CPyramidContainer : public CCoeControl,
  120.         public MCoeControlBrushContext
  121.     {
  122. public:
  123.     CPyramidControl* iPyramidControl; // example control
  124.     void ConstructL(const TRect& aRect, TPyramidModel* aModel);
  125.     ~CPyramidContainer();
  126. private:
  127.     void Draw(const TRect& /*aRect*/) const;
  128.     TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
  129.     TInt CountComponentControls() const;
  130.     CCoeControl* ComponentControl(TInt aIndex) const;
  131. private: // data
  132.     TPyramidModel* iModel;
  133.     };
  134.  
  135. //
  136. // CPyramidDocument
  137. //
  138.  
  139. class CPyramidDocument : public CEikDocument
  140.     {
  141. public:
  142.     CPyramidDocument(CEikApplication& aApp): CEikDocument(aApp) { }
  143.     TPyramidModel* Model() { return(&iModel); }
  144. private: // from CEikDocument
  145.     CEikAppUi* CreateAppUiL();
  146. private:
  147.     TPyramidModel iModel;
  148.     };
  149.  
  150. //
  151. // CPyramidAppUi
  152. //
  153.  
  154. class CPyramidAppUi : public CEikAppUi
  155.     {
  156. public:
  157.     void ConstructL();
  158.     ~CPyramidAppUi();
  159. private: // from CEikAppUi
  160.     void HandleCommandL(TInt aCommand);
  161. private:
  162.     void UpdateProfile();
  163.     void ReadProfile();
  164.     CPyramidContainer* iContainer;
  165.     TPyramidModel* iModel;
  166.     };
  167.  
  168. class CExampleAboutDialog : public CEikDialog
  169.     {
  170. public:
  171.       // Construction
  172.     CExampleAboutDialog(){};
  173.     };
  174.  
  175. class CPrefDialog : public CEikDialog
  176.     {
  177. public:
  178.       // Construction
  179.     virtual void PreLayoutDynInitL();
  180.     virtual TBool OkToExitL(TInt aKeycode);
  181.     TInt *dlgpref;
  182.     CPrefDialog(TInt *val){dlgpref = val;};
  183.     };
  184.  
  185. class CStatDialog : public CEikDialog
  186.     {
  187. public:
  188.       // Construction
  189.     virtual void PreLayoutDynInitL();
  190.     TInt *gamesp;
  191.     TInt *gamesw;
  192.     TInt *mscore;
  193.     TInt *tscore;
  194.     CStatDialog(TInt *gplayed, TInt *gwon, TInt *maxscore, TInt *totalscore)
  195.      {
  196.      gamesp = gplayed; gamesw = gwon;
  197.      mscore = maxscore; tscore = totalscore;
  198.      };
  199.     };
  200. //
  201. // CPyramidApplication
  202. //
  203.  
  204. class CPyramidApplication : public CEikApplication
  205.     {
  206. private: // from CApaApplication
  207.     CApaDocument* CreateDocumentL();
  208.     TUid AppDllUid() const;
  209.     };
  210.  
  211. #endif
  212.  
  213. TSize CalcCardPos(TInt x, TInt y);
  214.  
  215.