66
|
1 |
/*******************************************************************************
|
|
2 |
* Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved. This program and the accompanying materials
|
|
4 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
5 |
* which accompanies this distribution, and is available at
|
|
6 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
7 |
*
|
|
8 |
* Contributors:
|
|
9 |
* Nokia Corporation - S60 implementation
|
|
10 |
*******************************************************************************/
|
|
11 |
|
|
12 |
|
|
13 |
#include <eikedwin.h>
|
|
14 |
#include <txtglobl.h>
|
|
15 |
#include <EIKCOCTL.rsg>
|
|
16 |
#include <AknsUtils.h>
|
|
17 |
#include <swtlaffacade.h>
|
|
18 |
#include <AknUtils.h>
|
|
19 |
#include <AknDef.h>
|
|
20 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
21 |
#include <AknPriv.hrh>
|
|
22 |
#endif
|
|
23 |
#include <aknappui.h>
|
|
24 |
#include <akntouchpane.h>
|
|
25 |
#include "swtscrollbar.h"
|
|
26 |
#include "swtfont.h"
|
|
27 |
#include "swttextbase.h"
|
|
28 |
#include "swtcaptionedcontrol.h"
|
|
29 |
|
|
30 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
|
|
31 |
#include <uikon/eikdefconst.h>
|
|
32 |
#endif
|
|
33 |
|
|
34 |
// ======== MEMBER FUNCTIONS ========
|
|
35 |
|
|
36 |
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
// CSwtTextBase::CSwtTextBase
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
CSwtTextBase::CSwtTextBase(
|
|
42 |
MSwtDisplay& aDisplay,
|
|
43 |
TSwtPeer aPeer,
|
|
44 |
MSwtComposite& aParent,
|
|
45 |
TInt aStyle)
|
|
46 |
: ASwtScrollableBase(aDisplay, aPeer, &aParent, aStyle)
|
|
47 |
{
|
|
48 |
}
|
|
49 |
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
// CSwtTextBase::~CSwtTextBase
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
CSwtTextBase::~CSwtTextBase()
|
|
55 |
{
|
|
56 |
// Own
|
|
57 |
delete iEditor;
|
|
58 |
iEditor = NULL;
|
|
59 |
delete iIndicator;
|
|
60 |
iIndicator = NULL;
|
|
61 |
|
|
62 |
// Not own.
|
|
63 |
if (iDefaultFont)
|
|
64 |
{
|
|
65 |
iDefaultFont->RemoveRef();
|
|
66 |
iDefaultFont = NULL;
|
|
67 |
}
|
|
68 |
|
|
69 |
if (iCharFormatLayer)
|
|
70 |
{
|
|
71 |
delete iCharFormatLayer;
|
|
72 |
iCharFormatLayer = NULL;
|
|
73 |
}
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// CSwtTextBase::ConstructL
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
void CSwtTextBase::ConstructL()
|
|
81 |
{
|
|
82 |
CCoeControl& coeParent = iParent->Control()->CoeControl();
|
|
83 |
SetContainerWindowL(coeParent);
|
|
84 |
CSwtEditIndicatorRedictor* redirector = MopGetObject(redirector);
|
|
85 |
if (redirector)
|
|
86 |
{
|
|
87 |
iIndicator = CSwtEditIndicator::NewL(CoeControl());
|
|
88 |
}
|
|
89 |
CCoeControl::MakeVisible(coeParent.IsVisible());
|
|
90 |
CCoeControl::SetDimmed(coeParent.IsDimmed());
|
|
91 |
SetComponentsToInheritVisibility(ETrue);
|
|
92 |
|
|
93 |
// Although the background is drawn already natively, this fixes
|
|
94 |
// problems with srollbar back when custom back color set.
|
|
95 |
SetBackground(this);
|
|
96 |
}
|
|
97 |
|
|
98 |
// ---------------------------------------------------------------------------
|
|
99 |
// CSwtTextBase::SetEditor
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
void CSwtTextBase::SetEditor(CEikEdwin* aEditor)
|
|
103 |
{
|
|
104 |
ASSERT(!iEditor);
|
|
105 |
iEditor = aEditor;
|
|
106 |
}
|
|
107 |
|
|
108 |
#if defined( RD_SCALABLE_UI_V2)
|
|
109 |
|
|
110 |
// ---------------------------------------------------------------------------
|
|
111 |
// CSwtTextBase::InputCapabilities
|
|
112 |
// ---------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
TCoeInputCapabilities CSwtTextBase::InputCapabilities() const
|
|
115 |
{
|
|
116 |
// Override CCoeControl behaviour to provide MCoeCaptionRetrieverForFep.
|
|
117 |
const TCoeInputCapabilities& capabilities = CAknControl::InputCapabilities();
|
|
118 |
|
|
119 |
return TCoeInputCapabilities(capabilities.Capabilities(),
|
|
120 |
capabilities.FepAwareTextEditor(),
|
|
121 |
(MCoeCaptionRetrieverForFep*)this);
|
|
122 |
}
|
|
123 |
|
|
124 |
// ---------------------------------------------------------------------------
|
|
125 |
// CSwtTextBase::GetCaptionForFep
|
|
126 |
// ---------------------------------------------------------------------------
|
|
127 |
//
|
|
128 |
void CSwtTextBase::GetCaptionForFep(TDes& aCaption) const
|
|
129 |
{
|
|
130 |
// If we are inside a CaptionedControl, return the CaptionedControl text.
|
|
131 |
// It will be shown in thumb keypad
|
|
132 |
MSwtCaptionedControl* captionedControl = iParent->Control()->CaptionedControlInterface();
|
|
133 |
|
|
134 |
if (captionedControl)
|
|
135 |
{
|
|
136 |
const TDesC* text = captionedControl->GetText();
|
|
137 |
|
|
138 |
if (!text)
|
|
139 |
{
|
|
140 |
aCaption = KNullDesC;
|
|
141 |
}
|
|
142 |
else
|
|
143 |
{
|
|
144 |
const TInt maximumLength = aCaption.MaxLength();
|
|
145 |
|
|
146 |
if (text->Length() > maximumLength)
|
|
147 |
{
|
|
148 |
aCaption = text->Left(maximumLength);
|
|
149 |
}
|
|
150 |
else
|
|
151 |
{
|
|
152 |
aCaption = *text;
|
|
153 |
}
|
|
154 |
}
|
|
155 |
}
|
|
156 |
else
|
|
157 |
{
|
|
158 |
aCaption=KNullDesC;
|
|
159 |
}
|
|
160 |
}
|
|
161 |
|
|
162 |
void CSwtTextBase::MCoeCaptionRetrieverForFep_Reserved_1()
|
|
163 |
{}
|
|
164 |
|
|
165 |
void CSwtTextBase::MCoeCaptionRetrieverForFep_Reserved_2()
|
|
166 |
{}
|
|
167 |
|
|
168 |
#endif //RD_SCALABLE_UI_V2
|
|
169 |
|
|
170 |
// ---------------------------------------------------------------------------
|
|
171 |
// CSwtTextBase::RetrieveDefaultFontL
|
|
172 |
// ---------------------------------------------------------------------------
|
|
173 |
//
|
|
174 |
void CSwtTextBase::RetrieveDefaultFontL()
|
|
175 |
{
|
|
176 |
ASSERT(iEditor);
|
|
177 |
|
|
178 |
if (iDefaultFont)
|
|
179 |
{
|
|
180 |
iDefaultFont->RemoveRef();
|
|
181 |
iDefaultFont = NULL;
|
|
182 |
}
|
|
183 |
|
|
184 |
// Not same but similar to DateEditor's font. Height most probably be same.
|
|
185 |
iDefaultFont = CSwtFont::NewL(iDisplay.Device(), *AknLayoutUtils::FontFromId(
|
|
186 |
CSwtLafFacade::GetFontId(CSwtLafFacade::EFont2MidpTextPaneT1Font, 0, 0), NULL));
|
|
187 |
|
|
188 |
if (!iFont)
|
|
189 |
{
|
|
190 |
// to avoid the default font of CEikEdwin
|
|
191 |
ProcessFontUpdateL();
|
|
192 |
}
|
|
193 |
}
|
|
194 |
|
|
195 |
|
|
196 |
// ---------------------------------------------------------------------------
|
|
197 |
// CSwtTextBase::ProcessFontUpdate
|
|
198 |
// ---------------------------------------------------------------------------
|
|
199 |
//
|
|
200 |
void CSwtTextBase::ProcessFontUpdateL()
|
|
201 |
{
|
|
202 |
TCharFormat charFormat;
|
|
203 |
TCharFormatMask charMask;
|
|
204 |
|
|
205 |
charFormat.iFontSpec = GetFont()->Font().FontSpecInTwips();
|
|
206 |
charMask.SetAttrib(EAttFontTypeface);
|
|
207 |
charMask.SetAttrib(EAttFontHeight);
|
|
208 |
|
|
209 |
if (charFormat.iFontSpec.iFontStyle.StrokeWeight() == EStrokeWeightBold)
|
|
210 |
{
|
|
211 |
charMask.SetAttrib(EAttFontStrokeWeight);
|
|
212 |
}
|
|
213 |
|
|
214 |
if (charFormat.iFontSpec.iFontStyle.Posture() == EPostureItalic)
|
|
215 |
{
|
|
216 |
charMask.SetAttrib(EAttFontPosture);
|
|
217 |
}
|
|
218 |
|
|
219 |
TRgb color(0);
|
|
220 |
TInt err(KErrNone);
|
|
221 |
|
|
222 |
if (HasHighlight())
|
|
223 |
{
|
|
224 |
err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance()
|
|
225 |
, color
|
|
226 |
, KAknsIIDQsnTextColors
|
|
227 |
, KHighlightedTextColor);
|
|
228 |
if (err == KErrNone)
|
|
229 |
{
|
|
230 |
charFormat.iFontPresentation.iTextColor = color;
|
|
231 |
charMask.SetAttrib(EAttColor);
|
|
232 |
}
|
|
233 |
}
|
|
234 |
else if (iTextColor)
|
|
235 |
{
|
|
236 |
charFormat.iFontPresentation.iTextColor = GetForeground();
|
|
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 |
}
|
|
250 |
}
|
|
251 |
|
|
252 |
if (iStyle & KSwtStyleSingle)
|
|
253 |
{
|
|
254 |
CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(charFormat, charMask);
|
|
255 |
// we are using CGlobalText for Single line. So SetGlobalCharFormat for Global text
|
|
256 |
static_cast<CGlobalText*>(iEditor->Text())->SetGlobalCharFormat(charFormatLayer);
|
|
257 |
if (iCharFormatLayer)
|
|
258 |
{
|
|
259 |
delete iCharFormatLayer;
|
|
260 |
}
|
|
261 |
iCharFormatLayer = charFormatLayer;
|
|
262 |
}
|
|
263 |
else
|
|
264 |
{
|
|
265 |
CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(charFormat, charMask);
|
|
266 |
// SetCharFormatLayer is for EText and RichText
|
|
267 |
iEditor->SetCharFormatLayer(charFormatLayer);
|
|
268 |
}
|
|
269 |
}
|
|
270 |
|
|
271 |
// ---------------------------------------------------------------------------
|
|
272 |
// CSwtTextBase::SetBackgroundL
|
|
273 |
// ---------------------------------------------------------------------------
|
|
274 |
//
|
|
275 |
void CSwtTextBase::SetBackgroundL(const MSwtColor* aColor)
|
|
276 |
{
|
|
277 |
ASwtControlBase::DoSetBackgroundL(aColor);
|
|
278 |
TRgb color(aColor ? aColor->RgbValue() :
|
|
279 |
iDisplay.CoeEnv()->Color(EColorControlBackground));
|
|
280 |
if (iEditor)
|
|
281 |
{
|
|
282 |
// Outside text view
|
|
283 |
iEditor->SetBackgroundColorL(color);
|
|
284 |
|
|
285 |
// Inside text view, outside paragraphs
|
|
286 |
iEditor->TextView()->SetBackgroundColor(color);
|
|
287 |
|
|
288 |
// Inside paragraphs
|
|
289 |
CParaFormat* paraFormat = new(ELeave) CParaFormat();
|
|
290 |
CleanupStack::PushL(paraFormat);
|
|
291 |
paraFormat->iFillColor = color;
|
|
292 |
TParaFormatMask paraMask;
|
|
293 |
paraMask.SetAttrib(EAttFillColor);
|
|
294 |
static_cast<CGlobalText*>(iEditor->Text())->ApplyParaFormatL(
|
|
295 |
paraFormat, paraMask, 0, iEditor->TextLength());
|
|
296 |
CleanupStack::PopAndDestroy(paraFormat);
|
|
297 |
}
|
|
298 |
Redraw();
|
|
299 |
}
|
|
300 |
|
|
301 |
// ---------------------------------------------------------------------------
|
|
302 |
// CSwtTextBase::SetForegroundL
|
|
303 |
// ---------------------------------------------------------------------------
|
|
304 |
//
|
|
305 |
void CSwtTextBase::SetForegroundL(const MSwtColor* aColor)
|
|
306 |
{
|
|
307 |
ASwtControlBase::DoSetForegroundL(aColor);
|
|
308 |
|
|
309 |
iTextColor = ETrue;
|
|
310 |
if (!aColor)
|
|
311 |
{
|
|
312 |
iTextColor = EFalse;
|
|
313 |
}
|
|
314 |
else if (iEditor)
|
|
315 |
{
|
|
316 |
TCharFormat charFormat;
|
|
317 |
TCharFormatMask charMask;
|
|
318 |
charFormat.iFontPresentation.iTextColor = aColor->RgbValue();
|
|
319 |
charMask.SetAttrib(EAttColor);
|
|
320 |
static_cast<CGlobalText*>(iEditor->Text())->
|
|
321 |
ApplyCharFormatL(charFormat, charMask, 0, iEditor->TextLength());
|
|
322 |
}
|
|
323 |
|
|
324 |
UpdateTextColor();
|
|
325 |
Redraw();
|
|
326 |
}
|
|
327 |
|
|
328 |
void CSwtTextBase::SetBounds(const TRect& aRect)
|
|
329 |
{
|
|
330 |
// Divert the job to UiUtils if this is an editor open for split view editing.
|
|
331 |
MSwtUiUtils& utils = iDisplay.UiUtils();
|
|
332 |
if (utils.SplitInputView() == this)
|
|
333 |
{
|
|
334 |
utils.SetSplitInputViewSize(aRect.Size());
|
|
335 |
SetLocation(aRect.iTl);
|
|
336 |
}
|
|
337 |
else
|
|
338 |
{
|
|
339 |
ASwtScrollableBase::SetBounds(aRect);
|
|
340 |
}
|
|
341 |
}
|
|
342 |
|
|
343 |
void CSwtTextBase::SetWidgetSize(const TSize& aSize)
|
|
344 |
{
|
|
345 |
// Divert the job to UiUtils if this is an editor open for split view editing.
|
|
346 |
MSwtUiUtils& utils = iDisplay.UiUtils();
|
|
347 |
if (utils.SplitInputView() == this)
|
|
348 |
{
|
|
349 |
utils.SetSplitInputViewSize(aSize);
|
|
350 |
}
|
|
351 |
else
|
|
352 |
{
|
|
353 |
ASwtScrollableBase::SetWidgetSize(aSize);
|
|
354 |
}
|
|
355 |
}
|
|
356 |
|
|
357 |
TSwtPeer CSwtTextBase::Dispose()
|
|
358 |
{
|
|
359 |
// Close VKB.
|
|
360 |
if (iEditor->IsFocused())
|
|
361 |
{
|
|
362 |
CCoeFep* fep = iDisplay.CoeEnv()->Fep();
|
|
363 |
if (fep)
|
|
364 |
{
|
|
365 |
fep->HandleDestructionOfFocusedItem();
|
|
366 |
}
|
|
367 |
}
|
|
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();
|
|
424 |
}
|
|
425 |
|
|
426 |
// ---------------------------------------------------------------------------
|
|
427 |
// CSwtTextBase::ComputeDelta
|
|
428 |
// ---------------------------------------------------------------------------
|
|
429 |
//
|
|
430 |
TSize CSwtTextBase::ComputeDelta() const
|
|
431 |
{
|
|
432 |
ASSERT(iEditor);
|
|
433 |
|
|
434 |
// Retrieve the various margins & borders
|
|
435 |
TInt labels = 0;
|
|
436 |
TInt cursor = 0;
|
|
437 |
iEditor->TextView()->MarginWidths(labels, cursor);
|
|
438 |
const TSize borderDelta(iEditor->Border().SizeDelta());
|
|
439 |
const TSize marginDelta(iEditor->Margins().SizeDelta());
|
|
440 |
const TSize ownBorderDelta(BorderSizeDelta());
|
|
441 |
|
|
442 |
// The scrollbars
|
|
443 |
const TSize sbDelta(SbOuterRect(TRect()).Size());
|
|
444 |
|
|
445 |
// Add them all up
|
|
446 |
// Note that marginDelta.iWidth is counted twice because CEikEdwin also
|
|
447 |
// counts it twice ( in LayoutWidth(), margins are substracted from
|
|
448 |
// ViewRect().Width() whereas this is already done when computing
|
|
449 |
// ViewRect().Width() ). So this is a workaround to avoid unwanted
|
|
450 |
// wrapping because of this defect in CEikEdwin.
|
|
451 |
TSize totalDelta(ownBorderDelta.iWidth + borderDelta.iWidth
|
|
452 |
+ 2 * marginDelta.iWidth + sbDelta.iWidth
|
|
453 |
+ labels + cursor + KEikDefaultCursorWidth,
|
|
454 |
ownBorderDelta.iHeight + borderDelta.iHeight
|
|
455 |
+ marginDelta.iHeight + sbDelta.iHeight);
|
|
456 |
if (iIndicator)
|
|
457 |
{
|
|
458 |
totalDelta.iHeight += KSWTEditIndicatorHeight;
|
|
459 |
}
|
|
460 |
return totalDelta;
|
|
461 |
}
|
|
462 |
|
|
463 |
// ---------------------------------------------------------------------------
|
|
464 |
// CSwtTextBase::HotKeyL
|
|
465 |
// ---------------------------------------------------------------------------
|
|
466 |
//
|
|
467 |
TInt CSwtTextBase::HotKeyL(const TKeyEvent& aKeyEvent) const
|
|
468 |
{
|
|
469 |
ASSERT(iEditor);
|
|
470 |
|
|
471 |
if (!(aKeyEvent.iModifiers & EModifierCtrl)
|
|
472 |
|| (aKeyEvent.iCode >= 100)
|
|
473 |
|| (aKeyEvent.iCode == ' '))
|
|
474 |
{
|
|
475 |
return -1;
|
|
476 |
}
|
|
477 |
|
|
478 |
HBufC* hkBuf;
|
|
479 |
if (aKeyEvent.iModifiers & EModifierShift)
|
|
480 |
{
|
|
481 |
hkBuf = iCoeEnv->AllocReadResourceL(R_EIK_EDWIN_SHIFT_CTRL_HOTKEYS);
|
|
482 |
}
|
|
483 |
else
|
|
484 |
{
|
|
485 |
hkBuf = iCoeEnv->AllocReadResourceL(R_EIK_EDWIN_CTRL_HOTKEYS);
|
|
486 |
}
|
|
487 |
TInt hotkey = hkBuf->Locate(TChar(aKeyEvent.iCode + 'a' - 1));
|
|
488 |
delete hkBuf;
|
|
489 |
return hotkey;
|
|
490 |
}
|
|
491 |
|
|
492 |
// ---------------------------------------------------------------------------
|
|
493 |
// CSwtTextBase::SetEditable
|
|
494 |
// ---------------------------------------------------------------------------
|
|
495 |
//
|
|
496 |
void CSwtTextBase::SetEditable(TBool aEditable)
|
|
497 |
{
|
|
498 |
// Update the style accordingly
|
|
499 |
if (aEditable)
|
|
500 |
{
|
|
501 |
iStyle &= ~KSwtStyleReadOnly;
|
|
502 |
}
|
|
503 |
else
|
|
504 |
{
|
|
505 |
iStyle |= KSwtStyleReadOnly;
|
|
506 |
}
|
|
507 |
|
|
508 |
iEditor->SetReadOnly(!aEditable);
|
|
509 |
iEditor->SetFocus(IsFocused());
|
|
510 |
}
|
|
511 |
|
|
512 |
// ---------------------------------------------------------------------------
|
|
513 |
// CSwtTextBase::SetTextL
|
|
514 |
// ---------------------------------------------------------------------------
|
|
515 |
//
|
|
516 |
TBool CSwtTextBase::SetTextL(const TDesC& aText)
|
|
517 |
{
|
|
518 |
// This must be called before querying the length or selection as it can
|
|
519 |
// remove the char that is just being typed.
|
|
520 |
iEditor->CancelFepTransaction();
|
|
521 |
|
|
522 |
// Get the remaining editing space available in editor if text limit set,
|
|
523 |
// and return if no available space.
|
|
524 |
TInt editorTextLen = iEditor->TextLength();
|
|
525 |
TInt availableLen = KErrNotFound;
|
|
526 |
if (iTextLimit)
|
|
527 |
{
|
|
528 |
ASSERT(editorTextLen <= iTextLimit);
|
|
529 |
availableLen = iTextLimit;
|
|
530 |
if (availableLen <= 0)
|
|
531 |
{
|
|
532 |
return EFalse;
|
|
533 |
}
|
|
534 |
}
|
|
535 |
|
|
536 |
|
|
537 |
// Clear selection if any
|
|
538 |
iEditor->ClearSelectionL();
|
|
539 |
|
|
540 |
// If a text limit is set, append as much as the available space permits,
|
|
541 |
// otherwise append the entire text.
|
|
542 |
TInt textToInsertLen = aText.Length();
|
|
543 |
if (availableLen != KErrNotFound
|
|
544 |
&& textToInsertLen > availableLen)
|
|
545 |
{
|
|
546 |
TPtrC des = aText.Left(availableLen);
|
|
547 |
iEditor->SetTextL(&des);
|
|
548 |
}
|
|
549 |
else
|
|
550 |
{
|
|
551 |
iEditor->SetTextL(&aText);
|
|
552 |
}
|
|
553 |
iEditor->HandleTextChangedL();
|
|
554 |
|
|
555 |
|
|
556 |
// Restore carret
|
|
557 |
iEditor->SetSelectionL(0, 0);
|
|
558 |
|
|
559 |
/* Workaround for junit tests. Copy and paste functions crash, when
|
|
560 |
* Text is not visible. There is some optimalization in CEikEdwin,
|
|
561 |
* that updates selection (and cursos position) after Text is drawn.
|
|
562 |
*/
|
|
563 |
iEditor->TextView()->SetSelectionL(TCursorSelection(0, 0));
|
|
564 |
|
|
565 |
return ETrue;
|
|
566 |
}
|
|
567 |
|
|
568 |
// ---------------------------------------------------------------------------
|
|
569 |
// CSwtTextBase::AppendL
|
|
570 |
// ---------------------------------------------------------------------------
|
|
571 |
//
|
|
572 |
TBool CSwtTextBase::AppendL(const TDesC& aText)
|
|
573 |
{
|
|
574 |
ASSERT(iEditor);
|
|
575 |
|
|
576 |
// This must be called before querying the length or selection as it can
|
|
577 |
// remove the char that is just being typed.
|
|
578 |
iEditor->CancelFepTransaction();
|
|
579 |
|
|
580 |
// Get the remaining editing space available in editor if text limit set,
|
|
581 |
// and return if no available space.
|
|
582 |
TInt textToInsertLen = aText.Length();
|
|
583 |
TInt editorTextLen = iEditor->TextLength();
|
|
584 |
TInt availableLen = KErrNotFound;
|
|
585 |
if (iTextLimit)
|
|
586 |
{
|
|
587 |
ASSERT(editorTextLen <= iTextLimit);
|
|
588 |
availableLen = iTextLimit - editorTextLen;
|
|
589 |
if (availableLen <= 0)
|
|
590 |
{
|
|
591 |
return EFalse;
|
|
592 |
}
|
|
593 |
}
|
|
594 |
|
|
595 |
// Clear selection if any
|
|
596 |
iEditor->ClearSelectionL();
|
|
597 |
|
|
598 |
// If a text limit is set, append as much as the available space permits,
|
|
599 |
// otherwise append the entire text.
|
|
600 |
CPlainText* plainText = iEditor->Text();
|
|
601 |
if (availableLen != KErrNotFound
|
|
602 |
&& textToInsertLen > availableLen)
|
|
603 |
{
|
|
604 |
plainText->InsertL(editorTextLen, aText.Left(availableLen));
|
|
605 |
}
|
|
606 |
else
|
|
607 |
{
|
|
608 |
plainText->InsertL(editorTextLen, aText);
|
|
609 |
}
|
|
610 |
iEditor->HandleTextChangedL();
|
|
611 |
|
|
612 |
// Restore carret
|
|
613 |
editorTextLen = iEditor->TextLength();
|
|
614 |
iEditor->SetSelectionL(editorTextLen, editorTextLen);
|
|
615 |
|
|
616 |
return ETrue;
|
|
617 |
}
|
|
618 |
|
|
619 |
// ---------------------------------------------------------------------------
|
|
620 |
// CSwtTextBase::InsertL
|
|
621 |
// ---------------------------------------------------------------------------
|
|
622 |
//
|
|
623 |
TBool CSwtTextBase::InsertL(const TDesC& aText)
|
|
624 |
{
|
|
625 |
ASSERT(iEditor);
|
|
626 |
|
|
627 |
// This must be called before querying the length or selection as it can
|
|
628 |
// remove the char that is just being typed.
|
|
629 |
iEditor->CancelFepTransaction();
|
|
630 |
|
|
631 |
const TCursorSelection selection(iEditor->Selection());
|
|
632 |
const TInt selStart = selection.LowerPos();
|
|
633 |
TInt textToInsertLen = aText.Length();
|
|
634 |
|
|
635 |
// Return if there is nothing to delete
|
|
636 |
if (textToInsertLen == 0 && selection.Length() == 0)
|
|
637 |
{
|
|
638 |
return EFalse;
|
|
639 |
}
|
|
640 |
|
|
641 |
iEditor->ClearSelectionL();
|
|
642 |
// Update selection to be sure selection is valid after text removal
|
|
643 |
iEditor->SetSelectionL(selStart, selStart);
|
|
644 |
iEditor->TextView()->SetSelectionL(TCursorSelection(selStart, selStart));
|
|
645 |
|
|
646 |
// Remove selected text
|
|
647 |
CPlainText* plainText = iEditor->Text();
|
|
648 |
plainText->DeleteL(selStart, selection.Length());
|
|
649 |
|
|
650 |
// Get the remaining editing space available in editor if text limit set,
|
|
651 |
// and return if no available space.
|
|
652 |
TInt editorTextLen = iEditor->TextLength();
|
|
653 |
TInt availableLen = KErrNotFound;
|
|
654 |
if (iTextLimit)
|
|
655 |
{
|
|
656 |
ASSERT(editorTextLen <= iTextLimit);
|
|
657 |
availableLen = iTextLimit - editorTextLen;
|
|
658 |
if (availableLen <= 0)
|
|
659 |
{
|
|
660 |
return EFalse;
|
|
661 |
}
|
|
662 |
}
|
|
663 |
|
|
664 |
// If a text limit is set, append as much as the available space permits,
|
|
665 |
// otherwise insert the entire text.
|
|
666 |
if (availableLen != KErrNotFound
|
|
667 |
&& textToInsertLen > availableLen)
|
|
668 |
{
|
|
669 |
plainText->InsertL(selStart, aText.Left(availableLen));
|
|
670 |
textToInsertLen = availableLen;
|
|
671 |
}
|
|
672 |
else
|
|
673 |
{
|
|
674 |
plainText->InsertL(selStart, aText);
|
|
675 |
}
|
|
676 |
|
|
677 |
iEditor->HandleTextChangedL();
|
|
678 |
|
|
679 |
// Restore carret
|
|
680 |
TInt newCaretPos = Min(selStart + textToInsertLen,
|
|
681 |
iEditor->TextLength());
|
|
682 |
iEditor->SetSelectionL(newCaretPos, newCaretPos);
|
|
683 |
|
|
684 |
return ETrue;
|
|
685 |
}
|
|
686 |
|
|
687 |
// ---------------------------------------------------------------------------
|
|
688 |
// CSwtTextBase::CutL
|
|
689 |
// ---------------------------------------------------------------------------
|
|
690 |
//
|
|
691 |
TBool CSwtTextBase::CutL()
|
|
692 |
{
|
|
693 |
ASSERT(iEditor);
|
|
694 |
|
|
695 |
if (iEditor->Selection().Length() == 0)
|
|
696 |
{
|
|
697 |
return EFalse;
|
|
698 |
}
|
|
699 |
iEditor->ClipboardL(CEikEdwin::ECut);
|
|
700 |
return ETrue;
|
|
701 |
}
|
|
702 |
|
|
703 |
// ---------------------------------------------------------------------------
|
|
704 |
// CSwtTextBase::SetLimit
|
|
705 |
// ---------------------------------------------------------------------------
|
|
706 |
//
|
|
707 |
TBool CSwtTextBase::SetLimitL(TInt aLimit)
|
|
708 |
{
|
|
709 |
ASSERT(iEditor);
|
|
710 |
ASSERT(aLimit);
|
|
711 |
|
|
712 |
const TCursorSelection selection(iEditor->Selection());
|
|
713 |
const TInt selStart = selection.LowerPos();
|
|
714 |
|
|
715 |
// This should be enough but it's not.
|
|
716 |
// iEditor->SetTextLimit( aLimit );
|
|
717 |
iTextLimit = aLimit;
|
|
718 |
|
|
719 |
// Clear selection.
|
|
720 |
iEditor->ClearSelectionL();
|
|
721 |
|
|
722 |
// Ensure that the editor's text is not longer than the limit just set.
|
|
723 |
TInt editorTextLen = iEditor->TextLength();
|
|
724 |
if (editorTextLen > iTextLimit)
|
|
725 |
{
|
|
726 |
CPlainText* plainText = iEditor->Text();
|
|
727 |
plainText->DeleteL(iTextLimit, editorTextLen - iTextLimit);
|
|
728 |
iEditor->HandleTextChangedL();
|
|
729 |
}
|
|
730 |
iEditor->SetTextLimit(aLimit);
|
|
731 |
// Not allowed to have failed here.
|
|
732 |
editorTextLen = iEditor->TextLength();
|
|
733 |
ASSERT(editorTextLen <= iTextLimit);
|
|
734 |
|
|
735 |
// Ensure cursor is at the most at the end of the new text.
|
|
736 |
if (selStart > editorTextLen)
|
|
737 |
{
|
|
738 |
iEditor->SetSelectionL(editorTextLen, editorTextLen);
|
|
739 |
}
|
|
740 |
|
|
741 |
return ETrue;
|
|
742 |
}
|
|
743 |
|
|
744 |
// ---------------------------------------------------------------------------
|
|
745 |
// CSwtTextBase::ForwardKeyEventL
|
|
746 |
// NOTE: FEP may deliver the key events directly to CEikEdwin!
|
|
747 |
// ---------------------------------------------------------------------------
|
|
748 |
//
|
|
749 |
void CSwtTextBase::ForwardKeyEventL(
|
|
750 |
const TKeyEvent& aKeyEvent, TEventCode aType)
|
|
751 |
{
|
|
752 |
ASSERT(iEditor);
|
|
753 |
TInt cursorPos = Editor().TextView()->Selection().iCursorPos;
|
|
754 |
TInt textLen = Editor().TextLength();
|
|
755 |
|
|
756 |
iEditor->OfferKeyEventL(aKeyEvent, aType);
|
|
757 |
|
|
758 |
// This is called, because when FepManager is notified first time,
|
|
759 |
// there are no changes in editor yet. Editor is updated later,
|
|
760 |
// after verification on java side. So now FepManager must be notified
|
|
761 |
// again to get a right information about changes.
|
|
762 |
iDisplay.CoeEnv()->InputCapabilitiesChanged();
|
|
763 |
|
|
764 |
// CEikEdwin doesn't loop when cursor is end or begining of Text
|
|
765 |
//if edwin is readonly. this is workaround to fix.
|
|
766 |
if ((iStyle & KSwtStyleReadOnly))
|
|
767 |
{
|
|
768 |
switch (aKeyEvent.iCode)
|
|
769 |
{
|
|
770 |
case EKeyLeftArrow:
|
|
771 |
if (!(aKeyEvent.iModifiers & EModifierShift)
|
|
772 |
&& (cursorPos == 0))
|
|
773 |
{
|
|
774 |
Editor().SetSelectionL(textLen , textLen);
|
|
775 |
}
|
|
776 |
break;
|
|
777 |
|
|
778 |
case EKeyRightArrow:
|
|
779 |
if (!(aKeyEvent.iModifiers & EModifierShift)
|
|
780 |
&& (cursorPos == textLen))
|
|
781 |
{
|
|
782 |
Editor().SetSelectionL(0, 0);
|
|
783 |
}
|
|
784 |
break;
|
|
785 |
|
|
786 |
default:
|
|
787 |
break;
|
|
788 |
}
|
|
789 |
}
|
|
790 |
}
|
|
791 |
|
|
792 |
// ---------------------------------------------------------------------------
|
|
793 |
// CSwtTextBase::CountComponentControls
|
|
794 |
// From CCoeControl
|
|
795 |
// ---------------------------------------------------------------------------
|
|
796 |
//
|
|
797 |
TInt CSwtTextBase::CountComponentControls() const
|
|
798 |
{
|
|
799 |
TInt componentCount = 0;
|
|
800 |
if (iEditor)
|
|
801 |
{
|
|
802 |
componentCount++;
|
|
803 |
if (iIndicator)
|
|
804 |
{
|
|
805 |
componentCount++;
|
|
806 |
}
|
|
807 |
}
|
|
808 |
return componentCount;
|
|
809 |
}
|
|
810 |
|
|
811 |
// ---------------------------------------------------------------------------
|
|
812 |
// CSwtTextBase::ComponentControl
|
|
813 |
// From CCoeControl
|
|
814 |
// ---------------------------------------------------------------------------
|
|
815 |
//
|
|
816 |
CCoeControl* CSwtTextBase::ComponentControl(TInt aIndex) const
|
|
817 |
{
|
|
818 |
ASSERT(iEditor);
|
|
819 |
if (aIndex == 1 && iIndicator)
|
|
820 |
{
|
|
821 |
return iIndicator->IndicatorContainer();
|
|
822 |
}
|
|
823 |
return iEditor;
|
|
824 |
}
|
|
825 |
|
|
826 |
// ---------------------------------------------------------------------------
|
|
827 |
// CSwtTextBase::MakeVisible
|
|
828 |
// From CCoeControl
|
|
829 |
// ---------------------------------------------------------------------------
|
|
830 |
//
|
|
831 |
void CSwtTextBase::MakeVisible(TBool aVisible)
|
|
832 |
{
|
|
833 |
const TBool oldVisibility = IsVisible();
|
|
834 |
if ((aVisible && oldVisibility) || (!aVisible && !oldVisibility))
|
|
835 |
{
|
|
836 |
return;
|
|
837 |
}
|
|
838 |
|
|
839 |
// Close VKB. Do it here instead of FocusChange to avoid split input flicker.
|
|
840 |
if (iEditor->IsFocused() && !aVisible)
|
|
841 |
{
|
|
842 |
CCoeFep* fep = iDisplay.CoeEnv()->Fep();
|
|
843 |
if (fep)
|
|
844 |
{
|
|
845 |
fep->HandleDestructionOfFocusedItem();
|
|
846 |
}
|
|
847 |
}
|
|
848 |
|
|
849 |
CCoeControl::MakeVisible(aVisible);
|
|
850 |
if (iEditor)
|
|
851 |
{
|
|
852 |
iEditor->MakeVisible(aVisible);
|
|
853 |
|
|
854 |
// Forward the new visibility to the scroll-bars
|
|
855 |
CEikScrollBarFrame* sbFrame = iEditor->ScrollBarFrame();
|
|
856 |
if (sbFrame)
|
|
857 |
{
|
|
858 |
//Update scrollbars
|
|
859 |
TRAP_IGNORE(iEditor->UpdateScrollBarsL());
|
|
860 |
const TInt count = sbFrame->CountComponentControls();
|
|
861 |
for (TInt i = 0; i < count; ++i)
|
|
862 |
{
|
|
863 |
sbFrame->ComponentControl(i)->MakeVisible(aVisible);
|
|
864 |
}
|
|
865 |
}
|
|
866 |
}
|
|
867 |
|
|
868 |
FocusabilityChanged();
|
|
869 |
}
|
|
870 |
|
|
871 |
// ---------------------------------------------------------------------------
|
|
872 |
// CSwtTextBase::SetDimmed
|
|
873 |
// From CCoeControl
|
|
874 |
// ---------------------------------------------------------------------------
|
|
875 |
//
|
|
876 |
void CSwtTextBase::SetDimmed(TBool aDimmed)
|
|
877 |
{
|
|
878 |
// Close VKB. Do it here instead of FocusChange to avoid split input flicker.
|
|
879 |
if (iEditor->IsFocused() && aDimmed)
|
|
880 |
{
|
|
881 |
CCoeFep* fep = iDisplay.CoeEnv()->Fep();
|
|
882 |
if (fep)
|
|
883 |
{
|
|
884 |
fep->HandleDestructionOfFocusedItem();
|
|
885 |
}
|
|
886 |
}
|
|
887 |
|
|
888 |
CCoeControl::SetDimmed(aDimmed);
|
|
889 |
if (iEditor)
|
|
890 |
{
|
|
891 |
iEditor->SetDimmed(aDimmed);
|
|
892 |
}
|
|
893 |
FocusabilityChanged();
|
|
894 |
}
|
|
895 |
|
|
896 |
// ---------------------------------------------------------------------------
|
|
897 |
// CSwtTextBase::HandleResourceChange
|
|
898 |
// From CCoeControl
|
|
899 |
// ---------------------------------------------------------------------------
|
|
900 |
//
|
|
901 |
void CSwtTextBase::HandleResourceChange(TInt aType)
|
|
902 |
{
|
|
903 |
TRAP_IGNORE(SwtHandleResourceChangeL(aType));
|
|
904 |
}
|
|
905 |
|
|
906 |
// ---------------------------------------------------------------------------
|
|
907 |
// CSwtTextBase::SwtHandleResourceChangeL
|
|
908 |
// ---------------------------------------------------------------------------
|
|
909 |
//
|
|
910 |
void CSwtTextBase::SwtHandleResourceChangeL(TInt aType)
|
|
911 |
{
|
|
912 |
CCoeControl::HandleResourceChange(aType);
|
|
913 |
|
|
914 |
if (aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch)
|
|
915 |
{
|
|
916 |
// The highlight color will be updated from ProcessFontUpdateL()
|
|
917 |
|
|
918 |
if (!iFont)
|
|
919 |
{
|
|
920 |
RetrieveDefaultFontL(); // ProcessFontUpdateL() will get called also.
|
|
921 |
}
|
|
922 |
else
|
|
923 |
{
|
|
924 |
ProcessFontUpdateL();
|
|
925 |
}
|
|
926 |
}
|
|
927 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
928 |
else if (aType == KAknSplitInputEnabled)
|
|
929 |
{
|
|
930 |
const MSwtShell* activeShell = iDisplay.UiUtils().GetActiveShell();
|
|
931 |
if (activeShell && activeShell->FocusControl() == this)
|
|
932 |
{
|
|
933 |
iDisplay.UiUtils().SetSplitInputEditor(this);
|
|
934 |
}
|
|
935 |
}
|
|
936 |
#endif
|
|
937 |
}
|
|
938 |
|
|
939 |
// ---------------------------------------------------------------------------
|
|
940 |
// CSwtTextBase::FixPadding
|
|
941 |
// ---------------------------------------------------------------------------
|
|
942 |
//
|
|
943 |
void CSwtTextBase::FixPadding()
|
|
944 |
{
|
|
945 |
Editor().SetBorderViewMargins(iDisplay.UiUtils().InlineReferencePadding());
|
|
946 |
}
|
|
947 |
|
|
948 |
// ---------------------------------------------------------------------------
|
|
949 |
// CSwtTextBase::HandlePointerEventL
|
|
950 |
// From CCoeControl
|
|
951 |
// ---------------------------------------------------------------------------
|
|
952 |
//
|
|
953 |
#ifdef RD_SCALABLE_UI_V2
|
|
954 |
void CSwtTextBase::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
|
955 |
{
|
|
956 |
// Scrollbar tap
|
|
957 |
CEikScrollBarFrame* sbFrame = iEditor->ScrollBarFrame();
|
|
958 |
CEikScrollBar* vsb = sbFrame ? sbFrame->GetScrollBarHandle(CEikScrollBar::EVertical) : NULL;
|
|
959 |
|
|
960 |
TBool hit = ETrue;
|
|
961 |
|
|
962 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
963 |
TBool isActiveSplitEditor = iDisplay.UiUtils().SplitInputEditor() == this;
|
|
964 |
hit = Rect().Contains(aPointerEvent.iPosition);
|
|
965 |
TBool pressed = iPressed;
|
|
966 |
#endif
|
|
967 |
|
|
968 |
// Check if we should start scrollbar grabbing
|
|
969 |
if (aPointerEvent.iType == TPointerEvent::EButton1Down)
|
|
970 |
{
|
|
971 |
if (vsb && vsb->Rect().Contains(aPointerEvent.iPosition))
|
|
972 |
{
|
|
973 |
iVScrollBarGrabsPointerEvents = ETrue;
|
|
974 |
}
|
|
975 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
976 |
else
|
|
977 |
{
|
|
978 |
iPressed = !isActiveSplitEditor;
|
|
979 |
}
|
|
980 |
#endif
|
|
981 |
}
|
|
982 |
|
|
983 |
// Deliver event to scrollbar
|
|
984 |
if (iVScrollBarGrabsPointerEvents && vsb)
|
|
985 |
{
|
|
986 |
vsb->HandlePointerEventL(aPointerEvent);
|
|
987 |
}
|
|
988 |
|
|
989 |
TBool forward(EFalse);
|
|
990 |
TPointerEvent pointerEvent(aPointerEvent);
|
|
991 |
|
|
992 |
// Edwin tap. Button1Up after the long tap is not forwarded to the editor
|
|
993 |
if (!(aPointerEvent.iType == TPointerEvent::EButton1Up
|
|
994 |
&& (iDisplay.RevertPointerEvent() || !hit))
|
|
995 |
&& !iVScrollBarGrabsPointerEvents
|
|
996 |
&& !iIgnorePointerDown)
|
|
997 |
{
|
|
998 |
// If clicking on margins, move the pointer event.
|
|
999 |
TRect viewRect(iEditor->TextView()->ViewRect());
|
|
1000 |
TRect viewRectWithoutMargins(viewRect);
|
|
1001 |
viewRectWithoutMargins.Shrink(2, 2); // well inside the edges
|
|
1002 |
|
|
1003 |
// EButtonRepeat and EDrag events should not be moved to viewRect
|
|
1004 |
// This enables to scroll text, when dragging outside of the text
|
|
1005 |
const TBool moveEventToViewRect =
|
|
1006 |
aPointerEvent.iType != TPointerEvent::EButtonRepeat
|
|
1007 |
&& aPointerEvent.iType != TPointerEvent::EDrag;
|
|
1008 |
|
|
1009 |
// Checking if event is in area between margins and borders
|
|
1010 |
// When so then moving event to the rect without margins
|
|
1011 |
if (moveEventToViewRect ||
|
|
1012 |
(viewRect.Contains(aPointerEvent.iPosition) &&
|
|
1013 |
!viewRectWithoutMargins.Contains(aPointerEvent.iPosition)))
|
|
1014 |
{
|
|
1015 |
if (pointerEvent.iPosition.iX < viewRectWithoutMargins.iTl.iX)
|
|
1016 |
{
|
|
1017 |
pointerEvent.iPosition.iX = viewRectWithoutMargins.iTl.iX;
|
|
1018 |
}
|
|
1019 |
if (pointerEvent.iPosition.iY < viewRectWithoutMargins.iTl.iY)
|
|
1020 |
{
|
|
1021 |
pointerEvent.iPosition.iY = viewRectWithoutMargins.iTl.iY;
|
|
1022 |
}
|
|
1023 |
if (pointerEvent.iPosition.iX > viewRectWithoutMargins.iBr.iX)
|
|
1024 |
{
|
|
1025 |
pointerEvent.iPosition.iX = viewRectWithoutMargins.iBr.iX;
|
|
1026 |
}
|
|
1027 |
if (pointerEvent.iPosition.iY > viewRectWithoutMargins.iBr.iY)
|
|
1028 |
{
|
|
1029 |
pointerEvent.iPosition.iY = viewRectWithoutMargins.iBr.iY;
|
|
1030 |
}
|
|
1031 |
}
|
|
1032 |
|
|
1033 |
forward = ETrue;
|
|
1034 |
}
|
|
1035 |
|
|
1036 |
// Stop scrollbar grabbing
|
|
1037 |
if (aPointerEvent.iType == TPointerEvent::EButton1Up)
|
|
1038 |
{
|
|
1039 |
iVScrollBarGrabsPointerEvents = EFalse;
|
|
1040 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
1041 |
iPressed = EFalse;
|
|
1042 |
#endif
|
|
1043 |
}
|
|
1044 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
1045 |
else if (aPointerEvent.iType == TPointerEvent::EDrag)
|
|
1046 |
{
|
|
1047 |
iPressed = hit && !iVScrollBarGrabsPointerEvents && !isActiveSplitEditor;
|
|
1048 |
}
|
|
1049 |
|
|
1050 |
if (pressed != iPressed)
|
|
1051 |
{
|
|
1052 |
GetShell().UpdateHighlight(ETrue); // draw now
|
|
1053 |
}
|
|
1054 |
#endif
|
|
1055 |
|
|
1056 |
#ifndef RD_JAVA_S60_RELEASE_9_2
|
|
1057 |
// We got a pointer event, so any subsequent events should not be ignored.
|
|
1058 |
iIgnorePointerDown = EFalse;
|
|
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 |
}
|
|
1066 |
|
|
1067 |
PostMouseEventL(aPointerEvent);
|
|
1068 |
}
|
|
1069 |
#else //RD_SCALABLE_UI_V2
|
|
1070 |
void CSwtTextBase::HandlePointerEventL(
|
|
1071 |
const TPointerEvent& /*aPointerEvent*/)
|
|
1072 |
{
|
|
1073 |
}
|
|
1074 |
#endif //RD_SCALABLE_UI_V2
|
|
1075 |
|
|
1076 |
// ---------------------------------------------------------------------------
|
|
1077 |
// CSwtTextBase::FocusChanged
|
|
1078 |
// From CCoeControl
|
|
1079 |
// ---------------------------------------------------------------------------
|
|
1080 |
//
|
|
1081 |
void CSwtTextBase::FocusChanged(TDrawNow aDrawNow)
|
|
1082 |
{
|
|
1083 |
if (iEditor)
|
|
1084 |
{
|
|
1085 |
TRAP_IGNORE(iEditor->UpdateScrollBarsL());
|
|
1086 |
}
|
|
1087 |
|
|
1088 |
if (iEditor)
|
|
1089 |
{
|
|
1090 |
if (iIndicator)
|
|
1091 |
{
|
|
1092 |
if (!IsFocused())
|
|
1093 |
iIndicator->SetState(EStateNone);
|
|
1094 |
}
|
|
1095 |
|
|
1096 |
iEditor->SetFocus(IsFocused());
|
|
1097 |
}
|
|
1098 |
|
|
1099 |
HandleFocusChanged(aDrawNow);
|
|
1100 |
}
|
|
1101 |
|
|
1102 |
// ---------------------------------------------------------------------------
|
|
1103 |
// CSwtTextBase::PositionChanged
|
|
1104 |
// From CCoeControl
|
|
1105 |
// ---------------------------------------------------------------------------
|
|
1106 |
//
|
|
1107 |
void CSwtTextBase::PositionChanged()
|
|
1108 |
{
|
|
1109 |
if (!iEditor)
|
|
1110 |
{
|
|
1111 |
return;
|
|
1112 |
}
|
|
1113 |
|
|
1114 |
// The size of scrollbars are set to ( 0,0 )
|
|
1115 |
// to be correctly updated in editor.
|
|
1116 |
CEikScrollBarFrame* sbFrame = SbFrame();
|
|
1117 |
if (sbFrame)
|
|
1118 |
{
|
|
1119 |
CEikScrollBar* verticalScrollBar = sbFrame->
|
|
1120 |
GetScrollBarHandle(CEikScrollBar::EVertical);
|
|
1121 |
if (verticalScrollBar)
|
|
1122 |
{
|
|
1123 |
verticalScrollBar->SetSize(TSize(0, 0));
|
|
1124 |
}
|
|
1125 |
CEikScrollBar* horizScrollBar = sbFrame->
|
|
1126 |
GetScrollBarHandle(CEikScrollBar::EHorizontal);
|
|
1127 |
if (horizScrollBar)
|
|
1128 |
{
|
|
1129 |
horizScrollBar->SetSize(TSize(0, 0));
|
|
1130 |
}
|
|
1131 |
}
|
|
1132 |
|
|
1133 |
//Position indicator
|
|
1134 |
TRect editorRect(SbInnerRect(BorderInnerRect()));
|
|
1135 |
|
|
1136 |
if (iIndicator)
|
|
1137 |
{
|
|
1138 |
const TPoint indPos(iPosition.iX + GetBorderWidth(),
|
|
1139 |
iPosition.iY + GetBorderWidth());
|
|
1140 |
iIndicator->IndicatorContainer()->SetPosition(indPos);
|
|
1141 |
editorRect.SetRect(TPoint(editorRect.iTl.iX,
|
|
1142 |
indPos.iY + KSWTEditIndicatorHeight), editorRect.iBr);
|
|
1143 |
}
|
|
1144 |
|
|
1145 |
// We have to call CEikEdwin::SetRect() to update the location
|
|
1146 |
// of the editor member on the screen.
|
|
1147 |
if (AknLayoutUtils::LayoutMirrored())
|
|
1148 |
{
|
|
1149 |
iEditor->SetAlignment(EAknEditorAlignRight);
|
|
1150 |
const TSize sbDelta(SbOuterRect(TRect()).Size());
|
|
1151 |
editorRect.iTl.iX += sbDelta.iWidth;
|
|
1152 |
}
|
|
1153 |
|
|
1154 |
iEditor->SetRect(editorRect);
|
|
1155 |
HandlePositionChanged();
|
|
1156 |
|
|
1157 |
// Notify change to UiUtils if this is an editor open for split view editing.
|
|
1158 |
MSwtUiUtils& utils = iDisplay.UiUtils();
|
|
1159 |
if (utils.SplitInputView() == this)
|
|
1160 |
{
|
|
1161 |
utils.AdjustSplitInputShellPos();
|
|
1162 |
}
|
|
1163 |
}
|
|
1164 |
|
|
1165 |
// ---------------------------------------------------------------------------
|
|
1166 |
// CSwtTextBase::SizeChanged
|
|
1167 |
// From CCoeControl
|
|
1168 |
// ---------------------------------------------------------------------------
|
|
1169 |
//
|
|
1170 |
void CSwtTextBase::SizeChanged()
|
|
1171 |
{
|
|
1172 |
if (!iEditor)
|
|
1173 |
{
|
|
1174 |
return;
|
|
1175 |
}
|
|
1176 |
const TSize sbDelta(SbOuterRect(TRect()).Size());
|
|
1177 |
const TSize ownBorderDelta(BorderSizeDelta());
|
|
1178 |
if (AknLayoutUtils::LayoutMirrored())
|
|
1179 |
{
|
|
1180 |
iEditor->SetAlignment(EAknEditorAlignRight);
|
|
1181 |
}
|
|
1182 |
if (iIndicator)
|
|
1183 |
{
|
|
1184 |
const TSize indicatorSize(
|
|
1185 |
BorderInnerRect().Size().iWidth,
|
|
1186 |
KSWTEditIndicatorHeight);
|
|
1187 |
iIndicator->IndicatorContainer()->SetSize(indicatorSize);
|
|
1188 |
TSize editorSize = iSize - sbDelta - ownBorderDelta;
|
|
1189 |
editorSize.iHeight -= indicatorSize.iHeight;
|
|
1190 |
iEditor->SetSize(editorSize);
|
|
1191 |
}
|
|
1192 |
else
|
|
1193 |
{
|
|
1194 |
iEditor->SetSize(iSize - sbDelta - ownBorderDelta);
|
|
1195 |
}
|
|
1196 |
|
|
1197 |
if (HasBorderStyle())
|
|
1198 |
{
|
|
1199 |
iEditor->SetPosition(BorderInnerRect().iTl);
|
|
1200 |
}
|
|
1201 |
|
|
1202 |
HandleSizeChanged();
|
|
1203 |
}
|
|
1204 |
|
|
1205 |
// ---------------------------------------------------------------------------
|
|
1206 |
// CSwtTextBase::MopSupplyObject
|
|
1207 |
// From CCoeControl
|
|
1208 |
// ---------------------------------------------------------------------------
|
|
1209 |
//
|
|
1210 |
TTypeUid::Ptr CSwtTextBase::MopSupplyObject(TTypeUid aId)
|
|
1211 |
{
|
|
1212 |
if (iIndicator && aId.iUid == MAknEditingStateIndicator::ETypeId)
|
|
1213 |
{
|
|
1214 |
return aId.MakePtr(static_cast<MAknEditingStateIndicator*>(iIndicator));
|
|
1215 |
}
|
|
1216 |
TTypeUid::Ptr id = ASwtControlBase::SwtMopSupplyObject(aId);
|
|
1217 |
|
|
1218 |
if (id.Pointer() == NULL)
|
|
1219 |
{
|
|
1220 |
return CCoeControl::MopSupplyObject(aId);
|
|
1221 |
}
|
|
1222 |
else
|
|
1223 |
{
|
|
1224 |
return id;
|
|
1225 |
}
|
|
1226 |
}
|
|
1227 |
|
|
1228 |
// ---------------------------------------------------------------------------
|
|
1229 |
// CSwtTextBase::CoeControl
|
|
1230 |
// From MSwtControl
|
|
1231 |
// ---------------------------------------------------------------------------
|
|
1232 |
//
|
|
1233 |
CCoeControl& CSwtTextBase::CoeControl()
|
|
1234 |
{
|
|
1235 |
return *this;
|
|
1236 |
}
|
|
1237 |
|
|
1238 |
// ---------------------------------------------------------------------------
|
|
1239 |
// CSwtTextBase::CoeControl
|
|
1240 |
// From MSwtControl
|
|
1241 |
// ---------------------------------------------------------------------------
|
|
1242 |
//
|
|
1243 |
const CCoeControl& CSwtTextBase::CoeControl() const
|
|
1244 |
{
|
|
1245 |
return *this;
|
|
1246 |
}
|
|
1247 |
|
|
1248 |
// ---------------------------------------------------------------------------
|
|
1249 |
// CSwtTextBase::SetSwtFocus
|
|
1250 |
// From MSwtControl
|
|
1251 |
// ---------------------------------------------------------------------------
|
|
1252 |
//
|
|
1253 |
TBool CSwtTextBase::SetSwtFocus(TInt aReason /*=KSwtFocusByApi*/)
|
|
1254 |
{
|
|
1255 |
#ifndef RD_JAVA_S60_RELEASE_9_2
|
|
1256 |
iIgnorePointerDown = EFalse;
|
|
1257 |
if (IsFocusControl())
|
|
1258 |
{
|
|
1259 |
return ETrue;
|
|
1260 |
}
|
|
1261 |
iIgnorePointerDown = aReason == KSwtFocusByPointer;
|
|
1262 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
1263 |
return ASwtControlBase::SetSwtFocus(aReason);
|
|
1264 |
}
|
|
1265 |
|
|
1266 |
// ---------------------------------------------------------------------------
|
|
1267 |
// CSwtTextBase::ClientRect
|
|
1268 |
// From MSwtControl
|
|
1269 |
// ---------------------------------------------------------------------------
|
|
1270 |
//
|
|
1271 |
TRect CSwtTextBase::ClientRect() const
|
|
1272 |
{
|
|
1273 |
TRect rect(ASwtScrollableBase::ClientRect());
|
|
1274 |
if (iIndicator)
|
|
1275 |
{
|
|
1276 |
rect.iTl.iY = iIndicator->IndicatorContainer()->Rect().iBr.iY;
|
|
1277 |
}
|
|
1278 |
return rect;
|
|
1279 |
}
|
|
1280 |
|
|
1281 |
// ---------------------------------------------------------------------------
|
|
1282 |
// CSwtTextBase::SetFontL
|
|
1283 |
// From MSwtControl
|
|
1284 |
// ---------------------------------------------------------------------------
|
|
1285 |
//
|
|
1286 |
void CSwtTextBase::SetFontL(const MSwtFont* aFont)
|
|
1287 |
{
|
|
1288 |
ASwtControlBase::DoSetFontL(aFont);
|
|
1289 |
|
|
1290 |
// Set the font in the edwin
|
|
1291 |
if (iEditor)
|
|
1292 |
{
|
|
1293 |
ProcessFontUpdateL();
|
|
1294 |
iEditor->HandleTextChangedL();
|
|
1295 |
}
|
|
1296 |
|
|
1297 |
Redraw();
|
|
1298 |
}
|
|
1299 |
|
|
1300 |
// ---------------------------------------------------------------------------
|
|
1301 |
// CSwtTextBase::ComputeSizeL
|
|
1302 |
// From MSwtControl
|
|
1303 |
// ---------------------------------------------------------------------------
|
|
1304 |
//
|
|
1305 |
TSize CSwtTextBase::ComputeSizeL(TInt aWHint, TInt aHHint)
|
|
1306 |
{
|
|
1307 |
if (!iEditor)
|
|
1308 |
{
|
|
1309 |
// iEditor could be null if the CSwtTextBase is contained in a
|
|
1310 |
// CaptionedControl.
|
|
1311 |
return TSize(0, 0);
|
|
1312 |
}
|
|
1313 |
|
|
1314 |
if (aWHint != KSwtDefault && aHHint != KSwtDefault)
|
|
1315 |
{
|
|
1316 |
return TSize(aWHint, aHHint);
|
|
1317 |
}
|
|
1318 |
|
|
1319 |
const TSize delta(ComputeDelta());
|
|
1320 |
const TInt maxWidth = KMaxTInt - delta.iWidth;
|
|
1321 |
|
|
1322 |
TSize prefSize(TSize::EUninitialized);
|
|
1323 |
|
|
1324 |
CTextView* textView = iEditor->TextView();
|
|
1325 |
CTextLayout* layout = const_cast<CTextLayout*>(textView->Layout());
|
|
1326 |
|
|
1327 |
if (aWHint == KSwtDefault)
|
|
1328 |
{
|
|
1329 |
layout->SetWrapWidth(maxWidth);
|
|
1330 |
}
|
|
1331 |
else
|
|
1332 |
{
|
|
1333 |
layout->SetWrapWidth(aWHint);
|
|
1334 |
}
|
|
1335 |
|
|
1336 |
TViewYPosQualifier yPosQualifier;
|
|
1337 |
yPosQualifier.SetFillScreen();
|
|
1338 |
yPosQualifier.SetMakeLineFullyVisible();
|
|
1339 |
textView->HandleGlobalChangeNoRedrawL(yPosQualifier);
|
|
1340 |
TInt formatedHeight = layout->FormattedHeightInPixels();
|
|
1341 |
|
|
1342 |
// if width is free, no effect for wraping. that is swt implementation
|
|
1343 |
if (aWHint == KSwtDefault)
|
|
1344 |
{
|
|
1345 |
layout->GetMinimumSizeL(maxWidth, prefSize);
|
|
1346 |
}
|
|
1347 |
else
|
|
1348 |
{
|
|
1349 |
// if width is fixed, height is free
|
|
1350 |
// if wrapping is on, the Height should be heights of all lines that all
|
|
1351 |
// characters fit in vertically ( note: VSrolling shouldn't be there )
|
|
1352 |
// if wrap is off, the Height should be heights of all lines and
|
|
1353 |
// HScrolling if any of the line width is bigger than given width
|
|
1354 |
layout->GetMinimumSizeL(aWHint, prefSize);
|
|
1355 |
prefSize.iHeight = formatedHeight;
|
|
1356 |
}
|
|
1357 |
|
|
1358 |
prefSize += delta;
|
|
1359 |
|
|
1360 |
if (aWHint != KSwtDefault)
|
|
1361 |
{
|
|
1362 |
prefSize.iWidth = aWHint;
|
|
1363 |
}
|
|
1364 |
if (aHHint != KSwtDefault)
|
|
1365 |
{
|
|
1366 |
prefSize.iHeight = aHHint;
|
|
1367 |
}
|
|
1368 |
|
|
1369 |
return prefSize;
|
|
1370 |
}
|
|
1371 |
|
|
1372 |
// ---------------------------------------------------------------------------
|
|
1373 |
// CSwtTextBase::IsKeyUsed
|
|
1374 |
// From MSwtControl
|
|
1375 |
// ---------------------------------------------------------------------------
|
|
1376 |
//
|
|
1377 |
TBool CSwtTextBase::IsKeyUsed(TUint aKeyCode) const
|
|
1378 |
{
|
|
1379 |
// A text uses the Backspace and OK keys
|
|
1380 |
if (aKeyCode == EKeyBackspace)
|
|
1381 |
{
|
|
1382 |
return ETrue;
|
|
1383 |
}
|
|
1384 |
else if (aKeyCode == EKeyOK)
|
|
1385 |
{
|
|
1386 |
return EFalse;
|
|
1387 |
}
|
|
1388 |
return ETrue;
|
|
1389 |
}
|
|
1390 |
|
|
1391 |
// ---------------------------------------------------------------------------
|
|
1392 |
// CSwtTextBase::CanDrawOutsideRect
|
|
1393 |
// Needed for drawing the scrollbars in multi line texts!
|
|
1394 |
// From MSwtControl
|
|
1395 |
// ---------------------------------------------------------------------------
|
|
1396 |
//
|
|
1397 |
TBool CSwtTextBase::CanDrawOutsideRect() const
|
|
1398 |
{
|
|
1399 |
return ETrue;
|
|
1400 |
}
|
|
1401 |
|
|
1402 |
// ---------------------------------------------------------------------------
|
|
1403 |
// CSwtTextBase::DefaultFont
|
|
1404 |
// From ASwtControlBase
|
|
1405 |
// ---------------------------------------------------------------------------
|
|
1406 |
//
|
|
1407 |
const MSwtFont& CSwtTextBase::DefaultFont() const
|
|
1408 |
{
|
|
1409 |
ASSERT(iDefaultFont);
|
|
1410 |
return *iDefaultFont;
|
|
1411 |
|
|
1412 |
}
|
|
1413 |
|
|
1414 |
// ---------------------------------------------------------------------------
|
|
1415 |
// CSwtTextBase::SbFrame
|
|
1416 |
// From ASwtScrollableBase
|
|
1417 |
// ---------------------------------------------------------------------------
|
|
1418 |
//
|
|
1419 |
CEikScrollBarFrame* CSwtTextBase::SbFrame() const
|
|
1420 |
{
|
|
1421 |
return (iEditor!=NULL) ? iEditor->ScrollBarFrame() : NULL;
|
|
1422 |
}
|
|
1423 |
|
|
1424 |
// ---------------------------------------------------------------------------
|
|
1425 |
// CSwtListBase::HandleScrollEventL
|
|
1426 |
// From MEikScrollBarObserver
|
|
1427 |
// ---------------------------------------------------------------------------
|
|
1428 |
//
|
|
1429 |
#ifdef RD_SCALABLE_UI_V2
|
|
1430 |
void CSwtTextBase::HandleScrollEventL(
|
|
1431 |
CEikScrollBar* aScrollBar,
|
|
1432 |
TEikScrollEvent aEventType)
|
|
1433 |
{
|
|
1434 |
iEditor->HandleScrollEventL(aScrollBar, aEventType);
|
|
1435 |
ASwtScrollableBase::HandleScrollEventL(aScrollBar, aEventType);
|
|
1436 |
}
|
|
1437 |
#else //RD_SCALABLE_UI_V2
|
|
1438 |
void CSwtTextBase::HandleScrollEventL(
|
|
1439 |
CEikScrollBar*,
|
|
1440 |
TEikScrollEvent)
|
|
1441 |
{
|
|
1442 |
}
|
|
1443 |
#endif //RD_SCALABLE_UI_V2
|