// Loads bitmaps bool wxEmulatorInfo::Load(const wxString& appDir) { // Try to find absolute path wxString absoluteConfigPath = m_emulatorFilename; if ( !::wxIsAbsolutePath(absoluteConfigPath) ) { wxString currDir = wxGetCwd(); absoluteConfigPath = currDir + wxString(wxFILE_SEP_PATH) + m_emulatorFilename; if ( !wxFile::Exists(absoluteConfigPath) ) { absoluteConfigPath = appDir + wxString(wxFILE_SEP_PATH) + m_emulatorFilename; } } if ( !wxFile::Exists(absoluteConfigPath) ) { wxString str; str.Printf( wxT("Could not find config file %s"), absoluteConfigPath.c_str() ); wxMessageBox(str); return false; } wxString rootPath = wxPathOnly(absoluteConfigPath); { wxFileConfig config(wxT("wxEmulator"), wxT("wxWidgets"), absoluteConfigPath, wxEmptyString, wxCONFIG_USE_LOCAL_FILE); config.Read(wxT("/General/title"), & m_emulatorTitle); config.Read(wxT("/General/description"), & m_emulatorDescription); config.Read(wxT("/General/backgroundBitmap"), & m_emulatorBackgroundBitmapName); wxString colString; if (config.Read(wxT("/General/backgroundColour"), & colString) || config.Read(wxT("/General/backgroundColor"), & colString) ) { m_emulatorBackgroundColour = wxHexStringToColour(colString); } int x = 0, y = 0, w = 0, h = 0, dw = 0, dh = 0; config.Read(wxT("/General/screenX"), & x); config.Read(wxT("/General/screenY"), & y); config.Read(wxT("/General/screenWidth"), & w); config.Read(wxT("/General/screenHeight"), & h); if (config.Read(wxT("/General/deviceWidth"), & dw) && config.Read(wxT("/General/deviceHeight"), & dh)) { m_emulatorDeviceSize = wxSize(dw, dh); } m_emulatorScreenPosition = wxPoint(x, y); m_emulatorScreenSize = wxSize(w, h); } if (!m_emulatorBackgroundBitmapName.empty()) { wxString absoluteBackgroundBitmapName = rootPath + wxString(wxFILE_SEP_PATH) + m_emulatorBackgroundBitmapName; if ( !wxFile::Exists(absoluteBackgroundBitmapName) ) { wxString str; str.Printf( wxT("Could not find bitmap %s"), absoluteBackgroundBitmapName.c_str() ); wxMessageBox(str); return false; } wxBitmapType type = wxDetermineImageType(m_emulatorBackgroundBitmapName); if (type == wxBITMAP_TYPE_INVALID) return false; if (!m_emulatorBackgroundBitmap.LoadFile(m_emulatorBackgroundBitmapName, type)) { wxString str; str.Printf( wxT("Could not load bitmap file %s"), m_emulatorBackgroundBitmapName.c_str() ); wxMessageBox(str); return false; } m_emulatorDeviceSize = wxSize(m_emulatorBackgroundBitmap.GetWidth(), m_emulatorBackgroundBitmap.GetHeight()); } return true; }
bool MyApp::ProcessCommandLine(MyFrame* frame) { bool success = TRUE; wxLogTextCtrl textLog(frame->m_logCtrl); wxLog* oldTarget = wxLog::SetActiveTarget(& textLog); Log(m_cmdLine); int retValue = m_parser.Parse(); if (retValue == -1) { // Help message m_parser.Usage(); success = FALSE; } else if (retValue > 0) { // Syntax error Log(wxT("Sorry, syntax error.")); success = FALSE; } else { if (m_parser.Found(wxT("h"))) { m_parser.Usage(); success = FALSE; } else { m_batchMode = m_parser.Found(wxT("b")); // command line OK. Find option values. if (!m_parser.Found(wxT("i"), & m_inputFilename)) { Log(wxT("You must supply an input filename.")); m_batchMode = FALSE; success = FALSE; } if (!m_parser.Found(wxT("o"), & m_outputFilename)) { Log(wxT("You must supply an output filename.")); m_batchMode = FALSE; success = FALSE; } if (!m_parser.Found(wxT("t"), & m_text)) { Log(wxT("You must supply some text to add.")); success = FALSE; m_batchMode = FALSE; } m_parser.Found(wxT("f"), & m_fontFaceName); m_parser.Found(wxT("p"), & m_fontPointSize); long x = 0, y = 0; m_parser.Found(wxT("x"), & x); m_parser.Found(wxT("y"), & y); m_textPosition = wxPoint(x, y); wxString colourStr; if (m_parser.Found(wxT("fcol"), & colourStr)) { m_textForegroundColour = wxHexStringToColour(colourStr); } if (m_parser.Found(wxT("bcol"), & colourStr)) { m_textBackgroundColour = wxHexStringToColour(colourStr); } m_parser.Found(wxT("m"), & m_scaleFactor); // Find switches m_verbose = m_parser.Found(wxT("v")); m_centre = m_parser.Found(wxT("c")); m_rightJustify = m_parser.Found(wxT("r")); m_antialias = m_parser.Found(wxT("a")); if (m_parser.Found(wxT("bo"))) m_fontWeight = wxBOLD; if (m_parser.Found(wxT("it"))) m_fontStyle = wxITALIC; } } if (success) { success = MakeSplash(); } wxLog::GetActiveTarget()->Flush(); wxLog::SetActiveTarget(oldTarget); return success; }