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