toy-window-en.tex 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. \documentclass[10pt,a4paper]{article}
  2. \usepackage{url}
  3. \usepackage{a4wide}
  4. \usepackage[utf8]{inputenc}
  5. \usepackage{tex2page}
  6. \usepackage{ifpdf}
  7. \texonly
  8. \ifpdf
  9. \usepackage[pdftex,colorlinks,backref,pagebackref]{hyperref}
  10. \hypersetup {
  11. pdftitle={Concurrent Programming --- Toy-Window API-Referenz}
  12. pdfauthor={Eric Knauel, Michael Speber}
  13. colorlinks=true
  14. \usepackage{thumbpdf}
  15. }
  16. \fi
  17. \endtexonly
  18. \begin{document}
  19. \title{Toy-Window API Reference}
  20. \maketitle
  21. \noindent This document describes the API of the ConcurrentML toy
  22. window system~\cite{Reppy1999} for Scheme~48 and Scsh.
  23. \section{Module \texttt{toy-geometry}}
  24. \begin{itemize}
  25. \item\texttt{(make-point x y) => point}
  26. returns a value that represents a point or vector. The origin of
  27. coordinate plane is located in the upper left corner with the y-axis
  28. growing down.
  29. \item\texttt{(point+ point1 point2) => point}
  30. adds two points by adding the corresponding coordinates.
  31. \item\texttt{(point+ point1 point2) => point}
  32. subtracts two points by subsctracting the corresponding coordinates.
  33. \item\texttt{(point<? point1 point2) => boolean}
  34. compares two points by comparing the corresponding coordinates.
  35. \item\texttt{(make-rectangle x y width height) => rectangle}
  36. returns a value representing a rectangle.
  37. \item\texttt{(rectangle-origin rectangle) => point}
  38. returns the origin of a rectangle.
  39. \item\texttt{(rectangle-x rectangle) => int}
  40. returns the x-axis coordinate of the rectangle's origin.
  41. \item\texttt{(rectangle-y rectangle) => int}
  42. returns the y-axis coordinate of the rectangle's origin.
  43. \item\texttt{(rectangle-width rectangle) => int}
  44. returns a rectangle's width.
  45. \item\texttt{(rectangle-height rectangle) => int}
  46. returns a rectangle's height.
  47. \item\texttt{(point-in-rectangle? point rectangle) => boolean}
  48. checks whether \texttt{point} is located inside \texttt{rectangle}.
  49. \item\texttt{(rectangle+ rectangle point) => rectangle}
  50. returns a rectangle that is displaced by \texttt{point}.
  51. \item\texttt{(rectangle- rectangle point) => rectangle}
  52. returns a rectangle that is displaced by \texttt{-point}.
  53. \item\texttt{(rectangle-within rectangle1 rectangle2) =>
  54. rectangle}
  55. fits a rectangle with the size of \texttt{rectangle2} into
  56. \texttt{rectangle1} and returns the rectangle.
  57. \end{itemize}
  58. \section{Module \texttt{toy-display-system}}
  59. \subsection{Bitmaps}
  60. Drawing functions take a \texttt{raster-op} as argument which
  61. specifies how the color values of the source and destination pixels
  62. are combined. The following symbols are valid operations:
  63. \texttt{copy}, \texttt{xor}, \texttt{or}, \texttt{and}, \texttt{clear}
  64. and \texttt{set}.
  65. \begin{itemize}
  66. \item\texttt{(make-bitmap bitmap rectangle) => bitmap}
  67. creates a new bitmap with the dimensions of \texttt{rectangle} and
  68. displays it. The new bitmap is a child of \texttt{bitmap} and lies
  69. on top of \texttt{bitmap}'s siblings.
  70. \item\texttt{(bitmap-to-front! bitmap)}
  71. moves \texttt{bitmap} to the top among its siblings.
  72. \item\texttt{(bitmap-to-back! bitmap)}
  73. moves \texttt{bitmap} to the back among its siblings.
  74. \item\texttt{(bitmap-move! bitmap point)}
  75. moves \texttt{bitmap} with respect to \texttt{bitmap}'s parent to
  76. \texttt{point}. As a side effect, \texttt{bitmap} becomes the top
  77. bitmap among its siblings.
  78. \item\texttt{(bitmap-delete! bitmap)}
  79. deletes the Bitmap \texttt{bitmap}.
  80. \item\texttt{(bitmap-clear bitmap)}
  81. deletes the contents of \texttt{bitmap}.
  82. \item\texttt{(bitmap-draw-line bitmap raster-op point1
  83. point2)}
  84. draws a line between \texttt{point1} and \texttt{point2}.
  85. \item\texttt{(bitmap-draw-rectangle bitmap raster-op rectangle)}
  86. draws a rectangle inside \texttt{bitmap} that is displaced by one
  87. pixel to right and below (with respect to \texttt{rectangle}).
  88. \item\texttt{(bitmap-fill-rectangle bitmap raster-op texture
  89. rectangle)}
  90. fills \texttt{rectangle} with the texture \texttt{texture}. At the
  91. moment there is only one texture: \texttt{texture-solid}.
  92. \item\texttt{(bitmap-bitblt bitmap1 raster-op point1 bitmap2
  93. rectangle1})
  94. copies rectangle \texttt{rectangle1} from \texttt{bitmap2} to
  95. \texttt{point1} in \texttt{bitmap1}.
  96. \item\texttt{(bitmap-draw-text bitmap raster-op point text)}
  97. draws the string \texttt{text} at position \texttt{point}.
  98. \texttt{Point} is the left edge on the baseline of the text.
  99. \item\texttt{(bitmap-text-size bitmap text) => width height
  100. ascent}
  101. calculates the extents of \texttt{text}. \texttt{Ascent} is the
  102. height of \texttt{text} above the baseline.
  103. \end{itemize}
  104. \subsection{Initializing Toy-Window}
  105. \begin{itemize}
  106. \item\texttt{(make-display label width height) => bitmap
  107. mouse-channel keyboard-channel}
  108. initializes the display system, create a new X11-window with the
  109. dimensions \texttt{width} and \texttt{height} and \texttt{label} as
  110. its title. It returns a bitmap that fills the whole window and
  111. synchronous channels for mouse and keyboard events.
  112. \end{itemize}
  113. \subsection{mouse messages}
  114. \begin{itemize}
  115. \item\texttt{(mouse-message-up? message) => boolean}
  116. returns false if the mouse button is pressed, true otherwise.
  117. \item\texttt{(mouse-message-down? message) => boolean}
  118. returns true if the mouse button in pressed, false otherwise.
  119. \item\texttt{(mouse-message-position message) => point}
  120. returns the position of the mouse cursor.
  121. \item\texttt{(mouse-message-translate point message) =>
  122. mouse-message}
  123. calculates the mouse cursor position of \texttt{message} relative to
  124. \texttt{point}.
  125. \end{itemize}
  126. \subsection{keyboard message}
  127. \begin{itemize}
  128. \item\texttt{(key-message-down? message) => boolean}
  129. returns wether the key has been pressed or not.
  130. \item\texttt{(key-message-keycode message) => integer}
  131. returns the X11 key code of the key.
  132. \item\texttt{(key-message-string message) => string}
  133. returns the string corresponding to the key or an empty string for a
  134. control key.
  135. \end{itemize}
  136. \section{Module \texttt{toy-window-system}}
  137. \begin{itemize}
  138. \item\texttt{(make-widget-env bitmap mouse-channel keyboard-channel
  139. control-in-channel\\ control-out-channel) => widget-env}
  140. returns a widget-environment. All channels are synchronous, except
  141. for \texttt{control-out-channel} which is an asynchronous channel.
  142. \item\texttt{(make-vanilla-widget-env bitmap) => widget-env}
  143. returns a widget-environment with fresh channels.
  144. \item\texttt{(widget-env-bitmap widget-env) => bitmap}
  145. returns the bitmap of a widget-environment.
  146. \item\texttt{(widget-env-mouse-channel widget-env) => channel}
  147. returns the mouse channel of \texttt{widget-env}.
  148. \item\texttt{(widget-env-keyboard-channel widget-env) => channel}
  149. returns the keyboard channel of \texttt{widget-env}.
  150. \item\texttt{(widget-env-control-in-channel widget-env) =>
  151. channel}
  152. returns the control in channel of \texttt{widget-env}.
  153. \item\texttt{(widget-env-control-out-channel widget-env) =>
  154. async-channel}
  155. returns the control out channel of \texttt{widget-env}, which is an
  156. asynchronous channel.
  157. \item\texttt{(make-channel-sink channel)}
  158. creates a sink for the synchronous \texttt{channel} which consumes
  159. all values sent to \texttt{channel}.
  160. \item\texttt{(realize-widget bitmap rectangle realization-proc) =>
  161. value}
  162. returns a fresh widget-environment that is located inside the parent
  163. bitmap \texttt{bitmap} at \texttt{rectangle}. Then, it calls
  164. \texttt{realization-proc} with the new widget-environment. The
  165. return value of \texttt{realize-widget} is the return value of the
  166. call to \texttt{realization-proc}.
  167. \item\texttt{(make-window-system label width height) => widget-env}
  168. initializes the window system and calls \texttt{make-display}.
  169. Creates and returns an initial widget-environment that fills the
  170. whole window.
  171. \end{itemize}
  172. \section{Module \texttt{toy-button}}
  173. \begin{itemize}
  174. \item\texttt{(make-button label thunk widget-env) =>
  175. widget-env}
  176. draws a button with label \texttt{label} inside \texttt{widget-env}.
  177. Pressing the button calls \texttt{thunk}.
  178. \end{itemize}
  179. \section{Module \texttt{toy-frame}}
  180. \begin{itemize}
  181. \item\texttt{(make-frame realize widget-env) => frame value}
  182. draws a frame inside \texttt{widget-env} and puts the widget created
  183. by calling \texttt{realize} inside this frame. \texttt{Realize} is
  184. called with a new widget-environment. All channels connected to
  185. \texttt{widget-env} are connected to the new widget-environment.
  186. \texttt{Make-frame} returns the a representation for the frame and
  187. the return value of \texttt{realize}.
  188. \end{itemize}
  189. \bibliographystyle{plain}
  190. \bibliography{toy-window}
  191. \end{document}