void CocaView::Activate( bool activate ) { COCA_DEBUG_INFO( "CocaView::Activate " << this << "; " << activate ); COCA_ASSERT( GetDocumentManager() ); CocaView* oldView = coca::staticCast<CocaView*>( GetDocumentManager()->GetCurrentView() ); wxView::Activate( activate ); CocaView* currentView = coca::staticCast<CocaView*>( GetDocumentManager()->GetCurrentView() ); if ( oldView ) { oldView->onDeactivated(); } if ( currentView ) { currentView->onActivated(); } }
void MainFrame::OnProperties(wxCommandEvent&) { const wxDocument* doc = GetDocumentManager()->GetCurrentDocument(); wxArrayString as; ::wxDocument_Info(doc, &as); ::wxMessageBox(::wxJoin(as, wxT('\n')), wxMessageBoxCaption, wxOK | wxCENTRE, this); }
CCamDocTemplate::Confidence CCamDocTemplate::MatchDocType(LPCTSTR lpszPathName, DWORD dwFileType, wxDocument*& rpDocMatch) #endif { ASSERT(lpszPathName != NULL); rpDocMatch = NULL; // go through all documents wxList& listDocuments = GetDocumentManager()->GetDocuments(); wxNode* pNode = listDocuments.GetFirst(); while (pNode != NULL) { // Get the next document CCamDoc* pDoc = (CCamDoc*)pNode->GetData(); #if (_OLE_VER >= 0x200) // Don't consider embedded or hidden docs. if (pDoc->IsEmbedded() || pDoc->GetKernelDoc()->IsAHiddenDoc()) continue; #endif // Find out the names of the old and new documents wxString OldDocName = pDoc->GetFilename(); wxString OrigDocName = wxString((LPCTSTR) pDoc->GetOriginalPath()); wxString NewDocName = wxString(lpszPathName); OldDocName.MakeLower(); OrigDocName.MakeLower(); NewDocName.MakeLower(); // Test if the docs refer to the same existing .ART file or if the two docs are based // on the same existing non-.ART file. BOOL fSameArtFiles = (OldDocName == NewDocName); BOOL fSameNonArtFiles = (OldDocName.IsEmpty() && OrigDocName == NewDocName); // see if they are the same if (fSameArtFiles || fSameNonArtFiles) { // already open TRACEUSER("JustinF", _T("File %s is already open\n"), (LPCTSTR) lpszPathName); rpDocMatch = pDoc; return yesAlreadyOpen; } pNode = pNode->GetNext(); } // see if it matches our default suffix if( !m_defaultExt.IsEmpty() ) { // see if extension matches LPCTSTR lpszDot = camStrrchr( lpszPathName, _T('.') ); if( NULL != lpszDot && 0 == camStricmp( lpszDot + 1, m_defaultExt ) ) return yesAttemptNative; // extension matches, looks like ours } // otherwise we will guess it may work return yesAttemptForeign; }
bool DatabaseTemplate::CreateDatabaseDocument(const wxString &path, ViewType type, Database *db, wxCriticalSection &cs, long flags) { DrawingDocument * const doc = (DrawingDocument *) DoCreateDocument(); wxTRY { doc->SetFilename( path ); doc->SetDocumentTemplate( this ); GetDocumentManager()->AddDocument( doc ); doc->SetDatabase( db, true ); doc->SetCommandProcessor( doc->OnCreateCommandProcessor() ); if( CreateDatabaseView( doc, type, cs, flags ) ) return true; if( GetDocumentManager()->GetDocuments().Member( doc ) ) doc->DeleteAllViews(); return false; } wxCATCH_ALL ( if( GetDocumentManager()->GetDocuments().Member( doc ) ) doc->DeleteAllViews(); throw; ) }
// Clean up windows used for displaying the view. bool TableView::OnClose(bool deleteWindow) { if( !wxView::OnClose( deleteWindow ) ) return false; Activate( false ); if( deleteWindow ) { GetFrame()->Destroy(); SetFrame( NULL ); } wxDocManager *manager = GetDocumentManager(); if( manager->GetDocumentsVector().size() == 0 ) { delete m_tb; m_tb = NULL; } return true; }
bool CocaView::isActive() const { return ( GetDocumentManager()->GetCurrentView() == this ); }