csxhelp/src/CSXHLegacyTopicContainer.cpp
branchRCL_3
changeset 22 e3a25416bf1f
parent 0 1f04cf54edd8
equal deleted inserted replaced
20:326673dff2bf 22:e3a25416bf1f
    31 #include <AknsDrawUtils.h> 
    31 #include <AknsDrawUtils.h> 
    32 #include <AknsBasicBackgroundControlContext.h>
    32 #include <AknsBasicBackgroundControlContext.h>
    33 #include <aknlayoutscalable_apps.cdl.h>
    33 #include <aknlayoutscalable_apps.cdl.h>
    34 #include <aknappui.h>
    34 #include <aknappui.h>
    35 #include <txtfrmat.h> 
    35 #include <txtfrmat.h> 
       
    36 #include <cshelp.rsg>
    36 
    37 
    37 CCSXHLegacyTopicContainer* CCSXHLegacyTopicContainer::NewL(const TRect& 
    38 CCSXHLegacyTopicContainer* CCSXHLegacyTopicContainer::NewL(const TRect& 
    38 aRect,CCSXHDocument &aDocument,CCSXHLegacyTOC2 *aTopic)
    39 aRect,CCSXHDocument &aDocument,CCSXHLegacyTOC2 *aTopic)
    39     {
    40     {
    40     CCSXHLegacyTopicContainer* self = CCSXHLegacyTopicContainer::NewLC(aRect,aDocument,aTopic);
    41     CCSXHLegacyTopicContainer* self = CCSXHLegacyTopicContainer::NewLC(aRect,aDocument,aTopic);
    67     iText = STATIC_CAST(CRichText*,iTopic->GetTopicContentL());
    68     iText = STATIC_CAST(CRichText*,iTopic->GetTopicContentL());
    68     
    69     
    69     GetTextFormat();
    70     GetTextFormat();
    70 
    71 
    71     iEdwin = new(ELeave) CEikEdwin();
    72     iEdwin = new(ELeave) CEikEdwin();
    72     const TInt flags(CEikEdwin::EKeepDocument |
    73     TInt flags(CEikEdwin::EKeepDocument |
    73                      CEikEdwin::EUserSuppliedText |
    74                CEikEdwin::EUserSuppliedText |
    74                      CEikEdwin::ENoAutoSelection |
    75                CEikEdwin::ENoAutoSelection |
    75                      CEikEdwin::EAvkonDisableCursor |
    76                CEikEdwin::EAvkonDisableCursor |
    76                      CEikEdwin::EReadOnly |
    77                CEikEdwin::EReadOnly |
    77                      CEikEdwin::EDisplayOnly);
    78                CEikEdwin::EDisplayOnly);
       
    79 
       
    80     if ( iText == NULL )
       
    81         {
       
    82         flags = flags & ~CEikEdwin::EUserSuppliedText;
       
    83         }
       
    84 
    78     iEdwin->SetContainerWindowL(*this);
    85     iEdwin->SetContainerWindowL(*this);
    79 
    86 
    80     iEdwin->ConstructL(flags);
    87     iEdwin->ConstructL(flags);
    81     iEdwin->CreatePreAllocatedScrollBarFrameL()->SetScrollBarVisibilityL(
    88     iEdwin->CreatePreAllocatedScrollBarFrameL()->SetScrollBarVisibilityL(
    82                                                  CEikScrollBarFrame::EOff,
    89                                                  CEikScrollBarFrame::EOff,
    83                                                  CEikScrollBarFrame::EAuto);
    90                                                  CEikScrollBarFrame::EAuto);
    84     SetTextL(iText);
    91     SetTextL(iText);
    85     FormatRichTextL(*iText);
    92     if( iText != NULL )
       
    93         {
       
    94         FormatRichTextL(*iText);
       
    95         }
    86     SetRect(aRect);
    96     SetRect(aRect);
    87     ActivateL();
    97     ActivateL();
    88     }
    98     }
    89 
    99 
    90 CCSXHLegacyTopicContainer::~CCSXHLegacyTopicContainer()
   100 CCSXHLegacyTopicContainer::~CCSXHLegacyTopicContainer()
    96 void CCSXHLegacyTopicContainer::RefreshL(CCSXHLegacyTOC2 *aTopic)
   106 void CCSXHLegacyTopicContainer::RefreshL(CCSXHLegacyTOC2 *aTopic)
    97     {
   107     {
    98     iTopic = aTopic;
   108     iTopic = aTopic;
    99     iText = STATIC_CAST(CRichText*,iTopic->GetTopicContentL());
   109     iText = STATIC_CAST(CRichText*,iTopic->GetTopicContentL());
   100     SetTextL(iText);
   110     SetTextL(iText);
   101     FormatRichTextL(*iText);
   111     if( iText != NULL )
       
   112         {
       
   113         FormatRichTextL(*iText);
       
   114         }
   102     SizeChanged();
   115     SizeChanged();
   103     }
   116     }
   104 
   117 
   105 void CCSXHLegacyTopicContainer::SetTextL(CRichText* aText)
   118 void CCSXHLegacyTopicContainer::SetTextL(CRichText* aText)
   106     {
   119     {
   107     iEdwin->SetDocumentContentL(*aText, CEikEdwin::EUseText);
   120     if( aText == NULL )
   108     iEdwin->SetCursorPosL(0, EFalse);
   121         {
   109     
   122         HBufC* errorMessage = iCoeEnv->AllocReadResourceLC( R_TYPE_NO_HELP_TOPICS );
       
   123         iEdwin->SetTextL( errorMessage );
       
   124         CleanupStack::PopAndDestroy( errorMessage ); 
       
   125         }
       
   126     else
       
   127         {
       
   128         iEdwin->SetDocumentContentL(*aText, CEikEdwin::EUseText);
       
   129         iEdwin->SetCursorPosL(0, EFalse);
       
   130         }    
   110     }
   131     }
   111 
   132 
   112 void CCSXHLegacyTopicContainer::FocusChanged(TDrawNow aDrawNow)
   133 void CCSXHLegacyTopicContainer::FocusChanged(TDrawNow aDrawNow)
   113     {
   134     {
   114     if (iEdwin)
   135     if (iEdwin)