stk/STklos/Tk/Composite/Defbutton.stklos

86 lines
2.8 KiB
Plaintext
Raw Normal View History

1996-09-27 06:29:02 -04:00
;;;;
;;;; D e f b u t t o n . s t k -- Default button composite widget
;;;;
1998-04-10 06:59:06 -04:00
;;;; Copyright <20> 1993-1998 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
1996-09-27 06:29:02 -04:00
;;;;
;;;; Permission to use, copy, and/or distribute this software and its
;;;; documentation for any purpose and without fee is hereby granted, provided
;;;; that both the above copyright notice and this permission notice appear in
;;;; all copies and derived works. Fees for distribution or use of this
;;;; software or derived works may only be charged with express written
;;;; permission of the copyright holder.
;;;; This software is provided ``as is'' without express or implied warranty.
;;;;
1998-04-10 06:59:06 -04:00
;;;; $Id: Defbutton.stklos 1.3 Wed, 04 Feb 1998 11:34:59 +0100 eg $
;;;;
1996-09-27 06:29:02 -04:00
;;;; Author: Erick Gallesio [eg@kaolin.unice.fr]
;;;; Creation date: 22-Mar-1994 13:05
1998-04-10 06:59:06 -04:00
;;;; Last file update: 3-Feb-1998 18:37
(require "Basics")
1996-09-27 06:29:02 -04:00
1998-04-10 06:59:06 -04:00
(select-module STklos+Tk)
1996-09-27 06:29:02 -04:00
1998-04-10 06:59:06 -04:00
;=============================================================================
;
; < D e f a u l t - b u t t o n >
;
;=============================================================================
1996-09-27 06:29:02 -04:00
;;;;
1998-04-10 06:59:06 -04:00
;;;; Resources
1996-09-27 06:29:02 -04:00
;;;;
1998-04-10 06:59:06 -04:00
(option 'add "*DefaultButton.Border.BorderWidth" 1 "widgetDefault")
(option 'add "*DefaultButton.Border.Relief" "sunken" "widgetDefault")
1996-09-27 06:29:02 -04:00
1998-04-10 06:59:06 -04:00
;;;;
;;;; Class definition
;;;;
1996-09-27 06:29:02 -04:00
(define-class <Default-button> (<Tk-composite-widget> <Button>)
1998-04-10 06:59:06 -04:00
((class :init-keyword :class
:init-form "DefaultButton")
(button :accessor button-of)
1996-09-27 06:29:02 -04:00
(internal-frame :accessor internal-frame-of)
1998-04-10 06:59:06 -04:00
1996-09-27 06:29:02 -04:00
;; Fictive slots
(background :accessor background
:init-keyword :background
:allocation :propagated
:propagate-to (frame button internal-frame))
(border-width :accessor border-width
:allocation :propagated
:init-keyword :border-width
:propagate-to (frame))
(relief :accessor relief
:init-keyword :relief
:allocation :propagated
:propagate-to (frame))))
(define-method initialize-composite-widget ((self <Default-button>) initargs frame)
1998-04-10 06:59:06 -04:00
(let* ((if (make <Frame> :parent frame :class "Border"))
1996-09-27 06:29:02 -04:00
(b (make <Button> :parent if)))
1998-04-10 06:59:06 -04:00
(next-method)
(pack (Id b) :padx 5 :pady 5 :expand #t)
(pack if :padx 5 :pady 5 :expand #t)
(set! (highlight-thickness frame) 1)
(focus b)
(bind b "<Return>" (lambda () (invoke b)))
1996-09-27 06:29:02 -04:00
(slot-set! self 'Id (Id b))
(slot-set! self 'button b)
(slot-set! self 'internal-frame if)))
1998-04-10 06:59:06 -04:00
1996-09-27 06:29:02 -04:00
(provide "Defbutton")
1998-04-10 06:59:06 -04:00
#|
Example:
(define db (make <Default-button> :text "Type Return anywhere"
:command (lambda () (display "Default\n"))))
(define b (make <Button> :text "Another button"
:command (lambda () (display "Other\n"))))
(pack db b :side 'left :padx 20 :pady 20)
|#