examples/ForumNokia/ImageConverter/inc/ImageConverterContainer.h

00001 /*
00002  * Copyright � 2008 Nokia Corporation.
00003  */
00004 
00005 #ifndef IMAGECONVERTERCONTAINER_H
00006 #define IMAGECONVERTERCONTAINER_H
00007 
00008 // INCLUDES
00009 #include <coecntrl.h>
00010 
00011 #ifdef __TUI_SUPPORTED__
00012 #include <touchfeedback.h>
00013 #include <touchlogicalfeedback.h>
00014 #include <aknlongtapdetector.h> 
00015 #endif
00016 
00017 // Minium amount of pointer drag events received
00018 const TInt KMIN_POINTER_COUNT = 10;
00019 
00020 #define DELAY 30000
00021 #define SLEEP_DELAY 1*1000*1000
00022 
00023 
00024 // FORWARD DECLARATIONS
00025 class CEikLabel;        // for example labels
00026 class CImageConverterAppUi;
00027 
00028 enum EPointerEvents
00029     {
00030     ENoValidPointerEvent = 0,
00031     EZoomIn,
00032     EZoomOut,
00033     ENextImage,
00034     EPrevImage,
00035     ERotateRight,
00036     ERotateLeft
00037     };
00038 
00039 enum ETitleState
00040     {
00041     ETitleNo = 0,
00042     ETitleZoomIn,
00043     ETitleZoomOut,
00044     ETitleNextImage,
00045     ETitlePrevImage,
00046     ETitleRotateRight,
00047     ETitleRotateLeft
00048     };
00049 
00050 enum EAnimationEvents
00051     {
00052     ENoAnimation = 0,
00053     EAnimateToRight,
00054     EAnimateToLeft,
00055     EAnimateFromRight,
00056     EAnimateFromLeft
00057     };
00058 
00059 // CLASS DECLARATION
00060 
00065 class CImageConverterContainer : public CCoeControl, 
00066 MCoeControlObserver
00067 #ifdef __TUI_SUPPORTED__
00068 , MAknLongTapDetectorCallBack
00069 #endif    
00070     {
00071     public: // Constructors and destructor
00072         
00077         void ConstructL(const TRect& aRect);
00078 
00082         ~CImageConverterContainer();
00083 
00084     public: // New functions
00085         void SetBitmap(CFbsBitmap* aBitmap);
00086         void StartAnimateL();
00087         void StartNewPictureAnimate();
00088         TBool IsAnimating();
00089         void SetNextAnimationWaiting(TBool aValue);
00090 
00091         void ChangeNextPictureL();
00092         void ChangePrevPictureL();
00093         void SetPictureScreenCenter(TBool aDraw);
00094         
00095     public:
00096         void DrawToBackBuffer();
00097         void SetTitleText(ETitleState aState, TBool aDrawNow);
00098         void ResetTitleText(TBool aDrawNow);
00099 
00100     private:
00101 
00105         void SizeChanged();
00106 
00110         void HandleResourceChange(TInt aType);
00111 
00115         TInt CountComponentControls() const;
00116 
00120         CCoeControl* ComponentControl(TInt aIndex) const;
00121 
00125         void Draw(const TRect& aRect) const;
00126         
00134         void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
00135         
00136         #ifdef __TUI_SUPPORTED__
00137         void HandlePointerEventL(const TPointerEvent& aPointerEvent);
00138         void MovePicture(const TPoint& aPoint);        
00139         #endif
00140         
00141         TBool IsZooming();
00142 
00143         TBool IsChangingPicture();
00144         
00145         TBool IsRotate();
00146 
00147         TPoint FindCenterPointInRotate(TPoint& aFirstPoint);
00148         
00149         void FindPointsForRotate(TPoint& aTopPoint, TPoint& aCenterPoint, TPoint& aBottomPoint, TBool& aDrawDirectionIsFromTop);
00150 
00151         void StopAnimate();
00152 
00153         static TInt Animate(TAny* aObj);
00154         static TInt Sleep(TAny* aObj);
00155         
00156         void DoFrame();
00157         
00158         void CreateBackBufferL();
00159         void ReleaseBackBuffer();
00160         
00161         
00162         
00163 
00164     #ifdef __TUI_SUPPORTED__    
00165     private: // From MAknLongTapDetectorCallBack
00166         void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation );
00167     #endif        
00168 
00169     private: //data
00170        CFbsBitmap*          iBitmap;        
00171        TPoint               iPicturePoint;
00172        TBuf<100>            iPictureInfo;
00173        TBuf<100>            iStateInfo;
00174        CFont*               iFont;
00175        CFont*               iCbaFont;
00176 
00177        // Pointer events
00178        RArray<TPoint>       iDragPoints;
00179        EPointerEvents       iPointerEvent;
00180 
00181        // Animation
00182        CPeriodic*           iPeriodic; 
00183        TInt                 iAnimateX;
00184        TInt                 iPixelsToMove;
00185        TBool                iNextAnimationWaiting;
00186        EAnimationEvents     iAnimationEvent;
00187 
00188        #ifdef __TUI_SUPPORTED__       
00189        // Long tap detection
00190        CAknLongTapDetector* iLongTapDetector;
00191        TBool                iLongTapDetected;
00192        TPoint               iLongTapPoint;
00193        
00194        MTouchFeedback*      iTouchFeedBack;
00195        #endif       
00196        
00197        CImageConverterAppUi*            iAppUi;
00198        
00199        TRect                            iOptionsRect;
00200        TRect                            iExitRect;
00201 
00202        // double buffer bitmapsystem
00203        CFbsBitmap*                      iBackBuffer;
00204        CFbsBitmapDevice*                iBackBufferDevice;
00205        CFbsBitGc*                       iBackBufferContext;
00206        TSize                            iBackBufferSize;
00207        
00208        ETitleState                      iTitleState;
00209     };
00210 
00211 #endif
00212 
00213 // End of File

Generated by  doxygen 1.6.2