ReactOS 0.4.15-dev-7934-g1dc8d80
config.c File Reference
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include "resource.h"
#include "globals.h"
#include "message.h"
#include "matrix.h"
Include dependency graph for config.c:

Go to the source code of this file.

Functions

int CALLBACK EnumFontProc (ENUMLOGFONT *lpelfe, NEWTEXTMETRIC *lpntme, int FontType, LPARAM lParam)
 
void AddFonts (HWND hwndCombo)
 
void UpdatePreview (HWND hwnd)
 
INT_PTR CALLBACK ConfigDlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
int Configure (HWND hwndParent)
 

Function Documentation

◆ AddFonts()

void AddFonts ( HWND  hwndCombo)

Definition at line 29 of file config.c.

30{
31 HDC hdc;
32 LOGFONT lf;
33
35 lf.lfPitchAndFamily = 0;
36 lf.lfFaceName[0] = _T('\0');
37
38 hdc = GetDC(0);
40 ReleaseDC(0, hdc);
41}
int CALLBACK EnumFontProc(ENUMLOGFONT *lpelfe, NEWTEXTMETRIC *lpntme, int FontType, LPARAM lParam)
Definition: config.c:20
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
BYTE lfPitchAndFamily
Definition: dimm.idl:54
BYTE lfCharSet
Definition: dimm.idl:50
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
#define _T(x)
Definition: vfdio.h:22
FONTENUMPROCA FONTENUMPROC
Definition: wingdi.h:2902
#define EnumFontFamiliesEx
Definition: wingdi.h:4451
#define ANSI_CHARSET
Definition: wingdi.h:383
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by ConfigDlgProc().

◆ ConfigDlgProc()

INT_PTR CALLBACK ConfigDlgProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 56 of file config.c.

57{
58 static TCHAR buf[256];
59 HWND hwndCombo, hwndCtrl;
60 int index, items, val;
61 RECT rect;
62 static int prevwidth, prevheight;
63
64 switch(uMsg)
65 {
66 case WM_INITDIALOG:
67
69 prevheight = GetSystemMetrics(SM_CYSCREEN) / GLYPH_HEIGHT + 1;
70
71 //Add any saved messages to the combo box
72 for(index = 0; index < g_nNumMessages; index++)
73 {
74 if(lstrlen(g_szMessages[index]) > 0)
76 }
77
78 //select the first message, and preview it
80
85
86 //SendDlgItemMessage(hwnd, IDC_SLIDER1, TBM_SETTICFREQ, 5, 0);
90
95
98
103 return 0;
104
105 case WM_DESTROY:
106 //DeInitMessage();
107 return 0;
108
110
112 {
113 SetTextColor((HDC)wParam, RGB(0,80,0));
116 }
117 else if(GetDlgCtrlID((HWND)lParam) == IDC_PREVIEW)
118 {
119 HDC hdc = (HDC)wParam;
120 RECT clip;
121
123
125
126 if(prevwidth < rect.right)
127 {
128 rect.left = (rect.right-prevwidth) / 2;
129 rect.right = rect.left + prevwidth;
130 }
131 else
132 {
133 rect.left = 0;
134 rect.right = prevwidth;
135 }
136
137 if(prevheight < rect.bottom)
138 {
139 rect.top = (rect.bottom-prevheight) / 2;
140 rect.bottom = rect.top + prevheight;
141 }
142 else
143 {
144 rect.top = 0;
145 rect.bottom = prevheight;
146 }
147
148 SetTextColor(hdc, RGB(128,255,128));
149 SetBkColor(hdc, 0);
150
151 //SetRect(&rect, 0, 0, PrevMessage->width, MAXMSG_HEIGHT);
152 CopyRect(&clip, &rect);
154
156
157 InflateRect(&clip, 2, 2);
158
160 IntersectClipRect(hdc, rect.left, rect.top, rect.right, rect.bottom);
161
162 // figure out where the bounding rectangle should be
164 OffsetRect(&rect, (prevwidth-(rect.right-rect.left))/2, (prevheight-(rect.bottom-rect.top))/2);
165
166 // now draw it!
168
169
171 }
172 else
173 {
174 break;
175 }
176
177 case WM_HSCROLL:
178
180 {
181 // one of the sliders changed..update
183 }
184
185 return 0;
186
187 case WM_COMMAND:
188
189 switch(HIWORD(wParam))
190 {
191 case CBN_EDITCHANGE:
192 case CBN_SELCHANGE:
193
194 //fall through to Preview:
197 //SetMessageFont(hwnd, g_szFontName, g_nFontSize, TRUE);
198
200 return 0;
201 }
202
203 switch(LOWORD(wParam))
204 {
205 case IDC_RANDOM:
207 break;
208
209 case IDC_BOLD:
212 break;
213
214 case IDOK:
215
216 hwndCtrl = GetDlgItem(hwnd, IDC_COMBO1);
217
218 items = min(MAX_MESSAGES, SendMessage(hwndCtrl, CB_GETCOUNT, 0, 0));
219
220 for(index = 0; index < items; index++)
221 {
223 }
224
226
227 //matrix speed
229 if(val >= SPEED_MIN && val <= SPEED_MAX)
231
232 //density
234 if(val >= DENSITY_MIN && val <= DENSITY_MAX)
235 g_nDensity = val;
236
237 //message speed
239 if(val >= MSGSPEED_MIN && val <= MSGSPEED_MAX)
241
242 //font size
244 if(val >= FONT_MIN && val <= FONT_MAX)
246
247 SaveSettings();
248 EndDialog(hwnd, 0);
249 return 0;
250
251 case IDCANCEL:
252 EndDialog(hwnd, 0);
253 return TRUE;
254
255 case IDC_ADD:
256
257 hwndCombo = GetDlgItem(hwnd, IDC_COMBO1);
258
259 if(GetWindowText(hwndCombo, buf, 256))
260 {
261 SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)buf);
262 }
263
265
266 return 0;
267
268 case IDC_REMOVE:
269 hwndCombo = GetDlgItem(hwnd, IDC_COMBO1);
270 GetWindowText(hwndCombo, buf, 256);
271
272 index = SendMessage(hwndCombo, CB_GETCURSEL, 0, 0);
273 SendMessage(hwndCombo, CB_DELETESTRING, index, 0);
274
275 SendMessage(hwndCombo, CB_SETCURSEL, 0, 0);
277 return 0;
278 }
279 return 0;
280
281 case WM_CLOSE:
282 EndDialog(hwnd, 0);
283 return 0;
284 }
285 return 0;
286}
void SaveSettings(void)
Definition: settings.c:115
#define index(s, c)
Definition: various.h:29
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define IDC_ADD
Definition: resource.h:16
#define IDC_REMOVE
Definition: resource.h:18
#define RGB(r, g, b)
Definition: precomp.h:71
GLuint index
Definition: glext.h:6031
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLfloat * val
Definition: glext.h:7180
void AddFonts(HWND hwndCombo)
Definition: config.c:29
void UpdatePreview(HWND hwnd)
Definition: config.c:46
int g_nNumMessages
Definition: settings.c:14
#define MAX_MESSAGES
Definition: globals.h:30
#define FONT_MAX
Definition: globals.h:33
BOOL g_fRandomizeMessages
Definition: settings.c:21
TCHAR g_szMessages[MAX_MESSAGES][MAXMSG_LENGTH]
Definition: settings.c:13
int g_nMatrixSpeed
Definition: settings.c:18
#define DENSITY_MAX
Definition: globals.h:11
BOOL g_fFontBold
Definition: settings.c:22
#define GLYPH_HEIGHT
Definition: globals.h:18
#define DENSITY_MIN
Definition: globals.h:12
TCHAR g_szFontName[]
Definition: settings.c:16
int g_nFontSize
Definition: settings.c:20
#define FONT_MIN
Definition: globals.h:32
int g_nMessageSpeed
Definition: settings.c:15
#define MSGSPEED_MIN
Definition: globals.h:28
#define GLYPH_WIDTH
Definition: globals.h:17
#define SPEED_MAX
Definition: globals.h:20
#define SPEED_MIN
Definition: globals.h:21
#define MSGSPEED_MAX
Definition: globals.h:27
int g_nDensity
Definition: settings.c:19
HFONT g_hFont
Definition: settings.c:25
#define IDC_SLIDER4
Definition: resource.h:18
#define IDC_SLIDER2
Definition: resource.h:16
#define IDC_BOLD
Definition: resource.h:19
#define IDC_SLIDER3
Definition: resource.h:17
#define IDC_COMBO2
Definition: resource.h:20
#define IDC_SLIDER1
Definition: resource.h:15
#define IDC_RANDOM
Definition: resource.h:14
#define IDC_COMBO1
Definition: resource.h:8
#define min(a, b)
Definition: monoChain.cc:55
#define IDC_ABOUT
static TCHAR * items[]
Definition: page1.c:45
#define LOWORD(l)
Definition: pedump.c:82
#define TBM_GETPOS
Definition: commctrl.h:2031
#define TBM_SETRANGE
Definition: commctrl.h:2037
#define TBM_SETPOS
Definition: commctrl.h:2036
#define TBM_SETTICFREQ
Definition: commctrl.h:2050
& rect
Definition: startmenu.cpp:1413
int32_t INT_PTR
Definition: typedefs.h:64
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
#define lstrlen
Definition: winbase.h:3876
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
HGDIOBJ WINAPI GetStockObject(_In_ int)
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define NULL_BRUSH
Definition: wingdi.h:901
#define BLACK_BRUSH
Definition: wingdi.h:896
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
DWORD WINAPI GetSysColor(_In_ int)
BOOL WINAPI CopyRect(_Out_ LPRECT, _In_ LPCRECT)
int WINAPI FrameRect(_In_ HDC, _In_ LPCRECT, _In_ HBRUSH)
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1772
#define WM_CLOSE
Definition: winuser.h:1621
#define CB_GETLBTEXT
Definition: winuser.h:1952
#define WM_HSCROLL
Definition: winuser.h:1743
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define SM_CYSCREEN
Definition: winuser.h:960
#define DT_CENTER
Definition: winuser.h:527
#define IDCANCEL
Definition: winuser.h:831
#define GetDlgItemText
Definition: winuser.h:5785
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1740
#define CB_SETCURSEL
Definition: winuser.h:1961
#define COLOR_3DSHADOW
Definition: winuser.h:931
#define WM_INITDIALOG
Definition: winuser.h:1739
#define CB_GETCOUNT
Definition: winuser.h:1942
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
#define CBN_SELCHANGE
Definition: winuser.h:1979
#define DrawText
Definition: winuser.h:5771
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_WORDBREAK
Definition: winuser.h:544
#define CB_ADDSTRING
Definition: winuser.h:1936
#define SendMessage
Definition: winuser.h:5843
#define GetWindowText
Definition: winuser.h:5798
#define DT_VCENTER
Definition: winuser.h:543
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
int WINAPI GetDlgCtrlID(_In_ HWND)
#define WM_DESTROY
Definition: winuser.h:1609
#define CB_FINDSTRING
Definition: winuser.h:1939
#define SM_CXSCREEN
Definition: winuser.h:959
#define DT_CALCRECT
Definition: winuser.h:526
#define CB_GETCURSEL
Definition: winuser.h:1943
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define CB_DELETESTRING
Definition: winuser.h:1937
#define SendDlgItemMessage
Definition: winuser.h:5842
int WINAPI GetSystemMetrics(_In_ int)
#define CBN_EDITCHANGE
Definition: winuser.h:1975
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define COLOR_3DFACE
Definition: winuser.h:929
#define IDC_PREVIEW
Definition: wordpad.h:171
char TCHAR
Definition: xmlstorage.h:189

Referenced by Configure().

◆ Configure()

int Configure ( HWND  hwndParent)

Definition at line 291 of file config.c.

292{
294
296 icc.dwSize = sizeof(icc);
297
299
300#ifdef _DEBUG
301 if(hwndParent == NULL)
302 hwndParent = 0;
303#else
304 if(hwndParent == NULL)
306#endif
307
309
310 return 0;
311}
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
static HWND hwndParent
Definition: cryptui.c:300
#define NULL
Definition: types.h:112
INT_PTR CALLBACK ConfigDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: config.c:56
#define IDD_CONFIG
Definition: resource.h:4
#define ICC_UPDOWN_CLASS
Definition: commctrl.h:62
#define ICC_BAR_CLASSES
Definition: commctrl.h:60
#define GetModuleHandle
Definition: winbase.h:3827
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DialogBox
Definition: winuser.h:5761

◆ EnumFontProc()

int CALLBACK EnumFontProc ( ENUMLOGFONT lpelfe,
NEWTEXTMETRIC lpntme,
int  FontType,
LPARAM  lParam 
)

Definition at line 20 of file config.c.

21{
23 return 1;
24}
LOGFONTA elfLogFont
Definition: wingdi.h:2686
CHAR lfFaceName[LF_FACESIZE]
Definition: wingdi.h:1894

Referenced by AddFonts().

◆ UpdatePreview()

void UpdatePreview ( HWND  hwnd)

Definition at line 46 of file config.c.

47{
51}
void SetMessageFont(HWND hwnd, TCHAR *szFontName, int nPointSize, BOOL fBold)
Definition: message.c:201
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by ConfigDlgProc().