// DemoPropertyPage.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "DemoPropertyPage.h"
#include "WindowManager.h"
#include "ViewManager.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CDemoPropertyPage1, CPropertyPage)
IMPLEMENT_DYNCREATE(CDemoPropertyPage2, CPropertyPage)
//m_wndViewManager
/////////////////////////////////////////////////////////////////////////////
// CDemoPropertyPage1 property page
CDemoPropertyPage1::CDemoPropertyPage1() : CPropertyPage(CDemoPropertyPage1::IDD)
{
CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
m_pViewManager = pFrame->m_MDIClient.GetViewManager();
DWORD dwStyle = m_pViewManager->m_ViewTabCtrl.GetStyle();
BOOL bButtons = dwStyle & TCS_BUTTONS;
BOOL bFlatButtons = dwStyle & TCS_FLATBUTTONS;
//{{AFX_DATA_INIT(CDemoPropertyPage1)
m_nButType = bButtons ? 1 : 0;
m_bFlatButtons = bFlatButtons;
m_bDispIcons = FALSE;
//}}AFX_DATA_INIT
}
CDemoPropertyPage1::~CDemoPropertyPage1()
{
}
void CDemoPropertyPage1::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDemoPropertyPage1)
DDX_Radio(pDX, IDC_NORMAL, m_nButType);
DDX_Check(pDX, IDC_FLAT, m_bFlatButtons);
DDX_Check(pDX, IDC_DISP_ICONS, m_bDispIcons);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDemoPropertyPage1, CPropertyPage)
//{{AFX_MSG_MAP(CDemoPropertyPage1)
ON_BN_CLICKED(IDC_ACTIVE, OnActiveTabFont)
ON_BN_CLICKED(IDC_INACTIVE, OnInactiveTabFont)
ON_BN_CLICKED(IDC_MODIFIED, OnModifiedColor)
ON_BN_CLICKED(IDC_SELECTED, OnSelectedColor)
ON_BN_CLICKED(IDC_UNSELECTED, OnUnselectedColor)
ON_BN_CLICKED(IDC_BUTTONS, OnButtons)
ON_BN_CLICKED(IDC_FLAT, OnFlat)
ON_BN_CLICKED(IDC_NORMAL, OnNormal)
ON_BN_CLICKED(IDC_DISP_ICONS, OnDispIcons)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CDemoPropertyPage1::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
GetDlgItem(IDC_FLAT)->EnableWindow(m_nButType);
CButton* pBut = (CButton*)GetDlgItem(IDC_FLAT);
pBut->SetCheck(m_bFlatButtons);
m_bDispIcons = m_pViewManager->m_ViewTabCtrl.GetIconDisplay();
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDemoPropertyPage1::OnActiveTabFont()
{
CFont* pFont = m_pViewManager->m_ViewTabCtrl.GetTabFont(TRUE);
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
pFont->GetLogFont(&lf);
CFontDialog dlg(&lf, CF_SCREENFONTS | CF_NOSTYLESEL);
if (dlg.DoModal() == IDOK)
{
dlg.GetCurrentFont(&lf);
pFont->DeleteObject();
pFont = new CFont();
pFont->CreateFontIndirect(&lf);
m_pViewManager->m_ViewTabCtrl.SetFonts(pFont, TRUE);
delete pFont;
}
}
void CDemoPropertyPage1::OnInactiveTabFont()
{
CFont* pFont = m_pViewManager->m_ViewTabCtrl.GetTabFont(FALSE);
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
pFont->GetLogFont(&lf);
CFontDialog dlg(&lf, CF_SCREENFONTS | CF_NOSTYLESEL);
if (dlg.DoModal() == IDOK)
{
dlg.GetCurrentFont(&lf);
pFont->DeleteObject();
pFont = new CFont();
pFont->CreateFontIndirect(&lf);
m_pViewManager->m_ViewTabCtrl.SetFonts(pFont, FALSE);
delete pFont;
}
}
void CDemoPropertyPage1::OnModifiedColor()
{
CColorDialog dlg(m_pViewManager->m_ViewTabCtrl.GetDocModifiedColor());
if (dlg.DoModal() == IDOK)
m_pViewManager->m_ViewTabCtrl.SetColors(CLR_NONE, CLR_NONE,
dlg.m_cc.rgbResult);
}
void CDemoPropertyPage1::OnSelectedColor()
{
CColorDialog dlg(m_pViewManager->m_ViewTabCtrl.GetSelColor());
if (dlg.DoModal() == IDOK)
m_pViewManager->m_ViewTabCtrl.SetColors(dlg.m_cc.rgbResult,
CLR_NONE, CLR_NONE);
}
void CDemoPropertyPage1::OnUnselectedColor()
{
CColorDialog dlg(m_pViewManager->m_ViewTabCtrl.GetUnSelColor());
if (dlg.DoModal() == IDOK)
m_pViewManager->m_ViewTabCtrl.SetColors(CLR_NONE,
dlg.m_cc.rgbResult, CLR_NONE);
}
void CDemoPropertyPage1::OnNormal()
{
m_pViewManager->m_ViewTabCtrl.SetTabStyle(FALSE, FALSE);
GetDlgItem(IDC_FLAT)->EnableWindow(FALSE);
}
void CDemoPropertyPage1::OnButtons()
{
m_pViewManager->m_ViewTabCtrl.SetTabStyle(TRUE, FALSE);
GetDlgItem(IDC_FLAT)->EnableWindow(TRUE);
}
void CDemoPropertyPage1::OnFlat()
{
UpdateData();
ASSERT(m_nButType == 1);
if (m_bFlatButtons)
m_pViewManager->m_ViewTabCtrl.SetTabStyle(TRUE, TRUE);
else
{
m_pViewManager->m_ViewTabCtrl.SetTabStyle(FALSE, FALSE);
m_pViewManager->m_ViewTabCtrl.SetTabStyle(TRUE, FALSE);
}
}
void CDemoPropertyPage1::OnDispIcons()
{
UpdateData();
m_pViewManager->m_ViewTabCtrl.SetIconDisplay(m_bDispIcons);
}
/////////////////////////////////////////////////////////////////////////////
// CDemoPropertyPage2 property page
CDemoPropertyPage2::CDemoPropertyPage2() : CPropertyPage(CDemoPropertyPage2::IDD)
{
m_pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
//{{AFX_DATA_INIT(CDemoPropertyPage2)
m_strFileName = m_pFrame->m_MDIClient.GetFileName();
m_nDispType = m_pFrame->m_MDIClient.GetDispType();
//}}AFX_DATA_INIT
}
CDemoPropertyPage2::~CDemoPropertyPage2()
{
}
void CDemoPropertyPage2::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDemoPropertyPage2)
DDX_Text(pDX, IDC_FILENAME, m_strFileName);
DDX_Radio(pDX, IDC_TILE, m_nDispType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDemoPropertyPage2, CPropertyPage)
//{{AFX_MSG_MAP(CDemoPropertyPage2)
ON_BN_CLICKED(IDC_BKCOLOR, OnBkcolor)
ON_BN_CLICKED(IDC_BKFONT, OnBkfont)
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
ON_BN_CLICKED(IDC_TILE, OnDisplayType)
ON_BN_CLICKED(IDC_BACKLOGO, OnBacklogo)
ON_BN_CLICKED(IDC_CENTER, OnDisplayType)
ON_BN_CLICKED(IDC_STRETCH, OnDisplayType)
ON_BN_CLICKED(IDC_DEFAULT, OnDefault)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CDemoPropertyPage2::OnBkcolor()
{
CColorDialog dlg(m_pFrame->m_MDIClient.GetBkColor());
if (dlg.DoModal() == IDOK)
m_pFrame->m_MDIClient.SetBkColor(dlg.m_cc.rgbResult);
}
void CDemoPropertyPage2::OnBkfont()
{
CFont* pFont = m_pFrame->m_MDIClient.GetLogoFont();
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
pFont->GetLogFont(&lf);
CFontDialog dlg(&lf, CF_SCREENFONTS | CF_NOSTYLESEL);
if (dlg.DoModal() == IDOK)
{
dlg.GetCurrentFont(&lf);
pFont->DeleteObject();
pFont = new CFont();
pFont->CreateFontIndirect(&lf);
m_pFrame->m_MDIClient.SetLogoFont(pFont);
delete pFont;
}
}
void CDemoPropertyPage2::OnBrowse()
{
CFileDialog dlg(TRUE, _T("bmp"), m_strFileName,
OFN_HIDEREADONLY,
_T("Bitmap Files (*.bmp)|*.bmp|All Files (*.*)|*.*||"));
if (dlg.DoModal() == IDOK)
{
m_pFrame->m_MDIClient.SetBitmap(dlg.GetPathName());
m_strFileName = dlg.GetPathName();
UpdateData(FALSE);
}
}
void CDemoPropertyPage2::OnDisplayType()
{
UpdateData();
m_pFrame->m_MDIClient.SetDispType(CMDIClient::DispType(m_nDispType));
}
void CDemoPropertyPage2::OnBacklogo()
{
CColorDialog dlg(m_pFrame->m_MDIClient.GetBkColor());
if (dlg.DoModal() == IDOK)
m_pFrame->m_MDIClient.SetLogoColor(dlg.m_cc.rgbResult);
}
void CDemoPropertyPage2::OnDefault()
{
// TODO: Add your control notification handler code here
m_pFrame->m_MDIClient.Defaults(TRUE, TRUE);
}