MDI child fixes, new on-mdi-activate method

svn: r1019
This commit is contained in:
Matthew Flatt 2005-10-07 19:11:42 +00:00
parent a596d06517
commit 57f609e539
17 changed files with 247 additions and 33 deletions

View File

@ -520,6 +520,7 @@
on-toolbar-click
on-menu-click
on-menu-command
on-mdi-activate
enforce-size
on-close
on-activate

View File

@ -160,6 +160,7 @@
(lambda (e)
(check-instance '(method frame% on-menu-char) wx:key-event% 'key-event% #f e)
(send wx handle-menu-key e)))]
[on-mdi-activate (lambda (on?) (void))]
[on-toolbar-button-click (lambda () (void))]
[create-status-line (entry-point (lambda () (unless status-line? (send wx create-status-line) (set! status-line? #t))))]
[set-status-text (lambda (s) (send wx set-status-text s))]

View File

@ -628,7 +628,14 @@
[on-toolbar-click
(entry-point
(lambda ()
(as-exit (lambda () (send (wx->mred this) on-toolbar-button-click)))))])
(as-exit (lambda () (send (wx->mred this) on-toolbar-button-click)))))]
[on-mdi-activate
(entry-point
(lambda (on?)
(let ([mr (wx->mred this)])
(queue-window-callback
this
(lambda () (send mr on-mdi-activate on?))))))])
(public
[handle-menu-key
(lambda (event)

View File

@ -235,6 +235,7 @@ static int exit_val = 0;
MrEdContext *mred_contexts;
static MrEdContext *mred_main_context;
static MrEdContext *mred_only_context;
static int only_context_just_once = 0;
static MrEdContext *user_main_context;
static MrEdContextFramesRef mred_frames; /* list of all frames (weak link to invisible ones) */
static wxTimer *mred_timers;
@ -417,9 +418,15 @@ MrEdContext *MrEdGetContext(wxObject *w)
#endif
}
if (mred_only_context)
return mred_only_context;
else
if (mred_only_context) {
if (only_context_just_once) {
MrEdContext *c = mred_only_context;
mred_only_context = NULL;
only_context_just_once = 0;
return c;
} else
return mred_only_context;
} else
return (MrEdContext *)scheme_get_param(scheme_current_config(), mred_eventspace_param);
}
@ -2179,6 +2186,7 @@ void MrEdQueueInEventspace(void *context, Scheme_Object *thunk)
#if REDIRECT_STDIO || WINDOW_STDIO || WCONSOLE_STDIO
static void MrEdSchemeMessages(char *, ...);
static Scheme_Object *stdin_pipe;
#endif
#if WINDOW_STDIO
@ -2376,8 +2384,6 @@ Bool IOMediaEdit::CanDelete(long start, long)
return (start >= ioFrame->endpos);
}
static Scheme_Object *stdin_pipe;
static Bool RecordInput(void *m, wxEvent *event, void *data)
{
char *s;
@ -2439,6 +2445,7 @@ static void MrEdSchemeMessages(char *msg, ...)
else {
/* Set eventspace ... */
mred_only_context = mred_main_context;
only_context_just_once = 1;
ioFrame = new IOFrame;
mred_only_context = NULL;
}
@ -3812,10 +3819,12 @@ void wxDrop_Runtime(char **argv, int argc)
void wxDrop_Quit()
{
#if WINDOW_STDIO
if (ioFrame) {
if (ioFrame->OnClose())
ioFrame->Show(FALSE);
}
#endif
wxDo(wxs_app_quit_proc, 0, NULL);
}

View File

@ -551,6 +551,7 @@ int wx_start_win_event(const char *who, HWND hWnd, UINT message, WPARAM wParam,
switch (message) {
/* These shouldn't happen; reject them if they do! */
case WM_ACTIVATE:
case WM_NCACTIVATE:
case WM_SETFOCUS:
case WM_KILLFOCUS:
case WM_SIZE:

View File

@ -187,6 +187,7 @@ static void DesignateRootFrame(wxFrame *f)
class os_wxFrame : public wxFrame {
public:
@ -201,6 +202,7 @@ class os_wxFrame : public wxFrame {
void OnToolbarButton();
void OnMenuClick();
void OnMenuCommand(ExactLong x0);
void OnMDIActivate(Bool x0);
Bool OnClose();
void OnActivate(Bool x0);
#ifdef MZ_PRECISE_GC
@ -559,6 +561,41 @@ void os_wxFrame::OnMenuCommand(ExactLong x0)
}
}
static Scheme_Object *os_wxFrameOnMDIActivate(int n, Scheme_Object *p[]);
void os_wxFrame::OnMDIActivate(Bool x0)
{
Scheme_Object *p[POFFSET+1] INIT_NULLED_ARRAY({ NULLED_OUT INA_comma NULLED_OUT });
Scheme_Object *v;
Scheme_Object *method INIT_NULLED_OUT;
#ifdef MZ_PRECISE_GC
os_wxFrame *sElF = this;
#endif
static void *mcache = 0;
SETUP_VAR_STACK(5);
VAR_STACK_PUSH(0, method);
VAR_STACK_PUSH(1, sElF);
VAR_STACK_PUSH_ARRAY(2, p, POFFSET+1);
SET_VAR_STACK();
method = objscheme_find_method((Scheme_Object *) ASSELF __gc_external, os_wxFrame_class, "on-mdi-activate", &mcache);
if (!method || OBJSCHEME_PRIM_METHOD(method, os_wxFrameOnMDIActivate)) {
SET_VAR_STACK();
READY_TO_RETURN; ASSELF wxFrame::OnMDIActivate(x0);
} else {
p[POFFSET+0] = (x0 ? scheme_true : scheme_false);
p[0] = (Scheme_Object *) ASSELF __gc_external;
v = WITH_VAR_STACK(scheme_apply(method, POFFSET+1, p));
READY_TO_RETURN;
}
}
static Scheme_Object *os_wxFrameOnClose(int n, Scheme_Object *p[]);
Bool os_wxFrame::OnClose()
@ -859,6 +896,31 @@ static Scheme_Object *os_wxFrameOnMenuCommand(int n, Scheme_Object *p[])
READY_TO_RETURN;
return scheme_void;
}
static Scheme_Object *os_wxFrameOnMDIActivate(int n, Scheme_Object *p[])
{
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
REMEMBER_VAR_STACK();
objscheme_check_valid(os_wxFrame_class, "on-mdi-activate in frame%", n, p);
Bool x0;
SETUP_VAR_STACK_REMEMBERED(1);
VAR_STACK_PUSH(0, p);
x0 = WITH_VAR_STACK(objscheme_unbundle_bool(p[POFFSET+0], "on-mdi-activate in frame%"));
if (((Scheme_Class_Object *)p[0])->primflag)
WITH_VAR_STACK(((os_wxFrame *)((Scheme_Class_Object *)p[0])->primdata)->wxFrame::OnMDIActivate(x0));
else
WITH_VAR_STACK(((wxFrame *)((Scheme_Class_Object *)p[0])->primdata)->OnMDIActivate(x0));
READY_TO_RETURN;
return scheme_void;
}
@ -1321,7 +1383,7 @@ void objscheme_setup_wxFrame(Scheme_Env *env)
wxREGGLOB(os_wxFrame_class);
os_wxFrame_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "frame%", "window%", (Scheme_Method_Prim *)os_wxFrame_ConstructScheme, 25));
os_wxFrame_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "frame%", "window%", (Scheme_Method_Prim *)os_wxFrame_ConstructScheme, 26));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxFrame_class, "on-drop-file" " method", (Scheme_Method_Prim *)os_wxFrameOnDropFile, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxFrame_class, "pre-on-event" " method", (Scheme_Method_Prim *)os_wxFramePreOnEvent, 2, 2));
@ -1332,6 +1394,7 @@ void objscheme_setup_wxFrame(Scheme_Env *env)
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxFrame_class, "on-toolbar-click" " method", (Scheme_Method_Prim *)os_wxFrameOnToolbarButton, 0, 0));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxFrame_class, "on-menu-click" " method", (Scheme_Method_Prim *)os_wxFrameOnMenuClick, 0, 0));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxFrame_class, "on-menu-command" " method", (Scheme_Method_Prim *)os_wxFrameOnMenuCommand, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxFrame_class, "on-mdi-activate" " method", (Scheme_Method_Prim *)os_wxFrameOnMDIActivate, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxFrame_class, "enforce-size" " method", (Scheme_Method_Prim *)os_wxFrameEnforceSize, 6, 6));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxFrame_class, "on-close" " method", (Scheme_Method_Prim *)os_wxFrameOnClose, 0, 0));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxFrame_class, "on-activate" " method", (Scheme_Method_Prim *)os_wxFrameOnActivate, 1, 1));

View File

@ -104,6 +104,8 @@ static void DesignateRootFrame(wxFrame *f)
@SETMARK f = d
@INCLUDE wxs_fram.xci
@ v "on-mdi-activate" : void OnMDIActivate(bool)
@ v "on-menu-command" : void OnMenuCommand(ExactLong)
@ v "on-menu-click" : void OnMenuClick()
@ v "on-toolbar-click" : void OnToolbarButton()

View File

@ -142,6 +142,8 @@ class wxFrame: public wxbFrame
virtual void OnEvent(wxMouseEvent *event);
virtual void OnChar(wxKeyEvent *event);
virtual void OnCommandEvent(wxCommandEvent *event) {};
virtual void OnMDIActivate(Bool flag);
void DragFrame(Point startpt);

View File

@ -1466,3 +1466,7 @@ long wxFrame::GetWindowHandle()
return (long)win;
}
void wxFrame::OnMDIActivate(Bool flag)
{
}

View File

@ -73,6 +73,7 @@ class wxFrame: public wxbFrame
void SetFrameModified(Bool mod);
virtual void OnToolbarButton(void);
virtual void OnMDIActivate(Bool act);
void DrawMenuBar(void);
void SystemMenu(void);

View File

@ -104,6 +104,7 @@ public:
virtual void OnChar(WORD wParam, LPARAM lParam, Bool isASCII = FALSE, Bool isRelease = FALSE);
virtual BOOL OnActivate(BOOL flag, BOOL minimized, HWND activate);
virtual BOOL OnNCActivate(BOOL flag, HWND activate);
virtual BOOL OnMDIActivate(BOOL flag, HWND activate, HWND deactivate);
virtual LONG DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
@ -235,6 +236,7 @@ public:
~wxMDIChild(void);
BOOL OnMDIActivate(BOOL bActivate, HWND, HWND);
BOOL OnNCActivate(BOOL bActivate, HWND);
BOOL OnClose(void);
void OnSize(int x, int y, UINT);
BOOL OnCommand(WORD id, WORD cmd, HWND control);
@ -242,6 +244,7 @@ public:
long Propagate(UINT nMsg, WPARAM wParam, LPARAM lParam);
BOOL ProcessMessage(MSG *msg);
void DestroyWindow(void);
virtual void OnChar(WORD wParam, LPARAM lParam, Bool isASCII = FALSE, Bool isRelease = FALSE);
};
#define wxTYPE_XWND 1

View File

@ -364,7 +364,16 @@ Bool wxFrame::Show(Bool show)
}
tlw = wxTopLevelWindows(this);
tlw->Show(this, show);
if (frame_type != wxMDI_CHILD) {
tlw->Show(this, show);
} else {
wxWindow *p;
p = GetParent();
if (p->IsShown()) {
tlw->Show(this, show);
}
}
if (window_parent) {
wxChildList *cl;
cl = window_parent->GetChildren();
@ -395,11 +404,16 @@ Bool wxFrame::Show(Bool show)
if (frame_type == wxMDI_CHILD) {
wxMDIFrame *cparent;
wxWindow *par;
WINDOWINFO winfo;
par = GetParent();
cparent = (wxMDIFrame *)par->handle;
if (cparent->current_child == (wxFrameWnd *)handle) {
if (cshow == SW_HIDE) {
if (cshow == SW_HIDE) {
if (cparent->current_child == (wxFrameWnd *)handle) {
HMENU new_menu;
HWND next;
cparent->current_child = NULL;
cparent->parent_frame_active = TRUE;
new_menu = ((wxFrame *)par)->GetWinMenu();
@ -415,6 +429,65 @@ Bool wxFrame::Show(Bool show)
(LPARAM)NULL);
::DrawMenuBar(cparent->handle);
OnMDIActivate(FALSE);
GetWindowInfo(cparent->handle, &winfo);
if (winfo.dwWindowStatus == WS_ACTIVECAPTION)
OnActivate(FALSE);
next = GetNextWindow(GetHWND(), GW_HWNDNEXT);
while (next) {
wxWnd *nh;
nh = wxFindWinFromHandle(next);
if (nh && nh->wx_window
&& wxSubType(nh->wx_window->__type, wxTYPE_FRAME)
&& (((wxFrame *)nh->wx_window)->frame_type == wxMDI_CHILD)) {
::SendMessage(cparent->client_hwnd, WM_MDIACTIVATE,
(WPARAM)next,
(LPARAM)NULL);
next = NULL;
} else
next = GetNextWindow(next, GW_HWNDNEXT);
}
}
} else if (cshow != SW_HIDE) {
HWND cur;
cur = (HWND)::SendMessage(cparent->client_hwnd, WM_MDIGETACTIVE, 0, 0);
if (cur == GetHWND()) {
HMENU new_menu;
cparent->current_child = (wxFrameWnd *)handle;
cparent->parent_frame_active = FALSE;
new_menu = GetWinMenu();
if (new_menu) {
::SendMessage(cparent->client_hwnd, WM_MDISETMENU,
(WPARAM)new_menu,
(LPARAM)NULL);
::DrawMenuBar(cparent->handle);
}
OnMDIActivate(TRUE);
GetWindowInfo(cparent->handle, &winfo);
if (winfo.dwWindowStatus == WS_ACTIVECAPTION)
OnActivate(TRUE);
}
}
}
}
if (frame_type == wxMDI_PARENT) {
/* Add/remove shown children in top-level-windows list */
wxChildList *cl;
wxChildNode *cn;
cl = GetChildren();
for (cn = cl->First(); cn; cn = cn->Next()) {
wxWindow *w;
w = (wxWindow *)cn->Data();
if (wxSubType(w->__type, wxTYPE_FRAME)) {
wxFrame *cf;
cf = (wxFrame *)w;
if ((cf->frame_type == wxMDI_CHILD)
&& cf->IsShown()) {
tlw->Show(cf, show);
}
}
}
@ -513,6 +586,10 @@ void wxFrame::OnToolbarButton(void)
{
}
void wxFrame::OnMDIActivate(Bool WXUNUSED(act))
{
}
static wxBitmap *black_bg = NULL;
void wxFrame::SetIcon(wxBitmap *icon, wxBitmap *bg, int kind)
@ -787,6 +864,8 @@ BOOL wxStatusWnd::OnPaint()
::SelectObject(cdc,penShadow) ;
LineTo(cdc, wxTHICK_LINE_BORDER, wxTHICK_LINE_BORDER);
LineTo(cdc, width-wxTHICK_LINE_BORDER, wxTHICK_LINE_BORDER);
#else
old_pen = NULL;
#endif
SetTextColor(cdc, GetSysColor(COLOR_BTNTEXT) );
@ -805,10 +884,10 @@ BOOL wxStatusWnd::OnPaint()
::SelectClipRgn(cdc, NULL);
if (old_pen)
SelectObject(cdc, old_pen);
old_pen = NULL ;
old_pen = NULL;
if (old_brush)
SelectObject(cdc, old_brush);
old_brush = NULL ;
old_brush = NULL;
EndPaint(handle, &ps);
cdc = NULL;
@ -1338,12 +1417,17 @@ BOOL wxMDIChild::OnMDIActivate(BOOL bActivate, HWND WXUNUSED(one), HWND WXUNUSED
cparent = (wxMDIFrame *)parent->handle;
if (bActivate) {
active = TRUE;
cparent->current_child = this;
if (child)
child_menu = child->GetWinMenu();
else
if (child->IsShown()) {
active = TRUE;
cparent->current_child = this;
if (child)
child_menu = child->GetWinMenu();
else
child_menu = NULL;
} else {
cparent->current_child = NULL;
child_menu = NULL;
}
} else {
if (cparent->current_child == this)
cparent->current_child = NULL;
@ -1374,12 +1458,36 @@ BOOL wxMDIChild::OnMDIActivate(BOOL bActivate, HWND WXUNUSED(one), HWND WXUNUSED
(LPARAM)NULL);
::DrawMenuBar(cparent->handle);
wxFrameWnd::OnActivate(bActivate, 0, 0);
if (child->IsShown())
child->OnMDIActivate(bActivate);
return 0;
}
BOOL wxMDIChild::OnNCActivate(BOOL bActivate, HWND WXUNUSED(one))
{
if (wx_window->IsShown())
return wxFrameWnd::OnActivate(bActivate, 0, 0);
else
return 1;
}
void wxMDIChild::OnChar(WORD wParam, LPARAM lParam, Bool isASCII, Bool isRelease)
{
if (!wx_window || wx_window->IsShown())
wxFrameWnd::OnChar(wParam, lParam, isASCII, isRelease);
else {
wxFrame *parent;
wxMDIFrame *cparent;
parent = (wxFrame *)wx_window->GetParent();
cparent = (wxMDIFrame *)parent->handle;
cparent->OnChar(wParam, lParam, isASCII, isRelease);
}
}
wxMDIChild::~wxMDIChild(void)
{
}

View File

@ -196,7 +196,7 @@ int wxWinMain(int wm_is_mred,
#if defined(MZ_PRECISE_GC)
mzscheme_stack_start = (void *)&__gc_var_stack__;
GC_init_type_tags(_scheme_last_type_, scheme_weak_box_type);
GC_init_type_tags(_scheme_last_type_, scheme_weak_box_type, scheme_ephemeron_type);
#endif
scheme_set_stack_base(mzscheme_stack_start, 1);

View File

@ -865,6 +865,13 @@ static LONG WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, in
if (dialog) retval = 0;
break;
}
case WM_NCACTIVATE:
{
WORD state = LOWORD(wParam);
wnd->OnNCActivate(state, hWnd);
retval = wnd->DefWindowProc(message, wParam, lParam);
break;
}
case WM_SETFOCUS:
{
HWND hwnd = (HWND)wParam;
@ -1549,17 +1556,6 @@ BOOL wxWnd::OnActivate(BOOL state, BOOL minimized, HWND WXUNUSED(activate))
wx_window->OnActivate(((state == WA_ACTIVE)
|| (state == WA_CLICKACTIVE)));
// If this window is an MDI parent, we must also send an OnActivate message
// to the current child.
if (wxSubType(wx_window->__type, wxTYPE_FRAME)) {
wxFrame *frame = (wxFrame *)wx_window;
if (frame->frame_type == wxMDI_PARENT) {
wxMDIFrame *mdiFrame = (wxMDIFrame *)this;
if (mdiFrame->current_child) {
mdiFrame->current_child->OnActivate(state, 0, 0);
}
}
}
return 0;
} else
return TRUE;
@ -1668,6 +1664,11 @@ BOOL wxWnd::OnMDIActivate(BOOL WXUNUSED(flag), HWND WXUNUSED(activate), HWND WXU
return 1;
}
BOOL wxWnd::OnNCActivate(BOOL WXUNUSED(flag), HWND WXUNUSED(activate))
{
return 1;
}
void wxWnd::DetachWindowMenu(void)
{
if (hMenu)

View File

@ -295,7 +295,8 @@ ushort wxGIF::get_next_code()
return(x);
byte_buff[i] = x;
}
}
} else
navail_bytes = 1; /* to avoid underflow */
}
b1 = byte_buff[pbytes++];
nbits_left = 8;
@ -318,7 +319,8 @@ ushort wxGIF::get_next_code()
return(x);
byte_buff[i] = x;
}
}
} else
navail_bytes = 1; /* to avoid underflow */
}
b1 = byte_buff[pbytes++];
ret = ret | (b1 << nbits_left);
@ -486,6 +488,8 @@ ushort wxGIF::decoder(ushort linewidth)
*/
while (code >= newcodes)
{
if (sp > MAX_CODES)
return BAD_CODE_SIZE;
stack[sp++] = suffix[code];
code = prefix[code];
if (code >= slot) {
@ -501,6 +505,8 @@ ushort wxGIF::decoder(ushort linewidth)
* suffix and prefix... I'm not certain if this is correct...
* it might be more proper to overwrite the last code...
*/
if (sp > MAX_CODES)
return BAD_CODE_SIZE;
stack[sp++] = code;
if (slot < top_slot)
{

View File

@ -828,3 +828,7 @@ void wxFrame::OnMenuClick()
void wxFrame::OnToolbarButton()
{
}
void wxFrame::OnMDIActivate(Bool WXUNUSED(flag))
{
}

View File

@ -76,6 +76,7 @@ public:
virtual void OnMenuSelect(long id);
virtual void OnMenuClick();
virtual void OnMDIActivate(Bool flag);
virtual void OnToolbarButton();
void SetFrameModified(Bool mod);