summaryrefslogtreecommitdiffstats
path: root/win/tkWinWm.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2004-08-20 00:40:31 (GMT)
committerhobbs <hobbs>2004-08-20 00:40:31 (GMT)
commit51fb06c44ba80d4a69fc319727d1a73af41fa085 (patch)
treeb1548575bf5b07b4ad9c5f88b033b1f197672b95 /win/tkWinWm.c
parent503873175147643759877b680b02299eeea1617f (diff)
downloadtk-51fb06c44ba80d4a69fc319727d1a73af41fa085.zip
tk-51fb06c44ba80d4a69fc319727d1a73af41fa085.tar.gz
tk-51fb06c44ba80d4a69fc319727d1a73af41fa085.tar.bz2
* win/tkWinDialog.c (Tk_MessageBoxObjCmd): Inherit the icon from
* win/tkWinInt.h: the -parent window for * win/tkWinWm.c (TkWinGetIcon): the MessageBox.
Diffstat (limited to 'win/tkWinWm.c')
-rw-r--r--win/tkWinWm.c99
1 files changed, 86 insertions, 13 deletions
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index d4fdec9..7489132 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.54.2.1 2004/05/15 04:07:15 chengyemao Exp $
+ * RCS: @(#) $Id: tkWinWm.c,v 1.54.2.2 2004/08/20 00:40:32 hobbs Exp $
*/
#include "tkWinInt.h"
@@ -798,7 +798,8 @@ ReadICOHeader( Tcl_Channel channel )
*----------------------------------------------------------------------
*/
static int
-InitWindowClass(WinIconPtr titlebaricon) {
+InitWindowClass(WinIconPtr titlebaricon)
+{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -1064,6 +1065,74 @@ WinSetIcon(interp, titlebaricon, tkw)
/*
*----------------------------------------------------------------------
*
+ * TkWinGetIcon --
+ *
+ * Gets either the default toplevel titlebar icon, or the icon
+ * for a specific toplevel (ICON_SMALL or ICON_BIG).
+ *
+ * Results:
+ * A Windows HICON.
+ *
+ * Side effects:
+ * The given window will be forced into existence.
+ *
+ *----------------------------------------------------------------------
+ */
+HICON
+TkWinGetIcon(Tk_Window tkw, DWORD iconsize)
+{
+ TkWindow *winPtr;
+ WmInfo *wmPtr;
+ HICON icon;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
+ if (tsdPtr->iconPtr != NULL) {
+ /*
+ * return default toplevel icon
+ */
+ return GetIcon(tsdPtr->iconPtr, iconsize);
+ }
+
+ if (Tk_WindowId(tkw) == None) {
+ Tk_MakeWindowExist(tkw);
+ }
+
+ winPtr = (TkWindow *)tkw;
+ if (!(Tk_IsTopLevel(tkw))) {
+ winPtr = GetTopLevel(Tk_GetHWND(Tk_WindowId(tkw)));
+ }
+ /* We must get the window's wrapper, not the window itself */
+ wmPtr = winPtr->wmInfoPtr;
+
+ if (wmPtr->iconPtr != NULL) {
+ /*
+ * return window toplevel icon
+ */
+ return GetIcon(wmPtr->iconPtr, iconsize);
+ }
+
+ /*
+ * Find the icon otherwise associated with the toplevel, or
+ * finally with the window class.
+ */
+ icon = (HICON) SendMessage(wmPtr->wrapper, WM_GETICON, iconsize,
+ (LPARAM) NULL);
+ if (icon == (HICON) NULL) {
+#ifdef _WIN64
+ icon = (HICON) GetClassLongPtr(wmPtr->wrapper,
+ (iconsize == ICON_BIG) ? GCLP_HICON : GCLP_ICONSM);
+#else
+ icon = (HICON) GetClassLong(wmPtr->wrapper,
+ (iconsize == ICON_BIG) ? GCL_HICON : GCL_HICONSM);
+#endif
+ }
+ return icon;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* ReadIconFromFile --
*
* Read the contents of a file (usually .ico, .icr) and extract an
@@ -1301,7 +1370,8 @@ DecrIconRefCount(WinIconPtr titlebaricon) {
*----------------------------------------------------------------------
*/
static void
-FreeIconBlock(BlockOfIconImagesPtr lpIR) {
+FreeIconBlock(BlockOfIconImagesPtr lpIR)
+{
int i;
/* Free all the bits */
@@ -1332,7 +1402,8 @@ FreeIconBlock(BlockOfIconImagesPtr lpIR) {
*----------------------------------------------------------------------
*/
static HICON
-GetIcon(WinIconPtr titlebaricon, int icon_size) {
+GetIcon(WinIconPtr titlebaricon, int icon_size)
+{
BlockOfIconImagesPtr lpIR;
if (titlebaricon == NULL) {
@@ -1367,7 +1438,8 @@ GetIcon(WinIconPtr titlebaricon, int icon_size) {
}
static HCURSOR
-TclWinReadCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName) {
+TclWinReadCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName)
+{
BlockOfIconImagesPtr lpIR;
HICON res = NULL;
@@ -1400,7 +1472,8 @@ TclWinReadCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName) {
*----------------------------------------------------------------------
*/
static BlockOfIconImagesPtr
-ReadIconOrCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName, BOOL isIcon) {
+ReadIconOrCursorFromFile(Tcl_Interp* interp, Tcl_Obj* fileName, BOOL isIcon)
+{
BlockOfIconImagesPtr lpIR, lpNew;
Tcl_Channel channel;
int i;
@@ -3373,6 +3446,7 @@ WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv)
/* If true, then set for all windows. */
int isDefault = 0;
char *string;
+ TkWindow *useWinPtr = winPtr; /* window to apply to (NULL if -default) */
if ((objc < 3) || (objc > 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?-default? ?image?");
@@ -3386,7 +3460,7 @@ WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv)
(char *) NULL);
return TCL_ERROR;
}
- isDefault = 1;
+ useWinPtr = NULL;
} else if (objc == 3) {
/* No arguments were given */
if (wmPtr->hints.flags & IconPixmapHint) {
@@ -3404,8 +3478,7 @@ WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv)
wmPtr->hints.icon_pixmap = None;
}
wmPtr->hints.flags &= ~IconPixmapHint;
- if (WinSetIcon(interp, NULL,
- (isDefault ? NULL : (Tk_Window) winPtr)) != TCL_OK) {
+ if (WinSetIcon(interp, NULL, (Tk_Window) useWinPtr) != TCL_OK) {
return TCL_ERROR;
}
} else {
@@ -3434,8 +3507,8 @@ WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv)
* Try to set the icon for the window. If it is a '-default'
* icon, we must pass in NULL
*/
- if (WinSetIcon(interp, titlebaricon,
- (isDefault ? NULL : (Tk_Window) winPtr)) != TCL_OK) {
+ if (WinSetIcon(interp, titlebaricon, (Tk_Window) useWinPtr)
+ != TCL_OK) {
/* We didn't use the titlebaricon after all */
DecrIconRefCount(titlebaricon);
titlebaricon = NULL;
@@ -3457,8 +3530,8 @@ WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv)
wmPtr->hints.flags |= IconPixmapHint;
titlebaricon = GetIconFromPixmap(Tk_Display(winPtr), pixmap);
if (titlebaricon != NULL) {
- if (WinSetIcon(interp, titlebaricon,
- (isDefault ? NULL : (Tk_Window) winPtr)) != TCL_OK) {
+ if (WinSetIcon(interp, titlebaricon, (Tk_Window) useWinPtr)
+ != TCL_OK) {
/* We didn't use the titlebaricon after all */
DecrIconRefCount(titlebaricon);
titlebaricon = NULL;