-
Notifications
You must be signed in to change notification settings - Fork 0
/
IFontOptions.cpp
231 lines (225 loc) · 6.43 KB
/
IFontOptions.cpp
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#include "stdafx.h"
#include "IFontOptions.h"
struct CFontOptions : public IFontOptions
{
CFontOptions()
{
RestoreDefaults();
}
virtual void Read(LPCTSTR file)
{
CPrivateIniFile ini;
BOOL res = FALSE;
if (ini.Create(file)) {
m_UserNameFore = (COLORREF)ini.GetInt(_T("visual"), _T("user_fore"), Colors::BLUE);
m_UserNameBack = (COLORREF)ini.GetInt(_T("visual"), _T("user_back"), Colors::WHITE);
m_UserTextFore = (COLORREF)ini.GetInt(_T("visual"), _T("text_fore"), Colors::BLACK);
m_UserTextBack = (COLORREF)ini.GetInt(_T("visual"), _T("text_back"), Colors::WHITE);
meFore = (COLORREF)ini.GetInt(_T("visual"), _T("me_fore"),Colors::BLUE);
meBack = (COLORREF)ini.GetInt(_T("visual"), _T("me_back"), Colors::WHITE);
myTextFore = (COLORREF)ini.GetInt(_T("visual"), _T("mytext_fore"), Colors::BLACK);
myTextBack = (COLORREF)ini.GetInt(_T("visual"), _T("mytext_back"), Colors::WHITE);
topicFore = (COLORREF)ini.GetInt(_T("visual"), _T("topic_fore"), Colors::MARRON);
topicBack = (COLORREF)ini.GetInt(_T("visual"), _T("topic_back"), Colors::WHITE);
motdFore = (COLORREF)ini.GetInt(_T("visual"), _T("motd_fore"), Colors::GREEN);
motdBack = (COLORREF)ini.GetInt(_T("visual"), _T("motd_back"), Colors::WHITE);
userEnter = (COLORREF)ini.GetInt(_T("visual"), _T("user_enters"), Colors::GREEN);
userLeave = (COLORREF)ini.GetInt(_T("visual"), _T("user_leaves"), Colors::GREEN);
}
}
virtual void Write(LPCTSTR file)
{
CPrivateIniFile ini;
BOOL res = FALSE;
if (ini.Create(file)) {
ini.WriteInt(_T("visual"), _T("user_fore"), m_UserNameFore);
ini.WriteInt(_T("visual"), _T("user_back"), m_UserNameBack);
ini.WriteInt(_T("visual"), _T("text_fore"), m_UserTextFore);
ini.WriteInt(_T("visual"), _T("text_back"), m_UserTextBack);
ini.WriteInt(_T("visual"), _T("me_fore"), meFore);
ini.WriteInt(_T("visual"), _T("me_back"), meBack);
ini.WriteInt(_T("visual"), _T("mytext_fore"), myTextFore);
ini.WriteInt(_T("visual"), _T("mytext_back"), myTextBack);
ini.WriteInt(_T("visual"), _T("topic_fore"), topicFore);
ini.WriteInt(_T("visual"), _T("topic_back"), topicBack);
ini.WriteInt(_T("visual"), _T("user_enters"), userEnter);
ini.WriteInt(_T("visual"), _T("user_leaves"), userLeave);
}
}
virtual void RestoreDefaults()
{
m_UserNameFore = Colors::BLUE;
m_UserNameBack = Colors::WHITE;
m_UserTextFore = Colors::BLACK;
m_UserTextBack = Colors::WHITE;
meFore = Colors::BLUE;
meBack = Colors::WHITE;
myTextFore = Colors::BLACK;
myTextBack = Colors::WHITE;
topicFore = Colors::MARRON;
topicBack = Colors::WHITE;
motdFore = Colors::GREEN;
motdBack = Colors::WHITE;
userEnter = Colors::GREEN;
userLeave = Colors::GREEN;
}
virtual void GetUserName(CColor& fore, CColor& back)
{
fore = m_UserNameFore;
back = m_UserNameBack;
}
virtual void GetUserNameDef(CColor& fore, CColor& back)
{
fore = Colors::BLUE;
back = Colors::WHITE;
}
virtual void GetUserText(CColor& fore, CColor& back)
{
fore = m_UserTextFore;
back = m_UserTextBack;
}
virtual void GetUserTextDef(CColor& fore, CColor& back)
{
fore = Colors::BLACK;
back = Colors::WHITE;
}
virtual void SetUserName(CColor& fore, CColor& back)
{
m_UserNameFore = fore;
m_UserNameBack = back;
}
virtual void SetUserNameDef()
{
CColor fore, back;
GetUserNameDef(fore, back);
SetUserName(fore, back);
}
virtual void SetUserText(CColor& fore, CColor& back)
{
m_UserTextFore = fore;
m_UserTextBack = back;
}
virtual void SetUserTextDef()
{
CColor fore, back;
GetUserTextDef(fore, back);
SetUserText(fore, back);
}
virtual CColor MeFore(bool def,bool dummy) const
{
if (def) {
return Colors::BLUE;
}
return meFore;
}
virtual CColor MeBack(bool def,bool dummy) const
{
if (def) {
return Colors::WHITE;
}
return meBack;
}
virtual CColor MyTextFore(bool def,bool dummy) const
{
if (def) {
return Colors::BLACK;
}
return myTextFore;
}
virtual CColor MyTextBack(bool def,bool dummy) const
{
if (def) {
return Colors::WHITE;
}
return myTextBack;
}
virtual void MeFore(const CColor& fore)
{
meFore = fore;
}
virtual void MeBack(const CColor& back)
{
meBack = back;
}
virtual void MyTextFore(const CColor& fore)
{
myTextFore = fore;
}
virtual void MyTextBack(const CColor& back)
{
myTextBack = back;
}
virtual void Topic(CColor& fore, CColor& back, bool def) const
{
fore = def?Colors::MARRON:topicFore;
back = def ? Colors::WHITE : topicBack;
}
virtual void Topic(const CColor& fore, const CColor& back)
{
topicFore = fore;
topicBack = back;
}
virtual void motd(CColor& fore, CColor& back, bool def) const
{
fore = def ? Colors::GREEN : motdFore;
back = def ? Colors::WHITE : motdBack;
}
virtual void motd(const CColor& fore, const CColor& back)
{
motdFore = fore;
motdBack = back;
}
virtual CColor UserEnters(bool def, bool dummy) const
{
return def ? Colors::GREEN : userEnter;
}
virtual void UserEnters(const CColor& clr)
{
userEnter = clr;
}
virtual CColor UserLeaves(bool def, bool dummy) const
{
return def ? Colors::GREEN : userLeave;
}
virtual void UserLeaves(const CColor& clr)
{
userLeave = clr;
}
virtual void CopyTo(IFontOptions** ppOptions)
{
ATLASSERT(ppOptions && (*ppOptions));
//if (*ppOptions)
// DestroyFontOptions(ppOptions);
//CreateFontOptions(ppOptions);
(*ppOptions)->SetUserName(m_UserNameFore, m_UserNameBack);
(*ppOptions)->SetUserText(m_UserTextFore, m_UserTextBack);
(*ppOptions)->MeFore(meFore);
(*ppOptions)->MeBack(meBack);
(*ppOptions)->MyTextFore(myTextFore);
(*ppOptions)->MyTextBack(myTextBack);
(*ppOptions)->Topic(topicFore, topicBack);
(*ppOptions)->motd(motdFore, motdBack);
(*ppOptions)->UserEnters(userEnter);
(*ppOptions)->UserLeaves(userLeave);
}
CColor m_UserNameFore, m_UserNameBack, m_UserTextFore, m_UserTextBack;
CColor meFore, meBack, myTextFore, myTextBack;
CColor topicFore, topicBack, motdFore, motdBack;
CColor userEnter, userLeave;
};
BOOL CreateFontOptions(IFontOptions** ppOptions)
{
if (ppOptions) {
*ppOptions = NULL;
*ppOptions = new CFontOptions();
}
return TRUE;
}
void DestroyFontOptions(IFontOptions** ppOptions)
{
if (ppOptions && *ppOptions) {
CFontOptions* pfo = (CFontOptions *)*ppOptions;
delete pfo;
*ppOptions = NULL;
}
}