## 5.21 Tbcheckbutton widget

### 5.21.1 Description

A tbcheckbutton is a widget that displays a textual string and a bitmap or image. If text is displayed, it is displayed below the bitmap or image if ever here is one defined. A tbcheckbutton has a flat border that gets raised when the mouse cursor gets over it. If the mouse 1 button is clicked, the tbbutton gets a sunken border. A tbcheckbutton is specially suited for toolbar buttons that looks like the toolbars of Netscape or Internet Explorer. When a user invokes the button (by pressing mouse button 1 with the cursor over the button), then the command specified in the `action` option is invoked and the button is switched on or off.

A tbcheckbutton has four differents states that have their own combinations of colors and border type :

- normal : State when the button is not disabled and when the mouse cursor is not above it. The colors are defined by the `foreground` and `background` parameters. The border is defined by the `borderwidth` and `relief` parameters. The picture displayed is defined by either by `bitmap` or `image`.

- highlighted : State when the button is not disabled and when the mouse cursor is above it. The colors are defined by the `highlightforeground` and `highlightbackground` parameters. The border is defined by the `highlightborderwidth` and `highlightrelief` parameters. The picture displayed is defined by either by `highlightbitmap` or `highlightimage`.

- selected : State when the button is not disabled and when the mouse cursor is above it and the mouse button 1 is currently clicked. The colors are defined by the `selectforeground` and `selectbackground` parameters. The border is defined by the `selectborderwidth` and `selectrelief` parameters. The picture displayed is defined by either by `selectbitmap` or `selectimage`.

- disabled : State when the button is not enabled. The colors are defined by the `disabledforeground` and `disabledbackground` parameters. The border is defined by the `disabledborderwidth` and `disabledrelief` parameters. The picture displayed is defined by either by `disabledbitmap` or `disabledimage`.

### 5.21.2 Parameters

- `1:B` : Specifies whether the button is on or off. `B` must be a boolean. Can be used with the `set()` and `get()` methods only.

- `init:B` : Specifies whether the button is on or off. `B` must be a boolean. Can be used at creation time only.

- `return:V` : When the window is closed, `B` is bound to true if the checkbutton is selected, false otherwise. `V` must be a free variable.

- `foreground:C` or `fg:C` : Specifies the foreground color to display when the mouse cursor is not over the widget (if it is not disabled). `C` must be a valid color (see Section 6.1)

- `background:C` or `bg:C` : Specifies the background color to display when the mouse cursor is not over the widget (if it is not disabled). `C` must be a valid color (see Section 6.1)

- `relief:A` : Specifies the relief to display when the mouse cursor is not over the widget (if it is not disabled). Defaults to `flat`.

- `borderwidth:P` : Specifies the border width to display when the mouse cursor is not over the widget (if it is not disabled).

- `bitmap:B` : Specifies the bitmap to display when the mouse cursor is not over the widget (if it is not disabled). If there is an image defined, this option is ignored.

- `image:I` : Specifies the image to display when the mouse cursor is not over the widget (if it is not disabled).

- `highlightforeground:C` : Specifies the foreground color to display when the mouse cursor is over the widget (if it is not disabled). `C` must be a valid color (see Section 6.1)

- `highlightbackground:C` : Specifies the background color to display when the mouse cursor is over the widget (if it is not disabled). `C` must be a valid color (see Section 6.1)

- `highlightrelief:A` : Specifies the relief to display when the mouse cursor is over the widget (if it is not disabled). Defaults to `raised`.

- `highlightborderwidth:P` : Specifies the border width to display when the mouse cursor is over the widget (if it is not disabled).

- `highlightbitmap:B` : Specifies the bitmap to display when the mouse cursor is over the widget (if it is not disabled). If there is an image defined, this option is ignored. Is this option is not specified, it defaults to the value of the `bitmap` parameter.

- `highlightimage:I` : Specifies the image to display when the mouse cursor is over the widget (if it is not disabled). Is this option is not specified, it defaults to the value of the `image` parameter.

- `selectforeground:C` : Specifies the foreground color to display when the user clicks the widget (if it is not disabled). `C` must be a valid color (see Section 6.1)

- `selectbackground:C` : Specifies the background color to display when the user clicks the widget (if it is not disabled). `C` must be a valid color (see Section 6.1)

- `selectrelief:A` : Specifies the relief to display when the user clicks the widget (if it is not disabled). Defaults to `sunken`.

- `selectborderwidth:P` : Specifies the border width to display when the user clicks the widget (if it is not disabled).

- `selectbitmap:B` : Specifies the bitmap to display when the user clicks the widget (if it is not disabled). If there is an image defined, this option is ignored. Is this option is not specified, it defaults to the value of the `bitmap` parameter.

- `selectimage:I` : Specifies the image to display when the user clicks the widget (if it is not disabled). Is this option is not specified, it defaults to the value of the `image` parameter.

- `disabledforeground:C` : Specifies the foreground color to display when the widget is disabled. `C` must be a valid color (see Section 6.1)

- `disabledbackground:C` : Specifies the background color to display when the widget is disabled. `C` must be a valid color (see Section 6.1)

- `disabledrelief:A` : Specifies the relief to display when the the widget is disabled. Defaults to `flat`.

- `disabledborderwidth:P` : Specifies the border width to display when the the widget is disabled.

- `disabledbitmap:B` : Specifies the bitmap to display when the widget is disabled. If there is an image defined, this option is ignored. Is this option is not specified, it defaults to the value of the `bitmap` parameter.

- `disabledimage:I` : Specifies the image to display when the widget is disabled. Is this option is not specified, it defaults to the value of the `image` parameter.

- `disabledstate:A` : Specifies one of two states for the button: `normal` or `disabled`. In normal state the button is displayed using the foreground and background options. Disabled state means that the button should be insensitive: the default bindings will refuse to activate the widget and will ignore mouse button presses. In this state the disabledforeground and background options determine how the button is displayed. `A` must be one of these three atoms : `normal` or `disabled`.

- `text:VS` : Specifies a string to be displayed inside the widget. The way in which the string is displayed depends on the particular widget and may be determined by other options, such as `anchor` or `justify`. `VS` must be a virtual string.

- `action:C` : Specifies an action to execute juste after the user clicked the button. `C` can take several different forms (see Section 4.3.1).

- `glue:A` : Specifies how a widget must fit in its own available place. `A` must be an atom that is any combination of `n`, `s`, `w` and `e`. If a direction is specified, the corresponding border is glued to its neighboor or border of the frame if there is no neighboor. If a direction is not specified, the corresponding border if such that the widget takes just the width or height it needs to draw itself. If none of opposite directions is specified, the widget is centered. For more details, see Section 4.1.

- `padx:P` : Specifies how much horizontal external padding to leave on each side of the widget. This space is added outside the widget border. `P` must be a valid screen distance (see Section 6.6)

- `pady:P` : Specifies how much vertical external padding to leave on each side of the widget. This space is added outside the widget border. `P` must be a valid screen distance (see Section 6.6)

- `feature:A` : Specifies a feature name for the container object to reference the object controlling this widget. For more details, see Section 4.2. `A` must be an atom.

- `handle:V` : Specifies a variable to reference the object controlling this widget. This variable is binded when the window is built. For more details, see Section 4.2. `V` must be a free variable.

- `tooltips:VS` : Specifies a tooltip for the widget. A tooltip is a small message that appears when the mouse cursor if left still over the widget for a while. If `VS` is set to `nil`, no tooltip will appear at all. `VS` must be a virtual string.

- `look:L` : Specifies a look to use for the widget. A look specifies default values for the parameters of widgets. This parameter can be specified at creation time only. Moreover changing a look will not change the appearance of widgets that are already displayed with that look. See Section 6.2 for more details.

### 5.21.3 Interface

The object you get by an handle on the widget implements the following methods :

- `set(parameter1:value1 ... parameterX:valueX)` : Changes the value of one or more parameters. `parameterX` must be a valid parameter for the widget. `valueX` must be a valid value for the parameter.

- `get(parameter1:Variable1 ... parameterX:VariableX)` : Obtains the value of one or more parameters. `parameterX` must be a valid parameter for the widget. `VariableX` must be free variables which will receive the current value of the parameters.

- `bind(event:E
  args:LA
  action:A)` : Specifies an action `LA` to execute when the event `E` is triggered. The event can have parameters (like mouse coordinates for a mouse click). You must explicitly ask in the `LA` list the parameters you are interested for. For more details, see Section 4.3.3.

- `getFocus(force:B)` : if `B` is `false` (which is the default) : if the application currently has the input focus on window's display, this command resets the input focus for window's display to window. If the application doesn't currently have the input focus on window's display, window will be remembered as the focus for its top-level; the next time the focus arrives at the top-level, it will be redirected it to window. If `B` is `true` : sets the focus of window's display to window, even if the application doesn't currently have the input focus for the display. This command should be used sparingly, if at all. In normal usage, an application should not claim the focus for itself; instead, it should wait for the window manager to give it the focus. `B` must be a boolean.

- `setGrab(global:B)` : Sets a grab on the widget. If `B` is `true` then the grab is global, otherwise it is local (`B` false by default). If a grab was already in effect for this application then it is automatically released. If there is already a grab on the widget and it has the same global/local form as the requested grab, then the command does nothing. Local grab affects only the grabbing application: events will be reported to other applications as if the grab had never occurred. A global grab locks out all applications on the screen, so that only the given subtree of the grabbing application will be sensitive to pointer events (mouse button presses, mouse button releases, pointer motions, window entries, and window exits). During global grabs the window manager will not receive pointer events either. Warning : whe a grab is set, it is define for the whole Oz process so that it will prevent the user to do input to other windows as well. Moreover a grab is still effective even if the window that contains the grabbed widgets is hidden. `B` must be a boolean.

- `releaseGrab` : Releases the grab on the widget if there is one, otherwise does nothing.

- `getGrabStatus(1:V)` : Binds `V` to the atom `none` if there is no grab on the widget, to the atom `local` if there is a local grab and to `global` if there is a global grab. `V` must be a free variable.

- `'raise'(1:W)` : If the `W` argument is omitted then the command raises the widget so that it is above all of its siblings in the stacking order (it will not be obscured by any siblings and will obscure any siblings that overlap it). If `W` is specified then it must be an handle to another widget that is either a sibling of this widget or the descendant of a sibling of this widget. In this case the `'raise'` command will insert this widget into the stacking order just above `W`; this could end up either raising or lowering window.

- `lower(1:W)` : If the `W` argument is omitted then the command lowers the widget so that it is below all of its siblings in the stacking order (it will be obscured by any siblings and will not obscure any siblings that overlap it). If `W` is specified then it must be an handle to another widget that is either a sibling of this widget or the descendant of a sibling of this widget. In this case the `lower` command will insert this widget into the stacking order just below `W`; this could end up either raising or lowering window.

- `winfo(parameter1:value1 ... parameterX:valueX)` : This commands works like the `get` method, but for window-related information. For more details, see Section 6.9.