Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

EntityListDlg.cpp

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 // EntityListDlg.cpp : implementation file
00023 //
00024 
00025 #include "stdafx.h"
00026 #include "Radiant.h"
00027 #include "EntityListDlg.h"
00028 
00029 #ifdef _DEBUG
00030 #define new DEBUG_NEW
00031 #undef THIS_FILE
00032 static char THIS_FILE[] = __FILE__;
00033 #endif
00034 
00036 // CEntityListDlg dialog
00037 
00038 
00039 CEntityListDlg::CEntityListDlg(CWnd* pParent /*=NULL*/)
00040     : CDialog(CEntityListDlg::IDD, pParent)
00041 {
00042     //{{AFX_DATA_INIT(CEntityListDlg)
00043     //}}AFX_DATA_INIT
00044 }
00045 
00046 
00047 void CEntityListDlg::DoDataExchange(CDataExchange* pDX)
00048 {
00049     CDialog::DoDataExchange(pDX);
00050     //{{AFX_DATA_MAP(CEntityListDlg)
00051     DDX_Control(pDX, IDC_LIST_ENTITY, m_lstEntity);
00052     DDX_Control(pDX, IDC_TREE_ENTITY, m_treeEntity);
00053     //}}AFX_DATA_MAP
00054 }
00055 
00056 
00057 BEGIN_MESSAGE_MAP(CEntityListDlg, CDialog)
00058     //{{AFX_MSG_MAP(CEntityListDlg)
00059     ON_BN_CLICKED(IDSELECT, OnSelect)
00060     ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_ENTITY, OnSelchangedTreeEntity)
00061     ON_NOTIFY(NM_DBLCLK, IDC_TREE_ENTITY, OnDblclkTreeEntity)
00062     //}}AFX_MSG_MAP
00063 END_MESSAGE_MAP()
00064 
00066 // CEntityListDlg message handlers
00067 
00068 void CEntityListDlg::OnSelect() 
00069 {
00070   HTREEITEM hItem = m_treeEntity.GetSelectedItem();
00071   if (hItem)
00072   {
00073     entity_t* pEntity = reinterpret_cast<entity_t*>(m_treeEntity.GetItemData(hItem));
00074     if (pEntity)
00075     {
00076       Select_Deselect();
00077         Select_Brush (pEntity->brushes.onext);
00078     }
00079     }
00080   Sys_UpdateWindows(W_ALL);
00081 }
00082 
00083 BOOL CEntityListDlg::OnInitDialog() 
00084 {
00085     CDialog::OnInitDialog();
00086     
00087   CMapStringToPtr mapEntity;
00088 
00089   HTREEITEM hParent = m_treeEntity.InsertItem(world_entity->eclass->name);
00090   HTREEITEM hChild = m_treeEntity.InsertItem(world_entity->eclass->name, hParent);
00091   m_treeEntity.SetItemData(hChild, reinterpret_cast<DWORD>(world_entity));
00092 
00093     for (entity_t* pEntity=entities.next ; pEntity != &entities ; pEntity=pEntity->next)
00094     {
00095     hParent = NULL;
00096     if (mapEntity.Lookup(pEntity->eclass->name, reinterpret_cast<void*&>(hParent)) == FALSE)
00097     {
00098       hParent = m_treeEntity.InsertItem(pEntity->eclass->name);
00099       mapEntity.SetAt(pEntity->eclass->name, reinterpret_cast<void*>(hParent));
00100     }
00101     hChild = m_treeEntity.InsertItem(pEntity->eclass->name, hParent);
00102     m_treeEntity.SetItemData(hChild, reinterpret_cast<DWORD>(pEntity));
00103   }
00104 
00105   CRect rct;
00106   m_lstEntity.GetClientRect(rct);
00107   m_lstEntity.InsertColumn(0, "Key", LVCFMT_LEFT, rct.Width() / 2);
00108   m_lstEntity.InsertColumn(1, "Value", LVCFMT_LEFT, rct.Width() / 2);
00109   m_lstEntity.DeleteColumn(2);
00110   UpdateData(FALSE);
00111     
00112     return TRUE;  // return TRUE unless you set the focus to a control
00113                   // EXCEPTION: OCX Property Pages should return FALSE
00114 }
00115 
00116 void CEntityListDlg::OnSelchangedTreeEntity(NMHDR* pNMHDR, LRESULT* pResult) 
00117 {
00118     NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
00119   HTREEITEM hItem = m_treeEntity.GetSelectedItem();
00120   m_lstEntity.DeleteAllItems();
00121   if (hItem)
00122   {
00123     CString strList;
00124     entity_t* pEntity = reinterpret_cast<entity_t*>(m_treeEntity.GetItemData(hItem));
00125     if (pEntity)
00126     {
00127         for (epair_t* pEpair = pEntity->epairs ; pEpair ; pEpair = pEpair->next)
00128       {
00129             if (strlen(pEpair->key) > 8)
00130           strList.Format("%s\t%s", pEpair->key, pEpair->value);
00131         else
00132           strList.Format("%s\t\t%s", pEpair->key, pEpair->value);
00133         int nParent = m_lstEntity.InsertItem(0, pEpair->key);
00134         m_lstEntity.SetItem(nParent, 1, LVIF_TEXT, pEpair->value, 0, 0, 0, reinterpret_cast<DWORD>(pEntity));
00135 
00136       }
00137     }
00138     }
00139     *pResult = 0;
00140 }
00141 
00142 void CEntityListDlg::OnDblclkListInfo() 
00143 {
00144     // TODO: Add your control notification handler code here
00145     
00146 }
00147 
00148 void CEntityListDlg::OnDblclkTreeEntity(NMHDR* pNMHDR, LRESULT* pResult) 
00149 {
00150   OnSelect();
00151     *pResult = 0;
00152 }

Generated on Thu Aug 25 12:38:29 2005 for Quake III Arena by  doxygen 1.3.9.1