|
1 /* |
|
2 * Copyright (c) 2006 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: Container class for search view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CCABLOCKINGDIALOG_H |
|
20 #define CCABLOCKINGDIALOG_H |
|
21 |
|
22 |
|
23 /* Dialogs for selection service implementation. |
|
24 * |
|
25 */ |
|
26 |
|
27 #include <aknform.h> |
|
28 #include <aknview.h> |
|
29 #include <aknutils.h> |
|
30 #include <aknpopup.h> |
|
31 #include <avkon.rsg> |
|
32 |
|
33 #include "impsbuilddefinitions.h" |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class CCAStatusPaneHandler; |
|
37 |
|
38 /** CCABlockingDialog is the actual interface to the applications. |
|
39 * |
|
40 * Use this class to get a full screen list. |
|
41 * |
|
42 * This class only works in whole main pane. Do not try to use |
|
43 * this directly for other places. |
|
44 * |
|
45 * resource definition for this class: |
|
46 * RESOURCE DIALOG r_res_id_for_a_dialog |
|
47 * { |
|
48 * flags = EAknDialogSelectionList; |
|
49 * buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK; |
|
50 * items = |
|
51 * { |
|
52 * DLG_LINE |
|
53 * { |
|
54 * type = EAknCtSingleGraphicListBox; |
|
55 * id = ESelectionListControl; |
|
56 * control = LISTBOX |
|
57 * { |
|
58 * flags = EAknListBoxSelectionList; |
|
59 * }; |
|
60 * } |
|
61 * // the next dlg line is optional. |
|
62 * , |
|
63 * DLG_LINE |
|
64 * { |
|
65 * itemflags = EEikDlgItemNonFocusing; |
|
66 * id = EFindControl; |
|
67 * type = EAknCtSelectionListFixedFind; |
|
68 * } |
|
69 * }; |
|
70 * } |
|
71 * |
|
72 * The listbox type can be one of the following: (avkon.hrh and aknlists.h) |
|
73 * EAknCtSingleListBox (See CAknSingleStyleListBox) |
|
74 * EAknCtSingleNumberListBox (See CAknSingleNumberStyleListBox) |
|
75 * EAknCtSingleHeadingListBox (See CAknSingleHeadingStyleListBox) |
|
76 * EAknCtSingleGraphicListBox (See CAknSingleGraphicStyleListBox) |
|
77 * EAknCtSingleGraphicHeadingListBox (See CAknSingleGraphicHeadingStyleListBox) |
|
78 * EAknCtSingleNumberHeadingListBox (See CAknSingleNumberHeadingStyleListBox) |
|
79 * EAknCtSingleLargeListBox (See CAknSingleLargeStyleListBox) |
|
80 * EAknCtDoubleListBox (See CAknDoubleStyleListBox) |
|
81 * EAknCtDoubleNumberListBox (See CAknDoubleNumberStyleListBox) |
|
82 * EAknCtDoubleTimeListBox (See CAknDoubleTimeStyleListBox) |
|
83 * EAknCtDoubleLargeListBox (See CAknDoubleLargeStyleListBox) |
|
84 * EAknCtDoubleGraphicListBox (See CAknDoubleGraphicStyleListBox) |
|
85 * |
|
86 * The type field while defining find can be one of the following: |
|
87 * EAknCtSelectionListFixedFind |
|
88 * EAknCtSelectionListPopupFind |
|
89 * |
|
90 * The menubar you give for selection list dialog should have |
|
91 * one of the following as one of its menu panes: (avkon.hrh) |
|
92 * R_AVKON_MENUPANE_SELECTION_LIST |
|
93 * R_AVKON_MENUPANE_SELECTION_LIST_WITH_FIND_POPUP |
|
94 * |
|
95 * RESOURCE MENU_BAR r_res_id_for_a_menubar |
|
96 * { |
|
97 * titles = |
|
98 * { |
|
99 * MENU_TITLE { menu_pane = R_AVKON_MENUPANE_SELECTION_LIST; } |
|
100 * }; |
|
101 * }; |
|
102 * |
|
103 * C++ Usage: |
|
104 * TInt openedItem = 0; |
|
105 * MDesCArray *array = ...; |
|
106 * CCABlockingDialog *dialog = CCABlockingDialog::NewL(openedItem, array, R_RES_ID_FOR_A_MENUBAR); |
|
107 * TInt result = dialog->ExecuteLD(R_RES_ID_FOR_A_DIALOG); |
|
108 * if (result) { ...use openeditem here... } else { ...canceled... } |
|
109 * |
|
110 * Alternatively, you can use: |
|
111 * TInt openedItem = 0; |
|
112 * MDesCArray *array = ...; |
|
113 * CCABlockingDialog *dialog = CCABlockingDialog::NewL(openedItem, array, R_RES_ID_FOR_A_MENUBAR); |
|
114 * dialog->PrepareLC(R_RES_ID_FOR_A_DIALOG); |
|
115 * // do some operations here, for example fill icon array |
|
116 * TInt result = dialog->RunLD(); |
|
117 * if (result) { ... } else { ... } |
|
118 * |
|
119 * Often it is also useful to derive from CCABlockingDialog and implement OkToExitL(), constructors and the NewL() methods. |
|
120 * OkToExitL() implementation helps with providing navigation with other dialogs; OkToExitL() is ideal place to launch |
|
121 * new dialogs when a list item is selected. This way when backstepping, the state of the first dialog is preserved... |
|
122 */ |
|
123 class CCABlockingDialog : public CAknDialog, public MEikListBoxObserver |
|
124 { |
|
125 |
|
126 public: // operands for selection lists |
|
127 /** CCABlockingDialog::NewL() |
|
128 * |
|
129 * aOpenedItem Variable to be modified when user selects a list item. |
|
130 * aArray Content of list items; A tab-separated string with texts and indexes to icon array |
|
131 * aMenuBarResourceId Menu items to be shown in options menu |
|
132 * aCommand Callback for state changes. EAknCmdOpen command is send by listbox. Options menu commands come here too. |
|
133 * @param aDontShowTabGroup For navipane control. |
|
134 */ |
|
135 static CCABlockingDialog *NewL( TInt &aOpenedItem, |
|
136 MDesCArray *aArray, |
|
137 TInt aMenuBarResourceId, |
|
138 TInt aOkMenuBarResourceId, |
|
139 MEikCommandObserver *aCommand = 0, |
|
140 TBool aDontShowTabGroup = EFalse ); |
|
141 static CCABlockingDialog *NewLC( TInt &aOpenedItem, |
|
142 MDesCArray *aArray, |
|
143 TInt aMenuBarResourceId, |
|
144 TInt aOkMenuBarResourceId, |
|
145 MEikCommandObserver *aCommand = 0, |
|
146 TBool aDontShowTabGroup = EFalse ); |
|
147 |
|
148 public: // different options |
|
149 enum TFindType |
|
150 { |
|
151 ENoFind, |
|
152 EFixedFind, |
|
153 EPopupFind |
|
154 }; |
|
155 /** SetupFind() provides a way to enable and disable find and find popup |
|
156 * on runtime. |
|
157 * |
|
158 * You still need entry with id EFindControl to resource file for the find, this is only for disabling |
|
159 * existing find element. |
|
160 */ |
|
161 void SetupFind( TFindType aType ); |
|
162 |
|
163 |
|
164 /* GetFindBoxTextL() returns the text in the FindPane, if the FindPane is empty |
|
165 * returns KNullDesC; |
|
166 * @return const TDesC& |
|
167 */ |
|
168 const TDesC& GetFindBoxTextL() ; |
|
169 |
|
170 /** Icons: IconArray(), SetIconArrayL() |
|
171 * |
|
172 * Icons, images and thumbnails are in this array. |
|
173 * |
|
174 * The list items are tab separated strings with fixed format. Some of the numbers |
|
175 * in the list item strings are indexes to this array. |
|
176 * |
|
177 * This array can be modified by MDesCArray::MdcaPoint() method or at construction of |
|
178 * dialog; after PrepareLC() call. |
|
179 */ |
|
180 CArrayPtr<CGulIcon>* IconArray() const; |
|
181 void SetIconArrayL( CArrayPtr<CGulIcon>* aIcons ); |
|
182 |
|
183 /** |
|
184 * refresh the block dialog title |
|
185 */ |
|
186 void RefreshDialogTitleL(); |
|
187 |
|
188 /** |
|
189 * To handle the deletiontem to the list box |
|
190 */ |
|
191 void HandleItemRemovalL(); |
|
192 |
|
193 /** |
|
194 * To handle the addition of an item to the list box |
|
195 */ |
|
196 void HandleItemAdditionL(); |
|
197 |
|
198 /** |
|
199 * Returns pointer to the listbox being used. |
|
200 */ |
|
201 virtual CEikListBox *ListBox() const; |
|
202 |
|
203 // Destructor |
|
204 ~CCABlockingDialog(); |
|
205 |
|
206 void GetHelpContext( TCoeHelpContext& aContext ) const; |
|
207 |
|
208 /* |
|
209 * Set the iExitEnable a new value |
|
210 * @param aValue The new value to be set |
|
211 */ |
|
212 void SetExitEnabled( TBool aValue ); |
|
213 |
|
214 protected: |
|
215 CCABlockingDialog( TInt &aIndex, |
|
216 MDesCArray *aArray, |
|
217 TInt aMenuBarResourceId, |
|
218 TInt aOkMenuBarResourceId, |
|
219 MEikCommandObserver *aCommand, |
|
220 TBool aDontShowTabGroup ); |
|
221 public: // Customisation from derived classes |
|
222 /** SelectionListProcessCommandL() handles selection list and markable list |
|
223 * default commands. |
|
224 * |
|
225 * For markable lists, this method handles EAknCmdMark, EAknCmdUnmark, EAknMarkAll, EAknUnmarkAll |
|
226 * defined in options menu pane R_AVKON_MENUPANE_MARKABLE_LIST. |
|
227 */ |
|
228 virtual void SelectionListProcessCommandL( TInt aCommand ); |
|
229 |
|
230 protected: |
|
231 /** IsAcceptableListType(): Detection of list and grid layouts |
|
232 * |
|
233 * The CCCABlockingDialog only works with certain list and grid |
|
234 * layouts. |
|
235 * |
|
236 * You will get Panic() if you use your own list/grid layouts and |
|
237 * you do not have this method implemented! |
|
238 * |
|
239 * If you add new list layouts, you should implement this method to |
|
240 * publish the type of the layout using this method. This is especially |
|
241 * the case where you use CAknSelectionGrid with your own grid layout. |
|
242 * (as there are no predefined grid layouts, you need to do this |
|
243 * every time you use a selection grid) |
|
244 * |
|
245 * The following aControlTypes are already implemented and requires |
|
246 * no action: |
|
247 * EAknCtSingleListBox |
|
248 * EAknCtSingleNumberListBox |
|
249 * EAknCtSingleHeadingListBox |
|
250 * EAknCtSingleGraphicListBox |
|
251 * EAknCtSingleGraphicHeadingListBox |
|
252 * EAknCtSingleNumberHeadingListBox |
|
253 * EAknCtSingleLargeListBox |
|
254 * EAknCtDoubleListBox |
|
255 * EAknCtDoubleNumberListBox |
|
256 * EAknCtDoubleTimeListBox |
|
257 * EAknCtDoubleLargeListBox |
|
258 * EAknCtDoubleGraphicListBox |
|
259 * EAknCtSettingListBox |
|
260 * EAknCtSettingNumberListBox |
|
261 * |
|
262 * Any other layout requires you to inherit from CCCABlockingDialog |
|
263 * and implement the following methods: |
|
264 * TBool IsAcceptableListBoxType(TInt aControlType, TBool &aIsFormattedCellList) |
|
265 * { |
|
266 * if (aControlType == EMyCtGridLayout) |
|
267 * { |
|
268 * // CAknGrid is-a formattedcelllistbox. |
|
269 * aIsFormattedCellList = ETrue; |
|
270 * return ETrue; |
|
271 * } |
|
272 * else |
|
273 * return EFalse; |
|
274 * } |
|
275 * |
|
276 * See also CreateCustomControlL(). IsAcceptableListType() and CreateCustomControlL() forms a pair that should |
|
277 * be implemented together. |
|
278 */ |
|
279 virtual TBool IsAcceptableListBoxType( TInt aControlType, TBool &aIsFormattedCellList ) const; |
|
280 |
|
281 /** |
|
282 * Second phase constructor. |
|
283 */ |
|
284 void ConstructL( TInt aMenuBarResourceId ); |
|
285 |
|
286 protected: |
|
287 |
|
288 /** |
|
289 * Processes user commands. |
|
290 * @see MEikCommandObserver |
|
291 */ |
|
292 void ProcessCommandL( TInt aCommandId ); |
|
293 |
|
294 /** |
|
295 * From CEikDialog : Prepare for opening dialog. |
|
296 */ |
|
297 void PreLayoutDynInitL(); |
|
298 |
|
299 /** |
|
300 * @see CAknDialog |
|
301 * @since S60 v3.1 |
|
302 */ |
|
303 void SetSizeAndPosition( const TSize &aSize ); |
|
304 |
|
305 /** |
|
306 * @see CAknDialog |
|
307 * @since S60 v3.1 |
|
308 */ |
|
309 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
310 |
|
311 /** |
|
312 * From CEikDialog. Called when dialog is dismissed |
|
313 * @see CEikDialog |
|
314 */ |
|
315 TBool OkToExitL( TInt aButtonId ); |
|
316 |
|
317 /** |
|
318 * Handles list box event |
|
319 */ |
|
320 void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType ); |
|
321 |
|
322 /** |
|
323 * From CoeControl, Returns the number of control contained by this |
|
324 * class. |
|
325 * @see CCoeControl |
|
326 */ |
|
327 TInt CountComponentControls() const; |
|
328 |
|
329 /** |
|
330 * From CCoeControl, Returns handle to control pointed by aIndex |
|
331 * @param aIndex Wanted control's index [0..n] |
|
332 * @return Handle to wanted control |
|
333 */ |
|
334 CCoeControl* ComponentControl( TInt aIndex ) const; |
|
335 |
|
336 /** |
|
337 * From CCoeControl. Handles the keyevents |
|
338 * @param aKeyEvent The key event. |
|
339 * @param aType The type of key event: EEventKey, |
|
340 * EEventKeyUp or EEventKeyDown. |
|
341 * @return Indicates whether or not the key event |
|
342 * was used by this control |
|
343 */ |
|
344 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
345 |
|
346 /** CreateCustomControlL() creates own list or grid layouts. |
|
347 * |
|
348 * Normal implementation of this method is: |
|
349 * SEikControlInfo CreateCustomControlL(TInt aControlType) |
|
350 * { |
|
351 * CCoeControl *control = NULL; |
|
352 * if (aControlType == EMyCtGridLayout) |
|
353 * { |
|
354 * // CMyOddStyleGrid should be derived from CAknFormattedCellListBox or CEikColumnListBox. |
|
355 * control = new(ELeave)CMyOddStyleGrid; |
|
356 * } |
|
357 * SEikControlInfo info = {control,0,0}; |
|
358 * return info; |
|
359 * } |
|
360 * See also IsAcceptableListType(). CreateCustomControlL() and IsAcceptableListType() forms a pair that should |
|
361 * be implemented together. |
|
362 */ |
|
363 SEikControlInfo CreateCustomControlL( TInt aControlType ); |
|
364 |
|
365 /** |
|
366 * From CoeControl. Called when focus changed |
|
367 * @see CCoeControl |
|
368 */ |
|
369 void FocusChanged(TDrawNow aDrawNow); |
|
370 |
|
371 private: |
|
372 /** |
|
373 * ResetFindBoxL : clear all character from findbox |
|
374 */ |
|
375 void ResetFindBoxL(); |
|
376 |
|
377 /** |
|
378 * Layouts current components according to AVKON LAF |
|
379 */ |
|
380 void SetLayout(); |
|
381 |
|
382 protected: |
|
383 |
|
384 // Returns the type do findbox being used. |
|
385 CAknSearchField *FindBox() const; |
|
386 |
|
387 TBool IsFormattedCellListBox() const; |
|
388 |
|
389 void Draw( const TRect& ) const; |
|
390 |
|
391 /** |
|
392 * From MEikMenuObserver, Called by framework before |
|
393 * constructing menupane |
|
394 * @param aResourceId Resource to be constructed |
|
395 * @param aMenuPane Pointer to menupane being constructed |
|
396 */ |
|
397 void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ); |
|
398 |
|
399 /** |
|
400 * Show context sensitive menubar |
|
401 */ |
|
402 void ShowContextMenuL(); |
|
403 |
|
404 protected: |
|
405 TBool iEnterKeyPressed; |
|
406 private: |
|
407 |
|
408 TFindType iFindType; |
|
409 TInt *iSelectedItem; |
|
410 |
|
411 //Does not own |
|
412 MDesCArray *iArray; |
|
413 |
|
414 //Does not own |
|
415 MEikCommandObserver *iCmdObserver; |
|
416 |
|
417 TInt iDialogResourceId; |
|
418 TInt iMenuBarResourceId; |
|
419 TInt iOkMenuBarResourceId; |
|
420 |
|
421 //Handle to titlepane. doesn't own |
|
422 CCAStatusPaneHandler* iTitlePane; |
|
423 |
|
424 // ETrue if findbox is enabled |
|
425 // else EFalse |
|
426 TBool iFindBoxEnabled; |
|
427 |
|
428 /// ETrue if we can not show tabgroup after desctruction of this class. |
|
429 /// EFalse if we can show. |
|
430 TBool iDontShowTabGroup; |
|
431 |
|
432 //Holds the text entered in the FindPane |
|
433 //Owns - has to be freed |
|
434 HBufC* iFindPaneText; |
|
435 |
|
436 // ETrue if we can shut the dialog. |
|
437 // EFalse if we can not. |
|
438 TBool iExitEnabled; |
|
439 |
|
440 // ETrue if touch event is allowed |
|
441 // EFalse if touch event is not allowed |
|
442 TBool iAllowPenEvent; |
|
443 }; |
|
444 |
|
445 |
|
446 |
|
447 #endif |