[squeak-dev] FFI: FFI-Examples-eem.3.mcz

commits at source.squeak.org commits at source.squeak.org
Tue May 19 21:32:59 UTC 2020


Eliot Miranda uploaded a new version of FFI-Examples to project FFI:
http://source.squeak.org/FFI/FFI-Examples-eem.3.mcz

==================== Summary ====================

Name: FFI-Examples-eem.3
Author: eem
Time: 19 May 2020, 2:30:52.589295 pm
UUID: 67a7e7fb-bde2-4f8e-8153-f53aa90a2b36
Ancestors: FFI-Examples-eem.2

a reorganized Examples package after several Win32 classes have (correctly) been moved to FFI-Win32.

=============== Diff against FFI-Examples-eem.2 ===============

Item was changed:
  ExternalStructure subclass: #MacPixPatPtr
  	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'FFI-Examples-MacOS'!
+ 
+ !MacPixPatPtr commentStamp: 'spd 5/16/2010 22:32' prior: 0!
+ See class comment for MacRect.!

Item was changed:
  ExternalStructure subclass: #MacPoint
  	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'FFI-Examples-MacOS'!
+ 
+ !MacPoint commentStamp: 'spd 5/16/2010 22:32' prior: 0!
+ See class comment for MacRect.!

Item was changed:
  ExternalStructure subclass: #MacRGBColor
  	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'FFI-Examples-MacOS'!
+ 
+ !MacRGBColor commentStamp: 'spd 5/16/2010 22:31' prior: 0!
+ See class comment for MacRect.!

Item was changed:
  ExternalStructure subclass: #MacRect
  	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'FFI-Examples-MacOS'!
+ 
+ !MacRect commentStamp: 'spd 5/16/2010 22:42' prior: 0!
+ I, with my friends (MacPixPatPtr, MacPoint and MacRGBColor), show how to make calls into a Mac OS framework.
+ 
+ The particular library I use in my examples, QuickDraw, is depreciated in OS X 10.4, but the examples still run as of OS X 10.6.2
+ See http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/QuickDraw_Ref/Reference/reference.html for more information.
+ 
+ WARNING: for Snow Leopard, see warning in MacOSShell!

Item was removed:
- Win32HGDIObj subclass: #Win32HBrush
- 	instanceVariableNames: ''
- 	classVariableNames: ''
- 	poolDictionaries: ''
- 	category: 'FFI-Examples-Win32'!

Item was removed:
- ----- Method: Win32HBrush class>>apiCreateHatchBrush:with: (in category 'api calls') -----
- apiCreateHatchBrush: aStyle with: colorref 
- 	"Creates a logical brush that has the specified hatch pattern and color"
- 	<apicall: Win32HBrush 'CreateHatchBrush' (long ulong) module: 'gdi32.dll'>
- 	^ self externalCallFailed!

Item was removed:
- ----- Method: Win32HBrush class>>backwardDiagonalWithColor: (in category 'hatch brushes') -----
- backwardDiagonalWithColor: aColor 
- 	"45-degree downward left-to-right hatch brush"
- 	^ self createHatchBrush: 3 color: aColor!

Item was removed:
- ----- Method: Win32HBrush class>>createHatchBrush:color: (in category 'instance creation') -----
- createHatchBrush: aStyle color: aColor 
- 	"Creates an instance of the receiver that has the specified hatch pattern and color"
- 	^ self apiCreateHatchBrush: aStyle with: aColor asColorref!

Item was removed:
- ----- Method: Win32HBrush class>>createSolidBrush: (in category 'instance creation') -----
- createSolidBrush: aCOLORREF
- 	<apicall: Win32HBrush 'CreateSolidBrush' (ulong) module: 'gdi32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32HBrush class>>crossWithColor: (in category 'hatch brushes') -----
- crossWithColor: aColor 
- 	"Horizontal and vertical crosshatch brush"
- 	^ self createHatchBrush: 4 color: aColor!

Item was removed:
- ----- Method: Win32HBrush class>>diagonalCrossWithColor: (in category 'hatch brushes') -----
- diagonalCrossWithColor: aColor 
- 	"45-degree crosshatch brush"
- 	^ self createHatchBrush: 5 color: aColor!

Item was removed:
- ----- Method: Win32HBrush class>>forwardDiagonalWithColor: (in category 'hatch brushes') -----
- forwardDiagonalWithColor: aColor 
- 	"45-degree upward left-to-right hatch brush"
- 	^ self createHatchBrush: 2 color: aColor!

Item was removed:
- ----- Method: Win32HBrush class>>horizontalWithColor: (in category 'hatch brushes') -----
- horizontalWithColor: aColor 
- 	"Horizontal hatch brush"
- 	^ self createHatchBrush: 0 color: aColor!

Item was removed:
- ----- Method: Win32HBrush class>>verticalWithColor: (in category 'hatch brushes') -----
- verticalWithColor: aColor 
- 	"Horizontal hatch brush"
- 	^ self createHatchBrush: 1 color: aColor !

Item was removed:
- Win32Handle subclass: #Win32HDC
- 	instanceVariableNames: ''
- 	classVariableNames: ''
- 	poolDictionaries: ''
- 	category: 'FFI-Examples-Win32'!

Item was removed:
- ----- Method: Win32HDC>>apiDeleteDC: (in category 'api calls') -----
- apiDeleteDC: aHDC
- 	<apicall: bool 'DeleteDC' (Win32HDC) module:'gdi32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32HDC>>apiDrawFocusRect:with: (in category 'api calls') -----
- apiDrawFocusRect: aHDC with: lpRect 
- 	"Draws a rectangle in the style used to indicate that the rectangle has 
- 	the focus."
- 	<apicall: bool 'DrawFocusRect' (Win32HDC Win32Rectangle*) module: 'user32.dll'>
- 	^ self externalCallFailed!

Item was removed:
- ----- Method: Win32HDC>>apiDrawFrameControl:with:with:with: (in category 'api calls') -----
- apiDrawFrameControl: aHDC with: lpRect with: type with: state
- 	"Draws a frame control of the specified type and style"
- 	<apicall: bool 'DrawFrameControl' (Win32HDC Win32Rectangle* ulong ulong) module: 'user32.dll'>
- 	^ self externalCallFailed!

Item was removed:
- ----- Method: Win32HDC>>apiEllipse:with:with:with:with: (in category 'api calls') -----
- apiEllipse: aHDC with: left with: top with: right with: bottom
- 	<apicall: bool 'Ellipse' (Win32HDC long long long long) module: 'gdi32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32HDC>>apiExtFloodFill:with:with:with:with: (in category 'api calls') -----
- apiExtFloodFill: aHDC with: x with: y with: colorref with: fillType 
- 	"fills an area of the display surface with the current brush"
- 	<apicall: bool 'ExtFloodFill' (Win32HDC long long ulong ulong) module: 'gdi32.dll'>
- 	^ self externalCallFailed!

Item was removed:
- ----- Method: Win32HDC>>apiFillRect:with:with: (in category 'api calls') -----
- apiFillRect: aHDC with: lpRect with: brush 
- 	"Fills a rectangle by using the specified brush. This function includes  
- 	the left and top borders, but excludes the right and bottom borders of  
- 	the rectangle.  
- 	"
- 	<apicall: char 'FillRect' (Win32HDC Win32Rectangle* Win32HBrush) module: 'user32.dll'>
- 	^ self externalCallFailed!

Item was removed:
- ----- Method: Win32HDC>>apiFrameRect:with:with: (in category 'api calls') -----
- apiFrameRect: aHDC with: lpRect with: brush 
- 	"Draws a border around the specified rectangle by using the specified brush. The width and height of the border are always one logical unit."
- 	<apicall: char 'FrameRect' (Win32HDC Win32Rectangle* Win32HBrush) module: 'user32.dll'>
- 	^ self externalCallFailed!

Item was removed:
- ----- Method: Win32HDC>>apiLineTo:with:with: (in category 'api calls') -----
- apiLineTo: aHDC with: x with: y
- 	<apicall: bool 'LineTo' (Win32HDC long long) module:'gdi32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32HDC>>apiMoveToEx:with:with:with: (in category 'api calls') -----
- apiMoveToEx: aHDC with: x with: y with: pt
- 	<apicall: bool 'MoveToEx' (Win32HDC long long Win32Point*) module: 'gdi32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32HDC>>apiRectangle:with:with:with:with: (in category 'api calls') -----
- apiRectangle: aHDC with: left with: top with: right with: bottom
- 	<apicall: bool 'Rectangle' (Win32HDC long long long long) module: 'gdi32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32HDC>>apiRoundRect:with:with:with:with:with:with: (in category 'api calls') -----
- apiRoundRect: aHDC with: left with: top with: right with: bottom with: width with: height
- 	"Draws a rectangle with rounded corners. The rectangle is outlined by  
- 	using the current pen and filled by using the current brush"
- 	<apicall: bool 'RoundRect' (Win32HDC long long long long long long) module: 'gdi32.dll'>
- 	^ self externalCallFailed!

Item was removed:
- ----- Method: Win32HDC>>apiSelectObject:with: (in category 'api calls') -----
- apiSelectObject: aHDC with: aHGDIOBJ
- 	<apicall: Win32HGDIObj 'SelectObject' (Win32HDC Win32HGDIObj) module: 'gdi32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32HDC>>delete (in category 'initialize-release') -----
- delete
- 	handle == nil
- 		ifFalse:[self apiDeleteDC: self].
- 	handle := nil.!

Item was removed:
- ----- Method: Win32HDC>>drawFocusRectangle: (in category 'drawing') -----
- drawFocusRectangle: aRect  
- 	"draws a rectangle in the style used to indicate that the rectangle has the focus"
-  
- 	self
- 		apiDrawFocusRect: self
- 		with: (Win32Rectangle fromRectangle: aRect)
- 	 
- 	 !

Item was removed:
- ----- Method: Win32HDC>>drawFrameControl:type:style: (in category 'drawing') -----
- drawFrameControl: aRect type: aType style: aStyle
- 	"Draws a frame control of the specified type and style (integer values)"
- 	self apiDrawFrameControl: self with: (Win32Rectangle fromRectangle: aRect) with: aType with: aStyle!

Item was removed:
- ----- Method: Win32HDC>>ellipse: (in category 'drawing') -----
- ellipse: aRect
- 	^self apiEllipse: self with: aRect left with: aRect top with: aRect right with: aRect bottom!

Item was removed:
- ----- Method: Win32HDC>>fillRectangle:color: (in category 'drawing') -----
- fillRectangle: aRect color: aColor 
- 	"fills an area of the display with the given color"
- 	| brush |
- 	 
- 	brush := Win32HBrush createSolidBrush: aColor asColorref.
- 	self
- 		apiFillRect: self
- 		with: (Win32Rectangle fromRectangle: aRect)
- 		with: brush.
- 	brush delete!

Item was removed:
- ----- Method: Win32HDC>>floodFillAt:boundaryColor:fillColor: (in category 'drawing') -----
- floodFillAt: aPoint boundaryColor: aColor fillColor: anotherColor 
- 	"fills an area of the display with the given color"
- 	| newBrush oldBrush |
- 	newBrush := Win32HBrush createSolidBrush: anotherColor asColorref.
- 	oldBrush := self selectObject: newBrush.
- 	(self
- 		apiExtFloodFill: self
- 		with: aPoint x
- 		with: aPoint y
- 		with: aColor asColorref
- 		with: 0) inspect.
- 	self selectObject: oldBrush.
- 	newBrush delete!

Item was removed:
- ----- Method: Win32HDC>>frameRectangle:brush: (in category 'drawing') -----
- frameRectangle: aRect brush: aBrush
- 	"Draws a border around the specified rectangle by using the specified brush. The width and height of the border are always one logical unit."
-  
- 	self
- 		apiFrameRect: self
- 		with: (Win32Rectangle fromRectangle: aRect)
- 		with: aBrush.
-  !

Item was removed:
- ----- Method: Win32HDC>>lineTo: (in category 'drawing') -----
- lineTo: aPoint
- 	^self apiLineTo: self with: aPoint x with: aPoint y!

Item was removed:
- ----- Method: Win32HDC>>moveTo: (in category 'drawing') -----
- moveTo: aPoint
- 	^self apiMoveToEx: self with: aPoint x with: aPoint y with: nil!

Item was removed:
- ----- Method: Win32HDC>>rectangle: (in category 'drawing') -----
- rectangle: aRect
- 	^self apiRectangle: self with: aRect left with: aRect top with: aRect right with: aRect bottom!

Item was removed:
- ----- Method: Win32HDC>>roundRectangle:width:height: (in category 'drawing') -----
- roundRectangle: aRect width: width height: height 
- 	^ self
- 		apiRoundRect: self
- 		with: aRect left
- 		with: aRect top
- 		with: aRect right
- 		with: aRect bottom
- 		with: width
- 		with: height!

Item was removed:
- ----- Method: Win32HDC>>selectObject: (in category 'drawing') -----
- selectObject: aHGDIOBJ
- 	^self apiSelectObject: self with: aHGDIOBJ!

Item was removed:
- Win32Handle subclass: #Win32HGDIObj
- 	instanceVariableNames: ''
- 	classVariableNames: ''
- 	poolDictionaries: ''
- 	category: 'FFI-Examples-Win32'!

Item was removed:
- ----- Method: Win32HGDIObj>>apiDeleteObject: (in category 'api calls') -----
- apiDeleteObject: aHGDIOBJ
- 	<apicall: bool 'DeleteObject' (Win32HGDIObj) module: 'gdi32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32HGDIObj>>delete (in category 'initialize-release') -----
- delete
- 	self apiDeleteObject: self!

Item was removed:
- ExternalStructure subclass: #Win32Handle
- 	instanceVariableNames: ''
- 	classVariableNames: ''
- 	poolDictionaries: ''
- 	category: 'FFI-Examples-Win32'!

Item was removed:
- ----- Method: Win32Handle class>>fields (in category 'accessing') -----
- fields
- 	"Win32Handle defineFields"
- 	"The following really means
- 		typedef void* Win32Handle;
- 	"
- 	^#(nil	'ulong') "an opaque 32bit handle"!

Item was removed:
- ExternalStructure subclass: #Win32Point
- 	instanceVariableNames: ''
- 	classVariableNames: ''
- 	poolDictionaries: ''
- 	category: 'FFI-Examples-Win32'!

Item was removed:
- ----- Method: Win32Point class>>apiGetCursorPos: (in category 'api calls') -----
- apiGetCursorPos: pt
- 	<apicall: bool 'GetCursorPos' (Win32Point*) module: 'user32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32Point class>>fields (in category 'accessing') -----
- fields
- 	"POINT defineFields"
- 	^#(
- 		(x 'long')
- 		(y 'long')
- 	)!

Item was removed:
- ----- Method: Win32Point class>>getCursorPos (in category 'instance creation') -----
- getCursorPos
- 	| pt |
- 	pt := self new.
- 	self apiGetCursorPos: pt.
- 	^pt!

Item was removed:
- ----- Method: Win32Point>>asPoint (in category 'converting') -----
- asPoint
- 	^self x @ self y!

Item was removed:
- ----- Method: Win32Point>>x (in category 'accessing') -----
- x
- 	"This method was automatically generated"
- 	^handle signedLongAt: 1!

Item was removed:
- ----- Method: Win32Point>>x: (in category 'accessing') -----
- x: anObject
- 	"This method was automatically generated"
- 	handle signedLongAt: 1 put: anObject!

Item was removed:
- ----- Method: Win32Point>>y (in category 'accessing') -----
- y
- 	"This method was automatically generated"
- 	^handle signedLongAt: 5!

Item was removed:
- ----- Method: Win32Point>>y: (in category 'accessing') -----
- y: anObject
- 	"This method was automatically generated"
- 	handle signedLongAt: 5 put: anObject!

Item was removed:
- ExternalStructure subclass: #Win32Rectangle
- 	instanceVariableNames: ''
- 	classVariableNames: ''
- 	poolDictionaries: ''
- 	category: 'FFI-Examples-Win32'!

Item was removed:
- ----- Method: Win32Rectangle class>>fields (in category 'accessing') -----
- fields
- 	"Win32Rectangle defineFields"
- 	^ #(#(#left 'long') #(#top 'long') #(#right 'long') #(#bottom 'long') )!

Item was removed:
- ----- Method: Win32Rectangle class>>fromRectangle: (in category 'instance creation') -----
- fromRectangle: rc 
- 	"returns an instance of the receiver from the given smalltalk rectangle"
- 	^ self new left: rc left top: rc top right: rc right bottom: rc bottom  !

Item was removed:
- ----- Method: Win32Rectangle>>bottom (in category 'accessing') -----
- bottom
- 	"This method was automatically generated"
- 	^handle signedLongAt: 13!

Item was removed:
- ----- Method: Win32Rectangle>>bottom: (in category 'accessing') -----
- bottom: anObject
- 	"This method was automatically generated"
- 	handle signedLongAt: 13 put: anObject!

Item was removed:
- ----- Method: Win32Rectangle>>left (in category 'accessing') -----
- left
- 	"This method was automatically generated"
- 	^handle signedLongAt: 1!

Item was removed:
- ----- Method: Win32Rectangle>>left: (in category 'accessing') -----
- left: anObject
- 	"This method was automatically generated"
- 	handle signedLongAt: 1 put: anObject!

Item was removed:
- ----- Method: Win32Rectangle>>left:top:right:bottom: (in category 'accessing') -----
- left: left top: top right: right bottom: bottom
- 	"sets the coordinates of the receiver"
- 
- 	self left: left.
- 	self top: top.
- 	self right: right.
- 	self bottom: bottom !

Item was removed:
- ----- Method: Win32Rectangle>>right (in category 'accessing') -----
- right
- 	"This method was automatically generated"
- 	^handle signedLongAt: 9!

Item was removed:
- ----- Method: Win32Rectangle>>right: (in category 'accessing') -----
- right: anObject
- 	"This method was automatically generated"
- 	handle signedLongAt: 9 put: anObject!

Item was removed:
- ----- Method: Win32Rectangle>>top (in category 'accessing') -----
- top
- 	"This method was automatically generated"
- 	^handle signedLongAt: 5!

Item was removed:
- ----- Method: Win32Rectangle>>top: (in category 'accessing') -----
- top: anObject
- 	"This method was automatically generated"
- 	handle signedLongAt: 5 put: anObject!

Item was removed:
- ExternalObject subclass: #Win32Shell
- 	instanceVariableNames: ''
- 	classVariableNames: ''
- 	poolDictionaries: ''
- 	category: 'FFI-Examples-Win32'!
- 
- !Win32Shell commentStamp: '<historical>' prior: 0!
- This class wrappes the Windows 32 shell.
- 
- Try 
- 	Win32Shell new shellOpen: 'c:\image.bmp' 		to open a document
- 	Win32Shell new shellOpen: 'c:\myprogram.exe' 	to start an executable
- 	Win32Shell new shellExplore: 'c:\'				to explore a directory
- 	Win32Shell new shellFind: 'c:\' 					to initiate a search
- 
- Note that this class is platform specific.
-  
-  !

Item was removed:
- ----- Method: Win32Shell>>shellExecute:lpOperation:lpFile:lpParameters:lpDirectory:nShowCmd: (in category 'api calls') -----
- shellExecute: hwnd lpOperation: opString lpFile: fileString lpParameters: parmString lpDirectory: dirString nShowCmd: anInteger
- 	"Opens or prints the specified file, which can be an executable or document file.
- 		HINSTANCE ShellExecute(
- 	  		HWND hwnd,			// handle to parent window
- 			LPCTSTR lpOperation,	// pointer to string that specifies operation to perform
- 			LPCTSTR lpFile,		// pointer to filename or folder name string
- 			LPCTSTR lpParameters,	// pointer to string that specifies executable-file parameters 
- 			LPCTSTR lpDirectory,	// pointer to string that specifies default directory
- 			INT nShowCmd 			// whether file is shown when opened
- 		);"
- 	<apicall: long 'ShellExecuteA' (long char* char* char* char* ulong) module:'shell32.dll'>!

Item was removed:
- ----- Method: Win32Shell>>shellExplore: (in category 'operations') -----
- shellExplore: aPathString
- 	"Explores the folder specified by aPathString"
- 
- 	(self shellExecute: nil 
- 		lpOperation: 'explore'
- 		lpFile: aPathString
- 		lpParameters: nil
- 		lpDirectory: nil
- 		nShowCmd: 1) <= 32 ifTrue: [self error: 'system error']!

Item was removed:
- ----- Method: Win32Shell>>shellFind: (in category 'operations') -----
- shellFind: aPathString
- 	"Initiates a search starting from the specified directory."
- 
- 	(self shellExecute: nil 
- 		lpOperation: 'find'
- 		lpFile: nil
- 		lpParameters: nil
- 		lpDirectory: aPathString
- 		nShowCmd: 1) <= 32 ifTrue: [self error: 'system error']!

Item was removed:
- ----- Method: Win32Shell>>shellOpen: (in category 'operations') -----
- shellOpen: aFileString
- 	"Opens the file specified by aFileString. The file can be an executable file, a document file, 
- 	 or a folder."
- 
- 	(self shellExecute: nil 
- 		lpOperation: 'open'
- 		lpFile: aFileString
- 		lpParameters: nil
- 		lpDirectory: nil
- 		nShowCmd: 1) <= 32 ifTrue: [self error: 'system error']!

Item was removed:
- Object subclass: #Win32Utils
- 	instanceVariableNames: ''
- 	classVariableNames: ''
- 	poolDictionaries: ''
- 	category: 'FFI-Examples-Win32'!
- 
- !Win32Utils commentStamp: 'tbn 8/22/2005 23:50' prior: 0!
- This is an utility class with helpfull methods for Win32 users. Note that it uses FFI and is 
- platform dependent.!

Item was removed:
- ----- Method: Win32Utils class>>apiGetEnvironmentVariable:with:with: (in category 'api calls') -----
- apiGetEnvironmentVariable: lpName with: lpBuffer with: nSize
-    <apicall: ulong 'GetEnvironmentVariableA' (char* byte* ulong) module: 'kernel32.dll'>
-    ^self externalCallFailed!

Item was removed:
- ----- Method: Win32Utils class>>getCommonEnvironmentVariables (in category 'examples') -----
- getCommonEnvironmentVariables
- 	"Returns a dictionary with common environment variables for Win32 systems"
- 
- 	|map|
- 	map := Dictionary new.
- 	#('ALLUSERSPROFILE' 'APPDATA' 'COMPUTERNAME' 'COMSPEC' 'HOMEDRIVE' 'HOMEPATH' 'LOGONSERVER'
-        'SYSTEMDRIVE' 'OS' 'PATH' 'SYSTEMROOT' 'TEMP' 'TMP' 'USERDOMAIN' 'USERNAME' 'USERPROFILE' 'WINDIR') 
- 		do: [:each | map at: each put: (self getEnvironmentVariable: each)].
- 	^map
- 		!

Item was removed:
- ----- Method: Win32Utils class>>getEnvironmentVariable: (in category 'accessing') -----
- getEnvironmentVariable: aString
-    "Win32Utils getEnvironmentVariable: 'windir'"
- 
-    | buffer size |
-    size := self apiGetEnvironmentVariable: aString with: nil with: 0.
-    buffer := String new: size.
-    self apiGetEnvironmentVariable: aString with: buffer with: size.
-    ^buffer allButLast!

Item was removed:
- Win32Handle subclass: #Win32Window
- 	instanceVariableNames: ''
- 	classVariableNames: ''
- 	poolDictionaries: ''
- 	category: 'FFI-Examples-Win32'!
- 
- !Win32Window commentStamp: '<historical>' prior: 0!
- Here's a simple Win32 example:
- 	| hwnd dc dst |
- 	hwnd _ Win32Window getFocus. "fetch the window currently having the focus"
- 	dc _ hwnd getDC. "grab the dc or the window"
- 	dst _ 100.
- 	dc moveTo: 0 at 0.
- 	"draw a rect"
- 	dc lineTo: dst at 0. dc lineTo: dst at dst. dc lineTo: 0 at dst. dc lineTo: 0 at 0.
- 	"and a cross"
- 	dc lineTo: dst at dst. dc moveTo: dst at 0. dc lineTo: 0 at dst.
- 	hwnd releaseDC: dc.!

Item was removed:
- ----- Method: Win32Window class>>coloredEllipses (in category 'examples') -----
- coloredEllipses "Win32Window coloredEllipses"
- 	"Draw a bunch of ellipses"
- 	| rnd pt1 pt2 w h colors newBrush oldBrush |
- 	colors := Color colorNames collect:[:cName| (Color perform: cName)].
- 	"convert to COLORREF"
- 	colors := colors collect:[:c| 
- 		(c red * 255) asInteger + 
- 			((c green * 255) asInteger << 8) + 
- 				((c blue * 255) asInteger << 16)].
- 	rnd := Random new.
- 	w := Display width.
- 	h := Display height.
- 	self getFocus getHDCDuring:[:hDC|
- 		[Sensor anyButtonPressed] whileFalse:[
- 			newBrush := Win32HBrush createSolidBrush: colors atRandom.
- 			oldBrush := hDC selectObject: newBrush.
- 			pt1 := (rnd next * w) asInteger @ (rnd next * h) asInteger.
- 			pt2 := (rnd next * w) asInteger @ (rnd next * h) asInteger.
- 			hDC ellipse: (Rectangle encompassing: (Array with: pt1 with: pt2)).
- 			hDC selectObject: oldBrush.
- 			newBrush delete.
- 		].
- 	].
- 	Display forceToScreen.!

Item was removed:
- ----- Method: Win32Window class>>coloredRectangles (in category 'examples') -----
- coloredRectangles "Win32Window coloredRectangles"
- 	"Draw a bunch of ellipses"
- 	| rnd pt1 pt2 w h colors newBrush oldBrush n nPixels time r |
- 	colors := Color colorNames collect:[:cName| (Color perform: cName)].
- 	"convert to COLORREF"
- 	colors := colors collect:[:c| 
- 		(c red * 255) asInteger + 
- 			((c green * 255) asInteger << 8) + 
- 				((c blue * 255) asInteger << 16)].
- 	rnd := Random new.
- 	w := Display width.
- 	h := Display height.
- 	self getFocus getHDCDuring:[:hDC|
- 		n := 0.
- 		nPixels := 0.
- 		time := Time millisecondClockValue.
- 		[Sensor anyButtonPressed] whileFalse:[
- 			newBrush := Win32HBrush createSolidBrush: colors atRandom.
- 			oldBrush := hDC selectObject: newBrush.
- 			pt1 := (rnd next * w) asInteger @ (rnd next * h) asInteger.
- 			pt2 := (rnd next * w) asInteger @ (rnd next * h) asInteger.
- 			hDC rectangle: (r := Rectangle encompassing: (Array with: pt1 with: pt2)).
- 			hDC selectObject: oldBrush.
- 			newBrush delete.
- 			n := n + 1.
- 			nPixels := nPixels + ((r right - r left) * (r bottom - r top)).
- 			(n \\ 100) = 0 ifTrue:[
- 				'Pixel fillRate: ', (nPixels * 1000 // (Time millisecondClockValue - time))
- 					asStringWithCommas displayAt: 0 at 0].
- 		].
- 	].
- 	Display forceToScreen.!

Item was removed:
- ----- Method: Win32Window class>>getDesktopWindow (in category 'accessing') -----
- getDesktopWindow
- 	"Return the HWND describing the desktop"
- 	<apicall: Win32Window 'GetDesktopWindow' (void) module: 'user32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32Window class>>getFocus (in category 'accessing') -----
- getFocus
- 	"Return the HWND currently having the input focus"
- 	<apicall: Win32Window 'GetFocus' (void) module: 'user32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32Window class>>win32Draw (in category 'examples') -----
- win32Draw "Win32Window win32Draw"
- 	"Draw a bunch of lines using the Windows API"
- 	| hWnd hDC pt |
- 	hWnd := Win32Window getFocus.
- 	hDC := hWnd getDC.
- 	hDC moveTo: (hWnd screenToClient: Win32Point getCursorPos).
- 	[Sensor anyButtonPressed] whileFalse:[
- 		pt := Win32Point getCursorPos.
- 		hWnd screenToClient: pt.
- 		hDC lineTo: pt.
- 	].
- 	hWnd releaseDC: hDC.
- 	Display forceToScreen.!

Item was removed:
- ----- Method: Win32Window>>apiGetDC: (in category 'api calls') -----
- apiGetDC: aHWND
- 	<apicall: Win32HDC 'GetDC' (Win32Window) module: 'user32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32Window>>apiGetParent: (in category 'api calls') -----
- apiGetParent: aWindow
- 	<apicall: Win32Window 'GetParent' (Win32Window) module: 'user32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32Window>>apiMessageBox:text:title:flags: (in category 'api calls') -----
- apiMessageBox: aHWND text: aString title: aTitle flags: flags
- 	<apicall: long 'MessageBoxA' (Win32Window char* char* ulong) module:'user32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32Window>>apiReleaseDC:with: (in category 'api calls') -----
- apiReleaseDC: aHWND with: aHDC
- 	<apicall: long 'ReleaseDC' (Win32Window Win32HDC) module:'user32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32Window>>apiScreenToClient:with: (in category 'api calls') -----
- apiScreenToClient: aHWND with: aPOINT
- 	<apicall: bool 'ScreenToClient' (Win32Window Win32Point*) module: 'user32.dll'>
- 	^self externalCallFailed!

Item was removed:
- ----- Method: Win32Window>>getDC (in category 'accessing') -----
- getDC
- 	"Return the DC associated with the window"
- 	^self apiGetDC: self!

Item was removed:
- ----- Method: Win32Window>>getHDCDuring: (in category 'accessing') -----
- getHDCDuring: aBlock
- 	"Provide a Win32 HDC during the execution of aBlock"
- 	| hDC |
- 	hDC := self getDC.
- 	[aBlock value: hDC] ensure:[self releaseDC: hDC].!

Item was removed:
- ----- Method: Win32Window>>getParent (in category 'accessing') -----
- getParent
- 	| wnd |
- 	wnd := self apiGetParent: self.
- 	^wnd handle = 0 ifTrue:[nil] ifFalse:[wnd]!

Item was removed:
- ----- Method: Win32Window>>messageBox: (in category 'accessing') -----
- messageBox: aString
- 	"Win32Window getFocus messageBox:'Hello World'"
- 	^self messageBox: aString title:'Squeak'!

Item was removed:
- ----- Method: Win32Window>>messageBox:title: (in category 'accessing') -----
- messageBox: aString title: aTitle
- 	"Win32Window getFocus messageBox:'Hello World' title:'News from Squeak:'"
- 	^self messageBox: aString title: aTitle flags: 0!

Item was removed:
- ----- Method: Win32Window>>messageBox:title:flags: (in category 'accessing') -----
- messageBox: aString title: aTitle flags: flags
- 	"Win32Window getFocus messageBox:'Are you ready???' title:'News from Squeak:' flags: 3"
- 	^self apiMessageBox: self text: aString title: aTitle flags: flags!

Item was removed:
- ----- Method: Win32Window>>releaseDC: (in category 'accessing') -----
- releaseDC: aHDC
- 	"Release the given DC"
- 	self apiReleaseDC: self with: aHDC!

Item was removed:
- ----- Method: Win32Window>>screenToClient: (in category 'accessing') -----
- screenToClient: aPoint
- 	self apiScreenToClient: self with: aPoint.
- 	^aPoint!

Item was added:
+ ----- Method: X11Display class>>new (in category 'instance creation') -----
+ new
+ 	^ self on: nil!

Item was added:
+ ----- Method: X11Display class>>on: (in category 'instance creation') -----
+ on: aStringOrNil
+ 	^ self XOpenDisplay: aStringOrNil!

Item was added:
+ ----- Method: X11Display>>None (in category 'xlib calls') -----
+ None
+ 	^ 0!

Item was added:
+ ----- Method: X11Display>>XWarpPointer:sourceWindow:destWindow:sourceX:sourceY:sourceWidth:sourceHeight:destX:destY: (in category 'xlib calls') -----
+ XWarpPointer: display sourceWindow: srcWindowID destWindow: destWindowID sourceX: srcX sourceY: srcY sourceWidth: srcWidth sourceHeight: srcHeight destX: destX destY: destY
+ 	<cdecl: bool 'XWarpPointer' (X11Display* ulong ulong long long ulong ulong long long) module: 'X11'>
+ 	^self externalCallFailed!

Item was added:
+ ----- Method: X11Display>>warpPointerBy: (in category 'accessing') -----
+ warpPointerBy: aPoint
+ "Moves the mouse pointer from its current location to its current location + aPoint. Generates a mouse move event if the squeak window is active"
+ 
+ 	^ self XWarpPointer: self
+ 		sourceWindow: self None
+ 		destWindow: self None
+ 		sourceX: 0 sourceY: 0 sourceWidth: 0 sourceHeight: 0
+ 		destX: aPoint x destY: aPoint y!

Item was added:
+ ----- Method: X11Display>>warpPointerFrom:in:To:in: (in category 'accessing') -----
+ warpPointerFrom: aRectangle in: sourceWindow To: aPoint in: destWindow
+ "Moves the mouse pointer to aPoint relative to the top-left corner of a window"
+ 
+ 	^ self XWarpPointer: self
+ 		sourceWindow: sourceWindow xid
+ 		destWindow: destWindow xid
+ 		sourceX: aRectangle left sourceY: aRectangle top
+ 			sourceWidth: aRectangle width sourceHeight: aRectangle height
+ 		destX: aPoint x destY: aPoint y!

Item was added:
+ ----- Method: X11Display>>warpPointerTo:in: (in category 'accessing') -----
+ warpPointerTo: aPoint in: aWindow
+ "Moves the mouse pointer to aPoint relative to the top-left corner of a window"
+ 
+ 	^ self XWarpPointer: self
+ 		sourceWindow: self None
+ 		destWindow: aWindow xid
+ 		sourceX: 0 sourceY: 0 sourceWidth: 0 sourceHeight: 0
+ 		destX: aPoint x destY: aPoint y!

Item was added:
+ ----- Method: X11Drawable class>>none (in category 'instance creation') -----
+ none
+ "Universal null resource or null atom"
+ 	^ self new!

Item was added:
+ ----- Method: X11Drawable>>xid: (in category 'accessing') -----
+ xid: anUnsignedInteger
+ 	xid := anUnsignedInteger!



More information about the Squeak-dev mailing list