|
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 Viewer Application UI class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <coeutils.h> |
|
21 #include <apparc.h> |
|
22 #include <avkon.hrh> |
|
23 #include <NpdApi.h> |
|
24 #include "NpdViewerAppUi.h" |
|
25 #include "NpdViewerDialog.h" |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CNotepadViewerAppUi::ConstructL |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 void CNotepadViewerAppUi::ConstructL() |
|
34 { |
|
35 iCurrentFileOpened = EFalse; |
|
36 BaseConstructL(EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible); |
|
37 iApi = CNotepadApi::NewL(); // AddResouceFile NpdLib.rsc |
|
38 iApi->CreateViewerDialogL(EFalse); // create non-wait viewerdialog |
|
39 iApi->Dialog()->SetMopParent(this); |
|
40 STATIC_CAST(CNotepadViewerDialog*, iApi->Dialog())->ExecuteLD(); //non-wait |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CNotepadViewerAppUi::~CNotepadViewerAppUi |
|
45 // Destructor. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CNotepadViewerAppUi::~CNotepadViewerAppUi() |
|
49 { |
|
50 delete iApi; // Release Resource, delete dialog |
|
51 if ( iDoorObserver ) |
|
52 { |
|
53 iDoorObserver->NotifyExit(MApaEmbeddedDocObserver::EEmpty); |
|
54 } |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CNotepadViewerAppUi::HandleCommandL |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CNotepadViewerAppUi::HandleCommandL(TInt aCommand) |
|
62 { |
|
63 switch ( aCommand ) |
|
64 { |
|
65 case EEikCmdExit: |
|
66 { |
|
67 Exit(); |
|
68 } |
|
69 break; |
|
70 default: |
|
71 break; |
|
72 } |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CNotepadViewerAppUi::ProcessCommandParametersL |
|
77 // From CEikAppUi |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 TBool CNotepadViewerAppUi::ProcessCommandParametersL( |
|
81 TApaCommand /*aCommand*/, |
|
82 TFileName& aDocumentName, |
|
83 const TDesC8& /*aTail*/ ) |
|
84 { |
|
85 // never call CEikAppUi::ProcessCommandParametersL(..) because |
|
86 // it is so harmfull to overwrite and destroy aDocumentName. |
|
87 // |
|
88 return ConeUtils::FileExists(aDocumentName); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CNotepadViewerAppUi::OpenFileL |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CNotepadViewerAppUi::OpenFileL(const TDesC& aFilename) |
|
96 { |
|
97 if( !iCurrentFileOpened ) |
|
98 { |
|
99 iCurrentFileOpened = ETrue; |
|
100 STATIC_CAST(CNotepadViewerDialog*, iApi->Dialog())->OpenFileL( |
|
101 aFilename, NULL, ETrue ); // auto-detect encoding |
|
102 } |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CNotepadViewerAppUi::OpenFileL(RFile& aFile) |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CNotepadViewerAppUi::OpenFileL(RFile& aFile) |
|
110 { |
|
111 if( !iCurrentFileOpened ) |
|
112 { |
|
113 iCurrentFileOpened = ETrue; |
|
114 STATIC_CAST(CNotepadViewerDialog*, iApi->Dialog())->OpenFileL( |
|
115 aFile, NULL, ETrue ); // auto-detect encoding |
|
116 } |
|
117 } |
|
118 |
|
119 // End of File |