uifw/EikStd/coctlsrc/smileyiconrecord.cpp
branchRCL_3
changeset 38 c52421ed5f07
parent 0 2f259fa3e83a
child 55 aecbbf00d063
equal deleted inserted replaced
29:a8834a2e9a96 38:c52421ed5f07
    82     if ( !aIcon )
    82     if ( !aIcon )
    83         {
    83         {
    84         return;
    84         return;
    85         }
    85         }
    86     TInt index( 0 );
    86     TInt index( 0 );
    87     for ( ; index < iIconArray.Count(); index++ )
    87     TInt count( iIconArray.Count() );
       
    88     for ( ; index < count; index++ )
    88         {
    89         {
    89         if ( iIconArray[index]->DocPos() >= aIcon->DocPos() )
    90         if ( iIconArray[index]->DocPos() >= aIcon->DocPos() )
    90             {
    91             {
    91             break;
    92             break;
    92             }
    93             }
   100 //
   101 //
   101 void CSmileyIconRecord::HandleTextDelete( TInt aStart, TInt aLength )
   102 void CSmileyIconRecord::HandleTextDelete( TInt aStart, TInt aLength )
   102     {
   103     {
   103     DeleteIconsIn( aStart, aLength );
   104     DeleteIconsIn( aStart, aLength );
   104     TInt index( FirstIndexAfter( aStart ) );
   105     TInt index( FirstIndexAfter( aStart ) );
   105     for ( ; index != KErrNotFound && index < iIconArray.Count(); index++ )
   106     TInt count( iIconArray.Count() );
       
   107     for ( ; index != KErrNotFound && index < count; index++ )
   106         {
   108         {
   107         TInt newPos( iIconArray[index]->DocPos() - aLength );
   109         TInt newPos( iIconArray[index]->DocPos() - aLength );
   108         iIconArray[index]->SetDocPos( newPos );
   110         iIconArray[index]->SetDocPos( newPos );
   109         }
   111         }
   110     }
   112     }
   114 // ---------------------------------------------------------------------------
   116 // ---------------------------------------------------------------------------
   115 //
   117 //
   116 void CSmileyIconRecord::HandleTextInsert( TInt aStart, TInt aLength )
   118 void CSmileyIconRecord::HandleTextInsert( TInt aStart, TInt aLength )
   117     {
   119     {
   118     TInt index( FirstIndexAfter( aStart ) );
   120     TInt index( FirstIndexAfter( aStart ) );
   119     for ( ; index != KErrNotFound && index < iIconArray.Count(); index++ )
   121     TInt count( iIconArray.Count() );
       
   122     for ( ; index != KErrNotFound && index < count; index++ )
   120         {
   123         {
   121         TInt newPos( iIconArray[index]->DocPos() + aLength );
   124         TInt newPos( iIconArray[index]->DocPos() + aLength );
   122         iIconArray[index]->SetDocPos( newPos );
   125         iIconArray[index]->SetDocPos( newPos );
   123         }
   126         }
   124     }
   127     }
   128 // ---------------------------------------------------------------------------
   131 // ---------------------------------------------------------------------------
   129 //
   132 //
   130 CSmileyIcon* CSmileyIconRecord::SmileyIconAtPos( TInt aDocPos )
   133 CSmileyIcon* CSmileyIconRecord::SmileyIconAtPos( TInt aDocPos )
   131     {
   134     {
   132     TInt count( iIconArray.Count() );
   135     TInt count( iIconArray.Count() );
   133     for ( TInt i( 0 ); i < iIconArray.Count(); i++ )
   136     for ( TInt i( 0 ); i < count; i++ )
   134         {
   137         {
   135         CSmileyIcon* icon( iIconArray[i] );
   138         CSmileyIcon* icon( iIconArray[i] );
   136         if ( iIconArray[i]->DocPos() <= aDocPos && 
   139         if ( icon->DocPos() <= aDocPos && 
   137             iIconArray[i]->DocPos() + iIconArray[i]->SmileyLength() > aDocPos )
   140              icon->DocPos() + icon->SmileyLength() > aDocPos )
   138             {
   141             {
   139             return iIconArray[i];
   142             return iIconArray[i];
   140             }
   143             }
   141         }
   144         }
   142     return NULL;
   145     return NULL;
   143     }
   146     }
   144 
   147 
   145 // ---------------------------------------------------------------------------
   148 // ---------------------------------------------------------------------------
       
   149 // CSmileyIconRecord::DeleteIconAtPos
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 void CSmileyIconRecord::DeleteIconAtPos( TInt aDocPos )
       
   153     {
       
   154     TInt count( iIconArray.Count() );
       
   155     for ( TInt i( 0 ); i < count; i++ )
       
   156         {
       
   157         CSmileyIcon* icon( iIconArray[i] );
       
   158         if ( icon->DocPos() <= aDocPos && 
       
   159              icon->DocPos() + icon->SmileyLength() > aDocPos )
       
   160             {
       
   161             iIconArray.Remove( i );
       
   162             delete icon;            
       
   163             break;
       
   164             }
       
   165         }
       
   166     }
       
   167 
       
   168 // ---------------------------------------------------------------------------
   146 // CSmileyIconRecord::SmileyRange
   169 // CSmileyIconRecord::SmileyRange
   147 // ---------------------------------------------------------------------------
   170 // ---------------------------------------------------------------------------
   148 //
   171 //
   149 void CSmileyIconRecord::CancelSelection()
   172 void CSmileyIconRecord::CancelSelection()
   150     {
   173     {
   151     for ( TInt i( 0 ); i < iIconArray.Count(); i++ )
   174     TInt count( iIconArray.Count() );
       
   175     for ( TInt i( 0 ); i < count; i++ )
   152         {
   176         {
   153         iIconArray[i]->EnableHighlight( EFalse );
   177         iIconArray[i]->EnableHighlight( EFalse );
   154         }
   178         }
   155     }
   179     }
   156 
   180 
   218 //
   242 //
   219 TInt CSmileyIconRecord::FirstIndexAfter( TInt aDocPos, TInt aSearchStart )
   243 TInt CSmileyIconRecord::FirstIndexAfter( TInt aDocPos, TInt aSearchStart )
   220     {
   244     {
   221     TInt i = ( aSearchStart < 0 || aSearchStart >= iIconArray.Count() ? 0 : 
   245     TInt i = ( aSearchStart < 0 || aSearchStart >= iIconArray.Count() ? 0 : 
   222         aSearchStart );
   246         aSearchStart );
   223     for ( ; i < iIconArray.Count(); i++ )
   247     TInt count( iIconArray.Count() );
       
   248     for ( ; i < count; i++ )
   224         {
   249         {
   225         if ( iIconArray[i]->DocPos() >= aDocPos )
   250         if ( iIconArray[i]->DocPos() >= aDocPos )
   226             {
   251             {
   227             return i;            
   252             return i;            
   228             }
   253             }
   234 // CSmileyIconRecord::InsertIconAtL
   259 // CSmileyIconRecord::InsertIconAtL
   235 // ---------------------------------------------------------------------------
   260 // ---------------------------------------------------------------------------
   236 //
   261 //
   237 TInt CSmileyIconRecord::FirstIndexIn( TInt aStart, TInt aLength )
   262 TInt CSmileyIconRecord::FirstIndexIn( TInt aStart, TInt aLength )
   238     {
   263     {
   239     for ( TInt i( 0 ); i < iIconArray.Count(); i++ )
   264     TInt count( iIconArray.Count() );
       
   265     for ( TInt i( 0 ); i < count; i++ )
   240         {
   266         {
   241         if ( iIconArray[i]->DocPos() < aStart + aLength && 
   267         if ( iIconArray[i]->DocPos() < aStart + aLength && 
   242             iIconArray[i]->EndPos() > aStart )
   268             iIconArray[i]->EndPos() > aStart )
   243             {
   269             {
   244             return i;
   270             return i;