sdkcreationmw/sdkruntimes/GuiLauncher/src/EcmtGuiLogContainer.cpp
author Shabe Razvi <shaber@symbian.org>
Thu, 04 Nov 2010 17:22:05 +0000
changeset 4 b3b823debf08
parent 0 b26acd06ea60
permissions -rw-r--r--
Workaround for Bug 3917 - CWinsockInterface::DataSent calls NotifyDataSent which is not implemented.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     1
/*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     2
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     3
* All rights reserved.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     8
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     9
* Initial Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    11
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    12
* Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    13
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    14
* Description:  Container class for log view.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    15
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    16
*/
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    17
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    18
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    19
#include <EcmtGui.rsg>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    20
#include <stringloader.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    21
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    22
#include "EcmtGuiLogContainer.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    23
#include "EcmtGuiAppUi.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    24
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    25
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    26
// ======== MEMBER FUNCTIONS ========
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    27
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    28
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    29
// C++ default constructor
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    30
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    31
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    32
CEcmtGuiLogContainer::CEcmtGuiLogContainer( CDesCArrayFlat& aMessageList ) 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    33
  : iMessageList( aMessageList )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    34
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    35
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    36
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    37
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    38
// Destructor
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    39
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    40
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    41
CEcmtGuiLogContainer::~CEcmtGuiLogContainer()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    42
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    43
    if( iListBox )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    44
      delete iListBox;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    45
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    46
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    47
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    48
// Symbian 2nd phase constructor can leave.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    49
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    50
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    51
void CEcmtGuiLogContainer::ConstructL(const TRect& aRect)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    52
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    53
    iAutoScroll = ETrue;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    54
    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    55
    CreateWindowL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    56
       
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    57
    SetRect( aRect );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    58
    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    59
    iListBox = new (ELeave) CAknDoubleStyleListBox(); 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    60
    iListBox->SetContainerWindowL( *this ); 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    61
    iListBox->ConstructL( NULL, EAknListBoxViewerFlags );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    62
    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    63
    // Screate scroll bars
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    64
    iListBox->CreateScrollBarFrameL( ETrue );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    65
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    66
        CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    67
	  
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    68
    // Give it to the control
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    69
    iListBox->Model()->SetItemTextArray( &iMessageList );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    70
    iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    71
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    72
    iListBox->SetRect( aRect );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    73
	
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    74
    // Activate the window, which makes it ready to be drawn
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    75
    iListBox->ActivateL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    76
    ActivateL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    77
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    78
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    79
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    80
// Loads message from resource and calls AddMessageL.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    81
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    82
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    83
void CEcmtGuiLogContainer::LogMessageL( TInt aMsgResId )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    84
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    85
    TBuf<KMaxLogMsgLen> msg;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    86
    StringLoader::Load( msg, aMsgResId );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    87
    LogMessageL( msg );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    88
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    89
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    90
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    91
// Calls AddMessageL
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    92
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    93
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    94
void CEcmtGuiLogContainer::LogMessageL( const TDesC& aMsg )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    95
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    96
    iLastMsg.SetLength(0);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    97
    _LIT( KTimeFormat, "\t%:0%J%:1%T%:2%S% " );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    98
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    99
    TTime curTime;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   100
    curTime.HomeTime();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   101
    curTime.FormatL( iLastMsg, KTimeFormat );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   102
    iLastMsg.Append( aMsg );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   103
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   104
    AddMessageL(iLastMsg, iAutoScroll);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   105
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   106
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   107
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   108
// Adds message to the listbox and to the message list iMessageList.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   109
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   110
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   111
void CEcmtGuiLogContainer::AddMessageL( const TDesC& aText, TBool aAutoScroll )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   112
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   113
    iMessageList.AppendL( aText );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   114
    iListBox->HandleItemAdditionL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   115
    if ( aAutoScroll )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   116
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   117
    	iListBox->SetCurrentItemIndexAndDraw( iMessageList.MdcaCount() - 1 );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   118
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   119
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   120
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   121
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   122
// Clears logs from the listbox.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   123
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   124
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   125
void CEcmtGuiLogContainer::ClearMessageListL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   126
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   127
    iListBox->HandleItemRemovalL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   128
    iListBox->Reset();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   129
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   130
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   131
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   132
// From class CCoeControl.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   133
// Draws the control.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   134
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   135
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   136
void CEcmtGuiLogContainer::Draw(const TRect& /*aRect*/) const
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   137
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   138
      
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   139
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   140
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   141
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   142
// From class CCoeControl.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   143
// Responds to changes to the size and position of the contents of this 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   144
// control.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   145
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   146
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   147
void CEcmtGuiLogContainer::SizeChanged()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   148
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   149
    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   150
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   151
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   152
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   153
// From class CCoeControl.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   154
// Responds to changes to the size and position of the contents of this 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   155
// control.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   156
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   157
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   158
TInt CEcmtGuiLogContainer::CountComponentControls() const
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   159
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   160
   	return 1;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   161
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   162
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   163
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   164
// From class CCoeControl.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   165
// Gets an indexed component of a compound control.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   166
// ---------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   167
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   168
CCoeControl* CEcmtGuiLogContainer::ComponentControl(TInt aIndex) const
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   169
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   170
    switch( aIndex )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   171
        {                
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   172
        case 0:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   173
            return iListBox; 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   174
        default:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   175
            return NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   176
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   177
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   178