23 #include <aknenv.h> |
23 #include <aknenv.h> |
24 #include <avkon.rsg> |
24 #include <avkon.rsg> |
25 #include <avkon.hrh> |
25 #include <avkon.hrh> |
26 #include <eikappui.h> |
26 #include <eikappui.h> |
27 #include <eikdialg.h> |
27 #include <eikdialg.h> |
28 const TInt ELeftSoftkeyIndex = 0; |
28 const TInt KLeftSoftkeyIndex = 0; |
29 const TInt ERightSoftkeyIndex = 2; |
29 const TInt KRightSoftkeyIndex = 2; |
30 const TInt ENullCommandId = -1; |
30 const TInt KNullCommandId = -1; |
31 |
31 |
|
32 /** |
|
33 * Internal extension class for CAknCcpuSupport. |
|
34 * |
|
35 * @since 9.2 |
|
36 * |
|
37 * @internal |
|
38 */ |
|
39 NONSHARABLE_CLASS( CAknCcpuSupportExtension ) : public CBase |
|
40 { |
|
41 public: // Construction and destruction |
|
42 |
|
43 CAknCcpuSupportExtension(); |
|
44 ~CAknCcpuSupportExtension(); |
|
45 |
|
46 public: // Data |
|
47 TBool iIsCbaEmded; |
|
48 // Owned |
|
49 CEikButtonGroupContainer* iCba; |
|
50 // not owned |
|
51 CEikButtonGroupContainer* iDialogCba; |
|
52 }; |
|
53 |
|
54 CAknCcpuSupportExtension::CAknCcpuSupportExtension() |
|
55 { |
|
56 } |
|
57 |
|
58 CAknCcpuSupportExtension::~CAknCcpuSupportExtension() |
|
59 { |
|
60 delete iCba; |
|
61 } |
32 |
62 |
33 // |
63 // |
34 // CAknCcpuSupport |
64 // CAknCcpuSupport |
35 // |
65 // |
36 |
66 |
37 enum TAknCcpuSupportFlags |
67 enum TAknCcpuSupportFlags |
38 { |
68 { |
39 EFocused |
69 EFocused |
40 }; |
70 }; |
41 |
71 |
42 EXPORT_C CAknCcpuSupport::CAknCcpuSupport(MEikCcpuEditor* aEditor) |
72 EXPORT_C CAknCcpuSupport::CAknCcpuSupport( MEikCcpuEditor* aEditor ) |
43 : iEditor(aEditor) |
73 : iEditor( aEditor ) |
44 { |
74 { |
45 } |
75 } |
46 |
76 |
47 EXPORT_C CAknCcpuSupport::~CAknCcpuSupport() |
77 EXPORT_C CAknCcpuSupport::~CAknCcpuSupport() |
48 { |
78 { |
49 if (iMenu) |
79 if ( iMenu ) |
|
80 { |
50 iMenu->RemoveEditMenuObserver(this); |
81 iMenu->RemoveEditMenuObserver(this); |
51 //delete iCba; |
82 } |
52 TRAP_IGNORE(DeleteCBAL()); |
83 TRAP_IGNORE( DeleteCBAL() ); |
53 iEikonEnv->EikAppUi()->RemoveFromStack(this); |
84 iEikonEnv->EikAppUi()->RemoveFromStack( this ); |
|
85 delete iExtention; |
54 } |
86 } |
55 |
87 |
56 EXPORT_C void CAknCcpuSupport::ConstructL() |
88 EXPORT_C void CAknCcpuSupport::ConstructL() |
57 { |
89 { |
58 iEikonEnv->EikAppUi()->AddToStackL(this, ECoeStackPriorityFep-1, ECoeStackFlagRefusesFocus); |
90 iExtention = new ( ELeave ) CAknCcpuSupportExtension; |
|
91 iEikonEnv->EikAppUi()->AddToStackL( this, ECoeStackPriorityFep-1, ECoeStackFlagRefusesFocus ); |
59 HandleFocusChangeL(); |
92 HandleFocusChangeL(); |
60 } |
93 } |
61 |
94 |
62 EXPORT_C void CAknCcpuSupport::HandleSelectionChangeL() |
95 EXPORT_C void CAknCcpuSupport::HandleSelectionChangeL() |
63 { |
96 { |
64 if (iCba) |
97 if ( iExtention->iCba ) |
|
98 { |
65 UpdateCBALabelsL(); |
99 UpdateCBALabelsL(); |
|
100 } |
66 } |
101 } |
67 |
102 |
68 EXPORT_C void CAknCcpuSupport::HandleFocusChangeL() |
103 EXPORT_C void CAknCcpuSupport::HandleFocusChangeL() |
69 { |
104 { |
70 TBool focused = iEditor->CcpuIsFocused(); |
105 TBool focused = iEditor->CcpuIsFocused(); |
71 if (COMPARE_BOOLS(focused, iFlags[EFocused])) |
106 if ( COMPARE_BOOLS( focused, iFlags[EFocused] ) ) |
|
107 { |
72 return; |
108 return; |
73 |
109 } |
74 iFlags.Assign(EFocused, focused); |
110 |
75 |
111 iFlags.Assign( EFocused, focused ); |
76 if (focused) |
112 |
77 { |
113 if ( focused ) |
78 MopGetObject(iMenu); |
114 { |
79 |
115 MopGetObject( iMenu ); |
80 if (iMenu) |
116 if ( iMenu ) |
81 iMenu->SetEditMenuObserver(this); |
117 { |
|
118 iMenu->SetEditMenuObserver( this ); |
|
119 } |
82 } |
120 } |
83 else |
121 else |
84 { |
122 { |
85 if (iMenu) |
123 if ( iMenu ) |
86 { |
124 { |
87 iMenu->RemoveEditMenuObserver(this); |
125 iMenu->RemoveEditMenuObserver( this ); |
88 iMenu = NULL; |
126 iMenu = NULL; |
89 } |
127 } |
90 } |
128 } |
91 |
129 |
92 if (iCba && !focused) |
130 if ( iExtention->iCba && !focused ) |
93 { |
131 { |
94 // something has caused loss of focus while shift is pressed - drop everything. |
132 // something has caused loss of focus while shift is pressed - drop everything. |
95 //delete iCba; |
|
96 //iCba = NULL; |
|
97 DeleteCBAL(); |
133 DeleteCBAL(); |
98 } |
134 } |
99 } |
135 } |
100 |
136 |
101 EXPORT_C TKeyResponse CAknCcpuSupport::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
137 EXPORT_C TKeyResponse CAknCcpuSupport::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
102 { |
138 { |
103 if (!iFlags[EFocused]) |
139 if ( !iFlags[EFocused] ) |
|
140 { |
104 return EKeyWasNotConsumed; |
141 return EKeyWasNotConsumed; |
105 |
142 } |
106 if (aKeyEvent.iCode == EKeyF21) // FEP generates F21 on long shift press |
143 |
107 { |
144 if ( aKeyEvent.iCode == EKeyF21 ) // FEP generates F21 on long shift press |
108 if (aType == EEventKey) |
145 { |
|
146 if ( aType == EEventKey ) |
109 { |
147 { |
110 DeleteCBAL(); |
148 DeleteCBAL(); |
111 CEikAppUi* eikAppUi = (CEikAppUi *)CCoeEnv::Static()->AppUi(); |
149 CEikAppUi* eikAppUi = (CEikAppUi *)CCoeEnv::Static()->AppUi(); |
112 if( eikAppUi!= NULL && eikAppUi->IsDisplayingDialog() && eikAppUi->TopFocusedControl() ) |
150 if( eikAppUi && eikAppUi->IsDisplayingDialog() && eikAppUi->TopFocusedControl() ) |
113 { |
151 { |
114 CEikDialog* dlg = eikAppUi->TopFocusedControl()->MopGetObject( dlg ); |
152 CEikDialog* dlg = eikAppUi->TopFocusedControl()->MopGetObject( dlg ); |
115 if ( dlg ) |
153 if ( dlg ) |
116 { |
154 { |
117 CEikButtonGroupContainer* currentCba = dlg->MopGetObject( currentCba ); |
155 CEikButtonGroupContainer* currentCba = dlg->MopGetObject( currentCba ); |
119 if ( currentCba ) |
157 if ( currentCba ) |
120 { |
158 { |
121 CEikCba* dlgcba = static_cast<CEikCba*>( currentCba->ButtonGroup() ); |
159 CEikCba* dlgcba = static_cast<CEikCba*>( currentCba->ButtonGroup() ); |
122 TUint flags( 0 ); |
160 TUint flags( 0 ); |
123 flags |= CEikButtonGroupContainer::EIsEmbedded | CEikButtonGroupContainer::EAddToStack; |
161 flags |= CEikButtonGroupContainer::EIsEmbedded | CEikButtonGroupContainer::EAddToStack; |
124 iCba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, CEikButtonGroupContainer::EHorizontal, |
162 iExtention->iCba = CEikButtonGroupContainer::NewL( |
|
163 CEikButtonGroupContainer::ECba, |
|
164 CEikButtonGroupContainer::EHorizontal, |
125 this, R_AVKON_SOFTKEYS_EMPTY, flags ); |
165 this, R_AVKON_SOFTKEYS_EMPTY, flags ); |
126 |
166 |
127 CEikCba* cba = static_cast<CEikCba*>( |
167 CEikCba* cba = static_cast<CEikCba*>( |
128 iCba->ButtonGroup() ); |
168 iExtention->iCba->ButtonGroup() ); |
129 |
169 |
130 if( ! isCbaEmded ) |
170 if( !iExtention->iIsCbaEmded ) |
131 { |
171 { |
132 currentCba->AddCommandToStackL(ELeftSoftkeyIndex, -1, _L(""), NULL, NULL); |
172 currentCba->AddCommandToStackL( KLeftSoftkeyIndex, -1, KNullDesC, NULL, NULL ); |
133 currentCba->AddCommandToStackL(ERightSoftkeyIndex, -1, _L(""), NULL, NULL); |
173 currentCba->AddCommandToStackL( KRightSoftkeyIndex, -1, KNullDesC, NULL, NULL ); |
134 currentCba->ActivateL(); |
174 currentCba->ActivateL(); |
135 currentCba->DrawNow(); |
175 currentCba->DrawNow(); |
136 iDialogCba = currentCba; |
176 iExtention->iDialogCba = currentCba; |
137 isCbaEmded = ETrue; |
177 iExtention->iIsCbaEmded = ETrue; |
138 } |
178 } |
139 |
179 |
140 cba->SetButtonGroupFlags( ~(EEikCbaFlagTransparent | EEikCbaFlagOutlineFont) ); |
180 cba->SetButtonGroupFlags( ~( EEikCbaFlagTransparent | EEikCbaFlagOutlineFont ) ); |
141 TRect dlgRect(dlg->Rect()); |
181 TRect dlgRect(dlg->Rect()); |
142 TRect cbaRect(currentCba->Rect()); |
182 TRect cbaRect(currentCba->Rect()); |
143 iCba->SetRect( currentCba->Rect()); |
183 iExtention->iCba->SetRect( currentCba->Rect()); |
144 iCba->SetPosition(TPoint(dlg->DrawableWindow()->Position().iX,dlg->DrawableWindow()->Position().iY + dlgRect.Height() - cbaRect.Height())); |
184 iExtention->iCba->SetPosition( |
145 iCba->SetBoundingRect( dlg->Rect()); |
185 TPoint( dlg->DrawableWindow()->Position().iX, |
|
186 dlg->DrawableWindow()->Position().iY + dlgRect.Height() - cbaRect.Height() ) ); |
|
187 iExtention->iCba->SetBoundingRect( dlg->Rect() ); |
146 |
188 |
147 } |
189 } |
148 |
190 } |
149 } |
|
150 |
|
151 } |
191 } |
152 if(iCba == NULL)//if iCba was not create in the above branch but was deleted by DeleteCBA |
192 if( !iExtention->iCba )//if iCba was not create in the above branch but was deleted by DeleteCBA |
153 { |
193 { |
154 iCba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, CEikButtonGroupContainer::EHorizontal, this, R_AVKON_SOFTKEYS_EMPTY); |
194 iExtention->iCba = CEikButtonGroupContainer::NewL( |
155 iCba->SetBoundingRect(iEikonEnv->EikAppUi()->ApplicationRect()); |
195 CEikButtonGroupContainer::ECba, |
|
196 CEikButtonGroupContainer::EHorizontal, |
|
197 this, R_AVKON_SOFTKEYS_EMPTY ); |
|
198 iExtention->iCba->SetBoundingRect( iEikonEnv->EikAppUi()->ApplicationRect() ); |
156 } |
199 } |
157 UpdateCBALabelsL(); |
200 UpdateCBALabelsL(); |
158 } |
201 } |
159 return EKeyWasConsumed; |
202 return EKeyWasConsumed; |
160 } |
203 } |
161 else if (aType == EEventKey && |
204 else if ( aType == EEventKey && |
162 aKeyEvent.iCode == EKeyF18 && |
205 aKeyEvent.iCode == EKeyF18 && |
163 (aKeyEvent.iModifiers & EModifierCtrl)) |
206 ( aKeyEvent.iModifiers & EModifierCtrl ) ) |
164 { |
207 { |
165 // FEP requests Ccpu actions with CTRL + F18 |
208 // FEP requests Ccpu actions with CTRL + F18 |
166 // Requested action is encoded in iScanCode. |
209 // Requested action is encoded in iScanCode. |
167 ProcessCommandL(aKeyEvent.iScanCode); |
210 ProcessCommandL( aKeyEvent.iScanCode ); |
168 return EKeyWasConsumed; |
211 return EKeyWasConsumed; |
169 } |
212 } |
170 else if ((aKeyEvent.iScanCode == EStdKeyLeftShift || aKeyEvent.iScanCode == EStdKeyRightShift) && aType == EEventKeyUp) |
213 else if ( ( aKeyEvent.iScanCode == EStdKeyLeftShift || |
171 { |
214 aKeyEvent.iScanCode == EStdKeyRightShift ) && |
172 //delete iCba; |
215 aType == EEventKeyUp ) |
173 //iCba = NULL; |
216 { |
174 DeleteCBAL(); |
217 DeleteCBAL(); |
175 } |
218 } |
176 |
219 |
177 return EKeyWasNotConsumed; |
220 return EKeyWasNotConsumed; |
178 } |
221 } |
179 |
222 |
180 EXPORT_C void CAknCcpuSupport::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) |
223 EXPORT_C void CAknCcpuSupport::DynInitMenuPaneL( TInt aResourceId,CEikMenuPane* aMenuPane ) |
181 { |
224 { |
182 if (aResourceId == R_AVKON_EDIT_MODE_MENU || |
225 if ( aResourceId == R_AVKON_EDIT_MODE_MENU || |
183 aResourceId == R_AVKON_EDIT_TEXT_MENU) |
226 aResourceId == R_AVKON_EDIT_TEXT_MENU ) |
184 { |
227 { |
185 aMenuPane->SetItemDimmed(EEikCmdEditCut,!iEditor->CcpuCanCut()); |
228 aMenuPane->SetItemDimmed( EEikCmdEditCut,!iEditor->CcpuCanCut() ); |
186 aMenuPane->SetItemDimmed(EEikCmdEditCopy,!iEditor->CcpuCanCopy()); |
229 aMenuPane->SetItemDimmed( EEikCmdEditCopy,!iEditor->CcpuCanCopy() ); |
187 aMenuPane->SetItemDimmed(EEikCmdEditPaste,!iEditor->CcpuCanPaste()); |
230 aMenuPane->SetItemDimmed( EEikCmdEditPaste,!iEditor->CcpuCanPaste() ); |
188 } |
231 } |
189 } |
232 } |
190 |
233 |
191 EXPORT_C void CAknCcpuSupport::ProcessCommandL(TInt aCommandId) |
234 EXPORT_C void CAknCcpuSupport::ProcessCommandL( TInt aCommandId ) |
192 { |
235 { |
193 switch (aCommandId) |
236 switch ( aCommandId ) |
194 { |
237 { |
195 case EEikCmdEditCut: |
238 case EEikCmdEditCut: |
196 iEditor->CcpuCutL(); |
239 iEditor->CcpuCutL(); |
197 break; |
240 break; |
198 case EEikCmdEditCopy: |
241 case EEikCmdEditCopy: |
211 |
254 |
212 void CAknCcpuSupport::UpdateCBALabelsL() |
255 void CAknCcpuSupport::UpdateCBALabelsL() |
213 { |
256 { |
214 TBool change = EFalse; |
257 TBool change = EFalse; |
215 |
258 |
216 if (iEditor->CcpuCanCopy()) |
259 if ( iEditor->CcpuCanCopy() ) |
217 change = UpdateCBALabelL(ELeftSoftkeyIndex, EEikCmdEditCopy, R_TEXT_SOFTKEY_COPY) || change; |
260 { |
|
261 change = UpdateCBALabelL( KLeftSoftkeyIndex, EEikCmdEditCopy, R_TEXT_SOFTKEY_COPY ) || change; |
|
262 } |
218 else |
263 else |
219 change = UpdateCBALabelL(ELeftSoftkeyIndex, ENullCommandId, R_TEXT_SOFTKEY_EMPTY) || change; |
264 { |
220 |
265 change = UpdateCBALabelL( KLeftSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY ) || change; |
221 if (iEditor->CcpuCanPaste()) |
266 } |
222 change = UpdateCBALabelL(ERightSoftkeyIndex, EEikCmdEditPaste, R_TEXT_SOFTKEY_PASTE) || change; |
267 |
|
268 if ( iEditor->CcpuCanPaste() ) |
|
269 { |
|
270 change = UpdateCBALabelL( KRightSoftkeyIndex, EEikCmdEditPaste, R_TEXT_SOFTKEY_PASTE ) || change; |
|
271 } |
223 else |
272 else |
224 change = UpdateCBALabelL(ERightSoftkeyIndex, ENullCommandId, R_TEXT_SOFTKEY_EMPTY) || change; |
273 { |
225 |
274 change = UpdateCBALabelL( KRightSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY ) || change; |
226 if (change) |
275 } |
227 { |
276 |
228 iCba->DrawNow(); |
277 if ( change ) |
229 } |
278 { |
230 } |
279 iExtention->iCba->DrawNow(); |
231 |
280 } |
232 TBool CAknCcpuSupport::UpdateCBALabelL(TInt aPosition, TInt aCommandId, TInt aTextResId) |
281 } |
233 { |
282 |
234 if (iCba->ButtonGroup()->CommandId(aPosition) != aCommandId) |
283 TBool CAknCcpuSupport::UpdateCBALabelL( TInt aPosition, TInt aCommandId, TInt aTextResId ) |
235 { |
284 { |
236 HBufC* buf = iEikonEnv->AllocReadResourceLC(aTextResId); |
285 if ( iExtention->iCba->ButtonGroup()->CommandId(aPosition) != aCommandId ) |
237 iCba->SetCommandL(aPosition, aCommandId, *buf); |
286 { |
238 CleanupStack::PopAndDestroy(buf); |
287 HBufC* buf = iEikonEnv->AllocReadResourceLC( aTextResId ); |
|
288 iExtention->iCba->SetCommandL( aPosition, aCommandId, *buf ); |
|
289 CleanupStack::PopAndDestroy( buf ); |
239 return ETrue; |
290 return ETrue; |
240 } |
291 } |
241 return EFalse; |
292 return EFalse; |
242 } |
293 } |
243 |
294 |
244 void CAknCcpuSupport::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/) |
295 void CAknCcpuSupport::SetEmphasis( CCoeControl* /*aMenuControl*/, TBool /*aEmphasis*/ ) |
245 { |
296 { |
246 } |
297 } |
247 |
298 |
248 EXPORT_C void CAknCcpuSupport::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
299 EXPORT_C void CAknCcpuSupport::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
249 { |
300 { |
250 CAknControl::HandlePointerEventL(aPointerEvent); |
301 CAknControl::HandlePointerEventL( aPointerEvent ); |
251 } |
302 } |
252 |
303 |
253 EXPORT_C void* CAknCcpuSupport::ExtensionInterface( TUid /*aInterface*/ ) |
304 EXPORT_C void* CAknCcpuSupport::ExtensionInterface( TUid /*aInterface*/ ) |
254 { |
305 { |
255 return NULL; |
306 return NULL; |
256 } |
307 } |
257 void CAknCcpuSupport::DeleteCBAL() |
308 void CAknCcpuSupport::DeleteCBAL() |
258 { |
309 { |
259 if ( iCba != NULL ) |
310 if ( iExtention->iCba ) |
260 { |
311 { |
261 delete iCba; |
312 delete iExtention->iCba; |
262 iCba = NULL; |
313 iExtention->iCba = NULL; |
263 } |
314 } |
264 if (isCbaEmded) |
315 if ( iExtention->iIsCbaEmded ) |
265 { |
316 { |
266 CEikAppUi* eikAppUi = (CEikAppUi *)CCoeEnv::Static()->AppUi(); |
317 CEikAppUi* eikAppUi = (CEikAppUi *)CCoeEnv::Static()->AppUi(); |
267 if( eikAppUi!= NULL && eikAppUi->IsDisplayingDialog() && eikAppUi->TopFocusedControl() ) |
318 if( eikAppUi && eikAppUi->IsDisplayingDialog() && eikAppUi->TopFocusedControl() ) |
268 { |
319 { |
269 CEikDialog* dlg = eikAppUi->TopFocusedControl()->MopGetObject( dlg ); |
320 CEikDialog* dlg = eikAppUi->TopFocusedControl()->MopGetObject( dlg ); |
270 if ( dlg ) |
321 if ( dlg ) |
271 { |
322 { |
272 CEikButtonGroupContainer* currentCba = dlg->MopGetObject( currentCba ); |
323 CEikButtonGroupContainer* currentCba = dlg->MopGetObject( currentCba ); |
273 CEikCba* dlgcba = static_cast<CEikCba*>( |
324 CEikCba* dlgcba = static_cast<CEikCba*>( |
274 currentCba->ButtonGroup() ); |
325 currentCba->ButtonGroup() ); |
275 if ( currentCba && iDialogCba == currentCba ) |
326 if ( currentCba && iExtention->iDialogCba == currentCba ) |
276 { |
327 { |
277 currentCba->RemoveCommandFromStack(ELeftSoftkeyIndex,-1); |
328 currentCba->RemoveCommandFromStack( KLeftSoftkeyIndex, -1 ); |
278 currentCba->RemoveCommandFromStack(ERightSoftkeyIndex,-1); |
329 currentCba->RemoveCommandFromStack( KRightSoftkeyIndex, -1 ); |
279 |
330 currentCba->DrawNow(); |
280 //dlgcba->UpdateCbaLabels(EFalse); |
331 currentCba->ActivateL(); |
281 currentCba->DrawNow(); |
332 iExtention->iDialogCba = NULL; |
282 currentCba->ActivateL(); |
333 iExtention->iIsCbaEmded = EFalse; |
283 iDialogCba = NULL; |
334 } |
284 isCbaEmded = EFalse; |
335 } |
285 } |
336 } |
286 } |
337 } |
287 } |
338 } |
288 } |
|
289 |
|
290 } |
|