bool MyApp::OnInit() { m_locale.Init(); #ifdef APP_LOCALE_DIR m_locale.AddCatalogLookupPathPrefix(wxT(APP_LOCALE_DIR)); #endif m_locale.AddCatalog(wxT(APP_CATALOG)); wxInitAllImageHandlers(); MyFrame* frame_1 = new MyFrame(NULL, wxID_ANY, wxEmptyString); SetTopWindow(frame_1); frame_1->Show(); return true; }
bool AppEditor::OnInit() { m_locale.Init(); #ifdef APP_LOCALE_DIR m_locale.AddCatalogLookupPathPrefix(wxT(APP_LOCALE_DIR)); #endif m_locale.AddCatalog(wxT(APP_CATALOG)); wxInitAllImageHandlers(); FrameEditor* frmEditor = new FrameEditor(NULL, wxID_ANY, wxEmptyString); SetTopWindow(frmEditor); frmEditor->Show(); return true; }
bool MyApp::OnInit() { m_locale.Init(); #ifdef APP_LOCALE_DIR m_locale.AddCatalogLookupPathPrefix(wxT(APP_LOCALE_DIR)); #endif m_locale.AddCatalog(wxT(APP_CATALOG)); wxInitAllImageHandlers(); WMain_wxg* wmain = new WMain_wxg(NULL, wxID_ANY, wxEmptyString); SetTopWindow(wmain); wmain->Show(); return true; }
/** * 初期処理 */ bool DicApp::OnInit() { // カレントフォルダを実行ファイルの場所にする。 ::wxSetWorkingDirectory(::wxPathOnly(argv[0])); // メッセージカタログの設定をする。 m_locale.Init(wxLANGUAGE_DEFAULT); m_locale.AddCatalogLookupPathPrefix(wxT("locale")); m_locale.AddCatalog(wxT("digdic")); #if 0 // 設定ファイルの設定をする。 wxString iniDir = wxStandardPaths::Get().GetUserDataDir(); wxFileName::Mkdir(iniDir, 0777, wxPATH_MKDIR_FULL); wxFileName fn = wxFileName(iniDir, GetAppName(), wxT("ini")); DicShare::iniFile = fn.GetFullPath(); wxFileConfig* config = new wxFileConfig( wxEmptyString, wxEmptyString, DicShare::iniFile, wxEmptyString, wxCONFIG_USE_LOCAL_FILE, *wxConvCurrent); #else // レジストリを使う。 wxConfig* config = new wxConfig( wxT("digdic"), wxT("digdic"), wxEmptyString, wxEmptyString, wxCONFIG_USE_LOCAL_FILE); #endif wxConfigBase::Set(config); // 共通の設定を読み込む。 DicShare::LoadConfig(); wxInitAllImageHandlers(); DicMainFrame* main_frame = new DicMainFrame(0, -1, wxT("")); SetTopWindow(main_frame); main_frame->Show(); return true; }
bool MadEditApp::OnInit() { xm::EncodingManager::PreInit(); xm::RemoteAccessInit(); wxm::AppPath::Instance().Init(GetAppName()); // parse commandline to filelist wxm::FileList filelist; for(int i=1; i<argc; i++) { wxFileName filename(argv[i]); filename.MakeAbsolute(); filelist.Append(filename.GetFullPath()); } // init wxConfig wxFileConfig *cfg=new wxFileConfig(wxEmptyString, wxEmptyString, wxm::AppPath::Instance().ConfigPath(), wxEmptyString, wxCONFIG_USE_RELATIVE_PATH|wxCONFIG_USE_NO_ESCAPE_CHARACTERS); cfg->SetExpandEnvVars(false); cfg->SetRecordDefaults(true); wxFileConfig::Set(cfg); bool bSingleInstance=true; cfg->Read(wxT("/wxMEdit/SingleInstance"), &bSingleInstance, true); // check SingleInstance and send filelist to previous instance if(bSingleInstance && OpenFilesInPrevInst(filelist.String())) return false; #ifdef __WXGTK__ bool bDisableWarningMessage = true; cfg->Read(wxT("/wxMEdit/DisableWarningMessage"), &bDisableWarningMessage, true); if(bDisableWarningMessage) { // redirect "IPP request failed" message to /dev/null int fdnull = open ("/dev/null", O_WRONLY, 0); if(fdnull >= 0) { dup2(fdnull, STDERR_FILENO); } } #endif // init locale wxString strlang; cfg->Read(wxT("/wxMEdit/Language"), &strlang); int lang=g_LanguageValue[0]; if(!strlang.IsEmpty()) { strlang.MakeLower(); for(size_t idx=1; idx<g_LanguageCount; idx++) { if(strlang == wxString(g_LanguageString[idx]).Lower()) { lang=g_LanguageValue[idx]; break; } } } wxm::AppPath& path = wxm::AppPath::Instance(); g_Locale.Init(lang); g_Locale.AddCatalogLookupPathPrefix(wxT("./locale/")); g_Locale.AddCatalogLookupPathPrefix(path.AppDir() + wxT("locale/")); if (path.AppDir() != path.HomeDir()) g_Locale.AddCatalogLookupPathPrefix(path.HomeDir() + wxT("locale/")); #ifndef __WXMSW__ # ifdef DATA_DIR g_Locale.AddCatalogLookupPathPrefix(wxT(DATA_DIR"/locale/")); # endif #endif g_Locale.AddCatalog(wxT("wxmedit")); // set colors wxm::SetL10nHtmlColors(); wxm::UpdatePeriods::Instance().Initialize(); #if defined(__WXMSW__) || defined(__WXGTK__) bool maximize=false; cfg->Read(wxT("/wxMEdit/WindowMaximize"), &maximize, false); #endif wxPoint pos=wxDefaultPosition; wxSize size; wxRect rect = wxGetClientDisplayRect(); // FIXME: multi-monitor size.x = std::min(rect.width, wxm::DEFAULT_WINDOW_WIDTH); size.y = std::min(rect.height, wxm::DEFAULT_WINDOW_HEIGHT); long x=0,y=0,w=0,h=0; cfg->Read(wxT("/wxMEdit/WindowLeft"), &x); cfg->Read(wxT("/wxMEdit/WindowTop"), &y); cfg->Read(wxT("/wxMEdit/WindowWidth"), &w); cfg->Read(wxT("/wxMEdit/WindowHeight"), &h); if(x+w>0 && y+h>0) //if(w>0 && h>0) { size.x=w; size.y=h; pos.x=x; pos.y=y; } // load FontWidth buffers cfg->Read(wxT("/wxMEdit/FontWidthBufferMaxCount"), &FontWidthManager::MaxCount, 10); if(FontWidthManager::MaxCount < 4) FontWidthManager::MaxCount=4; else if(FontWidthManager::MaxCount>40) FontWidthManager::MaxCount=40; FontWidthManager::Init(wxm::AppPath::Instance().HomeDir()); // create the main frame MadEditFrame *myFrame = new MadEditFrame(nullptr, 1 , wxEmptyString, pos, size); SetTopWindow(myFrame); #if defined(__WXMSW__) || defined(__WXGTK__) if (maximize) myFrame->Maximize(true); #endif myFrame->Show(true); #if defined(__WXGTK__) && wxMAJOR_VERSION == 2 if(bSingleInstance) { GtkPizza *pizza = GTK_PIZZA(myFrame->m_mainWidget); Window win=GDK_WINDOW_XWINDOW(pizza->bin_window); XSetSelectionOwner(g_Display, g_MadEdit_atom, win, CurrentTime); gdk_window_add_filter(nullptr, my_gdk_filter, nullptr); } #endif wxm::AutoCheckUpdates(cfg); // reload files previously opened wxString files; cfg->Read(wxT("/wxMEdit/ReloadFilesList"), &files); files += filelist.String(); if(!files.IsEmpty()) { // use OnReceiveMessage() to open the files OnReceiveMessage(files.c_str(), (files.size()+1)*sizeof(wxChar)); } if(myFrame->OpenedFileCount()==0) { myFrame->OpenFile(wxEmptyString, false); } return true; }
bool OnInit() { #if DEBUG wxLogWarning("MODO DEBUG"); #else wxSetAssertHandler(NULL); #endif //i18n/l10n: //20120603: Change suggested by Juan Pizarro to solve the i18n bug in some Windows and Linux machines: //if ( !locale.Init(wxLANGUAGE_DEFAULT, wxLOCALE_CONV_ENCODING) ) #if !defined(linux) wxLogWarning("Esta version esta desarrollada exclusivamente para Linux"); return true; #endif /* #if defined (linux) wxLogNull logNo; #endif */ /* if ( !locale.Init(wxLANGUAGE_ENGLISH, wxLOCALE_CONV_ENCODING) ) wxLogWarning(_("Error #1: This language is not supported by the system.")); */ /* wxString lanPath(wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()) + wxFileName::GetPathSeparator() + wxString("GUI") + wxFileName::GetPathSeparator() + wxString("Texts") //##Unhardcode this in the future? I'm not sure... ); */ //wxString lanPath = wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()) + "/../../GUI/Texts/"; //wxLocale::AddCatalogLookupPathPrefix(lanPath); wxString lanPath = "/usr/share"; locale.AddCatalogLookupPathPrefix(lanPath); //Por defecto debe levantar en Castellano //wxString initialCatalogName("es.mo"); wxString initialCatalogName = "Minibloq.mo"; //wxString initialCatalogName("es.mo"); //##Debug... if (!locale.AddCatalog(initialCatalogName)) { //##Future: See if future wxLocale implementations solve this problem: wxLogWarning( _("Error #1: The installation path\n\n\"") + wxStandardPaths::Get().GetExecutablePath() + _("\"\n\ncontains non-English chars.\n") + _("Please try to install Minibloq on a location without this kind of chars. ") + _("Otherwise, the program will run, but the translation system will not work properly.") ); //wxLogWarning(_("Error #2: Can't load ") + initialCatalogName); printf("NO ENCUENTRO EL CATALOGO\n"); } MainFrame* frame = NULL; wxString caption = wxString(wxString("miniBloq ") + MINIBLOQ_VERSION); wxPoint framePosition = wxDefaultPosition; wxSize frameSize = wxDefaultSize; long style = wxDEFAULT_FRAME_STYLE; //Default values: initialFrameX = 0; initialFrameY = 0; initialFrameHeight = 600; initialFrameWidth = 800; maximized = true; centered = true; strBoard = wxString(""); //Try to read the configuration file: readConfig(); //Priorities: // maximized has priority over all the other pos and size settings. // centered has priority over x and y settings. if (maximized) style = style | wxMAXIMIZE; if ( (initialFrameWidth > 0) && (initialFrameHeight > 0) ) { framePosition = wxPoint(initialFrameX, initialFrameY); frameSize = wxSize(initialFrameWidth, initialFrameHeight); } //TODO: Chequeo de errores wxString execPath = wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()); wxString splashImg = execPath + "/../../GUI/Images/minibloqSplash.png"; wxBitmap splashPng; splashPng.LoadFile(splashImg); wxSplashScreen* splash = new wxSplashScreen(splashPng, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 3000, NULL, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxSTAY_ON_TOP); wxYield(); frame = new MainFrame( NULL, wxID_ANY, locale, lanPath, initialCatalogName, caption, strBoard, framePosition, frameSize, style ); /*## Future: Full screen: wxFrame* frame = new MainFrame(NULL, wxID_ANY, wxString("Minibloq v1.0"), wxDefaultPosition, wxSize(1280, 800), wxCLIP_CHILDREN); */ if (frame) { if (centered) frame->Centre(); frame->setCentered(centered); SetTopWindow(frame); frame->Show(); if (maximized) { frame->Maximize(); } if (argc > 0) { wxString fileName = argv[1]; if (wxFile::Exists(fileName)) { frame->loadFileComponent(fileName); } } } return true; }