diff --git a/collects/teachpack/htdp/Docs/arrow-gui.scrbl b/collects/teachpack/htdp/Docs/arrow-gui.scrbl new file mode 100644 index 0000000000..d80d71c3a5 --- /dev/null +++ b/collects/teachpack/htdp/Docs/arrow-gui.scrbl @@ -0,0 +1,45 @@ +#lang scribble/doc + +@(require scribble/manual + (for-label scheme + teachpack/htdp/arrow-gui)) + +@title[#:tag "arrow-gui"]{An Arrow GUI: arrow-gui.ss} + +@declare-exporting[teachpack/htdp/arrow-gui] + +The teachpack provides operations for creating and manipulating an arrow +GUI. We recommend using the @seclink["world"]{world teachpack} instead. + +@deftech{modelT} @scheme[(-> button% event% true)] + +A @tech{modelT} is a function that accepts and ignores two arguments. + +@defproc[(control) symbol?]{Reads out the current state of the message +field.} + +@defproc[(view [s (or/c string? symbol?)]) true]{Displays @scheme[s] in the +message field.} + +@defproc[(connect [l (unsyntax @tech{modelT})][r (unsyntax @tech{modelT})][u (unsyntax @tech{modelT})][d (unsyntax @tech{modelT})]) true]{Connects four +controllers with the four directions in the arrow window.} + +Example: +@(begin +#reader scribble/comment-reader +(schemeblock +;; Advanced +(define (make-model dir) + (lambda (b e) + (begin + (view dir) + (printf "~a ~n" (control))))) + +(connect + (make-model "left") + (make-model "right") + (make-model "up") + (make-model "down")) +)) +Now click on the four arrows. The message field contains the current +direction, the print-out the prior contents of the message field. diff --git a/collects/teachpack/htdp/Docs/arrow-gui.thtml b/collects/teachpack/htdp/Docs/arrow-gui.thtml deleted file mode 100644 index 2874dff8e1..0000000000 --- a/collects/teachpack/htdp/Docs/arrow-gui.thtml +++ /dev/null @@ -1,34 +0,0 @@ -{ (define LIBNAME "Arrows GUI") - (include "head.tinc") } - -

The teachpack arrow-gui.ss implements three functions: -

-
  • {(idx control)} : -> symbol
    - to read out the current state of the message field - -
  • {(idx view)} : (union string symbol) -> true
    - to display its argument in the message field - -
  • modelT = (button% event% -> true)
    - {(idx connect)} : modelT modelT modelT modelT -> true
    - to connect four controllers with the four directions in the arrow window -
  • - -

    Example: -

    -> (define (make-model dir)
    -   (lambda (b e)
    -     (begin
    -       (view dir)
    -       (printf "~a ~n" (control)))))
    -
    -> (connect
    -   (make-model "left")
    -   (make-model "right")
    -   (make-model "up")
    -   (make-model "down"))
    -
    -Now click on the four arrows. The message field will contain the current -direction, the print-out the prior contents of the message field. - -{(include "foot.tinc")} diff --git a/collects/teachpack/htdp/Docs/convert.scrbl b/collects/teachpack/htdp/Docs/convert.scrbl index b7e74779b5..8ccd4ba6ed 100644 --- a/collects/teachpack/htdp/Docs/convert.scrbl +++ b/collects/teachpack/htdp/Docs/convert.scrbl @@ -4,7 +4,7 @@ (for-label scheme teachpack/htdp/convert)) -@title[#:tag "convert"]{Converting Temperaturs: convert.ss} +@title[#:tag "convert"]{Converting Temperatures: convert.ss} @declare-exporting[teachpack/htdp/convert] diff --git a/collects/teachpack/htdp/Docs/dir.scrbl b/collects/teachpack/htdp/Docs/dir.scrbl new file mode 100644 index 0000000000..172444c581 --- /dev/null +++ b/collects/teachpack/htdp/Docs/dir.scrbl @@ -0,0 +1,41 @@ +#lang scribble/doc + +@(require scribble/manual + (for-label (except-in scheme/base file-size) + teachpack/htdp/dir)) + +@title[#:tag "dir"]{Working with Files and Directories: dir.ss} + +@declare-exporting[teachpack/htdp/dir] + +The teachpack provides structures and operations for working with files and +directories: + +@defstruct[dir ([name string?][dirs (list-of dir?)][files (list-of file?)])]{} + +@defstruct[file ([name string?][content (list-of char?)])]{} + +@defproc[(create-dir [path string?]) dir?]{ + Turns the directory found at @scheme[path] on your computer into an instance of @scheme[dir?].} + +Sample: Set teachpack to dir.ss and click RUN: +@(begin +#reader scribble/comment-reader +(schemeblock +> (create-dir ".") +(make-dir + '|.| + empty + (cons (make-file 'ball1.gif 1289 empty) + (cons (make-file 'blueball.gif 205 empty) + (cons (make-file 'greenbal.gif 204 empty) + (cons (make-file 'redball.gif 203 empty) + (cons (make-file 'ufo.gif 1044 empty) + (cons (make-file 'gif-test.ss 5811 empty) + empty))))))) +)) +Using ``.'' usually means the directory in which your program is +located. In this case, the directory contains no sub-directories and six +files. + +Note: Softlinks are always treated as if they were empty files. diff --git a/collects/teachpack/htdp/Docs/dir.thtml b/collects/teachpack/htdp/Docs/dir.thtml deleted file mode 100644 index 8ff9259cdf..0000000000 --- a/collects/teachpack/htdp/Docs/dir.thtml +++ /dev/null @@ -1,41 +0,0 @@ -{ (define LIBNAME "Directories") - (include "head.tinc") } - -

    The teachpack dir.ss provides two-structures and one -operation: -

    -
  • (define-struct dir (name dirs files)) - -
  • (define-struct file (name size content)) - -
  • {(idx create-dir)} which consumes a directory path (a string) - and produces a directory. -
  • - -

    The teachpack relies on two data definitions: -

    -
  • - A Directory is - ({(idx make-dir)} string[path] (listof Directory) (listof File)) -
  • - A File is ({(idx make-file)} String PositiveNumber (listof Char)) -
  • - -Sample: Set teachpack to dir.ss and execute. Then evaluate -
    -> (create-dir ".")
    -(make-dir
    -  '|.|
    -  empty
    -  (cons (make-file 'ball1.gif 1289 empty)
    -        (cons (make-file 'blueball.gif 205 empty)
    -              (cons (make-file 'greenbal.gif 204 empty)
    -                    (cons (make-file 'redball.gif 203 empty)
    -                          (cons (make-file 'ufo.gif 1044 empty)
    -                                (cons (make-file 'gif-test.ss 5811 empty)
    -                                      empty)))))))
    -
    - -

    Note: Softlinks are always treated as if they were empty files. - -{(include "foot.tinc")} diff --git a/collects/teachpack/htdp/Docs/graphing.scrbl b/collects/teachpack/htdp/Docs/graphing.scrbl new file mode 100644 index 0000000000..93112856e8 --- /dev/null +++ b/collects/teachpack/htdp/Docs/graphing.scrbl @@ -0,0 +1,23 @@ +#lang scribble/doc + +@(require scribble/manual + (for-label scheme + teachpack/htdp/graphing)) + +@title[#:tag "graphing"]{Graphing Functions: graphing.ss} + +@declare-exporting[teachpack/htdp/graphing] + +The teachpack provides two operations for graphing functions in the regular +(upper right) quadrant of the Cartesian plane (between 0 and 10 in both +directions): + +@defproc[(graph-fun [f (-> number? number?)][color symbol?]) true]{ +Draws the graph of @scheme[f] with the given @scheme[color].} + +@defproc[(graph-line [line (-> number? number?)][color symbol?]) true]{ +Draws @scheme[line], a function representing a straight line, with a given +color.} + +For color symbols, see @secref{draw}. + diff --git a/collects/teachpack/htdp/Docs/graphing.thtml b/collects/teachpack/htdp/Docs/graphing.thtml deleted file mode 100644 index c1eeac03cb..0000000000 --- a/collects/teachpack/htdp/Docs/graphing.thtml +++ /dev/null @@ -1,18 +0,0 @@ -{ (define LIBNAME "Graphing Functions") - (include "head.tinc") } - -The teachpack graphing.ss provides two operations for -graphing functions in the regular (north-east) quadrant of the Cartesian -plane (between 0 and 10 in both directions): -graphics functions: -

    -
  • {(idx graph-fun)} : (number -> number) symbol -> true;
    -draws a function in bulletized form with a given color -
  • {(idx graph-line)} : (number -> number) symbol -> true (no arguments);
    -draws a straight-line function with a given color -
  • -For legal color symbols, see the documentation for the draw.ss -teachpack. -
    - -{(include "foot.tinc")} diff --git a/collects/teachpack/htdp/Docs/gui.scrbl b/collects/teachpack/htdp/Docs/gui.scrbl new file mode 100644 index 0000000000..6e24be5bf5 --- /dev/null +++ b/collects/teachpack/htdp/Docs/gui.scrbl @@ -0,0 +1,87 @@ +#lang scribble/doc + +@(require scribble/manual + (for-label scheme + teachpack/htdp/gui)) + +@title[#:tag "gui"]{Simple Graphical User Interfaces: gui.ss} + +@declare-exporting[teachpack/htdp/gui] + +The teachpack provides operations for creating and manipulating graphical +user interfaces. We recommend using the @seclink["world"]{world teachpack} +instead. + +@deftech{Window} A @tech{Window} is a data representation of a visible +window on your computer screen. + +@deftech{GUI-ITEM} A @tech{GUI-Item} is a data representation of an active +component of a window on your computer screen. + +@defproc[(show-window [w Window]) true]{Shows @scheme[w].} + +@defproc[(hide-window [w window]) true]{Hides @scheme[w].} + +@defproc[(create-window [g (listof (listof (unsyntax @tech{GUI-ITEM})))]) Window]{ +Creates a window from the ``matrix'' of gui items @scheme[g].} + +@defproc[(make-button [label string>][callback (-> event% boolean)]) (unsyntax @tech{GUI-ITEM})]{Creates a +button with @scheme[label] and @scheme[callback] function. The latter +receives an argument that it may safely ignore.} + +@defproc[(make-message [msg string?]) (unsyntax @tech{GUI-ITEM})]{Creates a message item from @scheme[msg].} + +@defproc[(draw-message [g (unsyntax @tech{GUI-ITEM})][m string?]) true]{Displays @scheme[m] +in message item @scheme[g] and erases the current message.} + +@defproc[(make-text [txt string?]) (unsyntax @tech{GUI-ITEM})]{Creates an text editor (with +label @scheme[txt]) that allows users to enter text.} + +@defproc[(text-contents [g (unsyntax @tech{GUI-ITEM})]) string?]{ +Determines the current contents of a text @tech{GUI-ITEM}.} + +@defproc[(make-choice [choices (listof string?)]) (unsyntax @tech{GUI-ITEM})]{ +Creates a choice menu from @scheme[choices] that permits users to choose +from some alternatives.} + +@defproc[(choice-index [g (unsyntax @tech{GUI-ITEM})]) natural-number/c]{Determines the +choice that is currently selected in a choice @tech{GUI-ITEM}; the result +is the 0-based index in the choice menu} + +Example 1: +@(begin +#reader scribble/comment-reader +(schemeblock +> (define w (create-window (list (list (make-button "QUIT" (lambda (e) (hide-window w))))))) +;; A button appears on the screen. Click on the button and it will disappear. +> (show-window w) +;; The window disappears. +)) + +Example 2: +@(begin +#reader scribble/comment-reader +(schemeblock +;; text1 : GUI-ITEM +(define text1 + (make-text "Please enter your name")) + +;; msg1 : GUI-ITEM +(define msg1 + (make-message (string-append "Hello, World" (make-string 33 #\SPACE)))) + +;; Event -> true +;; draws the current contents of text1 into msg1, prepended with "Hello, " +(define (respond e) + (draw-message msg1 (string-append "Hello, " (text-contents text1)))) + +;; set up window with three "lines": a text field, a message, and two buttons +;; fill in text and click OKAY +(define w + (create-window + (list + (list text1) + (list msg1) + (list (make-button "OKAY" respond) + (make-button "QUIT" (lambda (e) (hide-window w))))))) +)) diff --git a/collects/teachpack/htdp/Docs/gui.thtml b/collects/teachpack/htdp/Docs/gui.thtml deleted file mode 100644 index 07857fef47..0000000000 --- a/collects/teachpack/htdp/Docs/gui.thtml +++ /dev/null @@ -1,77 +0,0 @@ -{ (define LIBNAME "GUI") - (include "head.tinc") } - -

    The teachpack gui.ss provides the following operations: -

    -
  • {(idx show-window)} : window -> true -
    to show the window - -
  • {(idx hide-window)} : window -> true -
    to hide the window - -
  • {(idx create-window)} : (listof (listof gui-item)) -> window -
    to add gui-items to a window and to show the window -
    each list of gui-items defines one row of gui items in the window - -
  • {(idx make-button)} : str (event% -> boolean) -> gui-item -
    to create a button with label and call-back function - -
  • {(idx make-message)} : str -> gui-item -
    to create an item that displays a message - -
  • {(idx draw-message)} : gui-item[message%] stri -> true -
    to display a message in a message item -
    it erases the current message - -
  • {(idx make-text)} : str -> gui-item -
    to create an item (with label) that allows users to enter text - -
  • {(idx text-contents)} : gui-item[text%] -> str -
    to determine the contents of a text field - -
  • {(idx make-choice)} : (listof str) -> gui-item -
    to create a choice menu that permits users to choose from some - string alternatives - -
  • {(idx choice-index)} : gui-item[choice%] -> num -
    to determine which choice is currently selected in a choice-item -
    the result is the 0-based index in the choice menu -
  • - -

    Example 1: -

    -> (define w (create-window (list (list (make-button "QUIT" (lambda (e) (hide-window w)))))))
    -
    -A button appears on the screen. Click on the button and it will disappear. -
    -> (show-window w)
    -
    -The frame reappears. - -

    Example 2: -

    -; text1 : GUI-ITEM
    -(define text1
    -  (make-text "Please enter your name"))
    -
    -; msg1 : GUI-ITEM
    -(define msg1
    -  (make-message (string-append "Hello, World" (make-string 33 #\SPACE))))
    -
    -; Event -> true
    -; draws the current contents of text1 into msg1, prepended with "Hello, "
    -(define (respond e)
    -  (draw-message msg1 (string-append "Hello, " (text-contents text1))))
    -
    -; set up window with three "lines": a text field, a message, and two buttons
    -; fill in text and click OKAY
    -(define w 
    - (create-window
    -  (list
    -   (list text1)
    -   (list msg1)
    -   (list (make-button "OKAY" respond)
    -	 (make-button "QUIT" (lambda (e) (hide-window w)))))))
    -
    - -{(include "foot.tinc")} diff --git a/collects/teachpack/htdp/Docs/htdp.scrbl b/collects/teachpack/htdp/Docs/htdp.scrbl index 7d984469ab..ad3c62aaa6 100644 --- a/collects/teachpack/htdp/Docs/htdp.scrbl +++ b/collects/teachpack/htdp/Docs/htdp.scrbl @@ -17,15 +17,14 @@ @include-section["hangman.scrbl"] @include-section["arrow.scrbl"] @include-section["docs.scrbl"] +@include-section["dir.scrbl"] +@include-section["graphing.scrbl"] +@include-section["gui.scrbl"] +@include-section["arrow-gui.scrbl"] -@;include-section["files-directories.scrbl"] -@;include-section["graphing.scrbl"] -@;include-section["gui.scrbl"] -@;include-section["lookup-gui.scrbl"] -@;include-section["arrows-gui.scrbl"] @;include-section["guess-gui.scrbl"] @;include-section["elevator.scrbl"] -@;include-section["Simplified Scheme Web Servlets" -@;include-section["Scheme Web Servlets" +@;include-section["Simplified Scheme Web Servlets"] +@;include-section["Scheme Web Servlets"] @;include-section["queen.scrbl"]