WinWorkstation.st
changeset 2682 ad97ce27c345
parent 2681 b86cc145f329
child 2683 934d038b270f
--- a/WinWorkstation.st	Wed May 19 15:07:50 1999 +0200
+++ b/WinWorkstation.st	Wed May 19 21:24:38 1999 +0200
@@ -14,7 +14,8 @@
 	instanceVariableNames:'blackpixel whitepixel listOfFonts rootWin rootDC buttonsPressed
 		eventTrace eventBuffer isWin95'
 	classVariableNames:'BeepDuration NativeWindows NativeWindowClassTable
-		StandardColorValues IgnoreSysColorChanges IgnoreFontChanges'
+		StandardColorValues IgnoreSysColorChanges IgnoreFontChanges
+		SystemColorValues'
 	poolDictionaries:''
 	category:'Interface-Graphics'
 !
@@ -383,8 +384,8 @@
 # define TH_DPRINTF(x)          /*{ if (__debug__) printf x;}*/
 # define DPRINTF(x)             { if (__debug__) printf x;}
 # define DDPRINTF(x)            { if (__debug__ > 1) printf x;}
-# define EVENT_PRINTF(x)        /*{ if (__debug__) printf x;}*/
-# define EVENT_PRINTF2(x)       /*{ if (__debug__) printf x;}*/
+# define EVENT_PRINTF(x)        { if (__debug__) printf x;}
+# define EVENT_PRINTF2(x)       { if (__debug__ > 1) printf x;}
 # define EVENT_PRINTF3(x)       /* */
 # define UNHANDLED_EVENT_PRINTF(x)  { if (__debug__) printf x;}
 #else
@@ -1974,6 +1975,8 @@
 	    {
 		CREATESTRUCT *lpcs = (LPCREATESTRUCT) lParam; // structure with creation data
 
+		EVENT_PRINTF(("WM_CREATE\n"));
+
 		SETLOCALWINDOWINFOPTR(hWnd, lpcs->lpCreateParams);
 #ifdef SUPERDEBUG
 		if (GETLOCALWINDOWINFOPTR(hWnd) != lpcs->lpCreateParams) {
@@ -1985,12 +1988,11 @@
 		__cnt_createWindows++;
 		RESPRINTF(("CreateWindows %d\n",__cnt_createWindows));
 #endif
-		DPRINTF(("WM_CREATE\n"));
 	    }
 	    break;
 
 	case WM_CLOSE:
-	    DPRINTF(("WM_CLOSE\n"));
+	    EVENT_PRINTF(("WM_CLOSE\n"));
 	    if (! destroyWin) {
 		enqEvent(ENQ_AT_END, 0, hWnd, WM_CLOSE, wParam, 0, 0, 0, 0, EV_NOTIME);
 	    } else {
@@ -2023,7 +2025,7 @@
 		localWindowInfo *lI;
 
 		lI = GETLOCALWINDOWINFOPTR(hWnd);
-		DPRINTF(("WM_DESTROY %x li=%x\n", hWnd, lI));
+		EVENT_PRINTF(("WM_DESTROY %x li=%x\n", hWnd, lI));
 
 #ifdef TOPWINDOWCLASS
 		if (lI) {
@@ -2063,7 +2065,7 @@
 
 		lpmmi = (LPMINMAXINFO) lParam;
 
-		DDPRINTF(("WM_GETMINMAXINFO handle=%x got min: %d/%d\n",
+		EVENT_PRINTF2(("WM_GETMINMAXINFO handle=%x got min: %d/%d\n",
 			    hWnd,
 			    lpmmi->ptMinTrackSize.x,
 			    lpmmi->ptMinTrackSize.y));
@@ -2077,7 +2079,7 @@
 		  lpmmi->ptMinTrackSize.x = lI->minWidth;
 		  lpmmi->ptMinTrackSize.y = lI->minHeight;
 
-		  DPRINTF(("WM_GETMINMAXINFO handle=%x return min: %d/%d max: %d/%d\n",
+		  EVENT_PRINTF3(("WM_GETMINMAXINFO handle=%x return min: %d/%d max: %d/%d\n",
 				  hWnd,
 				  lI->minWidth, lI->minHeight,
 				  lI->maxWidth, lI->maxHeight));
@@ -2164,9 +2166,9 @@
 		w = rct.right - rct.left;
 		h = rct.bottom - rct.top;
 
-		DPRINTF(("WM_WINDOWPOSCHANGED %d/%d %d/%d flags:%x ->",
+		EVENT_PRINTF(("WM_WINDOWPOSCHANGED %d/%d %d/%d flags:%x ->",
 			wp->x, wp->y, wp->cx, wp->cy, wp->flags));
-		DPRINTF(("          rect now: %d/%d %d/%d\n",x, y, w, h));
+		EVENT_PRINTF(("          rect now: %d/%d %d/%d\n",x, y, w, h));
 #if 1
 		if (wp->flags & SWP_NOSIZE) {
 		    DPRINTF((stderr, "SWP_NOSIZE\n"));
@@ -4894,6 +4896,27 @@
 %}
 !
 
+supportedSystemColorKeys
+    "return a collection of supported systemColor keys"
+
+    ^#( 
+	COLOR_WINDOW
+	COLOR_WINDOWTEXT
+	COLOR_MENU
+	COLOR_MENUTEXT
+	COLOR_BTNFACE
+	COLOR_BTNSHADOW
+	COLOR_BTNTEXT
+	COLOR_GRAYTEXT
+	COLOR_HIGHLIGHT
+	COLOR_HIGHLIGHTTEXT
+	COLOR_MENU
+	COLOR_MENUTEXT
+	COLOR_SCROLLBAR
+	COLOR_SHADOW
+    )
+!
+
 translatePoint:aPoint from:windowId1 to:windowId2
     "given a point in window1, return the coordinate in window2.
      This expects a device coordinate (relative to the first views origin)
@@ -7838,16 +7861,37 @@
      Tell the viewStyle to update itself,
      and tell all view to reinit its style."
 
+    |anyChange|
+
 "/    'WinWorkstation [info]: systemColorChange for ' infoPrint.
 "/    aWindow printCR.
 
     IgnoreSysColorChanges ~~ true ifTrue:[
-	"/ TODO: this should go through the sensor ...
-	"/ ...and handled as an event by the views thread.
-	View updateAllStyleCaches.
-
-	aWindow withAllSubViewsDo:[:aView |
-	    aView reinitStyle
+	"/ first check, if there was really a change
+	"/ (when exceed is running, we get plenty of those messages ...)
+
+	SystemColorValues isNil ifTrue:[
+	    SystemColorValues := IdentityDictionary new.
+	].
+	anyChange := false.
+	self supportedSystemColorKeys do:[:key |
+	    |oldValue newValue|
+
+	    oldValue := SystemColorValues at:key ifAbsent:nil.
+	    newValue := self getSystemColor:key.
+	    oldValue ~~ newValue ifTrue:[
+		SystemColorValues at:key put:newValue.
+		anyChange := true.
+	    ]
+	].
+	anyChange ifTrue:[
+	    "/ TODO: this should go through the sensor ...
+	    "/ ...and handled as an event by the views thread.
+	    View updateAllStyleCaches.
+
+	    aWindow withAllSubViewsDo:[:aView |
+		aView reinitStyle
+	    ]
 	]
     ]
 
@@ -12214,6 +12258,6 @@
 !WinWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.129 1999-05-19 13:07:50 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.130 1999-05-19 19:24:38 cg Exp $'
 ! !
 WinWorkstation initialize!