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 #define wxEMULATOR_VERSION 0.1
17 // Information about the emulator decorations
18 class wxEmulatorInfo
: public wxObject
22 wxEmulatorInfo() { Init(); }
23 wxEmulatorInfo(const wxEmulatorInfo
& info
) : wxObject() { Init(); Copy(info
); }
25 void operator= (const wxEmulatorInfo
& info
) { Copy(info
); }
26 void Copy(const wxEmulatorInfo
& info
);
32 bool Load(const wxString
& appDir
);
34 // Emulator config filename
35 wxString m_emulatorFilename
;
38 wxString m_emulatorTitle
;
40 // Emulator description
41 wxString m_emulatorDescription
;
43 // The offset from the top-left of the main emulator
44 // bitmap and the virtual screen (where Xnest is
46 wxPoint m_emulatorScreenPosition
;
48 // The emulated screen size, e.g. 320x240
49 wxSize m_emulatorScreenSize
;
51 // The emulated device size. This is ignored
52 // if there is a background bitmap
53 wxSize m_emulatorDeviceSize
;
55 // The bitmap used for drawing the main emulator
57 wxBitmap m_emulatorBackgroundBitmap
;
58 wxString m_emulatorBackgroundBitmapName
;
60 // The intended background colour (for filling in
61 // areas of the window not covered by the bitmap)
62 wxColour m_emulatorBackgroundColour
;
64 // TODO: an array of bitmaps and ids for custom buttons
68 class wxEmulatorContainer
;
69 class wxEmulatorApp
: public wxApp
73 virtual bool OnInit();
75 // Load the specified emulator
76 bool LoadEmulator(const wxString
& appDir
);
79 wxString
GetAppDir() const { return m_appDir
; }
81 // Prepend the current app program directory to the name
82 wxString
GetFullAppPath(const wxString
& filename
) const;
86 wxEmulatorInfo m_emulatorInfo
;
88 wxAdoptedWindow
* m_xnestWindow
;
90 wxWindow
* m_xnestWindow
;
92 wxEmulatorContainer
* m_containerWindow
;
94 wxString m_displayNumber
;
98 // The container for the Xnest window. The decorations
99 // will be drawn on this window.
100 class wxEmulatorContainer
: public wxWindow
104 wxEmulatorContainer(wxWindow
* parent
, wxWindowID id
);
108 void OnSize(wxSizeEvent
& event
);
109 void OnPaint(wxPaintEvent
& event
);
110 void OnEraseBackground(wxEraseEvent
& event
);
112 DECLARE_CLASS(wxEmulatorContainer
)
113 DECLARE_EVENT_TABLE()
118 class wxEmulatorFrame
: public wxFrame
122 wxEmulatorFrame(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
);
125 void OnQuit(wxCommandEvent
& event
);
126 void OnAbout(wxCommandEvent
& event
);
127 void OnCloseWindow(wxCloseEvent
& event
);
130 // any class wishing to process wxWidgets events must use this macro
131 DECLARE_EVENT_TABLE()
134 // ----------------------------------------------------------------------------
136 // ----------------------------------------------------------------------------
138 // IDs for the controls and the menu commands
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
150 // Returns the image type, or -1, determined from the extension.
151 wxBitmapType
wxDetermineImageType(const wxString
& filename
);
153 // Convert a colour to a 6-digit hex string
154 wxString
wxColourToHexString(const wxColour
& col
);
156 // Convert 6-digit hex string to a colour
157 wxColour
wxHexStringToColour(const wxString
& hex
);
159 // Find the absolute path where this application has been run from.
160 wxString
wxFindAppPath(const wxString
& argv0
, const wxString
& cwd
, const wxString
& appVariableName
);