epoc32/include/mw/eikbutb.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     1 /*
     2 * Copyright (c) 2001-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:  Base class for legacy Uikon buttons
    15 *
    16 */
    17 
    18 
    19 #if !defined(__EIKBUTB_H__)
    20 #define __EIKBUTB_H__
    21 
    22 #if !defined(__EIKBCTRL_H__)
    23 #include <eikbctrl.h>
    24 #endif
    25 
    26 #if !defined(__UIKON_HRH__)
    27 #include <uikon.hrh>
    28 #endif
    29 
    30 #include <eikon.hrh>
    31 
    32 #include <lafpublc.h>
    33 
    34 class TEikButtonCoordinator;
    35 
    36 /**
    37 * Possible button behaviours 
    38 */
    39 enum TButtonBehavior
    40 	{
    41 	EEikButtonStaysClear=EEikButStaysClear,
    42 	EEikButtonStaysSet=EEikButStaysSet,
    43 	EEikButtonLatches=EEikButLatches,
    44 	EEikButtonReportsOnPointerDown=EEikButReportOnPointerDown
    45 	};
    46 	
    47 /**
    48  *  Base class for button controls
    49  *
    50  *  This class defines behavior available to all button classes.
    51  *
    52  *  @lib eikcoctl
    53  *  @since S60 1.0
    54  */
    55 class CEikButtonBase : public CEikBorderedControl
    56 	{
    57 public:
    58     /**
    59      * C++ constructor
    60      */
    61     IMPORT_C CEikButtonBase();
    62     
    63     /**
    64      * C++ destructor
    65      */     
    66     IMPORT_C ~CEikButtonBase();
    67     
    68 public:
    69 
    70     /**
    71      * States that the button can be in.
    72      */     
    73     enum TState
    74         {
    75         EClear		  	=0,
    76         ESet			=1,
    77         EIndeterminate  =2
    78         };
    79 		
    80 public: // new functions
    81     /**
    82      * Access the state
    83      *
    84      * @return The state of the button
    85      */     
    86     IMPORT_C TState State() const;
    87     
    88     /**
    89      * Set the state of the button.
    90      *
    91      * @param aState The state the button is to be set to.
    92      */     
    93     IMPORT_C void SetState(TState aState);
    94     
    95     /**
    96      * Cause the button to animate. The appearance changes to the "pressed in" state. Subsequent 
    97      *  behaviour depends upon the SetBehavior setting
    98      */     
    99     IMPORT_C virtual void Animate();
   100     
   101     /**
   102      * Sets the coordinator for the button.
   103      *
   104      * @param aButCoord The coordinator to set for these button
   105      */     
   106     IMPORT_C void SetCoordinator(TEikButtonCoordinator* aButCoord);
   107     
   108     /**
   109      * Sets the button’s behaviour. A button can be made to stay set or stay clear. It can also be made a latching button.
   110      *
   111      * @param aBehavior Behaviour to use
   112      */     
   113     IMPORT_C void SetBehavior(TButtonBehavior aBehavior);
   114     
   115     /**
   116      * Sets the control to ignore the next pointer up event
   117      */     
   118     IMPORT_C void SetIgnoreNextPointerUp();
   119     
   120 protected:
   121     /**
   122     * The draw state of the button.
   123     */
   124     enum TDrawState
   125         {
   126         EDrawClear					=SLafButtonBase::EDrawClear,
   127         EDrawSet					=SLafButtonBase::EDrawSet,
   128         EDrawIndeterminate			=SLafButtonBase::EDrawIndeterminate,
   129         EDrawClearPressed			=SLafButtonBase::EDrawClearPressed,
   130         EDrawSetPressed				=SLafButtonBase::EDrawSetPressed,
   131         EDrawIndeterminatePressed	=SLafButtonBase::EDrawIndeterminatePressed
   132         };
   133 
   134 protected: // new functions
   135     /**
   136      * Set whether the control should report on pointer down
   137      */     
   138     IMPORT_C void SetReportOnPointerDown();
   139     
   140     /**
   141      *  Access the draw state defined in SLafButtonBase
   142      *
   143      * @return The draw state of the control
   144      */     
   145     IMPORT_C TDrawState DrawState() const;
   146     
   147     /**
   148      * Returns whether the button is currently pressed.
   149      *
   150      * @return EFalse if the button is not pressed
   151      */     
   152     IMPORT_C TBool IsPressed() const;
   153     
   154     /**
   155      * Sets the button to be tri-state
   156      */     
   157     IMPORT_C void SetAllowTristate();
   158     
   159     /**
   160      * Transfers the draw state to the referenced button
   161      *
   162      * @param aTargetButton button to transfer the 
   163      */     
   164     IMPORT_C void CopyDrawStateTo(CEikButtonBase* aTargetButton) const;
   165     
   166 public:	// from CCoeControl
   167     /**
   168      *  From CCoeControl
   169      * 
   170      * Obtain the color use list for this control
   171      *
   172      * @param aColorUseList Output; upon non-leaving return, constains the color use list
   173      */     
   174     IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const;
   175     
   176     /**
   177      *  From CCoeControl
   178      * 
   179      *  Perform necessary operations when resource changes.  This includes layout switches, or other events
   180      *  that affect appearance.
   181      *
   182      * @param aType Type of resouce changed
   183      */     
   184     IMPORT_C virtual void HandleResourceChange(TInt aType);			// not available before Release 005u
   185     
   186     /**
   187      *  From CCoeControl
   188      * 
   189      *  Serialize the control's state. For testing
   190      *
   191      * @param aWriteStream  Stream to write to.
   192      */     
   193     IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const;
   194     
   195 private: // from CCoeControl
   196     IMPORT_C void Reserved_2();
   197 
   198 private: // new functions
   199     /**
   200     * Called but button framework when the state of the control has changed
   201     */
   202     IMPORT_C virtual void StateChanged();
   203     IMPORT_C virtual void Reserved_3();
   204 
   205 public:
   206     /**
   207      *  From CCoeControl
   208      * 
   209      * A pointer event is being routed to this control for handling
   210      *
   211      * @param aPointerEvent Wserv pointer event
   212      */     
   213     IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
   214     
   215     /**
   216      *  From CCoeControl
   217      * 
   218      * A key event is being being given to the control for handling
   219      *
   220      * @param aKeyEvent     Key event code
   221      * @param aType            Type of event (i.e.. EEventKey, EEventKeyUp, EEventKeyDown)
   222      * @return EKeyWasConsumed or EKeyWasNotConsumed
   223      */     
   224     IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
   225 
   226     /**
   227      *  From CCoeControl
   228      * 
   229      * Interface used by the FEP or others to determine what type of input the control requires.
   230      *
   231      * @return A value indicating what input is required.
   232      */     
   233     IMPORT_C TCoeInputCapabilities InputCapabilities() const; 
   234     
   235 private:
   236     /**
   237     * From CAknControl
   238     * 
   239     * Interface for extending virtual functionality of CAknControl
   240     */
   241     IMPORT_C void* ExtensionInterface( TUid aInterface );
   242     
   243 private: // internal use only
   244     TBool ClickCompleted();
   245 
   246 private:
   247     enum { EIgnoreNextPointerUp=0x1000 };
   248 
   249 protected:
   250     /**
   251     * Flags for the button class hierarchy
   252     */ 
   253     TInt iButFlags;
   254     
   255 private:
   256     /**
   257     * Button co-ordinator associated with this button
   258     */ 
   259     TEikButtonCoordinator* iButCoord;
   260     
   261     TInt iSpare[2];
   262     };
   263 
   264 /**
   265  *  Button coordinator class
   266  * 
   267  * This class performs simple coordination functions on a set of buttons. It ensures that only
   268  * one button of those sharing a coordinator is set at once.
   269  *
   270  *  @lib eikcoctl
   271  *  @since S60 1.0
   272  */
   273 class TEikButtonCoordinator
   274 	{
   275 public:
   276     /**
   277     * Constructor
   278     */
   279     IMPORT_C TEikButtonCoordinator();
   280     
   281     /**
   282     * Set the current chosen button to the passed-in object. 
   283     * Any previously selected button is set to the Clear state and re-drawn.
   284     *
   285     * @param aChosenButton Button to set as the new chosen button.
   286     */
   287     IMPORT_C void SetChosenButton(CEikButtonBase* aChosenButton);		
   288 
   289 private:
   290     /**
   291     * Records the currently chosen button associated with this co-ordinator object.
   292     */
   293     CEikButtonBase* iChosenButton;
   294     };		 
   295 
   296 #endif // __EIKBUTB_H__