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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 #include <barsread.h> |
|
28 #include <AvkonInternalCRKeys.h> |
|
29 #include <AknFepInternalCRKeys.h> |
|
30 #include <e32property.h> |
|
31 #include <PtiDefs.h> |
|
32 #include <AknFepGlobalEnums.h> |
|
33 #include <avkon.hrh> |
|
34 #include <aknsettingitemlist.h> |
|
35 #include <aknfep.rsg> |
|
36 #include "AknFepUIAvkonCtrlDualLanguageSettingList.h" |
|
37 |
|
38 |
|
39 CAknFepDualLanguageSettingItem::CAknFepDualLanguageSettingItem( TInt aResourceId, TBool aPrimary, CAknFepDualLanguageSettingData* aData) |
|
40 : CAknEnumeratedTextPopupSettingItem(aResourceId, (aPrimary?aData->iCurrentValue:aData->iCurrentSecondaryValue)) |
|
41 , iData(aData), iPrimary(aPrimary) |
|
42 { |
|
43 } |
|
44 |
|
45 CAknFepDualLanguageSettingItem::~CAknFepDualLanguageSettingItem() |
|
46 { |
|
47 } |
|
48 |
|
49 void CAknFepDualLanguageSettingItem::CompleteConstructionL() |
|
50 { |
|
51 CAknEnumeratedTextPopupSettingItem::CompleteConstructionL(); |
|
52 CArrayPtrFlat<HBufC>* dummyPtr = new (ELeave) CArrayPtrFlat<HBufC>(1); |
|
53 CleanupStack::PushL(dummyPtr); |
|
54 CArrayPtrFlat<CAknEnumeratedText>* items = new (ELeave) CArrayPtrFlat<CAknEnumeratedText>(10); |
|
55 CleanupStack::PushL(items); |
|
56 if(iPrimary) |
|
57 { |
|
58 for(TInt i = 0; i < iData->Items()->Count(); i++) |
|
59 { |
|
60 HBufC* buffer = HBufC::NewLC( 128 ); |
|
61 (*buffer) = (*iData->Items())[i]; |
|
62 CAknEnumeratedText* newItem = new (ELeave) CAknEnumeratedText(i, buffer); |
|
63 CleanupStack::PushL(newItem); |
|
64 items->AppendL(newItem); |
|
65 CleanupStack::Pop(newItem); |
|
66 CleanupStack::Pop(buffer); |
|
67 } |
|
68 SetEnumeratedTextArrays(items, dummyPtr); |
|
69 SetInternalValue(iData->iCurrentValue); |
|
70 SetExternalValue(iData->iCurrentValue); |
|
71 } |
|
72 else |
|
73 { |
|
74 for(TInt i = 0; i < iData->SecondaryItems()->Count(); i++) |
|
75 { |
|
76 HBufC* buffer = HBufC::NewLC( 128 ); |
|
77 (*buffer) = (*iData->SecondaryItems())[i]; |
|
78 CAknEnumeratedText* newItem = new (ELeave) CAknEnumeratedText(i, buffer); |
|
79 CleanupStack::PushL(newItem); |
|
80 items->AppendL(newItem); |
|
81 CleanupStack::Pop(newItem); |
|
82 CleanupStack::Pop(buffer); |
|
83 } |
|
84 SetEnumeratedTextArrays(items, dummyPtr); |
|
85 SetInternalValue(iData->iCurrentSecondaryValue); |
|
86 SetExternalValue(iData->iCurrentSecondaryValue); |
|
87 } |
|
88 CleanupStack::Pop(items); |
|
89 CleanupStack::Pop(dummyPtr); |
|
90 } |
|
91 |
|
92 CAknFepDualLanguageSettingList *CAknFepDualLanguageSettingList::NewL(CAknFepDualLanguageSettingData* aData, CAknFepDualLanguageSettingDialog* aDialog) |
|
93 { |
|
94 CAknFepDualLanguageSettingList* self = CAknFepDualLanguageSettingList::NewLC(aData, aDialog); |
|
95 CleanupStack::Pop(self); |
|
96 return self; |
|
97 } |
|
98 |
|
99 CAknFepDualLanguageSettingList *CAknFepDualLanguageSettingList::NewLC(CAknFepDualLanguageSettingData* aData, CAknFepDualLanguageSettingDialog* aDialog) |
|
100 { |
|
101 CAknFepDualLanguageSettingList* self = new (ELeave) CAknFepDualLanguageSettingList(aData, aDialog); |
|
102 CleanupStack::PushL(self); |
|
103 return self; |
|
104 } |
|
105 |
|
106 CAknFepDualLanguageSettingList::CAknFepDualLanguageSettingList(CAknFepDualLanguageSettingData* aData, CAknFepDualLanguageSettingDialog* aDialog) : |
|
107 CAknSettingItemList(), iData(aData), iDialog(aDialog) |
|
108 { |
|
109 } |
|
110 |
|
111 CAknFepDualLanguageSettingList::~CAknFepDualLanguageSettingList() |
|
112 { |
|
113 // no specific destruction code required - no owned data |
|
114 } |
|
115 |
|
116 |
|
117 void CAknFepDualLanguageSettingList::SizeChanged() |
|
118 { |
|
119 // if size changes, make sure component takes whole available space |
|
120 CEikFormattedCellListBox *listbox = ListBox(); |
|
121 |
|
122 if (listbox) |
|
123 { |
|
124 listbox->SetRect(Rect()); |
|
125 } |
|
126 } |
|
127 |
|
128 void CAknFepDualLanguageSettingList::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) |
|
129 { |
|
130 if(aEventType == EEventEnterKeyPressed) |
|
131 { |
|
132 EditCurrentItemL(EFalse); |
|
133 } |
|
134 } |
|
135 |
|
136 void CAknFepDualLanguageSettingList::EditCurrentItemL(TBool aCalledFromMenu) |
|
137 { |
|
138 // invoke EditItemL on the current item |
|
139 TInt index = SettingItemArray()->ItemIndexFromVisibleIndex(ListBox()->CurrentItemIndex()); |
|
140 |
|
141 EditItemL(index, aCalledFromMenu); // invoked from menu,or not |
|
142 |
|
143 StoreSettingsL(); |
|
144 } |
|
145 |
|
146 CAknSettingItem * CAknFepDualLanguageSettingList::CreateSettingItemL (TInt aIdentifier) |
|
147 { |
|
148 // method is used to create specific setting item as required at run-time. |
|
149 // aIdentifier is used to determine what kind of setting item should be |
|
150 // created |
|
151 |
|
152 CAknFepDualLanguageSettingItem* settingItem = NULL; |
|
153 |
|
154 TInt language = 0; |
|
155 CRepository* aknFepRepository = CRepository::NewLC(KCRUidAknFep); |
|
156 aknFepRepository->Get( KAknFepInputTxtLang, language ); |
|
157 |
|
158 switch (aIdentifier) |
|
159 { |
|
160 case EAknFepDualLanguageSettingDualInputPrimary: |
|
161 settingItem = new (ELeave) CAknFepDualLanguageSettingItem( |
|
162 R_PRIMARY_INPUT_LANGUAGE_SETTING_PAGE, ETrue, iData); |
|
163 break; |
|
164 case EAknFepDualLanguageSettingDualInputSecondary: |
|
165 settingItem = new (ELeave) CAknFepDualLanguageSettingItem( |
|
166 R_SECONDARY_INPUT_LANGUAGE_SETTING_PAGE, EFalse, iData); |
|
167 if(language == ELangTaiwanChinese || |
|
168 language == ELangHongKongChinese || |
|
169 language == ELangPrcChinese || |
|
170 language == ELangJapanese || |
|
171 language == ELangKorean ) |
|
172 { |
|
173 settingItem->SetHidden(ETrue); |
|
174 } |
|
175 break; |
|
176 default: |
|
177 break; |
|
178 } |
|
179 CleanupStack::PopAndDestroy( aknFepRepository ); |
|
180 |
|
181 return (CAknSettingItem*)settingItem; |
|
182 } |
|
183 |
|
184 void CAknFepDualLanguageSettingList::HideSecondaryInputL(TBool aHidden) |
|
185 { |
|
186 SettingItemArray()->At(1)->SetHidden(aHidden); |
|
187 HandleChangeInItemArrayOrVisibilityL(); |
|
188 } |
|