csxhelp/src/CSXHHtmlTopicContainer.cpp
branchRCL_3
changeset 40 0d1adf67ec1b
parent 32 b69cc3efe785
equal deleted inserted replaced
32:b69cc3efe785 40:0d1adf67ec1b
    46 #include <bautils.h>
    46 #include <bautils.h>
    47 
    47 
    48 _LIT(KContentType,"text/html");
    48 _LIT(KContentType,"text/html");
    49 _LIT(KCsstextToRemovePathinfo,"<style>\n #APP_LAUNCH_LINK{display:none}\n</style>");
    49 _LIT(KCsstextToRemovePathinfo,"<style>\n #APP_LAUNCH_LINK{display:none}\n</style>");
    50 
    50 
       
    51 
       
    52 CBlankContainer::CBlankContainer()
       
    53     {
       
    54     }
       
    55 
       
    56 CBlankContainer::~CBlankContainer()
       
    57     {
       
    58     }
       
    59     
       
    60 
       
    61 void CBlankContainer::Draw( const TRect& aRect ) const
       
    62     {
       
    63     CWindowGc& gc = SystemGc();
       
    64     TRect rect = Rect();
       
    65     gc.Clear(rect);    
       
    66     }
       
    67 
       
    68 
    51 // Standard construction sequence
    69 // Standard construction sequence
    52 CCSXHHtmlTopicContainer* CCSXHHtmlTopicContainer::NewL(const TRect& aRect,CCSXHDocument 
    70 CCSXHHtmlTopicContainer* CCSXHHtmlTopicContainer::NewL(const TRect& aRect,CCSXHDocument 
    53 &aDocument,CCSXHHtmlTopicView *aView)
    71 &aDocument,CCSXHHtmlTopicView *aView)
    54     {
    72     {
    55     CCSXHHtmlTopicContainer* self = CCSXHHtmlTopicContainer::NewLC(aRect,aDocument,aView);
    73     CCSXHHtmlTopicContainer* self = CCSXHHtmlTopicContainer::NewLC(aRect,aDocument,aView);
    82         iBrCtrl->SetFocus(EFalse);
   100         iBrCtrl->SetFocus(EFalse);
    83         iBrCtrl->RemoveLoadEventObserver(this);
   101         iBrCtrl->RemoveLoadEventObserver(this);
    84         delete iBrCtrl;
   102         delete iBrCtrl;
    85         iBrLibrary.Close();
   103         iBrLibrary.Close();
    86         }
   104         }
    87     if(iAppLauncher)
   105 
    88     	{
   106     delete iAppLauncher;
    89     	delete iAppLauncher;
   107   
    90     	}     
   108     delete iBlankContainer;
    91     }
   109 
    92 
   110     }
    93 void CCSXHHtmlTopicContainer::ConstructL(const TRect& aRect)
   111 
       
   112 void CCSXHHtmlTopicContainer::ConstructL( const TRect& aRect )
    94     {
   113     {
    95     // Create a window for this application view
   114     // Create a window for this application view
    96     CreateWindowL();
   115     CreateWindowL();
    97 
   116 
    98     // Set the windows size
   117     // Set the windows size
    99     SetRect(aRect);
   118     SetRect(aRect);
   100     if(KErrNone != iBrLibrary.Load(_L("BrowserEngine.dll")))
   119     if( KErrNone != iBrLibrary.Load( _L( "BrowserEngine.dll" ) ) )
   101     	{
   120     	{
   102        	HBufC* ErrorMessage = CCSXHAppUi::GetCoeEnv()->AllocReadResourceLC(
   121        	HBufC* ErrorMessage = CCSXHAppUi::GetCoeEnv()->AllocReadResourceLC(
   103     				R_CSHELP_RETRIEVE_NO_MEMORY_TEXT);      
   122     				R_CSHELP_RETRIEVE_NO_MEMORY_TEXT );      
   104     	CAknGlobalNote* note = CAknGlobalNote::NewLC();
   123     	CAknGlobalNote* note = CAknGlobalNote::NewLC();
   105     	note->ShowNoteL(EAknGlobalInformationNote, *ErrorMessage);
   124     	note->ShowNoteL( EAknGlobalInformationNote, *ErrorMessage );
   106     	CleanupStack::PopAndDestroy(note); 
   125     	CleanupStack::PopAndDestroy( note ); 
   107     	CleanupStack::PopAndDestroy(ErrorMessage); 
   126     	CleanupStack::PopAndDestroy( ErrorMessage ); 
   108     	iDocument.SetDisplayTopic(iDocument.GetPrevTopic());
   127     	iDocument.SetDisplayTopic( iDocument.GetPrevTopic() );
   109 		CCSXHAppUi::GetInstance()->HandleCommandL(ECSXHOpenItem);
   128 		CCSXHAppUi::GetInstance()->HandleCommandL( ECSXHOpenItem );
   110 		User::Leave(KErrNoMemory);
   129 		User::Leave( KErrNoMemory );
   111     	}     
   130     	}     
   112 
   131 
   113 #ifdef __WINS__    
   132 #ifdef __WINS__    
   114     TLibraryFunction result = iBrLibrary.Lookup(10); 
   133     TLibraryFunction result = iBrLibrary.Lookup( 10 ); 
   115 #else
   134 #else
   116     TLibraryFunction result = iBrLibrary.Lookup(1);   
   135     TLibraryFunction result = iBrLibrary.Lookup( 1 );   
   117 #endif    
   136 #endif    
   118 		
   137 		
   119 	FuncPtr_CreateBrowserControlL fptr  = (FuncPtr_CreateBrowserControlL)result;
   138 	FuncPtr_CreateBrowserControlL fptr  = ( FuncPtr_CreateBrowserControlL )result;
   120     
   139     
   121     iBrCtrl = (*fptr)(
   140     iBrCtrl = ( *fptr )(
   122                     this,aRect,
   141                     this,aRect,
   123                     TBrCtlDefs::ECapabilityDisplayScrollBar|
   142                     TBrCtlDefs::ECapabilityDisplayScrollBar|
   124                     TBrCtlDefs::ECapabilityClientResolveEmbeddedURL|
   143                     TBrCtlDefs::ECapabilityClientResolveEmbeddedURL|
   125 #ifndef __SERIES60_30__                                 
   144 #ifndef __SERIES60_30__                                 
   126                     TBrCtlDefs::ECapabilityCursorNavigation|
   145                     TBrCtlDefs::ECapabilityCursorNavigation|
   127                     TBrCtlDefs::ECapabilityWebKitLite|
   146                     TBrCtlDefs::ECapabilityWebKitLite|
   128 #endif                                  
   147 #endif                                  
   129                     TBrCtlDefs::ECapabilityClientNotifyURL,
   148                     TBrCtlDefs::ECapabilityClientNotifyURL,
   130                     TBrCtlDefs::ECommandIdBase,this,this,NULL,this
   149                     TBrCtlDefs::ECommandIdBase, this, this, NULL, this
   131                     );
   150                     );
   132     iBrCtrl->SetBrowserSettingL(TBrCtlDefs::ESettingsCSSFetchEnabled,1);    
   151     iBrCtrl->SetBrowserSettingL( TBrCtlDefs::ESettingsCSSFetchEnabled, 1 );    
   133     iBrCtrl->AddLoadEventObserverL(this);   
   152     iBrCtrl->AddLoadEventObserverL( this );   
   134     
   153     
   135     
   154     
   136     SetSelectedFontSizeL(iView->GetCurrentFontSize());
   155     SetSelectedFontSizeL( iView->GetCurrentFontSize() );
   137     iBrCtrl->MakeVisible(ETrue);
   156     iBrCtrl->MakeVisible( ETrue );
       
   157     
       
   158     iBlankContainer = new ( ELeave ) CBlankContainer();
       
   159     iBlankContainer->SetRect( Rect() );
       
   160     
       
   161     ShowBrowser();
   138     
   162     
   139     ActivateL();
   163     ActivateL();
   140     }
   164     }
   141 
   165 
   142 void CCSXHHtmlTopicContainer::Draw(const TRect& /*aRect*/) const
   166 void CCSXHHtmlTopicContainer::Draw(const TRect& /*aRect*/) const
   164  
   188  
   165 	}
   189 	}
   166 
   190 
   167 void CCSXHHtmlTopicContainer::LoadHtmlL()
   191 void CCSXHHtmlTopicContainer::LoadHtmlL()
   168     {
   192     {
   169     iBrCtrl->MakeVisible( EFalse );
   193     iBrCtrl->MakeVisible( EFalse ); 
   170     SetContentLoadState( EContentLoading );
   194     SetContentLoadState( EContentLoading );
   171     HBufC8 *htmlBuffer = STATIC_CAST(HBufC8*,iTopic->GetTopicContentL());
   195     HBufC8 *htmlBuffer = STATIC_CAST(HBufC8*,iTopic->GetTopicContentL());
   172     if(htmlBuffer)
   196     if(htmlBuffer)
   173         {
   197         {
   174         CleanupStack::PushL(htmlBuffer);
   198         CleanupStack::PushL(htmlBuffer);
   228     return result;  
   252     return result;  
   229     }
   253     }
   230 
   254 
   231 TInt CCSXHHtmlTopicContainer::CountComponentControls() const
   255 TInt CCSXHHtmlTopicContainer::CountComponentControls() const
   232     {
   256     {
   233     return 1; 
   257     return 2; 
   234     }
   258     }
   235 
   259 
   236 CCoeControl* CCSXHHtmlTopicContainer::ComponentControl(TInt aIndex) const
   260 CCoeControl* CCSXHHtmlTopicContainer::ComponentControl(TInt aIndex) const
   237     {
   261     {
   238     switch (aIndex)
   262     switch (aIndex)
   239         {
   263         {
   240         case 0:
   264         case 0:
   241             return iBrCtrl;
   265             return iBottomControl;
       
   266         case 1:
       
   267             return iTopControl;
   242         default:
   268         default:
   243             return NULL;
   269             return NULL;
   244         }
   270         }
   245     }
   271     }
   246     
   272     
   272     }
   298     }
   273 
   299 
   274 void CCSXHHtmlTopicContainer::SizeChanged()
   300 void CCSXHHtmlTopicContainer::SizeChanged()
   275     {
   301     {
   276 #ifndef __SERIES60_30__ 
   302 #ifndef __SERIES60_30__ 
   277     if(iBrCtrl)
   303     if( iBrCtrl )
   278         {
   304         {
   279         if ( iContentLoading != EContentLoading )
   305         if ( iContentLoading != EContentLoading )
   280             {
   306             {
   281             iBrCtrl->SetRect(Rect());
   307             iBlankContainer->SetRect( Rect() );
   282             iBrCtrl->MakeVisible(ETrue);
   308             iBrCtrl->SetRect( Rect() );
       
   309             iBrCtrl->MakeVisible( ETrue );
   283             }
   310             }
   284         else
   311         else
   285             {
   312             {
   286             //Update the title bar
   313             //Update the title bar
   287             CEikStatusPane* sp = CCSXHAppUi::GetInstance()->StatusPane();
   314             CEikStatusPane* sp = CCSXHAppUi::GetInstance()->StatusPane();
   288             CAknTitlePane* titlePane = NULL;
   315             CAknTitlePane* titlePane = NULL;
   289             TRAPD( err, titlePane = STATIC_CAST(CAknTitlePane*, 
   316             TRAPD( err, titlePane = STATIC_CAST(CAknTitlePane*,
   290                     sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ) );
   317                     sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ) );
   291             if ( KErrNone == err )
   318             if ( KErrNone == err )
   292                 {
   319                 {
   293                 //If can't set Null text to title, no other good way to do further, 
   320                 //If can't set Null text to title, no other good way to do further, 
   294                 //so just ignore this leave
   321                 //so just ignore this leave
   295                 TRAP_IGNORE( titlePane->SetTextL( KNullDesC ) );
   322                 TRAP_IGNORE( titlePane->SetTextL( KNullDesC ) );
   296                 }
   323                 }
   297             
   324             iBlankContainer->SetRect( Rect() );
   298             iBrCtrl->SetRect(TRect(0,0,0,0));
   325             iBrCtrl->SetRect( Rect() );            
   299             }
   326             }
   300         }
   327         }
   301 #endif  
   328 #endif  
   302     }
   329     }
   303 
   330 
   443 void CCSXHHtmlTopicContainer::HandleBrowserLoadEventL(TBrCtlDefs::TBrCtlLoadEvent aLoadEvent, 
   470 void CCSXHHtmlTopicContainer::HandleBrowserLoadEventL(TBrCtlDefs::TBrCtlLoadEvent aLoadEvent, 
   444                                     TUint /*aSize*/, TUint16 /*aTransactionId*/)
   471                                     TUint /*aSize*/, TUint16 /*aTransactionId*/)
   445     {
   472     {
   446     if(aLoadEvent == TBrCtlDefs::EEventLoadFinished)
   473     if(aLoadEvent == TBrCtlDefs::EEventLoadFinished)
   447         {
   474         {
       
   475         ShowBrowser();
   448         SetContentLoadState( EContentLoadFinished );
   476         SetContentLoadState( EContentLoadFinished );
   449         if ( IsVisible() )
   477         if ( IsVisible() )
   450              {
   478              {
   451                HBufC* title = iBrCtrl->PageInfoLC(TBrCtlDefs::EPageInfoTitle);
   479                HBufC* title = iBrCtrl->PageInfoLC(TBrCtlDefs::EPageInfoTitle);
   452                if(!title)
   480                if(!title)
   503         	}
   531         	}
   504             
   532             
   505         iNewTopic = iDocument.GetHtmlTopicForUrlL(iUrlNoAnchors);            
   533         iNewTopic = iDocument.GetHtmlTopicForUrlL(iUrlNoAnchors);            
   506         CheckForMSK();
   534         CheckForMSK();
   507         }
   535         }
       
   536     // Only when loadhtml is called, in that condition, last-displayed content may show;
       
   537     // then we should hide browser.
       
   538     else  if ( iContentLoading == EContentLoading )
       
   539         {
       
   540         HideBrowser();
       
   541         }
   508     }
   542     }
   509     
   543     
   510 CCSXHHelpContentBase* CCSXHHtmlTopicContainer::GetCurrActiveObject()
   544 CCSXHHelpContentBase* CCSXHHtmlTopicContainer::GetCurrActiveObject()
   511     	{
   545     	{
   512     	return iNewTopic;
   546     	return iNewTopic;
   646         return ETrue;
   680         return ETrue;
   647     else
   681     else
   648         return EFalse;
   682         return EFalse;
   649     }
   683     }
   650 
   684 
       
   685 void CCSXHHtmlTopicContainer::HideBrowser()
       
   686     {
       
   687     SetTopAndBottomContainer( iBlankContainer, iBrCtrl );
       
   688     }
       
   689 
       
   690 void CCSXHHtmlTopicContainer::ShowBrowser()
       
   691     {
       
   692     SetTopAndBottomContainer( iBrCtrl, iBlankContainer );
       
   693     }
       
   694 
       
   695 void CCSXHHtmlTopicContainer::SetTopAndBottomContainer( CCoeControl* aTopControl, 
       
   696         CCoeControl* aBottomControl )
       
   697     {
       
   698     iTopControl = aTopControl;
       
   699     iBottomControl = aBottomControl;
       
   700     }
       
   701     
   651 //end of the file
   702 //end of the file
   652 
   703