|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * Postcard application address dialog |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __POSTCARDADDRESSFORM_H__ |
|
22 #define __POSTCARDADDRESSFORM_H__ |
|
23 |
|
24 // INCLUDES |
|
25 #include <AknForm.h> // CAknForm |
|
26 #include <ConeResLoader.h> |
|
27 #include <coecntrl.h> |
|
28 |
|
29 #include <eikrted.h> |
|
30 #include <eikedwin.h> |
|
31 #include <eikedwob.h> |
|
32 |
|
33 #include "PostcardContact.h" |
|
34 #include "Postcard.hrh" |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class CAknNavigationDecorator; |
|
38 class CContactCard; |
|
39 class CContactItem; |
|
40 class CEikMenuPane; |
|
41 class CPostcardAppUi; |
|
42 class CPostcardDocument; |
|
43 |
|
44 /** |
|
45 * Postcard Address Form. |
|
46 */ |
|
47 class CPostcardAddressForm : public CAknForm, |
|
48 public MEikEdwinObserver |
|
49 { |
|
50 public: // Constants |
|
51 enum |
|
52 { |
|
53 // Name, info, street, zip, city, state, country |
|
54 ENumAddrFields = 7 |
|
55 }; |
|
56 public: // Constructors and destructor |
|
57 |
|
58 /** |
|
59 * Two-phased constructor. |
|
60 * param IN aAppUi reference to AppUi object |
|
61 * param IN aDocument reference to document object |
|
62 * param IN aContactItem the item to be edited |
|
63 * param OUT aRetValue if for example Send was pressed in the dialog it's returned here |
|
64 * param IN aFirstActive the field that should be activated first |
|
65 * param IN aKeyEvent possible keyevent to simulate when dialog opened |
|
66 * @return pointer to created CPostcardAddressForm |
|
67 */ |
|
68 static CPostcardAddressForm* NewL( CPostcardAppUi& aAppUi, |
|
69 CPostcardDocument& aDocument, |
|
70 CContactCard& aContactItem, |
|
71 TInt& aRetValue, |
|
72 TInt aFirstActive = -1, |
|
73 TKeyEvent aKeyEvent = TKeyEvent() ); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 */ |
|
78 ~CPostcardAddressForm(); |
|
79 |
|
80 public: |
|
81 |
|
82 /** |
|
83 * @return CAknDialog::RunLD() |
|
84 */ |
|
85 TInt ExecLD( ); |
|
86 |
|
87 public: // Functions from base classes |
|
88 |
|
89 /** |
|
90 * From MEikCommandObserver Prosesses menucommands |
|
91 * @param aCommandId - id of the command |
|
92 */ |
|
93 void ProcessCommandL( TInt aCommandId ); |
|
94 |
|
95 /** |
|
96 * From CCoeControl Handles key events |
|
97 * @param aKeyEvent - keyevent to be handled |
|
98 * @param aType - keyeventtype to be handled |
|
99 */ |
|
100 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
101 TEventCode aType ); |
|
102 |
|
103 /** |
|
104 * HandleResourceChange |
|
105 */ |
|
106 void HandleResourceChange(TInt aType); |
|
107 |
|
108 /** |
|
109 * from CEikDialog |
|
110 */ |
|
111 void PreLayoutDynInitL(); |
|
112 |
|
113 /** |
|
114 * from CEikDialog |
|
115 * Fills the fields. |
|
116 */ |
|
117 void PostLayoutDynInitL(); |
|
118 |
|
119 /** |
|
120 * from MCoeControlObserver |
|
121 * Updates the length indicator and checks if the field is too long |
|
122 */ |
|
123 void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); |
|
124 |
|
125 protected: // Functions from base classes |
|
126 |
|
127 /** |
|
128 * From MEikMenuObserver Initializes items on the menu |
|
129 * |
|
130 * @param aMenuId Current menu's resource Id |
|
131 * @param aMenuPane Pointer to menupane |
|
132 */ |
|
133 void DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane); |
|
134 |
|
135 /** |
|
136 * From CEikDialog Handles button events and looks if the dialog |
|
137 * can be closed. First calls CAknDialog::OkToExitL. If that returns |
|
138 * true, and aButtonId is either EAknSoftkeyBack, EAknSoftkeyExit, |
|
139 * EAknSoftkeyDone, EAknCmdExit, EEikCmdExit or EPostcardCmdSend, |
|
140 * If a message is not yet sent, then recipient is added to the message |
|
141 * and ETrue is returned. |
|
142 * Otherwise returns false; |
|
143 * @param aButtonId Id of the 'pressed' button |
|
144 * |
|
145 * @return ETrue if it's OK to exit |
|
146 * EFalse otherwise |
|
147 */ |
|
148 TBool OkToExitL( TInt aButtonId ); |
|
149 |
|
150 /** |
|
151 * If aEventType is EEventTextUpdate -> Updates navipane and checks the length of the field |
|
152 */ |
|
153 void HandleEdwinEventL( CEikEdwin* aEdwin, TEdwinEvent aEventType ); |
|
154 |
|
155 /** |
|
156 * Changes the edwin event observer and updates navipane |
|
157 */ |
|
158 void LineChangedL(TInt aControlId); |
|
159 |
|
160 protected: // New functions |
|
161 |
|
162 /** |
|
163 * DynInitMainMenuL Initializes items on the menu |
|
164 * |
|
165 * @param aMenuPane Pointer to menupane |
|
166 */ |
|
167 void DynInitMainMenuL(CEikMenuPane* aMenuPane); |
|
168 |
|
169 /** |
|
170 * DynInitInsertSubMenuL Initializes items on the menu |
|
171 * |
|
172 * @param aMenuPane Pointer to menupane |
|
173 */ |
|
174 void DynInitInsertSubMenuL(CEikMenuPane* aMenuPane); |
|
175 |
|
176 /** |
|
177 * DynInitContextMenuL Initializes items on the menu |
|
178 * |
|
179 * @param aMenuPane Pointer to menupane |
|
180 */ |
|
181 void DynInitContextMenuL(CEikMenuPane* aMenuPane); |
|
182 |
|
183 /** |
|
184 * IsMainMenuOptionInvisible |
|
185 * Returns true if menuoption aMenuOptionId is visible in Mainmenu |
|
186 * @param aMenuOptionId menu option to be checked |
|
187 * @return TBool True if option is invisible |
|
188 */ |
|
189 TBool IsMainMenuOptionInvisible( TInt aMenuOptionId ); |
|
190 |
|
191 /** |
|
192 * LaunchHelpL |
|
193 * This function is called when Help application is launched. |
|
194 */ |
|
195 void LaunchHelpL( ); |
|
196 |
|
197 private: // From CAknForm |
|
198 |
|
199 /** |
|
200 * Calls CAknForm::SetInitialCurrentLine() if it's not been called yet |
|
201 */ |
|
202 void SetInitialCurrentLine(); |
|
203 |
|
204 /** |
|
205 * Does nothing at the moment |
|
206 */ |
|
207 void HandleControlStateChangeL(TInt aControlId); |
|
208 |
|
209 private: // Own ones |
|
210 |
|
211 /** |
|
212 * Opens the add recipient dialog |
|
213 */ |
|
214 void DoSelectionKeyL( ); |
|
215 |
|
216 /** |
|
217 * Changes the value of iRetVal and tries to exit the dialog |
|
218 */ |
|
219 void SendL( ); |
|
220 |
|
221 /** |
|
222 * Changes the value of iRetVal and tries to exit the dialog |
|
223 */ |
|
224 void ForwardMessageL( ); |
|
225 |
|
226 /** |
|
227 * Updates current TMsvEntry and calls AppUi's DoShowMessageInfoL |
|
228 */ |
|
229 void MessageInfoL( ); |
|
230 |
|
231 /** |
|
232 * Checks the length of current text field and shows an info note if necessary |
|
233 */ |
|
234 void CheckTextExceedingL( ); |
|
235 |
|
236 /** |
|
237 * Uses CPostcardContact to show the recipient fetch dialog |
|
238 * Uses CPostcardRecipientWrapper to fetch the right detail of the contact item |
|
239 * Adds the value of the contact item into the address fields |
|
240 */ |
|
241 void DoAddRecipientL( ); |
|
242 |
|
243 /** |
|
244 * Updates recipient to entry. |
|
245 */ |
|
246 void UpdateRecipientToEntryL(); |
|
247 |
|
248 /** |
|
249 * Adds the right fields of aContact to right fields of the dialog |
|
250 */ |
|
251 void UpdateFieldsL( CContactItem& aContact ); |
|
252 |
|
253 /** |
|
254 * Add the aLocation fields of aContact to right fields of the dialog |
|
255 */ |
|
256 void UpdateFieldsL( CPostcardContact::TLocation aLocation ); |
|
257 |
|
258 /** |
|
259 * Returns true if none of the fields have any text |
|
260 */ |
|
261 TBool IsEmpty( ); |
|
262 |
|
263 /** |
|
264 * Cleans navipane. |
|
265 */ |
|
266 void CleanNavipane(); |
|
267 |
|
268 /** |
|
269 * Forces all visible lines to be redrawn on the screen |
|
270 */ |
|
271 void RefreshDisplay( ); |
|
272 |
|
273 /** |
|
274 * Set middle softkey according to the mode (viewer / edit) |
|
275 * and whether address is empty or not |
|
276 */ |
|
277 void SetMiddleSoftkeyL(); |
|
278 |
|
279 protected: // Constructors |
|
280 CPostcardAddressForm( CPostcardAppUi& aAppUi, |
|
281 CPostcardDocument& aDocument, |
|
282 CContactCard& aContactItem, |
|
283 TInt& aRetValue, |
|
284 TInt aFirstActive, |
|
285 TKeyEvent aKeyEvent ); |
|
286 |
|
287 /** |
|
288 * EPOC constructor |
|
289 */ |
|
290 void ConstructL(); |
|
291 |
|
292 /** |
|
293 * Goes thru the fields. Hides the hidden ones. |
|
294 * Shows error note of an empty field if necessary. |
|
295 * Changes the focused field to the right one. |
|
296 * Updates navipane. Simulate keys if necessary. |
|
297 */ |
|
298 void ActivateL(); |
|
299 |
|
300 protected: // data |
|
301 /// Ref: Contact item under editing |
|
302 CContactCard& iContactItem; |
|
303 |
|
304 private: // Data |
|
305 |
|
306 enum PostcardAddressFlags |
|
307 { |
|
308 EPostcardAddressHelpSupported = 1, |
|
309 EPostcardAddressTextExceeded = 2 |
|
310 }; |
|
311 |
|
312 CPostcardAppUi& iAppUi; |
|
313 CPostcardDocument& iDocument; |
|
314 |
|
315 CAknNavigationDecorator* iNaviDecorator; |
|
316 |
|
317 TKeyEvent iKeyEvent; |
|
318 TInt& iRetValue; |
|
319 TInt iAddrFlags; |
|
320 TInt iMaxLen; |
|
321 TInt iPreviousControl; |
|
322 TInt iFirstActive; |
|
323 |
|
324 CPostcardContact* iContact; // interface to contact database |
|
325 |
|
326 TInt iMskResource; // current middle softkey resource ID |
|
327 }; |
|
328 |
|
329 #endif // __CPbkContactEditorDlg_H__ |
|
330 |
|
331 // End of File |