doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PropTree.h
Go to the documentation of this file.
1 // PropTree.h : header file
2 //
3 // Copyright (C) 1998-2001 Scott Ramsay
4 // sramsay@gonavi.com
5 // http://www.gonavi.com
6 //
7 // This material is provided "as is", with absolutely no warranty expressed
8 // or implied. Any use is at your own risk.
9 //
10 // Permission to use or copy this software for any purpose is hereby granted
11 // without fee, provided the above notices are retained on all copies.
12 // Permission to modify the code and to distribute modified code is granted,
13 // provided the above notices are retained, and a notice that the code was
14 // modified is included with the above copyright notice.
15 //
16 // If you use this code, drop me an email. I'd like to know if you find the code
17 // useful.
18 
19 #if !defined(AFX_PROPT_H__386AA426_6FB7_4B4B_9563_C4CC045BB0C9__INCLUDED_)
20 #define AFX_PROPT_H__386AA426_6FB7_4B4B_9563_C4CC045BB0C9__INCLUDED_
21 
22 #if _MSC_VER > 1000
23 #pragma once
24 #endif // _MSC_VER > 1000
25 
26 /*#ifdef _PROPTREE_EXPORT
27 #define PROPTREE_API __declspec(dllexport)
28 #else
29 #define PROPTREE_API __declspec(dllimport)
30 #endif
31 
32 #ifndef _PROPTREE_DLL
33  #ifdef _UNICODE
34  #ifdef _DEBUG
35  #pragma comment(lib, "PropTreeDU")
36  #pragma message("Automatically linking with PropTreeDU.dll (Debug Unicode)")
37  #else
38  #pragma comment(lib, "PropTreeU")
39  #pragma message("Automatically linking with PropTreeU.dll (Release Unicode)")
40  #endif
41  #else
42  #ifdef _DEBUG
43  #pragma comment(lib, "PropTreeD")
44  #pragma message("Automatically linking with PropTreeD.dll (Debug)")
45  #else
46  #pragma comment(lib, "PropTree")
47  #pragma message("Automatically linking with PropTree.dll (Release)")
48  #endif
49  #endif // _UNICODE
50 #endif // _PROPTREE_DLL
51 */
52 
53 #define PROPTREE_API
54 
55 #include "PropTreeList.h"
56 #include "PropTreeInfo.h"
57 
58 #include "PropTreeItem.h"
59 #include "PropTreeItemStatic.h"
60 #include "PropTreeItemEdit.h"
61 #include "PropTreeItemCombo.h"
62 #include "PropTreeItemColor.h"
63 #include "PropTreeItemCheck.h"
64 #include "PropTreeItemButton.h"
65 #include "PropTreeItemEditButton.h"
66 #include "PropTreeItemFileEdit.h"
67 
68 class CPropTree;
69 
70 typedef BOOL (CALLBACK* ENUMPROPITEMPROC)(CPropTree*, CPropTreeItem*, LPARAM);
71 
72 void InitPropTree(HINSTANCE hInstance);
73 
74 // CPropTree window styles
75 #define PTS_NOTIFY 0x00000001
76 
77 // CPropTree HitTest return codes
78 #define HTPROPFIRST 50
79 
80 #define HTLABEL (HTPROPFIRST + 0)
81 #define HTCOLUMN (HTPROPFIRST + 1)
82 #define HTEXPAND (HTPROPFIRST + 2)
83 #define HTATTRIBUTE (HTPROPFIRST + 3)
84 #define HTCHECKBOX (HTPROPFIRST + 4)
85 #define HTBUTTON (HTPROPFIRST + 5)
86 
87 // CPropTree WM_NOTIFY notification structure
88 typedef struct _NMPROPTREE
89 {
90  NMHDR hdr;
93 
94 // CPropTree specific Notification Codes
95 #define PTN_FIRST (0U-1100U)
96 
97 #define PTN_INSERTITEM (PTN_FIRST-1)
98 #define PTN_DELETEITEM (PTN_FIRST-2)
99 #define PTN_DELETEALLITEMS (PTN_FIRST-3)
100 #define PTN_ITEMCHANGED (PTN_FIRST-5)
101 #define PTN_ITEMBUTTONCLICK (PTN_FIRST-6)
102 #define PTN_SELCHANGE (PTN_FIRST-7)
103 #define PTN_ITEMEXPANDING (PTN_FIRST-8)
104 #define PTN_COLUMNCLICK (PTN_FIRST-9)
105 #define PTN_PROPCLICK (PTN_FIRST-10)
106 #define PTN_CHECKCLICK (PTN_FIRST-12)
107 
109 // CPropTree window
110 
111 class PROPTREE_API CPropTree : public CWnd
112 {
113 // Construction
114 public:
115  CPropTree();
116  virtual ~CPropTree();
117 
118  BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
119 
120 // Attributes/Operations
121 public:
122  static CFont* GetNormalFont();
123  static CFont* GetBoldFont();
124 
125  // Returns the root item of the tree
126  CPropTreeItem* GetRootItem();
127 
128  // Returns the focused item or NULL for none
129  CPropTreeItem* GetFocusedItem();
130 
131  // Enumerates an item and all its child items
132  BOOL EnumItems(CPropTreeItem* pItem, ENUMPROPITEMPROC proc, LPARAM lParam = 0L);
133 
134  // Insert a created CPropTreeItem into the control
135  CPropTreeItem* InsertItem(CPropTreeItem* pItem, CPropTreeItem* pParent = NULL);
136 
137  // Delete an item and ALL its children
138  void DeleteItem(CPropTreeItem* pItem);
139 
140  // Delete all items from the tree
141  void DeleteAllItems();
142 
143  // Return the splitter position
144  LONG GetColumn();
145 
146  // Set the splitter position
147  void SetColumn(LONG nColumn);
148 
149  // Sets the focused item
150  void SetFocusedItem(CPropTreeItem* pItem);
151 
152  // Show or hide the info text
153  void ShowInfoText(BOOL bShow = TRUE);
154 
155  // Returns TRUE if the item is visible (its parent is expanded)
156  BOOL IsItemVisible(CPropTreeItem* pItem);
157 
158  // Ensures that an item is visible
159  void EnsureVisible(CPropTreeItem* pItem);
160 
161  // do a hit test on the control (returns a HTxxxx code)
162  LONG HitTest(const POINT& pt);
163 
164  // find an item by a location
165  CPropTreeItem* FindItem(const POINT& pt);
166 
167  // find an item by item id
168  CPropTreeItem* FindItem(UINT nCtrlID);
169 
170 protected:
171  // Actual tree control
173 
174  // Descriptive control
176 
177  // TRUE to show info control
179 
180  // Height of the info control
182 
183  // Root level tree item
185 
186  // Linked list of visible items
188 
189  // Pointer to the focused item (selected)
191 
192  // PropTree scroll position. x = splitter position, y = vscroll position
193  CPoint m_Origin;
194 
195  // auto generated last created ID
197 
198  // Number of CPropTree controls in the current application
200 
201  static CFont* s_pNormalFont;
202  static CFont* s_pBoldFont;
203 
205 
206  // Used for enumeration
208 
209 public:
210  //
211  // functions used by CPropTreeItem (you normally dont need to call these directly)
212  //
213 
214  void AddToVisibleList(CPropTreeItem* pItem);
215  void ClearVisibleList();
216 
217  void SetOriginOffset(LONG nOffset);
218  void UpdatedItems();
219  void UpdateMoveAllItems();
220  void RefreshItems(CPropTreeItem* pItem = NULL);
221 
222  // enable or disable tree input
223  void DisableInput(BOOL bDisable = TRUE);
224  BOOL IsDisableInput();
225 
226  BOOL IsSingleSelection();
227 
228  CPropTreeItem* GetVisibleList();
229  CWnd* GetCtrlParent();
230 
231  const POINT& GetOrigin();
232 
233  void SelectItems(CPropTreeItem* pItem, BOOL bSelect = TRUE);
234 
235  // Focus on the first visible item
236  CPropTreeItem *FocusFirst();
237 
238  // Focus on the last visible item
239  CPropTreeItem *FocusLast();
240 
241  // Focus on the previous item
242  CPropTreeItem *FocusPrev();
243 
244  // Focus on the next item
245  CPropTreeItem *FocusNext();
246 
247  LRESULT SendNotify(UINT nNotifyCode, CPropTreeItem* pItem = NULL);
248 
249 protected:
250  // Resize the child windows to fit the exact dimensions the CPropTree control
251  void ResizeChildWindows(int cx, int cy);
252 
253  // Initialize global resources, brushes, fonts, etc.
254  void InitGlobalResources();
255 
256  // Free global resources, brushes, fonts, etc.
257  void FreeGlobalResources();
258 
259  // Recursive version of DeleteItem
260  void Delete(CPropTreeItem* pItem);
261 
262 // Overrides
263  // ClassWizard generated virtual function overrides
264  //{{AFX_VIRTUAL(CPropTree)
265  //}}AFX_VIRTUAL
266 
267 // Implementation
268 private:
269  static BOOL CALLBACK EnumFindItem(CPropTree* pProp, CPropTreeItem* pItem, LPARAM lParam);
270  static BOOL CALLBACK EnumSelectAll(CPropTree*, CPropTreeItem* pItem, LPARAM lParam);
271  static BOOL CALLBACK EnumMoveAll(CPropTree*, CPropTreeItem* pItem, LPARAM);
272  static BOOL CALLBACK EnumRefreshAll(CPropTree*, CPropTreeItem* pItem, LPARAM);
273 
274  // Generated message map functions
275 protected:
276  //{{AFX_MSG(CPropTree)
277  afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
278  afx_msg void OnSize(UINT nType, int cx, int cy);
279  afx_msg void OnEnable(BOOL bEnable);
280  afx_msg void OnSysColorChange();
281  //}}AFX_MSG
282  DECLARE_MESSAGE_MAP()
283 };
284 
286 
287 //{{AFX_INSERT_LOCATION}}
288 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
289 
290 #endif // !defined(AFX_PROPT_H__386AA426_6FB7_4B4B_9563_C4CC045BB0C9__INCLUDED_)
CPropTreeItem LPARAM
Definition: PropTree.h:70
struct _NMPROPTREE NMPROPTREE
CPropTreeItem * m_pVisbleList
Definition: PropTree.h:187
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
static CFont * s_pBoldFont
Definition: PropTree.h:202
DWORD
Definition: win_qgl.cpp:61
#define PROPTREE_API
Definition: PropTree.h:53
CPropTreeItem m_Root
Definition: PropTree.h:184
static UINT s_nInstanceCount
Definition: PropTree.h:199
CPoint m_Origin
Definition: PropTree.h:193
struct _NMPROPTREE * LPNMPROPTREE
CPropTreeItem * m_pFocus
Definition: PropTree.h:190
BOOL m_bShowInfo
Definition: PropTree.h:178
BOOL m_bDisableInput
Definition: PropTree.h:204
LONG m_nInfoHeight
Definition: PropTree.h:181
#define NULL
Definition: Lib.h:88
Definition: eax4.h:1413
#define FAR
Definition: jmorecfg.h:205
CPropTreeItem * pItem
Definition: PropTree.h:91
CPropTreeList m_List
Definition: PropTree.h:172
NMHDR hdr
Definition: PropTree.h:90
long LONG
typedef BOOL(CALLBACK *ENUMPROPITEMPROC)(CPropTree *
CPropTreeInfo m_Info
Definition: PropTree.h:175
static CPropTreeItem * s_pFound
Definition: PropTree.h:207
#define TRUE
Definition: mprintf.c:69
struct _NMPROPTREE * PNMPROPTREE
static CFont * s_pNormalFont
Definition: PropTree.h:201
void InitPropTree(HINSTANCE hInstance)
Definition: PropTree.cpp:62
UINT m_nLastUID
Definition: PropTree.h:196