home *** CD-ROM | disk | FTP | other *** search
- // PYRAMID.H
- //
- // Written in 1997 by Frederic Bouvry
-
- #ifndef __PYRAMID_H
- #define __PYRAMID_H
-
- #pragma warning(disable : 4100)
- // disable "parameter not used"
-
- #include <coemain.h>
- #include <coeaui.h>
- #include <coecntrl.h>
- #include <coeccntx.h>
-
- #include <eikappui.h>
- #include <eikapp.h>
- #include <eikdoc.h>
-
- // Convenient TInt used in the pragma data_seg.
- // See definition of symbol KNarrowReleaseUid defined in E32UID.H
- const TInt KExampleNarrowRelUidValue = 0x10000079; //268435577
-
- // UID of app
-
- const TUid KUidPyramidApp= { 0x1000055D } ;
-
-
-
- //
- // TPyramidModel
- //
-
- class TPyramidModel
- {
- public:
- TPyramidModel();
- TBool Differs(const TPyramidModel* aCompare) const;
- public:
- TFileName iLibrary; // active control
- };
-
-
- class CPyramidControl : public CCoeControl, public MCoeControlObserver
- {
- public:
- void Draw(const TRect& aRect) const;
- // construct/destruct
- void ConstructL(RWindowTreeNode& parent, const TRect& aRect);
- void Restart();
- ~CPyramidControl();
- virtual void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
- TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
- int Score;
- int MaxRedeals;
- int Redeals;
- TInt GamesPlayed[4];
- TInt GamesWon[4];
- TInt MaxScore[4];
- TInt TotalScore[4];
- CFbsBitmapDevice* MemBitmap;
- CGraphicsContext* MemContext;
- void MyActivateGc(){ActivateGc();}
- void MyDeactivateGc(){DeactivateGc();}
- protected:
- int state;
- TInt64 seed;
- int Tapis[28];
- CFbsBitmap *iUnderTapis[28];
- int TapisState[28];
- int Stock[24];
- int StockSize;
- int Waste[24];
- int WasteSize;
- int Tallon;
- int DragCard;
- int DragCardHit;
- int DropCardHit;
- int DragCardValue;
- CFbsBitmap *iCardsMsBmp; // Mask
- CFbsBitmap *iCardsNoBmp; // Empty slot
- CFbsBitmap *iCardsBkBmp; // Card's back
- CFbsBitmap *iCards52Bmp[52]; // 52 game cards
- CFont *MyFont,*MyFont2;
- MGraphicsDeviceMap* iDeviceMap;
- TZoomFactor iZoomFactor;
-
- void LoadBitmapL(CFbsBitmap* aBitMap,TDesC& aPathAndFile,TInt aId);
- void UpdateModelL();
- void DrawTapis(CWindowGc& gc) const;
- void DrawTallon(CWindowGc& gc) const;
- void DrawStock(CWindowGc& gc) const;
- void DrawWaste(CWindowGc& gc) const;
- void DrawLabels(CWindowGc& gc) const;
- void Random();
- private:
- // functions provided for CCoeControl protocol
- void HandlePointerEventL(const TPointerEvent& aPointerEvent);
- };
-
- //
- // class CPyramidContainer
- //
-
- class CPyramidContainer : public CCoeControl,
- public MCoeControlBrushContext
- {
- public:
- CPyramidControl* iPyramidControl; // example control
- void ConstructL(const TRect& aRect, TPyramidModel* aModel);
- ~CPyramidContainer();
- private:
- void Draw(const TRect& /*aRect*/) const;
- TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
- TInt CountComponentControls() const;
- CCoeControl* ComponentControl(TInt aIndex) const;
- private: // data
- TPyramidModel* iModel;
- };
-
- //
- // CPyramidDocument
- //
-
- class CPyramidDocument : public CEikDocument
- {
- public:
- CPyramidDocument(CEikApplication& aApp): CEikDocument(aApp) { }
- TPyramidModel* Model() { return(&iModel); }
- private: // from CEikDocument
- CEikAppUi* CreateAppUiL();
- private:
- TPyramidModel iModel;
- };
-
- //
- // CPyramidAppUi
- //
-
- class CPyramidAppUi : public CEikAppUi
- {
- public:
- void ConstructL();
- ~CPyramidAppUi();
- private: // from CEikAppUi
- void HandleCommandL(TInt aCommand);
- private:
- void UpdateProfile();
- void ReadProfile();
- CPyramidContainer* iContainer;
- TPyramidModel* iModel;
- };
-
- class CExampleAboutDialog : public CEikDialog
- {
- public:
- // Construction
- CExampleAboutDialog(){};
- };
-
- class CPrefDialog : public CEikDialog
- {
- public:
- // Construction
- virtual void PreLayoutDynInitL();
- virtual TBool OkToExitL(TInt aKeycode);
- TInt *dlgpref;
- CPrefDialog(TInt *val){dlgpref = val;};
- };
-
- class CStatDialog : public CEikDialog
- {
- public:
- // Construction
- virtual void PreLayoutDynInitL();
- TInt *gamesp;
- TInt *gamesw;
- TInt *mscore;
- TInt *tscore;
- CStatDialog(TInt *gplayed, TInt *gwon, TInt *maxscore, TInt *totalscore)
- {
- gamesp = gplayed; gamesw = gwon;
- mscore = maxscore; tscore = totalscore;
- };
- };
- //
- // CPyramidApplication
- //
-
- class CPyramidApplication : public CEikApplication
- {
- private: // from CApaApplication
- CApaDocument* CreateDocumentL();
- TUid AppDllUid() const;
- };
-
- #endif
-