📄 cipherappview.cpp
字号:
/* Copyright (c) 2003, Nokia. All rights reserved */
#include <eiklabel.h>
#include <aknlists.h>
#include "CipherAppView.h"
#include "Cipher.pan"
// Dimensions of output window
const TInt KMaxLineLength = 40;
const TInt KGranularityOfArray = 10;
CCipherAppView* CCipherAppView::NewL(const TRect& aRect)
{
CCipherAppView* self = NewLC(aRect);
CleanupStack::Pop(self);
return self;
}
CCipherAppView* CCipherAppView::NewLC(const TRect& aRect)
{
CCipherAppView* self = new (ELeave) CCipherAppView;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}
void CCipherAppView::ConstructL(const TRect& aRect)
{
iOutputText = HBufC::NewL(KMaxLineLength);
CreateWindowL();
SetRect(aRect);
iMsgIndex = NULL;
iListBox = new (ELeave) CAknSingleStyleListBox;
iListBox->SetContainerWindowL(*this);
iListBox->ConstructL(this, NULL);
iListBox->SetRect(aRect.Size());
iListBox->ActivateL();
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()
->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);
iListBox->SetDimmed(ETrue);
iMessageList = new (ELeave) CDesCArrayFlat(KGranularityOfArray);
CTextListBoxModel* model = iListBox->Model();
model->SetItemTextArray(iMessageList);
model->SetOwnershipType(ELbmOwnsItemArray); // Transfer ownership of iMessageList
ActivateL();
MakeVisible(ETrue);
}
CCipherAppView::CCipherAppView()
{
// No implementation required
}
CCipherAppView::~CCipherAppView()
{
// iMessageList owned by iListBox->Model()
iMessageList = NULL;
delete iListBox;
iListBox = NULL;
delete iOutputText;
iOutputText = NULL;
}
TInt CCipherAppView::CountComponentControls() const
{
return 1; // Only have one Component
}
CCoeControl* CCipherAppView::ComponentControl(TInt aIndex) const
{
__ASSERT_ALWAYS(aIndex == 0, Panic(ECipherInvalidComponentIndex));
return iListBox;
}
TKeyResponse CCipherAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
{
return iListBox->OfferKeyEventL(aKeyEvent, aType);
}
void CCipherAppView::PrintLineL(const TDesC& aText)
{
_LIT(KTabLiteral,"\t");
iOutputText->Des().Append(KTabLiteral);
TInt spaceRemaining = KMaxLineLength - iOutputText->Des().Length();
// If mlen is greater than the length of the string
// then Left returns the whole of the descriptor.
iOutputText->Des().Append(aText.Left(spaceRemaining));
iMessageList->AppendL(*iOutputText);
iListBox->HandleItemAdditionL();
iOutputText->Des().Zero();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -