884 "Modified: / 1.9.1995 / 13:40:05 / claus" |
884 "Modified: / 1.9.1995 / 13:40:05 / claus" |
885 "Modified: / 7.2.1997 / 16:16:58 / cg" |
885 "Modified: / 7.2.1997 / 16:16:58 / cg" |
886 "Modified: / 18.3.1999 / 18:20:39 / stefan" |
886 "Modified: / 18.3.1999 / 18:20:39 / stefan" |
887 ! |
887 ! |
888 |
888 |
|
889 currentDisplayResolution |
|
890 "ONLY WINDOWS redfines this method |
|
891 here just return my known extent |
|
892 |
|
893 this is the current resolution of the display, |
|
894 without any effect of scaling |
|
895 |
|
896 for e.g. |
|
897 real current display resolution -> 1080p |
|
898 scaling 150% |
|
899 virtual display resolution -> 720p |
|
900 |
|
901 real current display resolution -> 1080p |
|
902 scaling 100% |
|
903 virtual display resolution -> 1080p" |
|
904 |
|
905 " |
|
906 self currentDisplayResolution |
|
907 " |
|
908 |
|
909 ^ Display extent |
|
910 |
|
911 "Created: / 15-11-2019 / 10:42:20 / Stefan Reise" |
|
912 ! |
|
913 |
889 currentWindow |
914 currentWindow |
890 "Return the currently active window, |
915 "Return the currently active window, |
891 that is, the topView of the currently executing windowGroup" |
916 that is, the topView of the currently executing windowGroup" |
892 |
917 |
893 |wg| |
918 |wg| |
959 "Modified (comment): / 17-05-2017 / 18:25:06 / mawalch" |
984 "Modified (comment): / 17-05-2017 / 18:25:06 / mawalch" |
960 ! |
985 ! |
961 |
986 |
962 scaleFactorForRootDisplayCoordinates |
987 scaleFactorForRootDisplayCoordinates |
963 "this is the factor we need to adopt for the root display coordinates, |
988 "this is the factor we need to adopt for the root display coordinates, |
964 if windows did scale the application (when the app is not high DPI aware" |
989 if windows did scale the application (when the app is not high DPI aware)" |
965 |
990 |
966 " |
991 " |
967 self scaleFactorForRootDisplayCoordinates |
992 self scaleFactorForRootDisplayCoordinates |
968 " |
993 " |
969 |
994 |
970 ^ 1@1 |
995 ^ 1@1 |
971 |
996 |
972 "Created: / 14-11-2019 / 13:43:12 / Stefan Reise" |
997 "Created: / 14-11-2019 / 13:43:12 / Stefan Reise" |
973 "Modified (comment): / 15-11-2019 / 09:42:36 / Stefan Reise" |
998 "Modified (comment): / 15-11-2019 / 10:23:45 / Stefan Reise" |
974 ! ! |
999 ! ! |
975 |
1000 |
976 !DeviceWorkstation class methodsFor:'standalone setup'! |
1001 !DeviceWorkstation class methodsFor:'standalone setup'! |
977 |
1002 |
978 exitOnLastClose:aBoolean |
1003 exitOnLastClose:aBoolean |
986 "/ For all other (non-main-Display) connections, an instVar is used. |
1011 "/ For all other (non-main-Display) connections, an instVar is used. |
987 |
1012 |
988 ExitOnLastClose := aBoolean |
1013 ExitOnLastClose := aBoolean |
989 |
1014 |
990 "Modified: 23.4.1996 / 22:01:28 / cg" |
1015 "Modified: 23.4.1996 / 22:01:28 / cg" |
|
1016 ! ! |
|
1017 |
|
1018 !DeviceWorkstation class methodsFor:'transformations'! |
|
1019 |
|
1020 transformVirtualDisplayPointToRootDisplayPoint:aPoint |
|
1021 "this is required when you want to access the root display coordinates correctly, |
|
1022 because may windows did scale the application (when the app is not high DPI aware), |
|
1023 and if windows did scale the application, the application gets a virtual display |
|
1024 with a diffrent resolution" |
|
1025 |
|
1026 ^ (aPoint * self scaleFactorForRootDisplayCoordinates) rounded |
|
1027 |
|
1028 "Created: / 15-11-2019 / 10:31:31 / Stefan Reise" |
|
1029 ! |
|
1030 |
|
1031 transformVirtualDisplayRectangleToRootDisplayRectangle:aRectangle |
|
1032 "this is required when you want to access the root display coordinates correctly, |
|
1033 because may windows did scale the application (when the app is not high DPI aware), |
|
1034 and if windows did scale the application, the application gets a virtual display |
|
1035 with a diffrent resolution" |
|
1036 |
|
1037 "ATTENTION: |
|
1038 do not call #transformVirtualDisplayPointToRootDisplayPoint: 2 times here, |
|
1039 because this would also call #scaleFactorForRootDisplayCoordinates 2 times, |
|
1040 but the call #scaleFactorForRootDisplayCoordinates is a little expensive" |
|
1041 |
|
1042 |scaleFactorForRootDisplayCoordinates| |
|
1043 |
|
1044 scaleFactorForRootDisplayCoordinates := self scaleFactorForRootDisplayCoordinates. |
|
1045 |
|
1046 ^ (aRectangle origin * scaleFactorForRootDisplayCoordinates) rounded |
|
1047 corner:(aRectangle corner * scaleFactorForRootDisplayCoordinates) rounded |
|
1048 |
|
1049 "Created: / 15-11-2019 / 10:22:38 / Stefan Reise" |
991 ! ! |
1050 ! ! |
992 |
1051 |
993 !DeviceWorkstation methodsFor:'Compatibility-ST80'! |
1052 !DeviceWorkstation methodsFor:'Compatibility-ST80'! |
994 |
1053 |
995 colorDepth |
1054 colorDepth |
6924 " |
6983 " |
6925 |
6984 |
6926 "Modified: 24.7.1997 / 16:04:54 / cg" |
6985 "Modified: 24.7.1997 / 16:04:54 / cg" |
6927 ! |
6986 ! |
6928 |
6987 |
6929 rectangleFromUser:initialRectangle |
6988 rectangleFromUser:initialRectangle keepExtent:keepExtent |
6930 keepExtent:keepExtent |
|
6931 |
|
6932 ^ self |
|
6933 rectangleFromUser:initialRectangle |
|
6934 keepExtent:keepExtent |
|
6935 scaleFactor:self class scaleFactorForRootDisplayCoordinates |
|
6936 |
|
6937 "Created: / 24-07-1997 / 15:26:47 / cg" |
|
6938 "Modified: / 10-09-1998 / 17:38:41 / cg" |
|
6939 "Modified: / 23-02-2017 / 13:30:21 / stefan" |
|
6940 "Modified: / 14-11-2019 / 13:43:28 / Stefan Reise" |
|
6941 ! |
|
6942 |
|
6943 rectangleFromUser:initialRectangle |
|
6944 keepExtent:keepExtent |
|
6945 scaleFactor:scaleFactor |
|
6946 |
|
6947 "{ Pragma: +optSpace }" |
6989 "{ Pragma: +optSpace }" |
6948 |
6990 |
6949 "let user specify a rectangle on the screen, return the rectangle. |
6991 "let user specify a rectangle on the screen, return the rectangle. |
6950 Start with initialRectangle. |
6992 Start with initialRectangle. |
6951 A helper for rectangleFromUser; can also be used for resizing operations." |
6993 A helper for rectangleFromUser; can also be used for resizing operations." |
6952 |
6994 |
6953 |curs1 origin corner root rect doRegrab prevGrab delay| |
6995 |curs1 origin corner root rect doRegrab prevGrab delay displayRectangleBlock| |
6954 |
6996 |
6955 "/ regrabbing leads to horrible flicker and |
6997 "/ regrabbing leads to horrible flicker and |
6956 "/ events being sent to applications under the mouse. |
6998 "/ events being sent to applications under the mouse. |
6957 "/ on windows displays. |
6999 "/ on windows displays. |
6958 doRegrab := self class ~~ WinWorkstation. |
7000 doRegrab := self class ~~ WinWorkstation. |
6968 " |
7010 " |
6969 grab and wait for leftButton being pressed |
7011 grab and wait for leftButton being pressed |
6970 " |
7012 " |
6971 origin := initialRectangle origin. |
7013 origin := initialRectangle origin. |
6972 |
7014 |
|
7015 displayRectangleBlock := |
|
7016 [:gc :rect | |
|
7017 gc |
|
7018 displayRectangle:(Screen |
|
7019 transformVirtualDisplayRectangleToRootDisplayRectangle:rect). |
|
7020 ]. |
|
7021 |
6973 root clippedByChildren:false. |
7022 root clippedByChildren:false. |
6974 root foreground:blackColor background:whiteColor. |
7023 root foreground:blackColor background:whiteColor. |
6975 |
7024 |
6976 delay := Delay forSeconds:0.05. |
7025 delay := Delay forSeconds:0.05. |
6977 |
7026 |
6979 |left right top bottom newOrigin newCorner p curs| |
7028 |left right top bottom newOrigin newCorner p curs| |
6980 |
7029 |
6981 keepExtent ifFalse:[ |
7030 keepExtent ifFalse:[ |
6982 corner := origin. |
7031 corner := origin. |
6983 rect := origin corner:corner. |
7032 rect := origin corner:corner. |
6984 root displayRectangle:rect. |
7033 |
|
7034 displayRectangleBlock |
|
7035 value:root |
|
7036 value:rect. |
6985 ]. |
7037 ]. |
6986 |
7038 |
6987 prevGrab := activePointerGrab. |
7039 prevGrab := activePointerGrab. |
6988 self grabPointerInView:root withCursor:curs1. |
7040 self grabPointerInView:root withCursor:curs1. |
6989 |
7041 |
6991 just in case; wait for button to be down ... |
7043 just in case; wait for button to be down ... |
6992 " |
7044 " |
6993 [self leftButtonPressed] whileFalse:[delay wait]. |
7045 [self leftButtonPressed] whileFalse:[delay wait]. |
6994 |
7046 |
6995 keepExtent ifTrue:[ |
7047 keepExtent ifTrue:[ |
6996 p := (self pointerPosition * scaleFactor) rounded. |
7048 p := self pointerPosition. |
6997 origin := p. |
7049 origin := p. |
6998 corner := origin + initialRectangle extent. |
7050 corner := origin + initialRectangle extent. |
6999 rect := origin corner:corner. |
7051 rect := origin corner:corner. |
7000 root displayRectangle:rect. |
7052 |
|
7053 displayRectangleBlock |
|
7054 value:root |
|
7055 value:rect. |
7001 ]. |
7056 ]. |
7002 |
7057 |
7003 [self leftButtonPressed] whileTrue:[ |
7058 [self leftButtonPressed] whileTrue:[ |
7004 left := initialRectangle origin x. |
7059 left := initialRectangle origin x. |
7005 top := initialRectangle origin y. |
7060 top := initialRectangle origin y. |
7006 right := initialRectangle corner x. |
7061 right := initialRectangle corner x. |
7007 bottom := initialRectangle corner y. |
7062 bottom := initialRectangle corner y. |
7008 |
7063 |
7009 p := (self pointerPosition * scaleFactor) rounded. |
7064 p := self pointerPosition. |
7010 keepExtent ifTrue:[ |
7065 keepExtent ifTrue:[ |
7011 newOrigin := p. |
7066 newOrigin := p. |
7012 newCorner := newOrigin + initialRectangle extent. |
7067 newCorner := newOrigin + initialRectangle extent. |
7013 curs := curs1. |
7068 curs := curs1. |
7014 ] ifFalse:[ |
7069 ] ifFalse:[ |
7037 newOrigin := left @ top. |
7092 newOrigin := left @ top. |
7038 newCorner := right @ bottom. |
7093 newCorner := right @ bottom. |
7039 ]. |
7094 ]. |
7040 |
7095 |
7041 ((newOrigin ~= origin) or:[newCorner ~= corner]) ifTrue:[ |
7096 ((newOrigin ~= origin) or:[newCorner ~= corner]) ifTrue:[ |
7042 root displayRectangle:rect. |
7097 displayRectangleBlock |
|
7098 value:root |
|
7099 value:rect. |
|
7100 |
7043 doRegrab ifTrue:[ |
7101 doRegrab ifTrue:[ |
7044 self grabPointerInView:root withCursor:curs1. |
7102 self grabPointerInView:root withCursor:curs1. |
7045 ]. |
7103 ]. |
7046 |
7104 |
7047 origin := newOrigin. |
7105 origin := newOrigin. |
7048 corner := newCorner. |
7106 corner := newCorner. |
7049 rect := origin corner:corner. |
7107 rect := origin corner:corner. |
7050 root displayRectangle:rect. |
7108 |
|
7109 displayRectangleBlock |
|
7110 value:root |
|
7111 value:rect. |
|
7112 |
7051 self disposeButtonEventsFor:nil. |
7113 self disposeButtonEventsFor:nil. |
7052 self flush. |
7114 self flush. |
7053 ] ifFalse:[ |
7115 ] ifFalse:[ |
7054 delay wait. |
7116 delay wait. |
7055 ] |
7117 ] |
7056 ]. |
7118 ]. |
7057 root displayRectangle:rect. |
7119 |
|
7120 displayRectangleBlock |
|
7121 value:root |
|
7122 value:rect. |
7058 ]. |
7123 ]. |
7059 |
7124 |
7060 |
7125 |
7061 self ungrabPointer. |
7126 self ungrabPointer. |
7062 prevGrab notNil ifTrue:[ |
7127 prevGrab notNil ifTrue:[ |
7076 Display rectangleFromUser |
7141 Display rectangleFromUser |
7077 Display rectangleFromUser:(100@100 corner:300@300) |
7142 Display rectangleFromUser:(100@100 corner:300@300) |
7078 Display rectangleFromUser:(100@100 corner:300@300) keepExtent:true |
7143 Display rectangleFromUser:(100@100 corner:300@300) keepExtent:true |
7079 " |
7144 " |
7080 |
7145 |
7081 "Created: / 14-11-2019 / 13:40:45 / Stefan Reise" |
7146 "Created: / 24-07-1997 / 15:26:47 / cg" |
|
7147 "Modified: / 10-09-1998 / 17:38:41 / cg" |
|
7148 "Modified: / 23-02-2017 / 13:30:21 / stefan" |
|
7149 "Modified: / 15-11-2019 / 10:26:36 / Stefan Reise" |
7082 ! |
7150 ! |
7083 |
7151 |
7084 topviewFromUser |
7152 topviewFromUser |
7085 "{ Pragma: +optSpace }" |
7153 "{ Pragma: +optSpace }" |
7086 |
7154 |