⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 projectview.cpp

📁 symbian下开发软件时
💻 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> 
#include <eiklbx.h>
#include <eiklbi.h>


// different granularities here represent the possibility for different listbox views
// the only reason for doing so is for illustartion purposes :-)
const TInt KGranularityOfOtherArray = 20;
const TInt KGranularityOfMainArray =14;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(KGranularityOfMainArray);
    
    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*/)    {        // In case you want to init another menubar for the view    //CEikMenuBar* menuBar = iEikonEnv->AppUiFactory()->MenuBar();    //menuBar->ChangeMenuBarL(0, iMenuBarResourceId, EFalse);    
    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==KGranularityOfMainArray-1)
        {
        iMessageList->Delete(KGranularityOfMainArray-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::EAuto, CEikScrollBarFrame::EAuto);
    
    iMessageList = new (ELeave) CDesCArrayFlat(KGranularityOfOtherArray);
    
    CTextListBoxModel* model = iListBox->Model();
    model->SetItemTextArray(iMessageList);
    model->SetOwnershipType(ELbmOwnsItemArray); 
    
    ((CTextListItemDrawer*)iListBox->View()->ItemDrawer())->SetCellWidthInChars(80);
    MakeVisible(EFalse);
    }

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==KGranularityOfOtherArray-1)
        {
        iMessageList->Delete(KGranularityOfOtherArray-2);
        iListBox->HandleItemRemovalL();		
        iListBox->DrawDeferred();
        }
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -