uifw/AvKon/inc/akntext.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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 *     Store and handle text labels for note dialogs. Each note dialog
       
    17 *     can have two different labels, one singular and one plural.
       
    18 *     For example:-
       
    19 *        "You have 1 new message" is the singular label and
       
    20 *        "You have 2 new messages" is the plural label.
       
    21 *     This class supports the ability to change number inside the label, 
       
    22 *     e.g. "You have 100 new messages" is supported.
       
    23 *     Text is read from resource but can also be set dynamically via the
       
    24 *     public API.
       
    25 * 
       
    26 *
       
    27 */
       
    28 
       
    29 
       
    30 #ifndef __AKNNOTETEXT__
       
    31 #define __AKNNOTETEXT__ 
       
    32 
       
    33 #include <e32base.h>
       
    34 #include <e32std.h>
       
    35 #include <barsread.h>
       
    36 
       
    37 /**
       
    38  * An avkon dynamic text class. 
       
    39  *
       
    40  * Manage static or dynamic text. Static text never changes,
       
    41  * e.g. "Delete?". Dynamic text changes depending on a number,
       
    42  * e.g. "Delete 1 message?" or "Delete 3 messages?"
       
    43  *
       
    44  * Client can specify plurality and/or number to determine which
       
    45  * text is returned. 
       
    46  *
       
    47  * Formatted text is stored in a buffer, there are then 2 additional
       
    48  * buffers storing the unformatted texts, e.g. "Delete %d message"
       
    49  * and "Delete %d messages".
       
    50  *
       
    51  * One current limitation is that only one number can be supported 
       
    52  * per text. A better approach would be to offer a printf alike interface.
       
    53  * In fact the whole idea of the control having to manage these texts
       
    54  * is a bit of a nonsese - the client should simply call a method
       
    55  * passing a text a number of args, like when calling printf. For future
       
    56  * implementations.
       
    57  *
       
    58  */
       
    59 NONSHARABLE_CLASS(CAknText) : public CBase
       
    60 	{
       
    61 	public:
       
    62 		enum TPlurality 
       
    63 			{
       
    64 			ENotSpecified,
       
    65 			ESingular,
       
    66 			EPlural
       
    67 			};
       
    68 		enum TType
       
    69 			{
       
    70 			EFormatted,
       
    71 			ENotFormatted
       
    72 			};
       
    73 	public:
       
    74 		CAknText();
       
    75 		CAknText(const TType& aType);
       
    76 		~CAknText();
       
    77 	
       
    78 	public:
       
    79 		void ConstructFromResourceL(TResourceReader& aRes);
       
    80 	    CAknText& operator=(CAknText& aNoteText);
       
    81 
       
    82 		void SetPluralityL(TBool aIsPlural);
       
    83 		void SetNumberL(TInt aNumber);
       
    84 		void SetL(const TDesC& aText);
       
    85 		TPtr Get() const;
       
    86 	
       
    87 	private:
       
    88 		void FormatL();
       
    89 		void DoFormatTextL(HBufC* aUnformattedText);
       
    90 		TPtr TranslateDintoN(HBufC* aUnformattedText);
       
    91 
       
    92 		void  DoSetTextL(HBufC*& aBuffer, const TDesC& aText);
       
    93 		TBool TextIsNotFormatted(const TDesC& aText);
       
    94 
       
    95 	private:
       
    96 		CAknText(const CAknText&);
       
    97 
       
    98 	private:
       
    99 		TPlurality iPlurality;
       
   100 		TType      iType;
       
   101 		TInt       iNumber;
       
   102 		TBool      iNumberHasBeenSet;
       
   103 		HBufC*     iUnformattedSingularText;
       
   104 		HBufC*     iUnformattedPluralText;
       
   105 		HBufC*     iText;
       
   106 		HBufC*     iTextCopy;
       
   107 		TInt iSpare;
       
   108 	};
       
   109 
       
   110 #endif