Copy rpoolmgr.h from trunk
[reactos.git] / rosapps / lib / dflat32 / log.c
1 /* ------------ log .c ------------ */
2
3 #include "dflat32/dflat.h"
4
5 #ifdef INCLUDE_LOGGING
6
7 static char *message[] = {
8 #undef DFlatMsg
9 #define DFlatMsg(m) " " #m,
10 #include "dflat32/dflatmsg.h"
11 NULL
12 };
13
14 static FILE *logfile = NULL;
15 extern DBOX Log;
16
17 void LogMessages (DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
18 {
19 if (logfile != NULL && message[msg][0] != ' ')
20 fprintf(logfile,
21 "%-20.20s %-12.12s %-20.20s, %5.5ld, %5.5ld\n",
22 wnd ? (GetTitle(wnd) ? GetTitle(wnd) : "") : "",
23 wnd ? ClassNames[GetClass(wnd)] : "",
24 message[msg]+1, p1, p2);
25 }
26
27 static int LogProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
28 {
29 DFWINDOW cwnd = ControlWindow(&Log, ID_LOGLIST);
30 char **mn = message;
31 switch (msg) {
32 case INITIATE_DIALOG:
33 AddAttribute(cwnd, MULTILINE | VSCROLLBAR);
34 while (*mn) {
35 DfSendMessage(cwnd, ADDTEXT, (PARAM) (*mn), 0);
36 mn++;
37 }
38 DfSendMessage(cwnd, SHOW_WINDOW, 0, 0);
39 break;
40 case DFM_COMMAND:
41 if ((int) p1 == ID_OK) {
42 int item;
43 int tl = GetTextLines(cwnd);
44 for (item = 0; item < tl; item++)
45 if (ItemSelected(cwnd, item))
46 mn[item][0] = LISTSELECTOR;
47 }
48 break;
49 default:
50 break;
51 }
52 return DefaultWndProc(wnd, msg, p1, p2);
53 }
54
55 void MessageLog(DFWINDOW wnd)
56 {
57 if (DfDialogBox(wnd, &Log, TRUE, LogProc))
58 {
59 if (CheckBoxSetting(&Log, ID_LOGGING))
60 {
61 logfile = fopen("DFLAT.LOG", "wt");
62 SetCommandToggle(&MainMenu, ID_LOG);
63 }
64 else if (logfile != NULL)
65 {
66 fclose(logfile);
67 logfile = NULL;
68 ClearCommandToggle(&MainMenu, ID_LOG);
69 }
70 }
71 }
72
73 #endif
74
75 /* EOF */