examples/ForumNokia/ImageConverter/inc/ImageConverterContainer.h

00001 /*
00002  * Copyright (c) 2008-2010 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 IMAGECONVERTERCONTAINER_H
00031 #define IMAGECONVERTERCONTAINER_H
00032 
00033 // INCLUDES
00034 #include <coecntrl.h>
00035 
00036 #ifdef __TUI_SUPPORTED__
00037 #include <touchfeedback.h>
00038 #include <touchlogicalfeedback.h>
00039 #include <aknlongtapdetector.h> 
00040 #endif
00041 
00042 // Minium amount of pointer drag events received
00043 const TInt KMIN_POINTER_COUNT = 10;
00044 
00045 #define DELAY 30000
00046 #define SLEEP_DELAY 1*1000*1000
00047 
00048 
00049 // FORWARD DECLARATIONS
00050 class CEikLabel;        // for example labels
00051 class CImageConverterAppUi;
00052 
00053 enum EPointerEvents
00054     {
00055     ENoValidPointerEvent = 0,
00056     EZoomIn,
00057     EZoomOut,
00058     ENextImage,
00059     EPrevImage,
00060     ERotateRight,
00061     ERotateLeft
00062     };
00063 
00064 enum ETitleState
00065     {
00066     ETitleNo = 0,
00067     ETitleZoomIn,
00068     ETitleZoomOut,
00069     ETitleNextImage,
00070     ETitlePrevImage,
00071     ETitleRotateRight,
00072     ETitleRotateLeft
00073     };
00074 
00075 enum EAnimationEvents
00076     {
00077     ENoAnimation = 0,
00078     EAnimateToRight,
00079     EAnimateToLeft,
00080     EAnimateFromRight,
00081     EAnimateFromLeft
00082     };
00083 
00084 // CLASS DECLARATION
00085 
00090 class CImageConverterContainer : public CCoeControl, 
00091 MCoeControlObserver
00092 #ifdef __TUI_SUPPORTED__
00093 , MAknLongTapDetectorCallBack
00094 #endif    
00095     {
00096     public: // Constructors and destructor
00097         
00102         void ConstructL(const TRect& aRect);
00103 
00107         ~CImageConverterContainer();
00108 
00109     public: // New functions
00110         void SetBitmap(CFbsBitmap* aBitmap);
00111         void StartAnimateL();
00112         void StartNewPictureAnimate();
00113         TBool IsAnimating();
00114         void SetNextAnimationWaiting(TBool aValue);
00115 
00116         void ChangeNextPictureL();
00117         void ChangePrevPictureL();
00118         void SetPictureScreenCenter(TBool aDraw);
00119         
00120     public:
00121         void DrawToBackBuffer();
00122         void SetTitleText(ETitleState aState, TBool aDrawNow);
00123         void ResetTitleText(TBool aDrawNow);
00124 
00125     private:
00126 
00130         void SizeChanged();
00131 
00135         void HandleResourceChange(TInt aType);
00136 
00140         TInt CountComponentControls() const;
00141 
00145         CCoeControl* ComponentControl(TInt aIndex) const;
00146 
00150         void Draw(const TRect& aRect) const;
00151         
00159         void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
00160         
00161         #ifdef __TUI_SUPPORTED__
00162         void HandlePointerEventL(const TPointerEvent& aPointerEvent);
00163         void MovePicture(const TPoint& aPoint);        
00164         #endif
00165         
00166         TBool IsZooming();
00167 
00168         TBool IsChangingPicture();
00169         
00170         TBool IsRotate();
00171 
00172         TPoint FindCenterPointInRotate(TPoint& aFirstPoint);
00173         
00174         void FindPointsForRotate(TPoint& aTopPoint, TPoint& aCenterPoint, TPoint& aBottomPoint, TBool& aDrawDirectionIsFromTop);
00175 
00176         void StopAnimate();
00177 
00178         static TInt Animate(TAny* aObj);
00179         static TInt Sleep(TAny* aObj);
00180         
00181         void DoFrame();
00182         
00183         void CreateBackBufferL();
00184         void ReleaseBackBuffer();
00185         
00186         
00187         
00188 
00189     #ifdef __TUI_SUPPORTED__    
00190     private: // From MAknLongTapDetectorCallBack
00191         void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation );
00192     #endif        
00193 
00194     private: //data
00195        CFbsBitmap*          iBitmap;        
00196        TPoint               iPicturePoint;
00197        TBuf<100>            iPictureInfo;
00198        TBuf<100>            iStateInfo;
00199        CFont*               iFont;
00200        CFont*               iCbaFont;
00201 
00202        // Pointer events
00203        RArray<TPoint>       iDragPoints;
00204        EPointerEvents       iPointerEvent;
00205 
00206        // Animation
00207        CPeriodic*           iPeriodic; 
00208        TInt                 iAnimateX;
00209        TInt                 iPixelsToMove;
00210        TBool                iNextAnimationWaiting;
00211        EAnimationEvents     iAnimationEvent;
00212 
00213        #ifdef __TUI_SUPPORTED__       
00214        // Long tap detection
00215        CAknLongTapDetector* iLongTapDetector;
00216        TBool                iLongTapDetected;
00217        TPoint               iLongTapPoint;
00218        
00219        MTouchFeedback*      iTouchFeedBack;
00220        #endif       
00221        
00222        CImageConverterAppUi*            iAppUi;
00223        
00224        TRect                            iOptionsRect;
00225        TRect                            iExitRect;
00226 
00227        // double buffer bitmapsystem
00228        CFbsBitmap*                      iBackBuffer;
00229        CFbsBitmapDevice*                iBackBufferDevice;
00230        CFbsBitGc*                       iBackBufferContext;
00231        TSize                            iBackBufferSize;
00232        
00233        ETitleState                      iTitleState;
00234     };
00235 
00236 #endif
00237 
00238 // End of File

Generated by  doxygen 1.6.2