fmradio/fmradio/inc/fmradiofrequencyquerycontrol.h
branchRCL_3
changeset 19 cce62ebc198e
parent 18 1a6714c53019
child 20 93c594350b9a
equal deleted inserted replaced
18:1a6714c53019 19:cce62ebc198e
     1 /*
       
     2 * Copyright (c) 2005-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:  Header file for CFMRadioFrequencyQueryControl
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef FMRADIOFREQUENCYQUERYCONTROL_H
       
    20 #define FMRADIOFREQUENCYQUERYCONTROL_H
       
    21 
       
    22 #include	<aknEditStateIndicator.h>
       
    23 #include	<AknIndicatorContainer.h>
       
    24 #include	<aknQueryControl.h>
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 const TInt KFMRadioFrequencyQueryDialogCustomAdditionHeight = 110;
       
    29 
       
    30 class CFMRadioFrequencyEditor;
       
    31 class CAknsFrameBackgroundControlContext;
       
    32 
       
    33 /**
       
    34  * Custom query control for frequency query dialog.
       
    35  */
       
    36 class CFMRadioFrequencyQueryControl : public CAknQueryControl
       
    37     {
       
    38 
       
    39 public:  // Methods
       
    40 
       
    41     /**
       
    42      * C++ default constructor.
       
    43      */
       
    44     CFMRadioFrequencyQueryControl();
       
    45     
       
    46     /**
       
    47      * Destructor.
       
    48      */
       
    49     ~CFMRadioFrequencyQueryControl();
       
    50 
       
    51 	/**
       
    52      * This control is constructed by the system using this static method.
       
    53      */
       
    54 	static SEikControlInfo StaticCreateCustomControl( TInt aIdentifier );
       
    55 
       
    56     /**
       
    57 	 * Gets the frequency from the control
       
    58 	 *
       
    59 	 * @return Frequency
       
    60      */
       
    61     TUint32 Frequency() const;
       
    62 
       
    63 	/**
       
    64 	 * Sets the frequency to the control
       
    65 	 *
       
    66 	 * @param aFreq Frequency
       
    67      */
       
    68     void SetFrequency(const TUint32 aFreq);
       
    69 
       
    70 	/**
       
    71 	 * Handle possible editor leave.
       
    72 	 *
       
    73 	 * @return ETrue, if editor can be left.
       
    74 	 */
       
    75 	TBool CanLeaveEditorL();
       
    76 
       
    77     // from base class CAknQueryControl
       
    78 	/**
       
    79      * From CAknQueryControl
       
    80      *
       
    81      * @see CAknQueryControl::ControlByLayoutOrNull( TInt aLayout )
       
    82      */
       
    83     CCoeControl* ControlByLayoutOrNull( TInt aLayout );
       
    84 
       
    85 	/**
       
    86      * From CAknQueryControl
       
    87      * 
       
    88      * @see CAknQueryControl::EditorContentIsValidL() const
       
    89      */
       
    90     TBool EditorContentIsValidL() const;
       
    91 
       
    92 	/**
       
    93      * From CAknQueryControl
       
    94      *
       
    95      * @see CAknQueryControl::SetAndUseFlags( TBitFlags16 aFlags )
       
    96      */
       
    97     void SetAndUseFlags( TBitFlags16 aFlags );
       
    98 
       
    99 	/**
       
   100 	 * From CAknQueryControl
       
   101 	 *
       
   102 	 * @see CAknQueryControl::WindowLayout( TAknWindowLineLayout& aLayout ) 
       
   103 	 *  const
       
   104 	 */
       
   105 	void WindowLayout( TAknWindowLineLayout& aLayout ) const;
       
   106 
       
   107 
       
   108     // from base class CCoeControl
       
   109 	/**
       
   110      * From CCoeControl
       
   111      *
       
   112      * @see CCoeControl::PrepareForFocusLossL()
       
   113      */
       
   114     void PrepareForFocusLossL();
       
   115 
       
   116 	/**
       
   117      * From CCoeControl
       
   118      *
       
   119      * @see CCoeControl::FocusChanged( TDrawNow aDrawNow )
       
   120      */
       
   121     void FocusChanged( TDrawNow aDrawNow );
       
   122 
       
   123 	/**
       
   124      * From CCoeControl
       
   125      *
       
   126      * @see CCoeControl::CountComponentControls() const
       
   127      */
       
   128     TInt CountComponentControls() const;
       
   129 
       
   130 	/**
       
   131      * From CCoeControl
       
   132      *
       
   133      * @see CCoeControl::ComponentControl( TInt aIndex ) const
       
   134      */
       
   135     CCoeControl* ComponentControl( TInt aIndex ) const;
       
   136     
       
   137     /**
       
   138      * Is public so that callbacks may utilize this.
       
   139      * Sets repeat intervals.
       
   140      * 
       
   141      * @param aAccelerated ETrue=accelerated speed, EFalse=default values
       
   142      */
       
   143     void SetAcceleratedLongPress(TBool aAccelerated);
       
   144     
       
   145     /**
       
   146      * From CCoeControl
       
   147      * 
       
   148      * @see CCoeControl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   149      * */
       
   150     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   151     
       
   152     // from base class MCoeControlObserver
       
   153 	/**
       
   154      * From MCoeControlObserver
       
   155      *
       
   156      * @see MCoeControlObserver::HandleControlEventL( 
       
   157      *    CCoeControl* aControl, 
       
   158      *    TCoeEvent aEventType )
       
   159      */
       
   160     void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
       
   161 
       
   162 	class CFMRadioManualTuningEditorIndicator : public CAknIndicatorContainer, public MAknEditingStateIndicator
       
   163 		{
       
   164 		public:
       
   165 			
       
   166 			static CFMRadioManualTuningEditorIndicator* NewL(CCoeControl* aControl);
       
   167 			
       
   168 			~CFMRadioManualTuningEditorIndicator();
       
   169 
       
   170 			/**
       
   171 			 * From MAknEditingStateIndicator
       
   172 			 */
       
   173 			void SetState(TAknEditingState aState); 
       
   174 
       
   175 			/**
       
   176 			 * From MAknEditingStateIndicator
       
   177 			 */
       
   178 			CAknIndicatorContainer* IndicatorContainer();
       
   179 
       
   180 			/**
       
   181 			 * Sets the information about the query flags.
       
   182 			 */
       
   183 			void SetFlags(TBitFlags16 aFlags);
       
   184 
       
   185 		private:
       
   186 		
       
   187 			CFMRadioManualTuningEditorIndicator();
       
   188 
       
   189 			void ConstructL(CCoeControl* aControl);
       
   190             
       
   191             // from base class CAknIndicatorContainer
       
   192 			/**
       
   193 			* From CAknIndicatorContainer
       
   194 			* 
       
   195 			* @see CAknIndicatorContainer::Reserved_1()
       
   196 			*/
       
   197 			void Reserved_1();
       
   198 
       
   199 		private:
       
   200 			/** 
       
   201 			 * Flags 
       
   202 			 */
       
   203 			TBitFlags16 iBitFlags;
       
   204 
       
   205 		};
       
   206 	
       
   207 		public:
       
   208 	    /**
       
   209 	     * Manage indexes into LAF tables
       
   210 	     */
       
   211 	    class TIndex 
       
   212 	    {   
       
   213 	    public:     
       
   214 	        TIndex(TInt aNumberOfPromptLines);  
       
   215 	    
       
   216 	    public: 
       
   217 	        TInt PromptLine() const;    
       
   218 	        
       
   219 	    public: 
       
   220 	        TInt DQPWindowTextsLine2(TInt aLineNum) const;  
       
   221 	        TInt PNWindow() const;  
       
   222 	        TInt PQDWindow(TInt aLineNum) const;    
       
   223 	        TInt PQCWindow() const;
       
   224 	        
       
   225 	    private:    
       
   226 
       
   227 	
       
   228 	    private:    
       
   229 	        TInt  iNumberOfPromptLines; 
       
   230 	    };  
       
   231     
       
   232 protected:  // Methods
       
   233 
       
   234     // from base class
       
   235     /**
       
   236      * From CAknQueryControl
       
   237      * 
       
   238      * @see CAknQueryControl::ConstructQueryL( TResourceReader& aRes )
       
   239      */
       
   240     void ConstructQueryL( TResourceReader& aRes );
       
   241 
       
   242 	/**
       
   243      * From CAknQueryControl
       
   244      *
       
   245      * @see CAknQueryControl::LayoutEditor( const TLayoutMethod& aLayoutM )
       
   246      */
       
   247 	void LayoutEditor( const TLayoutMethod& aLayoutM );
       
   248 
       
   249     /**
       
   250      * From CAknQueryControl
       
   251      *
       
   252      * @see CAknQueryControl::LayoutPrompt( const TLayoutMethod& aLayoutM )
       
   253      */
       
   254 	void LayoutPrompt( const TLayoutMethod& aLayoutM );
       
   255 
       
   256     /**
       
   257      * From CAknQueryControl
       
   258      *
       
   259      * @see CAknQueryControl::LayoutImageOrAnim( 
       
   260      *    const TLayoutMethod& aLayoutM )
       
   261      */
       
   262     void LayoutImageOrAnim( const TLayoutMethod& aLayoutM );
       
   263 
       
   264     /**
       
   265      * From CAknQueryControl
       
   266      *
       
   267      * @see CAknQueryControl::LayoutEditorFrame( 
       
   268      *    const TLayoutMethod& aLayoutM )
       
   269      */
       
   270     void LayoutEditorFrame( const TLayoutMethod& aLayoutM );
       
   271 
       
   272     /**
       
   273      * From CAknQueryControl
       
   274      *
       
   275      * @see CAknQueryControl::LayoutEditorIndicator( 
       
   276      *    const TLayoutMethod& aLayoutM )
       
   277      */
       
   278     void LayoutEditorIndicator( const TLayoutMethod& aLayoutM );
       
   279 
       
   280     /**
       
   281      * From CAknQueryControl
       
   282      *
       
   283      * @see CAknQueryControl::LayoutRect()
       
   284      */
       
   285 	TRect LayoutRect();
       
   286 
       
   287     /**
       
   288      * From CAknQueryControl
       
   289      *
       
   290      * @see CAknQueryControl::SetLineWidthsL();
       
   291      */
       
   292 	void SetLineWidthsL();
       
   293 
       
   294 	/**
       
   295      * From CCoeControl
       
   296      *
       
   297      * @see CCoeControl::Draw( const TRect& aRect ) const
       
   298      */
       
   299     void Draw( const TRect& aRect ) const;
       
   300 
       
   301     /**
       
   302      * Draw editor frame and shadows
       
   303      */
       
   304      void DrawFrequencyEditorFrame(CWindowGc& aGc,TRect& aRect) const;
       
   305      
       
   306 	/**
       
   307      * From CCoeControl
       
   308      *
       
   309      * @see CCoeControl::SizeChanged()
       
   310      */
       
   311     void SizeChanged();
       
   312 
       
   313 	/**
       
   314     * From MObjectProvider
       
   315     *
       
   316     * @see MObjectProvider::MopSupplyObject( TTypeUid aId )
       
   317     */
       
   318     TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
       
   319     
       
   320     /**
       
   321     * From CCoeControl.
       
   322     * @see CCoeControl::HandlePointerEventL()
       
   323     */
       
   324     void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   325     
       
   326 private:    // Methods
       
   327     
       
   328     /**
       
   329      * Starts timer to accelerate long press repeat interval
       
   330      */
       
   331     void StartKeypress();
       
   332     
       
   333     /**
       
   334      * Instructs frequency editor component to update the appropriate field
       
   335      * if it is possible (user is not typing numbers). Update is either
       
   336      * incrementing or decrementing depending on state of iChangeDirectionIncrease.
       
   337      * If it is ETrue, the desired action is to increment the value.
       
   338      */
       
   339     void DoIncrementOrDecrement();
       
   340 
       
   341     /**
       
   342      * Callback for iLongPressAccelerationTimer
       
   343      * Speeds up repeated key event interval.
       
   344      * See CPeriodic::Start()
       
   345      * 
       
   346      * @param aAny pointer to self
       
   347      * 
       
   348      * @return ignored
       
   349      */
       
   350     static TInt LongPressAccelerateCallBack( TAny* aAny );
       
   351     
       
   352     /**
       
   353      * Callback for iLongPressTimer
       
   354      * Called repeatedly to act as long keypress repeat event.
       
   355      * See CPeriodic::Start()
       
   356      * 
       
   357      * @return ignored
       
   358      */
       
   359     static TInt LongPressTimerCallBack( TAny* aAny );
       
   360     
       
   361 private:    // Data
       
   362 
       
   363 	/** 
       
   364 	 * Prompt 
       
   365 	 */
       
   366     CEikLabel* iMyPrompt;
       
   367     
       
   368 	/**  
       
   369 	 * Editor indicator 
       
   370 	 */
       
   371     CFMRadioManualTuningEditorIndicator* iMyEditorIndicator;
       
   372 	
       
   373 	/** 
       
   374 	 * Editor 
       
   375 	 */
       
   376     CFMRadioFrequencyEditor*	iFreqEditor;
       
   377     
       
   378 	/** 
       
   379 	 * A control context that provides a layout background generated from a frame item 
       
   380 	 */
       
   381     CAknsFrameBackgroundControlContext* iEditorContext;
       
   382      /**
       
   383      * Accelerates manual tuning speed after two seconds
       
   384      */
       
   385     CPeriodic* iLongPressAccelerationTimer;
       
   386     
       
   387     CPeriodic* iLongPressTimer;
       
   388     
       
   389     /**
       
   390      * State of current keypress. Value is valid only between EEventKeyDown
       
   391      * and EEventKeyUp.
       
   392      * ETrue == increment, EFalse == decrement
       
   393      */
       
   394     TBool iChangeDirectionIncrease;
       
   395     
       
   396     TBool iKeyPressReported;
       
   397     
       
   398     };
       
   399 
       
   400 #endif      // FMRADIOFREQUENCYQUERYCONTROL_H