1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxX11-based PDA emulator classes
4 // Author: Julian Smart
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_EMULATOR_H_
13 #define _WX_EMULATOR_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "emulator.h"
19 #define wxEMULATOR_VERSION 0.1
21 // Information about the emulator decorations
22 class wxEmulatorInfo
: public wxObject
26 wxEmulatorInfo() { Init(); }
27 wxEmulatorInfo(const wxEmulatorInfo
& info
) : wxObject() { Init(); Copy(info
); }
29 void operator= (const wxEmulatorInfo
& info
) { Copy(info
); }
30 void Copy(const wxEmulatorInfo
& info
);
36 bool Load(const wxString
& appDir
);
38 // Emulator config filename
39 wxString m_emulatorFilename
;
42 wxString m_emulatorTitle
;
44 // Emulator description
45 wxString m_emulatorDescription
;
47 // The offset from the top-left of the main emulator
48 // bitmap and the virtual screen (where Xnest is
50 wxPoint m_emulatorScreenPosition
;
52 // The emulated screen size, e.g. 320x240
53 wxSize m_emulatorScreenSize
;
55 // The emulated device size. This is ignored
56 // if there is a background bitmap
57 wxSize m_emulatorDeviceSize
;
59 // The bitmap used for drawing the main emulator
61 wxBitmap m_emulatorBackgroundBitmap
;
62 wxString m_emulatorBackgroundBitmapName
;
64 // The intended background colour (for filling in
65 // areas of the window not covered by the bitmap)
66 wxColour m_emulatorBackgroundColour
;
68 // TODO: an array of bitmaps and ids for custom buttons
72 class wxEmulatorContainer
;
73 class wxEmulatorApp
: public wxApp
77 virtual bool OnInit();
79 // Load the specified emulator
80 bool LoadEmulator(const wxString
& appDir
);
83 wxString
GetAppDir() const { return m_appDir
; }
85 // Prepend the current app program directory to the name
86 wxString
GetFullAppPath(const wxString
& filename
) const;
90 wxEmulatorInfo m_emulatorInfo
;
92 wxAdoptedWindow
* m_xnestWindow
;
94 wxWindow
* m_xnestWindow
;
96 wxEmulatorContainer
* m_containerWindow
;
98 wxString m_displayNumber
;
102 // The container for the Xnest window. The decorations
103 // will be drawn on this window.
104 class wxEmulatorContainer
: public wxWindow
108 wxEmulatorContainer(wxWindow
* parent
, wxWindowID id
);
112 void OnSize(wxSizeEvent
& event
);
113 void OnPaint(wxPaintEvent
& event
);
114 void OnEraseBackground(wxEraseEvent
& event
);
116 DECLARE_CLASS(wxEmulatorContainer
)
117 DECLARE_EVENT_TABLE()
122 class wxEmulatorFrame
: public wxFrame
126 wxEmulatorFrame(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
);
129 void OnQuit(wxCommandEvent
& event
);
130 void OnAbout(wxCommandEvent
& event
);
131 void OnCloseWindow(wxCloseEvent
& event
);
134 // any class wishing to process wxWidgets events must use this macro
135 DECLARE_EVENT_TABLE()
138 // ----------------------------------------------------------------------------
140 // ----------------------------------------------------------------------------
142 // IDs for the controls and the menu commands
148 // it is important for the id corresponding to the "About" command to have
149 // this standard value as otherwise it won't be handled properly under Mac
150 // (where it is special and put into the "Apple" menu)
151 Emulator_About
= wxID_ABOUT
154 // Returns the image type, or -1, determined from the extension.
155 wxBitmapType
wxDetermineImageType(const wxString
& filename
);
157 // Convert a colour to a 6-digit hex string
158 wxString
wxColourToHexString(const wxColour
& col
);
160 // Convert 6-digit hex string to a colour
161 wxColour
wxHexStringToColour(const wxString
& hex
);
163 // Find the absolute path where this application has been run from.
164 wxString
wxFindAppPath(const wxString
& argv0
, const wxString
& cwd
, const wxString
& appVariableName
);