📄 projectview.cpp
字号:
// projectView.cpp// Copyright Symbian Ltd, John Pagonis 2005-2006, Symbian Developer Network#include "projectView.h"
#include <eiklabel.h>
#include <eiktxlbx.h>
#include <eiktxlbm.h>
const TInt KGranularityOfArray = 10;
CProjectView::CProjectView() { }CProjectView::~CProjectView() { }void CProjectView::ConstructL(const TRect& aRect, CProjectModel* aModel,TUid aViewId,TInt aMenuBarResourceId) { CProjectBaseView::ConstructL(aRect,aModel,aViewId,aMenuBarResourceId);
ConstructControlsL(Border().InnerRect(Rect())); }void CProjectView::ConstructControlsL(const TRect& aRect) { CEikTextListBox* tmpBox=new(ELeave) CEikTextListBox();
CleanupStack::PushL(tmpBox);
tmpBox->SetContainerWindowL(*this);
tmpBox->ConstructL(this, 0);
CleanupStack::Pop(tmpBox);
iListBox = tmpBox;
iControls.Append(tmpBox); //no need to check return val here, default size is 8
SetBorder(TGulBorder::EFlatContainer);
iListBox->SetRect(aRect);
iListBox->ActivateL();
iListBox->CreateScrollBarFrameL(EFalse);
iListBox->ScrollBarFrame()
->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
iListBox->SetDimmed(ETrue);
iMessageList = new (ELeave) CDesCArrayFlat(KGranularityOfArray);
CTextListBoxModel* model = iListBox->Model();
model->SetItemTextArray(iMessageList);
model->SetOwnershipType(ELbmOwnsItemArray); // transfer ownership of iMessageList }void CProjectView::Draw(const TRect& aRect) const {
CEikBorderedControl::Draw(aRect);
CWindowGc& gc = SystemGc();
TRect rect = Border().InnerRect(Rect());
gc.SetClippingRect(rect); }void CProjectView::ViewActivatedL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/) {
MakeVisible(ETrue); ActivateL(); }void CProjectView::ViewDeactivated() {
MakeVisible(EFalse);
}void CProjectView::ViewConstructL() { }void CProjectView::UpdateMsgL(const TDesC& aScreenMsg) {
iMessageList->InsertL(0,aScreenMsg);
iListBox->HandleItemAdditionL();
TInt msgIndex=iMessageList->MdcaCount();
if (msgIndex==KGranularityOfArray-1)
{
iMessageList->Delete(KGranularityOfArray-2);
iListBox->HandleItemRemovalL();
iListBox->DrawDeferred();
}
}
// other view
CProjectOtherView::CProjectOtherView()
{
}
CProjectOtherView::~CProjectOtherView()
{
}
void CProjectOtherView::ConstructL(const TRect& aRect, CProjectModel* aModel,
TUid aViewId, TInt aMenuBarResourceId)
{
CProjectBaseView::ConstructL(aRect,aModel,aViewId,aMenuBarResourceId);
ConstructControlsL(Border().InnerRect(Rect()));
}
void CProjectOtherView::ConstructControlsL(const TRect& aRect)
{
CEikTextListBox* tmpBox=new(ELeave) CEikTextListBox();
CleanupStack::PushL(tmpBox);
tmpBox->SetContainerWindowL(*this);
tmpBox->ConstructL(this, 0);
CleanupStack::Pop(tmpBox);
iListBox = tmpBox;
iControls.Append(tmpBox); //no need to check return val here, default size is 8
SetBorder(TGulBorder::EFlatContainer);
iListBox->SetRect(aRect);
iListBox->ActivateL();
iListBox->CreateScrollBarFrameL(EFalse);
iListBox->ScrollBarFrame()
->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
iMessageList = new (ELeave) CDesCArrayFlat(KGranularityOfArray);
CTextListBoxModel* model = iListBox->Model();
model->SetItemTextArray(iMessageList);
model->SetOwnershipType(ELbmOwnsItemArray); // transfer ownership of iMessageList
iListBox->SetFocus(ETrue);
}
void CProjectOtherView::Draw(const TRect& aRect) const
{
CEikBorderedControl::Draw(aRect);
CWindowGc& gc = SystemGc();
TRect rect = Border().InnerRect(Rect());
gc.SetClippingRect(rect);
}
void CProjectOtherView::ViewActivatedL(const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
{
iListBox->SetDimmed(EFalse);
iListBox->SetFocus(ETrue);
iFocusedControl=iListBox;
MakeVisible(ETrue);
ActivateL();
}
void CProjectOtherView::ViewDeactivated()
{
iListBox->SetDimmed(ETrue);
iListBox->SetFocus(EFalse);
MakeVisible(EFalse);
}
void CProjectOtherView::ViewConstructL()
{
}
TKeyResponse CProjectOtherView::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
{
return iListBox->OfferKeyEventL(aKeyEvent,aType);
}
void CProjectOtherView::UpdateMsgL(const TDesC& aScreenMsg)
{
iMessageList->InsertL(0,aScreenMsg);
iListBox->HandleItemAdditionL();
TInt msgIndex=iMessageList->MdcaCount();
if (msgIndex==KGranularityOfArray-1)
{
iMessageList->Delete(KGranularityOfArray-2);
iListBox->HandleItemRemovalL();
iListBox->DrawDeferred();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -