summaryrefslogtreecommitdiff
path: root/symbian/PerlApp.h
blob: 04cc0c7db55af49b7c8cf41e70cce58846cc5c89 (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
/* 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>
#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 "PerlMin", which is the
 * minimal Perl launchpad application.  Define the cpp symbols
 * PerlMin (a boolean), PerlMinUid (the Symbian application uid in
 * the 0x... format), and PerlMinName (a C wide string, with the L prefix)
 * to compile as "PerlMin". */

#define PerlMinSample

#ifdef PerlMinSample
# define PerlMin
# define PerlMinUid 0x102015F6
# define PerlMinName L"PerlMin"
#endif

#ifdef PerlMin
# ifndef PerlMinUid
#   error PerlMin defined but PerlMinUid undefined
# endif
# ifndef PerlMinName
#  error PerlMin defined but PerlMinName 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 PerlMin
    CFileStore* OpenFileL(TBool aDoOpen, const TDesC& aFilename, RFs& aFs);
#endif // #ifndef PerlMin
  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 PerlMin
    void OpenFileL(const TDesC& aFileName);
    void InstallOrRunL(const TFileName& aFileName);
    void SetFs(const RFs& aFs);
#endif // #ifndef PerlMin
    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);
};

#endif // __PerlApp_h__