MyFrame::MyFrame( wxWindow* parent ) : elMFrame( parent ),oConfig(0) { wxInitAllImageHandlers(); strIntConf.ulMaxMenuTasks = MAX_DYN_MENU_ITEMS; strIntConf.ulMaxTools = MAX_TOOLS; ulTimeQuant = TIME_QUANT; loadCfg(); Connect(elTHREAD_MSG, wxEVT_USER_FIRST, wxCommandEventHandler( MyFrame::onThreadMsg)); Connect( elTHREAD_LIFECYCLE , wxEVT_USER_FIRST, wxCommandEventHandler( MyFrame::onThreadLC)); Connect( NEW_TASK , wxEVT_USER_FIRST, wxCommandEventHandler( MyFrame::onNewTask)); Connect( 0, wxEVT_USER_FIRST + 1, //TODO wxCommandEventHandler( MyFrame::onExecReq)); Connect( mID_USEDTASKS, mID_USEDTASKS+strIntConf.ulMaxMenuTasks, wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( MyFrame::onDynTask) ); Connect( strIntConf.ulIDTools, strIntConf.ulIDTools+strIntConf.ulMaxTools, wxEVT_COMMAND_TOOL_CLICKED, wxMenuEventHandler( MyFrame::onToolClick) ); Connect( strIntConf.ulIDTools, strIntConf.ulIDTools+strIntConf.ulMaxTools, wxEVT_COMMAND_TOOL_RCLICKED, wxMenuEventHandler( MyFrame::onToolRClick) ); Connect( ID_EDIT_TOOL, wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( MyFrame::onEditTool) ); Connect( ID_REMOVE_TOOL, wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( MyFrame::onRemoveTool) ); counter = 0; loadHandlers(); pocessHandlers(strIntConf.mapHandlersToUse); }
SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::SIGNAL_CONTEXT_MENU( const wxString& aSignal, SIM_PLOT_FRAME* aPlotFrame ) : m_signal( aSignal ), m_plotFrame( aPlotFrame ) { SIM_PLOT_PANEL* plot = m_plotFrame->CurrentPlot(); AddMenuItem( this, HIDE_SIGNAL, _( "Hide Signal" ), _( "Erase the signal from plot screen" ), KiBitmap( delete_xpm ) ); TRACE* trace = plot->GetTrace( m_signal ); if( trace->HasCursor() ) AddMenuItem( this, HIDE_CURSOR, _( "Hide Cursor" ), KiBitmap( pcb_target_xpm ) ); else AddMenuItem( this, SHOW_CURSOR, _( "Show Cursor" ), KiBitmap( pcb_target_xpm ) ); Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( SIGNAL_CONTEXT_MENU::onMenuEvent ), NULL, this ); }
CSpyUserPanel::CSpyUserPanel(const SBeatsSocket* pSockInfo, HMODULE hSpyDLLHandle, wxWindow *parent, wxWindowID winid /*= wxID_ANY*/, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/, long style /*= wxTAB_TRAVERSAL | wxNO_BORDER*/, const wxString& name /*= wxPanelNameStr*/ ) : super(parent, winid, pos, size, style, name) , m_pSocketInfo(pSockInfo) , m_pDiskInfoCache(NULL) , m_pRootDirectoryCache(NULL) , m_hSpyDllHandle(hSpyDLLHandle) , m_uCurSelectHistoryIndex(0) { BEATS_ASSERT(hSpyDLLHandle != NULL, _T("Invalid spy dll handle!")); wxBoxSizer* pUserPanelSizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* pLeftSizer = new wxBoxSizer(wxVERTICAL); wxStaticBoxSizer* pInfoSizer = new wxStaticBoxSizer(wxVERTICAL, this, _T("详细信息")); sockaddr_in sockaddrInfo; int nSize = sizeof(sockaddrInfo); bool bGetPeerSuccess = SOCKET_ERROR != ::getpeername(pSockInfo->m_socket, (sockaddr*)(&sockaddrInfo), &nSize); m_pPeerAddrLabel = new wxStaticText(this, wxID_ANY, bGetPeerSuccess ? wxString::Format(_T("节点地址: %s:%d"), inet_ntoa(sockaddrInfo.sin_addr), sockaddrInfo.sin_port): wxString(_T("节点地址:获取失败"))); pInfoSizer->Add(m_pPeerAddrLabel, 0, wxEXPAND, 0); m_pPeerNameLabel = new wxStaticText(this, wxID_ANY, _T("节点名称: Unknown")); pInfoSizer->Add(m_pPeerNameLabel, 0, wxEXPAND, 0); FILETIME fileTime; SYSTEMTIME sysTime; GetLocalTime(&sysTime); SystemTimeToFileTime(&sysTime, &fileTime); ULARGE_INTEGER curTimeLarge; memcpy(&curTimeLarge, &fileTime, sizeof(curTimeLarge)); curTimeLarge.QuadPart = curTimeLarge.QuadPart - GetTickCount() + m_pSocketInfo->m_uCreateTime; memcpy(&fileTime, &curTimeLarge, sizeof(fileTime)); FileTimeToSystemTime(&fileTime, & sysTime); m_pConnectTimeInfoLabel = new wxStaticText(this, wxID_ANY, wxString::Format(_T("连接建立时间: %d:%d.%d.%d"), sysTime.wHour, sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds)); pInfoSizer->Add(m_pConnectTimeInfoLabel, 0, wxEXPAND, 0); m_pCurrentStateLabel = new wxStaticText(this, wxID_ANY, _T("当前状态: 空闲")); pInfoSizer->Add(m_pCurrentStateLabel, 0, wxEXPAND, 0); m_pUploadSpeedLabel = new wxStaticText(this, wxID_ANY, _T("上传速度: 0 kb/s")); pInfoSizer->Add(m_pUploadSpeedLabel, 0, wxEXPAND, 0); m_pUploadDataCountLabel = new wxStaticText(this, wxID_ANY, _T("上传数据量: 0 bytes")); pInfoSizer->Add(m_pUploadDataCountLabel, 0, wxEXPAND, 0); m_pDownloadSpeedLabel = new wxStaticText(this, wxID_ANY, _T("下载速度: 0 kb/s")); pInfoSizer->Add(m_pDownloadSpeedLabel, 0, wxEXPAND, 0); m_pDownloadDataCountLabel = new wxStaticText(this, wxID_ANY, _T("下载数据量: 0 bytes")); pInfoSizer->Add(m_pDownloadDataCountLabel, 0, wxEXPAND, 0); wxStaticBoxSizer* pSpyConsoleSizer = new wxStaticBoxSizer(wxVERTICAL, this, _T("命令控制台")); m_pConsoleTextCtrl = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP); pSpyConsoleSizer->Add(m_pConsoleTextCtrl, 1, wxEXPAND, 0); m_pConsoleInputTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_NO_VSCROLL | wxTE_PROCESS_ENTER ); m_pConsoleInputTextCtrl->SetMaxLength( 256 ); pSpyConsoleSizer->Add( m_pConsoleInputTextCtrl, 0, wxEXPAND, 5 ); pInfoSizer->Add(pSpyConsoleSizer, 1, wxEXPAND, 0); pLeftSizer->Add(pInfoSizer, 1, wxEXPAND, 0); pUserPanelSizer->Add(pLeftSizer, 1, wxEXPAND, 0); wxBoxSizer* pRightSizer = new wxBoxSizer(wxVERTICAL); pUserPanelSizer->Add(pRightSizer, 1, wxEXPAND, 0); wxStaticBoxSizer* pSpyFuncSizer = new wxStaticBoxSizer(wxVERTICAL, this, _T("功能区")); wxBoxSizer* pCommandExecutionSizer = new wxBoxSizer(wxHORIZONTAL); m_pExecuteCommandButton = new wxButton(this, wxID_ANY, _T("执行")); m_pCommandChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, eSCT_Count, Command_Type_String, 0 ); m_pCommandChoice->SetSelection( 0 ); pCommandExecutionSizer->Add(m_pCommandChoice, 1, wxEXPAND, 0); pCommandExecutionSizer->Add(m_pExecuteCommandButton, 0, wxEXPAND, 0); pSpyFuncSizer->Add(pCommandExecutionSizer, 0, wxEXPAND, 0); wxStaticBoxSizer* pFileExplorerSizer = new wxStaticBoxSizer(wxVERTICAL, this, _T("远程文件")); wxBoxSizer* pFileLocationSizer = new wxBoxSizer(wxHORIZONTAL); wxStaticText* pFileLocationLabel = new wxStaticText(this, wxID_ANY, _T("地址")); pFileLocationSizer->Add(pFileLocationLabel, 0, wxALIGN_CENTER | wxALL, 0); m_pFileLocationText = new wxTextCtrl(this, wxID_ANY); pFileLocationSizer->Add(m_pFileLocationText, 1, wxEXPAND | wxLEFT | wxRIGHT , 5); m_pRefreshFileInfoButton = new wxButton(this, wxID_ANY, _T("刷新")); pFileLocationSizer->Add(m_pRefreshFileInfoButton, 0, wxALIGN_CENTER | wxALL, 0); pFileExplorerSizer->Add(pFileLocationSizer, 0, wxEXPAND, 0); m_pRemoteFileCtrl = new CVirtualFileCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT); pFileExplorerSizer->Add(m_pRemoteFileCtrl, 1, wxEXPAND, 5); pRightSizer->Add(pSpyFuncSizer, 0, wxEXPAND, 0); pRightSizer->Add(pFileExplorerSizer, 1, wxEXPAND, 0); this->SetSizer(pUserPanelSizer); m_pConsoleInputTextCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( CSpyUserPanel::OnSpyConsoleCommandEnter ), NULL, this ); m_pConsoleInputTextCtrl->Connect( wxEVT_KEY_UP, wxKeyEventHandler( CSpyUserPanel::OnSpyConsoleCommandKeypress), NULL, this ); m_pExecuteCommandButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSpyUserPanel::OnSpyCommandExecuteBtnClick ), NULL, this ); m_pRemoteFileCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CSpyUserPanel::OnSpyFileItemActivated), NULL, this); m_pRemoteFileCtrl->Connect(wxEVT_CONTEXT_MENU, wxContextMenuEventHandler(CSpyUserPanel::OnSpyRightClickFileCtrl), NULL, this); this->Connect(wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler(CSpyUserPanel::OnSpySelectFileCtrlMenu), NULL, this); m_pRefreshFileInfoButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSpyUserPanel::OnSpyRefreshFileBtnClick ), NULL, this ); // Do some initialize action. SendCommand("cd"); GetFileInfo(_T(""), true); }
TopLevelFrame::TopLevelFrame() : wxFrame(NULL, wxID_ANY, wxT("DarkRadiant")), _topLevelContainer(NULL), _mainContainer(NULL) { _topLevelContainer = new wxBoxSizer(wxVERTICAL); SetSizer(_topLevelContainer); wxMenuBar* menuBar = createMenuBar(); if (menuBar != nullptr) { SetMenuBar(menuBar); } // Instantiate the ToolbarManager and retrieve the view toolbar widget IToolbarManager& tbCreator = GlobalUIManager().getToolbarManager(); wxToolBar* viewToolbar = tbCreator.getToolbar("view", this); if (viewToolbar != NULL) { _toolbars[IMainFrame::TOOLBAR_HORIZONTAL] = viewToolbar; // Pack it into the main window _topLevelContainer->Add(_toolbars[IMainFrame::TOOLBAR_HORIZONTAL].get(), 0, wxEXPAND); } else { rWarning() << "TopLevelFrame: Cannot instantiate view toolbar!" << std::endl; } _mainContainer = new wxBoxSizer(wxHORIZONTAL); _topLevelContainer->Add(_mainContainer, 1, wxEXPAND); // Get the edit toolbar widget wxToolBar* editToolbar = tbCreator.getToolbar("edit", this); if (editToolbar != NULL) { _toolbars[IMainFrame::TOOLBAR_VERTICAL] = editToolbar; // Pack it into the main window _mainContainer->Add(_toolbars[IMainFrame::TOOLBAR_VERTICAL].get(), 0, wxEXPAND); } else { rWarning() << "MainFrame: Cannot instantiate edit toolbar!" << std::endl; } wxWindow* statusBar = GlobalUIManager().getStatusBarManager().getStatusBar(); statusBar->Reparent(this); statusBar->SetCanFocus(false); _topLevelContainer->Add(statusBar, 0, wxEXPAND); // Set the window icon wxIcon appIcon; appIcon.CopyFromBitmap(wxArtProvider::GetBitmap( GlobalUIManager().ArtIdPrefix() + "darkradiant_icon_64x64.png")); SetIcon(appIcon); // Redirect scroll events to the window below the cursor _scrollEventFilter.reset(new wxutil::ScrollEventPropagationFilter); #if (wxMAJOR_VERSION >= 3) && (wxMINOR_VERSION < 1) // In wxWidgets < 3.1.0 we don't receive the wxEVT_MENU_OPEN event on // the menu itself (only on the toplevel frame), so let's propagate it Connect(wxEVT_MENU_OPEN, wxMenuEventHandler(TopLevelFrame::onMenuOpenClose), nullptr, this); #endif }
void CONTEXT_MENU::setupEvents() { Connect( wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); }