Applied patch #827025 (Removes last warnings from emulator util); Cosmetic cleanup.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24553 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
#include "wx/cmdline.h"
|
#include "wx/cmdline.h"
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
|
|
||||||
#ifdef __WXX11__
|
#ifdef __WXX11__
|
||||||
#include "wx/x11/reparent.h"
|
#include "wx/x11/reparent.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ bool wxEmulatorApp::OnInit()
|
|||||||
|
|
||||||
// Use argv to get current app directory
|
// Use argv to get current app directory
|
||||||
m_appDir = wxFindAppPath(argv[0], currentDir, wxT("WXEMUDIR"));
|
m_appDir = wxFindAppPath(argv[0], currentDir, wxT("WXEMUDIR"));
|
||||||
|
|
||||||
// If the development version, go up a directory.
|
// If the development version, go up a directory.
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
if ((m_appDir.Right(5).CmpNoCase(_T("DEBUG")) == 0) ||
|
if ((m_appDir.Right(5).CmpNoCase(_T("DEBUG")) == 0) ||
|
||||||
@@ -138,7 +138,7 @@ bool wxEmulatorApp::OnInit()
|
|||||||
wxLog::SetActiveTarget(new wxLogStderr);
|
wxLog::SetActiveTarget(new wxLogStderr);
|
||||||
#endif
|
#endif
|
||||||
parser.Usage();
|
parser.Usage();
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
if (parser.Found(wxT("v")))
|
if (parser.Found(wxT("v")))
|
||||||
{
|
{
|
||||||
@@ -148,7 +148,7 @@ bool wxEmulatorApp::OnInit()
|
|||||||
wxString msg;
|
wxString msg;
|
||||||
msg.Printf(wxT("wxWindows PDA Emulator (c) Julian Smart, 2002 Version %.2f, %s"), wxEMULATOR_VERSION, __DATE__);
|
msg.Printf(wxT("wxWindows PDA Emulator (c) Julian Smart, 2002 Version %.2f, %s"), wxEMULATOR_VERSION, __DATE__);
|
||||||
wxLogMessage(msg);
|
wxLogMessage(msg);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
if (parser.Found(wxT("u"), & m_displayNumber))
|
if (parser.Found(wxT("u"), & m_displayNumber))
|
||||||
{
|
{
|
||||||
@@ -172,13 +172,13 @@ bool wxEmulatorApp::OnInit()
|
|||||||
if (!LoadEmulator(m_appDir))
|
if (!LoadEmulator(m_appDir))
|
||||||
{
|
{
|
||||||
//wxMessageBox(wxT("Sorry, could not load this emulator. Please check bitmaps are valid."));
|
//wxMessageBox(wxT("Sorry, could not load this emulator. Please check bitmaps are valid."));
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the main application window
|
// create the main application window
|
||||||
wxEmulatorFrame *frame = new wxEmulatorFrame(_T("wxEmulator"),
|
wxEmulatorFrame *frame = new wxEmulatorFrame(_T("wxEmulator"),
|
||||||
wxPoint(50, 50), wxSize(450, 340));
|
wxPoint(50, 50), wxSize(450, 340));
|
||||||
|
|
||||||
frame->SetStatusText(m_emulatorInfo.m_emulatorTitle, 0);
|
frame->SetStatusText(m_emulatorInfo.m_emulatorTitle, 0);
|
||||||
|
|
||||||
wxString sizeStr;
|
wxString sizeStr;
|
||||||
@@ -186,16 +186,16 @@ bool wxEmulatorApp::OnInit()
|
|||||||
(int) m_emulatorInfo.m_emulatorScreenSize.y);
|
(int) m_emulatorInfo.m_emulatorScreenSize.y);
|
||||||
frame->SetStatusText(sizeStr, 1);
|
frame->SetStatusText(sizeStr, 1);
|
||||||
|
|
||||||
m_containerWindow = new wxEmulatorContainer(frame, -1);
|
m_containerWindow = new wxEmulatorContainer(frame, wxID_ANY);
|
||||||
|
|
||||||
frame->SetClientSize(m_emulatorInfo.m_emulatorDeviceSize.x,
|
frame->SetClientSize(m_emulatorInfo.m_emulatorDeviceSize.x,
|
||||||
m_emulatorInfo.m_emulatorDeviceSize.y);
|
m_emulatorInfo.m_emulatorDeviceSize.y);
|
||||||
|
|
||||||
// and show it (the frames, unlike simple controls, are not shown when
|
// and show it (the frames, unlike simple controls, are not shown when
|
||||||
// created initially)
|
// created initially)
|
||||||
frame->Show(TRUE);
|
frame->Show(true);
|
||||||
|
|
||||||
#ifdef __WXX11__
|
#ifdef __WXX11__
|
||||||
m_xnestWindow = new wxAdoptedWindow;
|
m_xnestWindow = new wxAdoptedWindow;
|
||||||
|
|
||||||
wxString cmd;
|
wxString cmd;
|
||||||
@@ -210,24 +210,24 @@ bool wxEmulatorApp::OnInit()
|
|||||||
{
|
{
|
||||||
frame->Destroy();
|
frame->Destroy();
|
||||||
wxMessageBox(wxT("Sorry, could not run Xnest. Please check your PATH."));
|
wxMessageBox(wxT("Sorry, could not run Xnest. Please check your PATH."));
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxReparenter reparenter;
|
wxReparenter reparenter;
|
||||||
if (!reparenter.WaitAndReparent(m_containerWindow, m_xnestWindow, wxT("Xnest")))
|
if (!reparenter.WaitAndReparent(m_containerWindow, m_xnestWindow, wxT("Xnest")))
|
||||||
{
|
{
|
||||||
wxMessageBox(wxT("Sorry, could not reparent Xnest.."));
|
wxMessageBox(wxT("Sorry, could not reparent Xnest.."));
|
||||||
frame->Destroy();
|
frame->Destroy();
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
m_containerWindow->DoResize();
|
m_containerWindow->DoResize();
|
||||||
|
|
||||||
// success: wxApp::OnRun() will be called which will enter the main message
|
// success: wxApp::OnRun() will be called which will enter the main message
|
||||||
// loop and the application will run. If we returned FALSE here, the
|
// loop and the application will run. If we returned false here, the
|
||||||
// application would exit immediately.
|
// application would exit immediately.
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepend the current program directory to the name
|
// Prepend the current program directory to the name
|
||||||
@@ -241,7 +241,7 @@ wxString wxEmulatorApp::GetFullAppPath(const wxString& filename) const
|
|||||||
path += '\\';
|
path += '\\';
|
||||||
#endif
|
#endif
|
||||||
path += filename;
|
path += filename;
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,8 +259,9 @@ bool wxEmulatorApp::LoadEmulator(const wxString& appDir)
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// frame constructor
|
// frame constructor
|
||||||
wxEmulatorFrame::wxEmulatorFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
wxEmulatorFrame::wxEmulatorFrame(const wxString& title,
|
||||||
: wxFrame(NULL, -1, title, pos, size)
|
const wxPoint& pos, const wxSize& size)
|
||||||
|
: wxFrame(NULL, wxID_ANY, title, pos, size)
|
||||||
{
|
{
|
||||||
// set the frame icon
|
// set the frame icon
|
||||||
SetIcon(wxICON(emulator));
|
SetIcon(wxICON(emulator));
|
||||||
@@ -295,8 +296,8 @@ wxEmulatorFrame::wxEmulatorFrame(const wxString& title, const wxPoint& pos, cons
|
|||||||
|
|
||||||
void wxEmulatorFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
void wxEmulatorFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
// TRUE is to force the frame to close
|
// true is to force the frame to close
|
||||||
Close(TRUE);
|
Close(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxEmulatorFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
void wxEmulatorFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||||
@@ -352,13 +353,13 @@ void wxEmulatorContainer::DoResize()
|
|||||||
{
|
{
|
||||||
int deviceWidth = wxGetApp().m_emulatorInfo.m_emulatorDeviceSize.x;
|
int deviceWidth = wxGetApp().m_emulatorInfo.m_emulatorDeviceSize.x;
|
||||||
int deviceHeight = wxGetApp().m_emulatorInfo.m_emulatorDeviceSize.y;
|
int deviceHeight = wxGetApp().m_emulatorInfo.m_emulatorDeviceSize.y;
|
||||||
|
|
||||||
int x = wxMax(0, (int) ((sz.x - deviceWidth)/2.0));
|
int x = wxMax(0, (int) ((sz.x - deviceWidth)/2.0));
|
||||||
int y = wxMax(0, (int) ((sz.y - deviceHeight)/2.0));
|
int y = wxMax(0, (int) ((sz.y - deviceHeight)/2.0));
|
||||||
|
|
||||||
x += wxGetApp().m_emulatorInfo.m_emulatorScreenPosition.x;
|
x += wxGetApp().m_emulatorInfo.m_emulatorScreenPosition.x;
|
||||||
y += wxGetApp().m_emulatorInfo.m_emulatorScreenPosition.y;
|
y += wxGetApp().m_emulatorInfo.m_emulatorScreenPosition.y;
|
||||||
|
|
||||||
wxGetApp().m_xnestWindow->Move(x, y);
|
wxGetApp().m_xnestWindow->Move(x, y);
|
||||||
}
|
}
|
||||||
Refresh();
|
Refresh();
|
||||||
@@ -367,24 +368,24 @@ void wxEmulatorContainer::DoResize()
|
|||||||
void wxEmulatorContainer::OnPaint(wxPaintEvent& WXUNUSED(event))
|
void wxEmulatorContainer::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
|
|
||||||
wxSize sz = GetClientSize();
|
wxSize sz = GetClientSize();
|
||||||
if (wxGetApp().m_emulatorInfo.m_emulatorBackgroundBitmap.Ok())
|
if (wxGetApp().m_emulatorInfo.m_emulatorBackgroundBitmap.Ok())
|
||||||
{
|
{
|
||||||
int deviceWidth = wxGetApp().m_emulatorInfo.m_emulatorDeviceSize.x;
|
int deviceWidth = wxGetApp().m_emulatorInfo.m_emulatorDeviceSize.x;
|
||||||
int deviceHeight = wxGetApp().m_emulatorInfo.m_emulatorDeviceSize.y;
|
int deviceHeight = wxGetApp().m_emulatorInfo.m_emulatorDeviceSize.y;
|
||||||
|
|
||||||
int x = wxMax(0, (int) ((sz.x - deviceWidth)/2.0));
|
int x = wxMax(0, (int) ((sz.x - deviceWidth)/2.0));
|
||||||
int y = wxMax(0, (int) ((sz.y - deviceHeight)/2.0));
|
int y = wxMax(0, (int) ((sz.y - deviceHeight)/2.0));
|
||||||
|
|
||||||
dc.DrawBitmap(wxGetApp().m_emulatorInfo.m_emulatorBackgroundBitmap, x, y);
|
dc.DrawBitmap(wxGetApp().m_emulatorInfo.m_emulatorBackgroundBitmap, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxEmulatorContainer::OnEraseBackground(wxEraseEvent& event)
|
void wxEmulatorContainer::OnEraseBackground(wxEraseEvent& event)
|
||||||
{
|
{
|
||||||
wxDC* dc = NULL;
|
wxDC* dc wxDUMMY_INITIALIZE(NULL);
|
||||||
|
|
||||||
if (event.GetDC())
|
if (event.GetDC())
|
||||||
{
|
{
|
||||||
dc = event.GetDC();
|
dc = event.GetDC();
|
||||||
@@ -393,10 +394,10 @@ void wxEmulatorContainer::OnEraseBackground(wxEraseEvent& event)
|
|||||||
{
|
{
|
||||||
dc = new wxClientDC(this);
|
dc = new wxClientDC(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
dc->SetBackground(wxBrush(wxGetApp().m_emulatorInfo.m_emulatorBackgroundColour, wxSOLID));
|
dc->SetBackground(wxBrush(wxGetApp().m_emulatorInfo.m_emulatorBackgroundColour, wxSOLID));
|
||||||
dc->Clear();
|
dc->Clear();
|
||||||
|
|
||||||
if (!event.GetDC())
|
if (!event.GetDC())
|
||||||
delete dc;
|
delete dc;
|
||||||
}
|
}
|
||||||
@@ -428,21 +429,25 @@ bool wxEmulatorInfo::Load(const wxString& appDir)
|
|||||||
{
|
{
|
||||||
// Try to find absolute path
|
// Try to find absolute path
|
||||||
wxString absoluteConfigPath = m_emulatorFilename;
|
wxString absoluteConfigPath = m_emulatorFilename;
|
||||||
if (!wxIsAbsolutePath(absoluteConfigPath))
|
if ( !::wxIsAbsolutePath(absoluteConfigPath) )
|
||||||
{
|
{
|
||||||
wxString currDir = wxGetCwd();
|
wxString currDir = wxGetCwd();
|
||||||
absoluteConfigPath = currDir + wxString(wxFILE_SEP_PATH) + m_emulatorFilename;
|
absoluteConfigPath = currDir + wxString(wxFILE_SEP_PATH) + m_emulatorFilename;
|
||||||
if (!wxFileExists(absoluteConfigPath))
|
if ( !wxFile::Exists(absoluteConfigPath) )
|
||||||
{
|
{
|
||||||
absoluteConfigPath = appDir + wxString(wxFILE_SEP_PATH) + m_emulatorFilename;
|
absoluteConfigPath = appDir + wxString(wxFILE_SEP_PATH)
|
||||||
|
+ m_emulatorFilename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!wxFileExists(absoluteConfigPath))
|
|
||||||
|
if ( !wxFile::Exists(absoluteConfigPath) )
|
||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
str.Printf(wxT("Could not find config file %s"), absoluteConfigPath.c_str()),
|
str.Printf( wxT("Could not find config file %s"),
|
||||||
|
absoluteConfigPath.c_str() );
|
||||||
|
|
||||||
wxMessageBox(str);
|
wxMessageBox(str);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString rootPath = wxPathOnly(absoluteConfigPath);
|
wxString rootPath = wxPathOnly(absoluteConfigPath);
|
||||||
@@ -476,33 +481,36 @@ bool wxEmulatorInfo::Load(const wxString& appDir)
|
|||||||
m_emulatorScreenPosition = wxPoint(x, y);
|
m_emulatorScreenPosition = wxPoint(x, y);
|
||||||
m_emulatorScreenSize = wxSize(w, h);
|
m_emulatorScreenSize = wxSize(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_emulatorBackgroundBitmapName.IsEmpty())
|
if (!m_emulatorBackgroundBitmapName.IsEmpty())
|
||||||
{
|
{
|
||||||
wxString absoluteBackgroundBitmapName = rootPath + wxString(wxFILE_SEP_PATH) + m_emulatorBackgroundBitmapName;
|
wxString absoluteBackgroundBitmapName = rootPath + wxString(wxFILE_SEP_PATH) + m_emulatorBackgroundBitmapName;
|
||||||
if (!wxFileExists(absoluteBackgroundBitmapName))
|
if ( !wxFile::Exists(absoluteBackgroundBitmapName) )
|
||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
str.Printf(wxT("Could not find bitmap %s"), absoluteBackgroundBitmapName.c_str()),
|
str.Printf( wxT("Could not find bitmap %s"),
|
||||||
|
absoluteBackgroundBitmapName.c_str() );
|
||||||
wxMessageBox(str);
|
wxMessageBox(str);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmapType type = wxDetermineImageType(m_emulatorBackgroundBitmapName);
|
wxBitmapType type = wxDetermineImageType(m_emulatorBackgroundBitmapName);
|
||||||
if (type == wxBITMAP_TYPE_INVALID)
|
if (type == wxBITMAP_TYPE_INVALID)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!m_emulatorBackgroundBitmap.LoadFile(m_emulatorBackgroundBitmapName, type))
|
if (!m_emulatorBackgroundBitmap.LoadFile(m_emulatorBackgroundBitmapName, type))
|
||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
str.Printf(wxT("Could not load bitmap file %s"), m_emulatorBackgroundBitmapName.c_str()),
|
str.Printf( wxT("Could not load bitmap file %s"),
|
||||||
|
m_emulatorBackgroundBitmapName.c_str() );
|
||||||
wxMessageBox(str);
|
wxMessageBox(str);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_emulatorDeviceSize = wxSize(m_emulatorBackgroundBitmap.GetWidth(),
|
m_emulatorDeviceSize = wxSize(m_emulatorBackgroundBitmap.GetWidth(),
|
||||||
m_emulatorBackgroundBitmap.GetHeight());
|
m_emulatorBackgroundBitmap.GetHeight());
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the image type, or -1, determined from the extension.
|
// Returns the image type, or -1, determined from the extension.
|
||||||
@@ -525,7 +533,7 @@ wxBitmapType wxDetermineImageType(const wxString& filename)
|
|||||||
return wxBITMAP_TYPE_PCX;
|
return wxBITMAP_TYPE_PCX;
|
||||||
if (ext == _T("tif") || ext == _T("tiff"))
|
if (ext == _T("tif") || ext == _T("tiff"))
|
||||||
return wxBITMAP_TYPE_TIF;
|
return wxBITMAP_TYPE_TIF;
|
||||||
|
|
||||||
return wxBITMAP_TYPE_INVALID;
|
return wxBITMAP_TYPE_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,12 +552,9 @@ wxString wxColourToHexString(const wxColour& col)
|
|||||||
// Convert 6-digit hex string to a colour
|
// Convert 6-digit hex string to a colour
|
||||||
wxColour wxHexStringToColour(const wxString& hex)
|
wxColour wxHexStringToColour(const wxString& hex)
|
||||||
{
|
{
|
||||||
unsigned int r = 0;
|
unsigned int r = wxHexToDec(hex.Mid(0, 2));
|
||||||
unsigned int g = 0;
|
unsigned int g = wxHexToDec(hex.Mid(2, 2));
|
||||||
unsigned int b = 0;
|
unsigned int b = wxHexToDec(hex.Mid(4, 2));
|
||||||
r = wxHexToDec(hex.Mid(0, 2));
|
|
||||||
g = wxHexToDec(hex.Mid(2, 2));
|
|
||||||
b = wxHexToDec(hex.Mid(4, 2));
|
|
||||||
|
|
||||||
return wxColour(r, g, b);
|
return wxColour(r, g, b);
|
||||||
}
|
}
|
||||||
@@ -582,7 +587,7 @@ wxString wxFindAppPath(const wxString& argv0, const wxString& cwd, const wxStrin
|
|||||||
currentDir += wxFILE_SEP_PATH;
|
currentDir += wxFILE_SEP_PATH;
|
||||||
|
|
||||||
str = currentDir + argv0;
|
str = currentDir + argv0;
|
||||||
if (wxFileExists(str))
|
if ( wxFile::Exists(str) )
|
||||||
return wxPathOnly(str);
|
return wxPathOnly(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user