|
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: Declaration of Notepad Editor Dialog class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NPDEDITORDIALOG_H |
|
20 #define NPDEDITORDIALOG_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <eikapp.h> |
|
24 #include <eikdoc.h> |
|
25 #include <e32std.h> |
|
26 #include <coeccntx.h> |
|
27 #include <aknappui.h> |
|
28 #include <eikedwob.h> |
|
29 #include "NpdDialogBase.h" |
|
30 #include "NpdModelObserver.h" |
|
31 #include <finditemengine.h> |
|
32 #include <e32property.h> |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CNotepadModel; |
|
36 class CNotepadEdwin; |
|
37 class CNotepadEditorLaf; |
|
38 class CSendUi; |
|
39 class CNotepadListDialog; |
|
40 class CAknAppUi; |
|
41 class CIdle; |
|
42 class CFindItemMenu; |
|
43 class CAiwServiceHandler; |
|
44 |
|
45 // CLASS DECLARATION |
|
46 /** |
|
47 * Dialog of editor mode. |
|
48 * CNotepadEditorDialog is a dialog for both memo editor and template editor. |
|
49 * |
|
50 * @lib NpdLib.lib |
|
51 * @see CNotepadDialogBase |
|
52 */ |
|
53 class CNotepadEditorDialog : public CNotepadDialogBase, |
|
54 public MNotepadModelObserver |
|
55 { |
|
56 public: // Constructors and destructor |
|
57 /** |
|
58 * Constructor. |
|
59 * |
|
60 * @param aResId resource id of type STRUCT NOTEPAD_EDITOR_DIALOG. |
|
61 * @param aModel pointer to CNotepadModel, never NULL. |
|
62 * @param aSendUi aSendUi object. |
|
63 * @return new CNotepadDialogBase object. |
|
64 * @internal |
|
65 */ |
|
66 IMPORT_C static CNotepadEditorDialog* NewL( |
|
67 TInt aResId, |
|
68 CNotepadModel* aModel, |
|
69 CNotepadListDialog* aListDialog, |
|
70 CSendUi* aSendUi); |
|
71 |
|
72 /** |
|
73 * Destructor. |
|
74 */ |
|
75 IMPORT_C virtual ~CNotepadEditorDialog(); |
|
76 |
|
77 public: // New functions |
|
78 |
|
79 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
80 void FocusChanged(TDrawNow aDrawNow); |
|
81 #endif |
|
82 /** |
|
83 * Execute a dialog. |
|
84 * |
|
85 * @return exit status value of CEikDialog's ExecuteLD. |
|
86 * @internal |
|
87 */ |
|
88 IMPORT_C TInt ExecuteLD(); |
|
89 |
|
90 /** |
|
91 * Switch contents of the editor to text of specified item. |
|
92 * |
|
93 * @param aKey Unique key id of Notepad items. |
|
94 */ |
|
95 void SwitchTextL(TInt aKey); |
|
96 |
|
97 /** |
|
98 * Save current contents of the editor into database. |
|
99 * |
|
100 * @param aNeedListRefresh Refresh List mode if ETrue. |
|
101 * @return TNotepadModelRowResult ( return value of SaveL ). |
|
102 */ |
|
103 TInt SaveOnExitL(TBool aNeedListRefresh); |
|
104 |
|
105 /** |
|
106 * Switch contents of the editor to text of specified item. |
|
107 * Current contents of the editor is saved before the switching. |
|
108 * |
|
109 * This method is called when receiving a message from |
|
110 * Pinboard while editor dialog is running. |
|
111 * |
|
112 * @param aKey unique memo id. |
|
113 * @param aAppUi base app ui. |
|
114 */ |
|
115 void EditByKeyL(const TInt aKey, CAknAppUi& aAppUi); |
|
116 |
|
117 /** |
|
118 * Set a key event. This method is used when the editor is opened |
|
119 * from list mode by pressing a number key. |
|
120 * |
|
121 * @param aKeyEvent number key event. |
|
122 */ |
|
123 void SetInitialKeyEventL(const TKeyEvent& aKeyEvent); |
|
124 |
|
125 protected: // Functions from base classes |
|
126 |
|
127 /** |
|
128 * From MNotepadModelObserver. |
|
129 */ |
|
130 void HandleNotepadModelEventL(TEvent aEvent, TInt aParam = 0); |
|
131 |
|
132 /** |
|
133 * From MEikMenuObserver. |
|
134 * |
|
135 * @param aResourceId resource id. |
|
136 * @param menu pane object. |
|
137 */ |
|
138 void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); |
|
139 |
|
140 |
|
141 /** |
|
142 * From MEikMenuObserver. |
|
143 * |
|
144 * @param aResourceId resource id. |
|
145 * @param menu Bar object. |
|
146 */ |
|
147 void DynInitMenuBarL(TInt aResourceId,CEikMenuBar* aMenuBar); |
|
148 |
|
149 |
|
150 /** |
|
151 * From MEikCommandObserver |
|
152 * |
|
153 * @param aCommandId command. |
|
154 */ |
|
155 void ProcessCommandL(TInt aCommandId); |
|
156 |
|
157 /** |
|
158 * From CEikDialog. |
|
159 * Override to implement dynamically changing decoration. |
|
160 * |
|
161 * @param aControlId id of editor dialog line. |
|
162 */ |
|
163 void HandleControlStateChangeL(TInt aControlId); |
|
164 |
|
165 /** |
|
166 * From CEikDialog. |
|
167 */ |
|
168 void PreLayoutDynInitL(); |
|
169 |
|
170 /** |
|
171 * From CEikDialog. |
|
172 */ |
|
173 TBool OkToExitL( TInt aButtonId ) ; |
|
174 |
|
175 /** |
|
176 * From CCoeControl. |
|
177 */ |
|
178 void ActivateL(); |
|
179 |
|
180 /** |
|
181 * From CCoeControl |
|
182 * |
|
183 * @param aKeyEvent key event which includes ScanCode etc. |
|
184 * @param aType event type ( up, in, down...). |
|
185 */ |
|
186 TKeyResponse OfferKeyEventL( |
|
187 const TKeyEvent& aKeyEvent, |
|
188 TEventCode aType); |
|
189 |
|
190 /** |
|
191 * From CCoeControl. |
|
192 * |
|
193 * @param aContext TCoeHelpContext. |
|
194 */ |
|
195 void GetHelpContext(TCoeHelpContext& aContext) const; |
|
196 |
|
197 /** |
|
198 * From CCoeControl |
|
199 * |
|
200 * @param aType event type. |
|
201 */ |
|
202 void HandleResourceChange(TInt aType); |
|
203 |
|
204 /** |
|
205 * From CCoeControl. |
|
206 * Called when SizeChanged. |
|
207 */ |
|
208 void SizeChanged(); |
|
209 |
|
210 private: // Constructors |
|
211 |
|
212 /** |
|
213 * C++ constructor. |
|
214 */ |
|
215 CNotepadEditorDialog( |
|
216 CNotepadModel& aModel, |
|
217 CNotepadListDialog* aListDialog ); |
|
218 |
|
219 /** |
|
220 * Internal base constructor. |
|
221 * |
|
222 * @param aReader resource reader already opened for |
|
223 * "STRUCT NOTEPAD_EDITOR_DIALOG". |
|
224 */ |
|
225 void ConstructL(TResourceReader& aReader); |
|
226 |
|
227 private: // New functions. |
|
228 |
|
229 /** |
|
230 * Save current content of editor into database. |
|
231 * |
|
232 * @return TNotepadModelRowResult |
|
233 */ |
|
234 TInt SaveL(); |
|
235 |
|
236 |
|
237 /** |
|
238 * Called on ENotepadCmdAdd. |
|
239 */ |
|
240 void OnCmdAddL(); |
|
241 |
|
242 /** |
|
243 * Called on ENotepadCmdNextMemo |
|
244 */ |
|
245 void OnCmdNextMemoL(); |
|
246 |
|
247 /** |
|
248 * Called on ENotepadCmdPreviousMemo |
|
249 */ |
|
250 void OnCmdPreviousMemoL(); |
|
251 |
|
252 /** |
|
253 * Called on ENotepadCmdDelete |
|
254 */ |
|
255 void OnCmdDeleteL(); |
|
256 |
|
257 |
|
258 /** |
|
259 * Number key callback function for deferred key event (for FEP). |
|
260 * |
|
261 * @param a pointer of CNotepadEditorDialog. |
|
262 * @return always EFalse. |
|
263 */ |
|
264 static TInt NumberKeyCallBack(TAny *aSelf); |
|
265 |
|
266 |
|
267 /** |
|
268 * Check the condition if the Notepad editor is empty or not. |
|
269 */ |
|
270 inline TBool IsEmpty() const; |
|
271 |
|
272 |
|
273 /** |
|
274 * Resource id of prompt text when deleting a single item. |
|
275 * |
|
276 * @return TBUF resource id. |
|
277 */ |
|
278 inline TInt QueryDeleteSingleResId() const; |
|
279 |
|
280 /** |
|
281 * Create iSequence. |
|
282 */ |
|
283 void CreateSequenceL(); |
|
284 |
|
285 /** |
|
286 * Sync between iSequence and iModel->iKeyArray. |
|
287 * |
|
288 * @param aForceSync if EFalse syncing is done only when the last |
|
289 * SyncSequenceL failed on LEAVE, otherwise syncing is done always. |
|
290 */ |
|
291 void SyncSequenceL(const TBool aForceSync); |
|
292 |
|
293 /** |
|
294 * Check wether we are at the end of Sequence. |
|
295 * |
|
296 * @return ETrue if sequence exists and current is last. |
|
297 */ |
|
298 TBool IsSequenceAtLast() const; |
|
299 |
|
300 /** |
|
301 * Check wether we are at the top of Sequence. |
|
302 * |
|
303 * @return ETrue if sequence exists and current is first. |
|
304 */ |
|
305 TBool IsSequenceAtFirst() const; |
|
306 |
|
307 /** |
|
308 * The current index in Sequence of the item now editing. |
|
309 * |
|
310 * @return the current index if IsModeEditing, |
|
311 * KNotepadInvalidSequenceIndex if IsModeAdding. |
|
312 */ |
|
313 TInt CurrentSequence() const; |
|
314 |
|
315 /** |
|
316 * Check if current mode is Adding. |
|
317 * |
|
318 * @return ETrue iff the current mode is Adding. |
|
319 */ |
|
320 inline TBool IsModeAdding() const; |
|
321 |
|
322 /** |
|
323 * Check if current mode is Editing. |
|
324 * |
|
325 * @return ETrue iff the current mode is Editing. |
|
326 */ |
|
327 inline TBool IsModeEditing() const; |
|
328 |
|
329 /** |
|
330 * Key id of the item next to the item now editing. |
|
331 * |
|
332 * If the mode is Adding and iSequence is empty, |
|
333 * return KNotepadPseudoKeyIdForNewNote. |
|
334 * |
|
335 * If the mode is Adding and iSequence is not empty, |
|
336 * return a key of the first item in iSequence. |
|
337 * |
|
338 * If the mode is Editing and the item now editing is the last item |
|
339 * in iSequence, return the key now editing. |
|
340 * |
|
341 * If the mode is Editing and the item now editing is not the last |
|
342 * item in iSequence, return the key of the next item. |
|
343 * |
|
344 * @return Key id of the item next to the item now editing. |
|
345 */ |
|
346 TInt NextKeyInSequence() const; |
|
347 |
|
348 /** |
|
349 * Key id of the item previous to the item now editing. |
|
350 * |
|
351 * If the mode is Adding, return KNotepadPseudoKeyIdForNewNote. |
|
352 * |
|
353 * If the mode is Editing and the item now editing is the first item |
|
354 * in iSequence, return the key now editing. |
|
355 * |
|
356 * If the mode is Editing and the item now editing is not the first |
|
357 * item in iSequence, return the key of the previous item. |
|
358 * |
|
359 * @return Key id of the item previous to the item now editing. |
|
360 */ |
|
361 TInt PreviousKeyInSequence() const; |
|
362 |
|
363 /** |
|
364 * Changes for Find Item. |
|
365 * To search a given buffer for phone numbers, email ids, URLs. |
|
366 **/ |
|
367 TInt DoSearchL(CFindItemEngine::TFindItemSearchCase aCase); |
|
368 /** |
|
369 * test whether the text contains the linefeed character. |
|
370 * @return ETrue if the test contains linefeed character, EFalse if not. |
|
371 */ |
|
372 TBool IsContainLinefeedSymbol(const TDesC& aDes); |
|
373 |
|
374 private: // reserved |
|
375 |
|
376 /** |
|
377 * Reserved. |
|
378 */ |
|
379 IMPORT_C void CNotepadEditorDialog_Reserved(); |
|
380 |
|
381 private: |
|
382 enum TNotepadEditorFlags |
|
383 { |
|
384 ENotepadFindItemRuning = 0x01, |
|
385 ENotepadMenuByOkKey = 0x02, |
|
386 ENotepadRequireSequenceUpdate = 0x04, |
|
387 ENotepadCatchSaveOnExitCallback = 0x08 |
|
388 }; |
|
389 CNotepadEdwin* iEditor; // not own (CEikDialog own) |
|
390 CNotepadModel& iModel; // never own |
|
391 CSendUi* iSendUi; // not own |
|
392 CNotepadListDialog* iListDialog; |
|
393 TInt iKey; |
|
394 CIdle* iIdle; |
|
395 TKeyEvent iEvent; // moved to here from ListDialog |
|
396 TUint iFlags; |
|
397 CArrayFixFlat<TInt>* iSequence; // own, map SequenceIndex -> Key. |
|
398 CFindItemMenu* iFindItemMenu; //Manual Find Item |
|
399 TBool iRedrawBackground; |
|
400 RProperty iQwertyModeStatusProperty; |
|
401 CAiwServiceHandler* iServiceHandler; // Own: AIW |
|
402 CActiveSchedulerWait iStoreWait; |
|
403 TBool iTaskSwapperFlag; |
|
404 TBool iExitByTerminateKey; |
|
405 }; |
|
406 |
|
407 #include "NpdEditorDialog.inl" |
|
408 #endif // NPDEDITORDIALOG_H |
|
409 |
|
410 // End of File |