XFloorPropertiesWnd.cpp
资源名称:propgrid.zip [点击查看]
上传用户:yangzi5763
上传日期:2007-01-02
资源大小:239k
文件大小:6k
源码类别:
ActiveX/DCOM/ATL
开发平台:
Visual C++
- /************************************
- REVISION LOG ENTRY
- Revision By: Mihai Filimon
- Revised on 10/14/98 10:22:23 AM
- Comments: XFloorPropertiesWnd.cpp: implementation of the CXFloorPropertiesWnd class.
- ************************************/
- #include "stdafx.h"
- #include "XPropertiesWnd.h"
- #include "XFloorPropertiesWnd.h"
- #include "PageTreeCtrl.h"
- #include "XPropertiesWndCtl.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- ///////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- BEGIN_MESSAGE_MAP(CXFloorPropertiesWnd, CXFloorWnd)
- //{{AFX_MSG_MAP(CXFloorPropertiesWnd)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- // Function name : CXFloorPropertiesWnd::CXFloorPropertiesWnd
- // Description : default constuctor
- // Return type :
- CXFloorPropertiesWnd::CXFloorPropertiesWnd(/*CXPropertiesWndCtrl* pControlWnd*/)
- {
- }
- // Function name : CXFloorPropertiesWnd::~CXFloorPropertiesWnd
- // Description : virtual destructor
- // Return type :
- CXFloorPropertiesWnd::~CXFloorPropertiesWnd()
- {
- OnDestructor();
- }
- // Function name : CXFloorPropertiesWnd::AddPage
- // Description : Add a new page, will insert a CPageListCtrl
- // Return type : short
- // Argument : LPCTSTR sName
- short CXFloorPropertiesWnd::AddPage(LPCTSTR sName, CXPropertiesWndCtrl* pControl, LPCTSTR lpszOptions)
- {
- short nResult = CXFloorWnd::AddPage(sName);
- if (nResult >= 0)
- {
- CString sOptions(lpszOptions);
- if (CPageListCtrl* pPageListCtrl = NewPageListCtrl(nResult, pControl, sOptions.Find(_T("[Group]")) >= 0))
- {
- RefreshPages();
- AttachWindow(nResult, (long)pPageListCtrl);
- pPageListCtrl->SetIndexPage(m_arPagesListCtrl.Add(pPageListCtrl));
- Init();
- }
- }
- return nResult;
- }
- // Function name : CXFloorPropertiesWnd::DeletePage
- // Description : When Delete a page delete the attached CPageListCtrl
- // Return type : BOOL
- // Argument : short nIndex
- BOOL CXFloorPropertiesWnd::DeletePage(short nIndex)
- {
- BOOL bResult = CXFloorWnd::DeletePage(nIndex);
- if (bResult)
- if (nIndex < m_arPagesListCtrl.GetSize())
- {
- delete m_arPagesListCtrl[nIndex];
- m_arPagesListCtrl.RemoveAt(nIndex);
- RefreshPages();
- }
- return bResult;
- }
- // Function name : CXFloorPropertiesWnd::NewPageListCtrl
- // Description :
- // Return type : CPageListCtrl*
- CPageListCtrl* CXFloorPropertiesWnd::NewPageListCtrl(int nIndex, CXPropertiesWndCtrl* pControl, BOOL bGroup)
- {
- ASSERT (pControl != NULL);
- CPageListCtrl* pPageListCtrl = !bGroup ? new CPageListCtrl(pControl) : new CPageTreeCtrl(pControl);
- pPageListCtrl->OnNew(this, nIndex + _nIDFirstListView);
- return pPageListCtrl;
- }
- // Function name : CXFloorPropertiesWnd::GetListCtrl
- // Description : GetListControl
- // Return type : CPageListCtrl*
- // Argument : int nIndex
- CPageListCtrl* CXFloorPropertiesWnd::GetListCtrl(int nIndex)
- {
- if ((nIndex >= 0) && (nIndex < m_arPagesListCtrl.GetSize()))
- return m_arPagesListCtrl[nIndex];
- return NULL;
- }
- // Function name : CXFloorPropertiesWnd::IsGroup
- // Description :
- // Return type : BOOL
- // Argument : int i
- BOOL CXFloorPropertiesWnd::IsGroup(int i)
- {
- if (CPageListCtrl* pPage = GetListCtrl(i))
- return pPage->IsGroup();
- return FALSE;
- }
- // Function name : CXFloorPropertiesWnd::OnReset
- // Description : Remove all
- // Return type : void
- void CXFloorPropertiesWnd::OnReset()
- {
- ((CXPropertiesWndCtrl*)GetParent())->KillAllControls();
- while (DeletePage(0));
- // Change the style to new one...
- StyleAs(m_bAsFloor);
- }
- // Function name : CXFloorPropertiesWnd::OnDestructor
- // Description :
- // Return type : void
- void CXFloorPropertiesWnd::OnDestructor()
- {
- for (int i = 0; i < m_arPagesListCtrl.GetSize(); i++)
- delete m_arPagesListCtrl[i];
- m_arPagesListCtrl.RemoveAll();
- }
- // Function name : CXFloorPropertiesWndDesign::Load
- // Description : Fill this control with stream string
- // Return type : void
- void CXFloorPropertiesWnd::Load(CString& stream, CXPropertiesWndCtrl* pControl)
- {
- if (GetControlUnknown())
- {
- CWnd* pWnd = (CWnd*)pControl;
- OnReset();
- if (!stream.IsEmpty())
- {
- BOOL bName = TRUE;
- CString sPage, sName, sOptions;
- int nNewPage = -1;
- for (int i = 0, nBracket = 0; ; i++)
- {
- CString sLine;
- AfxExtractSubString(sLine, stream, i, _cPagesSeparator);
- if (sLine.IsEmpty())
- break;
- if (sLine == _T("{"))
- {
- nBracket++;
- if (!sName.IsEmpty())
- if (nBracket == 1)
- nNewPage = AddPage(sName, pControl, sOptions);
- }
- else
- if (sLine == _T("}"))
- {
- nBracket--;
- if (nBracket == 0)
- if (nNewPage >= 0)
- GetListCtrl(nNewPage)->Load(sPage);
- nBracket = max(0,nBracket);
- // Reset the values
- sPage.Empty();
- bName = TRUE;
- sOptions.Empty();
- }
- else
- switch (nBracket)
- {
- case 0:
- {
- if (bName)
- {
- sName = sLine;
- bName = FALSE; // fill the sOptions
- }
- else
- sOptions += sLine;
- break;
- }
- case 1:
- {
- sPage += sLine + CString(_cPagesSeparator);
- }
- }
- }
- }
- }
- }
- // Function name : CXFloorPropertiesWnd::SetAutoResizingColumns
- // Description : Set TRUE or FALSE for resizing listctrl
- // Return type : void
- // Argument : BOOL bValue
- void CXFloorPropertiesWnd::SetAutoResizingColumns(BOOL bValue)
- {
- CPageListCtrl::m_bAutoResizingColumns = bValue;
- }
- // Function name : CXFloorPropertiesWnd::SetSignEnableDisable
- // Description : Set or not
- // Return type : void
- // Argument : BOOL bValue
- void CXFloorPropertiesWnd::SetSignEnableDisable(BOOL bValue)
- {
- m_bSignEnableDisable = bValue;
- }
- // Function name : CXFloorPropertiesWnd::GetSignEnableDisable
- // Description :
- // Return type : const BOOL
- const BOOL CXFloorPropertiesWnd::GetSignEnableDisable()
- {
- return m_bSignEnableDisable;
- }
- // Function name : CXFloorPropertiesWnd::RefreshPages
- // Description :
- // Return type : void
- void CXFloorPropertiesWnd::RefreshPages()
- {
- if (!m_bFirstPageHasCaption)
- if (long cPages = GetPagesCount())
- SetHeight(0, cPages == 1 ? 0 : 20);
- }