csxhelp/inc/CSXHHtmlTopicContainer.h
branchRCL_3
changeset 18 cbffe13eac63
equal deleted inserted replaced
17:12f60d9a73b3 18:cbffe13eac63
       
     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 "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:  CCSXHHtmlTopicContainer class declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef INC_CCSXHHTMLTOPICCONTAINER_H__
       
    20 #define INC_CCSXHHTMLTOPICCONTAINER_H__
       
    21 //If I use INC_CCSXHHTMLTOPICCONTAINER_H__, then CodeScanner fails 
       
    22 //but if I use INC_CCSXH_HTML_TOPIC_CONTAINER_H__ code scanner 
       
    23 //reports an error but produces results for other files
       
    24 
       
    25 #include <coecntrl.h>
       
    26 #include <brctllinkresolver.h>
       
    27 #include <brctlinterface.h>
       
    28 //RUNTIME
       
    29 #include <featurecontrol.h>
       
    30 
       
    31 class CBrCtlInterface;
       
    32 class CCSXHDocument;
       
    33 class CCSXHHtmlTOC2;
       
    34 class CCSXHHtmlTopicView;
       
    35 class AppLauncherForCSXH;
       
    36 class CCSXHHelpContentBase;
       
    37 
       
    38 typedef CBrCtlInterface* (*FuncPtr_CreateBrowserControlL) (CCoeControl* aParent, TRect aRect,
       
    39     TUint aBrCtlCapabilities, TUint aCommandIdBase = TBrCtlDefs::ECommandIdBase,
       
    40     MBrCtlSoftkeysObserver* aBrCtlSoftkeysObserver = NULL,
       
    41     MBrCtlLinkResolver* aBrCtlLinkResolver = NULL,
       
    42     MBrCtlSpecialLoadObserver* aBrCtlSpecialLoadObserver = NULL,
       
    43     MBrCtlLayoutObserver* aBrCtlLayoutObserver = NULL,
       
    44     MBrCtlDialogsProvider* aBrCtlDialogsProvider = NULL,
       
    45     MBrCtlWindowObserver* aBrCtlWindowObserver = NULL,
       
    46 	MBrCtlDownloadObserver* aBrCtlDownloadObserver = NULL );
       
    47 
       
    48 // A container which draw white rectagle.
       
    49 NONSHARABLE_CLASS( CBlankContainer ): public CCoeControl
       
    50     {
       
    51 public:
       
    52     CBlankContainer();
       
    53     ~CBlankContainer();
       
    54     
       
    55     /** 
       
    56     *  From CoeControl class
       
    57     *  @function Draw
       
    58     *  Draw() for drawing the Background
       
    59     */
       
    60     void Draw( const TRect& aRect ) const;
       
    61     
       
    62     };
       
    63 
       
    64 /** 
       
    65 * @class CCSXHHtmlTopicContainer
       
    66 * This class provides Browser functionality
       
    67 */
       
    68 
       
    69 class CCSXHHtmlTopicContainer : public CCoeControl, public MBrCtlLinkResolver, 
       
    70 								public MBrCtlLinkContent, public MBrCtlLoadEventObserver,
       
    71 								public MBrCtlSoftkeysObserver,public MBrCtlLayoutObserver
       
    72     {
       
    73 public:
       
    74 
       
    75 /** 
       
    76 *  @function NewL
       
    77 *  @since S60 3.2
       
    78 *  Construct a CCSXHHtmlTopicContainer 
       
    79 *  and return a pointer to the created object
       
    80 *  @param aRect - TRect Object
       
    81 *		  aDocument - Document Object 
       
    82 *		  aView		- HtmlTopicView Pointer
       
    83 *  @return a CCSXHHtmlTopicContainer Pointer 
       
    84 */
       
    85     static CCSXHHtmlTopicContainer* NewL(const TRect& aRect,CCSXHDocument 
       
    86     &aDocument,CCSXHHtmlTopicView *aView);
       
    87 
       
    88 /** 
       
    89 *  @function NewLC
       
    90 *  @since S60 3.2
       
    91 *  Construct a CCSXHHtmlTopicContainer 
       
    92 *  and return a pointer to the created object using two phase constuction
       
    93 *  @param aRect - TRect Object
       
    94 *		  aDocument - Document Object 
       
    95 *		  aView		- HtmlTopicView Pointer
       
    96 *  @return a CCSXHHtmlTopicContainer Pointer 
       
    97 */
       
    98     static CCSXHHtmlTopicContainer* NewLC(const TRect& aRect,CCSXHDocument
       
    99      &aDocument,CCSXHHtmlTopicView *aView);
       
   100 
       
   101 /** 
       
   102 *  @function CCSXHHtmlTopicContainer
       
   103 *  @since S60 3.2
       
   104 *  Construct a CCSXHHtmlTopicContainer 
       
   105 *  and return a pointer to the created object using two phase constuction
       
   106 *  @param aRect - TRect Object
       
   107 *		  aDocument - Document Object 
       
   108 *		  aView		- HtmlTopicView Pointer
       
   109 *  @return a CCSXHHtmlTopicContainer Pointer 
       
   110 */
       
   111 	CCSXHHtmlTopicContainer(CCSXHDocument &aDocument, CCSXHHtmlTopicView *aView);
       
   112 /** 
       
   113  * @function ~CCSXHHtmlTopicContainer
       
   114  * @since S60 3.2
       
   115  * Destroy the object and release all memory objects
       
   116  */
       
   117   ~CCSXHHtmlTopicContainer();
       
   118   
       
   119 /** 
       
   120  * @function SetAndLoadInitialTopicL
       
   121  * @since S60 3.2
       
   122  * Destroy the object and release all memory objects
       
   123  * @param aTopic - Initial Topic to be displayed 
       
   124  */  
       
   125  void SetAndLoadInitialTopicL(CCSXHHtmlTOC2* aTopic);
       
   126      
       
   127 public:  
       
   128 /**
       
   129 * From MBrCtlSoftkeysObserver class
       
   130 *  Browser plug-in calls this method requests to update a softkey 
       
   131 *  @function UpdateSoftkeyL    
       
   132 *  @since S60 3.2
       
   133 *  @Param aKeySoftkey	- Update the left softkey or the right softkey  
       
   134 *		 aLabel			- The label associated with the softkey update  
       
   135 *		 aCommandId		- The command to use if the softkey is selected by the user  
       
   136 *		 aBrCtlSoftkeyChangeReason - The reason for the softkey change  
       
   137 */
       
   138 void UpdateSoftkeyL(TBrCtlKeySoftkey aKeySoftkey,
       
   139                                     const TDesC& aLabel,
       
   140                                     TUint32 aCommandId,
       
   141                                     TBrCtlSoftkeyChangeReason aBrCtlSoftkeyChangeReason);
       
   142 
       
   143 /**
       
   144 * From MBrCtlLayoutObserver Class
       
   145 *  Browser plug-in calls this method to Update the position of vertical scrollbar
       
   146 *  @function UpdateBrowserVScrollBarL
       
   147 *  @since S60 3.2    
       
   148 *  @Param  aDocumentHeight - The total height of the markup page  
       
   149 * 		   aDisplayHeight  - The height of the display  
       
   150 * 		   aDisplayPosY    - The current Y position  
       
   151 */                                    
       
   152  void UpdateBrowserVScrollBarL(TInt aDocumentHeight, 
       
   153                                               TInt aDisplayHeight,
       
   154                                               TInt aDisplayPosY ) ;
       
   155                                               
       
   156 /**
       
   157 * From MBrCtlLayoutObserver Class
       
   158 *  Browser plug-in calls this method to Update the position of horizontal scrollbar
       
   159 *  @function UpdateBrowserHScrollBarL
       
   160 *  @since S60 3.2    
       
   161 *  @Param  aDocumentWidth - The total width of the markup page  
       
   162 * 		   aDisplayWidth  - The width of the display  
       
   163 * 		   aDisplayPosX    - The current X position  
       
   164 */                                              
       
   165 void UpdateBrowserHScrollBarL(TInt aDocumentWidth, 
       
   166                                               TInt aDisplayWidth,
       
   167                                               TInt aDisplayPosX );
       
   168                                               
       
   169 /**
       
   170 * From MBrCtlLayoutObserver Class
       
   171 *  Browser plug-in calls this method to Inform the layout of the page: right to left or left to right
       
   172 *  @function NotifyLayoutChange    
       
   173 *  @since S60 3.2
       
   174 *  @Param  aNewLayout - RTL or LTR 
       
   175 */                                              
       
   176 void NotifyLayoutChange( TBrCtlLayout aNewLayout );
       
   177   
       
   178 /**
       
   179 * From MBrCtlLayoutObserver Class
       
   180 *  Browser plug-in calls this method to Inform the layout of the page: right to left or left to right
       
   181 *  @function UpdateTitleL
       
   182 *  @since S60 3.2    
       
   183 *  @Param  aTitle - Title of the page 
       
   184 */        
       
   185 void UpdateTitleL( const TDesC& aTitle );                                   
       
   186 
       
   187 public:  // from CCoeControl
       
   188 /** 
       
   189 *  From CoeControl class
       
   190 *  @function SizeChanged
       
   191 *  @since S60 3.2
       
   192 *  re-allocates and re-sizes components.
       
   193 */
       
   194 	void SizeChanged();
       
   195 /** 
       
   196 *  From CoeControl class
       
   197 *  @function CountComponentControls
       
   198 *  @since S60 3.2
       
   199 *  @return Number of child controls this has.  
       
   200 */	
       
   201 	TInt CountComponentControls() const;
       
   202 
       
   203 /** 
       
   204 *  From CoeControl class
       
   205 *  @function ComponentControl
       
   206 *  @since S60 3.2
       
   207 * @param aIndex index of child controls
       
   208 * @retrun pointer to child control
       
   209 */	
       
   210 	CCoeControl* ComponentControl(TInt aIndex) const;
       
   211 /** 
       
   212 *  From CoeControl class
       
   213 *  @function OfferKeyEventL
       
   214 *  @since S60 3.2
       
   215 *  Progress Key Event
       
   216 *  @param aKeyEvent the key event
       
   217 *  @param aType EEventKey | EEventKeyUp | EEventKeyDown
       
   218 *  @return EKeyWasConsumed if key event is processed,
       
   219 *         otherwise EKeyWasNotConsumed
       
   220 */
       
   221 	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
       
   222 
       
   223 /** 
       
   224 *  From MBrCtlLoadEventObserver class
       
   225 *  @function HandleBrowserLoadEventL
       
   226 *  @since S60 3.2
       
   227 *  A load events notification
       
   228 *  @param aLoadEvent - The load event  
       
   229 *  		  aSize  	 - Size depends on the event  
       
   230 *  		  aTransactionId  - The transaction id of the transaction that had this event  
       
   231 */	
       
   232 	void HandleBrowserLoadEventL(TBrCtlDefs::TBrCtlLoadEvent aLoadEvent, 
       
   233 								TUint aSize, TUint16 aTransactionId);
       
   234 
       
   235 /** 
       
   236 *  @function RefreshL
       
   237 *  @since S60 3.2
       
   238 *  Used to Refresh the Content
       
   239 *  @param aTopic - CCSXHHtmlTOC2 Object  
       
   240 */	
       
   241 	void RefreshL(CCSXHHtmlTOC2 *aTopic);
       
   242 	
       
   243 /** 
       
   244 *  @function HandleBackKeyL
       
   245 *  Handle Back Key
       
   246 *  @since S60 3.2
       
   247 *  @return ETrue, if the key is handled in the container, EFalse otherwise 
       
   248 */ 
       
   249 	TBool HandleBackKeyL();
       
   250 
       
   251 /** 
       
   252 *  @function IsPrevHtmlPageAvblL
       
   253 *  Check for Existance of the page in the Browser history stack
       
   254 *  @since S60 3.2
       
   255 *  @return ETrue, if page is available in Browser History Stack, EFalse otherwise 
       
   256 */ 
       
   257 	TBool IsPrevHtmlPageAvblL();
       
   258 
       
   259 /** 
       
   260 *  @function SetSelectedFontSizeL
       
   261 *  Sets BrowserFontsize
       
   262 *  @since S60 3.2
       
   263 *  @param aValue - Fontsize Value
       
   264 */	
       
   265 	void SetSelectedFontSizeL(TInt aValue);
       
   266 	
       
   267 /** 
       
   268 *  @function SetSelectedFontSizeL
       
   269 *  Get Current Settings Value
       
   270 *  @since S60 3.2
       
   271 *  @param aValue - Any Setting 
       
   272 *  @return Current Value used by Browser
       
   273 */	
       
   274 	TInt GetCurrentValueL(TInt aSetting);
       
   275 
       
   276 /** 
       
   277 *  @function HandleCommandBackL
       
   278 *  @since S60 3.2
       
   279 *  Handles resource changes.
       
   280 *  pass OpenLink command to the browser HandlecommandL 
       
   281 */
       
   282 	void HandleCommandOpenHyperLinkL();
       
   283 
       
   284 /** 
       
   285 *  From CoeControl class
       
   286 *  @function Draw
       
   287 *  @since S60 3.2
       
   288 *  Draw() for drawing the Background
       
   289 */
       
   290     void Draw(const TRect& aRect) const;
       
   291   
       
   292   	void ShowIndexHtmlPageL() const;
       
   293 /** 
       
   294 *  @function HandleResourceChange
       
   295 *  @since S60 3.2
       
   296 *  Handles resource changes.
       
   297 *  This function is called by framework when when e.g skin or locale is changed.
       
   298 *  @param aType resource change type
       
   299 */    	
       
   300    	void HandleResourceChange(TInt aType);
       
   301 
       
   302 /** 
       
   303 *  @function HandleResourceChangeImpl
       
   304 *  @since S60 3.2
       
   305 *  Handles resource changes.
       
   306 *  Implementation function for resource change
       
   307 *  @param aType resource change type
       
   308 */    	
       
   309     	void HandleResourceChangeImpl(TInt aType);
       
   310 
       
   311 /** 
       
   312 *  @function HandleCommandBackL
       
   313 *  @since S60 3.2
       
   314 *  Handles resource changes.
       
   315 *  pass Back command to the browser HandlecommandL 
       
   316 */   	
       
   317 	void HandleCommandBackL();
       
   318 	
       
   319 /**
       
   320 * Browser plug-in calls this method when embedded link is found. Used with ECapabilityClientResolveEmbeddedURL
       
   321 * @since 3.2
       
   322 * @param aEmbeddedUrl The url of the embedded content
       
   323 * @param aCurrentUrl The url of the current page
       
   324 * @param aLoadContentType The expected type of the embedded content
       
   325 * @param aEmbeddedLinkContent a callback interface to return the embedded content
       
   326 * @return EFalse, browser will resolve the link
       
   327 */
       
   328     TBool ResolveEmbeddedLinkL(const TDesC& aEmbeddedUrl,
       
   329     		                               const TDesC& aCurrentUrl,
       
   330         	                               TBrCtlLoadContentType aLoadContentType, 
       
   331         	                               MBrCtlLinkContent& aEmbeddedLinkContent); 
       
   332 		
       
   333 /**
       
   334 * Browser plug-in calls this method when the user requests to load content via selecting a link, or any other way. Used with ECapabilityClientNotifyURL 
       
   335 * @since 3.2
       
   336 * @param aUrl The requested url
       
   337 * @param aCurrentUrl The url of the current page
       
   338 * @param aBrCtlLinkContent a callback interface to return the embedded content
       
   339 * @return EFalse, browser will resolve the link
       
   340 */
       
   341         TBool ResolveLinkL(const TDesC& aUrl, const TDesC& aCurrentUrl,
       
   342                                    MBrCtlLinkContent& aBrCtlLinkContent);
       
   343 
       
   344 /**
       
   345 * @function CancelFetchL
       
   346 * Cancel all outstanding resolving operations
       
   347 */
       
   348         void CancelFetchL();
       
   349 /**
       
   350 * @function CancelAll
       
   351 * Cancel all outstanding resolving operations
       
   352 * @since 3.2
       
   353 */
       
   354         void CancelAll();
       
   355         
       
   356         
       
   357 /**
       
   358 * @function HandleResolveComplete
       
   359 * @since 3.2	
       
   360 * Resolver calls this method when content is resolved.
       
   361 * @param aContentType The content type of the response
       
   362 * @param aCharset The charset of the response. May be empty in case of image
       
   363 * @param aContentBuf content data. Ownership is not transfered
       
   364 * @return void
       
   365 */
       
   366         void HandleResolveComplete(const TDesC& aContentType,
       
   367                                            const TDesC& aCharset,
       
   368                                            const HBufC8* aContentBuf);
       
   369 
       
   370 /**
       
   371 * @function HandleResolveError
       
   372 * @since 3.2
       
   373 * This method is called if there is some error while resolving the content
       
   374 * @param aError system wide error code.
       
   375 */
       
   376         void HandleResolveError(TInt aError);
       
   377 /** 
       
   378 *  @function CheckForMSK
       
   379 *  @since S60 3.2
       
   380 *  Checks Msk flag is Enabled or not, If Enabled, Sets MSK Label
       
   381 */      
       
   382 		void CheckForMSK();
       
   383 /** 
       
   384 *  @function IsPrevPageAvbl
       
   385 *  Check wether focus is on Hyperlink or not
       
   386 *  @since S60 3.2
       
   387 *  @return ETrue, if Focus is on Hyperlink , EFalse otherwise 
       
   388 */		
       
   389 		TBool IsHyperLinkFocused();	
       
   390 /** 
       
   391 *  @function IsPrevPageAvbl
       
   392 *  Check for Existance of the page
       
   393 *  @since S60 3.2
       
   394 *  @return ETrue, if page is available , EFalse otherwise 
       
   395 */		
       
   396 	 	TBool IsPrevPageAvbl();
       
   397 	 	
       
   398 /** 
       
   399 *  @function ClearHistoryL
       
   400 *  Clear Browser history stack
       
   401 *  @since S60 3.2
       
   402 */	 	
       
   403  		void  ClearHistoryL(); 
       
   404  		
       
   405 /** 
       
   406 *  @function GetCurrActiveObject
       
   407 *  Get the Current Active Object 
       
   408 *  @since S60 3.2
       
   409 *  @return CCSXHHelpContentBase Pointer, 
       
   410 */ 		
       
   411  		CCSXHHelpContentBase* GetCurrActiveObject();
       
   412 
       
   413 private:
       
   414  		
       
   415 /**
       
   416 * The state type of browser content.
       
   417 * @see SetContentLoadState() and NeedRefresh.
       
   418 */
       
   419     enum TContentLoadState
       
   420         {
       
   421         ENoContent,
       
   422         EContentLoading,
       
   423         EContentLoadFinished
       
   424         };
       
   425 
       
   426 /**
       
   427 *  @function ConstructL
       
   428 *  @since S60 3.2
       
   429 *  @Perform the second phase construction of a HtmlTopicContainer object
       
   430 *  @param aRect the rectangle this view will be drawn to
       
   431  */
       
   432     void ConstructL( const TRect& aRect );
       
   433 
       
   434 /** 
       
   435 *  @function LoadHtmlL
       
   436 *  loads HTML page in the Browser
       
   437 *  @since S60 3.2
       
   438 */
       
   439 	void LoadHtmlL();
       
   440 
       
   441 /** 
       
   442 *  @function CheckForExternalLinkL
       
   443 *  Check for external Hyperlink, if yes launch browserNG
       
   444 *  @since S60 3.2
       
   445 *  @return ETrue, if external hyperlink available, EFalse otherwise 
       
   446 */	
       
   447 	TBool CheckForExternalLinkL(const TDesC& aUrl);
       
   448 	
       
   449 /**
       
   450 * @function SetContentLoadingState
       
   451 * Set the state of content loading and refresh the UI id needed
       
   452 */
       
   453     void SetContentLoadState( const TContentLoadState aLoadState );
       
   454         
       
   455 /**
       
   456 * @function NeedRefresh
       
   457 * Judge whether we need to refresh the browser control
       
   458 */
       
   459     TBool NeedRefresh( const TContentLoadState aNewLoadState ) const;
       
   460     
       
   461 /**
       
   462  * @function HideBrowser
       
   463  */    
       
   464     void HideBrowser();
       
   465     
       
   466 /**
       
   467  * * @function ShowBrowser
       
   468  */
       
   469     void ShowBrowser();
       
   470     
       
   471 /*
       
   472  *  @function SetTopAndBottomContainer
       
   473  *  To set top and Bottom container of browser and blank container
       
   474  */
       
   475     void SetTopAndBottomContainer( CCoeControl* aTopControl, 
       
   476             CCoeControl* aBottomControl );
       
   477 
       
   478 private:
       
   479 	CBrCtlInterface* iBrCtrl;    
       
   480 	CCSXHHtmlTOC2* iTopic;
       
   481 	CCSXHDocument& iDocument;
       
   482     CCSXHHelpContentBase *iNewTopic;
       
   483     
       
   484     //Check the impln comments in HandleBrowserLoadEventL function
       
   485     TBuf<KMaxFileName> iUrlNoAnchors; 
       
   486     
       
   487     CCSXHHtmlTopicView* iView;    
       
   488     AppLauncherForCSXH* iAppLauncher;
       
   489     RLibrary iBrLibrary;
       
   490     RFeatureControl iFeatureControl;
       
   491     TBool iLoadHtml;    
       
   492     TInt32 iPrevPageCount;
       
   493     TBool iBack;
       
   494     
       
   495     TContentLoadState iContentLoading;
       
   496     
       
   497     // used to hide browser control if needed.
       
   498     CCoeControl*    iBlankContainer;
       
   499     
       
   500     // Used to determine whether hide browser control or not.
       
   501     CCoeControl*    iTopControl;
       
   502     CCoeControl*    iBottomControl;
       
   503     
       
   504 	};
       
   505 
       
   506 
       
   507 #endif