williamr@2: /* williamr@2: * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * 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 williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Base class for legacy Uikon buttons williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #if !defined(__EIKBUTB_H__) williamr@2: #define __EIKBUTB_H__ williamr@2: williamr@2: #if !defined(__EIKBCTRL_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__UIKON_HRH__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #include williamr@2: williamr@2: #include williamr@2: williamr@2: class TEikButtonCoordinator; williamr@2: williamr@2: /** williamr@2: * Possible button behaviours williamr@2: */ williamr@2: enum TButtonBehavior williamr@2: { williamr@2: EEikButtonStaysClear=EEikButStaysClear, williamr@2: EEikButtonStaysSet=EEikButStaysSet, williamr@2: EEikButtonLatches=EEikButLatches, williamr@2: EEikButtonReportsOnPointerDown=EEikButReportOnPointerDown williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Base class for button controls williamr@2: * williamr@2: * This class defines behavior available to all button classes. williamr@2: * williamr@2: * @lib eikcoctl williamr@2: * @since S60 1.0 williamr@2: */ williamr@2: class CEikButtonBase : public CEikBorderedControl williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * C++ constructor williamr@2: */ williamr@2: IMPORT_C CEikButtonBase(); williamr@2: williamr@2: /** williamr@2: * C++ destructor williamr@2: */ williamr@2: IMPORT_C ~CEikButtonBase(); williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * States that the button can be in. williamr@2: */ williamr@2: enum TState williamr@2: { williamr@2: EClear =0, williamr@2: ESet =1, williamr@2: EIndeterminate =2 williamr@2: }; williamr@2: williamr@2: public: // new functions williamr@2: /** williamr@2: * Access the state williamr@2: * williamr@2: * @return The state of the button williamr@2: */ williamr@2: IMPORT_C TState State() const; williamr@2: williamr@2: /** williamr@2: * Set the state of the button. williamr@2: * williamr@2: * @param aState The state the button is to be set to. williamr@2: */ williamr@2: IMPORT_C void SetState(TState aState); williamr@2: williamr@2: /** williamr@2: * Cause the button to animate. The appearance changes to the "pressed in" state. Subsequent williamr@2: * behaviour depends upon the SetBehavior setting williamr@2: */ williamr@2: IMPORT_C virtual void Animate(); williamr@2: williamr@2: /** williamr@2: * Sets the coordinator for the button. williamr@2: * williamr@2: * @param aButCoord The coordinator to set for these button williamr@2: */ williamr@2: IMPORT_C void SetCoordinator(TEikButtonCoordinator* aButCoord); williamr@2: williamr@2: /** williamr@2: * Sets the button’s behaviour. A button can be made to stay set or stay clear. It can also be made a latching button. williamr@2: * williamr@2: * @param aBehavior Behaviour to use williamr@2: */ williamr@2: IMPORT_C void SetBehavior(TButtonBehavior aBehavior); williamr@2: williamr@2: /** williamr@2: * Sets the control to ignore the next pointer up event williamr@2: */ williamr@2: IMPORT_C void SetIgnoreNextPointerUp(); williamr@2: williamr@2: protected: williamr@2: /** williamr@2: * The draw state of the button. williamr@2: */ williamr@2: enum TDrawState williamr@2: { williamr@2: EDrawClear =SLafButtonBase::EDrawClear, williamr@2: EDrawSet =SLafButtonBase::EDrawSet, williamr@2: EDrawIndeterminate =SLafButtonBase::EDrawIndeterminate, williamr@2: EDrawClearPressed =SLafButtonBase::EDrawClearPressed, williamr@2: EDrawSetPressed =SLafButtonBase::EDrawSetPressed, williamr@2: EDrawIndeterminatePressed =SLafButtonBase::EDrawIndeterminatePressed williamr@2: }; williamr@2: williamr@2: protected: // new functions williamr@2: /** williamr@2: * Set whether the control should report on pointer down williamr@2: */ williamr@2: IMPORT_C void SetReportOnPointerDown(); williamr@2: williamr@2: /** williamr@2: * Access the draw state defined in SLafButtonBase williamr@2: * williamr@2: * @return The draw state of the control williamr@2: */ williamr@2: IMPORT_C TDrawState DrawState() const; williamr@2: williamr@2: /** williamr@2: * Returns whether the button is currently pressed. williamr@2: * williamr@2: * @return EFalse if the button is not pressed williamr@2: */ williamr@2: IMPORT_C TBool IsPressed() const; williamr@2: williamr@2: /** williamr@2: * Sets the button to be tri-state williamr@2: */ williamr@2: IMPORT_C void SetAllowTristate(); williamr@2: williamr@2: /** williamr@2: * Transfers the draw state to the referenced button williamr@2: * williamr@2: * @param aTargetButton button to transfer the williamr@2: */ williamr@2: IMPORT_C void CopyDrawStateTo(CEikButtonBase* aTargetButton) const; williamr@2: williamr@2: public: // from CCoeControl williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Obtain the color use list for this control williamr@2: * williamr@2: * @param aColorUseList Output; upon non-leaving return, constains the color use list williamr@2: */ williamr@2: IMPORT_C virtual void GetColorUseListL(CArrayFix& aColorUseList) const; williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Perform necessary operations when resource changes. This includes layout switches, or other events williamr@2: * that affect appearance. williamr@2: * williamr@2: * @param aType Type of resouce changed williamr@2: */ williamr@2: IMPORT_C virtual void HandleResourceChange(TInt aType); // not available before Release 005u williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Serialize the control's state. For testing williamr@2: * williamr@2: * @param aWriteStream Stream to write to. williamr@2: */ williamr@2: IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const; williamr@2: williamr@2: private: // from CCoeControl williamr@2: IMPORT_C void Reserved_2(); williamr@2: williamr@2: private: // new functions williamr@2: /** williamr@2: * Called but button framework when the state of the control has changed williamr@2: */ williamr@2: IMPORT_C virtual void StateChanged(); williamr@2: IMPORT_C virtual void Reserved_3(); williamr@2: williamr@2: public: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * A pointer event is being routed to this control for handling williamr@2: * williamr@2: * @param aPointerEvent Wserv pointer event williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * A key event is being being given to the control for handling williamr@2: * williamr@2: * @param aKeyEvent Key event code williamr@2: * @param aType Type of event (i.e.. EEventKey, EEventKeyUp, EEventKeyDown) williamr@2: * @return EKeyWasConsumed or EKeyWasNotConsumed williamr@2: */ williamr@2: IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Interface used by the FEP or others to determine what type of input the control requires. williamr@2: * williamr@2: * @return A value indicating what input is required. williamr@2: */ williamr@2: IMPORT_C TCoeInputCapabilities InputCapabilities() const; williamr@2: williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: * williamr@2: * Interface for extending virtual functionality of CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: private: // internal use only williamr@2: TBool ClickCompleted(); williamr@2: williamr@2: private: williamr@2: enum { EIgnoreNextPointerUp=0x1000 }; williamr@2: williamr@2: protected: williamr@2: /** williamr@2: * Flags for the button class hierarchy williamr@2: */ williamr@2: TInt iButFlags; williamr@2: williamr@2: private: williamr@2: /** williamr@2: * Button co-ordinator associated with this button williamr@2: */ williamr@2: TEikButtonCoordinator* iButCoord; williamr@2: williamr@2: TInt iSpare[2]; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Button coordinator class williamr@2: * williamr@2: * This class performs simple coordination functions on a set of buttons. It ensures that only williamr@2: * one button of those sharing a coordinator is set at once. williamr@2: * williamr@2: * @lib eikcoctl williamr@2: * @since S60 1.0 williamr@2: */ williamr@2: class TEikButtonCoordinator williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Constructor williamr@2: */ williamr@2: IMPORT_C TEikButtonCoordinator(); williamr@2: williamr@2: /** williamr@2: * Set the current chosen button to the passed-in object. williamr@2: * Any previously selected button is set to the Clear state and re-drawn. williamr@2: * williamr@2: * @param aChosenButton Button to set as the new chosen button. williamr@2: */ williamr@2: IMPORT_C void SetChosenButton(CEikButtonBase* aChosenButton); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * Records the currently chosen button associated with this co-ordinator object. williamr@2: */ williamr@2: CEikButtonBase* iChosenButton; williamr@2: }; williamr@2: williamr@2: #endif // __EIKBUTB_H__