WinWorkstation.st
changeset 8538 23138b66fe48
parent 8536 130cc50076b4
child 8540 294088ce62be
equal deleted inserted replaced
8537:8bd2123b96c6 8538:23138b66fe48
     1 "{ Encoding: utf8 }"
     1 "{ Encoding: utf8 }"
     2 
     2 
     3 "
     3 "
     4 COPYRIGHT (c) 1996 by Claus Gittinger
     4 COPYRIGHT (c) 1996 by Claus Gittinger
     5               All Rights Reserved
     5 	      All Rights Reserved
     6 
     6 
     7  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
     8  only in accordance with the terms of that license and with the
     8  only in accordance with the terms of that license and with the
     9  inclusion of the above copyright notice.   This software may not
     9  inclusion of the above copyright notice.   This software may not
    10  be provided or otherwise made available to, or used by, any
    10  be provided or otherwise made available to, or used by, any
    14 "{ Package: 'stx:libview' }"
    14 "{ Package: 'stx:libview' }"
    15 
    15 
    16 "{ NameSpace: Smalltalk }"
    16 "{ NameSpace: Smalltalk }"
    17 
    17 
    18 DeviceWorkstation subclass:#WinWorkstation
    18 DeviceWorkstation subclass:#WinWorkstation
    19         instanceVariableNames:'blackpixel whitepixel listOfFonts rootWin rootDC buttonsPressed
    19 	instanceVariableNames:'blackpixel whitepixel listOfFonts rootWin rootDC buttonsPressed
    20                 eventTrace eventBuffer lastClipboardSequenceNumber'
    20 		eventTrace eventBuffer lastClipboardSequenceNumber'
    21         classVariableNames:'BeepDuration NativeDialogs NativeFileDialogs NativeWidgets
    21 	classVariableNames:'BeepDuration NativeDialogs NativeFileDialogs NativeWidgets
    22                 NativeWidgetClassTable StandardColorValues IgnoreSysColorChanges
    22 		NativeWidgetClassTable StandardColorValues IgnoreSysColorChanges
    23                 IgnoreFontChanges SystemColorValues CanEndSession
    23 		IgnoreFontChanges SystemColorValues CanEndSession
    24                 VerboseNativeDialogs'
    24 		VerboseNativeDialogs'
    25         poolDictionaries:''
    25 	poolDictionaries:''
    26         category:'Interface-Graphics'
    26 	category:'Interface-Graphics'
    27 !
    27 !
    28 
    28 
    29 Object subclass:#AlphaBlendParameters
    29 Object subclass:#AlphaBlendParameters
    30         instanceVariableNames:'sourceAlpha padding redMask greenMask blueMask'
    30 	instanceVariableNames:'sourceAlpha padding redMask greenMask blueMask'
    31         classVariableNames:''
    31 	classVariableNames:''
    32         poolDictionaries:''
    32 	poolDictionaries:''
    33         privateIn:WinWorkstation
    33 	privateIn:WinWorkstation
    34 !
    34 !
    35 
    35 
    36 ByteArray variableByteSubclass:#CopyDataStructStructure
    36 ByteArray variableByteSubclass:#CopyDataStructStructure
    37         instanceVariableNames:''
    37 	instanceVariableNames:''
    38         classVariableNames:''
    38 	classVariableNames:''
    39         poolDictionaries:''
    39 	poolDictionaries:''
    40         privateIn:WinWorkstation
    40 	privateIn:WinWorkstation
    41 !
    41 !
    42 
    42 
    43 Object subclass:#MonitorInfo
    43 Object subclass:#MonitorInfo
    44         instanceVariableNames:'screenX screenY screenW screenH workX workY workW workH isPrimary
    44 	instanceVariableNames:'screenX screenY screenW screenH workX workY workW workH isPrimary
    45                 name'
    45 		name'
    46         classVariableNames:''
    46 	classVariableNames:''
    47         poolDictionaries:''
    47 	poolDictionaries:''
    48         privateIn:WinWorkstation
    48 	privateIn:WinWorkstation
    49 !
    49 !
    50 
    50 
    51 DeviceHandle subclass:#PrinterDeviceContextHandle
    51 DeviceHandle subclass:#PrinterDeviceContextHandle
    52         instanceVariableNames:''
    52 	instanceVariableNames:''
    53         classVariableNames:''
    53 	classVariableNames:''
    54         poolDictionaries:''
    54 	poolDictionaries:''
    55         privateIn:WinWorkstation
    55 	privateIn:WinWorkstation
    56 !
    56 !
    57 
    57 
    58 !WinWorkstation primitiveDefinitions!
    58 !WinWorkstation primitiveDefinitions!
    59 %{
    59 %{
    60 #define TRACE_ALL_EVENTS      /* */
    60 #define TRACE_ALL_EVENTS      /* */
    85 #define USE_DRAW_MUTEX
    85 #define USE_DRAW_MUTEX
    86 #define GDIFLUSH_WHEN_CHANGING_CLIP       /* workaround a redraw problem (with dell?) */
    86 #define GDIFLUSH_WHEN_CHANGING_CLIP       /* workaround a redraw problem (with dell?) */
    87 #define LATE_GENERATE_EXPOSE              /* get update region from stx thread */
    87 #define LATE_GENERATE_EXPOSE              /* get update region from stx thread */
    88 #define xxNO_CLEAR_FOR_WM_PAINT           /* do not fill exposed areas with bgColor */
    88 #define xxNO_CLEAR_FOR_WM_PAINT           /* do not fill exposed areas with bgColor */
    89 #define xxLATE_CLEAR_FOR_WM_PAINT         /* fill exposed areas with bgColor in ST/X thread (instead of in event-thread) */
    89 #define xxLATE_CLEAR_FOR_WM_PAINT         /* fill exposed areas with bgColor in ST/X thread (instead of in event-thread) */
    90                                           /* seems to be needed to avoid DC conflicts */
    90 					  /* seems to be needed to avoid DC conflicts */
    91 
    91 
    92 #if 0 /* DOES NOT WORK */
    92 #if 0 /* DOES NOT WORK */
    93 # define CACHE_LAST_PEN                  /* remember last pen in gcData */
    93 # define CACHE_LAST_PEN                  /* remember last pen in gcData */
    94 # define CACHE_LAST_BRUSH                /* remember last brush in gcData */
    94 # define CACHE_LAST_BRUSH                /* remember last brush in gcData */
    95 # define CACHE_LAST_WM_PAINT_BRUSH       /* remember last viewBackground brush */
    95 # define CACHE_LAST_WM_PAINT_BRUSH       /* remember last viewBackground brush */
   347 
   347 
   348 #define ISCONNECTED         1
   348 #define ISCONNECTED         1
   349 
   349 
   350 struct gcData {
   350 struct gcData {
   351     union {
   351     union {
   352         HDC         __hDC;
   352 	HDC         __hDC;
   353         struct gcData *__nextFree;
   353 	struct gcData *__nextFree;
   354     } u;
   354     } u;
   355     HWND        hWnd;
   355     HWND        hWnd;
   356     HBITMAP     hBitmap;
   356     HBITMAP     hBitmap;
   357     HBITMAP     save_hBitmap;
   357     HBITMAP     save_hBitmap;
   358     HBITMAP     hMask;
   358     HBITMAP     hMask;
   613 
   613 
   614 /* # define EVENT_PRINTF(x)        { printf x;} */
   614 /* # define EVENT_PRINTF(x)        { printf x;} */
   615 
   615 
   616 #define INFOFPRINTF(__x__)                 \
   616 #define INFOFPRINTF(__x__)                 \
   617     if (@global(InfoPrinting) == true) { \
   617     if (@global(InfoPrinting) == true) { \
   618         console_fprintf __x__;           \
   618 	console_fprintf __x__;           \
   619     }
   619     }
   620 
   620 
   621 #define DEBUGFPRINTF(__x__)                 \
   621 #define DEBUGFPRINTF(__x__)                 \
   622     if (@global(InfoPrinting) == true) { \
   622     if (@global(InfoPrinting) == true) { \
   623         console_fprintf __x__;           \
   623 	console_fprintf __x__;           \
   624     }
   624     }
   625 
   625 
   626 #define BR_SOLID       0
   626 #define BR_SOLID       0
   627 #define BR_PATTERN     1
   627 #define BR_PATTERN     1
   628 
   628 
   753 #define LI_TOPWIN       0x0001
   753 #define LI_TOPWIN       0x0001
   754 #define LI_INPUTWIN     0x0002
   754 #define LI_INPUTWIN     0x0002
   755 #define LI_NATIVEWIN    0x0004
   755 #define LI_NATIVEWIN    0x0004
   756 
   756 
   757 typedef struct {
   757 typedef struct {
   758         HCURSOR         hCursor;
   758 	HCURSOR         hCursor;
   759         HBRUSH          viewBgBrush;  /* if that is nil, it has a solid bg color */
   759 	HBRUSH          viewBgBrush;  /* if that is nil, it has a solid bg color */
   760         COLORREF        viewBgColor;
   760 	COLORREF        viewBgColor;
   761         int             eventMask;
   761 	int             eventMask;
   762         short           flag;         /* LI_ - flags bits */
   762 	short           flag;         /* LI_ - flags bits */
   763         short           minWidth;
   763 	short           minWidth;
   764         short           maxWidth;
   764 	short           maxWidth;
   765         short           minHeight;
   765 	short           minHeight;
   766         short           maxHeight;
   766 	short           maxHeight;
   767         short           currentMonitorWidth;
   767 	short           currentMonitorWidth;
   768         short           currentMonitorHeight;
   768 	short           currentMonitorHeight;
   769         short           bw;
   769 	short           bw;
   770         unsigned char   iconified;
   770 	unsigned char   iconified;
   771         unsigned char   viewGravity;
   771 	unsigned char   viewGravity;
   772         unsigned char   unmapping;
   772 	unsigned char   unmapping;
   773 #if 0
   773 #if 0
   774         short           bgOffsX;      /* bg-pattern offset */
   774 	short           bgOffsX;      /* bg-pattern offset */
   775         short           bgOffsY;      /* bg-pattern offset */
   775 	short           bgOffsY;      /* bg-pattern offset */
   776 #endif
   776 #endif
   777         short           mouseX;       /* last mouseX */
   777 	short           mouseX;       /* last mouseX */
   778         short           mouseY;       /* last mouseY */
   778 	short           mouseY;       /* last mouseY */
   779         COLORREF        bdColor;
   779 	COLORREF        bdColor;
   780 } localWindowInfo;
   780 } localWindowInfo;
   781 typedef localWindowInfo *plocalWindowInfo;
   781 typedef localWindowInfo *plocalWindowInfo;
   782 
   782 
   783 typedef struct createWindowInfo {
   783 typedef struct createWindowInfo {
   784         localWindowInfo *localWindowInfo;  /* in param */
   784 	localWindowInfo *localWindowInfo;  /* in param */
   785         HANDLE          newWinHandle;      /* out param */
   785 	HANDLE          newWinHandle;      /* out param */
   786         wchar_t         *windowName;       /* in params */
   786 	wchar_t         *windowName;       /* in params */
   787         wchar_t         *className;
   787 	wchar_t         *className;
   788         int             winStyleBits;
   788 	int             winStyleBits;
   789         int             winStyleBitsEx;
   789 	int             winStyleBitsEx;
   790         HANDLE          parentHandle;
   790 	HANDLE          parentHandle;
   791         int             x;
   791 	int             x;
   792         int             y;
   792 	int             y;
   793         int             dx;
   793 	int             dx;
   794         int             dy;
   794 	int             dy;
   795         HANDLE          hCreateEvent;
   795 	HANDLE          hCreateEvent;
   796         short           infoWasRead;
   796 	short           infoWasRead;
   797         unsigned short  sequenceNr;
   797 	unsigned short  sequenceNr;
   798         unsigned        errCode;
   798 	unsigned        errCode;
   799 } createWindowInfo;
   799 } createWindowInfo;
   800 
   800 
   801 #define INVALIDATED_CWI 0xFFFF             /* seqNr for invalidated CWI */
   801 #define INVALIDATED_CWI 0xFFFF             /* seqNr for invalidated CWI */
   802 
   802 
   803 static createWindowInfo *pendingCREATEWINDOWInfo = 0;
   803 static createWindowInfo *pendingCREATEWINDOWInfo = 0;
   808 #ifdef _WIN64
   808 #ifdef _WIN64
   809 
   809 
   810 # define GWL_LOCALINFO  GWLP_USERDATA
   810 # define GWL_LOCALINFO  GWLP_USERDATA
   811 
   811 
   812 # define SETLOCALWINDOWINFOPTR(__hWnd__,__ptr__) \
   812 # define SETLOCALWINDOWINFOPTR(__hWnd__,__ptr__) \
   813         SetWindowLongPtr(__hWnd__, GWL_LOCALINFO , (LONG_PTR)__ptr__)
   813 	SetWindowLongPtr(__hWnd__, GWL_LOCALINFO , (LONG_PTR)__ptr__)
   814 
   814 
   815 # define GETLOCALWINDOWINFOPTR(__hWnd__) \
   815 # define GETLOCALWINDOWINFOPTR(__hWnd__) \
   816         ((localWindowInfo *)GetWindowLongPtr(__hWnd__, GWL_LOCALINFO))
   816 	((localWindowInfo *)GetWindowLongPtr(__hWnd__, GWL_LOCALINFO))
   817 
   817 
   818 #else
   818 #else
   819 
   819 
   820 # define GWL_LOCALINFO  GWL_USERDATA
   820 # define GWL_LOCALINFO  GWL_USERDATA
   821 
   821 
   822 # define SETLOCALWINDOWINFOPTR(__hWnd__,__ptr__) \
   822 # define SETLOCALWINDOWINFOPTR(__hWnd__,__ptr__) \
   823         SetWindowLong(__hWnd__, GWL_LOCALINFO , (DWORD)__ptr__)
   823 	SetWindowLong(__hWnd__, GWL_LOCALINFO , (DWORD)__ptr__)
   824 
   824 
   825 # define GETLOCALWINDOWINFOPTR(__hWnd__) \
   825 # define GETLOCALWINDOWINFOPTR(__hWnd__) \
   826         ((localWindowInfo *)GetWindowLong(__hWnd__, GWL_LOCALINFO))
   826 	((localWindowInfo *)GetWindowLong(__hWnd__, GWL_LOCALINFO))
   827 
   827 
   828 #endif
   828 #endif
   829 
   829 
   830 #define SetWindow_Cursor(__hWnd__, __hCurs__) \
   830 #define SetWindow_Cursor(__hWnd__, __hCurs__) \
   831         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->hCursor = __hCurs__) : 0)
   831 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->hCursor = __hCurs__) : 0)
   832 
   832 
   833 #define GetWindow_Cursor(__hWnd__) \
   833 #define GetWindow_Cursor(__hWnd__) \
   834         (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->hCursor : 0)
   834 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->hCursor : 0)
   835 
   835 
   836 #define SetWindow_viewBgColor(__hWnd__, __viewBgColor__) \
   836 #define SetWindow_viewBgColor(__hWnd__, __viewBgColor__) \
   837         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgColor = __viewBgColor__) : 0)
   837 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgColor = __viewBgColor__) : 0)
   838 
   838 
   839 #define GetWindow_viewBgColor(__hWnd__) \
   839 #define GetWindow_viewBgColor(__hWnd__) \
   840         (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgColor : 0)
   840 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgColor : 0)
   841 
   841 
   842 #define SetWindow_bdColor(__hWnd__, __bdColor__) \
   842 #define SetWindow_bdColor(__hWnd__, __bdColor__) \
   843         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->bdColor = __bdColor__) : 0)
   843 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->bdColor = __bdColor__) : 0)
   844 
   844 
   845 #define GetWindow_bdColor(__hWnd__) \
   845 #define GetWindow_bdColor(__hWnd__) \
   846         (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->bdColor : 0)
   846 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->bdColor : 0)
   847 
   847 
   848 #define SetWindow_iconified(__hWnd__, __iconified__) \
   848 #define SetWindow_iconified(__hWnd__, __iconified__) \
   849         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->iconified = __iconified__) : 0)
   849 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->iconified = __iconified__) : 0)
   850 
   850 
   851 #define GetWindow_iconified(__hWnd__) \
   851 #define GetWindow_iconified(__hWnd__) \
   852         (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->iconified : 0)
   852 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->iconified : 0)
   853 
   853 
   854 #define SetWindow_unmapping(__hWnd__, __unmapping__) \
   854 #define SetWindow_unmapping(__hWnd__, __unmapping__) \
   855         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->unmapping = __unmapping__) : 0)
   855 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->unmapping = __unmapping__) : 0)
   856 
   856 
   857 #define GetWindow_unmapping(__hWnd__) \
   857 #define GetWindow_unmapping(__hWnd__) \
   858         (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->unmapping : 0)
   858 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->unmapping : 0)
   859 
   859 
   860 #define SetWindow_mouseX(__hWnd__, __mouseX__) \
   860 #define SetWindow_mouseX(__hWnd__, __mouseX__) \
   861         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->mouseX = __mouseX__) : 0)
   861 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->mouseX = __mouseX__) : 0)
   862 
   862 
   863 #define GetWindow_mouseX(__hWnd__) \
   863 #define GetWindow_mouseX(__hWnd__) \
   864         (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->mouseX : 0)
   864 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->mouseX : 0)
   865 
   865 
   866 #define SetWindow_mouseY(__hWnd__, __mouseY__) \
   866 #define SetWindow_mouseY(__hWnd__, __mouseY__) \
   867         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->mouseY = __mouseY__) : 0)
   867 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->mouseY = __mouseY__) : 0)
   868 
   868 
   869 #define GetWindow_mouseY(__hWnd__) \
   869 #define GetWindow_mouseY(__hWnd__) \
   870         (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->mouseY : 0)
   870 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->mouseY : 0)
   871 
   871 
   872 #define SetWindow_mouseXY(__hWnd__, __mouseX__, __mouseY__) \
   872 #define SetWindow_mouseXY(__hWnd__, __mouseX__, __mouseY__) \
   873         { SetWindow_mouseX(__hWnd__, __mouseX__); SetWindow_mouseY(__hWnd__, __mouseY__); }
   873 	{ SetWindow_mouseX(__hWnd__, __mouseX__); SetWindow_mouseY(__hWnd__, __mouseY__); }
   874 
   874 
   875 #define SetWindow_viewBgBrush(__hWnd__, __viewBgBrush__) \
   875 #define SetWindow_viewBgBrush(__hWnd__, __viewBgBrush__) \
   876         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgBrush = __viewBgBrush__) : (HBRUSH)0)
   876 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgBrush = __viewBgBrush__) : (HBRUSH)0)
   877 
   877 
   878 #define GetWindow_viewBgBrush(__hWnd__) \
   878 #define GetWindow_viewBgBrush(__hWnd__) \
   879         (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgBrush : (HBRUSH)0)
   879 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgBrush : (HBRUSH)0)
   880 
   880 
   881 #define SetWindow_bw(__hWnd__, __bw__) \
   881 #define SetWindow_bw(__hWnd__, __bw__) \
   882         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->bw = __bw__) : 0)
   882 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->bw = __bw__) : 0)
   883 
   883 
   884 #define GetWindow_bw(__hWnd__) \
   884 #define GetWindow_bw(__hWnd__) \
   885         (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->bw : 0)
   885 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->bw : 0)
   886 
   886 
   887 #define GetWindow_paintInfoPtr(__hWnd__) \
   887 #define GetWindow_paintInfoPtr(__hWnd__) \
   888         (GETLOCALWINDOWINFOPTR(__hWnd__) ? &(GETLOCALWINDOWINFOPTR(__hWnd__)->paintInfo) : 0)
   888 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? &(GETLOCALWINDOWINFOPTR(__hWnd__)->paintInfo) : 0)
   889 
   889 
   890 #define SetWindow_flag(__hWnd__, __flag__) \
   890 #define SetWindow_flag(__hWnd__, __flag__) \
   891         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->flag = __flag__) : 0)
   891 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->flag = __flag__) : 0)
   892 
   892 
   893 #define GetWindow_flag(__hWnd__) \
   893 #define GetWindow_flag(__hWnd__) \
   894         (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->flag : 0)
   894 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->flag : 0)
   895 
   895 
   896 #define GetWindow_eventMask(__hWnd__) \
   896 #define GetWindow_eventMask(__hWnd__) \
   897         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->eventMask) : 0)
   897 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->eventMask) : 0)
   898 
   898 
   899 #define SetWindow_currentMonitorWidth(__hWnd__, __width__) \
   899 #define SetWindow_currentMonitorWidth(__hWnd__, __width__) \
   900         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->currentMonitorWidth = __width__) : 0)
   900 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->currentMonitorWidth = __width__) : 0)
   901 
   901 
   902 #define SetWindow_currentMonitorHeight(__hWnd__, __height__) \
   902 #define SetWindow_currentMonitorHeight(__hWnd__, __height__) \
   903         (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->currentMonitorHeight = __height__) : 0)
   903 	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->currentMonitorHeight = __height__) : 0)
   904 
   904 
   905 
   905 
   906 struct queuedEvent {
   906 struct queuedEvent {
   907         struct queuedEvent     *ev_next;
   907 	struct queuedEvent     *ev_next;
   908         int                     count;
   908 	int                     count;
   909         int                     ev_flag;
   909 	int                     ev_flag;
   910         HWND                    ev_hWnd;
   910 	HWND                    ev_hWnd;
   911         UINT                    ev_message;
   911 	UINT                    ev_message;
   912         UINT                    ev_wParam;
   912 	UINT                    ev_wParam;
   913         INT                     ev_arg1;
   913 	INT                     ev_arg1;
   914         INT                     ev_arg2;
   914 	INT                     ev_arg2;
   915         INT                     ev_arg3;
   915 	INT                     ev_arg3;
   916         INT                     ev_arg4;
   916 	INT                     ev_arg4;
   917         UINT                    ev_time;
   917 	UINT                    ev_time;
   918 };
   918 };
   919 
   919 
   920 #define ev_x    ev_arg1
   920 #define ev_x    ev_arg1
   921 #define ev_y    ev_arg2
   921 #define ev_y    ev_arg2
   922 #define ev_w    ev_arg3
   922 #define ev_w    ev_arg3
   935 #define BITBLT_XOR              SRCINVERT
   935 #define BITBLT_XOR              SRCINVERT
   936 #define BITBLT_AND              SRCAND
   936 #define BITBLT_AND              SRCAND
   937 #define BITBLT_OR               SRCPAINT
   937 #define BITBLT_OR               SRCPAINT
   938 
   938 
   939 typedef struct registerHotKeyInfo {
   939 typedef struct registerHotKeyInfo {
   940         HANDLE       hwnd;          /* in param */
   940 	HANDLE       hwnd;          /* in param */
   941         int          hotKeyId;      /* in param */
   941 	int          hotKeyId;      /* in param */
   942         unsigned int modifier;      /* in param */
   942 	unsigned int modifier;      /* in param */
   943         unsigned int virtualKey;    /* in params */
   943 	unsigned int virtualKey;    /* in params */
   944         int          finished;      /* out param */
   944 	int          finished;      /* out param */
   945         int          errorCode;     /* out param */
   945 	int          errorCode;     /* out param */
   946 } registerHotKeyInfo;
   946 } registerHotKeyInfo;
   947 
   947 
   948 typedef struct fileDialogDataStruct {
   948 typedef struct fileDialogDataStruct {
   949     wchar_t filename[1000 * MAX_PATH]; // big buffer to support multiselect
   949     wchar_t filename[1000 * MAX_PATH]; // big buffer to support multiselect
   950     wchar_t directory[MAX_PATH];
   950     wchar_t directory[MAX_PATH];
   953     wchar_t filter[MAX_PATH];
   953     wchar_t filter[MAX_PATH];
   954     int filterIndex;
   954     int filterIndex;
   955     BOOL trueForSave;
   955     BOOL trueForSave;
   956     BOOL trueForMultiSelect;
   956     BOOL trueForMultiSelect;
   957 
   957 
   958         DWORD fileDialogThreadId;
   958 	DWORD fileDialogThreadId;
   959     BOOL fileDialogDidReturn;
   959     BOOL fileDialogDidReturn;
   960 } fileDialogData;
   960 } fileDialogData;
   961 
   961 
   962 DWORD WINAPI OpenFileDialog(void *arg) {
   962 DWORD WINAPI OpenFileDialog(void *arg) {
   963     BOOL hasResult;
   963     BOOL hasResult;
   964     OPENFILENAMEW ofn;
   964     OPENFILENAMEW ofn;
   965         fileDialogData *pFdd = (fileDialogData*)arg;
   965 	fileDialogData *pFdd = (fileDialogData*)arg;
   966         
   966 
   967         pFdd->fileDialogThreadId = GetCurrentThreadId();
   967 	pFdd->fileDialogThreadId = GetCurrentThreadId();
   968     ZeroMemory(&ofn, sizeof(ofn));
   968     ZeroMemory(&ofn, sizeof(ofn));
   969 
   969 
   970     ofn.lStructSize = sizeof(OPENFILENAMEW);
   970     ofn.lStructSize = sizeof(OPENFILENAMEW);
   971     ofn.lpstrFile = pFdd->filename;
   971     ofn.lpstrFile = pFdd->filename;
   972     ofn.lpstrInitialDir = pFdd->directory;
   972     ofn.lpstrInitialDir = pFdd->directory;
   975     ofn.lpstrFilter = pFdd->filter;
   975     ofn.lpstrFilter = pFdd->filter;
   976     ofn.nFilterIndex = pFdd->filterIndex;
   976     ofn.nFilterIndex = pFdd->filterIndex;
   977     ofn.hwndOwner = pFdd->owningWindow;
   977     ofn.hwndOwner = pFdd->owningWindow;
   978 
   978 
   979     if (pFdd->trueForSave) {
   979     if (pFdd->trueForSave) {
   980             ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
   980 	    ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
   981             hasResult = GetSaveFileNameW(&ofn);
   981 	    hasResult = GetSaveFileNameW(&ofn);
   982     } else {
   982     } else {
   983                 if (pFdd->trueForMultiSelect) {
   983 		if (pFdd->trueForMultiSelect) {
   984                         ofn.Flags = OFN_EXPLORER | OFN_ALLOWMULTISELECT;
   984 			ofn.Flags = OFN_EXPLORER | OFN_ALLOWMULTISELECT;
   985                 } else {
   985 		} else {
   986                         ofn.Flags = OFN_FILEMUSTEXIST;
   986 			ofn.Flags = OFN_FILEMUSTEXIST;
   987                 }
   987 		}
   988                 
   988 
   989             hasResult = GetOpenFileNameW(&ofn);
   989 	    hasResult = GetOpenFileNameW(&ofn);
   990     }
   990     }
   991 
   991 
   992     if (!hasResult) {
   992     if (!hasResult) {
   993             ZeroMemory(&pFdd->filename, sizeof(pFdd->filename));
   993 	    ZeroMemory(&pFdd->filename, sizeof(pFdd->filename));
   994     }
   994     }
   995 
   995 
   996     pFdd->fileDialogDidReturn = TRUE;
   996     pFdd->fileDialogDidReturn = TRUE;
   997 
   997 
   998     return 0;
   998     return 0;
   999 }
   999 }
  1000 
  1000 
  1001 HANDLE openFileDialogInNewThread(fileDialogData *pFdd) {
  1001 HANDLE openFileDialogInNewThread(fileDialogData *pFdd) {
  1002     HANDLE fileDialogThread = CreateThread(NULL, 0, OpenFileDialog, pFdd, 0, NULL);
  1002     HANDLE fileDialogThread = CreateThread(NULL, 0, OpenFileDialog, pFdd, 0, NULL);
  1003     if (fileDialogThread == INVALID_HANDLE_VALUE) {
  1003     if (fileDialogThread == INVALID_HANDLE_VALUE) {
  1004             printf("error: could not create thread for native file dialog: %d\n", GetLastError());
  1004 	    printf("error: could not create thread for native file dialog: %d\n", GetLastError());
  1005     }
  1005     }
  1006 
  1006 
  1007     return fileDialogThread;
  1007     return fileDialogThread;
  1008 }
  1008 }
  1009 
  1009 
  1010 BOOL CALLBACK enumWindowsToFindAndDestroyFileDialogProc(HWND hwnd, LPARAM fileDialogThreadId) {
  1010 BOOL CALLBACK enumWindowsToFindAndDestroyFileDialogProc(HWND hwnd, LPARAM fileDialogThreadId) {
  1011     if (GetWindowThreadProcessId(hwnd, NULL) == (DWORD)fileDialogThreadId) {
  1011     if (GetWindowThreadProcessId(hwnd, NULL) == (DWORD)fileDialogThreadId) {
  1012         EndDialog(hwnd, 0);
  1012 	EndDialog(hwnd, 0);
  1013         DestroyWindow(hwnd);
  1013 	DestroyWindow(hwnd);
  1014     }
  1014     }
  1015 
  1015 
  1016     return TRUE;
  1016     return TRUE;
  1017 };  
  1017 };
  1018 
  1018 
  1019 %}
  1019 %}
  1020 ! !
  1020 ! !
  1021 
  1021 
  1022 !WinWorkstation primitiveVariables!
  1022 !WinWorkstation primitiveVariables!
  1173 static void __debugEvent__() {}
  1173 static void __debugEvent__() {}
  1174 
  1174 
  1175 #ifdef DEBUGMASK
  1175 #ifdef DEBUGMASK
  1176 static void
  1176 static void
  1177 printMask(int mask) {
  1177 printMask(int mask) {
  1178         if (mask & KeyPressMask)        console_printf("KeyPressMask\n");
  1178 	if (mask & KeyPressMask)        console_printf("KeyPressMask\n");
  1179         if (mask & KeyReleaseMask)      console_printf("KeyReleaseMask\n");
  1179 	if (mask & KeyReleaseMask)      console_printf("KeyReleaseMask\n");
  1180         if (mask & ButtonPressMask)     console_printf("ButtonPressMask\n");
  1180 	if (mask & ButtonPressMask)     console_printf("ButtonPressMask\n");
  1181         if (mask & ButtonReleaseMask)   console_printf("ButtonReleaseMask\n");
  1181 	if (mask & ButtonReleaseMask)   console_printf("ButtonReleaseMask\n");
  1182         if (mask & ButtonMotionMask)    console_printf("ButtonMotionMask\n");
  1182 	if (mask & ButtonMotionMask)    console_printf("ButtonMotionMask\n");
  1183         if (mask & PointerMotionMask)   console_printf("PointerMotionMask\n");
  1183 	if (mask & PointerMotionMask)   console_printf("PointerMotionMask\n");
  1184         if (mask & ExposureMask)        console_printf("ExposureMask\n");
  1184 	if (mask & ExposureMask)        console_printf("ExposureMask\n");
  1185         if (mask & FocusChangeMask)     console_printf("FocusChangeMask\n");
  1185 	if (mask & FocusChangeMask)     console_printf("FocusChangeMask\n");
  1186         if (mask & EnterWindowMask)     console_printf("EnterWindowMask\n");
  1186 	if (mask & EnterWindowMask)     console_printf("EnterWindowMask\n");
  1187         if (mask & LeaveWindowMask)     console_printf("LeaveWindowMask\n");
  1187 	if (mask & LeaveWindowMask)     console_printf("LeaveWindowMask\n");
  1188         if (mask & KeymapStateMask)     console_printf("KeymapStateMask\n");
  1188 	if (mask & KeymapStateMask)     console_printf("KeymapStateMask\n");
  1189         if (mask & VisibilityChangeMask)console_printf("VisibilityChangeMask\n");
  1189 	if (mask & VisibilityChangeMask)console_printf("VisibilityChangeMask\n");
  1190         if (mask & StructureNotifyMask) console_printf("StructureNotifyMask\n");
  1190 	if (mask & StructureNotifyMask) console_printf("StructureNotifyMask\n");
  1191         if (mask & ResizeRedirectMask)  console_printf("ResizeRedirectMask\n");
  1191 	if (mask & ResizeRedirectMask)  console_printf("ResizeRedirectMask\n");
  1192         if (mask & PropertyChangeMask)  console_printf("PropertyChangeMask\n");
  1192 	if (mask & PropertyChangeMask)  console_printf("PropertyChangeMask\n");
  1193         if (mask & ColormapChangeMask)  console_printf("ColormapChangeMask\n");
  1193 	if (mask & ColormapChangeMask)  console_printf("ColormapChangeMask\n");
  1194 }
  1194 }
  1195 #endif
  1195 #endif
  1196 
  1196 
  1197 static int
  1197 static int
  1198 st2RGB(int color, struct gcData *gcData)
  1198 st2RGB(int color, struct gcData *gcData)
  1199 {
  1199 {
  1200         if (gcData && gcData->bitmapColorBitCount == 1) {
  1200 	if (gcData && gcData->bitmapColorBitCount == 1) {
  1201             return (color ? WhitePixel : BlackPixel);
  1201 	    return (color ? WhitePixel : BlackPixel);
  1202         }
  1202 	}
  1203 #ifdef ALWAYSTRUECOLOR
  1203 #ifdef ALWAYSTRUECOLOR
  1204         return (color & 0xffffff);
  1204 	return (color & 0xffffff);
  1205 #else
  1205 #else
  1206         if (__depth < 15) {
  1206 	if (__depth < 15) {
  1207             return 0;
  1207 	    return 0;
  1208         } else {
  1208 	} else {
  1209             if ((__depth == 16) || (__depth == 15)) {
  1209 	    if ((__depth == 16) || (__depth == 15)) {
  1210                 int ib = (color & 0x1f) << 3;
  1210 		int ib = (color & 0x1f) << 3;
  1211                 int ig = ((color >> 5) & 0x3f) << 2;
  1211 		int ig = ((color >> 5) & 0x3f) << 2;
  1212                 int ir = ((color >> 11) & 0x1f) << 3;
  1212 		int ir = ((color >> 11) & 0x1f) << 3;
  1213                 ir |= 7;
  1213 		ir |= 7;
  1214                 ig |= 3;
  1214 		ig |= 3;
  1215                 ib |= 7;
  1215 		ib |= 7;
  1216                 return RGB(ir,ig,ib);
  1216 		return RGB(ir,ig,ib);
  1217             }
  1217 	    }
  1218             return (color & 0xffffff);
  1218 	    return (color & 0xffffff);
  1219         }
  1219 	}
  1220 #endif
  1220 #endif
  1221 }
  1221 }
  1222 
  1222 
  1223 static int
  1223 static int
  1224 RGB2st(int r, int g, int b)
  1224 RGB2st(int r, int g, int b)
  1225 {
  1225 {
  1226         int ir,ig,ib,id;
  1226 	int ir,ig,ib,id;
  1227 
  1227 
  1228 #ifdef ALWAYSTRUECOLOR
  1228 #ifdef ALWAYSTRUECOLOR
  1229         ir = (r >> 8) & 0xff;
  1229 	ir = (r >> 8) & 0xff;
  1230         ig = (g >> 8) & 0xff;
  1230 	ig = (g >> 8) & 0xff;
  1231         ib = (b >> 8) & 0xff;
  1231 	ib = (b >> 8) & 0xff;
  1232 
  1232 
  1233         id = RGB( ir, ig, ib);
  1233 	id = RGB( ir, ig, ib);
  1234 #else
  1234 #else
  1235         if (__depth < 15) {
  1235 	if (__depth < 15) {
  1236             id = 0;
  1236 	    id = 0;
  1237         } else {
  1237 	} else {
  1238             if ((__depth == 16) || (__depth == 15)) {
  1238 	    if ((__depth == 16) || (__depth == 15)) {
  1239                 ir = (r >> 11) & 0x1f;
  1239 		ir = (r >> 11) & 0x1f;
  1240                 ig = (g >> 10) & 0x3f;
  1240 		ig = (g >> 10) & 0x3f;
  1241                 ib = (b >> 11) & 0x1f;
  1241 		ib = (b >> 11) & 0x1f;
  1242 
  1242 
  1243                 id = ( ir << 11 ) | ( ig << 5 ) | ib;
  1243 		id = ( ir << 11 ) | ( ig << 5 ) | ib;
  1244             } else {
  1244 	    } else {
  1245                 ir = (r >> 8) & 0xff;
  1245 		ir = (r >> 8) & 0xff;
  1246                 ig = (g >> 8) & 0xff;
  1246 		ig = (g >> 8) & 0xff;
  1247                 ib = (b >> 8) & 0xff;
  1247 		ib = (b >> 8) & 0xff;
  1248 
  1248 
  1249                 id = RGB( ir, ig, ib);
  1249 		id = RGB( ir, ig, ib);
  1250             }
  1250 	    }
  1251         }
  1251 	}
  1252 #endif
  1252 #endif
  1253         return id;
  1253 	return id;
  1254 }
  1254 }
  1255 
  1255 
  1256 #if 0
  1256 #if 0
  1257 /*
  1257 /*
  1258  * return a windows top-window
  1258  * return a windows top-window
  1259  */
  1259  */
  1260 static HWND
  1260 static HWND
  1261 GetTopParent(HWND hwnd)
  1261 GetTopParent(HWND hwnd)
  1262 {
  1262 {
  1263         HWND lastParent = hWnd;
  1263 	HWND lastParent = hWnd;
  1264         HWND nextParent;
  1264 	HWND nextParent;
  1265 
  1265 
  1266         while (nextParent = GetParent(lastParent)) {
  1266 	while (nextParent = GetParent(lastParent)) {
  1267             lastParent = nextParent;
  1267 	    lastParent = nextParent;
  1268         }
  1268 	}
  1269         return lastParent;
  1269 	return lastParent;
  1270 }
  1270 }
  1271 #endif
  1271 #endif
  1272 
  1272 
  1273 #ifdef DEBUG_DELETEOBJECT
  1273 #ifdef DEBUG_DELETEOBJECT
  1274 
  1274 
  1276 _DeleteObject(HANDLE o, int lineNr)
  1276 _DeleteObject(HANDLE o, int lineNr)
  1277 {
  1277 {
  1278     int r = DeleteObject(o);
  1278     int r = DeleteObject(o);
  1279 
  1279 
  1280     if (r == 0)
  1280     if (r == 0)
  1281         console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteObject %x [%d]\n", o, lineNr);
  1281 	console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteObject %x [%d]\n", o, lineNr);
  1282     return r;
  1282     return r;
  1283 }
  1283 }
  1284 
  1284 
  1285 #else
  1285 #else
  1286 # define _DeleteObject(o,lnr)  DeleteObject(o)
  1286 # define _DeleteObject(o,lnr)  DeleteObject(o)
  1289 static void
  1289 static void
  1290 _DeleteFont(HFONT f, int lineNr)
  1290 _DeleteFont(HFONT f, int lineNr)
  1291 {
  1291 {
  1292 #ifdef CACHE_LAST_TMP_FONT
  1292 #ifdef CACHE_LAST_TMP_FONT
  1293     if (f == __tmpDC_hfont) {
  1293     if (f == __tmpDC_hfont) {
  1294         SelectObject(__tmpDC, __tmpDC_prev_hfont);
  1294 	SelectObject(__tmpDC, __tmpDC_prev_hfont);
  1295         __tmpDC_hfont = NULL;
  1295 	__tmpDC_hfont = NULL;
  1296     }
  1296     }
  1297 #endif
  1297 #endif
  1298     _DeleteObject(f, lineNr);
  1298     _DeleteObject(f, lineNr);
  1299 }
  1299 }
  1300 
  1300 
  1301 static int
  1301 static int
  1302 _DeleteBrush(HBRUSH br, int lineNr)
  1302 _DeleteBrush(HBRUSH br, int lineNr)
  1303 {
  1303 {
  1304     if ((br != __whiteBrush) && (br != __blackBrush)) {
  1304     if ((br != __whiteBrush) && (br != __blackBrush)) {
  1305         int r = DeleteObject(br);
  1305 	int r = DeleteObject(br);
  1306 
  1306 
  1307         if (r == 0)
  1307 	if (r == 0)
  1308             console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteBrush %x [%d]\n", br, lineNr);
  1308 	    console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteBrush %x [%d]\n", br, lineNr);
  1309         return r;
  1309 	return r;
  1310     }
  1310     }
  1311     return 1;
  1311     return 1;
  1312 }
  1312 }
  1313 
  1313 
  1314 static int
  1314 static int
  1315 _DeletePen(HPEN p, int lineNr)
  1315 _DeletePen(HPEN p, int lineNr)
  1316 {
  1316 {
  1317     if ((p != __whitePen) && (p != __blackPen)) {
  1317     if ((p != __whitePen) && (p != __blackPen)) {
  1318         int r = DeleteObject(p);
  1318 	int r = DeleteObject(p);
  1319 
  1319 
  1320         if (r == 0)
  1320 	if (r == 0)
  1321             console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeletePen %x [%d]\n", p, lineNr);
  1321 	    console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeletePen %x [%d]\n", p, lineNr);
  1322         return r;
  1322 	return r;
  1323     }
  1323     }
  1324     return 1;
  1324     return 1;
  1325 }
  1325 }
  1326 
  1326 
  1327 #ifdef CACHE_PEN
  1327 #ifdef CACHE_PEN
  1330 _DeletePenIfNotInCache(HPEN p, int lineNr)
  1330 _DeletePenIfNotInCache(HPEN p, int lineNr)
  1331 {
  1331 {
  1332     int i, r;
  1332     int i, r;
  1333 
  1333 
  1334     if ((p == __whitePen) || (p == __blackPen)) {
  1334     if ((p == __whitePen) || (p == __blackPen)) {
  1335         return 1; /* not deleted, but OK */
  1335 	return 1; /* not deleted, but OK */
  1336     }
  1336     }
  1337     for (i=0; i<NUM_PEN_CACHED;i++) {
  1337     for (i=0; i<NUM_PEN_CACHED;i++) {
  1338         if (__penCache[i].pen == p) {
  1338 	if (__penCache[i].pen == p) {
  1339             return 1; /* not deleted, but OK */
  1339 	    return 1; /* not deleted, but OK */
  1340         }
  1340 	}
  1341     }
  1341     }
  1342     r = DeleteObject(p);
  1342     r = DeleteObject(p);
  1343 
  1343 
  1344     if (r == 0)
  1344     if (r == 0)
  1345         console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeletePen2 %x [%d]\n", p, lineNr);
  1345 	console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeletePen2 %x [%d]\n", p, lineNr);
  1346     return r;
  1346     return r;
  1347 }
  1347 }
  1348 
  1348 
  1349 #else
  1349 #else
  1350 # define _DeletePenIfNotInCache(p, lineNr)   _DeletePen(p, lineNr)
  1350 # define _DeletePenIfNotInCache(p, lineNr)   _DeletePen(p, lineNr)
  1356 _DeleteBrushIfNotInCache(HBRUSH br, int lineNr)
  1356 _DeleteBrushIfNotInCache(HBRUSH br, int lineNr)
  1357 {
  1357 {
  1358     int i, r;
  1358     int i, r;
  1359 
  1359 
  1360     for (i=0; i<NUM_BRUSH_CACHED;i++) {
  1360     for (i=0; i<NUM_BRUSH_CACHED;i++) {
  1361         if (__brushCache[i].brush == br) {
  1361 	if (__brushCache[i].brush == br) {
  1362             return 1; /* not deleted, but OK */
  1362 	    return 1; /* not deleted, but OK */
  1363         }
  1363 	}
  1364     }
  1364     }
  1365     if ((br == __whiteBrush) || (br == __blackBrush)) {
  1365     if ((br == __whiteBrush) || (br == __blackBrush)) {
  1366         return 1; /* not deleted, but OK */
  1366 	return 1; /* not deleted, but OK */
  1367     }
  1367     }
  1368     r = DeleteObject(br);
  1368     r = DeleteObject(br);
  1369 
  1369 
  1370     if (r == 0)
  1370     if (r == 0)
  1371         console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteBrush2 %x [%d]\n", br, lineNr);
  1371 	console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteBrush2 %x [%d]\n", br, lineNr);
  1372     return r;
  1372     return r;
  1373 }
  1373 }
  1374 
  1374 
  1375 #else
  1375 #else
  1376 # define _DeleteBrushIfNotInCache(br, lineNr)   _DeleteBrush(br, lineNr)
  1376 # define _DeleteBrushIfNotInCache(br, lineNr)   _DeleteBrush(br, lineNr)
  1380 newGcData(void)
  1380 newGcData(void)
  1381 {
  1381 {
  1382     struct gcData *gcData;
  1382     struct gcData *gcData;
  1383 
  1383 
  1384     if (gcDataFreeList) {
  1384     if (gcDataFreeList) {
  1385         gcData = gcDataFreeList;
  1385 	gcData = gcDataFreeList;
  1386         gcDataFreeList = gcData->u.__nextFree;
  1386 	gcDataFreeList = gcData->u.__nextFree;
  1387         gcDataNumFree--;
  1387 	gcDataNumFree--;
  1388     } else {
  1388     } else {
  1389         gcData = (struct gcData *) malloc(sizeof(struct gcData));
  1389 	gcData = (struct gcData *) malloc(sizeof(struct gcData));
  1390         if (! gcData) {
  1390 	if (! gcData) {
  1391             console_fprintf(stderr, "WinWorkstat [warning]: failed to allocate gcData\n");
  1391 	    console_fprintf(stderr, "WinWorkstat [warning]: failed to allocate gcData\n");
  1392             return 0;
  1392 	    return 0;
  1393         }
  1393 	}
  1394     }
  1394     }
  1395 
  1395 
  1396     memset(gcData, 0, sizeof(struct gcData));
  1396     memset(gcData, 0, sizeof(struct gcData));
  1397     gcData->fgColor = 0xffffff;
  1397     gcData->fgColor = 0xffffff;
  1398     /* gcData->bgColor = 0; - not needed - memset does it */
  1398     /* gcData->bgColor = 0; - not needed - memset does it */
  1409 
  1409 
  1410 static void
  1410 static void
  1411 freeGcData(struct gcData *gcData)
  1411 freeGcData(struct gcData *gcData)
  1412 {
  1412 {
  1413     if (gcDataNumFree < NUM_FREE_GC) {
  1413     if (gcDataNumFree < NUM_FREE_GC) {
  1414         gcData->u.__nextFree = gcDataFreeList;
  1414 	gcData->u.__nextFree = gcDataFreeList;
  1415         gcDataFreeList = gcData;
  1415 	gcDataFreeList = gcData;
  1416         gcDataNumFree++;
  1416 	gcDataNumFree++;
  1417     } else {
  1417     } else {
  1418         free(gcData);
  1418 	free(gcData);
  1419     }
  1419     }
  1420 }
  1420 }
  1421 
  1421 
  1422 #ifdef CACHE_LAST_DC
  1422 #ifdef CACHE_LAST_DC
  1423 # define FLUSH_CACHED_DC(__gcData__) \
  1423 # define FLUSH_CACHED_DC(__gcData__) \
  1424     if (lastGcData == __gcData__) {  \
  1424     if (lastGcData == __gcData__) {  \
  1425         _releaseDC(lastGcData);      \
  1425 	_releaseDC(lastGcData);      \
  1426     }
  1426     }
  1427 #else
  1427 #else
  1428 # define FLUSH_CACHED_DC(x)     /* */
  1428 # define FLUSH_CACHED_DC(x)     /* */
  1429 #endif
  1429 #endif
  1430 
  1430 
  1431 #ifdef CACHE_LAST_PEN
  1431 #ifdef CACHE_LAST_PEN
  1432 # define FLUSH_CACHED_PEN(__gcData__) \
  1432 # define FLUSH_CACHED_PEN(__gcData__) \
  1433     if (__gcData__->hPen) {           \
  1433     if (__gcData__->hPen) {           \
  1434         if (__gcData__->save_hPen) {  \
  1434 	if (__gcData__->save_hPen) {  \
  1435             SelectObject(__gcData__->_hDC, __gcData__->save_hPen); \
  1435 	    SelectObject(__gcData__->_hDC, __gcData__->save_hPen); \
  1436             __gcData__->save_hPen = 0;   \
  1436 	    __gcData__->save_hPen = 0;   \
  1437         } \
  1437 	} \
  1438         _DeletePenIfNotInCache(__gcData__->hPen, __LINE__); \
  1438 	_DeletePenIfNotInCache(__gcData__->hPen, __LINE__); \
  1439         __gcData__->hPen = 0; \
  1439 	__gcData__->hPen = 0; \
  1440     }
  1440     }
  1441 #else
  1441 #else
  1442 # define FLUSH_CACHED_PEN(x)    /* */
  1442 # define FLUSH_CACHED_PEN(x)    /* */
  1443 #endif
  1443 #endif
  1444 
  1444 
  1445 #ifdef CACHE_LAST_BRUSH
  1445 #ifdef CACHE_LAST_BRUSH
  1446 # define FLUSH_CACHED_BRUSH(__gcData__) \
  1446 # define FLUSH_CACHED_BRUSH(__gcData__) \
  1447     if (__gcData__->hBrush) {           \
  1447     if (__gcData__->hBrush) {           \
  1448         if (__gcData__->save_hBrush) {  \
  1448 	if (__gcData__->save_hBrush) {  \
  1449             SelectObject(__gcData__->_hDC, __gcData__->save_hBrush); \
  1449 	    SelectObject(__gcData__->_hDC, __gcData__->save_hBrush); \
  1450             __gcData__->save_hBrush = 0;   \
  1450 	    __gcData__->save_hBrush = 0;   \
  1451         } \
  1451 	} \
  1452         _DeleteBrushIfNotInCache(__gcData__->hBrush, __LINE__); \
  1452 	_DeleteBrushIfNotInCache(__gcData__->hBrush, __LINE__); \
  1453         __gcData__->hBrush = 0; \
  1453 	__gcData__->hBrush = 0; \
  1454     }
  1454     }
  1455 #else
  1455 #else
  1456 # define FLUSH_CACHED_BRUSH(x)    /* */
  1456 # define FLUSH_CACHED_BRUSH(x)    /* */
  1457 #endif
  1457 #endif
  1458 
  1458 
  1460 _releaseDC(struct gcData *gcData)
  1460 _releaseDC(struct gcData *gcData)
  1461 {
  1461 {
  1462     HDC hDC = gcData->_hDC;
  1462     HDC hDC = gcData->_hDC;
  1463 
  1463 
  1464     if (gcData->doNotCacheOrRelease ) {
  1464     if (gcData->doNotCacheOrRelease ) {
  1465         return;
  1465 	return;
  1466     }
  1466     }
  1467 
  1467 
  1468     if (gcData->save_hPen) {
  1468     if (gcData->save_hPen) {
  1469         SelectObject(hDC, gcData->save_hPen);
  1469 	SelectObject(hDC, gcData->save_hPen);
  1470         gcData->save_hPen = 0;
  1470 	gcData->save_hPen = 0;
  1471     }
  1471     }
  1472     if (gcData->save_hBrush) {
  1472     if (gcData->save_hBrush) {
  1473         SelectObject(hDC, gcData->save_hBrush);
  1473 	SelectObject(hDC, gcData->save_hBrush);
  1474         gcData->save_hBrush = 0;
  1474 	gcData->save_hBrush = 0;
  1475     }
  1475     }
  1476     if (gcData->save_hFont) {
  1476     if (gcData->save_hFont) {
  1477         SelectObject(hDC, gcData->save_hFont);
  1477 	SelectObject(hDC, gcData->save_hFont);
  1478         gcData->save_hFont = 0;
  1478 	gcData->save_hFont = 0;
  1479     }
  1479     }
  1480 
  1480 
  1481     if (gcData->hWnd) {
  1481     if (gcData->hWnd) {
  1482         if (hDC) {
  1482 	if (hDC) {
  1483             ReleaseDC(gcData->hWnd, hDC);
  1483 	    ReleaseDC(gcData->hWnd, hDC);
  1484 #ifdef CACHE_LAST_WM_PAINT_DC
  1484 #ifdef CACHE_LAST_WM_PAINT_DC
  1485             if (hDC == last_wm_paint_dc) {
  1485 	    if (hDC == last_wm_paint_dc) {
  1486                 last_wm_paint_dc = last_wm_paint_win = 0;
  1486 		last_wm_paint_dc = last_wm_paint_win = 0;
  1487 # ifdef DEBUG_DC_REUSE
  1487 # ifdef DEBUG_DC_REUSE
  1488                 console_fprintf(stderr, "WinWorkstation [info]: Oops - releasing bg_paint-dc\n");
  1488 		console_fprintf(stderr, "WinWorkstation [info]: Oops - releasing bg_paint-dc\n");
  1489 # endif
  1489 # endif
  1490             }
  1490 	    }
  1491 #endif
  1491 #endif
  1492         }
  1492 	}
  1493     } else if (gcData->hBitmap) {
  1493     } else if (gcData->hBitmap) {
  1494         SelectObject(hDC, gcData->save_hBitmap);
  1494 	SelectObject(hDC, gcData->save_hBitmap);
  1495         DeleteDC(hDC);
  1495 	DeleteDC(hDC);
  1496     }
  1496     }
  1497     gcData->_hDC = 0;
  1497     gcData->_hDC = 0;
  1498 
  1498 
  1499 #ifdef CACHE_LAST_DC
  1499 #ifdef CACHE_LAST_DC
  1500     if (lastGcData == gcData) {
  1500     if (lastGcData == gcData) {
  1501         lastGcData = 0;
  1501 	lastGcData = 0;
  1502     }
  1502     }
  1503 #endif
  1503 #endif
  1504 #ifdef CACHE_LAST_PEN
  1504 #ifdef CACHE_LAST_PEN
  1505     if (gcData->hPen) {
  1505     if (gcData->hPen) {
  1506         _DeletePenIfNotInCache(gcData->hPen, __LINE__);
  1506 	_DeletePenIfNotInCache(gcData->hPen, __LINE__);
  1507         gcData->hPen = 0;
  1507 	gcData->hPen = 0;
  1508     }
  1508     }
  1509 #endif
  1509 #endif
  1510 #ifdef CACHE_LAST_BRUSH
  1510 #ifdef CACHE_LAST_BRUSH
  1511     if (gcData->hBrush) {
  1511     if (gcData->hBrush) {
  1512         _DeleteBrushIfNotInCache(gcData->hBrush, __LINE__);
  1512 	_DeleteBrushIfNotInCache(gcData->hBrush, __LINE__);
  1513         gcData->hBrush = 0;
  1513 	gcData->hBrush = 0;
  1514     }
  1514     }
  1515 #endif
  1515 #endif
  1516 }
  1516 }
  1517 
  1517 
  1518 static HDC
  1518 static HDC
  1520 {
  1520 {
  1521     HDC hDC;
  1521     HDC hDC;
  1522     int currThreadId;
  1522     int currThreadId;
  1523 
  1523 
  1524     if (gcData->doNotCacheOrRelease ) {
  1524     if (gcData->doNotCacheOrRelease ) {
  1525         return gcData->_hDC;
  1525 	return gcData->_hDC;
  1526     }
  1526     }
  1527 
  1527 
  1528 #ifdef CACHE_LAST_DC
  1528 #ifdef CACHE_LAST_DC
  1529     currThreadId = GetCurrentThreadId();
  1529     currThreadId = GetCurrentThreadId();
  1530 
  1530 
  1531     if (lastGcData) {
  1531     if (lastGcData) {
  1532         if ((lastGcData == gcData)
  1532 	if ((lastGcData == gcData)
  1533          && (lastGcHWIN == gcData->hWnd)
  1533 	 && (lastGcHWIN == gcData->hWnd)
  1534          && (lastGcHBITMAP == gcData->hBitmap)
  1534 	 && (lastGcHBITMAP == gcData->hBitmap)
  1535          && (lastGcOwnerThreadID == currThreadId)
  1535 	 && (lastGcOwnerThreadID == currThreadId)
  1536          && gcData->_hDC
  1536 	 && gcData->_hDC
  1537         ) {
  1537 	) {
  1538 # ifdef CACHE_LAST_WM_PAINT_DC /* DDD */
  1538 # ifdef CACHE_LAST_WM_PAINT_DC /* DDD */
  1539             if (last_wm_paint_dc == gcData->_hDC) {
  1539 	    if (last_wm_paint_dc == gcData->_hDC) {
  1540 #  ifdef DEBUG_DC_REUSE
  1540 #  ifdef DEBUG_DC_REUSE
  1541                 console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
  1541 		console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
  1542 #  endif
  1542 #  endif
  1543                 last_wm_paint_dc = last_wm_paint_win = 0;
  1543 		last_wm_paint_dc = last_wm_paint_win = 0;
  1544             }
  1544 	    }
  1545 # endif
  1545 # endif
  1546             return gcData->_hDC;
  1546 	    return gcData->_hDC;
  1547         }
  1547 	}
  1548 
  1548 
  1549         _releaseDC(lastGcData);
  1549 	_releaseDC(lastGcData);
  1550         lastGcData = 0;
  1550 	lastGcData = 0;
  1551     }
  1551     }
  1552 #endif
  1552 #endif
  1553 
  1553 
  1554     hDC = 0;
  1554     hDC = 0;
  1555     if (gcData->hWnd != 0) {
  1555     if (gcData->hWnd != 0) {
  1556         if (gcData->hWnd == __rootWin) {
  1556 	if (gcData->hWnd == __rootWin) {
  1557             hDC = gcData->_hDC = GetDCEx(gcData->hWnd, 0, DCX_WINDOW);
  1557 	    hDC = gcData->_hDC = GetDCEx(gcData->hWnd, 0, DCX_WINDOW);
  1558         } else if (gcData->clipByChildren) {
  1558 	} else if (gcData->clipByChildren) {
  1559             //gcData->_hDC = GetDCEx(gcData->hWnd, 0, DCX_CLIPCHILDREN);
  1559 	    //gcData->_hDC = GetDCEx(gcData->hWnd, 0, DCX_CLIPCHILDREN);
  1560             hDC = gcData->_hDC = GetDC(gcData->hWnd);
  1560 	    hDC = gcData->_hDC = GetDC(gcData->hWnd);
  1561         } else  {
  1561 	} else  {
  1562             hDC = gcData->_hDC = GetDCEx(gcData->hWnd, 0, DCX_PARENTCLIP);
  1562 	    hDC = gcData->_hDC = GetDCEx(gcData->hWnd, 0, DCX_PARENTCLIP);
  1563         }
  1563 	}
  1564     } else if (gcData->hBitmap) {
  1564     } else if (gcData->hBitmap) {
  1565         hDC = gcData->_hDC = CreateCompatibleDC(__tmpDC);
  1565 	hDC = gcData->_hDC = CreateCompatibleDC(__tmpDC);
  1566         gcData->save_hBitmap = SelectObject(gcData->_hDC,gcData->hBitmap);
  1566 	gcData->save_hBitmap = SelectObject(gcData->_hDC,gcData->hBitmap);
  1567     }
  1567     }
  1568     gcData->bkMode = BK_UNDEF;
  1568     gcData->bkMode = BK_UNDEF;
  1569 
  1569 
  1570     if (hDC) {
  1570     if (hDC) {
  1571         SetTextColor(hDC, gcData->fgColor);
  1571 	SetTextColor(hDC, gcData->fgColor);
  1572         SetBkColor(hDC, gcData->bgColor);
  1572 	SetBkColor(hDC, gcData->bgColor);
  1573 
  1573 
  1574         if (gcData->rop2)
  1574 	if (gcData->rop2)
  1575             SetROP2(hDC, gcData->rop2);
  1575 	    SetROP2(hDC, gcData->rop2);
  1576 
  1576 
  1577         if (gcData->clipping) {
  1577 	if (gcData->clipping) {
  1578             HRGN region = CreateRectRgn( gcData->clipX, gcData->clipY,
  1578 	    HRGN region = CreateRectRgn( gcData->clipX, gcData->clipY,
  1579                                          gcData->clipX + gcData->clipW,
  1579 					 gcData->clipX + gcData->clipW,
  1580                                          gcData->clipY + gcData->clipH);
  1580 					 gcData->clipY + gcData->clipH);
  1581             if (region == NULL ) {
  1581 	    if (region == NULL ) {
  1582                 console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
  1582 		console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
  1583             } else {
  1583 	    } else {
  1584                 if (SelectClipRgn(hDC, region) == ERROR ) {
  1584 		if (SelectClipRgn(hDC, region) == ERROR ) {
  1585                     DPRINTF(("WinWorkstat [warning]: select clipping region failed\n" ));
  1585 		    DPRINTF(("WinWorkstat [warning]: select clipping region failed\n" ));
  1586                 }
  1586 		}
  1587                 _DeleteObject(region, __LINE__);
  1587 		_DeleteObject(region, __LINE__);
  1588             }
  1588 	    }
  1589         } else {
  1589 	} else {
  1590             SelectClipRgn(hDC, NULL);
  1590 	    SelectClipRgn(hDC, NULL);
  1591         }
  1591 	}
  1592 
  1592 
  1593         if (gcData->hFont) {
  1593 	if (gcData->hFont) {
  1594             HFONT prevFont;
  1594 	    HFONT prevFont;
  1595 
  1595 
  1596             prevFont = SelectObject(hDC, gcData->hFont);
  1596 	    prevFont = SelectObject(hDC, gcData->hFont);
  1597             if (! gcData->save_hFont) {
  1597 	    if (! gcData->save_hFont) {
  1598                 gcData->save_hFont = prevFont;
  1598 		gcData->save_hFont = prevFont;
  1599             }
  1599 	    }
  1600         }
  1600 	}
  1601     }
  1601     }
  1602 
  1602 
  1603 #ifdef CACHE_LAST_DC
  1603 #ifdef CACHE_LAST_DC
  1604     lastGcData = gcData;
  1604     lastGcData = gcData;
  1605     lastGcOwnerThreadID = currThreadId;
  1605     lastGcOwnerThreadID = currThreadId;
  1609     gcData->_hDC = hDC;
  1609     gcData->_hDC = hDC;
  1610 
  1610 
  1611 # ifdef CACHE_LAST_WM_PAINT_DC /* DDD */
  1611 # ifdef CACHE_LAST_WM_PAINT_DC /* DDD */
  1612     if (last_wm_paint_dc == hDC) {
  1612     if (last_wm_paint_dc == hDC) {
  1613 #  ifdef DEBUG_DC_REUSE
  1613 #  ifdef DEBUG_DC_REUSE
  1614         console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
  1614 	console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
  1615 #  endif
  1615 #  endif
  1616         last_wm_paint_dc = last_wm_paint_win = 0;
  1616 	last_wm_paint_dc = last_wm_paint_win = 0;
  1617     }
  1617     }
  1618 # endif
  1618 # endif
  1619 #endif
  1619 #endif
  1620 
  1620 
  1621     return hDC;
  1621     return hDC;
  1627     HBRUSH hBrush = 0;
  1627     HBRUSH hBrush = 0;
  1628     HBRUSH prevBrush;
  1628     HBRUSH prevBrush;
  1629 
  1629 
  1630 #ifdef CACHE_LAST_BRUSH
  1630 #ifdef CACHE_LAST_BRUSH
  1631     if (hBrush = gcData->hBrush) {
  1631     if (hBrush = gcData->hBrush) {
  1632         if (! gcData->save_hBrush) {
  1632 	if (! gcData->save_hBrush) {
  1633             gcData->save_hBrush = SelectObject(gcData->_hDC, hBrush);
  1633 	    gcData->save_hBrush = SelectObject(gcData->_hDC, hBrush);
  1634         }
  1634 	}
  1635         return hBrush;
  1635 	return hBrush;
  1636     }
  1636     }
  1637 #endif
  1637 #endif
  1638     if (gcData->hMask) {
  1638     if (gcData->hMask) {
  1639         hBrush = CreatePatternBrush(gcData->hMask);
  1639 	hBrush = CreatePatternBrush(gcData->hMask);
  1640         SetBrushOrgEx(hDC, gcData->maskOrgX, gcData->maskOrgY, 0);
  1640 	SetBrushOrgEx(hDC, gcData->maskOrgX, gcData->maskOrgY, 0);
  1641         RESPRINTF(("CreatePatternBrush %x\n",gcData->hMask));
  1641 	RESPRINTF(("CreatePatternBrush %x\n",gcData->hMask));
  1642     } else {
  1642     } else {
  1643         if (gcData->fgColor == BlackPixel) {
  1643 	if (gcData->fgColor == BlackPixel) {
  1644             hBrush = __blackBrush;
  1644 	    hBrush = __blackBrush;
  1645         } else if (gcData->fgColor == WhitePixel) {
  1645 	} else if (gcData->fgColor == WhitePixel) {
  1646             hBrush = __whiteBrush;
  1646 	    hBrush = __whiteBrush;
  1647         } else {
  1647 	} else {
  1648 #ifdef CACHE_BRUSH
  1648 #ifdef CACHE_BRUSH
  1649             {
  1649 	    {
  1650                 int i;
  1650 		int i;
  1651 
  1651 
  1652                 for (i=0; i<NUM_BRUSH_CACHED; i++) {
  1652 		for (i=0; i<NUM_BRUSH_CACHED; i++) {
  1653                     if (__brushCache[i].clr == gcData->fgColor) {
  1653 		    if (__brushCache[i].clr == gcData->fgColor) {
  1654                         hBrush = __brushCache[i].brush;
  1654 			hBrush = __brushCache[i].brush;
  1655                         /*
  1655 			/*
  1656                          * move it up in the cache
  1656 			 * move it up in the cache
  1657                          */
  1657 			 */
  1658                         if (i > 0) {
  1658 			if (i > 0) {
  1659                             HBRUSH t = __brushCache[i-1].brush;
  1659 			    HBRUSH t = __brushCache[i-1].brush;
  1660                             int c = __brushCache[i-1].clr;
  1660 			    int c = __brushCache[i-1].clr;
  1661 
  1661 
  1662                             __brushCache[i-1].brush = hBrush;
  1662 			    __brushCache[i-1].brush = hBrush;
  1663                             __brushCache[i-1].clr = gcData->fgColor;
  1663 			    __brushCache[i-1].clr = gcData->fgColor;
  1664                             __brushCache[i].brush = t;
  1664 			    __brushCache[i].brush = t;
  1665                             __brushCache[i].clr = c;
  1665 			    __brushCache[i].clr = c;
  1666                         }
  1666 			}
  1667 # ifdef CACHE_LAST_BRUSH
  1667 # ifdef CACHE_LAST_BRUSH
  1668                         prevBrush = SelectObject(gcData->_hDC, hBrush);
  1668 			prevBrush = SelectObject(gcData->_hDC, hBrush);
  1669                         if (! gcData->save_hBrush) {
  1669 			if (! gcData->save_hBrush) {
  1670                             gcData->save_hBrush = prevBrush;
  1670 			    gcData->save_hBrush = prevBrush;
  1671                         }
  1671 			}
  1672                         gcData->hBrush = hBrush;
  1672 			gcData->hBrush = hBrush;
  1673 # endif
  1673 # endif
  1674                         return hBrush;
  1674 			return hBrush;
  1675                     }
  1675 		    }
  1676                 }
  1676 		}
  1677             }
  1677 	    }
  1678 #endif /* BRUSH_CACHE */
  1678 #endif /* BRUSH_CACHE */
  1679             hBrush = CreateSolidBrush(gcData->fgColor);
  1679 	    hBrush = CreateSolidBrush(gcData->fgColor);
  1680             RESPRINTF(("CreateSolidBrush %x\n",gcData->fgColor));
  1680 	    RESPRINTF(("CreateSolidBrush %x\n",gcData->fgColor));
  1681         }
  1681 	}
  1682     }
  1682     }
  1683     gcData->hBrush = hBrush;
  1683     gcData->hBrush = hBrush;
  1684 
  1684 
  1685     prevBrush = SelectObject(gcData->_hDC, hBrush);
  1685     prevBrush = SelectObject(gcData->_hDC, hBrush);
  1686     if (! gcData->save_hBrush) {
  1686     if (! gcData->save_hBrush) {
  1687         gcData->save_hBrush = prevBrush;
  1687 	gcData->save_hBrush = prevBrush;
  1688     }
  1688     }
  1689     return hBrush;
  1689     return hBrush;
  1690 }
  1690 }
  1691 
  1691 
  1692 #ifdef CACHE_LAST_BRUSH
  1692 #ifdef CACHE_LAST_BRUSH
  1696 GcDataReleaseBrush(HDC hDC, struct gcData *gcData)
  1696 GcDataReleaseBrush(HDC hDC, struct gcData *gcData)
  1697 {
  1697 {
  1698     HBRUSH hBrush = gcData->hBrush;
  1698     HBRUSH hBrush = gcData->hBrush;
  1699 
  1699 
  1700     if (gcData->save_hBrush) {
  1700     if (gcData->save_hBrush) {
  1701         SelectObject(hDC, gcData->save_hBrush);
  1701 	SelectObject(hDC, gcData->save_hBrush);
  1702         gcData->save_hBrush = NULL;
  1702 	gcData->save_hBrush = NULL;
  1703     }
  1703     }
  1704     _DeleteBrushIfNotInCache(hBrush, __LINE__);
  1704     _DeleteBrushIfNotInCache(hBrush, __LINE__);
  1705     gcData->hBrush = 0;
  1705     gcData->hBrush = 0;
  1706 }
  1706 }
  1707 #endif
  1707 #endif
  1714     LOGBRUSH Brush;
  1714     LOGBRUSH Brush;
  1715     int lw;
  1715     int lw;
  1716 
  1716 
  1717 #ifdef CACHE_LAST_PEN
  1717 #ifdef CACHE_LAST_PEN
  1718     if (hPen = gcData->hPen) {
  1718     if (hPen = gcData->hPen) {
  1719         if (! gcData->save_hPen) {
  1719 	if (! gcData->save_hPen) {
  1720             gcData->save_hPen = SelectObject(gcData->_hDC, hPen);
  1720 	    gcData->save_hPen = SelectObject(gcData->_hDC, hPen);
  1721         }
  1721 	}
  1722         return hPen;
  1722 	return hPen;
  1723     }
  1723     }
  1724 #endif
  1724 #endif
  1725 
  1725 
  1726     if (((gcData->lStyle & PS_STYLE_MASK) == PS_SOLID)
  1726     if (((gcData->lStyle & PS_STYLE_MASK) == PS_SOLID)
  1727      && (gcData->hMask == 0)
  1727      && (gcData->hMask == 0)
  1728      && (gcData->lineWidth <= 1)) {
  1728      && (gcData->lineWidth <= 1)) {
  1729         if (gcData->fgColor == BlackPixel) {
  1729 	if (gcData->fgColor == BlackPixel) {
  1730             gcData->hPen = hPen = __blackPen;
  1730 	    gcData->hPen = hPen = __blackPen;
  1731             prevPen = SelectObject(hDC, hPen);
  1731 	    prevPen = SelectObject(hDC, hPen);
  1732             if (! gcData->save_hPen) {
  1732 	    if (! gcData->save_hPen) {
  1733                 gcData->save_hPen = prevPen;
  1733 		gcData->save_hPen = prevPen;
  1734             }
  1734 	    }
  1735             return hPen;
  1735 	    return hPen;
  1736         }
  1736 	}
  1737         if (gcData->fgColor == WhitePixel) {
  1737 	if (gcData->fgColor == WhitePixel) {
  1738             gcData->hPen = hPen = __whitePen;
  1738 	    gcData->hPen = hPen = __whitePen;
  1739             prevPen = SelectObject(hDC, hPen);
  1739 	    prevPen = SelectObject(hDC, hPen);
  1740             if (! gcData->save_hPen) {
  1740 	    if (! gcData->save_hPen) {
  1741                 gcData->save_hPen = prevPen;
  1741 		gcData->save_hPen = prevPen;
  1742             }
  1742 	    }
  1743             return hPen;
  1743 	    return hPen;
  1744         }
  1744 	}
  1745 
  1745 
  1746 #ifdef CACHE_PEN
  1746 #ifdef CACHE_PEN
  1747         {
  1747 	{
  1748             int i;
  1748 	    int i;
  1749 
  1749 
  1750             for (i=0; i<NUM_PEN_CACHED; i++) {
  1750 	    for (i=0; i<NUM_PEN_CACHED; i++) {
  1751                 if (__penCache[i].clr == gcData->fgColor) {
  1751 		if (__penCache[i].clr == gcData->fgColor) {
  1752                     hPen = __penCache[i].pen;
  1752 		    hPen = __penCache[i].pen;
  1753                     /*
  1753 		    /*
  1754                      * move it up in the cache
  1754 		     * move it up in the cache
  1755                      */
  1755 		     */
  1756                     if (i > 0) {
  1756 		    if (i > 0) {
  1757                         HPEN t = __penCache[i-1].pen;
  1757 			HPEN t = __penCache[i-1].pen;
  1758                         int c = __penCache[i-1].clr;
  1758 			int c = __penCache[i-1].clr;
  1759 
  1759 
  1760                         __penCache[i-1].pen = hPen;
  1760 			__penCache[i-1].pen = hPen;
  1761                         __penCache[i-1].clr = gcData->fgColor;
  1761 			__penCache[i-1].clr = gcData->fgColor;
  1762                         __penCache[i].pen = t;
  1762 			__penCache[i].pen = t;
  1763                         __penCache[i].clr = c;
  1763 			__penCache[i].clr = c;
  1764                     }
  1764 		    }
  1765 
  1765 
  1766                     gcData->hPen = hPen;
  1766 		    gcData->hPen = hPen;
  1767                     prevPen = SelectObject(hDC, hPen);
  1767 		    prevPen = SelectObject(hDC, hPen);
  1768                     if (! gcData->save_hPen) {
  1768 		    if (! gcData->save_hPen) {
  1769                         gcData->save_hPen = prevPen;
  1769 			gcData->save_hPen = prevPen;
  1770                     }
  1770 		    }
  1771                     return hPen;
  1771 		    return hPen;
  1772                 }
  1772 		}
  1773             }
  1773 	    }
  1774         }
  1774 	}
  1775 #endif /* PEN_CACHE */
  1775 #endif /* PEN_CACHE */
  1776     }
  1776     }
  1777 
  1777 
  1778     hPen = (HPEN) 0;
  1778     hPen = (HPEN) 0;
  1779     lw = gcData->lineWidth;
  1779     lw = gcData->lineWidth;
  1780     if (lw == 0) {
  1780     if (lw == 0) {
  1781         lw = 1;
  1781 	lw = 1;
  1782     }
  1782     }
  1783 
  1783 
  1784     /*
  1784     /*
  1785      * NT supports masked drawing with any lineStyle,
  1785      * NT supports masked drawing with any lineStyle,
  1786      * and also non-solid lines with any lineWidth.
  1786      * and also non-solid lines with any lineWidth.
  1787      */
  1787      */
  1788     if (gcData->hMask) {
  1788     if (gcData->hMask) {
  1789         Brush.lbStyle = BS_PATTERN;
  1789 	Brush.lbStyle = BS_PATTERN;
  1790         Brush.lbHatch = (ULONG_PTR)(gcData->hMask);
  1790 	Brush.lbHatch = (ULONG_PTR)(gcData->hMask);
  1791         Brush.lbColor = gcData->fgColor;
  1791 	Brush.lbColor = gcData->fgColor;
  1792     } else {
  1792     } else {
  1793         Brush.lbStyle = BS_SOLID;
  1793 	Brush.lbStyle = BS_SOLID;
  1794         Brush.lbHatch = (ULONG_PTR)0;
  1794 	Brush.lbHatch = (ULONG_PTR)0;
  1795         Brush.lbColor = gcData->fgColor;
  1795 	Brush.lbColor = gcData->fgColor;
  1796 
  1796 
  1797         hPen = (HPEN) 0;
  1797 	hPen = (HPEN) 0;
  1798 
  1798 
  1799 #if USE_OLD_CREATE_PEN
  1799 #if USE_OLD_CREATE_PEN
  1800         hPen = CreatePen((gcData->lStyle & PS_STYLE_MASK), lw, gcData->fgColor);
  1800 	hPen = CreatePen((gcData->lStyle & PS_STYLE_MASK), lw, gcData->fgColor);
  1801 
  1801 
  1802         RESPRINTF(("CreatePen %x %d(%d) %x %x\n",
  1802 	RESPRINTF(("CreatePen %x %d(%d) %x %x\n",
  1803                     gcData->lStyle,
  1803 		    gcData->lStyle,
  1804                     lw, gcData->lineWidth,
  1804 		    lw, gcData->lineWidth,
  1805                     gcData->fgColor, gcData->hMask));
  1805 		    gcData->fgColor, gcData->hMask));
  1806 #endif
  1806 #endif
  1807 
  1807 
  1808         SetBkMode(hDC, TRANSPARENT);
  1808 	SetBkMode(hDC, TRANSPARENT);
  1809         gcData->bkMode = BK_TRANSPARENT;
  1809 	gcData->bkMode = BK_TRANSPARENT;
  1810 
  1810 
  1811         if (! hPen) {
  1811 	if (! hPen) {
  1812             hPen = ExtCreatePen(PS_GEOMETRIC | gcData->lStyle,
  1812 	    hPen = ExtCreatePen(PS_GEOMETRIC | gcData->lStyle,
  1813                             lw, /* gcData->lineWidth, */
  1813 			    lw, /* gcData->lineWidth, */
  1814                             &Brush,
  1814 			    &Brush,
  1815                             0, 0);
  1815 			    0, 0);
  1816 
  1816 
  1817             RESPRINTF(("ExtCreatePen1 %x %d(%d) %x %x\n",
  1817 	    RESPRINTF(("ExtCreatePen1 %x %d(%d) %x %x\n",
  1818                         gcData->lStyle,
  1818 			gcData->lStyle,
  1819                         lw, gcData->lineWidth,
  1819 			lw, gcData->lineWidth,
  1820                         gcData->fgColor, gcData->hMask));
  1820 			gcData->fgColor, gcData->hMask));
  1821 
  1821 
  1822             if (gcData->hMask) {
  1822 	    if (gcData->hMask) {
  1823                 SetBrushOrgEx(hDC, gcData->maskOrgX, gcData->maskOrgY, 0);
  1823 		SetBrushOrgEx(hDC, gcData->maskOrgX, gcData->maskOrgY, 0);
  1824             }
  1824 	    }
  1825         }
  1825 	}
  1826     }
  1826     }
  1827 
  1827 
  1828     gcData->hPen = hPen;
  1828     gcData->hPen = hPen;
  1829     prevPen = SelectObject(hDC, hPen);
  1829     prevPen = SelectObject(hDC, hPen);
  1830     if (! gcData->save_hPen) {
  1830     if (! gcData->save_hPen) {
  1831         gcData->save_hPen = prevPen;
  1831 	gcData->save_hPen = prevPen;
  1832     }
  1832     }
  1833 
  1833 
  1834 #ifdef CACHE_PEN
  1834 #ifdef CACHE_PEN
  1835     /*
  1835     /*
  1836      * remember in penCache
  1836      * remember in penCache
  1837      */
  1837      */
  1838     if (((gcData->lStyle & PS_STYLE_MASK) == PS_SOLID)
  1838     if (((gcData->lStyle & PS_STYLE_MASK) == PS_SOLID)
  1839      && (gcData->hMask == 0)
  1839      && (gcData->hMask == 0)
  1840      && (gcData->lineWidth <= 1)) {
  1840      && (gcData->lineWidth <= 1)) {
  1841         int i;
  1841 	int i;
  1842 
  1842 
  1843         /*
  1843 	/*
  1844          * search for an empty slot
  1844 	 * search for an empty slot
  1845          */
  1845 	 */
  1846         for (i=0; i<NUM_PEN_CACHED; i++) {
  1846 	for (i=0; i<NUM_PEN_CACHED; i++) {
  1847             if (__penCache[i].pen == 0) {
  1847 	    if (__penCache[i].pen == 0) {
  1848                 __penCache[i].clr = gcData->fgColor;
  1848 		__penCache[i].clr = gcData->fgColor;
  1849                 __penCache[i].pen = hPen;
  1849 		__penCache[i].pen = hPen;
  1850                 break;
  1850 		break;
  1851             }
  1851 	    }
  1852         }
  1852 	}
  1853         if (i == NUM_PEN_CACHED) {
  1853 	if (i == NUM_PEN_CACHED) {
  1854             /*
  1854 	    /*
  1855              * replace last in penCache
  1855 	     * replace last in penCache
  1856              */
  1856 	     */
  1857             HPEN t = __penCache[NUM_PEN_CACHED - 1].pen;
  1857 	    HPEN t = __penCache[NUM_PEN_CACHED - 1].pen;
  1858 
  1858 
  1859             __penCache[NUM_PEN_CACHED - 1].pen = hPen;
  1859 	    __penCache[NUM_PEN_CACHED - 1].pen = hPen;
  1860             __penCache[NUM_PEN_CACHED - 1].clr = gcData->fgColor;
  1860 	    __penCache[NUM_PEN_CACHED - 1].clr = gcData->fgColor;
  1861             _DeletePen(t, __LINE__);
  1861 	    _DeletePen(t, __LINE__);
  1862         }
  1862 	}
  1863     }
  1863     }
  1864 #endif
  1864 #endif
  1865 
  1865 
  1866     return hPen;
  1866     return hPen;
  1867 }
  1867 }
  1873 GcDataReleasePen(HDC hDC, struct gcData *gcData)
  1873 GcDataReleasePen(HDC hDC, struct gcData *gcData)
  1874 {
  1874 {
  1875     HPEN hPen;
  1875     HPEN hPen;
  1876 
  1876 
  1877     if (gcData->save_hPen) {
  1877     if (gcData->save_hPen) {
  1878         SelectObject(hDC, gcData->save_hPen);
  1878 	SelectObject(hDC, gcData->save_hPen);
  1879         gcData->save_hPen = NULL;
  1879 	gcData->save_hPen = NULL;
  1880     }
  1880     }
  1881     hPen = gcData->hPen;
  1881     hPen = gcData->hPen;
  1882     _DeletePenIfNotInCache(hPen, __LINE__);
  1882     _DeletePenIfNotInCache(hPen, __LINE__);
  1883     gcData->hPen = 0;
  1883     gcData->hPen = 0;
  1884 }
  1884 }
  1892     DWORD dwWaitResult = WaitForSingleObject(hEventsMutex, 5000L);
  1892     DWORD dwWaitResult = WaitForSingleObject(hEventsMutex, 5000L);
  1893 
  1893 
  1894 #ifdef LOCK_DEBUG
  1894 #ifdef LOCK_DEBUG
  1895     lockCountEvents++;
  1895     lockCountEvents++;
  1896     if (lockCountEvents != 1) {
  1896     if (lockCountEvents != 1) {
  1897         console_fprintf(stderr, "WinWorkstation [warning]: lockCountEvents (%d) != 1 in lock\n", lockCountEvents);
  1897 	console_fprintf(stderr, "WinWorkstation [warning]: lockCountEvents (%d) != 1 in lock\n", lockCountEvents);
  1898         lockCountEvents = 1;
  1898 	lockCountEvents = 1;
  1899     }
  1899     }
  1900 #endif
  1900 #endif
  1901 
  1901 
  1902     switch (dwWaitResult) {
  1902     switch (dwWaitResult) {
  1903         case WAIT_OBJECT_0:
  1903 	case WAIT_OBJECT_0:
  1904             hEventsMutexOwner = whoIsLocking;
  1904 	    hEventsMutexOwner = whoIsLocking;
  1905             return (TRUE);
  1905 	    return (TRUE);
  1906 
  1906 
  1907         case WAIT_ABANDONED:
  1907 	case WAIT_ABANDONED:
  1908             console_fprintf(stderr, "WinWorkstation [warning]: lockEvent abandoned (was owned by %s)\n",
  1908 	    console_fprintf(stderr, "WinWorkstation [warning]: lockEvent abandoned (was owned by %s)\n",
  1909                         (hEventsMutexOwner ? hEventsMutexOwner : "NONE"));
  1909 			(hEventsMutexOwner ? hEventsMutexOwner : "NONE"));
  1910             hEventsMutexOwner = whoIsLocking;
  1910 	    hEventsMutexOwner = whoIsLocking;
  1911             return (TRUE);
  1911 	    return (TRUE);
  1912 
  1912 
  1913         case WAIT_TIMEOUT:
  1913 	case WAIT_TIMEOUT:
  1914             console_fprintf(stderr, "WinWorkstation [warning]: lockEvent timeout (owned by %s)\n",
  1914 	    console_fprintf(stderr, "WinWorkstation [warning]: lockEvent timeout (owned by %s)\n",
  1915                         (hEventsMutexOwner ? hEventsMutexOwner : "NONE") );
  1915 			(hEventsMutexOwner ? hEventsMutexOwner : "NONE") );
  1916             break;
  1916 	    break;
  1917 
  1917 
  1918         default:
  1918 	default:
  1919             {
  1919 	    {
  1920                 unsigned errCode = GetLastError();
  1920 		unsigned errCode = GetLastError();
  1921 
  1921 
  1922                 console_fprintf(stderr, "WinWorkstation [error]: lockEvent error (owned by %s) rslt=0x%x err=0x%x\n",
  1922 		console_fprintf(stderr, "WinWorkstation [error]: lockEvent error (owned by %s) rslt=0x%x err=0x%x\n",
  1923                             (hEventsMutexOwner ? hEventsMutexOwner : "NONE"),
  1923 			    (hEventsMutexOwner ? hEventsMutexOwner : "NONE"),
  1924                             dwWaitResult, errCode );
  1924 			    dwWaitResult, errCode );
  1925             }
  1925 	    }
  1926             break;
  1926 	    break;
  1927     }
  1927     }
  1928     return (FALSE);
  1928     return (FALSE);
  1929 }
  1929 }
  1930 
  1930 
  1931 static int
  1931 static int
  1932 unlockEvents(void) {
  1932 unlockEvents(void) {
  1933 #ifdef LOCK_DEBUG
  1933 #ifdef LOCK_DEBUG
  1934     lockCountEvents--;
  1934     lockCountEvents--;
  1935     if (lockCountEvents != 0) {
  1935     if (lockCountEvents != 0) {
  1936         console_fprintf(stderr, "WinWorkstation [warning]: lockCountEvents (%d) != 0 in unlock\n", lockCountEvents);
  1936 	console_fprintf(stderr, "WinWorkstation [warning]: lockCountEvents (%d) != 0 in unlock\n", lockCountEvents);
  1937         lockCountEvents = 0;
  1937 	lockCountEvents = 0;
  1938     }
  1938     }
  1939 #endif
  1939 #endif
  1940     if (! ReleaseMutex(hEventsMutex)) {
  1940     if (! ReleaseMutex(hEventsMutex)) {
  1941        console_fprintf(stderr, "WinWorkstation [error]: unlockEvent error\n");
  1941        console_fprintf(stderr, "WinWorkstation [error]: unlockEvent error\n");
  1942        return (FALSE);
  1942        return (FALSE);
  1952     struct queuedEvent *bulk;
  1952     struct queuedEvent *bulk;
  1953     int i;
  1953     int i;
  1954 
  1954 
  1955     bulk = (struct queuedEvent *) malloc(EV_CHUNK_SZ);
  1955     bulk = (struct queuedEvent *) malloc(EV_CHUNK_SZ);
  1956     if (bulk == 0) {
  1956     if (bulk == 0) {
  1957         console_fprintf(stderr, "WinWorkstation [warning]: no memory for dispatchqueue\n");
  1957 	console_fprintf(stderr, "WinWorkstation [warning]: no memory for dispatchqueue\n");
  1958         return 0;
  1958 	return 0;
  1959     }
  1959     }
  1960     for (i=1; i<EV_CHUNK_CNT; i++) {
  1960     for (i=1; i<EV_CHUNK_CNT; i++) {
  1961         bulk[i-1].ev_next = &(bulk[i]);
  1961 	bulk[i-1].ev_next = &(bulk[i]);
  1962     }
  1962     }
  1963     bulk[EV_CHUNK_CNT-1].ev_next = (struct queuedEvent *)0;
  1963     bulk[EV_CHUNK_CNT-1].ev_next = (struct queuedEvent *)0;
  1964     eventFreeList = bulk;
  1964     eventFreeList = bulk;
  1965 
  1965 
  1966     return 1;
  1966     return 1;
  1978     int repeatCount = 0;
  1978     int repeatCount = 0;
  1979 
  1979 
  1980     /* get an event struct
  1980     /* get an event struct
  1981     */
  1981     */
  1982     while (! eventFreeList) {
  1982     while (! eventFreeList) {
  1983         if (repeatCount++ >= 5) {
  1983 	if (repeatCount++ >= 5) {
  1984             /* throw away sorry */
  1984 	    /* throw away sorry */
  1985             console_fprintf(stderr, "WinWorkstation [error]: event throw away (memory problem)\n");
  1985 	    console_fprintf(stderr, "WinWorkstation [error]: event throw away (memory problem)\n");
  1986             return;
  1986 	    return;
  1987         }
  1987 	}
  1988         console_fprintf(stderr, "WinWorkstation [warning]: wait for event memory (%d)\n", repeatCount);
  1988 	console_fprintf(stderr, "WinWorkstation [warning]: wait for event memory (%d)\n", repeatCount);
  1989         WaitForSingleObject( hNeverTriggered, 100L );
  1989 	WaitForSingleObject( hNeverTriggered, 100L );
  1990     }
  1990     }
  1991     if (! lockEvents("enqEvent")) {
  1991     if (! lockEvents("enqEvent")) {
  1992         console_fprintf(stderr, "WinWorkstation [error]: event throw away (lock problem)\n");
  1992 	console_fprintf(stderr, "WinWorkstation [error]: event throw away (lock problem)\n");
  1993         return;
  1993 	return;
  1994     }
  1994     }
  1995 
  1995 
  1996     ev = eventFreeList;
  1996     ev = eventFreeList;
  1997 
  1997 
  1998     if (! ev) {
  1998     if (! ev) {
  1999         console_fprintf(stderr, "WinWorkstation [error]: event throw away (memory problem)\n");
  1999 	console_fprintf(stderr, "WinWorkstation [error]: event throw away (memory problem)\n");
  2000         unlockEvents();
  2000 	unlockEvents();
  2001         return;
  2001 	return;
  2002     }
  2002     }
  2003     eventFreeList  = ev->ev_next;
  2003     eventFreeList  = ev->ev_next;
  2004     ev->ev_flag    = flag;
  2004     ev->ev_flag    = flag;
  2005     ev->ev_hWnd    = hWnd;
  2005     ev->ev_hWnd    = hWnd;
  2006     ev->ev_message = message;
  2006     ev->ev_message = message;
  2012     ev->ev_time    = evTime /* lastMSGTime */;
  2012     ev->ev_time    = evTime /* lastMSGTime */;
  2013     ev->count      = eventsendcount++;
  2013     ev->count      = eventsendcount++;
  2014     ev->ev_next    = (struct queuedEvent *) 0;
  2014     ev->ev_next    = (struct queuedEvent *) 0;
  2015 
  2015 
  2016     if (eventQueueTail) {
  2016     if (eventQueueTail) {
  2017         eventQueueTail->ev_next = ev;
  2017 	eventQueueTail->ev_next = ev;
  2018     } else {
  2018     } else {
  2019         eventQueueHead = ev;
  2019 	eventQueueHead = ev;
  2020     }
  2020     }
  2021     eventQueueTail = ev;
  2021     eventQueueTail = ev;
  2022 
  2022 
  2023     unlockEvents();
  2023     unlockEvents();
  2024 
  2024 
  2025     if (eventQueueHead == ev) {
  2025     if (eventQueueHead == ev) {
  2026         SetEvent(hInputEvent);
  2026 	SetEvent(hInputEvent);
  2027     }
  2027     }
  2028 
  2028 
  2029 #if 0
  2029 #if 0
  2030     SetThreadPriority(_masterThread, THREAD_PRIORITY_HIGHEST);
  2030     SetThreadPriority(_masterThread, THREAD_PRIORITY_HIGHEST);
  2031 #endif
  2031 #endif
  2036 {
  2036 {
  2037     struct queuedEvent * ev = NULL;
  2037     struct queuedEvent * ev = NULL;
  2038     char * freeArg2 = NULL;
  2038     char * freeArg2 = NULL;
  2039 
  2039 
  2040     if (mask != ~0) {
  2040     if (mask != ~0) {
  2041         PRINTF(("deqEvent mask:%x\n",mask));
  2041 	PRINTF(("deqEvent mask:%x\n",mask));
  2042     }
  2042     }
  2043     if (hWnd) {
  2043     if (hWnd) {
  2044         PRINTF(("deqEvent hWnd:%x\n",hWnd));
  2044 	PRINTF(("deqEvent hWnd:%x\n",hWnd));
  2045     }
  2045     }
  2046 
  2046 
  2047   again:
  2047   again:
  2048 
  2048 
  2049     if (! eventQueueHead)
  2049     if (! eventQueueHead)
  2050         return (0);
  2050 	return (0);
  2051 
  2051 
  2052     if (! lockEvents("deqEvent")) {
  2052     if (! lockEvents("deqEvent")) {
  2053         return (0);
  2053 	return (0);
  2054     }
  2054     }
  2055 
  2055 
  2056     TH_DPRINTF(("TDEQ\n"));
  2056     TH_DPRINTF(("TDEQ\n"));
  2057     ev = eventQueueHead;
  2057     ev = eventQueueHead;
  2058 
  2058 
  2059     if (! ev) {
  2059     if (! ev) {
  2060         unlockEvents();
  2060 	unlockEvents();
  2061         return (0);
  2061 	return (0);
  2062     }
  2062     }
  2063     eventQueueHead = ev->ev_next;
  2063     eventQueueHead = ev->ev_next;
  2064 
  2064 
  2065     if (! eventQueueHead) {
  2065     if (! eventQueueHead) {
  2066         eventQueueTail = (struct queuedEvent *) 0;
  2066 	eventQueueTail = (struct queuedEvent *) 0;
  2067     }
  2067     }
  2068 
  2068 
  2069     if (ev->count != -1) {
  2069     if (ev->count != -1) {
  2070         static int anyGoodEventReceived = 1;
  2070 	static int anyGoodEventReceived = 1;
  2071 
  2071 
  2072         if (eventempfcount != ev->count) {
  2072 	if (eventempfcount != ev->count) {
  2073             if (anyGoodEventReceived) {
  2073 	    if (anyGoodEventReceived) {
  2074                 console_fprintf(stderr, "WinWorkstation [warning]: lost event (eventcount error %d <-> %d)\n",
  2074 		console_fprintf(stderr, "WinWorkstation [warning]: lost event (eventcount error %d <-> %d)\n",
  2075                                  eventempfcount, ev->count);
  2075 				 eventempfcount, ev->count);
  2076             }
  2076 	    }
  2077             eventempfcount = ev->count;
  2077 	    eventempfcount = ev->count;
  2078             anyGoodEventReceived = 0;
  2078 	    anyGoodEventReceived = 0;
  2079         } else {
  2079 	} else {
  2080             anyGoodEventReceived = 1;
  2080 	    anyGoodEventReceived = 1;
  2081         }
  2081 	}
  2082         eventempfcount++;
  2082 	eventempfcount++;
  2083     }
  2083     }
  2084 
  2084 
  2085     if (ev->ev_message == WM_DESTROY) {
  2085     if (ev->ev_message == WM_DESTROY) {
  2086         /*
  2086 	/*
  2087          * arg2 is the localInfoPtr
  2087 	 * arg2 is the localInfoPtr
  2088          * (which is already cleared in the wind-structure)
  2088 	 * (which is already cleared in the wind-structure)
  2089          * it must be freed by the stx-process ('cause it was malloc'd by it)
  2089 	 * it must be freed by the stx-process ('cause it was malloc'd by it)
  2090          */
  2090 	 */
  2091         if (ev->ev_arg2) {
  2091 	if (ev->ev_arg2) {
  2092             freeArg2 = (char *) ev->ev_arg2;
  2092 	    freeArg2 = (char *) ev->ev_arg2;
  2093             ev->ev_arg2 = 0;
  2093 	    ev->ev_arg2 = 0;
  2094         }
  2094 	}
  2095 
  2095 
  2096 #ifdef TOPWINDOWCLASS
  2096 #ifdef TOPWINDOWCLASS
  2097 
  2097 
  2098 FALSCH: nochmals in QUEUE -> (ev_arg2 != 0) arg2 freed !!!
  2098 FALSCH: nochmals in QUEUE -> (ev_arg2 != 0) arg2 freed !!!
  2099 
  2099 
  2100         if (ev->ev_arg1) {
  2100 	if (ev->ev_arg1) {
  2101             if (UnregisterClass((char*)ev->ev_arg1,(HANDLE) __getHInstance())) {
  2101 	    if (UnregisterClass((char*)ev->ev_arg1,(HANDLE) __getHInstance())) {
  2102                 /*console_printf("UnregisterClass %s ok.\n",(char*)ev->ev_arg1);*/
  2102 		/*console_printf("UnregisterClass %s ok.\n",(char*)ev->ev_arg1);*/
  2103 
  2103 
  2104             } else {
  2104 	    } else {
  2105                 /* noch einmal in die queue
  2105 		/* noch einmal in die queue
  2106                 */
  2106 		*/
  2107                 if (ev->ev_arg2++ < 100) {
  2107 		if (ev->ev_arg2++ < 100) {
  2108                     ev->ev_next = (struct queuedEvent *)0;
  2108 		    ev->ev_next = (struct queuedEvent *)0;
  2109                     ev->count   = eventsendcount++;
  2109 		    ev->count   = eventsendcount++;
  2110 
  2110 
  2111                     if (eventQueueTail) {
  2111 		    if (eventQueueTail) {
  2112                         eventQueueTail->ev_next = ev;
  2112 			eventQueueTail->ev_next = ev;
  2113                     } else {
  2113 		    } else {
  2114                         eventQueueHead = ev;
  2114 			eventQueueHead = ev;
  2115                     }
  2115 		    }
  2116                     eventQueueTail = ev;
  2116 		    eventQueueTail = ev;
  2117                     unlockEvents();
  2117 		    unlockEvents();
  2118 
  2118 
  2119                     if (freeArg2) {
  2119 		    if (freeArg2) {
  2120                         free (freeArg2);
  2120 			free (freeArg2);
  2121                         freeArg2 = NULL;
  2121 			freeArg2 = NULL;
  2122                     }
  2122 		    }
  2123 
  2123 
  2124                     if (ev->ev_arg2 > 98) {
  2124 		    if (ev->ev_arg2 > 98) {
  2125                         console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed. Wait 1 sec.\n",(char*)ev->ev_arg1);
  2125 			console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed. Wait 1 sec.\n",(char*)ev->ev_arg1);
  2126                         sleep(1);
  2126 			sleep(1);
  2127                     } else {
  2127 		    } else {
  2128                         sleep(0);
  2128 			sleep(0);
  2129                     }
  2129 		    }
  2130                     goto again;
  2130 		    goto again;
  2131                 }
  2131 		}
  2132                 /* fail evtl. später ändern und in st verzögert aufrufen
  2132 		/* fail evtl. später ändern und in st verzögert aufrufen
  2133                 */
  2133 		*/
  2134                 console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed.\n",(char*)ev->ev_arg1);
  2134 		console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed.\n",(char*)ev->ev_arg1);
  2135             }
  2135 	    }
  2136             free((char*)ev->ev_arg1);
  2136 	    free((char*)ev->ev_arg1);
  2137             ev->ev_arg1 = 0;
  2137 	    ev->ev_arg1 = 0;
  2138         }
  2138 	}
  2139 #endif
  2139 #endif
  2140     }
  2140     }
  2141 
  2141 
  2142     *ret_ev = *ev;
  2142     *ret_ev = *ev;
  2143 
  2143 
  2144     ev->ev_next   = eventFreeList;
  2144     ev->ev_next   = eventFreeList;
  2145     eventFreeList = ev;
  2145     eventFreeList = ev;
  2146     unlockEvents();
  2146     unlockEvents();
  2147 
  2147 
  2148     if (freeArg2) {
  2148     if (freeArg2) {
  2149         free (freeArg2);
  2149 	free (freeArg2);
  2150     }
  2150     }
  2151     return (1);
  2151     return (1);
  2152 }
  2152 }
  2153 
  2153 
  2154 static void
  2154 static void
  2155 __clearRectangles(HWND hWnd, int numRects, RECT *pRect)
  2155 __clearRectangles(HWND hWnd, int numRects, RECT *pRect)
  2156 {
  2156 {
  2157         HDC dc;
  2157 	HDC dc;
  2158         HBRUSH br;
  2158 	HBRUSH br;
  2159         int bgClr;
  2159 	int bgClr;
  2160         int isPrivateBrush = 0;
  2160 	int isPrivateBrush = 0;
  2161 
  2161 
  2162 # ifdef CACHE_LAST_WM_PAINT_DC
  2162 # ifdef CACHE_LAST_WM_PAINT_DC
  2163         AQUIRE_PAINT_MUTEX;
  2163 	AQUIRE_PAINT_MUTEX;
  2164 
  2164 
  2165         if (last_wm_paint_dc && (last_wm_paint_win == hWnd)) {
  2165 	if (last_wm_paint_dc && (last_wm_paint_win == hWnd)) {
  2166             dc = last_wm_paint_dc;
  2166 	    dc = last_wm_paint_dc;
  2167         } else {
  2167 	} else {
  2168             if (last_wm_paint_dc) {
  2168 	    if (last_wm_paint_dc) {
  2169 #  ifdef CACHE_LAST_DC
  2169 #  ifdef CACHE_LAST_DC
  2170                 if (lastGcData && (lastGcData->_hDC == last_wm_paint_dc)) {
  2170 		if (lastGcData && (lastGcData->_hDC == last_wm_paint_dc)) {
  2171 #   ifdef DEBUG_DC_REUSE
  2171 #   ifdef DEBUG_DC_REUSE
  2172                     console_fprintf(stderr, "WinWorkstation [info]: Oops - release lastGcData [%d]\n", __LINE__);
  2172 		    console_fprintf(stderr, "WinWorkstation [info]: Oops - release lastGcData [%d]\n", __LINE__);
  2173 #   endif
  2173 #   endif
  2174                     _releaseDC(lastGcData);
  2174 		    _releaseDC(lastGcData);
  2175                 } else {
  2175 		} else {
  2176                     ReleaseDC(last_wm_paint_win, last_wm_paint_dc);
  2176 		    ReleaseDC(last_wm_paint_win, last_wm_paint_dc);
  2177                 }
  2177 		}
  2178 #  else
  2178 #  else
  2179                 ReleaseDC(last_wm_paint_win, last_wm_paint_dc);
  2179 		ReleaseDC(last_wm_paint_win, last_wm_paint_dc);
  2180 #  endif /* CACHE_LAST_DC */
  2180 #  endif /* CACHE_LAST_DC */
  2181             }
  2181 	    }
  2182             dc = GetDC(hWnd);
  2182 	    dc = GetDC(hWnd);
  2183             last_wm_paint_dc = dc;
  2183 	    last_wm_paint_dc = dc;
  2184             last_wm_paint_win = hWnd;
  2184 	    last_wm_paint_win = hWnd;
  2185         }
  2185 	}
  2186 # else
  2186 # else
  2187         dc = (HDC)GetDC(hWnd);
  2187 	dc = (HDC)GetDC(hWnd);
  2188 # endif /* CACHE_LAST_WM_PAINT_DC */
  2188 # endif /* CACHE_LAST_WM_PAINT_DC */
  2189 
  2189 
  2190 # ifdef CACHE_LAST_DC
  2190 # ifdef CACHE_LAST_DC
  2191         if (lastGcData && (lastGcData->_hDC == dc)) {
  2191 	if (lastGcData && (lastGcData->_hDC == dc)) {
  2192 #  ifdef DEBUG_DC_REUSE
  2192 #  ifdef DEBUG_DC_REUSE
  2193             console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
  2193 	    console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
  2194 #  endif
  2194 #  endif
  2195             if ((lastGcData->rop2 != R2_COPYPEN)
  2195 	    if ((lastGcData->rop2 != R2_COPYPEN)
  2196              || (lastGcData->bitbltrop2 != BITBLT_COPY)) {
  2196 	     || (lastGcData->bitbltrop2 != BITBLT_COPY)) {
  2197                 console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc not in Copy mode\n");
  2197 		console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc not in Copy mode\n");
  2198             }
  2198 	    }
  2199             lastGcData = 0;
  2199 	    lastGcData = 0;
  2200         }
  2200 	}
  2201 # endif
  2201 # endif
  2202 
  2202 
  2203         br = GetWindow_viewBgBrush(hWnd);
  2203 	br = GetWindow_viewBgBrush(hWnd);
  2204         if (! br) {
  2204 	if (! br) {
  2205             bgClr = GetWindow_viewBgColor(hWnd);
  2205 	    bgClr = GetWindow_viewBgColor(hWnd);
  2206 
  2206 
  2207 # ifdef CACHE_LAST_WM_PAINT_BRUSH
  2207 # ifdef CACHE_LAST_WM_PAINT_BRUSH
  2208             if (last_wm_paint_brush
  2208 	    if (last_wm_paint_brush
  2209              && (last_wm_paint_brush_clr == bgClr)) {
  2209 	     && (last_wm_paint_brush_clr == bgClr)) {
  2210                 br = last_wm_paint_brush;
  2210 		br = last_wm_paint_brush;
  2211             } else {
  2211 	    } else {
  2212                 if (bgClr == WhitePixel) {
  2212 		if (bgClr == WhitePixel) {
  2213                     br = __whiteBrush;
  2213 		    br = __whiteBrush;
  2214                 } else if (bgClr == BlackPixel) {
  2214 		} else if (bgClr == BlackPixel) {
  2215                     br = __blackBrush;
  2215 		    br = __blackBrush;
  2216                 } else {
  2216 		} else {
  2217                     if (last_wm_paint_brush) {
  2217 		    if (last_wm_paint_brush) {
  2218                         _DeleteBrush(last_wm_paint_brush, __LINE__);
  2218 			_DeleteBrush(last_wm_paint_brush, __LINE__);
  2219                     }
  2219 		    }
  2220                     last_wm_paint_brush = br = CreateSolidBrush(bgClr);
  2220 		    last_wm_paint_brush = br = CreateSolidBrush(bgClr);
  2221                     last_wm_paint_brush_clr = bgClr;
  2221 		    last_wm_paint_brush_clr = bgClr;
  2222                     isPrivateBrush = 1;
  2222 		    isPrivateBrush = 1;
  2223                 }
  2223 		}
  2224             }
  2224 	    }
  2225 # else
  2225 # else
  2226             br = CreateSolidBrush(bgClr);
  2226 	    br = CreateSolidBrush(bgClr);
  2227             isPrivateBrush = 1;
  2227 	    isPrivateBrush = 1;
  2228 # endif
  2228 # endif
  2229         }
  2229 	}
  2230 
  2230 
  2231         if (! br) {
  2231 	if (! br) {
  2232             console_fprintf(stderr, "WinWorkstation [info]: no brush\n");
  2232 	    console_fprintf(stderr, "WinWorkstation [info]: no brush\n");
  2233         }
  2233 	}
  2234 
  2234 
  2235         if (br) {
  2235 	if (br) {
  2236             int i;
  2236 	    int i;
  2237 
  2237 
  2238             SelectClipRgn(dc, NULL);
  2238 	    SelectClipRgn(dc, NULL);
  2239 
  2239 
  2240             for (i=0; i<numRects; i++) {
  2240 	    for (i=0; i<numRects; i++) {
  2241                 /*
  2241 		/*
  2242                  * always clear - even if not interested in exposes
  2242 		 * always clear - even if not interested in exposes
  2243                  */
  2243 		 */
  2244                 FillRect(dc, &(pRect[i]), br);
  2244 		FillRect(dc, &(pRect[i]), br);
  2245             }
  2245 	    }
  2246         }
  2246 	}
  2247 
  2247 
  2248 # ifndef CACHE_LAST_WM_PAINT_BRUSH
  2248 # ifndef CACHE_LAST_WM_PAINT_BRUSH
  2249         if (isPrivateBrush) {
  2249 	if (isPrivateBrush) {
  2250             _DeleteBrush(br, __LINE__);
  2250 	    _DeleteBrush(br, __LINE__);
  2251         }
  2251 	}
  2252 # endif
  2252 # endif
  2253 
  2253 
  2254 # ifndef CACHE_LAST_WM_PAINT_DC
  2254 # ifndef CACHE_LAST_WM_PAINT_DC
  2255         ReleaseDC(hWnd, dc);
  2255 	ReleaseDC(hWnd, dc);
  2256 # endif
  2256 # endif
  2257 
  2257 
  2258 # if defined(CACHE_LAST_WM_PAINT_DC)
  2258 # if defined(CACHE_LAST_WM_PAINT_DC)
  2259         RELEASE_PAINT_MUTEX
  2259 	RELEASE_PAINT_MUTEX
  2260 # endif
  2260 # endif
  2261 }
  2261 }
  2262 
  2262 
  2263 static void
  2263 static void
  2264 __clearWindow(HWND hWnd, int x, int y, int w, int h)
  2264 __clearWindow(HWND hWnd, int x, int y, int w, int h)
  2265 {
  2265 {
  2266         RECT rect;
  2266 	RECT rect;
  2267 
  2267 
  2268         rect.left = x;
  2268 	rect.left = x;
  2269         rect.top = y;
  2269 	rect.top = y;
  2270         rect.right = x + w;
  2270 	rect.right = x + w;
  2271         rect.bottom = y + h;
  2271 	rect.bottom = y + h;
  2272         __clearRectangles(hWnd, 1, &rect);
  2272 	__clearRectangles(hWnd, 1, &rect);
  2273 }
  2273 }
  2274 
  2274 
  2275 
  2275 
  2276 /*
  2276 /*
  2277  * generate expose events from hWnd's update region or the passedIn region.
  2277  * generate expose events from hWnd's update region or the passedIn region.
  2281  */
  2281  */
  2282 
  2282 
  2283 static int
  2283 static int
  2284 __generateExposes(HWND hWnd, HRGN hRgnInOrNull, int msgType, int doClear)
  2284 __generateExposes(HWND hWnd, HRGN hRgnInOrNull, int msgType, int doClear)
  2285 {
  2285 {
  2286         RECT updRect;
  2286 	RECT updRect;
  2287         HRGN updRgn = 0;
  2287 	HRGN updRgn = 0;
  2288         int numRects, ret, n, i;
  2288 	int numRects, ret, n, i;
  2289         int wantExpose;
  2289 	int wantExpose;
  2290         RECT *pRect;
  2290 	RECT *pRect;
  2291         union {
  2291 	union {
  2292             RGNDATA rgnData;
  2292 	    RGNDATA rgnData;
  2293             char    bytes[512];
  2293 	    char    bytes[512];
  2294         } data;
  2294 	} data;
  2295 
  2295 
  2296         wantExpose = 0;
  2296 	wantExpose = 0;
  2297 
  2297 
  2298         if( msgType >= 0 )
  2298 	if( msgType >= 0 )
  2299             wantExpose = (GetWindow_eventMask(hWnd) & ExposureMask);
  2299 	    wantExpose = (GetWindow_eventMask(hWnd) & ExposureMask);
  2300 
  2300 
  2301         if (hRgnInOrNull) {
  2301 	if (hRgnInOrNull) {
  2302             updRgn = hRgnInOrNull;
  2302 	    updRgn = hRgnInOrNull;
  2303         } else {
  2303 	} else {
  2304             PAINTSTRUCT ps;
  2304 	    PAINTSTRUCT ps;
  2305 
  2305 
  2306             /*
  2306 	    /*
  2307              * fetch the update region, even if ExposureMask is empty.
  2307 	     * fetch the update region, even if ExposureMask is empty.
  2308              */
  2308 	     */
  2309             updRgn = CreateRectRgn(0, 0, 0, 0);
  2309 	    updRgn = CreateRectRgn(0, 0, 0, 0);
  2310             ret = GetUpdateRgn(hWnd, updRgn, FALSE);
  2310 	    ret = GetUpdateRgn(hWnd, updRgn, FALSE);
  2311 
  2311 
  2312 #if 0
  2312 #if 0
  2313             BeginPaint(hWnd, &ps);
  2313 	    BeginPaint(hWnd, &ps);
  2314             /* store the rectangle required for image bit reversal */
  2314 	    /* store the rectangle required for image bit reversal */
  2315             /* updateRect = ps.rcPaint;   */
  2315 	    /* updateRect = ps.rcPaint;   */
  2316             EndPaint(hWnd, &ps);
  2316 	    EndPaint(hWnd, &ps);
  2317 #endif
  2317 #endif
  2318             switch (ret) {
  2318 	    switch (ret) {
  2319                 case ERROR:
  2319 		case ERROR:
  2320                     console_fprintf(stderr, "WinWorkstation [info]: errregion\n");
  2320 		    console_fprintf(stderr, "WinWorkstation [info]: errregion\n");
  2321                     return -1;
  2321 		    return -1;
  2322                 case NULLREGION:
  2322 		case NULLREGION:
  2323                     DDDDPRINTF(("nullregion\n"));
  2323 		    DDDDPRINTF(("nullregion\n"));
  2324                     _DeleteObject(updRgn, __LINE__);
  2324 		    _DeleteObject(updRgn, __LINE__);
  2325                     return 0;
  2325 		    return 0;
  2326                 case SIMPLEREGION:
  2326 		case SIMPLEREGION:
  2327                 case COMPLEXREGION:
  2327 		case COMPLEXREGION:
  2328                     break;
  2328 		    break;
  2329             }
  2329 	    }
  2330         }
  2330 	}
  2331         n = GetRegionData(updRgn, sizeof(data), &(data.rgnData));
  2331 	n = GetRegionData(updRgn, sizeof(data), &(data.rgnData));
  2332 
  2332 
  2333         /*
  2333 	/*
  2334          * the MS-doc states: n==1
  2334 	 * the MS-doc states: n==1
  2335          * but this is not true
  2335 	 * but this is not true
  2336          */
  2336 	 */
  2337         if ((n >= sizeof(RGNDATA))
  2337 	if ((n >= sizeof(RGNDATA))
  2338          && (n <= sizeof(data))
  2338 	 && (n <= sizeof(data))
  2339          && (data.rgnData.rdh.iType == RDH_RECTANGLES))  {
  2339 	 && (data.rgnData.rdh.iType == RDH_RECTANGLES))  {
  2340             /* ok, got the region */
  2340 	    /* ok, got the region */
  2341             numRects = data.rgnData.rdh.nCount;
  2341 	    numRects = data.rgnData.rdh.nCount;
  2342             pRect = (RECT *)(data.rgnData.Buffer);
  2342 	    pRect = (RECT *)(data.rgnData.Buffer);
  2343             DDDDPRINTF(("region numRects=%d\n", numRects));
  2343 	    DDDDPRINTF(("region numRects=%d\n", numRects));
  2344         } else {
  2344 	} else {
  2345             /* a big region ... */
  2345 	    /* a big region ... */
  2346             GetRgnBox(updRgn, &updRect);
  2346 	    GetRgnBox(updRgn, &updRect);
  2347             numRects = 1;
  2347 	    numRects = 1;
  2348             pRect = &updRect;
  2348 	    pRect = &updRect;
  2349             DPRINTF(("very complex region (need:%d have:%d) bounds=%d,%d -> %d,%d\n",
  2349 	    DPRINTF(("very complex region (need:%d have:%d) bounds=%d,%d -> %d,%d\n",
  2350                      n, sizeof(data),
  2350 		     n, sizeof(data),
  2351                      updRect.left, updRect.top,
  2351 		     updRect.left, updRect.top,
  2352                      updRect.right, updRect.bottom));
  2352 		     updRect.right, updRect.bottom));
  2353             if (((updRect.right - updRect.left) <= 0)
  2353 	    if (((updRect.right - updRect.left) <= 0)
  2354              || ((updRect.bottom - updRect.top) <= 0)) {
  2354 	     || ((updRect.bottom - updRect.top) <= 0)) {
  2355                 numRects = 0;
  2355 		numRects = 0;
  2356             }
  2356 	    }
  2357         }
  2357 	}
  2358 
  2358 
  2359         if (numRects) {
  2359 	if (numRects) {
  2360             if (doClear) {
  2360 	    if (doClear) {
  2361                 __clearRectangles(hWnd, numRects, pRect);
  2361 		__clearRectangles(hWnd, numRects, pRect);
  2362             }
  2362 	    }
  2363 
  2363 
  2364 #ifndef PRE_21_NOV
  2364 #ifndef PRE_21_NOV
  2365         for (i=0; i < numRects; i++) {
  2365 	for (i=0; i < numRects; i++) {
  2366             ValidateRect( hWnd, &pRect[i] );
  2366 	    ValidateRect( hWnd, &pRect[i] );
  2367         }
  2367 	}
  2368 #endif
  2368 #endif
  2369 
  2369 
  2370 #ifdef DEBUG_COLORIZE_WM_PAINT_RECTS1
  2370 #ifdef DEBUG_COLORIZE_WM_PAINT_RECTS1
  2371             {
  2371 	    {
  2372                 HDC hDC;
  2372 		HDC hDC;
  2373                 HBRUSH hBrush;
  2373 		HBRUSH hBrush;
  2374 
  2374 
  2375                 hBrush = CreateSolidBrush(BlackPixel);
  2375 		hBrush = CreateSolidBrush(BlackPixel);
  2376                 hDC = GetWindowDC(hWnd);
  2376 		hDC = GetWindowDC(hWnd);
  2377                 SelectClipRgn(hDC, NULL);
  2377 		SelectClipRgn(hDC, NULL);
  2378                 for (i=0; i<numRects; i++) {
  2378 		for (i=0; i<numRects; i++) {
  2379                     FillRect(hDC, &(pRect[i]), hBrush);
  2379 		    FillRect(hDC, &(pRect[i]), hBrush);
  2380                 }
  2380 		}
  2381                 _DeleteBrush(hBrush, __LINE__);
  2381 		_DeleteBrush(hBrush, __LINE__);
  2382                 ReleaseDC(hWnd, hDC);
  2382 		ReleaseDC(hWnd, hDC);
  2383             }
  2383 	    }
  2384 #endif
  2384 #endif
  2385 
  2385 
  2386             if (wantExpose) {
  2386 	    if (wantExpose) {
  2387                 for (i=0; i<numRects; i++) {
  2387 		for (i=0; i<numRects; i++) {
  2388                     int final = 0;
  2388 		    int final = 0;
  2389 
  2389 
  2390                     if ((msgType == __WM_GEXPOSE)
  2390 		    if ((msgType == __WM_GEXPOSE)
  2391                      && (i == (numRects - 1))) {
  2391 		     && (i == (numRects - 1))) {
  2392                         final = 1;
  2392 			final = 1;
  2393                     }
  2393 		    }
  2394                     enqEvent(ExposureMask, hWnd, msgType, final,
  2394 		    enqEvent(ExposureMask, hWnd, msgType, final,
  2395                              (pRect[i].left), (pRect[i].top),
  2395 			     (pRect[i].left), (pRect[i].top),
  2396                              (pRect[i].right - pRect[i].left),
  2396 			     (pRect[i].right - pRect[i].left),
  2397                              (pRect[i].bottom - pRect[i].top),
  2397 			     (pRect[i].bottom - pRect[i].top),
  2398                              EV_NOTIME);
  2398 			     EV_NOTIME);
  2399                 }
  2399 		}
  2400             }
  2400 	    }
  2401         }
  2401 	}
  2402 
  2402 
  2403         if (updRgn && (updRgn != hRgnInOrNull)) {
  2403 	if (updRgn && (updRgn != hRgnInOrNull)) {
  2404             _DeleteObject(updRgn, __LINE__);
  2404 	    _DeleteObject(updRgn, __LINE__);
  2405         }
  2405 	}
  2406 
  2406 
  2407         return numRects;
  2407 	return numRects;
  2408 }
  2408 }
  2409 
  2409 
  2410 #ifdef THIS_DOES_NOT_AVOID_DOUBLE_REPAINTS
  2410 #ifdef THIS_DOES_NOT_AVOID_DOUBLE_REPAINTS
  2411 
  2411 
  2412 BOOL CALLBACK
  2412 BOOL CALLBACK
  2413 recursiveExposeGenerator(HWND hChild, LPARAM param)
  2413 recursiveExposeGenerator(HWND hChild, LPARAM param)
  2414 {
  2414 {
  2415         __generateExposes(hChild, NULL, param, 0);
  2415 	__generateExposes(hChild, NULL, param, 0);
  2416         return TRUE;
  2416 	return TRUE;
  2417 }
  2417 }
  2418 
  2418 
  2419 static void
  2419 static void
  2420 __generateRecursiveExposes(HWND hWnd, int msgType)
  2420 __generateRecursiveExposes(HWND hWnd, int msgType)
  2421 {
  2421 {
  2422         EnumChildWindows(hWnd, recursiveExposeGenerator, msgType);
  2422 	EnumChildWindows(hWnd, recursiveExposeGenerator, msgType);
  2423 }
  2423 }
  2424 
  2424 
  2425 #endif /* sigh */
  2425 #endif /* sigh */
  2426 
  2426 
  2427 
  2427 
  2429 getModifiers(void)
  2429 getModifiers(void)
  2430 {
  2430 {
  2431     int modifiers = 0;
  2431     int modifiers = 0;
  2432 
  2432 
  2433     if (GetKeyState(VK_SHIFT) & 0x8000)
  2433     if (GetKeyState(VK_SHIFT) & 0x8000)
  2434         modifiers |= ShiftMask;
  2434 	modifiers |= ShiftMask;
  2435     if (GetKeyState(VK_CONTROL) & 0x8000)
  2435     if (GetKeyState(VK_CONTROL) & 0x8000)
  2436         modifiers |= ControlMask;
  2436 	modifiers |= ControlMask;
  2437 #if 0
  2437 #if 0
  2438     if (GetKeyState(VK_RMENU) & 0x8000)
  2438     if (GetKeyState(VK_RMENU) & 0x8000)
  2439         modifiers |= RightAltMask;
  2439 	modifiers |= RightAltMask;
  2440     if (GetKeyState(VK_LMENU) & 0x8000)
  2440     if (GetKeyState(VK_LMENU) & 0x8000)
  2441         modifiers |= LeftAltMask;
  2441 	modifiers |= LeftAltMask;
  2442 #else
  2442 #else
  2443     if (GetKeyState(VK_MENU) & 0x8000)
  2443     if (GetKeyState(VK_MENU) & 0x8000)
  2444         modifiers |= LeftAltMask;
  2444 	modifiers |= LeftAltMask;
  2445 #endif
  2445 #endif
  2446     if (GetKeyState(VK_LBUTTON) & 0x8000)
  2446     if (GetKeyState(VK_LBUTTON) & 0x8000)
  2447         modifiers |= Button1Mask;
  2447 	modifiers |= Button1Mask;
  2448     if (GetKeyState(VK_MBUTTON) & 0x8000)
  2448     if (GetKeyState(VK_MBUTTON) & 0x8000)
  2449         modifiers |= Button2Mask;
  2449 	modifiers |= Button2Mask;
  2450     if (GetKeyState(VK_RBUTTON) & 0x8000)
  2450     if (GetKeyState(VK_RBUTTON) & 0x8000)
  2451         modifiers |= Button3Mask;
  2451 	modifiers |= Button3Mask;
  2452 
  2452 
  2453     if ((modifiers & AnyButtonMask) == 0) {
  2453     if ((modifiers & AnyButtonMask) == 0) {
  2454         __eatingMouseEvents = 0;
  2454 	__eatingMouseEvents = 0;
  2455     }
  2455     }
  2456     return modifiers;
  2456     return modifiers;
  2457 }
  2457 }
  2458 
  2458 
  2459 #ifndef PRE_01_APR_04
  2459 #ifndef PRE_01_APR_04
  2463 */
  2463 */
  2464 
  2464 
  2465 # define MustHandleButtonEvent()\
  2465 # define MustHandleButtonEvent()\
  2466     (((__currentCapture == CAPTURE_NONE)       \
  2466     (((__currentCapture == CAPTURE_NONE)       \
  2467      && (   (GetKeyState(VK_LBUTTON) & 0x8000) \
  2467      && (   (GetKeyState(VK_LBUTTON) & 0x8000) \
  2468          || (GetKeyState(VK_MBUTTON) & 0x8000) \
  2468 	 || (GetKeyState(VK_MBUTTON) & 0x8000) \
  2469          || (GetKeyState(VK_RBUTTON) & 0x8000) \
  2469 	 || (GetKeyState(VK_RBUTTON) & 0x8000) \
  2470         )                                      \
  2470 	)                                      \
  2471     ) ? 0 : 1)
  2471     ) ? 0 : 1)
  2472 
  2472 
  2473 #else
  2473 #else
  2474 # define MustHandleButtonEvent()   1
  2474 # define MustHandleButtonEvent()   1
  2475 #endif
  2475 #endif
  2489 {
  2489 {
  2490     localWindowInfo *lI;
  2490     localWindowInfo *lI;
  2491     int gravity;
  2491     int gravity;
  2492 
  2492 
  2493     if (lI = GETLOCALWINDOWINFOPTR(hChild)) {
  2493     if (lI = GETLOCALWINDOWINFOPTR(hChild)) {
  2494         if ((gravity = lI->viewGravity) != GRAVITY_NONE) {
  2494 	if ((gravity = lI->viewGravity) != GRAVITY_NONE) {
  2495             RECT oldChildRct, oldChildWinRct;
  2495 	    RECT oldChildRct, oldChildWinRct;
  2496             RECT newChildRct;
  2496 	    RECT newChildRct;
  2497             int deltaW, deltaH;
  2497 	    int deltaW, deltaH;
  2498             int anyChange = 0;
  2498 	    int anyChange = 0;
  2499 
  2499 
  2500             /*
  2500 	    /*
  2501              * get its current bounds ...
  2501 	     * get its current bounds ...
  2502              */
  2502 	     */
  2503             GetClientRect(hChild, &oldChildRct);
  2503 	    GetClientRect(hChild, &oldChildRct);
  2504             deltaW = iP->newW - iP->currW;
  2504 	    deltaW = iP->newW - iP->currW;
  2505             deltaH = iP->newH - iP->currH;
  2505 	    deltaH = iP->newH - iP->currH;
  2506 
  2506 
  2507             GetWindowRect(hChild, &oldChildWinRct);
  2507 	    GetWindowRect(hChild, &oldChildWinRct);
  2508             oldChildRct.left = oldChildWinRct.left - iP->parentWinX;
  2508 	    oldChildRct.left = oldChildWinRct.left - iP->parentWinX;
  2509             oldChildRct.top =  oldChildWinRct.top - iP->parentWinY;
  2509 	    oldChildRct.top =  oldChildWinRct.top - iP->parentWinY;
  2510 
  2510 
  2511             newChildRct = oldChildRct;
  2511 	    newChildRct = oldChildRct;
  2512             switch (gravity) {
  2512 	    switch (gravity) {
  2513 #if 0
  2513 #if 0
  2514                 case GRAVITY_N:
  2514 		case GRAVITY_N:
  2515                     console_fprintf(stderr, "WinWorkstation [info]: Child %x: North gravity\n", hChild);
  2515 		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: North gravity\n", hChild);
  2516                     /*
  2516 		    /*
  2517                      * shift to the bottom, for a constant
  2517 		     * shift to the bottom, for a constant
  2518                      * distance from the bottom edge;
  2518 		     * distance from the bottom edge;
  2519                      */
  2519 		     */
  2520                     newChildRct.bottom += deltaH;
  2520 		    newChildRct.bottom += deltaH;
  2521                     anyChange = 1;
  2521 		    anyChange = 1;
  2522                     break;
  2522 		    break;
  2523 
  2523 
  2524                 case GRAVITY_W:
  2524 		case GRAVITY_W:
  2525                     console_fprintf(stderr, "WinWorkstation [info]: Child %x: West gravity\n", hChild);
  2525 		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: West gravity\n", hChild);
  2526                     /*
  2526 		    /*
  2527                      * shift to the right, for a constant
  2527 		     * shift to the right, for a constant
  2528                      * distance from the right edge;
  2528 		     * distance from the right edge;
  2529                      */
  2529 		     */
  2530                     newChildRct.right += deltaW;
  2530 		    newChildRct.right += deltaW;
  2531                     anyChange = 1;
  2531 		    anyChange = 1;
  2532                     break;
  2532 		    break;
  2533 #endif
  2533 #endif
  2534                 case GRAVITY_S:
  2534 		case GRAVITY_S:
  2535                     console_fprintf(stderr, "WinWorkstation [info]: Child %x: South gravity\n", hChild);
  2535 		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: South gravity\n", hChild);
  2536                     /*
  2536 		    /*
  2537                      * shift to the bottom, for a constant
  2537 		     * shift to the bottom, for a constant
  2538                      * distance from the bottom edge;
  2538 		     * distance from the bottom edge;
  2539                      */
  2539 		     */
  2540                     newChildRct.top += deltaH;
  2540 		    newChildRct.top += deltaH;
  2541                     newChildRct.bottom  += deltaH;
  2541 		    newChildRct.bottom  += deltaH;
  2542                     anyChange = 1;
  2542 		    anyChange = 1;
  2543                     break;
  2543 		    break;
  2544 
  2544 
  2545                 case GRAVITY_E:
  2545 		case GRAVITY_E:
  2546                     console_fprintf(stderr, "WinWorkstation [info]: Child %x: East gravity\n", hChild);
  2546 		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: East gravity\n", hChild);
  2547                     /*
  2547 		    /*
  2548                      * shift to the right, for a constant
  2548 		     * shift to the right, for a constant
  2549                      * distance from the right edge;
  2549 		     * distance from the right edge;
  2550                      */
  2550 		     */
  2551                     newChildRct.right += deltaW;
  2551 		    newChildRct.right += deltaW;
  2552                     newChildRct.left  += deltaW;
  2552 		    newChildRct.left  += deltaW;
  2553                     anyChange = 1;
  2553 		    anyChange = 1;
  2554                     break;
  2554 		    break;
  2555 
  2555 
  2556                 case GRAVITY_SE:
  2556 		case GRAVITY_SE:
  2557                     console_fprintf(stderr, "WinWorkstation [info]: Child %x: SouthEast gravity\n", hChild);
  2557 		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: SouthEast gravity\n", hChild);
  2558                     /*
  2558 		    /*
  2559                      * shift to the bottom-right, for a constant
  2559 		     * shift to the bottom-right, for a constant
  2560                      * distance from the bottom-right edge;
  2560 		     * distance from the bottom-right edge;
  2561                      */
  2561 		     */
  2562                     newChildRct.right += deltaW;
  2562 		    newChildRct.right += deltaW;
  2563                     newChildRct.left  += deltaW;
  2563 		    newChildRct.left  += deltaW;
  2564                     newChildRct.top += deltaH;
  2564 		    newChildRct.top += deltaH;
  2565                     newChildRct.bottom  += deltaH;
  2565 		    newChildRct.bottom  += deltaH;
  2566                     anyChange = 1;
  2566 		    anyChange = 1;
  2567                     break;
  2567 		    break;
  2568 
  2568 
  2569                 default:
  2569 		default:
  2570                     DPRINTF(("Child %x: other gravity\n", hChild));
  2570 		    DPRINTF(("Child %x: other gravity\n", hChild));
  2571                     break;
  2571 		    break;
  2572             }
  2572 	    }
  2573 
  2573 
  2574             if (anyChange) {
  2574 	    if (anyChange) {
  2575                 if ((newChildRct.left < 0)
  2575 		if ((newChildRct.left < 0)
  2576                  || (newChildRct.top < 0)
  2576 		 || (newChildRct.top < 0)
  2577                  || (newChildRct.right >= iP->newW)
  2577 		 || (newChildRct.right >= iP->newW)
  2578                  || (newChildRct.bottom >= iP->newH)) {
  2578 		 || (newChildRct.bottom >= iP->newH)) {
  2579                     console_fprintf(stderr, "WinWorkstation [info]: dont move child to: %d/%d -> %d/%d\n",
  2579 		    console_fprintf(stderr, "WinWorkstation [info]: dont move child to: %d/%d -> %d/%d\n",
  2580                                     newChildRct.left, newChildRct.top,
  2580 				    newChildRct.left, newChildRct.top,
  2581                                     newChildRct.right, newChildRct.bottom);
  2581 				    newChildRct.right, newChildRct.bottom);
  2582                 } else {
  2582 		} else {
  2583                     console_fprintf(stderr, "WinWorkstation [info]: move child from %d/%d->%d/%d to: %d/%d->%d/%d\n",
  2583 		    console_fprintf(stderr, "WinWorkstation [info]: move child from %d/%d->%d/%d to: %d/%d->%d/%d\n",
  2584                                     oldChildRct.left, oldChildRct.top,
  2584 				    oldChildRct.left, oldChildRct.top,
  2585                                     oldChildRct.right, oldChildRct.bottom,
  2585 				    oldChildRct.right, oldChildRct.bottom,
  2586                                     newChildRct.left, newChildRct.top,
  2586 				    newChildRct.left, newChildRct.top,
  2587                                     newChildRct.right, newChildRct.bottom);
  2587 				    newChildRct.right, newChildRct.bottom);
  2588 
  2588 
  2589                     SetWindowPos(hChild, (HWND)0,
  2589 		    SetWindowPos(hChild, (HWND)0,
  2590                                  newChildRct.left, newChildRct.top,
  2590 				 newChildRct.left, newChildRct.top,
  2591                                  0, 0,
  2591 				 0, 0,
  2592                                  /* SWP_NOSENDCHANGING | */
  2592 				 /* SWP_NOSENDCHANGING | */
  2593                                  SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
  2593 				 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
  2594                 }
  2594 		}
  2595             }
  2595 	    }
  2596         }
  2596 	}
  2597     }
  2597     }
  2598     return TRUE;
  2598     return TRUE;
  2599 }
  2599 }
  2600 #endif /* HANDLE_VIEWGRAVITY */
  2600 #endif /* HANDLE_VIEWGRAVITY */
  2601 
  2601 
  2604 {
  2604 {
  2605     unsigned char *cp = (unsigned char *)in;
  2605     unsigned char *cp = (unsigned char *)in;
  2606     wchar_t *wcp = out;
  2606     wchar_t *wcp = out;
  2607 
  2607 
  2608     while ((nMax > 1) && cp && *cp) {
  2608     while ((nMax > 1) && cp && *cp) {
  2609         *wcp++ = *cp++;
  2609 	*wcp++ = *cp++;
  2610         nMax--;
  2610 	nMax--;
  2611     }
  2611     }
  2612     *wcp = 0;
  2612     *wcp = 0;
  2613 }
  2613 }
  2614 
  2614 
  2615 static int
  2615 static int
  2616 winEventProcessing(
  2616 winEventProcessing(
  2617         HWND hWnd,         /* window handle                   */
  2617 	HWND hWnd,         /* window handle                   */
  2618         UINT message,      /* type of message                 */
  2618 	UINT message,      /* type of message                 */
  2619         UINT wParam,       /* additional information          */
  2619 	UINT wParam,       /* additional information          */
  2620         INT lParam,        /* additional information          */
  2620 	INT lParam,        /* additional information          */
  2621         int *pDefault
  2621 	int *pDefault
  2622     ) {
  2622     ) {
  2623     int curButton;
  2623     int curButton;
  2624     int x, y, w, h;
  2624     int x, y, w, h;
  2625     int isNative = 0;
  2625     int isNative = 0;
  2626     UINT evTime;
  2626     UINT evTime;
  2629      * but lost here. (slightly inexact ... but who cares)
  2629      * but lost here. (slightly inexact ... but who cares)
  2630      */
  2630      */
  2631     evTime = lastMSGTime;
  2631     evTime = lastMSGTime;
  2632     lastMSGTime = 0;
  2632     lastMSGTime = 0;
  2633     if (evTime == 0) {
  2633     if (evTime == 0) {
  2634         lastMSGTime = GetTickCount();
  2634 	lastMSGTime = GetTickCount();
  2635     }
  2635     }
  2636 
  2636 
  2637 /*
  2637 /*
  2638     EVENT_PRINTF(("winEvent hWin=0x%x message=0x%x wP=0x%x lP=0x%x\n",
  2638     EVENT_PRINTF(("winEvent hWin=0x%x message=0x%x wP=0x%x lP=0x%x\n",
  2639                         hWnd, message, wParam, lParam));
  2639 			hWnd, message, wParam, lParam));
  2640 */
  2640 */
  2641 
  2641 
  2642     if (hWnd) {
  2642     if (hWnd) {
  2643         if (message != WM_MOUSEMOVE) {
  2643 	if (message != WM_MOUSEMOVE) {
  2644             lastMotionWnd = 0;
  2644 	    lastMotionWnd = 0;
  2645         }
  2645 	}
  2646 
  2646 
  2647         isNative = (GetWindow_flag(hWnd) & LI_NATIVEWIN);
  2647 	isNative = (GetWindow_flag(hWnd) & LI_NATIVEWIN);
  2648         if (isNative) {
  2648 	if (isNative) {
  2649             NDPRINTF(("event %d (0x%x) for nativeWindow\n", message, message));
  2649 	    NDPRINTF(("event %d (0x%x) for nativeWindow\n", message, message));
  2650         }
  2650 	}
  2651     }
  2651     }
  2652 
  2652 
  2653     /*
  2653     /*
  2654      * messages which are enqueued to be handled by the view thread
  2654      * messages which are enqueued to be handled by the view thread
  2655      */
  2655      */
  2656     switch (message) {
  2656     switch (message) {
  2657         case WM_THREAD_CREATEWINDOW:
  2657 	case WM_THREAD_CREATEWINDOW:
  2658             EVENT_PRINTF(("*WM_THREAD_CREATEWINDOW\n"));
  2658 	    EVENT_PRINTF(("*WM_THREAD_CREATEWINDOW\n"));
  2659 
  2659 
  2660             {
  2660 	    {
  2661                 createWindowInfo *cwi = (createWindowInfo *)(lParam);
  2661 		createWindowInfo *cwi = (createWindowInfo *)(lParam);
  2662 
  2662 
  2663                 if ((cwi->sequenceNr == wParam)
  2663 		if ((cwi->sequenceNr == wParam)
  2664                  && (cwi->sequenceNr != INVALIDATED_CWI)) {
  2664 		 && (cwi->sequenceNr != INVALIDATED_CWI)) {
  2665                     cwi->sequenceNr = INVALIDATED_CWI;
  2665 		    cwi->sequenceNr = INVALIDATED_CWI;
  2666                     cwi->infoWasRead = 1;
  2666 		    cwi->infoWasRead = 1;
  2667                     if (cwi->newWinHandle == NULL) {
  2667 		    if (cwi->newWinHandle == NULL) {
  2668                         HANDLE ev;
  2668 			HANDLE ev;
  2669                         HANDLE hwnd;
  2669 			HANDLE hwnd;
  2670 
  2670 
  2671                         cwi->newWinHandle = hwnd = CreateWindowExW(
  2671 			cwi->newWinHandle = hwnd = CreateWindowExW(
  2672                                             cwi->winStyleBitsEx,
  2672 					    cwi->winStyleBitsEx,
  2673                                             cwi->className,
  2673 					    cwi->className,
  2674                                             cwi->windowName,
  2674 					    cwi->windowName,
  2675                                             cwi->winStyleBits,
  2675 					    cwi->winStyleBits,
  2676                                             cwi->x, cwi->y,
  2676 					    cwi->x, cwi->y,
  2677                                             cwi->dx, cwi->dy,
  2677 					    cwi->dx, cwi->dy,
  2678                                             cwi->parentHandle,
  2678 					    cwi->parentHandle,
  2679                                             NULL,           /* menu */
  2679 					    NULL,           /* menu */
  2680                                             (HANDLE) __getHInstance(),
  2680 					    (HANDLE) __getHInstance(),
  2681                                             cwi->localWindowInfo
  2681 					    cwi->localWindowInfo
  2682                                            );
  2682 					   );
  2683 
  2683 
  2684                         if (hwnd == NULL) {
  2684 			if (hwnd == NULL) {
  2685                             cwi->errCode = GetLastError();
  2685 			    cwi->errCode = GetLastError();
  2686                             console_fprintf(stderr, "WinWorkstation [info]: CreateWindow failed: %d (0x%x) [%d]\n",
  2686 			    console_fprintf(stderr, "WinWorkstation [info]: CreateWindow failed: %d (0x%x) [%d]\n",
  2687                                                 cwi->errCode, cwi->errCode, __LINE__);
  2687 						cwi->errCode, cwi->errCode, __LINE__);
  2688                         } else {
  2688 			} else {
  2689                             SETLOCALWINDOWINFOPTR(hwnd, cwi->localWindowInfo);
  2689 			    SETLOCALWINDOWINFOPTR(hwnd, cwi->localWindowInfo);
  2690 #ifdef DEBUG /* PARANOIA */
  2690 #ifdef DEBUG /* PARANOIA */
  2691                             if (GETLOCALWINDOWINFOPTR(hwnd) != cwi->localWindowInfo) {
  2691 			    if (GETLOCALWINDOWINFOPTR(hwnd) != cwi->localWindowInfo) {
  2692                                console_fprintf(stderr, "lI-Error\n");
  2692 			       console_fprintf(stderr, "lI-Error\n");
  2693                             }
  2693 			    }
  2694 #endif
  2694 #endif
  2695                             SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
  2695 			    SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
  2696                                         /* SWP_NOOWNERZORDER |*/
  2696 					/* SWP_NOOWNERZORDER |*/
  2697                                         SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  2697 					SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  2698                         }
  2698 			}
  2699 
  2699 
  2700                         ev = cwi->hCreateEvent;
  2700 			ev = cwi->hCreateEvent;
  2701                         if (ev) {
  2701 			if (ev) {
  2702                             SetEvent(ev);
  2702 			    SetEvent(ev);
  2703                         }
  2703 			}
  2704                     }
  2704 		    }
  2705                 } else {
  2705 		} else {
  2706                     DPRINTF(("obsolete createWindow message %x ignored\n", cwi->sequenceNr));
  2706 		    DPRINTF(("obsolete createWindow message %x ignored\n", cwi->sequenceNr));
  2707                 }
  2707 		}
  2708             }
  2708 	    }
  2709             *pDefault = 0;
  2709 	    *pDefault = 0;
  2710             return 0;
  2710 	    return 0;
  2711 
  2711 
  2712         case WM_THREAD_DESTROYWINDOW:
  2712 	case WM_THREAD_DESTROYWINDOW:
  2713             {
  2713 	    {
  2714                 HBRUSH br;
  2714 		HBRUSH br;
  2715 
  2715 
  2716                 br = GetWindow_viewBgBrush(hWnd);
  2716 		br = GetWindow_viewBgBrush(hWnd);
  2717                 if (br) {
  2717 		if (br) {
  2718                     SetWindow_viewBgBrush(hWnd, 0);
  2718 		    SetWindow_viewBgBrush(hWnd, 0);
  2719                     _DeleteBrushIfNotInCache(br, __LINE__);
  2719 		    _DeleteBrushIfNotInCache(br, __LINE__);
  2720                 }
  2720 		}
  2721             }
  2721 	    }
  2722 
  2722 
  2723 #ifdef CACHE_LAST_DC
  2723 #ifdef CACHE_LAST_DC
  2724             if (lastGcData && (lastGcHWIN == hWnd)) {
  2724 	    if (lastGcData && (lastGcHWIN == hWnd)) {
  2725                 _releaseDC(lastGcData);
  2725 		_releaseDC(lastGcData);
  2726             }
  2726 	    }
  2727 #endif
  2727 #endif
  2728 #ifdef CACHE_LAST_WM_PAINT_DC
  2728 #ifdef CACHE_LAST_WM_PAINT_DC
  2729             if (last_wm_paint_dc && (last_wm_paint_win == hWnd)) {
  2729 	    if (last_wm_paint_dc && (last_wm_paint_win == hWnd)) {
  2730                 ReleaseDC(hWnd, last_wm_paint_dc);
  2730 		ReleaseDC(hWnd, last_wm_paint_dc);
  2731                 last_wm_paint_win = last_wm_paint_dc = 0;
  2731 		last_wm_paint_win = last_wm_paint_dc = 0;
  2732             }
  2732 	    }
  2733 #endif
  2733 #endif
  2734             if (! DestroyWindow(hWnd)) {
  2734 	    if (! DestroyWindow(hWnd)) {
  2735                 DPRINTF(("DestroyWindow ERROR\n"));
  2735 		DPRINTF(("DestroyWindow ERROR\n"));
  2736             } else {
  2736 	    } else {
  2737 #ifdef COUNT_RESOURCES
  2737 #ifdef COUNT_RESOURCES
  2738                 __cnt_createWindows--;
  2738 		__cnt_createWindows--;
  2739                 RESPRINTF(("DestroyWindow -> %d\n", __cnt_createWindows));
  2739 		RESPRINTF(("DestroyWindow -> %d\n", __cnt_createWindows));
  2740 #endif
  2740 #endif
  2741             }
  2741 	    }
  2742             *pDefault = 0;
  2742 	    *pDefault = 0;
  2743             return 0;
  2743 	    return 0;
  2744 
  2744 
  2745         case WM_CREATE:
  2745 	case WM_CREATE:
  2746             {
  2746 	    {
  2747 #ifdef SETLOCALINFO_IN_CREATE /* no longer */
  2747 #ifdef SETLOCALINFO_IN_CREATE /* no longer */
  2748                 localWindowInfo *lI;
  2748 		localWindowInfo *lI;
  2749 
  2749 
  2750                 CREATESTRUCT *lpcs = (LPCREATESTRUCT) lParam; // structure with creation data
  2750 		CREATESTRUCT *lpcs = (LPCREATESTRUCT) lParam; // structure with creation data
  2751 
  2751 
  2752                 lI = lpcs->lpCreateParams;
  2752 		lI = lpcs->lpCreateParams;
  2753                 EVENT_PRINTF(("WM_CREATE lI=%x\n", lI));
  2753 		EVENT_PRINTF(("WM_CREATE lI=%x\n", lI));
  2754 
  2754 
  2755                 SETLOCALWINDOWINFOPTR(hWnd, lI);
  2755 		SETLOCALWINDOWINFOPTR(hWnd, lI);
  2756 # ifdef SUPERDEBUG
  2756 # ifdef SUPERDEBUG
  2757                 if (GETLOCALWINDOWINFOPTR(hWnd) != lpcs->lpCreateParams) {
  2757 		if (GETLOCALWINDOWINFOPTR(hWnd) != lpcs->lpCreateParams) {
  2758                     PRINTF(("SETLOCALWINDOWINFOPTR ERROR\n"));
  2758 		    PRINTF(("SETLOCALWINDOWINFOPTR ERROR\n"));
  2759                 }
  2759 		}
  2760 # endif /* SUPERDEBUG */
  2760 # endif /* SUPERDEBUG */
  2761 #endif
  2761 #endif
  2762 
  2762 
  2763                 *pDefault = 0;
  2763 		*pDefault = 0;
  2764 #ifdef COUNT_RESOURCES
  2764 #ifdef COUNT_RESOURCES
  2765                 __cnt_createWindows++;
  2765 		__cnt_createWindows++;
  2766                 RESPRINTF(("CreateWindows %d\n",__cnt_createWindows));
  2766 		RESPRINTF(("CreateWindows %d\n",__cnt_createWindows));
  2767 #endif
  2767 #endif
  2768             }
  2768 	    }
  2769             break;
  2769 	    break;
  2770 
  2770 
  2771         case WM_CLOSE:
  2771 	case WM_CLOSE:
  2772             EVENT_PRINTF(("WM_CLOSE\n"));
  2772 	    EVENT_PRINTF(("WM_CLOSE\n"));
  2773             if (! destroyWin) {
  2773 	    if (! destroyWin) {
  2774                 // (flag, hWnd, message, wParam, arg1, arg2, arg3, arg4, evTime)
  2774 		// (flag, hWnd, message, wParam, arg1, arg2, arg3, arg4, evTime)
  2775                 enqEvent(0, hWnd, WM_CLOSE, wParam, 0, 0, 0, 0, EV_NOTIME);
  2775 		enqEvent(0, hWnd, WM_CLOSE, wParam, 0, 0, 0, 0, EV_NOTIME);
  2776             } else {
  2776 	    } else {
  2777                 destroyWin = 0;
  2777 		destroyWin = 0;
  2778                 {
  2778 		{
  2779                     HBRUSH br;
  2779 		    HBRUSH br;
  2780 
  2780 
  2781                     br = GetWindow_viewBgBrush(hWnd);
  2781 		    br = GetWindow_viewBgBrush(hWnd);
  2782                     if (br) {
  2782 		    if (br) {
  2783                         SetWindow_viewBgBrush(hWnd, 0);
  2783 			SetWindow_viewBgBrush(hWnd, 0);
  2784                         _DeleteBrushIfNotInCache(br, __LINE__);
  2784 			_DeleteBrushIfNotInCache(br, __LINE__);
  2785                     }
  2785 		    }
  2786                 }
  2786 		}
  2787 #ifdef CACHE_LAST_DC
  2787 #ifdef CACHE_LAST_DC
  2788                 if (lastGcData && (lastGcHWIN == hWnd)) {
  2788 		if (lastGcData && (lastGcHWIN == hWnd)) {
  2789                     _releaseDC(lastGcData);
  2789 		    _releaseDC(lastGcData);
  2790                 }
  2790 		}
  2791 #endif
  2791 #endif
  2792 #ifdef CACHE_LAST_WM_PAINT_DC
  2792 #ifdef CACHE_LAST_WM_PAINT_DC
  2793                 if (last_wm_paint_dc && (last_wm_paint_win == hWnd)) {
  2793 		if (last_wm_paint_dc && (last_wm_paint_win == hWnd)) {
  2794                     ReleaseDC(hWnd, last_wm_paint_dc);
  2794 		    ReleaseDC(hWnd, last_wm_paint_dc);
  2795                     last_wm_paint_win = last_wm_paint_dc = 0;
  2795 		    last_wm_paint_win = last_wm_paint_dc = 0;
  2796                 }
  2796 		}
  2797 #endif
  2797 #endif
  2798                 if (! DestroyWindow(hWnd)) {
  2798 		if (! DestroyWindow(hWnd)) {
  2799                     DPRINTF(("DestroyWindow ERROR\n"));
  2799 		    DPRINTF(("DestroyWindow ERROR\n"));
  2800                 } else {
  2800 		} else {
  2801 #ifdef COUNT_RESOURCES
  2801 #ifdef COUNT_RESOURCES
  2802                     __cnt_createWindows--;
  2802 		    __cnt_createWindows--;
  2803                     RESPRINTF(("DestroyWindow -> %d\n", __cnt_createWindows));
  2803 		    RESPRINTF(("DestroyWindow -> %d\n", __cnt_createWindows));
  2804 #endif
  2804 #endif
  2805                 }
  2805 		}
  2806             }
  2806 	    }
  2807             *pDefault = 0;
  2807 	    *pDefault = 0;
  2808             return 0;
  2808 	    return 0;
  2809             break;
  2809 	    break;
  2810 
  2810 
  2811         case WM_DESTROY:
  2811 	case WM_DESTROY:
  2812             {
  2812 	    {
  2813                 char *nm = 0;
  2813 		char *nm = 0;
  2814                 localWindowInfo *lI;
  2814 		localWindowInfo *lI;
  2815 
  2815 
  2816                 lI = GETLOCALWINDOWINFOPTR(hWnd);
  2816 		lI = GETLOCALWINDOWINFOPTR(hWnd);
  2817                 EVENT_PRINTF(("WM_DESTROY %x li=%x\n", hWnd, lI));
  2817 		EVENT_PRINTF(("WM_DESTROY %x li=%x\n", hWnd, lI));
  2818 
  2818 
  2819 #ifdef TOPWINDOWCLASS
  2819 #ifdef TOPWINDOWCLASS
  2820                 if (lI) {
  2820 		if (lI) {
  2821                     if (lI->flag & LI_TOPWIN) {
  2821 		    if (lI->flag & LI_TOPWIN) {
  2822                         nm = (char*) malloc(300);
  2822 			nm = (char*) malloc(300);
  2823                         GetClassName(hWnd, nm, 300);
  2823 			GetClassName(hWnd, nm, 300);
  2824                     }
  2824 		    }
  2825                     /* freeing now done in other thread */
  2825 		    /* freeing now done in other thread */
  2826                 }
  2826 		}
  2827 #endif
  2827 #endif
  2828                 SETLOCALWINDOWINFOPTR(hWnd, 0);
  2828 		SETLOCALWINDOWINFOPTR(hWnd, 0);
  2829 
  2829 
  2830 #ifdef FREE_LI_IN_STX_PROCESS
  2830 #ifdef FREE_LI_IN_STX_PROCESS
  2831                 enqEvent(0, hWnd, WM_DESTROY, wParam, (INT)nm, lI, 0, 0, EV_NOTIME);
  2831 		enqEvent(0, hWnd, WM_DESTROY, wParam, (INT)nm, lI, 0, 0, EV_NOTIME);
  2832 #else
  2832 #else
  2833                 if (lI) {
  2833 		if (lI) {
  2834                     free(lI);
  2834 		    free(lI);
  2835                 }
  2835 		}
  2836                 enqEvent(0, hWnd, WM_DESTROY, wParam, (INT)nm, 0, 0, 0, EV_NOTIME);
  2836 		enqEvent(0, hWnd, WM_DESTROY, wParam, (INT)nm, 0, 0, 0, EV_NOTIME);
  2837 #endif
  2837 #endif
  2838                 *pDefault = 0;
  2838 		*pDefault = 0;
  2839                 return 0;
  2839 		return 0;
  2840             }
  2840 	    }
  2841             break;
  2841 	    break;
  2842 
  2842 
  2843         case WM_GETMINMAXINFO:
  2843 	case WM_GETMINMAXINFO:
  2844 
  2844 
  2845 #ifndef PRE_13_APR_04_POSCHANGED_IN_EXITSIZEMOVE
  2845 #ifndef PRE_13_APR_04_POSCHANGED_IN_EXITSIZEMOVE
  2846             if (inMove) {
  2846 	    if (inMove) {
  2847                 *pDefault = 0;
  2847 		*pDefault = 0;
  2848                 return 0;
  2848 		return 0;
  2849             }
  2849 	    }
  2850 #endif
  2850 #endif
  2851 
  2851 
  2852             {
  2852 	    {
  2853                 int minW, maxW;
  2853 		int minW, maxW;
  2854                 localWindowInfo *lI;
  2854 		localWindowInfo *lI;
  2855                 LPMINMAXINFO lpmmi = (LPMINMAXINFO) lParam;
  2855 		LPMINMAXINFO lpmmi = (LPMINMAXINFO) lParam;
  2856 
  2856 
  2857                 EVENT_PRINTF2(("WM_GETMINMAXINFO handle=%x got min: %d/%d\n",
  2857 		EVENT_PRINTF2(("WM_GETMINMAXINFO handle=%x got min: %d/%d\n",
  2858                             hWnd,
  2858 			    hWnd,
  2859                             lpmmi->ptMinTrackSize.x,
  2859 			    lpmmi->ptMinTrackSize.x,
  2860                             lpmmi->ptMinTrackSize.y));
  2860 			    lpmmi->ptMinTrackSize.y));
  2861 
  2861 
  2862                 lI = GETLOCALWINDOWINFOPTR(hWnd);
  2862 		lI = GETLOCALWINDOWINFOPTR(hWnd);
  2863                 if (lI && (lI->minWidth) && (lI->maxWidth)) {
  2863 		if (lI && (lI->minWidth) && (lI->maxWidth)) {
  2864                   lpmmi->ptMaxPosition.x = 0;
  2864 		  lpmmi->ptMaxPosition.x = 0;
  2865                   lpmmi->ptMaxPosition.y = 0;
  2865 		  lpmmi->ptMaxPosition.y = 0;
  2866                   lpmmi->ptMaxSize.x = lI->currentMonitorWidth;
  2866 		  lpmmi->ptMaxSize.x = lI->currentMonitorWidth;
  2867                   lpmmi->ptMaxSize.y = lI->currentMonitorHeight;
  2867 		  lpmmi->ptMaxSize.y = lI->currentMonitorHeight;
  2868 #define MIN(a, b) (a < b ? a : b)
  2868 #define MIN(a, b) (a < b ? a : b)
  2869                   lpmmi->ptMaxSize.x = MIN(GetSystemMetrics(SM_CXMAXIMIZED), lI->maxWidth);
  2869 		  lpmmi->ptMaxSize.x = MIN(GetSystemMetrics(SM_CXMAXIMIZED), lI->maxWidth);
  2870                   lpmmi->ptMaxSize.y = MIN(GetSystemMetrics(SM_CYMAXIMIZED), lI->maxHeight);
  2870 		  lpmmi->ptMaxSize.y = MIN(GetSystemMetrics(SM_CYMAXIMIZED), lI->maxHeight);
  2871 
  2871 
  2872                   lpmmi->ptMaxTrackSize.x = lI->maxWidth == 0 ? GetSystemMetrics(SM_CXMAXTRACK) : lI->maxWidth;
  2872 		  lpmmi->ptMaxTrackSize.x = lI->maxWidth == 0 ? GetSystemMetrics(SM_CXMAXTRACK) : lI->maxWidth;
  2873                   lpmmi->ptMaxTrackSize.y = lI->maxHeight == 0 ? GetSystemMetrics(SM_CYMAXTRACK) : lI->maxHeight;
  2873 		  lpmmi->ptMaxTrackSize.y = lI->maxHeight == 0 ? GetSystemMetrics(SM_CYMAXTRACK) : lI->maxHeight;
  2874                   lpmmi->ptMinTrackSize.x = lI->minWidth;
  2874 		  lpmmi->ptMinTrackSize.x = lI->minWidth;
  2875                   lpmmi->ptMinTrackSize.y = lI->minHeight;
  2875 		  lpmmi->ptMinTrackSize.y = lI->minHeight;
  2876 
  2876 
  2877                   EVENT_PRINTF3(("WM_GETMINMAXINFO handle=%x return min: %d/%d max: %d/%d\n",
  2877 		  EVENT_PRINTF3(("WM_GETMINMAXINFO handle=%x return min: %d/%d max: %d/%d\n",
  2878                                   hWnd,
  2878 				  hWnd,
  2879                                   lI->minWidth, lI->minHeight,
  2879 				  lI->minWidth, lI->minHeight,
  2880                                   lI->maxWidth, lI->maxHeight));
  2880 				  lI->maxWidth, lI->maxHeight));
  2881                   *pDefault = 0;
  2881 		  *pDefault = 0;
  2882                 }
  2882 		}
  2883             }
  2883 	    }
  2884             break;
  2884 	    break;
  2885 
  2885 
  2886         case WM_SETCURSOR:
  2886 	case WM_SETCURSOR:
  2887             {
  2887 	    {
  2888                 HCURSOR curs;
  2888 		HCURSOR curs;
  2889                 int hitCode;
  2889 		int hitCode;
  2890 
  2890 
  2891                 hitCode = LOWORD(lParam);
  2891 		hitCode = LOWORD(lParam);
  2892                 if (hitCode != HTCLIENT) {
  2892 		if (hitCode != HTCLIENT) {
  2893                     /*
  2893 		    /*
  2894                      * not in client area ...
  2894 		     * not in client area ...
  2895                      */
  2895 		     */
  2896                     return 0;
  2896 		    return 0;
  2897                 }
  2897 		}
  2898                 DPRINTFIF(__debug_WM_SETCURSOR__ , ("WM_SETCURSOR\n"));
  2898 		DPRINTFIF(__debug_WM_SETCURSOR__ , ("WM_SETCURSOR\n"));
  2899                 curs = GetWindow_Cursor(hWnd);
  2899 		curs = GetWindow_Cursor(hWnd);
  2900                 if (curs) {
  2900 		if (curs) {
  2901                     SetCursor(curs);
  2901 		    SetCursor(curs);
  2902                     *pDefault = 0;
  2902 		    *pDefault = 0;
  2903                     return 1;
  2903 		    return 1;
  2904                 }
  2904 		}
  2905             }
  2905 	    }
  2906             return 0;
  2906 	    return 0;
  2907 
  2907 
  2908         case WM_WINDOWPOSCHANGED:
  2908 	case WM_WINDOWPOSCHANGED:
  2909 
  2909 
  2910 #ifndef PRE_13_APR_04_POSCHANGED_IN_EXITSIZEMOVE
  2910 #ifndef PRE_13_APR_04_POSCHANGED_IN_EXITSIZEMOVE
  2911             if (inMove) {
  2911 	    if (inMove) {
  2912                 *pDefault = 0;
  2912 		*pDefault = 0;
  2913                 return 0;
  2913 		return 0;
  2914             }
  2914 	    }
  2915 #endif
  2915 #endif
  2916             if (hWnd == __rootWinSpezial) {
  2916 	    if (hWnd == __rootWinSpezial) {
  2917                 /* can this happen ? */
  2917 		/* can this happen ? */
  2918                 *pDefault = 1;
  2918 		*pDefault = 1;
  2919                 return 0;
  2919 		return 0;
  2920             }
  2920 	    }
  2921 
  2921 
  2922             if (! inMove && (__currentCapture == CAPTURE_NONE)) {
  2922 	    if (! inMove && (__currentCapture == CAPTURE_NONE)) {
  2923                 POINT p;
  2923 		POINT p;
  2924                 HWND hWndChild,hWndTemp;
  2924 		HWND hWndChild,hWndTemp;
  2925 
  2925 
  2926                 p.x = evRootX;
  2926 		p.x = evRootX;
  2927                 p.y = evRootY;
  2927 		p.y = evRootY;
  2928                 ScreenToClient(hWnd, &p);
  2928 		ScreenToClient(hWnd, &p);
  2929                 hWndChild = hWnd; //hWndChild = ChildWindowFromPoint(hWnd,p);
  2929 		hWndChild = hWnd; //hWndChild = ChildWindowFromPoint(hWnd,p);
  2930                 do {
  2930 		do {
  2931                     hWndTemp = hWndChild;
  2931 		    hWndTemp = hWndChild;
  2932                     hWndChild = ChildWindowFromPointEx(hWndTemp,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
  2932 		    hWndChild = ChildWindowFromPointEx(hWndTemp,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
  2933                 } while ((hWndChild) && (hWndChild != hWndTemp));
  2933 		} while ((hWndChild) && (hWndChild != hWndTemp));
  2934 
  2934 
  2935                 if (hWndChild /*&& (hWndChild != hWnd)*/) {
  2935 		if (hWndChild /*&& (hWndChild != hWnd)*/) {
  2936                     if (hWndChild != __currentPointerView) {
  2936 		    if (hWndChild != __currentPointerView) {
  2937                         int modifiers = getModifiers();
  2937 			int modifiers = getModifiers();
  2938 
  2938 
  2939                         if (__currentPointerView) {
  2939 			if (__currentPointerView) {
  2940                             if (inSizeMove) {
  2940 			    if (inSizeMove) {
  2941                                 if (needDelayedMouseLeaveWindow == NULL) {
  2941 				if (needDelayedMouseLeaveWindow == NULL) {
  2942                                     needDelayedMouseLeaveWindow = __currentPointerView;
  2942 				    needDelayedMouseLeaveWindow = __currentPointerView;
  2943                                 }
  2943 				}
  2944                             } else {
  2944 			    } else {
  2945                                 if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  2945 				if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  2946                                     enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
  2946 				    enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
  2947                                     SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  2947 				    SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  2948                                 }
  2948 				}
  2949                             }
  2949 			    }
  2950                             __currentPointerView = 0;
  2950 			    __currentPointerView = 0;
  2951                         }
  2951 			}
  2952                         if (inSizeMove) {
  2952 			if (inSizeMove) {
  2953                             needDelayedMouseEnterWindow = hWndChild;
  2953 			    needDelayedMouseEnterWindow = hWndChild;
  2954                             delayedMouseEnterX = evRootX;
  2954 			    delayedMouseEnterX = evRootX;
  2955                             delayedMouseEnterY = evRootY;
  2955 			    delayedMouseEnterY = evRootY;
  2956                         } else {
  2956 			} else {
  2957                             if (GetWindow_eventMask(hWndChild) & EnterWindowMask) {
  2957 			    if (GetWindow_eventMask(hWndChild) & EnterWindowMask) {
  2958                                 enqEvent(EnterWindowMask, hWndChild, __WM_MOUSEENTER, 0, evRootX, evRootY, 0, modifiers, EV_NOTIME);
  2958 				enqEvent(EnterWindowMask, hWndChild, __WM_MOUSEENTER, 0, evRootX, evRootY, 0, modifiers, EV_NOTIME);
  2959                                 SetWindow_mouseXY(hWndChild, evRootX, evRootY);
  2959 				SetWindow_mouseXY(hWndChild, evRootX, evRootY);
  2960                             }
  2960 			    }
  2961                             // SetFocus(hWndChild);
  2961 			    // SetFocus(hWndChild);
  2962                         }
  2962 			}
  2963                         __currentPointerView = hWndChild;
  2963 			__currentPointerView = hWndChild;
  2964                     }
  2964 		    }
  2965                 }
  2965 		}
  2966             }
  2966 	    }
  2967 
  2967 
  2968             /*
  2968 	    /*
  2969              * ignore child window messages ...
  2969 	     * ignore child window messages ...
  2970              */
  2970 	     */
  2971             if (GetParent(hWnd) != NULL) {
  2971 	    if (GetParent(hWnd) != NULL) {
  2972                 break;
  2972 		break;
  2973             }
  2973 	    }
  2974 
  2974 
  2975             {
  2975 	    {
  2976                 WINDOWPOS *wp = (WINDOWPOS *)lParam;
  2976 		WINDOWPOS *wp = (WINDOWPOS *)lParam;
  2977                 RECT rct, dRect;
  2977 		RECT rct, dRect;
  2978                 int x, y, w, h;
  2978 		int x, y, w, h;
  2979                 int dW, dH;
  2979 		int dW, dH;
  2980 
  2980 
  2981 #if 0
  2981 #if 0
  2982                 dRect.left = 0;
  2982 		dRect.left = 0;
  2983                 dRect.top = 0;
  2983 		dRect.top = 0;
  2984                 dRect.right = 100;
  2984 		dRect.right = 100;
  2985                 dRect.bottom = 100;
  2985 		dRect.bottom = 100;
  2986                 winStyleBits = GetWindowLong(hWnd, GWL_STYLE);
  2986 		winStyleBits = GetWindowLong(hWnd, GWL_STYLE);
  2987                 winExStyleBits = GetWindowLong(hWnd, GWL_EXSTYLE);
  2987 		winExStyleBits = GetWindowLong(hWnd, GWL_EXSTYLE);
  2988                 AdjustWindowRectEx(&dRect, winStyleBits, 0, winExStyleBits);
  2988 		AdjustWindowRectEx(&dRect, winStyleBits, 0, winExStyleBits);
  2989                 dW = dRect.right - dRect.left;
  2989 		dW = dRect.right - dRect.left;
  2990                 dH = dRect.bottom - dRect.top;
  2990 		dH = dRect.bottom - dRect.top;
  2991 #endif
  2991 #endif
  2992                 GetClientRect(hWnd, &rct);
  2992 		GetClientRect(hWnd, &rct);
  2993 
  2993 
  2994                 x = rct.left;
  2994 		x = rct.left;
  2995                 y = rct.top;
  2995 		y = rct.top;
  2996                 w = rct.right - rct.left;
  2996 		w = rct.right - rct.left;
  2997                 h = rct.bottom - rct.top;
  2997 		h = rct.bottom - rct.top;
  2998 
  2998 
  2999                 if (__debug__) {
  2999 		if (__debug__) {
  3000                     EVENT_PRINTF(("WM_WINDOWPOSCHANGED ["));
  3000 		    EVENT_PRINTF(("WM_WINDOWPOSCHANGED ["));
  3001 
  3001 
  3002                     if (wp->flags & SWP_NOSIZE) {
  3002 		    if (wp->flags & SWP_NOSIZE) {
  3003                         EVENT_PRINTF(("NOSIZE "));
  3003 			EVENT_PRINTF(("NOSIZE "));
  3004                     }
  3004 		    }
  3005                     if (wp->flags & SWP_NOMOVE) {
  3005 		    if (wp->flags & SWP_NOMOVE) {
  3006                         EVENT_PRINTF(("NOMOVE "));
  3006 			EVENT_PRINTF(("NOMOVE "));
  3007                     }
  3007 		    }
  3008                     if (wp->flags & SWP_NOZORDER) {
  3008 		    if (wp->flags & SWP_NOZORDER) {
  3009                         EVENT_PRINTF(("NOZORDER "));
  3009 			EVENT_PRINTF(("NOZORDER "));
  3010                     }
  3010 		    }
  3011                     if (wp->flags & SWP_NOREDRAW) {
  3011 		    if (wp->flags & SWP_NOREDRAW) {
  3012                         EVENT_PRINTF(("NOREDRAW "));
  3012 			EVENT_PRINTF(("NOREDRAW "));
  3013                     }
  3013 		    }
  3014                     if (wp->flags & SWP_NOACTIVATE) {
  3014 		    if (wp->flags & SWP_NOACTIVATE) {
  3015                         EVENT_PRINTF(("NOACTIVATE "));
  3015 			EVENT_PRINTF(("NOACTIVATE "));
  3016                     }
  3016 		    }
  3017                     if (wp->flags & SWP_FRAMECHANGED) {
  3017 		    if (wp->flags & SWP_FRAMECHANGED) {
  3018                         EVENT_PRINTF(("FRAMECHANGED "));
  3018 			EVENT_PRINTF(("FRAMECHANGED "));
  3019                     }
  3019 		    }
  3020                     if (wp->flags & SWP_NOCOPYBITS) {
  3020 		    if (wp->flags & SWP_NOCOPYBITS) {
  3021                         EVENT_PRINTF(("NOCOPYBITS "));
  3021 			EVENT_PRINTF(("NOCOPYBITS "));
  3022                     }
  3022 		    }
  3023                     if (wp->flags & SWP_NOOWNERZORDER) {
  3023 		    if (wp->flags & SWP_NOOWNERZORDER) {
  3024                         EVENT_PRINTF(("NOOWNERZORDER "));
  3024 			EVENT_PRINTF(("NOOWNERZORDER "));
  3025                     }
  3025 		    }
  3026                     if (wp->flags & SWP_NOSENDCHANGING) {
  3026 		    if (wp->flags & SWP_NOSENDCHANGING) {
  3027                         EVENT_PRINTF(("NOSENDCHANGING "));
  3027 			EVENT_PRINTF(("NOSENDCHANGING "));
  3028                     }
  3028 		    }
  3029                     if (wp->flags & SWP_DEFERERASE) {
  3029 		    if (wp->flags & SWP_DEFERERASE) {
  3030                         EVENT_PRINTF(("DEFERERASE "));
  3030 			EVENT_PRINTF(("DEFERERASE "));
  3031                     }
  3031 		    }
  3032                     if (wp->flags & SWP_ASYNCWINDOWPOS) {
  3032 		    if (wp->flags & SWP_ASYNCWINDOWPOS) {
  3033                         EVENT_PRINTF(("ASYNCWINDOWPOS "));
  3033 			EVENT_PRINTF(("ASYNCWINDOWPOS "));
  3034                     }
  3034 		    }
  3035                     if (wp->flags & SWP_HIDEWINDOW) {
  3035 		    if (wp->flags & SWP_HIDEWINDOW) {
  3036                         EVENT_PRINTF(("HIDEWINDOW "));
  3036 			EVENT_PRINTF(("HIDEWINDOW "));
  3037                     }
  3037 		    }
  3038                     if (wp->flags & SWP_SHOWWINDOW) {
  3038 		    if (wp->flags & SWP_SHOWWINDOW) {
  3039                         EVENT_PRINTF(("SHOWWINDOW "));
  3039 			EVENT_PRINTF(("SHOWWINDOW "));
  3040                     }
  3040 		    }
  3041 
  3041 
  3042                     EVENT_PRINTF(("] %d/%d %d/%d flags:%d (0x%x) ->",
  3042 		    EVENT_PRINTF(("] %d/%d %d/%d flags:%d (0x%x) ->",
  3043                                 wp->x, wp->y, wp->cx, wp->cy, wp->flags, wp->flags));
  3043 				wp->x, wp->y, wp->cx, wp->cy, wp->flags, wp->flags));
  3044                     EVENT_PRINTF(("  client rect now: %d/%d %d/%d\n",x, y, w, h));
  3044 		    EVENT_PRINTF(("  client rect now: %d/%d %d/%d\n",x, y, w, h));
  3045 
  3045 
  3046                 } /* __debug__ */
  3046 		} /* __debug__ */
  3047 #ifdef THIS_IS_WRONG
  3047 #ifdef THIS_IS_WRONG
  3048                 if (!(wp->flags & SWP_NOSIZE)) {
  3048 		if (!(wp->flags & SWP_NOSIZE)) {
  3049                     EVENT_PRINTF(("w,h: %d/%d vs. %d/%d\n", wp->cx, wp->cy, w, h));
  3049 		    EVENT_PRINTF(("w,h: %d/%d vs. %d/%d\n", wp->cx, wp->cy, w, h));
  3050                     w = wp->cx;
  3050 		    w = wp->cx;
  3051                     h = wp->cy;
  3051 		    h = wp->cy;
  3052                 }
  3052 		}
  3053                 if (!(wp->flags & SWP_NOMOVE)) {
  3053 		if (!(wp->flags & SWP_NOMOVE)) {
  3054                     EVENT_PRINTF(("x,y: %d/%d vs. %d/%d\n", wp->x, wp->y, x, y));
  3054 		    EVENT_PRINTF(("x,y: %d/%d vs. %d/%d\n", wp->x, wp->y, x, y));
  3055                     x = wp->x;
  3055 		    x = wp->x;
  3056                     y = wp->y;
  3056 		    y = wp->y;
  3057                 }
  3057 		}
  3058 #endif
  3058 #endif
  3059                 lastPos_win = 0;
  3059 		lastPos_win = 0;
  3060 
  3060 
  3061                 if ((w == 0) && (h == 0)) {
  3061 		if ((w == 0) && (h == 0)) {
  3062                     EVENT_PRINTF(("w,h = 0.\n"));
  3062 		    EVENT_PRINTF(("w,h = 0.\n"));
  3063                     if (! GetWindow_iconified(hWnd)) {
  3063 		    if (! GetWindow_iconified(hWnd)) {
  3064                         EVENT_PRINTF(("iconified.\n"));
  3064 			EVENT_PRINTF(("iconified.\n"));
  3065                         SetWindow_iconified(hWnd, 1);
  3065 			SetWindow_iconified(hWnd, 1);
  3066                         DPRINTF(("WM_WINDOWPOSCHANGED to iconified (flags:0x%x)\n", wp->flags));
  3066 			DPRINTF(("WM_WINDOWPOSCHANGED to iconified (flags:0x%x)\n", wp->flags));
  3067                         enqEvent(0, hWnd, __WM_ICONIFIED, 1, 0, 0, 0, 0, EV_NOTIME);
  3067 			enqEvent(0, hWnd, __WM_ICONIFIED, 1, 0, 0, 0, 0, EV_NOTIME);
  3068                     }
  3068 		    }
  3069                 } else {
  3069 		} else {
  3070                     if (GetWindow_iconified(hWnd)) {
  3070 		    if (GetWindow_iconified(hWnd)) {
  3071                         EVENT_PRINTF(("deiconified.\n"));
  3071 			EVENT_PRINTF(("deiconified.\n"));
  3072                         SetWindow_iconified(hWnd, 0);
  3072 			SetWindow_iconified(hWnd, 0);
  3073                         DPRINTF(("WM_WINDOWPOSCHANGED to deiconified (flags:0x%x)\n", wp->flags));
  3073 			DPRINTF(("WM_WINDOWPOSCHANGED to deiconified (flags:0x%x)\n", wp->flags));
  3074                         enqEvent(0, hWnd, __WM_ICONIFIED, 0, 0, 0, 0, 0, EV_NOTIME);
  3074 			enqEvent(0, hWnd, __WM_ICONIFIED, 0, 0, 0, 0, 0, EV_NOTIME);
  3075                     }
  3075 		    }
  3076                     if (!(wp->flags & SWP_NOSIZE)
  3076 		    if (!(wp->flags & SWP_NOSIZE)
  3077                      || !(wp->flags & SWP_NOMOVE)) {
  3077 		     || !(wp->flags & SWP_NOMOVE)) {
  3078                         EVENT_PRINTF(("enq event %x: %d, %d, %d, %d\n", hWnd, x, y, w, h));
  3078 			EVENT_PRINTF(("enq event %x: %d, %d, %d, %d\n", hWnd, x, y, w, h));
  3079 #ifdef COMPRESS_WINDOWPOSCHANGED
  3079 #ifdef COMPRESS_WINDOWPOSCHANGED
  3080                         /*
  3080 			/*
  3081                          * remember the current
  3081 			 * remember the current
  3082                          * window and size;
  3082 			 * window and size;
  3083                          * This allows the backend to ignore
  3083 			 * This allows the backend to ignore
  3084                          * intermediate events.
  3084 			 * intermediate events.
  3085                          */
  3085 			 */
  3086                         lastPos_w = w;
  3086 			lastPos_w = w;
  3087                         lastPos_h = h;
  3087 			lastPos_h = h;
  3088                         lastPos_x = x;
  3088 			lastPos_x = x;
  3089                         lastPos_y = y;
  3089 			lastPos_y = y;
  3090                         lastPos_win = hWnd;
  3090 			lastPos_win = hWnd;
  3091 #endif
  3091 #endif
  3092                         enqEvent(0, hWnd, WM_WINDOWPOSCHANGED, 0, x, y, w, h, EV_NOTIME);
  3092 			enqEvent(0, hWnd, WM_WINDOWPOSCHANGED, 0, x, y, w, h, EV_NOTIME);
  3093                     } else {
  3093 		    } else {
  3094                         EVENT_PRINTF(("no event due to SWP_NOSIZE/SWP_NOMOVE.\n"));
  3094 			EVENT_PRINTF(("no event due to SWP_NOSIZE/SWP_NOMOVE.\n"));
  3095                     }
  3095 		    }
  3096                 }
  3096 		}
  3097             }
  3097 	    }
  3098             *pDefault = 0;
  3098 	    *pDefault = 0;
  3099             return 0;
  3099 	    return 0;
  3100 
  3100 
  3101         case WM_ERASEBKGND:
  3101 	case WM_ERASEBKGND:
  3102             DPRINTFIF(__debug_WM_ERASEBKGND__ , ("WM_ERASEBKGND\n"));
  3102 	    DPRINTFIF(__debug_WM_ERASEBKGND__ , ("WM_ERASEBKGND\n"));
  3103             if (isNative) {
  3103 	    if (isNative) {
  3104                 NDPRINTF(("WM_ERASEBKGND for native - default handling\n"));
  3104 		NDPRINTF(("WM_ERASEBKGND for native - default handling\n"));
  3105                 return 0;
  3105 		return 0;
  3106             }
  3106 	    }
  3107 
  3107 
  3108 #ifndef PRE_21_NOV
  3108 #ifndef PRE_21_NOV
  3109             *pDefault = 0;
  3109 	    *pDefault = 0;
  3110             return 0;
  3110 	    return 0;
  3111 #else
  3111 #else
  3112 
  3112 
  3113             if (GetWindow_flag(hWnd) & LI_INPUTWIN) {
  3113 	    if (GetWindow_flag(hWnd) & LI_INPUTWIN) {
  3114                 *pDefault = 0;
  3114 		*pDefault = 0;
  3115                 return 0;
  3115 		return 0;
  3116             }
  3116 	    }
  3117             if (hWnd == __rootWinSpezial) {
  3117 	    if (hWnd == __rootWinSpezial) {
  3118                 *pDefault = 0;
  3118 		*pDefault = 0;
  3119                 return 0;
  3119 		return 0;
  3120             }
  3120 	    }
  3121 
  3121 
  3122             /* THIS_WORKS */
  3122 	    /* THIS_WORKS */
  3123             *pDefault = 0;
  3123 	    *pDefault = 0;
  3124             return 0;
  3124 	    return 0;
  3125 
  3125 
  3126 #endif  /* ! PRE_21_NOV */
  3126 #endif  /* ! PRE_21_NOV */
  3127 
  3127 
  3128         case WM_PAINT:
  3128 	case WM_PAINT:
  3129             DPRINTFIF(__debug_WM_PAINT__ , ("WM_PAINT ********************* "));
  3129 	    DPRINTFIF(__debug_WM_PAINT__ , ("WM_PAINT ********************* "));
  3130 
  3130 
  3131             if (isNative) {
  3131 	    if (isNative) {
  3132                 NDPRINTF(("WM_PAINT for native - default handling\n"));
  3132 		NDPRINTF(("WM_PAINT for native - default handling\n"));
  3133                 return 0;
  3133 		return 0;
  3134             }
  3134 	    }
  3135 
  3135 
  3136 #ifndef PRE_21_NOV
  3136 #ifndef PRE_21_NOV
  3137             {   int n;
  3137 	    {   int n;
  3138 
  3138 
  3139                 n = __generateExposes( hWnd, NULL, WM_PAINT, 0 );
  3139 		n = __generateExposes( hWnd, NULL, WM_PAINT, 0 );
  3140 
  3140 
  3141                 if( n <= 0 ) {
  3141 		if( n <= 0 ) {
  3142                     * pDefault = 1;
  3142 		    * pDefault = 1;
  3143                     return 0;
  3143 		    return 0;
  3144                 }
  3144 		}
  3145                 * pDefault = 0;
  3145 		* pDefault = 0;
  3146                 return n;
  3146 		return n;
  3147             }
  3147 	    }
  3148 #else
  3148 #else
  3149 
  3149 
  3150 
  3150 
  3151 
  3151 
  3152             if (GetWindow_flag(hWnd) & LI_INPUTWIN) {
  3152 	    if (GetWindow_flag(hWnd) & LI_INPUTWIN) {
  3153                 *pDefault = 0;
  3153 		*pDefault = 0;
  3154                 return 0;
  3154 		return 0;
  3155             }
  3155 	    }
  3156 
  3156 
  3157             if (hWnd == __rootWinSpezial) {
  3157 	    if (hWnd == __rootWinSpezial) {
  3158 # ifdef THIS_MAKES_GUI_PAINTER_START_SLOW
  3158 # ifdef THIS_MAKES_GUI_PAINTER_START_SLOW
  3159                 *pDefault = 0;
  3159 		*pDefault = 0;
  3160 # endif
  3160 # endif
  3161                 return 0;
  3161 		return 0;
  3162             }
  3162 	    }
  3163 
  3163 
  3164             {
  3164 	    {
  3165                 int retVal;
  3165 		int retVal;
  3166 
  3166 
  3167 # ifdef LATE_GENERATE_EXPOSE
  3167 # ifdef LATE_GENERATE_EXPOSE
  3168                 enqEvent(0, hWnd, __WM_PAINT, 0, 0, 0, 0, 0, EV_NOTIME);
  3168 		enqEvent(0, hWnd, __WM_PAINT, 0, 0, 0, 0, 0, EV_NOTIME);
  3169 # else
  3169 # else
  3170                 AQUIRE_DRAW_MUTEX
  3170 		AQUIRE_DRAW_MUTEX
  3171                 retVal = __generateExposes(hWnd, NULL, WM_PAINT, WM_PAINT_CLEAR_EARLY);
  3171 		retVal = __generateExposes(hWnd, NULL, WM_PAINT, WM_PAINT_CLEAR_EARLY);
  3172                 RELEASE_DRAW_MUTEX
  3172 		RELEASE_DRAW_MUTEX
  3173 # endif
  3173 # endif
  3174                 switch (retVal) {
  3174 		switch (retVal) {
  3175                     case -1:  /* error */
  3175 		    case -1:  /* error */
  3176                         *pDefault = 0;
  3176 			*pDefault = 0;
  3177                         break;
  3177 			break;
  3178                     case 0:   /* nothing generated */
  3178 		    case 0:   /* nothing generated */
  3179                     default:  /* generated events */
  3179 		    default:  /* generated events */
  3180                         break;
  3180 			break;
  3181                 }
  3181 		}
  3182 # ifdef THIS_IS_BAD
  3182 # ifdef THIS_IS_BAD
  3183                 *pDefault = 0;
  3183 		*pDefault = 0;
  3184                 return 1;
  3184 		return 1;
  3185 # endif
  3185 # endif
  3186             }
  3186 	    }
  3187             return 0;
  3187 	    return 0;
  3188 
  3188 
  3189 #endif  /* ! PRE_21_NOV */
  3189 #endif  /* ! PRE_21_NOV */
  3190 
  3190 
  3191         case WM_SIZE:
  3191 	case WM_SIZE:
  3192             DPRINTFIF(__debug_WM_SIZE__ , ("WM_SIZE\n"));
  3192 	    DPRINTFIF(__debug_WM_SIZE__ , ("WM_SIZE\n"));
  3193 
  3193 
  3194             lastPos_win = 0;
  3194 	    lastPos_win = 0;
  3195             /*
  3195 	    /*
  3196              * ignore child window messages ...
  3196 	     * ignore child window messages ...
  3197              */
  3197 	     */
  3198             if (GetParent(hWnd) != NULL) {
  3198 	    if (GetParent(hWnd) != NULL) {
  3199                 *pDefault = 0;
  3199 		*pDefault = 0;
  3200                 return 0;
  3200 		return 0;
  3201             }
  3201 	    }
  3202 
  3202 
  3203             switch (wParam) {
  3203 	    switch (wParam) {
  3204                 case SIZE_MAXIMIZED:     /* default handling */
  3204 		case SIZE_MAXIMIZED:     /* default handling */
  3205                 case SIZE_MINIMIZED:     /* default handling */
  3205 		case SIZE_MINIMIZED:     /* default handling */
  3206                 case SIZE_RESTORED:      /* default handling */
  3206 		case SIZE_RESTORED:      /* default handling */
  3207                     {
  3207 		    {
  3208                         RECT rct;
  3208 			RECT rct;
  3209                         int x, y, w, h;
  3209 			int x, y, w, h;
  3210 
  3210 
  3211                         GetClientRect(hWnd, &rct);
  3211 			GetClientRect(hWnd, &rct);
  3212 
  3212 
  3213                         x = rct.left;
  3213 			x = rct.left;
  3214                         y = rct.top;
  3214 			y = rct.top;
  3215                         w = rct.right - rct.left;
  3215 			w = rct.right - rct.left;
  3216                         h = rct.bottom - rct.top;
  3216 			h = rct.bottom - rct.top;
  3217 
  3217 
  3218                         EVENT_PRINTF(("WM_MIN/MAX/RESTORED\n"));
  3218 			EVENT_PRINTF(("WM_MIN/MAX/RESTORED\n"));
  3219 
  3219 
  3220                         if ((w == 0) && (h == 0)) {
  3220 			if ((w == 0) && (h == 0)) {
  3221                             /*
  3221 			    /*
  3222                              * iconified ...
  3222 			     * iconified ...
  3223                              */
  3223 			     */
  3224                             if (! GetWindow_iconified(hWnd)) {
  3224 			    if (! GetWindow_iconified(hWnd)) {
  3225                                 SetWindow_iconified(hWnd, 1);
  3225 				SetWindow_iconified(hWnd, 1);
  3226                                 enqEvent(0, hWnd, __WM_ICONIFIED, 1, 0, 0, 0, 0, EV_NOTIME);
  3226 				enqEvent(0, hWnd, __WM_ICONIFIED, 1, 0, 0, 0, 0, EV_NOTIME);
  3227                             }
  3227 			    }
  3228                         } else {
  3228 			} else {
  3229                             if (GetWindow_iconified(hWnd)) {
  3229 			    if (GetWindow_iconified(hWnd)) {
  3230                                 SetWindow_iconified(hWnd, 0);
  3230 				SetWindow_iconified(hWnd, 0);
  3231                                 enqEvent(0, hWnd, __WM_ICONIFIED, 0, 0, 0, 0, 0, EV_NOTIME);
  3231 				enqEvent(0, hWnd, __WM_ICONIFIED, 0, 0, 0, 0, 0, EV_NOTIME);
  3232                             }
  3232 			    }
  3233                             EVENT_PRINTF(("enq event2 %x: %d, %d, %d, %d\n", hWnd, x, y, w, h));
  3233 			    EVENT_PRINTF(("enq event2 %x: %d, %d, %d, %d\n", hWnd, x, y, w, h));
  3234 #ifdef COMPRESS_WINDOWPOSCHANGED
  3234 #ifdef COMPRESS_WINDOWPOSCHANGED
  3235                             /*
  3235 			    /*
  3236                              * remember the current
  3236 			     * remember the current
  3237                              * window and size;
  3237 			     * window and size;
  3238                              * This allows the backend to ignore
  3238 			     * This allows the backend to ignore
  3239                              * intermediate events.
  3239 			     * intermediate events.
  3240                              */
  3240 			     */
  3241                             lastPos_w = w;
  3241 			    lastPos_w = w;
  3242                             lastPos_h = h;
  3242 			    lastPos_h = h;
  3243                             lastPos_x = x;
  3243 			    lastPos_x = x;
  3244                             lastPos_y = y;
  3244 			    lastPos_y = y;
  3245                             lastPos_win = hWnd;
  3245 			    lastPos_win = hWnd;
  3246 #endif
  3246 #endif
  3247                             enqEvent(0, hWnd, WM_WINDOWPOSCHANGED, 0, x, y, w, h, EV_NOTIME);
  3247 			    enqEvent(0, hWnd, WM_WINDOWPOSCHANGED, 0, x, y, w, h, EV_NOTIME);
  3248                         }
  3248 			}
  3249                    }
  3249 		   }
  3250                    break;
  3250 		   break;
  3251 
  3251 
  3252                 default:                 /* ignore */
  3252 		default:                 /* ignore */
  3253                     *pDefault = 0;
  3253 		    *pDefault = 0;
  3254                     return 0;
  3254 		    return 0;
  3255             }
  3255 	    }
  3256             break;
  3256 	    break;
  3257 
  3257 
  3258         case WM_DROPFILES:
  3258 	case WM_DROPFILES:
  3259             DPRINTFIF(__debug_WM_DROPFILES__ , ("WM_DROPFILES\n"));
  3259 	    DPRINTFIF(__debug_WM_DROPFILES__ , ("WM_DROPFILES\n"));
  3260             enqEvent(0, hWnd, message, wParam, 0, 0, 0, 0, EV_NOTIME);
  3260 	    enqEvent(0, hWnd, message, wParam, 0, 0, 0, 0, EV_NOTIME);
  3261             break;
  3261 	    break;
  3262 
  3262 
  3263         case WM_SHOWWINDOW:
  3263 	case WM_SHOWWINDOW:
  3264             DPRINTFIF(__debug_WM_SHOWWINDOW__ , ("WM_SHOWWINDOW h=%x\n", hWnd));
  3264 	    DPRINTFIF(__debug_WM_SHOWWINDOW__ , ("WM_SHOWWINDOW h=%x\n", hWnd));
  3265             enqEvent(0, hWnd, message, wParam, 0, 0, 0, 0, EV_NOTIME);
  3265 	    enqEvent(0, hWnd, message, wParam, 0, 0, 0, 0, EV_NOTIME);
  3266             if (isNative) {
  3266 	    if (isNative) {
  3267                 NDPRINTF(("WM_SHOWWINDOW for native - default handling\n"));
  3267 		NDPRINTF(("WM_SHOWWINDOW for native - default handling\n"));
  3268                 return 0;
  3268 		return 0;
  3269             }
  3269 	    }
  3270             *pDefault = 0;
  3270 	    *pDefault = 0;
  3271             break;
  3271 	    break;
  3272 
  3272 
  3273         case WM_MOUSEACTIVATE :
  3273 	case WM_MOUSEACTIVATE :
  3274             DPRINTFIF(__debug_WM_MOUSEACTIVATE__ , ("WM_MOUSEACTIVATE h=%x parent=%x\n", hWnd, GetParent(hWnd)));
  3274 	    DPRINTFIF(__debug_WM_MOUSEACTIVATE__ , ("WM_MOUSEACTIVATE h=%x parent=%x\n", hWnd, GetParent(hWnd)));
  3275 
  3275 
  3276             /*
  3276 	    /*
  3277              * ignore child window messages ...
  3277 	     * ignore child window messages ...
  3278              */
  3278 	     */
  3279             if (GetParent(hWnd)) {
  3279 	    if (GetParent(hWnd)) {
  3280                 return 0;
  3280 		return 0;
  3281             }
  3281 	    }
  3282 
  3282 
  3283             *pDefault = 0;
  3283 	    *pDefault = 0;
  3284             if ((hWnd == __rootWinSpezial) || (hWnd == GetActiveWindow())) {
  3284 	    if ((hWnd == __rootWinSpezial) || (hWnd == GetActiveWindow())) {
  3285                 DDPRINTF(("NOACTIVATE (root or already)\n"));
  3285 		DDPRINTF(("NOACTIVATE (root or already)\n"));
  3286                 return MA_NOACTIVATE;
  3286 		return MA_NOACTIVATE;
  3287             }
  3287 	    }
  3288             if (LOWORD(lParam) != HTCLIENT) {
  3288 	    if (LOWORD(lParam) != HTCLIENT) {
  3289                 DDPRINTF(("ACTIVATE (not client)\n"));
  3289 		DDPRINTF(("ACTIVATE (not client)\n"));
  3290                 return MA_ACTIVATE;
  3290 		return MA_ACTIVATE;
  3291             }
  3291 	    }
  3292             if (__activateOnClick) {
  3292 	    if (__activateOnClick) {
  3293                 if (__ignoreButtonPressOnActivate) {
  3293 		if (__ignoreButtonPressOnActivate) {
  3294                     DDPRINTF(("ACTIVATE_EAT\n"));
  3294 		    DDPRINTF(("ACTIVATE_EAT\n"));
  3295                     /*
  3295 		    /*
  3296                      * windows is sooo stupid:
  3296 		     * windows is sooo stupid:
  3297                      * it will send me a MOTION soon after, with the
  3297 		     * it will send me a MOTION soon after, with the
  3298                      * to the click location, with the buttonState down.
  3298 		     * to the click location, with the buttonState down.
  3299                      * The app will interpret that as a pressed motion and
  3299 		     * The app will interpret that as a pressed motion and
  3300                      * do a selection (if in a textview).
  3300 		     * do a selection (if in a textview).
  3301                      * To prevent this, we set a flag here, that the following
  3301 		     * To prevent this, we set a flag here, that the following
  3302                      * motion is to be suppressed.
  3302 		     * motion is to be suppressed.
  3303                      * Until the mouse is released.
  3303 		     * Until the mouse is released.
  3304                      */
  3304 		     */
  3305                     __eatingMouseEvents = 1;
  3305 		    __eatingMouseEvents = 1;
  3306                     return MA_ACTIVATEANDEAT;
  3306 		    return MA_ACTIVATEANDEAT;
  3307                 }
  3307 		}
  3308                 DDPRINTF(("ACTIVATE\n"));
  3308 		DDPRINTF(("ACTIVATE\n"));
  3309                 return MA_ACTIVATE;
  3309 		return MA_ACTIVATE;
  3310             }
  3310 	    }
  3311             DDPRINTF(("NO_ACTIVATE\n"));
  3311 	    DDPRINTF(("NO_ACTIVATE\n"));
  3312             return MA_NOACTIVATE;
  3312 	    return MA_NOACTIVATE;
  3313 
  3313 
  3314         case WM_NCHITTEST:
  3314 	case WM_NCHITTEST:
  3315             EVENT_PRINTF2(("WM_NCHITTEST\n"));
  3315 	    EVENT_PRINTF2(("WM_NCHITTEST\n"));
  3316             if (hWnd == __rootWinSpezial) {
  3316 	    if (hWnd == __rootWinSpezial) {
  3317                 *pDefault = 0;
  3317 		*pDefault = 0;
  3318                 return HTCLIENT;
  3318 		return HTCLIENT;
  3319             }
  3319 	    }
  3320             break;
  3320 	    break;
  3321 
  3321 
  3322         case WM_NCACTIVATE:
  3322 	case WM_NCACTIVATE:
  3323             EVENT_PRINTF(("WM_NCACTIVATE\n"));
  3323 	    EVENT_PRINTF(("WM_NCACTIVATE\n"));
  3324             break;
  3324 	    break;
  3325 
  3325 
  3326         case WM_ACTIVATE:
  3326 	case WM_ACTIVATE:
  3327             CPRINTF(("WM_ACTIVATE %s h=%x\n", LOWORD(wParam) ? "active" : "inactive", hWnd));
  3327 	    CPRINTF(("WM_ACTIVATE %s h=%x\n", LOWORD(wParam) ? "active" : "inactive", hWnd));
  3328 
  3328 
  3329             switch (LOWORD(wParam)) {
  3329 	    switch (LOWORD(wParam)) {
  3330                 case WA_INACTIVE:
  3330 		case WA_INACTIVE:
  3331                     EVENT_PRINTF2(("WM_ACTIVATE inactive h=%x\n", hWnd));
  3331 		    EVENT_PRINTF2(("WM_ACTIVATE inactive h=%x\n", hWnd));
  3332                     break;
  3332 		    break;
  3333 
  3333 
  3334                 case WA_ACTIVE:
  3334 		case WA_ACTIVE:
  3335                     EVENT_PRINTF2(("WM_ACTIVATE active h=%x\n", hWnd));
  3335 		    EVENT_PRINTF2(("WM_ACTIVATE active h=%x\n", hWnd));
  3336 
  3336 
  3337 #ifdef THIS_DOES_NOT_AVOID_DOUBLE_REPAINTS
  3337 #ifdef THIS_DOES_NOT_AVOID_DOUBLE_REPAINTS
  3338                     __generateRecursiveExposes(hWnd, WM_PAINT);
  3338 		    __generateRecursiveExposes(hWnd, WM_PAINT);
  3339 #endif /* sigh */
  3339 #endif /* sigh */
  3340                     break;
  3340 		    break;
  3341 
  3341 
  3342                 case WA_CLICKACTIVE:
  3342 		case WA_CLICKACTIVE:
  3343                     EVENT_PRINTF2(("++ WM_ACTIVATE clkactive h=%x\n", hWnd));
  3343 		    EVENT_PRINTF2(("++ WM_ACTIVATE clkactive h=%x\n", hWnd));
  3344                     break;
  3344 		    break;
  3345 
  3345 
  3346                 default:
  3346 		default:
  3347                     EVENT_PRINTF2(("WM_ACTIVATE ? h=%x\n", hWnd));
  3347 		    EVENT_PRINTF2(("WM_ACTIVATE ? h=%x\n", hWnd));
  3348                     break;
  3348 		    break;
  3349             }
  3349 	    }
  3350 
  3350 
  3351 #ifndef PRE_25_NOV_03
  3351 #ifndef PRE_25_NOV_03
  3352             if (__currentCapture == CAPTURE_NONE) {
  3352 	    if (__currentCapture == CAPTURE_NONE) {
  3353                 HWND  newHWnd = 0;
  3353 		HWND  newHWnd = 0;
  3354                 POINT newPoint;
  3354 		POINT newPoint;
  3355 
  3355 
  3356                 if (LOWORD(wParam) != WA_INACTIVE) {
  3356 		if (LOWORD(wParam) != WA_INACTIVE) {
  3357                     if (MustHandleButtonEvent()) {
  3357 		    if (MustHandleButtonEvent()) {
  3358                         newPoint.x = evRootX;
  3358 			newPoint.x = evRootX;
  3359                         newPoint.y = evRootY;
  3359 			newPoint.y = evRootY;
  3360 
  3360 
  3361                         newHWnd = WindowFromPoint (newPoint);
  3361 			newHWnd = WindowFromPoint (newPoint);
  3362 
  3362 
  3363                         if (newHWnd) {
  3363 			if (newHWnd) {
  3364                             if ( (newHWnd == hWnd) || IsChild(hWnd, newHWnd) ) {
  3364 			    if ( (newHWnd == hWnd) || IsChild(hWnd, newHWnd) ) {
  3365                                 ScreenToClient (newHWnd, & newPoint);
  3365 				ScreenToClient (newHWnd, & newPoint);
  3366 
  3366 
  3367                                 if ((newPoint.x < 0) || (newPoint.y < 0)) {
  3367 				if ((newPoint.x < 0) || (newPoint.y < 0)) {
  3368                                     newHWnd = 0;
  3368 				    newHWnd = 0;
  3369                                 }
  3369 				}
  3370                             } else {
  3370 			    } else {
  3371                                 newHWnd = 0;
  3371 				newHWnd = 0;
  3372                             }
  3372 			    }
  3373                         }
  3373 			}
  3374                     }
  3374 		    }
  3375                 }
  3375 		}
  3376                 CPRINTF(( "Old Handle: %x New Handle: %x  x:%d y:%d\n", __currentPointerView, newHWnd, newPoint.x, newPoint.y));
  3376 		CPRINTF(( "Old Handle: %x New Handle: %x  x:%d y:%d\n", __currentPointerView, newHWnd, newPoint.x, newPoint.y));
  3377 
  3377 
  3378                 if (newHWnd != __currentPointerView) {
  3378 		if (newHWnd != __currentPointerView) {
  3379                     int modifiers = getModifiers();
  3379 		    int modifiers = getModifiers();
  3380 
  3380 
  3381                     if (__currentPointerView) {
  3381 		    if (__currentPointerView) {
  3382                         if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  3382 			if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  3383                             enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
  3383 			    enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
  3384                             SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  3384 			    SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  3385                         }
  3385 			}
  3386                     }
  3386 		    }
  3387                     __currentPointerView = newHWnd;
  3387 		    __currentPointerView = newHWnd;
  3388 
  3388 
  3389                     if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  3389 		    if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  3390                         enqEvent(EnterWindowMask, __currentPointerView, __WM_MOUSEENTER, 0, newPoint.x, newPoint.y, 0, modifiers, EV_NOTIME);
  3390 			enqEvent(EnterWindowMask, __currentPointerView, __WM_MOUSEENTER, 0, newPoint.x, newPoint.y, 0, modifiers, EV_NOTIME);
  3391                         SetWindow_mouseXY(__currentPointerView, newPoint.x, newPoint.y);
  3391 			SetWindow_mouseXY(__currentPointerView, newPoint.x, newPoint.y);
  3392                     }
  3392 		    }
  3393                 }
  3393 		}
  3394             }
  3394 	    }
  3395 #endif
  3395 #endif
  3396             enqEvent(0, hWnd, WM_ACTIVATE, wParam, 0, 0, 0, 0, EV_NOTIME);
  3396 	    enqEvent(0, hWnd, WM_ACTIVATE, wParam, 0, 0, 0, 0, EV_NOTIME);
  3397 
  3397 
  3398             if (isNative) {
  3398 	    if (isNative) {
  3399                 return 0;
  3399 		return 0;
  3400             }
  3400 	    }
  3401             break;
  3401 	    break;
  3402 
  3402 
  3403         case WM_HOTKEY:
  3403 	case WM_HOTKEY:
  3404             // console_fprintf(stderr, "winEventProcessing [info]: receive hotkey %x\n",wParam);
  3404 	    // console_fprintf(stderr, "winEventProcessing [info]: receive hotkey %x\n",wParam);
  3405             DPRINTFIF(__debug_WM_KEYUP__ , ("WM_HOTKEY %x\n", wParam));
  3405 	    DPRINTFIF(__debug_WM_KEYUP__ , ("WM_HOTKEY %x\n", wParam));
  3406             {
  3406 	    {
  3407                 enqEvent(0, hWnd, WM_HOTKEY, wParam, lParam, 0, 0, 0, evTime);
  3407 		enqEvent(0, hWnd, WM_HOTKEY, wParam, lParam, 0, 0, 0, evTime);
  3408             }
  3408 	    }
  3409             break;
  3409 	    break;
  3410 
  3410 
  3411         case WM_SYSCHAR:
  3411 	case WM_SYSCHAR:
  3412             EVENT_PRINTF2(("WM_SYSCHAR h=%x %x\n", hWnd, wParam));
  3412 	    EVENT_PRINTF2(("WM_SYSCHAR h=%x %x\n", hWnd, wParam));
  3413             goto commonChar;
  3413 	    goto commonChar;
  3414 
  3414 
  3415 #ifdef WM_UNICHAR
  3415 #ifdef WM_UNICHAR
  3416         /* does not work, anyway */
  3416 	/* does not work, anyway */
  3417         case WM_UNICHAR:
  3417 	case WM_UNICHAR:
  3418             DPRINTFIF(__debug_WM_CHAR__ , ("WM_UNICHAR h=%x %x\n", hWnd, wParam));
  3418 	    DPRINTFIF(__debug_WM_CHAR__ , ("WM_UNICHAR h=%x %x\n", hWnd, wParam));
  3419             if (wParam == UNICODE_NOCHAR) {
  3419 	    if (wParam == UNICODE_NOCHAR) {
  3420                 /* this is a query from windows to see if I am able to receive unicode... */
  3420 		/* this is a query from windows to see if I am able to receive unicode... */
  3421                 *pDefault = 0;
  3421 		*pDefault = 0;
  3422                 return 1;
  3422 		return 1;
  3423             }
  3423 	    }
  3424             goto commonChar;
  3424 	    goto commonChar;
  3425 #endif
  3425 #endif
  3426 
  3426 
  3427         case WM_CHAR:
  3427 	case WM_CHAR:
  3428             DPRINTFIF(__debug_WM_CHAR__ , ("WM_CHAR h=%x %x\n", hWnd, wParam));
  3428 	    DPRINTFIF(__debug_WM_CHAR__ , ("WM_CHAR h=%x %x\n", hWnd, wParam));
  3429 #if 0
  3429 #if 0
  3430             EVENT_PRINTF2(("WM_CHAR h=%x %x\n", hWnd, wParam));
  3430 	    EVENT_PRINTF2(("WM_CHAR h=%x %x\n", hWnd, wParam));
  3431 #endif
  3431 #endif
  3432         commonChar:
  3432 	commonChar:
  3433             if (isNative) {
  3433 	    if (isNative) {
  3434                 NDPRINTF(("WM_CHAR for native - default handling\n"));
  3434 		NDPRINTF(("WM_CHAR for native - default handling\n"));
  3435                 return 0;
  3435 		return 0;
  3436             }
  3436 	    }
  3437 
  3437 
  3438             {
  3438 	    {
  3439                 HWND destWindow;
  3439 		HWND destWindow;
  3440                 int evMask;
  3440 		int evMask;
  3441 
  3441 
  3442                 if (__focusFollowsMouse) {
  3442 		if (__focusFollowsMouse) {
  3443                     destWindow = __currentPointerView;
  3443 		    destWindow = __currentPointerView;
  3444                     if (destWindow == 0) {
  3444 		    if (destWindow == 0) {
  3445                         destWindow = hWnd;
  3445 			destWindow = hWnd;
  3446                     }
  3446 		    }
  3447                 } else {
  3447 		} else {
  3448                     destWindow = hWnd;
  3448 		    destWindow = hWnd;
  3449                 }
  3449 		}
  3450 
  3450 
  3451                 evMask = GetWindow_eventMask(destWindow);
  3451 		evMask = GetWindow_eventMask(destWindow);
  3452                 if (evMask & (KeyPressMask | KeyReleaseMask)) {
  3452 		if (evMask & (KeyPressMask | KeyReleaseMask)) {
  3453                     POINT p;
  3453 		    POINT p;
  3454                     int modifiers = getModifiers();
  3454 		    int modifiers = getModifiers();
  3455 
  3455 
  3456                     p.x = evRootX;
  3456 		    p.x = evRootX;
  3457                     p.y = evRootY;
  3457 		    p.y = evRootY;
  3458                     ScreenToClient(destWindow, &p);
  3458 		    ScreenToClient(destWindow, &p);
  3459                     x = p.x;
  3459 		    x = p.x;
  3460                     y = p.y;
  3460 		    y = p.y;
  3461 
  3461 
  3462                     DPRINTFIF(__debug_WM_CHAR__ , ("key:%x modifiers: %x\n", wParam, modifiers));
  3462 		    DPRINTFIF(__debug_WM_CHAR__ , ("key:%x modifiers: %x\n", wParam, modifiers));
  3463                     if (evMask & KeyPressMask)
  3463 		    if (evMask & KeyPressMask)
  3464                         enqEvent(KeyPressMask, destWindow, WM_KEYDOWN, wParam, x, y, lParam, (modifiers | TRANSLATED_KEY), evTime);
  3464 			enqEvent(KeyPressMask, destWindow, WM_KEYDOWN, wParam, x, y, lParam, (modifiers | TRANSLATED_KEY), evTime);
  3465                     if (evMask & KeyReleaseMask)
  3465 		    if (evMask & KeyReleaseMask)
  3466                         enqEvent(KeyReleaseMask, destWindow, WM_KEYUP, wParam, x, y, lParam, (modifiers | TRANSLATED_KEY), evTime);
  3466 			enqEvent(KeyReleaseMask, destWindow, WM_KEYUP, wParam, x, y, lParam, (modifiers | TRANSLATED_KEY), evTime);
  3467                 }
  3467 		}
  3468             }
  3468 	    }
  3469             *pDefault = 0;
  3469 	    *pDefault = 0;
  3470             return 0;
  3470 	    return 0;
  3471 
  3471 
  3472 
  3472 
  3473         case WM_KEYUP:
  3473 	case WM_KEYUP:
  3474             DPRINTFIF(__debug_WM_KEYUP__ , ("WM_KEYUP h=%x %x\n", hWnd, wParam));
  3474 	    DPRINTFIF(__debug_WM_KEYUP__ , ("WM_KEYUP h=%x %x\n", hWnd, wParam));
  3475             goto commonKeyUp;
  3475 	    goto commonKeyUp;
  3476 
  3476 
  3477         case WM_SYSKEYUP:
  3477 	case WM_SYSKEYUP:
  3478             DPRINTFIF(__debug_WM_KEYUP__ , ("WM_SYSKEYUP %x\n, wParam"));
  3478 	    DPRINTFIF(__debug_WM_KEYUP__ , ("WM_SYSKEYUP %x\n, wParam"));
  3479         commonKeyUp:
  3479 	commonKeyUp:
  3480             if (isNative) {
  3480 	    if (isNative) {
  3481                 NDPRINTF(("WM_KEYUP/WM_SYSKEYUP for native - default handling\n"));
  3481 		NDPRINTF(("WM_KEYUP/WM_SYSKEYUP for native - default handling\n"));
  3482                 return 0;
  3482 		return 0;
  3483             }
  3483 	    }
  3484             {
  3484 	    {
  3485                 HWND destWindow;
  3485 		HWND destWindow;
  3486 
  3486 
  3487                 if (__focusFollowsMouse) {
  3487 		if (__focusFollowsMouse) {
  3488                     destWindow = __currentPointerView;
  3488 		    destWindow = __currentPointerView;
  3489                     if (destWindow == 0) {
  3489 		    if (destWindow == 0) {
  3490                         destWindow = hWnd;
  3490 			destWindow = hWnd;
  3491                     }
  3491 		    }
  3492                 } else {
  3492 		} else {
  3493                     destWindow = hWnd;
  3493 		    destWindow = hWnd;
  3494                 }
  3494 		}
  3495 
  3495 
  3496                 if (GetWindow_eventMask(destWindow) & KeyReleaseMask) {
  3496 		if (GetWindow_eventMask(destWindow) & KeyReleaseMask) {
  3497                     POINT p;
  3497 		    POINT p;
  3498 
  3498 
  3499                     p.x = evRootX;
  3499 		    p.x = evRootX;
  3500                     p.y = evRootY;
  3500 		    p.y = evRootY;
  3501                     ScreenToClient(destWindow, &p);
  3501 		    ScreenToClient(destWindow, &p);
  3502                     x = p.x;
  3502 		    x = p.x;
  3503                     y = p.y;
  3503 		    y = p.y;
  3504 
  3504 
  3505                     enqEvent(KeyReleaseMask, destWindow, message, wParam, x, y, lParam, getModifiers(), evTime);
  3505 		    enqEvent(KeyReleaseMask, destWindow, message, wParam, x, y, lParam, getModifiers(), evTime);
  3506                 }
  3506 		}
  3507             }
  3507 	    }
  3508             *pDefault = 0;
  3508 	    *pDefault = 0;
  3509             return 0;
  3509 	    return 0;
  3510 
  3510 
  3511         case WM_SYSKEYDOWN:
  3511 	case WM_SYSKEYDOWN:
  3512             DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_SYSKEYDOWN %x\n, wParam"));
  3512 	    DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_SYSKEYDOWN %x\n, wParam"));
  3513             goto commonKey;
  3513 	    goto commonKey;
  3514 
  3514 
  3515         case WM_KEYDOWN:
  3515 	case WM_KEYDOWN:
  3516             DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_KEYDOWN h=%x %x\n", hWnd, wParam));
  3516 	    DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_KEYDOWN h=%x %x\n", hWnd, wParam));
  3517         commonKey:
  3517 	commonKey:
  3518             if (isNative) {
  3518 	    if (isNative) {
  3519                 NDPRINTF(("WM_KEYDOWN/WM_SYSKEYDOWN for native - default handling\n"));
  3519 		NDPRINTF(("WM_KEYDOWN/WM_SYSKEYDOWN for native - default handling\n"));
  3520                 return 0;
  3520 		return 0;
  3521             }
  3521 	    }
  3522 
  3522 
  3523 #ifdef EXIT_WITH_3_CTRL_Cs
  3523 #ifdef EXIT_WITH_3_CTRL_Cs
  3524             if ((msg.wParam == 'c')
  3524 	    if ((msg.wParam == 'c')
  3525              && (GetKeyState(VK_CONTROL) & 0x8000)) {
  3525 	     && (GetKeyState(VK_CONTROL) & 0x8000)) {
  3526                 /* CTRL-C */
  3526 		/* CTRL-C */
  3527                 if (ctrl_c_count++ > 3)  /* for debugging */
  3527 		if (ctrl_c_count++ > 3)  /* for debugging */
  3528                     exit(1);
  3528 		    exit(1);
  3529             } else {
  3529 	    } else {
  3530                 if (msg.wParam != VK_CONTROL)
  3530 		if (msg.wParam != VK_CONTROL)
  3531                     ctrl_c_count = 0;
  3531 		    ctrl_c_count = 0;
  3532             }
  3532 	    }
  3533 #endif
  3533 #endif
  3534 #ifdef RELEASE_CAPTURE_WITH_3_ESCAPEs
  3534 #ifdef RELEASE_CAPTURE_WITH_3_ESCAPEs
  3535             if (msg.wParam == VK_ESCAPE)) {
  3535 	    if (msg.wParam == VK_ESCAPE)) {
  3536                 /* ESCAPE */
  3536 		/* ESCAPE */
  3537                 if (escape_count++ > 3) {
  3537 		if (escape_count++ > 3) {
  3538                     __currentCapture = CAPTURE_NONE;
  3538 		    __currentCapture = CAPTURE_NONE;
  3539                     ReleaseCapture();
  3539 		    ReleaseCapture();
  3540                     CPRINTF(("ReleaseCapture <ESC>\n"));
  3540 		    CPRINTF(("ReleaseCapture <ESC>\n"));
  3541                 }
  3541 		}
  3542             } else {
  3542 	    } else {
  3543                 escape_count = 0;
  3543 		escape_count = 0;
  3544             }
  3544 	    }
  3545 #endif
  3545 #endif
  3546             /* FALL INTO */
  3546 	    /* FALL INTO */
  3547 
  3547 
  3548             {
  3548 	    {
  3549                 HWND destWindow;
  3549 		HWND destWindow;
  3550 
  3550 
  3551                 if (__focusFollowsMouse) {
  3551 		if (__focusFollowsMouse) {
  3552                     destWindow = __currentPointerView;
  3552 		    destWindow = __currentPointerView;
  3553                     if (destWindow == 0) {
  3553 		    if (destWindow == 0) {
  3554                         destWindow = hWnd;
  3554 			destWindow = hWnd;
  3555                     }
  3555 		    }
  3556                 } else {
  3556 		} else {
  3557                     destWindow = hWnd;
  3557 		    destWindow = hWnd;
  3558                 }
  3558 		}
  3559 
  3559 
  3560                 if (GetWindow_eventMask(destWindow) & KeyPressMask) {
  3560 		if (GetWindow_eventMask(destWindow) & KeyPressMask) {
  3561                     POINT p;
  3561 		    POINT p;
  3562 
  3562 
  3563                     p.x = evRootX;
  3563 		    p.x = evRootX;
  3564                     p.y = evRootY;
  3564 		    p.y = evRootY;
  3565                     ScreenToClient(destWindow, &p);
  3565 		    ScreenToClient(destWindow, &p);
  3566                     x = p.x;
  3566 		    x = p.x;
  3567                     y = p.y;
  3567 		    y = p.y;
  3568 
  3568 
  3569                     enqEvent(KeyPressMask, destWindow, message, wParam, x, y, lParam, getModifiers(), evTime);
  3569 		    enqEvent(KeyPressMask, destWindow, message, wParam, x, y, lParam, getModifiers(), evTime);
  3570                 }
  3570 		}
  3571             }
  3571 	    }
  3572             *pDefault = 0;
  3572 	    *pDefault = 0;
  3573             return 0;
  3573 	    return 0;
  3574 
  3574 
  3575 #ifdef WM_MOUSEWHEEL
  3575 #ifdef WM_MOUSEWHEEL
  3576         case WM_MOUSEWHEEL:
  3576 	case WM_MOUSEWHEEL:
  3577             {
  3577 	    {
  3578                 HWND destWindow;
  3578 		HWND destWindow;
  3579 
  3579 
  3580                 if (__focusFollowsMouse) {
  3580 		if (__focusFollowsMouse) {
  3581                     destWindow = __currentPointerView;
  3581 		    destWindow = __currentPointerView;
  3582                     if (destWindow == 0) {
  3582 		    if (destWindow == 0) {
  3583                         destWindow = hWnd;
  3583 			destWindow = hWnd;
  3584                     }
  3584 		    }
  3585                 } else {
  3585 		} else {
  3586                     destWindow = hWnd;
  3586 		    destWindow = hWnd;
  3587                 }
  3587 		}
  3588 
  3588 
  3589 
  3589 
  3590                 EVENT_PRINTF(("WM_MOUSEWHEEL h=%x wP=%x lP=%x\n", hWnd, wParam, lParam));
  3590 		EVENT_PRINTF(("WM_MOUSEWHEEL h=%x wP=%x lP=%x\n", hWnd, wParam, lParam));
  3591                 if (GetWindow_eventMask(destWindow) & KeyPressMask) {
  3591 		if (GetWindow_eventMask(destWindow) & KeyPressMask) {
  3592                     POINT p;
  3592 		    POINT p;
  3593                     int delta;
  3593 		    int delta;
  3594 
  3594 
  3595                     p.x = evRootX;
  3595 		    p.x = evRootX;
  3596                     p.y = evRootY;
  3596 		    p.y = evRootY;
  3597                     ScreenToClient(destWindow, &p);
  3597 		    ScreenToClient(destWindow, &p);
  3598                     x = p.x;
  3598 		    x = p.x;
  3599                     y = p.y;
  3599 		    y = p.y;
  3600                     delta = evTime - lastMouseWheelTime;
  3600 		    delta = evTime - lastMouseWheelTime;
  3601                     if (evTime < lastMouseWheelTime) {
  3601 		    if (evTime < lastMouseWheelTime) {
  3602                         delta = (0xFFFFFFFF - lastMouseWheelTime) + evTime;
  3602 			delta = (0xFFFFFFFF - lastMouseWheelTime) + evTime;
  3603                     }
  3603 		    }
  3604                     enqEvent(0, destWindow, message, wParam, x, y, lParam, getModifiers(), delta);
  3604 		    enqEvent(0, destWindow, message, wParam, x, y, lParam, getModifiers(), delta);
  3605                 }
  3605 		}
  3606                 lastMouseWheelTime = evTime;
  3606 		lastMouseWheelTime = evTime;
  3607             }
  3607 	    }
  3608             *pDefault = 0;
  3608 	    *pDefault = 0;
  3609             return 0;
  3609 	    return 0;
  3610 #endif
  3610 #endif
  3611 
  3611 
  3612         case WM_MOUSEMOVE:
  3612 	case WM_MOUSEMOVE:
  3613             DPRINTFIF(__debug_WM_MOUSEMOVE__ , ("WM_MOUSEMOVE h=%x\n", hWnd));
  3613 	    DPRINTFIF(__debug_WM_MOUSEMOVE__ , ("WM_MOUSEMOVE h=%x\n", hWnd));
  3614             if (isNative) {
  3614 	    if (isNative) {
  3615                 NDPRINTF(("WM_MOUSEMOVE for native - default handling\n"));
  3615 		NDPRINTF(("WM_MOUSEMOVE for native - default handling\n"));
  3616                 return 0;
  3616 		return 0;
  3617             }
  3617 	    }
  3618 
  3618 
  3619             if (hWnd != __currentPointerView) {
  3619 	    if (hWnd != __currentPointerView) {
  3620                 if (! MustHandleButtonEvent()) {
  3620 		if (! MustHandleButtonEvent()) {
  3621                     *pDefault = 0;
  3621 		    *pDefault = 0;
  3622                     return 0;
  3622 		    return 0;
  3623                 }
  3623 		}
  3624             }
  3624 	    }
  3625 
  3625 
  3626             {
  3626 	    {
  3627                 short x, y;
  3627 		short x, y;
  3628                 int modifiers = getModifiers();
  3628 		int modifiers = getModifiers();
  3629 
  3629 
  3630                 x = (int)(short)LOWORD(lParam);
  3630 		x = (int)(short)LOWORD(lParam);
  3631                 y = (int)(short)HIWORD(lParam);
  3631 		y = (int)(short)HIWORD(lParam);
  3632 
  3632 
  3633                 if (__currentCapture == CAPTURE_NONE) {
  3633 		if (__currentCapture == CAPTURE_NONE) {
  3634                     if (hWnd != __currentPointerView) {
  3634 		    if (hWnd != __currentPointerView) {
  3635                         HWND prevPointerView;
  3635 			HWND prevPointerView;
  3636 
  3636 
  3637                         prevPointerView = __currentPointerView;
  3637 			prevPointerView = __currentPointerView;
  3638                         if (prevPointerView) {
  3638 			if (prevPointerView) {
  3639                             if (inSizeMove) {
  3639 			    if (inSizeMove) {
  3640                                 if (needDelayedMouseLeaveWindow == NULL) {
  3640 				if (needDelayedMouseLeaveWindow == NULL) {
  3641                                     needDelayedMouseLeaveWindow = __currentPointerView;
  3641 				    needDelayedMouseLeaveWindow = __currentPointerView;
  3642                                 }
  3642 				}
  3643                             } else {
  3643 			    } else {
  3644                                 if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  3644 				if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  3645                                     enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, evTime);
  3645 				    enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, evTime);
  3646                                     SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  3646 				    SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  3647                                 }
  3647 				}
  3648                             }
  3648 			    }
  3649                             __currentPointerView = 0;
  3649 			    __currentPointerView = 0;
  3650                         }
  3650 			}
  3651 
  3651 
  3652 #if 0
  3652 #if 0
  3653                         if (__activateOnClick) {
  3653 			if (__activateOnClick) {
  3654                             /*
  3654 			    /*
  3655                              * only send mouseEnter if the window belongs to the current
  3655 			     * only send mouseEnter if the window belongs to the current
  3656                              * active window
  3656 			     * active window
  3657                              */
  3657 			     */
  3658                             if (GetTopParent(prevPointerView) == GetTopParent(hWnd)) {
  3658 			    if (GetTopParent(prevPointerView) == GetTopParent(hWnd)) {
  3659                             }
  3659 			    }
  3660                         }
  3660 			}
  3661 #endif
  3661 #endif
  3662                         if (inSizeMove) {
  3662 			if (inSizeMove) {
  3663                             needDelayedMouseEnterWindow = hWnd;
  3663 			    needDelayedMouseEnterWindow = hWnd;
  3664                             delayedMouseEnterX = x;
  3664 			    delayedMouseEnterX = x;
  3665                             delayedMouseEnterY = y;
  3665 			    delayedMouseEnterY = y;
  3666                         } else {
  3666 			} else {
  3667                             if (GetWindow_eventMask(hWnd) & EnterWindowMask) {
  3667 			    if (GetWindow_eventMask(hWnd) & EnterWindowMask) {
  3668                                 enqEvent(EnterWindowMask, hWnd, __WM_MOUSEENTER, 0, x, y, 0, modifiers, evTime);
  3668 				enqEvent(EnterWindowMask, hWnd, __WM_MOUSEENTER, 0, x, y, 0, modifiers, evTime);
  3669                                 SetWindow_mouseXY(hWnd, x, y);
  3669 				SetWindow_mouseXY(hWnd, x, y);
  3670                             }
  3670 			    }
  3671                         }
  3671 			}
  3672                         __currentPointerView = hWnd;
  3672 			__currentPointerView = hWnd;
  3673                     }
  3673 		    }
  3674                     DPRINTFIF(__debug_WM_MOUSEMOVE__ , ("MouseMove %x\n", __currentPointerView));
  3674 		    DPRINTFIF(__debug_WM_MOUSEMOVE__ , ("MouseMove %x\n", __currentPointerView));
  3675                 } else {
  3675 		} else {
  3676                     CPRINTF(("MouseMove Capture %x\n", __currentPointerView));
  3676 		    CPRINTF(("MouseMove Capture %x\n", __currentPointerView));
  3677                 }
  3677 		}
  3678 
  3678 
  3679                 if ((GetWindow_eventMask(__currentPointerView) & PointerMotionMask)
  3679 		if ((GetWindow_eventMask(__currentPointerView) & PointerMotionMask)
  3680                  || (modifiers & AnyButtonMask)) {
  3680 		 || (modifiers & AnyButtonMask)) {
  3681                     if (! __eatingMouseEvents) {
  3681 		    if (! __eatingMouseEvents) {
  3682                         if ((x == lastMotionX)
  3682 			if ((x == lastMotionX)
  3683                          && (y == lastMotionY)
  3683 			 && (y == lastMotionY)
  3684                          && (__currentPointerView == lastMotionWnd)) {
  3684 			 && (__currentPointerView == lastMotionWnd)) {
  3685                             /* ignore */
  3685 			    /* ignore */
  3686                         } else {
  3686 			} else {
  3687                             lastMotionX = x;
  3687 			    lastMotionX = x;
  3688                             lastMotionY = y;
  3688 			    lastMotionY = y;
  3689                             lastMotionWnd = __currentPointerView;
  3689 			    lastMotionWnd = __currentPointerView;
  3690 
  3690 
  3691                             if ((GetWindow_mouseX(__currentPointerView) == x)
  3691 			    if ((GetWindow_mouseX(__currentPointerView) == x)
  3692                              && (GetWindow_mouseY(__currentPointerView) == y)) {
  3692 			     && (GetWindow_mouseY(__currentPointerView) == y)) {
  3693                             } else {
  3693 			    } else {
  3694                                 enqEvent(PointerMotionMask, __currentPointerView, WM_MOUSEMOVE, wParam, x, y, 0, modifiers, evTime);
  3694 				enqEvent(PointerMotionMask, __currentPointerView, WM_MOUSEMOVE, wParam, x, y, 0, modifiers, evTime);
  3695                                 SetWindow_mouseXY(__currentPointerView, x, y);
  3695 				SetWindow_mouseXY(__currentPointerView, x, y);
  3696                             }
  3696 			    }
  3697                         }
  3697 			}
  3698                     }
  3698 		    }
  3699                 }
  3699 		}
  3700             }
  3700 	    }
  3701             *pDefault = 0;
  3701 	    *pDefault = 0;
  3702             return 0;
  3702 	    return 0;
  3703 
  3703 
  3704         case WM_LBUTTONUP:
  3704 	case WM_LBUTTONUP:
  3705             DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_LBUTTONUP h=%x\n", hWnd));
  3705 	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_LBUTTONUP h=%x\n", hWnd));
  3706             curButton = Button1;
  3706 	    curButton = Button1;
  3707             goto commonButtonUp;
  3707 	    goto commonButtonUp;
  3708         case WM_MBUTTONUP:
  3708 	case WM_MBUTTONUP:
  3709             DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_MBUTTONUP h=%x\n", hWnd));
  3709 	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_MBUTTONUP h=%x\n", hWnd));
  3710             curButton = Button2;
  3710 	    curButton = Button2;
  3711             goto commonButtonUp;
  3711 	    goto commonButtonUp;
  3712         case WM_RBUTTONUP:
  3712 	case WM_RBUTTONUP:
  3713             DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_RBUTTONUP h=%x\n", hWnd));
  3713 	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_RBUTTONUP h=%x\n", hWnd));
  3714             curButton = Button3;
  3714 	    curButton = Button3;
  3715 commonButtonUp:
  3715 commonButtonUp:
  3716             if (isNative) {
  3716 	    if (isNative) {
  3717                 NDPRINTF(("WM_*BUTTONUP for native - default handling\n"));
  3717 		NDPRINTF(("WM_*BUTTONUP for native - default handling\n"));
  3718                 return 0;
  3718 		return 0;
  3719             }
  3719 	    }
  3720 
  3720 
  3721 #ifndef PRE_01_APR_04
  3721 #ifndef PRE_01_APR_04
  3722             if ((__currentPointerView != hWnd) && (__currentPointerView == (HANDLE)0)) {
  3722 	    if ((__currentPointerView != hWnd) && (__currentPointerView == (HANDLE)0)) {
  3723                 __currentPointerView = hWnd;
  3723 		__currentPointerView = hWnd;
  3724 
  3724 
  3725                 if (GetWindow_eventMask(hWnd) & EnterWindowMask) {
  3725 		if (GetWindow_eventMask(hWnd) & EnterWindowMask) {
  3726                     POINT p;
  3726 		    POINT p;
  3727 
  3727 
  3728                     p.x = evRootX;
  3728 		    p.x = evRootX;
  3729                     p.y = evRootY;
  3729 		    p.y = evRootY;
  3730 
  3730 
  3731                     ScreenToClient (hWnd, & p);
  3731 		    ScreenToClient (hWnd, & p);
  3732 
  3732 
  3733                     if ((p.x >= 0) && (p.y >= 0)) {
  3733 		    if ((p.x >= 0) && (p.y >= 0)) {
  3734                         enqEvent(EnterWindowMask, hWnd, __WM_MOUSEENTER, 0, p.x, p.y, 0, getModifiers(), EV_NOTIME);
  3734 			enqEvent(EnterWindowMask, hWnd, __WM_MOUSEENTER, 0, p.x, p.y, 0, getModifiers(), EV_NOTIME);
  3735                         SetWindow_mouseXY(hWnd, p.x, p.y);
  3735 			SetWindow_mouseXY(hWnd, p.x, p.y);
  3736                     } else {
  3736 		    } else {
  3737                         __currentPointerView = (HANDLE) 0;
  3737 			__currentPointerView = (HANDLE) 0;
  3738                     }
  3738 		    }
  3739                 }
  3739 		}
  3740             }
  3740 	    }
  3741 #endif
  3741 #endif
  3742 
  3742 
  3743             if (__currentCapture == curButton /* CAPTURE_IMPLICIT*/) {
  3743 	    if (__currentCapture == curButton /* CAPTURE_IMPLICIT*/) {
  3744                 __currentCapture = CAPTURE_NONE;
  3744 		__currentCapture = CAPTURE_NONE;
  3745                 ReleaseCapture();
  3745 		ReleaseCapture();
  3746                 CPRINTF(("ReleaseCapture <BUTTONUP>\n"));
  3746 		CPRINTF(("ReleaseCapture <BUTTONUP>\n"));
  3747             }
  3747 	    }
  3748             EVENT_PRINTF3(("WM_BUTTONUP h=%x pos=%d/%d\n",
  3748 	    EVENT_PRINTF3(("WM_BUTTONUP h=%x pos=%d/%d\n",
  3749                            hWnd, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)));
  3749 			   hWnd, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)));
  3750 
  3750 
  3751 
  3751 
  3752             if (GetWindow_eventMask(hWnd) & ButtonReleaseMask) {
  3752 	    if (GetWindow_eventMask(hWnd) & ButtonReleaseMask) {
  3753                 if (__eatingMouseEvents) {
  3753 		if (__eatingMouseEvents) {
  3754                     __eatingMouseEvents = 0;
  3754 		    __eatingMouseEvents = 0;
  3755                 } else {
  3755 		} else {
  3756                     enqEvent(ButtonReleaseMask, hWnd,
  3756 		    enqEvent(ButtonReleaseMask, hWnd,
  3757                              message, wParam, (UINT)(short)LOWORD(lParam), (INT)(short)HIWORD(lParam),
  3757 			     message, wParam, (UINT)(short)LOWORD(lParam), (INT)(short)HIWORD(lParam),
  3758                              wParam, getModifiers(), evTime);
  3758 			     wParam, getModifiers(), evTime);
  3759                 }
  3759 		}
  3760             }
  3760 	    }
  3761             *pDefault = 0;
  3761 	    *pDefault = 0;
  3762             break;
  3762 	    break;
  3763 
  3763 
  3764         case WM_LBUTTONDBLCLK:
  3764 	case WM_LBUTTONDBLCLK:
  3765             DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_LBUTTONDBLCLK h=%x\n", hWnd));
  3765 	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_LBUTTONDBLCLK h=%x\n", hWnd));
  3766             curButton = Button1;
  3766 	    curButton = Button1;
  3767             goto commonButtonDown;
  3767 	    goto commonButtonDown;
  3768         case WM_MBUTTONDBLCLK:
  3768 	case WM_MBUTTONDBLCLK:
  3769             DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_MBUTTONDBLCLK h=%x\n", hWnd));
  3769 	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_MBUTTONDBLCLK h=%x\n", hWnd));
  3770             curButton = Button2;
  3770 	    curButton = Button2;
  3771             goto commonButtonDown;
  3771 	    goto commonButtonDown;
  3772         case WM_RBUTTONDBLCLK:
  3772 	case WM_RBUTTONDBLCLK:
  3773             DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_RBUTTONDBLCLK h=%x\n", hWnd));
  3773 	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_RBUTTONDBLCLK h=%x\n", hWnd));
  3774             curButton = Button3;
  3774 	    curButton = Button3;
  3775 #ifdef PRE_25_AUG_2010
  3775 #ifdef PRE_25_AUG_2010
  3776             if (isNative) {
  3776 	    if (isNative) {
  3777                  NDPRINTF(("WM_*BUTTONDBLCLK for native - default handling\n"));
  3777 		 NDPRINTF(("WM_*BUTTONDBLCLK for native - default handling\n"));
  3778                  return 0;
  3778 		 return 0;
  3779             }
  3779 	    }
  3780             goto commonButton;
  3780 	    goto commonButton;
  3781 #else
  3781 #else
  3782             goto commonButtonDown;
  3782 	    goto commonButtonDown;
  3783 #endif /* PRE_25_AUG_2010 */
  3783 #endif /* PRE_25_AUG_2010 */
  3784 
  3784 
  3785         case WM_LBUTTONDOWN:
  3785 	case WM_LBUTTONDOWN:
  3786             DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_LBUTTONDOWN h=%x\n", hWnd));
  3786 	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_LBUTTONDOWN h=%x\n", hWnd));
  3787             curButton = Button1;
  3787 	    curButton = Button1;
  3788             goto commonButtonDown;
  3788 	    goto commonButtonDown;
  3789         case WM_MBUTTONDOWN:
  3789 	case WM_MBUTTONDOWN:
  3790             DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_MBUTTONDOWN h=%x\n", hWnd));
  3790 	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_MBUTTONDOWN h=%x\n", hWnd));
  3791             curButton = Button2;
  3791 	    curButton = Button2;
  3792             goto commonButtonDown;
  3792 	    goto commonButtonDown;
  3793         case WM_RBUTTONDOWN:
  3793 	case WM_RBUTTONDOWN:
  3794             DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_RBUTTONDOWN h=%x\n", hWnd));
  3794 	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_RBUTTONDOWN h=%x\n", hWnd));
  3795             curButton = Button3;
  3795 	    curButton = Button3;
  3796 
  3796 
  3797         commonButtonDown:
  3797 	commonButtonDown:
  3798             if (isNative) {
  3798 	    if (isNative) {
  3799                 NDPRINTF(("WM_*BUTTONDOWN for native - default handling\n"));
  3799 		NDPRINTF(("WM_*BUTTONDOWN for native - default handling\n"));
  3800                 return 0;
  3800 		return 0;
  3801             }
  3801 	    }
  3802 
  3802 
  3803         commonButtonWithCapture:
  3803 	commonButtonWithCapture:
  3804             if (__currentCapture == CAPTURE_NONE) {
  3804 	    if (__currentCapture == CAPTURE_NONE) {
  3805                 __currentCapture = curButton /*CAPTURE_IMPLICIT*/;
  3805 		__currentCapture = curButton /*CAPTURE_IMPLICIT*/;
  3806                 //SetFocus(hWnd);
  3806 		//SetFocus(hWnd);
  3807                 SetCapture(hWnd);
  3807 		SetCapture(hWnd);
  3808                 CPRINTF(("SetCapture <BUTTONDOWN>%x\n",hWnd));
  3808 		CPRINTF(("SetCapture <BUTTONDOWN>%x\n",hWnd));
  3809             }
  3809 	    }
  3810             goto commonButton;
  3810 	    goto commonButton;
  3811 
  3811 
  3812         commonButton:
  3812 	commonButton:
  3813             EVENT_PRINTF3(("WM_BUTTONDOWN h=%x pos=%d/%d\n",
  3813 	    EVENT_PRINTF3(("WM_BUTTONDOWN h=%x pos=%d/%d\n",
  3814                            hWnd, LOWORD(lParam), HIWORD(lParam)));
  3814 			   hWnd, LOWORD(lParam), HIWORD(lParam)));
  3815 
  3815 
  3816             if (GetWindow_eventMask(hWnd) & ButtonPressMask) {
  3816 	    if (GetWindow_eventMask(hWnd) & ButtonPressMask) {
  3817                 if (__eatingMouseEvents) {
  3817 		if (__eatingMouseEvents) {
  3818                     __eatingMouseEvents = 0;
  3818 		    __eatingMouseEvents = 0;
  3819                 } else {
  3819 		} else {
  3820                     enqEvent(ButtonPressMask, hWnd,
  3820 		    enqEvent(ButtonPressMask, hWnd,
  3821                              message, wParam, (UINT)(short)LOWORD(lParam), (INT)(short)HIWORD(lParam),
  3821 			     message, wParam, (UINT)(short)LOWORD(lParam), (INT)(short)HIWORD(lParam),
  3822                              wParam, getModifiers(), evTime);
  3822 			     wParam, getModifiers(), evTime);
  3823                 }
  3823 		}
  3824             }
  3824 	    }
  3825             *pDefault = 0;
  3825 	    *pDefault = 0;
  3826             break;
  3826 	    break;
  3827 
  3827 
  3828         case WM_CAPTURECHANGED:
  3828 	case WM_CAPTURECHANGED:
  3829             DPRINTFIF(__debug_WM_FOCUS__ , ("WM_CAPTURECHANGED h=%x to %x\n", hWnd, lParam));
  3829 	    DPRINTFIF(__debug_WM_FOCUS__ , ("WM_CAPTURECHANGED h=%x to %x\n", hWnd, lParam));
  3830 #if 0
  3830 #if 0
  3831             if ((__currentCapture != CAPTURE_NONE) && (__currentCapture != CAPTURE_EXPLICIT))
  3831 	    if ((__currentCapture != CAPTURE_NONE) && (__currentCapture != CAPTURE_EXPLICIT))
  3832             {
  3832 	    {
  3833             }
  3833 	    }
  3834 #endif
  3834 #endif
  3835             break;
  3835 	    break;
  3836 
  3836 
  3837         case WM_KILLFOCUS:
  3837 	case WM_KILLFOCUS:
  3838             DPRINTFIF(__debug_WM_FOCUS__ , ("WM_KILLFOCUS h=%x\n", hWnd));
  3838 	    DPRINTFIF(__debug_WM_FOCUS__ , ("WM_KILLFOCUS h=%x\n", hWnd));
  3839             // enqEvent(0, hWnd, WM_KILLFOCUS, wParam, 0, 0, 0, 0, EV_NOTIME);
  3839 	    // enqEvent(0, hWnd, WM_KILLFOCUS, wParam, 0, 0, 0, 0, EV_NOTIME);
  3840             if (isNative) {
  3840 	    if (isNative) {
  3841                 NDPRINTF(("WM_KILLFOCUS for native - default handling\n"));
  3841 		NDPRINTF(("WM_KILLFOCUS for native - default handling\n"));
  3842                 return 0;
  3842 		return 0;
  3843             }
  3843 	    }
  3844             *pDefault = 0;
  3844 	    *pDefault = 0;
  3845             break;
  3845 	    break;
  3846 
  3846 
  3847         case WM_SETFOCUS:
  3847 	case WM_SETFOCUS:
  3848             DPRINTFIF(__debug_WM_FOCUS__ , ("WM_SETFOCUS h=%x\n", hWnd));
  3848 	    DPRINTFIF(__debug_WM_FOCUS__ , ("WM_SETFOCUS h=%x\n", hWnd));
  3849 #if 0
  3849 #if 0
  3850             // enqEvent(0,hWnd, WM_SETFOCUS, wParam, 0, 0, 0, 0, EV_NOTIME);
  3850 	    // enqEvent(0,hWnd, WM_SETFOCUS, wParam, 0, 0, 0, 0, EV_NOTIME);
  3851             {
  3851 	    {
  3852                 POINT p;
  3852 		POINT p;
  3853                 HWND hWndChild,hWndTemp;
  3853 		HWND hWndChild,hWndTemp;
  3854 
  3854 
  3855                 p.x = evRootX;
  3855 		p.x = evRootX;
  3856                 p.y = evRootY;
  3856 		p.y = evRootY;
  3857                 ScreenToClient(hWnd, &p);
  3857 		ScreenToClient(hWnd, &p);
  3858                 hWndChild = hWnd; //hWndChild = ChildWindowFromPoint(hWnd,p);
  3858 		hWndChild = hWnd; //hWndChild = ChildWindowFromPoint(hWnd,p);
  3859                 do {
  3859 		do {
  3860                     hWndTemp = hWndChild;
  3860 		    hWndTemp = hWndChild;
  3861                     hWndChild = ChildWindowFromPointEx(hWndTemp,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
  3861 		    hWndChild = ChildWindowFromPointEx(hWndTemp,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
  3862                 } while ((hWndChild) && (hWndChild != hWndTemp));
  3862 		} while ((hWndChild) && (hWndChild != hWndTemp));
  3863 
  3863 
  3864                 /*console_printf("WM_ACTIVATE active h=%x p=%d.%d in %x\n", hWnd,p.x,p.y,hWndChild);*/
  3864 		/*console_printf("WM_ACTIVATE active h=%x p=%d.%d in %x\n", hWnd,p.x,p.y,hWndChild);*/
  3865                 if (hWndChild /*&& (hWndChild != hWnd)*/) {
  3865 		if (hWndChild /*&& (hWndChild != hWnd)*/) {
  3866                     if (hWndChild != __currentPointerView) {
  3866 		    if (hWndChild != __currentPointerView) {
  3867                         int modifiers = getModifiers();
  3867 			int modifiers = getModifiers();
  3868 
  3868 
  3869                         if (__currentPointerView) {
  3869 			if (__currentPointerView) {
  3870                             if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask)
  3870 			    if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask)
  3871                                 enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
  3871 				enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
  3872                                 SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  3872 				SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  3873 
  3873 
  3874                             __currentPointerView = 0;
  3874 			    __currentPointerView = 0;
  3875                         }
  3875 			}
  3876                         if (GetWindow_eventMask(hWndChild) & EnterWindowMask) {
  3876 			if (GetWindow_eventMask(hWndChild) & EnterWindowMask) {
  3877                             enqEvent(EnterWindowMask, hWndChild, __WM_MOUSEENTER, 0, evRootX, evRootY, 0, modifiers, EV_NOTIME);
  3877 			    enqEvent(EnterWindowMask, hWndChild, __WM_MOUSEENTER, 0, evRootX, evRootY, 0, modifiers, EV_NOTIME);
  3878                             SetWindow_mouseXY(hWndChild, evRootX, evRootY);
  3878 			    SetWindow_mouseXY(hWndChild, evRootX, evRootY);
  3879                         }
  3879 			}
  3880                         //SetFocus(hWndChild);
  3880 			//SetFocus(hWndChild);
  3881                         __currentPointerView = hWndChild;
  3881 			__currentPointerView = hWndChild;
  3882                     }
  3882 		    }
  3883                 }
  3883 		}
  3884             }
  3884 	    }
  3885 
  3885 
  3886             if (isNative) {
  3886 	    if (isNative) {
  3887                 NDPRINTF(("WM_SETFOCUS for native - default handling\n"));
  3887 		NDPRINTF(("WM_SETFOCUS for native - default handling\n"));
  3888                 return 0;
  3888 		return 0;
  3889             }
  3889 	    }
  3890             *pDefault = 0;
  3890 	    *pDefault = 0;
  3891 #endif
  3891 #endif
  3892             break;
  3892 	    break;
  3893 
  3893 
  3894         case WM_GETTEXT:
  3894 	case WM_GETTEXT:
  3895             /*EVENT_PRINTF(("WM_GETTEXT %x\n", message));*/
  3895 	    /*EVENT_PRINTF(("WM_GETTEXT %x\n", message));*/
  3896             break;
  3896 	    break;
  3897 
  3897 
  3898         case WM_GETTEXTLENGTH:
  3898 	case WM_GETTEXTLENGTH:
  3899             EVENT_PRINTF(("WM_GETTEXTLENGTH %x\n", message));
  3899 	    EVENT_PRINTF(("WM_GETTEXTLENGTH %x\n", message));
  3900             break;
  3900 	    break;
  3901 
  3901 
  3902         case WM_NCCREATE:
  3902 	case WM_NCCREATE:
  3903             EVENT_PRINTF(("WM_NCCREATE %x\n", message));
  3903 	    EVENT_PRINTF(("WM_NCCREATE %x\n", message));
  3904             break;
  3904 	    break;
  3905 
  3905 
  3906         case WM_NCMOUSEMOVE:
  3906 	case WM_NCMOUSEMOVE:
  3907             if (__currentCapture == CAPTURE_NONE) {
  3907 	    if (__currentCapture == CAPTURE_NONE) {
  3908                 if (__currentPointerView && (hWnd != __currentPointerView)) {
  3908 		if (__currentPointerView && (hWnd != __currentPointerView)) {
  3909                     if (inSizeMove) {
  3909 		    if (inSizeMove) {
  3910                         if (needDelayedMouseLeaveWindow == NULL) {
  3910 			if (needDelayedMouseLeaveWindow == NULL) {
  3911                             needDelayedMouseLeaveWindow = __currentPointerView;
  3911 			    needDelayedMouseLeaveWindow = __currentPointerView;
  3912                         }
  3912 			}
  3913                     } else {
  3913 		    } else {
  3914                         if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  3914 			if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  3915                             enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, getModifiers(), evTime);
  3915 			    enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, getModifiers(), evTime);
  3916                             SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  3916 			    SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  3917                         }
  3917 			}
  3918                     }
  3918 		    }
  3919                     __currentPointerView = 0;
  3919 		    __currentPointerView = 0;
  3920                 }
  3920 		}
  3921             }
  3921 	    }
  3922             *pDefault = 0;
  3922 	    *pDefault = 0;
  3923             break;
  3923 	    break;
  3924 
  3924 
  3925         case WM_PARENTNOTIFY:
  3925 	case WM_PARENTNOTIFY:
  3926             EVENT_PRINTF2(("WM_PARENTNOTIFY h=%x hChild=%x %d\n",
  3926 	    EVENT_PRINTF2(("WM_PARENTNOTIFY h=%x hChild=%x %d\n",
  3927                                 hWnd, lParam, LOWORD(wParam)));
  3927 				hWnd, lParam, LOWORD(wParam)));
  3928             break;
  3928 	    break;
  3929 
  3929 
  3930         case WM_NCLBUTTONDOWN:
  3930 	case WM_NCLBUTTONDOWN:
  3931             DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_NCLBUTTONDOWN\n"));
  3931 	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_NCLBUTTONDOWN\n"));
  3932             if (__shiftedLeftButtonIsLowerWindow) {
  3932 	    if (__shiftedLeftButtonIsLowerWindow) {
  3933                 /*
  3933 		/*
  3934                  * with shift, this is a lower-operation
  3934 		 * with shift, this is a lower-operation
  3935                  */
  3935 		 */
  3936                 if (GetKeyState(VK_SHIFT) & 0x8000) {
  3936 		if (GetKeyState(VK_SHIFT) & 0x8000) {
  3937                     SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0,
  3937 		    SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0,
  3938                                  SWP_NOSENDCHANGING |
  3938 				 SWP_NOSENDCHANGING |
  3939                                  SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  3939 				 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  3940                     *pDefault = 0;
  3940 		    *pDefault = 0;
  3941                 }
  3941 		}
  3942             }
  3942 	    }
  3943             break;
  3943 	    break;
  3944 
  3944 
  3945         case WM_NCLBUTTONUP:
  3945 	case WM_NCLBUTTONUP:
  3946             DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_NCLBUTTONUP\n"));
  3946 	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_NCLBUTTONUP\n"));
  3947             break;
  3947 	    break;
  3948 
  3948 
  3949         case WM_NCRBUTTONDOWN:
  3949 	case WM_NCRBUTTONDOWN:
  3950             DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_NCRBUTTONDOWN\n"));
  3950 	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_NCRBUTTONDOWN\n"));
  3951             if (__rightButtonIsLowerWindow) {
  3951 	    if (__rightButtonIsLowerWindow) {
  3952                 /*
  3952 		/*
  3953                  * this is a lower-operation
  3953 		 * this is a lower-operation
  3954                  */
  3954 		 */
  3955                 SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0,
  3955 		SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0,
  3956                              SWP_NOSENDCHANGING |
  3956 			     SWP_NOSENDCHANGING |
  3957                              SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  3957 			     SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  3958                 *pDefault = 0;
  3958 		*pDefault = 0;
  3959             }
  3959 	    }
  3960             break;
  3960 	    break;
  3961 
  3961 
  3962         case WM_NCRBUTTONUP:
  3962 	case WM_NCRBUTTONUP:
  3963             DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_NCRBUTTONUP\n"));
  3963 	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_NCRBUTTONUP\n"));
  3964             break;
  3964 	    break;
  3965 
  3965 
  3966         case WM_NCMBUTTONDOWN:
  3966 	case WM_NCMBUTTONDOWN:
  3967             DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_NCMBUTTONDOWN\n"));
  3967 	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_NCMBUTTONDOWN\n"));
  3968             break;
  3968 	    break;
  3969 
  3969 
  3970         case WM_NCMBUTTONUP:
  3970 	case WM_NCMBUTTONUP:
  3971             DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_NCMBUTTONUP\n"));
  3971 	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_NCMBUTTONUP\n"));
  3972             break;
  3972 	    break;
  3973 
  3973 
  3974         case WM_NCLBUTTONDBLCLK:
  3974 	case WM_NCLBUTTONDBLCLK:
  3975             EVENT_PRINTF(("WM_NCLBUTTONDBLCLK\n"));
  3975 	    EVENT_PRINTF(("WM_NCLBUTTONDBLCLK\n"));
  3976             break;
  3976 	    break;
  3977 
  3977 
  3978         case WM_NCRBUTTONDBLCLK:
  3978 	case WM_NCRBUTTONDBLCLK:
  3979             EVENT_PRINTF(("WM_NCRBUTTONDBLCLK\n"));
  3979 	    EVENT_PRINTF(("WM_NCRBUTTONDBLCLK\n"));
  3980             break;
  3980 	    break;
  3981 
  3981 
  3982         case WM_NCMBUTTONDBLCLK:
  3982 	case WM_NCMBUTTONDBLCLK:
  3983             EVENT_PRINTF(("WM_NCMBUTTONDBLCLK\n"));
  3983 	    EVENT_PRINTF(("WM_NCMBUTTONDBLCLK\n"));
  3984             break;
  3984 	    break;
  3985 
  3985 
  3986         case WM_SETTEXT:
  3986 	case WM_SETTEXT:
  3987             DPRINTFIF(__debug_WM_SETTEXT__ , ("WM_SETTEXT\n"));
  3987 	    DPRINTFIF(__debug_WM_SETTEXT__ , ("WM_SETTEXT\n"));
  3988             break;
  3988 	    break;
  3989 
  3989 
  3990 #ifdef WM_SYNCPAINT
  3990 #ifdef WM_SYNCPAINT
  3991         case WM_SYNCPAINT:
  3991 	case WM_SYNCPAINT:
  3992             EVENT_PRINTF(("WM_SYNCPAINT\n"));
  3992 	    EVENT_PRINTF(("WM_SYNCPAINT\n"));
  3993             break;
  3993 	    break;
  3994 #else
  3994 #else
  3995         case 0x88:
  3995 	case 0x88:
  3996             EVENT_PRINTF(("0x88 (undoc)\n"));
  3996 	    EVENT_PRINTF(("0x88 (undoc)\n"));
  3997             break;
  3997 	    break;
  3998 #endif
  3998 #endif
  3999 
  3999 
  4000         case WM_NCCALCSIZE:
  4000 	case WM_NCCALCSIZE:
  4001             EVENT_PRINTF(("WM_NCCALCSIZE\n"));
  4001 	    EVENT_PRINTF(("WM_NCCALCSIZE\n"));
  4002             break;
  4002 	    break;
  4003 
  4003 
  4004         case WM_NCPAINT:
  4004 	case WM_NCPAINT:
  4005             EVENT_PRINTF3(("WM_NCPAINT\n"));
  4005 	    EVENT_PRINTF3(("WM_NCPAINT\n"));
  4006 
  4006 
  4007 #ifdef THIS_DOES_NOT_WORK
  4007 #ifdef THIS_DOES_NOT_WORK
  4008             /* mhmh - something is drawn, but clipped wrong
  4008 	    /* mhmh - something is drawn, but clipped wrong
  4009              * and with wrong colors ....
  4009 	     * and with wrong colors ....
  4010              */
  4010 	     */
  4011 
  4011 
  4012             /*
  4012 	    /*
  4013              * child windows only ...
  4013 	     * child windows only ...
  4014              */
  4014 	     */
  4015             if (GetParent(hWnd)) {
  4015 	    if (GetParent(hWnd)) {
  4016                 int clr;
  4016 		int clr;
  4017 
  4017 
  4018                 clr = GetWindow_bdColor(hWnd);
  4018 		clr = GetWindow_bdColor(hWnd);
  4019                 if (clr != BlackPixel) {
  4019 		if (clr != BlackPixel) {
  4020                     /*
  4020 		    /*
  4021                      * draw it here
  4021 		     * draw it here
  4022                      */
  4022 		     */
  4023                     HBRUSH br;
  4023 		    HBRUSH br;
  4024                     RECT rect, lineRect;
  4024 		    RECT rect, lineRect;
  4025                     HDC hDC;
  4025 		    HDC hDC;
  4026 
  4026 
  4027                     if (clr == WhitePixel) {
  4027 		    if (clr == WhitePixel) {
  4028                         br = __whiteBrush;
  4028 			br = __whiteBrush;
  4029                     } else {
  4029 		    } else {
  4030                         br = CreateSolidBrush(clr);
  4030 			br = CreateSolidBrush(clr);
  4031                     }
  4031 		    }
  4032 
  4032 
  4033                     GetWindowRect(hWnd, &rect);
  4033 		    GetWindowRect(hWnd, &rect);
  4034                     hDC = GetWindowDC(hWnd);
  4034 		    hDC = GetWindowDC(hWnd);
  4035                     SelectClipRgn(hDC, NULL);
  4035 		    SelectClipRgn(hDC, NULL);
  4036 
  4036 
  4037                     lineRect.left = rect.left;
  4037 		    lineRect.left = rect.left;
  4038                     lineRect.right = rect.right;
  4038 		    lineRect.right = rect.right;
  4039                     lineRect.top = rect.top;
  4039 		    lineRect.top = rect.top;
  4040                     lineRect.bottom = rect.top + 1;
  4040 		    lineRect.bottom = rect.top + 1;
  4041                     FillRect(hDC, &lineRect, br);
  4041 		    FillRect(hDC, &lineRect, br);
  4042 
  4042 
  4043                     lineRect.bottom = rect.bottom - 1;
  4043 		    lineRect.bottom = rect.bottom - 1;
  4044                     lineRect.bottom = rect.bottom;
  4044 		    lineRect.bottom = rect.bottom;
  4045                     FillRect(hDC, &lineRect, br);
  4045 		    FillRect(hDC, &lineRect, br);
  4046 
  4046 
  4047                     lineRect.top = rect.top;
  4047 		    lineRect.top = rect.top;
  4048                     lineRect.bottom = rect.bottom;
  4048 		    lineRect.bottom = rect.bottom;
  4049                     lineRect.left = rect.left;
  4049 		    lineRect.left = rect.left;
  4050                     lineRect.right = rect.left + 1;
  4050 		    lineRect.right = rect.left + 1;
  4051                     FillRect(hDC, &lineRect, br);
  4051 		    FillRect(hDC, &lineRect, br);
  4052 
  4052 
  4053                     lineRect.left = rect.right - 1;
  4053 		    lineRect.left = rect.right - 1;
  4054                     lineRect.right = rect.right;
  4054 		    lineRect.right = rect.right;
  4055                     FillRect(hDC, &lineRect, br);
  4055 		    FillRect(hDC, &lineRect, br);
  4056 
  4056 
  4057                     _DeleteBrush(br, __LINE__);
  4057 		    _DeleteBrush(br, __LINE__);
  4058                     ReleaseDC(hWnd, hDC);
  4058 		    ReleaseDC(hWnd, hDC);
  4059                     *pDefault = 0;
  4059 		    *pDefault = 0;
  4060                     return 0;
  4060 		    return 0;
  4061                 }
  4061 		}
  4062             }
  4062 	    }
  4063 #endif /* THIS_DOES_NOT_WORK */
  4063 #endif /* THIS_DOES_NOT_WORK */
  4064             break;
  4064 	    break;
  4065 
  4065 
  4066         case WM_SYSCOMMAND:
  4066 	case WM_SYSCOMMAND:
  4067             switch (wParam & ~0x000F) {
  4067 	    switch (wParam & ~0x000F) {
  4068                 case SC_CLOSE:
  4068 		case SC_CLOSE:
  4069                     EVENT_PRINTF2(("WM_SYSCOMMAND SC_CLOSE\n"));
  4069 		    EVENT_PRINTF2(("WM_SYSCOMMAND SC_CLOSE\n"));
  4070                     break;
  4070 		    break;
  4071 
  4071 
  4072                 case SC_MOVE:
  4072 		case SC_MOVE:
  4073                     EVENT_PRINTF2(("WM_SYSCOMMAND SC_MOVE\n"));
  4073 		    EVENT_PRINTF2(("WM_SYSCOMMAND SC_MOVE\n"));
  4074                     break;
  4074 		    break;
  4075 
  4075 
  4076                 case SC_RESTORE:
  4076 		case SC_RESTORE:
  4077                     EVENT_PRINTF2(("WM_SYSCOMMAND SC_RESTORE\n"));
  4077 		    EVENT_PRINTF2(("WM_SYSCOMMAND SC_RESTORE\n"));
  4078                     break;
  4078 		    break;
  4079 
  4079 
  4080                 case SC_SIZE:
  4080 		case SC_SIZE:
  4081                     EVENT_PRINTF2(("WM_SYSCOMMAND SC_SIZE\n"));
  4081 		    EVENT_PRINTF2(("WM_SYSCOMMAND SC_SIZE\n"));
  4082                     break;
  4082 		    break;
  4083 
  4083 
  4084                 default:
  4084 		default:
  4085                     EVENT_PRINTF2(("WM_SYSCOMMAND %x\n", wParam));
  4085 		    EVENT_PRINTF2(("WM_SYSCOMMAND %x\n", wParam));
  4086                     break;
  4086 		    break;
  4087             }
  4087 	    }
  4088             break;
  4088 	    break;
  4089 
  4089 
  4090         case WM_INITMENU:
  4090 	case WM_INITMENU:
  4091             EVENT_PRINTF(("WM_INITMENU\n"));
  4091 	    EVENT_PRINTF(("WM_INITMENU\n"));
  4092             break;
  4092 	    break;
  4093 
  4093 
  4094         case WM_INITMENUPOPUP:
  4094 	case WM_INITMENUPOPUP:
  4095             EVENT_PRINTF(("WM_INITMENUPOPUP\n"));
  4095 	    EVENT_PRINTF(("WM_INITMENUPOPUP\n"));
  4096             break;
  4096 	    break;
  4097 
  4097 
  4098         case WM_ENTERIDLE:
  4098 	case WM_ENTERIDLE:
  4099             EVENT_PRINTF(("WM_ENTERIDLE\n"));
  4099 	    EVENT_PRINTF(("WM_ENTERIDLE\n"));
  4100             break;
  4100 	    break;
  4101 
  4101 
  4102         case WM_ENTERMENULOOP:
  4102 	case WM_ENTERMENULOOP:
  4103             EVENT_PRINTF(("WM_ENTERMENULOOP\n"));
  4103 	    EVENT_PRINTF(("WM_ENTERMENULOOP\n"));
  4104             break;
  4104 	    break;
  4105 
  4105 
  4106         case WM_EXITMENULOOP:
  4106 	case WM_EXITMENULOOP:
  4107             EVENT_PRINTF(("WM_EXITMENULOOP\n"));
  4107 	    EVENT_PRINTF(("WM_EXITMENULOOP\n"));
  4108             break;
  4108 	    break;
  4109 
  4109 
  4110         case WM_MENUSELECT:
  4110 	case WM_MENUSELECT:
  4111             EVENT_PRINTF(("WM_MENUSELECT\n"));
  4111 	    EVENT_PRINTF(("WM_MENUSELECT\n"));
  4112             break;
  4112 	    break;
  4113 
  4113 
  4114         case WM_QUIT:
  4114 	case WM_QUIT:
  4115             DPRINTF(("quit message hWnd=0x%x lP=0x%x wP=0x%x\n", hWnd, lParam, wParam));
  4115 	    DPRINTF(("quit message hWnd=0x%x lP=0x%x wP=0x%x\n", hWnd, lParam, wParam));
  4116             enqEvent(0, 0, WM_QUIT, wParam, lParam, 0, 0, 0, EV_NOTIME);
  4116 	    enqEvent(0, 0, WM_QUIT, wParam, lParam, 0, 0, 0, EV_NOTIME);
  4117             break;
  4117 	    break;
  4118 
  4118 
  4119         case WM_NCDESTROY:
  4119 	case WM_NCDESTROY:
  4120             EVENT_PRINTF(("WM_NCDESTROY\n"));
  4120 	    EVENT_PRINTF(("WM_NCDESTROY\n"));
  4121             break;
  4121 	    break;
  4122 
  4122 
  4123         case WM_QUERYNEWPALETTE:
  4123 	case WM_QUERYNEWPALETTE:
  4124             EVENT_PRINTF(("WM_QUERYNEWPALETTE\n"));
  4124 	    EVENT_PRINTF(("WM_QUERYNEWPALETTE\n"));
  4125             break;
  4125 	    break;
  4126 
  4126 
  4127         case WM_PALETTECHANGED:
  4127 	case WM_PALETTECHANGED:
  4128             EVENT_PRINTF(("WM_PALETTECHANGED\n"));
  4128 	    EVENT_PRINTF(("WM_PALETTECHANGED\n"));
  4129             break;
  4129 	    break;
  4130 
  4130 
  4131         case WM_ACTIVATEAPP:
  4131 	case WM_ACTIVATEAPP:
  4132             EVENT_PRINTF2(("WM_ACTIVATEAPP %s\n", wParam ? "active" : "inactive"));
  4132 	    EVENT_PRINTF2(("WM_ACTIVATEAPP %s\n", wParam ? "active" : "inactive"));
  4133             break;
  4133 	    break;
  4134 
  4134 
  4135         case WM_SYSDEADCHAR:
  4135 	case WM_SYSDEADCHAR:
  4136             EVENT_PRINTF2(("WM_SYSDEADCHAR %x\n, wParam"));
  4136 	    EVENT_PRINTF2(("WM_SYSDEADCHAR %x\n, wParam"));
  4137             break;
  4137 	    break;
  4138 
  4138 
  4139         case WM_DEADCHAR:
  4139 	case WM_DEADCHAR:
  4140             EVENT_PRINTF2(("WM_DEADCHAR %x\n, wParam"));
  4140 	    EVENT_PRINTF2(("WM_DEADCHAR %x\n, wParam"));
  4141             break;
  4141 	    break;
  4142 
  4142 
  4143         case WM_PAINTICON:
  4143 	case WM_PAINTICON:
  4144             EVENT_PRINTF(("WM_PAINTICON\n"));
  4144 	    EVENT_PRINTF(("WM_PAINTICON\n"));
  4145             break;
  4145 	    break;
  4146 
  4146 
  4147         case WM_ICONERASEBKGND:
  4147 	case WM_ICONERASEBKGND:
  4148             EVENT_PRINTF(("WM_ICONERASEBKGND\n"));
  4148 	    EVENT_PRINTF(("WM_ICONERASEBKGND\n"));
  4149             break;
  4149 	    break;
  4150 
  4150 
  4151         case WM_WINDOWPOSCHANGING:
  4151 	case WM_WINDOWPOSCHANGING:
  4152             DPRINTFIF(__debug_WM_WINDOWPOSCHANGING__ , ("WM_WINDOWPOSCHANGING\n"));
  4152 	    DPRINTFIF(__debug_WM_WINDOWPOSCHANGING__ , ("WM_WINDOWPOSCHANGING\n"));
  4153 
  4153 
  4154 #ifdef HANDLE_VIEWGRAVITY
  4154 #ifdef HANDLE_VIEWGRAVITY
  4155             /*
  4155 	    /*
  4156              * any child with a viewGravity ?
  4156 	     * any child with a viewGravity ?
  4157              * (only care for topViews here;
  4157 	     * (only care for topViews here;
  4158              *  child views do it on the smalltalk level ...)
  4158 	     *  child views do it on the smalltalk level ...)
  4159              */
  4159 	     */
  4160             if (GetParent(hWnd) == 0) {
  4160 	    if (GetParent(hWnd) == 0) {
  4161                 if (GetParent(hWnd) == 0) {
  4161 		if (GetParent(hWnd) == 0) {
  4162                     struct gravityCallBackInfo i;
  4162 		    struct gravityCallBackInfo i;
  4163                     RECT rct, dRect;
  4163 		    RECT rct, dRect;
  4164                     int dW, dH;
  4164 		    int dW, dH;
  4165                     WINDOWPOS *wp = (WINDOWPOS *)lParam;
  4165 		    WINDOWPOS *wp = (WINDOWPOS *)lParam;
  4166                     int winStyleBits, winExStyleBits;
  4166 		    int winStyleBits, winExStyleBits;
  4167 
  4167 
  4168                     if (! (wp->flags & SWP_NOSIZE)) {
  4168 		    if (! (wp->flags & SWP_NOSIZE)) {
  4169                         dRect.left = 0;
  4169 			dRect.left = 0;
  4170                         dRect.top = 0;
  4170 			dRect.top = 0;
  4171                         dRect.right = 100;
  4171 			dRect.right = 100;
  4172                         dRect.bottom = 100;
  4172 			dRect.bottom = 100;
  4173                         winStyleBits = GetWindowLong(hWnd, GWL_STYLE);
  4173 			winStyleBits = GetWindowLong(hWnd, GWL_STYLE);
  4174                         winExStyleBits = GetWindowLong(hWnd, GWL_EXSTYLE);
  4174 			winExStyleBits = GetWindowLong(hWnd, GWL_EXSTYLE);
  4175                         AdjustWindowRectEx(&dRect, winStyleBits, 0, winExStyleBits);
  4175 			AdjustWindowRectEx(&dRect, winStyleBits, 0, winExStyleBits);
  4176                         dW = dRect.right - dRect.left;
  4176 			dW = dRect.right - dRect.left;
  4177                         dH = dRect.bottom - dRect.top;
  4177 			dH = dRect.bottom - dRect.top;
  4178 
  4178 
  4179                         GetClientRect(hWnd, &rct);
  4179 			GetClientRect(hWnd, &rct);
  4180 
  4180 
  4181                         i.parent = hWnd;
  4181 			i.parent = hWnd;
  4182 
  4182 
  4183                         i.currW = rct.right - rct.left;
  4183 			i.currW = rct.right - rct.left;
  4184                         i.currH = rct.bottom - rct.top;
  4184 			i.currH = rct.bottom - rct.top;
  4185 
  4185 
  4186                         /* wp gives us the new outer (frame) bounds */
  4186 			/* wp gives us the new outer (frame) bounds */
  4187                         i.newW = wp->cx - (dW - 100);
  4187 			i.newW = wp->cx - (dW - 100);
  4188                         i.newH = wp->cy - (dH - 100);
  4188 			i.newH = wp->cy - (dH - 100);
  4189 
  4189 
  4190                         if ((i.currW != i.newW)
  4190 			if ((i.currW != i.newW)
  4191                          || (i.currH != i.newH)) {
  4191 			 || (i.currH != i.newH)) {
  4192                             DPRINTF((stderr, "about to sizeChange old: %d/%d new: %d/%d\n",
  4192 			    DPRINTF((stderr, "about to sizeChange old: %d/%d new: %d/%d\n",
  4193                                     i.currW, i.currH, i.newW, i.newH));
  4193 				    i.currW, i.currH, i.newW, i.newH));
  4194 
  4194 
  4195                             GetWindowRect(hWnd, &rct);
  4195 			    GetWindowRect(hWnd, &rct);
  4196                             i.parentWinX = rct.left - dRect.left;
  4196 			    i.parentWinX = rct.left - dRect.left;
  4197                             i.parentWinY = rct.top - dRect.top;
  4197 			    i.parentWinY = rct.top - dRect.top;
  4198                             EnumChildWindows(hWnd, gravityEnumeratorCallBack, (int)(&i));
  4198 			    EnumChildWindows(hWnd, gravityEnumeratorCallBack, (int)(&i));
  4199                         }
  4199 			}
  4200                     }
  4200 		    }
  4201                 }
  4201 		}
  4202             }
  4202 	    }
  4203 #endif /* HANDLE_VIEWGRAVITY */
  4203 #endif /* HANDLE_VIEWGRAVITY */
  4204 
  4204 
  4205             break;
  4205 	    break;
  4206 
  4206 
  4207         case WM_QUERYOPEN:
  4207 	case WM_QUERYOPEN:
  4208             EVENT_PRINTF(("WM_QUERYOPEN\n"));
  4208 	    EVENT_PRINTF(("WM_QUERYOPEN\n"));
  4209             break;
  4209 	    break;
  4210 
  4210 
  4211         case WM_QUERYENDSESSION:
  4211 	case WM_QUERYENDSESSION:
  4212             EVENT_PRINTF(("WM_QUERYENDSESSION\n"));
  4212 	    EVENT_PRINTF(("WM_QUERYENDSESSION\n"));
  4213             *pDefault = 0;
  4213 	    *pDefault = 0;
  4214             if (@global(CanEndSession) == false) {
  4214 	    if (@global(CanEndSession) == false) {
  4215                 enqEvent(0, hWnd, WM_QUERYENDSESSION, wParam, 0, 0, 0, 0, EV_NOTIME);
  4215 		enqEvent(0, hWnd, WM_QUERYENDSESSION, wParam, 0, 0, 0, 0, EV_NOTIME);
  4216 
  4216 
  4217                 // TODO: enter new event loop
  4217 		// TODO: enter new event loop
  4218                 // which is left when an endSessionConfirmation
  4218 		// which is left when an endSessionConfirmation
  4219                 // arrives from smalltalk
  4219 		// arrives from smalltalk
  4220                 // (either positive or negative).
  4220 		// (either positive or negative).
  4221                 // for now, do not allow leaving
  4221 		// for now, do not allow leaving
  4222                 // windows as long as ST/X is open.
  4222 		// windows as long as ST/X is open.
  4223 
  4223 
  4224                 return(0);
  4224 		return(0);
  4225             }
  4225 	    }
  4226             return(TRUE);  // allow leaving windows
  4226 	    return(TRUE);  // allow leaving windows
  4227             break;
  4227 	    break;
  4228 
  4228 
  4229         case WM_ENDSESSION:
  4229 	case WM_ENDSESSION:
  4230             EVENT_PRINTF(("WM_ENDSESSION\n"));
  4230 	    EVENT_PRINTF(("WM_ENDSESSION\n"));
  4231             enqEvent(0, hWnd, WM_ENDSESSION, wParam, 0, 0, 0, 0, EV_NOTIME);
  4231 	    enqEvent(0, hWnd, WM_ENDSESSION, wParam, 0, 0, 0, 0, EV_NOTIME);
  4232             break;
  4232 	    break;
  4233 
  4233 
  4234         case WM_DISPLAYCHANGE:
  4234 	case WM_DISPLAYCHANGE:
  4235             EVENT_PRINTF(("WM_DISPLAYCHANGE\n"));
  4235 	    EVENT_PRINTF(("WM_DISPLAYCHANGE\n"));
  4236             enqEvent(0, hWnd, WM_DISPLAYCHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
  4236 	    enqEvent(0, hWnd, WM_DISPLAYCHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
  4237             break;
  4237 	    break;
  4238 
  4238 
  4239         case WM_FONTCHANGE:
  4239 	case WM_FONTCHANGE:
  4240             EVENT_PRINTF(("WM_FONTCHANGE\n"));
  4240 	    EVENT_PRINTF(("WM_FONTCHANGE\n"));
  4241             enqEvent(0, hWnd, WM_FONTCHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
  4241 	    enqEvent(0, hWnd, WM_FONTCHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
  4242             break;
  4242 	    break;
  4243 
  4243 
  4244         case WM_WININICHANGE:
  4244 	case WM_WININICHANGE:
  4245             EVENT_PRINTF(("WM_WININICHANGE\n"));
  4245 	    EVENT_PRINTF(("WM_WININICHANGE\n"));
  4246             enqEvent(0, hWnd, WM_WININICHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
  4246 	    enqEvent(0, hWnd, WM_WININICHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
  4247             break;
  4247 	    break;
  4248 
  4248 
  4249         case WM_SYSCOLORCHANGE:
  4249 	case WM_SYSCOLORCHANGE:
  4250             EVENT_PRINTF(("WM_SYSCOLORCHANGE\n"));
  4250 	    EVENT_PRINTF(("WM_SYSCOLORCHANGE\n"));
  4251             enqEvent(0, hWnd, WM_SYSCOLORCHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
  4251 	    enqEvent(0, hWnd, WM_SYSCOLORCHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
  4252             break;
  4252 	    break;
  4253 
  4253 
  4254         case WM_MOVING:
  4254 	case WM_MOVING:
  4255             DPRINTFIF(__debug_WM_MOVING__ , ("WM_MOVING\n"));
  4255 	    DPRINTFIF(__debug_WM_MOVING__ , ("WM_MOVING\n"));
  4256 #ifdef DELAY_ENTER_LEAVE_WHILE_IN_SIZE_MOVE
  4256 #ifdef DELAY_ENTER_LEAVE_WHILE_IN_SIZE_MOVE
  4257             inMove = 1;
  4257 	    inMove = 1;
  4258 #endif
  4258 #endif
  4259             break;
  4259 	    break;
  4260 
  4260 
  4261         case WM_SIZING:
  4261 	case WM_SIZING:
  4262             EVENT_PRINTF(("WM_SIZING\n"));
  4262 	    EVENT_PRINTF(("WM_SIZING\n"));
  4263 #ifdef DELAY_ENTER_LEAVE_WHILE_IN_SIZE_MOVE
  4263 #ifdef DELAY_ENTER_LEAVE_WHILE_IN_SIZE_MOVE
  4264             inSize = 1;
  4264 	    inSize = 1;
  4265 #endif
  4265 #endif
  4266             break;
  4266 	    break;
  4267 
  4267 
  4268         case WM_ENTERSIZEMOVE:
  4268 	case WM_ENTERSIZEMOVE:
  4269             EVENT_PRINTF(("WM_ENTERSIZEMOVE\n"));
  4269 	    EVENT_PRINTF(("WM_ENTERSIZEMOVE\n"));
  4270 #ifdef DELAY_ENTER_LEAVE_WHILE_IN_SIZE_MOVE
  4270 #ifdef DELAY_ENTER_LEAVE_WHILE_IN_SIZE_MOVE
  4271             inSizeMove = 1;
  4271 	    inSizeMove = 1;
  4272 #endif
  4272 #endif
  4273             break;
  4273 	    break;
  4274 
  4274 
  4275         case WM_EXITSIZEMOVE:
  4275 	case WM_EXITSIZEMOVE:
  4276             EVENT_PRINTF(("WM_EXITSIZEMOVE\n"));
  4276 	    EVENT_PRINTF(("WM_EXITSIZEMOVE\n"));
  4277 
  4277 
  4278 #ifndef PRE_13_APR_04_POSCHANGED_IN_EXITSIZEMOVE
  4278 #ifndef PRE_13_APR_04_POSCHANGED_IN_EXITSIZEMOVE
  4279             if (inMove) {
  4279 	    if (inMove) {
  4280                 /* generate WM_WINDOWPOSCHANGED
  4280 		/* generate WM_WINDOWPOSCHANGED
  4281                 */
  4281 		*/
  4282                 RECT rct;
  4282 		RECT rct;
  4283                 int x, y, w, h;
  4283 		int x, y, w, h;
  4284 
  4284 
  4285                 GetClientRect(hWnd, &rct);
  4285 		GetClientRect(hWnd, &rct);
  4286 
  4286 
  4287                 x = rct.left;
  4287 		x = rct.left;
  4288                 y = rct.top;
  4288 		y = rct.top;
  4289                 w = rct.right - rct.left;
  4289 		w = rct.right - rct.left;
  4290                 h = rct.bottom - rct.top;
  4290 		h = rct.bottom - rct.top;
  4291 
  4291 
  4292                 if ((w == 0) && (h == 0)) {
  4292 		if ((w == 0) && (h == 0)) {
  4293                     if (! GetWindow_iconified(hWnd)) {
  4293 		    if (! GetWindow_iconified(hWnd)) {
  4294                         SetWindow_iconified(hWnd, 1);
  4294 			SetWindow_iconified(hWnd, 1);
  4295                     }
  4295 		    }
  4296                     enqEvent(0, hWnd, __WM_ICONIFIED, 1, 0, 0, 0, 0, EV_NOTIME);
  4296 		    enqEvent(0, hWnd, __WM_ICONIFIED, 1, 0, 0, 0, 0, EV_NOTIME);
  4297                 } else {
  4297 		} else {
  4298                     if (GetWindow_iconified(hWnd)) {
  4298 		    if (GetWindow_iconified(hWnd)) {
  4299                         SetWindow_iconified(hWnd, 0);
  4299 			SetWindow_iconified(hWnd, 0);
  4300                         enqEvent(0, hWnd, __WM_ICONIFIED, 0, 0, 0, 0, 0, EV_NOTIME);
  4300 			enqEvent(0, hWnd, __WM_ICONIFIED, 0, 0, 0, 0, 0, EV_NOTIME);
  4301                     } else {
  4301 		    } else {
  4302                         enqEvent(0, hWnd, WM_WINDOWPOSCHANGED, 0, x, y, w, h, EV_NOTIME);
  4302 			enqEvent(0, hWnd, WM_WINDOWPOSCHANGED, 0, x, y, w, h, EV_NOTIME);
  4303                     }
  4303 		    }
  4304                 }
  4304 		}
  4305             }
  4305 	    }
  4306 #endif
  4306 #endif
  4307 
  4307 
  4308             inSizeMove = inMove = inSize = 0;
  4308 	    inSizeMove = inMove = inSize = 0;
  4309 
  4309 
  4310             if (needDelayedMouseLeaveWindow || needDelayedMouseEnterWindow) {
  4310 	    if (needDelayedMouseLeaveWindow || needDelayedMouseEnterWindow) {
  4311                 int modifiers = getModifiers();
  4311 		int modifiers = getModifiers();
  4312 
  4312 
  4313                 if (needDelayedMouseLeaveWindow) {
  4313 		if (needDelayedMouseLeaveWindow) {
  4314                     if (GetWindow_eventMask(needDelayedMouseLeaveWindow) & LeaveWindowMask) {
  4314 		    if (GetWindow_eventMask(needDelayedMouseLeaveWindow) & LeaveWindowMask) {
  4315                         enqEvent(LeaveWindowMask, needDelayedMouseLeaveWindow, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
  4315 			enqEvent(LeaveWindowMask, needDelayedMouseLeaveWindow, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
  4316                         SetWindow_mouseXY(needDelayedMouseLeaveWindow, -9999, -9999);
  4316 			SetWindow_mouseXY(needDelayedMouseLeaveWindow, -9999, -9999);
  4317                     }
  4317 		    }
  4318                     needDelayedMouseLeaveWindow = NULL;
  4318 		    needDelayedMouseLeaveWindow = NULL;
  4319                 }
  4319 		}
  4320                 if (needDelayedMouseEnterWindow) {
  4320 		if (needDelayedMouseEnterWindow) {
  4321                     if (GetWindow_eventMask(needDelayedMouseEnterWindow) & EnterWindowMask) {
  4321 		    if (GetWindow_eventMask(needDelayedMouseEnterWindow) & EnterWindowMask) {
  4322                         enqEvent(EnterWindowMask, needDelayedMouseEnterWindow, __WM_MOUSEENTER, 0, delayedMouseEnterX, delayedMouseEnterY, 0, modifiers, EV_NOTIME);
  4322 			enqEvent(EnterWindowMask, needDelayedMouseEnterWindow, __WM_MOUSEENTER, 0, delayedMouseEnterX, delayedMouseEnterY, 0, modifiers, EV_NOTIME);
  4323                         SetWindow_mouseXY(needDelayedMouseEnterWindow, delayedMouseEnterX, delayedMouseEnterY);
  4323 			SetWindow_mouseXY(needDelayedMouseEnterWindow, delayedMouseEnterX, delayedMouseEnterY);
  4324                     }
  4324 		    }
  4325                     needDelayedMouseEnterWindow = NULL;
  4325 		    needDelayedMouseEnterWindow = NULL;
  4326                 }
  4326 		}
  4327             }
  4327 	    }
  4328 
  4328 
  4329             break;
  4329 	    break;
  4330 
  4330 
  4331         case WM_MOVE:
  4331 	case WM_MOVE:
  4332             EVENT_PRINTF(("WM_MOVE\n"));
  4332 	    EVENT_PRINTF(("WM_MOVE\n"));
  4333             break;
  4333 	    break;
  4334 
  4334 
  4335         case WM_POWER:
  4335 	case WM_POWER:
  4336             EVENT_PRINTF(("WM_POWER\n"));
  4336 	    EVENT_PRINTF(("WM_POWER\n"));
  4337             enqEvent(0, hWnd, WM_POWER, wParam, 0, 0, 0, 0, EV_NOTIME);
  4337 	    enqEvent(0, hWnd, WM_POWER, wParam, 0, 0, 0, 0, EV_NOTIME);
  4338             break;
  4338 	    break;
  4339 
  4339 
  4340         /* native widget actions */
  4340 	/* native widget actions */
  4341         case WM_COMMAND:
  4341 	case WM_COMMAND:
  4342             if (lParam) {
  4342 	    if (lParam) {
  4343                 NDPRINTF(("COMMAND for widget\n"));
  4343 		NDPRINTF(("COMMAND for widget\n"));
  4344                 enqEvent(0, (HWND)(lParam), WM_COMMAND, wParam, lParam, 0, 0, 0, EV_NOTIME);
  4344 		enqEvent(0, (HWND)(lParam), WM_COMMAND, wParam, lParam, 0, 0, 0, EV_NOTIME);
  4345             } else {
  4345 	    } else {
  4346                 NDPRINTF(("COMMAND for owner\n"));
  4346 		NDPRINTF(("COMMAND for owner\n"));
  4347                 enqEvent(0, hWnd, WM_COMMAND, wParam, lParam, 0, 0, 0, EV_NOTIME);
  4347 		enqEvent(0, hWnd, WM_COMMAND, wParam, lParam, 0, 0, 0, EV_NOTIME);
  4348             }
  4348 	    }
  4349             break;
  4349 	    break;
  4350 
  4350 
  4351         /* tray action */
  4351 	/* tray action */
  4352         case WM_TRAY_MESSAGE:
  4352 	case WM_TRAY_MESSAGE:
  4353             DPRINTF(("tray message hWnd=0x%x lP=0x%x wP=0x%x\n", hWnd, lParam, wParam));
  4353 	    DPRINTF(("tray message hWnd=0x%x lP=0x%x wP=0x%x\n", hWnd, lParam, wParam));
  4354             enqEvent(0, hWnd, WM_TRAY_MESSAGE, wParam, lParam, 0, 0, 0, EV_NOTIME);
  4354 	    enqEvent(0, hWnd, WM_TRAY_MESSAGE, wParam, lParam, 0, 0, 0, EV_NOTIME);
  4355             break;
  4355 	    break;
  4356 
  4356 
  4357         case WM_COPYDATA:
  4357 	case WM_COPYDATA:
  4358             DPRINTFIF(__debug_WM_COPYDATA__ , ("WM_COPYDATA\n"));
  4358 	    DPRINTFIF(__debug_WM_COPYDATA__ , ("WM_COPYDATA\n"));
  4359             {
  4359 	    {
  4360                 PCOPYDATASTRUCT pCDs = (PCOPYDATASTRUCT) lParam;
  4360 		PCOPYDATASTRUCT pCDs = (PCOPYDATASTRUCT) lParam;
  4361                 int dwData = pCDs->dwData;
  4361 		int dwData = pCDs->dwData;
  4362                 int nBytes = pCDs->cbData;
  4362 		int nBytes = pCDs->cbData;
  4363                 void *pData = pCDs->lpData;
  4363 		void *pData = pCDs->lpData;
  4364                 void *pCopiedData;
  4364 		void *pCopiedData;
  4365 
  4365 
  4366                 DPRINTFIF(__debug_WM_COPYDATA__ , ("WM_COPYDATA %d %lx\n", nBytes, pData));
  4366 		DPRINTFIF(__debug_WM_COPYDATA__ , ("WM_COPYDATA %d %lx\n", nBytes, pData));
  4367 
  4367 
  4368                 /*
  4368 		/*
  4369                  * because pData is only valid here, copy it out to a malloc'd
  4369 		 * because pData is only valid here, copy it out to a malloc'd
  4370                  * area. This MUST be free'd by someone else !
  4370 		 * area. This MUST be free'd by someone else !
  4371                  */
  4371 		 */
  4372                 if (nBytes) {
  4372 		if (nBytes) {
  4373                     pCopiedData = malloc(nBytes);
  4373 		    pCopiedData = malloc(nBytes);
  4374                     memcpy(pCopiedData, pData, nBytes);
  4374 		    memcpy(pCopiedData, pData, nBytes);
  4375                 } else {
  4375 		} else {
  4376                     pCopiedData = NULL;
  4376 		    pCopiedData = NULL;
  4377                 }
  4377 		}
  4378                 //     (flag, hWnd, message, wParam, arg1, arg2, arg3, arg4, evTime)
  4378 		//     (flag, hWnd, message, wParam, arg1, arg2, arg3, arg4, evTime)
  4379                 enqEvent(0, hWnd, WM_COPYDATA, wParam, (INT)pCopiedData, nBytes, dwData, 0, EV_NOTIME);
  4379 		enqEvent(0, hWnd, WM_COPYDATA, wParam, (INT)pCopiedData, nBytes, dwData, 0, EV_NOTIME);
  4380             }
  4380 	    }
  4381             *pDefault = 0;
  4381 	    *pDefault = 0;
  4382             break;
  4382 	    break;
  4383 
  4383 
  4384         case WM_HSCROLL:
  4384 	case WM_HSCROLL:
  4385         case WM_VSCROLL:
  4385 	case WM_VSCROLL:
  4386             NDPRINTF(("VM_*SCROLL\n"));
  4386 	    NDPRINTF(("VM_*SCROLL\n"));
  4387             enqEvent(0, hWnd, message, wParam, lParam, 0, 0, 0, EV_NOTIME);
  4387 	    enqEvent(0, hWnd, message, wParam, lParam, 0, 0, 0, EV_NOTIME);
  4388             break;
  4388 	    break;
  4389 
  4389 
  4390         case WM_DRAWITEM:
  4390 	case WM_DRAWITEM:
  4391             EVENT_PRINTF(("WM_DRAWITEM\n"));
  4391 	    EVENT_PRINTF(("WM_DRAWITEM\n"));
  4392 #if 0
  4392 #if 0
  4393             {
  4393 	    {
  4394                 DRAWITEMSTRUCT *pItemStruct;
  4394 		DRAWITEMSTRUCT *pItemStruct;
  4395 
  4395 
  4396                 pItemStruct = (DRAWITEMSTRUCT *)lParam;
  4396 		pItemStruct = (DRAWITEMSTRUCT *)lParam;
  4397                 enqEvent(0, pItemStruct->hwndItem, WM_DRAWITEM, wParam, 0, 0, 0, 0, EV_NOTIME);
  4397 		enqEvent(0, pItemStruct->hwndItem, WM_DRAWITEM, wParam, 0, 0, 0, 0, EV_NOTIME);
  4398             }
  4398 	    }
  4399 #endif
  4399 #endif
  4400             break;
  4400 	    break;
  4401 
  4401 
  4402 #ifdef TRACE_ALL_EVENTS
  4402 #ifdef TRACE_ALL_EVENTS
  4403         case WM_CTLCOLORMSGBOX:
  4403 	case WM_CTLCOLORMSGBOX:
  4404             UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORMSGBOX\n"));
  4404 	    UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORMSGBOX\n"));
  4405             break;
  4405 	    break;
  4406         case WM_CTLCOLOREDIT:
  4406 	case WM_CTLCOLOREDIT:
  4407             UNHANDLED_EVENT_PRINTF(("WM_CTLCOLOREDIT\n"));
  4407 	    UNHANDLED_EVENT_PRINTF(("WM_CTLCOLOREDIT\n"));
  4408             break;
  4408 	    break;
  4409         case WM_CTLCOLORLISTBOX:
  4409 	case WM_CTLCOLORLISTBOX:
  4410             UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORLISTBOX\n"));
  4410 	    UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORLISTBOX\n"));
  4411             break;
  4411 	    break;
  4412         case WM_CTLCOLORBTN:
  4412 	case WM_CTLCOLORBTN:
  4413             UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORBTN\n"));
  4413 	    UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORBTN\n"));
  4414             break;
  4414 	    break;
  4415         case WM_CTLCOLORDLG:
  4415 	case WM_CTLCOLORDLG:
  4416             UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORDLG\n"));
  4416 	    UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORDLG\n"));
  4417             break;
  4417 	    break;
  4418         case WM_CTLCOLORSTATIC:
  4418 	case WM_CTLCOLORSTATIC:
  4419             UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORSTATIC\n"));
  4419 	    UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORSTATIC\n"));
  4420             break;
  4420 	    break;
  4421         case WM_CTLCOLORSCROLLBAR:
  4421 	case WM_CTLCOLORSCROLLBAR:
  4422             UNHANDLED_EVENT_PRINTFIF(__debug_WM_CTLCOLORSCROLLBAR__, ("WM_CTLCOLORSCROLLBAR\n"));
  4422 	    UNHANDLED_EVENT_PRINTFIF(__debug_WM_CTLCOLORSCROLLBAR__, ("WM_CTLCOLORSCROLLBAR\n"));
  4423             break;
  4423 	    break;
  4424 
  4424 
  4425         case WM_STYLECHANGING:
  4425 	case WM_STYLECHANGING:
  4426             UNHANDLED_EVENT_PRINTF(("WM_STYLECHANGING\n"));
  4426 	    UNHANDLED_EVENT_PRINTF(("WM_STYLECHANGING\n"));
  4427             break;
  4427 	    break;
  4428         case WM_STYLECHANGED:
  4428 	case WM_STYLECHANGED:
  4429             UNHANDLED_EVENT_PRINTF(("WM_STYLECHANGED\n"));
  4429 	    UNHANDLED_EVENT_PRINTF(("WM_STYLECHANGED\n"));
  4430             break;
  4430 	    break;
  4431 
  4431 
  4432         case WM_GETICON:
  4432 	case WM_GETICON:
  4433             UNHANDLED_EVENT_PRINTFIF(__debug_WM_GETICON__, ("WM_GETICON\n"));
  4433 	    UNHANDLED_EVENT_PRINTFIF(__debug_WM_GETICON__, ("WM_GETICON\n"));
  4434             break;
  4434 	    break;
  4435         case WM_SETICON:
  4435 	case WM_SETICON:
  4436             UNHANDLED_EVENT_PRINTF(("WM_SETICON\n"));
  4436 	    UNHANDLED_EVENT_PRINTF(("WM_SETICON\n"));
  4437             break;
  4437 	    break;
  4438 
  4438 
  4439         case WM_PRINT:
  4439 	case WM_PRINT:
  4440             UNHANDLED_EVENT_PRINTF(("WM_PRINT(lParam=%d)\n", lParam));
  4440 	    UNHANDLED_EVENT_PRINTF(("WM_PRINT(lParam=%d)\n", lParam));
  4441             break;
  4441 	    break;
  4442         case WM_PRINTCLIENT:
  4442 	case WM_PRINTCLIENT:
  4443             UNHANDLED_EVENT_PRINTF(("WM_PRINTCLIENT(lParam=%d)\n", lParam));
  4443 	    UNHANDLED_EVENT_PRINTF(("WM_PRINTCLIENT(lParam=%d)\n", lParam));
  4444             break;
  4444 	    break;
  4445 
  4445 
  4446         case WM_NULL:
  4446 	case WM_NULL:
  4447             UNHANDLED_EVENT_PRINTF(("WM_NULL\n"));
  4447 	    UNHANDLED_EVENT_PRINTF(("WM_NULL\n"));
  4448             break;
  4448 	    break;
  4449 
  4449 
  4450         case WM_ENABLE:
  4450 	case WM_ENABLE:
  4451             UNHANDLED_EVENT_PRINTF(("WM_ENABLE\n"));
  4451 	    UNHANDLED_EVENT_PRINTF(("WM_ENABLE\n"));
  4452             break;
  4452 	    break;
  4453 
  4453 
  4454         case WM_SETREDRAW:
  4454 	case WM_SETREDRAW:
  4455             UNHANDLED_EVENT_PRINTF(("WM_SETREDRAW\n"));
  4455 	    UNHANDLED_EVENT_PRINTF(("WM_SETREDRAW\n"));
  4456             break;
  4456 	    break;
  4457 
  4457 
  4458         case WM_DEVMODECHANGE:
  4458 	case WM_DEVMODECHANGE:
  4459             UNHANDLED_EVENT_PRINTF(("WM_DEVMODECHANGE\n"));
  4459 	    UNHANDLED_EVENT_PRINTF(("WM_DEVMODECHANGE\n"));
  4460             break;
  4460 	    break;
  4461 
  4461 
  4462         case WM_TIMECHANGE:
  4462 	case WM_TIMECHANGE:
  4463             UNHANDLED_EVENT_PRINTF(("WM_TIMECHANGE\n"));
  4463 	    UNHANDLED_EVENT_PRINTF(("WM_TIMECHANGE\n"));
  4464             break;
  4464 	    break;
  4465 
  4465 
  4466         case WM_CANCELMODE:
  4466 	case WM_CANCELMODE:
  4467             UNHANDLED_EVENT_PRINTF(("WM_CANCELMODE\n"));
  4467 	    UNHANDLED_EVENT_PRINTF(("WM_CANCELMODE\n"));
  4468             break;
  4468 	    break;
  4469 
  4469 
  4470         case WM_CHILDACTIVATE:
  4470 	case WM_CHILDACTIVATE:
  4471             UNHANDLED_EVENT_PRINTF(("WM_CHILDACTIVATE\n"));
  4471 	    UNHANDLED_EVENT_PRINTF(("WM_CHILDACTIVATE\n"));
  4472             break;
  4472 	    break;
  4473 
  4473 
  4474         case WM_QUEUESYNC:
  4474 	case WM_QUEUESYNC:
  4475             UNHANDLED_EVENT_PRINTF(("WM_QUEUESYNC\n"));
  4475 	    UNHANDLED_EVENT_PRINTF(("WM_QUEUESYNC\n"));
  4476             break;
  4476 	    break;
  4477 
  4477 
  4478         case WM_NEXTDLGCTL:
  4478 	case WM_NEXTDLGCTL:
  4479             UNHANDLED_EVENT_PRINTF(("WM_NEXTDLGCTL\n"));
  4479 	    UNHANDLED_EVENT_PRINTF(("WM_NEXTDLGCTL\n"));
  4480             break;
  4480 	    break;
  4481 
  4481 
  4482         case WM_SPOOLERSTATUS:
  4482 	case WM_SPOOLERSTATUS:
  4483             UNHANDLED_EVENT_PRINTF(("WM_SPOOLERSTATUS\n"));
  4483 	    UNHANDLED_EVENT_PRINTF(("WM_SPOOLERSTATUS\n"));
  4484             break;
  4484 	    break;
  4485 
  4485 
  4486         case WM_MEASUREITEM:
  4486 	case WM_MEASUREITEM:
  4487             UNHANDLED_EVENT_PRINTF(("WM_MEASUREITEM\n"));
  4487 	    UNHANDLED_EVENT_PRINTF(("WM_MEASUREITEM\n"));
  4488             break;
  4488 	    break;
  4489 
  4489 
  4490         case WM_DELETEITEM:
  4490 	case WM_DELETEITEM:
  4491             UNHANDLED_EVENT_PRINTF(("WM_DELETEITEM\n"));
  4491 	    UNHANDLED_EVENT_PRINTF(("WM_DELETEITEM\n"));
  4492             break;
  4492 	    break;
  4493 
  4493 
  4494         case WM_VKEYTOITEM:
  4494 	case WM_VKEYTOITEM:
  4495             UNHANDLED_EVENT_PRINTF(("WM_VKEYTOITEM\n"));
  4495 	    UNHANDLED_EVENT_PRINTF(("WM_VKEYTOITEM\n"));
  4496             break;
  4496 	    break;
  4497 
  4497 
  4498         case WM_CHARTOITEM:
  4498 	case WM_CHARTOITEM:
  4499             UNHANDLED_EVENT_PRINTF(("WM_CHARTOITEM\n"));
  4499 	    UNHANDLED_EVENT_PRINTF(("WM_CHARTOITEM\n"));
  4500             break;
  4500 	    break;
  4501 
  4501 
  4502         case WM_SETFONT:
  4502 	case WM_SETFONT:
  4503             UNHANDLED_EVENT_PRINTF(("WM_SETFONT\n"));
  4503 	    UNHANDLED_EVENT_PRINTF(("WM_SETFONT\n"));
  4504             break;
  4504 	    break;
  4505 
  4505 
  4506         case WM_GETFONT:
  4506 	case WM_GETFONT:
  4507             UNHANDLED_EVENT_PRINTF(("WM_GETFONT\n"));
  4507 	    UNHANDLED_EVENT_PRINTF(("WM_GETFONT\n"));
  4508             break;
  4508 	    break;
  4509 
  4509 
  4510         case WM_SETHOTKEY:
  4510 	case WM_SETHOTKEY:
  4511             UNHANDLED_EVENT_PRINTF(("WM_SETHOTKEY\n"));
  4511 	    UNHANDLED_EVENT_PRINTF(("WM_SETHOTKEY\n"));
  4512             break;
  4512 	    break;
  4513 
  4513 
  4514         case WM_GETHOTKEY:
  4514 	case WM_GETHOTKEY:
  4515             UNHANDLED_EVENT_PRINTF(("WM_GETHOTKEY\n"));
  4515 	    UNHANDLED_EVENT_PRINTF(("WM_GETHOTKEY\n"));
  4516             break;
  4516 	    break;
  4517 
  4517 
  4518         case WM_QUERYDRAGICON:
  4518 	case WM_QUERYDRAGICON:
  4519             UNHANDLED_EVENT_PRINTF(("WM_QUERYDRAGICON\n"));
  4519 	    UNHANDLED_EVENT_PRINTF(("WM_QUERYDRAGICON\n"));
  4520             break;
  4520 	    break;
  4521 
  4521 
  4522         case WM_COMPAREITEM:
  4522 	case WM_COMPAREITEM:
  4523             UNHANDLED_EVENT_PRINTF(("WM_COMPAREITEM\n"));
  4523 	    UNHANDLED_EVENT_PRINTF(("WM_COMPAREITEM\n"));
  4524             break;
  4524 	    break;
  4525 
  4525 
  4526         case WM_GETOBJECT:
  4526 	case WM_GETOBJECT:
  4527             UNHANDLED_EVENT_PRINTF(("WM_GETOBJECT\n"));
  4527 	    UNHANDLED_EVENT_PRINTF(("WM_GETOBJECT\n"));
  4528             break;
  4528 	    break;
  4529 
  4529 
  4530         case WM_COMPACTING:
  4530 	case WM_COMPACTING:
  4531             UNHANDLED_EVENT_PRINTF(("WM_COMPACTING\n"));
  4531 	    UNHANDLED_EVENT_PRINTF(("WM_COMPACTING\n"));
  4532             break;
  4532 	    break;
  4533 
  4533 
  4534         case WM_COMMNOTIFY:
  4534 	case WM_COMMNOTIFY:
  4535             UNHANDLED_EVENT_PRINTF(("WM_COMMNOTIFY\n"));
  4535 	    UNHANDLED_EVENT_PRINTF(("WM_COMMNOTIFY\n"));
  4536             break;
  4536 	    break;
  4537 
  4537 
  4538         case WM_CANCELJOURNAL:
  4538 	case WM_CANCELJOURNAL:
  4539             UNHANDLED_EVENT_PRINTF(("WM_CANCELJOURNAL\n"));
  4539 	    UNHANDLED_EVENT_PRINTF(("WM_CANCELJOURNAL\n"));
  4540             break;
  4540 	    break;
  4541 
  4541 
  4542         case WM_INPUTLANGCHANGEREQUEST:
  4542 	case WM_INPUTLANGCHANGEREQUEST:
  4543             UNHANDLED_EVENT_PRINTF(("WM_INPUTLANGCHANGEREQUEST\n"));
  4543 	    UNHANDLED_EVENT_PRINTF(("WM_INPUTLANGCHANGEREQUEST\n"));
  4544             break;
  4544 	    break;
  4545 
  4545 
  4546         case WM_INPUTLANGCHANGE:
  4546 	case WM_INPUTLANGCHANGE:
  4547             UNHANDLED_EVENT_PRINTF(("WM_INPUTLANGCHANGE\n"));
  4547 	    UNHANDLED_EVENT_PRINTF(("WM_INPUTLANGCHANGE\n"));
  4548             break;
  4548 	    break;
  4549 
  4549 
  4550         case WM_TCARD:
  4550 	case WM_TCARD:
  4551             UNHANDLED_EVENT_PRINTF(("WM_TCARD\n"));
  4551 	    UNHANDLED_EVENT_PRINTF(("WM_TCARD\n"));
  4552             break;
  4552 	    break;
  4553 
  4553 
  4554         case WM_HELP:
  4554 	case WM_HELP:
  4555             UNHANDLED_EVENT_PRINTF(("WM_HELP\n"));
  4555 	    UNHANDLED_EVENT_PRINTF(("WM_HELP\n"));
  4556             break;
  4556 	    break;
  4557 
  4557 
  4558         case WM_USERCHANGED:
  4558 	case WM_USERCHANGED:
  4559             UNHANDLED_EVENT_PRINTF(("WM_USERCHANGED\n"));
  4559 	    UNHANDLED_EVENT_PRINTF(("WM_USERCHANGED\n"));
  4560             break;
  4560 	    break;
  4561 
  4561 
  4562         case WM_NOTIFY:
  4562 	case WM_NOTIFY:
  4563             UNHANDLED_EVENT_PRINTF(("WM_NOTIFY\n"));
  4563 	    UNHANDLED_EVENT_PRINTF(("WM_NOTIFY\n"));
  4564             break;
  4564 	    break;
  4565 
  4565 
  4566         case WM_NOTIFYFORMAT:
  4566 	case WM_NOTIFYFORMAT:
  4567             UNHANDLED_EVENT_PRINTF(("WM_NOTIFYFORMAT\n"));
  4567 	    UNHANDLED_EVENT_PRINTF(("WM_NOTIFYFORMAT\n"));
  4568             break;
  4568 	    break;
  4569 
  4569 
  4570         case WM_CONTEXTMENU:
  4570 	case WM_CONTEXTMENU:
  4571             UNHANDLED_EVENT_PRINTF(("WM_CONTEXTMENU\n"));
  4571 	    UNHANDLED_EVENT_PRINTF(("WM_CONTEXTMENU\n"));
  4572             break;
  4572 	    break;
  4573 
  4573 
  4574         case WM_NCXBUTTONDOWN:
  4574 	case WM_NCXBUTTONDOWN:
  4575             UNHANDLED_EVENT_PRINTF(("WM_NCXBUTTONDOWN\n"));
  4575 	    UNHANDLED_EVENT_PRINTF(("WM_NCXBUTTONDOWN\n"));
  4576             break;
  4576 	    break;
  4577 
  4577 
  4578         case WM_NCXBUTTONUP:
  4578 	case WM_NCXBUTTONUP:
  4579             UNHANDLED_EVENT_PRINTF(("WM_NCXBUTTONUP\n"));
  4579 	    UNHANDLED_EVENT_PRINTF(("WM_NCXBUTTONUP\n"));
  4580             break;
  4580 	    break;
  4581 
  4581 
  4582         case WM_NCXBUTTONDBLCLK:
  4582 	case WM_NCXBUTTONDBLCLK:
  4583             UNHANDLED_EVENT_PRINTF(("WM_NCXBUTTONDBLCLK\n"));
  4583 	    UNHANDLED_EVENT_PRINTF(("WM_NCXBUTTONDBLCLK\n"));
  4584             break;
  4584 	    break;
  4585 
  4585 
  4586         case WM_DEVICECHANGE:
  4586 	case WM_DEVICECHANGE:
  4587             UNHANDLED_EVENT_PRINTF(("WM_DEVICECHANGE\n"));
  4587 	    UNHANDLED_EVENT_PRINTF(("WM_DEVICECHANGE\n"));
  4588             break;
  4588 	    break;
  4589 
  4589 
  4590         case DBT_DEVICEARRIVAL:
  4590 	case DBT_DEVICEARRIVAL:
  4591             UNHANDLED_EVENT_PRINTF(("DBT_DEVICEARRIVAL\n"));
  4591 	    UNHANDLED_EVENT_PRINTF(("DBT_DEVICEARRIVAL\n"));
  4592             break;
  4592 	    break;
  4593 
  4593 
  4594         case DBT_DEVICEREMOVECOMPLETE:
  4594 	case DBT_DEVICEREMOVECOMPLETE:
  4595             UNHANDLED_EVENT_PRINTF(("DBT_DEVICEREMOVECOMPLETE\n"));
  4595 	    UNHANDLED_EVENT_PRINTF(("DBT_DEVICEREMOVECOMPLETE\n"));
  4596             break;
  4596 	    break;
  4597 #endif
  4597 #endif
  4598 
  4598 
  4599         default:
  4599 	default:
  4600             EVENT_PRINTF(( "WinWorkstat [info] unhandled msg = %d 0x%x [%d]\n", message, message, __LINE__));
  4600 	    EVENT_PRINTF(( "WinWorkstat [info] unhandled msg = %d 0x%x [%d]\n", message, message, __LINE__));
  4601             break;
  4601 	    break;
  4602     }
  4602     }
  4603     return 0;
  4603     return 0;
  4604 }
  4604 }
  4605 
  4605 
  4606 
  4606 
  4619     TH_DPRINTF(("TS %d\n", th_calls++));
  4619     TH_DPRINTF(("TS %d\n", th_calls++));
  4620     PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE);   /* must be */
  4620     PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE);   /* must be */
  4621 
  4621 
  4622 #if 0
  4622 #if 0
  4623     if (AttachThreadInput(_masterThreadId, _dispatchThreadId2, TRUE) != TRUE) {
  4623     if (AttachThreadInput(_masterThreadId, _dispatchThreadId2, TRUE) != TRUE) {
  4624         console_fprintf(stderr, "WinWorkstation [warning]: AttachThreadInput failed\n");
  4624 	console_fprintf(stderr, "WinWorkstation [warning]: AttachThreadInput failed\n");
  4625     };
  4625     };
  4626 #endif
  4626 #endif
  4627 #ifndef WIN32THREADS
  4627 #ifndef WIN32THREADS
  4628 # if 0
  4628 # if 0
  4629     SetThreadPriority(_masterThread,THREAD_PRIORITY_HIGHEST);
  4629     SetThreadPriority(_masterThread,THREAD_PRIORITY_HIGHEST);
  4633 
  4633 
  4634     GetWindowRect(GetDesktopWindow(), &rect);
  4634     GetWindowRect(GetDesktopWindow(), &rect);
  4635     /* allocate localMemory for Window */
  4635     /* allocate localMemory for Window */
  4636     lI = (localWindowInfo *)malloc(sizeof(localWindowInfo));
  4636     lI = (localWindowInfo *)malloc(sizeof(localWindowInfo));
  4637     if (lI) {
  4637     if (lI) {
  4638         memset(lI, 0, sizeof(*lI));
  4638 	memset(lI, 0, sizeof(*lI));
  4639     }
  4639     }
  4640 
  4640 
  4641     __rootWinSpezial = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT,
  4641     __rootWinSpezial = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT,
  4642                                       wapp_nameRoot, wapp_nameRoot,
  4642 				      wapp_nameRoot, wapp_nameRoot,
  4643                                       WS_POPUP | WS_DISABLED,
  4643 				      WS_POPUP | WS_DISABLED,
  4644                                       0, 0,
  4644 				      0, 0,
  4645                                       rect.right - rect.left, rect.bottom - rect.top,
  4645 				      rect.right - rect.left, rect.bottom - rect.top,
  4646                                       0, 0, (HANDLE) __getHInstance(), lI);
  4646 				      0, 0, (HANDLE) __getHInstance(), lI);
  4647 
  4647 
  4648     //ShowWindow(__rootWinSpezial,SW_SHOWNOACTIVATE);
  4648     //ShowWindow(__rootWinSpezial,SW_SHOWNOACTIVATE);
  4649     SetWindowPos(__rootWinSpezial, HWND_BOTTOM, 0, 0, 0, 0,
  4649     SetWindowPos(__rootWinSpezial, HWND_BOTTOM, 0, 0, 0, 0,
  4650                  SWP_NOSENDCHANGING |
  4650 		 SWP_NOSENDCHANGING |
  4651                  SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  4651 		 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  4652 
  4652 
  4653 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
  4653 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
  4654     console_fprintf(stderr, "WinWorkstation [info]: setting ThreadRunningEvent\n");
  4654     console_fprintf(stderr, "WinWorkstation [info]: setting ThreadRunningEvent\n");
  4655 #endif
  4655 #endif
  4656     SetEvent(hDispatchThreadRunningEvent);
  4656     SetEvent(hDispatchThreadRunningEvent);
  4657 
  4657 
  4658     for (;;) {
  4658     for (;;) {
  4659         HANDLE dummy;
  4659 	HANDLE dummy;
  4660 
  4660 
  4661         TH_DPRINTF(("TG %d\n", th_calls++));
  4661 	TH_DPRINTF(("TG %d\n", th_calls++));
  4662 
  4662 
  4663         /*
  4663 	/*
  4664          * if there is no current capture (pointer-grab),
  4664 	 * if there is no current capture (pointer-grab),
  4665          * make certain that we do not get stuck in the GetMessage
  4665 	 * make certain that we do not get stuck in the GetMessage
  4666          * but instead poll the mouse in 200ms intervals.
  4666 	 * but instead poll the mouse in 200ms intervals.
  4667          * This is required to synthesize the MOUSELEAVE message,
  4667 	 * This is required to synthesize the MOUSELEAVE message,
  4668          */
  4668 	 */
  4669 // DPRINTF(("X1\n"));
  4669 // DPRINTF(("X1\n"));
  4670         if (__currentPointerView && (__currentCapture == CAPTURE_NONE)) {
  4670 	if (__currentPointerView && (__currentCapture == CAPTURE_NONE)) {
  4671 // DPRINTF(("X2\n"));
  4671 // DPRINTF(("X2\n"));
  4672             while (PeekMessageW(&msg, 0, 0, 0, PM_NOREMOVE) == 0) {
  4672 	    while (PeekMessageW(&msg, 0, 0, 0, PM_NOREMOVE) == 0) {
  4673 // DPRINTF(("PeekMessage -> 0\n"));
  4673 // DPRINTF(("PeekMessage -> 0\n"));
  4674                 /*
  4674 		/*
  4675                  * wait for an event; timeout after 200 millis
  4675 		 * wait for an event; timeout after 200 millis
  4676                  */
  4676 		 */
  4677                 if (MsgWaitForMultipleObjects(0,&dummy,FALSE,200,QS_ALLINPUT) == WAIT_TIMEOUT) {
  4677 		if (MsgWaitForMultipleObjects(0,&dummy,FALSE,200,QS_ALLINPUT) == WAIT_TIMEOUT) {
  4678                     if (! inSizeMove) {
  4678 		    if (! inSizeMove) {
  4679                         /*
  4679 			/*
  4680                          * timeout - see where mouse pointer is
  4680 			 * timeout - see where mouse pointer is
  4681                          * for synthetic leave events.
  4681 			 * for synthetic leave events.
  4682                          */
  4682 			 */
  4683                         POINT point;
  4683 			POINT point;
  4684 
  4684 
  4685                         if (GetCursorPos(&point)) {
  4685 			if (GetCursorPos(&point)) {
  4686                             HWND hWnd = WindowFromPoint(point);
  4686 			    HWND hWnd = WindowFromPoint(point);
  4687 
  4687 
  4688                             if (hWnd) {
  4688 			    if (hWnd) {
  4689                                 if (GetWindowThreadProcessId(hWnd,0) != GetCurrentThreadId()) {
  4689 				if (GetWindowThreadProcessId(hWnd,0) != GetCurrentThreadId()) {
  4690                                     if (inSizeMove) {
  4690 				    if (inSizeMove) {
  4691                                         if (needDelayedMouseLeaveWindow == NULL) {
  4691 					if (needDelayedMouseLeaveWindow == NULL) {
  4692                                             needDelayedMouseLeaveWindow = __currentPointerView;
  4692 					    needDelayedMouseLeaveWindow = __currentPointerView;
  4693                                         }
  4693 					}
  4694                                     } else {
  4694 				    } else {
  4695                                         if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  4695 					if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  4696                                             enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, getModifiers(), EV_NOTIME);
  4696 					    enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, getModifiers(), EV_NOTIME);
  4697                                             SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  4697 					    SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  4698                                         }
  4698 					}
  4699                                     }
  4699 				    }
  4700                                     __currentPointerView = 0;
  4700 				    __currentPointerView = 0;
  4701                                     break;
  4701 				    break;
  4702                                 }
  4702 				}
  4703                             }
  4703 			    }
  4704                         }
  4704 			}
  4705                     }
  4705 		    }
  4706                 }
  4706 		}
  4707             }
  4707 	    }
  4708         }
  4708 	}
  4709 
  4709 
  4710         GetMessageW(&msg, NULL, 0, 0);
  4710 	GetMessageW(&msg, NULL, 0, 0);
  4711 // DPRINTF(("GetMessage -> %d\n", msg.message));
  4711 // DPRINTF(("GetMessage -> %d\n", msg.message));
  4712         TH_DPRINTF(("TD %d\n", th_calls++));
  4712 	TH_DPRINTF(("TD %d\n", th_calls++));
  4713         destroyWin = 0;
  4713 	destroyWin = 0;
  4714 
  4714 
  4715         switch (msg.message) {
  4715 	switch (msg.message) {
  4716 #if 0
  4716 #if 0
  4717             case WM_THREAD_DESTROYWINDOW:
  4717 	    case WM_THREAD_DESTROYWINDOW:
  4718                 destroyWin = TRUE;
  4718 		destroyWin = TRUE;
  4719                 msg.message = WM_CLOSE;
  4719 		msg.message = WM_CLOSE;
  4720                 EVENT_PRINTF(("thread WM_THREAD_DESTROYWINDOW %x\n",msg.hwnd));
  4720 		EVENT_PRINTF(("thread WM_THREAD_DESTROYWINDOW %x\n",msg.hwnd));
  4721                 break;
  4721 		break;
  4722 #endif
  4722 #endif
  4723 
  4723 
  4724 #ifdef SET_FOCUS_IN_WINTHREAD
  4724 #ifdef SET_FOCUS_IN_WINTHREAD
  4725             case WM_THREAD_SETFOCUS:
  4725 	    case WM_THREAD_SETFOCUS:
  4726                 DPRINTFIF(__debug_WM_FOCUS__ , ("WM_THREAD_SETFOCUS h=%x\n", msg.wParam));
  4726 		DPRINTFIF(__debug_WM_FOCUS__ , ("WM_THREAD_SETFOCUS h=%x\n", msg.wParam));
  4727 # ifdef xxWIN32THREADS
  4727 # ifdef xxWIN32THREADS
  4728                 if (msg.lParam) {
  4728 		if (msg.lParam) {
  4729                     if (AttachThreadInput(_dispatchThreadId2,msg.lParam,TRUE) == FALSE)
  4729 		    if (AttachThreadInput(_dispatchThreadId2,msg.lParam,TRUE) == FALSE)
  4730                         PRINTF(("SetFocus AttachThreadInput error %d\n", GetLastError()));
  4730 			PRINTF(("SetFocus AttachThreadInput error %d\n", GetLastError()));
  4731                 }
  4731 		}
  4732 # endif
  4732 # endif
  4733                 EVENT_PRINTF(("threadSetfocus %x\n",msg.wParam));
  4733 		EVENT_PRINTF(("threadSetfocus %x\n",msg.wParam));
  4734                 if (SetFocus((HWND)msg.wParam) == 0) {
  4734 		if (SetFocus((HWND)msg.wParam) == 0) {
  4735                     DDPRINTF(("SetFocus to %x failed.\n",msg.wParam));
  4735 		    DDPRINTF(("SetFocus to %x failed.\n",msg.wParam));
  4736                 }
  4736 		}
  4737                 continue;
  4737 		continue;
  4738 #endif
  4738 #endif
  4739 
  4739 
  4740 #ifdef SET_CURSOR_IN_WINTHREAD
  4740 #ifdef SET_CURSOR_IN_WINTHREAD
  4741             case WM_THREAD_SETCURSOR:
  4741 	    case WM_THREAD_SETCURSOR:
  4742                 if (msg.lParam) {
  4742 		if (msg.lParam) {
  4743 #if 1
  4743 #if 1
  4744                     SetCursor((HCURSOR)msg.lParam);
  4744 		    SetCursor((HCURSOR)msg.lParam);
  4745 #else
  4745 #else
  4746                     /* this check is done by our sender */
  4746 		    /* this check is done by our sender */
  4747                     {
  4747 		    {
  4748                         POINT p;
  4748 			POINT p;
  4749                         GetCursorPos(&p);
  4749 			GetCursorPos(&p);
  4750                         if (WindowFromPoint(p) == msg.hwnd) {
  4750 			if (WindowFromPoint(p) == msg.hwnd) {
  4751                             EVENT_PRINTF(("threadSetCursor %x\n",msg.lParam));
  4751 			    EVENT_PRINTF(("threadSetCursor %x\n",msg.lParam));
  4752                             SetCursor((HCURSOR)msg.lParam);
  4752 			    SetCursor((HCURSOR)msg.lParam);
  4753                         }
  4753 			}
  4754                     }
  4754 		    }
  4755 #endif
  4755 #endif
  4756                 }
  4756 		}
  4757                 continue;
  4757 		continue;
  4758 #endif
  4758 #endif
  4759 
  4759 
  4760 #ifdef BEEP_IN_WINTHREAD
  4760 #ifdef BEEP_IN_WINTHREAD
  4761             case WM_THREAD_BEEP:
  4761 	    case WM_THREAD_BEEP:
  4762                 MessageBeep( MB_ICONEXCLAMATION);
  4762 		MessageBeep( MB_ICONEXCLAMATION);
  4763                 continue;
  4763 		continue;
  4764 #endif
  4764 #endif
  4765 
  4765 
  4766             case WM_THREAD_SETCAPTURE:
  4766 	    case WM_THREAD_SETCAPTURE:
  4767                 if (msg.wParam) {
  4767 		if (msg.wParam) {
  4768                     if (__currentPointerView) {
  4768 		    if (__currentPointerView) {
  4769                         if (inSizeMove) {
  4769 			if (inSizeMove) {
  4770                             if (needDelayedMouseLeaveWindow == NULL) {
  4770 			    if (needDelayedMouseLeaveWindow == NULL) {
  4771                                 needDelayedMouseLeaveWindow = __currentPointerView;
  4771 				needDelayedMouseLeaveWindow = __currentPointerView;
  4772                             }
  4772 			    }
  4773                         } else {
  4773 			} else {
  4774                             if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  4774 			    if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
  4775                                 enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, getModifiers(), EV_NOTIME);
  4775 				enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, getModifiers(), EV_NOTIME);
  4776                                 SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  4776 				SetWindow_mouseXY(__currentPointerView, -9999, -9999);
  4777                             }
  4777 			    }
  4778                         }
  4778 			}
  4779                     }
  4779 		    }
  4780 
  4780 
  4781                     __currentPointerView = (HWND)msg.wParam;
  4781 		    __currentPointerView = (HWND)msg.wParam;
  4782                     __currentCapture = CAPTURE_EXPLICIT;
  4782 		    __currentCapture = CAPTURE_EXPLICIT;
  4783                     EVENT_PRINTF(("threadSetCapture %x\n",msg.wParam));
  4783 		    EVENT_PRINTF(("threadSetCapture %x\n",msg.wParam));
  4784                     SetCapture(__currentPointerView);
  4784 		    SetCapture(__currentPointerView);
  4785                 } else {
  4785 		} else {
  4786                     if (__currentPointerView  == __rootWinSpezial) {
  4786 		    if (__currentPointerView  == __rootWinSpezial) {
  4787                         //ShowWindow(__rootWinSpezial, SW_HIDE);
  4787 			//ShowWindow(__rootWinSpezial, SW_HIDE);
  4788                         SetWindowPos(__rootWinSpezial, HWND_BOTTOM, 0, 0, 0, 0,
  4788 			SetWindowPos(__rootWinSpezial, HWND_BOTTOM, 0, 0, 0, 0,
  4789                                      SWP_NOREDRAW | SWP_NOSENDCHANGING | SWP_NOCOPYBITS
  4789 				     SWP_NOREDRAW | SWP_NOSENDCHANGING | SWP_NOCOPYBITS
  4790                                      | SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE
  4790 				     | SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE
  4791                                    /*| SWP_NOZORDER | SWP_NOOWNERZORDER */);
  4791 				   /*| SWP_NOZORDER | SWP_NOOWNERZORDER */);
  4792                     }
  4792 		    }
  4793                     __currentPointerView = 0;
  4793 		    __currentPointerView = 0;
  4794                     __currentCapture = CAPTURE_NONE;
  4794 		    __currentCapture = CAPTURE_NONE;
  4795                     EVENT_PRINTF(("threadReleaseCapture\n"));
  4795 		    EVENT_PRINTF(("threadReleaseCapture\n"));
  4796                     ReleaseCapture();
  4796 		    ReleaseCapture();
  4797                 }
  4797 		}
  4798                 if (msg.lParam) {
  4798 		if (msg.lParam) {
  4799                     DDDDPRINTF(("threadSetCursor %x\n",msg.lParam));
  4799 		    DDDDPRINTF(("threadSetCursor %x\n",msg.lParam));
  4800                     SetCursor((HCURSOR)msg.lParam);
  4800 		    SetCursor((HCURSOR)msg.lParam);
  4801                 }
  4801 		}
  4802                 continue;
  4802 		continue;
  4803 
  4803 
  4804             case WM_THREAD_CREATEWINDOW:
  4804 	    case WM_THREAD_CREATEWINDOW:
  4805                 EVENT_PRINTF(("*WM_THREAD_CREATEWINDOW %d\n", th_calls));
  4805 		EVENT_PRINTF(("*WM_THREAD_CREATEWINDOW %d\n", th_calls));
  4806 
  4806 
  4807                 {
  4807 		{
  4808                     createWindowInfo *cwi = (createWindowInfo *)(msg.lParam);
  4808 		    createWindowInfo *cwi = (createWindowInfo *)(msg.lParam);
  4809 
  4809 
  4810                     if ((cwi->sequenceNr == msg.wParam)
  4810 		    if ((cwi->sequenceNr == msg.wParam)
  4811                      && (cwi->sequenceNr != INVALIDATED_CWI)) {
  4811 		     && (cwi->sequenceNr != INVALIDATED_CWI)) {
  4812                         cwi->sequenceNr = INVALIDATED_CWI;
  4812 			cwi->sequenceNr = INVALIDATED_CWI;
  4813                         cwi->infoWasRead = 1;
  4813 			cwi->infoWasRead = 1;
  4814                         if (cwi->newWinHandle == NULL) {
  4814 			if (cwi->newWinHandle == NULL) {
  4815                             HANDLE ev;
  4815 			    HANDLE ev;
  4816 
  4816 
  4817                             cwi->newWinHandle = CreateWindowExW(
  4817 			    cwi->newWinHandle = CreateWindowExW(
  4818                                                 cwi->winStyleBitsEx,
  4818 						cwi->winStyleBitsEx,
  4819                                                 cwi->className,
  4819 						cwi->className,
  4820                                                 cwi->windowName,
  4820 						cwi->windowName,
  4821                                                 cwi->winStyleBits,
  4821 						cwi->winStyleBits,
  4822                                                 cwi->x, cwi->y,
  4822 						cwi->x, cwi->y,
  4823                                                 cwi->dx, cwi->dy,
  4823 						cwi->dx, cwi->dy,
  4824                                                 cwi->parentHandle,
  4824 						cwi->parentHandle,
  4825                                                 NULL,           /* menu */
  4825 						NULL,           /* menu */
  4826                                                 (HANDLE) __getHInstance(),
  4826 						(HANDLE) __getHInstance(),
  4827                                                 cwi->localWindowInfo
  4827 						cwi->localWindowInfo
  4828                                                );
  4828 					       );
  4829 
  4829 
  4830                             if (cwi->newWinHandle == NULL) {
  4830 			    if (cwi->newWinHandle == NULL) {
  4831                                 cwi->errCode = GetLastError();
  4831 				cwi->errCode = GetLastError();
  4832                                 console_fprintf(stderr, "WinWorkstation [info]: CreateWindow %s failed: %d (0x%x) [%d]\n",
  4832 				console_fprintf(stderr, "WinWorkstation [info]: CreateWindow %s failed: %d (0x%x) [%d]\n",
  4833                                                 cwi->className, cwi->errCode, cwi->errCode, __LINE__);
  4833 						cwi->className, cwi->errCode, cwi->errCode, __LINE__);
  4834                             } else {
  4834 			    } else {
  4835                                 SETLOCALWINDOWINFOPTR(cwi->newWinHandle, cwi->localWindowInfo);
  4835 				SETLOCALWINDOWINFOPTR(cwi->newWinHandle, cwi->localWindowInfo);
  4836 #ifdef DEBUG /* PARANOIA */
  4836 #ifdef DEBUG /* PARANOIA */
  4837                                 if (GETLOCALWINDOWINFOPTR(cwi->newWinHandle) != cwi->localWindowInfo) {
  4837 				if (GETLOCALWINDOWINFOPTR(cwi->newWinHandle) != cwi->localWindowInfo) {
  4838                                    console_fprintf(stderr, "lI-Error\n");
  4838 				   console_fprintf(stderr, "lI-Error\n");
  4839                                 }
  4839 				}
  4840 #endif
  4840 #endif
  4841                             }
  4841 			    }
  4842 
  4842 
  4843                             ev = cwi->hCreateEvent;
  4843 			    ev = cwi->hCreateEvent;
  4844                             if (ev) {
  4844 			    if (ev) {
  4845                                 SetEvent(ev);
  4845 				SetEvent(ev);
  4846                             }
  4846 			    }
  4847                         }
  4847 			}
  4848                     } else {
  4848 		    } else {
  4849                         DPRINTF(("obsolete createWindow message %x ignored\n", cwi->sequenceNr));
  4849 			DPRINTF(("obsolete createWindow message %x ignored\n", cwi->sequenceNr));
  4850                     }
  4850 		    }
  4851                 }
  4851 		}
  4852                 continue;
  4852 		continue;
  4853 
  4853 
  4854             case WM_THREAD_REGISTERHOTKEY:
  4854 	    case WM_THREAD_REGISTERHOTKEY:
  4855                 EVENT_PRINTF(("*WM_THREAD_REGISTERHOTKEY\n"));
  4855 		EVENT_PRINTF(("*WM_THREAD_REGISTERHOTKEY\n"));
  4856                 {
  4856 		{
  4857                     registerHotKeyInfo *rhki = (registerHotKeyInfo *)(msg.lParam);
  4857 		    registerHotKeyInfo *rhki = (registerHotKeyInfo *)(msg.lParam);
  4858                     rhki->errorCode = 0;
  4858 		    rhki->errorCode = 0;
  4859                     if (!RegisterHotKey(rhki->hwnd,rhki->hotKeyId,rhki->modifier,rhki->virtualKey)){
  4859 		    if (!RegisterHotKey(rhki->hwnd,rhki->hotKeyId,rhki->modifier,rhki->virtualKey)){
  4860                         rhki->errorCode = GetLastError();
  4860 			rhki->errorCode = GetLastError();
  4861                         console_fprintf(stderr, "WinWorkstation [error]: RegisterHotKey failed: err=%d\n", rhki->errorCode);
  4861 			console_fprintf(stderr, "WinWorkstation [error]: RegisterHotKey failed: err=%d\n", rhki->errorCode);
  4862                     }
  4862 		    }
  4863                     rhki->finished = 1;
  4863 		    rhki->finished = 1;
  4864                 }
  4864 		}
  4865                 continue;
  4865 		continue;
  4866 
  4866 
  4867             case WM_THREAD_UNREGISTERHOTKEY:
  4867 	    case WM_THREAD_UNREGISTERHOTKEY:
  4868                 EVENT_PRINTF(("*WM_THREAD_UNREGISTERHOTKEY\n"));
  4868 		EVENT_PRINTF(("*WM_THREAD_UNREGISTERHOTKEY\n"));
  4869                 {
  4869 		{
  4870                     registerHotKeyInfo *rhki = (registerHotKeyInfo *)(msg.lParam);
  4870 		    registerHotKeyInfo *rhki = (registerHotKeyInfo *)(msg.lParam);
  4871                     rhki->errorCode = 0;
  4871 		    rhki->errorCode = 0;
  4872                     if (!UnregisterHotKey(rhki->hwnd,rhki->hotKeyId)){
  4872 		    if (!UnregisterHotKey(rhki->hwnd,rhki->hotKeyId)){
  4873                         rhki->errorCode = GetLastError();
  4873 			rhki->errorCode = GetLastError();
  4874                         console_fprintf(stderr, "WinWorkstation [error]: UnegisterHotKey failed: err=%d\n", rhki->errorCode);
  4874 			console_fprintf(stderr, "WinWorkstation [error]: UnegisterHotKey failed: err=%d\n", rhki->errorCode);
  4875                     }
  4875 		    }
  4876                     rhki->finished = 1;
  4876 		    rhki->finished = 1;
  4877                 }
  4877 		}
  4878                 continue;
  4878 		continue;
  4879 
  4879 
  4880             case WM_KEYDOWN:
  4880 	    case WM_KEYDOWN:
  4881                 DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_KEYDOWN %x\n", msg.wParam));
  4881 		DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_KEYDOWN %x\n", msg.wParam));
  4882                 goto commonKey;
  4882 		goto commonKey;
  4883 
  4883 
  4884             case WM_KEYUP:
  4884 	    case WM_KEYUP:
  4885                 DPRINTFIF(__debug_WM_KEYUP__  , ("WM_KEYUP %x\n", msg.wParam));
  4885 		DPRINTFIF(__debug_WM_KEYUP__  , ("WM_KEYUP %x\n", msg.wParam));
  4886                 goto commonKey;
  4886 		goto commonKey;
  4887 
  4887 
  4888             case WM_SYSKEYDOWN:
  4888 	    case WM_SYSKEYDOWN:
  4889                 DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_SYSKEYDOWN %x\n", msg.wParam));
  4889 		DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_SYSKEYDOWN %x\n", msg.wParam));
  4890                 goto commonKey;
  4890 		goto commonKey;
  4891 
  4891 
  4892             case WM_SYSKEYUP:
  4892 	    case WM_SYSKEYUP:
  4893                 DPRINTFIF(__debug_WM_KEYUP__ , ("WM_SYSKEYUP %x\n", msg.wParam));
  4893 		DPRINTFIF(__debug_WM_KEYUP__ , ("WM_SYSKEYUP %x\n", msg.wParam));
  4894                 goto commonKey;
  4894 		goto commonKey;
  4895 
  4895 
  4896             case WM_HOTKEY:
  4896 	    case WM_HOTKEY:
  4897                 // console_fprintf(stderr, "dispatchThread [info]: receive hotkey %x %x\n", msg.hwnd, msg.wParam);
  4897 		// console_fprintf(stderr, "dispatchThread [info]: receive hotkey %x %x\n", msg.hwnd, msg.wParam);
  4898                 DPRINTFIF(__debug_WM_KEYUP__ , ("WM_HOTKEY %x\n", msg.wParam));
  4898 		DPRINTFIF(__debug_WM_KEYUP__ , ("WM_HOTKEY %x\n", msg.wParam));
  4899                 break;
  4899 		break;
  4900 
  4900 
  4901             commonKey:
  4901 	    commonKey:
  4902 #if 1
  4902 #if 1
  4903                 if (((msg.wParam >= '0') && (msg.wParam <= 'Z'))
  4903 		if (((msg.wParam >= '0') && (msg.wParam <= 'Z'))
  4904                  || ((msg.wParam >= VK_MULTIPLY) && (msg.wParam <= VK_DIVIDE))
  4904 		 || ((msg.wParam >= VK_MULTIPLY) && (msg.wParam <= VK_DIVIDE))
  4905                  || (msg.wParam == VK_SPACE)
  4905 		 || (msg.wParam == VK_SPACE)
  4906                  || (msg.wParam == VK_CAPITAL)
  4906 		 || (msg.wParam == VK_CAPITAL)
  4907                  /* || (msg.wParam == VK_SHIFT) */
  4907 		 /* || (msg.wParam == VK_SHIFT) */
  4908                  || (msg.wParam >= 0xB0))
  4908 		 || (msg.wParam >= 0xB0))
  4909 #endif
  4909 #endif
  4910                 {
  4910 		{
  4911                     /*
  4911 		    /*
  4912                      * translate to a WM_CHAR message
  4912 		     * translate to a WM_CHAR message
  4913                      */
  4913 		     */
  4914                     if (TranslateMessage(&msg))
  4914 		    if (TranslateMessage(&msg))
  4915                         continue;
  4915 			continue;
  4916                 }
  4916 		}
  4917                 break;
  4917 		break;
  4918 
  4918 
  4919             /* short cirquit some messages */
  4919 	    /* short cirquit some messages */
  4920 #if 0
  4920 #if 0
  4921 # ifndef SUPPORT_NATIVE_WINDOWS
  4921 # ifndef SUPPORT_NATIVE_WINDOWS
  4922             /*
  4922 	    /*
  4923              * some can simply be ignored ...
  4923 	     * some can simply be ignored ...
  4924              */
  4924 	     */
  4925             case WM_ERASEBKGND:
  4925 	    case WM_ERASEBKGND:
  4926                 EVENT_PRINTF(("*WM_ERASEBKGND\n"));
  4926 		EVENT_PRINTF(("*WM_ERASEBKGND\n"));
  4927                 continue;
  4927 		continue;
  4928             case WM_KILLFOCUS:
  4928 	    case WM_KILLFOCUS:
  4929                 EVENT_PRINTF(("*WM_KILLFOCUS\n"));
  4929 		EVENT_PRINTF(("*WM_KILLFOCUS\n"));
  4930                 continue;
  4930 		continue;
  4931 # endif
  4931 # endif
  4932 #endif
  4932 #endif
  4933 
  4933 
  4934 #if 0
  4934 #if 0
  4935             case WM_SIZE:
  4935 	    case WM_SIZE:
  4936                 EVENT_PRINTF(("*WM_SIZE\n"));
  4936 		EVENT_PRINTF(("*WM_SIZE\n"));
  4937                 continue;
  4937 		continue;
  4938 #endif
  4938 #endif
  4939         }
  4939 	}
  4940 
  4940 
  4941         /*
  4941 	/*
  4942          * common ...
  4942 	 * common ...
  4943          */
  4943 	 */
  4944         evRootX = msg.pt.x;
  4944 	evRootX = msg.pt.x;
  4945         evRootY = msg.pt.y;
  4945 	evRootY = msg.pt.y;
  4946 #if 1
  4946 #if 1
  4947         {
  4947 	{
  4948             POINT p;
  4948 	    POINT p;
  4949 
  4949 
  4950             if (GetCursorPos(&p)) {
  4950 	    if (GetCursorPos(&p)) {
  4951                 evRootX = p.x;
  4951 		evRootX = p.x;
  4952                 evRootY = p.y;
  4952 		evRootY = p.y;
  4953             }
  4953 	    }
  4954         }
  4954 	}
  4955 #endif
  4955 #endif
  4956         lastMSGTime = msg.time;
  4956 	lastMSGTime = msg.time;
  4957         DispatchMessageW(&msg);   /* Dispatches message to window */
  4957 	DispatchMessageW(&msg);   /* Dispatches message to window */
  4958     }
  4958     }
  4959 }
  4959 }
  4960 
  4960 
  4961 LONG APIENTRY
  4961 LONG APIENTRY
  4962 MainWndProc(HWND hWnd, UINT message, UINT wParam, LONG lParam)
  4962 MainWndProc(HWND hWnd, UINT message, UINT wParam, LONG lParam)
  4973      * even more of a kludge: to prevent the message in the PostThreadMessage-queue
  4973      * even more of a kludge: to prevent the message in the PostThreadMessage-queue
  4974      * from being processed twice, we use a sequenceNr, which is passed as wParam.
  4974      * from being processed twice, we use a sequenceNr, which is passed as wParam.
  4975      */
  4975      */
  4976     cwi = pendingCREATEWINDOWInfo;
  4976     cwi = pendingCREATEWINDOWInfo;
  4977     if (cwi) {
  4977     if (cwi) {
  4978         int dummyWantDefault;
  4978 	int dummyWantDefault;
  4979         int seqNr = pendingSequenceNr;
  4979 	int seqNr = pendingSequenceNr;
  4980 
  4980 
  4981         pendingCREATEWINDOWInfo = 0;
  4981 	pendingCREATEWINDOWInfo = 0;
  4982         pendingSequenceNr = INVALIDATED_CWI;
  4982 	pendingSequenceNr = INVALIDATED_CWI;
  4983         DPRINTF(("### THREAD_CREATEWINDOW\n"));
  4983 	DPRINTF(("### THREAD_CREATEWINDOW\n"));
  4984         winEventProcessing(0, WM_THREAD_CREATEWINDOW, seqNr, (INT)cwi, &dummyWantDefault);
  4984 	winEventProcessing(0, WM_THREAD_CREATEWINDOW, seqNr, (INT)cwi, &dummyWantDefault);
  4985     }
  4985     }
  4986 
  4986 
  4987     retVal = winEventProcessing(hWnd, message, wParam, lParam, &wantDefault);
  4987     retVal = winEventProcessing(hWnd, message, wParam, lParam, &wantDefault);
  4988     if (wantDefault) {
  4988     if (wantDefault) {
  4989         DDDPRINTF((">>DefWindowProc\n"));
  4989 	DDDPRINTF((">>DefWindowProc\n"));
  4990         retVal = DefWindowProcW(hWnd, message, wParam, lParam);
  4990 	retVal = DefWindowProcW(hWnd, message, wParam, lParam);
  4991         DDDPRINTF(("<<DefWindowProc\n"));
  4991 	DDDPRINTF(("<<DefWindowProc\n"));
  4992     }
  4992     }
  4993     return retVal;
  4993     return retVal;
  4994 }
  4994 }
  4995 
  4995 
  4996 static int CALLBACK
  4996 static int CALLBACK
  4997 EnumWindowsProc(HWND hwnd, LPARAM lParam)
  4997 EnumWindowsProc(HWND hwnd, LPARAM lParam)
  4998 {
  4998 {
  4999         volatile OBJ *refToCollection;
  4999 	volatile OBJ *refToCollection;
  5000         OBJ collection;
  5000 	OBJ collection;
  5001         OBJ wHandle;
  5001 	OBJ wHandle;
  5002 
  5002 
  5003         if (hwnd) {
  5003 	if (hwnd) {
  5004             refToCollection = (OBJ*) lParam;
  5004 	    refToCollection = (OBJ*) lParam;
  5005             __PROTECT__(*refToCollection);
  5005 	    __PROTECT__(*refToCollection);
  5006             wHandle = __MKEXTERNALADDRESS(hwnd);
  5006 	    wHandle = __MKEXTERNALADDRESS(hwnd);
  5007             __UNPROTECT__(*refToCollection);
  5007 	    __UNPROTECT__(*refToCollection);
  5008             collection = *refToCollection;
  5008 	    collection = *refToCollection;
  5009             __SSEND1( collection, @symbol(add:), 0, wHandle );
  5009 	    __SSEND1( collection, @symbol(add:), 0, wHandle );
  5010         }
  5010 	}
  5011         return TRUE;
  5011 	return TRUE;
  5012 }
  5012 }
  5013 
  5013 
  5014 #ifdef USE_EnumFontFamiliesEx
  5014 #ifdef USE_EnumFontFamiliesEx
  5015 # define LOGFONTTYPE  ENUMLOGFONTEX
  5015 # define LOGFONTTYPE  ENUMLOGFONTEX
  5016 #else
  5016 #else
  5022     const LOGFONTTYPE *lplf,   /* ptr to of logical-font data */
  5022     const LOGFONTTYPE *lplf,   /* ptr to of logical-font data */
  5023     const TEXTMETRIC  *lptm,   /* ptr to physical font data */
  5023     const TEXTMETRIC  *lptm,   /* ptr to physical font data */
  5024     DWORD dwType,              /* font type */
  5024     DWORD dwType,              /* font type */
  5025     LPARAM lpData              /* application supplied data */
  5025     LPARAM lpData              /* application supplied data */
  5026 ) {
  5026 ) {
  5027         OBJ t;
  5027 	OBJ t;
  5028         volatile OBJ *refToList;
  5028 	volatile OBJ *refToList;
  5029         OBJ  typeFaceList;
  5029 	OBJ  typeFaceList;
  5030         char *faceNameString;
  5030 	char *faceNameString;
  5031 
  5031 
  5032         if (lplf) {
  5032 	if (lplf) {
  5033             refToList = (OBJ *) lpData;
  5033 	    refToList = (OBJ *) lpData;
  5034             __PROTECT__(*refToList);
  5034 	    __PROTECT__(*refToList);
  5035 
  5035 
  5036 #ifdef USE_EnumFontFamiliesEx
  5036 #ifdef USE_EnumFontFamiliesEx
  5037             faceNameString = lplf->elfLogFont.lfFaceName;
  5037 	    faceNameString = lplf->elfLogFont.lfFaceName;
  5038 #else
  5038 #else
  5039             faceNameString = lplf->lfFaceName;
  5039 	    faceNameString = lplf->lfFaceName;
  5040 #endif
  5040 #endif
  5041             t = __MKSTRING( faceNameString );
  5041 	    t = __MKSTRING( faceNameString );
  5042             __UNPROTECT__(*refToList);
  5042 	    __UNPROTECT__(*refToList);
  5043             typeFaceList = *refToList;
  5043 	    typeFaceList = *refToList;
  5044             __SSEND1( typeFaceList, @symbol(add:), 0, t );
  5044 	    __SSEND1( typeFaceList, @symbol(add:), 0, t );
  5045         }
  5045 	}
  5046         return 1;
  5046 	return 1;
  5047 }
  5047 }
  5048 
  5048 
  5049 /*
  5049 /*
  5050  * take a LOGFONT structure and extract relevant data into a smalltalk array.
  5050  * take a LOGFONT structure and extract relevant data into a smalltalk array.
  5051  *
  5051  *
  5078 __charSetSymbolFor(int charSet)
  5078 __charSetSymbolFor(int charSet)
  5079 {
  5079 {
  5080     OBJ s;
  5080     OBJ s;
  5081 
  5081 
  5082     switch (charSet) {
  5082     switch (charSet) {
  5083         case ANSI_CHARSET:
  5083 	case ANSI_CHARSET:
  5084             s = @symbol('ms-ansi');
  5084 	    s = @symbol('ms-ansi');
  5085             break;
  5085 	    break;
  5086         case DEFAULT_CHARSET:
  5086 	case DEFAULT_CHARSET:
  5087             s = @symbol('ms-default');
  5087 	    s = @symbol('ms-default');
  5088             break;
  5088 	    break;
  5089         case SYMBOL_CHARSET:
  5089 	case SYMBOL_CHARSET:
  5090             s = @symbol('ms-symbol');
  5090 	    s = @symbol('ms-symbol');
  5091             break;
  5091 	    break;
  5092         case SHIFTJIS_CHARSET:
  5092 	case SHIFTJIS_CHARSET:
  5093             s = @symbol('ms-shiftjis');
  5093 	    s = @symbol('ms-shiftjis');
  5094             break;
  5094 	    break;
  5095         case GB2312_CHARSET:
  5095 	case GB2312_CHARSET:
  5096             s = @symbol('ms-gb2312');
  5096 	    s = @symbol('ms-gb2312');
  5097             break;
  5097 	    break;
  5098         case HANGEUL_CHARSET:
  5098 	case HANGEUL_CHARSET:
  5099             s = @symbol('ms-hangeul');
  5099 	    s = @symbol('ms-hangeul');
  5100             break;
  5100 	    break;
  5101 # if defined(HANGUL_CHARSET) && (HANGUL_CHARSET != HANGEUL_CHARSET)
  5101 # if defined(HANGUL_CHARSET) && (HANGUL_CHARSET != HANGEUL_CHARSET)
  5102         case HANGUL_CHARSET:
  5102 	case HANGUL_CHARSET:
  5103             s = @symbol('ms-hangul');
  5103 	    s = @symbol('ms-hangul');
  5104             break;
  5104 	    break;
  5105 # endif
  5105 # endif
  5106         case CHINESEBIG5_CHARSET:
  5106 	case CHINESEBIG5_CHARSET:
  5107             s = @symbol('ms-chinesebig5');
  5107 	    s = @symbol('ms-chinesebig5');
  5108             break;
  5108 	    break;
  5109         case OEM_CHARSET:
  5109 	case OEM_CHARSET:
  5110             s = @symbol('ms-oem');
  5110 	    s = @symbol('ms-oem');
  5111             break;
  5111 	    break;
  5112 # ifdef JOHAB_CHARSET
  5112 # ifdef JOHAB_CHARSET
  5113         case JOHAB_CHARSET:
  5113 	case JOHAB_CHARSET:
  5114             s = @symbol('ms-johab');
  5114 	    s = @symbol('ms-johab');
  5115             break;
  5115 	    break;
  5116 # endif
  5116 # endif
  5117 # ifdef HEBREW_CHARSET
  5117 # ifdef HEBREW_CHARSET
  5118         case HEBREW_CHARSET:
  5118 	case HEBREW_CHARSET:
  5119             s = @symbol('ms-hebrew');
  5119 	    s = @symbol('ms-hebrew');
  5120             break;
  5120 	    break;
  5121 # endif
  5121 # endif
  5122 # ifdef ARABIC_CHARSET
  5122 # ifdef ARABIC_CHARSET
  5123         case ARABIC_CHARSET:
  5123 	case ARABIC_CHARSET:
  5124             s = @symbol('ms-arabic');
  5124 	    s = @symbol('ms-arabic');
  5125             break;
  5125 	    break;
  5126 # endif
  5126 # endif
  5127 # ifdef GREEK_CHARSET
  5127 # ifdef GREEK_CHARSET
  5128         case GREEK_CHARSET:
  5128 	case GREEK_CHARSET:
  5129             s = @symbol('ms-greek');
  5129 	    s = @symbol('ms-greek');
  5130             break;
  5130 	    break;
  5131 # endif
  5131 # endif
  5132 # ifdef TURKISH_CHARSET
  5132 # ifdef TURKISH_CHARSET
  5133         case TURKISH_CHARSET:
  5133 	case TURKISH_CHARSET:
  5134             s = @symbol('ms-turkish');
  5134 	    s = @symbol('ms-turkish');
  5135             break;
  5135 	    break;
  5136 # endif
  5136 # endif
  5137 # ifdef RUSSIAN_CHARSET
  5137 # ifdef RUSSIAN_CHARSET
  5138         case RUSSIAN_CHARSET:
  5138 	case RUSSIAN_CHARSET:
  5139             s = @symbol('ms-russian');
  5139 	    s = @symbol('ms-russian');
  5140             break;
  5140 	    break;
  5141 # endif
  5141 # endif
  5142 # ifdef EASTEUROPE_CHARSET
  5142 # ifdef EASTEUROPE_CHARSET
  5143         case EASTEUROPE_CHARSET:
  5143 	case EASTEUROPE_CHARSET:
  5144             s = @symbol('ms-easteurope');
  5144 	    s = @symbol('ms-easteurope');
  5145             break;
  5145 	    break;
  5146 # endif
  5146 # endif
  5147 # ifdef BALTIC_CHARSET
  5147 # ifdef BALTIC_CHARSET
  5148         case BALTIC_CHARSET:
  5148 	case BALTIC_CHARSET:
  5149             s = @symbol('ms-baltic');
  5149 	    s = @symbol('ms-baltic');
  5150             break;
  5150 	    break;
  5151 # endif
  5151 # endif
  5152 # ifdef VIETNAMESE_CHARSET
  5152 # ifdef VIETNAMESE_CHARSET
  5153         case VIETNAMESE_CHARSET:
  5153 	case VIETNAMESE_CHARSET:
  5154             s = @symbol('ms-vietnamese');
  5154 	    s = @symbol('ms-vietnamese');
  5155             break;
  5155 	    break;
  5156 # endif
  5156 # endif
  5157 # ifdef THAI_CHARSET
  5157 # ifdef THAI_CHARSET
  5158         case THAI_CHARSET:
  5158 	case THAI_CHARSET:
  5159             s = @symbol('ms-thai');
  5159 	    s = @symbol('ms-thai');
  5160             break;
  5160 	    break;
  5161 # endif
  5161 # endif
  5162 # ifdef MAC_CHARSET
  5162 # ifdef MAC_CHARSET
  5163         case MAC_CHARSET:
  5163 	case MAC_CHARSET:
  5164             s = @symbol('ms-mac');
  5164 	    s = @symbol('ms-mac');
  5165             break;
  5165 	    break;
  5166 # endif
  5166 # endif
  5167 # ifdef UNICODE_CHARSET
  5167 # ifdef UNICODE_CHARSET
  5168         case UNICODE_CHARSET:
  5168 	case UNICODE_CHARSET:
  5169             s = @symbol('ms-unicode');
  5169 	    s = @symbol('ms-unicode');
  5170             break;
  5170 	    break;
  5171 # endif
  5171 # endif
  5172         default:
  5172 	default:
  5173             s = @symbol(unknown);
  5173 	    s = @symbol(unknown);
  5174             break;
  5174 	    break;
  5175     }
  5175     }
  5176     return s;
  5176     return s;
  5177 }
  5177 }
  5178 
  5178 
  5179 OBJ
  5179 OBJ
  5180 __extractLogicalFontParameters(LOGFONT *lplf)
  5180 __extractLogicalFontParameters(LOGFONT *lplf)
  5181 {
  5181 {
  5182         OBJ newArray, t;
  5182 	OBJ newArray, t;
  5183         OBJ s;
  5183 	OBJ s;
  5184 
  5184 
  5185         DPRINTF((" lfHeight          %d\n", lplf->lfHeight ));
  5185 	DPRINTF((" lfHeight          %d\n", lplf->lfHeight ));
  5186         DPRINTF((" lfWidth           %d\n", lplf->lfWidth  ));
  5186 	DPRINTF((" lfWidth           %d\n", lplf->lfWidth  ));
  5187         DPRINTF((" lfEscapement      %d\n", lplf->lfEscapement  ));
  5187 	DPRINTF((" lfEscapement      %d\n", lplf->lfEscapement  ));
  5188         DPRINTF((" lfOrientation     %d\n", lplf->lfOrientation  ));
  5188 	DPRINTF((" lfOrientation     %d\n", lplf->lfOrientation  ));
  5189         DPRINTF((" lfWeight          %d\n", lplf->lfWeight  ));
  5189 	DPRINTF((" lfWeight          %d\n", lplf->lfWeight  ));
  5190         DPRINTF((" lfItalic          %d\n", lplf->lfItalic  ));
  5190 	DPRINTF((" lfItalic          %d\n", lplf->lfItalic  ));
  5191         DPRINTF((" lfUnderline       %d\n", lplf->lfUnderline  ));
  5191 	DPRINTF((" lfUnderline       %d\n", lplf->lfUnderline  ));
  5192         DPRINTF((" lfStrikeOut       %d\n", lplf->lfStrikeOut  ));
  5192 	DPRINTF((" lfStrikeOut       %d\n", lplf->lfStrikeOut  ));
  5193         DPRINTF((" lfCharSet         %d\n", lplf->lfCharSet  ));
  5193 	DPRINTF((" lfCharSet         %d\n", lplf->lfCharSet  ));
  5194         DPRINTF((" lfOutPrecision    %d\n", lplf->lfOutPrecision  ));
  5194 	DPRINTF((" lfOutPrecision    %d\n", lplf->lfOutPrecision  ));
  5195         DPRINTF((" lfClipPrecision   %d\n", lplf->lfClipPrecision  ));
  5195 	DPRINTF((" lfClipPrecision   %d\n", lplf->lfClipPrecision  ));
  5196         DPRINTF((" lfQuality         %d\n", lplf->lfQuality  ));
  5196 	DPRINTF((" lfQuality         %d\n", lplf->lfQuality  ));
  5197         DPRINTF((" lfPitchAndFamily  %d\n", lplf->lfPitchAndFamily  ));
  5197 	DPRINTF((" lfPitchAndFamily  %d\n", lplf->lfPitchAndFamily  ));
  5198         DPRINTF((" lfFaceName        %s\n\n", lplf->lfFaceName  ));
  5198 	DPRINTF((" lfFaceName        %s\n\n", lplf->lfFaceName  ));
  5199 
  5199 
  5200         newArray = __ARRAY_NEW_INT(20);
  5200 	newArray = __ARRAY_NEW_INT(20);
  5201 
  5201 
  5202         __ArrayInstPtr(newArray)->a_element[0] = __MKSMALLINT(lplf->lfHeight);
  5202 	__ArrayInstPtr(newArray)->a_element[0] = __MKSMALLINT(lplf->lfHeight);
  5203         __ArrayInstPtr(newArray)->a_element[1] = __MKSMALLINT(lplf->lfWidth);
  5203 	__ArrayInstPtr(newArray)->a_element[1] = __MKSMALLINT(lplf->lfWidth);
  5204         __ArrayInstPtr(newArray)->a_element[2] = __MKSMALLINT(lplf->lfEscapement);
  5204 	__ArrayInstPtr(newArray)->a_element[2] = __MKSMALLINT(lplf->lfEscapement);
  5205         __ArrayInstPtr(newArray)->a_element[3] = __MKSMALLINT(lplf->lfOrientation);
  5205 	__ArrayInstPtr(newArray)->a_element[3] = __MKSMALLINT(lplf->lfOrientation);
  5206         __ArrayInstPtr(newArray)->a_element[4] = __MKSMALLINT(lplf->lfWeight);
  5206 	__ArrayInstPtr(newArray)->a_element[4] = __MKSMALLINT(lplf->lfWeight);
  5207         switch (lplf->lfWeight) {
  5207 	switch (lplf->lfWeight) {
  5208             case FW_HEAVY:
  5208 	    case FW_HEAVY:
  5209             case FW_EXTRABOLD:
  5209 	    case FW_EXTRABOLD:
  5210             case FW_SEMIBOLD:
  5210 	    case FW_SEMIBOLD:
  5211             case FW_BOLD:
  5211 	    case FW_BOLD:
  5212                 s = @symbol(bold);
  5212 		s = @symbol(bold);
  5213                 break;
  5213 		break;
  5214             case FW_NORMAL:
  5214 	    case FW_NORMAL:
  5215 #if 0
  5215 #if 0
  5216                 s = @symbol(normal);
  5216 		s = @symbol(normal);
  5217                 break;
  5217 		break;
  5218 #endif
  5218 #endif
  5219             case FW_MEDIUM:
  5219 	    case FW_MEDIUM:
  5220                 s = @symbol(medium);
  5220 		s = @symbol(medium);
  5221                 break;
  5221 		break;
  5222             case FW_THIN:
  5222 	    case FW_THIN:
  5223             case FW_EXTRALIGHT:
  5223 	    case FW_EXTRALIGHT:
  5224             case FW_LIGHT:
  5224 	    case FW_LIGHT:
  5225                 s = @symbol(demi);
  5225 		s = @symbol(demi);
  5226                 break;
  5226 		break;
  5227             default:
  5227 	    default:
  5228                 s = @symbol(other);
  5228 		s = @symbol(other);
  5229                 break;
  5229 		break;
  5230         }
  5230 	}
  5231         __ArrayInstPtr(newArray)->a_element[5] = s; __STORE(newArray, s);
  5231 	__ArrayInstPtr(newArray)->a_element[5] = s; __STORE(newArray, s);
  5232         __ArrayInstPtr(newArray)->a_element[6] = __MKSMALLINT(lplf->lfItalic);
  5232 	__ArrayInstPtr(newArray)->a_element[6] = __MKSMALLINT(lplf->lfItalic);
  5233         __ArrayInstPtr(newArray)->a_element[7] = __MKSMALLINT(lplf->lfUnderline);
  5233 	__ArrayInstPtr(newArray)->a_element[7] = __MKSMALLINT(lplf->lfUnderline);
  5234         __ArrayInstPtr(newArray)->a_element[8] = __MKSMALLINT(lplf->lfStrikeOut);
  5234 	__ArrayInstPtr(newArray)->a_element[8] = __MKSMALLINT(lplf->lfStrikeOut);
  5235         __ArrayInstPtr(newArray)->a_element[9] = __MKSMALLINT(lplf->lfCharSet);
  5235 	__ArrayInstPtr(newArray)->a_element[9] = __MKSMALLINT(lplf->lfCharSet);
  5236         __ArrayInstPtr(newArray)->a_element[10] = __MKSMALLINT(lplf->lfOutPrecision);
  5236 	__ArrayInstPtr(newArray)->a_element[10] = __MKSMALLINT(lplf->lfOutPrecision);
  5237         __ArrayInstPtr(newArray)->a_element[11] = __MKSMALLINT(lplf->lfClipPrecision);
  5237 	__ArrayInstPtr(newArray)->a_element[11] = __MKSMALLINT(lplf->lfClipPrecision);
  5238         __ArrayInstPtr(newArray)->a_element[12] = __MKSMALLINT(lplf->lfQuality);
  5238 	__ArrayInstPtr(newArray)->a_element[12] = __MKSMALLINT(lplf->lfQuality);
  5239         __ArrayInstPtr(newArray)->a_element[13] = __MKSMALLINT(lplf->lfPitchAndFamily);
  5239 	__ArrayInstPtr(newArray)->a_element[13] = __MKSMALLINT(lplf->lfPitchAndFamily);
  5240         /* ... */
  5240 	/* ... */
  5241 
  5241 
  5242         if( lplf->lfItalic == TRUE ) {
  5242 	if( lplf->lfItalic == TRUE ) {
  5243             if( lplf->lfUnderline == TRUE ) {
  5243 	    if( lplf->lfUnderline == TRUE ) {
  5244                 if( lplf->lfStrikeOut == TRUE ) {
  5244 		if( lplf->lfStrikeOut == TRUE ) {
  5245                     s = @symbol('italic-underline-strikeOut');
  5245 		    s = @symbol('italic-underline-strikeOut');
  5246                 } else {
  5246 		} else {
  5247                     s = @symbol('italic-underline');
  5247 		    s = @symbol('italic-underline');
  5248                 }
  5248 		}
  5249             } else {
  5249 	    } else {
  5250                 if( lplf->lfStrikeOut == TRUE ) {
  5250 		if( lplf->lfStrikeOut == TRUE ) {
  5251                     s = @symbol('italic-strikeOut');
  5251 		    s = @symbol('italic-strikeOut');
  5252                 } else {
  5252 		} else {
  5253                     s = @symbol('italic');
  5253 		    s = @symbol('italic');
  5254                 }
  5254 		}
  5255             }
  5255 	    }
  5256         } else {
  5256 	} else {
  5257             if( lplf->lfUnderline == TRUE ) {
  5257 	    if( lplf->lfUnderline == TRUE ) {
  5258                 if( lplf->lfStrikeOut == TRUE ) {
  5258 		if( lplf->lfStrikeOut == TRUE ) {
  5259                     s = @symbol('roman-underline-strikeOut');
  5259 		    s = @symbol('roman-underline-strikeOut');
  5260                 } else {
  5260 		} else {
  5261                     s = @symbol('roman-underline');
  5261 		    s = @symbol('roman-underline');
  5262                 }
  5262 		}
  5263             } else {
  5263 	    } else {
  5264                 if( lplf->lfStrikeOut == TRUE ) {
  5264 		if( lplf->lfStrikeOut == TRUE ) {
  5265                     s = @symbol('roman-strikeOut');
  5265 		    s = @symbol('roman-strikeOut');
  5266                 } else {
  5266 		} else {
  5267                     s = @symbol('roman');
  5267 		    s = @symbol('roman');
  5268                 }
  5268 		}
  5269             }
  5269 	    }
  5270         }
  5270 	}
  5271         __ArrayInstPtr(newArray)->a_element[14] = s; __STORE(newArray, s);
  5271 	__ArrayInstPtr(newArray)->a_element[14] = s; __STORE(newArray, s);
  5272 
  5272 
  5273         __PROTECT__(newArray);
  5273 	__PROTECT__(newArray);
  5274         t = __MKSTRING(lplf->lfFaceName);
  5274 	t = __MKSTRING(lplf->lfFaceName);
  5275         __UNPROTECT__(newArray);
  5275 	__UNPROTECT__(newArray);
  5276         __ArrayInstPtr(newArray)->a_element[15] = t; __STORE(newArray, t);
  5276 	__ArrayInstPtr(newArray)->a_element[15] = t; __STORE(newArray, t);
  5277 
  5277 
  5278         t = __charSetSymbolFor(lplf->lfCharSet);
  5278 	t = __charSetSymbolFor(lplf->lfCharSet);
  5279         __ArrayInstPtr(newArray)->a_element[16] = t; __STORE(newArray, t);
  5279 	__ArrayInstPtr(newArray)->a_element[16] = t; __STORE(newArray, t);
  5280 
  5280 
  5281         return newArray;
  5281 	return newArray;
  5282 }
  5282 }
  5283 
  5283 
  5284 
  5284 
  5285 static int CALLBACK
  5285 static int CALLBACK
  5286 EnumFontsProc(
  5286 EnumFontsProc(
  5287     const LOGFONTTYPE *lplf,   // ptr to of logical-font data
  5287     const LOGFONTTYPE *lplf,   // ptr to of logical-font data
  5288     const TEXTMETRIC *lptm,    // ptr to physical font data
  5288     const TEXTMETRIC *lptm,    // ptr to physical font data
  5289     DWORD dwType,              // font type
  5289     DWORD dwType,              // font type
  5290     LPARAM lpData              // application supplied data
  5290     LPARAM lpData              // application supplied data
  5291 ) {
  5291 ) {
  5292         volatile OBJ *refToList;
  5292 	volatile OBJ *refToList;
  5293         OBJ list;
  5293 	OBJ list;
  5294         OBJ infoArray;
  5294 	OBJ infoArray;
  5295         OBJ *fullName;
  5295 	OBJ *fullName;
  5296 
  5296 
  5297         DPRINTF(("EnumFontsProc\n"));
  5297 	DPRINTF(("EnumFontsProc\n"));
  5298 
  5298 
  5299         if ( lplf ) {
  5299 	if ( lplf ) {
  5300             refToList = (OBJ *) lpData;
  5300 	    refToList = (OBJ *) lpData;
  5301 
  5301 
  5302             __PROTECT__(*refToList);
  5302 	    __PROTECT__(*refToList);
  5303 #ifdef USE_EnumFontFamiliesEx
  5303 #ifdef USE_EnumFontFamiliesEx
  5304             infoArray = __extractLogicalFontParameters(lplf->elfLogFont);
  5304 	    infoArray = __extractLogicalFontParameters(lplf->elfLogFont);
  5305             __PROTECT__(infoArray);
  5305 	    __PROTECT__(infoArray);
  5306             fullName = __MKSTRING(lplf->elfFullName);
  5306 	    fullName = __MKSTRING(lplf->elfFullName);
  5307             __UNPROTECT__(infoArray);
  5307 	    __UNPROTECT__(infoArray);
  5308             __ArrayInstPtr(infoArray)->a_element[17] = fullName; __STORE(infoArray, fullName);
  5308 	    __ArrayInstPtr(infoArray)->a_element[17] = fullName; __STORE(infoArray, fullName);
  5309 #else
  5309 #else
  5310             infoArray = __extractLogicalFontParameters(lplf);
  5310 	    infoArray = __extractLogicalFontParameters(lplf);
  5311 #endif
  5311 #endif
  5312 
  5312 
  5313             __UNPROTECT__(*refToList);
  5313 	    __UNPROTECT__(*refToList);
  5314 
  5314 
  5315             if ( dwType & TRUETYPE_FONTTYPE ) {
  5315 	    if ( dwType & TRUETYPE_FONTTYPE ) {
  5316                 /* change height to 0 to mark variable fonts */
  5316 		/* change height to 0 to mark variable fonts */
  5317                 __ArrayInstPtr(infoArray)->a_element[0] = __MKSMALLINT(0);
  5317 		__ArrayInstPtr(infoArray)->a_element[0] = __MKSMALLINT(0);
  5318             }
  5318 	    }
  5319             list = *refToList;
  5319 	    list = *refToList;
  5320             __SSEND1(list, @symbol(add:), 0, infoArray);
  5320 	    __SSEND1(list, @symbol(add:), 0, infoArray);
  5321         }
  5321 	}
  5322         return 1;
  5322 	return 1;
  5323 }
  5323 }
  5324 
  5324 
  5325 struct EnumDisplayMonitorsProcData {
  5325 struct EnumDisplayMonitorsProcData {
  5326     OBJ hArray;
  5326     OBJ hArray;
  5327     int index;
  5327     int index;
  5348 !WinWorkstation class methodsFor:'documentation'!
  5348 !WinWorkstation class methodsFor:'documentation'!
  5349 
  5349 
  5350 copyright
  5350 copyright
  5351 "
  5351 "
  5352 COPYRIGHT (c) 1996 by Claus Gittinger
  5352 COPYRIGHT (c) 1996 by Claus Gittinger
  5353               All Rights Reserved
  5353 	      All Rights Reserved
  5354 
  5354 
  5355  This software is furnished under a license and may be used
  5355  This software is furnished under a license and may be used
  5356  only in accordance with the terms of that license and with the
  5356  only in accordance with the terms of that license and with the
  5357  inclusion of the above copyright notice.   This software may not
  5357  inclusion of the above copyright notice.   This software may not
  5358  be provided or otherwise made available to, or used by, any
  5358  be provided or otherwise made available to, or used by, any
  5364 documentation
  5364 documentation
  5365 "
  5365 "
  5366     See more documentation in my superclass, DeviceWorkstation.
  5366     See more documentation in my superclass, DeviceWorkstation.
  5367 
  5367 
  5368     [author:]
  5368     [author:]
  5369         Claus Gittinger (initial port & final fixups)
  5369 	Claus Gittinger (initial port & final fixups)
  5370         Manfred Dierolf (many, many changes & fixes, multithreading etc.)
  5370 	Manfred Dierolf (many, many changes & fixes, multithreading etc.)
  5371 "
  5371 "
  5372 ! !
  5372 ! !
  5373 
  5373 
  5374 !WinWorkstation class methodsFor:'initialization'!
  5374 !WinWorkstation class methodsFor:'initialization'!
  5375 
  5375 
  5390 
  5390 
  5391     "/ translation table from ST/X windowType symbol (system-independent)
  5391     "/ translation table from ST/X windowType symbol (system-independent)
  5392     "/ to Windows windowClass (windows-specific).
  5392     "/ to Windows windowClass (windows-specific).
  5393 
  5393 
  5394     NativeWidgetClassTable := IdentityDictionary
  5394     NativeWidgetClassTable := IdentityDictionary
  5395         withKeysAndValues:#(
  5395 	withKeysAndValues:#(
  5396                 ScrollBar                 SCROLLBAR
  5396 		ScrollBar                 SCROLLBAR
  5397                 HorizontalScrollBar       SCROLLBAR
  5397 		HorizontalScrollBar       SCROLLBAR
  5398                 VerticalScrollBar         SCROLLBAR
  5398 		VerticalScrollBar         SCROLLBAR
  5399                 CheckBox                  BUTTON
  5399 		CheckBox                  BUTTON
  5400                 RadioButton               BUTTON
  5400 		RadioButton               BUTTON
  5401                 Button                    BUTTON
  5401 		Button                    BUTTON
  5402                 DefaultButton             BUTTON
  5402 		DefaultButton             BUTTON
  5403                 OwnerDrawButton           BUTTON
  5403 		OwnerDrawButton           BUTTON
  5404                 ComboBox                  COMBOBOX
  5404 		ComboBox                  COMBOBOX
  5405                 EditField                 EDIT
  5405 		EditField                 EDIT
  5406                 ListBox                   LISTBOX
  5406 		ListBox                   LISTBOX
  5407         ).
  5407 	).
  5408 
  5408 
  5409     "Modified: / 24-08-2010 / 16:42:23 / sr"
  5409     "Modified: / 24-08-2010 / 16:42:23 / sr"
  5410 !
  5410 !
  5411 
  5411 
  5412 initializeStandardColorNames
  5412 initializeStandardColorNames
  5413     "{ Pragma: +optSpace }"
  5413     "{ Pragma: +optSpace }"
  5414 
  5414 
  5415     "setup standard color names (X-color names)"
  5415     "setup standard color names (X-color names)"
  5416 
  5416 
  5417     StandardColorValues := Dictionary
  5417     StandardColorValues := Dictionary
  5418         withKeysAndValues:#(
  5418 	withKeysAndValues:#(
  5419             'aliceblue'     (240 248 255)
  5419 	    'aliceblue'     (240 248 255)
  5420             'antiquewhite'  (250 235 215)
  5420 	    'antiquewhite'  (250 235 215)
  5421             'AntiqueWhite1' (255 239 219)
  5421 	    'AntiqueWhite1' (255 239 219)
  5422             'AntiqueWhite2' (238 223 204)
  5422 	    'AntiqueWhite2' (238 223 204)
  5423             'AntiqueWhite3' (205 192 176)
  5423 	    'AntiqueWhite3' (205 192 176)
  5424             'AntiqueWhite4' (139 131 120)
  5424 	    'AntiqueWhite4' (139 131 120)
  5425             'aquamarine'    (127 255 212)
  5425 	    'aquamarine'    (127 255 212)
  5426             'aquamarine1'   (127 255 212)
  5426 	    'aquamarine1'   (127 255 212)
  5427             'aquamarine2'   (118 238 198)
  5427 	    'aquamarine2'   (118 238 198)
  5428             'aquamarine3'   (102 205 170)
  5428 	    'aquamarine3'   (102 205 170)
  5429             'aquamarine4'   (69 139 116)
  5429 	    'aquamarine4'   (69 139 116)
  5430             'azure'         (240 255 255)
  5430 	    'azure'         (240 255 255)
  5431             'azure1'        (240 255 255)
  5431 	    'azure1'        (240 255 255)
  5432             'azure2'        (224 238 238)
  5432 	    'azure2'        (224 238 238)
  5433             'azure3'        (193 205 205)
  5433 	    'azure3'        (193 205 205)
  5434             'azure4'        (131 139 139)
  5434 	    'azure4'        (131 139 139)
  5435             'beige'         (245 245 220)
  5435 	    'beige'         (245 245 220)
  5436             'bisque'        (255 228 196)
  5436 	    'bisque'        (255 228 196)
  5437             'bisque1'       (255 228 196)
  5437 	    'bisque1'       (255 228 196)
  5438             'bisque2'       (238 213 183)
  5438 	    'bisque2'       (238 213 183)
  5439             'bisque3'       (205 183 158)
  5439 	    'bisque3'       (205 183 158)
  5440             'bisque4'       (139 125 107)
  5440 	    'bisque4'       (139 125 107)
  5441             'black'         (0 0 0)
  5441 	    'black'         (0 0 0)
  5442             'blanchedalmond'        (255 235 205)
  5442 	    'blanchedalmond'        (255 235 205)
  5443             'blue'          (0 0 255)
  5443 	    'blue'          (0 0 255)
  5444             'blueviolet'    (138 43 226)
  5444 	    'blueviolet'    (138 43 226)
  5445             'blue1'         (0 0 255)
  5445 	    'blue1'         (0 0 255)
  5446             'blue2'         (0 0 238)
  5446 	    'blue2'         (0 0 238)
  5447             'blue3'         (0 0 205)
  5447 	    'blue3'         (0 0 205)
  5448             'blue4'         (0 0 139)
  5448 	    'blue4'         (0 0 139)
  5449             'brown'         (165 42 42)
  5449 	    'brown'         (165 42 42)
  5450             'brown1'        (255 64 64)
  5450 	    'brown1'        (255 64 64)
  5451             'brown2'        (238 59 59)
  5451 	    'brown2'        (238 59 59)
  5452             'brown3'        (205 51 51)
  5452 	    'brown3'        (205 51 51)
  5453             'brown4'        (139 35 35)
  5453 	    'brown4'        (139 35 35)
  5454             'burlywood'     (222 184 135)
  5454 	    'burlywood'     (222 184 135)
  5455             'burlywood1'    (255 211 155)
  5455 	    'burlywood1'    (255 211 155)
  5456             'burlywood2'    (238 197 145)
  5456 	    'burlywood2'    (238 197 145)
  5457             'burlywood3'    (205 170 125)
  5457 	    'burlywood3'    (205 170 125)
  5458             'burlywood4'    (139 115 85)
  5458 	    'burlywood4'    (139 115 85)
  5459             'cadetblue'     (95 158 160)
  5459 	    'cadetblue'     (95 158 160)
  5460             'CadetBlue1'    (152 245 255)
  5460 	    'CadetBlue1'    (152 245 255)
  5461             'CadetBlue2'    (142 229 238)
  5461 	    'CadetBlue2'    (142 229 238)
  5462             'CadetBlue3'    (122 197 205)
  5462 	    'CadetBlue3'    (122 197 205)
  5463             'CadetBlue4'    (83 134 139)
  5463 	    'CadetBlue4'    (83 134 139)
  5464             'chartreuse'    (127 255 0)
  5464 	    'chartreuse'    (127 255 0)
  5465             'chartreuse1'   (127 255 0)
  5465 	    'chartreuse1'   (127 255 0)
  5466             'chartreuse2'   (118 238 0)
  5466 	    'chartreuse2'   (118 238 0)
  5467             'chartreuse3'   (102 205 0)
  5467 	    'chartreuse3'   (102 205 0)
  5468             'chartreuse4'   (69 139 0)
  5468 	    'chartreuse4'   (69 139 0)
  5469             'chocolate'     (210 105 30)
  5469 	    'chocolate'     (210 105 30)
  5470             'chocolate1'    (255 127 36)
  5470 	    'chocolate1'    (255 127 36)
  5471             'chocolate2'    (238 118 33)
  5471 	    'chocolate2'    (238 118 33)
  5472             'chocolate3'    (205 102 29)
  5472 	    'chocolate3'    (205 102 29)
  5473             'chocolate4'    (139 69 19)
  5473 	    'chocolate4'    (139 69 19)
  5474             'coral'         (255 127 80)
  5474 	    'coral'         (255 127 80)
  5475             'coral1'        (255 114 86)
  5475 	    'coral1'        (255 114 86)
  5476             'coral2'        (238 106 80)
  5476 	    'coral2'        (238 106 80)
  5477             'coral3'        (205 91 69)
  5477 	    'coral3'        (205 91 69)
  5478             'coral4'        (139 62 47)
  5478 	    'coral4'        (139 62 47)
  5479             'cornflowerblue'        (100 149 237)
  5479 	    'cornflowerblue'        (100 149 237)
  5480             'cornsilk'      (255 248 220)
  5480 	    'cornsilk'      (255 248 220)
  5481             'cornsilk1'     (255 248 220)
  5481 	    'cornsilk1'     (255 248 220)
  5482             'cornsilk2'     (238 232 205)
  5482 	    'cornsilk2'     (238 232 205)
  5483             'cornsilk3'     (205 200 177)
  5483 	    'cornsilk3'     (205 200 177)
  5484             'cornsilk4'     (139 136 120)
  5484 	    'cornsilk4'     (139 136 120)
  5485             'cyan'          (0 255 255)
  5485 	    'cyan'          (0 255 255)
  5486             'cyan1'         (0 255 255)
  5486 	    'cyan1'         (0 255 255)
  5487             'cyan2'         (0 238 238)
  5487 	    'cyan2'         (0 238 238)
  5488             'cyan3'         (0 205 205)
  5488 	    'cyan3'         (0 205 205)
  5489             'cyan4'         (0 139 139)
  5489 	    'cyan4'         (0 139 139)
  5490             'darkblue'      (0 0 139)
  5490 	    'darkblue'      (0 0 139)
  5491             'darkcyan'      (0 139 139)
  5491 	    'darkcyan'      (0 139 139)
  5492             'darkgoldenrod' (184 134 11)
  5492 	    'darkgoldenrod' (184 134 11)
  5493             'darkgray'      (169 169 169)
  5493 	    'darkgray'      (169 169 169)
  5494             'darkgreen'     (0 100 0)
  5494 	    'darkgreen'     (0 100 0)
  5495             'darkgrey'      (169 169 169)
  5495 	    'darkgrey'      (169 169 169)
  5496             'darkkhaki'     (189 183 107)
  5496 	    'darkkhaki'     (189 183 107)
  5497             'darkmagenta'   (139 0 139)
  5497 	    'darkmagenta'   (139 0 139)
  5498             'darkolivegreen'        (85 107 47)
  5498 	    'darkolivegreen'        (85 107 47)
  5499             'darkorange'    (255 140 0)
  5499 	    'darkorange'    (255 140 0)
  5500             'darkorchid'    (153 50 204)
  5500 	    'darkorchid'    (153 50 204)
  5501             'darkred'       (139 0 0)
  5501 	    'darkred'       (139 0 0)
  5502             'darksalmon'    (233 150 122)
  5502 	    'darksalmon'    (233 150 122)
  5503             'darkseagreen'  (143 188 143)
  5503 	    'darkseagreen'  (143 188 143)
  5504             'darkslateblue' (72 61 139)
  5504 	    'darkslateblue' (72 61 139)
  5505             'darkslategray' (47 79 79)
  5505 	    'darkslategray' (47 79 79)
  5506             'darkslategrey' (47 79 79)
  5506 	    'darkslategrey' (47 79 79)
  5507             'darkturquoise' (0 206 209)
  5507 	    'darkturquoise' (0 206 209)
  5508             'darkviolet'    (148 0 211)
  5508 	    'darkviolet'    (148 0 211)
  5509             'DarkGoldenrod1'        (255 185 15)
  5509 	    'DarkGoldenrod1'        (255 185 15)
  5510             'DarkGoldenrod2'        (238 173 14)
  5510 	    'DarkGoldenrod2'        (238 173 14)
  5511             'DarkGoldenrod3'        (205 149 12)
  5511 	    'DarkGoldenrod3'        (205 149 12)
  5512             'DarkGoldenrod4'        (139 101 8)
  5512 	    'DarkGoldenrod4'        (139 101 8)
  5513             'DarkOliveGreen1'       (202 255 112)
  5513 	    'DarkOliveGreen1'       (202 255 112)
  5514             'DarkOliveGreen2'       (188 238 104)
  5514 	    'DarkOliveGreen2'       (188 238 104)
  5515             'DarkOliveGreen3'       (162 205 90)
  5515 	    'DarkOliveGreen3'       (162 205 90)
  5516             'DarkOliveGreen4'       (110 139 61)
  5516 	    'DarkOliveGreen4'       (110 139 61)
  5517             'DarkOrange1'   (255 127 0)
  5517 	    'DarkOrange1'   (255 127 0)
  5518             'DarkOrange2'   (238 118 0)
  5518 	    'DarkOrange2'   (238 118 0)
  5519             'DarkOrange3'   (205 102 0)
  5519 	    'DarkOrange3'   (205 102 0)
  5520             'DarkOrange4'   (139 69 0)
  5520 	    'DarkOrange4'   (139 69 0)
  5521             'DarkOrchid1'   (191 62 255)
  5521 	    'DarkOrchid1'   (191 62 255)
  5522             'DarkOrchid2'   (178 58 238)
  5522 	    'DarkOrchid2'   (178 58 238)
  5523             'DarkOrchid3'   (154 50 205)
  5523 	    'DarkOrchid3'   (154 50 205)
  5524             'DarkOrchid4'   (104 34 139)
  5524 	    'DarkOrchid4'   (104 34 139)
  5525             'DarkSeaGreen1' (193 255 193)
  5525 	    'DarkSeaGreen1' (193 255 193)
  5526             'DarkSeaGreen2' (180 238 180)
  5526 	    'DarkSeaGreen2' (180 238 180)
  5527             'DarkSeaGreen3' (155 205 155)
  5527 	    'DarkSeaGreen3' (155 205 155)
  5528             'DarkSeaGreen4' (105 139 105)
  5528 	    'DarkSeaGreen4' (105 139 105)
  5529             'DarkSlateGray1'        (151 255 255)
  5529 	    'DarkSlateGray1'        (151 255 255)
  5530             'DarkSlateGray2'        (141 238 238)
  5530 	    'DarkSlateGray2'        (141 238 238)
  5531             'DarkSlateGray3'        (121 205 205)
  5531 	    'DarkSlateGray3'        (121 205 205)
  5532             'DarkSlateGray4'        (82 139 139)
  5532 	    'DarkSlateGray4'        (82 139 139)
  5533             'deeppink'      (255 20 147)
  5533 	    'deeppink'      (255 20 147)
  5534             'deepskyblue'   (0 191 255)
  5534 	    'deepskyblue'   (0 191 255)
  5535             'DeepPink'      (255 20 147)
  5535 	    'DeepPink'      (255 20 147)
  5536             'DeepPink1'     (255 20 147)
  5536 	    'DeepPink1'     (255 20 147)
  5537             'DeepPink2'     (238 18 137)
  5537 	    'DeepPink2'     (238 18 137)
  5538             'DeepPink3'     (205 16 118)
  5538 	    'DeepPink3'     (205 16 118)
  5539             'DeepPink4'     (139 10 80)
  5539 	    'DeepPink4'     (139 10 80)
  5540             'DeepSkyBlue1'  (0 191 255)
  5540 	    'DeepSkyBlue1'  (0 191 255)
  5541             'DeepSkyBlue2'  (0 178 238)
  5541 	    'DeepSkyBlue2'  (0 178 238)
  5542             'DeepSkyBlue3'  (0 154 205)
  5542 	    'DeepSkyBlue3'  (0 154 205)
  5543             'DeepSkyBlue4'  (0 104 139)
  5543 	    'DeepSkyBlue4'  (0 104 139)
  5544             'dimgray'       (105 105 105)
  5544 	    'dimgray'       (105 105 105)
  5545             'dimgrey'       (105 105 105)
  5545 	    'dimgrey'       (105 105 105)
  5546             'dodgerblue'    (30 144 255)
  5546 	    'dodgerblue'    (30 144 255)
  5547             'DodgerBlue1'   (30 144 255)
  5547 	    'DodgerBlue1'   (30 144 255)
  5548             'DodgerBlue2'   (28 134 238)
  5548 	    'DodgerBlue2'   (28 134 238)
  5549             'DodgerBlue3'   (24 116 205)
  5549 	    'DodgerBlue3'   (24 116 205)
  5550             'DodgerBlue4'   (16 78 139)
  5550 	    'DodgerBlue4'   (16 78 139)
  5551             'firebrick'     (178 34 34)
  5551 	    'firebrick'     (178 34 34)
  5552             'firebrick1'    (255 48 48)
  5552 	    'firebrick1'    (255 48 48)
  5553             'firebrick2'    (238 44 44)
  5553 	    'firebrick2'    (238 44 44)
  5554             'firebrick3'    (205 38 38)
  5554 	    'firebrick3'    (205 38 38)
  5555             'firebrick4'    (139 26 26)
  5555 	    'firebrick4'    (139 26 26)
  5556             'floralwhite'   (255 250 240)
  5556 	    'floralwhite'   (255 250 240)
  5557             'forestgreen'   (34 139 34)
  5557 	    'forestgreen'   (34 139 34)
  5558             'gainsboro'     (220 220 220)
  5558 	    'gainsboro'     (220 220 220)
  5559             'ghostwhite'    (248 248 255)
  5559 	    'ghostwhite'    (248 248 255)
  5560             'gold'          (255 215 0)
  5560 	    'gold'          (255 215 0)
  5561             'gold1'         (255 215 0)
  5561 	    'gold1'         (255 215 0)
  5562             'gold2'         (238 201 0)
  5562 	    'gold2'         (238 201 0)
  5563             'gold3'         (205 173 0)
  5563 	    'gold3'         (205 173 0)
  5564             'gold4'         (139 117 0)
  5564 	    'gold4'         (139 117 0)
  5565             'goldenrod'     (218 165 32)
  5565 	    'goldenrod'     (218 165 32)
  5566             'goldenrod1'    (255 193 37)
  5566 	    'goldenrod1'    (255 193 37)
  5567             'goldenrod2'    (238 180 34)
  5567 	    'goldenrod2'    (238 180 34)
  5568             'goldenrod3'    (205 155 29)
  5568 	    'goldenrod3'    (205 155 29)
  5569             'goldenrod4'    (139 105 20)
  5569 	    'goldenrod4'    (139 105 20)
  5570             'grey'          (192 192 192)
  5570 	    'grey'          (192 192 192)
  5571             'grey0'         (0 0 0)
  5571 	    'grey0'         (0 0 0)
  5572             'grey1'         (3 3 3)
  5572 	    'grey1'         (3 3 3)
  5573             'grey10'        (26 26 26)
  5573 	    'grey10'        (26 26 26)
  5574             'grey100'       (255 255 255)
  5574 	    'grey100'       (255 255 255)
  5575             'grey11'        (28 28 28)
  5575 	    'grey11'        (28 28 28)
  5576             'grey12'        (31 31 31)
  5576 	    'grey12'        (31 31 31)
  5577             'grey13'        (33 33 33)
  5577 	    'grey13'        (33 33 33)
  5578             'grey14'        (36 36 36)
  5578 	    'grey14'        (36 36 36)
  5579             'grey15'        (38 38 38)
  5579 	    'grey15'        (38 38 38)
  5580             'grey16'        (41 41 41)
  5580 	    'grey16'        (41 41 41)
  5581             'grey17'        (43 43 43)
  5581 	    'grey17'        (43 43 43)
  5582             'grey18'        (46 46 46)
  5582 	    'grey18'        (46 46 46)
  5583             'grey19'        (48 48 48)
  5583 	    'grey19'        (48 48 48)
  5584             'grey2'         (5 5 5)
  5584 	    'grey2'         (5 5 5)
  5585             'grey20'        (51 51 51)
  5585 	    'grey20'        (51 51 51)
  5586             'grey21'        (54 54 54)
  5586 	    'grey21'        (54 54 54)
  5587             'grey22'        (56 56 56)
  5587 	    'grey22'        (56 56 56)
  5588             'grey23'        (59 59 59)
  5588 	    'grey23'        (59 59 59)
  5589             'grey24'        (61 61 61)
  5589 	    'grey24'        (61 61 61)
  5590             'grey25'        (64 64 64)
  5590 	    'grey25'        (64 64 64)
  5591             'grey26'        (66 66 66)
  5591 	    'grey26'        (66 66 66)
  5592             'grey27'        (69 69 69)
  5592 	    'grey27'        (69 69 69)
  5593             'grey28'        (71 71 71)
  5593 	    'grey28'        (71 71 71)
  5594             'grey29'        (74 74 74)
  5594 	    'grey29'        (74 74 74)
  5595             'grey3'         (8 8 8)
  5595 	    'grey3'         (8 8 8)
  5596             'grey30'        (77 77 77)
  5596 	    'grey30'        (77 77 77)
  5597             'grey31'        (79 79 79)
  5597 	    'grey31'        (79 79 79)
  5598             'grey32'        (82 82 82)
  5598 	    'grey32'        (82 82 82)
  5599             'grey33'        (84 84 84)
  5599 	    'grey33'        (84 84 84)
  5600             'grey34'        (87 87 87)
  5600 	    'grey34'        (87 87 87)
  5601             'grey35'        (89 89 89)
  5601 	    'grey35'        (89 89 89)
  5602             'grey36'        (92 92 92)
  5602 	    'grey36'        (92 92 92)
  5603             'grey37'        (94 94 94)
  5603 	    'grey37'        (94 94 94)
  5604             'grey38'        (97 97 97)
  5604 	    'grey38'        (97 97 97)
  5605             'grey39'        (99 99 99)
  5605 	    'grey39'        (99 99 99)
  5606             'grey4'         (10 10 10)
  5606 	    'grey4'         (10 10 10)
  5607             'grey40'        (102 102 102)
  5607 	    'grey40'        (102 102 102)
  5608             'grey41'        (105 105 105)
  5608 	    'grey41'        (105 105 105)
  5609             'grey42'        (107 107 107)
  5609 	    'grey42'        (107 107 107)
  5610             'grey43'        (110 110 110)
  5610 	    'grey43'        (110 110 110)
  5611             'grey44'        (112 112 112)
  5611 	    'grey44'        (112 112 112)
  5612             'grey45'        (115 115 115)
  5612 	    'grey45'        (115 115 115)
  5613             'grey46'        (117 117 117)
  5613 	    'grey46'        (117 117 117)
  5614             'grey47'        (120 120 120)
  5614 	    'grey47'        (120 120 120)
  5615             'grey48'        (122 122 122)
  5615 	    'grey48'        (122 122 122)
  5616             'grey49'        (125 125 125)
  5616 	    'grey49'        (125 125 125)
  5617             'grey5'         (13 13 13)
  5617 	    'grey5'         (13 13 13)
  5618             'grey50'        (127 127 127)
  5618 	    'grey50'        (127 127 127)
  5619             'grey51'        (130 130 130)
  5619 	    'grey51'        (130 130 130)
  5620             'grey52'        (133 133 133)
  5620 	    'grey52'        (133 133 133)
  5621             'grey53'        (135 135 135)
  5621 	    'grey53'        (135 135 135)
  5622             'grey54'        (138 138 138)
  5622 	    'grey54'        (138 138 138)
  5623             'grey55'        (140 140 140)
  5623 	    'grey55'        (140 140 140)
  5624             'grey56'        (143 143 143)
  5624 	    'grey56'        (143 143 143)
  5625             'grey57'        (145 145 145)
  5625 	    'grey57'        (145 145 145)
  5626             'grey58'        (148 148 148)
  5626 	    'grey58'        (148 148 148)
  5627             'grey59'        (150 150 150)
  5627 	    'grey59'        (150 150 150)
  5628             'grey6'         (15 15 15)
  5628 	    'grey6'         (15 15 15)
  5629             'grey60'        (153 153 153)
  5629 	    'grey60'        (153 153 153)
  5630             'grey61'        (156 156 156)
  5630 	    'grey61'        (156 156 156)
  5631             'grey62'        (158 158 158)
  5631 	    'grey62'        (158 158 158)
  5632             'grey63'        (161 161 161)
  5632 	    'grey63'        (161 161 161)
  5633             'grey64'        (163 163 163)
  5633 	    'grey64'        (163 163 163)
  5634             'grey65'        (166 166 166)
  5634 	    'grey65'        (166 166 166)
  5635             'grey66'        (168 168 168)
  5635 	    'grey66'        (168 168 168)
  5636             'grey67'        (171 171 171)
  5636 	    'grey67'        (171 171 171)
  5637             'grey68'        (173 173 173)
  5637 	    'grey68'        (173 173 173)
  5638             'grey69'        (176 176 176)
  5638 	    'grey69'        (176 176 176)
  5639             'grey7'         (18 18 18)
  5639 	    'grey7'         (18 18 18)
  5640             'grey70'        (179 179 179)
  5640 	    'grey70'        (179 179 179)
  5641             'grey71'        (181 181 181)
  5641 	    'grey71'        (181 181 181)
  5642             'grey72'        (184 184 184)
  5642 	    'grey72'        (184 184 184)
  5643             'grey73'        (186 186 186)
  5643 	    'grey73'        (186 186 186)
  5644             'grey74'        (189 189 189)
  5644 	    'grey74'        (189 189 189)
  5645             'grey75'        (191 191 191)
  5645 	    'grey75'        (191 191 191)
  5646             'grey76'        (194 194 194)
  5646 	    'grey76'        (194 194 194)
  5647             'grey77'        (196 196 196)
  5647 	    'grey77'        (196 196 196)
  5648             'grey78'        (199 199 199)
  5648 	    'grey78'        (199 199 199)
  5649             'grey79'        (201 201 201)
  5649 	    'grey79'        (201 201 201)
  5650             'grey8'         (20 20 20)
  5650 	    'grey8'         (20 20 20)
  5651             'grey80'        (204 204 204)
  5651 	    'grey80'        (204 204 204)
  5652             'grey81'        (207 207 207)
  5652 	    'grey81'        (207 207 207)
  5653             'grey82'        (209 209 209)
  5653 	    'grey82'        (209 209 209)
  5654             'grey83'        (212 212 212)
  5654 	    'grey83'        (212 212 212)
  5655             'grey84'        (214 214 214)
  5655 	    'grey84'        (214 214 214)
  5656             'grey85'        (217 217 217)
  5656 	    'grey85'        (217 217 217)
  5657             'grey86'        (219 219 219)
  5657 	    'grey86'        (219 219 219)
  5658             'grey87'        (222 222 222)
  5658 	    'grey87'        (222 222 222)
  5659             'grey88'        (224 224 224)
  5659 	    'grey88'        (224 224 224)
  5660             'grey89'        (227 227 227)
  5660 	    'grey89'        (227 227 227)
  5661             'grey9'         (23 23 23)
  5661 	    'grey9'         (23 23 23)
  5662             'grey90'        (229 229 229)
  5662 	    'grey90'        (229 229 229)
  5663             'grey91'        (232 232 232)
  5663 	    'grey91'        (232 232 232)
  5664             'grey92'        (235 235 235)
  5664 	    'grey92'        (235 235 235)
  5665             'grey93'        (237 237 237)
  5665 	    'grey93'        (237 237 237)
  5666             'grey94'        (240 240 240)
  5666 	    'grey94'        (240 240 240)
  5667             'grey95'        (242 242 242)
  5667 	    'grey95'        (242 242 242)
  5668             'grey96'        (245 245 245)
  5668 	    'grey96'        (245 245 245)
  5669             'grey97'        (247 247 247)
  5669 	    'grey97'        (247 247 247)
  5670             'grey98'        (250 250 250)
  5670 	    'grey98'        (250 250 250)
  5671             'grey99'        (252 252 252)
  5671 	    'grey99'        (252 252 252)
  5672             'gray'          (192 192 192)
  5672 	    'gray'          (192 192 192)
  5673             'gray0'         (0 0 0)
  5673 	    'gray0'         (0 0 0)
  5674             'gray1'         (3 3 3)
  5674 	    'gray1'         (3 3 3)
  5675             'gray10'        (26 26 26)
  5675 	    'gray10'        (26 26 26)
  5676             'gray100'       (255 255 255)
  5676 	    'gray100'       (255 255 255)
  5677             'gray11'        (28 28 28)
  5677 	    'gray11'        (28 28 28)
  5678             'gray12'        (31 31 31)
  5678 	    'gray12'        (31 31 31)
  5679             'gray13'        (33 33 33)
  5679 	    'gray13'        (33 33 33)
  5680             'gray14'        (36 36 36)
  5680 	    'gray14'        (36 36 36)
  5681             'gray15'        (38 38 38)
  5681 	    'gray15'        (38 38 38)
  5682             'gray16'        (41 41 41)
  5682 	    'gray16'        (41 41 41)
  5683             'gray17'        (43 43 43)
  5683 	    'gray17'        (43 43 43)
  5684             'gray18'        (46 46 46)
  5684 	    'gray18'        (46 46 46)
  5685             'gray19'        (48 48 48)
  5685 	    'gray19'        (48 48 48)
  5686             'gray2'         (5 5 5)
  5686 	    'gray2'         (5 5 5)
  5687             'gray20'        (51 51 51)
  5687 	    'gray20'        (51 51 51)
  5688             'gray21'        (54 54 54)
  5688 	    'gray21'        (54 54 54)
  5689             'gray22'        (56 56 56)
  5689 	    'gray22'        (56 56 56)
  5690             'gray23'        (59 59 59)
  5690 	    'gray23'        (59 59 59)
  5691             'gray24'        (61 61 61)
  5691 	    'gray24'        (61 61 61)
  5692             'gray25'        (64 64 64)
  5692 	    'gray25'        (64 64 64)
  5693             'gray26'        (66 66 66)
  5693 	    'gray26'        (66 66 66)
  5694             'gray27'        (69 69 69)
  5694 	    'gray27'        (69 69 69)
  5695             'gray28'        (71 71 71)
  5695 	    'gray28'        (71 71 71)
  5696             'gray29'        (74 74 74)
  5696 	    'gray29'        (74 74 74)
  5697             'gray3'         (8 8 8)
  5697 	    'gray3'         (8 8 8)
  5698             'gray30'        (77 77 77)
  5698 	    'gray30'        (77 77 77)
  5699             'gray31'        (79 79 79)
  5699 	    'gray31'        (79 79 79)
  5700             'gray32'        (82 82 82)
  5700 	    'gray32'        (82 82 82)
  5701             'gray33'        (84 84 84)
  5701 	    'gray33'        (84 84 84)
  5702             'gray34'        (87 87 87)
  5702 	    'gray34'        (87 87 87)
  5703             'gray35'        (89 89 89)
  5703 	    'gray35'        (89 89 89)
  5704             'gray36'        (92 92 92)
  5704 	    'gray36'        (92 92 92)
  5705             'gray37'        (94 94 94)
  5705 	    'gray37'        (94 94 94)
  5706             'gray38'        (97 97 97)
  5706 	    'gray38'        (97 97 97)
  5707             'gray39'        (99 99 99)
  5707 	    'gray39'        (99 99 99)
  5708             'gray4'         (10 10 10)
  5708 	    'gray4'         (10 10 10)
  5709             'gray40'        (102 102 102)
  5709 	    'gray40'        (102 102 102)
  5710             'gray41'        (105 105 105)
  5710 	    'gray41'        (105 105 105)
  5711             'gray42'        (107 107 107)
  5711 	    'gray42'        (107 107 107)
  5712             'gray43'        (110 110 110)
  5712 	    'gray43'        (110 110 110)
  5713             'gray44'        (112 112 112)
  5713 	    'gray44'        (112 112 112)
  5714             'gray45'        (115 115 115)
  5714 	    'gray45'        (115 115 115)
  5715             'gray46'        (117 117 117)
  5715 	    'gray46'        (117 117 117)
  5716             'gray47'        (120 120 120)
  5716 	    'gray47'        (120 120 120)
  5717             'gray48'        (122 122 122)
  5717 	    'gray48'        (122 122 122)
  5718             'gray49'        (125 125 125)
  5718 	    'gray49'        (125 125 125)
  5719             'gray5'         (13 13 13)
  5719 	    'gray5'         (13 13 13)
  5720             'gray50'        (127 127 127)
  5720 	    'gray50'        (127 127 127)
  5721             'gray51'        (130 130 130)
  5721 	    'gray51'        (130 130 130)
  5722             'gray52'        (133 133 133)
  5722 	    'gray52'        (133 133 133)
  5723             'gray53'        (135 135 135)
  5723 	    'gray53'        (135 135 135)
  5724             'gray54'        (138 138 138)
  5724 	    'gray54'        (138 138 138)
  5725             'gray55'        (140 140 140)
  5725 	    'gray55'        (140 140 140)
  5726             'gray56'        (143 143 143)
  5726 	    'gray56'        (143 143 143)
  5727             'gray57'        (145 145 145)
  5727 	    'gray57'        (145 145 145)
  5728             'gray58'        (148 148 148)
  5728 	    'gray58'        (148 148 148)
  5729             'gray59'        (150 150 150)
  5729 	    'gray59'        (150 150 150)
  5730             'gray6'         (15 15 15)
  5730 	    'gray6'         (15 15 15)
  5731             'gray60'        (153 153 153)
  5731 	    'gray60'        (153 153 153)
  5732             'gray61'        (156 156 156)
  5732 	    'gray61'        (156 156 156)
  5733             'gray62'        (158 158 158)
  5733 	    'gray62'        (158 158 158)
  5734             'gray63'        (161 161 161)
  5734 	    'gray63'        (161 161 161)
  5735             'gray64'        (163 163 163)
  5735 	    'gray64'        (163 163 163)
  5736             'gray65'        (166 166 166)
  5736 	    'gray65'        (166 166 166)
  5737             'gray66'        (168 168 168)
  5737 	    'gray66'        (168 168 168)
  5738             'gray67'        (171 171 171)
  5738 	    'gray67'        (171 171 171)
  5739             'gray68'        (173 173 173)
  5739 	    'gray68'        (173 173 173)
  5740             'gray69'        (176 176 176)
  5740 	    'gray69'        (176 176 176)
  5741             'gray7'         (18 18 18)
  5741 	    'gray7'         (18 18 18)
  5742             'gray70'        (179 179 179)
  5742 	    'gray70'        (179 179 179)
  5743             'gray71'        (181 181 181)
  5743 	    'gray71'        (181 181 181)
  5744             'gray72'        (184 184 184)
  5744 	    'gray72'        (184 184 184)
  5745             'gray73'        (186 186 186)
  5745 	    'gray73'        (186 186 186)
  5746             'gray74'        (189 189 189)
  5746 	    'gray74'        (189 189 189)
  5747             'gray75'        (191 191 191)
  5747 	    'gray75'        (191 191 191)
  5748             'gray76'        (194 194 194)
  5748 	    'gray76'        (194 194 194)
  5749             'gray77'        (196 196 196)
  5749 	    'gray77'        (196 196 196)
  5750             'gray78'        (199 199 199)
  5750 	    'gray78'        (199 199 199)
  5751             'gray79'        (201 201 201)
  5751 	    'gray79'        (201 201 201)
  5752             'gray8'         (20 20 20)
  5752 	    'gray8'         (20 20 20)
  5753             'gray80'        (204 204 204)
  5753 	    'gray80'        (204 204 204)
  5754             'gray81'        (207 207 207)
  5754 	    'gray81'        (207 207 207)
  5755             'gray82'        (209 209 209)
  5755 	    'gray82'        (209 209 209)
  5756             'gray83'        (212 212 212)
  5756 	    'gray83'        (212 212 212)
  5757             'gray84'        (214 214 214)
  5757 	    'gray84'        (214 214 214)
  5758             'gray85'        (217 217 217)
  5758 	    'gray85'        (217 217 217)
  5759             'gray86'        (219 219 219)
  5759 	    'gray86'        (219 219 219)
  5760             'gray87'        (222 222 222)
  5760 	    'gray87'        (222 222 222)
  5761             'gray88'        (224 224 224)
  5761 	    'gray88'        (224 224 224)
  5762             'gray89'        (227 227 227)
  5762 	    'gray89'        (227 227 227)
  5763             'gray9'         (23 23 23)
  5763 	    'gray9'         (23 23 23)
  5764             'gray90'        (229 229 229)
  5764 	    'gray90'        (229 229 229)
  5765             'gray91'        (232 232 232)
  5765 	    'gray91'        (232 232 232)
  5766             'gray92'        (235 235 235)
  5766 	    'gray92'        (235 235 235)
  5767             'gray93'        (237 237 237)
  5767 	    'gray93'        (237 237 237)
  5768             'gray94'        (240 240 240)
  5768 	    'gray94'        (240 240 240)
  5769             'gray95'        (242 242 242)
  5769 	    'gray95'        (242 242 242)
  5770             'gray96'        (245 245 245)
  5770 	    'gray96'        (245 245 245)
  5771             'gray97'        (247 247 247)
  5771 	    'gray97'        (247 247 247)
  5772             'gray98'        (250 250 250)
  5772 	    'gray98'        (250 250 250)
  5773             'gray99'        (252 252 252)
  5773 	    'gray99'        (252 252 252)
  5774             'green'         (0 255 0)
  5774 	    'green'         (0 255 0)
  5775             'greenyellow'   (173 255 47)
  5775 	    'greenyellow'   (173 255 47)
  5776             'green1'        (0 255 0)
  5776 	    'green1'        (0 255 0)
  5777             'green2'        (0 238 0)
  5777 	    'green2'        (0 238 0)
  5778             'green3'        (0 205 0)
  5778 	    'green3'        (0 205 0)
  5779             'green4'        (0 139 0)
  5779 	    'green4'        (0 139 0)
  5780             'honeydew'      (240 255 240)
  5780 	    'honeydew'      (240 255 240)
  5781             'honeydew1'     (240 255 240)
  5781 	    'honeydew1'     (240 255 240)
  5782             'honeydew2'     (224 238 224)
  5782 	    'honeydew2'     (224 238 224)
  5783             'honeydew3'     (193 205 193)
  5783 	    'honeydew3'     (193 205 193)
  5784             'honeydew4'     (131 139 131)
  5784 	    'honeydew4'     (131 139 131)
  5785             'hotpink'       (255 105 180)
  5785 	    'hotpink'       (255 105 180)
  5786             'HotPink1'      (255 110 180)
  5786 	    'HotPink1'      (255 110 180)
  5787             'HotPink2'      (238 106 167)
  5787 	    'HotPink2'      (238 106 167)
  5788             'HotPink3'      (205 96 144)
  5788 	    'HotPink3'      (205 96 144)
  5789             'HotPink4'      (139 58 98)
  5789 	    'HotPink4'      (139 58 98)
  5790             'indianred'     (205 92 92)
  5790 	    'indianred'     (205 92 92)
  5791             'IndianRed1'    (255 106 106)
  5791 	    'IndianRed1'    (255 106 106)
  5792             'IndianRed2'    (238 99 99)
  5792 	    'IndianRed2'    (238 99 99)
  5793             'IndianRed3'    (205 85 85)
  5793 	    'IndianRed3'    (205 85 85)
  5794             'IndianRed4'    (139 58 58)
  5794 	    'IndianRed4'    (139 58 58)
  5795             'ivory'         (255 255 240)
  5795 	    'ivory'         (255 255 240)
  5796             'ivory1'        (255 255 240)
  5796 	    'ivory1'        (255 255 240)
  5797             'ivory2'        (238 238 224)
  5797 	    'ivory2'        (238 238 224)
  5798             'ivory3'        (205 205 193)
  5798 	    'ivory3'        (205 205 193)
  5799             'ivory4'        (139 139 131)
  5799 	    'ivory4'        (139 139 131)
  5800             'khaki'         (240 230 140)
  5800 	    'khaki'         (240 230 140)
  5801             'khaki1'        (255 246 143)
  5801 	    'khaki1'        (255 246 143)
  5802             'khaki2'        (238 230 133)
  5802 	    'khaki2'        (238 230 133)
  5803             'khaki3'        (205 198 115)
  5803 	    'khaki3'        (205 198 115)
  5804             'khaki4'        (139 134 78)
  5804 	    'khaki4'        (139 134 78)
  5805             'lavender'      (230 230 250)
  5805 	    'lavender'      (230 230 250)
  5806             'lavenderblush'         (255 240 245)
  5806 	    'lavenderblush'         (255 240 245)
  5807             'LavenderBlush1'        (255 240 245)
  5807 	    'LavenderBlush1'        (255 240 245)
  5808             'LavenderBlush2'        (238 224 229)
  5808 	    'LavenderBlush2'        (238 224 229)
  5809             'LavenderBlush3'        (205 193 197)
  5809 	    'LavenderBlush3'        (205 193 197)
  5810             'LavenderBlush4'        (139 131 134)
  5810 	    'LavenderBlush4'        (139 131 134)
  5811             'lawngreen'     (124 252 0)
  5811 	    'lawngreen'     (124 252 0)
  5812             'lemonchiffon'  (255 250 205)
  5812 	    'lemonchiffon'  (255 250 205)
  5813             'LemonChiffon1'         (255 250 205)
  5813 	    'LemonChiffon1'         (255 250 205)
  5814             'LemonChiffon2'         (238 233 191)
  5814 	    'LemonChiffon2'         (238 233 191)
  5815             'LemonChiffon3'         (205 201 165)
  5815 	    'LemonChiffon3'         (205 201 165)
  5816             'LemonChiffon4'         (139 137 112)
  5816 	    'LemonChiffon4'         (139 137 112)
  5817             'lightblue'     (173 216 230)
  5817 	    'lightblue'     (173 216 230)
  5818             'lightcoral'    (240 128 128)
  5818 	    'lightcoral'    (240 128 128)
  5819             'lightcyan'     (224 255 255)
  5819 	    'lightcyan'     (224 255 255)
  5820             'lightgoldenrod'        (238 221 130)
  5820 	    'lightgoldenrod'        (238 221 130)
  5821             'lightgoldenrodyellow'  (250 250 210)
  5821 	    'lightgoldenrodyellow'  (250 250 210)
  5822             'lightgray'     (211 211 211)
  5822 	    'lightgray'     (211 211 211)
  5823             'lightgreen'    (144 238 144)
  5823 	    'lightgreen'    (144 238 144)
  5824             'lightgrey'     (211 211 211)
  5824 	    'lightgrey'     (211 211 211)
  5825             'lightpink'     (255 182 193)
  5825 	    'lightpink'     (255 182 193)
  5826             'lightsalmon'   (255 160 122)
  5826 	    'lightsalmon'   (255 160 122)
  5827             'lightseagreen' (32 178 170)
  5827 	    'lightseagreen' (32 178 170)
  5828             'lightskyblue'  (135 206 250)
  5828 	    'lightskyblue'  (135 206 250)
  5829             'lightslateblue'        (132 112 255)
  5829 	    'lightslateblue'        (132 112 255)
  5830             'lightslategray'        (119 136 153)
  5830 	    'lightslategray'        (119 136 153)
  5831             'lightslategrey'        (119 136 153)
  5831 	    'lightslategrey'        (119 136 153)
  5832             'lightsteelblue'        (176 196 222)
  5832 	    'lightsteelblue'        (176 196 222)
  5833             'lightyellow'   (255 255 224)
  5833 	    'lightyellow'   (255 255 224)
  5834             'LightBlue1'    (191 239 255)
  5834 	    'LightBlue1'    (191 239 255)
  5835             'LightBlue2'    (178 223 238)
  5835 	    'LightBlue2'    (178 223 238)
  5836             'LightBlue3'    (154 192 205)
  5836 	    'LightBlue3'    (154 192 205)
  5837             'LightBlue4'    (104 131 139)
  5837 	    'LightBlue4'    (104 131 139)
  5838             'LightCyan1'    (224 255 255)
  5838 	    'LightCyan1'    (224 255 255)
  5839             'LightCyan2'    (209 238 238)
  5839 	    'LightCyan2'    (209 238 238)
  5840             'LightCyan3'    (180 205 205)
  5840 	    'LightCyan3'    (180 205 205)
  5841             'LightCyan4'    (122 139 139)
  5841 	    'LightCyan4'    (122 139 139)
  5842             'LightGoldenrod1'       (255 236 139)
  5842 	    'LightGoldenrod1'       (255 236 139)
  5843             'LightGoldenrod2'       (238 220 130)
  5843 	    'LightGoldenrod2'       (238 220 130)
  5844             'LightGoldenrod3'       (205 190 112)
  5844 	    'LightGoldenrod3'       (205 190 112)
  5845             'LightGoldenrod4'       (139 129 76)
  5845 	    'LightGoldenrod4'       (139 129 76)
  5846             'LightPink1'    (255 174 185)
  5846 	    'LightPink1'    (255 174 185)
  5847             'LightPink2'    (238 162 173)
  5847 	    'LightPink2'    (238 162 173)
  5848             'LightPink3'    (205 140 149)
  5848 	    'LightPink3'    (205 140 149)
  5849             'LightPink4'    (139 95 101)
  5849 	    'LightPink4'    (139 95 101)
  5850             'LightSalmon1'  (255 160 122)
  5850 	    'LightSalmon1'  (255 160 122)
  5851             'LightSalmon2'  (238 149 114)
  5851 	    'LightSalmon2'  (238 149 114)
  5852             'LightSalmon3'  (205 129 98)
  5852 	    'LightSalmon3'  (205 129 98)
  5853             'LightSalmon4'  (139 87 66)
  5853 	    'LightSalmon4'  (139 87 66)
  5854             'LightSkyBlue1'         (176 226 255)
  5854 	    'LightSkyBlue1'         (176 226 255)
  5855             'LightSkyBlue2'         (164 211 238)
  5855 	    'LightSkyBlue2'         (164 211 238)
  5856             'LightSkyBlue3'         (141 182 205)
  5856 	    'LightSkyBlue3'         (141 182 205)
  5857             'LightSkyBlue4'         (96 123 139)
  5857 	    'LightSkyBlue4'         (96 123 139)
  5858             'LightSteelBlue1'       (202 225 255)
  5858 	    'LightSteelBlue1'       (202 225 255)
  5859             'LightSteelBlue2'       (188 210 238)
  5859 	    'LightSteelBlue2'       (188 210 238)
  5860             'LightSteelBlue3'       (162 181 205)
  5860 	    'LightSteelBlue3'       (162 181 205)
  5861             'LightSteelBlue4'       (110 123 139)
  5861 	    'LightSteelBlue4'       (110 123 139)
  5862             'LightYellow1'  (255 255 224)
  5862 	    'LightYellow1'  (255 255 224)
  5863             'LightYellow2'  (238 238 209)
  5863 	    'LightYellow2'  (238 238 209)
  5864             'LightYellow3'  (205 205 180)
  5864 	    'LightYellow3'  (205 205 180)
  5865             'LightYellow4'  (139 139 122)
  5865 	    'LightYellow4'  (139 139 122)
  5866             'limegreen'     (50 205 50)
  5866 	    'limegreen'     (50 205 50)
  5867             'linen'         (250 240 230)
  5867 	    'linen'         (250 240 230)
  5868             'magenta'       (255 0 255)
  5868 	    'magenta'       (255 0 255)
  5869             'magenta1'      (255 0 255)
  5869 	    'magenta1'      (255 0 255)
  5870             'magenta2'      (238 0 238)
  5870 	    'magenta2'      (238 0 238)
  5871             'magenta3'      (205 0 205)
  5871 	    'magenta3'      (205 0 205)
  5872             'magenta4'      (139 0 139)
  5872 	    'magenta4'      (139 0 139)
  5873             'maroon'        (176 48 96)
  5873 	    'maroon'        (176 48 96)
  5874             'maroon1'       (255 52 179)
  5874 	    'maroon1'       (255 52 179)
  5875             'maroon2'       (238 48 167)
  5875 	    'maroon2'       (238 48 167)
  5876             'maroon3'       (205 41 144)
  5876 	    'maroon3'       (205 41 144)
  5877             'maroon4'       (139 28 98)
  5877 	    'maroon4'       (139 28 98)
  5878             'mediumaquamarine'      (102 205 170)
  5878 	    'mediumaquamarine'      (102 205 170)
  5879             'mediumblue'    (0 0 205)
  5879 	    'mediumblue'    (0 0 205)
  5880             'mediumorchid'  (186 85 211)
  5880 	    'mediumorchid'  (186 85 211)
  5881             'mediumpurple'  (147 112 219)
  5881 	    'mediumpurple'  (147 112 219)
  5882             'mediumseagreen'        (60 179 113)
  5882 	    'mediumseagreen'        (60 179 113)
  5883             'mediumslateblue'       (123 104 238)
  5883 	    'mediumslateblue'       (123 104 238)
  5884             'mediumspringgreen'     (0 250 154)
  5884 	    'mediumspringgreen'     (0 250 154)
  5885             'mediumturquoise'       (72 209 204)
  5885 	    'mediumturquoise'       (72 209 204)
  5886             'mediumvioletred'       (199 21 133)
  5886 	    'mediumvioletred'       (199 21 133)
  5887             'MediumOrchid1'         (224 102 255)
  5887 	    'MediumOrchid1'         (224 102 255)
  5888             'MediumOrchid2' (209 95 238)
  5888 	    'MediumOrchid2' (209 95 238)
  5889             'MediumOrchid3' (180 82 205)
  5889 	    'MediumOrchid3' (180 82 205)
  5890             'MediumOrchid4' (122 55 139)
  5890 	    'MediumOrchid4' (122 55 139)
  5891             'MediumPurple1' (171 130 255)
  5891 	    'MediumPurple1' (171 130 255)
  5892             'MediumPurple2' (159 121 238)
  5892 	    'MediumPurple2' (159 121 238)
  5893             'MediumPurple3' (137 104 205)
  5893 	    'MediumPurple3' (137 104 205)
  5894             'MediumPurple4' (93 71 139)
  5894 	    'MediumPurple4' (93 71 139)
  5895             'midnightblue'  (25 25 112)
  5895 	    'midnightblue'  (25 25 112)
  5896             'mintcream'     (245 255 250)
  5896 	    'mintcream'     (245 255 250)
  5897             'mistyrose'     (255 228 225)
  5897 	    'mistyrose'     (255 228 225)
  5898             'MistyRose1'    (255 228 225)
  5898 	    'MistyRose1'    (255 228 225)
  5899             'MistyRose2'    (238 213 210)
  5899 	    'MistyRose2'    (238 213 210)
  5900             'MistyRose3'    (205 183 181)
  5900 	    'MistyRose3'    (205 183 181)
  5901             'MistyRose4'    (139 125 123)
  5901 	    'MistyRose4'    (139 125 123)
  5902             'moccasin'      (255 228 181)
  5902 	    'moccasin'      (255 228 181)
  5903             'navajowhite'   (255 222 173)
  5903 	    'navajowhite'   (255 222 173)
  5904             'NavajoWhite1'  (255 222 173)
  5904 	    'NavajoWhite1'  (255 222 173)
  5905             'NavajoWhite2'  (238 207 161)
  5905 	    'NavajoWhite2'  (238 207 161)
  5906             'NavajoWhite3'  (205 179 139)
  5906 	    'NavajoWhite3'  (205 179 139)
  5907             'NavajoWhite4'  (139 121 94)
  5907 	    'NavajoWhite4'  (139 121 94)
  5908             'navy'          (0 0 128)
  5908 	    'navy'          (0 0 128)
  5909             'navyblue'      (0 0 128)
  5909 	    'navyblue'      (0 0 128)
  5910             'oldlace'       (253 245 230)
  5910 	    'oldlace'       (253 245 230)
  5911             'olivedrab'     (107 142 35)
  5911 	    'olivedrab'     (107 142 35)
  5912             'OliveDrab1'    (192 255 62)
  5912 	    'OliveDrab1'    (192 255 62)
  5913             'OliveDrab2'    (179 238 58)
  5913 	    'OliveDrab2'    (179 238 58)
  5914             'OliveDrab3'    (154 205 50)
  5914 	    'OliveDrab3'    (154 205 50)
  5915             'OliveDrab4'    (105 139 34)
  5915 	    'OliveDrab4'    (105 139 34)
  5916             'orange'        (255 165 0)
  5916 	    'orange'        (255 165 0)
  5917             'orange1'       (255 165 0)
  5917 	    'orange1'       (255 165 0)
  5918             'orange2'       (238 154 0)
  5918 	    'orange2'       (238 154 0)
  5919             'orange3'       (205 133 0)
  5919 	    'orange3'       (205 133 0)
  5920             'orange4'       (139 90 0)
  5920 	    'orange4'       (139 90 0)
  5921             'orangered'     (255 69 0)
  5921 	    'orangered'     (255 69 0)
  5922             'OrangeRed1'    (255 69 0)
  5922 	    'OrangeRed1'    (255 69 0)
  5923             'OrangeRed2'    (238 64 0)
  5923 	    'OrangeRed2'    (238 64 0)
  5924             'OrangeRed3'    (205 55 0)
  5924 	    'OrangeRed3'    (205 55 0)
  5925             'OrangeRed4'    (139 37 0)
  5925 	    'OrangeRed4'    (139 37 0)
  5926             'orchid'        (218 112 214)
  5926 	    'orchid'        (218 112 214)
  5927             'orchid1'       (255 131 250)
  5927 	    'orchid1'       (255 131 250)
  5928             'orchid2'       (238 122 233)
  5928 	    'orchid2'       (238 122 233)
  5929             'orchid3'       (205 105 201)
  5929 	    'orchid3'       (205 105 201)
  5930             'orchid4'       (139 71 137)
  5930 	    'orchid4'       (139 71 137)
  5931             'palegoldenrod' (238 232 170)
  5931 	    'palegoldenrod' (238 232 170)
  5932             'palegreen'     (152 251 152)
  5932 	    'palegreen'     (152 251 152)
  5933             'paleturquoise' (175 238 238)
  5933 	    'paleturquoise' (175 238 238)
  5934             'palevioletred' (219 112 147)
  5934 	    'palevioletred' (219 112 147)
  5935             'PaleGreen1'    (154 255 154)
  5935 	    'PaleGreen1'    (154 255 154)
  5936             'PaleGreen2'    (144 238 144)
  5936 	    'PaleGreen2'    (144 238 144)
  5937             'PaleGreen3'    (124 205 124)
  5937 	    'PaleGreen3'    (124 205 124)
  5938             'PaleGreen4'    (84 139 84)
  5938 	    'PaleGreen4'    (84 139 84)
  5939             'PaleTurquoise1'        (187 255 255)
  5939 	    'PaleTurquoise1'        (187 255 255)
  5940             'PaleTurquoise2'        (174 238 238)
  5940 	    'PaleTurquoise2'        (174 238 238)
  5941             'PaleTurquoise3'        (150 205 205)
  5941 	    'PaleTurquoise3'        (150 205 205)
  5942             'PaleTurquoise4'        (102 139 139)
  5942 	    'PaleTurquoise4'        (102 139 139)
  5943             'PaleVioletRed1'        (255 130 171)
  5943 	    'PaleVioletRed1'        (255 130 171)
  5944             'PaleVioletRed2'        (238 121 159)
  5944 	    'PaleVioletRed2'        (238 121 159)
  5945             'PaleVioletRed3'        (205 104 137)
  5945 	    'PaleVioletRed3'        (205 104 137)
  5946             'PaleVioletRed4'        (139 71 93)
  5946 	    'PaleVioletRed4'        (139 71 93)
  5947             'papayawhip'    (255 239 213)
  5947 	    'papayawhip'    (255 239 213)
  5948             'peachpuff'     (255 218 185)
  5948 	    'peachpuff'     (255 218 185)
  5949             'PeachPuff1'    (255 218 185)
  5949 	    'PeachPuff1'    (255 218 185)
  5950             'PeachPuff2'    (238 203 173)
  5950 	    'PeachPuff2'    (238 203 173)
  5951             'PeachPuff3'    (205 175 149)
  5951 	    'PeachPuff3'    (205 175 149)
  5952             'PeachPuff4'    (139 119 101)
  5952 	    'PeachPuff4'    (139 119 101)
  5953             'peru'  (205 133 63)
  5953 	    'peru'  (205 133 63)
  5954             'pink'  (255 192 203)
  5954 	    'pink'  (255 192 203)
  5955             'pink1' (255 181 197)
  5955 	    'pink1' (255 181 197)
  5956             'pink2' (238 169 184)
  5956 	    'pink2' (238 169 184)
  5957             'pink3' (205 145 158)
  5957 	    'pink3' (205 145 158)
  5958             'pink4' (139 99 108)
  5958 	    'pink4' (139 99 108)
  5959             'plum'  (221 160 221)
  5959 	    'plum'  (221 160 221)
  5960             'plum1' (255 187 255)
  5960 	    'plum1' (255 187 255)
  5961             'plum2' (238 174 238)
  5961 	    'plum2' (238 174 238)
  5962             'plum3' (205 150 205)
  5962 	    'plum3' (205 150 205)
  5963             'plum4' (139 102 139)
  5963 	    'plum4' (139 102 139)
  5964             'powderblue'    (176 224 230)
  5964 	    'powderblue'    (176 224 230)
  5965             'purple'        (160 32 240)
  5965 	    'purple'        (160 32 240)
  5966             'purple1'       (155 48 255)
  5966 	    'purple1'       (155 48 255)
  5967             'purple2'       (145 44 238)
  5967 	    'purple2'       (145 44 238)
  5968             'purple3'       (125 38 205)
  5968 	    'purple3'       (125 38 205)
  5969             'purple4'       (85 26 139)
  5969 	    'purple4'       (85 26 139)
  5970             'red'   (255 0 0)
  5970 	    'red'   (255 0 0)
  5971             'red1'  (255 0 0)
  5971 	    'red1'  (255 0 0)
  5972             'red2'  (238 0 0)
  5972 	    'red2'  (238 0 0)
  5973             'red3'  (205 0 0)
  5973 	    'red3'  (205 0 0)
  5974             'red4'  (139 0 0)
  5974 	    'red4'  (139 0 0)
  5975             'rosybrown'     (188 143 143)
  5975 	    'rosybrown'     (188 143 143)
  5976             'RosyBrown1'    (255 193 193)
  5976 	    'RosyBrown1'    (255 193 193)
  5977             'RosyBrown2'    (238 180 180)
  5977 	    'RosyBrown2'    (238 180 180)
  5978             'RosyBrown3'    (205 155 155)
  5978 	    'RosyBrown3'    (205 155 155)
  5979             'RosyBrown4'    (139 105 105)
  5979 	    'RosyBrown4'    (139 105 105)
  5980             'royalblue'     (65 105 225)
  5980 	    'royalblue'     (65 105 225)
  5981             'RoyalBlue1'    (72 118 255)
  5981 	    'RoyalBlue1'    (72 118 255)
  5982             'RoyalBlue2'    (67 110 238)
  5982 	    'RoyalBlue2'    (67 110 238)
  5983             'RoyalBlue3'    (58 95 205)
  5983 	    'RoyalBlue3'    (58 95 205)
  5984             'RoyalBlue4'    (39 64 139)
  5984 	    'RoyalBlue4'    (39 64 139)
  5985             'saddlebrown'   (139 69 19)
  5985 	    'saddlebrown'   (139 69 19)
  5986             'salmon'        (250 128 114)
  5986 	    'salmon'        (250 128 114)
  5987             'salmon1'       (255 140 105)
  5987 	    'salmon1'       (255 140 105)
  5988             'salmon2'       (238 130 98)
  5988 	    'salmon2'       (238 130 98)
  5989             'salmon3'       (205 112 84)
  5989 	    'salmon3'       (205 112 84)
  5990             'salmon4'       (139 76 57)
  5990 	    'salmon4'       (139 76 57)
  5991             'sandybrown'    (244 164 96)
  5991 	    'sandybrown'    (244 164 96)
  5992             'scoActiveBackground'   (255 206 137)
  5992 	    'scoActiveBackground'   (255 206 137)
  5993             'scoActiveForeground'   (43 45 49)
  5993 	    'scoActiveForeground'   (43 45 49)
  5994             'scoActiveTopShadow'    (254 222 255)
  5994 	    'scoActiveTopShadow'    (254 222 255)
  5995             'scoAltBackground'      (172 186 204)
  5995 	    'scoAltBackground'      (172 186 204)
  5996             'scoBackground' (203 203 192)
  5996 	    'scoBackground' (203 203 192)
  5997             'scoForeground' (11 0 113)
  5997 	    'scoForeground' (11 0 113)
  5998             'scoHighlight'  (141 178 215)
  5998 	    'scoHighlight'  (141 178 215)
  5999             'scoTopShadow'  (255 240 248)
  5999 	    'scoTopShadow'  (255 240 248)
  6000             'seagreen'      (46 139 87)
  6000 	    'seagreen'      (46 139 87)
  6001             'SeaGreen1'     (84 255 159)
  6001 	    'SeaGreen1'     (84 255 159)
  6002             'SeaGreen2'     (78 238 148)
  6002 	    'SeaGreen2'     (78 238 148)
  6003             'SeaGreen3'     (67 205 128)
  6003 	    'SeaGreen3'     (67 205 128)
  6004             'SeaGreen4'     (46 139 87)
  6004 	    'SeaGreen4'     (46 139 87)
  6005             'seashell'      (255 245 238)
  6005 	    'seashell'      (255 245 238)
  6006             'seashell1'     (255 245 238)
  6006 	    'seashell1'     (255 245 238)
  6007             'seashell2'     (238 229 222)
  6007 	    'seashell2'     (238 229 222)
  6008             'seashell3'     (205 197 191)
  6008 	    'seashell3'     (205 197 191)
  6009             'seashell4'     (139 134 130)
  6009 	    'seashell4'     (139 134 130)
  6010             'sgi beet'      (142 56 142)
  6010 	    'sgi beet'      (142 56 142)
  6011             'sgi bright gray'       (197 193 170)
  6011 	    'sgi bright gray'       (197 193 170)
  6012             'sgi bright grey'       (197 193 170)
  6012 	    'sgi bright grey'       (197 193 170)
  6013             'sgi chartreuse'        (113 198 113)
  6013 	    'sgi chartreuse'        (113 198 113)
  6014             'sgi dark gray' (85 85 85)
  6014 	    'sgi dark gray' (85 85 85)
  6015             'sgi dark grey' (85 85 85)
  6015 	    'sgi dark grey' (85 85 85)
  6016             'sgi gray 0'    (0 0 0)
  6016 	    'sgi gray 0'    (0 0 0)
  6017             'sgi gray 100'  (255 255 255)
  6017 	    'sgi gray 100'  (255 255 255)
  6018             'sgi gray 12'   (30 30 30)
  6018 	    'sgi gray 12'   (30 30 30)
  6019             'sgi gray 16'   (40 40 40)
  6019 	    'sgi gray 16'   (40 40 40)
  6020             'sgi gray 20'   (51 51 51)
  6020 	    'sgi gray 20'   (51 51 51)
  6021             'sgi gray 24'   (61 61 61)
  6021 	    'sgi gray 24'   (61 61 61)
  6022             'sgi gray 28'   (71 71 71)
  6022 	    'sgi gray 28'   (71 71 71)
  6023             'sgi gray 32'   (81 81 81)
  6023 	    'sgi gray 32'   (81 81 81)
  6024             'sgi gray 36'   (91 91 91)
  6024 	    'sgi gray 36'   (91 91 91)
  6025             'sgi gray 4'    (10 10 10)
  6025 	    'sgi gray 4'    (10 10 10)
  6026             'sgi gray 40'   (102 102 102)
  6026 	    'sgi gray 40'   (102 102 102)
  6027             'sgi gray 44'   (112 112 112)
  6027 	    'sgi gray 44'   (112 112 112)
  6028             'sgi gray 48'   (122 122 122)
  6028 	    'sgi gray 48'   (122 122 122)
  6029             'sgi gray 52'   (132 132 132)
  6029 	    'sgi gray 52'   (132 132 132)
  6030             'sgi gray 56'   (142 142 142)
  6030 	    'sgi gray 56'   (142 142 142)
  6031             'sgi gray 60'   (153 153 153)
  6031 	    'sgi gray 60'   (153 153 153)
  6032             'sgi gray 64'   (163 163 163)
  6032 	    'sgi gray 64'   (163 163 163)
  6033             'sgi gray 68'   (173 173 173)
  6033 	    'sgi gray 68'   (173 173 173)
  6034             'sgi gray 72'   (183 183 183)
  6034 	    'sgi gray 72'   (183 183 183)
  6035             'sgi gray 76'   (193 193 193)
  6035 	    'sgi gray 76'   (193 193 193)
  6036             'sgi gray 8'    (20 20 20)
  6036 	    'sgi gray 8'    (20 20 20)
  6037             'sgi gray 80'   (204 204 204)
  6037 	    'sgi gray 80'   (204 204 204)
  6038             'sgi gray 84'   (214 214 214)
  6038 	    'sgi gray 84'   (214 214 214)
  6039             'sgi gray 88'   (224 224 224)
  6039 	    'sgi gray 88'   (224 224 224)
  6040             'sgi gray 92'   (234 234 234)
  6040 	    'sgi gray 92'   (234 234 234)
  6041             'sgi gray 96'   (244 244 244)
  6041 	    'sgi gray 96'   (244 244 244)
  6042             'sgi grey 0'    (0 0 0)
  6042 	    'sgi grey 0'    (0 0 0)
  6043             'sgi grey 100'  (255 255 255)
  6043 	    'sgi grey 100'  (255 255 255)
  6044             'sgi grey 12'   (30 30 30)
  6044 	    'sgi grey 12'   (30 30 30)
  6045             'sgi grey 16'   (40 40 40)
  6045 	    'sgi grey 16'   (40 40 40)
  6046             'sgi grey 20'   (51 51 51)
  6046 	    'sgi grey 20'   (51 51 51)
  6047             'sgi grey 24'   (61 61 61)
  6047 	    'sgi grey 24'   (61 61 61)
  6048             'sgi grey 28'   (71 71 71)
  6048 	    'sgi grey 28'   (71 71 71)
  6049             'sgi grey 32'   (81 81 81)
  6049 	    'sgi grey 32'   (81 81 81)
  6050             'sgi grey 36'   (91 91 91)
  6050 	    'sgi grey 36'   (91 91 91)
  6051             'sgi grey 4'    (10 10 10)
  6051 	    'sgi grey 4'    (10 10 10)
  6052             'sgi grey 40'   (102 102 102)
  6052 	    'sgi grey 40'   (102 102 102)
  6053             'sgi grey 44'   (112 112 112)
  6053 	    'sgi grey 44'   (112 112 112)
  6054             'sgi grey 48'   (122 122 122)
  6054 	    'sgi grey 48'   (122 122 122)
  6055             'sgi grey 52'   (132 132 132)
  6055 	    'sgi grey 52'   (132 132 132)
  6056             'sgi grey 56'   (142 142 142)
  6056 	    'sgi grey 56'   (142 142 142)
  6057             'sgi grey 60'   (153 153 153)
  6057 	    'sgi grey 60'   (153 153 153)
  6058             'sgi grey 64'   (163 163 163)
  6058 	    'sgi grey 64'   (163 163 163)
  6059             'sgi grey 68'   (173 173 173)
  6059 	    'sgi grey 68'   (173 173 173)
  6060             'sgi grey 72'   (183 183 183)
  6060 	    'sgi grey 72'   (183 183 183)
  6061             'sgi grey 76'   (193 193 193)
  6061 	    'sgi grey 76'   (193 193 193)
  6062             'sgi grey 8'    (20 20 20)
  6062 	    'sgi grey 8'    (20 20 20)
  6063             'sgi grey 80'   (204 204 204)
  6063 	    'sgi grey 80'   (204 204 204)
  6064             'sgi grey 84'   (214 214 214)
  6064 	    'sgi grey 84'   (214 214 214)
  6065             'sgi grey 88'   (224 224 224)
  6065 	    'sgi grey 88'   (224 224 224)
  6066             'sgi grey 92'   (234 234 234)
  6066 	    'sgi grey 92'   (234 234 234)
  6067             'sgi grey 96'   (244 244 244)
  6067 	    'sgi grey 96'   (244 244 244)
  6068             'sgi light blue'        (125 158 192)
  6068 	    'sgi light blue'        (125 158 192)
  6069             'sgi light gray'        (170 170 170)
  6069 	    'sgi light gray'        (170 170 170)
  6070             'sgi light grey'        (170 170 170)
  6070 	    'sgi light grey'        (170 170 170)
  6071             'sgi medium gray'       (132 132 132)
  6071 	    'sgi medium gray'       (132 132 132)
  6072             'sgi medium grey'       (132 132 132)
  6072 	    'sgi medium grey'       (132 132 132)
  6073             'sgi olive drab'        (142 142 56)
  6073 	    'sgi olive drab'        (142 142 56)
  6074             'sgi salmon'    (198 113 113)
  6074 	    'sgi salmon'    (198 113 113)
  6075             'sgi slate blue'        (113 113 198)
  6075 	    'sgi slate blue'        (113 113 198)
  6076             'sgi teal'      (56 142 142)
  6076 	    'sgi teal'      (56 142 142)
  6077             'sgi very dark gray'    (40 40 40)
  6077 	    'sgi very dark gray'    (40 40 40)
  6078             'sgi very dark grey'    (40 40 40)
  6078 	    'sgi very dark grey'    (40 40 40)
  6079             'sgi very light gray'   (214 214 214)
  6079 	    'sgi very light gray'   (214 214 214)
  6080             'sgi very light grey'   (214 214 214)
  6080 	    'sgi very light grey'   (214 214 214)
  6081             'SGIBeet'       (142 56 142)
  6081 	    'SGIBeet'       (142 56 142)
  6082             'SGIBrightGray' (197 193 170)
  6082 	    'SGIBrightGray' (197 193 170)
  6083             'SGIBrightGrey' (197 193 170)
  6083 	    'SGIBrightGrey' (197 193 170)
  6084             'SGIChartreuse' (113 198 113)
  6084 	    'SGIChartreuse' (113 198 113)
  6085             'SGIDarkGray'   (85 85 85)
  6085 	    'SGIDarkGray'   (85 85 85)
  6086             'SGIDarkGrey'   (85 85 85)
  6086 	    'SGIDarkGrey'   (85 85 85)
  6087             'SGIGray0'      (0 0 0)
  6087 	    'SGIGray0'      (0 0 0)
  6088             'SGIGray100'    (255 255 255)
  6088 	    'SGIGray100'    (255 255 255)
  6089             'SGIGray12'     (30 30 30)
  6089 	    'SGIGray12'     (30 30 30)
  6090             'SGIGray16'     (40 40 40)
  6090 	    'SGIGray16'     (40 40 40)
  6091             'SGIGray20'     (51 51 51)
  6091 	    'SGIGray20'     (51 51 51)
  6092             'SGIGray24'     (61 61 61)
  6092 	    'SGIGray24'     (61 61 61)
  6093             'SGIGray28'     (71 71 71)
  6093 	    'SGIGray28'     (71 71 71)
  6094             'SGIGray32'     (81 81 81)
  6094 	    'SGIGray32'     (81 81 81)
  6095             'SGIGray36'     (91 91 91)
  6095 	    'SGIGray36'     (91 91 91)
  6096             'SGIGray4'      (10 10 10)
  6096 	    'SGIGray4'      (10 10 10)
  6097             'SGIGray40'     (102 102 102)
  6097 	    'SGIGray40'     (102 102 102)
  6098             'SGIGray44'     (112 112 112)
  6098 	    'SGIGray44'     (112 112 112)
  6099             'SGIGray48'     (122 122 122)
  6099 	    'SGIGray48'     (122 122 122)
  6100             'SGIGray52'     (132 132 132)
  6100 	    'SGIGray52'     (132 132 132)
  6101             'SGIGray56'     (142 142 142)
  6101 	    'SGIGray56'     (142 142 142)
  6102             'SGIGray60'     (153 153 153)
  6102 	    'SGIGray60'     (153 153 153)
  6103             'SGIGray64'     (163 163 163)
  6103 	    'SGIGray64'     (163 163 163)
  6104             'SGIGray68'     (173 173 173)
  6104 	    'SGIGray68'     (173 173 173)
  6105             'SGIGray72'     (183 183 183)
  6105 	    'SGIGray72'     (183 183 183)
  6106             'SGIGray76'     (193 193 193)
  6106 	    'SGIGray76'     (193 193 193)
  6107             'SGIGray8'      (20 20 20)
  6107 	    'SGIGray8'      (20 20 20)
  6108             'SGIGray80'     (204 204 204)
  6108 	    'SGIGray80'     (204 204 204)
  6109             'SGIGray84'     (214 214 214)
  6109 	    'SGIGray84'     (214 214 214)
  6110             'SGIGray88'     (224 224 224)
  6110 	    'SGIGray88'     (224 224 224)
  6111             'SGIGray92'     (234 234 234)
  6111 	    'SGIGray92'     (234 234 234)
  6112             'SGIGray96'     (244 244 244)
  6112 	    'SGIGray96'     (244 244 244)
  6113             'SGIGrey0'      (0 0 0)
  6113 	    'SGIGrey0'      (0 0 0)
  6114             'SGIGrey100'    (255 255 255)
  6114 	    'SGIGrey100'    (255 255 255)
  6115             'SGIGrey12'     (30 30 30)
  6115 	    'SGIGrey12'     (30 30 30)
  6116             'SGIGrey16'     (40 40 40)
  6116 	    'SGIGrey16'     (40 40 40)
  6117             'SGIGrey20'     (51 51 51)
  6117 	    'SGIGrey20'     (51 51 51)
  6118             'SGIGrey24'     (61 61 61)
  6118 	    'SGIGrey24'     (61 61 61)
  6119             'SGIGrey28'     (71 71 71)
  6119 	    'SGIGrey28'     (71 71 71)
  6120             'SGIGrey32'     (81 81 81)
  6120 	    'SGIGrey32'     (81 81 81)
  6121             'SGIGrey36'     (91 91 91)
  6121 	    'SGIGrey36'     (91 91 91)
  6122             'SGIGrey4'      (10 10 10)
  6122 	    'SGIGrey4'      (10 10 10)
  6123             'SGIGrey40'     (102 102 102)
  6123 	    'SGIGrey40'     (102 102 102)
  6124             'SGIGrey44'     (112 112 112)
  6124 	    'SGIGrey44'     (112 112 112)
  6125             'SGIGrey48'     (122 122 122)
  6125 	    'SGIGrey48'     (122 122 122)
  6126             'SGIGrey52'     (132 132 132)
  6126 	    'SGIGrey52'     (132 132 132)
  6127             'SGIGrey56'     (142 142 142)
  6127 	    'SGIGrey56'     (142 142 142)
  6128             'SGIGrey60'     (153 153 153)
  6128 	    'SGIGrey60'     (153 153 153)
  6129             'SGIGrey64'     (163 163 163)
  6129 	    'SGIGrey64'     (163 163 163)
  6130             'SGIGrey68'     (173 173 173)
  6130 	    'SGIGrey68'     (173 173 173)
  6131             'SGIGrey72'     (183 183 183)
  6131 	    'SGIGrey72'     (183 183 183)
  6132             'SGIGrey76'     (193 193 193)
  6132 	    'SGIGrey76'     (193 193 193)
  6133             'SGIGrey8'      (20 20 20)
  6133 	    'SGIGrey8'      (20 20 20)
  6134             'SGIGrey80'     (204 204 204)
  6134 	    'SGIGrey80'     (204 204 204)
  6135             'SGIGrey84'     (214 214 214)
  6135 	    'SGIGrey84'     (214 214 214)
  6136             'SGIGrey88'     (224 224 224)
  6136 	    'SGIGrey88'     (224 224 224)
  6137             'SGIGrey92'     (234 234 234)
  6137 	    'SGIGrey92'     (234 234 234)
  6138             'SGIGrey96'     (244 244 244)
  6138 	    'SGIGrey96'     (244 244 244)
  6139             'SGILightBlue'  (125 158 192)
  6139 	    'SGILightBlue'  (125 158 192)
  6140             'SGILightGray'  (170 170 170)
  6140 	    'SGILightGray'  (170 170 170)
  6141             'SGILightGrey'  (170 170 170)
  6141 	    'SGILightGrey'  (170 170 170)
  6142             'SGIMediumGray' (132 132 132)
  6142 	    'SGIMediumGray' (132 132 132)
  6143             'SGIMediumGrey' (132 132 132)
  6143 	    'SGIMediumGrey' (132 132 132)
  6144             'SGIOliveDrab'  (142 142 56)
  6144 	    'SGIOliveDrab'  (142 142 56)
  6145             'SGISalmon'     (198 113 113)
  6145 	    'SGISalmon'     (198 113 113)
  6146             'SGISlateBlue'  (113 113 198)
  6146 	    'SGISlateBlue'  (113 113 198)
  6147             'SGITeal'       (56 142 142)
  6147 	    'SGITeal'       (56 142 142)
  6148             'SGIVeryDarkGray'       (40 40 40)
  6148 	    'SGIVeryDarkGray'       (40 40 40)
  6149             'SGIVeryDarkGrey'       (40 40 40)
  6149 	    'SGIVeryDarkGrey'       (40 40 40)
  6150             'SGIVeryLightGray'      (214 214 214)
  6150 	    'SGIVeryLightGray'      (214 214 214)
  6151             'SGIVeryLightGrey'      (214 214 214)
  6151 	    'SGIVeryLightGrey'      (214 214 214)
  6152             'sienna'        (160 82 45)
  6152 	    'sienna'        (160 82 45)
  6153             'sienna1'       (255 130 71)
  6153 	    'sienna1'       (255 130 71)
  6154             'sienna2'       (238 121 66)
  6154 	    'sienna2'       (238 121 66)
  6155             'sienna3'       (205 104 57)
  6155 	    'sienna3'       (205 104 57)
  6156             'sienna4'       (139 71 38)
  6156 	    'sienna4'       (139 71 38)
  6157             'skyblue'       (135 206 235)
  6157 	    'skyblue'       (135 206 235)
  6158             'SkyBlue1'      (135 206 255)
  6158 	    'SkyBlue1'      (135 206 255)
  6159             'SkyBlue2'      (126 192 238)
  6159 	    'SkyBlue2'      (126 192 238)
  6160             'SkyBlue3'      (108 166 205)
  6160 	    'SkyBlue3'      (108 166 205)
  6161             'SkyBlue4'      (74 112 139)
  6161 	    'SkyBlue4'      (74 112 139)
  6162             'slategray'     (112 128 144)
  6162 	    'slategray'     (112 128 144)
  6163             'slategrey'     (112 128 144)
  6163 	    'slategrey'     (112 128 144)
  6164             'slateblue'     (106 90 205)
  6164 	    'slateblue'     (106 90 205)
  6165             'SlateBlue1'    (131 111 255)
  6165 	    'SlateBlue1'    (131 111 255)
  6166             'SlateBlue2'    (122 103 238)
  6166 	    'SlateBlue2'    (122 103 238)
  6167             'SlateBlue3'    (105 89 205)
  6167 	    'SlateBlue3'    (105 89 205)
  6168             'SlateBlue4'    (71 60 139)
  6168 	    'SlateBlue4'    (71 60 139)
  6169             'SlateGray1'    (198 226 255)
  6169 	    'SlateGray1'    (198 226 255)
  6170             'SlateGray2'    (185 211 238)
  6170 	    'SlateGray2'    (185 211 238)
  6171             'SlateGray3'    (159 182 205)
  6171 	    'SlateGray3'    (159 182 205)
  6172             'SlateGray4'    (108 123 139)
  6172 	    'SlateGray4'    (108 123 139)
  6173             'snow'          (255 250 250)
  6173 	    'snow'          (255 250 250)
  6174             'snow1'         (255 250 250)
  6174 	    'snow1'         (255 250 250)
  6175             'snow2'         (238 233 233)
  6175 	    'snow2'         (238 233 233)
  6176             'snow3'         (205 201 201)
  6176 	    'snow3'         (205 201 201)
  6177             'snow4'         (139 137 137)
  6177 	    'snow4'         (139 137 137)
  6178             'springgreen'   (0 255 127)
  6178 	    'springgreen'   (0 255 127)
  6179             'SpringGreen1'  (0 255 127)
  6179 	    'SpringGreen1'  (0 255 127)
  6180             'SpringGreen2'  (0 238 118)
  6180 	    'SpringGreen2'  (0 238 118)
  6181             'SpringGreen3'  (0 205 102)
  6181 	    'SpringGreen3'  (0 205 102)
  6182             'SpringGreen4'  (0 139 69)
  6182 	    'SpringGreen4'  (0 139 69)
  6183             'steelblue'     (70 130 180)
  6183 	    'steelblue'     (70 130 180)
  6184             'SteelBlue1'    (99 184 255)
  6184 	    'SteelBlue1'    (99 184 255)
  6185             'SteelBlue2'    (92 172 238)
  6185 	    'SteelBlue2'    (92 172 238)
  6186             'SteelBlue3'    (79 148 205)
  6186 	    'SteelBlue3'    (79 148 205)
  6187             'SteelBlue4'    (54 100 139)
  6187 	    'SteelBlue4'    (54 100 139)
  6188             'tan'   (210 180 140)
  6188 	    'tan'   (210 180 140)
  6189             'tan1'  (255 165 79)
  6189 	    'tan1'  (255 165 79)
  6190             'tan2'  (238 154 73)
  6190 	    'tan2'  (238 154 73)
  6191             'tan3'  (205 133 63)
  6191 	    'tan3'  (205 133 63)
  6192             'tan4'  (139 90 43)
  6192 	    'tan4'  (139 90 43)
  6193             'thistle'       (216 191 216)
  6193 	    'thistle'       (216 191 216)
  6194             'thistle1'      (255 225 255)
  6194 	    'thistle1'      (255 225 255)
  6195             'thistle2'      (238 210 238)
  6195 	    'thistle2'      (238 210 238)
  6196             'thistle3'      (205 181 205)
  6196 	    'thistle3'      (205 181 205)
  6197             'thistle4'      (139 123 139)
  6197 	    'thistle4'      (139 123 139)
  6198             'tomato'        (255 99 71)
  6198 	    'tomato'        (255 99 71)
  6199             'tomato1'       (255 99 71)
  6199 	    'tomato1'       (255 99 71)
  6200             'tomato2'       (238 92 66)
  6200 	    'tomato2'       (238 92 66)
  6201             'tomato3'       (205 79 57)
  6201 	    'tomato3'       (205 79 57)
  6202             'tomato4'       (139 54 38)
  6202 	    'tomato4'       (139 54 38)
  6203             'turquoise'     (64 224 208)
  6203 	    'turquoise'     (64 224 208)
  6204             'turquoise1'    (0 245 255)
  6204 	    'turquoise1'    (0 245 255)
  6205             'turquoise2'    (0 229 238)
  6205 	    'turquoise2'    (0 229 238)
  6206             'turquoise3'    (0 197 205)
  6206 	    'turquoise3'    (0 197 205)
  6207             'turquoise4'    (0 134 139)
  6207 	    'turquoise4'    (0 134 139)
  6208             'violet'        (238 130 238)
  6208 	    'violet'        (238 130 238)
  6209             'violetred'     (208 32 144)
  6209 	    'violetred'     (208 32 144)
  6210             'VioletRed1'    (255 62 150)
  6210 	    'VioletRed1'    (255 62 150)
  6211             'VioletRed2'    (238 58 140)
  6211 	    'VioletRed2'    (238 58 140)
  6212             'VioletRed3'    (205 50 120)
  6212 	    'VioletRed3'    (205 50 120)
  6213             'VioletRed4'    (139 34 82)
  6213 	    'VioletRed4'    (139 34 82)
  6214             'wheat'         (245 222 179)
  6214 	    'wheat'         (245 222 179)
  6215             'wheat1'        (255 231 186)
  6215 	    'wheat1'        (255 231 186)
  6216             'wheat2'        (238 216 174)
  6216 	    'wheat2'        (238 216 174)
  6217             'wheat3'        (205 186 150)
  6217 	    'wheat3'        (205 186 150)
  6218             'wheat4'        (139 126 102)
  6218 	    'wheat4'        (139 126 102)
  6219             'white'         (255 255 255)
  6219 	    'white'         (255 255 255)
  6220             'whitesmoke'    (245 245 245)
  6220 	    'whitesmoke'    (245 245 245)
  6221             'yellow'        (255 255 0)
  6221 	    'yellow'        (255 255 0)
  6222             'yellowgreen'   (154 205 50)
  6222 	    'yellowgreen'   (154 205 50)
  6223             'yellow1'       (255 255 0)
  6223 	    'yellow1'       (255 255 0)
  6224             'yellow2'       (238 238 0)
  6224 	    'yellow2'       (238 238 0)
  6225             'yellow3'       (205 205 0)
  6225 	    'yellow3'       (205 205 0)
  6226             'yellow4'       (139 139 0)
  6226 	    'yellow4'       (139 139 0)
  6227         ).
  6227 	).
  6228 
  6228 
  6229     "
  6229     "
  6230      WinWorkstation initializeStandardColorNames
  6230      WinWorkstation initializeStandardColorNames
  6231     "
  6231     "
  6232 ! !
  6232 ! !
  6275     "enable more debug prints - this will vanish"
  6275     "enable more debug prints - this will vanish"
  6276 
  6276 
  6277 %{  /* NOCONTEXT */
  6277 %{  /* NOCONTEXT */
  6278 
  6278 
  6279     if (aBoolean == true) {
  6279     if (aBoolean == true) {
  6280         __debug__ |= 2;
  6280 	__debug__ |= 2;
  6281     } else {
  6281     } else {
  6282         __debug__ &= ~2;
  6282 	__debug__ &= ~2;
  6283     }
  6283     }
  6284 %}
  6284 %}
  6285 !
  6285 !
  6286 
  6286 
  6287 debug4:aBoolean
  6287 debug4:aBoolean
  6288     "enable even more debug prints - this will vanish"
  6288     "enable even more debug prints - this will vanish"
  6289 
  6289 
  6290 %{  /* NOCONTEXT */
  6290 %{  /* NOCONTEXT */
  6291 
  6291 
  6292     if (aBoolean == true) {
  6292     if (aBoolean == true) {
  6293         __debug__ |= 4;
  6293 	__debug__ |= 4;
  6294     } else {
  6294     } else {
  6295         __debug__ &= ~4;
  6295 	__debug__ &= ~4;
  6296     }
  6296     }
  6297 %}
  6297 %}
  6298 !
  6298 !
  6299 
  6299 
  6300 debug8:aBoolean
  6300 debug8:aBoolean
  6301     "enable even more debug prints - this will vanish"
  6301     "enable even more debug prints - this will vanish"
  6302 
  6302 
  6303 %{  /* NOCONTEXT */
  6303 %{  /* NOCONTEXT */
  6304 
  6304 
  6305     if (aBoolean == true) {
  6305     if (aBoolean == true) {
  6306         __debug__ |= 8;
  6306 	__debug__ |= 8;
  6307     } else {
  6307     } else {
  6308         __debug__ &= ~8;
  6308 	__debug__ &= ~8;
  6309     }
  6309     }
  6310 %}
  6310 %}
  6311 !
  6311 !
  6312 
  6312 
  6313 debug:aBoolean
  6313 debug:aBoolean
  6326 debug:aBoolean message:msg
  6326 debug:aBoolean message:msg
  6327     "enable/disable debugging of individual WM messages"
  6327     "enable/disable debugging of individual WM messages"
  6328 
  6328 
  6329     msg = 'WM_ALL' ifTrue:[
  6329     msg = 'WM_ALL' ifTrue:[
  6330 %{
  6330 %{
  6331         __debug_WM_ALL__ = (aBoolean == true);
  6331 	__debug_WM_ALL__ = (aBoolean == true);
  6332         RETURN (self);
  6332 	RETURN (self);
  6333 %}
  6333 %}
  6334     ].
  6334     ].
  6335     msg = 'WM_USER' ifTrue:[
  6335     msg = 'WM_USER' ifTrue:[
  6336 %{
  6336 %{
  6337         __debug_WM_MOUSEENTER__ = (aBoolean == true);
  6337 	__debug_WM_MOUSEENTER__ = (aBoolean == true);
  6338         __debug_WM_MOUSELEAVE__ = (aBoolean == true);
  6338 	__debug_WM_MOUSELEAVE__ = (aBoolean == true);
  6339         __debug_WM_MOUSEMOVE__ = (aBoolean == true);
  6339 	__debug_WM_MOUSEMOVE__ = (aBoolean == true);
  6340         __debug_WM_MOUSEACTIVATE__ = (aBoolean == true);
  6340 	__debug_WM_MOUSEACTIVATE__ = (aBoolean == true);
  6341         __debug_WM_BUTTONUP__ = (aBoolean == true);
  6341 	__debug_WM_BUTTONUP__ = (aBoolean == true);
  6342         __debug_WM_BUTTONDOWN__ = (aBoolean == true);
  6342 	__debug_WM_BUTTONDOWN__ = (aBoolean == true);
  6343         __debug_WM_KEYUP__ = (aBoolean == true);
  6343 	__debug_WM_KEYUP__ = (aBoolean == true);
  6344         __debug_WM_KEYDOWN__ = (aBoolean == true);
  6344 	__debug_WM_KEYDOWN__ = (aBoolean == true);
  6345         __debug_WM_CHAR__ = (aBoolean == true);
  6345 	__debug_WM_CHAR__ = (aBoolean == true);
  6346         RETURN (self);
  6346 	RETURN (self);
  6347 %}
  6347 %}
  6348     ].
  6348     ].
  6349 
  6349 
  6350     msg = 'WM_MOUSEENTER' ifTrue:[
  6350     msg = 'WM_MOUSEENTER' ifTrue:[
  6351 %{
  6351 %{
  6352         __debug_WM_MOUSEENTER__ = (aBoolean == true);
  6352 	__debug_WM_MOUSEENTER__ = (aBoolean == true);
  6353         RETURN (self);
  6353 	RETURN (self);
  6354 %}
  6354 %}
  6355     ].
  6355     ].
  6356     msg = 'WM_MOUSELEAVE' ifTrue:[
  6356     msg = 'WM_MOUSELEAVE' ifTrue:[
  6357 %{
  6357 %{
  6358         __debug_WM_MOUSELEAVE__ = (aBoolean == true);
  6358 	__debug_WM_MOUSELEAVE__ = (aBoolean == true);
  6359         RETURN (self);
  6359 	RETURN (self);
  6360 %}
  6360 %}
  6361     ].
  6361     ].
  6362     msg = 'WM_MOUSEMOVE' ifTrue:[
  6362     msg = 'WM_MOUSEMOVE' ifTrue:[
  6363 %{
  6363 %{
  6364         __debug_WM_MOUSEMOVE__ = (aBoolean == true);
  6364 	__debug_WM_MOUSEMOVE__ = (aBoolean == true);
  6365         RETURN (self);
  6365 	RETURN (self);
  6366 %}
  6366 %}
  6367     ].
  6367     ].
  6368     msg = 'WM_MOUSEACTIVATE' ifTrue:[
  6368     msg = 'WM_MOUSEACTIVATE' ifTrue:[
  6369 %{
  6369 %{
  6370         __debug_WM_MOUSEACTIVATE__ = (aBoolean == true);
  6370 	__debug_WM_MOUSEACTIVATE__ = (aBoolean == true);
  6371         RETURN (self);
  6371 	RETURN (self);
  6372 %}
  6372 %}
  6373     ].
  6373     ].
  6374     msg = 'WM_BUTTONUP' ifTrue:[
  6374     msg = 'WM_BUTTONUP' ifTrue:[
  6375 %{
  6375 %{
  6376         __debug_WM_BUTTONUP__ = (aBoolean == true);
  6376 	__debug_WM_BUTTONUP__ = (aBoolean == true);
  6377         RETURN (self);
  6377 	RETURN (self);
  6378 %}
  6378 %}
  6379     ].
  6379     ].
  6380     msg = 'WM_BUTTONDOWN' ifTrue:[
  6380     msg = 'WM_BUTTONDOWN' ifTrue:[
  6381 %{
  6381 %{
  6382         __debug_WM_BUTTONDOWN__ = (aBoolean == true);
  6382 	__debug_WM_BUTTONDOWN__ = (aBoolean == true);
  6383         RETURN (self);
  6383 	RETURN (self);
  6384 %}
  6384 %}
  6385     ].
  6385     ].
  6386     msg = 'WM_KEYUP' ifTrue:[
  6386     msg = 'WM_KEYUP' ifTrue:[
  6387 %{
  6387 %{
  6388         __debug_WM_KEYUP__ = (aBoolean == true);
  6388 	__debug_WM_KEYUP__ = (aBoolean == true);
  6389         RETURN (self);
  6389 	RETURN (self);
  6390 %}
  6390 %}
  6391     ].
  6391     ].
  6392     msg = 'WM_KEYDOWN' ifTrue:[
  6392     msg = 'WM_KEYDOWN' ifTrue:[
  6393 %{
  6393 %{
  6394         __debug_WM_KEYDOWN__ = (aBoolean == true);
  6394 	__debug_WM_KEYDOWN__ = (aBoolean == true);
  6395         RETURN (self);
  6395 	RETURN (self);
  6396 %}
  6396 %}
  6397     ].
  6397     ].
  6398     msg = 'WM_CHAR' ifTrue:[
  6398     msg = 'WM_CHAR' ifTrue:[
  6399 %{
  6399 %{
  6400         __debug_WM_CHAR__ = (aBoolean == true);
  6400 	__debug_WM_CHAR__ = (aBoolean == true);
  6401         RETURN (self);
  6401 	RETURN (self);
  6402 %}
  6402 %}
  6403     ].
  6403     ].
  6404     msg = 'WM_PAINT' ifTrue:[
  6404     msg = 'WM_PAINT' ifTrue:[
  6405 %{
  6405 %{
  6406         __debug_WM_PAINT__ = (aBoolean == true);
  6406 	__debug_WM_PAINT__ = (aBoolean == true);
  6407         RETURN (self);
  6407 	RETURN (self);
  6408 %}
  6408 %}
  6409     ].
  6409     ].
  6410     msg = 'WM_MOVING' ifTrue:[
  6410     msg = 'WM_MOVING' ifTrue:[
  6411 %{
  6411 %{
  6412         __debug_WM_MOVING__ = (aBoolean == true);
  6412 	__debug_WM_MOVING__ = (aBoolean == true);
  6413         RETURN (self);
  6413 	RETURN (self);
  6414 %}
  6414 %}
  6415     ].
  6415     ].
  6416     msg = 'WM_ERASEBKGND' ifTrue:[
  6416     msg = 'WM_ERASEBKGND' ifTrue:[
  6417 %{
  6417 %{
  6418         __debug_WM_ERASEBKGND__ = (aBoolean == true);
  6418 	__debug_WM_ERASEBKGND__ = (aBoolean == true);
  6419         RETURN (self);
  6419 	RETURN (self);
  6420 %}
  6420 %}
  6421     ].
  6421     ].
  6422     msg = 'WM_SETTEXT' ifTrue:[
  6422     msg = 'WM_SETTEXT' ifTrue:[
  6423 %{
  6423 %{
  6424         __debug_WM_SETTEXT__ = (aBoolean == true);
  6424 	__debug_WM_SETTEXT__ = (aBoolean == true);
  6425         RETURN (self);
  6425 	RETURN (self);
  6426 %}
  6426 %}
  6427     ].
  6427     ].
  6428     msg = 'WM_COPYDATA' ifTrue:[
  6428     msg = 'WM_COPYDATA' ifTrue:[
  6429 %{
  6429 %{
  6430         __debug_WM_COPYDATA__ = (aBoolean == true);
  6430 	__debug_WM_COPYDATA__ = (aBoolean == true);
  6431         RETURN (self);
  6431 	RETURN (self);
  6432 %}
  6432 %}
  6433     ].
  6433     ].
  6434     msg = 'WM_DROPFILES' ifTrue:[
  6434     msg = 'WM_DROPFILES' ifTrue:[
  6435 %{
  6435 %{
  6436         __debug_WM_DROPFILES__ = (aBoolean == true);
  6436 	__debug_WM_DROPFILES__ = (aBoolean == true);
  6437         RETURN (self);
  6437 	RETURN (self);
  6438 %}
  6438 %}
  6439     ].
  6439     ].
  6440     msg = 'WM_SHOWWINDOW' ifTrue:[
  6440     msg = 'WM_SHOWWINDOW' ifTrue:[
  6441 %{
  6441 %{
  6442         __debug_WM_SHOWWINDOW__ = (aBoolean == true);
  6442 	__debug_WM_SHOWWINDOW__ = (aBoolean == true);
  6443         RETURN (self);
  6443 	RETURN (self);
  6444 %}
  6444 %}
  6445     ].
  6445     ].
  6446     msg = 'WM_SETCURSOR' ifTrue:[
  6446     msg = 'WM_SETCURSOR' ifTrue:[
  6447 %{
  6447 %{
  6448         __debug_WM_SETCURSOR__ = (aBoolean == true);
  6448 	__debug_WM_SETCURSOR__ = (aBoolean == true);
  6449         RETURN (self);
  6449 	RETURN (self);
  6450 %}
  6450 %}
  6451     ].
  6451     ].
  6452     msg = 'WM_FOCUS' ifTrue:[
  6452     msg = 'WM_FOCUS' ifTrue:[
  6453 %{
  6453 %{
  6454         __debug_WM_FOCUS__ = (aBoolean == true);
  6454 	__debug_WM_FOCUS__ = (aBoolean == true);
  6455         RETURN (self);
  6455 	RETURN (self);
  6456 %}
  6456 %}
  6457     ].
  6457     ].
  6458     'unknown WM_x' infoPrintCR.
  6458     'unknown WM_x' infoPrintCR.
  6459 
  6459 
  6460     "
  6460     "
  6573 
  6573 
  6574     if (aBoolean == true) {
  6574     if (aBoolean == true) {
  6575        __activateOnClick = 1;
  6575        __activateOnClick = 1;
  6576     } else {
  6576     } else {
  6577        if (aBoolean == false) {
  6577        if (aBoolean == false) {
  6578            __activateOnClick = 0;
  6578 	   __activateOnClick = 0;
  6579        }
  6579        }
  6580     }
  6580     }
  6581     RETURN (rslt);
  6581     RETURN (rslt);
  6582 %}
  6582 %}
  6583     "
  6583     "
  6636     "return the state-mask for button1 in motion events state-field.
  6636     "return the state-mask for button1 in motion events state-field.
  6637      This is the devices mask."
  6637      This is the devices mask."
  6638 
  6638 
  6639 %{  /* NOCONTEXT */
  6639 %{  /* NOCONTEXT */
  6640     if (aButton == __MKSMALLINT(1)) {
  6640     if (aButton == __MKSMALLINT(1)) {
  6641         RETURN (__MKSMALLINT(Button1MotionMask));
  6641 	RETURN (__MKSMALLINT(Button1MotionMask));
  6642     }
  6642     }
  6643     if (aButton == __MKSMALLINT(2)) {
  6643     if (aButton == __MKSMALLINT(2)) {
  6644         RETURN (__MKSMALLINT(Button2MotionMask));
  6644 	RETURN (__MKSMALLINT(Button2MotionMask));
  6645     }
  6645     }
  6646     if (aButton == __MKSMALLINT(3)) {
  6646     if (aButton == __MKSMALLINT(3)) {
  6647         RETURN (__MKSMALLINT(Button3MotionMask));
  6647 	RETURN (__MKSMALLINT(Button3MotionMask));
  6648     }
  6648     }
  6649 %}.
  6649 %}.
  6650     ^ nil
  6650     ^ nil
  6651 !
  6651 !
  6652 
  6652 
  6670 defaultEventMask
  6670 defaultEventMask
  6671     "return a mask to enable some events by default."
  6671     "return a mask to enable some events by default."
  6672 
  6672 
  6673 %{  /* NOCONTEXT */
  6673 %{  /* NOCONTEXT */
  6674     RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask |
  6674     RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask |
  6675                          KeyPressMask | KeyReleaseMask |
  6675 			 KeyPressMask | KeyReleaseMask |
  6676                          EnterWindowMask | LeaveWindowMask |
  6676 			 EnterWindowMask | LeaveWindowMask |
  6677                          ButtonPressMask | ButtonMotionMask | ButtonReleaseMask ));
  6677 			 ButtonPressMask | ButtonMotionMask | ButtonReleaseMask ));
  6678 %}
  6678 %}
  6679 !
  6679 !
  6680 
  6680 
  6681 deviceContext
  6681 deviceContext
  6682     ^ rootDC
  6682     ^ rootDC
  6716 
  6716 
  6717     if (aBoolean == true) {
  6717     if (aBoolean == true) {
  6718        __focusFollowsMouse = 1;
  6718        __focusFollowsMouse = 1;
  6719     } else {
  6719     } else {
  6720        if (aBoolean == false) {
  6720        if (aBoolean == false) {
  6721            __focusFollowsMouse = 0;
  6721 	   __focusFollowsMouse = 0;
  6722        }
  6722        }
  6723     }
  6723     }
  6724     RETURN (rslt);
  6724     RETURN (rslt);
  6725 %}
  6725 %}
  6726     "
  6726     "
  6753     int info = 0;
  6753     int info = 0;
  6754     int isBool = 0;
  6754     int isBool = 0;
  6755     int arg;
  6755     int arg;
  6756 
  6756 
  6757     if (__isSmallInteger(aNumberOrSymbol)) {
  6757     if (__isSmallInteger(aNumberOrSymbol)) {
  6758         arg = __intVal(aNumberOrSymbol);
  6758 	arg = __intVal(aNumberOrSymbol);
  6759     } else if ((aNumberOrSymbol == @symbol(swapButton)) || (aNumberOrSymbol == @symbol(SM_SWAPBUTTON))) {
  6759     } else if ((aNumberOrSymbol == @symbol(swapButton)) || (aNumberOrSymbol == @symbol(SM_SWAPBUTTON))) {
  6760         arg = SM_SWAPBUTTON;
  6760 	arg = SM_SWAPBUTTON;
  6761         isBool = 1;
  6761 	isBool = 1;
  6762     } else if ((aNumberOrSymbol == @symbol(mousePresent)) || (aNumberOrSymbol == @symbol(SM_MOUSEPRESENT))) {
  6762     } else if ((aNumberOrSymbol == @symbol(mousePresent)) || (aNumberOrSymbol == @symbol(SM_MOUSEPRESENT))) {
  6763         arg = SM_MOUSEPRESENT;
  6763 	arg = SM_MOUSEPRESENT;
  6764         isBool = 1;
  6764 	isBool = 1;
  6765     } else if ((aNumberOrSymbol == @symbol(mouseButtons)) || (aNumberOrSymbol == @symbol(SM_CMOUSEBUTTONS))) {
  6765     } else if ((aNumberOrSymbol == @symbol(mouseButtons)) || (aNumberOrSymbol == @symbol(SM_CMOUSEBUTTONS))) {
  6766         arg = SM_CMOUSEBUTTONS;
  6766 	arg = SM_CMOUSEBUTTONS;
  6767     } else if ((aNumberOrSymbol == @symbol(iconWidth)) || (aNumberOrSymbol == @symbol(SM_CXICON))) {
  6767     } else if ((aNumberOrSymbol == @symbol(iconWidth)) || (aNumberOrSymbol == @symbol(SM_CXICON))) {
  6768         arg = SM_CXICON;
  6768 	arg = SM_CXICON;
  6769     } else if ((aNumberOrSymbol == @symbol(iconHeight)) || (aNumberOrSymbol == @symbol(SM_CYICON))) {
  6769     } else if ((aNumberOrSymbol == @symbol(iconHeight)) || (aNumberOrSymbol == @symbol(SM_CYICON))) {
  6770         arg = SM_CYICON;
  6770 	arg = SM_CYICON;
  6771     } else if ((aNumberOrSymbol == @symbol(iconWidth)) || (aNumberOrSymbol == @symbol(SM_CXDOUBLECLK))) {
  6771     } else if ((aNumberOrSymbol == @symbol(iconWidth)) || (aNumberOrSymbol == @symbol(SM_CXDOUBLECLK))) {
  6772         arg = SM_CXDOUBLECLK;
  6772 	arg = SM_CXDOUBLECLK;
  6773     } else if ((aNumberOrSymbol == @symbol(iconHeight)) || (aNumberOrSymbol == @symbol(SM_CYDOUBLECLK))) {
  6773     } else if ((aNumberOrSymbol == @symbol(iconHeight)) || (aNumberOrSymbol == @symbol(SM_CYDOUBLECLK))) {
  6774         arg = SM_CYDOUBLECLK;
  6774 	arg = SM_CYDOUBLECLK;
  6775     } else if ((aNumberOrSymbol == @symbol(cursorWidth)) || (aNumberOrSymbol == @symbol(SM_CXCURSOR))) {
  6775     } else if ((aNumberOrSymbol == @symbol(cursorWidth)) || (aNumberOrSymbol == @symbol(SM_CXCURSOR))) {
  6776         arg = SM_CXCURSOR;
  6776 	arg = SM_CXCURSOR;
  6777     } else if ((aNumberOrSymbol == @symbol(cursorHeight)) || (aNumberOrSymbol == @symbol(SM_CYCURSOR))) {
  6777     } else if ((aNumberOrSymbol == @symbol(cursorHeight)) || (aNumberOrSymbol == @symbol(SM_CYCURSOR))) {
  6778         arg = SM_CYCURSOR;
  6778 	arg = SM_CYCURSOR;
  6779     } else if ((aNumberOrSymbol == @symbol(captionHeight)) || (aNumberOrSymbol == @symbol(SM_CYCAPTION))) {
  6779     } else if ((aNumberOrSymbol == @symbol(captionHeight)) || (aNumberOrSymbol == @symbol(SM_CYCAPTION))) {
  6780         arg = SM_CYCAPTION;
  6780 	arg = SM_CYCAPTION;
  6781     } else if ((aNumberOrSymbol == @symbol(resizeFrameWidth)) || (aNumberOrSymbol == @symbol(SM_CXFRAME))) {
  6781     } else if ((aNumberOrSymbol == @symbol(resizeFrameWidth)) || (aNumberOrSymbol == @symbol(SM_CXFRAME))) {
  6782         arg = SM_CXFRAME;
  6782 	arg = SM_CXFRAME;
  6783     } else if ((aNumberOrSymbol == @symbol(resizeFrameHeight)) || (aNumberOrSymbol == @symbol(SM_CYFRAME))) {
  6783     } else if ((aNumberOrSymbol == @symbol(resizeFrameHeight)) || (aNumberOrSymbol == @symbol(SM_CYFRAME))) {
  6784         arg = SM_CYFRAME;
  6784 	arg = SM_CYFRAME;
  6785     } else if ((aNumberOrSymbol == @symbol(borderFrameWidth)) || (aNumberOrSymbol == @symbol(SM_CXBORDER))) {
  6785     } else if ((aNumberOrSymbol == @symbol(borderFrameWidth)) || (aNumberOrSymbol == @symbol(SM_CXBORDER))) {
  6786         arg = SM_CXBORDER;
  6786 	arg = SM_CXBORDER;
  6787     } else if ((aNumberOrSymbol == @symbol(borderFrameHeight)) || (aNumberOrSymbol == @symbol(SM_CYBORDER))) {
  6787     } else if ((aNumberOrSymbol == @symbol(borderFrameHeight)) || (aNumberOrSymbol == @symbol(SM_CYBORDER))) {
  6788         arg = SM_CYBORDER;
  6788 	arg = SM_CYBORDER;
  6789     } else if (aNumberOrSymbol == @symbol(SM_CXDLGFRAME)) {
  6789     } else if (aNumberOrSymbol == @symbol(SM_CXDLGFRAME)) {
  6790         arg = SM_CXDLGFRAME;
  6790 	arg = SM_CXDLGFRAME;
  6791     } else if (aNumberOrSymbol == @symbol(SM_CYDLGFRAME)) {
  6791     } else if (aNumberOrSymbol == @symbol(SM_CYDLGFRAME)) {
  6792         arg = SM_CYDLGFRAME;
  6792 	arg = SM_CYDLGFRAME;
  6793     } else if ((aNumberOrSymbol == @symbol(fullScreenWindowWidth)) || (aNumberOrSymbol == @symbol(SM_CXFULLSCREEN))) {
  6793     } else if ((aNumberOrSymbol == @symbol(fullScreenWindowWidth)) || (aNumberOrSymbol == @symbol(SM_CXFULLSCREEN))) {
  6794         arg = SM_CXFULLSCREEN;
  6794 	arg = SM_CXFULLSCREEN;
  6795     } else if ((aNumberOrSymbol == @symbol(fullScreenWindowHeight)) || (aNumberOrSymbol == @symbol(SM_CYFULLSCREEN))) {
  6795     } else if ((aNumberOrSymbol == @symbol(fullScreenWindowHeight)) || (aNumberOrSymbol == @symbol(SM_CYFULLSCREEN))) {
  6796         arg = SM_CYFULLSCREEN;
  6796 	arg = SM_CYFULLSCREEN;
  6797     } else if ((aNumberOrSymbol == @symbol(screenWidth)) || (aNumberOrSymbol == @symbol(SM_CXSCREEN))) {
  6797     } else if ((aNumberOrSymbol == @symbol(screenWidth)) || (aNumberOrSymbol == @symbol(SM_CXSCREEN))) {
  6798         arg = SM_CXSCREEN;
  6798 	arg = SM_CXSCREEN;
  6799     } else if ((aNumberOrSymbol == @symbol(screenHeight)) || (aNumberOrSymbol == @symbol(SM_CYSCREEN))) {
  6799     } else if ((aNumberOrSymbol == @symbol(screenHeight)) || (aNumberOrSymbol == @symbol(SM_CYSCREEN))) {
  6800         arg = SM_CYSCREEN;
  6800 	arg = SM_CYSCREEN;
  6801     } else if ((aNumberOrSymbol == @symbol(minWindowWidth)) || (aNumberOrSymbol == @symbol(SM_CXMIN))) {
  6801     } else if ((aNumberOrSymbol == @symbol(minWindowWidth)) || (aNumberOrSymbol == @symbol(SM_CXMIN))) {
  6802         arg = SM_CXMIN;
  6802 	arg = SM_CXMIN;
  6803     } else if ((aNumberOrSymbol == @symbol(minWindowHeight)) || (aNumberOrSymbol == @symbol(SM_CYMIN))) {
  6803     } else if ((aNumberOrSymbol == @symbol(minWindowHeight)) || (aNumberOrSymbol == @symbol(SM_CYMIN))) {
  6804         arg = SM_CYMIN;
  6804 	arg = SM_CYMIN;
  6805     } else if ((aNumberOrSymbol == @symbol(vScrollbarWidth)) || (aNumberOrSymbol == @symbol(SM_CXVSCROLL))) {
  6805     } else if ((aNumberOrSymbol == @symbol(vScrollbarWidth)) || (aNumberOrSymbol == @symbol(SM_CXVSCROLL))) {
  6806         arg = SM_CXVSCROLL;
  6806 	arg = SM_CXVSCROLL;
  6807     } else if ((aNumberOrSymbol == @symbol(hScrollbarHeight)) || (aNumberOrSymbol == @symbol(SM_CYHSCROLL))) {
  6807     } else if ((aNumberOrSymbol == @symbol(hScrollbarHeight)) || (aNumberOrSymbol == @symbol(SM_CYHSCROLL))) {
  6808         arg = SM_CYHSCROLL;
  6808 	arg = SM_CYHSCROLL;
  6809     } else if ((aNumberOrSymbol == @symbol(vThumbHeight)) || (aNumberOrSymbol == @symbol(SM_CYVTHUMB))) {
  6809     } else if ((aNumberOrSymbol == @symbol(vThumbHeight)) || (aNumberOrSymbol == @symbol(SM_CYVTHUMB))) {
  6810         arg = SM_CYVTHUMB;
  6810 	arg = SM_CYVTHUMB;
  6811     } else if ((aNumberOrSymbol == @symbol(hThumbWidth)) || (aNumberOrSymbol == @symbol(SM_CXHTHUMB))) {
  6811     } else if ((aNumberOrSymbol == @symbol(hThumbWidth)) || (aNumberOrSymbol == @symbol(SM_CXHTHUMB))) {
  6812         arg = SM_CXHTHUMB;
  6812 	arg = SM_CXHTHUMB;
  6813     } else if ((aNumberOrSymbol == @symbol(SM_CXSIZE))) {
  6813     } else if ((aNumberOrSymbol == @symbol(SM_CXSIZE))) {
  6814         arg = SM_CXSIZE;
  6814 	arg = SM_CXSIZE;
  6815     } else if ((aNumberOrSymbol == @symbol(SM_CYSIZE))) {
  6815     } else if ((aNumberOrSymbol == @symbol(SM_CYSIZE))) {
  6816         arg = SM_CYSIZE;
  6816 	arg = SM_CYSIZE;
  6817     } else if ((aNumberOrSymbol == @symbol(SM_CYVSCROLL))) {
  6817     } else if ((aNumberOrSymbol == @symbol(SM_CYVSCROLL))) {
  6818         arg = SM_CYVSCROLL;
  6818 	arg = SM_CYVSCROLL;
  6819     } else if ((aNumberOrSymbol == @symbol(SM_CXHSCROLL))) {
  6819     } else if ((aNumberOrSymbol == @symbol(SM_CXHSCROLL))) {
  6820         arg = SM_CXHSCROLL;
  6820 	arg = SM_CXHSCROLL;
  6821     } else if ((aNumberOrSymbol == @symbol(SM_CXMINTRACK))) {
  6821     } else if ((aNumberOrSymbol == @symbol(SM_CXMINTRACK))) {
  6822         arg = SM_CXMINTRACK;
  6822 	arg = SM_CXMINTRACK;
  6823     } else if ((aNumberOrSymbol == @symbol(SM_CYMINTRACK))) {
  6823     } else if ((aNumberOrSymbol == @symbol(SM_CYMINTRACK))) {
  6824         arg = SM_CYMINTRACK;
  6824 	arg = SM_CYMINTRACK;
  6825     } else if ((aNumberOrSymbol == @symbol(SM_CXICONSPACING))) {
  6825     } else if ((aNumberOrSymbol == @symbol(SM_CXICONSPACING))) {
  6826         arg = SM_CXICONSPACING;
  6826 	arg = SM_CXICONSPACING;
  6827     } else if ((aNumberOrSymbol == @symbol(SM_CYICONSPACING))) {
  6827     } else if ((aNumberOrSymbol == @symbol(SM_CYICONSPACING))) {
  6828         arg = SM_CYICONSPACING;
  6828 	arg = SM_CYICONSPACING;
  6829     } else if ((aNumberOrSymbol == @symbol(SM_CYMENU))) {
  6829     } else if ((aNumberOrSymbol == @symbol(SM_CYMENU))) {
  6830         arg = SM_CYMENU;
  6830 	arg = SM_CYMENU;
  6831     } else if ((aNumberOrSymbol == @symbol(SM_MENUDROPALIGNMENT))) {
  6831     } else if ((aNumberOrSymbol == @symbol(SM_MENUDROPALIGNMENT))) {
  6832         arg = SM_MENUDROPALIGNMENT;
  6832 	arg = SM_MENUDROPALIGNMENT;
  6833     } else if ((aNumberOrSymbol == @symbol(SM_PENWINDOWS))) {
  6833     } else if ((aNumberOrSymbol == @symbol(SM_PENWINDOWS))) {
  6834         arg = SM_PENWINDOWS;
  6834 	arg = SM_PENWINDOWS;
  6835     } else if ((aNumberOrSymbol == @symbol(SM_DBCSENABLED))) {
  6835     } else if ((aNumberOrSymbol == @symbol(SM_DBCSENABLED))) {
  6836         arg = SM_DBCSENABLED;
  6836 	arg = SM_DBCSENABLED;
  6837     } else if ((aNumberOrSymbol == @symbol(SM_CXFIXEDFRAME))) {
  6837     } else if ((aNumberOrSymbol == @symbol(SM_CXFIXEDFRAME))) {
  6838         arg = SM_CXFIXEDFRAME;
  6838 	arg = SM_CXFIXEDFRAME;
  6839     } else if ((aNumberOrSymbol == @symbol(SM_CYFIXEDFRAME))) {
  6839     } else if ((aNumberOrSymbol == @symbol(SM_CYFIXEDFRAME))) {
  6840         arg = SM_CYFIXEDFRAME;
  6840 	arg = SM_CYFIXEDFRAME;
  6841     } else if ((aNumberOrSymbol == @symbol(SM_CXSIZEFRAME))) {
  6841     } else if ((aNumberOrSymbol == @symbol(SM_CXSIZEFRAME))) {
  6842         arg = SM_CXSIZEFRAME;
  6842 	arg = SM_CXSIZEFRAME;
  6843     } else if ((aNumberOrSymbol == @symbol(SM_CYSIZEFRAME))) {
  6843     } else if ((aNumberOrSymbol == @symbol(SM_CYSIZEFRAME))) {
  6844         arg = SM_CYSIZEFRAME;
  6844 	arg = SM_CYSIZEFRAME;
  6845     } else if ((aNumberOrSymbol == @symbol(SM_CYKANJIWINDOW))) {
  6845     } else if ((aNumberOrSymbol == @symbol(SM_CYKANJIWINDOW))) {
  6846         arg = SM_CYKANJIWINDOW;
  6846 	arg = SM_CYKANJIWINDOW;
  6847     } else if ((aNumberOrSymbol == @symbol(SM_SECURE))) {
  6847     } else if ((aNumberOrSymbol == @symbol(SM_SECURE))) {
  6848         arg = SM_SECURE;
  6848 	arg = SM_SECURE;
  6849     } else if ((aNumberOrSymbol == @symbol(SM_CXEDGE))) {
  6849     } else if ((aNumberOrSymbol == @symbol(SM_CXEDGE))) {
  6850         arg = SM_CXEDGE;
  6850 	arg = SM_CXEDGE;
  6851     } else if ((aNumberOrSymbol == @symbol(SM_CYEDGE))) {
  6851     } else if ((aNumberOrSymbol == @symbol(SM_CYEDGE))) {
  6852         arg = SM_CYEDGE;
  6852 	arg = SM_CYEDGE;
  6853     } else if ((aNumberOrSymbol == @symbol(SM_CXMINSPACING))) {
  6853     } else if ((aNumberOrSymbol == @symbol(SM_CXMINSPACING))) {
  6854         arg = SM_CXMINSPACING;
  6854 	arg = SM_CXMINSPACING;
  6855     } else if ((aNumberOrSymbol == @symbol(SM_CYMINSPACING))) {
  6855     } else if ((aNumberOrSymbol == @symbol(SM_CYMINSPACING))) {
  6856         arg = SM_CYMINSPACING;
  6856 	arg = SM_CYMINSPACING;
  6857     } else if ((aNumberOrSymbol == @symbol(SM_CXSMICON))) {
  6857     } else if ((aNumberOrSymbol == @symbol(SM_CXSMICON))) {
  6858         arg = SM_CXSMICON;
  6858 	arg = SM_CXSMICON;
  6859     } else if ((aNumberOrSymbol == @symbol(SM_CYSMICON))) {
  6859     } else if ((aNumberOrSymbol == @symbol(SM_CYSMICON))) {
  6860         arg = SM_CYSMICON;
  6860 	arg = SM_CYSMICON;
  6861     } else if ((aNumberOrSymbol == @symbol(SM_CYSMCAPTION))) {
  6861     } else if ((aNumberOrSymbol == @symbol(SM_CYSMCAPTION))) {
  6862         arg = SM_CYSMCAPTION;
  6862 	arg = SM_CYSMCAPTION;
  6863     } else if ((aNumberOrSymbol == @symbol(SM_CXSMSIZE))) {
  6863     } else if ((aNumberOrSymbol == @symbol(SM_CXSMSIZE))) {
  6864         arg = SM_CXSMSIZE;
  6864 	arg = SM_CXSMSIZE;
  6865     } else if ((aNumberOrSymbol == @symbol(SM_CYSMSIZE))) {
  6865     } else if ((aNumberOrSymbol == @symbol(SM_CYSMSIZE))) {
  6866         arg = SM_CYSMSIZE;
  6866 	arg = SM_CYSMSIZE;
  6867     } else if ((aNumberOrSymbol == @symbol(SM_CXMENUSIZE))) {
  6867     } else if ((aNumberOrSymbol == @symbol(SM_CXMENUSIZE))) {
  6868         arg = SM_CXMENUSIZE;
  6868 	arg = SM_CXMENUSIZE;
  6869     } else if ((aNumberOrSymbol == @symbol(SM_CYMENUSIZE))) {
  6869     } else if ((aNumberOrSymbol == @symbol(SM_CYMENUSIZE))) {
  6870         arg = SM_CYMENUSIZE;
  6870 	arg = SM_CYMENUSIZE;
  6871     } else if ((aNumberOrSymbol == @symbol(SM_ARRANGE))) {
  6871     } else if ((aNumberOrSymbol == @symbol(SM_ARRANGE))) {
  6872         arg = SM_ARRANGE;
  6872 	arg = SM_ARRANGE;
  6873     } else if ((aNumberOrSymbol == @symbol(SM_CXMINIMIZED))) {
  6873     } else if ((aNumberOrSymbol == @symbol(SM_CXMINIMIZED))) {
  6874         arg = SM_CXMINIMIZED;
  6874 	arg = SM_CXMINIMIZED;
  6875     } else if ((aNumberOrSymbol == @symbol(SM_CYMINIMIZED))) {
  6875     } else if ((aNumberOrSymbol == @symbol(SM_CYMINIMIZED))) {
  6876         arg = SM_CYMINIMIZED;
  6876 	arg = SM_CYMINIMIZED;
  6877     } else if ((aNumberOrSymbol == @symbol(SM_CXMAXTRACK))) {
  6877     } else if ((aNumberOrSymbol == @symbol(SM_CXMAXTRACK))) {
  6878         arg = SM_CXMAXTRACK;
  6878 	arg = SM_CXMAXTRACK;
  6879     } else if ((aNumberOrSymbol == @symbol(SM_CYMAXTRACK))) {
  6879     } else if ((aNumberOrSymbol == @symbol(SM_CYMAXTRACK))) {
  6880         arg = SM_CYMAXTRACK;
  6880 	arg = SM_CYMAXTRACK;
  6881     } else if ((aNumberOrSymbol == @symbol(SM_CXMAXIMIZED))) {
  6881     } else if ((aNumberOrSymbol == @symbol(SM_CXMAXIMIZED))) {
  6882         arg = SM_CXMAXIMIZED;
  6882 	arg = SM_CXMAXIMIZED;
  6883     } else if ((aNumberOrSymbol == @symbol(SM_CYMAXIMIZED))) {
  6883     } else if ((aNumberOrSymbol == @symbol(SM_CYMAXIMIZED))) {
  6884         arg = SM_CYMAXIMIZED;
  6884 	arg = SM_CYMAXIMIZED;
  6885     } else if ((aNumberOrSymbol == @symbol(SM_NETWORK))) {
  6885     } else if ((aNumberOrSymbol == @symbol(SM_NETWORK))) {
  6886         arg = SM_NETWORK;
  6886 	arg = SM_NETWORK;
  6887     } else if ((aNumberOrSymbol == @symbol(SM_CXDRAG))) {
  6887     } else if ((aNumberOrSymbol == @symbol(SM_CXDRAG))) {
  6888         arg = SM_CXDRAG;
  6888 	arg = SM_CXDRAG;
  6889     } else if ((aNumberOrSymbol == @symbol(SM_CYDRAG))) {
  6889     } else if ((aNumberOrSymbol == @symbol(SM_CYDRAG))) {
  6890         arg = SM_CYDRAG;
  6890 	arg = SM_CYDRAG;
  6891     } else if ((aNumberOrSymbol == @symbol(SM_NETWORK))) {
  6891     } else if ((aNumberOrSymbol == @symbol(SM_NETWORK))) {
  6892         arg = SM_NETWORK;
  6892 	arg = SM_NETWORK;
  6893     } else if ((aNumberOrSymbol == @symbol(SM_SHOWSOUNDS))) {
  6893     } else if ((aNumberOrSymbol == @symbol(SM_SHOWSOUNDS))) {
  6894         arg = SM_SHOWSOUNDS;
  6894 	arg = SM_SHOWSOUNDS;
  6895     } else if ((aNumberOrSymbol == @symbol(SM_CXMENUCHECK))) {
  6895     } else if ((aNumberOrSymbol == @symbol(SM_CXMENUCHECK))) {
  6896         arg = SM_CXMENUCHECK;
  6896 	arg = SM_CXMENUCHECK;
  6897     } else if ((aNumberOrSymbol == @symbol(SM_CYMENUCHECK))) {
  6897     } else if ((aNumberOrSymbol == @symbol(SM_CYMENUCHECK))) {
  6898         arg = SM_CYMENUCHECK;
  6898 	arg = SM_CYMENUCHECK;
  6899     } else if ((aNumberOrSymbol == @symbol(SM_SLOWMACHINE))) {
  6899     } else if ((aNumberOrSymbol == @symbol(SM_SLOWMACHINE))) {
  6900         arg = SM_SLOWMACHINE;
  6900 	arg = SM_SLOWMACHINE;
  6901     } else if ((aNumberOrSymbol == @symbol(SM_MIDEASTENABLED))) {
  6901     } else if ((aNumberOrSymbol == @symbol(SM_MIDEASTENABLED))) {
  6902         arg = SM_MIDEASTENABLED;
  6902 	arg = SM_MIDEASTENABLED;
  6903     } else if ((aNumberOrSymbol == @symbol(SM_MOUSEWHEELPRESENT))) {
  6903     } else if ((aNumberOrSymbol == @symbol(SM_MOUSEWHEELPRESENT))) {
  6904         arg = SM_MOUSEWHEELPRESENT;
  6904 	arg = SM_MOUSEWHEELPRESENT;
  6905     } else if ((aNumberOrSymbol == @symbol(SM_XVIRTUALSCREEN))) {
  6905     } else if ((aNumberOrSymbol == @symbol(SM_XVIRTUALSCREEN))) {
  6906         arg = SM_XVIRTUALSCREEN;
  6906 	arg = SM_XVIRTUALSCREEN;
  6907     } else if ((aNumberOrSymbol == @symbol(SM_YVIRTUALSCREEN))) {
  6907     } else if ((aNumberOrSymbol == @symbol(SM_YVIRTUALSCREEN))) {
  6908         arg = SM_YVIRTUALSCREEN;
  6908 	arg = SM_YVIRTUALSCREEN;
  6909     } else if ((aNumberOrSymbol == @symbol(SM_CXVIRTUALSCREEN))) {
  6909     } else if ((aNumberOrSymbol == @symbol(SM_CXVIRTUALSCREEN))) {
  6910         arg = SM_CXVIRTUALSCREEN;
  6910 	arg = SM_CXVIRTUALSCREEN;
  6911     } else if ((aNumberOrSymbol == @symbol(SM_CYVIRTUALSCREEN))) {
  6911     } else if ((aNumberOrSymbol == @symbol(SM_CYVIRTUALSCREEN))) {
  6912         arg = SM_CYVIRTUALSCREEN;
  6912 	arg = SM_CYVIRTUALSCREEN;
  6913     } else if ((aNumberOrSymbol == @symbol(SM_CMONITORS))) {
  6913     } else if ((aNumberOrSymbol == @symbol(SM_CMONITORS))) {
  6914         arg = SM_CMONITORS;
  6914 	arg = SM_CMONITORS;
  6915     } else if ((aNumberOrSymbol == @symbol(SM_SAMEDISPLAYFORMAT))) {
  6915     } else if ((aNumberOrSymbol == @symbol(SM_SAMEDISPLAYFORMAT))) {
  6916         arg = SM_SAMEDISPLAYFORMAT;
  6916 	arg = SM_SAMEDISPLAYFORMAT;
  6917 #ifdef SM_IMMENABLED
  6917 #ifdef SM_IMMENABLED
  6918     } else if ((aNumberOrSymbol == @symbol(SM_IMMENABLED))) {
  6918     } else if ((aNumberOrSymbol == @symbol(SM_IMMENABLED))) {
  6919         arg = SM_IMMENABLED;
  6919 	arg = SM_IMMENABLED;
  6920 #endif
  6920 #endif
  6921     } else if ((aNumberOrSymbol == @symbol(SM_DEBUG))) {
  6921     } else if ((aNumberOrSymbol == @symbol(SM_DEBUG))) {
  6922         arg = SM_DEBUG;
  6922 	arg = SM_DEBUG;
  6923 #ifdef SM_REMOTESESSION
  6923 #ifdef SM_REMOTESESSION
  6924     } else if ((aNumberOrSymbol == @symbol(SM_REMOTESESSION))) {
  6924     } else if ((aNumberOrSymbol == @symbol(SM_REMOTESESSION))) {
  6925         arg = SM_REMOTESESSION;
  6925 	arg = SM_REMOTESESSION;
  6926 #endif
  6926 #endif
  6927     } else {
  6927     } else {
  6928         RETURN (nil);
  6928 	RETURN (nil);
  6929     }
  6929     }
  6930     info = GetSystemMetrics(arg);
  6930     info = GetSystemMetrics(arg);
  6931     if (isBool) {
  6931     if (isBool) {
  6932         RETURN (info ? true : false);
  6932 	RETURN (info ? true : false);
  6933     }
  6933     }
  6934     RETURN (__MKSMALLINT(info));
  6934     RETURN (__MKSMALLINT(info));
  6935 %}
  6935 %}
  6936     "
  6936     "
  6937      Screen current getSystemMetrics:#SM_MOUSEWHEELPRESENT
  6937      Screen current getSystemMetrics:#SM_MOUSEWHEELPRESENT
  6962     int isRect = 0;
  6962     int isRect = 0;
  6963     int isNonClientInfo = 0;
  6963     int isNonClientInfo = 0;
  6964     int arg, param;
  6964     int arg, param;
  6965     void *pRslt;
  6965     void *pRslt;
  6966     union {
  6966     union {
  6967         char buffer[1024];
  6967 	char buffer[1024];
  6968         RECT rect;
  6968 	RECT rect;
  6969         NONCLIENTMETRICS nc;
  6969 	NONCLIENTMETRICS nc;
  6970     } rslt;
  6970     } rslt;
  6971 
  6971 
  6972     if (__isSmallInteger(aNumberOrSymbol)) {
  6972     if (__isSmallInteger(aNumberOrSymbol)) {
  6973         arg = __intVal(aNumberOrSymbol);
  6973 	arg = __intVal(aNumberOrSymbol);
  6974 #ifdef SPI_GETDESKWALLPAPER
  6974 #ifdef SPI_GETDESKWALLPAPER
  6975     } else if (aNumberOrSymbol == @symbol(SPI_GETDESKWALLPAPER)) {
  6975     } else if (aNumberOrSymbol == @symbol(SPI_GETDESKWALLPAPER)) {
  6976         arg = SPI_GETDESKWALLPAPER;
  6976 	arg = SPI_GETDESKWALLPAPER;
  6977         isString = 1;
  6977 	isString = 1;
  6978 #endif
  6978 #endif
  6979 #ifdef SPI_GETDROPSHADOW
  6979 #ifdef SPI_GETDROPSHADOW
  6980     } else if (aNumberOrSymbol == @symbol(SPI_GETDROPSHADOW)) {
  6980     } else if (aNumberOrSymbol == @symbol(SPI_GETDROPSHADOW)) {
  6981         arg = SPI_GETDROPSHADOW;
  6981 	arg = SPI_GETDROPSHADOW;
  6982         isBool = 1;
  6982 	isBool = 1;
  6983 #endif
  6983 #endif
  6984 #ifdef SPI_GETFLATMENU
  6984 #ifdef SPI_GETFLATMENU
  6985     } else if (aNumberOrSymbol == @symbol(SPI_GETFLATMENU)) {
  6985     } else if (aNumberOrSymbol == @symbol(SPI_GETFLATMENU)) {
  6986         arg = SPI_GETFLATMENU;
  6986 	arg = SPI_GETFLATMENU;
  6987         isBool = 1;
  6987 	isBool = 1;
  6988 #endif
  6988 #endif
  6989 #ifdef SPI_GETWHEELSCROLLLINES
  6989 #ifdef SPI_GETWHEELSCROLLLINES
  6990     } else if (aNumberOrSymbol == @symbol(SPI_GETWHEELSCROLLLINES)) {
  6990     } else if (aNumberOrSymbol == @symbol(SPI_GETWHEELSCROLLLINES)) {
  6991         arg = SPI_GETWHEELSCROLLLINES;
  6991 	arg = SPI_GETWHEELSCROLLLINES;
  6992 #endif
  6992 #endif
  6993 #ifdef SPI_GETHOTTRACKING
  6993 #ifdef SPI_GETHOTTRACKING
  6994     } else if (aNumberOrSymbol == @symbol(SPI_GETHOTTRACKING)) {
  6994     } else if (aNumberOrSymbol == @symbol(SPI_GETHOTTRACKING)) {
  6995         arg = SPI_GETHOTTRACKING;
  6995 	arg = SPI_GETHOTTRACKING;
  6996         isBool = 1;
  6996 	isBool = 1;
  6997 #endif
  6997 #endif
  6998 #ifdef SPI_GETTOOLTIPANIMATION
  6998 #ifdef SPI_GETTOOLTIPANIMATION
  6999     } else if (aNumberOrSymbol == @symbol(SPI_GETTOOLTIPANIMATION)) {
  6999     } else if (aNumberOrSymbol == @symbol(SPI_GETTOOLTIPANIMATION)) {
  7000         arg = SPI_GETTOOLTIPANIMATION;
  7000 	arg = SPI_GETTOOLTIPANIMATION;
  7001         isBool = 1;
  7001 	isBool = 1;
  7002 #endif
  7002 #endif
  7003 #ifdef SPI_GETWORKAREA
  7003 #ifdef SPI_GETWORKAREA
  7004     } else if (aNumberOrSymbol == @symbol(SPI_GETWORKAREA)) {
  7004     } else if (aNumberOrSymbol == @symbol(SPI_GETWORKAREA)) {
  7005         arg = SPI_GETWORKAREA;
  7005 	arg = SPI_GETWORKAREA;
  7006         isRect = 1;
  7006 	isRect = 1;
  7007 #endif
  7007 #endif
  7008 #ifdef SPI_GETNONCLIENTMETRICS
  7008 #ifdef SPI_GETNONCLIENTMETRICS
  7009     } else if (aNumberOrSymbol == @symbol(SPI_GETNONCLIENTMETRICS)) {
  7009     } else if (aNumberOrSymbol == @symbol(SPI_GETNONCLIENTMETRICS)) {
  7010         arg = SPI_GETNONCLIENTMETRICS;
  7010 	arg = SPI_GETNONCLIENTMETRICS;
  7011         rslt.nc.cbSize = sizeof ( rslt.nc ) ;
  7011 	rslt.nc.cbSize = sizeof ( rslt.nc ) ;
  7012         isNonClientInfo = 1;
  7012 	isNonClientInfo = 1;
  7013 #endif
  7013 #endif
  7014     } else {
  7014     } else {
  7015         RETURN (nil);
  7015 	RETURN (nil);
  7016     }
  7016     }
  7017 
  7017 
  7018     param = 0;
  7018     param = 0;
  7019     pRslt = (void *)&rslt;
  7019     pRslt = (void *)&rslt;
  7020     if (isString) {
  7020     if (isString) {
  7021         param = sizeof(rslt);
  7021 	param = sizeof(rslt);
  7022     }
  7022     }
  7023     retVal = SystemParametersInfo(arg, param, pRslt, 0);
  7023     retVal = SystemParametersInfo(arg, param, pRslt, 0);
  7024     if (! retVal) {
  7024     if (! retVal) {
  7025         RETURN (nil);
  7025 	RETURN (nil);
  7026     }
  7026     }
  7027 
  7027 
  7028     if (isBool) {
  7028     if (isBool) {
  7029         RETURN (info ? true : false);
  7029 	RETURN (info ? true : false);
  7030     }
  7030     }
  7031     if (isString) {
  7031     if (isString) {
  7032         RETURN (__MKSTRING(rslt.buffer));
  7032 	RETURN (__MKSTRING(rslt.buffer));
  7033     }
  7033     }
  7034     if (isRect) {
  7034     if (isRect) {
  7035         RETURN ( __SSEND4(__DEF_Rectangle, @symbol(left:top:right:bottom:), 0,
  7035 	RETURN ( __SSEND4(__DEF_Rectangle, @symbol(left:top:right:bottom:), 0,
  7036                         __MKSMALLINT(rslt.rect.left),
  7036 			__MKSMALLINT(rslt.rect.left),
  7037                         __MKSMALLINT(rslt.rect.top),
  7037 			__MKSMALLINT(rslt.rect.top),
  7038                         __MKSMALLINT(rslt.rect.right),
  7038 			__MKSMALLINT(rslt.rect.right),
  7039                         __MKSMALLINT(rslt.rect.bottom)) );
  7039 			__MKSMALLINT(rslt.rect.bottom)) );
  7040     }
  7040     }
  7041     if (isNonClientInfo) {
  7041     if (isNonClientInfo) {
  7042         menuFontInfoArray = __extractLogicalFontParameters(&rslt.nc.lfMenuFont);
  7042 	menuFontInfoArray = __extractLogicalFontParameters(&rslt.nc.lfMenuFont);
  7043         statusFontInfoArray = __extractLogicalFontParameters(&rslt.nc.lfStatusFont);
  7043 	statusFontInfoArray = __extractLogicalFontParameters(&rslt.nc.lfStatusFont);
  7044         messageFontInfoArray = __extractLogicalFontParameters(&rslt.nc.lfMessageFont);
  7044 	messageFontInfoArray = __extractLogicalFontParameters(&rslt.nc.lfMessageFont);
  7045     }
  7045     }
  7046 
  7046 
  7047    out: ;
  7047    out: ;
  7048 %}.
  7048 %}.
  7049 
  7049 
  7050     menuFontInfoArray notNil ifTrue:[
  7050     menuFontInfoArray notNil ifTrue:[
  7051         menuFont := self fontDescriptionFromLogicalFontInfoArray:menuFontInfoArray.
  7051 	menuFont := self fontDescriptionFromLogicalFontInfoArray:menuFontInfoArray.
  7052         statusFont := self fontDescriptionFromLogicalFontInfoArray:statusFontInfoArray.
  7052 	statusFont := self fontDescriptionFromLogicalFontInfoArray:statusFontInfoArray.
  7053         messageFont := self fontDescriptionFromLogicalFontInfoArray:messageFontInfoArray.
  7053 	messageFont := self fontDescriptionFromLogicalFontInfoArray:messageFontInfoArray.
  7054         ^ (Dictionary new)
  7054 	^ (Dictionary new)
  7055             at:#menuFont put:menuFont;
  7055 	    at:#menuFont put:menuFont;
  7056             at:#statusFont put:statusFont;
  7056 	    at:#statusFont put:statusFont;
  7057             at:#messageFont put:messageFont;
  7057 	    at:#messageFont put:messageFont;
  7058             yourself.
  7058 	    yourself.
  7059     ].
  7059     ].
  7060 
  7060 
  7061     ^ nil
  7061     ^ nil
  7062 
  7062 
  7063     "
  7063     "
  7087 
  7087 
  7088     if (aBoolean == true) {
  7088     if (aBoolean == true) {
  7089        __ignoreButtonPressOnActivate = 1;
  7089        __ignoreButtonPressOnActivate = 1;
  7090     } else {
  7090     } else {
  7091        if (aBoolean == false) {
  7091        if (aBoolean == false) {
  7092            __ignoreButtonPressOnActivate = 0;
  7092 	   __ignoreButtonPressOnActivate = 0;
  7093        }
  7093        }
  7094     }
  7094     }
  7095     RETURN (rslt);
  7095     RETURN (rslt);
  7096 %}
  7096 %}
  7097     "
  7097     "
  7106     |screenL screenT screenR screenB screenW screenH
  7106     |screenL screenT screenR screenB screenW screenH
  7107      workL workT workR workB workW workH
  7107      workL workT workR workB workW workH
  7108      isPrimary mName|
  7108      isPrimary mName|
  7109 %{
  7109 %{
  7110     if (__isExternalAddress(aMonitorId)) {
  7110     if (__isExternalAddress(aMonitorId)) {
  7111         HMONITOR hMonitor = (HMONITOR)(_HWNDVal(aMonitorId));
  7111 	HMONITOR hMonitor = (HMONITOR)(_HWNDVal(aMonitorId));
  7112         MONITORINFOEX info;
  7112 	MONITORINFOEX info;
  7113 
  7113 
  7114         info.cbSize = sizeof(MONITORINFOEX);
  7114 	info.cbSize = sizeof(MONITORINFOEX);
  7115 #if 0
  7115 #if 0
  7116         /* the following is only needed when we want
  7116 	/* the following is only needed when we want
  7117          * to support very old NT/W95/W98 systems; we don't !
  7117 	 * to support very old NT/W95/W98 systems; we don't !
  7118          */
  7118 	 */
  7119         static BOOL (__stdcall *P_GetMonitorInfo)(HMONITOR , MONITORINFOEX *);
  7119 	static BOOL (__stdcall *P_GetMonitorInfo)(HMONITOR , MONITORINFOEX *);
  7120 
  7120 
  7121         if (P_GetMonitorInfo == 0) {
  7121 	if (P_GetMonitorInfo == 0) {
  7122             HINSTANCE hUser = LoadLibrary("user32.dll");
  7122 	    HINSTANCE hUser = LoadLibrary("user32.dll");
  7123             // console_printf("hUser: %x\n", hUser);
  7123 	    // console_printf("hUser: %x\n", hUser);
  7124             if (hUser) {
  7124 	    if (hUser) {
  7125                 P_GetMonitorInfo = (BOOL (__stdcall *)(HMONITOR, MONITORINFOEX * ))
  7125 		P_GetMonitorInfo = (BOOL (__stdcall *)(HMONITOR, MONITORINFOEX * ))
  7126                                     GetProcAddress(hUser, "GetMonitorInfo");
  7126 				    GetProcAddress(hUser, "GetMonitorInfo");
  7127             }
  7127 	    }
  7128         }
  7128 	}
  7129         DPRINTF(("P_GetMonitorInfo: %x\n", P_GetMonitorInfo));
  7129 	DPRINTF(("P_GetMonitorInfo: %x\n", P_GetMonitorInfo));
  7130         if ((*P_GetMonitorInfo)(hMonitor, &info))
  7130 	if ((*P_GetMonitorInfo)(hMonitor, &info))
  7131 #else
  7131 #else
  7132         if (GetMonitorInfo(hMonitor, (MONITORINFO *)(&info)))
  7132 	if (GetMonitorInfo(hMonitor, (MONITORINFO *)(&info)))
  7133 #endif
  7133 #endif
  7134         {
  7134 	{
  7135             // console_printf("l %d\n", info.rcMonitor.left);
  7135 	    // console_printf("l %d\n", info.rcMonitor.left);
  7136             screenL = __MKSMALLINT(info.rcMonitor.left);
  7136 	    screenL = __MKSMALLINT(info.rcMonitor.left);
  7137             screenT = __MKSMALLINT(info.rcMonitor.top);
  7137 	    screenT = __MKSMALLINT(info.rcMonitor.top);
  7138             screenR = __MKSMALLINT(info.rcMonitor.right);
  7138 	    screenR = __MKSMALLINT(info.rcMonitor.right);
  7139             screenB = __MKSMALLINT(info.rcMonitor.bottom);
  7139 	    screenB = __MKSMALLINT(info.rcMonitor.bottom);
  7140             workL = __MKSMALLINT(info.rcWork.left);
  7140 	    workL = __MKSMALLINT(info.rcWork.left);
  7141             workT = __MKSMALLINT(info.rcWork.top);
  7141 	    workT = __MKSMALLINT(info.rcWork.top);
  7142             workR = __MKSMALLINT(info.rcWork.right);
  7142 	    workR = __MKSMALLINT(info.rcWork.right);
  7143             workB = __MKSMALLINT(info.rcWork.bottom);
  7143 	    workB = __MKSMALLINT(info.rcWork.bottom);
  7144             isPrimary = (info.dwFlags & MONITORINFOF_PRIMARY) ? true : false;
  7144 	    isPrimary = (info.dwFlags & MONITORINFOF_PRIMARY) ? true : false;
  7145             info.szDevice[31] = '\0';
  7145 	    info.szDevice[31] = '\0';
  7146             mName = __MKSTRING(info.szDevice);
  7146 	    mName = __MKSTRING(info.szDevice);
  7147         }
  7147 	}
  7148     }
  7148     }
  7149 %}.
  7149 %}.
  7150     screenL isNil ifTrue:[ ^ nil ].
  7150     screenL isNil ifTrue:[ ^ nil ].
  7151 
  7151 
  7152     ^ MonitorInfo new
  7152     ^ MonitorInfo new
  7153         screenX:screenL screenY:screenT
  7153 	screenX:screenL screenY:screenT
  7154         screenWidth:(screenR-screenL) screenHeight:(screenB-screenT)
  7154 	screenWidth:(screenR-screenL) screenHeight:(screenB-screenT)
  7155         workX:workL workY:workT
  7155 	workX:workL workY:workT
  7156         workWidth:(workR-workL) workHeight:(workB-workT)
  7156 	workWidth:(workR-workL) workHeight:(workB-workT)
  7157         isPrimary:isPrimary
  7157 	isPrimary:isPrimary
  7158         name:mName
  7158 	name:mName
  7159 
  7159 
  7160     "
  7160     "
  7161      Screen current monitorInfoFor:(Screen current monitorHandleForView:(Transcript topView id))
  7161      Screen current monitorInfoFor:(Screen current monitorHandleForView:(Transcript topView id))
  7162      Screen current monitorInfoFor:(Screen current monitorHandleForPoint:(0@0))
  7162      Screen current monitorInfoFor:(Screen current monitorHandleForPoint:(0@0))
  7163      Screen current monitorInfoFor:(Screen current monitorHandleForPoint:(Display pointFromUser))
  7163      Screen current monitorInfoFor:(Screen current monitorHandleForPoint:(Display pointFromUser))
  7309 getOutOfHere: ;
  7309 getOutOfHere: ;
  7310 %}.
  7310 %}.
  7311     red isNil ifTrue:[ ^ nil ].
  7311     red isNil ifTrue:[ ^ nil ].
  7312 
  7312 
  7313     ^ Color
  7313     ^ Color
  7314         redByte:red
  7314 	redByte:red
  7315         greenByte:green
  7315 	greenByte:green
  7316         blueByte:blue
  7316 	blueByte:blue
  7317 
  7317 
  7318     "
  7318     "
  7319      Display primGetSystemColor:#COLOR_WINDOW
  7319      Display primGetSystemColor:#COLOR_WINDOW
  7320      Display primGetSystemColor:#COLOR_HIGHLIGHT
  7320      Display primGetSystemColor:#COLOR_HIGHLIGHT
  7321     "
  7321     "
  7337 
  7337 
  7338     if (ISCONNECTED
  7338     if (ISCONNECTED
  7339      && __isExternalAddress(windowId)
  7339      && __isExternalAddress(windowId)
  7340      && __isPoint(aPoint))
  7340      && __isPoint(aPoint))
  7341     {
  7341     {
  7342         xp = _point_X(aPoint);
  7342 	xp = _point_X(aPoint);
  7343         yp = _point_Y(aPoint);
  7343 	yp = _point_Y(aPoint);
  7344         if (__bothSmallInteger(xp, yp))
  7344 	if (__bothSmallInteger(xp, yp))
  7345         {
  7345 	{
  7346             POINT p;
  7346 	    POINT p;
  7347             HWND hWnd = _HWNDVal(windowId);
  7347 	    HWND hWnd = _HWNDVal(windowId);
  7348             p.x = __intVal(xp);
  7348 	    p.x = __intVal(xp);
  7349             p.y = __intVal(yp);
  7349 	    p.y = __intVal(yp);
  7350             ScreenToClient(hWnd, &p);
  7350 	    ScreenToClient(hWnd, &p);
  7351             child_ret = ChildWindowFromPointEx(hWnd,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
  7351 	    child_ret = ChildWindowFromPointEx(hWnd,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
  7352             /*console_printf("ChildWindow From %x Point %d.%d = %x\n",hWnd,p.x,p.y,child_ret);*/
  7352 	    /*console_printf("ChildWindow From %x Point %d.%d = %x\n",hWnd,p.x,p.y,child_ret);*/
  7353             if ((child_ret) && (child_ret != hWnd))
  7353 	    if ((child_ret) && (child_ret != hWnd))
  7354             {
  7354 	    {
  7355                 RETURN ( __MKEXTERNALADDRESS(child_ret) );
  7355 		RETURN ( __MKEXTERNALADDRESS(child_ret) );
  7356             }
  7356 	    }
  7357             RETURN ( nil );
  7357 	    RETURN ( nil );
  7358         }
  7358 	}
  7359     }
  7359     }
  7360 %}.
  7360 %}.
  7361 !
  7361 !
  7362 
  7362 
  7363 prim_getWindowRect:hWnd
  7363 prim_getWindowRect:hWnd
  7364     |l r t b|
  7364     |l r t b|
  7365 
  7365 
  7366 %{
  7366 %{
  7367     if (__isExternalAddress(hWnd) || __isExternalBytesLike(hWnd)) {
  7367     if (__isExternalAddress(hWnd) || __isExternalBytesLike(hWnd)) {
  7368         HANDLE _hwnd = __externalAddressVal(hWnd);
  7368 	HANDLE _hwnd = __externalAddressVal(hWnd);
  7369         RECT rect;
  7369 	RECT rect;
  7370 
  7370 
  7371         if (GetWindowRect(_hwnd, &rect)) {
  7371 	if (GetWindowRect(_hwnd, &rect)) {
  7372             l = __MKSMALLINT(rect.left);
  7372 	    l = __MKSMALLINT(rect.left);
  7373             r = __MKSMALLINT(rect.right);
  7373 	    r = __MKSMALLINT(rect.right);
  7374             t = __MKSMALLINT(rect.top);
  7374 	    t = __MKSMALLINT(rect.top);
  7375             b = __MKSMALLINT(rect.bottom);
  7375 	    b = __MKSMALLINT(rect.bottom);
  7376         }
  7376 	}
  7377     }
  7377     }
  7378 %}.
  7378 %}.
  7379     l isNil ifTrue:[
  7379     l isNil ifTrue:[
  7380         self primitiveFailed.
  7380 	self primitiveFailed.
  7381     ].
  7381     ].
  7382     ^ l@t corner:r@b
  7382     ^ l@t corner:r@b
  7383 !
  7383 !
  7384 
  7384 
  7385 protocolVersion
  7385 protocolVersion
  7406 
  7406 
  7407     if (aBoolean == true) {
  7407     if (aBoolean == true) {
  7408        __rightButtonIsLowerWindow = 1;
  7408        __rightButtonIsLowerWindow = 1;
  7409     } else {
  7409     } else {
  7410        if (aBoolean == false) {
  7410        if (aBoolean == false) {
  7411            __rightButtonIsLowerWindow = 0;
  7411 	   __rightButtonIsLowerWindow = 0;
  7412        }
  7412        }
  7413     }
  7413     }
  7414     RETURN (rslt);
  7414     RETURN (rslt);
  7415 %}
  7415 %}
  7416     "
  7416     "
  7462 
  7462 
  7463     if (aBoolean == true) {
  7463     if (aBoolean == true) {
  7464        __shiftedLeftButtonIsLowerWindow = 1;
  7464        __shiftedLeftButtonIsLowerWindow = 1;
  7465     } else {
  7465     } else {
  7466        if (aBoolean == false) {
  7466        if (aBoolean == false) {
  7467            __shiftedLeftButtonIsLowerWindow = 0;
  7467 	   __shiftedLeftButtonIsLowerWindow = 0;
  7468        }
  7468        }
  7469     }
  7469     }
  7470     RETURN (rslt);
  7470     RETURN (rslt);
  7471 %}
  7471 %}
  7472     "
  7472     "
  7477 
  7477 
  7478 supportedSystemColorKeys
  7478 supportedSystemColorKeys
  7479     "return a collection of supported systemColor keys"
  7479     "return a collection of supported systemColor keys"
  7480 
  7480 
  7481     ^#(
  7481     ^#(
  7482         COLOR_WINDOW
  7482 	COLOR_WINDOW
  7483         COLOR_WINDOWTEXT
  7483 	COLOR_WINDOWTEXT
  7484         COLOR_MENU
  7484 	COLOR_MENU
  7485         COLOR_MENUTEXT
  7485 	COLOR_MENUTEXT
  7486         COLOR_BTNFACE
  7486 	COLOR_BTNFACE
  7487         COLOR_BTNSHADOW
  7487 	COLOR_BTNSHADOW
  7488         COLOR_BTNTEXT
  7488 	COLOR_BTNTEXT
  7489         COLOR_GRAYTEXT
  7489 	COLOR_GRAYTEXT
  7490         COLOR_HIGHLIGHT
  7490 	COLOR_HIGHLIGHT
  7491         COLOR_HIGHLIGHTTEXT
  7491 	COLOR_HIGHLIGHTTEXT
  7492         COLOR_MENU
  7492 	COLOR_MENU
  7493         COLOR_MENUTEXT
  7493 	COLOR_MENUTEXT
  7494         COLOR_SCROLLBAR
  7494 	COLOR_SCROLLBAR
  7495         COLOR_SHADOW
  7495 	COLOR_SHADOW
  7496     )
  7496     )
  7497 !
  7497 !
  7498 
  7498 
  7499 translatePoint:aPoint from:windowId1 to:windowId2
  7499 translatePoint:aPoint from:windowId1 to:windowId2
  7500     "given a point in window1, return the coordinate in window2.
  7500     "given a point in window1, return the coordinate in window2.
  7512     POINT point;
  7512     POINT point;
  7513 
  7513 
  7514     if (__isExternalAddress(windowId1)
  7514     if (__isExternalAddress(windowId1)
  7515      && __isExternalAddress(windowId2)
  7515      && __isExternalAddress(windowId2)
  7516      && __bothSmallInteger(x1, y1)) {
  7516      && __bothSmallInteger(x1, y1)) {
  7517         w1 = _HWNDVal(windowId1);
  7517 	w1 = _HWNDVal(windowId1);
  7518         w2 = _HWNDVal(windowId2);
  7518 	w2 = _HWNDVal(windowId2);
  7519         point.x = __intVal(x1);
  7519 	point.x = __intVal(x1);
  7520         point.y = __intVal(y1);
  7520 	point.y = __intVal(y1);
  7521         CPRINTF(("TransPoint %x %d/%d ->", w1, point.x, point.y));
  7521 	CPRINTF(("TransPoint %x %d/%d ->", w1, point.x, point.y));
  7522         if (ClientToScreen(w1, &point) == FALSE) {
  7522 	if (ClientToScreen(w1, &point) == FALSE) {
  7523             RETURN (nil);
  7523 	    RETURN (nil);
  7524         }
  7524 	}
  7525         if (ScreenToClient(w2, &point) == FALSE) {
  7525 	if (ScreenToClient(w2, &point) == FALSE) {
  7526             RETURN (nil);
  7526 	    RETURN (nil);
  7527         }
  7527 	}
  7528         CPRINTF((" %x %d/%d\n", w2, point.x, point.y));
  7528 	CPRINTF((" %x %d/%d\n", w2, point.x, point.y));
  7529         ret = __MKPOINT_INT(point.x, point.y);
  7529 	ret = __MKPOINT_INT(point.x, point.y);
  7530     }
  7530     }
  7531 %}.
  7531 %}.
  7532     ^ ret
  7532     ^ ret
  7533 !
  7533 !
  7534 
  7534 
  7550      hit by this coordinate. Return nil if no view was hit.
  7550      hit by this coordinate. Return nil if no view was hit.
  7551      The returned id may be the id of a non ST view.
  7551      The returned id may be the id of a non ST view.
  7552      - used to find the window to drop objects after a cross-view drag."
  7552      - used to find the window to drop objects after a cross-view drag."
  7553 
  7553 
  7554     windowId notNil ifTrue:[
  7554     windowId notNil ifTrue:[
  7555         aPoint isPoint ifTrue:[
  7555 	aPoint isPoint ifTrue:[
  7556             "/(aPoint x > 30000) ifTrue:[self halt.].
  7556 	    "/(aPoint x > 30000) ifTrue:[self halt.].
  7557             "/(aPoint y > 30000) ifTrue:[self halt.].
  7557 	    "/(aPoint y > 30000) ifTrue:[self halt.].
  7558             "/aPoint printString errorPrintCR.
  7558 	    "/aPoint printString errorPrintCR.
  7559             ^ self primViewIdFromPoint:aPoint asPoint truncated in:windowId
  7559 	    ^ self primViewIdFromPoint:aPoint asPoint truncated in:windowId
  7560         ]
  7560 	]
  7561     ].
  7561     ].
  7562 
  7562 
  7563     ^ nil
  7563     ^ nil
  7564 !
  7564 !
  7565 
  7565 
  7615     "answer the bounds of the monitor the point is contained in"
  7615     "answer the bounds of the monitor the point is contained in"
  7616 
  7616 
  7617     |monitorHandle monitorInfo|
  7617     |monitorHandle monitorInfo|
  7618 
  7618 
  7619     self numberOfMonitors > 1 ifTrue:[
  7619     self numberOfMonitors > 1 ifTrue:[
  7620         "/ ******* MULTI SCREEN ******
  7620 	"/ ******* MULTI SCREEN ******
  7621         monitorHandle := self monitorHandleForPoint:aPoint.
  7621 	monitorHandle := self monitorHandleForPoint:aPoint.
  7622         monitorHandle notNil ifTrue:[
  7622 	monitorHandle notNil ifTrue:[
  7623             monitorInfo := self monitorInfoFor:monitorHandle.
  7623 	    monitorInfo := self monitorInfoFor:monitorHandle.
  7624             monitorInfo notNil ifTrue:[
  7624 	    monitorInfo notNil ifTrue:[
  7625                 ^ monitorInfo bounds
  7625 		^ monitorInfo bounds
  7626             ].
  7626 	    ].
  7627         ].
  7627 	].
  7628     ].
  7628     ].
  7629     ^ super monitorBoundsAt:aPoint
  7629     ^ super monitorBoundsAt:aPoint
  7630 
  7630 
  7631     "
  7631     "
  7632      Display monitorBoundsAt:100@100
  7632      Display monitorBoundsAt:100@100
  7686 
  7686 
  7687     |info minH|
  7687     |info minH|
  7688 
  7688 
  7689     minH := self usableHeight.
  7689     minH := self usableHeight.
  7690     self monitorHandles do:[:eachHandle |
  7690     self monitorHandles do:[:eachHandle |
  7691         info := self monitorInfoFor:eachHandle.
  7691 	info := self monitorInfoFor:eachHandle.
  7692         info notNil ifTrue:[ minH := minH min: info workHeight ].
  7692 	info notNil ifTrue:[ minH := minH min: info workHeight ].
  7693     ].
  7693     ].
  7694     ^ minH
  7694     ^ minH
  7695 
  7695 
  7696     "
  7696     "
  7697      Display smallestMonitorHeight
  7697      Display smallestMonitorHeight
  7794 
  7794 
  7795     w := wSingle := self getSystemMetrics:#SM_CXFULLSCREEN.
  7795     w := wSingle := self getSystemMetrics:#SM_CXFULLSCREEN.
  7796     h := hSingle := self getSystemMetrics:#SM_CYFULLSCREEN.
  7796     h := hSingle := self getSystemMetrics:#SM_CYFULLSCREEN.
  7797 
  7797 
  7798     (self numberOfMonitors) > 1 ifTrue:[
  7798     (self numberOfMonitors) > 1 ifTrue:[
  7799         w := self getSystemMetrics:#SM_CXVIRTUALSCREEN.
  7799 	w := self getSystemMetrics:#SM_CXVIRTUALSCREEN.
  7800         h := self getSystemMetrics:#SM_CYVIRTUALSCREEN.
  7800 	h := self getSystemMetrics:#SM_CYVIRTUALSCREEN.
  7801         (w isNil or:[h isNil]) ifTrue:[
  7801 	(w isNil or:[h isNil]) ifTrue:[
  7802             "/ not supported under win95 and win-nt4 - fallback to real extent
  7802 	    "/ not supported under win95 and win-nt4 - fallback to real extent
  7803             w := wSingle.
  7803 	    w := wSingle.
  7804             h := hSingle.
  7804 	    h := hSingle.
  7805         ] ifFalse:[
  7805 	] ifFalse:[
  7806             dx := (self getSystemMetrics:#SM_CXSCREEN) - wSingle.
  7806 	    dx := (self getSystemMetrics:#SM_CXSCREEN) - wSingle.
  7807             dy := (self getSystemMetrics:#SM_CYSCREEN) - hSingle.
  7807 	    dy := (self getSystemMetrics:#SM_CYSCREEN) - hSingle.
  7808             w := w - dx.
  7808 	    w := w - dx.
  7809             h := h - dy - 8.
  7809 	    h := h - dy - 8.
  7810         ].
  7810 	].
  7811     ].
  7811     ].
  7812     ^ w @ h.
  7812     ^ w @ h.
  7813 
  7813 
  7814     "
  7814     "
  7815      Display usableExtent
  7815      Display usableExtent
  7830      which display is at the given x-position"
  7830      which display is at the given x-position"
  7831 
  7831 
  7832     |info fullHeight usableHeight delta|
  7832     |info fullHeight usableHeight delta|
  7833 
  7833 
  7834     true "(self numberOfMonitors) > 1" ifTrue:[
  7834     true "(self numberOfMonitors) > 1" ifTrue:[
  7835         "/ ******* MULTI SCREEN ******
  7835 	"/ ******* MULTI SCREEN ******
  7836         info := self monitorInfoFor:(self monitorHandleForPoint:aPoint).
  7836 	info := self monitorInfoFor:(self monitorHandleForPoint:aPoint).
  7837         info notNil ifTrue:[
  7837 	info notNil ifTrue:[
  7838             ^ info workHeight
  7838 	    ^ info workHeight
  7839 
  7839 
  7840         "/ only works with single screen..
  7840 	"/ only works with single screen..
  7841 "/            fullHeight := self getSystemMetrics:#SM_CYVIRTUALSCREEN.
  7841 "/            fullHeight := self getSystemMetrics:#SM_CYVIRTUALSCREEN.
  7842 "/            usableHeight := self getSystemMetrics:#SM_CYFULLSCREEN.  "/ without any start-menu bar
  7842 "/            usableHeight := self getSystemMetrics:#SM_CYFULLSCREEN.  "/ without any start-menu bar
  7843 "/            delta := fullHeight - usableHeight.
  7843 "/            delta := fullHeight - usableHeight.
  7844 "/            ^ info workHeight - delta
  7844 "/            ^ info workHeight - delta
  7845         ].
  7845 	].
  7846     ].
  7846     ].
  7847     ^ self usableHeight
  7847     ^ self usableHeight
  7848 
  7848 
  7849     "
  7849     "
  7850      Display numberOfMonitors
  7850      Display numberOfMonitors
  7864 addMenuItemWithLabel:aString toWindowID:aWindowId
  7864 addMenuItemWithLabel:aString toWindowID:aWindowId
  7865     "not yet"
  7865     "not yet"
  7866 %{
  7866 %{
  7867 #ifdef NOT_YET_IMPLEMENTED
  7867 #ifdef NOT_YET_IMPLEMENTED
  7868     if (__isExternalAddress(aWindowId)) {
  7868     if (__isExternalAddress(aWindowId)) {
  7869         HWND hWin = _HWNDVal(aWindowId);
  7869 	HWND hWin = _HWNDVal(aWindowId);
  7870         HMENU hMenu;
  7870 	HMENU hMenu;
  7871 
  7871 
  7872         hMenu = GetMenu(hWin);
  7872 	hMenu = GetMenu(hWin);
  7873         if (hMenu) {
  7873 	if (hMenu) {
  7874 
  7874 
  7875         }
  7875 	}
  7876     }
  7876     }
  7877 #endif
  7877 #endif
  7878 %}
  7878 %}
  7879 !
  7879 !
  7880 
  7880 
  7882     |bitmapId|
  7882     |bitmapId|
  7883 
  7883 
  7884     bitmapId := self primCreateBitmapFromArray:anArray width:w height:h.
  7884     bitmapId := self primCreateBitmapFromArray:anArray width:w height:h.
  7885 
  7885 
  7886     bitmapId isNil ifTrue:[
  7886     bitmapId isNil ifTrue:[
  7887         'WINWORKSTATION: cannot create bitmap' errorPrintCR.
  7887 	'WINWORKSTATION: cannot create bitmap' errorPrintCR.
  7888     ].
  7888     ].
  7889     ^ bitmapId
  7889     ^ bitmapId
  7890 !
  7890 !
  7891 
  7891 
  7892 createBitmapWidth:w height:h
  7892 createBitmapWidth:w height:h
  7894 %{
  7894 %{
  7895     HANDLE newBitmapHandle;
  7895     HANDLE newBitmapHandle;
  7896     int b_width, b_height;
  7896     int b_width, b_height;
  7897 
  7897 
  7898     if (__bothSmallInteger(w, h)) {
  7898     if (__bothSmallInteger(w, h)) {
  7899         b_width = __intVal(w);
  7899 	b_width = __intVal(w);
  7900         b_height = __intVal(h);
  7900 	b_height = __intVal(h);
  7901         newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, NULL);
  7901 	newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, NULL);
  7902 
  7902 
  7903         if (newBitmapHandle) {
  7903 	if (newBitmapHandle) {
  7904 #ifdef COUNT_BMP_RESOURCES
  7904 #ifdef COUNT_BMP_RESOURCES
  7905             __cnt_bitmap++;
  7905 	    __cnt_bitmap++;
  7906             RES_BMP_PRINTF(("CreateBitmap %x %d\n",newBitmapHandle, __cnt_bitmap));
  7906 	    RES_BMP_PRINTF(("CreateBitmap %x %d\n",newBitmapHandle, __cnt_bitmap));
  7907 #endif
  7907 #endif
  7908             RETURN ( __MKOBJ(newBitmapHandle));
  7908 	    RETURN ( __MKOBJ(newBitmapHandle));
  7909         }
  7909 	}
  7910         DPRINTF(("empty bitmap handle = %x\n", newBitmapHandle));
  7910 	DPRINTF(("empty bitmap handle = %x\n", newBitmapHandle));
  7911     }
  7911     }
  7912     RETURN (nil);
  7912     RETURN (nil);
  7913 %}
  7913 %}
  7914 !
  7914 !
  7915 
  7915 
  7920 %{
  7920 %{
  7921     HANDLE newBitmapHandle;
  7921     HANDLE newBitmapHandle;
  7922 
  7922 
  7923     /*console_printf("CreateBitmap Color\n");*/
  7923     /*console_printf("CreateBitmap Color\n");*/
  7924     if (__bothSmallInteger(w, h) && __isSmallInteger(d) && ISCONNECTED) {
  7924     if (__bothSmallInteger(w, h) && __isSmallInteger(d) && ISCONNECTED) {
  7925         if (__intVal(d) == 1) {
  7925 	if (__intVal(d) == 1) {
  7926             newBitmapHandle = CreateBitmap(__intVal(w), __intVal(h) , 1, 1, NULL);
  7926 	    newBitmapHandle = CreateBitmap(__intVal(w), __intVal(h) , 1, 1, NULL);
  7927         } else {
  7927 	} else {
  7928 #if 0
  7928 #if 0
  7929             if (__intVal(d) != __depth) {
  7929 	    if (__intVal(d) != __depth) {
  7930                 console_printf("invalid depth\n");
  7930 		console_printf("invalid depth\n");
  7931                 RETURN (nil);
  7931 		RETURN (nil);
  7932             }
  7932 	    }
  7933 #endif
  7933 #endif
  7934             newBitmapHandle = CreateCompatibleBitmap(__rootDC, __intVal(w), __intVal(h) );
  7934 	    newBitmapHandle = CreateCompatibleBitmap(__rootDC, __intVal(w), __intVal(h) );
  7935         }
  7935 	}
  7936 
  7936 
  7937         if (newBitmapHandle) {
  7937 	if (newBitmapHandle) {
  7938 #ifdef COUNT_BMP_RESOURCES
  7938 #ifdef COUNT_BMP_RESOURCES
  7939             __cnt_bitmap++;
  7939 	    __cnt_bitmap++;
  7940             RES_BMP_PRINTF(("CreatePixmap %x %d\n",newBitmapHandle, __cnt_bitmap));
  7940 	    RES_BMP_PRINTF(("CreatePixmap %x %d\n",newBitmapHandle, __cnt_bitmap));
  7941 #endif
  7941 #endif
  7942             RETURN ( __MKOBJ(newBitmapHandle));
  7942 	    RETURN ( __MKOBJ(newBitmapHandle));
  7943         }
  7943 	}
  7944         DPRINTF(("empty bitmap handle = %x\n", newBitmapHandle));
  7944 	DPRINTF(("empty bitmap handle = %x\n", newBitmapHandle));
  7945     }
  7945     }
  7946     RETURN (nil);
  7946     RETURN (nil);
  7947 %}
  7947 %}
  7948 !
  7948 !
  7949 
  7949 
  7950 createWindowFor:aView type:typeSymbol
  7950 createWindowFor:aView type:typeSymbol
  7951                  origin:origin
  7951 		 origin:origin
  7952                  extent:extent
  7952 		 extent:extent
  7953                  minExtent:minExt
  7953 		 minExtent:minExt
  7954                  maxExtent:maxExt
  7954 		 maxExtent:maxExt
  7955                  borderWidth:bWidth
  7955 		 borderWidth:bWidth
  7956                  subViewOf:wsuperView
  7956 		 subViewOf:wsuperView
  7957                  style:wStyle
  7957 		 style:wStyle
  7958                  inputOnly:winputOnly
  7958 		 inputOnly:winputOnly
  7959                  label:wlabel
  7959 		 label:wlabel
  7960                  owner:wowner
  7960 		 owner:wowner
  7961                  icon:wicon
  7961 		 icon:wicon
  7962                  iconMask:wiconMaskArg
  7962 		 iconMask:wiconMaskArg
  7963                  iconView:wiconView
  7963 		 iconView:wiconView
  7964 
  7964 
  7965 
  7965 
  7966     |xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight
  7966     |xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight
  7967      wsuperViewId wiconId wiconMask invertedWiconMask wiconMaskId windowId
  7967      wsuperViewId wiconId wiconMask invertedWiconMask wiconMaskId windowId
  7968      weventMask wiconWidth wiconHeight windowType windowClass moreArgs|
  7968      weventMask wiconWidth wiconHeight windowType windowClass moreArgs|
  7969 
  7969 
  7970     "/ bColorId wiconViewId bitGravity vBgColor vBgForm deepForm
  7970     "/ bColorId wiconViewId bitGravity vBgColor vBgForm deepForm
  7971     "/  preferredVisual preferredDepth  viewGravity wcursorId
  7971     "/  preferredVisual preferredDepth  viewGravity wcursorId
  7972 
  7972 
  7973     displayId isNil ifTrue:[
  7973     displayId isNil ifTrue:[
  7974         self primitiveFailed.
  7974 	self primitiveFailed.
  7975         ^ nil
  7975 	^ nil
  7976     ].
  7976     ].
  7977 
  7977 
  7978     origin notNil ifTrue:[
  7978     origin notNil ifTrue:[
  7979         xpos := origin x.
  7979 	xpos := origin x.
  7980         ypos := origin y.
  7980 	ypos := origin y.
  7981     ] ifFalse:[
  7981     ] ifFalse:[
  7982         xpos := ypos := 0.
  7982 	xpos := ypos := 0.
  7983     ].
  7983     ].
  7984     extent notNil ifTrue:[
  7984     extent notNil ifTrue:[
  7985         wwidth := extent x.
  7985 	wwidth := extent x.
  7986         wheight := extent y.
  7986 	wheight := extent y.
  7987     ] ifFalse:[
  7987     ] ifFalse:[
  7988         wwidth := 100.
  7988 	wwidth := 100.
  7989         wheight := 40.
  7989 	wheight := 40.
  7990     ].
  7990     ].
  7991     minExt notNil ifTrue:[
  7991     minExt notNil ifTrue:[
  7992         minWidth := minExt x.
  7992 	minWidth := minExt x.
  7993         minHeight := minExt y
  7993 	minHeight := minExt y
  7994     ] ifFalse:[
  7994     ] ifFalse:[
  7995         minWidth := 1.
  7995 	minWidth := 1.
  7996         minHeight := 1.
  7996 	minHeight := 1.
  7997     ].
  7997     ].
  7998 
  7998 
  7999     maxExt notNil ifTrue:[
  7999     maxExt notNil ifTrue:[
  8000         maxWidth := maxExt x.
  8000 	maxWidth := maxExt x.
  8001         maxHeight := maxExt y
  8001 	maxHeight := maxExt y
  8002     ] ifFalse:[
  8002     ] ifFalse:[
  8003         "/ this is not really a good idea
  8003 	"/ this is not really a good idea
  8004         "/ maxWidth := width.
  8004 	"/ maxWidth := width.
  8005         "/ maxHeight := height.
  8005 	"/ maxHeight := height.
  8006     ].
  8006     ].
  8007 
  8007 
  8008     wsuperView notNil ifTrue:[
  8008     wsuperView notNil ifTrue:[
  8009         wsuperViewId := wsuperView id
  8009 	wsuperViewId := wsuperView id
  8010     ].
  8010     ].
  8011 
  8011 
  8012     wicon notNil ifTrue:[
  8012     wicon notNil ifTrue:[
  8013         wiconId := wicon id.
  8013 	wiconId := wicon id.
  8014         wiconHeight := wicon height.
  8014 	wiconHeight := wicon height.
  8015         wiconWidth  := wicon width.
  8015 	wiconWidth  := wicon width.
  8016         wiconMask := wiconMaskArg.
  8016 	wiconMask := wiconMaskArg.
  8017         wiconMask isNil ifTrue:[
  8017 	wiconMask isNil ifTrue:[
  8018             wiconMask := wicon mask.
  8018 	    wiconMask := wicon mask.
  8019         ].
  8019 	].
  8020         wiconMask notNil ifTrue:[
  8020 	wiconMask notNil ifTrue:[
  8021             "/ WIN32's mask has zeros for opaque pixels
  8021 	    "/ WIN32's mask has zeros for opaque pixels
  8022             invertedWiconMask := wiconMask copy.
  8022 	    invertedWiconMask := wiconMask copy.
  8023             invertedWiconMask bits invert.
  8023 	    invertedWiconMask bits invert.
  8024             invertedWiconMask := invertedWiconMask onDevice:self.
  8024 	    invertedWiconMask := invertedWiconMask onDevice:self.
  8025             wiconMaskId := invertedWiconMask id
  8025 	    wiconMaskId := invertedWiconMask id
  8026         ].
  8026 	].
  8027     ].
  8027     ].
  8028 "/    wiconView notNil ifTrue:[
  8028 "/    wiconView notNil ifTrue:[
  8029 "/        wiconViewId := wiconView id
  8029 "/        wiconViewId := wiconView id
  8030 "/    ].
  8030 "/    ].
  8031     weventMask := aView eventMask.
  8031     weventMask := aView eventMask.
  8032 
  8032 
  8033     NativeWidgets ifTrue:[
  8033     NativeWidgets ifTrue:[
  8034         windowType := aView nativeWindowType.
  8034 	windowType := aView nativeWindowType.
  8035         windowType notNil ifTrue:[
  8035 	windowType notNil ifTrue:[
  8036             "/ must be a symbol and is used
  8036 	    "/ must be a symbol and is used
  8037             "/ as a key into the nativeClass translation map.
  8037 	    "/ as a key into the nativeClass translation map.
  8038 
  8038 
  8039             windowClass := NativeWidgetClassTable at:windowType ifAbsent:windowType.
  8039 	    windowClass := NativeWidgetClassTable at:windowType ifAbsent:windowType.
  8040             self class debugNative ifTrue:[
  8040 	    self class debugNative ifTrue:[
  8041                 'WinWorkstation [info]: windowType: ' infoPrint. windowType infoPrint.
  8041 		'WinWorkstation [info]: windowType: ' infoPrint. windowType infoPrint.
  8042                 ' windowClass: ' infoPrint. windowClass infoPrintCR.
  8042 		' windowClass: ' infoPrint. windowClass infoPrintCR.
  8043             ].
  8043 	    ].
  8044         ].
  8044 	].
  8045     ].
  8045     ].
  8046     aView isMDIClientView ifTrue:[
  8046     aView isMDIClientView ifTrue:[
  8047         windowClass := 'mdiclient'.
  8047 	windowClass := 'mdiclient'.
  8048     ].
  8048     ].
  8049 
  8049 
  8050     windowClass notNil ifTrue:[
  8050     windowClass notNil ifTrue:[
  8051         aView beNativeWidget.
  8051 	aView beNativeWidget.
  8052     ] ifFalse:[
  8052     ] ifFalse:[
  8053         aView beNonNativeWidget.
  8053 	aView beNonNativeWidget.
  8054     ].
  8054     ].
  8055 
  8055 
  8056     moreArgs := Array new:20.
  8056     moreArgs := Array new:20.
  8057     moreArgs at:1 put:xpos.
  8057     moreArgs at:1 put:xpos.
  8058     moreArgs at:2 put:ypos.
  8058     moreArgs at:2 put:ypos.
  8073     moreArgs at:17 put:weventMask.
  8073     moreArgs at:17 put:weventMask.
  8074     moreArgs at:18 put:(aView className asString).
  8074     moreArgs at:18 put:(aView className asString).
  8075 
  8075 
  8076     [
  8076     [
  8077       windowId := self
  8077       windowId := self
  8078                   primCreateWindowFor:aView
  8078 		  primCreateWindowFor:aView
  8079                   type:typeSymbol
  8079 		  type:typeSymbol
  8080                   borderWidth:bWidth
  8080 		  borderWidth:bWidth
  8081                   subViewOf:wsuperView
  8081 		  subViewOf:wsuperView
  8082                   style:wStyle
  8082 		  style:wStyle
  8083                   inputOnly:winputOnly
  8083 		  inputOnly:winputOnly
  8084                   label:wlabel
  8084 		  label:wlabel
  8085                   owner:wowner
  8085 		  owner:wowner
  8086                   icon:wicon
  8086 		  icon:wicon
  8087                   iconMask:wiconMask
  8087 		  iconMask:wiconMask
  8088                   moreArgs:moreArgs.
  8088 		  moreArgs:moreArgs.
  8089       aView graphicsContext setId:windowId.
  8089       aView graphicsContext setId:windowId.
  8090     ] valueUninterruptably.
  8090     ] valueUninterruptably.
  8091 
  8091 
  8092     windowId notNil ifTrue:[
  8092     windowId notNil ifTrue:[
  8093         self addKnownView:aView withId:windowId
  8093 	self addKnownView:aView withId:windowId
  8094     ].
  8094     ].
  8095     ^ windowId
  8095     ^ windowId
  8096 
  8096 
  8097     "Modified: / 28-01-2012 / 10:20:30 / cg"
  8097     "Modified: / 28-01-2012 / 10:20:30 / cg"
  8098 !
  8098 !
  8099 
  8099 
  8100 destroyGC:aGCId
  8100 destroyGC:aGCId
  8101 %{
  8101 %{
  8102     if (__isExternalAddress(aGCId)) {
  8102     if (__isExternalAddress(aGCId)) {
  8103         struct gcData *gcData = _GCDATA(aGCId);
  8103 	struct gcData *gcData = _GCDATA(aGCId);
  8104 
  8104 
  8105         if (gcData == NULL) {
  8105 	if (gcData == NULL) {
  8106             console_fprintf(stderr, "WinWorkstation [warning]: trying to destroy GC twice\n");
  8106 	    console_fprintf(stderr, "WinWorkstation [warning]: trying to destroy GC twice\n");
  8107             RETURN(self);
  8107 	    RETURN(self);
  8108         }
  8108 	}
  8109 
  8109 
  8110 #ifdef COUNT_RESOURCES
  8110 #ifdef COUNT_RESOURCES
  8111          __cnt_gcData--;
  8111 	 __cnt_gcData--;
  8112         RESPRINTF(("DestroyGcData %d\n",__cnt_gcData));
  8112 	RESPRINTF(("DestroyGcData %d\n",__cnt_gcData));
  8113 #endif
  8113 #endif
  8114 
  8114 
  8115 #ifdef CACHE_LAST_DC
  8115 #ifdef CACHE_LAST_DC
  8116         if (lastGcData == gcData) {
  8116 	if (lastGcData == gcData) {
  8117             _releaseDC(gcData);
  8117 	    _releaseDC(gcData);
  8118         }
  8118 	}
  8119 #endif
  8119 #endif
  8120         __ExternalAddressInstPtr(aGCId)->e_address = NULL;
  8120 	__ExternalAddressInstPtr(aGCId)->e_address = NULL;
  8121 
  8121 
  8122         freeGcData(gcData);
  8122 	freeGcData(gcData);
  8123     }
  8123     }
  8124 %}
  8124 %}
  8125 !
  8125 !
  8126 
  8126 
  8127 destroyPixmap:aDrawableId
  8127 destroyPixmap:aDrawableId
  8128 
  8128 
  8129 %{  /* NOCONTEXT */
  8129 %{  /* NOCONTEXT */
  8130     if (__isExternalAddress(aDrawableId) && ISCONNECTED) {
  8130     if (__isExternalAddress(aDrawableId) && ISCONNECTED) {
  8131         HANDLE bitmapHandle = _HANDLEVal(aDrawableId);
  8131 	HANDLE bitmapHandle = _HANDLEVal(aDrawableId);
  8132 
  8132 
  8133         if (bitmapHandle) {
  8133 	if (bitmapHandle) {
  8134 #ifdef COUNT_BMP_RESOURCES
  8134 #ifdef COUNT_BMP_RESOURCES
  8135             __cnt_bitmap--;
  8135 	    __cnt_bitmap--;
  8136             RES_BMP_PRINTF(("DestroyPixmap %x %d\n", bitmapHandle, __cnt_bitmap));
  8136 	    RES_BMP_PRINTF(("DestroyPixmap %x %d\n", bitmapHandle, __cnt_bitmap));
  8137 #endif
  8137 #endif
  8138             _DeleteObject(bitmapHandle, __LINE__);
  8138 	    _DeleteObject(bitmapHandle, __LINE__);
  8139         }
  8139 	}
  8140     }
  8140     }
  8141 %}
  8141 %}
  8142 !
  8142 !
  8143 
  8143 
  8144 destroyView:aView withId:aWindowId
  8144 destroyView:aView withId:aWindowId
  8151 %{  /* NOCONTEXT */
  8151 %{  /* NOCONTEXT */
  8152     HWND hWnd;
  8152     HWND hWnd;
  8153     struct gcData *gcData;
  8153     struct gcData *gcData;
  8154 
  8154 
  8155     if (__isExternalAddress(aDrawableId)) {
  8155     if (__isExternalAddress(aDrawableId)) {
  8156         hWnd = _HWNDVal(aDrawableId);
  8156 	hWnd = _HWNDVal(aDrawableId);
  8157 
  8157 
  8158         if (! hWnd) {
  8158 	if (! hWnd) {
  8159             RETURN (nil);
  8159 	    RETURN (nil);
  8160         }
  8160 	}
  8161 
  8161 
  8162         gcData = newGcData();
  8162 	gcData = newGcData();
  8163         if (! gcData) {
  8163 	if (! gcData) {
  8164             RETURN (nil);
  8164 	    RETURN (nil);
  8165         }
  8165 	}
  8166 
  8166 
  8167 #ifdef COUNT_RESOURCES
  8167 #ifdef COUNT_RESOURCES
  8168         __cnt_gcData++;
  8168 	__cnt_gcData++;
  8169         RESPRINTF(("CreateGcData %d\n",__cnt_gcData));
  8169 	RESPRINTF(("CreateGcData %d\n",__cnt_gcData));
  8170 #endif
  8170 #endif
  8171         gcData->hWnd = hWnd;
  8171 	gcData->hWnd = hWnd;
  8172         gcData->_hDC = 0;
  8172 	gcData->_hDC = 0;
  8173         CPRINTF(("gcFor hDC=%x hWnd=%x\n",gcData->_hDC,gcData->hWnd));
  8173 	CPRINTF(("gcFor hDC=%x hWnd=%x\n",gcData->_hDC,gcData->hWnd));
  8174         RETURN ( __MKOBJ(gcData) );
  8174 	RETURN ( __MKOBJ(gcData) );
  8175     }
  8175     }
  8176     RETURN (nil);
  8176     RETURN (nil);
  8177 %}
  8177 %}
  8178 !
  8178 !
  8179 
  8179 
  8180 gcForBitmap:aDrawableId
  8180 gcForBitmap:aDrawableId
  8181 
  8181 
  8182 %{  /* NOCONTEXT */
  8182 %{  /* NOCONTEXT */
  8183 
  8183 
  8184     if (__isExternalAddress(aDrawableId)) {  /* HBITMAP */
  8184     if (__isExternalAddress(aDrawableId)) {  /* HBITMAP */
  8185         struct gcData *gcData;
  8185 	struct gcData *gcData;
  8186         BITMAP bitmap;
  8186 	BITMAP bitmap;
  8187         HBITMAP hBitmap = _HBITMAPVAL(aDrawableId);
  8187 	HBITMAP hBitmap = _HBITMAPVAL(aDrawableId);
  8188         HDC hDC;
  8188 	HDC hDC;
  8189 
  8189 
  8190         if (! hBitmap) {
  8190 	if (! hBitmap) {
  8191             RETURN (nil);
  8191 	    RETURN (nil);
  8192         }
  8192 	}
  8193         gcData = newGcData();
  8193 	gcData = newGcData();
  8194         if (! gcData) {
  8194 	if (! gcData) {
  8195             RETURN (nil);
  8195 	    RETURN (nil);
  8196         }
  8196 	}
  8197 
  8197 
  8198         if (GetObject(hBitmap, sizeof(bitmap), &bitmap)) {
  8198 	if (GetObject(hBitmap, sizeof(bitmap), &bitmap)) {
  8199             DDDDPRINTF(("bitmap info:%d\n", bitmap.bmBitsPixel));
  8199 	    DDDDPRINTF(("bitmap info:%d\n", bitmap.bmBitsPixel));
  8200         } else {
  8200 	} else {
  8201             DPRINTF(("noinfo returned for bitmap\n"));
  8201 	    DPRINTF(("noinfo returned for bitmap\n"));
  8202             /* mhmh - can this happen ? */
  8202 	    /* mhmh - can this happen ? */
  8203             bitmap.bmBitsPixel = 1;
  8203 	    bitmap.bmBitsPixel = 1;
  8204         }
  8204 	}
  8205         gcData->hBitmap = hBitmap;
  8205 	gcData->hBitmap = hBitmap;
  8206         gcData->bitmapColorBitCount = bitmap.bmBitsPixel;
  8206 	gcData->bitmapColorBitCount = bitmap.bmBitsPixel;
  8207 
  8207 
  8208 #ifdef COUNT_RESOURCES
  8208 #ifdef COUNT_RESOURCES
  8209         __cnt_gcData++;
  8209 	__cnt_gcData++;
  8210         RESPRINTF(("CreateGcData %d\n", __cnt_gcData));
  8210 	RESPRINTF(("CreateGcData %d\n", __cnt_gcData));
  8211 #endif
  8211 #endif
  8212         RETURN ( __MKOBJ(gcData) );
  8212 	RETURN ( __MKOBJ(gcData) );
  8213     }
  8213     }
  8214     RETURN (nil);
  8214     RETURN (nil);
  8215 %}
  8215 %}
  8216 !
  8216 !
  8217 
  8217 
  8220 %{  /* NOCONTEXT */
  8220 %{  /* NOCONTEXT */
  8221     HDC hDC;
  8221     HDC hDC;
  8222     struct gcData *gcData;
  8222     struct gcData *gcData;
  8223 
  8223 
  8224     if (__isExternalAddressLike(aDeviceContextHandle)) {
  8224     if (__isExternalAddressLike(aDeviceContextHandle)) {
  8225         hDC = _HDCVal(aDeviceContextHandle);
  8225 	hDC = _HDCVal(aDeviceContextHandle);
  8226 
  8226 
  8227         if (! hDC) {
  8227 	if (! hDC) {
  8228             RETURN (nil);
  8228 	    RETURN (nil);
  8229         }
  8229 	}
  8230 
  8230 
  8231         gcData = newGcData();
  8231 	gcData = newGcData();
  8232         if (! gcData) {
  8232 	if (! gcData) {
  8233             RETURN (nil);
  8233 	    RETURN (nil);
  8234         }
  8234 	}
  8235 
  8235 
  8236 #ifdef COUNT_RESOURCES
  8236 #ifdef COUNT_RESOURCES
  8237         __cnt_gcData++;
  8237 	__cnt_gcData++;
  8238         RESPRINTF(("CreateGcData %d\n",__cnt_gcData));
  8238 	RESPRINTF(("CreateGcData %d\n",__cnt_gcData));
  8239 #endif
  8239 #endif
  8240         gcData->_hDC = hDC;
  8240 	gcData->_hDC = hDC;
  8241         gcData->doNotCacheOrRelease = 1;
  8241 	gcData->doNotCacheOrRelease = 1;
  8242         CPRINTF(("gcFor hDC=%x hWnd=%x\n",gcData->_hDC,gcData->hWnd));
  8242 	CPRINTF(("gcFor hDC=%x hWnd=%x\n",gcData->_hDC,gcData->hWnd));
  8243         RETURN ( __MKOBJ(gcData) );
  8243 	RETURN ( __MKOBJ(gcData) );
  8244     }
  8244     }
  8245     RETURN (nil);
  8245     RETURN (nil);
  8246 %}
  8246 %}
  8247 !
  8247 !
  8248 
  8248 
  8258     OBJ num;
  8258     OBJ num;
  8259     unsigned char *allocatedBits = 0;
  8259     unsigned char *allocatedBits = 0;
  8260     unsigned char fastBits[10000];
  8260     unsigned char fastBits[10000];
  8261 
  8261 
  8262     if (__bothSmallInteger(w, h) && __isNonNilObject(anArray)) {
  8262     if (__bothSmallInteger(w, h) && __isNonNilObject(anArray)) {
  8263         b_width = __intVal(w);
  8263 	b_width = __intVal(w);
  8264         b_height = __intVal(h);
  8264 	b_height = __intVal(h);
  8265         bytesPerRowST = (b_width + 7) / 8;
  8265 	bytesPerRowST = (b_width + 7) / 8;
  8266         bytesPerRowWN = ((b_width + 15) / 16) * 2;
  8266 	bytesPerRowWN = ((b_width + 15) / 16) * 2;
  8267         padding = bytesPerRowWN - bytesPerRowST;
  8267 	padding = bytesPerRowWN - bytesPerRowST;
  8268 
  8268 
  8269         if ((padding == 0) && (__isByteArrayLike(anArray))) {
  8269 	if ((padding == 0) && (__isByteArrayLike(anArray))) {
  8270             b_bits = __ByteArrayInstPtr(anArray)->ba_element;
  8270 	    b_bits = __ByteArrayInstPtr(anArray)->ba_element;
  8271             cp = 0;
  8271 	    cp = 0;
  8272         } else {
  8272 	} else {
  8273             int nBytes = b_height * bytesPerRowWN;
  8273 	    int nBytes = b_height * bytesPerRowWN;
  8274 
  8274 
  8275             if (nBytes < sizeof(fastBits)) {
  8275 	    if (nBytes < sizeof(fastBits)) {
  8276                 cp = b_bits = fastBits;
  8276 		cp = b_bits = fastBits;
  8277             } else {
  8277 	    } else {
  8278                 cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
  8278 		cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
  8279                 if (! cp) goto fail;
  8279 		if (! cp) goto fail;
  8280             }
  8280 	    }
  8281         }
  8281 	}
  8282         if (cp) {
  8282 	if (cp) {
  8283             if (__qIsArrayLike(anArray)) {
  8283 	    if (__qIsArrayLike(anArray)) {
  8284                 OBJ *op;
  8284 		OBJ *op;
  8285 
  8285 
  8286                 index = 1;
  8286 		index = 1;
  8287                 op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
  8287 		op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
  8288                 for (row = b_height; row; row--) {
  8288 		for (row = b_height; row; row--) {
  8289                     for (col = bytesPerRowST; col; col--) {
  8289 		    for (col = bytesPerRowST; col; col--) {
  8290                         num = *op++;
  8290 			num = *op++;
  8291                         if (! __isSmallInteger(num))
  8291 			if (! __isSmallInteger(num))
  8292                             goto fail;
  8292 			    goto fail;
  8293                         *cp++ = __intVal(num);
  8293 			*cp++ = __intVal(num);
  8294                     }
  8294 		    }
  8295                     cp += padding;
  8295 		    cp += padding;
  8296                 }
  8296 		}
  8297             } else if (__qIsByteArrayLike(anArray)) {
  8297 	    } else if (__qIsByteArrayLike(anArray)) {
  8298                 unsigned char *pBits;
  8298 		unsigned char *pBits;
  8299 
  8299 
  8300                 pBits = __ByteArrayInstPtr(anArray)->ba_element;
  8300 		pBits = __ByteArrayInstPtr(anArray)->ba_element;
  8301                 for (row = b_height; row; row--) {
  8301 		for (row = b_height; row; row--) {
  8302                     for (col = bytesPerRowST; col; col--) {
  8302 		    for (col = bytesPerRowST; col; col--) {
  8303                         *cp++ = ( *pBits++ /*^ 0xFF*/ );
  8303 			*cp++ = ( *pBits++ /*^ 0xFF*/ );
  8304                     }
  8304 		    }
  8305                     cp += padding;
  8305 		    cp += padding;
  8306                 }
  8306 		}
  8307             } else {
  8307 	    } else {
  8308                 goto fail;
  8308 		goto fail;
  8309             }
  8309 	    }
  8310         }
  8310 	}
  8311         CPRINTF(("create bitmap ...\n"));
  8311 	CPRINTF(("create bitmap ...\n"));
  8312 
  8312 
  8313         newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits );
  8313 	newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits );
  8314 
  8314 
  8315         if (newBitmapHandle ) {
  8315 	if (newBitmapHandle ) {
  8316 #ifdef COUNT_BMP_RESOURCES
  8316 #ifdef COUNT_BMP_RESOURCES
  8317             __cnt_bitmap++;
  8317 	    __cnt_bitmap++;
  8318             RES_BMP_PRINTF(("CreateBitmap %x %d\n",newBitmapHandle,__cnt_bitmap));
  8318 	    RES_BMP_PRINTF(("CreateBitmap %x %d\n",newBitmapHandle,__cnt_bitmap));
  8319 #endif
  8319 #endif
  8320             DDDDPRINTF(("returning bitmap %x ...\n", newBitmapHandle));
  8320 	    DDDDPRINTF(("returning bitmap %x ...\n", newBitmapHandle));
  8321             if (allocatedBits) {
  8321 	    if (allocatedBits) {
  8322                 free(allocatedBits);
  8322 		free(allocatedBits);
  8323             }
  8323 	    }
  8324             RETURN ( __MKEXTERNALADDRESS(newBitmapHandle));
  8324 	    RETURN ( __MKEXTERNALADDRESS(newBitmapHandle));
  8325         }
  8325 	}
  8326     }
  8326     }
  8327 fail: ;
  8327 fail: ;
  8328     DDPRINTF(("create bitmap FAILED!!!\n"));
  8328     DDPRINTF(("create bitmap FAILED!!!\n"));
  8329     if (allocatedBits) {
  8329     if (allocatedBits) {
  8330         CPRINTF(("freeing up bitmap bits ...\n"));
  8330 	CPRINTF(("freeing up bitmap bits ...\n"));
  8331         free(allocatedBits);
  8331 	free(allocatedBits);
  8332     }
  8332     }
  8333     CPRINTF(("returning nil ...\n"));
  8333     CPRINTF(("returning nil ...\n"));
  8334     RETURN ( nil );
  8334     RETURN ( nil );
  8335 %}
  8335 %}
  8336 !
  8336 !
  8337 
  8337 
  8338 primCreateWindowFor:aView type:typeSymbol
  8338 primCreateWindowFor:aView type:typeSymbol
  8339           borderWidth:bWidth subViewOf:wsuperView
  8339 	  borderWidth:bWidth subViewOf:wsuperView
  8340           style:wStyle inputOnly:winputOnly
  8340 	  style:wStyle inputOnly:winputOnly
  8341           label:wlabel owner:wowner
  8341 	  label:wlabel owner:wowner
  8342           icon:wicon iconMask:wiconMask
  8342 	  icon:wicon iconMask:wiconMask
  8343           moreArgs:moreArgs
  8343 	  moreArgs:moreArgs
  8344 
  8344 
  8345 %{  /* STACK: 16000 */
  8345 %{  /* STACK: 16000 */
  8346 
  8346 
  8347     WNDCLASS wc;
  8347     WNDCLASS wc;
  8348     long bg, bd, bw;
  8348     long bg, bd, bw;
  8397     bg = WhitePixel;
  8397     bg = WhitePixel;
  8398     bd = BlackPixel;
  8398     bd = BlackPixel;
  8399 
  8399 
  8400     /* get bitmap for icon */
  8400     /* get bitmap for icon */
  8401     if ( __isExternalAddress(wiconId) ) {
  8401     if ( __isExternalAddress(wiconId) ) {
  8402         xBitMap = _HBITMAPVAL( wiconId );
  8402 	xBitMap = _HBITMAPVAL( wiconId );
  8403         if ( xBitMap != 0 ) {
  8403 	if ( xBitMap != 0 ) {
  8404             BITMAP bm;
  8404 	    BITMAP bm;
  8405 
  8405 
  8406             if (GetObject(xBitMap, sizeof(bm), (LPSTR)&bm)) {
  8406 	    if (GetObject(xBitMap, sizeof(bm), (LPSTR)&bm)) {
  8407                 int d = bm.bmPlanes * bm.bmBitsPixel;
  8407 		int d = bm.bmPlanes * bm.bmBitsPixel;
  8408                 BYTE *ep;
  8408 		BYTE *ep;
  8409                 int height, width;
  8409 		int height, width;
  8410                 int nBytes;
  8410 		int nBytes;
  8411                 unsigned char *allocatedBits = 0;
  8411 		unsigned char *allocatedBits = 0;
  8412                 int privateMask = 0;
  8412 		int privateMask = 0;
  8413 
  8413 
  8414                 if ( __isExternalAddress(wiconMaskId) ) {
  8414 		if ( __isExternalAddress(wiconMaskId) ) {
  8415                     maskBitmap = _HBITMAPVAL( wiconMaskId );
  8415 		    maskBitmap = _HBITMAPVAL( wiconMaskId );
  8416                 } else {
  8416 		} else {
  8417                     if (wiconMaskId != nil) {
  8417 		    if (wiconMaskId != nil) {
  8418                         PRINTF(("WinWorkstat [warning]: wiconMaskId is not an external address\n"));
  8418 			PRINTF(("WinWorkstat [warning]: wiconMaskId is not an external address\n"));
  8419                     }
  8419 		    }
  8420                     maskBitmap = 0;
  8420 		    maskBitmap = 0;
  8421                 }
  8421 		}
  8422 
  8422 
  8423                 /*
  8423 		/*
  8424                  * if there is no mask, generate one
  8424 		 * if there is no mask, generate one
  8425                  */
  8425 		 */
  8426                 if (maskBitmap == 0) {
  8426 		if (maskBitmap == 0) {
  8427                     DPRINTF(("Bitmap w:%d h:%d p:%d d:%d\n",bm.bmWidth,bm.bmHeight,bm.bmPlanes,bm.bmBitsPixel));
  8427 		    DPRINTF(("Bitmap w:%d h:%d p:%d d:%d\n",bm.bmWidth,bm.bmHeight,bm.bmPlanes,bm.bmBitsPixel));
  8428                     height = __intVal( wiconHeight );
  8428 		    height = __intVal( wiconHeight );
  8429                     width  = __intVal( wiconWidth  );
  8429 		    width  = __intVal( wiconWidth  );
  8430                     nBytes = ( width + 15 ) / 8;
  8430 		    nBytes = ( width + 15 ) / 8;
  8431                     nBytes = height * nBytes;
  8431 		    nBytes = height * nBytes;
  8432                     if (nBytes < sizeof(fastBits)) {
  8432 		    if (nBytes < sizeof(fastBits)) {
  8433                         ep = fastBits;
  8433 			ep = fastBits;
  8434                     } else {
  8434 		    } else {
  8435                         ep = allocatedBits = (unsigned char *) malloc(nBytes);
  8435 			ep = allocatedBits = (unsigned char *) malloc(nBytes);
  8436                     }
  8436 		    }
  8437                     if ( ep == 0 ) {
  8437 		    if ( ep == 0 ) {
  8438                         PRINTF(( "WinWorkstat [warning]: malloc failed\n" ));
  8438 			PRINTF(( "WinWorkstat [warning]: malloc failed\n" ));
  8439                     } else {
  8439 		    } else {
  8440                         memset(ep, 0, nBytes);
  8440 			memset(ep, 0, nBytes);
  8441                         maskBitmap = CreateBitmap(width, height, 1, 1, ep );
  8441 			maskBitmap = CreateBitmap(width, height, 1, 1, ep );
  8442                         if ( maskBitmap == NULL ) {
  8442 			if ( maskBitmap == NULL ) {
  8443                             PRINTF(( "WinWorkstat [warning]: mask CREATION failed\n" ));
  8443 			    PRINTF(( "WinWorkstat [warning]: mask CREATION failed\n" ));
  8444                         } else {
  8444 			} else {
  8445                             privateMask = 1;
  8445 			    privateMask = 1;
  8446                         }
  8446 			}
  8447                     }
  8447 		    }
  8448                 }
  8448 		}
  8449                 if ( maskBitmap != NULL ) {
  8449 		if ( maskBitmap != NULL ) {
  8450                     DPRINTF(( "BITMAP mask CREATED!!!\n" ));
  8450 		    DPRINTF(( "BITMAP mask CREATED!!!\n" ));
  8451                     iconInfo.fIcon = TRUE;
  8451 		    iconInfo.fIcon = TRUE;
  8452                     iconInfo.hbmMask  = maskBitmap;
  8452 		    iconInfo.hbmMask  = maskBitmap;
  8453                     iconInfo.hbmColor = xBitMap;
  8453 		    iconInfo.hbmColor = xBitMap;
  8454                     xIcon = CreateIconIndirect( &iconInfo );
  8454 		    xIcon = CreateIconIndirect( &iconInfo );
  8455                     if (privateMask) {
  8455 		    if (privateMask) {
  8456                         _DeleteObject( maskBitmap, __LINE__ );
  8456 			_DeleteObject( maskBitmap, __LINE__ );
  8457                     }
  8457 		    }
  8458                 } else {
  8458 		} else {
  8459                     PRINTF(( "WinWorkstat [warning]: no mask for icon !\n" ));
  8459 		    PRINTF(( "WinWorkstat [warning]: no mask for icon !\n" ));
  8460                 }
  8460 		}
  8461 
  8461 
  8462                 if (allocatedBits) {
  8462 		if (allocatedBits) {
  8463                     free(allocatedBits);
  8463 		    free(allocatedBits);
  8464                 }
  8464 		}
  8465             }
  8465 	    }
  8466         } else {
  8466 	} else {
  8467             DPRINTF(("WinWorkstat [warning]: xBitMap is zero \n" ));
  8467 	    DPRINTF(("WinWorkstat [warning]: xBitMap is zero \n" ));
  8468         }
  8468 	}
  8469     } else {
  8469     } else {
  8470         if (wiconId != nil) {
  8470 	if (wiconId != nil) {
  8471             PRINTF(("WinWorkstat [warning]: wiconId is not an external address\n"));
  8471 	    PRINTF(("WinWorkstat [warning]: wiconId is not an external address\n"));
  8472         }
  8472 	}
  8473     }
  8473     }
  8474 
  8474 
  8475     if (__bothSmallInteger(wwidth, wheight)) {
  8475     if (__bothSmallInteger(wwidth, wheight)) {
  8476         w = __intVal(wwidth);
  8476 	w = __intVal(wwidth);
  8477         h = __intVal(wheight);
  8477 	h = __intVal(wheight);
  8478     } else {
  8478     } else {
  8479         w = h = 100;
  8479 	w = h = 100;
  8480     }
  8480     }
  8481 
  8481 
  8482     if (__bothSmallInteger(xpos, ypos)) {
  8482     if (__bothSmallInteger(xpos, ypos)) {
  8483         x = __intVal(xpos);
  8483 	x = __intVal(xpos);
  8484         y = __intVal(ypos);
  8484 	y = __intVal(ypos);
  8485     } else {
  8485     } else {
  8486         x = y = 0;
  8486 	x = y = 0;
  8487     }
  8487     }
  8488 
  8488 
  8489     if (__bothSmallInteger(minWidth, minHeight)) {
  8489     if (__bothSmallInteger(minWidth, minHeight)) {
  8490         min_width = __intVal(minWidth);
  8490 	min_width = __intVal(minWidth);
  8491         min_height = __intVal(minHeight);
  8491 	min_height = __intVal(minHeight);
  8492     } else {
  8492     } else {
  8493         DPRINTF(("WinWorkstat [warning]: minWidth/minHeight not integer\n"))
  8493 	DPRINTF(("WinWorkstat [warning]: minWidth/minHeight not integer\n"))
  8494         min_width = min_height = 0;
  8494 	min_width = min_height = 0;
  8495     }
  8495     }
  8496 
  8496 
  8497     if (__bothSmallInteger(maxWidth, maxHeight)) {
  8497     if (__bothSmallInteger(maxWidth, maxHeight)) {
  8498         max_width = __intVal(maxWidth);
  8498 	max_width = __intVal(maxWidth);
  8499         max_height = __intVal(maxHeight);
  8499 	max_height = __intVal(maxHeight);
  8500     } else {
  8500     } else {
  8501         DPRINTF(("WinWorkstat [warning]: maxWidth/maxHeight not integer\n"))
  8501 	DPRINTF(("WinWorkstat [warning]: maxWidth/maxHeight not integer\n"))
  8502         max_width = max_height = 10000;
  8502 	max_width = max_height = 10000;
  8503     }
  8503     }
  8504 
  8504 
  8505     winStyleBits = winEXStyleBits = 0;
  8505     winStyleBits = winEXStyleBits = 0;
  8506 
  8506 
  8507     if (__isSmallInteger(bWidth)) {
  8507     if (__isSmallInteger(bWidth)) {
  8508         bw = __intVal(bWidth);
  8508 	bw = __intVal(bWidth);
  8509         if (bw) {
  8509 	if (bw) {
  8510             winStyleBits |= WS_BORDER;
  8510 	    winStyleBits |= WS_BORDER;
  8511             bw = 1;
  8511 	    bw = 1;
  8512         }
  8512 	}
  8513     } else {
  8513     } else {
  8514         bw = 0;
  8514 	bw = 0;
  8515     }
  8515     }
  8516 
  8516 
  8517     className = app_name;
  8517     className = app_name;
  8518     if (__isStringLike(windowClass)) {
  8518     if (__isStringLike(windowClass)) {
  8519         className = __stringVal(windowClass);
  8519 	className = __stringVal(windowClass);
  8520         NDPRINTF(("className: %s\n", className));
  8520 	NDPRINTF(("className: %s\n", className));
  8521 
  8521 
  8522         if (__isInteger(wStyle)) {
  8522 	if (__isInteger(wStyle)) {
  8523             isNativeWindow = 1;
  8523 	    isNativeWindow = 1;
  8524             winStyleBits |= __longIntVal(wStyle);
  8524 	    winStyleBits |= __longIntVal(wStyle);
  8525             NDPRINTF(("winStyleBits: %x\n", winStyleBits));
  8525 	    NDPRINTF(("winStyleBits: %x\n", winStyleBits));
  8526         } else {
  8526 	} else {
  8527             if (windowType != nil) {
  8527 	    if (windowType != nil) {
  8528                 if (windowType == @symbol(RadioButton)) {
  8528 		if (windowType == @symbol(RadioButton)) {
  8529                     isNativeWindow = 1;
  8529 		    isNativeWindow = 1;
  8530                     winStyleBits |= BS_RADIOBUTTON;
  8530 		    winStyleBits |= BS_RADIOBUTTON;
  8531                     NDPRINTF(("class: %s - winStyleBits BS_RADIOBUTTON: %x\n", className, winStyleBits));
  8531 		    NDPRINTF(("class: %s - winStyleBits BS_RADIOBUTTON: %x\n", className, winStyleBits));
  8532                 } else if (windowType == @symbol(CheckBox)) {
  8532 		} else if (windowType == @symbol(CheckBox)) {
  8533                     isNativeWindow = 1;
  8533 		    isNativeWindow = 1;
  8534                     winStyleBits |= BS_CHECKBOX;
  8534 		    winStyleBits |= BS_CHECKBOX;
  8535                     NDPRINTF(("class: %s - winStyleBits BS_CHECKBOX: %x\n", className, winStyleBits));
  8535 		    NDPRINTF(("class: %s - winStyleBits BS_CHECKBOX: %x\n", className, winStyleBits));
  8536                 } else if (windowType == @symbol(HorizontalScrollBar)) {
  8536 		} else if (windowType == @symbol(HorizontalScrollBar)) {
  8537                     isNativeWindow = 1;
  8537 		    isNativeWindow = 1;
  8538                     winStyleBits |= SBS_HORZ;
  8538 		    winStyleBits |= SBS_HORZ;
  8539                     NDPRINTF(("class: %s - winStyleBits SBS_HORZ: %x\n", className, winStyleBits));
  8539 		    NDPRINTF(("class: %s - winStyleBits SBS_HORZ: %x\n", className, winStyleBits));
  8540                 } else if (windowType == @symbol(VerticalScrollBar)) {
  8540 		} else if (windowType == @symbol(VerticalScrollBar)) {
  8541                     isNativeWindow = 1;
  8541 		    isNativeWindow = 1;
  8542                     winStyleBits |= SBS_VERT;
  8542 		    winStyleBits |= SBS_VERT;
  8543                     NDPRINTF(("class: %s - winStyleBits SBS_VERT: %x\n", className, winStyleBits));
  8543 		    NDPRINTF(("class: %s - winStyleBits SBS_VERT: %x\n", className, winStyleBits));
  8544                 } else if (windowType == @symbol(Button)) {
  8544 		} else if (windowType == @symbol(Button)) {
  8545                     isNativeWindow = 1;
  8545 		    isNativeWindow = 1;
  8546                     NDPRINTF(("class: %s\n", className));
  8546 		    NDPRINTF(("class: %s\n", className));
  8547                 } else if (windowType == @symbol(OwnerDrawButton)) {
  8547 		} else if (windowType == @symbol(OwnerDrawButton)) {
  8548                     isNativeWindow = 1;
  8548 		    isNativeWindow = 1;
  8549                     winStyleBits |= BS_OWNERDRAW;
  8549 		    winStyleBits |= BS_OWNERDRAW;
  8550                     NDPRINTF(("class: %s - winStyleBits BS_OWNERDRAW: %x\n", className, winStyleBits));
  8550 		    NDPRINTF(("class: %s - winStyleBits BS_OWNERDRAW: %x\n", className, winStyleBits));
  8551                 }
  8551 		}
  8552             }
  8552 	    }
  8553         }
  8553 	}
  8554     }
  8554     }
  8555 
  8555 
  8556     if (__isExternalAddress(wsuperViewId)) {
  8556     if (__isExternalAddress(wsuperViewId)) {
  8557         /*
  8557 	/*
  8558          * a child window
  8558 	 * a child window
  8559          */
  8559 	 */
  8560         parentHandle = _HANDLEVal(wsuperViewId);
  8560 	parentHandle = _HANDLEVal(wsuperViewId);
  8561         if (wStyle == @symbol(mdiChild)) {
  8561 	if (wStyle == @symbol(mdiChild)) {
  8562             isMDIChild = 1;
  8562 	    isMDIChild = 1;
  8563         }
  8563 	}
  8564     } else {
  8564     } else {
  8565         parentHandle = NULL;
  8565 	parentHandle = NULL;
  8566         isTopWindow = 1;
  8566 	isTopWindow = 1;
  8567     }
  8567     }
  8568 
  8568 
  8569     if (!isTopWindow && !isMDIChild) {
  8569     if (!isTopWindow && !isMDIChild) {
  8570         /*
  8570 	/*
  8571          * a child window
  8571 	 * a child window
  8572          */
  8572 	 */
  8573         winStyleBits |= WS_CHILD;
  8573 	winStyleBits |= WS_CHILD;
  8574         if (winputOnly != true) {
  8574 	if (winputOnly != true) {
  8575             winStyleBits |= (WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
  8575 	    winStyleBits |= (WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
  8576             /*winStyleBits |= WS_CLIPCHILDREN;*/
  8576 	    /*winStyleBits |= WS_CLIPCHILDREN;*/
  8577             DPRINTF(("parent handle=%x\n", parentHandle));
  8577 	    DPRINTF(("parent handle=%x\n", parentHandle));
  8578         } else {
  8578 	} else {
  8579             winEXStyleBits |= WS_EX_TRANSPARENT;
  8579 	    winEXStyleBits |= WS_EX_TRANSPARENT;
  8580             DPRINTF(("inputview parent handle=%x\n", parentHandle));
  8580 	    DPRINTF(("inputview parent handle=%x\n", parentHandle));
  8581         }
  8581 	}
  8582 #if 0
  8582 #if 0
  8583         winEXStyleBits |= WS_EX_NOPARENTNOTIFY;
  8583 	winEXStyleBits |= WS_EX_NOPARENTNOTIFY;
  8584 #endif
  8584 #endif
  8585     } else {
  8585     } else {
  8586         /*
  8586 	/*
  8587          * a top window (regular / popUp / dialog) or MDIChild
  8587 	 * a top window (regular / popUp / dialog) or MDIChild
  8588          */
  8588 	 */
  8589         if (isMDIChild) {
  8589 	if (isMDIChild) {
  8590             winEXStyleBits |= WS_EX_MDICHILD;
  8590 	    winEXStyleBits |= WS_EX_MDICHILD;
  8591         }
  8591 	}
  8592 
  8592 
  8593         if (! isMDIChild)
  8593 	if (! isMDIChild)
  8594         {
  8594 	{
  8595 #ifdef TOPWINDOWCLASS
  8595 #ifdef TOPWINDOWCLASS
  8596             this could fail, since a pointer to local buf is passed
  8596 	    this could fail, since a pointer to local buf is passed
  8597             to the window-creation code (in the other thread ...)
  8597 	    to the window-creation code (in the other thread ...)
  8598 
  8598 
  8599             static winCount = 1;
  8599 	    static winCount = 1;
  8600             char buf[300];
  8600 	    char buf[300];
  8601             char *stName;
  8601 	    char *stName;
  8602 
  8602 
  8603 # ifdef __BORLANDC__
  8603 # ifdef __BORLANDC__
  8604             struct timeb timebuffer;
  8604 	    struct timeb timebuffer;
  8605             ftime(&timebuffer);
  8605 	    ftime(&timebuffer);
  8606 # else
  8606 # else
  8607             struct _timeb timebuffer;
  8607 	    struct _timeb timebuffer;
  8608             _ftime(&timebuffer);
  8608 	    _ftime(&timebuffer);
  8609 # endif
  8609 # endif
  8610 
  8610 
  8611             if (__isStringLike(stClassName)) {
  8611 	    if (__isStringLike(stClassName)) {
  8612                 stName = __stringVal(stClassName);
  8612 		stName = __stringVal(stClassName);
  8613             } else {
  8613 	    } else {
  8614                 stName = app_name;
  8614 		stName = app_name;
  8615             }
  8615 	    }
  8616             sprintf(buf, "S%d.%d%s", HIWORD(timebuffer.time), ++winCount, stName);
  8616 	    sprintf(buf, "S%d.%d%s", HIWORD(timebuffer.time), ++winCount, stName);
  8617             DPRINTF(("topview - registerClass:%s\n",buf));
  8617 	    DPRINTF(("topview - registerClass:%s\n",buf));
  8618 
  8618 
  8619             wc.style = /* CS_HREDRAW | CS_VREDRAW | CS_OWNDC  |*/ CS_DBLCLKS;
  8619 	    wc.style = /* CS_HREDRAW | CS_VREDRAW | CS_OWNDC  |*/ CS_DBLCLKS;
  8620             wc.lpfnWndProc = (WNDPROC) MainWndProc;
  8620 	    wc.lpfnWndProc = (WNDPROC) MainWndProc;
  8621             wc.cbClsExtra = 0;
  8621 	    wc.cbClsExtra = 0;
  8622             wc.cbWndExtra = N_WINDOW_PRIVATE;
  8622 	    wc.cbWndExtra = N_WINDOW_PRIVATE;
  8623             wc.hInstance = (HANDLE) __getHInstance();
  8623 	    wc.hInstance = (HANDLE) __getHInstance();
  8624             if (xIcon) {
  8624 	    if (xIcon) {
  8625                 wc.hIcon   = xIcon;
  8625 		wc.hIcon   = xIcon;
  8626                 /* wc.hIconSm = wiconId; In 4.x there are large and small icons */
  8626 		/* wc.hIconSm = wiconId; In 4.x there are large and small icons */
  8627             } else {
  8627 	    } else {
  8628                 wc.hIcon = NULL;        /* THIS MUST BE NULL TO DELETE ICONS */
  8628 		wc.hIcon = NULL;        /* THIS MUST BE NULL TO DELETE ICONS */
  8629             }
  8629 	    }
  8630             wc.hCursor = 0 /* LoadCursor(NULL, IDC_ARROW) */;
  8630 	    wc.hCursor = 0 /* LoadCursor(NULL, IDC_ARROW) */;
  8631             wc.hbrBackground = 0; /*CreateSolidBrush (bg);*/
  8631 	    wc.hbrBackground = 0; /*CreateSolidBrush (bg);*/
  8632 
  8632 
  8633             wc.lpszMenuName =  NULL;
  8633 	    wc.lpszMenuName =  NULL;
  8634             wc.lpszClassName = buf;
  8634 	    wc.lpszClassName = buf;
  8635 
  8635 
  8636             if (!RegisterClass(&wc)) {
  8636 	    if (!RegisterClass(&wc)) {
  8637                 PRINTF(("RegisterClass failed\n"));
  8637 		PRINTF(("RegisterClass failed\n"));
  8638                 RETURN( nil );
  8638 		RETURN( nil );
  8639             }
  8639 	    }
  8640 
  8640 
  8641             className = buf;
  8641 	    className = buf;
  8642 #endif /* TOPWINDOWCLASS */
  8642 #endif /* TOPWINDOWCLASS */
  8643         }
  8643 	}
  8644 
  8644 
  8645         if (wStyle == @symbol(popUp)) {
  8645 	if (wStyle == @symbol(popUp)) {
  8646             winStyleBits |= WS_POPUP;
  8646 	    winStyleBits |= WS_POPUP;
  8647             // winStyleBits |= WS_DISABLED;
  8647 	    // winStyleBits |= WS_DISABLED;
  8648             winEXStyleBits |= WS_EX_TOOLWINDOW;
  8648 	    winEXStyleBits |= WS_EX_TOOLWINDOW;
  8649             CPRINTF(("Create popUpWindow\n"));
  8649 	    CPRINTF(("Create popUpWindow\n"));
  8650 #if 0
  8650 #if 0
  8651             parentHandle = GetActiveWindow();
  8651 	    parentHandle = GetActiveWindow();
  8652 #endif
  8652 #endif
  8653         } else if (wStyle == @symbol(popUpWithFrame)) {
  8653 	} else if (wStyle == @symbol(popUpWithFrame)) {
  8654             winStyleBits |= WS_POPUP | WS_THICKFRAME /* | WS_CAPTION | DS_MODALFRAME | WS_SIZEBOX */ ;
  8654 	    winStyleBits |= WS_POPUP | WS_THICKFRAME /* | WS_CAPTION | DS_MODALFRAME | WS_SIZEBOX */ ;
  8655             // winStyleBits |= WS_DISABLED;
  8655 	    // winStyleBits |= WS_DISABLED;
  8656             // winEXStyleBits |= WS_EX_TOOLWINDOW;
  8656 	    // winEXStyleBits |= WS_EX_TOOLWINDOW;
  8657             CPRINTF(("Create popUpWindow\n"));
  8657 	    CPRINTF(("Create popUpWindow\n"));
  8658 #if 0
  8658 #if 0
  8659             parentHandle = GetActiveWindow();
  8659 	    parentHandle = GetActiveWindow();
  8660 #endif
  8660 #endif
  8661 
  8661 
  8662         } else if ((wStyle == @symbol(dialog)) || (wStyle == @symbol(toolDialog))) {
  8662 	} else if ((wStyle == @symbol(dialog)) || (wStyle == @symbol(toolDialog))) {
  8663             winStyleBits |= WS_OVERLAPPED | WS_CAPTION | DS_MODALFRAME | WS_SYSMENU | WS_SIZEBOX;
  8663 	    winStyleBits |= WS_OVERLAPPED | WS_CAPTION | DS_MODALFRAME | WS_SYSMENU | WS_SIZEBOX;
  8664             winStyleBits |= WS_POPUP;
  8664 	    winStyleBits |= WS_POPUP;
  8665             winStyleBits |= DS_NOIDLEMSG;
  8665 	    winStyleBits |= DS_NOIDLEMSG;
  8666             //winEXStyleBits |= WS_EX_TOOLWINDOW;
  8666 	    //winEXStyleBits |= WS_EX_TOOLWINDOW;
  8667             if ((min_width || min_height)
  8667 	    if ((min_width || min_height)
  8668              && (min_width == max_width)
  8668 	     && (min_width == max_width)
  8669              && (min_height == max_height)) {
  8669 	     && (min_height == max_height)) {
  8670                 winStyleBits &= ~WS_THICKFRAME;
  8670 		winStyleBits &= ~WS_THICKFRAME;
  8671             }
  8671 	    }
  8672             if (wStyle == @symbol(toolDialog)) {
  8672 	    if (wStyle == @symbol(toolDialog)) {
  8673                 winEXStyleBits |= WS_EX_TOOLWINDOW;
  8673 		winEXStyleBits |= WS_EX_TOOLWINDOW;
  8674             }
  8674 	    }
  8675         } else if (wStyle == @symbol(undecorated)) {
  8675 	} else if (wStyle == @symbol(undecorated)) {
  8676             winStyleBits |= WS_OVERLAPPED;
  8676 	    winStyleBits |= WS_OVERLAPPED;
  8677             winEXStyleBits |= WS_EX_WINDOWEDGE;
  8677 	    winEXStyleBits |= WS_EX_WINDOWEDGE;
  8678         } else if (wStyle == @symbol(undecoratedResizable)) {
  8678 	} else if (wStyle == @symbol(undecoratedResizable)) {
  8679             winStyleBits |= WS_OVERLAPPED | WS_THICKFRAME;
  8679 	    winStyleBits |= WS_OVERLAPPED | WS_THICKFRAME;
  8680             winEXStyleBits |= WS_EX_WINDOWEDGE;
  8680 	    winEXStyleBits |= WS_EX_WINDOWEDGE;
  8681         } else if (isMDIChild) {
  8681 	} else if (isMDIChild) {
  8682             winStyleBits |= WS_OVERLAPPED | WS_CAPTION | DS_MODALFRAME | WS_SYSMENU | WS_SIZEBOX;
  8682 	    winStyleBits |= WS_OVERLAPPED | WS_CAPTION | DS_MODALFRAME | WS_SYSMENU | WS_SIZEBOX;
  8683             if ((min_width || min_height)
  8683 	    if ((min_width || min_height)
  8684              && (min_width == max_width)
  8684 	     && (min_width == max_width)
  8685              && (min_height == max_height)) {
  8685 	     && (min_height == max_height)) {
  8686                 winStyleBits &= ~WS_THICKFRAME;
  8686 		winStyleBits &= ~WS_THICKFRAME;
  8687             }
  8687 	    }
  8688         } else {
  8688 	} else {
  8689             //winStyleBits |= WS_OVERLAPPEDWINDOW;
  8689 	    //winStyleBits |= WS_OVERLAPPEDWINDOW;
  8690             winStyleBits |= WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SIZEBOX;
  8690 	    winStyleBits |= WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SIZEBOX;
  8691             //winEXStyleBits |= WS_EX_CLIENTEDGE;
  8691 	    //winEXStyleBits |= WS_EX_CLIENTEDGE;
  8692             winEXStyleBits |= WS_EX_WINDOWEDGE;
  8692 	    winEXStyleBits |= WS_EX_WINDOWEDGE;
  8693             //winEXStyleBits |= WS_EX_ACCEPTFILES;
  8693 	    //winEXStyleBits |= WS_EX_ACCEPTFILES;
  8694 
  8694 
  8695             if (wStyle == @symbol(toolWindow)) {
  8695 	    if (wStyle == @symbol(toolWindow)) {
  8696                 winEXStyleBits |= WS_EX_TOOLWINDOW;
  8696 		winEXStyleBits |= WS_EX_TOOLWINDOW;
  8697             }
  8697 	    }
  8698         }
  8698 	}
  8699         winStyleBits |= WS_CLIPCHILDREN;
  8699 	winStyleBits |= WS_CLIPCHILDREN;
  8700     }
  8700     }
  8701 
  8701 
  8702     rec.left = x;
  8702     rec.left = x;
  8703     rec.top = y;
  8703     rec.top = y;
  8704     rec.right = x + w;
  8704     rec.right = x + w;
  8717 
  8717 
  8718     /*
  8718     /*
  8719      * check if previous request has been properly processed ...
  8719      * check if previous request has been properly processed ...
  8720      */
  8720      */
  8721     if (cwi.sequenceNr && (cwi.sequenceNr != INVALIDATED_CWI)) {
  8721     if (cwi.sequenceNr && (cwi.sequenceNr != INVALIDATED_CWI)) {
  8722         console_fprintf(stderr, "WinWorkstation [info]: oops - unprocessed createWindow still pending\n");
  8722 	console_fprintf(stderr, "WinWorkstation [info]: oops - unprocessed createWindow still pending\n");
  8723         /* this prevents the event processor from interpreting this message */
  8723 	/* this prevents the event processor from interpreting this message */
  8724         cwi.sequenceNr = nextSequenceNr;
  8724 	cwi.sequenceNr = nextSequenceNr;
  8725     }
  8725     }
  8726 
  8726 
  8727     cwi.winStyleBitsEx = WS_EX_LEFT | WS_EX_NOPARENTNOTIFY | winEXStyleBits;
  8727     cwi.winStyleBitsEx = WS_EX_LEFT | WS_EX_NOPARENTNOTIFY | winEXStyleBits;
  8728 
  8728 
  8729 #ifdef ADJUSTWINDOW
  8729 #ifdef ADJUSTWINDOW
  8731     w = rec.right - rec.left;
  8731     w = rec.right - rec.left;
  8732     h = rec.bottom - rec.top;
  8732     h = rec.bottom - rec.top;
  8733 #endif
  8733 #endif
  8734 
  8734 
  8735     DPRINTF(("create%s pos==%d/%d size=%d/%d bw:%d parent:%x class:'%s' style:%x exStyle:%x ...\n",
  8735     DPRINTF(("create%s pos==%d/%d size=%d/%d bw:%d parent:%x class:'%s' style:%x exStyle:%x ...\n",
  8736                 ((wStyle == @symbol(popUp)) ? " popUp" : ""),
  8736 		((wStyle == @symbol(popUp)) ? " popUp" : ""),
  8737                 x, y, w, h,
  8737 		x, y, w, h,
  8738                 bw, parentHandle, className,
  8738 		bw, parentHandle, className,
  8739                 winStyleBits, winEXStyleBits));
  8739 		winStyleBits, winEXStyleBits));
  8740 
  8740 
  8741     /* allocate localMemory for Window */
  8741     /* allocate localMemory for Window */
  8742     lI = (localWindowInfo *) malloc(sizeof(localWindowInfo));
  8742     lI = (localWindowInfo *) malloc(sizeof(localWindowInfo));
  8743     if (! lI) {
  8743     if (! lI) {
  8744         console_fprintf(stderr, "WinWorkstation [error]: malloc failed in CreateWindow\n");
  8744 	console_fprintf(stderr, "WinWorkstation [error]: malloc failed in CreateWindow\n");
  8745         RETURN ( nil );
  8745 	RETURN ( nil );
  8746     }
  8746     }
  8747 
  8747 
  8748     memset(lI, 0, sizeof(localWindowInfo));
  8748     memset(lI, 0, sizeof(localWindowInfo));
  8749     lI->mouseX = lI->mouseY = -9999;
  8749     lI->mouseX = lI->mouseY = -9999;
  8750 
  8750 
  8751     if (isTopWindow) {
  8751     if (isTopWindow) {
  8752 /****** MULTI SCREEN   CATZKERN *********
  8752 /****** MULTI SCREEN   CATZKERN *********
  8753         if (rec.left < 0) {
  8753 	if (rec.left < 0) {
  8754             rec.left = 0;
  8754 	    rec.left = 0;
  8755             rec.right = w;
  8755 	    rec.right = w;
  8756         }
  8756 	}
  8757         if (rec.top < 0) {
  8757 	if (rec.top < 0) {
  8758             rec.top = 0;
  8758 	    rec.top = 0;
  8759             rec.bottom = h;
  8759 	    rec.bottom = h;
  8760         }
  8760 	}
  8761 ****** MULTI SCREEN   CATZKERN *********/
  8761 ****** MULTI SCREEN   CATZKERN *********/
  8762 
  8762 
  8763         lI->flag |= LI_TOPWIN;
  8763 	lI->flag |= LI_TOPWIN;
  8764     } else {
  8764     } else {
  8765         if (bw) {
  8765 	if (bw) {
  8766             // adjust for border
  8766 	    // adjust for border
  8767             rec.left++;
  8767 	    rec.left++;
  8768             rec.top++;
  8768 	    rec.top++;
  8769         }
  8769 	}
  8770     }
  8770     }
  8771 
  8771 
  8772     if (winputOnly == true) {
  8772     if (winputOnly == true) {
  8773         lI->flag |= LI_INPUTWIN;
  8773 	lI->flag |= LI_INPUTWIN;
  8774     }
  8774     }
  8775     if (isNativeWindow) {
  8775     if (isNativeWindow) {
  8776         NDPRINTF(("set native flag\n"));
  8776 	NDPRINTF(("set native flag\n"));
  8777         lI->flag |= LI_NATIVEWIN;
  8777 	lI->flag |= LI_NATIVEWIN;
  8778     }
  8778     }
  8779 
  8779 
  8780     if (wStyle == @symbol(popUp)) {
  8780     if (wStyle == @symbol(popUp)) {
  8781         cwi.className = wapp_namePopup;
  8781 	cwi.className = wapp_namePopup;
  8782     } else {
  8782     } else {
  8783         if (wStyle == @symbol(dialog)) {
  8783 	if (wStyle == @symbol(dialog)) {
  8784             cwi.className = wapp_nameDialog;
  8784 	    cwi.className = wapp_nameDialog;
  8785         } else {
  8785 	} else {
  8786             ch2wch(className, classNameBufferw, MAX_CLASSNAME_SIZE);
  8786 	    ch2wch(className, classNameBufferw, MAX_CLASSNAME_SIZE);
  8787             cwi.className = classNameBufferw;
  8787 	    cwi.className = classNameBufferw;
  8788         }
  8788 	}
  8789     }
  8789     }
  8790 
  8790 
  8791     cwi.winStyleBits = winStyleBits;
  8791     cwi.winStyleBits = winStyleBits;
  8792     cwi.parentHandle = parentHandle;
  8792     cwi.parentHandle = parentHandle;
  8793     cwi.x = rec.left;
  8793     cwi.x = rec.left;
  8794     cwi.y = rec.top;
  8794     cwi.y = rec.top;
  8795     cwi.dx = rec.right - rec.left;
  8795     cwi.dx = rec.right - rec.left;
  8796     cwi.dy = rec.bottom - rec.top;
  8796     cwi.dy = rec.bottom - rec.top;
  8797 
  8797 
  8798     if (isTopWindow | isMDIChild) {
  8798     if (isTopWindow | isMDIChild) {
  8799         rec.left = 0;
  8799 	rec.left = 0;
  8800         rec.top = 0;
  8800 	rec.top = 0;
  8801         rec.right = min_width;
  8801 	rec.right = min_width;
  8802         rec.bottom = min_height;
  8802 	rec.bottom = min_height;
  8803 #ifdef ADJUSTWINDOW
  8803 #ifdef ADJUSTWINDOW
  8804         AdjustWindowRectEx(&rec, winStyleBits, 0, cwi.winStyleBitsEx);
  8804 	AdjustWindowRectEx(&rec, winStyleBits, 0, cwi.winStyleBitsEx);
  8805 #endif
  8805 #endif
  8806         lI->minWidth = rec.right - rec.left;
  8806 	lI->minWidth = rec.right - rec.left;
  8807         lI->minHeight = rec.bottom - rec.top;
  8807 	lI->minHeight = rec.bottom - rec.top;
  8808 
  8808 
  8809         rec.left = 0;
  8809 	rec.left = 0;
  8810         rec.top = 0;
  8810 	rec.top = 0;
  8811         rec.right = max_width;
  8811 	rec.right = max_width;
  8812         rec.bottom = max_height;
  8812 	rec.bottom = max_height;
  8813 #ifdef ADJUSTWINDOW
  8813 #ifdef ADJUSTWINDOW
  8814         AdjustWindowRectEx(&rec, winStyleBits, 0, cwi.winStyleBitsEx);
  8814 	AdjustWindowRectEx(&rec, winStyleBits, 0, cwi.winStyleBitsEx);
  8815 #endif
  8815 #endif
  8816         lI->maxWidth = rec.right - rec.left;
  8816 	lI->maxWidth = rec.right - rec.left;
  8817         lI->maxHeight = rec.bottom - rec.top;
  8817 	lI->maxHeight = rec.bottom - rec.top;
  8818     } else {
  8818     } else {
  8819         lI->minWidth = lI->minHeight = 0;
  8819 	lI->minWidth = lI->minHeight = 0;
  8820         lI->maxWidth = lI->maxHeight = 9999;
  8820 	lI->maxWidth = lI->maxHeight = 9999;
  8821     }
  8821     }
  8822 
  8822 
  8823     lI->viewBgBrush = __whiteBrush;
  8823     lI->viewBgBrush = __whiteBrush;
  8824     lI->viewBgColor = WhitePixel;
  8824     lI->viewBgColor = WhitePixel;
  8825     lI->bdColor = BlackPixel;
  8825     lI->bdColor = BlackPixel;
  8826 
  8826 
  8827     if (__isSmallInteger(eventMask))
  8827     if (__isSmallInteger(eventMask))
  8828         lI->eventMask = __intVal(eventMask);
  8828 	lI->eventMask = __intVal(eventMask);
  8829     else
  8829     else
  8830         lI->eventMask = ~0;
  8830 	lI->eventMask = ~0;
  8831     DPRINTF(("eventMask is %x\n", lI->eventMask));
  8831     DPRINTF(("eventMask is %x\n", lI->eventMask));
  8832 #ifdef DEBUGMASK1
  8832 #ifdef DEBUGMASK1
  8833     printMask(lI->eventMask);
  8833     printMask(lI->eventMask);
  8834 #endif
  8834 #endif
  8835 
  8835 
  8837 
  8837 
  8838     cwi.newWinHandle = newWindowHandle = NULL;
  8838     cwi.newWinHandle = newWindowHandle = NULL;
  8839     cwi.windowName = 0;
  8839     cwi.windowName = 0;
  8840 
  8840 
  8841     if (isTopWindow | isMDIChild) {
  8841     if (isTopWindow | isMDIChild) {
  8842         if (__isStringLike(wlabel)) {
  8842 	if (__isStringLike(wlabel)) {
  8843             ch2wch((char *)__stringVal(wlabel), windowNameBufferw, MAX_LABEL_SIZE);
  8843 	    ch2wch((char *)__stringVal(wlabel), windowNameBufferw, MAX_LABEL_SIZE);
  8844             cwi.windowName = windowNameBufferw;
  8844 	    cwi.windowName = windowNameBufferw;
  8845         } else
  8845 	} else
  8846             if (__isUnicode16String(wlabel)) {
  8846 	    if (__isUnicode16String(wlabel)) {
  8847                 int l = __unicode16StringSize(wlabel);
  8847 		int l = __unicode16StringSize(wlabel);
  8848 
  8848 
  8849                 if (l >= MAX_LABEL_SIZE) l = MAX_LABEL_SIZE-1;
  8849 		if (l >= MAX_LABEL_SIZE) l = MAX_LABEL_SIZE-1;
  8850                 memmove(windowNameBufferw, __unicode16StringVal(wlabel), l*sizeof(wchar_t));
  8850 		memmove(windowNameBufferw, __unicode16StringVal(wlabel), l*sizeof(wchar_t));
  8851                 windowNameBufferw[ l ] = 0;
  8851 		windowNameBufferw[ l ] = 0;
  8852                 cwi.windowName = windowNameBufferw;
  8852 		cwi.windowName = windowNameBufferw;
  8853             }
  8853 	    }
  8854     }
  8854     }
  8855 
  8855 
  8856     cwi.infoWasRead = 0;
  8856     cwi.infoWasRead = 0;
  8857     cwi.localWindowInfo = lI;
  8857     cwi.localWindowInfo = lI;
  8858     cwi.sequenceNr = nextSequenceNr;
  8858     cwi.sequenceNr = nextSequenceNr;
  8862     cwi.hCreateEvent = hCreateEvent;
  8862     cwi.hCreateEvent = hCreateEvent;
  8863     ResetEvent(cwi.hCreateEvent);
  8863     ResetEvent(cwi.hCreateEvent);
  8864 #else
  8864 #else
  8865     /* creating a new event does not work - why ? */
  8865     /* creating a new event does not work - why ? */
  8866     cwi.hCreateEvent = CreateEvent(
  8866     cwi.hCreateEvent = CreateEvent(
  8867         NULL,        /* no security attributes */
  8867 	NULL,        /* no security attributes */
  8868         FALSE,
  8868 	FALSE,
  8869         FALSE,
  8869 	FALSE,
  8870         NULL);       /* name of mutex */
  8870 	NULL);       /* name of mutex */
  8871 
  8871 
  8872     if (cwi.hCreateEvent == NULL) {
  8872     if (cwi.hCreateEvent == NULL) {
  8873         console_fprintf(stderr, "WinWorkstation [error]: oops - CreateEvent failed in CreateWindow: %d\n", GetLastError() );
  8873 	console_fprintf(stderr, "WinWorkstation [error]: oops - CreateEvent failed in CreateWindow: %d\n", GetLastError() );
  8874         cwi.sequenceNr = INVALIDATED_CWI;
  8874 	cwi.sequenceNr = INVALIDATED_CWI;
  8875         free(lI);
  8875 	free(lI);
  8876         RETURN ( nil );
  8876 	RETURN ( nil );
  8877     }
  8877     }
  8878 #endif
  8878 #endif
  8879 
  8879 
  8880     /*
  8880     /*
  8881      * kludge to allow for createWindow while in sizeMove processing loop
  8881      * kludge to allow for createWindow while in sizeMove processing loop
  8882      */
  8882      */
  8883     if (pendingCREATEWINDOWInfo) {
  8883     if (pendingCREATEWINDOWInfo) {
  8884         console_fprintf(stderr, "WinWorkstation [error]: oops - pending create\n");
  8884 	console_fprintf(stderr, "WinWorkstation [error]: oops - pending create\n");
  8885     }
  8885     }
  8886     pendingCREATEWINDOWInfo = &cwi;
  8886     pendingCREATEWINDOWInfo = &cwi;
  8887     pendingSequenceNr = cwi.sequenceNr;
  8887     pendingSequenceNr = cwi.sequenceNr;
  8888 
  8888 
  8889     if (PostThreadMessage(_dispatchThreadId, WM_THREAD_CREATEWINDOW, (INT)(cwi.sequenceNr), (INT)(&cwi)) == FALSE) {
  8889     if (PostThreadMessage(_dispatchThreadId, WM_THREAD_CREATEWINDOW, (INT)(cwi.sequenceNr), (INT)(&cwi)) == FALSE) {
  8890         console_fprintf(stderr, "WinWorkstation [error]: oops - PostThreadMessage(%x) failed in CreateWindow: err=%d\n",
  8890 	console_fprintf(stderr, "WinWorkstation [error]: oops - PostThreadMessage(%x) failed in CreateWindow: err=%d\n",
  8891                                         _dispatchThreadId, GetLastError() );
  8891 					_dispatchThreadId, GetLastError() );
  8892         free(lI);
  8892 	free(lI);
  8893         RETURN (nil);
  8893 	RETURN (nil);
  8894     }
  8894     }
  8895 
  8895 
  8896     if (cwi.newWinHandle != NULL) {
  8896     if (cwi.newWinHandle != NULL) {
  8897         cwi.sequenceNr = INVALIDATED_CWI;
  8897 	cwi.sequenceNr = INVALIDATED_CWI;
  8898         cwi.hCreateEvent = NULL;
  8898 	cwi.hCreateEvent = NULL;
  8899         /* wow - that was quick ... */
  8899 	/* wow - that was quick ... */
  8900     } else {
  8900     } else {
  8901         DWORD dwWaitResult;
  8901 	DWORD dwWaitResult;
  8902 
  8902 
  8903         /* wait for the window to be created ... */
  8903 	/* wait for the window to be created ... */
  8904         dwWaitResult = WaitForSingleObject(hCreateEvent, 5000L);
  8904 	dwWaitResult = WaitForSingleObject(hCreateEvent, 5000L);
  8905 
  8905 
  8906         /* no longer want to get informed ... */
  8906 	/* no longer want to get informed ... */
  8907         cwi.hCreateEvent = NULL;
  8907 	cwi.hCreateEvent = NULL;
  8908         cwi.sequenceNr = INVALIDATED_CWI;
  8908 	cwi.sequenceNr = INVALIDATED_CWI;
  8909 
  8909 
  8910         switch (dwWaitResult) {
  8910 	switch (dwWaitResult) {
  8911             // The thread got mutex ownership.
  8911 	    // The thread got mutex ownership.
  8912             case WAIT_OBJECT_0:
  8912 	    case WAIT_OBJECT_0:
  8913                 break;
  8913 		break;
  8914 
  8914 
  8915             // Cannot get mutex ownership due to time-out.
  8915 	    // Cannot get mutex ownership due to time-out.
  8916             case WAIT_TIMEOUT:
  8916 	    case WAIT_TIMEOUT:
  8917                 DEBUGFPRINTF((stderr, "WinWorkstation [error]: oops - timeout in CreateWindow\n"));
  8917 		DEBUGFPRINTF((stderr, "WinWorkstation [error]: oops - timeout in CreateWindow\n"));
  8918                 break;
  8918 		break;
  8919 
  8919 
  8920             // Got ownership of the abandoned mutex object.
  8920 	    // Got ownership of the abandoned mutex object.
  8921             default:
  8921 	    default:
  8922                 DEBUGFPRINTF((stderr, "WinWorkstation [warning]: CreateEvent abandoned\n"));
  8922 		DEBUGFPRINTF((stderr, "WinWorkstation [warning]: CreateEvent abandoned\n"));
  8923                 break;
  8923 		break;
  8924         }
  8924 	}
  8925 
  8925 
  8926 #ifdef NEW_CREATE_EVENT
  8926 #ifdef NEW_CREATE_EVENT
  8927         CloseHandle(cwi.hCreateEvent);
  8927 	CloseHandle(cwi.hCreateEvent);
  8928 #endif
  8928 #endif
  8929     }
  8929     }
  8930 
  8930 
  8931     pendingCREATEWINDOWInfo = 0;
  8931     pendingCREATEWINDOWInfo = 0;
  8932     newWindowHandle = cwi.newWinHandle;
  8932     newWindowHandle = cwi.newWinHandle;
  8933     DPRINTF(("handle = %x\n", newWindowHandle));
  8933     DPRINTF(("handle = %x\n", newWindowHandle));
  8934 
  8934 
  8935     if (! newWindowHandle) {
  8935     if (! newWindowHandle) {
  8936         console_fprintf(stderr, "WinWorkstation [error]: CreateWindow failed: %d (0x%x) [%d]\n",
  8936 	console_fprintf(stderr, "WinWorkstation [error]: CreateWindow failed: %d (0x%x) [%d]\n",
  8937                         cwi.errCode, cwi.errCode, __LINE__ );
  8937 			cwi.errCode, cwi.errCode, __LINE__ );
  8938         if (cwi.infoWasRead) {
  8938 	if (cwi.infoWasRead) {
  8939             free(lI);
  8939 	    free(lI);
  8940         } else {
  8940 	} else {
  8941             console_fprintf(stderr, "WinWorkstation [warning]: localInfo memory leak [%d]\n", __LINE__ );
  8941 	    console_fprintf(stderr, "WinWorkstation [warning]: localInfo memory leak [%d]\n", __LINE__ );
  8942         }
  8942 	}
  8943         RETURN ( nil );
  8943 	RETURN ( nil );
  8944     }
  8944     }
  8945 
  8945 
  8946 #ifdef CACHE_LAST_DC
  8946 #ifdef CACHE_LAST_DC
  8947     if (lastGcData && (lastGcHWIN == newWindowHandle)) {
  8947     if (lastGcData && (lastGcHWIN == newWindowHandle)) {
  8948         _releaseDC(lastGcData);
  8948 	_releaseDC(lastGcData);
  8949     }
  8949     }
  8950 #endif
  8950 #endif
  8951 #ifdef CACHE_LAST_WM_PAINT_DC
  8951 #ifdef CACHE_LAST_WM_PAINT_DC
  8952     if (last_wm_paint_dc && (last_wm_paint_win == newWindowHandle)) {
  8952     if (last_wm_paint_dc && (last_wm_paint_win == newWindowHandle)) {
  8953         ReleaseDC(newWindowHandle, last_wm_paint_dc);
  8953 	ReleaseDC(newWindowHandle, last_wm_paint_dc);
  8954         last_wm_paint_win = last_wm_paint_dc = 0;
  8954 	last_wm_paint_win = last_wm_paint_dc = 0;
  8955     }
  8955     }
  8956 #endif
  8956 #endif
  8957 
  8957 
  8958     windowId = __MKOBJ(newWindowHandle);
  8958     windowId = __MKOBJ(newWindowHandle);
  8959 #if 1
  8959 #if 1
  8960     if (isTopWindow | isMDIChild) {
  8960     if (isTopWindow | isMDIChild) {
  8961         /*
  8961 	/*
  8962          * mhmh - what is that raise for ?
  8962 	 * mhmh - what is that raise for ?
  8963          */
  8963 	 */
  8964         SetWindowPos(newWindowHandle, HWND_TOP, 0, 0, 0, 0,
  8964 	SetWindowPos(newWindowHandle, HWND_TOP, 0, 0, 0, 0,
  8965                      SWP_NOSENDCHANGING |
  8965 		     SWP_NOSENDCHANGING |
  8966                      /* SWP_NOACTIVATE | */ SWP_NOMOVE | SWP_NOSIZE);
  8966 		     /* SWP_NOACTIVATE | */ SWP_NOMOVE | SWP_NOSIZE);
  8967     } else {
  8967     } else {
  8968         SetWindowPos(newWindowHandle, HWND_TOP, 0, 0, 0, 0,
  8968 	SetWindowPos(newWindowHandle, HWND_TOP, 0, 0, 0, 0,
  8969                      SWP_NOSENDCHANGING |
  8969 		     SWP_NOSENDCHANGING |
  8970                      SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  8970 		     SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  8971     }
  8971     }
  8972 #endif
  8972 #endif
  8973     if (isTopWindow | isMDIChild) {
  8973     if (isTopWindow | isMDIChild) {
  8974         BringWindowToTop(newWindowHandle);
  8974 	BringWindowToTop(newWindowHandle);
  8975     }
  8975     }
  8976     DragAcceptFiles(newWindowHandle, 1);
  8976     DragAcceptFiles(newWindowHandle, 1);
  8977 
  8977 
  8978     if (isNativeWindow) {
  8978     if (isNativeWindow) {
  8979         if (winStyleBits & (SBS_HORZ | SBS_VERT)) {
  8979 	if (winStyleBits & (SBS_HORZ | SBS_VERT)) {
  8980             SetScrollRange(newWindowHandle, SB_CTL, 0, 100, 0);
  8980 	    SetScrollRange(newWindowHandle, SB_CTL, 0, 100, 0);
  8981             SetScrollPos(newWindowHandle, SB_CTL, 0, 0);
  8981 	    SetScrollPos(newWindowHandle, SB_CTL, 0, 0);
  8982         }
  8982 	}
  8983     }
  8983     }
  8984 
  8984 
  8985 #ifndef TOPWINDOWCLASS
  8985 #ifndef TOPWINDOWCLASS
  8986     if (xIcon) {
  8986     if (xIcon) {
  8987         SendMessage(newWindowHandle, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)xIcon);
  8987 	SendMessage(newWindowHandle, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)xIcon);
  8988         SendMessage(newWindowHandle, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)xIcon);
  8988 	SendMessage(newWindowHandle, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)xIcon);
  8989     }
  8989     }
  8990 #endif
  8990 #endif
  8991 
  8991 
  8992     DPRINTF(("done - create h=%x\n", newWindowHandle));
  8992     DPRINTF(("done - create h=%x\n", newWindowHandle));
  8993     RETURN (windowId);
  8993     RETURN (windowId);
  8998 
  8998 
  8999 %{  /* NOCONTEXT */
  8999 %{  /* NOCONTEXT */
  9000     HICON oldIcon;
  9000     HICON oldIcon;
  9001 
  9001 
  9002     if (__isExternalAddress(aWindowId)) {
  9002     if (__isExternalAddress(aWindowId)) {
  9003         HWND win = _HWNDVal(aWindowId);
  9003 	HWND win = _HWNDVal(aWindowId);
  9004 
  9004 
  9005         if (win && IsWindow(win)) {
  9005 	if (win && IsWindow(win)) {
  9006 #ifndef TOPWINDOWCLASS
  9006 #ifndef TOPWINDOWCLASS
  9007 # ifdef _WIN64
  9007 # ifdef _WIN64
  9008             oldIcon = (HICON) GetClassLongPtr(win, GCLP_HICON);
  9008 	    oldIcon = (HICON) GetClassLongPtr(win, GCLP_HICON);
  9009             SetClassLongPtr(win, GCLP_HICON, (INT)0);
  9009 	    SetClassLongPtr(win, GCLP_HICON, (INT)0);
  9010 # else
  9010 # else
  9011             oldIcon = (HICON) GetClassLong(win, GCL_HICON);
  9011 	    oldIcon = (HICON) GetClassLong(win, GCL_HICON);
  9012             SetClassLong(win, GCL_HICON, (DWORD)0);
  9012 	    SetClassLong(win, GCL_HICON, (DWORD)0);
  9013 # endif
  9013 # endif
  9014             /* It has to be checked whether this can be deleted!!!!! */
  9014 	    /* It has to be checked whether this can be deleted!!!!! */
  9015             if ( oldIcon ) {
  9015 	    if ( oldIcon ) {
  9016                 if ( DestroyIcon( oldIcon )) {
  9016 		if ( DestroyIcon( oldIcon )) {
  9017                     DPRINTF(( "Old icon deleted\n" ));
  9017 		    DPRINTF(( "Old icon deleted\n" ));
  9018                 } else {
  9018 		} else {
  9019                     console_fprintf(stderr, "failed to destroy icon\n");
  9019 		    console_fprintf(stderr, "failed to destroy icon\n");
  9020                 }
  9020 		}
  9021             }
  9021 	    }
  9022 #endif
  9022 #endif
  9023            /*console_printf("post WM_THREAD_DESTROYWINDOW\n");*/
  9023 	   /*console_printf("post WM_THREAD_DESTROYWINDOW\n");*/
  9024             PostMessage(win, WM_THREAD_DESTROYWINDOW, 0, 0);
  9024 	    PostMessage(win, WM_THREAD_DESTROYWINDOW, 0, 0);
  9025         }
  9025 	}
  9026     }
  9026     }
  9027 %}
  9027 %}
  9028 !
  9028 !
  9029 
  9029 
  9030 rootWindowId
  9030 rootWindowId
  9045 
  9045 
  9046     |currentSequenceNumber|
  9046     |currentSequenceNumber|
  9047 
  9047 
  9048     currentSequenceNumber := self getClipboardSequenceNumber.
  9048     currentSequenceNumber := self getClipboardSequenceNumber.
  9049     lastClipboardSequenceNumber ~= currentSequenceNumber ifTrue:[
  9049     lastClipboardSequenceNumber ~= currentSequenceNumber ifTrue:[
  9050         "copyBuffer is invalid, fill it from the windows clipboard.
  9050 	"copyBuffer is invalid, fill it from the windows clipboard.
  9051          Even if we could not decode the windows clipboard,
  9051 	 Even if we could not decode the windows clipboard,
  9052          we intentionally set the copyBuffer to nil to get a consistent
  9052 	 we intentionally set the copyBuffer to nil to get a consistent
  9053          behavior."
  9053 	 behavior."
  9054         copyBuffer := self getClipboardData.
  9054 	copyBuffer := self getClipboardData.
  9055         lastClipboardSequenceNumber := currentSequenceNumber.
  9055 	lastClipboardSequenceNumber := currentSequenceNumber.
  9056     ].
  9056     ].
  9057     ^ copyBuffer
  9057     ^ copyBuffer
  9058 !
  9058 !
  9059 
  9059 
  9060 getClipboardText:selectionBufferSymbol for:drawableId
  9060 getClipboardText:selectionBufferSymbol for:drawableId
  9063 
  9063 
  9064     |currentSequenceNumber|
  9064     |currentSequenceNumber|
  9065 
  9065 
  9066     currentSequenceNumber := self getClipboardSequenceNumber.
  9066     currentSequenceNumber := self getClipboardSequenceNumber.
  9067     lastClipboardSequenceNumber ~= currentSequenceNumber ifTrue:[
  9067     lastClipboardSequenceNumber ~= currentSequenceNumber ifTrue:[
  9068         "copyBuffer is invalid, fill it from the windows clipboard.
  9068 	"copyBuffer is invalid, fill it from the windows clipboard.
  9069          Even if we could not decode the windows clipboard,
  9069 	 Even if we could not decode the windows clipboard,
  9070          we intentionally set the copyBuffer to nil to get a consistent
  9070 	 we intentionally set the copyBuffer to nil to get a consistent
  9071          behavior."
  9071 	 behavior."
  9072         copyBuffer := self getClipboardData.
  9072 	copyBuffer := self getClipboardData.
  9073         lastClipboardSequenceNumber := currentSequenceNumber.
  9073 	lastClipboardSequenceNumber := currentSequenceNumber.
  9074     ].
  9074     ].
  9075     ^ self copyBufferAsString
  9075     ^ self copyBufferAsString
  9076 
  9076 
  9077     "
  9077     "
  9078      Screen current getClipboardText:#clipboard for:nil
  9078      Screen current getClipboardText:#clipboard for:nil
  9086      Since we currently support only text, any other object
  9086      Since we currently support only text, any other object
  9087      is stored only in our local copyBuffer and not made available
  9087      is stored only in our local copyBuffer and not made available
  9088      to other applications."
  9088      to other applications."
  9089 
  9089 
  9090     something isString ifTrue:[
  9090     something isString ifTrue:[
  9091         self setClipboardText:something owner:drawableId.
  9091 	self setClipboardText:something owner:drawableId.
  9092         ^ self
  9092 	^ self
  9093     ].
  9093     ].
  9094     something isStringCollection ifTrue:[
  9094     something isStringCollection ifTrue:[
  9095         self setClipboardText:something asString owner:drawableId.
  9095 	self setClipboardText:something asString owner:drawableId.
  9096         ^ self
  9096 	^ self
  9097     ].
  9097     ].
  9098 
  9098 
  9099     "copyBuffer is valid until the clipboard sequence number increases,
  9099     "copyBuffer is valid until the clipboard sequence number increases,
  9100      because new data has been put into the clipboard"
  9100      because new data has been put into the clipboard"
  9101     lastClipboardSequenceNumber := self getClipboardSequenceNumber.
  9101     lastClipboardSequenceNumber := self getClipboardSequenceNumber.
  9147     unsigned char *src, *p;
  9147     unsigned char *src, *p;
  9148     WIDECHAR *w_src, *w_p;
  9148     WIDECHAR *w_src, *w_p;
  9149     int fmt;
  9149     int fmt;
  9150 
  9150 
  9151     if (format == @symbol(CF_TIFF)) {
  9151     if (format == @symbol(CF_TIFF)) {
  9152         fmt = CF_TIFF;
  9152 	fmt = CF_TIFF;
  9153     } else if (format == @symbol(CF_BITMAP)) {
  9153     } else if (format == @symbol(CF_BITMAP)) {
  9154         fmt = CF_BITMAP;
  9154 	fmt = CF_BITMAP;
  9155     } else if (format == @symbol(CF_DIB)) {
  9155     } else if (format == @symbol(CF_DIB)) {
  9156         fmt = CF_DIB;
  9156 	fmt = CF_DIB;
  9157     } else
  9157     } else
  9158         goto badFormat;
  9158 	goto badFormat;
  9159 
  9159 
  9160     if (IsClipboardFormatAvailable(fmt)) {
  9160     if (IsClipboardFormatAvailable(fmt)) {
  9161         int len;
  9161 	int len;
  9162 
  9162 
  9163         if (OpenClipboard(NULL)) {
  9163 	if (OpenClipboard(NULL)) {
  9164             hData = GetClipboardData(fmt);
  9164 	    hData = GetClipboardData(fmt);
  9165             if (hData) {
  9165 	    if (hData) {
  9166                 len = GlobalSize(hData);
  9166 		len = GlobalSize(hData);
  9167                 src = GlobalLock(hData);
  9167 		src = GlobalLock(hData);
  9168                 if (src) {
  9168 		if (src) {
  9169                     bytes = __MKBYTEARRAY(src, len);
  9169 		    bytes = __MKBYTEARRAY(src, len);
  9170                 }
  9170 		}
  9171                 GlobalUnlock(hData);
  9171 		GlobalUnlock(hData);
  9172                 CloseClipboard();
  9172 		CloseClipboard();
  9173                 DDPRINTF(("WinWorkstation [info]: clipBoard data size is <%d>\n", len));
  9173 		DDPRINTF(("WinWorkstation [info]: clipBoard data size is <%d>\n", len));
  9174                 RETURN(bytes);
  9174 		RETURN(bytes);
  9175             }
  9175 	    }
  9176         }
  9176 	}
  9177     }
  9177     }
  9178 badFormat: ;
  9178 badFormat: ;
  9179 %}.
  9179 %}.
  9180     ^ nil
  9180     ^ nil
  9181 
  9181 
  9198     hWnd = GetClipboardOwner();
  9198     hWnd = GetClipboardOwner();
  9199     RETURN(__MKEXTERNALADDRESS(hWnd));
  9199     RETURN(__MKEXTERNALADDRESS(hWnd));
  9200 %}
  9200 %}
  9201 
  9201 
  9202    "
  9202    "
  9203         Screen current getClipboardOwner
  9203 	Screen current getClipboardOwner
  9204    "
  9204    "
  9205 !
  9205 !
  9206 
  9206 
  9207 getClipboardSequenceNumber
  9207 getClipboardSequenceNumber
  9208     "answer the sequence number of the clioboard.
  9208     "answer the sequence number of the clioboard.
  9214     sequenceNumber = GetClipboardSequenceNumber();
  9214     sequenceNumber = GetClipboardSequenceNumber();
  9215     RETURN(__MKUINT(sequenceNumber));
  9215     RETURN(__MKUINT(sequenceNumber));
  9216 %}
  9216 %}
  9217 
  9217 
  9218    "
  9218    "
  9219         Screen current getClipboardSequenceNumber
  9219 	Screen current getClipboardSequenceNumber
  9220    "
  9220    "
  9221 !
  9221 !
  9222 
  9222 
  9223 getImapeClipboardData
  9223 getImapeClipboardData
  9224     "get the contents of the windows clipboard.
  9224     "get the contents of the windows clipboard.
  9225      Answer an image on success or nil otherwise."
  9225      Answer an image on success or nil otherwise."
  9226 
  9226 
  9227     |data|
  9227     |data|
  9228 
  9228 
  9229     (data := self getClipboardDataBytes:#CF_TIFF) notNil ifTrue:[
  9229     (data := self getClipboardDataBytes:#CF_TIFF) notNil ifTrue:[
  9230         "/ tiff image in data...
  9230 	"/ tiff image in data...
  9231         ^ "TIFFReader fromBytes:data" nil
  9231 	^ "TIFFReader fromBytes:data" nil
  9232     ].
  9232     ].
  9233     (data := self getClipboardDataBytes:#CF_DIB) notNil ifTrue:[
  9233     (data := self getClipboardDataBytes:#CF_DIB) notNil ifTrue:[
  9234         "/ device independent bitmap image in data...
  9234 	"/ device independent bitmap image in data...
  9235         ^ "TIFFReader fromBytes:data" nil
  9235 	^ "TIFFReader fromBytes:data" nil
  9236     ].
  9236     ].
  9237     ^ nil
  9237     ^ nil
  9238 
  9238 
  9239     "Created: / 09-10-2007 / 14:19:53 / cg"
  9239     "Created: / 09-10-2007 / 14:19:53 / cg"
  9240 !
  9240 !
  9250     unsigned char *src, *p;
  9250     unsigned char *src, *p;
  9251     WIDECHAR *w_src, *w_p;
  9251     WIDECHAR *w_src, *w_p;
  9252 
  9252 
  9253     /* check for format CF_TEXT */
  9253     /* check for format CF_TEXT */
  9254     if (IsClipboardFormatAvailable(CF_TEXT)) {
  9254     if (IsClipboardFormatAvailable(CF_TEXT)) {
  9255         int nRemain, len, realLen;
  9255 	int nRemain, len, realLen;
  9256 
  9256 
  9257         if (OpenClipboard(NULL)) {
  9257 	if (OpenClipboard(NULL)) {
  9258             hData = GetClipboardData(CF_TEXT);
  9258 	    hData = GetClipboardData(CF_TEXT);
  9259             src = GlobalLock(hData);
  9259 	    src = GlobalLock(hData);
  9260             len = src ? strlen(src) : 0;
  9260 	    len = src ? strlen(src) : 0;
  9261 
  9261 
  9262             /* see how much we really need (when CRLF is replaced by LF) */
  9262 	    /* see how much we really need (when CRLF is replaced by LF) */
  9263             for (realLen=nRemain=len, p=src; nRemain; ) {
  9263 	    for (realLen=nRemain=len, p=src; nRemain; ) {
  9264                 unsigned char ch;
  9264 		unsigned char ch;
  9265 
  9265 
  9266                 ch = *p++; nRemain--;
  9266 		ch = *p++; nRemain--;
  9267                 if (ch == 0x0D) {
  9267 		if (ch == 0x0D) {
  9268                     if (nRemain && (*p == 0x0A)) {
  9268 		    if (nRemain && (*p == 0x0A)) {
  9269                         p++; nRemain--;realLen--;
  9269 			p++; nRemain--;realLen--;
  9270                     }
  9270 		    }
  9271                 }
  9271 		}
  9272             }
  9272 	    }
  9273             s = __MKEMPTYSTRING(realLen);
  9273 	    s = __MKEMPTYSTRING(realLen);
  9274             if (s != nil) {
  9274 	    if (s != nil) {
  9275                 for (p=__stringVal(s); len; ) {
  9275 		for (p=__stringVal(s); len; ) {
  9276                     unsigned char ch;
  9276 		    unsigned char ch;
  9277 
  9277 
  9278                     *p = ch = *src++;
  9278 		    *p = ch = *src++;
  9279                     len--;
  9279 		    len--;
  9280                     if (len && (ch == 0x0D) && (*src == 0x0A)) {
  9280 		    if (len && (ch == 0x0D) && (*src == 0x0A)) {
  9281                         *p = 0x0A;
  9281 			*p = 0x0A;
  9282                         src++;
  9282 			src++;
  9283                         len--;
  9283 			len--;
  9284                     }
  9284 		    }
  9285                     p++;
  9285 		    p++;
  9286                 }
  9286 		}
  9287             }
  9287 	    }
  9288             GlobalUnlock(hData);
  9288 	    GlobalUnlock(hData);
  9289             CloseClipboard();
  9289 	    CloseClipboard();
  9290             DDPRINTF(("WinWorkstation [info]: clipBoard data is <%s>\n", (char *)hData));
  9290 	    DDPRINTF(("WinWorkstation [info]: clipBoard data is <%s>\n", (char *)hData));
  9291             RETURN(s);
  9291 	    RETURN(s);
  9292         }
  9292 	}
  9293     }
  9293     }
  9294 %}.
  9294 %}.
  9295     ^ nil
  9295     ^ nil
  9296 
  9296 
  9297     "Created: / 09-10-2007 / 12:46:00 / cg"
  9297     "Created: / 09-10-2007 / 12:46:00 / cg"
  9308     unsigned char *src, *p;
  9308     unsigned char *src, *p;
  9309     WIDECHAR *w_src, *w_p;
  9309     WIDECHAR *w_src, *w_p;
  9310 
  9310 
  9311     /* Unicode */
  9311     /* Unicode */
  9312     if (IsClipboardFormatAvailable(CF_UNICODETEXT)) {
  9312     if (IsClipboardFormatAvailable(CF_UNICODETEXT)) {
  9313         int nRemain, len, realLen;
  9313 	int nRemain, len, realLen;
  9314 
  9314 
  9315         if (OpenClipboard(NULL)) {
  9315 	if (OpenClipboard(NULL)) {
  9316             int needUnicode = 0;
  9316 	    int needUnicode = 0;
  9317 
  9317 
  9318             hData = GetClipboardData(CF_UNICODETEXT);
  9318 	    hData = GetClipboardData(CF_UNICODETEXT);
  9319             w_src = GlobalLock(hData);
  9319 	    w_src = GlobalLock(hData);
  9320             len = w_src ? wcslen(w_src) : 0;
  9320 	    len = w_src ? wcslen(w_src) : 0;
  9321             /*
  9321 	    /*
  9322              * see how much we really need (when CRLF is replaced by LF)
  9322 	     * see how much we really need (when CRLF is replaced by LF)
  9323              * and if result is really Unicode ...
  9323 	     * and if result is really Unicode ...
  9324              */
  9324 	     */
  9325             for (realLen=nRemain=len, w_p=w_src; nRemain; ) {
  9325 	    for (realLen=nRemain=len, w_p=w_src; nRemain; ) {
  9326                 WIDECHAR w_ch;
  9326 		WIDECHAR w_ch;
  9327 
  9327 
  9328                 w_ch = *w_p++; nRemain--;
  9328 		w_ch = *w_p++; nRemain--;
  9329                 if ((unsigned) w_ch > 0xFF) {
  9329 		if ((unsigned) w_ch > 0xFF) {
  9330                     needUnicode = 1;
  9330 		    needUnicode = 1;
  9331                 }
  9331 		}
  9332                 if (w_ch == 0x0D) {
  9332 		if (w_ch == 0x0D) {
  9333                     if (nRemain && (*w_p == 0x0A)) {
  9333 		    if (nRemain && (*w_p == 0x0A)) {
  9334                         w_p++; nRemain--;realLen--;
  9334 			w_p++; nRemain--;realLen--;
  9335                     }
  9335 		    }
  9336                 }
  9336 		}
  9337             }
  9337 	    }
  9338             if (! needUnicode) {
  9338 	    if (! needUnicode) {
  9339                 s = __MKEMPTYSTRING(realLen);
  9339 		s = __MKEMPTYSTRING(realLen);
  9340                 if (s != nil) {
  9340 		if (s != nil) {
  9341                     for (p = __stringVal(s); len; ) {
  9341 		    for (p = __stringVal(s); len; ) {
  9342                         unsigned char ch;
  9342 			unsigned char ch;
  9343 
  9343 
  9344                         *p = ch = *w_src++;
  9344 			*p = ch = *w_src++;
  9345                         len--;
  9345 			len--;
  9346                         if (len && (ch == 0x0D) && (*w_src == 0x0A)) {
  9346 			if (len && (ch == 0x0D) && (*w_src == 0x0A)) {
  9347                             *p = 0x0A;
  9347 			    *p = 0x0A;
  9348                             w_src++;
  9348 			    w_src++;
  9349                             len--;
  9349 			    len--;
  9350                         }
  9350 			}
  9351                         p++;
  9351 			p++;
  9352                     }
  9352 		    }
  9353                 }
  9353 		}
  9354             } else {
  9354 	    } else {
  9355                 s = __BYTEARRAY_NEW_INT(realLen * 2);
  9355 		s = __BYTEARRAY_NEW_INT(realLen * 2);
  9356                 if (s != nil) {
  9356 		if (s != nil) {
  9357                     __objPtr(s)->o_class = @global(Unicode16String);
  9357 		    __objPtr(s)->o_class = @global(Unicode16String);
  9358                     for (w_p = (WIDECHAR *)__stringVal(s); len; ) {
  9358 		    for (w_p = (WIDECHAR *)__stringVal(s); len; ) {
  9359                         WIDECHAR w_ch;
  9359 			WIDECHAR w_ch;
  9360 
  9360 
  9361                         *w_p = w_ch = *w_src++;
  9361 			*w_p = w_ch = *w_src++;
  9362                         len--;
  9362 			len--;
  9363                         if (len && (w_ch == 0x0D) && (*w_src == 0x0A)) {
  9363 			if (len && (w_ch == 0x0D) && (*w_src == 0x0A)) {
  9364                             *w_p = 0x0A;
  9364 			    *w_p = 0x0A;
  9365                             w_src++;
  9365 			    w_src++;
  9366                             len--;
  9366 			    len--;
  9367                         }
  9367 			}
  9368                         w_p++;
  9368 			w_p++;
  9369                     }
  9369 		    }
  9370                 }
  9370 		}
  9371             }
  9371 	    }
  9372             GlobalUnlock(hData);
  9372 	    GlobalUnlock(hData);
  9373             CloseClipboard();
  9373 	    CloseClipboard();
  9374             RETURN(s);
  9374 	    RETURN(s);
  9375         }
  9375 	}
  9376     }
  9376     }
  9377 %}.
  9377 %}.
  9378     ^ nil
  9378     ^ nil
  9379 
  9379 
  9380     "Created: / 09-10-2007 / 12:45:26 / cg"
  9380     "Created: / 09-10-2007 / 12:45:26 / cg"
  9387 
  9387 
  9388 %{
  9388 %{
  9389     HANDLE hData;
  9389     HANDLE hData;
  9390 
  9390 
  9391     if (__isStringLike(aString)) {
  9391     if (__isStringLike(aString)) {
  9392         char *s, *p, *src, *dst;
  9392 	char *s, *p, *src, *dst;
  9393         int n, len, realLen;
  9393 	int n, len, realLen;
  9394 
  9394 
  9395         if (OpenClipboard(NULL)) {
  9395 	if (OpenClipboard(NULL)) {
  9396             s = __stringVal(aString);
  9396 	    s = __stringVal(aString);
  9397             /* must replace CR by CRLF */
  9397 	    /* must replace CR by CRLF */
  9398             len = realLen = __stringSize(aString);
  9398 	    len = realLen = __stringSize(aString);
  9399             for (src=s, n=len; n; n--) {
  9399 	    for (src=s, n=len; n; n--) {
  9400                 if ((src[0] == 0x0A) && ((src == s) || (src[-1] != 0x0D))) {
  9400 		if ((src[0] == 0x0A) && ((src == s) || (src[-1] != 0x0D))) {
  9401                     realLen++;
  9401 		    realLen++;
  9402                 }
  9402 		}
  9403                 src++;
  9403 		src++;
  9404             }
  9404 	    }
  9405 
  9405 
  9406             hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, realLen+1);
  9406 	    hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, realLen+1);
  9407             if (hData) {
  9407 	    if (hData) {
  9408                 char *t = GlobalLock(hData);
  9408 		char *t = GlobalLock(hData);
  9409 
  9409 
  9410                 if (t) {
  9410 		if (t) {
  9411                     for (src=s, dst=t, n=len; n;) {
  9411 		    for (src=s, dst=t, n=len; n;) {
  9412                         unsigned char ch;
  9412 			unsigned char ch;
  9413 
  9413 
  9414                         ch = src[0]; n--;
  9414 			ch = src[0]; n--;
  9415                         if ((ch == 0x0A) && ((src == s) || (src[-1] != 0x0D))) {
  9415 			if ((ch == 0x0A) && ((src == s) || (src[-1] != 0x0D))) {
  9416                             *dst++ = 0x0D;
  9416 			    *dst++ = 0x0D;
  9417                             *dst++ = 0x0A;
  9417 			    *dst++ = 0x0A;
  9418                         } else {
  9418 			} else {
  9419                             *dst++ = ch;
  9419 			    *dst++ = ch;
  9420                         }
  9420 			}
  9421                         src++;
  9421 			src++;
  9422                     }
  9422 		    }
  9423                     *dst = 0;
  9423 		    *dst = 0;
  9424 
  9424 
  9425                     EmptyClipboard();
  9425 		    EmptyClipboard();
  9426                     if (SetClipboardData(CF_TEXT, hData) != 0) {
  9426 		    if (SetClipboardData(CF_TEXT, hData) != 0) {
  9427                         /* Note: After setting clipboard data,
  9427 			/* Note: After setting clipboard data,
  9428                          * the memory block previously allocated belongs to
  9428 			 * the memory block previously allocated belongs to
  9429                          * the clipboard - not to the app.
  9429 			 * the clipboard - not to the app.
  9430                          */
  9430 			 */
  9431                         CloseClipboard();
  9431 			CloseClipboard();
  9432                         RETURN (true);
  9432 			RETURN (true);
  9433                     }
  9433 		    }
  9434                     DPRINTF(("SetClipboardData error:%d\n", GetLastError()));
  9434 		    DPRINTF(("SetClipboardData error:%d\n", GetLastError()));
  9435                     GlobalUnlock(hData);
  9435 		    GlobalUnlock(hData);
  9436                 }
  9436 		}
  9437             }
  9437 	    }
  9438             CloseClipboard();
  9438 	    CloseClipboard();
  9439         }
  9439 	}
  9440         RETURN(false);
  9440 	RETURN(false);
  9441     }
  9441     }
  9442 
  9442 
  9443     /* Unicode */
  9443     /* Unicode */
  9444     if (__isWords(aString)) {
  9444     if (__isWords(aString)) {
  9445         WIDECHAR *w_s, *w_p, *w_src, *w_dst;
  9445 	WIDECHAR *w_s, *w_p, *w_src, *w_dst;
  9446         int n, len, realLen;
  9446 	int n, len, realLen;
  9447 
  9447 
  9448         if (OpenClipboard(NULL)) {
  9448 	if (OpenClipboard(NULL)) {
  9449             OBJ cls;
  9449 	    OBJ cls;
  9450             int nInstBytes;
  9450 	    int nInstBytes;
  9451 
  9451 
  9452             cls = __qClass(aString);
  9452 	    cls = __qClass(aString);
  9453             nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  9453 	    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  9454             w_s = (WIDECHAR *)(__stringVal(aString) + nInstBytes);
  9454 	    w_s = (WIDECHAR *)(__stringVal(aString) + nInstBytes);
  9455 
  9455 
  9456             /* must replace CR by CRLF */
  9456 	    /* must replace CR by CRLF */
  9457             len = realLen = (__byteArraySize(aString) - nInstBytes) / 2;
  9457 	    len = realLen = (__byteArraySize(aString) - nInstBytes) / 2;
  9458             for (w_src=w_s, n=len; n; n--) {
  9458 	    for (w_src=w_s, n=len; n; n--) {
  9459                 if ((w_src[0] == 0x0A) && ((w_src == w_s) || (w_src[-1] != 0x0D))) {
  9459 		if ((w_src[0] == 0x0A) && ((w_src == w_s) || (w_src[-1] != 0x0D))) {
  9460                     realLen++;
  9460 		    realLen++;
  9461                 }
  9461 		}
  9462                 w_src++;
  9462 		w_src++;
  9463             }
  9463 	    }
  9464 
  9464 
  9465             hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (realLen+1)*sizeof(WIDECHAR));
  9465 	    hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (realLen+1)*sizeof(WIDECHAR));
  9466             if (hData) {
  9466 	    if (hData) {
  9467                 WIDECHAR *t = GlobalLock(hData);
  9467 		WIDECHAR *t = GlobalLock(hData);
  9468 
  9468 
  9469                 if (t) {
  9469 		if (t) {
  9470                     for (w_src=w_s, w_dst=t, n=len; n;) {
  9470 		    for (w_src=w_s, w_dst=t, n=len; n;) {
  9471                         WIDECHAR w_ch;
  9471 			WIDECHAR w_ch;
  9472 
  9472 
  9473                         w_ch = w_src[0]; n--;
  9473 			w_ch = w_src[0]; n--;
  9474                         if ((w_ch == 0x0A) && ((w_src == w_s) || (w_src[-1] != 0x0D))) {
  9474 			if ((w_ch == 0x0A) && ((w_src == w_s) || (w_src[-1] != 0x0D))) {
  9475                             *w_dst++ = 0x0D;
  9475 			    *w_dst++ = 0x0D;
  9476                             *w_dst++ = 0x0A;
  9476 			    *w_dst++ = 0x0A;
  9477                         } else {
  9477 			} else {
  9478                             *w_dst++ = w_ch;
  9478 			    *w_dst++ = w_ch;
  9479                         }
  9479 			}
  9480                         w_src++;
  9480 			w_src++;
  9481                     }
  9481 		    }
  9482                     *w_dst = 0;
  9482 		    *w_dst = 0;
  9483 
  9483 
  9484                     EmptyClipboard();
  9484 		    EmptyClipboard();
  9485                     if (SetClipboardData(CF_UNICODETEXT, hData) != 0) {
  9485 		    if (SetClipboardData(CF_UNICODETEXT, hData) != 0) {
  9486                         /* Note: After setting clipboard data,
  9486 			/* Note: After setting clipboard data,
  9487                          * the memory block previously allocated belongs to
  9487 			 * the memory block previously allocated belongs to
  9488                          * the clipboard - not to the app.
  9488 			 * the clipboard - not to the app.
  9489                          */
  9489 			 */
  9490                         CloseClipboard();
  9490 			CloseClipboard();
  9491                         RETURN (true);
  9491 			RETURN (true);
  9492                     }
  9492 		    }
  9493                     DPRINTF(("SetClipboardData error:%d\n", GetLastError()));
  9493 		    DPRINTF(("SetClipboardData error:%d\n", GetLastError()));
  9494                     GlobalUnlock(hData);
  9494 		    GlobalUnlock(hData);
  9495                 }
  9495 		}
  9496             }
  9496 	    }
  9497             CloseClipboard();
  9497 	    CloseClipboard();
  9498         }
  9498 	}
  9499         RETURN(false);
  9499 	RETURN(false);
  9500     }
  9500     }
  9501 %}.
  9501 %}.
  9502     self primitiveFailed.
  9502     self primitiveFailed.
  9503 ! !
  9503 ! !
  9504 
  9504 
  9522 
  9522 
  9523 %{  /* NOCONTEXT */
  9523 %{  /* NOCONTEXT */
  9524     int id, ir, ig, ib;
  9524     int id, ir, ig, ib;
  9525 
  9525 
  9526     if (__bothSmallInteger(r, g) && __isSmallInteger(b)) {
  9526     if (__bothSmallInteger(r, g) && __isSmallInteger(b)) {
  9527         id = RGB2st(__intVal(r),__intVal(g),__intVal(b));
  9527 	id = RGB2st(__intVal(r),__intVal(g),__intVal(b));
  9528         CPRINTF(("alloc color %d/%d/%d -> %x\n", ir, ig, ib, id));
  9528 	CPRINTF(("alloc color %d/%d/%d -> %x\n", ir, ig, ib, id));
  9529         RETURN ( __MKSMALLINT(id) );
  9529 	RETURN ( __MKSMALLINT(id) );
  9530     }
  9530     }
  9531 %}.
  9531 %}.
  9532     self primitiveFailed.
  9532     self primitiveFailed.
  9533     ^ nil
  9533     ^ nil
  9534 !
  9534 !
  9546      and evaluate the 3-arg block, aBlock with them"
  9546      and evaluate the 3-arg block, aBlock with them"
  9547 
  9547 
  9548     |val|
  9548     |val|
  9549 
  9549 
  9550     self getScaledRGBFrom:index into:[:r :g :b |
  9550     self getScaledRGBFrom:index into:[:r :g :b |
  9551         val := aBlock
  9551 	val := aBlock
  9552                 value:(r * 100.0 / 16rFFFF)
  9552 		value:(r * 100.0 / 16rFFFF)
  9553                 value:(g * 100.0 / 16rFFFF)
  9553 		value:(g * 100.0 / 16rFFFF)
  9554                 value:(b * 100.0 / 16rFFFF)
  9554 		value:(b * 100.0 / 16rFFFF)
  9555     ].
  9555     ].
  9556     "/ 'get RGB' printCR.
  9556     "/ 'get RGB' printCR.
  9557     ^ val
  9557     ^ val
  9558 !
  9558 !
  9559 
  9559 
  9563      Return nil for unknown color names."
  9563      Return nil for unknown color names."
  9564 
  9564 
  9565     |val|
  9565     |val|
  9566 
  9566 
  9567     self getScaledRGBFromName:colorName into:[:r :g :b |
  9567     self getScaledRGBFromName:colorName into:[:r :g :b |
  9568         r isNil ifTrue:[^nil].
  9568 	r isNil ifTrue:[^nil].
  9569         val := aBlock
  9569 	val := aBlock
  9570                 value:(r * 100.0 / 16rFFFF)
  9570 		value:(r * 100.0 / 16rFFFF)
  9571                 value:(g * 100.0 / 16rFFFF)
  9571 		value:(g * 100.0 / 16rFFFF)
  9572                 value:(b * 100.0 / 16rFFFF)
  9572 		value:(b * 100.0 / 16rFFFF)
  9573     ].
  9573     ].
  9574     ^ val
  9574     ^ val
  9575 !
  9575 !
  9576 
  9576 
  9577 getScaledRGBFrom:index into:aBlock
  9577 getScaledRGBFrom:index into:aBlock
  9607     |triple r g b found cName|
  9607     |triple r g b found cName|
  9608 
  9608 
  9609     r := g := b := 0.
  9609     r := g := b := 0.
  9610     found := false.
  9610     found := false.
  9611     (colorName startsWith:$#) ifTrue:[
  9611     (colorName startsWith:$#) ifTrue:[
  9612         "/ color in r/g/b hex notation
  9612 	"/ color in r/g/b hex notation
  9613         colorName size == 7 ifTrue:[
  9613 	colorName size == 7 ifTrue:[
  9614             r := Integer readFrom:(colorName copyFrom:2 to:3) radix:16 onError:[nil].
  9614 	    r := Integer readFrom:(colorName copyFrom:2 to:3) radix:16 onError:[nil].
  9615             g := Integer readFrom:(colorName copyFrom:4 to:5) radix:16 onError:[nil].
  9615 	    g := Integer readFrom:(colorName copyFrom:4 to:5) radix:16 onError:[nil].
  9616             b := Integer readFrom:(colorName copyFrom:6 to:7) radix:16 onError:[nil].
  9616 	    b := Integer readFrom:(colorName copyFrom:6 to:7) radix:16 onError:[nil].
  9617         ].
  9617 	].
  9618         (r isNil or:[g isNil or:[b isNil]]) ifTrue:[^ nil].
  9618 	(r isNil or:[g isNil or:[b isNil]]) ifTrue:[^ nil].
  9619         found := true.
  9619 	found := true.
  9620     ] ifFalse:[
  9620     ] ifFalse:[
  9621         cName := colorName asString.
  9621 	cName := colorName asString.
  9622         triple := StandardColorValues at:cName ifAbsent:nil.
  9622 	triple := StandardColorValues at:cName ifAbsent:nil.
  9623         triple isNil ifTrue:[
  9623 	triple isNil ifTrue:[
  9624             "/ try lowercase name
  9624 	    "/ try lowercase name
  9625             cName := cName asLowercase.
  9625 	    cName := cName asLowercase.
  9626             triple := StandardColorValues at:cName ifAbsent:nil.
  9626 	    triple := StandardColorValues at:cName ifAbsent:nil.
  9627             triple isNil ifTrue:[
  9627 	    triple isNil ifTrue:[
  9628                 "/ try lowercase without intermixed spaces
  9628 		"/ try lowercase without intermixed spaces
  9629                 cName := cName asCollectionOfWords asStringWith:nil.
  9629 		cName := cName asCollectionOfWords asStringWith:nil.
  9630                 triple := StandardColorValues at:cName ifAbsent:nil.
  9630 		triple := StandardColorValues at:cName ifAbsent:nil.
  9631             ].
  9631 	    ].
  9632         ].
  9632 	].
  9633         triple notNil ifTrue:[
  9633 	triple notNil ifTrue:[
  9634             r := triple at:1.
  9634 	    r := triple at:1.
  9635             g := triple at:2.
  9635 	    g := triple at:2.
  9636             b := triple at:3.
  9636 	    b := triple at:3.
  9637             found := true.
  9637 	    found := true.
  9638         ].
  9638 	].
  9639     ].
  9639     ].
  9640     found ifFalse:[
  9640     found ifFalse:[
  9641         "/ ('WinWorkstation: unknown color: ' , colorName) infoPrintCR.
  9641 	"/ ('WinWorkstation: unknown color: ' , colorName) infoPrintCR.
  9642         ^ nil.
  9642 	^ nil.
  9643     ].
  9643     ].
  9644 
  9644 
  9645     ^ aBlock value:((r * 256) + r) value:((g * 256) + g) value:((b * 256) + b)
  9645     ^ aBlock value:((r * 256) + r) value:((g * 256) + g) value:((b * 256) + b)
  9646 
  9646 
  9647     "Modified (comment): / 14-11-2016 / 14:02:11 / cg"
  9647     "Modified (comment): / 14-11-2016 / 14:02:11 / cg"
  9656 
  9656 
  9657     aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'.
  9657     aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'.
  9658     aStream isNil ifTrue:[^ nil].
  9658     aStream isNil ifTrue:[^ nil].
  9659     list := OrderedCollection new.
  9659     list := OrderedCollection new.
  9660     [aStream atEnd] whileFalse:[
  9660     [aStream atEnd] whileFalse:[
  9661         line := aStream nextLine.
  9661 	line := aStream nextLine.
  9662         line notNil ifTrue:[
  9662 	line notNil ifTrue:[
  9663             "skip the r/g/b numbers"
  9663 	    "skip the r/g/b numbers"
  9664             index := 1.
  9664 	    index := 1.
  9665             [(line at:index) isSeparator] whileTrue:[index := index + 1].
  9665 	    [(line at:index) isSeparator] whileTrue:[index := index + 1].
  9666             [(line at:index) isDigit] whileTrue:[index := index + 1].
  9666 	    [(line at:index) isDigit] whileTrue:[index := index + 1].
  9667             [(line at:index) isSeparator] whileTrue:[index := index + 1].
  9667 	    [(line at:index) isSeparator] whileTrue:[index := index + 1].
  9668             [(line at:index) isDigit] whileTrue:[index := index + 1].
  9668 	    [(line at:index) isDigit] whileTrue:[index := index + 1].
  9669             [(line at:index) isSeparator] whileTrue:[index := index + 1].
  9669 	    [(line at:index) isSeparator] whileTrue:[index := index + 1].
  9670             [(line at:index) isDigit] whileTrue:[index := index + 1].
  9670 	    [(line at:index) isDigit] whileTrue:[index := index + 1].
  9671             [(line at:index) isSeparator] whileTrue:[index := index + 1].
  9671 	    [(line at:index) isSeparator] whileTrue:[index := index + 1].
  9672             colorName := line copyFrom:index.
  9672 	    colorName := line copyFrom:index.
  9673             ((colorName occurrencesOf:(Character space)) == 0) ifTrue:[
  9673 	    ((colorName occurrencesOf:(Character space)) == 0) ifTrue:[
  9674                 list add:colorName
  9674 		list add:colorName
  9675             ]
  9675 	    ]
  9676         ]
  9676 	]
  9677     ].
  9677     ].
  9678     aStream close.
  9678     aStream close.
  9679     ^ list sort
  9679     ^ list sort
  9680 
  9680 
  9681     "
  9681     "
  9690      WIN-component value (0..16rFFFF) as an integer"
  9690      WIN-component value (0..16rFFFF) as an integer"
  9691 
  9691 
  9692 %{  /* NOCONTEXT */
  9692 %{  /* NOCONTEXT */
  9693 
  9693 
  9694     if (__isSmallInteger(aPercentage)) {
  9694     if (__isSmallInteger(aPercentage)) {
  9695         RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) );
  9695 	RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) );
  9696     }
  9696     }
  9697     if (__isFloat(aPercentage)) {
  9697     if (__isFloat(aPercentage)) {
  9698         RETURN ( __MKSMALLINT(0xFFFF * (INT)(__floatVal(aPercentage)) / 100) );
  9698 	RETURN ( __MKSMALLINT(0xFFFF * (INT)(__floatVal(aPercentage)) / 100) );
  9699     }
  9699     }
  9700 %}.
  9700 %}.
  9701     ^ (16rFFFF * aPercentage / 100) rounded
  9701     ^ (16rFFFF * aPercentage / 100) rounded
  9702 !
  9702 !
  9703 
  9703 
  9722      (actually, there are more than those below ...)"
  9722      (actually, there are more than those below ...)"
  9723 
  9723 
  9724     "/ if you add something here, also add to #shapeNumberFromCursor ...
  9724     "/ if you add something here, also add to #shapeNumberFromCursor ...
  9725 
  9725 
  9726     ^ #(
  9726     ^ #(
  9727         #upLeftArrow            "/ IDC_ARROW
  9727 	#upLeftArrow            "/ IDC_ARROW
  9728         #upDownArrow            "/ IDC_SIZENS
  9728 	#upDownArrow            "/ IDC_SIZENS
  9729         #leftRightArrow         "/ IDC_SIZEWE
  9729 	#leftRightArrow         "/ IDC_SIZEWE
  9730         #text                   "/ IDC_IBEAM
  9730 	#text                   "/ IDC_IBEAM
  9731         #wait                   "/ IDC_WAIT
  9731 	#wait                   "/ IDC_WAIT
  9732         #execute                "/ IDC_APPSTARTING
  9732 	#execute                "/ IDC_APPSTARTING
  9733         #crossHair              "/ IDC_CROSS
  9733 	#crossHair              "/ IDC_CROSS
  9734         #fourWay                "/ IDC_SIZEALL
  9734 	#fourWay                "/ IDC_SIZEALL
  9735         #upRightHand            "/ IDC_ARROW
  9735 	#upRightHand            "/ IDC_ARROW
  9736         #noDrop                 "/ IDC_NO
  9736 	#noDrop                 "/ IDC_NO
  9737         #stop                   "/ IDC_NO
  9737 	#stop                   "/ IDC_NO
  9738        )
  9738        )
  9739 
  9739 
  9740     "Modified: / 10.12.1999 / 15:16:26 / cg"
  9740     "Modified: / 10.12.1999 / 15:16:26 / cg"
  9741 !
  9741 !
  9742 
  9742 
  9767     "/ repadding and/or resizing required ?
  9767     "/ repadding and/or resizing required ?
  9768     bpl := sourceBytes size / h.
  9768     bpl := sourceBytes size / h.
  9769     bplPadded := (cW + padding - 1) // padding * 2.
  9769     bplPadded := (cW + padding - 1) // padding * 2.
  9770 
  9770 
  9771     bpl ~~ bplPadded ifTrue:[
  9771     bpl ~~ bplPadded ifTrue:[
  9772          "/     'repad cursor bits' infoPrintCR.
  9772 	 "/     'repad cursor bits' infoPrintCR.
  9773         srcPadded := ByteArray new:(bplPadded * cH).
  9773 	srcPadded := ByteArray new:(bplPadded * cH).
  9774         nB := bpl min: bplPadded.
  9774 	nB := bpl min: bplPadded.
  9775         nR := cH min: h.
  9775 	nR := cH min: h.
  9776 
  9776 
  9777         dstOffs := srcOffs := 1.
  9777 	dstOffs := srcOffs := 1.
  9778         1 to:nR do:[:row |
  9778 	1 to:nR do:[:row |
  9779             srcPadded
  9779 	    srcPadded
  9780                 replaceFrom:dstOffs
  9780 		replaceFrom:dstOffs
  9781                 to:(dstOffs+nB-1)
  9781 		to:(dstOffs+nB-1)
  9782                 with:src
  9782 		with:src
  9783                 startingAt:srcOffs.
  9783 		startingAt:srcOffs.
  9784             dstOffs := dstOffs + bplPadded.
  9784 	    dstOffs := dstOffs + bplPadded.
  9785             srcOffs := srcOffs + bpl.
  9785 	    srcOffs := srcOffs + bpl.
  9786         ].
  9786 	].
  9787 
  9787 
  9788         maskPadded := ByteArray new:(bplPadded * cH).
  9788 	maskPadded := ByteArray new:(bplPadded * cH).
  9789         dstOffs := srcOffs := 1.
  9789 	dstOffs := srcOffs := 1.
  9790         1 to:nR do:[:row |
  9790 	1 to:nR do:[:row |
  9791             maskPadded
  9791 	    maskPadded
  9792                 replaceFrom:dstOffs
  9792 		replaceFrom:dstOffs
  9793                 to:(dstOffs+nB-1)
  9793 		to:(dstOffs+nB-1)
  9794                 with:mask
  9794 		with:mask
  9795                 startingAt:srcOffs.
  9795 		startingAt:srcOffs.
  9796             dstOffs := dstOffs + bplPadded.
  9796 	    dstOffs := dstOffs + bplPadded.
  9797             srcOffs := srcOffs + bpl.
  9797 	    srcOffs := srcOffs + bpl.
  9798         ].
  9798 	].
  9799         src := srcPadded.
  9799 	src := srcPadded.
  9800         mask := maskPadded.
  9800 	mask := maskPadded.
  9801 
  9801 
  9802     ].
  9802     ].
  9803 
  9803 
  9804     src invert.
  9804     src invert.
  9805     1 to:src size do:[:index |
  9805     1 to:src size do:[:index |
  9806         src byteAt:index put:((src byteAt:index) bitAnd:(mask byteAt:index)).
  9806 	src byteAt:index put:((src byteAt:index) bitAnd:(mask byteAt:index)).
  9807     ].
  9807     ].
  9808     mask invert.
  9808     mask invert.
  9809     cursor := self
  9809     cursor := self
  9810         primCreateCursorSourceBits:src
  9810 	primCreateCursorSourceBits:src
  9811         maskBits:mask
  9811 	maskBits:mask
  9812         hotX:hx hotY:hy
  9812 	hotX:hx hotY:hy
  9813         width:cW height:cH.
  9813 	width:cW height:cH.
  9814     cursor notNil ifTrue:[^ cursor ].
  9814     cursor notNil ifTrue:[^ cursor ].
  9815     'WinWorkstation [warning]: could not create bitmap cursor' infoPrintCR.
  9815     'WinWorkstation [warning]: could not create bitmap cursor' infoPrintCR.
  9816 
  9816 
  9817     "Modified: / 08-09-2006 / 15:39:42 / cg"
  9817     "Modified: / 08-09-2006 / 15:39:42 / cg"
  9818 !
  9818 !
  9825     "destroy a cursor"
  9825     "destroy a cursor"
  9826 
  9826 
  9827 %{  /* NOCONTEXT */
  9827 %{  /* NOCONTEXT */
  9828 
  9828 
  9829     if (ISCONNECTED) {
  9829     if (ISCONNECTED) {
  9830         if (__isExternalAddress(aCursorId)) {
  9830 	if (__isExternalAddress(aCursorId)) {
  9831             HCURSOR curs = _HCURSORVal(aCursorId);
  9831 	    HCURSOR curs = _HCURSORVal(aCursorId);
  9832 
  9832 
  9833             if (curs) {
  9833 	    if (curs) {
  9834 #ifdef KEEP_STD_CURSORS
  9834 #ifdef KEEP_STD_CURSORS
  9835                 if ((curs != H_C_ARROW)
  9835 		if ((curs != H_C_ARROW)
  9836                  && (curs != H_C_CROSS)
  9836 		 && (curs != H_C_CROSS)
  9837                  && (curs != H_C_IBEAM)
  9837 		 && (curs != H_C_IBEAM)
  9838                  && (curs != H_C_ICON)
  9838 		 && (curs != H_C_ICON)
  9839                  && (curs != H_C_NO)
  9839 		 && (curs != H_C_NO)
  9840                  && (curs != H_C_SIZE)
  9840 		 && (curs != H_C_SIZE)
  9841                  && (curs != H_C_SIZEALL)
  9841 		 && (curs != H_C_SIZEALL)
  9842                  && (curs != H_C_SIZENESW)
  9842 		 && (curs != H_C_SIZENESW)
  9843                  && (curs != H_C_SIZENS)
  9843 		 && (curs != H_C_SIZENS)
  9844                  && (curs != H_C_SIZENWSE)
  9844 		 && (curs != H_C_SIZENWSE)
  9845                  && (curs != H_C_UPARROW)
  9845 		 && (curs != H_C_UPARROW)
  9846                  && (curs != H_C_APPSTARTING)
  9846 		 && (curs != H_C_APPSTARTING)
  9847                  && (curs != H_C_WAIT))
  9847 		 && (curs != H_C_WAIT))
  9848 #endif /* KEEP_STD_CURSORS */
  9848 #endif /* KEEP_STD_CURSORS */
  9849                 {
  9849 		{
  9850                     DestroyCursor(curs);
  9850 		    DestroyCursor(curs);
  9851 #ifdef COUNT_RESOURCES
  9851 #ifdef COUNT_RESOURCES
  9852                     __cnt_cur--;
  9852 		    __cnt_cur--;
  9853                     RESPRINTF(("DestroyCursor %d\n",__cnt_cur));
  9853 		    RESPRINTF(("DestroyCursor %d\n",__cnt_cur));
  9854 #endif
  9854 #endif
  9855                 }
  9855 		}
  9856             }
  9856 	    }
  9857             RETURN ( self );
  9857 	    RETURN ( self );
  9858         }
  9858 	}
  9859     }
  9859     }
  9860 %}
  9860 %}
  9861 !
  9861 !
  9862 
  9862 
  9863 needDeviceFormsForCursor
  9863 needDeviceFormsForCursor
  9870 %{  /* NOCONTEXT */
  9870 %{  /* NOCONTEXT */
  9871     HCURSOR newCursor;
  9871     HCURSOR newCursor;
  9872     LPCTSTR cId;
  9872     LPCTSTR cId;
  9873 
  9873 
  9874     if (__isSmallInteger(number)) {
  9874     if (__isSmallInteger(number)) {
  9875         cId = (LPCTSTR)(__intVal(number));
  9875 	cId = (LPCTSTR)(__intVal(number));
  9876         newCursor = LoadCursor(NULL, cId);
  9876 	newCursor = LoadCursor(NULL, cId);
  9877         if (newCursor) {
  9877 	if (newCursor) {
  9878 #ifdef KEEP_STD_CURSORS
  9878 #ifdef KEEP_STD_CURSORS
  9879             if (cId == IDC_ARROW)
  9879 	    if (cId == IDC_ARROW)
  9880                 H_C_ARROW = newCursor;
  9880 		H_C_ARROW = newCursor;
  9881             else if (cId == IDC_CROSS)
  9881 	    else if (cId == IDC_CROSS)
  9882                 H_C_CROSS = newCursor;
  9882 		H_C_CROSS = newCursor;
  9883             else if (cId == IDC_IBEAM)
  9883 	    else if (cId == IDC_IBEAM)
  9884                 H_C_IBEAM = newCursor;
  9884 		H_C_IBEAM = newCursor;
  9885             else if (cId == IDC_ICON)
  9885 	    else if (cId == IDC_ICON)
  9886                 H_C_ICON = newCursor;
  9886 		H_C_ICON = newCursor;
  9887             else if (cId == IDC_NO)
  9887 	    else if (cId == IDC_NO)
  9888                 H_C_NO = newCursor;
  9888 		H_C_NO = newCursor;
  9889             else if (cId == IDC_SIZE)
  9889 	    else if (cId == IDC_SIZE)
  9890                 H_C_SIZE = newCursor;
  9890 		H_C_SIZE = newCursor;
  9891             else if (cId == IDC_SIZEALL)
  9891 	    else if (cId == IDC_SIZEALL)
  9892                 H_C_SIZEALL = newCursor;
  9892 		H_C_SIZEALL = newCursor;
  9893             else if (cId == IDC_SIZENESW)
  9893 	    else if (cId == IDC_SIZENESW)
  9894                 H_C_SIZENESW = newCursor;
  9894 		H_C_SIZENESW = newCursor;
  9895             else if (cId == IDC_SIZENS)
  9895 	    else if (cId == IDC_SIZENS)
  9896                 H_C_SIZENS = newCursor;
  9896 		H_C_SIZENS = newCursor;
  9897             else if (cId == IDC_SIZENWSE)
  9897 	    else if (cId == IDC_SIZENWSE)
  9898                 H_C_SIZENWSE = newCursor;
  9898 		H_C_SIZENWSE = newCursor;
  9899             else if (cId == IDC_UPARROW)
  9899 	    else if (cId == IDC_UPARROW)
  9900                 H_C_UPARROW = newCursor;
  9900 		H_C_UPARROW = newCursor;
  9901             else if (cId == IDC_WAIT)
  9901 	    else if (cId == IDC_WAIT)
  9902                 H_C_WAIT = newCursor;
  9902 		H_C_WAIT = newCursor;
  9903             else if (cId == IDC_APPSTARTING)
  9903 	    else if (cId == IDC_APPSTARTING)
  9904                 H_C_APPSTARTING = newCursor;
  9904 		H_C_APPSTARTING = newCursor;
  9905 #endif /* KEEP_STD_CURSORS */
  9905 #endif /* KEEP_STD_CURSORS */
  9906             RETURN ( __MKOBJ(newCursor) );
  9906 	    RETURN ( __MKOBJ(newCursor) );
  9907         }
  9907 	}
  9908     }
  9908     }
  9909     RETURN (nil);
  9909     RETURN (nil);
  9910 %}
  9910 %}
  9911 !
  9911 !
  9912 
  9912 
  9919     if (__isByteArray(src)
  9919     if (__isByteArray(src)
  9920      && __isByteArray(mask)
  9920      && __isByteArray(mask)
  9921      && __bothSmallInteger(hx, hy)
  9921      && __bothSmallInteger(hx, hy)
  9922      && __bothSmallInteger(w, h)) {
  9922      && __bothSmallInteger(w, h)) {
  9923 
  9923 
  9924         newCursor = CreateCursor((HANDLE) __getHInstance(),
  9924 	newCursor = CreateCursor((HANDLE) __getHInstance(),
  9925                                  __intVal(hx), __intVal(hy),
  9925 				 __intVal(hx), __intVal(hy),
  9926                                  __intVal(w), __intVal(h),
  9926 				 __intVal(w), __intVal(h),
  9927                                  __ByteArrayInstPtr(mask)->ba_element,
  9927 				 __ByteArrayInstPtr(mask)->ba_element,
  9928                                  __ByteArrayInstPtr(src)->ba_element);
  9928 				 __ByteArrayInstPtr(src)->ba_element);
  9929         if (newCursor) {
  9929 	if (newCursor) {
  9930 #ifdef COUNT_RESOURCES
  9930 #ifdef COUNT_RESOURCES
  9931             __cnt_cur++;
  9931 	    __cnt_cur++;
  9932             RESPRINTF(("CreateCursor %d\n",__cnt_cur));
  9932 	    RESPRINTF(("CreateCursor %d\n",__cnt_cur));
  9933 #endif
  9933 #endif
  9934             RETURN ( __MKOBJ(newCursor));
  9934 	    RETURN ( __MKOBJ(newCursor));
  9935         }
  9935 	}
  9936     }
  9936     }
  9937     RETURN (nil);
  9937     RETURN (nil);
  9938 %}
  9938 %}
  9939 !
  9939 !
  9940 
  9940 
  9944 
  9944 
  9945     "this is pure Win-knowlegde - but you may easily add more"
  9945     "this is pure Win-knowlegde - but you may easily add more"
  9946 
  9946 
  9947 %{  /* NOCONTEXT */
  9947 %{  /* NOCONTEXT */
  9948     if (shape == @symbol(upRightHand)) {
  9948     if (shape == @symbol(upRightHand)) {
  9949         RETURN ( __MKSMALLINT( (INT)IDC_ARROW));
  9949 	RETURN ( __MKSMALLINT( (INT)IDC_ARROW));
  9950     }
  9950     }
  9951     if (shape == @symbol(upLeftArrow)) {
  9951     if (shape == @symbol(upLeftArrow)) {
  9952         RETURN ( __MKSMALLINT( (INT)IDC_ARROW));
  9952 	RETURN ( __MKSMALLINT( (INT)IDC_ARROW));
  9953     }
  9953     }
  9954     if (shape == @symbol(upDownArrow)) {
  9954     if (shape == @symbol(upDownArrow)) {
  9955         RETURN ( __MKSMALLINT( (INT)IDC_SIZENS));
  9955 	RETURN ( __MKSMALLINT( (INT)IDC_SIZENS));
  9956     }
  9956     }
  9957     if (shape == @symbol(leftRightArrow)) {
  9957     if (shape == @symbol(leftRightArrow)) {
  9958         RETURN ( __MKSMALLINT( (INT)IDC_SIZEWE));
  9958 	RETURN ( __MKSMALLINT( (INT)IDC_SIZEWE));
  9959     }
  9959     }
  9960     if (shape == @symbol(text)) {
  9960     if (shape == @symbol(text)) {
  9961         RETURN ( __MKSMALLINT( (INT)IDC_IBEAM));
  9961 	RETURN ( __MKSMALLINT( (INT)IDC_IBEAM));
  9962     }
  9962     }
  9963     if (shape == @symbol(wait)) {
  9963     if (shape == @symbol(wait)) {
  9964         RETURN ( __MKSMALLINT( (INT)IDC_WAIT));
  9964 	RETURN ( __MKSMALLINT( (INT)IDC_WAIT));
  9965     }
  9965     }
  9966     if (shape == @symbol(crossHair)) {
  9966     if (shape == @symbol(crossHair)) {
  9967         RETURN ( __MKSMALLINT( (INT)IDC_CROSS));
  9967 	RETURN ( __MKSMALLINT( (INT)IDC_CROSS));
  9968     }
  9968     }
  9969     if (shape == @symbol(fourWay)) {
  9969     if (shape == @symbol(fourWay)) {
  9970         RETURN ( __MKSMALLINT( (INT)IDC_SIZEALL));
  9970 	RETURN ( __MKSMALLINT( (INT)IDC_SIZEALL));
  9971     }
  9971     }
  9972     if (shape == @symbol(execute)) {
  9972     if (shape == @symbol(execute)) {
  9973         RETURN ( __MKSMALLINT( (INT)IDC_APPSTARTING));
  9973 	RETURN ( __MKSMALLINT( (INT)IDC_APPSTARTING));
  9974     }
  9974     }
  9975     if (shape == @symbol(noDrop)) {
  9975     if (shape == @symbol(noDrop)) {
  9976         RETURN ( __MKSMALLINT( (INT)IDC_NO));
  9976 	RETURN ( __MKSMALLINT( (INT)IDC_NO));
  9977     }
  9977     }
  9978     if (shape == @symbol(stop)) {
  9978     if (shape == @symbol(stop)) {
  9979         RETURN ( __MKSMALLINT( (INT)IDC_NO));
  9979 	RETURN ( __MKSMALLINT( (INT)IDC_NO));
  9980     }
  9980     }
  9981 
  9981 
  9982     if (shape == @symbol(IDC_UPARROW)) {
  9982     if (shape == @symbol(IDC_UPARROW)) {
  9983         RETURN ( __MKSMALLINT( (INT)IDC_UPARROW));
  9983 	RETURN ( __MKSMALLINT( (INT)IDC_UPARROW));
  9984     }
  9984     }
  9985 
  9985 
  9986     if (shape == @symbol(IDC_SIZE)) {
  9986     if (shape == @symbol(IDC_SIZE)) {
  9987         RETURN ( __MKSMALLINT( (INT)IDC_SIZE));
  9987 	RETURN ( __MKSMALLINT( (INT)IDC_SIZE));
  9988     }
  9988     }
  9989     if (shape == @symbol(IDC_SIZENWSE)) {
  9989     if (shape == @symbol(IDC_SIZENWSE)) {
  9990         RETURN ( __MKSMALLINT( (INT)IDC_SIZENWSE));
  9990 	RETURN ( __MKSMALLINT( (INT)IDC_SIZENWSE));
  9991     }
  9991     }
  9992     if (shape == @symbol(IDC_SIZENESW)) {
  9992     if (shape == @symbol(IDC_SIZENESW)) {
  9993         RETURN ( __MKSMALLINT( (INT)IDC_SIZENESW));
  9993 	RETURN ( __MKSMALLINT( (INT)IDC_SIZENESW));
  9994     }
  9994     }
  9995     if (shape == @symbol(IDC_NO)) {
  9995     if (shape == @symbol(IDC_NO)) {
  9996         RETURN ( __MKSMALLINT( (INT)IDC_NO));
  9996 	RETURN ( __MKSMALLINT( (INT)IDC_NO));
  9997     }
  9997     }
  9998 #ifdef IDC_HELP
  9998 #ifdef IDC_HELP
  9999     if (shape == @symbol(IDC_HELP)) {
  9999     if (shape == @symbol(IDC_HELP)) {
 10000         RETURN ( __MKSMALLINT( (INT)IDC_HELP));
 10000 	RETURN ( __MKSMALLINT( (INT)IDC_HELP));
 10001     }
 10001     }
 10002 #endif
 10002 #endif
 10003 %}.
 10003 %}.
 10004 "/    ('WINWORKSTATION: invalid cursorShape:' , shape printString) infoPrintNL.
 10004 "/    ('WINWORKSTATION: invalid cursorShape:' , shape printString) infoPrintNL.
 10005     ^  nil
 10005     ^  nil
 10009 
 10009 
 10010 dragFinish:dropHandle
 10010 dragFinish:dropHandle
 10011     "free Win32 data (and remove the drop-file)"
 10011     "free Win32 data (and remove the drop-file)"
 10012 %{
 10012 %{
 10013     if (__isExternalAddress(dropHandle)) {
 10013     if (__isExternalAddress(dropHandle)) {
 10014         HDROP hDrop = (HDROP)__externalAddressVal(dropHandle);
 10014 	HDROP hDrop = (HDROP)__externalAddressVal(dropHandle);
 10015 
 10015 
 10016         __externalAddressVal(dropHandle) = 0;
 10016 	__externalAddressVal(dropHandle) = 0;
 10017         if (hDrop) {
 10017 	if (hDrop) {
 10018             DragFinish(hDrop);
 10018 	    DragFinish(hDrop);
 10019         }
 10019 	}
 10020     }
 10020     }
 10021 %}
 10021 %}
 10022 ! !
 10022 ! !
 10023 
 10023 
 10024 !WinWorkstation methodsFor:'drawing'!
 10024 !WinWorkstation methodsFor:'drawing'!
 10025 
 10025 
 10026 copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId
 10026 copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId
 10027                 width:w height:h
 10027 		width:w height:h
 10028     "do a bit-blt; copy bits from the rectangle defined by
 10028     "do a bit-blt; copy bits from the rectangle defined by
 10029      srcX/srcY and w/h from the sourceId drawable to the rectangle
 10029      srcX/srcY and w/h from the sourceId drawable to the rectangle
 10030      below dstX/dstY in the destId drawable. Trigger an error if any
 10030      below dstX/dstY in the destId drawable. Trigger an error if any
 10031      argument is not integer."
 10031      argument is not integer."
 10032 
 10032 
 10039     HWND    dstGcHWIN;
 10039     HWND    dstGcHWIN;
 10040     HBITMAP dstGcHBITMAP;
 10040     HBITMAP dstGcHBITMAP;
 10041 
 10041 
 10042     if (! __isExternalAddress(srcGCId)
 10042     if (! __isExternalAddress(srcGCId)
 10043      || ! __isExternalAddress(dstGCId)) {
 10043      || ! __isExternalAddress(dstGCId)) {
 10044         goto fail;
 10044 	goto fail;
 10045     }
 10045     }
 10046     srcGcData = _GCDATA(srcGCId);
 10046     srcGcData = _GCDATA(srcGCId);
 10047     dstGcData = _GCDATA(dstGCId);
 10047     dstGcData = _GCDATA(dstGCId);
 10048 
 10048 
 10049     if (__bothSmallInteger(w, h)
 10049     if (__bothSmallInteger(w, h)
 10050      && __bothSmallInteger(srcX, srcY)
 10050      && __bothSmallInteger(srcX, srcY)
 10051      && __bothSmallInteger(dstX, dstY)
 10051      && __bothSmallInteger(dstX, dstY)
 10052      && srcGcData
 10052      && srcGcData
 10053      && dstGcData) {
 10053      && dstGcData) {
 10054         int fun = BITBLT_COPY;
 10054 	int fun = BITBLT_COPY;
 10055         int src_fg, src_bg, dst_fg, dst_bg;
 10055 	int src_fg, src_bg, dst_fg, dst_bg;
 10056 
 10056 
 10057         fun = dstGcData->bitbltrop2;
 10057 	fun = dstGcData->bitbltrop2;
 10058 #if 0
 10058 #if 0
 10059         switch (fun) {
 10059 	switch (fun) {
 10060           case BITBLT_COPY:
 10060 	  case BITBLT_COPY:
 10061             console_printf("BITBLT_COPY\n");
 10061 	    console_printf("BITBLT_COPY\n");
 10062             break;
 10062 	    break;
 10063           case BITBLT_COPYINVERTED:
 10063 	  case BITBLT_COPYINVERTED:
 10064             console_printf("BITBLT_COPYINVERTED\n");
 10064 	    console_printf("BITBLT_COPYINVERTED\n");
 10065             break;
 10065 	    break;
 10066           case BITBLT_XOR:
 10066 	  case BITBLT_XOR:
 10067             console_printf("BITBLT_XOR\n");
 10067 	    console_printf("BITBLT_XOR\n");
 10068             break;
 10068 	    break;
 10069           case BITBLT_AND:
 10069 	  case BITBLT_AND:
 10070             console_printf("BITBLT_AND\n");
 10070 	    console_printf("BITBLT_AND\n");
 10071             break;
 10071 	    break;
 10072           case BITBLT_OR:
 10072 	  case BITBLT_OR:
 10073             console_printf("BITBLT_OR\n");
 10073 	    console_printf("BITBLT_OR\n");
 10074             break;
 10074 	    break;
 10075         }
 10075 	}
 10076 #endif
 10076 #endif
 10077 
 10077 
 10078         /*
 10078 	/*
 10079          * a scroll operation ?
 10079 	 * a scroll operation ?
 10080          */
 10080 	 */
 10081         if (srcGcData->hWnd
 10081 	if (srcGcData->hWnd
 10082          && ((srcGcData->hWnd == dstGcData->hWnd)
 10082 	 && ((srcGcData->hWnd == dstGcData->hWnd)
 10083          && (fun == BITBLT_COPY))) {
 10083 	 && (fun == BITBLT_COPY))) {
 10084             RECT rec, updRect;
 10084 	    RECT rec, updRect;
 10085             RECT invRec;
 10085 	    RECT invRec;
 10086             HRGN updRgn = 0, dstRgn = 0, nUpdRgn = 0;
 10086 	    HRGN updRgn = 0, dstRgn = 0, nUpdRgn = 0;
 10087             int _srcX = __intVal(srcX);
 10087 	    int _srcX = __intVal(srcX);
 10088             int _srcY = __intVal(srcY);
 10088 	    int _srcY = __intVal(srcY);
 10089             int _dstX = __intVal(dstX);
 10089 	    int _dstX = __intVal(dstX);
 10090             int _dstY = __intVal(dstY);
 10090 	    int _dstY = __intVal(dstY);
 10091             int _w = __intVal(w);
 10091 	    int _w = __intVal(w);
 10092             int _h = __intVal(h);
 10092 	    int _h = __intVal(h);
 10093             int noExpose = 0;
 10093 	    int noExpose = 0;
 10094             int _deltaX, _deltaY;
 10094 	    int _deltaX, _deltaY;
 10095 
 10095 
 10096 #ifdef CACHE_LAST_DC
 10096 #ifdef CACHE_LAST_DC
 10097             if (lastGcData) {
 10097 	    if (lastGcData) {
 10098                 _releaseDC(lastGcData);
 10098 		_releaseDC(lastGcData);
 10099             }
 10099 	    }
 10100 #endif
 10100 #endif
 10101 
 10101 
 10102             rec.left = _srcX;
 10102 	    rec.left = _srcX;
 10103             rec.top  = _srcY;
 10103 	    rec.top  = _srcY;
 10104             rec.right = rec.left + _w;
 10104 	    rec.right = rec.left + _w;
 10105             rec.bottom = rec.top + _h;
 10105 	    rec.bottom = rec.top + _h;
 10106 
 10106 
 10107             _deltaX = _dstX - _srcX;
 10107 	    _deltaX = _dstX - _srcX;
 10108             _deltaY = _dstY - _srcY;
 10108 	    _deltaY = _dstY - _srcY;
 10109 
 10109 
 10110             DDPRINTF(("dst and src is HWND %x fun == BITBLT_COPY --> scroll %d/%d\n",
 10110 	    DDPRINTF(("dst and src is HWND %x fun == BITBLT_COPY --> scroll %d/%d\n",
 10111                     srcGcData->hWnd,
 10111 		    srcGcData->hWnd,
 10112                     _deltaX,
 10112 		    _deltaX,
 10113                     _deltaY));
 10113 		    _deltaY));
 10114 
 10114 
 10115             if ((_deltaX == 0) && (_deltaY == 0)) {
 10115 	    if ((_deltaX == 0) && (_deltaY == 0)) {
 10116                 noExpose = 1;
 10116 		noExpose = 1;
 10117             } else {
 10117 	    } else {
 10118                 updRgn = CreateRectRgn(0, 0, 0, 0);
 10118 		updRgn = CreateRectRgn(0, 0, 0, 0);
 10119                 ScrollWindowEx(srcGcData->hWnd,
 10119 		ScrollWindowEx(srcGcData->hWnd,
 10120                             _deltaX,
 10120 			    _deltaX,
 10121                             _deltaY,
 10121 			    _deltaY,
 10122                             &rec,            /* area to scroll */
 10122 			    &rec,            /* area to scroll */
 10123                             0,               /* clip region */
 10123 			    0,               /* clip region */
 10124                             updRgn,
 10124 			    updRgn,
 10125                             NULL, /* &invRec, */
 10125 			    NULL, /* &invRec, */
 10126                             0 /* SW_ERASE | SW_INVALIDATE */);
 10126 			    0 /* SW_ERASE | SW_INVALIDATE */);
 10127 
 10127 
 10128                 /*
 10128 		/*
 10129                  * we are not interested in the source-area;
 10129 		 * we are not interested in the source-area;
 10130                  * only care for exposed areas in the dst area.
 10130 		 * only care for exposed areas in the dst area.
 10131                  */
 10131 		 */
 10132                 dstRgn = CreateRectRgn(_dstX, _dstY, _dstX+_w, _dstY+_h);
 10132 		dstRgn = CreateRectRgn(_dstX, _dstY, _dstX+_w, _dstY+_h);
 10133                 nUpdRgn = CreateRectRgn(0, 0, 0, 0);
 10133 		nUpdRgn = CreateRectRgn(0, 0, 0, 0);
 10134                 switch (CombineRgn(nUpdRgn, updRgn, dstRgn, RGN_AND)) {
 10134 		switch (CombineRgn(nUpdRgn, updRgn, dstRgn, RGN_AND)) {
 10135                     case ERROR:
 10135 		    case ERROR:
 10136                         _DeleteObject(nUpdRgn, __LINE__);
 10136 			_DeleteObject(nUpdRgn, __LINE__);
 10137                         nUpdRgn = updRgn;
 10137 			nUpdRgn = updRgn;
 10138                         noExpose = 1;
 10138 			noExpose = 1;
 10139                         break;
 10139 			break;
 10140                     case NULLREGION:
 10140 		    case NULLREGION:
 10141                         noExpose = 1;
 10141 			noExpose = 1;
 10142                         break;
 10142 			break;
 10143                     default:
 10143 		    default:
 10144                         if (__generateExposes(srcGcData->hWnd, nUpdRgn, __WM_GEXPOSE, 1) <= 0) {
 10144 			if (__generateExposes(srcGcData->hWnd, nUpdRgn, __WM_GEXPOSE, 1) <= 0) {
 10145                             noExpose = 1;
 10145 			    noExpose = 1;
 10146                         }
 10146 			}
 10147                         break;
 10147 			break;
 10148                 }
 10148 		}
 10149             }
 10149 	    }
 10150             if (noExpose) {
 10150 	    if (noExpose) {
 10151                 /*
 10151 		/*
 10152                  * no exposes generated - must send a NOEXPOSE
 10152 		 * no exposes generated - must send a NOEXPOSE
 10153                  */
 10153 		 */
 10154                 enqEvent(ExposureMask, srcGcData->hWnd, __WM_NOGEXPOSE, 0, 0, 0, 0, 0, EV_NOTIME);
 10154 		enqEvent(ExposureMask, srcGcData->hWnd, __WM_NOGEXPOSE, 0, 0, 0, 0, 0, EV_NOTIME);
 10155             }
 10155 	    }
 10156 
 10156 
 10157             if (dstRgn) {
 10157 	    if (dstRgn) {
 10158                 _DeleteObject(dstRgn, __LINE__);
 10158 		_DeleteObject(dstRgn, __LINE__);
 10159             }
 10159 	    }
 10160             if (nUpdRgn && (nUpdRgn != updRgn)) {
 10160 	    if (nUpdRgn && (nUpdRgn != updRgn)) {
 10161                 _DeleteObject(nUpdRgn, __LINE__);
 10161 		_DeleteObject(nUpdRgn, __LINE__);
 10162             }
 10162 	    }
 10163             if (updRgn) {
 10163 	    if (updRgn) {
 10164                 _DeleteObject(updRgn, __LINE__);
 10164 		_DeleteObject(updRgn, __LINE__);
 10165             }
 10165 	    }
 10166             RETURN ( self );
 10166 	    RETURN ( self );
 10167         }
 10167 	}
 10168 
 10168 
 10169         fun = dstGcData->bitbltrop2;
 10169 	fun = dstGcData->bitbltrop2;
 10170 
 10170 
 10171         if (0 /* fun == BITBLT_COPY */) {
 10171 	if (0 /* fun == BITBLT_COPY */) {
 10172             src_fg = dst_fg = 0xFFFFFF;
 10172 	    src_fg = dst_fg = 0xFFFFFF;
 10173             src_bg = dst_bg = 0x000000;
 10173 	    src_bg = dst_bg = 0x000000;
 10174         } else {
 10174 	} else {
 10175             src_fg = srcGcData->fgColor;
 10175 	    src_fg = srcGcData->fgColor;
 10176             src_bg = srcGcData->bgColor;
 10176 	    src_bg = srcGcData->bgColor;
 10177             dst_fg = dstGcData->fgColor;
 10177 	    dst_fg = dstGcData->fgColor;
 10178             dst_bg = dstGcData->bgColor;
 10178 	    dst_bg = dstGcData->bgColor;
 10179         }
 10179 	}
 10180 
 10180 
 10181         /*
 10181 	/*
 10182          * a simple copy (like scroll, but in a bitmap) ?
 10182 	 * a simple copy (like scroll, but in a bitmap) ?
 10183          */
 10183 	 */
 10184         if ((srcGcData == dstGcData)
 10184 	if ((srcGcData == dstGcData)
 10185          && (fun == BITBLT_COPY)) {
 10185 	 && (fun == BITBLT_COPY)) {
 10186             RECT rec, uprec;
 10186 	    RECT rec, uprec;
 10187             int _srcX, _srcY;
 10187 	    int _srcX, _srcY;
 10188 
 10188 
 10189             rec.left = _srcX = __intVal(srcX);
 10189 	    rec.left = _srcX = __intVal(srcX);
 10190             rec.top = _srcY = __intVal(srcY);
 10190 	    rec.top = _srcY = __intVal(srcY);
 10191             rec.right = rec.left + __intVal(w);
 10191 	    rec.right = rec.left + __intVal(w);
 10192             rec.bottom = rec.top + __intVal(h);
 10192 	    rec.bottom = rec.top + __intVal(h);
 10193             srcDC = _getDC(srcGcData);
 10193 	    srcDC = _getDC(srcGcData);
 10194             SetBkColor(srcDC, src_fg);
 10194 	    SetBkColor(srcDC, src_fg);
 10195             SetTextColor(srcDC, src_bg);
 10195 	    SetTextColor(srcDC, src_bg);
 10196 
 10196 
 10197             DDPRINTF(("dst and src is DC %x fun == BITBLT_COPY  --> scrolling %d %d\n",srcDC,__intVal(dstX) - __intVal(srcX),__intVal(dstY) - __intVal(srcY)));
 10197 	    DDPRINTF(("dst and src is DC %x fun == BITBLT_COPY  --> scrolling %d %d\n",srcDC,__intVal(dstX) - __intVal(srcX),__intVal(dstY) - __intVal(srcY)));
 10198             ScrollDC(srcDC, __intVal(dstX)-_srcX,
 10198 	    ScrollDC(srcDC, __intVal(dstX)-_srcX,
 10199                             __intVal(dstY)-_srcY,
 10199 			    __intVal(dstY)-_srcY,
 10200                             &rec, 0, 0, &uprec);
 10200 			    &rec, 0, 0, &uprec);
 10201 
 10201 
 10202             SetBkColor(srcDC, srcGcData->bgColor);
 10202 	    SetBkColor(srcDC, srcGcData->bgColor);
 10203             SetTextColor(srcDC, srcGcData->fgColor);
 10203 	    SetTextColor(srcDC, srcGcData->fgColor);
 10204 #ifndef CACHE_LAST_DC
 10204 #ifndef CACHE_LAST_DC
 10205             _releaseDC(srcGcData);
 10205 	    _releaseDC(srcGcData);
 10206 #endif
 10206 #endif
 10207             RETURN ( self );
 10207 	    RETURN ( self );
 10208         }
 10208 	}
 10209 
 10209 
 10210 #ifdef xxCACHE_LAST_DC
 10210 #ifdef xxCACHE_LAST_DC
 10211 /* mhmh - this should not be needed */
 10211 /* mhmh - this should not be needed */
 10212         if (lastGcData) {
 10212 	if (lastGcData) {
 10213             _releaseDC(lastGcData);
 10213 	    _releaseDC(lastGcData);
 10214         }
 10214 	}
 10215 #endif
 10215 #endif
 10216 
 10216 
 10217         if (dstGcData == srcGcData) {
 10217 	if (dstGcData == srcGcData) {
 10218             srcDC = dstDC = _getDC(dstGcData);
 10218 	    srcDC = dstDC = _getDC(dstGcData);
 10219         } else {
 10219 	} else {
 10220             srcDC = _getDC(srcGcData);
 10220 	    srcDC = _getDC(srcGcData);
 10221 
 10221 
 10222             /*
 10222 	    /*
 10223              * kludge - pretent nothing is cached for a moment,
 10223 	     * kludge - pretent nothing is cached for a moment,
 10224              * to avoid release in getDC below ...
 10224 	     * to avoid release in getDC below ...
 10225              */
 10225 	     */
 10226 #ifdef CACHE_LAST_DC
 10226 #ifdef CACHE_LAST_DC
 10227             dstGcOwnerThreadID = lastGcOwnerThreadID;
 10227 	    dstGcOwnerThreadID = lastGcOwnerThreadID;
 10228             dstGcHWIN = lastGcHWIN;
 10228 	    dstGcHWIN = lastGcHWIN;
 10229             dstGcHBITMAP = lastGcHBITMAP;
 10229 	    dstGcHBITMAP = lastGcHBITMAP;
 10230             lastGcData = 0;
 10230 	    lastGcData = 0;
 10231 #endif
 10231 #endif
 10232 
 10232 
 10233             dstDC = _getDC(dstGcData);
 10233 	    dstDC = _getDC(dstGcData);
 10234             SetBkColor(dstDC, dst_fg);
 10234 	    SetBkColor(dstDC, dst_fg);
 10235             SetTextColor(dstDC, dst_bg);
 10235 	    SetTextColor(dstDC, dst_bg);
 10236         }
 10236 	}
 10237 
 10237 
 10238         SetBkColor(srcDC, src_fg);
 10238 	SetBkColor(srcDC, src_fg);
 10239         SetTextColor(srcDC, src_bg);
 10239 	SetTextColor(srcDC, src_bg);
 10240 
 10240 
 10241         CPRINTF(("bitblt src f:%x b:%x",GetTextColor(srcDC),GetBkColor(srcDC)));
 10241 	CPRINTF(("bitblt src f:%x b:%x",GetTextColor(srcDC),GetBkColor(srcDC)));
 10242         CPRINTF(("dst f:%x b:%x\n",GetTextColor(dstDC),GetBkColor(dstDC)));
 10242 	CPRINTF(("dst f:%x b:%x\n",GetTextColor(dstDC),GetBkColor(dstDC)));
 10243         if (BitBlt(dstDC,
 10243 	if (BitBlt(dstDC,
 10244              __intVal(dstX), __intVal(dstY),
 10244 	     __intVal(dstX), __intVal(dstY),
 10245              __intVal(w), __intVal(h),
 10245 	     __intVal(w), __intVal(h),
 10246              srcDC,
 10246 	     srcDC,
 10247              __intVal(srcX), __intVal(srcY),
 10247 	     __intVal(srcX), __intVal(srcY),
 10248              fun)
 10248 	     fun)
 10249            == 0
 10249 	   == 0
 10250           ) {
 10250 	  ) {
 10251             console_fprintf(stderr, "WinWorkstation [info]: ERROR in BitBlt: %d\n", GetLastError());
 10251 	    console_fprintf(stderr, "WinWorkstation [info]: ERROR in BitBlt: %d\n", GetLastError());
 10252         }
 10252 	}
 10253 
 10253 
 10254         if (dstGcData != srcGcData) {
 10254 	if (dstGcData != srcGcData) {
 10255             SetBkColor(dstDC, dstGcData->bgColor);
 10255 	    SetBkColor(dstDC, dstGcData->bgColor);
 10256             SetTextColor(dstDC, dstGcData->fgColor);
 10256 	    SetTextColor(dstDC, dstGcData->fgColor);
 10257         }
 10257 	}
 10258         SetBkColor(srcDC, srcGcData->bgColor);
 10258 	SetBkColor(srcDC, srcGcData->bgColor);
 10259         SetTextColor(srcDC, srcGcData->fgColor);
 10259 	SetTextColor(srcDC, srcGcData->fgColor);
 10260 
 10260 
 10261         if (srcGcData != dstGcData) {
 10261 	if (srcGcData != dstGcData) {
 10262             _releaseDC(srcGcData);
 10262 	    _releaseDC(srcGcData);
 10263         }
 10263 	}
 10264 
 10264 
 10265 #ifdef CACHE_LAST_DC
 10265 #ifdef CACHE_LAST_DC
 10266         /*
 10266 	/*
 10267          * kludge again - restore last-DC cache
 10267 	 * kludge again - restore last-DC cache
 10268          */
 10268 	 */
 10269         lastGcData = dstGcData;
 10269 	lastGcData = dstGcData;
 10270         lastGcOwnerThreadID = dstGcOwnerThreadID;
 10270 	lastGcOwnerThreadID = dstGcOwnerThreadID;
 10271         lastGcHWIN = dstGcHWIN;
 10271 	lastGcHWIN = dstGcHWIN;
 10272         lastGcHBITMAP = dstGcHBITMAP;
 10272 	lastGcHBITMAP = dstGcHBITMAP;
 10273 #else
 10273 #else
 10274         _releaseDC(dstGcData);
 10274 	_releaseDC(dstGcData);
 10275 #endif
 10275 #endif
 10276         RETURN ( self );
 10276 	RETURN ( self );
 10277     }
 10277     }
 10278 
 10278 
 10279  fail: ;
 10279  fail: ;
 10280 %}.
 10280 %}.
 10281     self primitiveFailed.
 10281     self primitiveFailed.
 10282     ^ nil
 10282     ^ nil
 10283 !
 10283 !
 10284 
 10284 
 10285 copyPlaneFromId:sourceId x:srcX y:srcY gc:srcDCId to:destId x:dstX y:dstY gc:dstDCId
 10285 copyPlaneFromId:sourceId x:srcX y:srcY gc:srcDCId to:destId x:dstX y:dstY gc:dstDCId
 10286                 width:w height:h
 10286 		width:w height:h
 10287     "do a bit-blt, but only copy the low-bit plane;
 10287     "do a bit-blt, but only copy the low-bit plane;
 10288      copy bits from the rectangle defined by
 10288      copy bits from the rectangle defined by
 10289      srcX/srcY and w/h from the sourceId drawable to the rectangle
 10289      srcX/srcY and w/h from the sourceId drawable to the rectangle
 10290      below dstX/dstY in the destId drawable. Trigger an error if any
 10290      below dstX/dstY in the destId drawable. Trigger an error if any
 10291      argument is not integer."
 10291      argument is not integer."
 10292 
 10292 
 10293     ^ self
 10293     ^ self
 10294         copyFromId:sourceId
 10294 	copyFromId:sourceId
 10295                  x:srcX y:srcY gc:srcDCId
 10295 		 x:srcX y:srcY gc:srcDCId
 10296                 to:destId x:dstX y:dstY gc:dstDCId
 10296 		to:destId x:dstX y:dstY gc:dstDCId
 10297              width:w height:h
 10297 	     width:w height:h
 10298 !
 10298 !
 10299 
 10299 
 10300 displayArcX:x y:y width:width height:height from:startAngle angle:angle in:ignoredDrawableId with:aGCId
 10300 displayArcX:x y:y width:width height:height from:startAngle angle:angle in:ignoredDrawableId with:aGCId
 10301     "draw an arc. If any of x,y, w or h is not an integer, an error is triggered.
 10301     "draw an arc. If any of x,y, w or h is not an integer, an error is triggered.
 10302      The angles may be floats or integer - they are given in degrees."
 10302      The angles may be floats or integer - they are given in degrees."
 10305     int __x, __y, w, h;
 10305     int __x, __y, w, h;
 10306     float angle1, angle2;
 10306     float angle1, angle2;
 10307     double f;
 10307     double f;
 10308 
 10308 
 10309     if (__isSmallInteger(startAngle))
 10309     if (__isSmallInteger(startAngle))
 10310         angle1 = (float)(__intVal(startAngle));
 10310 	angle1 = (float)(__intVal(startAngle));
 10311     else if (__isFloat(startAngle)) {
 10311     else if (__isFloat(startAngle)) {
 10312         angle1 = (float) __floatVal(startAngle);
 10312 	angle1 = (float) __floatVal(startAngle);
 10313     } else if (__isShortFloat(startAngle)) {
 10313     } else if (__isShortFloat(startAngle)) {
 10314         angle1 = __shortFloatVal(startAngle);
 10314 	angle1 = __shortFloatVal(startAngle);
 10315     } else goto bad;
 10315     } else goto bad;
 10316 
 10316 
 10317     if (__isSmallInteger(angle))
 10317     if (__isSmallInteger(angle))
 10318         angle2 = (float)(__intVal(angle));
 10318 	angle2 = (float)(__intVal(angle));
 10319     else if (__isFloat(angle)) {
 10319     else if (__isFloat(angle)) {
 10320         angle2 = (float) __floatVal(angle);
 10320 	angle2 = (float) __floatVal(angle);
 10321     } else if (__isShortFloat(angle)) {
 10321     } else if (__isShortFloat(angle)) {
 10322         angle2 = __shortFloatVal(angle);
 10322 	angle2 = __shortFloatVal(angle);
 10323     } else goto bad;
 10323     } else goto bad;
 10324 
 10324 
 10325     if (angle2 <= 0) {
 10325     if (angle2 <= 0) {
 10326         RETURN (self);
 10326 	RETURN (self);
 10327     }
 10327     }
 10328 
 10328 
 10329     if (__isExternalAddress(aGCId)
 10329     if (__isExternalAddress(aGCId)
 10330      && __bothSmallInteger(x, y)
 10330      && __bothSmallInteger(x, y)
 10331      && __bothSmallInteger(width, height))
 10331      && __bothSmallInteger(width, height))
 10332      {
 10332      {
 10333         struct gcData *gcData = _GCDATA(aGCId);
 10333 	struct gcData *gcData = _GCDATA(aGCId);
 10334         HDC hDC;
 10334 	HDC hDC;
 10335         POINT p;
 10335 	POINT p;
 10336 
 10336 
 10337         w = __intVal(width);
 10337 	w = __intVal(width);
 10338         h = __intVal(height);
 10338 	h = __intVal(height);
 10339         __x = __intVal(x);
 10339 	__x = __intVal(x);
 10340         __y = __intVal(y);
 10340 	__y = __intVal(y);
 10341 
 10341 
 10342         hDC = _getDC(gcData);
 10342 	hDC = _getDC(gcData);
 10343 
 10343 
 10344         if (! GcDataGetPen(hDC, gcData)) {
 10344 	if (! GcDataGetPen(hDC, gcData)) {
 10345             DPRINTF(("displayArc: no pen\n"));
 10345 	    DPRINTF(("displayArc: no pen\n"));
 10346         } else {
 10346 	} else {
 10347             double xB, yB, xE, yE, xR, yR;
 10347 	    double xB, yB, xE, yE, xR, yR;
 10348 
 10348 
 10349             xR = w / 2;
 10349 	    xR = w / 2;
 10350             yR = h / 2;
 10350 	    yR = h / 2;
 10351             if (angle2 - angle1 >= 360) {
 10351 	    if (angle2 - angle1 >= 360) {
 10352                 xB = xE = __x + xR + 0.5;
 10352 		xB = xE = __x + xR + 0.5;
 10353                 yB = yE = __y /*+ yR + 0.5*/;
 10353 		yB = yE = __y /*+ yR + 0.5*/;
 10354             } else {
 10354 	    } else {
 10355                 double sin(), cos();
 10355 		double sin(), cos();
 10356                 float rad1, rad2;
 10356 		float rad1, rad2;
 10357 
 10357 
 10358                 if (angle1 <= 180)
 10358 		if (angle1 <= 180)
 10359                   angle1 = 180 - angle1;
 10359 		  angle1 = 180 - angle1;
 10360                 else
 10360 		else
 10361                   angle1 = 360 + 180 - angle1;
 10361 		  angle1 = 360 + 180 - angle1;
 10362                 angle2 = angle1 - angle2;
 10362 		angle2 = angle1 - angle2;
 10363                 /* sigh - compute the intersections ... */
 10363 		/* sigh - compute the intersections ... */
 10364                 rad1 = (angle1 * 3.14159265359) / 180.0;
 10364 		rad1 = (angle1 * 3.14159265359) / 180.0;
 10365                 rad2 = (angle2 * 3.14159265359) / 180.0;
 10365 		rad2 = (angle2 * 3.14159265359) / 180.0;
 10366                 xB = cos(rad1) * xR;
 10366 		xB = cos(rad1) * xR;
 10367                 yB = sin(rad1) * yR;
 10367 		yB = sin(rad1) * yR;
 10368                 xE = cos(rad2) * xR;
 10368 		xE = cos(rad2) * xR;
 10369                 yE = sin(rad2) * yR;
 10369 		yE = sin(rad2) * yR;
 10370                 xB = __x + xR - xB + 0.5;
 10370 		xB = __x + xR - xB + 0.5;
 10371                 yB = __y + yR - yB + 0.5;
 10371 		yB = __y + yR - yB + 0.5;
 10372                 xE = __x + xR - xE + 0.5;
 10372 		xE = __x + xR - xE + 0.5;
 10373                 yE = __y + yR - yE + 0.5;
 10373 		yE = __y + yR - yE + 0.5;
 10374             }
 10374 	    }
 10375             DPRINTF(("Arc x=%d y=%d w=%d h=%d xB=%d xE=%d yB=%d yE=%d a1=%f a2=%f\n",__x,__y,w,h,(int)xB,(int)xE,(int)yB,(int)yE,angle1,angle2));
 10375 	    DPRINTF(("Arc x=%d y=%d w=%d h=%d xB=%d xE=%d yB=%d yE=%d a1=%f a2=%f\n",__x,__y,w,h,(int)xB,(int)xE,(int)yB,(int)yE,angle1,angle2));
 10376             Arc(hDC,
 10376 	    Arc(hDC,
 10377                 __x, __y,
 10377 		__x, __y,
 10378                 __x + w, __y + h,
 10378 		__x + w, __y + h,
 10379                 (int)xB, (int)yB,
 10379 		(int)xB, (int)yB,
 10380                 (int)xE, (int)yE);
 10380 		(int)xE, (int)yE);
 10381 
 10381 
 10382             GcDataReleasePen(hDC, gcData);
 10382 	    GcDataReleasePen(hDC, gcData);
 10383         }
 10383 	}
 10384 #ifndef CACHE_LAST_DC
 10384 #ifndef CACHE_LAST_DC
 10385         _releaseDC(gcData);
 10385 	_releaseDC(gcData);
 10386 #endif
 10386 #endif
 10387         RETURN ( self );
 10387 	RETURN ( self );
 10388     }
 10388     }
 10389     bad: ;
 10389     bad: ;
 10390 %}.
 10390 %}.
 10391     self primitiveFailed
 10391     self primitiveFailed
 10392 !
 10392 !
 10396 
 10396 
 10397 %{  /* NOCONTEXT */
 10397 %{  /* NOCONTEXT */
 10398     if (__isExternalAddress(aGCId)
 10398     if (__isExternalAddress(aGCId)
 10399      && __bothSmallInteger(x0, y0)
 10399      && __bothSmallInteger(x0, y0)
 10400      && __bothSmallInteger(x1, y1)) {
 10400      && __bothSmallInteger(x1, y1)) {
 10401         struct gcData *gcData = _GCDATA(aGCId);
 10401 	struct gcData *gcData = _GCDATA(aGCId);
 10402         int __x1 = __intVal(x1), __y1 = __intVal(y1);
 10402 	int __x1 = __intVal(x1), __y1 = __intVal(y1);
 10403         HDC hDC = _getDC(gcData);
 10403 	HDC hDC = _getDC(gcData);
 10404 
 10404 
 10405 /*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
 10405 /*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
 10406                     __intVal(x0), __intVal(y0),
 10406 		    __intVal(x0), __intVal(y0),
 10407                     __x1, __y1));
 10407 		    __x1, __y1));
 10408 */
 10408 */
 10409         if (! GcDataGetPen(hDC, gcData)) {
 10409 	if (! GcDataGetPen(hDC, gcData)) {
 10410             DPRINTF(("displayLine: no pen\n"));
 10410 	    DPRINTF(("displayLine: no pen\n"));
 10411         } else {
 10411 	} else {
 10412             MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
 10412 	    MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
 10413 
 10413 
 10414             LineTo(hDC, __x1, __y1);
 10414 	    LineTo(hDC, __x1, __y1);
 10415 
 10415 
 10416             /*
 10416 	    /*
 10417              * end-point ...
 10417 	     * end-point ...
 10418              */
 10418 	     */
 10419             LineTo(hDC, __x1+1, __y1);
 10419 	    LineTo(hDC, __x1+1, __y1);
 10420 
 10420 
 10421             GcDataReleasePen(hDC, gcData);
 10421 	    GcDataReleasePen(hDC, gcData);
 10422         }
 10422 	}
 10423 #ifndef CACHE_LAST_DC
 10423 #ifndef CACHE_LAST_DC
 10424         _releaseDC(gcData);
 10424 	_releaseDC(gcData);
 10425 #endif
 10425 #endif
 10426         RETURN ( self );
 10426 	RETURN ( self );
 10427     }
 10427     }
 10428 %}
 10428 %}
 10429 !
 10429 !
 10430 
 10430 
 10431 displayPointX:px y:py in:ignoredDrawableId with:aGCId
 10431 displayPointX:px y:py in:ignoredDrawableId with:aGCId
 10432     "draw a point. If x/y are not integers, an error is triggered."
 10432     "draw a point. If x/y are not integers, an error is triggered."
 10433 
 10433 
 10434 %{  /* NOCONTEXT */
 10434 %{  /* NOCONTEXT */
 10435     if (__isExternalAddress(aGCId)
 10435     if (__isExternalAddress(aGCId)
 10436      && __bothSmallInteger(px, py)) {
 10436      && __bothSmallInteger(px, py)) {
 10437         struct gcData *gcData = _GCDATA(aGCId);
 10437 	struct gcData *gcData = _GCDATA(aGCId);
 10438         HDC hDC;
 10438 	HDC hDC;
 10439         POINT p;
 10439 	POINT p;
 10440         int __x = __intVal(px), __y = __intVal(py);
 10440 	int __x = __intVal(px), __y = __intVal(py);
 10441 
 10441 
 10442 #ifdef OLD
 10442 #ifdef OLD
 10443         int savedLStyle = gcData->lStyle;
 10443 	int savedLStyle = gcData->lStyle;
 10444         int savedLWidth = gcData->lineWidth;
 10444 	int savedLWidth = gcData->lineWidth;
 10445 
 10445 
 10446         /*
 10446 	/*
 10447          * a point is a point - no matter what lineWidth we have set before
 10447 	 * a point is a point - no matter what lineWidth we have set before
 10448          */
 10448 	 */
 10449         if ((gcData->lStyle != PS_SOLID)
 10449 	if ((gcData->lStyle != PS_SOLID)
 10450          || (gcData->lineWidth > 1)) {
 10450 	 || (gcData->lineWidth > 1)) {
 10451             FLUSH_CACHED_DC(gcData);
 10451 	    FLUSH_CACHED_DC(gcData);
 10452             gcData->lStyle = PS_SOLID;
 10452 	    gcData->lStyle = PS_SOLID;
 10453             gcData->lineWidth = 0;
 10453 	    gcData->lineWidth = 0;
 10454         }
 10454 	}
 10455 
 10455 
 10456         hDC = _getDC(gcData);
 10456 	hDC = _getDC(gcData);
 10457 
 10457 
 10458         if (! GcDataGetPen(hDC,gcData)) {
 10458 	if (! GcDataGetPen(hDC,gcData)) {
 10459             DPRINTF(("displayPoint: no pen\n"));
 10459 	    DPRINTF(("displayPoint: no pen\n"));
 10460         } else {
 10460 	} else {
 10461             MoveToEx(hDC, __x, __y, NULL);
 10461 	    MoveToEx(hDC, __x, __y, NULL);
 10462             /*
 10462 	    /*
 10463              * end-point ...
 10463 	     * end-point ...
 10464              */
 10464 	     */
 10465             LineTo(hDC, __x+1, __y);
 10465 	    LineTo(hDC, __x+1, __y);
 10466 
 10466 
 10467             GcDataReleasePen(hDC, gcData);
 10467 	    GcDataReleasePen(hDC, gcData);
 10468         }
 10468 	}
 10469 
 10469 
 10470 # ifndef CACHE_LAST_DC
 10470 # ifndef CACHE_LAST_DC
 10471         _releaseDC(gcData);
 10471 	_releaseDC(gcData);
 10472 # endif
 10472 # endif
 10473         if ((gcData->lStyle != savedLStyle)
 10473 	if ((gcData->lStyle != savedLStyle)
 10474          || (gcData->lineWidth != savedLWidth)) {
 10474 	 || (gcData->lineWidth != savedLWidth)) {
 10475             FLUSH_CACHED_DC(gcData);
 10475 	    FLUSH_CACHED_DC(gcData);
 10476             gcData->lStyle = savedLStyle;
 10476 	    gcData->lStyle = savedLStyle;
 10477             gcData->lineWidth = savedLWidth;
 10477 	    gcData->lineWidth = savedLWidth;
 10478         }
 10478 	}
 10479 #else /* NEW */
 10479 #else /* NEW */
 10480 
 10480 
 10481         hDC = _getDC(gcData);
 10481 	hDC = _getDC(gcData);
 10482         SetPixelV(hDC, __x, __y, gcData->fgColor);
 10482 	SetPixelV(hDC, __x, __y, gcData->fgColor);
 10483 # ifndef CACHE_LAST_DC
 10483 # ifndef CACHE_LAST_DC
 10484         _releaseDC(gcData);
 10484 	_releaseDC(gcData);
 10485 # endif
 10485 # endif
 10486 
 10486 
 10487 #endif /* NEW */
 10487 #endif /* NEW */
 10488         RETURN ( self );
 10488 	RETURN ( self );
 10489     }
 10489     }
 10490 %}
 10490 %}
 10491 !
 10491 !
 10492 
 10492 
 10493 displayPolygon:aPolygon in:ignoredDrawableId with:aGCId
 10493 displayPolygon:aPolygon in:ignoredDrawableId with:aGCId
 10503     OBJ point, px, py;
 10503     OBJ point, px, py;
 10504     int i, num;
 10504     int i, num;
 10505 
 10505 
 10506     if (__isExternalAddress(aGCId)
 10506     if (__isExternalAddress(aGCId)
 10507      && __isSmallInteger(numberOfPoints)) {
 10507      && __isSmallInteger(numberOfPoints)) {
 10508         struct gcData *gcData = _GCDATA(aGCId);
 10508 	struct gcData *gcData = _GCDATA(aGCId);
 10509         HDC hDC = 0;
 10509 	HDC hDC = 0;
 10510         POINT p;
 10510 	POINT p;
 10511 
 10511 
 10512         num = __intVal(numberOfPoints);
 10512 	num = __intVal(numberOfPoints);
 10513 
 10513 
 10514         for (i=0; i<num; i++) {
 10514 	for (i=0; i<num; i++) {
 10515             point = __AT_(aPolygon, __MKSMALLINT(i+1));
 10515 	    point = __AT_(aPolygon, __MKSMALLINT(i+1));
 10516             if (! __isPoint(point)) goto fail;
 10516 	    if (! __isPoint(point)) goto fail;
 10517             px = _point_X(point);
 10517 	    px = _point_X(point);
 10518             py = _point_Y(point);
 10518 	    py = _point_Y(point);
 10519             if (! __bothSmallInteger(px, py)) {
 10519 	    if (! __bothSmallInteger(px, py)) {
 10520                 goto fail;
 10520 		goto fail;
 10521             }
 10521 	    }
 10522         }
 10522 	}
 10523 
 10523 
 10524         hDC = _getDC(gcData);
 10524 	hDC = _getDC(gcData);
 10525         if (! GcDataGetPen(hDC,gcData)) {
 10525 	if (! GcDataGetPen(hDC,gcData)) {
 10526             DPRINTF(("displayPolygon: no pen\n"));
 10526 	    DPRINTF(("displayPolygon: no pen\n"));
 10527         } else {
 10527 	} else {
 10528             for (i=0; i<num; i++) {
 10528 	    for (i=0; i<num; i++) {
 10529                 point = __AT_(aPolygon, __MKSMALLINT(i+1));
 10529 		point = __AT_(aPolygon, __MKSMALLINT(i+1));
 10530                 px = _point_X(point);
 10530 		px = _point_X(point);
 10531                 py = _point_Y(point);
 10531 		py = _point_Y(point);
 10532                 p.x = __intVal(px);
 10532 		p.x = __intVal(px);
 10533                 p.y = __intVal(py);
 10533 		p.y = __intVal(py);
 10534                 if (i == 0) {
 10534 		if (i == 0) {
 10535                     MoveToEx(hDC, p.x, p.y, NULL);
 10535 		    MoveToEx(hDC, p.x, p.y, NULL);
 10536                 } else {
 10536 		} else {
 10537                     if (i == (num-1)) {
 10537 		    if (i == (num-1)) {
 10538                         PolylineTo(hDC, &p, 1);
 10538 			PolylineTo(hDC, &p, 1);
 10539                     } else {
 10539 		    } else {
 10540                         LineTo(hDC, p.x, p.y);
 10540 			LineTo(hDC, p.x, p.y);
 10541 #ifdef PRE_04_JUN_04
 10541 #ifdef PRE_04_JUN_04
 10542                         /*
 10542 			/*
 10543                          * end-point ...
 10543 			 * end-point ...
 10544                          */
 10544 			 */
 10545                         LineTo(hDC, p.x+1, p.y);
 10545 			LineTo(hDC, p.x+1, p.y);
 10546 #endif
 10546 #endif
 10547                     }
 10547 		    }
 10548                 }
 10548 		}
 10549             }
 10549 	    }
 10550             GcDataReleasePen(hDC, gcData);
 10550 	    GcDataReleasePen(hDC, gcData);
 10551         }
 10551 	}
 10552 
 10552 
 10553 #ifndef CACHE_LAST_DC
 10553 #ifndef CACHE_LAST_DC
 10554         _releaseDC(gcData);
 10554 	_releaseDC(gcData);
 10555 #endif
 10555 #endif
 10556         RETURN ( self );
 10556 	RETURN ( self );
 10557     }
 10557     }
 10558 fail: ;
 10558 fail: ;
 10559 %}
 10559 %}
 10560 !
 10560 !
 10561 
 10561 
 10572     OBJ point, px, py;
 10572     OBJ point, px, py;
 10573     int i, num;
 10573     int i, num;
 10574 
 10574 
 10575     if (__isExternalAddress(aGCId)
 10575     if (__isExternalAddress(aGCId)
 10576      && __isSmallInteger(numberOfPoints)) {
 10576      && __isSmallInteger(numberOfPoints)) {
 10577         struct gcData *gcData = _GCDATA(aGCId);
 10577 	struct gcData *gcData = _GCDATA(aGCId);
 10578         HDC hDC = 0;
 10578 	HDC hDC = 0;
 10579         POINT p;
 10579 	POINT p;
 10580 
 10580 
 10581         num = __intVal(numberOfPoints);
 10581 	num = __intVal(numberOfPoints);
 10582 
 10582 
 10583         for (i=0; i<num; i++) {
 10583 	for (i=0; i<num; i++) {
 10584             point = __AT_(aPolyline, __MKSMALLINT(i+1));
 10584 	    point = __AT_(aPolyline, __MKSMALLINT(i+1));
 10585             if (! __isPoint(point)) goto fail;
 10585 	    if (! __isPoint(point)) goto fail;
 10586             px = _point_X(point);
 10586 	    px = _point_X(point);
 10587             py = _point_Y(point);
 10587 	    py = _point_Y(point);
 10588             if (! __bothSmallInteger(px, py)) {
 10588 	    if (! __bothSmallInteger(px, py)) {
 10589                 goto fail;
 10589 		goto fail;
 10590             }
 10590 	    }
 10591         }
 10591 	}
 10592 
 10592 
 10593         hDC = _getDC(gcData);
 10593 	hDC = _getDC(gcData);
 10594         if (! GcDataGetPen(hDC,gcData)) {
 10594 	if (! GcDataGetPen(hDC,gcData)) {
 10595             DPRINTF(("displayPolygon: no pen\n"));
 10595 	    DPRINTF(("displayPolygon: no pen\n"));
 10596         } else {
 10596 	} else {
 10597             for (i=0; i<num; i++) {
 10597 	    for (i=0; i<num; i++) {
 10598                 point = __AT_(aPolyline, __MKSMALLINT(i+1));
 10598 		point = __AT_(aPolyline, __MKSMALLINT(i+1));
 10599                 px = _point_X(point);
 10599 		px = _point_X(point);
 10600                 py = _point_Y(point);
 10600 		py = _point_Y(point);
 10601                 p.x = __intVal(px);
 10601 		p.x = __intVal(px);
 10602                 p.y = __intVal(py);
 10602 		p.y = __intVal(py);
 10603                 if ((i & 1) == 0) {
 10603 		if ((i & 1) == 0) {
 10604                     MoveToEx(hDC, p.x, p.y, NULL);
 10604 		    MoveToEx(hDC, p.x, p.y, NULL);
 10605                 } else {
 10605 		} else {
 10606                     LineTo(hDC, p.x, p.y);
 10606 		    LineTo(hDC, p.x, p.y);
 10607                     /*
 10607 		    /*
 10608                      * end-point ...
 10608 		     * end-point ...
 10609                      */
 10609 		     */
 10610                     LineTo(hDC, p.x+1, p.y);
 10610 		    LineTo(hDC, p.x+1, p.y);
 10611                 }
 10611 		}
 10612             }
 10612 	    }
 10613             GcDataReleasePen(hDC, gcData);
 10613 	    GcDataReleasePen(hDC, gcData);
 10614         }
 10614 	}
 10615 
 10615 
 10616 #ifndef CACHE_LAST_DC
 10616 #ifndef CACHE_LAST_DC
 10617         _releaseDC(gcData);
 10617 	_releaseDC(gcData);
 10618 #endif
 10618 #endif
 10619         RETURN ( self );
 10619 	RETURN ( self );
 10620     }
 10620     }
 10621 fail: ;
 10621 fail: ;
 10622 %}
 10622 %}
 10623 !
 10623 !
 10624 
 10624 
 10629     int w, h;
 10629     int w, h;
 10630     int xL, yT;
 10630     int xL, yT;
 10631     if (__isExternalAddress(aGCId)
 10631     if (__isExternalAddress(aGCId)
 10632      && __bothSmallInteger(x, y)
 10632      && __bothSmallInteger(x, y)
 10633      && __bothSmallInteger(width, height)) {
 10633      && __bothSmallInteger(width, height)) {
 10634         struct gcData *gcData = _GCDATA(aGCId);
 10634 	struct gcData *gcData = _GCDATA(aGCId);
 10635         HDC hDC = _getDC(gcData);
 10635 	HDC hDC = _getDC(gcData);
 10636 
 10636 
 10637         xL = __intVal(x);
 10637 	xL = __intVal(x);
 10638         yT = __intVal(y);
 10638 	yT = __intVal(y);
 10639         w = __intVal(width);
 10639 	w = __intVal(width);
 10640         h = __intVal(height);
 10640 	h = __intVal(height);
 10641 
 10641 
 10642         DDDDPRINTF(("displayRectangle: %d/%d -> %d/%d\n",
 10642 	DDDDPRINTF(("displayRectangle: %d/%d -> %d/%d\n",
 10643                         xL, yT, w, h));
 10643 			xL, yT, w, h));
 10644 
 10644 
 10645         if ((w >= 0) && (h >= 0)) {
 10645 	if ((w >= 0) && (h >= 0)) {
 10646             if (! GcDataGetPen(hDC,gcData)) {
 10646 	    if (! GcDataGetPen(hDC,gcData)) {
 10647                 DPRINTF(("displayRect: no pen\n"));
 10647 		DPRINTF(("displayRect: no pen\n"));
 10648             } else {
 10648 	    } else {
 10649                 MoveToEx(hDC, xL, yT, NULL);
 10649 		MoveToEx(hDC, xL, yT, NULL);
 10650 #if 0
 10650 #if 0
 10651                 LineTo(hDC, xL+w, yT);     // to top-right
 10651 		LineTo(hDC, xL+w, yT);     // to top-right
 10652                 LineTo(hDC, xL+w, yT+h);   // to bot-right
 10652 		LineTo(hDC, xL+w, yT+h);   // to bot-right
 10653                 LineTo(hDC, xL, yT+h);     // to bot-left
 10653 		LineTo(hDC, xL, yT+h);     // to bot-left
 10654                 LineTo(hDC, xL, yT);       // back to top-left
 10654 		LineTo(hDC, xL, yT);       // back to top-left
 10655 #else
 10655 #else
 10656                 LineTo(hDC, xL+w, yT);       // to top-right
 10656 		LineTo(hDC, xL+w, yT);       // to top-right
 10657                 LineTo(hDC, xL+w, yT+h);     // to bot-right
 10657 		LineTo(hDC, xL+w, yT+h);     // to bot-right
 10658                 MoveToEx(hDC, xL, yT, NULL); // back to top-left
 10658 		MoveToEx(hDC, xL, yT, NULL); // back to top-left
 10659                 LineTo(hDC, xL, yT+h);       // to bot-left
 10659 		LineTo(hDC, xL, yT+h);       // to bot-left
 10660 
 10660 
 10661 #ifndef PRE_31_JAN_03
 10661 #ifndef PRE_31_JAN_03
 10662                 LineTo(hDC, xL+w+1, yT+h);   // move pen one pixel more
 10662 		LineTo(hDC, xL+w+1, yT+h);   // move pen one pixel more
 10663 #else
 10663 #else
 10664                 LineTo(hDC, xL+w, yT+h);     // to bot-right
 10664 		LineTo(hDC, xL+w, yT+h);     // to bot-right
 10665 #endif
 10665 #endif
 10666 
 10666 
 10667 #endif
 10667 #endif
 10668 
 10668 
 10669                 GcDataReleasePen(hDC, gcData);
 10669 		GcDataReleasePen(hDC, gcData);
 10670             }
 10670 	    }
 10671         }
 10671 	}
 10672 #ifndef CACHE_LAST_DC
 10672 #ifndef CACHE_LAST_DC
 10673         _releaseDC(gcData);
 10673 	_releaseDC(gcData);
 10674 #endif
 10674 #endif
 10675         RETURN ( self );
 10675 	RETURN ( self );
 10676     }
 10676     }
 10677 %}
 10677 %}
 10678 !
 10678 !
 10679 
 10679 
 10680 displayString:aString from:index1 to:index2 x:x y:y in:ignoredDrawableId with:aGCId opaque:opaque
 10680 displayString:aString from:index1 to:index2 x:x y:y in:ignoredDrawableId with:aGCId opaque:opaque
 10691     if (__isExternalAddress(aGCId)
 10691     if (__isExternalAddress(aGCId)
 10692      && __isNonNilObject(aString)
 10692      && __isNonNilObject(aString)
 10693      && __bothSmallInteger(index1, index2)
 10693      && __bothSmallInteger(index1, index2)
 10694      && __bothSmallInteger(x, y))
 10694      && __bothSmallInteger(x, y))
 10695     {
 10695     {
 10696         struct gcData *gcData;
 10696 	struct gcData *gcData;
 10697         int pX, pY;
 10697 	int pX, pY;
 10698         HDC hDC;
 10698 	HDC hDC;
 10699         HFONT hOldFont;
 10699 	HFONT hOldFont;
 10700 
 10700 
 10701         i1 = __intVal(index1) - 1;
 10701 	i1 = __intVal(index1) - 1;
 10702         i2 = __intVal(index2) - 1;
 10702 	i2 = __intVal(index2) - 1;
 10703         if ((i1 < 0) || (i2 < i1)) {
 10703 	if ((i1 < 0) || (i2 < i1)) {
 10704             RETURN (self);
 10704 	    RETURN (self);
 10705         }
 10705 	}
 10706 
 10706 
 10707         gcData = _GCDATA(aGCId);
 10707 	gcData = _GCDATA(aGCId);
 10708         hDC = _getDC(gcData);
 10708 	hDC = _getDC(gcData);
 10709         pX = __intVal(x);
 10709 	pX = __intVal(x);
 10710         pY = __intVal(y);
 10710 	pY = __intVal(y);
 10711         pY -= gcData->fontAscent;
 10711 	pY -= gcData->fontAscent;
 10712 
 10712 
 10713         if (opaque == true) {
 10713 	if (opaque == true) {
 10714             if (gcData->bkMode != BK_OPAQUE) {
 10714 	    if (gcData->bkMode != BK_OPAQUE) {
 10715                 SetBkMode(hDC, OPAQUE);
 10715 		SetBkMode(hDC, OPAQUE);
 10716                 gcData->bkMode = BK_OPAQUE;
 10716 		gcData->bkMode = BK_OPAQUE;
 10717             }
 10717 	    }
 10718         } else {
 10718 	} else {
 10719             if (gcData->bkMode != BK_TRANSPARENT) {
 10719 	    if (gcData->bkMode != BK_TRANSPARENT) {
 10720                 SetBkMode(hDC, TRANSPARENT);
 10720 		SetBkMode(hDC, TRANSPARENT);
 10721                 gcData->bkMode = BK_TRANSPARENT;
 10721 		gcData->bkMode = BK_TRANSPARENT;
 10722             }
 10722 	    }
 10723         }
 10723 	}
 10724 #if 0
 10724 #if 0
 10725         /* leftover code from tries to make TextOut honor the gc-mode,
 10725 	/* leftover code from tries to make TextOut honor the gc-mode,
 10726          * until I googled, that TextOut does not (by purpose, or backward-bug compatibility)
 10726 	 * until I googled, that TextOut does not (by purpose, or backward-bug compatibility)
 10727          */
 10727 	 */
 10728         hOldFont = SelectObject(hDC, gcData->hFont);
 10728 	hOldFont = SelectObject(hDC, gcData->hFont);
 10729         SetTextColor(hDC, gcData->fgColor);
 10729 	SetTextColor(hDC, gcData->fgColor);
 10730         SetBkColor(hDC, gcData->bgColor);
 10730 	SetBkColor(hDC, gcData->bgColor);
 10731 #endif
 10731 #endif
 10732 #if 0
 10732 #if 0
 10733         GcDataGetPen(hDC, gcData);
 10733 	GcDataGetPen(hDC, gcData);
 10734 #endif
 10734 #endif
 10735 
 10735 
 10736         cls = __qClass(aString);
 10736 	cls = __qClass(aString);
 10737 
 10737 
 10738         cp = __stringVal(aString);
 10738 	cp = __stringVal(aString);
 10739         l = i2 - i1 + 1;
 10739 	l = i2 - i1 + 1;
 10740         if (l > 32758) {
 10740 	if (l > 32758) {
 10741             /* Windows (as in XP) limits the string size for TextOut* to 32758 */
 10741 	    /* Windows (as in XP) limits the string size for TextOut* to 32758 */
 10742             l = 32758;
 10742 	    l = 32758;
 10743         }
 10743 	}
 10744 
 10744 
 10745         if (__isStringLike(aString)) {
 10745 	if (__isStringLike(aString)) {
 10746             n = __stringSize(aString);
 10746 	    n = __stringSize(aString);
 10747 commonOutChars:
 10747 commonOutChars:
 10748             if (i2 < n) {
 10748 	    if (i2 < n) {
 10749                 cp += i1;
 10749 		cp += i1;
 10750                 CPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC));
 10750 		CPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC));
 10751                 if (! TextOutA(hDC, pX, pY, (char *)cp, l)) {
 10751 		if (! TextOutA(hDC, pX, pY, (char *)cp, l)) {
 10752                     PRINTF(("WinWorkstation [warning]: TextOutA failed. [%d]\n", __LINE__));
 10752 		    PRINTF(("WinWorkstation [warning]: TextOutA failed. [%d]\n", __LINE__));
 10753                     PRINTF(("WinWorkstation [warning]: lastError=%d x:%d y:%d len:%d\n", GetLastError(), pX, pY, l));
 10753 		    PRINTF(("WinWorkstation [warning]: lastError=%d x:%d y:%d len:%d\n", GetLastError(), pX, pY, l));
 10754                     goto error;
 10754 		    goto error;
 10755                 }
 10755 		}
 10756             }
 10756 	    }
 10757             goto ret;
 10757 	    goto ret;
 10758         }
 10758 	}
 10759 
 10759 
 10760         nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
 10760 	nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
 10761         cp += nInstBytes;
 10761 	cp += nInstBytes;
 10762         n = __byteArraySize(aString) - nInstBytes;
 10762 	n = __byteArraySize(aString) - nInstBytes;
 10763 
 10763 
 10764         if (__isBytes(aString)) {
 10764 	if (__isBytes(aString)) {
 10765             goto commonOutChars;
 10765 	    goto commonOutChars;
 10766         }
 10766 	}
 10767 
 10767 
 10768         /* Unicode */
 10768 	/* Unicode */
 10769         if (__isWords(aString)) {
 10769 	if (__isWords(aString)) {
 10770             n = n / 2;
 10770 	    n = n / 2;
 10771             if (i2 < n) {
 10771 	    if (i2 < n) {
 10772                 WIDECHAR *w_cp = (WIDECHAR *)cp;
 10772 		WIDECHAR *w_cp = (WIDECHAR *)cp;
 10773                 w_cp += i1;
 10773 		w_cp += i1;
 10774                 if (! TextOutW(hDC, pX, pY, w_cp, l)) {
 10774 		if (! TextOutW(hDC, pX, pY, w_cp, l)) {
 10775                     PRINTF(("WinWorkstation [warning]: TextOutW failed. [%d]\n", __LINE__));
 10775 		    PRINTF(("WinWorkstation [warning]: TextOutW failed. [%d]\n", __LINE__));
 10776                     PRINTF(("WinWorkstation [warning]: lastError=%d x:%d y:%d len:%d\n", GetLastError(), pX, pY, l));
 10776 		    PRINTF(("WinWorkstation [warning]: lastError=%d x:%d y:%d len:%d\n", GetLastError(), pX, pY, l));
 10777                 }
 10777 		}
 10778                 goto ret;
 10778 		goto ret;
 10779             }
 10779 	    }
 10780         }
 10780 	}
 10781 ret:;
 10781 ret:;
 10782 #if 0
 10782 #if 0
 10783         GcDataReleasePen(hDC, gcData);
 10783 	GcDataReleasePen(hDC, gcData);
 10784 #endif
 10784 #endif
 10785 #if 0
 10785 #if 0
 10786         SelectObject(hDC, hOldFont);
 10786 	SelectObject(hDC, hOldFont);
 10787 #endif
 10787 #endif
 10788 #ifndef CACHE_LAST_DC
 10788 #ifndef CACHE_LAST_DC
 10789         _releaseDC(gcData);
 10789 	_releaseDC(gcData);
 10790 #endif
 10790 #endif
 10791     }
 10791     }
 10792     RETURN (self);
 10792     RETURN (self);
 10793 error: ;;
 10793 error: ;;
 10794 %}.
 10794 %}.
 10813      depth - otherwise, primitive failure will be signalled.
 10813      depth - otherwise, primitive failure will be signalled.
 10814      Also it is assumed, that the colormap is setup correctly and the
 10814      Also it is assumed, that the colormap is setup correctly and the
 10815      colors are allocated - otherwise the colors may be wrong."
 10815      colors are allocated - otherwise the colors may be wrong."
 10816 
 10816 
 10817     (self
 10817     (self
 10818         primDrawBits:imageBits
 10818 	primDrawBits:imageBits
 10819         bitsPerPixel:bitsPerPixel
 10819 	bitsPerPixel:bitsPerPixel
 10820         depth:imageDepth
 10820 	depth:imageDepth
 10821         width:imageWidth height:imageHeight
 10821 	width:imageWidth height:imageHeight
 10822         x:srcx y:srcy
 10822 	x:srcx y:srcy
 10823         into:ignoredDrawableId
 10823 	into:ignoredDrawableId
 10824         x:dstx y:dsty
 10824 	x:dstx y:dsty
 10825         width:w height:h
 10825 	width:w height:h
 10826         with:aGCId
 10826 	with:aGCId
 10827         parameters:(Array with:nil with:padd with:nil with:nil with:nil)
 10827 	parameters:(Array with:nil with:padd with:nil with:nil with:nil)
 10828         "/ the params array is ONLY used, because there is a 15-argument limit in st/x !!
 10828 	"/ the params array is ONLY used, because there is a 15-argument limit in st/x !!
 10829     ) ifFalse:[
 10829     ) ifFalse:[
 10830         "
 10830 	"
 10831          also happens, if a segmentation violation occurs in primitive code...
 10831 	 also happens, if a segmentation violation occurs in primitive code...
 10832         "
 10832 	"
 10833         self primitiveFailed
 10833 	self primitiveFailed
 10834     ].
 10834     ].
 10835 !
 10835 !
 10836 
 10836 
 10837 drawBits:imageBits
 10837 drawBits:imageBits
 10838     bitsPerPixel:bitsPerPixel
 10838     bitsPerPixel:bitsPerPixel
 10853      depth - otherwise, primitive failure will be signalled.
 10853      depth - otherwise, primitive failure will be signalled.
 10854      Also it is assumed, that the colormap is setup correctly and the
 10854      Also it is assumed, that the colormap is setup correctly and the
 10855      colors are allocated - otherwise the colors may be wrong."
 10855      colors are allocated - otherwise the colors may be wrong."
 10856 
 10856 
 10857     (self
 10857     (self
 10858         primDrawBits:imageBits
 10858 	primDrawBits:imageBits
 10859         bitsPerPixel:bitsPerPixel
 10859 	bitsPerPixel:bitsPerPixel
 10860         depth:imageDepth
 10860 	depth:imageDepth
 10861         width:imageWidth height:imageHeight
 10861 	width:imageWidth height:imageHeight
 10862         x:srcx y:srcy
 10862 	x:srcx y:srcy
 10863         into:ignoredDrawableId
 10863 	into:ignoredDrawableId
 10864         x:dstx y:dsty
 10864 	x:dstx y:dsty
 10865         width:w height:h
 10865 	width:w height:h
 10866         with:aGCId
 10866 	with:aGCId
 10867         parameters:parameters
 10867 	parameters:parameters
 10868         "/ the params array is ONLY used, because there is a 15-argument limit in st/x !!
 10868 	"/ the params array is ONLY used, because there is a 15-argument limit in st/x !!
 10869     ) ifFalse:[
 10869     ) ifFalse:[
 10870         "
 10870 	"
 10871          also happens, if a segmentation violation occurs in primitive code...
 10871 	 also happens, if a segmentation violation occurs in primitive code...
 10872         "
 10872 	"
 10873         self primitiveFailed
 10873 	self primitiveFailed
 10874     ].
 10874     ].
 10875 !
 10875 !
 10876 
 10876 
 10877 fillArcX:x y:y width:width height:height from:startAngle angle:angle
 10877 fillArcX:x y:y width:width height:height from:startAngle angle:angle
 10878                in:ignoredDrawableId with:aGCId
 10878 	       in:ignoredDrawableId with:aGCId
 10879     "fill an arc. If any coordinate is not integer, an error is triggered.
 10879     "fill an arc. If any coordinate is not integer, an error is triggered.
 10880      The angles may be floats or integer - they are given in degrees."
 10880      The angles may be floats or integer - they are given in degrees."
 10881 
 10881 
 10882 %{
 10882 %{
 10883     int __x, __y, w, h;
 10883     int __x, __y, w, h;
 10884     float angle1, angle2;
 10884     float angle1, angle2;
 10885 
 10885 
 10886     if (__isSmallInteger(startAngle))
 10886     if (__isSmallInteger(startAngle))
 10887         angle1 = (float)(__intVal(startAngle));
 10887 	angle1 = (float)(__intVal(startAngle));
 10888     else if (__isFloat(startAngle)) {
 10888     else if (__isFloat(startAngle)) {
 10889         angle1 = __floatVal(startAngle);
 10889 	angle1 = __floatVal(startAngle);
 10890     } else if (__isShortFloat(startAngle)) {
 10890     } else if (__isShortFloat(startAngle)) {
 10891         angle1 = __shortFloatVal(startAngle);
 10891 	angle1 = __shortFloatVal(startAngle);
 10892     } else goto bad;
 10892     } else goto bad;
 10893 
 10893 
 10894     if (__isSmallInteger(angle))
 10894     if (__isSmallInteger(angle))
 10895         angle2 = (float)(__intVal(angle));
 10895 	angle2 = (float)(__intVal(angle));
 10896     else if (__isFloat(angle)) {
 10896     else if (__isFloat(angle)) {
 10897         angle2 = __floatVal(angle);
 10897 	angle2 = __floatVal(angle);
 10898     } else if (__isShortFloat(angle)) {
 10898     } else if (__isShortFloat(angle)) {
 10899         angle2 = __shortFloatVal(angle);
 10899 	angle2 = __shortFloatVal(angle);
 10900     } else goto bad;
 10900     } else goto bad;
 10901 
 10901 
 10902     if (angle2 <= 0) {
 10902     if (angle2 <= 0) {
 10903         RETURN (self);
 10903 	RETURN (self);
 10904     }
 10904     }
 10905 
 10905 
 10906     if (__isExternalAddress(aGCId)
 10906     if (__isExternalAddress(aGCId)
 10907      && __bothSmallInteger(x, y)
 10907      && __bothSmallInteger(x, y)
 10908      && __bothSmallInteger(width, height))
 10908      && __bothSmallInteger(width, height))
 10909      {
 10909      {
 10910         struct gcData *gcData = _GCDATA(aGCId);
 10910 	struct gcData *gcData = _GCDATA(aGCId);
 10911         HDC hDC;
 10911 	HDC hDC;
 10912         HBRUSH hBrush;
 10912 	HBRUSH hBrush;
 10913         HPEN prevPen = 0;
 10913 	HPEN prevPen = 0;
 10914 
 10914 
 10915         w = __intVal(width);
 10915 	w = __intVal(width);
 10916         h = __intVal(height);
 10916 	h = __intVal(height);
 10917         __x = __intVal(x);
 10917 	__x = __intVal(x);
 10918         __y = __intVal(y);
 10918 	__y = __intVal(y);
 10919 
 10919 
 10920         hDC = _getDC(gcData);
 10920 	hDC = _getDC(gcData);
 10921 
 10921 
 10922         hBrush = GcDataGetBrush(hDC, gcData);
 10922 	hBrush = GcDataGetBrush(hDC, gcData);
 10923         if (hBrush == 0) {
 10923 	if (hBrush == 0) {
 10924             DPRINTF(("fillArc: no brush\n"));
 10924 	    DPRINTF(("fillArc: no brush\n"));
 10925         } else {
 10925 	} else {
 10926             HPEN hPen = 0;
 10926 	    HPEN hPen = 0;
 10927 
 10927 
 10928 #if 0
 10928 #if 0
 10929             hPen = GcDataGetPen(hDC, gcData);
 10929 	    hPen = GcDataGetPen(hDC, gcData);
 10930             if (hPen == 0) {
 10930 	    if (hPen == 0) {
 10931                 DPRINTF(("fillArc: no pen\n"));
 10931 		DPRINTF(("fillArc: no pen\n"));
 10932                 goto failpen;
 10932 		goto failpen;
 10933             }
 10933 	    }
 10934 #else
 10934 #else
 10935             prevPen = SelectObject(hDC, __nullPen);
 10935 	    prevPen = SelectObject(hDC, __nullPen);
 10936             w++;
 10936 	    w++;
 10937             h++;
 10937 	    h++;
 10938 #endif
 10938 #endif
 10939             {
 10939 	    {
 10940                 double xB, yB, xE, yE, xR, yR;
 10940 		double xB, yB, xE, yE, xR, yR;
 10941 
 10941 
 10942                 xR = w / 2;
 10942 		xR = w / 2;
 10943                 yR = h / 2;
 10943 		yR = h / 2;
 10944                 if (angle2 - angle1 >= 360) {
 10944 		if (angle2 - angle1 >= 360) {
 10945                     xB = xE = __x + xR + 0.5;
 10945 		    xB = xE = __x + xR + 0.5;
 10946                     yB = yE = __y /*+ yR + 0.5*/;
 10946 		    yB = yE = __y /*+ yR + 0.5*/;
 10947                 } else {
 10947 		} else {
 10948                     double sin(), cos();
 10948 		    double sin(), cos();
 10949                     float rad1, rad2;
 10949 		    float rad1, rad2;
 10950 
 10950 
 10951                     if (angle1 <= 180)
 10951 		    if (angle1 <= 180)
 10952                         angle1 = 180 - angle1;
 10952 			angle1 = 180 - angle1;
 10953                     else
 10953 		    else
 10954                         angle1 = 360 + 180 - angle1;
 10954 			angle1 = 360 + 180 - angle1;
 10955                     angle2 = angle1 - angle2;
 10955 		    angle2 = angle1 - angle2;
 10956                     /* sigh - compute the intersections ... */
 10956 		    /* sigh - compute the intersections ... */
 10957                     rad1 = (angle1 * 3.14159265359) / 180.0;
 10957 		    rad1 = (angle1 * 3.14159265359) / 180.0;
 10958                     rad2 = (angle2 * 3.14159265359) / 180.0;
 10958 		    rad2 = (angle2 * 3.14159265359) / 180.0;
 10959                     xB = cos(rad1) * xR;
 10959 		    xB = cos(rad1) * xR;
 10960                     yB = sin(rad1) * yR;
 10960 		    yB = sin(rad1) * yR;
 10961                     xE = cos(rad2) * xR;
 10961 		    xE = cos(rad2) * xR;
 10962                     yE = sin(rad2) * yR;
 10962 		    yE = sin(rad2) * yR;
 10963                     xB = __x + xR - xB + 0.5;
 10963 		    xB = __x + xR - xB + 0.5;
 10964                     yB = __y + yR - yB + 0.5;
 10964 		    yB = __y + yR - yB + 0.5;
 10965                     xE = __x + xR - xE + 0.5;
 10965 		    xE = __x + xR - xE + 0.5;
 10966                     yE = __y + yR - yE + 0.5;
 10966 		    yE = __y + yR - yE + 0.5;
 10967                 }
 10967 		}
 10968                 DPRINTF(("fillArc x=%d y=%d w=%d h=%d xB=%d xE=%d yB=%d yE=%d a1=%f a2=%f\n",__x,__y,w,h,(int)xB,(int)xE,(int)yB,(int)yE,angle1,angle2));
 10968 		DPRINTF(("fillArc x=%d y=%d w=%d h=%d xB=%d xE=%d yB=%d yE=%d a1=%f a2=%f\n",__x,__y,w,h,(int)xB,(int)xE,(int)yB,(int)yE,angle1,angle2));
 10969 
 10969 
 10970                 Pie(hDC,
 10970 		Pie(hDC,
 10971                     __x, __y,
 10971 		    __x, __y,
 10972                     __x + w + 1, __y + h + 1,
 10972 		    __x + w + 1, __y + h + 1,
 10973                     (int)xB, (int)yB,
 10973 		    (int)xB, (int)yB,
 10974                     (int)xE, (int)yE);
 10974 		    (int)xE, (int)yE);
 10975 
 10975 
 10976                 if (hPen) {
 10976 		if (hPen) {
 10977                     GcDataReleasePen(hDC, gcData);
 10977 		    GcDataReleasePen(hDC, gcData);
 10978                 }
 10978 		}
 10979             }
 10979 	    }
 10980 failpen:
 10980 failpen:
 10981 #ifdef CACHE_LAST_CG
 10981 #ifdef CACHE_LAST_CG
 10982             if (prevPen) SelectObject(hDC, prevPen);
 10982 	    if (prevPen) SelectObject(hDC, prevPen);
 10983 #endif
 10983 #endif
 10984             GcDataReleaseBrush(hDC, gcData);
 10984 	    GcDataReleaseBrush(hDC, gcData);
 10985         }
 10985 	}
 10986 #ifndef CACHE_LAST_DC
 10986 #ifndef CACHE_LAST_DC
 10987         _releaseDC(gcData);
 10987 	_releaseDC(gcData);
 10988 #endif
 10988 #endif
 10989         RETURN ( self );
 10989 	RETURN ( self );
 10990     }
 10990     }
 10991     bad: ;
 10991     bad: ;
 10992 %}.
 10992 %}.
 10993     self primitiveFailed
 10993     self primitiveFailed
 10994 !
 10994 !
 10999 
 10999 
 11000     |numberOfPoints|
 11000     |numberOfPoints|
 11001 
 11001 
 11002     numberOfPoints := aPolygon size.
 11002     numberOfPoints := aPolygon size.
 11003     self
 11003     self
 11004         primFillPolygon:aPolygon n:numberOfPoints
 11004 	primFillPolygon:aPolygon n:numberOfPoints
 11005         in:ignoredDrawableId with:aGCId
 11005 	in:ignoredDrawableId with:aGCId
 11006 !
 11006 !
 11007 
 11007 
 11008 fillRectangleX:x y:y width:width height:height in:ignoredDrawableId with:aGCId
 11008 fillRectangleX:x y:y width:width height:height in:ignoredDrawableId with:aGCId
 11009     "fill a rectangle. If any coordinate is not integer, an error is triggered."
 11009     "fill a rectangle. If any coordinate is not integer, an error is triggered."
 11010 
 11010 
 11012 
 11012 
 11013     int w, h;
 11013     int w, h;
 11014     if (__isExternalAddress(aGCId)
 11014     if (__isExternalAddress(aGCId)
 11015      && __bothSmallInteger(x, y)
 11015      && __bothSmallInteger(x, y)
 11016      && __bothSmallInteger(width, height)) {
 11016      && __bothSmallInteger(width, height)) {
 11017         w = __intVal(width);
 11017 	w = __intVal(width);
 11018         h = __intVal(height);
 11018 	h = __intVal(height);
 11019 
 11019 
 11020         if ((w >= 0) && (h >= 0)) {
 11020 	if ((w >= 0) && (h >= 0)) {
 11021             struct gcData *gcData = _GCDATA(aGCId);
 11021 	    struct gcData *gcData = _GCDATA(aGCId);
 11022             HDC hDC;
 11022 	    HDC hDC;
 11023             HBRUSH hBrush;
 11023 	    HBRUSH hBrush;
 11024             RECT rct;
 11024 	    RECT rct;
 11025 
 11025 
 11026             hDC = _getDC(gcData);
 11026 	    hDC = _getDC(gcData);
 11027 
 11027 
 11028             hBrush = GcDataGetBrush(hDC, gcData);
 11028 	    hBrush = GcDataGetBrush(hDC, gcData);
 11029             if (! hBrush) {
 11029 	    if (! hBrush) {
 11030                 PRINTF(("fillRectangle: no brush\n"));
 11030 		PRINTF(("fillRectangle: no brush\n"));
 11031             } else {
 11031 	    } else {
 11032                 rct.left = __intVal(x);
 11032 		rct.left = __intVal(x);
 11033                 rct.top  = __intVal(y);
 11033 		rct.top  = __intVal(y);
 11034 
 11034 
 11035 #ifndef PRE_31_JAN_03
 11035 #ifndef PRE_31_JAN_03
 11036                 rct.right  = rct.left + w;
 11036 		rct.right  = rct.left + w;
 11037                 rct.bottom = rct.top  + h;
 11037 		rct.bottom = rct.top  + h;
 11038 #else
 11038 #else
 11039                 rct.right  = rct.left + w + 1;    /* definitiv ! */
 11039 		rct.right  = rct.left + w + 1;    /* definitiv ! */
 11040                 rct.bottom = rct.top  + h + 1;
 11040 		rct.bottom = rct.top  + h + 1;
 11041 #endif
 11041 #endif
 11042 
 11042 
 11043                 CPRINTF(("fillRectangle:%d.%d -> %d.%d\n",rct.left,rct.top,rct.right,rct.bottom));
 11043 		CPRINTF(("fillRectangle:%d.%d -> %d.%d\n",rct.left,rct.top,rct.right,rct.bottom));
 11044 
 11044 
 11045                 /*
 11045 		/*
 11046                  * for solid draws (without function), can use FillRect,
 11046 		 * for solid draws (without function), can use FillRect,
 11047                  * which is faster and does not need a pen.
 11047 		 * which is faster and does not need a pen.
 11048                  */
 11048 		 */
 11049                 if ((gcData->rop2 == R2_COPYPEN)
 11049 		if ((gcData->rop2 == R2_COPYPEN)
 11050                  && (gcData->bitbltrop2 == BITBLT_COPY)) {
 11050 		 && (gcData->bitbltrop2 == BITBLT_COPY)) {
 11051                     AQUIRE_DRAW_MUTEX
 11051 		    AQUIRE_DRAW_MUTEX
 11052                     FillRect(hDC, &rct, hBrush);
 11052 		    FillRect(hDC, &rct, hBrush);
 11053                     RELEASE_DRAW_MUTEX
 11053 		    RELEASE_DRAW_MUTEX
 11054                     GcDataReleaseBrush(hDC, gcData);
 11054 		    GcDataReleaseBrush(hDC, gcData);
 11055                 } else {
 11055 		} else {
 11056                     HPEN prevPen;
 11056 		    HPEN prevPen;
 11057 
 11057 
 11058                     prevPen = SelectObject(hDC, __nullPen);
 11058 		    prevPen = SelectObject(hDC, __nullPen);
 11059 /* sigh - conflict between ST/X's Rectangle and Win32's Rectangle */
 11059 /* sigh - conflict between ST/X's Rectangle and Win32's Rectangle */
 11060 # undef Rectangle
 11060 # undef Rectangle
 11061 
 11061 
 11062 #ifndef PRE_31_JAN_03
 11062 #ifndef PRE_31_JAN_03
 11063                     Rectangle(hDC, rct.left, rct.top, rct.right +1, rct.bottom +1);
 11063 		    Rectangle(hDC, rct.left, rct.top, rct.right +1, rct.bottom +1);
 11064 #else
 11064 #else
 11065                     Rectangle(hDC, rct.left, rct.top, rct.right, rct.bottom);
 11065 		    Rectangle(hDC, rct.left, rct.top, rct.right, rct.bottom);
 11066 #endif
 11066 #endif
 11067 
 11067 
 11068 # define Rectangle __DEF_Rectangle
 11068 # define Rectangle __DEF_Rectangle
 11069                     GcDataReleaseBrush(hDC, gcData);
 11069 		    GcDataReleaseBrush(hDC, gcData);
 11070 #ifdef CACHE_LAST_DC
 11070 #ifdef CACHE_LAST_DC
 11071                     SelectObject(hDC, prevPen);
 11071 		    SelectObject(hDC, prevPen);
 11072 #endif
 11072 #endif
 11073                 }
 11073 		}
 11074             }
 11074 	    }
 11075 #ifndef CACHE_LAST_DC
 11075 #ifndef CACHE_LAST_DC
 11076             _releaseDC(gcData);
 11076 	    _releaseDC(gcData);
 11077 #endif
 11077 #endif
 11078         }
 11078 	}
 11079         RETURN ( self );
 11079 	RETURN ( self );
 11080     }
 11080     }
 11081 %}
 11081 %}
 11082 !
 11082 !
 11083 
 11083 
 11084 primDrawBits:imageBits
 11084 primDrawBits:imageBits
 11092     destinationOrigin:dstOrigin
 11092     destinationOrigin:dstOrigin
 11093     extent:imageExtent2
 11093     extent:imageExtent2
 11094     with:aGCId
 11094     with:aGCId
 11095 
 11095 
 11096     (self
 11096     (self
 11097         primDrawBits:imageBits
 11097 	primDrawBits:imageBits
 11098         bitsPerPixel:bitsPerPixel
 11098 	bitsPerPixel:bitsPerPixel
 11099         depth:imageDepth
 11099 	depth:imageDepth
 11100         width:imageExtent x height:imageExtent y
 11100 	width:imageExtent x height:imageExtent y
 11101         x:srcOrigin x y:srcOrigin y
 11101 	x:srcOrigin x y:srcOrigin y
 11102         into:ignoredDrawableId
 11102 	into:ignoredDrawableId
 11103         x:dstOrigin x y:dstOrigin y
 11103 	x:dstOrigin x y:dstOrigin y
 11104         width:imageExtent x height:imageExtent y
 11104 	width:imageExtent x height:imageExtent y
 11105         with:aGCId
 11105 	with:aGCId
 11106         parameters:(Array with:nil with:padd with:(maskVector at:1) with:(maskVector at:2) with:(maskVector at:3))
 11106 	parameters:(Array with:nil with:padd with:(maskVector at:1) with:(maskVector at:2) with:(maskVector at:3))
 11107         "/ the params array is ONLY used, because there is a 15-argument limit in st/x !!
 11107 	"/ the params array is ONLY used, because there is a 15-argument limit in st/x !!
 11108         "/   sourceAlphaOrNil := params at:1.
 11108 	"/   sourceAlphaOrNil := params at:1.
 11109         "/   padd := params at:2.
 11109 	"/   padd := params at:2.
 11110         "/   redMask := params at:3.
 11110 	"/   redMask := params at:3.
 11111         "/   greenMask := params at:4.
 11111 	"/   greenMask := params at:4.
 11112         "/   blueMask := params at:5.
 11112 	"/   blueMask := params at:5.
 11113     ) ifFalse:[
 11113     ) ifFalse:[
 11114         "
 11114 	"
 11115          also happens, if a segmentation violation occurs in primitive code...
 11115 	 also happens, if a segmentation violation occurs in primitive code...
 11116         "
 11116 	"
 11117         self primitiveFailed
 11117 	self primitiveFailed
 11118     ].
 11118     ].
 11119 !
 11119 !
 11120 
 11120 
 11121 primDrawBits:imageBits
 11121 primDrawBits:imageBits
 11122         bitsPerPixel:bitsPerPixel depth:imageDepth
 11122 	bitsPerPixel:bitsPerPixel depth:imageDepth
 11123         width:imageWidth height:imageHeight
 11123 	width:imageWidth height:imageHeight
 11124         x:srcx y:srcy
 11124 	x:srcx y:srcy
 11125         into:ignoredDrawableId
 11125 	into:ignoredDrawableId
 11126         x:dstx y:dsty
 11126 	x:dstx y:dsty
 11127         width:w height:h
 11127 	width:w height:h
 11128         with:aGCId
 11128 	with:aGCId
 11129         parameters:params
 11129 	parameters:params
 11130 
 11130 
 11131     |sourceAlphaOrNil padd redMask greenMask blueMask|
 11131     |sourceAlphaOrNil padd redMask greenMask blueMask|
 11132 
 11132 
 11133     "/ the params array is ONLY used, because there is a 15-argument limit in st/x
 11133     "/ the params array is ONLY used, because there is a 15-argument limit in st/x
 11134     sourceAlphaOrNil := params at:1.
 11134     sourceAlphaOrNil := params at:1.
 11146     unsigned char *__imageBits = 0;
 11146     unsigned char *__imageBits = 0;
 11147     int _sourceAlpha = 0;
 11147     int _sourceAlpha = 0;
 11148     int _doAlphaBlend = 0;
 11148     int _doAlphaBlend = 0;
 11149 
 11149 
 11150     if (__isByteArray(imageBits)) {
 11150     if (__isByteArray(imageBits)) {
 11151         __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
 11151 	__imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
 11152     } else if (__isExternalBytesLike(imageBits)) {
 11152     } else if (__isExternalBytesLike(imageBits)) {
 11153         __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
 11153 	__imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
 11154     }
 11154     }
 11155 
 11155 
 11156     if (ISCONNECTED
 11156     if (ISCONNECTED
 11157      && __isExternalAddress(aGCId)
 11157      && __isExternalAddress(aGCId)
 11158      && __bothSmallInteger(srcx, srcy)
 11158      && __bothSmallInteger(srcx, srcy)
 11161      && __bothSmallInteger(imageWidth, imageHeight)
 11161      && __bothSmallInteger(imageWidth, imageHeight)
 11162      && __bothSmallInteger(imageDepth, bitsPerPixel)
 11162      && __bothSmallInteger(imageDepth, bitsPerPixel)
 11163      && __isSmallInteger(padd)
 11163      && __isSmallInteger(padd)
 11164      && __imageBits)
 11164      && __imageBits)
 11165      {
 11165      {
 11166         struct
 11166 	struct
 11167         {
 11167 	{
 11168           BITMAPINFOHEADER bmiHeader;
 11168 	  BITMAPINFOHEADER bmiHeader;
 11169           DWORD r;
 11169 	  DWORD r;
 11170           DWORD g;
 11170 	  DWORD g;
 11171           DWORD b;
 11171 	  DWORD b;
 11172           DWORD a;
 11172 	  DWORD a;
 11173         } bitmap;
 11173 	} bitmap;
 11174         int _padd = __intVal(padd);
 11174 	int _padd = __intVal(padd);
 11175 
 11175 
 11176         gcData = _GCDATA(aGCId);
 11176 	gcData = _GCDATA(aGCId);
 11177         if (! gcData )
 11177 	if (! gcData )
 11178             goto fail;
 11178 	    goto fail;
 11179         hDC = _getDC(gcData);
 11179 	hDC = _getDC(gcData);
 11180         DDDDPRINTF(("hDC = %x\n", hDC));
 11180 	DDDDPRINTF(("hDC = %x\n", hDC));
 11181 
 11181 
 11182         if (_padd != WIN32PADDING) {
 11182 	if (_padd != WIN32PADDING) {
 11183             int row, col;
 11183 	    int row, col;
 11184             unsigned char *cp;
 11184 	    unsigned char *cp;
 11185             unsigned char *pBits;
 11185 	    unsigned char *pBits;
 11186             int b_width, b_height, bytesPerRowST, bytesPerRowWIN, paddingDelta, nBytes;
 11186 	    int b_width, b_height, bytesPerRowST, bytesPerRowWIN, paddingDelta, nBytes;
 11187             int bi = __intVal(bitsPerPixel);
 11187 	    int bi = __intVal(bitsPerPixel);
 11188 
 11188 
 11189             b_width = __intVal(imageWidth);
 11189 	    b_width = __intVal(imageWidth);
 11190             b_height = __intVal(imageHeight);
 11190 	    b_height = __intVal(imageHeight);
 11191 
 11191 
 11192             bytesPerRowST = (b_width * bi + (_padd-1)) / _padd * (_padd / 8);
 11192 	    bytesPerRowST = (b_width * bi + (_padd-1)) / _padd * (_padd / 8);
 11193             bytesPerRowWIN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
 11193 	    bytesPerRowWIN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
 11194             paddingDelta = bytesPerRowWIN - bytesPerRowST;
 11194 	    paddingDelta = bytesPerRowWIN - bytesPerRowST;
 11195             /* console_printf("padd %d bs %d bw %d p %d\n",_padd,bytesPerRowST,bytesPerRowWN,padding); */
 11195 	    /* console_printf("padd %d bs %d bw %d p %d\n",_padd,bytesPerRowST,bytesPerRowWN,padding); */
 11196             if (paddingDelta != 0) {
 11196 	    if (paddingDelta != 0) {
 11197                 nBytes = b_height * bytesPerRowWIN;
 11197 		nBytes = b_height * bytesPerRowWIN;
 11198                 if (nBytes < sizeof(fastBits)) {
 11198 		if (nBytes < sizeof(fastBits)) {
 11199                     cp = b_bits = fastBits;
 11199 		    cp = b_bits = fastBits;
 11200                 } else {
 11200 		} else {
 11201                     cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
 11201 		    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
 11202                 }
 11202 		}
 11203                 if (cp) {
 11203 		if (cp) {
 11204                     pBits = __imageBits;
 11204 		    pBits = __imageBits;
 11205                     for (row = b_height; row; row--) {
 11205 		    for (row = b_height; row; row--) {
 11206                         for (col = bytesPerRowST; col; col--) {
 11206 			for (col = bytesPerRowST; col; col--) {
 11207                             *cp++ = *pBits++;
 11207 			    *cp++ = *pBits++;
 11208                         }
 11208 			}
 11209                         cp += paddingDelta;
 11209 			cp += paddingDelta;
 11210                     }
 11210 		    }
 11211                 } else
 11211 		} else
 11212                     goto fail;
 11212 		    goto fail;
 11213             }
 11213 	    }
 11214         }
 11214 	}
 11215 
 11215 
 11216         if (b_bits == 0) {
 11216 	if (b_bits == 0) {
 11217             b_bits = __imageBits;
 11217 	    b_bits = __imageBits;
 11218         }
 11218 	}
 11219 
 11219 
 11220         bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 11220 	bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 11221         bitmap.bmiHeader.biPlanes = 1;
 11221 	bitmap.bmiHeader.biPlanes = 1;
 11222         switch (__intVal(imageDepth)) {
 11222 	switch (__intVal(imageDepth)) {
 11223             case 16:
 11223 	    case 16:
 11224                 // BI_BITFIELDS is only possible with 16 and 32 bit images
 11224 		// BI_BITFIELDS is only possible with 16 and 32 bit images
 11225                 // (see msdn.microoft.com/library/cc250415.aspx)
 11225 		// (see msdn.microoft.com/library/cc250415.aspx)
 11226 
 11226 
 11227                 // notice the default r/g/b (STX order here)
 11227 		// notice the default r/g/b (STX order here)
 11228                 bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 11228 		bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 11229                 bitmap.r = redMask == nil ? 0xf800 : __intVal(redMask);
 11229 		bitmap.r = redMask == nil ? 0xf800 : __intVal(redMask);
 11230                 bitmap.g = greenMask == nil ? 0x07e0 : __intVal(greenMask);
 11230 		bitmap.g = greenMask == nil ? 0x07e0 : __intVal(greenMask);
 11231                 bitmap.b = blueMask == nil ? 0x001f : __intVal(blueMask);
 11231 		bitmap.b = blueMask == nil ? 0x001f : __intVal(blueMask);
 11232                 break;
 11232 		break;
 11233 
 11233 
 11234             case 24:
 11234 	    case 24:
 11235                 // BI_BITFIELDS is only possible with 16 and 32 bit images
 11235 		// BI_BITFIELDS is only possible with 16 and 32 bit images
 11236                 // (see msdn.microoft.com/library/cc250415.aspx)
 11236 		// (see msdn.microoft.com/library/cc250415.aspx)
 11237 
 11237 
 11238                 // notice the default b/g/r (WIN32 order here)
 11238 		// notice the default b/g/r (WIN32 order here)
 11239                 bitmap.bmiHeader.biCompression = BI_RGB;
 11239 		bitmap.bmiHeader.biCompression = BI_RGB;
 11240                 break;
 11240 		break;
 11241 
 11241 
 11242             case 32:
 11242 	    case 32:
 11243                 // BI_BITFIELDS is only possible with 16 and 32 bit images
 11243 		// BI_BITFIELDS is only possible with 16 and 32 bit images
 11244                 // (see msdn.microoft.com/library/cc250415.aspx)
 11244 		// (see msdn.microoft.com/library/cc250415.aspx)
 11245 
 11245 
 11246                 // notice the default r/g/b (STX order here)
 11246 		// notice the default r/g/b (STX order here)
 11247                 bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 11247 		bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 11248                 bitmap.r = redMask == nil ? 0x0000ff : __intVal(redMask);
 11248 		bitmap.r = redMask == nil ? 0x0000ff : __intVal(redMask);
 11249                 bitmap.g = greenMask == nil ? 0x00ff00 : __intVal(greenMask);
 11249 		bitmap.g = greenMask == nil ? 0x00ff00 : __intVal(greenMask);
 11250                 bitmap.b = blueMask == nil ? 0xff0000 : __intVal(blueMask);
 11250 		bitmap.b = blueMask == nil ? 0xff0000 : __intVal(blueMask);
 11251                 bitmap.a = 0xff000000;
 11251 		bitmap.a = 0xff000000;
 11252                 break;
 11252 		break;
 11253         }
 11253 	}
 11254 
 11254 
 11255         if (sourceAlphaOrNil != nil) {
 11255 	if (sourceAlphaOrNil != nil) {
 11256             DPRINTF(("sourceAlphaOrNil = %x\n", sourceAlphaOrNil));
 11256 	    DPRINTF(("sourceAlphaOrNil = %x\n", sourceAlphaOrNil));
 11257             _sourceAlpha = __intVal(sourceAlphaOrNil);
 11257 	    _sourceAlpha = __intVal(sourceAlphaOrNil);
 11258             _doAlphaBlend = 1;
 11258 	    _doAlphaBlend = 1;
 11259         }
 11259 	}
 11260 
 11260 
 11261         bitmap.bmiHeader.biSizeImage = 0;
 11261 	bitmap.bmiHeader.biSizeImage = 0;
 11262         bitmap.bmiHeader.biXPelsPerMeter = 0;
 11262 	bitmap.bmiHeader.biXPelsPerMeter = 0;
 11263         bitmap.bmiHeader.biYPelsPerMeter = 0;
 11263 	bitmap.bmiHeader.biYPelsPerMeter = 0;
 11264         bitmap.bmiHeader.biClrUsed = 0;
 11264 	bitmap.bmiHeader.biClrUsed = 0;
 11265         bitmap.bmiHeader.biClrImportant = 0;
 11265 	bitmap.bmiHeader.biClrImportant = 0;
 11266         bitmap.bmiHeader.biWidth = __intVal(imageWidth);
 11266 	bitmap.bmiHeader.biWidth = __intVal(imageWidth);
 11267         bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
 11267 	bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
 11268         bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
 11268 	bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
 11269         DPRINTF(("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight));
 11269 	DPRINTF(("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight));
 11270 
 11270 
 11271         if (! _doAlphaBlend) {
 11271 	if (! _doAlphaBlend) {
 11272             // normal draw (no alpha)
 11272 	    // normal draw (no alpha)
 11273 
 11273 
 11274             SetDIBitsToDevice(hDC,
 11274 	    SetDIBitsToDevice(hDC,
 11275                                 __intVal(dstx), __intVal(dsty),
 11275 				__intVal(dstx), __intVal(dsty),
 11276                                 __intVal(w), __intVal(h),
 11276 				__intVal(w), __intVal(h),
 11277                                 __intVal(srcx), __intVal(srcy),
 11277 				__intVal(srcx), __intVal(srcy),
 11278                                 0, __intVal(h),
 11278 				0, __intVal(h),
 11279                                 (void *)b_bits,
 11279 				(void *)b_bits,
 11280                                 (BITMAPINFO*)&bitmap,
 11280 				(BITMAPINFO*)&bitmap,
 11281                                 DIB_RGB_COLORS);
 11281 				DIB_RGB_COLORS);
 11282         } else {
 11282 	} else {
 11283             // alpha blending
 11283 	    // alpha blending
 11284 
 11284 
 11285             HDC ahdc;
 11285 	    HDC ahdc;
 11286             HBITMAP ahbitmap;
 11286 	    HBITMAP ahbitmap;
 11287             void *pvBits;
 11287 	    void *pvBits;
 11288             BLENDFUNCTION bf;
 11288 	    BLENDFUNCTION bf;
 11289             static BOOL (__stdcall *P_AlphaBlend)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION );
 11289 	    static BOOL (__stdcall *P_AlphaBlend)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION );
 11290 
 11290 
 11291             if (P_AlphaBlend == 0) {
 11291 	    if (P_AlphaBlend == 0) {
 11292                 /* as I don't have AlphaBlend in the inport32.lib (bcc sucks),
 11292 		/* as I don't have AlphaBlend in the inport32.lib (bcc sucks),
 11293                  * fetch its address dynamically...
 11293 		 * fetch its address dynamically...
 11294                  */
 11294 		 */
 11295                 HINSTANCE hWinGDI = LoadLibrary("msimg32.dll");
 11295 		HINSTANCE hWinGDI = LoadLibrary("msimg32.dll");
 11296                 if (hWinGDI) {
 11296 		if (hWinGDI) {
 11297                     P_AlphaBlend = (BOOL (__stdcall *)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION ))
 11297 		    P_AlphaBlend = (BOOL (__stdcall *)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION ))
 11298                                         GetProcAddress(hWinGDI, "AlphaBlend");
 11298 					GetProcAddress(hWinGDI, "AlphaBlend");
 11299                 }
 11299 		}
 11300             }
 11300 	    }
 11301             if (P_AlphaBlend != 0) {
 11301 	    if (P_AlphaBlend != 0) {
 11302                 DPRINTF(("***********************************\n"));
 11302 		DPRINTF(("***********************************\n"));
 11303                 DPRINTF(("_sourceAlpha = %d\n", _sourceAlpha));
 11303 		DPRINTF(("_sourceAlpha = %d\n", _sourceAlpha));
 11304 
 11304 
 11305                 ahdc = CreateCompatibleDC(hDC);
 11305 		ahdc = CreateCompatibleDC(hDC);
 11306 
 11306 
 11307                 ahbitmap = CreateCompatibleBitmap(hDC, __intVal(imageWidth), __intVal(imageHeight));
 11307 		ahbitmap = CreateCompatibleBitmap(hDC, __intVal(imageWidth), __intVal(imageHeight));
 11308                 SelectObject(ahdc, ahbitmap);
 11308 		SelectObject(ahdc, ahbitmap);
 11309                 SetDIBitsToDevice(ahdc,
 11309 		SetDIBitsToDevice(ahdc,
 11310                                 0, 0,    /* dstx, dsty */
 11310 				0, 0,    /* dstx, dsty */
 11311                                 __intVal(imageWidth), __intVal(imageHeight),
 11311 				__intVal(imageWidth), __intVal(imageHeight),
 11312                                 __intVal(srcx), __intVal(srcy),
 11312 				__intVal(srcx), __intVal(srcy),
 11313                                 0, __intVal(imageHeight),
 11313 				0, __intVal(imageHeight),
 11314                                 (void *)b_bits,
 11314 				(void *)b_bits,
 11315                                 (BITMAPINFO*)&bitmap,
 11315 				(BITMAPINFO*)&bitmap,
 11316                                 DIB_RGB_COLORS);
 11316 				DIB_RGB_COLORS);
 11317 
 11317 
 11318                 bf.BlendOp = AC_SRC_OVER;
 11318 		bf.BlendOp = AC_SRC_OVER;
 11319                 bf.BlendFlags = 0;
 11319 		bf.BlendFlags = 0;
 11320                 bf.SourceConstantAlpha = _sourceAlpha;
 11320 		bf.SourceConstantAlpha = _sourceAlpha;
 11321                 bf.AlphaFormat = AC_SRC_ALPHA;
 11321 		bf.AlphaFormat = AC_SRC_ALPHA;
 11322 #if 1
 11322 #if 1
 11323                 (*P_AlphaBlend) (hDC,
 11323 		(*P_AlphaBlend) (hDC,
 11324                                 __intVal(dstx), __intVal(dsty),
 11324 				__intVal(dstx), __intVal(dsty),
 11325                                 __intVal(imageWidth), __intVal(imageHeight),
 11325 				__intVal(imageWidth), __intVal(imageHeight),
 11326                                 ahdc,
 11326 				ahdc,
 11327                                 0, 0,     /* srcx, srcy */
 11327 				0, 0,     /* srcx, srcy */
 11328                                 __intVal(imageWidth), __intVal(imageHeight),
 11328 				__intVal(imageWidth), __intVal(imageHeight),
 11329                                 bf);
 11329 				bf);
 11330 #else
 11330 #else
 11331                 bf.SourceConstantAlpha = 255-_sourceAlpha;
 11331 		bf.SourceConstantAlpha = 255-_sourceAlpha;
 11332                 bf.AlphaFormat = 0;
 11332 		bf.AlphaFormat = 0;
 11333                 bf.BlendOp = 0;
 11333 		bf.BlendOp = 0;
 11334                 (*P_AlphaBlend) (ahdc,
 11334 		(*P_AlphaBlend) (ahdc,
 11335                                 0, 0,     /* dstx, dsty */
 11335 				0, 0,     /* dstx, dsty */
 11336                                 __intVal(imageWidth), __intVal(imageHeight),
 11336 				__intVal(imageWidth), __intVal(imageHeight),
 11337                                 hDC,
 11337 				hDC,
 11338                                 __intVal(dstx), __intVal(dsty),   /* srcx, srcy */
 11338 				__intVal(dstx), __intVal(dsty),   /* srcx, srcy */
 11339                                 __intVal(imageWidth), __intVal(imageHeight),
 11339 				__intVal(imageWidth), __intVal(imageHeight),
 11340                                 bf);
 11340 				bf);
 11341 
 11341 
 11342                 BitBlt (hDC,
 11342 		BitBlt (hDC,
 11343                                 __intVal(dstx), __intVal(dsty),
 11343 				__intVal(dstx), __intVal(dsty),
 11344                                 __intVal(imageWidth), __intVal(imageHeight),
 11344 				__intVal(imageWidth), __intVal(imageHeight),
 11345                                 ahdc,
 11345 				ahdc,
 11346                                 0, 0,   /* srcx, srcy */
 11346 				0, 0,   /* srcx, srcy */
 11347                                 SRCCOPY);
 11347 				SRCCOPY);
 11348 #endif
 11348 #endif
 11349                 DeleteObject(ahbitmap);
 11349 		DeleteObject(ahbitmap);
 11350                 DeleteDC(ahdc);
 11350 		DeleteDC(ahdc);
 11351             }
 11351 	    }
 11352         }
 11352 	}
 11353         if (allocatedBits) {
 11353 	if (allocatedBits) {
 11354             free(allocatedBits);
 11354 	    free(allocatedBits);
 11355         }
 11355 	}
 11356 #ifndef CACHE_LAST_DC
 11356 #ifndef CACHE_LAST_DC
 11357         _releaseDC(gcData);
 11357 	_releaseDC(gcData);
 11358 #endif
 11358 #endif
 11359         RETURN ( true );
 11359 	RETURN ( true );
 11360     }
 11360     }
 11361 
 11361 
 11362 fail: ;
 11362 fail: ;
 11363     PRINTF(("create temp bitmap FAILED!!!\n"));
 11363     PRINTF(("create temp bitmap FAILED!!!\n"));
 11364     if (allocatedBits) {
 11364     if (allocatedBits) {
 11365         PRINTF(("freeing up temp bitmap bits ...\n"));
 11365 	PRINTF(("freeing up temp bitmap bits ...\n"));
 11366         free(allocatedBits);
 11366 	free(allocatedBits);
 11367     }
 11367     }
 11368 #ifndef CACHE_LAST_DC
 11368 #ifndef CACHE_LAST_DC
 11369     if (hDC) {
 11369     if (hDC) {
 11370         _releaseDC(gcData);
 11370 	_releaseDC(gcData);
 11371     }
 11371     }
 11372 #endif
 11372 #endif
 11373 %}
 11373 %}
 11374 .
 11374 .
 11375     ^ false
 11375     ^ false
 11381     OBJ point, px, py;
 11381     OBJ point, px, py;
 11382     int i, num;
 11382     int i, num;
 11383 
 11383 
 11384     if (__isExternalAddress(aGCId)
 11384     if (__isExternalAddress(aGCId)
 11385      && __isSmallInteger(numberOfPoints)) {
 11385      && __isSmallInteger(numberOfPoints)) {
 11386         struct gcData *gcData = _GCDATA(aGCId);
 11386 	struct gcData *gcData = _GCDATA(aGCId);
 11387         HDC hDC;
 11387 	HDC hDC;
 11388         POINT p;
 11388 	POINT p;
 11389         HBRUSH hBrush;
 11389 	HBRUSH hBrush;
 11390 
 11390 
 11391         num = __intVal(numberOfPoints);
 11391 	num = __intVal(numberOfPoints);
 11392         if (num < 3) {
 11392 	if (num < 3) {
 11393             RETURN ( self );
 11393 	    RETURN ( self );
 11394         }
 11394 	}
 11395         for (i=0; i<num; i++) {
 11395 	for (i=0; i<num; i++) {
 11396             point = __AT_(aPolygon, __MKSMALLINT(i+1));
 11396 	    point = __AT_(aPolygon, __MKSMALLINT(i+1));
 11397             if (! __isPoint(point)) goto fail;
 11397 	    if (! __isPoint(point)) goto fail;
 11398             px = _point_X(point);
 11398 	    px = _point_X(point);
 11399             py = _point_Y(point);
 11399 	    py = _point_Y(point);
 11400             if (! __bothSmallInteger(px, py))
 11400 	    if (! __bothSmallInteger(px, py))
 11401                 goto fail;
 11401 		goto fail;
 11402         }
 11402 	}
 11403 
 11403 
 11404         hDC = _getDC(gcData);
 11404 	hDC = _getDC(gcData);
 11405 
 11405 
 11406         hBrush = GcDataGetBrush(hDC,gcData);
 11406 	hBrush = GcDataGetBrush(hDC,gcData);
 11407         if (hBrush == 0) {
 11407 	if (hBrush == 0) {
 11408             DPRINTF(("fillPolygon: no brush\n"));
 11408 	    DPRINTF(("fillPolygon: no brush\n"));
 11409         } else {
 11409 	} else {
 11410             HPEN prevPen;
 11410 	    HPEN prevPen;
 11411 
 11411 
 11412             prevPen = SelectObject(hDC, __nullPen);
 11412 	    prevPen = SelectObject(hDC, __nullPen);
 11413 
 11413 
 11414             BeginPath(hDC);
 11414 	    BeginPath(hDC);
 11415 
 11415 
 11416             for (i=0; i<num; i++) {
 11416 	    for (i=0; i<num; i++) {
 11417                 point = __AT_(aPolygon, __MKSMALLINT(i+1));
 11417 		point = __AT_(aPolygon, __MKSMALLINT(i+1));
 11418                 px = _point_X(point);
 11418 		px = _point_X(point);
 11419                 py = _point_Y(point);
 11419 		py = _point_Y(point);
 11420                 if (i == 0) {
 11420 		if (i == 0) {
 11421                     MoveToEx(hDC, __intVal(px), __intVal(py), NULL);
 11421 		    MoveToEx(hDC, __intVal(px), __intVal(py), NULL);
 11422                 } else {
 11422 		} else {
 11423                     if (i == (num-1)) {
 11423 		    if (i == (num-1)) {
 11424                         p.x = __intVal(px);
 11424 			p.x = __intVal(px);
 11425                         p.y = __intVal(py);
 11425 			p.y = __intVal(py);
 11426                         PolylineTo(hDC, &p, 1);
 11426 			PolylineTo(hDC, &p, 1);
 11427                     } else {
 11427 		    } else {
 11428                         LineTo(hDC, __intVal(px), __intVal(py));
 11428 			LineTo(hDC, __intVal(px), __intVal(py));
 11429                     }
 11429 		    }
 11430                 }
 11430 		}
 11431             }
 11431 	    }
 11432 
 11432 
 11433             EndPath(hDC);
 11433 	    EndPath(hDC);
 11434             FillPath(hDC);
 11434 	    FillPath(hDC);
 11435             GcDataReleaseBrush(hDC, gcData);
 11435 	    GcDataReleaseBrush(hDC, gcData);
 11436 #ifdef CACHE_LAST_DC
 11436 #ifdef CACHE_LAST_DC
 11437             SelectObject(hDC, prevPen);
 11437 	    SelectObject(hDC, prevPen);
 11438 #endif
 11438 #endif
 11439         }
 11439 	}
 11440 #ifndef CACHE_LAST_DC
 11440 #ifndef CACHE_LAST_DC
 11441         _releaseDC(gcData);
 11441 	_releaseDC(gcData);
 11442 #endif
 11442 #endif
 11443         RETURN ( self );
 11443 	RETURN ( self );
 11444 
 11444 
 11445 fail: ;
 11445 fail: ;
 11446     }
 11446     }
 11447 %}
 11447 %}
 11448 ! !
 11448 ! !
 11452 activate:aBoolean view:aView
 11452 activate:aBoolean view:aView
 11453     "some view was activated/deactivated.
 11453     "some view was activated/deactivated.
 11454      For compatibility we send a focus-event to that topView"
 11454      For compatibility we send a focus-event to that topView"
 11455 
 11455 
 11456     aBoolean ifFalse:[
 11456     aBoolean ifFalse:[
 11457         activeView == aView ifTrue:[
 11457 	activeView == aView ifTrue:[
 11458             activeView := nil.
 11458 	    activeView := nil.
 11459         ].
 11459 	].
 11460         self focusOutView:aView.
 11460 	self focusOutView:aView.
 11461     ] ifTrue:[
 11461     ] ifTrue:[
 11462         activeView := aView.
 11462 	activeView := aView.
 11463         self focusInView:aView.
 11463 	self focusInView:aView.
 11464     ].
 11464     ].
 11465 
 11465 
 11466     "Created: / 28.4.1999 / 14:51:51 / cg"
 11466     "Created: / 28.4.1999 / 14:51:51 / cg"
 11467     "Modified: / 28.4.1999 / 15:07:09 / cg"
 11467     "Modified: / 28.4.1999 / 15:07:09 / cg"
 11468 !
 11468 !
 11469 
 11469 
 11470 configureX:x y:y width:w height:h view:aView
 11470 configureX:x y:y width:w height:h view:aView
 11471     "forward a configure for some view"
 11471     "forward a configure for some view"
 11472 
 11472 
 11473     aView realized ifTrue:[
 11473     aView realized ifTrue:[
 11474         super configureX:x y:y width:w height:h view:aView
 11474 	super configureX:x y:y width:w height:h view:aView
 11475     ]
 11475     ]
 11476 
 11476 
 11477     "Modified: / 08-09-2006 / 19:40:18 / cg"
 11477     "Modified: / 08-09-2006 / 19:40:18 / cg"
 11478 !
 11478 !
 11479 
 11479 
 11480 copyDataEvent:parameter eventData:dataBytes view:aView
 11480 copyDataEvent:parameter eventData:dataBytes view:aView
 11481     "forward a copyData event for some view as a client message"
 11481     "forward a copyData event for some view as a client message"
 11482 
 11482 
 11483     aView isNil ifTrue:[
 11483     aView isNil ifTrue:[
 11484         "/ event arrived, after I destroyed it myself
 11484 	"/ event arrived, after I destroyed it myself
 11485         ^ self
 11485 	^ self
 11486     ].
 11486     ].
 11487     aView sensor
 11487     aView sensor
 11488         copyDataEvent:parameter
 11488 	copyDataEvent:parameter
 11489         eventData:dataBytes
 11489 	eventData:dataBytes
 11490         view:aView
 11490 	view:aView
 11491 !
 11491 !
 11492 
 11492 
 11493 displayChange
 11493 displayChange
 11494     "the display metrics/settings have changed.
 11494     "the display metrics/settings have changed.
 11495      This is a speciality of windows.
 11495      This is a speciality of windows.
 11496      TODO: Tell the viewStyle to update itself,
 11496      TODO: Tell the viewStyle to update itself,
 11497            and tell all views to reinit their style.
 11497 	   and tell all views to reinit their style.
 11498      For now,this is ignored, except for updating my metrics."
 11498      For now,this is ignored, except for updating my metrics."
 11499 
 11499 
 11500     self initializeVariableScreenProperties.
 11500     self initializeVariableScreenProperties.
 11501 !
 11501 !
 11502 
 11502 
 11512 "/    files do:[:f|
 11512 "/    files do:[:f|
 11513 "/        Transcript showCR:('    ', f printString)
 11513 "/        Transcript showCR:('    ', f printString)
 11514 "/    ].
 11514 "/    ].
 11515 "/
 11515 "/
 11516     view isNil ifTrue:[
 11516     view isNil ifTrue:[
 11517         "/ event arrived, after I destroyed it myself
 11517 	"/ event arrived, after I destroyed it myself
 11518         ^ self
 11518 	^ self
 11519     ].
 11519     ].
 11520     view sensor
 11520     view sensor
 11521         dropFiles:files view:view position:dropPosition handle:dropHandle
 11521 	dropFiles:files view:view position:dropPosition handle:dropHandle
 11522 !
 11522 !
 11523 
 11523 
 11524 fontChange
 11524 fontChange
 11525     "the system fonts (users preferences) have changed.
 11525     "the system fonts (users preferences) have changed.
 11526      This is a speciality of windows.
 11526      This is a speciality of windows.
 11527      TODO: Tell the viewStyle to update itself,
 11527      TODO: Tell the viewStyle to update itself,
 11528            and tell all views to reinit their style.
 11528 	   and tell all views to reinit their style.
 11529      For now,this is ignored."
 11529      For now,this is ignored."
 11530 
 11530 
 11531     IgnoreFontChanges ~~ true ifTrue:[
 11531     IgnoreFontChanges ~~ true ifTrue:[
 11532 "/        'WinWorkstation [info]: fontChange ignored for now.' infoPrintCR
 11532 "/        'WinWorkstation [info]: fontChange ignored for now.' infoPrintCR
 11533     ]
 11533     ]
 11542      and pass that one down (used to be the focus view, but that is inconvenient)."
 11542      and pass that one down (used to be the focus view, but that is inconvenient)."
 11543 
 11543 
 11544     |wg screenPoint targetView|
 11544     |wg screenPoint targetView|
 11545 
 11545 
 11546     aView isNil ifTrue:[
 11546     aView isNil ifTrue:[
 11547         "/ event arrived, after I destroyed it myself
 11547 	"/ event arrived, after I destroyed it myself
 11548         ^ self
 11548 	^ self
 11549     ].
 11549     ].
 11550 
 11550 
 11551     UserPreferences current mouseWheelFocusFollowsMouse ifTrue:[
 11551     UserPreferences current mouseWheelFocusFollowsMouse ifTrue:[
 11552         screenPoint := self translatePointToRoot:(x@y) fromView:aView.
 11552 	screenPoint := self translatePointToRoot:(x@y) fromView:aView.
 11553         targetView := self viewFromPoint:screenPoint.
 11553 	targetView := self viewFromPoint:screenPoint.
 11554     ].
 11554     ].
 11555 
 11555 
 11556     (targetView isNil) ifTrue:[
 11556     (targetView isNil) ifTrue:[
 11557         (wg := aView windowGroup) notNil ifTrue:[
 11557 	(wg := aView windowGroup) notNil ifTrue:[
 11558             targetView := wg focusView.
 11558 	    targetView := wg focusView.
 11559         ].
 11559 	].
 11560     ].
 11560     ].
 11561 
 11561 
 11562     aView sensor
 11562     aView sensor
 11563         mouseWheelMotion:buttonState x:x y:y amount:amount deltaTime:dTime
 11563 	mouseWheelMotion:buttonState x:x y:y amount:amount deltaTime:dTime
 11564         view:(targetView ? aView)
 11564 	view:(targetView ? aView)
 11565 
 11565 
 11566     "Modified: / 21.5.1999 / 13:05:53 / cg"
 11566     "Modified: / 21.5.1999 / 13:05:53 / cg"
 11567 !
 11567 !
 11568 
 11568 
 11569 nativeWidgetCommand:commandId view:aView
 11569 nativeWidgetCommand:commandId view:aView
 11571      (Button, CheckBox etc.)"
 11571      (Button, CheckBox etc.)"
 11572 
 11572 
 11573     |sensor|
 11573     |sensor|
 11574 
 11574 
 11575     aView isNil ifTrue:[
 11575     aView isNil ifTrue:[
 11576         "/ event arrived, after I destroyed it myself
 11576 	"/ event arrived, after I destroyed it myself
 11577         ^ self
 11577 	^ self
 11578     ].
 11578     ].
 11579     sensor := aView sensor.
 11579     sensor := aView sensor.
 11580     sensor
 11580     sensor
 11581         nativeWidgetCommand:#'win32nativeWMCommand:'
 11581 	nativeWidgetCommand:#'win32nativeWMCommand:'
 11582         arguments:(Array with:commandId)
 11582 	arguments:(Array with:commandId)
 11583         view:aView
 11583 	view:aView
 11584 !
 11584 !
 11585 
 11585 
 11586 queryEndSession
 11586 queryEndSession
 11587     "system is about to be shut down.
 11587     "system is about to be shut down.
 11588      This is a speciality of windows.
 11588      This is a speciality of windows.
 11610      The argument, aWindow is not used."
 11610      The argument, aWindow is not used."
 11611 
 11611 
 11612     |anyChange|
 11612     |anyChange|
 11613 
 11613 
 11614     IgnoreSysColorChanges ifFalse:[
 11614     IgnoreSysColorChanges ifFalse:[
 11615         "/ first check, if there was really a change of any color that
 11615 	"/ first check, if there was really a change of any color that
 11616         "/ we are interested in
 11616 	"/ we are interested in
 11617         "/ (when exceed is running, we get plenty of those messages ...)
 11617 	"/ (when exceed is running, we get plenty of those messages ...)
 11618 
 11618 
 11619         anyChange := false.
 11619 	anyChange := false.
 11620         SystemColorValues synchronized:[
 11620 	SystemColorValues synchronized:[
 11621             SystemColorValues copy keysAndValuesDo:[:eachKey :eachOldColor|
 11621 	    SystemColorValues copy keysAndValuesDo:[:eachKey :eachOldColor|
 11622                 |newColor|
 11622 		|newColor|
 11623 
 11623 
 11624                 newColor := self primGetSystemColor:eachKey.
 11624 		newColor := self primGetSystemColor:eachKey.
 11625                 newColor ~= eachOldColor ifTrue:[
 11625 		newColor ~= eachOldColor ifTrue:[
 11626                     SystemColorValues at:eachKey put:newColor.
 11626 		    SystemColorValues at:eachKey put:newColor.
 11627                     anyChange := true.
 11627 		    anyChange := true.
 11628                 ].
 11628 		].
 11629             ].
 11629 	    ].
 11630             anyChange ifTrue:[
 11630 	    anyChange ifTrue:[
 11631                 SimpleView readStyleSheetAndUpdateAllStyleCaches.
 11631 		SimpleView readStyleSheetAndUpdateAllStyleCaches.
 11632                 "/ TODO: this should go through the sensor ...
 11632 		"/ TODO: this should go through the sensor ...
 11633                 "/ ...and be handled as an event by the views thread.
 11633 		"/ ...and be handled as an event by the views thread.
 11634                 self allViewsDo:[:eachView| eachView reinitStyle].
 11634 		self allViewsDo:[:eachView| eachView reinitStyle].
 11635             ].
 11635 	    ].
 11636         ].
 11636 	].
 11637     ]
 11637     ]
 11638 
 11638 
 11639     "
 11639     "
 11640         Display systemColorChange:nil
 11640 	Display systemColorChange:nil
 11641     "
 11641     "
 11642 !
 11642 !
 11643 
 11643 
 11644 trayAction:eventCode view:aView
 11644 trayAction:eventCode view:aView
 11645     "forward a tray event for some view."
 11645     "forward a tray event for some view."
 11646 
 11646 
 11647     |sensor message arg|
 11647     |sensor message arg|
 11648 
 11648 
 11649     aView isNil ifTrue:[
 11649     aView isNil ifTrue:[
 11650         "/ event arrived, after I destroyed it myself
 11650 	"/ event arrived, after I destroyed it myself
 11651         ^ self
 11651 	^ self
 11652     ].
 11652     ].
 11653 
 11653 
 11654     eventCode == 512 "WM_MOUSEMOVE" ifTrue:[
 11654     eventCode == 512 "WM_MOUSEMOVE" ifTrue:[
 11655         "/ mouse motion
 11655 	"/ mouse motion
 11656         message := #trayMouseMotion
 11656 	message := #trayMouseMotion
 11657     ].
 11657     ].
 11658     eventCode == 513 "WM_LBUTTONDOWN" ifTrue:[
 11658     eventCode == 513 "WM_LBUTTONDOWN" ifTrue:[
 11659         "/ left-button-press
 11659 	"/ left-button-press
 11660         message := #trayButtonPress:.
 11660 	message := #trayButtonPress:.
 11661         arg := 1.
 11661 	arg := 1.
 11662     ].
 11662     ].
 11663     eventCode == 514 "WM_LBUTTONUP" ifTrue:[
 11663     eventCode == 514 "WM_LBUTTONUP" ifTrue:[
 11664         "/ left-button-release
 11664 	"/ left-button-release
 11665         message := #trayButtonRelease:.
 11665 	message := #trayButtonRelease:.
 11666         arg := 1.
 11666 	arg := 1.
 11667     ].
 11667     ].
 11668     eventCode == 515 "WM_LBUTTONDBLCLK" ifTrue:[
 11668     eventCode == 515 "WM_LBUTTONDBLCLK" ifTrue:[
 11669         "/ left-button-double-click
 11669 	"/ left-button-double-click
 11670         message := #trayButtonDoubleClick:.
 11670 	message := #trayButtonDoubleClick:.
 11671         arg := 1.
 11671 	arg := 1.
 11672     ].
 11672     ].
 11673     eventCode == 516 "WM_RBUTTONDOWN" ifTrue:[
 11673     eventCode == 516 "WM_RBUTTONDOWN" ifTrue:[
 11674         "/ right-button-press
 11674 	"/ right-button-press
 11675         message := #trayButtonPress:.
 11675 	message := #trayButtonPress:.
 11676         arg := 3.
 11676 	arg := 3.
 11677     ].
 11677     ].
 11678     eventCode == 517 "WM_RBUTTONUP" ifTrue:[
 11678     eventCode == 517 "WM_RBUTTONUP" ifTrue:[
 11679         "/ right-button-release
 11679 	"/ right-button-release
 11680         message := #trayButtonRelease:.
 11680 	message := #trayButtonRelease:.
 11681         arg := 3.
 11681 	arg := 3.
 11682     ].
 11682     ].
 11683     eventCode == 518 "WM_RBUTTONDBLCLK" ifTrue:[
 11683     eventCode == 518 "WM_RBUTTONDBLCLK" ifTrue:[
 11684         "/ left-button-double-click
 11684 	"/ left-button-double-click
 11685         message := #trayButtonDoubleClick:.
 11685 	message := #trayButtonDoubleClick:.
 11686         arg := 3.
 11686 	arg := 3.
 11687     ].
 11687     ].
 11688     eventCode == 519 "WM_MBUTTONDOWN" ifTrue:[
 11688     eventCode == 519 "WM_MBUTTONDOWN" ifTrue:[
 11689         "/ middle-button-press
 11689 	"/ middle-button-press
 11690         message := #trayButtonPress:.
 11690 	message := #trayButtonPress:.
 11691         arg := 2.
 11691 	arg := 2.
 11692     ].
 11692     ].
 11693     eventCode == 520 "WM_MBUTTONUP" ifTrue:[
 11693     eventCode == 520 "WM_MBUTTONUP" ifTrue:[
 11694         "/ middle-button-release
 11694 	"/ middle-button-release
 11695         message := #trayButtonRelease:.
 11695 	message := #trayButtonRelease:.
 11696         arg := 2.
 11696 	arg := 2.
 11697     ].
 11697     ].
 11698     eventCode == 521 "WM_MBUTTONDBLCLK" ifTrue:[
 11698     eventCode == 521 "WM_MBUTTONDBLCLK" ifTrue:[
 11699         "/ middle-button-double-click
 11699 	"/ middle-button-double-click
 11700         message := #trayButtonDoubleClick:.
 11700 	message := #trayButtonDoubleClick:.
 11701         arg := 2.
 11701 	arg := 2.
 11702     ].
 11702     ].
 11703 
 11703 
 11704     message isNil ifTrue:[
 11704     message isNil ifTrue:[
 11705         Transcript showCR:eventCode.
 11705 	Transcript showCR:eventCode.
 11706         ^ self.
 11706 	^ self.
 11707     ].
 11707     ].
 11708 
 11708 
 11709     sensor := aView sensor.
 11709     sensor := aView sensor.
 11710     sensor
 11710     sensor
 11711         trayAction:message
 11711 	trayAction:message
 11712         arguments:(Array with:arg)
 11712 	arguments:(Array with:arg)
 11713         view:aView
 11713 	view:aView
 11714 
 11714 
 11715     "Created: / 31-10-2007 / 00:13:31 / cg"
 11715     "Created: / 31-10-2007 / 00:13:31 / cg"
 11716     "Modified: / 05-11-2007 / 12:14:28 / cg"
 11716     "Modified: / 05-11-2007 / 12:14:28 / cg"
 11717 ! !
 11717 ! !
 11718 
 11718 
 11720 
 11720 
 11721 win32NativeScroll:scrollCode position:newPos view:aScrollBar
 11721 win32NativeScroll:scrollCode position:newPos view:aScrollBar
 11722     "native scrollbar widget event."
 11722     "native scrollbar widget event."
 11723 
 11723 
 11724     aScrollBar isNil ifTrue:[
 11724     aScrollBar isNil ifTrue:[
 11725         "/ event arrived, after I destroyed it myself
 11725 	"/ event arrived, after I destroyed it myself
 11726         ^ self
 11726 	^ self
 11727     ].
 11727     ].
 11728 
 11728 
 11729     self class debugNative ifTrue:[
 11729     self class debugNative ifTrue:[
 11730         'WinWorkstation [info]: native scroll event' infoPrint.
 11730 	'WinWorkstation [info]: native scroll event' infoPrint.
 11731             ' code=' infoPrint.
 11731 	    ' code=' infoPrint.
 11732             scrollCode infoPrint.
 11732 	    scrollCode infoPrint.
 11733             ' position=' infoPrint.
 11733 	    ' position=' infoPrint.
 11734             newPos infoPrintCR.
 11734 	    newPos infoPrintCR.
 11735     ].
 11735     ].
 11736 
 11736 
 11737     aScrollBar sensor
 11737     aScrollBar sensor
 11738         nativeWidgetCommand:#win32NativeScroll:position:
 11738 	nativeWidgetCommand:#win32NativeScroll:position:
 11739         arguments:(Array with:scrollCode with:newPos) view:aScrollBar
 11739 	arguments:(Array with:scrollCode with:newPos) view:aScrollBar
 11740 ! !
 11740 ! !
 11741 
 11741 
 11742 !WinWorkstation methodsFor:'event handling'!
 11742 !WinWorkstation methodsFor:'event handling'!
 11743 
 11743 
 11744 dispatchEventFor:aViewIdOrNil withMask:eventMask
 11744 dispatchEventFor:aViewIdOrNil withMask:eventMask
 11747      If the argument aViewIdOrNil is nil, events for any view are processed,
 11747      If the argument aViewIdOrNil is nil, events for any view are processed,
 11748      otherwise only events for the view with given id are processed.
 11748      otherwise only events for the view with given id are processed.
 11749      If the argument aMask is nonNil, only events for this eventMask are
 11749      If the argument aMask is nonNil, only events for this eventMask are
 11750      handled.
 11750      handled.
 11751      WARNING: this may block to wait for an event - you better check for a
 11751      WARNING: this may block to wait for an event - you better check for a
 11752               pending event before calling this."
 11752 	      pending event before calling this."
 11753 
 11753 
 11754     (self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[
 11754     (self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[
 11755         AbortOperationRequest handle:[:ex |
 11755 	AbortOperationRequest handle:[:ex |
 11756             ex return
 11756 	    ex return
 11757         ] do:[
 11757 	] do:[
 11758             self dispatchLastEvent.
 11758 	    self dispatchLastEvent.
 11759         ]
 11759 	]
 11760     ].
 11760     ].
 11761 
 11761 
 11762     "Modified: 19.8.1997 / 17:10:42 / cg"
 11762     "Modified: 19.8.1997 / 17:10:42 / cg"
 11763 !
 11763 !
 11764 
 11764 
 11830     DDDPRINTF(("dispatchLast\n"));
 11830     DDDPRINTF(("dispatchLast\n"));
 11831 
 11831 
 11832     eB = __INST(eventBuffer);
 11832     eB = __INST(eventBuffer);
 11833 
 11833 
 11834     if (__isByteArray(eB)) {
 11834     if (__isByteArray(eB)) {
 11835         ev = (struct queuedEvent *)(__ByteArrayInstPtr(eB)->ba_element);
 11835 	ev = (struct queuedEvent *)(__ByteArrayInstPtr(eB)->ba_element);
 11836     } else {
 11836     } else {
 11837         console_fprintf(stderr, "WinWorkstation [error]: no eventBuffer\n");
 11837 	console_fprintf(stderr, "WinWorkstation [error]: no eventBuffer\n");
 11838         RETURN (false);
 11838 	RETURN (false);
 11839     }
 11839     }
 11840     if (ev) {
 11840     if (ev) {
 11841         _ev_buf = *ev;
 11841 	_ev_buf = *ev;
 11842         ev = &_ev_buf;
 11842 	ev = &_ev_buf;
 11843     }
 11843     }
 11844     hWnd = ev->ev_hWnd;
 11844     hWnd = ev->ev_hWnd;
 11845     if (!(hWnd /*&& IsWindow(hWnd)*/)) {
 11845     if (!(hWnd /*&& IsWindow(hWnd)*/)) {
 11846         DPRINTF(("wrong hWnd in event in dispatchLastEvent\n"));
 11846 	DPRINTF(("wrong hWnd in event in dispatchLastEvent\n"));
 11847         RETURN (false);
 11847 	RETURN (false);
 11848     }
 11848     }
 11849     {
 11849     {
 11850         OBJ t = __INST(lastId);
 11850 	OBJ t = __INST(lastId);
 11851 
 11851 
 11852         /*
 11852 	/*
 11853          * very often, its another event for the same view ...
 11853 	 * very often, its another event for the same view ...
 11854          * avoid creation & lookup then.
 11854 	 * avoid creation & lookup then.
 11855          */
 11855 	 */
 11856         if (__isExternalAddress(t) && _HWNDVal(t) == hWnd) {
 11856 	if (__isExternalAddress(t) && _HWNDVal(t) == hWnd) {
 11857             theView = __INST(lastView);
 11857 	    theView = __INST(lastView);
 11858             if (__isNonNilObject(theView) && __qClass(theView) == nil) {
 11858 	    if (__isNonNilObject(theView) && __qClass(theView) == nil) {
 11859                 theView = nil;
 11859 		theView = nil;
 11860             }
 11860 	    }
 11861         }
 11861 	}
 11862 
 11862 
 11863         if (theView == nil) {
 11863 	if (theView == nil) {
 11864             windowID = __MKOBJ(ev->ev_hWnd);
 11864 	    windowID = __MKOBJ(ev->ev_hWnd);
 11865             theView = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, windowID);
 11865 	    theView = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, windowID);
 11866         }
 11866 	}
 11867     }
 11867     }
 11868 
 11868 
 11869     if (theView == nil) {
 11869     if (theView == nil) {
 11870         DPRINTF(("nil view [hWnd=%x msg=0x%x] in dispatchEvent\n",
 11870 	DPRINTF(("nil view [hWnd=%x msg=0x%x] in dispatchEvent\n",
 11871                  ev->ev_hWnd, ev->ev_message));
 11871 		 ev->ev_hWnd, ev->ev_message));
 11872 
 11872 
 11873         RETURN (false);
 11873 	RETURN (false);
 11874     }
 11874     }
 11875 
 11875 
 11876     switch (ev->ev_message) {
 11876     switch (ev->ev_message) {
 11877             DPRINTFIF((__debug_WM_ALL__) , ("message=%d 0x%x wparam=%"_lx_" hwnd=%"_lx_" arg1=%"_lx_")\n",
 11877 	    DPRINTFIF((__debug_WM_ALL__) , ("message=%d 0x%x wparam=%"_lx_" hwnd=%"_lx_" arg1=%"_lx_")\n",
 11878                         ev->ev_message, ev->ev_message, (INT)(ev->ev_wParam), (INT)(ev->ev_hWnd), (INT)(ev->ev_arg1)));
 11878 			ev->ev_message, ev->ev_message, (INT)(ev->ev_wParam), (INT)(ev->ev_hWnd), (INT)(ev->ev_arg1)));
 11879             case WM_WINDOWPOSCHANGED:
 11879 	    case WM_WINDOWPOSCHANGED:
 11880                 {
 11880 		{
 11881                     RECT rct;
 11881 		    RECT rct;
 11882 
 11882 
 11883                     x = ev->ev_x;
 11883 		    x = ev->ev_x;
 11884                     y = ev->ev_y;
 11884 		    y = ev->ev_y;
 11885                     w = ev->ev_w;
 11885 		    w = ev->ev_w;
 11886                     h = ev->ev_h;
 11886 		    h = ev->ev_h;
 11887 
 11887 
 11888                     DPRINTF((">>> WM_WINDOWPOSCHANGED -> configure %d/%d , %d/%d\n", x,y,w,h));
 11888 		    DPRINTF((">>> WM_WINDOWPOSCHANGED -> configure %d/%d , %d/%d\n", x,y,w,h));
 11889 
 11889 
 11890                     (*conf.ilc_func)(self,
 11890 		    (*conf.ilc_func)(self,
 11891                                      @symbol(configureX:y:width:height:view:),
 11891 				     @symbol(configureX:y:width:height:view:),
 11892                                      nil, &conf,
 11892 				     nil, &conf,
 11893                                      __MKSMALLINT(x),
 11893 				     __MKSMALLINT(x),
 11894                                      __MKSMALLINT(y),
 11894 				     __MKSMALLINT(y),
 11895                                      __MKSMALLINT(w),
 11895 				     __MKSMALLINT(w),
 11896                                      __MKSMALLINT(h),
 11896 				     __MKSMALLINT(h),
 11897                                      theView);
 11897 				     theView);
 11898                 }
 11898 		}
 11899                 break;
 11899 		break;
 11900 
 11900 
 11901             case WM_DROPFILES:
 11901 	    case WM_DROPFILES:
 11902                 {
 11902 		{
 11903                     HDROP hDrop = (HDROP) ev->ev_wParam;
 11903 		    HDROP hDrop = (HDROP) ev->ev_wParam;
 11904                     int   count = DragQueryFile( hDrop,0xffffffff,0,0 );
 11904 		    int   count = DragQueryFile( hDrop,0xffffffff,0,0 );
 11905 
 11905 
 11906                     DPRINTFIF((__debug_WM_DROPFILES__ | __debug_WM_ALL__) , ("count=%d hDrop=%x\n", count, hDrop));
 11906 		    DPRINTFIF((__debug_WM_DROPFILES__ | __debug_WM_ALL__) , ("count=%d hDrop=%x\n", count, hDrop));
 11907                     if (count > 0) {
 11907 		    if (count > 0) {
 11908                         OBJ  dropHandle, files, position;
 11908 			OBJ  dropHandle, files, position;
 11909                         char buf[MAXPATH];
 11909 			char buf[MAXPATH];
 11910                         int  i;
 11910 			int  i;
 11911 
 11911 
 11912                         dropHandle = __MKOBJ(hDrop);
 11912 			dropHandle = __MKOBJ(hDrop);
 11913                         __PROTECT__(dropHandle);
 11913 			__PROTECT__(dropHandle);
 11914                         files = __ARRAY_NEW_INT( count );
 11914 			files = __ARRAY_NEW_INT( count );
 11915                         __UNPROTECT__(dropHandle);
 11915 			__UNPROTECT__(dropHandle);
 11916 
 11916 
 11917                         for (i = 0;i < count;i++) {
 11917 			for (i = 0;i < count;i++) {
 11918                             OBJ s;
 11918 			    OBJ s;
 11919 
 11919 
 11920                             DragQueryFile(hDrop,i,buf,sizeof(buf));
 11920 			    DragQueryFile(hDrop,i,buf,sizeof(buf));
 11921                             __PROTECT__(dropHandle);
 11921 			    __PROTECT__(dropHandle);
 11922                             __PROTECT__(files);
 11922 			    __PROTECT__(files);
 11923                             s = __MKSTRING(buf);
 11923 			    s = __MKSTRING(buf);
 11924                             __UNPROTECT__(files);
 11924 			    __UNPROTECT__(files);
 11925                             __UNPROTECT__(dropHandle);
 11925 			    __UNPROTECT__(dropHandle);
 11926                             __ArrayInstPtr(files)->a_element[i] = s; __STORE(files, s);
 11926 			    __ArrayInstPtr(files)->a_element[i] = s; __STORE(files, s);
 11927                         }
 11927 			}
 11928 
 11928 
 11929                         {
 11929 			{
 11930                             POINT pos;
 11930 			    POINT pos;
 11931 
 11931 
 11932                             DragQueryPoint(hDrop, &pos);
 11932 			    DragQueryPoint(hDrop, &pos);
 11933 
 11933 
 11934                             __PROTECT__(dropHandle);
 11934 			    __PROTECT__(dropHandle);
 11935                             __PROTECT__(files);
 11935 			    __PROTECT__(files);
 11936                             position = __MKPOINT_INT(pos.x, pos.y);
 11936 			    position = __MKPOINT_INT(pos.x, pos.y);
 11937                             __UNPROTECT__(files);
 11937 			    __UNPROTECT__(files);
 11938                             __UNPROTECT__(dropHandle);
 11938 			    __UNPROTECT__(dropHandle);
 11939                         }
 11939 			}
 11940 
 11940 
 11941                         (*dropFiles.ilc_func)
 11941 			(*dropFiles.ilc_func)
 11942                             ( self
 11942 			    ( self
 11943                               , @symbol(dropFiles:view:position:handle:)
 11943 			      , @symbol(dropFiles:view:position:handle:)
 11944                               , nil, &dropFiles,
 11944 			      , nil, &dropFiles,
 11945                               files, theView, position, dropHandle
 11945 			      files, theView, position, dropHandle
 11946                             );
 11946 			    );
 11947                     }
 11947 		    }
 11948                 }
 11948 		}
 11949                 break;
 11949 		break;
 11950 
 11950 
 11951             case WM_SHOWWINDOW:
 11951 	    case WM_SHOWWINDOW:
 11952                 if (ev->ev_wParam == TRUE) {
 11952 		if (ev->ev_wParam == TRUE) {
 11953                     DPRINTF((">>> WM_SHOWWINDOW -> mappedView:\n"));
 11953 		    DPRINTF((">>> WM_SHOWWINDOW -> mappedView:\n"));
 11954                     arg = @symbol(unobscured);
 11954 		    arg = @symbol(unobscured);
 11955                     (*vis.ilc_func)(theView,
 11955 		    (*vis.ilc_func)(theView,
 11956                                     @symbol(visibilityChange:),
 11956 				    @symbol(visibilityChange:),
 11957                                     nil, &vis, arg);
 11957 				    nil, &vis, arg);
 11958                     (*map.ilc_func)(self,
 11958 		    (*map.ilc_func)(self,
 11959                                     @symbol(mappedView:),
 11959 				    @symbol(mappedView:),
 11960                                     nil, &map, theView);
 11960 				    nil, &map, theView);
 11961                 } else {
 11961 		} else {
 11962                     DPRINTF((">>> WM_SHOWWINDOW -> unMappedView:\n"));
 11962 		    DPRINTF((">>> WM_SHOWWINDOW -> unMappedView:\n"));
 11963 #if 0
 11963 #if 0
 11964                     arg = @symbol(fullyObscured);
 11964 		    arg = @symbol(fullyObscured);
 11965                     (*vis.ilc_func)(theView,
 11965 		    (*vis.ilc_func)(theView,
 11966                                     @symbol(visibilityChange:),
 11966 				    @symbol(visibilityChange:),
 11967                                     nil, &vis, arg);
 11967 				    nil, &vis, arg);
 11968 #endif
 11968 #endif
 11969                     (*unmap.ilc_func)(self,
 11969 		    (*unmap.ilc_func)(self,
 11970                                       @symbol(unmappedView:),
 11970 				      @symbol(unmappedView:),
 11971                                       nil, &unmap, theView);
 11971 				      nil, &unmap, theView);
 11972                 }
 11972 		}
 11973                 break;
 11973 		break;
 11974 
 11974 
 11975             case __WM_ICONIFIED:
 11975 	    case __WM_ICONIFIED:
 11976                 if (ev->ev_wParam) {
 11976 		if (ev->ev_wParam) {
 11977                     DPRINTF((">>> __WM_ICONIFIED -> unMappedView:\n"));
 11977 		    DPRINTF((">>> __WM_ICONIFIED -> unMappedView:\n"));
 11978 #if 0
 11978 #if 0
 11979                     arg = @symbol(fullyObscured);
 11979 		    arg = @symbol(fullyObscured);
 11980                     (*vis.ilc_func)(theView,
 11980 		    (*vis.ilc_func)(theView,
 11981                                     @symbol(visibilityChange:),
 11981 				    @symbol(visibilityChange:),
 11982                                     nil, &vis, arg);
 11982 				    nil, &vis, arg);
 11983 #endif
 11983 #endif
 11984                     (*unmap.ilc_func)(self,
 11984 		    (*unmap.ilc_func)(self,
 11985                                       @symbol(unmappedView:),
 11985 				      @symbol(unmappedView:),
 11986                                       nil, &unmap, theView);
 11986 				      nil, &unmap, theView);
 11987                 } else {
 11987 		} else {
 11988                     DPRINTF((">>> __WM_DEICONIFIED -> mappedView:\n"));
 11988 		    DPRINTF((">>> __WM_DEICONIFIED -> mappedView:\n"));
 11989                     arg = @symbol(unobscured);
 11989 		    arg = @symbol(unobscured);
 11990                     (*vis.ilc_func)(theView,
 11990 		    (*vis.ilc_func)(theView,
 11991                                     @symbol(visibilityChange:),
 11991 				    @symbol(visibilityChange:),
 11992                                     nil, &vis, arg);
 11992 				    nil, &vis, arg);
 11993                     (*map.ilc_func)(self,
 11993 		    (*map.ilc_func)(self,
 11994                                     @symbol(mappedView:),
 11994 				    @symbol(mappedView:),
 11995                                     nil, &map, theView);
 11995 				    nil, &map, theView);
 11996                 }
 11996 		}
 11997                 break;
 11997 		break;
 11998 
 11998 
 11999             case WM_CLOSE:
 11999 	    case WM_CLOSE:
 12000                 DPRINTF((">>> WM_CLOSE -> terminateView:\n"));
 12000 		DPRINTF((">>> WM_CLOSE -> terminateView:\n"));
 12001                 (*termS.ilc_func)(self,
 12001 		(*termS.ilc_func)(self,
 12002                                   @symbol(terminateView:),
 12002 				  @symbol(terminateView:),
 12003                                   nil, &termS, theView);
 12003 				  nil, &termS, theView);
 12004                 break;
 12004 		break;
 12005 
 12005 
 12006             case WM_DESTROY:
 12006 	    case WM_DESTROY:
 12007                 DPRINTF((">>> WM_DESTROY -> destroyedView\n"));
 12007 		DPRINTF((">>> WM_DESTROY -> destroyedView\n"));
 12008                 (*destr.ilc_func)(self,
 12008 		(*destr.ilc_func)(self,
 12009                                   @symbol(destroyedView:),
 12009 				  @symbol(destroyedView:),
 12010                                   nil, &destr, theView);
 12010 				  nil, &destr, theView);
 12011                 break;
 12011 		break;
 12012 
 12012 
 12013             case WM_ACTIVATE:
 12013 	    case WM_ACTIVATE:
 12014 
 12014 
 12015                 switch (LOWORD(ev->ev_wParam)) {
 12015 		switch (LOWORD(ev->ev_wParam)) {
 12016                     case WA_INACTIVE:
 12016 		    case WA_INACTIVE:
 12017                         DPRINTF((">>> WM_ACTIVATE inactive h=%x\n", ev->ev_hWnd));
 12017 			DPRINTF((">>> WM_ACTIVATE inactive h=%x\n", ev->ev_hWnd));
 12018                         (*act.ilc_func)(self,
 12018 			(*act.ilc_func)(self,
 12019                                         @symbol(activate:view:),
 12019 					@symbol(activate:view:),
 12020                                         nil, &act,
 12020 					nil, &act,
 12021                                         false, theView);
 12021 					false, theView);
 12022                         break;
 12022 			break;
 12023 
 12023 
 12024                     case WA_ACTIVE:
 12024 		    case WA_ACTIVE:
 12025                     case WA_CLICKACTIVE:
 12025 		    case WA_CLICKACTIVE:
 12026                         DPRINTF((">>> WM_ACTIVATE active h=%x\n", ev->ev_hWnd));
 12026 			DPRINTF((">>> WM_ACTIVATE active h=%x\n", ev->ev_hWnd));
 12027                         (*act.ilc_func)(self,
 12027 			(*act.ilc_func)(self,
 12028                                         @symbol(activate:view:),
 12028 					@symbol(activate:view:),
 12029                                         nil, &act,
 12029 					nil, &act,
 12030                                         true, theView);
 12030 					true, theView);
 12031                         break;
 12031 			break;
 12032 
 12032 
 12033                     default:
 12033 		    default:
 12034                         break;
 12034 			break;
 12035                 }
 12035 		}
 12036                 break;
 12036 		break;
 12037 
 12037 
 12038             case WM_MOUSEACTIVATE:
 12038 	    case WM_MOUSEACTIVATE:
 12039                 if (__debug_WM_MOUSEACTIVATE__ | __debug_WM_ALL__) {
 12039 		if (__debug_WM_MOUSEACTIVATE__ | __debug_WM_ALL__) {
 12040                     PRINTF((">>> WM_MOUSEACTIVATE h=%x -> focusInView:\n", ev->ev_hWnd));
 12040 		    PRINTF((">>> WM_MOUSEACTIVATE h=%x -> focusInView:\n", ev->ev_hWnd));
 12041                 }
 12041 		}
 12042 
 12042 
 12043                 (*focIn.ilc_func)(self,
 12043 		(*focIn.ilc_func)(self,
 12044                                   @symbol(focusInView:),
 12044 				  @symbol(focusInView:),
 12045                                   nil, &focIn, theView);
 12045 				  nil, &focIn, theView);
 12046                 break;
 12046 		break;
 12047 
 12047 
 12048             case WM_SETFOCUS:
 12048 	    case WM_SETFOCUS:
 12049                 DPRINTFIF(__debug_WM_FOCUS__ , (">>> WM_SETFOCUS h=%x -> focusInView:\n", ev->ev_hWnd));
 12049 		DPRINTFIF(__debug_WM_FOCUS__ , (">>> WM_SETFOCUS h=%x -> focusInView:\n", ev->ev_hWnd));
 12050                 (*focIn.ilc_func)(self,
 12050 		(*focIn.ilc_func)(self,
 12051                                   @symbol(focusInView:),
 12051 				  @symbol(focusInView:),
 12052                                   nil, &focIn, theView);
 12052 				  nil, &focIn, theView);
 12053                 break;
 12053 		break;
 12054 
 12054 
 12055             case WM_KILLFOCUS:
 12055 	    case WM_KILLFOCUS:
 12056                 DPRINTFIF(__debug_WM_FOCUS__ , (">>> WM_KILLFOCUS h=%x -> focusOutOfView\n", ev->ev_hWnd));
 12056 		DPRINTFIF(__debug_WM_FOCUS__ , (">>> WM_KILLFOCUS h=%x -> focusOutOfView\n", ev->ev_hWnd));
 12057                 (*focOut.ilc_func)(self,
 12057 		(*focOut.ilc_func)(self,
 12058                                    @symbol(focusOutView:),
 12058 				   @symbol(focusOutView:),
 12059                                    nil, &focOut, theView);
 12059 				   nil, &focOut, theView);
 12060                 break;
 12060 		break;
 12061 
 12061 
 12062             case __WM_GEXPOSE:
 12062 	    case __WM_GEXPOSE:
 12063                 x = ev->ev_x;
 12063 		x = ev->ev_x;
 12064                 y = ev->ev_y;
 12064 		y = ev->ev_y;
 12065                 w = ev->ev_w;
 12065 		w = ev->ev_w;
 12066                 h = ev->ev_h;
 12066 		h = ev->ev_h;
 12067                 DPRINTF((">>> __WM_GEXPOSE -> gExpose %d/%d -> %d/%d\n", x, y, w, h));
 12067 		DPRINTF((">>> __WM_GEXPOSE -> gExpose %d/%d -> %d/%d\n", x, y, w, h));
 12068 #if 0
 12068 #if 0
 12069                 if (GetWindow_unmapping(hWnd)) {
 12069 		if (GetWindow_unmapping(hWnd)) {
 12070                     console_fprintf(stderr, "oops - __WM_GEXPOSE for unmapping\n");
 12070 		    console_fprintf(stderr, "oops - __WM_GEXPOSE for unmapping\n");
 12071                 }
 12071 		}
 12072 #endif
 12072 #endif
 12073                 (*gexpS.ilc_func)(self,
 12073 		(*gexpS.ilc_func)(self,
 12074                                   @symbol(graphicsExposeX:y:width:height:final:view:),
 12074 				  @symbol(graphicsExposeX:y:width:height:final:view:),
 12075                                   nil, &gexpS,
 12075 				  nil, &gexpS,
 12076                                   __MKSMALLINT(x),
 12076 				  __MKSMALLINT(x),
 12077                                   __MKSMALLINT(y),
 12077 				  __MKSMALLINT(y),
 12078                                   __MKSMALLINT(w),
 12078 				  __MKSMALLINT(w),
 12079                                   __MKSMALLINT(h),
 12079 				  __MKSMALLINT(h),
 12080                                   ev->ev_wParam ? true : false,
 12080 				  ev->ev_wParam ? true : false,
 12081                                   theView);
 12081 				  theView);
 12082                 break;
 12082 		break;
 12083 
 12083 
 12084             case __WM_NOGEXPOSE:
 12084 	    case __WM_NOGEXPOSE:
 12085                 DPRINTFIF((__debug_WM_EXPOSE__ | __debug_WM_ALL__), (">>> __WM_NOGEXPOSE -> noExpose\n"));
 12085 		DPRINTFIF((__debug_WM_EXPOSE__ | __debug_WM_ALL__), (">>> __WM_NOGEXPOSE -> noExpose\n"));
 12086 #if 0
 12086 #if 0
 12087                 if (GetWindow_unmapping(hWnd)) {
 12087 		if (GetWindow_unmapping(hWnd)) {
 12088                     console_fprintf(stderr, "oops - __WM_NOGEXPOSE for unmapping\n");
 12088 		    console_fprintf(stderr, "oops - __WM_NOGEXPOSE for unmapping\n");
 12089                 }
 12089 		}
 12090 #endif
 12090 #endif
 12091                  (*nexpS.ilc_func)(self,
 12091 		 (*nexpS.ilc_func)(self,
 12092                                    @symbol(noExposeView:), nil, &nexpS,
 12092 				   @symbol(noExposeView:), nil, &nexpS,
 12093                                    theView);
 12093 				   theView);
 12094                 break;
 12094 		break;
 12095 
 12095 
 12096 # ifdef LATE_GENERATE_EXPOSE
 12096 # ifdef LATE_GENERATE_EXPOSE
 12097             case __WM_PAINT:
 12097 	    case __WM_PAINT:
 12098                 {
 12098 		{
 12099                     PAINTSTRUCT ps;
 12099 		    PAINTSTRUCT ps;
 12100 
 12100 
 12101                     AQUIRE_DRAW_MUTEX
 12101 		    AQUIRE_DRAW_MUTEX
 12102                     __generateExposes(hWnd, NULL, WM_PAINT, 0);
 12102 		    __generateExposes(hWnd, NULL, WM_PAINT, 0);
 12103                     RELEASE_DRAW_MUTEX
 12103 		    RELEASE_DRAW_MUTEX
 12104 
 12104 
 12105 # if 0
 12105 # if 0
 12106                     BeginPaint(hWnd, &ps);
 12106 		    BeginPaint(hWnd, &ps);
 12107                     EndPaint(hWnd, &ps);
 12107 		    EndPaint(hWnd, &ps);
 12108 # endif
 12108 # endif
 12109                 }
 12109 		}
 12110                 break;
 12110 		break;
 12111 # endif
 12111 # endif
 12112 
 12112 
 12113             case WM_PAINT:
 12113 	    case WM_PAINT:
 12114                 x = ev->ev_x;
 12114 		x = ev->ev_x;
 12115                 y = ev->ev_y;
 12115 		y = ev->ev_y;
 12116                 w = ev->ev_w;
 12116 		w = ev->ev_w;
 12117                 h = ev->ev_h;
 12117 		h = ev->ev_h;
 12118 
 12118 
 12119 #if 0
 12119 #if 0
 12120                 if (GetWindow_unmapping(hWnd)) {
 12120 		if (GetWindow_unmapping(hWnd)) {
 12121                     console_fprintf(stderr, "oops - WM_PAINT for unmapping\n");
 12121 		    console_fprintf(stderr, "oops - WM_PAINT for unmapping\n");
 12122                 }
 12122 		}
 12123 #endif
 12123 #endif
 12124 
 12124 
 12125 #ifndef PRE_21_NOV
 12125 #ifndef PRE_21_NOV
 12126                 __clearWindow(hWnd, x, y, w, h);
 12126 		__clearWindow(hWnd, x, y, w, h);
 12127 #else
 12127 #else
 12128 # if WM_PAINT_CLEAR_LATE
 12128 # if WM_PAINT_CLEAR_LATE
 12129                 __clearWindow(hWnd, x, y, w, h);
 12129 		__clearWindow(hWnd, x, y, w, h);
 12130 # endif
 12130 # endif
 12131 
 12131 
 12132 #endif
 12132 #endif
 12133 
 12133 
 12134 #ifdef DEBUG_COLORIZE_WM_PAINT_RECTS2
 12134 #ifdef DEBUG_COLORIZE_WM_PAINT_RECTS2
 12135                 {
 12135 		{
 12136                     HDC hDC;
 12136 		    HDC hDC;
 12137                     HBRUSH hBrush;
 12137 		    HBRUSH hBrush;
 12138                     RECT rect;
 12138 		    RECT rect;
 12139 
 12139 
 12140                     hBrush = CreateSolidBrush(BlackPixel);
 12140 		    hBrush = CreateSolidBrush(BlackPixel);
 12141                     hDC = GetWindowDC(hWnd);
 12141 		    hDC = GetWindowDC(hWnd);
 12142                     SelectClipRgn(hDC, NULL);
 12142 		    SelectClipRgn(hDC, NULL);
 12143                     rect.left = x;
 12143 		    rect.left = x;
 12144                     rect.top = y;
 12144 		    rect.top = y;
 12145                     rect.right = x+w;
 12145 		    rect.right = x+w;
 12146                     rect.bottom = y+h;
 12146 		    rect.bottom = y+h;
 12147 
 12147 
 12148                     FillRect(hDC, &rect, hBrush);
 12148 		    FillRect(hDC, &rect, hBrush);
 12149                     _DeleteBrush(hBrush, __LINE__);
 12149 		    _DeleteBrush(hBrush, __LINE__);
 12150                     ReleaseDC(hWnd, hDC);
 12150 		    ReleaseDC(hWnd, hDC);
 12151                 }
 12151 		}
 12152 #endif
 12152 #endif
 12153                 if (__debug_WM_PAINT__ | __debug_WM_ALL__) {
 12153 		if (__debug_WM_PAINT__ | __debug_WM_ALL__) {
 12154                     PRINTF((">>> WM_PAINT -> expose %d/%d -> %d/%d\n", x, y, w, h));
 12154 		    PRINTF((">>> WM_PAINT -> expose %d/%d -> %d/%d\n", x, y, w, h));
 12155                 }
 12155 		}
 12156                 (*exp.ilc_func)(self,
 12156 		(*exp.ilc_func)(self,
 12157                          @symbol(exposeX:y:width:height:view:),
 12157 			 @symbol(exposeX:y:width:height:view:),
 12158                          nil, &exp,
 12158 			 nil, &exp,
 12159                          __MKSMALLINT(x),
 12159 			 __MKSMALLINT(x),
 12160                          __MKSMALLINT(y),
 12160 			 __MKSMALLINT(y),
 12161                          __MKSMALLINT(w),
 12161 			 __MKSMALLINT(w),
 12162                          __MKSMALLINT(h),
 12162 			 __MKSMALLINT(h),
 12163                          theView);
 12163 			 theView);
 12164                 break;
 12164 		break;
 12165 
 12165 
 12166             case WM_LBUTTONDBLCLK:
 12166 	    case WM_LBUTTONDBLCLK:
 12167                 isDoubleClick = 1;
 12167 		isDoubleClick = 1;
 12168                 butt = __MKSMALLINT(Button1);
 12168 		butt = __MKSMALLINT(Button1);
 12169                 goto commonButton;
 12169 		goto commonButton;
 12170 
 12170 
 12171             case WM_LBUTTONUP:
 12171 	    case WM_LBUTTONUP:
 12172                 isDown = 0;
 12172 		isDown = 0;
 12173                 butt = __MKSMALLINT(Button1);
 12173 		butt = __MKSMALLINT(Button1);
 12174                 goto commonButton;
 12174 		goto commonButton;
 12175 
 12175 
 12176             case WM_LBUTTONDOWN:
 12176 	    case WM_LBUTTONDOWN:
 12177                 butt = __MKSMALLINT(Button1);
 12177 		butt = __MKSMALLINT(Button1);
 12178                 goto commonButton;
 12178 		goto commonButton;
 12179 
 12179 
 12180             case WM_MBUTTONDBLCLK:
 12180 	    case WM_MBUTTONDBLCLK:
 12181                 isDoubleClick = 1;
 12181 		isDoubleClick = 1;
 12182                 butt = __MKSMALLINT(Button2);
 12182 		butt = __MKSMALLINT(Button2);
 12183                 goto commonButton;
 12183 		goto commonButton;
 12184 
 12184 
 12185             case WM_MBUTTONUP:
 12185 	    case WM_MBUTTONUP:
 12186                 isDown = 0;
 12186 		isDown = 0;
 12187                 butt = __MKSMALLINT(Button2);
 12187 		butt = __MKSMALLINT(Button2);
 12188                 goto commonButton;
 12188 		goto commonButton;
 12189 
 12189 
 12190             case WM_MBUTTONDOWN:
 12190 	    case WM_MBUTTONDOWN:
 12191                 butt = __MKSMALLINT(Button2);
 12191 		butt = __MKSMALLINT(Button2);
 12192                 goto commonButton;
 12192 		goto commonButton;
 12193 
 12193 
 12194             case WM_RBUTTONDBLCLK:
 12194 	    case WM_RBUTTONDBLCLK:
 12195                 isDoubleClick = 1;
 12195 		isDoubleClick = 1;
 12196                 butt = __MKSMALLINT(Button3);
 12196 		butt = __MKSMALLINT(Button3);
 12197                 goto commonButton;
 12197 		goto commonButton;
 12198 
 12198 
 12199             case WM_RBUTTONUP:
 12199 	    case WM_RBUTTONUP:
 12200                 isDown = 0;
 12200 		isDown = 0;
 12201                 butt = __MKSMALLINT(Button3);
 12201 		butt = __MKSMALLINT(Button3);
 12202                 goto commonButton;
 12202 		goto commonButton;
 12203 
 12203 
 12204             case WM_RBUTTONDOWN:
 12204 	    case WM_RBUTTONDOWN:
 12205                 butt = __MKSMALLINT(Button3);
 12205 		butt = __MKSMALLINT(Button3);
 12206                 goto commonButton;
 12206 		goto commonButton;
 12207 
 12207 
 12208             commonButton:
 12208 	    commonButton:
 12209                 x = ev->ev_x;
 12209 		x = ev->ev_x;
 12210                 y = ev->ev_y;
 12210 		y = ev->ev_y;
 12211                 modifiers = ev->ev_modifiers;
 12211 		modifiers = ev->ev_modifiers;
 12212 
 12212 
 12213                 if (__INST(buttonTranslation) != nil) {
 12213 		if (__INST(buttonTranslation) != nil) {
 12214                     butt = __AT_(__INST(buttonTranslation), butt);
 12214 		    butt = __AT_(__INST(buttonTranslation), butt);
 12215                 }
 12215 		}
 12216                 arg = butt;
 12216 		arg = butt;
 12217 
 12217 
 12218                 __INST(altDown) = (modifiers & AltMask) ? true : false;
 12218 		__INST(altDown) = (modifiers & AltMask) ? true : false;
 12219                 __INST(metaDown) = (modifiers & MetaMask) ? true : false;
 12219 		__INST(metaDown) = (modifiers & MetaMask) ? true : false;
 12220                 __INST(shiftDown) = (modifiers & ShiftMask) ? true : false;
 12220 		__INST(shiftDown) = (modifiers & ShiftMask) ? true : false;
 12221                 __INST(ctrlDown) = (modifiers & ControlMask) ? true : false;
 12221 		__INST(ctrlDown) = (modifiers & ControlMask) ? true : false;
 12222 
 12222 
 12223                 if (deltaDoubleClickX == -999) {
 12223 		if (deltaDoubleClickX == -999) {
 12224                     deltaDoubleClickX = GetSystemMetrics(SM_CXDOUBLECLK);
 12224 		    deltaDoubleClickX = GetSystemMetrics(SM_CXDOUBLECLK);
 12225                     deltaDoubleClickY = GetSystemMetrics(SM_CYDOUBLECLK);
 12225 		    deltaDoubleClickY = GetSystemMetrics(SM_CYDOUBLECLK);
 12226                 }
 12226 		}
 12227 
 12227 
 12228                 if (isDoubleClick) {
 12228 		if (isDoubleClick) {
 12229                     multiClickCount = 2;
 12229 		    multiClickCount = 2;
 12230                     ipS = &bmp;
 12230 		    ipS = &bmp;
 12231                     symS = @symbol(buttonMultiPress:x:y:view:);
 12231 		    symS = @symbol(buttonMultiPress:x:y:view:);
 12232                     nextMultiClickTime = ev->ev_time + __intVal(__INST(multiClickTimeDelta));
 12232 		    nextMultiClickTime = ev->ev_time + __intVal(__INST(multiClickTimeDelta));
 12233                 } else {
 12233 		} else {
 12234                     if (isDown) {
 12234 		    if (isDown) {
 12235                         if (multiClickCount
 12235 			if (multiClickCount
 12236                          && (ev->ev_time < nextMultiClickTime)
 12236 			 && (ev->ev_time < nextMultiClickTime)
 12237                          && (butt == lastButton)
 12237 			 && (butt == lastButton)
 12238                          && (x >= (lastClickX - (deltaDoubleClickX / 2)))
 12238 			 && (x >= (lastClickX - (deltaDoubleClickX / 2)))
 12239                          && (x <= (lastClickX + (deltaDoubleClickX / 2)))
 12239 			 && (x <= (lastClickX + (deltaDoubleClickX / 2)))
 12240                          && (y >= (lastClickY - (deltaDoubleClickY / 2)))
 12240 			 && (y >= (lastClickY - (deltaDoubleClickY / 2)))
 12241                          && (y <= (lastClickY + (deltaDoubleClickY / 2)))
 12241 			 && (y <= (lastClickY + (deltaDoubleClickY / 2)))
 12242                         ) {
 12242 			) {
 12243                             ipS = &bmp;
 12243 			    ipS = &bmp;
 12244                             symS = @symbol(buttonMultiPress:x:y:view:);
 12244 			    symS = @symbol(buttonMultiPress:x:y:view:);
 12245                         } else {
 12245 			} else {
 12246                             ipS = &bp;
 12246 			    ipS = &bp;
 12247                             symS = @symbol(buttonPress:x:y:view:);
 12247 			    symS = @symbol(buttonPress:x:y:view:);
 12248                             multiClickCount = 0;
 12248 			    multiClickCount = 0;
 12249                         }
 12249 			}
 12250                         multiClickCount = multiClickCount + 1;
 12250 			multiClickCount = multiClickCount + 1;
 12251                         nextMultiClickTime = ev->ev_time + __intVal(__INST(multiClickTimeDelta));
 12251 			nextMultiClickTime = ev->ev_time + __intVal(__INST(multiClickTimeDelta));
 12252                     } else {
 12252 		    } else {
 12253                         ipS = &br;
 12253 			ipS = &br;
 12254                         symS = @symbol(buttonRelease:x:y:view:);
 12254 			symS = @symbol(buttonRelease:x:y:view:);
 12255                     }
 12255 		    }
 12256                 }
 12256 		}
 12257 
 12257 
 12258                 if (isDown || isDoubleClick) {
 12258 		if (isDown || isDoubleClick) {
 12259                     lastClickX = x;
 12259 		    lastClickX = x;
 12260                     lastClickY = y;
 12260 		    lastClickY = y;
 12261                     lastButton = butt;
 12261 		    lastButton = butt;
 12262                 }
 12262 		}
 12263 
 12263 
 12264                 if (__debug_WM_BUTTONUP__ | __debug_WM_BUTTONDOWN__ | __debug_WM_ALL__) {
 12264 		if (__debug_WM_BUTTONUP__ | __debug_WM_BUTTONDOWN__ | __debug_WM_ALL__) {
 12265                     if (__isSymbol(arg)) {
 12265 		    if (__isSymbol(arg)) {
 12266                         PRINTF(("buttonPress/buttonRelease: %s %d/%d\n",
 12266 			PRINTF(("buttonPress/buttonRelease: %s %d/%d\n",
 12267                                     __stringVal(arg), x, y));
 12267 				    __stringVal(arg), x, y));
 12268                     } else {
 12268 		    } else {
 12269                         PRINTF(("buttonPress/buttonRelease: %d %d/%d\n",
 12269 			PRINTF(("buttonPress/buttonRelease: %d %d/%d\n",
 12270                                     __intVal(arg), x, y));
 12270 				    __intVal(arg), x, y));
 12271                     }
 12271 		    }
 12272                 }
 12272 		}
 12273 
 12273 
 12274                 (*(*ipS).ilc_func)(self, symS, nil, ipS,
 12274 		(*(*ipS).ilc_func)(self, symS, nil, ipS,
 12275                                    arg,
 12275 				   arg,
 12276                                    __MKSMALLINT(x),
 12276 				   __MKSMALLINT(x),
 12277                                    __MKSMALLINT(y),
 12277 				   __MKSMALLINT(y),
 12278                                    theView);
 12278 				   theView);
 12279                 break;
 12279 		break;
 12280 
 12280 
 12281             case __WM_MOUSEENTER:
 12281 	    case __WM_MOUSEENTER:
 12282                 x = ev->ev_x;
 12282 		x = ev->ev_x;
 12283                 y = ev->ev_y;
 12283 		y = ev->ev_y;
 12284                 state = ev->ev_modifiers;
 12284 		state = ev->ev_modifiers;
 12285 
 12285 
 12286                 if (__debug_WM_MOUSEENTER__ | __debug_WM_ALL__) {
 12286 		if (__debug_WM_MOUSEENTER__ | __debug_WM_ALL__) {
 12287                     PRINTF((">>> WM_MOUSEENTER: %x %d/%d state:%x\n", ev->ev_hWnd, x, y, state));
 12287 		    PRINTF((">>> WM_MOUSEENTER: %x %d/%d state:%x\n", ev->ev_hWnd, x, y, state));
 12288                 }
 12288 		}
 12289 #if 0
 12289 #if 0
 12290                 if (GetWindow_unmapping(hWnd)) {
 12290 		if (GetWindow_unmapping(hWnd)) {
 12291                     console_fprintf(stderr, "oops - WM_MOUSEENTER for unmapping\n");
 12291 		    console_fprintf(stderr, "oops - WM_MOUSEENTER for unmapping\n");
 12292                 }
 12292 		}
 12293 #endif
 12293 #endif
 12294                 (*pe.ilc_func)(self, @symbol(pointerEnter:x:y:view:),
 12294 		(*pe.ilc_func)(self, @symbol(pointerEnter:x:y:view:),
 12295                                     nil, &pe,
 12295 				    nil, &pe,
 12296                                     __MKSMALLINT(state),
 12296 				    __MKSMALLINT(state),
 12297                                     __MKSMALLINT(x),
 12297 				    __MKSMALLINT(x),
 12298                                     __MKSMALLINT(y),
 12298 				    __MKSMALLINT(y),
 12299                                     theView);
 12299 				    theView);
 12300                 break;
 12300 		break;
 12301 
 12301 
 12302             case __WM_MOUSELEAVE:
 12302 	    case __WM_MOUSELEAVE:
 12303                 state = ev->ev_modifiers;
 12303 		state = ev->ev_modifiers;
 12304                 if (__debug_WM_MOUSELEAVE__ | __debug_WM_ALL__) {
 12304 		if (__debug_WM_MOUSELEAVE__ | __debug_WM_ALL__) {
 12305                     PRINTF((">>> WM_MOUSELEAVE: %x state:%x\n", ev->ev_hWnd, state));
 12305 		    PRINTF((">>> WM_MOUSELEAVE: %x state:%x\n", ev->ev_hWnd, state));
 12306                 }
 12306 		}
 12307 #if 0
 12307 #if 0
 12308                 if (GetWindow_unmapping(hWnd)) {
 12308 		if (GetWindow_unmapping(hWnd)) {
 12309                     console_fprintf(stderr, "oops - WM_MOUSELEAVE for unmapping\n");
 12309 		    console_fprintf(stderr, "oops - WM_MOUSELEAVE for unmapping\n");
 12310                 }
 12310 		}
 12311 #endif
 12311 #endif
 12312                 (*pl.ilc_func)(self, @symbol(pointerLeave:view:),
 12312 		(*pl.ilc_func)(self, @symbol(pointerLeave:view:),
 12313                                     nil, &pl,
 12313 				    nil, &pl,
 12314                                     __MKSMALLINT(state),
 12314 				    __MKSMALLINT(state),
 12315                                     theView);
 12315 				    theView);
 12316                 break;
 12316 		break;
 12317 
 12317 
 12318             case WM_MOUSEMOVE:
 12318 	    case WM_MOUSEMOVE:
 12319                 x = ev->ev_x;
 12319 		x = ev->ev_x;
 12320                 y = ev->ev_y;
 12320 		y = ev->ev_y;
 12321                 state = ev->ev_modifiers;
 12321 		state = ev->ev_modifiers;
 12322                 if (__debug_WM_MOUSEMOVE__ | __debug_WM_ALL__) {
 12322 		if (__debug_WM_MOUSEMOVE__ | __debug_WM_ALL__) {
 12323                     PRINTF((">>> WM_MOUSEMOVE: %d/%d %x\n", x, y, state));
 12323 		    PRINTF((">>> WM_MOUSEMOVE: %d/%d %x\n", x, y, state));
 12324                 }
 12324 		}
 12325                 (*mot.ilc_func)(self, @symbol(buttonMotion:x:y:view:),
 12325 		(*mot.ilc_func)(self, @symbol(buttonMotion:x:y:view:),
 12326                                     nil, &mot,
 12326 				    nil, &mot,
 12327                                     __MKSMALLINT(state),
 12327 				    __MKSMALLINT(state),
 12328                                     __MKSMALLINT(x),
 12328 				    __MKSMALLINT(x),
 12329                                     __MKSMALLINT(y),
 12329 				    __MKSMALLINT(y),
 12330                                     theView);
 12330 				    theView);
 12331                 break;
 12331 		break;
 12332 
 12332 
 12333 #ifdef WM_MOUSEWHEEL
 12333 #ifdef WM_MOUSEWHEEL
 12334             case WM_MOUSEWHEEL:
 12334 	    case WM_MOUSEWHEEL:
 12335                 x = ev->ev_x;
 12335 		x = ev->ev_x;
 12336                 y = ev->ev_y;
 12336 		y = ev->ev_y;
 12337                 state = ev->ev_modifiers;
 12337 		state = ev->ev_modifiers;
 12338                 dir = GET_WHEEL_DELTA_WPARAM(ev->ev_wParam);
 12338 		dir = GET_WHEEL_DELTA_WPARAM(ev->ev_wParam);
 12339                 // dir = ev->ev_wParam & 0xFFFF;
 12339 		// dir = ev->ev_wParam & 0xFFFF;
 12340                 DPRINTF((">>> WM_MOUSEWHEEL: %d %x\n", dir, state));
 12340 		DPRINTF((">>> WM_MOUSEWHEEL: %d %x\n", dir, state));
 12341                 {
 12341 		{
 12342                     OBJ tim;
 12342 		    OBJ tim;
 12343 
 12343 
 12344                     __PROTECT__(theView);
 12344 		    __PROTECT__(theView);
 12345                     tim = __MKUINT(ev->ev_time);
 12345 		    tim = __MKUINT(ev->ev_time);
 12346                     __UNPROTECT__(theView);
 12346 		    __UNPROTECT__(theView);
 12347                     (*mwh.ilc_func)(self, @symbol(mouseWheelMotion:x:y:amount:deltaTime:view:),
 12347 		    (*mwh.ilc_func)(self, @symbol(mouseWheelMotion:x:y:amount:deltaTime:view:),
 12348                                     nil, &mwh,
 12348 				    nil, &mwh,
 12349                                     __MKSMALLINT(state),
 12349 				    __MKSMALLINT(state),
 12350                                     __MKSMALLINT(x),
 12350 				    __MKSMALLINT(x),
 12351                                     __MKSMALLINT(y),
 12351 				    __MKSMALLINT(y),
 12352                                     __MKSMALLINT(dir),
 12352 				    __MKSMALLINT(dir),
 12353                                     tim,
 12353 				    tim,
 12354                                     theView);
 12354 				    theView);
 12355                 }
 12355 		}
 12356                 break;
 12356 		break;
 12357 #endif
 12357 #endif
 12358 
 12358 
 12359             case WM_CHAR:
 12359 	    case WM_CHAR:
 12360                 DPRINTFIF((__debug_WM_CHAR__ | __debug_WM_ALL__)  , ("WM_CHAR %x %d/%d\n", ev->ev_keyCode, ev->ev_x, ev->ev_y));
 12360 		DPRINTFIF((__debug_WM_CHAR__ | __debug_WM_ALL__)  , ("WM_CHAR %x %d/%d\n", ev->ev_keyCode, ev->ev_x, ev->ev_y));
 12361                 DPRINTF((">>> WM_CHAR: %d/%d\n", x, y));
 12361 		DPRINTF((">>> WM_CHAR: %d/%d\n", x, y));
 12362                 symS = @symbol(keyPress:x:y:view:);
 12362 		symS = @symbol(keyPress:x:y:view:);
 12363                 ipS = &skp;
 12363 		ipS = &skp;
 12364                 upDown = true;
 12364 		upDown = true;
 12365                 goto keyPressAndRelease;
 12365 		goto keyPressAndRelease;
 12366 
 12366 
 12367             case WM_HOTKEY:
 12367 	    case WM_HOTKEY:
 12368                 {
 12368 		{
 12369                 (*hkp.ilc_func)(self, @symbol(hotkeyWithId:key:view:),
 12369 		(*hkp.ilc_func)(self, @symbol(hotkeyWithId:key:view:),
 12370                                     nil, &hkp,
 12370 				    nil, &hkp,
 12371                                     __MKSMALLINT(ev->ev_wParam),
 12371 				    __MKSMALLINT(ev->ev_wParam),
 12372                                     __MKSMALLINT(ev->ev_arg1),
 12372 				    __MKSMALLINT(ev->ev_arg1),
 12373                                     theView);
 12373 				    theView);
 12374                 }
 12374 		}
 12375                 break;
 12375 		break;
 12376 
 12376 
 12377             case WM_SYSKEYUP:
 12377 	    case WM_SYSKEYUP:
 12378             case WM_KEYUP:
 12378 	    case WM_KEYUP:
 12379                 DPRINTFIF((__debug_WM_KEYUP__ | __debug_WM_ALL__)  , (">>> WM_KEYUP / SYSKEYUP: %x %d/%d\n", ev->ev_keyCode, ev->ev_x, ev->ev_y));
 12379 		DPRINTFIF((__debug_WM_KEYUP__ | __debug_WM_ALL__)  , (">>> WM_KEYUP / SYSKEYUP: %x %d/%d\n", ev->ev_keyCode, ev->ev_x, ev->ev_y));
 12380                 symS = @symbol(keyRelease:x:y:view:);
 12380 		symS = @symbol(keyRelease:x:y:view:);
 12381                 ipS = &skr;
 12381 		ipS = &skr;
 12382                 upDown = false;
 12382 		upDown = false;
 12383                 goto keyPressAndRelease;
 12383 		goto keyPressAndRelease;
 12384 
 12384 
 12385             case WM_SYSKEYDOWN:
 12385 	    case WM_SYSKEYDOWN:
 12386             case WM_KEYDOWN:
 12386 	    case WM_KEYDOWN:
 12387                 DPRINTFIF((__debug_WM_KEYUP__ | __debug_WM_ALL__)  , (">>> WM_KEYDOWN / SYSKEYDOWN: %x %d/%d\n", ev->ev_keyCode, ev->ev_x, ev->ev_y));
 12387 		DPRINTFIF((__debug_WM_KEYUP__ | __debug_WM_ALL__)  , (">>> WM_KEYDOWN / SYSKEYDOWN: %x %d/%d\n", ev->ev_keyCode, ev->ev_x, ev->ev_y));
 12388                 symS = @symbol(keyPress:x:y:view:);
 12388 		symS = @symbol(keyPress:x:y:view:);
 12389                 ipS = &skp;
 12389 		ipS = &skp;
 12390                 upDown = true;
 12390 		upDown = true;
 12391                 /* FALL INTO */
 12391 		/* FALL INTO */
 12392 
 12392 
 12393             keyPressAndRelease: ;
 12393 	    keyPressAndRelease: ;
 12394 
 12394 
 12395                 x = ev->ev_x;
 12395 		x = ev->ev_x;
 12396                 y = ev->ev_y;
 12396 		y = ev->ev_y;
 12397 
 12397 
 12398 #ifdef NOTDEF
 12398 #ifdef NOTDEF
 12399                 {
 12399 		{
 12400                     BYTE vKeyState[256];
 12400 		    BYTE vKeyState[256];
 12401                     char buff[5];
 12401 		    char buff[5];
 12402 
 12402 
 12403                     GetKeyboardState(vKeyState);
 12403 		    GetKeyboardState(vKeyState);
 12404                     ToAscii(ev->ev_keyCode, ev->ev_scanCode, vKeyState, &buff; 0);
 12404 		    ToAscii(ev->ev_keyCode, ev->ev_scanCode, vKeyState, &buff; 0);
 12405                 }
 12405 		}
 12406 #endif
 12406 #endif
 12407 
 12407 
 12408                 keyCode = ev->ev_keyCode;
 12408 		keyCode = ev->ev_keyCode;
 12409                 modifiers = ev->ev_modifiers;
 12409 		modifiers = ev->ev_modifiers;
 12410 
 12410 
 12411                 if (modifiers & TRANSLATED_KEY) {
 12411 		if (modifiers & TRANSLATED_KEY) {
 12412 #if 1
 12412 #if 1
 12413                     if (modifiers & ControlMask) {
 12413 		    if (modifiers & ControlMask) {
 12414                         if (keyCode < 0x20) {
 12414 			if (keyCode < 0x20) {
 12415                             keyCode = keyCode + 'a' - 1;
 12415 			    keyCode = keyCode + 'a' - 1;
 12416                             if (modifiers & ShiftMask) {
 12416 			    if (modifiers & ShiftMask) {
 12417                                 keyCode = keyCode - 'a' + 'A';
 12417 				keyCode = keyCode - 'a' + 'A';
 12418                             }
 12418 			    }
 12419                         }
 12419 			}
 12420                     } else if (modifiers & (MetaMask | AltMask)) {
 12420 		    } else if (modifiers & (MetaMask | AltMask)) {
 12421                         if (! (modifiers & ShiftMask)) {
 12421 			if (! (modifiers & ShiftMask)) {
 12422                             if ((keyCode >= 'A') && (keyCode <= 'Z')) {
 12422 			    if ((keyCode >= 'A') && (keyCode <= 'Z')) {
 12423                                 keyCode = keyCode - 'A' + 'a';
 12423 				keyCode = keyCode - 'A' + 'a';
 12424                             }
 12424 			    }
 12425                         }
 12425 			}
 12426                     }
 12426 		    }
 12427 #endif
 12427 #endif
 12428                     arg = __MKSMALLINT(keyCode & 0xFFFF);
 12428 		    arg = __MKSMALLINT(keyCode & 0xFFFF);
 12429                 } else {
 12429 		} else {
 12430                     switch (keyCode) {
 12430 		    switch (keyCode) {
 12431                         case VK_F1:
 12431 			case VK_F1:
 12432                             arg = @symbol(F1);
 12432 			    arg = @symbol(F1);
 12433                             break;
 12433 			    break;
 12434                         case VK_F2:
 12434 			case VK_F2:
 12435                             arg = @symbol(F2);
 12435 			    arg = @symbol(F2);
 12436                             break;
 12436 			    break;
 12437                         case VK_F3:
 12437 			case VK_F3:
 12438                             arg = @symbol(F3);
 12438 			    arg = @symbol(F3);
 12439                             break;
 12439 			    break;
 12440                         case VK_F4:
 12440 			case VK_F4:
 12441                             arg = @symbol(F4);
 12441 			    arg = @symbol(F4);
 12442                             break;
 12442 			    break;
 12443                         case VK_F5:
 12443 			case VK_F5:
 12444                             arg = @symbol(F5);
 12444 			    arg = @symbol(F5);
 12445                             break;
 12445 			    break;
 12446                         case VK_F6:
 12446 			case VK_F6:
 12447                             arg = @symbol(F6);
 12447 			    arg = @symbol(F6);
 12448                             break;
 12448 			    break;
 12449                         case VK_F7:
 12449 			case VK_F7:
 12450                             arg = @symbol(F7);
 12450 			    arg = @symbol(F7);
 12451                             break;
 12451 			    break;
 12452                         case VK_F8:
 12452 			case VK_F8:
 12453                             arg = @symbol(F8);
 12453 			    arg = @symbol(F8);
 12454                             break;
 12454 			    break;
 12455                         case VK_F9:
 12455 			case VK_F9:
 12456                             arg = @symbol(F9);
 12456 			    arg = @symbol(F9);
 12457                             break;
 12457 			    break;
 12458                         case VK_F10:
 12458 			case VK_F10:
 12459                             arg = @symbol(F10);
 12459 			    arg = @symbol(F10);
 12460                             break;
 12460 			    break;
 12461                         case VK_F11:
 12461 			case VK_F11:
 12462                             arg = @symbol(F11);
 12462 			    arg = @symbol(F11);
 12463                             break;
 12463 			    break;
 12464                         case VK_F12:
 12464 			case VK_F12:
 12465                             arg = @symbol(F12);
 12465 			    arg = @symbol(F12);
 12466                             break;
 12466 			    break;
 12467                         case VK_PRIOR:
 12467 			case VK_PRIOR:
 12468                             arg = @symbol(Prior);
 12468 			    arg = @symbol(Prior);
 12469                             break;
 12469 			    break;
 12470                         case VK_NEXT:
 12470 			case VK_NEXT:
 12471                             arg = @symbol(Next);
 12471 			    arg = @symbol(Next);
 12472                             break;
 12472 			    break;
 12473                         case VK_END:
 12473 			case VK_END:
 12474                             arg = @symbol(End);
 12474 			    arg = @symbol(End);
 12475                             break;
 12475 			    break;
 12476                         case VK_HOME:
 12476 			case VK_HOME:
 12477                             arg = @symbol(Home);
 12477 			    arg = @symbol(Home);
 12478                             break;
 12478 			    break;
 12479                         case VK_LEFT:
 12479 			case VK_LEFT:
 12480                             arg = @symbol(CursorLeft);
 12480 			    arg = @symbol(CursorLeft);
 12481                             break;
 12481 			    break;
 12482                         case VK_RIGHT:
 12482 			case VK_RIGHT:
 12483                             arg = @symbol(CursorRight);
 12483 			    arg = @symbol(CursorRight);
 12484                             break;
 12484 			    break;
 12485                         case VK_UP:
 12485 			case VK_UP:
 12486                             arg = @symbol(CursorUp);
 12486 			    arg = @symbol(CursorUp);
 12487                             break;
 12487 			    break;
 12488                         case VK_DOWN:
 12488 			case VK_DOWN:
 12489                             arg = @symbol(CursorDown);
 12489 			    arg = @symbol(CursorDown);
 12490                             break;
 12490 			    break;
 12491                         case VK_MENU:  /*alt key with w95 ???*/
 12491 			case VK_MENU:  /*alt key with w95 ???*/
 12492                             arg = @symbol(Menu);
 12492 			    arg = @symbol(Menu);
 12493                             break;
 12493 			    break;
 12494                         case VK_LMENU:
 12494 			case VK_LMENU:
 12495                             arg = @symbol(Menu_L);
 12495 			    arg = @symbol(Menu_L);
 12496                             break;
 12496 			    break;
 12497                         case VK_RMENU:
 12497 			case VK_RMENU:
 12498                             arg = @symbol(Menu_R);
 12498 			    arg = @symbol(Menu_R);
 12499                             break;
 12499 			    break;
 12500                         case VK_PAUSE:
 12500 			case VK_PAUSE:
 12501                             arg = @symbol(Pause);
 12501 			    arg = @symbol(Pause);
 12502                             break;
 12502 			    break;
 12503                         case VK_HELP:
 12503 			case VK_HELP:
 12504                             arg = @symbol(Help);
 12504 			    arg = @symbol(Help);
 12505                             break;
 12505 			    break;
 12506                         case VK_EXECUTE:
 12506 			case VK_EXECUTE:
 12507                             arg = @symbol(Execute);
 12507 			    arg = @symbol(Execute);
 12508                             break;
 12508 			    break;
 12509                         case VK_CANCEL:
 12509 			case VK_CANCEL:
 12510                             arg = @symbol(Cancel);
 12510 			    arg = @symbol(Cancel);
 12511                             break;
 12511 			    break;
 12512                         case VK_SELECT:
 12512 			case VK_SELECT:
 12513                             arg = @symbol(Select);
 12513 			    arg = @symbol(Select);
 12514                             break;
 12514 			    break;
 12515                         case VK_PRINT:
 12515 			case VK_PRINT:
 12516                             arg = @symbol(Print);
 12516 			    arg = @symbol(Print);
 12517                             break;
 12517 			    break;
 12518                         case VK_SNAPSHOT:
 12518 			case VK_SNAPSHOT:
 12519                             arg = @symbol(Snapshot);
 12519 			    arg = @symbol(Snapshot);
 12520                             break;
 12520 			    break;
 12521                         case VK_INSERT:
 12521 			case VK_INSERT:
 12522                             arg = @symbol(Insert);
 12522 			    arg = @symbol(Insert);
 12523                             break;
 12523 			    break;
 12524                         case VK_DELETE:
 12524 			case VK_DELETE:
 12525                             arg = @symbol(Delete);
 12525 			    arg = @symbol(Delete);
 12526                             break;
 12526 			    break;
 12527                         case VK_BACK:
 12527 			case VK_BACK:
 12528                             arg = @symbol(BackSpace);
 12528 			    arg = @symbol(BackSpace);
 12529                             break;
 12529 			    break;
 12530                         case VK_LWIN:
 12530 			case VK_LWIN:
 12531                             arg = @symbol(Win_L);
 12531 			    arg = @symbol(Win_L);
 12532                             break;
 12532 			    break;
 12533                         case VK_RWIN:
 12533 			case VK_RWIN:
 12534                             arg = @symbol(Win_R);
 12534 			    arg = @symbol(Win_R);
 12535                             break;
 12535 			    break;
 12536                         case VK_APPS:
 12536 			case VK_APPS:
 12537                             arg = @symbol(Appl);
 12537 			    arg = @symbol(Appl);
 12538                             break;
 12538 			    break;
 12539                         case VK_NUMPAD0:
 12539 			case VK_NUMPAD0:
 12540                             arg = @symbol(KeyPad0);
 12540 			    arg = @symbol(KeyPad0);
 12541                             break;
 12541 			    break;
 12542                         case VK_NUMPAD1:
 12542 			case VK_NUMPAD1:
 12543                             arg = @symbol(KeyPad1);
 12543 			    arg = @symbol(KeyPad1);
 12544                             break;
 12544 			    break;
 12545                         case VK_NUMPAD2:
 12545 			case VK_NUMPAD2:
 12546                             arg = @symbol(KeyPad2);
 12546 			    arg = @symbol(KeyPad2);
 12547                             break;
 12547 			    break;
 12548                         case VK_NUMPAD3:
 12548 			case VK_NUMPAD3:
 12549                             arg = @symbol(KeyPad3);
 12549 			    arg = @symbol(KeyPad3);
 12550                             break;
 12550 			    break;
 12551                         case VK_NUMPAD4:
 12551 			case VK_NUMPAD4:
 12552                             arg = @symbol(KeyPad4);
 12552 			    arg = @symbol(KeyPad4);
 12553                             break;
 12553 			    break;
 12554                         case VK_NUMPAD5:
 12554 			case VK_NUMPAD5:
 12555                             arg = @symbol(KeyPad5);
 12555 			    arg = @symbol(KeyPad5);
 12556                             break;
 12556 			    break;
 12557                         case VK_NUMPAD6:
 12557 			case VK_NUMPAD6:
 12558                             arg = @symbol(KeyPad6);
 12558 			    arg = @symbol(KeyPad6);
 12559                             break;
 12559 			    break;
 12560                         case VK_NUMPAD7:
 12560 			case VK_NUMPAD7:
 12561                             arg = @symbol(KeyPad7);
 12561 			    arg = @symbol(KeyPad7);
 12562                             break;
 12562 			    break;
 12563                         case VK_NUMPAD8:
 12563 			case VK_NUMPAD8:
 12564                             arg = @symbol(KeyPad8);
 12564 			    arg = @symbol(KeyPad8);
 12565                             break;
 12565 			    break;
 12566                         case VK_NUMPAD9:
 12566 			case VK_NUMPAD9:
 12567                             arg = @symbol(KeyPad9);
 12567 			    arg = @symbol(KeyPad9);
 12568                             break;
 12568 			    break;
 12569                         case VK_LSHIFT:
 12569 			case VK_LSHIFT:
 12570                             arg = @symbol(Shift_L);
 12570 			    arg = @symbol(Shift_L);
 12571                             break;
 12571 			    break;
 12572                         case VK_RSHIFT:
 12572 			case VK_RSHIFT:
 12573                             arg = @symbol(Shift_R);
 12573 			    arg = @symbol(Shift_R);
 12574                             break;
 12574 			    break;
 12575                         case VK_LCONTROL:
 12575 			case VK_LCONTROL:
 12576                             arg = @symbol(Ctrl_L);
 12576 			    arg = @symbol(Ctrl_L);
 12577                             break;
 12577 			    break;
 12578                         case VK_RCONTROL:
 12578 			case VK_RCONTROL:
 12579                             arg = @symbol(Ctrl_R);
 12579 			    arg = @symbol(Ctrl_R);
 12580                             break;
 12580 			    break;
 12581                         case VK_CONTROL:
 12581 			case VK_CONTROL:
 12582                             arg = @symbol(Ctrl);
 12582 			    arg = @symbol(Ctrl);
 12583                             break;
 12583 			    break;
 12584                         case VK_SHIFT:
 12584 			case VK_SHIFT:
 12585                             arg = @symbol(Shift);
 12585 			    arg = @symbol(Shift);
 12586                             break;
 12586 			    break;
 12587                         case VK_TAB:
 12587 			case VK_TAB:
 12588                             arg = @symbol(Tab);
 12588 			    arg = @symbol(Tab);
 12589                             break;
 12589 			    break;
 12590                         case VK_ESCAPE:
 12590 			case VK_ESCAPE:
 12591                             arg = @symbol(Escape);
 12591 			    arg = @symbol(Escape);
 12592                             break;
 12592 			    break;
 12593                         case VK_NUMLOCK:
 12593 			case VK_NUMLOCK:
 12594                             arg = @symbol(NumLock);
 12594 			    arg = @symbol(NumLock);
 12595                             break;
 12595 			    break;
 12596                         case VK_SCROLL:
 12596 			case VK_SCROLL:
 12597                             arg = @symbol(ScrollLock);
 12597 			    arg = @symbol(ScrollLock);
 12598                             break;
 12598 			    break;
 12599                         case VK_RETURN:
 12599 			case VK_RETURN:
 12600                             arg = @symbol(Return);
 12600 			    arg = @symbol(Return);
 12601                             break;
 12601 			    break;
 12602 
 12602 
 12603                         default:
 12603 			default:
 12604 #if 0
 12604 #if 0
 12605                             nameBuffer[0] = 0;
 12605 			    nameBuffer[0] = 0;
 12606                             GetKeyNameText(ev->ev_scanCode, nameBuffer, sizeof(nameBuffer));
 12606 			    GetKeyNameText(ev->ev_scanCode, nameBuffer, sizeof(nameBuffer));
 12607                             if (__debug_WM_KEYUP__ | __debug_WM_KEYDOWN__ | __debug_WM_CHAR__ | __debug_WM_ALL__) {
 12607 			    if (__debug_WM_KEYUP__ | __debug_WM_KEYDOWN__ | __debug_WM_CHAR__ | __debug_WM_ALL__) {
 12608                                 PRINTF(("char is <%d>\n", keyCode));
 12608 				PRINTF(("char is <%d>\n", keyCode));
 12609                             }
 12609 			    }
 12610 #endif
 12610 #endif
 12611                             arg = __MKSMALLINT(keyCode & 0xFFFF);
 12611 			    arg = __MKSMALLINT(keyCode & 0xFFFF);
 12612                             break;
 12612 			    break;
 12613                     }
 12613 		    }
 12614                 }
 12614 		}
 12615                 __INST(altDown) = (modifiers & AltMask) ? true : false;
 12615 		__INST(altDown) = (modifiers & AltMask) ? true : false;
 12616                 __INST(metaDown) = (modifiers & MetaMask) ? true : false;
 12616 		__INST(metaDown) = (modifiers & MetaMask) ? true : false;
 12617                 __INST(shiftDown) = (modifiers & ShiftMask) ? true : false;
 12617 		__INST(shiftDown) = (modifiers & ShiftMask) ? true : false;
 12618                 __INST(ctrlDown) = (modifiers & ControlMask) ? true : false;
 12618 		__INST(ctrlDown) = (modifiers & ControlMask) ? true : false;
 12619 
 12619 
 12620                 if (__debug_WM_CHAR__ | __debug_WM_KEYUP__ | __debug_WM_KEYDOWN__ | __debug_WM_ALL__) {
 12620 		if (__debug_WM_CHAR__ | __debug_WM_KEYUP__ | __debug_WM_KEYDOWN__ | __debug_WM_ALL__) {
 12621                     PRINTF(("%s: code=%x mod=%x ", __stringVal(symS), keyCode, modifiers));
 12621 		    PRINTF(("%s: code=%x mod=%x ", __stringVal(symS), keyCode, modifiers));
 12622                     PRINTF((" alt=%d meta=%d ", __INST(altDown) == true , __INST(metaDown) == true));
 12622 		    PRINTF((" alt=%d meta=%d ", __INST(altDown) == true , __INST(metaDown) == true));
 12623                     PRINTF((" sh=%d ctrl=%d", __INST(shiftDown) == true , __INST(ctrlDown) == true));
 12623 		    PRINTF((" sh=%d ctrl=%d", __INST(shiftDown) == true , __INST(ctrlDown) == true));
 12624                     PRINTF((" arg=%x\n", arg));
 12624 		    PRINTF((" arg=%x\n", arg));
 12625                 }
 12625 		}
 12626 
 12626 
 12627                 (*(*ipS).ilc_func)(self, symS, nil, ipS,
 12627 		(*(*ipS).ilc_func)(self, symS, nil, ipS,
 12628                                    arg,
 12628 				   arg,
 12629                                    __MKSMALLINT(x),
 12629 				   __MKSMALLINT(x),
 12630                                    __MKSMALLINT(y),
 12630 				   __MKSMALLINT(y),
 12631                                    theView);
 12631 				   theView);
 12632                 break;
 12632 		break;
 12633 
 12633 
 12634            case WM_SYSCOLORCHANGE:
 12634 	   case WM_SYSCOLORCHANGE:
 12635                 DPRINTF((">>> WM_SYSCOLORCHANGE\n"));
 12635 		DPRINTF((">>> WM_SYSCOLORCHANGE\n"));
 12636                 (*sysClrChg.ilc_func)(self, @symbol(systemColorChange:), nil, &sysClrChg, theView);
 12636 		(*sysClrChg.ilc_func)(self, @symbol(systemColorChange:), nil, &sysClrChg, theView);
 12637                 break;
 12637 		break;
 12638 
 12638 
 12639            case WM_FONTCHANGE:
 12639 	   case WM_FONTCHANGE:
 12640                 DPRINTF((">>> WM_FONTCHANGE\n"));
 12640 		DPRINTF((">>> WM_FONTCHANGE\n"));
 12641                 (*fontChg.ilc_func)(self, @symbol(fontChange), nil, &fontChg);
 12641 		(*fontChg.ilc_func)(self, @symbol(fontChange), nil, &fontChg);
 12642                 break;
 12642 		break;
 12643 
 12643 
 12644            case WM_WININICHANGE:
 12644 	   case WM_WININICHANGE:
 12645                 DPRINTF((">>> WM_WININICHANGE\n"));
 12645 		DPRINTF((">>> WM_WININICHANGE\n"));
 12646                 (*settingChg.ilc_func)(self, @symbol(settingsChange), nil, &settingChg);
 12646 		(*settingChg.ilc_func)(self, @symbol(settingsChange), nil, &settingChg);
 12647                 break;
 12647 		break;
 12648 
 12648 
 12649            case WM_DISPLAYCHANGE:
 12649 	   case WM_DISPLAYCHANGE:
 12650                 DPRINTF((">>> WM_DISPLAYCHANGE\n"));
 12650 		DPRINTF((">>> WM_DISPLAYCHANGE\n"));
 12651                 (*fontChg.ilc_func)(self, @symbol(displayChange), nil, &fontChg);
 12651 		(*fontChg.ilc_func)(self, @symbol(displayChange), nil, &fontChg);
 12652                 break;
 12652 		break;
 12653 
 12653 
 12654            case WM_QUERYENDSESSION:
 12654 	   case WM_QUERYENDSESSION:
 12655                 DPRINTF((">>> WM_QUERYENDSESSION\n"));
 12655 		DPRINTF((">>> WM_QUERYENDSESSION\n"));
 12656                 (*qEndSess.ilc_func)(self, @symbol(queryEndSession), nil, &qEndSess);
 12656 		(*qEndSess.ilc_func)(self, @symbol(queryEndSession), nil, &qEndSess);
 12657                 break;
 12657 		break;
 12658 
 12658 
 12659 #ifdef LATER
 12659 #ifdef LATER
 12660            case WM_POWER:
 12660 	   case WM_POWER:
 12661                 DPRINTF((">>> WM_POWER\n"));
 12661 		DPRINTF((">>> WM_POWER\n"));
 12662                 (*power.ilc_func)(self, @symbol(powerDown), nil, &power);
 12662 		(*power.ilc_func)(self, @symbol(powerDown), nil, &power);
 12663                break;
 12663 	       break;
 12664 #endif
 12664 #endif
 12665             /* native widget actions */
 12665 	    /* native widget actions */
 12666             case WM_COMMAND:
 12666 	    case WM_COMMAND:
 12667                 DPRINTF((">>> WM_COMMAND\n"));
 12667 		DPRINTF((">>> WM_COMMAND\n"));
 12668                 (*command.ilc_func)(self, @symbol(nativeWidgetCommand:view:), nil, &command,
 12668 		(*command.ilc_func)(self, @symbol(nativeWidgetCommand:view:), nil, &command,
 12669                                 __MKSMALLINT(ev->ev_wParam), theView);
 12669 				__MKSMALLINT(ev->ev_wParam), theView);
 12670                break;
 12670 	       break;
 12671 
 12671 
 12672             /* tray action */
 12672 	    /* tray action */
 12673             case WM_TRAY_MESSAGE:
 12673 	    case WM_TRAY_MESSAGE:
 12674                 DPRINTF((">>> WM_TRAY_MESSAGE\n"));
 12674 		DPRINTF((">>> WM_TRAY_MESSAGE\n"));
 12675                 (*trayMessage.ilc_func)(self, @symbol(trayAction:view:), nil, &trayMessage,
 12675 		(*trayMessage.ilc_func)(self, @symbol(trayAction:view:), nil, &trayMessage,
 12676                                 __MKSMALLINT(ev->ev_arg1), theView);
 12676 				__MKSMALLINT(ev->ev_arg1), theView);
 12677                 break;
 12677 		break;
 12678 
 12678 
 12679             /* message from another process */
 12679 	    /* message from another process */
 12680             case WM_COPYDATA:
 12680 	    case WM_COPYDATA:
 12681                 DPRINTF((">>> WM_COPYDATA"));
 12681 		DPRINTF((">>> WM_COPYDATA"));
 12682                 {
 12682 		{
 12683                     OBJ eventData;
 12683 		    OBJ eventData;
 12684                     void *data = (void *)(ev->ev_arg1);
 12684 		    void *data = (void *)(ev->ev_arg1);
 12685                     DPRINTFIF((__debug_WM_COPYDATA__) , (">>> WM_COPYDATA %s (%d)\n", data, ev->ev_arg2));
 12685 		    DPRINTFIF((__debug_WM_COPYDATA__) , (">>> WM_COPYDATA %s (%d)\n", data, ev->ev_arg2));
 12686 
 12686 
 12687                     if (data) {
 12687 		    if (data) {
 12688                         eventData = __MKBYTEARRAY(data, (int)ev->ev_arg2);
 12688 			eventData = __MKBYTEARRAY(data, (int)ev->ev_arg2);
 12689                         free(data);     // see winEventProcessing()
 12689 			free(data);     // see winEventProcessing()
 12690                     } else {
 12690 		    } else {
 12691                         eventData = nil;
 12691 			eventData = nil;
 12692                     }
 12692 		    }
 12693                     (*copyData.ilc_func)(self, @symbol(copyDataEvent:eventData:view:), nil, &copyData,
 12693 		    (*copyData.ilc_func)(self, @symbol(copyDataEvent:eventData:view:), nil, &copyData,
 12694                                 __MKSMALLINT(ev->ev_wParam), eventData, theView);
 12694 				__MKSMALLINT(ev->ev_wParam), eventData, theView);
 12695                 }
 12695 		}
 12696                 break;
 12696 		break;
 12697 
 12697 
 12698 #ifdef LATER
 12698 #ifdef LATER
 12699             case WM_QUIT:
 12699 	    case WM_QUIT:
 12700                 DPRINTF((">>> WM_QUIT_MESSAGE\n"));
 12700 		DPRINTF((">>> WM_QUIT_MESSAGE\n"));
 12701                 (*quit.ilc_func)(self, @symbol(quitCommand:), nil, &quit);
 12701 		(*quit.ilc_func)(self, @symbol(quitCommand:), nil, &quit);
 12702                 break;
 12702 		break;
 12703 #endif
 12703 #endif
 12704             case WM_HSCROLL:
 12704 	    case WM_HSCROLL:
 12705             case WM_VSCROLL:
 12705 	    case WM_VSCROLL:
 12706                 {
 12706 		{
 12707                     int scrollCode = 0;
 12707 		    int scrollCode = 0;
 12708                     OBJ scrollCodeOrScrollCodeSymbol = nil, positionOrNil = nil;
 12708 		    OBJ scrollCodeOrScrollCodeSymbol = nil, positionOrNil = nil;
 12709                     int pos = 0;
 12709 		    int pos = 0;
 12710 
 12710 
 12711                     scrollCode = LOWORD(ev->ev_wParam);
 12711 		    scrollCode = LOWORD(ev->ev_wParam);
 12712                     scrollCodeOrScrollCodeSymbol = __MKSMALLINT(scrollCode);
 12712 		    scrollCodeOrScrollCodeSymbol = __MKSMALLINT(scrollCode);
 12713                     positionOrNil = nil;
 12713 		    positionOrNil = nil;
 12714                     switch (scrollCode) {
 12714 		    switch (scrollCode) {
 12715                         case SB_BOTTOM:
 12715 			case SB_BOTTOM:
 12716                             scrollCodeOrScrollCodeSymbol = @symbol(SB_BOTTOM);
 12716 			    scrollCodeOrScrollCodeSymbol = @symbol(SB_BOTTOM);
 12717                             break;
 12717 			    break;
 12718                         case SB_TOP:
 12718 			case SB_TOP:
 12719                             scrollCodeOrScrollCodeSymbol = @symbol(SB_TOP);
 12719 			    scrollCodeOrScrollCodeSymbol = @symbol(SB_TOP);
 12720                             break;
 12720 			    break;
 12721                         case SB_ENDSCROLL:
 12721 			case SB_ENDSCROLL:
 12722                             scrollCodeOrScrollCodeSymbol = @symbol(SB_ENDSCROLL);
 12722 			    scrollCodeOrScrollCodeSymbol = @symbol(SB_ENDSCROLL);
 12723                             break;
 12723 			    break;
 12724                         case SB_LINEDOWN:
 12724 			case SB_LINEDOWN:
 12725                             if (ev->ev_message == WM_HSCROLL) {
 12725 			    if (ev->ev_message == WM_HSCROLL) {
 12726                                 scrollCodeOrScrollCodeSymbol = @symbol(SB_LINERIGHT);
 12726 				scrollCodeOrScrollCodeSymbol = @symbol(SB_LINERIGHT);
 12727                             } else {
 12727 			    } else {
 12728                                 scrollCodeOrScrollCodeSymbol = @symbol(SB_LINEDOWN);
 12728 				scrollCodeOrScrollCodeSymbol = @symbol(SB_LINEDOWN);
 12729                             }
 12729 			    }
 12730                             break;
 12730 			    break;
 12731                         case SB_LINEUP:
 12731 			case SB_LINEUP:
 12732                             if (ev->ev_message == WM_HSCROLL) {
 12732 			    if (ev->ev_message == WM_HSCROLL) {
 12733                                 scrollCodeOrScrollCodeSymbol = @symbol(SB_LINELEFT);
 12733 				scrollCodeOrScrollCodeSymbol = @symbol(SB_LINELEFT);
 12734                             } else {
 12734 			    } else {
 12735                                 scrollCodeOrScrollCodeSymbol = @symbol(SB_LINEUP);
 12735 				scrollCodeOrScrollCodeSymbol = @symbol(SB_LINEUP);
 12736                             }
 12736 			    }
 12737                             break;
 12737 			    break;
 12738                         case SB_PAGEDOWN:
 12738 			case SB_PAGEDOWN:
 12739                             if (ev->ev_message == WM_HSCROLL) {
 12739 			    if (ev->ev_message == WM_HSCROLL) {
 12740                                 scrollCodeOrScrollCodeSymbol = @symbol(SB_PAGERIGHT);
 12740 				scrollCodeOrScrollCodeSymbol = @symbol(SB_PAGERIGHT);
 12741                             } else {
 12741 			    } else {
 12742                                 scrollCodeOrScrollCodeSymbol = @symbol(SB_PAGEDOWN);
 12742 				scrollCodeOrScrollCodeSymbol = @symbol(SB_PAGEDOWN);
 12743                             }
 12743 			    }
 12744                             break;
 12744 			    break;
 12745                         case SB_PAGEUP:
 12745 			case SB_PAGEUP:
 12746                             if (ev->ev_message == WM_HSCROLL) {
 12746 			    if (ev->ev_message == WM_HSCROLL) {
 12747                                 scrollCodeOrScrollCodeSymbol = @symbol(SB_PAGELEFT);
 12747 				scrollCodeOrScrollCodeSymbol = @symbol(SB_PAGELEFT);
 12748                             } else {
 12748 			    } else {
 12749                                 scrollCodeOrScrollCodeSymbol = @symbol(SB_PAGEUP);
 12749 				scrollCodeOrScrollCodeSymbol = @symbol(SB_PAGEUP);
 12750                             }
 12750 			    }
 12751                             break;
 12751 			    break;
 12752                         case SB_THUMBPOSITION:
 12752 			case SB_THUMBPOSITION:
 12753                             if (ev->ev_message == WM_HSCROLL) {
 12753 			    if (ev->ev_message == WM_HSCROLL) {
 12754                                 scrollCodeOrScrollCodeSymbol = @symbol(SB_THUMBPOSITIONHORIZONTAL);
 12754 				scrollCodeOrScrollCodeSymbol = @symbol(SB_THUMBPOSITIONHORIZONTAL);
 12755                             } else {
 12755 			    } else {
 12756                                 scrollCodeOrScrollCodeSymbol = @symbol(SB_THUMBPOSITIONVERTICAL);
 12756 				scrollCodeOrScrollCodeSymbol = @symbol(SB_THUMBPOSITIONVERTICAL);
 12757                             }
 12757 			    }
 12758                             pos = HIWORD(ev->ev_wParam);
 12758 			    pos = HIWORD(ev->ev_wParam);
 12759                             positionOrNil = __MKSMALLINT(pos);
 12759 			    positionOrNil = __MKSMALLINT(pos);
 12760                             break;
 12760 			    break;
 12761                         case SB_THUMBTRACK:
 12761 			case SB_THUMBTRACK:
 12762                             if (ev->ev_message == WM_HSCROLL) {
 12762 			    if (ev->ev_message == WM_HSCROLL) {
 12763                                 scrollCodeOrScrollCodeSymbol = @symbol(SB_THUMBTRACKHORIZONTAL);
 12763 				scrollCodeOrScrollCodeSymbol = @symbol(SB_THUMBTRACKHORIZONTAL);
 12764                             } else {
 12764 			    } else {
 12765                                 scrollCodeOrScrollCodeSymbol = @symbol(SB_THUMBTRACKVERTICAL);
 12765 				scrollCodeOrScrollCodeSymbol = @symbol(SB_THUMBTRACKVERTICAL);
 12766                             }
 12766 			    }
 12767                             pos = HIWORD(ev->ev_wParam);
 12767 			    pos = HIWORD(ev->ev_wParam);
 12768                             positionOrNil = __MKSMALLINT(pos);
 12768 			    positionOrNil = __MKSMALLINT(pos);
 12769                             break;
 12769 			    break;
 12770                         default:
 12770 			default:
 12771                             DPRINTF((">>> WM_SCROLL: unhandled scrollCode:%d %d\n", scrollCode));
 12771 			    DPRINTF((">>> WM_SCROLL: unhandled scrollCode:%d %d\n", scrollCode));
 12772                             break;
 12772 			    break;
 12773                     }
 12773 		    }
 12774                     NDPRINTF((">>> WM_SCROLL: %d %d\n", scrollCode, pos));
 12774 		    NDPRINTF((">>> WM_SCROLL: %d %d\n", scrollCode, pos));
 12775 
 12775 
 12776                     (*win32NativeScroll.ilc_func)(self, @symbol(win32NativeScroll:position:view:),
 12776 		    (*win32NativeScroll.ilc_func)(self, @symbol(win32NativeScroll:position:view:),
 12777                                         nil, &win32NativeScroll,
 12777 					nil, &win32NativeScroll,
 12778                                         scrollCodeOrScrollCodeSymbol,
 12778 					scrollCodeOrScrollCodeSymbol,
 12779                                         positionOrNil,
 12779 					positionOrNil,
 12780                                         theView);
 12780 					theView);
 12781                 }
 12781 		}
 12782                 break;
 12782 		break;
 12783 
 12783 
 12784             case WM_DRAWITEM:
 12784 	    case WM_DRAWITEM:
 12785                 {
 12785 		{
 12786                     NDPRINTF((">>> WM_DRAWITEM: wParam: %x\n", ev->ev_wParam));
 12786 		    NDPRINTF((">>> WM_DRAWITEM: wParam: %x\n", ev->ev_wParam));
 12787                     (*win32DrawItem.ilc_func)(self, @symbol(win32DrawItem:view:),
 12787 		    (*win32DrawItem.ilc_func)(self, @symbol(win32DrawItem:view:),
 12788                                         nil, &win32DrawItem,
 12788 					nil, &win32DrawItem,
 12789                                         __MKSMALLINT(ev->ev_wParam),
 12789 					__MKSMALLINT(ev->ev_wParam),
 12790                                         theView);
 12790 					theView);
 12791                 }
 12791 		}
 12792                 break;
 12792 		break;
 12793 
 12793 
 12794             default:
 12794 	    default:
 12795                 UNHANDLED_EVENT_PRINTF(("WinWorkstat [info]: >>> unhandled event: %x\n", ev->ev_message));
 12795 		UNHANDLED_EVENT_PRINTF(("WinWorkstat [info]: >>> unhandled event: %x\n", ev->ev_message));
 12796                 break;
 12796 		break;
 12797     }
 12797     }
 12798 %}.
 12798 %}.
 12799     ^ true
 12799     ^ true
 12800 !
 12800 !
 12801 
 12801 
 12807      expose events (which are sent after a bitblt). After such a bitblt,
 12807      expose events (which are sent after a bitblt). After such a bitblt,
 12808      we only handle exposes until the graphicsExpose arrives.
 12808      we only handle exposes until the graphicsExpose arrives.
 12809      Other systems may not need such a kludge"
 12809      Other systems may not need such a kludge"
 12810 
 12810 
 12811     [self eventPendingWithSync:false] whileTrue:[
 12811     [self eventPendingWithSync:false] whileTrue:[
 12812         (self getEventFor:nil withMask:nil) ifTrue:[
 12812 	(self getEventFor:nil withMask:nil) ifTrue:[
 12813             AbortOperationRequest handle:[:ex |
 12813 	    AbortOperationRequest handle:[:ex |
 12814                 ex return
 12814 		ex return
 12815             ] do:[
 12815 	    ] do:[
 12816                 self dispatchLastEvent.
 12816 		self dispatchLastEvent.
 12817                 "/ multi-screen config: give others a chance
 12817 		"/ multi-screen config: give others a chance
 12818                 "/ (needed because we run at high (non-timesliced) prio)
 12818 		"/ (needed because we run at high (non-timesliced) prio)
 12819                 Processor yield.
 12819 		Processor yield.
 12820             ]
 12820 	    ]
 12821         ].
 12821 	].
 12822     ]
 12822     ]
 12823 
 12823 
 12824     "Modified: 19.8.1997 / 17:11:18 / cg"
 12824     "Modified: 19.8.1997 / 17:11:18 / cg"
 12825 !
 12825 !
 12826 
 12826 
 12882 
 12882 
 12883     doSync notNil ifTrue:[self flush].
 12883     doSync notNil ifTrue:[self flush].
 12884 
 12884 
 12885 %{
 12885 %{
 12886     if (hasEventQueued()) {
 12886     if (hasEventQueued()) {
 12887         RETURN (true);
 12887 	RETURN (true);
 12888     }
 12888     }
 12889 %}.
 12889 %}.
 12890     ^ false
 12890     ^ false
 12891 !
 12891 !
 12892 
 12892 
 12906 
 12906 
 12907 %{  /* NOCONTEXT */
 12907 %{  /* NOCONTEXT */
 12908 
 12908 
 12909     DDDPRINTF(("peek q - "));
 12909     DDDPRINTF(("peek q - "));
 12910     if (hasEventQueued()) {
 12910     if (hasEventQueued()) {
 12911         DDDPRINTF(("true\n"));
 12911 	DDDPRINTF(("true\n"));
 12912         RETURN (true);
 12912 	RETURN (true);
 12913     }
 12913     }
 12914     DDDPRINTF(("false\n"));
 12914     DDDPRINTF(("false\n"));
 12915 %}.
 12915 %}.
 12916     ^ false
 12916     ^ false
 12917 !
 12917 !
 12948     struct queuedEvent *ev;
 12948     struct queuedEvent *ev;
 12949     struct queuedEvent *qev;
 12949     struct queuedEvent *qev;
 12950 
 12950 
 12951     eB = __INST(eventBuffer);
 12951     eB = __INST(eventBuffer);
 12952     if (! __isByteArray(eB)) {
 12952     if (! __isByteArray(eB)) {
 12953         console_fprintf(stderr, "WinWorkstation [error]: no eventBuffer\n");
 12953 	console_fprintf(stderr, "WinWorkstation [error]: no eventBuffer\n");
 12954         /* RETURN (false); */
 12954 	/* RETURN (false); */
 12955     } else {
 12955     } else {
 12956         ev = (struct queuedEvent *)(__ByteArrayInstPtr(eB)->ba_element);
 12956 	ev = (struct queuedEvent *)(__ByteArrayInstPtr(eB)->ba_element);
 12957         ev->ev_message = 0;
 12957 	ev->ev_message = 0;
 12958 
 12958 
 12959         if (__isSmallInteger(eventMask)) {
 12959 	if (__isSmallInteger(eventMask)) {
 12960             evMask = __intVal(eventMask);
 12960 	    evMask = __intVal(eventMask);
 12961         } else {
 12961 	} else {
 12962             evMask = ~0;
 12962 	    evMask = ~0;
 12963         }
 12963 	}
 12964         if (__isExternalAddress(aViewIdOrNil)) {
 12964 	if (__isExternalAddress(aViewIdOrNil)) {
 12965             wWanted = _HWNDVal(aViewIdOrNil);
 12965 	    wWanted = _HWNDVal(aViewIdOrNil);
 12966         } else{
 12966 	} else{
 12967             wWanted = 0;
 12967 	    wWanted = 0;
 12968         }
 12968 	}
 12969 
 12969 
 12970         do { /* only to allow continue */
 12970 	do { /* only to allow continue */
 12971             if (deqEvent(ev, wWanted, evMask)) {
 12971 	    if (deqEvent(ev, wWanted, evMask)) {
 12972 #ifdef COMPRESS_WINDOWPOSCHANGED
 12972 #ifdef COMPRESS_WINDOWPOSCHANGED
 12973                 if ((ev->ev_hWnd == lastPos_win)
 12973 		if ((ev->ev_hWnd == lastPos_win)
 12974                  && (ev->ev_message == WM_WINDOWPOSCHANGED)
 12974 		 && (ev->ev_message == WM_WINDOWPOSCHANGED)
 12975                  && ((ev->ev_x != lastPos_x)
 12975 		 && ((ev->ev_x != lastPos_x)
 12976                      || (ev->ev_y != lastPos_y)
 12976 		     || (ev->ev_y != lastPos_y)
 12977                      || (ev->ev_w != lastPos_w)
 12977 		     || (ev->ev_w != lastPos_w)
 12978                      || (ev->ev_h != lastPos_h))) {
 12978 		     || (ev->ev_h != lastPos_h))) {
 12979                     /*
 12979 		    /*
 12980                      * ignore intermediate resize events
 12980 		     * ignore intermediate resize events
 12981                      * (that event is an intermediate one, because the peek-values
 12981 		     * (that event is an intermediate one, because the peek-values
 12982                      *  have already been updated for another event)
 12982 		     *  have already been updated for another event)
 12983                      */
 12983 		     */
 12984                     EVENT_PRINTF(("ignored WINDOWPOSCHANGED (%d:%d / %d:%d / %d:%d / %d:%d\n",
 12984 		    EVENT_PRINTF(("ignored WINDOWPOSCHANGED (%d:%d / %d:%d / %d:%d / %d:%d\n",
 12985                                   ev->ev_x, lastPos_x,
 12985 				  ev->ev_x, lastPos_x,
 12986                                   ev->ev_y, lastPos_y,
 12986 				  ev->ev_y, lastPos_y,
 12987                                   ev->ev_w, lastPos_w,
 12987 				  ev->ev_w, lastPos_w,
 12988                                   ev->ev_h, lastPos_h ));
 12988 				  ev->ev_h, lastPos_h ));
 12989                     continue;
 12989 		    continue;
 12990                 }
 12990 		}
 12991 #endif
 12991 #endif
 12992                 RETURN ( true );
 12992 		RETURN ( true );
 12993             }
 12993 	    }
 12994         } while (0);
 12994 	} while (0);
 12995     }
 12995     }
 12996 %}.
 12996 %}.
 12997     ^ false
 12997     ^ false
 12998 !
 12998 !
 12999 
 12999 
 13017 %{
 13017 %{
 13018     registerHotKeyInfo * rhki = NULL;
 13018     registerHotKeyInfo * rhki = NULL;
 13019     HWND hWnd = NULL;
 13019     HWND hWnd = NULL;
 13020 
 13020 
 13021     if (__isExternalAddress(aDrawableId)) {
 13021     if (__isExternalAddress(aDrawableId)) {
 13022         hWnd = _HWNDVal(aDrawableId);
 13022 	hWnd = _HWNDVal(aDrawableId);
 13023 
 13023 
 13024         if (! hWnd) {
 13024 	if (! hWnd) {
 13025             RETURN (false);
 13025 	    RETURN (false);
 13026         }
 13026 	}
 13027     } else {
 13027     } else {
 13028         RETURN (false);
 13028 	RETURN (false);
 13029     }
 13029     }
 13030 
 13030 
 13031     rhki = (registerHotKeyInfo *) malloc(sizeof(registerHotKeyInfo));
 13031     rhki = (registerHotKeyInfo *) malloc(sizeof(registerHotKeyInfo));
 13032 
 13032 
 13033     rhki->hwnd       = hWnd;
 13033     rhki->hwnd       = hWnd;
 13036     rhki->virtualKey = __intVal(aVirtualKeyCode);
 13036     rhki->virtualKey = __intVal(aVirtualKeyCode);
 13037     rhki->finished   = 0;
 13037     rhki->finished   = 0;
 13038 
 13038 
 13039     // the same thread that created the window musr register the hotkey!
 13039     // the same thread that created the window musr register the hotkey!
 13040     if (PostThreadMessage(_dispatchThreadId, WM_THREAD_REGISTERHOTKEY, 0, (INT)rhki) == FALSE) {
 13040     if (PostThreadMessage(_dispatchThreadId, WM_THREAD_REGISTERHOTKEY, 0, (INT)rhki) == FALSE) {
 13041         console_fprintf(stderr, "WinWorkstation [error]: oops - PostThreadMessage(%x) failed in registerHotKeyForWindow: err=%d\n",
 13041 	console_fprintf(stderr, "WinWorkstation [error]: oops - PostThreadMessage(%x) failed in registerHotKeyForWindow: err=%d\n",
 13042                                         _dispatchThreadId, GetLastError() );
 13042 					_dispatchThreadId, GetLastError() );
 13043         RETURN (false);
 13043 	RETURN (false);
 13044     }
 13044     }
 13045     while (rhki->finished == 0) {
 13045     while (rhki->finished == 0) {
 13046         Sleep(2);   // milliseconds
 13046 	Sleep(2);   // milliseconds
 13047     }
 13047     }
 13048     error = __MKINT(rhki->errorCode);
 13048     error = __MKINT(rhki->errorCode);
 13049     free(rhki);
 13049     free(rhki);
 13050 %}.
 13050 %}.
 13051     ^ error == 0
 13051     ^ error == 0
 13059 
 13059 
 13060 %{  /* NOCONTEXT */
 13060 %{  /* NOCONTEXT */
 13061 
 13061 
 13062     if (__isExternalAddress(aWindowId)
 13062     if (__isExternalAddress(aWindowId)
 13063      && __isSmallInteger(aMask)) {
 13063      && __isSmallInteger(aMask)) {
 13064         HWND hWnd = _HWNDVal(aWindowId);
 13064 	HWND hWnd = _HWNDVal(aWindowId);
 13065         int mask = __intVal(aMask);
 13065 	int mask = __intVal(aMask);
 13066         localWindowInfo *lI;
 13066 	localWindowInfo *lI;
 13067 
 13067 
 13068         lI = GETLOCALWINDOWINFOPTR(hWnd);
 13068 	lI = GETLOCALWINDOWINFOPTR(hWnd);
 13069         if (lI) {
 13069 	if (lI) {
 13070 #ifdef DEBUGMASK
 13070 #ifdef DEBUGMASK
 13071             PRINTF(("new eventMask %x\n",mask));
 13071 	    PRINTF(("new eventMask %x\n",mask));
 13072             printMask(mask);
 13072 	    printMask(mask);
 13073 #endif
 13073 #endif
 13074             lI->eventMask = mask;
 13074 	    lI->eventMask = mask;
 13075             RETURN ( self );
 13075 	    RETURN ( self );
 13076         }
 13076 	}
 13077     }
 13077     }
 13078 %}.
 13078 %}.
 13079     self primitiveFailed
 13079     self primitiveFailed
 13080 !
 13080 !
 13081 
 13081 
 13087 %{
 13087 %{
 13088     registerHotKeyInfo * rhki = NULL;
 13088     registerHotKeyInfo * rhki = NULL;
 13089     HWND hWnd = NULL;
 13089     HWND hWnd = NULL;
 13090 
 13090 
 13091     if (__isExternalAddress(aDrawableId)) {
 13091     if (__isExternalAddress(aDrawableId)) {
 13092         hWnd = _HWNDVal(aDrawableId);
 13092 	hWnd = _HWNDVal(aDrawableId);
 13093 
 13093 
 13094         if (! hWnd) {
 13094 	if (! hWnd) {
 13095             RETURN (false);
 13095 	    RETURN (false);
 13096         }
 13096 	}
 13097     } else {
 13097     } else {
 13098         RETURN (false);
 13098 	RETURN (false);
 13099     }
 13099     }
 13100 
 13100 
 13101     rhki = (registerHotKeyInfo *) malloc(sizeof(registerHotKeyInfo));
 13101     rhki = (registerHotKeyInfo *) malloc(sizeof(registerHotKeyInfo));
 13102 
 13102 
 13103     rhki->hwnd       = hWnd;
 13103     rhki->hwnd       = hWnd;
 13105     rhki->modifier   = 0;
 13105     rhki->modifier   = 0;
 13106     rhki->virtualKey = 0;
 13106     rhki->virtualKey = 0;
 13107     rhki->finished   = 0;
 13107     rhki->finished   = 0;
 13108 
 13108 
 13109     if (PostThreadMessage(_dispatchThreadId, WM_THREAD_UNREGISTERHOTKEY, 0, (INT)rhki) == FALSE) {
 13109     if (PostThreadMessage(_dispatchThreadId, WM_THREAD_UNREGISTERHOTKEY, 0, (INT)rhki) == FALSE) {
 13110         console_fprintf(stderr, "WinWorkstation [error]: oops - PostThreadMessage(%x) failed in unregisterHotKeyForWindow: err=%d\n",
 13110 	console_fprintf(stderr, "WinWorkstation [error]: oops - PostThreadMessage(%x) failed in unregisterHotKeyForWindow: err=%d\n",
 13111                                         _dispatchThreadId, GetLastError() );
 13111 					_dispatchThreadId, GetLastError() );
 13112         RETURN (false);
 13112 	RETURN (false);
 13113     }
 13113     }
 13114 
 13114 
 13115     while (rhki->finished == 0) {
 13115     while (rhki->finished == 0) {
 13116         Sleep(2);   // milliseconds
 13116 	Sleep(2);   // milliseconds
 13117     }
 13117     }
 13118     error = __MKINT(rhki->errorCode);
 13118     error = __MKINT(rhki->errorCode);
 13119     free(rhki);
 13119     free(rhki);
 13120 %}.
 13120 %}.
 13121     ^ error == 0
 13121     ^ error == 0
 13135      (not very user friendly)"
 13135      (not very user friendly)"
 13136 
 13136 
 13137     |ok xLog yLog targetId|
 13137     |ok xLog yLog targetId|
 13138 
 13138 
 13139     (xPos notNil and:[yPos notNil]) ifTrue:[
 13139     (xPos notNil and:[yPos notNil]) ifTrue:[
 13140         "/ scale 0..width to 0..16rFFFF
 13140 	"/ scale 0..width to 0..16rFFFF
 13141         xLog := xPos * 16rFFFF // self width.
 13141 	xLog := xPos * 16rFFFF // self width.
 13142         yLog := yPos * 16rFFFF // self height.
 13142 	yLog := yPos * 16rFFFF // self height.
 13143     ].
 13143     ].
 13144     (targetIdArg notNil and:[targetIdArg ~= self rootWindowId]) ifTrue:[
 13144     (targetIdArg notNil and:[targetIdArg ~= self rootWindowId]) ifTrue:[
 13145         targetId := targetIdArg.
 13145 	targetId := targetIdArg.
 13146     ].
 13146     ].
 13147 
 13147 
 13148     ok := false.
 13148     ok := false.
 13149 %{
 13149 %{
 13150     BOOL rslt;
 13150     BOOL rslt;
 13159     int _shifted = 0;
 13159     int _shifted = 0;
 13160     int _xP = 0;
 13160     int _xP = 0;
 13161     int _yP = 0;
 13161     int _yP = 0;
 13162 
 13162 
 13163     if (__isExternalAddress(targetId)) {
 13163     if (__isExternalAddress(targetId)) {
 13164         hWnd = _HWNDVal(targetId);
 13164 	hWnd = _HWNDVal(targetId);
 13165     }
 13165     }
 13166     if (__isSmallInteger(keySymCodeOrButtonNr)) {
 13166     if (__isSmallInteger(keySymCodeOrButtonNr)) {
 13167         _keyCodeOrButtonNr = __intVal(keySymCodeOrButtonNr);
 13167 	_keyCodeOrButtonNr = __intVal(keySymCodeOrButtonNr);
 13168     } else {
 13168     } else {
 13169         if (__isCharacter(keySymCodeOrButtonNr)) {
 13169 	if (__isCharacter(keySymCodeOrButtonNr)) {
 13170 
 13170 
 13171             _keyCodeOrButtonNr = __intVal(__characterVal(keySymCodeOrButtonNr));
 13171 	    _keyCodeOrButtonNr = __intVal(__characterVal(keySymCodeOrButtonNr));
 13172             DPRINTF(("code: %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13172 	    DPRINTF(("code: %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13173             if ((_keyCodeOrButtonNr >= 'a') && (_keyCodeOrButtonNr <= 'z')) {
 13173 	    if ((_keyCodeOrButtonNr >= 'a') && (_keyCodeOrButtonNr <= 'z')) {
 13174                 _keyCodeOrButtonNr -= 0x20;
 13174 		_keyCodeOrButtonNr -= 0x20;
 13175                 DPRINTF(("code: %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13175 		DPRINTF(("code: %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13176             } else {
 13176 	    } else {
 13177                 if ((_keyCodeOrButtonNr >= 'A') && (_keyCodeOrButtonNr <= 'Z')) {
 13177 		if ((_keyCodeOrButtonNr >= 'A') && (_keyCodeOrButtonNr <= 'Z')) {
 13178                     DPRINTF(("code: shifted %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13178 		    DPRINTF(("code: shifted %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13179                     _shifted = 1;
 13179 		    _shifted = 1;
 13180                 }
 13180 		}
 13181             }
 13181 	    }
 13182         } else if (keySymCodeOrButtonNr == @symbol(Return)) {
 13182 	} else if (keySymCodeOrButtonNr == @symbol(Return)) {
 13183             _keyCodeOrButtonNr = VK_RETURN;
 13183 	    _keyCodeOrButtonNr = VK_RETURN;
 13184         } else if (keySymCodeOrButtonNr == @symbol(Enter)) {
 13184 	} else if (keySymCodeOrButtonNr == @symbol(Enter)) {
 13185             _keyCodeOrButtonNr = VK_RETURN;
 13185 	    _keyCodeOrButtonNr = VK_RETURN;
 13186         } else if (keySymCodeOrButtonNr == @symbol(BackSpace)) {
 13186 	} else if (keySymCodeOrButtonNr == @symbol(BackSpace)) {
 13187             _keyCodeOrButtonNr = VK_BACK;
 13187 	    _keyCodeOrButtonNr = VK_BACK;
 13188         } else if (keySymCodeOrButtonNr == @symbol(Tab)) {
 13188 	} else if (keySymCodeOrButtonNr == @symbol(Tab)) {
 13189             _keyCodeOrButtonNr = VK_TAB;
 13189 	    _keyCodeOrButtonNr = VK_TAB;
 13190         } else if (keySymCodeOrButtonNr == @symbol(Shift)) {
 13190 	} else if (keySymCodeOrButtonNr == @symbol(Shift)) {
 13191             _keyCodeOrButtonNr = VK_SHIFT;
 13191 	    _keyCodeOrButtonNr = VK_SHIFT;
 13192         } else if (keySymCodeOrButtonNr == @symbol(Ctrl)) {
 13192 	} else if (keySymCodeOrButtonNr == @symbol(Ctrl)) {
 13193             _keyCodeOrButtonNr = VK_CONTROL;
 13193 	    _keyCodeOrButtonNr = VK_CONTROL;
 13194         } else if (keySymCodeOrButtonNr == @symbol(Menu)) {
 13194 	} else if (keySymCodeOrButtonNr == @symbol(Menu)) {
 13195             _keyCodeOrButtonNr = VK_MENU;
 13195 	    _keyCodeOrButtonNr = VK_MENU;
 13196         } else if (keySymCodeOrButtonNr == @symbol(Escape)) {
 13196 	} else if (keySymCodeOrButtonNr == @symbol(Escape)) {
 13197             _keyCodeOrButtonNr = VK_ESCAPE;
 13197 	    _keyCodeOrButtonNr = VK_ESCAPE;
 13198         } else if (keySymCodeOrButtonNr == @symbol(Space)) {
 13198 	} else if (keySymCodeOrButtonNr == @symbol(Space)) {
 13199             _keyCodeOrButtonNr = VK_SPACE;
 13199 	    _keyCodeOrButtonNr = VK_SPACE;
 13200         } else if (keySymCodeOrButtonNr == @symbol(Prior)) {
 13200 	} else if (keySymCodeOrButtonNr == @symbol(Prior)) {
 13201             _keyCodeOrButtonNr = VK_PRIOR;
 13201 	    _keyCodeOrButtonNr = VK_PRIOR;
 13202         } else if (keySymCodeOrButtonNr == @symbol(Next)) {
 13202 	} else if (keySymCodeOrButtonNr == @symbol(Next)) {
 13203             _keyCodeOrButtonNr = VK_NEXT;
 13203 	    _keyCodeOrButtonNr = VK_NEXT;
 13204         } else if (keySymCodeOrButtonNr == @symbol(End)) {
 13204 	} else if (keySymCodeOrButtonNr == @symbol(End)) {
 13205             _keyCodeOrButtonNr = VK_END;
 13205 	    _keyCodeOrButtonNr = VK_END;
 13206         } else if (keySymCodeOrButtonNr == @symbol(Home)) {
 13206 	} else if (keySymCodeOrButtonNr == @symbol(Home)) {
 13207             _keyCodeOrButtonNr = VK_HOME;
 13207 	    _keyCodeOrButtonNr = VK_HOME;
 13208         } else if (keySymCodeOrButtonNr == @symbol(Left)) {
 13208 	} else if (keySymCodeOrButtonNr == @symbol(Left)) {
 13209             _keyCodeOrButtonNr = VK_LEFT;
 13209 	    _keyCodeOrButtonNr = VK_LEFT;
 13210         } else if (keySymCodeOrButtonNr == @symbol(Right)) {
 13210 	} else if (keySymCodeOrButtonNr == @symbol(Right)) {
 13211             _keyCodeOrButtonNr = VK_RIGHT;
 13211 	    _keyCodeOrButtonNr = VK_RIGHT;
 13212         } else if (keySymCodeOrButtonNr == @symbol(Down)) {
 13212 	} else if (keySymCodeOrButtonNr == @symbol(Down)) {
 13213             _keyCodeOrButtonNr = VK_DOWN;
 13213 	    _keyCodeOrButtonNr = VK_DOWN;
 13214         } else if (keySymCodeOrButtonNr == @symbol(Up)) {
 13214 	} else if (keySymCodeOrButtonNr == @symbol(Up)) {
 13215             _keyCodeOrButtonNr = VK_UP;
 13215 	    _keyCodeOrButtonNr = VK_UP;
 13216         } else if (keySymCodeOrButtonNr == @symbol(Insert)) {
 13216 	} else if (keySymCodeOrButtonNr == @symbol(Insert)) {
 13217             _keyCodeOrButtonNr = VK_INSERT;
 13217 	    _keyCodeOrButtonNr = VK_INSERT;
 13218         } else if (keySymCodeOrButtonNr == @symbol(Delete)) {
 13218 	} else if (keySymCodeOrButtonNr == @symbol(Delete)) {
 13219             _keyCodeOrButtonNr = VK_DELETE;
 13219 	    _keyCodeOrButtonNr = VK_DELETE;
 13220         } else if (keySymCodeOrButtonNr == @symbol(Help)) {
 13220 	} else if (keySymCodeOrButtonNr == @symbol(Help)) {
 13221             _keyCodeOrButtonNr = VK_HELP;
 13221 	    _keyCodeOrButtonNr = VK_HELP;
 13222         } else if (keySymCodeOrButtonNr == @symbol(F1)) {
 13222 	} else if (keySymCodeOrButtonNr == @symbol(F1)) {
 13223             _keyCodeOrButtonNr = VK_F1;
 13223 	    _keyCodeOrButtonNr = VK_F1;
 13224         } else if (keySymCodeOrButtonNr == @symbol(F2)) {
 13224 	} else if (keySymCodeOrButtonNr == @symbol(F2)) {
 13225             _keyCodeOrButtonNr = VK_F2;
 13225 	    _keyCodeOrButtonNr = VK_F2;
 13226         } else if (keySymCodeOrButtonNr == @symbol(F3)) {
 13226 	} else if (keySymCodeOrButtonNr == @symbol(F3)) {
 13227             _keyCodeOrButtonNr = VK_F3;
 13227 	    _keyCodeOrButtonNr = VK_F3;
 13228         } else if (keySymCodeOrButtonNr == @symbol(F4)) {
 13228 	} else if (keySymCodeOrButtonNr == @symbol(F4)) {
 13229             _keyCodeOrButtonNr = VK_F4;
 13229 	    _keyCodeOrButtonNr = VK_F4;
 13230         } else if (keySymCodeOrButtonNr == @symbol(F5)) {
 13230 	} else if (keySymCodeOrButtonNr == @symbol(F5)) {
 13231             _keyCodeOrButtonNr = VK_F5;
 13231 	    _keyCodeOrButtonNr = VK_F5;
 13232         } else if (keySymCodeOrButtonNr == @symbol(F6)) {
 13232 	} else if (keySymCodeOrButtonNr == @symbol(F6)) {
 13233             _keyCodeOrButtonNr = VK_F6;
 13233 	    _keyCodeOrButtonNr = VK_F6;
 13234         } else if (keySymCodeOrButtonNr == @symbol(F7)) {
 13234 	} else if (keySymCodeOrButtonNr == @symbol(F7)) {
 13235             _keyCodeOrButtonNr = VK_F7;
 13235 	    _keyCodeOrButtonNr = VK_F7;
 13236         } else if (keySymCodeOrButtonNr == @symbol(F8)) {
 13236 	} else if (keySymCodeOrButtonNr == @symbol(F8)) {
 13237             _keyCodeOrButtonNr = VK_F8;
 13237 	    _keyCodeOrButtonNr = VK_F8;
 13238         } else if (keySymCodeOrButtonNr == @symbol(F9)) {
 13238 	} else if (keySymCodeOrButtonNr == @symbol(F9)) {
 13239             _keyCodeOrButtonNr = VK_F9;
 13239 	    _keyCodeOrButtonNr = VK_F9;
 13240         } else if (keySymCodeOrButtonNr == @symbol(F10)) {
 13240 	} else if (keySymCodeOrButtonNr == @symbol(F10)) {
 13241             _keyCodeOrButtonNr = VK_F10;
 13241 	    _keyCodeOrButtonNr = VK_F10;
 13242         } else if (keySymCodeOrButtonNr == @symbol(F11)) {
 13242 	} else if (keySymCodeOrButtonNr == @symbol(F11)) {
 13243             _keyCodeOrButtonNr = VK_F11;
 13243 	    _keyCodeOrButtonNr = VK_F11;
 13244         } else if (keySymCodeOrButtonNr == @symbol(F12)) {
 13244 	} else if (keySymCodeOrButtonNr == @symbol(F12)) {
 13245             _keyCodeOrButtonNr = VK_F12;
 13245 	    _keyCodeOrButtonNr = VK_F12;
 13246         } else {
 13246 	} else {
 13247             console_printf("bad key\n");
 13247 	    console_printf("bad key\n");
 13248             goto getOutOfHere;
 13248 	    goto getOutOfHere;
 13249         }
 13249 	}
 13250     }
 13250     }
 13251     if (__isSmallInteger(xLog)) {
 13251     if (__isSmallInteger(xLog)) {
 13252         _xP = __intVal(xLog);
 13252 	_xP = __intVal(xLog);
 13253     }
 13253     }
 13254     if (__isSmallInteger(yLog)) {
 13254     if (__isSmallInteger(yLog)) {
 13255         _yP = __intVal(yLog);
 13255 	_yP = __intVal(yLog);
 13256     }
 13256     }
 13257     lParam = _xP | (_yP << 16);
 13257     lParam = _xP | (_yP << 16);
 13258 
 13258 
 13259     if (typeSymbol == @symbol(buttonPress)) {
 13259     if (typeSymbol == @symbol(buttonPress)) {
 13260         _isMouseEvent = 1;
 13260 	_isMouseEvent = 1;
 13261         switch (_keyCodeOrButtonNr) {
 13261 	switch (_keyCodeOrButtonNr) {
 13262             case 1:
 13262 	    case 1:
 13263                 msg = WM_LBUTTONDOWN;
 13263 		msg = WM_LBUTTONDOWN;
 13264                 wParam = MK_LBUTTON;
 13264 		wParam = MK_LBUTTON;
 13265                 dwFlags = MOUSEEVENTF_LEFTDOWN;
 13265 		dwFlags = MOUSEEVENTF_LEFTDOWN;
 13266                 break;
 13266 		break;
 13267             case 2:
 13267 	    case 2:
 13268                 msg = WM_MBUTTONDOWN;
 13268 		msg = WM_MBUTTONDOWN;
 13269                 wParam = MK_MBUTTON;
 13269 		wParam = MK_MBUTTON;
 13270                 dwFlags = MOUSEEVENTF_MIDDLEDOWN;
 13270 		dwFlags = MOUSEEVENTF_MIDDLEDOWN;
 13271                 break;
 13271 		break;
 13272             case 3:
 13272 	    case 3:
 13273                 msg = WM_RBUTTONDOWN;
 13273 		msg = WM_RBUTTONDOWN;
 13274                 wParam = MK_RBUTTON;
 13274 		wParam = MK_RBUTTON;
 13275                 dwFlags = MOUSEEVENTF_RIGHTDOWN;
 13275 		dwFlags = MOUSEEVENTF_RIGHTDOWN;
 13276                 break;
 13276 		break;
 13277             default:
 13277 	    default:
 13278                 console_printf("bad button\n");
 13278 		console_printf("bad button\n");
 13279                 goto getOutOfHere;
 13279 		goto getOutOfHere;
 13280         }
 13280 	}
 13281     } else if (typeSymbol == @symbol(buttonRelease)) {
 13281     } else if (typeSymbol == @symbol(buttonRelease)) {
 13282         _isMouseEvent = 1;
 13282 	_isMouseEvent = 1;
 13283         switch (_keyCodeOrButtonNr) {
 13283 	switch (_keyCodeOrButtonNr) {
 13284             case 1:
 13284 	    case 1:
 13285                 msg = WM_LBUTTONUP;
 13285 		msg = WM_LBUTTONUP;
 13286                 dwFlags = MOUSEEVENTF_LEFTUP;
 13286 		dwFlags = MOUSEEVENTF_LEFTUP;
 13287                 break;
 13287 		break;
 13288             case 2:
 13288 	    case 2:
 13289                 msg = WM_MBUTTONUP;
 13289 		msg = WM_MBUTTONUP;
 13290                 dwFlags = MOUSEEVENTF_MIDDLEUP;
 13290 		dwFlags = MOUSEEVENTF_MIDDLEUP;
 13291                 break;
 13291 		break;
 13292             case 3:
 13292 	    case 3:
 13293                 msg = WM_RBUTTONUP;
 13293 		msg = WM_RBUTTONUP;
 13294                 dwFlags = MOUSEEVENTF_RIGHTUP;
 13294 		dwFlags = MOUSEEVENTF_RIGHTUP;
 13295                 break;
 13295 		break;
 13296             default:
 13296 	    default:
 13297                 console_printf("bad button\n");
 13297 		console_printf("bad button\n");
 13298                 goto getOutOfHere;
 13298 		goto getOutOfHere;
 13299         }
 13299 	}
 13300     } else if ((typeSymbol == @symbol(keyPress)) || (typeSymbol == @symbol(keyRelease))) {
 13300     } else if ((typeSymbol == @symbol(keyPress)) || (typeSymbol == @symbol(keyRelease))) {
 13301         dwFlags = 0;
 13301 	dwFlags = 0;
 13302         if (typeSymbol == @symbol(keyRelease)) dwFlags = KEYEVENTF_KEYUP;
 13302 	if (typeSymbol == @symbol(keyRelease)) dwFlags = KEYEVENTF_KEYUP;
 13303     } else {
 13303     } else {
 13304         console_printf("bad typeSymbol\n");
 13304 	console_printf("bad typeSymbol\n");
 13305         goto getOutOfHere;
 13305 	goto getOutOfHere;
 13306     }
 13306     }
 13307     if (_isMouseEvent) {
 13307     if (_isMouseEvent) {
 13308         if ((xPos == nil) || (yPos == nil)) {
 13308 	if ((xPos == nil) || (yPos == nil)) {
 13309             console_printf("bad x/y\n");
 13309 	    console_printf("bad x/y\n");
 13310             goto getOutOfHere;
 13310 	    goto getOutOfHere;
 13311         }
 13311 	}
 13312     }
 13312     }
 13313 
 13313 
 13314     if (hWnd == 0) {
 13314     if (hWnd == 0) {
 13315         // send to screen
 13315 	// send to screen
 13316         if ((xPos != nil) && (yPos != nil)) {
 13316 	if ((xPos != nil) && (yPos != nil)) {
 13317             mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, _xP, _yP, 0, NULL);
 13317 	    mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, _xP, _yP, 0, NULL);
 13318         }
 13318 	}
 13319 
 13319 
 13320         if (_isMouseEvent) {
 13320 	if (_isMouseEvent) {
 13321             DPRINTF(("mouse %08x %d/%d\n", dwFlags | MOUSEEVENTF_ABSOLUTE, _xP, _yP));
 13321 	    DPRINTF(("mouse %08x %d/%d\n", dwFlags | MOUSEEVENTF_ABSOLUTE, _xP, _yP));
 13322             mouse_event(dwFlags | MOUSEEVENTF_ABSOLUTE, _xP, _yP, 0, NULL);
 13322 	    mouse_event(dwFlags | MOUSEEVENTF_ABSOLUTE, _xP, _yP, 0, NULL);
 13323         } else {
 13323 	} else {
 13324             if (_shifted) {
 13324 	    if (_shifted) {
 13325                 DPRINTF(("shifted keybd #%08x %d (#%02x)\n", dwFlags, _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13325 		DPRINTF(("shifted keybd #%08x %d (#%02x)\n", dwFlags, _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13326                 keybd_event( VK_SHIFT, 0 /* _keyCodeOrButtonNr */, 0, 0);
 13326 		keybd_event( VK_SHIFT, 0 /* _keyCodeOrButtonNr */, 0, 0);
 13327                 keybd_event( _keyCodeOrButtonNr, 0 /* _keyCodeOrButtonNr */, dwFlags, 0);
 13327 		keybd_event( _keyCodeOrButtonNr, 0 /* _keyCodeOrButtonNr */, dwFlags, 0);
 13328                 keybd_event( VK_SHIFT, 0 /* _keyCodeOrButtonNr */, KEYEVENTF_KEYUP, 0);
 13328 		keybd_event( VK_SHIFT, 0 /* _keyCodeOrButtonNr */, KEYEVENTF_KEYUP, 0);
 13329             } else {
 13329 	    } else {
 13330                 DPRINTF(("keybd #%08x %d (#%02x)\n", dwFlags, _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13330 		DPRINTF(("keybd #%08x %d (#%02x)\n", dwFlags, _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13331                 keybd_event( _keyCodeOrButtonNr, 0 /* _keyCodeOrButtonNr */, dwFlags, 0);
 13331 		keybd_event( _keyCodeOrButtonNr, 0 /* _keyCodeOrButtonNr */, dwFlags, 0);
 13332             }
 13332 	    }
 13333         }
 13333 	}
 13334     } else {
 13334     } else {
 13335         rslt = PostMessage(hWnd, msg, wParam, lParam);
 13335 	rslt = PostMessage(hWnd, msg, wParam, lParam);
 13336     }
 13336     }
 13337     ok = true;
 13337     ok = true;
 13338 
 13338 
 13339 getOutOfHere: ;
 13339 getOutOfHere: ;
 13340 %}.
 13340 %}.
 13341     ok ifFalse:[
 13341     ok ifFalse:[
 13342         'WinWorkstation [warning]: sendKeyOrButtonEvent unimplemented' infoPrintCR.
 13342 	'WinWorkstation [warning]: sendKeyOrButtonEvent unimplemented' infoPrintCR.
 13343         self primitiveFailed.
 13343 	self primitiveFailed.
 13344     ].
 13344     ].
 13345     ^ ok
 13345     ^ ok
 13346 ! !
 13346 ! !
 13347 
 13347 
 13348 !WinWorkstation methodsFor:'font stuff'!
 13348 !WinWorkstation methodsFor:'font stuff'!
 13355 %{
 13355 %{
 13356     HGDIOBJ hFont;
 13356     HGDIOBJ hFont;
 13357     char *fn;
 13357     char *fn;
 13358 
 13358 
 13359     if (__isStringLike(aFontName)) {
 13359     if (__isStringLike(aFontName)) {
 13360         fn = __stringVal(aFontName);
 13360 	fn = __stringVal(aFontName);
 13361         if ((strcmp(fn, "fixed") == 0) || (strcmp(fn, "ANSI_FIXED_FONT") == 0)) {
 13361 	if ((strcmp(fn, "fixed") == 0) || (strcmp(fn, "ANSI_FIXED_FONT") == 0)) {
 13362             hFont = GetStockObject(ANSI_FIXED_FONT);
 13362 	    hFont = GetStockObject(ANSI_FIXED_FONT);
 13363         } else if ((strcmp(fn, "variable") == 0) || (strcmp(fn, "ANSI_VAR_FONT") == 0)) {
 13363 	} else if ((strcmp(fn, "variable") == 0) || (strcmp(fn, "ANSI_VAR_FONT") == 0)) {
 13364             hFont = GetStockObject(ANSI_VAR_FONT);
 13364 	    hFont = GetStockObject(ANSI_VAR_FONT);
 13365         } else if ((strcmp(fn, "system") == 0) || (strcmp(fn, "SYSTEM_FONT") == 0)) {
 13365 	} else if ((strcmp(fn, "system") == 0) || (strcmp(fn, "SYSTEM_FONT") == 0)) {
 13366             hFont = GetStockObject(SYSTEM_FONT);
 13366 	    hFont = GetStockObject(SYSTEM_FONT);
 13367         } else if ((strcmp(fn, "systemFixed") == 0) || (strcmp(fn, "SYSTEM_FIXED_FONT") == 0)) {
 13367 	} else if ((strcmp(fn, "systemFixed") == 0) || (strcmp(fn, "SYSTEM_FIXED_FONT") == 0)) {
 13368             hFont = GetStockObject(SYSTEM_FIXED_FONT);
 13368 	    hFont = GetStockObject(SYSTEM_FIXED_FONT);
 13369         } else if ((strcmp(fn, "deviceDefault") == 0) || (strcmp(fn, "DEVICE_DEFAULT_FONT") == 0)) {
 13369 	} else if ((strcmp(fn, "deviceDefault") == 0) || (strcmp(fn, "DEVICE_DEFAULT_FONT") == 0)) {
 13370             hFont = GetStockObject(DEVICE_DEFAULT_FONT);
 13370 	    hFont = GetStockObject(DEVICE_DEFAULT_FONT);
 13371         } else {
 13371 	} else {
 13372             hFont = GetStockObject(ANSI_FIXED_FONT);
 13372 	    hFont = GetStockObject(ANSI_FIXED_FONT);
 13373         }
 13373 	}
 13374         if (hFont) {
 13374 	if (hFont) {
 13375             DPRINTF(("createFontFor:%s -> %x\n", fn, hFont));
 13375 	    DPRINTF(("createFontFor:%s -> %x\n", fn, hFont));
 13376             RETURN ( __MKOBJ(hFont) );
 13376 	    RETURN ( __MKOBJ(hFont) );
 13377         }
 13377 	}
 13378     }
 13378     }
 13379 %}.
 13379 %}.
 13380     ^ nil
 13380     ^ nil
 13381 !
 13381 !
 13382 
 13382 
 13398     logicalSize := logicalSize abs.
 13398     logicalSize := logicalSize abs.
 13399     "/ convert from device to point size
 13399     "/ convert from device to point size
 13400     pointSize := (logicalSize / self getLogicalPixelSizeY * 72.0).
 13400     pointSize := (logicalSize / self getLogicalPixelSizeY * 72.0).
 13401 
 13401 
 13402     fntDescr := FontDescription
 13402     fntDescr := FontDescription
 13403                     family:family
 13403 		    family:family
 13404                     face:face
 13404 		    face:face
 13405                     style:style
 13405 		    style:style
 13406                     size:pointSize
 13406 		    size:pointSize
 13407                     sizeUnit:#pt
 13407 		    sizeUnit:#pt
 13408                     encoding:encoding.
 13408 		    encoding:encoding.
 13409     fntDescr setPixelSize:logicalSize.
 13409     fntDescr setPixelSize:logicalSize.
 13410     ^ fntDescr.
 13410     ^ fntDescr.
 13411 
 13411 
 13412     "Modified: / 09-11-2010 / 13:00:18 / cg"
 13412     "Modified: / 09-11-2010 / 13:00:18 / cg"
 13413 !
 13413 !
 13417 
 13417 
 13418     |rawData info|
 13418     |rawData info|
 13419 
 13419 
 13420     rawData := Array new:15.
 13420     rawData := Array new:15.
 13421     (self primFontMetricsOf:fontId intoArray:rawData) isNil ifTrue:[
 13421     (self primFontMetricsOf:fontId intoArray:rawData) isNil ifTrue:[
 13422         self primitiveFailed.
 13422 	self primitiveFailed.
 13423         ^ self
 13423 	^ self
 13424     ].
 13424     ].
 13425 
 13425 
 13426     info := DeviceWorkstation::DeviceFontMetrics new.
 13426     info := DeviceWorkstation::DeviceFontMetrics new.
 13427     info
 13427     info
 13428       ascent:(rawData at:1)
 13428       ascent:(rawData at:1)
 13449     allFonts := self listOfAvailableFonts.
 13449     allFonts := self listOfAvailableFonts.
 13450     allFonts isNil ifTrue:[^ nil].
 13450     allFonts isNil ifTrue:[^ nil].
 13451 
 13451 
 13452     fonts := Set new.
 13452     fonts := Set new.
 13453     allFonts do:[:fntDescr |
 13453     allFonts do:[:fntDescr |
 13454         (aFamilyName sameAs:(fntDescr family)) ifTrue:[
 13454 	(aFamilyName sameAs:(fntDescr family)) ifTrue:[
 13455             (filter isNil or:[filter value:fntDescr]) ifTrue:[
 13455 	    (filter isNil or:[filter value:fntDescr]) ifTrue:[
 13456                 fonts add:fntDescr
 13456 		fonts add:fntDescr
 13457             ]
 13457 	    ]
 13458         ]
 13458 	]
 13459     ].
 13459     ].
 13460     ^ fonts
 13460     ^ fonts
 13461 !
 13461 !
 13462 
 13462 
 13463 getAvailableFontsMatching:pattern
 13463 getAvailableFontsMatching:pattern
 13472 
 13472 
 13473      ^ self createFontFor:'fixed'
 13473      ^ self createFontFor:'fixed'
 13474 !
 13474 !
 13475 
 13475 
 13476 getFontWithFamily:familyString face:faceString
 13476 getFontWithFamily:familyString face:faceString
 13477             style:styleArgString size:sizeArg sizeUnit:sizeUnitArg
 13477 	    style:styleArgString size:sizeArg sizeUnit:sizeUnitArg
 13478             encoding:encoding
 13478 	    encoding:encoding
 13479 
 13479 
 13480     "try to get the specified font, if not available, try the next smaller
 13480     "try to get the specified font, if not available, try the next smaller
 13481      font."
 13481      font."
 13482 
 13482 
 13483     |styleString theName theId xlatedStyle id spacing pxSize ptSize encodingSym|
 13483     |styleString theName theId xlatedStyle id spacing pxSize ptSize encodingSym|
 13484 
 13484 
 13485     styleString := styleArgString.
 13485     styleString := styleArgString.
 13486     encoding isEmptyOrNil ifTrue:[
 13486     encoding isEmptyOrNil ifTrue:[
 13487         encodingSym := #'ms-default' "/ encoding.
 13487 	encodingSym := #'ms-default' "/ encoding.
 13488     ] ifFalse:[
 13488     ] ifFalse:[
 13489         encodingSym := encoding asLowercase asSymbol.
 13489 	encodingSym := encoding asLowercase asSymbol.
 13490     ].
 13490     ].
 13491 
 13491 
 13492     "special: if face is nil, allow access to X-fonts"
 13492     "special: if face is nil, allow access to X-fonts"
 13493     faceString isNil ifTrue:[
 13493     faceString isNil ifTrue:[
 13494         sizeArg notNil ifTrue:[
 13494 	sizeArg notNil ifTrue:[
 13495             theName := familyString , '-' , sizeArg printString
 13495 	    theName := familyString , '-' , sizeArg printString
 13496         ] ifFalse:[
 13496 	] ifFalse:[
 13497             theName := familyString
 13497 	    theName := familyString
 13498         ].
 13498 	].
 13499         theName notNil ifTrue:[
 13499 	theName notNil ifTrue:[
 13500             theId := self createFontFor:theName.
 13500 	    theId := self createFontFor:theName.
 13501         ].
 13501 	].
 13502         theId isNil ifTrue:[
 13502 	theId isNil ifTrue:[
 13503             theId := self getDefaultFontWithEncoding:encoding
 13503 	    theId := self getDefaultFontWithEncoding:encoding
 13504         ].
 13504 	].
 13505         ^ theId
 13505 	^ theId
 13506     ].
 13506     ].
 13507 
 13507 
 13508     "/ spacing other than 'normal' is contained as last component
 13508     "/ spacing other than 'normal' is contained as last component
 13509     "/ in style
 13509     "/ in style
 13510     styleString notNil ifTrue:[
 13510     styleString notNil ifTrue:[
 13511         ((styleString endsWith:'-narrow')
 13511 	((styleString endsWith:'-narrow')
 13512          or:[styleString endsWith:'-semicondensed']) ifTrue:[
 13512 	 or:[styleString endsWith:'-semicondensed']) ifTrue:[
 13513             |i|
 13513 	    |i|
 13514             i := styleString lastIndexOf:$-.
 13514 	    i := styleString lastIndexOf:$-.
 13515             spacing := styleString copyFrom:(i+1).
 13515 	    spacing := styleString copyFrom:(i+1).
 13516             styleString := styleString copyTo:(i-1).
 13516 	    styleString := styleString copyTo:(i-1).
 13517         ] ifFalse:[
 13517 	] ifFalse:[
 13518             spacing := #normal.
 13518 	    spacing := #normal.
 13519         ].
 13519 	].
 13520     ].
 13520     ].
 13521 
 13521 
 13522     xlatedStyle := styleString.
 13522     xlatedStyle := styleString.
 13523     xlatedStyle notNil ifTrue:[
 13523     xlatedStyle notNil ifTrue:[
 13524         xlatedStyle := xlatedStyle first asString
 13524 	xlatedStyle := xlatedStyle first asString
 13525     ].
 13525     ].
 13526 
 13526 
 13527     pxSize := sizeUnitArg == #px ifTrue:[sizeArg] ifFalse:[nil].
 13527     pxSize := sizeUnitArg == #px ifTrue:[sizeArg] ifFalse:[nil].
 13528     ptSize := sizeUnitArg == #pt ifTrue:[sizeArg] ifFalse:[nil].
 13528     ptSize := sizeUnitArg == #pt ifTrue:[sizeArg] ifFalse:[nil].
 13529 
 13529 
 13530     id := self
 13530     id := self
 13531             getFontWithFoundry:#*
 13531 	    getFontWithFoundry:#*
 13532             family:familyString asLowercase
 13532 	    family:familyString asLowercase
 13533             weight:faceString
 13533 	    weight:faceString
 13534             slant:styleString "/ xlatedStyle
 13534 	    slant:styleString "/ xlatedStyle
 13535             spacing:spacing
 13535 	    spacing:spacing
 13536             pixelSize:pxSize
 13536 	    pixelSize:pxSize
 13537             size:ptSize
 13537 	    size:ptSize
 13538             registry:#*
 13538 	    registry:#*
 13539             encoding:encodingSym.
 13539 	    encoding:encodingSym.
 13540 
 13540 
 13541     id isNil ifTrue:[
 13541     id isNil ifTrue:[
 13542         id := self
 13542 	id := self
 13543                 getFontWithFoundry:#*
 13543 		getFontWithFoundry:#*
 13544                 family:familyString asLowercase
 13544 		family:familyString asLowercase
 13545                 weight:faceString asLowercase
 13545 		weight:faceString asLowercase
 13546                 slant:styleString asLowercase
 13546 		slant:styleString asLowercase
 13547                 spacing:spacing
 13547 		spacing:spacing
 13548                 pixelSize:pxSize
 13548 		pixelSize:pxSize
 13549                 size:ptSize
 13549 		size:ptSize
 13550                 registry:#*
 13550 		registry:#*
 13551                 encoding:encodingSym.
 13551 		encoding:encodingSym.
 13552     ].
 13552     ].
 13553     ^ id
 13553     ^ id
 13554 
 13554 
 13555     "Modified: / 04-07-1996 / 11:38:47 / stefan"
 13555     "Modified: / 04-07-1996 / 11:38:47 / stefan"
 13556     "Modified: / 04-08-2010 / 18:39:02 / cg"
 13556     "Modified: / 04-08-2010 / 18:39:02 / cg"
 13557 !
 13557 !
 13558 
 13558 
 13559 getFontWithFoundry:foundry family:family weight:weight
 13559 getFontWithFoundry:foundry family:family weight:weight
 13560               slant:slant spacing:spc pixelSize:pixelSizeOrNil size:pointSize
 13560 	      slant:slant spacing:spc pixelSize:pixelSizeOrNil size:pointSize
 13561               registry:registry encoding:encodingArg
 13561 	      registry:registry encoding:encodingArg
 13562 
 13562 
 13563     "get the specified font, if not available, return nil.
 13563     "get the specified font, if not available, return nil.
 13564      For now, this is a poor (incomplete) emulation of the X code ...
 13564      For now, this is a poor (incomplete) emulation of the X code ...
 13565      Individual attributes can be left empty (i.e. '') or nil to match any.
 13565      Individual attributes can be left empty (i.e. '') or nil to match any.
 13566 
 13566 
 13576     "
 13576     "
 13577 
 13577 
 13578     "
 13578     "
 13579      Windows-NT/95 allows the creation of a font with the following parameters
 13579      Windows-NT/95 allows the creation of a font with the following parameters
 13580 
 13580 
 13581         nHeight
 13581 	nHeight
 13582         nWidth
 13582 	nWidth
 13583         nEscapement
 13583 	nEscapement
 13584         nOrientation
 13584 	nOrientation
 13585         fnWeight        FW_DONTCARE, FW_NORMAL, FW_MEDIUM, FW_BOLD, ...
 13585 	fnWeight        FW_DONTCARE, FW_NORMAL, FW_MEDIUM, FW_BOLD, ...
 13586         fdwItalic       TRUE or FALSE
 13586 	fdwItalic       TRUE or FALSE
 13587         fdwUnderline    TRUE or FALSE
 13587 	fdwUnderline    TRUE or FALSE
 13588         fdwStrikeOut    TRUE or FALSE
 13588 	fdwStrikeOut    TRUE or FALSE
 13589         fdwCharSet      ANSI_CHARSET, UNICODE_, SYMBOL_, SHIFTJIS_,...
 13589 	fdwCharSet      ANSI_CHARSET, UNICODE_, SYMBOL_, SHIFTJIS_,...
 13590         fdwOutputPrecision      DEFAULT, STRING, CHAR, ...
 13590 	fdwOutputPrecision      DEFAULT, STRING, CHAR, ...
 13591         fdwClipPrecision        DEFAULT, CHAR, STROKE, MASK, ...
 13591 	fdwClipPrecision        DEFAULT, CHAR, STROKE, MASK, ...
 13592         fdwQuality      DEFAULT, DRAFT, or PROOF.
 13592 	fdwQuality      DEFAULT, DRAFT, or PROOF.
 13593         fdwPitchAndFamily
 13593 	fdwPitchAndFamily
 13594                 DEFAULT, FIXED or VARIABLE pitch
 13594 		DEFAULT, FIXED or VARIABLE pitch
 13595                 DECORATIVE, DONTCASE, MODERN, ROMAN, SCRIPT, or SWISS.
 13595 		DECORATIVE, DONTCASE, MODERN, ROMAN, SCRIPT, or SWISS.
 13596         lpszFace
 13596 	lpszFace
 13597                 Typeface Name
 13597 		Typeface Name
 13598 
 13598 
 13599       These two above descriptions will be matched as follows:
 13599       These two above descriptions will be matched as follows:
 13600 
 13600 
 13601         foundry   - ignored
 13601 	foundry   - ignored
 13602         family    - mapped to type face name.
 13602 	family    - mapped to type face name.
 13603         weight    - mapped to fnWeight
 13603 	weight    - mapped to fnWeight
 13604         slant     - used for style
 13604 	slant     - used for style
 13605         spacing   - NOT USED INITIALLY
 13605 	spacing   - NOT USED INITIALLY
 13606         pixelSize - NOT USED INITIALLY
 13606 	pixelSize - NOT USED INITIALLY
 13607         size      - mapped to nHeight
 13607 	size      - mapped to nHeight
 13608         registry  - NOT USED INITIALLY
 13608 	registry  - NOT USED INITIALLY
 13609         encoding  - mapped to fdwCharSet
 13609 	encoding  - mapped to fdwCharSet
 13610      "
 13610      "
 13611 
 13611 
 13612     |encoding logSize heightIsCellHeight|
 13612     |encoding logSize heightIsCellHeight|
 13613 
 13613 
 13614     encoding := encodingArg asSymbol.
 13614     encoding := encodingArg asSymbol.
 13615 
 13615 
 13616     pixelSizeOrNil notNil ifTrue:[
 13616     pixelSizeOrNil notNil ifTrue:[
 13617         logSize := pixelSizeOrNil.
 13617 	logSize := pixelSizeOrNil.
 13618         heightIsCellHeight := false.
 13618 	heightIsCellHeight := false.
 13619     ] ifFalse:[
 13619     ] ifFalse:[
 13620         logSize := (pointSize * (self getLogicalPixelSizeY) / 72.0) rounded.
 13620 	logSize := (pointSize * (self getLogicalPixelSizeY) / 72.0) rounded.
 13621         heightIsCellHeight := false.
 13621 	heightIsCellHeight := false.
 13622     ].
 13622     ].
 13623 %{
 13623 %{
 13624     HGDIOBJ hFont;
 13624     HGDIOBJ hFont;
 13625     int nHeight, nWidth, nEscapement, nOrientation;
 13625     int nHeight, nWidth, nEscapement, nOrientation;
 13626     char* work;
 13626     char* work;
 13651     fdwQuality         = DEFAULT_QUALITY;
 13651     fdwQuality         = DEFAULT_QUALITY;
 13652     fdwPitchAndFamily  = FF_DONTCARE;
 13652     fdwPitchAndFamily  = FF_DONTCARE;
 13653 
 13653 
 13654     fdwCharSet   = ANSI_CHARSET;
 13654     fdwCharSet   = ANSI_CHARSET;
 13655     if ((encoding == @symbol('ms-ansi'))) {
 13655     if ((encoding == @symbol('ms-ansi'))) {
 13656         fdwCharSet   = ANSI_CHARSET;
 13656 	fdwCharSet   = ANSI_CHARSET;
 13657     } else if (encoding == @symbol('ms-default')
 13657     } else if (encoding == @symbol('ms-default')
 13658                || encoding == @symbol(*)) {
 13658 	       || encoding == @symbol(*)) {
 13659         fdwCharSet   = DEFAULT_CHARSET;
 13659 	fdwCharSet   = DEFAULT_CHARSET;
 13660     } else if ((encoding == @symbol('ms-symbol'))
 13660     } else if ((encoding == @symbol('ms-symbol'))
 13661             || (encoding == @symbol('misc-fontspecific'))) {
 13661 	    || (encoding == @symbol('misc-fontspecific'))) {
 13662         fdwCharSet   = SYMBOL_CHARSET;
 13662 	fdwCharSet   = SYMBOL_CHARSET;
 13663     } else if ((encoding == @symbol('ms-shiftjis'))
 13663     } else if ((encoding == @symbol('ms-shiftjis'))
 13664             || (encoding == @symbol('jisx0208.1983-0'))){
 13664 	    || (encoding == @symbol('jisx0208.1983-0'))){
 13665         fdwCharSet   = SHIFTJIS_CHARSET;
 13665 	fdwCharSet   = SHIFTJIS_CHARSET;
 13666     } else if ((encoding == @symbol('ms-gb2312'))
 13666     } else if ((encoding == @symbol('ms-gb2312'))
 13667             || (encoding == @symbol('gb2312.1980-0'))) {
 13667 	    || (encoding == @symbol('gb2312.1980-0'))) {
 13668         fdwCharSet   = GB2312_CHARSET;
 13668 	fdwCharSet   = GB2312_CHARSET;
 13669     } else if ((encoding == @symbol('ms-hangeul'))
 13669     } else if ((encoding == @symbol('ms-hangeul'))
 13670             || (encoding == @symbol('ksc5601.1987-0'))) {
 13670 	    || (encoding == @symbol('ksc5601.1987-0'))) {
 13671         fdwCharSet   = HANGEUL_CHARSET;
 13671 	fdwCharSet   = HANGEUL_CHARSET;
 13672     } else if ((encoding == @symbol('ms-chinesebig5'))
 13672     } else if ((encoding == @symbol('ms-chinesebig5'))
 13673             || (encoding == @symbol('big5'))) {
 13673 	    || (encoding == @symbol('big5'))) {
 13674         fdwCharSet   = CHINESEBIG5_CHARSET;
 13674 	fdwCharSet   = CHINESEBIG5_CHARSET;
 13675     } else if (encoding == @symbol('ms-oem')) {
 13675     } else if (encoding == @symbol('ms-oem')) {
 13676         fdwCharSet   = OEM_CHARSET;
 13676 	fdwCharSet   = OEM_CHARSET;
 13677     } else if (encoding == @symbol('ms-johab')) {
 13677     } else if (encoding == @symbol('ms-johab')) {
 13678         fdwCharSet   = JOHAB_CHARSET;
 13678 	fdwCharSet   = JOHAB_CHARSET;
 13679     } else if ((encoding == @symbol('ms-hebrew'))
 13679     } else if ((encoding == @symbol('ms-hebrew'))
 13680             || (encoding == @symbol('ms-cp1255'))) {
 13680 	    || (encoding == @symbol('ms-cp1255'))) {
 13681         fdwCharSet   = HEBREW_CHARSET;
 13681 	fdwCharSet   = HEBREW_CHARSET;
 13682     } else if ((encoding == @symbol('ms-arabic'))
 13682     } else if ((encoding == @symbol('ms-arabic'))
 13683             || (encoding == @symbol('ms-cp1256'))) {
 13683 	    || (encoding == @symbol('ms-cp1256'))) {
 13684         fdwCharSet   = ARABIC_CHARSET;
 13684 	fdwCharSet   = ARABIC_CHARSET;
 13685     } else if ((encoding == @symbol('ms-greek'))
 13685     } else if ((encoding == @symbol('ms-greek'))
 13686             || (encoding == @symbol('ms-cp1253'))) {
 13686 	    || (encoding == @symbol('ms-cp1253'))) {
 13687         fdwCharSet   = GREEK_CHARSET;
 13687 	fdwCharSet   = GREEK_CHARSET;
 13688     } else if ((encoding == @symbol('ms-turkish'))
 13688     } else if ((encoding == @symbol('ms-turkish'))
 13689             || (encoding == @symbol('ms-cp1254'))) {
 13689 	    || (encoding == @symbol('ms-cp1254'))) {
 13690         fdwCharSet   = TURKISH_CHARSET;
 13690 	fdwCharSet   = TURKISH_CHARSET;
 13691     } else if ((encoding == @symbol('ms-russian'))
 13691     } else if ((encoding == @symbol('ms-russian'))
 13692             || (encoding == @symbol('ms-cp1251'))) {
 13692 	    || (encoding == @symbol('ms-cp1251'))) {
 13693         fdwCharSet   = RUSSIAN_CHARSET;
 13693 	fdwCharSet   = RUSSIAN_CHARSET;
 13694     } else if ((encoding == @symbol('ms-easteurope'))
 13694     } else if ((encoding == @symbol('ms-easteurope'))
 13695             || (encoding == @symbol('ms-cp1250'))) {
 13695 	    || (encoding == @symbol('ms-cp1250'))) {
 13696         fdwCharSet   = EASTEUROPE_CHARSET;
 13696 	fdwCharSet   = EASTEUROPE_CHARSET;
 13697     } else if ((encoding == @symbol('ms-baltic'))
 13697     } else if ((encoding == @symbol('ms-baltic'))
 13698             || (encoding == @symbol('ms-cp1257'))) {
 13698 	    || (encoding == @symbol('ms-cp1257'))) {
 13699         fdwCharSet   = BALTIC_CHARSET;
 13699 	fdwCharSet   = BALTIC_CHARSET;
 13700     } else if ((encoding == @symbol('ms-vietnamese'))) {
 13700     } else if ((encoding == @symbol('ms-vietnamese'))) {
 13701         fdwCharSet   = VIETNAMESE_CHARSET;
 13701 	fdwCharSet   = VIETNAMESE_CHARSET;
 13702     } else if ((encoding == @symbol('ms-thai'))) {
 13702     } else if ((encoding == @symbol('ms-thai'))) {
 13703         fdwCharSet   = THAI_CHARSET;
 13703 	fdwCharSet   = THAI_CHARSET;
 13704     } else if ((encoding == @symbol('ms-mac'))) {
 13704     } else if ((encoding == @symbol('ms-mac'))) {
 13705         fdwCharSet   = MAC_CHARSET;
 13705 	fdwCharSet   = MAC_CHARSET;
 13706 #ifdef UNICODE_CHARSET
 13706 #ifdef UNICODE_CHARSET
 13707     } else if ((encoding == @symbol('ms-unicode'))) {
 13707     } else if ((encoding == @symbol('ms-unicode'))) {
 13708         fdwCharSet   = UNICODE_CHARSET;
 13708 	fdwCharSet   = UNICODE_CHARSET;
 13709 #endif
 13709 #endif
 13710     }
 13710     }
 13711 
 13711 
 13712     if ( __isStringLike( family ) ) {
 13712     if ( __isStringLike( family ) ) {
 13713         work = __stringVal( family );
 13713 	work = __stringVal( family );
 13714         if (strcmp( work, "nil" ) != 0 ) {
 13714 	if (strcmp( work, "nil" ) != 0 ) {
 13715             strncpy( faceName, work, sizeof(faceName)-1 );
 13715 	    strncpy( faceName, work, sizeof(faceName)-1 );
 13716         }
 13716 	}
 13717     }
 13717     }
 13718 
 13718 
 13719     /* Q: should we allow those ? (they make ST/X programs less portable to X */
 13719     /* Q: should we allow those ? (they make ST/X programs less portable to X */
 13720     if( __isStringLike( weight ) ) {
 13720     if( __isStringLike( weight ) ) {
 13721         work = __stringVal( weight );
 13721 	work = __stringVal( weight );
 13722         if (strcmp( work, "bold" ) == 0 ) {
 13722 	if (strcmp( work, "bold" ) == 0 ) {
 13723             fnWeight = FW_BOLD;
 13723 	    fnWeight = FW_BOLD;
 13724         } else if (strcmp( work, "medium" ) == 0 ) {
 13724 	} else if (strcmp( work, "medium" ) == 0 ) {
 13725             fnWeight = FW_MEDIUM;
 13725 	    fnWeight = FW_MEDIUM;
 13726         } else if (strcmp( work, "normal" ) == 0 ) {
 13726 	} else if (strcmp( work, "normal" ) == 0 ) {
 13727             fnWeight = FW_NORMAL;
 13727 	    fnWeight = FW_NORMAL;
 13728         } else if (strcmp( work, "light" ) == 0 ) {
 13728 	} else if (strcmp( work, "light" ) == 0 ) {
 13729             fnWeight = FW_LIGHT;
 13729 	    fnWeight = FW_LIGHT;
 13730         } else if (strcmp( work, "demi" ) == 0 ) {
 13730 	} else if (strcmp( work, "demi" ) == 0 ) {
 13731             fnWeight = FW_LIGHT;
 13731 	    fnWeight = FW_LIGHT;
 13732         } else if (strcmp( work, "heavy" ) == 0 ) {
 13732 	} else if (strcmp( work, "heavy" ) == 0 ) {
 13733             fnWeight = FW_HEAVY;
 13733 	    fnWeight = FW_HEAVY;
 13734         } else if (strcmp( work, "extraBold" ) == 0 ) {
 13734 	} else if (strcmp( work, "extraBold" ) == 0 ) {
 13735             fnWeight = FW_EXTRABOLD;
 13735 	    fnWeight = FW_EXTRABOLD;
 13736         } else if (strcmp( work, "semiBold" ) == 0 ) {
 13736 	} else if (strcmp( work, "semiBold" ) == 0 ) {
 13737             fnWeight = FW_SEMIBOLD;
 13737 	    fnWeight = FW_SEMIBOLD;
 13738         } else if (strcmp( work, "thin" ) == 0 ) {
 13738 	} else if (strcmp( work, "thin" ) == 0 ) {
 13739             fnWeight = FW_THIN;
 13739 	    fnWeight = FW_THIN;
 13740         } else if (strcmp( work, "extraLight" ) == 0 ) {
 13740 	} else if (strcmp( work, "extraLight" ) == 0 ) {
 13741             fnWeight = FW_EXTRALIGHT;
 13741 	    fnWeight = FW_EXTRALIGHT;
 13742         }
 13742 	}
 13743     } else if (__isSmallInteger(weight)) {
 13743     } else if (__isSmallInteger(weight)) {
 13744         fnWeight = __intVal(weight);
 13744 	fnWeight = __intVal(weight);
 13745     }
 13745     }
 13746 
 13746 
 13747     if(__isSmallInteger( logSize )) {
 13747     if(__isSmallInteger( logSize )) {
 13748         nHeight = __intVal( logSize );
 13748 	nHeight = __intVal( logSize );
 13749     }
 13749     }
 13750 
 13750 
 13751     if (__isStringLike(slant)) {
 13751     if (__isStringLike(slant)) {
 13752         work2 = __stringVal( slant );
 13752 	work2 = __stringVal( slant );
 13753         work  = __stringVal( slant );
 13753 	work  = __stringVal( slant );
 13754 
 13754 
 13755         if (strncmp(work2, "italic", 6) == 0)  {
 13755 	if (strncmp(work2, "italic", 6) == 0)  {
 13756             fdwItalic = TRUE;
 13756 	    fdwItalic = TRUE;
 13757             if ( work2[6] == '-' )
 13757 	    if ( work2[6] == '-' )
 13758                 strncpy( work, &work2[7], ( strlen( work2) - 7) );
 13758 		strncpy( work, &work2[7], ( strlen( work2) - 7) );
 13759         } else {
 13759 	} else {
 13760             if (strncmp(work2, "oblique", 7) == 0)  {
 13760 	    if (strncmp(work2, "oblique", 7) == 0)  {
 13761                 fdwItalic = TRUE;
 13761 		fdwItalic = TRUE;
 13762                 if ( work2[7] == '-' )
 13762 		if ( work2[7] == '-' )
 13763                     strncpy( work, &work2[8], ( strlen( work2) - 8) );
 13763 		    strncpy( work, &work2[8], ( strlen( work2) - 8) );
 13764             }
 13764 	    }
 13765         }
 13765 	}
 13766         if (strncmp( work, "underline", 9 ) == 0 ) {
 13766 	if (strncmp( work, "underline", 9 ) == 0 ) {
 13767             fdwUnderline = TRUE;
 13767 	    fdwUnderline = TRUE;
 13768             if( work[10] == '-' )
 13768 	    if( work[10] == '-' )
 13769                 strncpy( work2, &work[11], ( strlen( work ) - 10 ) );
 13769 		strncpy( work2, &work[11], ( strlen( work ) - 10 ) );
 13770         }
 13770 	}
 13771         if (strncmp( work2, "strikeOut", 9 ) == 0 ) {
 13771 	if (strncmp( work2, "strikeOut", 9 ) == 0 ) {
 13772             fdwStrikeOut = TRUE;
 13772 	    fdwStrikeOut = TRUE;
 13773         }
 13773 	}
 13774     }
 13774     }
 13775 
 13775 
 13776     DPRINTF(("CreateFont face:%s h=%d w=%d wght=%d\n",
 13776     DPRINTF(("CreateFont face:%s h=%d w=%d wght=%d\n",
 13777                 faceName, nHeight, nWidth, fnWeight));
 13777 		faceName, nHeight, nWidth, fnWeight));
 13778 
 13778 
 13779     hFont = CreateFont(
 13779     hFont = CreateFont(
 13780                         (
 13780 			(
 13781                             (heightIsCellHeight == true)  ?
 13781 			    (heightIsCellHeight == true)  ?
 13782                                 nHeight : -nHeight            /* positive:cell height; negative:character height */
 13782 				nHeight : -nHeight            /* positive:cell height; negative:character height */
 13783                         ),
 13783 			),
 13784                         nWidth,
 13784 			nWidth,
 13785                         nEscapement,
 13785 			nEscapement,
 13786                         nOrientation,
 13786 			nOrientation,
 13787                         fnWeight,
 13787 			fnWeight,
 13788                         fdwItalic,
 13788 			fdwItalic,
 13789                         fdwUnderline,
 13789 			fdwUnderline,
 13790                         fdwStrikeOut,
 13790 			fdwStrikeOut,
 13791                         fdwCharSet,
 13791 			fdwCharSet,
 13792                         fdwOutputPrecision,
 13792 			fdwOutputPrecision,
 13793                         fdwClipPrecision,
 13793 			fdwClipPrecision,
 13794                         fdwQuality,
 13794 			fdwQuality,
 13795                         fdwPitchAndFamily,
 13795 			fdwPitchAndFamily,
 13796                         faceName );
 13796 			faceName );
 13797 
 13797 
 13798     if (hFont != NULL) {
 13798     if (hFont != NULL) {
 13799         DPRINTF(("createFont: %x\n", hFont));
 13799 	DPRINTF(("createFont: %x\n", hFont));
 13800 #ifdef COUNT_RESOURCES
 13800 #ifdef COUNT_RESOURCES
 13801         __cnt_font++;
 13801 	__cnt_font++;
 13802         RES1PRINTF(("CreateFont %d\n", __cnt_font));
 13802 	RES1PRINTF(("CreateFont %d\n", __cnt_font));
 13803 #endif
 13803 #endif
 13804         RETURN ( __MKOBJ(hFont) );
 13804 	RETURN ( __MKOBJ(hFont) );
 13805     }
 13805     }
 13806 
 13806 
 13807     DPRINTF(("***** ERROR createFontWithFoundry failed ERROR *****\n" ));
 13807     DPRINTF(("***** ERROR createFontWithFoundry failed ERROR *****\n" ));
 13808 %}.
 13808 %}.
 13809     ^ nil
 13809     ^ nil
 13810 
 13810 
 13811     "
 13811     "
 13812      Display getFontWithFoundry:'*'
 13812      Display getFontWithFoundry:'*'
 13813                          family:'courier'
 13813 			 family:'courier'
 13814                          weight:'medium'
 13814 			 weight:'medium'
 13815                           slant:'r'
 13815 			  slant:'r'
 13816                         spacing:nil
 13816 			spacing:nil
 13817                       pixelSize:nil
 13817 		      pixelSize:nil
 13818                            size:13
 13818 			   size:13
 13819                        registry:'iso8859'
 13819 		       registry:'iso8859'
 13820                        encoding:#*
 13820 		       encoding:#*
 13821     "
 13821     "
 13822 
 13822 
 13823     "new NT Version: 20.2.1997 / 22:33:29 / dq"
 13823     "new NT Version: 20.2.1997 / 22:33:29 / dq"
 13824 !
 13824 !
 13825 
 13825 
 13846       self primEnumFontTypesInto:typeFaceList.
 13846       self primEnumFontTypesInto:typeFaceList.
 13847 
 13847 
 13848       "/Transcript showCR:typeFaceList.
 13848       "/Transcript showCR:typeFaceList.
 13849 
 13849 
 13850       typeFaceList do:[:typeFace |
 13850       typeFaceList do:[:typeFace |
 13851           self primEnumFontsIn:typeFace into:list.
 13851 	  self primEnumFontsIn:typeFace into:list.
 13852       ].
 13852       ].
 13853     ] valueUninterruptably.
 13853     ] valueUninterruptably.
 13854 
 13854 
 13855     "/ Transcript showCR:list.
 13855     "/ Transcript showCR:list.
 13856     listOfFonts := OrderedCollection new.
 13856     listOfFonts := OrderedCollection new.
 13857     list do:[:anInfoArray |
 13857     list do:[:anInfoArray |
 13858         | fntDescr italicFontDescr |
 13858 	| fntDescr italicFontDescr |
 13859 
 13859 
 13860         fntDescr := self fontDescriptionFromLogicalFontInfoArray:anInfoArray.
 13860 	fntDescr := self fontDescriptionFromLogicalFontInfoArray:anInfoArray.
 13861         listOfFonts add:fntDescr.
 13861 	listOfFonts add:fntDescr.
 13862 
 13862 
 13863         "/ manually generate italic version (any font can be made italic here)
 13863 	"/ manually generate italic version (any font can be made italic here)
 13864         (fntDescr style startsWith:'roman') ifTrue:[
 13864 	(fntDescr style startsWith:'roman') ifTrue:[
 13865             italicFontDescr := FontDescription
 13865 	    italicFontDescr := FontDescription
 13866                             family:fntDescr family
 13866 			    family:fntDescr family
 13867                             face:fntDescr face
 13867 			    face:fntDescr face
 13868                             style:('italic' , (fntDescr style copyFrom:'roman' size+1))
 13868 			    style:('italic' , (fntDescr style copyFrom:'roman' size+1))
 13869                             size:fntDescr size
 13869 			    size:fntDescr size
 13870                             encoding:fntDescr encoding.
 13870 			    encoding:fntDescr encoding.
 13871             listOfFonts add:italicFontDescr.
 13871 	    listOfFonts add:italicFontDescr.
 13872         ].
 13872 	].
 13873     ].
 13873     ].
 13874 
 13874 
 13875     ^ listOfFonts
 13875     ^ listOfFonts
 13876 
 13876 
 13877     "
 13877     "
 13889 
 13889 
 13890     |sizes|
 13890     |sizes|
 13891 
 13891 
 13892     sizes := super pixelSizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filterBlock.
 13892     sizes := super pixelSizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filterBlock.
 13893     (sizes notNil and:[sizes includes:0]) ifTrue:[
 13893     (sizes notNil and:[sizes includes:0]) ifTrue:[
 13894         "special: size 0 means:
 13894 	"special: size 0 means:
 13895          there are scaled versions in all sizes available"
 13895 	 there are scaled versions in all sizes available"
 13896 
 13896 
 13897         ^ #(6 8 10 12 13 14 15 16 18 20 22 24 28 32 48 64)
 13897 	^ #(6 8 10 12 13 14 15 16 18 20 22 24 28 32 48 64)
 13898     ].
 13898     ].
 13899     ^ sizes
 13899     ^ sizes
 13900 
 13900 
 13901     "
 13901     "
 13902      Display pixelSizesInFamily:'courier' face:'bold' style:'roman'
 13902      Display pixelSizesInFamily:'courier' face:'bold' style:'roman'
 13907 
 13907 
 13908 primEnumFontTypesInto:typeFaceList
 13908 primEnumFontTypesInto:typeFaceList
 13909 %{
 13909 %{
 13910     if (__tmpDC) {
 13910     if (__tmpDC) {
 13911 #ifdef USE_EnumFontFamiliesEx
 13911 #ifdef USE_EnumFontFamiliesEx
 13912         EnumFontFamiliesEx( __tmpDC, NULL, EnumFPTypeFaceProc, (INT)&typeFaceList);
 13912 	EnumFontFamiliesEx( __tmpDC, NULL, EnumFPTypeFaceProc, (INT)&typeFaceList);
 13913 #else
 13913 #else
 13914         EnumFontFamilies( __tmpDC, NULL, EnumFPTypeFaceProc, (INT)&typeFaceList);
 13914 	EnumFontFamilies( __tmpDC, NULL, EnumFPTypeFaceProc, (INT)&typeFaceList);
 13915 #endif
 13915 #endif
 13916     }
 13916     }
 13917 %}
 13917 %}
 13918 !
 13918 !
 13919 
 13919 
 13920 primEnumFontsIn:typeFace into:fontList
 13920 primEnumFontsIn:typeFace into:fontList
 13921 %{
 13921 %{
 13922     char *cp;
 13922     char *cp;
 13923 
 13923 
 13924     if (__isStringLike(typeFace)) {
 13924     if (__isStringLike(typeFace)) {
 13925         if (__tmpDC) {
 13925 	if (__tmpDC) {
 13926 #ifdef USE_EnumFontFamiliesEx
 13926 #ifdef USE_EnumFontFamiliesEx
 13927             EnumFontFamiliesEx(__tmpDC, __stringVal(typeFace), EnumFontsProc, (INT)&fontList);
 13927 	    EnumFontFamiliesEx(__tmpDC, __stringVal(typeFace), EnumFontsProc, (INT)&fontList);
 13928 #else
 13928 #else
 13929             EnumFontFamilies(__tmpDC, __stringVal(typeFace), EnumFontsProc, (INT)&fontList);
 13929 	    EnumFontFamilies(__tmpDC, __stringVal(typeFace), EnumFontsProc, (INT)&fontList);
 13930 #endif
 13930 #endif
 13931         }
 13931 	}
 13932     }
 13932     }
 13933 %}.
 13933 %}.
 13934 !
 13934 !
 13935 
 13935 
 13936 primFontMetricsOf:fontId intoArray:rawData
 13936 primFontMetricsOf:fontId intoArray:rawData
 13951 
 13951 
 13952 %{
 13952 %{
 13953     if (__isExternalAddress(fontId)
 13953     if (__isExternalAddress(fontId)
 13954      && __isArray(rawData)
 13954      && __isArray(rawData)
 13955      && (__arraySize(rawData) >= 11)) {
 13955      && (__arraySize(rawData) >= 11)) {
 13956         SIZE size;
 13956 	SIZE size;
 13957         int avgWidth;
 13957 	int avgWidth;
 13958         HGDIOBJ hFont;
 13958 	HGDIOBJ hFont;
 13959         HGDIOBJ prevFont;
 13959 	HGDIOBJ prevFont;
 13960         // TEXTMETRIC tmet;
 13960 	// TEXTMETRIC tmet;
 13961         TEXTMETRICW tmet;
 13961 	TEXTMETRICW tmet;
 13962         OBJ t;
 13962 	OBJ t;
 13963 
 13963 
 13964         hFont = _HGDIOBJVal(fontId);
 13964 	hFont = _HGDIOBJVal(fontId);
 13965 
 13965 
 13966         /*
 13966 	/*
 13967          * temporarily set this font in the tmpDC (root-) context
 13967 	 * temporarily set this font in the tmpDC (root-) context
 13968          */
 13968 	 */
 13969 #ifdef CACHE_LAST_TMP_FONT
 13969 #ifdef CACHE_LAST_TMP_FONT
 13970         if (__tmpDC_hfont != hFont) {
 13970 	if (__tmpDC_hfont != hFont) {
 13971             prevFont = SelectObject(__tmpDC, hFont);
 13971 	    prevFont = SelectObject(__tmpDC, hFont);
 13972             if (__tmpDC_prev_hfont == NULL) {
 13972 	    if (__tmpDC_prev_hfont == NULL) {
 13973                 __tmpDC_prev_hfont = prevFont;
 13973 		__tmpDC_prev_hfont = prevFont;
 13974             }
 13974 	    }
 13975             __tmpDC_hfont = hFont;
 13975 	    __tmpDC_hfont = hFont;
 13976         }
 13976 	}
 13977 #else
 13977 #else
 13978         prevFont = SelectObject(__tmpDC, hFont);
 13978 	prevFont = SelectObject(__tmpDC, hFont);
 13979 #endif
 13979 #endif
 13980         GetTextMetricsW(__tmpDC, &tmet);
 13980 	GetTextMetricsW(__tmpDC, &tmet);
 13981 #if 0
 13981 #if 0
 13982         {
 13982 	{
 13983             static char *s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 13983 	    static char *s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 13984             static int len;
 13984 	    static int len;
 13985 
 13985 
 13986             if (len == 0) {
 13986 	    if (len == 0) {
 13987                 len = strlen(s);
 13987 		len = strlen(s);
 13988             }
 13988 	    }
 13989             GetTextExtentPoint32(__tmpDC, s, len, &size);
 13989 	    GetTextExtentPoint32(__tmpDC, s, len, &size);
 13990             avgWidth = (size.cx / (len / 2) + 1) / 2;
 13990 	    avgWidth = (size.cx / (len / 2) + 1) / 2;
 13991         }
 13991 	}
 13992 #else
 13992 #else
 13993         avgWidth = tmet.tmAveCharWidth;
 13993 	avgWidth = tmet.tmAveCharWidth;
 13994 #endif
 13994 #endif
 13995 
 13995 
 13996 #ifndef CACHE_LAST_TMP_FONT
 13996 #ifndef CACHE_LAST_TMP_FONT
 13997         SelectObject(__tmpDC, prevFont);
 13997 	SelectObject(__tmpDC, prevFont);
 13998 #endif
 13998 #endif
 13999 
 13999 
 14000         __ArrayInstPtr(rawData)->a_element[0] = __MKSMALLINT(tmet.tmAscent);        /* ascent     -> (data at:1) */
 14000 	__ArrayInstPtr(rawData)->a_element[0] = __MKSMALLINT(tmet.tmAscent);        /* ascent     -> (data at:1) */
 14001         __ArrayInstPtr(rawData)->a_element[1] = __MKSMALLINT(tmet.tmDescent);       /* descent    -> (data at:2) */
 14001 	__ArrayInstPtr(rawData)->a_element[1] = __MKSMALLINT(tmet.tmDescent);       /* descent    -> (data at:2) */
 14002         __ArrayInstPtr(rawData)->a_element[2] = __MKSMALLINT(tmet.tmAscent);        /* maxAscent  -> (data at:3) */
 14002 	__ArrayInstPtr(rawData)->a_element[2] = __MKSMALLINT(tmet.tmAscent);        /* maxAscent  -> (data at:3) */
 14003         __ArrayInstPtr(rawData)->a_element[3] = __MKSMALLINT(tmet.tmDescent);       /* maxDescent -> (data at:4) */
 14003 	__ArrayInstPtr(rawData)->a_element[3] = __MKSMALLINT(tmet.tmDescent);       /* maxDescent -> (data at:4) */
 14004         __ArrayInstPtr(rawData)->a_element[4] = __MKSMALLINT(avgWidth);             /* minWidth   -> (data at:5) */
 14004 	__ArrayInstPtr(rawData)->a_element[4] = __MKSMALLINT(avgWidth);             /* minWidth   -> (data at:5) */
 14005         __ArrayInstPtr(rawData)->a_element[5] = __MKSMALLINT(tmet.tmMaxCharWidth);  /* maxWidth   -> (data at:6) */
 14005 	__ArrayInstPtr(rawData)->a_element[5] = __MKSMALLINT(tmet.tmMaxCharWidth);  /* maxWidth   -> (data at:6) */
 14006         __ArrayInstPtr(rawData)->a_element[6] = __MKSMALLINT(avgWidth);             /* avgWidth   -> (data at:7) */
 14006 	__ArrayInstPtr(rawData)->a_element[6] = __MKSMALLINT(avgWidth);             /* avgWidth   -> (data at:7) */
 14007         __ArrayInstPtr(rawData)->a_element[7] = __MKSMALLINT(tmet.tmFirstChar);     /* min        -> (data at:8) */
 14007 	__ArrayInstPtr(rawData)->a_element[7] = __MKSMALLINT(tmet.tmFirstChar);     /* min        -> (data at:8) */
 14008         __ArrayInstPtr(rawData)->a_element[8] = __MKSMALLINT(tmet.tmLastChar);      /* max        -> (data at:9) */
 14008 	__ArrayInstPtr(rawData)->a_element[8] = __MKSMALLINT(tmet.tmLastChar);      /* max        -> (data at:9) */
 14009         __ArrayInstPtr(rawData)->a_element[9] = __MKSMALLINT(tmet.tmDefaultChar);   /* default    -> (data at:10) */
 14009 	__ArrayInstPtr(rawData)->a_element[9] = __MKSMALLINT(tmet.tmDefaultChar);   /* default    -> (data at:10) */
 14010         t = __charSetSymbolFor(tmet.tmCharSet);
 14010 	t = __charSetSymbolFor(tmet.tmCharSet);
 14011         __ArrayInstPtr(rawData)->a_element[10]= t; __STORE(rawData, t);             /* charSet    -> (data at:11) */
 14011 	__ArrayInstPtr(rawData)->a_element[10]= t; __STORE(rawData, t);             /* charSet    -> (data at:11) */
 14012 
 14012 
 14013         DPRINTF(("textMetrics h=%x  avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d\n",
 14013 	DPRINTF(("textMetrics h=%x  avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d\n",
 14014                     hFont, tmet.tmAscent, tmet.tmDescent, avgWidth, tmet.tmMaxCharWidth,
 14014 		    hFont, tmet.tmAscent, tmet.tmDescent, avgWidth, tmet.tmMaxCharWidth,
 14015                     tmet.tmAveCharWidth));
 14015 		    tmet.tmAveCharWidth));
 14016         RETURN (self);
 14016 	RETURN (self);
 14017     }
 14017     }
 14018     RETURN (nil);
 14018     RETURN (nil);
 14019 %}
 14019 %}
 14020 !
 14020 !
 14021 
 14021 
 14022 releaseFont:aFontId
 14022 releaseFont:aFontId
 14023 
 14023 
 14024 %{  /* NOCONTEXT */
 14024 %{  /* NOCONTEXT */
 14025     if (__isExternalAddress(aFontId)) {
 14025     if (__isExternalAddress(aFontId)) {
 14026         HGDIOBJ hFont = _HGDIOBJVal(aFontId);
 14026 	HGDIOBJ hFont = _HGDIOBJVal(aFontId);
 14027 
 14027 
 14028         if (hFont) {
 14028 	if (hFont) {
 14029 #ifdef COUNT_RESOURCES
 14029 #ifdef COUNT_RESOURCES
 14030             __cnt_font--;
 14030 	    __cnt_font--;
 14031            RES1PRINTF(("DestroyFont %d\n",__cnt_font));
 14031 	   RES1PRINTF(("DestroyFont %d\n",__cnt_font));
 14032 #endif
 14032 #endif
 14033            DPRINTF(("ReleaseFont: %x\n", hFont));
 14033 	   DPRINTF(("ReleaseFont: %x\n", hFont));
 14034            _DeleteFont(hFont, __LINE__);
 14034 	   _DeleteFont(hFont, __LINE__);
 14035         }
 14035 	}
 14036     }
 14036     }
 14037 %}
 14037 %}
 14038 !
 14038 !
 14039 
 14039 
 14040 sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter
 14040 sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter
 14044 
 14044 
 14045     |sizes|
 14045     |sizes|
 14046 
 14046 
 14047     sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter.
 14047     sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter.
 14048     (sizes notNil and:[sizes includes:0]) ifTrue:[
 14048     (sizes notNil and:[sizes includes:0]) ifTrue:[
 14049         "special: in X11R5 and above, size 0 means:
 14049 	"special: in X11R5 and above, size 0 means:
 14050          there are scaled versions in all sizes available"
 14050 	 there are scaled versions in all sizes available"
 14051 
 14051 
 14052         ^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64)
 14052 	^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64)
 14053     ].
 14053     ].
 14054     ^ sizes
 14054     ^ sizes
 14055 
 14055 
 14056     "
 14056     "
 14057      Display sizesInFamily:'courier' face:'bold' style:'roman'
 14057      Display sizesInFamily:'courier' face:'bold' style:'roman'
 14063 widthOf:aString from:index1 to:index2 inFont:aFontId
 14063 widthOf:aString from:index1 to:index2 inFont:aFontId
 14064     "leftover - bw compatibility"
 14064     "leftover - bw compatibility"
 14065     |w|
 14065     |w|
 14066 
 14066 
 14067     w := self
 14067     w := self
 14068         widthOf:aString from:index1 to:index2 inFont:aFontId
 14068 	widthOf:aString from:index1 to:index2 inFont:aFontId
 14069         in:nil with:nil.
 14069 	in:nil with:nil.
 14070 
 14070 
 14071     w isNil ifTrue:[
 14071     w isNil ifTrue:[
 14072         "/ the primitive returns nil (sigh) for invalid argument
 14072 	"/ the primitive returns nil (sigh) for invalid argument
 14073         w := self
 14073 	w := self
 14074             widthOf:aString asString asUnicode16String from:index1 to:index2 inFont:aFontId
 14074 	    widthOf:aString asString asUnicode16String from:index1 to:index2 inFont:aFontId
 14075             in:nil with:nil
 14075 	    in:nil with:nil
 14076     ].
 14076     ].
 14077     ^ w
 14077     ^ w
 14078 !
 14078 !
 14079 
 14079 
 14080 widthOf:aString from:index1 to:index2 inFont:aFontId in:ignoredDrawableId with:aGCId
 14080 widthOf:aString from:index1 to:index2 inFont:aFontId in:ignoredDrawableId with:aGCId
 14085     int nInstBytes;
 14085     int nInstBytes;
 14086 
 14086 
 14087     if (__bothSmallInteger(index1, index2)
 14087     if (__bothSmallInteger(index1, index2)
 14088      && __isExternalAddress(aFontId)
 14088      && __isExternalAddress(aFontId)
 14089      && __isNonNilObject(aString)) {
 14089      && __isNonNilObject(aString)) {
 14090         HGDIOBJ hFont,prevFont;
 14090 	HGDIOBJ hFont,prevFont;
 14091         HDC hDC;
 14091 	HDC hDC;
 14092         SIZE tsize;
 14092 	SIZE tsize;
 14093 
 14093 
 14094 #define xxPRE_22_FEP_2007
 14094 #define xxPRE_22_FEP_2007
 14095 #ifndef PRE_22_FEP_2007
 14095 #ifndef PRE_22_FEP_2007
 14096 #       define N_QUICK_CHARS    1024
 14096 #       define N_QUICK_CHARS    1024
 14097         unsigned short quickWchars[N_QUICK_CHARS];
 14097 	unsigned short quickWchars[N_QUICK_CHARS];
 14098         unsigned short *wcharPtr;
 14098 	unsigned short *wcharPtr;
 14099         int mustFree = 0;
 14099 	int mustFree = 0;
 14100         int i;
 14100 	int i;
 14101 #endif
 14101 #endif
 14102 
 14102 
 14103         hFont = _HGDIOBJVal(aFontId);
 14103 	hFont = _HGDIOBJVal(aFontId);
 14104 
 14104 
 14105         if (__isExternalAddress(aGCId)) {
 14105 	if (__isExternalAddress(aGCId)) {
 14106             struct gcData *gcData = _GCDATA(aGCId);
 14106 	    struct gcData *gcData = _GCDATA(aGCId);
 14107             hDC = _getDC(gcData);
 14107 	    hDC = _getDC(gcData);
 14108             prevFont = SelectObject(hDC, hFont);
 14108 	    prevFont = SelectObject(hDC, hFont);
 14109         } else {
 14109 	} else {
 14110             hDC = __tmpDC;
 14110 	    hDC = __tmpDC;
 14111 #ifdef CACHE_LAST_TMP_FONT
 14111 #ifdef CACHE_LAST_TMP_FONT
 14112             if (__tmpDC_hfont != hFont) {
 14112 	    if (__tmpDC_hfont != hFont) {
 14113                 prevFont = SelectObject(hDC, hFont);
 14113 		prevFont = SelectObject(hDC, hFont);
 14114                 if (__tmpDC_prev_hfont == NULL) {
 14114 		if (__tmpDC_prev_hfont == NULL) {
 14115                     __tmpDC_prev_hfont = prevFont;
 14115 		    __tmpDC_prev_hfont = prevFont;
 14116                 }
 14116 		}
 14117                 __tmpDC_hfont = hFont;
 14117 		__tmpDC_hfont = hFont;
 14118             }
 14118 	    }
 14119 #else
 14119 #else
 14120             prevFont = SelectObject(hDC, hFont);
 14120 	    prevFont = SelectObject(hDC, hFont);
 14121 #endif
 14121 #endif
 14122         }
 14122 	}
 14123 
 14123 
 14124         i1 = __intVal(index1) - 1;
 14124 	i1 = __intVal(index1) - 1;
 14125         cls = __qClass(aString);
 14125 	cls = __qClass(aString);
 14126 
 14126 
 14127         if (i1 >= 0) {
 14127 	if (i1 >= 0) {
 14128             i2 = __intVal(index2) - 1;
 14128 	    i2 = __intVal(index2) - 1;
 14129             if (i2 < i1) {
 14129 	    if (i2 < i1) {
 14130                 RETURN ( __MKSMALLINT( 0 ) );
 14130 		RETURN ( __MKSMALLINT( 0 ) );
 14131             }
 14131 	    }
 14132 
 14132 
 14133             cp = (char *) _stringVal(aString);
 14133 	    cp = (char *) _stringVal(aString);
 14134             l = i2 - i1 + 1;
 14134 	    l = i2 - i1 + 1;
 14135 
 14135 
 14136             if (__isStringLike(aString)) {
 14136 	    if (__isStringLike(aString)) {
 14137                 n = _stringSize(aString);
 14137 		n = _stringSize(aString);
 14138     commonWidthChars:
 14138     commonWidthChars:
 14139                 if (i2 < n) {
 14139 		if (i2 < n) {
 14140                     cp += i1;
 14140 		    cp += i1;
 14141 
 14141 
 14142 #ifdef PRE_22_FEP_2007
 14142 #ifdef PRE_22_FEP_2007
 14143                     GetTextExtentPoint32(hDC, cp, l, &tsize);
 14143 		    GetTextExtentPoint32(hDC, cp, l, &tsize);
 14144 #else
 14144 #else
 14145                     if (l <= N_QUICK_CHARS) {
 14145 		    if (l <= N_QUICK_CHARS) {
 14146                         wcharPtr = quickWchars;
 14146 			wcharPtr = quickWchars;
 14147                         mustFree = 0;
 14147 			mustFree = 0;
 14148                     } else {
 14148 		    } else {
 14149                         wcharPtr = malloc(sizeof(short)*l);
 14149 			wcharPtr = malloc(sizeof(short)*l);
 14150                         if (! wcharPtr) RETURN (__MKSMALLINT(0));
 14150 			if (! wcharPtr) RETURN (__MKSMALLINT(0));
 14151                         mustFree = 1;
 14151 			mustFree = 1;
 14152                     }
 14152 		    }
 14153                     for (i=0; i<l; i++) wcharPtr[i] = ((unsigned char *)cp)[i];
 14153 		    for (i=0; i<l; i++) wcharPtr[i] = ((unsigned char *)cp)[i];
 14154                     GetTextExtentPoint32W(hDC, wcharPtr, l, &tsize);
 14154 		    GetTextExtentPoint32W(hDC, wcharPtr, l, &tsize);
 14155                     if (mustFree) free(wcharPtr);
 14155 		    if (mustFree) free(wcharPtr);
 14156 #endif
 14156 #endif
 14157 
 14157 
 14158 #ifdef SUPERDEBUG
 14158 #ifdef SUPERDEBUG
 14159                     if (__debug__) {
 14159 		    if (__debug__) {
 14160                         char buf[80];
 14160 			char buf[80];
 14161 
 14161 
 14162                         GetTextFace(hDC,80,buf);
 14162 			GetTextFace(hDC,80,buf);
 14163                         console_printf("font1 %x %s >%s< l=%d dx=%d\n",hFont,buf,cp,l,tsize.cx);
 14163 			console_printf("font1 %x %s >%s< l=%d dx=%d\n",hFont,buf,cp,l,tsize.cx);
 14164                     }
 14164 		    }
 14165 #endif
 14165 #endif
 14166                     if (__isExternalAddress(aGCId)) {
 14166 		    if (__isExternalAddress(aGCId)) {
 14167                         SelectObject(hDC, prevFont);
 14167 			SelectObject(hDC, prevFont);
 14168                     } else {
 14168 		    } else {
 14169 #ifndef CACHE_LAST_TMP_FONT
 14169 #ifndef CACHE_LAST_TMP_FONT
 14170                         SelectObject(hDC, prevFont);
 14170 			SelectObject(hDC, prevFont);
 14171 #endif
 14171 #endif
 14172                     }
 14172 		    }
 14173                     RETURN ( __MKSMALLINT(tsize.cx) );
 14173 		    RETURN ( __MKSMALLINT(tsize.cx) );
 14174                 }
 14174 		}
 14175                 RETURN (__MKSMALLINT(0));
 14175 		RETURN (__MKSMALLINT(0));
 14176             }
 14176 	    }
 14177 
 14177 
 14178             nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
 14178 	    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
 14179             cp += nInstBytes;
 14179 	    cp += nInstBytes;
 14180             n = __byteArraySize(aString) - nInstBytes;
 14180 	    n = __byteArraySize(aString) - nInstBytes;
 14181 
 14181 
 14182             if (__isBytes(aString)) {
 14182 	    if (__isBytes(aString)) {
 14183                 goto commonWidthChars;
 14183 		goto commonWidthChars;
 14184             }
 14184 	    }
 14185 
 14185 
 14186             /* Unicode */
 14186 	    /* Unicode */
 14187             if (__isWords(aString)) {
 14187 	    if (__isWords(aString)) {
 14188                 n = n / 2;
 14188 		n = n / 2;
 14189                 if (i2 < n) {
 14189 		if (i2 < n) {
 14190                     WIDECHAR *w_cp = (WIDECHAR *)cp;
 14190 		    WIDECHAR *w_cp = (WIDECHAR *)cp;
 14191 
 14191 
 14192                     w_cp += i1;
 14192 		    w_cp += i1;
 14193 
 14193 
 14194                     GetTextExtentPoint32W(hDC, w_cp, l, &tsize);
 14194 		    GetTextExtentPoint32W(hDC, w_cp, l, &tsize);
 14195                     if (__isExternalAddress(aGCId)) {
 14195 		    if (__isExternalAddress(aGCId)) {
 14196                         SelectObject(hDC, prevFont);
 14196 			SelectObject(hDC, prevFont);
 14197                     } else {
 14197 		    } else {
 14198 #ifndef CACHE_LAST_TMP_FONT
 14198 #ifndef CACHE_LAST_TMP_FONT
 14199                         SelectObject(hDC, prevFont);
 14199 			SelectObject(hDC, prevFont);
 14200 #endif
 14200 #endif
 14201                     }
 14201 		    }
 14202                     RETURN ( __MKSMALLINT(tsize.cx) );
 14202 		    RETURN ( __MKSMALLINT(tsize.cx) );
 14203                 }
 14203 		}
 14204                 RETURN (__MKSMALLINT(0));
 14204 		RETURN (__MKSMALLINT(0));
 14205             }
 14205 	    }
 14206         }
 14206 	}
 14207     }
 14207     }
 14208 %}.
 14208 %}.
 14209     ^ nil
 14209     ^ nil
 14210 ! !
 14210 ! !
 14211 
 14211 
 14230 grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId
 14230 grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId
 14231     "grap the pointer - return true if ok"
 14231     "grap the pointer - return true if ok"
 14232 
 14232 
 14233 %{
 14233 %{
 14234     if (__isExternalAddress(aWindowId)) {
 14234     if (__isExternalAddress(aWindowId)) {
 14235         HWND hWnd = _HWNDVal(aWindowId);
 14235 	HWND hWnd = _HWNDVal(aWindowId);
 14236         HCURSOR hCursor = 0;
 14236 	HCURSOR hCursor = 0;
 14237 
 14237 
 14238         if (__currentCapture != CAPTURE_NONE) {
 14238 	if (__currentCapture != CAPTURE_NONE) {
 14239             PostMessage(__currentPointerView, WM_THREAD_SETCAPTURE, 0, 0);
 14239 	    PostMessage(__currentPointerView, WM_THREAD_SETCAPTURE, 0, 0);
 14240             //ReleaseCapture();
 14240 	    //ReleaseCapture();
 14241         }
 14241 	}
 14242 #if 1
 14242 #if 1
 14243         /*
 14243 	/*
 14244          * place a special, invisible view above the root
 14244 	 * place a special, invisible view above the root
 14245          */
 14245 	 */
 14246         if (hWnd == __rootWin) {
 14246 	if (hWnd == __rootWin) {
 14247             hWnd = __rootWinSpezial;
 14247 	    hWnd = __rootWinSpezial;
 14248             ShowWindow(hWnd, SW_SHOWNOACTIVATE);
 14248 	    ShowWindow(hWnd, SW_SHOWNOACTIVATE);
 14249             //EnableWindow(hWnd,TRUE);
 14249 	    //EnableWindow(hWnd,TRUE);
 14250             SetWindowPos(hWnd, HWND_TOP,
 14250 	    SetWindowPos(hWnd, HWND_TOP,
 14251                          0, 0, 0, 0,
 14251 			 0, 0, 0, 0,
 14252                          SWP_NOREDRAW | SWP_NOSENDCHANGING | SWP_NOCOPYBITS
 14252 			 SWP_NOREDRAW | SWP_NOSENDCHANGING | SWP_NOCOPYBITS
 14253                          | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
 14253 			 | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
 14254             CPRINTF(("setRootCapture %x\n",hWnd));
 14254 	    CPRINTF(("setRootCapture %x\n",hWnd));
 14255         }
 14255 	}
 14256 #endif
 14256 #endif
 14257         if (__isExternalAddress(aCursorId)) {
 14257 	if (__isExternalAddress(aCursorId)) {
 14258             hCursor = _HCURSORVal(aCursorId);
 14258 	    hCursor = _HCURSORVal(aCursorId);
 14259             CPRINTF(("grabPointerIn  SetCapture %x\n",hWnd));
 14259 	    CPRINTF(("grabPointerIn  SetCapture %x\n",hWnd));
 14260         }
 14260 	}
 14261         PostMessage(hWnd, WM_THREAD_SETCAPTURE, (INT)hWnd, (INT)hCursor);
 14261 	PostMessage(hWnd, WM_THREAD_SETCAPTURE, (INT)hWnd, (INT)hCursor);
 14262         RETURN (true);
 14262 	RETURN (true);
 14263     }
 14263     }
 14264 %}.
 14264 %}.
 14265     ^ false
 14265     ^ false
 14266 !
 14266 !
 14267 
 14267 
 14293 
 14293 
 14294 %{  /* NOCONTEXT */
 14294 %{  /* NOCONTEXT */
 14295 
 14295 
 14296     if (__isExternalAddress(aWindowId)
 14296     if (__isExternalAddress(aWindowId)
 14297      && __isExternalAddress(aGCId)) {
 14297      && __isExternalAddress(aGCId)) {
 14298         struct gcData *gcData = _GCDATA(aGCId);
 14298 	struct gcData *gcData = _GCDATA(aGCId);
 14299 
 14299 
 14300         if (gcData->clipping != FALSE) {
 14300 	if (gcData->clipping != FALSE) {
 14301 #ifdef GDIFLUSH_WHEN_CHANGING_CLIP
 14301 #ifdef GDIFLUSH_WHEN_CHANGING_CLIP
 14302             GdiFlush();
 14302 	    GdiFlush();
 14303 #endif
 14303 #endif
 14304             gcData->clipping = FALSE;
 14304 	    gcData->clipping = FALSE;
 14305 #ifdef CACHE_LAST_DC
 14305 #ifdef CACHE_LAST_DC
 14306             if (lastGcData == gcData) {
 14306 	    if (lastGcData == gcData) {
 14307                 SelectClipRgn(gcData->_hDC, NULL);
 14307 		SelectClipRgn(gcData->_hDC, NULL);
 14308             }
 14308 	    }
 14309 #endif
 14309 #endif
 14310         }
 14310 	}
 14311         RETURN (self);
 14311 	RETURN (self);
 14312     }
 14312     }
 14313 %}
 14313 %}
 14314 !
 14314 !
 14315 
 14315 
 14316 setBackground:bgColorIndex in:aGCId
 14316 setBackground:bgColorIndex in:aGCId
 14317     "set background color to be drawn with"
 14317     "set background color to be drawn with"
 14318 
 14318 
 14319 %{  /* NOCONTEXT */
 14319 %{  /* NOCONTEXT */
 14320 
 14320 
 14321     if (__isSmallInteger(bgColorIndex)
 14321     if (__isSmallInteger(bgColorIndex)
 14322         && __isExternalAddress(aGCId)) {
 14322 	&& __isExternalAddress(aGCId)) {
 14323         struct gcData *gcData = _GCDATA(aGCId);
 14323 	struct gcData *gcData = _GCDATA(aGCId);
 14324         COLORREF bgColor;
 14324 	COLORREF bgColor;
 14325 
 14325 
 14326         bgColor = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData);
 14326 	bgColor = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData);
 14327         if (bgColor != gcData->bgColor) {
 14327 	if (bgColor != gcData->bgColor) {
 14328             gcData->bgColor = bgColor;
 14328 	    gcData->bgColor = bgColor;
 14329 #ifdef CACHE_LAST_DC
 14329 #ifdef CACHE_LAST_DC
 14330             if (lastGcData == gcData) {
 14330 	    if (lastGcData == gcData) {
 14331                 SetBkColor(gcData->_hDC, bgColor);
 14331 		SetBkColor(gcData->_hDC, bgColor);
 14332                 /*
 14332 		/*
 14333                  * no need to flush pen - it does not depend upon
 14333 		 * no need to flush pen - it does not depend upon
 14334                  * the bg color
 14334 		 * the bg color
 14335                  */
 14335 		 */
 14336             }
 14336 	    }
 14337 #endif
 14337 #endif
 14338         }
 14338 	}
 14339 
 14339 
 14340         CPRINTF(("setBackground: %x\n", bgColor));
 14340 	CPRINTF(("setBackground: %x\n", bgColor));
 14341         RETURN (self);
 14341 	RETURN (self);
 14342     }
 14342     }
 14343 %}.
 14343 %}.
 14344 
 14344 
 14345     ^self primitiveFailed
 14345     ^self primitiveFailed
 14346 !
 14346 !
 14349     "set or clear the drawing mask - a bitmap mask using current fg/bg"
 14349     "set or clear the drawing mask - a bitmap mask using current fg/bg"
 14350 
 14350 
 14351 %{  /* NOCONTEXT */
 14351 %{  /* NOCONTEXT */
 14352 
 14352 
 14353     if (__isExternalAddress(aGCId)) {
 14353     if (__isExternalAddress(aGCId)) {
 14354         struct gcData *gcData = _GCDATA(aGCId);
 14354 	struct gcData *gcData = _GCDATA(aGCId);
 14355         HBITMAP oldM;
 14355 	HBITMAP oldM;
 14356 
 14356 
 14357         oldM = gcData->hMask;
 14357 	oldM = gcData->hMask;
 14358         if (__isExternalAddress(aBitmapId))
 14358 	if (__isExternalAddress(aBitmapId))
 14359             gcData->hMask = _HBITMAPVAL(aBitmapId);
 14359 	    gcData->hMask = _HBITMAPVAL(aBitmapId);
 14360         else
 14360 	else
 14361             gcData->hMask = 0;
 14361 	    gcData->hMask = 0;
 14362 
 14362 
 14363         if (oldM != gcData->hMask) {
 14363 	if (oldM != gcData->hMask) {
 14364             FLUSH_CACHED_DC(gcData);
 14364 	    FLUSH_CACHED_DC(gcData);
 14365             CPRINTF(("masks set to %x\n",gcData->hMask));
 14365 	    CPRINTF(("masks set to %x\n",gcData->hMask));
 14366         }
 14366 	}
 14367         RETURN (self);
 14367 	RETURN (self);
 14368     }
 14368     }
 14369 %}
 14369 %}
 14370 !
 14370 !
 14371 
 14371 
 14372 setClipByChildren:aBool in:aWindowId gc:aGCId
 14372 setClipByChildren:aBool in:aWindowId gc:aGCId
 14373     "enable/disable drawing into child views"
 14373     "enable/disable drawing into child views"
 14374 
 14374 
 14375 %{  /* NOCONTEXT */
 14375 %{  /* NOCONTEXT */
 14376 
 14376 
 14377     if (ISCONNECTED && __isExternalAddress(aGCId)) {
 14377     if (ISCONNECTED && __isExternalAddress(aGCId)) {
 14378         struct gcData *gcData = _GCDATA(aGCId);
 14378 	struct gcData *gcData = _GCDATA(aGCId);
 14379 
 14379 
 14380         if (gcData && gcData->hWnd) {
 14380 	if (gcData && gcData->hWnd) {
 14381             int newClip;
 14381 	    int newClip;
 14382 
 14382 
 14383            newClip = (aBool == true) ? TRUE : FALSE;
 14383 	   newClip = (aBool == true) ? TRUE : FALSE;
 14384             if (newClip != gcData->clipByChildren) {
 14384 	    if (newClip != gcData->clipByChildren) {
 14385 #ifdef GDIFLUSH_WHEN_CHANGING_CLIP
 14385 #ifdef GDIFLUSH_WHEN_CHANGING_CLIP
 14386                 GdiFlush();
 14386 		GdiFlush();
 14387 #endif
 14387 #endif
 14388                 /* set/clear clip by children */
 14388 		/* set/clear clip by children */
 14389                 gcData->clipByChildren = newClip;
 14389 		gcData->clipByChildren = newClip;
 14390                 FLUSH_CACHED_DC(gcData);
 14390 		FLUSH_CACHED_DC(gcData);
 14391             }
 14391 	    }
 14392         } else {
 14392 	} else {
 14393             DPRINTF(("clipping by child failed - invalid window\n" ));
 14393 	    DPRINTF(("clipping by child failed - invalid window\n" ));
 14394         }
 14394 	}
 14395     }
 14395     }
 14396 %}.
 14396 %}.
 14397     ^ self
 14397     ^ self
 14398 !
 14398 !
 14399 
 14399 
 14404       p--w---
 14404       p--w---
 14405       |     |
 14405       |     |
 14406       h     |  the clipping rectangle
 14406       h     |  the clipping rectangle
 14407       |     |
 14407       |     |
 14408       -------
 14408       -------
 14409           where p = ( clipXArg, clipYArg ), w = clipWidth, h = clipHeight
 14409 	  where p = ( clipXArg, clipYArg ), w = clipWidth, h = clipHeight
 14410 "
 14410 "
 14411 
 14411 
 14412 %{  /* NOCONTEXT */
 14412 %{  /* NOCONTEXT */
 14413 
 14413 
 14414     if (  __isExternalAddress(aGCId)
 14414     if (  __isExternalAddress(aGCId)
 14415        && __bothSmallInteger(clipXArg, clipYArg)
 14415        && __bothSmallInteger(clipXArg, clipYArg)
 14416        && __bothSmallInteger(clipWidth, clipHeight) ) {
 14416        && __bothSmallInteger(clipWidth, clipHeight) ) {
 14417         struct gcData *gcData = _GCDATA(aGCId);
 14417 	struct gcData *gcData = _GCDATA(aGCId);
 14418         int cX, cY, cW, cH;
 14418 	int cX, cY, cW, cH;
 14419 
 14419 
 14420         cX = __intVal(clipXArg);
 14420 	cX = __intVal(clipXArg);
 14421         cY = __intVal(clipYArg);
 14421 	cY = __intVal(clipYArg);
 14422         cW = __intVal(clipWidth);
 14422 	cW = __intVal(clipWidth);
 14423         cH = __intVal(clipHeight);
 14423 	cH = __intVal(clipHeight);
 14424 
 14424 
 14425         if ((gcData->clipping != TRUE)
 14425 	if ((gcData->clipping != TRUE)
 14426          || (cX != gcData->clipX)
 14426 	 || (cX != gcData->clipX)
 14427          || (cY != gcData->clipY)
 14427 	 || (cY != gcData->clipY)
 14428          || (cW != gcData->clipW)
 14428 	 || (cW != gcData->clipW)
 14429          || (cH != gcData->clipH)) {
 14429 	 || (cH != gcData->clipH)) {
 14430             gcData->clipping = TRUE;
 14430 	    gcData->clipping = TRUE;
 14431             gcData->clipX = cX;
 14431 	    gcData->clipX = cX;
 14432             gcData->clipY = cY;
 14432 	    gcData->clipY = cY;
 14433             gcData->clipW = cW;
 14433 	    gcData->clipW = cW;
 14434             gcData->clipH = cH;
 14434 	    gcData->clipH = cH;
 14435 
 14435 
 14436 #ifdef GDIFLUSH_WHEN_CHANGING_CLIP
 14436 #ifdef GDIFLUSH_WHEN_CHANGING_CLIP
 14437             GdiFlush();
 14437 	    GdiFlush();
 14438 #endif
 14438 #endif
 14439 #ifdef CACHE_LAST_DC
 14439 #ifdef CACHE_LAST_DC
 14440             /*
 14440 	    /*
 14441              * must update current cached DC
 14441 	     * must update current cached DC
 14442              */
 14442 	     */
 14443             if (lastGcData == gcData) {
 14443 	    if (lastGcData == gcData) {
 14444                 HRGN region = CreateRectRgn(cX, cY, cX + cW, cY + cH);
 14444 		HRGN region = CreateRectRgn(cX, cY, cX + cW, cY + cH);
 14445 
 14445 
 14446                 if (region == NULL ) {
 14446 		if (region == NULL ) {
 14447                     console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
 14447 		    console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
 14448                     FLUSH_CACHED_DC(gcData);
 14448 		    FLUSH_CACHED_DC(gcData);
 14449                 } else {
 14449 		} else {
 14450                     if (SelectClipRgn(gcData->_hDC, region) == ERROR ) {
 14450 		    if (SelectClipRgn(gcData->_hDC, region) == ERROR ) {
 14451                         console_fprintf(stderr, "WinWorkstat [warning]: select clipping region failed\n");
 14451 			console_fprintf(stderr, "WinWorkstat [warning]: select clipping region failed\n");
 14452                         FLUSH_CACHED_DC(gcData);
 14452 			FLUSH_CACHED_DC(gcData);
 14453                     }
 14453 		    }
 14454                     _DeleteObject(region, __LINE__);
 14454 		    _DeleteObject(region, __LINE__);
 14455                 }
 14455 		}
 14456             }
 14456 	    }
 14457 #endif
 14457 #endif
 14458         }
 14458 	}
 14459         RETURN (self);
 14459 	RETURN (self);
 14460     }
 14460     }
 14461 %}
 14461 %}
 14462 !
 14462 !
 14463 
 14463 
 14464 setDashes:dashList dashOffset:offset in:aGCId
 14464 setDashes:dashList dashOffset:offset in:aGCId
 14465     "set line attributes"
 14465     "set line attributes"
 14466 
 14466 
 14467 %{  /* NOCONTEXT */
 14467 %{  /* NOCONTEXT */
 14468 
 14468 
 14469     if (__isExternalAddress(aGCId)) {
 14469     if (__isExternalAddress(aGCId)) {
 14470         PRINTF(("WinWorkstat [warning]: dashes not (yet) implemented\n"));
 14470 	PRINTF(("WinWorkstat [warning]: dashes not (yet) implemented\n"));
 14471     }
 14471     }
 14472 %}
 14472 %}
 14473 !
 14473 !
 14474 
 14474 
 14475 setFont:aFontId in:aGCId
 14475 setFont:aFontId in:aGCId
 14478 %{  /* NOCONTEXT */
 14478 %{  /* NOCONTEXT */
 14479 
 14479 
 14480     if (__isExternalAddress(aGCId)
 14480     if (__isExternalAddress(aGCId)
 14481      && __isExternalAddress(aFontId))
 14481      && __isExternalAddress(aFontId))
 14482     {
 14482     {
 14483         struct gcData *gcData = _GCDATA(aGCId);
 14483 	struct gcData *gcData = _GCDATA(aGCId);
 14484         HGDIOBJ prevFont, hFont;
 14484 	HGDIOBJ prevFont, hFont;
 14485         // TEXTMETRIC tmet;
 14485 	// TEXTMETRIC tmet;
 14486         TEXTMETRICW tmet;
 14486 	TEXTMETRICW tmet;
 14487 
 14487 
 14488         hFont = _HGDIOBJVal(aFontId);
 14488 	hFont = _HGDIOBJVal(aFontId);
 14489         if (gcData->hFont != hFont) {
 14489 	if (gcData->hFont != hFont) {
 14490             gcData->hFont = hFont;
 14490 	    gcData->hFont = hFont;
 14491 
 14491 
 14492 #ifdef CACHE_LAST_TMP_FONT
 14492 #ifdef CACHE_LAST_TMP_FONT
 14493             if (__tmpDC_hfont != hFont) {
 14493 	    if (__tmpDC_hfont != hFont) {
 14494                 prevFont = SelectObject(__tmpDC, hFont);
 14494 		prevFont = SelectObject(__tmpDC, hFont);
 14495                 if (__tmpDC_prev_hfont == NULL) {
 14495 		if (__tmpDC_prev_hfont == NULL) {
 14496                     __tmpDC_prev_hfont = prevFont;
 14496 		    __tmpDC_prev_hfont = prevFont;
 14497                 }
 14497 		}
 14498                 __tmpDC_hfont = hFont;
 14498 		__tmpDC_hfont = hFont;
 14499             }
 14499 	    }
 14500 #else
 14500 #else
 14501             prevFont = SelectObject(__tmpDC, hFont);
 14501 	    prevFont = SelectObject(__tmpDC, hFont);
 14502 #endif
 14502 #endif
 14503 
 14503 
 14504             GetTextMetricsW(__tmpDC, &tmet);
 14504 	    GetTextMetricsW(__tmpDC, &tmet);
 14505             gcData->fontAscent = tmet.tmAscent;
 14505 	    gcData->fontAscent = tmet.tmAscent;
 14506 #ifdef SUPERDEBUG
 14506 #ifdef SUPERDEBUG
 14507             if (__debug__) {
 14507 	    if (__debug__) {
 14508                 char buf[80];
 14508 		char buf[80];
 14509 
 14509 
 14510                 GetTextFace(__tmpDC, 80, buf);
 14510 		GetTextFace(__tmpDC, 80, buf);
 14511                 PRINTF(("setFont: %x %s\n", hFont, buf));
 14511 		PRINTF(("setFont: %x %s\n", hFont, buf));
 14512             }
 14512 	    }
 14513 #endif
 14513 #endif
 14514 #ifndef CACHE_LAST_TMP_FONT
 14514 #ifndef CACHE_LAST_TMP_FONT
 14515             SelectObject(__tmpDC, prevFont);
 14515 	    SelectObject(__tmpDC, prevFont);
 14516 #endif
 14516 #endif
 14517 
 14517 
 14518 #ifdef CACHE_LAST_DC
 14518 #ifdef CACHE_LAST_DC
 14519             /*
 14519 	    /*
 14520              * must update current cached DC
 14520 	     * must update current cached DC
 14521              */
 14521 	     */
 14522             if (lastGcData == gcData) {
 14522 	    if (lastGcData == gcData) {
 14523                 prevFont = SelectObject(gcData->_hDC, hFont);
 14523 		prevFont = SelectObject(gcData->_hDC, hFont);
 14524                 if (! gcData->save_hFont) {
 14524 		if (! gcData->save_hFont) {
 14525                     gcData->save_hFont = prevFont;
 14525 		    gcData->save_hFont = prevFont;
 14526                 }
 14526 		}
 14527             }
 14527 	    }
 14528 #endif
 14528 #endif
 14529             RETURN ( self );
 14529 	    RETURN ( self );
 14530         }
 14530 	}
 14531     }
 14531     }
 14532 %}
 14532 %}
 14533 !
 14533 !
 14534 
 14534 
 14535 setForeground:fgColorIndex background:bgColorIndex in:aGCId
 14535 setForeground:fgColorIndex background:bgColorIndex in:aGCId
 14536     "set foreground and background colors to be drawn with"
 14536     "set foreground and background colors to be drawn with"
 14537 
 14537 
 14538 %{  /* NOCONTEXT */
 14538 %{  /* NOCONTEXT */
 14539 
 14539 
 14540     if (__bothSmallInteger(fgColorIndex, bgColorIndex)
 14540     if (__bothSmallInteger(fgColorIndex, bgColorIndex)
 14541         && __isExternalAddress(aGCId)) {
 14541 	&& __isExternalAddress(aGCId)) {
 14542         struct gcData *gcData = _GCDATA(aGCId);
 14542 	struct gcData *gcData = _GCDATA(aGCId);
 14543         COLORREF fg, bg, oldFg, oldBg;
 14543 	COLORREF fg, bg, oldFg, oldBg;
 14544 
 14544 
 14545         fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData);
 14545 	fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData);
 14546         bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData);
 14546 	bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData);
 14547         oldFg = gcData->fgColor;
 14547 	oldFg = gcData->fgColor;
 14548         oldBg = gcData->bgColor;
 14548 	oldBg = gcData->bgColor;
 14549 
 14549 
 14550         if ((fg != oldFg) || (bg != oldBg)) {
 14550 	if ((fg != oldFg) || (bg != oldBg)) {
 14551             gcData->fgColor = fg;
 14551 	    gcData->fgColor = fg;
 14552             gcData->bgColor = bg;
 14552 	    gcData->bgColor = bg;
 14553 
 14553 
 14554 #ifdef CACHE_LAST_DC
 14554 #ifdef CACHE_LAST_DC
 14555             /*
 14555 	    /*
 14556              * must update or flush current cached DC
 14556 	     * must update or flush current cached DC
 14557              */
 14557 	     */
 14558             if (lastGcData == gcData) {
 14558 	    if (lastGcData == gcData) {
 14559                 /* Pen only depends upon fg-color */
 14559 		/* Pen only depends upon fg-color */
 14560                 if (fg != oldFg) {
 14560 		if (fg != oldFg) {
 14561                     SetTextColor(gcData->_hDC, fg);
 14561 		    SetTextColor(gcData->_hDC, fg);
 14562                     FLUSH_CACHED_PEN(gcData);
 14562 		    FLUSH_CACHED_PEN(gcData);
 14563                 }
 14563 		}
 14564                 if (bg != oldBg) {
 14564 		if (bg != oldBg) {
 14565                     SetBkColor(gcData->_hDC, bg);
 14565 		    SetBkColor(gcData->_hDC, bg);
 14566                 }
 14566 		}
 14567                 FLUSH_CACHED_BRUSH(gcData);
 14567 		FLUSH_CACHED_BRUSH(gcData);
 14568             }
 14568 	    }
 14569 #endif
 14569 #endif
 14570             CPRINTF(("setForeground: %x background: %x\n", gcData->fgColor, gcData->bgColor));
 14570 	    CPRINTF(("setForeground: %x background: %x\n", gcData->fgColor, gcData->bgColor));
 14571         }
 14571 	}
 14572         RETURN (self);
 14572 	RETURN (self);
 14573     }
 14573     }
 14574 %}.
 14574 %}.
 14575     ^self primitiveFailed
 14575     ^self primitiveFailed
 14576 !
 14576 !
 14577 
 14577 
 14580      solid (if aBitmapId is nil)"
 14580      solid (if aBitmapId is nil)"
 14581 
 14581 
 14582 %{  /* NOCONTEXT */
 14582 %{  /* NOCONTEXT */
 14583 
 14583 
 14584     if (__bothSmallInteger(fgColorIndex, bgColorIndex)
 14584     if (__bothSmallInteger(fgColorIndex, bgColorIndex)
 14585         && __isExternalAddress(aGCId)) {
 14585 	&& __isExternalAddress(aGCId)) {
 14586         struct gcData *gcData = _GCDATA(aGCId);
 14586 	struct gcData *gcData = _GCDATA(aGCId);
 14587         COLORREF fg, bg, oldFg, oldBg;
 14587 	COLORREF fg, bg, oldFg, oldBg;
 14588         HBITMAP m, oldM;
 14588 	HBITMAP m, oldM;
 14589 
 14589 
 14590         fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData);
 14590 	fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData);
 14591         bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData);
 14591 	bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData);
 14592         if (__isExternalAddress(aBitmapId))
 14592 	if (__isExternalAddress(aBitmapId))
 14593             m = _HBITMAPVAL(aBitmapId);
 14593 	    m = _HBITMAPVAL(aBitmapId);
 14594         else
 14594 	else
 14595             m = 0;
 14595 	    m = 0;
 14596 
 14596 
 14597         oldFg = gcData->fgColor;
 14597 	oldFg = gcData->fgColor;
 14598         oldBg = gcData->bgColor;
 14598 	oldBg = gcData->bgColor;
 14599         oldM = gcData->hMask;
 14599 	oldM = gcData->hMask;
 14600 
 14600 
 14601         if ((oldFg != fg) || (oldBg != bg) || (oldM != m)) {
 14601 	if ((oldFg != fg) || (oldBg != bg) || (oldM != m)) {
 14602             gcData->fgColor = fg;
 14602 	    gcData->fgColor = fg;
 14603             gcData->bgColor = bg;
 14603 	    gcData->bgColor = bg;
 14604             gcData->hMask = m;
 14604 	    gcData->hMask = m;
 14605 
 14605 
 14606 #ifdef CACHE_LAST_DC
 14606 #ifdef CACHE_LAST_DC
 14607             /*
 14607 	    /*
 14608              * must update or flush current cached DC
 14608 	     * must update or flush current cached DC
 14609              */
 14609 	     */
 14610             if (lastGcData == gcData) {
 14610 	    if (lastGcData == gcData) {
 14611                 if (oldM == m) {
 14611 		if (oldM == m) {
 14612                     /*
 14612 		    /*
 14613                      * only fg/bg changed
 14613 		     * only fg/bg changed
 14614                      */
 14614 		     */
 14615                     /* Pen only depends upon fg-color */
 14615 		    /* Pen only depends upon fg-color */
 14616                     if (fg != oldFg) {
 14616 		    if (fg != oldFg) {
 14617                         SetTextColor(gcData->_hDC, fg);
 14617 			SetTextColor(gcData->_hDC, fg);
 14618                         FLUSH_CACHED_PEN(gcData);
 14618 			FLUSH_CACHED_PEN(gcData);
 14619                     }
 14619 		    }
 14620                     if (bg != oldBg) {
 14620 		    if (bg != oldBg) {
 14621                         SetBkColor(gcData->_hDC, bg);
 14621 			SetBkColor(gcData->_hDC, bg);
 14622                     }
 14622 		    }
 14623                     FLUSH_CACHED_BRUSH(gcData);
 14623 		    FLUSH_CACHED_BRUSH(gcData);
 14624                 } else {
 14624 		} else {
 14625                     _releaseDC(gcData);
 14625 		    _releaseDC(gcData);
 14626                 }
 14626 		}
 14627             }
 14627 	    }
 14628 #endif
 14628 #endif
 14629             CPRINTF(("setForeground: %x background: %x mask: %x\n", gcData->fgColor, gcData->bgColor,gcData->hMask));
 14629 	    CPRINTF(("setForeground: %x background: %x mask: %x\n", gcData->fgColor, gcData->bgColor,gcData->hMask));
 14630         }
 14630 	}
 14631         RETURN (self);
 14631 	RETURN (self);
 14632     }
 14632     }
 14633 %}.
 14633 %}.
 14634 
 14634 
 14635     ^ self primitiveFailed
 14635     ^ self primitiveFailed
 14636 !
 14636 !
 14640      solid (if aBitmapId is nil); also set lineWidth"
 14640      solid (if aBitmapId is nil); also set lineWidth"
 14641 
 14641 
 14642 %{  /* NOCONTEXT */
 14642 %{  /* NOCONTEXT */
 14643 
 14643 
 14644     if (__bothSmallInteger(fgColorIndex, bgColorIndex)
 14644     if (__bothSmallInteger(fgColorIndex, bgColorIndex)
 14645         && __isSmallInteger(aLineWidth)
 14645 	&& __isSmallInteger(aLineWidth)
 14646         && __isExternalAddress(aGCId)) {
 14646 	&& __isExternalAddress(aGCId)) {
 14647         struct gcData *gcData = _GCDATA(aGCId);
 14647 	struct gcData *gcData = _GCDATA(aGCId);
 14648         COLORREF fg, bg, oldFg, oldBg;
 14648 	COLORREF fg, bg, oldFg, oldBg;
 14649         HBITMAP m, oldM;
 14649 	HBITMAP m, oldM;
 14650         int lw, oldLw;
 14650 	int lw, oldLw;
 14651 
 14651 
 14652         fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData);
 14652 	fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData);
 14653         bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData);
 14653 	bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData);
 14654         if (__isExternalAddress(aBitmapId))
 14654 	if (__isExternalAddress(aBitmapId))
 14655             m = _HBITMAPVAL(aBitmapId);
 14655 	    m = _HBITMAPVAL(aBitmapId);
 14656         else
 14656 	else
 14657             m = 0;
 14657 	    m = 0;
 14658         lw = __intVal(aLineWidth);
 14658 	lw = __intVal(aLineWidth);
 14659 
 14659 
 14660         oldFg = gcData->fgColor;
 14660 	oldFg = gcData->fgColor;
 14661         oldBg = gcData->bgColor;
 14661 	oldBg = gcData->bgColor;
 14662         oldLw = gcData->lineWidth;
 14662 	oldLw = gcData->lineWidth;
 14663         oldM = gcData->hMask;
 14663 	oldM = gcData->hMask;
 14664 
 14664 
 14665         if ((oldFg != fg) || (oldBg != bg)
 14665 	if ((oldFg != fg) || (oldBg != bg)
 14666          || (oldLw != lw) || (oldM != m)) {
 14666 	 || (oldLw != lw) || (oldM != m)) {
 14667 
 14667 
 14668             gcData->fgColor = fg;
 14668 	    gcData->fgColor = fg;
 14669             gcData->bgColor = bg;
 14669 	    gcData->bgColor = bg;
 14670             gcData->lineWidth = lw;
 14670 	    gcData->lineWidth = lw;
 14671             gcData->hMask = m;
 14671 	    gcData->hMask = m;
 14672 
 14672 
 14673 #ifdef CACHE_LAST_DC
 14673 #ifdef CACHE_LAST_DC
 14674             /*
 14674 	    /*
 14675              * must update or flush current cached DC
 14675 	     * must update or flush current cached DC
 14676              */
 14676 	     */
 14677             if (lastGcData == gcData) {
 14677 	    if (lastGcData == gcData) {
 14678                 if ((oldM == m) && (oldLw == lw)) {
 14678 		if ((oldM == m) && (oldLw == lw)) {
 14679                     /*
 14679 		    /*
 14680                      * only fg/bg changed
 14680 		     * only fg/bg changed
 14681                      */
 14681 		     */
 14682                     /* Pen only depends upon fg-color */
 14682 		    /* Pen only depends upon fg-color */
 14683                     if (fg != oldFg) {
 14683 		    if (fg != oldFg) {
 14684                         SetTextColor(gcData->_hDC, fg);
 14684 			SetTextColor(gcData->_hDC, fg);
 14685                         FLUSH_CACHED_PEN(gcData);
 14685 			FLUSH_CACHED_PEN(gcData);
 14686                     }
 14686 		    }
 14687                     if (bg != oldBg) {
 14687 		    if (bg != oldBg) {
 14688                         SetBkColor(gcData->_hDC, bg);
 14688 			SetBkColor(gcData->_hDC, bg);
 14689                     }
 14689 		    }
 14690                     FLUSH_CACHED_BRUSH(gcData);
 14690 		    FLUSH_CACHED_BRUSH(gcData);
 14691                 } else {
 14691 		} else {
 14692                     _releaseDC(gcData);
 14692 		    _releaseDC(gcData);
 14693                 }
 14693 		}
 14694             }
 14694 	    }
 14695 #endif
 14695 #endif
 14696             CPRINTF(("setForeground: %x background: %x mask: %x linewidth: %d\n",
 14696 	    CPRINTF(("setForeground: %x background: %x mask: %x linewidth: %d\n",
 14697                         gcData->fgColor, gcData->bgColor,
 14697 			gcData->fgColor, gcData->bgColor,
 14698                         gcData->hMask, gcData->lineWidth));
 14698 			gcData->hMask, gcData->lineWidth));
 14699         }
 14699 	}
 14700         RETURN (self);
 14700 	RETURN (self);
 14701     }
 14701     }
 14702 %}.
 14702 %}.
 14703 
 14703 
 14704     ^ self primitiveFailed
 14704     ^ self primitiveFailed
 14705 !
 14705 !
 14710 %{  /* NOCONTEXT */
 14710 %{  /* NOCONTEXT */
 14711 
 14711 
 14712     HDC hDC;
 14712     HDC hDC;
 14713 
 14713 
 14714     if (__isSmallInteger(fgColorIndex)
 14714     if (__isSmallInteger(fgColorIndex)
 14715         && __isExternalAddress(aGCId)) {
 14715 	&& __isExternalAddress(aGCId)) {
 14716         struct gcData *gcData = _GCDATA(aGCId);
 14716 	struct gcData *gcData = _GCDATA(aGCId);
 14717         COLORREF fg;
 14717 	COLORREF fg;
 14718 
 14718 
 14719         fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData);
 14719 	fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData);
 14720         if (fg != gcData->fgColor) {
 14720 	if (fg != gcData->fgColor) {
 14721             gcData->fgColor = fg;
 14721 	    gcData->fgColor = fg;
 14722 
 14722 
 14723 #ifdef CACHE_LAST_DC
 14723 #ifdef CACHE_LAST_DC
 14724             /*
 14724 	    /*
 14725              * must update or flush current cached DC
 14725 	     * must update or flush current cached DC
 14726              */
 14726 	     */
 14727             if (lastGcData == gcData) {
 14727 	    if (lastGcData == gcData) {
 14728                 /* Pen depends upon fg-color */
 14728 		/* Pen depends upon fg-color */
 14729                 SetTextColor(gcData->_hDC, fg);
 14729 		SetTextColor(gcData->_hDC, fg);
 14730                 FLUSH_CACHED_PEN(gcData);
 14730 		FLUSH_CACHED_PEN(gcData);
 14731                 FLUSH_CACHED_BRUSH(gcData);
 14731 		FLUSH_CACHED_BRUSH(gcData);
 14732             }
 14732 	    }
 14733 #endif
 14733 #endif
 14734             CPRINTF(("setForeground: %x\n", gcData->fgColor));
 14734 	    CPRINTF(("setForeground: %x\n", gcData->fgColor));
 14735         }
 14735 	}
 14736         RETURN (self);
 14736 	RETURN (self);
 14737     }
 14737     }
 14738 %}.
 14738 %}.
 14739 
 14739 
 14740     ^ self primitiveFailed
 14740     ^ self primitiveFailed
 14741 !
 14741 !
 14744     "set alu function to be drawn with"
 14744     "set alu function to be drawn with"
 14745 
 14745 
 14746 %{  /* NOCONTEXT */
 14746 %{  /* NOCONTEXT */
 14747 
 14747 
 14748     if (__isExternalAddress(aGCId)) {
 14748     if (__isExternalAddress(aGCId)) {
 14749         struct gcData *gcData = _GCDATA(aGCId);
 14749 	struct gcData *gcData = _GCDATA(aGCId);
 14750         int fun = -1;
 14750 	int fun = -1;
 14751         int bfun = -1;
 14751 	int bfun = -1;
 14752 
 14752 
 14753         if (aFunctionSymbol == @symbol(copy)) {
 14753 	if (aFunctionSymbol == @symbol(copy)) {
 14754             fun = R2_COPYPEN;
 14754 	    fun = R2_COPYPEN;
 14755             bfun = BITBLT_COPY;
 14755 	    bfun = BITBLT_COPY;
 14756         } else if (aFunctionSymbol == @symbol(copyInverted)) {
 14756 	} else if (aFunctionSymbol == @symbol(copyInverted)) {
 14757             fun = R2_NOTCOPYPEN;
 14757 	    fun = R2_NOTCOPYPEN;
 14758             bfun = BITBLT_COPYINVERTED;
 14758 	    bfun = BITBLT_COPYINVERTED;
 14759         } else if (aFunctionSymbol == @symbol(xor)) {
 14759 	} else if (aFunctionSymbol == @symbol(xor)) {
 14760             fun = R2_XORPEN;
 14760 	    fun = R2_XORPEN;
 14761             bfun = BITBLT_XOR;
 14761 	    bfun = BITBLT_XOR;
 14762         } else if (aFunctionSymbol == @symbol(and)) {
 14762 	} else if (aFunctionSymbol == @symbol(and)) {
 14763             fun = R2_MASKPEN;
 14763 	    fun = R2_MASKPEN;
 14764             bfun = BITBLT_AND;
 14764 	    bfun = BITBLT_AND;
 14765         } else if (aFunctionSymbol == @symbol(or)) {
 14765 	} else if (aFunctionSymbol == @symbol(or)) {
 14766             fun = R2_MERGEPEN;
 14766 	    fun = R2_MERGEPEN;
 14767             bfun = BITBLT_OR;
 14767 	    bfun = BITBLT_OR;
 14768         }
 14768 	}
 14769 
 14769 
 14770         if (fun != -1) {
 14770 	if (fun != -1) {
 14771 #if 0
 14771 #if 0
 14772             console_printf("set func to");
 14772 	    console_printf("set func to");
 14773             switch (bfun) {
 14773 	    switch (bfun) {
 14774                 case BITBLT_COPY:
 14774 		case BITBLT_COPY:
 14775                     console_printf("BITBLT_COPY\n");
 14775 		    console_printf("BITBLT_COPY\n");
 14776                     break;
 14776 		    break;
 14777                 case BITBLT_COPYINVERTED:
 14777 		case BITBLT_COPYINVERTED:
 14778                     console_printf("BITBLT_COPYINVERTED\n");
 14778 		    console_printf("BITBLT_COPYINVERTED\n");
 14779                     break;
 14779 		    break;
 14780                 case BITBLT_XOR:
 14780 		case BITBLT_XOR:
 14781                     console_printf("BITBLT_XOR\n");
 14781 		    console_printf("BITBLT_XOR\n");
 14782                     break;
 14782 		    break;
 14783                 case BITBLT_AND:
 14783 		case BITBLT_AND:
 14784                     console_printf("BITBLT_AND\n");
 14784 		    console_printf("BITBLT_AND\n");
 14785                     break;
 14785 		    break;
 14786                 case BITBLT_OR:
 14786 		case BITBLT_OR:
 14787                     console_printf("BITBLT_OR\n");
 14787 		    console_printf("BITBLT_OR\n");
 14788                     break;
 14788 		    break;
 14789             }
 14789 	    }
 14790 #endif
 14790 #endif
 14791         } else {
 14791 	} else {
 14792             INFOFPRINTF( (stderr, "WinWorkstat [warning]: unsuported Rasterfunction\n") );
 14792 	    INFOFPRINTF( (stderr, "WinWorkstat [warning]: unsuported Rasterfunction\n") );
 14793             fun = R2_COPYPEN;
 14793 	    fun = R2_COPYPEN;
 14794             bfun = BITBLT_COPY;
 14794 	    bfun = BITBLT_COPY;
 14795         }
 14795 	}
 14796 
 14796 
 14797         if ((fun != gcData->rop2)
 14797 	if ((fun != gcData->rop2)
 14798          || (bfun != gcData->bitbltrop2)) {
 14798 	 || (bfun != gcData->bitbltrop2)) {
 14799             gcData->rop2 = fun;
 14799 	    gcData->rop2 = fun;
 14800             gcData->bitbltrop2 = bfun;
 14800 	    gcData->bitbltrop2 = bfun;
 14801 #ifdef CACHE_LAST_DC
 14801 #ifdef CACHE_LAST_DC
 14802             /*
 14802 	    /*
 14803              * must update current cached DC
 14803 	     * must update current cached DC
 14804              */
 14804 	     */
 14805             if (gcData == lastGcData) {
 14805 	    if (gcData == lastGcData) {
 14806                 SetROP2(gcData->_hDC, fun);
 14806 		SetROP2(gcData->_hDC, fun);
 14807             }
 14807 	    }
 14808 #endif
 14808 #endif
 14809         }
 14809 	}
 14810     } else {
 14810     } else {
 14811         INFOFPRINTF((stderr, "WinWorkstation [warning]: Rasterfunction no GC\n"));
 14811 	INFOFPRINTF((stderr, "WinWorkstation [warning]: Rasterfunction no GC\n"));
 14812     }
 14812     }
 14813 %}
 14813 %}
 14814 !
 14814 !
 14815 
 14815 
 14816 setGraphicsExposures:aBoolean in:aGCId
 14816 setGraphicsExposures:aBoolean in:aGCId
 14825 
 14825 
 14826     HDC hDC;
 14826     HDC hDC;
 14827 
 14827 
 14828     if (__isExternalAddress(aGCId)
 14828     if (__isExternalAddress(aGCId)
 14829      && __isSmallInteger(aNumber)) {
 14829      && __isSmallInteger(aNumber)) {
 14830         struct gcData *gcData = _GCDATA(aGCId);
 14830 	struct gcData *gcData = _GCDATA(aGCId);
 14831         int style;
 14831 	int style;
 14832 
 14832 
 14833         gcData->lineWidth = __intVal(aNumber);
 14833 	gcData->lineWidth = __intVal(aNumber);
 14834         if (lineStyle == @symbol(solid)) {
 14834 	if (lineStyle == @symbol(solid)) {
 14835             style = PS_SOLID;
 14835 	    style = PS_SOLID;
 14836         } else if (lineStyle == @symbol(dashed)) {
 14836 	} else if (lineStyle == @symbol(dashed)) {
 14837             style= PS_DASH;
 14837 	    style= PS_DASH;
 14838         } else if (lineStyle == @symbol(dotted)) {
 14838 	} else if (lineStyle == @symbol(dotted)) {
 14839             style= PS_DOT;
 14839 	    style= PS_DOT;
 14840         } else if (lineStyle == @symbol(dashDot)) {
 14840 	} else if (lineStyle == @symbol(dashDot)) {
 14841             style= PS_DASHDOT;
 14841 	    style= PS_DASHDOT;
 14842         } else if (lineStyle == @symbol(dashDotDot)) {
 14842 	} else if (lineStyle == @symbol(dashDotDot)) {
 14843             style= PS_DASHDOTDOT;
 14843 	    style= PS_DASHDOTDOT;
 14844         } else
 14844 	} else
 14845             style= PS_SOLID;
 14845 	    style= PS_SOLID;
 14846         gcData->lStyle &= ~PS_STYLE_MASK;
 14846 	gcData->lStyle &= ~PS_STYLE_MASK;
 14847         gcData->lStyle |= style;
 14847 	gcData->lStyle |= style;
 14848 
 14848 
 14849 
 14849 
 14850         if (capStyle == @symbol(round)) {
 14850 	if (capStyle == @symbol(round)) {
 14851             style = PS_ENDCAP_ROUND;
 14851 	    style = PS_ENDCAP_ROUND;
 14852         } else if (capStyle == @symbol(square)) {
 14852 	} else if (capStyle == @symbol(square)) {
 14853             style = PS_ENDCAP_SQUARE;
 14853 	    style = PS_ENDCAP_SQUARE;
 14854         } else if (capStyle == @symbol(flat)) {
 14854 	} else if (capStyle == @symbol(flat)) {
 14855             style = PS_ENDCAP_FLAT;
 14855 	    style = PS_ENDCAP_FLAT;
 14856         } else
 14856 	} else
 14857             style = PS_ENDCAP_FLAT;
 14857 	    style = PS_ENDCAP_FLAT;
 14858         gcData->lStyle &= ~PS_ENDCAP_MASK;
 14858 	gcData->lStyle &= ~PS_ENDCAP_MASK;
 14859         gcData->lStyle |= style;
 14859 	gcData->lStyle |= style;
 14860 
 14860 
 14861         if (joinStyle == @symbol(bevel)) {
 14861 	if (joinStyle == @symbol(bevel)) {
 14862             style = PS_JOIN_BEVEL;
 14862 	    style = PS_JOIN_BEVEL;
 14863         } else if (joinStyle == @symbol(miter)) {
 14863 	} else if (joinStyle == @symbol(miter)) {
 14864             style = PS_JOIN_MITER;
 14864 	    style = PS_JOIN_MITER;
 14865         } else if (joinStyle == @symbol(round)) {
 14865 	} else if (joinStyle == @symbol(round)) {
 14866             style = PS_JOIN_ROUND;
 14866 	    style = PS_JOIN_ROUND;
 14867         } else
 14867 	} else
 14868             style = PS_JOIN_MITER;
 14868 	    style = PS_JOIN_MITER;
 14869         gcData->lStyle &= ~PS_JOIN_MASK;
 14869 	gcData->lStyle &= ~PS_JOIN_MASK;
 14870         gcData->lStyle |= style;
 14870 	gcData->lStyle |= style;
 14871 
 14871 
 14872         FLUSH_CACHED_DC(gcData);
 14872 	FLUSH_CACHED_DC(gcData);
 14873         RETURN (self);
 14873 	RETURN (self);
 14874     }
 14874     }
 14875 %}
 14875 %}
 14876 !
 14876 !
 14877 
 14877 
 14878 setMaskOriginX:orgX y:orgY in:aGCId
 14878 setMaskOriginX:orgX y:orgY in:aGCId
 14880 
 14880 
 14881 %{  /* NOCONTEXT */
 14881 %{  /* NOCONTEXT */
 14882 
 14882 
 14883     if (__isExternalAddress(aGCId)
 14883     if (__isExternalAddress(aGCId)
 14884      && __bothSmallInteger(orgX,orgY)) {
 14884      && __bothSmallInteger(orgX,orgY)) {
 14885         struct gcData *gcData = _GCDATA(aGCId);
 14885 	struct gcData *gcData = _GCDATA(aGCId);
 14886         int oX, oY;
 14886 	int oX, oY;
 14887 
 14887 
 14888         oX = __intVal(orgX);
 14888 	oX = __intVal(orgX);
 14889         oY = __intVal(orgY);
 14889 	oY = __intVal(orgY);
 14890         if ((oX != gcData->maskOrgX)
 14890 	if ((oX != gcData->maskOrgX)
 14891          || (oY != gcData->maskOrgY)) {
 14891 	 || (oY != gcData->maskOrgY)) {
 14892             gcData->maskOrgX = __intVal(orgX);
 14892 	    gcData->maskOrgX = __intVal(orgX);
 14893             gcData->maskOrgY = __intVal(orgY);;
 14893 	    gcData->maskOrgY = __intVal(orgY);;
 14894             FLUSH_CACHED_DC(gcData);
 14894 	    FLUSH_CACHED_DC(gcData);
 14895         }
 14895 	}
 14896         RETURN (self);
 14896 	RETURN (self);
 14897     }
 14897     }
 14898 %}
 14898 %}
 14899 !
 14899 !
 14900 
 14900 
 14901 setPixmapMask:aPixmapId in:aGCId
 14901 setPixmapMask:aPixmapId in:aGCId
 14902     "set or clear the drawing mask - a pixmap mask providing full color"
 14902     "set or clear the drawing mask - a pixmap mask providing full color"
 14903 
 14903 
 14904 %{  /* NOCONTEXT */
 14904 %{  /* NOCONTEXT */
 14905     if (__isExternalAddress(aGCId)) {
 14905     if (__isExternalAddress(aGCId)) {
 14906         struct gcData *gcData = _GCDATA(aGCId);
 14906 	struct gcData *gcData = _GCDATA(aGCId);
 14907         HBITMAP oldM;
 14907 	HBITMAP oldM;
 14908 
 14908 
 14909         oldM = gcData->hMask;
 14909 	oldM = gcData->hMask;
 14910         if (__isExternalAddress(aPixmapId))
 14910 	if (__isExternalAddress(aPixmapId))
 14911             gcData->hMask = _HBITMAPVAL(aPixmapId);
 14911 	    gcData->hMask = _HBITMAPVAL(aPixmapId);
 14912         else
 14912 	else
 14913             gcData->hMask = 0;
 14913 	    gcData->hMask = 0;
 14914 
 14914 
 14915         if (oldM != gcData->hMask) {
 14915 	if (oldM != gcData->hMask) {
 14916             FLUSH_CACHED_DC(gcData);
 14916 	    FLUSH_CACHED_DC(gcData);
 14917             DPRINTF(("PixmapMasks set to %x\n",gcData->hMask));
 14917 	    DPRINTF(("PixmapMasks set to %x\n",gcData->hMask));
 14918         }
 14918 	}
 14919         RETURN (self);
 14919 	RETURN (self);
 14920     }
 14920     }
 14921 %}
 14921 %}
 14922 ! !
 14922 ! !
 14923 
 14923 
 14924 !WinWorkstation methodsFor:'initialization & release'!
 14924 !WinWorkstation methodsFor:'initialization & release'!
 14930 !
 14930 !
 14931 
 14931 
 14932 initializeDefaultKeyboardMappingsIn:aKeyboardMap
 14932 initializeDefaultKeyboardMappingsIn:aKeyboardMap
 14933 
 14933 
 14934     #(
 14934     #(
 14935         Copy            Ctrlc           "copy selection to buffer"
 14935 	Copy            Ctrlc           "copy selection to buffer"
 14936         Cut             Ctrlx           "cut selection into buffer"
 14936 	Cut             Ctrlx           "cut selection into buffer"
 14937         Paste           Ctrlv           "paste buffer or external selection"
 14937 	Paste           Ctrlv           "paste buffer or external selection"
 14938         UserAbort       CtrlCancel      "Abort window process"
 14938 	UserAbort       CtrlCancel      "Abort window process"
 14939         UserInterrupt   Pause           "interrupt window process"
 14939 	UserInterrupt   Pause           "interrupt window process"
 14940         $0              KeyPad0         "NumLocked numeric keypad keys..."
 14940 	$0              KeyPad0         "NumLocked numeric keypad keys..."
 14941         $1              KeyPad1
 14941 	$1              KeyPad1
 14942         $2              KeyPad2
 14942 	$2              KeyPad2
 14943         $3              KeyPad3
 14943 	$3              KeyPad3
 14944         $4              KeyPad4
 14944 	$4              KeyPad4
 14945         $5              KeyPad5
 14945 	$5              KeyPad5
 14946         $6              KeyPad6
 14946 	$6              KeyPad6
 14947         $7              KeyPad7
 14947 	$7              KeyPad7
 14948         $8              KeyPad8
 14948 	$8              KeyPad8
 14949         $9              KeyPad9
 14949 	$9              KeyPad9
 14950     ) pairWiseDo:[:eachMapping :eachKey|
 14950     ) pairWiseDo:[:eachMapping :eachKey|
 14951             aKeyboardMap
 14951 	    aKeyboardMap
 14952                 bindValue:eachMapping to:eachKey.
 14952 		bindValue:eachMapping to:eachKey.
 14953         ].
 14953 	].
 14954 
 14954 
 14955     "
 14955     "
 14956      Screen default initializeDefaultKeyboardMappingsIn:Screen default keyboardMap
 14956      Screen default initializeDefaultKeyboardMappingsIn:Screen default keyboardMap
 14957     "
 14957     "
 14958 !
 14958 !
 14982     int mask, shift, nBits;
 14982     int mask, shift, nBits;
 14983     HDC _rootDC;
 14983     HDC _rootDC;
 14984     OBJ id;
 14984     OBJ id;
 14985 
 14985 
 14986     if (firstInstance) {
 14986     if (firstInstance) {
 14987         OSVERSIONINFO osvi;
 14987 	OSVERSIONINFO osvi;
 14988         WNDCLASSW wc_stx;
 14988 	WNDCLASSW wc_stx;
 14989         WNDCLASSW wc_root;
 14989 	WNDCLASSW wc_root;
 14990         WNDCLASSW wc_popup;
 14990 	WNDCLASSW wc_popup;
 14991         WNDCLASSW wc_dialog;
 14991 	WNDCLASSW wc_dialog;
 14992         firstInstance = 0;
 14992 	firstInstance = 0;
 14993         DPRINTF(("first create - registerClass\n"));
 14993 	DPRINTF(("first create - registerClass\n"));
 14994 
 14994 
 14995         memset(&osvi, 0, sizeof(OSVERSIONINFO));
 14995 	memset(&osvi, 0, sizeof(OSVERSIONINFO));
 14996         osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
 14996 	osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
 14997         GetVersionEx (&osvi);
 14997 	GetVersionEx (&osvi);
 14998 
 14998 
 14999         switch (osvi.dwMajorVersion) {
 14999 	switch (osvi.dwMajorVersion) {
 15000             default:
 15000 	    default:
 15001                 // defaults to the newest version we know about
 15001 		// defaults to the newest version we know about
 15002                 INFOFPRINTF( (stderr, "WinWorkstat [info]: unknown/new display version %d:%d (assume post vista)\n", osvi.dwMajorVersion, osvi.dwMinorVersion) );
 15002 		INFOFPRINTF( (stderr, "WinWorkstat [info]: unknown/new display version %d:%d (assume post vista)\n", osvi.dwMajorVersion, osvi.dwMinorVersion) );
 15003                 // fall into
 15003 		// fall into
 15004             case 6:
 15004 	    case 6:
 15005                 // vista, win7, win8
 15005 		// vista, win7, win8
 15006                 __isWinXP = 1;
 15006 		__isWinXP = 1;
 15007                 __isWinVista = 1;
 15007 		__isWinVista = 1;
 15008                 break;
 15008 		break;
 15009 
 15009 
 15010             case 5:
 15010 	    case 5:
 15011                 // 2k, xp and 2003
 15011 		// 2k, xp and 2003
 15012                 switch (osvi.dwMinorVersion) {
 15012 		switch (osvi.dwMinorVersion) {
 15013                     default:
 15013 		    default:
 15014                     case 2:         // windows server 2003
 15014 		    case 2:         // windows server 2003
 15015                     case 1:         // windows xp
 15015 		    case 1:         // windows xp
 15016                         __isWinXP = 1;
 15016 			__isWinXP = 1;
 15017                         break;
 15017 			break;
 15018                     case 0:
 15018 		    case 0:
 15019                         __isWin2k = 1;
 15019 			__isWin2k = 1;
 15020                 }
 15020 		}
 15021                 break;
 15021 		break;
 15022 
 15022 
 15023             // no longer supported
 15023 	    // no longer supported
 15024             case 4:   // nt4.0
 15024 	    case 4:   // nt4.0
 15025             case 3:   // nt3.51
 15025 	    case 3:   // nt3.51
 15026             case 2:
 15026 	    case 2:
 15027             case 1:
 15027 	    case 1:
 15028             case 0:
 15028 	    case 0:
 15029                 INFOFPRINTF( (stderr, "WinWorkstat [error]: no longer supported display version %d:%d\n", osvi.dwMajorVersion, osvi.dwMinorVersion) );
 15029 		INFOFPRINTF( (stderr, "WinWorkstat [error]: no longer supported display version %d:%d\n", osvi.dwMajorVersion, osvi.dwMinorVersion) );
 15030                 break;
 15030 		break;
 15031         }
 15031 	}
 15032 
 15032 
 15033         /*
 15033 	/*
 15034          * register class: ST/X
 15034 	 * register class: ST/X
 15035          */
 15035 	 */
 15036         wc_stx.style = 0
 15036 	wc_stx.style = 0
 15037                    /* | CS_OWNDC */
 15037 		   /* | CS_OWNDC */
 15038                    /* | CS_HREDRAW */
 15038 		   /* | CS_HREDRAW */
 15039                    /* | CS_VREDRAW */
 15039 		   /* | CS_VREDRAW */
 15040                   | CS_DBLCLKS;
 15040 		  | CS_DBLCLKS;
 15041         wc_stx.lpfnWndProc = (WNDPROC) MainWndProc;
 15041 	wc_stx.lpfnWndProc = (WNDPROC) MainWndProc;
 15042         wc_stx.cbClsExtra = 0;
 15042 	wc_stx.cbClsExtra = 0;
 15043         wc_stx.cbWndExtra = N_WINDOW_PRIVATE;
 15043 	wc_stx.cbWndExtra = N_WINDOW_PRIVATE;
 15044         wc_stx.hInstance = (HANDLE) __getHInstance();
 15044 	wc_stx.hInstance = (HANDLE) __getHInstance();
 15045         wc_stx.hIcon = NULL;
 15045 	wc_stx.hIcon = NULL;
 15046         wc_stx.hCursor = 0;
 15046 	wc_stx.hCursor = 0;
 15047         wc_stx.hbrBackground = 0;
 15047 	wc_stx.hbrBackground = 0;
 15048 
 15048 
 15049         wc_stx.lpszMenuName =  NULL;
 15049 	wc_stx.lpszMenuName =  NULL;
 15050         wc_stx.lpszClassName = wapp_name;
 15050 	wc_stx.lpszClassName = wapp_name;
 15051         RegisterClassW( (&wc_stx) );
 15051 	RegisterClassW( (&wc_stx) );
 15052 
 15052 
 15053         /*
 15053 	/*
 15054          * register class: ST/X:Root
 15054 	 * register class: ST/X:Root
 15055          */
 15055 	 */
 15056         wc_root.style = 0;
 15056 	wc_root.style = 0;
 15057         wc_root.lpfnWndProc = (WNDPROC) MainWndProc;
 15057 	wc_root.lpfnWndProc = (WNDPROC) MainWndProc;
 15058         wc_root.cbClsExtra = 0;
 15058 	wc_root.cbClsExtra = 0;
 15059         wc_root.cbWndExtra = N_WINDOW_PRIVATE;
 15059 	wc_root.cbWndExtra = N_WINDOW_PRIVATE;
 15060         wc_root.hInstance = (HANDLE) __getHInstance();
 15060 	wc_root.hInstance = (HANDLE) __getHInstance();
 15061         wc_root.hIcon = NULL;
 15061 	wc_root.hIcon = NULL;
 15062         wc_root.hCursor = 0;
 15062 	wc_root.hCursor = 0;
 15063         wc_root.hbrBackground = GetStockObject(HOLLOW_BRUSH);
 15063 	wc_root.hbrBackground = GetStockObject(HOLLOW_BRUSH);
 15064 
 15064 
 15065         wc_root.lpszMenuName =  NULL;
 15065 	wc_root.lpszMenuName =  NULL;
 15066         wc_root.lpszClassName = wapp_nameRoot;
 15066 	wc_root.lpszClassName = wapp_nameRoot;
 15067         RegisterClassW( (CONST WNDCLASSW *)(&wc_root) );
 15067 	RegisterClassW( (CONST WNDCLASSW *)(&wc_root) );
 15068 
 15068 
 15069         /*
 15069 	/*
 15070          * register class: ST/X:Popup
 15070 	 * register class: ST/X:Popup
 15071          */
 15071 	 */
 15072         wc_popup.style = CS_SAVEBITS;
 15072 	wc_popup.style = CS_SAVEBITS;
 15073         if (__isWinXP) {
 15073 	if (__isWinXP) {
 15074 #ifndef CS_DROPSHADOW
 15074 #ifndef CS_DROPSHADOW
 15075 # define CS_DROPSHADOW    0x020000
 15075 # define CS_DROPSHADOW    0x020000
 15076 #endif
 15076 #endif
 15077             wc_popup.style |= CS_DROPSHADOW;
 15077 	    wc_popup.style |= CS_DROPSHADOW;
 15078         }
 15078 	}
 15079         wc_popup.lpfnWndProc = (WNDPROC) MainWndProc;;
 15079 	wc_popup.lpfnWndProc = (WNDPROC) MainWndProc;;
 15080         wc_popup.cbClsExtra = 0;
 15080 	wc_popup.cbClsExtra = 0;
 15081         wc_popup.cbWndExtra = N_WINDOW_PRIVATE;
 15081 	wc_popup.cbWndExtra = N_WINDOW_PRIVATE;
 15082         wc_popup.hInstance = (HANDLE) __getHInstance();
 15082 	wc_popup.hInstance = (HANDLE) __getHInstance();
 15083         wc_popup.hIcon = NULL;
 15083 	wc_popup.hIcon = NULL;
 15084         wc_popup.hCursor = 0;
 15084 	wc_popup.hCursor = 0;
 15085         wc_popup.hbrBackground = GetStockObject(HOLLOW_BRUSH);
 15085 	wc_popup.hbrBackground = GetStockObject(HOLLOW_BRUSH);
 15086 
 15086 
 15087         wc_popup.lpszMenuName =  NULL;
 15087 	wc_popup.lpszMenuName =  NULL;
 15088         wc_popup.lpszClassName = wapp_namePopup;
 15088 	wc_popup.lpszClassName = wapp_namePopup;
 15089         RegisterClassW( (CONST WNDCLASSW *)(&wc_popup) );
 15089 	RegisterClassW( (CONST WNDCLASSW *)(&wc_popup) );
 15090 
 15090 
 15091         /*
 15091 	/*
 15092          * register class: ST/X:Dialog
 15092 	 * register class: ST/X:Dialog
 15093          */
 15093 	 */
 15094         wc_dialog.style = CS_SAVEBITS;
 15094 	wc_dialog.style = CS_SAVEBITS;
 15095         wc_dialog.lpfnWndProc = (WNDPROC) MainWndProc;;
 15095 	wc_dialog.lpfnWndProc = (WNDPROC) MainWndProc;;
 15096         wc_dialog.cbClsExtra = 0;
 15096 	wc_dialog.cbClsExtra = 0;
 15097         wc_dialog.cbWndExtra = N_WINDOW_PRIVATE;
 15097 	wc_dialog.cbWndExtra = N_WINDOW_PRIVATE;
 15098         wc_dialog.hInstance = (HANDLE) __getHInstance();
 15098 	wc_dialog.hInstance = (HANDLE) __getHInstance();
 15099         wc_dialog.hIcon = NULL;
 15099 	wc_dialog.hIcon = NULL;
 15100         wc_dialog.hCursor = 0;
 15100 	wc_dialog.hCursor = 0;
 15101         wc_dialog.hbrBackground = GetStockObject(HOLLOW_BRUSH);
 15101 	wc_dialog.hbrBackground = GetStockObject(HOLLOW_BRUSH);
 15102 
 15102 
 15103         wc_dialog.lpszMenuName =  NULL;
 15103 	wc_dialog.lpszMenuName =  NULL;
 15104         wc_dialog.lpszClassName = wapp_nameDialog;
 15104 	wc_dialog.lpszClassName = wapp_nameDialog;
 15105         RegisterClassW( (CONST WNDCLASSW *)(&wc_dialog) );
 15105 	RegisterClassW( (CONST WNDCLASSW *)(&wc_dialog) );
 15106 
 15106 
 15107         /*
 15107 	/*
 15108          * generate my events
 15108 	 * generate my events
 15109          */
 15109 	 */
 15110         hDispatchThreadRunningEvent = CreateEvent(
 15110 	hDispatchThreadRunningEvent = CreateEvent(
 15111                                 NULL,            /* no security attributes */
 15111 				NULL,            /* no security attributes */
 15112                                 FALSE,
 15112 				FALSE,
 15113                                 FALSE,
 15113 				FALSE,
 15114                                 "DispatchThreadRunning"); /* name of event */
 15114 				"DispatchThreadRunning"); /* name of event */
 15115 
 15115 
 15116         if (hDispatchThreadRunningEvent == NULL) {
 15116 	if (hDispatchThreadRunningEvent == NULL) {
 15117             console_fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-0 failed\n");
 15117 	    console_fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-0 failed\n");
 15118             exit(1);
 15118 	    exit(1);
 15119         }
 15119 	}
 15120 
 15120 
 15121         hNeverTriggered = CreateEvent(
 15121 	hNeverTriggered = CreateEvent(
 15122                                 NULL,            /* no security attributes */
 15122 				NULL,            /* no security attributes */
 15123                                 FALSE,
 15123 				FALSE,
 15124                                 FALSE,
 15124 				FALSE,
 15125                                 "Never");
 15125 				"Never");
 15126 
 15126 
 15127         if (hNeverTriggered == NULL) {
 15127 	if (hNeverTriggered == NULL) {
 15128             console_fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-1 failed\n");
 15128 	    console_fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-1 failed\n");
 15129             exit(1);
 15129 	    exit(1);
 15130         }
 15130 	}
 15131 
 15131 
 15132         hCreateEvent = CreateEvent(
 15132 	hCreateEvent = CreateEvent(
 15133                                 NULL,            /* no security attributes */
 15133 				NULL,            /* no security attributes */
 15134                                 FALSE,
 15134 				FALSE,
 15135                                 FALSE,
 15135 				FALSE,
 15136                                 "CreateEvents"); /* name of event */
 15136 				"CreateEvents"); /* name of event */
 15137 
 15137 
 15138         if (hCreateEvent == NULL) {
 15138 	if (hCreateEvent == NULL) {
 15139             console_fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-2 failed\n");
 15139 	    console_fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-2 failed\n");
 15140             exit(1);
 15140 	    exit(1);
 15141         }
 15141 	}
 15142 
 15142 
 15143         hInputEvent = CreateEvent(
 15143 	hInputEvent = CreateEvent(
 15144                                 NULL,            /* no security attributes */
 15144 				NULL,            /* no security attributes */
 15145                                 FALSE,
 15145 				FALSE,
 15146                                 FALSE,
 15146 				FALSE,
 15147                                 "InputEvents");  /* name of event */
 15147 				"InputEvents");  /* name of event */
 15148 
 15148 
 15149         if (hInputEvent == NULL) {
 15149 	if (hInputEvent == NULL) {
 15150             console_fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-3 failed\n");
 15150 	    console_fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-3 failed\n");
 15151             exit(1);
 15151 	    exit(1);
 15152         }
 15152 	}
 15153 
 15153 
 15154         if (hEventsMutex) {
 15154 	if (hEventsMutex) {
 15155             console_fprintf(stderr, "WinWorkstation [fatal]: hEventsMutex already created\n");
 15155 	    console_fprintf(stderr, "WinWorkstation [fatal]: hEventsMutex already created\n");
 15156             exit(1);
 15156 	    exit(1);
 15157         }
 15157 	}
 15158         hEventsMutex = CreateMutex(
 15158 	hEventsMutex = CreateMutex(
 15159                                 NULL,            /* no security attributes */
 15159 				NULL,            /* no security attributes */
 15160                                 FALSE,           /* initially not owned */
 15160 				FALSE,           /* initially not owned */
 15161                                 "EventsMutex");  /* name of mutex */
 15161 				"EventsMutex");  /* name of mutex */
 15162 
 15162 
 15163         if (! hEventsMutex) {
 15163 	if (! hEventsMutex) {
 15164             console_fprintf(stderr, "WinWorkstation [fatal]: hEventsMutex failed\n");
 15164 	    console_fprintf(stderr, "WinWorkstation [fatal]: hEventsMutex failed\n");
 15165             exit(1);
 15165 	    exit(1);
 15166         }
 15166 	}
 15167         DuplicateHandle(GetCurrentProcess(),
 15167 	DuplicateHandle(GetCurrentProcess(),
 15168                         hEventsMutex,
 15168 			hEventsMutex,
 15169                         GetCurrentProcess(),
 15169 			GetCurrentProcess(),
 15170                         &hEventsMutex,
 15170 			&hEventsMutex,
 15171                         DUPLICATE_SAME_ACCESS,
 15171 			DUPLICATE_SAME_ACCESS,
 15172                         FALSE,
 15172 			FALSE,
 15173                         DUPLICATE_SAME_ACCESS);
 15173 			DUPLICATE_SAME_ACCESS);
 15174 
 15174 
 15175 #ifdef USE_PAINT_MUTEX
 15175 #ifdef USE_PAINT_MUTEX
 15176         hPaintMutex = CreateMutex(
 15176 	hPaintMutex = CreateMutex(
 15177                                 NULL,           /* no security attributes */
 15177 				NULL,           /* no security attributes */
 15178                                 FALSE,          /* initially not owned */
 15178 				FALSE,          /* initially not owned */
 15179                                 "PaintMutex");  /* name of mutex */
 15179 				"PaintMutex");  /* name of mutex */
 15180 
 15180 
 15181         if (hPaintMutex == NULL) {
 15181 	if (hPaintMutex == NULL) {
 15182             console_fprintf(stderr, "WinWorkstation [fatal]: CreateMutex(PaintMutex) failed\n");
 15182 	    console_fprintf(stderr, "WinWorkstation [fatal]: CreateMutex(PaintMutex) failed\n");
 15183             exit(1);
 15183 	    exit(1);
 15184         }
 15184 	}
 15185         DuplicateHandle(GetCurrentProcess(),
 15185 	DuplicateHandle(GetCurrentProcess(),
 15186                         hPaintMutex,
 15186 			hPaintMutex,
 15187                         GetCurrentProcess(),
 15187 			GetCurrentProcess(),
 15188                         &hPaintMutex,
 15188 			&hPaintMutex,
 15189                         DUPLICATE_SAME_ACCESS,
 15189 			DUPLICATE_SAME_ACCESS,
 15190                         FALSE,
 15190 			FALSE,
 15191                         DUPLICATE_SAME_ACCESS);
 15191 			DUPLICATE_SAME_ACCESS);
 15192 #endif
 15192 #endif
 15193 #ifdef USE_DRAW_MUTEX
 15193 #ifdef USE_DRAW_MUTEX
 15194         hDrawMutex = CreateMutex(
 15194 	hDrawMutex = CreateMutex(
 15195                                 NULL,           /* no security attributes */
 15195 				NULL,           /* no security attributes */
 15196                                 FALSE,          /* initially not owned */
 15196 				FALSE,          /* initially not owned */
 15197                                 "DrawMutex");   /* name of mutex */
 15197 				"DrawMutex");   /* name of mutex */
 15198 
 15198 
 15199         if (hDrawMutex == NULL) {
 15199 	if (hDrawMutex == NULL) {
 15200             console_fprintf(stderr, "WinWorkstation [fatal]: CreateMutex(DrawMutex) failed\n");
 15200 	    console_fprintf(stderr, "WinWorkstation [fatal]: CreateMutex(DrawMutex) failed\n");
 15201             exit(1);
 15201 	    exit(1);
 15202         }
 15202 	}
 15203         DuplicateHandle(GetCurrentProcess(),
 15203 	DuplicateHandle(GetCurrentProcess(),
 15204                         hDrawMutex,
 15204 			hDrawMutex,
 15205                         GetCurrentProcess(),
 15205 			GetCurrentProcess(),
 15206                         &hDrawMutex,
 15206 			&hDrawMutex,
 15207                         DUPLICATE_SAME_ACCESS,
 15207 			DUPLICATE_SAME_ACCESS,
 15208                         FALSE,
 15208 			FALSE,
 15209                         DUPLICATE_SAME_ACCESS);
 15209 			DUPLICATE_SAME_ACCESS);
 15210 #endif
 15210 #endif
 15211 
 15211 
 15212         _masterThreadId = GetCurrentThreadId();
 15212 	_masterThreadId = GetCurrentThreadId();
 15213 #ifndef WIN32THREADS
 15213 #ifndef WIN32THREADS
 15214         DuplicateHandle(GetCurrentProcess(),
 15214 	DuplicateHandle(GetCurrentProcess(),
 15215                         GetCurrentThread(),
 15215 			GetCurrentThread(),
 15216                         GetCurrentProcess(),
 15216 			GetCurrentProcess(),
 15217                         &_masterThread,
 15217 			&_masterThread,
 15218                         DUPLICATE_SAME_ACCESS,
 15218 			DUPLICATE_SAME_ACCESS,
 15219                         FALSE,
 15219 			FALSE,
 15220                         DUPLICATE_SAME_ACCESS);
 15220 			DUPLICATE_SAME_ACCESS);
 15221 #endif
 15221 #endif
 15222 
 15222 
 15223         initEventqueue();
 15223 	initEventqueue();
 15224 
 15224 
 15225         /*
 15225 	/*
 15226          * start the event dispatcher thread and wait for it to
 15226 	 * start the event dispatcher thread and wait for it to
 15227          * be ready
 15227 	 * be ready
 15228          */
 15228 	 */
 15229         CreateThread((LPSECURITY_ATTRIBUTES)0,
 15229 	CreateThread((LPSECURITY_ATTRIBUTES)0,
 15230                      EVENT_THREAD_STACKSIZE,
 15230 		     EVENT_THREAD_STACKSIZE,
 15231                      (LPTHREAD_START_ROUTINE)dispatchThread,
 15231 		     (LPTHREAD_START_ROUTINE)dispatchThread,
 15232                      0, 0, &_dispatchThreadId);
 15232 		     0, 0, &_dispatchThreadId);
 15233 
 15233 
 15234 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
 15234 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
 15235         console_fprintf(stderr, "WinWorkstation [info]: dispatchThreadId=%x\n", _dispatchThreadId);
 15235 	console_fprintf(stderr, "WinWorkstation [info]: dispatchThreadId=%x\n", _dispatchThreadId);
 15236 #endif
 15236 #endif
 15237 
 15237 
 15238         if (WaitForSingleObject(hDispatchThreadRunningEvent, 5000L) != WAIT_OBJECT_0) {
 15238 	if (WaitForSingleObject(hDispatchThreadRunningEvent, 5000L) != WAIT_OBJECT_0) {
 15239             console_fprintf(stderr, "WinWorkstation [error]: oops - timeout waiting for eventThread to start\n");
 15239 	    console_fprintf(stderr, "WinWorkstation [error]: oops - timeout waiting for eventThread to start\n");
 15240         }
 15240 	}
 15241 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
 15241 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
 15242         console_fprintf(stderr, "WinWorkstation [info]: got ThreadRunningEvent\n");
 15242 	console_fprintf(stderr, "WinWorkstation [info]: got ThreadRunningEvent\n");
 15243 #endif
 15243 #endif
 15244     }
 15244     }
 15245 
 15245 
 15246 #if 0
 15246 #if 0
 15247     __rootDesk = OpenDesktop ("Desktop0", 0, FALSE, GENERIC_ALL);
 15247     __rootDesk = OpenDesktop ("Desktop0", 0, FALSE, GENERIC_ALL);
 15248     if (!__rootDesk) {
 15248     if (!__rootDesk) {
 15249         PRINTF(("OpenDesktop fail\n"));
 15249 	PRINTF(("OpenDesktop fail\n"));
 15250         __rootDesk = CreateDesktop ("Desktop0", NULL, NULL, 0, DESKTOP_WRITEOBJECTS, NULL);
 15250 	__rootDesk = CreateDesktop ("Desktop0", NULL, NULL, 0, DESKTOP_WRITEOBJECTS, NULL);
 15251         if (!__rootDesk) {
 15251 	if (!__rootDesk) {
 15252             PRINTF(("CreateDesktop fail\n"));
 15252 	    PRINTF(("CreateDesktop fail\n"));
 15253         }
 15253 	}
 15254     }
 15254     }
 15255 #endif
 15255 #endif
 15256 
 15256 
 15257     __rootWin = GetDesktopWindow();
 15257     __rootWin = GetDesktopWindow();
 15258     __PROTECT__(self);
 15258     __PROTECT__(self);
 15282 
 15282 
 15283 %{
 15283 %{
 15284     sz = __MKSMALLINT(sizeof(struct queuedEvent) + 100);
 15284     sz = __MKSMALLINT(sizeof(struct queuedEvent) + 100);
 15285 %}.
 15285 %}.
 15286     eventBuffer isNil ifTrue:[
 15286     eventBuffer isNil ifTrue:[
 15287         eventBuffer := ByteArray new:sz.
 15287 	eventBuffer := ByteArray new:sz.
 15288     ].
 15288     ].
 15289 !
 15289 !
 15290 
 15290 
 15291 initializeFor:aDisplayName
 15291 initializeFor:aDisplayName
 15292     "initialize the receiver for a connection to the display;
 15292     "initialize the receiver for a connection to the display;
 15293      the argument, aDisplayName is ignored under Win32.
 15293      the argument, aDisplayName is ignored under Win32.
 15294      (who knows - it may be used in the future to support multiple
 15294      (who knows - it may be used in the future to support multiple
 15295       windows displays ...)"
 15295       windows displays ...)"
 15296 
 15296 
 15297     displayId notNil ifTrue:[
 15297     displayId notNil ifTrue:[
 15298         "/ already connected - trying to trick me ?
 15298 	"/ already connected - trying to trick me ?
 15299         ^ self
 15299 	^ self
 15300     ].
 15300     ].
 15301 
 15301 
 15302     displayId := self primInitializeFor:aDisplayName.
 15302     displayId := self primInitializeFor:aDisplayName.
 15303     displayId isNil ifTrue:[
 15303     displayId isNil ifTrue:[
 15304         self class deviceOpenErrorSignal raiseWith:aDisplayName
 15304 	self class deviceOpenErrorSignal raiseWith:aDisplayName
 15305     ].
 15305     ].
 15306 
 15306 
 15307     dispatching := false.
 15307     dispatching := false.
 15308     isSlow := false.
 15308     isSlow := false.
 15309     shiftDown := false.
 15309     shiftDown := false.
 15356 #ifdef ALWAYSTRUECOLOR
 15356 #ifdef ALWAYSTRUECOLOR
 15357     __depth = 24;  /* its a hack */
 15357     __depth = 24;  /* its a hack */
 15358 #else
 15358 #else
 15359     __depth = __realDepth;
 15359     __depth = __realDepth;
 15360     if (__depth == 15)
 15360     if (__depth == 15)
 15361         __depth = 16;
 15361 	__depth = 16;
 15362 #endif
 15362 #endif
 15363 
 15363 
 15364 #if 0
 15364 #if 0
 15365     numcolors = GetDeviceCaps(__rootDC, NUMCOLORS);
 15365     numcolors = GetDeviceCaps(__rootDC, NUMCOLORS);
 15366     numpens = GetDeviceCaps(__rootDC, NUMPENS);
 15366     numpens = GetDeviceCaps(__rootDC, NUMPENS);
 15375     __INST(ncells) = __MKSMALLINT(1<<__depth);
 15375     __INST(ncells) = __MKSMALLINT(1<<__depth);
 15376 
 15376 
 15377     val = GetDeviceCaps(__rootDC, HORZSIZE);
 15377     val = GetDeviceCaps(__rootDC, HORZSIZE);
 15378     DPRINTF(("HORSIZE=%d\n",val));
 15378     DPRINTF(("HORSIZE=%d\n",val));
 15379     if (val > 0) {
 15379     if (val > 0) {
 15380         __INST(widthMM) = __MKSMALLINT(val);
 15380 	__INST(widthMM) = __MKSMALLINT(val);
 15381     }
 15381     }
 15382     val = GetDeviceCaps(__rootDC, VERTSIZE);
 15382     val = GetDeviceCaps(__rootDC, VERTSIZE);
 15383     DPRINTF(("VERTSIZE=%d\n",val));
 15383     DPRINTF(("VERTSIZE=%d\n",val));
 15384     if (val > 0) {
 15384     if (val > 0) {
 15385         __INST(heightMM) = __MKSMALLINT(val);
 15385 	__INST(heightMM) = __MKSMALLINT(val);
 15386     }
 15386     }
 15387     __logPixelSY = GetDeviceCaps(__rootDC, LOGPIXELSY);
 15387     __logPixelSY = GetDeviceCaps(__rootDC, LOGPIXELSY);
 15388     capabilities = GetDeviceCaps(__rootDC, RASTERCAPS);
 15388     capabilities = GetDeviceCaps(__rootDC, RASTERCAPS);
 15389 
 15389 
 15390 #ifdef LATER
 15390 #ifdef LATER
 15391     console_printf("device support:\n");
 15391     console_printf("device support:\n");
 15392     if (capabilities & RC_BANDING)
 15392     if (capabilities & RC_BANDING)
 15393         console_printf(" RC_BANDING");
 15393 	console_printf(" RC_BANDING");
 15394 
 15394 
 15395     if (capabilities & RC_BITBLT)
 15395     if (capabilities & RC_BITBLT)
 15396         console_printf(" RC_BITBLT");
 15396 	console_printf(" RC_BITBLT");
 15397 
 15397 
 15398     if (capabilities & RC_BITMAP64)
 15398     if (capabilities & RC_BITMAP64)
 15399         console_printf(" RC_BITMAP64");
 15399 	console_printf(" RC_BITMAP64");
 15400 
 15400 
 15401     if (capabilities & RC_DI_BITMAP)
 15401     if (capabilities & RC_DI_BITMAP)
 15402         console_printf(" RC_DI_BITMAP");
 15402 	console_printf(" RC_DI_BITMAP");
 15403 
 15403 
 15404     if (capabilities & RC_DIBTODEV)
 15404     if (capabilities & RC_DIBTODEV)
 15405         console_printf(" RC_DIBTODEV");
 15405 	console_printf(" RC_DIBTODEV");
 15406 
 15406 
 15407     if (capabilities & RC_FLOODFILL)
 15407     if (capabilities & RC_FLOODFILL)
 15408         console_printf(" RC_FLOODFILL");
 15408 	console_printf(" RC_FLOODFILL");
 15409 
 15409 
 15410     if (capabilities & RC_PALETTE)
 15410     if (capabilities & RC_PALETTE)
 15411         console_printf(" RC_PALETTE");
 15411 	console_printf(" RC_PALETTE");
 15412 
 15412 
 15413     if (capabilities & RC_SCALING)
 15413     if (capabilities & RC_SCALING)
 15414         console_printf(" RC_SCALING");
 15414 	console_printf(" RC_SCALING");
 15415 
 15415 
 15416     if (capabilities & RC_STRETCHBLT)
 15416     if (capabilities & RC_STRETCHBLT)
 15417         console_printf(" RC_STRETCHBLT");
 15417 	console_printf(" RC_STRETCHBLT");
 15418 
 15418 
 15419     if (capabilities & RC_STRETCHDIB)
 15419     if (capabilities & RC_STRETCHDIB)
 15420         console_printf(" RC_STRETCHDIB");
 15420 	console_printf(" RC_STRETCHDIB");
 15421 
 15421 
 15422     console_printf("\n");
 15422     console_printf("\n");
 15423     console_printf("cursor size %d %d\n", GetSystemMetrics(SM_CXCURSOR), GetSystemMetrics(SM_CYCURSOR));
 15423     console_printf("cursor size %d %d\n", GetSystemMetrics(SM_CXCURSOR), GetSystemMetrics(SM_CYCURSOR));
 15424 #endif
 15424 #endif
 15425 
 15425 
 15434     __INST(visualType) = @symbol(TrueColor);
 15434     __INST(visualType) = @symbol(TrueColor);
 15435     __INST(redShift) = __MKSMALLINT(0);
 15435     __INST(redShift) = __MKSMALLINT(0);
 15436     __INST(greenShift) = __MKSMALLINT(8);
 15436     __INST(greenShift) = __MKSMALLINT(8);
 15437     __INST(blueShift) = __MKSMALLINT(16);
 15437     __INST(blueShift) = __MKSMALLINT(16);
 15438     switch (__realDepth) {
 15438     switch (__realDepth) {
 15439         case 15:
 15439 	case 15:
 15440         case 16:
 15440 	case 16:
 15441             __INST(bitsPerRGB) = __MKSMALLINT(5);
 15441 	    __INST(bitsPerRGB) = __MKSMALLINT(5);
 15442             break;
 15442 	    break;
 15443         default:
 15443 	default:
 15444             __INST(bitsPerRGB) = __MKSMALLINT(8);
 15444 	    __INST(bitsPerRGB) = __MKSMALLINT(8);
 15445     }
 15445     }
 15446     __INST(bitsRed) = __INST(bitsGreen) = __INST(bitsBlue) = __MKSMALLINT(8);
 15446     __INST(bitsRed) = __INST(bitsGreen) = __INST(bitsBlue) = __MKSMALLINT(8);
 15447     __INST(redMask) = __MKSMALLINT(0xFF);
 15447     __INST(redMask) = __MKSMALLINT(0xFF);
 15448     __INST(greenMask) = __MKSMALLINT(0xFF00);
 15448     __INST(greenMask) = __MKSMALLINT(0xFF00);
 15449     __INST(blueMask) = __MKSMALLINT(0xFF0000);
 15449     __INST(blueMask) = __MKSMALLINT(0xFF0000);
 15450 #else
 15450 #else
 15451     if (! (capabilities & RC_PALETTE)) {
 15451     if (! (capabilities & RC_PALETTE)) {
 15452         DPRINTF(("no palette\n"));
 15452 	DPRINTF(("no palette\n"));
 15453         if (__depth == 1) {
 15453 	if (__depth == 1) {
 15454             __INST(hasColors) = false;
 15454 	    __INST(hasColors) = false;
 15455             __INST(hasGreyscales) = false;
 15455 	    __INST(hasGreyscales) = false;
 15456             __INST(visualType) = @symbol(GrayScale);
 15456 	    __INST(visualType) = @symbol(GrayScale);
 15457             __INST(monitorType) = @symbol(monochrome);
 15457 	    __INST(monitorType) = @symbol(monochrome);
 15458         } else {
 15458 	} else {
 15459             __INST(hasColors) = true;
 15459 	    __INST(hasColors) = true;
 15460             __INST(hasGreyscales) = true;
 15460 	    __INST(hasGreyscales) = true;
 15461             if ((__depth == 16) || (__depth == 15)) {
 15461 	    if ((__depth == 16) || (__depth == 15)) {
 15462               __INST(visualType) = @symbol(TrueColor);
 15462 	      __INST(visualType) = @symbol(TrueColor);
 15463               __INST(blueShift) = __MKSMALLINT(0);
 15463 	      __INST(blueShift) = __MKSMALLINT(0);
 15464               __INST(greenShift) = __MKSMALLINT(5);
 15464 	      __INST(greenShift) = __MKSMALLINT(5);
 15465               __INST(redShift) = __MKSMALLINT(11);
 15465 	      __INST(redShift) = __MKSMALLINT(11);
 15466               __INST(bitsPerRGB) = __MKSMALLINT(5);
 15466 	      __INST(bitsPerRGB) = __MKSMALLINT(5);
 15467               __INST(bitsRed) = __INST(bitsGreen) = __INST(bitsBlue) = __MKSMALLINT(5);
 15467 	      __INST(bitsRed) = __INST(bitsGreen) = __INST(bitsBlue) = __MKSMALLINT(5);
 15468               __INST(blueMask) = __MKSMALLINT(0x1f);
 15468 	      __INST(blueMask) = __MKSMALLINT(0x1f);
 15469               __INST(greenMask) = __MKSMALLINT(0x7e0);
 15469 	      __INST(greenMask) = __MKSMALLINT(0x7e0);
 15470               __INST(redMask) = __MKSMALLINT(0xf800);
 15470 	      __INST(redMask) = __MKSMALLINT(0xf800);
 15471             } else {
 15471 	    } else {
 15472               __INST(visualType) = @symbol(TrueColor);
 15472 	      __INST(visualType) = @symbol(TrueColor);
 15473               __INST(redShift) = __MKSMALLINT(0);
 15473 	      __INST(redShift) = __MKSMALLINT(0);
 15474               __INST(greenShift) = __MKSMALLINT(8);
 15474 	      __INST(greenShift) = __MKSMALLINT(8);
 15475               __INST(blueShift) = __MKSMALLINT(16);
 15475 	      __INST(blueShift) = __MKSMALLINT(16);
 15476               __INST(bitsPerRGB) = __MKSMALLINT(8);
 15476 	      __INST(bitsPerRGB) = __MKSMALLINT(8);
 15477               __INST(bitsRed) = __INST(bitsGreen) = __INST(bitsBlue) = __MKSMALLINT(8);
 15477 	      __INST(bitsRed) = __INST(bitsGreen) = __INST(bitsBlue) = __MKSMALLINT(8);
 15478               __INST(redMask) = __MKSMALLINT(0xFF);
 15478 	      __INST(redMask) = __MKSMALLINT(0xFF);
 15479               __INST(greenMask) = __MKSMALLINT(0xFF00);
 15479 	      __INST(greenMask) = __MKSMALLINT(0xFF00);
 15480               __INST(blueMask) = __MKSMALLINT(0xFF0000);
 15480 	      __INST(blueMask) = __MKSMALLINT(0xFF0000);
 15481             }
 15481 	    }
 15482         }
 15482 	}
 15483     } else {
 15483     } else {
 15484         val = GetDeviceCaps(__rootDC, SIZEPALETTE); /* First two entries are black and white. */
 15484 	val = GetDeviceCaps(__rootDC, SIZEPALETTE); /* First two entries are black and white. */
 15485         // console_printf("SizeofPalette %d\n",val);
 15485 	// console_printf("SizeofPalette %d\n",val);
 15486         __INST(ncells) = __MKSMALLINT(val);
 15486 	__INST(ncells) = __MKSMALLINT(val);
 15487         __INST(blackpixel) = __MKSMALLINT(0);
 15487 	__INST(blackpixel) = __MKSMALLINT(0);
 15488         __INST(whitepixel) = __MKSMALLINT(1);
 15488 	__INST(whitepixel) = __MKSMALLINT(1);
 15489         __INST(hasColors) = true;
 15489 	__INST(hasColors) = true;
 15490         __INST(hasGreyscales) = true;
 15490 	__INST(hasGreyscales) = true;
 15491         // __INST(usingSystemPalette) = true;
 15491 	// __INST(usingSystemPalette) = true;
 15492 
 15492 
 15493         __INST(redShift) = __MKSMALLINT(0);
 15493 	__INST(redShift) = __MKSMALLINT(0);
 15494         __INST(greenShift) = __MKSMALLINT(2);
 15494 	__INST(greenShift) = __MKSMALLINT(2);
 15495         __INST(blueShift) = __MKSMALLINT(4);
 15495 	__INST(blueShift) = __MKSMALLINT(4);
 15496         __INST(bitsPerRGB) = __MKSMALLINT(2);
 15496 	__INST(bitsPerRGB) = __MKSMALLINT(2);
 15497         __INST(bitsRed) = __INST(bitsGreen) = __INST(bitsBlue) = __MKSMALLINT(2);
 15497 	__INST(bitsRed) = __INST(bitsGreen) = __INST(bitsBlue) = __MKSMALLINT(2);
 15498         __INST(redMask) = __MKSMALLINT(0x3);
 15498 	__INST(redMask) = __MKSMALLINT(0x3);
 15499         __INST(greenMask) = __MKSMALLINT(0xc);
 15499 	__INST(greenMask) = __MKSMALLINT(0xc);
 15500         __INST(blueMask) = __MKSMALLINT(0x30);
 15500 	__INST(blueMask) = __MKSMALLINT(0x30);
 15501     }
 15501     }
 15502 #endif /* ! ALWAYSTRUECOLOR */
 15502 #endif /* ! ALWAYSTRUECOLOR */
 15503 %}
 15503 %}
 15504 !
 15504 !
 15505 
 15505 
 15592     "Get a KeySymbol (a smalltalk symbol) from the keycode."
 15592     "Get a KeySymbol (a smalltalk symbol) from the keycode."
 15593 
 15593 
 15594     ^ ''
 15594     ^ ''
 15595 
 15595 
 15596     "
 15596     "
 15597         Display stringFromKeycode:28
 15597 	Display stringFromKeycode:28
 15598     "
 15598     "
 15599 ! !
 15599 ! !
 15600 
 15600 
 15601 !WinWorkstation methodsFor:'misc'!
 15601 !WinWorkstation methodsFor:'misc'!
 15602 
 15602 
 15618 
 15618 
 15619 %{
 15619 %{
 15620     unsigned int type;
 15620     unsigned int type;
 15621 
 15621 
 15622     if (__isSmallInteger(aSymbolOrInteger)) {
 15622     if (__isSmallInteger(aSymbolOrInteger)) {
 15623         type = __smallIntegerVal(aSymbolOrInteger);
 15623 	type = __smallIntegerVal(aSymbolOrInteger);
 15624     } else if (aSymbolOrInteger == @symbol(iconAsterisk)) {
 15624     } else if (aSymbolOrInteger == @symbol(iconAsterisk)) {
 15625         type = MB_ICONASTERISK;
 15625 	type = MB_ICONASTERISK;
 15626     } else if (aSymbolOrInteger == @symbol(iconExclamation)) {
 15626     } else if (aSymbolOrInteger == @symbol(iconExclamation)) {
 15627         type = MB_ICONEXCLAMATION;
 15627 	type = MB_ICONEXCLAMATION;
 15628     } else if (aSymbolOrInteger == @symbol(iconHand)) {
 15628     } else if (aSymbolOrInteger == @symbol(iconHand)) {
 15629         type = MB_ICONHAND;
 15629 	type = MB_ICONHAND;
 15630     } else if (aSymbolOrInteger == @symbol(iconQuestion)) {
 15630     } else if (aSymbolOrInteger == @symbol(iconQuestion)) {
 15631         type = MB_ICONQUESTION;
 15631 	type = MB_ICONQUESTION;
 15632     } else if (aSymbolOrInteger == @symbol(ok)) {
 15632     } else if (aSymbolOrInteger == @symbol(ok)) {
 15633         type = MB_OK;
 15633 	type = MB_OK;
 15634     } else {
 15634     } else {
 15635         type = 0xffffffff;
 15635 	type = 0xffffffff;
 15636     }
 15636     }
 15637 
 15637 
 15638 #ifdef BEEP_IN_WINTHREAD
 15638 #ifdef BEEP_IN_WINTHREAD
 15639     PostThreadMessage(_dispatchThreadId, WM_THREAD_BEEP, 0, 0);
 15639     PostThreadMessage(_dispatchThreadId, WM_THREAD_BEEP, 0, 0);
 15640 #else
 15640 #else
 15680 
 15680 
 15681     pX := aPoint x.
 15681     pX := aPoint x.
 15682     pY := aPoint y.
 15682     pY := aPoint y.
 15683 %{
 15683 %{
 15684     if (__bothSmallInteger(pX, pY)) {
 15684     if (__bothSmallInteger(pX, pY)) {
 15685         POINT p;
 15685 	POINT p;
 15686         HMONITOR hMonitor;
 15686 	HMONITOR hMonitor;
 15687         p.x = __intVal(pX);
 15687 	p.x = __intVal(pX);
 15688         p.y = __intVal(pY);
 15688 	p.y = __intVal(pY);
 15689 #if 0
 15689 #if 0
 15690         /* the following is only needed when we want
 15690 	/* the following is only needed when we want
 15691          * to support very old NT/W95/W98 systems; we don't !
 15691 	 * to support very old NT/W95/W98 systems; we don't !
 15692          */
 15692 	 */
 15693         static HMONITOR (__stdcall *P_MonitorFromPoint)(POINT, int);
 15693 	static HMONITOR (__stdcall *P_MonitorFromPoint)(POINT, int);
 15694 
 15694 
 15695         if (P_MonitorFromPoint == 0) {
 15695 	if (P_MonitorFromPoint == 0) {
 15696             HINSTANCE hUser = LoadLibrary("user32.dll");
 15696 	    HINSTANCE hUser = LoadLibrary("user32.dll");
 15697             // console_printf("hUser: %x\n", hUser);
 15697 	    // console_printf("hUser: %x\n", hUser);
 15698             if (hUser) {
 15698 	    if (hUser) {
 15699                 P_MonitorFromPoint = (HMONITOR (__stdcall *)(POINT, int ))
 15699 		P_MonitorFromPoint = (HMONITOR (__stdcall *)(POINT, int ))
 15700                                     GetProcAddress(hUser, "MonitorFromPoint");
 15700 				    GetProcAddress(hUser, "MonitorFromPoint");
 15701             }
 15701 	    }
 15702         }
 15702 	}
 15703         // console_printf("P_MonitorFromPoint: %x\n", P_MonitorFromPoint);
 15703 	// console_printf("P_MonitorFromPoint: %x\n", P_MonitorFromPoint);
 15704 
 15704 
 15705         hMonitor = (*P_MonitorFromPoint)(p, MONITOR_DEFAULTTONULL);
 15705 	hMonitor = (*P_MonitorFromPoint)(p, MONITOR_DEFAULTTONULL);
 15706 #else
 15706 #else
 15707         hMonitor = MonitorFromPoint(p, MONITOR_DEFAULTTONULL);
 15707 	hMonitor = MonitorFromPoint(p, MONITOR_DEFAULTTONULL);
 15708 #endif
 15708 #endif
 15709         if (hMonitor == 0) {
 15709 	if (hMonitor == 0) {
 15710             RETURN(nil);
 15710 	    RETURN(nil);
 15711         }
 15711 	}
 15712         RETURN ( __MKEXTERNALADDRESS(hMonitor) );
 15712 	RETURN ( __MKEXTERNALADDRESS(hMonitor) );
 15713     }
 15713     }
 15714 %}
 15714 %}
 15715     "
 15715     "
 15716      Screen current monitorHandleForPoint:(0@0)
 15716      Screen current monitorHandleForPoint:(0@0)
 15717      Screen current monitorHandleForPoint:(1500@0)
 15717      Screen current monitorHandleForPoint:(1500@0)
 15723 monitorHandleForView:aWindowId
 15723 monitorHandleForView:aWindowId
 15724     "given a window ID, return a handle to the monitor"
 15724     "given a window ID, return a handle to the monitor"
 15725 
 15725 
 15726 %{
 15726 %{
 15727     if (__isExternalAddress(aWindowId)) {
 15727     if (__isExternalAddress(aWindowId)) {
 15728         HWND hWnd = _HWNDVal(aWindowId);
 15728 	HWND hWnd = _HWNDVal(aWindowId);
 15729         HMONITOR hMonitor;
 15729 	HMONITOR hMonitor;
 15730 #if 0
 15730 #if 0
 15731         /* the following is only needed when we want
 15731 	/* the following is only needed when we want
 15732          * to support very old NT/W95/W98 systems; we don't !
 15732 	 * to support very old NT/W95/W98 systems; we don't !
 15733          */
 15733 	 */
 15734         static HMONITOR (__stdcall *P_MonitorFromWindow)(HWND, int);
 15734 	static HMONITOR (__stdcall *P_MonitorFromWindow)(HWND, int);
 15735 
 15735 
 15736         if (P_MonitorFromWindow == 0) {
 15736 	if (P_MonitorFromWindow == 0) {
 15737             HINSTANCE hUser = LoadLibrary("user32.dll");
 15737 	    HINSTANCE hUser = LoadLibrary("user32.dll");
 15738             // console_printf("hUser: %x\n", hUser);
 15738 	    // console_printf("hUser: %x\n", hUser);
 15739             if (hUser) {
 15739 	    if (hUser) {
 15740                 P_MonitorFromWindow = (HMONITOR (__stdcall *)(HWND, int ))
 15740 		P_MonitorFromWindow = (HMONITOR (__stdcall *)(HWND, int ))
 15741                                     GetProcAddress(hUser, "MonitorFromWindow");
 15741 				    GetProcAddress(hUser, "MonitorFromWindow");
 15742             }
 15742 	    }
 15743         }
 15743 	}
 15744         // console_printf("P_MonitorFromWindow: %x\n", P_MonitorFromWindow);
 15744 	// console_printf("P_MonitorFromWindow: %x\n", P_MonitorFromWindow);
 15745         hMonitor = (*P_MonitorFromWindow)(hWnd, MONITOR_DEFAULTTONULL);
 15745 	hMonitor = (*P_MonitorFromWindow)(hWnd, MONITOR_DEFAULTTONULL);
 15746 #else
 15746 #else
 15747         hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL);
 15747 	hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL);
 15748 #endif
 15748 #endif
 15749         if (hMonitor == 0) {
 15749 	if (hMonitor == 0) {
 15750             RETURN(nil);
 15750 	    RETURN(nil);
 15751         }
 15751 	}
 15752         RETURN ( __MKEXTERNALADDRESS(hMonitor) );
 15752 	RETURN ( __MKEXTERNALADDRESS(hMonitor) );
 15753     }
 15753     }
 15754 %}
 15754 %}
 15755     "
 15755     "
 15756      Screen current monitorHandleForView:(Transcript topView id)
 15756      Screen current monitorHandleForView:(Transcript topView id)
 15757      Screen current monitorHandleForPoint:(0@0)
 15757      Screen current monitorHandleForPoint:(0@0)
 15792      passing one of #parent, #root or nil specifies that the focus should be
 15792      passing one of #parent, #root or nil specifies that the focus should be
 15793      given to the parent view, the root view or no view."
 15793      given to the parent view, the root view or no view."
 15794 
 15794 
 15795 %{
 15795 %{
 15796     if (__isExternalAddress(aWindowId)) {
 15796     if (__isExternalAddress(aWindowId)) {
 15797         HWND hWnd = _HWNDVal(aWindowId);
 15797 	HWND hWnd = _HWNDVal(aWindowId);
 15798         int r = 0;
 15798 	int r = 0;
 15799 
 15799 
 15800         if (revertSymbol == @symbol(parent)) {
 15800 	if (revertSymbol == @symbol(parent)) {
 15801             r = 1;
 15801 	    r = 1;
 15802         } else if (revertSymbol == @symbol(root)) {
 15802 	} else if (revertSymbol == @symbol(root)) {
 15803             r = 2;
 15803 	    r = 2;
 15804         }
 15804 	}
 15805         if (hWnd) {
 15805 	if (hWnd) {
 15806             if (GetFocus() != hWnd) {
 15806 	    if (GetFocus() != hWnd) {
 15807                 DPRINTFIF(__debug_WM_FOCUS__ , ("setInputFocusTo %x revertTo %d\n",hWnd,r));
 15807 		DPRINTFIF(__debug_WM_FOCUS__ , ("setInputFocusTo %x revertTo %d\n",hWnd,r));
 15808 #ifdef SET_FOCUS_IN_WINTHREAD
 15808 #ifdef SET_FOCUS_IN_WINTHREAD
 15809                 PostMessage(hWnd, WM_THREAD_SETFOCUS, (INT)hWnd, GetCurrentThreadId());
 15809 		PostMessage(hWnd, WM_THREAD_SETFOCUS, (INT)hWnd, GetCurrentThreadId());
 15810 #else
 15810 #else
 15811                 if (SetFocus(hWnd) == 0) {
 15811 		if (SetFocus(hWnd) == 0) {
 15812                     PRINTF(("SetFocus to %x failed.\n",hWnd));
 15812 		    PRINTF(("SetFocus to %x failed.\n",hWnd));
 15813                 }
 15813 		}
 15814 #endif
 15814 #endif
 15815             } else {
 15815 	    } else {
 15816                 CPRINTF(("setInputFocusTo %x revertTo %d\n",hWnd,r));
 15816 		CPRINTF(("setInputFocusTo %x revertTo %d\n",hWnd,r));
 15817             }
 15817 	    }
 15818         }
 15818 	}
 15819         RETURN ( self );
 15819 	RETURN ( self );
 15820     }
 15820     }
 15821 %}
 15821 %}
 15822 ! !
 15822 ! !
 15823 
 15823 
 15824 !WinWorkstation methodsFor:'native dialogs'!
 15824 !WinWorkstation methodsFor:'native dialogs'!
 15825 
 15825 
 15826 nativeConfirm:aString title:titleString flags:flags initialAnswer:trueOrFalse
 15826 nativeConfirm:aString title:titleString flags:flags initialAnswer:trueOrFalse
 15827      ^ self
 15827      ^ self
 15828             nativeMessageBoxFor:nil
 15828 	    nativeMessageBoxFor:nil
 15829             text:aString asString string
 15829 	    text:aString asString string
 15830             title:titleString
 15830 	    title:titleString
 15831             flags:flags
 15831 	    flags:flags
 15832             blocking:false
 15832 	    blocking:false
 15833 
 15833 
 15834      "
 15834      "
 15835       Screen current
 15835       Screen current
 15836         nativeConfirm:'please confirm'
 15836 	nativeConfirm:'please confirm'
 15837         title:'Confirm'
 15837 	title:'Confirm'
 15838         flags:#( APPLMODAL ICONQUESTION OKCANCEL)
 15838 	flags:#( APPLMODAL ICONQUESTION OKCANCEL)
 15839         initialAnswer:true
 15839 	initialAnswer:true
 15840      "
 15840      "
 15841      "
 15841      "
 15842       Screen current
 15842       Screen current
 15843         nativeConfirm:'Yes or No'
 15843 	nativeConfirm:'Yes or No'
 15844         title:'Confirm'
 15844 	title:'Confirm'
 15845         flags:#( APPLMODAL ICONQUESTION YESNO)
 15845 	flags:#( APPLMODAL ICONQUESTION YESNO)
 15846         initialAnswer:true
 15846 	initialAnswer:true
 15847      "
 15847      "
 15848 
 15848 
 15849     "Modified: / 02-03-2007 / 15:37:57 / cg"
 15849     "Modified: / 02-03-2007 / 15:37:57 / cg"
 15850     "Modified: / 24-08-2010 / 16:17:29 / sr"
 15850     "Modified: / 24-08-2010 / 16:17:29 / sr"
 15851 !
 15851 !
 15852 
 15852 
 15853 nativeConfirmOKCancel:aString title:titleString initialAnswer:trueOrFalse
 15853 nativeConfirmOKCancel:aString title:titleString initialAnswer:trueOrFalse
 15854      ^ (self
 15854      ^ (self
 15855             nativeConfirm:aString
 15855 	    nativeConfirm:aString
 15856             title:titleString
 15856 	    title:titleString
 15857             flags:#( APPLMODAL ICONQUESTION OKCANCEL)
 15857 	    flags:#( APPLMODAL ICONQUESTION OKCANCEL)
 15858             initialAnswer:trueOrFalse) == #IDOK
 15858 	    initialAnswer:trueOrFalse) == #IDOK
 15859 
 15859 
 15860      "
 15860      "
 15861       Screen current
 15861       Screen current
 15862         nativeConfirmOKCancel:'please confirm' title:'Confirm' initialAnswer:true
 15862 	nativeConfirmOKCancel:'please confirm' title:'Confirm' initialAnswer:true
 15863      "
 15863      "
 15864 
 15864 
 15865     "Modified: / 02-03-2007 / 15:37:32 / cg"
 15865     "Modified: / 02-03-2007 / 15:37:32 / cg"
 15866 !
 15866 !
 15867 
 15867 
 15868 nativeConfirmYesNo:aString title:titleString initialAnswer:trueOrFalse
 15868 nativeConfirmYesNo:aString title:titleString initialAnswer:trueOrFalse
 15869      ^ (self
 15869      ^ (self
 15870             nativeConfirm:aString
 15870 	    nativeConfirm:aString
 15871             title:titleString
 15871 	    title:titleString
 15872             flags:#( APPLMODAL ICONQUESTION YESNO)
 15872 	    flags:#( APPLMODAL ICONQUESTION YESNO)
 15873             initialAnswer:trueOrFalse) == #IDYES
 15873 	    initialAnswer:trueOrFalse) == #IDYES
 15874 
 15874 
 15875      "
 15875      "
 15876       Screen current
 15876       Screen current
 15877         nativeConfirmYesNo:'please confirm' title:'Confirm' initialAnswer:true
 15877 	nativeConfirmYesNo:'please confirm' title:'Confirm' initialAnswer:true
 15878      "
 15878      "
 15879 
 15879 
 15880     "Modified: / 02-03-2007 / 15:12:49 / cg"
 15880     "Modified: / 02-03-2007 / 15:12:49 / cg"
 15881 !
 15881 !
 15882 
 15882 
 15883 nativeFileDialogFor:ownerId save:isSaveDialog title:titleOrNil inDirectory:dirPathOrNil
 15883 nativeFileDialogFor:ownerId save:isSaveDialog title:titleOrNil inDirectory:dirPathOrNil
 15884              initialAnswer:initialOrNil
 15884 	     initialAnswer:initialOrNil
 15885              filter:filterArrayOrNil extension:extensionOrNil
 15885 	     filter:filterArrayOrNil extension:extensionOrNil
 15886     <resource: #obsolete>
 15886     <resource: #obsolete>
 15887 
 15887 
 15888     "sr: replaced by:
 15888     "sr: replaced by:
 15889         nativeFileDialogWithTitle:dialogTitleArg
 15889 	nativeFileDialogWithTitle:dialogTitleArg
 15890         defaultFilename:defaultFilenameArg
 15890 	defaultFilename:defaultFilenameArg
 15891         owningTopView:owningTopView
 15891 	owningTopView:owningTopView
 15892         filter:filterStringOrArrayOfPairs
 15892 	filter:filterStringOrArrayOfPairs
 15893         filterIndex:filterIndexArg
 15893 	filterIndex:filterIndexArg
 15894         doSave:doSave"
 15894 	doSave:doSave"
 15895 
 15895 
 15896     "start a native open-file dialog.
 15896     "start a native open-file dialog.
 15897      If not cancelled, the selected fileName is returned; nil otherwise.
 15897      If not cancelled, the selected fileName is returned; nil otherwise.
 15898      Of course, this one looks like the
 15898      Of course, this one looks like the
 15899      Windows file dialog - no matter which viewStyle settings are active.
 15899      Windows file dialog - no matter which viewStyle settings are active.
 15900      Notice: if no ownerId is given, the dialog pops up at 0@0.
 15900      Notice: if no ownerId is given, the dialog pops up at 0@0.
 15901      filterArrayOrNil: if non nil, must be an array of 2-element arrays,
 15901      filterArrayOrNil: if non nil, must be an array of 2-element arrays,
 15902                        each element specifying filter commnet and filter
 15902 		       each element specifying filter commnet and filter
 15903                        i.e. #( 'bitmap files (*.bmp)' '*.bmp' )
 15903 		       i.e. #( 'bitmap files (*.bmp)' '*.bmp' )
 15904                        i.e. #( 'smalltalk files' '*.st' )
 15904 		       i.e. #( 'smalltalk files' '*.st' )
 15905 
 15905 
 15906      EXPERIMENTAL & non-portable: use with caution"
 15906      EXPERIMENTAL & non-portable: use with caution"
 15907 
 15907 
 15908 
 15908 
 15909 "/
 15909 "/
 15950 "/        extension:extensionOrNil
 15950 "/        extension:extensionOrNil
 15951 "/        blocking:false
 15951 "/        blocking:false
 15952 
 15952 
 15953     "
 15953     "
 15954      Display
 15954      Display
 15955         nativeFileDialogFor:nil save:false
 15955 	nativeFileDialogFor:nil save:false
 15956         title:'Test OpenFile Dialog'
 15956 	title:'Test OpenFile Dialog'
 15957         inDirectory:nil
 15957 	inDirectory:nil
 15958         initialAnswer:nil
 15958 	initialAnswer:nil
 15959         filter:nil
 15959 	filter:nil
 15960         extension:nil
 15960 	extension:nil
 15961 
 15961 
 15962      Display
 15962      Display
 15963         nativeFileDialogFor:nil save:true
 15963 	nativeFileDialogFor:nil save:true
 15964         title:'Test SaveFile Dialog'
 15964 	title:'Test SaveFile Dialog'
 15965         inDirectory:nil
 15965 	inDirectory:nil
 15966         initialAnswer:nil
 15966 	initialAnswer:nil
 15967         filter:nil
 15967 	filter:nil
 15968         extension:nil
 15968 	extension:nil
 15969 
 15969 
 15970      Display
 15970      Display
 15971         nativeFileDialogFor:nil save:true
 15971 	nativeFileDialogFor:nil save:true
 15972         title:'Test SaveFile Dialog'
 15972 	title:'Test SaveFile Dialog'
 15973         inDirectory:nil
 15973 	inDirectory:nil
 15974         initialAnswer:'newFile.bmp'
 15974 	initialAnswer:'newFile.bmp'
 15975         filter:nil
 15975 	filter:nil
 15976         extension:'bmp'
 15976 	extension:'bmp'
 15977 
 15977 
 15978      Display
 15978      Display
 15979         nativeFileDialogFor:nil save:false
 15979 	nativeFileDialogFor:nil save:false
 15980         title:'Test OpenFile Dialog'
 15980 	title:'Test OpenFile Dialog'
 15981         inDirectory:nil
 15981 	inDirectory:nil
 15982         initialAnswer:nil
 15982 	initialAnswer:nil
 15983         filter:#(
 15983 	filter:#(
 15984                     #( 'all files'       '*.*' )
 15984 		    #( 'all files'       '*.*' )
 15985                     #( 'smalltalk files' '*.st' )
 15985 		    #( 'smalltalk files' '*.st' )
 15986                     #( 'change files'    '*.chg' )
 15986 		    #( 'change files'    '*.chg' )
 15987                     #( 'image files'     '*.img' )
 15987 		    #( 'image files'     '*.img' )
 15988                 )
 15988 		)
 15989         extension:nil
 15989 	extension:nil
 15990     "
 15990     "
 15991 
 15991 
 15992     "Modified: / 26-10-2010 / 17:08:04 / cg"
 15992     "Modified: / 26-10-2010 / 17:08:04 / cg"
 15993     "Modified: / 22-10-2018 / 16:23:43 / sr"
 15993     "Modified: / 22-10-2018 / 16:23:43 / sr"
 15994     "Modified (comment): / 23-10-2018 / 10:03:59 / sr"
 15994     "Modified (comment): / 23-10-2018 / 10:03:59 / sr"
 15995 !
 15995 !
 15996 
 15996 
 15997 nativeFileDialogFor:ownerId save:isSaveDialog title:titleOrNil inDirectory:dirPathOrNil
 15997 nativeFileDialogFor:ownerId save:isSaveDialog title:titleOrNil inDirectory:dirPathOrNil
 15998              initialAnswer:initialOrNil flags:flagArray
 15998 	     initialAnswer:initialOrNil flags:flagArray
 15999              filter:filterArrayOrNil extension:extensionOrNil
 15999 	     filter:filterArrayOrNil extension:extensionOrNil
 16000              blocking:blocking
 16000 	     blocking:blocking
 16001     <resource: #obsolete>
 16001     <resource: #obsolete>
 16002 
 16002 
 16003     "sr: replaced by:
 16003     "sr: replaced by:
 16004         nativeFileDialogWithTitle:dialogTitleArg
 16004 	nativeFileDialogWithTitle:dialogTitleArg
 16005         defaultFilename:defaultFilenameArg
 16005 	defaultFilename:defaultFilenameArg
 16006         owningTopView:owningTopView
 16006 	owningTopView:owningTopView
 16007         filter:filterStringOrArrayOfPairs
 16007 	filter:filterStringOrArrayOfPairs
 16008         filterIndex:filterIndexArg
 16008 	filterIndex:filterIndexArg
 16009         doSave:doSave"
 16009 	doSave:doSave"
 16010 
 16010 
 16011     "start a native open-file dialog.
 16011     "start a native open-file dialog.
 16012      If not cancelled, the selected fileName is returned; nil otherwise.
 16012      If not cancelled, the selected fileName is returned; nil otherwise.
 16013      Of course, this one looks like the
 16013      Of course, this one looks like the
 16014      Windows file dialog - no matter which viewStyle settings are active.
 16014      Windows file dialog - no matter which viewStyle settings are active.
 16015      Notice: if no ownerId is given, the dialog pops up at 0@0.
 16015      Notice: if no ownerId is given, the dialog pops up at 0@0.
 16016      filterArrayOrNil: if non nil, must be an array of 2-element arrays,
 16016      filterArrayOrNil: if non nil, must be an array of 2-element arrays,
 16017                        each element specifying filter commnet and filter
 16017 		       each element specifying filter commnet and filter
 16018                        i.e. #( 'bitmap files (*.bmp)' '*.bmp' )
 16018 		       i.e. #( 'bitmap files (*.bmp)' '*.bmp' )
 16019                        i.e. #( 'smalltalk files' '*.st' )
 16019 		       i.e. #( 'smalltalk files' '*.st' )
 16020 
 16020 
 16021      EXPERIMENTAL & non-portable: use with caution"
 16021      EXPERIMENTAL & non-portable: use with caution"
 16022 
 16022 
 16023     |rslt errorCode fileName|
 16023     |rslt errorCode fileName|
 16024 
 16024 
 16032     BOOL __rslt;
 16032     BOOL __rslt;
 16033     jmp_buf exitJmpBuf;
 16033     jmp_buf exitJmpBuf;
 16034     extern void __setAtExitLongJmp(jmp_buf);
 16034     extern void __setAtExitLongJmp(jmp_buf);
 16035 
 16035 
 16036     if (__isExternalAddress(ownerId)) {
 16036     if (__isExternalAddress(ownerId)) {
 16037         hWndOwner = _HWNDVal(ownerId);
 16037 	hWndOwner = _HWNDVal(ownerId);
 16038     }
 16038     }
 16039 
 16039 
 16040 # ifdef OPENFILENAME_SIZE_VERSION_400
 16040 # ifdef OPENFILENAME_SIZE_VERSION_400
 16041     ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; // sizeof(ofn);
 16041     ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; // sizeof(ofn);
 16042 # else
 16042 # else
 16044 # endif
 16044 # endif
 16045     ofn.hwndOwner = hWndOwner;
 16045     ofn.hwndOwner = hWndOwner;
 16046     ofn.hInstance = NULL;
 16046     ofn.hInstance = NULL;
 16047 
 16047 
 16048     if ((filterArrayOrNil != nil) && __isArrayLike(filterArrayOrNil)) {
 16048     if ((filterArrayOrNil != nil) && __isArrayLike(filterArrayOrNil)) {
 16049         char *dst = filterBuffer;
 16049 	char *dst = filterBuffer;
 16050         unsigned int idx;
 16050 	unsigned int idx;
 16051 
 16051 
 16052         for (idx=0; idx<__arraySize(filterArrayOrNil); idx++) {
 16052 	for (idx=0; idx<__arraySize(filterArrayOrNil); idx++) {
 16053             OBJ el = __ArrayInstPtr(filterArrayOrNil)->a_element[idx];
 16053 	    OBJ el = __ArrayInstPtr(filterArrayOrNil)->a_element[idx];
 16054             // console_printf("idx = %d\n", idx);
 16054 	    // console_printf("idx = %d\n", idx);
 16055             if (__isArrayLike(el) && (__arraySize(el) == 2)) {
 16055 	    if (__isArrayLike(el) && (__arraySize(el) == 2)) {
 16056                 OBJ descr, filter;
 16056 		OBJ descr, filter;
 16057 
 16057 
 16058                 descr = __ArrayInstPtr(el)->a_element[0];
 16058 		descr = __ArrayInstPtr(el)->a_element[0];
 16059                 filter = __ArrayInstPtr(el)->a_element[1];
 16059 		filter = __ArrayInstPtr(el)->a_element[1];
 16060                 if (__isStringLike(descr) && __isStringLike(filter)) {
 16060 		if (__isStringLike(descr) && __isStringLike(filter)) {
 16061                     char *src = __stringVal(descr);
 16061 		    char *src = __stringVal(descr);
 16062 
 16062 
 16063                     // console_printf("descr: %s filter: %s\n", __stringVal(descr), __stringVal(filter));
 16063 		    // console_printf("descr: %s filter: %s\n", __stringVal(descr), __stringVal(filter));
 16064 
 16064 
 16065                     // append (incl 0-byte)
 16065 		    // append (incl 0-byte)
 16066                     while (*src) {
 16066 		    while (*src) {
 16067                         *dst++ = *src++;
 16067 			*dst++ = *src++;
 16068                     }
 16068 		    }
 16069                     *dst++ = '\0';
 16069 		    *dst++ = '\0';
 16070 
 16070 
 16071                     src = __stringVal(filter);
 16071 		    src = __stringVal(filter);
 16072                     // append (incl 0-byte)
 16072 		    // append (incl 0-byte)
 16073                     while (*src) {
 16073 		    while (*src) {
 16074                         *dst++ = *src++;
 16074 			*dst++ = *src++;
 16075                     }
 16075 		    }
 16076                     *dst++ = '\0';
 16076 		    *dst++ = '\0';
 16077                 }
 16077 		}
 16078             }
 16078 	    }
 16079         }
 16079 	}
 16080         *dst++ = '\0';
 16080 	*dst++ = '\0';
 16081         *dst = '\0';
 16081 	*dst = '\0';
 16082         ofn.lpstrFilter = filterBuffer;
 16082 	ofn.lpstrFilter = filterBuffer;
 16083         ofn.nFilterIndex = 1;
 16083 	ofn.nFilterIndex = 1;
 16084     } else {
 16084     } else {
 16085         ofn.lpstrFilter = NULL;
 16085 	ofn.lpstrFilter = NULL;
 16086         ofn.nFilterIndex = 0;
 16086 	ofn.nFilterIndex = 0;
 16087     }
 16087     }
 16088     ofn.lpstrCustomFilter = NULL;
 16088     ofn.lpstrCustomFilter = NULL;
 16089     ofn.nMaxCustFilter = 0;
 16089     ofn.nMaxCustFilter = 0;
 16090 
 16090 
 16091     if (__isStringLike(initialOrNil)) {
 16091     if (__isStringLike(initialOrNil)) {
 16092         strcpy(fileNameBuffer, __stringVal(initialOrNil));
 16092 	strcpy(fileNameBuffer, __stringVal(initialOrNil));
 16093     }
 16093     }
 16094     ofn.lpstrFile = fileNameBuffer;
 16094     ofn.lpstrFile = fileNameBuffer;
 16095     ofn.nMaxFile = sizeof(fileNameBuffer);
 16095     ofn.nMaxFile = sizeof(fileNameBuffer);
 16096 
 16096 
 16097     ofn.lpstrFileTitle = NULL;
 16097     ofn.lpstrFileTitle = NULL;
 16098     ofn.nMaxFileTitle = 0;
 16098     ofn.nMaxFileTitle = 0;
 16099     if (__isStringLike(dirPathOrNil)) {
 16099     if (__isStringLike(dirPathOrNil)) {
 16100         ofn.lpstrInitialDir = __stringVal(dirPathOrNil);
 16100 	ofn.lpstrInitialDir = __stringVal(dirPathOrNil);
 16101     } else {
 16101     } else {
 16102         ofn.lpstrInitialDir = NULL;
 16102 	ofn.lpstrInitialDir = NULL;
 16103     }
 16103     }
 16104 
 16104 
 16105     if (__isStringLike(titleOrNil)) {
 16105     if (__isStringLike(titleOrNil)) {
 16106         ofn.lpstrTitle = __stringVal(titleOrNil);
 16106 	ofn.lpstrTitle = __stringVal(titleOrNil);
 16107     } else {
 16107     } else {
 16108         ofn.lpstrTitle = "";
 16108 	ofn.lpstrTitle = "";
 16109     }
 16109     }
 16110     ofn.nFileOffset = 0;
 16110     ofn.nFileOffset = 0;
 16111     ofn.nFileExtension = 0;
 16111     ofn.nFileExtension = 0;
 16112     if (__isStringLike(extensionOrNil)) {
 16112     if (__isStringLike(extensionOrNil)) {
 16113         ofn.lpstrDefExt = __stringVal(extensionOrNil);
 16113 	ofn.lpstrDefExt = __stringVal(extensionOrNil);
 16114     } else {
 16114     } else {
 16115         ofn.lpstrDefExt = NULL;
 16115 	ofn.lpstrDefExt = NULL;
 16116     }
 16116     }
 16117 
 16117 
 16118     ofn.lCustData = (INT)NULL;
 16118     ofn.lCustData = (INT)NULL;
 16119     ofn.lpfnHook = NULL;
 16119     ofn.lpfnHook = NULL;
 16120     ofn.lpTemplateName = NULL;
 16120     ofn.lpTemplateName = NULL;
 16121 
 16121 
 16122     ofn.Flags = 0;
 16122     ofn.Flags = 0;
 16123     if (__isNonNilObject(flagArray) && __isArrayLike(flagArray)) {
 16123     if (__isNonNilObject(flagArray) && __isArrayLike(flagArray)) {
 16124         unsigned int i;
 16124 	unsigned int i;
 16125 
 16125 
 16126         for (i=0; i<__arraySize(flagArray); i++) {
 16126 	for (i=0; i<__arraySize(flagArray); i++) {
 16127             OBJ flag = __ArrayInstPtr(flagArray)->a_element[i];
 16127 	    OBJ flag = __ArrayInstPtr(flagArray)->a_element[i];
 16128             int flagVal = 0;
 16128 	    int flagVal = 0;
 16129 
 16129 
 16130             if (__isSmallInteger(flag)) {
 16130 	    if (__isSmallInteger(flag)) {
 16131                 flagVal = __intVal(flag);
 16131 		flagVal = __intVal(flag);
 16132             } else if (flag == @symbol(READONLY)) {
 16132 	    } else if (flag == @symbol(READONLY)) {
 16133                 flagVal = OFN_READONLY;
 16133 		flagVal = OFN_READONLY;
 16134             } else if (flag == @symbol(OVERWRITEPROMPT)) {
 16134 	    } else if (flag == @symbol(OVERWRITEPROMPT)) {
 16135                 flagVal = OFN_OVERWRITEPROMPT;
 16135 		flagVal = OFN_OVERWRITEPROMPT;
 16136             } else if (flag == @symbol(HIDEREADONLY)) {
 16136 	    } else if (flag == @symbol(HIDEREADONLY)) {
 16137                 flagVal = OFN_HIDEREADONLY;
 16137 		flagVal = OFN_HIDEREADONLY;
 16138             } else if (flag == @symbol(NOCHANGEDIR)) {
 16138 	    } else if (flag == @symbol(NOCHANGEDIR)) {
 16139                 flagVal = OFN_NOCHANGEDIR;
 16139 		flagVal = OFN_NOCHANGEDIR;
 16140             } else if (flag == @symbol(SHOWHELP)) {
 16140 	    } else if (flag == @symbol(SHOWHELP)) {
 16141                 flagVal = OFN_SHOWHELP;
 16141 		flagVal = OFN_SHOWHELP;
 16142             } else if (flag == @symbol(ENABLEHOOK)) {
 16142 	    } else if (flag == @symbol(ENABLEHOOK)) {
 16143                 flagVal = OFN_ENABLEHOOK;
 16143 		flagVal = OFN_ENABLEHOOK;
 16144             } else if (flag == @symbol(ENABLETEMPLATE)) {
 16144 	    } else if (flag == @symbol(ENABLETEMPLATE)) {
 16145                 flagVal = OFN_ENABLETEMPLATE;
 16145 		flagVal = OFN_ENABLETEMPLATE;
 16146             } else if (flag == @symbol(ENABLETEMPLATEHANDLE)) {
 16146 	    } else if (flag == @symbol(ENABLETEMPLATEHANDLE)) {
 16147                 flagVal = OFN_ENABLETEMPLATEHANDLE;
 16147 		flagVal = OFN_ENABLETEMPLATEHANDLE;
 16148             } else if (flag == @symbol(NOVALIDATE)) {
 16148 	    } else if (flag == @symbol(NOVALIDATE)) {
 16149                 flagVal = OFN_NOVALIDATE;
 16149 		flagVal = OFN_NOVALIDATE;
 16150             } else if (flag == @symbol(ALLOWMULTISELECT)) {
 16150 	    } else if (flag == @symbol(ALLOWMULTISELECT)) {
 16151                 flagVal = OFN_ALLOWMULTISELECT;
 16151 		flagVal = OFN_ALLOWMULTISELECT;
 16152             } else if (flag == @symbol(EXTENSIONDIFFERENT)) {
 16152 	    } else if (flag == @symbol(EXTENSIONDIFFERENT)) {
 16153                 flagVal = OFN_EXTENSIONDIFFERENT;
 16153 		flagVal = OFN_EXTENSIONDIFFERENT;
 16154             } else if (flag == @symbol(PATHMUSTEXIST)) {
 16154 	    } else if (flag == @symbol(PATHMUSTEXIST)) {
 16155                 flagVal = OFN_PATHMUSTEXIST;
 16155 		flagVal = OFN_PATHMUSTEXIST;
 16156             } else if (flag == @symbol(FILEMUSTEXIST)) {
 16156 	    } else if (flag == @symbol(FILEMUSTEXIST)) {
 16157                 flagVal = OFN_FILEMUSTEXIST;
 16157 		flagVal = OFN_FILEMUSTEXIST;
 16158             } else if (flag == @symbol(CREATEPROMPT)) {
 16158 	    } else if (flag == @symbol(CREATEPROMPT)) {
 16159                 flagVal = OFN_CREATEPROMPT;
 16159 		flagVal = OFN_CREATEPROMPT;
 16160             } else if (flag == @symbol(SHAREAWARE)) {
 16160 	    } else if (flag == @symbol(SHAREAWARE)) {
 16161                 flagVal = OFN_SHAREAWARE;
 16161 		flagVal = OFN_SHAREAWARE;
 16162             } else if (flag == @symbol(NOREADONLYRETURN)) {
 16162 	    } else if (flag == @symbol(NOREADONLYRETURN)) {
 16163                 flagVal = OFN_NOREADONLYRETURN;
 16163 		flagVal = OFN_NOREADONLYRETURN;
 16164             } else if (flag == @symbol(NOTESTFILECREATE)) {
 16164 	    } else if (flag == @symbol(NOTESTFILECREATE)) {
 16165                 flagVal = OFN_NOTESTFILECREATE;
 16165 		flagVal = OFN_NOTESTFILECREATE;
 16166             } else if (flag == @symbol(NONETWORKBUTTON)) {
 16166 	    } else if (flag == @symbol(NONETWORKBUTTON)) {
 16167                 flagVal = OFN_NONETWORKBUTTON;
 16167 		flagVal = OFN_NONETWORKBUTTON;
 16168             } else if (flag == @symbol(NOLONGNAMES)) {
 16168 	    } else if (flag == @symbol(NOLONGNAMES)) {
 16169                 flagVal = OFN_NOLONGNAMES;
 16169 		flagVal = OFN_NOLONGNAMES;
 16170 # ifdef OFN_EXPLORER
 16170 # ifdef OFN_EXPLORER
 16171             } else if (flag == @symbol(EXPLORER)) {
 16171 	    } else if (flag == @symbol(EXPLORER)) {
 16172                 flagVal = OFN_EXPLORER;
 16172 		flagVal = OFN_EXPLORER;
 16173 # endif
 16173 # endif
 16174 # ifdef OFN_NODEREFERENCELINKS
 16174 # ifdef OFN_NODEREFERENCELINKS
 16175             } else if (flag == @symbol(NODEREFERENCELINKS)) {
 16175 	    } else if (flag == @symbol(NODEREFERENCELINKS)) {
 16176                 flagVal = OFN_NODEREFERENCELINKS;
 16176 		flagVal = OFN_NODEREFERENCELINKS;
 16177 # endif
 16177 # endif
 16178 # ifdef OFN_LONGNAMES
 16178 # ifdef OFN_LONGNAMES
 16179             } else if (flag == @symbol(LONGNAMES)) {
 16179 	    } else if (flag == @symbol(LONGNAMES)) {
 16180                 flagVal = OFN_LONGNAMES;
 16180 		flagVal = OFN_LONGNAMES;
 16181 # endif
 16181 # endif
 16182 # ifdef OFN_ENABLEINCLUDENOTIFY
 16182 # ifdef OFN_ENABLEINCLUDENOTIFY
 16183             } else if (flag == @symbol(ENABLEINCLUDENOTIFY)) {
 16183 	    } else if (flag == @symbol(ENABLEINCLUDENOTIFY)) {
 16184                 flagVal = OFN_ENABLEINCLUDENOTIFY;
 16184 		flagVal = OFN_ENABLEINCLUDENOTIFY;
 16185 # endif
 16185 # endif
 16186 # ifdef OFN_ENABLESIZING
 16186 # ifdef OFN_ENABLESIZING
 16187             } else if (flag == @symbol(ENABLESIZING)) {
 16187 	    } else if (flag == @symbol(ENABLESIZING)) {
 16188                 flagVal = OFN_ENABLESIZING;
 16188 		flagVal = OFN_ENABLESIZING;
 16189 # endif
 16189 # endif
 16190             }
 16190 	    }
 16191             ofn.Flags |= flagVal;
 16191 	    ofn.Flags |= flagVal;
 16192         }
 16192 	}
 16193     }
 16193     }
 16194 
 16194 
 16195     if (isSaveDialog == true) {
 16195     if (isSaveDialog == true) {
 16196         if (blocking == true) {
 16196 	if (blocking == true) {
 16197             __rslt = GetSaveFileName(&ofn);
 16197 	    __rslt = GetSaveFileName(&ofn);
 16198         } else {
 16198 	} else {
 16199             do {
 16199 	    do {
 16200                 __threadErrno = 0;
 16200 		__threadErrno = 0;
 16201                 __rslt = (BOOL)((INT) __STX_API_CALL1( "GetSaveFileName", (voidFUNC)GetSaveFileName, (void *)(&ofn)));
 16201 		__rslt = (BOOL)((INT) __STX_API_CALL1( "GetSaveFileName", (voidFUNC)GetSaveFileName, (void *)(&ofn)));
 16202             } while ((__rslt < 0) && (__threadErrno == EINTR));
 16202 	    } while ((__rslt < 0) && (__threadErrno == EINTR));
 16203         }
 16203 	}
 16204     } else {
 16204     } else {
 16205         if (blocking == true) {
 16205 	if (blocking == true) {
 16206             __rslt = GetOpenFileName(&ofn);
 16206 	    __rslt = GetOpenFileName(&ofn);
 16207         } else {
 16207 	} else {
 16208             do {
 16208 	    do {
 16209                 __threadErrno = 0;
 16209 		__threadErrno = 0;
 16210                 __rslt = (BOOL)((INT) __STX_API_CALL1( "GetOpenFileName", (voidFUNC)GetOpenFileName, (void *)(&ofn)));
 16210 		__rslt = (BOOL)((INT) __STX_API_CALL1( "GetOpenFileName", (voidFUNC)GetOpenFileName, (void *)(&ofn)));
 16211             } while ((__rslt < 0) && (__threadErrno == EINTR));
 16211 	    } while ((__rslt < 0) && (__threadErrno == EINTR));
 16212         }
 16212 	}
 16213     }
 16213     }
 16214 
 16214 
 16215     if ( @global(WinWorkstation:VerboseNativeDialogs) == true) {
 16215     if ( @global(WinWorkstation:VerboseNativeDialogs) == true) {
 16216         console_fprintf(stderr, "WinWorkstation [info]: after GetOpenFileName\n");
 16216 	console_fprintf(stderr, "WinWorkstation [info]: after GetOpenFileName\n");
 16217     }
 16217     }
 16218 
 16218 
 16219     if (setjmp(exitJmpBuf)) {
 16219     if (setjmp(exitJmpBuf)) {
 16220         __setAtExitLongJmp(0);
 16220 	__setAtExitLongJmp(0);
 16221         if ( @global(WinWorkstation:VerboseNativeDialogs) == true) {
 16221 	if ( @global(WinWorkstation:VerboseNativeDialogs) == true) {
 16222             console_fprintf(stderr, "WinWorkstation [warning]: exit longjmp\n");
 16222 	    console_fprintf(stderr, "WinWorkstation [warning]: exit longjmp\n");
 16223         }
 16223 	}
 16224         rslt = false;
 16224 	rslt = false;
 16225         errorCode = __MKSMALLINT(0);
 16225 	errorCode = __MKSMALLINT(0);
 16226         goto getOutOfHere;
 16226 	goto getOutOfHere;
 16227     }
 16227     }
 16228     __setAtExitLongJmp(exitJmpBuf);
 16228     __setAtExitLongJmp(exitJmpBuf);
 16229 
 16229 
 16230     if (__rslt == TRUE) {
 16230     if (__rslt == TRUE) {
 16231         rslt = true;
 16231 	rslt = true;
 16232         fileName = __MKSTRING(fileNameBuffer);
 16232 	fileName = __MKSTRING(fileNameBuffer);
 16233     } else {
 16233     } else {
 16234         rslt = false;
 16234 	rslt = false;
 16235         errorCode = __MKSMALLINT(CommDlgExtendedError());
 16235 	errorCode = __MKSMALLINT(CommDlgExtendedError());
 16236     }
 16236     }
 16237     __setAtExitLongJmp(0);
 16237     __setAtExitLongJmp(0);
 16238 
 16238 
 16239 #else
 16239 #else
 16240     errorCode = __MKSMALLINT(-1);
 16240     errorCode = __MKSMALLINT(-1);
 16241 #endif /* NO_NATIVE_DIALOGS */
 16241 #endif /* NO_NATIVE_DIALOGS */
 16242 getOutOfHere: ;
 16242 getOutOfHere: ;
 16243 %}.
 16243 %}.
 16244     (errorCode notNil) ifTrue:[
 16244     (errorCode notNil) ifTrue:[
 16245         errorCode ~~ 0 ifTrue:[
 16245 	errorCode ~~ 0 ifTrue:[
 16246             self primitiveFailed.
 16246 	    self primitiveFailed.
 16247         ].
 16247 	].
 16248         ^ nil
 16248 	^ nil
 16249     ].
 16249     ].
 16250 
 16250 
 16251     ^ fileName
 16251     ^ fileName
 16252 
 16252 
 16253     "
 16253     "
 16254      Display
 16254      Display
 16255         nativeFileDialogFor:nil save:false
 16255 	nativeFileDialogFor:nil save:false
 16256         title:'Test OpenFile Dialog'
 16256 	title:'Test OpenFile Dialog'
 16257         inDirectory:nil
 16257 	inDirectory:nil
 16258         initialAnswer:nil
 16258 	initialAnswer:nil
 16259         flags:#( ENABLESIZING HIDEREADONLY EXPLORER ENABLESIZING )
 16259 	flags:#( ENABLESIZING HIDEREADONLY EXPLORER ENABLESIZING )
 16260         filter:#(
 16260 	filter:#(
 16261                     #( 'all files'       '*.*' )
 16261 		    #( 'all files'       '*.*' )
 16262                     #( 'smalltalk files' '*.st' )
 16262 		    #( 'smalltalk files' '*.st' )
 16263                     #( 'change files'    '*.chg' )
 16263 		    #( 'change files'    '*.chg' )
 16264                     #( 'image files'     '*.img' )
 16264 		    #( 'image files'     '*.img' )
 16265                 )
 16265 		)
 16266         extension:nil
 16266 	extension:nil
 16267         blocking:false
 16267 	blocking:false
 16268     "
 16268     "
 16269 
 16269 
 16270     "
 16270     "
 16271      Display
 16271      Display
 16272         nativeFileDialogFor:nil save:false
 16272 	nativeFileDialogFor:nil save:false
 16273         title:'Test OpenFile Dialog'
 16273 	title:'Test OpenFile Dialog'
 16274         inDirectory:nil
 16274 	inDirectory:nil
 16275         initialAnswer:nil
 16275 	initialAnswer:nil
 16276         flags:#( ENABLESIZING HIDEREADONLY EXPLORER ENABLESIZING )
 16276 	flags:#( ENABLESIZING HIDEREADONLY EXPLORER ENABLESIZING )
 16277         filter:#(
 16277 	filter:#(
 16278                     #( 'all files'       '*.*' )
 16278 		    #( 'all files'       '*.*' )
 16279                     #( 'smalltalk files' '*.st' )
 16279 		    #( 'smalltalk files' '*.st' )
 16280                     #( 'change files'    '*.chg' )
 16280 		    #( 'change files'    '*.chg' )
 16281                     #( 'image files'     '*.img' )
 16281 		    #( 'image files'     '*.img' )
 16282                 )
 16282 		)
 16283         extension:nil
 16283 	extension:nil
 16284         blocking:true
 16284 	blocking:true
 16285     "
 16285     "
 16286 
 16286 
 16287     "Modified: / 23-10-2018 / 10:04:05 / sr"
 16287     "Modified: / 23-10-2018 / 10:04:05 / sr"
 16288 !
 16288 !
 16289 
 16289 
 16308 
 16308 
 16309     memset(&pdsetup, 0, sizeof(pdsetup));
 16309     memset(&pdsetup, 0, sizeof(pdsetup));
 16310     pdsetup.lStructSize = sizeof(pdsetup);
 16310     pdsetup.lStructSize = sizeof(pdsetup);
 16311     pdsetup.Flags = PD_RETURNDEFAULT | PD_RETURNDC;
 16311     pdsetup.Flags = PD_RETURNDEFAULT | PD_RETURNDC;
 16312     if (! PrintDlg(&pdsetup)) {
 16312     if (! PrintDlg(&pdsetup)) {
 16313         RETURN (nil);
 16313 	RETURN (nil);
 16314     }
 16314     }
 16315     if ( pdsetup.hDC ) {
 16315     if ( pdsetup.hDC ) {
 16316         newDCHandle = __MKOBJ( pdsetup.hDC );
 16316 	newDCHandle = __MKOBJ( pdsetup.hDC );
 16317     }
 16317     }
 16318 #else
 16318 #else
 16319     errorCode = __MKSMALLINT(-1);
 16319     errorCode = __MKSMALLINT(-1);
 16320 #endif /* NO_NATIVE_PRINT_DIALOGS */
 16320 #endif /* NO_NATIVE_PRINT_DIALOGS */
 16321 %}.
 16321 %}.
 16322     (errorCode notNil) ifTrue:[
 16322     (errorCode notNil) ifTrue:[
 16323         self primitiveFailed.
 16323 	self primitiveFailed.
 16324         ^ nil
 16324 	^ nil
 16325     ].
 16325     ].
 16326 
 16326 
 16327     ^ newDCHandle
 16327     ^ newDCHandle
 16328 
 16328 
 16329     "
 16329     "
 16353 
 16353 
 16354     memset(&pdsetup, 0, sizeof(pdsetup));
 16354     memset(&pdsetup, 0, sizeof(pdsetup));
 16355     pdsetup.lStructSize = sizeof(pdsetup);
 16355     pdsetup.lStructSize = sizeof(pdsetup);
 16356     pdsetup.Flags = PD_RETURNDC;
 16356     pdsetup.Flags = PD_RETURNDC;
 16357     if (defaultBoolean == true) {
 16357     if (defaultBoolean == true) {
 16358         pdsetup.Flags |= PD_RETURNDEFAULT;
 16358 	pdsetup.Flags |= PD_RETURNDEFAULT;
 16359     }
 16359     }
 16360 # ifdef BLOCKING
 16360 # ifdef BLOCKING
 16361     answer = PrintDlg(&pdsetup);
 16361     answer = PrintDlg(&pdsetup);
 16362 # else
 16362 # else
 16363     answer = __STX_API_CALL1( "PrintDlg",
 16363     answer = __STX_API_CALL1( "PrintDlg",
 16364                                         (voidFUNC)PrintDlg,
 16364 					(voidFUNC)PrintDlg,
 16365                                         (void *)&pdsetup );
 16365 					(void *)&pdsetup );
 16366 # endif
 16366 # endif
 16367     if (! answer) {
 16367     if (! answer) {
 16368         RETURN (nil);
 16368 	RETURN (nil);
 16369     }
 16369     }
 16370     if ( pdsetup.hDC ) {
 16370     if ( pdsetup.hDC ) {
 16371         newDCHandle = __MKOBJ( pdsetup.hDC );
 16371 	newDCHandle = __MKOBJ( pdsetup.hDC );
 16372     }
 16372     }
 16373 #else
 16373 #else
 16374     errorCode = __MKSMALLINT(-1);
 16374     errorCode = __MKSMALLINT(-1);
 16375 #endif /* NO_NATIVE_PRINT_DIALOGS */
 16375 #endif /* NO_NATIVE_PRINT_DIALOGS */
 16376 %}.
 16376 %}.
 16377     (errorCode notNil) ifTrue:[
 16377     (errorCode notNil) ifTrue:[
 16378         self primitiveFailed.
 16378 	self primitiveFailed.
 16379         ^ nil
 16379 	^ nil
 16380     ].
 16380     ].
 16381 
 16381 
 16382     ^ newDCHandle
 16382     ^ newDCHandle
 16383 
 16383 
 16384     "
 16384     "
 16387     "
 16387     "
 16388 !
 16388 !
 16389 
 16389 
 16390 nativeInformationOK:aString title:titleString
 16390 nativeInformationOK:aString title:titleString
 16391      ^ self
 16391      ^ self
 16392             nativeConfirm:aString
 16392 	    nativeConfirm:aString
 16393             title:titleString
 16393 	    title:titleString
 16394             flags:#( APPLMODAL ICONINFORMATION OK)
 16394 	    flags:#( APPLMODAL ICONINFORMATION OK)
 16395             initialAnswer:nil
 16395 	    initialAnswer:nil
 16396 
 16396 
 16397      "
 16397      "
 16398       Screen current
 16398       Screen current
 16399         nativeInformationOK:'Some Info' title:'Info'
 16399 	nativeInformationOK:'Some Info' title:'Info'
 16400      "
 16400      "
 16401 
 16401 
 16402     "Modified: / 02-03-2007 / 15:37:40 / cg"
 16402     "Modified: / 02-03-2007 / 15:37:40 / cg"
 16403 !
 16403 !
 16404 
 16404 
 16417     char *__title;
 16417     char *__title;
 16418     char *__text;
 16418     char *__text;
 16419     INT __answer;
 16419     INT __answer;
 16420 
 16420 
 16421     if (__isExternalAddress(ownerId)) {
 16421     if (__isExternalAddress(ownerId)) {
 16422         hWndOwner = _HWNDVal(ownerId);
 16422 	hWndOwner = _HWNDVal(ownerId);
 16423     }
 16423     }
 16424     if (__isStringLike(titleOrNil)) {
 16424     if (__isStringLike(titleOrNil)) {
 16425         __title = __stringVal(titleOrNil);
 16425 	__title = __stringVal(titleOrNil);
 16426     } else {
 16426     } else {
 16427         __title = "";
 16427 	__title = "";
 16428     }
 16428     }
 16429     if (__isStringLike(textOrNil)) {
 16429     if (__isStringLike(textOrNil)) {
 16430         __text = __stringVal(textOrNil);
 16430 	__text = __stringVal(textOrNil);
 16431     } else {
 16431     } else {
 16432         __text = "";
 16432 	__text = "";
 16433     }
 16433     }
 16434 
 16434 
 16435     if (__isNonNilObject(flagArray) && __isArrayLike(flagArray)) {
 16435     if (__isNonNilObject(flagArray) && __isArrayLike(flagArray)) {
 16436         unsigned int i;
 16436 	unsigned int i;
 16437 
 16437 
 16438         for (i=0; i<__arraySize(flagArray); i++) {
 16438 	for (i=0; i<__arraySize(flagArray); i++) {
 16439             OBJ flag = __ArrayInstPtr(flagArray)->a_element[i];
 16439 	    OBJ flag = __ArrayInstPtr(flagArray)->a_element[i];
 16440             int flagVal = 0;
 16440 	    int flagVal = 0;
 16441 
 16441 
 16442             if (__isSmallInteger(flag)) {
 16442 	    if (__isSmallInteger(flag)) {
 16443                 flagVal = __intVal(flag);
 16443 		flagVal = __intVal(flag);
 16444             } else if (flag == @symbol(ABORTRETRYIGNORE)) {
 16444 	    } else if (flag == @symbol(ABORTRETRYIGNORE)) {
 16445                 flagVal = MB_ABORTRETRYIGNORE;
 16445 		flagVal = MB_ABORTRETRYIGNORE;
 16446             } else if (flag == @symbol(APPLMODAL)) {
 16446 	    } else if (flag == @symbol(APPLMODAL)) {
 16447                 flagVal = MB_APPLMODAL;
 16447 		flagVal = MB_APPLMODAL;
 16448             } else if (flag == @symbol(DEFAULT_DESKTOP_ONLY)) {
 16448 	    } else if (flag == @symbol(DEFAULT_DESKTOP_ONLY)) {
 16449                 flagVal = MB_DEFAULT_DESKTOP_ONLY;
 16449 		flagVal = MB_DEFAULT_DESKTOP_ONLY;
 16450             } else if (flag == @symbol(DEFBUTTON1)) {
 16450 	    } else if (flag == @symbol(DEFBUTTON1)) {
 16451                 flagVal = MB_DEFBUTTON1;
 16451 		flagVal = MB_DEFBUTTON1;
 16452             } else if (flag == @symbol(DEFBUTTON2)) {
 16452 	    } else if (flag == @symbol(DEFBUTTON2)) {
 16453                 flagVal = MB_DEFBUTTON2;
 16453 		flagVal = MB_DEFBUTTON2;
 16454             } else if (flag == @symbol(DEFBUTTON3)) {
 16454 	    } else if (flag == @symbol(DEFBUTTON3)) {
 16455                 flagVal = MB_DEFBUTTON3;
 16455 		flagVal = MB_DEFBUTTON3;
 16456             } else if (flag == @symbol(ICONASTERISK)) {
 16456 	    } else if (flag == @symbol(ICONASTERISK)) {
 16457                 flagVal = MB_ICONASTERISK;
 16457 		flagVal = MB_ICONASTERISK;
 16458             } else if (flag == @symbol(ICONHAND)) {
 16458 	    } else if (flag == @symbol(ICONHAND)) {
 16459                 flagVal = MB_ICONHAND;
 16459 		flagVal = MB_ICONHAND;
 16460             } else if (flag == @symbol(ICONINFORMATION)) {
 16460 	    } else if (flag == @symbol(ICONINFORMATION)) {
 16461                 flagVal = MB_ICONINFORMATION;
 16461 		flagVal = MB_ICONINFORMATION;
 16462             } else if (flag == @symbol(ICONQUESTION)) {
 16462 	    } else if (flag == @symbol(ICONQUESTION)) {
 16463                 flagVal = MB_ICONQUESTION;
 16463 		flagVal = MB_ICONQUESTION;
 16464             } else if (flag == @symbol(ICONSTOP)) {
 16464 	    } else if (flag == @symbol(ICONSTOP)) {
 16465                 flagVal = MB_ICONSTOP;
 16465 		flagVal = MB_ICONSTOP;
 16466             } else if (flag == @symbol(OK)) {
 16466 	    } else if (flag == @symbol(OK)) {
 16467                 flagVal = MB_OK;
 16467 		flagVal = MB_OK;
 16468             } else if (flag == @symbol(OKCANCEL)) {
 16468 	    } else if (flag == @symbol(OKCANCEL)) {
 16469                 flagVal = MB_OKCANCEL;
 16469 		flagVal = MB_OKCANCEL;
 16470             } else if (flag == @symbol(RETRYCANCEL)) {
 16470 	    } else if (flag == @symbol(RETRYCANCEL)) {
 16471                 flagVal = MB_RETRYCANCEL;
 16471 		flagVal = MB_RETRYCANCEL;
 16472             } else if (flag == @symbol(SETFOREGROUND)) {
 16472 	    } else if (flag == @symbol(SETFOREGROUND)) {
 16473                 flagVal = MB_SETFOREGROUND;
 16473 		flagVal = MB_SETFOREGROUND;
 16474             } else if (flag == @symbol(SYSTEMMODAL)) {
 16474 	    } else if (flag == @symbol(SYSTEMMODAL)) {
 16475                 flagVal = MB_SYSTEMMODAL;
 16475 		flagVal = MB_SYSTEMMODAL;
 16476             } else if (flag == @symbol(TASKMODAL)) {
 16476 	    } else if (flag == @symbol(TASKMODAL)) {
 16477                 flagVal = MB_TASKMODAL;
 16477 		flagVal = MB_TASKMODAL;
 16478             } else if (flag == @symbol(YESNO)) {
 16478 	    } else if (flag == @symbol(YESNO)) {
 16479                 flagVal = MB_YESNO;
 16479 		flagVal = MB_YESNO;
 16480             } else if (flag == @symbol(YESNOCANCEL)) {
 16480 	    } else if (flag == @symbol(YESNOCANCEL)) {
 16481                 flagVal = MB_YESNOCANCEL;
 16481 		flagVal = MB_YESNOCANCEL;
 16482             }
 16482 	    }
 16483             boxFlags |= flagVal;
 16483 	    boxFlags |= flagVal;
 16484         }
 16484 	}
 16485     }
 16485     }
 16486 
 16486 
 16487     if (blocking == true) {
 16487     if (blocking == true) {
 16488         __answer = MessageBox(hWndOwner,
 16488 	__answer = MessageBox(hWndOwner,
 16489                               __text,
 16489 			      __text,
 16490                               __title,
 16490 			      __title,
 16491                               boxFlags);
 16491 			      boxFlags);
 16492     } else {
 16492     } else {
 16493         do {
 16493 	do {
 16494             __threadErrno = 0;
 16494 	    __threadErrno = 0;
 16495             __answer = (INT) __STX_API_CALL4(
 16495 	    __answer = (INT) __STX_API_CALL4(
 16496                                         "MessageBox",
 16496 					"MessageBox",
 16497                                         (voidFUNC)MessageBox,
 16497 					(voidFUNC)MessageBox,
 16498                                         (void *)hWndOwner,
 16498 					(void *)hWndOwner,
 16499                                         (void *)__text,
 16499 					(void *)__text,
 16500                                         (void *)__title,
 16500 					(void *)__title,
 16501                                         (void *)((INT)boxFlags));
 16501 					(void *)((INT)boxFlags));
 16502         } while ((__answer < 0) && (__threadErrno == EINTR));
 16502 	} while ((__answer < 0) && (__threadErrno == EINTR));
 16503     }
 16503     }
 16504 
 16504 
 16505     switch (__answer) {
 16505     switch (__answer) {
 16506         case IDABORT:
 16506 	case IDABORT:
 16507             answer = @symbol(IDABORT);
 16507 	    answer = @symbol(IDABORT);
 16508             break;
 16508 	    break;
 16509         case IDCANCEL:
 16509 	case IDCANCEL:
 16510             answer = @symbol(IDCANCEL);
 16510 	    answer = @symbol(IDCANCEL);
 16511             break;
 16511 	    break;
 16512         case IDIGNORE:
 16512 	case IDIGNORE:
 16513             answer = @symbol(IDIGNORE);
 16513 	    answer = @symbol(IDIGNORE);
 16514             break;
 16514 	    break;
 16515         case IDNO:
 16515 	case IDNO:
 16516             answer = @symbol(IDNO);
 16516 	    answer = @symbol(IDNO);
 16517             break;
 16517 	    break;
 16518         case IDOK:
 16518 	case IDOK:
 16519             answer = @symbol(IDOK);
 16519 	    answer = @symbol(IDOK);
 16520             break;
 16520 	    break;
 16521         case IDRETRY:
 16521 	case IDRETRY:
 16522             answer = @symbol(IDRETRY);
 16522 	    answer = @symbol(IDRETRY);
 16523             break;
 16523 	    break;
 16524         case IDYES:
 16524 	case IDYES:
 16525             answer = @symbol(IDYES);
 16525 	    answer = @symbol(IDYES);
 16526             break;
 16526 	    break;
 16527         default:
 16527 	default:
 16528             answer = __MKSMALLINT(__answer);
 16528 	    answer = __MKSMALLINT(__answer);
 16529             break;
 16529 	    break;
 16530     }
 16530     }
 16531 #else
 16531 #else
 16532     errorCode = __MKSMALLINT(-1);
 16532     errorCode = __MKSMALLINT(-1);
 16533 #endif /* NO_NATIVE_DIALOGS */
 16533 #endif /* NO_NATIVE_DIALOGS */
 16534 %}.
 16534 %}.
 16535     (errorCode notNil) ifTrue:[
 16535     (errorCode notNil) ifTrue:[
 16536         self primitiveFailed.
 16536 	self primitiveFailed.
 16537         ^ nil
 16537 	^ nil
 16538     ].
 16538     ].
 16539 
 16539 
 16540     ^ answer
 16540     ^ answer
 16541 
 16541 
 16542     "
 16542     "
 16543      Display
 16543      Display
 16544         nativeMessageBoxFor:nil
 16544 	nativeMessageBoxFor:nil
 16545         text:'Hello world'
 16545 	text:'Hello world'
 16546         title:'Message'
 16546 	title:'Message'
 16547         flags:#( OK APPLMODAL ICONSTOP )
 16547 	flags:#( OK APPLMODAL ICONSTOP )
 16548         blocking:true
 16548 	blocking:true
 16549 
 16549 
 16550      Display
 16550      Display
 16551         nativeMessageBoxFor:nil
 16551 	nativeMessageBoxFor:nil
 16552         text:'Hello world'
 16552 	text:'Hello world'
 16553         title:'Message'
 16553 	title:'Message'
 16554         flags:#( OK APPLMODAL ICONSTOP )
 16554 	flags:#( OK APPLMODAL ICONSTOP )
 16555         blocking:false
 16555 	blocking:false
 16556 
 16556 
 16557      Display
 16557      Display
 16558         nativeMessageBoxFor:nil
 16558 	nativeMessageBoxFor:nil
 16559         text:'Hello world'
 16559 	text:'Hello world'
 16560         title:'Message'
 16560 	title:'Message'
 16561         flags:#( ABORTRETRYIGNORE ICONSTOP )
 16561 	flags:#( ABORTRETRYIGNORE ICONSTOP )
 16562         blocking:false
 16562 	blocking:false
 16563     "
 16563     "
 16564 !
 16564 !
 16565 
 16565 
 16566 nativeWarnOK:aString title:titleString
 16566 nativeWarnOK:aString title:titleString
 16567      ^ self
 16567      ^ self
 16568             nativeConfirm:aString
 16568 	    nativeConfirm:aString
 16569             title:titleString
 16569 	    title:titleString
 16570             flags:#( APPLMODAL ICONSTOP OK)
 16570 	    flags:#( APPLMODAL ICONSTOP OK)
 16571             initialAnswer:nil
 16571 	    initialAnswer:nil
 16572 
 16572 
 16573      "
 16573      "
 16574       Screen current
 16574       Screen current
 16575         nativeWarnOK:'some warning' title:'Warning'
 16575 	nativeWarnOK:'some warning' title:'Warning'
 16576      "
 16576      "
 16577 
 16577 
 16578     "Modified: / 02-03-2007 / 15:37:47 / cg"
 16578     "Modified: / 02-03-2007 / 15:37:47 / cg"
 16579 ! !
 16579 ! !
 16580 
 16580 
 16590     "opens a native windows file dialog,
 16590     "opens a native windows file dialog,
 16591      supports unicode 16 strings (like windows does it for filenames)
 16591      supports unicode 16 strings (like windows does it for filenames)
 16592      returns nil or the full path to the selected file
 16592      returns nil or the full path to the selected file
 16593      see example at the end of the method code"
 16593      see example at the end of the method code"
 16594 
 16594 
 16595     |dialogTitle defaultBaseName defaultDirectory owningViewId windowGroup filterString null 
 16595     |dialogTitle defaultBaseName defaultDirectory owningViewId windowGroup filterString null
 16596      dataAddressAndThreadAddress dataAddress returnValue|
 16596      dataAddressAndThreadAddress dataAddress returnValue|
 16597 
 16597 
 16598     dialogTitleArg notEmptyOrNil ifTrue:[
 16598     dialogTitleArg notEmptyOrNil ifTrue:[
 16599         dialogTitle := dialogTitleArg asUnicode16String.
 16599 	dialogTitle := dialogTitleArg asUnicode16String.
 16600     ].
 16600     ].
 16601 
 16601 
 16602     defaultFilenameArg notNil ifTrue:[
 16602     defaultFilenameArg notNil ifTrue:[
 16603         |defaultFilename|    
 16603 	|defaultFilename|
 16604 
 16604 
 16605         defaultFilename := defaultFilenameArg asFilename.
 16605 	defaultFilename := defaultFilenameArg asFilename.
 16606         defaultFilename isDirectory ifTrue:[
 16606 	defaultFilename isDirectory ifTrue:[
 16607             defaultDirectory := defaultFilename.
 16607 	    defaultDirectory := defaultFilename.
 16608         ] ifFalse:[
 16608 	] ifFalse:[
 16609             defaultDirectory := defaultFilename directory.
 16609 	    defaultDirectory := defaultFilename directory.
 16610             defaultBaseName := defaultFilename baseName asUnicode16String.
 16610 	    defaultBaseName := defaultFilename baseName asUnicode16String.
 16611         ].
 16611 	].
 16612 
 16612 
 16613         defaultDirectory := defaultDirectory pathName asUnicode16String.
 16613 	defaultDirectory := defaultDirectory pathName asUnicode16String.
 16614     ].    
 16614     ].
 16615 
 16615 
 16616     owningTopView notNil ifTrue:[
 16616     owningTopView notNil ifTrue:[
 16617         owningViewId := owningTopView id.
 16617 	owningViewId := owningTopView id.
 16618         windowGroup := owningTopView windowGroup.
 16618 	windowGroup := owningTopView windowGroup.
 16619     ].
 16619     ].
 16620 
 16620 
 16621     filterStringOrArrayOfPairs notEmptyOrNil ifTrue:[
 16621     filterStringOrArrayOfPairs notEmptyOrNil ifTrue:[
 16622         filterStringOrArrayOfPairs isString ifTrue:[
 16622 	filterStringOrArrayOfPairs isString ifTrue:[
 16623             filterString := filterStringOrArrayOfPairs.
 16623 	    filterString := filterStringOrArrayOfPairs.
 16624         ] ifFalse:[
 16624 	] ifFalse:[
 16625             null := (Character codePoint:0) asString. 
 16625 	    null := (Character codePoint:0) asString.
 16626             filterString := ((filterStringOrArrayOfPairs 
 16626 	    filterString := ((filterStringOrArrayOfPairs
 16627                 collect:[:eachPair | 
 16627 		collect:[:eachPair |
 16628                     eachPair first, null, eachPair second, null
 16628 		    eachPair first, null, eachPair second, null
 16629                 ]) 
 16629 		])
 16630                     asStringWith:''), null.
 16630 		    asStringWith:''), null.
 16631         ].
 16631 	].
 16632 
 16632 
 16633         filterString := filterString asUnicode16String.
 16633 	filterString := filterString asUnicode16String.
 16634     ].       
 16634     ].
 16635 
 16635 
 16636     [
 16636     [
 16637         dataAddressAndThreadAddress := self 
 16637 	dataAddressAndThreadAddress := self
 16638             primNativeFileDialogWithTitle:dialogTitle
 16638 	    primNativeFileDialogWithTitle:dialogTitle
 16639             defaultBaseName:defaultBaseName
 16639 	    defaultBaseName:defaultBaseName
 16640             defaultDirectory:defaultDirectory
 16640 	    defaultDirectory:defaultDirectory
 16641             owningViewId:owningViewId
 16641 	    owningViewId:owningViewId
 16642             filterString:filterString
 16642 	    filterString:filterString
 16643             filterIndex:filterIndexArg ? 1 
 16643 	    filterIndex:filterIndexArg ? 1
 16644             doSave:doSave
 16644 	    doSave:doSave
 16645             allowMultiSelect:false. "/ not yet implemented
 16645 	    allowMultiSelect:false. "/ not yet implemented
 16646 
 16646 
 16647         dataAddress := dataAddressAndThreadAddress first.
 16647 	dataAddress := dataAddressAndThreadAddress first.
 16648 
 16648 
 16649         [
 16649 	[
 16650             windowGroup notNil ifTrue:[
 16650 	    windowGroup notNil ifTrue:[
 16651                 windowGroup sensor eventSemaphore waitWithTimeout:100 milliseconds.
 16651 		windowGroup sensor eventSemaphore waitWithTimeout:100 milliseconds.
 16652                 "sr: we can process all events (also redraws), 
 16652 		"sr: we can process all events (also redraws),
 16653                  because the operating system handles the modal,
 16653 		 because the operating system handles the modal,
 16654                  user events are blocked by operating system"
 16654 		 user events are blocked by operating system"
 16655                 windowGroup processEvents.
 16655 		windowGroup processEvents.
 16656             ] ifFalse:[
 16656 	    ] ifFalse:[
 16657                 Delay waitForMilliseconds:100.
 16657 		Delay waitForMilliseconds:100.
 16658             ].
 16658 	    ].
 16659 
 16659 
 16660             returnValue := self primGetNativeFileDialogResultByDataAddress:dataAddress.
 16660 	    returnValue := self primGetNativeFileDialogResultByDataAddress:dataAddress.
 16661         ] doWhile:[
 16661 	] doWhile:[
 16662             returnValue isNil 
 16662 	    returnValue isNil
 16663         ].
 16663 	].
 16664     ] ensure:[
 16664     ] ensure:[
 16665         (dataAddressAndThreadAddress notNil 
 16665 	(dataAddressAndThreadAddress notNil
 16666         "/ if #returnValue is not nil, we already finished and did the memory free
 16666 	"/ if #returnValue is not nil, we already finished and did the memory free
 16667         and:[returnValue isNil]) ifTrue:[
 16667 	and:[returnValue isNil]) ifTrue:[
 16668             Display 
 16668 	    Display
 16669                 primCloseNativeFileDialogByDataAddress:dataAddressAndThreadAddress first
 16669 		primCloseNativeFileDialogByDataAddress:dataAddressAndThreadAddress first
 16670                 threadHandleAddress:dataAddressAndThreadAddress second.    
 16670 		threadHandleAddress:dataAddressAndThreadAddress second.
 16671         ].
 16671 	].
 16672     ].
 16672     ].
 16673 
 16673 
 16674     returnValue isEmptyOrNil ifTrue:[
 16674     returnValue isEmptyOrNil ifTrue:[
 16675         ^ nil
 16675 	^ nil
 16676     ].
 16676     ].
 16677 
 16677 
 16678     ^ returnValue
 16678     ^ returnValue
 16679 
 16679 
 16680     "
 16680     "
 16681     ########### example1 without owning view ##########
 16681     ########### example1 without owning view ##########
 16682 
 16682 
 16683         |null|
 16683 	|null|
 16684 
 16684 
 16685         null := (Character codePoint:0) asString.    
 16685 	null := (Character codePoint:0) asString.
 16686 
 16686 
 16687         Display 
 16687 	Display
 16688             nativeFileDialogWithTitle:'Hello World' 
 16688 	    nativeFileDialogWithTitle:'Hello World'
 16689             defaultFilename:'C:\users\sr\desktop'
 16689 	    defaultFilename:'C:\users\sr\desktop'
 16690             owningTopView:nil
 16690 	    owningTopView:nil
 16691             filter:
 16691 	    filter:
 16692                 'expecco Testsuite', null, '*.ets', null, 
 16692 		'expecco Testsuite', null, '*.ets', null,
 16693                 'expecco Logfile', null, '*.elf', null, 
 16693 		'expecco Logfile', null, '*.elf', null,
 16694                 'All', null, '*.*', null, 
 16694 		'All', null, '*.*', null,
 16695                 null
 16695 		null
 16696             filterIndex:3
 16696 	    filterIndex:3
 16697             doSave:false.            
 16697 	    doSave:false.
 16698 
 16698 
 16699     ########### example2 without owning view and termination ##########
 16699     ########### example2 without owning view and termination ##########
 16700 
 16700 
 16701         |null p|
 16701 	|null p|
 16702 
 16702 
 16703         null := (Character codePoint:0) asString.    
 16703 	null := (Character codePoint:0) asString.
 16704 
 16704 
 16705         p := 
 16705 	p :=
 16706             [
 16706 	    [
 16707                 Display 
 16707 		Display
 16708                     nativeFileDialogWithTitle:'Hello World' 
 16708 		    nativeFileDialogWithTitle:'Hello World'
 16709                     defaultFilename:'D:\sadasdsad'   
 16709 		    defaultFilename:'D:\sadasdsad'
 16710                     owningTopView:nil
 16710 		    owningTopView:nil
 16711                     filter:
 16711 		    filter:
 16712                         'expecco Testsuite', null, '*.ets', null, 
 16712 			'expecco Testsuite', null, '*.ets', null,
 16713                         'expecco Logfile', null, '*.elf', null, 
 16713 			'expecco Logfile', null, '*.elf', null,
 16714                         null
 16714 			null
 16715                     filterIndex:2
 16715 		    filterIndex:2
 16716                     doSave:false.    
 16716 		    doSave:false.
 16717             ] fork.
 16717 	    ] fork.
 16718 
 16718 
 16719         Delay waitForSeconds:5. 
 16719 	Delay waitForSeconds:5.
 16720 
 16720 
 16721         p terminate.          
 16721 	p terminate.
 16722 
 16722 
 16723     ########### example3 with owning view (makes the launcher modal) ##########
 16723     ########### example3 with owning view (makes the launcher modal) ##########
 16724 
 16724 
 16725         |owningTopView|
 16725 	|owningTopView|
 16726 
 16726 
 16727         owningTopView := NewLauncher open window topView.
 16727 	owningTopView := NewLauncher open window topView.
 16728         Delay waitForSeconds:1. 
 16728 	Delay waitForSeconds:1.
 16729 
 16729 
 16730         Display 
 16730 	Display
 16731             nativeFileDialogWithTitle:'Hello World' 
 16731 	    nativeFileDialogWithTitle:'Hello World'
 16732             defaultFilename:'D:\sadasdsad'   
 16732 	    defaultFilename:'D:\sadasdsad'
 16733             owningTopView:owningTopView
 16733 	    owningTopView:owningTopView
 16734             filter:#(
 16734 	    filter:#(
 16735                         #('expecco Testsuite' '*.ets') 
 16735 			#('expecco Testsuite' '*.ets')
 16736                         #('expecco Logfile' '*.elf') 
 16736 			#('expecco Logfile' '*.elf')
 16737                     )            
 16737 		    )
 16738             filterIndex:2
 16738 	    filterIndex:2
 16739             doSave:false.     
 16739 	    doSave:false.
 16740 
 16740 
 16741     ########### example4 with owning view (makes the launcher modal) and termination ##########
 16741     ########### example4 with owning view (makes the launcher modal) and termination ##########
 16742 
 16742 
 16743         |owningTopView p|
 16743 	|owningTopView p|
 16744 
 16744 
 16745         owningTopView := NewLauncher open window topView.
 16745 	owningTopView := NewLauncher open window topView.
 16746         Delay waitForSeconds:1. 
 16746 	Delay waitForSeconds:1.
 16747 
 16747 
 16748         p := 
 16748 	p :=
 16749             [
 16749 	    [
 16750                 Display 
 16750 		Display
 16751                     nativeFileDialogWithTitle:'Hello World' 
 16751 		    nativeFileDialogWithTitle:'Hello World'
 16752                     defaultFilename:'D:\sadasdsad'   
 16752 		    defaultFilename:'D:\sadasdsad'
 16753                     owningTopView:owningTopView
 16753 		    owningTopView:owningTopView
 16754                     filter:#(
 16754 		    filter:#(
 16755                         #('expecco Testsuite' '*.ets') 
 16755 			#('expecco Testsuite' '*.ets')
 16756                         #('expecco Logfile' '*.elf') 
 16756 			#('expecco Logfile' '*.elf')
 16757                     )
 16757 		    )
 16758                     filterIndex:2
 16758 		    filterIndex:2
 16759                     doSave:false.    
 16759 		    doSave:false.
 16760             ] fork.
 16760 	    ] fork.
 16761 
 16761 
 16762         Delay waitForSeconds:5. 
 16762 	Delay waitForSeconds:5.
 16763 
 16763 
 16764         p terminate.                  
 16764 	p terminate.
 16765     "
 16765     "
 16766 
 16766 
 16767     "Created: / 23-10-2018 / 09:58:25 / sr"
 16767     "Created: / 23-10-2018 / 09:58:25 / sr"
 16768     "Modified (comment): / 23-10-2018 / 13:25:11 / sr"
 16768     "Modified (comment): / 23-10-2018 / 13:25:11 / sr"
 16769 !
 16769 !
 16773 
 16773 
 16774     "this method can cleanly close/destroy an open native file dialog.
 16774     "this method can cleanly close/destroy an open native file dialog.
 16775      this is called as an ensure, when the native file dialog process gets terminated
 16775      this is called as an ensure, when the native file dialog process gets terminated
 16776      this is required because windows does not cleanup the dialog by itself when its thread gets terminated"
 16776      this is required because windows does not cleanup the dialog by itself when its thread gets terminated"
 16777 
 16777 
 16778 %{  /* STACK: 100000 */ 
 16778 %{  /* STACK: 100000 */
 16779     if (__isExternalAddress(dataAddress)) {
 16779     if (__isExternalAddress(dataAddress)) {
 16780         fileDialogData *pFdd = __externalAddressVal(dataAddress);
 16780 	fileDialogData *pFdd = __externalAddressVal(dataAddress);
 16781         DWORD fileDialogThreadId = pFdd->fileDialogThreadId;
 16781 	DWORD fileDialogThreadId = pFdd->fileDialogThreadId;
 16782                 
 16782 
 16783         if (fileDialogThreadId != 0) {
 16783 	if (fileDialogThreadId != 0) {
 16784             EnumWindows(enumWindowsToFindAndDestroyFileDialogProc, fileDialogThreadId);
 16784 	    EnumWindows(enumWindowsToFindAndDestroyFileDialogProc, fileDialogThreadId);
 16785         }
 16785 	}
 16786         if (__isExternalAddress(threadHandleAddress)) {
 16786 	if (__isExternalAddress(threadHandleAddress)) {
 16787             HANDLE fileDialogThread = _HWNDVal(threadHandleAddress);
 16787 	    HANDLE fileDialogThread = _HWNDVal(threadHandleAddress);
 16788             TerminateThread(fileDialogThread, 0); 
 16788 	    TerminateThread(fileDialogThread, 0);
 16789             CloseHandle(fileDialogThread);
 16789 	    CloseHandle(fileDialogThread);
 16790         };  
 16790 	};
 16791 
 16791 
 16792         free(pFdd);
 16792 	free(pFdd);
 16793     }
 16793     }
 16794 %}.
 16794 %}.
 16795 
 16795 
 16796     "Created: / 22-10-2018 / 13:53:02 / sr"
 16796     "Created: / 22-10-2018 / 13:53:02 / sr"
 16797     "Modified: / 22-10-2018 / 15:07:54 / sr"
 16797     "Modified: / 22-10-2018 / 15:07:54 / sr"
 16802      returns an empty string if the file dialog was canceled
 16802      returns an empty string if the file dialog was canceled
 16803      returns the full path to the user selected file"
 16803      returns the full path to the user selected file"
 16804 
 16804 
 16805     |targetFileOrNil multiSelectValues|
 16805     |targetFileOrNil multiSelectValues|
 16806 
 16806 
 16807 %{  /* STACK: 100000 */ 
 16807 %{  /* STACK: 100000 */
 16808     if (__isExternalAddress(dataAddress)) {
 16808     if (__isExternalAddress(dataAddress)) {
 16809         fileDialogData *pFdd = __externalAddressVal(dataAddress);     
 16809 	fileDialogData *pFdd = __externalAddressVal(dataAddress);
 16810 
 16810 
 16811         if (pFdd->fileDialogDidReturn) {
 16811 	if (pFdd->fileDialogDidReturn) {
 16812             targetFileOrNil = __MKU16STRING(pFdd->filename);  
 16812 	    targetFileOrNil = __MKU16STRING(pFdd->filename);
 16813 
 16813 
 16814             if ((!pFdd->trueForSave) && pFdd->trueForMultiSelect) {
 16814 	    if ((!pFdd->trueForSave) && pFdd->trueForMultiSelect) {
 16815                 wchar_t buffer[1000 * MAX_PATH]; // big buffer to support multiselect
 16815 		wchar_t buffer[1000 * MAX_PATH]; // big buffer to support multiselect
 16816                 ZeroMemory(buffer, sizeof(buffer));
 16816 		int pos = wcslen(pFdd->filename);
 16817 
 16817 		BYTE *b = &pFdd->filename[pos + 1];
 16818                 int pos = wcslen(pFdd->filename); 
 16818 
 16819                 BYTE *b = &pFdd->filename[pos + 1];
 16819 		ZeroMemory(buffer, sizeof(buffer));
 16820                 if ((*b + *(b + 1)) != 0) {
 16820 		if ((*b + *(b + 1)) != 0) {
 16821                     multiSelectValues = __MKU16STRING(&pFdd->filename[pos + 1]);
 16821 		    multiSelectValues = __MKU16STRING(&pFdd->filename[pos + 1]);
 16822                 }
 16822 		}
 16823 
 16823 
 16824                 multiSelectValues = __MKU16STRING(buffer);
 16824 		multiSelectValues = __MKU16STRING(buffer);
 16825 
 16825 
 16826 /*
 16826 #if 0
 16827 
 16827 
 16828                 do {
 16828 		do {
 16829                     printf("pos: %d\n", pos);  
 16829 		    printf("pos: %d\n", pos);
 16830                     *b = &pFdd->filename[pos];  
 16830 		    *b = &pFdd->filename[pos];
 16831 
 16831 
 16832                     pos++;            
 16832 		    pos++;
 16833                 } while((*b + *(b + 1)) != 0);
 16833 		} while((*b + *(b + 1)) != 0);
 16834 
 16834 
 16835                 wprintf(L"bytes next char '%d'\n", *b + *(b + 1));   
 16835 		wprintf(L"bytes next char '%d'\n", *b + *(b + 1));
 16836                 if (*b + *(b + 1))
 16836 		if (*b + *(b + 1))
 16837 
 16837 
 16838 
 16838 
 16839 
 16839 
 16840                 wprintf(L"pos '%d'\n", pos);   
 16840 		wprintf(L"pos '%d'\n", pos);
 16841                 wchar_t buff[5];
 16841 		wchar_t buff[5];
 16842                 wcsncpy(buff, &pFdd->filename[pos], 1);  
 16842 		wcsncpy(buff, &pFdd->filename[pos], 1);
 16843                 wprintf(L"char '%ls'\n", buff);  
 16843 		wprintf(L"char '%ls'\n", buff);
 16844                 BYTE *b;
 16844 		BYTE *b;
 16845                 b = &pFdd->filename[pos];
 16845 		b = &pFdd->filename[pos];
 16846                 wprintf(L"char byte1 '%d'\n", *b);  
 16846 		wprintf(L"char byte1 '%d'\n", *b);
 16847                 wprintf(L"char byte2 '%d'\n", *(b + 1));  */
 16847 		wprintf(L"char byte2 '%d'\n", *(b + 1));
 16848             }
 16848 #endif
 16849 
 16849 	    }
 16850             free(pFdd);
 16850 
 16851         }
 16851 	    free(pFdd);
       
 16852 	}
 16852     }
 16853     }
 16853 %}.
 16854 %}.
 16854 
 16855 
 16855     ^ targetFileOrNil
 16856     ^ targetFileOrNil
 16856 "/    targetFileOrNil isNil ifTrue:[
 16857 "/    targetFileOrNil isNil ifTrue:[
 16876 
 16877 
 16877     "do not call this directly, use #nativeFileDialogWithTitle:..."
 16878     "do not call this directly, use #nativeFileDialogWithTitle:..."
 16878 
 16879 
 16879     |fileDialogDataAddress fileDialogThreadHandle|
 16880     |fileDialogDataAddress fileDialogThreadHandle|
 16880 
 16881 
 16881 %{  /* STACK: 100000 */ 
 16882 %{  /* STACK: 100000 */
 16882     int i;
 16883     int i;
 16883     fileDialogData *pFdd = malloc(sizeof(fileDialogData));
 16884     fileDialogData *pFdd = malloc(sizeof(fileDialogData));
 16884     ZeroMemory(pFdd, sizeof(fileDialogData)); 
 16885     ZeroMemory(pFdd, sizeof(fileDialogData));
 16885 
 16886 
 16886     if (__isUnicode16String(defaultBaseName)) {
 16887     if (__isUnicode16String(defaultBaseName)) {
 16887         for (i = 0; i < __unicode16StringSize(defaultBaseName); i++) {
 16888 	for (i = 0; i < __unicode16StringSize(defaultBaseName); i++) {
 16888             pFdd->filename[i] = __unicode16StringVal(defaultBaseName)[i];
 16889 	    pFdd->filename[i] = __unicode16StringVal(defaultBaseName)[i];
 16889         }
 16890 	}
 16890         pFdd->filename[i] = 0;
 16891 	pFdd->filename[i] = 0;
 16891     };       
 16892     };
 16892     if (__isUnicode16String(defaultDirectory)) {
 16893     if (__isUnicode16String(defaultDirectory)) {
 16893         for (i = 0; i < __unicode16StringSize(defaultDirectory); i++) {
 16894 	for (i = 0; i < __unicode16StringSize(defaultDirectory); i++) {
 16894             pFdd->directory[i] = __unicode16StringVal(defaultDirectory)[i];
 16895 	    pFdd->directory[i] = __unicode16StringVal(defaultDirectory)[i];
 16895         }
 16896 	}
 16896         pFdd->directory[i] = 0;
 16897 	pFdd->directory[i] = 0;
 16897     };      
 16898     };
 16898     if (__isUnicode16String(dialogTitle)) {
 16899     if (__isUnicode16String(dialogTitle)) {
 16899         for (i = 0; i < __unicode16StringSize(dialogTitle); i++) {
 16900 	for (i = 0; i < __unicode16StringSize(dialogTitle); i++) {
 16900             pFdd->title[i] = __unicode16StringVal(dialogTitle)[i];
 16901 	    pFdd->title[i] = __unicode16StringVal(dialogTitle)[i];
 16901         }
 16902 	}
 16902         pFdd->title[i] = 0;  
 16903 	pFdd->title[i] = 0;
 16903     };         
 16904     };
 16904     if (__isExternalAddress(owningViewId)) {
 16905     if (__isExternalAddress(owningViewId)) {
 16905         pFdd->owningWindow = _HWNDVal(owningViewId);
 16906 	pFdd->owningWindow = _HWNDVal(owningViewId);
 16906     };  
 16907     };
 16907     if (__isUnicode16String(filterString)) {
 16908     if (__isUnicode16String(filterString)) {
 16908         for (i = 0; i < __unicode16StringSize(filterString); i++) {
 16909 	for (i = 0; i < __unicode16StringSize(filterString); i++) {
 16909             pFdd->filter[i] = __unicode16StringVal(filterString)[i];
 16910 	    pFdd->filter[i] = __unicode16StringVal(filterString)[i];
 16910         }
 16911 	}
 16911         pFdd->filter[i] = 0;  
 16912 	pFdd->filter[i] = 0;
 16912     };   
 16913     };
 16913     if (__isInteger(filterIndexArg)) {
 16914     if (__isInteger(filterIndexArg)) {
 16914         pFdd->filterIndex = __intVal(filterIndexArg);
 16915 	pFdd->filterIndex = __intVal(filterIndexArg);
 16915     }
 16916     }
 16916     pFdd->trueForSave = doSave == true;
 16917     pFdd->trueForSave = doSave == true;
 16917     pFdd->trueForMultiSelect = allowMultiSelectArg == true;
 16918     pFdd->trueForMultiSelect = allowMultiSelectArg == true;
 16918     pFdd->fileDialogDidReturn = FALSE;
 16919     pFdd->fileDialogDidReturn = FALSE;
 16919 
 16920 
 16920     fileDialogDataAddress = __MKEXTERNALADDRESS(pFdd);   
 16921     fileDialogDataAddress = __MKEXTERNALADDRESS(pFdd);
 16921     fileDialogThreadHandle = __MKEXTERNALADDRESS(openFileDialogInNewThread(pFdd));
 16922     fileDialogThreadHandle = __MKEXTERNALADDRESS(openFileDialogInNewThread(pFdd));
 16922 %}.
 16923 %}.
 16923 
 16924 
 16924     ^ Array
 16925     ^ Array
 16925         with:fileDialogDataAddress
 16926 	with:fileDialogDataAddress
 16926         with:fileDialogThreadHandle
 16927 	with:fileDialogThreadHandle
 16927 
 16928 
 16928     "Created: / 23-10-2018 / 10:59:50 / sr"
 16929     "Created: / 23-10-2018 / 10:59:50 / sr"
 16929 ! !
 16930 ! !
 16930 
 16931 
 16931 !WinWorkstation methodsFor:'native widget support'!
 16932 !WinWorkstation methodsFor:'native widget support'!
 17037     int modifiers = 0;
 17038     int modifiers = 0;
 17038     int b1m = Button1Mask;
 17039     int b1m = Button1Mask;
 17039     int b3m = Button3Mask;
 17040     int b3m = Button3Mask;
 17040 
 17041 
 17041     if (GetSystemMetrics(SM_SWAPBUTTON)) {
 17042     if (GetSystemMetrics(SM_SWAPBUTTON)) {
 17042         b3m = Button1Mask;
 17043 	b3m = Button1Mask;
 17043         b1m = Button3Mask;
 17044 	b1m = Button3Mask;
 17044     }
 17045     }
 17045 
 17046 
 17046     if (GetAsyncKeyState(VK_LBUTTON) & 0x8000)
 17047     if (GetAsyncKeyState(VK_LBUTTON) & 0x8000)
 17047         modifiers |= b1m;
 17048 	modifiers |= b1m;
 17048     if (GetAsyncKeyState(VK_MBUTTON) & 0x8000)
 17049     if (GetAsyncKeyState(VK_MBUTTON) & 0x8000)
 17049         modifiers |= Button2Mask;
 17050 	modifiers |= Button2Mask;
 17050     if (GetAsyncKeyState(VK_RBUTTON) & 0x8000)
 17051     if (GetAsyncKeyState(VK_RBUTTON) & 0x8000)
 17051         modifiers |= b3m;
 17052 	modifiers |= b3m;
 17052 
 17053 
 17053     RETURN (__MKSMALLINT(modifiers));
 17054     RETURN (__MKSMALLINT(modifiers));
 17054 %}
 17055 %}
 17055 
 17056 
 17056     "
 17057     "
 17100 
 17101 
 17101 %{  /* NOCONTEXT */
 17102 %{  /* NOCONTEXT */
 17102     POINT p;
 17103     POINT p;
 17103 
 17104 
 17104     if (! GetCursorPos(&p)) {
 17105     if (! GetCursorPos(&p)) {
 17105         p.x = 0;
 17106 	p.x = 0;
 17106         p.y = 0;
 17107 	p.y = 0;
 17107     }
 17108     }
 17108     RETURN (__MKPOINT_INT(p.x, p.y));
 17109     RETURN (__MKPOINT_INT(p.x, p.y));
 17109 %}
 17110 %}
 17110 !
 17111 !
 17111 
 17112 
 17134 setPointerPosition:newPosition
 17135 setPointerPosition:newPosition
 17135     "change the pointer position in root-window coordinates."
 17136     "change the pointer position in root-window coordinates."
 17136 
 17137 
 17137 %{  /* NOCONTEXT */
 17138 %{  /* NOCONTEXT */
 17138     if (__isPoint(newPosition)) {
 17139     if (__isPoint(newPosition)) {
 17139         OBJ xpos, ypos;
 17140 	OBJ xpos, ypos;
 17140 
 17141 
 17141         xpos = __point_X(newPosition);
 17142 	xpos = __point_X(newPosition);
 17142         ypos = __point_Y(newPosition);
 17143 	ypos = __point_Y(newPosition);
 17143         if (__bothSmallInteger(xpos, ypos)) {
 17144 	if (__bothSmallInteger(xpos, ypos)) {
 17144             SetCursorPos(__intVal(xpos), __intVal(ypos));
 17145 	    SetCursorPos(__intVal(xpos), __intVal(ypos));
 17145         }
 17146 	}
 17146     }
 17147     }
 17147 %}
 17148 %}
 17148 !
 17149 !
 17149 
 17150 
 17150 setPointerPosition:newPosition in:aWindowId
 17151 setPointerPosition:newPosition in:aWindowId
 17178      in advance, since the Workstation is free to return whatever it thinks is a good padding."
 17179      in advance, since the Workstation is free to return whatever it thinks is a good padding."
 17179 
 17180 
 17180     |error bytesPerLine bitmapPad bitsPerPixel|
 17181     |error bytesPerLine bitmapPad bitsPerPixel|
 17181 
 17182 
 17182     ((w <= 0) or:[h <= 0]) ifTrue:[
 17183     ((w <= 0) or:[h <= 0]) ifTrue:[
 17183         ^ self primitiveFailed:'zero width or height'.
 17184 	^ self primitiveFailed:'zero width or height'.
 17184     ].
 17185     ].
 17185 
 17186 
 17186 %{
 17187 %{
 17187     int     height, width;
 17188     int     height, width;
 17188     unsigned int numBytes;
 17189     unsigned int numBytes;
 17190     HWND    hWnd;
 17191     HWND    hWnd;
 17191     HBITMAP hBitmap = 0;
 17192     HBITMAP hBitmap = 0;
 17192     HGDIOBJ hPrevious = 0;
 17193     HGDIOBJ hPrevious = 0;
 17193     HDC     bDC = 0;
 17194     HDC     bDC = 0;
 17194     struct {
 17195     struct {
 17195         BITMAPINFOHEADER bmiHeader;
 17196 	BITMAPINFOHEADER bmiHeader;
 17196         DWORD r;
 17197 	DWORD r;
 17197         DWORD g;
 17198 	DWORD g;
 17198         DWORD b;
 17199 	DWORD b;
 17199     } bitmap;
 17200     } bitmap;
 17200 
 17201 
 17201     if (! __isExternalAddress(aDrawableId)) {
 17202     if (! __isExternalAddress(aDrawableId)) {
 17202         error = __MKSTRING("externalAddress arg");
 17203 	error = __MKSTRING("externalAddress arg");
 17203         goto out;
 17204 	goto out;
 17204     }
 17205     }
 17205     if (! __bothSmallInteger(srcX, srcY)) {
 17206     if (! __bothSmallInteger(srcX, srcY)) {
 17206         error = __MKSTRING("x,y args");
 17207 	error = __MKSTRING("x,y args");
 17207         goto out;
 17208 	goto out;
 17208     }
 17209     }
 17209     if (! __bothSmallInteger(w, h)) {
 17210     if (! __bothSmallInteger(w, h)) {
 17210         error = __MKSTRING("w,h args");
 17211 	error = __MKSTRING("w,h args");
 17211         goto out;
 17212 	goto out;
 17212     }
 17213     }
 17213     if (! __isByteArray(imageBits)) {
 17214     if (! __isByteArray(imageBits)) {
 17214         error = __MKSTRING("imageBits arg");
 17215 	error = __MKSTRING("imageBits arg");
 17215         goto out;
 17216 	goto out;
 17216     }
 17217     }
 17217 
 17218 
 17218     {
 17219     {
 17219         hWnd = _HWNDVal( aDrawableId );
 17220 	hWnd = _HWNDVal( aDrawableId );
 17220         BMDPRINTF(("primGetBits %x\n",hWnd));
 17221 	BMDPRINTF(("primGetBits %x\n",hWnd));
 17221         if ( hWnd != 0 ) {
 17222 	if ( hWnd != 0 ) {
 17222             HDC wDC;
 17223 	    HDC wDC;
 17223             HANDLE prevBitmap;
 17224 	    HANDLE prevBitmap;
 17224             int widthRoundedUpToNextMultipleOf4 = ((width + 3 ) / 4) * 4;
 17225 	    int widthRoundedUpToNextMultipleOf4 = ((width + 3 ) / 4) * 4;
 17225             int widthUsed;
 17226 	    int widthUsed;
 17226 
 17227 
 17227             bDC = CreateCompatibleDC(__rootDC);
 17228 	    bDC = CreateCompatibleDC(__rootDC);
 17228 
 17229 
 17229             BMDPRINTF(("primGetBits srcX %d srcY %d w %d h %d\n",__intVal(srcX),__intVal(srcY),__intVal(w),__intVal(h)));
 17230 	    BMDPRINTF(("primGetBits srcX %d srcY %d w %d h %d\n",__intVal(srcX),__intVal(srcY),__intVal(w),__intVal(h)));
 17230             height =  __intVal(h);
 17231 	    height =  __intVal(h);
 17231             width  =  __intVal(w);
 17232 	    width  =  __intVal(w);
 17232 
 17233 
 17233             widthUsed = widthRoundedUpToNextMultipleOf4;
 17234 	    widthUsed = widthRoundedUpToNextMultipleOf4;
 17234             widthUsed = width;
 17235 	    widthUsed = width;
 17235 
 17236 
 17236             BMDPRINTF(("width %d height %d\n",width,height));
 17237 	    BMDPRINTF(("width %d height %d\n",width,height));
 17237             hBitmap = CreateCompatibleBitmap(__rootDC, widthUsed, height);
 17238 	    hBitmap = CreateCompatibleBitmap(__rootDC, widthUsed, height);
 17238             if (!hBitmap) {
 17239 	    if (!hBitmap) {
 17239                 error = __MKSTRING("CreateCompatibleBitmap failed");
 17240 		error = __MKSTRING("CreateCompatibleBitmap failed");
 17240                 goto out;
 17241 		goto out;
 17241             }
 17242 	    }
 17242             bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 17243 	    bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 17243             bitmap.bmiHeader.biPlanes = 1;
 17244 	    bitmap.bmiHeader.biPlanes = 1;
 17244 #ifdef ALWAYSTRUECOLOR
 17245 #ifdef ALWAYSTRUECOLOR
 17245             bitmap.bmiHeader.biCompression = BI_RGB;
 17246 	    bitmap.bmiHeader.biCompression = BI_RGB;
 17246             bytesPerRow = (((width*3) + 3 ) / 4) * 4;
 17247 	    bytesPerRow = (((width*3) + 3 ) / 4) * 4;
 17247 #else
 17248 #else
 17248             if (__depth == 24) {
 17249 	    if (__depth == 24) {
 17249                 bitmap.bmiHeader.biCompression = BI_RGB;
 17250 		bitmap.bmiHeader.biCompression = BI_RGB;
 17250                 bytesPerRow = (((width*3) + 3 ) / 4) * 4;
 17251 		bytesPerRow = (((width*3) + 3 ) / 4) * 4;
 17251             } else if (__depth == 16) {
 17252 	    } else if (__depth == 16) {
 17252 # if 0
 17253 # if 0
 17253                 bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 17254 		bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 17254                 bitmap.b = 0x001f;
 17255 		bitmap.b = 0x001f;
 17255                 bitmap.g = 0x07e0;
 17256 		bitmap.g = 0x07e0;
 17256                 bitmap.r = 0xf800;
 17257 		bitmap.r = 0xf800;
 17257                 bytesPerRow = (((width*2) + 1 ) / 4) * 4;
 17258 		bytesPerRow = (((width*2) + 1 ) / 4) * 4;
 17258 # else
 17259 # else
 17259                 bitmap.b = 0;
 17260 		bitmap.b = 0;
 17260                 bitmap.g = 0;
 17261 		bitmap.g = 0;
 17261                 bitmap.r = 0;
 17262 		bitmap.r = 0;
 17262                 bitmap.bmiHeader.biCompression = BI_RGB;
 17263 		bitmap.bmiHeader.biCompression = BI_RGB;
 17263                 bytesPerRow = (((width*3) + 3 ) / 4) * 4;
 17264 		bytesPerRow = (((width*3) + 3 ) / 4) * 4;
 17264 # endif
 17265 # endif
 17265             }
 17266 	    }
 17266 #endif /* ALWAYSTRUECOLOR */
 17267 #endif /* ALWAYSTRUECOLOR */
 17267             bitmap.bmiHeader.biSizeImage = 0;
 17268 	    bitmap.bmiHeader.biSizeImage = 0;
 17268             bitmap.bmiHeader.biXPelsPerMeter = 0;
 17269 	    bitmap.bmiHeader.biXPelsPerMeter = 0;
 17269             bitmap.bmiHeader.biYPelsPerMeter = 0;
 17270 	    bitmap.bmiHeader.biYPelsPerMeter = 0;
 17270             bitmap.bmiHeader.biClrUsed = 0;
 17271 	    bitmap.bmiHeader.biClrUsed = 0;
 17271             bitmap.bmiHeader.biClrImportant = 0;
 17272 	    bitmap.bmiHeader.biClrImportant = 0;
 17272             bitmap.bmiHeader.biBitCount = __depth;
 17273 	    bitmap.bmiHeader.biBitCount = __depth;
 17273 
 17274 
 17274             bitmap.bmiHeader.biWidth = widthUsed;
 17275 	    bitmap.bmiHeader.biWidth = widthUsed;
 17275             bitmap.bmiHeader.biHeight = -height;
 17276 	    bitmap.bmiHeader.biHeight = -height;
 17276 
 17277 
 17277             wDC = GetDC(hWnd);
 17278 	    wDC = GetDC(hWnd);
 17278 
 17279 
 17279             hPrevious = SelectObject(bDC, hBitmap);
 17280 	    hPrevious = SelectObject(bDC, hBitmap);
 17280             if (BitBlt(bDC,
 17281 	    if (BitBlt(bDC,
 17281                    0,0,
 17282 		   0,0,
 17282                    width,height,
 17283 		   width,height,
 17283                    wDC,
 17284 		   wDC,
 17284                    __intVal(srcX), __intVal(srcY),
 17285 		   __intVal(srcX), __intVal(srcY),
 17285                    SRCCOPY|CAPTUREBLT)
 17286 		   SRCCOPY|CAPTUREBLT)
 17286                  == 0
 17287 		 == 0
 17287                 )
 17288 		)
 17288             {
 17289 	    {
 17289                 INFOFPRINTF((stderr, "WinWorkstation [warning]: in primGetBitsFrom: BitBlt\n"));
 17290 		INFOFPRINTF((stderr, "WinWorkstation [warning]: in primGetBitsFrom: BitBlt\n"));
 17290             }
 17291 	    }
 17291 
 17292 
 17292 #ifdef CACHE_LAST_DC
 17293 #ifdef CACHE_LAST_DC
 17293             if (lastGcData && (lastGcData->_hDC == wDC)) {
 17294 	    if (lastGcData && (lastGcData->_hDC == wDC)) {
 17294 # ifdef DEBUG_DC_REUSE
 17295 # ifdef DEBUG_DC_REUSE
 17295                 console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - cachedDC reuse\n", __LINE__);
 17296 		console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - cachedDC reuse\n", __LINE__);
 17296 # endif
 17297 # endif
 17297             } else
 17298 	    } else
 17298 #endif
 17299 #endif
 17299             {
 17300 	    {
 17300 #ifdef CACHE_LAST_WM_PAINT_DC
 17301 #ifdef CACHE_LAST_WM_PAINT_DC
 17301                 if (last_wm_paint_dc && (last_wm_paint_dc == wDC)) {
 17302 		if (last_wm_paint_dc && (last_wm_paint_dc == wDC)) {
 17302 # ifdef DEBUG_DC_REUSE
 17303 # ifdef DEBUG_DC_REUSE
 17303                     console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - last_wm_paint_dc reuse\n", __LINE__);
 17304 		    console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - last_wm_paint_dc reuse\n", __LINE__);
 17304 # endif
 17305 # endif
 17305                 } else
 17306 		} else
 17306 #endif
 17307 #endif
 17307                 {
 17308 		{
 17308                     ReleaseDC(hWnd, wDC);
 17309 		    ReleaseDC(hWnd, wDC);
 17309                 }
 17310 		}
 17310             }
 17311 	    }
 17311 
 17312 
 17312             if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
 17313 	    if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
 17313             {
 17314 	    {
 17314                 error = __MKSTRING("noinfo returned in primGetBits");
 17315 		error = __MKSTRING("noinfo returned in primGetBits");
 17315                 goto out;
 17316 		goto out;
 17316             }
 17317 	    }
 17317             BMDPRINTF(("bitmap info:%d %d %d %d\n",
 17318 	    BMDPRINTF(("bitmap info:%d %d %d %d\n",
 17318                         bitmap.bmiHeader.biWidth, bitmap.bmiHeader.biHeight,
 17319 			bitmap.bmiHeader.biWidth, bitmap.bmiHeader.biHeight,
 17319                         bitmap.bmiHeader.biBitCount, bitmap.bmiHeader.biSizeImage));
 17320 			bitmap.bmiHeader.biBitCount, bitmap.bmiHeader.biSizeImage));
 17320             numBytes = bitmap.bmiHeader.biSizeImage;
 17321 	    numBytes = bitmap.bmiHeader.biSizeImage;
 17321             if ( numBytes != 0 ) {
 17322 	    if ( numBytes != 0 ) {
 17322                 if (numBytes > __byteArraySize(imageBits)) {
 17323 		if (numBytes > __byteArraySize(imageBits)) {
 17323                     /* imageBits too small */
 17324 		    /* imageBits too small */
 17324                     INFOFPRINTF((stderr, "WinWorkstation [warning]: primGetBits - byteArray too small (is:%d need:%d; w:%d h:%d)\n",
 17325 		    INFOFPRINTF((stderr, "WinWorkstation [warning]: primGetBits - byteArray too small (is:%d need:%d; w:%d h:%d)\n",
 17325                                 __byteArraySize(imageBits), numBytes,
 17326 				__byteArraySize(imageBits), numBytes,
 17326                                 bitmap.bmiHeader.biWidth, -bitmap.bmiHeader.biHeight
 17327 				bitmap.bmiHeader.biWidth, -bitmap.bmiHeader.biHeight
 17327                              ));
 17328 			     ));
 17328                     error = __MKSTRING("byteArray too small");
 17329 		    error = __MKSTRING("byteArray too small");
 17329                     goto out;
 17330 		    goto out;
 17330                 }
 17331 		}
 17331                 BMDPRINTF(("numBytes %d\n",numBytes));
 17332 		BMDPRINTF(("numBytes %d\n",numBytes));
 17332 
 17333 
 17333                 bitmap.bmiHeader.biHeight = -height;
 17334 		bitmap.bmiHeader.biHeight = -height;
 17334                 if (GetDIBits(bDC,hBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
 17335 		if (GetDIBits(bDC,hBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
 17335                 {
 17336 		{
 17336                     error = __MKSTRING("zero bits returned in primGetBits");
 17337 		    error = __MKSTRING("zero bits returned in primGetBits");
 17337                     goto out;
 17338 		    goto out;
 17338                 }
 17339 		}
 17339 
 17340 
 17340                 /* swap red and blue (windows delivers BGR) */
 17341 		/* swap red and blue (windows delivers BGR) */
 17341                 {
 17342 		{
 17342                     char *cp = __ByteArrayInstPtr(imageBits)->ba_element;
 17343 		    char *cp = __ByteArrayInstPtr(imageBits)->ba_element;
 17343                     int _h;
 17344 		    int _h;
 17344                     char *rowp = cp;
 17345 		    char *rowp = cp;
 17345 
 17346 
 17346                     for (_h=height; _h>0; _h--) {
 17347 		    for (_h=height; _h>0; _h--) {
 17347                         int _w;
 17348 			int _w;
 17348                         char *pixel = rowp;
 17349 			char *pixel = rowp;
 17349 
 17350 
 17350                         for (_w=width; _w>0; _w--) {
 17351 			for (_w=width; _w>0; _w--) {
 17351                             char b;
 17352 			    char b;
 17352 
 17353 
 17353                             b = pixel[0];
 17354 			    b = pixel[0];
 17354                             pixel[0] = pixel[2];
 17355 			    pixel[0] = pixel[2];
 17355                             pixel[2] = b;
 17356 			    pixel[2] = b;
 17356                             pixel += 3;
 17357 			    pixel += 3;
 17357                         };
 17358 			};
 17358                         rowp += bytesPerRow;
 17359 			rowp += bytesPerRow;
 17359                     };
 17360 		    };
 17360                 }
 17361 		}
 17361             } else {
 17362 	    } else {
 17362                 error = __MKSTRING("unacceptable bitmap in primGetBits");
 17363 		error = __MKSTRING("unacceptable bitmap in primGetBits");
 17363                 goto out;
 17364 		goto out;
 17364             }
 17365 	    }
 17365         } else {
 17366 	} else {
 17366             error = __MKSTRING("unacceptable HWND in primGetBits");
 17367 	    error = __MKSTRING("unacceptable HWND in primGetBits");
 17367             goto out;
 17368 	    goto out;
 17368         }
 17369 	}
 17369 
 17370 
 17370         bytesPerLine = __MKSMALLINT(bytesPerRow);
 17371 	bytesPerLine = __MKSMALLINT(bytesPerRow);
 17371         bitmapPad = __MKSMALLINT(WIN32PADDING);
 17372 	bitmapPad = __MKSMALLINT(WIN32PADDING);
 17372         bitsPerPixel = __MKSMALLINT(bitmap.bmiHeader.biBitCount);
 17373 	bitsPerPixel = __MKSMALLINT(bitmap.bmiHeader.biBitCount);
 17373     }
 17374     }
 17374 
 17375 
 17375 out:
 17376 out:
 17376     if ((hPrevious != NULL) && (bDC != NULL))
 17377     if ((hPrevious != NULL) && (bDC != NULL))
 17377         SelectObject(bDC, hPrevious);
 17378 	SelectObject(bDC, hPrevious);
 17378     if (bDC)
 17379     if (bDC)
 17379         DeleteDC(bDC);
 17380 	DeleteDC(bDC);
 17380     if (hBitmap)
 17381     if (hBitmap)
 17381         _DeleteObject(hBitmap, __LINE__);
 17382 	_DeleteObject(hBitmap, __LINE__);
 17382 %}.
 17383 %}.
 17383 
 17384 
 17384     error notNil ifTrue:[
 17385     error notNil ifTrue:[
 17385         ^ self primitiveFailed:error.
 17386 	^ self primitiveFailed:error.
 17386     ].
 17387     ].
 17387 
 17388 
 17388 
 17389 
 17389     ^ IdentityDictionary new
 17390     ^ IdentityDictionary new
 17390             at:#bitOrder put:#msbFirst;
 17391 	    at:#bitOrder put:#msbFirst;
 17391             at:#depth put:1;
 17392 	    at:#depth put:1;
 17392             at:#bytesPerLine put:bytesPerLine;
 17393 	    at:#bytesPerLine put:bytesPerLine;
 17393             at:#byteOrder put:#lsbFirst;
 17394 	    at:#byteOrder put:#lsbFirst;
 17394             at:#format put:#XYPixmap;
 17395 	    at:#format put:#XYPixmap;
 17395             at:#bitmapUnit put:0;
 17396 	    at:#bitmapUnit put:0;
 17396             at:#bitmapPad put:bitmapPad;
 17397 	    at:#bitmapPad put:bitmapPad;
 17397             at:#bitsPerPixel put:bitsPerPixel;
 17398 	    at:#bitsPerPixel put:bitsPerPixel;
 17398             at:#redMask put:16rFF0000;
 17399 	    at:#redMask put:16rFF0000;
 17399             at:#greenMask put:16r00FF00;
 17400 	    at:#greenMask put:16r00FF00;
 17400             at:#blueMask put:16r0000FF;
 17401 	    at:#blueMask put:16r0000FF;
 17401             yourself.
 17402 	    yourself.
 17402 
 17403 
 17403     "Modified (comment): / 28-03-2017 / 14:28:39 / stefan"
 17404     "Modified (comment): / 28-03-2017 / 14:28:39 / stefan"
 17404 !
 17405 !
 17405 
 17406 
 17406 getBitsFromPixmapId:aDrawableId x:srcX y:srcY width:w height:h into:imageBits
 17407 getBitsFromPixmapId:aDrawableId x:srcX y:srcY width:w height:h into:imageBits
 17411      in advance, since the Workstation is free to return whatever it thinks is a good padding."
 17412      in advance, since the Workstation is free to return whatever it thinks is a good padding."
 17412 
 17413 
 17413     |rawInfo error bytesPerLine format bitmapPad bitsPerPixel|
 17414     |rawInfo error bytesPerLine format bitmapPad bitsPerPixel|
 17414 
 17415 
 17415     ((w <= 0) or:[h <= 0]) ifTrue:[
 17416     ((w <= 0) or:[h <= 0]) ifTrue:[
 17416         self primitiveFailed:'zero width or height'.
 17417 	self primitiveFailed:'zero width or height'.
 17417         ^ nil
 17418 	^ nil
 17418     ].
 17419     ].
 17419 
 17420 
 17420     rawInfo := Array new:11.
 17421     rawInfo := Array new:11.
 17421 
 17422 
 17422 %{
 17423 %{
 17427     HBITMAP hBitmap = 0;
 17428     HBITMAP hBitmap = 0;
 17428     HDC bDC = 0;
 17429     HDC bDC = 0;
 17429     HDC xDC = 0;
 17430     HDC xDC = 0;
 17430     struct
 17431     struct
 17431     {
 17432     {
 17432         BITMAPINFOHEADER bmiHeader;
 17433 	BITMAPINFOHEADER bmiHeader;
 17433         DWORD rgb[2];
 17434 	DWORD rgb[2];
 17434     } bitmap;
 17435     } bitmap;
 17435     BITMAP bitmapInfo;
 17436     BITMAP bitmapInfo;
 17436 
 17437 
 17437     if (__isExternalAddress(aDrawableId)
 17438     if (__isExternalAddress(aDrawableId)
 17438      && __bothSmallInteger(srcX, srcY)
 17439      && __bothSmallInteger(srcX, srcY)
 17439      && __bothSmallInteger(w, h)
 17440      && __bothSmallInteger(w, h)
 17440      && __isArray(rawInfo) && __arraySize(rawInfo) >= 11
 17441      && __isArray(rawInfo) && __arraySize(rawInfo) >= 11
 17441      && __isByteArray(imageBits))
 17442      && __isByteArray(imageBits))
 17442     {
 17443     {
 17443         xBitmap = _HBITMAPVAL( aDrawableId );
 17444 	xBitmap = _HBITMAPVAL( aDrawableId );
 17444         BMDPRINTF(("primGetBitsFromPixmap %x\n",xBitmap));
 17445 	BMDPRINTF(("primGetBitsFromPixmap %x\n",xBitmap));
 17445         if (xBitmap != 0) {
 17446 	if (xBitmap != 0) {
 17446             xDC = GetDC(0);
 17447 	    xDC = GetDC(0);
 17447             SelectObject(xDC, xBitmap);
 17448 	    SelectObject(xDC, xBitmap);
 17448             GetObject(xBitmap,sizeof(bitmapInfo),&bitmapInfo);
 17449 	    GetObject(xBitmap,sizeof(bitmapInfo),&bitmapInfo);
 17449 
 17450 
 17450             bDC = CreateCompatibleDC(__rootDC);
 17451 	    bDC = CreateCompatibleDC(__rootDC);
 17451             BMDPRINTF(("srcX %d srcY %d w %d h %d\n",__intVal(srcX),__intVal(srcY),__intVal(w),__intVal(h)));
 17452 	    BMDPRINTF(("srcX %d srcY %d w %d h %d\n",__intVal(srcX),__intVal(srcY),__intVal(w),__intVal(h)));
 17452             height =  __intVal(h);
 17453 	    height =  __intVal(h);
 17453             width  =  __intVal(w);
 17454 	    width  =  __intVal(w);
 17454             BMDPRINTF(("width %d height %d\n",width,height));
 17455 	    BMDPRINTF(("width %d height %d\n",width,height));
 17455 
 17456 
 17456             hBitmap = CreateCompatibleBitmap(xDC, width, height);
 17457 	    hBitmap = CreateCompatibleBitmap(xDC, width, height);
 17457             if (!hBitmap) {
 17458 	    if (!hBitmap) {
 17458                 error = __MKSTRING("create bitmap failed");
 17459 		error = __MKSTRING("create bitmap failed");
 17459                 goto out;
 17460 		goto out;
 17460             }
 17461 	    }
 17461 
 17462 
 17462             SelectObject(bDC,hBitmap);
 17463 	    SelectObject(bDC,hBitmap);
 17463             if (BitBlt(bDC,
 17464 	    if (BitBlt(bDC,
 17464                    0,0,
 17465 		   0,0,
 17465                    width,height,
 17466 		   width,height,
 17466                    xDC,
 17467 		   xDC,
 17467                    __intVal(srcX), __intVal(srcY),
 17468 		   __intVal(srcX), __intVal(srcY),
 17468                    SRCCOPY)
 17469 		   SRCCOPY)
 17469                  == 0
 17470 		 == 0
 17470                 )
 17471 		)
 17471             {
 17472 	    {
 17472                 error = __MKSTRING("BitBlt failed");
 17473 		error = __MKSTRING("BitBlt failed");
 17473                 goto out;
 17474 		goto out;
 17474             }
 17475 	    }
 17475             bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 17476 	    bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 17476             bitmap.bmiHeader.biPlanes = 1;
 17477 	    bitmap.bmiHeader.biPlanes = 1;
 17477 #ifdef ALWAYSTRUECOLOR
 17478 #ifdef ALWAYSTRUECOLOR
 17478             bitmap.bmiHeader.biCompression = BI_RGB;
 17479 	    bitmap.bmiHeader.biCompression = BI_RGB;
 17479 #else
 17480 #else
 17480             if (__depth == 24) {
 17481 	    if (__depth == 24) {
 17481                 /*bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 17482 		/*bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 17482                 bitmap.r = 0xff0000;
 17483 		bitmap.r = 0xff0000;
 17483                 bitmap.g = 0x00ff00;
 17484 		bitmap.g = 0x00ff00;
 17484                 bitmap.b = 0x0000ff;*/
 17485 		bitmap.b = 0x0000ff;*/
 17485                 bitmap.bmiHeader.biCompression = BI_RGB;
 17486 		bitmap.bmiHeader.biCompression = BI_RGB;
 17486             } else if (__depth == 16) {
 17487 	    } else if (__depth == 16) {
 17487                 bitmap.b = 0x001f;
 17488 		bitmap.b = 0x001f;
 17488                 bitmap.g = 0x07e0;
 17489 		bitmap.g = 0x07e0;
 17489                 bitmap.r = 0xf800;*/
 17490 		bitmap.r = 0xf800;*/
 17490                 bitmap.bmiHeader.biCompression = BI_RGB;
 17491 		bitmap.bmiHeader.biCompression = BI_RGB;
 17491             } else {
 17492 	    } else {
 17492                 error = __MKSTRING("primGetBitsFromPixmap: unsupported depth");
 17493 		error = __MKSTRING("primGetBitsFromPixmap: unsupported depth");
 17493                 got fail;
 17494 		got fail;
 17494             }
 17495 	    }
 17495 #endif /* ALWAYSTRUECOLOR */
 17496 #endif /* ALWAYSTRUECOLOR */
 17496             bitmap.bmiHeader.biSizeImage = 0;
 17497 	    bitmap.bmiHeader.biSizeImage = 0;
 17497             bitmap.bmiHeader.biXPelsPerMeter = 0;
 17498 	    bitmap.bmiHeader.biXPelsPerMeter = 0;
 17498             bitmap.bmiHeader.biYPelsPerMeter = 0;
 17499 	    bitmap.bmiHeader.biYPelsPerMeter = 0;
 17499             bitmap.bmiHeader.biClrUsed = 0;
 17500 	    bitmap.bmiHeader.biClrUsed = 0;
 17500             bitmap.bmiHeader.biClrImportant = 0;
 17501 	    bitmap.bmiHeader.biClrImportant = 0;
 17501 
 17502 
 17502             bitmap.bmiHeader.biWidth = width;
 17503 	    bitmap.bmiHeader.biWidth = width;
 17503             bitmap.bmiHeader.biHeight = -height;
 17504 	    bitmap.bmiHeader.biHeight = -height;
 17504             bitmap.bmiHeader.biBitCount = bitmapInfo.bmBitsPixel;
 17505 	    bitmap.bmiHeader.biBitCount = bitmapInfo.bmBitsPixel;
 17505 
 17506 
 17506             if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
 17507 	    if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
 17507             {
 17508 	    {
 17508                 error = __MKSTRING("GetDIBits failed");
 17509 		error = __MKSTRING("GetDIBits failed");
 17509                 goto out;
 17510 		goto out;
 17510             }
 17511 	    }
 17511             BMDPRINTF(("bitmap info:%d %d %d %d\n",bitmap.bmiHeader.biWidth,bitmap.bmiHeader.biHeight,bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biSizeImage));
 17512 	    BMDPRINTF(("bitmap info:%d %d %d %d\n",bitmap.bmiHeader.biWidth,bitmap.bmiHeader.biHeight,bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biSizeImage));
 17512             numBytes = bitmap.bmiHeader.biSizeImage;
 17513 	    numBytes = bitmap.bmiHeader.biSizeImage;
 17513             if ( numBytes != 0 ) {
 17514 	    if ( numBytes != 0 ) {
 17514                 if (numBytes > __byteArraySize(imageBits)) {
 17515 		if (numBytes > __byteArraySize(imageBits)) {
 17515                     /* imageBits too small */
 17516 		    /* imageBits too small */
 17516                     error = __MKSTRING("provided byteArray too small");
 17517 		    error = __MKSTRING("provided byteArray too small");
 17517                     goto out;
 17518 		    goto out;
 17518                 }
 17519 		}
 17519                 BMDPRINTF(("numBytes %d\n",numBytes));
 17520 		BMDPRINTF(("numBytes %d\n",numBytes));
 17520 
 17521 
 17521                 bitmap.bmiHeader.biHeight = -height;
 17522 		bitmap.bmiHeader.biHeight = -height;
 17522                 bitmap.bmiHeader.biBitCount = bitmapInfo.bmBitsPixel; /*__depth;*/
 17523 		bitmap.bmiHeader.biBitCount = bitmapInfo.bmBitsPixel; /*__depth;*/
 17523                 bitmap.rgb[0] = 0;
 17524 		bitmap.rgb[0] = 0;
 17524                 bitmap.rgb[1] = 0xffffff;
 17525 		bitmap.rgb[1] = 0xffffff;
 17525                 if (GetDIBits(xDC,xBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
 17526 		if (GetDIBits(xDC,xBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
 17526                 {
 17527 		{
 17527                     BMDPRINTF(("zero bits returned\n"));
 17528 		    BMDPRINTF(("zero bits returned\n"));
 17528                     error = __MKSTRING("zero bits returned");
 17529 		    error = __MKSTRING("zero bits returned");
 17529                     goto out;
 17530 		    goto out;
 17530                 }
 17531 		}
 17531 
 17532 
 17532 #if 0
 17533 #if 0
 17533                 {
 17534 		{
 17534                     /* swap red and blue (windows delivers BGR) */
 17535 		    /* swap red and blue (windows delivers BGR) */
 17535                     char *cp = __ByteArrayInstPtr(imageBits)->ba_element;
 17536 		    char *cp = __ByteArrayInstPtr(imageBits)->ba_element;
 17536                     int n = numBytes;
 17537 		    int n = numBytes;
 17537 
 17538 
 17538                     for ( ;n > 0; n -= 3, cp += 3) {
 17539 		    for ( ;n > 0; n -= 3, cp += 3) {
 17539                           char b = cp[0];
 17540 			  char b = cp[0];
 17540                           cp[0] = cp[2];
 17541 			  cp[0] = cp[2];
 17541                           cp[2] = b;
 17542 			  cp[2] = b;
 17542                     }
 17543 		    }
 17543                 }
 17544 		}
 17544 #endif
 17545 #endif
 17545             } else {
 17546 	    } else {
 17546                 error = __MKSTRING("unacceptable bitmap (size is 0 bytes)");
 17547 		error = __MKSTRING("unacceptable bitmap (size is 0 bytes)");
 17547                 goto out;
 17548 		goto out;
 17548             }
 17549 	    }
 17549         } else {
 17550 	} else {
 17550             error = __MKSTRING("unacceptable bitmap (null xBitmap)");
 17551 	    error = __MKSTRING("unacceptable bitmap (null xBitmap)");
 17551             goto out;
 17552 	    goto out;
 17552         }
 17553 	}
 17553         bytesPerLine = __MKSMALLINT(numBytes/height);
 17554 	bytesPerLine = __MKSMALLINT(numBytes/height);
 17554         format = (bitmap.bmiHeader.biBitCount == 1) ? @symbol(ZPixmap) : @symbol(XYPixmap);
 17555 	format = (bitmap.bmiHeader.biBitCount == 1) ? @symbol(ZPixmap) : @symbol(XYPixmap);
 17555         bitmapPad = __MKSMALLINT(WIN32PADDING);
 17556 	bitmapPad = __MKSMALLINT(WIN32PADDING);
 17556         bitsPerPixel = __MKSMALLINT(bitmap.bmiHeader.biBitCount);
 17557 	bitsPerPixel = __MKSMALLINT(bitmap.bmiHeader.biBitCount);
 17557     }
 17558     }
 17558 out:
 17559 out:
 17559     if (bDC)
 17560     if (bDC)
 17560         DeleteDC(bDC);
 17561 	DeleteDC(bDC);
 17561     if (xDC)
 17562     if (xDC)
 17562         ReleaseDC(0, xDC); //DeleteDC(xDC);
 17563 	ReleaseDC(0, xDC); //DeleteDC(xDC);
 17563     if (hBitmap)
 17564     if (hBitmap)
 17564         DeleteObject(hBitmap);
 17565 	DeleteObject(hBitmap);
 17565 %}.
 17566 %}.
 17566 
 17567 
 17567     error notNil ifTrue:[
 17568     error notNil ifTrue:[
 17568         self primitiveFailed:error.
 17569 	self primitiveFailed:error.
 17569     ].
 17570     ].
 17570 
 17571 
 17571     ^ IdentityDictionary new
 17572     ^ IdentityDictionary new
 17572             at:#bitOrder put:#msbFirst;
 17573 	    at:#bitOrder put:#msbFirst;
 17573             at:#depth put:1;
 17574 	    at:#depth put:1;
 17574             at:#bytesPerLine put:bytesPerLine;
 17575 	    at:#bytesPerLine put:bytesPerLine;
 17575             at:#byteOrder put:#lsbFirst;
 17576 	    at:#byteOrder put:#lsbFirst;
 17576             at:#format put:format;
 17577 	    at:#format put:format;
 17577             at:#bitmapUnit put:0;
 17578 	    at:#bitmapUnit put:0;
 17578             at:#bitmapPad put:bitmapPad;
 17579 	    at:#bitmapPad put:bitmapPad;
 17579             at:#bitsPerPixel put:bitsPerPixel;
 17580 	    at:#bitsPerPixel put:bitsPerPixel;
 17580             at:#redMask put:16rFF0000;
 17581 	    at:#redMask put:16rFF0000;
 17581             at:#greenMask put:16r00FF00;
 17582 	    at:#greenMask put:16r00FF00;
 17582             at:#blueMask put:16r0000FF;
 17583 	    at:#blueMask put:16r0000FF;
 17583             yourself.
 17584 	    yourself.
 17584 
 17585 
 17585     "Modified (comment): / 28-03-2017 / 14:28:46 / stefan"
 17586     "Modified (comment): / 28-03-2017 / 14:28:46 / stefan"
 17586 !
 17587 !
 17587 
 17588 
 17588 getPixelX:px y:py from:ignoredDrawableId with:aGCId
 17589 getPixelX:px y:py from:ignoredDrawableId with:aGCId
 17590      Nil is returned for invalid coordinates or if any other problem arises."
 17591      Nil is returned for invalid coordinates or if any other problem arises."
 17591 
 17592 
 17592 %{  /* NOCONTEXT */
 17593 %{  /* NOCONTEXT */
 17593     if (__isExternalAddress(aGCId)
 17594     if (__isExternalAddress(aGCId)
 17594      && __bothSmallInteger(px, py)) {
 17595      && __bothSmallInteger(px, py)) {
 17595         struct gcData *gcData = _GCDATA(aGCId);
 17596 	struct gcData *gcData = _GCDATA(aGCId);
 17596         HDC hDC;
 17597 	HDC hDC;
 17597         int __x = __intVal(px), __y = __intVal(py);
 17598 	int __x = __intVal(px), __y = __intVal(py);
 17598         int pixel;
 17599 	int pixel;
 17599 
 17600 
 17600         hDC = _getDC(gcData);
 17601 	hDC = _getDC(gcData);
 17601         pixel = GetPixel(hDC, __x, __y);
 17602 	pixel = GetPixel(hDC, __x, __y);
 17602 #ifndef CACHE_LAST_DC
 17603 #ifndef CACHE_LAST_DC
 17603         _releaseDC(gcData);
 17604 	_releaseDC(gcData);
 17604 #endif
 17605 #endif
 17605         /*
 17606 	/*
 17606          * for compatibility, returns the pixelValue
 17607 	 * for compatibility, returns the pixelValue
 17607          * from a monochrome bitmap
 17608 	 * from a monochrome bitmap
 17608          */
 17609 	 */
 17609         if (gcData->hBitmap) {
 17610 	if (gcData->hBitmap) {
 17610             if (gcData->bitmapColorBitCount == 1) {
 17611 	    if (gcData->bitmapColorBitCount == 1) {
 17611                 pixel = (pixel == 0) ? 0 : 1;
 17612 		pixel = (pixel == 0) ? 0 : 1;
 17612             }
 17613 	    }
 17613         }
 17614 	}
 17614 
 17615 
 17615         RETURN ( __MKSMALLINT(pixel & 0xFFFFFF) );
 17616 	RETURN ( __MKSMALLINT(pixel & 0xFFFFFF) );
 17616     }
 17617     }
 17617 %}.
 17618 %}.
 17618     ^ nil
 17619     ^ nil
 17619 ! !
 17620 ! !
 17620 
 17621 
 17636 "/    aKey == #lightColor ifTrue:[
 17637 "/    aKey == #lightColor ifTrue:[
 17637 "/        ^ Color white
 17638 "/        ^ Color white
 17638 "/    ].
 17639 "/    ].
 17639 
 17640 
 17640     aKey == #viewBackgroundColor ifTrue:[
 17641     aKey == #viewBackgroundColor ifTrue:[
 17641         clr := self getSystemColor:#COLOR_WINDOW.
 17642 	clr := self getSystemColor:#COLOR_WINDOW.
 17642     ].
 17643     ].
 17643     aKey == #textForegroundColor ifTrue:[
 17644     aKey == #textForegroundColor ifTrue:[
 17644         clr := self getSystemColor:#COLOR_WINDOWTEXT
 17645 	clr := self getSystemColor:#COLOR_WINDOWTEXT
 17645     ].
 17646     ].
 17646 
 17647 
 17647 
 17648 
 17648 "/    aKey == #scrollerViewBackgroundColor ifTrue:[
 17649 "/    aKey == #scrollerViewBackgroundColor ifTrue:[
 17649 "/        ^ Color white
 17650 "/        ^ Color white
 17658 ! !
 17659 ! !
 17659 
 17660 
 17660 !WinWorkstation methodsFor:'tray access'!
 17661 !WinWorkstation methodsFor:'tray access'!
 17661 
 17662 
 17662 addTrayIconFor:aView
 17663 addTrayIconFor:aView
 17663         icon:wicon iconMask:wiconMaskArg
 17664 	icon:wicon iconMask:wiconMaskArg
 17664         toolTipMessage:toolTipMessageArg
 17665 	toolTipMessage:toolTipMessageArg
 17665 
 17666 
 17666     "add an icon to the tray for aView (which will receive tray-events in the future.
 17667     "add an icon to the tray for aView (which will receive tray-events in the future.
 17667      The icon, mask and toolTopText are optional.
 17668      The icon, mask and toolTopText are optional.
 17668      Windows places a limit of 63 characters to the tooltip - so dont be to chatty here..."
 17669      Windows places a limit of 63 characters to the tooltip - so dont be to chatty here..."
 17669 
 17670 
 17670     |windowId wiconId wiconMask invertedWiconMask wiconMaskId
 17671     |windowId wiconId wiconMask invertedWiconMask wiconMaskId
 17671      wiconWidth wiconHeight toolTipMessage|
 17672      wiconWidth wiconHeight toolTipMessage|
 17672 
 17673 
 17673     "/ the toolTop string cannot be longer than 64 characters including the NULL terminator
 17674     "/ the toolTop string cannot be longer than 64 characters including the NULL terminator
 17674     toolTipMessageArg size > 63 ifTrue:[
 17675     toolTipMessageArg size > 63 ifTrue:[
 17675         toolTipMessage := toolTipMessageArg copyTo:63
 17676 	toolTipMessage := toolTipMessageArg copyTo:63
 17676     ] ifFalse:[
 17677     ] ifFalse:[
 17677         toolTipMessage := toolTipMessageArg.
 17678 	toolTipMessage := toolTipMessageArg.
 17678     ].
 17679     ].
 17679 
 17680 
 17680     windowId := aView id.
 17681     windowId := aView id.
 17681 
 17682 
 17682     wicon notNil ifTrue:[
 17683     wicon notNil ifTrue:[
 17683         wiconId := (wicon asFormOn:self) id.
 17684 	wiconId := (wicon asFormOn:self) id.
 17684         wiconHeight := wicon height.
 17685 	wiconHeight := wicon height.
 17685         wiconWidth  := wicon width.
 17686 	wiconWidth  := wicon width.
 17686         wiconMask := wiconMaskArg.
 17687 	wiconMask := wiconMaskArg.
 17687         wiconMask isNil ifTrue:[
 17688 	wiconMask isNil ifTrue:[
 17688             wiconMask := wicon mask.
 17689 	    wiconMask := wicon mask.
 17689         ].
 17690 	].
 17690         wiconMask notNil ifTrue:[
 17691 	wiconMask notNil ifTrue:[
 17691             "/ WIN32's mask has zeros for opaque pixels
 17692 	    "/ WIN32's mask has zeros for opaque pixels
 17692             invertedWiconMask := wiconMask copy.
 17693 	    invertedWiconMask := wiconMask copy.
 17693             invertedWiconMask bits invert.
 17694 	    invertedWiconMask bits invert.
 17694             invertedWiconMask := invertedWiconMask onDevice:self.
 17695 	    invertedWiconMask := invertedWiconMask onDevice:self.
 17695             wiconMaskId := invertedWiconMask id
 17696 	    wiconMaskId := invertedWiconMask id
 17696         ].
 17697 	].
 17697     ].
 17698     ].
 17698 
 17699 
 17699 %{  /* STACK: 20000 */
 17700 %{  /* STACK: 20000 */
 17700 #ifndef WM_TRAY_MESSAGE
 17701 #ifndef WM_TRAY_MESSAGE
 17701 # define WM_TRAY_MESSAGE (WM_USER+0x200)
 17702 # define WM_TRAY_MESSAGE (WM_USER+0x200)
 17706     NOTIFYICONDATA nid;
 17707     NOTIFYICONDATA nid;
 17707     unsigned char fastBits[10000];
 17708     unsigned char fastBits[10000];
 17708 
 17709 
 17709     /* get bitmap for icon */
 17710     /* get bitmap for icon */
 17710     if ( __isExternalAddress(wiconId) ) {
 17711     if ( __isExternalAddress(wiconId) ) {
 17711         xBitMap = _HBITMAPVAL( wiconId );
 17712 	xBitMap = _HBITMAPVAL( wiconId );
 17712         if ( xBitMap != 0 ) {
 17713 	if ( xBitMap != 0 ) {
 17713             BITMAP bm;
 17714 	    BITMAP bm;
 17714 
 17715 
 17715             if (GetObject(xBitMap, sizeof(bm), (LPSTR)&bm)) {
 17716 	    if (GetObject(xBitMap, sizeof(bm), (LPSTR)&bm)) {
 17716                 int d = bm.bmPlanes * bm.bmBitsPixel;
 17717 		int d = bm.bmPlanes * bm.bmBitsPixel;
 17717                 BYTE *ep;
 17718 		BYTE *ep;
 17718                 int height, width;
 17719 		int height, width;
 17719                 int nBytes;
 17720 		int nBytes;
 17720                 unsigned char *allocatedBits = 0;
 17721 		unsigned char *allocatedBits = 0;
 17721                 int privateMask = 0;
 17722 		int privateMask = 0;
 17722 
 17723 
 17723                 if ( __isExternalAddress(wiconMaskId) ) {
 17724 		if ( __isExternalAddress(wiconMaskId) ) {
 17724                     maskBitmap = _HBITMAPVAL( wiconMaskId );
 17725 		    maskBitmap = _HBITMAPVAL( wiconMaskId );
 17725                 } else {
 17726 		} else {
 17726                     if (wiconMaskId != nil) {
 17727 		    if (wiconMaskId != nil) {
 17727                         PRINTF(("WinWorkstat [warning]: wiconMaskId is not an external address\n"));
 17728 			PRINTF(("WinWorkstat [warning]: wiconMaskId is not an external address\n"));
 17728                     }
 17729 		    }
 17729                     maskBitmap = 0;
 17730 		    maskBitmap = 0;
 17730                 }
 17731 		}
 17731 
 17732 
 17732                 /*
 17733 		/*
 17733                  * if there is no mask, generate one
 17734 		 * if there is no mask, generate one
 17734                  */
 17735 		 */
 17735                 if (maskBitmap == 0) {
 17736 		if (maskBitmap == 0) {
 17736                     DPRINTF(("Bitmap w:%d h:%d p:%d d:%d\n",bm.bmWidth,bm.bmHeight,bm.bmPlanes,bm.bmBitsPixel));
 17737 		    DPRINTF(("Bitmap w:%d h:%d p:%d d:%d\n",bm.bmWidth,bm.bmHeight,bm.bmPlanes,bm.bmBitsPixel));
 17737                     height = __intVal( wiconHeight );
 17738 		    height = __intVal( wiconHeight );
 17738                     width  = __intVal( wiconWidth  );
 17739 		    width  = __intVal( wiconWidth  );
 17739                     nBytes = ( width + 15 ) / 8;
 17740 		    nBytes = ( width + 15 ) / 8;
 17740                     nBytes = height * nBytes;
 17741 		    nBytes = height * nBytes;
 17741                     if (nBytes < sizeof(fastBits)) {
 17742 		    if (nBytes < sizeof(fastBits)) {
 17742                         ep = fastBits;
 17743 			ep = fastBits;
 17743                     } else {
 17744 		    } else {
 17744                         ep = allocatedBits = (unsigned char *) malloc(nBytes);
 17745 			ep = allocatedBits = (unsigned char *) malloc(nBytes);
 17745                     }
 17746 		    }
 17746                     if ( ep == 0 ) {
 17747 		    if ( ep == 0 ) {
 17747                         PRINTF(( "WinWorkstat [warning]: malloc failed\n" ));
 17748 			PRINTF(( "WinWorkstat [warning]: malloc failed\n" ));
 17748                     } else {
 17749 		    } else {
 17749                         memset(ep, 0, nBytes);
 17750 			memset(ep, 0, nBytes);
 17750                         maskBitmap = CreateBitmap(width, height, 1, 1, ep );
 17751 			maskBitmap = CreateBitmap(width, height, 1, 1, ep );
 17751                         if ( maskBitmap == NULL ) {
 17752 			if ( maskBitmap == NULL ) {
 17752                             PRINTF(( "WinWorkstat [warning]: mask CREATION failed\n" ));
 17753 			    PRINTF(( "WinWorkstat [warning]: mask CREATION failed\n" ));
 17753                         } else {
 17754 			} else {
 17754                             privateMask = 1;
 17755 			    privateMask = 1;
 17755                         }
 17756 			}
 17756                     }
 17757 		    }
 17757                 }
 17758 		}
 17758                 if ( maskBitmap != NULL ) {
 17759 		if ( maskBitmap != NULL ) {
 17759                     DPRINTF(( "BITMAP mask CREATED!!!\n" ));
 17760 		    DPRINTF(( "BITMAP mask CREATED!!!\n" ));
 17760                     iconInfo.fIcon = TRUE;
 17761 		    iconInfo.fIcon = TRUE;
 17761                     iconInfo.hbmMask  = maskBitmap;
 17762 		    iconInfo.hbmMask  = maskBitmap;
 17762                     iconInfo.hbmColor = xBitMap;
 17763 		    iconInfo.hbmColor = xBitMap;
 17763                     xIcon = CreateIconIndirect( &iconInfo );
 17764 		    xIcon = CreateIconIndirect( &iconInfo );
 17764                     if (privateMask) {
 17765 		    if (privateMask) {
 17765                         DeleteObject( maskBitmap );
 17766 			DeleteObject( maskBitmap );
 17766                     }
 17767 		    }
 17767                 } else {
 17768 		} else {
 17768                     PRINTF(( "WinWorkstat [warning]: no mask for icon !\n" ));
 17769 		    PRINTF(( "WinWorkstat [warning]: no mask for icon !\n" ));
 17769                 }
 17770 		}
 17770 
 17771 
 17771                 if (allocatedBits) {
 17772 		if (allocatedBits) {
 17772                     free(allocatedBits);
 17773 		    free(allocatedBits);
 17773                 }
 17774 		}
 17774             }
 17775 	    }
 17775         } else {
 17776 	} else {
 17776             DPRINTF(("WinWorkstat [warning]: xBitMap is zero \n" ));
 17777 	    DPRINTF(("WinWorkstat [warning]: xBitMap is zero \n" ));
 17777         }
 17778 	}
 17778     } else {
 17779     } else {
 17779         if (wiconId != nil) {
 17780 	if (wiconId != nil) {
 17780             PRINTF(("WinWorkstat [warning]: wiconId is not an external address\n"));
 17781 	    PRINTF(("WinWorkstat [warning]: wiconId is not an external address\n"));
 17781         }
 17782 	}
 17782     }
 17783     }
 17783 
 17784 
 17784     ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
 17785     ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
 17785     nid.cbSize = sizeof(NOTIFYICONDATA);
 17786     nid.cbSize = sizeof(NOTIFYICONDATA);
 17786 
 17787 
 17787     if (__isExternalAddress(windowId)) {
 17788     if (__isExternalAddress(windowId)) {
 17788         HWND hwnd = _HWNDVal(windowId);
 17789 	HWND hwnd = _HWNDVal(windowId);
 17789 
 17790 
 17790         if (hwnd && IsWindow(hwnd)) {
 17791 	if (hwnd && IsWindow(hwnd)) {
 17791             nid.hWnd = hwnd; //the hWnd and uID members allow the OS to uniquely identify your icon.
 17792 	    nid.hWnd = hwnd; //the hWnd and uID members allow the OS to uniquely identify your icon.
 17792                              // One window (the hWnd) can have more than one icon, as long as they have unique uIDs.
 17793 			     // One window (the hWnd) can have more than one icon, as long as they have unique uIDs.
 17793             nid.uFlags =
 17794 	    nid.uFlags =
 17794                 NIF_ICON        //we're adding an icon
 17795 		NIF_ICON        //we're adding an icon
 17795                 | NIF_MESSAGE   //we want the tray to send a message to the window identified by hWnd when something happens to our icon (see uCallbackMesage member below).
 17796 		| NIF_MESSAGE   //we want the tray to send a message to the window identified by hWnd when something happens to our icon (see uCallbackMesage member below).
 17796                 | NIF_TIP;      //our icon has a tooltip.
 17797 		| NIF_TIP;      //our icon has a tooltip.
 17797 
 17798 
 17798             nid.uCallbackMessage = WM_TRAY_MESSAGE; //this message must be handled in hwnd's window procedure. more info below.
 17799 	    nid.uCallbackMessage = WM_TRAY_MESSAGE; //this message must be handled in hwnd's window procedure. more info below.
 17799             if (xIcon) {
 17800 	    if (xIcon) {
 17800                 nid.hIcon   = xIcon;
 17801 		nid.hIcon   = xIcon;
 17801                 /* wc.hIconSm = wiconId; In 4.x there are large and small icons */
 17802 		/* wc.hIconSm = wiconId; In 4.x there are large and small icons */
 17802             } else {
 17803 	    } else {
 17803                 nid.hIcon = NULL;        /* THIS MUST BE NULL TO DELETE ICONS */
 17804 		nid.hIcon = NULL;        /* THIS MUST BE NULL TO DELETE ICONS */
 17804             }
 17805 	    }
 17805             if (__isStringLike(toolTipMessage)) {
 17806 	    if (__isStringLike(toolTipMessage)) {
 17806                 strcpy(nid.szTip, __stringVal(toolTipMessage));
 17807 		strcpy(nid.szTip, __stringVal(toolTipMessage));
 17807             }
 17808 	    }
 17808             Shell_NotifyIcon(NIM_ADD, &nid);
 17809 	    Shell_NotifyIcon(NIM_ADD, &nid);
 17809         }
 17810 	}
 17810     }
 17811     }
 17811 %}
 17812 %}
 17812 
 17813 
 17813     "
 17814     "
 17814      |v icon|
 17815      |v icon|
 17816      v := StandardSystemView new.
 17817      v := StandardSystemView new.
 17817      v openAndWait.
 17818      v openAndWait.
 17818 
 17819 
 17819      icon := Icon stxIcon.
 17820      icon := Icon stxIcon.
 17820      Screen current
 17821      Screen current
 17821           addTrayIconFor:v
 17822 	  addTrayIconFor:v
 17822           icon:icon iconMask:nil
 17823 	  icon:icon iconMask:nil
 17823           toolTipMessage:'Hi There'
 17824 	  toolTipMessage:'Hi There'
 17824     "
 17825     "
 17825 
 17826 
 17826     "Created: / 31-10-2007 / 01:51:49 / cg"
 17827     "Created: / 31-10-2007 / 01:51:49 / cg"
 17827     "Modified: / 05-11-2007 / 12:18:54 / cg"
 17828     "Modified: / 05-11-2007 / 12:18:54 / cg"
 17828 !
 17829 !
 17843 
 17844 
 17844     ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
 17845     ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
 17845     nid.cbSize = sizeof(NOTIFYICONDATA);
 17846     nid.cbSize = sizeof(NOTIFYICONDATA);
 17846 
 17847 
 17847     if (__isExternalAddress(windowId)) {
 17848     if (__isExternalAddress(windowId)) {
 17848         HWND hwnd = _HWNDVal(windowId);
 17849 	HWND hwnd = _HWNDVal(windowId);
 17849 
 17850 
 17850         if (hwnd && IsWindow(hwnd)) {
 17851 	if (hwnd && IsWindow(hwnd)) {
 17851             nid.hWnd = hwnd;
 17852 	    nid.hWnd = hwnd;
 17852             Shell_NotifyIcon(NIM_DELETE, &nid);
 17853 	    Shell_NotifyIcon(NIM_DELETE, &nid);
 17853         }
 17854 	}
 17854     }
 17855     }
 17855 %}
 17856 %}
 17856 
 17857 
 17857     "
 17858     "
 17858      |v icon|
 17859      |v icon|
 17860      v := StandardSystemView new.
 17861      v := StandardSystemView new.
 17861      v openAndWait.
 17862      v openAndWait.
 17862 
 17863 
 17863      icon := Icon stxIcon.
 17864      icon := Icon stxIcon.
 17864      Screen current
 17865      Screen current
 17865           addTrayIconFor:v
 17866 	  addTrayIconFor:v
 17866           icon:icon iconMask:nil
 17867 	  icon:icon iconMask:nil
 17867           toolTipMessage:'Hi There'.
 17868 	  toolTipMessage:'Hi There'.
 17868 
 17869 
 17869      Delay waitForSeconds:3.
 17870      Delay waitForSeconds:3.
 17870      icon := Tools::NewSystemBrowser defaultIcon.
 17871      icon := Tools::NewSystemBrowser defaultIcon.
 17871      Screen current
 17872      Screen current
 17872           setTrayIconFor:v
 17873 	  setTrayIconFor:v
 17873           icon:icon iconMask:nil.
 17874 	  icon:icon iconMask:nil.
 17874      Delay waitForSeconds:3.
 17875      Delay waitForSeconds:3.
 17875      Screen current
 17876      Screen current
 17876             removeTrayIconFor:v.
 17877 	    removeTrayIconFor:v.
 17877     "
 17878     "
 17878 
 17879 
 17879     "Created: / 05-11-2007 / 12:17:17 / cg"
 17880     "Created: / 05-11-2007 / 12:17:17 / cg"
 17880 !
 17881 !
 17881 
 17882 
 17886      wiconWidth wiconHeight|
 17887      wiconWidth wiconHeight|
 17887 
 17888 
 17888     windowId := aView id.
 17889     windowId := aView id.
 17889 
 17890 
 17890     wicon notNil ifTrue:[
 17891     wicon notNil ifTrue:[
 17891         wiconId := (wicon asFormOn:self) id.
 17892 	wiconId := (wicon asFormOn:self) id.
 17892         wiconHeight := wicon height.
 17893 	wiconHeight := wicon height.
 17893         wiconWidth  := wicon width.
 17894 	wiconWidth  := wicon width.
 17894         wiconMask := wiconMaskArg.
 17895 	wiconMask := wiconMaskArg.
 17895         wiconMask isNil ifTrue:[
 17896 	wiconMask isNil ifTrue:[
 17896             wiconMask := wicon mask.
 17897 	    wiconMask := wicon mask.
 17897         ].
 17898 	].
 17898         wiconMask notNil ifTrue:[
 17899 	wiconMask notNil ifTrue:[
 17899             "/ WIN32's mask has zeros for opaque pixels
 17900 	    "/ WIN32's mask has zeros for opaque pixels
 17900             invertedWiconMask := wiconMask copy.
 17901 	    invertedWiconMask := wiconMask copy.
 17901             invertedWiconMask bits invert.
 17902 	    invertedWiconMask bits invert.
 17902             invertedWiconMask := invertedWiconMask onDevice:self.
 17903 	    invertedWiconMask := invertedWiconMask onDevice:self.
 17903             wiconMaskId := invertedWiconMask id
 17904 	    wiconMaskId := invertedWiconMask id
 17904         ].
 17905 	].
 17905     ].
 17906     ].
 17906 
 17907 
 17907 %{  /* STACK: 20000 */
 17908 %{  /* STACK: 20000 */
 17908 #ifndef WM_TRAY_MESSAGE
 17909 #ifndef WM_TRAY_MESSAGE
 17909 # define WM_TRAY_MESSAGE (WM_USER+0x200)
 17910 # define WM_TRAY_MESSAGE (WM_USER+0x200)
 17914     NOTIFYICONDATA nid;
 17915     NOTIFYICONDATA nid;
 17915     unsigned char fastBits[10000];
 17916     unsigned char fastBits[10000];
 17916 
 17917 
 17917     /* get bitmap for icon */
 17918     /* get bitmap for icon */
 17918     if ( __isExternalAddress(wiconId) ) {
 17919     if ( __isExternalAddress(wiconId) ) {
 17919         xBitMap = _HBITMAPVAL( wiconId );
 17920 	xBitMap = _HBITMAPVAL( wiconId );
 17920         if ( xBitMap != 0 ) {
 17921 	if ( xBitMap != 0 ) {
 17921             BITMAP bm;
 17922 	    BITMAP bm;
 17922 
 17923 
 17923             if (GetObject(xBitMap, sizeof(bm), (LPSTR)&bm)) {
 17924 	    if (GetObject(xBitMap, sizeof(bm), (LPSTR)&bm)) {
 17924                 int d = bm.bmPlanes * bm.bmBitsPixel;
 17925 		int d = bm.bmPlanes * bm.bmBitsPixel;
 17925                 BYTE *ep;
 17926 		BYTE *ep;
 17926                 int height, width;
 17927 		int height, width;
 17927                 int nBytes;
 17928 		int nBytes;
 17928                 unsigned char *allocatedBits = 0;
 17929 		unsigned char *allocatedBits = 0;
 17929                 int privateMask = 0;
 17930 		int privateMask = 0;
 17930 
 17931 
 17931                 if ( __isExternalAddress(wiconMaskId) ) {
 17932 		if ( __isExternalAddress(wiconMaskId) ) {
 17932                     maskBitmap = _HBITMAPVAL( wiconMaskId );
 17933 		    maskBitmap = _HBITMAPVAL( wiconMaskId );
 17933                 } else {
 17934 		} else {
 17934                     if (wiconMaskId != nil) {
 17935 		    if (wiconMaskId != nil) {
 17935                         PRINTF(("WinWorkstat [warning]: wiconMaskId is not an external address\n"));
 17936 			PRINTF(("WinWorkstat [warning]: wiconMaskId is not an external address\n"));
 17936                     }
 17937 		    }
 17937                     maskBitmap = 0;
 17938 		    maskBitmap = 0;
 17938                 }
 17939 		}
 17939 
 17940 
 17940                 /*
 17941 		/*
 17941                  * if there is no mask, generate one
 17942 		 * if there is no mask, generate one
 17942                  */
 17943 		 */
 17943                 if (maskBitmap == 0) {
 17944 		if (maskBitmap == 0) {
 17944                     DPRINTF(("Bitmap w:%d h:%d p:%d d:%d\n",bm.bmWidth,bm.bmHeight,bm.bmPlanes,bm.bmBitsPixel));
 17945 		    DPRINTF(("Bitmap w:%d h:%d p:%d d:%d\n",bm.bmWidth,bm.bmHeight,bm.bmPlanes,bm.bmBitsPixel));
 17945                     height = __intVal( wiconHeight );
 17946 		    height = __intVal( wiconHeight );
 17946                     width  = __intVal( wiconWidth  );
 17947 		    width  = __intVal( wiconWidth  );
 17947                     nBytes = ( width + 15 ) / 8;
 17948 		    nBytes = ( width + 15 ) / 8;
 17948                     nBytes = height * nBytes;
 17949 		    nBytes = height * nBytes;
 17949                     if (nBytes < sizeof(fastBits)) {
 17950 		    if (nBytes < sizeof(fastBits)) {
 17950                         ep = fastBits;
 17951 			ep = fastBits;
 17951                     } else {
 17952 		    } else {
 17952                         ep = allocatedBits = (unsigned char *) malloc(nBytes);
 17953 			ep = allocatedBits = (unsigned char *) malloc(nBytes);
 17953                     }
 17954 		    }
 17954                     if ( ep == 0 ) {
 17955 		    if ( ep == 0 ) {
 17955                         PRINTF(( "WinWorkstat [warning]: malloc failed\n" ));
 17956 			PRINTF(( "WinWorkstat [warning]: malloc failed\n" ));
 17956                     } else {
 17957 		    } else {
 17957                         memset(ep, 0, nBytes);
 17958 			memset(ep, 0, nBytes);
 17958                         maskBitmap = CreateBitmap(width, height, 1, 1, ep );
 17959 			maskBitmap = CreateBitmap(width, height, 1, 1, ep );
 17959                         if ( maskBitmap == NULL ) {
 17960 			if ( maskBitmap == NULL ) {
 17960                             PRINTF(( "WinWorkstat [warning]: mask CREATION failed\n" ));
 17961 			    PRINTF(( "WinWorkstat [warning]: mask CREATION failed\n" ));
 17961                         } else {
 17962 			} else {
 17962                             privateMask = 1;
 17963 			    privateMask = 1;
 17963                         }
 17964 			}
 17964                     }
 17965 		    }
 17965                 }
 17966 		}
 17966                 if ( maskBitmap != NULL ) {
 17967 		if ( maskBitmap != NULL ) {
 17967                     DPRINTF(( "BITMAP mask CREATED!!!\n" ));
 17968 		    DPRINTF(( "BITMAP mask CREATED!!!\n" ));
 17968                     iconInfo.fIcon = TRUE;
 17969 		    iconInfo.fIcon = TRUE;
 17969                     iconInfo.hbmMask  = maskBitmap;
 17970 		    iconInfo.hbmMask  = maskBitmap;
 17970                     iconInfo.hbmColor = xBitMap;
 17971 		    iconInfo.hbmColor = xBitMap;
 17971                     xIcon = CreateIconIndirect( &iconInfo );
 17972 		    xIcon = CreateIconIndirect( &iconInfo );
 17972                     if (privateMask) {
 17973 		    if (privateMask) {
 17973                         DeleteObject( maskBitmap );
 17974 			DeleteObject( maskBitmap );
 17974                     }
 17975 		    }
 17975                 } else {
 17976 		} else {
 17976                     PRINTF(( "WinWorkstat [warning]: no mask for icon !\n" ));
 17977 		    PRINTF(( "WinWorkstat [warning]: no mask for icon !\n" ));
 17977                 }
 17978 		}
 17978 
 17979 
 17979                 if (allocatedBits) {
 17980 		if (allocatedBits) {
 17980                     free(allocatedBits);
 17981 		    free(allocatedBits);
 17981                 }
 17982 		}
 17982             }
 17983 	    }
 17983         } else {
 17984 	} else {
 17984             DPRINTF(("WinWorkstat [warning]: xBitMap is zero \n" ));
 17985 	    DPRINTF(("WinWorkstat [warning]: xBitMap is zero \n" ));
 17985         }
 17986 	}
 17986     } else {
 17987     } else {
 17987         if (wiconId != nil) {
 17988 	if (wiconId != nil) {
 17988             PRINTF(("WinWorkstat [warning]: wiconId is not an external address\n"));
 17989 	    PRINTF(("WinWorkstat [warning]: wiconId is not an external address\n"));
 17989         }
 17990 	}
 17990     }
 17991     }
 17991 
 17992 
 17992     ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
 17993     ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
 17993     nid.cbSize = sizeof(NOTIFYICONDATA);
 17994     nid.cbSize = sizeof(NOTIFYICONDATA);
 17994 
 17995 
 17995     if (__isExternalAddress(windowId)) {
 17996     if (__isExternalAddress(windowId)) {
 17996         HWND hwnd = _HWNDVal(windowId);
 17997 	HWND hwnd = _HWNDVal(windowId);
 17997 
 17998 
 17998         if (hwnd && IsWindow(hwnd)) {
 17999 	if (hwnd && IsWindow(hwnd)) {
 17999             nid.hWnd = hwnd; //the hWnd and uID members allow the OS to uniquely identify your icon.
 18000 	    nid.hWnd = hwnd; //the hWnd and uID members allow the OS to uniquely identify your icon.
 18000                              // One window (the hWnd) can have more than one icon, as long as they have unique uIDs.
 18001 			     // One window (the hWnd) can have more than one icon, as long as they have unique uIDs.
 18001             nid.uFlags = NIF_ICON;      //our icon has a tooltip.
 18002 	    nid.uFlags = NIF_ICON;      //our icon has a tooltip.
 18002 
 18003 
 18003             if (xIcon) {
 18004 	    if (xIcon) {
 18004                 nid.hIcon   = xIcon;
 18005 		nid.hIcon   = xIcon;
 18005                 /* wc.hIconSm = wiconId; In 4.x there are large and small icons */
 18006 		/* wc.hIconSm = wiconId; In 4.x there are large and small icons */
 18006             } else {
 18007 	    } else {
 18007                 nid.hIcon = NULL;        /* THIS MUST BE NULL TO DELETE ICONS */
 18008 		nid.hIcon = NULL;        /* THIS MUST BE NULL TO DELETE ICONS */
 18008             }
 18009 	    }
 18009             Shell_NotifyIcon(NIM_MODIFY, &nid);
 18010 	    Shell_NotifyIcon(NIM_MODIFY, &nid);
 18010         }
 18011 	}
 18011     }
 18012     }
 18012 %}
 18013 %}
 18013 
 18014 
 18014     "
 18015     "
 18015      |v icon|
 18016      |v icon|
 18017      v := StandardSystemView new.
 18018      v := StandardSystemView new.
 18018      v openAndWait.
 18019      v openAndWait.
 18019 
 18020 
 18020      icon := Icon stxIcon.
 18021      icon := Icon stxIcon.
 18021      Screen current
 18022      Screen current
 18022           addTrayIconFor:v
 18023 	  addTrayIconFor:v
 18023           icon:icon iconMask:nil
 18024 	  icon:icon iconMask:nil
 18024           toolTipMessage:'Hi There'.
 18025 	  toolTipMessage:'Hi There'.
 18025 
 18026 
 18026      Delay waitForSeconds:3.
 18027      Delay waitForSeconds:3.
 18027      icon := Tools::NewSystemBrowser defaultIcon.
 18028      icon := Tools::NewSystemBrowser defaultIcon.
 18028      Screen current
 18029      Screen current
 18029           setTrayIconFor:v
 18030 	  setTrayIconFor:v
 18030           icon:icon iconMask:nil.
 18031 	  icon:icon iconMask:nil.
 18031 
 18032 
 18032     "
 18033     "
 18033 
 18034 
 18034     "Created: / 31-10-2007 / 11:41:33 / cg"
 18035     "Created: / 31-10-2007 / 11:41:33 / cg"
 18035     "Modified: / 05-11-2007 / 12:19:12 / cg"
 18036     "Modified: / 05-11-2007 / 12:19:12 / cg"
 18046     |windowId wiconId wiconMask invertedWiconMask wiconMaskId
 18047     |windowId wiconId wiconMask invertedWiconMask wiconMaskId
 18047      wiconWidth wiconHeight toolTipMessage|
 18048      wiconWidth wiconHeight toolTipMessage|
 18048 
 18049 
 18049     "/ the toolTop string cannot be longer than 64 characters including the NULL terminator
 18050     "/ the toolTop string cannot be longer than 64 characters including the NULL terminator
 18050     toolTipMessageArg size > 63 ifTrue:[
 18051     toolTipMessageArg size > 63 ifTrue:[
 18051         toolTipMessage := toolTipMessageArg copyTo:63
 18052 	toolTipMessage := toolTipMessageArg copyTo:63
 18052     ] ifFalse:[
 18053     ] ifFalse:[
 18053         toolTipMessage := toolTipMessageArg.
 18054 	toolTipMessage := toolTipMessageArg.
 18054     ].
 18055     ].
 18055 
 18056 
 18056     windowId := aView id.
 18057     windowId := aView id.
 18057 
 18058 
 18058 %{  /* STACK: 20000 */
 18059 %{  /* STACK: 20000 */
 18060 
 18061 
 18061     ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
 18062     ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
 18062     nid.cbSize = sizeof(NOTIFYICONDATA);
 18063     nid.cbSize = sizeof(NOTIFYICONDATA);
 18063 
 18064 
 18064     if (__isExternalAddress(windowId)) {
 18065     if (__isExternalAddress(windowId)) {
 18065         HWND hwnd = _HWNDVal(windowId);
 18066 	HWND hwnd = _HWNDVal(windowId);
 18066 
 18067 
 18067         if (hwnd && IsWindow(hwnd)) {
 18068 	if (hwnd && IsWindow(hwnd)) {
 18068             nid.hWnd = hwnd; //the hWnd and uID members allow the OS to uniquely identify your icon.
 18069 	    nid.hWnd = hwnd; //the hWnd and uID members allow the OS to uniquely identify your icon.
 18069                              // One window (the hWnd) can have more than one icon, as long as they have unique uIDs.
 18070 			     // One window (the hWnd) can have more than one icon, as long as they have unique uIDs.
 18070             nid.uFlags = NIF_TIP;    //change the tooltip.
 18071 	    nid.uFlags = NIF_TIP;    //change the tooltip.
 18071             if (__isStringLike(toolTipMessage)) {
 18072 	    if (__isStringLike(toolTipMessage)) {
 18072                 strcpy(nid.szTip, __stringVal(toolTipMessage));
 18073 		strcpy(nid.szTip, __stringVal(toolTipMessage));
 18073             }
 18074 	    }
 18074             Shell_NotifyIcon(NIM_MODIFY, &nid);
 18075 	    Shell_NotifyIcon(NIM_MODIFY, &nid);
 18075         }
 18076 	}
 18076     }
 18077     }
 18077 %}
 18078 %}
 18078 
 18079 
 18079     "
 18080     "
 18080      |v icon|
 18081      |v icon|
 18082      v := StandardSystemView new.
 18083      v := StandardSystemView new.
 18083      v openAndWait.
 18084      v openAndWait.
 18084 
 18085 
 18085      icon := Icon stxIcon.
 18086      icon := Icon stxIcon.
 18086      Screen current
 18087      Screen current
 18087           addTrayIconFor:v
 18088 	  addTrayIconFor:v
 18088           icon:icon iconMask:nil
 18089 	  icon:icon iconMask:nil
 18089           toolTipMessage:'Hi There'.
 18090 	  toolTipMessage:'Hi There'.
 18090      1 to:5 do:[:i |
 18091      1 to:5 do:[:i |
 18091          Delay waitForSeconds:2.
 18092 	 Delay waitForSeconds:2.
 18092          Screen current
 18093 	 Screen current
 18093               setTrayIconsToolTipMessageFor:v
 18094 	      setTrayIconsToolTipMessageFor:v
 18094               to:(i printString).
 18095 	      to:(i printString).
 18095      ].
 18096      ].
 18096      v destroy.
 18097      v destroy.
 18097     "
 18098     "
 18098 
 18099 
 18099     "Created: / 31-10-2007 / 11:25:49 / cg"
 18100     "Created: / 31-10-2007 / 11:25:49 / cg"
 18105 activateWindow1:aWindowId
 18106 activateWindow1:aWindowId
 18106     "make a window active (so that it gets the focus)"
 18107     "make a window active (so that it gets the focus)"
 18107 
 18108 
 18108 %{  /* NOCONTEXT */
 18109 %{  /* NOCONTEXT */
 18109     if (__isExternalAddress(aWindowId)) {
 18110     if (__isExternalAddress(aWindowId)) {
 18110         HWND win = _HWNDVal(aWindowId);
 18111 	HWND win = _HWNDVal(aWindowId);
 18111 
 18112 
 18112         if (win) {
 18113 	if (win) {
 18113             CPRINTF(("activateWindow %x\n",win));
 18114 	    CPRINTF(("activateWindow %x\n",win));
 18114 #if 0
 18115 #if 0
 18115             ShowWindowAsync(win, SW_SHOW);
 18116 	    ShowWindowAsync(win, SW_SHOW);
 18116 #else
 18117 #else
 18117             ShowWindow(win, SW_SHOW);
 18118 	    ShowWindow(win, SW_SHOW);
 18118 #endif
 18119 #endif
 18119         }
 18120 	}
 18120     }
 18121     }
 18121 %}
 18122 %}
 18122 !
 18123 !
 18123 
 18124 
 18124 activateWindow2:aWindowId
 18125 activateWindow2:aWindowId
 18125     "make a window active (so that it gets the focus).
 18126     "make a window active (so that it gets the focus).
 18126      Paranoid implementation."
 18127      Paranoid implementation."
 18127 
 18128 
 18128 %{  /* NOCONTEXT */
 18129 %{  /* NOCONTEXT */
 18129     if (__isExternalAddress(aWindowId)) {
 18130     if (__isExternalAddress(aWindowId)) {
 18130         HWND win = _HWNDVal(aWindowId);
 18131 	HWND win = _HWNDVal(aWindowId);
 18131 
 18132 
 18132         if (win) {
 18133 	if (win) {
 18133             DWORD activeThreadID, activeProcessID;
 18134 	    DWORD activeThreadID, activeProcessID;
 18134             DWORD myThreadID;
 18135 	    DWORD myThreadID;
 18135             HWND foregroundWindow = GetForegroundWindow();
 18136 	    HWND foregroundWindow = GetForegroundWindow();
 18136 
 18137 
 18137             if (foregroundWindow) {
 18138 	    if (foregroundWindow) {
 18138                 activeThreadID = GetWindowThreadProcessId(foregroundWindow, &activeProcessID);
 18139 		activeThreadID = GetWindowThreadProcessId(foregroundWindow, &activeProcessID);
 18139                 myThreadID = GetCurrentThreadId();
 18140 		myThreadID = GetCurrentThreadId();
 18140                 AttachThreadInput(activeThreadID, myThreadID, TRUE);
 18141 		AttachThreadInput(activeThreadID, myThreadID, TRUE);
 18141             }
 18142 	    }
 18142 
 18143 
 18143             // Do our stuff here ;-)
 18144 	    // Do our stuff here ;-)
 18144             ShowWindow(win, SW_SHOW);
 18145 	    ShowWindow(win, SW_SHOW);
 18145             SetForegroundWindow(win);
 18146 	    SetForegroundWindow(win);
 18146             SetFocus(win);
 18147 	    SetFocus(win);
 18147 
 18148 
 18148             if (foregroundWindow) {
 18149 	    if (foregroundWindow) {
 18149                 AttachThreadInput(activeThreadID, myThreadID, FALSE);
 18150 		AttachThreadInput(activeThreadID, myThreadID, FALSE);
 18150             }
 18151 	    }
 18151         }
 18152 	}
 18152     }
 18153     }
 18153 %}
 18154 %}
 18154 !
 18155 !
 18155 
 18156 
 18156 activateWindow:aWindowId
 18157 activateWindow:aWindowId
 18164 !
 18165 !
 18165 
 18166 
 18166 animateWindow:aWindowId show:doShow animation:animationSymbolorNil time:timeInMillisOrNil
 18167 animateWindow:aWindowId show:doShow animation:animationSymbolorNil time:timeInMillisOrNil
 18167     "make a window visible/invisible with animation effect.
 18168     "make a window visible/invisible with animation effect.
 18168      CAVEAT:
 18169      CAVEAT:
 18169         This does not work yet correctly, as we do not handle WM_PRINT messages correctly."
 18170 	This does not work yet correctly, as we do not handle WM_PRINT messages correctly."
 18170 
 18171 
 18171 %{
 18172 %{
 18172     if (__isExternalAddress(aWindowId)) {
 18173     if (__isExternalAddress(aWindowId)) {
 18173         HWND hWnd = _HWNDVal(aWindowId);
 18174 	HWND hWnd = _HWNDVal(aWindowId);
 18174 
 18175 
 18175         if (hWnd) {
 18176 	if (hWnd) {
 18176             DWORD how = (doShow == true) ? AW_ACTIVATE : AW_HIDE;
 18177 	    DWORD how = (doShow == true) ? AW_ACTIVATE : AW_HIDE;
 18177             DWORD time = 0;
 18178 	    DWORD time = 0;
 18178 
 18179 
 18179             CPRINTF(("mapWindowAnimated %x\n", hWnd));
 18180 	    CPRINTF(("mapWindowAnimated %x\n", hWnd));
 18180             if (animationSymbolorNil != nil) {
 18181 	    if (animationSymbolorNil != nil) {
 18181                 if (__isSmallInteger(timeInMillisOrNil)) {
 18182 		if (__isSmallInteger(timeInMillisOrNil)) {
 18182                     time = __intVal(timeInMillisOrNil);
 18183 		    time = __intVal(timeInMillisOrNil);
 18183                 }
 18184 		}
 18184                 if (animationSymbolorNil == @symbol(SLIDE)) {
 18185 		if (animationSymbolorNil == @symbol(SLIDE)) {
 18185                     how |= AW_SLIDE;
 18186 		    how |= AW_SLIDE;
 18186                 } else if (animationSymbolorNil == @symbol(BLEND)) {
 18187 		} else if (animationSymbolorNil == @symbol(BLEND)) {
 18187                     how |= AW_BLEND;
 18188 		    how |= AW_BLEND;
 18188                 } else if (animationSymbolorNil == @symbol(CENTER)) {
 18189 		} else if (animationSymbolorNil == @symbol(CENTER)) {
 18189                     how |= AW_CENTER;
 18190 		    how |= AW_CENTER;
 18190                 } else if (animationSymbolorNil == @symbol(HOR_POSITIVE)) {
 18191 		} else if (animationSymbolorNil == @symbol(HOR_POSITIVE)) {
 18191                     how |= AW_HOR_POSITIVE;
 18192 		    how |= AW_HOR_POSITIVE;
 18192                 } else if (animationSymbolorNil == @symbol(HOR_NEGATIVE)) {
 18193 		} else if (animationSymbolorNil == @symbol(HOR_NEGATIVE)) {
 18193                     how |= AW_HOR_NEGATIVE;
 18194 		    how |= AW_HOR_NEGATIVE;
 18194                 } else if (animationSymbolorNil == @symbol(VER_POSITIVE)) {
 18195 		} else if (animationSymbolorNil == @symbol(VER_POSITIVE)) {
 18195                     how |= AW_VER_POSITIVE;
 18196 		    how |= AW_VER_POSITIVE;
 18196                 } else if (animationSymbolorNil == @symbol(VER_NEGATIVE)) {
 18197 		} else if (animationSymbolorNil == @symbol(VER_NEGATIVE)) {
 18197                     how |= AW_VER_NEGATIVE;
 18198 		    how |= AW_VER_NEGATIVE;
 18198                 }
 18199 		}
 18199             }
 18200 	    }
 18200             AnimateWindow(hWnd, time, how);
 18201 	    AnimateWindow(hWnd, time, how);
 18201         }
 18202 	}
 18202         RETURN ( self );
 18203 	RETURN ( self );
 18203     }
 18204     }
 18204 %}
 18205 %}
 18205 !
 18206 !
 18206 
 18207 
 18207 configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol
 18208 configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol
 18213     "window accept Files from Shell"
 18214     "window accept Files from Shell"
 18214 
 18215 
 18215 %{  /*  */
 18216 %{  /*  */
 18216 
 18217 
 18217     if (__isExternalAddress(aWindowId)) {
 18218     if (__isExternalAddress(aWindowId)) {
 18218         HWND hWnd = _HWNDVal(aWindowId);
 18219 	HWND hWnd = _HWNDVal(aWindowId);
 18219 
 18220 
 18220         if (hWnd) {
 18221 	if (hWnd) {
 18221             if (doAccept == true)
 18222 	    if (doAccept == true)
 18222             DragAcceptFiles(hWnd, (doAccept == true) ? TRUE : FALSE);
 18223 	    DragAcceptFiles(hWnd, (doAccept == true) ? TRUE : FALSE);
 18223         }
 18224 	}
 18224         RETURN ( self );
 18225 	RETURN ( self );
 18225     }
 18226     }
 18226 %}
 18227 %}
 18227 !
 18228 !
 18228 
 18229 
 18229 findWindow:lpClassName windowName:lpWindowName
 18230 findWindow:lpClassName windowName:lpWindowName
 18230     "If the function succeeds, the return value is a handle to the window that has the specified class name
 18231     "If the function succeeds, the return value is a handle to the window that has the specified class name
 18231      and window name. If the function fails, the return value is NULL."
 18232      and window name. If the function fails, the return value is NULL."
 18232 
 18233 
 18233     ((lpClassName notNil and:[lpClassName isWideString])
 18234     ((lpClassName notNil and:[lpClassName isWideString])
 18234      or:[lpWindowName notNil and:[lpWindowName isWideString]]) ifTrue:[
 18235      or:[lpWindowName notNil and:[lpWindowName isWideString]]) ifTrue:[
 18235         ^ self
 18236 	^ self
 18236             primFindWindowW:(lpClassName isNil
 18237 	    primFindWindowW:(lpClassName isNil
 18237                                     ifTrue:[nil]
 18238 				    ifTrue:[nil]
 18238                                     ifFalse:[lpClassName asUnicode16StringZ])
 18239 				    ifFalse:[lpClassName asUnicode16StringZ])
 18239             windowName:(lpWindowName isNil
 18240 	    windowName:(lpWindowName isNil
 18240                                     ifTrue:[nil]
 18241 				    ifTrue:[nil]
 18241                                     ifFalse:[lpWindowName asUnicode16StringZ])
 18242 				    ifFalse:[lpWindowName asUnicode16StringZ])
 18242     ].
 18243     ].
 18243     ^ self primFindWindowA:lpClassName windowName:lpWindowName
 18244     ^ self primFindWindowA:lpClassName windowName:lpWindowName
 18244 
 18245 
 18245     "
 18246     "
 18246      |h|
 18247      |h|
 18254 
 18255 
 18255 getParentWindowIdOfWindowId:aChildWindowId
 18256 getParentWindowIdOfWindowId:aChildWindowId
 18256 %{  /* NOCONTEXT */
 18257 %{  /* NOCONTEXT */
 18257 
 18258 
 18258     if (__isExternalAddress(aChildWindowId)) {
 18259     if (__isExternalAddress(aChildWindowId)) {
 18259         HWND wChild = _HWNDVal(aChildWindowId);
 18260 	HWND wChild = _HWNDVal(aChildWindowId);
 18260         HWND wParent;
 18261 	HWND wParent;
 18261 
 18262 
 18262         if (wChild) {
 18263 	if (wChild) {
 18263             wParent = GetParent(wChild);
 18264 	    wParent = GetParent(wChild);
 18264             if (wParent) {
 18265 	    if (wParent) {
 18265                 RETURN ( __MKEXTERNALADDRESS(wParent) );
 18266 		RETURN ( __MKEXTERNALADDRESS(wParent) );
 18266             }
 18267 	    }
 18267         }
 18268 	}
 18268     }
 18269     }
 18269 %}.
 18270 %}.
 18270     ^ nil
 18271     ^ nil
 18271 
 18272 
 18272     "
 18273     "
 18282 
 18283 
 18283 getThreadIdOfWindowId:windowId
 18284 getThreadIdOfWindowId:windowId
 18284 %{  /* NOCONTEXT */
 18285 %{  /* NOCONTEXT */
 18285 
 18286 
 18286     if (__isExternalAddress(windowId)) {
 18287     if (__isExternalAddress(windowId)) {
 18287         HWND hwnd = _HWNDVal(windowId);
 18288 	HWND hwnd = _HWNDVal(windowId);
 18288         DWORD id;
 18289 	DWORD id;
 18289 
 18290 
 18290         if (hwnd) {
 18291 	if (hwnd) {
 18291             id = GetWindowThreadProcessId(hwnd, &id);
 18292 	    id = GetWindowThreadProcessId(hwnd, &id);
 18292             RETURN ( __MKEXTERNALADDRESS(id) );
 18293 	    RETURN ( __MKEXTERNALADDRESS(id) );
 18293         }
 18294 	}
 18294     }
 18295     }
 18295 %}.
 18296 %}.
 18296     ^ nil
 18297     ^ nil
 18297 
 18298 
 18298     "
 18299     "
 18311     |buffer n|
 18312     |buffer n|
 18312 
 18313 
 18313     buffer := Unicode16String new:200.
 18314     buffer := Unicode16String new:200.
 18314     n := self primGetWindowClassW:aWindowId into:buffer size:200.
 18315     n := self primGetWindowClassW:aWindowId into:buffer size:200.
 18315     n >= 0 ifTrue:[
 18316     n >= 0 ifTrue:[
 18316         ^ (buffer copyTo:n) asSingleByteStringIfPossible
 18317 	^ (buffer copyTo:n) asSingleByteStringIfPossible
 18317     ].
 18318     ].
 18318     self primitiveFailed.
 18319     self primitiveFailed.
 18319 
 18320 
 18320     "
 18321     "
 18321      |h|
 18322      |h|
 18336     |l|
 18337     |l|
 18337 
 18338 
 18338     l := OrderedCollection new.
 18339     l := OrderedCollection new.
 18339     self primEnumWindowsInto:l.
 18340     self primEnumWindowsInto:l.
 18340     l do:[:eachWindowId |
 18341     l do:[:eachWindowId |
 18341         (self getParentWindowIdOfWindowId:eachWindowId) isNil ifTrue:[
 18342 	(self getParentWindowIdOfWindowId:eachWindowId) isNil ifTrue:[
 18342             "/ a topView
 18343 	    "/ a topView
 18343             (self getThreadIdOfWindowId:eachWindowId) = id ifTrue:[
 18344 	    (self getThreadIdOfWindowId:eachWindowId) = id ifTrue:[
 18344                 ^ eachWindowId
 18345 		^ eachWindowId
 18345             ].
 18346 	    ].
 18346         ]
 18347 	]
 18347     ].
 18348     ].
 18348     ^ nil
 18349     ^ nil
 18349 
 18350 
 18350     "
 18351     "
 18351      Display getWindowIdFromThreadId:(OperatingSystem getProcessId)
 18352      Display getWindowIdFromThreadId:(OperatingSystem getProcessId)
 18360     (aWindowId isNil or:[aWindowId address == 0]) ifTrue:[^ self].
 18361     (aWindowId isNil or:[aWindowId address == 0]) ifTrue:[^ self].
 18361 
 18362 
 18362     bytes := ByteArray new:(ExternalBytes sizeofLong*4).
 18363     bytes := ByteArray new:(ExternalBytes sizeofLong*4).
 18363     self primGetWindowRect:aWindowId lpRect:bytes.
 18364     self primGetWindowRect:aWindowId lpRect:bytes.
 18364     ^ Rectangle
 18365     ^ Rectangle
 18365         left:(bytes longAt:1)
 18366 	left:(bytes longAt:1)
 18366         top:(bytes longAt:5)
 18367 	top:(bytes longAt:5)
 18367         right:(bytes longAt:9)
 18368 	right:(bytes longAt:9)
 18368         bottom:(bytes longAt:13)
 18369 	bottom:(bytes longAt:13)
 18369 
 18370 
 18370     "
 18371     "
 18371      |handle|
 18372      |handle|
 18372 
 18373 
 18373      handle := Display findWindow: nil windowName: 'ST/X Launcher'.
 18374      handle := Display findWindow: nil windowName: 'ST/X Launcher'.
 18382     |buffer n|
 18383     |buffer n|
 18383 
 18384 
 18384     buffer := Unicode16String new:200.
 18385     buffer := Unicode16String new:200.
 18385     n := self primGetWindowTextW:aWindowId into:buffer size:200.
 18386     n := self primGetWindowTextW:aWindowId into:buffer size:200.
 18386     n >= 0 ifTrue:[
 18387     n >= 0 ifTrue:[
 18387         ^ (buffer copyTo:n) asSingleByteStringIfPossible
 18388 	^ (buffer copyTo:n) asSingleByteStringIfPossible
 18388     ].
 18389     ].
 18389     self primitiveFailed.
 18390     self primitiveFailed.
 18390 
 18391 
 18391     "
 18392     "
 18392      |h|
 18393      |h|
 18408      Especially useful, if the passed windowID is
 18409      Especially useful, if the passed windowID is
 18409      an alien (external) windows id."
 18410      an alien (external) windows id."
 18410 
 18411 
 18411 %{  /* NOCONTEXT */
 18412 %{  /* NOCONTEXT */
 18412     if (__isExternalAddress(aWindowId)) {
 18413     if (__isExternalAddress(aWindowId)) {
 18413         HWND win = _HWNDVal(aWindowId);
 18414 	HWND win = _HWNDVal(aWindowId);
 18414         DWORD threadID, processID = 0;
 18415 	DWORD threadID, processID = 0;
 18415 
 18416 
 18416         if (! IsWindow(win)) {
 18417 	if (! IsWindow(win)) {
 18417             RETURN (false);
 18418 	    RETURN (false);
 18418         }
 18419 	}
 18419         threadID = GetWindowThreadProcessId(win, &processID);
 18420 	threadID = GetWindowThreadProcessId(win, &processID);
 18420         if ((threadID==0) || (processID==0)) {
 18421 	if ((threadID==0) || (processID==0)) {
 18421             RETURN (false);
 18422 	    RETURN (false);
 18422         }
 18423 	}
 18423         RETURN (true);
 18424 	RETURN (true);
 18424     }
 18425     }
 18425 %}.
 18426 %}.
 18426     self primitiveFailed.
 18427     self primitiveFailed.
 18427     ^ false
 18428     ^ false
 18428 
 18429 
 18447     "bring a window to back"
 18448     "bring a window to back"
 18448 
 18449 
 18449 %{  /* NOCONTEXT */
 18450 %{  /* NOCONTEXT */
 18450 
 18451 
 18451     if (__isExternalAddress(aWindowId)) {
 18452     if (__isExternalAddress(aWindowId)) {
 18452         HWND win = _HWNDVal(aWindowId);
 18453 	HWND win = _HWNDVal(aWindowId);
 18453 
 18454 
 18454         if (win) {
 18455 	if (win) {
 18455             CPRINTF(("lowerWindow %x\n",win));
 18456 	    CPRINTF(("lowerWindow %x\n",win));
 18456             SetWindowPos(win, HWND_BOTTOM, 0, 0, 0, 0,
 18457 	    SetWindowPos(win, HWND_BOTTOM, 0, 0, 0, 0,
 18457                          SWP_NOSENDCHANGING |
 18458 			 SWP_NOSENDCHANGING |
 18458                          SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
 18459 			 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
 18459         }
 18460 	}
 18460         RETURN ( self );
 18461 	RETURN ( self );
 18461     }
 18462     }
 18462 %}
 18463 %}
 18463 !
 18464 !
 18464 
 18465 
 18465 mapView:aView id:aWindowId iconified:aBoolean atX:x y:y width:w height:h minExtent:minExt maxExtent:maxExt
 18466 mapView:aView id:aWindowId iconified:aBoolean atX:x y:y width:w height:h minExtent:minExt maxExtent:maxExt
 18469      and to collaps/expand windows."
 18470      and to collaps/expand windows."
 18470 
 18471 
 18471     |minW minH maxW maxH|
 18472     |minW minH maxW maxH|
 18472 
 18473 
 18473     minExt notNil ifTrue:[
 18474     minExt notNil ifTrue:[
 18474         minW := minExt x.
 18475 	minW := minExt x.
 18475         minH := minExt y.
 18476 	minH := minExt y.
 18476     ].
 18477     ].
 18477     maxExt notNil ifTrue:[
 18478     maxExt notNil ifTrue:[
 18478         maxW := maxExt x.
 18479 	maxW := maxExt x.
 18479         maxH := maxExt y.
 18480 	maxH := maxExt y.
 18480     ].
 18481     ].
 18481 
 18482 
 18482 %{
 18483 %{
 18483     if (__isExternalAddress(aWindowId)) {
 18484     if (__isExternalAddress(aWindowId)) {
 18484         HWND win = _HWNDVal(aWindowId);
 18485 	HWND win = _HWNDVal(aWindowId);
 18485 
 18486 
 18486         if (win) {
 18487 	if (win) {
 18487             int bw = 0;
 18488 	    int bw = 0;
 18488             int flag = 0;
 18489 	    int flag = 0;
 18489             int __left, __top, __width, __height;
 18490 	    int __left, __top, __width, __height;
 18490             int winStyleBits;
 18491 	    int winStyleBits;
 18491             int winExStyleBits;
 18492 	    int winExStyleBits;
 18492             localWindowInfo *lI;
 18493 	    localWindowInfo *lI;
 18493 
 18494 
 18494             bw = GetWindow_bw(win);
 18495 	    bw = GetWindow_bw(win);
 18495             winStyleBits = GetWindowLong(win, GWL_STYLE);
 18496 	    winStyleBits = GetWindowLong(win, GWL_STYLE);
 18496             winExStyleBits = GetWindowLong(win, GWL_EXSTYLE);
 18497 	    winExStyleBits = GetWindowLong(win, GWL_EXSTYLE);
 18497             lI = GETLOCALWINDOWINFOPTR(win);
 18498 	    lI = GETLOCALWINDOWINFOPTR(win);
 18498             if (! lI) {
 18499 	    if (! lI) {
 18499                 console_fprintf(stderr, "WinWorkstation [info]: oops - no localInfo in mapView\n");
 18500 		console_fprintf(stderr, "WinWorkstation [info]: oops - no localInfo in mapView\n");
 18500                 RETURN (self);
 18501 		RETURN (self);
 18501             }
 18502 	    }
 18502 
 18503 
 18503             if (__bothSmallInteger(x, y)) {
 18504 	    if (__bothSmallInteger(x, y)) {
 18504                 __left = __intVal(x) + bw;
 18505 		__left = __intVal(x) + bw;
 18505                 __top = __intVal(y) + bw;
 18506 		__top = __intVal(y) + bw;
 18506             } else {
 18507 	    } else {
 18507                 __left = __top = 0;
 18508 		__left = __top = 0;
 18508                 flag |= SWP_NOMOVE;
 18509 		flag |= SWP_NOMOVE;
 18509             }
 18510 	    }
 18510             if (__bothSmallInteger(w, h)) {
 18511 	    if (__bothSmallInteger(w, h)) {
 18511                 __width = __intVal(w) - bw - bw;
 18512 		__width = __intVal(w) - bw - bw;
 18512                 __height = __intVal(h) - bw - bw;
 18513 		__height = __intVal(h) - bw - bw;
 18513             } else {
 18514 	    } else {
 18514                 __width = __height = 100;
 18515 		__width = __height = 100;
 18515                 flag |= SWP_NOSIZE;
 18516 		flag |= SWP_NOSIZE;
 18516             }
 18517 	    }
 18517 
 18518 
 18518             if (__bothSmallInteger(minW, minH)) {
 18519 	    if (__bothSmallInteger(minW, minH)) {
 18519                 RECT rec;
 18520 		RECT rec;
 18520 
 18521 
 18521                 rec.left = 0;
 18522 		rec.left = 0;
 18522                 rec.top = 0;
 18523 		rec.top = 0;
 18523                 rec.right = __intVal(minW);
 18524 		rec.right = __intVal(minW);
 18524                 rec.bottom = __intVal(minH);
 18525 		rec.bottom = __intVal(minH);
 18525 #ifdef ADJUSTWINDOW
 18526 #ifdef ADJUSTWINDOW
 18526                 AdjustWindowRectEx(&rec, winStyleBits, 0, winExStyleBits);
 18527 		AdjustWindowRectEx(&rec, winStyleBits, 0, winExStyleBits);
 18527 #endif
 18528 #endif
 18528                 lI->minWidth = rec.right - rec.left;
 18529 		lI->minWidth = rec.right - rec.left;
 18529                 lI->minHeight = rec.bottom - rec.top;
 18530 		lI->minHeight = rec.bottom - rec.top;
 18530             }
 18531 	    }
 18531             if (__bothSmallInteger(maxW, maxH)) {
 18532 	    if (__bothSmallInteger(maxW, maxH)) {
 18532                 RECT rec;
 18533 		RECT rec;
 18533 
 18534 
 18534                 rec.left = 0;
 18535 		rec.left = 0;
 18535                 rec.top = 0;
 18536 		rec.top = 0;
 18536                 rec.right = __intVal(maxW);
 18537 		rec.right = __intVal(maxW);
 18537                 rec.bottom = __intVal(maxH);
 18538 		rec.bottom = __intVal(maxH);
 18538 #ifdef ADJUSTWINDOW
 18539 #ifdef ADJUSTWINDOW
 18539                 AdjustWindowRectEx(&rec, winStyleBits, 0, winExStyleBits);
 18540 		AdjustWindowRectEx(&rec, winStyleBits, 0, winExStyleBits);
 18540 #endif
 18541 #endif
 18541                 lI->maxWidth = rec.right - rec.left;
 18542 		lI->maxWidth = rec.right - rec.left;
 18542                 lI->maxHeight = rec.bottom - rec.top;
 18543 		lI->maxHeight = rec.bottom - rec.top;
 18543             }
 18544 	    }
 18544 
 18545 
 18545 #ifdef ADJUSTWINDOW
 18546 #ifdef ADJUSTWINDOW
 18546             if (flag != (SWP_NOMOVE | SWP_NOSIZE)) {
 18547 	    if (flag != (SWP_NOMOVE | SWP_NOSIZE)) {
 18547                 RECT rec;
 18548 		RECT rec;
 18548                 int __left0, __top0, __width0, __height0;
 18549 		int __left0, __top0, __width0, __height0;
 18549 
 18550 
 18550                 __left0   = __left;
 18551 		__left0   = __left;
 18551                 __top0    = __top;
 18552 		__top0    = __top;
 18552                 __width0  = __width;
 18553 		__width0  = __width;
 18553                 __height0 = __height;
 18554 		__height0 = __height;
 18554 
 18555 
 18555                 rec.left = __left;
 18556 		rec.left = __left;
 18556                 // rec.left = __left-2;
 18557 		// rec.left = __left-2;
 18557                 rec.top = __top;
 18558 		rec.top = __top;
 18558                 // rec.top = __top-2;
 18559 		// rec.top = __top-2;
 18559                 rec.right = rec.left + __width;
 18560 		rec.right = rec.left + __width;
 18560                 rec.bottom = rec.top + __height;
 18561 		rec.bottom = rec.top + __height;
 18561                 AdjustWindowRectEx(&rec, winStyleBits, 0, winExStyleBits);
 18562 		AdjustWindowRectEx(&rec, winStyleBits, 0, winExStyleBits);
 18562 
 18563 
 18563                 __left = rec.left;
 18564 		__left = rec.left;
 18564                 __top = rec.top;
 18565 		__top = rec.top;
 18565                 __width = rec.right - rec.left;
 18566 		__width = rec.right - rec.left;
 18566                 __height = rec.bottom - rec.top;
 18567 		__height = rec.bottom - rec.top;
 18567 
 18568 
 18568                 CPRINTF(("mapView %x %d/%d %d/%d -> %d/%d %d/%d\n",
 18569 		CPRINTF(("mapView %x %d/%d %d/%d -> %d/%d %d/%d\n",
 18569                          win,
 18570 			 win,
 18570                          __left0, __top0, __width0, __height0,
 18571 			 __left0, __top0, __width0, __height0,
 18571                          __left, __top, __width, __height));
 18572 			 __left, __top, __width, __height));
 18572             }
 18573 	    }
 18573 #else
 18574 #else
 18574             CPRINTF(("mapView %x %d/%d %d/%d\n",
 18575 	    CPRINTF(("mapView %x %d/%d %d/%d\n",
 18575                      win,
 18576 		     win,
 18576                      __left, __top, __width, __height));
 18577 		     __left, __top, __width, __height));
 18577 #endif
 18578 #endif
 18578 
 18579 
 18579             flag |= SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOZORDER | SWP_NOOWNERZORDER;
 18580 	    flag |= SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOZORDER | SWP_NOOWNERZORDER;
 18580 
 18581 
 18581             if (aBoolean == true) {
 18582 	    if (aBoolean == true) {
 18582                 /* iconified */
 18583 		/* iconified */
 18583 //              SetWindowPos(win, (HWND)0,
 18584 //              SetWindowPos(win, (HWND)0,
 18584 //                           __left, __top, __width, __height,
 18585 //                           __left, __top, __width, __height,
 18585 //                           flag);
 18586 //                           flag);
 18586 //                ShowWindow(win, SW_SHOWMINIMIZED);
 18587 //                ShowWindow(win, SW_SHOWMINIMIZED);
 18587                 ShowWindowAsync(win, SW_SHOWMINNOACTIVE);
 18588 		ShowWindowAsync(win, SW_SHOWMINNOACTIVE);
 18588 /*
 18589 /*
 18589                 enqEvent(0, win, WM_SHOWWINDOW, FALSE, 0, 0, 0, 0, EV_NOTIME);
 18590 		enqEvent(0, win, WM_SHOWWINDOW, FALSE, 0, 0, 0, 0, EV_NOTIME);
 18590 */
 18591 */
 18591             } else {
 18592 	    } else {
 18592                 /* normal */
 18593 		/* normal */
 18593                 SetWindowPos(win, (HWND)0,
 18594 		SetWindowPos(win, (HWND)0,
 18594                              __left, __top, __width, __height,
 18595 			     __left, __top, __width, __height,
 18595                              flag);
 18596 			     flag);
 18596 /*
 18597 /*
 18597                 enqEvent(0, win, WM_SHOWWINDOW, TRUE, 0, 0, 0, 0, EV_NOTIME);
 18598 		enqEvent(0, win, WM_SHOWWINDOW, TRUE, 0, 0, 0, 0, EV_NOTIME);
 18598 */
 18599 */
 18599                 //ShowWindow(win, SW_RESTORE);
 18600 		//ShowWindow(win, SW_RESTORE);
 18600                 // ShowWindowAsync(win, SW_RESTORE);
 18601 		// ShowWindowAsync(win, SW_RESTORE);
 18601                 ShowWindowAsync(win, SW_SHOWNOACTIVATE);
 18602 		ShowWindowAsync(win, SW_SHOWNOACTIVATE);
 18602             }
 18603 	    }
 18603         }
 18604 	}
 18604         RETURN ( self );
 18605 	RETURN ( self );
 18605     }
 18606     }
 18606 %}
 18607 %}
 18607 !
 18608 !
 18608 
 18609 
 18609 mapWindow:aWindowId
 18610 mapWindow:aWindowId
 18610     "make a window visible"
 18611     "make a window visible"
 18611 
 18612 
 18612 %{  /* NOCONTEXT */
 18613 %{  /* NOCONTEXT */
 18613 
 18614 
 18614     if (__isExternalAddress(aWindowId)) {
 18615     if (__isExternalAddress(aWindowId)) {
 18615         HWND hWnd = _HWNDVal(aWindowId);
 18616 	HWND hWnd = _HWNDVal(aWindowId);
 18616 
 18617 
 18617         if (hWnd) {
 18618 	if (hWnd) {
 18618             CPRINTF(("mapWindow %x\n", hWnd));
 18619 	    CPRINTF(("mapWindow %x\n", hWnd));
 18619             if (GetParent(hWnd) == 0) {
 18620 	    if (GetParent(hWnd) == 0) {
 18620                 ShowWindowAsync(hWnd, SW_SHOWNOACTIVATE);
 18621 		ShowWindowAsync(hWnd, SW_SHOWNOACTIVATE);
 18621             } else {
 18622 	    } else {
 18622                 ShowWindowAsync(hWnd, SW_SHOWNORMAL);
 18623 		ShowWindowAsync(hWnd, SW_SHOWNORMAL);
 18623             }
 18624 	    }
 18624         }
 18625 	}
 18625         RETURN ( self );
 18626 	RETURN ( self );
 18626     }
 18627     }
 18627 %}
 18628 %}
 18628 !
 18629 !
 18629 
 18630 
 18630 mapWindow:aWindowId animation:animationSymbolorNil time:timeInMillisOrNil
 18631 mapWindow:aWindowId animation:animationSymbolorNil time:timeInMillisOrNil
 18639 %{  /* NOCONTEXT */
 18640 %{  /* NOCONTEXT */
 18640     RECT rec;
 18641     RECT rec;
 18641     if (__isExternalAddress(aWindowId)
 18642     if (__isExternalAddress(aWindowId)
 18642      && __bothSmallInteger(x, y)
 18643      && __bothSmallInteger(x, y)
 18643      && __bothSmallInteger(w, h)) {
 18644      && __bothSmallInteger(w, h)) {
 18644         HWND win = _HWNDVal(aWindowId);
 18645 	HWND win = _HWNDVal(aWindowId);
 18645         int bw = 0;
 18646 	int bw = 0;
 18646 
 18647 
 18647         if (win) {
 18648 	if (win) {
 18648             bw = GetWindow_bw(win);
 18649 	    bw = GetWindow_bw(win);
 18649 
 18650 
 18650             rec.left = __intVal(x) + bw;
 18651 	    rec.left = __intVal(x) + bw;
 18651             rec.top = __intVal(y) + bw;
 18652 	    rec.top = __intVal(y) + bw;
 18652             rec.right = rec.left + __intVal(w) - bw - bw;
 18653 	    rec.right = rec.left + __intVal(w) - bw - bw;
 18653             rec.bottom = rec.top + __intVal(h) - bw - bw;
 18654 	    rec.bottom = rec.top + __intVal(h) - bw - bw;
 18654             if (GetParent(win) == 0) {
 18655 	    if (GetParent(win) == 0) {
 18655 #ifdef ADJUSTWINDOW
 18656 #ifdef ADJUSTWINDOW
 18656                 AdjustWindowRectEx(&rec,GetWindowLong(win,GWL_STYLE),0,GetWindowLong(win,GWL_EXSTYLE));
 18657 		AdjustWindowRectEx(&rec,GetWindowLong(win,GWL_STYLE),0,GetWindowLong(win,GWL_EXSTYLE));
 18657 #endif
 18658 #endif
 18658             }
 18659 	    }
 18659             CPRINTF(("moveresize %x x:%d y:%d w:%d h:%d -> x:%d y:%d w:%d h:%d\n",win,__intVal(x),__intVal(y),__intVal(w),__intVal(h),rec.left,rec.top,
 18660 	    CPRINTF(("moveresize %x x:%d y:%d w:%d h:%d -> x:%d y:%d w:%d h:%d\n",win,__intVal(x),__intVal(y),__intVal(w),__intVal(h),rec.left,rec.top,
 18660                          rec.right - rec.left, rec.bottom - rec.top));
 18661 			 rec.right - rec.left, rec.bottom - rec.top));
 18661             SetWindowPos(win, (HWND)0,
 18662 	    SetWindowPos(win, (HWND)0,
 18662                          rec.left, rec.top,
 18663 			 rec.left, rec.top,
 18663                          rec.right - rec.left, rec.bottom - rec.top,
 18664 			 rec.right - rec.left, rec.bottom - rec.top,
 18664                          SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOOWNERZORDER);
 18665 			 SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOOWNERZORDER);
 18665         }
 18666 	}
 18666         RETURN ( self );
 18667 	RETURN ( self );
 18667     }
 18668     }
 18668 %}
 18669 %}
 18669 !
 18670 !
 18670 
 18671 
 18671 moveWindow:aWindowId x:x y:y
 18672 moveWindow:aWindowId x:x y:y
 18674 %{  /* NOCONTEXT */
 18675 %{  /* NOCONTEXT */
 18675     RECT rec;
 18676     RECT rec;
 18676 
 18677 
 18677     if (__isExternalAddress(aWindowId)
 18678     if (__isExternalAddress(aWindowId)
 18678      && __bothSmallInteger(x, y)) {
 18679      && __bothSmallInteger(x, y)) {
 18679         HWND win = _HWNDVal(aWindowId);
 18680 	HWND win = _HWNDVal(aWindowId);
 18680         int bw = 0;
 18681 	int bw = 0;
 18681 
 18682 
 18682         if (win) {
 18683 	if (win) {
 18683             bw = GetWindow_bw(win);
 18684 	    bw = GetWindow_bw(win);
 18684 
 18685 
 18685             rec.left = __intVal(x) + bw;
 18686 	    rec.left = __intVal(x) + bw;
 18686             rec.top = __intVal(y) + bw;
 18687 	    rec.top = __intVal(y) + bw;
 18687             if (GetParent(win) == 0) {
 18688 	    if (GetParent(win) == 0) {
 18688                 rec.right = rec.left + 10;  /* only needed to give adjust some valid numbers */
 18689 		rec.right = rec.left + 10;  /* only needed to give adjust some valid numbers */
 18689                 rec.bottom = rec.top + 10;
 18690 		rec.bottom = rec.top + 10;
 18690 #ifdef ADJUSTWINDOW
 18691 #ifdef ADJUSTWINDOW
 18691                 AdjustWindowRectEx(&rec, GetWindowLong(win,GWL_STYLE), 0, GetWindowLong(win,GWL_EXSTYLE));
 18692 		AdjustWindowRectEx(&rec, GetWindowLong(win,GWL_STYLE), 0, GetWindowLong(win,GWL_EXSTYLE));
 18692 #endif
 18693 #endif
 18693             }
 18694 	    }
 18694             CPRINTF(("move %x x:%d y:%d -> x:%d y:%d\n", win,
 18695 	    CPRINTF(("move %x x:%d y:%d -> x:%d y:%d\n", win,
 18695                         __intVal(x), __intVal(y), rec.left, rec.top));
 18696 			__intVal(x), __intVal(y), rec.left, rec.top));
 18696             SetWindowPos(win, (HWND)0,
 18697 	    SetWindowPos(win, (HWND)0,
 18697                          rec.left, rec.top,
 18698 			 rec.left, rec.top,
 18698                          0, 0,
 18699 			 0, 0,
 18699                          SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
 18700 			 SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
 18700         }
 18701 	}
 18701         RETURN ( self );
 18702 	RETURN ( self );
 18702     }
 18703     }
 18703 %}
 18704 %}
 18704 !
 18705 !
 18705 
 18706 
 18706 primEnumChildWindowsOf:aWindowId into:handleList
 18707 primEnumChildWindowsOf:aWindowId into:handleList
 18707 %{
 18708 %{
 18708     if (__isExternalAddress(aWindowId)) {
 18709     if (__isExternalAddress(aWindowId)) {
 18709         HWND hwParent = _HWNDVal(aWindowId);
 18710 	HWND hwParent = _HWNDVal(aWindowId);
 18710 
 18711 
 18711         if ( EnumChildWindows( hwParent, EnumWindowsProc, (INT)&(handleList))) {
 18712 	if ( EnumChildWindows( hwParent, EnumWindowsProc, (INT)&(handleList))) {
 18712             DPRINTF(("EnumChildWindows successful\n"));
 18713 	    DPRINTF(("EnumChildWindows successful\n"));
 18713         }
 18714 	}
 18714     }
 18715     }
 18715 %}
 18716 %}
 18716 !
 18717 !
 18717 
 18718 
 18718 primEnumWindowsInto:handleList
 18719 primEnumWindowsInto:handleList
 18719 %{
 18720 %{
 18720     if ( EnumWindows( EnumWindowsProc, (INT)&(handleList))) {
 18721     if ( EnumWindows( EnumWindowsProc, (INT)&(handleList))) {
 18721         DPRINTF(("EnumWindows successful\n"));
 18722 	DPRINTF(("EnumWindows successful\n"));
 18722     }
 18723     }
 18723 %}
 18724 %}
 18724 !
 18725 !
 18725 
 18726 
 18726 primEnumWindowsOf:threadId into:handleList
 18727 primEnumWindowsOf:threadId into:handleList
 18727 %{
 18728 %{
 18728     if (__isSmallInteger(threadId)) {
 18729     if (__isSmallInteger(threadId)) {
 18729         if ( EnumThreadWindows( __intVal(threadId), EnumWindowsProc, (INT)&(handleList))) {
 18730 	if ( EnumThreadWindows( __intVal(threadId), EnumWindowsProc, (INT)&(handleList))) {
 18730             DPRINTF(("EnumThreadWindows successful\n"));
 18731 	    DPRINTF(("EnumThreadWindows successful\n"));
 18731         }
 18732 	}
 18732     }
 18733     }
 18733 %}
 18734 %}
 18734 !
 18735 !
 18735 
 18736 
 18736 primFindWindowA:lpClassName windowName:lpWindowName
 18737 primFindWindowA:lpClassName windowName:lpWindowName
 18802 
 18803 
 18803     DPRINTF(("primSetWindowIconId\n"));
 18804     DPRINTF(("primSetWindowIconId\n"));
 18804     if (__isExternalAddress(aWindowId)
 18805     if (__isExternalAddress(aWindowId)
 18805      && __isExternalAddress(wiconId)
 18806      && __isExternalAddress(wiconId)
 18806      && __bothSmallInteger(wiconWidth, wiconHeight)) {
 18807      && __bothSmallInteger(wiconWidth, wiconHeight)) {
 18807         HWND win = _HWNDVal(aWindowId);
 18808 	HWND win = _HWNDVal(aWindowId);
 18808 
 18809 
 18809         xBitMap = _HBITMAPVAL( wiconId );
 18810 	xBitMap = _HBITMAPVAL( wiconId );
 18810         if ( xBitMap != 0 ) {
 18811 	if ( xBitMap != 0 ) {
 18811             BITMAP bm;
 18812 	    BITMAP bm;
 18812 
 18813 
 18813             if (GetObject(xBitMap, sizeof(bm), (LPSTR)&bm)) {
 18814 	    if (GetObject(xBitMap, sizeof(bm), (LPSTR)&bm)) {
 18814                 BYTE *ep;
 18815 		BYTE *ep;
 18815                 int privateMask = 0;
 18816 		int privateMask = 0;
 18816                 unsigned char  *allocatedBits = 0;
 18817 		unsigned char  *allocatedBits = 0;
 18817 
 18818 
 18818                 DPRINTF(("Bitmap w:%d h:%d p:%d d:%d\n",bm.bmWidth,bm.bmHeight,bm.bmPlanes,bm.bmBitsPixel));
 18819 		DPRINTF(("Bitmap w:%d h:%d p:%d d:%d\n",bm.bmWidth,bm.bmHeight,bm.bmPlanes,bm.bmBitsPixel));
 18819                 height = __intVal( wiconHeight );
 18820 		height = __intVal( wiconHeight );
 18820                 width  = __intVal( wiconWidth  );
 18821 		width  = __intVal( wiconWidth  );
 18821 
 18822 
 18822                 if ( __isExternalAddress(wmaskId) ) {
 18823 		if ( __isExternalAddress(wmaskId) ) {
 18823                     maskBitmap = _HBITMAPVAL( wmaskId );
 18824 		    maskBitmap = _HBITMAPVAL( wmaskId );
 18824                 } else {
 18825 		} else {
 18825                     if (wmaskId != nil) {
 18826 		    if (wmaskId != nil) {
 18826                         PRINTF(("WinWorkstat [warning]: wmaskId is not an external address\n"));
 18827 			PRINTF(("WinWorkstat [warning]: wmaskId is not an external address\n"));
 18827                     }
 18828 		    }
 18828                     maskBitmap = 0;
 18829 		    maskBitmap = 0;
 18829                 }
 18830 		}
 18830 
 18831 
 18831                 /*
 18832 		/*
 18832                  * if there is no mask, generate one
 18833 		 * if there is no mask, generate one
 18833                  */
 18834 		 */
 18834                 if (maskBitmap == 0) {
 18835 		if (maskBitmap == 0) {
 18835                     int nBytes;
 18836 		    int nBytes;
 18836 
 18837 
 18837                     nBytes = ( width + 31 ) / 8;
 18838 		    nBytes = ( width + 31 ) / 8;
 18838                     nBytes = height * nBytes;
 18839 		    nBytes = height * nBytes;
 18839                     if (nBytes < sizeof(fastBits)) {
 18840 		    if (nBytes < sizeof(fastBits)) {
 18840                         ep = fastBits;
 18841 			ep = fastBits;
 18841                     } else {
 18842 		    } else {
 18842                         ep = allocatedBits = (unsigned char *) malloc(nBytes);
 18843 			ep = allocatedBits = (unsigned char *) malloc(nBytes);
 18843                     }
 18844 		    }
 18844                     if ( ep == 0 ) {
 18845 		    if ( ep == 0 ) {
 18845                         PRINTF(( "WinWorkstat [warning]: malloc failed\n" ));
 18846 			PRINTF(( "WinWorkstat [warning]: malloc failed\n" ));
 18846                     } else {
 18847 		    } else {
 18847                         memset(ep, 0, nBytes);
 18848 			memset(ep, 0, nBytes);
 18848                         maskBitmap = CreateBitmap(width, height, 1, 1, ep );
 18849 			maskBitmap = CreateBitmap(width, height, 1, 1, ep );
 18849                         if ( maskBitmap == NULL ) {
 18850 			if ( maskBitmap == NULL ) {
 18850                             PRINTF(( "WinWorkstat [warning]: mask CREATION failed\n" ));
 18851 			    PRINTF(( "WinWorkstat [warning]: mask CREATION failed\n" ));
 18851                         } else {
 18852 			} else {
 18852                             privateMask = 1;
 18853 			    privateMask = 1;
 18853                         }
 18854 			}
 18854                     }
 18855 		    }
 18855                 }
 18856 		}
 18856                 if ( maskBitmap != NULL ) {
 18857 		if ( maskBitmap != NULL ) {
 18857                     DPRINTF(( "BITMAP mask CREATED!!!\n" ));
 18858 		    DPRINTF(( "BITMAP mask CREATED!!!\n" ));
 18858                     iconInfo.fIcon = TRUE;
 18859 		    iconInfo.fIcon = TRUE;
 18859                     iconInfo.hbmMask  =maskBitmap;
 18860 		    iconInfo.hbmMask  =maskBitmap;
 18860                     iconInfo.hbmColor = xBitMap;
 18861 		    iconInfo.hbmColor = xBitMap;
 18861                     xIcon = CreateIconIndirect( &iconInfo );
 18862 		    xIcon = CreateIconIndirect( &iconInfo );
 18862                     DPRINTF(( "ICON CREATED!!!\n" ));
 18863 		    DPRINTF(( "ICON CREATED!!!\n" ));
 18863                     if (privateMask) {
 18864 		    if (privateMask) {
 18864                         _DeleteObject( maskBitmap, __LINE__ );
 18865 			_DeleteObject( maskBitmap, __LINE__ );
 18865                     }
 18866 		    }
 18866                 } else {
 18867 		} else {
 18867                     PRINTF(( "WinWorkstat [warning]: no mask for icon !\n" ));
 18868 		    PRINTF(( "WinWorkstat [warning]: no mask for icon !\n" ));
 18868                 }
 18869 		}
 18869 
 18870 
 18870                 if (allocatedBits) {
 18871 		if (allocatedBits) {
 18871                     free(allocatedBits);
 18872 		    free(allocatedBits);
 18872                 }
 18873 		}
 18873             }
 18874 	    }
 18874         } else {
 18875 	} else {
 18875             DPRINTF(("WinWorkstat [warning]: xBitMap is zero \n" ));
 18876 	    DPRINTF(("WinWorkstat [warning]: xBitMap is zero \n" ));
 18876         }
 18877 	}
 18877 
 18878 
 18878         if (xIcon) {
 18879 	if (xIcon) {
 18879 #ifndef TOPWINDOWCLASS
 18880 #ifndef TOPWINDOWCLASS
 18880             HICON oldIcon = (HICON)0;
 18881 	    HICON oldIcon = (HICON)0;
 18881 
 18882 
 18882 # ifdef _WIN64
 18883 # ifdef _WIN64
 18883             oldIcon = (HICON) GetClassLongPtr(win, GCLP_HICON);
 18884 	    oldIcon = (HICON) GetClassLongPtr(win, GCLP_HICON);
 18884             SetClassLongPtr(win, GCLP_HICON, (INT)xIcon);
 18885 	    SetClassLongPtr(win, GCLP_HICON, (INT)xIcon);
 18885 # else
 18886 # else
 18886             oldIcon = (HICON) GetClassLong(win, GCL_HICON);
 18887 	    oldIcon = (HICON) GetClassLong(win, GCL_HICON);
 18887             SetClassLong(win, GCL_HICON, (DWORD)xIcon);
 18888 	    SetClassLong(win, GCL_HICON, (DWORD)xIcon);
 18888 # endif
 18889 # endif
 18889 /* It has to be checked whether this can be deleted!!!!! */
 18890 /* It has to be checked whether this can be deleted!!!!! */
 18890             if ( oldIcon ) {
 18891 	    if ( oldIcon ) {
 18891                 if (DestroyIcon( oldIcon )) {
 18892 		if (DestroyIcon( oldIcon )) {
 18892                     DPRINTF(( "Old icon deleted\n" ));
 18893 		    DPRINTF(( "Old icon deleted\n" ));
 18893                 } else {
 18894 		} else {
 18894                     console_fprintf(stderr, "failed to delete old icon\n");
 18895 		    console_fprintf(stderr, "failed to delete old icon\n");
 18895                 }
 18896 		}
 18896             }
 18897 	    }
 18897 #else
 18898 #else
 18898             SendMessage(win, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)xIcon);
 18899 	    SendMessage(win, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)xIcon);
 18899             SendMessage(win, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)xIcon);
 18900 	    SendMessage(win, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)xIcon);
 18900 #endif
 18901 #endif
 18901         }
 18902 	}
 18902         RETURN (self);
 18903 	RETURN (self);
 18903     }
 18904     }
 18904 %}
 18905 %}
 18905 !
 18906 !
 18906 
 18907 
 18907 raiseWindow:aWindowId
 18908 raiseWindow:aWindowId
 18910      as topmost, when it gets the focus)"
 18911      as topmost, when it gets the focus)"
 18911 
 18912 
 18912 %{  /* NOCONTEXT */
 18913 %{  /* NOCONTEXT */
 18913 
 18914 
 18914     if (__isExternalAddress(aWindowId)) {
 18915     if (__isExternalAddress(aWindowId)) {
 18915         HWND hWnd = _HWNDVal(aWindowId);
 18916 	HWND hWnd = _HWNDVal(aWindowId);
 18916 
 18917 
 18917         if (hWnd) {
 18918 	if (hWnd) {
 18918             CPRINTF(("raiseWindow %x\n",hWnd));
 18919 	    CPRINTF(("raiseWindow %x\n",hWnd));
 18919             SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
 18920 	    SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
 18920                          /* SWP_NOOWNERZORDER |*/
 18921 			 /* SWP_NOOWNERZORDER |*/
 18921                         SWP_NOSENDCHANGING | SWP_NOACTIVATE |
 18922 			SWP_NOSENDCHANGING | SWP_NOACTIVATE |
 18922                         SWP_NOMOVE | SWP_NOSIZE);
 18923 			SWP_NOMOVE | SWP_NOSIZE);
 18923         }
 18924 	}
 18924     }
 18925     }
 18925 %}
 18926 %}
 18926 !
 18927 !
 18927 
 18928 
 18928 raiseWindowToTop:aWindowId
 18929 raiseWindowToTop:aWindowId
 18930      Q: is this a windows-specific thing ?"
 18931      Q: is this a windows-specific thing ?"
 18931 
 18932 
 18932 %{  /* NOCONTEXT */
 18933 %{  /* NOCONTEXT */
 18933 
 18934 
 18934     if (__isExternalAddress(aWindowId)) {
 18935     if (__isExternalAddress(aWindowId)) {
 18935         HWND hWnd = _HWNDVal(aWindowId);
 18936 	HWND hWnd = _HWNDVal(aWindowId);
 18936 
 18937 
 18937         if (hWnd) {
 18938 	if (hWnd) {
 18938             CPRINTF(("raiseWindow %x\n",hWnd));
 18939 	    CPRINTF(("raiseWindow %x\n",hWnd));
 18939 
 18940 
 18940             SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0,
 18941 	    SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0,
 18941                          /* SWP_NOOWNERZORDER |*/
 18942 			 /* SWP_NOOWNERZORDER |*/
 18942                         SWP_NOSENDCHANGING | SWP_NOACTIVATE |
 18943 			SWP_NOSENDCHANGING | SWP_NOACTIVATE |
 18943                         SWP_NOMOVE | SWP_NOSIZE);
 18944 			SWP_NOMOVE | SWP_NOSIZE);
 18944 
 18945 
 18945             SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0,
 18946 	    SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0,
 18946                          /* SWP_NOOWNERZORDER |*/
 18947 			 /* SWP_NOOWNERZORDER |*/
 18947                         SWP_NOSENDCHANGING | SWP_NOACTIVATE |
 18948 			SWP_NOSENDCHANGING | SWP_NOACTIVATE |
 18948                         SWP_NOMOVE | SWP_NOSIZE);
 18949 			SWP_NOMOVE | SWP_NOSIZE);
 18949 
 18950 
 18950             SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
 18951 	    SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
 18951                         /* SWP_NOOWNERZORDER | */
 18952 			/* SWP_NOOWNERZORDER | */
 18952                         /* SWP_NOSENDCHANGING | SWP_NOACTIVATE | */
 18953 			/* SWP_NOSENDCHANGING | SWP_NOACTIVATE | */
 18953                         SWP_NOMOVE | SWP_NOSIZE);
 18954 			SWP_NOMOVE | SWP_NOSIZE);
 18954 
 18955 
 18955             SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
 18956 	    SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
 18956                         /* SWP_NOOWNERZORDER | */
 18957 			/* SWP_NOOWNERZORDER | */
 18957                         /* SWP_NOSENDCHANGING | SWP_NOACTIVATE | */
 18958 			/* SWP_NOSENDCHANGING | SWP_NOACTIVATE | */
 18958                         SWP_NOMOVE | SWP_NOSIZE);
 18959 			SWP_NOMOVE | SWP_NOSIZE);
 18959         }
 18960 	}
 18960     }
 18961     }
 18961 %}
 18962 %}
 18962 !
 18963 !
 18963 
 18964 
 18964 raiseWindowToTopMost:aWindowId
 18965 raiseWindowToTopMost:aWindowId
 18966      Q: is this a windows-specific thing ?"
 18967      Q: is this a windows-specific thing ?"
 18967 
 18968 
 18968 %{  /* NOCONTEXT */
 18969 %{  /* NOCONTEXT */
 18969 
 18970 
 18970     if (__isExternalAddress(aWindowId)) {
 18971     if (__isExternalAddress(aWindowId)) {
 18971         HWND hWnd = _HWNDVal(aWindowId);
 18972 	HWND hWnd = _HWNDVal(aWindowId);
 18972 
 18973 
 18973         if (hWnd) {
 18974 	if (hWnd) {
 18974             CPRINTF(("raiseWindow %x\n",hWnd));
 18975 	    CPRINTF(("raiseWindow %x\n",hWnd));
 18975             SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
 18976 	    SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
 18976         }
 18977 	}
 18977     }
 18978     }
 18978 %}
 18979 %}
 18979 !
 18980 !
 18980 
 18981 
 18981 reparentWindow:windowId to:newParentWindowId
 18982 reparentWindow:windowId to:newParentWindowId
 18982     "change a windows parent (an optional interface)"
 18983     "change a windows parent (an optional interface)"
 18983 
 18984 
 18984 %{  /* NOCONTEXT */
 18985 %{  /* NOCONTEXT */
 18985     if (__isExternalAddress(windowId)
 18986     if (__isExternalAddress(windowId)
 18986      && __isExternalAddress(newParentWindowId)) {
 18987      && __isExternalAddress(newParentWindowId)) {
 18987         HWND hWnd = _HWNDVal(windowId);
 18988 	HWND hWnd = _HWNDVal(windowId);
 18988         HWND hWndNewParent = _HWNDVal(newParentWindowId);
 18989 	HWND hWndNewParent = _HWNDVal(newParentWindowId);
 18989 
 18990 
 18990         SetParent(hWnd, hWndNewParent);
 18991 	SetParent(hWnd, hWndNewParent);
 18991         RETURN ( true );
 18992 	RETURN ( true );
 18992     }
 18993     }
 18993 %}.
 18994 %}.
 18994     self primitiveFailed
 18995     self primitiveFailed
 18995 !
 18996 !
 18996 
 18997 
 19000 %{  /* NOCONTEXT */
 19001 %{  /* NOCONTEXT */
 19001     RECT rec;
 19002     RECT rec;
 19002 
 19003 
 19003     if (__isExternalAddress(aWindowId)
 19004     if (__isExternalAddress(aWindowId)
 19004      && __bothSmallInteger(w, h)) {
 19005      && __bothSmallInteger(w, h)) {
 19005         HWND hWnd = _HWNDVal(aWindowId);
 19006 	HWND hWnd = _HWNDVal(aWindowId);
 19006         int bw;
 19007 	int bw;
 19007 
 19008 
 19008         if (hWnd) {
 19009 	if (hWnd) {
 19009             bw = GetWindow_bw(hWnd);
 19010 	    bw = GetWindow_bw(hWnd);
 19010 
 19011 
 19011             rec.left = 0;  /* only needed to have a valid origin in adjust */
 19012 	    rec.left = 0;  /* only needed to have a valid origin in adjust */
 19012             rec.top = 0;   /* only needed to have a valid origin in adjust */
 19013 	    rec.top = 0;   /* only needed to have a valid origin in adjust */
 19013             rec.right = __intVal(w) - bw - bw;
 19014 	    rec.right = __intVal(w) - bw - bw;
 19014             rec.bottom = __intVal(h) - bw - bw;
 19015 	    rec.bottom = __intVal(h) - bw - bw;
 19015 #ifdef ADJUSTWINDOW
 19016 #ifdef ADJUSTWINDOW
 19016             AdjustWindowRectEx(&rec, GetWindowLong(hWnd, GWL_STYLE), 0, GetWindowLong(hWnd, GWL_EXSTYLE));
 19017 	    AdjustWindowRectEx(&rec, GetWindowLong(hWnd, GWL_STYLE), 0, GetWindowLong(hWnd, GWL_EXSTYLE));
 19017 #endif
 19018 #endif
 19018             CPRINTF(("resize %x w:%d h:%d -> w:%d h:%d\n",hWnd,__intVal(w),__intVal(h),rec.right - rec.left, rec.bottom - rec.top));
 19019 	    CPRINTF(("resize %x w:%d h:%d -> w:%d h:%d\n",hWnd,__intVal(w),__intVal(h),rec.right - rec.left, rec.bottom - rec.top));
 19019             SetWindowPos(hWnd, (HWND)0,
 19020 	    SetWindowPos(hWnd, (HWND)0,
 19020                          0, 0,
 19021 			 0, 0,
 19021                          rec.right - rec.left, rec.bottom - rec.top,
 19022 			 rec.right - rec.left, rec.bottom - rec.top,
 19022                          SWP_NOSENDCHANGING | SWP_NOACTIVATE |
 19023 			 SWP_NOSENDCHANGING | SWP_NOACTIVATE |
 19023                          SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);
 19024 			 SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);
 19024         }
 19025 	}
 19025         RETURN ( self );
 19026 	RETURN ( self );
 19026     }
 19027     }
 19027 %}
 19028 %}
 19028 !
 19029 !
 19029 
 19030 
 19030 sendButtonMessageType:messageType at:aPoint toWindowId:aWindowId
 19031 sendButtonMessageType:messageType at:aPoint toWindowId:aWindowId
 19060 
 19061 
 19061     |messageType|
 19062     |messageType|
 19062 
 19063 
 19063     self assert:(button between:1 and:3).
 19064     self assert:(button between:1 and:3).
 19064     messageType := #(   16r0201 "WM_LBUTTONDOWN"
 19065     messageType := #(   16r0201 "WM_LBUTTONDOWN"
 19065                         16r0207 "WM_MBUTTONDOWN"
 19066 			16r0207 "WM_MBUTTONDOWN"
 19066                         16r0204 "WM_RBUTTONDOWN"  ) at:button.
 19067 			16r0204 "WM_RBUTTONDOWN"  ) at:button.
 19067 
 19068 
 19068     self sendButtonMessageType:messageType at:aPoint toWindowId:aWindowId
 19069     self sendButtonMessageType:messageType at:aPoint toWindowId:aWindowId
 19069 
 19070 
 19070     "
 19071     "
 19071      |v b externalAddress handle|
 19072      |v b externalAddress handle|
 19088 
 19089 
 19089     |messageType|
 19090     |messageType|
 19090 
 19091 
 19091     self assert:(button between:1 and:3).
 19092     self assert:(button between:1 and:3).
 19092     messageType := #(   16r0202 "WM_LBUTTONUP"
 19093     messageType := #(   16r0202 "WM_LBUTTONUP"
 19093                         16r0208 "WM_MBUTTONUP"
 19094 			16r0208 "WM_MBUTTONUP"
 19094                         16r0205 "WM_RBUTTONUP"  ) at:button.
 19095 			16r0205 "WM_RBUTTONUP"  ) at:button.
 19095 
 19096 
 19096     self sendButtonMessageType:messageType at:aPoint toWindowId:aWindowId
 19097     self sendButtonMessageType:messageType at:aPoint toWindowId:aWindowId
 19097 
 19098 
 19098     "
 19099     "
 19099      |v b externalAddress handle|
 19100      |v b externalAddress handle|
 19121     messageType := 74 "WM_COPYDATA".
 19122     messageType := 74 "WM_COPYDATA".
 19122 
 19123 
 19123     externalBytes := aByteArrayOrString asExternalBytesUnprotected.
 19124     externalBytes := aByteArrayOrString asExternalBytesUnprotected.
 19124     copyDataStruct := CopyDataStructStructure new.
 19125     copyDataStruct := CopyDataStructStructure new.
 19125     copyDataStruct
 19126     copyDataStruct
 19126         cbData:externalBytes size;
 19127 	cbData:externalBytes size;
 19127         lpData:externalBytes address.
 19128 	lpData:externalBytes address.
 19128     lParam := copyDataStruct asExternalBytesUnprotected.
 19129     lParam := copyDataStruct asExternalBytesUnprotected.
 19129     ^ self primSendMessage:aWindowId message:messageType wParam:nil lParam:lParam.
 19130     ^ self primSendMessage:aWindowId message:messageType wParam:nil lParam:lParam.
 19130 
 19131 
 19131     "
 19132     "
 19132      |handle|
 19133      |handle|
 19167     HCURSOR newCursor;
 19168     HCURSOR newCursor;
 19168 
 19169 
 19169     if (ISCONNECTED
 19170     if (ISCONNECTED
 19170      && __isExternalAddress(aWindowId)
 19171      && __isExternalAddress(aWindowId)
 19171      && __isExternalAddress(aCursorId)) {
 19172      && __isExternalAddress(aCursorId)) {
 19172         HWND win = _HWNDVal(aWindowId);
 19173 	HWND win = _HWNDVal(aWindowId);
 19173 //        POINT p;
 19174 //        POINT p;
 19174 //        GUITHREADINFO info;
 19175 //        GUITHREADINFO info;
 19175 
 19176 
 19176         SetWindow_Cursor(win, _HCURSORVal(aCursorId));
 19177 	SetWindow_Cursor(win, _HCURSORVal(aCursorId));
 19177 
 19178 
 19178         /*
 19179 	/*
 19179          * The window's cursor has been set. When the mouse moves into
 19180 	 * The window's cursor has been set. When the mouse moves into
 19180          * the window, the new cursor will be shown when the WM_SETCURSOR event is handled.
 19181 	 * the window, the new cursor will be shown when the WM_SETCURSOR event is handled.
 19181          * If the window contains the mouse pointer, or the window has captured the mousem
 19182 	 * If the window contains the mouse pointer, or the window has captured the mousem
 19182          * no WM_SETCURSOR event is generated, so we have to set the cursor here.
 19183 	 * no WM_SETCURSOR event is generated, so we have to set the cursor here.
 19183          */
 19184 	 */
 19184 
 19185 
 19185 // forget about the GetGUIThreadInfo stuff (although it works) - __currentPointerView is easier
 19186 // forget about the GetGUIThreadInfo stuff (although it works) - __currentPointerView is easier
 19186 //        info.cbSize = sizeof(info);
 19187 //        info.cbSize = sizeof(info);
 19187 //        if (GetGUIThreadInfo(0, &info) == 0) {
 19188 //        if (GetGUIThreadInfo(0, &info) == 0) {
 19188 //            info.hwndCapture = 0;               // set to defined value on failure
 19189 //            info.hwndCapture = 0;               // set to defined value on failure
 19189 //        }
 19190 //        }
 19190 //        if (info.hwndCapture == win
 19191 //        if (info.hwndCapture == win
 19191 //            || (GetCursorPos(&p), WindowFromPoint(p) == win)) {
 19192 //            || (GetCursorPos(&p), WindowFromPoint(p) == win)) {
 19192 
 19193 
 19193         if (win == __currentPointerView) {
 19194 	if (win == __currentPointerView) {
 19194 #if defined(SET_CURSOR_IN_WINTHREAD)
 19195 #if defined(SET_CURSOR_IN_WINTHREAD)
 19195             PostMessage(win, WM_THREAD_SETCURSOR, (WPARAM)0, (INT)_HCURSORVal(aCursorId));
 19196 	    PostMessage(win, WM_THREAD_SETCURSOR, (WPARAM)0, (INT)_HCURSORVal(aCursorId));
 19196 #else
 19197 #else
 19197             SetCursor(_HCURSORVal(aCursorId));
 19198 	    SetCursor(_HCURSORVal(aCursorId));
 19198 #endif
 19199 #endif
 19199         }
 19200 	}
 19200     }
 19201     }
 19201 %}
 19202 %}
 19202 !
 19203 !
 19203 
 19204 
 19204 setForegroundWindow2:aWindowId
 19205 setForegroundWindow2:aWindowId
 19205     "make a window the foreground window"
 19206     "make a window the foreground window"
 19206 
 19207 
 19207 %{  /* NOCONTEXT */
 19208 %{  /* NOCONTEXT */
 19208     if (__isExternalAddress(aWindowId)) {
 19209     if (__isExternalAddress(aWindowId)) {
 19209         HWND win = _HWNDVal(aWindowId);
 19210 	HWND win = _HWNDVal(aWindowId);
 19210 
 19211 
 19211         if (win) {
 19212 	if (win) {
 19212             ShowWindow(win, SW_SHOW);
 19213 	    ShowWindow(win, SW_SHOW);
 19213             SetForegroundWindow(win);
 19214 	    SetForegroundWindow(win);
 19214             BringWindowToTop(win);
 19215 	    BringWindowToTop(win);
 19215         }
 19216 	}
 19216         RETURN ( self );
 19217 	RETURN ( self );
 19217     }
 19218     }
 19218 %}
 19219 %}
 19219 !
 19220 !
 19220 
 19221 
 19221 setForegroundWindow:aWindowId
 19222 setForegroundWindow:aWindowId
 19232 
 19233 
 19233 %{  /* NOCONTEXT */
 19234 %{  /* NOCONTEXT */
 19234 #if 0
 19235 #if 0
 19235     if (__isExternalAddress(aWindowId)
 19236     if (__isExternalAddress(aWindowId)
 19236      && (__isStringLike(aString))) {
 19237      && (__isStringLike(aString))) {
 19237         HWND win = _HWNDVal(aWindowId);
 19238 	HWND win = _HWNDVal(aWindowId);
 19238 
 19239 
 19239         SetWindowText(win, __stringVal(aString));
 19240 	SetWindowText(win, __stringVal(aString));
 19240         RETURN (self);
 19241 	RETURN (self);
 19241     }
 19242     }
 19242 #endif
 19243 #endif
 19243 %}
 19244 %}
 19244 !
 19245 !
 19245 
 19246 
 19246 setParentWindowIdOf:aChildWindowId to:newParentWindowId
 19247 setParentWindowIdOf:aChildWindowId to:newParentWindowId
 19247 %{  /* NOCONTEXT */
 19248 %{  /* NOCONTEXT */
 19248 
 19249 
 19249     if (__isExternalAddress(aChildWindowId)
 19250     if (__isExternalAddress(aChildWindowId)
 19250      && __isExternalAddress(newParentWindowId)) {
 19251      && __isExternalAddress(newParentWindowId)) {
 19251         HWND wChild = _HWNDVal(aChildWindowId);
 19252 	HWND wChild = _HWNDVal(aChildWindowId);
 19252         HWND wNewParent = _HWNDVal(newParentWindowId);
 19253 	HWND wNewParent = _HWNDVal(newParentWindowId);
 19253 
 19254 
 19254         if (wChild && wNewParent) {
 19255 	if (wChild && wNewParent) {
 19255             SetParent(wChild, wNewParent);
 19256 	    SetParent(wChild, wNewParent);
 19256         }
 19257 	}
 19257     }
 19258     }
 19258 %}
 19259 %}
 19259 !
 19260 !
 19260 
 19261 
 19261 setSaveUnder:yesOrNo in:aWindowId
 19262 setSaveUnder:yesOrNo in:aWindowId
 19262     "turn on/off save-under for a window"
 19263     "turn on/off save-under for a window"
 19263 
 19264 
 19264 %{  /* NOCONTEXT */
 19265 %{  /* NOCONTEXT */
 19265     if (yesOrNo != false) {
 19266     if (yesOrNo != false) {
 19266         DPRINTF(("WinWorkstation [info]: setSaveUnder:in: not (yet) implemented\n"));
 19267 	DPRINTF(("WinWorkstation [info]: setSaveUnder:in: not (yet) implemented\n"));
 19267     }
 19268     }
 19268 %}.
 19269 %}.
 19269 !
 19270 !
 19270 
 19271 
 19271 setTransient:aWindowId for:aMainWindowId
 19272 setTransient:aWindowId for:aMainWindowId
 19276 
 19277 
 19277 %{  /* NOCONTEXT */
 19278 %{  /* NOCONTEXT */
 19278 
 19279 
 19279 #ifdef NOT_YET_SUPPORTED
 19280 #ifdef NOT_YET_SUPPORTED
 19280     if (__isExternalAddress(aWindowId)) {
 19281     if (__isExternalAddress(aWindowId)) {
 19281         HWND w;
 19282 	HWND w;
 19282         HWND cw = _HWNDVal(aWindowId);
 19283 	HWND cw = _HWNDVal(aWindowId);
 19283 
 19284 
 19284         if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) {
 19285 	if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) {
 19285             w = (HWND) 0;
 19286 	    w = (HWND) 0;
 19286         } else {
 19287 	} else {
 19287             if (__isExternalAddress(aMainWindowId)) {
 19288 	    if (__isExternalAddress(aMainWindowId)) {
 19288                 w = _HWNDVal(aMainWindowId);
 19289 		w = _HWNDVal(aMainWindowId);
 19289             } else {
 19290 	    } else {
 19290                 goto getOutOfHere;
 19291 		goto getOutOfHere;
 19291             }
 19292 	    }
 19292         }
 19293 	}
 19293         CPRINTF(("setTransient:%x for:%x\n",cw,w));
 19294 	CPRINTF(("setTransient:%x for:%x\n",cw,w));
 19294         //SetParent(cw, w);
 19295 	//SetParent(cw, w);
 19295         RETURN ( self );
 19296 	RETURN ( self );
 19296     }
 19297     }
 19297  getOutOfHere: ;
 19298  getOutOfHere: ;
 19298 #else
 19299 #else
 19299     RETURN (self);
 19300     RETURN (self);
 19300 #endif
 19301 #endif
 19309 
 19310 
 19310 %{  /* NOCONTEXT */
 19311 %{  /* NOCONTEXT */
 19311 
 19312 
 19312     if (__isExternalAddress(aWindowId)
 19313     if (__isExternalAddress(aWindowId)
 19313      && (__isSmallInteger(aColorIndex))) {
 19314      && (__isSmallInteger(aColorIndex))) {
 19314         HWND hWnd = _HWNDVal(aWindowId);
 19315 	HWND hWnd = _HWNDVal(aWindowId);
 19315         int clr;
 19316 	int clr;
 19316         HBRUSH oldBrush;
 19317 	HBRUSH oldBrush;
 19317 
 19318 
 19318         oldBrush = GetWindow_viewBgBrush(hWnd);
 19319 	oldBrush = GetWindow_viewBgBrush(hWnd);
 19319         if (oldBrush) {
 19320 	if (oldBrush) {
 19320             SetWindow_viewBgBrush(hWnd, 0);
 19321 	    SetWindow_viewBgBrush(hWnd, 0);
 19321             _DeleteBrushIfNotInCache(oldBrush, __LINE__);
 19322 	    _DeleteBrushIfNotInCache(oldBrush, __LINE__);
 19322         }
 19323 	}
 19323         clr = st2RGB(__intVal(aColorIndex), 0);
 19324 	clr = st2RGB(__intVal(aColorIndex), 0);
 19324         SetWindow_viewBgColor(hWnd, clr);
 19325 	SetWindow_viewBgColor(hWnd, clr);
 19325 
 19326 
 19326         RETURN (self);
 19327 	RETURN (self);
 19327     }
 19328     }
 19328 %}
 19329 %}
 19329 !
 19330 !
 19330 
 19331 
 19331 setWindowBackgroundPixmap:aPixmapId in:aWindowId
 19332 setWindowBackgroundPixmap:aPixmapId in:aWindowId
 19332     "set the windows background pattern to be a form.
 19333     "set the windows background pattern to be a form.
 19333      This is the pattern with which the view is filled whenever exposed.
 19334      This is the pattern with which the view is filled whenever exposed.
 19334      Do not confuse this with the background drawing color, which is used
 19335      Do not confuse this with the background drawing color, which is used
 19335      with opaque drawing.
 19336      with opaque drawing.
 19336      NOTICE: due to the limitations of WIN95,
 19337      NOTICE: due to the limitations of WIN95,
 19337              background pixmaps which are not 8x8 pixels in size,
 19338 	     background pixmaps which are not 8x8 pixels in size,
 19338              are handled by smalltalk code in the WIN95 version."
 19339 	     are handled by smalltalk code in the WIN95 version."
 19339 
 19340 
 19340 %{
 19341 %{
 19341     if (__isExternalAddress(aWindowId)) {
 19342     if (__isExternalAddress(aWindowId)) {
 19342         HWND hWnd = _HWNDVal(aWindowId);
 19343 	HWND hWnd = _HWNDVal(aWindowId);
 19343         HBITMAP pixmap;
 19344 	HBITMAP pixmap;
 19344         HBRUSH oldBrush, newBrush;
 19345 	HBRUSH oldBrush, newBrush;
 19345 
 19346 
 19346         if (__isExternalAddress(aPixmapId))
 19347 	if (__isExternalAddress(aPixmapId))
 19347             pixmap = _HBITMAPVAL(aPixmapId);
 19348 	    pixmap = _HBITMAPVAL(aPixmapId);
 19348         else
 19349 	else
 19349             pixmap = 0;
 19350 	    pixmap = 0;
 19350 
 19351 
 19351         oldBrush = GetWindow_viewBgBrush(hWnd);
 19352 	oldBrush = GetWindow_viewBgBrush(hWnd);
 19352         if (oldBrush) {
 19353 	if (oldBrush) {
 19353             SetWindow_viewBgBrush(hWnd, 0);
 19354 	    SetWindow_viewBgBrush(hWnd, 0);
 19354             _DeleteBrushIfNotInCache(oldBrush, __LINE__);
 19355 	    _DeleteBrushIfNotInCache(oldBrush, __LINE__);
 19355         }
 19356 	}
 19356         if (pixmap) {
 19357 	if (pixmap) {
 19357             newBrush = CreatePatternBrush(pixmap);
 19358 	    newBrush = CreatePatternBrush(pixmap);
 19358             SetWindow_viewBgBrush(hWnd, newBrush);
 19359 	    SetWindow_viewBgBrush(hWnd, newBrush);
 19359 /*
 19360 /*
 19360  *            SetBrushOrgEx(hDC, gcData->maskOrgX, gcData->maskOrgY, 0);
 19361  *            SetBrushOrgEx(hDC, gcData->maskOrgX, gcData->maskOrgY, 0);
 19361  */
 19362  */
 19362         }
 19363 	}
 19363 
 19364 
 19364         RETURN (self);
 19365 	RETURN (self);
 19365     }
 19366     }
 19366 %}.
 19367 %}.
 19367 !
 19368 !
 19368 
 19369 
 19369 setWindowBorderColor:aColorIndex in:aWindowId
 19370 setWindowBorderColor:aColorIndex in:aWindowId
 19373 %{  /* NOCONTEXT */
 19374 %{  /* NOCONTEXT */
 19374     DPRINTF(("WinWorkstation [info]: setWindowBorderColor:in: not (yet) implemented\n"));
 19375     DPRINTF(("WinWorkstation [info]: setWindowBorderColor:in: not (yet) implemented\n"));
 19375 
 19376 
 19376     if (__isExternalAddress(aWindowId)
 19377     if (__isExternalAddress(aWindowId)
 19377      && __isSmallInteger(aColorIndex)) {
 19378      && __isSmallInteger(aColorIndex)) {
 19378         HWND win = _HWNDVal(aWindowId);
 19379 	HWND win = _HWNDVal(aWindowId);
 19379         int clr;
 19380 	int clr;
 19380 
 19381 
 19381         if (GetParent(win) != 0) {
 19382 	if (GetParent(win) != 0) {
 19382             clr = st2RGB(__intVal(aColorIndex), 0);
 19383 	    clr = st2RGB(__intVal(aColorIndex), 0);
 19383             SetWindow_bdColor(win, clr);
 19384 	    SetWindow_bdColor(win, clr);
 19384 
 19385 
 19385             {
 19386 	    {
 19386                 /*
 19387 		/*
 19387                  * force a redraw - even if we do not support
 19388 		 * force a redraw - even if we do not support
 19388                  * border colors ... (see UIPainter code)
 19389 		 * border colors ... (see UIPainter code)
 19389                  */
 19390 		 */
 19390                 RECT rect;
 19391 		RECT rect;
 19391                 HRGN rgn;
 19392 		HRGN rgn;
 19392 
 19393 
 19393                 GetWindowRect(win, &rect);
 19394 		GetWindowRect(win, &rect);
 19394                 rgn = CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom);
 19395 		rgn = CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom);
 19395                 DefWindowProcW(win, WM_NCPAINT, (WPARAM)rgn, 0);
 19396 		DefWindowProcW(win, WM_NCPAINT, (WPARAM)rgn, 0);
 19396                 _DeleteObject(rgn, __LINE__);
 19397 		_DeleteObject(rgn, __LINE__);
 19397             }
 19398 	    }
 19398         }
 19399 	}
 19399     }
 19400     }
 19400 %}.
 19401 %}.
 19401 !
 19402 !
 19402 
 19403 
 19403 setWindowBorderPixmap:aPixmapId in:aWindowId
 19404 setWindowBorderPixmap:aPixmapId in:aWindowId
 19415 
 19416 
 19416 %{  /* NOCONTEXT */
 19417 %{  /* NOCONTEXT */
 19417     int bw = (aNumber == __MKSMALLINT(0)) ? 0 : 1;
 19418     int bw = (aNumber == __MKSMALLINT(0)) ? 0 : 1;
 19418 
 19419 
 19419     if (__isExternalAddress(aWindowId)) {
 19420     if (__isExternalAddress(aWindowId)) {
 19420         HWND win = _HWNDVal(aWindowId);
 19421 	HWND win = _HWNDVal(aWindowId);
 19421         int gwl;
 19422 	int gwl;
 19422 
 19423 
 19423         gwl = GetWindowLong(win, GWL_STYLE);
 19424 	gwl = GetWindowLong(win, GWL_STYLE);
 19424         if (gwl & WS_CHILD) {
 19425 	if (gwl & WS_CHILD) {
 19425             SetWindow_bw(win, bw);
 19426 	    SetWindow_bw(win, bw);
 19426 
 19427 
 19427             if (bw) {
 19428 	    if (bw) {
 19428                 gwl |= WS_BORDER;
 19429 		gwl |= WS_BORDER;
 19429             } else {
 19430 	    } else {
 19430                 gwl &= ~WS_BORDER;
 19431 		gwl &= ~WS_BORDER;
 19431             }
 19432 	    }
 19432             SetWindowLong(win, GWL_STYLE, gwl);
 19433 	    SetWindowLong(win, GWL_STYLE, gwl);
 19433 
 19434 
 19434             /*
 19435 	    /*
 19435              * force a redraw - even if we do not support
 19436 	     * force a redraw - even if we do not support
 19436              * border colors ... (see UIPainter code)
 19437 	     * border colors ... (see UIPainter code)
 19437              */
 19438 	     */
 19438 #if 0
 19439 #if 0
 19439             PostMessage(win, WM_NCPAINT, 0, 0);
 19440 	    PostMessage(win, WM_NCPAINT, 0, 0);
 19440 #endif
 19441 #endif
 19441             {
 19442 	    {
 19442                 RECT rect;
 19443 		RECT rect;
 19443                 HRGN rgn;
 19444 		HRGN rgn;
 19444 
 19445 
 19445                 GetWindowRect(win, &rect);
 19446 		GetWindowRect(win, &rect);
 19446                 rgn = CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom);
 19447 		rgn = CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom);
 19447                 DefWindowProcW(win, WM_NCPAINT, (WPARAM)rgn, 0);
 19448 		DefWindowProcW(win, WM_NCPAINT, (WPARAM)rgn, 0);
 19448                 _DeleteObject(rgn, __LINE__);
 19449 		_DeleteObject(rgn, __LINE__);
 19449             }
 19450 	    }
 19450         }
 19451 	}
 19451     }
 19452     }
 19452 %}.
 19453 %}.
 19453 !
 19454 !
 19454 
 19455 
 19455 setWindowClass:wClass name:wName in:aWindowId
 19456 setWindowClass:wClass name:wName in:aWindowId
 19468 
 19469 
 19469 %{  /* NOCONTEXT */
 19470 %{  /* NOCONTEXT */
 19470     int gr = GRAVITY_NONE;
 19471     int gr = GRAVITY_NONE;
 19471 
 19472 
 19472     if (__isExternalAddress(aWindowId)) {
 19473     if (__isExternalAddress(aWindowId)) {
 19473         HWND hWnd = _HWNDVal(aWindowId);
 19474 	HWND hWnd = _HWNDVal(aWindowId);
 19474         localWindowInfo *lI;
 19475 	localWindowInfo *lI;
 19475 
 19476 
 19476         if (how == @symbol(South)) {
 19477 	if (how == @symbol(South)) {
 19477             gr = GRAVITY_S;
 19478 	    gr = GRAVITY_S;
 19478         } else if (how == @symbol(SouthWest)) {
 19479 	} else if (how == @symbol(SouthWest)) {
 19479             gr = GRAVITY_SW;
 19480 	    gr = GRAVITY_SW;
 19480         } else if (how == @symbol(SouthEast)) {
 19481 	} else if (how == @symbol(SouthEast)) {
 19481             gr = GRAVITY_SE;
 19482 	    gr = GRAVITY_SE;
 19482         } else if (how == @symbol(North)) {
 19483 	} else if (how == @symbol(North)) {
 19483             gr = GRAVITY_N;
 19484 	    gr = GRAVITY_N;
 19484         } else if (how == @symbol(NorthWest)) {
 19485 	} else if (how == @symbol(NorthWest)) {
 19485             gr = GRAVITY_NW;
 19486 	    gr = GRAVITY_NW;
 19486         } else if (how == @symbol(NorthEast)) {
 19487 	} else if (how == @symbol(NorthEast)) {
 19487             gr = GRAVITY_NE;
 19488 	    gr = GRAVITY_NE;
 19488         } else if (how == @symbol(East)) {
 19489 	} else if (how == @symbol(East)) {
 19489             gr = GRAVITY_E;
 19490 	    gr = GRAVITY_E;
 19490         } else if (how == @symbol(West)) {
 19491 	} else if (how == @symbol(West)) {
 19491             gr = GRAVITY_W;
 19492 	    gr = GRAVITY_W;
 19492         }
 19493 	}
 19493         lI = GETLOCALWINDOWINFOPTR(hWnd);
 19494 	lI = GETLOCALWINDOWINFOPTR(hWnd);
 19494         if (lI) {
 19495 	if (lI) {
 19495             lI->viewGravity = gr;
 19496 	    lI->viewGravity = gr;
 19496         }
 19497 	}
 19497     }
 19498     }
 19498 %}.
 19499 %}.
 19499 !
 19500 !
 19500 
 19501 
 19501 setWindowIcon:aForm mask:aMaskForm in:aWindowId
 19502 setWindowIcon:aForm mask:aMaskForm in:aWindowId
 19502     "set a windows icon & iconMask"
 19503     "set a windows icon & iconMask"
 19503 
 19504 
 19504     |wiconId wmaskId wiconHeight wiconWidth|
 19505     |wiconId wmaskId wiconHeight wiconWidth|
 19505 
 19506 
 19506     aForm notNil ifTrue:[
 19507     aForm notNil ifTrue:[
 19507         wiconId := aForm id.
 19508 	wiconId := aForm id.
 19508         wiconHeight := aForm height.
 19509 	wiconHeight := aForm height.
 19509         wiconWidth  := aForm width.
 19510 	wiconWidth  := aForm width.
 19510         aMaskForm notNil ifTrue:[
 19511 	aMaskForm notNil ifTrue:[
 19511             wmaskId := aMaskForm id
 19512 	    wmaskId := aMaskForm id
 19512         ].
 19513 	].
 19513         self
 19514 	self
 19514             primSetWindowIconId:wiconId
 19515 	    primSetWindowIconId:wiconId
 19515             maskId:wmaskId
 19516 	    maskId:wmaskId
 19516             width:wiconWidth
 19517 	    width:wiconWidth
 19517             height:wiconHeight
 19518 	    height:wiconHeight
 19518             in:aWindowId
 19519 	    in:aWindowId
 19519     ].
 19520     ].
 19520 !
 19521 !
 19521 
 19522 
 19522 setWindowIconWindow:aView in:aWindowId
 19523 setWindowIconWindow:aView in:aWindowId
 19523     "define a window to be used as icon.
 19524     "define a window to be used as icon.
 19531      nil arguments are ignored."
 19532      nil arguments are ignored."
 19532 
 19533 
 19533     |minW minH maxW maxH|
 19534     |minW minH maxW maxH|
 19534 
 19535 
 19535     minExt notNil ifTrue:[
 19536     minExt notNil ifTrue:[
 19536         minW := minExt x.
 19537 	minW := minExt x.
 19537         minH := minExt y.
 19538 	minH := minExt y.
 19538     ].
 19539     ].
 19539     maxExt notNil ifTrue:[
 19540     maxExt notNil ifTrue:[
 19540         maxW := maxExt x.
 19541 	maxW := maxExt x.
 19541         maxH := maxExt y.
 19542 	maxH := maxExt y.
 19542     ].
 19543     ].
 19543 %{
 19544 %{
 19544     if (__isExternalAddress(aWindowId)) {
 19545     if (__isExternalAddress(aWindowId)) {
 19545         HWND win = _HWNDVal(aWindowId);
 19546 	HWND win = _HWNDVal(aWindowId);
 19546         RECT rec;
 19547 	RECT rec;
 19547         int winStyleBits;
 19548 	int winStyleBits;
 19548         int winExStyleBits;
 19549 	int winExStyleBits;
 19549         localWindowInfo *lI;
 19550 	localWindowInfo *lI;
 19550 
 19551 
 19551         if (win) {
 19552 	if (win) {
 19552             winStyleBits = GetWindowLong(win, GWL_STYLE);
 19553 	    winStyleBits = GetWindowLong(win, GWL_STYLE);
 19553             winExStyleBits = GetWindowLong(win, GWL_EXSTYLE);
 19554 	    winExStyleBits = GetWindowLong(win, GWL_EXSTYLE);
 19554             lI = GETLOCALWINDOWINFOPTR(win);
 19555 	    lI = GETLOCALWINDOWINFOPTR(win);
 19555             if (! lI) {
 19556 	    if (! lI) {
 19556                 console_fprintf(stderr, "WinWorkstation [info]: oops - no localInfo in setMinMaxExt\n");
 19557 		console_fprintf(stderr, "WinWorkstation [info]: oops - no localInfo in setMinMaxExt\n");
 19557                 RETURN (self);
 19558 		RETURN (self);
 19558             }
 19559 	    }
 19559 
 19560 
 19560             if (__bothSmallInteger(minW, minH)) {
 19561 	    if (__bothSmallInteger(minW, minH)) {
 19561                 RECT rec;
 19562 		RECT rec;
 19562 
 19563 
 19563                 rec.left = 0;
 19564 		rec.left = 0;
 19564                 rec.top = 0;
 19565 		rec.top = 0;
 19565                 rec.right = __intVal(minW);
 19566 		rec.right = __intVal(minW);
 19566                 rec.bottom = __intVal(minH);
 19567 		rec.bottom = __intVal(minH);
 19567 #ifdef ADJUSTWINDOW
 19568 #ifdef ADJUSTWINDOW
 19568                 AdjustWindowRectEx(&rec, winStyleBits, 0, winExStyleBits);
 19569 		AdjustWindowRectEx(&rec, winStyleBits, 0, winExStyleBits);
 19569 #endif
 19570 #endif
 19570                 lI->minWidth = rec.right - rec.left;
 19571 		lI->minWidth = rec.right - rec.left;
 19571                 lI->minHeight = rec.bottom - rec.top;
 19572 		lI->minHeight = rec.bottom - rec.top;
 19572             }
 19573 	    }
 19573             if (__bothSmallInteger(maxW, maxH)) {
 19574 	    if (__bothSmallInteger(maxW, maxH)) {
 19574                 RECT rec;
 19575 		RECT rec;
 19575 
 19576 
 19576                 rec.left = 0;
 19577 		rec.left = 0;
 19577                 rec.top = 0;
 19578 		rec.top = 0;
 19578                 rec.right = __intVal(maxW);
 19579 		rec.right = __intVal(maxW);
 19579                 rec.bottom = __intVal(maxH);
 19580 		rec.bottom = __intVal(maxH);
 19580 #ifdef ADJUSTWINDOW
 19581 #ifdef ADJUSTWINDOW
 19581                 AdjustWindowRectEx(&rec, winStyleBits, 0, winExStyleBits);
 19582 		AdjustWindowRectEx(&rec, winStyleBits, 0, winExStyleBits);
 19582 #endif
 19583 #endif
 19583                 lI->maxWidth = rec.right - rec.left;
 19584 		lI->maxWidth = rec.right - rec.left;
 19584                 lI->maxHeight = rec.bottom - rec.top;
 19585 		lI->maxHeight = rec.bottom - rec.top;
 19585             }
 19586 	    }
 19586         }
 19587 	}
 19587     }
 19588     }
 19588 %}
 19589 %}
 19589 !
 19590 !
 19590 
 19591 
 19591 setWindowName:aString in:aWindowId
 19592 setWindowName:aString in:aWindowId
 19592     "define a windows name"
 19593     "define a windows name"
 19593 
 19594 
 19594 %{  /* NOCONTEXT */
 19595 %{  /* NOCONTEXT */
 19595 
 19596 
 19596     if (__isExternalAddress(aWindowId)) {
 19597     if (__isExternalAddress(aWindowId)) {
 19597         HWND win = _HWNDVal(aWindowId);
 19598 	HWND win = _HWNDVal(aWindowId);
 19598         wchar_t nameBuffer[ MAX_LABEL_SIZE ];
 19599 	wchar_t nameBuffer[ MAX_LABEL_SIZE ];
 19599 
 19600 
 19600         if (__isStringLike(aString)) {
 19601 	if (__isStringLike(aString)) {
 19601             ch2wch((char *)__stringVal(aString), nameBuffer, MAX_LABEL_SIZE);
 19602 	    ch2wch((char *)__stringVal(aString), nameBuffer, MAX_LABEL_SIZE);
 19602             SetWindowTextW(win, nameBuffer);
 19603 	    SetWindowTextW(win, nameBuffer);
 19603             RETURN (self);
 19604 	    RETURN (self);
 19604         }
 19605 	}
 19605         if (__isUnicode16String(aString)) {
 19606 	if (__isUnicode16String(aString)) {
 19606             int l = __unicode16StringSize(aString);
 19607 	    int l = __unicode16StringSize(aString);
 19607             if (l >= MAX_LABEL_SIZE) l = MAX_LABEL_SIZE-1;
 19608 	    if (l >= MAX_LABEL_SIZE) l = MAX_LABEL_SIZE-1;
 19608             memmove(nameBuffer, __unicode16StringVal(aString), l*sizeof(wchar_t));
 19609 	    memmove(nameBuffer, __unicode16StringVal(aString), l*sizeof(wchar_t));
 19609             nameBuffer[ l ] = 0;
 19610 	    nameBuffer[ l ] = 0;
 19610             SetWindowTextW(win, nameBuffer);
 19611 	    SetWindowTextW(win, nameBuffer);
 19611             RETURN (self);
 19612 	    RETURN (self);
 19612         }
 19613 	}
 19613     }
 19614     }
 19614 %}
 19615 %}
 19615     "
 19616     "
 19616      (StandardSystemView new label:'äöü') open
 19617      (StandardSystemView new label:'äöü') open
 19617     "
 19618     "
 19622 
 19623 
 19623 %{
 19624 %{
 19624     if (__isExternalAddress(aWindowId)
 19625     if (__isExternalAddress(aWindowId)
 19625      && __bothSmallInteger(x, y)
 19626      && __bothSmallInteger(x, y)
 19626      && __bothSmallInteger(w, h)) {
 19627      && __bothSmallInteger(w, h)) {
 19627         HWND win = _HWNDVal(aWindowId);
 19628 	HWND win = _HWNDVal(aWindowId);
 19628         int left = __intVal(x);
 19629 	int left = __intVal(x);
 19629         int top = __intVal(y);
 19630 	int top = __intVal(y);
 19630         int right = left + __intVal(w);
 19631 	int right = left + __intVal(w);
 19631         int bottom = top + __intVal(h);
 19632 	int bottom = top + __intVal(h);
 19632         HRGN rgn;
 19633 	HRGN rgn;
 19633         HDC winDC;
 19634 	HDC winDC;
 19634 
 19635 
 19635         rgn = CreateEllipticRgn(left, top, right, bottom);
 19636 	rgn = CreateEllipticRgn(left, top, right, bottom);
 19636         if (rgn) {
 19637 	if (rgn) {
 19637             winDC = GetDCEx(win, 0, DCX_WINDOW);
 19638 	    winDC = GetDCEx(win, 0, DCX_WINDOW);
 19638             if (winDC) {
 19639 	    if (winDC) {
 19639 #ifdef GDIFLUSH_WHEN_CHANGING_CLIP
 19640 #ifdef GDIFLUSH_WHEN_CHANGING_CLIP
 19640                 GdiFlush();
 19641 		GdiFlush();
 19641 #endif
 19642 #endif
 19642                 if (SelectClipRgn(winDC, rgn) == ERROR ) {
 19643 		if (SelectClipRgn(winDC, rgn) == ERROR ) {
 19643                     console_fprintf(stderr, "select clipping region failed\n");
 19644 		    console_fprintf(stderr, "select clipping region failed\n");
 19644                 }
 19645 		}
 19645                 ReleaseDC(win, winDC);
 19646 		ReleaseDC(win, winDC);
 19646             }
 19647 	    }
 19647             else
 19648 	    else
 19648                 console_fprintf(stderr, "getDC failed\n");
 19649 		console_fprintf(stderr, "getDC failed\n");
 19649 
 19650 
 19650             _DeleteObject(rgn, __LINE__);
 19651 	    _DeleteObject(rgn, __LINE__);
 19651         }
 19652 	}
 19652         else
 19653 	else
 19653             console_fprintf(stderr, "region creation failed\n");
 19654 	    console_fprintf(stderr, "region creation failed\n");
 19654         RETURN ( self );
 19655 	RETURN ( self );
 19655     }
 19656     }
 19656 %}.
 19657 %}.
 19657     self primitiveFailed
 19658     self primitiveFailed
 19658 !
 19659 !
 19659 
 19660 
 19661     |l|
 19662     |l|
 19662 
 19663 
 19663     l := OrderedCollection new.
 19664     l := OrderedCollection new.
 19664     self primEnumWindowsInto:l.
 19665     self primEnumWindowsInto:l.
 19665     l do:[:eachWindowId |
 19666     l do:[:eachWindowId |
 19666         (self getParentWindowIdOfWindowId:eachWindowId) isNil ifTrue:[
 19667 	(self getParentWindowIdOfWindowId:eachWindowId) isNil ifTrue:[
 19667             "/ a topView
 19668 	    "/ a topView
 19668             aBlock value:eachWindowId
 19669 	    aBlock value:eachWindowId
 19669         ]
 19670 	]
 19670     ].
 19671     ].
 19671     ^ nil
 19672     ^ nil
 19672 
 19673 
 19673     "
 19674     "
 19674      Display topWindowIdsDo:[:id |
 19675      Display topWindowIdsDo:[:id |
 19675         |nm|
 19676 	|nm|
 19676 
 19677 
 19677         nm := String new:100.
 19678 	nm := String new:100.
 19678         Transcript showCR:id.
 19679 	Transcript showCR:id.
 19679         Display primGetWindowText:id into:nm size:nm size-1.
 19680 	Display primGetWindowText:id into:nm size:nm size-1.
 19680         Transcript showCR:nm.
 19681 	Transcript showCR:nm.
 19681      ].
 19682      ].
 19682     "
 19683     "
 19683 
 19684 
 19684     "
 19685     "
 19685      |w|
 19686      |w|
 19686      Display topWindowIdsDo:[:id |
 19687      Display topWindowIdsDo:[:id |
 19687         |nm|
 19688 	|nm|
 19688 
 19689 
 19689         nm := String new:100.
 19690 	nm := String new:100.
 19690         Display primGetWindowText:id into:nm size:nm size-1.
 19691 	Display primGetWindowText:id into:nm size:nm size-1.
 19691         (nm includesString:'Mortal') ifTrue:[
 19692 	(nm includesString:'Mortal') ifTrue:[
 19692             w := id.
 19693 	    w := id.
 19693         ]
 19694 	]
 19694      ].
 19695      ].
 19695      Display resizeWindow:w width:1024 height:1024
 19696      Display resizeWindow:w width:1024 height:1024
 19696     "
 19697     "
 19697 !
 19698 !
 19698 
 19699 
 19700     "make a window invisible"
 19701     "make a window invisible"
 19701 
 19702 
 19702 %{  /* NOCONTEXT */
 19703 %{  /* NOCONTEXT */
 19703 
 19704 
 19704     if (__isExternalAddress(aWindowId)) {
 19705     if (__isExternalAddress(aWindowId)) {
 19705         HWND win = _HWNDVal(aWindowId);
 19706 	HWND win = _HWNDVal(aWindowId);
 19706 
 19707 
 19707         if (win) {
 19708 	if (win) {
 19708             CPRINTF(("unmapWindow %x\n",win));
 19709 	    CPRINTF(("unmapWindow %x\n",win));
 19709             SetWindow_unmapping(win, 1);
 19710 	    SetWindow_unmapping(win, 1);
 19710             ShowWindowAsync(win, SW_HIDE);
 19711 	    ShowWindowAsync(win, SW_HIDE);
 19711         }
 19712 	}
 19712         RETURN ( self );
 19713 	RETURN ( self );
 19713     }
 19714     }
 19714 %}
 19715 %}
 19715 !
 19716 !
 19716 
 19717 
 19717 unmapWindow:aWindowId animation:animationSymbolorNil time:timeInMillisOrNil
 19718 unmapWindow:aWindowId animation:animationSymbolorNil time:timeInMillisOrNil
 19723 windowIsIconified:aWindowId
 19724 windowIsIconified:aWindowId
 19724     "return true, if some window is iconified."
 19725     "return true, if some window is iconified."
 19725 
 19726 
 19726 %{  /* NOCONTEXT */
 19727 %{  /* NOCONTEXT */
 19727     if (__isExternalAddress(aWindowId)) {
 19728     if (__isExternalAddress(aWindowId)) {
 19728         HWND win = _HWNDVal(aWindowId);
 19729 	HWND win = _HWNDVal(aWindowId);
 19729 
 19730 
 19730         if (win) {
 19731 	if (win) {
 19731             if (GetWindow_iconified(win)) {
 19732 	    if (GetWindow_iconified(win)) {
 19732                 RETURN (true);
 19733 		RETURN (true);
 19733             }
 19734 	    }
 19734         }
 19735 	}
 19735     }
 19736     }
 19736 %}.
 19737 %}.
 19737     ^ false
 19738     ^ false
 19738 ! !
 19739 ! !
 19739 
 19740 
 19742 enableScrollBar:howSymbol in:aWindowId
 19743 enableScrollBar:howSymbol in:aWindowId
 19743     "native scrollBar widget access"
 19744     "native scrollBar widget access"
 19744 
 19745 
 19745 %{
 19746 %{
 19746     if (__isExternalAddress(aWindowId)) {
 19747     if (__isExternalAddress(aWindowId)) {
 19747         HWND win = _HWNDVal(aWindowId);
 19748 	HWND win = _HWNDVal(aWindowId);
 19748         int how;
 19749 	int how;
 19749 
 19750 
 19750         if (howSymbol == @symbol(ENABLE_BOTH)) {
 19751 	if (howSymbol == @symbol(ENABLE_BOTH)) {
 19751             how = ESB_ENABLE_BOTH;
 19752 	    how = ESB_ENABLE_BOTH;
 19752         } else if (howSymbol == @symbol(DISABLE_LTUP)) {
 19753 	} else if (howSymbol == @symbol(DISABLE_LTUP)) {
 19753             how = ESB_DISABLE_LTUP;
 19754 	    how = ESB_DISABLE_LTUP;
 19754         } else if (howSymbol == @symbol(DISABLE_RTDN)) {
 19755 	} else if (howSymbol == @symbol(DISABLE_RTDN)) {
 19755             how = ESB_DISABLE_RTDN;
 19756 	    how = ESB_DISABLE_RTDN;
 19756         } else if (howSymbol == @symbol(DISABLE_BOTH)) {
 19757 	} else if (howSymbol == @symbol(DISABLE_BOTH)) {
 19757             how = ESB_DISABLE_BOTH;
 19758 	    how = ESB_DISABLE_BOTH;
 19758         } else {
 19759 	} else {
 19759             RETURN ( self );
 19760 	    RETURN ( self );
 19760         }
 19761 	}
 19761         NDPRINTF(("EnableScrollBar(%d)\n", how));
 19762 	NDPRINTF(("EnableScrollBar(%d)\n", how));
 19762         EnableScrollBar(win, SB_CTL, how);
 19763 	EnableScrollBar(win, SB_CTL, how);
 19763         RETURN ( self );
 19764 	RETURN ( self );
 19764     }
 19765     }
 19765 %}.
 19766 %}.
 19766     self primitiveFailed
 19767     self primitiveFailed
 19767 !
 19768 !
 19768 
 19769 
 19770     "native scrollBar widget access"
 19771     "native scrollBar widget access"
 19771 
 19772 
 19772 %{
 19773 %{
 19773     if (__isExternalAddress(aWindowId)
 19774     if (__isExternalAddress(aWindowId)
 19774      && __isSmallInteger(sz)) {
 19775      && __isSmallInteger(sz)) {
 19775         HWND win = _HWNDVal(aWindowId);
 19776 	HWND win = _HWNDVal(aWindowId);
 19776         SCROLLINFO info;
 19777 	SCROLLINFO info;
 19777 
 19778 
 19778         info.cbSize = sizeof(SCROLLINFO);
 19779 	info.cbSize = sizeof(SCROLLINFO);
 19779         info.nPage = __intVal(sz);
 19780 	info.nPage = __intVal(sz);
 19780         info.fMask = SIF_PAGE;
 19781 	info.fMask = SIF_PAGE;
 19781         NDPRINTF2(("SetScrollPage(%d)\n", __intVal(sz)));
 19782 	NDPRINTF2(("SetScrollPage(%d)\n", __intVal(sz)));
 19782         SetScrollInfo(win, SB_CTL, &info, redraw==true ? 1 : 0);
 19783 	SetScrollInfo(win, SB_CTL, &info, redraw==true ? 1 : 0);
 19783         RETURN ( self );
 19784 	RETURN ( self );
 19784     }
 19785     }
 19785 %}.
 19786 %}.
 19786     self primitiveFailed
 19787     self primitiveFailed
 19787 !
 19788 !
 19788 
 19789 
 19790     "native scrollBar widget access"
 19791     "native scrollBar widget access"
 19791 
 19792 
 19792 %{
 19793 %{
 19793     if (__isExternalAddress(aWindowId)
 19794     if (__isExternalAddress(aWindowId)
 19794      && __isSmallInteger(newPosition)) {
 19795      && __isSmallInteger(newPosition)) {
 19795         HWND win = _HWNDVal(aWindowId);
 19796 	HWND win = _HWNDVal(aWindowId);
 19796 
 19797 
 19797         NDPRINTF2(("SetScrollPos(%d)\n", __intVal(newPosition)));
 19798 	NDPRINTF2(("SetScrollPos(%d)\n", __intVal(newPosition)));
 19798         SetScrollPos(win, SB_CTL, __intVal(newPosition), redraw==true ? 1 : 0);
 19799 	SetScrollPos(win, SB_CTL, __intVal(newPosition), redraw==true ? 1 : 0);
 19799         RETURN ( self );
 19800 	RETURN ( self );
 19800     }
 19801     }
 19801 %}.
 19802 %}.
 19802     self primitiveFailed
 19803     self primitiveFailed
 19803 !
 19804 !
 19804 
 19805 
 19806     "native scrollBar widget access"
 19807     "native scrollBar widget access"
 19807 
 19808 
 19808 %{
 19809 %{
 19809     if (__isExternalAddress(aWindowId)
 19810     if (__isExternalAddress(aWindowId)
 19810      && __bothSmallInteger(min, max)) {
 19811      && __bothSmallInteger(min, max)) {
 19811         HWND win = _HWNDVal(aWindowId);
 19812 	HWND win = _HWNDVal(aWindowId);
 19812 
 19813 
 19813         NDPRINTF2(("SetScrollRange(%d..%d)\n", __intVal(min), __intVal(max)));
 19814 	NDPRINTF2(("SetScrollRange(%d..%d)\n", __intVal(min), __intVal(max)));
 19814         SetScrollRange(win, SB_CTL, __intVal(min), __intVal(max), redraw==true ? 1 : 0);
 19815 	SetScrollRange(win, SB_CTL, __intVal(min), __intVal(max), redraw==true ? 1 : 0);
 19815         RETURN ( self );
 19816 	RETURN ( self );
 19816     }
 19817     }
 19817 %}.
 19818 %}.
 19818     self primitiveFailed
 19819     self primitiveFailed
 19819 ! !
 19820 ! !
 19820 
 19821 
 19866 
 19867 
 19867 !WinWorkstation::CopyDataStructStructure class methodsFor:'accessing'!
 19868 !WinWorkstation::CopyDataStructStructure class methodsFor:'accessing'!
 19868 
 19869 
 19869 sizeInBytes
 19870 sizeInBytes
 19870     ExternalAddress pointerSize == 8 ifTrue:[
 19871     ExternalAddress pointerSize == 8 ifTrue:[
 19871         ^ 24.
 19872 	^ 24.
 19872     ].
 19873     ].
 19873     ^ 12
 19874     ^ 12
 19874 ! !
 19875 ! !
 19875 
 19876 
 19876 !WinWorkstation::CopyDataStructStructure class methodsFor:'instance creation'!
 19877 !WinWorkstation::CopyDataStructStructure class methodsFor:'instance creation'!
 19882 
 19883 
 19883 !WinWorkstation::CopyDataStructStructure methodsFor:'accessing'!
 19884 !WinWorkstation::CopyDataStructStructure methodsFor:'accessing'!
 19884 
 19885 
 19885 cbData
 19886 cbData
 19886     ExternalAddress pointerSize == 8 ifTrue:[
 19887     ExternalAddress pointerSize == 8 ifTrue:[
 19887         ^ self unsignedInt32At: 8 + 1.
 19888 	^ self unsignedInt32At: 8 + 1.
 19888     ].
 19889     ].
 19889     ^ self unsignedInt32At: 4 + 1.
 19890     ^ self unsignedInt32At: 4 + 1.
 19890 !
 19891 !
 19891 
 19892 
 19892 cbData: cbData
 19893 cbData: cbData
 19893     ExternalAddress pointerSize == 8 ifTrue:[
 19894     ExternalAddress pointerSize == 8 ifTrue:[
 19894         self unsignedInt32At: 8 + 1  put: cbData.
 19895 	self unsignedInt32At: 8 + 1  put: cbData.
 19895     ] ifFalse:[
 19896     ] ifFalse:[
 19896         self unsignedInt32At: 4 + 1  put: cbData.
 19897 	self unsignedInt32At: 4 + 1  put: cbData.
 19897     ].
 19898     ].
 19898 !
 19899 !
 19899 
 19900 
 19900 dwData
 19901 dwData
 19901     ExternalAddress pointerSize == 8 ifTrue:[
 19902     ExternalAddress pointerSize == 8 ifTrue:[
 19902         ^ self unsignedInt64At: 0 + 1.
 19903 	^ self unsignedInt64At: 0 + 1.
 19903     ].
 19904     ].
 19904     ^ self unsignedInt32At: 0 + 1.
 19905     ^ self unsignedInt32At: 0 + 1.
 19905 !
 19906 !
 19906 
 19907 
 19907 dwData: dwData
 19908 dwData: dwData
 19908     ExternalAddress pointerSize == 8 ifTrue:[
 19909     ExternalAddress pointerSize == 8 ifTrue:[
 19909         self unsignedInt64At: 0 + 1 put:dwData.
 19910 	self unsignedInt64At: 0 + 1 put:dwData.
 19910     ] ifFalse:[
 19911     ] ifFalse:[
 19911         self unsignedInt32At: 0 + 1 put:dwData.
 19912 	self unsignedInt32At: 0 + 1 put:dwData.
 19912     ].
 19913     ].
 19913 !
 19914 !
 19914 
 19915 
 19915 lpData
 19916 lpData
 19916     ExternalAddress pointerSize == 8 ifTrue:[
 19917     ExternalAddress pointerSize == 8 ifTrue:[
 19917         ^ self unsignedInt64At: 16 + 1.
 19918 	^ self unsignedInt64At: 16 + 1.
 19918     ].
 19919     ].
 19919     ^ self unsignedInt32At: 8 + 1.
 19920     ^ self unsignedInt32At: 8 + 1.
 19920 !
 19921 !
 19921 
 19922 
 19922 lpData: lpData
 19923 lpData: lpData
 19923     ExternalAddress pointerSize == 8 ifTrue:[
 19924     ExternalAddress pointerSize == 8 ifTrue:[
 19924         self unsignedInt64At: 16 + 1  put: lpData.
 19925 	self unsignedInt64At: 16 + 1  put: lpData.
 19925     ] ifFalse:[
 19926     ] ifFalse:[
 19926         self unsignedInt32At: 8 + 1  put: lpData.
 19927 	self unsignedInt32At: 8 + 1  put: lpData.
 19927     ].
 19928     ].
 19928 ! !
 19929 ! !
 19929 
 19930 
 19930 !WinWorkstation::MonitorInfo methodsFor:'accessing'!
 19931 !WinWorkstation::MonitorInfo methodsFor:'accessing'!
 19931 
 19932 
 19933      "return a rectangle representing the displays bounding box of the monitor"
 19934      "return a rectangle representing the displays bounding box of the monitor"
 19934 
 19935 
 19935 "/ ******* MULTI SCREEN ******
 19936 "/ ******* MULTI SCREEN ******
 19936 
 19937 
 19937     ^ Rectangle
 19938     ^ Rectangle
 19938         left:screenX
 19939 	left:screenX
 19939         top:screenY
 19940 	top:screenY
 19940         width:workW - 1
 19941 	width:workW - 1
 19941         height:workH - 1
 19942 	height:workH - 1
 19942 !
 19943 !
 19943 
 19944 
 19944 isPrimary
 19945 isPrimary
 19945     ^ isPrimary
 19946     ^ isPrimary
 19946 !
 19947 !
 20002 documentation
 20003 documentation
 20003 "
 20004 "
 20004     This is used as a finalization handle for printer contexts
 20005     This is used as a finalization handle for printer contexts
 20005 
 20006 
 20006     [see also:]
 20007     [see also:]
 20007         DeviceHandle
 20008 	DeviceHandle
 20008 
 20009 
 20009     [author:]
 20010     [author:]
 20010         Claus Gittinger
 20011 	Claus Gittinger
 20011 
 20012 
 20012 "
 20013 "
 20013 ! !
 20014 ! !
 20014 
 20015 
 20015 !WinWorkstation::PrinterDeviceContextHandle methodsFor:'finalization'!
 20016 !WinWorkstation::PrinterDeviceContextHandle methodsFor:'finalization'!
 20018     "the PrintingContext for which I am a handle has been collected - tell it to Windows"
 20019     "the PrintingContext for which I am a handle has been collected - tell it to Windows"
 20019 
 20020 
 20020     |id|
 20021     |id|
 20021 
 20022 
 20022     (id := gcId) notNil ifTrue:[
 20023     (id := gcId) notNil ifTrue:[
 20023         gcId := nil.
 20024 	gcId := nil.
 20024         device destroyPrinterDC:id.
 20025 	device destroyPrinterDC:id.
 20025     ]
 20026     ]
 20026 ! !
 20027 ! !
 20027 
 20028 
 20028 !WinWorkstation class methodsFor:'documentation'!
 20029 !WinWorkstation class methodsFor:'documentation'!
 20029 
 20030