void wxSTEditorOptions::SaveFileConfig(wxConfigBase &config) { wxFileHistory *fileHistory = GetFileHistory(); if (!fileHistory) return; wxString configPath = FixConfigPath(GetConfigPath(STE_OPTION_CFGPATH_FILEHISTORY), false); config.Write(configPath+wxT("/LastDir"), GetDefaultFilePath()); int n, count = fileHistory->GetCount(); for (n = 0; n < count; n++) config.Write(configPath + wxString::Format(wxT("/file%d"), n+1), fileHistory->GetHistoryFile(n)); }
void wxSTEditorOptions::SaveFileConfig(wxConfigBase &config) { const wxString oldpath = config.GetPath(); wxFileHistory *fileHistory = GetFileHistory(); if (!fileHistory) return; wxString configPath = FixConfigPath(GetConfigPath(STE_OPTION_CFGPATH_FILEHISTORY), false); config.Write(configPath+wxT("/LastDir"), GetDefaultFilePath()); config.SetPath(configPath); fileHistory->Save(config); config.SetPath(oldpath); }
int ctApp::OnExit(void) { SaveConfig(); // Save the file history { wxConfig config(wxGetApp().GetSettings().GetAppName(), wxT("Generic Organisation")); GetFileHistory().Save(config); } delete m_docManager; m_docManager = NULL; return 0; }
void wxSTEditorOptions::LoadFileConfig( wxConfigBase &config) { const wxString oldpath = config.GetPath(); wxFileHistory *fileHistory = GetFileHistory(); if (!fileHistory) return; wxString configPath = FixConfigPath(GetConfigPath(STE_OPTION_CFGPATH_FILEHISTORY), false); wxString value, key = configPath+wxT("/LastDir"); if (config.Read(key, &value) && wxDirExists(value)) SetDefaultFilePath(value); config.SetPath(configPath); fileHistory->Load(config); config.SetPath(oldpath); }
void wxSTEditorOptions::LoadFileConfig( wxConfigBase &config) { wxFileHistory *fileHistory = GetFileHistory(); if (!fileHistory) return; wxString configPath = FixConfigPath(GetConfigPath(STE_OPTION_CFGPATH_FILEHISTORY), false); wxString value, key = configPath+wxT("/LastDir"); if (config.Read(key, &value) && wxDirExists(value)) SetDefaultFilePath(value); int n = 1; key = configPath + wxString::Format(wxT("/file%d"), n); while ((int(n-1) < fileHistory->GetMaxFiles()) && config.Read(key, &value) && (!value.IsEmpty())) { //value.Trim(false).Trim(true); if (!value.IsEmpty() && wxFileExists(value)) fileHistory->AddFileToHistory(value); key = configPath + wxString::Format(wxT("/file%d"), ++n); value.Clear(); } }
wxExSampleFrame::wxExSampleFrame() : wxExManagedFrame(nullptr, wxID_ANY, wxTheApp->GetAppDisplayName(), 4) , m_Process(new wxExProcess()) , m_Notebook(new wxExNotebook(this, this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE | wxAUI_NB_SCROLL_BUTTONS)) , m_STC(new wxExSTC(this)) , m_Shell(new wxExShell(this, ">", "\n", true, 10)) , m_STCLexers(new wxExSTC(this, wxExLexers::Get()->GetFileName())) { wxExProcess::PrepareOutput(this); SetIcon(wxICON(app)); wxExMenu* menuFile = new wxExMenu; menuFile->Append(wxID_OPEN); GetFileHistory().UseMenu(ID_RECENTFILE_MENU, menuFile); menuFile->AppendSeparator(); menuFile->Append(ID_SHOW_VCS, "Show VCS"); menuFile->AppendPrint(); menuFile->AppendSeparator(); menuFile->Append(wxID_EXECUTE); menuFile->Append(wxID_STOP); menuFile->AppendSeparator(); menuFile->Append(wxID_EXIT); wxExMenu *menuEdit = new wxExMenu(); menuEdit->Append(wxID_UNDO); menuEdit->Append(wxID_REDO); menuEdit->AppendSeparator(); menuEdit->Append(wxID_CUT); menuEdit->Append(wxID_COPY); menuEdit->Append(wxID_PASTE); menuEdit->AppendSeparator(); menuEdit->Append(wxID_JUMP_TO); menuEdit->AppendSeparator(); wxExMenu* menuFind = new wxExMenu(); menuFind->Append(wxID_FIND); menuFind->Append(wxID_REPLACE); menuEdit->AppendSubMenu(menuFind, _("&Find And Replace")); wxExMenu* menuDialog = new wxExMenu; menuDialog->Append(ID_DLG_ITEM, wxExEllipsed("Item Dialog")); menuDialog->AppendSeparator(); menuDialog->Append(ID_DLG_CONFIG_ITEM, wxExEllipsed("Config Dialog")); menuDialog->Append(ID_DLG_CONFIG_ITEM_COL, wxExEllipsed("Config Dialog Columns")); menuDialog->Append(ID_DLG_CONFIG_ITEM_READONLY, wxExEllipsed("Config Dialog Readonly")); menuDialog->AppendSeparator(); menuDialog->Append(ID_DLG_LISTVIEW, wxExEllipsed("List Dialog")); menuDialog->AppendSeparator(); menuDialog->Append(ID_DLG_STC_CONFIG, wxExEllipsed("STC Dialog")); menuDialog->Append(ID_DLG_STC_ENTRY, wxExEllipsed("STC Entry Dialog")); menuDialog->AppendSeparator(); menuDialog->Append(ID_DLG_VCS, wxExEllipsed("VCS Dialog")); wxExMenu* menuSTC = new wxExMenu; menuSTC->Append(ID_STC_FLAGS, wxExEllipsed("Open Flag")); menuSTC->AppendSeparator(); menuSTC->Append(ID_STC_SPLIT, "Split"); wxExMenu *menuView = new wxExMenu; AppendPanes(menuView); menuView->AppendSeparator(); menuView->Append(ID_STATISTICS_SHOW, "Statistics"); wxExMenu* menuHelp = new wxExMenu; menuHelp->Append(wxID_ABOUT); wxMenuBar *menubar = new wxMenuBar; menubar->Append(menuFile, "&File"); menubar->Append(menuEdit, "&Edit"); menubar->Append(menuView, "&View"); menubar->Append(menuDialog, "&Dialog"); menubar->Append(menuSTC, "&STC"); menubar->Append(menuHelp, "&Help"); SetMenuBar(menubar); #if wxUSE_GRID m_Grid = new wxExGrid(m_Notebook); #endif m_ListView = new wxExListView(m_Notebook, wxExListView::LIST_NONE); GetManager().AddPane(m_Notebook, wxAuiPaneInfo().CenterPane().MinSize(wxSize(250, 250))); GetManager().AddPane(m_STC, wxAuiPaneInfo().Bottom().Caption("STC")); GetManager().AddPane(m_Shell, wxAuiPaneInfo().Bottom().Caption("Shell").MinSize(wxSize(250, 250))); GetManager().AddPane(m_Process->GetShell(), wxAuiPaneInfo() .Bottom() .Name("PROCESS") .MinSize(250, 100) .Caption(_("Process"))); GetManager().Update(); m_Notebook->AddPage(m_STCLexers, wxExLexers::Get()->GetFileName().GetFullName()); m_Notebook->AddPage(m_ListView, "wxExListView"); #if wxUSE_GRID m_Notebook->AddPage(m_Grid, "wxExGrid"); m_Grid->CreateGrid(0, 0); m_Grid->AppendCols(2); wxExSampleDir dir(wxGetCwd().ToStdString(), "*.*", m_Grid); dir.FindFiles(); m_Grid->AutoSizeColumns(); #endif m_ListView->SetSingleStyle(wxLC_REPORT); m_ListView->AppendColumn(wxExColumn("String", wxExColumn::COL_STRING)); m_ListView->AppendColumn(wxExColumn("Number", wxExColumn::COL_INT)); m_ListView->AppendColumn(wxExColumn("Float", wxExColumn::COL_FLOAT)); m_ListView->AppendColumn(wxExColumn("Date", wxExColumn::COL_DATE)); const int items = 50; for (auto i = 0; i < items; i++) { m_ListView->InsertItem(i, wxString::Format("item%d", i)); m_ListView->SetItem(i, 1, std::to_string(i)); m_ListView->SetItem(i, 2, wxString::Format("%f", (float)i / 2.0)); m_ListView->SetItem(i, 3, wxDateTime::Now().FormatISOCombined(' ')); // Set some images. if (i == 0) m_ListView->SetItemImage(i, wxART_CDROM); else if (i == 1) m_ListView->SetItemImage(i, wxART_REMOVABLE); else if (i == 2) m_ListView->SetItemImage(i, wxART_FOLDER); else if (i == 3) m_ListView->SetItemImage(i, wxART_FOLDER_OPEN); else if (i == 4) m_ListView->SetItemImage(i, wxART_GO_DIR_UP); else if (i == 5) m_ListView->SetItemImage(i, wxART_EXECUTABLE_FILE); else if (i == 6) m_ListView->SetItemImage(i, wxART_NORMAL_FILE); else m_ListView->SetItemImage(i, wxART_TICK_MARK); } #if wxUSE_STATUSBAR SetupStatusBar(std::vector<wxExStatusBarPane>{ wxExStatusBarPane(), wxExStatusBarPane("PaneFileType", 50, "File type"), wxExStatusBarPane("PaneInfo", 100, "Lines or items"), wxExStatusBarPane("PaneLexer", 60, "Lexer")}); #endif GetToolBar()->AddControls(); GetOptionsToolBar()->AddControls(); // The OnCommand keeps statistics. Bind(wxEVT_MENU, &wxExSampleFrame::OnCommand, this, wxID_COPY); Bind(wxEVT_MENU, &wxExSampleFrame::OnCommand, this, wxID_CUT); Bind(wxEVT_MENU, &wxExSampleFrame::OnCommand, this, wxID_EXECUTE); Bind(wxEVT_MENU, &wxExSampleFrame::OnCommand, this, wxID_JUMP_TO); Bind(wxEVT_MENU, &wxExSampleFrame::OnCommand, this, wxID_PASTE); Bind(wxEVT_MENU, &wxExSampleFrame::OnCommand, this, wxID_OPEN, wxID_SAVEAS); Bind(wxEVT_MENU, &wxExSampleFrame::OnCommand, this, wxID_UNDO, wxID_REDO); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { wxAboutDialogInfo info; info.SetIcon(GetIcon()); info.SetVersion(wxExGetVersionInfo().GetVersionOnlyString()); info.SetCopyright(wxExGetVersionInfo().GetCopyright()); wxAboutBox(info);}, wxID_ABOUT); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { Close(true);}, wxID_EXIT); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { m_ListView->Print();}, wxID_PRINT); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { m_ListView->PrintPreview();}, wxID_PREVIEW); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { wxExPrinting::Get()->GetHtmlPrinter()->PageSetup();}, wxID_PRINT_SETUP); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { const long val = wxGetNumberFromUser("Input columns:", wxEmptyString, _("Columns"), 1, 1, 100); if (val >= 0) { wxExItemDialog(this, TestConfigItems(0, val), "Config Dialog Columns", 0, val).ShowModal(); }}, ID_DLG_CONFIG_ITEM_COL); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { wxExItemDialog* dlg = new wxExItemDialog(this, TestConfigItems(0, 1), "Config Dialog", 0, 1, wxAPPLY | wxCANCEL, wxID_ANY, wxDefaultPosition, #ifdef __WXMSW__ wxSize(500, 500)); #else wxSize(600, 600)); #endif // dlg->ForceCheckBoxChecked("Group", "Checkboxes"); dlg->Show();}, ID_DLG_CONFIG_ITEM);
bool PGM_KICAD::OnPgmInit( wxApp* aWxApp ) { m_wx_app = aWxApp; // first thing. wxString absoluteArgv0 = wxStandardPaths::Get().GetExecutablePath(); if( !wxIsAbsolutePath( absoluteArgv0 ) ) { wxLogError( wxT( "No meaningful argv[0]" ) ); return false; } // Set LIB_ENV_VAR *before* loading the KIFACE DSOs, in case they have hard // dependencies on subsidiary DSOs below it. set_lib_env_var( absoluteArgv0 ); if( !initPgm() ) return false; m_bm.Init(); // Add search paths to feed the PGM_KICAD::SysSearch() function, // currenly limited in support to only look for project templates { SEARCH_STACK bases; SystemDirsAppend( &bases ); // DBG( bases.Show( (std::string(__func__) + " bases").c_str() );) for( unsigned i = 0; i < bases.GetCount(); ++i ) { wxFileName fn( bases[i], wxEmptyString ); // Add KiCad template file path to search path list. fn.AppendDir( wxT( "template" ) ); m_bm.m_search.AddPaths( fn.GetPath() ); } //DBG( m_bm.m_search.Show( (std::string( __func__ ) + " SysSearch()").c_str() );) } // Must be called before creating the main frame in order to // display the real hotkeys in menus or tool tips extern struct EDA_HOTKEY_CONFIG kicad_Manager_Hokeys_Descr[]; ReadHotkeyConfig( KICAD_MANAGER_FRAME_NAME, kicad_Manager_Hokeys_Descr ); KICAD_MANAGER_FRAME* frame = new KICAD_MANAGER_FRAME( NULL, wxT( "KiCad" ), wxDefaultPosition, wxDefaultSize ); App().SetTopWindow( frame ); Kiway.SetTop( frame ); bool prjloaded = false; // true when the project is loaded if( App().argc > 1 ) frame->SetProjectFileName( App().argv[1] ); else if( GetFileHistory().GetCount() ) { wxString last_pro = GetFileHistory().GetHistoryFile( 0 ); if( !wxFileExists( last_pro ) ) { GetFileHistory().RemoveFileFromHistory( 0 ); wxFileName namelessProject( wxStandardPaths::Get().GetDocumentsDir(), NAMELESS_PROJECT, ProjectFileExtension ); frame->SetProjectFileName( namelessProject.GetFullPath() ); } else { // Try to open the last opened project, // if a project name is not given when starting Kicad frame->SetProjectFileName( last_pro ); wxCommandEvent cmd( 0, wxID_FILE1 ); frame->OnFileHistory( cmd ); prjloaded = true; // OnFileHistory() loads the project } } else // there is no history { wxFileName namelessProject( wxStandardPaths::Get().GetDocumentsDir(), NAMELESS_PROJECT, ProjectFileExtension ); frame->SetProjectFileName( namelessProject.GetFullPath() ); } if( !prjloaded ) { wxCommandEvent cmd( 0, wxID_ANY ); frame->OnLoadProject( cmd ); } frame->Show( true ); frame->Raise(); return true; }
Frame::Frame() : wxExFrameWithHistory(nullptr, wxID_ANY, wxTheApp->GetAppDisplayName()) , m_Results(new wxExGrid(this)) , m_Query(new wxExSTC(this)) , m_Shell(new wxExShell(this, "", ";", true, 50)) { SetIcon(wxICON(app)); wxExMenu* menuFile = new wxExMenu; menuFile->Append(wxID_NEW); menuFile->Append(wxID_OPEN); GetFileHistory().UseMenu(ID_RECENTFILE_MENU, menuFile); menuFile->AppendSeparator(); menuFile->Append(wxID_SAVE); menuFile->Append(wxID_SAVEAS); menuFile->AppendSeparator(); menuFile->Append(wxID_EXIT); wxExMenu* menuDatabase = new wxExMenu; menuDatabase->Append(ID_DATABASE_OPEN, wxExEllipsed(_("&Open"))); menuDatabase->Append(ID_DATABASE_CLOSE, _("&Close")); wxExMenu* menuQuery = new wxExMenu; menuQuery->Append(wxID_EXECUTE); menuQuery->Append(wxID_STOP); wxMenu* menuOptions = new wxMenu(); menuOptions->Append(wxID_PREFERENCES); wxExMenu* menuView = new wxExMenu(); AppendPanes(menuView); menuView->AppendSeparator(); menuView->AppendCheckItem(ID_VIEW_QUERY, _("Query")); menuView->AppendCheckItem(ID_VIEW_RESULTS, _("Results")); menuView->AppendCheckItem(ID_VIEW_STATISTICS, _("Statistics")); wxMenu* menuHelp = new wxMenu(); menuHelp->Append(wxID_ABOUT); wxMenuBar *menubar = new wxMenuBar; menubar->Append(menuFile, wxGetStockLabel(wxID_FILE)); menubar->Append(menuView, _("&View")); menubar->Append(menuDatabase, _("&Connection")); menubar->Append(menuQuery, _("&Query")); menubar->Append(menuOptions, _("&Options")); menubar->Append(menuHelp, wxGetStockLabel(wxID_HELP)); SetMenuBar(menubar); m_Results->CreateGrid(0, 0); m_Results->EnableEditing(false); // this is a read-only grid m_Shell->SetFocus(); #if wxUSE_STATUSBAR SetupStatusBar(std::vector<wxExStatusBarPane>{ wxExStatusBarPane(), wxExStatusBarPane("PaneInfo", 100, _("Lines"))}); #endif GetToolBar()->AddControls(false); // no realize yet GetToolBar()->AddTool(wxID_EXECUTE, wxEmptyString, wxArtProvider::GetBitmap( wxART_GO_FORWARD, wxART_TOOLBAR, GetToolBar()->GetToolBitmapSize()), wxGetStockLabel(wxID_EXECUTE, wxSTOCK_NOFLAGS)); GetToolBar()->Realize(); GetManager().AddPane(m_Shell, wxAuiPaneInfo(). Name("CONSOLE"). CenterPane()); GetManager().AddPane(m_Results, wxAuiPaneInfo(). Name("RESULTS"). Caption(_("Results")). CloseButton(true). Bottom(). MaximizeButton(true)); GetManager().AddPane(m_Query, wxAuiPaneInfo(). Name("QUERY"). Caption(_("Query")). CloseButton(true). MaximizeButton(true)); GetManager().AddPane(m_Statistics.Show(this), wxAuiPaneInfo().Left(). Hide(). MaximizeButton(true). Caption(_("Statistics")). Name("STATISTICS")); GetManager().LoadPerspective(wxConfigBase::Get()->Read("Perspective")); GetManager().GetPane("QUERY").Show(false); GetManager().Update(); Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& event) { if (wxExFileDialog(this, &m_Query->GetFile()).ShowModalIfChanged() != wxID_CANCEL) { wxConfigBase::Get()->Write("Perspective", GetManager().SavePerspective()); event.Skip(); }}); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { wxAboutDialogInfo info; info.SetIcon(GetIcon()); info.SetDescription(_("This program offers a general ODBC query.")); info.SetVersion(wxExGetVersionInfo().GetVersionOnlyString()); info.SetCopyright(wxExGetVersionInfo().GetCopyright()); info.AddDeveloper(wxExOTL::VersionInfo().GetVersionString()); wxAboutBox(info); }, wxID_ABOUT); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { m_Stopped = false; if (m_Query->GetText().empty()) return; if (m_Results->IsShown()) { m_Results->ClearGrid(); } // Skip sql comments. std::regex re("--.*$"); wxString output = std::regex_replace(m_Query->GetText().ToStdString(), re, "", std::regex_constants::format_sed); // Queries are seperated by ; character. wxStringTokenizer tkz(output, ";"); int no_queries = 0; m_Running = true; const auto start = std::chrono::system_clock::now(); // Run all queries. while (tkz.HasMoreTokens() && !m_Stopped) { wxString query = tkz.GetNextToken(); query.Trim(true); query.Trim(false); if (!query.empty()) { try { RunQuery(query, no_queries == 0); no_queries++; } catch (otl_exception& p) { m_Statistics.Inc(_("Number of query errors")); m_Shell->AppendText( _("\nerror: ") + wxString(wxExQuoted(p.msg)) + _(" in: ") + wxString(wxExQuoted(query))); } } } const auto end = std::chrono::system_clock::now(); const auto elapsed = end - start; const auto milli = std::chrono::duration_cast<std::chrono::milliseconds>(elapsed); m_Shell->Prompt(wxString::Format(_("\n%d queries (%.3f seconds)"), no_queries, (float)milli.count() / (float)1000).ToStdString()); m_Running = false;}, wxID_EXECUTE); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { Close(true);}, wxID_EXIT); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { m_Query->GetFile().FileNew(wxExFileName()); m_Query->SetFocus(); ShowPane("QUERY");}, wxID_NEW); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { wxExOpenFilesDialog( this, wxFD_OPEN | wxFD_CHANGE_DIR, "sql files (*.sql)|*.sql|" + _("All Files") + wxString::Format(" (%s)|%s", wxFileSelectorDefaultWildcardStr, wxFileSelectorDefaultWildcardStr), true);}, wxID_OPEN); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { m_Query->GetFile().FileSave();}, wxID_SAVE); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { wxExFileDialog dlg( this, &m_Query->GetFile(), wxGetStockLabel(wxID_SAVEAS), wxFileSelectorDefaultWildcardStr, wxFD_SAVE); if (dlg.ShowModal() == wxID_OK) { m_Query->GetFile().FileSave(dlg.GetPath().ToStdString()); }}, wxID_SAVEAS); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { m_Running = false; m_Stopped = true;}, wxID_STOP); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { if (m_otl.Logoff()) { m_Shell->SetPrompt(">"); }}, ID_DATABASE_CLOSE); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { if (m_otl.Logon(this)) { m_Shell->SetPrompt(m_otl.Datasource().ToStdString() + ">"); }}, ID_DATABASE_OPEN); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { if (m_otl.IsConnected()) { try { const wxString input(event.GetString()); if (!input.empty()) { const wxString query = input.substr( 0, input.length() - 1); m_Stopped = false; RunQuery(query, true); } } catch (otl_exception& p) { if (m_Results->IsShown()) { m_Results->EndBatch(); } m_Shell->AppendText(_("\nerror: ") + wxString(wxExQuoted(p.msg))); } } else { m_Shell->AppendText(_("\nnot connected")); } m_Shell->Prompt();}, ID_SHELL_COMMAND); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { m_Stopped = true; m_Shell->Prompt("cancelled");}, ID_SHELL_COMMAND_STOP); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { TogglePane("QUERY");}, ID_VIEW_QUERY); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { TogglePane("RESULTS");}, ID_VIEW_RESULTS); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { TogglePane("STATISTICS");}, ID_VIEW_STATISTICS); Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) { event.Enable(m_Query->GetModify());}, wxID_SAVE); Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) { event.Enable(m_Query->GetLength() > 0);}, wxID_SAVEAS); Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) { event.Enable(m_Running);}, wxID_STOP); Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) { event.Enable(m_otl.IsConnected());}, ID_DATABASE_CLOSE); Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) { event.Enable(!m_otl.IsConnected());}, ID_DATABASE_OPEN); Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) { // If we have a query, you can hide it, but still run it. event.Enable(m_Query->GetLength() > 0 && m_otl.IsConnected());}, wxID_EXECUTE); Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) { event.Enable(!GetFileHistory().GetHistoryFile().empty());}, ID_RECENTFILE_MENU); Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) { event.Check(GetManager().GetPane("QUERY").IsShown());}, ID_VIEW_QUERY); Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) { event.Check(GetManager().GetPane("RESULTS").IsShown());}, ID_VIEW_RESULTS); Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& event) { event.Check(GetManager().GetPane("STATISTICS").IsShown());}, ID_VIEW_STATISTICS); // Do automatic connect. if (!m_otl.Datasource().empty() && m_otl.Logon()) { m_Shell->SetPrompt(m_otl.Datasource().ToStdString() + ">"); } else { m_Shell->SetPrompt(">"); } }
bool ctApp::OnInit(void) { #if wxUSE_LOG wxLog::SetTimestamp(NULL); #endif // wxUSE_LOG wxHelpProvider::Set(new wxSimpleHelpProvider); #if wxUSE_LIBPNG wxImage::AddHandler( new wxPNGHandler ); #endif #if wxUSE_LIBJPEG wxImage::AddHandler( new wxJPEGHandler ); #endif #if wxUSE_GIF wxImage::AddHandler( new wxGIFHandler ); #endif #if wxUSE_MS_HTML_HELP && !defined(__WXUNIVERSAL__) m_helpController = new wxCHMHelpController; m_helpControllerReference = new wxCHMHelpController; #else m_helpController = new wxHtmlHelpController; m_helpControllerReference = new wxHtmlHelpController; #endif // Required for HTML help #if wxUSE_STREAMS && wxUSE_ZIPSTREAM && wxUSE_ZLIB wxFileSystem::AddHandler(new wxZipFSHandler); #endif wxString currentDir = wxGetCwd(); // Use argv to get current app directory wxString argv0(argv[0]); wxString appVariableName(wxT("WXCONFIGTOOLDIR")); m_appDir = apFindAppPath(argv0, currentDir, appVariableName); #ifdef __WXMSW__ // If the development version, go up a directory. if ((m_appDir.Right(5).CmpNoCase(_T("DEBUG")) == 0) || (m_appDir.Right(11).CmpNoCase(_T("DEBUGSTABLE")) == 0) || (m_appDir.Right(7).CmpNoCase(_T("RELEASE")) == 0) || (m_appDir.Right(13).CmpNoCase(_T("RELEASESTABLE")) == 0) || (m_appDir.Right(10).CmpNoCase(_T("RELEASEDEV")) == 0) || (m_appDir.Right(8).CmpNoCase(_T("DEBUGDEV")) == 0) ) m_appDir = wxPathOnly(m_appDir); #endif m_docManager = new wxDocManager; m_docManager->SetMaxDocsOpen(1); //// Create a template relating documents to their views (void) new wxDocTemplate(m_docManager, wxGetApp().GetSettings().GetShortAppName(), wxT("*.wxs"), wxT(""), wxT("wxs"), wxT("Doc"), wxT("View"), CLASSINFO(ctConfigToolDoc), CLASSINFO(ctConfigToolView)); m_settings.Init(); LoadConfig(); wxString helpFilePathReference(GetFullAppPath(_("wx"))); m_helpControllerReference->Initialize(helpFilePathReference); wxString helpFilePath(GetFullAppPath(_("configtool"))); m_helpController->Initialize(helpFilePath); ctMainFrame* frame = new ctMainFrame(m_docManager, NULL, wxID_ANY, wxGetApp().GetSettings().GetAppName(), GetSettings().m_frameSize.GetPosition(), GetSettings().m_frameSize.GetSize(), wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN); SetTopWindow(frame); switch (wxGetApp().GetSettings().m_frameStatus) { case ctSHOW_STATUS_MAXIMIZED: { frame->Maximize(true); break; } case ctSHOW_STATUS_MINIMIZED: { frame->Iconize(true); break; } default: case ctSHOW_STATUS_NORMAL: { break; } } // Load the file history. This has to be done AFTER the // main frame has been created, so that the items // will get appended to the file menu. { wxConfig config(wxGetApp().GetSettings().GetAppName(), wxT("Generic Organisation")); GetFileHistory().Load(config); } if (argc > 1) { // Concatenate strings since it could have spaces (and quotes) wxString arg; int i; for (i = 1; i < argc; i++) { arg += argv[i]; if (i < (argc - 1)) arg += wxString(wxT(" ")); } if (arg[0u] == '"') arg = arg.Mid(1); if (arg.Last() == '"') arg = arg.Mid(0, arg.Len() - 1); // Load the file wxDocument* doc = m_docManager->CreateDocument(arg, wxDOC_SILENT); if (doc) doc->SetDocumentSaved(true); } else { if (GetSettings().m_loadLastDocument) { // Load the file that was last loaded wxDocument* doc = m_docManager->CreateDocument(GetSettings().m_lastFilename, wxDOC_SILENT); if (doc) doc->SetDocumentSaved(true); } } GetTopWindow()->Show(true); return true; }