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

📄 uulistitemdrawer.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 "UUListItem.h"
#include "UUListItemDrawer.h"
#include "UUListBoxModel.h"

CUUListItemDrawer::CUUListItemDrawer()
{
}

CUUListItemDrawer::~CUUListItemDrawer()
{
}

void CUUListItemDrawer::SetModel( CUUListBoxModel* aModel )
{
	iModel = aModel;
}

void CUUListItemDrawer::SetItemIndice( TInt cur, TInt top, TInt btm ) 
{
	iCurItemIndex = cur;
	iTopItemIndex = top;
	iBtmItemIndex = btm;
}

void CUUListItemDrawer::SetCurItemExtraHeight( TInt h )
{
	iCurItemExtraHeight = h;
}

void CUUListItemDrawer::ShowCurItemIndex( TBool aBool )
{
	iShowCurItemIndex = aBool;
}

void CUUListItemDrawer::ClearRect( const TRect& aRect ) const
{
	CWindowGc*	gc = Gc();
	gc->SetPenStyle( CGraphicsContext::ENullPen );
	gc->SetBrushColor( KRgbWhite );
	gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
	gc->DrawRect( aRect );
}

void CUUListItemDrawer::DrawFrame(CWindowGc& aGc,const TRect& aRect,TInt /* aFlags */) const
{
    aGc.SetPenStyle(CGraphicsContext::ENullPen);
	aGc.SetBrushColor(KRgbGray);
    aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    aGc.DrawRect(aRect);
}


void CUUListItemDrawer::DrawItem( TInt aItemIndex, 
								  TPoint aItemRectPos, 
								  TBool aItemIsSelected, 
								  TBool aItemIsCurrent, 
								  TBool aViewIsEmphasized, 
								  TBool aViewIsDimmed ) const
{
	if ( aItemIndex > iCurItemIndex ) {
		aItemRectPos.iY += iCurItemExtraHeight;
	}
	
	CListItemDrawer::DrawItem( aItemIndex, aItemRectPos, aItemIsSelected, aItemIsCurrent, aViewIsEmphasized, aViewIsDimmed );
}

void CUUListItemDrawer::DrawCurItemFrame( CWindowGc* gc, TRect aRect ) const
{
	//iMarkColor
	gc->SetPenStyle( CGraphicsContext::ENullPen );
	gc->SetPenColor( KRgbCurItemFrm1 );
	gc->SetBrushColor( KRgbCurItemFrm1 );
	gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
	aRect.SetHeight( aRect.Height() + iCurItemExtraHeight );
	//aRect.Shrink( 0, 1 );
	gc->DrawRect( aRect );

	gc->SetPenStyle( CGraphicsContext::ESolidPen );
	gc->SetPenColor( KRgbCurItemFrm1 );
	gc->DrawLine( TPoint( 0, aRect.iTl.iY ),  TPoint( 176, aRect.iTl.iY ) );
	gc->SetPenColor( KRgbCurItemFrm2 );
	gc->DrawLine( TPoint( 0, aRect.iTl.iY + 1 ),  TPoint( 176, aRect.iTl.iY + 1 ) );
	gc->SetPenStyle( CGraphicsContext::ESolidPen );
	gc->SetPenColor( KRgbCurItemFrm3 );
	gc->DrawLine( TPoint( 0, aRect.iBr.iY - 1 ),  TPoint( 176, aRect.iBr.iY - 1) );
	gc->SetPenColor( KRgbCurItemFrm4 );
	gc->DrawLine( TPoint( 0, aRect.iBr.iY + 0 ),  TPoint( 176, aRect.iBr.iY + 0 ) );
	gc->SetPenColor( KRgbCurItemFrm1 );
	gc->DrawLine( TPoint( 0, aRect.iBr.iY + 1 ),  TPoint( 176, aRect.iBr.iY + 1 ) );

}

void CUUListItemDrawer::DrawActualItem( TInt aItemIndex, 
									   const TRect& aActualItemRect,
									   TBool aItemIsCurrent, 
									   TBool /*aViewIsEmphasized*/,
									   TBool /*aViewIsDimmed*/,
									   TBool /*aItemIsSelected*/ ) const
{
	CWindowGc*	gc = Gc();

	if ( aItemIsCurrent ) {
		DrawCurItemFrame( gc, aActualItemRect );
	} 

	gc->SetPenColor( KRgbCurItemFrm5 );
    gc->SetPenStyle(CGraphicsContext::ENullPen);

	MUUListItem *iItem = iModel->GetItemAt(aItemIndex);

	TRect	rect = aActualItemRect;
	rect.iBr.iY += iCurItemExtraHeight*aItemIsCurrent;
	iItem->ItemDraw( gc, rect, 19, iFont );
	// iItem->ItemDraw( gc, rect, 19 );
}

void CUUListItemDrawer::SetFont(CFont * aFont)
{
	iFont = aFont;
}

⌨️ 快捷键说明

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