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@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Provides support for cut, copy, paste and williamr@2: * undo functionality in editors. williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef EIKCCPU_H williamr@2: #define EIKCCPU_H williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: class CEikButtonGroupContainer; williamr@2: class CEikMenuBar; williamr@2: williamr@2: williamr@2: /** williamr@2: * Interface for cut, copy, paste and undo functionality. williamr@2: */ williamr@2: class MEikCcpuEditor williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Derived classes must provide the implementation for williamr@2: * following: williamr@2: * williamr@2: * Tests whether the editor is focused. williamr@2: * williamr@2: * @return If editor is focused, @c ETrue is returned. williamr@2: */ williamr@2: virtual TBool CcpuIsFocused() const = 0; williamr@2: williamr@2: /** williamr@2: * Derived classes must provide the implementation for williamr@2: * following: williamr@2: * williamr@2: * Tests whether the selected text can be cut. williamr@2: * williamr@2: * @return @c ETrue if it is possible to cut the selected text. williamr@2: */ williamr@2: virtual TBool CcpuCanCut() const = 0; williamr@2: williamr@2: /** williamr@2: * Derived classes must provide the implementation for williamr@2: * following: williamr@2: * williamr@2: * Cuts selected text. williamr@2: */ williamr@2: virtual void CcpuCutL() = 0; williamr@2: williamr@2: /** williamr@2: * Derived classes must provide the implementation for williamr@2: * following: williamr@2: * williamr@2: * Tests whether the selected text can be copied. williamr@2: * williamr@2: * @return @c ETrue if it is possible to copy the selected text. williamr@2: */ williamr@2: virtual TBool CcpuCanCopy() const = 0; williamr@2: williamr@2: /** williamr@2: * Derived classes must provide the implementation for williamr@2: * following: williamr@2: * williamr@2: * Copies selected text. williamr@2: */ williamr@2: virtual void CcpuCopyL() = 0; williamr@2: williamr@2: /** williamr@2: * Derived classes must provide the implementation for williamr@2: * following: williamr@2: * williamr@2: * Tests whether text can be pasted from the clipboard. williamr@2: * williamr@2: * @return @c ETrue if it is possible to paste the clipboard text. williamr@2: */ williamr@2: virtual TBool CcpuCanPaste() const = 0; williamr@2: williamr@2: /** williamr@2: * Derived classes must provide the implementation for williamr@2: * following: williamr@2: * williamr@2: * Pastes text from the clipboard to the editor. williamr@2: */ williamr@2: virtual void CcpuPasteL() = 0; williamr@2: williamr@2: /** williamr@2: * Derived classes must provide the implementation for williamr@2: * following: williamr@2: * williamr@2: * Tests is it possible to undo previous operation. williamr@2: * williamr@2: * @return @c ETrue if it is possible to undo previous operation. williamr@2: */ williamr@2: virtual TBool CcpuCanUndo() const = 0; williamr@2: williamr@2: /** williamr@2: * Derived classes must provide the implementation for williamr@2: * following: williamr@2: * williamr@2: * Undoes the most recent text operation when the editor supports this williamr@2: * feature and when the undo store is not empty williamr@2: */ williamr@2: virtual void CcpuUndoL() = 0; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Cut, copy, paste and undo support class. Takes care williamr@2: * of CBA handling and menu command processing when FEP williamr@2: * instructs this control to activate the commands williamr@2: * for ccpu operations. williamr@2: */ williamr@2: class CAknCcpuSupport : public CAknControl, public MEikMenuObserver williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Constructor. ConstructL() must be called after a call williamr@2: * to this function. williamr@2: * williamr@2: * @param aEditor A pointer to the editor implementing the williamr@2: * MEikCcpuEditor interface. williamr@2: */ williamr@2: IMPORT_C CAknCcpuSupport(MEikCcpuEditor* aEditor); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C ~CAknCcpuSupport(); williamr@2: williamr@2: /** williamr@2: * 2nd phase constructor. williamr@2: * williamr@2: * Adds this control to the control stack. williamr@2: */ williamr@2: IMPORT_C void ConstructL(); williamr@2: williamr@2: /** williamr@2: * Updates the CBA labels according to selection and williamr@2: * clipboard contents. williamr@2: */ williamr@2: IMPORT_C void HandleSelectionChangeL(); williamr@2: williamr@2: /** williamr@2: * Updates the CBA labels according to editor focus williamr@2: * state. williamr@2: */ williamr@2: IMPORT_C void HandleFocusChangeL(); williamr@2: williamr@2: // from CCoeControl williamr@2: williamr@2: /** williamr@2: * Responds to key presses. williamr@2: * williamr@2: * Overrides CCoeControl::OfferKeyEventL(). williamr@2: * williamr@2: * @param aKeyEvent The key event. williamr@2: * @param aType Not used. williamr@2: * @return Indicates whether or not the key event was consumed. williamr@2: */ williamr@2: IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Handles pointer events. williamr@2: * williamr@2: * @param aPointerEvent The pointer event. williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: // from MEikMenuObserver williamr@2: williamr@2: /** williamr@2: * From MEikMenuObserver. williamr@2: * williamr@2: * Dynamically initialises a menu pane. williamr@2: * williamr@2: * @param aResourceId Resource ID of the menu. williamr@2: * @param aMenuPane The in-memory representation of the menu pane. williamr@2: */ williamr@2: IMPORT_C void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); williamr@2: williamr@2: /** williamr@2: * From MEikCommandObserver. williamr@2: * williamr@2: * Processes user commands. williamr@2: * williamr@2: * @param aCommandId ID of the command to respond to. williamr@2: */ williamr@2: IMPORT_C void ProcessCommandL(TInt aCommandId); williamr@2: williamr@2: private: williamr@4: void UpdateCBALabelsL(); williamr@4: TBool UpdateCBALabelL(TInt aPosition, TInt aCommandId, TInt aTextResId); williamr@4: void SetEmphasis(CCoeControl* aMenuControl,TBool aEmphasis); williamr@4: void DeleteCBAL(); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: private: williamr@4: TBitFlags iFlags; williamr@4: TBool isCbaEmded; williamr@4: // Owned williamr@4: CEikButtonGroupContainer* iCba; williamr@4: williamr@2: williamr@2: // Not owned williamr@2: CEikMenuBar* iMenu; williamr@2: MEikCcpuEditor* iEditor; williamr@4: CEikButtonGroupContainer* iDialogCba; williamr@2: }; williamr@2: williamr@2: #endif // EIKCCPU_H