2 * Copyright (c) 2002-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: Provides support for cut, copy, paste and
15 * undo functionality in editors.
26 #include <babitflags.h>
27 #include <AknControl.h>
29 class CEikButtonGroupContainer;
34 * Interface for cut, copy, paste and undo functionality.
40 * Derived classes must provide the implementation for
43 * Tests whether the editor is focused.
45 * @return If editor is focused, @c ETrue is returned.
47 virtual TBool CcpuIsFocused() const = 0;
50 * Derived classes must provide the implementation for
53 * Tests whether the selected text can be cut.
55 * @return @c ETrue if it is possible to cut the selected text.
57 virtual TBool CcpuCanCut() const = 0;
60 * Derived classes must provide the implementation for
65 virtual void CcpuCutL() = 0;
68 * Derived classes must provide the implementation for
71 * Tests whether the selected text can be copied.
73 * @return @c ETrue if it is possible to copy the selected text.
75 virtual TBool CcpuCanCopy() const = 0;
78 * Derived classes must provide the implementation for
81 * Copies selected text.
83 virtual void CcpuCopyL() = 0;
86 * Derived classes must provide the implementation for
89 * Tests whether text can be pasted from the clipboard.
91 * @return @c ETrue if it is possible to paste the clipboard text.
93 virtual TBool CcpuCanPaste() const = 0;
96 * Derived classes must provide the implementation for
99 * Pastes text from the clipboard to the editor.
101 virtual void CcpuPasteL() = 0;
104 * Derived classes must provide the implementation for
107 * Tests is it possible to undo previous operation.
109 * @return @c ETrue if it is possible to undo previous operation.
111 virtual TBool CcpuCanUndo() const = 0;
114 * Derived classes must provide the implementation for
117 * Undoes the most recent text operation when the editor supports this
118 * feature and when the undo store is not empty
120 virtual void CcpuUndoL() = 0;
124 * Cut, copy, paste and undo support class. Takes care
125 * of CBA handling and menu command processing when FEP
126 * instructs this control to activate the commands
127 * for ccpu operations.
129 class CAknCcpuSupport : public CAknControl, public MEikMenuObserver
133 * Constructor. ConstructL() must be called after a call
136 * @param aEditor A pointer to the editor implementing the
137 * MEikCcpuEditor interface.
139 IMPORT_C CAknCcpuSupport(MEikCcpuEditor* aEditor);
144 IMPORT_C ~CAknCcpuSupport();
147 * 2nd phase constructor.
149 * Adds this control to the control stack.
151 IMPORT_C void ConstructL();
154 * Updates the CBA labels according to selection and
155 * clipboard contents.
157 IMPORT_C void HandleSelectionChangeL();
160 * Updates the CBA labels according to editor focus
163 IMPORT_C void HandleFocusChangeL();
168 * Responds to key presses.
170 * Overrides CCoeControl::OfferKeyEventL().
172 * @param aKeyEvent The key event.
173 * @param aType Not used.
174 * @return Indicates whether or not the key event was consumed.
176 IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
179 * From @c CCoeControl.
181 * Handles pointer events.
183 * @param aPointerEvent The pointer event.
185 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
187 // from MEikMenuObserver
190 * From MEikMenuObserver.
192 * Dynamically initialises a menu pane.
194 * @param aResourceId Resource ID of the menu.
195 * @param aMenuPane The in-memory representation of the menu pane.
197 IMPORT_C void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
200 * From MEikCommandObserver.
202 * Processes user commands.
204 * @param aCommandId ID of the command to respond to.
206 IMPORT_C void ProcessCommandL(TInt aCommandId);
209 void UpdateCBALabelsL();
210 TBool UpdateCBALabelL(TInt aPosition, TInt aCommandId, TInt aTextResId);
211 void SetEmphasis(CCoeControl* aMenuControl,TBool aEmphasis);
217 IMPORT_C void* ExtensionInterface( TUid aInterface );
222 CEikButtonGroupContainer* iCba;
226 MEikCcpuEditor* iEditor;