66
|
1 |
/*******************************************************************************
|
|
2 |
* Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved. This program and the accompanying materials
|
|
4 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
5 |
* which accompanies this distribution, and is available at
|
|
6 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
7 |
*
|
|
8 |
* Contributors:
|
|
9 |
* Nokia Corporation - S60 implementation
|
|
10 |
*******************************************************************************/
|
|
11 |
|
|
12 |
|
|
13 |
#include <eikedwin.h>
|
|
14 |
#include <CPbkContactEngine.h>
|
|
15 |
#include <CPbkSingleEntryFetchDlg.h>
|
|
16 |
#include <CPbkContactItem.h>
|
|
17 |
#include <RPbkViewResourceFile.h>
|
|
18 |
#include <avkon.rsg>
|
|
19 |
#include <barsread.h>
|
|
20 |
#include <favouritesdb.h>
|
|
21 |
#include <favouritesitemlist.h>
|
|
22 |
#include <favouritessession.h>
|
|
23 |
#include <aknselectionlist.h>
|
|
24 |
#include <eikspane.h>
|
|
25 |
#include <akntitle.h>
|
|
26 |
#include <akncontext.h>
|
|
27 |
#include <AknsUtils.h>
|
|
28 |
#include <aknappui.h>
|
|
29 |
#include <eswtcore.rsg>
|
|
30 |
#include <featdiscovery.h>
|
|
31 |
#include <e32const.h>
|
|
32 |
#include <swtlaffacade.h>
|
|
33 |
#include "swtcontrolmenu.h"
|
|
34 |
#include "swtmenuitem.h"
|
|
35 |
#include "eswtmobile.hrh"
|
|
36 |
#include "swtuiutils.h"
|
|
37 |
#include "swttextextension.h"
|
|
38 |
|
|
39 |
|
|
40 |
//Pin Board UID for Favourites Icon
|
|
41 |
#define PINB_UID 0x1000590B
|
|
42 |
|
|
43 |
_LIT(KTAB,"\t");
|
|
44 |
|
|
45 |
const TInt KSWTTEXTEXTENSION_EMAIL_LENGTH = 150;
|
|
46 |
const TInt KSWTTEXTEXTENSION_URL_LENGTH = 1000;
|
|
47 |
|
|
48 |
// Character subsets for SetInitialInputModeL
|
|
49 |
_LIT(KUcbBasicLatin, "UCB_BASIC_LATIN");
|
|
50 |
_LIT(KIsLatin, "IS_LATIN");
|
|
51 |
_LIT(KIsLatinDigits, "IS_LATIN_DIGITS");
|
|
52 |
_LIT(KUcbArabic, "UCB_ARABIC");
|
|
53 |
_LIT(KUcbHebrew, "UCB_HEBREW");
|
|
54 |
_LIT(KUcbGreek, "UCB_GREEK");
|
|
55 |
_LIT(KUcbThai, "UCB_THAI");
|
|
56 |
_LIT(KIsSimplifiedHanzi, "IS_SIMPLIFIED_HANZI");
|
|
57 |
_LIT(KUcbHiragana, "UCB_HIRAGANA");
|
|
58 |
_LIT(KUcbKatakana, "UCB_KATAKANA");
|
|
59 |
_LIT(KIsHalfwidthKatakana, "IS_HALFWIDTH_KATAKANA");
|
|
60 |
_LIT(KIsKanji, "IS_KANJI");
|
|
61 |
_LIT(KIsFullwidthDigits, "IS_FULLWIDTH_DIGITS");
|
|
62 |
_LIT(KIsFullwidthLatin, "IS_FULLWIDTH_LATIN");
|
|
63 |
_LIT(KUcbCyrillic, "UCB_CYRILLIC");
|
|
64 |
_LIT(KUcbArmenian, "UCB_ARMENIAN");
|
|
65 |
_LIT(KUcbDevanagari, "UCB_DEVANAGARI");
|
|
66 |
_LIT(KUcbBengali, "UCB_BENGALI");
|
|
67 |
_LIT(KUcbHangulSyllables, "UCB_HANGUL_SYLLABLES");
|
|
68 |
_LIT(KIsHanja, "IS_HANJA");
|
|
69 |
_LIT(KIsTraditionalHanzi, "IS_TRADITIONAL_HANZI");
|
|
70 |
|
|
71 |
|
|
72 |
// Character subsets that contain more than one S60 language
|
|
73 |
enum
|
|
74 |
{
|
|
75 |
ECharSubsetNone= 0,
|
|
76 |
EIsLatin, // "IS_LATIN"
|
|
77 |
EUcbCyrillic, // "UCB_CYRILLIC"
|
|
78 |
EUcbArabic, // "UCB_ARABIC"
|
|
79 |
EIsTraditionalHanzi // "IS_TRADITIONAL_HANZI"
|
|
80 |
};
|
|
81 |
|
|
82 |
|
|
83 |
// ======== LOCAL FUNCTIONS ========
|
|
84 |
|
|
85 |
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
// Local function for sorting the Favourite items by Name
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
LOCAL_C TInt CompareItemsByNameL(const CFavouritesItem& aLeft, const CFavouritesItem& aRight)
|
|
91 |
{
|
|
92 |
return aLeft.Name().CompareF(aRight.Name());
|
|
93 |
}
|
|
94 |
|
|
95 |
|
|
96 |
// ======== MEMBER FUNCTIONS ========
|
|
97 |
|
|
98 |
|
|
99 |
// ---------------------------------------------------------------------------
|
|
100 |
// Destructor for TextExtension
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
//
|
|
103 |
CSwtTextExtension::~CSwtTextExtension()
|
|
104 |
{
|
|
105 |
delete iNaviDecorator;
|
|
106 |
|
|
107 |
if (iMenuItem)
|
|
108 |
iMenuItem->Dispose();
|
|
109 |
|
|
110 |
if (iMenu)
|
|
111 |
iMenu->Dispose();
|
|
112 |
}
|
|
113 |
|
|
114 |
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
// 2nd phase constructor.
|
|
117 |
// ---------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
void CSwtTextExtension::ConstructL()
|
|
120 |
{
|
|
121 |
CSwtText::ConstructL();
|
|
122 |
}
|
|
123 |
|
|
124 |
|
|
125 |
// ---------------------------------------------------------------------------
|
|
126 |
// Constructs and returns an object.
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
CSwtTextExtension* CSwtTextExtension::NewL(
|
|
130 |
MSwtDisplay& aDisplay,
|
|
131 |
TSwtPeer aPeer,
|
|
132 |
MSwtComposite& aParent,
|
|
133 |
TInt aStyle)
|
|
134 |
{
|
|
135 |
CSwtTextExtension* self = new(ELeave) CSwtTextExtension(aDisplay,
|
|
136 |
aPeer, aParent, aStyle);
|
|
137 |
CleanupStack::PushL(self);
|
|
138 |
self->ConstructL();
|
|
139 |
self->InitControlBaseL();
|
|
140 |
CleanupStack::Pop(self);
|
|
141 |
return self;
|
|
142 |
}
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
// ---------------------------------------------------------------------------
|
|
147 |
// Sets content styles(Email address, URL), input modifier styles and
|
|
148 |
// casing modifiers. Note that Non Midlet commands are added here
|
|
149 |
// ---------------------------------------------------------------------------
|
|
150 |
//
|
|
151 |
void CSwtTextExtension::SetTypeStyleL(TInt aTypeStyle)
|
|
152 |
{
|
|
153 |
iTypeStyle=aTypeStyle;
|
|
154 |
|
|
155 |
TInt sct = R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG;
|
|
156 |
TUint flags = 0;
|
|
157 |
CEikEdwin& edwin = Editor();
|
|
158 |
if (iTypeStyle & EEmailAddress)
|
|
159 |
{
|
|
160 |
iMenu = CSwtControlMenu::NewL(iDisplay, NULL, 0);
|
|
161 |
iMenu->SetObserver(this);
|
|
162 |
iMenuItem = CSwtMenuItem::NewL(iDisplay, NULL, *iMenu, 0, 0, ESwtFetchEmail);
|
|
163 |
// Email style implementation
|
|
164 |
edwin.SetMaxLength(KSWTTEXTEXTENSION_EMAIL_LENGTH);
|
|
165 |
edwin.SetAknEditorAllowedInputModes(EAknEditorAllInputModes);
|
|
166 |
edwin.SetAknEditorCurrentInputMode(EAknEditorAlphaInputMode);
|
|
167 |
edwin.SetAknEditorPermittedCaseModes(EAknEditorAllCaseModes);
|
|
168 |
edwin.SetAknEditorCase(EAknEditorLowerCase);
|
|
169 |
edwin.SetAknEditorCurrentCase(EAknEditorLowerCase);
|
|
170 |
sct = R_AVKON_EMAIL_ADDR_SPECIAL_CHARACTER_TABLE_DIALOG;
|
|
171 |
flags |= EEikEdwinNoLineOrParaBreaks|EAknEditorFlagNoT9;
|
|
172 |
//Adding Non Midlet Commands
|
|
173 |
HBufC* buffer = iCoeEnv->AllocReadResourceLC(R_EMAIL_COMMAND_TEXT);
|
|
174 |
TPtrC ptr = buffer->Des();
|
|
175 |
iMenuItem->SetTextL(ptr);
|
|
176 |
CleanupStack::PopAndDestroy(buffer);
|
|
177 |
}
|
|
178 |
else if (iTypeStyle & EUrl)
|
|
179 |
{
|
|
180 |
iMenu = CSwtControlMenu::NewL(iDisplay, NULL, 0);
|
|
181 |
iMenu->SetObserver(this);
|
|
182 |
iMenuItem = CSwtMenuItem::NewL(iDisplay, NULL, *iMenu, 0, 0, ESwtFetchUrl);
|
|
183 |
// Url type implementation
|
|
184 |
edwin.SetMaxLength(KSWTTEXTEXTENSION_URL_LENGTH);
|
|
185 |
edwin.SetAknEditorAllowedInputModes(EAknEditorAllInputModes);
|
|
186 |
edwin.SetAknEditorCurrentInputMode(EAknEditorAlphaInputMode);
|
|
187 |
edwin.SetAknEditorPermittedCaseModes(EAknEditorAllCaseModes);
|
|
188 |
edwin.SetAknEditorCase(EAknEditorLowerCase);
|
|
189 |
edwin.SetAknEditorCurrentCase(EAknEditorLowerCase);
|
|
190 |
sct = R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG;
|
|
191 |
flags |= EEikEdwinNoLineOrParaBreaks|EAknEditorFlagNoT9;
|
|
192 |
//Adding Non Midlet Commands
|
|
193 |
HBufC* buffer = iCoeEnv->AllocReadResourceLC(R_URL_COMMAND_TEXT);
|
|
194 |
TPtrC ptr = buffer->Des();
|
|
195 |
iMenuItem->SetTextL(ptr);
|
|
196 |
CleanupStack::PopAndDestroy(buffer);
|
|
197 |
}
|
|
198 |
|
|
199 |
if (iTypeStyle & ELatinInputOnly)
|
|
200 |
{
|
|
201 |
//LatinInputOnly type implementation
|
|
202 |
flags |= EAknEditorFlagLatinInputModesOnly;
|
|
203 |
}
|
|
204 |
|
|
205 |
if (iTypeStyle & ENonPredictive)
|
|
206 |
{
|
|
207 |
//NonPredictive type implementation
|
|
208 |
flags |= EAknEditorFlagNoT9;
|
|
209 |
}
|
|
210 |
|
|
211 |
#ifdef RD_SCALABLE_UI_V2
|
|
212 |
flags |= EAknEditorFlagDeliverVirtualKeyEventsToApplication;
|
|
213 |
#endif // RD_SCALABLE_UI_V2
|
|
214 |
|
|
215 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
216 |
flags |= EAknEditorFlagEnablePartialScreen;
|
|
217 |
#endif
|
|
218 |
|
|
219 |
edwin.SetAknEditorFlags(flags);
|
|
220 |
edwin.SetAknEditorSpecialCharacterTable(sct);
|
|
221 |
|
|
222 |
TRAP_IGNORE(edwin.NotifyEditorStateObserverOfStateChangeL());
|
|
223 |
}
|
|
224 |
|
|
225 |
|
|
226 |
// ---------------------------------------------------------------------------
|
|
227 |
// Handling non midlet menu commands
|
|
228 |
// ---------------------------------------------------------------------------
|
|
229 |
//
|
|
230 |
void CSwtTextExtension::ProcessCommandL(TInt aCmdId)
|
|
231 |
{
|
|
232 |
|
|
233 |
switch (aCmdId)
|
|
234 |
{
|
|
235 |
|
|
236 |
case ESwtFetchEmail:
|
|
237 |
FetchEmailL();// Fetching the Email address from the phone book
|
|
238 |
break;
|
|
239 |
|
|
240 |
case ESwtFetchUrl:
|
|
241 |
FetchUrlL();// Fetching URL from favourites
|
|
242 |
break;
|
|
243 |
|
|
244 |
default:
|
|
245 |
ASSERT(EFalse);
|
|
246 |
break;
|
|
247 |
}
|
|
248 |
}
|
|
249 |
|
|
250 |
|
|
251 |
// ---------------------------------------------------------------------------
|
|
252 |
// Return the control menu to the menu arranger
|
|
253 |
// ---------------------------------------------------------------------------
|
|
254 |
//
|
|
255 |
const MSwtMenu* CSwtTextExtension::GetControlMenu() const
|
|
256 |
{
|
|
257 |
if (iMenu)
|
|
258 |
{
|
|
259 |
return iMenu;
|
|
260 |
}
|
|
261 |
return ASwtControlBase::GetControlMenu();
|
|
262 |
}
|
|
263 |
|
|
264 |
|
|
265 |
#ifdef RD_SCALABLE_UI_V2
|
|
266 |
// ---------------------------------------------------------------------------
|
|
267 |
// Return the control menu for the stylus popup menu
|
|
268 |
// ---------------------------------------------------------------------------
|
|
269 |
//
|
|
270 |
const MSwtMenu* CSwtTextExtension::GetStylusPopupControlMenu() const
|
|
271 |
{
|
|
272 |
return GetControlMenu();
|
|
273 |
}
|
|
274 |
#endif //RD_SCALABLE_UI_V2
|
|
275 |
|
|
276 |
// ---------------------------------------------------------------------------
|
|
277 |
// Provides GUI that allows the user to select Email address from Phone Book
|
|
278 |
// and returns selected email id to the editor
|
|
279 |
// ---------------------------------------------------------------------------
|
|
280 |
//
|
|
281 |
void CSwtTextExtension::FetchEmailL()
|
|
282 |
{
|
|
283 |
// The dialog used to select the address doesn't work properly if there is no
|
|
284 |
// status pane. Therefore, the status pane is temporarily made visible for
|
|
285 |
// the duration of showing the dialog.
|
|
286 |
MSwtShell* shell = iDisplay.UiUtils().TopMostTopShell();
|
|
287 |
TBool fullScreenMode(EFalse);
|
|
288 |
MSwtShell::TSwtStatusPaneStyle statusPaneStyle;
|
|
289 |
MakeStatusPaneLargeL(shell, fullScreenMode, statusPaneStyle);
|
|
290 |
|
|
291 |
CPbkContactEngine* pbkContactEngine = CPbkContactEngine::NewL();
|
|
292 |
CleanupStack::PushL(pbkContactEngine);
|
|
293 |
RPbkViewResourceFile pbkResource(*iCoeEnv);
|
|
294 |
// Opening the default phone book
|
|
295 |
TBool isOpen = EFalse;
|
|
296 |
if (!pbkResource.IsOpen())
|
|
297 |
{
|
|
298 |
pbkResource.OpenL();
|
|
299 |
isOpen = ETrue;
|
|
300 |
}
|
|
301 |
// Filtering phone book items which have email address
|
|
302 |
CContactDatabase::TContactViewFilter filter(CContactDatabase::EMailable);
|
|
303 |
CPbkSingleEntryFetchDlg::TParams params;
|
|
304 |
params.iContactView = &pbkContactEngine->FilteredContactsViewL(filter);
|
|
305 |
//Construct the dialog with filtered parameters
|
|
306 |
CPbkSingleEntryFetchDlg* fetchDialog = CPbkSingleEntryFetchDlg::NewL(params);
|
|
307 |
CleanupStack::PushL(fetchDialog);
|
|
308 |
fetchDialog->SetMopParent(this);
|
|
309 |
// Executes the dialog and waits for user selection
|
|
310 |
TInt selection = fetchDialog->ExecuteLD();
|
|
311 |
CleanupStack::Pop(fetchDialog);
|
|
312 |
if (selection)
|
|
313 |
{
|
|
314 |
//Retrieving the user selected email address
|
|
315 |
const TContactItemId contactItemId = params.iSelectedEntry;
|
|
316 |
CPbkContactItem* pbkItem = pbkContactEngine->ReadContactLC(contactItemId);
|
|
317 |
TPbkContactItemField* emailField = pbkItem->FindField(EPbkFieldIdEmailAddress);
|
|
318 |
TPtrC ptr = emailField->Text();
|
|
319 |
Editor().SetTextL(&ptr); // assigning email address to editor
|
|
320 |
Editor().HandleTextChangedL();
|
|
321 |
CleanupStack::PopAndDestroy(pbkItem);
|
|
322 |
}
|
|
323 |
if (isOpen)
|
|
324 |
{
|
|
325 |
pbkResource.Close();
|
|
326 |
}
|
|
327 |
CleanupStack::PopAndDestroy(pbkContactEngine);
|
|
328 |
|
|
329 |
// Restore the original status pane style and fullscreenmode state
|
|
330 |
RestoreStatusPaneL(shell, fullScreenMode, statusPaneStyle);
|
|
331 |
}
|
|
332 |
|
|
333 |
|
|
334 |
// ---------------------------------------------------------------------------
|
|
335 |
// Provides GUI that allows the user to select URL from Favourites Database
|
|
336 |
// and returns selected Bookmarked URL to the editor
|
|
337 |
// ---------------------------------------------------------------------------
|
|
338 |
//
|
|
339 |
void CSwtTextExtension::FetchUrlL()
|
|
340 |
{
|
|
341 |
// The dialog used to select the url doesn't work properly if there is no
|
|
342 |
// status pane. Therefore, the status pane is temporarily made visible for
|
|
343 |
// the duration of showing the dialog.
|
|
344 |
MSwtShell* shell = iDisplay.UiUtils().TopMostTopShell();
|
|
345 |
TBool fullScreenMode(EFalse);
|
|
346 |
MSwtShell::TSwtStatusPaneStyle statusPaneStyle;
|
|
347 |
MakeStatusPaneLargeL(shell, fullScreenMode, statusPaneStyle);
|
|
348 |
|
|
349 |
RFavouritesSession favouritesSession;
|
|
350 |
User::LeaveIfError(favouritesSession.Connect());
|
|
351 |
CleanupClosePushL<RFavouritesSession>(favouritesSession);
|
|
352 |
|
|
353 |
// Opening the Favourites Database
|
|
354 |
RFavouritesDb favouritesDb;
|
|
355 |
TInt error(favouritesDb.Open(favouritesSession, KBrowserBookmarks));
|
|
356 |
if (!error)
|
|
357 |
{
|
|
358 |
CleanupClosePushL<RFavouritesDb>(favouritesDb);
|
|
359 |
CFavouritesItemList* favouriteItemsList = new(ELeave) CFavouritesItemList();
|
|
360 |
CleanupStack::PushL(favouriteItemsList);
|
|
361 |
|
|
362 |
// Retrieving the items which have URL address into the items list
|
|
363 |
User::LeaveIfError(favouritesDb.GetAll(*favouriteItemsList,
|
|
364 |
KFavouritesNullUid,
|
|
365 |
CFavouritesItem::EItem,
|
|
366 |
NULL,
|
|
367 |
KFavouritesNullContextId));
|
|
368 |
TInt itemsCount = favouriteItemsList->Count();
|
|
369 |
favouriteItemsList->SortL(&CompareItemsByNameL); // Sorting the items by name
|
|
370 |
|
|
371 |
// Defining the array with the size equals to the number of items retrieved
|
|
372 |
CDesCArrayFlat* arrayList = new(ELeave) CDesCArrayFlat(
|
|
373 |
itemsCount ? itemsCount : 1);
|
|
374 |
|
|
375 |
CleanupStack::PushL(arrayList);
|
|
376 |
for (TInt i = 0; i < itemsCount; i++)
|
|
377 |
{
|
|
378 |
// Adding items to the array
|
|
379 |
const TInt size(((favouriteItemsList->At(i))->Name()).Length());
|
|
380 |
HBufC* name = HBufC::NewLC(size + 1);
|
|
381 |
name->Des().Append(KTAB);
|
|
382 |
name->Des().Append((favouriteItemsList->At(i))->Name());
|
|
383 |
arrayList->AppendL(*name);
|
|
384 |
CleanupStack::PopAndDestroy(name);
|
|
385 |
}
|
|
386 |
TInt selectedItem(0); // Default selected item
|
|
387 |
CAknSelectionListDialog* selectionListDialog =
|
|
388 |
CAknSelectionListDialog::NewL(selectedItem, arrayList, 0);
|
|
389 |
|
|
390 |
// Constructing the dialog from the resource
|
|
391 |
selectionListDialog->PrepareLC(R_SELECTION_LIST_DIALOG);
|
|
392 |
selectionListDialog->SetMopParent(this);
|
|
393 |
|
|
394 |
// Getting pointer to the AppUi's status pane
|
|
395 |
CEikStatusPane* statusPane = iAvkonAppUi->StatusPane();
|
|
396 |
|
|
397 |
// Setting the dialog title to the title pane
|
|
398 |
CAknNavigationControlContainer* naviContainer =
|
|
399 |
static_cast<CAknNavigationControlContainer*>(statusPane->ControlL(
|
|
400 |
TUid::Uid(EEikStatusPaneUidNavi)));
|
|
401 |
HBufC* buffer = iCoeEnv->AllocReadResourceLC(R_TITLEPANE_TITLE);
|
|
402 |
TPtrC ptr = buffer->Des();
|
|
403 |
if (iNaviDecorator)
|
|
404 |
{
|
|
405 |
delete iNaviDecorator;
|
|
406 |
iNaviDecorator = NULL;
|
|
407 |
}
|
|
408 |
iNaviDecorator = naviContainer->CreateMessageLabelL(ptr);
|
|
409 |
CleanupStack::PopAndDestroy(buffer);
|
|
410 |
|
|
411 |
// Newly created navigation decorator onto the navigation panes object stack
|
|
412 |
naviContainer->PushL(*iNaviDecorator);
|
|
413 |
|
|
414 |
TInt selection(selectionListDialog->RunLD()); // pops the dialog from cleanupstack
|
|
415 |
if (selection)
|
|
416 |
{
|
|
417 |
// Setting selected url to editor
|
|
418 |
if (selectedItem >= 0)
|
|
419 |
{
|
|
420 |
TPtrC itemPtr((favouriteItemsList->At(selectedItem))->Url());
|
|
421 |
Editor().SetTextL(&itemPtr);
|
|
422 |
Editor().HandleTextChangedL();
|
|
423 |
}
|
|
424 |
}
|
|
425 |
|
|
426 |
CleanupStack::PopAndDestroy(arrayList);
|
|
427 |
CleanupStack::PopAndDestroy(favouriteItemsList);
|
|
428 |
CleanupStack::PopAndDestroy(&favouritesDb);
|
|
429 |
}
|
|
430 |
CleanupStack::PopAndDestroy(&favouritesSession);
|
|
431 |
|
|
432 |
// Restore the original status pane style and fullscreenmode state
|
|
433 |
RestoreStatusPaneL(shell, fullScreenMode, statusPaneStyle);
|
|
434 |
}
|
|
435 |
|
|
436 |
|
|
437 |
// ---------------------------------------------------------------------------
|
|
438 |
// Sets input language and character subset
|
|
439 |
// ---------------------------------------------------------------------------
|
|
440 |
//
|
|
441 |
void CSwtTextExtension::SetInitialInputModeL(TCasingModifier aCasingModifier, const TDesC* aMode)
|
|
442 |
{
|
|
443 |
iInitialCurrentCase = 0;
|
|
444 |
switch (aCasingModifier)
|
|
445 |
{
|
|
446 |
case ELowerCase:
|
|
447 |
iInitialCurrentCase = EAknEditorLowerCase;
|
|
448 |
break;
|
|
449 |
case EUpperCase:
|
|
450 |
iInitialCurrentCase = EAknEditorUpperCase ;
|
|
451 |
break;
|
|
452 |
case ETitleCase://Fall-through
|
|
453 |
case ETextCase:
|
|
454 |
iInitialCurrentCase = EAknEditorTextCase ;
|
|
455 |
break;
|
|
456 |
default:
|
|
457 |
iInitialCurrentCase = EAknEditorAllCaseModes;
|
|
458 |
break;
|
|
459 |
}
|
|
460 |
|
|
461 |
iInitialCurrentInputMode = 0;
|
|
462 |
iInitialCurrentLanguage = ELangTest; // 0
|
|
463 |
if (aMode)
|
|
464 |
{
|
|
465 |
HBufC* mode = aMode->AllocLC();
|
|
466 |
if (mode->Compare(KUcbBasicLatin) == 0 || mode->Compare(KIsLatin) == 0)
|
|
467 |
{
|
|
468 |
// UCB_BASIC_LATIN, IS_LATIN
|
|
469 |
iInitialCurrentLanguage = SelectLanguage(EIsLatin,ELangEnglish);
|
|
470 |
iInitialCurrentInputMode = EAknEditorTextInputMode;
|
|
471 |
|
|
472 |
}
|
|
473 |
else if (mode->Compare(KIsLatinDigits) == 0)
|
|
474 |
{
|
|
475 |
// IS_LATIN_DIGITS
|
|
476 |
iInitialCurrentInputMode = EAknEditorNumericInputMode;
|
|
477 |
}
|
|
478 |
else if (mode->Compare(KUcbArabic) == 0)
|
|
479 |
{
|
|
480 |
// UCB_ARABIC
|
|
481 |
iInitialCurrentLanguage = ELangArabic;
|
|
482 |
}
|
|
483 |
else if (mode->Compare(KUcbHebrew) == 0)
|
|
484 |
{
|
|
485 |
// UCB_HEBREW
|
|
486 |
iInitialCurrentLanguage = ELangHebrew;
|
|
487 |
}
|
|
488 |
else if (mode->Compare(KUcbGreek) == 0)
|
|
489 |
{
|
|
490 |
// UCB_GREEK
|
|
491 |
iInitialCurrentLanguage = ELangGreek;
|
|
492 |
iInitialCurrentCase = EAknEditorTextCase;
|
|
493 |
}
|
|
494 |
else if (mode->Compare(KUcbThai) == 0)
|
|
495 |
{
|
|
496 |
// UCB_THAI
|
|
497 |
#ifdef KFeatureIdThai
|
|
498 |
if (CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdThai))
|
|
499 |
{
|
|
500 |
iInitialCurrentLanguage = ELangThai;
|
|
501 |
}
|
|
502 |
#endif // KFeatureIdThai
|
|
503 |
}
|
|
504 |
else if (mode->Compare(KIsSimplifiedHanzi) == 0)
|
|
505 |
{
|
|
506 |
// IS_SIMPLIIFED_HANZI
|
|
507 |
#ifdef KFeatureIdChinese
|
|
508 |
if (CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdChinese))
|
|
509 |
{
|
|
510 |
iInitialCurrentLanguage = ELangPrcChinese;
|
|
511 |
}
|
|
512 |
#endif // KFeatureIdChinese
|
|
513 |
}
|
|
514 |
else if (mode->Compare(KUcbKatakana) == 0)
|
|
515 |
{
|
|
516 |
// UCB_KATAKANA
|
|
517 |
#ifdef KFeatureIdJapanese
|
|
518 |
if (CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdJapanese))
|
|
519 |
{
|
|
520 |
iInitialCurrentLanguage = ELangJapanese;
|
|
521 |
iInitialCurrentInputMode = EAknEditorFullWidthKatakanaInputMode;
|
|
522 |
}
|
|
523 |
#endif // KFeatureIdJapanese
|
|
524 |
}
|
|
525 |
else if (mode->Compare(KUcbHiragana) == 0 || mode->Compare(KIsKanji) == 0)
|
|
526 |
{
|
|
527 |
// UCB_HIRAGANA, IS_KANJI
|
|
528 |
#ifdef KFeatureIdJapanese
|
|
529 |
if (CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdJapanese))
|
|
530 |
{
|
|
531 |
iInitialCurrentLanguage = ELangJapanese;
|
|
532 |
iInitialCurrentInputMode = EAknEditorHiraganaKanjiInputMode;
|
|
533 |
}
|
|
534 |
#endif // KFeatureIdJapanese
|
|
535 |
}
|
|
536 |
else if (mode->Compare(KUcbHangulSyllables) == 0 || mode->Compare(KIsHanja) == 0)
|
|
537 |
{
|
|
538 |
// UCB_HANGUL_SYLLABLES, IS_HANJA
|
|
539 |
iInitialCurrentLanguage = ELangKorean;
|
|
540 |
|
|
541 |
}
|
|
542 |
else if (mode->Compare(KIsTraditionalHanzi) == 0)
|
|
543 |
{
|
|
544 |
//IS_TRADITIONAL_HANZI
|
|
545 |
#ifdef KFeatureIdChinese
|
|
546 |
if (CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdChinese))
|
|
547 |
{
|
|
548 |
iInitialCurrentLanguage = SelectLanguage(
|
|
549 |
EIsTraditionalHanzi, ELangTest);
|
|
550 |
}
|
|
551 |
#endif // KFeatureIdChinese
|
|
552 |
}
|
|
553 |
else if (mode->Compare(KUcbDevanagari) == 0)
|
|
554 |
{
|
|
555 |
//UCB_DEVANAGARI
|
|
556 |
iInitialCurrentLanguage = ELangHindi;
|
|
557 |
}
|
|
558 |
else if (mode->Compare(KUcbBengali) == 0)
|
|
559 |
{
|
|
560 |
//UCB_BENGALI
|
|
561 |
iInitialCurrentLanguage = ELangBengali;
|
|
562 |
}
|
|
563 |
else if (mode->Compare(KUcbArmenian) == 0)
|
|
564 |
{
|
|
565 |
//UCB_ARMENIAN
|
|
566 |
iInitialCurrentLanguage = ELangArmenian;
|
|
567 |
}
|
|
568 |
else if (mode->Compare(KUcbCyrillic) == 0)
|
|
569 |
{
|
|
570 |
//UCB_CYRILLIC
|
|
571 |
iInitialCurrentLanguage = SelectLanguage(EUcbCyrillic, ELangRussian);
|
|
572 |
iInitialCurrentCase = EAknEditorTextCase;
|
|
573 |
}
|
|
574 |
|
|
575 |
else if (mode->Compare(KIsHalfwidthKatakana) == 0)
|
|
576 |
{
|
|
577 |
// IS_HALFWIDTH_KATAKANA
|
|
578 |
#ifdef KFeatureIdJapanese
|
|
579 |
if (CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdJapanese))
|
|
580 |
{
|
|
581 |
iInitialCurrentLanguage = ELangJapanese;
|
|
582 |
iInitialCurrentInputMode = EAknEditorKatakanaInputMode;
|
|
583 |
}
|
|
584 |
#endif // KFeatureIdJapanese
|
|
585 |
}
|
|
586 |
else if (mode->Compare(KIsFullwidthDigits) == 0)
|
|
587 |
{
|
|
588 |
// IS_FULLWIDTH_DIGITS
|
|
589 |
#ifdef KFeatureIdJapanese
|
|
590 |
if (CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdJapanese))
|
|
591 |
{
|
|
592 |
iInitialCurrentLanguage = ELangJapanese;
|
|
593 |
iInitialCurrentInputMode = EAknEditorFullWidthNumericInputMode;
|
|
594 |
}
|
|
595 |
#endif // KFeatureIdJapanese
|
|
596 |
}
|
|
597 |
else if (mode->Compare(KIsFullwidthLatin) == 0)
|
|
598 |
{
|
|
599 |
// IS_FULLWIDTH_DIGITS
|
|
600 |
#ifdef KFeatureIdJapanese
|
|
601 |
if (CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdJapanese))
|
|
602 |
{
|
|
603 |
iInitialCurrentLanguage = ELangJapanese;
|
|
604 |
iInitialCurrentInputMode = EAknEditorFullWidthTextInputMode;
|
|
605 |
}
|
|
606 |
#endif // KFeatureIdJapanese
|
|
607 |
}
|
|
608 |
CleanupStack::PopAndDestroy(mode); //mode
|
|
609 |
}
|
|
610 |
else
|
|
611 |
{
|
|
612 |
iInitialCurrentLanguage = CSwtLafFacade::GetLanguage();
|
|
613 |
}
|
|
614 |
}
|
|
615 |
|
|
616 |
|
|
617 |
// ---------------------------------------------------------------------------
|
|
618 |
// Returns an intial input language for a given character subset.
|
|
619 |
// If the global input language or the display language belong to the desired
|
|
620 |
// character set, that language is returned as the initial input language.
|
|
621 |
// Otherwise the given default language is returned. Note that this method
|
|
622 |
// is only used for character sets that contain more than one language.
|
|
623 |
// ---------------------------------------------------------------------------
|
|
624 |
//
|
|
625 |
TLanguage CSwtTextExtension::SelectLanguage(
|
|
626 |
TInt aCharSubset,
|
|
627 |
TLanguage aDefaultLanguage)
|
|
628 |
{
|
|
629 |
TLanguage language = CSwtLafFacade::GetLanguage();
|
|
630 |
if (IsLanguageInCharSubset(language, aCharSubset))
|
|
631 |
{
|
|
632 |
return language; // global input language
|
|
633 |
}
|
|
634 |
language = User::Language();
|
|
635 |
if (IsLanguageInCharSubset(language, aCharSubset))
|
|
636 |
{
|
|
637 |
return language; // display language
|
|
638 |
}
|
|
639 |
return aDefaultLanguage; // given default
|
|
640 |
}
|
|
641 |
|
|
642 |
|
|
643 |
// ---------------------------------------------------------------------------
|
|
644 |
// Returns ETrue if the given language belongs to the given character subset
|
|
645 |
// ---------------------------------------------------------------------------
|
|
646 |
//
|
|
647 |
TBool CSwtTextExtension::IsLanguageInCharSubset(TLanguage aLanguage, TInt aCharSubset)
|
|
648 |
{
|
|
649 |
switch (aLanguage)
|
|
650 |
{
|
|
651 |
// Cyrillic languages:
|
|
652 |
case ELangBulgarian:
|
|
653 |
case ELangRussian:
|
|
654 |
case ELangSerbian:
|
|
655 |
case ELangUkrainian:
|
|
656 |
return (aCharSubset == EUcbCyrillic);
|
|
657 |
// Arabic languages:
|
|
658 |
case ELangArabic:
|
|
659 |
case ELangFarsi:
|
|
660 |
case ELangUrdu:
|
|
661 |
return(aCharSubset == EUcbArabic);
|
|
662 |
// Traditi onal Chinese languages, support latin, too:
|
|
663 |
case ELangTaiwanChinese:
|
|
664 |
case ELangHongKongChinese:
|
|
665 |
return (aCharSubset == EIsTraditionalHanzi ||
|
|
666 |
aCharSubset == EIsLatin);
|
|
667 |
// Single languages that belong to other character subsets than latin
|
|
668 |
case ELangHebrew:
|
|
669 |
case ELangGreek:
|
|
670 |
case ELangHindi:
|
|
671 |
case ELangVietnamese:
|
|
672 |
case ELangThai:
|
|
673 |
case ELangBengali:
|
|
674 |
return (aCharSubset == ECharSubsetNone);
|
|
675 |
// All the rest are latin languages; Japanese and Simplified Chinese
|
|
676 |
// included here, because they support latin, too
|
|
677 |
default:
|
|
678 |
return (aCharSubset == EIsLatin);
|
|
679 |
}
|
|
680 |
}
|
|
681 |
|
|
682 |
|
|
683 |
// =========================== VIRTUAL FUNCTIONS =============================
|
|
684 |
|
|
685 |
// ---------------------------------------------------------------------------
|
|
686 |
// Virtual methods from ASwtControlBase
|
|
687 |
// Sets the Focus
|
|
688 |
// This is where the inputMode will be set (if needed).
|
|
689 |
// ---------------------------------------------------------------------------
|
|
690 |
//
|
|
691 |
void CSwtTextExtension::FocusChanged(TDrawNow aDrawNow)
|
|
692 |
{
|
|
693 |
if (iInitialCurrentLanguage)
|
|
694 |
{
|
|
695 |
Editor().SetAknEditorLocalLanguage(iInitialCurrentLanguage);
|
|
696 |
if (iInitialCurrentInputMode == 0)
|
|
697 |
{
|
|
698 |
// clears any number mode used previously
|
|
699 |
Editor().SetAknEditorCurrentInputMode(EAknEditorNullInputMode);
|
|
700 |
}
|
|
701 |
}
|
|
702 |
|
|
703 |
if (iInitialCurrentInputMode)
|
|
704 |
{
|
|
705 |
Editor().SetAknEditorCurrentInputMode(iInitialCurrentInputMode);
|
|
706 |
}
|
|
707 |
|
|
708 |
if (iInitialCurrentCase)
|
|
709 |
{
|
|
710 |
TInt initialCurrentCase = iInitialCurrentCase;
|
|
711 |
if ((iStyle & KSwtStylePassword ||
|
|
712 |
iTypeStyle & EEmailAddress ||
|
|
713 |
iTypeStyle & EUrl) &&
|
|
714 |
iInitialCurrentCase == EAknEditorTextCase)
|
|
715 |
{
|
|
716 |
// Text case is not used in passwords, emailaddrs and urls
|
|
717 |
initialCurrentCase = EAknEditorLowerCase;
|
|
718 |
}
|
|
719 |
Editor().SetAknEditorCurrentCase(initialCurrentCase);
|
|
720 |
Editor().SetAknEditorCase(initialCurrentCase);
|
|
721 |
}
|
|
722 |
CSwtTextBase::FocusChanged(aDrawNow);
|
|
723 |
}
|
|
724 |
|
|
725 |
|
|
726 |
// ---------------------------------------------------------------------------
|
|
727 |
// Virtual methods from MSwtTextExtension
|
|
728 |
// ---------------------------------------------------------------------------
|
|
729 |
//
|
|
730 |
MSwtText* CSwtTextExtension::Text()
|
|
731 |
{
|
|
732 |
return this;
|
|
733 |
}
|
|
734 |
|
|
735 |
|
|
736 |
// ---------------------------------------------------------------------------
|
|
737 |
// CSwtTextExtension::MakeStatusPaneLargeL
|
|
738 |
// This is only needed because the dialogs don't work unless status pane
|
|
739 |
// is certain size.
|
|
740 |
// ---------------------------------------------------------------------------
|
|
741 |
//
|
|
742 |
void CSwtTextExtension::MakeStatusPaneLargeL(MSwtShell* aShell,
|
|
743 |
TBool& aFullScreenMode,
|
|
744 |
MSwtShell::TSwtStatusPaneStyle& aStyle)
|
|
745 |
{
|
|
746 |
if (aShell)
|
|
747 |
{
|
|
748 |
aStyle = aShell->StatusPaneStyle();
|
|
749 |
if (aStyle != MSwtShell::EStyleLargeStatusPane)
|
|
750 |
{
|
|
751 |
MSwtMobileShell* mobileShell = aShell->MobileShellInterface();
|
|
752 |
ASSERT(mobileShell);
|
|
753 |
// Also FullScreenMode has to be temporarily disabled because setting status
|
|
754 |
// pane style doesn't have any effect otherwise.
|
|
755 |
aFullScreenMode = aShell->FullScreenMode();
|
|
756 |
if (aFullScreenMode)
|
|
757 |
{
|
|
758 |
aShell->SetFullScreen(EFalse);
|
|
759 |
}
|
|
760 |
mobileShell->ChangeTrimL(aShell->Control()->Style(),
|
|
761 |
MSwtShell::EStyleLargeStatusPane);
|
|
762 |
}
|
|
763 |
}
|
|
764 |
}
|
|
765 |
|
|
766 |
|
|
767 |
// ---------------------------------------------------------------------------
|
|
768 |
// CSwtTextExtension::RestoreStatusPaneL
|
|
769 |
// ---------------------------------------------------------------------------
|
|
770 |
//
|
|
771 |
void CSwtTextExtension::RestoreStatusPaneL(MSwtShell* aShell,
|
|
772 |
const TBool& aFullScreenMode,
|
|
773 |
const MSwtShell::TSwtStatusPaneStyle& aStyle)
|
|
774 |
{
|
|
775 |
if (aShell)
|
|
776 |
{
|
|
777 |
if (aFullScreenMode)
|
|
778 |
{
|
|
779 |
aShell->SetFullScreen(ETrue);
|
|
780 |
}
|
|
781 |
if (aStyle != MSwtShell::EStyleLargeStatusPane)
|
|
782 |
{
|
|
783 |
MSwtMobileShell* mobileShell = aShell->MobileShellInterface();
|
|
784 |
if (mobileShell)
|
|
785 |
{
|
|
786 |
mobileShell->ChangeTrimL(aShell->Control()->Style(), aStyle);
|
|
787 |
}
|
|
788 |
}
|
|
789 |
}
|
|
790 |
}
|