summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das>2006-04-11 07:36:36 (GMT)
committerdas <das>2006-04-11 07:36:36 (GMT)
commit070434c182c27254deaee167b8933d75caa88f07 (patch)
tree8453fd3ff6200edf45dabd6c54b008e5b62d728a
parent395b185e7d03c18efd681420914e6992a82a2508 (diff)
downloadtk-070434c182c27254deaee167b8933d75caa88f07.zip
tk-070434c182c27254deaee167b8933d75caa88f07.tar.gz
tk-070434c182c27254deaee167b8933d75caa88f07.tar.bz2
* macosx/tkMacOSXInt.h: Implemented 'zoomed' window state
* macosx/tkMacOSXWindowEvent.c: handling for TkAqua, via titlebar * macosx/tkMacOSXWm.c: widget clicks as well as [wm state]. * doc/wm.n: [Bug 1073456]
-rw-r--r--ChangeLog17
-rw-r--r--doc/wm.n12
-rw-r--r--macosx/tkMacOSXInt.h5
-rw-r--r--macosx/tkMacOSXWindowEvent.c5
-rw-r--r--macosx/tkMacOSXWm.c182
5 files changed, 137 insertions, 84 deletions
diff --git a/ChangeLog b/ChangeLog
index ffb038e..23ec159 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-04-11 Daniel Steffen <das@users.sourceforge.net>
+
+ * macosx/tkMacOSXInt.h: Implemented 'zoomed' window state
+ * macosx/tkMacOSXWindowEvent.c: handling for TkAqua, via titlebar
+ * macosx/tkMacOSXWm.c: widget clicks as well as [wm state].
+ * doc/wm.n: [Bug 1073456]
+
2006-04-10 Donal K. Fellows <donal.k.fellows@manchester.ac.uk>
* library/tkfbox.tcl (::tk::IconList_Goto): Fix prefix searching so
@@ -6,13 +13,13 @@
2006-04-10 Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net>
- * macosx/tkMacOSXFont.c (MeasureStringWidth): Use implementation
- based on ATSUGetGlyphBounds (TK_MAC_USE_GETGLYPHBOUNDS), so we can
- use kATSUseFractionalOrigins. This in turn corrects [Bug 1461650].
- * (InitFont): Use "." and "W" instead of "i" and "w" to determine the
+ * macosx/tkMacOSXFont.c (MeasureStringWidth): Use implementation based
+ on ATSUGetGlyphBounds (TK_MAC_USE_GETGLYPHBOUNDS), so we can use
+ kATSUseFractionalOrigins. This in turn corrects [Bug 1461650].
+ (InitFont): Use "." and "W" instead of "i" and "w" to determine the
"-fixed" attribute. This prevents "Apple Chancery" from being
classified as fixed.
- * (InitFontFamilies): Only get the font families once.
+ (InitFontFamilies): Only get the font families once.
2006-04-09 Daniel Steffen <das@users.sourceforge.net>
diff --git a/doc/wm.n b/doc/wm.n
index 9b2afa9..ecccdf3 100644
--- a/doc/wm.n
+++ b/doc/wm.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: wm.n,v 1.24 2005/11/16 02:51:38 jenglish Exp $
+'\" RCS: @(#) $Id: wm.n,v 1.25 2006/04/11 07:36:36 das Exp $
'\"
.so man.macros
.TH wm n 8.5 Tk "Tk Built-In Commands"
@@ -76,7 +76,8 @@ menu and taskbar.
.PP
On Mac OS X, \fB\-modified\fR gets or sets the modification state of the
window (determines whether the window close widget contains the modification
-indicator). \fB\-titlepath\fR gets or sets the path of the file referenced as
+indicator and whether the proxy icon is draggable).
+\fB\-titlepath\fR gets or sets the path of the file referenced as
the window proxy icon (which can be dragged and dropped in lieu of the file's
finder icon). \fB\-alpha\fR sets the alpha transparency level of the window,
it accepts a value from \fB0.0\fR (fully transparent) to \fB1.0\fR (opaque),
@@ -95,7 +96,7 @@ attribute set.
.TP
\fB-zoomed\fP
Requests that the window should be maximized.
-This is the same as \fB[wm state zoomed]\fP on Windows.
+This is the same as \fB[wm state zoomed]\fP on Windows and Mac OS X.
.TP
\fB-fullscreen\fP
Requests that the window should fill the entire screen
@@ -501,8 +502,9 @@ window in the stacking order.
\fBwm state \fIwindow\fR ?newstate?
If \fInewstate\fR is specified, the window will be set to the new state,
otherwise it returns the current state of \fIwindow\fR: either
-\fBnormal\fR, \fBiconic\fR, \fBwithdrawn\fR, \fBicon\fR, or (Windows only)
-\fBzoomed\fR. The difference between \fBiconic\fR and \fBicon\fR is that
+\fBnormal\fR, \fBiconic\fR, \fBwithdrawn\fR, \fBicon\fR, or (Windows and Mac
+OS X only) \fBzoomed\fR.
+The difference between \fBiconic\fR and \fBicon\fR is that
\fBiconic\fR refers to a window that has been iconified (e.g., with the
\fBwm iconify\fR command) while \fBicon\fR refers to a window whose only
purpose is to serve as the icon for some other window (via the \fBwm
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index 8fd36a8..09eb983 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.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: tkMacOSXInt.h,v 1.14 2006/03/24 14:58:01 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInt.h,v 1.15 2006/04/11 07:36:36 das Exp $
*/
#ifndef _TKMACINT
@@ -166,9 +166,10 @@ MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiA
MODULE_SCOPE void TkMacOSXDefaultStartupScript(void);
MODULE_SCOPE int TkMacOSXGenerateFocusEvent( Window window, int activeFlag);
MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr);
-MODULE_SCOPE void* TkMacOSXGetNamedSymbol(const char* module, const char* symbol);
+MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr);
MODULE_SCOPE int TkMacOSXCompareColors(unsigned long c1, unsigned long c2);
+MODULE_SCOPE void* TkMacOSXGetNamedSymbol(const char* module, const char* symbol);
/* Macro to abstract common use of TkMacOSXGetNamedSymbol to initialize named symbols */
#define TkMacOSXInitNamedSymbol(module, ret, symbol, ...) \
static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 1996305..e2fb633 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -54,7 +54,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.11 2006/03/24 14:58:01 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.12 2006/04/11 07:36:36 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -238,7 +238,8 @@ TkMacOSXProcessWindowEvent(
dispPtr = TkGetDisplayList();
winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, window);
if (winPtr) {
- TkpWmSetState(winPtr, NormalState);
+ TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ?
+ ZoomState : NormalState);
}
break;
}
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 1591e2a..c051316 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.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: tkMacOSXWm.c,v 1.28 2006/04/10 09:25:34 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWm.c,v 1.29 2006/04/11 07:36:36 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -1318,7 +1318,6 @@ int objc; /* Number of arguments. */
Tcl_Obj *CONST objv[]; /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
-
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
return TCL_ERROR;
@@ -1334,12 +1333,8 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */
": it is an embedded window", (char *) NULL);
return TCL_ERROR;
}
-
- /*
- * TODO: may not want to call this function - look at Map events gened.
- */
-
- TkpWmSetState(winPtr, NormalState);
+ TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ?
+ ZoomState : NormalState);
return TCL_OK;
}
@@ -2786,6 +2781,11 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */
if (wmPtr->iconFor != NULL) {
Tcl_SetResult(interp, "icon", TCL_STATIC);
} else {
+ if (wmPtr->hints.initial_state == NormalState ||
+ wmPtr->hints.initial_state == ZoomState) {
+ wmPtr->hints.initial_state = (TkMacOSXIsWindowZoomed(winPtr) ?
+ ZoomState : NormalState);
+ }
switch (wmPtr->hints.initial_state) {
case NormalState:
Tcl_SetResult(interp, "normal", TCL_STATIC);
@@ -4509,7 +4509,7 @@ TkMacOSXGrowToplevel(
SetPort(GetWindowPort(whichWindow));
GlobalToLocal(&where);
- GetPortBounds(GetWindowPort(whichWindow), &portRect );
+ GetPortBounds(GetWindowPort(whichWindow), &portRect);
if (where.h > (portRect.right - 16) &&
where.v > (portRect.bottom - 16)) {
Window window;
@@ -4546,7 +4546,7 @@ TkMacOSXGrowToplevel(
if (growResult != 0) {
SizeWindow(whichWindow,
LoWord(growResult), HiWord(growResult), true);
- InvalWindowRect(whichWindow,&portRect); /* TODO: may not be needed */
+ InvalWindowRect(whichWindow, &portRect); /* TODO: may not be needed */
TkMacOSXInvalClipRgns((Tk_Window) winPtr);
TkGenWMConfigureEvent((Tk_Window) winPtr, -1, -1,
(int) LoWord(growResult), (int) HiWord(growResult),
@@ -4659,11 +4659,57 @@ TkMacOSXGetXWindow(
/*
*----------------------------------------------------------------------
*
+ * TkMacOSXIsWindowZoomed --
+ *
+ * Ask Carbon if the given window is in the zoomed out state.
+ * Because dragging & growing a window can change the Carbon
+ * zoom state, we cannot rely on wmInfoPtr->hints.initial_state
+ * for this information.
+ *
+ * Results:
+ * True if window is zoomed out, false otherwise.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+MODULE_SCOPE int
+TkMacOSXIsWindowZoomed(
+ TkWindow *winPtr)
+{
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ Point idealSize;
+
+ if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) &&
+ (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) {
+ return false;
+ }
+ if (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) {
+ idealSize.h = winPtr->changes.width;
+ } else {
+ idealSize.h = wmPtr->maxWidth;
+ }
+ if (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) {
+ idealSize.v = winPtr->changes.height;
+ } else {
+ idealSize.v = wmPtr->maxHeight;
+ }
+
+ return IsWindowInStandardState(
+ GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window)),
+ &idealSize, NULL);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkMacOSXZoomToplevel --
*
* The function is invoked when the user clicks in the zoom region
- * of a Tk window. The function will handle the mouse tracking
- * for the interaction. If the window is to be zoomed the window
+ * of a Tk window or when the window state is set/unset to "zoomed"
+ * manually. If the window is to be zoomed (in or out), the window
* size is changed and events are generated to let Tk know what
* happened.
*
@@ -4682,65 +4728,60 @@ TkMacOSXZoomToplevel(
short zoomPart) /* Either inZoomIn or inZoomOut */
{
Window window;
- Tk_Window tkwin;
- Point location = {0, 0};
- int xOffset, yOffset;
- WmInfo *wmPtr;
TkDisplay *dispPtr;
- Rect portRect;
-
- SetPort(GetWindowPort(whichWindow));
+ TkWindow *winPtr;
+ WmInfo *wmPtr;
+ Point location = {0, 0}, idealSize;
+ Rect portRect;
+ int xOffset, yOffset;
+ OSStatus status;
- /*
- * We should now zoom the window (as long as it's one of ours). We
- * also need to generate an event to let Tk know that the window size
- * has changed.
- */
window = TkMacOSXGetXWindow(whichWindow);
dispPtr = TkGetDisplayList();
- tkwin = Tk_IdToWindow(dispPtr->display, window);
- if (tkwin == NULL) {
+ winPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, window);
+ wmPtr = winPtr->wmInfoPtr;
+
+ if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) &&
+ (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) {
return false;
}
+ if (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) {
+ idealSize.h = winPtr->changes.width;
+ } else {
+ idealSize.h = wmPtr->maxWidth;
+ }
+ if (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) {
+ idealSize.v = winPtr->changes.height;
+ } else {
+ idealSize.v = wmPtr->maxHeight;
+ }
- /*
- * The following block of code works around a bug in the window
- * definition for Apple's floating windows. The zoom behavior is
- * broken - we must manually set the standard state (by default
- * it's something like 1x1) and we must swap the zoomPart manually
- * otherwise we always get the same zoomPart and nothing happens.
- */
- wmPtr = ((TkWindow *) tkwin)->wmInfoPtr;
- if (wmPtr->style >= floatProc && wmPtr->style <= floatSideZoomGrowProc) {
- if (zoomPart == inZoomIn) {
- BitMap screenBits;
- Rect zoomRect;
- GetQDGlobalsScreenBits(&screenBits);
- zoomRect = screenBits.bounds;
- InsetRect(&zoomRect, 60, 60);
- SetWindowStandardState(whichWindow, &zoomRect);
- zoomPart = inZoomOut;
- } else {
- zoomPart = inZoomIn;
- }
+ /* Do nothing if already in desired zoom state */
+ if (!IsWindowInStandardState(whichWindow, &idealSize, NULL) ==
+ (zoomPart == inZoomIn)) {
+ return false;
+ }
+
+ SetPort(GetWindowPort(whichWindow));
+ GetPortBounds(GetWindowPort(whichWindow), &portRect);
+ status = ZoomWindowIdeal(whichWindow, zoomPart, &idealSize);
+ if (status == noErr) {
+ wmPtr->hints.initial_state =
+ (zoomPart == inZoomIn ? NormalState : ZoomState);
+ InvalWindowRect(whichWindow, &portRect);
+ TkMacOSXInvalClipRgns((Tk_Window) winPtr);
+ LocalToGlobal(&location);
+ TkMacOSXWindowOffset(whichWindow, &xOffset, &yOffset);
+ location.h -= xOffset;
+ location.v -= yOffset;
+ GetPortBounds(GetWindowPort(whichWindow), &portRect);
+ TkGenWMConfigureEvent((Tk_Window) winPtr, location.h, location.v,
+ portRect.right - portRect.left, portRect.bottom - portRect.top,
+ TK_BOTH_CHANGED);
+ return true;
} else {
- zoomPart = inZoomIn;
+ return false;
}
-
- ZoomWindow(whichWindow, zoomPart, false);
- InvalWindowRect(whichWindow,&portRect);
- TkMacOSXInvalClipRgns(tkwin);
-
- LocalToGlobal(&location);
- TkMacOSXWindowOffset(whichWindow, &xOffset, &yOffset);
- location.h -= xOffset;
- location.v -= yOffset;
- GetPortBounds ( GetWindowPort(whichWindow), &portRect );
- TkGenWMConfigureEvent(tkwin, location.h, location.v,
- portRect.right - portRect.left,
- portRect.bottom - portRect.top,
- TK_BOTH_CHANGED);
- return true;
}
/*
@@ -5157,6 +5198,7 @@ TkMacOSXMakeRealWindowExist(
SetWindowGroup(newWindow, group);
}
}
+ SetWindowModified(newWindow, false);
if (!windowHashInit) {
Tcl_InitHashTable(&windowTable, TCL_ONE_WORD_KEYS);
@@ -5395,10 +5437,15 @@ TkpWmSetState(winPtr, state)
} else if (state == NormalState) {
Tk_MapWindow((Tk_Window) winPtr);
if (IsWindowCollapsable(macWin) && IsWindowCollapsed(macWin)) {
- CollapseWindow((WindowPtr) macWin, false);
- }
+ CollapseWindow(macWin, false);
+ }
+ TkMacOSXZoomToplevel(macWin, inZoomIn);
} else if (state == ZoomState) {
- /* TODO: need to support zoomed windows */
+ Tk_MapWindow((Tk_Window) winPtr);
+ if (IsWindowCollapsable(macWin) && IsWindowCollapsed(macWin)) {
+ CollapseWindow(macWin, false);
+ }
+ TkMacOSXZoomToplevel(macWin, inZoomOut);
}
}
@@ -5753,8 +5800,3 @@ TkWmStackorderToplevel(parentPtr)
Tcl_DeleteHashTable(&table);
return windows;
}
-
-
-
-
-