2000-03-05 19:58:08 +00:00
|
|
|
/* ------------ log .c ------------ */
|
|
|
|
|
|
|
|
#include "dflat.h"
|
|
|
|
|
|
|
|
#ifdef INCLUDE_LOGGING
|
|
|
|
|
|
|
|
static char *message[] = {
|
|
|
|
#undef DFlatMsg
|
|
|
|
#define DFlatMsg(m) " " #m,
|
|
|
|
#include "dflatmsg.h"
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static FILE *logfile = NULL;
|
2003-06-19 02:48:13 +00:00
|
|
|
extern DF_DBOX Log;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfLogMessages (DFWINDOW wnd, DFMESSAGE msg, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
if (logfile != NULL && message[msg][0] != ' ')
|
|
|
|
fprintf(logfile,
|
|
|
|
"%-20.20s %-12.12s %-20.20s, %5.5ld, %5.5ld\n",
|
2003-06-19 02:48:13 +00:00
|
|
|
wnd ? (DfGetTitle(wnd) ? DfGetTitle(wnd) : "") : "",
|
|
|
|
wnd ? DfClassNames[DfGetClass(wnd)] : "",
|
2000-03-05 19:58:08 +00:00
|
|
|
message[msg]+1, p1, p2);
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
static int LogProc(DFWINDOW wnd, DFMESSAGE msg, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DFWINDOW cwnd = DfControlWindow(&Log, DF_ID_LOGLIST);
|
2000-03-05 19:58:08 +00:00
|
|
|
char **mn = message;
|
|
|
|
switch (msg) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_INITIATE_DIALOG:
|
|
|
|
DfAddAttribute(cwnd, DF_MULTILINE | DF_VSCROLLBAR);
|
2000-03-05 19:58:08 +00:00
|
|
|
while (*mn) {
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(cwnd, DFM_ADDTEXT, (DF_PARAM) (*mn), 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
mn++;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(cwnd, DFM_SHOW_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
case DFM_COMMAND:
|
2003-06-19 02:48:13 +00:00
|
|
|
if ((int) p1 == DF_ID_OK) {
|
2000-03-05 19:58:08 +00:00
|
|
|
int item;
|
2003-06-19 02:48:13 +00:00
|
|
|
int tl = DfGetTextLines(cwnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
for (item = 0; item < tl; item++)
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfItemSelected(cwnd, item))
|
|
|
|
mn[item][0] = DF_LISTSELECTOR;
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
return DfDefaultWndProc(wnd, msg, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfMessageLog(DFWINDOW wnd)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
if (DfDialogBox(wnd, &Log, TRUE, LogProc))
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfCheckBoxSetting(&Log, DF_ID_LOGGING))
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
logfile = fopen("DFLAT.LOG", "wt");
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSetCommandToggle(&DfMainMenu, DF_ID_LOG);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
else if (logfile != NULL)
|
|
|
|
{
|
|
|
|
fclose(logfile);
|
|
|
|
logfile = NULL;
|
2003-06-19 02:48:13 +00:00
|
|
|
DfClearCommandToggle(&DfMainMenu, DF_ID_LOG);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-09-03 18:44:19 +00:00
|
|
|
/* EOF */
|