epoc32/include/mw/aknqueryvalueduration.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.
     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: 
    15 *
    16 */
    17 
    18 // AknQueryValueDuration.h
    19 //
    20 // Copyright (c) 2001 Symbian Ltd.  All rights reserved.
    21 //
    22 
    23 #if !defined(__AKNQUERYVALUEDURATION_H__)
    24 #define __AKNQUERYVALUEDURATION_H__
    25 
    26 #include <bamdesca.h>
    27 #include <eikdialg.h>
    28 #include "AknQueryValue.h"
    29 
    30 class CAknQueryValueDurationArray;
    31 
    32 /**
    33  * Encapsulates a TTimeIntervalSeconds. Provides an interface to create a dialog
    34  * containing a duration query control, which will edit the value. Optionally 
    35  * allows the value to be changed by selecting from a list of values. 
    36  *
    37  */
    38 NONSHARABLE_CLASS(CAknQueryValueDuration) : public CAknQueryValue
    39     {
    40 public:
    41     /**
    42      * Two-phased constructor.
    43      *
    44     */
    45 	IMPORT_C static CAknQueryValueDuration* NewL();
    46 	
    47     /**
    48      * Two-phased constructor.
    49      *
    50     */
    51 	IMPORT_C static CAknQueryValueDuration* NewLC();
    52     IMPORT_C virtual ~CAknQueryValueDuration();
    53     
    54     /**
    55      * Set the array.
    56      * 
    57      * @param aArray pointer to array, ownership is not passed
    58     */
    59 	IMPORT_C void SetArrayL(const CAknQueryValueDurationArray* aArray);
    60 	
    61     /**
    62      * Set the string used for the query caption to be a string other than the default.
    63      *
    64      * @param aResourceId		resource id of string to use for caption.
    65      *
    66     */
    67 	IMPORT_C void SetQueryCaption(TInt aResourceId);
    68 	
    69     /**
    70      * Return the current value, which may have been set by the user
    71      *
    72     */
    73 	IMPORT_C TTimeIntervalSeconds Value() const;
    74 	
    75 public: // from MAknQueryValue
    76     IMPORT_C virtual const MDesCArray* MdcArray() const;
    77     IMPORT_C virtual HBufC* CurrentValueTextLC();
    78     IMPORT_C virtual TInt CurrentValueIndex() const;
    79     IMPORT_C virtual void SetCurrentValueIndex(const TInt aIndex);
    80     IMPORT_C virtual TBool CreateEditorL();
    81 protected:
    82 	CAknQueryValueDuration();
    83 	
    84     /**
    85      * 2nd stage construction.
    86      *
    87     */
    88 	void ConstructL();
    89 	
    90 	/**
    91      * Search for the current value in the list, and set the curent index 
    92      * to be the found index. If not found, set current index to 1 after the size of the array.
    93      *
    94      */
    95 	void CalculateCurrentIndex();
    96 	
    97 	virtual void AppendValueIfNewL();
    98 private: // from MAknQueryValue
    99 	IMPORT_C void Reserved_MAknQueryValue();
   100 private:
   101 	// the following are member variables
   102 	TInt iQueryCaptionId;
   103 	TTimeIntervalSeconds iDuration;
   104 	TInt iCurrentIndex;
   105 	// the following are not owned
   106 	const CAknQueryValueDurationArray* iArray;
   107     };
   108 
   109 
   110 /**
   111  * Wraps an array of numeric values, adapts it into a descriptor array.
   112  *
   113  */
   114 NONSHARABLE_CLASS(CAknQueryValueDurationArray) : public CBase, public MDesCArray
   115 	{
   116 public:
   117     /**
   118      * Typedef for array containing TTimeIntervalSeconds items
   119      *
   120     */
   121 	typedef CArrayFix<TTimeIntervalSeconds> DurationArray;
   122 	
   123 	enum {KSafeSizeOfDescriptorForDurationFormat = 32};
   124 	
   125 public:
   126     /**
   127      * Two-phased constructor..
   128      *
   129      * @param aResourceId	Recource id of a TBUF containing a duration format string. Client
   130      *							can use R_AVKON_TBUF_POPUP_FIELD_DEFAULT_DURATION_FORMAT
   131      *							if desired, or provide its own resource. (must be at least "%d%d%d")
   132     */
   133 	IMPORT_C static CAknQueryValueDurationArray* NewL(TInt aResourceId);
   134 	
   135     /**
   136      * See NewL
   137      *
   138     */
   139 	IMPORT_C static CAknQueryValueDurationArray* NewLC(TInt aResourceId);
   140 	
   141 	IMPORT_C ~CAknQueryValueDurationArray();
   142 	
   143     /**
   144      * Set the array of values. 
   145      * Note that client can use any implementation of array class, but must pass in a 
   146      * TArray generated from it (by calling the Array() method on the array class)
   147      *
   148      * @param aArray   array of values, ownership is not passed
   149     */
   150 	IMPORT_C void SetArray(DurationArray& aArray);
   151 	
   152     /**
   153      * Get the array of values as a TArray. 
   154      * Note that client can use any implementation of array class, but the array is 
   155      * treated as a TArray.
   156      *
   157      * @return array of values, ownership is not passed
   158     */
   159 	IMPORT_C DurationArray* Array() const;
   160 	
   161     /**
   162      * Return the TTime format string that is used to generate MDesCArray values
   163      *
   164      * @return format string
   165     */
   166 	IMPORT_C const HBufC* FormatString() const;
   167 	
   168     /**
   169      * Return the size of a maximal time string formated using the format string 
   170      * that was supplied during construction of this instance.
   171      * Two versions to eliminate compiler warnings.
   172      *
   173      * @return length of formatted string.
   174     */
   175 #ifdef __WINS__    
   176 	IMPORT_C const TInt FormattedStringSize() const;
   177 #else
   178 	IMPORT_C TInt FormattedStringSize() const;
   179 #endif // __WINS__
   180 
   181    /**
   182     * Format a descriptor with the textual version of a duration, formated according to the format string. 
   183      * Number of hours is not bounded.
   184      *
   185      * @param aText descriptor to be filled, must be of sufficient size
   186      * @param aDuration the interval to be formatted
   187      *
   188     */
   189 	IMPORT_C void FormatDuration(TPtr& aText, TTimeIntervalSeconds aDuration) const;
   190 	
   191 public:
   192 	// from MDesCArray
   193     /**
   194      * @return count of contained array
   195      *
   196     */    
   197     IMPORT_C virtual TInt MdcaCount() const;
   198     
   199     /**
   200      * Returns array element, converting value to text. 
   201      * <p> WARNING: the returned pointer is only valid until the next time this
   202      * method is invoked. 
   203      *
   204      * @param aIndex   index of element to return
   205      * @return descriptor representing array element, ownership is not passed
   206     */
   207     IMPORT_C virtual TPtrC MdcaPoint(TInt aIndex) const;
   208     
   209 protected:
   210 	CAknQueryValueDurationArray();
   211 	
   212     /**
   213      * 2nd stage construction.
   214      *
   215     */
   216 	void ConstructL(TInt aResourceId);
   217 	
   218 private:
   219 	// the following members are owned
   220 	HBufC* iLastGeneratedTextValue;
   221 	HBufC* iFormatString;
   222 	// the following members are not owned
   223 	DurationArray* iArray;
   224 	TInt iFormattedStringSize;
   225 	};
   226 
   227 
   228 #endif // __AKNQUERYVALUEDURATION_H__
   229