|
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: Implementation of hwr window class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System includes |
|
20 #include <peninputhwrwindowjp.rsg> |
|
21 #include <peninputhwrwindowconfiginfo_32.rsg> |
|
22 #include <peninputdataconverter.h> |
|
23 #include <aknlayoutscalable_avkon.cdl.h> |
|
24 #include <peninputcommonlayoutglobalenum.h> // EPeninputLayoutEventEnter |
|
25 #include <peninputclientlayoutinfo.h> |
|
26 #include <peninputcontextfieldjp.h> |
|
27 #include <peninputeventbutton.h> |
|
28 #include <peninputrepeatbutton.h> |
|
29 #include <peninputdropdownlist.h> |
|
30 #include <peninputjapanesepredictivewnd.h> |
|
31 #include <peninputjapanesecandidatewnd.h> |
|
32 #include <AknsUtils.h> |
|
33 #include <aknfeppeninputenums.h> // ERangeEnglish, ... |
|
34 |
|
35 // User includes |
|
36 #include "peninputhwrboxlayout.h" |
|
37 #include "peninputhwrboxwindow.h" |
|
38 #include "peninputhwrboxgroup.h" |
|
39 #include "peninputhwrboxdatamgr.h" |
|
40 #include "peninputhwrboxjp.hrh" |
|
41 #include "peninputhwrevent.h" |
|
42 |
|
43 // Constants |
|
44 _LIT( KHwrWindowResourceFile, |
|
45 "z:\\resource\\plugins\\peninputhwrwindowjp.RSC" ); |
|
46 _LIT( KConfigurationResourceFile, |
|
47 "z:\\resource\\plugins\\peninputhwrwindowconfiginfo_32.RSC" ); |
|
48 const TInt KWndTransparencyFactor = 180; |
|
49 |
|
50 const TInt KBoxCount = 1; |
|
51 |
|
52 |
|
53 const TInt KWriteBoxFrameBackColorMajor = EAknsMajorSkin; |
|
54 const TInt KWriteBoxFrameBackColorGrp = EAknsMinorQsnOtherColors; |
|
55 const TInt KWriteBoxFrameBackColorIdx = EAknsCIQsnOtherColorsCG9; |
|
56 const TUint32 KDefaultWriteBoxFrameColor = 0x000000; |
|
57 const TUint32 KDefaultWriteBoxBackColor = 0xffffff; |
|
58 // ======== MEMBER FUNCTIONS ======== |
|
59 |
|
60 // -------------------------------------------------------------------------- |
|
61 // CPeninputHwrBoxWindow::NewL |
|
62 // (other items were commented in a header) |
|
63 // -------------------------------------------------------------------------- |
|
64 CPeninputHwrBoxWindow* CPeninputHwrBoxWindow::NewL( |
|
65 CFepUiLayout* aUiLayout, MPeninputLayoutContext* aLayoutContext ) |
|
66 { |
|
67 CPeninputHwrBoxWindow* self = |
|
68 new ( ELeave ) CPeninputHwrBoxWindow( aUiLayout, aLayoutContext ); |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop( self ); |
|
72 |
|
73 return self; |
|
74 } |
|
75 |
|
76 // -------------------------------------------------------------------------- |
|
77 // CPeninputHwrBoxWindow::~CPeninputHwrBoxWindow |
|
78 // (other items were commented in a header) |
|
79 // -------------------------------------------------------------------------- |
|
80 CPeninputHwrBoxWindow::~CPeninputHwrBoxWindow() |
|
81 { |
|
82 } |
|
83 |
|
84 // -------------------------------------------------------------------------- |
|
85 // CPeninputHwrBoxWindow::HandleControlEvent |
|
86 // (other items were commented in a header) |
|
87 // -------------------------------------------------------------------------- |
|
88 void CPeninputHwrBoxWindow::HandleControlEvent( TInt aEventType, |
|
89 CFepUiBaseCtrl* aCtrl, |
|
90 const TDesC& aEventData ) |
|
91 { |
|
92 // Call this function in base class |
|
93 CPeninputLayoutWindowJp::HandleControlEvent( aEventType, |
|
94 aCtrl, |
|
95 aEventData ); |
|
96 |
|
97 TInt* data = ( TInt* ) aEventData.Ptr(); |
|
98 |
|
99 switch ( aEventType ) |
|
100 { |
|
101 case EPeninputLayoutHwrEventPenColorChange: |
|
102 { |
|
103 iBoxGroup->SetBoxPenColor(*((TRgb*)data)); |
|
104 } |
|
105 break; |
|
106 case EPeninputLayoutHwrEventPenSizeChange: |
|
107 { |
|
108 iBoxGroup->SetBoxPenSize(*((TSize*)data)); |
|
109 } |
|
110 break; |
|
111 case EPeninputLayoutHwrEventWritingSpeedChange: |
|
112 { |
|
113 iBoxGroup->SetWritingSpeed(*data); |
|
114 |
|
115 #ifdef _NOT_USING_DECUMA_MCR_ |
|
116 |
|
117 // similar as S90 |
|
118 iBoxGroup->SetStrokeDelay(90000); |
|
119 #endif |
|
120 } |
|
121 break; |
|
122 case EPeninputLayoutHwrEventCandidates: |
|
123 { |
|
124 const TInt candiCount = static_cast<CPeninputHwrBoxLayout*>(UiLayout())->DataMgr(0)->CandidateCount(); |
|
125 RArray<TInt> secondaryList; |
|
126 |
|
127 for (TInt i = 0; i < candiCount; i++) |
|
128 { |
|
129 if (i > candiCount - static_cast<CPeninputHwrBoxLayout*>(UiLayout())->DataMgr(0)->PermittedRangesCount()) |
|
130 { |
|
131 //cell index start from 1 |
|
132 secondaryList.Append(i); |
|
133 } |
|
134 } |
|
135 iDropdownList->SetSecondaryList(secondaryList); |
|
136 |
|
137 secondaryList.Close(); |
|
138 |
|
139 RPointerArray<HBufC>* candidates = (RPointerArray<HBufC>*)aEventData.Ptr(); |
|
140 if ( candiCount ) |
|
141 { |
|
142 TRAP_IGNORE(iDropdownList->SetCandidatesL(*candidates, CFepCtrlDropdownList::EListExpandableWithoutIcon)); |
|
143 } |
|
144 else |
|
145 { |
|
146 TRAP_IGNORE(iDropdownList->SetCandidatesL(*candidates, CFepCtrlDropdownList::EListNoExpandable)); |
|
147 } |
|
148 } |
|
149 break; |
|
150 case EPeninputLayoutEventSwitchCharacterRange: |
|
151 if (iCharacterRangeWnd) |
|
152 { |
|
153 CFepUiBaseCtrl* rangeBtn = Control(EPeninutWindowCtrlIdSwitchToVkbBtn); |
|
154 if (rangeBtn) |
|
155 { |
|
156 TRect rect = rangeBtn->Rect(); |
|
157 TPoint point; |
|
158 point.iX = rect.iTl.iX-6; |
|
159 point.iY = rect.iBr.iY-6; |
|
160 iCharacterRangeWnd->SetPosition(point); |
|
161 } |
|
162 TInt index = static_cast<CPeninputHwrBoxLayout*>(UiLayout())->DataMgr(0)->CurrentCharacterRangeIndex(); |
|
163 if (0 <= index && index <static_cast<CPeninputHwrBoxLayout*>(UiLayout())->DataMgr(0)->CharacterRangeArray()->Count()) |
|
164 { |
|
165 TRAP_IGNORE(iCharacterRangeWnd->ShowPopupL(static_cast<CPeninputHwrBoxLayout*>(UiLayout())->DataMgr(0)->CharacterRangeArray(), index)); |
|
166 } |
|
167 } |
|
168 break; |
|
169 case EPeninputLayoutEventCloseCharacterRange: |
|
170 if (iCharacterRangeWnd) |
|
171 { |
|
172 iCharacterRangeWnd->HidePopup(); |
|
173 } |
|
174 break; |
|
175 case EPeninputLayoutEventSetCharacterRangeText: // from datamgr::SetPremaryRange |
|
176 { |
|
177 TInt count = static_cast<CPeninputHwrBoxLayout*>(UiLayout())->DataMgr(0)->CharacterRangeArray()->Count(); |
|
178 TBool dimmFlag = (count < 2)? ETrue : EFalse; |
|
179 TInt resourceId = R_PENINPUT_LAYOUT_HWR_SWITCH_RANGE_ALL; |
|
180 switch(static_cast<CPeninputHwrBoxLayout*>(UiLayout())->DataMgr(0)->CharacterRangeId()) |
|
181 { |
|
182 case EPeninutCharacterRangeIdKanaKanji: |
|
183 resourceId = R_PENINPUT_LAYOUT_HWR_SWITCH_RANGE_KANA_KANJI; // temporary |
|
184 break; |
|
185 case EPeninutCharacterRangeIdLatin: |
|
186 resourceId = R_PENINPUT_LAYOUT_HWR_SWITCH_RANGE_LATIN; |
|
187 break; |
|
188 case EPeninutCharacterRangeIdNumber: |
|
189 resourceId = R_PENINPUT_LAYOUT_HWR_SWITCH_RANGE_NUMERIC; |
|
190 break; |
|
191 default: |
|
192 break; |
|
193 } |
|
194 iCharacterRangeSwitchBtn->SetResourceId(resourceId); |
|
195 TRAP_IGNORE(iCharacterRangeSwitchBtn->ConstructFromResourceL()); |
|
196 iCharacterRangeSwitchBtn->SetDimmed(dimmFlag); |
|
197 } |
|
198 break; |
|
199 case EPeninputLayoutEventSetConversion: |
|
200 iConvertBtn->SetDimmed(*((TBool*)data)); |
|
201 break; |
|
202 case EPeninputLayoutHwrEventStrokeEndMark: |
|
203 { |
|
204 const TPoint endMark = *(TPoint*)(aEventData.Ptr()); |
|
205 iBoxGroup->SetStrokeEndMark(endMark); |
|
206 } |
|
207 break; |
|
208 case EEventHwrStrokeStarted: |
|
209 { |
|
210 iDisableCaseChange = ETrue; |
|
211 } |
|
212 break; |
|
213 case EEventHwrCharacterTimerOut: |
|
214 case EEventHwrStrokeCanceled: |
|
215 { |
|
216 if (iDisableCaseChange) |
|
217 { |
|
218 iDisableCaseChange = EFalse; |
|
219 if (iCachedCase) |
|
220 { |
|
221 DoCaseChange(iCachedCase); |
|
222 } |
|
223 } |
|
224 iCachedCase = 0; |
|
225 } |
|
226 break; |
|
227 default: |
|
228 break; |
|
229 } |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------------------------- |
|
233 // CPeninputHwrBoxWindow:HandlePointerDownEventL |
|
234 // Handle pointer down event |
|
235 // (other items were commented in a header). |
|
236 // --------------------------------------------------------------------------- |
|
237 CFepUiBaseCtrl* CPeninputHwrBoxWindow::HandlePointerDownEventL(const TPoint& aPoint) |
|
238 { |
|
239 if (!CandidateWindow()->Hiden() |
|
240 && iDropdownList->Rect().Contains(aPoint) |
|
241 && !CandidateWindow()->Rect().Contains(aPoint)) |
|
242 { |
|
243 return this; |
|
244 } |
|
245 return CPeninputLayoutWindowJp::HandlePointerDownEventL(aPoint); |
|
246 } |
|
247 |
|
248 // -------------------------------------------------------------------------- |
|
249 // CPeninputHwrBoxWindow::GetWindowConfigResId |
|
250 // (other items were commented in a header) |
|
251 // -------------------------------------------------------------------------- |
|
252 TInt CPeninputHwrBoxWindow::GetWindowConfigResId() |
|
253 { |
|
254 return R_PENINPUT_LAYOUT_CONFIG_INFO; |
|
255 } |
|
256 |
|
257 // -------------------------------------------------------------------------- |
|
258 // CPeninputHwrBoxWindow::GetWindowResId |
|
259 // (other items were commented in a header) |
|
260 // -------------------------------------------------------------------------- |
|
261 TInt CPeninputHwrBoxWindow::GetWindowResId() |
|
262 { |
|
263 return R_PENINPUT_LAYOUT_HWR_WINDOW; |
|
264 } |
|
265 |
|
266 // -------------------------------------------------------------------------- |
|
267 // CPeninputHwrBoxWindow::GetWindowConfigResFileName |
|
268 // (other items were commented in a header) |
|
269 // -------------------------------------------------------------------------- |
|
270 const TDesC& CPeninputHwrBoxWindow::GetWindowConfigResFileName( |
|
271 TInt /*aLangID*/ ) // LangId : 32 fixed |
|
272 { |
|
273 return KConfigurationResourceFile(); |
|
274 } |
|
275 |
|
276 // -------------------------------------------------------------------------- |
|
277 // CPeninputHwrBoxWindow::GetWindowResFileName |
|
278 // (other items were commented in a header) |
|
279 // -------------------------------------------------------------------------- |
|
280 const TDesC& CPeninputHwrBoxWindow::GetWindowResFileName() |
|
281 { |
|
282 return KHwrWindowResourceFile(); |
|
283 } |
|
284 |
|
285 // -------------------------------------------------------------------------- |
|
286 // CPeninputHwrBoxWindow::ChangeUnitSize |
|
287 // (other items were commented in a header) |
|
288 // -------------------------------------------------------------------------- |
|
289 // |
|
290 const TRect CPeninputHwrBoxWindow::ChangeUnitSize() |
|
291 { |
|
292 TAknWindowLineLayout appWnd; |
|
293 TAknWindowLineLayout mainPane; |
|
294 TAknWindowLineLayout wndLayout; |
|
295 TAknWindowLineLayout unitLayout; |
|
296 TAknLayoutRect mainPaneRect; |
|
297 TAknLayoutRect wndRect; |
|
298 TAknLayoutRect unitRect; |
|
299 |
|
300 // Get hwr window layout |
|
301 appWnd = AknLayoutScalable_Avkon::application_window( 0 ).LayoutLine(); |
|
302 |
|
303 if (appWnd.iW > appWnd.iH) |
|
304 { |
|
305 // landscape |
|
306 mainPane = AknLayoutScalable_Avkon::main_pane(4).LayoutLine(); |
|
307 } |
|
308 else |
|
309 { |
|
310 // portrait |
|
311 mainPane = AknLayoutScalable_Avkon::main_pane(1).LayoutLine(); |
|
312 } |
|
313 if (!iPredictiveWnd->Hiden()) |
|
314 { |
|
315 wndLayout = AknLayoutScalable_Avkon::popup_fep_hwr_window(7).LayoutLine(); |
|
316 } |
|
317 else |
|
318 { |
|
319 wndLayout = AknLayoutScalable_Avkon::popup_fep_hwr_window(6).LayoutLine(); |
|
320 } |
|
321 |
|
322 mainPaneRect.LayoutRect(appWnd.Rect(), mainPane); |
|
323 wndRect.LayoutRect(mainPaneRect.Rect(), wndLayout); |
|
324 |
|
325 unitLayout = AknLayoutScalable_Avkon::fep_hwr_aid_pane().LayoutLine(); |
|
326 unitRect.LayoutRect(wndRect.Rect(), unitLayout); |
|
327 |
|
328 TRect hwrWndRect = TRect(0, |
|
329 0, |
|
330 wndRect.Rect().Width(), |
|
331 wndRect.Rect().Height()); |
|
332 |
|
333 TInt unitWidth = unitRect.Rect().Width(); |
|
334 TInt unitHeight = unitRect.Rect().Height(); |
|
335 |
|
336 iLayoutContext->SetData( EPeninputDataTypeUnitWidth, &unitWidth ); |
|
337 iLayoutContext->SetData( EPeninputDataTypeUnitHeight, &unitHeight ); |
|
338 |
|
339 return hwrWndRect; |
|
340 } |
|
341 |
|
342 // -------------------------------------------------------------------------- |
|
343 // CPeninputHwrBoxWindow::ChangeClientSize |
|
344 // (other items were commented in a header) |
|
345 // -------------------------------------------------------------------------- |
|
346 void CPeninputHwrBoxWindow::ChangeClientSize() |
|
347 { |
|
348 TAknTextLineLayout languageSwitchText; |
|
349 TInt unitWidth = CPeninputDataConverter::AnyToInt |
|
350 ( iLayoutContext->RequestData( EPeninputDataTypeUnitWidth ) ); |
|
351 TInt unitHeight = CPeninputDataConverter::AnyToInt |
|
352 ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) ); |
|
353 |
|
354 TInt clientLayoutId = CPeninputDataConverter::AnyToInt |
|
355 ( iLayoutContext->RequestData( EPeninputDataTypeClientLayout ) ); |
|
356 CPeninputClientLayoutInfo* clientLayout = |
|
357 ConfigInfo()->FindClientLayoutInfo( clientLayoutId ); |
|
358 |
|
359 if ( clientLayout ) |
|
360 { |
|
361 // Change self rect |
|
362 TInt width = clientLayout->Columns() * unitWidth; |
|
363 TInt height = clientLayout->Rows() * unitHeight; |
|
364 TRect rect = TRect( ClientPane()->Rect().iTl, |
|
365 TSize( width, height ) ); |
|
366 |
|
367 ClientPane()->SetRect( rect ); |
|
368 // Change the postion and size of controls in current layout |
|
369 ReorganizeControls( clientLayout->LayoutID(), ETrue ); |
|
370 } |
|
371 } |
|
372 |
|
373 // -------------------------------------------------------------------------- |
|
374 // CPeninputHwrBoxWindow::CreateAllControlsL |
|
375 // (other items were commented in a header) |
|
376 // -------------------------------------------------------------------------- |
|
377 void CPeninputHwrBoxWindow::CreateAllControlsL() |
|
378 { |
|
379 CPeninputLayoutWindowJp::CreateAllControlsL(); |
|
380 |
|
381 if (iInputContextField) |
|
382 { |
|
383 HeaderPane()->RemoveControl(static_cast<CFepUiBaseCtrl*>(iInputContextField)); |
|
384 iInputContextField = NULL; |
|
385 } |
|
386 AddContextFieldJpL(); |
|
387 |
|
388 // DropDown List |
|
389 AddDropdownListL(); |
|
390 |
|
391 // Hwr box |
|
392 AddBoxGroupL(); |
|
393 |
|
394 // convert button : use EventSpace |
|
395 iConvertBtn = AddButtonL( EPeninutWindowCtrlIdConvertToKanjiBtn, |
|
396 EPeninputLayoutEventSpace, |
|
397 R_PENINPUT_LAYOUT_HWR_CONVERT); |
|
398 iConvertBtn->SetDimmed(ETrue); |
|
399 |
|
400 // Backspace button |
|
401 AddButtonL( EPeninutWindowCtrlIdClear2Btn, |
|
402 EPeninputLayoutEventBack, |
|
403 R_PENINPUT_LAYOUT_HWR_BACKSPACE, |
|
404 EKeyBackspace, |
|
405 ETrue ); |
|
406 |
|
407 // Enter button |
|
408 AddButtonL( EPeninutWindowCtrlIdEnterBtn, |
|
409 EPeninputLayoutEventEnter, |
|
410 R_PENINPUT_LAYOUT_HWR_ENTER, |
|
411 EKeyEnter ); |
|
412 |
|
413 // character range switch button |
|
414 iCharacterRangeSwitchBtn = AddButtonL( EPeninutWindowCtrlIdInputLangSwitcherBtn, |
|
415 EPeninputLayoutEventSwitchCharacterRange, |
|
416 R_PENINPUT_LAYOUT_HWR_SWITCH_RANGE_ALL ); |
|
417 |
|
418 // SCT button |
|
419 AddButtonL( EPeninutWindowCtrlIdSymbolBtn, |
|
420 EPeninputLayoutEventSct, |
|
421 R_PENINPUT_LAYOUT_HWR_SCT ); |
|
422 |
|
423 // Switch to vkb button |
|
424 AddButtonL( EPeninutWindowCtrlIdSwitchToVkbBtn, |
|
425 EPeninputLayoutEventToVkb, |
|
426 R_PENINPUT_LAYOUT_HWR_VKB ); |
|
427 |
|
428 for ( TInt i = 0; i < iCtrlPool->ControlCount(); i++ ) |
|
429 { |
|
430 if ( iCtrlPool ) |
|
431 { |
|
432 iCtrlPool->ControlByIndex( i )->AddEventObserver( UiLayout() ); |
|
433 } |
|
434 } |
|
435 } |
|
436 |
|
437 // -------------------------------------------------------------------------- |
|
438 // CPeninputHwrBoxWindow::SetControlsFont |
|
439 // (other items were commented in a header) |
|
440 // -------------------------------------------------------------------------- |
|
441 void CPeninputHwrBoxWindow::SetControlsFont() |
|
442 { |
|
443 CPeninputLayoutWindowJp::SetControlsFont(); |
|
444 |
|
445 TAknTextLineLayout candTextLayout = AknLayoutScalable_Avkon::cell_hwr_candidate_pane_t1().LayoutLine(); |
|
446 iDropdownList->SetFont(AknLayoutUtils::FontFromId(candTextLayout.iFont, NULL)); |
|
447 } |
|
448 |
|
449 // -------------------------------------------------------------------------- |
|
450 // CPeninputHwrBoxWindow::PopupChoiceList |
|
451 // (other items were commented in a header) |
|
452 // -------------------------------------------------------------------------- |
|
453 void CPeninputHwrBoxWindow::PopupChoiceList() |
|
454 { |
|
455 } |
|
456 |
|
457 // -------------------------------------------------------------------------- |
|
458 // CPeninputHwrBoxWindow::ReorganizeControls |
|
459 // (other items were commented in a header) |
|
460 // -------------------------------------------------------------------------- |
|
461 void CPeninputHwrBoxWindow::ReorganizeControls( TInt aClientLayoutId, TBool /*aNeedReset*/ ) |
|
462 { |
|
463 TInt unitWidth = CPeninputDataConverter::AnyToInt |
|
464 ( iLayoutContext->RequestData( EPeninputDataTypeUnitWidth ) ); |
|
465 TInt unitHeight = CPeninputDataConverter::AnyToInt |
|
466 ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) ); |
|
467 |
|
468 // First remove all controls in the client pane, but don't delete them |
|
469 ( const_cast<RPointerArray<CFepUiBaseCtrl>&> |
|
470 ( ClientPane()->ControlList() ) ).Reset(); |
|
471 |
|
472 // Clear rect |
|
473 ClearRect( ClientPane()->Rect() ); |
|
474 UpdateArea( ClientPane()->Rect(), EFalse ); |
|
475 |
|
476 // Then add controls according to the configuration of clientlayout |
|
477 CPeninputClientLayoutInfo* clientLayout = |
|
478 ConfigInfo()->FindClientLayoutInfo( aClientLayoutId ); |
|
479 |
|
480 // Get control list from client layout |
|
481 RPointerArray<CPeninputControlInfo>& controlList = |
|
482 clientLayout->ControlInfoList(); |
|
483 const TInt count = controlList.Count(); |
|
484 TInt controlID = 0; |
|
485 TInt cols = 0; |
|
486 TInt rows = 0; |
|
487 CFepUiBaseCtrl* ctrl = NULL; |
|
488 TRect rect = ClientPane()->Rect(); |
|
489 |
|
490 // Set rect for client area |
|
491 rect.SetSize( TSize( clientLayout->Columns() * unitWidth, |
|
492 clientLayout->Rows() * unitHeight ) ); |
|
493 ClientPane()->SetRect( rect ); |
|
494 |
|
495 // Set owner rect |
|
496 SetWholeWindowRect( ClientPane()->Rect() ); |
|
497 |
|
498 TPoint point = rect.iTl; |
|
499 |
|
500 for ( TInt i = 0; i < count; i++ ) |
|
501 { |
|
502 controlID = controlList[i]->ControlID(); |
|
503 ctrl = iCtrlPool->Control( controlID ); |
|
504 |
|
505 if ( ctrl ) |
|
506 { |
|
507 rect.iTl = point |
|
508 + TPoint( controlList[i]->BeginColumn() * unitWidth, |
|
509 controlList[i]->BeginRow() * unitHeight ); |
|
510 cols = controlList[i]->EndColumn() |
|
511 - controlList[i]->BeginColumn(); |
|
512 rows = controlList[i]->EndRow() |
|
513 - controlList[i]->BeginRow(); |
|
514 rect.SetSize( TSize( cols * unitWidth, rows * unitHeight ) ); |
|
515 |
|
516 if ( ( ctrl->ControlType() | ECtrlButton ) == ECtrlButton ) |
|
517 { |
|
518 ( static_cast<CAknFepCtrlButton*> ( ctrl ) )->SizeChanged |
|
519 ( rect, ETrue ); |
|
520 } |
|
521 else if ( ctrl->ControlId() == EPeninutWindowCtrlIdHwrBox ) |
|
522 { |
|
523 iBoxGroup->SizeChanged( rect ); |
|
524 static_cast<CPeninputHwrBoxLayout*>(UiLayout())->DataMgr(0)->SetInputAreaSize(rect.Size()); |
|
525 } |
|
526 else if ( ctrl->ControlId() == EPeninutWindowCtrlIdDropDownList ) // DropDownList |
|
527 { |
|
528 iDropdownList->SizeChanged(unitWidth, unitHeight, unitWidth, rect.iTl, cols-1, rows); |
|
529 } |
|
530 AddNotOwnedControl( ctrl ); |
|
531 } |
|
532 } |
|
533 } |
|
534 |
|
535 // -------------------------------------------------------------------------- |
|
536 // CPeninputHwrBoxWindow::GetScrollUpBtnResId |
|
537 // (other items were commented in a header) |
|
538 // -------------------------------------------------------------------------- |
|
539 TInt CPeninputHwrBoxWindow::GetScrollUpBtnResId() |
|
540 { |
|
541 return R_PENINPUT_LAYOUT_HWR_SCROLL_UP; |
|
542 } |
|
543 |
|
544 // -------------------------------------------------------------------------- |
|
545 // CPeninputHwrBoxWindow::GetScrollDownBtnResId |
|
546 // (other items were commented in a header) |
|
547 // -------------------------------------------------------------------------- |
|
548 // |
|
549 TInt CPeninputHwrBoxWindow::GetScrollDownBtnResId() |
|
550 { |
|
551 return R_PENINPUT_LAYOUT_HWR_SCROLL_DOWN; |
|
552 } |
|
553 |
|
554 // -------------------------------------------------------------------------- |
|
555 // CPeninputHwrBoxWindow::DoCaseChange |
|
556 // (other items were commented in a header) |
|
557 // -------------------------------------------------------------------------- |
|
558 // |
|
559 void CPeninputHwrBoxWindow::DoCaseChange( TInt aNewCase ) |
|
560 { |
|
561 if( iDisableCaseChange ) |
|
562 { |
|
563 iCachedCase = aNewCase; |
|
564 return; |
|
565 } |
|
566 TInt* val = static_cast<TInt*>(iLayoutContext->RequestData(EPeninputDataTypePermittedRange)); |
|
567 if ( *val & (ERangeEnglish | ERangeFullWidthEnglish)) |
|
568 { |
|
569 iLayoutContext->SetData( EPeninputDataTypeCase, &aNewCase ); |
|
570 } |
|
571 } |
|
572 |
|
573 // --------------------------------------------------------- |
|
574 // Highlight a dropdownlist cell |
|
575 // --------------------------------------------------------- |
|
576 // |
|
577 void CPeninputHwrBoxWindow::HighlightCell(TInt aIndex) |
|
578 { |
|
579 iDropdownList->SetHighlightCell(aIndex); |
|
580 } |
|
581 |
|
582 // --------------------------------------------------------- |
|
583 // redraw dropdownlist |
|
584 // --------------------------------------------------------- |
|
585 // |
|
586 void CPeninputHwrBoxWindow::DropdownListDraw() |
|
587 { |
|
588 iDropdownList->Draw(); |
|
589 } |
|
590 |
|
591 // --------------------------------------------------------- |
|
592 // Cancel writing |
|
593 // --------------------------------------------------------- |
|
594 // |
|
595 void CPeninputHwrBoxWindow::CancelWriting() |
|
596 { |
|
597 if (iBoxGroup) |
|
598 { |
|
599 iBoxGroup->CancelWriting(); |
|
600 } |
|
601 } |
|
602 |
|
603 // --------------------------------------------------------- |
|
604 // Draw window and shadow |
|
605 // --------------------------------------------------------- |
|
606 // |
|
607 void CPeninputHwrBoxWindow::DimInputContextField( TBool aFlag ) |
|
608 { |
|
609 if ( iInputContextField ) |
|
610 { |
|
611 iInputContextField->SetDimmed( aFlag ); |
|
612 } |
|
613 } |
|
614 |
|
615 // --------------------------------------------------------------------------- |
|
616 // CPeninputHwrBoxWindow::SetDimmed |
|
617 // Dim hwrbox |
|
618 // (other items were commented in a header). |
|
619 // --------------------------------------------------------------------------- |
|
620 // |
|
621 void CPeninputHwrBoxWindow::SetDimmed(TBool aDimFlag) |
|
622 { |
|
623 if (iBoxGroup) |
|
624 { |
|
625 iBoxGroup->SetDimmed(aDimFlag); |
|
626 } |
|
627 } |
|
628 |
|
629 // --------------------------------------------------------------------------- |
|
630 // CPeninputHwrBoxWindow::BoxGroup() |
|
631 // hwrbox control |
|
632 // (other items were commented in a header). |
|
633 // --------------------------------------------------------------------------- |
|
634 // |
|
635 CPeninputHwrBoxGroup* CPeninputHwrBoxWindow::BoxGroup() |
|
636 { |
|
637 return iBoxGroup; |
|
638 } |
|
639 |
|
640 // ----------------------------------------------------------------------------- |
|
641 // CPeninputHwrBoxWindow::ConstructFromResourceL |
|
642 // (other items were commented in a header). |
|
643 // ----------------------------------------------------------------------------- |
|
644 // |
|
645 void CPeninputHwrBoxWindow::ConstructFromResourceL() |
|
646 { |
|
647 CPeninputLayoutWindowJp::ConstructFromResourceL(); |
|
648 SetHwBoxFrameBackColor(); |
|
649 } |
|
650 |
|
651 // --------------------------------------------------------------------------- |
|
652 // CPeninputHwrBoxWindow::SetEnableSettingBtnJp |
|
653 // (other items were commented in a header) |
|
654 // --------------------------------------------------------------------------- |
|
655 // |
|
656 void CPeninputHwrBoxWindow::SetEnableSettingBtnJp(TBool aEnable) |
|
657 { |
|
658 if ( aEnable ) |
|
659 { |
|
660 iTouchInputOptionButton->SetDimmed(EFalse); |
|
661 } |
|
662 else |
|
663 { |
|
664 iTouchInputOptionButton->SetDimmed(ETrue); |
|
665 iTouchInputOptionButton->SetActive(EFalse); |
|
666 } |
|
667 } |
|
668 |
|
669 // -------------------------------------------------------------------------- |
|
670 // CPeninputHwrBoxWindow::CPeninputHwrBoxWindow |
|
671 // (other items were commented in a header) |
|
672 // -------------------------------------------------------------------------- |
|
673 // |
|
674 CPeninputHwrBoxWindow::CPeninputHwrBoxWindow( |
|
675 CFepUiLayout* aUiLayout, MPeninputLayoutContext* aLayoutContext ) |
|
676 : CPeninputLayoutWindowJp( aUiLayout, aLayoutContext ), |
|
677 iDisableCaseChange(EFalse) |
|
678 { |
|
679 } |
|
680 |
|
681 // -------------------------------------------------------------------------- |
|
682 // CPeninputHwrBoxWindow::AddButtonL |
|
683 // (other items were commented in a header) |
|
684 // -------------------------------------------------------------------------- |
|
685 // |
|
686 CAknFepCtrlEventButton* CPeninputHwrBoxWindow::AddButtonL( |
|
687 const TInt aControlId, const TInt aEventId, const TInt aResId, |
|
688 const TInt aUnicode, const TBool aIsRepeat ) |
|
689 { |
|
690 CAknFepCtrlEventButton* button = NULL; |
|
691 |
|
692 if ( aIsRepeat ) |
|
693 { |
|
694 button = CAknFepCtrlRepeatButton::NewL( UiLayout(), aControlId, |
|
695 aEventId, aUnicode ); |
|
696 } |
|
697 else |
|
698 { |
|
699 button = CAknFepCtrlEventButton::NewL( UiLayout(), aControlId, |
|
700 aEventId, aUnicode ); |
|
701 } |
|
702 |
|
703 CleanupStack::PushL( button ); |
|
704 if ( button ) |
|
705 { |
|
706 // Read resource |
|
707 TResourceReader reader; |
|
708 |
|
709 CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId ); |
|
710 button->SetResourceId( aResId ); |
|
711 button->ConstructFromResourceL(); |
|
712 // Pop and destroy reader |
|
713 CleanupStack::PopAndDestroy( 1 ); |
|
714 |
|
715 // Add into the control pool |
|
716 if ( iCtrlPool ) |
|
717 { |
|
718 iCtrlPool->AddControl( button ); |
|
719 } |
|
720 } |
|
721 CleanupStack::Pop( button ); |
|
722 |
|
723 return button; |
|
724 } |
|
725 |
|
726 // -------------------------------------------------------------------------- |
|
727 // CPeninputHwrBoxWindow::AddBoxGroupL |
|
728 // (other items were commented in a header) |
|
729 // -------------------------------------------------------------------------- |
|
730 // |
|
731 void CPeninputHwrBoxWindow::AddBoxGroupL() |
|
732 { |
|
733 iBoxGroup = CPeninputHwrBoxGroup::NewL(UiLayout(), EPeninutWindowCtrlIdHwrBox, KBoxCount); |
|
734 iBoxGroup->SetTransparency(KWndTransparencyFactor, 100); |
|
735 |
|
736 if ( iCtrlPool ) |
|
737 { |
|
738 iCtrlPool->AddControl( iBoxGroup ); |
|
739 } |
|
740 SetHwBoxFrameBackColor(); |
|
741 } |
|
742 |
|
743 // -------------------------------------------------------------------------- |
|
744 // CPeninputHwrBoxWindow::SetHwBoxFrameBackColor |
|
745 // (other items were commented in a header) |
|
746 // -------------------------------------------------------------------------- |
|
747 // |
|
748 void CPeninputHwrBoxWindow::SetHwBoxFrameBackColor() |
|
749 { |
|
750 TRgb frameColor; |
|
751 TRgb backColor; |
|
752 TAknsItemID id; |
|
753 |
|
754 id.Set(KWriteBoxFrameBackColorMajor, KWriteBoxFrameBackColorGrp); |
|
755 |
|
756 TInt error = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
757 frameColor, |
|
758 id, |
|
759 KWriteBoxFrameBackColorIdx); |
|
760 |
|
761 if (error != KErrNone) |
|
762 { |
|
763 frameColor = TRgb(KDefaultWriteBoxFrameColor); |
|
764 backColor = TRgb(KDefaultWriteBoxBackColor); |
|
765 } |
|
766 else |
|
767 { |
|
768 backColor = frameColor; |
|
769 } |
|
770 |
|
771 if (iBoxGroup) |
|
772 { |
|
773 iBoxGroup->SetBoxFrameColor(frameColor); |
|
774 iBoxGroup->SetBoxBackColor(backColor); |
|
775 } |
|
776 } |
|
777 |
|
778 // --------------------------------------------------------- |
|
779 // Add dropdown list to window |
|
780 // --------------------------------------------------------- |
|
781 // |
|
782 void CPeninputHwrBoxWindow::AddDropdownListL() |
|
783 { |
|
784 ChangeUnitSize(); |
|
785 TInt unitWidth = CPeninputDataConverter::AnyToInt |
|
786 ( iLayoutContext->RequestData( EPeninputDataTypeUnitWidth ) ); |
|
787 TInt unitHeight = CPeninputDataConverter::AnyToInt |
|
788 ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) ); |
|
789 |
|
790 TResourceReader reader; |
|
791 CCoeEnv::Static()->CreateResourceReaderLC(reader,R_PENINPUT_LAYOUT_HWR_DROP_DOWN_LIST); |
|
792 |
|
793 TAknTextLineLayout candTextLayout = AknLayoutScalable_Avkon::cell_hwr_candidate_pane_t1().LayoutLine(); |
|
794 |
|
795 TInt textMargin = (unitHeight - |
|
796 AknLayoutUtils::FontFromId(candTextLayout.iFont, NULL)->HeightInPixels())/2; |
|
797 |
|
798 iDropdownList = CFepCtrlDropdownList::NewL(TPoint(Rect().iTl.iX, Rect().iTl.iY + unitHeight), |
|
799 UiLayout(), |
|
800 EPeninutWindowCtrlIdDropDownList, |
|
801 reader, |
|
802 unitWidth, |
|
803 unitHeight, |
|
804 unitWidth, |
|
805 PENINPUT_LAYOUT_HWR_COL_COUNT-1, |
|
806 PENINPUT_LAYOUT_HWR_ROW_COUNT, |
|
807 AknLayoutUtils::FontFromId(candTextLayout.iFont, NULL), |
|
808 NULL, |
|
809 CGraphicsContext::ECenter, |
|
810 textMargin, |
|
811 KRgbBlack, // border color |
|
812 TRgb(0xeeeeee), // content bg color |
|
813 KRgbWhite, // navi bg color |
|
814 AKN_LAF_COLOR_STATIC(candTextLayout.iC), |
|
815 KRgbRed); |
|
816 |
|
817 if ( iCtrlPool ) |
|
818 { |
|
819 iCtrlPool->AddControl( iDropdownList ); |
|
820 } |
|
821 iDropdownList->SetResourceId(R_PENINPUT_LAYOUT_HWR_DROP_DOWN_LIST); |
|
822 iDropdownList->SetEventIdForCandidateSelected(EPeninputLayoutHwrEventCandidateSelected); |
|
823 CleanupStack::PopAndDestroy(); // reader |
|
824 } |
|
825 |
|
826 // --------------------------------------------------------------------------- |
|
827 // CPeninputHwrBoxWindow::SetWholeWindowRect |
|
828 // [Ref]CPeninputLayoutWindow::SetWindowRect |
|
829 // (other items were commented in a header). |
|
830 // --------------------------------------------------------------------------- |
|
831 // |
|
832 void CPeninputHwrBoxWindow::SetWholeWindowRect(const TRect& aRect) |
|
833 { |
|
834 TRect rect = aRect; |
|
835 |
|
836 TInt unitHeight = CPeninputDataConverter::AnyToInt |
|
837 ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) ); |
|
838 rect.iTl.iY = rect.iTl.iY - unitHeight; |
|
839 |
|
840 if (!iPredictiveWnd->Hiden()) |
|
841 { |
|
842 TRect predictiveRect = aRect; |
|
843 predictiveRect.iTl.iY = predictiveRect.iBr.iY; |
|
844 predictiveRect.iBr.iY += iPredictiveWnd->Rect().Size().iHeight; |
|
845 iPredictiveWnd->SetRect(predictiveRect); |
|
846 rect.iBr.iY += iPredictiveWnd->Rect().Size().iHeight; |
|
847 } |
|
848 |
|
849 SetRect(rect); |
|
850 |
|
851 |
|
852 TRect shadowRect = TRect(TPoint(rect.iTl.iX - iShadowTlWidth, |
|
853 rect.iTl.iY - iShadowTlHeight), |
|
854 TPoint(rect.iBr.iX + iShadowBrWidth, |
|
855 rect.iBr.iY + iShadowBrHeight)); |
|
856 |
|
857 SetShadowRect(shadowRect); |
|
858 ICFDisableRegionUpdating(); // ICF::OnDeActivate() |
|
859 UiLayout()->SetShadowRect(shadowRect); |
|
860 ICFDisableRegionUpdating(); // ICF::OnDeActivate() |
|
861 |
|
862 HandleControlEvent(EPeninputLayoutEventMovePosition, NULL, KNullDesC); |
|
863 } |
|
864 |
|
865 // --------------------------------------------------------------------------- |
|
866 // CPeninputHwrBoxWindow::AddContextFieldJpL |
|
867 // [ref]CPeninputLayoutWindow::AddContextFieldL( aResID ) |
|
868 // (other items were commented in a header) |
|
869 // --------------------------------------------------------------------------- |
|
870 // |
|
871 void CPeninputHwrBoxWindow::AddContextFieldJpL() |
|
872 { |
|
873 // Get reference CControlGroup of headerPane |
|
874 CControlGroup* headerPane = HeaderPane(); |
|
875 |
|
876 User::LeaveIfNull( headerPane ); |
|
877 |
|
878 // Input context field |
|
879 iInputContextField = CFepInputContextFieldJp::NewL( TRect(), |
|
880 UiLayout(), EPeninutWindowCtrlIdInputContextField ); |
|
881 |
|
882 // Read resource |
|
883 TResourceReader resReader; |
|
884 CCoeEnv::Static()->CreateResourceReaderLC( resReader, R_PENINPUT_LAYOUT_ICF ); |
|
885 ReadIcfInfo( resReader ); |
|
886 CleanupStack::PopAndDestroy( 1 ); |
|
887 // Transfer to headerPane |
|
888 headerPane->AddControlL( iInputContextField ); |
|
889 |
|
890 iInputContextField->SetFocus(ETrue); |
|
891 |
|
892 // Add layout as event observer |
|
893 iInputContextField->AddEventObserver( UiLayout() ); |
|
894 } |
|
895 |