summaryrefslogtreecommitdiff
path: root/hammer/listboxex.h
blob: 3065095e7e6bbd15afbf07fe2e8d0dab34188543 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//
//=============================================================================//
// ListBoxEx.h : header file
//

#ifndef _LISTBOXEX_H
#define _LISTBOXEX_H

#include <afxtempl.h>

enum
{
	lbdBool,
	lbdString,
	lbdInteger
};

enum
{
	lbeYesNo,
	lbeOnOff,
	lbeString,
	lbeInteger,
	lbeTexture,
	lbeChoices
};

typedef struct
{
	char szCaption[128];	// field named
	char *pszSaveCaption;	// save caption to this, if supported
	int iDataType;			// how to display	(lbdxxx)
	int iEditType;			// how to edit		(lbexxx)
	
	int iDataValue;			// int value for integer/bool fields
	char szDataString[128];	// str value for string fields
	
	PVOID pSaveTo;
	const char * pszHelp;	// help text		(ptr or NULL)
	int iRangeMin;			// ranged value min	(-1 if no range)
	int iRangeMax;			// ranged value max	(-1 if no range)
	CStringArray* pChoices;	// choices, if lbdChoices

} LBEXTITEMSTRUCT;

// listboxex styles
enum
{
	LBES_EDITCAPTIONS = 0x01
};

/////////////////////////////////////////////////////////////////////////////
// CListBoxEx window

class CListBoxEx : public CListBox
{
// Construction
public:
	CListBoxEx();

// Attributes
public:
	int iCaptionWidthUnits;
	int iCaptionWidthPixels;
	int iItemHeight;
	CEdit EditCtrl;
	CComboBox ComboCtrl;
	DWORD dwStyle;
	BOOL bControlActive;
	BOOL bIgnoreChange;
	int iControlItem;

	void SetStyle(DWORD dwStyle);

	void AddItem(char * pszCaption, int iEditType, PVOID pData,
		int iRangeMin = -1, int iRangeMax = -1, const char * pszHelp = NULL);
	void SetItemChoices(int iItem, CStringArray * pChoices, 
		int iDefaultChoice = 0);
	void GetItemText(int iItem, char *pszText);
	void CreateEditControl();
	void CreateComboControl();
	void DestroyControls();

	CArray<LBEXTITEMSTRUCT, LBEXTITEMSTRUCT&> Items;
	unsigned nItems;

// Operations
public:
	BOOL bActivateOnRelease;

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CListBoxEx)
	public:
	virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
	virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CListBoxEx();

	// Generated message map functions
protected:
	//{{AFX_MSG(CListBoxEx)
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnSelchange();
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

#endif // _LISTBOXEX_H