20
|
1 |
/*
|
|
2 |
* Copyright (c) 1997-1999 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 |
|
|
19 |
#if !defined(__EIKSECED_H__)
|
|
20 |
#define __EIKSECED_H__
|
|
21 |
|
|
22 |
#if !defined(__EIKDEF_H__)
|
|
23 |
#include <eikdef.h>
|
|
24 |
#endif
|
|
25 |
|
|
26 |
#if !defined(__EIKBCTRL_H__)
|
|
27 |
#include <eikbctrl.h>
|
|
28 |
#endif
|
|
29 |
|
|
30 |
#include <fepbase.h>
|
|
31 |
|
|
32 |
// FORWARD DECLARATIONS
|
|
33 |
class TResourceReader;
|
|
34 |
class CEikSecretEditorExtension;
|
|
35 |
class MAknsControlContext;
|
|
36 |
|
|
37 |
/**
|
|
38 |
* A single line text editor which displays an asterisk for every
|
|
39 |
* character entered.
|
|
40 |
*
|
|
41 |
* The editor is suitable for editing confidential information such as
|
|
42 |
* a password. You can paste to the editor but no other clipboard
|
|
43 |
* functions are available.
|
|
44 |
*
|
|
45 |
* The editor has an associated resource struct SECRETED and control
|
|
46 |
* factory identifier EEikCtSecretEd.
|
|
47 |
*/
|
|
48 |
class CEikSecretEditor : public CEikBorderedControl, public MCoeFepAwareTextEditor, public MCoeFepAwareTextEditor_Extension1
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
enum {
|
|
52 |
/**
|
|
53 |
* The maximum number of characters in the displayed
|
|
54 |
* text buffer.
|
|
55 |
*/
|
|
56 |
EMaxSecEdBufLength = 32,
|
|
57 |
/**
|
|
58 |
* Indicates the maximum number of characters which may be entered into
|
|
59 |
* the editor.
|
|
60 |
*
|
|
61 |
* Editors additionally have a maximum length, see SetMaxLength(),
|
|
62 |
* which must not exceed this value.
|
|
63 |
*/
|
|
64 |
EMaxSecEdSecArrayLength = 255
|
|
65 |
};
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Settable features for Secret Editor. See SetFeature().
|
|
69 |
*
|
|
70 |
* @since S60 5.0
|
|
71 |
*/
|
|
72 |
enum TFeatureId
|
|
73 |
{
|
|
74 |
/** Disables VKB. Non-zero (or ETrue) parameter disables VKB,
|
|
75 |
0 (or EFalse) enables VKB. When disabled,
|
|
76 |
editor doesn't request PenInputServer to start VKB */
|
|
77 |
EDisablePenInput,
|
|
78 |
|
|
79 |
ELaunchPenInputAutomatic,
|
|
80 |
|
|
81 |
EPartialScreenInput,
|
|
82 |
ELockQuerySCT
|
|
83 |
};
|
|
84 |
|
|
85 |
|
|
86 |
public:
|
|
87 |
/**
|
|
88 |
* Default constructor.
|
|
89 |
*
|
|
90 |
* This constructs a editor with a border type of
|
|
91 |
* TGulBorder::ESingleGray.
|
|
92 |
*
|
|
93 |
* This function should be used as the first stage in two stage
|
|
94 |
* construction, followed by a call to either ConstructFromResourceL() or
|
|
95 |
* SetMaxLength().
|
|
96 |
*/
|
|
97 |
IMPORT_C CEikSecretEditor();
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Destructor.
|
|
101 |
*/
|
|
102 |
IMPORT_C ~CEikSecretEditor();
|
|
103 |
|
|
104 |
public: // from CCoeControl
|
|
105 |
/**
|
|
106 |
* Second-phase construction from a resource file.
|
|
107 |
*
|
|
108 |
* This function reads the number of characters which may be entered by
|
|
109 |
* the user into the editor from a SECRETED resource. You should call
|
|
110 |
* either this function or SetMaxLength() before drawing the editor and
|
|
111 |
* offering key events, otherwise the editor will not accept text input.
|
|
112 |
*
|
|
113 |
* @param aReader A resource file reader.
|
|
114 |
* @panic EIKCTL 13 If the value read from resource is greater than
|
|
115 |
* EMaxSecEdLength.
|
|
116 |
*/
|
|
117 |
IMPORT_C virtual void ConstructFromResourceL(TResourceReader& aReader);
|
|
118 |
|
|
119 |
/**
|
|
120 |
* Gets the editor's minimum size in pixels.
|
|
121 |
*
|
|
122 |
* Overrides CCoeControl::MinimumSize().
|
|
123 |
*
|
|
124 |
* @return The editor's minimum size in pixels.
|
|
125 |
*/
|
|
126 |
IMPORT_C virtual TSize MinimumSize();
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Responds to key presses.
|
|
130 |
*
|
|
131 |
* Overrides CCoeControl::OfferKeyEventL().
|
|
132 |
*
|
|
133 |
* @param aKeyEvent The key event.
|
|
134 |
* @param aType Not used.
|
|
135 |
* @return Indicates whether or not the key event was consumed.
|
|
136 |
*/
|
|
137 |
IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Gets the list of logical colours used to draw the editor.
|
|
141 |
*
|
|
142 |
* Overrides CCoeControl::GetColorUseListL().
|
|
143 |
*
|
|
144 |
* @param aColorUseList On return, the colour list.
|
|
145 |
*/
|
|
146 |
IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; // not available before Release 005u
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Handles a change to the editor's resources.
|
|
150 |
*
|
|
151 |
* The types of resources handled are those which are shared across the
|
|
152 |
* environment, e.g. colours or fonts.
|
|
153 |
*
|
|
154 |
* Calls CEikBorderedControl::HandleResourceChange().
|
|
155 |
*
|
|
156 |
* @param aType A message UID value.
|
|
157 |
*/
|
|
158 |
IMPORT_C virtual void HandleResourceChange(TInt aType); // not available before Release 005u
|
|
159 |
|
|
160 |
/**
|
|
161 |
* Gets the editor's input capabilities.
|
|
162 |
*
|
|
163 |
* Overrides CCoeControl::InputCapabilities().
|
|
164 |
*
|
|
165 |
* If this function is overrided in a subclass, the subclass should
|
|
166 |
* obtain this class' InputCapabilities' object provider through
|
|
167 |
* TCoeInputCapabilities::ObjectProvider() and set that as a part of
|
|
168 |
* the subclass' InputCapabilities object provider chain to ensure
|
|
169 |
* maximum functionality.
|
|
170 |
*
|
|
171 |
* @return The editor's input capabilities. The ESecretText and
|
|
172 |
* ENavigation flags are set.
|
|
173 |
*/
|
|
174 |
IMPORT_C virtual TCoeInputCapabilities InputCapabilities() const;
|
|
175 |
|
|
176 |
/**
|
|
177 |
* From @c CCoeControl.
|
|
178 |
*
|
|
179 |
* Handles pointer events.
|
|
180 |
*
|
|
181 |
* @param aPointerEvent The pointer event.
|
|
182 |
*/
|
|
183 |
IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
|
|
184 |
|
|
185 |
IMPORT_C void FocusChanged( TDrawNow aDrawNow );
|
|
186 |
|
|
187 |
public: // specific
|
|
188 |
/**
|
|
189 |
* Gets the editor's text string.
|
|
190 |
*
|
|
191 |
* This may be called from the container class when the model data
|
|
192 |
* should be updated according to the text contained in the editor.
|
|
193 |
*
|
|
194 |
* @param aText On return, the editor's text. This is what is stored in
|
|
195 |
* memory, not what is displayed. This descriptor must be capable of
|
|
196 |
* holding the maxlength of the internal buffer.
|
|
197 |
*
|
|
198 |
*/
|
|
199 |
IMPORT_C void GetText(TDes& aText) const;
|
|
200 |
|
|
201 |
/**
|
|
202 |
* Set the contents of the character buffer.
|
|
203 |
*
|
|
204 |
* @param aText The text to be set as the contents of the character buffer.
|
|
205 |
*/
|
|
206 |
IMPORT_C virtual void SetText(const TDesC& aText);
|
|
207 |
|
|
208 |
/**
|
|
209 |
* Set the initial display of the secret editor.
|
|
210 |
* Calling this routine doesn't affect the actual character buffer.
|
|
211 |
*
|
|
212 |
* @param aNumberOfCharacters Must be >=0 and <= EMaxSecEdBufLength.
|
|
213 |
*/
|
|
214 |
IMPORT_C virtual void InitializeDisplay(TInt aNumberOfChars);
|
|
215 |
|
|
216 |
/**
|
|
217 |
* Clears the editor's text string removing any trace of it from memory.
|
|
218 |
*/
|
|
219 |
IMPORT_C void Reset();
|
|
220 |
|
|
221 |
/**
|
|
222 |
* Set the maximum length of the editor.
|
|
223 |
*
|
|
224 |
* This is the maximum number of characters which may be entered by the
|
|
225 |
* user into the editor.
|
|
226 |
*
|
|
227 |
* @param aMaxLength The maximum number of characters which may be
|
|
228 |
* entered.
|
|
229 |
* @panic EIKCTL 13 If aMaxLength is greater than EMaxSecEdLength.
|
|
230 |
*
|
|
231 |
*/
|
|
232 |
IMPORT_C void SetMaxLength(TInt aMaxLength);
|
|
233 |
|
|
234 |
/**
|
|
235 |
* Sets the font that is used to draw the text in this editor.
|
|
236 |
*
|
|
237 |
* @param aFont A pointer to a CFont object that is used to draw the
|
|
238 |
* text in this editor.
|
|
239 |
*/
|
|
240 |
IMPORT_C void AknSetFont(const CFont &aFont);
|
|
241 |
|
|
242 |
/**
|
|
243 |
* Sets the alignment of the editor.
|
|
244 |
*
|
|
245 |
* @param aAlign The editor's alignment.
|
|
246 |
*/
|
|
247 |
IMPORT_C void AknSetAlignment(const CGraphicsContext::TTextAlign &aAlign);
|
|
248 |
|
|
249 |
/**
|
|
250 |
* Changes default and current input mode of a secret editor. By default
|
|
251 |
* input mode in the secret editor is alpha input mode
|
|
252 |
* (EAknEditorSecretAlphaInputMode). By using this method the default input
|
|
253 |
* mode can be changed to numeric input mode (EAknEditorNumericInputMode).
|
|
254 |
*
|
|
255 |
* @since 2.1
|
|
256 |
* @param aInputMode Default input mode in the secret editor.
|
|
257 |
* Only EAknEditorNumericInputMode and EAknEditorSecretAlphaInputMode
|
|
258 |
* are supported.
|
|
259 |
*/
|
|
260 |
IMPORT_C void SetDefaultInputMode(TInt aInputMode);
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Returns the current maximum length of the internal buffer.
|
|
264 |
*
|
|
265 |
* @return the current maximum length of the internal buffer.
|
|
266 |
*/
|
|
267 |
IMPORT_C TInt MaxLength() const;
|
|
268 |
|
|
269 |
/**
|
|
270 |
* Access method for getting at the buffer without copying out from it.
|
|
271 |
*
|
|
272 |
* @return Non-modifiable descriptor reference to the contained buffer.
|
|
273 |
*/
|
|
274 |
IMPORT_C const TDesC& Buffer() const;
|
|
275 |
|
|
276 |
/**
|
|
277 |
* Method to reveal (or hide) the currently input editor contents.
|
|
278 |
*
|
|
279 |
* @param aReveal - if ETrue, reveals the contents; if EFalse hides them.
|
|
280 |
*/
|
|
281 |
IMPORT_C void RevealSecretText( TBool aReveal );
|
|
282 |
|
|
283 |
/**
|
|
284 |
* Method for enabling/disabling special character table from
|
|
285 |
* the secret editor. By default the SCT is enabled in the secret
|
|
286 |
* editors.
|
|
287 |
* ConstructFromResourceL need to be called before this method.
|
|
288 |
*
|
|
289 |
* @since 3.2
|
|
290 |
*
|
|
291 |
* @param aEnable Boolean value for enabling or disabling the special
|
|
292 |
* character table.
|
|
293 |
*/
|
|
294 |
IMPORT_C void EnableSCT( TBool aEnable = ETrue );
|
|
295 |
|
|
296 |
/**
|
|
297 |
* Set the skin control context to be used with this secret editor. If this
|
|
298 |
* method is not called, the control context available through MOP (if any)
|
|
299 |
* is used. If @c NULL control context is specified, no control context is
|
|
300 |
* used at all.
|
|
301 |
*
|
|
302 |
* @since 2.0
|
|
303 |
*
|
|
304 |
* @param aContext The background control context used to draw the
|
|
305 |
* background of this editor or @c NULL. Ownership is not transferred.
|
|
306 |
*/
|
|
307 |
IMPORT_C void SetSkinBackgroundControlContextL( MAknsControlContext* aContext );
|
|
308 |
|
|
309 |
// for cursor support
|
|
310 |
TPoint CursorPos();
|
|
311 |
IMPORT_C void EnableCursor( TBool aEnable );
|
|
312 |
|
|
313 |
protected: // inherited
|
|
314 |
// methods to enable CAknNumericSecretEditor to inherit from CEikSecretEditor
|
|
315 |
/**
|
|
316 |
* Appends a character to the editor.
|
|
317 |
*
|
|
318 |
* @param aKeyCode The character to append.
|
|
319 |
*/
|
|
320 |
IMPORT_C virtual void AppendCharacterL( TInt aKeyCode );
|
|
321 |
|
|
322 |
/**
|
|
323 |
* Updates and redraws the editor.
|
|
324 |
*/
|
|
325 |
IMPORT_C virtual void Update();
|
|
326 |
|
|
327 |
void InsertSecretChar();
|
|
328 |
|
|
329 |
/**
|
|
330 |
* Responds to changes to the size and position of
|
|
331 |
* the contents of this control.
|
|
332 |
*
|
|
333 |
* Overrides CCoeControl::SizeChanged().
|
|
334 |
*/
|
|
335 |
IMPORT_C void SizeChanged();
|
|
336 |
|
|
337 |
private: // virtual
|
|
338 |
IMPORT_C virtual void Draw(const TRect& aRect) const;
|
|
339 |
|
|
340 |
private: // from MCoeFepAwareTextEditor
|
|
341 |
IMPORT_C void StartFepInlineEditL(const TDesC& aInitialInlineText, TInt aPositionOfInsertionPointInInlineText, TBool aCursorVisibility, const MFormCustomDraw* aCustomDraw, MFepInlineTextFormatRetriever& aInlineTextFormatRetriever, MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit);
|
|
342 |
IMPORT_C void UpdateFepInlineTextL(const TDesC& aNewInlineText, TInt aPositionOfInsertionPointInInlineText);
|
|
343 |
IMPORT_C void SetInlineEditingCursorVisibilityL(TBool aCursorVisibility);
|
|
344 |
IMPORT_C void CancelFepInlineEdit();
|
|
345 |
IMPORT_C TInt DocumentLengthForFep() const;
|
|
346 |
IMPORT_C TInt DocumentMaximumLengthForFep() const;
|
|
347 |
IMPORT_C void SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection);
|
|
348 |
IMPORT_C void GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const;
|
|
349 |
IMPORT_C void GetEditorContentForFep(TDes& aEditorContent, TInt aDocumentPosition, TInt aLengthToRetrieve) const;
|
|
350 |
IMPORT_C void GetFormatForFep(TCharFormat& aFormat, TInt aDocumentPosition) const;
|
|
351 |
IMPORT_C void GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine, TInt& aHeight, TInt& aAscent, TInt aDocumentPosition) const;
|
|
352 |
IMPORT_C void DoCommitFepInlineEditL();
|
|
353 |
IMPORT_C MCoeFepAwareTextEditor_Extension1* Extension1(TBool& aSetToTrue);
|
|
354 |
IMPORT_C void SetStateTransferingOwnershipL(CState* aState, TUid aTypeSafetyUid);
|
|
355 |
IMPORT_C CState* State(TUid aTypeSafetyUid); // this function does *not* transfer ownership
|
|
356 |
|
|
357 |
private:
|
|
358 |
void OverflowAlert();
|
|
359 |
|
|
360 |
private: // from CCoeControl
|
|
361 |
IMPORT_C void Reserved_1();
|
|
362 |
IMPORT_C void Reserved_2();
|
|
363 |
private:
|
|
364 |
/**
|
|
365 |
* From CAknControl
|
|
366 |
*/
|
|
367 |
IMPORT_C void* ExtensionInterface( TUid aInterface );
|
|
368 |
private: // from MCoeFepAwareTextEditor
|
|
369 |
IMPORT_C void MCoeFepAwareTextEditor_Reserved_2();
|
|
370 |
private: // from MCoeFepAwareTextEditor_Extension1
|
|
371 |
IMPORT_C virtual void MCoeFepAwareTextEditor_Extension1_Reserved_2();
|
|
372 |
IMPORT_C virtual void MCoeFepAwareTextEditor_Extension1_Reserved_3();
|
|
373 |
IMPORT_C virtual void MCoeFepAwareTextEditor_Extension1_Reserved_4();
|
|
374 |
|
|
375 |
private: // specific
|
|
376 |
void InsertChar();
|
|
377 |
TInt CharsFitOnEditor() const;
|
|
378 |
IMPORT_C virtual MCoeFepAwareTextEditor_Extension1::CState* CreateFepStateL();
|
|
379 |
void CalculateAscent();
|
|
380 |
void ReportUpdate();
|
|
381 |
|
|
382 |
// for cursor support
|
|
383 |
void SetCursorFormat();
|
|
384 |
void UpdateCursor();
|
|
385 |
void InitCRedirectionListenerL();
|
|
386 |
|
|
387 |
private:
|
|
388 |
typedef TBuf<EMaxSecEdBufLength> TSecEdBuf;
|
|
389 |
protected:
|
|
390 |
HBufC* iSecCharArr;
|
|
391 |
TInt iSecPos;
|
|
392 |
TSecEdBuf iBuf;
|
|
393 |
TInt iMaxLen;
|
|
394 |
TInt iCharWidth;
|
|
395 |
TInt iAscent;
|
|
396 |
TBool iBufferFull;
|
|
397 |
|
|
398 |
public: // timer methods
|
|
399 |
void StartTimer();
|
|
400 |
private:
|
|
401 |
static TInt TimerCallback(TAny* aThis);
|
|
402 |
private:
|
|
403 |
CPeriodic* iTimer;
|
|
404 |
const CFont *iFont;
|
|
405 |
CGraphicsContext::TTextAlign iAlign;
|
|
406 |
TBool iRevealSecretText; // holds the state of whether text is shown or not
|
|
407 |
CEikSecretEditorExtension* iExtension;
|
|
408 |
CState* iFepState;
|
|
409 |
HBufC* iInlineEditText;
|
|
410 |
|
|
411 |
public:
|
|
412 |
/**
|
|
413 |
* Sets the colors for text and background as skin IDs.
|
|
414 |
*
|
|
415 |
* @since 3.0
|
|
416 |
* @param aAknSkinIDForTextColor ID for text color.
|
|
417 |
* @param aAknSkinIDForBgColor ID for background color.
|
|
418 |
*/
|
|
419 |
IMPORT_C void SetSkinTextColorL(TInt aAknSkinIDForTextColor, TInt aAknSkinIdForBgColor=KErrNotFound);
|
|
420 |
|
|
421 |
/**
|
|
422 |
* Used for setting various flag-like features to the editor.
|
|
423 |
*
|
|
424 |
* @param aFeatureId The feature id, see TFeatureId
|
|
425 |
* @param aFeatureParam The feature parameter. This is usually
|
|
426 |
* enabled or disabled. For more info, see
|
|
427 |
* the feature documentation in TFeatureId.
|
|
428 |
* @return KErrNone if the feature modification succeeded
|
|
429 |
* @since S60 5.0
|
|
430 |
**/
|
|
431 |
IMPORT_C TInt SetFeature( TInt aFeatureId, TInt aFeatureParam );
|
|
432 |
|
|
433 |
/**
|
|
434 |
* Used to getting feature statuses.
|
|
435 |
*
|
|
436 |
* @param aFeatureId The feature id, see TFeatureId
|
|
437 |
* @param aFeatureParam On return, the parameter for the feature
|
|
438 |
* (usually non-zero for an enabled feature
|
|
439 |
* and zero for disabled)
|
|
440 |
* @return KErrNone if the feature is supported and fetching its value
|
|
441 |
* succeeded
|
|
442 |
* @since S60 5.0
|
|
443 |
*/
|
|
444 |
IMPORT_C TInt GetFeature( TInt aFeatureId, TInt& aFeatureParam ) const;
|
|
445 |
|
|
446 |
/**
|
|
447 |
* Used for checking if the editor supports a feature.
|
|
448 |
* For features, see TFeatureId.
|
|
449 |
*
|
|
450 |
* @param aFeatureId
|
|
451 |
* @return ETrue if the feature is supported
|
|
452 |
* @since S60 5.0
|
|
453 |
*/
|
|
454 |
IMPORT_C TBool SupportsFeature( TInt aFeatureId ) const;
|
|
455 |
};
|
|
456 |
|
|
457 |
#endif
|