class imageButton

superclass(es) customControl
subclass(es) -
description The imageButton control is a button control that can display a bitmap image and a text.

pl_img36.gif (1914 bytes)
see also panel - image

tasks

The image button control is a custom control that can display an image and a text on a button control. How the button reacts and looks can be set per button instance. If the border must not be visible call the method putPaintBorder/1 or if the focus rectangle must never be drawn call putDrawFocusRect/1. Where the image and text are displayed on the button can be set by putDrawMode/1. Below there are some examples of different draw modes:

pl_img37.gif (1907 bytes) pl_img38.gif (1975 bytes) pl_img39.gif (1968 bytes)

The image for the button must contain two versions of the same picture, one version for if the button is enabled and another one for if the button is disabled. Below there is an example of an appropriate image (the border is not part of the image).
    pl_img16.gif (179 bytes)
Another requirement for the image is that the color white is replaced by the background color of the button control to make it look transparent. So it is important to make the areas that must look transparent white.

To have the button control redraw itself immediately use the method forceRedraw/0 of the class window.

An image button can use a different background color than the standard background color and also a different 3D effect, for example:
pl_img128.gif (1844 bytes)

methods

putImage(+Img)

func Set the image that can be displayed. The image must contain two versions of the same picture, one for if the button is enabled and the other for if the button is disabled.
The color white in the image will be replaced by the background color of the button (the rgb value of the color removed is 255, 255, 255).
pre The variable Img must contain an instance of the image class.
post The image of the button was set the image referred to by the variable Img.

image(?Output)

func Get the image of the image button control.
pre TRUE.
post The image of the button was assigned to the variable Output, if the button control contains no image then no value was assigned to Output.

putPaintBorder(+YesNo)

func Make the button control draw a border line or remove the border line.
pre The variable YesNo must contain true or false.
post If YesNo was true the button control will draw a border the next time it draws itself, else the border will not be drawn.

paintBorder(?Output)

func Determine if the button control draws a border line or not.
pre TRUE.
post If the button control draws a border then Output was assigned true, else it was assigned false.

putFlatButton(+YesNo)

func A flat button is a button that does not look raised until the mouse is moved over it.
pre The variable YesNo must contain true or false.
post If YesNo was true the button control will behave like a flat button the next time it draws itself, else the button control will look like a normal button.

flatButton(?Output)

func Determine if the button control reacts like a flat button.
pre TRUE.
post If the button control reacts like a flat button border then Ouput was assigned true, else it was assigned false.

putDrawFocusRect(+YesNo)

func Make the button draw a focus rectangle if it has the focus or never draw a focus rectangle.
pre The variable YesNo must contain true or false.
post If YesNo was true the button control draws a focus rectangle if it has the focus, else the button control never draws a focus rectangle.

drawFocusRect(?Output)

func Determine if the button control draws a focus rectangle if it has the focus, or if it never draws a focus rectangle.
pre TRUE.
post If the button control draws a focus rectangle then Ouput was assigned true, else it was assigned false.

putDrawMode(+Mode)

func Set the draw mode of the button control, the draw mode determines where the image and text are placed on the control. The default draw mode is left.
pre The variable Mode must contain one of the following values: left, right, top, bottom or userdef.
left = image is placed on the left side of the button.
right = image is placed on the right side of the button.
top =  image is placed on the top of control and text below it.
bottom =  image is placed on the bottom of control and text above it.
userdef = position of text and image can be set by putTopLeftImage/1 and putTopLeftText/1.
post The draw mode was set to the value of the variable Mode.

drawMode(?Output)

func Get the draw mode of the image button control.
pre TRUE.
post The draw mode was assigned to the variable Output.

putTopLeftImage(+point(X, Y))

func Set the position of the upper-left corner of the image, if the draw mode is userdef.
pre The variables X and Y must contain integer values.
post If the draw mode is userdef the position of the upperleft corner of the image was set to the values specified by X and Y.
Arrow.gif (1632 bytes) See putDrawMode/1.

topLeftImage(?point(X, Y))

func Get the position of the upper-left corner of the image, if the draw mode is userdef.
pre TRUE.
post The position of the upperleft corner of the image was assigned to the variables X and Y.
Arrow.gif (1632 bytes) See putDrawMode/1 and drawMode/1.

putTopLeftText(+point(X, Y))

func Set the position of the upper-left corner of the text, if the draw mode is userdef.
pre The variables X and Y must contain integer values.
post If the draw mode is userdef the position of the upperleft corner of the text was set to the values specified by X and Y.
Arrow.gif (1632 bytes) See putDrawMode/1.

topLeftText(?point(X, Y))

func Get the position of the upper-left corner of the text, if the draw mode is userdef.
pre TRUE.
post The position of the upperleft corner of the text was assigned to the variables X and Y.
Arrow.gif (1632 bytes) See putDrawMode/1 and drawMode/1.

putRespondEnterKey(+YesNo)

func Determine if the button may respond to pressing of the ENTER key or not, default is that an image button responds to the ENTER key. The image button control responds to the ENTER key as if the left mouse button was pressed.
pre The variable YesNo must contain a boolean value.
post If the value of the parameter was false then the image button instance no longer responds to the ENTER key, else it does.

respondEnterKey(?Output)

func Check if the button responds to the ENTER key or not.
pre TRUE
post If true was assigned to the parameter Output then the image button responds to the ENTER key as if the left mouse button was pressed, else the ENTER key is ignored.

putExtended3DEffect(+YesNo)

func Determine if the button draws itself with an extended 3D shadow effect or with the default windows 3D effect.
pre The variable YesNo must contain a boolean value.
post If the value of the parameter was true then the image button draws itself with a different 3D effect than the default windows 3D effect, else not and the button will draw itself with the default 3D effect.
arrow.gif (1632 bytes)
Button with windows 3D effect pl_img129.gif (1804 bytes) pl_img130.gif (1807 bytes)
The same button with the extended 3D effect: pl_img128.gif (1844 bytes) pl_img136.gif (1856 bytes)

extended3DEffect(?Output)

func Check if the button draws itself with an extended 3D shadow effect or with the default windows 3D effect.
pre TRUE
post If the image button draws itself with a different 3D effect then the value of the parameter Output is unified with the value true, else with the value false.

putBackgroundColor(+R, +G, +B)

func Set the background color of the button control.
pre The variables R, G, and B must contain integer values in the range [0, 255].
post The background color was changed to the color specified by the variables R, G and B.

backgroundColor(?R, ?G, ?B)

func Get the background color of the button control.
pre TRUE.
post The Red, Green and Blue values of the background color were unified with the values of the variables R, G and B.

putRepeatOnClickIfPressed(+YesNo)

func Determine if the button must generate more than one OnClick event if the user keeps pressing the left mouse button. The buttons in a scrollbar have the same behavior.
pre The variable YesNo must contain a boolean value.
post If the value of the parameter was true then the image button instance will send multiple OnClick events if the user keeps pressing the left mouse button over the control, else not.

repeatOnClickIfPressed(?Output)

func Check if the image button instance sends multiple OnClick instances if the user keeps pressing the left mouse button.
pre TRUE
post If true was unified with the parameter Output then the image button sends multiple OnClick instances if the user keeps pressing the left mouse button, else not and was false unified with the Output parameter.

putStickyButton(+YesNo)

func Determine if the button must react like a normal button or as a sticky button. A sticky button means that the button remains in the down state after releasing the left mouse button (or the spacebar or enter key). The user must then click the button again to get it back in the raised state.
pre The variable YesNo must contain a boolean value.
post If the value of the parameter was true then the image button instance will be a sticky button, else not.

stickyButton(?Output)

func Check if the button reacts like a normal button or as a sticky button.
pre TRUE
post If the value of the parameter was unified with true then the image button instance is a sticky button, else not.

buttonUp

func Put the button in the raised state.
pre TRUE
post The button is in the raised state.

buttonDown

func Put the button in the down state.
pre TRUE
post The button is in the down state.