Ejemplo n.º 1
0
bool Mint::Initialize(int nWorkspaceWidth, int nWorkspaceHeight, MDrawContext* pDC, MFont* pDefaultFont)
{
	_ASSERT(m_pMainFrame==NULL);

	m_pDC = pDC;

//	MFontManager::Add(pDefaultFont);
	MFontManager::SetDefaultFont(pDefaultFont);

	m_pMainFrame = new MMainFrame("Mint");
	m_pMainFrame->SetBounds(0, 0, nWorkspaceWidth, nWorkspaceHeight);

	SetWorkspaceSize(nWorkspaceWidth, nWorkspaceHeight);

	return true;
}
Ejemplo n.º 2
0
void CWorkspacePreferencesDialog::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
	DWORD dwNewSize = ((m_dwWorkspaceSize+500000L)/1000000L)*1000000L;

	if (nSBCode == SB_LINEUP)
	{
		dwNewSize += 1000000L;
	}

	if (nSBCode == SB_LINEDOWN)
	{
		if (dwNewSize >= 1000000L)
		{
			dwNewSize -= 1000000L;
		}
	}

	if (dwNewSize < MINIMUM_WORKSPACE_SIZE)
	{
		dwNewSize = MINIMUM_WORKSPACE_SIZE;
	}

	if (dwNewSize > MAXIMUM_WORKSPACE_SIZE)
	{
		dwNewSize = MAXIMUM_WORKSPACE_SIZE;
	}

	if (m_dwWorkspaceSize != dwNewSize)
	{
		SetWorkspaceSize(dwNewSize);
		RedrawInterface();

		if (GetFocus() == GetDlgItem(IDC_WORKSPACE_SIZE))
		{
			m_workspace_edit.SetSel(0, -1);
		}
	}

	CPmwDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
Ejemplo n.º 3
0
LRESULT CWorkspacePreferencesDialog::OnValidateWorkspaceSize(WPARAM wParam, LPARAM lParam)
{
	CString csSize;
	CString csFormat;
	CString csMessage;
	CString csError;

	LRESULT lResult = 0;

	TRY
	{
		GetDlgItemText(IDC_WORKSPACE_SIZE, csSize.GetBuffer(100), 100-1);
		csSize.ReleaseBuffer();

		// get the value that the user entered
		BOOL fIsValid = TRUE;
		BOOL fSeenDigit = FALSE;
		BOOL fSeenDecimal = FALSE;
		DWORD dwSize = 0L;
		DWORD dwFraction = 1000000L;

		for (int i = 0; i < csSize.GetLength(); i++)
		{
			if ((csSize[i] >= '0') && (csSize[i] <= '9'))
			{
				if (!fSeenDecimal)
				{
					dwSize = (dwSize*10L)+(1000000L*(csSize[i]-'0'));
				}

				else
				{
					dwFraction /= 10L;
					dwSize += dwFraction*(csSize[i]-'0');
				}

				fSeenDigit = TRUE;
			}

			else if (csSize[i] == '.')
			{
				if (fSeenDecimal)
				{
					fIsValid = FALSE;
					break;
				}

				fSeenDecimal = TRUE;
			}

			else if (csSize[i] != ' ')
			{
				fIsValid = FALSE;
				break;
			}
		}

		if (!fSeenDigit)
		{
			fIsValid = FALSE;
		}

		if (!fIsValid)
		{
			GetConfiguration()->MessageBox(IDS_ErrInvalidWorkspaceSize, 0, MB_OK|MB_ICONEXCLAMATION);
		}

		else
		{
			// a number was entered, check if it is with the legal range

			DWORD dwMinMaxSize;

			if (dwSize < MINIMUM_WORKSPACE_SIZE)
			{
				LoadConfigurationString(IDS_ErrWorkspaceSizeTooSmall, csFormat);
				dwMinMaxSize = MINIMUM_WORKSPACE_SIZE;
				fIsValid = FALSE;
			}

			if (dwSize > MAXIMUM_WORKSPACE_SIZE)
			{
				LoadConfigurationString(IDS_ErrWorkspaceSizeTooLarge, csFormat);
				dwMinMaxSize = MAXIMUM_WORKSPACE_SIZE;
				fIsValid = FALSE;
			}

			if (!fIsValid)
			{
				wsprintf(csMessage.GetBuffer(1024), csFormat, (int)(dwMinMaxSize/1000000L));
				csMessage.ReleaseBuffer();
			}

			if (!fIsValid)
			{
				AfxMessageBox(csMessage, MB_OK|MB_ICONEXCLAMATION);
			}
		}

		if (fIsValid)
		{
			// the number entered was valid, display it
			SetWorkspaceSize(dwSize);
			RedrawInterface();
			lResult = 1;
		}

		else
		{
			// restore the number to its previous value
			m_fRedrawWorkspaceSize = TRUE;
			RedrawInterface();

			// reset the focus back to the workspace edit
			GetDlgItem(IDC_WORKSPACE_SIZE)->SetFocus();
		}
	}
	CATCH_ALL(e)
	{
		csSize.Empty();
		csFormat.Empty();
		csMessage.Empty();

		THROW_LAST();
	}
	END_CATCH_ALL

	return lResult;
}