csxhelp/src/CSXHHtmlTopicView.cpp
changeset 0 1f04cf54edd8
child 5 d06b1526f62c
equal deleted inserted replaced
-1:000000000000 0:1f04cf54edd8
       
     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:  CCSXHHtmlTopicView class definition
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDES
       
    19 #include "CSXHHtmlTopicView.h"
       
    20 #include "CSXHHtmlTopicContainer.h"
       
    21 #include "CSXHHtmlTOC2.h"
       
    22 #include "CSXHAppUi.h"
       
    23 #include "CSXHDocument.h"
       
    24 #include <cshelp.rsg>
       
    25 #include "CsHelp.hrh"
       
    26 
       
    27 #include "CSXHViewIDs.h"
       
    28 #include "CSXHKywdTOC1.h"
       
    29 #include "CSXHHelpDataBase.h"
       
    30 #include "CSXHContextTopic.h"
       
    31 #include "CSXHHtmlTOC2.h"
       
    32 #include "CSXHHtmlTOC1.h" 
       
    33 
       
    34 #include <avkon.hrh>
       
    35 #include <aknnotewrappers.h> 
       
    36 #include <BrCtlDefs.h>
       
    37 #include <f32file.h>
       
    38 #include <apgcli.h>
       
    39 #include <akntitle.h>
       
    40 
       
    41 #include <AiwMenu.h>
       
    42 #include <AiwCommon.h>
       
    43 #include <AiwServiceHandler.h>
       
    44 #include <AknGlobalNote.h>
       
    45 TInt CCSXHHtmlTopicView::iFontSize = TBrCtlDefs::EFontSizeLevelNormal;
       
    46 
       
    47 CCSXHHtmlTopicView* CCSXHHtmlTopicView::NewL(const TUid& aUid, const TInt& aFlags,const 
       
    48 TRect& aRect)
       
    49     {
       
    50     CCSXHHtmlTopicView* temp = new(ELeave) CCSXHHtmlTopicView(aUid,aFlags);
       
    51     CleanupStack::PushL(temp);
       
    52     temp->ConstructL(aRect);
       
    53     CleanupStack::Pop(temp);
       
    54     return temp;
       
    55     }
       
    56 
       
    57 CCSXHHtmlTopicView::CCSXHHtmlTopicView(const TUid& aUid, const TInt& aFlags):
       
    58                         iUid(aUid),iAppFlags(aFlags)
       
    59     {   
       
    60     }
       
    61 CCSXHHtmlTopicView::~CCSXHHtmlTopicView()
       
    62     {
       
    63     if(iBCContainer)
       
    64         {
       
    65         delete iBCContainer;
       
    66         iBCContainer = NULL;
       
    67         }
       
    68     }
       
    69     
       
    70 void CCSXHHtmlTopicView::ConstructL(const TRect& /*aRect*/)
       
    71     {
       
    72     BaseConstructL(iAppFlags);
       
    73     }
       
    74 
       
    75 void CCSXHHtmlTopicView::SetViewTypeL(TInt type)
       
    76 	{
       
    77 	if(type == iContextTopicView)
       
    78 		return;
       
    79 	
       
    80 	if(type == EContextHtmlView)
       
    81 		{
       
    82 		iContextTopicView = ETrue;
       
    83 		SetSoftKeysL(R_CSHELP_SOFTKEYS_OPTIONS_CLOSE_OPENLINK);
       
    84 		}
       
    85 	else
       
    86 		{
       
    87 		iContextTopicView = EFalse;
       
    88 		SetSoftKeysL(R_CSHELP_SOFTKEYS_OPTIONS_BACK_OPENLINK);
       
    89 		}	
       
    90 	}
       
    91 	
       
    92 TInt CCSXHHtmlTopicView::GetViewType()	
       
    93 	{
       
    94 	return iContextTopicView ? EContextHtmlView : EHtmlView;
       
    95 	}
       
    96     
       
    97 TUid CCSXHHtmlTopicView::Id() const 
       
    98     {
       
    99     return iUid;
       
   100     }
       
   101 // --------------------------------------------------------------------------
       
   102 // Launches an application based on the Application UID and a View ID
       
   103 // --------------------------------------------------------------------------    
       
   104 void CCSXHHtmlTopicView::HandleCommandL(TInt  aCommand  )
       
   105     {
       
   106     switch(aCommand)
       
   107         {
       
   108         case EAknSoftkeyBack:
       
   109             {
       
   110             if(iBCContainer->HandleBackKeyL())
       
   111                 return;
       
   112             CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document());              
       
   113             //if not the current view, return
       
   114             TUid viewId = doc->GetDisplayTopic()->GetViewID();
       
   115             if( viewId != KCSXHHtmlTopicViewID && viewId != KCSXHKywdToc2ViewID )
       
   116                 {
       
   117                 return;
       
   118                 }          
       
   119             CCSXHHtmlTOC2 *displayTopic = STATIC_CAST(CCSXHHtmlTOC2*,doc->GetDisplayTopic());
       
   120             CCSXHKywdTOC1* kywdParent = displayTopic->GetKywdParent();
       
   121             if(kywdParent)
       
   122                 {
       
   123                 doc->SetDisplayAndPrevTopic(kywdParent);    
       
   124                 AppUi()->HandleCommandL(ECSXHOpenItem); 
       
   125                 }
       
   126             else
       
   127                 {
       
   128                 HandleCommandL(ECSXHOpenApplicationTopics); 
       
   129                 }   
       
   130             break;  
       
   131             }
       
   132         case ECSXHOpenApplicationTopics:       
       
   133             {
       
   134             CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document());   
       
   135             if(iBCContainer->GetCurrActiveObject())
       
   136             	{
       
   137             	doc->SetDisplayTopic(iBCContainer->GetCurrActiveObject());
       
   138             	CCSXHAppUi::GetInstance()->ResetTOC2ViewContainer();
       
   139             	}            	           
       
   140             CCSXHHtmlTOC2 *displayTopic = STATIC_CAST(CCSXHHtmlTOC2*,doc->GetDisplayTopic());
       
   141             doc->SetDisplayAndPrevTopic(displayTopic->GetParent()); 
       
   142             AppUi()->HandleCommandL(ECSXHOpenItem);
       
   143             }
       
   144             break;
       
   145         case ECSXHTOC1ListView:
       
   146             {
       
   147             CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document());      
       
   148             if(iBCContainer->GetCurrActiveObject())
       
   149             	{
       
   150             	doc->SetDisplayTopic(iBCContainer->GetCurrActiveObject());
       
   151             	CCSXHAppUi::GetInstance()->ResetTOC2ViewContainer();
       
   152             	}            	        
       
   153             	
       
   154             CCSXHHtmlTOC2 *displayTopic = STATIC_CAST(CCSXHHtmlTOC2*,doc->GetDisplayTopic());
       
   155             //These two steps are necessary to set the correct display and prev topics
       
   156             doc->SetDisplayTopic(displayTopic->GetParent());    
       
   157             doc->SetDisplayAndPrevTopic(doc->GetHelpDataBase()->GetMainTopics());   
       
   158             AppUi()->HandleCommandL(ECSXHOpenItem); 
       
   159             }
       
   160             break;
       
   161         case ECsHelpCmdFontLarge:
       
   162             {
       
   163             TInt CurrentFontSize = iBCContainer->GetCurrentValueL(TBrCtlDefs::ESettingsFontSize);
       
   164             iBCContainer->SetSelectedFontSizeL(++CurrentFontSize);
       
   165             iFontSize = CurrentFontSize;
       
   166             }
       
   167             break;
       
   168         case ECsHelpCmdFontSmall:
       
   169             {
       
   170             TInt CurrentFontSize = iBCContainer->GetCurrentValueL(TBrCtlDefs::ESettingsFontSize);
       
   171             iBCContainer->SetSelectedFontSizeL(--CurrentFontSize);
       
   172             iFontSize = CurrentFontSize;
       
   173             }
       
   174             break;
       
   175         case ECSXHOpenHyperLink: 
       
   176             {           
       
   177             iBCContainer->HandleCommandOpenHyperLinkL();
       
   178             }
       
   179             break;
       
   180 		case ECSXHSearchText:
       
   181 			{		
       
   182         	CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document()); 
       
   183         	if(iBCContainer->GetCurrActiveObject())
       
   184 	        	{
       
   185 	        	doc->SetDisplayTopic(iBCContainer->GetCurrActiveObject());
       
   186 	       		CCSXHAppUi::GetInstance()->ResetTOC2ViewContainer();
       
   187 	        	}            
       
   188         	}
       
   189 			AppUi()->HandleCommandL( aCommand );
       
   190 			break;
       
   191         case EAknSoftkeyExit:
       
   192         case EAknSoftkeyClose: 
       
   193             AppUi()->HandleCommandL( aCommand );
       
   194             break;
       
   195         default:
       
   196             break;      
       
   197         }     
       
   198     }
       
   199 // --------------------------------------------------------------------------
       
   200 // Handlign for view activation. For a context view, the actual display topic
       
   201 // has to be modified
       
   202 // --------------------------------------------------------------------------
       
   203 void CCSXHHtmlTopicView::DoActivateL(const TVwsViewId& aPrevViewId,TUid,const TDesC8&)  
       
   204     {
       
   205     iPrevious = aPrevViewId;    
       
   206     CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document());  
       
   207      
       
   208     if(!iBCContainer)
       
   209     	{
       
   210     	TRAPD(Result,iBCContainer = CCSXHHtmlTopicContainer::NewL(ClientRect(),*doc,this));
       
   211     	if(KErrNone != Result)
       
   212     		return;
       
   213     	}
       
   214     
       
   215     //Set the correct display topic here for context sensitive launch
       
   216     if(doc->GetDisplayTopic()->GetViewID() == KCSXHContextHtmlTopicViewID)
       
   217         {
       
   218         CCSXHContextTopic *topic = STATIC_CAST(CCSXHContextTopic*,doc->GetDisplayTopic());
       
   219         doc->SetDisplayTopic(topic->GetTopic());
       
   220         iContextTopicView = ETrue;
       
   221         }
       
   222     else
       
   223     	{
       
   224     	iContextTopicView = EFalse;
       
   225     	}    
       
   226 	
       
   227 	CCSXHHtmlTOC2 *displayTopic = STATIC_CAST(CCSXHHtmlTOC2*,doc->GetDisplayTopic());
       
   228     TRAPD(err,iBCContainer->SetAndLoadInitialTopicL(displayTopic));
       
   229 
       
   230    	if( KErrNone != err )    
       
   231    	    {
       
   232    	    delete iBCContainer;
       
   233    	    iBCContainer = NULL;
       
   234    	    return;
       
   235    	    }
       
   236    	if( iContextTopicView )
       
   237    	    {
       
   238    	    SetSoftKeysL(R_CSHELP_SOFTKEYS_OPTIONS_CLOSE_OPENLINK);
       
   239    	    }
       
   240    	else
       
   241    	    {
       
   242    	    SetSoftKeysL(R_CSHELP_SOFTKEYS_OPTIONS_BACK_OPENLINK);
       
   243    	    }
       
   244     iBCContainer->SetMopParent(this); 
       
   245     iBCContainer->SetRect(ClientRect());
       
   246     AppUi()->AddToStackL(*this, iBCContainer);    
       
   247     iBCContainer->MakeVisible(ETrue);     
       
   248     }
       
   249                              
       
   250 void CCSXHHtmlTopicView::DoDeactivate()                             
       
   251     {   
       
   252     if(iBCContainer)
       
   253         {
       
   254         TRAP_IGNORE(iBCContainer->CancelFetchL());
       
   255         iBCContainer->MakeVisible(EFalse);
       
   256         AppUi()->RemoveFromStack(iBCContainer);
       
   257         }
       
   258     }
       
   259 // --------------------------------------------------------------------------
       
   260 // When a view which was previously activated, goes to background and gets
       
   261 // activated again, the DoActivateL will not be called only ViewActivatedL 
       
   262 // will be called. Special handling is required for the context view for the
       
   263 // scenario, open context help from any application, with out changing the 
       
   264 // help view, open context help from another application, the contents of the
       
   265 // context view has to be refreshed with the new topic
       
   266 // --------------------------------------------------------------------------    
       
   267 void CCSXHHtmlTopicView::ViewActivatedL(const TVwsViewId& aPrevViewId,
       
   268                                  TUid aCustomMessageId,
       
   269                                  const TDesC8& aCustomMessage)
       
   270     {
       
   271     
       
   272     if(iBCContainer)
       
   273     	{
       
   274         //This handling is required for the following scenario
       
   275     	//Context sensitive help launch more than once with no 
       
   276 	    //other view navigation in the help application
       
   277     	CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document());
       
   278      	if(doc->GetDisplayTopic()->GetViewID() == KCSXHContextHtmlTopicViewID)
       
   279  	    	{
       
   280         	CCSXHContextTopic *topic = static_cast<CCSXHContextTopic*>(doc->GetDisplayTopic());
       
   281         	doc->SetDisplayTopic(topic->GetTopic());
       
   282         	CCSXHHtmlTOC2 *displayTopic = STATIC_CAST(CCSXHHtmlTOC2*,doc->GetDisplayTopic());
       
   283         	iBCContainer->RefreshL(displayTopic);
       
   284         	SetSoftKeysL(R_CSHELP_SOFTKEYS_OPTIONS_CLOSE_OPENLINK);
       
   285          	}
       
   286         iBCContainer->CheckForMSK();
       
   287     	}
       
   288     CAknView::ViewActivatedL(aPrevViewId,aCustomMessageId,aCustomMessage);
       
   289     }
       
   290     
       
   291 void CCSXHHtmlTopicView::SetSoftKeysL(TInt aSoftKeys)
       
   292     {    
       
   293     if( Cba() )
       
   294         {
       
   295         Cba()->SetCommandSetL( aSoftKeys );
       
   296         Cba()->DrawDeferred();   	
       
   297         }
       
   298     }
       
   299 // --------------------------------------------------------------------------
       
   300 // Dynamically updating Options menu item
       
   301 // --------------------------------------------------------------------------    
       
   302 void CCSXHHtmlTopicView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
       
   303     {
       
   304 
       
   305     if( R_CSXH_MENU_HTMLTOPICVIEW == aResourceId)
       
   306         {    
       
   307         TInt CurrentFontSize = iBCContainer->GetCurrentValueL(TBrCtlDefs::ESettingsFontSize);
       
   308         
       
   309         if(CurrentFontSize == TBrCtlDefs::EFontSizeLevelAllSmall)
       
   310             {
       
   311             aMenuPane->SetItemDimmed(ECsHelpCmdFontSmall,ETrue);
       
   312             }
       
   313         else if(CurrentFontSize == TBrCtlDefs::EFontSizeLevelAllLarge)
       
   314             {
       
   315             aMenuPane->SetItemDimmed(ECsHelpCmdFontLarge,ETrue);
       
   316             }
       
   317         
       
   318         if(!iBCContainer->IsHyperLinkFocused())
       
   319             {
       
   320             aMenuPane->SetItemDimmed(ECSXHOpenHyperLink,ETrue);
       
   321             }
       
   322         }
       
   323     }
       
   324 // --------------------------------------------------------------------------
       
   325 // MSK Handling
       
   326 // --------------------------------------------------------------------------
       
   327 void CCSXHHtmlTopicView::SetMiddleSoftKey(TBool aValue)
       
   328     {
       
   329 #ifndef __SERIES60_30__    
       
   330     if(AknLayoutUtils::MSKEnabled())
       
   331         {        
       
   332         Cba()->MakeCommandVisible(ECSXHOpenHyperLink,aValue);
       
   333         Cba()->DrawDeferred();
       
   334         }
       
   335 #endif      
       
   336     }
       
   337     
       
   338 TInt CCSXHHtmlTopicView::GetCurrentFontSize()
       
   339  	{
       
   340  	return iFontSize;
       
   341  	}
       
   342  	
       
   343 void CCSXHHtmlTopicView::ResourceChangeHdl(TInt aType)
       
   344     {
       
   345     if(iBCContainer)
       
   346         iBCContainer->HandleResourceChangeImpl(aType);
       
   347     } 
       
   348     
       
   349 #ifdef FF_HELP_TUTORIAL_MERGE
       
   350  // --------------------------------------------------------------------------
       
   351 // CCSXHAppUi::LaunchTutorial
       
   352 // Lauch tutorial if exist, else popup a error message.
       
   353 // --------------------------------------------------------------------------
       
   354 void CCSXHHtmlTopicView::LaunchTutorial()
       
   355     {
       
   356     CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document());
       
   357     CCSXHHtmlTOC2 *displayTopic = STATIC_CAST(CCSXHHtmlTOC2*,doc->GetDisplayTopic());
       
   358     TCoeHelpContext helpContext;
       
   359     displayTopic->GetHelpContext(helpContext);
       
   360     CCSXHAppUi::GetInstance()->SetHelpContext(helpContext);
       
   361     if( CCSXHAppUi::GetInstance()->IsApplicationPresentInTutorialL() )
       
   362         {
       
   363         CCSXHAppUi::GetInstance()->CallTutorialAiwProviderL();
       
   364         }
       
   365     else
       
   366         {
       
   367         HBufC* ErrorMessage = iCoeEnv->AllocReadResourceLC(R_TYPE_NO_HELP_TOPICS);
       
   368         CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   369         note->ShowNoteL(EAknGlobalInformationNote, *ErrorMessage);
       
   370 
       
   371         CleanupStack::PopAndDestroy(note);
       
   372         CleanupStack::PopAndDestroy(ErrorMessage);
       
   373         }
       
   374     }
       
   375 #endif // FF_HELP_TUTORIAL_MERGE