Nokia N97 SDK
Example Applications Guide

CChatContainer Class Reference

#include <ChatContainer.h>

Inheritance diagram for CChatContainer:

MLog List of all members.

Detailed Description

CChatContainer container control class.

Definition at line 38 of file ChatContainer.h.


Public Member Functions

  ~CChatContainer ()
TBool  ContainsEntries ()
void  ClearMessageListL ()
void  ShowDataQueryL (const TInt aQueryResourceId, const TInt aTextResourceId, const TInt aPromptResoureId, const TInt aMaxLength, const TBool aDisplayFlag, TDes &aText)
void  LogL (const TDesC &aText)
void  LogL (const TDesC &aText, const TDesC &aExtraText)
void  LogL (const TDesC &aText, TInt aNumber)
TKeyResponse  OfferKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType)
TInt  CountComponentControls () const
CCoeControl *  ComponentControl (TInt aIndex) const

Static Public Member Functions

static CChatContainer *  NewL (const TRect &aRect)
static CChatContainer *  NewLC (const TRect &aRect)

Private Member Functions

void  SizeChanged ()
void  ConstructL (const TRect &aRect)
  CChatContainer ()

Private Attributes

TBool  iDisplayDialog
CAknQueryDialog *  iQueryDialog
CEikLabel *  iLabelResultMessage
CEikTextListBox *  iListBox
CDesCArrayFlat *  iMessageList
TInt  iMsgIndex


Constructor & Destructor Documentation

CChatContainer::~CChatContainer (   ) 
 

Destructor.

Definition at line 104 of file ChatContainer.cpp.

References iListBox.

00105     {
00106     // iMessageList not deleted as it is owned by iListBox->Model()
00107     delete iListBox;
00108     iListBox = NULL;
00109     }

CChatContainer::CChatContainer (   )  [private]
 

CBTPointToPointAppView() Perform the first phase of two phase construction

Definition at line 94 of file ChatContainer.cpp.

00095     {
00096     // no implementation required
00097     }


Member Function Documentation

CChatContainer * CChatContainer::NewL (  const TRect &  aRect  )  [static]
 

NewL() Create a CChatContainer object, which will draw itself to aRect

Parameters:
aRect  the rectangle this view will be drawn to
Returns:
a pointer to the created instance of CChatContainer

Definition at line 29 of file ChatContainer.cpp.

References NewLC().

Referenced by CChatAppUi::ConstructL().

00030     {
00031     CChatContainer* self = CChatContainer::NewLC( aRect );
00032     CleanupStack::Pop( self );
00033     return self;
00034     }

CChatContainer * CChatContainer::NewLC (  const TRect &  aRect  )  [static]
 

NewLC() Create a CChatContainer object, which will draw itself to aRect

Parameters:
aRect  the rectangle this view will be drawn to
Returns:
a pointer to the created instance of CChatContainer

Definition at line 41 of file ChatContainer.cpp.

References ConstructL().

Referenced by NewL().

00042     {
00043     CChatContainer* self = new ( ELeave ) CChatContainer;
00044     CleanupStack::PushL( self );
00045     self->ConstructL( aRect );
00046     return self;
00047     }

TBool CChatContainer::ContainsEntries (   ) 
 

ContainsEntries()

Returns:
ETrue if the list view contains entries

Definition at line 215 of file ChatContainer.cpp.

References iListBox.

00216     {
00217     return iListBox->Model()->NumberOfItems() != 0;
00218     }

void CChatContainer::ClearMessageListL (   ) 
 

ClearMessageListL() Clear the list of messages.

Definition at line 116 of file ChatContainer.cpp.

References iListBox, and iMessageList.

00117     {
00118     iMessageList->Reset();
00119 
00120     iListBox->HandleItemRemovalL();
00121     iListBox->Reset();
00122       
00123     // tell the control about the change
00124     iListBox->HandleItemAdditionL();
00125     }

void CChatContainer::ShowDataQueryL (  const TInt  aQueryResourceId,
const TInt  aTextResourceId,
const TInt  aPromptResoureId,
const TInt  aMaxLength,
const TBool  aDisplayFlag,
TDes &  aText
) 
 

ShowDataQueryL() Show data query.

Parameters:
aQueryResourceId  the id of the query
aTextResourceId  for inial value
aPromptResoureId  for prompt
aMaxLength  sets up the length of the character
aDisplayFlag  sets the query visible
aText  text to be set to the list

Definition at line 226 of file ChatContainer.cpp.

References iDisplayDialog, iListBox, and iMessageList.

00233     {
00234     
00235     iDisplayDialog = ETrue;
00236 
00237     TBuf<KChatTextBufLength> textData;
00238     
00239     if ( aTextResourceId )
00240         {
00241         iCoeEnv->ReadResourceL( textData, aTextResourceId );
00242         }
00243     
00244     CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL(
00245         textData, CAknQueryDialog::ENoTone );
00246     CleanupStack::PushL( dlg );
00247          
00248     if ( aPromptResoureId )
00249         {
00250         TBuf<KChatTextBufLength> prompt;
00251         iCoeEnv->ReadResourceL( prompt, aTextResourceId );
00252         dlg->SetPromptL( prompt );
00253         }
00254 
00255     if ( aMaxLength )
00256         {
00257         dlg->SetMaxLength( aMaxLength );
00258         }
00259         
00260           CleanupStack::Pop( dlg );
00261           TBool answer( dlg->ExecuteLD( aQueryResourceId ) );
00262     
00263     if ( aDisplayFlag && answer )
00264         {
00265         HBufC* buffer = HBufC::NewLC( KMessageHeaderLen + 
00266                                   textData.Length() );
00267 
00268         buffer->Des().Append( '<' );
00269         buffer->Des().Append( '\t' );
00270         buffer->Des().Append( textData );
00271         
00272         // add the message to the list
00273         iMessageList->AppendL( *buffer );
00274         CleanupStack::PopAndDestroy( buffer );
00275       
00276         // tell the control about the change
00277         iListBox->HandleItemAdditionL();
00278         }
00279 
00280     iDisplayDialog = EFalse;
00281   
00282     // get message
00283     aText = textData;
00284     
00285     DrawNow();
00286     }

void CChatContainer::LogL (  const TDesC &  aText  )  [virtual]
 

LogL() Add an entry to the log.

Parameters:
aText  the text of the entry

Implements MLog.

Definition at line 164 of file ChatContainer.cpp.

Referenced by LogL().

00165     {
00166     LogL( aText, KNullDesC );
00167     }

void CChatContainer::LogL (  const TDesC &  aText,
const TDesC &  aExtraText
)  [virtual]
 

LogL() Add an entry to the log.

Parameters:
aText  the text of the entry
aExtraText  extra text to append onto the entry

Implements MLog.

Definition at line 192 of file ChatContainer.cpp.

References iListBox, and iMessageList.

00194     {
00195     HBufC* buffer = HBufC::NewLC( KMessageHeaderLen + aText.Length() +
00196         aExtraText.Length() );
00197 
00198     buffer->Des().Append( aExtraText );
00199     buffer->Des().Append( '\t' );
00200     buffer->Des().Append( aText );
00201     
00202     // add the message to the list
00203     iMessageList->AppendL( *buffer );
00204     CleanupStack::PopAndDestroy( buffer );
00205 
00206     // tell the control about the change
00207     iListBox->HandleItemAdditionL();
00208     }

void CChatContainer::LogL (  const TDesC &  aText,
TInt  aNumber
)  [virtual]
 

LogL() Add an entry to the log.

Parameters:
aText  the text of the entry
aNumber  a number to append onto the entry

Implements MLog.

Definition at line 174 of file ChatContainer.cpp.

References LogL().

00175     {
00176     TBuf<KMessageHeaderLen> numberString;
00177     HBufC* buffer = HBufC::NewLC( KMessageHeaderLen + aText.Length() +
00178         numberString.Length() );
00179     numberString.Num( aNumber );
00180     buffer->Des().Append( aText );
00181     buffer->Des().Append( ' ' );
00182     buffer->Des().Append( numberString );
00183     LogL( buffer->Des(), KNullDesC );
00184     CleanupStack::PopAndDestroy( buffer );
00185     }

TKeyResponse CChatContainer::OfferKeyEventL (  const TKeyEvent &  aKeyEvent,
TEventCode  aType
) 
 

OfferKeyEventL() Offer the key event to the list box

Parameters:
aKeyEvent  the key that caused the event
aType  the type of event that occured
Returns:
indicates whether or not the key event was used by this control

Definition at line 154 of file ChatContainer.cpp.

00155     {
00156     return iListBox->OfferKeyEventL( aKeyEvent, aType );
00157     }

TInt CChatContainer::CountComponentControls (   )  const
 

CountComponentControls() Return the number of component controls

Returns:
the number of component controls

Definition at line 132 of file ChatContainer.cpp.

00133     {
00134     return 1; // Only have one Component
00135     }

CCoeControl * CChatContainer::ComponentControl (  TInt  aIndex  )  const
 

ComponentControl() Return a component control

Parameters:
aIndex  the index of the control to return
Returns:
the specified component control

Definition at line 142 of file ChatContainer.cpp.

References iListBox.

00143     {
00144     __ASSERT_ALWAYS( aIndex == 0, Panic( EChatInvalidControlIndex ) );
00145     return iListBox;    //  Return the component
00146     }

void CChatContainer::SizeChanged (   )  [private]
 

From CoeControl,SizeChanged.

Definition at line 294 of file ChatContainer.cpp.

References iListBox.

00295     { 
00296     if ( iListBox ) 
00297         { 
00298         iListBox-> SetRect( iAvkonAppUi->ApplicationRect() ); 
00299         } 
00300     }

void CChatContainer::ConstructL (  const TRect &  aRect  )  [private]
 

ConstructL() Perform the second phase construction

Parameters:
aRect  the rectangle this view will be drawn to

Definition at line 54 of file ChatContainer.cpp.

References iListBox, and iMessageList.

Referenced by NewLC().

00055     {
00056     // Create a window for this application view
00057     CreateWindowL();
00058 
00059     // Set the windows size
00060     SetRect( aRect );
00061 
00062     // Create a control to display a list of messages
00063     iListBox = new ( ELeave ) CAknSingleNumberStyleListBox;
00064     iListBox->SetContainerWindowL( *this );
00065     iListBox->ConstructL( this, 0 );
00066 
00067     iListBox->SetRect( aRect.Size() );
00068 
00069     iListBox->ActivateL();
00070     iListBox->CreateScrollBarFrameL( ETrue );
00071     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
00072         CEikScrollBarFrame::EOn, 
00073         CEikScrollBarFrame::EAuto );
00074 
00075     // Create an array to hold the messages
00076     iMessageList = new ( ELeave ) CDesCArrayFlat( KMessageListLen );
00077 
00078     // Give it to the control
00079     CTextListBoxModel* model = iListBox->Model();
00080     model->SetItemTextArray( iMessageList );
00081 
00082     // transfer ownership of iMessageList
00083     model->SetOwnershipType( ELbmOwnsItemArray );
00084 
00085     // Activate the window, which makes it ready to be drawn
00086     ActivateL();
00087     }


Member Data Documentation

TBool CChatContainer::iDisplayDialog [private]
 

iDisplayDialog boolean for Display Dialog

Definition at line 182 of file ChatContainer.h.

Referenced by ShowDataQueryL().

CAknQueryDialog* CChatContainer::iQueryDialog [private]
 

iQueryDialog

Definition at line 187 of file ChatContainer.h.

CEikLabel* CChatContainer::iLabelResultMessage [private]
 

iLabelResultMessage

Definition at line 192 of file ChatContainer.h.

CEikTextListBox* CChatContainer::iListBox [private]
 

iListBox the control used to display the results Owned by CCChatContainer

Definition at line 198 of file ChatContainer.h.

Referenced by ClearMessageListL(), ComponentControl(), ConstructL(), ContainsEntries(), LogL(), ShowDataQueryL(), SizeChanged(), and ~CChatContainer().

CDesCArrayFlat* CChatContainer::iMessageList [private]
 

iMessageList the list of messages to display Not owned by CChatContainer

Definition at line 204 of file ChatContainer.h.

Referenced by ClearMessageListL(), ConstructL(), LogL(), and ShowDataQueryL().

TInt CChatContainer::iMsgIndex [private]
 

iMsgIndex the id for the next message in the list

Definition at line 210 of file ChatContainer.h.


The documentation for this class was generated from the following files:

© Nokia 2009

Back to top