1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxX11-based PDA emulator classes
4 // Author: Julian Smart
7 // Copyright: (c) wxWidgets team
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_EMULATOR_H_
12 #define _WX_EMULATOR_H_
14 #define wxEMULATOR_VERSION 0.1
16 // Information about the emulator decorations
17 class wxEmulatorInfo
: public wxObject
21 wxEmulatorInfo() { Init(); }
22 wxEmulatorInfo(const wxEmulatorInfo
& info
) : wxObject() { Init(); Copy(info
); }
24 void operator= (const wxEmulatorInfo
& info
) { Copy(info
); }
25 void Copy(const wxEmulatorInfo
& info
);
31 bool Load(const wxString
& appDir
);
33 // Emulator config filename
34 wxString m_emulatorFilename
;
37 wxString m_emulatorTitle
;
39 // Emulator description
40 wxString m_emulatorDescription
;
42 // The offset from the top-left of the main emulator
43 // bitmap and the virtual screen (where Xnest is
45 wxPoint m_emulatorScreenPosition
;
47 // The emulated screen size, e.g. 320x240
48 wxSize m_emulatorScreenSize
;
50 // The emulated device size. This is ignored
51 // if there is a background bitmap
52 wxSize m_emulatorDeviceSize
;
54 // The bitmap used for drawing the main emulator
56 wxBitmap m_emulatorBackgroundBitmap
;
57 wxString m_emulatorBackgroundBitmapName
;
59 // The intended background colour (for filling in
60 // areas of the window not covered by the bitmap)
61 wxColour m_emulatorBackgroundColour
;
63 // TODO: an array of bitmaps and ids for custom buttons
67 class wxEmulatorContainer
;
68 class wxEmulatorApp
: public wxApp
72 virtual bool OnInit();
74 // Load the specified emulator
75 bool LoadEmulator(const wxString
& appDir
);
78 wxString
GetAppDir() const { return m_appDir
; }
80 // Prepend the current app program directory to the name
81 wxString
GetFullAppPath(const wxString
& filename
) const;
85 wxEmulatorInfo m_emulatorInfo
;
87 wxAdoptedWindow
* m_xnestWindow
;
89 wxWindow
* m_xnestWindow
;
91 wxEmulatorContainer
* m_containerWindow
;
93 wxString m_displayNumber
;
97 // The container for the Xnest window. The decorations
98 // will be drawn on this window.
99 class wxEmulatorContainer
: public wxWindow
103 wxEmulatorContainer(wxWindow
* parent
, wxWindowID id
);
107 void OnSize(wxSizeEvent
& event
);
108 void OnPaint(wxPaintEvent
& event
);
109 void OnEraseBackground(wxEraseEvent
& event
);
111 DECLARE_CLASS(wxEmulatorContainer
)
112 DECLARE_EVENT_TABLE()
117 class wxEmulatorFrame
: public wxFrame
121 wxEmulatorFrame(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
);
124 void OnQuit(wxCommandEvent
& event
);
125 void OnAbout(wxCommandEvent
& event
);
126 void OnCloseWindow(wxCloseEvent
& event
);
129 // any class wishing to process wxWidgets events must use this macro
130 DECLARE_EVENT_TABLE()
133 // ----------------------------------------------------------------------------
135 // ----------------------------------------------------------------------------
137 // IDs for the controls and the menu commands
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
149 // Returns the image type, or -1, determined from the extension.
150 wxBitmapType
wxDetermineImageType(const wxString
& filename
);
152 // Convert a colour to a 6-digit hex string
153 wxString
wxColourToHexString(const wxColour
& col
);
155 // Convert 6-digit hex string to a colour
156 wxColour
wxHexStringToColour(const wxString
& hex
);
158 // Find the absolute path where this application has been run from.
159 wxString
wxFindAppPath(const wxString
& argv0
, const wxString
& cwd
, const wxString
& appVariableName
);