2000-03-05 19:58:08 +00:00
|
|
|
/* ------------- sysmenu.c ------------ */
|
|
|
|
|
|
|
|
#include "dflat.h"
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
int DfSystemMenuProc(DFWINDOW wnd, DFMESSAGE msg, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
int mx, my;
|
|
|
|
DFWINDOW wnd1;
|
|
|
|
switch (msg) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_CREATE_WINDOW:
|
|
|
|
wnd->holdmenu = DfActiveMenuBar;
|
|
|
|
DfActiveMenuBar = &DfSystemMenu;
|
|
|
|
DfSystemMenu.PullDown[0].Selection = 0;
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_LEFT_BUTTON:
|
|
|
|
wnd1 = DfGetParent(wnd);
|
|
|
|
mx = (int) p1 - DfGetLeft(wnd1);
|
|
|
|
my = (int) p2 - DfGetTop(wnd1);
|
|
|
|
if (DfHitControlBox(wnd1, mx, my))
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_LB_CHOOSE:
|
|
|
|
DfPostMessage(wnd, DFM_CLOSE_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
case DOUBLE_CLICK:
|
2003-06-19 02:48:13 +00:00
|
|
|
if (p2 == DfGetTop(DfGetParent(wnd))) {
|
|
|
|
DfPostMessage(DfGetParent(wnd), msg, p1, p2);
|
|
|
|
DfSendMessage(wnd, DFM_CLOSE_WINDOW, TRUE, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_SHIFT_CHANGED:
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_CLOSE_WINDOW:
|
|
|
|
DfActiveMenuBar = wnd->holdmenu;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* ------- Build a system menu -------- */
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfBuildSystemMenu(DFWINDOW wnd)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
int lf, tp, ht, wd;
|
|
|
|
DFWINDOW SystemMenuWnd;
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSystemMenu.PullDown[0].Selections[6].Accelerator =
|
|
|
|
(DfGetClass(wnd) == DF_APPLICATION) ? DF_ALT_F4 : DF_CTRL_F4;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
lf = DfGetLeft(wnd)+1;
|
|
|
|
tp = DfGetTop(wnd)+1;
|
|
|
|
ht = DfMenuHeight(DfSystemMenu.PullDown[0].Selections);
|
|
|
|
wd = DfMenuWidth(DfSystemMenu.PullDown[0].Selections);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
2000-03-08 01:49:37 +00:00
|
|
|
if (lf+wd > DfGetScreenWidth()-1)
|
|
|
|
lf = (DfGetScreenWidth()-1) - wd;
|
|
|
|
if (tp+ht > DfGetScreenHeight()-2)
|
|
|
|
tp = (DfGetScreenHeight()-2) - ht;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
SystemMenuWnd = DfDfCreateWindow(DF_POPDOWNMENU, NULL,
|
|
|
|
lf,tp,ht,wd,NULL,wnd,DfSystemMenuProc, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
#ifdef INCLUDE_RESTORE
|
2003-06-19 02:48:13 +00:00
|
|
|
if (wnd->condition == DF_SRESTORED)
|
|
|
|
DfDeactivateCommand(&DfSystemMenu, DF_ID_SYSRESTORE);
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfActivateCommand(&DfSystemMenu, DF_ID_SYSRESTORE);
|
2000-03-05 19:58:08 +00:00
|
|
|
#endif
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfTestAttribute(wnd, DF_MOVEABLE)
|
2000-03-05 19:58:08 +00:00
|
|
|
#ifdef INCLUDE_MAXIMIZE
|
2003-06-19 02:48:13 +00:00
|
|
|
&& wnd->condition != DF_ISMAXIMIZED
|
2000-03-05 19:58:08 +00:00
|
|
|
#endif
|
|
|
|
)
|
2003-06-19 02:48:13 +00:00
|
|
|
DfActivateCommand(&DfSystemMenu, DF_ID_SYSMOVE);
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfDeactivateCommand(&DfSystemMenu, DF_ID_SYSMOVE);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
if (wnd->condition != DF_SRESTORED ||
|
|
|
|
DfTestAttribute(wnd, DF_SIZEABLE) == FALSE)
|
|
|
|
DfDeactivateCommand(&DfSystemMenu, DF_ID_SYSSIZE);
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfActivateCommand(&DfSystemMenu, DF_ID_SYSSIZE);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
#ifdef INCLUDE_MINIMIZE
|
2003-06-19 02:48:13 +00:00
|
|
|
if (wnd->condition == DF_ISMINIMIZED ||
|
|
|
|
DfTestAttribute(wnd, DF_MINMAXBOX) == FALSE)
|
|
|
|
DfDeactivateCommand(&DfSystemMenu, DF_ID_SYSMINIMIZE);
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfActivateCommand(&DfSystemMenu, DF_ID_SYSMINIMIZE);
|
2000-03-05 19:58:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef INCLUDE_MAXIMIZE
|
2003-06-19 02:48:13 +00:00
|
|
|
if (wnd->condition != DF_SRESTORED ||
|
|
|
|
DfTestAttribute(wnd, DF_MINMAXBOX) == FALSE)
|
|
|
|
DfDeactivateCommand(&DfSystemMenu, DF_ID_SYSMAXIMIZE);
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfActivateCommand(&DfSystemMenu, DF_ID_SYSMAXIMIZE);
|
2000-03-05 19:58:08 +00:00
|
|
|
#endif
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(SystemMenuWnd, DFM_BUILD_SELECTIONS,
|
|
|
|
(DF_PARAM) &DfSystemMenu.PullDown[0], 0);
|
|
|
|
DfSendMessage(SystemMenuWnd, DFM_SETFOCUS, TRUE, 0);
|
|
|
|
DfSendMessage(SystemMenuWnd, DFM_SHOW_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|