15 Switchable Button

▼ |  | Mr Lib: Extra GUI Libraries

1 | Aligned Pasteboard
2 | Arrow Toggle Snip
3 | Bitmap Label
4 | Cache-image Snip
5 | Close Icon
6 | Expandable Snip
7 | GIF and Animated GIF Writing
8 | Graphs
9 | Hierarchical List Control
10 | Include Bitmap
11 | Interactive Value Port
12 | Name Message
13 | Path Dialog
14 | Plot
15 | Switchable Button
16 | Image Core
17 | Matrix Snip
18 | Snip Canvases
19 | Syntax Browser
20 | Te X Table
21 | Terminal Window
22 | White on Black Panel Predicate
23 | Acknowledgments
| Index

On this page:

switchable-button%
new
set-label-visible
command
get-button-label
get-large-width
get-small-width
get-without-label-small-width

top contents ← prev up next →

### 15`` Switchable Button🔗ℹ

(require mrlib/switchable-button) | package: gui-lib

class switchable-button% : class?
superclass: canvas%

A switchable-button% control displays an icon and a string label. It toggles between display of just the icon and a display with the label and the icon side-by-side.
The panel:discrete-sizes-mixin explicitly uses switchable-button%s via their get-small-width, get-large-width, and get-without-label-small-width methods. See panel:discrete-sizes-mixin for more details.

> > > constructor
> > > (new switchable-button% |
> > > |  | [label label] |
> > > |  | [bitmap bitmap] |
> > > |  | [callback callback] |
> > > | [ | [alternate-bitmap alternate-bitmap] |
> > > |  | [vertical-tight? vertical-tight?] |
> > > |  | [min-width-includes-label? min-width-includes-label?]] |
> > > |  | ...superclass-args...) |
> > → (is-a?/c switchable-button%)
> > label : (or/c string? (is-a?/c bitmap%) #f)
> > bitmap : (is-a?/c bitmap%)
> > callback : (-> (is-a?/c switchable-button%) any/c)
> > alternate-bitmap : (is-a?/c bitmap%) = bitmap
> > vertical-tight? : boolean? = #f
> > min-width-includes-label? : boolean? = #f

> The callback is called when the button is pressed. The label and bitmap are used as discussed above.

> If alternate-bitmap is supplied, then it is used when the label is not visible (via a call to set-label-visible). If it is not supplied, both modes show bitmap.

> If the vertical-tight? argument is #t, then the button takes up as little as possible vertical space.

> If the min-width-includes-label? is #t, then the minimum width includes both the bitmap and the label. Otherwise, it includes only the bitmap.

> > method (send a-switchable-button set-label-visible visible?) → void?
> > visible? : boolean?

> Sets the visibility of the string part of the label.

> > method (send a-switchable-button command) → void?

> Calls the button’s callback function.

> > method (send a-switchable-button get-button-label) → string?

> Returns the label of this button.

> > method (send a-switchable-button get-large-width)
> > → exact-nonnegative-integer?

> Returns the width of the button when it would show both the label and the bitmap and when it is in label-visible mode (i.e., when set-label-visible has been called with #t).

> > method (send a-switchable-button get-small-width)
> > → exact-nonnegative-integer?

> Returns the width of the button when it would show both just the bitmap (not the alternate bitmap), and when it is in label-visible mode (i.e., when set-label-visible has been called with #t).

> > method (send a-switchable-button get-without-label-small-width)
> > → exact-nonnegative-integer?

> Returns the width of the button when it is not in label-visible mode (i.e., when set-label-visible has been called with #f).

top contents ← prev up next →