eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Form':

Home

everywhere
www.exept.de
for:
[back]

Class: Form


Inheritance:

   Object
   |
   +--GraphicsContext
      |
      +--DeviceGraphicsContext
         |
         +--GraphicsMedium
            |
            +--Form
               |
               +--Form::ImageForm
               |
               +--Pixmap

Package:
stx:libview
Category:
Compatibility-ST80-Graphics-Display Objects
Version:
rev: 1.143 date: 2009/02/26 21:23:01
user: stefan
file: Form.st directory: libview
module: stx stc-classLibrary: libview
Author:
Claus Gittinger

Description:


Instances of this class represent forms (i.e. bit- and pixmaps)
which can be created on a drawing device. 
In X, these device resources are XPixmaps.
Not all devices will support forms.

NOTICE:
    the Form class is a historic leftover and now only used for real
    device forms (i.e. on devices which support downloading bitmaps).

    In your application, you should always use Image, both for compatibility
    with ST-80 and for device independence, since Form may not be supported
    by all devices.

WARNING:
    Forms created on some device may not be recreatable, when an
    image is restarted on a display with different display capabilities.
    For example, a 24bit truecolor form will be lost when the image is
    saved and restarted in an 8bit or monochrome display.
    Worse: the information is completely lost.

    With images, the original information is always preserved, although
    the display may be with less resolution, dithered or otherwise
    approximated.


Related information:

    Image
    DeviceDrawable

Class protocol:

Compatibility-ST80
o  and
return a constant usable as bitblt-combinationrule.
In ST-80rel2.x, these used to be numeric constants; in ST/X,
these are symbolic.

o  black
ST80 compatibility;
In old st80, you could use `Form black' for drawing
- here we return the black color.

o  darkGray
ST80 compatibility;
In old st80, you could use `Form darkGray' for drawing
- here we return the darkGray color.

o  darkGrey
ST80 compatibility;
In old st80, you could use `Form darkGrey' for drawing
- here we return the darkGrey color.

o  gray
ST80 compatibility;
In old st80, you could use `Form gray' for drawing
- here we return the grey color.

o  grey
ST80 compatibility;
In old st80, you could use `Form grey' for drawing
- here we return the grey color.

o  lightGray
ST80 compatibility;
In old st80, you could use `Form lightGray' for drawing
- here we return the lightGray color.

o  lightGrey
ST80 compatibility;
In old st80, you could use `Form lightGray' for drawing
- here we return the lightGray color.

o  over
return a constant usable as bitblt-combinationrule.
In ST-80rel2.x, these used to be numeric constants; in ST/X,
these are symbolic.

o  paint
return a constant usable as bitblt-combinationrule.
In ST-80rel2.x, these used to be numeric constants; in ST/X,
these are symbolic.

o  reverse
return a constant usable as bitblt-combinationrule.
In ST-80rel2.x, these used to be numeric constants; in ST/X,
these are symbolic.

o  under
return a constant usable as bitblt-combinationrule.
In ST-80rel2.x, these used to be numeric constants; in ST/X,
these are symbolic.

o  white
ST80rel2.x compatibility;
In old st80, you could use `Form white' for drawing
- here we return the white color.

Compatibility-Squeak
o  extent: ext depth: d bits: data

o  extent: ext depth: d fromArray: data offset: offs

cleanup
o  lowSpaceCleanup
cleanup in low-memory situations

file search
o  findBitmapFile: fileName
find the bitmap file in one of the standard places;
return the pathName or nil

fileIn/Out
o  fromFile: filename
create a new form taking the bits from a file on the default device.
WARNING:
Please do no longer use this, since it will not work
correctly in multi-display applications (creates the form on the
default Display).
Use #fromFile:on: and pass the devive as argument.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  fromFile: filename on: aDevice
create a new form on device, aDevice and
initialize the pixels from the file filename

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  fromFile: filename resolution: dpi
create a new form taking the bits from a file on the default device
the data in the file is assumed to be for dpi resolution;
if it is different from the displays resolution, magnify or
shrink the picture (but only in integer magnification steps).
WARNING:
Please do no longer use this, since it will not work
correctly in multi-display applications (creates the form on the
default Display).
Use #fromFile:resolution:on: and pass the devive as argument.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  fromFile: filename resolution: dpi on: aDevice
create a new form on device, aDevice and
initialize the pixels from the file filename;
the data in the file is assumed to be for dpi resolution;
if it is different from the displays resolution, magnify or
shrink the picture (but only in integer magnification steps)

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  readFrom: fileName
same as Form>>fromFile: - for ST-80 compatibility.
WARNING:
Please do no longer use this, since it will not work
correctly in multi-display applications (creates the form on the
default Display).
Use #fromFile:on: and pass the device as argument.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

initialization
o  flushDeviceForms
recreate all forms on aDevice; called by Workstation, to
have all background bitmaps at hand, when views are restored

o  initialize
initialize set of dictionaries to look for bitmaps

o  reinitializeAllOn: aDevice
recreate all forms on aDevice; called by Workstation, to
have all background bitmaps at hand, when views are restored

o  update: something with: aParameter from: changedObject
sent just before snapOut and just after a snapIn

instance creation
o  dotOfSize: size
create and return a form which contains a dot (filled circle)
of the given size.

o  extent: ext
create a new, cleared form, take dimensions from ext.
Smalltalk-80 compatibility

o  extent: ext depth: d
create a new, cleared form.
Smalltalk-80 compatibility

o  extent: ext depth: d onDevice: aDevice
create a new form on device, aDevice; depth is what device likes most

o  extent: ext fromArray: data
create a new form, take dimensions from ext, bits from data.
Smalltalk-80 compatibility.

o  extent: ext fromArray: data offset: offs
create a new form, take dimensions from ext, bits from data.
Smalltalk-80 compatibility.

o  extent: ext fromArray: data offset: offs onDevice: aDevice
create a new form, take dimensions from ext, bits from data.

o  extent: ext fromArray: data onDevice: aDevice
create a new form, take dimensions from ext, bits from data.

o  extent: ext offset: anOffset
create a new, cleared form, take dimensions from ext.
Smalltalk-80 compatibility

o  extent: ext onDevice: aDevice
create a new form on device, aDevice; depth is what device likes most

o  width: w height: h
create a new form on the default device

o  width: w height: h depth: d
create a new form on the default device

o  width: w height: h depth: d onDevice: aDevice
create a new form with depth d on device, aDevice

o  width: w height: h fromArray: anArray
create a new form on the default device

o  width: w height: h fromArray: anArray onDevice: aDevice
create a new form on device, aDevice and
initialize the pixels from anArray

o  width: w height: h offset: offs fromArray: anArray
create a new form on the default device

o  width: w height: h offset: offs fromArray: anArray onDevice: aDevice
create a new form on the default device

o  width: w height: h onDevice: aDevice
create a new form on device, aDevice; depth is what device likes most

obsolete instance creation
o  darkGreyFormOn: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  extent: ext depth: d on: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  extent: ext fromArray: data offset: offs on: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  extent: ext fromArray: data on: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  extent: ext on: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  grey: percent on: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  lightGreyFormOn: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  mediumGreyFormOn: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  veryDarkGreyFormOn: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  veryLightGreyFormOn: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  width: w height: h depth: d on: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  width: w height: h fromArray: anArray on: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  width: w height: h offset: offs fromArray: anArray on: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  width: w height: h on: aDevice

** This is an obsolete interface - do not use it (it may vanish in future versions) **

obsolete patterns
o  darkGreyFormBits

o  grey12Bits

o  grey25Bits

o  grey37Bits

o  grey50Bits

o  grey6Bits

o  greyFormBits

o  lightGreyFormBits

o  veryDarkGreyFormBits

o  veryLightGreyFormBits


Instance protocol:

Compatibility-ST80
o  destroy
destroy my underlying device resource(s)

o  displayAt: aPoint
show the receiver on the current display screen

o  displayOn: aGC at: aPoint rule: rule
draw in aGC.
Smalltalk-80 (2.x) compatibility

o  displayOn: aGC rule: rule
draw in aGC.
Smalltalk-80 (2.x) compatibility

o  displayOn: aGC x: x y: y
draw in aGC.
Smalltalk-80 (2.x) compatibility

o  displayOn: aGC x: x y: y rule: rule
draw in aGC.
Smalltalk-80 (2.x) compatibility

o  isOpen

o  offset
set the offset.
Smalltalk-80 compatibility

o  offset: org
set the offset.
Smalltalk-80 compatibility

o  preferredBounds

Compatibility-Squeak
o  colormapIfNeededForDepth: destDepth

o  magnify: aRectangle by: scale smoothing: smooth

accessing
o  bits
return a ByteArray filled with my bits -
for depth 8 forms, 1 pixel/byte is filled;
for depth 1 forms, 8 pixels/byte are filled
for depth 4 forms, 2 pixels/byte are filled.
Padding is done row-wise to the next BYTE-boundary
If multiple pixels are contained in a single byte,
left bits are in the most significant bit positions.
(i.e. for width==13 and depth==1 it will return 2 bytes per scanline)

o  bits: aByteArray
set the forms bits;
for depth-8 forms, 1 pixel/byte is expected;
for depth-1 forms, 8 pixels/byte are expected
for depth-4 forms, 2 pixels/byte are expected.
Padding is expected to the next byte-boundary
(i.e. for width==13 and depth==1 2 bytes per scanline are expected)

o  bitsPerSample
for compatibility with Image class ...

o  colorMap
return the receivers colormap

o  colorMap: anArrayOrColorMap
set the receivers colormap

o  depth
return the receivers depth

o  fileName
return the filename, from which the receiver was created,
or nil, if it was not read from a file

o  filename
return the filename, from which the receiver was created,
or nil, if it was not read from a file

o  forgetBits
for image, which also keeps the bits - so there is
no need to hold them again here

o  mask
for compatibility with images; forms have no mask/alpha channel

o  photometric
for compatibility with Image class ...

o  samplesperPixel
for compatibility with Image class ...

o  valueAt: aPoint
return the pixel at aPoint; the coordinates start with 0@0
in the upper left, increasing to the lower right

o  valueAt: aPoint put: value
set the pixel at aPoint; the coordinates start with 0@0
in the upper left, increasing to the lower right.

binary storage
o  readBinaryContentsFrom: stream manager: manager
tell the newly restored Form about restoration

o  storeBinaryDefinitionOn: stream manager: manager
store a binary representation of the receiver on stream.
This is an internal interface for binary storage mechanism.
Redefined to store the actual bits, even if I have been loaded
from a file, and to ommit all device related stuff.

comanche processing
o  asHtmlElementIn: htmlContainer
answer my HTML representation (String),
as I would look like inside htmlContainer

o  asHttpResponseTo: request

o  asWebImage
return a MIMEDocument

converting
o  asForm
convert & return the receiver into a Form instance - nothing to be done here

o  asImage
convert & return the receiver into an Image instance

o  asImageForm
convert & return the receiver into a ImageForm instance

copying
o  executor
redefined for faster creation of finalization copies
(only device, gcId and drawableId are needed)

o  postCopy
redefined to copy the colorMap as well

editing
o  show
open an imageView on the receiver

getting a device form
o  asFormOn: aDevice
convert & return the receiver into a Form instance
and associate it to a device (i.e. download its bits).
Added for protocol compatibility with Image.

o  asMonochromeFormOn: aDevice
added for protocol compatiblity with Image

o  exactOn: aDevice
for compatibility with color protocol - here, the same as #onDevice.

o  exactOrNearestOn: aDevice
for compatibility with color protocol - here, the same as #onDevice.

o  nearestOn: aDevice
for compatibility with color protocol - here, the same as #onDevice.

o  on: aDevice
associate the receiver to a device (i.e. download its bits);
return a deviceForm (possibly different from the receiver).

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  onDevice: aDevice
associate the receiver to a device (i.e. download its bits);
return a deviceForm (possibly different from the receiver).

image manipulations
o  clearMaskedPixels
Added for protocol compatibility with Image.

o  darkened
return a darkened version of the receiver.
Added for protocol compatibility with Color and Image.
Here, the receiver is returned as a kludge
- actually should return a darkened image (or Color black ?) ..

o  easyMagnifiedBy: extent into: newForm
return a new form magnified by extent, aPoint.
If non-integral magnify is asked for, pass the work on to 'hardMagnifiedBy:'

o  flipHorizontal
return a new form flipped vertically

o  flipVertical
return a new form flipped horizontally

o  hardMagnifiedBy: extent
return a new form magnified by extent, aPoint.
This method handles non-integral factors.

o  lightened
return a lightened version of the receiver.
Added for protocol compatibility with Color and Image.
Here, the receiver is returned as a kludge
- actually should return a lightened image (or Color white ?) ..

o  magnifiedBy: extent
return a new form magnified by extent, aPoint.
If non-integral magnify is asked for, pass the work on to 'hardMagnifiedBy:'

o  magnifiedTo: anExtent
return a new form magnified to have the size specified by extent.
This may distort the image if the arguments ratio is not the images ratio.
See also #magnifiedPreservingRatioTo: and #magnifiedBy:

o  magnifyBy: scale

** This is an obsolete interface - do not use it (it may vanish in future versions) **

initialization
o  createGC
physically create a device GC.
Since we do not need a gc-object for the drawable until something is
really drawn, none is created up to the first draw.
This method is sent, when the first drawing happens.
Redefined here to create a bitmap GC (some devices (i.e. windows) require
different GC's for different canvases.

o  initGC
stop server from sending exposure events for Forms -
(will fill up stream-queue on some stupid (i.e. sco) systems

o  initialize

o  recreate
reconstruct the form after a snapin or a migration

o  releaseFromDevice
flush device data.
The sender has to take care that the Form has been
unregistered from (Finalization-)Lobby

inspecting
o  inspectorClass
redefined to launch an ImageInspector
(instead of the default InspectorView).

printing & storing
o  storeOn: aStream
append an ascii representation of the receiver to aStream,
from which a copy of the receiver can be reconstructed

private
o  beImmediateForm
read the pixels from the device into a local data array.
This makes certain that a fileName form is independent of
its fileName.
To make the image smaller (i.e. not keep all those bitmaps),
this is NOT done by default.

o  flushDeviceHandles
flush device handles (sent after a restart)

o  getBits
if the receiver was not created from a file, or
an array (i.e. it was drawn), read the pixels from the
device into a local data array. This has to be done before
an image is saved, or the receiver is storedBinary, since
the information present in the device is lost after restart/reload

o  readFromFile: fn
read a monochrome form from a file (in xbm-format).
The fileName argument, fn should be a relative pathname
such as bitmaps/foo.xbm and the corresponding file
will be searched in the standard places (i.e. along the SEARCHPATH).
Notice, when saving an image, only that fileName is kept with the
form, and the file is reloaded at image startup time.
You should therefore make certain, that the file is present at image
reload time. (this is done to make the image smaller ...)
If you dont like that behavior (or your application should be able to
restart fully standAlone), send #beImmediateForm to all instances of
Form - this will set the data instance variable to a ByteArray containing
the actual bits and will therefore no longer depend on the file being present.


** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  readFromFile: filename resolution: dpi
read a monochrome form from a file, which is assumed to have data for a dpi-resolution;
if the actual resolution of the device differs, magnify the form.
Read the comment in #readFromFile: on what happenes if the file is no longer present
after an image reload.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  restored
flush device data, when restored (sent after a binaryLoad)

o  width: w height: h
actual create of a monochrome form

o  width: w height: h depth: d
actual create of an arbitrary deep form (but, must be supported by device)

o  width: wIn height: hIn fromArray: anArray
actual create of a monochrome form from array.
This method is somewhat more complicated as it should be due to
supporting both byte-wise (ST/X-type) and short-word-wise (ST-80-type)
Arrays; in the later case, the shorts are first converted to bytes in
a ByteArray, then passed to the device.

o  width: w height: h offset: offs fromArray: anArray
actual create of a monochrome form from array

queries
o  ascentOn: aGC
displayOn: does not draw above baseline

o  bounds
return my bounds (added to make forms usable as VisualComponents)

o  colorFromValue: pixel
given a pixelValue, return the corresponding color.
For compatibility with Images

o  hasBits
return true, if the receiver has its pixel data available.
For forms, which were created from data, this is always true.
For forms, which were created as off-screen device forms on some
device, this is always false.

o  heightOn: aGC
return my height, if displayed on aGC;
since my height is independent of the device (the number of pixels),
return the pixel-height

o  isDithered
for compatibility with color protocol

o  isForm
return true, if the receiver is some kind of form;
true is returned here - the method is redefined from Object.

o  isImageOrForm
return true, if the receiver is some kind of image or form;
true is returned here - the method is redefined from Object.

o  widthOn: aGC
return my width, if displayed on aGC;
since my width is independent of the device (the number of pixels),
return the pixel-width


Private classes:

    DeviceFormHandle
    ImageForm


ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 09:15:09 GMT