\documentclass[10pt,a4paper]{article}
\usepackage{url}
\usepackage{a4wide}
\usepackage[utf8]{inputenc}
\usepackage{tex2page}
\usepackage{ifpdf}

\texonly
\ifpdf
\usepackage[pdftex,colorlinks,backref,pagebackref]{hyperref}
\hypersetup {
  pdftitle={Concurrent Programming --- Toy-Window API-Referenz}
  pdfauthor={Eric Knauel, Michael Speber}
  colorlinks=true
  \usepackage{thumbpdf} 
}
\fi
\endtexonly

\begin{document}

\title{Toy-Window API Reference}

\maketitle

\noindent This document describes the API of the ConcurrentML toy
window system~\cite{Reppy1999} for Scheme~48 and Scsh.

\section{Module \texttt{toy-geometry}}

\begin{itemize}
  
\item\texttt{(make-point x y) => point} 
  
  returns a value that represents a point or vector.  The origin of
  coordinate plane is located in the upper left corner with the y-axis
  growing down.
  
\item\texttt{(point+ point1 point2) => point} 

  adds two points by adding the corresponding coordinates.
  
\item\texttt{(point+ point1 point2) => point} 

  subtracts two points by subsctracting the corresponding coordinates.
  
\item\texttt{(point<? point1 point2) => boolean} 
  
  compares two points by comparing the corresponding coordinates.
  
\item\texttt{(make-rectangle x y width height) => rectangle}

  returns a value representing a rectangle.
  
\item\texttt{(rectangle-origin rectangle) => point} 
  
  returns the origin of a rectangle.
  
\item\texttt{(rectangle-x rectangle) => int} 

  returns the x-axis coordinate of the rectangle's origin.
  
\item\texttt{(rectangle-y rectangle) => int} 

  returns the y-axis coordinate of the rectangle's origin.
  
\item\texttt{(rectangle-width rectangle) => int} 

  returns a rectangle's width.
  
\item\texttt{(rectangle-height rectangle) => int} 

  returns a rectangle's height.
  
\item\texttt{(point-in-rectangle? point rectangle) => boolean}
  
  checks whether \texttt{point} is located inside \texttt{rectangle}.
  
\item\texttt{(rectangle+ rectangle point) => rectangle} 
  
  returns a rectangle that is displaced by \texttt{point}.
  
\item\texttt{(rectangle- rectangle point) => rectangle} 
  
  returns a rectangle that is displaced by \texttt{-point}.
  
\item\texttt{(rectangle-within rectangle1 rectangle2) =>
    rectangle} 

  fits a rectangle with the size of \texttt{rectangle2} into
  \texttt{rectangle1} and returns the rectangle.
\end{itemize}

\section{Module \texttt{toy-display-system}}

\subsection{Bitmaps}

Drawing functions take a \texttt{raster-op} as argument which
specifies how the color values of the source and destination pixels
are combined.  The following symbols are valid operations:
\texttt{copy}, \texttt{xor}, \texttt{or}, \texttt{and}, \texttt{clear}
and \texttt{set}.

\begin{itemize}
  
\item\texttt{(make-bitmap bitmap rectangle) => bitmap} 
  
  creates a new bitmap with the dimensions of \texttt{rectangle} and
  displays it.  The new bitmap is a child of \texttt{bitmap} and lies
  on top of \texttt{bitmap}'s siblings.
  
\item\texttt{(bitmap-to-front! bitmap)} 

  moves \texttt{bitmap} to the top among its siblings.
  
\item\texttt{(bitmap-to-back! bitmap)} 

  moves \texttt{bitmap} to the back among its siblings.
  
\item\texttt{(bitmap-move! bitmap point)} 
  
  moves \texttt{bitmap} with respect to \texttt{bitmap}'s parent to
  \texttt{point}. As a side effect, \texttt{bitmap} becomes the top
  bitmap among its siblings.

\item\texttt{(bitmap-delete! bitmap)} 

  deletes the Bitmap \texttt{bitmap}.
  
\item\texttt{(bitmap-clear bitmap)} 

  deletes the contents of \texttt{bitmap}.
  
\item\texttt{(bitmap-draw-line bitmap raster-op point1
    point2)} 

  draws a line between \texttt{point1} and \texttt{point2}.
  
\item\texttt{(bitmap-draw-rectangle bitmap raster-op rectangle)}

  draws a rectangle inside \texttt{bitmap} that is displaced by one
  pixel to right and below (with respect to \texttt{rectangle}).
  
\item\texttt{(bitmap-fill-rectangle bitmap raster-op texture
    rectangle)} 

  fills \texttt{rectangle} with the texture \texttt{texture}.  At the
  moment there is only one texture: \texttt{texture-solid}.
  
\item\texttt{(bitmap-bitblt bitmap1 raster-op point1 bitmap2
    rectangle1}) 
  
  copies rectangle \texttt{rectangle1} from \texttt{bitmap2} to
  \texttt{point1} in \texttt{bitmap1}.
  
\item\texttt{(bitmap-draw-text bitmap raster-op point text)}
  
  draws the string \texttt{text} at position \texttt{point}.
  \texttt{Point} is the left edge on the baseline of the text.
  
\item\texttt{(bitmap-text-size bitmap text) => width height
    ascent} 

  calculates the extents of \texttt{text}.  \texttt{Ascent} is the
  height of \texttt{text} above the baseline.

\end{itemize}

\subsection{Initializing Toy-Window}

\begin{itemize}
  
\item\texttt{(make-display label width height) => bitmap
    mouse-channel keyboard-channel} 
  
  initializes the display system, create a new X11-window with the
  dimensions \texttt{width} and \texttt{height} and \texttt{label} as
  its title.  It returns a bitmap that fills the whole window and
  synchronous channels for mouse and keyboard events.
\end{itemize}

\subsection{mouse messages}

\begin{itemize}
  
\item\texttt{(mouse-message-up? message) => boolean} 

  returns false if the mouse button is pressed, true otherwise.
  
\item\texttt{(mouse-message-down? message) => boolean} 
  
  returns true if the mouse button in pressed, false otherwise.
  
\item\texttt{(mouse-message-position message) => point} 

  returns the position of the mouse cursor.
  
\item\texttt{(mouse-message-translate point message) =>
    mouse-message} 
  
  calculates the mouse cursor position of \texttt{message} relative to
  \texttt{point}.

\end{itemize}

\subsection{keyboard message}

\begin{itemize}
\item\texttt{(key-message-down? message) => boolean}

  returns wether the key has been pressed or not.

\item\texttt{(key-message-keycode message) => integer}

  returns the X11 key code of the key.

\item\texttt{(key-message-string message) => string}

  returns the string corresponding to the key or an empty string for a
  control key.
\end{itemize}


\section{Module \texttt{toy-window-system}}

\begin{itemize}
  
\item\texttt{(make-widget-env bitmap mouse-channel keyboard-channel
    control-in-channel\\ control-out-channel) => widget-env}
  
  returns a widget-environment.  All channels are synchronous, except
  for \texttt{control-out-channel} which is an asynchronous channel.
  
\item\texttt{(make-vanilla-widget-env bitmap) => widget-env}

  returns a widget-environment with fresh channels.
  
\item\texttt{(widget-env-bitmap widget-env) => bitmap} 
  
  returns the bitmap of a widget-environment.
  
\item\texttt{(widget-env-mouse-channel widget-env) => channel}

  returns the mouse channel of \texttt{widget-env}.
  
\item\texttt{(widget-env-keyboard-channel widget-env) => channel}

  returns the keyboard channel of \texttt{widget-env}.
  
\item\texttt{(widget-env-control-in-channel widget-env) =>
    channel} 

  returns the control in channel of \texttt{widget-env}.
  
\item\texttt{(widget-env-control-out-channel widget-env) =>
    async-channel} 
 
  returns the control out channel of \texttt{widget-env}, which is an
  asynchronous channel.
  
\item\texttt{(make-channel-sink channel)} 

  creates a sink for the synchronous \texttt{channel} which consumes
  all values sent to \texttt{channel}.
  
\item\texttt{(realize-widget bitmap rectangle realization-proc) =>
    value}
  
  returns a fresh widget-environment that is located inside the parent
  bitmap \texttt{bitmap} at \texttt{rectangle}. Then, it calls
  \texttt{realization-proc} with the new widget-environment.  The
  return value of \texttt{realize-widget} is the return value of the
  call to \texttt{realization-proc}.
  
\item\texttt{(make-window-system label width height) => widget-env}
  
  initializes the window system and calls \texttt{make-display}.
  Creates and returns an initial widget-environment that fills the
  whole window.
\end{itemize}
    
\section{Module \texttt{toy-button}}

\begin{itemize}
  
\item\texttt{(make-button label thunk widget-env) =>
    widget-env} 
  
  draws a button with label \texttt{label} inside \texttt{widget-env}.
  Pressing the button calls \texttt{thunk}.
 
\end{itemize}

\section{Module \texttt{toy-frame}}

\begin{itemize}
  
\item\texttt{(make-frame realize widget-env) => frame value}
  
  draws a frame inside \texttt{widget-env} and puts the widget created
  by calling \texttt{realize} inside this frame.  \texttt{Realize} is
  called with a new widget-environment.  All channels connected to
  \texttt{widget-env} are connected to the new widget-environment.
  \texttt{Make-frame} returns the a representation for the frame and
  the return value of \texttt{realize}.
\end{itemize}

\bibliographystyle{plain}
\bibliography{toy-window}

\end{document}
