On this page:
15.1 GUI Widgets
15.1.1 Locked Text Fields
locked-text-field-mixin
set-value
locked-text-field%
locked-combo-field%
15.1.2 Union GUIs
union-container-mixin
choose
union-pane%
union-panel%
15.2 Dr Scheme Plugins
language-level@
language-level^
make-language-level
simple-language-level%
language-level-render-mixin
language-level-capability-mixin
language-level-no-executable-mixin
language-level-eval-as-module-mixin
language-level-macro-stepper-mixin
language-level-check-expect-mixin
language-level-metadata-mixin
15.3 Slideshow Presentations
15.3.1 Text Formatting
with-size
with-scale
big
small
with-font
with-style
bold
italic
subscript
superscript
caps
15.3.2 Pict Colors
color
red
orange
yellow
green
blue
purple
black
brown
gray
white
cyan
magenta
light
dark
color/ c
15.3.3 Pict Manipulation
fill
15.3.3.1 Conditional Manipulations
show
hide
strike
shade
15.3.3.2 Conditional Combinations
pict-if
pict-cond
pict-case
pict-match
pict-combine
with-pict-combine
15.3.4 Staged Slides
staged
stage
stage-name
slide/ staged
15.3.5 Tables
tabular
15.3.6 Multiple Columns
two-columns
mini-slide
columns
column
column-size
Version: 5.1.3

15 Graphics

15.1 GUI Widgets

 (require (planet cce/scheme:7:5/gui))

The bindings in this module are not included in (planet cce/scheme:7:5/scheme).

15.1.1 Locked Text Fields

These classes and mixins provide text and combo field controls that cannot be directly edited by the user, but may be updated by other controls.

locked-text-field-mixin : (class? . -> . class?)
  argument extends/implements: text-field%
This mixin updates text field classes to prevent user edits, but allow programmatic update of the text value. It also sets the undo history length to a default of 0, as user undo commands are disabled and the history takes up space.

(new locked-text-field-mixin [[undo-history undo-history]])
  (is-a?/c locked-text-field-mixin)
  undo-history : exact-nonnegative-integer? = 0
The mixin adds the undo-history initialization argument to control the length of the undo history. It defaults to 0 to save space, but may be set higher.

The mixin inherits all the initialization arguments of its parent class; it does not override any of them.

(send a-locked-text-field set-value str)  void?
  str : string?
Overrides set-value in text-field%.
Unlocks the text field’s nested editor, calls the parent class’s set-value, and then re-locks the editor.

15.1.2 Union GUIs

union-container-mixin : (class? . -> . class?)
  argument extends/implements: area-container<%>
This mixin modifies a container class to display only one of its child areas at a time, but to leave room to switch to any of them.

(send an-union-container choose child)  void?
  child : (is-a?/c subwindow<%>)
This method changes which of the container’s children is displayed. The chosen child is shown and the previous choice is hidden.

union-pane% : class?

  superclass: pane%

union-panel% : class?

  superclass: panel%

15.2 DrScheme Plugins

 (require (planet cce/scheme:7:5/drscheme))

The bindings in this module are not included in (planet cce/scheme:7:5/scheme).

This unit imports drscheme:tool^ and exports language-level^.

language-level^ : signature

(make-language-level name 
  path 
  mixin ... 
  [#:number number 
  #:hierarchy hierarchy 
  #:summary summary 
  #:url url 
  #:reader reader]) 
  (object-provides/c drscheme:language:language<%>)
  name : string?
  path : module-path?
  mixin : (-> class? class?)
  number : integer? = ...
  hierarchy : (listof (cons/c string? integer?)) = ...
  summary : string? = name
  url : (or/c string? #f) = #f
  reader : (->* [] [any/c input-port?] (or/c syntax? eof-object?))
   = read-syntax
Constructs a language level as an instance of drscheme:language:language<%> with the given name based on the language defined by the module at path. Applies (drscheme:language:get-default-mixin) and the given mixins to simple-language-level% to construct the class, and uses the optional keyword arguments to fill in the language’s description and reader.

(language-level-render-mixin to-sexp 
  show-void?) 
  (mixin-provides/c [drscheme:language:language<%>] [])
  to-sexp : (-> any/c any/c)
  show-void? : boolean?
Produces a mixin that overrides render-value/format to apply to-sexp to each value before printing it, and to skip void? values (pre-transformation) if show-void? is #f.

Produces a mixin that augments capability-value to look up each key in dict, producing the corresponding value if the key is found and deferring to inner otherwise.

Overrides create-executable to print an error message in a dialog box.

language-level-eval-as-module-mixin : 
(mixin-provides/c [drscheme:language:language<%>
                   drscheme:language:module-based-language<%>]
                  [])
Overrides front-end/complete-program to wrap terms from the definition in a module based on the language level’s definition module. This duplicates the behavior of the HtDP teaching languages, for instance.

language-level-macro-stepper-mixin : 
(mixin-provides/c [drscheme:language:language<%>
                   language/macro-stepper<%>]
                  [])
This mixin enables the macro stepper for its language level.

This mixin overrides on-execute to set up the check-expect test engine to a language level similarly to the HtDP teaching languages.

(language-level-metadata-mixin reader-module 
  meta-lines 
  meta->settings 
  settings->meta) 
  (mixin-provides/c [drscheme:language:language<%>] [])
  reader-module : module-path?
  meta-lines : exact-nonnegative-integer?
  meta->settings : (-> string? any/c any/c)
  settings->meta : (-> symbol? any/c string?)
This mixin constructs a language level that stores metadata in saved files allowing DrScheme to automatically switch back to this language level upon opening them. It overrides get-reader-module, get-metadata, metadata->settings, and get-metadata-lines.

The resulting language level uses the reader from reader-module, and is recognized in files that start with a reader directive for that module path within the first meta-lines lines. Metadata about the language’s settings is marshalled between a string and a usable value (based on a default value) by meta->settings, and between a usable value for a current module (with a symbolic name) by settings->meta.

15.3 Slideshow Presentations

 (require (planet cce/scheme:7:5/slideshow))

The bindings in this module are not included in (planet cce/scheme:7:5/scheme).

15.3.1 Text Formatting

(with-size size expr)
Sets current-font-size to size while running expr.

(with-scale scale expr)
Multiplies current-font-size by scale while running expr.

(big text)
(small text)
Scale current-font-size by 3/2 or 2/3, respectively, while running text.

(with-font font expr)
Sets current-main-font to font while running expr.

(with-style style expr)
Adds style to current-main-font (via cons) while running expr.

(bold text)
(italic text)
(subscript text)
(superscript text)
(caps text)
Adds the attributes for bold, italic, superscript, subscript, or small caps text, respectively, to current-main-font while running text.

15.3.2 Pict Colors

(color c p)  pict?
  c : color/c
  p : pict?
Applies color c to picture p. Equivalent to (colorize p c).

(red pict)  pict?
  pict : pict?
(orange pict)  pict?
  pict : pict?
(yellow pict)  pict?
  pict : pict?
(green pict)  pict?
  pict : pict?
(blue pict)  pict?
  pict : pict?
(purple pict)  pict?
  pict : pict?
(black pict)  pict?
  pict : pict?
(brown pict)  pict?
  pict : pict?
(gray pict)  pict?
  pict : pict?
(white pict)  pict?
  pict : pict?
(cyan pict)  pict?
  pict : pict?
(magenta pict)  pict?
  pict : pict?
These functions apply appropriate colors to picture p.

(light color)  color/c
  color : color/c
(dark color)  color/c
  color : color/c
These functions produce ligher or darker versions of a color.

This contract recognizes color strings, color% instances, and RGB color lists.

15.3.3 Pict Manipulation

(fill pict width height)  pict?
  pict : pict?
  width : (or/c real? #f)
  height : (or/c real? #f)
Extends pict’s bounding box to a minimum width and/or height, placing the original picture in the middle of the space.

15.3.3.1 Conditional Manipulations

These pict transformers all take boolean arguments that determine whether to transform the pict or leave it unchanged. These transformations can be useful for staged slides, as the resulting pict always has the same size and shape, and its contents always appear at the same position, but changing the boolean argument between slides can control when the transformation occurs.

(show pict [show?])  pict?
  pict : pict?
  show? : truth/c = #t
(hide pict [hide?])  pict?
  pict : pict?
  hide? : truth/c = #t
These functions conditionally show or hide an image, essentially choosing between pict and (ghost pict). The only difference between the two is the default behavior and the opposite meaning of the show? and hide? booleans. Both functions are provided for mnemonic purposes.

(strike pict [strike?])  pict?
  pict : pict?
  strike? : truth/c = #t
Displays a strikethrough image by putting a line through the middle of pict if strike? is true; produces pict unchanged otherwise.

(shade pict [shade? #:ratio ratio])  pict?
  pict : pict?
  shade? : truth/c = #t
  ratio : (real-in 0 1) = 1/2
Shades pict to show with ratio of its normal opacity; if ratio is 1 or shade? is #f, shows pict unchanged.

15.3.3.2 Conditional Combinations

These pict control flow operators decide which pict of several to use. All branches are evaluated; the resulting pict is a combination of the pict chosen by normal conditional flow with ghost applied to all the other picts. The result is a picture large enough to accomodate each alternative, but showing only the chosen one. This is useful for staged slides, as the pict chosen may change with each slide but its size and position will not.

(pict-if maybe-combine test-expr then-expr else-expr)
 
maybe-combine = 
  | #:combine combine-expr
Chooses either then-expr or else-expr based on test-expr, similarly to if. Combines the chosen, visible image with the other, invisible image using combine-expr, defaulting to pict-combine.

(pict-cond maybe-combine [test-expr pict-expr] ...)
 
maybe-combine = 
  | #:combine combine-expr
Chooses a pict-expr based on the first successful test-expr, similarly to cond. Combines the chosen, visible image with the other, invisible images using combine-expr, defaulting to pict-combine.

(pict-case test-expr maybe-combine [literals pict-expr] ...)
 
maybe-combine = 
  | #:combine combine-expr
Chooses a pict-expr based on test-expr and each list of literals, similarly to case. Combines the chosen, visible image with the other, invisible images using combine-expr, defaulting to pict-combine.

(pict-match test-expr maybe-combine [pattern pict-expr] ...)
 
maybe-combine = 
  | #:combine combine-expr
Chooses a pict-expr based on test-expr and each pattern, similarly to match. Combines the chosen, visible image with the other, invisible images using combine-expr, defaulting to pict-combine.

This syntax parameter determines the default pict combining form used by the above macros. It defaults to lbl-superimpose.

(with-pict-combine combine-id body ...)
Sets pict-combine to refer to combine-id within each of the body terms, which are spliced into the containing context.

15.3.4 Staged Slides

(staged [name ...] body ...)
Executes the body terms once for each stage name. The terms may include expressions and mutually recursive definitions. Within the body, each name is bound to a number from 1 to the number of stages in order. Furthermore, during execution stage is bound to the number of the current stage and stage-name is bound to a symbol representing the name of the current stage. By comparing stage to the numeric value of each name, or stage-name to quoted symbols of the form 'name, the user may compute based on the progression of the stages.

These keywords are bound during the execution of staged and should not be used otherwise.

(slide/staged [name ...] arg ...)
Creates a staged slide. Equivalent to (staged [name ...] (slide arg ...)).

Within a staged slide, the boolean arguments to hide, show, strike, and shade can be used to determine in which stages to perform a transformation. The macros pict-if, pict-cond, pict-case, and pict-match may also be used to create images which change naturally between stages.

15.3.5 Tables

(tabular row    
  ...    
  [#:gap gap    
  #:hgap hgap    
  #:vgap vgap    
  #:align align    
  #:halign halign    
  #:valign valign])  pict?
  row : (listof (or/c string? pict?))
  gap : natural-number/c = gap-size
  hgap : natural-number/c = gap
  vgap : natural-number/c = gap
  align : (->* [] [] #:rest (listof pict?) pict?)
   = lbl-superimpose
  halign : (->* [] [] #:rest (listof pict?) pict?) = align
  valign : (->* [] [] #:rest (listof pict?) pict?) = align
Constructs a table containing the given rows, all of which must be of the same length. Applies t to each string in a row to construct a pict. The hgap, vgap, halign, and valign are used to determine the horizontal and vertical gaps and alignments as in table (except that every row and column is uniform).

15.3.6 Multiple Columns

(two-columns one two)
Constructs a two-column pict using one and two as the two columns. Sets current-para-width appropriately in each column.

(mini-slide pict ...)  pict?
  pict : pict?
Appends each pict vertically with space between them, similarly to the slide function.

(columns pict ...)  pict?
  pict : pict?
Combines each pict horizontally, aligned at the top, with space in between.

(column width body ...)
Sets current-para-width to width during execution of the body expressions.

(column-size n [r])  real?
  n : exact-positive-integer?
  r : real? = (/ n)
Computes the width of one column out of n that takes up a ratio of r of the available space (according to current-para-width).