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