2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * CAknProgressDialog should be used when the progress of the process
16 * can be traced and the length of the process is known. If that's not
17 * the case please use CAknWaitDialog.
22 #ifndef __AKN_PROGRESS_DIALOG__
23 #define __AKN_PROGRESS_DIALOG__
25 #include <aknnotedialog.h>
26 #include <aknprogresstimer.h>
28 class CEikProgressInfo;
31 * MProgressDialogCallBack
32 * Inherit from this class and implement DialogDismissed to
33 * get a callback when/if a dialog is dismissed.
35 class MProgressDialogCallback
40 * Gets called when a dialog is dismissed.
42 virtual void DialogDismissedL( TInt aButtonId ) = 0;
49 * A note dialog with a timer. Display the note only if the process is at least 1 second long
50 * in order to avoid a note quickly flashing on the screen. Display the note for at least 1.5
51 * seconds (even if the client process is shorter that this). The client can specify an initial
52 * delay when displaying the note. Timer events are used for displaying and dismissing the dialog.
53 * The client can set the progress by specifying the values in the constructors provided.
56 * <LI> Fixed process length
58 * iProgressDialog = new(ELeave)CAknProgressDialog(model->FinalValue(),model->Increment(),
60 * (REINTERPRET_CAST(CEikDialog**,&iProgressDialog)));
61 * iProgressDialog->ExecuteLD(R_PROGRESS_NOTE);
64 * <LI> Variable process length
66 * iProgressDialog = new(ELeave)CAknProgressDialog(
67 * (REINTERPRET_CAST(CEikDialog**,&iProgressDialog)));
68 * iProgressInfo = iProgressDialog->GetProgressInfoL();
69 * iProgressInfo->SetFinalValue(model->FinalValue());
70 * iProgressDialog->ExecuteLD(R_PROGRESS_NOTE);
72 * // Incrementing progress of the process:
73 * iProgressInfo->IncrementAndDraw(model->Increment());
76 * iProgressDialog->ProcessFinishedL(); // deletes the dialog
78 * <LI> Variable process length, modal dialog
80 * Set following flags in resources: EEikDialogFlagWait and EAknProgressNoteFlags
82 * iProgressDialog = new(ELeave)CAknProgressDialog(
83 * (REINTERPRET_CAST(CEikDialog**,&iProgressDialog)));
84 * iProgressInfo = iProgressDialog->GetProgressInfoL();
85 * iProgressInfo->SetFinalValue(model->FinalValue());
86 * iProgressInfo->SetTone( CAknNoteDialog::EConfirmationTone );
87 * iProgressDialog->ExecuteLD(R_PROGRESS_NOTE);
89 * // Incrementing progress of the process:
90 * iProgressInfo->IncrementAndDraw(model->Increment());
93 * iProgressDialog->ProcessFinishedL(); // deletes the dialog
95 * <LI> Setting label dynamically
97 * iProgressDialog = new(ELeave)CAknProgressDialog(
98 * (REINTERPRET_CAST(CEikDialog**,&iProgressDialog)));
99 * iProgressDialog->PrepareLC(R_PROGRESS_NOTE);
100 * iProgressDialog->SetTextL(_L("Hello AVKON!"));
101 * iProgressDialog->RunLD();
105 * To get a callback when/if the dialog has been dismissed
106 * use SetCallBack API:
107 * With class which uses a progressdialog:
108 * - Inherit from pure virtual class MProgressDialogCallback
109 * - Implement DialogDismissedL
110 * - Call CAknProgressDialog->SetCallback(this);
112 * Or make your dialog modal. If the dialog is used as a modal, RunLD
113 * returns 0 if the dialog is dismissed and EAknSoftkeyDone if not.
116 * - Always set EEikDialogFlagNotifyEsc. (or use preset avkon
117 * dialog resource flag, i.e. EAknProgressNoteFlags).
118 * - To make a dialog modal use EEikDialogFlagWait
120 * <P>Note! If aVisibilityDelayOff is set to ETrue in constructor the dialog
121 * will be visible immediality. This should only be used in cases where
122 * the process lasts ALWAYS atleast 1.5 seconds.
124 * <P> For comprehensive example, see \Akndemo\Notesapp </P>
127 class CAknProgressDialog : public CAknNoteDialog
132 * Use this when the length (in time) of the process is known.
133 * @param aFinalValue Final value for the process
134 * @param anIncrement Increment of the process
135 * @param anInterval Interval of the process
136 * @param aSelfPtr Pointer to itself. The pointer must be
137 * valid when the dialog is dismissed and it
138 * must not be on the stack.
140 IMPORT_C CAknProgressDialog(TInt aFinalValue,TInt anIncrement,TInt anInterval, CEikDialog** aSelfPtr);
144 * Use this if the length of the process is unknown but the progress
146 * @param aSelfPtr Pointer to itself. The pointer must be
147 * valid when the dialog is dismissed and it
148 * must not be on the stack.
150 IMPORT_C CAknProgressDialog(CEikDialog** aSelfPtr);
154 * Use this if the length of the process is unknown but the progress
156 * @param aSelfPtr Pointer to itself. The pointer must be
157 * valid when the dialog is dismissed and it must
158 * not be on the stack.
159 * @param aVisibilityDelayOff If set ETrue the dialog will be visible
160 * immediality. Use only when the length of
161 * the process is ALWAYS over 1.5 seconds.
163 IMPORT_C CAknProgressDialog(CEikDialog** aSelfPtr,TBool aVisibilityDelayOff);
168 IMPORT_C virtual ~CAknProgressDialog();
171 * Executes the dialog (part of dialog framework).
172 * PrepareLC needs to be called before this.
174 IMPORT_C virtual TInt RunLD();
177 * Get a handle to the progress bar.
179 IMPORT_C CEikProgressInfo* GetProgressInfoL();
182 * Handle key events (part of CONE framework)
184 IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
187 * This must be called when the dialog must be dismissed.
188 * It stops the timer and deletes the dialog.
190 IMPORT_C void ProcessFinishedL();
193 * This callback notifies the client when the dialog is dismissed.
194 * @param aCallBack A pointer to a class that inherits from
195 * MProgressDialogCallback.
197 IMPORT_C void SetCallback( MProgressDialogCallback* aCallback );
200 * HandlePointerEventL processes pointer events directed at the
202 * @param aPointerEvent Pointerevent to be handled.
204 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
208 * Enumeration to handle progress states
210 enum TProgressDialogState
212 EProcessOnDisplayOff, /// cannot be dismissed
213 EProcessOnDisplayOn, /// cannot be dismissed
214 EProcessOffDisplayOff, /// can be dismissed
215 EProcessOffDisplayOn, /// cannot be dismissed
216 EProcessOffDisplayOnCanBeDismissed, /// can be dismissed
217 EProcessOnDisplayOnCanBeDismissed /// can be dismissed when process ends
221 * Initializes dialog before layout is executed (part of dialog framework).
223 IMPORT_C void PreLayoutDynInitL(void);
228 * @param aPtr Pointer to this
230 static TInt DialogTimerCallback(TAny* aPtr);
233 * Handles timer events.
235 TInt DialogTimerEvent();
238 * Called by the dialog framework, returns true if the
239 * dialog can exit, false otherwise.
241 * @param aButtonId Id of the softkey which was pressed
242 * @return ETrue if the dialog can exit, false otherwise.
244 IMPORT_C TBool OkToExitL(TInt aButtonId);
250 IMPORT_C void* ExtensionInterface( TUid aInterface );
253 /// Timer to handle dialog's visibility and existence
254 CPeriodic* iProgressDialogTimer;
255 /// State to handle dialog's visibility and existence
256 TProgressDialogState iState;
257 /// Contains progress timer's variables
260 MProgressDialogCallback* iCallback;
261 /// Boolean to declare whether the visibility delay should
263 TBool iVisibilityDelayOff;
266 // Boolean to declare whether the progress is handled by
268 TBool iInternalTimerControl;
269 // Timer to handle progress if iInternalTimerControl is
271 CAknProgressTimer* iProgressTimer;
273 class CCancelWhileHidden;
274 CCancelWhileHidden* iCancelWhileHidden;
279 IMPORT_C virtual void CEikDialog_Reserved_1();
280 IMPORT_C virtual void CEikDialog_Reserved_2();
282 IMPORT_C virtual void CAknNoteDialog_Reserved();