csxhelp/src/CSXHLegacyTopicView.cpp
branchRCL_3
changeset 17 12f60d9a73b3
parent 16 0d1adf67ec1b
child 18 cbffe13eac63
equal deleted inserted replaced
16:0d1adf67ec1b 17:12f60d9a73b3
     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:  CCSXHLegacyTopicView class definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include "CSXHLegacyTopicView.h"
       
    21 #include "CSXHLegacyTopicContainer.h"
       
    22 #include "CSXHAppUi.h"
       
    23 #include "CSXHDocument.h"
       
    24 #include <cshelp.rsg>
       
    25 #include "CsHelp.hrh"
       
    26 
       
    27 #include "CSXHHelpContentBase.h"
       
    28 #include "CSXHLegacyTOC2.h"
       
    29 #include "CSXHLegacyTOC1.h" 
       
    30 #include "CSXHViewIDs.h"
       
    31 #include "CSXHHelpDataBase.h"
       
    32 #include "CSXHContextTopic.h"
       
    33 
       
    34 #include <akntitle.h>
       
    35 
       
    36 CCSXHLegacyTopicView* CCSXHLegacyTopicView::NewL(const TUid& aUid, 
       
    37                                         const TInt& aFlags,const TRect& aRect)
       
    38     {
       
    39     CCSXHLegacyTopicView* temp = new(ELeave) CCSXHLegacyTopicView(aUid,aFlags);
       
    40     CleanupStack::PushL(temp);
       
    41     temp->ConstructL(aRect);
       
    42     CleanupStack::Pop(temp);
       
    43     return temp;
       
    44     }
       
    45 
       
    46 CCSXHLegacyTopicView::CCSXHLegacyTopicView(const TUid& aUid, const TInt& aFlags)
       
    47                         : iUid(aUid),iAppFlags(aFlags)
       
    48     {
       
    49     }
       
    50     
       
    51 CCSXHLegacyTopicView::~CCSXHLegacyTopicView()
       
    52     {
       
    53     }
       
    54     
       
    55 void CCSXHLegacyTopicView::ConstructL(const TRect& /*aRect*/)
       
    56     {
       
    57     BaseConstructL(iAppFlags);
       
    58     }
       
    59     
       
    60 TUid CCSXHLegacyTopicView::Id() const   
       
    61     {
       
    62     return iUid;
       
    63     }
       
    64 // --------------------------------------------------------------------------
       
    65 // Launches an application based on the Application UID and a View ID
       
    66 // --------------------------------------------------------------------------
       
    67 void CCSXHLegacyTopicView::HandleCommandL(TInt aCommand)
       
    68     {
       
    69     switch(aCommand)
       
    70         {       
       
    71         case ECSXHOpenApplicationTopics:
       
    72             {
       
    73             CCSXHDocument* doc = static_cast<CCSXHDocument*>(AppUi()->Document());              
       
    74             CCSXHLegacyTOC2* displayTopic = STATIC_CAST(CCSXHLegacyTOC2*,doc->GetDisplayTopic());
       
    75             CCSXHLegacyTOC1* toc1 = displayTopic->GetLegacyParent();
       
    76             if(toc1)
       
    77                 {
       
    78                 doc->SetDisplayAndPrevTopic(toc1);
       
    79                 AppUi()->HandleCommandL(ECSXHOpenItem);
       
    80                 }
       
    81             else
       
    82                 {
       
    83                 //Handling will be same as EAknSoftkeyBack
       
    84                 HandleCommandL(EAknSoftkeyBack);
       
    85                 }
       
    86             break;      
       
    87             }
       
    88         case EAknSoftkeyBack:
       
    89             {
       
    90             CCSXHDocument* doc = static_cast<CCSXHDocument*>(AppUi()->Document());              
       
    91             CCSXHLegacyTOC2* displayTopic = STATIC_CAST(CCSXHLegacyTOC2*,doc->GetDisplayTopic());
       
    92             doc->SetDisplayAndPrevTopic(displayTopic->GetParent());
       
    93             AppUi()->HandleCommandL(ECSXHOpenItem);                 
       
    94             }               
       
    95         break;
       
    96         case ECSXHTOC1ListView:
       
    97             {
       
    98             CCSXHDocument* doc = static_cast<CCSXHDocument*>(AppUi()->Document());              
       
    99             CCSXHLegacyTOC2* displayTopic = STATIC_CAST(CCSXHLegacyTOC2*,doc->GetDisplayTopic());
       
   100             CCSXHGenericTOC1* toc1 = displayTopic->GetLegacyParent();
       
   101             if(!toc1)
       
   102                 toc1 = displayTopic->GetParent();
       
   103             doc->SetDisplayTopic(toc1);
       
   104             doc->SetDisplayAndPrevTopic(doc->GetHelpDataBase()->GetMainTopics());   
       
   105             AppUi()->HandleCommandL(ECSXHOpenItem);
       
   106             }
       
   107             break;  
       
   108         default:
       
   109             AppUi()->HandleCommandL(aCommand);  
       
   110             break;
       
   111         }   
       
   112     }
       
   113 
       
   114 // --------------------------------------------------------------------------
       
   115 // Handlign for view activation. For a context view, the actual display topic
       
   116 // has to be modified
       
   117 // --------------------------------------------------------------------------
       
   118 void CCSXHLegacyTopicView::DoActivateL(const TVwsViewId& aPrevViewId,TUid /* aCustomMessageId */,
       
   119                              const TDesC8& /* aCustomMessage */)    
       
   120     {
       
   121     iPrevious = aPrevViewId;
       
   122     CCSXHDocument* doc = static_cast<CCSXHDocument*>(AppUi()->Document());
       
   123      //Set the correct display topic here for context sensitive launch
       
   124     if(iUid == KCSXHContextLegacyTopicViewID)
       
   125         {
       
   126         CCSXHContextTopic* topic = STATIC_CAST(CCSXHContextTopic*,doc->GetDisplayTopic());
       
   127         doc->SetDisplayTopic(topic->GetTopic());
       
   128         }
       
   129             
       
   130     if(!iTopicContainer)
       
   131         {
       
   132         CCSXHLegacyTOC2* displayTopic = STATIC_CAST(CCSXHLegacyTOC2*,doc->GetDisplayTopic());
       
   133         iTopicContainer = CCSXHLegacyTopicContainer::NewL(ClientRect(),*doc,displayTopic);
       
   134         }
       
   135         
       
   136     iTopicContainer->SetMopParent(this);
       
   137     iTopicContainer->SetRect(ClientRect());
       
   138     AppUi()->AddToStackL(*this, iTopicContainer);
       
   139     iTopicContainer->MakeVisible(ETrue);
       
   140     
       
   141     //Set the title of the view
       
   142     CEikStatusPane* sp = StatusPane();
       
   143     CAknTitlePane* title = STATIC_CAST(CAknTitlePane*, 
       
   144             sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
       
   145     title->SetTextL(doc->GetDisplayTopic()->GetName());
       
   146     
       
   147    	//MSK: Should be Inactive in this view
       
   148 	//TSW Error:EAJA-6XLFTW :
       
   149 	//S60 3.2 Help: Selection key opens Option menu in Topic view 
       
   150 	//If MSK is not defined, "." appears in the MSK, 
       
   151 	//On Middle key press, Options menu items are shown to the user 
       
   152 #ifndef __SERIES60_30__    
       
   153     if(AknLayoutUtils::MSKEnabled())
       
   154         {        
       
   155         Cba()->MakeCommandVisible(ECSXHDummyMSK,EFalse);
       
   156         Cba()->DrawDeferred();
       
   157         }
       
   158 #endif 
       
   159     }
       
   160                              
       
   161 void CCSXHLegacyTopicView::DoDeactivate()                             
       
   162     {
       
   163     if(iTopicContainer)
       
   164         {
       
   165         iTopicContainer->MakeVisible(EFalse);
       
   166         AppUi()->RemoveFromStack(iTopicContainer);
       
   167         delete iTopicContainer;
       
   168         iTopicContainer = NULL;
       
   169         }
       
   170     }
       
   171 // --------------------------------------------------------------------------
       
   172 // When a view which was previously activated, goes to background and gets
       
   173 // activated again, the DoActivateL will not be called only ViewActivatedL 
       
   174 // will be called. Special handling is required for the context view for the
       
   175 // scenario, open context help from any application, with out changing the 
       
   176 // help view, open context help from another application, the contents of the
       
   177 // context view has to be refreshed with the new topic
       
   178 // --------------------------------------------------------------------------
       
   179 void CCSXHLegacyTopicView::ViewActivatedL(const TVwsViewId& aPrevViewId,
       
   180                                  TUid aCustomMessageId,
       
   181                                  const TDesC8& aCustomMessage)
       
   182     {
       
   183     if(iTopicContainer && iUid == KCSXHContextLegacyTopicViewID)
       
   184         {
       
   185         CCSXHDocument* doc = static_cast<CCSXHDocument*>(AppUi()->Document());
       
   186         
       
   187         if(doc->GetDisplayTopic()->GetViewID() == KCSXHContextLegacyTopicViewID)
       
   188             {
       
   189             CCSXHContextTopic* topic = STATIC_CAST(CCSXHContextTopic*,doc->GetDisplayTopic());
       
   190             doc->SetDisplayTopic(topic->GetTopic());
       
   191             CCSXHLegacyTOC2* displayTopic = STATIC_CAST(CCSXHLegacyTOC2*,doc->GetDisplayTopic());
       
   192             iTopicContainer->RefreshL(displayTopic);    
       
   193             }
       
   194         
       
   195          //Set the title of the view
       
   196         CEikStatusPane* sp = StatusPane();
       
   197         CAknTitlePane* title = STATIC_CAST(CAknTitlePane*, 
       
   198             sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
       
   199         title->SetTextL(doc->GetDisplayTopic()->GetName());
       
   200         }
       
   201         
       
   202     CAknView::ViewActivatedL(aPrevViewId,aCustomMessageId,aCustomMessage);
       
   203     }
       
   204 void CCSXHLegacyTopicView::ViewDeactivated()
       
   205     {
       
   206     CAknView::ViewDeactivated();
       
   207     }
       
   208 void CCSXHLegacyTopicView::ResourceChangeHdl(TInt aType)
       
   209     {
       
   210     if(iTopicContainer)
       
   211         iTopicContainer->HandleResourceChangeImpl(aType);
       
   212     }
       
   213