diff --git a/collects/mrlib/cache-image-snip.ss b/collects/mrlib/cache-image-snip.ss index 12eadb20..19e9bbb6 100644 --- a/collects/mrlib/cache-image-snip.ss +++ b/collects/mrlib/cache-image-snip.ss @@ -197,6 +197,7 @@ [h (send bm get-height)] [new-bm (make-object bitmap% w h)] [bdc (make-object bitmap-dc% new-bm)]) + (send bdc clear) (send bdc draw-bitmap bm 0 0 'solid (send the-color-database find-color "black") (send bm get-loaded-mask)) diff --git a/collects/mrlib/doc/aligned-pasteboard/aligned-editor-canvas-class.scrbl b/collects/mrlib/doc/aligned-pasteboard/aligned-editor-canvas-class.scrbl new file mode 100644 index 00000000..d996e011 --- /dev/null +++ b/collects/mrlib/doc/aligned-pasteboard/aligned-editor-canvas-class.scrbl @@ -0,0 +1,10 @@ +#lang scribble/doc +@(require "common.ss") + +@defclass/title[aligned-editor-canvas% editor-canvas% ()]{ + +Calls the +@method[aligned-pasteboard<%> realign] method when resized. + +} + diff --git a/collects/mrlib/doc/aligned-pasteboard/aligned-editor-snip-class.scrbl b/collects/mrlib/doc/aligned-pasteboard/aligned-editor-snip-class.scrbl new file mode 100644 index 00000000..5740201c --- /dev/null +++ b/collects/mrlib/doc/aligned-pasteboard/aligned-editor-snip-class.scrbl @@ -0,0 +1,9 @@ +#lang scribble/doc +@(require "common.ss") + +@defclass/title[aligned-editor-snip% editor-snip% ()]{ + +Calls the @method[aligned-pasteboard<%> realign] method when resized. + +} + diff --git a/collects/mrlib/doc/aligned-pasteboard/aligned-pasteboard-intf.scrbl b/collects/mrlib/doc/aligned-pasteboard/aligned-pasteboard-intf.scrbl new file mode 100644 index 00000000..7055eaea --- /dev/null +++ b/collects/mrlib/doc/aligned-pasteboard/aligned-pasteboard-intf.scrbl @@ -0,0 +1,37 @@ +#lang scribble/doc +@(require "common.ss") + +@definterface/title[aligned-pasteboard<%> ()]{ + + + +@defmethod[(get-aligned-min-height) + real?]{ + +The minimum height an aligned-pasteboard can be and still +fit the heights of all of its children.} + + +@defmethod[(get-aligned-min-width) + real?]{ +The minimum width an aligned-pasteboard can be and still +fit the widths of all of its children. + +} + +@defmethod*[([(realign [width exact-nonnegative-integer?] + [height exact-nonnegative-integer?]) + void?] + [(realign) + void?])]{ + +Realigns the children inside the @scheme[aligned-pasteboard<%>] to +either a given @scheme[width] and @scheme[height] or the previously +alloted width and height.} + +@defmethod[(set-aligned-min-sizes) + void?]{ + +Calculates the minimum width and height of the of the +pasteboard based on children's min-sizes and stores it for +later retrieval via the getters.}} diff --git a/collects/mrlib/doc/aligned-pasteboard/aligned-pasteboard-parent-intf.scrbl b/collects/mrlib/doc/aligned-pasteboard/aligned-pasteboard-parent-intf.scrbl new file mode 100644 index 00000000..81f7a8b4 --- /dev/null +++ b/collects/mrlib/doc/aligned-pasteboard/aligned-pasteboard-parent-intf.scrbl @@ -0,0 +1,13 @@ +#lang scribble/doc +@(require "common.ss") + +@definterface/title[aligned-pasteboard-parent<%> ()]{ + +This interface must be implemented by any class who's editor +is an @scheme[aligned-pasteboard<%>]. + +@defmethod[(set-aligned-min-sizes) + void?]{} + +} + diff --git a/collects/mrlib/doc/aligned-pasteboard/aligned-pasteboard.scrbl b/collects/mrlib/doc/aligned-pasteboard/aligned-pasteboard.scrbl new file mode 100644 index 00000000..d2b13f17 --- /dev/null +++ b/collects/mrlib/doc/aligned-pasteboard/aligned-pasteboard.scrbl @@ -0,0 +1,20 @@ +#lang scribble/doc +@(require "../common.ss") + +@title[#:style 'toc]{Aligned Pasteboard} + +The aligned-pasteboard library provides classes derived from +@scheme[pasteboard%] with geometry management that mirrors that of +@scheme[vertical-panel%] and @scheme[horizontal-panel%]. + +@defmodule[mrlib/aligned-pasteboard] + +@local-table-of-contents[] + +@include-section["aligned-pasteboard-intf.scrbl"] +@include-section["horizontal-pasteboard-class.scrbl"] +@include-section["vertical-pasteboard-class.scrbl"] +@include-section["aligned-editor-snip-class.scrbl"] +@include-section["aligned-editor-canvas-class.scrbl"] +@include-section["aligned-pasteboard-parent-intf.scrbl"] +@include-section["stretchable-snip-intf.scrbl"] diff --git a/collects/mrlib/doc/aligned-pasteboard/common.ss b/collects/mrlib/doc/aligned-pasteboard/common.ss new file mode 100644 index 00000000..9f62762a --- /dev/null +++ b/collects/mrlib/doc/aligned-pasteboard/common.ss @@ -0,0 +1,8 @@ +#lang scheme/base + +(require "../common.ss" + (for-label mrlib/aligned-pasteboard)) + +(provide (all-from-out "../common.ss") + (for-label (all-from-out mrlib/aligned-pasteboard))) + diff --git a/collects/mrlib/doc/aligned-pasteboard/horizontal-pasteboard-class.scrbl b/collects/mrlib/doc/aligned-pasteboard/horizontal-pasteboard-class.scrbl new file mode 100644 index 00000000..10319a0c --- /dev/null +++ b/collects/mrlib/doc/aligned-pasteboard/horizontal-pasteboard-class.scrbl @@ -0,0 +1,31 @@ +#lang scribble/doc +@(require "common.ss") + +@defclass/title[horizontal-pasteboard% pasteboard% (aligned-pasteboard<%>)]{ + +@defconstructor/auto-super[()]{ +Passes all arguments to @scheme[super-init]. +} + +@defmethod[#:mode override + (after-delete [snip (is-a?/c snip%)]) + void?]{} + +@defmethod[#:mode override + (after-insert [snip (is-a?/c snip%)] + [before (or/c (is-a?/c snip%) false/c)] + [x real?] + [y real?]) + void?]{} + +@defmethod[#:mode override + (after-reorder [snip (is-a?/c snip%)] + [to-snip (is-a?/c snip%)] + [before? any/c]) + boolean?]{} + +@defmethod[#:mode override + (resized [snip (is-a?/c snip%)] + [redraw-now? any/c]) + void?]{}} + diff --git a/collects/mrlib/doc/aligned-pasteboard/stretchable-snip-intf.scrbl b/collects/mrlib/doc/aligned-pasteboard/stretchable-snip-intf.scrbl new file mode 100644 index 00000000..64f72b1e --- /dev/null +++ b/collects/mrlib/doc/aligned-pasteboard/stretchable-snip-intf.scrbl @@ -0,0 +1,34 @@ +#lang scribble/doc +@(require "common.ss") + +@definterface/title[stretchable-snip<%> ()]{ + +This interface must be implemented by any snip class who's +objects will be stretchable when inserted into an +@scheme[aligned-pasteboard<%>]. + + + +@defmethod[(get-aligned-min-height) + real?]{ +The minimum height that the snip can be resized to + +} + +@defmethod[(get-aligned-min-width) + real?]{ +The minimum width that the snip can be resized to. + +} + +@defmethod[(stretchable-height) + boolean?]{ +Whether or not the snip can be stretched in the Y dimension + +} + +@defmethod[(stretchable-width) + boolean?]{ +Whether or not the snip can be stretched in the X dimension + +}} diff --git a/collects/mrlib/doc/aligned-pasteboard/vertical-pasteboard-class.scrbl b/collects/mrlib/doc/aligned-pasteboard/vertical-pasteboard-class.scrbl new file mode 100644 index 00000000..151f6e50 --- /dev/null +++ b/collects/mrlib/doc/aligned-pasteboard/vertical-pasteboard-class.scrbl @@ -0,0 +1,30 @@ +#lang scribble/doc +@(require "common.ss") + +@defclass/title[vertical-pasteboard% pasteboard% (aligned-pasteboard<%>)]{ + +@defconstructor/auto-super[()]{ +Passes all arguments to @scheme[super-init]. +} + +@defmethod[#:mode override + (after-delete [snip (is-a?/c snip%)]) + void?]{} + +@defmethod[#:mode override + (after-insert [snip (is-a?/c snip%)] + [before (or/c (is-a?/c snip%) false/c)] + [x real?] + [y real?]) + void?]{} + +@defmethod[#:mode override + (after-reorder [snip (is-a?/c snip%)] + [to-snip (is-a?/c snip%)] + [before? any/c]) + boolean?]{} + +@defmethod[#:mode override + (resized [snip (is-a?/c snip%)] + [redraw-now? any/c]) + void?]{}} diff --git a/collects/mrlib/doc/bitmap-label.scrbl b/collects/mrlib/doc/bitmap-label.scrbl new file mode 100644 index 00000000..d9ae7030 --- /dev/null +++ b/collects/mrlib/doc/bitmap-label.scrbl @@ -0,0 +1,24 @@ +#lang scribble/doc +@(require "common.ss" + (for-label mrlib/bitmap-label)) + +@title{Bitmap Label} + +@defmodule[mrlib/bitmap-label] + +@defproc[(make-bitmap-label [str string?] + [img (or/c (is-a?/c bitmap%) path-string?)] + [font (is-a?/c font%) normal-control-font]) + (is-a?/c bitmap%)]{ + +Constructs a bitmap label suitable for use a button that contains the +image specified by @scheme[img] followed by the text in @scheme[str].} + + +@defproc[((bitmap-label-maker [str string?] + [img (or/c (is-a?/c bitmap%) path-string?)]) + [future-parent (is-a?/c area-container<%>)]) + (is-a?/c bitmap%)]{ + +And older variant of @scheme[make-bitmap-label] that obtains a +font to use from a container @scheme[future-parent].} diff --git a/collects/mrlib/doc/cache-image-snip.scrbl b/collects/mrlib/doc/cache-image-snip.scrbl new file mode 100644 index 00000000..e1bb976b --- /dev/null +++ b/collects/mrlib/doc/cache-image-snip.scrbl @@ -0,0 +1,150 @@ +#lang scribble/doc +@(require "common.ss" + (for-label mrlib/cache-image-snip)) + +@title{Cache-image Snip} + +@defmodule[mrlib/cache-image-snip]{ + +The @schememodname[mrlib/cache-image-snip] library provides the core +data structure for DrScheme's @filepath{image.ss} teachpack. Images in +the @filepath{image.ss} teachpack are instances of the +@scheme[cache-image-snip%] class.} + +The library also defines a new type, @scheme[argb], that represents a +bitmap, but with alpha values. It has a maker, two selectors, and a +predicate. + + +@defclass[cache-image-snip% snip% ()]{ + + +@defmethod[(get-argb) + argb?]{ + + Returns a pixel array for this image, forcing it to be + computed. +} + +@defmethod[(get-argb-proc) + (argb? exact-integer? exact-integer? . -> . void?)]{ + + Returns a procedure that fills in an argb with the contents of this image + at the given offset + + +} + +@defmethod[(get-argb/no-compute) + (or/c false/c argb?)]{ + + Returns a pixel array for this image or @scheme[#f] if it has not + been computed yet. + + +} + +@defmethod[(get-bitmap) + (is-a?/c bitmap%)]{ + + Builds (if not yet built) a bitmap corresponding to + this snip and returns it. + + +} + +@defmethod[(get-dc-proc) + (or/c false/c ((is-a?/c dc<%>) real? real? -> void?))]{ + + Either returns false, or a procedure that draws the + contents of this snip into a dc. + +} + +@defmethod[(get-pinhole) + (values real? real?)]{ + + Returns the pinhole coordinates for this image, counting + from the top-left of the image. + + +} + +@defmethod[(get-size) + (values exact-nonnegative-integer? exact-nonnegative-integer?)]{ + + Returns the width and height for the image. + +}} + +@; ---------------------------------------- + +@defthing[snip-class (is-a?/c snip-class%)]{ + +This snipclass is used for saved cache image snips.} + +@defproc[(make-argb [vectorof (integer-in 0 255)] [width exact-nonnegative-integer?]) + argb?]{ + + Constructs a new argb value. The vector has four entries + for each pixel, an alpha, red, green, and blue value. The + int specifies the width of the image; the height is the + size of the vector, divided by 4, divided by the width.} + +@defproc[(argb-vector [argb argb?]) (vectorof (integer-in 0 255))]{ + + Extracts the vector from @scheme[argb].} + +@defproc[(argb-width [argb argb?]) exact-nonnegative-integer?]{ + + Extracts the width from @scheme[argb].} + + +@defproc[(argb? [v any/c]) boolean?]{ + +Returns @scheme[#t] if @scheme[v] is an argb, @scheme[#f] otherwise.} + + +@defproc[(overlay-bitmap [dest argb?] + [dx exact-integer?] + [dy exact-integer?] + [img (is-a?/c bitmap%)] + [mask (is-a?/c bitmap%)]) + void?]{ + +Changes @scheme[argb], overlaying @scheme[img] with masking based on +@scheme[mask] at @math{(@scheme[dx], @scheme[dy])} from the top-left.} + + +@defproc[(build-bitmap [draw ((is-a?/c dc<%>) . -> . any)] + [width (integer-in 1 10000)] + [height (integer-in 1 10000)]) + (is-a?/c bitmap%)]{ + +Builds a bitmap of size @scheme[width] by @scheme[height], using the +procedure @scheme[draw] to render the bitmap content into the given +@scheme[dc<%>].} + + +@defproc[(flatten-bitmap [bitmap (is-a?/c bitmap%)]) (is-a?/c bitmap%)]{ + + Builds a new bitmap that flattens the original @scheme[bitmap] + with its mask (as determined by @xmethod[bitmap% + get-loaded-mask]), producing a bitmap that has no mask, and looks + the way that bitmap would draw (when drawn with the mask) onto a + white background.} + + +@defproc[(argb->cache-image-snip [argb argb?][dx real?][dy real?]) + (is-a?/c cache-image-snip%)]{ + + Builds a new @scheme[cache-image-snip%] based on the contents of + @scheme[argb], using @scheme[dx] and @scheme[dy] as the pinhole.} + + +@defproc[(argb->bitmap [argb argb?]) (is-a?/c bitmap%)]{ + + Builds a bitmap that draws the same way as @scheme[argb]; the alpha + pixels are put into the bitmap's @method[bitmap% get-loaded-mask] + bitmap.} + diff --git a/collects/mrlib/doc/common.ss b/collects/mrlib/doc/common.ss new file mode 100644 index 00000000..a733b1d0 --- /dev/null +++ b/collects/mrlib/doc/common.ss @@ -0,0 +1,13 @@ +#lang scheme/base + +(require scribble/manual + (for-label scheme/base + scheme/contract + scheme/class + scheme/gui/base)) + +(provide (all-from-out scribble/manual) + (for-label (all-from-out scheme/base + scheme/contract + scheme/class + scheme/gui/base))) diff --git a/collects/mrlib/doc/gif.scrbl b/collects/mrlib/doc/gif.scrbl new file mode 100644 index 00000000..9ae89e02 --- /dev/null +++ b/collects/mrlib/doc/gif.scrbl @@ -0,0 +1,50 @@ +#lang scribble/doc +@(require "common.ss" + (for-label mrlib/gif + file/gif)) + +@title{GIF and Animated GFI Writing} + +@defmodule[mrlib/gif] + + +@defproc[(write-gif [bitmap (or/c (is-a?/c bitmap%) + (-> (is-a?/c bitmap%)))] + [filename path-string]) + void?]{ + +Writes the given @scheme[bitmap] to @scheme[filename] as a GIF image, +where @scheme[bitmap] is either an instance of @scheme[bitmap%] or a +thunk (to be called just once) that generates such an object. If the +bitmap uses more than 256 colors, it is automatically quantized using +a simple algorithm; see @scheme[quantize]. If the bitmap has a mask +bitmap via @method[bitmap% get-loaded-mask], it is used to determine +transparent pixels in the generated GIF image.} + +@defproc[(write-animated-gif [bitmaps (listof (or/c (is-a?/c bitmap%) + (-> (is-a?/c bitmap%))))] + [delay-csec (integer-in 0 #xFFFFFFFF)] + [filename path-string] + [#:one-at-a-time? one-at-a-time? any/c #f]) + void?]{ + +Writes the bitmaps in @scheme[bitmap-list] to @scheme[filename] as an +animated GIF. The @scheme[bitmap-list] list can contain a mixture of +@scheme[bitmap%] objects and thunks (each called just once) that +produce @scheme[bitmap%] objects. The @scheme[delay-csec] argument is +the amount of time in 1/100s of a second to wait between transitions. + +If @scheme[one-at-a-time?] is @scheme[#f], then the content of all +images is collected and quantized at once, to produce a single +colortable; a drawback to this approach is that it uses more memory, +and it allows less color variation among animation frames. Even when +@scheme[one-at-a-time?] is @scheme[#f], the result of each thunk in +@scheme[bitmap-list] is converted to a byte-string one at a time +(which helps avoid bitmap-count limits under Windows). + +If @scheme[one-at-a-time?] is true, then the bitmaps are quantized and +written to the file one at a time; that is, for each thunk in +@scheme[bitmap-list], its result is written and discarded before +another thunk is called. A drawback to this approach is that a +separate colortable is written for each frame in the animation, which +can make the resulting file large.} diff --git a/collects/mrlib/doc/graph/common.ss b/collects/mrlib/doc/graph/common.ss new file mode 100644 index 00000000..94dac0ff --- /dev/null +++ b/collects/mrlib/doc/graph/common.ss @@ -0,0 +1,8 @@ +#lang scheme/base + +(require "../common.ss" + (for-label mrlib/graph)) + +(provide (all-from-out "../common.ss") + (for-label (all-from-out mrlib/graph))) + diff --git a/collects/mrlib/doc/graph/graph-pasteboard-intf.scrbl b/collects/mrlib/doc/graph/graph-pasteboard-intf.scrbl new file mode 100644 index 00000000..71ead5d6 --- /dev/null +++ b/collects/mrlib/doc/graph/graph-pasteboard-intf.scrbl @@ -0,0 +1,47 @@ +#lang scribble/doc +@(require "common.ss") + +@definterface/title[graph-pasteboard<%> ()]{ + + +@defmethod[(get-arrowhead-params) + (values number number number)]{ + +Returns the current settings for the arrowhead's drawing. +} + + +@defmethod[(on-mouse-over-snips [lst (listof (is-a?/c snip%))]) + void?]{ + +This method is called when the mouse passes over any snips +in the editor. It is only called when the list of snips +under the editor changes (ie, if the mouse moves, but +remains over the same list of snips, the method is not +called). Also, this method is called with the empty list if +the mouse leaves the pasteboard.} + + +@defmethod[(set-arrowhead-params [angle-width real?] + [short-side real?] + [long-size real?]) + void?]{ + +Sets drawing parameters for the arrowhead. The first is the +angle of the arrowhead's point, in radians. The second is +the length of the outside line of the arrowhead and the last +is the distance from the arrowhead's point to the place where +the arrowhead comes together.} + + +@defmethod[(set-draw-arrow-heads? [draw-arrow-heads? any/c]) + void?]{ + +Sets a boolean controlling whether or not arrow heads are +drawn on the edges between nodes. + +This setting does not affect self-links---only links between two +different nodes. + +}} + diff --git a/collects/mrlib/doc/graph/graph-pasteboard-mixin.scrbl b/collects/mrlib/doc/graph/graph-pasteboard-mixin.scrbl new file mode 100644 index 00000000..d74956f9 --- /dev/null +++ b/collects/mrlib/doc/graph/graph-pasteboard-mixin.scrbl @@ -0,0 +1,7 @@ +#lang scribble/doc +@(require "common.ss") + +@defmixin/title[graph-pasteboard-mixin (pasteboard%) (graph-pasteboard<%>)]{ + +This mixin overrides many methods to draw lines between +@scheme[graph-snip<%>] that it contains.} diff --git a/collects/mrlib/doc/graph/graph-snip-intf.scrbl b/collects/mrlib/doc/graph/graph-snip-intf.scrbl new file mode 100644 index 00000000..ef630047 --- /dev/null +++ b/collects/mrlib/doc/graph/graph-snip-intf.scrbl @@ -0,0 +1,63 @@ +#lang scribble/doc +@(require "common.ss") + +@definterface/title[graph-snip<%> ()]{ + + + +@defmethod[(add-child [child (is-a?/c graph-snip<%>)]) + void?]{ + + Adds a child of this snip. Instead of calling this method, + consider using the @scheme[add-links] function. + +} + +@defmethod*[([(add-parent [parent (is-a?/c graph-snip<%>)]) + void?] + [(add-parent [parent (is-a?/c graph-snip<%>)] + [mouse-over-pen (or/c false/c (is-a?/c pen%))] + [mouse-off-pen (or/c false/c (is-a?/c pen%))] + [mouse-over-brush (or/c false/c (is-a?/c brush%))] + [mouse-off-brush (or/c false/c (is-a?/c brush%))]) + void?])]{ + + Adds a parent of this snip. Instead of calling this + method, consider using the @scheme[add-links] function. + +} + +@defmethod[(get-children) + (listof snip%)]{ + +returns a list of snips that implement +@scheme[graph-snip<%>]. Each of these snips will have a line +drawn from it, pointing at this snip. + +} + + +@defmethod[(get-parents) + (listof graph-snip<%>)]{ + +Returns a list of snips that implement @scheme[graph-snip<%>]. Each +of these snips will have a line drawn to it, starting from +this snip. +} + + +@defmethod[(remove-child [child (is-a?/c graph-snip<%>)]) + void?]{ + + Removes a child snip from this snip. Be sure to remove + this snip as a parent from the argument, too. +} + + +@defmethod[(remove-parent [parent (is-a?/c graph-snip<%>)]) + void?]{ + + Removes a parent snip from this snip. Be sure to remove this + snip as a child from the argument, too. + +}} diff --git a/collects/mrlib/doc/graph/graph-snip-mixin.scrbl b/collects/mrlib/doc/graph/graph-snip-mixin.scrbl new file mode 100644 index 00000000..b6a72dde --- /dev/null +++ b/collects/mrlib/doc/graph/graph-snip-mixin.scrbl @@ -0,0 +1,5 @@ +#lang scribble/doc +@(require "common.ss") + +@defmixin/title[graph-snip-mixin (snip%) (graph-snip<%>)]{ +} diff --git a/collects/mrlib/doc/graph/graph.scrbl b/collects/mrlib/doc/graph/graph.scrbl new file mode 100644 index 00000000..ecb08768 --- /dev/null +++ b/collects/mrlib/doc/graph/graph.scrbl @@ -0,0 +1,76 @@ +#lang scribble/doc +@(require "common.ss" + (for-label mrlib/graph)) + +@title[#:style 'toc]{Graphs} + +@defmodule[mrlib/graph]{The @schememodname[mrlib/graph] library +provides a graph drawing toolkit built out of @scheme[pasteboard%]s.} + +@local-table-of-contents[] + +@include-section["graph-pasteboard-intf.scrbl"] +@include-section["graph-pasteboard-mixin.scrbl"] +@include-section["graph-snip-intf.scrbl"] +@include-section["graph-snip-mixin.scrbl"] + +@section{Graph Functions} + +@defproc*[([(add-links [parent (is-a?/c graph-snip<%>)] + [child (is-a?/c graph-snip<%>)]) + void?] + [(add-links [parent (is-a?/c graph-snip<%>)] + [child (is-a?/c graph-snip<%>)]) + void?] + [(add-links [parent (is-a?/c graph-snip<%>)] + [child (is-a?/c graph-snip<%>)] + [dark-pen (or/c (is-a?/c pen) false/c)] + [light-pen (or/c (is-a?/c pen) false/c)] + [dark-brush (or/c (is-a?/c brush%) false/c)] + [light-brush (or/c (is-a?/c brush%) false/c)] + [label (or/c string? false/c) #f]) + void?] + [(add-links [parent (is-a?/c graph-snip<%>)] + [child (is-a?/c graph-snip<%>)] + [dark-pen (or/c (is-a?/c pen) false/c)] + [light-pen (or/c (is-a?/c pen) false/c)] + [dark-brush (or/c (is-a?/c brush%) false/c)] + [light-brush (or/c (is-a?/c brush%) false/c)] + [dx real?] + [dy real?] + [label (or/c string? false/c) #f]) + void?])]{ + +Connects a parent snip to a child snip within a pasteboard. + +The default @scheme[dark-pen]/@scheme[dark-brush] and +@scheme[light-pen]/@scheme[light-brush] are blue and purple, +respectively. The @scheme[dark-pen] and @scheme[dark-brush] are used +when the mouse cursor is over the snip (or a child or parent), and the +@scheme[light-pen] and @scheme[light-brush] are used when the mouse +cursor is not over the snip. The brush is used to draw inside the +arrow head and the pen is used to draw the border of the arrowhead and +the line connecting the two snips. + +if @scheme[label] is provided and not @scheme[#f], it is used as a +label on the edge. + +When @scheme[dx] and @scheme[dy] are provided, the are offsets for the +head and the tail of the arrow. Otherwise, @scheme[0] offsets are +used.} + +@defproc[(add-links/text-colors [parent (is-a?/c graph-snip<%>)] + [child (is-a?/c graph-snip<%>)] + [dark-pen (or/c (is-a?/c pen) false/c)] + [light-pen (or/c (is-a?/c pen) false/c)] + [dark-brush (or/c (is-a?/c brush%) false/c)] + [light-brush (or/c (is-a?/c brush%) false/c)] + [dark-text (or/c (is-a?/c color%) false/c)] + [light-text (or/c (is-a?/c color) false/c)] + [dx real?] + [dy real?] + [label (or/c string? false/c)]) + void?]{ + +Like @scheme[add-links], but with extra @scheme[dark-text] and +@scheme[light-text] arguments to set the colors of the label.} diff --git a/collects/mrlib/doc/include-bitmap.scrbl b/collects/mrlib/doc/include-bitmap.scrbl new file mode 100644 index 00000000..873c7e30 --- /dev/null +++ b/collects/mrlib/doc/include-bitmap.scrbl @@ -0,0 +1,33 @@ +#lang scribble/doc +@(require "common.ss" + (for-label mrlib/include-bitmap + scheme/runtime-path + scheme/include)) + +@title{Include Bitmap} + +@defmodule[mrlib/include-bitmap]{The @scheme[include-bitmap] form +takes a filename containing a bitmap and ``inlines'' the bitmap into +the program.} + +Historically, the advantage of inlining the bitmap is that a +stand-alone executable can be created that contains the bitmap and +does not refer to the original image file. The +@scheme[define-runtime-path] form, however, now provides a better +alternative. + +@defform*[[(include-bitmap path-spec) + (include-bitmap path-spec type-expr)]]{ + + +The @scheme[path-spec] is the same as for @scheme[include] form. The +@scheme[type-expr] should produce @scheme['unknown], +@scheme['unknown/mask], etc., as for @scheme[bitmap%], and the default +is @scheme['unknown/mask].} + + +@defform*[[(include-bitmap/relative-to source path-spec) + (include-bitmap/relative-to source path-spec [type-expr])]]{ + +Analogous to @scheme[include-at/relative-to], though only a source is +needed (no context).} diff --git a/collects/mrlib/doc/info.ss b/collects/mrlib/doc/info.ss new file mode 100644 index 00000000..7cf6a42b --- /dev/null +++ b/collects/mrlib/doc/info.ss @@ -0,0 +1,3 @@ +(module info setup/infotab + (define name "MrLib documentation") + (define scribblings '(("mrlib.scrbl" (multi-page))))) diff --git a/collects/mrlib/doc/interactive-value-port.scrbl b/collects/mrlib/doc/interactive-value-port.scrbl new file mode 100644 index 00000000..a4548c8c --- /dev/null +++ b/collects/mrlib/doc/interactive-value-port.scrbl @@ -0,0 +1,42 @@ +#lang scribble/doc +@(require "common.ss" + (for-label mrlib/interactive-value-port + scheme/pretty)) + +@title{Interactive Value Port} + +@defmodule[mrlib/interactive-value-port] + + +@defproc[(set-interactive-display-handler [port output-port?]) void?]{ + +Sets @scheme[port]'s display handler (via +@scheme[port-display-handler]) so that when it encounters these +values: + +@itemize{ + + @item{exact, real, non-integral numbers} + + @item{syntax objects} + +} + +it uses @scheme[write-special] to send snips to the port, +instead of those values. Otherwise, it behaves like the +default handler. + +To show values embedded in lists and other compound object, it uses +@scheme[pretty-print].} + + +@defproc[(set-interactive-write-handler [port output-port?]) void?]{ + +Like @scheme[set-interactive-display-handler], but sets the +@scheme[port-write-handler].} + + +@defproc[(set-interactive-print-handler [port output-port?]) void?]{ + +Like @scheme[set-interactive-display-handler], but sets the +@scheme[port-print-handler].} diff --git a/collects/mrlib/doc/mrlib.scrbl b/collects/mrlib/doc/mrlib.scrbl new file mode 100644 index 00000000..a32fe32c --- /dev/null +++ b/collects/mrlib/doc/mrlib.scrbl @@ -0,0 +1,24 @@ +#lang scribble/doc +@(require "common.ss") + +@title{Extra PLT GUI Libraries} + +@table-of-contents[] + +@include-section["aligned-pasteboard/aligned-pasteboard.scrbl"] +@include-section["bitmap-label.scrbl"] +@include-section["cache-image-snip.scrbl"] +@include-section["interactive-value-port.scrbl"] +@include-section["gif.scrbl"] +@include-section["graph/graph.scrbl"] +@include-section["include-bitmap.scrbl"] +@include-section["name-message.scrbl"] +@include-section["path-dialog.scrbl"] +@include-section["plot.scrbl"] + +@section{Acknowledgments} + +Contributors to this set of libraries include Mike MacHenry. + +@index-section[] + diff --git a/collects/mrlib/doc/name-message.scrbl b/collects/mrlib/doc/name-message.scrbl new file mode 100644 index 00000000..efa17860 --- /dev/null +++ b/collects/mrlib/doc/name-message.scrbl @@ -0,0 +1,111 @@ +#lang scribble/doc +@(require "common.ss" + (for-label mrlib/name-message)) + +@title{Name Message} + +@defmodule[mrlib/name-message] + +@defclass[name-message% canvas% ()]{ + +A @scheme[name-message%] control displays a filename that the user can +click to show the filename's path and select one of the enclosing +directories. Override the @method[name-message% on-choose-directory] +method to handle the user's selection. + + +@defconstructor/auto-super[()]{ + +Passes all arguments to @scheme[super-init].} + + +@defmethod[(on-choose-directory [dir path-string?]) + void?]{ + +Called when one of the popup menu items is chosen. The argument is a +represents the selected directory.} + + +@defmethod[#:mode override + (on-event [event (is-a?/c mouse-event%)]) + void?]{ + +Handles the click by popping up a menu or message.} + + +@defmethod[#:mode override + (on-paint) + void?]{ + +Draws the control's current message.} + + +@defmethod[(set-hidden? [hidden? any/c]) + void?]{ +Calling this method with @scheme[#f] causes the name message +to become invisible and to stop responding to mouse movements. + +Calling it with a true value restores its visibility and +makes it respond to mouse movements again.} + + +@defmethod[(set-message [file-name? any/c] + [msg path-string?]) + void?]{ + +Sets the label for the control. + +If @scheme[file-name?] is @scheme[#t], @scheme[msg] is treated like a + pathname, and a click on the name-message control creates a popup + menu to open a get-file dialog. + +If @scheme[file-name?] is @scheme[#f], @scheme[msg] is treated as a +label string. Clicking on the name-message control pops up a dialog +saying that there is no file name until the file is saved.} + +} + +@; ---------------------------------------------------------------------- + + +@defproc[(calc-button-min-sizes [dc (is-a?/c dc<%>)] + [str string?]) + (values real? real?)]{ + +Calculates the minimum width and height of a button label (when drawn +with @scheme[draw-button-label]). Returns two values: the width +and height. The @scheme[dc] argument is used for sizing.} + + +@defproc[(draw-button-label [dc (is-a?/c dc<%>)] + [str string?] + [dx real?] + [dy real?] + [width real?] + [height real?] + [mouse-over? boolean?] + [grabbed? boolean?] + [font (is-a?/c font%)] + [background (or/c (is-a?/c color%) string? false/c)]) + void?]{ + +Draws a button label like the one for the @onscreen{(define ...)} and +filename buttons in the top-left corner of the DrScheme frame. Use +this function to draw similar buttons. + +The basic idea is to create a canvas object whose on-paint method is +overridden to call this function. The @scheme[dc] argument should be +canvas's drawing context, and @scheme[str] should be the string to +display on the button. The @scheme[width] and @scheme[height] +arguments should be the width and height of the button, and the +@scheme[dx] and @scheme[dy] arguments specify an offset into +@scheme[dc] for the button. The @scheme[mouse-over?] argument should +be true when the mouse is over the button, and the @scheme[grabbed?] +argument should be true when the button has been pressed. The +@scheme[font] and @scheme[background] arguments supply the font to use +in drawing (possibly @scheme[normal-control-font]) and the background +color to paint (if any). + +See @scheme[calc-button-min-sizes] for help calculating the min sizes +of the button.} + diff --git a/collects/mrlib/doc/path-dialog.scrbl b/collects/mrlib/doc/path-dialog.scrbl new file mode 100644 index 00000000..8439e536 --- /dev/null +++ b/collects/mrlib/doc/path-dialog.scrbl @@ -0,0 +1,127 @@ +#lang scribble/doc +@(require "common.ss" + (for-label mrlib/path-dialog)) + +@title{Path Dialog} + +@defmodule[mrlib/path-dialog] + +@defclass[path-dialog% dialog% ()]{ + +The @scheme[path-dialog%] class implements a platform-independent +file/directory dialog. The dialog is the same as the dialog under X +for the @scheme[get-file], @scheme[put-file], @scheme[get-directory], +and @scheme[get-file-list] procedures, but considerable extra +functionality is available through the @scheme[path-dialog%] class. + + +@defconstructor[([label (or/c label-string? false/c) #f] + [message (or/c label-string? false/c) #f] + [parent (or/c (is-a?/c frame%) (is-a?/c dialog%) false/c) #f] + [directory (or/c path-string? false/c) #f] + [filename (or/c path-string? false/c) #f] + [put? any/c #f] + [dir? any/c #f] + [existing? any/c (not put?)] + [new? any/c #f] + [multi? any/c #f] + [can-mkdir? any/c put?] + [filters (or/c (listof (list string? string?)) + (one-of/c #f #t)) + #t] + [show-file? (or/c (path? . -> . any) false/c) #f] + [show-dir? (or/c (path? . -> . any) false/c) #f] + [ok? (or/c (path? . -> . any) false/c) #f] + [guard (or/c (path? . -> . any) false/c) #f])]{ + +The @scheme[label] argument is the dialog's title string. If +@scheme[label] is @scheme[#f], the default is based on other field +values. + +The @scheme[message] argument is a prompt message to show at the top +of the dialog. If it is @scheme[#f], no prompt line. + +The @scheme[parent] argument is the parent frame or dialog, if any, +for this dialog. + +The @scheme[directory] argument specifies the dialog's initial +directory. If it is @scheme[#f], the initial directory is the last +directory that was used by the user (or the current directory on first +use). + +The @scheme[filename] argument provides an initial filename text, if +any. + +If @scheme[put?] is true, the dialog operates in choose-file-to-write +mode (and warn the user if choosing an existing name). + +If @scheme[dir?] is true, the dialog operates in directory-choice +mode. + +If @scheme[existing?] is true, the use must choose an existing file. + +If @scheme[new?] is true, the user must choose a non-existant +path. Providing both @scheme[new?] and @scheme[existing?] as true +triggers an exception. + +If @scheme[multi?] is true, the dialog allows selection of multiple +paths. + +If @scheme[can-mkdir?] is true, the dialog includes a button for the +user to create a new directory. + +The @scheme[filters] argument is one of: + +@itemize{ + + @item{@scheme[(list (list _filter-name _filter-glob) ...)] --- a + list of pattern names (e.g., @scheme["Scheme Files"]) and glob + patterns (e.g., @scheme["*.scm;*.ss"]). Any list, including an + empty list, enables a filter box for the user to enter glob + patterns, and the given list of choices is available in a + combo-box drop-down menu. Glob patterns are the usual Unix ones + (see @scheme[glob->regexp]), and a semicolon can be used to allow + multiple patterns.} + + @item{@scheme[#f] --- no patterns and no filter input box.} + + @item{@scheme[#t] --- use a generic @scheme["All"] filter, which is + @scheme["*.*"] under Windows and @scheme["*"] on other + platforms.} + +} + +The @scheme[show-file?] predicate is used to filter file paths that +are shown in the dialog. The predicate is applied to the file name as +a string while the current-directory parameter is set. This predicate +is intended to be a lightweight filter for choosing which names to +display. + +The @scheme[show-dir?] predicate is similar, but for directories +instead of files. + +The @scheme[ok?] predicate is used in a similar fashion to the +@scheme[show-file?] and @scheme[show-dir?] predicate, but it is used +to determine whether the @onscreen{OK} button should be enabled when a +file or directory is selected (so it need not be as lightweight as the +other predicates). + +The @scheme[guard] procedure is a generic verifier for the dialog's +final result, as produced by the @method[path-dialog% run] method. It +receives the result that is about to be returned (which can be a list +in a multi-selection dialog), and can return a different value (any +value) instead. If it throws an exception, an error dialog is shown, +and the dialog interaction continues (so it can be used to verify +results without dismissing the dialog). This procedure can also raise +@|void-const|, in which case the dialog remains without an error +message.} + + +@defmethod[(run) any/c]{ + +Shows the dialog and returns the selected result. If a @scheme[guard] +procedure is not supplied when the dialog is created, then the result +is either a path or a list of paths (and the latter only when +@scheme[_multi?] is true when the dialog is created). If a +@scheme[_guard] procedure is supplied, its result determines the result +of this method.}} diff --git a/collects/mrlib/doc/plot.scrbl b/collects/mrlib/doc/plot.scrbl new file mode 100644 index 00000000..504a52eb --- /dev/null +++ b/collects/mrlib/doc/plot.scrbl @@ -0,0 +1,46 @@ +#lang scribble/doc +@(require "common.ss" + (for-label mrlib/plot)) + +@title{Plot} + +@defmodule[mrlib/plot]{The @schememodname[mrlib/plot] library provides +a simple tool for plotting data values to a device context.} + +@defstruct[data-set ([points (listof (is-a?/c point%))] + [connected? any/c] + [pen (is-a?/c pen%)] + [min-x real?] + [max-x real?] + [min-y real?] + [max-y real?])]{ + +The @scheme[points] field contains the data values to plot, and +@scheme[connected?] indicates whether the points are connected by a +line. The @scheme[pen] field provides a pen for plotting +points/lines. The remaining fields determine the plotting area within +a drawing context.} + +@defstruct[plot-setup ([axis-label-font (is-a?/c font%)] + [axis-number-font (is-a?/c font%)] + [axis-pen (is-a?/c pen)] + [grid? any/c] + [grid-pen (is-a?/c pen)] + [x-axis-marking (listof real?)] + [y-axis-marking (listof real?)] + [x-axis-label string?] + [y-axis-label string?])]{ + +Configures a plot. The @scheme[grid?] field determines whether to draw +a grid at axis markings, and the @scheme[x-axis-marking] and +@scheme[y-axis-marking] lists supply locations for marks on each +axis. The other fields are self-explanatory.} + +@defproc[(plot [dc (is-a?/c dc<%>)] + [data (listof data-set?)] + [setup plot-setup?]) + void?]{ + +Draws the @scheme[data-set]s in @scheme[data] into the given +@scheme[dc]. Uses drawing-context coordinates in @scheme[data-set]s +that will accommodate all of the data sets.}