📄 bencoolenaboutdlg.cpp
字号:
/*
* BencoolenAboutDlg.cpp
*
* Copyright 2005 - 2007, Antony Pranata
* http://www.antonypranata.com
*
* Project: Screenshot for Symbian OS.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
// INCLUDES
#include <eikrted.h>
#include <txtrich.h>
#include <txtfrmat.h>
#include <StringLoader.h>
#include <screenshot.rsg>
#include "BencoolenAboutDlg.h"
#include "ScreenShotData.h"
#include "Bencoolen.hrh"
// MEMBER FUNCTIONS
// --------------------------------------------------------------------------
// Default constructor.
// --------------------------------------------------------------------------
CBencoolenAboutDlg::CBencoolenAboutDlg()
:CAknDialog()
{
}
// --------------------------------------------------------------------------
// Destructor.
// --------------------------------------------------------------------------
CBencoolenAboutDlg::~CBencoolenAboutDlg()
{
delete iTextEditorAbout;
}
// --------------------------------------------------------------------------
// Creates rich edit control in this dialog to display copyright message.
// --------------------------------------------------------------------------
void CBencoolenAboutDlg::PreLayoutDynInitL()
{
// Construct a new rich text editor.
iTextEditorAbout = new(ELeave) CEikRichTextEditor();
iTextEditorAbout->ConstructL(this, 0, 0,
CEikEdwin::EReadOnly | CEikEdwin::ENoAutoSelection);
iTextEditorAbout->SetContainerWindowL(*this);
iTextEditorAbout->SetAknEditorFlags(EAknEditorFlagEnableScrollBars);
// Insert all copyright text to the rich text.
CRichText* richText = iTextEditorAbout->RichText();
HBufC* message = StringLoader::LoadLC(R_BENCOOLEN_DIALOG_INFORMATION);
richText->InsertL(0, '\f'); // EOL
richText->InsertL(0, '\f'); // EOL
richText->InsertL(0, *message);
CleanupStack::PopAndDestroy(); // message
message = 0;
message = StringLoader::LoadLC(R_BENCOOLEN_DIALOG_URL);
richText->InsertL(0, '\f'); // EOL
richText->InsertL(0, *message);
CleanupStack::PopAndDestroy(); // message
message = 0;
message = StringLoader::LoadLC(R_BENCOOLEN_DIALOG_COPYRIGHT);
richText->InsertL(0, '\f'); // EOL
richText->InsertL(0, *message);
CleanupStack::PopAndDestroy(); // message
message = 0;
message = StringLoader::LoadLC(R_BENCOOLEN_DIALOG_VERSION);
richText->InsertL(0, '\f'); // EOL
richText->InsertL(0, *message);
CleanupStack::PopAndDestroy(); // message
message = 0;
message = StringLoader::LoadLC(R_BENCOOLEN_DIALOG_PROGRAM_NAME);
richText->InsertL(0, '\f'); // EOL
richText->InsertL(0, *message);
CleanupStack::PopAndDestroy(); // message
message = 0;
// Make it to the center
CParaFormat paraFormat;
TParaFormatMask paraFormatMask;
iTextEditorAbout->SetSelectionL(0, richText->DocumentLength());
paraFormatMask.SetAttrib(EAttAlignment); // set the mask
paraFormat.iHorizontalAlignment = CParaFormat::ECenterAlign;
iTextEditorAbout->ApplyParaFormatL(¶Format, paraFormatMask);
// Create scroll bar.
CEikScrollBarFrame* scrollBarFrame = iTextEditorAbout->CreateScrollBarFrameL();
scrollBarFrame->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
iTextEditorAbout->SetCursorPosL(0, EFalse);
iTextEditorAbout->UpdateScrollBarsL();
}
// --------------------------------------------------------------------------
// Returns the number of control in this dialog.
// In this case we have only one, which is the rich edit control.
// --------------------------------------------------------------------------
TInt CBencoolenAboutDlg::CountComponentControls() const
{
return 1;
}
// --------------------------------------------------------------------------
// Returns the pointer to the controls in this dialog.
// --------------------------------------------------------------------------
CCoeControl* CBencoolenAboutDlg::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iTextEditorAbout;
default:
return NULL;
}
}
// --------------------------------------------------------------------------
// Called when the size of this dialog is changed.
// In this case, we just resize the rich edit control.
// --------------------------------------------------------------------------
void CBencoolenAboutDlg::SizeChanged()
{
iTextEditorAbout->SetExtent(TPoint(0, 0), Rect().Size());
DrawNow();
}
// --------------------------------------------------------------------------
// We have to handle key event here because by default we don't set the focus
// to the text editor. That's why we have to pass the key event to the
// text editor.
// --------------------------------------------------------------------------
TKeyResponse CBencoolenAboutDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent,
TEventCode aType)
{
if (iTextEditorAbout)
{
switch (aKeyEvent.iCode)
{
case EKeyDownArrow:
{
iTextEditorAbout->MoveCursorL(TCursorPosition::EFPageDown, EFalse);
return EKeyWasConsumed;
}
case EKeyUpArrow:
{
iTextEditorAbout->MoveCursorL(TCursorPosition::EFPageUp, EFalse);
return EKeyWasConsumed;
}
default:
return iTextEditorAbout->OfferKeyEventL(aKeyEvent, aType);
}
}
else
{
return EKeyWasNotConsumed;
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -