#include "wx/confbase.h"
#include "wx/fileconf.h"
#include "wx/cmdline.h"
+#include "wx/image.h"
#ifdef __WXX11__
#include "wx/x11/reparent.h"
BEGIN_EVENT_TABLE(wxEmulatorFrame, wxFrame)
EVT_MENU(Emulator_Quit, wxEmulatorFrame::OnQuit)
EVT_MENU(Emulator_About, wxEmulatorFrame::OnAbout)
+ EVT_CLOSE(wxEmulatorFrame::OnCloseWindow)
END_EVENT_TABLE()
// Create a new application object: this macro will allow wxWindows to create
m_xnestWindow = NULL;
m_containerWindow = NULL;
m_displayNumber = wxT("100");
+ m_xnestPID = 0;
+
}
// 'Main program' equivalent: the program execution "starts" here
bool wxEmulatorApp::OnInit()
{
+ wxLog::SetTimestamp(NULL);
wxInitAllImageHandlers();
wxString currentDir = wxGetCwd();
m_xnestWindow = new wxAdoptedWindow;
wxString cmd;
- cmd.Printf(wxT("Xnest %s -geometry %dx%d"),
+ cmd.Printf(wxT("Xnest :%s -geometry %dx%d"),
m_displayNumber.c_str(),
(int) m_emulatorInfo.m_emulatorScreenSize.x,
(int) m_emulatorInfo.m_emulatorScreenSize.y);
- // Asynchronously executes Xnest
- if (0 == wxExecute(cmd))
+ // Asynchronously executes Xnest
+ m_xnestPID = wxExecute(cmd);
+ if (0 == m_xnestPID)
{
frame->Destroy();
wxMessageBox(wxT("Sorry, could not run Xnest. Please check your PATH."));
wxMessageBox(msg, _T("About wxEmulator"), wxOK | wxICON_INFORMATION, this);
}
+void wxEmulatorFrame::OnCloseWindow(wxCloseEvent& event)
+{
+#ifdef __WXX11__
+ if (wxGetApp().m_xnestWindow)
+ {
+ wxGetApp().m_xnestWindow->SetHandle((WXWindow) NULL);
+ }
+#endif
+ this->Destroy();
+ if (wxGetApp().m_xnestPID > 0)
+ {
+ wxKill(wxGetApp().m_xnestPID);
+ wxGetApp().m_xnestPID = 0;
+ }
+}
+
IMPLEMENT_CLASS(wxEmulatorContainer, wxWindow)
BEGIN_EVENT_TABLE(wxEmulatorContainer, wxWindow)
void wxEmulatorContainer::DoResize()
{
wxSize sz = GetClientSize();
- if (wxGetApp().m_xnestWindow)
+ if (wxGetApp().m_xnestWindow
+#ifdef __WXX11__
+ && wxGetApp().m_xnestWindow->GetMainWindow()
+#endif
+ )
{
int deviceWidth = wxGetApp().m_emulatorInfo.m_emulatorDeviceSize.x;
int deviceHeight = wxGetApp().m_emulatorInfo.m_emulatorDeviceSize.y;
return FALSE;
}
- int type = wxDetermineImageType(m_emulatorBackgroundBitmapName);
- if (type == -1)
+ wxBitmapType type = wxDetermineImageType(m_emulatorBackgroundBitmapName);
+ if (type == wxBITMAP_TYPE_INVALID)
return FALSE;
if (!m_emulatorBackgroundBitmap.LoadFile(m_emulatorBackgroundBitmapName, type))
}
// Returns the image type, or -1, determined from the extension.
-int wxDetermineImageType(const wxString& filename)
+wxBitmapType wxDetermineImageType(const wxString& filename)
{
wxString path, name, ext;
ext.MakeLower();
if (ext == "jpg" || ext == "jpeg")
return wxBITMAP_TYPE_JPEG;
- else if (ext == "gif")
+ if (ext == "gif")
return wxBITMAP_TYPE_GIF;
- else if (ext == "bmp")
+ if (ext == "bmp")
return wxBITMAP_TYPE_BMP;
- else if (ext == "png")
+ if (ext == "png")
return wxBITMAP_TYPE_PNG;
- else if (ext == "pcx")
+ if (ext == "pcx")
return wxBITMAP_TYPE_PCX;
- else if (ext == "tif" || ext == "tiff")
+ if (ext == "tif" || ext == "tiff")
return wxBITMAP_TYPE_TIF;
- else
- return -1;
+
+ return wxBITMAP_TYPE_INVALID;
}
// Convert a colour to a 6-digit hex string
{
// Is it a relative path?
wxString currentDir(cwd);
- if (currentDir.Last() != wxFILE_SEP_PATH)
+ if (!wxEndsWithPathSeparator(currentDir))
currentDir += wxFILE_SEP_PATH;
str = currentDir + argv0;