camerauis/activepalette/Inc/ActivePalette2BasicUI.h
branchRCL_3
changeset 54 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  AP implementation using standard Symbian controls*
       
    15 */
       
    16 
       
    17 
       
    18 /**
       
    19  * @file ActivePalette2BasicUI.h
       
    20  * AP implementation using standard Symbian controls
       
    21  */
       
    22 
       
    23 
       
    24 #ifndef _ACTIVE_PALETTE_2_BASIC_UI_H
       
    25 #define _ACTIVE_PALETTE_2_BASIC_UI_H
       
    26 
       
    27 #include <e32std.h>
       
    28 #include <coecntrl.h>
       
    29 #include <activepalette2ui.h>
       
    30 #include <activepalette2genericpluginint.h>
       
    31 #include <activepalette2navigationkeys.h>
       
    32 #include <activepalette2factory.h>
       
    33 #include <activepalette2itemvisible.h>
       
    34 
       
    35 #include "CActivePalettePluginBase.h"
       
    36 #include "ActivePalette2ModelObserver.h"
       
    37 #include "ActivePalette2Const.h"
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 class MActivePalette2Observer;
       
    41 
       
    42 class CFbsBitmap;
       
    43 class CFbsBitmapDevice;
       
    44 class CFbsBitGc;
       
    45 class CPeriodic;
       
    46 
       
    47 class CAknsBasicBackgroundControlContext;
       
    48 
       
    49 class TActivePalette2NavigationKeys;
       
    50 class CActivePalette2Item;
       
    51 class TActivePalette2EventData;
       
    52 class CActivePalette2Model;
       
    53 class CActivePalette2Styler;
       
    54 class CActivePalette2Model;
       
    55 class CActivePalette2Tooltip;
       
    56 class CActivePalette2Configuration;
       
    57 
       
    58 /**
       
    59  * 2D renderer for Active Palette 2.
       
    60  *
       
    61  * @warning   application SHOULD NOT use directly SetSize(),
       
    62  *            SetRect() and SetLocation() of Active Palette object.
       
    63  *            Active palette object will adjust its size automatically
       
    64  *            when showing / hiding items. Position should be set using
       
    65  *            LocateTo(). 
       
    66  */
       
    67 class CActivePalette2BasicUI :    public CCoeControl, 
       
    68                                 public MActivePalette2UI, 
       
    69                                 public MActivePalette2ModelObserver,
       
    70                                 public MActivePalette2TooltipTimerObserver,
       
    71                                 public MActivePalette2FocusTimerObserver,
       
    72                                 public MActivePalette2ItemScrollTimerObserver,
       
    73                                 public MActivePalette2AppearanceTimerObserver
       
    74     {
       
    75 
       
    76 public:
       
    77 /// @name Object creation and deletion
       
    78 //@{
       
    79     /**
       
    80      * 2-stage construction
       
    81      * @param aDrawMode The drawing mode required
       
    82      * @return The newly-created object
       
    83      */
       
    84     static CActivePalette2BasicUI* NewL(TActivePalette2DrawMode aDrawMode);
       
    85     
       
    86     /**
       
    87      * Destructor
       
    88      */
       
    89 	virtual ~CActivePalette2BasicUI();
       
    90 //@}
       
    91     
       
    92 public: 
       
    93 /// @name From CoeControl
       
    94 //@{
       
    95 	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
       
    96     void SetContainerWindowL(const CCoeControl& aContainer);    
       
    97 //@}
       
    98 
       
    99 private: 
       
   100 /// @name From CoeControl
       
   101 //@{
       
   102     TInt CountComponentControls() const;
       
   103     CCoeControl* ComponentControl(TInt aIndex) const;
       
   104 	void Draw(const TRect& aRect) const;
       
   105 	void SizeChanged(void);
       
   106 	
       
   107 	/**
       
   108 	* Allow AP to respond to layout/orientation changes
       
   109 	* @param aType event type
       
   110 	*/
       
   111 	void HandleResourceChange( TInt aType );
       
   112 //@}
       
   113 
       
   114 public:  
       
   115 /// @name From MActivePalette2UI
       
   116 //@{
       
   117 	virtual TInt InstallItemL(const TActivePalette2ItemVisible& aItemVisible, 
       
   118 						const TUid& aPluginUid, 
       
   119 						const TDesC8& aCustomDataDes);
       
   120 	virtual TInt InstallItemL(const TActivePalette2ItemVisible& aItemVisible,
       
   121 						const TUid& aPluginUid, 
       
   122 						TInt aCustomDataInt = 0);
       
   123 	virtual TInt InstallItemL(const TActivePalette2ItemVisible& aItemVisible,
       
   124 						const TUid& aPluginUid, 
       
   125 						TInt aCustomDataInt, 
       
   126 						const TDesC8& aCustomDataDes);
       
   127 	virtual TInt RemoveItem(TInt aItemId);
       
   128 	virtual TInt SetItemVisibility(TInt aItemId, TBool aIsVisible);
       
   129 	virtual TInt GetItemVisibility(TInt aItemId, TBool &aIsVisible) const;
       
   130     virtual TInt GetItemList(RArray<TActivePalette2ItemVisible>& aItemVisibleList) const;
       
   131     virtual TInt SetItemList(const RArray<TActivePalette2ItemVisible>& aItemVisibleList);
       
   132 	virtual TInt SendMessage(TInt aItemId, TInt aMessageId, const TDesC8& aDataDes);
       
   133 	virtual TInt SendMessage(TInt aItemId, TInt aMessageId, TInt aDataInt);
       
   134 	virtual TInt GetCurrentItem(TInt& aItemId) const;
       
   135 	virtual TInt SetCurrentItem(TInt aItemId);
       
   136     virtual TInt SetPaletteVisibility(TBool aVisible, TBool aAnimated, TInt aDelayedStartMilliseconds = 0);
       
   137     virtual TInt SetPaletteVisibilityAnimationDuration(TInt aTimeInMilliseconds);
       
   138     virtual TInt GetPaletteVisibilityAnimationDuration(TInt& aTimeInMilliseconds) const;
       
   139 	virtual void LocateTo(const TPoint& aTopLeft);
       
   140 	virtual TPoint Location() const;
       
   141     virtual CCoeControl* CoeControl();
       
   142     virtual CHuiControl* HuiControl();
       
   143     virtual void SetGc(CBitmapContext* aGc = NULL);
       
   144     virtual void RenderActivePalette(const TRect& aRect) const;
       
   145     virtual void SetObserver(MActivePalette2Observer* aObserver);
       
   146     virtual TInt GetAvailablePlugins(RArray<TUid>& aPluginList) const;
       
   147     virtual void SetNavigationKeys(const TActivePalette2NavigationKeys& aNavigationKeys);
       
   148 //@}
       
   149 
       
   150 public: 
       
   151 /// @name From MActivePalette2ModelObserver
       
   152 //@{
       
   153     virtual TInt TooltipUpdated();
       
   154     virtual void ItemsUpdated();
       
   155     virtual void ItemAnimated(TInt aScreenPos, CActivePalette2Item* aItem, TInt aAnimFrame);
       
   156     virtual void ItemAnimationComplete(TInt aScreenPos, CActivePalette2Item* aItem);
       
   157     virtual void FocusUpdated();
       
   158     virtual void PaletteAppearingUpdated();
       
   159 	virtual MActivePalette2Observer* APObserver() const;
       
   160     virtual void ShowTooltipUpdated();
       
   161 //@}
       
   162 
       
   163 public: 
       
   164 /// @name From MActivePalette2TooltipTimerObserver
       
   165 //@{
       
   166     virtual void TooltipAnimated();
       
   167 //@}
       
   168 
       
   169 public: 
       
   170 /// @name From MActivePalette2FocusTimerObserver
       
   171 //@{
       
   172     virtual void FocusAnimated();
       
   173 //@}
       
   174 
       
   175 public: 
       
   176 /// @name From MActivePalette2ItemScrollTimerObserver
       
   177 //@{
       
   178     virtual void ItemsScrolled();
       
   179 //@}
       
   180 
       
   181 public: 
       
   182 /// @name From MActivePalette2AppearanceTimerObserver
       
   183 //@{
       
   184     virtual void PaletteAppearingAnimated();
       
   185 //@}
       
   186 		
       
   187 private:
       
   188 /// @name Object creation helpers
       
   189 //@{
       
   190 	/**
       
   191 	 * Constructor
       
   192 	 */
       
   193 	CActivePalette2BasicUI();
       
   194 	
       
   195 	/**
       
   196 	 * Leaving constructor
       
   197 	 * @param aDrawMode The rendering style for the AP
       
   198 	 */
       
   199 	void ConstructL(TActivePalette2DrawMode aDrawMode);
       
   200 //@}
       
   201 
       
   202 /// @name New functions
       
   203 //@{	
       
   204 	/**
       
   205 	 * Flush the draw buffer in the specified area
       
   206 	 * @param aRectToFlush The area to flush
       
   207 	 */
       
   208 	void FlushBufNow(const TRect& aRectToFlush);
       
   209 	
       
   210 	/**
       
   211 	 * Recalculate the size of the AP
       
   212 	 */
       
   213 	void ReCalcAutoSizeL();
       
   214 	
       
   215 	/** 
       
   216 	 * Draw palette
       
   217 	 * @param aForceDisplayUpdate Indicates whether to force display update
       
   218 	 */
       
   219 	void RedrawIdle(TBool aForceDisplayUpdate = ETrue) const;
       
   220 
       
   221     /**
       
   222      * Produce the palette on the screen
       
   223      * @param aRect Rectangle in which to display the palette
       
   224      */
       
   225 	void ProducePaletteToScreen(const TRect& aRect) const;
       
   226 
       
   227     /**
       
   228      * Translates a draw buffer rect to it's on-screen position
       
   229      * @param aDrawBufRect The buffer rect
       
   230      * @return The on-screen rect
       
   231      */
       
   232     TRect DrawBufRectToScreenRect(TRect aDrawBufRect) const;
       
   233     
       
   234     /**
       
   235      * Translates a screen rect to it's in-buffer position
       
   236      * @param aScreenRect The on-screen rect
       
   237      * @return The buffer rect
       
   238      */
       
   239     TRect ScreenRectToDrawBufRect(TRect aScreenRect) const;
       
   240     
       
   241     /**
       
   242      * The palette's current screen position
       
   243      * @return The palette's current screen position
       
   244      */
       
   245     TPoint PalettePosition() const;
       
   246 
       
   247     /**
       
   248      * Draws a range of items, including the gaps between them.
       
   249      * @param aStartIndex The item index to begin drawing from
       
   250      * @param aFinishIndex The item index to finish with
       
   251      */
       
   252     void DrawItemRange(TInt aStartIndex, TInt aFinishIndex) const;
       
   253 
       
   254     /**
       
   255      * Draws a particular item
       
   256      * @param aIndex The item index to draw
       
   257      * @param aAnimOnly Whether to only draw the item's icon area, for use when animating
       
   258      */
       
   259     void DrawItem(TInt aIndex, TBool aAnimOnly = EFalse) const;
       
   260     
       
   261     /**
       
   262      * Draws the separator below the given item index.
       
   263      * @param aIndex The item index. If -1, the top scroll-arrow portion is drawn. If the same as the
       
   264      *               last shown item index, the bottom scroll-arrow portion is drawn.
       
   265      */
       
   266     void DrawSeparator(TInt aIndex) const;
       
   267 
       
   268     /**
       
   269      * Redraw to screen the portion of the AP most recently updated.
       
   270      */
       
   271     void FlushDirtyRect();
       
   272 //@}
       
   273 
       
   274 	
       
   275 
       
   276 
       
   277 private:	// data
       
   278 
       
   279     /// The model. Owned.
       
   280 	CActivePalette2Model* 	iModel;
       
   281 
       
   282     /// The observer; may be NULL. Not owned.
       
   283 	MActivePalette2Observer*	iAPObserver;
       
   284 
       
   285     /// The position of a fully-displayed palette.
       
   286 	TPoint                  iTopLeftCorner;
       
   287 	/// The current size of the palette
       
   288 	TSize                   iOverallSize;
       
   289 	
       
   290     /// The tooltip note. Owned
       
   291 	CActivePalette2Tooltip*	iTooltipNote;
       
   292 
       
   293     /// Current navigation keys
       
   294 	TActivePalette2NavigationKeys iNavigationKeys;
       
   295 
       
   296     /// Focused item's animation info
       
   297 	CActivePalettePluginBase::TPluginAnimationInfo iFocusPluginAniInfo;
       
   298 
       
   299     /// Stores the current screen size.
       
   300 	TSize	                iScreenSize;
       
   301 
       
   302     /// The rendering style
       
   303     TActivePalette2DrawMode iDrawMode;
       
   304 
       
   305     /// The context to render to. If NULL (default), the screen is used. Not owned
       
   306     CBitmapContext* iRenderGc;
       
   307     
       
   308     /// The style to render with
       
   309     CActivePalette2Styler* iStyler;
       
   310   	
       
   311   	// Configuration provider
       
   312   	CActivePalette2Configuration* iConfiguration;
       
   313     
       
   314     /// Remeber which items are (partially) covered by focus
       
   315     mutable TInt iFocusedItem1;
       
   316     /// Remeber which items are (partially) covered by focus
       
   317     mutable TInt iFocusedItem2;
       
   318     
       
   319     /// Where the palette was last rendered
       
   320     mutable TRect iRenderedRect;
       
   321     };
       
   322 
       
   323 
       
   324 #endif // _ACTIVE_PALETTE_2_BASIC_UI_H