]>
Commit | Line | Data |
---|---|---|
3373d6bf JS |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: emulator.h | |
3 | // Purpose: wxX11-based PDA emulator classes | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 2002-03-10 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) wxWindows team | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_EMULATOR_H_ | |
13 | #define _WX_EMULATOR_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "emulator.h" | |
17 | #endif | |
18 | ||
d1b327e1 JS |
19 | #define wxEMULATOR_VERSION 0.1 |
20 | ||
3373d6bf JS |
21 | // Information about the emulator decorations |
22 | class wxEmulatorInfo: public wxObject | |
23 | { | |
24 | public: | |
25 | ||
26 | wxEmulatorInfo() { Init(); } | |
27 | wxEmulatorInfo(const wxEmulatorInfo& info) { Init(); Copy(info); } | |
28 | ||
29 | void operator= (const wxEmulatorInfo& info) { Copy(info); } | |
30 | void Copy(const wxEmulatorInfo& info); | |
31 | ||
32 | // Initialisation | |
33 | void Init(); | |
34 | ||
35 | // Loads bitmaps | |
d1b327e1 JS |
36 | bool Load(const wxString& appDir); |
37 | ||
38 | // Emulator config filename | |
39 | wxString m_emulatorFilename; | |
3373d6bf JS |
40 | |
41 | // Emulator title | |
42 | wxString m_emulatorTitle; | |
43 | ||
44 | // Emulator description | |
45 | wxString m_emulatorDescription; | |
46 | ||
47 | // The offset from the top-left of the main emulator | |
48 | // bitmap and the virtual screen (where Xnest is | |
49 | // positioned) | |
50 | wxPoint m_emulatorScreenPosition; | |
51 | ||
52 | // The emulated screen size, e.g. 320x240 | |
53 | wxSize m_emulatorScreenSize; | |
54 | ||
d1b327e1 JS |
55 | // The emulated device size. This is ignored |
56 | // if there is a background bitmap | |
57 | wxSize m_emulatorDeviceSize; | |
58 | ||
3373d6bf JS |
59 | // The bitmap used for drawing the main emulator |
60 | // decorations | |
61 | wxBitmap m_emulatorBackgroundBitmap; | |
62 | wxString m_emulatorBackgroundBitmapName; | |
63 | ||
64 | // The intended background colour (for filling in | |
65 | // areas of the window not covered by the bitmap) | |
66 | wxColour m_emulatorBackgroundColour; | |
67 | ||
68 | // TODO: an array of bitmaps and ids for custom buttons | |
69 | }; | |
70 | ||
71 | // Emulator app class | |
72 | class wxEmulatorContainer; | |
73 | class wxEmulatorApp : public wxApp | |
74 | { | |
75 | public: | |
76 | wxEmulatorApp(); | |
77 | virtual bool OnInit(); | |
78 | ||
79 | // Load the specified emulator | |
d1b327e1 JS |
80 | bool LoadEmulator(const wxString& appDir); |
81 | ||
82 | // Get app dir | |
83 | wxString GetAppDir() const { return m_appDir; } | |
84 | ||
85 | // Prepend the current app program directory to the name | |
86 | wxString GetFullAppPath(const wxString& filename) const; | |
3373d6bf JS |
87 | |
88 | public: | |
d1b327e1 | 89 | |
3373d6bf JS |
90 | wxEmulatorInfo m_emulatorInfo; |
91 | #ifdef __WXX11__ | |
92 | wxAdoptedWindow* m_xnestWindow; | |
93 | #else | |
94 | wxWindow* m_xnestWindow; | |
95 | #endif | |
96 | wxEmulatorContainer* m_containerWindow; | |
d1b327e1 JS |
97 | wxString m_appDir; |
98 | wxString m_displayNumber; | |
3373d6bf JS |
99 | }; |
100 | ||
101 | // The container for the Xnest window. The decorations | |
102 | // will be drawn on this window. | |
103 | class wxEmulatorContainer: public wxWindow | |
104 | { | |
105 | public: | |
106 | ||
107 | wxEmulatorContainer(wxWindow* parent, wxWindowID id); | |
108 | ||
0470b382 JS |
109 | void DoResize(); |
110 | ||
3373d6bf JS |
111 | void OnSize(wxSizeEvent& event); |
112 | void OnPaint(wxPaintEvent& event); | |
113 | void OnEraseBackground(wxEraseEvent& event); | |
114 | ||
115 | DECLARE_CLASS(wxEmulatorContainer) | |
116 | DECLARE_EVENT_TABLE() | |
117 | ||
118 | }; | |
119 | ||
120 | // Frame class | |
121 | class wxEmulatorFrame : public wxFrame | |
122 | { | |
123 | public: | |
124 | // ctor(s) | |
125 | wxEmulatorFrame(const wxString& title, const wxPoint& pos, const wxSize& size); | |
126 | ||
127 | // event handlers (these functions should _not_ be virtual) | |
128 | void OnQuit(wxCommandEvent& event); | |
129 | void OnAbout(wxCommandEvent& event); | |
130 | ||
131 | private: | |
132 | // any class wishing to process wxWindows events must use this macro | |
133 | DECLARE_EVENT_TABLE() | |
134 | }; | |
135 | ||
136 | // ---------------------------------------------------------------------------- | |
137 | // constants | |
138 | // ---------------------------------------------------------------------------- | |
139 | ||
140 | // IDs for the controls and the menu commands | |
141 | enum | |
142 | { | |
143 | // menu items | |
144 | Emulator_Quit = 1, | |
145 | ||
146 | // it is important for the id corresponding to the "About" command to have | |
147 | // this standard value as otherwise it won't be handled properly under Mac | |
148 | // (where it is special and put into the "Apple" menu) | |
149 | Emulator_About = wxID_ABOUT | |
150 | }; | |
151 | ||
152 | // Returns the image type, or -1, determined from the extension. | |
153 | int wxDetermineImageType(const wxString& filename); | |
154 | ||
d1b327e1 JS |
155 | // Convert a colour to a 6-digit hex string |
156 | wxString wxColourToHexString(const wxColour& col); | |
157 | ||
158 | // Convert 6-digit hex string to a colour | |
159 | wxColour wxHexStringToColour(const wxString& hex); | |
160 | ||
161 | // Find the absolute path where this application has been run from. | |
162 | wxString wxFindAppPath(const wxString& argv0, const wxString& cwd, const wxString& appVariableName); | |
163 | ||
3373d6bf JS |
164 | #endif |
165 | // _WX_EMULATOR_H_ | |
166 |