📄 sabberrostercontainer.cpp
字号:
/*
* ============================================================================
* Name : CSabberRosterContainer from SabberRosterContainer.h
* Part of : Sabber
* Created : 2004-12-9 by Xie Tian Lu
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version : 0.1
* Copyright: (c) Xie Tian Lu Http://sabber.jabberstudio.org/
* ============================================================================
*/
// INCLUDE FILES
#include "SabberRosterContainer.h"
#include "UUListBox.h"
#include "RosterModel.h"
#include "osaux.h"
#include "SabberAppUi.h"
#include "roster.h"
#include "iconset.h"
#include "listboxicon.h"
_LIT(KArialFont,"Arial");
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CSabberRosterContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CSabberRosterContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
iListBox = 0;
iListBox = new (ELeave) CUUListBox;
if ( iListBox )
{
iListBox->SetListBoxObserver( this );
CUUListItemDrawer* lid = new ( ELeave ) CUUListItemDrawer();
//CFont* font = CUtil::GetFont( KArialFont, 600 );
lid->SetFont( iFont );
iListBox->ConstructL( iModel, lid, this );
iListBox->SetContainerWindowL( *this );
CreateScrollbarL( iListBox );
}
SetRect(aRect);
ActivateL();
}
// Destructor
CSabberRosterContainer::~CSabberRosterContainer()
{
//delete iModel;
delete iListBox;
iListBox = 0;
}
// ---------------------------------------------------------
// CSabberRosterContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CSabberRosterContainer::SizeChanged()
{
// TODO: Add here control resize code etc.
if ( iListBox )
{
TRect gRect = Rect();
gRect.iTl.iY += 21;
gRect.iBr.iY -= 1;
iListBox->SetRect( gRect );
iListBox->CalLayout();
}
}
// ---------------------------------------------------------
// CSabberRosterContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CSabberRosterContainer::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CSabberRosterContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CSabberRosterContainer::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iListBox;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CSabberRosterContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CSabberRosterContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
// TODO: Add your drawing code here
// example code...
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(TRgb(0x80e0e0));
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
gc.SetPenStyle( CGraphicsContext::ESolidPen );
gc.SetPenColor( KRgbGray );
gc.DrawLine( TPoint( 0, aRect.iTl.iY + 19 ), TPoint( 176, aRect.iTl.iY + 19 ) );
gc.DrawLine( TPoint( 0, aRect.iBr.iY - 1 ), TPoint( 176, aRect.iBr.iY - 1 ) );
TInt x = aRect.iTl.iX + 8;
TInt y = aRect.iTl.iY;
switch ( iUi->GetPresence() ) {
case CS_OFFLINE:
iUi->iIconSet->DrawIcon( gc, EJabOffline, x, y );
break;
case CS_ONLINE:
iUi->iIconSet->DrawIcon( gc, EJabOnline, x, y );
break;
case CS_CHAT:
iUi->iIconSet->DrawIcon( gc, EJabChat, x, y );
break;
case CS_AWAY:
iUi->iIconSet->DrawIcon( gc, EJabAway, x, y );
break;
case CS_DND:
iUi->iIconSet->DrawIcon( gc, EJabDND, x, y );
break;
case CS_XA:
iUi->iIconSet->DrawIcon( gc, EJabXA, x, y );
break;
}
gc.UseFont( iFont );
}
// ---------------------------------------------------------
// CSabberRosterContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CSabberRosterContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
// TODO: Add your control event handler code here
}
void CSabberRosterContainer::HandleListBoxEventL(
CEikListBox* aListBox, TListBoxEvent aEventType )
{
}
TKeyResponse CSabberRosterContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
{
TChar charCode(aKeyEvent.iCode);
switch ( charCode ) // The code of key event is...
{
// Switches tab.
case EKeyLeftArrow: // Left key.
case EKeyRightArrow: // Right Key.
return EKeyWasNotConsumed; //iUi->HandleKeyEvent( aKeyEvent, aType );
}
if ( iListBox )
return iListBox->OfferKeyEventL( aKeyEvent, aType );
return EKeyWasNotConsumed;
}
void CSabberRosterContainer::SetAppUi( CSabberAppUi* aUi )
{
iUi = aUi;
}
void CSabberRosterContainer::GetCurItemJid( char* jid )
{
strcpy( jid, "" );
int idx = iListBox->CurrentItemIndex();
if( idx < 0 )
return;
CRosterItem* item = ( CRosterItem* )iModel->GetItemAt( idx );
item->GetJid( jid );
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -