summaryrefslogtreecommitdiff
path: root/symbian/PerlApp.h
blob: 8782fa0db5aad6a85eb5fd079dd6b6b737e84d5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* Copyright (c) 2004-2005 Nokia. All rights reserved. */

/* The PerlApp application is licensed under the same terms as Perl itself. */

#ifndef __PerlApp_h__
#define __PerlApp_h__

#ifdef __SERIES60__
# include <aknapp.h>
# include <aknappui.h>
# include <akndoc.h>
#endif /* #ifdef __SERIES60__ */

#ifdef __SERIES80__
# include <eikapp.h>
# include <eikappui.h>
# include <eikdoc.h>
# include <eikbctrl.h>
# include <eikgted.h>
# include <eikdialg.h>
#endif /* #ifdef __SERIES60__ */

#include <coecntrl.h>
#include <f32file.h>

/* The source code can be compiled into "PerlApp" which is the simple
 * launchpad application/demonstrator, or into "PerlAppMinimal", which
 * is the minimal Perl launchpad application.  Define the cpp symbols
 * CreatePerlAppMinimal (a boolean), PerlAppMinimalUid (the Symbian
 * application uid in the 0x... format), and PerlAppMinimalName (a C
 * wide string, with the L prefix) to compile as "PerlAppMinimal". */

// #define CreatePerlAppMinimal

#ifdef CreatePerlAppMinimal
# define PerlAppMinimal
# ifndef PerlAppMinimalUid // PerlApp is ...F6, PerlRecog is ...F7
#  define PerlAppMinimalUid 0x102015F8
# endif
# ifndef PerlAppMinimalName
#  define PerlAppMinimalName L"PerlAppMinimal"
# endif
#endif

#ifdef PerlAppMinimal
# ifndef PerlAppMinimalUid
#   error PerlAppMinimal defined but PerlAppMinimalUid undefined
# endif
# ifndef PerlAppMinimalName
#  error PerlAppMinimal defined but PerlAppMinimalName undefined
# endif
#endif

#ifdef __SERIES60__
# define CMyDocument    CAknDocument
# define CMyApplication CAknApplication
# define CMyAppUi       CAknAppUi
# define CMyNoteDialog  CAknNoteDialog
# define CMyAppView     CCoeControl
#endif /* #ifdef __SERIES60__ */

#ifdef __SERIES80__
# define CMyDocument    CEikDocument
# define CMyApplication CEikApplication
# define CMyAppUi       CEikAppUi
# define CMyNoteDialog  CCknFlashingDialog
# define CMyAppView     CEikBorderedControl
#endif /* #ifdef __SERIES60__ */

class CPerlAppDocument : public CMyDocument
{
  public:
    CPerlAppDocument(CEikApplication& aApp):CMyDocument(aApp) {;}
#ifndef PerlAppMinimal
    CFileStore* OpenFileL(TBool aDoOpen, const TDesC& aFilename, RFs& aFs);
#endif // #ifndef PerlAppMinimal
  private: // from CEikDocument
    CEikAppUi* CreateAppUiL();
};

class CPerlAppApplication : public CMyApplication
{
  private:
    CApaDocument* CreateDocumentL();
    TUid AppDllUid() const;
};

const TUint KPerlAppPromptSize   = 20;
const TUint KPerlAppOneLinerSize = 128;

class CPerlAppView;

class CPerlAppUi : public CMyAppUi
{
  public:
    void ConstructL();
     ~CPerlAppUi();
    TBool ProcessCommandParametersL(TApaCommand aCommand, TFileName& aDocumentName, const TDesC8& aTail);
    void HandleCommandL(TInt aCommand);
#ifndef PerlAppMinimal
    void OpenFileL(const TDesC& aFileName);
    void InstallOrRunL(const TFileName& aFileName);
    void SetFs(const RFs& aFs);
#endif // #ifndef PerlAppMinimal
    TBuf<KPerlAppOneLinerSize> iOneLiner; // Perl source code to evaluate.
    CPerlAppView* iAppView;
  private:
    RFs* iFs;
};

class CPerlAppView : public CMyAppView
{
  public:
    static CPerlAppView* NewL(const TRect& aRect);
    static CPerlAppView* NewLC(const TRect& aRect);
    ~CPerlAppView();
    void Draw(const TRect& aRect) const;
#ifdef __SERIES80__
    void HandleCommandL(TInt aCommand);
#endif /* #ifdef __SERIES80__ */
  private:
    void ConstructL(const TRect& aRect);
};

#ifdef __SERIES80__

class CPerlAppTextQueryDialog : public CEikDialog
{
  public:
    CPerlAppTextQueryDialog(HBufC*& aBuffer);
    /* TODO: OfferKeyEventL() so that newline can be seen as 'OK'. */
    HBufC*& iData;
    TPtrC iTitle;  // used in S80 but not in S60
    TPtrC iPrompt; // used in S60 and S80
    TInt iMaxLength;
  protected:
    void PreLayoutDynInitL();
  private:
    TBool OkToExitL(TInt aKeycode);
};

#endif /* #ifdef __SERIES80__ */

#endif // __PerlApp_h__