agar

Check-in [39b15b34a1]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Checkboxes, radio buttons and small tweaks
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:39b15b34a18240d00fc108e5b07f6bfe8e6ebd83
User & Date: murphy 2016-09-25 10:18:40
Context
2016-09-25
10:50
Indirect variable support check-in: e08bcf4470 user: murphy tags: trunk
10:18
Checkboxes, radio buttons and small tweaks check-in: 39b15b34a1 user: murphy tags: trunk
2016-09-24
17:20
Corrected date in license file check-in: 1ada5735ed user: murphy tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to agar-types.scm.

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  (object->pointer #t)
  (pointer->object #t))

(define-foreign-type box (c-pointer "AG_Box")
  (object->pointer #f)
  (pointer->object #f))

(define-foreign-type nonnull-button (nonnull-c-pointer "AG_Button")
  (object->pointer #t)
  (pointer->object #t))

(define-foreign-type button (c-pointer "AG_Button")
  (object->pointer #f)
  (pointer->object #f))

(define-foreign-type nonnull-textbox (nonnull-c-pointer "AG_Textbox")
  (object->pointer #t)
  (pointer->object #t))

(define-foreign-type textbox (c-pointer "AG_Textbox")
  (object->pointer #f)
  (pointer->object #f))

;; vim:set ft=scheme ts=2 sts=2 sw=2 ai: ;;







|



|












36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  (object->pointer #t)
  (pointer->object #t))

(define-foreign-type box (c-pointer "AG_Box")
  (object->pointer #f)
  (pointer->object #f))

(define-foreign-type nonnull-radio (nonnull-c-pointer "AG_Radio")
  (object->pointer #t)
  (pointer->object #t))

(define-foreign-type radio (c-pointer "AG_Radio")
  (object->pointer #f)
  (pointer->object #f))

(define-foreign-type nonnull-textbox (nonnull-c-pointer "AG_Textbox")
  (object->pointer #t)
  (pointer->object #t))

(define-foreign-type textbox (c-pointer "AG_Textbox")
  (object->pointer #f)
  (pointer->object #f))

;; vim:set ft=scheme ts=2 sts=2 sw=2 ai: ;;

Changes to agar.scm.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438


































439
440
441
442
443
444
445
   init-agar!
   pointer->object object->pointer pointer->class class->pointer
   object? lookup-object make-object destroy-object! object-class object-name object-name-set!
   class? lookup-class class-hierarchy class-version
   object-ref object-set! event-add!
   widget-expand! widget-position-set! widget-size-set!
   make-window window-caption window-caption-set! window-visible? window-visible-set!
   make-box make-button
   make-textbox textbox-string textbox-string-set!
   event-loop terminate!)
  (import
    scheme chicken foreign
    (only lolevel pointer? pointer=? tag-pointer tagged-pointer?)
    data-structures ports srfi-42 srfi-69)

................................................................................
              (foreign-safe-lambda void "AG_WindowShow" nonnull-window)
              (foreign-safe-lambda void "AG_WindowHide" nonnull-window))
            win))])
    (values
      (getter-with-setter window-visible? window-visible-set!)
      window-visible-set!)))

(define (make-box parent orientation #!key name homogenous? padding spacing hfill? vfill? expand?)
  (let ([box
         ((foreign-safe-lambda nonnull-box "AG_BoxNew" widget int unsigned-int)
          parent
          (case orientation
            [(horizontal horiz) (foreign-value "AG_BOX_HORIZ" int)]
            [(vertical vert) (foreign-value "AG_BOX_VERT" int)])
          (bitwise-ior
            (if homogenous? (foreign-value "AG_BOX_HOMOGENOUS" unsigned-int) 0)
            (if (or hfill? expand?) (foreign-value "AG_BOX_HFILL" unsigned-int) 0)
            (if (or vfill? expand?) (foreign-value "AG_BOX_VFILL" unsigned-int) 0)))])
    (when name
      (set! (object-name box) name))



    (when padding
      ((foreign-safe-lambda void "AG_BoxSetPadding" nonnull-box int)
       box padding))
    (when spacing
      ((foreign-safe-lambda void "AG_BoxSetSpacing" nonnull-box int)
       box spacing))
    box))

(define (make-button parent #!key name label sticky? hfill? vfill? expand?)
  (let ([btn
         ((foreign-safe-lambda nonnull-button "AG_ButtonNewS" widget unsigned-int c-string)
          parent
          (bitwise-ior
            (if sticky? (foreign-value "AG_BUTTON_STICKY" unsigned-int) 0)
            (if (or hfill? expand?) (foreign-value "AG_BUTTON_HFILL" unsigned-int) 0)
            (if (or vfill? expand?) (foreign-value "AG_BUTTON_VFILL" unsigned-int) 0))
          label)])
    (when name
      (set! (object-name btn) name))
    btn))



































(define (make-textbox parent #!key name label multiline? multilingual? password? int-only? flt-only? catch-tab? noemacs? nolatin1? nopopup? readonly? hfill? vfill? expand?)
  (let ([txt
         ((foreign-safe-lambda nonnull-textbox "AG_TextboxNewS" widget unsigned-int c-string)
          parent
          (bitwise-ior
            (if multiline? (foreign-value "AG_TEXTBOX_MULTILINE" unsigned-int) 0)







|







 







|



|








>
>
>










|









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
   init-agar!
   pointer->object object->pointer pointer->class class->pointer
   object? lookup-object make-object destroy-object! object-class object-name object-name-set!
   class? lookup-class class-hierarchy class-version
   object-ref object-set! event-add!
   widget-expand! widget-position-set! widget-size-set!
   make-window window-caption window-caption-set! window-visible? window-visible-set!
   make-box make-button make-checkbox make-radio
   make-textbox textbox-string textbox-string-set!
   event-loop terminate!)
  (import
    scheme chicken foreign
    (only lolevel pointer? pointer=? tag-pointer tagged-pointer?)
    data-structures ports srfi-42 srfi-69)

................................................................................
              (foreign-safe-lambda void "AG_WindowShow" nonnull-window)
              (foreign-safe-lambda void "AG_WindowHide" nonnull-window))
            win))])
    (values
      (getter-with-setter window-visible? window-visible-set!)
      window-visible-set!)))

(define (make-box parent  #!key name label orient homogenous? padding spacing hfill? vfill? expand?)
  (let ([box
         ((foreign-safe-lambda nonnull-box "AG_BoxNew" widget int unsigned-int)
          parent
          (case orient
            [(horizontal horiz) (foreign-value "AG_BOX_HORIZ" int)]
            [(vertical vert) (foreign-value "AG_BOX_VERT" int)])
          (bitwise-ior
            (if homogenous? (foreign-value "AG_BOX_HOMOGENOUS" unsigned-int) 0)
            (if (or hfill? expand?) (foreign-value "AG_BOX_HFILL" unsigned-int) 0)
            (if (or vfill? expand?) (foreign-value "AG_BOX_VFILL" unsigned-int) 0)))])
    (when name
      (set! (object-name box) name))
    (when label
      ((foreign-safe-lambda void "AG_BoxSetLabelS" nonnull-box c-string)
       box label))
    (when padding
      ((foreign-safe-lambda void "AG_BoxSetPadding" nonnull-box int)
       box padding))
    (when spacing
      ((foreign-safe-lambda void "AG_BoxSetSpacing" nonnull-box int)
       box spacing))
    box))

(define (make-button parent #!key name label sticky? hfill? vfill? expand?)
  (let ([btn
         ((foreign-safe-lambda nonnull-widget "AG_ButtonNewS" widget unsigned-int c-string)
          parent
          (bitwise-ior
            (if sticky? (foreign-value "AG_BUTTON_STICKY" unsigned-int) 0)
            (if (or hfill? expand?) (foreign-value "AG_BUTTON_HFILL" unsigned-int) 0)
            (if (or vfill? expand?) (foreign-value "AG_BUTTON_VFILL" unsigned-int) 0))
          label)])
    (when name
      (set! (object-name btn) name))
    btn))

(define (make-checkbox parent #!key name label state hfill? vfill? expand?)
  (let ([chk
         ((foreign-safe-lambda nonnull-widget "AG_CheckboxNewS" widget unsigned-int c-string)
          parent
          (bitwise-ior
            (if state (foreign-value "AG_CHECKBOX_SET" unsigned-int) 0)
            (if (or hfill? expand?) (foreign-value "AG_CHECKBOX_HFILL" unsigned-int) 0)
            (if (or vfill? expand?) (foreign-value "AG_CHECKBOX_VFILL" unsigned-int) 0))
          label)])
    (when name
      (set! (object-name chk) name))
    chk))

(define (make-radio parent #!key name [items '()] hfill? vfill? expand?)
  (let ([rad
         ((foreign-safe-lambda nonnull-radio "AG_RadioNew" widget unsigned-int c-pointer)
          parent
          (bitwise-ior
            (if (or hfill? expand?) (foreign-value "AG_RADIO_HFILL" unsigned-int) 0)
            (if (or vfill? expand?) (foreign-value "AG_RADIO_VFILL" unsigned-int) 0))
          #f)])
    (when name
      (set! (object-name rad) name))
    (for-each
      (cut radio-item-add! rad <>)
      items)
    rad))

(define radio-items-clear!
  (foreign-safe-lambda void "AG_RadioClearItems" nonnull-radio))

(define radio-item-add!
  (foreign-safe-lambda void "AG_RadioAddItemS" nonnull-radio c-string))

(define (make-textbox parent #!key name label multiline? multilingual? password? int-only? flt-only? catch-tab? noemacs? nolatin1? nopopup? readonly? hfill? vfill? expand?)
  (let ([txt
         ((foreign-safe-lambda nonnull-textbox "AG_TextboxNewS" widget unsigned-int c-string)
          parent
          (bitwise-ior
            (if multiline? (foreign-value "AG_TEXTBOX_MULTILINE" unsigned-int) 0)

Changes to agar.wiki.

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
















157
158
159
160
161
162
163
<h3><a id="window-visible_">procedure: <code><nowiki>(window-visible? WINDOW) → STRING</nowiki></code></a></h3>
<h3><a id="window-visible-set_">procedure: <code><nowiki>(window-visible-set! WINDOW STRING) → UNSPECIFIED</nowiki></code></a></h3>

Accessors for the visibility state of a given window.

<tt>window-visible?</tt> has <tt>window-visible-set!</tt> attached as a setter.

<h3><a id="make-box">procedure: <code><nowiki>(make-box PARENT ORIENTATION [name: STRING] [homogenous?: BOOLEAN] [padding: INTEGER] [spacing: INTEGER] [hfill?: BOOLEAN] [vfill?: BOOLEAN] [expand?: BOOLEAN]) → OBJECT</nowiki></code></a></h3>

Creates a new layout container, passing various flags and settings as
specified. The orientation can be one of the symbols <tt>horizontal</tt>,
<tt>horiz</tt>, <tt>vertical</tt>, <tt>vert</tt>.

<h3><a id="make-button">procedure: <code><nowiki>(make-button PARENT [name: STRING] [label: STRING] [sticky?: BOOLEAN] [hfill?: BOOLEAN] [vfill?: BOOLEAN] [expand?: BOOLEAN]) → OBJECT</nowiki></code></a></h3>

Creates a new button, passing various flags and settings as specified.

















<h3><a id="make-textbox">procedure: <code><nowiki>(make-textbox PARENT [name: STRING] [label: STRING] [multiline?: BOOLEAN] [multilingual?: BOOLEAN] [password?: BOOLEAN] [int-only?: BOOLEAN] [flt-only?: BOOLEAN] [catch-tab?: BOOLEAN] [noemacs?: BOOLEAN] [nolatin1?: BOOLEAN] [nopopup?: BOOLEAN] [readonly?: BOOLEAN] [hfill?: BOOLEAN] [vfill?: BOOLEAN] [expand?: BOOLEAN]) → OBJECT</nowiki></code></a></h3>

Creates a new textbox, passing various flags and settings as specified.

<h3><a id="textbox-string">procedure: <code><nowiki>(textbox-string TEXTBOX) → STRING</nowiki></code></a></h3>
<h3><a id="textbox-string-set_">procedure: <code><nowiki>(textbox-string-set! TEXTBOX STRING) → STRING</nowiki></code></a></h3>







|








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<h3><a id="window-visible_">procedure: <code><nowiki>(window-visible? WINDOW) → STRING</nowiki></code></a></h3>
<h3><a id="window-visible-set_">procedure: <code><nowiki>(window-visible-set! WINDOW STRING) → UNSPECIFIED</nowiki></code></a></h3>

Accessors for the visibility state of a given window.

<tt>window-visible?</tt> has <tt>window-visible-set!</tt> attached as a setter.

<h3><a id="make-box">procedure: <code><nowiki>(make-box PARENT [name: STRING] [label: STRING] [orient: SYMBOL] [homogenous?: BOOLEAN] [padding: INTEGER] [spacing: INTEGER] [hfill?: BOOLEAN] [vfill?: BOOLEAN] [expand?: BOOLEAN]) → OBJECT</nowiki></code></a></h3>

Creates a new layout container, passing various flags and settings as
specified. The orientation can be one of the symbols <tt>horizontal</tt>,
<tt>horiz</tt>, <tt>vertical</tt>, <tt>vert</tt>.

<h3><a id="make-button">procedure: <code><nowiki>(make-button PARENT [name: STRING] [label: STRING] [sticky?: BOOLEAN] [hfill?: BOOLEAN] [vfill?: BOOLEAN] [expand?: BOOLEAN]) → OBJECT</nowiki></code></a></h3>

Creates a new button, passing various flags and settings as specified.

<h3><a id="make-checkbox">procedure: <code><nowiki>(make-checkbox PARENT [name: STRING] [label: STRING] [state: BOOLEAN] [hfill?: BOOLEAN] [vfill?: BOOLEAN] [expand?: BOOLEAN]) → OBJECT</nowiki></code></a></h3>

Creates a new checkbox, passing various flags and settings as specified.

<h3><a id="make-radio">procedure: <code><nowiki>(make-radio PARENT [name: STRING] [label: STRING] [items: LIST] [hfill?: BOOLEAN] [vfill?: BOOLEAN] [expand?: BOOLEAN]) → OBJECT</nowiki></code></a></h3>

Creates a new radio button group, passing various flags and settings as specified.

<h3><a id="radio-items-clear_">procedure: <code><nowiki>(radio-items-clear! RADIO) → UNSPECIFIED</nowiki></code></a></h3>

Removes all radio buttons from a given group.

<h3><a id="radio-item-add_">procedure: <code><nowiki>(radio-item-add! RADIO STRING) → UNSPECIFIED</nowiki></code></a></h3>

Adds a radio button to a given group.

<h3><a id="make-textbox">procedure: <code><nowiki>(make-textbox PARENT [name: STRING] [label: STRING] [multiline?: BOOLEAN] [multilingual?: BOOLEAN] [password?: BOOLEAN] [int-only?: BOOLEAN] [flt-only?: BOOLEAN] [catch-tab?: BOOLEAN] [noemacs?: BOOLEAN] [nolatin1?: BOOLEAN] [nopopup?: BOOLEAN] [readonly?: BOOLEAN] [hfill?: BOOLEAN] [vfill?: BOOLEAN] [expand?: BOOLEAN]) → OBJECT</nowiki></code></a></h3>

Creates a new textbox, passing various flags and settings as specified.

<h3><a id="textbox-string">procedure: <code><nowiki>(textbox-string TEXTBOX) → STRING</nowiki></code></a></h3>
<h3><a id="textbox-string-set_">procedure: <code><nowiki>(textbox-string-set! TEXTBOX STRING) → STRING</nowiki></code></a></h3>