Changeset 21101 for S60/trunk/WebKit

Show
Ignore:
Timestamp:
04/25/07 17:24:43 (21 months ago)
Author:
zbujtas
Message:

rathnasa, reviewed by zbujtas

DESC: widet menu api implementation
http://bugs.webkit.org/show_bug.cgi?id=13494

Location:
S60/trunk/WebKit
Files:
11 modified

Legend:

Unmodified
Added
Removed
  • S60/trunk/WebKit/BrowserControl/inc/BrCtlInterface.h

    r21033 r21101  
    938938        */ 
    939939        virtual void SetParamL(TBrCtlDefs::TBrCtlWidgetParams aParam, TUint aValue) = 0; 
     940 
     941        virtual TBool RightKeyCallback() = 0; 
     942 
    940943    }; 
    941944#endif      // BRCTLINTERFACE_H 
  • S60/trunk/WebKit/BrowserControl/src/BrCtl.cpp

    r21033 r21101  
    915915                if (wdgtExt) 
    916916                    { 
    917                     wdgtExt->OptionsMenuItemSelected(aCommand); 
     917                    wdgtExt->MenuItemSelected( aCommand ); 
    918918                    } 
    919919                break; 
    … …  
    11051105// ----------------------------------------------------------------------------- 
    11061106// 
    1107 EXPORT_C void CBrCtl::AddOptionMenuItemsL(CEikMenuPane& aMenuPane, TInt /*aResourceId*/, 
     1107EXPORT_C void CBrCtl::AddOptionMenuItemsL(CEikMenuPane& aMenuPane, TInt aResourceId, 
    11081108        TInt aAfter) 
    11091109    { 
    … …  
    11521152#ifdef  RD_BROWSER_WIDGETS 
    11531153    CWidgetExtension* wdgtExt = iWebKitControl->WidgetExtension(); 
    1154     if (wdgtExt) 
    1155         { 
    1156         wdgtExt->AddOptionMenuItemsL(aMenuPane); 
     1154    if ( wdgtExt ) 
     1155        { 
     1156        wdgtExt->AddOptionMenuItemsL( aMenuPane, aResourceId ); 
    11571157        } 
    11581158#endif //RD_BROWSER_WIDGETS 
    11591159    } 
     1160 
    11601161 
    11611162// ----------------------------------------------------------------------------- 
    … …  
    16271628    ComponentControl(0)->SetFocus(aFocus, aDrawNow); 
    16281629    } 
    1629  
    16301630 
    16311631// ----------------------------------------------------------------------------- 
  • S60/trunk/WebKit/BrowserView/inc/WidgetExtension.h

    r21033 r21101  
    4545//  INCLUDES 
    4646#include <e32base.h> 
     47#include <eikamnt.h> 
    4748#include <e32hashtab.h> 
    4849#include <BrCtlInterface.h> 
    … …  
    6263class TWidgetRenderer; 
    6364class CEikMenuPane; 
     65class CMenuItem; 
     66 
     67namespace KJS { 
     68    class WidgetEventHandler; 
     69} 
    6470 
    6571// CLASS DECLARATION 
    … …  
    8086        * @return CWidgetExtension object. 
    8187        */ 
    82         static CWidgetExtension* NewL(CWebKitView& aWebKitView,MWidgetCallback& aWidgetCallback); 
     88        static CWidgetExtension* NewL( CWebKitView& aWebKitView,MWidgetCallback& aWidgetCallback ); 
    8389 
    8490        /** 
    … …  
    94100        * @return void 
    95101        */ 
    96         void AddOptionMenuItemsL( CEikMenuPane& aMenuPane ); 
    97  
    98         /** 
    99         * Method OptionsMenuItemSelected 
     102        void AddOptionMenuItemsL( CEikMenuPane& aMenuPane,TInt aResourceId ); 
     103 
     104        /** 
     105        * Method MenuItemSelected 
    100106        * @since 3.2 
    101107        * @param The options menu command 
    102108        * @return void 
    103109        */ 
    104         void OptionsMenuItemSelected( TInt aCommand ); 
     110        void MenuItemSelected( TInt aCmdId ); 
    105111 
    106112        /** 
    … …  
    132138        * Method OpenApplication 
    133139        * @since 3.2 
    134         * @param The name of the application to open 
    135         * @return void 
    136         */ 
    137         void OpenApplication(const TDesC& aAppName, const TDesC& aParam); 
     140        * @param The Uid of the application to open 
     141        * @return void 
     142        */ 
     143        void OpenApplication( const TUid& aAppUid, const TDesC& aParam ); 
    138144 
    139145        /** 
    … …  
    143149        * @return void 
    144150        */ 
    145         void OpenUrl(const TDesC& aUrl); 
     151        void OpenUrl( const TDesC& aUrl ); 
    146152 
    147153        /** 
    … …  
    152158        * @return void 
    153159        */ 
    154         TInt PreferenceForKey(const TDesC& aKey, TPtrC& aValue); 
     160        TInt PreferenceForKey( const TDesC& aKey, TPtrC& aValue ); 
    155161 
    156162        /** 
    … …  
    160166        * @return void 
    161167        */ 
    162         void PrepareForTransition(const TDesC& aTransition); 
     168        void PrepareForTransition( const TDesC& aTransition ); 
    163169 
    164170        /** 
    … …  
    176182        * @return void 
    177183        */ 
    178         void SetPreferenceForKey(const TDesC& aKey, const TDesC& aValue); 
     184        void SetPreferenceForKey( const TDesC& aKey, const TDesC& aValue ); 
    179185 
    180186        /** 
    181187        * Method AddOptionsMenuItem 
    182188        * @since 3.2 
    183         * @param Name of options menu item 
    184         * @return command id 
    185         */ 
    186         TInt AddOptionsMenuItem(const TDesC& aName); 
    187  
    188         /** 
    189         * Method ClearOptionsMenu 
    190         * @since 3.2 
    191         * @return void 
    192         */ 
    193         void ClearOptionsMenu(); 
     189        * @param text buffer displayed in the main area of the menu item 
     190        * @param ID of the command to issue when the menu item is selected 
     191        * @param command ID of the parent menu item 
     192        * @return none 
     193        */ 
     194        void AddOptionsMenuItem( const TDesC& aText, TInt aCmdId, TInt aParentCmdId, void* obj ); 
     195 
     196        /** 
     197        * Method SetRightSoftKeyLabel 
     198        * @since 3.2 
     199        * @param text buffer to be set as right soft key label  
     200        * @return none 
     201        */ 
     202        void SetRightSoftKeyLabel( const TDesC& aText ); 
     203 
     204        /** 
     205        * Method DeleteMenuItem 
     206        * @since 3.2 
     207        * @param command ID of the menu item 
     208        * @param command ID of the parent menu item 
     209        * @return none 
     210        */ 
     211        void DeleteMenuItem( TInt aCmdId, TInt aParentCmdId ); 
     212         
     213        /** 
     214        * Method ClearMenuItems 
     215        * @since 3.2 
     216        * @param none 
     217        * @return none 
     218        */ 
     219        void ClearMenuItems(); 
     220 
     221        /** 
     222        * Method ReplaceMenuItem 
     223        * @since 3.2 
     224        * @param command ID of the menu item to be replaced 
     225        * @param text/label for the new menu item 
     226        * @param command ID of the new menu item 
     227        * @param dimmed status 
     228        * @return none 
     229        */ 
     230        void ReplaceMenuItem( TInt oldCmdId, const TDesC& newText,  
     231            TInt newCmdId, TInt newDimmed ); 
     232 
     233        /** 
     234        * Method GetMenuItem 
     235        * @since 3.2 
     236        * @param text/label for the menu item 
     237        * @param command ID of the menu item 
     238        * @param boolean flag to dim or undim the menu item 
     239        * @return none 
     240        */ 
     241        void GetMenuItem( TDes& textVal, TInt& cmdId, TBool& dimStat ); 
     242 
     243        /** 
     244        * Method SetDimmed 
     245        * @since 3.2 
     246        * @param command ID of the menu item 
     247        * @param boolean flag to dim or undim the menu item 
     248        * @return none 
     249        */ 
     250        void SetDimmed( TInt aCmdId, TBool aValue ); 
     251 
     252        /** 
     253        * Method SetMenuItemObserver 
     254        * @since 3.2 
     255        * @param command ID of the menu item 
     256        * @param callback function 
     257        * @return none 
     258        */ 
     259        void SetMenuItemObserver(  
     260            TInt aCmdId, WidgetEventHandler* aOnSelectCallback ); 
     261 
     262        /** 
     263        * Method GetMenuItemObserver 
     264        * @since 3.2 
     265        * @param command ID of the menu item 
     266        * @return callback function 
     267        */ 
     268        WidgetEventHandler* GetMenuItemObserver( TInt aCmdId ); 
     269 
     270        /** 
     271        * Method SetMenuObserver 
     272        * @since 3.2 
     273        * @param callback function 
     274        * @return none 
     275        */ 
     276        void SetMenuObserver( WidgetEventHandler* aMenuCallback ); 
     277 
     278        /** 
     279        * Method GetMenuObserver 
     280        * @since 3.2 
     281        * @param  
     282        * @return callback function 
     283        */ 
     284        WidgetEventHandler*& GetMenuObserver(); 
     285 
     286        /** 
     287        * Method SetRightKeyObserver 
     288        * @since 3.2 
     289        * @param callback function 
     290        * @return none 
     291        */ 
     292        void SetRightKeyObserver( WidgetEventHandler* aMenuCallback ); 
     293         
     294 
     295        /** 
     296        * Method GetMenuObserver 
     297        * @since 3.2 
     298        * @param  
     299        * @return callback function 
     300        */ 
     301        WidgetEventHandler*& GetRightKeyObserver(); 
    194302 
    195303        /** 
    … …  
    206314        * @return void 
    207315        */ 
    208         void SetScrollBar(TBool aVisible); 
     316        void SetScrollBar( TBool aVisible ); 
    209317 
    210318        /** 
    … …  
    214322        * @return void 
    215323        */ 
    216         void SetNavigationEnabled(TBool aEnable); 
     324        void SetNavigationEnabled( TBool aEnable ); 
    217325 
    218326        /** 
    219327        * Method SetOptionsMenuListener 
    220328        * @since 3.2 
     329        * @param WidgetEventHandler 
     330        * @return void 
     331        */ 
     332        void SetOptionsMenuListener( WidgetEventHandler* aCallback ); 
     333 
     334        /** 
     335        * Method SetOnHideListener 
     336        * @since 3.2 
     337        * @param WidgetEventHandler 
     338        * @return void 
     339        */ 
     340        void SetOnHideListener( WidgetEventHandler* aCallback ); 
     341 
     342        /** 
     343        * Method SetOnRemoveListener 
     344        * @since 3.2 
    221345        * @param CWidgetEventHandler 
    222346        * @return void 
    223347        */ 
    224         void SetOptionsMenuListener(CWidgetEventHandler* aCallback); 
    225  
    226         /** 
    227         * Method SetOnHideListener 
     348        void SetOnRemoveListener( WidgetEventHandler* aCallback ); 
     349 
     350        /** 
     351        * Method SetOnShowListener 
    228352        * @since 3.2 
    229353        * @param CWidgetEventHandler 
    230354        * @return void 
    231355        */ 
    232         void SetOnHideListener(CWidgetEventHandler* aCallback); 
    233  
    234         /** 
    235         * Method SetOnRemoveListener 
    236         * @since 3.2 
    237         * @param CWidgetEventHandler 
    238         * @return void 
    239         */ 
    240         void SetOnRemoveListener(CWidgetEventHandler* aCallback); 
    241  
    242         /** 
    243         * Method SetOnShowListener 
    244         * @since 3.2 
    245         * @param CWidgetEventHandler 
    246         * @return void 
    247         */ 
    248         void SetOnShowListener(CWidgetEventHandler* aCallback); 
     356        void SetOnShowListener( WidgetEventHandler* aCallback ); 
     357         
     358        /** 
     359        * Method GetFromMenuItemCollection 
     360        * @since 3.2 
     361        * @param text of menu item 
     362        * @return void* 
     363        */ 
     364        void* GetFromMenuItemCollection( const TDesC& textVal ); 
     365         
     366        /** 
     367        * Method GetFromMenuItemCollection 
     368        * @since 3.2 
     369        * @param commmand id of menu item 
     370        * @return void* 
     371        */ 
     372        void* GetFromMenuItemCollection( TInt cmdId ); 
     373 
    249374 
    250375    public: 
    … …  
    261386        * @return widget engine bridge 
    262387        */ 
    263         MWidgetEngineBridge& WidgetEngineBridge() const { return *iWidgetEngineBridge; } 
     388        MWidgetEngineBridge& WidgetEngineBridge() const {  
     389            return *iWidgetEngineBridge; } 
    264390 
    265391        /** 
    … …  
    300426        * @return void 
    301427        */ 
    302         void SetParamL(TBrCtlDefs::TBrCtlWidgetParams aParam, const TDesC& aValue); 
     428        void SetParamL(  
     429            TBrCtlDefs::TBrCtlWidgetParams aParam, const TDesC& aValue ); 
    303430 
    304431        /** 
    … …  
    309436        * @return void 
    310437        */ 
    311         void SetParamL(TBrCtlDefs::TBrCtlWidgetParams aParam, TUint aValue); 
     438        void SetParamL( TBrCtlDefs::TBrCtlWidgetParams aParam, TUint aValue ); 
     439 
     440        /** 
     441        * Method to invoke right soft key callback 
     442        * @since 3.2 
     443        * @param none 
     444        * @return Tbool 
     445        */ 
     446        TBool RightKeyCallback(); 
    312447 
    313448        /** 
    … …  
    317452        * @return void 
    318453        */ 
    319         void* createWidgetObject(void* exec); 
     454        void* createWidgetObject( void* aExec ); 
     455 
     456        /** 
     457        * Method createWidgetMenuObject 
     458        * @since 3.2 
     459        * @param 
     460        * @return void 
     461        */ 
     462        void* createWidgetMenuObject( void* aExec ); 
     463 
     464        /** 
     465        * Method createWidgetMenuItemObject 
     466        * @since 3.2 
     467        * @param 
     468        * @return void 
     469        */ 
     470        void* createWidgetMenuItemObject( void* aExec ); 
    320471 
    321472    private: 
    … …  
    340491        * @return void 
    341492        */ 
    342         void LaunchApplicationL(const TUid& aUid, const TDesC& aParam); 
     493        void LaunchApplicationL( const TUid& aUid, const TDesC& aParam ); 
     494 
     495        /* 
     496        * Method DeleteTree 
     497        * @since 3.2 
     498        * @param root node of the tree 
     499        * @return void 
     500        */ 
     501        void DeleteTree( CMenuItem* node ); 
    343502 
    344503    protected: 
    … …  
    353512        CWidgetExtension( CWebKitView& aWebKitView,MWidgetCallback& aWidgetCallback ); 
    354513 
    355  
    356514    private: 
    357         CWebKitView* iWebKitView;                    //not owned 
    358  
    359         CWidgetPreferences* iPreferences; 
    360         TWidgetRenderer* iWidgetRenderer; 
    361  
    362         struct TMenuItem 
     515        CWebKitView*            iWebKitView;//not owned 
     516        CWidgetPreferences*     iPreferences; 
     517        TWidgetRenderer*        iWidgetRenderer;       Â 
     518        TInt                    iWidgetId; 
     519        TBool                   iNavigationEnabled; 
     520        TBool                   iPageScalerWasEnabled; 
     521        HBufC*                  iWidgetBasePath; 
     522        HBufC*                  iWidgetBundleId; 
     523        MWidgetEngineBridge*    iWidgetEngineBridge; 
     524        MWidgetCallback*        iWidgetCallback; 
     525        RPtrHashMap<TDesC,TInt> iAppUidMap; 
     526        RLibrary                iLibrary; 
     527        CMenuItem*              iMenuRoot; 
     528        WidgetEventHandler*     iMenuCallback; 
     529        WidgetEventHandler*     iRightKeyCallback; 
     530 
     531        struct TCascadeIDMap 
    363532            { 
    364             HBufC* iText; 
    365             TInt iCmdId; 
     533            TInt iResourceId; 
     534            TInt parentCmdId; 
    366535            }; 
    367536 
    368         RArray<TMenuItem> iMenuItems; 
    369  
    370         TInt    iWidgetId; 
    371         TBool   iNavigationEnabled; 
    372         TBool   iPageScalerWasEnabled; 
    373         HBufC*  iWidgetBasePath; 
    374         HBufC*  iWidgetBundleId; 
    375  
    376         MWidgetEngineBridge* iWidgetEngineBridge; 
    377         MWidgetCallback* iWidgetCallback; 
    378  
    379         RPtrHashMap<TDesC,TInt> iAppUidMap; 
    380         RLibrary iLibrary; 
     537        RArray<TCascadeIDMap>   iCascadeArr; 
     538        TInt                    iResourceId; 
     539 
     540    private: 
     541        /* 
     542        * Method AddMenuItem 
     543        * @since 3.2 
     544        * @param menu pane 
     545        * @param menu item to be added 
     546        * @return void 
     547        */ 
     548        void AddMenuItem( CEikMenuPane& aMenuPane, CMenuItem* aNode ); 
     549 
     550        /* 
     551        * Method Insert 
     552        * @since 3.2 
     553        * @param root of the tree 
     554        * @param menu item to be inserted 
     555        * @param parent command id of the menu item to be inserted 
     556        * @return TBool 
     557        */ 
     558        TBool Insert( CMenuItem* root, CMenuItem* item, TInt parentId ); 
     559 
     560        /* 
     561        * Method InsertSibling 
     562        * @since 3.2 
     563        * @param root of the tree 
     564        * @param menu item to be inserted 
     565        * @return void 
     566        */ 
     567        void InsertSibling( CMenuItem* root, CMenuItem* item ); 
     568 
     569        /* 
     570        * Method FindNodeById 
     571        * @since 3.2 
     572        * @param root of the tree 
     573        * @param command id of the menu item  
     574        * @return CMenuItem* 
     575        */ 
     576        CMenuItem* FindNodeById( CMenuItem* node, TInt aCmdId ); 
     577 
     578        /* 
     579        * Method FindNodeByText 
     580        * @since 3.2 
     581        * @param root of the tree 
     582        * @param text of the menu item  
     583        * @return CMenuItem* 
     584        */ 
     585        CMenuItem* FindNodeByText( CMenuItem* node, const TDesC& aText ); 
    381586 
    382587    }; 
    383588 
     589 
     590class CMenuItem : public CBase 
     591    {     
     592    public: 
     593        /** 
     594        * Constructor       Â 
     595        */ 
     596        static CMenuItem* NewL( const TDesC16& aText, TInt aCmdId, void* aObj = NULL ); 
     597 
     598        /** 
     599        * Destructor. 
     600        */ 
     601        virtual ~CMenuItem(); 
     602 
     603    protected: 
     604        /** 
     605        * 2nd phase constructor. 
     606        */ 
     607        void ConstructL(); 
     608 
     609        /** 
     610        * C++ constructor. 
     611        */ 
     612        CMenuItem( const TDesC16& aText, TInt aCmdId, void* aObj = NULL );       Â 
     613 
     614    public: 
     615 
     616        /* 
     617        * Method Text() 
     618        * @since 3.2 
     619        * @param none 
     620        * @return text of menu item 
     621        */ 
     622        const TDesC& Text()  
     623            {  
     624            if ( iText ) return *iText; 
     625            else return KNullDesC(); 
     626            } 
     627 
     628        /* 
     629        * Method CmdId() 
     630        * @since 3.2 
     631        * @param none 
     632        * @return command id of menu item 
     633        */ 
     634        TInt CmdId() { return iCmdId; } 
     635 
     636        /* 
     637        * Method FirstChild() 
     638        * @since 3.2 
     639        * @param none 
     640        * @return first child of menu item 
     641        */ 
     642        CMenuItem*& FirstChild() { return iFirstChild; } 
     643 
     644        /* 
     645        * Method NextSibling() 
     646        * @since 3.2 
     647        * @param none 
     648        * @return next sibling of menu item 
     649        */ 
     650        CMenuItem*& NextSibling() { return iNextSibling; } 
     651         
     652        /* 
     653        * Method Dimmed() 
     654        * @since 3.2 
     655        * @param none 
     656        * @return dimmed status of menu item 
     657        */ 
     658        TBool Dimmed() { return iDimmed; } 
     659 
     660        /* 
     661        * Method Callback() 
     662        * @since 3.2 
     663        * @param none 
     664        * @return onselect callback function of menu item 
     665        */ 
     666        WidgetEventHandler*& Callback() { return iCallback; } 
     667 
     668        /* 
     669        * Method Obj() 
     670        * @since 3.2 
     671        * @param none 
     672        * @return menu item javascript object 
     673        */ 
     674        void*& Obj() { return iObj; } 
     675 
     676        /* 
     677        * Method SetText() 
     678        * @since 3.2 
     679        * @param text of menu item 
     680        * @return none 
     681        */ 
     682        void SetText( const TDesC& aText )  
     683            {  
     684            HBufC* tmpText = HBufC::NewL( aText.Length() ); 
     685            tmpText->Des().Append( aText ); 
     686            delete iText; 
     687            iText = tmpText;     
     688            } 
     689 
     690        /* 
     691        * Method SetCmdId() 
     692        * @since 3.2 
     693        * @param command id of menu item 
     694        * @return none 
     695        */ 
     696        void SetCmdId( TInt aCmdId ) { iCmdId = aCmdId; } 
     697 
     698        /* 
     699        * Method SetFirstChild() 
     700        * @since 3.2 
     701        * @param first child of menu item 
     702        * @return none 
     703        */ 
     704        void SetFirstChild( CMenuItem*& aFirstChild ) { iFirstChild = aFirstChild; } 
     705         
     706        /* 
     707        * Method SetNextSibling() 
     708        * @since 3.2 
     709        * @param next sibling of menu item 
     710        * @return none 
     711        */ 
     712        void SetNextSibling( CMenuItem*& aNextSibling ) { iNextSibling = aNextSibling; } 
     713         
     714        /* 
     715        * Method SetDimmed() 
     716        * @since 3.2 
     717        * @param dimmed status 
     718        * @return none 
     719        */ 
     720        void SetDimmed( TBool aDimmed ) { iDimmed = aDimmed; } 
     721 
     722        /* 
     723        * Method SetCallback() 
     724        * @since 3.2 
     725        * @param callback function 
     726        * @return none 
     727        */ 
     728        void SetCallback( WidgetEventHandler*& aCallback ) { iCallback = aCallback; } 
     729 
     730        /* 
     731        * Method SetObj() 
     732        * @since 3.2 
     733        * @param menu item javascript object 
     734        * @return none 
     735        */ 
     736        void SetObj( void*& aObj ) { iObj = aObj; } 
     737 
     738    private: 
     739        HBufC*                  iText;//data 
     740        TInt                    iCmdId;//data 
     741        CMenuItem*              iFirstChild;//left node 
     742        CMenuItem*              iNextSibling;//right node 
     743        TBool                   iDimmed;//ETrue to dim this menu item. EFalse to un-dim this menu item.  
     744        WidgetEventHandler*     iCallback; 
     745        void*                   iObj; 
     746    }; 
    Â