📄 applicat.c
字号:
return TRUE;
case COMMAND:
CommandMsg(wnd, p1, p2);
return TRUE;
case CLOSE_WINDOW:
return CloseWindowMsg(wnd);
default:
break;
}
return BaseWndProc(APPLICATION, wnd, msg, p1, p2);
}
#ifdef INCLUDE_SHELLDOS
static void SwitchCursor(void)
{
SendMessage(NULL, SAVE_CURSOR, 0, 0);
SwapCursorStack();
SendMessage(NULL, RESTORE_CURSOR, 0, 0);
}
/* ------- Shell out to DOS ---------- */
static void ShellDOS(WINDOW wnd)
{
oldFocus=inFocus;
SendMessage(wnd, HIDE_WINDOW, 0, 0);
SwitchCursor();
if (ScreenHeight != SCREENHEIGHT)
SetScreenHeight(ScreenHeight);
SendMessage(NULL, HIDE_MOUSE, 0, 0);
printf("Type EXIT to return to %s.\n\n", DFlatApplication);
fflush(stdout);
spawnl(P_WAIT, getenv("COMSPEC"), NULL);
if (SCREENHEIGHT != cfg.ScreenLines)
SetScreenHeight(cfg.ScreenLines);
SwitchCursor();
SendMessage(wnd, SHOW_WINDOW, 0, 0);
SendMessage(oldFocus, SETFOCUS, TRUE, 0);
SendMessage(NULL, SHOW_MOUSE, 0, 0);
}
#endif
/* -------- Create the menu bar -------- */
static void CreateMenu(WINDOW wnd)
{
AddAttribute(wnd, HASMENUBAR);
if (wnd->MenuBarWnd != NULL)
SendMessage(wnd->MenuBarWnd, CLOSE_WINDOW, 0, 0);
wnd->MenuBarWnd=CreateWindow(MENUBAR, NULL, GetClientLeft(wnd), GetClientTop(wnd)-1, 1, ClientWidth(wnd), NULL, wnd, NULL, 0);
SendMessage(wnd->MenuBarWnd,BUILDMENU, (PARAM)wnd->extension,0);
AddAttribute(wnd->MenuBarWnd, VISIBLE);
}
/* ----------- Create the status bar ------------- */
static void CreateStatusBar(WINDOW wnd)
{
if (wnd->StatusBar != NULL)
{
SendMessage(wnd->StatusBar, CLOSE_WINDOW, 0, 0);
wnd->StatusBar=NULL;
}
if (TestAttribute(wnd, HASSTATUSBAR))
{
wnd->StatusBar=CreateWindow(STATUSBAR, NULL, GetClientLeft(wnd), GetBottom(wnd), 1, ClientWidth(wnd), NULL, wnd, NULL, 0);
AddAttribute(wnd->StatusBar, VISIBLE);
}
}
#ifdef INCLUDE_MULTI_WINDOWS
/* -------- return the name of a document window ------- */
static char *WindowName(WINDOW wnd)
{
if (GetTitle(wnd)==NULL)
{
if (GetClass(wnd)==DIALOG)
return ((DBOX *)(wnd->extension))->HelpName;
else
return "Untitled";
}
else
return GetTitle(wnd);
}
/* ----------- Prepare the Window menu ------------ */
void PrepWindowMenu(void *w, struct Menu *mnu)
{
WINDOW wnd=w,cwnd;
struct PopDown *p0=mnu->Selections;
struct PopDown *pd=mnu->Selections+2;
struct PopDown *ca=mnu->Selections+13;
int MenuNo=0;
mnu->Selection=0;
oldFocus=NULL;
if (GetClass(wnd) != APPLICATION)
{
oldFocus=wnd;
if (ApplicationWindow==NULL) /* Point to the APPLICATION window */
return;
cwnd=FirstWindow(ApplicationWindow);
/* ----- get the first 9 document windows ----- */
while (cwnd != NULL && MenuNo < 9)
{
if (isVisible(cwnd) && GetClass(cwnd) != MENUBAR && GetClass(cwnd) != STATUSBAR)
{
/* 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 -- */
pd->Attrib |= CHECKED;
mnu->Selection=MenuNo+2;
}
else
pd->Attrib &= ~CHECKED;
pd++;
MenuNo++;
}
cwnd=NextWindow(cwnd);
}
}
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 */
static int WindowPrep(WINDOW wnd,MESSAGE msg,PARAM p1,PARAM p2)
{
switch (msg)
{
case INITIATE_DIALOG:
{
WINDOW cwnd=ControlWindow(&Windows,ID_WINDOWLIST),wnd1;
int sel=0;
if (cwnd==NULL)
return FALSE;
wnd1=FirstWindow(ApplicationWindow);
while (wnd1 != NULL)
{
if (isVisible(wnd1) && wnd1 != wnd && GetClass(wnd1) != MENUBAR && GetClass(wnd1) != STATUSBAR)
{
if (wnd1==oldFocus)
WindowSel=sel;
SendMessage(cwnd, ADDTEXT, (PARAM) WindowName(wnd1), 0);
sel++;
}
wnd1=NextWindow(wnd1);
}
SendMessage(cwnd, LB_SETSELECTION, WindowSel, 0);
AddAttribute(cwnd, VSCROLLBAR);
PostMessage(cwnd, SHOW_WINDOW, 0, 0);
break;
}
case COMMAND:
switch ((int) p1)
{
case ID_OK:
if ((int)p2==0)
WindowSel=SendMessage(ControlWindow(&Windows, ID_WINDOWLIST), LB_CURRENTSELECTION, 0, 0);
break;
case ID_WINDOWLIST:
if ((int) p2==LB_CHOOSE)
SendMessage(wnd, COMMAND, ID_OK, 0);
break;
default:
break;
}
break;
default:
break;
}
return DefaultWndProc(wnd, msg, p1, p2);
}
/* ---- the More Windows command on the Window menu ---- */
static void MoreWindows(WINDOW wnd)
{
if (DialogBox(wnd, &Windows, TRUE, WindowPrep))
ChooseWindow(wnd, WindowSel);
}
/* ----- user chose a window from the Window menu or the More Window dialog box ----- */
static void ChooseWindow(WINDOW wnd, int WindowNo)
{
WINDOW cwnd=FirstWindow(wnd);
while (cwnd != NULL)
{
if (isVisible(cwnd) && GetClass(cwnd) != MENUBAR && GetClass(cwnd) != STATUSBAR)
if (WindowNo-- == 0)
break;
cwnd=NextWindow(cwnd);
}
if (cwnd != NULL)
{
SendMessage(cwnd, SETFOCUS, TRUE, 0);
if (cwnd->condition==ISMINIMIZED)
SendMessage(cwnd, RESTORE, 0, 0);
}
}
/* ----- Close all document windows ----- */
static void CloseAll(WINDOW wnd, int closing)
{
WINDOW wnd1, wnd2;
SendMessage(wnd, SETFOCUS, TRUE, 0);
wnd1=LastWindow(wnd);
while (wnd1 != NULL)
{
wnd2=PrevWindow(wnd1);
if (isVisible(wnd1) && GetClass(wnd1) != MENUBAR && GetClass(wnd1) != STATUSBAR)
{
ClearVisible(wnd1);
SendMessage(wnd1, CLOSE_WINDOW, 0, 0);
}
wnd1=wnd2;
}
if (!closing)
SendMessage(wnd, PAINT, 0, 0);
}
#endif /* #ifdef INCLUDE_MULTI_WINDOWS */
static void DoWindowColors(WINDOW wnd)
{
WINDOW cwnd;
InitWindowColors(wnd);
cwnd=FirstWindow(wnd);
while (cwnd != NULL)
{
DoWindowColors(cwnd);
if (GetClass(cwnd)==TEXT && GetText(cwnd) != NULL)
SendMessage(cwnd, CLEARTEXT, 0, 0);
cwnd=NextWindow(cwnd);
}
}
/* ----- set up colors for the application window ------ */
static void SelectColors(WINDOW wnd)
{
if (RadioButtonSetting(&Display, ID_MONO))
cfg.mono=1;
else if (RadioButtonSetting(&Display, ID_REVERSE))
cfg.mono=2;
else
cfg.mono=0;
cfg.snowy=CheckBoxSetting(&Display, ID_SNOWY);
get_videomode();
if ((ismono() || video_mode==2) && cfg.mono==0)
cfg.mono=1;
if (cfg.mono==1)
memcpy(cfg.clr, bw, sizeof bw);
else if (cfg.mono==2)
memcpy(cfg.clr, reverse, sizeof reverse);
else
memcpy(cfg.clr, color, sizeof color);
DoWindowColors(wnd);
}
static void SelectLoadBlank(void)
{
cfg.loadblank=CheckBoxSetting(&Display, ID_LOADBLANK);
}
/* ---- select screen lines ---- */
static void SelectLines(WINDOW wnd)
{
cfg.ScreenLines=25;
if (isEGA() || isVGA())
{
if (RadioButtonSetting(&Display, ID_43LINES))
cfg.ScreenLines=43;
else if (RadioButtonSetting(&Display, ID_50LINES))
cfg.ScreenLines=50;
}
if (SCREENHEIGHT != cfg.ScreenLines)
{
SetScreenHeight(cfg.ScreenLines);
if (wnd->condition==ISMAXIMIZED)
{
SendMessage(wnd, SIZE, (PARAM) GetRight(wnd), SCREENHEIGHT-1);
return;
}
/* --- adjust if current size does not fit --- */
if (WindowHeight(wnd) > SCREENHEIGHT)
SendMessage(wnd, SIZE, (PARAM) GetRight(wnd), (PARAM) GetTop(wnd)+SCREENHEIGHT-1);
/* --- if window is off-screen, move it on-screen --- */
if (GetTop(wnd) >= SCREENHEIGHT-1)
SendMessage(wnd, MOVE, (PARAM) GetLeft(wnd), (PARAM) SCREENHEIGHT-WindowHeight(wnd));
}
}
/* ---- set the screen height in the video hardware ---- */
static void SetScreenHeight(int height)
{
if (isEGA() || isVGA())
{
SendMessage(NULL, SAVE_CURSOR, 0, 0);
switch (height)
{
case 25:
Set25();
break;
case 43:
Set43();
break;
case 50:
Set50();
break;
default:
break;
}
SendMessage(NULL, RESTORE_CURSOR, 0, 0);
SendMessage(NULL, RESET_MOUSE, 0, 0);
SendMessage(NULL, SHOW_MOUSE, 0, 0);
}
}
#ifdef INCLUDE_WINDOWOPTIONS
/* ----- select the screen texture ----- */
static void SelectTexture(void)
{
cfg.Texture=CheckBoxSetting(&Display, ID_TEXTURE);
}
/* -- select whether the application screen has a border -- */
static void SelectBorder(WINDOW wnd)
{
cfg.Border=CheckBoxSetting(&Display, ID_BORDER);
if (cfg.Border)
AddAttribute(wnd, HASBORDER);
else
ClearAttribute(wnd, HASBORDER);
}
/* select whether the application screen has a status bar */
static void SelectStatusBar(WINDOW wnd)
{
cfg.StatusBar=CheckBoxSetting(&Display, ID_STATUSBAR);
if (cfg.StatusBar)
AddAttribute(wnd, HASSTATUSBAR);
else
ClearAttribute(wnd, HASSTATUSBAR);
}
/* select whether the application screen has a title bar */
static void SelectTitle(WINDOW wnd)
{
cfg.Title=CheckBoxSetting(&Display, ID_TITLE);
if (cfg.Title)
AddAttribute(wnd, HASTITLEBAR);
else
ClearAttribute(wnd, HASTITLEBAR);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -