Exemple #1
0
void CMainFrame::OnUpdateCmd(CCmdUI *pCmdUI)
{
	if( !GetActiveFrame() )
		return;

	pCmdUI->Enable( GetActiveFrame()->GetActiveDocument() != NULL );
}
Exemple #2
0
void CPromFrame::OnUpdateViewTbDLPRtree(CCmdUI* pCmdUI)
{
  pCmdUI->SetCheck((dt_fileBar.GetStyle() & WS_VISIBLE) != 0);
  CGraphFrame *frame=(CGraphFrame *)GetActiveFrame();
  pCmdUI->SetText(frame && ((CGraphView *)(frame->GetActiveView()))->GetDocument()->is_drainage?
		  "Drainage &tree":"Divide &tree");
}
Exemple #3
0
void CMainFrame::OnViewFullscreen() 
{
	if (m_fullscreen)
	{
		ModifyStyle(0,WS_CAPTION|WS_THICKFRAME);			
		ShowWindow(SW_SHOWNORMAL);

		ShowControlBar(&m_wndToolBar, TRUE, FALSE);
		ShowControlBar(&m_wndCmdBar, TRUE, FALSE);
		ShowControlBar(&m_wndStatusBar, TRUE, FALSE);
	}
	else
	{
		ModifyStyle(WS_CAPTION|WS_THICKFRAME,0);			
		ShowWindow(SW_MAXIMIZE);

		CFrameWnd* pChild = GetActiveFrame();
		if (pChild)	pChild->ShowWindow(SW_MAXIMIZE);

		ShowControlBar(&m_wndToolBar, FALSE, FALSE);
		ShowControlBar(&m_wndCmdBar, FALSE, FALSE);
		ShowControlBar(&m_wndStatusBar, FALSE, FALSE);
	}
	m_fullscreen = !m_fullscreen;
}
//****************************************************************************
COleClientItem*	CBCGPFrameWnd::GetInPlaceActiveItem ()
{
    CFrameWnd* pActiveFrame = GetActiveFrame ();
    if (pActiveFrame == NULL)
    {
        return NULL;
    }

    ASSERT_VALID (pActiveFrame);

    CView* pView = pActiveFrame->GetActiveView ();
    if (pView == NULL || pView->IsKindOf (RUNTIME_CLASS (CBCGPPrintPreviewView)))
    {
        return NULL;
    }

    ASSERT_VALID (pView);

    COleDocument* pDoc = DYNAMIC_DOWNCAST (COleDocument, pView->GetDocument ());
    if (pDoc == NULL)
    {
        return NULL;
    }

    ASSERT_VALID (pDoc);
    return pDoc->GetInPlaceActiveItem (pView);
}
   virtual CDocument* OpenDocumentFile(LPCTSTR lpszPathName, BOOL /*bMakeVisible*/)
   {
      CWnd* parent = GetActiveFrame();
      CDocument* doc = NULL;
      CStringArray newfile;
      CString tablename;
   #ifdef x_DEBUG
      tablename = _T("årstal");
      //tablename = _T("tur_tur");
      //tablename = _T("Adresser");
   #endif
      bool ok = ::mdb2dbf(parent, lpszPathName, &newfile, tablename);
      if (ok)
      {
         if (newfile.GetSize())
         {
            for (int i = 0; i < newfile.GetSize(); i++)
            {
	            doc = theApp.m_doctemplate->OpenDocumentFile(newfile.ElementAt(i));
            }
         }
         else // user chose csv
         {
            AfxMessageBox(_T("Done"));
         }
         AfxGetApp()->AddToRecentFileList(lpszPathName);
      }
      else AfxMessageBox(_T("Error"));
      return doc;
   }
Exemple #6
0
void CMainFrame::OnUpdateImageInfo(CCmdUI *pCmdUI)
{
	// Get the active MDI child window.
	CMDIChildWnd *pChild = (CMDIChildWnd *)GetActiveFrame();
	if (pChild != NULL)
	{
		// Get the active view attached to the active MDI child window.
		CDtxViewView *pView = (CDtxViewView*)pChild->GetActiveView();
		CDtxViewDoc *pDoc = pView->GetDocument();

		CString strInfo;
		if (pDoc->GetImageInfoString(&strInfo))
		{
			pCmdUI->Enable();
			pCmdUI->SetText(strInfo);
		}
		else
		{
			pCmdUI->Enable(FALSE);
		}
	}
	else
	{
		pCmdUI->Enable(FALSE);
	}
}
Exemple #7
0
void CMainFrame::OnBnClickedButtonPlay()
{
	CRecordeOperatorDoc* pDoc = NULL;
	CChildFrame* pChild = NULL;
	pChild = (CChildFrame*)GetActiveFrame();
	if (!pChild)
		return;
	pDoc = (CRecordeOperatorDoc*)pChild->GetActiveDocument();
	if (!pDoc)
		return;
	IERecPlayer* pRecord = pDoc->GetRecord();
	if (pRecord)
	{
		if (pRecord->RePlay() == S_OK)
		{
			m_wndProgressDialogBar.m_buttonPlay.SetWindowText("Pause");
		}
		else if (pRecord->PauseRePlay() == S_OK)
		{
			m_wndProgressDialogBar.m_buttonPlay.SetWindowText("Play");
		}
	}
	else
		MessageBox("»¹Î´°ó¶¨Â¼Ïñ¶ÔÏó£¡","ѽ",MB_OK);
}
Exemple #8
0
void  CMainFrame::OnExpandingTree(NMHDR* pNMHDR, LRESULT* pResult)
{
	NMTREEVIEW* pTreeView = (NMTREEVIEW*)pNMHDR;
	HTREEITEM hSelected = pTreeView->itemNew.hItem;
	if (pTreeView->action == TVE_EXPAND)
	{		
		int nDeep = 0;
		HTREEITEM hTempItem = m_wndMasterlistDialogBar.m_treeMasters.GetParentItem(hSelected);
		while (hTempItem)
		{
			nDeep++;
			hTempItem = m_wndMasterlistDialogBar.m_treeMasters.GetParentItem(hTempItem);
		}
		if (nDeep == 2)
		{
			CRecordeOperatorDoc* pDoc = NULL;
			CChildFrame* pChild = NULL;
			pChild = (CChildFrame*)GetActiveFrame();
			if (!pChild)
				return;
			pDoc = (CRecordeOperatorDoc*)pChild->GetActiveDocument();
			if (!pDoc)
				return;
			IERecPlayer* pRecord = pDoc->GetRecord();
			if (pRecord)
			{
				g_RecordUITools.FillEvent(pRecord, 
					hSelected, 
					m_wndMasterlistDialogBar.m_treeMasters);
			}
		}

	}
}
Exemple #9
0
void CMainFrame::OnSelChangedTree(NMHDR* pNMHDR, LRESULT* pResult)
{
	NMTREEVIEW* pTreeView = (NMTREEVIEW*)pNMHDR;
	HTREEITEM hSelected = pTreeView->itemNew.hItem;	
	int nDeep = 0;
	HTREEITEM hTempItem = m_wndMasterlistDialogBar.m_treeMasters.GetParentItem(hSelected);
	while (hTempItem)
	{
		nDeep++;
		hTempItem = m_wndMasterlistDialogBar.m_treeMasters.GetParentItem(hTempItem);
	}
	DWORD_PTR pPoint = m_wndMasterlistDialogBar.m_treeMasters.GetItemData(hSelected); 
	CRecordeOperatorDoc* pDoc = NULL;
	CChildFrame* pChild = NULL;
	pChild = (CChildFrame*)GetActiveFrame();
	if (!pChild)
		return;
	pDoc = (CRecordeOperatorDoc*)pChild->GetActiveDocument();
	if (!pDoc)
		return;
	IERecPlayer* pRecord = pDoc->GetRecord();
	if (pRecord)
	{
		g_RecordUITools.FillListCtrl(pRecord, nDeep,pPoint,m_wndMasterlistDialogBar.m_listCtrl);
	}
}
CDocument *CFrameWnd::GetActiveDocument()
/***************************************/
{
    CFrameWnd *pFrame = GetActiveFrame();
    if( pFrame != NULL ) {
        CView *pView = pFrame->GetActiveView();
        if( pView != NULL ) {
            return( pView->GetDocument() );
        }
    }
    return( NULL );
}
Exemple #11
0
void CMainFrame::OnCmdBuild()
{
	CDocument *pDoc = GetActiveFrame()->GetActiveDocument();
	pDoc->DoFileSave();

	CString strFolder = theApp.CombinePath( theApp.GetPath(), theApp.m_strSDKOutput );
	CString strApp = theApp.CombinePath( theApp.GetPath(), theApp.m_strCompilerApp );
	SetEnvironmentVariable( _T("NEWPAS"), '"' + strApp + '"' );

	CString strArgs;
	// using an environ. var. because cmd /C doesn't support more than 1 quoted path
	strArgs.Format( _T("/C %%NEWPAS%% \"%s\" outvm || pause"), (LPCTSTR)pDoc->GetPathName() );

	::ShellExecute( 0, _T("open"), _T("cmd"), strArgs, strFolder, SW_SHOW );
}
Exemple #12
0
void CMainFrame::OnReleaseCapture(NMHDR* pNMHDR, LRESULT* pResult)
{
	int nRunTime = m_wndProgressDialogBar.m_sliderProgress.GetPos();
	g_bSlider = TRUE;
	CRecordeOperatorDoc* pDoc = NULL;
	CChildFrame* pChild = NULL;
	pChild = (CChildFrame*)GetActiveFrame();
	if (!pChild)
		return;
	pDoc = (CRecordeOperatorDoc*)pChild->GetActiveDocument();
	if (!pDoc)
		return;
	IERecPlayer* pRecord = pDoc->GetRecord();
	if (pRecord)
		pRecord->StepToEvent(nRunTime);

}
Exemple #13
0
void CMainFrame::OnCmdRun()
{
	CDocument *pDoc = GetActiveFrame()->GetActiveDocument();
	pDoc->DoFileSave();

	CString strApp = theApp.CombinePath( theApp.GetPath(), theApp.m_strCompilerApp );
	SetEnvironmentVariable( _T("NEWPAS"), '"' + strApp + '"' );

	CString strArgs;
	// using an environ. var. because cmd /C doesn't support more than 1 quoted path
	strArgs.Format( _T("/C %%NEWPAS%% \"%s\" execvm & pause"), (LPCTSTR)pDoc->GetPathName() );

	TCHAR szFolder[MAX_PATH];
	_tcscpy_s( szFolder, MAX_PATH, pDoc->GetPathName() );
	PathRemoveFileSpec( szFolder );

	::ShellExecute( 0, _T("open"), _T("cmd"), strArgs, szFolder, SW_SHOW );
}
Exemple #14
0
void CMainFrame::OnBnClickedButtonFree()
{
	CRecordeOperatorDoc* pDoc = NULL;
	CChildFrame* pChild = NULL;
	pChild = (CChildFrame*)GetActiveFrame();
	if (!pChild)
		return;
	pDoc = (CRecordeOperatorDoc*)pChild->GetActiveDocument();
	if (!pDoc)
		return;
	IERecPlayer* pRecord = pDoc->GetRecord();
	if (pRecord)
	{
		if (pRecord->FreeCamera() == S_OK)
		{
			if (pRecord->IsFreeCamera())
				m_wndProgressDialogBar.m_buttonFreeCamera.SetWindowText("RestoreCamera");
			else
				m_wndProgressDialogBar.m_buttonFreeCamera.SetWindowText("FreeCamera");
		}
	}
	else
		MessageBox("»¹Î´°ó¶¨Â¼Ïñ¶ÔÏó£¡","ѽ",MB_OK);
}
Exemple #15
0
void CDBFExplorerDoc::OnFileStructure() 
{
   USES_CONVERSION;
	CStructureDlg dlg(AfxGetMainWnd());

	// copy fieldnames
	for (size_t i = 0; i < m_dBaseFile->GetFieldCount(); i++)
	{
      DBF_FIELD_INFO info;
      if (m_dBaseFile->GetFieldInfo(i, &info))
		{
			CString strFieldData;
			strFieldData.Format(_T("%s,%c,%d,%d"), A2CT(info.name), dbf_gettype_ext2int(info.type), info.length, info.decimals);
			dlg.m_strFieldArray.Add(strFieldData);
		}
	}

	if (dlg.DoModal() == IDOK)
	{
		if(MessageBox(GetFocus(), _T("The database structure has been changed.\nSome data may be lost during the conversion of the database.\nAre you sure you want to apply the changes?"), _T("DBF Explorer"), MB_YESNO | MB_ICONQUESTION) == IDYES)
		{
			// close database
			m_dBaseFile->Close();
	
			CString strFileName, strFileBackup, strMemoBackup;

			// temp file ?
			if (_tcscmp(m_szTempFileName, _T("")) != 0)
			{
				strFileName = m_szTempFileName;
			}
			else
				strFileName = GetPathName();

			strFileBackup = strFileName;
			strMemoBackup = m_dBaseFile->GetMemoFileName(strFileName);

			// make backup names
			int nPos = strFileBackup.ReverseFind('\\');
			if (nPos != -1)
			{
				strFileBackup.SetAt(nPos+1, '_');
				strMemoBackup.SetAt(nPos+1, '_');
			}
			// delete existing backups
			DeleteFile(strFileBackup);
			DeleteFile(strMemoBackup);

			// make backup copy of existing file
			if (!MoveFile(strFileName, strFileBackup))
			{
				MessageBox(GetFocus(), _T("Error while making backup"), _T("Updating structure"), MB_ICONSTOP);
				return;
			}
			
			// make backup copy of memo file
			MoveFile(m_dBaseFile->GetMemoFileName(strFileName), strMemoBackup);

			// create file with new structure
			if (m_dBaseFile->Create(strFileName, dlg.m_strFieldArray) == DBASE_SUCCESS)
			{
				if (OnOpenDocument(strFileName))
				{
					CopyBackupData(strFileBackup);

					if (_tcscmp(m_szTempFileName, _T("")) != 0)
						SetModifiedFlag();

					// reload records
					POSITION pos = GetFirstViewPosition();
					while (pos)
						((CDBFExplorerView *)GetNextView(pos))->ShowRecords(GetActiveFrame()->m_bShowDeletedRecords);
				}
			}
		}
	}	
}
Exemple #16
0
void CDBFExplorerDoc::ExportToText(LPCTSTR lpszFileName)
{
   USES_CONVERSION;
	try
	{
		CFile file;

		// Create "progress bar"
		CProgressCtrl wndProgress;

		GetActiveFrame()->ShowProgressBar(&wndProgress, _T("Exporting records, press Esc to cancel..."));
    
		// Initialize progress control range and step size
		wndProgress.SetRange(0, 100);

		int nCount = m_dBaseFile->GetRecordCount();

		if (file.Open(lpszFileName, CFile::modeWrite | CFile::shareExclusive | CFile::modeCreate, NULL))
		{
	    	// show all records
			for(int rc=m_dBaseFile->GetFirstRecord(); rc==DBASE_SUCCESS; rc=m_dBaseFile->GetNextRecord())
  			{
				// Test for "Esc" key
				if( ::GetAsyncKeyState(VK_ESCAPE) < 0)
				{
					break;
				}

				int nItem = m_dBaseFile->GetPosition();
				
				// do not show deleted records
				if (m_dBaseFile->IsRecordDeleted() && !GetActiveFrame()->m_bShowDeletedRecords)
					continue;

				for (size_t i = 0; i < m_dBaseFile->GetFieldCount(); i++)
				{
					CString szBuff;

               DBF_FIELD_INFO info;
               m_dBaseFile->GetFieldInfo(i, &info);
					if (info.type == DBF_DATA_TYPE_MEMO)
					{
						szBuff = _T("MEMO");
					}
					else
					{
						m_dBaseFile->Read(i, &szBuff);
					}
					if (i != 1)
						file.Write(",", 1);
					file.Write(T2CA(szBuff), szBuff.GetLength());
				}
				file.Write("\r\n", 2);
				// Update progress control
				int nPos = (nItem*100)/nCount;
				wndProgress.SetPos(nPos);
			}	
		}
	}
	catch(CFileException *e)
	{
		e->Delete();
		MessageBox(GetFocus(), _T("Failed to export database!"), _T("Export Database"), MB_OK | MB_ICONSTOP);
	}
	// Ensures that idle message is displayed again
	GetActiveFrame()->PostMessage(WM_SETMESSAGESTRING, (WPARAM) AFX_IDS_IDLEMESSAGE, 0L);
}	
Exemple #17
0
void CDBFExplorerDoc::ExportToHTML(LPCTSTR lpszFileName)
{
   USES_CONVERSION;
	try
	{
		CFile file;
		CString strHTML;

		// Create "progress bar"
		CProgressCtrl wndProgress;

		GetActiveFrame()->ShowProgressBar(&wndProgress, _T("Exporting records, press Esc to cancel..."));
    
		// Initialize progress control range and step size
		wndProgress.SetRange(0, 100);

		int nCount = m_dBaseFile->GetRecordCount();

		if (file.Open(lpszFileName, CFile::modeWrite | CFile::shareExclusive | CFile::modeCreate, NULL))
		{
			strHTML = "<HTML>\r\n";
			file.Write(strHTML, strHTML.GetLength());
			strHTML = "<HEAD>\r\n";
			file.Write(strHTML, strHTML.GetLength());
			strHTML = "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;charset=windows-1252\">\r\n";
			file.Write(strHTML, strHTML.GetLength());
			strHTML.Format(_T("<TITLE>%s</TITLE>\r\n"), GetTitle());
			file.Write(strHTML, strHTML.GetLength());
			strHTML = "</HEAD>\r\n";
			file.Write(strHTML, strHTML.GetLength());
			strHTML = "<BODY>\r\n";
			file.Write(strHTML, strHTML.GetLength());
			strHTML.Format(_T("<TABLE BORDER=1 BGCOLOR=#FFFFFF CELLSPACING=0><FONT FACE=\"Arial\" COLOR=#000000><CAPTION><B>%s</B></CAPTION></FONT>\r\n"), GetTitle().operator LPCTSTR());
			file.Write(strHTML, strHTML.GetLength());

			strHTML = "<THEAD>\r\n<TR>\r\n";
			file.Write(strHTML, strHTML.GetLength());

			// show fieldnames
			for (size_t i = 0; i < m_dBaseFile->GetFieldCount(); i++)
			{
            DBF_FIELD_INFO info;
            if (m_dBaseFile->GetFieldInfo(i, &info))
		      {
					strHTML.Format(_T("<TH BGCOLOR=#c0c0c0 BORDERCOLOR=#000000 ><FONT SIZE=2 FACE=\"Arial\" COLOR=#000000>%s</FONT></TH>\r\n"), 
                  A2CT(info.name));
					file.Write(strHTML, strHTML.GetLength());
				}
			}
			strHTML = "</TR>\r\n</THEAD>\r\n\r\n<TBODY>\r\n";
			file.Write(strHTML, strHTML.GetLength());

			// show all records
			for(int rc=m_dBaseFile->GetFirstRecord(); rc==DBASE_SUCCESS; rc=m_dBaseFile->GetNextRecord())
  			{
				// Test for "Esc" key
				if( ::GetAsyncKeyState(VK_ESCAPE) < 0)
				{
					break;
				}

				int nItem = m_dBaseFile->GetPosition();
				
				// do not show deleted records
				if (m_dBaseFile->IsRecordDeleted() && !GetActiveFrame()->m_bShowDeletedRecords)
					continue;

				strHTML = "<TR VALIGN=TOP>\r\n";
				file.Write(strHTML, strHTML.GetLength());
				
				for (size_t i = 0; i < m_dBaseFile->GetFieldCount(); i++)
				{
					CString szBuff;

               DBF_FIELD_INFO info;
               m_dBaseFile->GetFieldInfo(i, &info);
					if (info.type == DBF_DATA_TYPE_MEMO)
					{
						szBuff = _T("MEMO");
					}
					else
					{
						m_dBaseFile->Read(i, &szBuff);
					}
					strHTML.Format(_T("<TD BORDERCOLOR=#c0c0c0 ><FONT SIZE=2 FACE=\"Arial\" COLOR=#000000>%s</FONT></TD>\r\n"), 
                  szBuff.operator LPCTSTR());
					file.Write(strHTML, strHTML.GetLength());
				}

				strHTML = "</TR>\r\n";
				file.Write(strHTML, strHTML.GetLength());

				// Update progress control
				int nPos = (nItem*100)/nCount;
				wndProgress.SetPos(nPos);
			}	
			strHTML = "</TBODY>\r\n<TFOOT></TFOOT>\r\n</TABLE>\r\n";
			file.Write(strHTML, strHTML.GetLength());
			strHTML = "</BODY>\r\n";
			file.Write(strHTML, strHTML.GetLength());
			strHTML = "</HTML>\r\n";
			file.Write(strHTML, strHTML.GetLength());
		}
	}
	catch(CFileException *e)
	{
		e->Delete();
		MessageBox(GetFocus(), _T("Failed to export database!"), _T("Export Database"), MB_OK | MB_ICONSTOP);
	}
	// Ensures that idle message is displayed again
	GetActiveFrame()->PostMessage(WM_SETMESSAGESTRING, (WPARAM) AFX_IDS_IDLEMESSAGE, 0L);
}
Exemple #18
0
// CMainFrame message handlers
void CMainFrame::OnViewFullScreen() 
{
	RECT rectDesktop;
	WINDOWPLACEMENT wpNew;

	if (!IsFullScreen())
	{
		// need to hide all status bars
		m_wndStatusBar.ShowWindow(SW_HIDE);
		m_wndToolBar.ShowWindow(SW_HIDE);
		m_wndProgressDialogBar.ShowWindow(SW_HIDE);
		m_wndMasterlistDialogBar.ShowWindow(SW_HIDE);
		// We'll need these to restore the original state.
		GetWindowPlacement (&m_wpPrev);

		m_wpPrev.length = sizeof m_wpPrev;

		//Adjust RECT to new size of window
		::GetWindowRect(::GetDesktopWindow(), &rectDesktop);
		::AdjustWindowRectEx(&rectDesktop, GetStyle(), TRUE, GetExStyle());

		// Remember this for OnGetMinMaxInfo()
		m_FullScreenWindowRect = rectDesktop;

		wpNew = m_wpPrev;
		wpNew.showCmd =  SW_SHOWNORMAL;
		wpNew.rcNormalPosition = rectDesktop;

		m_pwndFullScrnBar=new CToolBar;

		if (!m_pwndFullScrnBar->Create(this,CBRS_SIZE_DYNAMIC|CBRS_FLOATING) ||
			!m_pwndFullScrnBar->LoadToolBar(IDR_FULLSCREEN))
		{
		//	TRACE0("Failed to create toolbar\n");
			return;      // fail to create
		}

		//don't allow the toolbar to dock
		m_pwndFullScrnBar->EnableDocking(0);
		m_pwndFullScrnBar->SetWindowPos(0, 100,100, 0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);   
		m_pwndFullScrnBar->SetWindowText(_T("Full Screen"));
		FloatControlBar(m_pwndFullScrnBar, CPoint(100,100));
		m_bFullScreen=TRUE;
	}
	else
	{
		m_pwndFullScrnBar->DestroyWindow();
		delete m_pwndFullScrnBar;

		m_bFullScreen=FALSE;

		m_wndStatusBar.ShowWindow(SW_SHOWNORMAL);
		m_wndToolBar.ShowWindow(SW_SHOWNORMAL);
		m_wndProgressDialogBar.ShowWindow(SW_SHOWNORMAL);
		m_wndMasterlistDialogBar.ShowWindow(SW_SHOWNORMAL);
		wpNew = m_wpPrev;
	}
	//pView = (CRecordeOperatorDoc*)pChild->GetActiveDocument();
	//if (!pDoc)
	//	return;
	SetWindowPlacement(&wpNew);
	CChildFrame* pChild = NULL;
	pChild = (CChildFrame*)GetActiveFrame();
	if (pChild)
		pChild->FullScreen(m_FullScreenWindowRect);
}
Exemple #19
0
LRESULT CMainFrame::OnHighlightRibbonListItem(WPARAM wp, LPARAM lp)
{
	int nIndex = (int) wp;

	CMFCRibbonBaseElement* pElem = (CMFCRibbonBaseElement*) lp;
	ASSERT_VALID(pElem);

	const UINT uiCommand = pElem->GetID();

	CFrameWnd* pFrame = GetActiveFrame();
	if (pFrame == NULL)
	{
		return 0;
	}

	CDrawDoc* pDoc = (CDrawDoc*)pFrame->GetActiveDocument();
	if (pDoc == NULL)
	{
		return 0;
	}

	ASSERT_VALID(pDoc);

	CDrawView* pView = DYNAMIC_DOWNCAST(CDrawView, pFrame->GetActiveView());
	if (pView == NULL)
	{
		return 0;
	}

	if (uiCommand != ID_VIEW_PAPERCOLOR)
	{
		if (nIndex != -1)
		{
			pView->StorePreviewState();
		}
		else
		{
			pView->RestorePreviewState();
		}
	}

	switch (uiCommand)
	{
	case ID_VIEW_PAPERCOLOR:
	case ID_OBJECT_FILLCOLOR:
	case ID_OBJECT_LINECOLOR:
		{
			COLORREF color = ((CMFCRibbonColorButton*) pElem)->GetHighlightedColor();

			if (uiCommand == ID_VIEW_PAPERCOLOR)
			{
				pDoc->SetPreviewColor(color);
			}
			else if (nIndex != -1)
			{
				if (uiCommand == ID_OBJECT_FILLCOLOR)
				{
					pView->PreviewFillColor(color);
				}
				else
				{
					pView->PreviewLineColor(color);
				}
			}

			CMFCPopupMenu::UpdateAllShadows();
		}
		break;

	case ID_OBJECT_LINEWEIGHT:
		if (nIndex != -1)
		{
			pView->PreviewLineWeight(nIndex + 1);
			CMFCPopupMenu::UpdateAllShadows();
		}
		break;

	case ID_OBJECT_STYLES:
		if (nIndex != -1)
		{
			pView->PreviewStyle(c_Styles[nIndex].clrFill, c_Styles[nIndex].clrLine);
			CMFCPopupMenu::UpdateAllShadows();
		}
		break;
	}

	return 0;
}
Exemple #20
0
void CMainFrame::AdjustObjectSubmenu(CMFCPopupMenu* pMenuPopup)
{
	ASSERT(pMenuPopup != NULL);

	if (pMenuPopup->GetParentPopupMenu() != NULL)
	{
		return;
	}

	// <snippet7>
	// CMFCPopupMenu* pMenuPopup
	CMFCPopupMenuBar* pMenuBar = pMenuPopup->GetMenuBar();
	// </snippet7>
	ASSERT(pMenuBar != NULL);

	// <snippet10>
	// CMFCPopupMenuBar* pMenuBar
	CMFCCustomizeMenuButton* pBtn = (CMFCCustomizeMenuButton*)pMenuBar->GetButton(0);
	pBtn->EnableCustomization(true);
	pBtn->SetSeparator();
	// </snippet10>


	int iIndex = pMenuBar->CommandToIndex(ID_OLE_VERB_FIRST);
	if (iIndex < 0)
	{
		return;
	}

	CFrameWnd* pFrame = GetActiveFrame();

	if (pFrame == NULL)
	{
		return;
	}

	CDrawDoc* pDoc = (CDrawDoc*)pFrame->GetActiveDocument();
	ASSERT_VALID(pDoc);

	// check for single selection
	COleClientItem* pItem = pDoc->GetPrimarySelectedItem(pFrame->GetActiveView());
	if (pItem == NULL || pItem->GetType() == OT_STATIC)
	{
		// no selection, or is 'static' item
		return;
	}

	// only include Convert... if there is a handler for ID_OLE_EDIT_CONVERT
	UINT nConvertID = ID_OLE_EDIT_CONVERT;
	AFX_CMDHANDLERINFO info;
	if (!pDoc->OnCmdMsg(ID_OLE_EDIT_CONVERT, CN_COMMAND, NULL, &info))
		nConvertID = 0;

	HMENU hMenu = pMenuBar->ExportToMenu();
	ASSERT(hMenu != NULL);

	// update the menu
	AfxOleSetEditMenu(pItem, CMenu::FromHandle(hMenu), iIndex, ID_OLE_VERB_FIRST, ID_OLE_VERB_LAST, nConvertID);

	pMenuBar->ImportFromMenu(hMenu);
	::DestroyMenu(hMenu);
}
Exemple #21
0
void CMainFrame::OnWindowCloseall() 
{
	CWnd *pWnd=GetActiveFrame(), *tt;
	if(pWnd==this) return; //there are no child windows
	for(;pWnd;pWnd=tt) { tt=pWnd->GetNextWindow(); pWnd->SendMessage(WM_CLOSE); }
}
bool LayerVolumeBase::SetVoxelByIndex( int* n_in, int nPlane, bool bAdd )
{
  int* nDim = m_imageData->GetDimensions();
  /* for ( int i = 0; i < 3; i++ )
   {
    if ( n_in[i] < 0 || n_in[i] >= nDim[i] )
     return false;
   }
  */
// float* ptr = ( float* )m_imageData->GetScalarPointer( n );
// if ( !ptr )
//  return false;

  int nBrushSize = m_propertyBrush->GetBrushSize();
  int n[3], nsize[3] = { nBrushSize/2+1, nBrushSize/2+1, nBrushSize/2+1 };
  nsize[nPlane] = 1;
  int nActiveComp = GetActiveFrame();
  double* draw_range = m_propertyBrush->GetDrawRange();
  double* exclude_range = m_propertyBrush->GetExcludeRange();
  LayerVolumeBase* ref_layer = m_propertyBrush->GetReferenceLayer();
  vtkImageData* ref = m_imageData;
  int nActiveCompRef = 0;
  if ( ref_layer != NULL )
  {
    ref = ref_layer->GetImageData();
    nActiveCompRef = ref_layer->GetActiveFrame();
  }
  for ( int i = -nsize[0]+1; i < nsize[0]; i++ )
  {
    for ( int j = -nsize[1]+1; j < nsize[1]; j++ )
    {
      for ( int k = -nsize[2]+1; k < nsize[2]; k++ )
      {
        n[0] = n_in[0] + i;
        n[1] = n_in[1] + j;
        n[2] = n_in[2] + k;
        if ( n[0] >= 0 && n[0] < nDim[0] &&
             n[1] >= 0 && n[1] < nDim[1] &&
             n[2] >= 0 && n[2] < nDim[2] &&
             MyUtils::GetDistance<int>( n, n_in ) <= nBrushSize/2.0 )
        {
          if ( bAdd )
          {
            double fvalue = ref->GetScalarComponentAsDouble( n[0], n[1], n[2], nActiveCompRef );
            if ( ( m_propertyBrush->GetDrawRangeEnabled() &&
                   ( fvalue < draw_range[0] || fvalue > draw_range[1] ) ) ||
                 ( m_propertyBrush->GetExcludeRangeEnabled() &&
                   ( fvalue >= exclude_range[0] && fvalue <= exclude_range[1] ) ) ||
                 ( m_propertyBrush->GetDrawConnectedOnly() &&
                   ( !GetConnectedToOld( m_imageData, nActiveComp, n, nPlane ) ) ) )
            {
              ;
            }
            else
            {
              m_imageData->SetScalarComponentFromFloat( n[0], n[1], n[2], nActiveComp, m_fFillValue );
              UpdateVoxelValueRange( m_fFillValue );
            }
          }
          else
          {
            m_imageData->SetScalarComponentFromFloat( n[0], n[1], n[2], nActiveComp, m_fBlankValue );
          }
        }
      }
    }
  }
  return true;
}
void TemplateFrame::UpdateTitle()
{
	if (template_canvas) SetTitle(template_canvas->GetCanvasTitle());
	if (GetActiveFrame()==this) GdaFrame::GetGdaFrame()->SetTitle(GetTitle());
}
Exemple #24
0
void CDBFExplorerDoc::OnFileExport() 
{
 	static TCHAR szFilters[] = _T("Text Files (*.txt;*.csv)|*.txt;*.csv|HTML Files (*.html;*.htm)|*.html;*.htm||");
	
	CString strFileName = GetTitle();
	int nPos = strFileName.ReverseFind('.');
	if (nPos != -1)
		strFileName = strFileName.Left(nPos);
	
	CExportFileDialog dlg(FALSE, NULL, strFileName, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, szFilters, GetActiveFrame());

	dlg.m_ofn.lpstrTitle = _T("Export database");

	if (dlg.DoModal() == IDOK)
	{
		strFileName = dlg.GetPathName();
		CString strExtension = dlg.GetFileExt();
		if (dlg.m_strType == _T("Text Files (*.txt;*.csv)"))
		{
			if (strExtension.IsEmpty())
				strFileName += _T(".txt");

			ExportToText(strFileName);
		}
		else
		if (dlg.m_strType == _T("HTML Files (*.html;*.htm)"))
		{
			if (strExtension.IsEmpty())
				strFileName += _T(".html");

			ExportToHTML(strFileName);
		}
	}	
}