.TH xcalc "" "" "X Client"
.PC "Scientific calculator for X"
\fBxcalc [\-stipple] [\-rpn] [\-\fItoolkitoption...\^\fB]\fR
.PP
.HS
.SH Options:
.IC "\fB\-bd \fIcolor\fR"
Set the color of the border to \fIcolor\fR
.IC "\fB\-bg \fIcolor\fR"
Set the color of the background to \fIcolor\fR
.IC "\fB\-bw \fIpixels\fR"
Set the width of the border to \fIpixels\fR
.IC "\fB\-display \fIhost\^\fB[:\fIserver\^\fB][.\fIscreen\^\fB]\fR"
Display the client's window on screen number \fIscreen\fR
of \fIserver\fR on host system \fIhost\fR
.IC "\fB\-fg \fIcolor\fR"
Set the color of the foreground to \fIcolor\fR
.IC "\fB\-fn \fIfont\fR"
Use \fIfont\fR in the display
.IC "\fB\-geometry \fIgeometry\fR"
Set the geometry of the program's window to \fIgeometry\fR
.IP \fB\-rpn\fR
Use reverse Polish notation
.IC \fB\-rv\fR
Simulate reverse video by exchanging the foreground and background colors
.IC \fB\-stipple\fR
Draw the background of the calculator
as a stipple of the foreground and background colors
.IC "\fB\-xrm \fIresourcestring\fR"
Use \fIresourcestring\fR to define a resource
.HE
.II "TI-30"
.II "HP-10C"
The X client
.B xcalc
emulates the Texas Instruments (TI) 30 and Hewlett-Packard (HP) 10C
scientific calculators.
.PP
.B xcalc
recognizes the following command-line options:
.IP "\fB\-bd \fIcolor\fR" 0.75i
Set the color of the border to
.IR color .
.IP "\fB\-bg \fIcolor\fR"
Set the color of the background to
.IR color .
.IP "\fB\-bw \fIpixels\fR"
Set the width of the border to
.IR pixels .
.IP "\fB\-display \fIhost\^\fB[:\fIserver\^\fB][.\fIscreen\^\fB]\fR"
Display the client's window on screen number
.I screen
of
.I server
on host system
.IR host .
.IP "\fB\-fg \fIcolor\fR"
Set the color of the foreground to
.IR color .
.IP "\fB\-fn \fIfont\fR"
Use
.I font
in the display.
.IP "\fB\-geometry \fIgeometry\fR"
Set the geometry of the program's window to
.IR geometry .
The term ``geometry'' means the dimensions of the window and its location
on the screen.
.I geometry
has the form \fIwidth\(muheight\(+-xoffset\(+-yoffset\fR.
.IP \fB\-rpn\fR
Use reverse Polish notation.
In this mode, the calculator looks and behaves like an HP-10C.
Without this flag, it emulates a TI-30.
.IP \fB\-rv\fR
Simulate reverse video by exchanging the foreground and background colors.
.IP \fB\-stipple\fR
Draw the background of the calculator
as a stipple of the foreground and background colors.
On monochrome displays, this improves the appearance.
.IP "\fB\-xrm \fIresourcestring\fR"
Use
.I resourcestring
to define a resource.
.SH "Key Operations"
When you invoke
.BR xcalc ,
it displays a picture of a scientific calculator on your
screen \(em of an HP-10C if you use the command-line option
.BR \-rpn ,
or of a TI-30 if you did not.
To operate the virtual calculator,
move the mouse cursor to the key you wish to press,
and then punch the left mouse button.
Some operations can also be invoked by pressing
appropriate keys on the keyboard.
To quit, move the mouse cursor to key \fK(AC)\fR
(on the TI calculator)
or the key \fK(ON)\fR
(on the TI calculator), and press the right mouse button.
.PP
The following shows the TI calculator, which is the default:
.PH 1 1 \*(XD/xcalc.eps
The following two sections describe the two virtual calculators in detail.
.SH "Calculator Keys \(em TI Mode"
The number keys and the keys
.DS
	\fK(+/-)\fR  \fK(+)\fR  \fK(-)\fR  \fK(*)\fR  \fK(/)\fR  \fK(=)\fR
.DE
.PP
do exactly what you expect them to do.
The operators obey the standard rules of precedence.
Thus, pressing the key sequence
.DS
	\fK(3)\fR  \fK(+)\fR  \fK(4)\fR  \fK(*)\fR  \fK(5)\fR  \fK(=)\fR
.DE
.PP
produces 23, not 35.
You can use parentheses to override this.
.PP
You can select the entire number in the calculator's display,
to paste the result of a calculation into text.
.PP
The following describes what happens when you click the function keys on
the virtual calculator.
These are useful if you are interested in defining a customized calculator.
.IP "\fK(0)\fR through \fK(9)\fR"
Each digit key is linked to function \fBdigit(\fIn\fB)\fR, where
.I n
is the corresponding digit, 0 through 9.
.IP \fK(1/x)\fR
Replace the number in the display with its reciprocal.
The corresponding procedure is
.BR reciprocal() .
.IP \fK(x^2)\fR
Square the number in the display.
The corresponding procedure is
.BR square() .
.IP \fK(SQRT)\fR
Compute the square root of the number in the display.
The corresponding procedure is
.BR squareRoot() .
.IP \fK(CE/C)\fR
When pressed once, clear the number in the display without clearing the state
of the machine.
This lets you re-enter a number if you make a mistake.
Pressing it twice also clears the state.
The corresponding procedure for TI mode is
.BR clear() .
.IP \fK(AC)\fR
Clear the display, the state, and the memory.
Pressing it with the right mouse button ``turns off'' the calculator,
which exits you from the program.
The action procedure to clear the state is
.BR off() ;
to quit,
.BR quit() .
.IP \fK(INV)\fR
Invert function.
See the individual function keys for details.
The corresponding procedure is
.BR inverse() .
.IP \fK(sin)\fR
Compute the sine of the number in the display, as interpreted by the current
DRG mode (see the description of the key \fK(DRG)\fR, below).
If inverted, it computes the arcsine.
The corresponding procedure is \fBsine()\fR.
.IP \fK(cos)\fR
Computes the cosine, or arccosine when inverted.
The corresponding procedure is \fBcosine()\fP.
.IP \fK(tan)\fR
Compute the tangent, or arctangent when inverted.
The corresponding procedure is \fBtangent()\fP.
.IP \fK(DRG)\fR
Change the DRG mode, as indicated by the fields
.BR DEG ,
.BR RAD ,
or
.B GRAD
at the bottom of of the calculator ``liquid crystal'' display.
When in
.B DEG
mode, numbers in the display are taken as being degrees.
In
.B RAD
mode, numbers are in radians.
In
.B GRAD
mode, numbers are in grads.
When inverted, the
.B DRG
key converts degrees to radians to grads.
.IP
For example, to put the calculator into
.B DEG
mode, press the key sequence:
.DS
	\fK(4)\fR  \fK(5)\fR  \fK(INV)\fR  \fK(DRG)\fR
.DE
.IP
The display shows
.BR .78539816 ,
which is 45\(de converted to radians.
The corresponding procedure is \fBdegree()\fR.
.IP \fK(e)\fR
The constant
.IR e .
The corresponding procedure is \fBe()\fR.
.IP \fK(EE)\fR
Enter exponential numbers.
For example, to get
.BR \-2.3E-4 ,
press the key sequence:
.DS
	\fK(2)\fR  \fK(\XB7)\fR  \fK(3)\fR  \fK(+)\fR  \fK(EE)\fR  \fK(4)\fR  \fK(+)\fR
.DE
.IP
The corresponding procedure is \fBscientific()\fR.
.IP \fK(log)\fR
Calculates the logarithm (base 10) of the number in the display.
When inverted, it raises 10.0 to the power of the number in the display.
For example, entering the key sequence
.DS
	\fK(3)\fR  \fK(INV)\fR  \fK(log)\fR
.DE
.IP	
1000 appears on the display.
The corresponding procedure is \fBlogarithm()\fP.
.IP \fK(ln)\fR
Calculate the natural logarithm (base \fIe\fR) of the number in the display.
When inverted, it raises \fIe\fR to the number in the display.
For example, pressing the key sequence
.DS
	\fK(e)\fR   \fK(ln)\fR
.DE
.IP
shows 1 in the display.
The corresponding procedure is \fBnaturalLog()\fR.
.IP \fK(y^x)\fR
Raise the number on the left to the power of the number on the right.
For example, pressing the key sequence:
.DS
	\fK(2)\fR  \fK(y^x)\fR  \fK(3)\fR  \fK(=)\fR
.DE
.IP
results in 8, which is two raised to the third power.
For a further example, the key sequence:
.DS
	\fK(\XAB)\fR  \fK(1)\fR  \fK(+)\fR  \fK(2)\fR  \fK(+)\fR  \fK(3)\fR  \fK(\XBB)\fR  \fK(y^x)\fR  \fK(\XAB)\fR  \fK(1)\fR  \fK(+)\fR  \fK(2)\fR  \fK(\XBB)\fR  \fK(=)\fR
.DE
.IP
equals
.DS
	\fK(6)\fR  \fK(y^x)\fR  \fK(3)\fR
.DE
.IP
which equals 216.
The corresponding procedure is \fBpower()\fR.
.IP \fK(PI)\fR
The constant \(*p.
The corresponding procedure is \fBpi()\fR.
.IP \fK(x!)\fR
Compute the factorial of the number in the display.
The number in the display must be an integer in the range 0 through 500 \(em
although, depending on whether you have a mathematics coprocessor,
.B xcalc
might overflow long before that.
The corresponding procedure is \fBfactorial()\fR.
.IP \fK(\XAB)\fR
Left parenthesis.
The corresponding procedure for TI calculators is \fBleftParen()\fR.
.IP \fK(\XBB)\fR
Right parenthesis.
The corresponding procedure for TI calculators is \fBrightParen()\fR.
.IP \fK(/)\fR
Division.
The corresponding procedure is \fBdivide()\fR.
.IP \fK(*)\fR
Multiplication.
The corresponding procedure is \fBmultiply()\fR.
.IP \fK(-)\fR
Subtraction.
The corresponding procedure is \fBsubtract()\fR.
.IP \fK(+)\fR
Addition.
The corresponding procedure is \fBadd()\fR.
.IP \fK(STO)\fR
Store:
copy the number in the display in system memory.
The corresponding procedure is \fBstore()\fR.
.IP \fK(RCL)\fR
Recall:
copy the number from memory to the display.
The corresponding procedure is \fBrecall()\fR.
.IP \fK(SUM)\fR
Add the number in the display to the number in memory.
The corresponding procedure is \fBsum()\fR.
.IP \fK(EXC)\fR
Swap the number in the display with the number in memory.
The corresponding procedure for the TI calculator is \fBexchange()\fR.
.IP \fK(.)\fR
Decimal point.
The action procedure is \fBdecimal()\fP.
.IP \fK(+/-)\fR
Negate:
change sign.
The corresponding procedure is \fBnegate()\fR.
.IP \fK(=)\fR
Perform calculation.
The TI-specific action procedure is \fBequal()\fR.
.SH "Calculator Keys \(em HP Mode"
The number keys and the keys
.DS
	\fK(CHS)\fR  \fK(+)\fR  \fK(-)\fR  \fK(*)\fR  \fK(/)\fR  \fK(=)\fR  \fK(ENTR)\fR
.DE
.PP
do exactly what you expect them to do.
Many of the remaining keys are the same as in TI mode.
The differences are detailed below.
.IP \fK(ENTR)\fR
Enter:
execute the key sequence just entered.
The corresponding procedure is \fBenter()\fR.
.IP \fK(<-)\fR
Backspace:
erase from the display the last number key pressed.
Inverse backspace clear the X register.
The corresponding procedure is \fBback()\fR.
.IP \fK(ON)\fR
Clear the display, the state, and the memory.
Clicking it with the right mouse button turns off the calculator.
To clear the state of the virtual calculator,
the procedure is \fBoff()\fR; to quit, \fBquit()\fR.
.IP \fK(INV)\fR
Invert the meaning of the function keys.
This would be the \fK(f)\fR key on an HP calculator, but
.B xcalc
does not display multiple legends on each key.
See the individual function keys for details.
.IP \fK(10^x)\fR
Raise 10.0 to power of the number in the top of the stack.
When inverted, it calculates the log (base 10) of the number in the display.
The corresponding procedure is \fBtenpower()\fR.
.IP \fK(e^x)\fR
Raise \fIe\fR to the number in the top of the stack.
When inverted,
.B xcalc
calculates the log (base \fIe\fR) of the number in the display.
The action procedure is \fBepower()\fR.
.IP \fK(STO)\fR
Copy the number in the top of the stack to a memory location.
There are ten memory locations.
The desired memory is specified by following this key with a digit key.
.IP \fK(RCL)\fR
Push the number from the specified memory location onto the stack.
.IP \fK(SUM)\fR
Add the number on top of the stack to the number in the specified
memory location.
.IP \fK(x:y)\fR
Exchange the numbers in the top two stack positions, the X and Y registers.
The corresponding procedure is \fBXexchangeY()\fR.
.IP \fK(Rv)\fR
Roll the stack downward.
When inverted, it rolls the stack upward.
The corresponding procedure is \fBroll()\fR.
.PP
Blank keys represent programming functions on the HP-10C whose functionality
has not been duplicated in
.BR xcalc .
.PP
Finally, there are two additional action procedures:
.BR bell() ,
which rings the bell;
and
.BR selection() ,
which performs a cut on the entire number in the
calculator's ``liquid crystal'' display.
.SH "Keyboard Accelerators"
Accelerators are shortcuts for entering commands.
By pressing one key on your keyboard, you can invoke an
.B xcalc
function that might require clicking several keys on the virtual calculator.
Even though the word ``calculator'' is descended from the Greek word for
``pebble,'' you may prefer not to have to program computations by shoving
a rock around on your desk.
.PP
.B xcalc
provides some sample keyboard accelerators;
you can also customize accelerators on your own.
The numeric keypad accelerators provided by
.B xcalc
should be intuitively correct.
The following gives the accelerators that
.B xcalc
defines:
.DM
.ta 0.25i 1.25i 2.25i 3.25i 4.25i
			\fIKeyboard\fR
	\fITI Key	HP Key	Accelerator	TI Function	HP Function\fR
.sp \n(pDu
	\fK(SQRT)\fR	\fK(SQRT)\fR	\fK(r)\fR	\fBsquareRoot()\fR	\fBsquareRoot()\fR
.sp 2p
	\fK(AC)\fR	\fK(ON)\fR	\fK(space)\fR	\fBclear()\fR	\fBclear()\fR
.sp 2p
	\fK(AC)\fR	\fK(<-)\fR	\fK(Del)\fR	\fBclear()\fR	\fBback()\fR
.sp 2p
	\fK(AC)\fR	\fK(<-)\fR	\fK(Backspace)\fR	\fBclear()\fR	\fBback()\fR
.sp 2p
	\fK(AC)\fR	\fK(<-)\fR	\fK(ctrl-H)\fR	\fBclear()\fR	\fBback()\fR
.DE
.DM
.ta 0.25i 1.25i 2.25i 3.25i 4.25i
	\fK(AC)\fR		\fK(Clear)\fR	\fBclear()\fR
.sp 2p
	\fK(AC)\fR	\fK(ON)\fR	\fK(q)\fR	\fBquit()\fR	\fBquit()\fR
.sp 2p
	\fK(AC)\fR	\fK(ON)\fR	\fK(ctrl-C)\fR	\fBquit()\fR	\fBquit()\fR
.sp 2p
	\fK(INV)\fR	\fK(i)\fR	\fK(i)\fR	\fBinverse()\fR	\fBinverse()\fR
.sp 2p
	\fK(sin)\fR	\fK(s)\fR	\fK(s)\fR	\fBsine()\fR	\fBsine()\fR
.DE
.DM
.ta 0.25i 1.25i 2.25i 3.25i 4.25i
	\fK(cos)\fR	\fK(c)\fR	\fK(c)\fR	\fBcosine()\fR	\fBcosine()\fR
.sp 2p
	\fK(tan)\fR	\fK(t)\fR	\fK(t)\fR	\fBtangent()\fR	\fBtangent()\fR
.sp 2p
	\fK(DRG)\fR	\fK(DRG)\fR	\fK(d)\fR	\fBdegree()\fR	\fBdegree()\fR
.sp 2p
	\fK(e)\fR		\fK(e)\fR	\fBe()\fR
.sp 2p
	\fK(ln)\fR	\fK(ln)\fR	\fK(l)\fR	\fBnaturalLog()\fR	\fBnaturalLog()\fR
.DE
.DM
.ta 0.25i 1.25i 2.25i 3.25i 4.25i
	\fK(y^x)\fR	\fK(y^x)\fR	\fK(^)\fR	\fBpower()\fR	\fBpower()\fR
.sp 2p
	\fK(PI)\fR	\fK(PI)\fR	\fK(p)\fR	\fBpi()\fR	\fBpi()\fR
.sp 2p
	\fK(x!)\fR	\fK(x!)\fR	\fK(!)\fR	\fBfactorial()\fR	\fBfactorial()\fR
.sp 2p
	\fK(\XAB)\fR		\fK(\XAB)\fR	\fBleftParen()\fR
.sp 2p
	\fK(\XBB)\fR		\fK(\XBB)\fR	\fBrightParen()\fR
.DE
.DM
.ta 0.25i 1.25i 2.25i 3.25i 4.25i
	\fK(/)\fR	\fK(/)\fR	\fK(/)\fR	\fBdivide()\fR	\fBdivide()\fR
.sp 2p
	\fK(*)\fR	\fK(*)\fR	\fK(*)\fR	\fBmultiply()\fR	\fBmultiply()\fR
.sp 2p
	\fK(-)\fR	\fK(-)\fR	\fK(-)\fR	\fBsubtract()\fR	\fBsubtract()\fR
.sp 2p
	\fK(+)\fR	\fK(+)\fR	\fK(+)\fR	\fBadd()\fR	\fBadd()\fR
.sp 2p
	\fK(=)\fR		\fK(=)\fR	\fBequal()\fR
.DE
.DM
.ta 0.25i 1.25i 2.25i 3.25i 4.25i
	\fK(0)\fR	\fK(0)\fR	\fK(0)\fR	\fBdigit()\fR	\fBdigit()\fR
.sp 2p
	\fK(1)\fR	\fK(1)\fR	\fK(1)\fR	\fBdigit()\fR	\fBdigit()\fR
.sp 2p
	\fK(2)\fR	\fK(2)\fR	\fK(2)\fR	\fBdigit()\fR	\fBdigit()\fR
.sp 2p
	\fK(3)\fR	\fK(3)\fR	\fK(3)\fR	\fBdigit()\fR	\fBdigit()\fR
.sp 2p
	\fK(4)\fR	\fK(4)\fR	\fK(4)\fR	\fBdigit()\fR	\fBdigit()\fR
.DE
.DM
.ta 0.25i 1.25i 2.25i 3.25i 4.25i
	\fK(5)\fR	\fK(5)\fR	\fK(5)\fR	\fBdigit()\fR	\fBdigit()\fR
.sp 2p
	\fK(6)\fR	\fK(6)\fR	\fK(6)\fR	\fBdigit()\fR	\fBdigit()\fR
.sp 2p
	\fK(7)\fR	\fK(7)\fR	\fK(7)\fR	\fBdigit()\fR	\fBdigit()\fR
.sp 2p
	\fK(8)\fR	\fK(8)\fR	\fK(8)\fR	\fBdigit()\fR	\fBdigit()\fR
.sp 2p
	\fK(9)\fR	\fK(9)\fR	\fK(9)\fR	\fBdigit()\fR	\fBdigit()\fR
.DE
.DM
.ta 0.25i 1.25i 2.25i 3.25i 4.25i
	\fK(.)\fR	\fK(.)\fR	\fK(.)\fR	\fBdecimal()\fR	\fBdecimal()\fR
.sp 2p
	\fK(+/-)\fR	\fK(CHS)\fR	\fK(n)\fR	\fBnegate()\fR	\fBnegate()\fR
.sp 2p
		\fK(x:y)\fR	\fK(x)\fR		\fBXexchangeY()\fR
.sp 2p
		\fK(ENTR)\fR	\*(RT		\fBenter()\fR
.sp 2p
		\fK(ENTR)\fR	\fK(ctrl-J)\fR		\fBenter()\fR
.DE
.SH Customization
The application class name is
.BR XCalc .
.PP
.B xcalc
has an enormous application defaults file that specifies
the position, label, and function of each key on the calculator,
and gives translations to serve as keyboard accelerators.
Because these resources are not specified in the source code, you can create
a customized calculator by writing a private application defaults file,
using the Athena Command and Form widget resources to specify the size and
position of buttons, the label for each button, and the function of each button.
.PP
You can specify the foreground and background colors of each
calculator key.
For the TI calculator, a classical color resource specification resembles:
.DM
	XCalc.ti.Command.background:  gray50
	XCalc.ti.Command.foreground:  white
.DE
.PP
For each of buttons 20, 25, 30, 35, and 40, specify:
.DM
	XCalc.ti.button20.background:  black
	XCalc.ti.button20.foreground:  white
.DE
.PP
For each of buttons 22, 23, 24, 27, 28, 29, 32, 33, 34, 37, 38, and 39:
.DM
	XCalc.ti.button22.background:  white
	XCalc.ti.button22.foreground:  black
.DE
.\".SH "Widget Hierarchy"
.\"The following gives the hierarchical structure of the widgets used by
.\".BR xcalc .
.\"The widget class name is given first, followed by the widget instance name:
.\".DM
.\"XCalc xcalc
.\"	Form  ti  \fIor\fP  hp    \fI(the name depends on the mode)\fP
.\"		Form  bevel
.\"			Form  screen
.\"				Label  M
.\"				Toggle  LCD
.\"				Label  INV
.\"				Label  DEG
.\"				Label  RAD
.\"				Label  GRAD
.\"				Label  P
.\".DE
.\".DM
.\"		Command  button1
.\"		Command  button2
.\"		Command  button3
.\"			...
.\"		Command  button38
.\"		Command  button39
.\"		Command  button40
.\".DE
.SH "Application Resources"
The following lists the resources used by
.BR xcalc :
.IP "\fBrpn (\fRClass \fBRpn)\fR"
Use
.B rpn
mode.
The default is TI mode.
Same as the command-line option
.BR \-rpn .
.IP "\fBstipple (\fRClass \fBStipple)\fR"
Stipple the background.
The default is
.B on
for monochrome displays, and
.B off
for color displays.
Same as the command-line option
.BR \-stipple .
.IP "\fBcursor (\fRClass \fBCursor)\fR"
The name of the symbol used to represent the pointer.
The default is
.BR hand2 .
.SH Colors
If you want
.B xcalc
to use its TI color palette, include the following in the
.B "#ifdef COLOR"
section of the file you read with
.BR xrdb :
.DM
	*customization:                 -color
.DE
.PP
This tells
.B xcalc
to pick up the colors in the application-defaults color customization file
.BR /usr/X11/lib/app-defaults/XCalc-color .
.SH "See Also"
.B 
X clients
.R
.SH Notes
Copyright \(co 1988, 1989, Massachusetts Institute of Technology.
.PP
.II "Bradley, John"
.II "Rosenstein, Mark"
.II "Converse, Donna"
.B xcalc
was written by
John Bradley of the University of Pennsylvania,
Mark Rosenstein of MIT Project Athena, and
Donna Converse of the MIT X Consortium.
