2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Implementation of Query control and List query control.
19 #ifndef AKNQUERYCONTROL_H
20 #define AKNQUERYCONTROL_H
23 #include <AknControl.h>
29 #include <Aknnumseced.h>
30 #include <AknNumEdwin.h>
40 #include <lbsposition.h>
42 // FORWARD DECLARATIONS
43 class CAknQueryControl;
44 class TAknQueryEcsObserver;
45 class CAknEcsDetector;
46 class CAknBitmapAnimation;
47 class CAknTextControl;
48 class CAknQueryEditIndicator;
50 class MAknEditingStateIndicator;
52 class CAknQueryExtension;
53 class TAknWindowLineLayout;
55 class CAknQueryControlExtension;
56 class CAknLocationEditor;
58 * MAknQueryControlObserver
59 * Callback class for CAknQueryDialog
61 class MAknQueryControlObserver
65 * Enumeration for query control events
67 enum TQueryControlEvent
69 EQueryControltSizeChanging,
70 EQueryControlEditorStateChanging,
71 EEmergencyCallAttempted
75 * Enumeration for editor validation status
77 enum TQueryValidationStatus
79 EEditorValueValid = KErrNone,
82 EEditorValueNotParsed,
88 * Gets called when editor sends size event
90 virtual TBool HandleQueryEditorSizeEventL(CAknQueryControl* aQueryControl, TQueryControlEvent aEventType)=0;
92 * Gets called when editor sends state event
94 virtual TBool HandleQueryEditorStateEventL(CAknQueryControl* aQueryControl, TQueryControlEvent aEventType, TQueryValidationStatus aStatus)=0;
98 * The control for a query dialog.
100 * Manage layout of elements in a query dialog:- the text, the image
103 * @see CAknQueryDialog, CAknText
105 class CAknQueryControl : public CAknControl , public MEikEdwinObserver , public MEikEdwinSizeObserver , public MCoeControlObserver
109 DECLARE_TYPE_ID(0x10283143)
113 * Enumeration for indexing into control flags, which
114 * determine the control behaviour relative to a number
115 * of things, e.g. emergency control handling, displaying of
116 * edit indicator, enabling of predictive text, etc
118 enum TQueryControlFlagBitIndices
120 /** Query supports emergency calls.
122 EEmergencyCallsEnabledByAPI,
123 /** Query doesn't support emergency calls.
125 EEmergencyCallsDisabledByAPI,
126 /** Predictive text input is allowed in the query.
128 EPredictiveTextEntryPermitted,
129 /** Editor indicators are not shown in the query.
132 /** Additional support to ECS for CBA label change.
133 * Must be enabled for touch full screen query for the
134 * ECS to function properly.
136 EEmergencyCallsCBASupport
140 * Layout for queries can be done
141 * using the following methods. Each
142 * method is specified in a LAF section
146 EConfQueryLayoutM, ///LAYOUT according to LAF specs for conf queries
147 EDataQueryLayoutM, ///LAYOUT according to LAF specs for data queries
148 ECodeQueryLayoutM, ///LAYOUT accoridng to LAF specs for code queries
149 ETimeQueryLayoutM, ///LAYOUT according to LAF specs for time queries
150 EDateQueryLayoutM, ///LAYOUT according to LAF specs for date queries
151 ECombinedCodeDataQueryLayoutM ///LAYOUT according to LAF specs for combined code and data queries
154 public: // Constructors and destructor
159 IMPORT_C CAknQueryControl();
164 IMPORT_C virtual ~CAknQueryControl();
167 * Second phase constructor: loads contents of array from resources.
169 * @param aRea resource reader pointed to a
172 IMPORT_C void ConstructFromResourceL(TResourceReader& aRes);
174 public: // New functions
177 * Set observer for query control.
179 * @param aQueryControlObserver Pointer to oberver class
181 IMPORT_C void SetQueryControlObserver(MAknQueryControlObserver* aQueryControlObserver);
184 * Read prompt text from resource and call SetPrompt if there was text for prompt.
186 * @param aRes resource reader pointed to a query resource
188 IMPORT_C virtual void ReadPromptL(TResourceReader& aRes);
191 * Set prompt text for query. This call WrapToStringL.
193 * @param aDesC Text for prompt
195 IMPORT_C virtual void SetPromptL(const TDesC& aDesC);
198 * Get text from text, secret text, numeric secret text snd phonenumber editor.
200 * @param aDes Address of variable where text returned.
202 IMPORT_C void GetText(TDes& aDes) const;
205 * Get time from date or time editors
207 * @return Returns data from editor.
209 IMPORT_C TTime GetTime() const;
212 * Get number from number editor.
214 * @return Returns number from editor
216 IMPORT_C TInt GetNumber() const;
219 * Get number from floating point editor.
221 * @return Returns number from editor
223 IMPORT_C TReal GetFloatingPointNumberL() const;
226 * Get duration from duration editor
228 * @return Return duration from editor.
230 IMPORT_C TTimeIntervalSeconds GetDuration() const;
234 * Get location from location editor
236 * Modifies aLocation in such way that either
237 * longitude or latitude will change.
239 IMPORT_C void GetLocation(TPosition &aLocation) const;
242 * Set text to text and phonenumber editor.
244 * @param aDesC Text for editor
246 IMPORT_C void SetTextL(const TDesC& aDesC);
249 * Set date of time to editor
251 * @param aTime Time or date to editor.
253 IMPORT_C void SetTime(TTime& aTime);
256 * Set duration to duration editor
258 * @param aDuration Duration to editor
260 IMPORT_C void SetDuration(TTimeIntervalSeconds& aDuration);
263 * Set number to number editor
264 * @param aNumber Number to editor
267 IMPORT_C void SetNumberL(TInt aNumber);
270 * Set number to floating point editor
271 * @param aNumber Number to editor
274 IMPORT_C void SetFloatingPointNumberL(const TReal* aNumber);
277 * Set location to location editor
279 * Modifies editor in such way that it'll start
280 * showing either longitude or latitude from
281 * the given location. It depends on resource file
282 * flags of the location editor which is used.
284 * @param aLocation Location to editor
287 IMPORT_C void SetLocation(const TPosition &aLocation);
290 * Set max length of text to text editor. This will override length from resource
291 * @param aLength Max length of text in editor
294 IMPORT_C void SetTextEntryLength(TInt aLength);
297 * Return the max length of the text in the text editor
298 * @return max text length
300 IMPORT_C TInt GetTextEntryLength() const;
303 * Set minimum and maximum time or date to editor
304 * @param aMinimum Minimum value
305 * @param aMaximum Maximum value
308 IMPORT_C void SetMinimumAndMaximum(const TTime& aMinimum, const TTime& aMaximum);
311 * Set minimum and maximum duration to editor
312 * @param aMinimumDuration Minimum value
313 * @param aMaximumDuration Maximum value
315 IMPORT_C void SetMinimumAndMaximum(const TTimeIntervalSeconds& aMinimumDuration, const TTimeIntervalSeconds& aMaximumDuration);
318 * Set minimum and maximum number to editor
319 * @param aMinimumValue Minimum value
320 * @param aMaximumValue Maximum value
322 IMPORT_C void SetMinimumAndMaximum(TInt aMinimumValue, TInt aMaximumValue);
326 * Checks if the given number in the editor is within the maximum and minimum values.
328 IMPORT_C TBool CheckNumber();
331 * Set the number of lines in the editor.
333 * @param aNum Number of lines in the editor
335 IMPORT_C void SetNumberOfEditorLines(TInt aNum);
338 * Set minimum and maximum number to floating point editor
339 * @param aMinimumValue Minimum value
340 * @param aMaximumValue Maximum value
342 IMPORT_C void SetMinimumAndMaximum(const TReal& aMinimumValue, const TReal& aMaximumValue);
344 * Get text length from editor.
346 * @return Length of text from editor
348 IMPORT_C TInt GetTextLength() const;
351 * Return number of editor lines
353 * @return Number lines in the editor
356 IMPORT_C TInt NbrOfEditorLines() const;
360 * Return number of prompt lines
362 * @return Number of lines in the prompt
364 IMPORT_C TInt NbrOfPromptLines() const;
367 * Get pointer to query controls control (editor)
369 * @param aLayout Controls layout (for one line queries use
370 * EDataLayout, ECodeLayout... and for
371 * multiline queries use
372 * EMultiDataFirstEdwin, EMultiDataSecondEdwin...)
373 * @return Pointer to control, NULL if not found
375 IMPORT_C virtual CCoeControl* ControlByLayoutOrNull(TInt aLayout);
378 * Sets and overrides other image or animation
379 * Takes ownership of aImage
381 IMPORT_C void SetImageL(CEikImage* aImage);
384 * Sets and overrides other image or animation
386 IMPORT_C void SetImageL(const TDesC& aImageFile,
387 TInt aBmpId, TInt aBmpMaskId);
389 * Sets and overrides other animation
392 IMPORT_C void SetAnimationL(TInt aResource);
395 * starts animation if one present
398 IMPORT_C void StartAnimationL();
401 * stops animation if one present
405 IMPORT_C TInt CancelAnimation();
408 * This cancels the query. Used when the query control has to get abandon the query
414 * @return true if the content of the editor is valid, false otherwise
416 TBool EditorContentIsValidL() const;
419 * This transfers CAknQueryControl's flags set by the dialog and then uses them.
420 * The method must be called after all the contained controls are constructed;
421 * Inside PreLayoutDynamicInitL is recommended.
423 * @param flag pattern to set and then act on.
425 void SetAndUseFlagsL( TBitFlags16 aFlags );
427 public: // Functions from CCoeControl
430 * From CCoeControl Handle key events. When a key event occurs,
431 * CONE calls this function for each control on the control stack,
432 * until one of them returns EKeyWasConsumed to indicate that it processed the key event.
433 * @param aKeyEvent The key event.
434 * @param aType The type of the event: EEventKey, EEventKeyUp or EEventKeyDown.
435 * @return Indicates whether or not the key event was used by this control.
437 IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType);
440 * From CCoeControl Give the control a mimimum size.
442 * @return The minimum size required by the control.
444 IMPORT_C TSize MinimumSize();
447 * From CCoeControl Added to pass-through focus-loss warnings.
448 * if not ready, this will leave.
449 * @return Indicates whether or not the key event was used by this control.
451 void PrepareForFocusLossL();
454 * From CCoeControl Added to pass-through focus-loss warnings.
455 * if not ready, this will leave.
456 * @return Indicates whether or not the key event was used by this control.
458 void FocusChanged(TDrawNow aDrawNow);
461 * From MEikEdwinObserver
463 * @param aEdwin Editor who sent the event
464 * @param aEventType Type of the event
466 IMPORT_C void HandleEdwinEventL(CEikEdwin* aEdwin,TEdwinEvent aEventType);
468 public:// Functions from MEikEdwinSizeObserver
471 * From MEikEdwinObserver
473 * @param aEdwin Editor who's size has changed
474 * @param aEventType Type of the size event
475 * @param aDesirableEdwinSize Desirable size of the edwin
477 IMPORT_C TBool HandleEdwinSizeEventL(CEikEdwin* aEdwin, TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize);
479 public:// Functions from MCoeControlObserver
482 * From MCoeControlObserver
483 * @param aControl Control who caused the event
484 * @param aEventType Type of the event
486 IMPORT_C void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
490 * @return Layout indication
492 * At the moment the layout is a good indication of the query type (PIN,number,etc)
493 * The query dialog uses this information to determine query type in order to
494 * process key events in a way dependent on the query type. These key events
495 * can't be processes by the control directly because they involve actions only
496 * the dialog can perform
498 inline TInt QueryType() const { return iQueryType; }
501 * Return window layout depending on Layout
502 * Window layout is done by the dialog
504 virtual void WindowLayout( TAknWindowLineLayout& aLayout ) const;
506 public:// Functions from CCoeControl
508 * From CCoeControl Count number of controls contained in a compound control.
510 * @return The number of component controls contained by this control.
512 TInt CountComponentControls() const;
515 * From CCoeControl Get the components of a compound control.
516 * It returns one of the control's component controls, identified by aIndex.
517 * @param anIndex The index of the control to get.
518 * @return The component control with an index of aIndex.
520 CCoeControl* ComponentControl(TInt anIndex) const;
524 * Handles pointer events
526 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
528 IMPORT_C void HandleResourceChange(TInt aType);
532 * Manage indexes into LAF tables
537 TIndex(TInt aNumberOfPromptLines);
540 TInt PromptLine() const;
543 TInt DQPWindowTextsLine2(TInt aLineNum) const;
544 TInt PNWindow() const;
545 TInt PQDWindow(TInt aLineNum) const;
546 TInt PQCWindow() const;
549 void SelfTest() const;
552 TInt iNumberOfPromptLines;
557 * From CCoeControl Respond to size changed. This function is called by CONE whenever SetExtentL(),
558 * SetSizeL(), SetRectL(), SetCornerAndSizeL(), or SetExtentToWholeScreenL()
559 * are called on the control.
564 * From CCoeControl Draw a control.
566 * @param aRect The region of the control to be redrawn.
568 void Draw(const TRect& aRect) const;
571 * From MObjectProvider
573 TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
576 * Perform layout by calling SizeChanged
583 * Determine the line widths for the prompt, depends on layout
585 virtual void SetLineWidthsL();
588 * After having read the query type from resource. This method is
589 * called in CostructFromResourceL()
591 * @see ConstructFromResourceL()
593 virtual void ConstructQueryL(TResourceReader& aRes);
596 * Layout rectangle (shift up and left by margins)
598 virtual TRect LayoutRect();
601 * Return the rect that is used by the dialog for layout
602 * This can be determined using LAF values and is equal to
603 * TPoint(0,0) plus the control size plus the margins
605 TRect DialogRect() const;
608 * Return the size of the dialog. This equals to the control
609 * size plus the margins.
611 TSize DialogSize() const;
614 * Calculates the size of the dialog. This can be determined
615 * using LAF values and is equal to the control size plus
618 void DialogSizeChanged();
622 * Layout the query prompt
624 virtual void LayoutPrompt(const TLayoutMethod& aLayoutM);
627 * Layout the image or the animation
629 virtual void LayoutImageOrAnim(const TLayoutMethod& aLayoutM);
632 * Layout the text editor
634 virtual void LayoutEditor(const TLayoutMethod& aLayoutM);
637 * Layout the editor frame
639 virtual void LayoutEditorFrame(const TLayoutMethod& aLayoutM);
642 * Layout the editor state indicator icons
644 virtual void LayoutEditorIndicator(const TLayoutMethod& aLayoutM);
649 * Get the extension object instance, if any exists.
651 CAknQueryExtension* QueryExtension() const;
654 * Draw editor frame and shadows
656 void DrawEditorFrame(CWindowGc& aGc,TRect& aRect) const;
661 * This transfers CAknQueryControl's flags set by the dialog
663 * @param flag pattern to set
666 void SetFlags( TBitFlags16 aFlags );
669 * This acts on the Query control flags that are set from CAknQueryDialog
675 * Call CAknTextControl::ParseTextL
680 static TInt StaticPictographCallBack( TAny* aPtr );
681 void PictographCallBack();
684 * Checks if this query control should contain embedded virtual keypad.
686 * @return ETrue if embedded virtual keypad should be used.
688 TBool EmbeddedVirtualInput() const;
691 * Returns pointer to dialog.
693 * @return Pointer to dialog if it exists.
695 CEikDialog* Dialog() const;
698 * Creates increment and decrement buttons.
701 void CreateIncAndDecButtonsL();
704 * Creates backspace button.
707 void CreateBackspaceButtonL();
710 * Layouts the query prompt in case of Full Screen Query.
713 void LayoutEditorForFullScreen( const TLayoutMethod& /*aLayoutM*/ );
716 * Layout the text editor in case of Full Screen Query.
719 void LayoutPromptForFullScreen();
722 * Callback for pin code timeouts for producing a tacticons.
724 * @param aThis Pointer to this object, which is used to
727 static TInt PinCodeTimeoutCallback( TAny* aThis );
730 * Plays a tacticon. Used by the timeout callback.
732 void PlayPinCodeTacticon();
735 * Resets the timer for pincode query tacticon playback.
737 void ResetPinCodeTacticonTimer();
740 * Stops/removes the timer for pincode query tacticon playback.
742 void StopPinCodeTacticonTimer();
748 IMPORT_C void* ExtensionInterface( TUid aInterface );
750 CAknLocationEditor *&LocationEd();
751 CAknLocationEditor *LocationEd() const;
755 * Return prompt needed by FEP to query dialog
757 void GetCaption( TDes& aCaption ) const;
760 * Sets the ECS CBA visibility in the query.
762 * TBool aVisible @c ETrue if an ECS number is entered to the
763 * query, @c EFalse otherwise.
765 void SetEcsCbaVisibleL( TBool aVisible );
768 * Attempts to make an emergency call if a valid emergency
769 * number has been entered to the query.
771 void AttemptEmergencyCallL();
774 /// Control for prompt text
775 CAknTextControl* iPrompt;
776 /// Editor indicator icons
777 CAknQueryEditIndicator* iEditIndicator;
781 CEikDateEditor* iDateEdwin;
783 CEikTimeEditor* iTimeEdwin;
785 CEikDurationEditor* iDurationEdwin;
787 CEikSecretEditor* iSecretEd;
789 CAknIntegerEdwin* iNumberEdwin;
790 /// Numeric secret editor
791 CAknNumericSecretEditor* iPinEdwin;
792 // Floating point editor
793 CEikFloatingPointEditor* iFloatingPointEditor;
798 // Layoutrect for Mfne
799 TAknLayoutRect iLayoutMfne;
800 // Emergency call detector
801 CAknEcsDetector* iEcsDetector;
802 // Emergency call observer
803 TAknQueryEcsObserver* iEcsObserver;
804 // Flags for emergency call support and other things
806 TUint16 iSpare_1; // padding
808 CAknBitmapAnimation* iAnimation;
809 // Pointer to query control observer
810 MAknQueryControlObserver* iQueryControlObserver;
813 // Layout rect for editor's vertical shadow
814 TAknLayoutRect iEditorVerShadow;
815 // Layout rect for editor's horizontal shadow
816 TAknLayoutRect iEditorHorShadow;
817 // Layout rect for editor's frame
818 TAknLayoutRect iEditorFrame;
820 TInt iNumberOfEditorLines; ///Maximum number of lines in the editor
822 TBool iHasEditor; //False for confirmation queries (default),
823 //true for all other queries
825 CArrayFixFlat<TInt>* iLineWidths; ///Widths of prompt lines (in pixels)
827 CAknButton* iIncreaseValueButton; //Reserved for plus button for MFNE editors
828 CAknButton* iDecreaseValueButton; //Reserved for minus button for MFNE editors
830 TSize iDialogSize; // Dialog size
832 CAknQueryControlExtension *iExtension;
840 * The extended control for a query dialog.
841 * ip and fixed point editors
843 * Manage layout of elements in a query dialog:- the text, the image
846 * @see CAknQueryDialog, CAknText
850 class CAknExtQueryControl : public CAknQueryControl
853 public: // Constructors and destructor
858 IMPORT_C CAknExtQueryControl();
863 IMPORT_C virtual ~CAknExtQueryControl();
865 public: //New functions
868 * Get ip address from ip editor.
870 * @return Returns data from editor
872 IMPORT_C TInetAddr GetInetAddress() const;
875 * Set ip address to editor
877 * @param aInetAddress to editor.
879 IMPORT_C void SetInetAddress(TInetAddr& aInetAddress);
882 * Get number from fixed point editor.
884 * @return Returns number from editor
886 IMPORT_C TInt GetFixedPointNumber() const;
889 * Set number to fixed point editor
890 * @param aNumber Number to editor
893 IMPORT_C void SetFixedPointNumberL(const TInt* aNumber);
896 public: // from CAknQueryControl
899 * Set minimum and maximum ip address to editor
900 * @param aMinimum Minimum value
901 * @param aMaximum Maximum value
904 IMPORT_C void SetMinimumAndMaximum(const TInetAddr& aMinimumAddress, const TInetAddr& aMaximumAddress);
907 * Set minimum and maximum fixed point number to editor
908 * @param aMinimumValue Minimum value
909 * @param aMaximumValue Maximum value
911 IMPORT_C void SetMinimumAndMaximum(TInt aMinimumValue, TInt aMaximumValue);
915 * Get pointer to query controls control (editor)
917 * @param aLayout Controls layout (for one line queries use
918 * EDataLayout, ECodeLayout... and for
919 * multiline queries use
920 * EMultiDataFirstEdwin, EMultiDataSecondEdwin...)
921 * @return Pointer to control, NULL if not found
923 IMPORT_C virtual CCoeControl* ControlByLayoutOrNull(TInt aLayout);
926 * @return true if the content of the editor is valid, false otherwise
928 TBool EditorContentIsValidL() const;
931 * This transfers CAknQueryControl's flags set by the dialog and then uses them.
932 * The method must be called after all the contained controls are constructed;
933 * Inside PreLayoutDynamicInitL is recommended.
935 * @param flag pattern to set and then act on.
937 void SetAndUseFlagsL( TBitFlags16 aFlags );
939 public: // Functions from CCoeControl
942 * From CCoeControl Added to pass-through focus-loss warnings.
943 * if not ready, this will leave.
944 * @return Indicates whether or not the key event was used by this control.
946 void PrepareForFocusLossL();
949 * From CCoeControl Added to pass-through focus-loss warnings.
950 * if not ready, this will leave.
951 * @return Indicates whether or not the key event was used by this control.
953 void FocusChanged(TDrawNow aDrawNow);
956 public:// Functions from MCoeControlObserver
959 * From MCoeControlObserver
960 * @param aControl Control who caused the event
961 * @param aEventType Type of the event
963 IMPORT_C void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
966 public:// Functions from CCoeControl
968 * From CCoeControl Count number of controls contained in a compound control.
970 * @return The number of component controls contained by this control.
972 TInt CountComponentControls() const;
975 * From CCoeControl Get the components of a compound control.
976 * It returns one of the control's component controls, identified by aIndex.
977 * @param anIndex The index of the control to get.
978 * @return The component control with an index of aIndex.
980 CCoeControl* ComponentControl(TInt anIndex) const;
983 * From CCoeControl. Handles pointer event.
984 * @param aPointerEvent Pointer event to be handled.
986 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
990 * Manage indexes into LAF tables
995 TIndex(TInt aNumberOfPromptLines);
998 TInt PromptLine() const;
1001 TInt DQPWindowTextsLine2(TInt aLineNum) const;
1002 TInt PNWindow() const;
1003 TInt PQDWindow(TInt aLineNum) const;
1006 void SelfTest() const;
1009 TInt iNumberOfPromptLines;
1016 * After having read the query type from resource. This method is
1017 * called in CostructFromResourceL()
1019 * @see ConstructFromResourceL()
1021 virtual void ConstructQueryL(TResourceReader& aRes);
1026 * Layout the text editor
1028 virtual void LayoutEditor(const TLayoutMethod& aLayoutM);
1035 IMPORT_C void* ExtensionInterface( TUid aInterface );
1040 * This transfers CAknQueryControl's flags set by the dialog
1042 * @param flag pattern to set
1045 void SetFlags( TBitFlags16 aFlags );
1048 * This acts on the Query control flags that are set from CAknQueryDialog
1051 void DeployFlagsL();
1053 static TInt StaticPictographCallBack( TAny* aPtr );
1054 void PictographCallBack();
1058 CAknIpFieldEditor* iIpEditor;
1059 CEikFixedPointEditor* iFixedPointEditor;