Files
envi-code/SourceCode/Code2026/inc/PropCtrl.h
T
2026-09-28 15:28:50 +08:00

265 lines
6.9 KiB
C++

// PropTree.h : header file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
#if !defined(__CPropCTRL_H__)
#define __CPropCTRL_H__
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "PropList.h"
#include "PropInfo.h"
#include "PropItem.h"
#include "PropItemStatic.h"
#include "PropItemEdit.h"
#include "PropItemCombo.h"
#include "PropItemColor.h"
class CPropCtrl;
#define PROPTREEITEM_DEFHEIGHT 18 // default heigt of an item
#define PROPTREEITEM_SPACE 3 // default horz spacing
#define PROPTREEITEM_EXPANDBOX 9 // size of the expand box
#define PROPTREEITEM_CHECKBOX 14 // size of the check box
#define PROPTREEITEM_EXPANDCOLUMN 16 // width of the expand column
#define PNINDENT 16 // child level indent
#define PROPTREEITEM_COLRNG 1 // width of splitter
typedef BOOL (CALLBACK* ENUMPROPITEMPROC)(CPropCtrl*, CPropItem*, LPARAM);
// CPropCtrl window styles
#define PTS_NOTIFY 0x00000001
// CPropCtrl HitTest return codes
#define HTPROPFIRST 50
#define HTLABEL (HTPROPFIRST + 0)
#define HTCOLUMN (HTPROPFIRST + 1)
#define HTEXPAND (HTPROPFIRST + 2)
#define HTATTRIBUTE (HTPROPFIRST + 3)
#define HTCHECKBOX (HTPROPFIRST + 4)
#define HTBUTTON (HTPROPFIRST + 5)
// CPropCtrl WM_NOTIFY notification structure
typedef struct _NMPROPTREE
{
NMHDR hdr;
CPropItem* pItem;
} NMPROPTREE, *PNMPROPTREE, FAR *LPNMPROPTREE;
// CPropCtrl specific Notification Codes
#define PTN_FIRST (0U-1100U)
#define PTN_INSERTITEM (PTN_FIRST-1)
#define PTN_DELETEITEM (PTN_FIRST-2)
#define PTN_DELETEALLITEMS (PTN_FIRST-3)
#define PTN_ITEMCHANGED (PTN_FIRST-5)
#define PTN_ITEMBUTTONCLICK (PTN_FIRST-6)
#define PTN_SELCHANGE (PTN_FIRST-7)
#define PTN_ITEMEXPANDING (PTN_FIRST-8)
#define PTN_COLUMNCLICK (PTN_FIRST-9)
#define PTN_PROPCLICK (PTN_FIRST-10)
#define PTN_CHECKCLICK (PTN_FIRST-12)
/////////////////////////////////////////////////////////////////////////////
// CPropCtrl window
class THVAC_UIAPI CPropCtrl : public CWnd
{
public:
CPropCtrl();
virtual ~CPropCtrl();
BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
BOOL Create(CWnd* pParentWnd, UINT nID);
public:
static CFont* GetNormalFont();
static CFont* GetBoldFont();
// Returns the root item of the tree
CPropItem* GetRootItem();
// Returns the focused item or NULL for none
CPropItem* GetFocusedItem();
// Enumerates an item and all its child items
BOOL EnumItems(CPropItem* pItem, ENUMPROPITEMPROC proc, LPARAM lParam = 0L);
// Insert a created CPropItem into the control
CPropItem* InsertItem(CPropItem* pItem, CPropItem* pParent = NULL);
// Delete an item and ALL its children
void DeleteItem(CPropItem* pItem);
// Delete all items from the tree
void DeleteAllItems();
// Return the splitter position
LONG GetColumn();
// Set the splitter position
void SetColumn(LONG nColumn);
// Sets the focused item
void SetFocusedItem(CPropItem* pItem);
// Show or hide the info text
void ShowInfoText(BOOL bShow = TRUE);
// Set infoRect Heigh
void SetInfoHeigh(int nHeigh);
// Returns TRUE if the item is visible (its parent is expanded)
BOOL IsItemVisible(CPropItem* pItem);
// Ensures that an item is visible
void EnsureVisible(CPropItem* pItem);
// do a hit test on the control (returns a HTxxxx code)
LONG HitTest(const POINT& pt);
// find an item by a location
CPropItem* FindItem(const POINT& pt);
// find an item by item id
CPropItem* FindItem(UINT nCtrlID);
// find an item by item Lable
CPropItem* FindItem(const CString &csLable);
protected:
// Actual tree control
CPropList m_List;
// Descriptive control
CPropInfo m_Info;
// TRUE to show info control
BOOL m_bShowInfo;
// Height of the info control
LONG m_nInfoHeight;
// Root level tree item
CPropItem m_Root;
// Linked list of visible items
CPropItem* m_pVisbleList;
// Pointer to the focused item (selected)
CPropItem* m_pFocus;
// PropTree scroll position. x = splitter position, y = vscroll position
CPoint m_Origin;
// auto generated last created ID
UINT m_nLastUID;
// Number of CPropCtrl controls in the current application
static UINT s_nInstanceCount;
static CFont* s_pNormalFont;
static CFont* s_pBoldFont;
BOOL m_bDisableInput;
// Used for enumeration
static CPropItem* s_pFound;
public:
void AddToVisibleList(CPropItem* pItem);
void ClearVisibleList();
void SetOriginOffset(LONG nOffset);
void UpdatedItems();
void UpdateMoveAllItems();
void RefreshItems(CPropItem* pItem = NULL);
// enable or disable tree input
void DisableInput(BOOL bDisable = TRUE);
BOOL IsDisableInput();
BOOL IsSingleSelection();
CPropItem* GetVisibleList();
CWnd* GetCtrlParent();
const POINT& GetOrigin();
void SelectItems(CPropItem* pItem, BOOL bSelect = TRUE);
// Focus on the first visible item
CPropItem *FocusFirst();
// Focus on the last visible item
CPropItem *FocusLast();
// Focus on the previous item
CPropItem *FocusPrev();
// Focus on the next item
CPropItem *FocusNext();
// Set All Items Readonly
void ReadOnly(CPropItem* pItem, BOOL bRead);
LRESULT SendNotify(UINT nNotifyCode, CPropItem* pItem = NULL);
void ShowVSrolBar(BOOL bShow = TRUE);
protected:
// Resize the child windows to fit the exact dimensions the CPropCtrl control
void ResizeChildWindows(int cx, int cy);
// Initialize global resources, brushes, fonts, etc.
void InitGlobalResources();
// Free global resources, brushes, fonts, etc.
void FreeGlobalResources();
// Recursive version of DeleteItem
void Delete(CPropItem* pItem);
//{{AFX_VIRTUAL(CPropCtrl)
//}}AFX_VIRTUAL
private:
static BOOL CALLBACK EnumFindItem(CPropCtrl* pProp, CPropItem* pItem, LPARAM lParam);
CPropItem* EnumFindItem(CPropItem*, const CString &csLable );
static BOOL CALLBACK EnumSelectAll(CPropCtrl*, CPropItem* pItem, LPARAM lParam);
static BOOL CALLBACK EnumMoveAll(CPropCtrl*, CPropItem* pItem, LPARAM);
static BOOL CALLBACK EnumRefreshAll(CPropCtrl*, CPropItem* pItem, LPARAM);
protected:
//{{AFX_MSG(CPropCtrl)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnEnable(BOOL bEnable);
afx_msg void OnSysColorChange();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include "PropOrigItemEdit.h"
//{{AFX_INSERT_LOCATION}}
#endif // !defined(__CPropCTRL_H__)