1995-03-28 13:35:14 +00:00
|
|
|
\chapter{Standard Windowing Interface}
|
|
|
|
|
|
|
|
The modules in this chapter are available only on those systems where
|
|
|
|
the STDWIN library is available. STDWIN runs on \UNIX{} under X11 and
|
|
|
|
on the Macintosh. See CWI report CS-R8817.
|
|
|
|
|
|
|
|
\strong{Warning:} Using STDWIN is not recommended for new
|
|
|
|
applications. It has never been ported to Microsoft Windows or
|
|
|
|
Windows NT, and for X11 or the Macintosh it lacks important
|
|
|
|
functionality --- in particular, it has no tools for the construction
|
|
|
|
of dialogs. For most platforms, alternative, native solutions exist
|
|
|
|
(though none are currently documented in this manual): Tkinter for
|
|
|
|
\UNIX{} under X11, native Xt with Motif or Athena widgets for \UNIX{}
|
|
|
|
under X11, Win32 for Windows and Windows NT, and a collection of
|
|
|
|
native toolkit interfaces for the Macintosh.
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-08-10 19:42:37 +00:00
|
|
|
\section{\module{stdwin} ---
|
1998-11-25 22:38:24 +00:00
|
|
|
Platform-independent GUI System}
|
1998-07-23 17:59:49 +00:00
|
|
|
\declaremodule{builtin}{stdwin}
|
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\modulesynopsis{Older GUI system for X11 and Macintosh}
|
1998-07-23 17:59:49 +00:00
|
|
|
|
1994-01-02 01:22:07 +00:00
|
|
|
|
|
|
|
This module defines several new object types and functions that
|
1995-03-28 13:35:14 +00:00
|
|
|
provide access to the functionality of STDWIN.
|
1995-03-17 16:07:09 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
On \UNIX{} running X11, it can only be used if the \envvar{DISPLAY}
|
1995-03-17 16:07:09 +00:00
|
|
|
environment variable is set or an explicit \samp{-display
|
|
|
|
\var{displayname}} argument is passed to the Python interpreter.
|
1994-01-02 01:22:07 +00:00
|
|
|
|
|
|
|
Functions have names that usually resemble their C STDWIN counterparts
|
|
|
|
with the initial `w' dropped.
|
|
|
|
Points are represented by pairs of integers; rectangles
|
|
|
|
by pairs of points.
|
|
|
|
For a complete description of STDWIN please refer to the documentation
|
|
|
|
of STDWIN for C programmers (aforementioned CWI report).
|
|
|
|
|
1998-04-04 07:23:21 +00:00
|
|
|
\subsection{Functions Defined in Module \module{stdwin}}
|
1995-03-20 12:59:56 +00:00
|
|
|
\nodename{STDWIN Functions}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
The following functions are defined in the \module{stdwin} module:
|
1994-01-02 01:22:07 +00:00
|
|
|
|
|
|
|
\begin{funcdesc}{open}{title}
|
|
|
|
Open a new window whose initial title is given by the string argument.
|
|
|
|
Return a window object; window object methods are described below.%
|
|
|
|
\footnote{The Python version of STDWIN does not support draw procedures; all
|
|
|
|
drawing requests are reported as draw events.}
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getevent}{}
|
|
|
|
Wait for and return the next event.
|
|
|
|
An event is returned as a triple: the first element is the event
|
|
|
|
type, a small integer; the second element is the window object to which
|
|
|
|
the event applies, or
|
|
|
|
\code{None}
|
|
|
|
if it applies to no window in particular;
|
|
|
|
the third element is type-dependent.
|
|
|
|
Names for event types and command codes are defined in the standard
|
1998-11-25 22:38:24 +00:00
|
|
|
module \module{stdwinevent}.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{pollevent}{}
|
|
|
|
Return the next event, if one is immediately available.
|
|
|
|
If no event is available, return \code{()}.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getactive}{}
|
|
|
|
Return the window that is currently active, or \code{None} if no
|
|
|
|
window is currently active. (This can be emulated by monitoring
|
|
|
|
WE_ACTIVATE and WE_DEACTIVATE events.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{listfontnames}{pattern}
|
|
|
|
Return the list of font names in the system that match the pattern (a
|
|
|
|
string). The pattern should normally be \code{'*'}; returns all
|
|
|
|
available fonts. If the underlying window system is X11, other
|
|
|
|
patterns follow the standard X11 font selection syntax (as used e.g.
|
|
|
|
in resource definitions), i.e. the wildcard character \code{'*'}
|
|
|
|
matches any sequence of characters (including none) and \code{'?'}
|
|
|
|
matches any single character.
|
1995-03-17 16:07:09 +00:00
|
|
|
On the Macintosh this function currently returns an empty list.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 06:33:25 +00:00
|
|
|
\begin{funcdesc}{setdefscrollbars}{hflag, vflag}
|
1994-01-02 01:22:07 +00:00
|
|
|
Set the flags controlling whether subsequently opened windows will
|
|
|
|
have horizontal and/or vertical scroll bars.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 06:33:25 +00:00
|
|
|
\begin{funcdesc}{setdefwinpos}{h, v}
|
1994-01-02 01:22:07 +00:00
|
|
|
Set the default window position for windows opened subsequently.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 06:33:25 +00:00
|
|
|
\begin{funcdesc}{setdefwinsize}{width, height}
|
1994-01-02 01:22:07 +00:00
|
|
|
Set the default window size for windows opened subsequently.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getdefscrollbars}{}
|
|
|
|
Return the flags controlling whether subsequently opened windows will
|
|
|
|
have horizontal and/or vertical scroll bars.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getdefwinpos}{}
|
|
|
|
Return the default window position for windows opened subsequently.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getdefwinsize}{}
|
|
|
|
Return the default window size for windows opened subsequently.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getscrsize}{}
|
|
|
|
Return the screen size in pixels.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getscrmm}{}
|
|
|
|
Return the screen size in millimeters.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{fetchcolor}{colorname}
|
|
|
|
Return the pixel value corresponding to the given color name.
|
|
|
|
Return the default foreground color for unknown color names.
|
1994-08-08 12:30:22 +00:00
|
|
|
Hint: the following code tests whether you are on a machine that
|
1994-01-02 01:22:07 +00:00
|
|
|
supports more than two colors:
|
1998-02-13 06:58:54 +00:00
|
|
|
\begin{verbatim}
|
1994-01-02 01:22:07 +00:00
|
|
|
if stdwin.fetchcolor('black') <> \
|
|
|
|
stdwin.fetchcolor('red') <> \
|
|
|
|
stdwin.fetchcolor('white'):
|
|
|
|
print 'color machine'
|
|
|
|
else:
|
|
|
|
print 'monochrome machine'
|
1998-02-13 06:58:54 +00:00
|
|
|
\end{verbatim}
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{setfgcolor}{pixel}
|
|
|
|
Set the default foreground color.
|
|
|
|
This will become the default foreground color of windows opened
|
|
|
|
subsequently, including dialogs.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{setbgcolor}{pixel}
|
|
|
|
Set the default background color.
|
|
|
|
This will become the default background color of windows opened
|
|
|
|
subsequently, including dialogs.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getfgcolor}{}
|
|
|
|
Return the pixel value of the current default foreground color.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getbgcolor}{}
|
|
|
|
Return the pixel value of the current default background color.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{setfont}{fontname}
|
|
|
|
Set the current default font.
|
|
|
|
This will become the default font for windows opened subsequently,
|
1998-11-25 22:38:24 +00:00
|
|
|
and is also used by the text measuring functions \function{textwidth()},
|
|
|
|
\function{textbreak()}, \function{lineheight()} and
|
|
|
|
\function{baseline()} below. This accepts two more optional
|
|
|
|
parameters, size and style: Size is the font size (in `points').
|
1994-01-02 01:22:07 +00:00
|
|
|
Style is a single character specifying the style, as follows:
|
|
|
|
\code{'b'} = bold,
|
|
|
|
\code{'i'} = italic,
|
|
|
|
\code{'o'} = bold + italic,
|
|
|
|
\code{'u'} = underline;
|
|
|
|
default style is roman.
|
|
|
|
Size and style are ignored under X11 but used on the Macintosh.
|
|
|
|
(Sorry for all this complexity --- a more uniform interface is being designed.)
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{menucreate}{title}
|
|
|
|
Create a menu object referring to a global menu (a menu that appears in
|
|
|
|
all windows).
|
|
|
|
Methods of menu objects are described below.
|
|
|
|
Note: normally, menus are created locally; see the window method
|
1998-11-25 22:38:24 +00:00
|
|
|
\method{menucreate()} below.
|
1994-01-02 01:22:07 +00:00
|
|
|
\strong{Warning:} the menu only appears in a window as long as the object
|
|
|
|
returned by this call exists.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 06:33:25 +00:00
|
|
|
\begin{funcdesc}{newbitmap}{width, height}
|
1994-01-02 01:22:07 +00:00
|
|
|
Create a new bitmap object of the given dimensions.
|
|
|
|
Methods of bitmap objects are described below.
|
1995-03-17 16:07:09 +00:00
|
|
|
Not available on the Macintosh.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{fleep}{}
|
|
|
|
Cause a beep or bell (or perhaps a `visual bell' or flash, hence the
|
|
|
|
name).
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{message}{string}
|
|
|
|
Display a dialog box containing the string.
|
|
|
|
The user must click OK before the function returns.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 06:33:25 +00:00
|
|
|
\begin{funcdesc}{askync}{prompt, default}
|
1994-01-02 01:22:07 +00:00
|
|
|
Display a dialog that prompts the user to answer a question with yes or
|
1998-11-25 22:38:24 +00:00
|
|
|
no. Return 0 for no, 1 for yes. If the user hits the Return key, the
|
|
|
|
default (which must be 0 or 1) is returned. If the user cancels the
|
|
|
|
dialog, \exception{KeyboardInterrupt} is raised.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 06:33:25 +00:00
|
|
|
\begin{funcdesc}{askstr}{prompt, default}
|
1994-01-02 01:22:07 +00:00
|
|
|
Display a dialog that prompts the user for a string.
|
|
|
|
If the user hits the Return key, the default string is returned.
|
1998-11-25 22:38:24 +00:00
|
|
|
If the user cancels the dialog, \exception{KeyboardInterrupt} is
|
|
|
|
raised.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 06:33:25 +00:00
|
|
|
\begin{funcdesc}{askfile}{prompt, default, new}
|
1998-11-25 22:38:24 +00:00
|
|
|
Ask the user to specify a filename. If \var{new} is zero it must be
|
|
|
|
an existing file; otherwise, it must be a new file. If the user
|
|
|
|
cancels the dialog, \exception{KeyboardInterrupt} is raised.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 06:33:25 +00:00
|
|
|
\begin{funcdesc}{setcutbuffer}{i, string}
|
1998-11-25 22:38:24 +00:00
|
|
|
Store the string in the system's cut buffer number \var{i}, where it
|
|
|
|
can be found (for pasting) by other applications. On X11, there are 8
|
|
|
|
cut buffers (numbered 0..7). Cut buffer number 0 is the `clipboard'
|
|
|
|
on the Macintosh.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getcutbuffer}{i}
|
1998-11-25 22:38:24 +00:00
|
|
|
Return the contents of the system's cut buffer number \var{i}.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{rotatecutbuffers}{n}
|
1998-11-25 22:38:24 +00:00
|
|
|
On X11, rotate the 8 cut buffers by \var{n}. Ignored on the
|
|
|
|
Macintosh.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{getselection}{i}
|
1998-11-25 22:38:24 +00:00
|
|
|
Return X11 selection number \var{i.} Selections are not cut buffers.
|
|
|
|
Selection numbers are defined in module \module{stdwinevents}.
|
|
|
|
Selection \constant{WS_PRIMARY} is the \dfn{primary} selection (used
|
|
|
|
by \program{xterm}, for instance); selection \constant{WS_SECONDARY}
|
|
|
|
is the \dfn{secondary} selection; selection \constant{WS_CLIPBOARD} is
|
|
|
|
the \dfn{clipboard} selection (used by \program{xclipboard}). On the
|
|
|
|
Macintosh, this always returns an empty string.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{resetselection}{i}
|
1998-11-25 22:38:24 +00:00
|
|
|
Reset selection number \var{i}, if this process owns it. (See window
|
|
|
|
method \method{setselection()}).
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{baseline}{}
|
|
|
|
Return the baseline of the current font (defined by STDWIN as the
|
|
|
|
vertical distance between the baseline and the top of the
|
|
|
|
characters).
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{lineheight}{}
|
|
|
|
Return the total line height of the current font.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 06:33:25 +00:00
|
|
|
\begin{funcdesc}{textbreak}{str, width}
|
1994-01-02 01:22:07 +00:00
|
|
|
Return the number of characters of the string that fit into a space of
|
|
|
|
\var{width}
|
|
|
|
bits wide when drawn in the curent font.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{textwidth}{str}
|
|
|
|
Return the width in bits of the string when drawn in the current font.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{connectionnumber}{}
|
|
|
|
\funcline{fileno}{}
|
|
|
|
(X11 under \UNIX{} only) Return the ``connection number'' used by the
|
|
|
|
underlying X11 implementation. (This is normally the file number of
|
|
|
|
the socket.) Both functions return the same value;
|
1998-11-25 22:38:24 +00:00
|
|
|
\method{connectionnumber()} is named after the corresponding function in
|
|
|
|
X11 and STDWIN, while \method{fileno()} makes it possible to use the
|
|
|
|
\module{stdwin} module as a ``file'' object parameter to
|
|
|
|
\function{select.select()}. Note that if \constant{select()} implies that
|
|
|
|
input is possible on \module{stdwin}, this does not guarantee that an
|
1994-01-02 01:22:07 +00:00
|
|
|
event is ready --- it may be some internal communication going on
|
|
|
|
between the X server and the client library. Thus, you should call
|
1998-11-25 22:38:24 +00:00
|
|
|
\function{stdwin.pollevent()} until it returns \code{None} to check for
|
1994-01-02 01:22:07 +00:00
|
|
|
events if you don't want your program to block. Because of internal
|
1998-11-25 22:38:24 +00:00
|
|
|
buffering in X11, it is also possible that \function{stdwin.pollevent()}
|
|
|
|
returns an event while \function{select()} does not find \module{stdwin} to
|
1994-01-02 01:22:07 +00:00
|
|
|
be ready, so you should read any pending events with
|
1998-11-25 22:38:24 +00:00
|
|
|
\function{stdwin.pollevent()} until it returns \code{None} before entering
|
|
|
|
a blocking \function{select()} call.
|
|
|
|
\withsubitem{(in module select)}{\ttindex{select()}}
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1995-03-17 16:07:09 +00:00
|
|
|
\subsection{Window Objects}
|
1996-12-13 22:04:31 +00:00
|
|
|
\nodename{STDWIN Window Objects}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
Window objects are created by \function{stdwin.open()}. They are closed
|
|
|
|
by their \method{close()} method or when they are garbage-collected.
|
1994-01-02 01:22:07 +00:00
|
|
|
Window objects have the following methods:
|
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{begindrawing}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Return a drawing object, whose methods (described below) allow drawing
|
|
|
|
in the window.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{change}{rect}
|
1994-01-02 01:22:07 +00:00
|
|
|
Invalidate the given rectangle; this may cause a draw event.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{gettitle}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Returns the window's title string.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{getdocsize}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
\begin{sloppypar}
|
|
|
|
Return a pair of integers giving the size of the document as set by
|
1998-11-25 22:38:24 +00:00
|
|
|
\method{setdocsize()}.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{sloppypar}
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{getorigin}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Return a pair of integers giving the origin of the window with respect
|
|
|
|
to the document.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{gettitle}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Return the window's title string.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{getwinsize}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Return a pair of integers giving the size of the window.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{getwinpos}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Return a pair of integers giving the position of the window's upper
|
|
|
|
left corner (relative to the upper left corner of the screen).
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{menucreate}{title}
|
1994-01-02 01:22:07 +00:00
|
|
|
Create a menu object referring to a local menu (a menu that appears
|
|
|
|
only in this window).
|
|
|
|
Methods of menu objects are described below.
|
1998-01-14 14:51:31 +00:00
|
|
|
\strong{Warning:} the menu only appears as long as the object
|
1994-01-02 01:22:07 +00:00
|
|
|
returned by this call exists.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{scroll}{rect, point}
|
1994-01-02 01:22:07 +00:00
|
|
|
Scroll the given rectangle by the vector given by the point.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{setdocsize}{point}
|
1994-01-02 01:22:07 +00:00
|
|
|
Set the size of the drawing document.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{setorigin}{point}
|
1994-01-02 01:22:07 +00:00
|
|
|
Move the origin of the window (its upper left corner)
|
|
|
|
to the given point in the document.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{setselection}{i, str}
|
|
|
|
Attempt to set X11 selection number \var{i} to the string \var{str}.
|
|
|
|
(See \module{stdwin} function \function{getselection()} for the
|
|
|
|
meaning of \var{i}.) Return true if it succeeds.
|
1994-01-02 01:22:07 +00:00
|
|
|
If succeeds, the window ``owns'' the selection until
|
1994-08-08 12:30:22 +00:00
|
|
|
(a) another application takes ownership of the selection; or
|
1994-01-02 01:22:07 +00:00
|
|
|
(b) the window is deleted; or
|
|
|
|
(c) the application clears ownership by calling
|
1998-11-25 22:38:24 +00:00
|
|
|
\function{stdwin.resetselection(\var{i})}. When another application
|
|
|
|
takes ownership of the selection, a \constant{WE_LOST_SEL} event is
|
|
|
|
received for no particular window and with the selection number as
|
|
|
|
detail. Ignored on the Macintosh.
|
|
|
|
\end{methoddesc}
|
|
|
|
|
|
|
|
\begin{methoddesc}[window]{settimer}{dsecs}
|
|
|
|
Schedule a timer event for the window in \code{\var{dsecs}/10}
|
1994-01-02 01:22:07 +00:00
|
|
|
seconds.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{settitle}{title}
|
1994-01-02 01:22:07 +00:00
|
|
|
Set the window's title string.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{setwincursor}{name}
|
1994-01-02 01:22:07 +00:00
|
|
|
\begin{sloppypar}
|
1998-11-25 22:38:24 +00:00
|
|
|
Set the window cursor to a cursor of the given name. It raises
|
|
|
|
\exception{RuntimeError} if no cursor of the given name exists.
|
1994-01-02 01:22:07 +00:00
|
|
|
Suitable names include
|
|
|
|
\code{'ibeam'},
|
|
|
|
\code{'arrow'},
|
|
|
|
\code{'cross'},
|
|
|
|
\code{'watch'}
|
|
|
|
and
|
|
|
|
\code{'plus'}.
|
1998-08-14 17:05:17 +00:00
|
|
|
On X11, there are many more (see \code{<X11/cursorfont.h>}).
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{sloppypar}
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{setwinpos}{h, v}
|
1994-01-02 01:22:07 +00:00
|
|
|
Set the the position of the window's upper left corner (relative to
|
|
|
|
the upper left corner of the screen).
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{setwinsize}{width, height}
|
1994-01-02 01:22:07 +00:00
|
|
|
Set the window's size.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{show}{rect}
|
1994-01-02 01:22:07 +00:00
|
|
|
Try to ensure that the given rectangle of the document is visible in
|
|
|
|
the window.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{textcreate}{rect}
|
1994-01-02 01:22:07 +00:00
|
|
|
Create a text-edit object in the document at the given rectangle.
|
|
|
|
Methods of text-edit objects are described below.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{setactive}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Attempt to make this window the active window. If successful, this
|
|
|
|
will generate a WE_ACTIVATE event (and a WE_DEACTIVATE event in case
|
|
|
|
another window in this application became inactive).
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[window]{close}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Discard the window object. It should not be used again.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1995-03-17 16:07:09 +00:00
|
|
|
\subsection{Drawing Objects}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
|
|
|
Drawing objects are created exclusively by the window method
|
1998-11-25 22:38:24 +00:00
|
|
|
\method{begindrawing()}. Only one drawing object can exist at any
|
|
|
|
given time; the drawing object must be deleted to finish drawing. No
|
|
|
|
drawing object may exist when \function{stdwin.getevent()} is called.
|
1994-01-02 01:22:07 +00:00
|
|
|
Drawing objects have the following methods:
|
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{box}{rect}
|
1994-01-02 01:22:07 +00:00
|
|
|
Draw a box just inside a rectangle.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{circle}{center, radius}
|
1994-01-02 01:22:07 +00:00
|
|
|
Draw a circle with given center point and radius.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{elarc}{center, (rh, rv), (a1, a2)}
|
1994-01-02 01:22:07 +00:00
|
|
|
Draw an elliptical arc with given center point.
|
|
|
|
\code{(\var{rh}, \var{rv})}
|
|
|
|
gives the half sizes of the horizontal and vertical radii.
|
|
|
|
\code{(\var{a1}, \var{a2})}
|
|
|
|
gives the angles (in degrees) of the begin and end points.
|
|
|
|
0 degrees is at 3 o'clock, 90 degrees is at 12 o'clock.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{erase}{rect}
|
1994-01-02 01:22:07 +00:00
|
|
|
Erase a rectangle.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{fillcircle}{center, radius}
|
1994-01-02 01:22:07 +00:00
|
|
|
Draw a filled circle with given center point and radius.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{fillelarc}{center, (rh, rv), (a1, a2)}
|
|
|
|
Draw a filled elliptical arc; arguments as for \method{elarc()}.
|
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{fillpoly}{points}
|
1994-01-02 01:22:07 +00:00
|
|
|
Draw a filled polygon given by a list (or tuple) of points.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{invert}{rect}
|
1994-01-02 01:22:07 +00:00
|
|
|
Invert a rectangle.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{line}{p1, p2}
|
1994-01-02 01:22:07 +00:00
|
|
|
Draw a line from point
|
|
|
|
\var{p1}
|
|
|
|
to
|
|
|
|
\var{p2}.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{paint}{rect}
|
1994-01-02 01:22:07 +00:00
|
|
|
Fill a rectangle.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{poly}{points}
|
1994-01-02 01:22:07 +00:00
|
|
|
Draw the lines connecting the given list (or tuple) of points.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{shade}{rect, percent}
|
1994-01-02 01:22:07 +00:00
|
|
|
Fill a rectangle with a shading pattern that is about
|
|
|
|
\var{percent}
|
|
|
|
percent filled.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{text}{p, str}
|
1994-01-02 01:22:07 +00:00
|
|
|
Draw a string starting at point p (the point specifies the
|
|
|
|
top left coordinate of the string).
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{xorcircle}{center, radius}
|
|
|
|
\funcline{xorelarc}{center, (rh, rv), (a1, a2)}
|
1998-03-17 06:33:25 +00:00
|
|
|
\funcline{xorline}{p1, p2}
|
1994-01-02 01:22:07 +00:00
|
|
|
\funcline{xorpoly}{points}
|
|
|
|
Draw a circle, an elliptical arc, a line or a polygon, respectively,
|
|
|
|
in XOR mode.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{setfgcolor}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
\funcline{setbgcolor}{}
|
|
|
|
\funcline{getfgcolor}{}
|
|
|
|
\funcline{getbgcolor}{}
|
|
|
|
These functions are similar to the corresponding functions described
|
1998-11-25 22:38:24 +00:00
|
|
|
above for the \module{stdwin}
|
1994-01-02 01:22:07 +00:00
|
|
|
module, but affect or return the colors currently used for drawing
|
|
|
|
instead of the global default colors.
|
|
|
|
When a drawing object is created, its colors are set to the window's
|
|
|
|
default colors, which are in turn initialized from the global default
|
|
|
|
colors when the window is created.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{setfont}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
\funcline{baseline}{}
|
|
|
|
\funcline{lineheight}{}
|
|
|
|
\funcline{textbreak}{}
|
|
|
|
\funcline{textwidth}{}
|
|
|
|
These functions are similar to the corresponding functions described
|
1998-11-25 22:38:24 +00:00
|
|
|
above for the \module{stdwin}
|
1994-01-02 01:22:07 +00:00
|
|
|
module, but affect or use the current drawing font instead of
|
|
|
|
the global default font.
|
|
|
|
When a drawing object is created, its font is set to the window's
|
|
|
|
default font, which is in turn initialized from the global default
|
|
|
|
font when the window is created.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{bitmap}{point, bitmap, mask}
|
1994-01-02 01:22:07 +00:00
|
|
|
Draw the \var{bitmap} with its top left corner at \var{point}.
|
|
|
|
If the optional \var{mask} argument is present, it should be either
|
|
|
|
the same object as \var{bitmap}, to draw only those bits that are set
|
|
|
|
in the bitmap, in the foreground color, or \code{None}, to draw all
|
|
|
|
bits (ones are drawn in the foreground color, zeros in the background
|
|
|
|
color).
|
1995-03-17 16:07:09 +00:00
|
|
|
Not available on the Macintosh.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{cliprect}{rect}
|
1994-01-02 01:22:07 +00:00
|
|
|
Set the ``clipping region'' to a rectangle.
|
|
|
|
The clipping region limits the effect of all drawing operations, until
|
|
|
|
it is changed again or until the drawing object is closed. When a
|
|
|
|
drawing object is created the clipping region is set to the entire
|
|
|
|
window. When an object to be drawn falls partly outside the clipping
|
|
|
|
region, the set of pixels drawn is the intersection of the clipping
|
|
|
|
region and the set of pixels that would be drawn by the same operation
|
|
|
|
in the absence of a clipping region.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{noclip}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Reset the clipping region to the entire window.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[drawing]{close}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
\funcline{enddrawing}{}
|
|
|
|
Discard the drawing object. It should not be used again.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1995-03-17 16:07:09 +00:00
|
|
|
\subsection{Menu Objects}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
|
|
|
A menu object represents a menu.
|
|
|
|
The menu is destroyed when the menu object is deleted.
|
|
|
|
The following methods are defined:
|
|
|
|
|
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[menu]{additem}{text, shortcut}
|
1994-01-02 01:22:07 +00:00
|
|
|
Add a menu item with given text.
|
|
|
|
The shortcut must be a string of length 1, or omitted (to specify no
|
|
|
|
shortcut).
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[menu]{setitem}{i, text}
|
|
|
|
Set the text of item number \var{i}.
|
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[menu]{enable}{i, flag}
|
|
|
|
Enable or disables item \var{i}.
|
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[menu]{check}{i, flag}
|
|
|
|
Set or clear the \dfn{check mark} for item \var{i}.
|
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[menu]{close}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Discard the menu object. It should not be used again.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1995-03-17 16:07:09 +00:00
|
|
|
\subsection{Bitmap Objects}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
|
|
|
A bitmap represents a rectangular array of bits.
|
|
|
|
The top left bit has coordinate (0, 0).
|
1998-11-25 22:38:24 +00:00
|
|
|
A bitmap can be drawn with the \method{bitmap()} method of a drawing object.
|
1995-03-17 16:07:09 +00:00
|
|
|
Bitmaps are currently not available on the Macintosh.
|
|
|
|
|
1994-01-02 01:22:07 +00:00
|
|
|
The following methods are defined:
|
|
|
|
|
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[bitmap]{getsize}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Return a tuple representing the width and height of the bitmap.
|
1998-11-25 22:38:24 +00:00
|
|
|
(This returns the values that have been passed to the
|
|
|
|
\function{newbitmap()} function.)
|
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[bitmap]{setbit}{point, bit}
|
1994-01-02 01:22:07 +00:00
|
|
|
Set the value of the bit indicated by \var{point} to \var{bit}.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[bitmap]{getbit}{point}
|
1994-01-02 01:22:07 +00:00
|
|
|
Return the value of the bit indicated by \var{point}.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[bitmap]{close}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Discard the bitmap object. It should not be used again.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1995-03-17 16:07:09 +00:00
|
|
|
\subsection{Text-edit Objects}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
|
|
|
A text-edit object represents a text-edit block.
|
1998-11-25 22:38:24 +00:00
|
|
|
For semantics, see the STDWIN documentation for \C{} programmers.
|
1994-01-02 01:22:07 +00:00
|
|
|
The following methods exist:
|
|
|
|
|
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[text-edit]{arrow}{code}
|
1994-01-02 01:22:07 +00:00
|
|
|
Pass an arrow event to the text-edit block.
|
1998-11-25 22:38:24 +00:00
|
|
|
The \var{code} must be one of \constant{WC_LEFT}, \constant{WC_RIGHT},
|
|
|
|
\constant{WC_UP} or \constant{WC_DOWN} (see module
|
|
|
|
\module{stdwinevents}).
|
|
|
|
\end{methoddesc}
|
|
|
|
|
|
|
|
\begin{methoddesc}[text-edit]{draw}{rect}
|
1994-01-02 01:22:07 +00:00
|
|
|
Pass a draw event to the text-edit block.
|
|
|
|
The rectangle specifies the redraw area.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[text-edit]{event}{type, window, detail}
|
1994-01-02 01:22:07 +00:00
|
|
|
Pass an event gotten from
|
1998-11-25 22:38:24 +00:00
|
|
|
\function{stdwin.getevent()}
|
1994-01-02 01:22:07 +00:00
|
|
|
to the text-edit block.
|
|
|
|
Return true if the event was handled.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[text-edit]{getfocus}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Return 2 integers representing the start and end positions of the
|
|
|
|
focus, usable as slice indices on the string returned by
|
1998-11-25 22:38:24 +00:00
|
|
|
\method{gettext()}.
|
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[text-edit]{getfocustext}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Return the text in the focus.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[text-edit]{getrect}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Return a rectangle giving the actual position of the text-edit block.
|
|
|
|
(The bottom coordinate may differ from the initial position because
|
|
|
|
the block automatically shrinks or grows to fit.)
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[text-edit]{gettext}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Return the entire text buffer.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[text-edit]{move}{rect}
|
1994-01-02 01:22:07 +00:00
|
|
|
Specify a new position for the text-edit block in the document.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[text-edit]{replace}{str}
|
1994-01-02 01:22:07 +00:00
|
|
|
Replace the text in the focus by the given string.
|
|
|
|
The new focus is an insert point at the end of the string.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[text-edit]{setfocus}{i, j}
|
1994-01-02 01:22:07 +00:00
|
|
|
Specify the new focus.
|
|
|
|
Out-of-bounds values are silently clipped.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[text-edit]{settext}{str}
|
1994-01-02 01:22:07 +00:00
|
|
|
Replace the entire text buffer by the given string and set the focus
|
|
|
|
to \code{(0, 0)}.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[text-edit]{setview}{rect}
|
1994-01-02 01:22:07 +00:00
|
|
|
Set the view rectangle to \var{rect}. If \var{rect} is \code{None},
|
|
|
|
viewing mode is reset. In viewing mode, all output from the text-edit
|
|
|
|
object is clipped to the viewing rectangle. This may be useful to
|
|
|
|
implement your own scrolling text subwindow.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{methoddesc}[text-edit]{close}{}
|
1994-01-02 01:22:07 +00:00
|
|
|
Discard the text-edit object. It should not be used again.
|
1998-11-25 22:38:24 +00:00
|
|
|
\end{methoddesc}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
|
|
|
\subsection{Example}
|
1995-03-20 12:59:56 +00:00
|
|
|
\nodename{STDWIN Example}
|
1994-01-02 01:22:07 +00:00
|
|
|
|
|
|
|
Here is a minimal example of using STDWIN in Python.
|
|
|
|
It creates a window and draws the string ``Hello world'' in the top
|
|
|
|
left corner of the window.
|
|
|
|
The window will be correctly redrawn when covered and re-exposed.
|
|
|
|
The program quits when the close icon or menu item is requested.
|
|
|
|
|
1998-02-13 06:58:54 +00:00
|
|
|
\begin{verbatim}
|
1994-01-02 01:22:07 +00:00
|
|
|
import stdwin
|
|
|
|
from stdwinevents import *
|
|
|
|
|
|
|
|
def main():
|
|
|
|
mywin = stdwin.open('Hello')
|
|
|
|
#
|
|
|
|
while 1:
|
|
|
|
(type, win, detail) = stdwin.getevent()
|
|
|
|
if type == WE_DRAW:
|
|
|
|
draw = win.begindrawing()
|
|
|
|
draw.text((0, 0), 'Hello, world')
|
|
|
|
del draw
|
|
|
|
elif type == WE_CLOSE:
|
|
|
|
break
|
|
|
|
|
|
|
|
main()
|
1998-02-13 06:58:54 +00:00
|
|
|
\end{verbatim}
|
1998-11-25 22:38:24 +00:00
|
|
|
|
1998-08-10 19:42:37 +00:00
|
|
|
\section{\module{stdwinevents} ---
|
1998-11-25 22:38:24 +00:00
|
|
|
Constants for use with \module{stdwin}}
|
1998-07-23 17:59:49 +00:00
|
|
|
\declaremodule{standard}{stdwinevents}
|
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\modulesynopsis{Constant definitions for use with \module{stdwin}}
|
1998-07-23 17:59:49 +00:00
|
|
|
|
1994-01-02 01:22:07 +00:00
|
|
|
|
|
|
|
This module defines constants used by STDWIN for event types
|
1998-11-25 22:38:24 +00:00
|
|
|
(\constant{WE_ACTIVATE} etc.), command codes (\constant{WC_LEFT} etc.)
|
|
|
|
and selection types (\constant{WS_PRIMARY} etc.).
|
1994-01-02 01:22:07 +00:00
|
|
|
Read the file for details.
|
|
|
|
Suggested usage is
|
|
|
|
|
1998-02-13 06:58:54 +00:00
|
|
|
\begin{verbatim}
|
1994-01-02 01:22:07 +00:00
|
|
|
>>> from stdwinevents import *
|
|
|
|
>>>
|
1998-02-13 06:58:54 +00:00
|
|
|
\end{verbatim}
|
1998-11-25 22:38:24 +00:00
|
|
|
|
1998-08-10 19:42:37 +00:00
|
|
|
\section{\module{rect} ---
|
1998-11-25 22:38:24 +00:00
|
|
|
Functions for use with \module{stdwin}}
|
1998-07-23 17:59:49 +00:00
|
|
|
\declaremodule{standard}{rect}
|
|
|
|
|
1998-11-25 22:38:24 +00:00
|
|
|
\modulesynopsis{Geometry-related utility function for use with \module{stdwin}}
|
1998-07-23 17:59:49 +00:00
|
|
|
|
1994-01-02 01:22:07 +00:00
|
|
|
|
|
|
|
This module contains useful operations on rectangles.
|
1998-11-25 22:38:24 +00:00
|
|
|
A rectangle is defined as in module \module{stdwin}:
|
1994-01-02 01:22:07 +00:00
|
|
|
a pair of points, where a point is a pair of integers.
|
|
|
|
For example, the rectangle
|
|
|
|
|
1998-02-13 06:58:54 +00:00
|
|
|
\begin{verbatim}
|
1994-01-02 01:22:07 +00:00
|
|
|
(10, 20), (90, 80)
|
1998-02-13 06:58:54 +00:00
|
|
|
\end{verbatim}
|
1998-11-25 22:38:24 +00:00
|
|
|
|
1994-01-02 01:22:07 +00:00
|
|
|
is a rectangle whose left, top, right and bottom edges are 10, 20, 90
|
1998-11-25 22:38:24 +00:00
|
|
|
and 80, respectively. Note that the positive vertical axis points
|
|
|
|
down (as in \module{stdwin}).
|
1994-01-02 01:22:07 +00:00
|
|
|
|
|
|
|
The module defines the following objects:
|
|
|
|
|
|
|
|
\begin{excdesc}{error}
|
|
|
|
The exception raised by functions in this module when they detect an
|
1998-11-25 22:38:24 +00:00
|
|
|
error. The exception argument is a string describing the problem in
|
|
|
|
more detail.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{excdesc}
|
|
|
|
|
|
|
|
\begin{datadesc}{empty}
|
|
|
|
The rectangle returned when some operations return an empty result.
|
|
|
|
This makes it possible to quickly check whether a result is empty:
|
|
|
|
|
1998-02-13 06:58:54 +00:00
|
|
|
\begin{verbatim}
|
1994-01-02 01:22:07 +00:00
|
|
|
>>> import rect
|
|
|
|
>>> r1 = (10, 20), (90, 80)
|
|
|
|
>>> r2 = (0, 0), (10, 20)
|
|
|
|
>>> r3 = rect.intersect([r1, r2])
|
|
|
|
>>> if r3 is rect.empty: print 'Empty intersection'
|
|
|
|
Empty intersection
|
|
|
|
>>>
|
1998-02-13 06:58:54 +00:00
|
|
|
\end{verbatim}
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{is_empty}{r}
|
|
|
|
Returns true if the given rectangle is empty.
|
|
|
|
A rectangle
|
|
|
|
\code{(\var{left}, \var{top}), (\var{right}, \var{bottom})}
|
|
|
|
is empty if
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{math}\var{left} \geq \var{right}\end{math} or
|
|
|
|
\begin{math}\var{top} \geq \var{bottom}\end{math}.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{intersect}{list}
|
|
|
|
Returns the intersection of all rectangles in the list argument.
|
1998-11-25 22:38:24 +00:00
|
|
|
It may also be called with a tuple argument. Raises
|
|
|
|
\exception{rect.error} if the list is empty. Returns
|
|
|
|
\constant{rect.empty} if the intersection of the rectangles is empty.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{union}{list}
|
|
|
|
Returns the smallest rectangle that contains all non-empty rectangles in
|
1998-11-25 22:38:24 +00:00
|
|
|
the list argument. It may also be called with a tuple argument or
|
|
|
|
with two or more rectangles as arguments. Returns
|
|
|
|
\constant{rect.empty} if the list is empty or all its rectangles are
|
|
|
|
empty.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 06:33:25 +00:00
|
|
|
\begin{funcdesc}{pointinrect}{point, rect}
|
1998-11-25 22:38:24 +00:00
|
|
|
Returns true if the point is inside the rectangle. By definition, a
|
|
|
|
point \code{(\var{h}, \var{v})} is inside a rectangle
|
1994-01-02 01:22:07 +00:00
|
|
|
\code{(\var{left}, \var{top}), (\var{right}, \var{bottom})} if
|
1998-11-25 22:38:24 +00:00
|
|
|
\begin{math}\var{left} \leq \var{h} < \var{right}\end{math} and
|
|
|
|
\begin{math}\var{top} \leq \var{v} < \var{bottom}\end{math}.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{inset}{rect, (dh, dv)}
|
|
|
|
Returns a rectangle that lies inside the \var{rect} argument by
|
|
|
|
\var{dh} pixels horizontally and \var{dv} pixels vertically. If
|
|
|
|
\var{dh} or \var{dv} is negative, the result lies outside \var{rect}.
|
1994-01-02 01:22:07 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{rect2geom}{rect}
|
|
|
|
Converts a rectangle to geometry representation:
|
|
|
|
\code{(\var{left}, \var{top}), (\var{width}, \var{height})}.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{geom2rect}{geom}
|
|
|
|
Converts a rectangle given in geometry representation back to the
|
|
|
|
standard rectangle representation
|
|
|
|
\code{(\var{left}, \var{top}), (\var{right}, \var{bottom})}.
|
|
|
|
\end{funcdesc}
|