textinput/peninputarc/inc/peninputlayoutcontrolinc/peninputpopupbubble.h
branchRCL_3
changeset 56 8152b1f1763a
parent 50 5a1685599b76
child 57 9eb76adaa71f
equal deleted inserted replaced
50:5a1685599b76 56:8152b1f1763a
     1 /*
       
     2 * Copyright (c) 2005-2005 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: Header file of CPopupBubbleCtrl
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_CPOPUPBUBBLECTRL_H
       
    19 #define C_CPOPUPBUBBLECTRL_H
       
    20 
       
    21 #include <peninputlayoutbasecontrol.h>
       
    22 #include <AknsConstants.h>
       
    23 #include <AknsItemID.h>
       
    24 #include <AknLayout2Def.h>
       
    25 #include <coecntrl.h>
       
    26 #include <aknsskininstance.h>
       
    27 #include <e32cmn.h>
       
    28 
       
    29 class CPopupBubbleCtrl;
       
    30 
       
    31 /**
       
    32  *  CPopupBubbleWnd
       
    33  *  
       
    34  *  CCoeControl based class used for drawing
       
    35  * 
       
    36  */
       
    37 NONSHARABLE_CLASS(CPopupBubbleWnd) : public CCoeControl
       
    38     {
       
    39 public:
       
    40     /**
       
    41      * Destructor.        
       
    42      */
       
    43     virtual ~CPopupBubbleWnd();
       
    44 
       
    45     /**
       
    46      * Symbian constructor.        
       
    47      *
       
    48      * @param aRect control rect
       
    49      * @param aParent parent control
       
    50      * @return An instance of CPopupBubbleWnd class        
       
    51      */     
       
    52     static CPopupBubbleWnd* NewL(const TRect& aRect, CPopupBubbleCtrl& aParent);
       
    53     
       
    54     /**
       
    55      * Symbian constructor.       
       
    56      *
       
    57      * @param aRect control rect
       
    58      * @param aParent parent control
       
    59      * @return An instance of CPopupBubbleWnd class        
       
    60      */
       
    61     static CPopupBubbleWnd* NewLC(const TRect& aRect, CPopupBubbleCtrl& aParent);
       
    62 
       
    63     /**
       
    64      * Draw control.       
       
    65      *
       
    66      * @param aRect control rect     
       
    67      */    
       
    68     void Draw(const TRect& aRect) const;
       
    69     
       
    70     /**
       
    71      * Test transparency support.       
       
    72      *
       
    73      * @return ETrue if transparency is supported, otherwise EFalse.     
       
    74      */    
       
    75     inline TBool SupportTransparent() const
       
    76         {
       
    77         return iSupportTransparent;
       
    78         };
       
    79     
       
    80     /**
       
    81      * Handle size change.       
       
    82      */  
       
    83     void SizeChanged();
       
    84     
       
    85     /**
       
    86      * Handle resource change.       
       
    87      * @param aType resource change event.
       
    88      */ 
       
    89     void HandleResourceChange(TInt aType);
       
    90     
       
    91 protected:
       
    92     
       
    93     /**
       
    94     * Symbian OS 2nd phase constructor 
       
    95     */
       
    96     void ConstructL(const TRect& aRect);
       
    97     
       
    98     /**
       
    99     * C++ constructor
       
   100     * @param aParent CPopupBubbleCtrl parent control
       
   101     */
       
   102     CPopupBubbleWnd(CPopupBubbleCtrl& parent);
       
   103  
       
   104     /**
       
   105     * Size images used for drawing
       
   106     * @param aId Skin item Id
       
   107     * @param aRect Rect to be used for sizing
       
   108     * @param aBitmap Bitmap to be sized 
       
   109     * @param aDevice BitmapDevice to be used for sizing
       
   110     * @param aBitGc BitGc to be used for sizing
       
   111     */    
       
   112     void SizeImage(TAknsItemID aId, TRect aRect, CFbsBitmap* aBitmap, CFbsBitmapDevice* aDevice, CFbsBitGc* aBitGc );
       
   113     
       
   114 private:
       
   115     /**
       
   116      * Draw transparent background.       
       
   117      *
       
   118      * @param aRect control rect     
       
   119      */    
       
   120     void DrawTransparentBackground(const TRect& aRect) const;    
       
   121     
       
   122 private:
       
   123     
       
   124     enum TItems
       
   125         {
       
   126         ETempItem = 0,
       
   127         ELeftItem,
       
   128         ERightItem,
       
   129         EMiddleItem,
       
   130         ELastItem
       
   131         };
       
   132     
       
   133     RPointerArray<CFbsBitmap> iBitmap;
       
   134     RPointerArray<CFbsBitmapDevice> iDevice;
       
   135     RPointerArray<CFbsBitGc> iBitGc; 
       
   136     TRect iRect[ELastItem];
       
   137     
       
   138     CPopupBubbleCtrl& iParent;
       
   139     TBool iSupportTransparent;
       
   140     };
       
   141 
       
   142 /**
       
   143  *  CPopupBubbleCtrl
       
   144  *  
       
   145  *  Bubble with own window
       
   146  * 
       
   147  */
       
   148 class CPopupBubbleCtrl: public CFepUiBaseCtrl
       
   149     {
       
   150 public: 
       
   151     //constructor and destructor
       
   152     /**
       
   153      * Destructor.        
       
   154      */                  
       
   155     IMPORT_C virtual ~CPopupBubbleCtrl();
       
   156     /**
       
   157      * Symbian constructor.        
       
   158      *
       
   159      * @param aRect The rectangle area for this control
       
   160      * @param aUiLayout Ui layout who contains this control. Ownership not transferred
       
   161      * @param aControlId control Id
       
   162      * @return An instance of CPopupBubbleCtrl class        
       
   163      */
       
   164     IMPORT_C static CPopupBubbleCtrl* NewL(const TRect& aRect,
       
   165                              CFepUiLayout* aUiLayout,
       
   166                              TInt aCtrlId);
       
   167     
       
   168     
       
   169     /**
       
   170      * SetIconOffsetAndSize
       
   171      *
       
   172      * @param aOffset The offset to be moved
       
   173      * @param aOffset The size to be set
       
   174      */    
       
   175     inline void SetIconOffsetAndSize( 
       
   176             const TSize& aOffset, const TSize& aSize );
       
   177     
       
   178     /**
       
   179      * Draw the control
       
   180      *
       
   181      */      
       
   182     IMPORT_C void Draw();
       
   183     
       
   184     
       
   185     /**
       
   186      * Move the control
       
   187      *
       
   188      * @param aOffset The offset to be moved
       
   189      */    
       
   190     IMPORT_C void Move(const TPoint& aOffset);
       
   191 
       
   192     /**
       
   193      * Set bitmap parameters
       
   194      *
       
   195      * @param aBmpId Bitmap to be used. Can be NULL
       
   196      * @param aMaskBmpId Mask to be used. Can be NULL
       
   197      * @param aFirstBmpId Skin Bitmap id.
       
   198      * @param aMiddleBmpId Skin Bitmap id.
       
   199      * @param aLastBmpId Skin Bitmap id.
       
   200      */    
       
   201     IMPORT_C void SetBitmapParamL(
       
   202                         CFbsBitmap* aBmpId,
       
   203                         CFbsBitmap* aMaskBmpId,
       
   204                         TAknsItemID aFirstBmpId,
       
   205                         TAknsItemID aMiddleBmpId,
       
   206                         TAknsItemID aLastBmpId);                            
       
   207 
       
   208     /**
       
   209      * Hide the control
       
   210      *    
       
   211      * @param aShowFlag visibility flag. ETrue if hidden, otherwise EFalse
       
   212      */
       
   213     IMPORT_C void Hide(TBool aShowFlag); 
       
   214 
       
   215     /**
       
   216      * Set text format used for text drawing
       
   217      *    
       
   218      * @param aTextFormat bubble text format
       
   219      */    
       
   220     IMPORT_C void SetTextFormat(TAknTextLineLayout aTextFormat);
       
   221 
       
   222     /**
       
   223      * Set bubble text
       
   224      *    
       
   225      * @param aText descriptor containing bubble text
       
   226      */        
       
   227     IMPORT_C void SetTextL(const TDesC& aText );
       
   228 
       
   229     /**
       
   230      * Get bubble text
       
   231      *    
       
   232      * @param aText descriptor to be filled in with data
       
   233      */     
       
   234     inline void GetText( TDes& aText );
       
   235     
       
   236     /**
       
   237      * Check if text is set
       
   238      *    
       
   239      * @return ETrue is text was set. Otherwise EFalse.
       
   240      */     
       
   241     inline TBool HasText();
       
   242 
       
   243     /**
       
   244      * Set text color index used for drawing
       
   245      *    
       
   246      * @param aTxtClrIndex Color index.
       
   247      */     
       
   248     inline void SetTextColorIndex( TInt aTxtClrIndex );
       
   249 
       
   250     /**
       
   251      * Get text color index used for drawing
       
   252      *    
       
   253      * @return Color index.
       
   254      */         
       
   255     inline TInt TextColorIndex() const;
       
   256 protected:
       
   257     
       
   258     /**
       
   259      * C++ constructor.        
       
   260      *
       
   261      * @param aRect The rectangle area for this control
       
   262      * @param aUiLayout Ui layout who contains this control. Ownership not transferred
       
   263      * @param aControlId control Id
       
   264      */    
       
   265     IMPORT_C CPopupBubbleCtrl(const TRect& aRect,
       
   266                 CFepUiLayout* aUiLayout,
       
   267                 TInt aCtrlId);
       
   268 private:
       
   269     CFbsBitmap* iForgroundBmp;
       
   270     CFbsBitmap* iForgroundBmpMask;
       
   271     
       
   272     TAknsItemID iFirstBmpId;
       
   273     TAknsItemID iMiddleBmpId;
       
   274     TAknsItemID iLastBmpId;
       
   275       
       
   276     HBufC* iText;
       
   277     TAknTextLineLayout iTextFormat;
       
   278     TInt iTextColorIndex;
       
   279 
       
   280     TSize iIconOffset;
       
   281     TSize iIconSize;    
       
   282     
       
   283     friend class CPopupBubbleWnd;
       
   284     };
       
   285    
       
   286 inline void CPopupBubbleCtrl::SetTextColorIndex( TInt aTxtClrIndex )
       
   287     {
       
   288     iTextColorIndex = aTxtClrIndex; 
       
   289     }
       
   290 
       
   291 inline void CPopupBubbleCtrl::SetIconOffsetAndSize( 
       
   292         const TSize& aOffset, const TSize& aSize )
       
   293     {
       
   294     iIconOffset = aOffset;
       
   295     iIconSize = aSize;
       
   296     }
       
   297 
       
   298 inline void CPopupBubbleCtrl::GetText( TDes& aText )
       
   299     {
       
   300     if (iText)
       
   301         {
       
   302         aText.Copy( *iText );
       
   303         }
       
   304     }
       
   305 
       
   306 inline TBool CPopupBubbleCtrl::HasText()
       
   307     {
       
   308     TBool ret = EFalse;
       
   309 
       
   310     if (iText && iText->Length() > 0)
       
   311         {
       
   312         ret = ETrue;
       
   313         }
       
   314 
       
   315     return ret;
       
   316     }
       
   317 
       
   318 /******************************************************************************/
       
   319 
       
   320 #endif //C_CPOPUPBUBBLECTRL_H