home *** CD-ROM | disk | FTP | other *** search
- From: guido@cwi.nl (Guido van Rossum)
- Newsgroups: alt.sources
- Subject: STDWIN 0.9.5, Part 11/19
- Message-ID: <3075@charon.cwi.nl>
- Date: 4 Mar 91 11:58:09 GMT
-
- Archive-name: stdwin/part11
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 11 (of 19)."
- # Contents: Appls/bed/mouse.c Doc/man/x11stdwin.man H/stdwin.h
- # Packs/textedit/editwin.c Ports/mac/about.c Ports/mac/dialog.c
- # Ports/x11/draw.c
- # Wrapped by guido@voorn.cwi.nl on Mon Mar 4 12:37:29 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Appls/bed/mouse.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Appls/bed/mouse.c'\"
- else
- echo shar: Extracting \"'Appls/bed/mouse.c'\" \(7752 characters\)
- sed "s/^X//" >'Appls/bed/mouse.c' <<'END_OF_FILE'
- X#include "bed.h"
- X#include "menu.h"
- X
- X#ifndef ABS
- X#define ABS(var) ((var) >= 0 ? (var) : -(var))
- X#endif
- X
- Xextern int sqrsize ;
- X
- Xextern int map_width ;
- Xextern int map_height ;
- X
- Xextern char *raster ;
- Xextern int raster_lenght ;
- Xextern int stride ;
- X
- Xextern WINDOW *win ;
- X
- Xextern bool changed ;
- X
- Xextern int state ;
- X
- Xbool drawline = FALSE ;
- Xint beg_h ;
- Xint beg_v ;
- Xint end_h ;
- Xint end_v ;
- X
- Xbool drawcircle = FALSE ;
- Xint cent_h ;
- Xint cent_v ;
- Xint c_dh ;
- Xint c_dv ;
- X
- Xbool selrect = FALSE ;
- Xint sr_left ;
- Xint sr_top ;
- Xint sr_right ;
- Xint sr_bottom ;
- X
- Xvoid
- Xwxorrect (left, top, right, bottom)
- X int left ;
- X int top ;
- X int right ;
- X int bottom ;
- X{
- X wxorline (left, top, right - 1, top) ;
- X wxorline (right - 1, top, right -1, bottom - 1) ;
- X wxorline (left, bottom - 1, right -1, bottom - 1) ;
- X wxorline (left, top, left, bottom - 1) ;
- X
- X if (right - left <= bottom - top) {
- X wxorline (left, top, right - 1, top + (right - left) - 1) ;
- X wxorline (right - 1, top, left, top + (right - left) - 1) ;
- X }
- X else {
- X wxorline (left, top, left + (bottom - top) - 1, bottom - 1) ;
- X wxorline (right - 1, top, right - (bottom - top) - 1, bottom -1) ;
- X }
- X}
- X
- Xvoid
- Xdrawselrect ()
- X{
- X int l = sr_left * sqrsize ;
- X int t = sr_top * sqrsize ;
- X int r = sr_right * sqrsize ;
- X int b = sr_bottom * sqrsize ;
- X
- X wbegindrawing (win) ;
- X
- X wxorrect (l, t, r, b) ;
- X
- X wenddrawing (win) ;
- X}
- X
- Xint
- Xgetbit(col, row)
- X{
- X char *byte ;
- X int rc ;
- X
- X if (row >= 0 && row < map_height && col >= 0 && col < map_width) {
- X byte = raster + (row * stride) + (col / 8) ;
- X rc = (*byte & (1 << (col % 8))) ? 1 : 0 ;
- X }
- X else
- X rc = 0 ;
- X
- X return (rc) ;
- X}
- X
- Xvoid
- Xsetbit(col, row, value)
- X{
- X char *byte ;
- X
- X if (row >= 0 && row < map_height && col >= 0 && col < map_width) {
- X changed = 1 ;
- X byte = raster + (row * stride) + (col / 8) ;
- X *byte = (*byte & ~(1 << (col %8))) | (value << (col % 8)) ;
- X wchange (win, col * sqrsize, row * sqrsize,
- X (col+1) * sqrsize, (row+1) * sqrsize);
- X }
- X}
- X
- Xvoid
- Xdo_pencil (ep)
- X EVENT *ep ;
- X{
- X static int value ;
- X
- X if (ep->type == WE_MOUSE_DOWN)
- X value = !getbit (ep->u.where.h / sqrsize,
- X ep->u.where.v / sqrsize) ;
- X setbit (ep->u.where.h / sqrsize,
- X ep->u.where.v / sqrsize, value) ;
- X}
- X
- Xvoid
- Xinvertbit (h, v, value)
- X int h ;
- X int v ;
- X bool value ;
- X{
- X if (h < 0 || v < 0 || h >= map_width || v >= map_height)
- X return ;
- X
- X winvert (h * sqrsize, v * sqrsize,
- X (h + 1) * sqrsize, (v + 1) * sqrsize) ;
- X}
- X
- Xvoid
- Xplotline (fp, value)
- X void (*fp) () ;
- X bool value ;
- X{
- X int d_h = end_h - beg_h ;
- X int d_v = end_v - beg_v ;
- X int e ;
- X int h = 0 ;
- X int v = 0 ;
- X int hsign = 1 ;
- X int vsign = 1 ;
- X int i ;
- X
- X if (d_h < 0) {
- X d_h = -d_h ;
- X hsign = -1 ;
- X }
- X
- X if (d_v < 0) {
- X d_v = -d_v ;
- X vsign = -1 ;
- X }
- X
- X wbegindrawing (win) ;
- X
- X if (d_v <= d_h) {
- X for (i = 0, e = 2 * d_v - d_h ; i <= d_h ; ++i) {
- X (*fp) (beg_h + (hsign * h), beg_v + (vsign * v), value) ;
- X
- X if (e > 0) {
- X ++v ;
- X e -= (2 * d_h) ;
- X }
- X
- X e += (2 * d_v) ;
- X ++h ;
- X }
- X }
- X else {
- X for (i = 0, e = 2 * d_h - d_v ; i <= d_v ; ++i) {
- X (*fp) (beg_h + (hsign * h), beg_v + (vsign * v), value) ;
- X
- X if (e > 0) {
- X ++h ;
- X e -= (2 * d_v) ;
- X }
- X
- X e += (2 * d_h) ;
- X ++v ;
- X }
- X }
- X
- X wenddrawing (win) ;
- X}
- X
- Xvoid
- Xplotcircle (fp, value)
- X void (*fp) () ;
- X bool value ;
- X{
- X long h_sqr = c_dh * c_dh ;
- X long v_sqr = c_dv * c_dv ;
- X long r_sqr = h_sqr * v_sqr ;
- X long prev_r = r_sqr ;
- X long min_h ;
- X long min_v ;
- X long min_hv ;
- X int h = c_dh ;
- X int v = 0 ;
- X
- X wbegindrawing (win) ;
- X
- X while (h >= 0 && v <= c_dv) {
- X (*fp) (cent_h + h, cent_v + v, value) ;
- X if (v)
- X (*fp) (cent_h + h, cent_v - v, value) ;
- X if (h)
- X (*fp) (cent_h - h, cent_v + v, value) ;
- X if (h && v)
- X (*fp) (cent_h - h, cent_v - v, value) ;
- X
- X min_h = (long) (2 * h - 1) * v_sqr ;
- X min_v = (long) (2 * v + 1) * -h_sqr ;
- X min_hv = min_h + min_v ;
- X
- X if (ABS (r_sqr - (prev_r - min_h)) <=
- X ABS (r_sqr - (prev_r - min_v))) {
- X if (ABS (r_sqr - (prev_r - min_hv)) <=
- X ABS (r_sqr - (prev_r - min_h))) {
- X prev_r = prev_r - min_hv ;
- X --h ;
- X ++v ;
- X }
- X else {
- X prev_r = prev_r - min_h ;
- X --h ;
- X }
- X }
- X else {
- X if (ABS (r_sqr - (prev_r - min_hv)) <=
- X ABS (r_sqr - (prev_r - min_v))) {
- X prev_r = prev_r - min_hv ;
- X --h ;
- X ++v ;
- X }
- X else {
- X prev_r = prev_r - min_v ;
- X ++v ;
- X }
- X }
- X }
- X
- X wenddrawing (win) ;
- X}
- X
- Xvoid
- Xdo_line (ep)
- X EVENT *ep ;
- X{
- X int curr_h = ep->u.where.h / sqrsize ;
- X int curr_v = ep->u.where.v / sqrsize ;
- X
- X if (curr_h > map_height - 1)
- X curr_h = map_height - 1 ;
- X if (curr_v > map_width - 1)
- X curr_v = map_width - 1 ;
- X
- X switch (ep->type) {
- X case WE_MOUSE_DOWN :
- X if (drawline) {
- X plotline (invertbit, FALSE) ;
- X drawline = FALSE ;
- X }
- X
- X drawline = TRUE ;
- X
- X beg_h = end_h = curr_h ;
- X beg_v = end_v = curr_v ;
- X
- X plotline (invertbit, TRUE) ;
- X break ;
- X case WE_MOUSE_MOVE :
- X if (drawline) {
- X if (curr_h == end_h && curr_v == end_v)
- X return ;
- X
- X plotline (invertbit, FALSE) ;
- X
- X end_h = curr_h ;
- X end_v = curr_v ;
- X
- X plotline (invertbit, TRUE) ;
- X }
- X break ;
- X case WE_MOUSE_UP :
- X if (drawline) {
- X if (curr_h != end_h || curr_v != end_v) {
- X plotline (invertbit, FALSE) ;
- X
- X end_h = curr_h ;
- X end_v = curr_v ;
- X
- X plotline (invertbit, TRUE) ;
- X }
- X
- X plotline (setbit, TRUE) ;
- X
- X drawline = FALSE ;
- X }
- X break ;
- X }
- X}
- X
- Xvoid
- Xdo_circle (ep)
- X EVENT *ep ;
- X{
- X int curr_h = ep->u.where.h / sqrsize ;
- X int curr_v = ep->u.where.v / sqrsize ;
- X
- X if (curr_h > map_height - 1)
- X curr_h = map_height - 1 ;
- X if (curr_v > map_width - 1)
- X curr_v = map_width - 1 ;
- X
- X switch (ep->type) {
- X case WE_MOUSE_DOWN :
- X if (drawcircle) {
- X plotcircle (invertbit, FALSE) ;
- X drawcircle = FALSE ;
- X }
- X
- X drawcircle = TRUE ;
- X
- X cent_h = curr_h ;
- X cent_v = curr_v ;
- X c_dh = c_dv = 0 ;
- X
- X plotcircle (invertbit, TRUE) ;
- X break ;
- X case WE_MOUSE_MOVE :
- X if (drawcircle) {
- X if (ABS ((curr_h - cent_h) + 1) == c_dh &&
- X ABS ((curr_v - cent_v) + 1) == c_dv)
- X return ;
- X
- X plotcircle (invertbit, FALSE) ;
- X
- X c_dh = ABS (curr_h - cent_h) ;
- X c_dv = ABS (curr_v - cent_v) ;
- X
- X plotcircle (invertbit, TRUE) ;
- X }
- X break ;
- X case WE_MOUSE_UP :
- X if (drawcircle) {
- X if (ABS ((curr_h - cent_h) + 1) != c_dh ||
- X ABS ((curr_v - cent_v) + 1) != c_dv) {
- X plotcircle (invertbit, FALSE) ;
- X
- X c_dh = ABS (curr_h - cent_h) ;
- X c_dv = ABS (curr_v - cent_v) ;
- X
- X plotcircle (invertbit, TRUE) ;
- X }
- X
- X plotcircle (setbit, TRUE) ;
- X
- X drawcircle = FALSE ;
- X }
- X break ;
- X }
- X}
- X
- Xvoid
- Xdo_select (ep)
- X EVENT *ep ;
- X{
- X static int sr_h ; /* coord. of mouse down */
- X static int sr_v ;
- X int curr_h = ep->u.where.h / sqrsize ;
- X int curr_v = ep->u.where.v / sqrsize ;
- X
- X switch (ep->type) {
- X case WE_MOUSE_DOWN :
- X if (selrect) {
- X drawselrect () ;
- X selrect = FALSE ;
- X }
- X
- X if (curr_h >= map_width || curr_v >= map_height)
- X return ;
- X
- X selrect = TRUE ;
- X sr_h = curr_h ;
- X sr_v = curr_v ;
- X
- X sr_left = curr_h ;
- X sr_top = curr_v ;
- X sr_right = sr_left + 1 ;
- X sr_bottom = sr_top + 1 ;
- X
- X drawselrect () ;
- X break ;
- X case WE_MOUSE_MOVE :
- X if (selrect) {
- X if (curr_h >= map_width)
- X curr_h = map_width - 1 ;
- X if (curr_v >= map_height)
- X curr_v = map_height - 1 ;
- X
- X if (curr_h < 0)
- X curr_h = 0 ;
- X if (curr_v < 0)
- X curr_v = 0 ;
- X
- X drawselrect () ;
- X
- X if (curr_h < sr_h) {
- X sr_left = curr_h ;
- X sr_right = sr_h + 1 ;
- X }
- X else {
- X sr_left = sr_h ;
- X sr_right = curr_h + 1 ;
- X }
- X
- X if (curr_v < sr_v) {
- X sr_top = curr_v ;
- X sr_bottom = sr_v + 1 ;
- X }
- X else {
- X sr_top = sr_v ;
- X sr_bottom = curr_v + 1 ;
- X }
- X
- X drawselrect () ;
- X }
- X break ;
- X case WE_MOUSE_UP :
- X break ;
- X }
- X}
- X
- Xvoid
- Xdo_mouse (ep)
- X EVENT *ep ;
- X{
- X switch (state) {
- X case PENCIL_ITEM :
- X do_pencil (ep) ;
- X break ;
- X case LINE_ITEM :
- X do_line (ep) ;
- X break ;
- X case CIRCLE_ITEM :
- X do_circle (ep) ;
- X break ;
- X case SELECT_ITEM :
- X do_select (ep) ;
- X break ;
- X }
- X}
- END_OF_FILE
- if test 7752 -ne `wc -c <'Appls/bed/mouse.c'`; then
- echo shar: \"'Appls/bed/mouse.c'\" unpacked with wrong size!
- fi
- # end of 'Appls/bed/mouse.c'
- fi
- if test -f 'Doc/man/x11stdwin.man' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Doc/man/x11stdwin.man'\"
- else
- echo shar: Extracting \"'Doc/man/x11stdwin.man'\" \(8317 characters\)
- sed "s/^X//" >'Doc/man/x11stdwin.man' <<'END_OF_FILE'
- X.TH X11-STDWIN 1
- X.SH NAME
- XX11-STDWIN \- a Standard Window System Interface, X11 version
- X.SH SYNOPSIS
- X.I application
- X[
- X.B \-display
- X.I display-name
- X]
- X[
- X.B \-name
- X.I program-name
- X]
- X[
- X.B \-geometry
- X.I geometry-spec
- X]
- X [
- X.B \-font
- X.I font-name
- X]
- X[
- X.B \-menufont
- X.I font-name
- X]
- X[
- X.B \-iconic
- X]
- X[
- X.B \-icongeometry
- X.I geometry-spec
- X]
- X [
- X.B \-foreground
- X.I color-spec
- X]
- X[
- X.B \-background
- X.I color-spec
- X]
- X [
- X.B \-menuforeground
- X.I color-spec
- X]
- X[
- X.B \-menubackground
- X.I color-spec
- X]
- X [
- X.B \-reverse
- X]
- X[
- X.B \-xrm
- X.I string
- X]
- X[
- X.B \-debuglevel
- X.I number
- X]
- X[
- X.B \-synchronous
- X]
- X[
- X.I option
- X] ...
- X.SH DESCRIPTION
- X.I STDWIN
- Xis a standard interface available for several window systems.
- XThis man page describes the common aspects of applications written using
- XSTDWIN when run under MIT's X Window System, Version 11.
- X.SH COMMAND LINE OPTIONS
- XMost applications (to be precise, those that use the
- X.I winitnew
- Xcall to initialize STDWIN) will accept all options shown in the
- Xsynopsis.
- XFor most options there can also be a corresponding
- X.I resource
- X(option string stored in the X server or in ~/.Xdefaults).
- XCommand line options override resources; resources override defaults
- Xbuilt in the application; application defaults override library defaults.
- XUnless otherwise stated, the resources have the same name as the command
- Xline options (all in lower case), prefixed with ``.stdwin''.
- XFor example, the full name of the resource corresponding to the
- X``\-font'' option is named
- X.IR program .stdwin.font.
- XSince most options have a standard meaning for most X applications, they
- Xare not explained in great length here.
- XOptions with a specific meaning for STDWIN are:
- X.TP
- X.BI \-font " font-name"
- XSpecifies the font to be used by default in text drawn by the
- Xapplication.
- XBoth proportional and fixed-width fonts are acceptable
- X(except that some old applications look nicer with a fixed-width font).
- XThe library default is to use the X server's default (usually 8x13).
- X.TP
- X.BI \-menufont " font-name"
- XSpecifies the font to be used in menus and dialog boxes.
- XThe library default is to use the same font as for normal text.
- X.TP
- X.BI \-foreground " color-spec, " \-background " color-spec"
- XSpecify the colors to be used in the application's part of the window.
- XThe defaults are black and white.
- X.TP
- X.BI \-menuforeground " color-spec, " \-menubackground " color-spec"
- XSpecify the colors to be used in the menu bar, the scroll bars,
- Xdialog boxes and for the window border (the foreground color).
- XBy default the same values are used as for
- X.B \-foreground
- Xand
- X.BR \-background .
- X.TP
- X.B \-reverse
- XReverses the uses of foreground and background colors.
- X.TP
- X.BI \-debuglevel " number"
- XSpecifies the amount of debugging output you want; the higher the
- Xnumber, the more output you have to wade through.
- XThe library default is wisely 0.
- X.TP
- X.B \-synchronous
- XSpecifies that you want the connection with the X server to be
- Xmaintained in synchronous mode (each request immediately sent and a
- Xreply waited for).
- XThis is sometimes useful while debugging.
- XNote that synchronous mode can tremendously reduce drawing efficiency.
- XSynchronous mode is not set automatically when the debugging level is
- Xnonzero, since some bugs go away when it is turned on!
- XThis option has no corresponding resource.
- X.SH SCROLL BARS
- XAll STDWIN applications have two scroll bars (which may be inactive),
- Xone to the left of the window and one at the bottom.
- XOperation and interpretation of the scroll bars is intended to be
- Xidentical to the scroll bars of applications using the X toolkit
- X(e.g., xterm).
- XSummarizing:
- Xthe left button click scrolls forward, the amount varying with
- Xthe position of the click in the bar (for the vertical bar, remember
- X``line to top'');
- Xthe right button similarly scrolls back (``top to line'');
- Xthe middle button moves the beginning of the position indicator
- X(the gray block) to the position where the button is pressed.
- X.SH MENUS
- XAll STDWIN applications display one or more menu titles in a
- X``menu bar'' at the top of the window.
- XPressing and holding a mouse button in a menu title ``pulls down'' a
- Xmenu containing text items.
- XSliding the mouse cursor over the text items
- Xinverts (highlights) the item over which the cursor is currently;
- Xreleasing the mouse button when an item is highlighted causes the
- Xcorresponding command th be executed by the application.
- XReleasing the mouse button outside the menu selects no item.
- XSliding the mouse horizontally over the menu titles pulls down the other
- Xmenus; at most one menu will be visible at any time.
- X.PP
- XOne menu, labeled
- X.BR X ,
- Xis present in all windows.
- XIts only item, named
- X.BR Close ,
- Xis the standard way to close the window; for single-window applications,
- Xselecting this also quits the application.
- XThe application is free to refuse closing its window, or to ask
- Xconfirmation first, or to do whatever when this item is selected; it is
- Xmerely a hint that you would like the window to go away, not a request.
- X.PP
- XMenu items may be marked (``checked'') with a `*' in the left margin; this
- Xan indicator that the function selected by the menu item is currently
- X``active''.
- XThe check mark can be set and cleared by the application for each menu
- Xitem; the use should be apparent from the application's documentation.
- XMenu items may be inactive (``disabled''); such items cannot be selected
- Xand will not be highlighted.
- XDisabled items are currently indicated by a `\-' in the left margin.
- X.PP
- XMenu items may be selectable via a keyboard shortcut.
- XThe existence of a keyboard shortcut is shown in the menu item by the
- Xpresence of the string
- X.RI ``M- c ''
- Xin the right margin, where
- X.I c
- Xcan be any character.
- XThe M stands for ``Meta''.
- XHolding a ``Meta'' key (possibly labeled Alt, Command, Compose, Left or
- Xsome such name on your keyboard, but definitely not Control or Shift)
- Xwhile typing a character, usually a letter, will be
- Xequivalent to selecting the corresponding menu item with the mouse.
- XShortcuts are defined by the application.
- XSome shortcuts are conventional in many applications:
- XM-Q for Quit, M-S for Save, M-O for Open.
- XAlso M-Z for Undo, M-X for Cut, M-C for Copy and M-V for Paste
- X(reminiscent of the Macintosh commands).
- XUpper and lower case characters are equivalent, unless the application
- Xuses the same letter in lower and upper case as shortcuts for
- Xdifferent menu items.
- X.\"SH DIALOG BOXES
- X.\"SH TEXT EDITING
- X.\" selecting, button-2 selecting, double-click, cut/paste, delete, arrows.
- X.SH EXAMPLE
- XHere are some lines you could put in your resource input file:
- X
- X *stdwin*font:courier12f
- X.br
- X dpv*geometry:700x850
- X.br
- X klok*geometry:-1+1
- X
- XThis sets the font for all STDWIN applications, the initial size for
- X.I dpv
- Xand the initial position for
- X.I klok.
- XNote the use of `*' for separators; extra levels of names may be
- Xinserted in the future.
- X.SH DIAGNOSTICS
- X.I STDWIN
- Xcan issue complaints about various error conditions, e.g., font not found;
- Xthese are intended to be self-explanatory.
- XSome messages indicate STDWIN has found an inconsistency in
- Xitself or in the X server.
- XThese should be reported to the author if the cause isn't obvious.
- X.\"SH FILES
- X.SH SEE ALSO
- XThe X documentation (especially the chapters on command line arguments
- Xand resources).
- X.br
- XSTDWIN \- A Standard Window System Interface, by Guido van Rossum
- X(CWI Report number CS-R8817, April 1988).
- X.SH AUTHOR
- XGuido van Rossum
- X.SH BUGS
- XI could be sued by Apple for stealing the ``look and feel'' of some
- Xaspects of the Macintosh. :-)
- X.br
- XThe
- X.B \-reverse
- Xoption doesn't affect the use of colors in dialog boxes.
- X.br
- XLike so many other window systems, X11 limits the size of windows to
- X64Kx64K.
- X.br
- XSince a STDWIN document is represented as an X11 window (scrolled inside
- Xanother X11 window), applications that create really big windows (~32K
- Xpixels wide or high) may crash due to a server bug.
- X.br
- XWhen an application does no window output for some time after a menu
- Xitem has been selected, the menu stays visible in its pulled-down state.
- X.br
- XThe conventional shortcuts for Undo, Cut and Paste aren't very mnemonic.
- X(But Apple never thought that was a problem.)
- X.br
- XThe standard X-STDWIN command line options are best given before all
- Xapplication-specific options.
- X.br
- XIf you are running an application in the background and have
- X.I "stty tostop"
- Xturned on, warnings or errors from STDWIN may cause the program to
- Xblock.
- END_OF_FILE
- if test 8317 -ne `wc -c <'Doc/man/x11stdwin.man'`; then
- echo shar: \"'Doc/man/x11stdwin.man'\" unpacked with wrong size!
- fi
- # end of 'Doc/man/x11stdwin.man'
- fi
- if test -f 'H/stdwin.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'H/stdwin.h'\"
- else
- echo shar: Extracting \"'H/stdwin.h'\" \(8311 characters\)
- sed "s/^X//" >'H/stdwin.h' <<'END_OF_FILE'
- X/* STDWIN INTERFACE */
- X
- X#ifndef __STDWIN_H__ /* Guard against multiple inclusion */
- X#define __STDWIN_H__
- X
- X#include "_ARGS.h" /* Definition of _ARGS() macro */
- X
- X
- X/***********************************/
- X/* Section 1. Types and constants */
- X/***********************************/
- X
- X
- X/* These structs are implementation-dependent, the user only sees
- X pointers to them */
- X
- X#define WINDOW struct _window
- X#define MENU struct _menu
- X#define CURSOR struct _cursor
- X
- X
- X/* Fake window type used by the wgettag() and wsettag() macros */
- X
- Xstruct _fakewindow {
- X short tag;
- X};
- X
- X#define _FAKEWINDOW struct _fakewindow
- X
- X
- X/* EVENT struct */
- X
- Xstruct _event {
- X int type;
- X WINDOW *window;
- X union {
- X /* case WE_CHAR: */
- X int character;
- X /* case WE_COMMAND: */
- X int command;
- X /* case WE_MENU: */
- X struct { int id; int item; } m;
- X /* case WE_DRAW: */
- X struct { int left, top, right, bottom; } area;
- X /* case WE_MOUSE_DOWN, WE_MOUSE_MOVE, WE_MOUSE_UP: */
- X struct {
- X int h;
- X int v;
- X int clicks;
- X int button;
- X int mask;
- X } where;
- X /* case WE_LOST_SEL: */
- X int sel;
- X } u;
- X};
- X
- X#define EVENT struct _event
- X
- X
- X/* Event types */
- X/* XXX Should be reordered */
- X
- X#define WE_NULL 0 /* (Used internally) */
- X#define WE_ACTIVATE 1 /* Window became active */
- X#define WE_CHAR 2 /* Character typed at keyboard */
- X#define WE_COMMAND 3 /* Special command, function key etc. */
- X#define WE_MOUSE_DOWN 4 /* Mouse button pressed */
- X#define WE_MOUSE_MOVE 5 /* Mouse moved with button down */
- X#define WE_MOUSE_UP 6 /* Mouse button released */
- X#define WE_MENU 7 /* Menu item selected */
- X#define WE_SIZE 8 /* Window size changed */
- X#define WE_MOVE 9 /* Window moved (reserved) */
- X#define WE_DRAW 10 /* Request to redraw part of window */
- X#define WE_TIMER 11 /* Window's timer went off */
- X#define WE_DEACTIVATE 12 /* Window became inactive */
- X#define WE_EXTERN 13 /* Externally generated event (Amoeba) */
- X#define WE_KEY 14 /* Low-level key event (reserved) */
- X#define WE_LOST_SEL 15 /* Lost selection */
- X#define WE_CLOSE 16 /* User wants to close window */
- X
- X
- X/* Special keys reported by WE_COMMAND */
- X/* XXX Should become key events */
- X
- X#define WC_CLOSE 1 /* Now a separate event! */
- X/* The following four are arrow keys */
- X#define WC_LEFT 2
- X#define WC_RIGHT 3
- X#define WC_UP 4
- X#define WC_DOWN 5
- X/* ASCII keys */
- X#define WC_CANCEL 6
- X#define WC_BACKSPACE 7
- X#define WC_TAB 8
- X#define WC_RETURN 9
- X/* IBM-PC keys -- not in all implementations */
- X/* XXX Should be done differently */
- X#define WC_HOME 10
- X#define WC_END 11
- X#define WC_CLEAR 12
- X#define WC_INS 13
- X#define WC_DEL 14
- X#define WC_PAGE_UP 15
- X#define WC_PAGE_DOWN 16
- X#define WC_META_LEFT 17
- X#define WC_META_RIGHT 18
- X#define WC_META_HOME 19
- X#define WC_META_END 20
- X#define WC_META_PAGE_UP 21
- X#define WC_META_PAGE_DOWN 22
- X/* XXX Should have entries for Alt-letter and F1-F10 etc. ? */
- X
- X
- X/* Codes for selections (e.u.sel for WE_LOST_SEL) */
- X
- X#define WS_CLIPBOARD 0
- X#define WS_PRIMARY 1
- X#define WS_SECONDARY 2
- X
- X
- X/* TEXTATTR struct */
- X
- X/* The contents of a text attributes struct are disclosed here because
- X the interface allows the programmer to declare objects of this type.
- X (I'm not so sure anymore that this is the right thing to do!) */
- X
- Xstruct _textattr {
- X short font;
- X unsigned char size;
- X unsigned char style;
- X};
- X
- X#define TEXTATTR struct _textattr
- X
- X
- X/*************************************/
- X/* Section 2. Function declarations */
- X/*************************************/
- X
- X
- Xvoid wargs _ARGS((int *pargc, char ***pargv));
- Xvoid winit _ARGS((void));
- Xvoid winitargs _ARGS((int *pargc, char ***pargv));
- Xvoid wdone _ARGS((void));
- X
- Xvoid wgetscrsize _ARGS((int *pwidth, int *pheight));
- Xvoid wgetscrmm _ARGS((int *pmmwidth, int *pmmheight));
- X
- Xvoid wsetmaxwinsize _ARGS((int width, int height));
- Xvoid wsetdefwinsize _ARGS((int width, int height));
- Xvoid wsetdefwinpos _ARGS((int h, int v));
- Xvoid wgetdefwinsize _ARGS((int *pwidth, int *pheight));
- Xvoid wgetdefwinpos _ARGS((int *ph, int *pv));
- X
- XWINDOW *wopen _ARGS((char *title,
- X void (*drawproc)(/*WINDOW *win,
- X int left, int top, int right, int bottom*/)));
- Xvoid wclose _ARGS((WINDOW *win));
- X#define wgettag(win) (((_FAKEWINDOW *)(win)) -> tag)
- X#define wsettag(win, newtag) (((_FAKEWINDOW *)(win)) -> tag = (newtag))
- Xvoid wsetactive _ARGS((WINDOW *win));
- XWINDOW *wgetactive _ARGS((void));
- Xvoid wgetwinsize _ARGS((WINDOW *win, int *width, int *height));
- Xvoid wsetdocsize _ARGS((WINDOW *win, int width, int height));
- Xvoid wgetdocsize _ARGS((WINDOW *win, int *width, int *height));
- Xvoid wsettitle _ARGS((WINDOW *win, char *title));
- Xchar *wgettitle _ARGS((WINDOW *win)); /* Returns pointer to static data */
- X
- Xvoid wsetorigin _ARGS((WINDOW *win, int h, int v));
- Xvoid wgetorigin _ARGS((WINDOW *win, int *h, int *v));
- Xvoid wshow _ARGS((WINDOW *win, int left, int top, int right, int bottom));
- Xvoid wchange _ARGS((WINDOW *win, int left, int top, int right, int bottom));
- Xvoid wscroll _ARGS((WINDOW *win, int left, int top, int right, int bottom,
- X int dh, int dv));
- X
- Xvoid wfleep _ARGS((void));
- Xvoid wmessage _ARGS((char *str));
- Xvoid wperror _ARGS((char *name));
- X/*bool*/int waskstr _ARGS((char *prompt, char *buf, int buflen));
- Xint waskync _ARGS((char *question, int dflt));
- X/*bool*/int waskfile _ARGS((char *prompt, char *buf, int buflen,
- X /*bool*/int newfile));
- X
- Xvoid wsetcaret _ARGS((WINDOW *win, int h, int v));
- Xvoid wnocaret _ARGS((WINDOW *win));
- X
- Xvoid wsettimer _ARGS((WINDOW *win, int deciseconds));
- X
- XMENU *wmenucreate _ARGS((int id, char *title));
- Xvoid wmenudelete _ARGS((MENU *mp));
- Xint wmenuadditem _ARGS((MENU *mp, char *text, int shortcut));
- Xvoid wmenusetitem _ARGS((MENU *mp, int i, char *text));
- Xvoid wmenusetdeflocal _ARGS((/*bool*/int local));
- Xvoid wmenuattach _ARGS((WINDOW *win, MENU *mp));
- Xvoid wmenudetach _ARGS((WINDOW *win, MENU *mp));
- Xvoid wmenuenable _ARGS((MENU *mp, int item, int flag));
- Xvoid wmenucheck _ARGS((MENU *mp, int item, int flag));
- X
- X/* The following is only available in termcap stdwin: */
- Xvoid wsetshortcut _ARGS((int id, int item, char *keys));
- X
- Xvoid wgetevent _ARGS((EVENT *ep));
- X/*bool*/int wpollevent _ARGS((EVENT *ep));
- Xvoid wungetevent _ARGS((EVENT *ep));
- Xvoid wupdate _ARGS((WINDOW *win));
- Xvoid wbegindrawing _ARGS((WINDOW *win));
- Xvoid wenddrawing _ARGS((WINDOW *win));
- Xvoid wflush _ARGS((void));
- X
- Xvoid wdrawline _ARGS((int h1, int v1, int h2, int v2));
- Xvoid wxorline _ARGS((int h1, int v1, int h2, int v2));
- Xvoid wdrawcircle _ARGS((int h, int v, int radius));
- Xvoid wdrawelarc _ARGS((int h, int v, int hrad, int vrad, int ang1, int ang2));
- Xvoid wdrawbox _ARGS((int left, int top, int right, int bottom));
- Xvoid werase _ARGS((int left, int top, int right, int bottom));
- Xvoid wpaint _ARGS((int left, int top, int right, int bottom));
- Xvoid winvert _ARGS((int left, int top, int right, int bottom));
- Xvoid wshade _ARGS((int left, int top, int right, int bottom, int percent));
- X
- Xvoid wcliprect _ARGS((int left, int top, int right, int bottom));
- Xvoid wnoclip _ARGS((void));
- X
- Xvoid wdrawtext _ARGS((int h, int v, char *str, int len));
- Xvoid wdrawchar _ARGS((int h, int v, int c));
- Xint wlineheight _ARGS((void));
- Xint wbaseline _ARGS((void));
- Xint wtextwidth _ARGS((char *str, int len));
- Xint wcharwidth _ARGS((int c));
- Xint wtextbreak _ARGS((char *str, int len, int width));
- X
- Xvoid wgettextattr _ARGS((TEXTATTR *attr));
- Xvoid wsettextattr _ARGS((TEXTATTR *attr));
- Xvoid wgetwintextattr _ARGS((WINDOW *win, TEXTATTR *attr));
- Xvoid wsetwintextattr _ARGS((WINDOW *win, TEXTATTR *attr));
- X
- Xvoid wsetplain _ARGS((void));
- Xvoid wsethilite _ARGS((void));
- Xvoid wsetinverse _ARGS((void));
- Xvoid wsetitalic _ARGS((void));
- Xvoid wsetbold _ARGS((void));
- Xvoid wsetbolditalic _ARGS((void));
- Xvoid wsetunderline _ARGS((void));
- X
- Xvoid wsetfont _ARGS((char *fontname));
- Xvoid wsetsize _ARGS((int pointsize));
- X
- X/* Setting the mouse cursor for a window */
- XCURSOR *wfetchcursor _ARGS((char *name));
- Xvoid wsetwincursor _ARGS((WINDOW *win, CURSOR *cursor));
- X
- X/* X11 Selection interface */
- X/*bool*/int wsetselection _ARGS((WINDOW *, int, char *, int));
- Xvoid wresetselection _ARGS((int));
- Xchar *wgetselection _ARGS((int, int *));
- X
- X/* Cut buffer interface */
- Xvoid wsetcutbuffer _ARGS((int, char *, int));
- Xchar *wgetcutbuffer _ARGS((int, int *));
- Xvoid wrotatecutbuffers _ARGS((int));
- Xvoid wsetclip _ARGS((char *, int));
- Xchar *wgetclip _ARGS((void));
- X
- X
- X/* Pull in definitions for TEXTEDIT package */
- X
- X#include "stdwtext.h"
- X
- X#endif /* __STDWIN_H__ */
- END_OF_FILE
- if test 8311 -ne `wc -c <'H/stdwin.h'`; then
- echo shar: \"'H/stdwin.h'\" unpacked with wrong size!
- fi
- # end of 'H/stdwin.h'
- fi
- if test -f 'Packs/textedit/editwin.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Packs/textedit/editwin.c'\"
- else
- echo shar: Extracting \"'Packs/textedit/editwin.c'\" \(7562 characters\)
- sed "s/^X//" >'Packs/textedit/editwin.c' <<'END_OF_FILE'
- X/* Edit Windows */
- X
- X/* The data structure exported by this module is intended to
- X be accessible to the caller;
- X the routines provided here don't duplicate operations that
- X can be done by calling text-edit or window routines directly.
- X Exception: ewreplace is like tereplace, but also clears
- X the 'saved' flag and sets the document size */
- X
- X#include "stdwin.h"
- X#include "tools.h"
- X#include "editwin.h"
- X
- Xextern long ftell _ARGS((FILE *));
- X
- X#define MAXFN 256 /* File name length */
- X
- Xstatic int ewnum;
- Xstatic EDITWIN **ewlist;
- X
- XEDITWIN *
- Xewfind(win)
- X WINDOW *win;
- X{
- X int i;
- X
- X if (win == NULL)
- X return NULL;
- X
- X i= wgettag(win);
- X
- X if (i >= 0 && i < ewnum &&
- X ewlist[i] != NULL && ewlist[i]->win == win)
- X return ewlist[i];
- X else
- X return NULL;
- X}
- X
- Xint
- Xewcount()
- X{
- X int count= 0;
- X int i;
- X for (i= 0; i < ewnum; ++i) {
- X if (ewlist[i] != NULL)
- X ++count;
- X }
- X return count;
- X}
- X
- Xstatic void
- Xewdrawproc(win, left, top, right, bottom)
- X WINDOW *win;
- X{
- X EDITWIN *ew= ewfind(win);
- X if (ew != NULL)
- X tedrawnew(ew->tp, left, top, right, bottom);
- X}
- X
- XEDITWIN *
- Xewcreate(filename)
- X char *filename;
- X{
- X EDITWIN *ew= ALLOC(EDITWIN);
- X int width, height;
- X int i;
- X
- X if (ew == NULL)
- X return NULL;
- X ew->win= wopen(filename==NULL ? "Untitled" : filename, ewdrawproc);
- X if (ew->win == NULL) {
- X FREE(ew);
- X return NULL;
- X }
- X wsetwincursor(ew->win, wfetchcursor("ibeam"));
- X wgetwinsize(ew->win, &width, &height);
- X ew->tp= tecreate(ew->win, 0, 0, width, height);
- X if (ew->tp == NULL) {
- X wclose(ew->win);
- X FREE(ew);
- X return NULL;
- X }
- X if (filename != NULL) {
- X if (!ewreadfile(ew, filename)) {
- X tefree(ew->tp);
- X wclose(ew->win);
- X FREE(ew);
- X return NULL;
- X }
- X }
- X ew->filename= strdup(filename);
- X ew->saved= TRUE;
- X for (i= 0; i < ewnum; ++i) {
- X if (ewlist[i] == NULL)
- X break;
- X }
- X wsettag(ew->win, i);
- X if (i >= ewnum) {
- X L_APPEND(ewnum, ewlist, EDITWIN*, NULL);
- X }
- X ewlist[i]= ew;
- X return ew;
- X}
- X
- XEDITWIN *
- Xewnew()
- X{
- X return ewcreate((char*)NULL);
- X}
- X
- XEDITWIN *
- Xewopen()
- X{
- X char filename[MAXFN];
- X
- X filename[0]= EOS;
- X if (waskfile("Open file:", filename, sizeof filename, FALSE))
- X return ewcreate(filename);
- X else
- X return NULL;
- X}
- X
- Xbool
- Xewclose(ew)
- X EDITWIN *ew;
- X{
- X int i;
- X
- X if (!ew->saved) {
- X char buf[MAXFN+25];
- X sprintf(buf, "Save changes to \"%s\" before closing?",
- X ew->filename==NULL ? "Untitled" : ew->filename);
- X switch (waskync(buf, 1)) {
- X case -1:
- X return FALSE;
- X case 0:
- X break;
- X case 1:
- X if (!ewsave(ew))
- X return FALSE;
- X break;
- X }
- X }
- X i= wgettag(ew->win);
- X if (i >= 0 && i < ewnum && ewlist[i] == ew)
- X ewlist[i]= NULL;
- X tefree(ew->tp);
- X wclose(ew->win);
- X FREE(ew->filename);
- X FREE(ew);
- X return TRUE;
- X}
- X
- Xbool
- Xewsave(ew)
- X EDITWIN *ew;
- X{
- X if (ew->saved)
- X return TRUE;
- X if (!ew->filename)
- X return ewsaveas(ew);
- X return ew->saved= ewwritefile(ew, ew->filename);
- X}
- X
- Xbool
- Xewsaveas(ew)
- X EDITWIN *ew;
- X{
- X return ewsaveprompt(ew, "Save as:", TRUE);
- X}
- X
- Xbool
- Xewsavecopy(ew)
- X EDITWIN *ew;
- X{
- X return ewsaveprompt(ew, "Save a copy as:", FALSE);
- X}
- X
- Xbool
- Xewsaveprompt(ew, prompt, changefile)
- X EDITWIN *ew;
- X char *prompt;
- X bool changefile;
- X{
- X char filename[MAXFN];
- X
- X filename[0]= EOS;
- X if (ew->filename != NULL) {
- X strncpy(filename, ew->filename, MAXFN);
- X filename[MAXFN-1]= EOS;
- X }
- X if (!waskfile(prompt, filename, sizeof filename, TRUE))
- X return FALSE;
- X if (!ewwritefile(ew, filename))
- X return FALSE;
- X if (changefile) {
- X FREE(ew->filename);
- X ew->filename= strdup(filename);
- X wsettitle(ew->win, filename);
- X ew->saved= TRUE;
- X }
- X return TRUE;
- X}
- X
- Xbool
- Xewrevert(ew)
- X EDITWIN *ew;
- X{
- X char buf[MAXFN+50];
- X
- X if (ew->saved)
- X return TRUE;
- X if (ew->filename == NULL) {
- X wmessage("Not saved yet");
- X return FALSE;
- X }
- X sprintf(buf, "Discard changes since last save to \"%s\" ?",
- X ew->filename);
- X if (waskync(buf, 1) < 1)
- X return FALSE;
- X return ewreadfile(ew, ew->filename);
- X}
- X
- Xbool
- Xewreadfile(ew, filename)
- X EDITWIN *ew;
- X char *filename;
- X{
- X FILE *fp= fopen(filename, "r");
- X long size;
- X char *buf;
- X
- X if (fp == NULL) {
- X wperror(filename);
- X return FALSE;
- X }
- X if (fseek(fp, 0L, 2) == -1) {
- X wperror (filename);
- X fclose (fp);
- X return FALSE;
- X }
- X size= ftell(fp);
- X if (size >= 1L<<15) {
- X char mbuf[MAXFN + 50];
- X sprintf(mbuf, "File \"%s\" is big (%d K). Still edit?",
- X filename, (int) ((size+1023)/1024));
- X if (waskync(mbuf, 1) < 1) {
- X fclose(fp);
- X return FALSE;
- X }
- X }
- X buf= malloc((unsigned)size);
- X if (buf == NULL) {
- X wmessage("Can't get memory for buffer");
- X fclose(fp);
- X return FALSE;
- X }
- X if (fseek(fp, 0L, 0) == -1) {
- X wperror (filename);
- X fclose (fp);
- X return FALSE;
- X }
- X if ((size = fread(buf, 1, (int) size, fp)) == -1) {
- X wmessage("Read error");
- X fclose(fp);
- X return FALSE;
- X }
- X fclose(fp);
- X tesetbuf(ew->tp, buf, (int) size); /* Gives the buffer away! */
- X ew->saved= TRUE;
- X ewsetdimensions(ew);
- X return TRUE;
- X}
- X
- Xvoid
- Xewsetdimensions(ew)
- X EDITWIN *ew;
- X{
- X wsetdocsize(ew->win, 0, tegetbottom(ew->tp));
- X}
- X
- Xbool
- Xewwritefile(ew, filename)
- X EDITWIN *ew;
- X char *filename;
- X{
- X FILE *fp= fopen(filename, "w");
- X char *buf;
- X int len, nwritten;
- X
- X if (fp == NULL) {
- X wperror(filename);
- X return FALSE;
- X }
- X buf= tegettext(ew->tp);
- X len= strlen(buf);
- X nwritten= fwrite(buf, 1, len, fp);
- X fclose(fp);
- X if (nwritten != len) {
- X wmessage("Write error");
- X return FALSE;
- X }
- X /* Can't set saved to TRUE, because of 'save a copy' */
- X return TRUE;
- X}
- X
- Xbool
- Xewevent(ew, e, closed_return)
- X EDITWIN *ew;
- X EVENT *e;
- X bool *closed_return;
- X{
- X bool closed= FALSE;
- X bool change= FALSE;
- X
- X if (ew == NULL) {
- X ew= ewfind(e->window);
- X if (ew == NULL)
- X return FALSE;
- X }
- X else if (e->window != ew->win)
- X return FALSE;
- X
- X switch (e->type) {
- X
- X case WE_ACTIVATE:
- X break;
- X
- X case WE_SIZE:
- X {
- X int width, height;
- X wgetwinsize(ew->win, &width, &height);
- X temovenew(ew->tp, 0, 0, width, height);
- X ewsetdimensions(ew);
- X }
- X break;
- X
- X case WE_COMMAND:
- X if (e->u.command == WC_CLOSE) {
- X closed= ewclose(ew);
- X break;
- X }
- X /* Else, fall through */
- X if (e->u.command == WC_RETURN ||
- X e->u.command == WC_TAB ||
- X e->u.command == WC_BACKSPACE)
- X change= TRUE;
- X goto def;
- X
- X case WE_MOUSE_DOWN:
- X /* Edit the coordinates slightly so teevent always
- X believes it is in the rect */
- X {
- X int left= tegetleft(ew->tp);
- X int right= tegetright(ew->tp);
- X int top= tegettop(ew->tp);
- X int bottom= tegetbottom(ew->tp);
- X CLIPMIN(e->u.where.h, left);
- X CLIPMAX(e->u.where.h, right);
- X CLIPMIN(e->u.where.v, top);
- X if (e->u.where.v >= bottom) {
- X e->u.where.v= bottom;
- X e->u.where.h= right;
- X }
- X }
- X /* Fall through */
- X default:
- X def:
- X if (!teevent(ew->tp, e))
- X return FALSE;
- X if (e->type == WE_CHAR)
- X change= TRUE;
- X if (change) {
- X ew->saved= FALSE;
- X ewsetdimensions(ew);
- X }
- X break;
- X
- X }
- X
- X if (closed_return != NULL)
- X *closed_return= closed;
- X return TRUE;
- X}
- X
- Xbool
- Xewsaveall()
- X{
- X int i;
- X
- X for (i= 0; i < ewnum; ++i) {
- X if (ewlist[i] != NULL && !ewsave(ewlist[i]))
- X return FALSE;
- X }
- X return TRUE;
- X}
- X
- Xbool
- Xewcloseall()
- X{
- X int i;
- X
- X for (i= 0; i < ewnum; ++i) {
- X if (ewlist[i] != NULL && !ewclose(ewlist[i]))
- X return FALSE;
- X }
- X return TRUE;
- X}
- X
- Xvoid
- Xewreplace(ew, str)
- X EDITWIN *ew;
- X char *str;
- X{
- X if (*str == EOS && tegetfoc1(ew->tp) == tegetfoc2(ew->tp))
- X return;
- X tereplace(ew->tp, str);
- X ew->saved= FALSE;
- X ewsetdimensions(ew);
- X}
- X
- X/*ARGSUSED*/
- Xvoid
- Xewundo(ew)
- X EDITWIN *ew;
- X{
- X wfleep();
- X}
- X
- Xvoid
- Xewcopy(ew)
- X EDITWIN *ew;
- X{
- X int f1= tegetfoc1(ew->tp);
- X int f2= tegetfoc2(ew->tp);
- X char *text;
- X if (f1 == f2)
- X wfleep();
- X else {
- X text= tegettext(ew->tp);
- X wsetclip(text+f1, f2-f1);
- X }
- X
- X}
- X
- Xvoid
- Xewpaste(ew)
- X EDITWIN *ew;
- X{
- X char *text= wgetclip();
- X if (text == NULL)
- X wfleep();
- X else
- X ewreplace(ew, text);
- X}
- END_OF_FILE
- if test 7562 -ne `wc -c <'Packs/textedit/editwin.c'`; then
- echo shar: \"'Packs/textedit/editwin.c'\" unpacked with wrong size!
- fi
- # end of 'Packs/textedit/editwin.c'
- fi
- if test -f 'Ports/mac/about.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Ports/mac/about.c'\"
- else
- echo shar: Extracting \"'Ports/mac/about.c'\" \(1563 characters\)
- sed "s/^X//" >'Ports/mac/about.c' <<'END_OF_FILE'
- X/* MAC STDWIN -- "ABOUT STDWIN" MESSAGE. */
- X
- X#include "macwin.h"
- X#ifdef MPW
- X#include <Events.h>
- X#include <TextEdit.h>
- X#endif
- X#ifdef THINK_C
- X#include <EventMgr.h>
- X#include <TextEdit.h>
- X#endif
- X
- X/* Default About... message; applications may assign to this.
- X You may also assign to about_item in "menu.c", *before*
- X calling winit() or winitargs().
- X Also see your THINK C licence.
- X*/
- Xchar *about_message=
- X "STDWIN version 0.9.5 (using THINK C 4.0)\r\r\
- XCopyright \251 1988, 1989, 1990 Stichting Mathematisch Centrum, \
- XAmsterdam\r\
- XWritten by Guido van Rossum (guido@cwi.nl)\r\
- XCWI, dept. AA, P.O.B. 4079\r1009 AB Amsterdam, The Netherlands\r\r\
- X[Option-click in window scrolls as in MacPaint,\r\
- XOption-click in title sends behind]";
- X /* \251 is the (c) Copyright symbol.
- X I don't want non-ASCII characters in my source. */
- X
- X
- X/* "About ..." procedure.
- X This is self-contained -- if you have a better idea, change it.
- X*/
- X
- Xvoid
- Xdo_about()
- X{
- X Rect r;
- X WindowPtr w;
- X EventRecord e;
- X
- X SetRect(&r, 0, 0, 340, 180); /* XXX Shouldn't be hardcoded */
- X OffsetRect(&r, (screen->portRect.right - r.right)/2, 40);
- X
- X w = NewWindow(
- X (Ptr) NULL, /* No storage */
- X &r, /* Bounds rect */
- X "", /* No title */
- X true, /* Visible */
- X altDBoxProc, /* Plain box with shadow */
- X (WindowPtr) -1, /* In front position */
- X false, /* No go-away box */
- X 0L); /* RefCon */
- X SetPort(w);
- X r = w->portRect;
- X InsetRect(&r, 10, 10);
- X TextBox(about_message, strlen(about_message), &r, teJustCenter);
- X while (!GetNextEvent(mDownMask|keyDownMask, &e))
- X ;
- X DisposeWindow(w);
- X}
- END_OF_FILE
- if test 1563 -ne `wc -c <'Ports/mac/about.c'`; then
- echo shar: \"'Ports/mac/about.c'\" unpacked with wrong size!
- fi
- # end of 'Ports/mac/about.c'
- fi
- if test -f 'Ports/mac/dialog.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Ports/mac/dialog.c'\"
- else
- echo shar: Extracting \"'Ports/mac/dialog.c'\" \(7879 characters\)
- sed "s/^X//" >'Ports/mac/dialog.c' <<'END_OF_FILE'
- X/* MAC STDWIN -- DIALOGS. */
- X
- X/* XXX These dialogs are distinctly ugly.
- X Maybe we should fix their size based on the amount of text
- X and the number of buttons. */
- X
- X#include "macwin.h"
- X#ifdef MPW
- X#include <Dialogs.h>
- X#include <Packages.h>
- X#endif
- X#ifdef THINK_C
- X#include <DialogMgr.h>
- X#include <StdFilePkg.h>
- X#endif
- X
- X/* Function prototypes */
- X
- XSTATIC struct itemlist **mkitemlist _ARGS((void));
- XSTATIC struct item *finditem _ARGS((struct itemlist **h, int i));
- XSTATIC void additem _ARGS((struct itemlist **h,
- X long stuff, Rect *ppos, int type, int size, char *data));
- XSTATIC struct itemlist **ynclist _ARGS((char *prompt));
- XSTATIC struct itemlist **oklist _ARGS((char *prompt));
- XSTATIC struct itemlist **editlist _ARGS((char *prompt));
- XSTATIC int do_dialog _ARGS((struct itemlist **h,
- X int emphasis, int lastbutton, char *buf));
- X
- X/* Mac-specific interface for applications that need different
- X file types */
- X
- Xextern OSType std_type;
- X
- X#ifdef THINK_C
- XOSType std_type= 'TEXT';
- X#endif
- X
- XOSType *wasktypelist= &std_type;
- Xint waskntypes= 1;
- X
- X/* Standard File interface routine */
- X
- Xbool
- Xwaskfile(prompt, buf, len, new)
- X char *prompt;
- X char *buf;
- X int len;
- X bool new;
- X{
- X static Point corner= {80, 60};
- X SFReply reply;
- X
- X if (active != NULL)
- X rmcaret(active);
- X if (new) {
- X char *def= strrchr(buf, ':');
- X if (def != NULL)
- X ++def;
- X else
- X def= buf;
- X SFPutFile(PASSPOINT corner, PSTRING(prompt),
- X#ifdef THINK_C /* XXX ??? */
- X CtoPstr(def),
- X#else
- X PSTRING(def),
- X#endif
- X (ProcPtr)NULL, &reply);
- X }
- X else {
- X SFGetFile(PASSPOINT corner, (char*)NULL, (ProcPtr)NULL,
- X waskntypes, wasktypelist, (ProcPtr)NULL, &reply);
- X }
- X set_watch();
- X if (!reply.good)
- X return FALSE;
- X fullpath(buf, reply.vRefNum, p2cstr((char*)&reply.fName));
- X return TRUE;
- X}
- X
- X/* Data definitions for dialog item lists (from Inside Mac). */
- X
- Xstruct item {
- X long stuff; /* Handle or proc pointer */
- X Rect pos; /* Position (local coord.) */
- X char type; /* Item type */
- X char size; /* Length of data; must be even */
- X char data[256]; /* The data; variable length */
- X};
- X
- Xstruct itemlist {
- X short count; /* Number of items minus one */
- X struct item data; /* First item */
- X /* NB: items are variable length. */
- X};
- X
- X#define ROUND_EVEN(x) (((x) + 1) & ~1) /* Round up to even */
- X
- X#define FIXED_SIZE 14 /* Size of struct item w/o data */
- X
- X/* Routines to manipulate Dialog item lists. */
- X
- X/* Create an empty item list. */
- X
- Xstatic struct itemlist **
- Xmkitemlist()
- X{
- X struct itemlist **h= (struct itemlist **) NewHandle(2);
- X
- X (*h)->count= -1;
- X return h;
- X}
- X
- X/* Find the i'th item, starting to count from 0.
- X It may be asked for the non-existing item just beyond the last,
- X but not beyond that. */
- X
- Xstatic struct item *
- Xfinditem(h, i)
- X struct itemlist **h;
- X int i;
- X{
- X int count= (*h)->count;
- X struct item *it= &(*h)->data;
- X int k;
- X
- X if (i < 0 || i > count+1) {
- X return NULL;
- X }
- X for (k= 0; k < i; ++k) {
- X /* I don't trust two casts in one expression: */
- X char *p= (char *) it;
- X int size= ROUND_EVEN(it->size);
- X p += FIXED_SIZE + size;
- X it= (struct item *) p;
- X }
- X return it;
- X}
- X
- X/* Add an item to the list. */
- X
- Xstatic void
- Xadditem(h, stuff, ppos, type, size, data)
- X struct itemlist **h;
- X long stuff;
- X Rect *ppos;
- X int type;
- X int size;
- X char *data;
- X{
- X struct item *it;
- X long totalsize;
- X
- X if (size < 0)
- X size= strlen(data);
- X it= finditem(h, (*h)->count + 1);
- X totalsize= (char *)it - (char *)(*h);
- X SetHandleSize(h, totalsize + FIXED_SIZE + ROUND_EVEN(size));
- X it= finditem(h, (*h)->count + 1);
- X it->stuff= stuff;
- X it->pos= *ppos;
- X it->type= type;
- X it->size= size;
- X BlockMove(data, it->data, size);
- X ++(*h)->count;
- X}
- X
- X/* Construct item list for question w/ Yes/No/Cancel response.
- X Note: the statText item is first, so we can distinguish between a
- X press on Return or Enter (when ModalDialog returns 1) and any
- X of the three buttons. */
- X
- Xstatic struct itemlist **
- Xynclist(prompt)
- X char *prompt;
- X{
- X struct itemlist **h= mkitemlist();
- X Rect pos;
- X
- X SetRect(&pos, 20, 20, 280, 70);
- X additem(h, 0L, &pos, statText|itemDisable, -1, prompt);
- X SetRect(&pos, 20, 80, 80, 100);
- X additem(h, 0L, &pos, ctrlItem|btnCtrl, -1, "Yes");
- X OffsetRect(&pos, 0, 30);
- X additem(h, 0L, &pos, ctrlItem|btnCtrl, -1, "No");
- X OffsetRect(&pos, 200, 0);
- X additem(h, 0L, &pos, ctrlItem|btnCtrl, -1, "Cancel");
- X return h;
- X}
- X
- X/* Construct item list for message w/ OK button. */
- X
- Xstatic struct itemlist **
- Xoklist(prompt)
- X char *prompt;
- X{
- X struct itemlist **h= mkitemlist();
- X Rect pos;
- X
- X SetRect(&pos, 20, 20, 280, 100);
- X additem(h, 0L, &pos, statText|itemDisable, -1, prompt);
- X SetRect(&pos, 20, 110, 80, 130);
- X additem(h, 0L, &pos, ctrlItem|btnCtrl, -1, "OK");
- X return h;
- X}
- X
- X/* Construct item list for dialog w/ edit-text, OK and Cancel button. */
- X
- Xstatic struct itemlist **
- Xeditlist(prompt)
- X char *prompt;
- X{
- X struct itemlist **h= mkitemlist();
- X Rect pos;
- X
- X SetRect(&pos, 20, 20, 280, 70);
- X additem(h, 0L, &pos, statText|itemDisable, -1, prompt);
- X SetRect(&pos, 20, 110, 80, 130);
- X additem(h, 0L, &pos, ctrlItem|btnCtrl, -1, "OK");
- X OffsetRect(&pos, 200, 0);
- X additem(h, 0L, &pos, ctrlItem|btnCtrl, -1, "Cancel");
- X SetRect(&pos, 20, 80, 280, 96);
- X additem(h, 0L, &pos, editText, 0, (char *) NULL);
- X return h;
- X}
- X
- X/* Perform an entire dialog.
- X It stops when an item <= lastbutton is hit, and returns the item number.
- X When buf is non-NULL, the next item is assumed to be an edit-text
- X item and its contents are transferred to buf. */
- X
- Xstatic int
- Xdo_dialog(h, emphasis, lastbutton, buf)
- X struct itemlist **h;
- X int emphasis;
- X int lastbutton;
- X char *buf;
- X{
- X Rect box;
- X DialogPtr d;
- X short hit;
- X short type;
- X Handle item;
- X
- X _wresetmouse(); /* Clean up mouse down status */
- X if (active != NULL)
- X rmcaret(active);
- X
- X /* Create a box of convenient size, centered horizontally,
- X somewhat below the top of the screen. */
- X SetRect(&box, 0, 0, 300, 140);
- X OffsetRect(&box, (screen->portRect.right - box.right)/2, 60);
- X
- X d= NewDialog(
- X (Ptr)NULL,
- X &box,
- X "",
- X true,
- X dBoxProc,
- X (WindowPtr)(-1),
- X false,
- X 0L,
- X h);
- X
- X if (emphasis > 0) { /* Emphasize default button */
- X GetDItem(d, emphasis, &type, &item, &box);
- X SetPort(d);
- X InsetRect(&box, -4, -4);
- X PenSize(3, 3);
- X FrameRoundRect(&box, 16, 16);
- X }
- X
- X if (buf != NULL) { /* Set edit text and focus on entire text */
- X GetDItem(d, lastbutton+1, &type, &item, &box);
- X SetIText(item, PSTRING(buf));
- X SelIText(d, lastbutton+1, 0, 32000);
- X }
- X
- X set_arrow();
- X
- X /* XXX Should support Cmd-period as shortcut for Cancel;
- X perhaps other shortcuts as well? */
- X
- X do {
- X ModalDialog((ProcPtr)NULL, &hit);
- X } while (hit > lastbutton);
- X
- X set_watch();
- X
- X if (hit == 1 && emphasis > 0) {
- X /* Pressed Return or Enter; flash default button. */
- X GetDItem(d, emphasis, &type, &item, &box);
- X HiliteControl((ControlHandle)item, inButton);
- X }
- X
- X if (buf != NULL) {
- X GetDItem(d, lastbutton+1, &type, &item, &box);
- X GetIText(item, buf);
- X#ifndef CLEVERGLUE
- X PtoCstr(buf);
- X#endif
- X }
- X DisposDialog(d);
- X return hit;
- X}
- X
- Xvoid
- Xwmessage(prompt)
- X char *prompt;
- X{
- X do_dialog(oklist(prompt), 2, 2, (char *)NULL);
- X}
- X
- Xint
- Xwaskync(prompt, def)
- X char *prompt;
- X{
- X int emphasis;
- X int hit;
- X
- X switch (def) {
- X case 1:
- X emphasis= 2;
- X break;
- X case 0:
- X emphasis= 3;
- X break;
- X default:
- X emphasis= 4;
- X break;
- X }
- X
- X hit= do_dialog(ynclist(prompt), emphasis, 4, (char *) NULL);
- X
- X switch (hit) {
- X default: /* case 1: Return or Enter pressed */
- X return def;
- X case 2: /* Yes button */
- X return 1;
- X case 3: /* No button */
- X return 0;
- X case 4: /* Cancel button */
- X return -1;
- X }
- X}
- X
- Xbool
- Xwaskstr(prompt, buf, len)
- X char *prompt;
- X char *buf;
- X int len;
- X{
- X /* This code assumes 'buf' is at least 256 bytes long! */
- X return do_dialog(editlist(prompt), 2, 3, buf) <= 2;
- X}
- X
- Xvoid
- Xwperror(name)
- X char *name;
- X{
- X char buf[256];
- X char *p= buf;
- X
- X if (name != NULL) {
- X strcpy(p, name);
- X strcat(p, ": ");
- X p += strlen(p);
- X }
- X strcat(p, "I/O error");
- X p += strlen(p);
- X sprintf(p, " %d", errno);
- X wmessage(buf);
- X}
- END_OF_FILE
- if test 7879 -ne `wc -c <'Ports/mac/dialog.c'`; then
- echo shar: \"'Ports/mac/dialog.c'\" unpacked with wrong size!
- fi
- # end of 'Ports/mac/dialog.c'
- fi
- if test -f 'Ports/x11/draw.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Ports/x11/draw.c'\"
- else
- echo shar: Extracting \"'Ports/x11/draw.c'\" \(7803 characters\)
- sed "s/^X//" >'Ports/x11/draw.c' <<'END_OF_FILE'
- X/* X11 STDWIN -- Drawing operations */
- X
- X#include "x11.h"
- X
- X/* Window ID and Graphics Context used implicitly by all drawing operations */
- X
- Xstatic Window wid;
- Xstatic GC gc;
- Xstatic unsigned long fg, bg;
- X
- X/* Start using the given Window ID, GC, fg and bg.
- X (I had hoped to use this from the Dialog and Menu modules,
- X but this hope didn't come true.) */
- X
- Xstatic void
- X_wusewgc(awid, agc, afg, abg)
- X Window awid;
- X GC agc;
- X unsigned long afg, abg;
- X{
- X wid= awid;
- X gc= agc;
- X fg= afg;
- X bg= abg;
- X}
- X
- X/* Put the current font's ID in the current GC, if non-null.
- X Called by _wfontswitch. */
- X
- X_wgcfontswitch()
- X{
- X if (gc != 0) {
- X if (_wf->fid == 0)
- X XCopyGC(_wd, DefaultGCOfScreen(_ws), GCFont, gc);
- X else
- X XSetFont(_wd, gc, _wf->fid);
- X }
- X}
- X
- X/* Begin drawing in the given window.
- X All drawing must be executed bewteen a call to wbegindrawing
- X and one to wenddrawing; in between, no other calls to wbegindrawing
- X should occur. */
- X
- Xstatic TEXTATTR saveattr;
- X
- Xvoid
- Xwbegindrawing(win)
- X WINDOW *win;
- X{
- X _wtrace(4, "wbegindrawing(win = 0x%lx)", (long)win);
- X if (wid != 0)
- X _werror("recursive wbegindrawing");
- X _wusewgc(win->wa.wid, win->gca, win->fga, win->bga);
- X saveattr= wattr;
- X wsettextattr(&win->attr);
- X if (win->caretshown)
- X _winvertcaret(win); /* Hide caret temporarily */
- X}
- X
- X/* End drawing in the given window */
- X
- Xvoid
- Xwenddrawing(win)
- X WINDOW *win;
- X{
- X _wtrace(4, "wenddrawing(win = 0x%lx)", (long)win);
- X if (wid != win->wa.wid)
- X _werror("wrong call to enddrawing");
- X else {
- X if (win->caretshown)
- X _winvertcaret(win); /* Put it back on */
- X _wusewgc((Window)0, (GC)0, 0L, 0L); /* Clear all */
- X wsettextattr(&saveattr);
- X XFlush(_wd);
- X }
- X}
- X
- X
- X/* Text measurement functions */
- X
- X
- X/* Compute the space taken by a string when drawn in the current font */
- X
- Xint
- Xwtextwidth(str, len)
- X char *str;
- X int len;
- X{
- X if (len < 0)
- X len= strlen(str);
- X len= XTextWidth(_wf, str, len);
- X _wtrace(7, "wtextwidth: width=%d", len);
- X return len;
- X}
- X
- X/* Compute a character's width */
- X
- Xint
- Xwcharwidth(c)
- X int c;
- X{
- X char buf[2];
- X
- X buf[0]= c;
- X return wtextwidth(buf, 1);
- X}
- X
- X/* Compute the right vertical spacing for the current font */
- X
- Xint
- Xwlineheight()
- X{
- X return _wf->ascent + _wf->descent;
- X}
- X
- X/* Compute how much the baseline of the characters drawn lies below
- X the v coordinate passed to wdrawtext or wdrawchar */
- X
- Xint
- Xwbaseline()
- X{
- X return _wf->ascent;
- X}
- X
- X
- X/* Text drawing functions */
- X
- X
- X/* Draw a text string */
- X
- Xvoid
- Xwdrawtext(h, v, str, len)
- X int h, v;
- X char *str;
- X int len;
- X{
- X int right;
- X int bottom= v + wlineheight();
- X
- X if (len < 0)
- X len= strlen(str);
- X _wtrace(5, "wdrawtext(%d, %d, \"%.*s%s\", %d)",
- X h, v, len>20 ? 17 : len, len>20 ? "..." : "", str, len);
- X if (wattr.style & (INVERSE|HILITE|UNDERLINE))
- X right = h + wtextwidth(str, len);
- X if (wattr.style & (INVERSE|HILITE))
- X werase(h, v, right, bottom);
- X XDrawString(_wd, wid, gc, h, v + _wf->ascent, str, len);
- X if (wattr.style & UNDERLINE) {
- X unsigned long ulpos, ulthick;
- X if (!XGetFontProperty(_wf, XA_UNDERLINE_POSITION, &ulpos))
- X ulpos= _wf->descent/2;
- X if (!XGetFontProperty(_wf, XA_UNDERLINE_THICKNESS, &ulthick)) {
- X ulthick= _wf->descent/3;
- X CLIPMIN(ulthick, 1);
- X }
- X ulpos += v + _wf->ascent;
- X winvert(h, (int)ulpos, right, (int)(ulpos + ulthick));
- X }
- X if (wattr.style & (INVERSE|HILITE))
- X winvert(h, v, right, bottom);
- X}
- X
- Xvoid
- Xwdrawchar(h, v, c)
- X int h, v;
- X int c;
- X{
- X char ch= c;
- X
- X if ((wattr.style & (INVERSE|HILITE|UNDERLINE)) == 0) {
- X#ifdef __GNUC__
- X /* Work-around for GCC bug (1.31 or some such):
- X without the _wtrace, XdrawString is never called. */
- X _wtrace(5, "wdrawchar(%d, %d, '\\%03o')", h, v, c&0377);
- X#endif
- X /* Optimize plain characters */
- X XDrawString(_wd, wid, gc, h, v + _wf->ascent, &ch, 1);
- X }
- X else {
- X /* Use wdrawtext for complicated cases */
- X wdrawtext(h, v, &ch, 1);
- X }
- X}
- X
- X
- X/* Manipulate text attribute structs */
- X
- X
- X/* Get a window's text attributes */
- X
- Xvoid
- Xwgetwintextattr(win, pattr)
- X WINDOW *win;
- X TEXTATTR *pattr;
- X{
- X *pattr= win->attr;
- X}
- X
- X/* Change a window's text attributes */
- X
- Xvoid
- Xwsetwintextattr(win, pattr)
- X WINDOW *win;
- X TEXTATTR *pattr;
- X{
- X win->attr= *pattr;
- X}
- X
- X
- X/* Non-text drawing primitives */
- X
- X
- X/* Draw a straight line */
- X
- Xvoid
- Xwdrawline(h1, v1, h2, v2)
- X{
- X _wtrace(7, "wdrawline((h1,v1)=(%d,%d), (h2,v2)=(%d,%d))",
- X h1, v1, h2, v2);
- X XDrawLine(_wd, wid, gc, h1, v1, h2, v2);
- X}
- X
- X/* Draw a straight line in XOR mode */
- X
- Xvoid
- Xwxorline(h1, v1, h2, v2)
- X{
- X _wtrace(7, "wxorline((h1,v1)=(%d,%d), (h2,v2)=(%d,%d))",
- X h1, v1, h2, v2);
- X XSetFunction(_wd, gc, GXinvert);
- X XDrawLine(_wd, wid, gc, h1, v1, h2, v2);
- X XSetFunction(_wd, gc, GXcopy);
- X}
- X
- X/* Draw a rectangle *inside* the given coordinate box */
- X
- Xvoid
- Xwdrawbox(left, top, right, bottom)
- X{
- X _wtrace(7, "wdrawbox(left=%d, top=%d, right=%d, bottom=%d)",
- X left, top, right, bottom);
- X XDrawRectangle(_wd, wid, gc, left, top, right-left-1, bottom-top-1);
- X}
- X
- X/* Erase the given rectangle */
- X
- Xvoid
- Xwerase(left, top, right, bottom)
- X{
- X _wtrace(7, "werase(left=%d, top=%d, right=%d, bottom=%d)",
- X left, top, right, bottom);
- X
- X if (left >= right || top >= bottom)
- X return;
- X
- X /* Can't use XClearArea here because it ignores the clipping region.
- X Can't set function to GXclear because it doesn't work
- X with color. So we fill with the background color. */
- X
- X XSetForeground(_wd, gc, bg);
- X XFillRectangle(_wd, wid, gc, left, top, right-left, bottom-top);
- X XSetForeground(_wd, gc, fg);
- X}
- X
- X/* Invert the bits in the given rectangle.
- X (This uses _winvert because this function is often used internally.) */
- X
- Xvoid
- Xwinvert(left, top, right, bottom)
- X{
- X _wtrace(7, "winvert(left=%d, top=%d, right=%d, bottom=%d)",
- X left, top, right, bottom);
- X
- X if (left >= right || top >= bottom)
- X return;
- X
- X _winvert(wid, gc, left, top, right-left, bottom-top);
- X}
- X
- X/* Paint a given rectangle black */
- X
- Xvoid
- Xwpaint(left, top, right, bottom)
- X{
- X _wtrace(7, "wpaint(left=%d, top=%d, right=%d, bottom=%d)",
- X left, top, right, bottom);
- X
- X if (left >= right || top >= bottom)
- X return;
- X
- X XFillRectangle(_wd, wid, gc, left, top, right-left, bottom-top);
- X}
- X
- X/* Shade a given area; this should add a lighter or darker raster
- X depending on the darkness percentage (0 = no raster, 100 = black) */
- X
- Xvoid
- Xwshade(left, top, right, bottom, percent)
- X{
- X _wtrace(7, "wshade(left=%d, top=%d, right=%d, bottom=%d, percent=%d)",
- X left, top, right, bottom, percent);
- X
- X if (left >= right || top >= bottom)
- X return;
- X
- X /* For now, implement this as wpaint for shade percentages > 0 */
- X if (percent > 0)
- X wpaint(left, top, right, bottom);
- X}
- X
- X/* Draw a circle with given center and radius */
- X
- Xvoid
- Xwdrawcircle(h, v, radius)
- X int h, v;
- X int radius;
- X{
- X _wtrace(7, "wdrawcircle(h=%d, v=%d, radius=%d)", h, v, radius);
- X XDrawArc(_wd, wid, gc, h-radius, v-radius, 2*radius, 2*radius,
- X 0, 360*64);
- X}
- X
- X/* Draw an elliptical arc.
- X The begin and end angles are specified in degrees (I'm not sure this
- X is a good idea, but I don't like X's degrees*64 either...).
- X The arc is drawn counter-clockwise; 0 degrees is 3 o'clock.
- X wdrawcircle is equivalent to wdrawarc(h, v, radius, radius, 0, 360). */
- X
- Xvoid
- Xwdrawelarc(h, v, hhalf, vhalf, angle1, angle2)
- X int h, v; /* Center */
- X int hhalf, vhalf; /* Half axes */
- X int angle1, angle2; /* Begin, end angle */
- X{
- X _wtrace(7, "wdrawelarc(%d, %d, %d, %d, %d, %d)",
- X h, v, hhalf, vhalf, angle1, angle2);
- X XDrawArc(_wd, wid, gc, h-hhalf, v-vhalf, 2*hhalf, 2*vhalf,
- X angle1*64, angle2*64);
- X}
- X
- X/* Clip drawing output to a rectangle. */
- X
- Xvoid
- Xwcliprect(left, top, right, bottom)
- X int left, top, right, bottom;
- X{
- X XRectangle clip;
- X
- X _wtrace(7, "wcliprect(%d, %d, %d, %d)", left, top, right, bottom);
- X clip.x = left;
- X clip.y = top;
- X clip.width = right-left;
- X clip.height = bottom-top;
- X XSetClipRectangles(_wd, gc, 0, 0, &clip, 1, Unsorted);
- X}
- X
- X/* Cancel any clipping in effect. */
- X
- Xvoid
- Xwnoclip()
- X{
- X XSetClipMask(_wd, gc, None);
- X}
- END_OF_FILE
- if test 7803 -ne `wc -c <'Ports/x11/draw.c'`; then
- echo shar: \"'Ports/x11/draw.c'\" unpacked with wrong size!
- fi
- # end of 'Ports/x11/draw.c'
- fi
- echo shar: End of archive 11 \(of 19\).
- cp /dev/null ark11isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 19 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-