summaryrefslogtreecommitdiff
path: root/hammer/anglebox.h
blob: e70c4613e5b79e552219a2f742a1694919dbe28e (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
124
125
126
127
128
129
130
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#ifndef ANGLEBOX_H
#define ANGLEBOX_H
#ifdef _WIN32
#pragma once
#endif

#include "mathlib/vector.h"


class CAngleCombo;


class CAngleBox : public CWnd
{
public:
	CAngleBox();
	virtual ~CAngleBox();

	bool GetAngles(QAngle &vecAngles);
	char *GetAngles(char *szAngles);

	void SetAngles(const QAngle &vecAngles, bool bRedraw = true);
	void SetAngles(const char *szAngles, bool bRedraw = true);
	
	void SetDifferent(bool bDifferent, bool bRedraw = true);
	inline void SetEditControl(CAngleCombo *pEdit);

	char *GetAngleEditText(char *szBuf);

	void Enable(bool bEnable);
	void Show(bool bShow);

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAngleBox)
	public:
	//}}AFX_VIRTUAL

protected:

	void UpdateAngleEditText(void);
	void UpdateLine(void);
	void DrawAngleLine(CDC *pDC);

	bool m_bDifferent;			// Set to true when we have multiselected objects with different angles.

	CDC m_DragDC;				// When dragging w/mouse.
	CPoint m_ptClientCenter;
	bool m_bDragging;

	QAngle m_vecAngles;

	CAngleCombo *m_pEdit;		// The linked angle edit box, NULL if none.

	// Generated message map functions
	//{{AFX_MSG(CAngleBox)
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnPaint();
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()

private:

friend class CAngleCombo;

	// Functions called by the angle combo to set our state without notification
	// back to the angle combo.
	void SetAnglesInternal(const QAngle &vecAngles, bool bRedraw = true);
	void SetDifferentInternal(bool bDifferent, bool bRedraw = true);
};


//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CAngleBox::SetEditControl(CAngleCombo *pEdit)
{
	m_pEdit = pEdit;
}


//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CAngleCombo : public CComboBox
{
public:

	CAngleCombo();

	inline void SetAngleBox(CAngleBox *pBox);

protected:

	void UpdateAngleBox(char *szText);

	// Generated message map functions
	//{{AFX_MSG(CAngleBox)
	afx_msg void OnChangeAngleEdit();
	afx_msg void OnSelChangeAngleEdit();
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()

private:

friend class CAngleBox;

	void SetAnglesInternal(const char *szAngles);

	CAngleBox *m_pBox;		// The linked angle box control.
	bool m_bEnableUpdate;	// Whether we forward update notifications to the linked angle box control.
};


void CAngleCombo::SetAngleBox(CAngleBox *pBox)
{
	m_pBox = pBox;
}


#endif // ANGLEBOX_H