WinWorkstation.st
changeset 8861 0471653a6a2d
parent 8768 b6d390b45b83
child 8862 01f3bcebcd5c
equal deleted inserted replaced
8860:221bf6fa2dfc 8861:0471653a6a2d
    20 		eventTrace eventBuffer lastClipboardSequenceNumber
    20 		eventTrace eventBuffer lastClipboardSequenceNumber
    21 		lastNativeFileDialogOutputStream'
    21 		lastNativeFileDialogOutputStream'
    22 	classVariableNames:'BeepDuration NativeDialogs NativeFileDialogs NativeWidgets
    22 	classVariableNames:'BeepDuration NativeDialogs NativeFileDialogs NativeWidgets
    23 		NativeWidgetClassTable StandardColorValues IgnoreSysColorChanges
    23 		NativeWidgetClassTable StandardColorValues IgnoreSysColorChanges
    24 		IgnoreFontChanges SystemColorValues CanEndSession
    24 		IgnoreFontChanges SystemColorValues CanEndSession
    25 		VerboseNativeDialogs'
    25 		VerboseNativeDialogs ScaleFactorByUser NativeDisplayResolution'
    26 	poolDictionaries:''
    26 	poolDictionaries:''
    27 	category:'Interface-Graphics'
    27 	category:'Interface-Graphics'
    28 !
    28 !
    29 
    29 
    30 Object subclass:#AlphaBlendParameters
    30 Object subclass:#AlphaBlendParameters
  6578     "return true, if this device is a windows screen"
  6578     "return true, if this device is a windows screen"
  6579 
  6579 
  6580     ^ true
  6580     ^ true
  6581 !
  6581 !
  6582 
  6582 
       
  6583 nativeDisplayResolution
       
  6584     "the powershell call is too expensive,
       
  6585      so cache it, you need to restart the app,
       
  6586      when you want to get an effect of changed display"
       
  6587 
       
  6588     "
       
  6589         self nativeDisplayResolution       
       
  6590     "
       
  6591 
       
  6592     |primNativeDisplayResolution|
       
  6593 
       
  6594     NativeDisplayResolution isNil ifTrue:[
       
  6595         primNativeDisplayResolution := self primNativeDisplayResolution.
       
  6596         primNativeDisplayResolution isNil ifTrue:[
       
  6597             "/ set 0 to avoid multiple calls of #primNativeDisplayResolution
       
  6598             NativeDisplayResolution := 0.
       
  6599         ] ifFalse:[
       
  6600             NativeDisplayResolution := primNativeDisplayResolution.
       
  6601         ].
       
  6602     ].
       
  6603 
       
  6604     "0 is the ident for nil"
       
  6605     NativeDisplayResolution == 0 ifTrue:[
       
  6606         ^ nil
       
  6607     ].
       
  6608 
       
  6609     ^ NativeDisplayResolution
       
  6610 
       
  6611     "Created: / 14-11-2019 / 13:36:08 / Stefan Reise"
       
  6612 !
       
  6613 
  6583 platformName
  6614 platformName
  6584     "ST-80 compatibility.
  6615     "ST-80 compatibility.
  6585      Return a string describing the display systems platform.
  6616      Return a string describing the display systems platform.
  6586      WinWorkstation always returns 'WIN32'."
  6617      WinWorkstation always returns 'WIN32'."
  6587 
  6618 
  6588     ^ 'WIN32'
  6619     ^ 'WIN32'
  6589 
  6620 
  6590     "Modified: 26.5.1996 / 15:32:46 / cg"
  6621     "Modified: 26.5.1996 / 15:32:46 / cg"
       
  6622 !
       
  6623 
       
  6624 primNativeDisplayResolution
       
  6625     "
       
  6626         self primNativeDisplayResolution      
       
  6627     "
       
  6628 
       
  6629     |output modeLine tmpString dataAsString
       
  6630      x y|
       
  6631 
       
  6632     output := '' writeStream.
       
  6633 
       
  6634     OperatingSystem
       
  6635         executePowershellCommands:(Array 
       
  6636             with:'Get-CimInstance -ClassName CIM_VideoController')
       
  6637         outputTo:output.
       
  6638 
       
  6639     modeLine := (output contents 
       
  6640         subStrings:Character cr) 
       
  6641             detect:[:eachLine | eachLine startsWith:'VideoModeDescription']
       
  6642             ifNone:[
       
  6643                 ^ nil
       
  6644             ].
       
  6645 
       
  6646     tmpString := (modeLine 
       
  6647         subStrings:$:)
       
  6648             at:2
       
  6649             ifAbsent:[
       
  6650                 ^ nil
       
  6651             ].
       
  6652 
       
  6653     dataAsString := (tmpString 
       
  6654         subStrings:$x)
       
  6655             collect:[:each | 
       
  6656                 each withoutSeparators
       
  6657             ].
       
  6658 
       
  6659     x := dataAsString 
       
  6660         at:1  
       
  6661         ifAbsent:[
       
  6662             ^ nil
       
  6663         ].
       
  6664 
       
  6665     x := Integer 
       
  6666         readFrom:x
       
  6667         onError:[
       
  6668             ^ nil
       
  6669         ].
       
  6670 
       
  6671     y := dataAsString 
       
  6672         at:2 
       
  6673         ifAbsent:[
       
  6674             ^ nil
       
  6675         ].
       
  6676 
       
  6677     y := Integer 
       
  6678         readFrom:y
       
  6679         onError:[
       
  6680             ^ nil
       
  6681         ].
       
  6682 
       
  6683     ^ x@y
       
  6684 
       
  6685     "Created: / 14-11-2019 / 13:35:59 / Stefan Reise"
       
  6686 !
       
  6687 
       
  6688 scaleFactorByUser
       
  6689     "this is the scale factor the user did enter within the windows settings,
       
  6690      for e.g. the user can choose between 100, 125, 150 etc.
       
  6691      here we return 1, 1.25 1.5
       
  6692      the call is too expensive (powershell),
       
  6693      so cache it, you need to restart the app,
       
  6694      when you want to get an effect of changed scaling"
       
  6695 
       
  6696     "
       
  6697         ScaleFactorByUser := nil.   
       
  6698         self scaleFactorByUser      
       
  6699     "
       
  6700 
       
  6701     |output scaledDesktopResolution|
       
  6702 
       
  6703     ScaleFactorByUser isNil ifTrue:[
       
  6704         output := '' writeStream.
       
  6705 
       
  6706         OperatingSystem 
       
  6707             executePowershellCommands:(Array
       
  6708                 with:'[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms");'
       
  6709                 with:'$ScreenExtent = [System.Windows.Forms.SystemInformation]::PrimaryMonitorSize;'
       
  6710                 with:'$Width = $ScreenExtent.Width;'
       
  6711                 with:'$Height = $ScreenExtent.Height;'
       
  6712                 with:'Write-Output "$Width@$Height";')
       
  6713             outputTo:output.
       
  6714 
       
  6715         scaledDesktopResolution := Point 
       
  6716             readFrom:output contents withoutSeparators 
       
  6717             onError:nil.
       
  6718 
       
  6719         scaledDesktopResolution isNil ifTrue:[
       
  6720             ScaleFactorByUser := 1@1.
       
  6721         ] ifFalse:[
       
  6722             ScaleFactorByUser := Display extent / scaledDesktopResolution.   
       
  6723         ].
       
  6724     ].
       
  6725 
       
  6726     ^ ScaleFactorByUser
       
  6727 
       
  6728     "Created: / 14-11-2019 / 13:25:46 / Stefan Reise"
       
  6729 !
       
  6730 
       
  6731 scaleFactorForRootDisplayCoordinates
       
  6732     "this is the factor we need to adopt for the root display coordinates,
       
  6733      if windows did scale the application"
       
  6734 
       
  6735     "
       
  6736         self scaleFactorForRootDisplayCoordinates              
       
  6737     "
       
  6738 
       
  6739     |nativeDisplayResolution|
       
  6740 
       
  6741     "here we assume the user has the native resolution with a scaling,
       
  6742      sorry no support for non native resolutions,
       
  6743      because I did not found any mechanism,
       
  6744      which did return the user specified resolution without any scaling"
       
  6745     nativeDisplayResolution := self nativeDisplayResolution.
       
  6746     nativeDisplayResolution isNil ifTrue:[
       
  6747         ^ 1@1
       
  6748     ].
       
  6749 
       
  6750     ^ nativeDisplayResolution / Display extent
       
  6751 
       
  6752     "Created: / 14-11-2019 / 13:36:59 / Stefan Reise"
  6591 ! !
  6753 ! !
  6592 
  6754 
  6593 !WinWorkstation methodsFor:'accessing & queries'!
  6755 !WinWorkstation methodsFor:'accessing & queries'!
  6594 
  6756 
  6595 activateOnClick:aBoolean
  6757 activateOnClick:aBoolean