void MainFrame::SaveImage() { cout<<"save image"<<endl; static unsigned int image_index=0; GLint l_ViewPort[4]; glGetIntegerv(GL_VIEWPORT, l_ViewPort); for (int i = 0; i != 4; ++i) l_ViewPort[i]-=l_ViewPort[i]%4; int width= (l_ViewPort[2] - l_ViewPort[0]); int height=(l_ViewPort[3] - l_ViewPort[1]); cout<<"l_Viewport[0] is "<<l_ViewPort[0]<<endl; cout<<"l_Viewport[1] is "<<l_ViewPort[1]<<endl; cout<<"l_Viewport[2] is "<<l_ViewPort[2]<<endl; cout<<"l_Viewport[3] is "<<l_ViewPort[3]<<endl; glReadBuffer(GL_BACK); glFinish(); glPixelStorei(GL_PACK_ALIGNMENT, 3); glPixelStorei(GL_PACK_ROW_LENGTH, 0); glPixelStorei(GL_PACK_SKIP_ROWS, 0); glPixelStorei(GL_PACK_SKIP_PIXELS, 0); unsigned char *glBitmapData = new unsigned char [3 * width * height]; unsigned char *glBitmapData_flip = new unsigned char [3 * width * height]; // glReadPixels((GLint)0, (GLint)0, (GLint)width, (GLint)height, GL_RGB, GL_BYTE, glBitmapData); glReadPixels((GLint)0, (GLint)0, (GLint)width, (GLint)height, GL_RGB, GL_UNSIGNED_BYTE, glBitmapData); for(int i=0;i<height;++i) memcpy(&glBitmapData_flip[3*i*width],&glBitmapData[3*(height-i-1)*width],3*width); //wxImage img (width, height, glBitmapData, true); wxImage img (width, height, glBitmapData_flip, true); cout<<"width is "<<width<<endl; cout<<"height is "<<height<<endl; wxInitAllImageHandlers(); //glReadPixels(l_ViewPort[0], l_ViewPort[1], l_ViewPort[2], l_ViewPort[3], // GL_RGB,GL_UNSIGNED_BYTE,(GLvoid*)&(pixels[0])); //wxImage img(width, height, &(pixels[0]),true); //img.Mirror(false); cout<<"outputed data"<<endl; stringstream file; file<<setfill('0'); // file<<path; // file<<savefolder; file<<"./"; file<<"Rendering"; file<<"/"; if(!bfs::exists(file.str().c_str())) { bfs::create_directory(file.str().c_str()); } file<<"render"<<setw(4)<< m_nCurrentFrame <<".png"; //file<<"out"<<setw(3)<<image_index++<<".bmp"; cout<<"saving as "<<file.str()<<endl; wxString mystring(file.str().c_str(),wxConvUTF8); cout<<"made mystring"<<endl; img.SaveFile(mystring,wxBITMAP_TYPE_PNG); //img.SaveFile(mystring,wxBITMAP_TYPE_BMP); cout<<"Saved"<<endl; // // Second method: delete [] glBitmapData; delete [] glBitmapData_flip; }
void ChessGLCanvas::Draw() { log->AppendText("-------\ndrawing the table..."); // clear the window and put in the background color glClearColor(bgR, bgG, bgB, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // draw the actual chess board squares DrawBoard(); // load a test image wxImage image; wxInitAllImageHandlers(); image.LoadFile("..\\..\\Images\\test.png"); // now convert rgb and a arrays into rgba array unsigned char *rgba_data; rgba_data = (unsigned char *) malloc(image.GetWidth()*image.GetHeight()*4); for(int n=0; n<image.GetWidth()*image.GetHeight(); n++) { rgba_data[4*n] = image.GetData()[3*n]; // red channel rgba_data[4*n+1] = image.GetData()[3*n+1]; // green channel rgba_data[4*n+2] = image.GetData()[3*n+2]; // blue channel rgba_data[4*n+3] = image.GetAlpha()[n]; // alpha channel } // come up with the places in GL to store the image data GLuint texture[1]; glGenTextures(1, texture); // sets aside some global integers that aren't in use by GL elsewhere for storing textures glBindTexture(GL_TEXTURE_2D, texture[0]); // until otherwise told, work with texture[0] // set up some parameters for handling this texture glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // linear interpolation of colors glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // linear interpolation of colors glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // if we want to learn lighting later // actually store the image data in the GL memory somewhere (can now delete the image object memory) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.GetWidth(), image.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, rgba_data); free(rgba_data); // draw one of the textures glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_QUADS); glTexCoord2f(0.0, 1.0); glVertex3f(0.5, 0.5, 0); // Bottom Left Of The Texture and Quad glTexCoord2f(1.0, 1.0); glVertex3f(1.5, 0.5, 0); // Bottom Right Of The Texture and Quad glTexCoord2f(1.0, 0.0); glVertex3f(1.5, 1.5, 0); // Top Right Of The Texture and Quad glTexCoord2f(0.0, 0.0); glVertex3f(0.5, 1.5, 0); // Top Left Of The Texture and Quad glEnd(); glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex3f(0, 0, 0); // Bottom Left Of The Texture and Quad glTexCoord2f(1, 1); glVertex3f(1, 0, 0); // Bottom Right Of The Texture and Quad glTexCoord2f(1, 0); glVertex3f(1, 1, 0); // Top Right Of The Texture and Quad glTexCoord2f(0, 0); glVertex3f(0, 1, 0); // Top Left Of The Texture and Quad glEnd(); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); // flush the GL buffer and then swap in a new one glFlush(); SwapBuffers(); }
//! @brief Initializes the application. //! //! It will open the main window and connect default to server or open the connect window. bool SpringLobbyApp::OnInit() { wxSetEnv( _T("UBUNTU_MENUPROXY"), _T("0") ); //this triggers the Cli Parser amongst other stuff if (!wxApp::OnInit()) return false; SetAppName( m_appname ); if (!m_crash_handle_disable) { #if wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions( true ); #endif #if defined(__WXMSW__) && defined(ENABLE_DEBUG_REPORT) //this undocumented function acts as a workaround for the dysfunctional // wxUSE_ON_FATAL_EXCEPTION on msw when mingw is used (or any other non SEH-capable compiler ) SetUnhandledExceptionFilter(filter); #endif } //initialize all loggers, we'll use the returned pointer to set correct parent window later wxLogChain* logchain = 0; wxLogWindow *loggerwin = InitializeLoggingTargets( 0, m_log_console, m_log_file_path, m_log_window_show, !m_crash_handle_disable, m_log_verbosity, logchain ); //this needs to called _before_ mainwindow instance is created wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxZipFSHandler); wxSocketBase::Initialize(); #ifdef __WXMSW__ wxString path = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + wxFileName::GetPathSeparator() + _T("locale"); #else #if defined(LOCALE_INSTALL_DIR) wxString path ( _T(LOCALE_INSTALL_DIR) ); #else // use a dummy name here, we're only interested in the base path wxString path = wxStandardPaths::Get().GetLocalizedResourcesDir(_T("noneWH"),wxStandardPaths::ResourceCat_Messages); path = path.Left( path.First(_T("noneWH") ) ); #endif #endif m_translationhelper = new wxTranslationHelper( *( (wxApp*)this ), path ); m_translationhelper->Load(); if ( !wxDirExists( GetConfigfileDir() ) ) wxMkdir( GetConfigfileDir() ); #ifdef __WXMSW__ sett().SetSearchSpringOnlyInSLPath( sett().GetSearchSpringOnlyInSLPath() ); #endif sett().SetSpringBinary( sett().GetCurrentUsedSpringIndex(), sett().GetCurrentUsedSpringBinary() ); sett().SetUnitSync( sett().GetCurrentUsedSpringIndex(), sett().GetCurrentUsedUnitSync() ); if ( sett().DoResetPerspectives() ) { //we do this early on and reset the config var a little later so we can save a def. perps once mw is created sett().RemoveLayouts(); sett().SetDoResetPerspectives( false ); ui().mw().SavePerspectives( _T("SpringLobby-default") ); } sett().RefreshSpringVersionList(); //this should take off the firstload time considerably *ie nil it :P ) mapSelectDialog(); if ( !m_customizer_archive_name.IsEmpty() ) {//this needsto happen before usync load sett().SetForcedSpringConfigFilePath( GetCustomizedEngineConfigFilePath() ); } //unitsync first load, NEEDS to be blocking const bool usync_loaded = usync().ReloadUnitSyncLib(); if ( !sett().IsFirstRun() && !usync_loaded ) { customMessageBox( SL_MAIN_ICON, _("Please check that the file given in Preferences->Spring is a proper, readable unitsync library"), _("Coulnd't load required unitsync library"), wxOK ); } #ifndef DISABLE_SOUND //sound sources/buffer init sound(); #endif CacheAndSettingsSetup(); if ( !m_customizer_archive_name.IsEmpty() ) { if ( SLcustomizations().Init( m_customizer_archive_name ) ) { ui().mw().SetIcons( SLcustomizations().GetAppIconBundle() ); } else { customMessageBox( SL_MAIN_ICON, _("Couldn't load customizations for ") + m_customizer_archive_name + _("\nPlease check that that is the correct name, passed in qoutation"), _("Fatal error"), wxOK ); // wxLogError( _("Couldn't load customizations for ") + m_customizer_archive_name + _("\nPlease check that that is the correct name, passed in qoutation"), _("Fatal error") ); exit( OnExit() );//for some twisted reason returning false here does not terminate the app } } notificationManager(); //needs to be initialized too ui().ShowMainWindow(); SetTopWindow( &ui().mw() ); if ( sett().DoResetPerspectives() ) { //now that mainwindow is shown, we can save what is the default layout and remove the flag to reset sett().SetDoResetPerspectives( false ); ui().mw().SavePerspectives( _T("SpringLobby-default") ); } //interim fix for resize crashes on metacity and kwin #ifdef __WXMSW__ mapSelectDialog().Reparent( &ui().mw() ); #endif ui().FirstRunWelcome(); m_timer->Start( TIMER_INTERVAL ); ui().mw().SetLogWin( loggerwin, logchain ); #ifndef NO_TORRENT_SYSTEM plasmaInterface(); // plasmaInterface().InitResourceList(); // plasmaInterface().FetchResourceList(); #endif return true; }
// App bool MultiMC::OnInit() { #if __WXGTK__ || defined MSVC // Only works with Linux GCC or MSVC wxHandleFatalExceptions(); #endif exitAction = EXIT_NORMAL; startMode = START_NORMAL; updateQuiet = false; useProvidedDir = false; // This is necessary for the update system since it calls OnInitCmdLine // to set up the command line arguments that the update system uses. if (!wxApp::OnInit()) return false; #if OSX { wxFileName mmcDir = wxFileName::DirName(wxStandardPaths::Get().GetResourcesDir()); mmcDir.Normalize(); if (!mmcDir.DirExists()) mmcDir.Mkdir(0777, wxPATH_MKDIR_FULL); wxSetWorkingDirectory(mmcDir.GetFullPath()); } #else if (!useProvidedDir) { wxFileName mmcDir (wxStandardPaths::Get().GetExecutablePath()); wxSetWorkingDirectory(mmcDir.GetPath()); } else { // do use provided directory wxSetWorkingDirectory(providedDir.GetFullPath()); } #endif if (!InitAppSettings()) { wxLogError(_("Failed to initialize settings.")); return false; } SetAppName(_("MultiMC")); InstallLangFiles(); localeHelper.UpdateLangList(); // Load language. long langID = wxLANGUAGE_UNKNOWN; if (settings->GetUseSystemLang()) langID = wxLocale::GetSystemLanguage(); else langID = settings->GetLanguageID(); langID = localeHelper.FindClosestMatch(langID); // If no matching language is found, use English. if (langID == wxLANGUAGE_UNKNOWN) { langID = wxLANGUAGE_ENGLISH_US; } if (!localeHelper.SetLanguage((wxLanguage)langID)) { localeHelper.SetLanguage(wxLANGUAGE_ENGLISH_US); wxLogError(_("Failed to set language. Language set to English.")); } wxString cwd = wxGetCwd(); if(cwd.Contains("!")) { wxLogError(_("MultiMC has been started from a path that contains '!':\n%s\nThis would break Minecraft. Please move it to a different place."), cwd.c_str()); return false; } wxInitAllImageHandlers(); wxSocketBase::Initialize(); wxMemoryInputStream iconInput16(multimc16, sizeof(multimc16)); wxMemoryInputStream iconInput32(multimc32, sizeof(multimc32)); wxMemoryInputStream iconInput64(multimc64, sizeof(multimc64)); wxMemoryInputStream iconInput128(multimc128, sizeof(multimc128)); wxIcon icon16,icon32,icon64,icon128; icon16.CopyFromBitmap(wxBitmap(wxImage(iconInput16))); icon32.CopyFromBitmap(wxBitmap(wxImage(iconInput32))); icon64.CopyFromBitmap(wxBitmap(wxImage(iconInput64))); icon128.CopyFromBitmap(wxBitmap(wxImage(iconInput128))); AppIcons.AddIcon(icon16); AppIcons.AddIcon(icon32); AppIcons.AddIcon(icon64); AppIcons.AddIcon(icon128); wxFileSystem::AddHandler(new wxArchiveFSHandler); // wxFileSystem::AddHandler(new wxMemoryFSHandler); if (!settings->GetInstDir().DirExists()) settings->GetInstDir().Mkdir(); if (!settings->GetModsDir().DirExists()) settings->GetModsDir().Mkdir(); if (!settings->GetLwjglDir().DirExists()) settings->GetLwjglDir().Mkdir(); switch (startMode) { case START_NORMAL: { MainWindow *mainWin = new MainWindow(); mainWin->SetName(wxT("MainWindow")); if (!wxPersistenceManager::Get().RegisterAndRestore(mainWin)) { mainWin->CenterOnScreen(); } SetTopWindow(mainWin); mainWin->Show(); mainWin->OnStartup(); return true; } case START_LAUNCH_INSTANCE: { MainWindow *mainWin = new MainWindow(); mainWin->SetName(wxT("MainWindow")); if (!wxPersistenceManager::Get().RegisterAndRestore(mainWin)) { mainWin->CenterOnScreen(); } SetTopWindow(mainWin); mainWin->launchInstance = launchInstance; mainWin->OnStartup(); mainWin->Hide(); return true; } case START_INSTALL_UPDATE: InstallUpdate(); return false; } return false; }
// `Main program' equivalent, creating windows and returning main app frame bool MyApp::OnInit() { #if wxUSE_IMAGE wxInitAllImageHandlers(); #endif m_canvasTextColour = wxColour(_T("BLACK")); m_canvasFont = *wxNORMAL_FONT; // Create the main frame window MyFrame *frame = new MyFrame((wxFrame *) NULL, _T("wxWidgets dialogs example")); // Make a menubar wxMenu *file_menu = new wxMenu; file_menu->Append(DIALOGS_MESSAGE_BOX, _T("&Message box\tCtrl-M")); #if wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG wxMenu *choices_menu = new wxMenu; #if wxUSE_COLOURDLG choices_menu->Append(DIALOGS_CHOOSE_COLOUR, _T("&Choose colour")); #endif // wxUSE_COLOURDLG #if wxUSE_FONTDLG choices_menu->Append(DIALOGS_CHOOSE_FONT, _T("Choose &font")); #endif // wxUSE_FONTDLG #if wxUSE_CHOICEDLG choices_menu->Append(DIALOGS_SINGLE_CHOICE, _T("&Single choice\tCtrl-C")); choices_menu->Append(DIALOGS_MULTI_CHOICE, _T("M&ultiple choice\tCtrl-U")); #endif // wxUSE_CHOICEDLG #if USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC choices_menu->AppendSeparator(); #endif // USE_COLOURDLG_GENERIC || USE_FONTDLG_GENERIC #if USE_COLOURDLG_GENERIC choices_menu->Append(DIALOGS_CHOOSE_COLOUR_GENERIC, _T("&Choose colour (generic)")); #endif // USE_COLOURDLG_GENERIC #if USE_FONTDLG_GENERIC choices_menu->Append(DIALOGS_CHOOSE_FONT_GENERIC, _T("Choose &font (generic)")); #endif // USE_FONTDLG_GENERIC file_menu->Append(wxID_ANY,_T("&Choices and selectors"),choices_menu); #endif // wxUSE_COLOURDLG || wxUSE_FONTDLG || wxUSE_CHOICEDLG #if wxUSE_TEXTDLG || wxUSE_NUMBERDLG wxMenu *entry_menu = new wxMenu; #if wxUSE_TEXTDLG entry_menu->Append(DIALOGS_TEXT_ENTRY, _T("Text &entry\tCtrl-E")); entry_menu->Append(DIALOGS_PASSWORD_ENTRY, _T("&Password entry\tCtrl-P")); #endif // wxUSE_TEXTDLG #if wxUSE_NUMBERDLG entry_menu->Append(DIALOGS_NUM_ENTRY, _T("&Numeric entry\tCtrl-N")); #endif // wxUSE_NUMBERDLG file_menu->Append(wxID_ANY,_T("&Entry dialogs"),entry_menu); #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG #if wxUSE_FILEDLG wxMenu *filedlg_menu = new wxMenu; filedlg_menu->Append(DIALOGS_FILE_OPEN, _T("&Open file\tCtrl-O")); filedlg_menu->Append(DIALOGS_FILE_OPEN2, _T("&Second open file\tCtrl-2")); filedlg_menu->Append(DIALOGS_FILES_OPEN, _T("Open &files\tCtrl-Q")); filedlg_menu->Append(DIALOGS_FILE_SAVE, _T("Sa&ve file\tCtrl-S")); #if USE_FILEDLG_GENERIC filedlg_menu->AppendSeparator(); filedlg_menu->Append(DIALOGS_FILE_OPEN_GENERIC, _T("&Open file (generic)")); filedlg_menu->Append(DIALOGS_FILES_OPEN_GENERIC, _T("Open &files (generic)")); filedlg_menu->Append(DIALOGS_FILE_SAVE_GENERIC, _T("Sa&ve file (generic)")); #endif // USE_FILEDLG_GENERIC file_menu->Append(wxID_ANY,_T("&File operations"),filedlg_menu); #endif // wxUSE_FILEDLG #if wxUSE_DIRDLG wxMenu *dir_menu = new wxMenu; dir_menu->Append(DIALOGS_DIR_CHOOSE, _T("&Choose a directory\tCtrl-D")); dir_menu->Append(DIALOGS_DIRNEW_CHOOSE, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D")); file_menu->Append(wxID_ANY,_T("&Directory operations"),dir_menu); #if USE_DIRDLG_GENERIC dir_menu->AppendSeparator(); dir_menu->Append(DIALOGS_GENERIC_DIR_CHOOSE, _T("&Choose a directory (generic)")); #endif // USE_DIRDLG_GENERIC #endif // wxUSE_DIRDLG #if wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG wxMenu *info_menu = new wxMenu; #if wxUSE_STARTUP_TIPS info_menu->Append(DIALOGS_TIP, _T("&Tip of the day\tCtrl-T")); #endif // wxUSE_STARTUP_TIPS #if wxUSE_PROGRESSDLG info_menu->Append(DIALOGS_PROGRESS, _T("Pro&gress dialog\tCtrl-G")); #endif // wxUSE_PROGRESSDLG #if wxUSE_BUSYINFO info_menu->Append(DIALOGS_BUSYINFO, _T("&Busy info dialog\tCtrl-B")); #endif // wxUSE_BUSYINFO #if wxUSE_LOG_DIALOG info_menu->Append(DIALOGS_LOG_DIALOG, _T("&Log dialog\tCtrl-L")); #endif // wxUSE_LOG_DIALOG file_menu->Append(wxID_ANY,_T("&Informative dialogs"),info_menu); #endif // wxUSE_STARTUP_TIPS || wxUSE_PROGRESSDLG || wxUSE_BUSYINFO || wxUSE_LOG_DIALOG #if wxUSE_FINDREPLDLG wxMenu *find_menu = new wxMenu; find_menu->AppendCheckItem(DIALOGS_FIND, _T("&Find dialog\tCtrl-F")); find_menu->AppendCheckItem(DIALOGS_REPLACE, _T("Find and &replace dialog\tShift-Ctrl-F")); file_menu->Append(wxID_ANY,_T("&Searching"),find_menu); #endif // wxUSE_FINDREPLDLG #if USE_MODAL_PRESENTATION wxMenu *modal_menu = new wxMenu; modal_menu->Append(DIALOGS_MODAL, _T("Mo&dal dialog\tCtrl-W")); modal_menu->AppendCheckItem(DIALOGS_MODELESS, _T("Modeless &dialog\tCtrl-Z")); file_menu->Append(wxID_ANY,_T("&Modal/Modeless"),modal_menu); #endif // USE_MODAL_PRESENTATION file_menu->Append(DIALOGS_PROPERTY_SHEET, _T("&Property Sheet Dialog\tCtrl-P")); file_menu->Append(DIALOGS_REQUEST, _T("&Request user attention\tCtrl-R")); file_menu->AppendSeparator(); file_menu->Append(wxID_EXIT, _T("E&xit\tAlt-X")); wxMenuBar *menu_bar = new wxMenuBar; menu_bar->Append(file_menu, _T("&File")); frame->SetMenuBar(menu_bar); myCanvas = new MyCanvas(frame); myCanvas->SetBackgroundColour(*wxWHITE); frame->Centre(wxBOTH); // Show the frame frame->Show(true); SetTopWindow(frame); return true; }
bool CBOINCGUIApp::OnInit() { // Setup variables with default values // m_pConfig = NULL; m_pSkin = NULL; m_pLog = NULL; m_pState = NULL; m_pInterface = NULL; wxString strVendorName = wxT("ROMWNET"); wxString strApplicationName = wxT("BOINC-Sentinels-Valkyrie"); // Command line parsing is done in wxApp::OnInit() // if (!wxApp::OnInit()) { return false; } // Enable known image types // wxInitAllImageHandlers(); // Reduce overhead of Idle Events // wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED); // Note: JAWS for Windows will only speak the context-sensitive // help if you use this help provider: // wxHelpProvider::Set(new wxHelpControllerHelpProvider()); // Setup application and company information // SetVendorName(strVendorName); SetAppName(strApplicationName); // Initialize the configuration storage module // m_pConfig = new CConfigManager(); wxASSERT(m_pConfig); wxConfigBase::Set(m_pConfig); // Enable Logging and Trace Masks // m_pLog = new CLogManager(); wxASSERT(m_pLog); wxLog::SetActiveTarget(m_pLog); m_pLog->AddTraceMask(wxT("Function Start/End")); m_pLog->AddTraceMask(wxT("Function Status")); m_pLog->AddTraceMask(wxT("Function Performance")); // Enable Notification Management // m_pNotification = new CNotificationManager(); wxASSERT(m_pNotification); // Enable Skinning // m_pSkin = new CSkinManager(); wxASSERT(m_pSkin); // Initialize the state of the system // m_pState = new CBSLClient(); wxASSERT(m_pState); m_pState->OnInit(); // Initialize the Interface // m_pInterface = new CInterface(); wxASSERT(m_pInterface); m_pInterface->Show(); SetTopWindow(m_pInterface); // Switch the current directory to the BOINC Data directory // #if !defined(__WXDEBUG__) || defined(__WXMAC__) if (!GetBOINCDataDirectory().IsEmpty()) { wxSetWorkingDirectory(GetBOINCDataDirectory()); } #endif return true; }
// 'Main program' equivalent: the program execution "starts" here bool moDirectorApp::OnInit() { //(*AppInitialize bool wxsOK = true; //*) wxInitAllImageHandlers(); // Check next line: Gustavo 05/20/2009 // return wxsOK; guint major, minor, micro, nano; cout << "Gstreamer initializing..." << endl; gst_init(NULL,NULL); gst_version (&major, &minor, µ, &nano); cout << "Gstreamer initialized" << " version: " << major << "." << minor << "." << micro << "." << nano << endl; //** SET WORKING PATH CORRECTLY **/ #if wxMAJOR_VERSION<3 wxStandardPaths StdPaths; #else wxStandardPaths StdPaths = wxStandardPaths::Get(); #endif wxFileName exename(StdPaths.GetExecutablePath()); exename.MakeAbsolute(); //wxMessageBox(wxString("appdir:")+wxString(exename.GetPath())); wxSetWorkingDirectory( wxString(exename.GetPath()) ); //** EVERYTHING OK!!!**// moDirectorCore* m_pDirectorCore = NULL; moDirectorFrame* m_pDirectorFrame = NULL; SetAppName(wxString(_("Moldeo Director ")) + moText2Wx(moGetVersionStr()) ); // Check only one instance running m_checker = NULL; /* const wxString name = wxString::Format(wxT("MoldeoDirector-%s"), wxGetUserId().c_str()); // Use mb_str() m_checker = new wxSingleInstanceChecker(name); if (m_checker->IsAnotherRunning()) { wxLogError(_("Program already running, aborting.")); return false; } */ // Check configuration file /* wxString str; wxFileConfig configuration(wxT("MoldeoDirector"),wxT("Moldeo"),wxT(wxGetCwd())); configuration.Read(wxT("General/File1"), &str); wxMessageBox(wxT(str),wxT("Moldeo Director")); */ // created initially) cout << "Image Handlers..." << endl; #if wxUSE_SYSTEM_OPTIONS //wxSystemOptions::SetOption(wxT("no-maskblt"), 1); #endif wxInitAllImageHandlers(); #if wxUSE_FS_INET && wxUSE_STREAMS && wxUSE_SOCKETS //wxFileSystem::AddHandler(new wxInternetFSHandler); #endif wxImageHandler* hndPNG = wxImage::FindHandler((long)wxBITMAP_TYPE_PNG); if (!hndPNG) cout << "Warning: PNG Image handler not loaded..." << endl; wxImageHandler* hndJPEG = wxImage::FindHandler((long)wxBITMAP_TYPE_JPEG); if (!hndJPEG) cout << "Warning: JPEG Image handler not loaded..." << endl; wxImageHandler* hndTGA = wxImage::FindHandler((long)wxBITMAP_TYPE_TGA); if (!hndTGA) cout << "Warning: TGA Image handler not loaded..." << endl; // create the main application window cout << "Director Frame..." << endl; m_pDirectorFrame = new moDirectorFrame(wxString(_("Moldeo Director ")) + moText2Wx(moGetVersionStr())); if (m_pDirectorFrame) { m_pDirectorFrame->SetIcon( wxIcon( wxIconLocation(wxT(MOLDEODATADIR "/icons/Moldeo32.ico")) ) ); m_pDirectorFrame->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT)); m_pDirectorFrame->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); } else { exit(1); } cout << "m_pDirectorFrame:" << (m_pDirectorFrame!=NULL) << endl; cout << "Director Core..." << endl; m_pDirectorCore = new moDirectorCore(); cout << "m_pDirectorCore:" << (m_pDirectorCore!=NULL) << endl; cout << "Director Frame UI to Core..." << endl; m_pDirectorCore->SetUserInterface( m_pDirectorFrame ); m_pDirectorCore->SetPaths( moWx2Text(exename.GetPath()), moWx2Text(StdPaths.GetUserDataDir()), moWx2Text(wxString(wxT(MODULESDIR))), moWx2Text(wxString(wxT(MOLDEODATADIR))) ); m_pDirectorCore->Init(); //wxList ImageHandlerList = wxImage::GetHandlers(); cout << "appdir:" << moWx2Text( wxGetCwd() ) << endl; cout << "userdir:" << moWx2Text( StdPaths.GetUserDataDir() ) << endl; cout << "datadir:" << moWx2Text(wxString(_(MOLDEODATADIR))) << endl; cout << "modulesdir:" << moWx2Text(wxString(_(MODULESDIR))) << endl; cout << "Showing Frame..." << endl; m_pDirectorFrame->Show(true); cout << "Setting Top Window..." << endl; SetTopWindow(m_pDirectorFrame); m_pDirectorFrame->Maximize(); m_pDirectorFrame->Init(); cout << "Success!!! rock and roll!!" << endl; moText config; cout << "argc: " << argc << endl; /*minimo 2*/ while( argc >= 2 ) { --argc; wxString arglast(argv[argc]); wxString argprev; if (argc>0) argprev = argv[argc-1]; wxString arg0(argv[0]); cout << "Argument id" << (argc) << " : " << moWx2Text(arglast) << endl; if( argprev == wxString( _("-mol") ) ) { config = moWx2Text( arglast ); cout << "Argument -mol found! : " << config << endl; --argc; } else if ( arglast == wxString(_("--help")) ) { cout << "Usage: " << moWx2Text(arg0) << " [-mol]" << endl; } else { cout << "Usage: " << moWx2Text(arg0) << " [-mol]" << endl; /*wxMessageBox( wxString(wxT("Error opening:")) + wxString(wxT(" argc:")) + // wxString(IntToStr(argc)) + wxString(wxT(" argv[argc-1]:")) + argv[argc-1] + wxString(wxT(" argv[0]:")) + wxString(argv[0]) + wxString(wxT(" argv[1]:")) + wxString(argv[1]) + wxString(wxT(" argv[2]:")) + wxString(argv[2]) ); */ //exit(0); } } if (config!=moText("")) { moProjectDescriptor ProjectDescriptor; wxFileName FileName( moText2Wx(config) ); wxString path = FileName.GetPath(); #ifdef MO_WIN32 path+= _T("\\"); #else path+= _T("/"); #endif wxString name = FileName.GetFullName(); ProjectDescriptor.Set( moWx2Text(path), moWx2Text(name) ); moDirectorStatus mStatus = m_pDirectorFrame->OpenProject( ProjectDescriptor ); } // success: wxApp::OnRun() will be called which will enter the main message // loop and the application will run. If we returned false here, the // application would exit immediately. return true; }
bool OnInitImpl(mmGUIApp* app) { app->SetAppName(mmex::GetAppName()); /* Setting Locale causes unexpected problems, so default to English Locale */ app->getLocale().Init(wxLANGUAGE_ENGLISH); Model_Report::prepareTempFolder(); Model_Report::WindowsUpdateRegistry(); /* Initialize Image Handlers */ wxInitAllImageHandlers(); /* Initialize File System Handlers */ wxFileSystem::AddHandler(new wxMemoryFSHandler()); wxFileSystem::AddHandler(new wxInternetFSHandler()); wxFileSystem::AddHandler(new wxArchiveFSHandler()); wxFileSystem::AddHandler(new wxFilterFSHandler()); app->m_setting_db = new wxSQLite3Database(); app->m_setting_db->Open(mmex::getPathUser(mmex::SETTINGS)); Model_Setting::instance(app->m_setting_db); Model_Usage::instance(app->m_setting_db); /* Force setting MMEX language parameter if it has not been set. */ mmDialogs::mmSelectLanguage(app, 0, !Model_Setting::instance().ContainsSetting(LANGUAGE_PARAMETER)); /* Load MMEX Custom Settings */ mmIniOptions::instance().loadOptions(); /* Was App Maximized? */ bool isMax = Model_Setting::instance().GetBoolSetting("ISMAXIMIZED", true); //Get System screen size #ifdef _MSC_VER int sys_screen_x = GetSystemMetrics(SM_CXVIRTUALSCREEN); int sys_screen_y = GetSystemMetrics(SM_CYVIRTUALSCREEN); #else int sys_screen_x = wxSystemSettings::GetMetric(wxSYS_SCREEN_X); int sys_screen_y = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y); #endif /* Load Dimensions of Window */ int valx = Model_Setting::instance().GetIntSetting("ORIGINX", 50); int valy = Model_Setting::instance().GetIntSetting("ORIGINY", 50); int valw = Model_Setting::instance().GetIntSetting("SIZEW", sys_screen_x/4*3); int valh = Model_Setting::instance().GetIntSetting("SIZEH", sys_screen_y/4*3); //BUGFIX: #214 MMEX Window is "off screen" if (valx >= sys_screen_x ) valx = sys_screen_x - valw; if (valy >= sys_screen_y ) valy = sys_screen_y - valh; app->m_frame = new mmGUIFrame(app, mmex::getProgramName(), wxPoint(valx, valy), wxSize(valw, valh)); Mongoose_Service::instance().open(); bool ok = app->m_frame->Show(); if (isMax) app->m_frame->Maximize(true); // success: wxApp::OnRun() will be called which will enter the main message // loop and the application will run. If we returned FALSE here, the // application would exit immediately. return ok; }
bool Rpcs3App::OnInit() { static const wxCmdLineEntryDesc desc[] { { wxCMD_LINE_SWITCH, "h", "help", "Command line options:\nh (help): Help and commands\nt (test): For directly executing a (S)ELF", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_SWITCH, "t", "test", "Run in test mode on (S)ELF", wxCMD_LINE_VAL_NONE }, { wxCMD_LINE_PARAM, NULL, NULL, "(S)ELF", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE } }; parser.SetDesc(desc); parser.SetCmdLine(argc, argv); if (parser.Parse()) { // help was given, terminating this->Exit(); } EmuCallbacks callbacks; callbacks.call_after = [](std::function<void()> func) { wxGetApp().CallAfter(std::move(func)); }; callbacks.process_events = [this]() { m_MainFrame->Update(); wxGetApp().ProcessPendingEvents(); }; callbacks.send_dbg_command = [](DbgCommand id, CPUThread* t) { wxGetApp().SendDbgCommand(id, t); }; callbacks.get_kb_handler = []() -> std::unique_ptr<KeyboardHandlerBase> { switch (auto mode = rpcs3::config.io.keyboard_handler_mode.value()) { case io_handler_mode::null: return std::make_unique<NullKeyboardHandler>(); case io_handler_mode::windows: return std::make_unique<WindowsKeyboardHandler>(); default: throw EXCEPTION("Invalid Keyboard Handler Mode %d", +(u32)mode); } }; callbacks.get_mouse_handler = []() -> std::unique_ptr<MouseHandlerBase> { switch (auto mode = rpcs3::config.io.mouse_handler_mode.value()) { case io_handler_mode::null: return std::make_unique<NullMouseHandler>(); case io_handler_mode::windows: return std::make_unique<WindowsMouseHandler>(); default: throw EXCEPTION("Invalid Mouse Handler Mode %d", +(u32)mode); } }; callbacks.get_pad_handler = []() -> std::unique_ptr<PadHandlerBase> { switch (auto mode = rpcs3::config.io.pad_handler_mode.value()) { case io_handler_mode::null: return std::make_unique<NullPadHandler>(); case io_handler_mode::windows: return std::make_unique<WindowsPadHandler>(); #ifdef _MSC_VER case io_handler_mode::xinput: return std::make_unique<XInputPadHandler>(); #endif default: throw EXCEPTION("Invalid Pad Handler Mode %d", (int)mode); } }; callbacks.get_gs_frame = [](frame_type type) -> std::unique_ptr<GSFrameBase> { switch (type) { case frame_type::OpenGL: return std::make_unique<GLGSFrame>(); case frame_type::DX12: return std::make_unique<GSFrame>("DirectX 12"); case frame_type::Null: return std::make_unique<GSFrame>("Null"); } throw EXCEPTION("Invalid Frame Type"); }; callbacks.get_gs_render = []() -> std::shared_ptr<GSRender> { switch (auto mode = rpcs3::state.config.rsx.renderer.value()) { case rsx_renderer_type::Null: return std::make_shared<NullGSRender>(); case rsx_renderer_type::OpenGL: return std::make_shared<GLGSRender>(); #ifdef _MSC_VER case rsx_renderer_type::DX12: return std::make_shared<D3D12GSRender>(); #endif default: throw EXCEPTION("Invalid GS Renderer %d", (int)mode); } }; callbacks.get_msg_dialog = []() -> std::shared_ptr<MsgDialogBase> { return std::make_shared<MsgDialogFrame>(); }; callbacks.get_save_dialog = []() -> std::unique_ptr<SaveDialogBase> { return std::make_unique<SaveDialogFrame>(); }; Emu.SetCallbacks(std::move(callbacks)); TheApp = this; SetAppName(_PRGNAME_); wxInitAllImageHandlers(); Emu.Init(); m_MainFrame = new MainFrame(); SetTopWindow(m_MainFrame); m_MainFrame->Show(); m_MainFrame->DoSettings(true); OnArguments(parser); return true; }
bool mxApplication::OnInit() { wxInitAllImageHandlers(); Vprincipal *p = new Vprincipal(NULL); p->Show(); return true; }
bool OnInit() { int i, RetVal = 1; long uj; //#define FLEXGRID #ifndef FLEXGRID wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); #else wxFlexGridSizer* sizer = new wxFlexGridSizer (3, 3, 0, 0); sizer->AddGrowableRow (1, 1); sizer->AddGrowableCol (1, 1); #endif // Parse command-line arguments. for (i = 1; i < argc; i++) { wxString Argv = argv[i]; if (Argv.BeforeFirst('=') == wxT("--port")) { if (Argv.AfterFirst('=').ToLong(&uj)) Port = uj; else { fprintf(stderr, "Illegal value in --port switch.\n"); goto Help; } } else if (Argv.BeforeFirst('=') == wxT("--host")) { Host = Argv.AfterFirst('='); } else if (Argv == wxT("--verbose") || Argv == wxT("-v")) Verbosity++; else if (Argv == wxT("--help")) { RetVal = 0; Help: ; fprintf(stderr, "USAGE:\n"); fprintf(stderr, " yaPanel [OPTIONS]\n"); fprintf(stderr, "The allowed OPTIONS are:\n"); fprintf(stderr, "--help Display this help-info.\n"); fprintf( stderr, "--host=H Host IP address or name of yaOBC server. Default \"%s\".\n", HOST); fprintf(stderr, "--port=P Defaults to --port=%d.\n", PORT); fprintf(stderr, "--verbose Increase message verbosity.\n"); goto Done; } else { fprintf(stderr, "Unrecognized switch.\n"); goto Help; } } // Initialize the socket library. if (enet_initialize() != 0) { fprintf(stderr, "An error occurred while initializing ENet.\n"); goto Done; } atexit(enet_deinitialize); if (Verbosity) fprintf(stderr, "Starting up enet client.\n"); host = enet_host_create(NULL, 1, 2, 0, 0); if (host == NULL) { fprintf(stderr, "An error occurred while trying to create an ENet client.\n"); goto Done; } wxInitAllImageHandlers(); // Read in the file that lists all of the positions of the input- // and output fields in the background PNG. { FILE *fp; char s[129], Name[MAX_NAME_SIZE]; int i1, i2, i3, i4; BackgroundWidth = 0; BackgroundHeight = 0; fp = fopen("yaPanel.coordinates", "rb"); if (fp == NULL) { wxMessageBox(wxT("Could not open yaPanel.coordinates"), wxT( "Fatal error"), wxOK | wxICON_ERROR); goto Done; } while (NULL != fgets(s, sizeof(s), fp)) { if (5 == sscanf(s, "%" NAME_FIELD_WIDTH "s%d%d%d%d", Name, &i1, &i2, &i3, &i4)) { int i; for (i = 0; i < NumFields; i++) if (!strcmp(Fields[i].Name, Name)) break; if (i < NumFields) { if (i2 < 0) i2 += BackgroundHeight - 1; if (i4 < 0) i4 += BackgroundHeight - 1; if (i1 > i3) { int i; i = i1; i1 = i3; i3 = i1; } if (i2 > i4) { int i; i = i2; i2 = i4; i4 = i; } strcpy(Fields[i].Name, Name); Fields[i].Type = FT_IN; Fields[i].Left = i1; Fields[i].Top = i2; Fields[i].Right = i3; Fields[i].Bottom = i4; } } else if (3 == sscanf(s, "%" NAME_FIELD_WIDTH "s%d%d", Name, &i1, &i2)) { if (!strcmp(Name, "size")) { BackgroundWidth = i1; BackgroundHeight = i2; } else { int i; for (i = 0; i < NumFields; i++) if (!strcmp(Fields[i].Name, Name)) break; if (i < NumFields) { if (i2 < 0) i2 += BackgroundHeight - 1; strcpy(Fields[i].Name, Name); Fields[i].Type = FT_OUT; Fields[i].x = i1; Fields[i].y = i2; } } } } } if (BackgroundWidth == 0 || BackgroundHeight == 0) { wxMessageBox(wxT("Size-fields not found in yaPanel.coordinates"), wxT( "Fatal error"), wxOK | wxICON_ERROR); goto Done; } frame = new wxFrame(NULL, wxID_ANY, wxT("Test yaPanel"), wxPoint(50, 50), wxSize(BackgroundWidth, BackgroundHeight)); // then simply create like this drawPane = new wxImagePanel(frame, wxT("yaPanel.png"), wxBITMAP_TYPE_PNG); #ifndef FLEXGRID sizer->Add(drawPane, 100, wxEXPAND); #else sizer->AddStretchSpacer(); sizer->AddStretchSpacer(); sizer->AddStretchSpacer(); sizer->AddStretchSpacer(); sizer->Add(drawPane, 100, wxSHAPED); sizer->AddStretchSpacer(); sizer->AddStretchSpacer(); sizer->AddStretchSpacer(); sizer->AddStretchSpacer(); #endif frame->SetSizer(sizer); drawPane->CaptureMouse(); frame->Show(); return true; // Error exit here. Done: ; if (host != NULL) enet_host_destroy(host); return false; }
bool PGM_BASE::initPgm() { wxFileName pgm_name( App().argv[0] ); wxConfigBase::DontCreateOnDemand(); wxInitAllImageHandlers(); m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) + wxGetUserId(), GetKicadLockFilePath() ); if( m_pgm_checker->IsAnotherRunning() ) { wxString quiz = wxString::Format( _( "%s is already running, Continue?" ), GetChars( pgm_name.GetName() ) ); if( !IsOK( NULL, quiz ) ) return false; } // Init KiCad environment // the environment variable KICAD (if exists) gives the kicad path: // something like set KICAD=d:\kicad bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_kicad_env ); if( isDefined ) // ensure m_kicad_env ends by "/" { m_kicad_env.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); if( !m_kicad_env.IsEmpty() && m_kicad_env.Last() != '/' ) m_kicad_env += UNIX_STRING_DIR_SEP; } // Init parameters for configuration App().SetVendorName( wxT( "KiCad" ) ); App().SetAppName( pgm_name.GetName().Lower() ); // Install some image handlers, mainly for help if( wxImage::FindHandler( wxBITMAP_TYPE_PNG ) == NULL ) wxImage::AddHandler( new wxPNGHandler ); if( wxImage::FindHandler( wxBITMAP_TYPE_GIF ) == NULL ) wxImage::AddHandler( new wxGIFHandler ); if( wxImage::FindHandler( wxBITMAP_TYPE_JPEG ) == NULL ) wxImage::AddHandler( new wxJPEGHandler ); wxFileSystem::AddHandler( new wxZipFSHandler ); // Analyze the command line & initialize the binary path setExecutablePath(); SetLanguagePath(); // OS specific instantiation of wxConfigBase derivative: m_common_settings = GetNewConfig( KICAD_COMMON ); // Only define the default environment variable if they haven't been set in the // .kicad_common configuration file. if( m_common_settings && !m_common_settings->HasGroup( pathEnvVariables ) ) { wxString envVarName = wxT( "KIGITHUB" ); ENV_VAR_ITEM envVarItem; wxString envValue; wxFileName tmpFileName; envVarItem.SetValue( wxString( wxT( "https://github.com/KiCad" ) ) ); envVarItem.SetDefinedExternally( wxGetEnv( envVarName, NULL ) ); m_local_env_vars[ envVarName ] = envVarItem; wxFileName baseSharePath; baseSharePath.AssignDir( wxString( wxT( DEFAULT_INSTALL_PATH ) ) ); #if !defined( __WXMAC__ ) baseSharePath.AppendDir( wxT( "share" ) ); baseSharePath.AppendDir( wxT( "kicad" ) ); #endif // KISYSMOD envVarName = wxT( "KISYSMOD" ); if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() ) { tmpFileName.AssignDir( envValue ); envVarItem.SetDefinedExternally( true ); } else { tmpFileName = baseSharePath; tmpFileName.AppendDir( wxT( "modules" ) ); envVarItem.SetDefinedExternally( false ); } envVarItem.SetValue( tmpFileName.GetFullPath() ); m_local_env_vars[ envVarName ] = envVarItem; // KISYS3DMOD envVarName = wxT( "KISYS3DMOD" ); if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() ) { tmpFileName.AssignDir( envValue ); envVarItem.SetDefinedExternally( true ); } else { tmpFileName.AppendDir( wxT( "packages3d" ) ); envVarItem.SetDefinedExternally( false ); } envVarItem.SetValue( tmpFileName.GetFullPath() ); m_local_env_vars[ envVarName ] = envVarItem; // KICAD_PTEMPLATES envVarName = wxT( "KICAD_PTEMPLATES" ); if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() ) { tmpFileName.AssignDir( envValue ); envVarItem.SetDefinedExternally( true ); } else { tmpFileName = baseSharePath; tmpFileName.AppendDir( wxT( "template" ) ); envVarItem.SetDefinedExternally( false ); } envVarItem.SetValue( tmpFileName.GetFullPath() ); m_local_env_vars[ envVarName ] = envVarItem; } ReadPdfBrowserInfos(); // needs m_common_settings // Init user language *before* calling loadCommonSettings, because // env vars could be incorrectly initialized on Linux // (if the value contains some non ASCII7 chars, the env var is not initialized) SetLanguage( true ); loadCommonSettings(); // Set locale option for separator used in float numbers SetLocaleTo_Default(); #ifdef __WXMAC__ // Always show filters on Open dialog to be able to choose plugin wxSystemOptions::SetOption( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1 ); #endif return true; }
bool CslApp::OnInit() { m_engine=NULL; m_single=NULL; m_shutdown=CSL_SHUTDOWN_NONE; ::wxSetWorkingDirectory(wxPathOnly(wxTheApp->argv[0])); g_basePath=::wxGetCwd(); m_locale.Init(wxLANGUAGE_DEFAULT,wxLOCALE_CONV_ENCODING); m_locale.AddCatalogLookupPathPrefix(LOCALEPATH); #ifdef __WXGTK__ m_locale.AddCatalogLookupPathPrefix(g_basePath+wxString(wxT("/lang"))); #endif if (m_locale.AddCatalog(CSL_NAME_SHORT_STR)) m_lang=m_locale.GetCanonicalName(); #ifdef __WXMAC__ wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"),1); //enables Command-H, Command-M and Command-Q at least when not in fullscreen wxSetEnv(wxT("SDL_SINGLEDISPLAY"),wxT("1")); wxSetEnv(wxT("SDL_ENABLEAPPEVENTS"),wxT("1")); //TODO wxApp::SetExitOnFrameDelete(false); //register event handler for URI schemes AEInstallEventHandler(kInternetEventClass,kAEGetURL, NewAEEventHandlerUPP((AEEventHandlerProcPtr)MacCallbackGetUrl),0,false); #endif wxString uri; for (wxInt32 i=1;i<wxApp::argc;i++) { uri=wxApp::argv[i]; if (!uri.StartsWith(CSL_URI_SCHEME_STR)) uri.Empty(); } wxString lock=wxString::Format(wxT(".%s-%s.lock"),CSL_NAME_SHORT_STR,wxGetUserId().c_str()); m_single=new wxSingleInstanceChecker(lock); if (m_single->IsAnotherRunning()) { if (uri.IsEmpty()) uri=wxT("show"); IpcCall(uri); return true; } m_engine=new CslEngine; wxInitAllImageHandlers(); CslFrame* frame=new CslFrame(NULL,wxID_ANY,wxEmptyString,wxDefaultPosition); SetTopWindow(frame); frame->Show(); if (!uri.IsEmpty()) IpcCall(uri,frame); return true; }
// frame constructor MyFrame::MyFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title) { // set the frame icon SetIcon(wxICON(Icono64)); /*FILE* PointMash; PointMash=fopen("/usr/share/Azpazeta/Res.cfg","r"); if(PointMash){ fscanf(PointMash,"RES=%d:%d",&x,&y); SetSize(x,y); adrx=x/2; adry=y/2; fclose(PointMash); }else{wxMessageBox(wxT("No se ha encontrado archivo de resolución PointMash en: /usr/share/Azpazeta/Res.cfg"),wxT("Error 201"),wxICON_ERROR|wxOK);SetSize(800,600); x=800; y=600;}*/ SetSize(800, 600); x=800; y=600; dcpanel=new wxPanel(this,-1,-1,800,600); wxInitAllImageHandlers(); /*wxImage portada("/usr/share/Azpazeta/media/Portada.png", wxBITMAP_TYPE_PNG); wxImage portadaSize; portadaSize=portada.Scale(x/2,y/2); portadaSize.SaveFile("/usr/share/Azpazeta/media/newres/Portada.png",wxBITMAP_TYPE_PNG); wxBitmap portadaBMP("/usr/share/Azpazeta/media/newres/Portada.png", wxBITMAP_TYPE_PNG);*/ /*wxBitmap portadaBMP("/opt/extras.ubuntu.com/azpazeta/media/inicio.png", wxBITMAP_TYPE_PNG); Portada = new wxStaticBitmap(panel, ID_DIBUJO, portadaBMP, wxPoint(-1,-1)); if(fachada!=1){ actualizar=new wxButton(panel, ID_ACTUALIZAR, wxT("Actualizar juego"), wxPoint(100,500)); jugar=new wxButton(panel, ID_JUGAR, wxT("Cargar partida"), wxPoint(250,500)); instrucciones=new wxButton(panel, ID_INSTRUCCIONES, wxT("Instrucciones"), wxPoint(400,500));} Connect(ID_JUGAR, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MyFrame::OnJugar)); Connect(ID_USER, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MyFrame::OnInstrucciones)); Connect(ID_ACTUALIZAR, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MyFrame::OnActualizar));*/ //dcpanel->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(MyFrame::OnTecla),NULL, this); //dcpanel->Connect(wxEVT_CHAR, wxKeyEventHandler(MyFrame::OnTecla),NULL, this); #if wxUSE_MENUS // create a menu bar fileMenu = new wxMenu; // the "About" item should be in the help menu helpMenu = new wxMenu; helpMenu->Append(ID_INSTRUCCIONES, "&Instrucciones", "Instrucciones sobre Azpazeta"); helpMenu->Append(Minimal_About, "A&cerca\tF1", "Acerca de Azpazeta"); fileMenu->Append(ID_AZPCLIENTE, "&Conectar con server", "Jugar multijugador"); fileMenu->Append(ID_NEWGAME, "&Nuevo juego","Nueva partida"); fileMenu->Append(ID_MODS, "C&heckear mods","Comprueba los mods instalados"); fileMenu->Append(ID_ACTUALIZAR, "A&ctualizar", "Actualizar Azpazeta"); fileMenu->Append(ID_NET, "&Mas productos de Divel", "Mas productos de Divel"); fileMenu->Append(Minimal_Quit, "&Salir\tAlt-X", "Salir sin guardar"); // now append the freshly created menu to the menu bar... menuBar = new wxMenuBar(); menuBar->Append(fileMenu, "&Archivo"); menuBar->Append(helpMenu, "A&yuda"); // ... and attach this menu bar to the frame //SetMenuBar(menuBar); //Hacer funcionar con tecla ALT-Estilo Windows 7 #endif // wxUSE_MENUS #if wxUSE_STATUSBAR // create a status bar just for fun (by default with 1 pane only) CreateStatusBar(2); SetStatusText("Azpazeta 1.0 Sin comprobar actualizaciones"); //Pantalla Completa, implementar en futuras versiones//ShowFullScreen(true, wxFULLSCREEN_ALL); #endif // wxUSE_STATUSBAR }
bool MyApp::OnInit(void) { wxInitAllImageHandlers(); // Set the font path and working directory wxFileName exePath = wxStandardPaths::Get().GetExecutablePath(); #ifdef __WXMAC__ wxString fontPath = exePath.GetPathWithSep() + wxT("../../../../../lib/fonts"); wxString cwdPath = exePath.GetPathWithSep() + wxT("../../.."); #else wxString fontPath = exePath.GetPathWithSep() + wxT("../../lib/fonts"); wxString cwdPath = exePath.GetPath(); #endif wxPdfFontManager::GetFontManager()->AddSearchPath(fontPath); wxSetWorkingDirectory(cwdPath); #if wxCHECK_VERSION(2,9,0) m_testFont.Create(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); #else m_testFont.Create(10, wxSWISS, wxNORMAL, wxNORMAL); #endif g_printData = new wxPrintData; // You could set an initial paper size here // g_printData->SetPaperId(wxPAPER_LETTER); // for Americans // g_printData->SetPaperId(wxPAPER_A4); // for everyone else g_pageSetupData = new wxPageSetupDialogData; // copy over initial paper size from print record (*g_pageSetupData) = *g_printData; // Set some initial page margins in mm. g_pageSetupData->SetMarginTopLeft(wxPoint(15, 15)); g_pageSetupData->SetMarginBottomRight(wxPoint(15, 15)); // Create the main frame window frame = new MyFrame((wxFrame *) NULL, _T("wxWidgets Printing Demo"), wxPoint(0, 0), wxSize(400, 400)); #if wxUSE_STATUSBAR // Give it a status line frame->CreateStatusBar(2); #endif // wxUSE_STATUSBAR // Load icon and bitmap frame->SetIcon( wxICON( mondrian) ); // Make a menubar wxMenu *file_menu = new wxMenu; file_menu->Append(WXPRINT_PRINT, _T("&Print..."), _T("Print")); file_menu->Append(WXPRINT_PDF, _T("PDF..."), _T("PDF")); file_menu->Append(WXPRINT_PAGE_SETUP, _T("Page Set&up..."), _T("Page setup")); #ifdef __WXMAC__ file_menu->Append(WXPRINT_PAGE_MARGINS, _T("Page Margins..."), _T("Page margins")); #endif file_menu->Append(WXPRINT_PREVIEW, _T("Print Pre&view"), _T("Preview")); #if wxUSE_ACCEL // Accelerators wxAcceleratorEntry entries[1]; entries[0].Set(wxACCEL_CTRL, (int) 'V', WXPRINT_PREVIEW); wxAcceleratorTable accel(1, entries); frame->SetAcceleratorTable(accel); #endif #if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW file_menu->AppendSeparator(); file_menu->Append(WXPRINT_PRINT_PS, _T("Print PostScript..."), _T("Print (PostScript)")); file_menu->Append(WXPRINT_PAGE_SETUP_PS, _T("Page Setup PostScript..."), _T("Page setup (PostScript)")); file_menu->Append(WXPRINT_PREVIEW_PS, _T("Print Preview PostScript"), _T("Preview (PostScript)")); #endif file_menu->AppendSeparator(); file_menu->Append(WXPRINT_ANGLEUP, _T("Angle up\tAlt-U"), _T("Raise rotated text angle")); file_menu->Append(WXPRINT_ANGLEDOWN, _T("Angle down\tAlt-D"), _T("Lower rotated text angle")); file_menu->AppendSeparator(); file_menu->Append(WXPRINT_QUIT, _T("E&xit"), _T("Exit program")); wxMenu *help_menu = new wxMenu; help_menu->Append(WXPRINT_ABOUT, _T("&About"), _T("About this demo")); wxMenuBar *menu_bar = new wxMenuBar; menu_bar->Append(file_menu, _T("&File")); menu_bar->Append(help_menu, _T("&Help")); // Associate the menu bar with the frame frame->SetMenuBar(menu_bar); MyCanvas *canvas = new MyCanvas(frame, wxPoint(0, 0), wxSize(100, 100), wxRETAINED|wxHSCROLL|wxVSCROLL); // Give it scrollbars: the virtual canvas is 20 * 50 = 1000 pixels in each direction canvas->SetScrollbars(20, 20, 50, 50); frame->canvas = canvas; frame->Centre(wxBOTH); frame->Show(); #if wxUSE_STATUSBAR frame->SetStatusText(_T("Printing demo")); #endif // wxUSE_STATUSBAR SetTopWindow(frame); return true; }
void wxPyCoreModuleInject(PyObject* moduleDict) { // Create an exception object to use for wxASSERTions wxAssertionError = PyErr_NewException("wx._core.wxAssertionError", PyExc_AssertionError, NULL); PyDict_SetItemString(moduleDict, "wxAssertionError", wxAssertionError); // An alias that should be deprecated sometime PyDict_SetItemString(moduleDict, "PyAssertionError", wxAssertionError); // // Create an exception object to use when the app object hasn't been created yet // wxPyNoAppError = PyErr_NewException("wx._core.PyNoAppError", // PyExc_RuntimeError, NULL); // PyDict_SetItemString(moduleDict, "PyNoAppError", wxPyNoAppError); #ifdef __WXGTK__ #define wxPort "__WXGTK__" #define wxPortName "wxGTK" #endif #ifdef __WXMSW__ #define wxPort "__WXMSW__" #define wxPortName "wxMSW" #endif #ifdef __WXMAC__ #define wxPort "__WXMAC__" #define wxPortName "wxMac" #endif wxInitAllImageHandlers(); // TODO: Find some blackmagic way to deprecate wx.Platform such that it raises // a wraning when used... Maybe a class that returns wx.Port for any __getattr__? PyDict_SetItemString(moduleDict, "Port", PyUnicode_FromString(wxPort)); PyDict_SetItemString(moduleDict, "Platform", PyUnicode_FromString(wxPort)); // Make a tuple of strings that gives more info about the platform and build. PyObject* PlatformInfo = PyList_New(0); PyObject* obj; #define _AddInfoString(st) \ obj = PyUnicode_FromString(st); \ PyList_Append(PlatformInfo, obj); \ Py_DECREF(obj) _AddInfoString(wxPort); _AddInfoString(wxPortName); #if wxUSE_UNICODE _AddInfoString("unicode"); #if wxUSE_UNICODE_WCHAR _AddInfoString("unicode-wchar"); #else _AddInfoString("unicode-utf8"); #endif #else _AddInfoString("ansi"); #endif #ifdef __WXOSX__ _AddInfoString("wxOSX"); #endif #ifdef __WXOSX_CARBON__ _AddInfoString("wxOSX-carbon"); #endif #ifdef __WXOSX_COCOA__ _AddInfoString("wxOSX-cocoa"); #endif #ifdef __WXGTK__ #ifdef __WXGTK3__ _AddInfoString("gtk3"); #elif __WXGTK20__ _AddInfoString("gtk2"); #else _AddInfoString("gtk1"); #endif #endif #ifdef __WXDEBUG__ _AddInfoString("wx-assertions-on"); #else _AddInfoString("wx-assertions-off"); #endif _AddInfoString("phoenix"); #undef _AddInfoString PyObject* PlatformInfoTuple = PyList_AsTuple(PlatformInfo); Py_DECREF(PlatformInfo); PyDict_SetItemString(moduleDict, "PlatformInfo", PlatformInfoTuple); }
bool yaAcaAppClass::OnInit() { int i; App = this; printf ("yaACA2 Apollo ACA simulation, ver " VER(NVER) ", built " __DATE__ " " __TIME__ "\n"); printf ("Copyright 2009 by Ronald S. Burkey\n"); printf ("Refer to http://www.ibiblio.org/apollo/index.html for more information.\n"); Portnum = 19803; for (i = 1; i < argc; i++) { wxString Arg = argv[i]; wxString ArgStart = Arg.BeforeFirst ('='); wxString ArgEnd = Arg.AfterFirst ('='); if (ArgStart.IsSameAs (wxT ("--ip"))) { strcpy (NonDefaultHostname, ArgEnd.char_str ()); Hostname = NonDefaultHostname; } else if (ArgStart.IsSameAs (wxT ("--port"))) { long lPortnum; ArgEnd.ToLong (&lPortnum); Portnum = lPortnum; if (Portnum <= 0 || Portnum >= 0x10000) { printf ("The --port switch is out of range. Must be 1-64K.\n"); goto Help; } } else if (ArgStart.IsSameAs (wxT ("--delay"))) { long lj; ArgEnd.ToLong (&lj); StartupDelay = lj; } else if (ArgStart.IsSameAs (wxT ("--controller"))) { long lj; ArgEnd.ToLong (&lj); if (lj < 0 || lj > 1) { wxMessageBox (wxT ("Only --controller=0 and --controller=1 are allowed."), wxT ("Error"), wxICON_ERROR); goto Help; } else ControllerNumber = lj; } else { Help: printf ("USAGE:\n"); printf ("\tyaACA2 [OPTIONS]\n"); printf ("The available options are:\n"); printf ("--ip=Hostname\n"); printf ("\tThe yaACA2 program and the yaAGC Apollo Guidance Computer simulation\n"); printf ("\texist in a \"client/server\" relationship, in which the yaACA2 program\n"); printf ("\tneeds to be aware of the IP address or symbolic name of the host \n"); printf ("\tcomputer running the yaAGC program. By default, this is \"localhost\",\n"); printf ("\tmeaning that both yaACA2 and yaAGC are running on the same computer.\n"); printf ("--port=Portnumber\n"); printf ("\tBy default, yaACA2 attempts to connect to the yaAGC program using port\n"); printf ("\tnumber %d. However, if more than one instance of yaACA2 is being\n", Portnum); printf ("\trun, or if yaAGC has been configured to listen on different ports, then\n"); printf ("\tdifferent port settings for yaACA2 are needed. Note that by default,\n"); printf ("\tyaAGC listens for new connections on ports %d-%d.\n", 19697, 19697 + 10 - 1); printf ("--delay=N\n"); printf ("\t\"Start-up delay\", in ms. Defaults to %d. What the start-up\n", StartupDelay); printf ("\tdelay does is to prevent yaACA2 from attempting to communicate with\n"); printf ("\tyaAGC for a brief time after power-up. This option is really only\n"); printf ("\tuseful in Win32, to work around a problem with race-conditions at\n"); printf ("\tstart-up.\n"); printf ("--roll=...\n"); printf ("--pitch=...\n"); printf ("--yaw=...\n"); printf ("\tThese options are accepted for backward-compatibility with yaACA, the\n"); printf ("\tpredecessor to yaACA2, but are ignored.\n"); printf ("--controller=N\n"); printf ("\tIn case there are two joystick controllers attached, this allows\n"); printf ("\tselection of just one of them. The default is N=0, but N=1 is also\n"); printf ("\tallowed. If there are more than two attached, only the first two can\n"); printf ("\tbe accessed.\n"); exit (1); } } wxInitAllImageHandlers(); yaAcaFrame = new yaAcaFrameClass(NULL, wxID_ANY, wxEmptyString); SetTopWindow(yaAcaFrame); yaAcaFrame->Timer = new TimerClass (); yaAcaFrame->Timer->Initialization = 0; yaAcaFrame->Timer->Start (PULSE_INTERVAL); yaAcaFrame->Show(); return true; }
bool App::OnInit() { _dlgPrefPtr = nullptr; //Re direction des logs ver la sorti standard. wxLog* logger = new wxLogStream(&std::cout); wxLog::SetActiveTarget(logger); //Changement du préfixe seulement sous unix #if defined(__UNIX__) wxStandardPaths::Get().SetInstallPrefix("/usr"); #endif //Chemin vair le fichier d'instance du programme. wxString fileSingleInstance = wxStandardPaths::Get().GetTempDir()+'/'+PROJECT_NAME+'-'+wxGetUserId(); //Si le fichier existe ceci veux dire qu'il y a une autre instances de ce //programme en cour d'exécution. if(wxFileExists(fileSingleInstance)) { //On lis le pid de l'autre instances. int pid; wxFile file(fileSingleInstance); file.Read(&pid, sizeof pid); file.Close(); //Et on luis envois le signale USER1. if(wxKill(pid, (wxSignal)SIGUSR1) == 0) { wxLogMessage(PROJECT_NAME" is already running ..."); return false; } } //Si le fichier n'existe pas, alors on le crée avec le pid de //cette instances. int pid = getpid(); wxFile file(fileSingleInstance, wxFile::write); file.Write(&pid, sizeof pid); file.Close(); //Installassions du gestionnaire de signale. //Pour récupère le signale USER1. std::signal(SIGUSR1, signal_user1); evtHandlerMain = this; //Init général wxInitAllImageHandlers(); SetExitOnFrameDelete(false); //Création de tout les managers. Manager::createManagers(); //Chargement de la confige de tous les manager. Manager::loadManagers(); //Bind. Bind(wxEVT_COMMAND_MENU_SELECTED, &App::onQuit, this, ID_QUIT); Bind(wxEVT_COMMAND_MENU_SELECTED, &App::onAbout, this, ID_ABOUT); Bind(wxEVT_COMMAND_MENU_SELECTED, &App::onPreferences, this, ID_PREFERENCES); Bind(wxEVT_COMMAND_MENU_SELECTED, &App::onEnableShortcuts, this, ID_ENABLE_SHORTKUT); #ifdef DEV_RUN_START_PREFERENCES //Envoi d'un évènement pour afficher les préférences. wxCommandEvent *event = new wxCommandEvent(wxEVT_COMMAND_MENU_SELECTED, ID_PREFERENCES); wxQueueEvent(this, event); #endif return true; }
// frame constructor MyFrame::MyFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title) { wxBoxSizer* topSizer; wxBoxSizer* topRowSizer; wxBoxSizer* colSizer; wxBoxSizer* rowSizer; // set the frame icon SetIcon(wxICON(sample)); #if wxUSE_MENUS // create a menu bar wxMenu *fileMenu = new wxMenu; // the "About" item should be in the help menu wxMenu *helpMenu = new wxMenu; helpMenu->Append(ComboCtrl_About, wxT("&About\tF1"), wxT("Show about dialog")); fileMenu->Append(ComboCtrl_Compare, wxT("&Compare against wxComboBox..."), wxT("Show some wxOwnerDrawnComboBoxes side-by-side with native wxComboBoxes.")); fileMenu->AppendSeparator(); fileMenu->Append(ComboCtrl_Quit, wxT("E&xit\tAlt-X"), wxT("Quit this program")); // now append the freshly created menu to the menu bar... wxMenuBar *menuBar = new wxMenuBar(); menuBar->Append(fileMenu, wxT("&File")); menuBar->Append(helpMenu, wxT("&Help")); // ... and attach this menu bar to the frame SetMenuBar(menuBar); #endif // wxUSE_MENUS wxPanel* panel = new wxPanel(this); // Prepare log window right away since it shows EVT_TEXTs m_logWin = new wxTextCtrl(panel, 105, wxEmptyString, wxDefaultPosition, wxSize(-1, 125), wxTE_MULTILINE); wxLogTextCtrl* logger = new wxLogTextCtrl(m_logWin); m_logOld = logger->SetActiveTarget(logger); logger->DisableTimestamp(); topSizer = new wxBoxSizer( wxVERTICAL ); topRowSizer = new wxBoxSizer( wxHORIZONTAL ); colSizer = new wxBoxSizer( wxVERTICAL ); wxComboCtrl* cc; wxGenericComboCtrl* gcc; wxOwnerDrawnComboBox* odc; // Create common strings array m_arrItems.Add( wxT("Solid") ); m_arrItems.Add( wxT("Transparent") ); m_arrItems.Add( wxT("Dot") ); m_arrItems.Add( wxT("Long Dash") ); m_arrItems.Add( wxT("Short Dash") ); m_arrItems.Add( wxT("Dot Dash") ); m_arrItems.Add( wxT("Backward Diagonal Hatch") ); m_arrItems.Add( wxT("Cross-diagonal Hatch") ); m_arrItems.Add( wxT("Forward Diagonal Hatch") ); m_arrItems.Add( wxT("Cross Hatch") ); m_arrItems.Add( wxT("Horizontal Hatch") ); m_arrItems.Add( wxT("Vertical Hatch") ); // // Create pen selector ODComboBox with owner-drawn items // rowSizer = new wxBoxSizer( wxHORIZONTAL ); rowSizer->Add( new wxStaticText(panel,wxID_ANY, wxT("OwnerDrawnComboBox with owner-drawn items:")), 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 4 ); colSizer->Add( rowSizer, 0, wxEXPAND|wxALL, 5 ); rowSizer = new wxBoxSizer( wxHORIZONTAL ); // When defining derivative class for callbacks, we need // to use two-stage creation (or redefine the common wx // constructor). odc = new wxPenStyleComboBox(); odc->Create(panel,wxID_ANY,wxEmptyString, wxDefaultPosition, wxDefaultSize, m_arrItems, wxCB_READONLY //wxNO_BORDER | wxCB_READONLY ); odc->SetSelection(0); rowSizer->Add( odc, 1, wxALIGN_CENTER_VERTICAL|wxALL, 4 ); rowSizer->AddStretchSpacer(1); colSizer->Add( rowSizer, 0, wxEXPAND|wxALL, 5 ); // // Same but with changed button position // rowSizer = new wxBoxSizer( wxHORIZONTAL ); rowSizer->Add( new wxStaticText(panel,wxID_ANY, wxT("OwnerDrawnComboBox with owner-drawn items and button on the left:")), 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 4 ); colSizer->Add( rowSizer, 0, wxEXPAND|wxALL, 5 ); rowSizer = new wxBoxSizer( wxHORIZONTAL ); // When defining derivative class for callbacks, we need // to use two-stage creation (or redefine the common wx // constructor). odc = new wxPenStyleComboBox(); odc->Create(panel,wxID_ANY,wxEmptyString, wxDefaultPosition, wxDefaultSize, m_arrItems, wxCB_READONLY //wxNO_BORDER | wxCB_READONLY ); odc->SetSelection(0); // Use button size that is slightly smaller than the default. wxSize butSize = odc->GetButtonSize(); odc->SetButtonPosition(butSize.x - 2, // button width butSize.y - 6, // button height wxLEFT, // side 2 // horizontal spacing ); rowSizer->Add( odc, 1, wxALIGN_CENTER_VERTICAL|wxALL, 4 ); rowSizer->AddStretchSpacer(1); colSizer->Add( rowSizer, 0, wxEXPAND|wxALL, 5 ); // // List View wxComboCtrl // rowSizer = new wxBoxSizer( wxHORIZONTAL ); rowSizer->Add( new wxStaticText(panel, wxID_ANY, "List View wxComboCtrl (custom animation):"), 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 4 ); rowSizer->Add( new wxStaticText(panel,wxID_ANY,wxT("Tree Ctrl wxComboCtrl:")), 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 4 ); colSizer->Add( rowSizer, 0, wxEXPAND|wxALL, 5 ); rowSizer = new wxBoxSizer( wxHORIZONTAL ); cc = new wxComboCtrlWithCustomPopupAnim(); // Let's set a custom style for the contained wxTextCtrl. We need to // use two-step creation for it to work properly. cc->SetTextCtrlStyle(wxTE_RIGHT); cc->Create(panel, wxID_ANY, wxEmptyString); // Make sure we use popup that allows focusing the listview. cc->UseAltPopupWindow(); cc->SetPopupMinWidth(300); ListViewComboPopup* iface = new ListViewComboPopup(); cc->SetPopupControl(iface); int i; for ( i=0; i<100; i++ ) iface->AddSelection( wxString::Format(wxT("Item %02i"),i)); rowSizer->Add( cc, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); // // Tree Ctrl wxComboCtrl // // Note that we test that wxGenericComboCtrl works gcc = new wxGenericComboCtrl(panel,wxID_ANY,wxEmptyString, wxDefaultPosition, wxDefaultSize); // Make sure we use popup that allows focusing the treectrl. gcc->UseAltPopupWindow(); // Set popup interface right away, otherwise some of the calls // below may fail TreeCtrlComboPopup* tcPopup = new TreeCtrlComboPopup(); gcc->SetPopupControl(tcPopup); // Add items using wxTreeCtrl methods directly wxTreeItemId rootId = tcPopup->AddRoot(wxT("<hidden_root>")); wxTreeItemId groupId; for ( i=0; i<4; i++ ) { groupId = tcPopup->AppendItem(rootId, wxString::Format(wxT("Branch %02i"),i)); int n; for ( n=0; n<25; n++ ) tcPopup->AppendItem(groupId, wxString::Format(wxT("Subitem %02i"),(i*25)+n)); } gcc->SetValue(wxT("Subitem 05")); // Move button to left - it makes more sense for a tree ctrl gcc->SetButtonPosition(-1, // button width -1, // button height wxLEFT, // side 0 // horizontal spacing ); rowSizer->Add( gcc, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); colSizer->Add( rowSizer, 0, wxEXPAND|wxALL, 5 ); #if wxUSE_IMAGE wxInitAllImageHandlers(); // // Custom Dropbutton Bitmaps // (second one uses blank button background) // rowSizer = new wxBoxSizer( wxHORIZONTAL ); rowSizer->Add( new wxStaticText(panel,wxID_ANY, wxT("OwnerDrawnComboBox with simple dropbutton graphics:")), 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 4 ); colSizer->Add( rowSizer, 0, wxEXPAND|wxALL, 5 ); rowSizer = new wxBoxSizer( wxHORIZONTAL ); odc = new wxOwnerDrawnComboBox(panel,wxID_ANY,wxEmptyString, wxDefaultPosition, wxDefaultSize, m_arrItems, (long)0 // wxCB_SORT // wxNO_BORDER | wxCB_READONLY ); wxOwnerDrawnComboBox* odc2; odc2 = new wxOwnerDrawnComboBox(panel,wxID_ANY,wxEmptyString, wxDefaultPosition, wxDefaultSize, m_arrItems, (long)0 // wxCB_SORT // wxNO_BORDER | wxCB_READONLY ); // Load images from disk wxImage imgNormal(wxT("dropbutn.png")); wxImage imgPressed(wxT("dropbutp.png")); wxImage imgHover(wxT("dropbuth.png")); if ( imgNormal.IsOk() && imgPressed.IsOk() && imgHover.IsOk() ) { wxBitmap bmpNormal(imgNormal); wxBitmap bmpPressed(imgPressed); wxBitmap bmpHover(imgHover); odc->SetButtonBitmaps(bmpNormal,false,bmpPressed,bmpHover); odc2->SetButtonBitmaps(bmpNormal,true,bmpPressed,bmpHover); } else wxLogError(wxT("Dropbutton images not found")); //odc2->SetButtonPosition(0, // width adjustment // 0, // height adjustment // wxLEFT, // side // 0 // horizontal spacing // ); rowSizer->Add( odc, 1, wxALIGN_CENTER_VERTICAL|wxALL, 4 ); rowSizer->Add( odc2, 1, wxALIGN_CENTER_VERTICAL|wxALL, 4 ); colSizer->Add( rowSizer, 0, wxEXPAND|wxALL, 5 ); #endif // // wxComboCtrl with totally custom button action (open file dialog) // rowSizer = new wxBoxSizer( wxHORIZONTAL ); rowSizer->Add( new wxStaticText(panel,wxID_ANY, wxT("wxComboCtrl with custom button action:")), 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 4 ); colSizer->Add( rowSizer, 0, wxEXPAND|wxALL, 5 ); rowSizer = new wxBoxSizer( wxHORIZONTAL ); wxFileSelectorCombo* fsc; fsc = new wxFileSelectorCombo(panel,wxID_ANY,wxEmptyString, wxDefaultPosition, wxDefaultSize, (long)0 ); rowSizer->Add( fsc, 1, wxALIGN_CENTER_VERTICAL|wxALL, 4 ); colSizer->Add( rowSizer, 0, wxEXPAND|wxALL, 5 ); // Make sure GetFeatures is implemented wxComboCtrl::GetFeatures(); topRowSizer->Add( colSizer, 1, wxALL, 2 ); colSizer = new wxBoxSizer( wxVERTICAL ); colSizer->AddSpacer(8); colSizer->Add( new wxStaticText(panel, wxID_ANY, wxT("Log Messages:")), 0, wxTOP|wxLEFT, 3 ); colSizer->Add( m_logWin, 1, wxEXPAND|wxALL, 3 ); topRowSizer->Add( colSizer, 1, wxEXPAND|wxALL, 2 ); topSizer->Add( topRowSizer, 1, wxEXPAND ); panel->SetSizer( topSizer ); topSizer->SetSizeHints( panel ); Fit(); Centre(); }
bool Rpcs3App::OnInit() { SetSendDbgCommandCallback([](DbgCommand id, CPUThread* t) { wxGetApp().SendDbgCommand(id, t); }); SetCallAfterCallback([](std::function<void()> func) { wxGetApp().CallAfter(func); }); SetGetKeyboardHandlerCountCallback([]() { return 2; }); SetGetKeyboardHandlerCallback([](int i) -> KeyboardHandlerBase* { switch (i) { case 0: return new NullKeyboardHandler(); break; case 1: return new WindowsKeyboardHandler(); break; default: return new NullKeyboardHandler(); } }); SetGetMouseHandlerCountCallback([]() { return 2; }); SetGetMouseHandlerCallback([](int i) -> MouseHandlerBase* { switch (i) { case 0: return new NullMouseHandler(); break; case 1: return new WindowsMouseHandler(); break; default: return new NullMouseHandler(); } }); SetGetPadHandlerCountCallback([]() { #if defined(_WIN32) return 3; #else return 2; #endif }); SetGetPadHandlerCallback([](int i) -> PadHandlerBase* { switch (i) { case 0: return new NullPadHandler(); break; case 1: return new WindowsPadHandler(); break; #if defined(_WIN32) case 2: return new XInputPadHandler(); break; #endif default: return new NullPadHandler(); } }); SetGetGSFrameCallback([]() -> GSFrameBase* { return new GLGSFrame(); }); SetMsgDialogCreateCallback(MsgDialogCreate); SetMsgDialogDestroyCallback(MsgDialogDestroy); SetMsgDialogProgressBarSetMsgCallback(MsgDialogProgressBarSetMsg); SetMsgDialogProgressBarResetCallback(MsgDialogProgressBarReset); SetMsgDialogProgressBarIncCallback(MsgDialogProgressBarInc); TheApp = this; SetAppName(_PRGNAME_); wxInitAllImageHandlers(); // RPCS3 assumes the current working directory is the folder where it is contained, so we make sure this is true const wxString executablePath = wxPathOnly(wxStandardPaths::Get().GetExecutablePath()); wxSetWorkingDirectory(executablePath); main_thread = std::this_thread::get_id(); Ini.Load(); Emu.Init(); Emu.SetEmulatorPath(executablePath.ToStdString()); m_MainFrame = new MainFrame(); SetTopWindow(m_MainFrame); m_MainFrame->Show(); m_MainFrame->DoSettings(true); OnArguments(); //compile_shader("compile_shader0.spo"); //compile_shader("compile_shader1.spo"); return true; }