|
1 /* |
|
2 * Copyright (c) 2002 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 Notepad/Template Editor mode. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <aknappui.h> |
|
21 #include <avkon.hrh> |
|
22 #include <eikmenub.h> |
|
23 #include <txtglobl.h> |
|
24 #include <AknForm.h> |
|
25 #include <aknnotedialog.h> |
|
26 #include <aknkeys.h> |
|
27 #include <eikapp.h> |
|
28 #include <eikedwob.h> |
|
29 #include <aknnotewrappers.h> |
|
30 #include <AknUtils.h> |
|
31 #include <barsread.h> |
|
32 #include <sendui.h> |
|
33 #include <Sendnorm.rsg> |
|
34 #include <hlplch.h> |
|
35 #include <featmgr.h> |
|
36 #include <NpdLib.rsg> |
|
37 #include "NpdLib.hrh" |
|
38 #include <txtrich.h> |
|
39 #include <StringLoader.h> |
|
40 #include <AvkonInternalCRKeys.h> |
|
41 #include <e32keys.h> |
|
42 #include <finditemengine.h> |
|
43 #include <finditemmenu.h> |
|
44 #include <finditemdialog.h> |
|
45 #include <FindItemmenu.rsg> |
|
46 |
|
47 #include <csxhelp/nmake.hlp.hrh> |
|
48 |
|
49 #include "NpdEdwin.h" |
|
50 #include "NpdEditorDialog.h" |
|
51 #include "NpdDialogBase.h" |
|
52 #include "NpdListDialog.h" |
|
53 #include "NpdModel_platsec.h" |
|
54 #include "NpdApi.h" |
|
55 #include "NpdLib.h" |
|
56 #include "NpdEdwinLines.h" |
|
57 #include "NpdLibPanic.h" |
|
58 |
|
59 // CONSTANTS |
|
60 const TInt KNotepadSequenceGranularity(10); |
|
61 const TInt KNotepadInvalidSequenceIndex(-1); |
|
62 //0x21b2 is the linefeed character |
|
63 //const TChar linefeed(0x21B2); |
|
64 // ============================ MEMBER FUNCTIONS =============================== |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CNotepadEditorDialog::NewL |
|
68 // Constructor. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 EXPORT_C CNotepadEditorDialog* CNotepadEditorDialog::NewL( |
|
72 TInt aResId, |
|
73 CNotepadModel* aModel, |
|
74 CNotepadListDialog* aListDialog, |
|
75 CSendUi* aSendUi |
|
76 ) |
|
77 { |
|
78 __ASSERT_DEBUG(aModel, Panic(ENotepadLibraryPanicNoModel)); |
|
79 |
|
80 CNotepadEditorDialog* self = |
|
81 new(ELeave) CNotepadEditorDialog(*aModel, aListDialog); |
|
82 CleanupStack::PushL(self); |
|
83 TResourceReader rr; |
|
84 self->iCoeEnv->CreateResourceReaderLC(rr, aResId); // Push rr |
|
85 self->ConstructL( rr ); |
|
86 CleanupStack::PopAndDestroy(); // rr |
|
87 CleanupStack::Pop(); // self |
|
88 self->iSendUi = aSendUi; |
|
89 return self; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CNotepadEditorDialog::ConstructL |
|
94 // private second-phase constructor |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CNotepadEditorDialog::ConstructL( TResourceReader& aReader) |
|
98 { |
|
99 CNotepadDialogBase::ConstructL( aReader ); // menubar, dialog |
|
100 TPtrC ptr = aReader.ReadTPtrC(); |
|
101 if ( ptr.Length() ) |
|
102 { |
|
103 SetTitleL(&ptr); // LTEXT title |
|
104 } |
|
105 iModel.SetNotepadModelObserver(this); |
|
106 iFindItemMenu = CFindItemMenu::NewL(ENotepadCmdFind); |
|
107 iRedrawBackground = EFalse; |
|
108 iTaskSwapperFlag=EFalse; |
|
109 User::LeaveIfError(iQwertyModeStatusProperty.Attach(KCRUidAvkon, KAknQwertyInputModeActive)); |
|
110 if ( FeatureManager::FeatureSupported( KFeatureIdFfEnablePrintingFramework ) ) |
|
111 { |
|
112 iServiceHandler = CAiwServiceHandler::NewL(); |
|
113 iServiceHandler->AttachMenuL( R_NOTEPAD_EDITOR_MENU, R_PS_AIW_INTEREST ); |
|
114 } |
|
115 } |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CNotepadEditorDialog::~CNotepadEditorDialog |
|
118 // Destructor |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 EXPORT_C CNotepadEditorDialog::~CNotepadEditorDialog() |
|
122 { |
|
123 if ( iEditor ) |
|
124 { |
|
125 iEditor->CancelFepTransaction(); |
|
126 } |
|
127 if ( iListDialog ) |
|
128 { |
|
129 iListDialog->EditorDeleted(); |
|
130 } |
|
131 delete iSequence; |
|
132 delete iIdle; |
|
133 delete iFindItemMenu; |
|
134 delete iServiceHandler; |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CNotepadEditorDialog::ExecuteLD |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 EXPORT_C TInt CNotepadEditorDialog::ExecuteLD() |
|
142 { |
|
143 CleanupStack::PushL(this); |
|
144 CreateSequenceL(); |
|
145 CleanupStack::Pop(); // this |
|
146 return CNotepadDialogBase::ExecuteLD(); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CNotepadEditorDialog::SwitchTextL |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CNotepadEditorDialog::SwitchTextL(TInt aKey) |
|
154 { |
|
155 TInt err(KErrNone); |
|
156 __ASSERT_DEBUG( iEditor, Panic(ENotepadLibraryPanicNoEdwin) ); |
|
157 if ( iModel.SeekKey(aKey) != 0 ) // not found |
|
158 { |
|
159 aKey = KNotepadPseudoKeyIdForNewNote; |
|
160 } |
|
161 TRAP(err, |
|
162 iEditor->ClearSelectionL(); |
|
163 iEditor->Text()->Reset(); |
|
164 iEditor->HandleTextChangedL(); |
|
165 iEditor->SetCursorPosL(0, EFalse); |
|
166 if ( aKey != KNotepadPseudoKeyIdForNewNote ) |
|
167 { |
|
168 HBufC* text = iModel.ContentByKeyL(aKey); |
|
169 CleanupStack::PushL(text); |
|
170 iEditor->SetTextL(text); |
|
171 CleanupStack::PopAndDestroy(); // text |
|
172 } |
|
173 else |
|
174 { |
|
175 |
|
176 iEditor->NotifyNewFormatL(); |
|
177 } |
|
178 iEditor->SetCursorPosL(0,EFalse); |
|
179 ); |
|
180 if (err != KErrNone) |
|
181 { |
|
182 delete(this); |
|
183 User::Leave(err); |
|
184 } |
|
185 iKey = aKey; // set after switching is succeeded (important) |
|
186 if (iRedrawBackground) |
|
187 { |
|
188 iEditor->HandleResourceChange(KEikDynamicLayoutVariantSwitch); |
|
189 iEditor->SetBackgroundColorL(); |
|
190 iRedrawBackground = EFalse; |
|
191 } |
|
192 iEditor->Text()->SetHasChanged(EFalse); |
|
193 iEditor->DrawDeferred(); |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CNotepadEditorDialog::SaveOnExitL |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 TInt CNotepadEditorDialog::SaveOnExitL( |
|
201 TBool aNeedListRefresh ) |
|
202 { |
|
203 TBool doSave( ( IsModeAdding() && !IsEmpty() ) || |
|
204 ( IsModeEditing() && iEditor->Text()->HasChanged() ) ); |
|
205 TInt statOfSave(CNotepadModel::ENotepadModelRowNop); |
|
206 TInt returnKey( iKey ); |
|
207 iFlags &= ~ENotepadCatchSaveOnExitCallback; |
|
208 if ( doSave ) |
|
209 { |
|
210 const TInt savedNextKey( NextKeyInSequence() ); |
|
211 statOfSave = SaveL(); |
|
212 returnKey = ( statOfSave == CNotepadModel::ENotepadModelRowDeleted ) ? |
|
213 savedNextKey : iKey; |
|
214 } |
|
215 if ( aNeedListRefresh ) |
|
216 { |
|
217 iListDialog->HandleEditorExitL( statOfSave, returnKey, |
|
218 statOfSave != CNotepadModel::ENotepadModelRowNop || |
|
219 iFlags & ENotepadCatchSaveOnExitCallback ); |
|
220 } |
|
221 return statOfSave; |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CNotepadEditorDialog::EditByKeyL |
|
226 // This case is caused by Pinboard. |
|
227 // If a pinned memo is selected by Pinboard while Notepad is |
|
228 // running in editor mode, we must change iEditorDialog's content |
|
229 // instead of creating new EditorDialog. |
|
230 // |
|
231 // we don't need to save/switchtext if required memo is |
|
232 // equivalent to the memo now being edited (ie. aKey == iKey) |
|
233 // |
|
234 // The editor did not work well after following operation: |
|
235 // 1. Launch Notepad |
|
236 // 2. Open a certain memo to switch into editor mode |
|
237 // 3. Press application key to return shell |
|
238 // 4. Launch Pinboard |
|
239 // 5. Select "Write a note" |
|
240 // then, no cursor will be displayed, numeric keys not work. |
|
241 // We can fix this by adding: |
|
242 // iBaseAppUi->UpdateStackedControlFlags(iEditorDialog, 0, ~0); |
|
243 // to this function. |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 void CNotepadEditorDialog::EditByKeyL(const TInt aKey, CAknAppUi& aAppUi) |
|
247 { |
|
248 if ( aKey == KNotepadPseudoKeyIdForNewNote // Pinboard "Write a Note" |
|
249 || aKey != iKey ) |
|
250 { |
|
251 SaveL(); |
|
252 SwitchTextL(aKey); |
|
253 } |
|
254 aAppUi.UpdateStackedControlFlags(this, 0, ~0); |
|
255 DrawNow(); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CNotepadEditorDialog::SetInitialKeyEventL |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 void CNotepadEditorDialog::SetInitialKeyEventL(const TKeyEvent& aKeyEvent) |
|
263 { |
|
264 iEvent = aKeyEvent; |
|
265 delete iIdle; |
|
266 iIdle = NULL; |
|
267 iIdle = CIdle::NewL(CActive::EPriorityUserInput); |
|
268 iIdle->Start(TCallBack(NumberKeyCallBack, this)); |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CNotepadEditorDialog::HandleNotepadModelEventL |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 void CNotepadEditorDialog::HandleNotepadModelEventL( |
|
276 TEvent aEvent, |
|
277 TInt /*aParam*/ ) |
|
278 { |
|
279 switch ( aEvent ) |
|
280 { |
|
281 case EDatabaseChanged: |
|
282 iFlags |= ENotepadCatchSaveOnExitCallback; |
|
283 if ( (iModel.ItemArrayFlags()) & CNotepadModel::ENotepadItemArrayUpdateOnly ) |
|
284 { |
|
285 iModel.SyncL(EFalse); |
|
286 } |
|
287 if ( iStoreWait.IsStarted() ) |
|
288 { |
|
289 iStoreWait.AsyncStop(); |
|
290 } |
|
291 break; |
|
292 case ECompleteItemArrayChange: |
|
293 SyncSequenceL(ETrue); |
|
294 break; |
|
295 default: |
|
296 break; |
|
297 } |
|
298 } |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // CNotepadEditorDialog::DynInitMenuPaneL |
|
302 // from MEikMenuObserver |
|
303 // ----------------------------------------------------------------------------- |
|
304 // |
|
305 void CNotepadEditorDialog::DynInitMenuPaneL( |
|
306 TInt aResourceId, |
|
307 CEikMenuPane* aMenuPane) |
|
308 { |
|
309 __ASSERT_DEBUG(aResourceId > 0, Panic(ENotepadLibraryPanicNoMenuResource)); |
|
310 __ASSERT_DEBUG(aMenuPane, Panic(ENotepadLibraryPanicNullMenuPane)); |
|
311 __ASSERT_DEBUG(iEditor, Panic(ENotepadLibraryPanicNoEdwin)); |
|
312 |
|
313 if ( iServiceHandler && iServiceHandler->HandleSubmenuL( *aMenuPane ) ) |
|
314 { |
|
315 return; |
|
316 } |
|
317 |
|
318 iModel.SyncL(EFalse); |
|
319 CNotepadDialogBase::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
320 SyncSequenceL(EFalse); |
|
321 TInt index; |
|
322 switch ( aResourceId ) |
|
323 { |
|
324 case R_SENDUI_MENU: |
|
325 index = 2; |
|
326 iSendUi->AddSendMenuItemL(*aMenuPane, index, ENotepadCmdSend /*TSendingCapabilities()*/ ); |
|
327 break; |
|
328 case R_NOTEPAD_EDITOR_MENU: // when Notepad Editor |
|
329 { |
|
330 if ( FeatureManager::FeatureSupported( KFeatureIdFfEnablePrintingFramework ) ) |
|
331 { |
|
332 // Initiliaze menu |
|
333 if ( !IsEmpty() ) |
|
334 { |
|
335 if ( iServiceHandler ) |
|
336 { |
|
337 CAiwGenericParamList& inParams = iServiceHandler->InParamListL(); |
|
338 iServiceHandler->InitializeMenuPaneL( *aMenuPane, |
|
339 aResourceId, |
|
340 ENotepadCmdPrint, |
|
341 inParams |
|
342 ); |
|
343 } |
|
344 } |
|
345 else |
|
346 { |
|
347 aMenuPane->DeleteMenuItem( ENotepadCmdPrint ); |
|
348 } |
|
349 } |
|
350 else |
|
351 { |
|
352 aMenuPane->DeleteMenuItem( ENotepadCmdPrint ); |
|
353 } |
|
354 |
|
355 const TBool empty(IsEmpty()); |
|
356 if((empty && !iEditor->CcpuCanPaste()) || ( iFlags & ENotepadMenuByOkKey) || iEditor->IsReadOnly() ) |
|
357 { |
|
358 aMenuPane->DeleteMenuItem( EAknCmdEditTextMenu ); |
|
359 } |
|
360 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
361 else |
|
362 { |
|
363 aMenuPane->DeleteMenuItem( EAknCmdEditTextMenu ); |
|
364 } |
|
365 #endif |
|
366 if ( empty ) |
|
367 { |
|
368 aMenuPane->DeleteMenuItem(ENotepadCmdAdd); |
|
369 } |
|
370 else |
|
371 { |
|
372 iSendUi->AddSendMenuItemL( *aMenuPane, 0, ENotepadCmdSend /*TSendingCapabilities()*/ ); // top item |
|
373 if ( !( iFlags & ENotepadMenuByOkKey ) ) |
|
374 { |
|
375 iFindItemMenu->DisplayFindItemMenuItemL(*aMenuPane, ENotepadCmdPreviousMemo); |
|
376 } |
|
377 } |
|
378 |
|
379 if ( iFlags & ENotepadMenuByOkKey ) |
|
380 { |
|
381 aMenuPane->DeleteMenuItem(ENotepadCmdNextMemo); |
|
382 aMenuPane->DeleteMenuItem(ENotepadCmdPreviousMemo); |
|
383 aMenuPane->DeleteMenuItem(EAknCmdExit); |
|
384 if(FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
385 { |
|
386 aMenuPane->DeleteMenuItem(EAknCmdHelp); |
|
387 } |
|
388 } |
|
389 else |
|
390 { |
|
391 if ( IsSequenceAtLast() || iSequence->Count() == 1 ) |
|
392 { |
|
393 aMenuPane->DeleteMenuItem(ENotepadCmdNextMemo); |
|
394 } |
|
395 if ( IsSequenceAtFirst() ) |
|
396 { |
|
397 aMenuPane->DeleteMenuItem(ENotepadCmdPreviousMemo); |
|
398 } |
|
399 } |
|
400 |
|
401 if(!FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
402 { |
|
403 aMenuPane->DeleteMenuItem(EAknCmdHelp); |
|
404 } |
|
405 |
|
406 TLanguage language = User::Language(); |
|
407 |
|
408 if(language == ELangJapanese || language == ELangEnglish_Japan) |
|
409 { |
|
410 aMenuPane->DeleteMenuItem(EAknCmdInputLanguage); |
|
411 } |
|
412 else |
|
413 { |
|
414 if (iFlags & ENotepadMenuByOkKey) |
|
415 { |
|
416 aMenuPane->DeleteMenuItem(EAknCmdInputLanguage); |
|
417 } |
|
418 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
419 else |
|
420 { |
|
421 aMenuPane->DeleteMenuItem(EAknCmdInputLanguage); |
|
422 } |
|
423 #endif |
|
424 } |
|
425 |
|
426 if(language == ELangPrcChinese || language ==ELangHongKongChinese || language ==ELangTaiwanChinese) |
|
427 { |
|
428 TInt checkQwertyStatus; |
|
429 iQwertyModeStatusProperty.Get(checkQwertyStatus); |
|
430 |
|
431 if(!checkQwertyStatus ) |
|
432 { |
|
433 |
|
434 aMenuPane->DeleteMenuItem(EAknCmdInputMethod); |
|
435 |
|
436 } |
|
437 |
|
438 } |
|
439 else |
|
440 { |
|
441 aMenuPane->DeleteMenuItem(EAknCmdInputMethod); |
|
442 } |
|
443 |
|
444 } |
|
445 break; |
|
446 |
|
447 |
|
448 case R_NOTEPAD_TEMPLATE_EDITOR_MENU: // when Template Editor |
|
449 { |
|
450 const TBool empty(IsEmpty()); |
|
451 if ( !empty ) |
|
452 { |
|
453 iSendUi->AddSendMenuItemL( *aMenuPane, 0, ENotepadCmdSend /*TSendingCapabilities()*/ ); // top item |
|
454 } |
|
455 if ( iFlags & ENotepadMenuByOkKey ) |
|
456 { |
|
457 aMenuPane->DeleteMenuItem(EAknCmdExit); |
|
458 if(FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
459 { |
|
460 aMenuPane->DeleteMenuItem(EAknCmdHelp); |
|
461 } |
|
462 } |
|
463 if(!FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
464 { |
|
465 aMenuPane->DeleteMenuItem(EAknCmdHelp); |
|
466 } |
|
467 } |
|
468 break; |
|
469 case R_FINDITEMMENU_MENU : |
|
470 { |
|
471 iFindItemMenu->DisplayFindItemCascadeMenuL(*aMenuPane); |
|
472 break; |
|
473 } |
|
474 |
|
475 |
|
476 default: |
|
477 break; |
|
478 } |
|
479 |
|
480 } |
|
481 |
|
482 |
|
483 // ----------------------------------------------------------------------------- |
|
484 // CNotepadEditorDialog::DynInitMenuBarL |
|
485 // from MEikMenuObserver |
|
486 // ----------------------------------------------------------------------------- |
|
487 // |
|
488 void CNotepadEditorDialog::DynInitMenuBarL( |
|
489 TInt aResourceId, |
|
490 CEikMenuBar* aMenuBar ) |
|
491 |
|
492 { |
|
493 |
|
494 __ASSERT_DEBUG( aResourceId > 0, |
|
495 Panic(ENotepadLibraryPanicNoMenuResource) ); |
|
496 __ASSERT_DEBUG( aMenuBar, Panic(ENotepadLibraryPanicNoMenuResource) ); |
|
497 |
|
498 if(!iTaskSwapperFlag ) |
|
499 { |
|
500 aMenuBar->SetMenuType(CEikMenuBar::EMenuOptionsNoTaskSwapper); |
|
501 } |
|
502 else |
|
503 { |
|
504 aMenuBar->SetMenuType(CEikMenuBar::EMenuOptions); |
|
505 iTaskSwapperFlag=EFalse; |
|
506 |
|
507 } |
|
508 |
|
509 } |
|
510 |
|
511 // ----------------------------------------------------------------------------- |
|
512 // CNotepadEditorDialog::ProcessCommandL |
|
513 // from MEikCommandObserver |
|
514 // ----------------------------------------------------------------------------- |
|
515 // |
|
516 void CNotepadEditorDialog::ProcessCommandL(TInt aCommandId) |
|
517 { |
|
518 HideMenu(); |
|
519 if ( iFindItemMenu && iFindItemMenu->CommandIsValidL( aCommandId ) ) |
|
520 { |
|
521 iFlags |= ENotepadFindItemRuning; |
|
522 TInt ret = DoSearchL( iFindItemMenu->SearchCase(aCommandId) ); |
|
523 if ( ret == EAknSoftkeyExit ) |
|
524 { |
|
525 aCommandId = ret; |
|
526 } |
|
527 iFlags &= ~ENotepadFindItemRuning; |
|
528 } |
|
529 |
|
530 switch (aCommandId) |
|
531 { |
|
532 case EAknSoftkeyExit: |
|
533 case EAknCmdExit: |
|
534 TryExitL(EAknSoftkeyExit); |
|
535 iAvkonAppUi->ProcessCommandL(EAknCmdExit); |
|
536 break; |
|
537 case ENotepadCmdAdd: |
|
538 OnCmdAddL(); |
|
539 break; |
|
540 case ENotepadCmdNextMemo: |
|
541 iRedrawBackground = ETrue; |
|
542 OnCmdNextMemoL(); |
|
543 break; |
|
544 case ENotepadCmdPreviousMemo: |
|
545 iRedrawBackground = ETrue; |
|
546 OnCmdPreviousMemoL(); |
|
547 break; |
|
548 case ENotepadCmdDelete: |
|
549 OnCmdDeleteL(); |
|
550 break; |
|
551 case ENotepadCmdSend: |
|
552 SendAsL( *iSendUi, aCommandId, EFalse, NULL, iEditor->Text() ); |
|
553 if ( IsExitDelayedBySendUi() ) |
|
554 { |
|
555 delete iListDialog; |
|
556 iListDialog = NULL; |
|
557 } |
|
558 default: |
|
559 { |
|
560 const TInt aiwServiceCmd( iServiceHandler ? iServiceHandler->ServiceCmdByMenuCmd( aCommandId ) : 0 ); |
|
561 if ( aiwServiceCmd == KAiwCmdPrint ) |
|
562 { |
|
563 CAiwGenericParamList& inParams = iServiceHandler->InParamListL(); |
|
564 |
|
565 // Just in case, save note to avoid situation when newly created |
|
566 // note cannot be be printed |
|
567 if ( iEditor->Text()->HasChanged() ) |
|
568 { |
|
569 if ( SaveOnExitL( ETrue ) != CNotepadModel::ENotepadModelRowNop ) |
|
570 { |
|
571 // Wait asynronously that memo is stored |
|
572 if ( !iStoreWait.IsStarted() ) |
|
573 { |
|
574 iStoreWait.Start(); |
|
575 } |
|
576 } |
|
577 } |
|
578 |
|
579 // Note index |
|
580 TAiwGenericParam noteParam( EGenericParamNoteItem ); |
|
581 const TInt32 noteKey = iKey; |
|
582 noteParam.Value().Set( noteKey ); |
|
583 inParams.AppendL( noteParam ); |
|
584 |
|
585 // Application uid |
|
586 const TUid uid( KUidNotepad ); // Notepad Uid3 |
|
587 TAiwGenericParam uidParam( EGenericParamApplication ); |
|
588 uidParam.Value().Set( uid ); |
|
589 inParams.AppendL( uidParam ); |
|
590 |
|
591 // Execute service command with given parameters |
|
592 iServiceHandler->ExecuteMenuCmdL( aCommandId, |
|
593 inParams, |
|
594 iServiceHandler->OutParamListL(), |
|
595 0, |
|
596 iListDialog |
|
597 ); |
|
598 break; |
|
599 } |
|
600 |
|
601 CNotepadDialogBase::ProcessCommandL(aCommandId); |
|
602 } |
|
603 break; |
|
604 } |
|
605 } |
|
606 |
|
607 // ----------------------------------------------------------------------------- |
|
608 // CNotepadEditorDialog::HandleControlStateChangeL |
|
609 // from CEikDialog |
|
610 // ----------------------------------------------------------------------------- |
|
611 // |
|
612 void CNotepadEditorDialog::HandleControlStateChangeL(TInt aControlId ) |
|
613 { |
|
614 CNotepadDialogBase::HandleControlStateChangeL(aControlId); |
|
615 } |
|
616 |
|
617 // ----------------------------------------------------------------------------- |
|
618 // CNotepadEditorDialog::PreLayoutDynInitL |
|
619 // from CEikDialog. |
|
620 // ----------------------------------------------------------------------------- |
|
621 // |
|
622 void CNotepadEditorDialog::PreLayoutDynInitL() |
|
623 { |
|
624 iEditor = STATIC_CAST(CNotepadEdwin*, Control(ENotepadIdEdwin)); |
|
625 TRect rect(iEikonEnv->EikAppUi()->ClientRect()); |
|
626 iEditor->SetRect(rect); |
|
627 } |
|
628 |
|
629 // ----------------------------------------------------------------------------- |
|
630 // CNotepadEditorDialog::OkToExitL |
|
631 // ----------------------------------------------------------------------------- |
|
632 // |
|
633 TBool CNotepadEditorDialog::OkToExitL( TInt aButtonId ) |
|
634 { |
|
635 const TChar linefeed(0x21B2); |
|
636 __ASSERT_DEBUG( iEditor, Panic(ENotepadLibraryPanicNoEdwin) ); |
|
637 if (IsContainLinefeedSymbol(iEditor->Text()->Read(0, |
|
638 iEditor->Text()->DocumentLength())) && !IsEmpty()) |
|
639 { |
|
640 return EFalse; |
|
641 } |
|
642 iFlags &= ~ENotepadMenuByOkKey; |
|
643 TBool isOk(ETrue); |
|
644 iTaskSwapperFlag= EFalse; |
|
645 switch ( aButtonId ) |
|
646 { |
|
647 //MSK |
|
648 case EAknSoftkeyContextOptions: |
|
649 { |
|
650 |
|
651 iFlags |= ENotepadMenuByOkKey; |
|
652 DisplayMenuL(); |
|
653 isOk= EFalse; |
|
654 } |
|
655 break; |
|
656 case EAknSoftkeyDone: |
|
657 SaveOnExitL(ETrue); |
|
658 break; |
|
659 case EEikBidCancel: // Simulated by CAknShutter |
|
660 case EAknSoftkeyExit: |
|
661 { |
|
662 TRAPD( err, SaveOnExitL( EFalse ); ); |
|
663 if ( err ) |
|
664 { |
|
665 CEikonEnv::Static()->HandleError(err); |
|
666 } |
|
667 } |
|
668 break; |
|
669 |
|
670 case EAknSoftkeyOptions: |
|
671 iTaskSwapperFlag= ETrue; |
|
672 if ( iFlags & ENotepadFindItemRuning ) |
|
673 { |
|
674 return EFalse; |
|
675 } |
|
676 default: |
|
677 isOk = CAknDialog::OkToExitL( aButtonId ); |
|
678 break; |
|
679 } |
|
680 return isOk; |
|
681 } |
|
682 |
|
683 // ----------------------------------------------------------------------------- |
|
684 // CNotepadEditorDialog::ActivateL |
|
685 // from CoeControl. |
|
686 // ----------------------------------------------------------------------------- |
|
687 // |
|
688 void CNotepadEditorDialog::ActivateL() |
|
689 { |
|
690 __ASSERT_DEBUG( iEditor, Panic(ENotepadLibraryPanicNoEdwin) ); |
|
691 iEditor->ConstructBaseL(); |
|
692 iEditor->InitNotepadEditorL(this, STATIC_CAST(CNotepadEdwinLines*, Control(ENotepadIdEdwinLines))); |
|
693 iEditor->SetFocus(ETrue, ENoDrawNow); |
|
694 CNotepadDialogBase::ActivateL(); |
|
695 } |
|
696 |
|
697 // ----------------------------------------------------------------------------- |
|
698 // CNotepadEditorDialog::OfferKeyEventL |
|
699 // from CCoeControl |
|
700 // ----------------------------------------------------------------------------- |
|
701 // |
|
702 TKeyResponse CNotepadEditorDialog::OfferKeyEventL( |
|
703 const TKeyEvent& aKeyEvent, |
|
704 TEventCode aType ) |
|
705 { |
|
706 |
|
707 |
|
708 if ( iIdle ) |
|
709 { |
|
710 NumberKeyCallBack(this); |
|
711 } |
|
712 TKeyResponse keyResponse(EKeyWasConsumed); |
|
713 |
|
714 |
|
715 if ( !MenuShowing() && aType == EEventKey && |
|
716 !( aKeyEvent.iModifiers & (EAllStdModifiers|EModifierSpecial) ) && |
|
717 ( aKeyEvent.iCode == EKeyOK ) ) |
|
718 { |
|
719 iFlags |= ENotepadMenuByOkKey; |
|
720 DisplayMenuL(); |
|
721 } |
|
722 else |
|
723 { |
|
724 if ( aKeyEvent.iCode == EKeyNo || aKeyEvent.iCode == EKeyEscape ) |
|
725 { |
|
726 iExitByTerminateKey = ETrue; |
|
727 } |
|
728 keyResponse = CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
|
729 } |
|
730 return keyResponse; |
|
731 } |
|
732 |
|
733 // ----------------------------------------------------------------------------- |
|
734 // CNotepadEditorDialog::GetHelpContext |
|
735 // from CCoeControl |
|
736 // ----------------------------------------------------------------------------- |
|
737 // |
|
738 void CNotepadEditorDialog::GetHelpContext(TCoeHelpContext& aContext) const |
|
739 { |
|
740 aContext.iMajor = KUidNotepad; |
|
741 switch ( iResId ) |
|
742 { |
|
743 case R_NOTEPAD_EDITOR_DIALOG_ORG: |
|
744 aContext.iContext = KNMAKE_HLP_MEMO_EDITOR; |
|
745 break; |
|
746 case R_NOTEPAD_TEMPLATE_EDITOR_DIALOG_ORG: |
|
747 aContext.iContext = KNMAKE_HLP_TEMPLATE_EDITOR; |
|
748 break; |
|
749 default: |
|
750 break; |
|
751 } |
|
752 } |
|
753 |
|
754 // --------------------------------------------------------- |
|
755 // CNotepadEditorDialog::HandleResourceChange |
|
756 // from CCoeControl |
|
757 // --------------------------------------------------------- |
|
758 // |
|
759 void CNotepadEditorDialog::HandleResourceChange(TInt aType) |
|
760 { |
|
761 if ( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch ) |
|
762 { |
|
763 CAknDialog::HandleResourceChange( aType ); |
|
764 CEikDialog::Layout(); |
|
765 if ( iEditor && IsActivated() ) |
|
766 { |
|
767 iEditor->HandleResourceChange(aType); |
|
768 } |
|
769 iEditor->DrawDeferred(); |
|
770 } |
|
771 else |
|
772 { |
|
773 CAknDialog::HandleResourceChange(aType); |
|
774 } |
|
775 if(iEditor) |
|
776 { |
|
777 iEditor->SetCursorVisible(IsFocused()); |
|
778 } |
|
779 } |
|
780 |
|
781 // --------------------------------------------------------- |
|
782 // CNotepadEditorDialog::SizeChanged |
|
783 // from CCoeControl |
|
784 // --------------------------------------------------------- |
|
785 // |
|
786 void CNotepadEditorDialog::SizeChanged() |
|
787 { |
|
788 CNotepadDialogBase::SizeChanged(); |
|
789 if (iEditor && IsActivated()) |
|
790 { |
|
791 TRAP_IGNORE(iEditor->DoEditorLayoutL()); |
|
792 } |
|
793 } |
|
794 |
|
795 // ----------------------------------------------------------------------------- |
|
796 // CNotepadEditorDialog::CNotepadEditorDialog |
|
797 // private c++ constructor |
|
798 // ----------------------------------------------------------------------------- |
|
799 // |
|
800 CNotepadEditorDialog::CNotepadEditorDialog( |
|
801 CNotepadModel& aModel, |
|
802 CNotepadListDialog* aListDialog ) |
|
803 :CNotepadDialogBase(), iModel(aModel), iListDialog(aListDialog), |
|
804 iKey(KNotepadPseudoKeyIdForNewNote), |
|
805 iServiceHandler( NULL ) |
|
806 { |
|
807 } |
|
808 |
|
809 |
|
810 |
|
811 // ----------------------------------------------------------------------------- |
|
812 // CNotepadEditorDialog::SaveL |
|
813 // |
|
814 // Table: What shoud we do after saving? |
|
815 // mode before saving, rowResult -> entry in iSequence |
|
816 // 1. adding nop -> nop |
|
817 // 2. adding added -> insert to top |
|
818 // 3. editing nop -> nop |
|
819 // 4. editing updated -> update the entry |
|
820 // 5. editing added -> update the entry |
|
821 // 6. editing deleted -> remove the entry |
|
822 // |
|
823 // In case 6, the info note "Memo delted" should be shown. |
|
824 // ----------------------------------------------------------------------------- |
|
825 // |
|
826 TInt CNotepadEditorDialog::SaveL() |
|
827 { |
|
828 __ASSERT_DEBUG(iEditor, Panic(ENotepadLibraryPanicNoEdwin)); |
|
829 __ASSERT_DEBUG(iEditor->Text(), Panic(ENotepadLibraryPanicNoTextInEdwin)); |
|
830 // in order to avoid leaving at *never leave* bellow |
|
831 iSequence->SetReserveL(iSequence->Count()+1); // *reserve space* |
|
832 const TBool wasModeAdding( IsModeAdding() ); |
|
833 const TInt savedCurrentSequence( CurrentSequence() ); |
|
834 TInt rowResult(CNotepadModel::ENotepadModelRowNop); |
|
835 if ( iEditor->Text()->HasChanged() ) |
|
836 { |
|
837 if ( wasModeAdding ) |
|
838 { |
|
839 rowResult = iModel.InsertL( iEditor->Text()->Read( |
|
840 0, iEditor->Text()->DocumentLength()), iKey ); |
|
841 // iKey is updated by InsertL if really added |
|
842 } |
|
843 else |
|
844 { |
|
845 rowResult = iModel.UpdateL( iEditor->Text()->Read( |
|
846 0, iEditor->Text()->DocumentLength()), iKey ); |
|
847 // iKey is updated by InsertL if iKey doesn't exist or set as |
|
848 // KNotepadPseudoKeyIdForNewNote if the entry was deleted |
|
849 } |
|
850 iEditor->Text()->SetHasChanged(EFalse); |
|
851 } |
|
852 if ( rowResult == CNotepadModel::ENotepadModelRowDeleted ) |
|
853 { |
|
854 if ( savedCurrentSequence != KNotepadInvalidSequenceIndex ) |
|
855 { |
|
856 iSequence->Delete(savedCurrentSequence); |
|
857 } |
|
858 |
|
859 if ( !iExitByTerminateKey ) |
|
860 { |
|
861 TInt resid = IsNotepad() ? R_NOTEPAD_TEXT_DELETED_EMPTY_MEMO : R_NOTEPAD_TEXT_DELETED_EMPTY_TEMPLATE; |
|
862 HBufC *text= StringLoader::LoadLC(resid); //<NOTEPAD_SAVE_NOTE_MAXLENGTH> text; |
|
863 CAknInformationNote* note |
|
864 = new(ELeave) CAknInformationNote(ETrue); |
|
865 note->SetMopParent(this); |
|
866 |
|
867 note->ExecuteLD(*text); |
|
868 CleanupStack::PopAndDestroy(text); |
|
869 } |
|
870 } |
|
871 else |
|
872 { |
|
873 if ( wasModeAdding && |
|
874 rowResult == CNotepadModel::ENotepadModelRowAdded ) |
|
875 { |
|
876 if ( IsNotepad() ) |
|
877 { |
|
878 iSequence->InsertL(1, iKey); // *never leave* because reserved |
|
879 } |
|
880 else |
|
881 { |
|
882 iSequence->InsertL(0, iKey); // *never leave* because reserved |
|
883 } |
|
884 |
|
885 } |
|
886 else if ( savedCurrentSequence != KNotepadInvalidSequenceIndex && |
|
887 ( rowResult == CNotepadModel::ENotepadModelRowAdded || |
|
888 rowResult == CNotepadModel::ENotepadModelRowUpdated ) ) |
|
889 { |
|
890 (*iSequence)[savedCurrentSequence] = iKey; |
|
891 } |
|
892 } |
|
893 return rowResult; |
|
894 } |
|
895 |
|
896 // ----------------------------------------------------------------------------- |
|
897 // CNotepadEditorDialog::OnCmdAddL |
|
898 // This command will never be called |
|
899 // in template Editor. |
|
900 // ----------------------------------------------------------------------------- |
|
901 // |
|
902 void CNotepadEditorDialog::OnCmdAddL() |
|
903 { |
|
904 SaveL(); |
|
905 SwitchTextL(KNotepadPseudoKeyIdForNewNote); |
|
906 } |
|
907 |
|
908 // ----------------------------------------------------------------------------- |
|
909 // CNotepadEditorDialog::OnCmdNextMemoL |
|
910 // |
|
911 // Ever reported; |
|
912 // 1. Notepad has memo "aaa", "bbb", "ddd" and open "aaa" in editor. |
|
913 // 2. Edit "aaa" to be "". |
|
914 // 3. Select 'Next memo' in Options menu. |
|
915 // then, editor contents will be changed to "bbb" correctly, but |
|
916 // Options menu has 'Previous memo' and nothing occurs if we select it. |
|
917 // |
|
918 // Table: What is next? |
|
919 // mode before saving, rowResult -> nextIndex |
|
920 // 1. adding nop -> 0 |
|
921 // 2. adding added -> 1 |
|
922 // 3. editing nop -> oldIndex+1 |
|
923 // 4. editing updated -> oldIndex+1 |
|
924 // 5. editing added -> oldIndex+1 |
|
925 // 6. editing deleted -> oldIndex |
|
926 // Of course, we must check the nextIndex so as not to exceed the total count. |
|
927 // ----------------------------------------------------------------------------- |
|
928 // |
|
929 void CNotepadEditorDialog::OnCmdNextMemoL() |
|
930 { |
|
931 TInt nextIndex(1); |
|
932 const TBool wasModeAdding( IsModeAdding() ); |
|
933 if ( !wasModeAdding ) |
|
934 { |
|
935 nextIndex = CurrentSequence(); // oldIndex |
|
936 } |
|
937 const TInt stat(SaveL()); // iKey has not changed when deleted |
|
938 if ( iSequence->Count() > 0 && |
|
939 wasModeAdding ? |
|
940 stat == CNotepadModel::ENotepadModelRowAdded : |
|
941 stat != CNotepadModel::ENotepadModelRowDeleted ) |
|
942 { |
|
943 nextIndex++; |
|
944 if ( nextIndex >= iSequence->Count() ) |
|
945 { |
|
946 nextIndex = iSequence->Count() - 1; |
|
947 } |
|
948 } |
|
949 if ( iSequence->Count() > 0 ) |
|
950 { |
|
951 TInt nextKey( (*iSequence)[nextIndex] ); |
|
952 if (nextKey != iKey) |
|
953 { |
|
954 SwitchTextL(nextKey); |
|
955 } |
|
956 } |
|
957 } |
|
958 |
|
959 // ----------------------------------------------------------------------------- |
|
960 // CNotepadEditorDialog::OnCmdPreviousMemoL |
|
961 // |
|
962 // Table: What is previous? |
|
963 // mode before saving, rowResult -> previousIndex |
|
964 // 1. editing nop -> oldIndex-1 |
|
965 // 2. editing updated -> oldIndex-1 |
|
966 // 3. editing added -> oldIndex-1 |
|
967 // 4. editing deleted -> oldIndex-1 |
|
968 // In adding mode, "Previous memo" is not available. |
|
969 // Of course, we must check the previousIndex so as not to be less than 0. |
|
970 // ----------------------------------------------------------------------------- |
|
971 // |
|
972 void CNotepadEditorDialog::OnCmdPreviousMemoL() |
|
973 { |
|
974 __ASSERT_DEBUG( IsModeEditing(), |
|
975 Panic(ENotepadLibraryPanicEditorInvalidMode) ); |
|
976 TInt previousIndex( CurrentSequence() ); // oldIndex |
|
977 SaveL(); |
|
978 if ( previousIndex > 0 ) |
|
979 { |
|
980 --previousIndex; |
|
981 } |
|
982 if ( iSequence->Count() > 0 ) |
|
983 { |
|
984 TInt previousKey( (*iSequence)[previousIndex] ); |
|
985 if (previousKey != iKey) |
|
986 { |
|
987 SwitchTextL(previousKey); |
|
988 } |
|
989 } |
|
990 } |
|
991 |
|
992 // ----------------------------------------------------------------------------- |
|
993 // CNotepadEditorDialog::OnCmdDeleteL |
|
994 // ----------------------------------------------------------------------------- |
|
995 // |
|
996 void CNotepadEditorDialog::OnCmdDeleteL() |
|
997 { |
|
998 TInt deleteKey( IsModeEditing() ? iKey : KNotepadPseudoKeyIdForNewNote ); |
|
999 if ( ExecuteConfirmationQueryL(QueryDeleteSingleResId()) ) |
|
1000 { |
|
1001 TInt returnKey( iKey ); |
|
1002 TInt stat(CNotepadModel::ENotepadModelRowNop); |
|
1003 iFlags &= ~ENotepadCatchSaveOnExitCallback; |
|
1004 if ( deleteKey >= 0 ) |
|
1005 { |
|
1006 const TBool isEditingFirst( |
|
1007 IsModeEditing() && IsSequenceAtFirst() ); |
|
1008 stat = iModel.DeleteL(deleteKey); |
|
1009 if ( !isEditingFirst && |
|
1010 stat == CNotepadModel::ENotepadModelRowDeleted ) |
|
1011 { |
|
1012 returnKey = NextKeyInSequence(); |
|
1013 } |
|
1014 } |
|
1015 iEditor->Text()->SetHasChanged(EFalse); // prevent saving |
|
1016 |
|
1017 iListDialog->HandleEditorExitL(stat, returnKey, |
|
1018 stat == CNotepadModel::ENotepadModelRowNop || |
|
1019 iFlags & ENotepadCatchSaveOnExitCallback ); |
|
1020 delete(this); // this is OK |
|
1021 } |
|
1022 } |
|
1023 |
|
1024 // ----------------------------------------------------------------------------- |
|
1025 // CNotepadEditorDialog::NumberKeyCallBack |
|
1026 // ----------------------------------------------------------------------------- |
|
1027 // |
|
1028 TInt CNotepadEditorDialog::NumberKeyCallBack(TAny *aSelf) |
|
1029 { |
|
1030 CNotepadEditorDialog *self = STATIC_CAST(CNotepadEditorDialog*, aSelf); |
|
1031 delete self->iIdle; |
|
1032 self->iIdle = NULL; |
|
1033 // delete must preceed KeyEvent to avoid infinite loop of OfferKeyEventL |
|
1034 // |
|
1035 TRAPD(err, |
|
1036 self->iCoeEnv->SimulateKeyEventL(self->iEvent, EEventKeyDown); |
|
1037 self->iCoeEnv->SimulateKeyEventL(self->iEvent, EEventKey); |
|
1038 ); |
|
1039 if ( err != KErrNone ) |
|
1040 { |
|
1041 self->iEditor->CancelFepTransaction(); // indispensable to avoid crash |
|
1042 self->iCoeEnv->HandleError(err); |
|
1043 } |
|
1044 return FALSE; |
|
1045 } |
|
1046 |
|
1047 // ----------------------------------------------------------------------------- |
|
1048 // CNotepadEditorDialog::CreateSequenceL |
|
1049 // ----------------------------------------------------------------------------- |
|
1050 // |
|
1051 void CNotepadEditorDialog::CreateSequenceL() |
|
1052 { |
|
1053 delete iSequence; |
|
1054 iSequence = NULL; |
|
1055 iSequence = new(ELeave) CArrayFixFlat<TInt>(KNotepadSequenceGranularity); |
|
1056 const RArray<TInt>& keyArray = iModel.KeyArray(); |
|
1057 const TInt count(keyArray.Count()); |
|
1058 iFlags |= ENotepadRequireSequenceUpdate; // flag on |
|
1059 for (TInt i(0); i < count; i++) |
|
1060 { |
|
1061 iSequence->AppendL( keyArray[i] ); |
|
1062 } |
|
1063 iFlags &= ~ENotepadRequireSequenceUpdate; // flag off |
|
1064 } |
|
1065 |
|
1066 // ----------------------------------------------------------------------------- |
|
1067 // CNotepadEditorDialog::SyncSequenceL |
|
1068 // ----------------------------------------------------------------------------- |
|
1069 // |
|
1070 void CNotepadEditorDialog::SyncSequenceL( const TBool aForceSync ) |
|
1071 { |
|
1072 if ( !iSequence || |
|
1073 !( aForceSync || iFlags & ENotepadRequireSequenceUpdate) ) |
|
1074 { |
|
1075 iFlags &= ~ENotepadRequireSequenceUpdate; // flag off |
|
1076 return; |
|
1077 } |
|
1078 iFlags |= ENotepadRequireSequenceUpdate; // flag on |
|
1079 const RArray<TInt>& keyArray = iModel.KeyArray(); |
|
1080 |
|
1081 // Delete entries which no longer exist |
|
1082 // |
|
1083 TInt i(0); |
|
1084 for ( i = iSequence->Count() - 1; i >= 0; --i ) |
|
1085 { |
|
1086 if ( keyArray.Find((*iSequence)[i]) < 0 ) // not found |
|
1087 { |
|
1088 iSequence->Delete(i); |
|
1089 } |
|
1090 } |
|
1091 |
|
1092 // Add entries which is newly added after previous Create/SyncSequenceL |
|
1093 // |
|
1094 TInt index( 0 ); |
|
1095 TKeyArrayFix cmpKeyArray(0, ECmpTInt); |
|
1096 for (i = keyArray.Count() - 1; i >= 1; --i) |
|
1097 { |
|
1098 if (iSequence->Find(keyArray[i], cmpKeyArray, index) != 0) |
|
1099 { |
|
1100 iSequence->InsertL(1, keyArray[i]); |
|
1101 } |
|
1102 } |
|
1103 if (iKey != KNotepadPseudoKeyIdForNewNote |
|
1104 && iSequence->Find(iKey, cmpKeyArray, index) != 0) // not found |
|
1105 { |
|
1106 iKey = KNotepadPseudoKeyIdForNewNote; |
|
1107 } |
|
1108 iFlags &= ~ENotepadRequireSequenceUpdate; // flag off |
|
1109 } |
|
1110 |
|
1111 // ----------------------------------------------------------------------------- |
|
1112 // CNotepadEditorDialog::IsSequenceAtLast |
|
1113 // ----------------------------------------------------------------------------- |
|
1114 // |
|
1115 TBool CNotepadEditorDialog::IsSequenceAtLast() const |
|
1116 { |
|
1117 __ASSERT_DEBUG( iSequence, |
|
1118 Panic(ENotepadLibraryPanicNullSequenceInEditor) ); |
|
1119 return ( IsModeAdding() ? iSequence->Count() == 1 : |
|
1120 CurrentSequence() == iSequence->Count() - 1 ); |
|
1121 } |
|
1122 |
|
1123 // ----------------------------------------------------------------------------- |
|
1124 // CNotepadEditorDialog::IsSequenceAtFirst |
|
1125 // ----------------------------------------------------------------------------- |
|
1126 // |
|
1127 TBool CNotepadEditorDialog::IsSequenceAtFirst() const |
|
1128 { |
|
1129 __ASSERT_DEBUG( iSequence, |
|
1130 Panic(ENotepadLibraryPanicNullSequenceInEditor) ); |
|
1131 return ( IsModeAdding() || CurrentSequence() == 1); |
|
1132 } |
|
1133 |
|
1134 // ----------------------------------------------------------------------------- |
|
1135 // CNotepadEditorDialog::CurrentSequence |
|
1136 // ----------------------------------------------------------------------------- |
|
1137 // |
|
1138 TInt CNotepadEditorDialog::CurrentSequence() const |
|
1139 { |
|
1140 __ASSERT_DEBUG( iSequence, |
|
1141 Panic(ENotepadLibraryPanicNullSequenceInEditor) ); |
|
1142 TInt index(KNotepadInvalidSequenceIndex); |
|
1143 TKeyArrayFix cmpKeyArray(0, ECmpTInt); |
|
1144 iSequence->Find(iKey, cmpKeyArray, index); |
|
1145 return index; |
|
1146 } |
|
1147 |
|
1148 // ----------------------------------------------------------------------------- |
|
1149 // CNotepadEditorDialog::NextKeyInSequence |
|
1150 // ----------------------------------------------------------------------------- |
|
1151 // |
|
1152 TInt CNotepadEditorDialog::NextKeyInSequence() const |
|
1153 { |
|
1154 __ASSERT_DEBUG( iSequence, |
|
1155 Panic(ENotepadLibraryPanicNullSequenceInEditor) ); |
|
1156 TInt nextKey(iKey); |
|
1157 if ( iKey == KNotepadPseudoKeyIdForNewNote ) // IsModeAdding |
|
1158 { |
|
1159 if ( iSequence->Count() > 1 ) |
|
1160 { |
|
1161 nextKey = (*iSequence)[1]; |
|
1162 } |
|
1163 else if ( iSequence->Count() == 1 ) |
|
1164 { |
|
1165 nextKey = (*iSequence)[0]; |
|
1166 } |
|
1167 } |
|
1168 else |
|
1169 { |
|
1170 TInt index ( CurrentSequence() ); |
|
1171 if ( index < iSequence->Count() - 1 ) |
|
1172 { |
|
1173 nextKey = (*iSequence)[index+1]; |
|
1174 } |
|
1175 } |
|
1176 return nextKey; |
|
1177 } |
|
1178 |
|
1179 // ----------------------------------------------------------------------------- |
|
1180 // CNotepadEditorDialog::PreviousKeyInSequence |
|
1181 // ----------------------------------------------------------------------------- |
|
1182 // |
|
1183 TInt CNotepadEditorDialog::PreviousKeyInSequence() const |
|
1184 { |
|
1185 __ASSERT_DEBUG( iSequence, |
|
1186 Panic(ENotepadLibraryPanicNullSequenceInEditor) ); |
|
1187 __ASSERT_DEBUG( IsModeEditing(), |
|
1188 Panic(ENotepadLibraryPanicEditorInvalidMode) ); |
|
1189 TInt previousKey(iKey); |
|
1190 if ( IsModeEditing() ) |
|
1191 { |
|
1192 TInt index( CurrentSequence() ); |
|
1193 if ( index > 0 ) |
|
1194 { |
|
1195 previousKey = (*iSequence)[index - 1]; |
|
1196 } |
|
1197 } |
|
1198 return previousKey; |
|
1199 } |
|
1200 |
|
1201 // ----------------------------------------------------------------------------- |
|
1202 // CNotepadEditorDialog::DoSearchL |
|
1203 // ----------------------------------------------------------------------------- |
|
1204 // |
|
1205 TInt CNotepadEditorDialog::DoSearchL(CFindItemEngine::TFindItemSearchCase aCase) |
|
1206 { |
|
1207 CFindItemDialog* dialog = CFindItemDialog::NewL( iEditor->Text()->Read( 0 ), aCase ); |
|
1208 dialog->EnableSingleClick( ETrue ); |
|
1209 dialog->SetCallSubMenuVisibility( EFalse ); // Click-To-Call |
|
1210 TInt ret = dialog->ExecuteLD(); |
|
1211 return ret; |
|
1212 } |
|
1213 |
|
1214 // ----------------------------------------------------------------------------- |
|
1215 // CNotepadEditorDialog::IsContainLinefeedSymbol |
|
1216 // ----------------------------------------------------------------------------- |
|
1217 // |
|
1218 TBool CNotepadEditorDialog::IsContainLinefeedSymbol(const TDesC& aDes) |
|
1219 { |
|
1220 const TChar linefeed(0x21B2); |
|
1221 for(TInt i = 0; i < aDes.Length(); i++) |
|
1222 { |
|
1223 TChar c(aDes[i]); |
|
1224 if(c == linefeed) |
|
1225 { |
|
1226 return ETrue; |
|
1227 } |
|
1228 } |
|
1229 return EFalse; |
|
1230 } |
|
1231 |
|
1232 // CNotepadEditorDialog::FocusChanged |
|
1233 // ----------------------------------------------------------------------------- |
|
1234 // |
|
1235 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1236 void CNotepadEditorDialog::FocusChanged(TDrawNow /*aDrawNow*/) |
|
1237 { |
|
1238 if(iEditor) |
|
1239 { |
|
1240 iEditor->SetCursorVisible(IsFocused()); |
|
1241 } |
|
1242 } |
|
1243 #endif |
|
1244 |
|
1245 // ----------------------------------------------------------------------------- |
|
1246 // CNotepadEditorDialog::CNotepadEditorDialog_Reserved |
|
1247 // ----------------------------------------------------------------------------- |
|
1248 // |
|
1249 EXPORT_C void CNotepadEditorDialog::CNotepadEditorDialog_Reserved() |
|
1250 { |
|
1251 } |
|
1252 |
|
1253 // End of File |