Google

NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.52">

GnomeCalculator

Name

GnomeCalculator -- Calculator widget.

Synopsis


#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)

Object Hierarchy


  GtkObject
   +----GtkWidget
         +----GtkContainer
               +----GtkBox
                     +----GtkVBox
                           +----GnomeCalculator

Description

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.

GnomeCalculator functions

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.


Memory Functions

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.


Exponential functions

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.


Trigonometric functions

  • 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.

Details

struct GnomeCalculator

struct GnomeCalculator;


enum GnomeCalculatorMode

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.


gnome_calculator_new ()

GtkWidget*  gnome_calculator_new            (void);

Creates a calculator widget, a window with all the common buttons and functions found on a standard pocket calculator.

Returns :Pointer to newly-created calculator widget.


gnome_calculator_clear ()

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.

gc : Pointer to GNOME calculator widget.
reset : FALSE to zero, TRUE to reset calculator completely


gnome_calculator_set ()

void        gnome_calculator_set            (GnomeCalculator *gc,
                                             gdouble result);

Sets the value stored in the calculator's result buffer to the given result.

gc : Pointer to GNOME calculator widget.
result : New value of calculator buffer.


gnome_calculator_get_result()

#define     gnome_calculator_get_result(gc)

gc : Pointer to GNOME calculator widget
Returns :Value currently stored in calculator buffer.