williamr@2: /* williamr@2: * Copyright (c) 2002-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 bio controls. williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: #ifndef MSGBIOCONTROL_H williamr@2: #define MSGBIOCONTROL_H williamr@2: williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include // for CCoeControl williamr@2: #include // for MMsgBioControl williamr@2: #include // for CDesCArray williamr@2: #include williamr@2: #include // for TMsgCursorLocation williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: williamr@2: class MMsgBioControlObserver; williamr@2: class CMsvSession; williamr@2: class MMsgBioControlExtension; williamr@2: williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * The base class for Bio controls. williamr@2: */ williamr@2: class CMsgBioControl : public CCoeControl, public MMsgBioControl williamr@2: { williamr@2: williamr@2: public: //construction and destruction williamr@2: williamr@2: /** williamr@2: * Constructor. Call this from your Bio Control constructor. williamr@2: * @param aObserver Reference to the Bio control observer. williamr@2: * @param aSession Message Server session. Ownership not transferred. williamr@2: * @param aId Id of the message in the server. williamr@2: * @param aEditorOrViewerMode Sets Bio Control into editor or viewer mode. williamr@2: * @param aFile Data file handle. Bio controls can also be file based. Not owned. williamr@2: */ williamr@2: IMPORT_C CMsgBioControl( williamr@2: MMsgBioControlObserver& aObserver, williamr@2: CMsvSession* aSession, //ownership is NOT transferred williamr@2: TMsvId aId, williamr@2: TMsgBioMode aEditorOrViewerMode, williamr@2: const RFile* aFile); //ownership is NOT transferred williamr@2: williamr@2: /** williamr@2: * Destructor williamr@2: */ williamr@2: IMPORT_C ~CMsgBioControl(); williamr@2: williamr@2: public: // static helper functions williamr@2: williamr@2: /** williamr@2: * Pops a confirmation query. The result is given by the return value. williamr@2: * The standard resource must have been loaded using williamr@2: * LoadStandardBioResourceL(). williamr@2: * @param aText The text that is to be used in the query. williamr@2: * @return A user confirmation results in ETrue, and vice versa. williamr@2: */ williamr@2: IMPORT_C static TBool ConfirmationQueryL(const TDesC& aText); williamr@2: williamr@2: /** williamr@2: * Pops a confirmation query. The result is given by the return value. williamr@2: * The standard resource must have been loaded using williamr@2: * LoadStandardBioResourceL(). Your resource must also be loaded, for williamr@2: * eg. with LoadResourceL(). williamr@2: * CCoeEnv must exist. williamr@2: * @param aStringResource The string resource id. williamr@2: * @return A user confirmation results in ETrue, and vice versa. williamr@2: */ williamr@2: IMPORT_C static TBool ConfirmationQueryL(TInt aStringResource); williamr@2: williamr@2: public: // from MMsgBioControl williamr@2: williamr@2: /** williamr@2: * The application can get the option menu recommendations using this williamr@2: * function. The function comes from MMsgBioControl. This is the williamr@2: * default implementation which returns the flags williamr@2: * EMsgBioCallBack | EMsgBioDelete | EMsgBioMessInfo | EMsgBioMove | williamr@2: * EMsgBioCreateCC | EMsgBioSend | EMsgBioAddRecipient | EMsgBioSave | williamr@2: * EMsgBioSendingOpt | EMsgBioHelp | EMsgBioExit. williamr@2: * Bio Controls should override this if it is not ok. williamr@2: * @return The option menu permission flags. If the flag is off it williamr@2: * means that the option menu command is not recommended with this williamr@2: * Bio Control. williamr@2: */ williamr@2: IMPORT_C TUint32 OptionMenuPermissionsL() const; williamr@2: williamr@2: /** williamr@2: * Gives the height of the text in pixels. williamr@2: * It is used by the scrolling framework. williamr@2: * @return Height of the text in pixels. williamr@2: */ williamr@2: IMPORT_C TInt VirtualHeight(); williamr@2: williamr@2: /** williamr@2: * Gives the cursor position in pixels. williamr@2: * It is used by the scrolling framework. williamr@2: * @return Cursor position in pixels. williamr@2: */ williamr@2: IMPORT_C TInt VirtualVisibleTop(); williamr@2: williamr@2: /** williamr@2: * Tells whether the cursor is in the topmost or bottom position. williamr@2: * It is used by the scrolling framework. williamr@2: * @param aLocation Specifies either top or bottom. williamr@2: * @return ETrue if the cursor is in the part specified by aLocation. williamr@2: */ williamr@2: IMPORT_C TBool IsCursorLocation(TMsgCursorLocation aLocation) const; williamr@2: williamr@2: public: //new functions williamr@2: williamr@2: /** williamr@2: * Performs the internal scrolling of control if needed. williamr@2: * Default implementation does not perform any scrolling and returns that williamr@2: * zero pixels were scrolled. williamr@2: * @since 3.2 williamr@2: * @param aPixelsToScroll Amount of pixels to scroll. williamr@2: * @param aDirection Scrolling direction. williamr@2: * @return Amount of pixels the where scrolled. Zero value means the component cannot williamr@2: * be scrolled to that direction anymore and view should be moved. williamr@2: */ williamr@2: IMPORT_C TInt ScrollL( TInt aPixelsToScroll, TMsgScrollDirection aDirection ); williamr@2: williamr@2: /** williamr@2: * Prepares control for viewing. williamr@2: * @since 3.2 williamr@2: * @param aEvent The event type williamr@2: * @param aParam Event related parameters williamr@2: */ williamr@2: IMPORT_C void NotifyViewEvent( TMsgViewEvent aEvent, TInt aParam ); williamr@2: williamr@2: williamr@2: protected: //new functions williamr@2: williamr@2: /** williamr@2: * Returns true if the control has been launched as editor, williamr@2: * and false if it was launched as viewer. williamr@2: * @return ETrue or EFalse williamr@2: */ williamr@2: IMPORT_C TBool IsEditor() const; williamr@2: williamr@2: /** williamr@2: * Is the Bio Control file based or not. williamr@2: * @return ETrue if is file based. williamr@2: */ williamr@2: IMPORT_C TBool IsFileBased() const; williamr@2: williamr@2: /** williamr@2: * Accessor for MsvSession. The session exists only if the Bio Control williamr@2: * has been created as message server based. williamr@2: * @exception Panics if there is no session. williamr@2: * @return CMsvSession& williamr@2: */ williamr@2: IMPORT_C CMsvSession& MsvSession() const; williamr@2: williamr@2: /** williamr@2: * Deprecated* williamr@2: * williamr@2: * Returns name of input file. williamr@2: * @return Name of file. williamr@2: * @exception Panics if the control is not file based. williamr@2: */ williamr@2: IMPORT_C const TFileName& FileName() const; williamr@2: williamr@2: /** williamr@2: * Deprecated* Handle is valid only at contsruction phase!! williamr@2: * To be removed. williamr@2: * Returns input file handle. williamr@2: * @return handle of file. williamr@2: * @exception Panics if the control is not file based. williamr@2: */ williamr@2: IMPORT_C const RFile& FileHandle() const; williamr@2: williamr@2: /** williamr@2: * Loads a resource file from /system/data/ into eikon env. This williamr@2: * function should be used for loading the Bio Control resources. williamr@2: * The resources are unloaded in the destructor of this class. The williamr@2: * offsets are kept in iResourceOffsets. williamr@2: * @param aFile File name mask, for eg. "vcalbc.r??". williamr@2: */ williamr@2: IMPORT_C void LoadResourceL(const TDesC& aFile); williamr@2: williamr@2: /** williamr@2: * Loads a resource file into eikon env. The resources are unloaded in williamr@2: * the destructor of this class. (the offsets are kept in williamr@2: * iResourceOffsets). williamr@2: * @param aFile File name mask, for eg. "vcalbc.r??". williamr@2: * @param aSearchPath Search path, for eg. "\\System\\libs\\". williamr@2: */ williamr@2: IMPORT_C void LoadResourceL(const TDesC& aFile, williamr@2: const TDesC& aSearchPath); williamr@2: williamr@2: /** williamr@2: * This loads the msgeditorutils.rsc resource, which is needed by williamr@2: * the dialogs and notes of this class. williamr@2: */ williamr@2: IMPORT_C void LoadStandardBioResourceL(); williamr@2: williamr@2: /** williamr@2: * Adds a menu item to the menu pane which is given as a reference. williamr@2: * @param aMenuPane Reference to the menu pane. williamr@2: * @param aStringRes The string resource id. williamr@2: * @param aCommandOffset The offset of the command from the first free williamr@2: * command. williamr@2: * @param aPosition The inserting position. The default is at the top. williamr@2: */ williamr@2: IMPORT_C void AddMenuItemL(CEikMenuPane& aMenuPane, TInt aStringRes, williamr@2: TInt aCommandOffset, TInt aPosition = 0); williamr@2: williamr@2: /** williamr@2: * Notify editor view. williamr@2: * This is used by the Bio Control for notifying the Editor Base williamr@2: * framework of an event, and usually for requesting something to williamr@2: * be done. williamr@2: */ williamr@2: IMPORT_C TBool NotifyEditorViewL( williamr@2: TMsgBioControlEventRequest aRequest, williamr@2: TInt aDelta = 0); williamr@2: williamr@2: /** williamr@2: * Call from base class if extension interface is supported. williamr@2: * @param Interface for bio control extension. Ownership is not taken. williamr@2: */ williamr@2: IMPORT_C void SetExtension(MMsgBioControlExtension* aExt); williamr@2: williamr@2: williamr@2: private: // new functions williamr@2: williamr@2: /** williamr@2: * Sets the bio body control reference. williamr@2: * Used only by CMsgBioBodyControl. williamr@2: * @param aBioBodyControl Address of the bio body control. williamr@2: */ williamr@2: void SetBioBodyControl( MMsgBioBodyControl* aBioBodyControl ); williamr@2: williamr@2: /// deprecated williamr@2: TBool IsNear(TInt aLafPos, TInt aPos) const; williamr@2: williamr@2: private: // not available williamr@2: williamr@2: /** williamr@2: * Default constructor hidden away williamr@2: */ williamr@2: CMsgBioControl(); williamr@2: williamr@2: /** williamr@2: * Copy constructor prohibited. williamr@2: */ williamr@2: CMsgBioControl(const CMsgBioControl& aSource); williamr@2: williamr@2: /** williamr@2: * Assignment operator prohibited. williamr@2: */ williamr@2: const CMsgBioControl& operator=(const CMsgBioControl& aSource); williamr@2: williamr@2: protected: williamr@2: williamr@2: /// Reference to the MMsgBioControlObserver williamr@2: MMsgBioControlObserver& iBioControlObserver; williamr@2: williamr@2: /// Id of the message in the server. williamr@2: TMsvId iId; williamr@2: williamr@2: private: williamr@2: williamr@2: /** williamr@2: * Pointer to Message Server session. It is NOT owned here. williamr@2: * The reason for using pointer type is that the session is optional. williamr@2: * It can be NULL without implying any error. williamr@2: * This session is accessed using the function MsvSession(). williamr@2: */ williamr@2: CMsvSession* iMsvSession; williamr@2: williamr@2: /// Tells if the control was launched in editor or viewer mode. williamr@2: TMsgBioMode iMode; williamr@2: williamr@2: /** williamr@2: * * Deprecated -> To be removed* williamr@2: * Handle is valid only during contruction phase. williamr@2: * A pointer to the handle of the input file, not owned. williamr@2: * Accessed using FileHandle(). williamr@2: * See also function FileBased(). williamr@2: */ williamr@2: const RFile* iFile; williamr@2: williamr@2: /** williamr@2: * A pointer to Bio control extension interface. It is not owned here. williamr@2: */ williamr@2: MMsgBioControlExtension* iExt; williamr@2: williamr@2: // Filler needed to keep this object's size the same. williamr@2: // Let the compiler calculate the filler size needed using sizeof. williamr@2: TUint8 iBCFiller[sizeof(TFileName) - sizeof(TFileName*) - sizeof(MMsgBioControlExtension*)]; williamr@2: williamr@2: williamr@2: /// This is the array of resource offsets. williamr@2: CArrayFixFlat* iResourceOffsets; williamr@2: williamr@2: /// Pointer to the bio bodycontrol. williamr@2: MMsgBioBodyControl* iBioBodyControl; williamr@2: williamr@2: /// status flags williamr@2: TInt iBCStatusFlags; williamr@2: williamr@2: private: williamr@2: williamr@2: friend class CMsgBioBodyControl; williamr@2: williamr@2: }; williamr@2: williamr@2: #endif // MSGBIOCONTROL_H williamr@2: williamr@2: // End of file