Gnome User Interface Library Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
#include <gnome.h> struct GnomeCalculator; enum GnomeCalculatorMode; GtkWidget* gnome_calculator_new (void); void gnome_calculator_clear (GnomeCalculator *gc, const gboolean reset); void gnome_calculator_set (GnomeCalculator *gc, gdouble result); #define gnome_calculator_get_result (gc) |
GtkObject +----GtkWidget +----GtkContainer +----GtkBox +----GtkVBox +----GnomeCalculator |
This widget provides a simple calculator that you can embed in your applications for doing quick computations.
The widget consists of a fully functional calculator including standard arithmetic functions as well as trigonometric capabilities, exponents, factorials, nested equations, and others.
The following is a list and description of each button represented on the GnomeCalculator widget
Calculations accurate to a maximum of 10 digits, or 9 decimal places.
Numbers 0-9 for numerical input
Decimal point for decimal calculations
+/- button for positive/negative number entry
/ for Division, * for Multiplication, - for Subtraction, and + for Addition
PI feature to automatically use the value of PI at the touch of a button
X! calculates the factorial for the current resultant
i.e: If resultant is 5, 5 factorial is 5*4*3*2*1 = 120
( and )
Parenthesis used to force grouping of expressions to be evaluated in a certain order.
5 + 6 * 8 = 53 is ambiguous, if you really meant to add 5 + 6 together first.
Use (5 + 6) * 8 = 88, to make sure your meaning is understood
The DEG or RAD button will switch between the degree or radians mode. Its often needed to measure in one mode or the other. As an example, 90 degrees is the same as PI/2, 180 degrees is PI, 270 degrees is 3 PI/2, and 360 degrees is 2 PI.
C will clear the current result value. AC will clear the current result, but will also clear all values stored in memory.
The following are GnomeCalculator widget's memory functions
STO stores the current result in the display into memory.
RCL will take the value stored in memory, and display it in the resultant.
SUM will take the current result in the display and add it to the current value stored in memory. If nothing is in the memory, the current value will be placed in memory as it is.
EXC will take the current value in memory and exchange it with the current resultant. The previous current result will be placed back in memory.
The following are GnomeCalculator widget's exponential functions
SQRT raises the current value to the 1/2 power. This is the opposite of squaring the number, seen below.
For example, the SQRT of 4 is 4^(1/2) = 2.
EE is used for scientific notation. Use this for manipulating numbers such as 1e+50, 9e+10, and so forth.
x^2 is used to square the current number. The square of a number is that same number multiplied by itself. 2^2 is 2 * 2 = 4.
x^y is used to take a number and raise it to the power of the 2nd number.
For example, entering a 3, pressing the x^y button, entering another 3 will lead to the result of 27. In other words, 3^3, or 3 * 3 * 3, or 27.
SIN calculates the trigonometric sine function on the current value
COS calculates the trigonometric cosine function on the current value
TAN calculates the trigonometric tangent function on the current value
The INV button will reversie the previous three trig functions. If the INV button is pressed, the SIN button will instead calculate the Inverse-Sine. COS will calculate the Inverse-Cosine, and the TAN will calculate the Inverse-Tangent.
typedef enum { GNOME_CALCULATOR_DEG, GNOME_CALCULATOR_RAD, GNOME_CALCULATOR_GRAD } GnomeCalculatorMode; |
The way in which degrees are handled by the calculator, possible values include: GNOME_CALCULATOR_DEG, GNOME_CALCULATOR_DEG, GNOME_CACLULATOR_DRAG.
GtkWidget* gnome_calculator_new (void); |
Creates a calculator widget, a window with all the common buttons and functions found on a standard pocket calculator.
void gnome_calculator_clear (GnomeCalculator *gc, const gboolean reset); |
Resets the calculator back to zero. If reset is TRUE, results stored in memory and the calculator mode are cleared also.
void gnome_calculator_set (GnomeCalculator *gc, gdouble result); |
Sets the value stored in the calculator's result buffer to the given result.