messagingappbase/msgeditor/viewsrc/MsgControlArray.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  MsgControlArray implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // ========== INCLUDE FILES ================================
       
    21 
       
    22 #include "MsgControlArray.h"               // for CMsgControlArray
       
    23 
       
    24 // ========== EXTERNAL DATA STRUCTURES =====================
       
    25 
       
    26 // ========== EXTERNAL FUNCTION PROTOTYPES =================
       
    27 
       
    28 // ========== CONSTANTS ====================================
       
    29 
       
    30 // ========== MACROS =======================================
       
    31 
       
    32 // ========== LOCAL CONSTANTS AND MACROS ===================
       
    33 
       
    34 // ========== MODULE DATA STRUCTURES =======================
       
    35 
       
    36 // ========== LOCAL FUNCTION PROTOTYPES ====================
       
    37 
       
    38 // ========== LOCAL FUNCTIONS ==============================
       
    39 
       
    40 // ========== MEMBER FUNCTIONS =============================
       
    41 
       
    42 // ---------------------------------------------------------
       
    43 // CMsgControlArray::CMsgControlArray
       
    44 //
       
    45 // Constructor.
       
    46 // ---------------------------------------------------------
       
    47 //
       
    48 CMsgControlArray::CMsgControlArray( TInt aGranularity )
       
    49     : CArrayPtrFlat<CMsgBaseControl>( aGranularity )
       
    50     {
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------
       
    54 // CMsgControlArray::~CMsgControlArray
       
    55 //
       
    56 // Destructor.
       
    57 // ---------------------------------------------------------
       
    58 //
       
    59 CMsgControlArray::~CMsgControlArray()
       
    60     {
       
    61     ResetAndDestroy();
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------
       
    65 // CMsgControlArray::ComponentIndexFromId
       
    66 //
       
    67 // Finds a control from the array based on control id aControlId and returns
       
    68 // its array index.
       
    69 // ---------------------------------------------------------
       
    70 //
       
    71 TInt CMsgControlArray::ComponentIndexFromId( TInt aControlId ) const
       
    72     {
       
    73     const TInt count = Count();
       
    74     TInt ii = 0;
       
    75 
       
    76     FOREVER
       
    77         {
       
    78         if ( ii == count )
       
    79             {
       
    80             return ( KErrNotFound );
       
    81             }
       
    82 
       
    83         if ( (*this)[ii]->ControlId() == aControlId )
       
    84             {
       
    85             break;
       
    86             }
       
    87         ii++;
       
    88         }
       
    89 
       
    90     return ( ii );
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // CMsgControlArray::DeleteComponent
       
    95 //
       
    96 // Deletes a control from the array.
       
    97 // ---------------------------------------------------------
       
    98 //
       
    99 void CMsgControlArray::DeleteComponent( TInt aIndex )
       
   100     {
       
   101     delete( (*this)[aIndex] );
       
   102     Delete( aIndex );
       
   103     }
       
   104 
       
   105 //  End of File