<HTML ><HEAD ><TITLE >GnomeCalculator</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.74b"><LINK REL="HOME" TITLE="Gnome User Interface Library Reference Manual" HREF="book1.html"><LINK REL="UP" TITLE="GNOME Widgets and Objects" HREF="gnome-objects.html"><LINK REL="PREVIOUS" TITLE="GnomeAppBar" HREF="gnomeappbar.html"><LINK REL="NEXT" TITLE="GnomeCanvas" HREF="gnomecanvas.html"></HEAD ><BODY CLASS="REFENTRY" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" BGCOLOR="#000000" CELLPADDING="1" CELLSPACING="0" ><TR ><TH COLSPAN="4" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="5" >Gnome User Interface Library Reference Manual</FONT ></TH ></TR ><TR ><TD WIDTH="25%" BGCOLOR="#C00000" ALIGN="left" ><A HREF="gnomeappbar.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><<< Previous Page</B ></FONT ></A ></TD ><TD WIDTH="25%" BGCOLOR="#0000C0" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><A HREF="book1.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Home</B ></FONT ></A ></B ></FONT ></TD ><TD WIDTH="25%" BGCOLOR="#00C000" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><A HREF="gnome-objects.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Up</B ></FONT ></A ></B ></FONT ></TD ><TD WIDTH="25%" BGCOLOR="#C00000" ALIGN="right" ><A HREF="gnomecanvas.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Next Page >>></B ></FONT ></A ></TD ></TR ></TABLE ></DIV ><H1 ><A NAME="GNOMECALCULATOR" >GnomeCalculator</A ></H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN9831" ></A ><H2 >Name</H2 >GnomeCalculator -- Calculator widget.</DIV ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN9834" ></A ><H2 >Synopsis</H2 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="SYNOPSIS" > #include <gnome.h> struct <A HREF="gnomecalculator.html#GNOMECALCULATOR-STRUCT" >GnomeCalculator</A >; enum <A HREF="gnomecalculator.html#GNOMECALCULATORMODE" >GnomeCalculatorMode</A >; <GTKDOCLINK HREF="GTKWIDGET" >GtkWidget</GTKDOCLINK >* <A HREF="gnomecalculator.html#GNOME-CALCULATOR-NEW" >gnome_calculator_new</A > (void); void <A HREF="gnomecalculator.html#GNOME-CALCULATOR-CLEAR" >gnome_calculator_clear</A > (<A HREF="gnomecalculator.html" >GnomeCalculator</A > *gc, const <GTKDOCLINK HREF="GBOOLEAN" >gboolean</GTKDOCLINK > reset); void <A HREF="gnomecalculator.html#GNOME-CALCULATOR-SET" >gnome_calculator_set</A > (<A HREF="gnomecalculator.html" >GnomeCalculator</A > *gc, <GTKDOCLINK HREF="GDOUBLE" >gdouble</GTKDOCLINK > result); #define <A HREF="gnomecalculator.html#GNOME-CALCULATOR-GET-RESULT" >gnome_calculator_get_result</A > (gc) </PRE ></TD ></TR ></TABLE ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN9848" ></A ><H2 >Object Hierarchy</H2 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="SYNOPSIS" > <GTKDOCLINK HREF="GTKOBJECT" >GtkObject</GTKDOCLINK > +----<GTKDOCLINK HREF="GTKWIDGET" >GtkWidget</GTKDOCLINK > +----<GTKDOCLINK HREF="GTKCONTAINER" >GtkContainer</GTKDOCLINK > +----<GTKDOCLINK HREF="GTKBOX" >GtkBox</GTKDOCLINK > +----<GTKDOCLINK HREF="GTKVBOX" >GtkVBox</GTKDOCLINK > +----GnomeCalculator</PRE ></TD ></TR ></TABLE ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN9856" ></A ><H2 >Description</H2 ><P > This widget provides a simple calculator that you can embed in your applications for doing quick computations.</P ><P > The widget consists of a fully functional calculator including standard arithmetic functions as well as trigonometric capabilities, exponents, factorials, nested equations, and others.</P ><DIV CLASS="REFSECT2" ><A NAME="AEN9860" ></A ><H3 ><SPAN CLASS="STRUCTNAME" >GnomeCalculator</SPAN > functions</H3 ><P >The following is a list and description of each button represented on the GnomeCalculator widget</P ><P ></P ><UL ><LI ><P > Calculations accurate to a maximum of 10 digits, or 9 decimal places.</P ></LI ><LI ><P > Numbers <TT CLASS="LITERAL" >0</TT >-<TT CLASS="LITERAL" >9</TT > for numerical input</P ></LI ><LI ><P > Decimal point for decimal calculations</P ></LI ><LI ><P > +/- button for positive/negative number entry</P ></LI ><LI ><P > / for Division, * for Multiplication, - for Subtraction, and + for Addition</P ></LI ><LI ><P > <TT CLASS="LITERAL" >PI</TT > feature to automatically use the value of <TT CLASS="LITERAL" >PI</TT > at the touch of a button</P ></LI ><LI ><P > <TT CLASS="LITERAL" >X</TT >! calculates the factorial for the current resultant</P ><P >i.e: If resultant is 5, 5 factorial is 5*4*3*2*1 = 120</P ></LI ><LI ><P > ( and )</P ><P >Parenthesis used to force grouping of expressions to be evaluated in a certain order.</P ><P >5 + 6 * 8 = 53 is ambiguous, if you really meant to add 5 + 6 together first.</P ><P >Use (5 + 6) * 8 = 88, to make sure your meaning is understood</P ></LI ><LI ><P > The <TT CLASS="LITERAL" >DEG</TT > or <TT CLASS="LITERAL" >RAD</TT > 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 <TT CLASS="LITERAL" >PI</TT >/2, 180 degrees is <TT CLASS="LITERAL" >PI</TT >, 270 degrees is 3 PI/2, and 360 degrees is 2 <TT CLASS="LITERAL" >PI</TT >.</P ></LI ><LI ><P > <TT CLASS="LITERAL" >C</TT > will clear the current result value. <TT CLASS="LITERAL" >AC</TT > will clear the current result, but will also clear all values stored in memory.</P ></LI ></UL ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN9901" ></A ><H3 >Memory Functions</H3 ><P >The following are <SPAN CLASS="STRUCTNAME" >GnomeCalculator</SPAN > widget's memory functions</P ><P ></P ><UL ><LI ><P > <TT CLASS="LITERAL" >STO</TT > stores the current result in the display into memory.</P ></LI ><LI ><P > <TT CLASS="LITERAL" >RCL</TT > will take the value stored in memory, and display it in the resultant.</P ></LI ><LI ><P > <TT CLASS="LITERAL" >SUM</TT > 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.</P ></LI ><LI ><P > <TT CLASS="LITERAL" >EXC</TT > will take the current value in memory and exchange it with the current resultant. The previous current result will be placed back in memory.</P ></LI ></UL ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN9918" ></A ><H3 >Exponential functions</H3 ><P >The following are <SPAN CLASS="STRUCTNAME" >GnomeCalculator</SPAN > widget's exponential functions</P ><P ></P ><UL ><LI ><P > <TT CLASS="LITERAL" >SQRT</TT > raises the current value to the 1/2 power. This is the opposite of squaring the number, seen below.</P ><P >For example, the SQRT of 4 is 4^(1/2) = 2.</P ></LI ><LI ><P > <TT CLASS="LITERAL" >EE</TT > is used for scientific notation. Use this for manipulating numbers such as 1e+50, 9e+10, and so forth.</P ></LI ><LI ><P > <TT CLASS="LITERAL" >x</TT >^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.</P ></LI ><LI ><P > <TT CLASS="LITERAL" >x</TT >^y is used to take a number and raise it to the power of the 2nd number.</P ><P >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.</P ></LI ></UL ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN9937" ></A ><H3 >Trigonometric functions</H3 ><P ></P ><UL ><LI ><P > <TT CLASS="LITERAL" >SIN</TT > calculates the trigonometric sine function on the current value</P ></LI ><LI ><P > <TT CLASS="LITERAL" >COS</TT > calculates the trigonometric cosine function on the current value</P ></LI ><LI ><P > <TT CLASS="LITERAL" >TAN</TT > calculates the trigonometric tangent function on the current value</P ></LI ><LI ><P > The <TT CLASS="LITERAL" >INV</TT > button will reversie the previous three trig functions. If the <TT CLASS="LITERAL" >INV</TT > button is pressed, the <TT CLASS="LITERAL" >SIN</TT > button will instead calculate the Inverse-Sine. <TT CLASS="LITERAL" >COS</TT > will calculate the Inverse-Cosine, and the <TT CLASS="LITERAL" >TAN</TT > will calculate the Inverse-Tangent.</P ></LI ></UL ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN9956" ></A ><H2 >Details</H2 ><DIV CLASS="REFSECT2" ><A NAME="AEN9958" ></A ><H3 ><A NAME="GNOMECALCULATOR-STRUCT" ></A >struct GnomeCalculator</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >struct GnomeCalculator;</PRE ></TD ></TR ></TABLE ><P ></P ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN9963" ></A ><H3 ><A NAME="GNOMECALCULATORMODE" ></A >enum GnomeCalculatorMode</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >typedef enum { GNOME_CALCULATOR_DEG, GNOME_CALCULATOR_RAD, GNOME_CALCULATOR_GRAD } GnomeCalculatorMode;</PRE ></TD ></TR ></TABLE ><P > The way in which degrees are handled by the calculator, possible values include: <TT CLASS="LITERAL" >GNOME_CALCULATOR_DEG</TT >, <TT CLASS="LITERAL" >GNOME_CALCULATOR_DEG</TT >, <TT CLASS="LITERAL" >GNOME_CACLULATOR_DRAG</TT >.</P ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN9971" ></A ><H3 ><A NAME="GNOME-CALCULATOR-NEW" ></A >gnome_calculator_new ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" ><GTKDOCLINK HREF="GTKWIDGET" >GtkWidget</GTKDOCLINK >* gnome_calculator_new (void);</PRE ></TD ></TR ></TABLE ><P >Creates a calculator widget, a window with all the common buttons and functions found on a standard pocket calculator.</P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN9978" ></A ><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Returns</I ></SPAN > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" >Pointer to newly-created calculator widget.</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN9987" ></A ><H3 ><A NAME="GNOME-CALCULATOR-CLEAR" ></A >gnome_calculator_clear ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >void gnome_calculator_clear (<A HREF="gnomecalculator.html" >GnomeCalculator</A > *gc, const <GTKDOCLINK HREF="GBOOLEAN" >gboolean</GTKDOCLINK > reset);</PRE ></TD ></TR ></TABLE ><P >Resets the calculator back to zero. If <TT CLASS="PARAMETER" ><I >reset</I ></TT > is <TT CLASS="LITERAL" >TRUE</TT >, results stored in memory and the calculator mode are cleared also.</P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN9997" ></A ><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >gc</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Pointer to GNOME calculator widget.</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >reset</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > <TT CLASS="LITERAL" >FALSE</TT > to zero, <TT CLASS="LITERAL" >TRUE</TT > to reset calculator completely</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN10012" ></A ><H3 ><A NAME="GNOME-CALCULATOR-SET" ></A >gnome_calculator_set ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >void gnome_calculator_set (<A HREF="gnomecalculator.html" >GnomeCalculator</A > *gc, <GTKDOCLINK HREF="GDOUBLE" >gdouble</GTKDOCLINK > result);</PRE ></TD ></TR ></TABLE ><P >Sets the value stored in the calculator's result buffer to the given <TT CLASS="PARAMETER" ><I >result</I ></TT >.</P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN10021" ></A ><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >gc</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Pointer to GNOME calculator widget.</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >result</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > New value of calculator buffer.</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN10034" ></A ><H3 ><A NAME="GNOME-CALCULATOR-GET-RESULT" ></A >gnome_calculator_get_result()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >#define gnome_calculator_get_result(gc)</PRE ></TD ></TR ></TABLE ><P ></P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN10040" ></A ><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >gc</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Pointer to GNOME calculator widget</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Returns</I ></SPAN > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" >Value currently stored in calculator buffer.</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN10053" ></A ><H2 >See Also</H2 ><P > <A HREF="gnomenumberentry.html" >GnomeNumberEntry</A ></P ></DIV ><DIV CLASS="NAVFOOTER" ><BR CLEAR="all"><BR><TABLE WIDTH="100%" BORDER="0" BGCOLOR="#000000" CELLPADDING="1" CELLSPACING="0" ><TR ><TD WIDTH="25%" BGCOLOR="#C00000" ALIGN="left" ><A HREF="gnomeappbar.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><<< Previous Page</B ></FONT ></A ></TD ><TD WIDTH="25%" BGCOLOR="#0000C0" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><A HREF="book1.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Home</B ></FONT ></A ></B ></FONT ></TD ><TD WIDTH="25%" BGCOLOR="#00C000" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><A HREF="gnome-objects.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Up</B ></FONT ></A ></B ></FONT ></TD ><TD WIDTH="25%" BGCOLOR="#C00000" ALIGN="right" ><A HREF="gnomecanvas.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Next Page >>></B ></FONT ></A ></TD ></TR ><TR ><TD COLSPAN="2" ALIGN="left" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >GnomeAppBar</B ></FONT ></TD ><TD COLSPAN="2" ALIGN="right" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >GnomeCanvas</B ></FONT ></TD ></TR ></TABLE ></DIV ></BODY ></HTML >