void CSeriousSkaStudioApp::OnFileOpen() 
{
  CTFileName fnSim;
  // get file name  
  fnSim = _EngineGUI.FileRequester( "Select existing Smc file",
    "ASCII model files (*.smc)\0*.smc\0"
    "All files (*.*)\0*.*\0\0",
    "Open directory", "Models\\", "");
  if (fnSim=="") return;

  CTFileName fnFull;
  fnFull = _fnmApplicationPath + fnSim;

  CModelInstance *pmi = OnOpenExistingInstance(fnSim);
  if(pmi == NULL)
  {
    // if faile to open smc
    theApp.ErrorMessage("Failed to open model instance '%s'",(const char*)fnSim);
    return;
  }
  // create new document
  CDocument* pDocument = m_pdtDocTemplate->CreateNewDocument();
  if (pDocument == NULL)
	{
		TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		return;
	}
	ASSERT_VALID(pDocument);
  // View creation
	CFrameWnd* pFrame = m_pdtDocTemplate->CreateNewFrame(pDocument, NULL);
	if (pFrame == NULL)
	{
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		delete pDocument;       // explicit delete on error
		return;
	}
	ASSERT_VALID(pFrame);

  pDocument->SetModifiedFlag( FALSE);

  // add file to mru
  CTString strFileName = pmi->mi_fnSourceFile.FileName() + pmi->mi_fnSourceFile.FileExt();
  CString strOpenPath;
  strOpenPath = theApp.GetProfileString(L"SeriousSkaStudio", L"Open directory", L"");
  strOpenPath += pmi->mi_fnSourceFile;

  pDocument->SetPathName(CString(strFileName), TRUE);
  pDocument->SetTitle(CString(strFileName));

  pDocument->SetModifiedFlag( FALSE);
  m_pdtDocTemplate->InitialUpdateFrame(pFrame, pDocument, TRUE);
  // set root model instance
  theApp.GetDocument()->m_ModelInstance = pmi;
  // fill tree view with new model insntance
  ReloadRootModelInstance();
}
Exemplo n.º 2
0
BOOL CEditView::OnEditChange()
/****************************/
{
    CDocument *pDoc = GetDocument();
    ASSERT( pDoc != NULL );
    pDoc->SetModifiedFlag();

    return( FALSE );
}
Exemplo n.º 3
0
void CMainFrame::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	CDocument* pDocument = GetActiveDocument();
	if (pDocument)
    pDocument->SetModifiedFlag(FALSE);
	
	CFrameWnd::OnClose();
}
Exemplo n.º 4
0
void CInstrument::InstrumentChanged() const
{
	// Set modified flag
	CFrameWnd *pFrameWnd = dynamic_cast<CFrameWnd*>(AfxGetMainWnd());
	if (pFrameWnd != NULL) {
		CDocument *pDoc = pFrameWnd->GetActiveDocument();
		if (pDoc != NULL)
			pDoc->SetModifiedFlag();
	}
}
Exemplo n.º 5
0
// @pymethod |PyCDocument|SetModifiedFlag|Set the "dirty" flag for the document.
static PyObject *
ui_doc_set_modified_flag(PyObject *self, PyObject *args)
{
	BOOL bModified = TRUE;
	if (!PyArg_ParseTuple(args, "|i:SetModifiedFlag", &bModified)) // @pyparm int|bModified|1|Set dirty flag
		return NULL;

	CDocument *pDoc;
	if (!(pDoc=PyCDocument::GetDoc(self)))
		return NULL;
	GUI_BGN_SAVE;
	pDoc->SetModifiedFlag(bModified); // @pyseemfc CDocument|SetModifiedFlag
	GUI_END_SAVE;
	RETURN_NONE;
}
void CSeriousSkaStudioApp::OnFileNew()
{
  // add new model instance
  CModelInstance *pmi = OnAddNewModelInstance();
  if(pmi == NULL)
  {
    //delete pDocument;
    theApp.ErrorMessage("Failed to create model instance");
    return;
  }

  CDocument* pDocument = m_pdtDocTemplate->CreateNewDocument();
  if (pDocument == NULL)
	{
		TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		return;
	}
	ASSERT_VALID(pDocument);
  // View creation
	CFrameWnd* pFrame = m_pdtDocTemplate->CreateNewFrame(pDocument, NULL);
	if (pFrame == NULL)
	{
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		delete pDocument;       // explicit delete on error
		return;
	}
	ASSERT_VALID(pFrame);

  // add file to mru
  CTString strFileName = pmi->mi_fnSourceFile.FileName() + pmi->mi_fnSourceFile.FileExt();
  CString strOpenPath;
  strOpenPath = theApp.GetProfileString(L"SeriousSkaStudio", L"Open directory", L"");
  strOpenPath += pmi->mi_fnSourceFile;

  pDocument->SetPathName(CString(strFileName), TRUE);
  pDocument->SetTitle(CString(strFileName));

  pDocument->SetModifiedFlag( FALSE);
	m_pdtDocTemplate->InitialUpdateFrame(pFrame, pDocument, TRUE);
  // set root model instance
  theApp.GetDocument()->m_ModelInstance = pmi;
  // theApp.SaveRootModel();
  // fill tree view with new model instance
  // ReloadRootModelInstance();
  UpdateRootModelInstance();
}
Exemplo n.º 7
0
void CSettingsPage::UpdateBrother()
{
	if(!m_dad->m_Brother){
		TRACE0("No brother on update\n");
		return;
	}
	if(::IsWindow(m_hWnd))
		UpdateData();
CBrother toCompare;
	toCompare = *m_dad->m_Brother;
	m_dad->m_Brother->m_IntervalBad=m_IntervalBad;
	m_dad->m_Brother->m_IntervalGood=m_IntervalGood;
	if(m_OverrideIntervals)
		m_dad->m_Brother->flags|=CBrother::flagsOverrideIntervals;
	else
		m_dad->m_Brother->flags&=~CBrother::flagsOverrideIntervals;
	m_dad->m_Brother->m_Retries=m_Retries;
	if(m_OverrideRetries)
		m_dad->m_Brother->flags|=CBrother::flagsOverrideRetries;
	else
		m_dad->m_Brother->flags&=~CBrother::flagsOverrideRetries;
	m_dad->m_Brother->m_TimeOut=m_TimeOut;
	if(m_OverrideTimeout)
		m_dad->m_Brother->flags|=CBrother::flagsOverrideTimeout;
	else
		m_dad->m_Brother->flags&=~CBrother::flagsOverrideTimeout;
	m_dad->m_Brother->ParentalAdjust();
	if(toCompare!=(*m_dad->m_Brother)){
	CDocument *pDoc = m_dad->m_Daddy->GetDocument();
		ASSERT(pDoc);
		pDoc->SetModifiedFlag();
	}
	if(::IsWindow(m_hWnd)){
		UpdateData(FALSE);
		SetupControls();
	}
}
Exemplo n.º 8
0
CCmdTarget* COleTemplateServer::OnCreateObject()
{
	ASSERT_VALID(this);
	ASSERT_VALID(m_pDocTemplate);

	// save application user control status
	BOOL bUserCtrl = AfxOleGetUserCtrl();

	// create invisible doc/view/frame set
	CDocument* pDoc = m_pDocTemplate->OpenDocumentFile(NULL, FALSE);

	// restore application's user control status
	AfxOleSetUserCtrl(bUserCtrl);

	if (pDoc != NULL)
	{
		ASSERT_VALID(pDoc);
		ASSERT_KINDOF(CDocument, pDoc);

		// all new documents created by OLE start out modified
		pDoc->SetModifiedFlag();
	}
	return pDoc;
}
/////////////////////////////////////
// @mfunc menu handler - find previous bookmark from the caret line
// @rvalue BOOL | TRUE if we handled the message - FALSE if message should be processed further
//
BOOL CScintillamfcView::OnNotify( 
								 WPARAM wParam,       //@parm not used
								 LPARAM lParam,       //@parm pointer to notification structure
								 LRESULT* pResult )   //@parm result
{
	NMHDR *phDR;
	phDR = (NMHDR*)lParam;
	// does notification come from my scintilla window?
	if (phDR != NULL && phDR->hwndFrom == m_wndScintilla.m_hWnd)
	{
		SCNotification *pMsg = (SCNotification*)lParam;
		switch (phDR->code)
		{
		case SCN_STYLENEEDED:
			break;
		case SCN_CHARADDED:
			break;
		case SCN_SAVEPOINTREACHED:
			break;
			//       called when the document is changed - mark document modified
		case SCN_SAVEPOINTLEFT:
			{
				CDocument *pDoc = GetDocument();
				pDoc->SetModifiedFlag(TRUE);
			}
			break;
		case SCN_MODIFYATTEMPTRO:
			break;
		case SCN_KEY:
			break;
		case SCN_DOUBLECLICK:
			break;
			//       called when something changes and we want to show new indicator state or brace matching
		case SCN_UPDATEUI:
			{
				m_wndScintilla.UpdateUI();
			}
			break;
		case SCN_MODIFIED:
			break;
		case SCN_MACRORECORD:
			break;
			//       user clicked margin - try folding action
		case SCN_MARGINCLICK:
			{
				m_wndScintilla.DoDefaultFolding(pMsg->margin, pMsg->position);
			}
			break;
		case SCN_NEEDSHOWN:
			break;
		case SCN_PAINTED:
			break;
		case SCN_USERLISTSELECTION:
			break;
		case SCN_URIDROPPED:
			break;
		case SCN_DWELLSTART:
			break;
		case SCN_DWELLEND:
			break;
		}
		return TRUE; // we processed the message
	}
	return CWnd::OnNotify(wParam, lParam, pResult);
}
Exemplo n.º 10
0
CDocument* CSingleDocTemplate::OpenDocumentFile(LPCTSTR lpszPathName,
	BOOL bMakeVisible)
	// if lpszPathName == NULL => create new file of this type
{
	CDocument* pDocument = NULL;
	CFrameWnd* pFrame = NULL;
	BOOL bCreated = FALSE;      // => doc and frame created
	BOOL bWasModified = FALSE;

	if (m_pOnlyDoc != NULL)
	{
		// already have a document - reinit it
		pDocument = m_pOnlyDoc;
		if (!pDocument->SaveModified())
			return NULL;        // leave the original one

		pFrame = (CFrameWnd*)AfxGetMainWnd();
		ASSERT(pFrame != NULL);
		ASSERT(pFrame->IsKindOf(RUNTIME_CLASS(CFrameWnd)));
		ASSERT_VALID(pFrame);
	}
	else
	{
		// create a new document
		pDocument = CreateNewDocument();
		ASSERT(pFrame == NULL);     // will be created below
		bCreated = TRUE;
	}

	if (pDocument == NULL)
	{
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		return NULL;
	}
	ASSERT(pDocument == m_pOnlyDoc);

	if (pFrame == NULL)
	{
		ASSERT(bCreated);

		// create frame - set as main document frame
		BOOL bAutoDelete = pDocument->m_bAutoDelete;
		pDocument->m_bAutoDelete = FALSE;
					// don't destroy if something goes wrong
		pFrame = CreateNewFrame(pDocument, NULL);
		pDocument->m_bAutoDelete = bAutoDelete;
		if (pFrame == NULL)
		{
			AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
			delete pDocument;       // explicit delete on error
			return NULL;
		}
	}

	if (lpszPathName == NULL)
	{
		// create a new document
		SetDefaultTitle(pDocument);

		// avoid creating temporary compound file when starting up invisible
		if (!bMakeVisible)
			pDocument->m_bEmbedded = TRUE;

		if (!pDocument->OnNewDocument())
		{
			// user has been alerted to what failed in OnNewDocument
			TRACE0("CDocument::OnNewDocument returned FALSE.\n");
			if (bCreated)
				pFrame->DestroyWindow();    // will destroy document
			return NULL;
		}
	}
	else
	{
		BeginWaitCursor();

		// open an existing document
		bWasModified = pDocument->IsModified();
		pDocument->SetModifiedFlag(FALSE);  // not dirty for open

		if (!pDocument->OnOpenDocument(lpszPathName))
		{
			// user has been alerted to what failed in OnOpenDocument
			TRACE0("CDocument::OnOpenDocument returned FALSE.\n");
			if (bCreated)
			{
				pFrame->DestroyWindow();    // will destroy document
			}
			else if (!pDocument->IsModified())
			{
				// original document is untouched
				pDocument->SetModifiedFlag(bWasModified);
			}
			else
			{
				// we corrupted the original document
				SetDefaultTitle(pDocument);

				if (!pDocument->OnNewDocument())
				{
					TRACE0("Error: OnNewDocument failed after trying to open a document - trying to continue.\n");
					// assume we can continue
				}
			}
			EndWaitCursor();
			return NULL;        // open failed
		}
#ifdef _MAC
		// if the document is dirty, we must have opened a stationery pad - don't
		// change the pathname because we want to treat the document as untitled
		if (!pDocument->IsModified())
#endif
			pDocument->SetPathName(lpszPathName);

		EndWaitCursor();
	}

	if (bCreated && AfxGetMainWnd() == NULL)
	{
		// set as main frame (InitialUpdateFrame will show the window)
		AfxGetThread()->m_pMainWnd = pFrame;
	}
	InitialUpdateFrame(pFrame, pDocument, bMakeVisible);

	return pDocument;
}
Exemplo n.º 11
0
void CIVAnimatorView::OnEditPaste() 
{
CDocument *pDoc = CIvfApp::IvfGetAfxDocument(this);
pDoc->SetModifiedFlag();
IvfOnEditPaste();	
}
Exemplo n.º 12
0
void CScriptView::OnScriptMakeModel() 
{
	// First we save script file
  CModelerDoc *pDoc = (CModelerDoc *) GetDocument();
  CTFileName fnScriptName = CTString(pDoc->GetPathName());

  CTFileName fnModelName = fnScriptName.FileDir() + fnScriptName.FileName() + ".mdl";
  try
  {
    fnScriptName.RemoveApplicationPath_t();
  }
  catch( char *err_str)
  {
    AfxMessageBox( err_str);
    return;
  }
  pDoc->OnSaveDocument( pDoc->GetPathName());

	// close mdl document with same name
  POSITION pos = theApp.m_pdtModelDocTemplate->GetFirstDocPosition();
  while (pos!=NULL)
  {
    CModelerDoc *pmdCurrent = (CModelerDoc *)theApp.m_pdtModelDocTemplate->GetNextDoc(pos);
    if( CTFileName( CTString(pmdCurrent->GetPathName())) == fnModelName)
    {
      pmdCurrent->OnCloseDocument();
      break;
    }
  }

	// Now we will create one instance of new document of type CModelerDoc
  CDocument* pDocument = theApp.m_pdtModelDocTemplate->CreateNewDocument();
 	if (pDocument == NULL)
	{
		TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		return;
	}
	ASSERT_VALID(pDocument);
	
  BOOL bAutoDelete = pDocument->m_bAutoDelete;
	pDocument->m_bAutoDelete = FALSE;   // don't destroy if something goes wrong
	CFrameWnd* pFrame = theApp.m_pdtModelDocTemplate->CreateNewFrame(pDocument, NULL);
	pDocument->m_bAutoDelete = bAutoDelete;
	if (pFrame == NULL)
	{
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		delete pDocument;       // explicit delete on error
		return;
	}
	ASSERT_VALID(pFrame);

  pDocument->SetPathName( fnModelName, FALSE);
  pDocument->SetTitle( fnModelName.FileName() + fnModelName.FileExt());
  
  char strError[ 256];
  if( !((CModelerDoc *)pDocument)->CreateModelFromScriptFile( fnScriptName, strError))
  {
    pDocument->OnCloseDocument();
    AfxMessageBox( strError);
    return;
  }
	theApp.m_pdtModelDocTemplate->InitialUpdateFrame(pFrame, pDocument, TRUE);
  ((CModelerDoc *)pDocument)->m_emEditModel.edm_md.md_bPreparedForRendering = FALSE;
  pDocument->SetModifiedFlag();

  // add textures from .ini file
  CTFileName fnIniFileName = fnScriptName.NoExt() + ".ini";
  try
  {
    ((CModelerDoc *)pDocument)->m_emEditModel.CSerial::Load_t(fnIniFileName);
  }
  catch( char *strError)
  {
    // ignore errors
    (void) strError;
  }
}