1 /* |
|
2 * Copyright (c) 2002-2004 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 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 // INCLUDE FILES |
|
30 #include <eikdef.h> |
|
31 |
|
32 #include <aknViewAppUi.h> |
|
33 #include <avkon.hrh> |
|
34 #include <aknPopup.h> |
|
35 #include <aknlists.h> |
|
36 #include <AknsDrawUtils.h> |
|
37 #include <AknLayout.lag> |
|
38 #include <aknlayoutscalable_avkon.cdl.h> |
|
39 #include <AknLayout2ScalableDef.h> |
|
40 |
|
41 #include "AknFepUiInterfacePanic.h" |
|
42 #include "AknFepUIAvkonCtrlJapaneseCandidateListbox.h" |
|
43 #include "AknFepUIAvkonCtrlJapaneseCandidateListboxView.h" |
|
44 #include "AknFepUIAvkonCtrlJapaneseCandidateCellListBoxData.h" |
|
45 |
|
46 // CONSTANTS |
|
47 const TInt KLAFBaseListColumns = 3; |
|
48 |
|
49 // ============================ MEMBER FUNCTIONS =============================== |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CAknFepUICtrlJapaneseCandidateListbox::SetMaximumColumns |
|
53 // Set maximum columns in listbox |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CAknFepUICtrlJapaneseCandidateListbox::SetMaximumColumns( |
|
57 const TInt aMaximumColumns) |
|
58 { |
|
59 iMaximumColumns = aMaximumColumns; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CAknFepUICtrlJapaneseCandidateListbox::SizeChanged |
|
64 // This function is called when changing window size. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CAknFepUICtrlJapaneseCandidateListbox::SizeChanged() |
|
68 { |
|
69 CEikFormattedCellListBox& listBox = *this; |
|
70 CFormattedCellListBoxItemDrawer* itemDrawer = listBox.ItemDrawer(); |
|
71 |
|
72 TAknWindowLineLayout textWindowLayout = |
|
73 AKN_LAYOUT_WINDOW_list_single_popup_jap_candidate_pane( |
|
74 0, iMaximumColumns - KLAFBaseListColumns); |
|
75 AknListBoxLayouts::SetupStandardListBox(listBox); |
|
76 AknListBoxLayouts::SetupStandardFormListbox(itemDrawer); |
|
77 AknListBoxLayouts::SetupListboxPos(listBox, textWindowLayout); |
|
78 |
|
79 { |
|
80 TRgb color( KRgbBlack ); |
|
81 // this does not modify color unless it gets a correct one |
|
82 // no real need to check errors |
|
83 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
84 color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10 ); |
|
85 itemDrawer->SetHighlightedTextColor( color ); |
|
86 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
87 color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG7 ); |
|
88 iItemDrawer->SetTextColor( color ); |
|
89 } |
|
90 |
|
91 // setting text box size in listbox |
|
92 TAknTextLineLayout textLineLayout = |
|
93 AKN_LAYOUT_TEXT_List_pane_text__single_japan_fep__Line_1( |
|
94 iMaximumColumns - KLAFBaseListColumns); |
|
95 TSize itemSize = View()->ItemSize(); |
|
96 |
|
97 AknListBoxLayouts::SetupFormAntiFlickerTextCell( |
|
98 listBox, itemDrawer, 0, textLineLayout, |
|
99 TPoint(0, 0), |
|
100 TPoint(itemSize.iWidth, itemSize.iHeight)); // CheckColor. |
|
101 |
|
102 CEikFormattedCellListBox::SizeChanged(); |
|
103 |
|
104 // Scroll bar |
|
105 TAknWindowLineLayout scrollLineLayout = AknLayoutScalable_Avkon::scroll_pane_cp30().LayoutLine(); |
|
106 scrollLineLayout.il = ELayoutEmpty; |
|
107 if (Model()->NumberOfItems() <= iMaximumRows) |
|
108 { |
|
109 scrollLineLayout.iW = 0; |
|
110 } |
|
111 TRect scrollBarParent = TRect(TPoint(listBox.Rect().iTl), |
|
112 TSize(listBox.Rect().Width() + scrollLineLayout.iW + scrollLineLayout.ir, |
|
113 listBox.Rect().Height())); |
|
114 AknLayoutUtils::LayoutVerticalScrollBar(iSBFrame, scrollBarParent, scrollLineLayout); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CAknFepUICtrlJapaneseCandidateListbox::MakeViewClassInstanceL |
|
119 // Create view class |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 CListBoxView* CAknFepUICtrlJapaneseCandidateListbox::MakeViewClassInstanceL() |
|
123 { |
|
124 return new(ELeave) CAknFepUICtrlJapaneseCandidateListboxView; |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CAknFepUICtrlJapaneseCandidateListbox::CreateItemDrawerL |
|
129 // Create ItemDrawer |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CAknFepUICtrlJapaneseCandidateListbox::CreateItemDrawerL() |
|
133 { |
|
134 CAknFepUICtrlJapaneseCandidateCellListBoxData* cellData = |
|
135 CAknFepUICtrlJapaneseCandidateCellListBoxData::NewL(); |
|
136 CleanupStack::PushL( cellData ); |
|
137 |
|
138 // getting font object |
|
139 TAknTextLineLayout textLineLayout = |
|
140 AKN_LAYOUT_TEXT_List_pane_text__single_japan_fep__Line_1(0); |
|
141 const CFont* font = AknLayoutUtils::FontFromId(textLineLayout.iFont); |
|
142 |
|
143 iItemDrawer = |
|
144 new(ELeave) CFormattedCellListBoxItemDrawer(Model(), font, cellData); |
|
145 CleanupStack::Pop(cellData); |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CAknFepUICtrlJapaneseCandidateListbox::SetMaximumRows |
|
150 // Set maximum visible rows in listbox |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CAknFepUICtrlJapaneseCandidateListbox::SetMaximumRows( |
|
154 const TInt aMaximumRows) |
|
155 { |
|
156 iMaximumRows = aMaximumRows; |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CAknFepUICtrlJapaneseCandidateListbox::HandlePointerEventL |
|
161 // (other items were commented in a header). |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 void CAknFepUICtrlJapaneseCandidateListbox::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
165 { |
|
166 const TInt old = CurrentItemIndex(); |
|
167 CAknSinglePopupMenuStyleListBox::HandlePointerEventL(aPointerEvent); |
|
168 switch (aPointerEvent.iType) |
|
169 { |
|
170 case TPointerEvent::EButton1Up: |
|
171 break; |
|
172 case TPointerEvent::EButton1Down: |
|
173 { |
|
174 if (CurrentItemIndex() != old) |
|
175 { |
|
176 ReportListBoxEventL(MEikListBoxObserver::EEventItemDraggingActioned);// need draw. |
|
177 } |
|
178 } |
|
179 break; |
|
180 default: |
|
181 break; |
|
182 } |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CAknFepUICtrlJapaneseCandidateListbox::HandleScrollEventL |
|
187 // (other items were commented in a header). |
|
188 // ----------------------------------------------------------------------------- |
|
189 void CAknFepUICtrlJapaneseCandidateListbox::HandleScrollEventL( |
|
190 CEikScrollBar* aScrollBar, |
|
191 TEikScrollEvent aEventType) |
|
192 { |
|
193 TInt oldThumbPos = (aEventType & KEikScrollEventBarMask) ? |
|
194 iView->HScrollOffset() : iView->TopItemIndex(); |
|
195 TInt newThumbPos = aScrollBar->ThumbPosition(); |
|
196 TInt maxThumbPos = static_cast<CTextListBoxModel*>(Model())->NumberOfItems() |
|
197 - MaximumRows(); |
|
198 TBool update = ETrue; |
|
199 TInt newThumbPosBeforeCorrecting = newThumbPos; |
|
200 |
|
201 if ((aEventType & KEikScrollEventBarMask) == KEikScrollEventFromVBar) |
|
202 { |
|
203 switch (aEventType) |
|
204 { |
|
205 case EEikScrollUp: |
|
206 if ( oldThumbPos == 0 && (iListBoxFlags & ELoopScrolling)) |
|
207 { |
|
208 newThumbPos = maxThumbPos; |
|
209 } |
|
210 break; |
|
211 case EEikScrollDown: |
|
212 if ( oldThumbPos == maxThumbPos && (iListBoxFlags & ELoopScrolling) ) |
|
213 { |
|
214 newThumbPos = 0; |
|
215 } |
|
216 break; |
|
217 case EEikScrollPageUp: |
|
218 case EEikScrollPageDown: |
|
219 case EEikScrollThumbDragVert: |
|
220 break; |
|
221 case EEikScrollThumbReleaseVert: |
|
222 // in the case of drag events, the scrollbar automatically updates its thumb pos... |
|
223 if(AknLayoutUtils::PenEnabled()) |
|
224 { |
|
225 update = EFalse; |
|
226 } |
|
227 break; |
|
228 |
|
229 default: |
|
230 break; |
|
231 } |
|
232 if ( (!AknLayoutUtils::PenEnabled()) || update ) |
|
233 { |
|
234 iView->VScrollTo(newThumbPos); |
|
235 if (aEventType != EEikScrollThumbDragVert) |
|
236 { |
|
237 aScrollBar->SetModelThumbPosition(iView->TopItemIndex()); |
|
238 } |
|
239 } |
|
240 |
|
241 // if event has changed thumb position, then update scroll bar |
|
242 if ( AknLayoutUtils::PenEnabled() && newThumbPos != newThumbPosBeforeCorrecting ) |
|
243 { |
|
244 UpdateScrollBarThumbs(); |
|
245 } |
|
246 } |
|
247 } |
|
248 |
|
249 |
|
250 // End of File |
|