author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:30:35 +0300 | |
branch | RCL_3 |
changeset 86 | ed599363c2d7 |
parent 66 | bd7edf625bdd |
permissions | -rw-r--r-- |
66 | 1 |
/* |
2 |
* Copyright (c) 2002 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: Implementation of Notepad Editor mode. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include "NpdLib.hrh" |
|
21 |
#include "NpdExternalTextEditorDialog.h" |
|
22 |
#include "NpdApi.h" |
|
23 |
#include "NpdLib.h" |
|
24 |
#include "NpdUtil.h" |
|
25 |
#include "NpdEdwin.h" |
|
26 |
||
27 |
#include <NpdLib.rsg> |
|
28 |
||
29 |
#include <aknappui.h> |
|
30 |
#include <avkon.hrh> |
|
31 |
#include <eikmenup.h> |
|
32 |
#include <txtetext.h> |
|
33 |
#include <AknForm.h> |
|
34 |
#include <aknnotedialog.h> |
|
35 |
#include <eikapp.h> |
|
36 |
#include <aknnotewrappers.h> |
|
37 |
#include <sendui.h> |
|
38 |
#include <SenduiMtmUids.h> |
|
39 |
#include <Sendnorm.rsg> |
|
40 |
#include <barsread.h> |
|
41 |
#include <featmgr.h> |
|
42 |
#include <hlplch.h> |
|
43 |
#include <finditemmenu.h> |
|
44 |
#include <CommonContentPolicy.h> |
|
45 |
||
46 |
#include <finditemengine.h> |
|
47 |
#include <finditemmenu.h> |
|
48 |
#include <finditemdialog.h> |
|
49 |
#include <FindItemmenu.rsg> |
|
50 |
#include <finditem.hrh> |
|
51 |
||
52 |
#include <csxhelp/nmake.hlp.hrh> |
|
53 |
#include "NpdLibPanic.h" |
|
54 |
#include "NpdEdwinLines.h" |
|
55 |
||
56 |
||
57 |
// ============================ MEMBER FUNCTIONS =============================== |
|
58 |
||
59 |
// ----------------------------------------------------------------------------- |
|
60 |
// CNotepadExternalTextDialog::NewL |
|
61 |
// constructor. |
|
62 |
// ----------------------------------------------------------------------------- |
|
63 |
// |
|
64 |
EXPORT_C CNotepadExternalTextDialog* CNotepadExternalTextDialog::NewL( |
|
65 |
HBufC** aText, |
|
66 |
TInt& aReturnStatus, |
|
67 |
const TDesC& aInitialText, |
|
68 |
const TDesC& aTitle, |
|
69 |
const TDesC& aConfirmText, |
|
70 |
CEikDialog** aSelfPtr |
|
71 |
) |
|
72 |
{ |
|
73 |
CNotepadExternalTextDialog* self = new(ELeave) CNotepadExternalTextDialog(); |
|
74 |
self->iSelfPtr = aSelfPtr; |
|
75 |
CleanupStack::PushL(self); |
|
76 |
||
77 |
TResourceReader rr; |
|
78 |
self->iCoeEnv->CreateResourceReaderLC(rr, R_NOTEPAD_TEXT_EDITOR); |
|
79 |
self->ConstructL( rr, aText, aReturnStatus, aInitialText, aTitle , aConfirmText); |
|
80 |
CleanupStack::PopAndDestroy(); // rr |
|
81 |
CleanupStack::Pop(); // rr |
|
82 |
return self; |
|
83 |
} |
|
84 |
||
85 |
// ----------------------------------------------------------------------------- |
|
86 |
// CNotepadExternalTextDialog::ConstructL |
|
87 |
// constructor. |
|
88 |
// ----------------------------------------------------------------------------- |
|
89 |
// |
|
90 |
void CNotepadExternalTextDialog::ConstructL( |
|
91 |
TResourceReader &rr, |
|
92 |
HBufC** aText, |
|
93 |
TInt& aReturnStatus, |
|
94 |
const TDesC& aInitialText, |
|
95 |
const TDesC& aTitle, |
|
96 |
const TDesC& aConfirmText |
|
97 |
) |
|
98 |
{ |
|
99 |
if ( aTitle.Length() != 0 ) |
|
100 |
{ |
|
101 |
CNotepadDialogBase::SetTitleL(&aTitle); |
|
102 |
} |
|
103 |
iContent.Set( aInitialText ); |
|
104 |
iContentPointer = aText; |
|
105 |
||
106 |
if (aConfirmText.Length() != 0) |
|
107 |
{ |
|
108 |
iDeleteConfirmation.Set( aConfirmText ); |
|
109 |
} |
|
110 |
||
111 |
iOKKeyPressed = ETrue; |
|
112 |
CNotepadDialogBase::ConstructL(rr); |
|
113 |
iReturnValue = &aReturnStatus; |
|
114 |
iFindItemMenu = CFindItemMenu::NewL(ENotepadCmdFind); |
|
115 |
} |
|
116 |
||
117 |
// ----------------------------------------------------------------------------- |
|
118 |
// CNotepadExternalTextDialog::~CNotepadExternalTextDialog |
|
119 |
// Destructor |
|
120 |
// ----------------------------------------------------------------------------- |
|
121 |
// |
|
122 |
EXPORT_C CNotepadExternalTextDialog::~CNotepadExternalTextDialog() |
|
123 |
{ |
|
124 |
delete iFindItemMenu; |
|
125 |
} |
|
126 |
||
127 |
// ----------------------------------------------------------------------------- |
|
128 |
// CNotepadExternalTextDialog::OkToExitL |
|
129 |
// ----------------------------------------------------------------------------- |
|
130 |
// |
|
131 |
TBool CNotepadExternalTextDialog::OkToExitL( TInt aButtonId ) |
|
132 |
{ |
|
133 |
TBool isOk(ETrue); |
|
134 |
//MSK |
|
135 |
if(aButtonId == EAknSoftkeyContextOptions ) |
|
136 |
{ |
|
137 |
iOKKeyPressed = ETrue; |
|
138 |
DisplayMenuL(); |
|
139 |
return EFalse; |
|
140 |
} |
|
141 |
else if(aButtonId == EAknSoftkeyOptions ) |
|
142 |
{ |
|
143 |
iOKKeyPressed = EFalse; |
|
144 |
} |
|
145 |
else |
|
146 |
{ |
|
147 |
} |
|
148 |
isOk = CAknDialog::OkToExitL(aButtonId); |
|
149 |
||
150 |
TInt size = iEditor->Text()->DocumentLength(); |
|
151 |
||
152 |
if(size == 0) |
|
153 |
{ |
|
154 |
*iReturnValue = CNotepadApi::ENpdDataErased; |
|
155 |
} |
|
156 |
else if(size != 0 && (*iReturnValue) != CNotepadApi::ENpdDataDeleted ) |
|
157 |
{ |
|
158 |
*iContentPointer = HBufC::NewL(size); |
|
159 |
TPtr desptr = (*iContentPointer)->Des(); |
|
160 |
iEditor->Text()->Extract(desptr,0,size); |
|
161 |
if(NotepadUtil::IsEmpty(**iContentPointer)) |
|
162 |
{ |
|
163 |
*iReturnValue = CNotepadApi::ENpdDataErased; |
|
164 |
} |
|
165 |
else |
|
166 |
{ |
|
167 |
*iReturnValue = CNotepadApi::ENpdDataEdited; |
|
168 |
} |
|
169 |
} |
|
170 |
||
171 |
return isOk; |
|
172 |
} |
|
173 |
||
174 |
// --------------------------------------------------------- |
|
175 |
// CNotepadExternalTextDialog::HandleResourceChange |
|
176 |
// from CCoeControl |
|
177 |
// --------------------------------------------------------- |
|
178 |
// |
|
179 |
void CNotepadExternalTextDialog::HandleResourceChange(TInt aType) |
|
180 |
{ |
|
181 |
if (aType == KEikDynamicLayoutVariantSwitch) |
|
182 |
{ |
|
183 |
TRect mainPane; |
|
184 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPane); |
|
185 |
SetRect(mainPane); |
|
186 |
} |
|
187 |
} |
|
188 |
||
189 |
// --------------------------------------------------------- |
|
190 |
// CNotepadExternalTextDialog::SizeChanged |
|
191 |
// from CCoeControl |
|
192 |
// --------------------------------------------------------- |
|
193 |
// |
|
194 |
void CNotepadExternalTextDialog::SizeChanged() |
|
195 |
{ |
|
196 |
CNotepadDialogBase::SizeChanged(); |
|
197 |
if (iEditor && IsActivated()) |
|
198 |
{ |
|
199 |
TRAP_IGNORE(iEditor->DoEditorLayoutL()); |
|
200 |
} |
|
201 |
} |
|
202 |
||
203 |
// ----------------------------------------------------------------------------- |
|
204 |
// CNotepadExternalTextDialog::PostLayoutDynInitL |
|
205 |
// ----------------------------------------------------------------------------- |
|
206 |
// |
|
207 |
void CNotepadExternalTextDialog::PostLayoutDynInitL() |
|
208 |
{ |
|
209 |
||
210 |
iEditor = STATIC_CAST(CNotepadEdwin*, Control(ENotepadIdEdwin)); |
|
211 |
iEditor->ConstructBaseL(); |
|
212 |
__ASSERT_DEBUG( iEditor, Panic(ENotepadLibraryPanicNoEdwin) ); |
|
213 |
iEditor->CreatePreAllocatedScrollBarFrameL()->SetScrollBarVisibilityL( |
|
214 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
215 |
||
216 |
iEditor->Text()->Reset(); |
|
217 |
iEditor->SetTextL(&iContent); |
|
218 |
iEditor->HandleTextChangedL(); |
|
219 |
||
220 |
CEikAppUi* container = iAvkonAppUi->ContainerAppUi(); |
|
221 |
//cannot find UIDs in SenduiMtmUids.h |
|
222 |
TUid appuid = KNullUid; |
|
223 |
if ( container ) |
|
224 |
{ |
|
225 |
appuid = container->Application()->AppDllUid(); |
|
226 |
} |
|
227 |
||
228 |
TRect rect(iEikonEnv->EikAppUi()->ClientRect()); |
|
229 |
iEditor->SetRect(rect); |
|
230 |
} |
|
231 |
||
232 |
// ----------------------------------------------------------------------------- |
|
233 |
// CNotepadExternalTextDialog::ActivateL |
|
234 |
// ----------------------------------------------------------------------------- |
|
235 |
// |
|
236 |
void CNotepadExternalTextDialog::ActivateL() |
|
237 |
{ |
|
238 |
__ASSERT_DEBUG( iEditor, Panic(ENotepadLibraryPanicNoEdwin) ); |
|
239 |
iEditor->InitNotepadEditorL(this, STATIC_CAST(CNotepadEdwinLines*, Control(ENotepadIdEdwinLines))); |
|
240 |
iEditor->SetFocus(ETrue, ENoDrawNow); |
|
241 |
CNotepadDialogBase::ActivateL(); |
|
242 |
} |
|
243 |
||
244 |
// ----------------------------------------------------------------------------- |
|
245 |
// CNotepadExternalTextDialog::OfferKeyEventL |
|
246 |
// from CoeControl |
|
247 |
// ----------------------------------------------------------------------------- |
|
248 |
// |
|
249 |
TKeyResponse CNotepadExternalTextDialog::OfferKeyEventL( |
|
250 |
const TKeyEvent& aKeyEvent, |
|
251 |
TEventCode aType ) |
|
252 |
{ |
|
253 |
TKeyResponse keyResponse(EKeyWasConsumed); |
|
254 |
||
255 |
if ( !MenuShowing() && aType == EEventKey && |
|
256 |
!( aKeyEvent.iModifiers & (EAllStdModifiers|EModifierSpecial) ) && |
|
257 |
( aKeyEvent.iCode == EKeyOK ) ) |
|
258 |
{ |
|
259 |
iOKKeyPressed = ETrue; |
|
260 |
DisplayMenuL(); |
|
261 |
} |
|
262 |
else if( aKeyEvent.iCode == EKeyPhoneEnd ) |
|
263 |
{ |
|
264 |
TInt size = iEditor->Text()->DocumentLength(); |
|
265 |
if(size == 0) |
|
266 |
{ |
|
267 |
*iReturnValue = CNotepadApi::ENpdDataErased; |
|
268 |
} |
|
269 |
else if(size != 0 && (*iReturnValue) != CNotepadApi::ENpdDataDeleted ) |
|
270 |
{ |
|
271 |
*iContentPointer = HBufC::NewL(size); |
|
272 |
TPtr desptr = (*iContentPointer)->Des(); |
|
273 |
iEditor->Text()->Extract(desptr,0,size); |
|
274 |
if(NotepadUtil::IsEmpty(**iContentPointer)) |
|
275 |
{ |
|
276 |
*iReturnValue = CNotepadApi::ENpdDataErased; |
|
277 |
} |
|
278 |
else |
|
279 |
{ |
|
280 |
*iReturnValue = CNotepadApi::ENpdDataEdited; |
|
281 |
} |
|
282 |
} |
|
283 |
} |
|
284 |
else |
|
285 |
{ |
|
286 |
keyResponse = CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
|
287 |
} |
|
288 |
return keyResponse; |
|
289 |
} |
|
290 |
||
291 |
// ----------------------------------------------------------------------------- |
|
292 |
// CNotepadExternalTextDialog::GetHelpContext |
|
293 |
// ----------------------------------------------------------------------------- |
|
294 |
// |
|
295 |
void CNotepadExternalTextDialog::GetHelpContext(TCoeHelpContext& aContext) const |
|
296 |
{ |
|
297 |
aContext.iMajor = KUidNotepad; |
|
298 |
aContext.iContext = KNMAKE_HLP_MEMO_EDITOR_APPS;//KNMAKE_HLP_MEMO_EDITOR; |
|
299 |
} |
|
300 |
||
301 |
// ----------------------------------------------------------------------------- |
|
302 |
// CNotepadExternalTextDialog::ProcessCommandL |
|
303 |
// from MEikCommandObserver |
|
304 |
// ----------------------------------------------------------------------------- |
|
305 |
// |
|
306 |
void CNotepadExternalTextDialog::ProcessCommandL(TInt aCommandId) |
|
307 |
{ |
|
308 |
HideMenu(); |
|
309 |
if ( iFindItemMenu && iFindItemMenu->CommandIsValidL( aCommandId ) ) |
|
310 |
{ |
|
311 |
TInt ret = DoSearchL( iFindItemMenu->SearchCase(aCommandId) ); |
|
312 |
if ( ret == EAknSoftkeyExit ) |
|
313 |
{ |
|
314 |
aCommandId = ret; |
|
315 |
} |
|
316 |
else |
|
317 |
{ |
|
318 |
return; |
|
319 |
} |
|
320 |
} |
|
321 |
||
322 |
switch (aCommandId) |
|
323 |
{ |
|
324 |
case ENotepadCmdDelete: |
|
325 |
{ |
|
326 |
TBool deleted; |
|
327 |
if(iDeleteConfirmation.Length() != 0) |
|
328 |
{ |
|
329 |
deleted = CNotepadDialogBase::ExecuteConfirmationQueryL( &iDeleteConfirmation ); |
|
330 |
} |
|
331 |
else |
|
332 |
{ |
|
333 |
deleted =CNotepadDialogBase::ExecuteConfirmationQueryL( R_NOTEPAD_QUERY_DELETE_MEMO ); |
|
334 |
} |
|
335 |
if(deleted) |
|
336 |
{ |
|
337 |
*iReturnValue = CNotepadApi::ENpdDataDeleted; |
|
338 |
TryExitL(0); |
|
339 |
} |
|
340 |
break; |
|
341 |
} |
|
342 |
default: |
|
343 |
CNotepadDialogBase::ProcessCommandL(aCommandId); |
|
344 |
break; |
|
345 |
} |
|
346 |
} |
|
347 |
||
348 |
// ----------------------------------------------------------------------------- |
|
349 |
// CNotepadExternalTextDialog::DynInitMenuPaneL |
|
350 |
// from MEikMenuObserver |
|
351 |
// ----------------------------------------------------------------------------- |
|
352 |
// |
|
353 |
void CNotepadExternalTextDialog::DynInitMenuPaneL( |
|
354 |
TInt aResourceId, |
|
355 |
CEikMenuPane* aMenuPane ) |
|
356 |
{ |
|
357 |
switch ( aResourceId ) |
|
358 |
{ |
|
359 |
case R_NOTEPAD_TEXT_EDITOR_MENU: |
|
360 |
if ( !(NotepadUtil::IsEmpty( iEditor->Text()->Read(0, iEditor->Text()->DocumentLength()) ) ) ) |
|
361 |
{ |
|
362 |
if ( !(iOKKeyPressed) ) |
|
363 |
{ |
|
364 |
iFindItemMenu->DisplayFindItemMenuItemL( |
|
365 |
*aMenuPane, ENotepadCmdDelete); |
|
366 |
} |
|
367 |
} |
|
368 |
if ( iOKKeyPressed ) |
|
369 |
{ |
|
370 |
aMenuPane->SetItemDimmed(EAknCmdHelp,ETrue); |
|
371 |
aMenuPane->SetItemDimmed(EAknCmdExit, ETrue); |
|
372 |
iOKKeyPressed = ETrue; |
|
373 |
} |
|
374 |
else |
|
375 |
{ |
|
376 |
iOKKeyPressed = ETrue; |
|
377 |
} |
|
378 |
if(!FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
379 |
{ |
|
380 |
aMenuPane->SetItemDimmed(EAknCmdHelp, ETrue); |
|
381 |
} |
|
382 |
||
383 |
break; |
|
384 |
case R_FINDITEMMENU_MENU : |
|
385 |
{ |
|
386 |
iFindItemMenu->DisplayFindItemCascadeMenuL(*aMenuPane); |
|
387 |
break; |
|
388 |
} |
|
389 |
default: |
|
390 |
break; |
|
391 |
} |
|
392 |
} |
|
393 |
||
394 |
||
395 |
// ----------------------------------------------------------------------------- |
|
396 |
// CNotepadExternalTextDialog::DynInitMenuBarL |
|
397 |
// from MEikMenuObserver |
|
398 |
// ----------------------------------------------------------------------------- |
|
399 |
// |
|
400 |
void CNotepadExternalTextDialog::DynInitMenuBarL(TInt aResourceId, CEikMenuBar* aMenuBar) |
|
401 |
{ |
|
402 |
__ASSERT_DEBUG( aResourceId > 0,Panic(ENotepadLibraryPanicNoMenuResource) ); |
|
403 |
__ASSERT_DEBUG( aMenuBar, Panic(ENotepadLibraryPanicNoMenuResource) ); |
|
404 |
||
405 |
CEikMenuBar::TMenuType menuType = (iOKKeyPressed) ? CEikMenuBar::EMenuOptionsNoTaskSwapper : |
|
406 |
CEikMenuBar::EMenuOptions ; |
|
407 |
aMenuBar->SetMenuType(menuType); |
|
408 |
||
409 |
} |
|
410 |
||
411 |
// ----------------------------------------------------------------------------- |
|
412 |
// CNotepadExternalTextDialog::DoSearchL |
|
413 |
// ----------------------------------------------------------------------------- |
|
414 |
// |
|
415 |
TInt CNotepadExternalTextDialog::DoSearchL(CFindItemEngine::TFindItemSearchCase aCase) |
|
86
ed599363c2d7
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
416 |
{ |
ed599363c2d7
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
417 |
CFindItemDialog* dialog = CFindItemDialog::NewL( iEditor->Text()->Read(0), aCase ); |
ed599363c2d7
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
418 |
dialog->EnableSingleClick( ETrue ); |
ed599363c2d7
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
419 |
TInt ret = dialog->ExecuteLD(); |
ed599363c2d7
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
420 |
TBuf<128> test = _L("FI returned: "); |
ed599363c2d7
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
421 |
test.AppendNum(ret); |
ed599363c2d7
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
422 |
iEikonEnv->InfoMsg(test); |
ed599363c2d7
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
423 |
return ret; |
66 | 424 |
} |
425 |
||
426 |
// End of File |