|
1 /* |
|
2 * Copyright (c) 2005-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 of mutli-page virtual keyboard control. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE |
|
20 #include <e32std.h> |
|
21 |
|
22 #include "peninputlayoutbubblectrl.h" |
|
23 #include "peninputlayoutvkb.h" |
|
24 #include "peninputpluginutils.h" |
|
25 #include "peninputfingerhwrarmultipagevkb.h" |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // Symbian Constructor |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CMultiPageVirtualKeyboard* CMultiPageVirtualKeyboard::NewL( |
|
32 const TRect& aRect, CFepUiLayout* aUiLayout,TInt aControlId, |
|
33 const TFontSpec& aFontSpec, TBool aIrregular ) |
|
34 { |
|
35 CMultiPageVirtualKeyboard* vkb = new(ELeave) CMultiPageVirtualKeyboard( |
|
36 aRect, aUiLayout, aControlId, aFontSpec, aIrregular ); |
|
37 |
|
38 CleanupStack::PushL( vkb ); |
|
39 vkb->ConstructL(); |
|
40 vkb->SetRect( aRect ); |
|
41 CleanupStack::Pop( vkb ); |
|
42 return vkb; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // Symbian Constructor |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CMultiPageVirtualKeyboard* CMultiPageVirtualKeyboard::NewL( |
|
50 const TRect& aRect, CFepUiLayout* aUiLayout,TInt aControlId, |
|
51 CFont* aFont, TBool aIrregular ) |
|
52 { |
|
53 TFontSpec fontSpec; |
|
54 fontSpec.iHeight = 0; |
|
55 CMultiPageVirtualKeyboard* vkb = new(ELeave) CMultiPageVirtualKeyboard( |
|
56 aRect, aUiLayout, aControlId, fontSpec, aIrregular ); |
|
57 |
|
58 vkb->SetFont( aFont ); |
|
59 CleanupStack::PushL( vkb ); |
|
60 vkb->ConstructL(); |
|
61 vkb->SetRect( aRect ); |
|
62 CleanupStack::Pop( vkb ); |
|
63 return vkb; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // c++ destructor |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CMultiPageVirtualKeyboard::~CMultiPageVirtualKeyboard() |
|
71 { |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // get current page index. |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 TInt CMultiPageVirtualKeyboard::CurPageIndex() |
|
79 { |
|
80 return iCurPageIndex; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // get current page count. |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 TInt CMultiPageVirtualKeyboard::PageCount() |
|
88 { |
|
89 return iPageCount; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // get current page size. |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 TInt CMultiPageVirtualKeyboard::PageSize() |
|
97 { |
|
98 return iPageSize; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // move to next page. |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 void CMultiPageVirtualKeyboard::NavToNextPage() |
|
106 { |
|
107 if ( iCurPageIndex < iPageCount - 1 ) |
|
108 { |
|
109 iCurPageIndex++; |
|
110 NavToPage( iCurPageIndex ); |
|
111 } |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // move to previous page. |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CMultiPageVirtualKeyboard::NavToPrevPage() |
|
119 { |
|
120 if ( iCurPageIndex > 0 ) |
|
121 { |
|
122 iCurPageIndex--; |
|
123 NavToPage( iCurPageIndex ); |
|
124 } |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // move to first page. |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void CMultiPageVirtualKeyboard::NavToFirstPage() |
|
132 { |
|
133 if ( iPageCount > 0 ) |
|
134 { |
|
135 NavToPage( 0 ); |
|
136 } |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // move to last page. |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CMultiPageVirtualKeyboard::NavToLastPage() |
|
144 { |
|
145 if ( iPageCount > 0 ) |
|
146 { |
|
147 NavToPage( iPageCount - 1 ); |
|
148 } |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // move to specified page. |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CMultiPageVirtualKeyboard::NavToPage( TInt aPageIndex ) |
|
156 { |
|
157 if ( aPageIndex >= iPageCount || aPageIndex <0 ) |
|
158 { |
|
159 _LIT(KErrorPageIndex,"invalid index"); |
|
160 User::Panic( KErrorPageIndex, 0 ); |
|
161 return; |
|
162 } |
|
163 |
|
164 iCurPageIndex = aPageIndex; |
|
165 |
|
166 const RPointerArray<CVirtualKey>& keys = KeyArray(); |
|
167 TInt count = keys.Count(); |
|
168 for ( TInt i = 0; i < count; i++ ) |
|
169 { |
|
170 TInt page = i / iPageSize; |
|
171 CVirtualKey* vk = keys[i]; |
|
172 |
|
173 vk->HideKeyCtrl( page != aPageIndex ); |
|
174 } |
|
175 |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // update paging. |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 void CMultiPageVirtualKeyboard::UpdatePaging( TInt aRows, TInt aCols ) |
|
183 { |
|
184 TInt count = KeyArray().Count(); |
|
185 |
|
186 iPageSize = aRows * aCols; |
|
187 iPageCount = ( count + iPageSize - 1) / iPageSize; |
|
188 iCurPageIndex = 0; |
|
189 NavToPage( iCurPageIndex ); |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // c++ constructor |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 CMultiPageVirtualKeyboard::CMultiPageVirtualKeyboard(const TRect& aRect, |
|
197 CFepUiLayout* aUiLayout, TInt aControlId, const TFontSpec& aFontSpec, |
|
198 TBool aIrregular ) |
|
199 : CVirtualKeyboard( aRect, aUiLayout, aControlId, aFontSpec, aIrregular ) |
|
200 { |
|
201 // No implementation required |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // Symbian second-phase constructor |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 void CMultiPageVirtualKeyboard::ConstructL() |
|
209 { |
|
210 CVirtualKeyboard::ConstructL(); |
|
211 } |
|
212 // End Of File |