|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Implementation for base control |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <peninputcmd.h> |
|
20 #include <coemain.h> |
|
21 #include <txtrich.h> |
|
22 #include <frmtlay.h> |
|
23 #include <frmtview.h> |
|
24 #include <eiksbfrm.h> |
|
25 #include <aknappui.h> |
|
26 #include <AknUtils.h> |
|
27 #include <w32std.h> |
|
28 #include <frmtlay.h> |
|
29 #include <AknsDrawUtils.h> |
|
30 #include <avkon.hrh> |
|
31 #include <AknBidiTextUtils.h> |
|
32 #include <bidivisual.h> |
|
33 |
|
34 #include "peninputlayoutbubblectrl.h" |
|
35 |
|
36 #include "peninputlayoutmultilineicf.h" |
|
37 #include "peninputlayout.h" |
|
38 #include "peninputlayoutcursor.h" |
|
39 #include "peninputlayoutmicfcustomdraw.h" |
|
40 #include "peninputlayoutmicfnomatchesinline.h" |
|
41 |
|
42 #include <gdi.h> |
|
43 |
|
44 EXPORT_C CFepLayoutMultiLineIcf* CFepLayoutMultiLineIcf::NewL(TRect aRect, |
|
45 CFepUiLayout* aUiLayout, |
|
46 TInt aControlId, |
|
47 TInt aFontHeight, |
|
48 TInt aMaxFontHeight, |
|
49 const CFont* aFont) |
|
50 { |
|
51 CFepLayoutMultiLineIcf* self = new (ELeave) CFepLayoutMultiLineIcf(aUiLayout,aControlId); |
|
52 CleanupStack::PushL(self); |
|
53 self->BaseConstructL(aRect, aFontHeight, aMaxFontHeight, aFont); |
|
54 CleanupStack::Pop(self); |
|
55 return self; |
|
56 } |
|
57 |
|
58 EXPORT_C CFepLayoutMultiLineIcf::CFepLayoutMultiLineIcf(CFepUiLayout* aUiLayout, |
|
59 TInt aControlId) |
|
60 :CControlGroup(aUiLayout,aControlId) |
|
61 { |
|
62 SetControlType(ECtrlEditAreaBase|ECtrlControlGroup); |
|
63 } |
|
64 |
|
65 EXPORT_C void CFepLayoutMultiLineIcf::BaseConstructL(TRect aRect, |
|
66 TInt aFontHeight, |
|
67 TInt aMaxFontHeight, |
|
68 const CFont* aFont) |
|
69 { |
|
70 CControlGroup::ConstructL(); |
|
71 |
|
72 iMsgBubble = CBubbleCtrl::NewL(TRect(0,0,0,0),UiLayout(),-0xFFFE); |
|
73 |
|
74 iInfoBubble = CBubbleCtrl::NewL(TRect(0,0,0,0),UiLayout(),-0xFFFE); |
|
75 AddControlL(iMsgBubble); |
|
76 |
|
77 AddControlL(iInfoBubble); |
|
78 iIcfEditor = CFepLayoutMultiLineIcfEditor::NewL(aRect,UiLayout(),-0xFFFD,aFontHeight, |
|
79 aMaxFontHeight,aFont); |
|
80 iIcfEditor->SetMsgBubble(iMsgBubble); |
|
81 iIcfEditor->SetInfoBubble(iInfoBubble); |
|
82 AddControlL(iIcfEditor); |
|
83 iIcfEditor->AddEventObserver(this); |
|
84 //EnableTextSelection(EFalse); |
|
85 iTooltip = CTooltipBubbleCtrl::NewL( TRect(0,0,0,0), UiLayout(), -0xFFFC ); |
|
86 iTooltip->AddEventObserver(this); |
|
87 iIcfEditor->SetTooltip( iTooltip ); |
|
88 AddControlL( iTooltip ); |
|
89 } |
|
90 |
|
91 |
|
92 EXPORT_C void CFepLayoutMultiLineIcf::SetTextAlignmentL(TInt aAlignment, TInt aLanguage) |
|
93 { |
|
94 iIcfEditor->SetTextAlignmentL(aAlignment, aLanguage); |
|
95 } |
|
96 |
|
97 EXPORT_C void CFepLayoutMultiLineIcf::SetTextColorL(const TRgb aColor) |
|
98 { |
|
99 iIcfEditor->SetTextColorL(aColor); |
|
100 } |
|
101 |
|
102 EXPORT_C void CFepLayoutMultiLineIcf::SetTextSelColorL(const TRgb aColor) |
|
103 { |
|
104 iIcfEditor->SetTextSelColorL(aColor); |
|
105 } |
|
106 |
|
107 EXPORT_C void CFepLayoutMultiLineIcf::SetAutoCompleteTextColor(const TRgb aColor) |
|
108 { |
|
109 iIcfEditor->SetAutoCompleteTextColor(aColor); |
|
110 } |
|
111 |
|
112 EXPORT_C TBool CFepLayoutMultiLineIcf::IsFocused() |
|
113 { |
|
114 return iIcfEditor->IsFocused(); |
|
115 } |
|
116 |
|
117 |
|
118 EXPORT_C const HBufC* CFepLayoutMultiLineIcf::PromptText() |
|
119 { |
|
120 return iIcfEditor->PromptText(); |
|
121 } |
|
122 |
|
123 EXPORT_C void CFepLayoutMultiLineIcf::SetPromptTextL(const TDesC& aPromptText, TBool aCleanContent ) |
|
124 { |
|
125 return iIcfEditor->SetPromptTextL(aPromptText, aCleanContent ); |
|
126 } |
|
127 |
|
128 EXPORT_C void CFepLayoutMultiLineIcf::SetTextL(const TFepInputContextFieldData& aData) |
|
129 { |
|
130 return iIcfEditor->SetTextL(aData); |
|
131 } |
|
132 |
|
133 EXPORT_C void CFepLayoutMultiLineIcf::SetDimmed(TBool aDimFlag) |
|
134 { |
|
135 iIcfEditor->SetDimmed(aDimFlag); |
|
136 } |
|
137 |
|
138 EXPORT_C void CFepLayoutMultiLineIcf::SetFontL(TInt aFontHeight, |
|
139 TInt aMaxFontHeight, |
|
140 const CFont* aFont) |
|
141 { |
|
142 iIcfEditor->SetFontL(aFontHeight,aMaxFontHeight,aFont); |
|
143 } |
|
144 |
|
145 EXPORT_C void CFepLayoutMultiLineIcf::SetFocus(TBool aFlag) |
|
146 { |
|
147 iIcfEditor->SetFocus(aFlag); |
|
148 } |
|
149 |
|
150 EXPORT_C void CFepLayoutMultiLineIcf::SetCursorVisible( TBool aCursorVisibleFlag ) |
|
151 { |
|
152 iIcfEditor->SetCursorVisible(aCursorVisibleFlag); |
|
153 } |
|
154 |
|
155 EXPORT_C TBool CFepLayoutMultiLineIcf::CursorVisible() const |
|
156 { |
|
157 return iIcfEditor->CursorVisible(); |
|
158 } |
|
159 |
|
160 |
|
161 EXPORT_C void CFepLayoutMultiLineIcf::SetRect(const TRect& aRect) |
|
162 { |
|
163 iIcfEditor->SetRect(aRect); |
|
164 CFepUiBaseCtrl::SetRect(aRect); |
|
165 //SetMsgBubbleRect(); |
|
166 } |
|
167 |
|
168 |
|
169 EXPORT_C void CFepLayoutMultiLineIcf::SetMsgBubbleCtrlSize(const TSize& aSize) |
|
170 { |
|
171 TPoint leftTop = TPoint(Rect().iBr.iX-iMsgBubble->Rect().Width(),Rect().iTl.iY); |
|
172 iMsgBubble->SetRect( TRect(leftTop,aSize) ) ; |
|
173 } |
|
174 EXPORT_C void CFepLayoutMultiLineIcf::SetInfoBubbleCtrlSize(const TSize& aSize) |
|
175 { |
|
176 TPoint leftTop = TPoint(Rect().iBr.iX-iInfoBubble->Rect().Width(),Rect().iTl.iY); |
|
177 iInfoBubble->SetRect( TRect(leftTop,aSize) ) ; |
|
178 } |
|
179 |
|
180 |
|
181 EXPORT_C void CFepLayoutMultiLineIcf::SizeChangedL(const TRect& aRect, |
|
182 TInt aFontHeight, |
|
183 TInt aMaxFontHeight, |
|
184 const CFont* aFont) |
|
185 { |
|
186 iIcfEditor->SizeChangedL(aRect,aFontHeight,aMaxFontHeight,aFont); |
|
187 CFepUiBaseCtrl::SetRect(aRect); |
|
188 return; |
|
189 } |
|
190 |
|
191 |
|
192 EXPORT_C CFepUiBaseCtrl* CFepLayoutMultiLineIcf::HandlePointerDownEventL(const TPoint& aPt) |
|
193 { |
|
194 CFepUiBaseCtrl* ctrl = ControlForPoints( aPt ); |
|
195 if ( ctrl == iTooltip ) |
|
196 { |
|
197 return iTooltip; |
|
198 } |
|
199 return iIcfEditor->HandlePointerDownEventL(aPt); |
|
200 } |
|
201 |
|
202 EXPORT_C CFepUiBaseCtrl* CFepLayoutMultiLineIcf::HandlePointerUpEventL(const TPoint& aPt) |
|
203 { |
|
204 CFepUiBaseCtrl* ctrl = ControlForPoints( aPt ); |
|
205 if ( ctrl == iTooltip ) |
|
206 { |
|
207 return iTooltip->HandlePointerUpEventL( aPt ); |
|
208 } |
|
209 return iIcfEditor->HandlePointerUpEventL(aPt); |
|
210 } |
|
211 |
|
212 EXPORT_C CFepUiBaseCtrl* CFepLayoutMultiLineIcf::HandlePointerMoveEventL(const TPoint& aPt) |
|
213 { |
|
214 return iIcfEditor->HandlePointerMoveEventL(aPt); |
|
215 } |
|
216 |
|
217 EXPORT_C void CFepLayoutMultiLineIcf::CancelPointerDownL() |
|
218 { |
|
219 iIcfEditor->CancelPointerDownL(); |
|
220 } |
|
221 |
|
222 EXPORT_C void CFepLayoutMultiLineIcf::HandlePointerLeave(const TPoint& aPt) |
|
223 { |
|
224 iIcfEditor->HandlePointerLeave(aPt); |
|
225 } |
|
226 |
|
227 EXPORT_C void CFepLayoutMultiLineIcf::PrepareForFocusLoss() |
|
228 { |
|
229 iIcfEditor->PrepareForFocusLoss(); |
|
230 //ReportEvent(EEventControlFocusLost); |
|
231 } |
|
232 |
|
233 EXPORT_C TBool CFepLayoutMultiLineIcf::PrepareForFocusGain() |
|
234 { |
|
235 iIcfEditor->PrepareForFocusGain(); |
|
236 //ReportEvent(EEventControlFocusGained); |
|
237 |
|
238 return ETrue; |
|
239 } |
|
240 |
|
241 EXPORT_C void CFepLayoutMultiLineIcf::Move(const TPoint& aOffset) |
|
242 { |
|
243 CFepUiBaseCtrl::Move(aOffset); |
|
244 iIcfEditor->Move(aOffset); |
|
245 //How about the msg bubble? |
|
246 } |
|
247 |
|
248 EXPORT_C void CFepLayoutMultiLineIcf::HandleArrowBtnEventL(TArrowBtnEvent aEventType) |
|
249 { |
|
250 iIcfEditor->HandleArrowBtnEventL(aEventType); |
|
251 } |
|
252 |
|
253 EXPORT_C TBool CFepLayoutMultiLineIcf::Contains(const TPoint& aPt) |
|
254 { |
|
255 return iIcfEditor->Contains(aPt); |
|
256 } |
|
257 |
|
258 EXPORT_C void CFepLayoutMultiLineIcf::SetOverLapState(TBool aSupportOverLap, TRect aRect) |
|
259 { |
|
260 iIcfEditor->SetOverLapState(aSupportOverLap, aRect); |
|
261 } |
|
262 |
|
263 EXPORT_C void CFepLayoutMultiLineIcf::AddOverLapState(TRect aRect) |
|
264 { |
|
265 iIcfEditor->AddOverLapState(aRect); |
|
266 } |
|
267 |
|
268 EXPORT_C TInt CFepLayoutMultiLineIcf::GetEditorFieldMaxLen() |
|
269 { |
|
270 return iRect.Width()/2; |
|
271 } |
|
272 |
|
273 EXPORT_C TBool CFepLayoutMultiLineIcf::IsEmpty() |
|
274 { |
|
275 return iIcfEditor->IsEmpty(); |
|
276 } |
|
277 |
|
278 EXPORT_C void CFepLayoutMultiLineIcf::InlineTextPos(TPoint& aPosBelow, TPoint& aPosRight) |
|
279 { |
|
280 iIcfEditor->InlineTextPos(aPosBelow,aPosRight); |
|
281 } |
|
282 |
|
283 |
|
284 EXPORT_C CBubbleCtrl* CFepLayoutMultiLineIcf::MsgBubbleCtrl() |
|
285 { |
|
286 return iMsgBubble; |
|
287 } |
|
288 EXPORT_C CBubbleCtrl* CFepLayoutMultiLineIcf::InfoBubbleCtrl() |
|
289 { |
|
290 return iInfoBubble; |
|
291 } |
|
292 EXPORT_C void CFepLayoutMultiLineIcf::ShowBubble(const TDesC& aText, const TRect& aRect) |
|
293 { |
|
294 return iIcfEditor->ShowBubble(aText,aRect); |
|
295 } |
|
296 EXPORT_C void CFepLayoutMultiLineIcf::ShowByteWarningBubble(const TDesC& aInfo) |
|
297 { |
|
298 iIcfEditor->ShowByteWarningBubble(aInfo); |
|
299 } |
|
300 |
|
301 EXPORT_C void CFepLayoutMultiLineIcf::HideBubble() |
|
302 { |
|
303 iIcfEditor->HideBubble(); |
|
304 } |
|
305 EXPORT_C void CFepLayoutMultiLineIcf::HideInfoBubble() |
|
306 { |
|
307 iIcfEditor->HideInfoBubble(); |
|
308 } |
|
309 |
|
310 EXPORT_C void CFepLayoutMultiLineIcf::ExtractText(TDes &aBuf, TInt aPos, TInt aLength) |
|
311 { |
|
312 iIcfEditor->ExtractText(aBuf, aPos, aLength); |
|
313 } |
|
314 |
|
315 |
|
316 EXPORT_C void CFepLayoutMultiLineIcf::EnableTextSelection(TBool aEnable) |
|
317 { |
|
318 return iIcfEditor->EnableTextSelection(aEnable); |
|
319 } |
|
320 /* |
|
321 EXPORT_C TBool CFepLayoutMultiLineIcf::TextSelectionOn() |
|
322 { |
|
323 return iIcfEditor->TextSelectionOn(); |
|
324 } |
|
325 */ |
|
326 EXPORT_C TBool CFepLayoutMultiLineIcf::InlineStateOn() |
|
327 { |
|
328 return iIcfEditor->InlineStateOn(); |
|
329 } |
|
330 |
|
331 EXPORT_C void CFepLayoutMultiLineIcf::SetTextIsSecret(TBool aIsSecret) |
|
332 { |
|
333 return iIcfEditor->SetTextIsSecret(aIsSecret); |
|
334 } |
|
335 |
|
336 EXPORT_C TBool CFepLayoutMultiLineIcf::TextIsSecret() const |
|
337 { |
|
338 return iIcfEditor->TextIsSecret(); |
|
339 } |
|
340 |
|
341 /*EXPORT_C TBool CFepLayoutMultiLineIcf::AutoCompleteStateOn() |
|
342 { |
|
343 return iIcfEditor->AutoCompleteStateOn(); |
|
344 } |
|
345 */ |
|
346 EXPORT_C void CFepLayoutMultiLineIcf::SetBgImgSkinId(TAknsItemID aSkinId) |
|
347 { |
|
348 iIcfEditor->SetBgImgSkinId(aSkinId); |
|
349 } |
|
350 |
|
351 EXPORT_C void CFepLayoutMultiLineIcf::SetLineSeparatorAfterPrompt(TBool aLineSeparator) |
|
352 { |
|
353 iIcfEditor->SetLineSeparatorAfterPrompt(aLineSeparator); |
|
354 } |
|
355 |
|
356 EXPORT_C void CFepLayoutMultiLineIcf::SetLanguageId( TInt aLanguageId ) |
|
357 { |
|
358 iIcfEditor->SetLanguageId(aLanguageId); |
|
359 } |
|
360 |
|
361 EXPORT_C TBool CFepLayoutMultiLineIcf::NomatchState() |
|
362 { |
|
363 return iIcfEditor->NomatchState(); |
|
364 } |
|
365 |
|
366 EXPORT_C void CFepLayoutMultiLineIcf::SetTextMargin |
|
367 (TInt aLeftMargin, TInt aRightMargin, TInt aTopMargin, TInt aBottomMargin) |
|
368 { |
|
369 iIcfEditor->SetTextMargin(aLeftMargin, aRightMargin, aTopMargin, aBottomMargin); |
|
370 } |
|
371 |
|
372 EXPORT_C void CFepLayoutMultiLineIcf::SetLineSpace( TInt aLineSpace ) |
|
373 { |
|
374 iIcfEditor->SetLineSpace( aLineSpace ); |
|
375 } |
|
376 |
|
377 void CFepLayoutMultiLineIcf::UpdateValidRegion(CFepUiBaseCtrl* aCtrl,TBool aRemoveFlag) |
|
378 { |
|
379 if(iIcfEditor) |
|
380 iIcfEditor->UpdateValidRegion(aCtrl,aRemoveFlag); |
|
381 } |
|
382 |
|
383 EXPORT_C void CFepLayoutMultiLineIcf::HandleControlEvent(TInt aEventType, CFepUiBaseCtrl* /*aCtrl*/, |
|
384 const TDesC& aEventData) |
|
385 { |
|
386 ReportEvent(aEventType,aEventData); |
|
387 } |
|
388 |
|
389 EXPORT_C void CFepLayoutMultiLineIcf::SetBackgroundBitmapL(CFbsBitmap* aBmp) |
|
390 { |
|
391 if(iIcfEditor) |
|
392 iIcfEditor->SetBackgroundBitmapL(aBmp); |
|
393 } |
|
394 |
|
395 EXPORT_C void CFepLayoutMultiLineIcf::UpdateSecretTextL() |
|
396 { |
|
397 if(iIcfEditor) |
|
398 iIcfEditor->UpdateSecretTextL(); |
|
399 } |
|
400 |
|
401 EXPORT_C void CFepLayoutMultiLineIcf::ReDrawRect(const TRect& aRect) |
|
402 { |
|
403 if(!AbleToDraw()) |
|
404 return; |
|
405 |
|
406 if(aRect.IsEmpty()) |
|
407 return; |
|
408 if(aRect == Rect()) |
|
409 { |
|
410 Draw(); |
|
411 } |
|
412 else |
|
413 { |
|
414 //find out the controls within the rect |
|
415 if(aRect.Intersects( iIcfEditor->Rect())) |
|
416 { |
|
417 iIcfEditor->ReDrawRect(aRect); |
|
418 if(iMsgBubble->IsShowing()) |
|
419 { |
|
420 iMsgBubble->Draw(); |
|
421 } |
|
422 if ( iTooltip && iTooltip->IsShowing() ) |
|
423 { |
|
424 iTooltip->Draw(); |
|
425 } |
|
426 iInfoBubble->Draw(); |
|
427 } |
|
428 } |
|
429 |
|
430 } |
|
431 |
|
432 EXPORT_C void CFepLayoutMultiLineIcf::SetNumberGrouping(TBool aIsNumberGrouping) |
|
433 { |
|
434 TRAP_IGNORE(iIcfEditor->SetNumberGroupingL(aIsNumberGrouping)); |
|
435 } |
|
436 |
|
437 // --------------------------------------------------------------------------- |
|
438 // Return the pointer to Toolitp control |
|
439 // --------------------------------------------------------------------------- |
|
440 // |
|
441 EXPORT_C CTooltipBubbleCtrl* CFepLayoutMultiLineIcf::TooltipBubbleCtrl() |
|
442 { |
|
443 return iTooltip; |
|
444 } |
|
445 |
|
446 // --------------------------------------------------------------------------- |
|
447 // Show tooltip of ICF |
|
448 // --------------------------------------------------------------------------- |
|
449 // |
|
450 EXPORT_C void CFepLayoutMultiLineIcf::ShowTooltipL( const TDesC& aText ) |
|
451 { |
|
452 if ( !iTooltip || !iIcfEditor ) |
|
453 { |
|
454 return; |
|
455 } |
|
456 iIcfEditor->ShowTooltipL( aText ); |
|
457 } |
|
458 |
|
459 // --------------------------------------------------------------------------- |
|
460 // Hide tooltip of ICF |
|
461 // --------------------------------------------------------------------------- |
|
462 // |
|
463 EXPORT_C void CFepLayoutMultiLineIcf::HideTooltip() |
|
464 { |
|
465 if ( !iTooltip || !iIcfEditor ) |
|
466 { |
|
467 return; |
|
468 } |
|
469 if ( iTooltip->IsShowing() ) |
|
470 { |
|
471 iIcfEditor->HideTooltip(); |
|
472 } |
|
473 } |
|
474 |
|
475 // --------------------------------------------------------------------------- |
|
476 // Find what is the control of aPoint. |
|
477 // --------------------------------------------------------------------------- |
|
478 // |
|
479 CFepUiBaseCtrl* CFepLayoutMultiLineIcf::ControlForPoints( const TPoint& aPoint ) |
|
480 { |
|
481 if ( !iTooltip || !iIcfEditor ) |
|
482 { |
|
483 return this; |
|
484 } |
|
485 if ( iTooltip->IsShowing() && iTooltip->Contains( aPoint ) ) |
|
486 { |
|
487 return iTooltip; |
|
488 } |
|
489 if ( iIcfEditor->Contains( aPoint ) ) |
|
490 { |
|
491 return iIcfEditor; |
|
492 } |
|
493 return this; |
|
494 } |
|
495 |
|
496 // End Of File |