;;;;
;;;; STk adaptation of the Tk widget demo.
;;;;
;;;; This demonstration script is the same as the entry1.tcl script
;;;; except that it creates scrollbars for the entries.
;;;;
(require "Tk-classes")

(define (demo-entry2)
  (define w (make-demo-toplevel "entry2"
				"Entry Demonstration (with scrollbars)"
				"Three different entries are displayed below, with a scrollbar for each entry.  You can add characters by pointing, clicking and typing.  The normal Motif editing characters are supported, along with many Emacs bindings.  For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor.  For entries that are too large to fit in the window all at once, you can scan through the entries with the scrollbars, or by dragging with Shift key and mouse button2 pressed."))

  (define (scroll-entry  value)
    (let* 
	((f (make <Frame>     :parent w))
	 (s (make <Scrollbar> :parent f :relief "sunken" :orientation 'h :width 10))
	 (e (make <Entry>     :parent f :relief "sunken" :value value)))
      ;; pack entry and scrollbar.
      (pack e s :side "top" :fill "x")
      ;; Associate bindings
      (slot-set! e 'x-scroll-command (lambda l (apply (slot-ref s 'Id) 'set  l)))
      (slot-set! s 'command 	     (lambda l (apply (slot-ref e 'Id) 'xview l)))
      ;; return the enclosing frame
      f))

    (pack (scroll-entry "Initial value")
	  (scroll-entry "This entry contains a long value, much too long to fit in the window at one time, so long in fact that you'll have to scan or scroll to see the end.")
	  (scroll-entry "")
	  :side "top"
	  :padx 10
	  :pady 10
	  :fill "x"))
