1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef FILEBROWSER_FILEVIEWERDLG_H |
|
20 #define FILEBROWSER_FILEVIEWERDLG_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <f32file.h> |
|
26 #include <AknDialog.h> |
|
27 #include <eiksbobs.h> |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CFileBrowserFileEditorViewControl; |
|
31 class CEikEdwin; |
|
32 class CParaFormat; |
|
33 class CEikScrollBarFrame; |
|
34 |
|
35 |
|
36 // CLASS DEFINITIONS |
|
37 |
|
38 class CFileBrowserFileEditorDlg : public CAknDialog |
|
39 { |
|
40 public: |
|
41 static CFileBrowserFileEditorDlg* NewL(const TDesC& aFileName, TInt aMode); |
|
42 virtual ~CFileBrowserFileEditorDlg(); |
|
43 |
|
44 private: // Constructors |
|
45 CFileBrowserFileEditorDlg(const TDesC& aFileName, TInt aMode); |
|
46 void ConstructL(); |
|
47 |
|
48 protected: // From CAknDialog |
|
49 void ProcessCommandL(TInt aCommandId); |
|
50 void PreLayoutDynInitL(); |
|
51 void PostLayoutDynInitL(); |
|
52 |
|
53 protected: // From CEikDialog |
|
54 void SetSizeAndPosition(const TSize& aSize); |
|
55 SEikControlInfo CreateCustomControlL(TInt aControlType); |
|
56 |
|
57 protected: // From MEikMenuObserver |
|
58 void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane); |
|
59 |
|
60 public: // New methods |
|
61 TBool RunDlgLD(); |
|
62 |
|
63 private: // New methods |
|
64 void OpenFileLC(RFile& aFile, const TDesC& aFileName); |
|
65 void LoadFileL(); |
|
66 void GetTextFileMode(RFile& aFile, TInt& aFileSize); |
|
67 HBufC16* ConvertBuf8ToBuf16L(HBufC8* aBuf8); |
|
68 HBufC8* ConvertBuf16ToBuf8L(HBufC16* aBuf16); |
|
69 void SaveEditorDataL(TBool aQueryNewName=EFalse); |
|
70 TBool IsHexChar(TInt aCh); |
|
71 |
|
72 private: // Data |
|
73 CFileBrowserFileEditorViewControl* iViewer; |
|
74 CEikEdwin* iTextEditor; |
|
75 CParaFormat* iEditorPF; |
|
76 TFileName iFileName; |
|
77 TInt iActiveMode; |
|
78 TInt iTextFormat; |
|
79 }; |
|
80 |
|
81 |
|
82 |
|
83 class CFileBrowserFileEditorViewControl : public CCoeControl, MEikScrollBarObserver |
|
84 { |
|
85 public: |
|
86 virtual ~CFileBrowserFileEditorViewControl(); |
|
87 |
|
88 public: // Constructors |
|
89 CFileBrowserFileEditorViewControl(); |
|
90 void ConstructL(); |
|
91 |
|
92 protected: // From CCoeControl |
|
93 void Draw(const TRect& aRect) const; |
|
94 TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType); |
|
95 TSize MinimumSize(); |
|
96 CCoeControl* ComponentControl(TInt aIndex) const; |
|
97 TInt CountComponentControls() const; |
|
98 void HandleResourceChange(TInt aType); |
|
99 TTypeUid::Ptr MopSupplyObject(TTypeUid aId); |
|
100 |
|
101 protected: // From MEikScrollBarObserver |
|
102 void HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType); |
|
103 |
|
104 public: // New methods |
|
105 void FormatAsTextL(HBufC16* aBuf=NULL); |
|
106 void FormatAsHexL(HBufC8* aBuf=NULL); |
|
107 |
|
108 private: // New methods |
|
109 void InitVariables(); |
|
110 void ResetVariables(TBool aResetData=ETrue); |
|
111 void UpdateScrollBarL(); |
|
112 |
|
113 private: // Data |
|
114 TInt iActiveMode; |
|
115 TRect iViewerRect; |
|
116 TInt iDrawingWidth; |
|
117 TInt iLeftDrawingPosition; |
|
118 TReal iX_factor; |
|
119 TReal iY_factor; |
|
120 TInt iNumberOfLinesFitsScreen; |
|
121 CEikScrollBarFrame* iScrollBarFrame; |
|
122 CFont* iFont; |
|
123 TInt iCurrentLine; |
|
124 TInt iTotalNumberOfLines; |
|
125 |
|
126 HBufC8* iHexesBuffer; |
|
127 TInt iHexGrougWidth; |
|
128 TInt iAmountOfHexesFitsHorizontally; |
|
129 |
|
130 HBufC16* iTextBuf; |
|
131 CArrayFix<TPtrC>* iWrappedTextArray; |
|
132 }; |
|
133 |
|
134 #endif |
|
135 |
|
136 // End of File |
|
137 |
|