forked from SomeSupport/eMule
-
Notifications
You must be signed in to change notification settings - Fork 97
/
ColorButton.h
178 lines (155 loc) · 6.26 KB
/
ColorButton.h
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
//***************************************************************************
//
// AUTHOR: James White (feel free to remove or otherwise mangle any part)
//
// DESCRIPTION: This class is alarmingly similar to the CColourPicker control
// created by Chris Maunder of www.codeproject.com. It is so as it was blatantly
// copied from that class and is entirely dependant on his other great work
// in CColourPopup. I was hoping for (cough.. gag..) a more Microsoft look
// and I think this is pretty close. Hope you like it.
//
// ORIGINAL: http://www.codeproject.com/miscctrl/colour_picker.asp
//
//***************************************************************************
#pragma once
#include "ColourPopup.h"
void AFXAPI DDX_ColorButton(CDataExchange *pDX, int nIDC, COLORREF& crColour);
class CColorButton : public CButton
{
public:
DECLARE_DYNCREATE(CColorButton);
//***********************************************************************
// Name: CColorButton
// Description: Default constructor.
// Parameters: None.
// Return: None.
// Notes: None.
//***********************************************************************
CColorButton(void);
//***********************************************************************
// Name: CColorButton
// Description: Destructor.
// Parameters: None.
// Return: None.
// Notes: None.
//***********************************************************************
virtual ~CColorButton(void);
//***********************************************************************
//** Property Accessors **
//***********************************************************************
__declspec(property(get=GetColor,put=SetColor)) COLORREF Color;
__declspec(property(get=GetDefaultColor,put=SetDefaultColor)) COLORREF DefaultColor;
__declspec(property(get=GetTrackSelection,put=SetTrackSelection)) BOOL TrackSelection;
__declspec(property(put=SetCustomText)) LPCTSTR CustomText;
__declspec(property(put=SetDefaultText)) LPCTSTR DefaultText;
//***********************************************************************
// Name: GetColor
// Description: Returns the current color selected in the control.
// Parameters: void
// Return: COLORREF
// Notes: None.
//***********************************************************************
COLORREF GetColor(void) const;
//***********************************************************************
// Name: SetColor
// Description: Sets the current color selected in the control.
// Parameters: COLORREF Color
// Return: None.
// Notes: None.
//***********************************************************************
void SetColor(COLORREF Color);
//***********************************************************************
// Name: GetDefaultColor
// Description: Returns the color associated with the 'default' selection.
// Parameters: void
// Return: COLORREF
// Notes: None.
//***********************************************************************
COLORREF GetDefaultColor(void) const;
//***********************************************************************
// Name: SetDefaultColor
// Description: Sets the color associated with the 'default' selection.
// The default value is COLOR_APPWORKSPACE.
// Parameters: COLORREF Color
// Return: None.
// Notes: None.
//***********************************************************************
void SetDefaultColor(COLORREF Color);
//***********************************************************************
// Name: SetCustomText
// Description: Sets the text to display in the 'Custom' selection of the
// CColourPicker control, the default text is "More Colors...".
// Parameters: LPCTSTR tszText
// Return: None.
// Notes: None.
//***********************************************************************
void SetCustomText(LPCTSTR tszText);
//***********************************************************************
// Name: SetDefaultText
// Description: Sets the text to display in the 'Default' selection of the
// CColourPicker control, the default text is "Automatic". If
// this value is set to "", the 'Default' selection will not
// be shown.
// Parameters: LPCTSTR tszText
// Return: None.
// Notes: None.
//***********************************************************************
void SetDefaultText(LPCTSTR tszText);
//***********************************************************************
// Name: SetTrackSelection
// Description: Turns on/off the 'Track Selection' option of the control
// which shows the colors during the process of selection.
// Parameters: BOOL bTrack
// Return: None.
// Notes: None.
//***********************************************************************
void SetTrackSelection(BOOL bTrack);
//***********************************************************************
// Name: GetTrackSelection
// Description: Returns the state of the 'Track Selection' option.
// Parameters: void
// Return: BOOL
// Notes: None.
//***********************************************************************
BOOL GetTrackSelection(void) const;
//{{AFX_VIRTUAL(CColorButton)
public:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
protected:
//{{AFX_MSG(CColorButton)
afx_msg BOOL OnClicked();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
afx_msg LONG OnSelEndOK(UINT lParam, LONG wParam);
afx_msg LONG OnSelEndCancel(UINT lParam, LONG wParam);
afx_msg LONG OnSelChange(UINT lParam, LONG wParam);
//***********************************************************************
// Name: DrawArrow
// Description: None.
// Parameters: CDC* pDC
// RECT* pRect
// int iDirection
// 0 - Down
// 1 - Up
// 2 - Left
// 3 - Right
// Return: static None.
// Notes: None.
//***********************************************************************
static void DrawArrow(CDC* pDC,
RECT* pRect,
int iDirection = 0,
COLORREF clrArrow = RGB(0,0,0));
DECLARE_MESSAGE_MAP()
COLORREF m_Color;
COLORREF m_DefaultColor;
CString m_strDefaultText;
CString m_strCustomText;
BOOL m_bPopupActive;
BOOL m_bTrackSelection;
private:
typedef CButton _Inherited;
};