214 if (charFormat.iFontSpec.iFontStyle.Posture() == EPostureItalic) |
214 if (charFormat.iFontSpec.iFontStyle.Posture() == EPostureItalic) |
215 { |
215 { |
216 charMask.SetAttrib(EAttFontPosture); |
216 charMask.SetAttrib(EAttFontPosture); |
217 } |
217 } |
218 |
218 |
219 // when we set the new font color also changes. So we have to set the color again. |
219 TRgb color(0); |
220 if (!iTextColor) |
220 TInt err(KErrNone); |
221 { |
221 |
222 TRgb color; |
222 if (HasHighlight()) |
223 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), color, |
223 { |
224 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6); |
224 err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance() |
225 charFormat.iFontPresentation.iTextColor = color; |
225 , color |
226 charMask.SetAttrib(EAttColor); |
226 , KAknsIIDQsnTextColors |
227 } |
227 , KHighlightedTextColor); |
228 else |
228 if (err == KErrNone) |
|
229 { |
|
230 charFormat.iFontPresentation.iTextColor = color; |
|
231 charMask.SetAttrib(EAttColor); |
|
232 } |
|
233 } |
|
234 else if (iTextColor) |
229 { |
235 { |
230 charFormat.iFontPresentation.iTextColor = GetForeground(); |
236 charFormat.iFontPresentation.iTextColor = GetForeground(); |
231 charMask.SetAttrib(EAttColor); |
237 charMask.SetAttrib(EAttColor); |
|
238 } |
|
239 else |
|
240 { |
|
241 err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance() |
|
242 , color |
|
243 , KAknsIIDQsnTextColors |
|
244 , KNonHighlightedTextColor); |
|
245 if (err == KErrNone) |
|
246 { |
|
247 charFormat.iFontPresentation.iTextColor = color; |
|
248 charMask.SetAttrib(EAttColor); |
|
249 } |
232 } |
250 } |
233 |
251 |
234 if (iStyle & KSwtStyleSingle) |
252 if (iStyle & KSwtStyleSingle) |
235 { |
253 { |
236 CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(charFormat, charMask); |
254 CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(charFormat, charMask); |
285 // --------------------------------------------------------------------------- |
303 // --------------------------------------------------------------------------- |
286 // |
304 // |
287 void CSwtTextBase::SetForegroundL(const MSwtColor* aColor) |
305 void CSwtTextBase::SetForegroundL(const MSwtColor* aColor) |
288 { |
306 { |
289 ASwtControlBase::DoSetForegroundL(aColor); |
307 ASwtControlBase::DoSetForegroundL(aColor); |
290 TRgb color(aColor ? aColor->RgbValue() : |
308 |
291 iDisplay.CoeEnv()->Color(EColorControlText)); |
309 iTextColor = ETrue; |
292 if (iEditor) |
310 if (!aColor) |
|
311 { |
|
312 iTextColor = EFalse; |
|
313 } |
|
314 else if (iEditor) |
293 { |
315 { |
294 TCharFormat charFormat; |
316 TCharFormat charFormat; |
295 TCharFormatMask charMask; |
317 TCharFormatMask charMask; |
296 charFormat.iFontPresentation.iTextColor=color; |
318 charFormat.iFontPresentation.iTextColor = aColor->RgbValue(); |
297 charMask.SetAttrib(EAttColor); |
319 charMask.SetAttrib(EAttColor); |
298 static_cast<CGlobalText*>(iEditor->Text())-> |
320 static_cast<CGlobalText*>(iEditor->Text())-> |
299 ApplyCharFormatL(charFormat, charMask, 0, iEditor->TextLength()); |
321 ApplyCharFormatL(charFormat, charMask, 0, iEditor->TextLength()); |
300 iTextColor = ETrue; |
322 } |
301 } |
323 |
|
324 UpdateTextColor(); |
302 Redraw(); |
325 Redraw(); |
303 } |
326 } |
304 |
327 |
305 void CSwtTextBase::SetBounds(const TRect& aRect) |
328 void CSwtTextBase::SetBounds(const TRect& aRect) |
306 { |
329 { |
341 { |
364 { |
342 fep->HandleDestructionOfFocusedItem(); |
365 fep->HandleDestructionOfFocusedItem(); |
343 } |
366 } |
344 } |
367 } |
345 return ASwtScrollableBase::Dispose(); |
368 return ASwtScrollableBase::Dispose(); |
|
369 } |
|
370 |
|
371 TInt CSwtTextBase::PressBackgroundPolicy() const |
|
372 { |
|
373 return EPressBackground; |
|
374 } |
|
375 |
|
376 void CSwtTextBase::UpdateTextColor() |
|
377 { |
|
378 if (iEditor) |
|
379 { |
|
380 TCharFormat charFormat; |
|
381 TCharFormatMask charMask; |
|
382 TRgb color(0); |
|
383 TInt err(KErrNone); |
|
384 |
|
385 if (HasHighlight()) |
|
386 { |
|
387 // Highlighted foreground color, overrides all others. |
|
388 err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance() |
|
389 , color |
|
390 , KAknsIIDQsnTextColors |
|
391 , KHighlightedTextColor); |
|
392 if (err == KErrNone) |
|
393 { |
|
394 charFormat.iFontPresentation.iTextColor = color; |
|
395 } |
|
396 } |
|
397 else if (iTextColor) |
|
398 { |
|
399 // Custom foreground color, overrides the default. |
|
400 charFormat.iFontPresentation.iTextColor = GetForeground(); |
|
401 } |
|
402 else |
|
403 { |
|
404 // Default foreground color. |
|
405 err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance() |
|
406 , color |
|
407 , KAknsIIDQsnTextColors |
|
408 , KNonHighlightedTextColor); |
|
409 if (err == KErrNone) |
|
410 { |
|
411 charFormat.iFontPresentation.iTextColor = color; |
|
412 } |
|
413 } |
|
414 |
|
415 charMask.SetAttrib(EAttColor); |
|
416 TRAP_IGNORE(static_cast<CGlobalText*>(iEditor->Text())-> |
|
417 ApplyCharFormatL(charFormat, charMask, 0, iEditor->TextLength())); |
|
418 } |
|
419 } |
|
420 |
|
421 void CSwtTextBase::HandleHighlightChange() |
|
422 { |
|
423 UpdateTextColor(); |
346 } |
424 } |
347 |
425 |
348 // --------------------------------------------------------------------------- |
426 // --------------------------------------------------------------------------- |
349 // CSwtTextBase::ComputeDelta |
427 // CSwtTextBase::ComputeDelta |
350 // --------------------------------------------------------------------------- |
428 // --------------------------------------------------------------------------- |
904 if (iVScrollBarGrabsPointerEvents && vsb) |
984 if (iVScrollBarGrabsPointerEvents && vsb) |
905 { |
985 { |
906 vsb->HandlePointerEventL(aPointerEvent); |
986 vsb->HandlePointerEventL(aPointerEvent); |
907 } |
987 } |
908 |
988 |
|
989 TBool forward(EFalse); |
|
990 TPointerEvent pointerEvent(aPointerEvent); |
|
991 |
909 // Edwin tap. Button1Up after the long tap is not forwarded to the editor |
992 // Edwin tap. Button1Up after the long tap is not forwarded to the editor |
910 if (!(aPointerEvent.iType == TPointerEvent::EButton1Up |
993 if (!(aPointerEvent.iType == TPointerEvent::EButton1Up |
911 && (iDisplay.RevertPointerEvent() || !hit)) |
994 && (iDisplay.RevertPointerEvent() || !hit)) |
912 && !iVScrollBarGrabsPointerEvents |
995 && !iVScrollBarGrabsPointerEvents |
913 && !iIgnorePointerDown) |
996 && !iIgnorePointerDown) |
914 { |
997 { |
915 TPointerEvent pointerEvent(aPointerEvent); |
|
916 |
|
917 // If clicking on margins, move the pointer event. |
998 // If clicking on margins, move the pointer event. |
918 TRect viewRect(iEditor->TextView()->ViewRect()); |
999 TRect viewRect(iEditor->TextView()->ViewRect()); |
919 TRect viewRectWithoutMargins(viewRect); |
1000 TRect viewRectWithoutMargins(viewRect); |
920 viewRectWithoutMargins.Shrink(2, 2); // well inside the edges |
1001 viewRectWithoutMargins.Shrink(2, 2); // well inside the edges |
921 |
1002 |
965 { |
1046 { |
966 iPressed = hit && !iVScrollBarGrabsPointerEvents && !isActiveSplitEditor; |
1047 iPressed = hit && !iVScrollBarGrabsPointerEvents && !isActiveSplitEditor; |
967 } |
1048 } |
968 |
1049 |
969 if (pressed != iPressed) |
1050 if (pressed != iPressed) |
970 Redraw(); |
1051 { |
|
1052 GetShell().UpdateHighlight(ETrue); // draw now |
|
1053 } |
971 #endif |
1054 #endif |
972 |
1055 |
973 #ifndef RD_JAVA_S60_RELEASE_9_2 |
1056 #ifndef RD_JAVA_S60_RELEASE_9_2 |
974 // We got a pointer event, so any subsequent events should not be ignored. |
1057 // We got a pointer event, so any subsequent events should not be ignored. |
975 iIgnorePointerDown = EFalse; |
1058 iIgnorePointerDown = EFalse; |
976 #endif // RD_JAVA_S60_RELEASE_9_2 |
1059 #endif // RD_JAVA_S60_RELEASE_9_2 |
|
1060 |
|
1061 // Forwarding this late due to splitview + pressed flicker issues. |
|
1062 if (forward) |
|
1063 { |
|
1064 iEditor->HandlePointerEventL(pointerEvent); |
|
1065 } |
977 |
1066 |
978 PostMouseEventL(aPointerEvent); |
1067 PostMouseEventL(aPointerEvent); |
979 } |
1068 } |
980 #else //RD_SCALABLE_UI_V2 |
1069 #else //RD_SCALABLE_UI_V2 |
981 void CSwtTextBase::HandlePointerEventL( |
1070 void CSwtTextBase::HandlePointerEventL( |
1173 #endif // RD_JAVA_S60_RELEASE_9_2 |
1262 #endif // RD_JAVA_S60_RELEASE_9_2 |
1174 return ASwtControlBase::SetSwtFocus(aReason); |
1263 return ASwtControlBase::SetSwtFocus(aReason); |
1175 } |
1264 } |
1176 |
1265 |
1177 // --------------------------------------------------------------------------- |
1266 // --------------------------------------------------------------------------- |
1178 // CSwtTextBase::FocusBackgroundPolicy |
|
1179 // From MSwtControl |
|
1180 // While background color is set, the editor's control context must be null, |
|
1181 // otherwise there will be ugly background drawing problems while typing. |
|
1182 // --------------------------------------------------------------------------- |
|
1183 // |
|
1184 TInt CSwtTextBase::FocusBackgroundPolicy() const |
|
1185 { |
|
1186 if (!IsDefaultBackgroundUse()) |
|
1187 { |
|
1188 return EEmbeddedFocusBackground; |
|
1189 } |
|
1190 else |
|
1191 { |
|
1192 return ASwtControlBase::FocusBackgroundPolicy(); |
|
1193 } |
|
1194 }; |
|
1195 |
|
1196 // --------------------------------------------------------------------------- |
|
1197 // CSwtTextBase::ClientRect |
1267 // CSwtTextBase::ClientRect |
1198 // From MSwtControl |
1268 // From MSwtControl |
1199 // --------------------------------------------------------------------------- |
1269 // --------------------------------------------------------------------------- |
1200 // |
1270 // |
1201 TRect CSwtTextBase::ClientRect() const |
1271 TRect CSwtTextBase::ClientRect() const |