Symbian: better Series 80 support
[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 # include <eikdialg.h>
21 #endif /* #ifdef __SERIES60__ */
22
23 #include <coecntrl.h>
24 #include <f32file.h>
25
26 /* The source code can be compiled into "PerlApp" which is the simple
27  * launchpad application/demonstrator, or into "PerlAppMinimal", which
28  * is the minimal Perl launchpad application.  Define the cpp symbols
29  * CreatePerlAppMinimal (a boolean), PerlAppMinimalUid (the Symbian
30  * application uid in the 0x... format), and PerlAppMinimalName (a C
31  * wide string, with the L prefix) to compile as "PerlAppMinimal". */
32
33 // #define CreatePerlAppMinimal
34
35 #ifdef CreatePerlAppMinimal
36 # define PerlAppMinimal
37 # ifndef PerlAppMinimalUid // PerlApp is ...F6, PerlRecog is ...F7
38 #  define PerlAppMinimalUid 0x102015F8
39 # endif
40 # ifndef PerlAppMinimalName
41 #  define PerlAppMinimalName L"PerlAppMinimal"
42 # endif
43 #endif
44
45 #ifdef PerlAppMinimal
46 # ifndef PerlAppMinimalUid
47 #   error PerlAppMinimal defined but PerlAppMinimalUid undefined
48 # endif
49 # ifndef PerlAppMinimalName
50 #  error PerlAppMinimal defined but PerlAppMinimalName undefined
51 # endif
52 #endif
53
54 #ifdef __SERIES60__
55 # define CMyDocument    CAknDocument
56 # define CMyApplication CAknApplication
57 # define CMyAppUi       CAknAppUi
58 # define CMyNoteDialog  CAknNoteDialog
59 # define CMyAppView     CCoeControl
60 #endif /* #ifdef __SERIES60__ */
61
62 #ifdef __SERIES80__
63 # define CMyDocument    CEikDocument
64 # define CMyApplication CEikApplication
65 # define CMyAppUi       CEikAppUi
66 # define CMyNoteDialog  CCknFlashingDialog
67 # define CMyAppView     CEikBorderedControl
68 #endif /* #ifdef __SERIES60__ */
69
70 class CPerlAppDocument : public CMyDocument
71 {
72   public:
73     CPerlAppDocument(CEikApplication& aApp):CMyDocument(aApp) {;}
74 #ifndef PerlAppMinimal
75     CFileStore* OpenFileL(TBool aDoOpen, const TDesC& aFilename, RFs& aFs);
76 #endif // #ifndef PerlAppMinimal
77   private: // from CEikDocument
78     CEikAppUi* CreateAppUiL();
79 };
80
81 class CPerlAppApplication : public CMyApplication
82 {
83   private:
84     CApaDocument* CreateDocumentL();
85     TUid AppDllUid() const;
86 };
87
88 const TUint KPerlAppPromptSize   = 20;
89 const TUint KPerlAppOneLinerSize = 128;
90
91 class CPerlAppView;
92
93 class CPerlAppUi : public CMyAppUi
94 {
95   public:
96     void ConstructL();
97      ~CPerlAppUi();
98     TBool ProcessCommandParametersL(TApaCommand aCommand, TFileName& aDocumentName, const TDesC8& aTail);
99     void HandleCommandL(TInt aCommand);
100 #ifndef PerlAppMinimal
101     void OpenFileL(const TDesC& aFileName);
102     void InstallOrRunL(const TFileName& aFileName);
103     void SetFs(const RFs& aFs);
104 #endif // #ifndef PerlAppMinimal
105     TBuf<KPerlAppOneLinerSize> iOneLiner; // Perl source code to evaluate.
106     CPerlAppView* iAppView;
107   private:
108     RFs* iFs;
109 };
110
111 class CPerlAppView : public CMyAppView
112 {
113   public:
114     static CPerlAppView* NewL(const TRect& aRect);
115     static CPerlAppView* NewLC(const TRect& aRect);
116     ~CPerlAppView();
117     void Draw(const TRect& aRect) const;
118 #ifdef __SERIES80__
119     void HandleCommandL(TInt aCommand);
120 #endif /* #ifdef __SERIES80__ */
121   private:
122     void ConstructL(const TRect& aRect);
123 };
124
125 #ifdef __SERIES80__
126
127 class CPerlAppTextQueryDialog : public CEikDialog
128 {
129   public:
130     CPerlAppTextQueryDialog(HBufC*& aBuffer);
131     /* TODO: OfferKeyEventL() so that newline can be seen as 'OK'. */
132     HBufC*& iData;
133     TPtrC iTitle;  // used in S80 but not in S60
134     TPtrC iPrompt; // used in S60 and S80
135     TInt iMaxLength;
136   protected:
137     void PreLayoutDynInitL();
138   private:
139     TBool OkToExitL(TInt aKeycode);
140 };
141
142 #endif /* #ifdef __SERIES80__ */
143
144 #endif // __PerlApp_h__