williamr@2: /* williamr@2: * Copyright (c) 1997-1999 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: williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #if !defined(__EIKIMAGE_H__) williamr@2: #define __EIKIMAGE_H__ williamr@2: williamr@2: #if !defined(__EIKALIGN_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: class CFbsBitmap; williamr@2: class CBitmapContext; williamr@2: williamr@2: /** williamr@2: * The package class @c CEikImage enables bitmaps to be packaged into an williamr@2: * image. Two bitmaps can be packaged, one for the image itself and, williamr@2: * optionally, another for the image’s mask. williamr@2: */ williamr@2: class CEikImage : public CEikAlignedControl williamr@2: { williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: IMPORT_C CEikImage(); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C ~CEikImage(); williamr@2: williamr@2: public: // framework williamr@2: williamr@2: /** williamr@2: * Gets the minimum size required to draw the image. williamr@2: * williamr@2: * @return The minimum size required to draw the image. williamr@2: */ williamr@2: IMPORT_C TSize MinimumSize(); williamr@2: williamr@2: /** williamr@2: * Constructs an image from resource using the specified resource reader. williamr@2: * williamr@2: * @param aReader The resource reader. williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); williamr@2: williamr@2: public: // new functions williamr@2: williamr@2: /** williamr@2: * Creates a bitmap and a mask for an icon. If @c aMaskId is not negative williamr@2: * then function allocates bitmap and mask objects and sets member variables williamr@2: * to point at them. These bitmaps are not ready for drawing until they are williamr@2: * initialized with @c SetSize() method. Usually, UI controls do this. Note williamr@2: * also that a single @c SetSize() call initializes both the bitmap and the williamr@2: * mask. williamr@2: * williamr@2: * If @c aMaskId is not needed and not given then this function creates the williamr@2: * bitmap for an icon. Returned object is saved to the member variable. The williamr@2: * bitmap is not ready for drawing until it is initialized with @c williamr@2: * SetSize() method. Usually, UI controls do this. williamr@2: * williamr@2: * @param aFilename File name. Can be either MBM or MIF file. williamr@2: * Extension is changed based on the given bitmap ID. williamr@2: * @param aMainId Bitmap id. williamr@2: * @param aMaskId Mask id, by default -1. williamr@2: */ williamr@2: IMPORT_C void CreatePictureFromFileL(const TDesC& aFilename, williamr@2: TInt aMainId, williamr@2: TInt aMaskId=-1); williamr@2: williamr@2: /** williamr@2: * Sets picture parameters. williamr@2: * williamr@2: * @param aBitmap A bitmap. williamr@2: * @param aMaskBitmap A bitmap mask. williamr@2: */ williamr@2: IMPORT_C void SetPicture(const CFbsBitmap* aBitmap, williamr@2: const CFbsBitmap* aMaskBitmap=NULL); williamr@2: williamr@2: /** williamr@2: * Sets emphasis. williamr@2: * williamr@2: * @param aEmphasis Full emphasis if @c ETrue and if not then @c EFalse. williamr@2: */ williamr@2: IMPORT_C void SetEmphasis(TBool aEmphasis); williamr@2: williamr@2: /** williamr@2: * Sets the owner of the picture. williamr@2: * williamr@2: * @param aOwnership @c Etrue if owner is external and @c EFalse if not. williamr@2: */ williamr@2: IMPORT_C void SetPictureOwnedExternally(TBool aOwnership); williamr@2: williamr@2: /** williamr@2: * Gets a pointer of @c CFbsBitmap object. williamr@2: * williamr@2: * @return Pointer to handle to the bitmap or NULL. williamr@2: */ williamr@2: IMPORT_C const CFbsBitmap* Bitmap() const; williamr@2: williamr@2: /** williamr@2: * Gets pointer of @c CFbsBitmap object. williamr@2: * williamr@2: * @return Pointer to handle to the bitmap's mask or NULL. williamr@2: */ williamr@2: IMPORT_C const CFbsBitmap* Mask() const; williamr@2: williamr@2: /** williamr@2: * Sets new bitmap. williamr@2: * williamr@2: * @param aBitmap Pointer to @c CFbsBitmap object containing the bitmap. williamr@2: */ williamr@2: IMPORT_C void SetBitmap(const CFbsBitmap* aBitmap); williamr@2: williamr@2: /** williamr@2: * Sets new bitmap mask. williamr@2: * williamr@2: * @param aMaskBitmap Pointer to @c CFbsBitmap object containing the bitmap williamr@2: * mask. williamr@2: */ williamr@2: IMPORT_C void SetMask(const CFbsBitmap* aMaskBitmap); williamr@2: williamr@2: /** williamr@2: * Sets new bitmap and bitmap's mask. williamr@2: * williamr@2: * @param aNewBitmap A bitmap. williamr@2: * @param aNewMask A bitmap mask. williamr@2: */ williamr@2: IMPORT_C void SetNewBitmaps(const CFbsBitmap* aNewBitmap, williamr@2: const CFbsBitmap* aNewMask); williamr@2: williamr@2: /** williamr@2: * Checks whether picture is owned externally. williamr@2: * williamr@2: * @return @c ETrue if picture owned externally and @c EFalse if williamr@2: * not. williamr@2: */ williamr@2: IMPORT_C TBool IsPictureOwnedExternally(); williamr@2: williamr@2: /** williamr@2: * Sets the brush style. williamr@2: * williamr@2: * @param aBrushStyle A brush style. williamr@2: */ williamr@2: IMPORT_C void SetBrushStyle(CGraphicsContext::TBrushStyle aBrushStyle); williamr@2: williamr@2: public: // from CCoeControl williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Handles pointer events. williamr@2: * williamr@2: * This function gets called whenever a pointer event occurs in the williamr@2: * control, i.e. when the pointer is within the control's extent, or when williamr@2: * the control has grabbed the pointer. The control should implement this williamr@2: * function to handle pointer events. williamr@2: * williamr@2: * Note: events of type @c EButton1Down are processed before williamr@2: * @c HandlePointerEventL() is called in order to transfer keyboard focus williamr@2: * to the control in which the @c EButton1Down event occurred. williamr@2: * williamr@2: * If overriding @c HandlePointerEventL(), the implementation must include williamr@2: * a base call to @c CCoeControl's @c HandlePointerEventL(). williamr@2: * williamr@2: * @param aPointerEvent The pointer event. williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: protected: // from CCoeControl williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl williamr@2: * williamr@2: * Writes the internal state of the control and its components to a stream. williamr@2: * Does nothing in release mode. Designed to be overidden and base called williamr@2: * by subclasses. williamr@2: * williamr@2: * @since App-Framework_6.1 williamr@2: * @param[in,out] aWriteStream The pointer writestream. williamr@2: */ williamr@2: IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const; williamr@2: williamr@2: private: // from CCoeControl williamr@2: williamr@2: IMPORT_C void Draw(const TRect& aRect) const; williamr@2: IMPORT_C void Reserved_2(); williamr@2: williamr@2: private: williamr@2: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: private: williamr@2: williamr@2: const CFbsBitmap* iBitmap; williamr@2: const CFbsBitmap* iMaskBitmap; williamr@2: TInt iImFlags; williamr@2: TInt iSpare; williamr@2: CGraphicsContext::TBrushStyle iBrushStyle; williamr@2: }; williamr@2: williamr@2: #endif // __EIKIMAGE_H__