|
1 /* |
|
2 * Copyright (c) 2002-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: Numeric Editor derived from Uikon's CEikEdwin |
|
15 * These specializations of CEikEdwin maintain a numeric content, |
|
16 * access methods and validation. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #if !defined(__AKNNUMEDWIN_H__) |
|
23 #define __AKNNUMEDWIN_H__ |
|
24 |
|
25 // INCLUDES |
|
26 #include <eikedwin.h> |
|
27 #include <aknnumed.h> // CAknNumericEdwin |
|
28 |
|
29 // CONSTANTS |
|
30 _LIT( KAknIntegerFormat, "%d" ); |
|
31 |
|
32 // CLASS DECLARATION |
|
33 |
|
34 /** |
|
35 * The CAknIntegerEdwin class implements an editor for an integer values. |
|
36 * |
|
37 * The editor has an associated resource struct @c AVKON_INTEGER_EDWIN and |
|
38 * control factory identifier @c EAknCtIntegerEdwin. |
|
39 * |
|
40 * @since Series 60 0.9 |
|
41 */ |
|
42 class CAknIntegerEdwin : public CAknNumericEdwin |
|
43 { |
|
44 public: |
|
45 /** |
|
46 * Two-phased constructor. |
|
47 * @param aMin The minimum allowable value. |
|
48 * @param aMax The maximum allowable value. |
|
49 * @param aMaxChars The maximum allowable number of the digits. |
|
50 * @return Pointer to a fully constructed editor object. |
|
51 */ |
|
52 IMPORT_C static CAknIntegerEdwin* NewL(TInt aMin, |
|
53 TInt aMax, |
|
54 TInt aMaxChars); |
|
55 |
|
56 /** |
|
57 * Constructs controls from a resource file. |
|
58 * Function reads needed values from a @c AVKON_INTEGER_EDWIN resource. |
|
59 * Essential for Dialog/Form construction. |
|
60 * @param aReader The resource reader with which to access the control's |
|
61 * resource values. |
|
62 */ |
|
63 IMPORT_C virtual void ConstructFromResourceL(TResourceReader& aReader); |
|
64 |
|
65 /** |
|
66 * 2nd phase constructor. |
|
67 * @param aMin The minimum allowable value. |
|
68 * @param aMax The maximum allowable value. |
|
69 * @param aMaxChars The maximum allowable number of the digits. |
|
70 */ |
|
71 IMPORT_C void ConstructL( TInt aMin, TInt aMax, TInt aMaxChars ); |
|
72 |
|
73 // New methods |
|
74 |
|
75 /** |
|
76 * Sets the current value of the editor. |
|
77 * The control is not redrawn. |
|
78 * @param aValue Current value of the editor. |
|
79 */ |
|
80 IMPORT_C void SetValueL(TInt aValue); |
|
81 |
|
82 /** |
|
83 * Sets the value that is returned when the editor field is left empty or |
|
84 * is not valid. |
|
85 * @param aUnsetValue The default value to be returned. |
|
86 */ |
|
87 IMPORT_C void SetUnsetValue( TInt aUnsetValue); |
|
88 |
|
89 /** |
|
90 * Gets the current value of the editor. |
|
91 * Validity of the value is checked, if the editor is empty, the unset value |
|
92 * is used. The value is put into aValue parameter even if it is not valid. |
|
93 * @param aValue Reference to the integer used to store the value got from |
|
94 * the editor field. |
|
95 * @return Indicates the validation status. |
|
96 */ |
|
97 IMPORT_C TValidationStatus GetTextAsInteger( TInt& aValue ); |
|
98 |
|
99 /** |
|
100 * Sets the minimum allowable value of the editor. |
|
101 * @param aMinimumValue The minimum value. |
|
102 */ |
|
103 IMPORT_C void SetMinimumIntegerValue( TInt aMinimumValue ); |
|
104 |
|
105 /** |
|
106 * Sets the maximum allowable value of the editor. |
|
107 * @param aMaximumValue The maximum value. |
|
108 */ |
|
109 IMPORT_C void SetMaximumIntegerValue( TInt aMaximumValue ); |
|
110 |
|
111 |
|
112 /** |
|
113 * From @c CCoeControl. Prepares for focus loss. |
|
114 * Called by the framework just before focus is removed from the control. |
|
115 */ |
|
116 IMPORT_C void PrepareForFocusLossL(); |
|
117 |
|
118 /** |
|
119 * From @c CCoeControl. Handles a change to the control's resources. |
|
120 * @since Series 60 2.0 |
|
121 * @param aType a message UID value. |
|
122 */ |
|
123 IMPORT_C void HandleResourceChange(TInt aType); |
|
124 |
|
125 /** |
|
126 * From @c CCoeControl. Handles key events. |
|
127 * Called by framework when a key event occurs. |
|
128 * @since Series 60 2.0 |
|
129 * @param aKeyEvent The key event that occured. |
|
130 * @param aType The type of key event that occured. |
|
131 * @return @c EKeyWasConsumed if the event was processed, |
|
132 * @c EKeyWasNotConsumed if the event was not processed. |
|
133 */ |
|
134 IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
135 TEventCode aType); |
|
136 |
|
137 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
138 |
|
139 /** |
|
140 * Checks if the number of the editor is within the min and max boundaries. |
|
141 * If not, the method set the number to closest legal value and highlights the |
|
142 * number text in the editor. |
|
143 */ |
|
144 IMPORT_C TBool CheckNumber(); |
|
145 |
|
146 private: |
|
147 void CommonConstructL(TInt aMin, |
|
148 TInt aMax, |
|
149 TInt aMaxChars, |
|
150 TInt aFlags, |
|
151 TInt aUnset); |
|
152 |
|
153 void RefreshFromLocale(); |
|
154 private: |
|
155 /** |
|
156 * From CAknControl |
|
157 */ |
|
158 IMPORT_C void* ExtensionInterface( TUid aInterface ); |
|
159 |
|
160 private: // from CEikEdwin |
|
161 IMPORT_C void Reserved_3(); |
|
162 |
|
163 private: |
|
164 TInt iMinimumValue; |
|
165 TInt iMaximumValue; |
|
166 TInt iUnsetValue; |
|
167 TAny* iUnsetText; |
|
168 TDigitType iDigitType; |
|
169 TInt iSpare_Integer_2; |
|
170 }; |
|
171 |
|
172 #endif |