www.pudn.com > LDFUCK.rar > HelpContainer.cpp
#include#include #include #include #include // TResourceReader #include // resources #include #include "HelpContainer.h" #include "RichTextEditorRichTextEditor.h" #define KEditorPosition TPoint(0,0) CHelpContainer::CHelpContainer() { } // EPOC default constructor can leave. void CHelpContainer::ConstructL(const TRect& aRect) { CreateWindowL(); iEditor = CRichTextEditorRichTextEditor::NewL(); iEditor->SetContainerWindowL(*this); AddTextToEditorL(); SetRect(aRect); ActivateL(); iEditor->DisplayStartOfHelpTextL(); } void CHelpContainer::AddTextToEditorL() { if (iEditor) { //软件介绍 HBufC* header1 = StringLoader::LoadLC (R_RICHTEXTEDITOR_HELP_HEADER1); iEditor->SetUnderlineOn(ETrue); iEditor->SetBoldOn(ETrue); iEditor->AddTextL (*header1); CleanupStack::PopAndDestroy(header1); iEditor->AddCarriageReturnL(); iEditor->SetUnderlineOn(EFalse); iEditor->SetBoldOn(EFalse); HBufC* text1 = StringLoader::LoadLC (R_RICHTEXTEDITOR_HELP_TEXT1); iEditor->AddTextL (*text1); iEditor->AddCarriageReturnL(); iEditor->AddCarriageReturnL(); CleanupStack::PopAndDestroy(text1); //使用说明 HBufC* header2 = StringLoader::LoadLC (R_RICHTEXTEDITOR_HELP_HEADER2); iEditor->SetUnderlineOn(ETrue); iEditor->SetBoldOn(ETrue); iEditor->AddTextL (*header2); CleanupStack::PopAndDestroy(header2); iEditor->AddCarriageReturnL(); iEditor->SetUnderlineOn(EFalse); iEditor->SetBoldOn(EFalse); HBufC* text2 = StringLoader::LoadLC (R_RICHTEXTEDITOR_HELP_TEXT2); iEditor->AddTextL (*text2); iEditor->AddCarriageReturnL(); iEditor->AddCarriageReturnL(); CleanupStack::PopAndDestroy(text2); //致谢 HBufC* header3 = StringLoader::LoadLC (R_RICHTEXTEDITOR_HELP_HEADER3); iEditor->SetUnderlineOn(ETrue); iEditor->SetBoldOn(ETrue); iEditor->AddTextL (*header3); CleanupStack::PopAndDestroy(header3); iEditor->AddCarriageReturnL(); iEditor->SetUnderlineOn(EFalse); iEditor->SetBoldOn(EFalse); HBufC* text3 = StringLoader::LoadLC (R_RICHTEXTEDITOR_HELP_TEXT3); iEditor->AddTextL (*text3); iEditor->AddCarriageReturnL(); iEditor->AddCarriageReturnL(); CleanupStack::PopAndDestroy(text3); } } /** * Symbian OS 2 phase constructor. * Constructs the CRichTextEditorContainer using the NewLC method, popping * the constructed object from the CleanupStack before returning it. * * @param aRect The rectangle for this window * @return The newly constructed CRichTextEditorContainer */ CHelpContainer* CHelpContainer::NewL(const TRect& aRect) { CHelpContainer* self = CHelpContainer::NewLC(aRect); CleanupStack::Pop(self); return self; } /** * Symbian OS 2 phase constructor. * Constructs the CRichTextEditorContainer using the constructor and ConstructL * method, leaving the constructed object on the CleanupStack before returning it. * * @param aRect The rectangle for this window * @return The newly constructed CRichTextEditorContainer */ CHelpContainer* CHelpContainer::NewLC(const TRect& aRect) { CHelpContainer* self = new (ELeave) CHelpContainer; CleanupStack::PushL(self); self->ConstructL(aRect); return self; } /** * Destructor. Frees up memory for the iEditor. */ CHelpContainer::~CHelpContainer() { if (iEditor) { delete iEditor; iEditor=NULL; } } // destructor void CHelpContainer::SizeChanged() { iEditor->SetExtent(KEditorPosition, iEditor->MinimumSize()); } // --------------------------------------------------------- // CHelpContainer::CountComponentControls() const // return the number of controls // --------------------------------------------------------- // TInt CHelpContainer::CountComponentControls() const { // return number of controls inside this container return 1; } // --------------------------------------------------------- // CHelpContainer::ComponentControl(TInt aIndex) const // return the pointer to specified control. // --------------------------------------------------------- // CCoeControl* CHelpContainer::ComponentControl( TInt aIndex ) const { switch (aIndex) { case 0: return iEditor; default: return NULL; } } // --------------------------------------------------------- // CHelpContainer::Draw(const TRect& aRect) const // handle the message when client region must be redrawn. // --------------------------------------------------------- // void CHelpContainer::Draw( const TRect& aRect ) const { CWindowGc& gc = SystemGc(); gc.Clear(aRect); } // --------------------------------------------------------- // CAknExGridContainer::OfferKeyEventL( // const TKeyEvent& aKeyEvent, TEventCode aType ) // Handles the key events. // --------------------------------------------------------- // TKeyResponse CHelpContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType ) { if (iEditor) return iEditor->OfferKeyEventL(aKeyEvent, aType); else return CCoeControl::OfferKeyEventL(aKeyEvent, aType); } // End of File