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

📄 uulistboxcontainer.cpp

📁 Simple Jabber Client for Symbian Platform
💻 CPP
字号:
/*
 *  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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 *  Jabber
 *  Copyright (C) 2004 Xie Tian Lu  http://sabber.jabberstudio.org/
 */

#include "UUListBoxContainer.h"
#include "UUListBox.h"

const TInt KTimerInterval = 60000000;

void CUUListBoxContainer::ConstructL(const TRect& /*aRect*/)
{	
	iListBox = new (ELeave) CUUListBox;
	if ( iListBox )
	{
		iListBox->SetListBoxObserver( this );
		CUUListItemDrawer* lid = new ( ELeave ) CUUListItemDrawer();
		iListBox->ConstructL( iModel, lid, this );
        iListBox->SetContainerWindowL( *this );
        CreateScrollbarL( iListBox );
	}
}

CUUListBoxContainer::~CUUListBoxContainer()
{
	delete iListBox;
}

void CUUListBoxContainer::SizeChanged()
{
    if ( iListBox )
    {
		TRect gRect = Rect();
		gRect.iTl.iY += 1;
		gRect.iBr.iY -= 1;
        iListBox->SetRect( gRect );
    }
}

TInt CUUListBoxContainer::CountComponentControls() const
{
	return 1;
}

CCoeControl* CUUListBoxContainer::ComponentControl(TInt aIndex ) const
{
	switch ( aIndex ) 
	{
		case 0:
		return iListBox;
	}
    return NULL;
}

void CUUListBoxContainer::Draw(const TRect& aRect) const
{    
    CWindowGc& gc = SystemGc();
    
    gc.SetPenStyle(CGraphicsContext::ENullPen);
	gc.SetBrushColor(KRgbWhite);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
}

TKeyResponse CUUListBoxContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
{
    if ( iListBox )
		return iListBox->OfferKeyEventL( aKeyEvent, aType );

	return EKeyWasNotConsumed;
}

void CUUListBoxContainer::HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType )
{
}

void CUUListBoxContainer::ActivateListBox()
{
	if ( iListBox ) 
	{
		iListBox->ActivateL();
		UpdateScrollBar( iListBox );
		ShowListBox();
	}
}

void CUUListBoxContainer::ShowListBox()
{
	if ( iListBox ) 
	{
		iListBox->MakeVisible( ETrue );
		iListBox->SetFocus( ETrue );
		iListBox->DrawNow();
	}
}

void CUUListBoxContainer::HideListBox()
{
	if ( iListBox ) 
	{
		iListBox->MakeVisible( EFalse );
		iListBox->SetFocus( EFalse );
	}
}

// ----------------------------------------------------------------------------
// void CUUListBoxContainer::CreateScrollbarL( CEikListBox* aListBox )
// Creates scrollbar.
// ----------------------------------------------------------------------------
//
void CUUListBoxContainer::CreateScrollbarL( CEikListBox* aListBox )
{
    if ( aListBox )
    {
        // Creates scrollbar.
        aListBox->CreateScrollBarFrameL( ETrue );
        aListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
    }
}

// ----------------------------------------------------------------------------
// void CUUListBoxContainer::UpdateScrollbarL( CEikListBox* aListBox )
// Creates scrollbar.
// ----------------------------------------------------------------------------
//
void CUUListBoxContainer::UpdateScrollBar( CEikListBox* aListBox )
{
	if ( aListBox )
    {   
		TInt pos( aListBox->View()->CurrentItemIndex() );
		if ( aListBox->ScrollBarFrame() )
        {
	        aListBox->ScrollBarFrame()->MoveVertThumbTo( pos );
        }
    }
}

void CUUListBoxContainer::SetListBoxFont( CFont* aFont )
{
	iFont = aFont;
}

void CUUListBoxContainer::SetListBoxModel( CUUListBoxModel* aModel )
{
	iModel = aModel;
}


void CUUListBoxContainer::Update()
{
	if ( iListBox )
		iListBox->Update();
}

⌨️ 快捷键说明

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