📄 applicat.c
字号:
/* ------------- applicat.c ------------- */
#include "dflat32/dflat.h"
static BOOL DisplayModified = FALSE;
DFWINDOW ApplicationWindow;
extern DBOX Display;
extern DBOX Windows;
#ifdef INCLUDE_LOGGING
extern DBOX Log;
#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
/* --------------- CREATE_WINDOW Message -------------- */
static int CreateWindowMsg(DFWINDOW wnd)
{
int rtn;
ApplicationWindow = wnd;
#ifdef INCLUDE_WINDOWOPTIONS
if (cfg.Border)
SetCheckBox(&Display, ID_BORDER);
if (cfg.Title)
SetCheckBox(&Display, ID_TITLE);
if (cfg.StatusBar)
SetCheckBox(&Display, ID_STATUSBAR);
if (cfg.Texture)
SetCheckBox(&Display, ID_TEXTURE);
#endif
SelectColors(wnd);
#ifdef INCLUDE_WINDOWOPTIONS
SelectBorder(wnd);
SelectTitle(wnd);
SelectStatusBar(wnd);
#endif
rtn = BaseWndProc(APPLICATION, wnd, CREATE_WINDOW, 0, 0);
if (wnd->extension != NULL)
DfCreateMenu(wnd);
CreateStatusBar(wnd);
return rtn;
}
/* --------- ADDSTATUS Message ---------- */
static void AddStatusMsg(DFWINDOW wnd, PARAM p1)
{
if (wnd->StatusBar != NULL) {
if (p1 && *(char *)p1)
DfSendMessage(wnd->StatusBar, SETTEXT, p1, 0);
else
DfSendMessage(wnd->StatusBar, CLEARTEXT, 0, 0);
DfSendMessage(wnd->StatusBar, PAINT, 0, 0);
}
}
/* -------- SETFOCUS Message -------- */
static void SetFocusMsg(DFWINDOW wnd, BOOL p1)
{
if (p1)
DfSendMessage(inFocus, SETFOCUS, FALSE, 0);
inFocus = p1 ? wnd : NULL;
if (isVisible(wnd))
DfSendMessage(wnd, BORDER, 0, 0);
else
DfSendMessage(wnd, SHOW_WINDOW, 0, 0);
}
/* ------- SIZE Message -------- */
static void SizeMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
BOOL WasVisible;
WasVisible = isVisible(wnd);
if (WasVisible)
DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
if (p1-GetLeft(wnd) < 30)
p1 = GetLeft(wnd) + 30;
BaseWndProc(APPLICATION, wnd, DFM_SIZE, p1, p2);
DfCreateMenu(wnd);
CreateStatusBar(wnd);
if (WasVisible)
DfSendMessage(wnd, SHOW_WINDOW, 0, 0);
}
/* ----------- KEYBOARD Message ------------ */
static int KeyboardMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
if (WindowMoving || WindowSizing || (int) p1 == F1)
return BaseWndProc(APPLICATION, wnd, KEYBOARD, p1, p2);
switch ((int) p1) {
case ALT_F4:
DfPostMessage(wnd, CLOSE_WINDOW, 0, 0);
return TRUE;
#ifdef INCLUDE_MULTI_WINDOWS
case ALT_F6:
SetNextFocus();
return TRUE;
#endif
case ALT_HYPHEN:
BuildSystemMenu(wnd);
return TRUE;
default:
break;
}
DfPostMessage(wnd->MenuBarWnd, KEYBOARD, p1, p2);
return TRUE;
}
/* --------- SHIFT_CHANGED Message -------- */
static void ShiftChangedMsg(DFWINDOW wnd, PARAM p1)
{
extern BOOL AltDown;
if ((int)p1 & ALTKEY)
AltDown = TRUE;
else if (AltDown) {
AltDown = FALSE;
if (wnd->MenuBarWnd != inFocus)
DfSendMessage(NULL, HIDE_CURSOR, 0, 0);
DfSendMessage(wnd->MenuBarWnd, KEYBOARD, F10, 0);
}
}
/* -------- COMMAND Message ------- */
static void CommandMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
switch ((int)p1) {
case ID_HELP:
DisplayHelp(wnd, DFlatApplication);
break;
case ID_HELPHELP:
DisplayHelp(wnd, "HelpHelp");
break;
case ID_EXTHELP:
DisplayHelp(wnd, "ExtHelp");
break;
case ID_KEYSHELP:
DisplayHelp(wnd, "KeysHelp");
break;
case ID_HELPINDEX:
DisplayHelp(wnd, "HelpIndex");
break;
#ifdef TESTING_DFLAT
case ID_LOADHELP:
LoadHelpFile();
break;
#endif
#ifdef INCLUDE_LOGGING
case ID_LOG:
MessageLog(wnd);
break;
#endif
#ifdef INCLUDE_SHELLDOS
case ID_DOS:
ShellDOS(wnd);
break;
#endif
case ID_EXIT:
case ID_SYSCLOSE:
DfPostMessage(wnd, CLOSE_WINDOW, 0, 0);
break;
case ID_DISPLAY:
if (DfDialogBox(wnd, &Display, TRUE, NULL)) {
if (inFocus == wnd->MenuBarWnd || inFocus == wnd->StatusBar)
oldFocus = ApplicationWindow;
else
oldFocus = inFocus;
DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
SelectColors(wnd);
#ifdef INCLUDE_WINDOWOPTIONS
SelectBorder(wnd);
SelectTitle(wnd);
SelectStatusBar(wnd);
SelectTexture();
#endif
DfCreateMenu(wnd);
CreateStatusBar(wnd);
DfSendMessage(wnd, SHOW_WINDOW, 0, 0);
DfSendMessage(oldFocus, SETFOCUS, TRUE, 0);
}
break;
case ID_SAVEOPTIONS:
SaveConfig();
break;
#ifdef INCLUDE_MULTI_WINDOWS
case ID_WINDOW:
ChooseWindow(wnd, (int)p2-2);
break;
case ID_CLOSEALL:
CloseAll(wnd, FALSE);
break;
case ID_MOREWINDOWS:
MoreWindows(wnd);
break;
#endif
#ifdef INCLUDE_RESTORE
case ID_SYSRESTORE:
#endif
case ID_SYSMOVE:
case ID_SYSSIZE:
#ifdef INCLUDE_MINIMIZE
case ID_SYSMINIMIZE:
#endif
#ifdef INCLUDE_MAXIMIZE
case ID_SYSMAXIMIZE:
#endif
BaseWndProc(APPLICATION, wnd, DFM_COMMAND, p1, p2);
break;
default:
if (inFocus != wnd->MenuBarWnd && inFocus != wnd)
DfPostMessage(inFocus, DFM_COMMAND, p1, p2);
break;
}
}
/* --------- CLOSE_WINDOW Message -------- */
static int CloseWindowMsg(DFWINDOW wnd)
{
int rtn;
#ifdef INCLUDE_MULTI_WINDOWS
CloseAll(wnd, TRUE);
WindowSel = 0;
#endif
DfPostMessage(NULL, DFM_STOP, 0, 0);
rtn = BaseWndProc(APPLICATION, wnd, CLOSE_WINDOW, 0, 0);
UnLoadHelpFile();
DisplayModified = FALSE;
ApplicationWindow = NULL;
return rtn;
}
/* --- APPLICATION Window Class window processing module --- */
int ApplicationProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
switch (msg)
{
case CREATE_WINDOW:
return CreateWindowMsg(wnd);
case DFM_HIDE_WINDOW:
if (wnd == inFocus)
inFocus = NULL;
break;
case ADDSTATUS:
AddStatusMsg(wnd, p1);
return TRUE;
case SETFOCUS:
if ((int)p1 == (inFocus != wnd)) {
SetFocusMsg(wnd, (BOOL) p1);
return TRUE;
}
break;
case DFM_SIZE:
SizeMsg(wnd, p1, p2);
return TRUE;
#ifdef INCLUDE_MINIMIZE
case MINIMIZE:
return TRUE;
#endif
case KEYBOARD:
return KeyboardMsg(wnd, p1, p2);
case SHIFT_CHANGED:
ShiftChangedMsg(wnd, p1);
return TRUE;
case PAINT:
if (isVisible(wnd)) {
#ifdef INCLUDE_WINDOWOPTIONS
int cl = cfg.Texture ? APPLCHAR : ' ';
#else
int cl = APPLCHAR;
#endif
ClearWindow(wnd, (DFRECT *)p1, cl);
}
return TRUE;
case DFM_COMMAND:
CommandMsg(wnd, p1, p2);
return TRUE;
case CLOSE_WINDOW:
return CloseWindowMsg(wnd);
default:
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -