Esempio n. 1
0
BOOL CCoolFormat3Doc::SaveModified()
{
	if (!IsModified())
		return TRUE;        // ok to continue

	// get name/title of document
	CString name;
	if (m_strPathName.IsEmpty())
	{
		// get name based on caption
		name = GetTitle();
		if (name.IsEmpty())
			ENSURE(name.LoadString(AFX_IDS_UNTITLED));
		if (m_bTitleMark)
		{
			name = name.Left(name.GetLength() - 2);
		}
	}
	else
	{
		// get name based on file title of path name
		name = m_strPathName;
		GetFileTitle(m_strPathName, name.GetBuffer(_MAX_PATH), _MAX_PATH);
		name.ReleaseBuffer();
	}	

	CString prompt;
	BOOL bNameVaild = prompt.LoadString(IDS_IS_WANTSAVE);
	ASSERT(bNameVaild);
	CString strMsg;
	strMsg.Format(prompt, name);	
	
	switch (CFMessageBox(strMsg, MB_YESNOCANCEL| MB_ICONINFORMATION))
	{
	case IDCANCEL:
		return FALSE;       // don't continue

	case IDYES:
		// If so, either Save or Update, as appropriate
		if (!DoFileSave())
			return FALSE;       // don't continue
		break;

	case IDNO:
		// If not saving changes, revert the document
		break;

	default:
		ASSERT(FALSE);
		break;
	}
	return TRUE;    // keep going
}
Esempio n. 2
0
BOOL CSetEditDlg::PreTranslateMessage(MSG* pMsg)
{
	if (WM_LBUTTONDOWN == pMsg->message)
	{
		if (pMsg->hwnd == GetDlgItem(IDC_BUTTON_DEFAULTEXT)->GetSafeHwnd())
		{
			CString strTemp;
			BOOL bNameVaild = strTemp.LoadString(IDS_MSG_GODEFAULT);
			ASSERT(bNameVaild);
			if (CFMessageBox(strTemp, MB_YESNO | MB_ICONINFORMATION) == IDYES)
			{
				m_colorBack.SetColor(GetSysColor (COLOR_WINDOW));
				m_colorText.SetColor(GetSysColor (COLOR_WINDOWTEXT));
				m_colorLineOutLine.SetColor(RGB (128, 128, 128));
				m_colorBackOutLine.SetColor(RGB (255, 255, 255));
				m_colorSidebar.SetColor(RGB (0, 130, 132));
				m_colorLineNumber.SetColor(RGB (0, 130, 132));
				m_colorBackSelActive.SetColor(g_GlobalUtils.m_sColorScheme.m_DefclrBackSelActive);
				m_colorBackSelInactive.SetColor(g_GlobalUtils.m_sColorScheme.m_DefclrBackSelInActive);
				m_colorTextSelActive.SetColor(g_GlobalUtils.m_sColorScheme.m_DefclrTextSelActive);
				m_colorTextSelInactive.SetColor(g_GlobalUtils.m_sColorScheme.m_DefclrTextSelInActive);
				m_colorLink.SetColor(RGB(0, 102, 204));
				m_colorLineNumberBack.SetColor(RGB (227, 227, 227));

				m_colorSyn.SetColor(RGB (0, 0, 255));
				m_colorType.SetColor(RGB (128, 0, 255));
				m_colorNumber.SetColor(RGB(255, 0, 0));
				m_colorString.SetColor(RGB(128, 0, 0));
				m_colorChar.SetColor(RGB(128, 0, 0));
				m_colorComment.SetColor(RGB(0, 128, 0));	

				m_editFont.SelectFont(_T("Consolas"));	
				m_editStyle.SetCurSel(0);
				CString strSize = _T("10");
				m_editSize.SelectString(-1, strSize);
			}
			return TRUE;
		}
	}
	return CBCGPDialog::PreTranslateMessage(pMsg);
}
Esempio n. 3
0
BOOL CSynBCGPEditCtrl::OpenFileEx( const CString& strFileName )
{
	CString strText;
	if (m_File.OpenFile(strFileName, strText))
	{
		if (!globalData.bIsWindowsVista) //XP的时候
		{
			if (theApp.m_bChangedLang)
			{
				strText = CA2T(CT2A(strText), GetACP());
			}
		}
		SetWindowText(strText);
		return TRUE;
	} 
	else
	{
		CFMessageBox(m_File.GetLastErrorMsg(), MB_OK | MB_ICONERROR);
		return FALSE;
	}
}
Esempio n. 4
0
void CLangExtDlg::OnOK()
{
	BOOL bRegVaild = TRUE;
	CString strExt;
	LPCTSTR lpszSubSection = _T("SynExt");
	CString strSection = theApp.GetRegSectionPath(lpszSubSection);

	CBCGPRegistrySP regSP;
	CBCGPRegistry& reg = regSP.Create (FALSE, FALSE);

	if (reg.CreateKey(strSection))
	{
		for (UINT i = 0; i < MAX_SYN_LANG; ++i)
		{
			if (m_aryExt[i] == 1)
			{
				strExt = m_listLangExt.GetItemText(i, 1);
				if (!reg.Write(CSynExtension::m_LangNames[i].langName, strExt))
				{
					bRegVaild = FALSE;
				}
				g_GlobalUtils.m_sLanguageExt.SetLanguageFilter(i, strExt);
			}
		}
	}
	else
	{
		bRegVaild = FALSE;
	}
	
	if (!bRegVaild)
	{
		bRegVaild = strExt.LoadString(IDS_REG_ERROR);
		ASSERT(bRegVaild);
		CFMessageBox(strExt, MB_ICONSTOP);
	}

	CBCGPDialog::OnOK();
}
Esempio n. 5
0
BOOL CSynBCGPEditCtrl::SaveFileEx( const CString& strFileName )
{
	CString strBuffer(m_strBuffer);
	strBuffer.Replace(_T("\n"), _T("\r\n"));
	if (m_File.SaveFile(strFileName, strBuffer))
	{
		m_bIsModified = FALSE;
		m_posDocSavedUndoPos = m_posUndoBuffer;
		m_bSavedUndo = !m_bBOL;

		// Update saved flag:
		for (POSITION pos = m_lstUndoActions.GetHeadPosition (); pos != NULL;)
		{
			POSITION posSave = pos;
			BCGP_EDIT_UNDO_ACTION* pUndoAction = m_lstUndoActions.GetNext (pos);
			ASSERT (pUndoAction != NULL);

			if (m_bEOL && posSave == m_lstUndoActions.GetTailPosition () ||
				!m_bEOL && posSave == m_posUndoBuffer)
			{
				// mark as saved
				pUndoAction->m_dwFlags |= g_dwUAFSaved;
			}
			else
			{
				// clear saved flag
				pUndoAction->m_dwFlags &= ~g_dwUAFSaved;
			}
		}
		return TRUE;
	} 
	else
	{
		CFMessageBox(m_File.GetLastErrorMsg(), MB_OK | MB_ICONERROR);
		return FALSE;
	}
}
Esempio n. 6
0
BOOL CLangExtDlg::PreTranslateMessage(MSG* pMsg)
{
	if (WM_LBUTTONDOWN == pMsg->message)
	{
		if (pMsg->hwnd == GetDlgItem(IDC_BUTTON_DEFAULTEXT)->GetSafeHwnd())
		{
			CString strTemp;
			BOOL bNameVaild = strTemp.LoadString(IDS_MSG_GODEFAULT);
			ASSERT(bNameVaild);
			if (CFMessageBox(strTemp, MB_YESNO | MB_ICONINFORMATION) == IDYES)
			{
				CString strExt;
				for (UINT i = 0; i < MAX_SYN_LANG; ++i)
				{
					g_GlobalUtils.m_sLanguageExt.GetLanguageFilter(i, strExt);
					if (!strExt.IsEmpty() && strExt.Compare(CSynExtension::m_LangNames[i].extName))
					{
						m_aryExt[i] = 1;
						m_listLangExt.SetItemText(i, 1, CSynExtension::m_LangNames[i].extName);
					}
					else
					{
						if (m_aryExt[i] == 1)
						{
							m_aryExt[i] = 0;
							m_listLangExt.SetItemText(i, 1, CSynExtension::m_LangNames[i].extName);
						}
					}
				}
			}
			return TRUE;
		}
	}

	return CBCGPDialog::PreTranslateMessage(pMsg);
}
Esempio n. 7
0
void CSetEditDlg::OnOK()
{
	GetColor();
	GetFont();
	BOOL bRegVaild = TRUE;
	LPCTSTR lpszSubSection = _T("SynColor");
	CString strSection = theApp.GetRegSectionPath(lpszSubSection);

	CBCGPRegistrySP regSP;
	CBCGPRegistry& reg = regSP.Create (FALSE, FALSE);

	if (reg.CreateKey(strSection))
	{
		if (!reg.Write(_T("clrBack"), g_GlobalUtils.m_sColorScheme.m_clrBack))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrText"), g_GlobalUtils.m_sColorScheme.m_clrText))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrBackSelActive"), g_GlobalUtils.m_sColorScheme.m_clrBackSelActive))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrBackSelInActive"), g_GlobalUtils.m_sColorScheme.m_clrBackSelInActive))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrTextSelActive"), g_GlobalUtils.m_sColorScheme.m_clrTextSelActive))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrTextSelInActive"), g_GlobalUtils.m_sColorScheme.m_clrTextSelInActive))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrBackOutline"), g_GlobalUtils.m_sColorScheme.m_clrBackOutline))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrLineOutline"), g_GlobalUtils.m_sColorScheme.m_clrLineOutline))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrBackLineNumber"), g_GlobalUtils.m_sColorScheme.m_clrBackLineNumber))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrTextLineNumber"), g_GlobalUtils.m_sColorScheme.m_clrTextLineNumber))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrBackSidebar"), g_GlobalUtils.m_sColorScheme.m_clrBackSidebar))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrHyperlink"), g_GlobalUtils.m_sColorScheme.m_clrHyperlink))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrSyn"), g_GlobalUtils.m_sColorScheme.m_clrSyn))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrType"), g_GlobalUtils.m_sColorScheme.m_clrType))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrNumber"), g_GlobalUtils.m_sColorScheme.m_clrNumber))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrString"), g_GlobalUtils.m_sColorScheme.m_clrString))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrChar"), g_GlobalUtils.m_sColorScheme.m_clrChar))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrComment"), g_GlobalUtils.m_sColorScheme.m_clrComment))
		{
			bRegVaild = FALSE;
		}
	}
	else
	{
		bRegVaild = FALSE;
	}

	lpszSubSection = _T("SynStyle");
	strSection = theApp.GetRegSectionPath(lpszSubSection);

	CBCGPRegistrySP regSPFont;
	CBCGPRegistry& regFont = regSPFont.Create(FALSE, FALSE);

	if (regFont.CreateKey(strSection))
	{
		if (!regFont.Write(_T("EdtFontName"), g_GlobalUtils.m_sStyleScheme.m_strEdtFontName))
		{
			bRegVaild = FALSE;
		}

		if (!regFont.Write(_T("EdtFontBold"), g_GlobalUtils.m_sStyleScheme.m_bEdtFontBold))
		{
			bRegVaild = FALSE;
		}

		if (!regFont.Write(_T("EdtFontItalic"), g_GlobalUtils.m_sStyleScheme.m_bEdtFontItalic))
		{
			bRegVaild = FALSE;
		}

		if (!regFont.Write(_T("EdtFontSize"), (int)g_GlobalUtils.m_sStyleScheme.m_uEdtFontSize))
		{
			bRegVaild = FALSE;
		}
	}
	else
	{
		bRegVaild = FALSE;
	}

	if (!bRegVaild)
	{
		CString strTemp;
		bRegVaild = strTemp.LoadString(IDS_REG_ERROR);
		ASSERT(bRegVaild);
		CFMessageBox(strTemp, MB_ICONSTOP);
	}

	CBCGPDialog::OnOK();
}