|
Revision 102, 1.2 kB
(checked in by ashley, 10 months ago)
|
|
Added bistate option to check.r and check-group.r
|
| Line | |
|---|
| 1 | check-group: make rebface [
|
|---|
| 2 | tip: {
|
|---|
| 3 | USAGE:
|
|---|
| 4 | check-group data ["Option-1" true "Option-2" false "Option-3" none]
|
|---|
| 5 |
|
|---|
| 6 | DESCRIPTION:
|
|---|
| 7 | Group of check boxes.
|
|---|
| 8 | Alignment is vertical unless height is specified as line height.
|
|---|
| 9 | At runtime face/data is a block of logic (or none) indicating state of each check box.
|
|---|
| 10 |
|
|---|
| 11 | OPTIONS:
|
|---|
| 12 | 'info specifies read-only
|
|---|
| 13 | 'bistate disables right-click state
|
|---|
| 14 | }
|
|---|
| 15 | size: 50x-1
|
|---|
| 16 | pane: []
|
|---|
| 17 | init: make function! [/local off siz pos last-pane] [
|
|---|
| 18 | data: reduce data
|
|---|
| 19 | all [negative? size/y size/y: .5 * sizes/line * length? data]
|
|---|
| 20 | off: either size/y > sizes/line [
|
|---|
| 21 | siz: as-pair size/x sizes/line
|
|---|
| 22 | as-pair 0 sizes/line
|
|---|
| 23 | ][
|
|---|
| 24 | siz: as-pair 2 * size/x / length? data sizes/line
|
|---|
| 25 | as-pair siz/x 0
|
|---|
| 26 | ]
|
|---|
| 27 | pos: 0x0
|
|---|
| 28 | foreach [label state] data [
|
|---|
| 29 | insert tail pane make check [
|
|---|
| 30 | tip: none
|
|---|
| 31 | offset: pos
|
|---|
| 32 | size: siz
|
|---|
| 33 | text: label
|
|---|
| 34 | data: state
|
|---|
| 35 | ]
|
|---|
| 36 | pos: pos + off
|
|---|
| 37 | last-pane: last pane
|
|---|
| 38 | last-pane/options: options
|
|---|
| 39 | last-pane/init
|
|---|
| 40 | last-pane/init: none
|
|---|
| 41 | ]
|
|---|
| 42 | data: make function! [/local states] [
|
|---|
| 43 | states: copy []
|
|---|
| 44 | foreach check pane [insert tail states check/data]
|
|---|
| 45 | states
|
|---|
| 46 | ]
|
|---|
| 47 | ]
|
|---|
| 48 | ] |
|---|