static void OnExitMenuLoop(HWND hWnd) { bInMenuLoop = FALSE; /* Update the status bar pane sizes*/ SetupStatusBar(hWnd, TRUE); UpdateStatusBar(); }
static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { WCHAR empty = 0; WNDCLASSEXW wndclass = {0}; /* Frame class */ wndclass.cbSize = sizeof(WNDCLASSEXW); wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = FrameWndProc; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT)); wndclass.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW); wndclass.lpszClassName = szFrameClass; wndclass.hIconSm = LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); RegisterClassExW(&wndclass); /* Child class */ wndclass.lpfnWndProc = ChildWndProc; wndclass.cbWndExtra = sizeof(HANDLE); wndclass.lpszClassName = szChildClass; RegisterClassExW(&wndclass); hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU)); hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS)); /* Initialize the Windows Common Controls DLL */ InitCommonControls(); /* register our hex editor control */ HexEdit_Register(); nClipboardFormat = RegisterClipboardFormatW(strClipboardFormat); hFrameWnd = CreateWindowExW(0, szFrameClass, szTitle, WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, hMenuFrame, hInstance, NULL/*lpParam*/); if (!hFrameWnd) { return FALSE; } /* Create the status bar */ hStatusBar = CreateStatusWindowW(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, &empty, hFrameWnd, STATUS_WINDOW); if (hStatusBar) { /* Create the status bar panes */ SetupStatusBar(hFrameWnd, FALSE); CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED); } ShowWindow(hFrameWnd, nCmdShow); UpdateWindow(hFrameWnd); return TRUE; }
MainWindow::MainWindow(QWidget *parent, QPointer<LogViewer> log) : QMainWindow(parent), ui(new Ui::MainWindow), logWindow(log), connectControl(0), servoControl(0), port(0) { ui->setupUi(this); SetupLayout(); SetupStatusBar(); }
frmDebugger::frmDebugger(frmMain *_parent, dbgController *_controller, const wxString &_title) : pgFrame(_parent, _title), m_menuBar(NULL), m_toolBar(NULL), m_viewMenu(NULL), m_debugMenu(NULL), m_statusBar(NULL), m_parent(_parent), m_controller(_controller), m_stackWindow(NULL), m_tabWindow(NULL), m_codeViewer(NULL) { dlgName = wxT("frmDebugger"); RestorePosition(100, 100, 600, 500, 450, 300); SetFont(settings->GetSystemFont()); m_manager.SetManagedWindow(this); m_manager.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_TRANSPARENT_DRAG); // Define the icon for this window SetIcon(*debugger_png_ico); // Create (and configure) the menu bar, toolbar, and status bar m_menuBar = SetupMenuBar(); m_toolBar = SetupToolBar(); m_statusBar = SetupStatusBar(); m_manager.AddPane( m_toolBar, wxAuiPaneInfo().Name(wxT("toolBar")).Caption(wxT("Toolbar")) .ToolbarPane().Top().Row(1).Position(1).LeftDockable(false) .RightDockable(false)); // Now load the layout wxString perspective; settings->Read( wxT("Debugger/frmDebugger/Perspective-") + wxString(FRMDEBUGGER_PERSPECTIVE_VER), &perspective, FRMDEBUGGER_DEFAULT_PERSPECTIVE); m_manager.LoadPerspective(perspective, true); // and reset the captions for the current language m_manager.GetPane(wxT("toolBar")).Caption(_("Toolbar")); // Sync the View menu options m_viewMenu->Check(MENU_ID_VIEW_TOOLBAR, m_manager.GetPane(wxT("toolBar")).IsShown()); SetupDebugger(); m_manager.Update(); }
static void resize_frame_rect(HWND hWnd, PRECT prect) { RECT rt; /* if (IsWindowVisible(hToolBar)) { SendMessage(hToolBar, WM_SIZE, 0, 0); GetClientRect(hToolBar, &rt); prect->top = rt.bottom+3; prect->bottom -= rt.bottom+3; } */ if (IsWindowVisible(hStatusBar)) { SetupStatusBar(hWnd, TRUE); GetClientRect(hStatusBar, &rt); prect->bottom -= rt.bottom; } MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE); }
LRESULT MainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { SetupCmdBar(); SetupRibbonBar(); SetupToolbar(); SetupMRUList(); SetupStatusBar(); SetupView(); // register object for message filtering and idle updates CMessageLoop* pLoop = _Module.GetMessageLoop(); ATLASSERT(pLoop != NULL); pLoop->AddMessageFilter(this); pLoop->AddIdleHandler(this); { bool bRibbonUI = RunTimeHelper::IsRibbonUIAvailable(); ShowRibbonUI(bRibbonUI); UISetCheck(ID_VIEW_RIBBON, bRibbonUI); } if (m_cszFilenameOpenAtStart.IsEmpty()) DoFileNew(); else { CString cszTitle = Path(m_cszFilenameOpenAtStart).FilenameAndExt(); if (DoFileOpen(m_cszFilenameOpenAtStart, cszTitle)) { m_mru.AddToList(m_cszFilenameOpenAtStart); m_mru.WriteToRegistry(c_pszSettingsRegkey); } } UIEnable(ID_SCRIPT_RUN, true); UIEnable(ID_SCRIPT_STOP, false); return 0; }
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);
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(">"); } }
Frame::Frame() : wxExFrameWithHistory(NULL, wxID_ANY, wxTheApp->GetAppDisplayName()) , m_Running(false) , m_Stopped(false) { SetIcon(wxICON(app)); wxExMenu* menuFile = new wxExMenu; menuFile->Append(wxID_NEW); menuFile->Append(wxID_OPEN); UseFileHistory(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(); menuView->AppendBars(); 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_Query = new wxExSTCWithFrame(this, this); m_Query->SetLexer("sql"); m_Results = new wxExGrid(this); m_Results->CreateGrid(0, 0); m_Results->EnableEditing(false); // this is a read-only grid m_Shell = new wxExSTCShell(this, ">", ";", true, 50); m_Shell->SetFocus(); #if wxUSE_STATUSBAR std::vector<wxExStatusBarPane> panes; panes.push_back(wxExStatusBarPane()); panes.push_back(wxExStatusBarPane("PaneInfo", 100, _("Lines"))); SetupStatusBar(panes); #endif GetManager().AddPane(m_Shell, wxAuiPaneInfo(). Name("CONSOLE"). CenterPane()); GetManager().AddPane(m_Results, wxAuiPaneInfo(). Name("RESULTS"). Caption(_("Results")). CloseButton(true). MaximizeButton(true)); GetManager().AddPane(m_Query, wxAuiPaneInfo(). Name("QUERY"). Caption(_("Query")). CloseButton(true). MaximizeButton(true)); GetManager().AddPane(m_Statistics.Show(this), wxAuiPaneInfo().Left(). MaximizeButton(true). Caption(_("Statistics")). Name("STATISTICS")); GetManager().LoadPerspective(wxConfigBase::Get()->Read("Perspective")); GetManager().GetPane("QUERY").Show(false); GetManager().Update(); }
wxExSampleFrame::wxExSampleFrame() : wxExManagedFrame(NULL, wxID_ANY, wxTheApp->GetAppDisplayName()) , m_FlagsSTC(0) { SetIcon(wxICON(app)); wxExMenu* menuFile = new wxExMenu; menuFile->Append(wxID_OPEN); menuFile->AppendSeparator(); menuFile->Append(ID_SHOW_VCS, "Show VCS"); menuFile->AppendPrint(); menuFile->AppendSeparator(); menuFile->Append(ID_PROCESS_SELECT, "Select Process"); menuFile->Append(ID_PROCESS_RUN, "Run Process"); 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* menuConfig = new wxExMenu; menuConfig->Append(ID_CONFIG_DLG, wxExEllipsed("Config Dialog")); menuConfig->Append( ID_CONFIG_DLG_READONLY, wxExEllipsed("Config Dialog Readonly")); wxExMenu* menuSTC = new wxExMenu; menuSTC->Append(ID_STC_FLAGS, wxExEllipsed("Open Flag")); menuSTC->AppendSeparator(); menuSTC->Append(ID_STC_CONFIG_DLG, wxExEllipsed("Config Dialog")); menuSTC->Append(ID_STC_ENTRY_DLG, wxExEllipsed("Entry Dialog")); menuSTC->AppendSeparator(); menuSTC->Append(ID_STC_SPLIT, "Split"); wxExMenu *menuView = new wxExMenu; menuView->AppendBars(); 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(menuSTC, "&STC"); menubar->Append(menuConfig, "&Config"); menubar->Append(menuHelp, "&Help"); SetMenuBar(menubar); m_Notebook = new wxExNotebook( this, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE | wxAUI_NB_SCROLL_BUTTONS); #if wxUSE_GRID m_Grid = new wxExGrid(m_Notebook); #endif m_ListView = new wxExListView(m_Notebook); m_STC = new wxExSTC(this); m_STCShell = new wxExSTCShell(this, ">", wxTextFile::GetEOL(), true, 10); GetManager().AddPane(m_Notebook, wxAuiPaneInfo().CenterPane().MinSize(wxSize(250, 250))); GetManager().AddPane(m_STC, wxAuiPaneInfo().Bottom().Caption("STC")); GetManager().AddPane(m_STCShell, wxAuiPaneInfo().Bottom().Caption("Shell").MinSize(wxSize(250, 250))); GetManager().Update(); m_STCLexers = new wxExSTC(this, wxExLexers::Get()->GetFileName()); 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(), "*.*", m_Grid); dir.FindFiles(); m_Grid->AutoSizeColumns(); #endif m_ListView->SetSingleStyle(wxLC_REPORT); m_ListView->InsertColumn(wxExColumn("String", wxExColumn::COL_STRING)); m_ListView->InsertColumn(wxExColumn("Number", wxExColumn::COL_INT)); m_ListView->InsertColumn(wxExColumn("Float", wxExColumn::COL_FLOAT)); m_ListView->InsertColumn(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, wxString::Format("%d", i)); m_ListView->SetItem(i, 2, wxString::Format("%f", (float)i / 2.0)); m_ListView->SetItem(i, 3, wxDateTime::Now().Format()); // 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 std::vector<wxExStatusBarPane> panes; panes.push_back(wxExStatusBarPane()); panes.push_back(wxExStatusBarPane("PaneFileType", 50, "File type")); panes.push_back(wxExStatusBarPane("PaneInfo", 100, "Lines or items")); panes.push_back(wxExStatusBarPane("PaneLexer", 60, "Lexer")); SetupStatusBar(panes); #endif }
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { BOOL AclUiAvailable; HMENU hEditMenu; TCHAR szBuffer[256]; WNDCLASSEX wcFrame; WNDCLASSEX wcChild; ATOM hFrameWndClass; ZeroMemory(&wcFrame, sizeof(WNDCLASSEX)); wcFrame.cbSize = sizeof(WNDCLASSEX); wcFrame.lpfnWndProc = FrameWndProc; wcFrame.hInstance = hInstance; wcFrame.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)); wcFrame.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); wcFrame.hCursor = LoadCursor(0, IDC_ARROW); wcFrame.lpszClassName = szFrameClass; hFrameWndClass = RegisterClassEx(&wcFrame); /* register frame window class */ ZeroMemory(&wcChild, sizeof(WNDCLASSEX)); wcChild.cbSize = sizeof(WNDCLASSEX); wcChild.lpfnWndProc = ChildWndProc; wcChild.cbWndExtra = sizeof(HANDLE); wcChild.hInstance = hInstance; wcChild.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)); wcChild.hCursor = LoadCursor(0, IDC_ARROW), wcChild.lpszClassName = szChildClass, wcChild.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); RegisterClassEx(&wcChild); /* register child windows class */ RegisterHexEditorClass(hInstance); hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU)); hPopupMenus = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_POPUP_MENUS)); /* Initialize the Windows Common Controls DLL */ InitCommonControls(); hEditMenu = GetSubMenu(hMenuFrame, 1); AclUiAvailable = InitializeAclUiDll(); if(!AclUiAvailable) { /* hide the Edit/Permissions... menu entry */ if(hEditMenu != NULL) { RemoveMenu(hEditMenu, ID_EDIT_PERMISSIONS, MF_BYCOMMAND); /* remove the separator after the menu item */ RemoveMenu(hEditMenu, 4, MF_BYPOSITION); } } if(hEditMenu != NULL) SetMenuDefaultItem(hEditMenu, ID_EDIT_MODIFY, MF_BYCOMMAND); nClipboardFormat = RegisterClipboardFormat(strClipboardFormat); /* if (nClipboardFormat == 0) { DWORD dwError = GetLastError(); } */ hFrameWnd = CreateWindowEx(WS_EX_WINDOWEDGE, (LPCTSTR)(UlongToPtr(hFrameWndClass)), szTitle, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, hMenuFrame, hInstance, NULL/*lpParam*/); if (!hFrameWnd) { return FALSE; } /* Create the status bar */ hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|SBT_NOBORDERS, _T(""), hFrameWnd, STATUS_WINDOW); if (hStatusBar) { /* Create the status bar panes */ SetupStatusBar(hFrameWnd, FALSE); CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED); } /* Restore position */ if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("LastKey"), szBuffer, COUNT_OF(szBuffer)) == ERROR_SUCCESS) { SelectNode(g_pChildWnd->hTreeWnd, szBuffer); } ShowWindow(hFrameWnd, nCmdShow); UpdateWindow(hFrameWnd); return TRUE; }
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { BOOL AclUiAvailable; HMENU hEditMenu; WNDCLASSEXW wcFrame; WNDCLASSEXW wcChild; ATOM hFrameWndClass; ZeroMemory(&wcFrame, sizeof(WNDCLASSEXW)); wcFrame.cbSize = sizeof(WNDCLASSEXW); wcFrame.lpfnWndProc = FrameWndProc; wcFrame.hInstance = hInstance; wcFrame.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT)); wcFrame.hIconSm = (HICON)LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); wcFrame.hCursor = LoadCursorW(NULL, IDC_ARROW); wcFrame.lpszClassName = szFrameClass; hFrameWndClass = RegisterClassExW(&wcFrame); /* register frame window class */ ZeroMemory(&wcChild, sizeof(WNDCLASSEXW)); wcChild.cbSize = sizeof(WNDCLASSEXW); wcChild.lpfnWndProc = ChildWndProc; wcChild.cbWndExtra = sizeof(HANDLE); wcChild.hInstance = hInstance; wcChild.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT)); wcChild.hCursor = LoadCursorW(NULL, IDC_ARROW); wcChild.lpszClassName = szChildClass; wcChild.hIconSm = (HICON)LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); RegisterClassExW(&wcChild); /* register child windows class */ RegisterHexEditorClass(hInstance); hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU)); hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS)); /* Initialize the Windows Common Controls DLL */ // TODO: Replace this call by InitCommonControlsEx(_something_) InitCommonControls(); hEditMenu = GetSubMenu(hMenuFrame, 1); AclUiAvailable = InitializeAclUiDll(); if(!AclUiAvailable) { /* hide the Edit/Permissions... menu entry */ if(hEditMenu != NULL) { RemoveMenu(hEditMenu, ID_EDIT_PERMISSIONS, MF_BYCOMMAND); /* remove the separator after the menu item */ RemoveMenu(hEditMenu, 4, MF_BYPOSITION); } } if(hEditMenu != NULL) SetMenuDefaultItem(hEditMenu, ID_EDIT_MODIFY, MF_BYCOMMAND); nClipboardFormat = RegisterClipboardFormatW(strClipboardFormat); /* if (nClipboardFormat == 0) { DWORD dwError = GetLastError(); } */ hFrameWnd = CreateWindowExW(WS_EX_WINDOWEDGE, (LPCWSTR)(UlongToPtr(hFrameWndClass)), szTitle, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, hMenuFrame, hInstance, NULL/*lpParam*/); if (!hFrameWnd) { return FALSE; } /* Create the status bar */ hStatusBar = CreateStatusWindowW(WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | SBT_NOBORDERS, L"", hFrameWnd, STATUS_WINDOW); if (hStatusBar) { /* Create the status bar panes */ SetupStatusBar(hFrameWnd, FALSE); CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND | MF_CHECKED); } LoadSettings(); UpdateWindow(hFrameWnd); return TRUE; }