45
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Provides support for cut, copy, paste and
|
|
15 |
* undo functionality in editors.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef EIKCCPU_H
|
|
21 |
#define EIKCCPU_H
|
|
22 |
|
|
23 |
#include <coecntrl.h>
|
|
24 |
#include <eikdef.h>
|
|
25 |
#include <eikmobs.h>
|
|
26 |
#include <babitflags.h>
|
|
27 |
#include <AknControl.h>
|
|
28 |
|
|
29 |
class CEikButtonGroupContainer;
|
|
30 |
class CEikMenuBar;
|
|
31 |
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Interface for cut, copy, paste and undo functionality.
|
|
35 |
*/
|
|
36 |
class MEikCcpuEditor
|
|
37 |
{
|
|
38 |
public:
|
|
39 |
/**
|
|
40 |
* Derived classes must provide the implementation for
|
|
41 |
* following:
|
|
42 |
*
|
|
43 |
* Tests whether the editor is focused.
|
|
44 |
*
|
|
45 |
* @return If editor is focused, @c ETrue is returned.
|
|
46 |
*/
|
|
47 |
virtual TBool CcpuIsFocused() const = 0;
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Derived classes must provide the implementation for
|
|
51 |
* following:
|
|
52 |
*
|
|
53 |
* Tests whether the selected text can be cut.
|
|
54 |
*
|
|
55 |
* @return @c ETrue if it is possible to cut the selected text.
|
|
56 |
*/
|
|
57 |
virtual TBool CcpuCanCut() const = 0;
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Derived classes must provide the implementation for
|
|
61 |
* following:
|
|
62 |
*
|
|
63 |
* Cuts selected text.
|
|
64 |
*/
|
|
65 |
virtual void CcpuCutL() = 0;
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Derived classes must provide the implementation for
|
|
69 |
* following:
|
|
70 |
*
|
|
71 |
* Tests whether the selected text can be copied.
|
|
72 |
*
|
|
73 |
* @return @c ETrue if it is possible to copy the selected text.
|
|
74 |
*/
|
|
75 |
virtual TBool CcpuCanCopy() const = 0;
|
|
76 |
|
|
77 |
/**
|
|
78 |
* Derived classes must provide the implementation for
|
|
79 |
* following:
|
|
80 |
*
|
|
81 |
* Copies selected text.
|
|
82 |
*/
|
|
83 |
virtual void CcpuCopyL() = 0;
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Derived classes must provide the implementation for
|
|
87 |
* following:
|
|
88 |
*
|
|
89 |
* Tests whether text can be pasted from the clipboard.
|
|
90 |
*
|
|
91 |
* @return @c ETrue if it is possible to paste the clipboard text.
|
|
92 |
*/
|
|
93 |
virtual TBool CcpuCanPaste() const = 0;
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Derived classes must provide the implementation for
|
|
97 |
* following:
|
|
98 |
*
|
|
99 |
* Pastes text from the clipboard to the editor.
|
|
100 |
*/
|
|
101 |
virtual void CcpuPasteL() = 0;
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Derived classes must provide the implementation for
|
|
105 |
* following:
|
|
106 |
*
|
|
107 |
* Tests is it possible to undo previous operation.
|
|
108 |
*
|
|
109 |
* @return @c ETrue if it is possible to undo previous operation.
|
|
110 |
*/
|
|
111 |
virtual TBool CcpuCanUndo() const = 0;
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Derived classes must provide the implementation for
|
|
115 |
* following:
|
|
116 |
*
|
|
117 |
* Undoes the most recent text operation when the editor supports this
|
|
118 |
* feature and when the undo store is not empty
|
|
119 |
*/
|
|
120 |
virtual void CcpuUndoL() = 0;
|
|
121 |
};
|
|
122 |
|
|
123 |
/**
|
|
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.
|
|
128 |
*/
|
|
129 |
class CAknCcpuSupport : public CAknControl, public MEikMenuObserver
|
|
130 |
{
|
|
131 |
public:
|
|
132 |
/**
|
|
133 |
* Constructor. ConstructL() must be called after a call
|
|
134 |
* to this function.
|
|
135 |
*
|
|
136 |
* @param aEditor A pointer to the editor implementing the
|
|
137 |
* MEikCcpuEditor interface.
|
|
138 |
*/
|
|
139 |
IMPORT_C CAknCcpuSupport(MEikCcpuEditor* aEditor);
|
|
140 |
|
|
141 |
/**
|
|
142 |
* Destructor.
|
|
143 |
*/
|
|
144 |
IMPORT_C ~CAknCcpuSupport();
|
|
145 |
|
|
146 |
/**
|
|
147 |
* 2nd phase constructor.
|
|
148 |
*
|
|
149 |
* Adds this control to the control stack.
|
|
150 |
*/
|
|
151 |
IMPORT_C void ConstructL();
|
|
152 |
|
|
153 |
/**
|
|
154 |
* Updates the CBA labels according to selection and
|
|
155 |
* clipboard contents.
|
|
156 |
*/
|
|
157 |
IMPORT_C void HandleSelectionChangeL();
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Updates the CBA labels according to editor focus
|
|
161 |
* state.
|
|
162 |
*/
|
|
163 |
IMPORT_C void HandleFocusChangeL();
|
|
164 |
|
|
165 |
// from CCoeControl
|
|
166 |
|
|
167 |
/**
|
|
168 |
* Responds to key presses.
|
|
169 |
*
|
|
170 |
* Overrides CCoeControl::OfferKeyEventL().
|
|
171 |
*
|
|
172 |
* @param aKeyEvent The key event.
|
|
173 |
* @param aType Not used.
|
|
174 |
* @return Indicates whether or not the key event was consumed.
|
|
175 |
*/
|
|
176 |
IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
|
|
177 |
|
|
178 |
/**
|
|
179 |
* From @c CCoeControl.
|
|
180 |
*
|
|
181 |
* Handles pointer events.
|
|
182 |
*
|
|
183 |
* @param aPointerEvent The pointer event.
|
|
184 |
*/
|
|
185 |
IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
|
|
186 |
|
|
187 |
// from MEikMenuObserver
|
|
188 |
|
|
189 |
/**
|
|
190 |
* From MEikMenuObserver.
|
|
191 |
*
|
|
192 |
* Dynamically initialises a menu pane.
|
|
193 |
*
|
|
194 |
* @param aResourceId Resource ID of the menu.
|
|
195 |
* @param aMenuPane The in-memory representation of the menu pane.
|
|
196 |
*/
|
|
197 |
IMPORT_C void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
|
|
198 |
|
|
199 |
/**
|
|
200 |
* From MEikCommandObserver.
|
|
201 |
*
|
|
202 |
* Processes user commands.
|
|
203 |
*
|
|
204 |
* @param aCommandId ID of the command to respond to.
|
|
205 |
*/
|
|
206 |
IMPORT_C void ProcessCommandL(TInt aCommandId);
|
|
207 |
|
|
208 |
private:
|
|
209 |
void UpdateCBALabelsL();
|
|
210 |
TBool UpdateCBALabelL(TInt aPosition, TInt aCommandId, TInt aTextResId);
|
|
211 |
void SetEmphasis(CCoeControl* aMenuControl,TBool aEmphasis);
|
|
212 |
|
|
213 |
private:
|
|
214 |
/**
|
|
215 |
* From CAknControl
|
|
216 |
*/
|
|
217 |
IMPORT_C void* ExtensionInterface( TUid aInterface );
|
|
218 |
private:
|
|
219 |
TBitFlags iFlags;
|
|
220 |
|
|
221 |
// Owned
|
|
222 |
CEikButtonGroupContainer* iCba;
|
|
223 |
|
|
224 |
// Not owned
|
|
225 |
CEikMenuBar* iMenu;
|
|
226 |
MEikCcpuEditor* iEditor;
|
|
227 |
};
|
|
228 |
|
|
229 |
#endif // EIKCCPU_H
|