From c763ca72e307a3c21c6221848e4e42f1dbefb3c7 Mon Sep 17 00:00:00 2001 From: chengyemao Date: Fri, 7 Jan 2005 15:18:02 +0000 Subject: Implemented TK_STAT message to support {wm state} for embedded window --- generic/tkIntPlatDecls.h | 12 ++++++++- generic/tkStubInit.c | 3 ++- win/tkWin.h | 3 ++- win/tkWinEmbed.c | 14 +++++++++- win/tkWinWm.c | 67 +++++++++++++++++++++++++++++++++++++++++++----- win/tkWinX.c | 3 ++- 6 files changed, 91 insertions(+), 11 deletions(-) diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h index 294a5af..aa27eb1 100644 --- a/generic/tkIntPlatDecls.h +++ b/generic/tkIntPlatDecls.h @@ -9,7 +9,7 @@ * Copyright (c) 1998-1999 by Scriptics Corporation. * All rights reserved. * - * RCS: @(#) $Id: tkIntPlatDecls.h,v 1.20 2004/12/17 14:30:45 chengyemao Exp $ + * RCS: @(#) $Id: tkIntPlatDecls.h,v 1.21 2005/01/07 15:18:02 chengyemao Exp $ */ #ifndef _TKINTPLATDECLS @@ -235,6 +235,11 @@ EXTERN int TkWinGetPlatformTheme _ANSI_ARGS_((void)); /* 36 */ EXTERN void TkWinCleanupContainerList _ANSI_ARGS_((void)); #endif +#ifndef TkpWmGetState_TCL_DECLARED +#define TkpWmGetState_TCL_DECLARED +/* 37 */ +EXTERN int TkpWmGetState _ANSI_ARGS_((TkWindow * winPtr)); +#endif #endif /* __WIN32__ */ #ifdef MAC_OSX_TK #ifndef TkGenerateActivateEvents_TCL_DECLARED @@ -617,6 +622,7 @@ typedef struct TkIntPlatStubs { void (*tkWinSetHINSTANCE) _ANSI_ARGS_((HINSTANCE hInstance)); /* 34 */ int (*tkWinGetPlatformTheme) _ANSI_ARGS_((void)); /* 35 */ void (*tkWinCleanupContainerList) _ANSI_ARGS_((void)); /* 36 */ + int (*tkpWmGetState) _ANSI_ARGS_((TkWindow * winPtr)); /* 36 */ #endif /* __WIN32__ */ #ifdef MAC_OSX_TK void (*tkGenerateActivateEvents) _ANSI_ARGS_((TkWindow * winPtr, int active)); /* 0 */ @@ -851,6 +857,10 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkWinCleanupContainerList \ (tkIntPlatStubsPtr->tkWinCleanupContainerList) /* 36 */ #endif +#ifndef TkpWmGetState +#define TkpWmGetState \ + (tkIntPlatStubsPtr->tkpWmGetState) /* 37 */ +#endif #endif /* __WIN32__ */ #ifdef MAC_OSX_TK #ifndef TkGenerateActivateEvents diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index fe27b33..0b81411 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkStubInit.c,v 1.48 2004/12/28 08:44:48 chengyemao Exp $ + * RCS: @(#) $Id: tkStubInit.c,v 1.49 2005/01/07 15:18:03 chengyemao Exp $ */ #include "tkInt.h" @@ -337,6 +337,7 @@ TkIntPlatStubs tkIntPlatStubs = { TkWinSetHINSTANCE, /* 34 */ TkWinGetPlatformTheme, /* 35 */ TkWinCleanupContainerList, /* 36 */ + TkpWmGetState, /* 37 */ #endif /* __WIN32__ */ #ifdef MAC_OSX_TK TkGenerateActivateEvents, /* 0 */ diff --git a/win/tkWin.h b/win/tkWin.h index c8eca7f..6df0144 100644 --- a/win/tkWin.h +++ b/win/tkWin.h @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWin.h,v 1.11 2004/12/28 08:45:31 chengyemao Exp $ + * RCS: @(#) $Id: tkWin.h,v 1.12 2005/01/07 15:18:03 chengyemao Exp $ */ #ifndef _TKWIN @@ -49,6 +49,7 @@ #define TK_GETFRAMEWID (WM_USER+9) /* an embedded window requests a frame window id */ #define TK_OVERRIDEREDIRECT (WM_USER+10) /* an embedded window requests to overrideredirect */ #define TK_SETMENU (WM_USER+11) /* an embedded window requests to setup menu */ +#define TK_STATE (WM_USER+12) /* an embedded window sets/gets state */ /* *-------------------------------------------------------------- diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index 3a0ccfd..470140b 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinEmbed.c,v 1.18 2005/01/07 01:39:24 chengyemao Exp $ + * RCS: @(#) $Id: tkWinEmbed.c,v 1.19 2005/01/07 15:18:03 chengyemao Exp $ */ #include "tkWinInt.h" @@ -484,6 +484,18 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam) result = 1; break; + case TK_STATE: + /* + * 0 - normal state + * 1 - withdrawn state + * 2 - zoom state + * 3 - icon state + */ + if(wParam >= 0 && wParam <= 3) { + TkpWmSetState(containerPtr->parentPtr, wParam); + } + result = TkpWmGetState(containerPtr->parentPtr); + break; /* * Return 0 since the current Tk container implementation * is unable to provide following services. diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 3f0d4f8..7593863 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinWm.c,v 1.87 2005/01/04 02:09:46 chengyemao Exp $ + * RCS: @(#) $Id: tkWinWm.c,v 1.88 2005/01/07 15:18:03 chengyemao Exp $ */ #include "tkWinInt.h" @@ -2204,6 +2204,7 @@ UpdateWrapper(winPtr) { SendMessage(wmPtr->wrapper, TK_GEOMETRYREQ, Tk_ReqWidth((Tk_Window)winPtr), Tk_ReqHeight((Tk_Window)winPtr)); + SendMessage(wmPtr->wrapper, TK_SETMENU, (WPARAM)wmPtr->hMenu, 0); } } @@ -2431,6 +2432,28 @@ TkpWmSetState(winPtr, state) } /* + *---------------------------------------------------------------------- + * + * TkpWinGetState -- + * + * This function returns state value of a toplevel window. + * + * Results: + * none + * + * Side effects: + * May deiconify the toplevel window. + * + *---------------------------------------------------------------------- + */ + +int TkpWmGetState(winPtr) + TkWindow *winPtr; +{ + return winPtr->wmInfoPtr->hints.initial_state; +} + +/* *-------------------------------------------------------------- * * TkWmDeadWindow -- @@ -4791,10 +4814,8 @@ WmStateCmd(tkwin, winPtr, interp, objc, objv) (char *) NULL); return TCL_ERROR; } - if (winPtr->flags & TK_EMBEDDED) { - Tcl_AppendResult(interp, "can't change state of ", - winPtr->pathName, ": it is an embedded window", - (char *) NULL); + if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, + &index) != TCL_OK) { return TCL_ERROR; } @@ -4803,6 +4824,35 @@ WmStateCmd(tkwin, winPtr, interp, objc, objv) return TCL_ERROR; } + if (winPtr->flags & TK_EMBEDDED) { + int state; + switch(index) { + case OPT_NORMAL: + state = NormalState; + break; + + case OPT_ICONIC: + state = IconicState; + break; + + case OPT_WITHDRAWN: + state = WithdrawnState; + break; + + case OPT_ZOOMED: + state = ZoomState; + break; + } + + if(state != SendMessage(wmPtr->wrapper, TK_STATE, state, 0)) { + Tcl_AppendResult(interp, "can't change state of ", + winPtr->pathName, ": it is an embedded window", + (char *) NULL); + return TCL_ERROR; + } + return TCL_OK; + } + if (index == OPT_NORMAL) { wmPtr->flags &= ~WM_WITHDRAWN; TkpWmSetState(winPtr, NormalState); @@ -4837,7 +4887,12 @@ WmStateCmd(tkwin, winPtr, interp, objc, objv) if (wmPtr->iconFor != NULL) { Tcl_SetResult(interp, "icon", TCL_STATIC); } else { - switch (wmPtr->hints.initial_state) { + int state; + if(winPtr->flags & TK_EMBEDDED) + state = SendMessage(wmPtr->wrapper, TK_STATE, -1, -1); + else + state = wmPtr->hints.initial_state; + switch (state) { case NormalState: Tcl_SetResult(interp, "normal", TCL_STATIC); break; diff --git a/win/tkWinX.c b/win/tkWinX.c index 2da11fa..41cfc04 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinX.c,v 1.40 2004/12/28 08:45:32 chengyemao Exp $ + * RCS: @(#) $Id: tkWinX.c,v 1.41 2005/01/07 15:18:04 chengyemao Exp $ */ #include "tkWinInt.h" @@ -822,6 +822,7 @@ TkWinChildProc(hwnd, message, wParam, lParam) case TK_GETFRAMEWID: case TK_OVERRIDEREDIRECT: case TK_SETMENU: + case TK_STATE: result = TkWinEmbeddedEventProc(hwnd, message, wParam, lParam); break; -- cgit v0.12