Changeset 25609 in project
- Timestamp:
- 12/01/11 14:08:04 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wiki/iup-tutor
r25606 r25609 529 529 (show (message-dialog title: title value: value) #:modal? #t)) 530 530 531 ;; setter and getter 532 ;; widgets are referenced by name 531 533 (define (set-attribute keyword) 532 534 (let ( 533 535 (msg (sprintf "Attribute ~A set with value ~A" 534 keyword (attribute line value:)))536 keyword (attribute single value:))) 535 537 (multi (handle-ref "multi")) 536 ( line (handle-ref "line"))538 (single (handle-ref "single")) 537 539 ) 538 (attribute-set! multi keyword (attribute line value:))540 (attribute-set! multi keyword (attribute single value:)) 539 541 (message "Set attribute" msg) 540 542 'default)) … … 545 547 keyword (attribute multi keyword))) 546 548 (multi (handle-ref "multi")) 547 ( line (handle-ref "line"))549 (single (handle-ref "single")) 548 550 ) 549 (attribute-set! line value: (attribute multi keyword))551 (attribute-set! single value: (attribute multi keyword)) 550 552 (message "Get attribute" msg) 551 553 'default)) 552 554 555 ;; callback generator 556 (define (cb keyword) 557 (lambda (self) 558 (let ((lb (handle-ref "lb"))) 559 (if (eqv? (string->number (attribute lb value:)) 1) 560 (set-attribute keyword) 561 (get-attribute keyword)) 562 'default))) 563 564 ;; buttons 553 565 (define btn-append 554 566 (button title: '&Append 555 action: (lambda (self) 556 (let ((lb (handle-ref "lb"))) 557 (if (eqv? (string->number (attribute lb value:)) 1) 558 (set-attribute append:) 559 (get-attribute append:)) 560 'default)))) 567 action: (cb append:))) 561 568 562 569 (define btn-insert 563 570 (button title: '&Insert 564 action: (lambda (self) 565 (let ((lb (handle-ref "lb"))) 566 (if (eqv? (string->number (attribute lb value:)) 1) 567 (set-attribute insert:) 568 (get-attribute insert:)) 569 'default)))) 571 action: (cb insert:))) 570 572 571 573 (define btn-border 572 574 (button title: '&Border 573 action: (lambda (self) 574 (let ((lb (handle-ref "lb"))) 575 (if (eqv? (string->number (attribute lb value:)) 1) 576 (set-attribute border:) 577 (get-attribute border:)) 578 'default)))) 575 action: (cb boarder:))) 579 576 580 577 (define btn-caret 581 578 (button title: '&Caret 582 action: (lambda (self) 583 (let ((lb (handle-ref "lb"))) 584 (if (eqv? (string->number (attribute lb value:)) 1) 585 (set-attribute caret:) 586 (get-attribute caret:)) 587 'default)))) 579 action: (cb caret:))) 588 580 589 581 (define btn-readonly 590 582 (button title: '&Readonly 591 action: (lambda (self) 592 (let ((lb (handle-ref "lb"))) 593 (if (eqv? (string->number (attribute lb value:)) 1) 594 (set-attribute readonly:) 595 (get-attribute readonly:)) 596 'default)))) 583 action: (cb readonly:))) 597 584 598 585 (define btn-selection 599 586 (button title: '&Selection 600 action: (lambda (self) 601 (let ((lb (handle-ref "lb"))) 602 (if (eqv? (string->number (attribute lb value:)) 1) 603 (set-attribute selection:) 604 (get-attribute selection:)) 605 'default)))) 587 action: (cb selection:))) 606 588 607 589 (define btn-selectedtextbox 608 590 (button title: 'Selected&textbox 609 action: (lambda (self) 610 (let ((lb (handle-ref "lb"))) 611 (if (eqv? (string->number (attribute lb value:)) 1) 612 (set-attribute selectedbox:) 613 (get-attribute selectedbox:)) 614 'default)))) 591 action: (cb selectedbox:))) 615 592 616 593 (define btn-nc 617 594 (button title: '&Nc 618 action: (lambda (self) 619 (let ((lb (handle-ref "lb"))) 620 (if (eqv? (string->number (attribute lb value:)) 1) 621 (set-attribute nc:) 622 (get-attribute nc:)) 623 'default)))) 595 action: (cb nc:))) 624 596 625 597 (define btn-value 626 598 (button title: '&Value 627 action: (lambda (self) 628 (let ((lb (handle-ref "lb"))) 629 (if (not (attribute lb value:)) 630 (set! (attribute lb value:) 1)) 631 (if (eqv? (string->number (attribute lb value:)) 1) 632 (set-attribute value:) 633 (get-attribute value:)) 634 'default)))) 635 599 action: (cb value:))) 600 601 ;; other widgets 636 602 (define lb (listbox #:1 'set #:2 'get value: 1 dropdown: #t)) 637 603 (define multi (textbox expand: #t multiline: #t)) 638 (define line (textbox expand: 'horizontal))639 640 604 (define single (textbox expand: 'horizontal)) 605 606 ;; name those other widgets, so that they can be referenced by name 641 607 (set! (handle-name lb) "lb") 642 608 (set! (handle-name multi) "multi") 643 (set! (handle-name line) "line") 644 609 (set! (handle-name single) "single") 610 611 ;; the dialog 645 612 (define dlg 646 613 (dialog (vbox multi 647 614 (hbox lb 648 line)615 single) 649 616 (hbox btn-append btn-insert btn-border btn-caret 650 617 btn-readonly btn-selection) … … 657 624 (destroy! dlg) 658 625 (exit 0) 659 660 626 </enscript> 661 627 … … 677 643 == Last updated 678 644 679 Nov 29, 2011645 Dec 01, 2011
Note: See TracChangeset
for help on using the changeset viewer.