/////////////////////////////////////
// @mfunc Called when view was created - we try to let scintilla load a file if there is one
// @rvalue void | not used
//
void CScintillamfcView::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
	CDocument *pDoc = GetDocument();
	CString strTitle = pDoc->GetPathName();
	m_wndScintilla.Init();
	//m_wndScintilla.LoadFile(strTitle);
	m_wndScintilla.SetLexer(SCLEX_CPP);
	m_wndScintilla.SendMessage(SCI_SETKEYWORDS, 0, (long)_T(
		"argCount and and_eq  "
		"bitand bitor break "
		"cslVersion cslCompiler cslBuilt cslFileName cslFunction "
		"case catch const continue "
		"default do "
		"else extern exists"
		"false for "
		"if "
		"mainArgVals MAXLONG "
		"not not_eq "
		"or or_eq "
		"PATHSEPARATOR "
		"resize return "
		"sizeof static switch "
		"throw true try "
		"var void "
		"while xor xor_eq"
	));
	//m_wndScintilla.SendMessage(SCI_SETCONTROLCHARSYMBOL, 0, 0);
	//m_wndScintilla.SendMessage(SCI_STYLESETVISIBLE, STYLE_CONTROLCHAR, 0);
	//m_wndScintilla.SetControlCharSymbol();
}
Esempio n. 2
0
LRESULT CMainFrame::OnGetTabToolTip(WPARAM /*wp*/, LPARAM lp)
{
	CMFCTabToolTipInfo* pInfo = (CMFCTabToolTipInfo*) lp;
	ASSERT(pInfo != NULL);
	if (!pInfo)
	{
		return 0;
	}

	ASSERT_VALID(pInfo->m_pTabWnd);

	if (!pInfo->m_pTabWnd->IsMDITab())
	{
		return 0;
	}

	CFrameWnd* pFrame = DYNAMIC_DOWNCAST(CFrameWnd, pInfo->m_pTabWnd->GetTabWnd(pInfo->m_nTabIndex));
	if (pFrame == NULL)
	{
		return 0;
	}

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

	pInfo->m_strText = pDoc->GetPathName();
	if(pInfo->m_strText.IsEmpty())
		pInfo->m_strText=pDoc->GetTitle();

	return 0;
}
Esempio n. 3
0
CDocTemplate::Confidence CDocTemplate::MatchDocType(LPCTSTR lpszPathName,
	CDocument*& rpDocMatch)
{
	ASSERT(lpszPathName != NULL);
	rpDocMatch = NULL;

	// go through all documents
	POSITION pos = GetFirstDocPosition();
	while (pos != NULL)
	{
		CDocument* pDoc = GetNextDoc(pos);
		if (AfxComparePath(pDoc->GetPathName(), lpszPathName))
		{
			// already open
			rpDocMatch = pDoc;
			return yesAlreadyOpen;
		}
	}

	// see if it matches our default suffix
	CString strFilterExt;
	if (GetDocString(strFilterExt, CDocTemplate::filterExt) &&
	  !strFilterExt.IsEmpty())
	{
		// see if extension matches
		ASSERT(strFilterExt[0] == '.');
		LPCTSTR lpszDot = _tcsrchr(lpszPathName, '.');
		if (lpszDot != NULL && lstrcmpi(lpszDot, strFilterExt) == 0)
			return yesAttemptNative; // extension matches, looks like ours
	}

	// otherwise we will guess it may work
	return yesAttemptForeign;
}
Esempio n. 4
0
void CFileView::OnProperties()
{
    CMDIFrameWnd   *pMain  = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;      
	CMDIChildWnd   *pChild  = (CMDIChildWnd *)pMain->GetActiveFrame(); 
	CDocument* pDoc = NULL;
	pDoc = pChild->GetActiveDocument();
	//9-8添加判断,如果不判断,都关闭后再点击项目管理项,程序会崩溃
	if( pDoc!= NULL)
	{
		CString filePath=pDoc->GetPathName();
		filePath.Trim();
		filePath.MakeLower();
		CString fileEx=filePath.Right(2);
		if(fileEx==_T(".t"))
		{
			int iLength = lstrlen(filePath) ;
			int iIndex = filePath.ReverseFind(L'\\') ;
			CString fileName = filePath.Right(iLength - iIndex - 1); 
			((CMainFrame*)AfxGetApp()->m_pMainWnd)->SetProjProperty(fileName,filePath);
		}
		else
		{
			((CMainFrame*)AfxGetApp()->m_pMainWnd)->SetProjProperty(_T(""),_T(""));
		}
	}
}
extern "C" __declspec(dllexport) bool GetWorkspaceName(LPTSTR buffer, int bufSize)
{
	if (!g_app)
		return false;

	POSITION pos = g_app->GetFirstDocTemplatePosition();
	while (pos)
	{
		CDocTemplate* dt = g_app->GetNextDocTemplate(pos);
		if (strcmp(dt->GetRuntimeClass()->m_lpszClassName, "CProjectWorkspaceDocTemplate") == 0)
		{
			POSITION docPos = dt->GetFirstDocPosition();
			if (!docPos)
				break;

			CDocument* doc = dt->GetNextDoc(docPos);
			if (!doc)
				break;

			strcpy(buffer, doc->GetPathName());

			return true;
		}
	}

	return false;
}
Esempio n. 6
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 );
}
Esempio n. 7
0
// @pymethod string|PyCDocument|GetPathName|Returns the full path name of the current document.
// The string will be empty if no path name has been set.
PyObject *
ui_doc_get_path_name(PyObject *self, PyObject *args)
{
	CDocument *pDoc;
	if (!(pDoc=PyCDocument::GetDoc(self)))
		return NULL;
	CHECK_NO_ARGS2(args,GetPathName);
	GUI_BGN_SAVE;
	CString path = pDoc->GetPathName(); // @pyseemfc CDocument|GetPathName
	GUI_END_SAVE;
	return PyWinObject_FromTCHAR(path);
}
Esempio n. 8
0
CDocument* CDocTemplateEx::OpenDocumentFile(LPCTSTR lpszPathName, BOOL bMakeVisible)
{
	CAIPIApp* pApp = (CAIPIApp*)AfxGetApp();

	if (m_docList.GetCount() == 1)
	{
		CDocument* pDocument = (CDocument*)m_docList.GetHead();
		BOOL e = pDocument->GetPathName().IsEmpty();
		BOOL m = pDocument->IsModified();

		if (lpszPathName != NULL && pDocument->GetPathName().IsEmpty() && pDocument->IsModified())
		{
			
			pApp->AipiOpenDocumentFile(lpszPathName);
	
			CWaitCursor wait;
			if (!pDocument->OnOpenDocument(lpszPathName))
			{
				// user has be alerted to what failed in OnOpenDocument
				TRACE0("CDocument::OnOpenDocument returned FALSE.\n");
				return NULL;
			}
			
			pDocument->SetPathName(lpszPathName);
			POSITION pos = pDocument->GetFirstViewPosition();
			CView* pView = pDocument->GetNextView(pos);
			CFrameWnd* pFrame = pView->GetParentFrame();
			InitialUpdateFrame(pFrame, pDocument);
			return pDocument;
		}
	}

	pApp->AipiOpenDocumentFile(lpszPathName);
	

	return CMultiDocTemplate::OpenDocumentFile(lpszPathName, bMakeVisible);
}
Esempio n. 9
0
void CdcmviewerView::draw_dcm_header(CDC *pDC,dicom::DataSet &data,int x, int &y,int line_height)
{
	if(m_create_dcm_img_error)
	{
		CDocument *pDoc = GetDocument();
		if(pDoc)
		{
			CString msg;
			msg.Format( _T("unrecognized file :%s"),pDoc->GetPathName());
			pDC->TextOut(x,y,msg);
		}
		else
		{
			pDC->TextOut(x,y,_T("no file"));
		}
		y+= line_height;
	}
	CString text;
	CdcmviewerDoc* pDoc = (CdcmviewerDoc*)GetDocument();
	if(pDoc && pDoc->m_photometric_interpretation!="RGB")
	{
		text.Format( _T("ww:%f,wc:%f,"),get_ww(),get_wc());
		theApp.DebugOutput(text);
		pDC->TextOut(x,y,text);
		y += line_height;
	}

	if(m_number_of_frame>1)
	{
		text.Format("frame index:%04d,navigate to next frame by key PAGE DOWN/RIGHT ARROW/DOWN ARROW",m_frame_index);
		pDC->TextOut(x,y,text);
		y += line_height;
	}
	std::stringstream oss;
	for(dicom::DataSet::const_iterator it=data.begin();
		it!=data.end();
		it++)
	{
		dicom::Tag tag = it->first;
		if(GroupTag(tag)==0x28 || /*GroupTag(tag) == 0x08 ||*/ GroupTag(tag)==0x10)
		{
			oss.str("");
			IndentDumper::write_tag(oss,tag,0);
			oss<<it->second;
			pDC->TextOut(x,y,oss.str().c_str());
			y += line_height;
		}
	}
}
Esempio n. 10
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 );
}
Esempio n. 11
0
CDocument* CFileView::FindSkinFile(CString& strPath)
{
	CDocTemplate* pDocTemplate = theApp.GetUIDocTemplate();
	POSITION posDoc = pDocTemplate->GetFirstDocPosition();
	while (posDoc != NULL)
	{
		CDocument* pDoc = pDocTemplate->GetNextDoc(posDoc);
		if ((pDoc != NULL) && (pDoc->GetPathName() == strPath))
		{
			return pDoc;
		}
	}

	return NULL;
}
Esempio n. 12
0
BOOL PSGame::LoadHistory()
{
	// Get the name of the game.
	CFrameWnd* pFrame = (CFrameWnd*) AfxGetMainWnd();
	CDocument* pDoc = pFrame->GetActiveDocument();
	CString strName = pDoc->GetPathName();
	if (strName == "")
		return FALSE;

	// Open the history file.
	char* path_buffer = strName.GetBuffer(_MAX_PATH);
	char drive[_MAX_DRIVE];
	char dir[_MAX_DIR];
	char fname[_MAX_FNAME];
	char ext[_MAX_EXT];
	_splitpath( path_buffer, drive, dir, fname, ext );
	strName.Format("%s%s%s%s", drive, dir, fname, ".dph");

	CFile f;
	CFileException fe;
	f.Open(strName, CFile::modeRead, &fe);
	if (fe.m_cause)
		return FALSE;

	// Load the history.
	PSHistory* pHist = new PSHistory;
	CArchive arh(&f, CArchive::load);
	pHist->Serialize(arh);
	arh.Close();
	f.Close();

	// If the data in the last step of the history is the same as the game's data, copy the history
	// into the game's history. If not, disregard the loaded history.
	PSStep* pLastStep = pHist->GetLastStep();
	PSData* pLastData = pLastStep->GetData();
	if (!(*pLastData == m_Data))// Operator != not defined.
	{
		AfxMessageBox(IDS_BAD_HISTORY);
		delete pHist;
		return FALSE;
	}

	SetHistory(pHist);
	SetCurrentStep(pLastStep);
	return TRUE;
}
Esempio n. 13
0
BOOL OleDocRoot::OnSaveDocument(const char* pszPathName)
  {
  gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands
  gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands, call more than once!

  if (gs_Exec.Busy())
    {
    LogError("SysCAD", 0, "Must not be running");
    return False;
    }
  //KGA : 7/5/96 : document sometimes not active ??? causes cmd to go to wrong document/window!!!
  //if (pFirstDoc!=this)
  //  OnActivate(True); 
  gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands, call more than once!

  //Check if a SaveAs is using a filename that is allready open in this project...
//  //TODO RESTORE

  /****/
  const int len = strlen(pszPathName);
  CDocTemplate* pTempl = GetDocTemplate();
  if (pTempl)
    {
    POSITION Pos = pTempl->GetFirstDocPosition();
    while (Pos)
      {
      CDocument * pDoc = pTempl->GetNextDoc(Pos);
      if (pDoc!=this)
        {
        CString PathName = pDoc->GetPathName();
        if (PathName.GetLength()==len && _stricmp((const char*)PathName, pszPathName)==0)
          {
          LogError("SysCAD", LF_Exclamation, "Save As '%s' failed. Document/window allready open!", pszPathName);
          return False;
          }
        }
      }
    }
  /***/
  //Strng Cmd;
  //Cmd.Set("SAVE DOCUMENT %s\r",pszPathName);
  //gs_pCmd->ProcessAStr(Cmd());

  return COleLinkingDoc::OnSaveDocument(pszPathName);//dn.GetBuffer(0));
  }
BOOL COXChildFrameState::ComputeProperties(CFrameWnd* pFrameWnd)
	{
	ASSERT_VALID(this);

	// Get the position of the frame window
	::ZeroMemory(&m_framePlacement, sizeof(WINDOWPLACEMENT));
	m_framePlacement.length = sizeof(WINDOWPLACEMENT);
	if (pFrameWnd != NULL)
	{
		VERIFY(pFrameWnd->GetWindowPlacement(&m_framePlacement));
		if(!pFrameWnd->IsWindowVisible())
		{
			m_framePlacement.showCmd=SW_HIDE;
		}
	}

	// Get the document and view of this frame
	CDocument* pDoc = NULL;
	CView* pView = NULL;
	if (!GetDocView(pFrameWnd, pDoc, pView))
		{
		TRACE0("COXChildFrameState::ComputeProperties : Failed to get the doc-view for this frame, failing\n");
		return FALSE;
		}

	// Get the file path of the document
	if (pDoc != NULL)
		m_sDocPath = pDoc->GetPathName();

	// Store the name of the classes of doc, frame and view
	if (pDoc != NULL)
		m_sDocClassName = pDoc->GetRuntimeClass()->m_lpszClassName;
	if (pFrameWnd != NULL)
		m_sFrameClassName = pFrameWnd->GetRuntimeClass()->m_lpszClassName;
	if (pView != NULL)
		m_sViewClassName = pView->GetRuntimeClass()->m_lpszClassName;

	EmptySplitterPanes(m_pSplitterPanes);
	if (m_bSaveSplitterPanes)
		ComputeSplitterPanes(pFrameWnd);

	ASSERT_VALID(this);
	return TRUE;
	}
BOOL CBackStagePageInfo::OnInitDialog() 
{
	LFDialog::OnInitDialog();

	LFStaticLayout* pLayout = (LFStaticLayout*)GetLayout();
	ASSERT_VALID(pLayout);
	
	pLayout->AddAnchor(IDC_PATH_LABEL, LFStaticLayout::e_MoveTypeNone, LFStaticLayout::e_SizeTypeHorz);
	
	pLayout->AddAnchor(IDC_SEPARATOR_1, LFStaticLayout::e_MoveTypeNone, LFStaticLayout::e_SizeTypeHorz);
	pLayout->AddAnchor(IDC_TEXT1, LFStaticLayout::e_MoveTypeNone, LFStaticLayout::e_SizeTypeHorz);
	
	pLayout->AddAnchor(IDC_SEPARATOR_2, LFStaticLayout::e_MoveTypeNone, LFStaticLayout::e_SizeTypeHorz);
	pLayout->AddAnchor(IDC_TEXT2, LFStaticLayout::e_MoveTypeNone, LFStaticLayout::e_SizeTypeHorz);
	
	pLayout->AddAnchor(IDC_SEPARATOR_3, LFStaticLayout::e_MoveTypeNone, LFStaticLayout::e_SizeTypeHorz);
	pLayout->AddAnchor(IDC_TEXT3, LFStaticLayout::e_MoveTypeNone, LFStaticLayout::e_SizeTypeHorz);
	
	pLayout->AddAnchor(IDC_SEPARATOR_4, LFStaticLayout::e_MoveTypeHorz, LFStaticLayout::e_SizeTypeVert);
	
	pLayout->AddAnchor(IDC_INFO_LABEL, LFStaticLayout::e_MoveTypeHorz, LFStaticLayout::e_SizeTypeNone);
	pLayout->AddAnchor(IDC_SEPARATOR_5, LFStaticLayout::e_MoveTypeHorz, LFStaticLayout::e_SizeTypeNone);
	pLayout->AddAnchor(IDC_PREVIEW, LFStaticLayout::e_MoveTypeHorz, LFStaticLayout::e_SizeTypeNone);
	pLayout->AddAnchor(IDC_TEXT4, LFStaticLayout::e_MoveTypeHorz, LFStaticLayout::e_SizeTypeNone);

	CFrameWnd* pMainFrame = (CFrameWnd*)AfxGetMainWnd();
	
	CFrameWnd* pFrame = pMainFrame->GetActiveFrame();
	if (pFrame != NULL)
	{
		CDocument* pDoc = pFrame->GetActiveDocument();
		if (pDoc != NULL)
		{
			m_strDocName = pDoc->GetTitle();
			m_strPath = pDoc->GetPathName();
		}
	}

	PreparePreviewBitmap();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Esempio n. 16
0
// FindOpenDocument - if the C++ framework has a document with this name open,
// then return a pointer to it, else NULL.
CDocument *CProtectedWinApp::FindOpenDocument(const TCHAR *lpszFileName)
{
	POSITION posTempl = m_pDocManager->GetFirstDocTemplatePosition();
	CDocument* pOpenDocument = NULL;

	TCHAR szPath[_MAX_PATH];
	if (!AfxFullPath(szPath, lpszFileName))
		_tcscpy(szPath, lpszFileName);

	while (posTempl) {
		CDocTemplate* pTemplate = m_pDocManager->GetNextDocTemplate(posTempl);
		ASSERT(pTemplate->IsKindOf(RUNTIME_CLASS(CDocTemplate)));
		// go through all documents
		POSITION posDoc = pTemplate->GetFirstDocPosition();
		while (posDoc) {
			CDocument* pDoc = pTemplate->GetNextDoc(posDoc);
			if (lstrcmpi(pDoc->GetPathName(), szPath) == 0)
				return pDoc;
		}
	}
	return NULL;
}
Esempio n. 17
0
CRossDoc* CSemanticStrView::FindRossDoc(DictTypeEnum RossType)
{
	CString strPathName = GetNormalizedRossPath(RossType);

	CDocTemplate* pRossDocTemplate = GetRossDocTemplate();
	assert(pRossDocTemplate);

	CDocument* pDoc;
	POSITION pos = pRossDocTemplate->GetFirstDocPosition();
	while( pos )
	{
		pDoc = pRossDocTemplate->GetNextDoc(pos);	
		CString strPathNameDoc = pDoc->GetPathName();
		strPathNameDoc.MakeLower();
		if( strPathNameDoc == strPathName )
		{
			return (CRossDoc*)pDoc;
		}				
	}

	return 0;
}
Esempio n. 18
0
// Returns the name of the currently opened file, including extension (if saved).
CString CTemplateFormater::GetFile(void)
{
	// Use the generic view class to make this class as portable as possible
	CView* pView = NULL;

	CMDIFrameWnd* pFrame = reinterpret_cast<CMDIFrameWnd*>(AfxGetApp()->m_pMainWnd);
	
	// Get the active MDI child window.
	CMDIChildWnd* pChild = 
		reinterpret_cast<CMDIChildWnd*>(pFrame->GetActiveFrame());		
	// or CMDIChildWnd *pChild = pFrame->MDIGetActive();
	
	// Get the active view attached to the active MDI child window.
	pView = reinterpret_cast<CView*>(pChild->GetActiveView());		

	ASSERT(pView != NULL);
	// If at this point the view could not be obtained, the leave
	if (pView != NULL)
	{
		CDocument* pDoc = pView->GetDocument();
		ASSERT(pDoc != NULL);
		if (pDoc != NULL)
		{
			CString strPathName = pDoc->GetPathName(); 

			if (!strPathName.IsEmpty())
			{
				CCFileSpec fs(strPathName);	//NOTE: This part is not portable!
				return fs.GetFileName();
			}
			else
			{
				return pDoc->GetTitle();
			}
		}
	}

	return _T("");
};
Esempio n. 19
0
void CCsgIdeView::OnInitialUpdate()
{
	CScintillaView::OnInitialUpdate();

	CScintillaCtrl& rCtrl = GetCtrl();

	//Setup the Lexer
	rCtrl.SetLexer(SCLEX_LUA);
	rCtrl.StyleSetFont(STYLE_DEFAULT, "Consolas");
	rCtrl.StyleSetSize(STYLE_DEFAULT, 10);
	rCtrl.SetKeyWords(0, LuaKeywords);

	//Setup styles
	SetAStyle(STYLE_DEFAULT, RGB(0, 0, 0), RGB(0xff, 0xff, 0xff), 11, "Consolas");
	rCtrl.StyleClearAll();
	SetAStyle(SCE_LUA_DEFAULT, RGB(0, 0, 0));
	SetAStyle(SCE_LUA_COMMENT, RGB(0, 0x80, 0));
	SetAStyle(SCE_LUA_COMMENTLINE, RGB(0, 0x80, 0));
	SetAStyle(SCE_LUA_COMMENTDOC, RGB(0, 0x80, 0));
	SetAStyle(SCE_LUA_NUMBER, RGB(0, 0x80, 0x80));
	SetAStyle(SCE_LUA_WORD, RGB(0, 0, 0x80));
	//rCtrl.StyleSetBold(SCE_LUA_WORD, 1);
	SetAStyle(SCE_LUA_STRING, RGB(0x80, 0, 0x80));
	SetAStyle(SCE_LUA_IDENTIFIER, RGB(0, 0, 0));
	SetAStyle(SCE_LUA_PREPROCESSOR, RGB(0x80, 0, 0));
	SetAStyle(SCE_LUA_OPERATOR, RGB(0x80, 0x80, 0));

	rCtrl.SetKeyWords(1, LuaFunctions);
	SetAStyle(SCE_LUA_WORD2, RGB(0x20, 0x20, 0x80));
	//rCtrl.StyleSetBold(SCE_LUA_WORD2, 1);

	rCtrl.SetKeyWords(2, UserFunctions);
	SetAStyle(SCE_LUA_WORD3, RGB(150, 0, 50));
	//rCtrl.StyleSetBold(SCE_LUA_WORD3, 1);

	rCtrl.SetKeyWords(3, UserConstants);
	SetAStyle(SCE_LUA_WORD4, RGB(255, 0, 0));
	//rCtrl.StyleSetBold(SCE_LUA_WORD4, 1);

	rCtrl.SetKeyWords(4, UserVariables);
	SetAStyle(SCE_LUA_WORD5, RGB(200, 50, 0));
	//rCtrl.StyleSetBold(SCE_LUA_WORD5, 1);

	//Setup folding
	rCtrl.SetMarginWidthN(2, 16);
	rCtrl.SetMarginSensitiveN(2, TRUE);
	rCtrl.SetMarginTypeN(2, SC_MARGIN_SYMBOL);
	rCtrl.SetMarginMaskN(2, SC_MASK_FOLDERS);
	rCtrl.SetProperty(_T("fold"), _T("1"));

	rCtrl.SetTabWidth(4);

	//Setup markers
	DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_MINUS, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0xFF));
	DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_PLUS, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
	DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
	DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
	DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
	DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
	DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));

	//Setup auto completion
	rCtrl.AutoCSetSeparator(10); //Use a separator of line feed

	//Setup call tips
	rCtrl.SetMouseDwellTime(1000);

	//Enable Multiple selection
	rCtrl.SetMultipleSelection(TRUE);

	CDocument *pDoc = GetDocument();
	LoadFile(pDoc->GetPathName());
}
Esempio n. 20
0
/////////////////////////////////////////////////////////////////////////////
// 打开文档,如果不能打开则返回FALSE
/////////////////////////////////////////////////////////////////////////////
CDocument* CPlugIn::OpenDocument(LPCTSTR lpszFileName)
{
	CString strFileName = lpszFileName;
	strFileName.MakeLower();
	int nPos = strFileName.ReverseFind('.');
	if(nPos == -1)
	{
		return NULL;
	}

	CString strFileExt = strFileName;
	strFileExt.Delete(0, nPos+1);

	for(int i=0; i<m_arDocExtend.GetSize(); i++)
	{
		for(int j=0; j<m_arDocExtend[i].m_arDocExt.GetSize(); j++)
		{
			if(strFileExt == m_arDocExtend[i].m_arDocExt[j])
			{
				// 如果是动态加载的OWM,并且未加载过,就先加载
				if((m_pDocTemplate == NULL) && (m_nType & OWM_DYNLOAD))
				{
					LoadOwmPlugIn();
				}

				// 如果文档模板为空,则此种文档模板不能使用,继续向下搜索
				if(m_pDocTemplate == NULL)
				{
					continue;
				}

				// 先判断是否已经打开了
				strFileName.Replace("/", "\\");

				CView* pView = NULL;
				POSITION posdoc = m_pDocTemplate->GetFirstDocPosition();
				while(posdoc != NULL)
				{
					CDocument* pDoc = m_pDocTemplate->GetNextDoc(posdoc);
					CString strFilePathExist = pDoc->GetPathName();
					strFilePathExist.MakeLower();
					strFilePathExist.Replace("/", "\\");
					if(strFilePathExist == strFileName)
					{
						// 如果已经打开则激活
						POSITION posview = pDoc->GetFirstViewPosition();
						if(posview)	// 如果视存在
						{
							CView* pView = pDoc->GetNextView(posview);	// 取到视指针
							pView->GetParentFrame()->ActivateFrame(); // 激活框架
						}
						return pDoc;
					}
				}

				return m_pDocTemplate->OpenDocumentFile(lpszFileName);
			}
		}
	}

	return NULL;
}
Esempio n. 21
0
/////////////////////////////////////////////////////////////////////////////
// CDocSelector message handlers
BOOL CDocSelector::AddButton( CWnd* wnd, WORD wIcon ,HICON hIcon )
{
	CRect rect;
	GetClientRect(&rect);

	// Yogesh Jagota
	CDocument* pDoc = ((CView *) wnd)->GetDocument();

	CString sPath = pDoc->GetPathName();
	CString sFileName;
	
	if ( sPath.IsEmpty() )
		sPath = pDoc->GetTitle();

	// Can be only the filename, like Noname01
	if ( sPath.Find( _T('\\') ) != -1 )
		sFileName = sPath.Mid( sPath.ReverseFind( _T('\\') ) + 1 );
	else
		sFileName = sPath;

	// If there is no space left to display extra buttons...
	int nNewSize = ( ( rect.Width() - DS_MENU_BUTTON_WIDTH ) 
		/ ( m_Buttons.GetSize() + 1 ) ) - DS_SEPERATER_MARGIN;

	bool bShowButton = true;
	if ( nNewSize <= MINWIDTH )
	{
		// Check if the menu button is displayed, if not, display it...
		m_btnMenuButton.ShowWindow( SW_SHOW );

		// Don't show the button...
		bShowButton = false;
	}
	else
		m_nDisplayedButtons++;

	// End Yogesh Jagota

	CSwitcherButton* newbutton = new CSwitcherButton();

	 // Yogesh Jagota
	newbutton->m_AttachedView = wnd;

	// I am saving the frame to make life easier in case
	// of activation in selection process...
	CMDIFrameWnd *pFrame = (CMDIFrameWnd *)AfxGetMainWnd();
	CWnd * pWnd = pFrame->GetWindow( GW_CHILD );
	ASSERT (pWnd);
	pWnd = pWnd->GetWindow( GW_CHILD );
	while (pWnd)
	{
		if ( ((CFrameWnd *)pWnd)->GetActiveView() == (CView*)wnd )
			newbutton->m_FrameWnd = (CFrameWnd *)pWnd;

		pWnd = pWnd->GetWindow( GW_HWNDNEXT );
	}

	// Load the icon....
	if ( hIcon)
	{
		newbutton->m_iIcon=hIcon;
		newbutton->m_iIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	}
	
	else

	if ( wIcon != -1 )
		newbutton->m_iIcon = ::LoadIcon( AfxGetInstanceHandle(), 
			MAKEINTRESOURCE( wIcon ) );
	// End Yogesh Jagota

	newbutton->m_iID = m_Buttons.GetSize();
	if (!newbutton->DoCreate(this, m_iNextButtonStart, 
		rect.top + 3, m_iButtonWidth, DS_HEIGHT - 2, 
		sFileName, sPath )) // Yogesh Jagota
	{
		return FALSE;
	}

	if ( !bShowButton )
		newbutton->ShowWindow( SW_HIDE );

	m_Buttons.Add((void*)newbutton);
	m_iNextButtonStart += m_iButtonWidth + DS_SEPERATER_MARGIN;

	if (m_iNextButtonStart - DS_SEPERATER_MARGIN > rect.Width())
	{
		// this loop makes a neat little animation
		int newsize = ((rect.Width() - DS_MENU_BUTTON_WIDTH ) 
			/ (m_Buttons.GetSize())) - DS_SEPERATER_MARGIN;

//		Yogesh Jagota. Removed animation because did'nt liked it.
//		Remove if you want animated addition or removal of buttons.
//
//		register int y;
//		for (y = m_iButtonWidth; y >= newsize; y-=3)
//		{
//			ResizeButtons(y);
//			Sleep(15);
//		}
//
//		if (y != newsize)
//			/* ResizeButtons(newsize); */ <- this is the next line...
//		End Yogesh Jagota

		ResizeButtons(newsize);

		if (m_iButtonWidth < MINWIDTH)
		{
			// the smallest allowable button size has been reached...
			// in this version, we can't handle this
			ASSERT(0);
			return FALSE;
		}
	}
	else
		m_btnMenuButton.ShowWindow( SW_HIDE );

	// Yogesh Jagota
	if ( m_iSelectedButton != -1 )
		((CSwitcherButton *) m_Buttons.GetAt( m_iSelectedButton ))->Unselect();

	m_iSelectedButton = newbutton->m_iID;
	((CSwitcherButton *) m_Buttons.GetAt( m_iSelectedButton ))->Select();
	// End Yogesh Jagota

	return TRUE;
}
Esempio n. 22
0
STDMETHODIMP COlePropertiesDialog::XOleUIObjInfo::GetObjectInfo(
	DWORD dwObject, DWORD* lpdwObjSize, LPTSTR* lplpszLabel,
	LPTSTR* lplpszType, LPTSTR* lplpszShortType, LPTSTR* lplpszLocation)
{
	COleClientItem* pItem = (COleClientItem*)dwObject;
	ASSERT_VALID(pItem);
	BOOL bIsLink = (pItem->GetType() == OT_LINK);

	if (lpdwObjSize != NULL)
	{
		ASSERT(pItem->m_lpStorage != NULL);

		// try ILockBytes first, then IStorage
		STATSTG statStg;
		if ((pItem->m_lpLockBytes == NULL ||
			pItem->m_lpLockBytes->Stat(&statStg, STATFLAG_NONAME) != S_OK) &&
			pItem->m_lpStorage->Stat(&statStg, STATFLAG_NONAME) != S_OK)
		{
			*lpdwObjSize = 0xFFFFFFFF;
		}
		else
		{
			ASSERT(statStg.pwcsName == NULL);
			if (statStg.cbSize.HighPart > 0)
				*lpdwObjSize = 0xFFFFFFFE;
			else if (statStg.cbSize.LowPart == 0)
				*lpdwObjSize = 0xFFFFFFFF;
			else
				*lpdwObjSize = statStg.cbSize.LowPart;
		}
	}

	if (lplpszLabel != NULL)
	{
		TCHAR szFormatLink[128];
		AfxLoadString(AFX_IDS_PASTELINKEDTYPE, szFormatLink, _countof(szFormatLink));
		TCHAR szFormatObj[] = _T("%s");
		LPTSTR lpszFormat = bIsLink ? szFormatLink : szFormatObj;
		CString strType;
		pItem->GetUserType(USERCLASSTYPE_FULL, strType);
		CString strResult;
		strResult.Format(lpszFormat, (LPCTSTR)strType);
		*lplpszLabel = AfxAllocTaskString(strResult);
	}

	if (lplpszType != NULL)
	{
		LPOLESTR lpOleStr;
		pItem->m_lpObject->GetUserType(USERCLASSTYPE_FULL, &lpOleStr);
		*lplpszType = TASKSTRINGOLE2T(lpOleStr);
	}

	if (lplpszShortType != NULL)
	{
		LPOLESTR lpOleStr;
		pItem->m_lpObject->GetUserType(USERCLASSTYPE_SHORT, &lpOleStr);
		*lplpszShortType = TASKSTRINGOLE2T(lpOleStr);
	}

	if (lplpszLocation != NULL)
	{
		if (bIsLink)
		{
			LPOLELINK lpOleLink = NULL;
			pItem->m_lpObject->QueryInterface(IID_IOleLink, (LPVOID*)&lpOleLink);
			ASSERT(lpOleLink != NULL);
			LPOLESTR lpOleStr;
			lpOleLink->GetSourceDisplayName(&lpOleStr);
			*lplpszLocation = TASKSTRINGOLE2T(lpOleStr);
			lpOleLink->Release();
		}
		else
		{
			CDocument* pDoc = (CDocument*)pItem->GetDocument();
			CString strLocation = pDoc->GetPathName();
			if (strLocation.IsEmpty())
				strLocation = pDoc->GetTitle();
			*lplpszLocation = AfxAllocTaskString(strLocation);
		}
	}

	return S_OK;
}