|
1 /* |
|
2 * Copyright (c) 2009 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: Candidate list |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <AknsDrawUtils.h> |
|
21 #include <aknconsts.h> // KStatusPaneBackgroundColor |
|
22 #include <skinlayout.cdl.h> // SkinLayout |
|
23 #include <aknlayoutscalable_avkon.cdl.h> // AknLayoutScalable_Avkon |
|
24 #include <peninputcommonlayoutglobalenum.h> // EPeninputLayoutEventRange |
|
25 #include <peninputeventjp.h> // EPeninputLayoutEventSelectItem |
|
26 #include <peninputlayout.h> |
|
27 #include <AknsBasicBackgroundControlContext.h> |
|
28 |
|
29 #include "peninputeventjp.h" |
|
30 #include "peninputjapanesecandidatewnd.h" |
|
31 #include "peninputjapanesecandidatelistbox.h" |
|
32 #include "peninputcontextfieldjp.h" |
|
33 |
|
34 // CONSTANTS |
|
35 const TInt KMaxTitleLength = 32; |
|
36 |
|
37 const TInt KMaxListRows = 7; |
|
38 const TInt KMinListRows = 3; |
|
39 const TInt KMaxListColumns = 6; |
|
40 const TInt KMinListColumns = 3; |
|
41 |
|
42 //default value for long press timer |
|
43 const TInt KLongPressInterval = 600000; |
|
44 |
|
45 //default value for repeat timer |
|
46 const TInt KRepeatInterval = 100000; |
|
47 |
|
48 /** |
|
49 * CPeninputJapaneseCandidateWnd class. |
|
50 * |
|
51 */ |
|
52 |
|
53 // ============================ MEMBER FUNCTIONS =============================== |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CPeninputJapaneseCandidateWnd::NewL |
|
57 // Two-phased constructor. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 EXPORT_C CPeninputJapaneseCandidateWnd* CPeninputJapaneseCandidateWnd::NewL(CFepUiLayout* aUiLayout, |
|
61 TInt aControlId, const CCoeControl* aParent) |
|
62 { |
|
63 CPeninputJapaneseCandidateWnd* self = |
|
64 new(ELeave) CPeninputJapaneseCandidateWnd(aUiLayout, aControlId); |
|
65 CleanupStack::PushL(self); |
|
66 self->ConstructL(aParent); |
|
67 CleanupStack::Pop(self); // self |
|
68 return self; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CPeninputJapaneseCandidateWnd::~CPeninputJapaneseCandidateWnd |
|
73 // Destructor |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CPeninputJapaneseCandidateWnd::~CPeninputJapaneseCandidateWnd() |
|
77 { |
|
78 delete iListBox; |
|
79 CancelScrollBarRepeat(); |
|
80 delete iLongPressTimer; |
|
81 delete iRepeatTimer; |
|
82 if(iAppGc) |
|
83 { |
|
84 CCoeEnv::Static()->SwapSystemGc(iAppGc); |
|
85 } |
|
86 } |
|
87 |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CFepLayoutPopupWnd::SetRect |
|
91 // Set the pop up window's rect |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 EXPORT_C void CPeninputJapaneseCandidateWnd::SetRect(const TRect& aRect) |
|
95 { |
|
96 iRect = aRect; |
|
97 if (iListBox->Parent()) |
|
98 { |
|
99 TRect rect(aRect); |
|
100 rect.iTl = TPoint(0,0); // parent is owning a window. |
|
101 iListBox->Parent()->SetRect(rect); |
|
102 } |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CPeninputJapaneseCandidateWnd::SetCurrentItemIndex |
|
107 // Specify the cursor position of a pop-up list. |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 EXPORT_C void CPeninputJapaneseCandidateWnd::SetPosition(const TPoint& aPos) |
|
111 { |
|
112 iPos = aPos; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CPeninputJapaneseCandidateWnd::SetIcf |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CPeninputJapaneseCandidateWnd::SetIcf(CFepInputContextFieldJp* aInputContextField) |
|
120 { |
|
121 iInputContextField = aInputContextField; |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CPeninputJapaneseCandidateWnd::ShowCandidateListL |
|
126 // Show Pop-up list |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 EXPORT_C void CPeninputJapaneseCandidateWnd::ShowPopupL(CDesCArrayFlat* aItems, TInt aIndex) |
|
130 { |
|
131 if(!Hiden() || aItems->Count() <= 0) |
|
132 { |
|
133 return; |
|
134 } |
|
135 |
|
136 // Set listitems. |
|
137 CTextListBoxModel* model = |
|
138 static_cast<CTextListBoxModel*>(iListBox->Model()); |
|
139 model->SetItemTextArray(aItems); |
|
140 model->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
141 |
|
142 iMaximumColumns = MaximumColumns(model); |
|
143 iMaximumRows = MaximumRows(model); |
|
144 iListBox->SetMaximumColumns(iMaximumColumns); |
|
145 iListBox->SetMaximumRows(iMaximumRows); |
|
146 |
|
147 TSize min = iListBox->MinimumSize(); |
|
148 |
|
149 TAknWindowLineLayout scrollLineLayout = AknLayoutScalable_Avkon::scroll_pane_cp30().LayoutLine(); |
|
150 TInt atom = AknLayoutScalable_Avkon::list_single_choice_list_pane(0).LayoutLine().iH; |
|
151 TInt margin = atom/KPENINPUT_LAYOUT_VALUE_2; |
|
152 TInt rightMargin = atom/KPENINPUT_LAYOUT_VALUE_4; |
|
153 |
|
154 if (iInputContextField) // candidate popup |
|
155 { |
|
156 TRect IcfRect = iInputContextField->Rect(); |
|
157 iPos.iX = IcfRect.iTl.iX + IcfRect.Size().iWidth/KPENINPUT_LAYOUT_VALUE_6; |
|
158 iPos.iY = IcfRect.iBr.iY; |
|
159 } |
|
160 else |
|
161 { |
|
162 iPos.iX -= min.iWidth + rightMargin; |
|
163 iPos.iY -= min.iHeight + margin*KPENINPUT_LAYOUT_VALUE_2; |
|
164 } |
|
165 TRect rect(TRect(iPos,Rect().Size())); |
|
166 |
|
167 rect.iBr.iX = rect.iTl.iX + min.iWidth; |
|
168 if (iMaximumRows < iListBox->Model()->NumberOfItems()) // scrollbar showing |
|
169 { |
|
170 rect.iBr.iX +=scrollLineLayout.iW; |
|
171 } |
|
172 |
|
173 // Title Font |
|
174 TAknTextLineLayout choiceTextLayout = |
|
175 AKN_LAYOUT_TEXT_Candidate_selection_list_texts_Line_1; |
|
176 const CFont* font = AknLayoutUtils::FontFromId(choiceTextLayout.iFont, NULL); |
|
177 TInt fontSize = font->AscentInPixels(); |
|
178 TInt titleHeight = (iInputContextField)? (fontSize+KPENINPUT_LAYOUT_VALUE_2) : 0; |
|
179 |
|
180 rect.iBr.iY = rect.iTl.iY + min.iHeight + titleHeight; |
|
181 |
|
182 TRect windowRect = rect; |
|
183 TAknLayoutRect topLeft; |
|
184 topLeft.LayoutRect(windowRect, SkinLayout::Popup_windows_skin_placing__frame_general__Line_2()); |
|
185 iTopLeft = TSize(topLeft.Rect().Size().iWidth/2, topLeft.Rect().Size().iHeight/2); |
|
186 rect.iBr.iX += (iTopLeft.iWidth*2); |
|
187 rect.iBr.iY += (iTopLeft.iHeight*2); |
|
188 |
|
189 |
|
190 TRect listRect; |
|
191 listRect = TRect(TPoint(rect.iTl.iX + iTopLeft.iWidth |
|
192 ,rect.iTl.iY + titleHeight + iTopLeft.iHeight) |
|
193 ,min); |
|
194 |
|
195 SetRect(rect); |
|
196 iListBox->SetRect(listRect); |
|
197 iListBox->SetCurrentItemIndex(aIndex); |
|
198 |
|
199 MAknsControlContext *cc = AknsDrawUtils::ControlContext( iListBox ); |
|
200 if (cc) |
|
201 { |
|
202 CAknsBasicBackgroundControlContext *bcc = |
|
203 (CAknsBasicBackgroundControlContext*)cc; |
|
204 bcc->SetBitmap(KAknsIIDQsnFrPopupCenter); |
|
205 listRect.iBr.iX = rect.iBr.iX - iTopLeft.iWidth; |
|
206 bcc->SetRect(listRect); |
|
207 } |
|
208 |
|
209 iListBox->MakeVisible(ETrue); // after iListBox->SetRect() |
|
210 if (iListBox->Parent() && !iListBox->Parent()->IsBackedUp()) |
|
211 { |
|
212 iListBox->Parent()->ActivateL(); |
|
213 } |
|
214 else |
|
215 { |
|
216 iListBox->ActivateL(); |
|
217 } |
|
218 ReportEvent(EEventShowCandidateWnd); |
|
219 if (!iAppGc) |
|
220 { |
|
221 iAppGc = CCoeEnv::Static()->SwapSystemGc(static_cast<CWindowGc*>(BitGc())); |
|
222 } |
|
223 Display(TPoint(0,0)); // set lock area, CapturePonter(ETrue) |
|
224 UiLayout()->UnLockArea(Rect(),this); // free lock area |
|
225 CapturePointer(EFalse); |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // CPeninputJapaneseCandidateWnd::HideWindow |
|
230 // Hide Pop-up list |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 EXPORT_C void CPeninputJapaneseCandidateWnd::HidePopup() |
|
234 { |
|
235 if(!Hiden()) |
|
236 { |
|
237 ReportEvent(EEventHideCandidateWnd); |
|
238 if(iAppGc) |
|
239 { |
|
240 CCoeEnv::Static()->SwapSystemGc(iAppGc); |
|
241 iAppGc = NULL; |
|
242 } |
|
243 iListBox->MakeVisible(EFalse); // before CloseWindow() |
|
244 CloseWindow(); |
|
245 } |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CPeninputJapanesePredictiveWnd::CurrentItemIndexOfCandidate |
|
250 // Return a selected candidate item number currently |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 EXPORT_C TInt CPeninputJapaneseCandidateWnd::CurrentItemIndex() const |
|
254 { |
|
255 if (iListBox->IsVisible()) |
|
256 { |
|
257 return iListBox->CurrentItemIndex(); |
|
258 } |
|
259 return -1; // Disable window |
|
260 } |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // CPeninputJapanesePredictiveWnd::UpdateMaximumRows |
|
264 // Return a selected candidate item number currently |
|
265 // called by CPeninputLayoutWindowJp::SetControlsFont() |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 void CPeninputJapaneseCandidateWnd::UpdateMaximumRows(TInt aUnitHeight, TInt aUnitCount) |
|
269 { |
|
270 iListBox->SizeChanged(); |
|
271 iListBox->SetMaximumColumns(iMaximumColumns); |
|
272 iFontMaximumRows = KMaxListRows; |
|
273 while (KMinListRows < iFontMaximumRows) |
|
274 { |
|
275 iListBox->SetMaximumRows(iFontMaximumRows); |
|
276 TSize min = iListBox->MinimumSize(); |
|
277 if (min.iHeight <= aUnitHeight*(aUnitCount-1)) |
|
278 { |
|
279 break; |
|
280 } |
|
281 -- iFontMaximumRows; |
|
282 } |
|
283 } |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // CPeninputJapaneseCandidateWnd::MoveToL |
|
287 // Move a current item in an appointed direction |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 void CPeninputJapaneseCandidateWnd::MoveToL(TPeninputUICtrlScroll aDirection) |
|
291 { |
|
292 if (iListBox->IsVisible()) |
|
293 { |
|
294 TInt code = EKeyNull; |
|
295 |
|
296 switch(aDirection) |
|
297 { |
|
298 case EScrollUp: |
|
299 { |
|
300 code = EKeyUpArrow; |
|
301 } |
|
302 break; |
|
303 |
|
304 case EScrollDown: |
|
305 { |
|
306 code = EKeyDownArrow; |
|
307 } |
|
308 break; |
|
309 |
|
310 default: |
|
311 break; |
|
312 } |
|
313 if (EKeyNull != code) |
|
314 { |
|
315 TKeyEvent keyEvent; |
|
316 keyEvent.iCode = code; |
|
317 keyEvent.iScanCode = 0; |
|
318 keyEvent.iModifiers = 0; |
|
319 iListBox->OfferKeyEventL(keyEvent, EEventKey); |
|
320 if (!Hiden()) |
|
321 { |
|
322 ReDraw(); |
|
323 } |
|
324 } |
|
325 } |
|
326 } |
|
327 |
|
328 // --------------------------------------------------------------------------- |
|
329 // CPeninputJapaneseCandidateWnd::HitTest |
|
330 // Get item whose region contains the point. |
|
331 // (other items were commented in a header). |
|
332 // --------------------------------------------------------------------------- |
|
333 // |
|
334 TInt CPeninputJapaneseCandidateWnd::HitTest(const TPoint& aPoint) |
|
335 { |
|
336 if( !Rect().Contains(aPoint) ) |
|
337 { |
|
338 return -1; |
|
339 } |
|
340 TRect listRect = iListBox->Rect(); |
|
341 if (listRect.iBr.iX >= aPoint.iX) |
|
342 { |
|
343 return 1; // ListBox Side |
|
344 } |
|
345 if (iListBox->ScrollBarFrame()->GetScrollBarHandle(CEikScrollBar::EVertical) |
|
346 && iListBox->ScrollBarFrame()->GetScrollBarHandle(CEikScrollBar::EVertical)->Rect().Contains(aPoint)) |
|
347 { |
|
348 return 0; // ScrollBar |
|
349 } |
|
350 return -2; |
|
351 } |
|
352 |
|
353 // --------------------------------------------------------------------------- |
|
354 // CPeninputJapaneseCandidateWnd::HandlePointerDownEventL |
|
355 // Handle pointer down event. |
|
356 // (other items were commented in a header). |
|
357 // --------------------------------------------------------------------------- |
|
358 // |
|
359 CFepUiBaseCtrl* CPeninputJapaneseCandidateWnd::HandlePointerDownEventL(const TPoint& aPoint) |
|
360 { |
|
361 if (Hiden()) |
|
362 return NULL; |
|
363 CFepLayoutPopupWnd::HandlePointerDownEventL(aPoint); // set pointer down |
|
364 TInt index = HitTest(aPoint); |
|
365 if (0 > index) |
|
366 { |
|
367 SetPointerDown(EFalse); |
|
368 if (iInputContextField) // candidate popup |
|
369 { |
|
370 return (-1 == index)? NULL:this; |
|
371 } |
|
372 else |
|
373 { |
|
374 HidePopup(); |
|
375 return this; |
|
376 } |
|
377 } |
|
378 else |
|
379 { |
|
380 TPointerEvent pEvent; |
|
381 pEvent.iType = TPointerEvent::EButton1Down; |
|
382 pEvent.iPosition = aPoint; |
|
383 pEvent.iModifiers = 0; |
|
384 pEvent.iParentPosition = TPoint(0,0); |
|
385 SendPointerEventL(pEvent, index, EFalse); |
|
386 if (!index) // on ScrollBar |
|
387 { |
|
388 iScrollBarPointerEvent = pEvent; |
|
389 iScrollBarPointerEvent.iType = TPointerEvent::EButton1Up; |
|
390 iLongPressTimer->SetTimer(KLongPressInterval); |
|
391 } |
|
392 } |
|
393 return this; |
|
394 } |
|
395 |
|
396 // --------------------------------------------------------------------------- |
|
397 // CPeninputJapaneseCandidateWnd::HandlePointerMoveEventL |
|
398 // Handle pointer move event. |
|
399 // (other items were commented in a header). |
|
400 // --------------------------------------------------------------------------- |
|
401 // |
|
402 CFepUiBaseCtrl* CPeninputJapaneseCandidateWnd::HandlePointerMoveEventL(const TPoint& aPoint) |
|
403 { |
|
404 CancelScrollBarRepeat(); |
|
405 CFepLayoutPopupWnd::HandlePointerMoveEventL(aPoint); // nop |
|
406 if( PointerDown() && !Hiden()) |
|
407 { |
|
408 TInt index = HitTest(aPoint); |
|
409 TPointerEvent pEvent; |
|
410 pEvent.iType = TPointerEvent::EDrag; |
|
411 pEvent.iPosition = aPoint; |
|
412 pEvent.iModifiers = 0; |
|
413 pEvent.iParentPosition = TPoint(0,0); |
|
414 SendPointerEventL(pEvent, index, ETrue); // if to ScrollBar, Draw. |
|
415 return this; |
|
416 } |
|
417 return NULL; |
|
418 } |
|
419 |
|
420 // --------------------------------------------------------------------------- |
|
421 // CPeninputJapaneseCandidateWnd::HandlePointerUpEventL |
|
422 // Handle pointer up event. |
|
423 // (other items were commented in a header). |
|
424 // --------------------------------------------------------------------------- |
|
425 // |
|
426 CFepUiBaseCtrl* CPeninputJapaneseCandidateWnd::HandlePointerUpEventL(const TPoint& aPoint) |
|
427 { |
|
428 CancelScrollBarRepeat(); |
|
429 if( PointerDown() && !Hiden()) |
|
430 { |
|
431 CFepLayoutPopupWnd::HandlePointerUpEventL(aPoint); // pointer down off |
|
432 TInt index = HitTest(aPoint); |
|
433 TPointerEvent pEvent; |
|
434 pEvent.iType = TPointerEvent::EButton1Up; |
|
435 pEvent.iPosition = aPoint; |
|
436 pEvent.iModifiers = 0; |
|
437 pEvent.iParentPosition = TPoint(0,0); |
|
438 SendPointerEventL(pEvent, index, ETrue); // if to ScrollBar, Draw. |
|
439 return this; |
|
440 } |
|
441 return NULL; |
|
442 } |
|
443 |
|
444 |
|
445 // CallBack from ListBox |
|
446 // --------------------------------------------------------------------------- |
|
447 // CPeninputJapaneseCandidateWnd::HandleListBoxEventL |
|
448 // (other items were commented in a header). |
|
449 // --------------------------------------------------------------------------- |
|
450 // |
|
451 void CPeninputJapaneseCandidateWnd::HandleListBoxEventL( |
|
452 CEikListBox* /*aListBox*/, TListBoxEvent aEventType) |
|
453 { |
|
454 switch (aEventType) |
|
455 { |
|
456 case EEventItemDraggingActioned: // Item Moved |
|
457 ReDraw(); |
|
458 break; |
|
459 case EEventItemClicked: |
|
460 { |
|
461 if (iInputContextField) // candidate popup |
|
462 { |
|
463 ReportEvent(EPeninputLayoutEventSelectItem); |
|
464 } |
|
465 else |
|
466 { |
|
467 TInt currentItem = iListBox->CurrentItemIndex(); |
|
468 TPtrC dataPtr; |
|
469 dataPtr.Set(reinterpret_cast<TUint16*>(¤tItem),sizeof(currentItem)/sizeof(TUint16)); |
|
470 ReportEvent(EPeninputLayoutEventRange, dataPtr); // Hwr:CharacterRange popup |
|
471 } |
|
472 } |
|
473 break; |
|
474 default: |
|
475 break; |
|
476 } |
|
477 } |
|
478 |
|
479 // --------------------------------------------------------- |
|
480 // Cancel timers for ScrollBar repeat |
|
481 // --------------------------------------------------------- |
|
482 // |
|
483 void CPeninputJapaneseCandidateWnd::CancelScrollBarRepeat() |
|
484 { |
|
485 if (iLongPressTimer) |
|
486 { |
|
487 iLongPressTimer->Cancel(); |
|
488 } |
|
489 if (iRepeatTimer) |
|
490 { |
|
491 iRepeatTimer->Cancel(); |
|
492 } |
|
493 } |
|
494 |
|
495 // --------------------------------------------------------- |
|
496 // Time out event handler of both long press timer & repeat timer |
|
497 // --------------------------------------------------------- |
|
498 // |
|
499 void CPeninputJapaneseCandidateWnd::HandleTimerOut(const CAknFepTimer* aTimer) |
|
500 { |
|
501 if (aTimer == iLongPressTimer) |
|
502 { |
|
503 iRepeatTimer->SetTimer(KRepeatInterval); |
|
504 } |
|
505 else |
|
506 { |
|
507 if (aTimer == iRepeatTimer) |
|
508 { |
|
509 if (TPointerEvent::EButton1Up == iScrollBarPointerEvent.iType) |
|
510 { |
|
511 TRAPD(err, SendPointerEventL(iScrollBarPointerEvent, 0, ETrue)); |
|
512 if(KErrNone == err) |
|
513 { |
|
514 iScrollBarPointerEvent.iType = TPointerEvent::EButton1Down; |
|
515 TRAP_IGNORE(SendPointerEventL(iScrollBarPointerEvent, 0, EFalse)); |
|
516 iScrollBarPointerEvent.iType = TPointerEvent::EButton1Up; |
|
517 } |
|
518 iRepeatTimer->SetTimer(KRepeatInterval); |
|
519 } |
|
520 } |
|
521 } |
|
522 } |
|
523 |
|
524 // ----------------------------------------------------------------------------- |
|
525 // CPeninputJapanesePredictiveWnd::ListBox() |
|
526 // (other items were commented in a header). |
|
527 // --------------------------------------------------------------------------- |
|
528 CPeninputJapaneseCandidateListBox* CPeninputJapaneseCandidateWnd::ListBox() const |
|
529 { |
|
530 return iListBox; |
|
531 } |
|
532 |
|
533 // --------------------------------------------------------------------------- |
|
534 // CPeninputJapaneseCandidateWnd::OnDeActivate |
|
535 // DeActivate popup window |
|
536 // --------------------------------------------------------------------------- |
|
537 // |
|
538 void CPeninputJapaneseCandidateWnd::OnDeActivate() |
|
539 { |
|
540 ;// Do not CloseWindow; |
|
541 } |
|
542 |
|
543 // --------------------------------------------------------------------------- |
|
544 // Constructor |
|
545 // |
|
546 // (other items were commented in a header). |
|
547 // --------------------------------------------------------------------------- |
|
548 // |
|
549 CPeninputJapaneseCandidateWnd::CPeninputJapaneseCandidateWnd(CFepUiLayout* aUiLayout, |
|
550 TInt aControlId) |
|
551 :CFepLayoutPopupWnd(TSize(0,0), aUiLayout, aControlId), |
|
552 iMaximumColumns(KMinListColumns), |
|
553 iMaximumRows(KMinListRows), |
|
554 iFontMaximumRows(KMaxListRows) |
|
555 { |
|
556 } |
|
557 |
|
558 // ----------------------------------------------------------------------------- |
|
559 // CPeninputJapaneseCandidateWnd::ConstructL |
|
560 // Symbian 2nd phase constructor can leave. |
|
561 // ----------------------------------------------------------------------------- |
|
562 // |
|
563 void CPeninputJapaneseCandidateWnd::ConstructL(const CCoeControl* aParent) |
|
564 { |
|
565 CFepLayoutPopupWnd::ConstructL(); |
|
566 iListBox = new(ELeave) CPeninputJapaneseCandidateListBox; |
|
567 iListBox->SetBorder(TGulBorder::ENone); |
|
568 iListBox->ConstructL(aParent, CEikListBox::ELeftDownInViewRect); |
|
569 iListBox->CreateScrollBarFrameL(ETrue, EFalse, EFalse); |
|
570 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
571 CEikScrollBarFrame::EOff, |
|
572 CEikScrollBarFrame::EAuto); |
|
573 iListBox->ItemDrawer()->SetGc(static_cast<CWindowGc*>(BitGc())); |
|
574 iListBox->ItemDrawer()->FormattedCellData()->SetSkinEnabledL( ETrue ); |
|
575 iListBox->SetListBoxObserver(this); |
|
576 iLongPressTimer = CAknFepTimer::NewL(this); |
|
577 iRepeatTimer = CAknFepTimer::NewL(this); |
|
578 } |
|
579 |
|
580 // ----------------------------------------------------------------------------- |
|
581 // CPeninputJapaneseCandidateWnd::MaximumColumns |
|
582 // This function returns maximum columns to be able to display in listbox. |
|
583 // ----------------------------------------------------------------------------- |
|
584 TInt CPeninputJapaneseCandidateWnd::MaximumColumns( |
|
585 const CTextListBoxModel* aModel) const |
|
586 { |
|
587 TInt maximumCharacters = 0; |
|
588 TInt numberOfItems = aModel->NumberOfItems(); |
|
589 TInt i; |
|
590 for (i = 0; i < numberOfItems; i++) |
|
591 { |
|
592 TPtrC text = aModel->ItemText(i); |
|
593 TInt textLength = text.Length(); |
|
594 if (maximumCharacters < textLength) |
|
595 { |
|
596 maximumCharacters = textLength; |
|
597 } |
|
598 } |
|
599 |
|
600 TInt maximumColumns = Min(KMaxListColumns, maximumCharacters); |
|
601 maximumColumns = Max(KMinListColumns, maximumColumns); |
|
602 |
|
603 return maximumColumns; |
|
604 } |
|
605 |
|
606 // ----------------------------------------------------------------------------- |
|
607 // CPeninputJapaneseCandidateWnd::MaximumRows |
|
608 // This function returns maximum rows to be able to display in listbox. |
|
609 // ----------------------------------------------------------------------------- |
|
610 TInt CPeninputJapaneseCandidateWnd::MaximumRows( |
|
611 const CTextListBoxModel* aModel) const |
|
612 { |
|
613 TInt numberOfItems = aModel->NumberOfItems(); |
|
614 if (iInputContextField) // candidate popup |
|
615 { |
|
616 numberOfItems = Max(KMinListRows, numberOfItems); |
|
617 } |
|
618 TInt maximumRows = Min(iFontMaximumRows, numberOfItems); |
|
619 |
|
620 return maximumRows; |
|
621 } |
|
622 |
|
623 // ----------------------------------------------------------------------------- |
|
624 // CPeninputJapaneseCandidateWnd::Draw |
|
625 // Called by the framework to draw the control |
|
626 // ----------------------------------------------------------------------------- |
|
627 // |
|
628 void CPeninputJapaneseCandidateWnd::Draw() |
|
629 { |
|
630 if(Hiden() || !Ready()) |
|
631 { |
|
632 return; |
|
633 } |
|
634 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
635 gc->Activate( MaskBitmapDevice() ); |
|
636 gc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
637 gc->SetBrushColor( MaskBkCol());//Non transparent at all |
|
638 gc->SetPenSize( PenSize()); |
|
639 gc->SetPenColor( MaskBkCol() ); |
|
640 gc->DrawRect(Rect()); |
|
641 gc->Activate( BitmapDevice() ); |
|
642 |
|
643 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
644 |
|
645 TRect outerRect = Rect(); |
|
646 TRect innerRect = TRect(Rect().iTl + TPoint(iTopLeft.iWidth, iTopLeft.iHeight) |
|
647 , Rect().iBr - TPoint(iTopLeft.iWidth, iTopLeft.iHeight)); |
|
648 |
|
649 TBool skinnedDraw = AknsDrawUtils::DrawFrame( skin, *gc, outerRect, innerRect, |
|
650 KAknsIIDQsnFrPopup,KAknsIIDQsnFrPopupCenter); |
|
651 |
|
652 if (!skinnedDraw) |
|
653 { |
|
654 gc->SetPenStyle(CGraphicsContext::ENullPen); |
|
655 gc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
656 gc->SetBrushColor(AKN_LAF_COLOR(KStatusPaneBackgroundColor)); |
|
657 gc->DrawRect(Rect()); |
|
658 } |
|
659 |
|
660 DrawTitle(); |
|
661 if (iListBox->Parent()) |
|
662 { |
|
663 iListBox->Parent()->DrawNow(); |
|
664 } |
|
665 UpdateArea(iRect, EFalse); |
|
666 } |
|
667 |
|
668 // --------------------------------------------------------------------------- |
|
669 // CPeninputJapaneseCandidateWnd::ReDraw |
|
670 // (other items were commented in a header). |
|
671 // --------------------------------------------------------------------------- |
|
672 // |
|
673 void CPeninputJapaneseCandidateWnd::ReDraw() |
|
674 { |
|
675 if(Hiden() || !Ready()) |
|
676 { |
|
677 return; |
|
678 } |
|
679 DrawTitle(); |
|
680 UpdateArea(iRect,EFalse); |
|
681 } |
|
682 |
|
683 // --------------------------------------------------------------------------- |
|
684 // CPeninputJapaneseCandidateWnd::DrawTitle |
|
685 // (other items were commented in a header). |
|
686 // --------------------------------------------------------------------------- |
|
687 // |
|
688 void CPeninputJapaneseCandidateWnd::DrawTitle() |
|
689 { |
|
690 if (!iInputContextField) // Hwr:CharacterRange popup |
|
691 { |
|
692 return; |
|
693 } |
|
694 CTextListBoxModel* model = |
|
695 static_cast<CTextListBoxModel*>(iListBox->Model()); |
|
696 TInt numOfItem = model->NumberOfItems(); |
|
697 TBuf<KMaxTitleLength> title; |
|
698 title.Format(_L("%d / %d"), iListBox->CurrentItemIndex() + 1, numOfItem); |
|
699 |
|
700 // Title Font |
|
701 TAknTextLineLayout choiceTextLayout = |
|
702 AKN_LAYOUT_TEXT_Candidate_selection_list_texts_Line_1; |
|
703 const CFont* font = AknLayoutUtils::FontFromId(choiceTextLayout.iFont, NULL); |
|
704 |
|
705 TRect rect(iListBox->Rect()); |
|
706 TInt fontSize = font->AscentInPixels(); |
|
707 rect.iBr.iY = rect.iTl.iY; |
|
708 rect.iTl.iY -= (fontSize + KPENINPUT_LAYOUT_VALUE_2); |
|
709 rect.iBr.iX = Rect().iBr.iX - iTopLeft.iWidth; |
|
710 TInt baseline = fontSize + 1; |
|
711 |
|
712 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
713 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
714 TRect outerRect = Rect(); |
|
715 TRect innerRect = TRect(Rect().iTl + TPoint(iTopLeft.iWidth, iTopLeft.iHeight) |
|
716 , Rect().iBr - TPoint(iTopLeft.iWidth, iTopLeft.iHeight)); |
|
717 |
|
718 gc->SetClippingRect(rect); |
|
719 TBool skinnedDraw = AknsDrawUtils::DrawFrame( skin, *gc, outerRect, innerRect, |
|
720 KAknsIIDQsnFrPopup,KAknsIIDQsnFrPopupCenter); |
|
721 gc->CancelClippingRect(); |
|
722 if (!skinnedDraw) |
|
723 { |
|
724 gc->SetPenStyle(CGraphicsContext::ENullPen); |
|
725 gc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
726 gc->SetBrushColor(AKN_LAF_COLOR(KStatusPaneBackgroundColor)); |
|
727 gc->DrawRect(rect); |
|
728 } |
|
729 |
|
730 TRgb color( KRgbBlack ); |
|
731 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
732 color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG7 ); |
|
733 gc->UseFont(font); |
|
734 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
735 gc->SetPenColor(color); |
|
736 gc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
737 gc->DrawText(title, rect, baseline, CGraphicsContext::ERight, KPENINPUT_LAYOUT_VALUE_2); |
|
738 gc->DiscardFont(); |
|
739 } |
|
740 |
|
741 // --------------------------------------------------------------------------- |
|
742 // CPeninputJapaneseCandidateWnd::SendPointerEventL |
|
743 // (other items were commented in a header). |
|
744 // --------------------------------------------------------------------------- |
|
745 // |
|
746 void CPeninputJapaneseCandidateWnd::SendPointerEventL(const TPointerEvent& aPointerEvent, TInt aFlags, TBool aDraw) |
|
747 { |
|
748 if (1 == aFlags) // to ListBox |
|
749 { |
|
750 iListBox->HandlePointerEventL(aPointerEvent); |
|
751 } |
|
752 else if(iListBox->ScrollBarFrame()->GetScrollBarHandle(CEikScrollBar::EVertical)) |
|
753 { // on ScrollBar |
|
754 iListBox->ScrollBarFrame()->GetScrollBarHandle(CEikScrollBar::EVertical)->HandlePointerEventL(aPointerEvent); |
|
755 if (aDraw) |
|
756 { |
|
757 UpdateArea(iRect,EFalse); |
|
758 } |
|
759 } |
|
760 } |
|
761 // End of File |