void CActiveViewsDialog::Wire() { // Setup things connect( mCloseDialogButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( mCloseWindowButton, SIGNAL( clicked() ), this, SLOT( HandleCloseWindow() ) ); connect( mSelectWindowButton, SIGNAL( clicked() ), this, SLOT( HandleSelectWindow() ) ); connect( mSelectWindowButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); RefreshWindowsList(); }
void CActiveViewsDialog::HandleCloseWindow() { int index = mViewsListWidget->currentRow(); if ( index >= 0 ) { auto *sub_window = mSubWindows[ index ]; if ( sub_window->close() ) RefreshWindowsList(); else SimpleWarnBox( "Window " + q2a( sub_window->windowTitle() ) + " could not be closed." ); } }
/* * Method: OnToolClick() * Purpose: called when the user click on of the tools on the * toll bar * Comments: none */ void CMainWindow::OnToolClick(wxCommandEvent& aEvent) { wxTreeItemId lItem = iTree->GetSelection(); if(lItem.IsOk() && lItem != iRoot || aEvent.GetId() == ID_SEEK) { CTreeItemData* lData = (CTreeItemData *)iTree->GetItemData(lItem); switch(aEvent.GetId()) { case ID_INFO: { if(!lData->iInfo) { // create the info window CInfoWindow* lWindow = new CInfoWindow(*this,lData->iData); if(lWindow) { // keep a pointer to it lData->iInfo = lWindow; // and show the window lWindow->Show(true); } } else lData->iInfo->Raise(); break; } case ID_CTRL: { if(!lData->iCtrl) { if(!lData->iHandle) lData->iHandle = OpenCamera(lData->iData.UniqueId,lData->iOwner); if(lData->iHandle) { // create the info window CCtrlWindow* lWindow = new CCtrlWindow(*this,lData->iData,lData->iHandle,lData->iOwner); if(lWindow) { // keep a pointer to it lData->iCtrl = lWindow; // and show the window lWindow->Show(true); if(lData->iFinder) lData->iCtrl->Notify(kEvnLiveOpened,lData->iFinder,true); } } else { wxMessageBox(L"Sorry, the camera couldn't be open.", L"Ooops ...", wxOK | wxICON_ERROR,this); } } else lData->iCtrl->Raise(); break; } case ID_LIVE: { if(!lData->iFinder) { if(!lData->iHandle) lData->iHandle = OpenCamera(lData->iData.UniqueId,lData->iOwner); if(lData->iHandle) { // create the info window CFinderWindow* lWindow = new CFinderWindow(*this,lData->iData,lData->iHandle); if(lWindow) { // keep a pointer to it lData->iFinder = lWindow; // and show the window lWindow->Show(true); if(lData->iCtrl) lData->iCtrl->Notify(kEvnLiveOpened,lWindow,true); } } else { wxMessageBox(L"Sorry, the camera couldn't be open.", L"Ooops ...", wxOK | wxICON_ERROR,this); } } else lData->iFinder->Raise(); break; } case ID_SEEK: { wxTextEntryDialog lDialog(this,L"Please enter the IP address of the camera",L"Seek a camera ...",L"0.0.0.0"); if(lDialog.ShowModal() == wxID_OK) { unsigned long lAddr = inet_addr(lDialog.GetValue().mb_str(wxConvUTF8)); if(lAddr) { iSeeking = new CSeeker(dSEEKER,GetEventHandler(),lAddr); if(iSeeking) if(!iSeeking->Start()) { delete iSeeking; iSeeking = NULL; } } else wxMessageBox(L"You need to enter a valid IP address", L"Ooops ...", wxOK | wxICON_ERROR,this); } break; } case ID_EXPO: { bool lClose = false; if(!lData->iHandle) { lData->iHandle = OpenCamera(lData->iData.UniqueId,lData->iOwner); lClose = true; } if(lData->iHandle) { wxFileDialog lDialog(NULL,wxT("Select an output file"),wxT(""), wxString(lData->iData.SerialNumber,wxConvUTF8), wxT("Text files (*.txt)|*.txt"),wxSAVE | wxOVERWRITE_PROMPT); if(lDialog.ShowModal() == wxID_OK) { wxString lExt = wxT(".txt"); wxString lPath = lDialog.GetPath(); if(!lPath.Contains(lExt)) lPath = lPath + lExt; if(!ExportCamera(lData->iHandle,lPath)) wxMessageBox(wxT("Camera's setup export failed."),wxT("Ooops ..."),wxOK | wxICON_ERROR,this); } if(lClose) { CloseCamera(lData->iHandle); lData->iHandle = NULL; } } break; } case ID_EVNT: { if(!lData->iEvnt) { if(!lData->iHandle) lData->iHandle = OpenCamera(lData->iData.UniqueId,lData->iOwner); if(lData->iOwner) { if(lData->iHandle) { // create the info window CEvntWindow* lWindow = new CEvntWindow(*this,lData->iData,lData->iHandle); if(lWindow) { // keep a pointer to it lData->iEvnt = lWindow; // and show the window lWindow->Show(true); } } else { wxMessageBox(L"Sorry, the camera couldn't be open.", L"Ooops ...", wxOK | wxICON_ERROR,this); } } else { wxMessageBox(L"Sorry, the camera is already open", L"Ooops ...", wxOK | wxICON_ERROR,this); } } else lData->iEvnt->Raise(); break; } case ID_SRIO: { if(!lData->iSrio) { if(!lData->iHandle) lData->iHandle = OpenCamera(lData->iData.UniqueId,lData->iOwner); if(lData->iOwner) { if(lData->iHandle) { // create the info window CSerialWindow* lWindow = new CSerialWindow(*this,lData->iData,lData->iHandle); if(lWindow) { // keep a pointer to it lData->iSrio = lWindow; // and show the window lWindow->Show(true); } } else { wxMessageBox(L"Sorry, the camera couldn't be open.", L"Ooops ...", wxOK | wxICON_ERROR,this); } } else { wxMessageBox(L"Sorry, the camera is already open", L"Ooops ...", wxOK | wxICON_ERROR,this); } } else lData->iSrio->Raise(); break; } } // refresh the list of window RefreshWindowsList(); // and force the window to be updated Update(); } else { wxMessageBox(L"You must select a camera first.", L"Ooops ...", wxOK | wxICON_ERROR,this); } }
/* * Method: OnChildClosed() * Purpose: called when a child window is been closed * Comments: none */ void CMainWindow::OnChildClosed(PChildWindow* aChild) { wxTreeItemId lChild; wxTreeItemIdValue lCookie; CTreeItemData* lData; bool lFound = false; // get the first child lChild = iTree->GetFirstChild(iRoot,lCookie); // then loop over the child in search of the window that // was closed while(lChild.IsOk() && !lFound) { lData = (CTreeItemData *)iTree->GetItemData(lChild); if(lData->iInfo == aChild) { lData->iInfo = NULL; lFound = true; } else if(lData->iFinder == aChild) { lData->iFinder = NULL; lFound = true; // if the control window is still open, we notify it // that the live window is a gonner if(lData->iCtrl) lData->iCtrl->Notify(kEvnLiveClosed,NULL,true); } else if(lData->iCtrl == aChild) { lData->iCtrl = NULL; lFound = true; } else if(lData->iEvnt == aChild) { lData->iEvnt = NULL; lFound = true; } else if(lData->iSrio == aChild) { lData->iSrio = NULL; lFound = true; } // if all the window are closed and that we had the camera // open, we close it if(!lData->iFinder && !lData->iCtrl && !lData->iEvnt && !lData->iSrio && lData->iHandle) { SetStatusText(L"Closing a camera"); CloseCamera(lData->iHandle); lData->iHandle = NULL; } lChild = iTree->GetNextChild(iRoot,lCookie); } RefreshWindowsList(); }