webengine/webkitutils/ToolBar/ToolBarButton.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2006 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 the License "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:  The Toolbar button class
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __TOOLBARBUTTON
       
    19 #define __TOOLBARBUTTON
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 
       
    24 // CONSTANTS
       
    25 
       
    26 // MACROS
       
    27 
       
    28 // DATA TYPES
       
    29 
       
    30 // FUNCTION PROTOTYPES
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CWindowGc;
       
    34 class CToolBar;
       
    35 class CToolBarButton;
       
    36 class CFbsBitmapDevice;
       
    37 class CFbsBitGc;
       
    38 class CFbsBitmap;
       
    39 class CGulIcon;
       
    40 class CDropDownButton;
       
    41 class TBrCtlSubscribeTo;
       
    42 class CRecentUrlStore;
       
    43 class CIdle;
       
    44 
       
    45 // CLASS DECLARATION
       
    46 /**
       
    47 *  CDropDownList
       
    48 *
       
    49 *  @lib toolbar.dll
       
    50 *  @since 3.1
       
    51 */
       
    52 class CDropDownList : public CBase
       
    53     {
       
    54     public:  // Constructors and destructor
       
    55 
       
    56         /**
       
    57         * Two-phased constructor.
       
    58         * @since 3.1
       
    59         * @param
       
    60         * @param
       
    61         * @return CHttpCacheEntry object.
       
    62         */
       
    63         static CDropDownList* NewL( CDropDownButton& aParent, CArrayPtrFlat<HBufC>* aItemText,
       
    64             CArrayPtrFlat<CGulIcon>* aItemIcon = NULL );
       
    65 
       
    66         /**
       
    67         * Destructor.
       
    68         */
       
    69         virtual ~CDropDownList();
       
    70 
       
    71     public: // new functions
       
    72 
       
    73         /**
       
    74         *
       
    75         * @since 3.1
       
    76         * @param
       
    77         * @return
       
    78         */
       
    79         void MakeVisible( TBool aVisible );
       
    80 
       
    81         /**
       
    82         *
       
    83         * @since 3.1
       
    84         * @param
       
    85         * @return
       
    86         */
       
    87         void SetFocus( TBool aFocusOn );
       
    88 
       
    89         /**
       
    90         *
       
    91         * @since 3.1
       
    92         * @param
       
    93         * @return
       
    94         */
       
    95         TKeyResponse HandleOfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aEventCode );
       
    96         
       
    97         /**
       
    98         *
       
    99         * @since 3.1
       
   100         * @param
       
   101         * @return
       
   102         */
       
   103         TBool HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   104 
       
   105         /**
       
   106         *
       
   107         * @since 3.1
       
   108         * @param
       
   109         * @return
       
   110         */
       
   111       //  void Draw( CWindowGc& aGc ) ;
       
   112         void Draw() ;
       
   113 
       
   114         /**
       
   115         *
       
   116         * @since 3.1
       
   117         * @param
       
   118         * @return
       
   119         */
       
   120         TInt SelectedItem() const { return iSelectedItem; }
       
   121 
       
   122         /**
       
   123         *
       
   124         * @since 3.1
       
   125         * @param
       
   126         * @return
       
   127         */
       
   128         const HBufC& SelectedItemText() const { return *iItemText->At( iSelectedItem ); }
       
   129 
       
   130         /**
       
   131         *
       
   132         * @since 3.1
       
   133         * @param
       
   134         * @return
       
   135         */
       
   136         void UpdateIconsL( CArrayPtrFlat<CGulIcon>* aItemIcon );
       
   137     private:
       
   138 
       
   139         /**
       
   140         * Construct.
       
   141         * @since 3.1
       
   142         * @param
       
   143         * @param
       
   144         * @return CDropDownList object.
       
   145         */
       
   146         CDropDownList( CDropDownButton& aParent, CArrayPtrFlat<HBufC>* aItemText,
       
   147                 CArrayPtrFlat<CGulIcon>* aItemIcon = NULL );
       
   148 
       
   149         /**
       
   150         * By default Symbian 2nd phase constructor is private.
       
   151         */
       
   152         void ConstructL();
       
   153 
       
   154         /**
       
   155         *
       
   156         * @since 3.1
       
   157         * @param
       
   158         * @return
       
   159         */
       
   160         void AnimateDropDown();
       
   161 
       
   162         /**
       
   163         *
       
   164         * @since 3.1
       
   165         * @param
       
   166         * @return
       
   167         */
       
   168         static TInt DropDownCb( TAny* aPtr );
       
   169 
       
   170         /**
       
   171         *
       
   172         * @since 3.1
       
   173         * @param
       
   174         * @return
       
   175         */
       
   176         void DrawDropDownListL();
       
   177 
       
   178         /**
       
   179         *
       
   180         * @since 3.1
       
   181         * @param
       
   182         * @return
       
   183         */
       
   184         TSize CalculateListSize();
       
   185 
       
   186         /**
       
   187         *
       
   188         * @since 3.1
       
   189         * @param
       
   190         * @return
       
   191         */
       
   192         void CreateBitmapL();
       
   193         
       
   194         /**
       
   195         *
       
   196         * @since 3.1
       
   197         * @param
       
   198         * @return
       
   199         */
       
   200         void ConstructSprite();
       
   201 
       
   202     private:    // Data
       
   203 
       
   204         CDropDownButton* iParent;   // not owned
       
   205 
       
   206         CArrayPtrFlat<HBufC>* iItemText; // owned
       
   207         CArrayPtrFlat<CGulIcon>* iItemIcon; // owned
       
   208 
       
   209         TBool        iVisible;
       
   210 
       
   211         TInt         iDropSlide;
       
   212 
       
   213         TPoint       iPosition;
       
   214 
       
   215         TSize        iSize;
       
   216 
       
   217         TInt         iSelectedItem;
       
   218         
       
   219         TInt          iOldSelectedItem;
       
   220 
       
   221         CPeriodic*   iAnimTimer;
       
   222 
       
   223         CFbsBitmapDevice*        iDropDownBitmapDevice;     // owned
       
   224 
       
   225         CFbsBitGc*               iDropDownBitmapContext; // owned
       
   226 
       
   227         CFbsBitmap*              iDropDownBitmap; //owned
       
   228         
       
   229         CFbsBitmapDevice*        iSpriteBitmapDevice;     // owned
       
   230 
       
   231         CFbsBitGc*               iSpriteBitmapContext; // owned
       
   232 
       
   233         CFbsBitmap*              iSpriteBitmap; //owned
       
   234         
       
   235         CFbsBitmapDevice*        iSpriteMaskBitmapDevice;     // owned
       
   236 
       
   237         CFbsBitGc*               iSpriteMaskBitmapContext; // owned
       
   238 
       
   239         CFbsBitmap*              iSpriteMaskBitmap; //owned
       
   240         
       
   241         CFbsBitmapDevice*        iMaskBitmapDevice;     // owned
       
   242 
       
   243         CFbsBitGc*               iMaskBitmapContext; // owned
       
   244 
       
   245         CFbsBitmap*              iMaskBitmap; //owned
       
   246         
       
   247         RWsSprite                iDropSprite;
       
   248 
       
   249         TBool                    iDropUp;
       
   250 
       
   251         TBool                     iSpriteInitialised;
       
   252     };
       
   253 
       
   254 /**
       
   255 *  This is the toolbar class
       
   256 *  @since 3.1
       
   257 */
       
   258 class CToolBarButton : public CBase
       
   259     {
       
   260     public:
       
   261 
       
   262         /**
       
   263         * Two-phased constructor.
       
   264         */
       
   265         static CToolBarButton* NewL( CToolBar& aParent, TInt aIconIndex, const TDesC& aToolTip );
       
   266 
       
   267         /**
       
   268         * Destructor.
       
   269         */
       
   270         virtual ~CToolBarButton();
       
   271 
       
   272         /**
       
   273         * SetPosition
       
   274         * Sets the position of the toolbar button
       
   275         * @since 3.1
       
   276         * @param TPoint &aPoint
       
   277         * @return void
       
   278         */
       
   279         void SetPosition( const TPoint& aPoint ) { iPosition = aPoint; }
       
   280 
       
   281         /**
       
   282         * Position
       
   283         * Gets the position of the toolbar button
       
   284         * @since 3.1
       
   285         * @return TPoint
       
   286         */
       
   287         TPoint Position() const { return iPosition; }
       
   288 
       
   289         /**
       
   290         * Size
       
   291         * Gets the size of the button
       
   292         * @since 3.1
       
   293         * @return TPoint
       
   294         */
       
   295         TSize Size() const { return iToolBarButton->SizeInPixels(); }
       
   296 
       
   297         /**
       
   298         * Draw
       
   299         * Refreshes the button
       
   300         * @since 3.1
       
   301         * @return CWebKitToolTip
       
   302         */
       
   303         CToolBar& ToolBar() const { return *iParent; };
       
   304 
       
   305         /**
       
   306         * ToolBarImage
       
   307         * Gets the canned image for the button
       
   308         * @since 3.1
       
   309         * @return CWebKitToolTip
       
   310         */
       
   311         CFbsBitmap& ButtonImage() const { return *iToolBarButton; }
       
   312 
       
   313         /**
       
   314         * ToolBarImage
       
   315         * Gets the canned image for the button
       
   316         * @since 3.1
       
   317         * @return CWebKitToolTip
       
   318         */
       
   319         CFbsBitmap& ButtonMaskImage() const { return *iToolBarButtonMask; }
       
   320 
       
   321         /**
       
   322         * HandleOfferKeyEventL
       
   323         * Handles key events
       
   324         * @since 3.1
       
   325         * @return CWebKitToolTip
       
   326         */
       
   327         virtual TKeyResponse HandleOfferKeyEventL( const TKeyEvent& /*aKeyEvent*/, TEventCode /*aEventCode*/ )
       
   328             { return EKeyWasNotConsumed; }
       
   329 
       
   330         /**
       
   331         * SetFocus
       
   332         * Puts focus on the button
       
   333         * @since 3.1
       
   334         * @return CWebKitToolTip
       
   335         */
       
   336         virtual void SetFocus( TBool aFocusOn );
       
   337 
       
   338         /**
       
   339         * Draw
       
   340         * Refreshes the button
       
   341         * @since 3.1
       
   342         * @return CWebKitToolTip
       
   343         */
       
   344  //       virtual void Draw( CWindowGc& /*aGc*/ ) const {}
       
   345         virtual void Draw() const {}
       
   346 
       
   347         /**
       
   348         * ShowToolTip
       
   349         * Method to enable tooltip visibility
       
   350         * @since 3.1
       
   351         * @param aVisible show or hide tooltip - default is to show tool tip
       
   352         * @return void
       
   353         */
       
   354         virtual void ShowToolTip(TBool aVisible = ETrue); 
       
   355         
       
   356         /**
       
   357         * RefreshToolTip
       
   358         * re-draws tool tip
       
   359         * @since 3.1
       
   360         * @param
       
   361         * @return
       
   362         */
       
   363         virtual void RefreshToolTip();
       
   364 
       
   365         /**
       
   366         * HandlePointerEventL
       
   367         * Handles pointer events
       
   368         * @since 3.1
       
   369         * @return TBool
       
   370         */
       
   371         virtual TBool HandlePointerEventL( const TPointerEvent& /*aPointerEvent*/ ){ return ETrue; }
       
   372 
       
   373     protected:
       
   374 
       
   375         /**
       
   376         * Two-phased constructor.
       
   377         */
       
   378         CToolBarButton( CToolBar& aParent );
       
   379 
       
   380         /**
       
   381         * Two-phased constructor.
       
   382         */
       
   383         void BaseConstructL( TInt aButtonCmd, const TDesC& aToolTip );
       
   384 
       
   385     protected:
       
   386         //The canned image for this button
       
   387         CFbsBitmap* iToolBarButton;
       
   388         //The bitmap mask for this button
       
   389         CFbsBitmap* iToolBarButtonMask;
       
   390         //A pointer to the tooltip
       
   391         HBufC* iToolTip; //owned
       
   392         // pointer to the toolbar
       
   393         CToolBar* iParent; // not owned
       
   394         //Position of this button
       
   395         TPoint iPosition;
       
   396         
       
   397         CFbsBitmapDevice*        iToolTipBitmapDevice;     // owned
       
   398 
       
   399         CFbsBitGc*               iToolTipBitmapContext; // owned
       
   400 
       
   401         CFbsBitmap*              iToolTipBitmap; //owned
       
   402         
       
   403         CFbsBitmapDevice*        iToolTipMaskDevice;     // owned
       
   404 
       
   405         CFbsBitGc*               iToolTipMaskContext; // owned
       
   406 
       
   407         CFbsBitmap*              iToolTipMask; //owned
       
   408         
       
   409         RWsSprite iToolTipSprite;
       
   410         
       
   411         TBool iToolTipSpriteVisible;        
       
   412         
       
   413         TPoint                   iToolTipPos;
       
   414         
       
   415     };
       
   416 
       
   417 /**
       
   418 *  CDropDownButton
       
   419 *
       
   420 *  @lib webkit.dll
       
   421 *  @since 3.0
       
   422 */
       
   423 class CDropDownButton: public CToolBarButton
       
   424     {
       
   425     public:  // Constructors and destructor
       
   426 
       
   427         /**
       
   428         * Destructor.
       
   429         */
       
   430         virtual ~CDropDownButton();
       
   431 
       
   432         /**
       
   433         *
       
   434         * @since 3.1
       
   435         * @param
       
   436         * @return
       
   437         */
       
   438         virtual TKeyResponse HandleOfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aEventCode );
       
   439 
       
   440         /**
       
   441         *
       
   442         * @since 3.1
       
   443         * @param
       
   444         * @return
       
   445         */
       
   446         virtual void SetFocus( TBool aFocusOn );
       
   447 
       
   448         /**
       
   449         *
       
   450         * @since 3.1
       
   451         * @param
       
   452         * @return
       
   453         */
       
   454     //    virtual void Draw( CWindowGc& aGc ) const;
       
   455         virtual void Draw() const;
       
   456                 
       
   457         /**
       
   458         *
       
   459         * @since 3.1
       
   460         * @param
       
   461         * @return
       
   462         */
       
   463         virtual void ActivatedL( TInt aSelectedItem ) = 0;
       
   464         
       
   465         /**
       
   466         * HandlePointerEventL
       
   467         * Handles pointer events
       
   468         * @since 3.1
       
   469         * @return TBool
       
   470         */
       
   471         virtual TBool HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   472         
       
   473         /**
       
   474         * ShowToolTip
       
   475         * Method to enable tooltip visibility
       
   476         * @since 3.1
       
   477         * @return CWebKitToolTip
       
   478         */
       
   479         virtual void ShowToolTip(); 
       
   480          
       
   481     protected:
       
   482 
       
   483         /**
       
   484         * Construct.
       
   485         * @since 3.1
       
   486         * @param
       
   487         * @param
       
   488         * @return CDropDownList object.
       
   489         */
       
   490         CDropDownButton( CToolBar& aParent );
       
   491 
       
   492     protected:
       
   493 
       
   494         CDropDownList* iDropDown; // owned
       
   495     };
       
   496 
       
   497 /**
       
   498 *  CBackButton
       
   499 *
       
   500 *  @lib webkit.dll
       
   501 *  @since 3.0
       
   502 */
       
   503 class CVisitedButton : public CDropDownButton
       
   504     {
       
   505     public:  // Constructors and destructor
       
   506 
       
   507         /**
       
   508         * Two-phased constructor.
       
   509         * @since 3.1
       
   510         * @param
       
   511         * @param
       
   512         * @return CHttpCacheEntry object.
       
   513         */
       
   514         static CVisitedButton* NewL( CToolBar& aParent, TInt aIconIndex, const TDesC& aToolTip );
       
   515 
       
   516         /**
       
   517         * Destructor.
       
   518         */
       
   519         virtual ~CVisitedButton();
       
   520 
       
   521     protected:
       
   522 
       
   523         /**
       
   524         * Construct.
       
   525         * @since 3.1
       
   526         * @param
       
   527         * @param
       
   528         * @return CDropDownList object.
       
   529         */
       
   530         CVisitedButton( CToolBar& aParent );
       
   531 
       
   532         /**
       
   533         * By default Symbian 2nd phase constructor is private.
       
   534         */
       
   535         void ConstructL( TInt aButtonCmd, const TDesC& aToolTip );
       
   536         /**
       
   537         *
       
   538         * @since 3.1
       
   539         * @param
       
   540         * @return
       
   541         */
       
   542         void ActivatedL( TInt aSelectedItem );
       
   543         /**
       
   544         *
       
   545         * @since 3.1
       
   546         * @param
       
   547         * @return
       
   548         */
       
   549         TBool ReadNextFaviconL();
       
   550         /**
       
   551         *
       
   552         * @since 3.1
       
   553         * @param
       
   554         * @return
       
   555         */
       
   556         static TBool ReadFaviconCb( TAny* aAny );
       
   557     private:
       
   558 
       
   559         CArrayPtrFlat<HBufC>* iVisitedUrls; // owned
       
   560         //
       
   561         CRecentUrlStore* iRecentUrlStore; //owned
       
   562         //
       
   563         TInt      iCurrentFavicon;
       
   564         //
       
   565         CArrayPtrFlat<CGulIcon>* iListIcons; // owned
       
   566         //
       
   567         CIdle*    iFaviTimer;  // owned
       
   568     };
       
   569 
       
   570 /**
       
   571 *      
       
   572 *
       
   573 *  @lib webkit.dll
       
   574 *  @since 3.0
       
   575 */
       
   576 class CRssButton : public CDropDownButton
       
   577     {
       
   578     public:  // Constructors and destructor
       
   579 
       
   580         /**
       
   581         * Two-phased constructor.
       
   582         * @since 3.1
       
   583         * @param
       
   584         * @param
       
   585         * @return CHttpCacheEntry object.
       
   586         */
       
   587         static CRssButton* NewL( CToolBar& aParent, TInt aIconIndex, const TDesC& aToolTip,
       
   588                 const RPointerArray<TBrCtlSubscribeTo>& aRssArray  );
       
   589 
       
   590         /**
       
   591         * Destructor.
       
   592         */
       
   593         virtual ~CRssButton();
       
   594 
       
   595     protected:
       
   596 
       
   597         /**
       
   598         * Construct.
       
   599         * @since 3.1
       
   600         * @param
       
   601         * @param
       
   602         * @return      object.
       
   603         */
       
   604         CRssButton( CToolBar& aParent );
       
   605 
       
   606         /**
       
   607         * By default Symbian 2nd phase constructor is private.
       
   608         */
       
   609         void ConstructL( TInt aButtonCmd, const TDesC& aToolTip, const RPointerArray<TBrCtlSubscribeTo>& aRssArray );
       
   610 
       
   611         /**
       
   612         *
       
   613         * @since 3.1
       
   614         * @param
       
   615         * @return
       
   616         */
       
   617         void ActivatedL( TInt aSelectedItem );
       
   618 
       
   619     private:
       
   620 
       
   621         CArrayPtrFlat<HBufC>* iSubscribeToItemsUrls; // owned
       
   622     };
       
   623     
       
   624 /**
       
   625 *  CBookmarksButton
       
   626 *
       
   627 */
       
   628 class CBookmarksButton : public CDropDownButton
       
   629     {
       
   630     public:  // Constructors and destructor
       
   631 
       
   632         /**
       
   633         * Two-phased constructor.
       
   634         * @since 3.1
       
   635         * @param
       
   636         * @param
       
   637         * @return CHttpCacheEntry object.
       
   638         */
       
   639         static CBookmarksButton* NewL( CToolBar& aParent, TInt aIconIndex, const TDesC& aToolTip );
       
   640 
       
   641         /**
       
   642         * Destructor.
       
   643         */
       
   644         virtual ~CBookmarksButton();
       
   645 
       
   646     protected:
       
   647 
       
   648         /**
       
   649         * Construct.
       
   650         * @since 3.1
       
   651         * @param
       
   652         * @param
       
   653         * @return CDropDownList object.
       
   654         */
       
   655         CBookmarksButton( CToolBar& aParent );
       
   656 
       
   657         /**
       
   658         * By default Symbian 2nd phase constructor is private.
       
   659         */
       
   660         void ConstructL( TInt aButtonCmd, const TDesC& aToolTip );
       
   661         /**
       
   662         *
       
   663         * @since 3.1
       
   664         * @param
       
   665         * @return
       
   666         */
       
   667         void ActivatedL( TInt aSelectedItem );
       
   668         /**
       
   669         *
       
   670         * @since 3.1
       
   671         * @param
       
   672         * @return
       
   673         */
       
   674         TBool ReadNextFaviconL();
       
   675         /**
       
   676         *
       
   677         * @since 3.1
       
   678         * @param
       
   679         * @return
       
   680         */
       
   681         static TBool ReadFaviconCb( TAny* aAny );
       
   682     private:
       
   683     
       
   684         CArrayPtrFlat<HBufC>* iBookmarkUrls; // owned
       
   685         //
       
   686         TInt      iCurrentFavicon;
       
   687         //
       
   688         CArrayPtrFlat<CGulIcon>* iListIcons; // owned
       
   689         //
       
   690         CIdle*    iFaviTimer;  // owned
       
   691     };
       
   692     
       
   693 #endif