imageeditor/ImageEditorUI/inc/ColorSelectionPopup.h
changeset 1 edfc90759b9f
equal deleted inserted replaced
0:57d4cdd99204 1:edfc90759b9f
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "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 * Ixonos Plc
       
    14 *
       
    15 * Description: 
       
    16 * Color selection popup dialog header file.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef COLORSELECTIONPOPUP_H
       
    22 #define COLORSELECTIONPOPUP_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <coecntrl.h>
       
    26 #include <AknDialog.h>
       
    27 
       
    28 #include "PreviewControlBase.h"
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CFbsBitmap;
       
    32 class TAknLayoutText;
       
    33 #ifdef RD_TACTILE_FEEDBACK 
       
    34 class MTouchFeedback; 
       
    35 #endif /* RD_TACTILE_FEEDBACK  */
       
    36    
       
    37 class CColorSelectionPopup :public CPreviewControlBase
       
    38 {
       
    39 
       
    40 public:
       
    41 
       
    42     /** Default constructor, cannot leave.
       
    43 	*
       
    44 	*   @since S60 5.0
       
    45 	*   @param -
       
    46 	*	@return -
       
    47 	*/
       
    48 	CColorSelectionPopup();
       
    49 
       
    50     /** Destructor
       
    51 	*
       
    52 	*   @since S60 5.0
       
    53 	*	@param -
       
    54 	*	@return -
       
    55 	*/
       
    56 	virtual ~CColorSelectionPopup ();
       
    57 
       
    58     /** Second phase constructor
       
    59 	*
       
    60 	*   @since S60 5.0
       
    61 	*	@param aParent - Parent control
       
    62 	*	@return -
       
    63 	*/
       
    64 	virtual void ConstructL ( CCoeControl* aParent );
       
    65 	
       
    66 	/**	OfferKeyEventL	
       
    67 	*
       
    68 	*	@see CCoeControl
       
    69 	*/
       
    70     virtual TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
    71                                                TEventCode aType );
       
    72                                                
       
    73     /**	HandlePointerEventL	
       
    74 	*
       
    75 	*	@see CCoeControl
       
    76 	*/
       
    77     virtual void HandlePointerEventL( const TPointerEvent &aPointerEvent );
       
    78 
       
    79 public: //new methods
       
    80       
       
    81     /** GridRect
       
    82     *
       
    83     * Returns popup component's rectangle area
       
    84     *
       
    85     * @since S60 5.0
       
    86     * @param -
       
    87     * @return TRect The area of the popup
       
    88     */
       
    89     TRect GridRect() const;
       
    90     
       
    91     /** HighlightedItemPressed
       
    92     *
       
    93     *   This function can be used to check whether user has pressed (by stylus)
       
    94     *   currently highlighted color item. 
       
    95     *
       
    96     *   @since S60 5.0
       
    97     *   @param aPosition position value to be checked.
       
    98     *   @return ETrue if aPosition is in the rect area of currently highlighted
       
    99     *          plugin item, EFalse otherwise.
       
   100     */
       
   101     TBool HighlightedItemPressed( TPoint aPosition ) const;
       
   102     
       
   103     /** GetSelectedColor
       
   104     *
       
   105     * Returns current highlighted color
       
   106     *
       
   107     * @since S60 5.0
       
   108     * @param -
       
   109     * @return TRgb Currently selected color item in RGB format
       
   110     */
       
   111     TRgb GetSelectedColor() const;
       
   112 
       
   113 
       
   114 	void SetSelectedColor(TRgb aRgb);
       
   115 
       
   116 
       
   117 private:                                                   
       
   118     
       
   119     /** CreateColorBitmapsL
       
   120     *
       
   121     * Creates a bitmap array
       
   122     *
       
   123     * @since S60 5.0
       
   124     * @param aSize Size that color bitmaps should be created to
       
   125     * @return -
       
   126     */
       
   127     void CreateColorBitmapsL( TSize aSize ); 
       
   128     
       
   129 protected:
       
   130 
       
   131    	/**	SizeChanged	
       
   132 	*
       
   133 	*	@see CCoeControl
       
   134 	*/
       
   135     virtual void SizeChanged();
       
   136 
       
   137 	/**	Draw	
       
   138 	*
       
   139 	*	@see CCoeControl
       
   140 	*/
       
   141     virtual void Draw( const TRect& aRect ) const;
       
   142     
       
   143 
       
   144 private:
       
   145         
       
   146     // Popup graphic bitmaps
       
   147     CFbsBitmap*     iPopupCenter;
       
   148     CFbsBitmap*     iPopupCenterMask;
       
   149     CFbsBitmap*     iPopupCornerTL;
       
   150     CFbsBitmap*     iPopupCornerTLMask;
       
   151     CFbsBitmap*     iPopupCornerTR;
       
   152     CFbsBitmap*     iPopupCornerTRMask;
       
   153     CFbsBitmap*     iPopupCornerBL;
       
   154     CFbsBitmap*     iPopupCornerBLMask;
       
   155     CFbsBitmap*     iPopupCornerBR;
       
   156     CFbsBitmap*     iPopupCornerBRMask;
       
   157     CFbsBitmap*     iPopupSideL;
       
   158     CFbsBitmap*     iPopupSideLMask;
       
   159     CFbsBitmap*     iPopupSideR;
       
   160     CFbsBitmap*     iPopupSideRMask;
       
   161     CFbsBitmap*     iPopupSideT;
       
   162     CFbsBitmap*     iPopupSideTMask;
       
   163     CFbsBitmap*     iPopupSideB;
       
   164     CFbsBitmap*     iPopupSideBMask;
       
   165          
       
   166     // Popup rects
       
   167     TRect           iPopupCenterRect;
       
   168     TRect           iPopupCornerTLRect;
       
   169     TRect           iPopupCornerTRRect;
       
   170     TRect           iPopupCornerBLRect;
       
   171     TRect           iPopupCornerBRRect;
       
   172     TRect           iPopupSideLRect;
       
   173     TRect           iPopupSideRRect;
       
   174     TRect           iPopupSideTRect;
       
   175     TRect           iPopupSideBRect;    
       
   176     TRect           iHeadingRect;    
       
   177     
       
   178     // Format and layout information of the heading text
       
   179     TAknLayoutText  iLayoutTextHeading;
       
   180     
       
   181     // Contains rectangles of all grid highlight items
       
   182     RArray< TRect > iHighlightRectsArray;
       
   183     
       
   184     // Contains rectangles of all grid color items
       
   185     RArray< TRect > iGridRectsArray;
       
   186     
       
   187     // Color bitmaps
       
   188     RPointerArray < CFbsBitmap > iColorBitmapsArray;
       
   189     
       
   190     // Used rgb values
       
   191     RArray< TRgb > iRGBArray;
       
   192     
       
   193     TInt            iCurrentItem;
       
   194 
       
   195         
       
   196 };
       
   197 
       
   198 
       
   199 class CColorSelectionDialog : public CAknDialog
       
   200     {
       
   201 public:
       
   202     
       
   203     /** RunDlgLD
       
   204 	*
       
   205 	*	@param aBitmap - background bitmap
       
   206 	*	@param aRect - Rect for the dialog
       
   207     *	@param aRgb - Color value to be returned
       
   208 	*	@return - ExecuteLD() return value
       
   209 	*/
       
   210 	static TInt RunDlgLD( const CFbsBitmap* aBitmap, 
       
   211 	                      const TRect& aRect, 
       
   212 	                      TRgb& aRgb );
       
   213 
       
   214   	/** Constructor
       
   215 	*
       
   216     *	@param aRgb - Color value to be returned
       
   217 	*	@return -
       
   218 	*/
       
   219     CColorSelectionDialog( TRgb& aRgb );
       
   220 
       
   221   	/** Destructor
       
   222 	*
       
   223 	*	@param  -
       
   224 	*	@return -
       
   225 	*/
       
   226     virtual ~CColorSelectionDialog();
       
   227 
       
   228   	/** 2nd phase constructor
       
   229 	*
       
   230 	*	@param aBitmap - background bitmap
       
   231 	*	@param aRect - Rect for the dialog
       
   232 	*	@return -
       
   233 	*/
       
   234     void ConstructL( const CFbsBitmap* aBitmap, const TRect& aRect);
       
   235 
       
   236     /** OkToExitL
       
   237     * 
       
   238     *   From CAknDialog update member variables .
       
   239     *   @param aButtonId The ID of the button that was activated.
       
   240     *   @return Should return ETrue if the dialog should exit,
       
   241     *           and EFalse if it should not
       
   242     */
       
   243     TBool OkToExitL( TInt aButtonId );
       
   244 
       
   245     /** Draw
       
   246     * 
       
   247     * 
       
   248     * @see CAknDialog
       
   249     *
       
   250     */
       
   251     void Draw(const TRect& aRect) const;
       
   252 
       
   253     /** SizeChanged
       
   254     * 
       
   255     * 
       
   256     * @see CCoeControl
       
   257     *
       
   258     */
       
   259     virtual void SizeChanged();
       
   260 
       
   261     /** OfferKeyEventL
       
   262     *  
       
   263     * @see CCoeControl
       
   264     *
       
   265     */
       
   266     virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
       
   267     
       
   268     /**	HandlePointerEventL	
       
   269 	*
       
   270 	*	@see CCoeControl
       
   271 	*/
       
   272     virtual void HandlePointerEventL( const TPointerEvent &aPointerEvent );
       
   273     
       
   274     /** PreLayoutDynInitL
       
   275     *  
       
   276     * @see CEikDialog
       
   277     *
       
   278     */
       
   279     virtual void PreLayoutDynInitL();
       
   280 
       
   281     /** CountComponentControls
       
   282     *  
       
   283     * @see CCoeControl
       
   284     *
       
   285     */
       
   286     TInt CountComponentControls() const;
       
   287 
       
   288     /** ComponentControl
       
   289     *  
       
   290     * @see CCoeControl
       
   291     *
       
   292     */
       
   293     virtual CCoeControl* ComponentControl(TInt aIndex) const;
       
   294 
       
   295 private:
       
   296     
       
   297     // popup component
       
   298     CColorSelectionPopup*   iPopup;
       
   299     
       
   300     // Selected color   
       
   301     TRgb&                   iCurrentRgb;
       
   302     
       
   303     	// Feedback for screen touch:
       
   304 #ifdef RD_TACTILE_FEEDBACK 
       
   305 	MTouchFeedback* iTouchFeedBack;
       
   306 #endif /* RD_TACTILE_FEEDBACK  */ 
       
   307     
       
   308     };
       
   309 
       
   310 #endif