101 // |
100 // |
102 void CSmileyIconRecord::HandleTextDelete( TInt aStart, TInt aLength ) |
101 void CSmileyIconRecord::HandleTextDelete( TInt aStart, TInt aLength ) |
103 { |
102 { |
104 DeleteIconsIn( aStart, aLength ); |
103 DeleteIconsIn( aStart, aLength ); |
105 TInt index( FirstIndexAfter( aStart ) ); |
104 TInt index( FirstIndexAfter( aStart ) ); |
106 TInt count( iIconArray.Count() ); |
105 for ( ; index != KErrNotFound && index < iIconArray.Count(); index++ ) |
107 for ( ; index != KErrNotFound && index < count; index++ ) |
|
108 { |
106 { |
109 TInt newPos( iIconArray[index]->DocPos() - aLength ); |
107 TInt newPos( iIconArray[index]->DocPos() - aLength ); |
110 iIconArray[index]->SetDocPos( newPos ); |
108 iIconArray[index]->SetDocPos( newPos ); |
111 } |
109 } |
112 } |
110 } |
116 // --------------------------------------------------------------------------- |
114 // --------------------------------------------------------------------------- |
117 // |
115 // |
118 void CSmileyIconRecord::HandleTextInsert( TInt aStart, TInt aLength ) |
116 void CSmileyIconRecord::HandleTextInsert( TInt aStart, TInt aLength ) |
119 { |
117 { |
120 TInt index( FirstIndexAfter( aStart ) ); |
118 TInt index( FirstIndexAfter( aStart ) ); |
121 TInt count( iIconArray.Count() ); |
119 for ( ; index != KErrNotFound && index < iIconArray.Count(); index++ ) |
122 for ( ; index != KErrNotFound && index < count; index++ ) |
|
123 { |
120 { |
124 TInt newPos( iIconArray[index]->DocPos() + aLength ); |
121 TInt newPos( iIconArray[index]->DocPos() + aLength ); |
125 iIconArray[index]->SetDocPos( newPos ); |
122 iIconArray[index]->SetDocPos( newPos ); |
126 } |
123 } |
127 } |
124 } |
131 // --------------------------------------------------------------------------- |
128 // --------------------------------------------------------------------------- |
132 // |
129 // |
133 CSmileyIcon* CSmileyIconRecord::SmileyIconAtPos( TInt aDocPos ) |
130 CSmileyIcon* CSmileyIconRecord::SmileyIconAtPos( TInt aDocPos ) |
134 { |
131 { |
135 TInt count( iIconArray.Count() ); |
132 TInt count( iIconArray.Count() ); |
136 for ( TInt i( 0 ); i < count; i++ ) |
133 for ( TInt i( 0 ); i < iIconArray.Count(); i++ ) |
137 { |
134 { |
138 CSmileyIcon* icon( iIconArray[i] ); |
135 CSmileyIcon* icon( iIconArray[i] ); |
139 if ( icon->DocPos() <= aDocPos && |
136 if ( iIconArray[i]->DocPos() <= aDocPos && |
140 icon->DocPos() + icon->SmileyLength() > aDocPos ) |
137 iIconArray[i]->DocPos() + iIconArray[i]->SmileyLength() > aDocPos ) |
141 { |
138 { |
142 return iIconArray[i]; |
139 return iIconArray[i]; |
143 } |
140 } |
144 } |
141 } |
145 return NULL; |
142 return NULL; |
146 } |
143 } |
147 |
144 |
148 // --------------------------------------------------------------------------- |
145 // --------------------------------------------------------------------------- |
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 // --------------------------------------------------------------------------- |
|
169 // CSmileyIconRecord::SmileyRange |
146 // CSmileyIconRecord::SmileyRange |
170 // --------------------------------------------------------------------------- |
147 // --------------------------------------------------------------------------- |
171 // |
148 // |
172 void CSmileyIconRecord::CancelSelection() |
149 void CSmileyIconRecord::CancelSelection() |
173 { |
150 { |
174 TInt count( iIconArray.Count() ); |
151 for ( TInt i( 0 ); i < iIconArray.Count(); i++ ) |
175 for ( TInt i( 0 ); i < count; i++ ) |
|
176 { |
152 { |
177 iIconArray[i]->EnableHighlight( EFalse ); |
153 iIconArray[i]->EnableHighlight( EFalse ); |
178 } |
154 } |
179 } |
155 } |
180 |
156 |
242 // |
218 // |
243 TInt CSmileyIconRecord::FirstIndexAfter( TInt aDocPos, TInt aSearchStart ) |
219 TInt CSmileyIconRecord::FirstIndexAfter( TInt aDocPos, TInt aSearchStart ) |
244 { |
220 { |
245 TInt i = ( aSearchStart < 0 || aSearchStart >= iIconArray.Count() ? 0 : |
221 TInt i = ( aSearchStart < 0 || aSearchStart >= iIconArray.Count() ? 0 : |
246 aSearchStart ); |
222 aSearchStart ); |
247 TInt count( iIconArray.Count() ); |
223 for ( ; i < iIconArray.Count(); i++ ) |
248 for ( ; i < count; i++ ) |
|
249 { |
224 { |
250 if ( iIconArray[i]->DocPos() >= aDocPos ) |
225 if ( iIconArray[i]->DocPos() >= aDocPos ) |
251 { |
226 { |
252 return i; |
227 return i; |
253 } |
228 } |
259 // CSmileyIconRecord::InsertIconAtL |
234 // CSmileyIconRecord::InsertIconAtL |
260 // --------------------------------------------------------------------------- |
235 // --------------------------------------------------------------------------- |
261 // |
236 // |
262 TInt CSmileyIconRecord::FirstIndexIn( TInt aStart, TInt aLength ) |
237 TInt CSmileyIconRecord::FirstIndexIn( TInt aStart, TInt aLength ) |
263 { |
238 { |
264 TInt count( iIconArray.Count() ); |
239 for ( TInt i( 0 ); i < iIconArray.Count(); i++ ) |
265 for ( TInt i( 0 ); i < count; i++ ) |
|
266 { |
240 { |
267 if ( iIconArray[i]->DocPos() < aStart + aLength && |
241 if ( iIconArray[i]->DocPos() < aStart + aLength && |
268 iIconArray[i]->EndPos() > aStart ) |
242 iIconArray[i]->EndPos() > aStart ) |
269 { |
243 { |
270 return i; |
244 return i; |