epoc32/include/mw/aknprogressdialog.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description: 
williamr@2
    15
*       CAknProgressDialog should be used when the progress of the process
williamr@2
    16
*       can be traced and the length of the process is known. If that's not
williamr@2
    17
*       the case please use CAknWaitDialog.
williamr@2
    18
*
williamr@2
    19
*/
williamr@2
    20
williamr@2
    21
williamr@2
    22
#ifndef __AKN_PROGRESS_DIALOG__
williamr@2
    23
#define __AKN_PROGRESS_DIALOG__
williamr@2
    24
williamr@2
    25
#include <aknnotedialog.h>
williamr@2
    26
#include <aknprogresstimer.h>
williamr@2
    27
williamr@2
    28
class CEikProgressInfo;
williamr@2
    29
williamr@2
    30
/**
williamr@2
    31
 * MProgressDialogCallBack
williamr@2
    32
 *   Inherit from this class and implement DialogDismissed to
williamr@2
    33
 *   get a callback when/if a dialog is dismissed.
williamr@2
    34
 */
williamr@2
    35
class MProgressDialogCallback
williamr@2
    36
    {
williamr@2
    37
    public:
williamr@2
    38
        /**
williamr@2
    39
        * Callback method
williamr@2
    40
        *   Gets called when a dialog is dismissed.
williamr@2
    41
        */
williamr@2
    42
        virtual void DialogDismissedL( TInt aButtonId ) = 0;
williamr@2
    43
    };
williamr@2
    44
williamr@2
    45
williamr@2
    46
/**
williamr@2
    47
* CAknProgressDialog
williamr@2
    48
*
williamr@2
    49
* A note dialog with a timer. Display the note only if the process is at least 1 second long
williamr@2
    50
* in order to avoid a note quickly flashing on the screen. Display the note for at least 1.5
williamr@2
    51
* seconds (even if the client process is shorter that this). The client can specify an initial
williamr@2
    52
* delay when displaying the note. Timer events are used for displaying and dismissing the dialog.
williamr@2
    53
* The client can set the progress by specifying the values in the constructors provided.
williamr@2
    54
*
williamr@2
    55
* Usage:<UL> 
williamr@2
    56
*   <LI> Fixed process length
williamr@2
    57
*      
williamr@2
    58
*        iProgressDialog = new(ELeave)CAknProgressDialog(model->FinalValue(),model->Increment(),
williamr@2
    59
*                                model->Interval(),
williamr@2
    60
*                                (REINTERPRET_CAST(CEikDialog**,&iProgressDialog)));
williamr@2
    61
*        iProgressDialog->ExecuteLD(R_PROGRESS_NOTE);
williamr@2
    62
*   </LI>
williamr@2
    63
*
williamr@2
    64
*   <LI> Variable process length
williamr@2
    65
*      
williamr@2
    66
*        iProgressDialog = new(ELeave)CAknProgressDialog(
williamr@2
    67
*                                (REINTERPRET_CAST(CEikDialog**,&iProgressDialog)));
williamr@2
    68
*        iProgressInfo = iProgressDialog->GetProgressInfoL();
williamr@2
    69
*        iProgressInfo->SetFinalValue(model->FinalValue());
williamr@2
    70
*        iProgressDialog->ExecuteLD(R_PROGRESS_NOTE);
williamr@2
    71
* 
williamr@2
    72
*        // Incrementing progress of the process:
williamr@2
    73
*        iProgressInfo->IncrementAndDraw(model->Increment());
williamr@2
    74
* 
williamr@2
    75
*        // Process finished
williamr@2
    76
*        iProgressDialog->ProcessFinishedL(); // deletes the dialog
williamr@2
    77
*   </LI> 
williamr@2
    78
*   <LI> Variable process length, modal dialog
williamr@2
    79
*      
williamr@2
    80
*        Set following flags in resources: EEikDialogFlagWait and EAknProgressNoteFlags
williamr@2
    81
*
williamr@2
    82
*        iProgressDialog = new(ELeave)CAknProgressDialog(
williamr@2
    83
*                                (REINTERPRET_CAST(CEikDialog**,&iProgressDialog)));
williamr@2
    84
*        iProgressInfo = iProgressDialog->GetProgressInfoL();
williamr@2
    85
*        iProgressInfo->SetFinalValue(model->FinalValue());
williamr@2
    86
*        iProgressInfo->SetTone( CAknNoteDialog::EConfirmationTone );
williamr@2
    87
*        iProgressDialog->ExecuteLD(R_PROGRESS_NOTE);
williamr@2
    88
* 
williamr@2
    89
*        // Incrementing progress of the process:
williamr@2
    90
*        iProgressInfo->IncrementAndDraw(model->Increment());
williamr@2
    91
* 
williamr@2
    92
*        // Process finished
williamr@2
    93
*        iProgressDialog->ProcessFinishedL(); // deletes the dialog
williamr@2
    94
*
williamr@2
    95
*   <LI> Setting label dynamically
williamr@2
    96
*     
williamr@2
    97
*        iProgressDialog = new(ELeave)CAknProgressDialog(
williamr@2
    98
*                                (REINTERPRET_CAST(CEikDialog**,&iProgressDialog)));
williamr@2
    99
*        iProgressDialog->PrepareLC(R_PROGRESS_NOTE);
williamr@2
   100
*        iProgressDialog->SetTextL(_L("Hello AVKON!"));
williamr@2
   101
*        iProgressDialog->RunLD();
williamr@2
   102
*
williamr@2
   103
*    </LI></UL>
williamr@2
   104
* <P>Callback:
williamr@2
   105
*       To get a callback when/if the dialog has been dismissed
williamr@2
   106
*       use SetCallBack API:
williamr@2
   107
*           With class which uses a progressdialog:
williamr@2
   108
*           - Inherit from pure virtual class MProgressDialogCallback
williamr@2
   109
*           - Implement DialogDismissedL
williamr@2
   110
*           - Call CAknProgressDialog->SetCallback(this);
williamr@2
   111
*       
williamr@2
   112
*       Or make your dialog modal. If the dialog is used as a modal, RunLD
williamr@2
   113
*       returns 0 if the dialog is dismissed and EAknSoftkeyDone if not.
williamr@2
   114
* </P>
williamr@2
   115
* <P>Resource flags:
williamr@2
   116
*        -   Always set EEikDialogFlagNotifyEsc. (or use preset avkon
williamr@2
   117
*                   dialog resource flag, i.e. EAknProgressNoteFlags).
williamr@2
   118
*        -   To make a dialog modal use EEikDialogFlagWait
williamr@2
   119
* </P>
williamr@2
   120
* <P>Note! If aVisibilityDelayOff is set to ETrue in constructor the dialog
williamr@2
   121
*   will be visible immediality. This should only be used in cases where
williamr@2
   122
*   the process lasts ALWAYS atleast 1.5 seconds.
williamr@2
   123
* </P>
williamr@2
   124
*  <P> For comprehensive example, see \Akndemo\Notesapp </P>
williamr@2
   125
*/
williamr@2
   126
williamr@2
   127
class CAknProgressDialog : public CAknNoteDialog  
williamr@2
   128
{
williamr@2
   129
public:
williamr@2
   130
    /**
williamr@2
   131
    * Constructor
williamr@2
   132
    *   Use this when the length (in time) of the process is known.
williamr@2
   133
    * @param    aFinalValue     Final value for the process
williamr@2
   134
    * @param    anIncrement     Increment of the process
williamr@2
   135
    * @param    anInterval      Interval of the process
williamr@2
   136
    * @param    aSelfPtr        Pointer to itself. The pointer must be
williamr@2
   137
    *                           valid when the dialog is dismissed and it 
williamr@2
   138
	*                           must not be on the stack.
williamr@2
   139
    */
williamr@2
   140
	IMPORT_C CAknProgressDialog(TInt aFinalValue,TInt anIncrement,TInt anInterval, CEikDialog** aSelfPtr);
williamr@2
   141
williamr@2
   142
    /**
williamr@2
   143
    * Constructor
williamr@2
   144
    *   Use this if the length of the process is unknown but the progress
williamr@2
   145
    *   can be calculated.
williamr@2
   146
    * @param    aSelfPtr        Pointer to itself. The pointer must be
williamr@2
   147
    *                           valid when the dialog is dismissed and it
williamr@2
   148
	*                           must not be on the stack.
williamr@2
   149
    */
williamr@2
   150
	IMPORT_C CAknProgressDialog(CEikDialog** aSelfPtr);
williamr@2
   151
williamr@2
   152
    /**
williamr@2
   153
    * Constructor
williamr@2
   154
    *   Use this if the length of the process is unknown but the progress
williamr@2
   155
    *   can be calculated.
williamr@2
   156
    * @param    aSelfPtr        Pointer to itself. The pointer must be
williamr@2
   157
    *                           valid when the dialog is dismissed and it must
williamr@2
   158
	*                           not be on the stack.
williamr@2
   159
    * @param    aVisibilityDelayOff If set ETrue the dialog will be visible
williamr@2
   160
    *                                   immediality. Use only when the length of
williamr@2
   161
    *                                   the process is ALWAYS over 1.5 seconds.
williamr@2
   162
    */
williamr@2
   163
	IMPORT_C CAknProgressDialog(CEikDialog** aSelfPtr,TBool aVisibilityDelayOff);
williamr@2
   164
williamr@2
   165
    /**
williamr@2
   166
    * Destructor
williamr@2
   167
    */
williamr@2
   168
	IMPORT_C virtual ~CAknProgressDialog();
williamr@2
   169
williamr@2
   170
	/**
williamr@2
   171
    * Executes the dialog (part of dialog framework).
williamr@2
   172
	* PrepareLC needs to be called before this. 
williamr@2
   173
    */
williamr@2
   174
	IMPORT_C virtual TInt RunLD();
williamr@2
   175
williamr@2
   176
    /**
williamr@2
   177
    *   Get a handle to the progress bar.
williamr@2
   178
    */
williamr@2
   179
	IMPORT_C CEikProgressInfo* GetProgressInfoL();
williamr@2
   180
williamr@2
   181
    /**
williamr@2
   182
    *  Handle key events (part of CONE framework)
williamr@2
   183
    */
williamr@2
   184
    IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
williamr@2
   185
williamr@2
   186
    /**
williamr@2
   187
    * This must be called when the dialog must be dismissed. 
williamr@2
   188
	* It stops the timer and deletes the dialog.
williamr@2
   189
    */
williamr@2
   190
    IMPORT_C void ProcessFinishedL();
williamr@2
   191
williamr@2
   192
    /**
williamr@2
   193
    * This callback notifies the client when the dialog is dismissed.
williamr@2
   194
    * @param    aCallBack   A pointer to a class that inherits from
williamr@2
   195
    *                       MProgressDialogCallback.
williamr@2
   196
    */
williamr@2
   197
    IMPORT_C void SetCallback( MProgressDialogCallback* aCallback );
williamr@2
   198
    
williamr@2
   199
     /**
williamr@2
   200
	 * HandlePointerEventL processes pointer events directed at the 
williamr@2
   201
	 * ProgressDialog.
williamr@2
   202
	 * @param aPointerEvent Pointerevent to be handled.
williamr@2
   203
	 */
williamr@2
   204
    IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
williamr@2
   205
williamr@2
   206
protected:
williamr@2
   207
    /**
williamr@2
   208
    * Enumeration to handle progress states
williamr@2
   209
    */
williamr@2
   210
    enum TProgressDialogState
williamr@2
   211
        {
williamr@2
   212
        EProcessOnDisplayOff, /// cannot be dismissed
williamr@2
   213
        EProcessOnDisplayOn, /// cannot be dismissed
williamr@2
   214
        EProcessOffDisplayOff, /// can be dismissed
williamr@2
   215
        EProcessOffDisplayOn, /// cannot be dismissed
williamr@2
   216
        EProcessOffDisplayOnCanBeDismissed, /// can be dismissed
williamr@2
   217
        EProcessOnDisplayOnCanBeDismissed /// can be dismissed when process ends
williamr@2
   218
        };
williamr@2
   219
williamr@2
   220
    /**
williamr@2
   221
    *   Initializes dialog before layout is executed (part of dialog framework).
williamr@2
   222
    */
williamr@2
   223
    IMPORT_C void PreLayoutDynInitL(void);
williamr@2
   224
williamr@2
   225
    /**
williamr@2
   226
    * Timer callback.
williamr@2
   227
	*
williamr@2
   228
    * @param aPtr   Pointer to this
williamr@2
   229
    */
williamr@2
   230
    static TInt DialogTimerCallback(TAny* aPtr);
williamr@2
   231
williamr@2
   232
    /**
williamr@2
   233
    *   Handles timer events.
williamr@2
   234
    */
williamr@2
   235
    TInt DialogTimerEvent();
williamr@2
   236
williamr@2
   237
    /**
williamr@2
   238
    * Called by the dialog framework, returns true if the 
williamr@2
   239
	* dialog can exit, false otherwise.
williamr@2
   240
	*
williamr@2
   241
    * @param aButtonId  Id of the softkey which was pressed
williamr@2
   242
    * @return           ETrue if the dialog can exit, false otherwise.
williamr@2
   243
    */
williamr@2
   244
    IMPORT_C TBool OkToExitL(TInt aButtonId);
williamr@2
   245
williamr@2
   246
private:
williamr@2
   247
    /**
williamr@2
   248
    * From CAknControl
williamr@2
   249
    */
williamr@2
   250
    IMPORT_C void* ExtensionInterface( TUid aInterface );
williamr@2
   251
williamr@2
   252
protected:
williamr@2
   253
    /// Timer to handle dialog's visibility and existence
williamr@2
   254
    CPeriodic* iProgressDialogTimer;
williamr@2
   255
    /// State to handle dialog's visibility and existence
williamr@2
   256
    TProgressDialogState iState;
williamr@2
   257
    /// Contains progress timer's variables
williamr@2
   258
    TTimerModel iModel;
williamr@2
   259
    /// Callback pointer
williamr@2
   260
    MProgressDialogCallback* iCallback;
williamr@2
   261
    /// Boolean to declare whether the visibility delay should
williamr@2
   262
    ///  be on or off.
williamr@2
   263
    TBool iVisibilityDelayOff;
williamr@2
   264
williamr@2
   265
private:
williamr@2
   266
    // Boolean to declare whether the progress is handled by
williamr@2
   267
    //  an internal timer
williamr@2
   268
	TBool iInternalTimerControl;
williamr@2
   269
    // Timer to handle progress if iInternalTimerControl is
williamr@2
   270
    //  set to ETrue
williamr@2
   271
    CAknProgressTimer* iProgressTimer;
williamr@2
   272
williamr@2
   273
	class CCancelWhileHidden;
williamr@2
   274
	CCancelWhileHidden* iCancelWhileHidden;
williamr@2
   275
	
williamr@2
   276
    TInt iSpare[3];
williamr@2
   277
williamr@2
   278
private: 
williamr@2
   279
	IMPORT_C virtual void CEikDialog_Reserved_1();
williamr@2
   280
	IMPORT_C virtual void CEikDialog_Reserved_2();	
williamr@2
   281
private: 
williamr@2
   282
	IMPORT_C virtual void CAknNoteDialog_Reserved();
williamr@2
   283
};
williamr@2
   284
williamr@2
   285
#endif