04cc0c7db55af49b7c8cf41e70cce58846cc5c89
[p5sagit/p5-mst-13.2.git] / symbian / PerlApp.h
1 /* Copyright (c) 2004-2005 Nokia. All rights reserved. */
2
3 /* The PerlApp application is licensed under the same terms as Perl itself. */
4
5 #ifndef __PerlApp_h__
6 #define __PerlApp_h__
7
8 #ifdef __SERIES60__
9 # include <aknapp.h>
10 # include <aknappui.h>
11 # include <akndoc.h>
12 #endif /* #ifdef __SERIES60__ */
13
14 #ifdef __SERIES80__
15 # include <eikapp.h>
16 # include <eikappui.h>
17 # include <eikdoc.h>
18 # include <eikbctrl.h>
19 # include <eikgted.h>
20 #endif /* #ifdef __SERIES60__ */
21
22 #include <coecntrl.h>
23 #include <f32file.h>
24
25 /* The source code can be compiled into "PerlApp" which is the simple
26  * launchpad application/demonstrator, or into "PerlMin", which is the
27  * minimal Perl launchpad application.  Define the cpp symbols
28  * PerlMin (a boolean), PerlMinUid (the Symbian application uid in
29  * the 0x... format), and PerlMinName (a C wide string, with the L prefix)
30  * to compile as "PerlMin". */
31
32 #define PerlMinSample
33
34 #ifdef PerlMinSample
35 # define PerlMin
36 # define PerlMinUid 0x102015F6
37 # define PerlMinName L"PerlMin"
38 #endif
39
40 #ifdef PerlMin
41 # ifndef PerlMinUid
42 #   error PerlMin defined but PerlMinUid undefined
43 # endif
44 # ifndef PerlMinName
45 #  error PerlMin defined but PerlMinName undefined
46 # endif
47 #endif
48
49 #ifdef __SERIES60__
50 # define CMyDocument    CAknDocument
51 # define CMyApplication CAknApplication
52 # define CMyAppUi       CAknAppUi
53 # define CMyNoteDialog  CAknNoteDialog
54 # define CMyAppView     CCoeControl
55 #endif /* #ifdef __SERIES60__ */
56
57 #ifdef __SERIES80__
58 # define CMyDocument    CEikDocument
59 # define CMyApplication CEikApplication
60 # define CMyAppUi       CEikAppUi
61 # define CMyNoteDialog  CCknFlashingDialog
62 # define CMyAppView     CEikBorderedControl
63 #endif /* #ifdef __SERIES60__ */
64
65 class CPerlAppDocument : public CMyDocument
66 {
67   public:
68     CPerlAppDocument(CEikApplication& aApp):CMyDocument(aApp) {;}
69 #ifndef PerlMin
70     CFileStore* OpenFileL(TBool aDoOpen, const TDesC& aFilename, RFs& aFs);
71 #endif // #ifndef PerlMin
72   private: // from CEikDocument
73     CEikAppUi* CreateAppUiL();
74 };
75
76 class CPerlAppApplication : public CMyApplication
77 {
78   private:
79     CApaDocument* CreateDocumentL();
80     TUid AppDllUid() const;
81 };
82
83 const TUint KPerlAppPromptSize   = 20;
84 const TUint KPerlAppOneLinerSize = 128;
85
86 class CPerlAppView;
87
88 class CPerlAppUi : public CMyAppUi
89 {
90   public:
91     void ConstructL();
92      ~CPerlAppUi();
93     TBool ProcessCommandParametersL(TApaCommand aCommand, TFileName& aDocumentName, const TDesC8& aTail);
94     void HandleCommandL(TInt aCommand);
95 #ifndef PerlMin
96     void OpenFileL(const TDesC& aFileName);
97     void InstallOrRunL(const TFileName& aFileName);
98     void SetFs(const RFs& aFs);
99 #endif // #ifndef PerlMin
100     TBuf<KPerlAppOneLinerSize> iOneLiner; // Perl source code to evaluate.
101     CPerlAppView* iAppView;
102   private:
103     RFs* iFs;
104 };
105
106 class CPerlAppView : public CMyAppView
107 {
108   public:
109     static CPerlAppView* NewL(const TRect& aRect);
110     static CPerlAppView* NewLC(const TRect& aRect);
111     ~CPerlAppView();
112     void Draw(const TRect& aRect) const;
113 #ifdef __SERIES80__
114     void HandleCommandL(TInt aCommand);
115 #endif /* #ifdef __SERIES80__ */
116   private:
117     void ConstructL(const TRect& aRect);
118 };
119
120 #endif // __PerlApp_h__