Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Command button class interfaces. Contains a common base class
15 * for command-generating buttons, plus several concrete, specialized classes
21 #if !defined(__EIKCMBUT_H__)
22 #define __EIKCMBUT_H__
24 #if !defined(__EIKBUTB_H__)
28 #if !defined(__COECCNTX_H__)
32 #if !defined(__GULUTIL_H__)
38 class CEikAlignedControl;
39 class TResourceReader;
40 class CEikCommandStack;
43 * Base class for buttons that generate commands.
45 * MControlContext is mixed in. This class is used as the interface to the button member of
46 * CEikLabeledButton, as well as being the base class for CEikCommandButton, CEikTextButton, and CEikBitmapButton
51 class CEikCommandButtonBase : public CEikButtonBase, public MCoeControlContext
55 * Enumeration to tag the components of a command button (text or image)
64 * Controls which of the components of the command button are shown.
74 * Layout and font options for the components of the command button
78 EFirstRightSecondLeft=0x0000,
79 EFirstBottomSecondTop=0x0001,
80 EFirstTopSecondBottom=0x0002,
81 EFirstLeftSecondRight=0x0003,
86 * Options for where excess space between the two components of the command button is distrubuted
95 public: // new functions
100 IMPORT_C ~CEikCommandButtonBase();
103 * Sets the layout of the button
104 * @param aLayout Layout enumeration
106 IMPORT_C void SetButtonLayout(TLayout aLayout);
109 * Sets where excess space is to be put
110 * @param aExcess Excess space enumeration
112 IMPORT_C void SetExcessSpace(TExcess aExcess);
115 * Sets the content of the button
119 IMPORT_C void SetDisplayContent(TDisplayContent aContent);
122 * Causes the content to be (re-)laid out.
124 IMPORT_C void LayoutComponents();
127 * Read preamble part of the resource. This call can be followed by calls to
128 * ConstructLabelFromResourceL and/or ConstructImageFromResourceL to complete contruction.
130 IMPORT_C void StartConstructFromResourceL(TResourceReader& aReader);
133 * Constructs a label component for the button
135 * @aparam aWhich Which component to construct in this call
137 IMPORT_C void ConstructLabelFromResourceL(TResourceReader& aReader,TWhichComponent aWhich);
140 * Constructs an image component for the button
142 * @aparam aWhich Which component to construct in this call
144 IMPORT_C void ConstructImageFromResourceL(TResourceReader& aReader,TWhichComponent aWhich);
147 * Cause a recalculation of the components alignment
149 IMPORT_C virtual void UpdateComponentAlignment();
152 * Sets this button to be the default.
154 IMPORT_C void SetDefault(TBool aIsDefault);
156 public: // from CCoeControl. See base class documentation
160 * Sets the button to be inactive. The button is drawn with a dimmed effect.
162 * @param aDimmed If not EFalse, set the state to dimmed. Otherwise set to non-dimmed
164 IMPORT_C void SetDimmed(TBool aDimmed);
169 * Reports to the caller the minimum size that the control can be, given its contents.
171 * @return The minimum size
173 IMPORT_C TSize MinimumSize();
178 * Returns the number of component controls
180 * @return Number of component controls
182 IMPORT_C TInt CountComponentControls() const;
187 * Return a pointer to the component control at the give index.
189 * @return Pointer to the conponent control. No ownership is transferred
191 IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const;
196 * Make the control ready for display.
198 IMPORT_C void ActivateL();
203 * Sets the control whose window is to be used as a container for this control
205 * @param aContainer control
207 IMPORT_C void SetContainerWindowL(const CCoeControl& aContainer);
212 * Called when the focus has changed
214 * @param aDrawNow Iff not EFalse, then the control is requested to redraw.
216 IMPORT_C void FocusChanged(TDrawNow aDrawNow);
221 * CONE framework is requesting that the passed-in key be handled.
223 * @param aKeyEvent Wserv event type
224 * @param aKeyCode Key code
226 IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode /*aType*/);
231 * Obtain the list of colors to be used by this control
233 * @param aColorUseList
235 IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const;
240 * This is called when resource or layout or other display-affecting setting has changed.
241 * Change the internals of the control so that it is ready for a subsequent SizeChanged call.
243 * @param aType Type of resource or setting that has changed
245 IMPORT_C virtual void HandleResourceChange(TInt aType);
250 * Handle a pointer event that has been routed to this control
252 * @param aPointerEvent Pointer event to handle
254 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
256 public: // but not exported
258 * Access to the command stack
260 * @return pointer to the command stack
262 CEikCommandStack* CommandStack() const;
265 * Access to the button flags
267 * @return The button flag pattern
269 TInt ButFlags() const;
272 * Access to whether the button is default
274 * @return EFalse iff the button is not default.
276 TBool IsDefault() const;
281 * From CEikButtonBase
283 * Framework method called when the state changes
285 IMPORT_C void StateChanged();
291 IMPORT_C CEikCommandButtonBase();
294 * Sets the label text for the button.
296 * @param aText The text to set
297 * @param aComponent The component for which the text is to be set.
299 IMPORT_C void SetTextL(const TDesC& aText,CEikAlignedControl*& aComponent);
302 * Sets the bitmap and optional mask for the button
304 * @param aMain The bitmap to use
305 * @param aMask The mask. If null, then no mask will be used
306 * @param aComponent The component for which the picture is to be set.
308 IMPORT_C void SetPictureL(const CFbsBitmap* aMain,const CFbsBitmap* aMask,CEikAlignedControl*& aComponent);
311 * Sets the bitmap and optional mask from an mbm file.
313 * @param aFile Mbm filename
314 * @param aMain Index of the bitmap to use
315 * @param aMask Index of the mask. If -1, then a null mask will be used
316 * @param aComponent The component for which the picture is to be set.
318 IMPORT_C void SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask,CEikAlignedControl*& aComponent);
321 * Utility routine. Calling this without a leave will ensure the internal command stack is constructed.
323 inline void CheckCreateCommandStackL();
325 protected: // from CCoeControl
329 * Request for the control to draw itself within the given rectangle
331 * @param aRect TRect to draw
333 IMPORT_C void Draw(const TRect& aRect) const;
338 * Utility routine. Sets additional look and feel attributes for the image
340 void SetImageAttributes(CEikImage* aImage);
343 * Access the behaviour set into the button
345 inline TInt Behavior() const;
351 * Serialize the state of the control
353 * @param aWriteStream Output stream for the serialization
355 IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const;
361 * Framework method called when the size or layout changes
363 IMPORT_C void SizeChanged();
364 IMPORT_C void Reserved_2();
366 private: // from CEikButtonBase
367 IMPORT_C void Reserved_3();
371 * From MCoeControlContext
373 * Modify the passed-in graphics context ready for use in this control
375 * @param aGc Graphics context to set up
377 IMPORT_C void PrepareContext(CWindowGc& aGc) const;
380 IMPORT_C virtual void Reserved_4();
385 IMPORT_C void* ExtensionInterface( TUid aInterface );
389 void SetComponentExtents(const TRect& aRect);
390 void SetNewComponentExtentL();
391 TBool LayoutIsVertical() const;
395 * The components of the button: the image or the text (order determined by construction)
397 CEikAlignedControl* iComponents[2];
404 CEikCommandStack* iCommandStack;
410 * Command button with a text and/or an image
412 * This class in S60 does not function without derivation
413 * This class does NOT implement S60 look-and-feel and is not skinned.
418 class CEikCommandButton : public CEikCommandButtonBase
421 /** Layout options for a command button*/
424 ETextRightPictureLeft=0x000,
425 ETextBottomPictureTop=0x001,
426 ETextTopPictureBottom=0x002,
427 ETextLeftPictureRight=0x003
431 * Where to put excess space in the layout
441 * Content to diplay for this button
446 EPictureOnly =0x0200,
447 ETextAndPicture =0x0300
455 IMPORT_C CEikCommandButton();
460 IMPORT_C ~CEikCommandButton();
463 * Sets the label text for the button.
465 * @param aText The text to set
467 IMPORT_C void SetTextL(const TDesC& aText);
470 * Sets the bitmap and optional mask for the button
472 * @param aMain The bitmap to use
473 * @param aMask The mask. If null, then no mask will be used
475 IMPORT_C void SetPictureL(const CFbsBitmap* aMain,const CFbsBitmap* aMask=NULL);
478 * Set bitmap and mask from file.
480 IMPORT_C void SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask=-1);
483 * Access the label control that implements the text label of the button. Ownership is not transferred.
485 * @return A pointer to the CEikLabel control used to implement the text display
487 IMPORT_C CEikLabel* Label() const;
490 * Access the CEikImage that implements the picture component of the button. Ownership is not transferred.
492 * @return A pointer to the CEikImage used to implement the image display.
494 IMPORT_C CEikImage* Picture() const;
497 * Set the layout of the button
499 * @param aLayout Layout to be used
501 IMPORT_C void SetButtonLayout(TLayout aLayout);
504 * Sets where the excess space in the layout is to be distributed
506 * @param aExcess Enum value to say where the excess space is to go
508 IMPORT_C void SetExcessSpace(TExcess aExcess);
511 * Set what content is to be displayed in the button
513 * @param aContent Enum value saying what content to display
515 IMPORT_C void SetDisplayContent(TDisplayContent aContent);
518 * Sets the command button's text, bitmap and bitmap mask.
520 * @param aCommandId Command ID to be generated by pressing this button
521 * @param aText Text to display on the button
522 * @param aBitmap Bitmap to display on the button
523 * @param aMask Mask to use. May be Null
525 IMPORT_C void SetCommandL(TInt aCommandId,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask);
528 * Push a command ID + text + image binding onto the command stack.
530 * @param aCommandId Command ID to be generated by pressing this button
531 * @param aText Text to display on the button
532 * @param aBitmap Bitmap to display on the button
533 * @param aMask Mask to use. May be Null
535 IMPORT_C void AddCommandToStackL(TInt aCommandId,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask);
538 * Find the stacked command with a given command ID and remove it from the stack
540 * @param aCommandId ID of the command to be removed
541 * @return EFalse iff the comand is not found
543 IMPORT_C TBool RemoveCommandFromStack(TInt aCommandId);
546 * Remove the top (most recently added) command binding from the command stack
548 * @return the number of commands left on the stack.
550 IMPORT_C TInt PopCommandFromStack();
552 public: // from CCoeControl
556 * Construct the object from resource
558 * @param aReader Fully constructed resource reader
560 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
565 * Handle a pointer event coming from the CONE framework
567 * @param aPointerEvent Event to handle
569 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
573 * From CEikCommandButtonBase
575 * Cause a recalculation of the components alignment
577 IMPORT_C void UpdateComponentAlignment();
580 void UpdateLabelReserveLengthL(const TDesC* aText);
586 IMPORT_C void* ExtensionInterface( TUid aInterface );
592 * The CEikTwoPictureCommandButton class is a command button which can hold two pictures as
593 * well as label text. If a second picture is set for the button it is shown when the button
599 class CEikTwoPictureCommandButton : public CEikCommandButtonBase
604 * Layout options for the Two Picture botton
608 ETextRightPictureLeft=0x000,
609 ETextBottomPictureTop=0x001,
610 ETextTopPictureBottom=0x002,
611 ETextLeftPictureRight=0x003
615 * Where to put the excess space when laying out the bitmaps or text
625 * Content to display for the text
630 EPictureOnly =0x0200,
631 ETextAndPicture =0x0300
636 * Options for the type of button
638 enum TPictureButtonType
640 EPictureButWithBorders =0x0000,
641 EPictureButWithoutBorders =0x1000
645 * Sets the ownership of the pictures bitmap and mask objects. If owned externally, then no copy is made of the objects
646 * in the setter functions. It must be, in this case, ensured by the client that that the button is destroyed before
647 * deleting the externally-owned objects.
649 enum TExternalPicture
651 EPictureNotOwnedExternally =0x00,
652 EPictureOwnedExternally =0x01
658 * Two picture command button constructor
660 IMPORT_C CEikTwoPictureCommandButton();
663 * Two picture command button C++ destructor
665 IMPORT_C ~CEikTwoPictureCommandButton();
668 * Accesses ownership of the second picture' bitmap and mask (if present)
670 * @return EFalse iff and if the second picture is not owned externally
672 IMPORT_C TBool IsSecondPictureOwnedExternally();
675 * Access the picture image.
677 * @return The picture as a CEikImage. No ownership transferred.
679 IMPORT_C CEikImage* Picture() const;
682 * Constructs the two images from resource
684 * @param aReader Constructed resource reader.
685 * @param aWhich Which picture to be constructing
687 IMPORT_C void ConstructImagesFromResourceL(TResourceReader& aReader,TWhichComponent aWhich);
690 * Sets the label text on the button
692 * @param aText The text to set
694 IMPORT_C void SetTextL(const TDesC& aText);
697 * Sets the bitmap and optional mask for the button's two pictures. Optionally, only the first button's
698 * picture may be set up.
700 * @param aMain The bitmap to use for the first picture
701 * @param aMask The mask. If null, then no mask will be used
702 * @param aSecondMain The bitmap to use for the second picture
703 * @param aSecondMask The mask. If null, then no mask will be used
705 IMPORT_C void SetTwoPicturesL(const CFbsBitmap* aMain,const CFbsBitmap* aMask=NULL,const CFbsBitmap* aSecondMain=NULL, const CFbsBitmap* aSecondMask=NULL);
708 * Sets the bitmap and optional mask for the button's second picture
710 * @param aMain The bitmap to use
711 * @param aMask The mask. If null, then no mask will be used
713 IMPORT_C void SetSecondPicture(const CFbsBitmap* aSecondMain, const CFbsBitmap* aSecondMask=NULL);
716 * Sets the bitmap and optional mask for the first picture from an mbm file.
718 * @param aFile Mbm filename
719 * @param aMain Index of the bitmap to use
720 * @param aMask Index of the mask. If -1, then a null mask will be used
722 IMPORT_C void SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask=-1);
725 * Sets the bitmap and optional mask for the second picture from an mbm file.
727 * @param aFile Mbm filename
728 * @param aMain Index of the bitmap to use
729 * @param aMask Index of the mask. If -1, then a null mask will be used
731 IMPORT_C void SetSecondPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask=-1);
734 * Sets the ownership of the second picture object
736 * @param aOwnership Set to EFalse if bitmaps associated with the object are owned by the button
738 IMPORT_C void SetSecondPictureOwnedExternally(TBool aOwnership);
740 public: // from CCoeControl.
745 * @param aReader Fully constructed resource reader
747 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
752 * Make the control ready for display
754 IMPORT_C void ActivateL();
759 * Handle a pointer event coming from the CONE framework
761 * @param aPointerEvent Event to handle
763 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
769 * Serialize the state of the control
771 * @param aWriteStream Output stream for the serialization
773 IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const;
775 private: // from CCoeControl
780 * Request for the control to draw itself within the given rectangle
782 * @param aRect TRect to draw
784 IMPORT_C void Draw(const TRect& /*aRect*/) const;
787 * From CEikButtonBase
789 * Framework method called when the state changes
791 IMPORT_C void StateChanged();
797 IMPORT_C void* ExtensionInterface( TUid aInterface );
801 * From MCoeControlContext
803 * Modify the passed-in graphics context ready for use in this control
805 * @param aGc Graphics context to set up
807 IMPORT_C void PrepareContext(CWindowGc& aGc) const;
810 void SwapPictures(CEikImage* aImage);
814 * Ownership dependent on state of flags
816 const CFbsBitmap* iSecondBitmap;
818 * Ownership dependent on state of flags
820 const CFbsBitmap* iSecondMaskBitmap;
826 * The CEikInverterCommandButton class is a command button which swaps the foreground and background
827 * colors used to draw the button contents when the button is pressed.
831 class CEikInverterCommandButton : public CEikCommandButton
838 IMPORT_C CEikInverterCommandButton();
843 IMPORT_C ~CEikInverterCommandButton();
845 public: // From CCoeControl
850 * Handle a pointer event coming from the CONE framework
852 * @param aPointerEvent Event to handle
854 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
861 * Serialize the state of the control
863 * @param aWriteStream Output stream for the serialization
865 IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const;
869 * From MCoeControlContext
871 * Modify the passed-in graphics context ready for use in this control
873 * @param aGc Graphics context to set up
875 IMPORT_C void PrepareContext(CWindowGc& aGc) const;
881 IMPORT_C void* ExtensionInterface( TUid aInterface );
888 * A command button with a text label
890 * This specialization of CEikCommandButtonBase supports a single text label.
895 class CEikTextButton : public CEikCommandButtonBase
902 IMPORT_C CEikTextButton();
907 IMPORT_C ~CEikTextButton();
910 * Sets the label text for the button.
912 * @param aText The text to set
913 * @param aWhich The component for which the text is to be set.
915 IMPORT_C void SetTextL(const TDesC& aText,TWhichComponent aWhich=EFirst);
918 * Access the label control that implements the text label of the button. Ownership is not transferred.
920 * @return A pointer to the CEikLabel control used to implement the text display
922 IMPORT_C CEikLabel* Label(TWhichComponent aWhich=EFirst) const;
930 * Construct the object from resource
932 * @param aReader Fully constructed resource reader
934 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
939 * Handle a pointer event coming from the CONE framework
941 * @param aPointerEvent Event to handle
943 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
947 IMPORT_C void* ExtensionInterface( TUid aInterface );
954 * A command button with a single bitmap
956 * This specialization of CEikCommandButtonBase supports a single bitmap, optionally with a mask.
961 class CEikBitmapButton : public CEikCommandButtonBase
968 IMPORT_C CEikBitmapButton();
973 IMPORT_C ~CEikBitmapButton();
976 * Sets the bitmap and optional mask for the button
978 * @param aMain The bitmap to use
979 * @param aMask The mask. If null, then no mask will be used
980 * @param aWhich The component for which the picture is to be set.
982 IMPORT_C void SetPictureL(const CFbsBitmap* aMain,const CFbsBitmap* aMask=NULL,TWhichComponent aWhich=EFirst);
985 * Sets the bitmap and optional mask from an mbm file.
987 * @param aFile Mbm filename
988 * @param aMain Index of the bitmap to use
989 * @param aMask Index of the mask. If -1, then a null mask will be used
990 * @param aWhich The component for which the picture is to be set.
992 IMPORT_C void SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask=-1,TWhichComponent aWhich=EFirst);
995 * Access to the image
997 * @param aWhich Which picture to access
998 * @return pointer to the image. No ownership is transferred
1000 IMPORT_C CEikImage* Picture(TWhichComponent aWhich=EFirst) const;
1007 * Construct the object from resource
1009 * @param aReader Fully constructed resource reader
1011 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
1016 * Handle a pointer event coming from the CONE framework
1018 * @param aPointerEvent Event to handle
1020 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
1026 IMPORT_C void* ExtensionInterface( TUid aInterface );
1032 #endif // __EIKCMBUT_H__