2000-03-05 19:58:08 +00:00
|
|
|
/* ------------- applicat.c ------------- */
|
|
|
|
|
|
|
|
#include "dflat.h"
|
|
|
|
|
|
|
|
static BOOL DisplayModified = FALSE;
|
2003-06-19 02:48:13 +00:00
|
|
|
DFWINDOW DfApplicationWindow;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
extern DF_DBOX Display;
|
|
|
|
extern DF_DBOX Windows;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
#ifdef INCLUDE_LOGGING
|
2003-06-19 02:48:13 +00:00
|
|
|
extern DF_DBOX Log;
|
2000-03-05 19:58:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef INCLUDE_SHELLDOS
|
|
|
|
static void ShellDOS(DFWINDOW);
|
|
|
|
#endif
|
|
|
|
static void DfCreateMenu(DFWINDOW);
|
|
|
|
static void CreateStatusBar(DFWINDOW);
|
|
|
|
static void SelectColors(DFWINDOW);
|
|
|
|
|
|
|
|
#ifdef INCLUDE_WINDOWOPTIONS
|
|
|
|
static void SelectTexture(void);
|
|
|
|
static void SelectBorder(DFWINDOW);
|
|
|
|
static void SelectTitle(DFWINDOW);
|
|
|
|
static void SelectStatusBar(DFWINDOW);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static DFWINDOW oldFocus;
|
|
|
|
#ifdef INCLUDE_MULTI_WINDOWS
|
|
|
|
static void CloseAll(DFWINDOW, int);
|
|
|
|
static void MoreWindows(DFWINDOW);
|
|
|
|
static void ChooseWindow(DFWINDOW, int);
|
|
|
|
static int WindowSel;
|
|
|
|
static char Menus[9][26] =
|
|
|
|
{
|
|
|
|
"~1. ",
|
|
|
|
"~2. ",
|
|
|
|
"~3. ",
|
|
|
|
"~4. ",
|
|
|
|
"~5. ",
|
|
|
|
"~6. ",
|
|
|
|
"~7. ",
|
|
|
|
"~8. ",
|
|
|
|
"~9. "
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* --------------- DFM_CREATE_WINDOW Message -------------- */
|
2000-03-05 19:58:08 +00:00
|
|
|
static int CreateWindowMsg(DFWINDOW wnd)
|
|
|
|
{
|
2000-03-08 01:49:37 +00:00
|
|
|
int rtn;
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
DfApplicationWindow = wnd;
|
2000-03-05 19:58:08 +00:00
|
|
|
#ifdef INCLUDE_WINDOWOPTIONS
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfCfg.Border)
|
|
|
|
DfSetCheckBox(&Display, DF_ID_BORDER);
|
|
|
|
if (DfCfg.Title)
|
|
|
|
DfSetCheckBox(&Display, DF_ID_TITLE);
|
|
|
|
if (DfCfg.StatusBar)
|
|
|
|
DfSetCheckBox(&Display, DF_ID_STATUSBAR);
|
|
|
|
if (DfCfg.Texture)
|
|
|
|
DfSetCheckBox(&Display, DF_ID_TEXTURE);
|
2000-03-05 19:58:08 +00:00
|
|
|
#endif
|
|
|
|
SelectColors(wnd);
|
|
|
|
#ifdef INCLUDE_WINDOWOPTIONS
|
|
|
|
SelectBorder(wnd);
|
|
|
|
SelectTitle(wnd);
|
|
|
|
SelectStatusBar(wnd);
|
|
|
|
#endif
|
2003-06-19 02:48:13 +00:00
|
|
|
rtn = DfBaseWndProc(DF_APPLICATION, wnd, DFM_CREATE_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (wnd->extension != NULL)
|
|
|
|
DfCreateMenu(wnd);
|
|
|
|
CreateStatusBar(wnd);
|
|
|
|
return rtn;
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* --------- DFM_ADDSTATUS Message ---------- */
|
|
|
|
static void AddStatusMsg(DFWINDOW wnd, DF_PARAM p1)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
if (wnd->StatusBar != NULL) {
|
|
|
|
if (p1 && *(char *)p1)
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd->StatusBar, DFM_SETTEXT, p1, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd->StatusBar, DFM_CLEARTEXT, 0, 0);
|
|
|
|
DfSendMessage(wnd->StatusBar, DFM_PAINT, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* -------- DFM_SETFOCUS Message -------- */
|
2000-03-05 19:58:08 +00:00
|
|
|
static void SetFocusMsg(DFWINDOW wnd, BOOL p1)
|
|
|
|
{
|
|
|
|
if (p1)
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(DfInFocus, DFM_SETFOCUS, FALSE, 0);
|
|
|
|
DfInFocus = p1 ? wnd : NULL;
|
|
|
|
if (DfIsVisible(wnd))
|
|
|
|
DfSendMessage(wnd, DFM_BORDER, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd, DFM_SHOW_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------- SIZE Message -------- */
|
2003-06-19 02:48:13 +00:00
|
|
|
static void SizeMsg(DFWINDOW wnd, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
BOOL WasVisible;
|
2003-06-19 02:48:13 +00:00
|
|
|
WasVisible = DfIsVisible(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (WasVisible)
|
|
|
|
DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
|
2003-06-19 02:48:13 +00:00
|
|
|
if (p1-DfGetLeft(wnd) < 30)
|
|
|
|
p1 = DfGetLeft(wnd) + 30;
|
|
|
|
DfBaseWndProc(DF_APPLICATION, wnd, DFM_DFM_SIZE, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
DfCreateMenu(wnd);
|
|
|
|
CreateStatusBar(wnd);
|
|
|
|
if (WasVisible)
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd, DFM_SHOW_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* ----------- DFM_KEYBOARD Message ------------ */
|
|
|
|
static int KeyboardMsg(DFWINDOW wnd, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfWindowMoving || DfWindowSizing || (int) p1 == DF_F1)
|
|
|
|
return DfBaseWndProc(DF_APPLICATION, wnd, DFM_KEYBOARD, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
switch ((int) p1) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ALT_F4:
|
|
|
|
DfPostMessage(wnd, DFM_CLOSE_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
#ifdef INCLUDE_MULTI_WINDOWS
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ALT_F6:
|
|
|
|
DfSetNextFocus();
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
#endif
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ALT_HYPHEN:
|
|
|
|
DfBuildSystemMenu(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
DfPostMessage(wnd->MenuBarWnd, DFM_KEYBOARD, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* --------- DFM_SHIFT_CHANGED Message -------- */
|
|
|
|
static void ShiftChangedMsg(DFWINDOW wnd, DF_PARAM p1)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
extern BOOL AltDown;
|
2003-06-19 02:48:13 +00:00
|
|
|
if ((int)p1 & DF_ALTKEY)
|
2000-03-05 19:58:08 +00:00
|
|
|
AltDown = TRUE;
|
|
|
|
else if (AltDown) {
|
|
|
|
AltDown = FALSE;
|
2003-06-19 02:48:13 +00:00
|
|
|
if (wnd->MenuBarWnd != DfInFocus)
|
|
|
|
DfSendMessage(NULL, DFM_HIDE_CURSOR, 0, 0);
|
|
|
|
DfSendMessage(wnd->MenuBarWnd, DFM_KEYBOARD, DF_F10, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------- COMMAND Message ------- */
|
2003-06-19 02:48:13 +00:00
|
|
|
static void CommandMsg(DFWINDOW wnd, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
switch ((int)p1) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_HELP:
|
|
|
|
DfDisplayHelp(wnd, DFlatApplication);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_HELPHELP:
|
|
|
|
DfDisplayHelp(wnd, "HelpHelp");
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_EXTHELP:
|
|
|
|
DfDisplayHelp(wnd, "ExtHelp");
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_KEYSHELP:
|
|
|
|
DfDisplayHelp(wnd, "KeysHelp");
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_HELPINDEX:
|
|
|
|
DfDisplayHelp(wnd, "HelpIndex");
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
#ifdef TESTING_DFLAT
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_LOADHELP:
|
|
|
|
DfLoadHelpFile();
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef INCLUDE_LOGGING
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_LOG:
|
|
|
|
DfMessageLog(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef INCLUDE_SHELLDOS
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_DOS:
|
2000-03-05 19:58:08 +00:00
|
|
|
ShellDOS(wnd);
|
|
|
|
break;
|
|
|
|
#endif
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_EXIT:
|
|
|
|
case DF_ID_SYSCLOSE:
|
|
|
|
DfPostMessage(wnd, DFM_CLOSE_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_DISPLAY:
|
2000-03-05 19:58:08 +00:00
|
|
|
if (DfDialogBox(wnd, &Display, TRUE, NULL)) {
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfInFocus == wnd->MenuBarWnd || DfInFocus == wnd->StatusBar)
|
|
|
|
oldFocus = DfApplicationWindow;
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
oldFocus = DfInFocus;
|
2000-03-05 19:58:08 +00:00
|
|
|
DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
|
|
|
|
SelectColors(wnd);
|
|
|
|
#ifdef INCLUDE_WINDOWOPTIONS
|
|
|
|
SelectBorder(wnd);
|
|
|
|
SelectTitle(wnd);
|
|
|
|
SelectStatusBar(wnd);
|
|
|
|
SelectTexture();
|
|
|
|
#endif
|
|
|
|
DfCreateMenu(wnd);
|
|
|
|
CreateStatusBar(wnd);
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd, DFM_SHOW_WINDOW, 0, 0);
|
|
|
|
DfSendMessage(oldFocus, DFM_SETFOCUS, TRUE, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_SAVEOPTIONS:
|
|
|
|
DfSaveConfig();
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
#ifdef INCLUDE_MULTI_WINDOWS
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_WINDOW:
|
2000-03-05 19:58:08 +00:00
|
|
|
ChooseWindow(wnd, (int)p2-2);
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_CLOSEALL:
|
2000-03-05 19:58:08 +00:00
|
|
|
CloseAll(wnd, FALSE);
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_MOREWINDOWS:
|
2000-03-05 19:58:08 +00:00
|
|
|
MoreWindows(wnd);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef INCLUDE_RESTORE
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_SYSRESTORE:
|
2000-03-05 19:58:08 +00:00
|
|
|
#endif
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_SYSMOVE:
|
|
|
|
case DF_ID_SYSSIZE:
|
2000-03-05 19:58:08 +00:00
|
|
|
#ifdef INCLUDE_MINIMIZE
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_SYSMINIMIZE:
|
2000-03-05 19:58:08 +00:00
|
|
|
#endif
|
|
|
|
#ifdef INCLUDE_MAXIMIZE
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_SYSMAXIMIZE:
|
2000-03-05 19:58:08 +00:00
|
|
|
#endif
|
2003-06-19 02:48:13 +00:00
|
|
|
DfBaseWndProc(DF_APPLICATION, wnd, DFM_COMMAND, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
default:
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfInFocus != wnd->MenuBarWnd && DfInFocus != wnd)
|
|
|
|
DfPostMessage(DfInFocus, DFM_COMMAND, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* --------- DFM_CLOSE_WINDOW Message -------- */
|
2000-03-05 19:58:08 +00:00
|
|
|
static int CloseWindowMsg(DFWINDOW wnd)
|
|
|
|
{
|
|
|
|
int rtn;
|
|
|
|
#ifdef INCLUDE_MULTI_WINDOWS
|
|
|
|
CloseAll(wnd, TRUE);
|
|
|
|
WindowSel = 0;
|
|
|
|
#endif
|
|
|
|
DfPostMessage(NULL, DFM_STOP, 0, 0);
|
2003-06-19 02:48:13 +00:00
|
|
|
rtn = DfBaseWndProc(DF_APPLICATION, wnd, DFM_CLOSE_WINDOW, 0, 0);
|
|
|
|
DfUnLoadHelpFile();
|
2000-03-05 19:58:08 +00:00
|
|
|
DisplayModified = FALSE;
|
2003-06-19 02:48:13 +00:00
|
|
|
DfApplicationWindow = NULL;
|
2000-03-05 19:58:08 +00:00
|
|
|
return rtn;
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* --- DF_APPLICATION Window Class window processing module --- */
|
|
|
|
int DfApplicationProc(DFWINDOW wnd, DFMESSAGE msg, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_CREATE_WINDOW:
|
2000-03-05 19:58:08 +00:00
|
|
|
return CreateWindowMsg(wnd);
|
|
|
|
case DFM_HIDE_WINDOW:
|
2003-06-19 02:48:13 +00:00
|
|
|
if (wnd == DfInFocus)
|
|
|
|
DfInFocus = NULL;
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_ADDSTATUS:
|
2000-03-05 19:58:08 +00:00
|
|
|
AddStatusMsg(wnd, p1);
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_SETFOCUS:
|
|
|
|
if ((int)p1 == (DfInFocus != wnd)) {
|
2000-03-05 19:58:08 +00:00
|
|
|
SetFocusMsg(wnd, (BOOL) p1);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_DFM_SIZE:
|
2000-03-05 19:58:08 +00:00
|
|
|
SizeMsg(wnd, p1, p2);
|
|
|
|
return TRUE;
|
|
|
|
#ifdef INCLUDE_MINIMIZE
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_MINIMIZE:
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
#endif
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_KEYBOARD:
|
2000-03-05 19:58:08 +00:00
|
|
|
return KeyboardMsg(wnd, p1, p2);
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_SHIFT_CHANGED:
|
2000-03-05 19:58:08 +00:00
|
|
|
ShiftChangedMsg(wnd, p1);
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_PAINT:
|
|
|
|
if (DfIsVisible(wnd)) {
|
2000-03-05 19:58:08 +00:00
|
|
|
#ifdef INCLUDE_WINDOWOPTIONS
|
2003-06-19 02:48:13 +00:00
|
|
|
int cl = DfCfg.Texture ? DF_APPLCHAR : ' ';
|
2000-03-05 19:58:08 +00:00
|
|
|
#else
|
2003-06-19 02:48:13 +00:00
|
|
|
int cl = DF_APPLCHAR;
|
2000-03-05 19:58:08 +00:00
|
|
|
#endif
|
2003-06-19 02:48:13 +00:00
|
|
|
DfClearWindow(wnd, (DFRECT *)p1, cl);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
case DFM_COMMAND:
|
|
|
|
CommandMsg(wnd, p1, p2);
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_CLOSE_WINDOW:
|
2000-03-05 19:58:08 +00:00
|
|
|
return CloseWindowMsg(wnd);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
return DfBaseWndProc(DF_APPLICATION, wnd, msg, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef INCLUDE_SHELLDOS
|
|
|
|
static void SwitchCursor(void)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(NULL, DFM_SAVE_CURSOR, 0, 0);
|
|
|
|
DfSwapCursorStack();
|
|
|
|
DfSendMessage(NULL, DFM_RESTORE_CURSOR, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------- Shell out to DOS ---------- */
|
|
|
|
static void ShellDOS(DFWINDOW wnd)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
oldFocus = DfInFocus;
|
2000-03-05 19:58:08 +00:00
|
|
|
DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
|
|
|
|
SwitchCursor();
|
|
|
|
printf("To return to %s, execute the DOS exit command.",
|
|
|
|
DFlatApplication);
|
|
|
|
fflush(stdout);
|
|
|
|
_spawnl(P_WAIT, getenv("COMSPEC"), " ", NULL);
|
|
|
|
SwitchCursor();
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd, DFM_SHOW_WINDOW, 0, 0);
|
|
|
|
DfSendMessage(oldFocus, DFM_SETFOCUS, TRUE, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* -------- Create the menu bar -------- */
|
|
|
|
static void DfCreateMenu(DFWINDOW wnd)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DfAddAttribute(wnd, DF_HASMENUBAR);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (wnd->MenuBarWnd != NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd->MenuBarWnd, DFM_CLOSE_WINDOW, 0, 0);
|
|
|
|
wnd->MenuBarWnd = DfDfCreateWindow(DF_MENUBAR,
|
2000-03-05 19:58:08 +00:00
|
|
|
NULL,
|
2003-06-19 02:48:13 +00:00
|
|
|
DfGetClientLeft(wnd),
|
|
|
|
DfGetClientTop(wnd)-1,
|
2000-03-05 19:58:08 +00:00
|
|
|
1,
|
2003-06-19 02:48:13 +00:00
|
|
|
DfClientWidth(wnd),
|
2000-03-05 19:58:08 +00:00
|
|
|
NULL,
|
|
|
|
wnd,
|
|
|
|
NULL,
|
|
|
|
0);
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd->MenuBarWnd,DFM_BUILDMENU,
|
|
|
|
(DF_PARAM)wnd->extension,0);
|
|
|
|
DfAddAttribute(wnd->MenuBarWnd, DF_VISIBLE);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------- Create the status bar ------------- */
|
|
|
|
static void CreateStatusBar(DFWINDOW wnd)
|
|
|
|
{
|
|
|
|
if (wnd->StatusBar != NULL) {
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd->StatusBar, DFM_CLOSE_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
wnd->StatusBar = NULL;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfTestAttribute(wnd, DF_HASSTATUSBAR)) {
|
|
|
|
wnd->StatusBar = DfDfCreateWindow(DF_STATUSBAR,
|
2000-03-05 19:58:08 +00:00
|
|
|
NULL,
|
2003-06-19 02:48:13 +00:00
|
|
|
DfGetClientLeft(wnd),
|
|
|
|
DfGetBottom(wnd),
|
2000-03-05 19:58:08 +00:00
|
|
|
1,
|
2003-06-19 02:48:13 +00:00
|
|
|
DfClientWidth(wnd),
|
2000-03-05 19:58:08 +00:00
|
|
|
NULL,
|
|
|
|
wnd,
|
|
|
|
NULL,
|
|
|
|
0);
|
2003-06-19 02:48:13 +00:00
|
|
|
DfAddAttribute(wnd->StatusBar, DF_VISIBLE);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef INCLUDE_MULTI_WINDOWS
|
|
|
|
/* -------- return the name of a document window ------- */
|
|
|
|
static char *WindowName(DFWINDOW wnd)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfGetTitle(wnd) == NULL)
|
2000-03-08 01:49:37 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfGetClass(wnd) == DF_DIALOG)
|
|
|
|
return ((DF_DBOX *)(wnd->extension))->HelpName;
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
|
|
|
return "Untitled";
|
|
|
|
}
|
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
return DfGetTitle(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------- Prepare the Window menu ------------ */
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfPrepWindowMenu(void *w, struct DfMenu *mnu)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
DFWINDOW wnd = w;
|
2003-06-19 02:48:13 +00:00
|
|
|
struct DfPopDown *p0 = mnu->Selections;
|
|
|
|
struct DfPopDown *pd = mnu->Selections + 2;
|
|
|
|
struct DfPopDown *ca = mnu->Selections + 13;
|
2000-03-05 19:58:08 +00:00
|
|
|
int MenuNo = 0;
|
|
|
|
DFWINDOW cwnd;
|
|
|
|
|
|
|
|
mnu->Selection = 0;
|
|
|
|
oldFocus = NULL;
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfGetClass(wnd) != DF_APPLICATION)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
oldFocus = wnd;
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* point to the DF_APPLICATION window */
|
|
|
|
if (DfApplicationWindow == NULL)
|
2000-03-05 19:58:08 +00:00
|
|
|
return;
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
cwnd = DfFirstWindow(DfApplicationWindow);
|
2000-03-05 19:58:08 +00:00
|
|
|
/* get the first 9 document windows */
|
|
|
|
while (cwnd != NULL && MenuNo < 9)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfGetClass(cwnd) != DF_MENUBAR &&
|
|
|
|
DfGetClass(cwnd) != DF_STATUSBAR)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
/* add the document window to the menu */
|
|
|
|
strncpy (Menus[MenuNo]+4, WindowName(cwnd), 20);
|
|
|
|
pd->SelectionTitle = Menus[MenuNo];
|
|
|
|
if (cwnd == oldFocus)
|
|
|
|
{
|
|
|
|
/* mark the current document */
|
2003-06-19 02:48:13 +00:00
|
|
|
pd->Attrib |= DF_CHECKED;
|
2000-03-05 19:58:08 +00:00
|
|
|
mnu->Selection = MenuNo+2;
|
|
|
|
}
|
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
pd->Attrib &= ~DF_CHECKED;
|
2000-03-05 19:58:08 +00:00
|
|
|
pd++;
|
|
|
|
MenuNo++;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
cwnd = DfNextWindow(cwnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MenuNo)
|
|
|
|
p0->SelectionTitle = "~Close all";
|
|
|
|
else
|
|
|
|
p0->SelectionTitle = NULL;
|
|
|
|
|
|
|
|
if (MenuNo >= 9)
|
|
|
|
{
|
|
|
|
*pd++ = *ca;
|
|
|
|
if (mnu->Selection == 0)
|
|
|
|
mnu->Selection = 11;
|
|
|
|
}
|
|
|
|
pd->SelectionTitle = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* window processing module for the More Windows dialog box */
|
2003-06-19 02:48:13 +00:00
|
|
|
static int WindowPrep(DFWINDOW wnd,DFMESSAGE msg,DF_PARAM p1,DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
switch (msg) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_INITIATE_DIALOG: {
|
2000-03-05 19:58:08 +00:00
|
|
|
DFWINDOW wnd1;
|
2003-06-19 02:48:13 +00:00
|
|
|
DFWINDOW cwnd = DfControlWindow(&Windows,DF_ID_WINDOWLIST);
|
2000-03-05 19:58:08 +00:00
|
|
|
int sel = 0;
|
|
|
|
if (cwnd == NULL)
|
|
|
|
return FALSE;
|
2003-06-19 02:48:13 +00:00
|
|
|
wnd1 = DfFirstWindow(DfApplicationWindow);
|
2000-03-05 19:58:08 +00:00
|
|
|
while (wnd1 != NULL) {
|
2003-06-19 02:48:13 +00:00
|
|
|
if (wnd1 != wnd && DfGetClass(wnd1) != DF_MENUBAR &&
|
|
|
|
DfGetClass(wnd1) != DF_STATUSBAR) {
|
2000-03-05 19:58:08 +00:00
|
|
|
if (wnd1 == oldFocus)
|
|
|
|
WindowSel = sel;
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(cwnd, DFM_ADDTEXT,
|
|
|
|
(DF_PARAM) WindowName(wnd1), 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
sel++;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
wnd1 = DfNextWindow(wnd1);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(cwnd, DFM_LB_SETSELECTION, WindowSel, 0);
|
|
|
|
DfAddAttribute(cwnd, DF_VSCROLLBAR);
|
|
|
|
DfPostMessage(cwnd, DFM_SHOW_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DFM_COMMAND:
|
|
|
|
switch ((int) p1) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_OK:
|
2000-03-05 19:58:08 +00:00
|
|
|
if ((int)p2 == 0)
|
|
|
|
WindowSel = DfSendMessage(
|
2003-06-19 02:48:13 +00:00
|
|
|
DfControlWindow(&Windows,
|
|
|
|
DF_ID_WINDOWLIST),
|
|
|
|
DFM_LB_CURRENTSELECTION, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_WINDOWLIST:
|
|
|
|
if ((int) p2 == DFM_LB_CHOOSE)
|
|
|
|
DfSendMessage(wnd, DFM_COMMAND, DF_ID_OK, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* ---- the More Windows command on the Window menu ---- */
|
|
|
|
static void MoreWindows(DFWINDOW wnd)
|
|
|
|
{
|
|
|
|
if (DfDialogBox(wnd, &Windows, TRUE, WindowPrep))
|
|
|
|
ChooseWindow(wnd, WindowSel);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----- user chose a window from the Window menu
|
|
|
|
or the More Window dialog box ----- */
|
|
|
|
static void ChooseWindow(DFWINDOW wnd, int WindowNo)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DFWINDOW cwnd = DfFirstWindow(wnd);
|
2000-03-08 01:49:37 +00:00
|
|
|
while (cwnd != NULL)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfGetClass(cwnd) != DF_MENUBAR &&
|
|
|
|
DfGetClass(cwnd) != DF_STATUSBAR)
|
2000-03-05 19:58:08 +00:00
|
|
|
if (WindowNo-- == 0)
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
cwnd = DfNextWindow(cwnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
if (cwnd != NULL) {
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(cwnd, DFM_SETFOCUS, TRUE, 0);
|
|
|
|
if (cwnd->condition == DF_ISMINIMIZED)
|
|
|
|
DfSendMessage(cwnd, DFM_RESTORE, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----- Close all document windows ----- */
|
|
|
|
static void CloseAll(DFWINDOW wnd, int closing)
|
|
|
|
{
|
|
|
|
DFWINDOW wnd1, wnd2;
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd, DFM_SETFOCUS, TRUE, 0);
|
|
|
|
wnd1 = DfLastWindow(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
while (wnd1 != NULL)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
wnd2 = DfPrevWindow(wnd1);
|
|
|
|
if (DfGetClass(wnd1) != DF_MENUBAR && DfGetClass(wnd1) != DF_STATUSBAR)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DfClearVisible(wnd1);
|
|
|
|
DfSendMessage(wnd1, DFM_CLOSE_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
wnd1 = wnd2;
|
|
|
|
}
|
|
|
|
if (!closing)
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd, DFM_PAINT, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* #ifdef INCLUDE_MULTI_WINDOWS */
|
|
|
|
|
|
|
|
static void DoWindowColors(DFWINDOW wnd)
|
|
|
|
{
|
|
|
|
DFWINDOW cwnd;
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
DfInitWindowColors(wnd);
|
|
|
|
cwnd = DfFirstWindow(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
while (cwnd != NULL)
|
|
|
|
{
|
|
|
|
DoWindowColors(cwnd);
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfGetClass(cwnd) == DF_TEXT && DfGetText(cwnd) != NULL)
|
|
|
|
DfSendMessage(cwnd, DFM_CLEARTEXT, 0, 0);
|
|
|
|
cwnd = DfNextWindow(cwnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set up colors for the application window */
|
|
|
|
static void SelectColors(DFWINDOW wnd)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
memcpy(DfCfg.clr, DfColor, sizeof DfColor);
|
2000-03-05 19:58:08 +00:00
|
|
|
DoWindowColors(wnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef INCLUDE_WINDOWOPTIONS
|
|
|
|
|
|
|
|
/* ----- select the screen texture ----- */
|
|
|
|
static void SelectTexture(void)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DfCfg.Texture = DfCheckBoxSetting(&Display, DF_ID_TEXTURE);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -- select whether the application screen has a border -- */
|
|
|
|
static void SelectBorder(DFWINDOW wnd)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DfCfg.Border = DfCheckBoxSetting(&Display, DF_ID_BORDER);
|
|
|
|
if (DfCfg.Border)
|
|
|
|
DfAddAttribute(wnd, DF_HASBORDER);
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfClearAttribute(wnd, DF_HASBORDER);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* select whether the application screen has a status bar */
|
|
|
|
static void SelectStatusBar(DFWINDOW wnd)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DfCfg.StatusBar = DfCheckBoxSetting(&Display, DF_ID_STATUSBAR);
|
|
|
|
if (DfCfg.StatusBar)
|
|
|
|
DfAddAttribute(wnd, DF_HASSTATUSBAR);
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfClearAttribute(wnd, DF_HASSTATUSBAR);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* select whether the application screen has a title bar */
|
|
|
|
static void SelectTitle(DFWINDOW wnd)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DfCfg.Title = DfCheckBoxSetting(&Display, DF_ID_TITLE);
|
|
|
|
if (DfCfg.Title)
|
|
|
|
DfAddAttribute(wnd, DF_HASTITLEBAR);
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfClearAttribute(wnd, DF_HASTITLEBAR);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* EOF */
|