Ejemplo n.º 1
0
void CFileView::OnFileNew()
{
	CMultiDocTemplate* pUIDocTemplate = theApp.GetUIDocTemplate();
	CDocument* pDoc = pUIDocTemplate->OpenDocumentFile(NULL);
	CString strFilePath = CGlobalVariable::m_strProjectPath + pDoc->GetTitle() + _T(".xml");
	pDoc->DoSave(strFilePath);
	HTREEITEM hSelectedItem = m_wndFileView.GetSelectedItem();
	DWORD dwInfo = m_wndFileView.GetItemData(hSelectedItem);
	HTREEITEM hParent = (dwInfo != INFO_FILE) ? hSelectedItem : m_wndFileView.GetParentItem(hSelectedItem);
	HTREEITEM hNewItem = m_wndFileView.InsertItem(pDoc->GetTitle(), 2, 2, hParent);
	m_wndFileView.SetItemData(hNewItem, INFO_FILE);
	m_wndFileView.Expand(hParent, TVE_EXPAND);
}
Ejemplo n.º 2
0
void g_OpenCursor(const ResourceBlob *pData)
{
    CMultiDocTemplate *pTemplate = theApp.GetCursorTemplate();
    if (pTemplate)
    {
        CCursorDoc *pDocument = (CCursorDoc*)pTemplate->OpenDocumentFile(NULL, TRUE);
        if (pDocument)
        {
            IResourceBase *pResource;
            if (SUCCEEDED(CreateResourceFromResourceData(pData, &pResource)))
            {
                pDocument->SetResource(pResource, pData->GetId());
            }
        }
    }
}
Ejemplo n.º 3
0
void g_OpenView(const ResourceBlob *pData)
{
    // Create the vocab000
    CMultiDocTemplate *pTemplate = theApp.GetViewTemplate();
    if (pTemplate)
    {
        CViewDoc *pDocument = (CViewDoc*)pTemplate->OpenDocumentFile(NULL, TRUE);
        if (pDocument)
        {
            IResourceBase *pResource;
            if (SUCCEEDED(CreateResourceFromResourceData(pData, &pResource)))
            {
                pDocument->SetResource(pResource, pData->GetId());
            }
        }
    }
}
Ejemplo n.º 4
0
//************************************
// Method:    OnOpFftview
// FullName:  CImgView::OnOpFftview
// Access:    protected 
// Returns:   void
// Qualifier:
//************************************
void CImgView::OnOpFftview() 
{
	// TODO: Add your command handler code here
	CImgDoc* pDoc = GetDocument();
	CFFTMachine oFFmachine;
	CImgFourierSource* imgRed = new CImgFourierSource();
	
	oFFmachine.Run(pDoc->GetSource(), imgRed, eForward);
	
	CImgApp* pApp = (CImgApp*)AfxGetApp();
	CMultiDocTemplate* pTemplate = pApp->m_pDocTemplate;
	CImgDoc* newDoc = (CImgDoc*)pTemplate->OpenDocumentFile(NULL);
	newDoc->SetTitle(pDoc->GetTitle() + IMP_SUF_FOURIER);
	newDoc->SetModifiedFlag();
	newDoc->SetSource(imgRed);
	newDoc->SetParentSrc(pDoc);
	pDoc->AddChild(newDoc);
}
Ejemplo n.º 5
0
void g_OpenText(const ResourceBlob *pData)
{
    // Create the text
    CMultiDocTemplate *pTemplate = theApp.GetTextTemplate();
    if (pTemplate)
    {
        CTextDoc *pDocument = (CTextDoc*)pTemplate->OpenDocumentFile(NULL, TRUE);
        if (pDocument)
        {
            IResourceBase *pResource;
            if (SUCCEEDED(CreateResourceFromResourceData(pData, &pResource)))
            {
                std::auto_ptr<TextResource> pText(static_cast<TextResource*>(pResource));
                pDocument->SetTextResource(pText, pData->GetId());
            }
        }
    }
}
Ejemplo n.º 6
0
//************************************
// Method:    process
// FullName:  CImgView::process
// Access:    protected 
// Returns:   procStatus
// Qualifier:
// Parameter: CImgProcessor * pProc
//************************************
procStatus CImgView::process(CImgProcessor *pProc)
{
	procStatus eRetCode = eNormal;

	CImgDoc* pDoc = NULL;
	CImgSource* imgRes = NULL;

	pDoc = GetDocument();
	if (pDoc == NULL)
		eRetCode = eSystemErr;
	else
		imgRes = new CImgSource();
	
	if (imgRes == NULL)
		eRetCode = eMemAllocErr;
	

	if(eRetCode == eNormal)
	{
		eRetCode = pProc->ApplyProcessor(pDoc->GetSource(), imgRes);
		if(eRetCode == eNormal)
		{
			CImgApp* pApp = (CImgApp*)AfxGetApp();
			CMultiDocTemplate* pTemplate = pApp->m_pDocTemplate;
			CImgDoc* newDoc = (CImgDoc*)pTemplate->OpenDocumentFile(NULL);
			newDoc->SetTitle(imgRes->GetName());
			newDoc->SetModifiedFlag();
			newDoc->SetSource(imgRes);
			newDoc->SetParentSrc(pDoc);
			pDoc->AddChild(newDoc);
		}		
	}
	else
	{
		delete imgRes;
	}

	return eRetCode;
}
Ejemplo n.º 7
0
void g_OpenSound(const ResourceBlob *pData)
{
    // Create the text
    CMultiDocTemplate *pTemplate = theApp.GetSoundTemplate();
    if (pTemplate)
    {
        IResourceBase *pResource;
        if (SUCCEEDED(CreateResourceFromResourceData(pData, &pResource)))
        {
            std::auto_ptr<SoundResource> pSound(static_cast<SoundResource*>(pResource));
            CSoundDoc *pDocument = (CSoundDoc*)pTemplate->OpenDocumentFile(NULL, TRUE);
            if (pDocument)
            {
                pDocument->SetSoundResource(pSound, pData->GetId());
            }
        }
        else
        {
            AfxMessageBox("Unable to create resource.", MB_ERRORFLAGS);
        }
    }
}
Ejemplo n.º 8
0
void g_OpenVocab(const ResourceBlob *pData)
{
    if (pData->GetNumber() == 0)
    {
        // Create the vocab000
        CMultiDocTemplate *pTemplate = theApp.GetVocabTemplate();
        if (pTemplate)
        {
            CVocabDoc *pDocument = (CVocabDoc*)pTemplate->OpenDocumentFile(NULL, TRUE);
            if (pDocument)
            {
                IResourceBase *pResource;
                if (SUCCEEDED(CreateResourceFromResourceData(pData, &pResource)))
                {
                    pDocument->SetVocab(static_cast<Vocab000*>(pResource), pData->GetId());
                }
            }
        }
    }
    else
    {
        AfxMessageBox(TEXT("Only Vocab 000 is editable."), MB_OK | MB_APPLMODAL);
    }
}
Ejemplo n.º 9
0
/////////////////////////////////////////////////////////////////////////////
// 新建OWM对象窗口(for Xtreme)
/////////////////////////////////////////////////////////////////////////////
void CPlugIn::NewOwmFrame(LPCTSTR lpszPath)
{
	if(m_pVciObj == NULL)
	{
		return;
	}

	IVciOwm* pIVciOwm = (IVciOwm*)m_pVciObj;
	CMultiDocTemplate* pDocTemplate = NULL;
	pIVciOwm->GetDocTemplate(&pDocTemplate);

	if((m_nType & OWM_DOC) && pDocTemplate)
	{
		// 如果只允许一个实例,则做相应处理
		if((m_nType & OWM_ONEFRAME) &&
			(pDocTemplate->GetFirstDocPosition()))
			return;

		// 打开一个空OWM文档
		//if(!pDocTemplate->OpenDocumentFile(lpszPath))
		if(!pDocTemplate->OpenDocumentFile(NULL))
		{
			return;
		}

		// 创建OWM扩展菜单
		if(m_nType & OWM_MENU)
		{
			// 取到文档指针,用来将扩展菜单指针纪录在文档中,文档关闭时清除
			POSITION pos = pDocTemplate->GetFirstDocPosition();
			CDocument* pDoc = pDocTemplate->GetNextDoc(pos);
			POSITION posview = pDoc->GetFirstViewPosition();
			if(posview)	// 如果视存在
			{
				CView* pView = pDoc->GetNextView(posview);	// 取到视指针
				//pView->GetParentFrame()->ActivateFrame(); // 激活框架
				if(m_nType & OWM_MAXWINDOW)
				{
					// 将窗口最大化
					pView->GetParentFrame()->ShowWindow(SW_SHOWMAXIMIZED);
				}
			}
/*
			// 注册OWM菜单,添加到弹出菜单上
			// 注:在Xtreme中需要通过MenuBar的GetMenu函数来获取主
			// 菜单的资源,而CJLib中直接通过MainFrame的GetMenu就可以了
			//ol.RegisterClientMenu(m_pMainWnd->GetMenu(), m_aOWMMenus, IDM_OWMCMD, pDoc);
			CXTMenuBar* pMenuBar = ((CMainFrame*)AfxGetMainWnd())->GetMenuBar();
			pIVciOwm->RegisterClientMenu(pMenuBar->GetMenu(),
							m_aOWMMenus, IDM_OWMCMD, pDoc);

			// 刷新菜单条
			// 注:在CJLib中用DrawMenuBar就可以了,在Xtreme中必须用
			// DrawMenuBarX来刷新Xtreme中的MenuBar和Menu资源的关联
			((CMainFrame*)AfxGetMainWnd())->DrawMenuBarX();

			// 注:关于OWM针对Xtreme toolkit的改动
			// Xtreme和CJLibrary的区别比较大,Cool菜单改为统一管理,
			// 通过CXTCoolMenu类来管理,此类可以加载许多图标资源,然后
			// 安装到一个窗口上,安装以后,用户不用再针对菜单做特殊处理
			// 就可以使用Cool菜单了.而以前的CJLib使用CoolMenu的方法是
			// 每个菜单单独加载图标资源.
			// 因此,在OWM中要想实现扩展菜单使用自己的图标资源,必须做
			// 一些特殊处理,因为OWM和主程序必须使用同一个CXTCoolMenu,
			// 这样是很容易造成资源冲突问题的,并且也不能通过资源切换
			// 来解决,那么唯一的办法就是保证OWM中需要添加到主程序的菜
			// 单和主程序中的菜单的资源ID不重合,因此规定OWM中需要扩展
			// 的资源ID必须在10000到20000范围内,其中10000-11999为系统
			// OWM保留,用户自己写的必须从12000开始.
			// 为了保证OWM接口的兼容性,因此对接口定义不做任何改动,在
			// OWM的RegisterClientMenu函数中要想注册自己的图标资源,
			// 可以通过获取MainFrame指针,然后通过MainFrame找到CXTCoolMenu
			// 的指针来操作.
*/
		}
	}
}
Ejemplo n.º 10
0
BOOL CCafeOrangeApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinAppEx::InitInstance();


	// Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}

	AfxEnableControlContainer();

	EnableTaskbarInteraction();

	// AfxInitRichEdit2() is required to use RichEdit control	
	// AfxInitRichEdit2();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("CafeOrange"));
	LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)


	InitContextMenuManager();
	InitShellManager();

	InitKeyboardManager();

	InitTooltipManager();
	CMFCToolTipInfo ttParams;
	ttParams.m_bVislManagerTheme = TRUE;
	theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
		RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views
	CMultiDocTemplate* pImageEditorDocTemplate;
	pImageEditorDocTemplate = new CMultiDocTemplate(IDR_CafeOrangeTYPE,
		RUNTIME_CLASS(CCafeOrangeDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CCafeOrangeView));
	if (!pImageEditorDocTemplate)
		return FALSE;
	AddDocTemplate(pImageEditorDocTemplate);

	CMultiDocTemplate* pOpenCVDocTemplate;
	pOpenCVDocTemplate = new CMultiDocTemplate(IDR_CafeOrangeTYPE,
		RUNTIME_CLASS(CCafeOrangeDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(COpenCVView));
	if (!pOpenCVDocTemplate)
		return FALSE;
	AddDocTemplate(pOpenCVDocTemplate);

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
	{
		delete pMainFrame;
		return FALSE;
	}
	m_pMainWnd = pMainFrame;
	// call DragAcceptFiles only if there's a suffix
	//  In an MDI app, this should occur immediately after setting m_pMainWnd

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line.  Will return FALSE if
	// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	// The main window has been initialized, so show and update it
	pMainFrame->ShowWindow(m_nCmdShow);
	//pMainFrame->UpdateWindow();
	
	CDocument* pOpenCVDoc = pOpenCVDocTemplate->OpenDocumentFile(NULL);
	CDocument* pImageEditorDoc = pImageEditorDocTemplate->OpenDocumentFile(NULL);

	pOpenCVDoc->SetTitle("Movie");
	pImageEditorDoc->SetTitle("ImageEditor");

	POSITION OpenCVPosition= pOpenCVDoc->GetFirstViewPosition();
	CView *pOpenCVView = pOpenCVDoc->GetNextView(OpenCVPosition);
	//CMDIChildWndEx* pOpenCVWnd = (CMDIChildWndEx*)pOpenCVView->GetParentFrame();

	POSITION ImageEditorPosition = pImageEditorDoc->GetFirstViewPosition();
	CView *pImageEditorView = pImageEditorDoc->GetNextView(ImageEditorPosition);
	//CMDIChildWndEx* pImageEditorWnd = (CMDIChildWndEx*)pImageEditorView->GetParentFrame();
	
	pMainFrame->InitializeMDIView(pOpenCVView, pImageEditorView);
	pMainFrame->UpdateWindow();


	return TRUE;
}