MyTreeDlgBar.cpp
上传用户:cding2008
上传日期:2007-01-03
资源大小:1812k
文件大小:5k
- /////////////////////////////////////////////////////////////////////
- // MyTreeDlgBar.cpp : implementation of the CMyTreeDlgBar floating
- // toolbar class
- //
- // ModelMagic 3D and 'glOOP' (OpenGL Object Oriented Programming library)
- // Copyright (c) Craig Fahrnbach 1997, 1999
- //
- // OpenGL is a registered trademark of Silicon Graphics
- //
- //
- // This program is provided for educational and personal use only and
- // is provided without guarantee or warrantee expressed or implied.
- //
- // Commercial use is strickly prohibited without written permission
- // from ImageWare Development.
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "ModelMagic3D.h"
- ////////////////////////////////////////////////////////////////////
- // CMyTreeDlgBar Construction/Destruction
-
- BOOL CMyTreeDlgBar::Create( CWnd* pParentWnd,
- UINT nStyle,
- UINT nID, BOOL bChange)
- {
- if(!CDialogBar::Create(pParentWnd, CMyTreeDlgBar::IDD, nStyle, nID))
- return FALSE;
- m_bChangeDockedSize = bChange;
- m_sizeFloating = m_sizeDocked = m_sizeDefault;
- return TRUE;
- }
-
- ////////////////////////////////////////////////////////////////////
- // Overloaded functions
-
- CSize CMyTreeDlgBar::CalcDynamicLayout(int nLength, DWORD nMode)
- {
- // Return default if it is being docked or floated
- if ((nMode & LM_VERTDOCK) || (nMode & LM_HORZDOCK))
- {
- if (nMode & LM_STRETCH) // if not docked stretch to fit
- return CSize((nMode & LM_HORZ) ? 32767 : m_sizeDocked.cx,
- (nMode & LM_HORZ) ? m_sizeDocked.cy : 32767);
- else
- return m_sizeDocked;
- }
- if (nMode & LM_MRUWIDTH)
- return m_sizeFloating;
- // In all other cases, accept the dynamic length
- if (nMode & LM_LENGTHY)
- return CSize(m_sizeFloating.cx, (m_bChangeDockedSize) ?
- m_sizeFloating.cy = m_sizeDocked.cy = nLength :
- m_sizeFloating.cy = nLength);
- else
- return CSize((m_bChangeDockedSize) ?
- m_sizeFloating.cx = m_sizeDocked.cx = nLength :
- m_sizeFloating.cx = nLength, m_sizeFloating.cy);
- }
- BEGIN_MESSAGE_MAP(CMyTreeDlgBar, CDialogBar)
- //{{AFX_MSG_MAP(CMyTreeDlgBar)
- ON_WM_SIZE()
- ON_WM_CREATE()
- ON_WM_DESTROY()
- ON_WM_PALETTECHANGED()
- ON_WM_QUERYNEWPALETTE()
- ON_WM_PAINT()
- //}}AFX_MSG_MAP
- // USER defined messages
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////
- // CMyTreeDlgBar custom functions
- /////////////////////////////////////////////////////////////////////
- void CMyTreeDlgBar::DisplayTree(C3dWorld* pWorld)
- {
- m_TreeCtrl.DeleteAllItems();
- if(pWorld) {
- m_TreeCtrl.FillTree(pWorld);
- m_TreeCtrl.ExpandAllItems();
- }
- }
- void CMyTreeDlgBar::ClearTree()
- {
- m_TreeCtrl.DeleteAllItems();
- }
- void CMyTreeDlgBar::InsertObject(C3dObject* pObject)
- {
- m_TreeCtrl.InsertObject(pObject);
- }
- HTREEITEM CMyTreeDlgBar::FindObject(C3dObject* pObject)
- {
- return m_TreeCtrl.FindObject(pObject);
- }
- void CMyTreeDlgBar::SelectItem(HTREEITEM hItem)
- {
- m_TreeCtrl.SelectItem(hItem);
- }
- void CMyTreeDlgBar::DisplaySelected(C3dObject* pObject)
- {
- if(pObject)
- SelectItem(FindObject(pObject));
- }
- /////////////////////////////////////////////////////////////////////
- // CMyTreeDlgBar message handlers
- /////////////////////////////////////////////////////////////////////
- void CMyTreeDlgBar::OnSize(UINT nType, int cx, int cy)
- {
- CDialogBar::OnSize(nType, cx, cy);
- // Get the handle of the CTreeCtrl window and set
- // its size
- HWND hTree = m_TreeCtrl.GetSafeHwnd();
- if(hTree) {
- m_TreeCtrl.SetWindowPos(NULL, 0+10, 0+10,
- cx-20, cy-20, SWP_NOZORDER | SWP_NOACTIVATE);
- }
- }
- int CMyTreeDlgBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CDialogBar::OnCreate(lpCreateStruct) == -1)
- return -1;
- // Get the last setting of the window position from
- // the ini file and restore
- WINDOWPLACEMENT wp;
- if (ReadWindowPlacement(&wp, "Settings", "TreeDlgWndPos"))
- SetWindowPlacement(&wp);
- // Create the Tree Control
- RECT rect = {0, 0, 0, 0};
- if(!m_TreeCtrl.Create(WS_BORDER | WS_THICKFRAME |
- TVS_HASLINES | TVS_LINESATROOT |
- TVS_HASBUTTONS | TVS_EDITLABELS |
- TVS_SHOWSELALWAYS | TVS_DISABLEDRAGDROP,
- rect,
- this,
- 0))
- return -1;
- m_TreeCtrl.ShowWindow(SW_SHOW);
- return 0;
- }
- void CMyTreeDlgBar::OnDestroy()
- {
- CDialogBar::OnDestroy();
- // Save the state of our CDialogBar derived class window
- WINDOWPLACEMENT wp;
- wp.length = sizeof wp;
- if (GetWindowPlacement(&wp))
- {
- wp.flags = 0;
- if (IsZoomed())
- wp.flags |= WPF_RESTORETOMAXIMIZED;
- // and write it to the .INI file
- WriteWindowPlacement(&wp, "Settings", "TreeDlgWndPos");
- }
- }
- void CMyTreeDlgBar::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
-
- // TODO: Add your message handler code here
-
- // Do not call CDialogBar::OnPaint() for painting messages
- }