Smalltalk User Guide : Making your own applications : Using TrailBlazer browsers : Example: Enabling a Display Image push button
Example: Enabling a Display Image push button
You can view the captured BMP files using the CgImageViewer class of the Smalltalk Programming Examples. To install the Smalltalk examples, load the configuration map ENVY/Image Examples, which loads the applications CommonExamplesFramework, CommonExampleLauncher, CwExamples, and CgExamples. You can open an instance of CgImageViewer by doing the following:
1. Evaluate CwExampleLauncher new open
2. From the displayed list of CgExamples classes, double-click on CgImageViewer.
To view a BMP file from CgImageViewer, select Open from the File menu. Then, enter the path and file names of the BMP.
To enable DevelopScreenCapture so it uses CgImageViewer to display BMP files, begin by adding a prerequisite to DevelopScreenCapture:
1. From a Loaded Applications browser, select DevelopScreenCapture in the list of applications. The display changes so available and current prerequisites are shown in the lower half of the browser.
2. From the list of available prerequisites, select CgExamples; then select the >>> push button. CgExamples is now a prerequisite of DevelopScreenCapture.

Prerequisites
Next, add a Display Image push button to the screen capture tool. To do this, change the expression for buttons := widgetManager in the method createButtonsRowColumn so it defines three columns using numColumns: 3.
Next, implement the method createDisplayButton in the Window Creation category and display:clientData:callData: in the Event Handlers category:
createDisplayButton
"Private - Creates a button."
| displayButton |
displayButton := buttons
createPushButton: 'display'
argBlock: [:w | w labelString: ' Display Image '].
displayButton
addCallback: XmNactivateCallback
receiver: self
selector: #display:clientData:callData:
clientData: nil.
displayButton manageChild.
 
display: aPushButton clientData: clientData callData: callData
"Private - The user pressed the Display Image push button.
Use the CgImageViewer to open the BMP file."
| name |
(name := self promptForFileName ) == nil ifTrue: [^self].
CgImageViewer new
viewFile: name;
open.
Finally, change createWindow so it references createCaptureButton:
...
self createButtonsRowColumn.
self createCaptureButton.
self createDisplayButton. “new line”
...
When you now open an instance of ScreenPMCapture or ScreenWinCapture, it displays:
C:\Users\documentation\Documents\vastePublisher\stable\VAS Documentation Word\images\sg\capture2.png
Example: Defining application lineups for OS/2 and Windows describes how to enable the class Chooser to open the screen capture tool on images that suit OS/2 and Windows platforms.
Last modified date: 03/13/2019