added: a user can change the names of variables or functions now

changed: the program uses TTMath 0.8.0 now
added: functions: from TTMath 0.8.0:        
       DegToDeg(deg, min, sec), DegToRad(deg), DegToRad(deg, min, sec),
       RadToDeg(rad), Ceil(x), Floor(x), Sqrt(x), Sinh(x), Cosh(x),
       Tanh(x) /Tgh(x)/, Coth(x) /Ctgh(x)/
added: a help
changed: from TTMath 0.8.0:
       renamed: CTan()  into Cot()  or Ctg()
       renamed: ACTan() into ACot() or ACtg()
       Factorial() has a history log now (it can remember last
       10 calculated values)
added: a directory 'help' with files of the help
added: a directory 'setup' with files needed to make an installer
       (we're using InnoSetup Compiler to make it)
fixed: the vertical size of the main window when a user uses a different size
       of the window caption (especially under the Windows XP Luna)
fixed: on Windows 9x: the program hung when a user clicks on a control 
       on the first tab (the procedure SetNextFocus(...) has been completely
       rewritten and the flag WS_EX_CONTROLPARENT on the tab dialogs has
       gone away)
fixed: when started navigating from the keyboard the program showed a wrong
       variable or a funtion in the edit dialog


git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@28 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2007-04-02 00:17:26 +00:00
parent fcd7cdbabf
commit b3d2fc5d24
30 changed files with 1285 additions and 305 deletions

View File

@ -1,11 +1,35 @@
Version 0.8.0 (2007.04.02):
* added: the del key deletes a variable or a function now
(if the focus is on the list)
* added: a user can change the names of variables or functions now
* changed: the program uses TTMath 0.8.0 now
* added: functions: from TTMath 0.8.0:
DegToDeg(deg, min, sec), DegToRad(deg), DegToRad(deg, min, sec),
RadToDeg(rad), Ceil(x), Floor(x), Sqrt(x), Sinh(x), Cosh(x),
Tanh(x) /Tgh(x)/, Coth(x) /Ctgh(x)/
* added: a help
* changed: from TTMath 0.8.0:
renamed: CTan() into Cot() or Ctg()
renamed: ACTan() into ACot() or ACtg()
Factorial() has a history log now (it can remember last
10 calculated values)
* fixed: the vertical size of the main window when a user uses a different
size of the window caption (especially under the Windows XP Luna)
* fixed: on Windows 9x: the program hung when a user clicks on a control
on the first tab
* fixed: when a user started navigating from the keyboard the program showed
a wrong variable or a funtion in the edit dialog
Version 0.7.3 (2007.03.08):
* added: the program shows some kind of errors itself
* added: checking whether an user has inserted a correct value of a variable or a function
* added: checking whether an user has inserted a correct value of a variable
or a function
* fixed: navigation from the keyboard
* changed: the esc key selects the entire input text now (in the input edit)
* added: a test when the program is being starded which checks if the coordinates of the
main window actually pointing at the valid area (for example when someone took
his configuration file into a new computer and the new computer has a smaller screen)
* added: a test when the program is being starded which checks if the
coordinates of the main window actually pointing at the valid area (for
example when someone took his configuration file into a new computer and
the new computer has a smaller screen)
Version 0.7.2 (2007.02.28):
* added buttons Sgn and Mod

19
README Normal file
View File

@ -0,0 +1,19 @@
TTCalc
TTCalc is a mathematical calculator. It has a nice user interface,
formulas for calculating can be inserted by using a keyboard or a mouse.
The result is automatically shown in a second window without using any
additional keys such as 'equal'. The program possess trigonometric
functions, inverse trigonometric functions, hyperbolic functions,
logical operators, logarithms, functions for converting between degrees
and radians and so on. Additionally the program allows the user to
define his own variables and functions. Calculations are performed by
using floating point numbers with three kind of precision, the biggest
has 288 bits for its mantissa and 96 bits for its exponent that is
about 2.551...e+11925026709067095507636213441 with 85 valid decimal
digits. The program independently allows to insert and display values
with the base (radix) from two to sixteen.
Author: Tomasz Sowa <t.sowa AnTispam slimaczek.pl>
Project page: http://sourceforge.net/projects/ttcalc
Licence: BSD (open source)

4
TODO
View File

@ -1,7 +1,7 @@
TODO TTCalc
===========
* To add some physical constants
* To make the help
* Add some physical constants

View File

@ -0,0 +1,175 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>TTCalc - arithmetic functions</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="Keyword" value="ln">
<param name="Keyword" value="log">
<param name="Keyword" value="exp">
<param name="Keyword" value="sin">
<param name="Keyword" value="cos">
<param name="Keyword" value="tan">
<param name="Keyword" value="tg">
<param name="Keyword" value="cot">
<param name="Keyword" value="ctg">
<param name="Keyword" value="asin">
<param name="Keyword" value="acos">
<param name="Keyword" value="atan">
<param name="Keyword" value="atg">
<param name="Keyword" value="acot">
<param name="Keyword" value="actg">
<param name="Keyword" value="sinh">
<param name="Keyword" value="cosh">
<param name="Keyword" value="tanh">
<param name="Keyword" value="tgh">
<param name="Keyword" value="coth">
<param name="Keyword" value="ctgh">
<param name="Keyword" value="degtodeg">
<param name="Keyword" value="degtorad">
<param name="Keyword" value="radtodeg">
<param name="Keyword" value="sqrt">
<param name="Keyword" value="factorial">
<param name="Keyword" value="abs">
<param name="Keyword" value="sgn">
<param name="Keyword" value="mod">
<param name="Keyword" value="int">
<param name="Keyword" value="round">
<param name="Keyword" value="ceil">
<param name="Keyword" value="floar">
<param name="Keyword" value="max">
<param name="Keyword" value="min">
<param name="Keyword" value="builtin functions">
</object>
</head>
<body>
<h1>Arithmetic functions</h1>
<p><strong>Note:</strong> If a function takes more than one argument, the arguments are separated with semicolon ';'.</p>
<dl>
<dt>ln(x)</dt>
<dd>This function calculates the natural logarithm of x,<br>e.g. ln(123)=4.812...</dd>
<dt>log(x; base)</dt>
<dd>This function calculates the logarithm of x with a base equal 'base'<br>e.g. log(123; 4)=3.471...</dd>
<dt>exp(x)</dt>
<dd>This function calculates the exponent of x<br>e.g. exp(20)=e^20=485165195.409...</dd>
<dt>sin(x)</dt>
<dd>This function returns the sine of x.<br>For example sin(0.8)=0.717...<br>The argument x is in radians, if you want to calculate
with degrees use the degtorad(x) function first e.g. sin(degtorad(30))=0.5 calculates the sine of 30 degrees.</dd>
<dt>cos(x)</dt>
<dd>Cosine of x<br>e.g. cos(1.3)=0.267...<br>The argument x is in radians.</dd>
<dt>tan(x) or tg(x)</dt>
<dd>Tangent of x<br>e.g. tan(3.6)=0.493...<br>The argument x is in radians.</dd>
<dt>cot(x) or ctg(x)</dt>
<dd>Cotangent of x<br>e.g. cot(2.3)=-0.893...<br>The argument x is in radians.</dd>
<dt>asin(x)</dt>
<dd>Arc sine of x<br>e.g. asin(0.7)=0.775...<br>The result is in radians. If you want the result to be in degrees use
radtodeg function e.g. radtodeg(asin(0,5))=30</dd>
<dt>acos(x)</dt>
<dd>Arc cosine of x<br>e.g. acos(0.9)=0.451...<br>The result is in radians.</dd>
<dt>atan(x) or atg(x)</dt>
<dd>Arc tangent of x<br>e.g. atan(3.3)=1.276...<br>The result is in radians.</dd>
<dt>acot(x) or actg(x)</dt>
<dd>Arc cotangent of x<br>e.g. acot(10)=0.099...<br>The result is in radians.</dd>
<dt>sinh(x)</dt>
<dd>This function returns hyperbolic sine of x<br>e.g.sinh(12)=81377.395...</dd>
<dt>cosh(x)</dt>
<dd>Hyperbolic cosine of x<br>e.g. cosh(8.5)=2457.384...</dd>
<dt>tanh(x) or tgh(x)</dt>
<dd>Hyperbolic tangent of x<br>e.g. tanh(0.67)=0.584...</dd>
<dt>coth(x) or ctgh(x)</dt>
<dd>Hyperbolic cotangent of x<br>e.g. coth(1.67)=1.073...</dd>
<dt>DegToDeg(deg; min; sec)</dt>
<dd>This function converts degrees from the long format with degres, minutes and seconds into only degrees.<br>
For example degtodeg(12; 30; 0)=12.5</dd>
<dt>DegToRad(deg)</dt>
<dd>This function converts degrees into radians<br>e.g. degtorad(12.5)=0.218166...</dd>
<dt>DegToRad(deg; min; sec)</dt>
<dd>This function converts degrees in the long format (degrees, minutes, seconds) to radians.<br>For example
degtorad(12; 30; 0)=0.218166...</dd>
<dt>RadToDeg(rad)</dt>
<dd>This function converts radians into degrees<br>e.g. radtodeg(pi)=180</dd>
<dt>sqrt(x)</dt>
<dd>Sqrt returns the square root of x<br>e.g. sqrt(9)=3<br>
If you want to calculate another kind of roots for example the cube root use the powering instead e.g.
the cube root of 8 is 8^(1/3)=2</dd>
<dt>factorial(x)</dt>
<dd>The factorial function<br>e.g. factorial(6)=1*2*3*4*5*6=720</dd>
<dt>abs(x)</dt>
<dd>The absolute value of x<br>e.g. abs(-10)=10</dd>
<dt>sgn(x)</dt>
<dd>This function returns the sign of x that means when the x is positive the result is 1, when the x is negative
the result is -1 and when the x is zero the result is zero too, e.g.<br>
sgn(-10)=-1<br>
sgn(0)=0<br>
sgn(5)=1</dd>
<dt>mod(x,y)</dt>
<dd>Mod returns the remainder from the division x by y<br>e.g. mod(10; 2.2)=1.2 because 10=2.2*4 + 1.2</dd>
<dt>int(x)</dt>
<dd>This method returns only the integer part of x.<br>e.g. int(2.7)=2</dd>
<dt>round(x)</dt>
<dd>This method rounds the value of x to the nearest integer e.g.<br>
round(2.8)=3<br>
round(2.2)=2<br>
round(2)=2<br>
round(-4.8)=-5<br>
round(-4.1)=-4</dd>
<dt>ceil(x)</dt>
<dd>This function returns a value representing the smallest integer that is greater than or equal to x, e.g.<br>
ceil(2.8)=3<br>
ceil(2.2)=3<br>
ceil(2)=2<br>
ceil(-4.8)=-4<br>
ceil(-4.1)=-4</dd>
<dt>floor(x)</dt>
<dd>This function returns a value representing the largest integer that is less than or equal to x, e.g.<br>
floor(2.8)=2<br>
floor(2.2)=2<br>
floor(2)=2<br>
floor(-4.8)=-5<br>
floor(-4.1)=-5</dd>
<dt>max(x1; x2; ...)</dt>
<dd>This functions takes any number of arguments. It returns the max value of them. If there aren't arguments
the function returns the max value which can be held in this precision.</dd>
<dt>min(x1; x2; ...)</dt>
<dd>This functions takes any number of arguments. It returns the min value of them. If there aren't arguments
the function returns the min value which can be held in this precision.</dd>
</dl>
</body>
</html>

23
help/help.hhp Normal file
View File

@ -0,0 +1,23 @@
[OPTIONS]
Auto Index=Yes
Compatibility=1.1 or later
Compiled file=..\..\output\ttcalc.chm
Contents file=toc.hhc
Default topic=index.html
Display compile progress=No
Index file=index.hhk
Language=0x809 Angielski (Wielka Brytania)
Title=TTCalc
[FILES]
values_and_std_operators.html
arithmetic_functions.html
logical_functions.html
operators_priority.html
userfunctions.html
index.html
tips.html
[INFOTYPES]

9
help/index.hhk Normal file
View File

@ -0,0 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
<!-- Sitemap 1.0 -->
</HEAD><BODY>
<UL>
</UL>
</BODY></HTML>

47
help/index.html Normal file
View File

@ -0,0 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>TTCalc</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="Keyword" value="TTCalc">
<param name="Keyword" value="author">
<param name="Keyword" value="contact">
<param name="Keyword" value="licence">
<param name="Keyword" value="operating systems">
<param name="Keyword" value="project page">
</object>
</head>
<body>
<h1>TTCalc</h1>
<p>
TTCalc is a mathematical calculator. It has a nice user interface, formulas for
calculating can be inserted by using a keyboard or a mouse. The result is automatically
shown in a second window without using any additional keys such as 'equal'. The
program possess trigonometric functions, inverse trigonometric functions, hyperbolic
functions, logical operators, logarithms, functions for converting between degrees and
radians and so on. Additionally the program allows the user to define his own
variables and functions. Calculations are performed by using floating point numbers
with three kind of precision, the biggest has 288 bits for its mantissa and 96 bits
for its exponent that is about 2.551...e+11925026709067095507636213441 with 85 valid
decimal digits. The program independently allows to insert and display values with
the base (radix) from two to sixteen.
</p>
<table>
<tr><td>Author:</td><td>Tomasz Sowa</td></tr>
<tr><td>Contact:</td><td>t.sowa@slimaczek.pl</td></tr>
<tr><td>Licence:</td><td>BSD (open source)</td></tr>
<tr><td>Operating systems:</td><td>Microsoft Windows 9x/Me/NT/2000/XP (Vista was not tested)</td></tr>
<tr><td>Interface:</td><td>English, Polish</td></tr>
<tr><td>Project page:</td><td><a href="http://sourceforge.net/projects/ttcalc">http://sourceforge.net/projects/ttcalc</a></td></tr>
</table>
</body>
</html>

103
help/logical_functions.html Normal file
View File

@ -0,0 +1,103 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>TTCalc - comparative and logical operators and functions</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="Keyword" value="&lt;">
<param name="Keyword" value="&gt;">
<param name="Keyword" value="&lt;=">
<param name="Keyword" value="&gt;=">
<param name="Keyword" value="==">
<param name="Keyword" value="!=">
<param name="Keyword" value="&amp;&amp;">
<param name="Keyword" value="||">
<param name="Keyword" value="if">
<param name="Keyword" value="and">
<param name="Keyword" value="or">
<param name="Keyword" value="not">
<param name="Keyword" value="logical operators">
<param name="Keyword" value="comparative operators">
<param name="Keyword" value="logical functions">
</object>
</head>
<body>
<h1>Comparative and logical operators and functions</h1>
<p>
We assume that the logical false is represented by zero and the logical true is represented by the
value different from zero. <strong>Note:</strong> If a function takes more than one argument, the arguments are separated with semicolon ';'.
</p>
<dl>
<dt>x &lt; y</dt>
<dd>This operator returns one if x is lower than y else it returns zero. For example:<br>
4 &lt; 10 = 1<br>
6 &lt; 2 = 0</dd>
<dt>x &gt; y</dt>
<dd>This operator returns one if x is greater than y else it returns zero. For example:<br>
5 &gt; 2 = 1<br>
5 &gt; 8 = 0</dd>
<dt>x &lt;= y</dt>
<dd>This operator returns one if x is lower than or equal to y else it returns zero. For example:<br>
4 &lt;= 4 = 1<br>
7 &lt;= 2 = 0</dd>
<dt>x &gt;= y</dt>
<dd>This operator returns one if x is greater than or equal to y else it returns zero. For example:<br>
5 &gt;= 5 = 1<br>
3 &gt;= 4 = 0</dd>
<dt>x == y</dt>
<dd>This operator returns one if x is equal y else it returns zero. For example:<br>
4 == 4 = 1<br>
6 == 2 = 0</dd>
<dt>x != y</dt>
<dd>This operator returns one if x is different from y else it returns zero. For example:<br>
5 != 2 = 1<br>
5 != 5 = 0</dd>
<dt>x &amp;&amp; y (logical and)</dt>
<dd>This operator returns one if both x and y are different from zero else it returns zero. For example:<br>
4 &amp;&amp; 10 = 1<br>
6 &amp;&amp; 0 = 0<br>
0 &amp;&amp; 0 = 0</dd>
<dt>x || y (logical or)</dt>
<dd>This operator returns one either if x or y are different from zero else it returns zero. For example:<br>
5 || 2 = 1<br>
0 || 3 = 1<br>
0 || 0 = 0</dd>
<dt>if(condition; if_true; if_false)</dt>
<dd>If the 'condition' is true (different from zero) the function returns 'if_true' else it returns 'if_false', e.g.<br>
if( 0 ; 20 ; 30) = 30<br>
if( 1 ; 20 ; 30) = 20<br>
if( 4<5 ; 10 ; 50) = 10<br>
if( 6>10 ; 200 ; 100) = 100</dd>
<dt>and(x ; y)</dt>
<dd>This function does the same thing as the logical operator 'and' (&amp;&amp;)</dd>
<dt>or(x ; y)</dt>
<dd>This function does the same thing as the logical operator 'or' (||)</dd>
<dt>not(x)</dt>
<dd>If the x is true (different from zero) this function returns zero, otherwise it returns one, e.g.<br>
not(15)=0<br>
not(0)=1</dd>
</dl>
</body>
</html>

View File

@ -0,0 +1,34 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>TTCalc - operators priority</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="Keyword" value="operators priority">
</object>
</head>
<body>
<h1>Operators Priority</h1>
<p>Below is a list of operators priority. At the top are operators with higher precedence.</p>
<table>
<thead>
<tr><td>Operator</td><td>Description</td><td>Sample</td></tr>
</thead>
<tr><td>( )</td><td>parentheses for grouping an expression</td><td>(1+3)*4</td></tr>
<tr><td>- + # &amp;</td><td>unary minus and plus, and operators for changing the base (radix)</td><td>-10</td></tr>
<tr><td>^</td><td>powering</td><td>3^2</td></tr>
<tr><td>* /</td><td>multiplication and division</td><td>10*20</td></tr>
<tr><td>+ -</td><td>addition and subtraction</td><td>10-30</td></tr>
<tr><td>== != &lt; &gt; &lt;= &gt;=</td><td>comparative operators</td><td>4&lt;5</td></tr>
<tr><td>&amp;&amp;</td><td>logical and</td><td>3&gt;2 &amp;&amp; 3&lt;10</td></tr>
<tr><td>||</td><td>logical or</td><td>3&gt;2 || 3&lt;10</td></tr>
</table>
</body>
</html>

48
help/styles.css Normal file
View File

@ -0,0 +1,48 @@
html * {
margin: 0;
border: 0;
padding: 0;
}
html, body {
font-size: 14px;
font-family: Tahoma, Arial, Sans-serif;
}
body {
margin: 0 0 20px 20px;
}
h1 {
font-size: 2em;
font-family: Arial, Tahoma, Sans-serif;
margin: 1.4em 0 1em 0;
}
p {
margin: 1em 0 1em 0;
}
dt {
font-size: 1.4em;
margin-top: 1em;
}
dd {
padding: 0.3em 0 0 2em;
}
thead {
font-size: 1.2em;
}
td {
padding: 0 2em 0 0;
}

40
help/tips.html Normal file
View File

@ -0,0 +1,40 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>TTCalc - tips</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="Keyword" value="tips">
<param name="Keyword" value="esc">
<param name="Keyword" value="#">
<param name="Keyword" value="&amp;">
<param name="Keyword" value="global semicolon">
</object>
</head>
<body>
<h1>Tips</h1>
<p>
If you want to clear the input edit or if you want to put something in and the focus is
somewhere on the tabs just type ESC, the entire edit will be selected and have a focus.
</p>
<p>
If you want to insert a value with a base (radix) 2 or 16 use the unary operator &amp; (for the base 2)
or # (for the base 16).
For example &amp;10=2 (decimal), #10=16 (decimal). When you're using these operators
then 'input' mode on the 'display' tab is ignored.
</p>
<p>
You can calculate more than one formula at the same time. To achive this use a semicolon
in the global space, for example type '2+4 ; 5*10' and the result will be '6&nbsp;&nbsp;&nbsp;50'.
</p>
</body>
</html>

42
help/toc.hhc Normal file
View File

@ -0,0 +1,42 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
<!-- Sitemap 1.0 -->
</HEAD><BODY>
<OBJECT type="text/site properties">
<param name="ImageType" value="Folder">
</OBJECT>
<UL>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="TTCalc">
<param name="Local" value="index.html">
</OBJECT>
<UL>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Numbers, standard operators and built-in variables">
<param name="Local" value="values_and_std_operators.html">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Arithmetic functions">
<param name="Local" value="arithmetic_functions.html">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Logical operators and functions">
<param name="Local" value="logical_functions.html">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="User defined variables and functions">
<param name="Local" value="userfunctions.html">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Operators priority">
<param name="Local" value="operators_priority.html">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Tips">
<param name="Local" value="tips.html">
</OBJECT>
</UL>
</UL>
</BODY></HTML>

36
help/userfunctions.html Normal file
View File

@ -0,0 +1,36 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>TTCalc - user defined variables and functions</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="Keyword" value="user defined variables">
<param name="Keyword" value="user defined functions">
</object>
</head>
<body>
<h1>User defined variables and functions</h1>
<p>
You are allowed to define your own variables and functions. As a name of a variable or a function
can be a name consists of letters and digits but the first character must be a letter. Names are case-insensitive
that means 'name' is the same as 'NaMe'. For example these
are correct names: a, b, c3, myname, etc. During defining variables and functions you can call another
variables and functions but you cannot call a variable or a function twice. Recurrence calling are not allowed.
</p>
<p>
Functions can get maximum 9 parameters. You have to specify how many parameters your function takes and
you can refer to them by using the variable 'x' with a number from 1 to 9 ('x' without a number means 'x1').
For example you can define a function 'xy' as 'x1*x2' (of course without apostrophes), set the 'parameters' on 2
and then put into the edit box an expression 'xy(10;20)', the result will be 200. Note that we use a semicolon
to separate arguments in a function.
</p>
</body>
</html>

View File

@ -0,0 +1,65 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>TTCalc - numbers, standard operators and built-in variables</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="Keyword" value="numbers">
<param name="Keyword" value="comma">
<param name="Keyword" value="dot">
<param name="Keyword" value="standard operators">
<param name="Keyword" value="builtin variables">
<param name="Keyword" value="e">
<param name="Keyword" value="^">
<param name="Keyword" value="*">
<param name="Keyword" value="/">
<param name="Keyword" value="+">
<param name="Keyword" value="-">
</object>
</head>
<body>
<h1>Numbers</h1>
You can type numbers directly using a keyboard or insert them by a mouse. This is a simple edit window,
you can use arrow keys etc. and copy&amp;paste a text by using standard shortcuts such as CTRL+C and CTRL+V.
As the decimal point can be either a comma or a dot that means 1,234 is the same as 1.234.
<h1>Standard operators</h1>
<dl>
<dt>^</dt>
<dd>Powering</dd>
<dt>*</dt>
<dd>Multiplication</dd>
<dt>/</dt>
<dd>Division</dd>
<dt>+</dt>
<dd>Addition</dd>
<dt>-</dt>
<dd>Subtraction</dd>
</dl>
<p>Of course you can use the parentheses ( and ). Look at the <a href="operators_priority.html">operators priority</a> as well.</p>
<h1>Built-in variables</h1>
<p>You can use following variables, just type its name into the edit window.</p>
<dl>
<dt>e</dt>
<dd>The base of the natural logarithm.<br>e = 2.718...</dd>
<dt>pi</dt>
<dd>The ratio of a circle's circumference to its diameter.<br>pi=3.141...</dd>
</dl>
</body>
</html>

18
setup/COPYRIGHT Normal file
View File

@ -0,0 +1,18 @@
Copyright (c) 2006-2007, Tomasz Sowa
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name Tomasz Sowa nor the names of contributors to this
project may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

45
setup/innosetup.iss Normal file
View File

@ -0,0 +1,45 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[Setup]
AppName=TTCalc
AppVerName=TTCalc 0.8.0
AppPublisher=Tomasz Sowa
AppPublisherURL=http://sourceforge.net/projects/ttcalc
AppSupportURL=http://sourceforge.net/projects/ttcalc
AppUpdatesURL=http://sourceforge.net/projects/ttcalc
DefaultDirName={pf}\TTCalc
DefaultGroupName=TTCalc
AllowNoIcons=yes
LicenseFile=COPYRIGHT
OutputDir=..\..\output_setup
OutputBaseFilename=ttcalc-setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "..\..\output\ttcalc.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\output\mingwm10.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\output\ttcalc.chm"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\COPYRIGHT"; DestDir: "{app}"; Flags: ignoreversion
Source: "ttcalc.ini"; DestDir: "{userappdata}\TTCalc"; Flags: onlyifdoesntexist
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\TTCalc"; Filename: "{app}\ttcalc.exe"; WorkingDir: "{app}"
Name: "{group}\Help"; Filename: "{app}\ttcalc.chm"; WorkingDir: "{app}"
Name: "{group}\{cm:UninstallProgram,TTCalc}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\TTCalc"; Filename: "{app}\ttcalc.exe"; WorkingDir: "{app}"; Tasks: desktopicon
[Run]
Filename: "{app}\ttcalc.exe"; Description: "{cm:LaunchProgram,TTCalc}"; Flags: nowait postinstall skipifsilent

21
setup/ttcalc.ini Normal file
View File

@ -0,0 +1,21 @@
# the configuration file of the program ttcalc
[GLOBAL]
always.on.top = 0
view = 0
maximized = 0
x = 0
y = 0
size.x = 402
size.y = 288
precision = 0
disp.input = 10
disp.output = 10
language = 0
disp.alw.scientific = 0
disp.when.scientific = 15
disp.rounding = -2
[variables]
[functions]

View File

@ -51,8 +51,8 @@
the version of the application
*/
#define TTCALC_MAJOR_VER 0
#define TTCALC_MINOR_VER 7
#define TTCALC_REVISION_VER 3
#define TTCALC_MINOR_VER 8
#define TTCALC_REVISION_VER 0

View File

@ -85,14 +85,9 @@ int i;
SendDlgItemMessage(hWnd,IDC_COMBO_FUNCTION_PARAM,CB_SETCURSEL,parameters,0);
if( adding )
{
SetFocus(GetDlgItem(hWnd,IDC_EDIT_FUNCTION_NAME));
}
else
{
SendDlgItemMessage(hWnd, IDC_EDIT_FUNCTION_NAME, EM_SETREADONLY, 1, 0);
SetFocus(GetDlgItem(hWnd,IDC_EDIT_FUNCTION_VALUE));
}
return false;
@ -127,58 +122,7 @@ return false;
}
void AddNewItemToFunctionList(HWND list, const std::string & name, const std::string & value, int parameters)
{
LVITEM item;
char buffer[20];
item.mask = LVIF_TEXT;
item.pszText = const_cast<char*>( name.c_str() );
item.iSubItem = 0;
int id = ListView_InsertItem(list, &item);
sprintf(buffer,"%u", parameters);
ListView_SetItemText(list,id,1, buffer);
ListView_SetItemText(list,id,2,const_cast<char*>( value.c_str() ));
}
void SetNewFunctionValueIntoList(HWND list, int id)
{
ttmath::ErrorCode code;
char buffer[20];
GetPrgRes()->GetThreadController()->StopCalculating();
code = GetPrgRes()->GetFunctions()->Edit(name, value, parameters);
GetPrgRes()->GetThreadController()->StartCalculating();
if( code == ttmath::err_unknown_object )
{
// there is probably an internal error
// because we should have had this function
MessageBox( list,
GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_edit_function_unknown_function),
GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption),
MB_ICONERROR);
return;
}
sprintf(buffer,"%u",parameters);
ListView_SetItemText(list,id,1,buffer);
ListView_SetItemText(list,id,2,const_cast<char*>( value.c_str() ));
}
void WmTabCommand_AddFunctionShowError(HWND hWnd, ttmath::ErrorCode error)
void ShowError(HWND hWnd, ttmath::ErrorCode error)
{
const char * message;
@ -192,6 +136,10 @@ const char * message;
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_function_incorrect_name);
break;
case ttmath::err_unknown_object:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_edit_function_unknown_function);
break;
default:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::unknown_error);
break;
@ -204,29 +152,89 @@ const char * message;
}
int AddNewItemToFunctionList(HWND list, const std::string & name,
const std::string & value, int parameters)
{
LVITEM item;
char buffer[20];
item.mask = LVIF_TEXT;
item.pszText = const_cast<char*>( name.c_str() );
item.iSubItem = 0;
int id = ListView_InsertItem(list, &item);
sprintf(buffer,"%u", parameters);
ListView_SetItemText(list,id,1, buffer);
ListView_SetItemText(list,id,2,const_cast<char*>( value.c_str() ));
return id;
}
void ChangeItemInFunctionList( HWND list, int id, const std::string & old_name,
const std::string & new_name, const std::string & value,
int parameters)
{
if( old_name != new_name )
{
ListView_DeleteItem(list, id);
// as we're using ListView_DeleteItem here the WM_NOTIFY is generated
// and system will call SetDisablingEditDeleteFunctionButtons
// and eventually the focus will be changed into the 'add' button
// (it's a small inconvenience)
int new_id = AddNewItemToFunctionList(list, new_name, value, parameters);
ListView_SetItemState(list,new_id, LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED);
}
else
{
char buffer[20];
sprintf(buffer,"%u", parameters);
ListView_SetItemText(list,id,1, buffer);
ListView_SetItemText(list,id,2,const_cast<char*>( value.c_str() ));
}
}
BOOL WmTabCommand_AddFunction(HWND, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hWnd = GetPrgRes()->GetTabWindow(TabWindowFunctions::tab_functions);
caption = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_function_caption);
name = "";
value = "";
adding = true;
parameters = 1;
ttmath::ErrorCode code;
adding = true;
if( DialogBox(GetPrgRes()->GetInstance(), MAKEINTRESOURCE(IDD_DIALOG_ADD_FUNCTION), hWnd, DialogProcFunction) )
do
{
if( !DialogBox(GetPrgRes()->GetInstance(), MAKEINTRESOURCE(IDD_DIALOG_ADD_FUNCTION), hWnd, DialogProcFunction) )
break;
HWND list = GetDlgItem(hWnd, IDC_FUNCTIONS_LIST);
ttmath::ErrorCode code;
GetPrgRes()->GetThreadController()->StopCalculating();
code = GetPrgRes()->GetFunctions()->Add(name, value, parameters);
GetPrgRes()->GetThreadController()->StartCalculating();
if( code != ttmath::err_ok )
WmTabCommand_AddFunctionShowError(hWnd, code);
ShowError(hWnd, code);
else
AddNewItemToFunctionList(list, name, value, parameters);
{
int id = AddNewItemToFunctionList(list, name, value, parameters);
Variables::SelectOnlyOneItem(list,id);
}
}
while( code != ttmath::err_ok );
return true;
}
@ -241,35 +249,55 @@ BOOL WmTabCommand_EditFunction(HWND, UINT message, WPARAM wParam, LPARAM)
{
HWND hWnd = GetPrgRes()->GetTabWindow(TabWindowFunctions::tab_functions);
HWND list = GetDlgItem(hWnd, IDC_FUNCTIONS_LIST);
adding = false;
if( ListView_GetSelectedCount(list) != 1 )
// there must be only one item selected
return true;
int id = ListView_GetSelectionMark(list);
int id = Variables::GetSelectedItem(list);
if( id == -1 )
return true;
const int buffer_size = 300;
char * buffer = new char[buffer_size];
std::string old_name;
ttmath::ErrorCode code;
caption = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_edit_function_caption);
ListView_GetItemText(list,id,0,buffer, buffer_size);
name = buffer;
ListView_GetItemText(list,id,2,buffer, buffer_size);
value = buffer;
old_name = name = buffer;
ListView_GetItemText(list,id,1,buffer, buffer_size);
parameters = atoi(buffer);
ListView_GetItemText(list,id,2,buffer, buffer_size);
value = buffer;
delete [] buffer;
adding = false;
if( DialogBox(GetPrgRes()->GetInstance(), MAKEINTRESOURCE(IDD_DIALOG_ADD_FUNCTION), hWnd, DialogProcFunction) )
do
{
SetNewFunctionValueIntoList(list, id);
if( !DialogBox(GetPrgRes()->GetInstance(), MAKEINTRESOURCE(IDD_DIALOG_ADD_FUNCTION), hWnd, DialogProcFunction) )
break;
GetPrgRes()->GetThreadController()->StopCalculating();
// firstly we're trying to change the name
code = GetPrgRes()->GetFunctions()->EditName(old_name, name);
if( code == ttmath::err_ok )
// if we've changed the name then we're changing the value and parameters
code = GetPrgRes()->GetFunctions()->EditValue(name, value, parameters);
GetPrgRes()->GetThreadController()->StartCalculating();
if( code != ttmath::err_ok )
ShowError(list, code);
else
ChangeItemInFunctionList(list, id, old_name, name, value, parameters);
}
while( code != ttmath::err_ok );
return true;
}
@ -307,7 +335,7 @@ int items = ListView_GetSelectedCount(list);
if( ListView_GetItemState(list, id, LVIS_SELECTED) == LVIS_SELECTED )
{
ListView_GetItemText(list,id,0,buffer,buffer_size);
if( GetPrgRes()->GetFunctions()->Delete(buffer) == ttmath::err_unknown_object )
if( GetPrgRes()->GetFunctions()->Delete(buffer) != ttmath::err_ok )
all_deleted = false;
else
ListView_DeleteItem(list, id);

View File

@ -87,12 +87,12 @@ void Languages::InitErrorMessagesTab()
InsertErrorPair(ttmath::err_ok,"ok");
InsertErrorPair(ttmath::err_nothing_has_read,"");
InsertErrorPair(ttmath::err_unknown_character,"Unknown character");
InsertErrorPair(ttmath::err_unknown_character,"An unknown character");
InsertErrorPair(ttmath::err_unexpected_final_bracket,"An unexpected final bracket");
InsertErrorPair(ttmath::err_stack_not_clear,"An unknown character has left");
InsertErrorPair(ttmath::err_unknown_variable,"An unknown variable");
InsertErrorPair(ttmath::err_division_by_zero,"Division by zero");
InsertErrorPair(ttmath::err_interrupt,"?");
InsertErrorPair(ttmath::err_interrupt,"The calculating has been broken");
InsertErrorPair(ttmath::err_overflow,"Overflow");
InsertErrorPair(ttmath::err_unknown_function,"An unknown function");
InsertErrorPair(ttmath::err_unknown_operator,"An unknown operator");
@ -109,7 +109,7 @@ void Languages::InitErrorMessagesTab()
InsertErrorPair(ttmath::err_functions_loop,"There's a recurrence between functions");
InsertErrorPair(ttmath::err_must_be_only_one_value,"Variables or functions must return only one value");
InsertErrorPair(ttmath::err_still_calculating,"Calculating...");
InsertErrorPair(ttmath::err_too_big_factorial,"A too big argument for the factorial() function");
// pl
@ -122,7 +122,7 @@ void Languages::InitErrorMessagesTab()
InsertErrorPair(ttmath::err_stack_not_clear,"Pozosta³ nieznany znak");
InsertErrorPair(ttmath::err_unknown_variable,"Nieznana zmienna");
InsertErrorPair(ttmath::err_division_by_zero,"Dzielenie przez zero");
InsertErrorPair(ttmath::err_interrupt,"?");
InsertErrorPair(ttmath::err_interrupt,"Obliczenia zosta³y przerwane");
InsertErrorPair(ttmath::err_overflow,"Przekroczony zakres");
InsertErrorPair(ttmath::err_unknown_function,"Nieznana funkcja");
InsertErrorPair(ttmath::err_unknown_operator,"Nieznany operator");
@ -139,6 +139,7 @@ void Languages::InitErrorMessagesTab()
InsertErrorPair(ttmath::err_functions_loop,"Pomiêdzy funkcjami zachodzi wywo³anie rekurencyjne");
InsertErrorPair(ttmath::err_must_be_only_one_value,"Zmienne albo funkcje mog¹ posiadaæ (zwracaæ) tylko jedn¹ wartoœæ");
InsertErrorPair(ttmath::err_still_calculating,"Obliczanie...");
InsertErrorPair(ttmath::err_too_big_factorial,"Zbyt du¿y argument dla funkcji factorial()");
@ -201,13 +202,13 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(dialog_box_add_variable_incorrect_value,"An incorrect value of the variable");
InsertGuiPair(dialog_box_add_variable_variable_exists,"This variable already exists");
InsertGuiPair(dialog_box_edit_variable_unknown_variable,"There isn't this variable in my table. There's probably an internal error!");
InsertGuiPair(dialog_box_delete_variable_confirm,"Are you sure that you want to delete these variables?");
InsertGuiPair(dialog_box_delete_variable_confirm,"Do you want to delete these variables?");
InsertGuiPair(dialog_box_variable_not_all_deleted,"There are some variables which I was not able to delete. Probably an internal error!");
InsertGuiPair(dialog_box_add_function_caption,"Add a new function");
InsertGuiPair(dialog_box_edit_function_caption,"Edit a function");
InsertGuiPair(dialog_box_add_function_function_exists,"This function already exists");
InsertGuiPair(dialog_box_edit_function_unknown_function,"There isn't this function in my table. There's probably an internal error!");
InsertGuiPair(dialog_box_delete_function_confirm,"Are you sure that you want to delete these functions?");
InsertGuiPair(dialog_box_delete_function_confirm,"Do you want to delete these functions?");
InsertGuiPair(dialog_box_function_not_all_deleted,"There are some functions which I was not able to delete. Probably an internal error!");
InsertGuiPair(dialog_box_add_function_incorrect_name,"An incorrect name of the function");
@ -246,8 +247,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(display_output, "Output");
InsertGuiPair(display_rounding, "Rounding");
InsertGuiPair(display_always_scientific,"Always");
InsertGuiPair(display_not_always_scientific,"When the exp is greater than:");
InsertGuiPair(display_digit, "digits");
InsertGuiPair(display_not_always_scientific,"When the exponent is greater than:");
InsertGuiPair(display_group_scientific, "Print the result as the scientific value");
InsertGuiPair(menu_view, "&View");
@ -261,10 +261,12 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_lang_english, "&English");
InsertGuiPair(menu_view_lang_polish, "&Polish");
InsertGuiPair(menu_view_close_program, "&Close");
InsertGuiPair(menu_view_edit_undo, "&Undo");
InsertGuiPair(menu_view_edit_paste, "&Paste");
InsertGuiPair(menu_view_edit_copy_result,"&Copy the result");
InsertGuiPair(menu_view_help_about, "&About");
InsertGuiPair(menu_edit_undo, "&Undo");
InsertGuiPair(menu_edit_paste, "&Paste");
InsertGuiPair(menu_edit_copy_result, "&Copy the result");
InsertGuiPair(menu_help_help, "&Help");
InsertGuiPair(menu_help_project_page, "&Project page");
InsertGuiPair(menu_help_about, "&About");
InsertGuiPair(cant_init_calculations, "I could not initialize the module of calculations");
InsertGuiPair(message_box_error_caption,"TTCalc");
InsertGuiPair(cant_create_thread, "I could not create the second thread for calculating");
@ -276,11 +278,11 @@ void Languages::InitGuiMessagesTab()
"Contact: t.sowa@slimaczek.pl\r\n"
"Licence: (New) BSD licence\r\n"
"Project page: http://sourceforge.net/projects/ttcalc\r\n"
"Mathemathical library: TTMath %d.%d.%d\r\n"
"Bignum library: TTMath %d.%d.%d\r\n"
"Programming language: C++\r\n"
"Compiler: %s\r\n"
"\r\n"
"This program uses the TTMath mathematical library"
"This program uses the TTMath bignum library"
" which can be found at http://sourceforge.net/projects/ttmath\r\n"
"\r\n"
"If you have any questions, advices or interesting ideas about"
@ -290,8 +292,8 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(about_box_title, "About");
InsertGuiPair(about_box_button_close, "Close");
InsertGuiPair(unknown_error, "An unknown error has occurred");
InsertGuiPair(cant_find_help, "I can't find any help files");
InsertGuiPair(cant_open_project_page, "I can't open the project webpage");
// pl
gui_messages_tab.push_back( std::map<GuiMsg, std::string>() );
@ -353,8 +355,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(display_output,"Wyjœcie");
InsertGuiPair(display_rounding,"Zaokr¹glenie");
InsertGuiPair(display_always_scientific,"Zawsze");
InsertGuiPair(display_not_always_scientific,"Jeœli eksponent wiêkszy ni¿");
InsertGuiPair(display_digit, "cyfr");
InsertGuiPair(display_not_always_scientific,"Jeœli eksponent jest wiêkszy ni¿:");
InsertGuiPair(display_group_scientific, "Wyœwietl wynik w postaci naukowej");
InsertGuiPair(menu_view, "&Widok");
@ -368,10 +369,12 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_lang_english, "Jêzyk &angielski");
InsertGuiPair(menu_view_lang_polish, "Jêzyk &polski");
InsertGuiPair(menu_view_close_program, "&Zamknij");
InsertGuiPair(menu_view_edit_undo, "&Cofnij");
InsertGuiPair(menu_view_edit_paste, "&Wklej");
InsertGuiPair(menu_view_edit_copy_result,"&Kopiuj wynik");
InsertGuiPair(menu_view_help_about, "&O programie");
InsertGuiPair(menu_edit_undo, "&Cofnij");
InsertGuiPair(menu_edit_paste, "&Wklej");
InsertGuiPair(menu_edit_copy_result, "&Kopiuj wynik");
InsertGuiPair(menu_help_help, "&Pomoc");
InsertGuiPair(menu_help_project_page, "&Strona projektu");
InsertGuiPair(menu_help_about, "&O programie");
InsertGuiPair(cant_init_calculations, "Nie uda³o siê zainicjalizowaæ modu³u obs³ugi obliczeñ");
InsertGuiPair(message_box_error_caption,"TTCalc");
InsertGuiPair(cant_create_thread, "Nie uda³o siê utworzyæ drugiego w¹tku do obliczeñ");
@ -383,11 +386,11 @@ void Languages::InitGuiMessagesTab()
"Kontakt: t.sowa@slimaczek.pl\r\n"
"Licencja: (New) BSD\r\n"
"Strona projektu: http://sourceforge.net/projects/ttcalc\r\n"
"Biblioteka matematyczna: TTMath %d.%d.%d\r\n"
"Biblioteka du¿ych liczb: TTMath %d.%d.%d\r\n"
"Jêzyk programowania: C++\r\n"
"Kompilator: %s\r\n"
"\r\n"
"Ten program u¿ywa biblioteki matematycznej TTMath"
"Ten program u¿ywa biblioteki du¿ych liczb TTMath"
" która jest dostêpna na http://sourceforge.net/projects/ttmath\r\n"
"\r\n"
"Je¿eli masz jakieœ pytania, rady, ciekawe pomys³y dotycz¹ce"
@ -397,7 +400,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(about_box_title, "O programie");
InsertGuiPair(about_box_button_close, "Zamknij");
InsertGuiPair(unknown_error, "Nieznany kod b³êdu");
InsertGuiPair(cant_find_help, "Nie mogê znale¿æ ¿adnych plików pomocy");
InsertGuiPair(cant_open_project_page, "Nie mogê otworzyæ strony projektu");
}

View File

@ -111,19 +111,22 @@ public:
menu_view_lang_english,
menu_view_lang_polish,
menu_view_close_program,
menu_view_edit_undo,
menu_view_edit_paste,
menu_view_edit_copy_result,
menu_view_help_about,
menu_edit_undo,
menu_edit_paste,
menu_edit_copy_result,
menu_help_help,
menu_help_project_page,
menu_help_about,
cant_init_calculations,
message_box_error_caption,
cant_create_thread,
cant_create_main_window,
cant_init_common_controls,
cant_find_help,
cant_open_project_page,
about_text,
about_box_title,
about_box_button_close,
display_digit,
display_group_scientific,
unknown_error
};

View File

@ -81,26 +81,103 @@ void CheckAndSetDefPushButton(HWND button)
}
HWND GetNextControlInsideTab(HWND input_edit, HWND tab, HWND tab_dialog, HWND focus,
HWND first_control,
WPARAM wParam, bool direction_next)
{
LRESULT dlg_code = SendMessage(focus, WM_GETDLGCODE, 0, 0);
HWND next = 0;
if( focus == first_control )
{
if( wParam==VK_TAB ||
((dlg_code & DLGC_WANTARROWS)==0 && (dlg_code & DLGC_RADIOBUTTON)==0) )
{
if( !direction_next )
next = tab;
else
{
// if we have only radio buttons (precision tab)
// the next item from GetNextDlgTabItem (or if we allow
// the system to look for it) will be the same as the focus
// we must set it on the input_edit
HWND nexttmp = GetNextDlgTabItem(tab_dialog, focus, false);
if( nexttmp == focus )
next = input_edit;
}
}
}
else
// the focus is somewhere inside a tab
{
if( wParam==VK_TAB ||
((dlg_code & DLGC_WANTARROWS)==0 && (dlg_code & DLGC_RADIOBUTTON)==0) )
{
if( direction_next )
{
HWND nexttmp = GetNextDlgTabItem(tab_dialog, focus, false);
if( nexttmp == first_control )
{
next = input_edit;
}
}
}
}
return next;
}
/*!
we're trying to get the next or previous control which should have
the focus now
*/
HWND GetNextControl(HWND focus, HWND output_edit, HWND tab, WPARAM wParam)
HWND GetNextControl(HWND focus, HWND main_window, HWND tab, WPARAM wParam)
{
HWND next = 0;
bool shift = (GetKeyState(VK_SHIFT) & 0xffff0000) != 0;
HWND next = 0;
HWND output_edit = GetDlgItem(main_window, IDC_OUTPUT_EDIT);
HWND input_edit = GetDlgItem(main_window, IDC_INPUT_EDIT);
bool shift = (GetKeyState(VK_SHIFT) & 0xffff0000) != 0;
bool direction_next = true;
int tab_sel = TabCtrl_GetCurSel(tab);
HWND tab_dialog = GetPrgRes()->GetTabWindow(tab_sel);
HWND first_control = GetNextDlgTabItem(tab_dialog, 0, false);
// if an user has pressed 'up' or 'left' or 'tab'+'shift'
// that means we're going 'back'
if( wParam==VK_UP || wParam==VK_LEFT || (wParam==VK_TAB && shift) )
direction_next = false;
if( focus==output_edit && direction_next )
if( focus == input_edit )
{
// if we are on the output edit and the direction is 'forward'
// then the next control will be the 'tab'
next = tab;
if( wParam==VK_TAB || wParam==VK_UP || wParam==VK_DOWN )
{
if( direction_next )
{
next = output_edit;
}
else
{
next = GetNextDlgTabItem(tab_dialog, first_control, true);
ClearPushButtons(tab_dialog);
}
}
}
else
if( focus == output_edit )
{
if( wParam==VK_LEFT || wParam==VK_RIGHT )
return 0;
if( direction_next )
// if we are on the output edit and the direction is 'forward'
// then the next control will be the 'tab'
next = tab;
else
next = input_edit;
}
else
if( focus == tab )
@ -113,9 +190,7 @@ HWND GetNextControl(HWND focus, HWND output_edit, HWND tab, WPARAM wParam)
if( direction_next )
{
// we're getting the first control on a specific dialog on the selected tab
int tab_sel = TabCtrl_GetCurSel(tab);
HWND tab_dialog = GetPrgRes()->GetTabWindow(tab_sel);
next = GetNextDlgTabItem(tab_dialog, 0, false);
next = first_control;
ClearPushButtons(tab_dialog);
}
else
@ -125,36 +200,15 @@ HWND GetNextControl(HWND focus, HWND output_edit, HWND tab, WPARAM wParam)
}
}
else
{
// we get here if the focus is not set on 'tab' neither
// on 'output_edit' with the direction equals 'forward'
// if an user has pressed the tab (with or without shift)
// or if the control with a focus doesn't want arrows key
// and the control isn't a radio button we're using
// GetNextDlgTabItem to find the next element
LRESULT dlg_code = SendMessage(focus, WM_GETDLGCODE, 0, 0);
if( wParam==VK_TAB ||
((dlg_code & DLGC_WANTARROWS)==0 && (dlg_code & DLGC_RADIOBUTTON)==0) )
{
// the control returns from GetNextDlgTabItem will not be perfect
// we have to make a small change:
// when this method has returned 'output_edit' and when we're
// moving back and the focus it not set on 'tab' the focus
// should be set into the tab control
HWND nexttmp = GetNextDlgTabItem(GetPrgRes()->GetMainWindow(),
focus, !direction_next);
if( !direction_next && focus!=tab && nexttmp==output_edit )
next = tab;
}
}
next = GetNextControlInsideTab(input_edit, tab, tab_dialog, focus,
first_control, wParam, direction_next);
return next;
}
/*!
this function sets the focus on a specific control
(the standard procedure from the operating system doesn't work well because
@ -168,10 +222,9 @@ bool SetNextFocus(WPARAM wParam)
HWND next = 0;
HWND main_window = GetPrgRes()->GetMainWindow();
HWND focus = GetFocus();
HWND output_edit = GetDlgItem(main_window, IDC_OUTPUT_EDIT);
HWND tab = GetDlgItem(main_window, IDC_TAB);
next = GetNextControl(focus, output_edit, tab, wParam);
next = GetNextControl(focus, main_window, tab, wParam);
if( next )
{
@ -244,10 +297,12 @@ HMENU menu = GetMenu(hWnd);
SetMenuLanguageItem(menu, IDM_LANGUAGE_ENGLISH, Languages::menu_view_lang_english);
SetMenuLanguageItem(menu, IDM_LANGUAGE_POLISH, Languages::menu_view_lang_polish);
SetMenuLanguageItem(menu, IDM_CLOSE_PROGRAM, Languages::menu_view_close_program);
SetMenuLanguageItem(menu, IDM_EDIT_UNDO, Languages::menu_view_edit_undo);
SetMenuLanguageItem(menu, IDM_EDIT_PASTE, Languages::menu_view_edit_paste);
SetMenuLanguageItem(menu, IDM_EDIT_COPY_RESULT, Languages::menu_view_edit_copy_result);
SetMenuLanguageItem(menu, IDM_HELP_ABOUT, Languages::menu_view_help_about);
SetMenuLanguageItem(menu, IDM_EDIT_UNDO, Languages::menu_edit_undo);
SetMenuLanguageItem(menu, IDM_EDIT_PASTE, Languages::menu_edit_paste);
SetMenuLanguageItem(menu, IDM_EDIT_COPY_RESULT, Languages::menu_edit_copy_result);
SetMenuLanguageItem(menu, IDM_HELP_HELP, Languages::menu_help_help);
SetMenuLanguageItem(menu, IDM_HELP_PROJECT_PAGE, Languages::menu_help_project_page);
SetMenuLanguageItem(menu, IDM_HELP_ABOUT, Languages::menu_help_about);
DrawMenuBar(hWnd);
}
@ -259,16 +314,16 @@ RECT r;
GetWindowRect(hTab, &r);
int cy_caption = GetSystemMetrics(SM_CYCAPTION);
int cy_add = 2 * GetSystemMetrics(SM_CYDLGFRAME) +
GetSystemMetrics(SM_CYCAPTION) +
GetSystemMetrics(SM_CYMENU);
int cx_add = 2 * GetSystemMetrics(SM_CXDLGFRAME) +
r.right - r.left;
GetPrgRes()->SetYSizeNormal ( 244 + cy_add );
GetPrgRes()->SetYSizeCompact( 59 + cy_add );
GetPrgRes()->SetYSizeNormal ( 225 + cy_add + cy_caption * 2);
GetPrgRes()->SetYSizeCompact( 59 + cy_add + cy_caption );
GetPrgRes()->SetXSizeMin ( 4 + cx_add );
}
@ -348,6 +403,8 @@ TCITEM tab_item;
WmInitDialogCreateTab(hTab, tab_precision, IDD_DIALOG_PRECISION, TabWindowProc);
WmInitDialogCreateTab(hTab, tab_display, IDD_DIALOG_DISPLAY, TabWindowProc);
SetSizeOfDialogs();
SendMessage(GetPrgRes()->GetTabWindow(tab_variables), WM_INIT_TAB_VARIABLES, 0,0);
SendMessage(GetPrgRes()->GetTabWindow(tab_functions), WM_INIT_TAB_FUNCTIONS, 0,0);
SendMessage(GetPrgRes()->GetTabWindow(tab_precision), WM_INIT_TAB_PRECISION, 0,0);
@ -814,6 +871,54 @@ return true;
}
BOOL WmHelp(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
SHELLEXECUTEINFO exec;
exec.cbSize = sizeof(exec);
exec.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS;
exec.hwnd = 0;
exec.lpVerb = "open";
exec.lpFile = "ttcalc.chm";
exec.lpParameters = 0;
exec.lpDirectory = "";
exec.nShow = SW_SHOWNORMAL;
if( !ShellExecuteEx(&exec) )
{
MessageBox(hWnd,
GetPrgRes()->GetLanguages()->GuiMessage(Languages::cant_find_help),
GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption),
MB_ICONERROR);
}
return true;
}
BOOL WmProjectPage(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
SHELLEXECUTEINFO exec;
exec.cbSize = sizeof(exec);
exec.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS;
exec.hwnd = 0;
exec.lpVerb = "open";
exec.lpFile = "http://sourceforge.net/projects/ttcalc";
exec.lpParameters = 0;
exec.lpDirectory = "";
exec.nShow = SW_SHOWNORMAL;
if( !ShellExecuteEx(&exec) )
{
MessageBox(hWnd,
GetPrgRes()->GetLanguages()->GuiMessage(Languages::cant_open_project_page),
GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption),
MB_ICONERROR);
}
return true;
}
void CreateCommandMessagesTable(Messages & cmessages)
@ -831,6 +936,8 @@ void CreateCommandMessagesTable(Messages & cmessages)
cmessages.Associate(IDCANCEL, WmCommand_IDCANCEL);
cmessages.Associate(IDM_LANGUAGE_ENGLISH, WmCommand_LanguageEnglish);
cmessages.Associate(IDM_LANGUAGE_POLISH, WmCommand_LanguagePolish);
cmessages.Associate(IDM_HELP_HELP, WmHelp);
cmessages.Associate(IDM_HELP_PROJECT_PAGE, WmProjectPage);
}
@ -862,6 +969,7 @@ void CreateMainMessagesTable(Messages & messages)
messages.Associate(WM_NOTIFY, WmNotify);
messages.Associate(WM_SIZING, WmSizing);
messages.Associate(WM_SET_LAST_ERROR, WmSetLastError);
messages.Associate(WM_HELP, WmHelp);
}

View File

@ -531,17 +531,30 @@ std::string application_data;
std::string application_directory = application_data + '\\' + simple_directory_name;
bool success = false;
// we're testing whether we've got our directory or not
if( SetCurrentDirectory( application_directory.c_str() ) )
success = true;
else
// now we must make our directory inside it
if( CreateDirectory(application_directory.c_str(), 0) )
success = true;
// we have to remember the currect directory
// (because we're using it when we're opening the help)
char * buffer = new char[_MAX_PATH];
if( success )
configuration_file = application_directory + '\\' + simple_file_name;
if( GetCurrentDirectory(_MAX_PATH, buffer) )
{
// we're testing whether we've got our directory or not
if( SetCurrentDirectory( application_directory.c_str() ) )
success = true;
else
// now we must create our directory inside it
if( CreateDirectory(application_directory.c_str(), 0) )
success = true;
if( success )
configuration_file = application_directory + '\\' + simple_file_name;
SetCurrentDirectory(buffer);
}
delete [] buffer;
}
}

View File

@ -49,6 +49,7 @@
#include "threadcontroller.h"
#include <string>
#include <cstdlib>
#include <windows.h>

View File

@ -76,7 +76,7 @@
#define IDC_BUTTON_ASIN 1071
#define IDC_BUTTON_ACOS 1072
#define IDC_BUTTON_ATAN 1073
#define IDC_BUTTON_ACTAN 1074
#define IDC_BUTTON_ACOT 1074
#define IDC_BUTTON_SGN 1075
#define IDC_BUTTON_MOD 1076
@ -105,7 +105,7 @@
#define IDC_BUTTON_SIN 1120
#define IDC_BUTTON_COS 1121
#define IDC_BUTTON_TAN 1122
#define IDC_BUTTON_CTAN 1123
#define IDC_BUTTON_COT 1123
#define IDC_BUTTON_LN 1124
#define IDC_BUTTON_LOG 1125
#define IDC_BUTTON_ABS 1126
@ -160,7 +160,6 @@
#define IDC_LABEL_DISPLAY_ROUNDING 1164
#define IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC 1165
#define IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC 1166
#define IDC_LABEL_DIGIT 1167
#define IDC_LABEL_GROUP_SCIENTIFIC 1168
// menu
@ -178,7 +177,9 @@
#define IDM_EDIT_UNDO 40030
#define IDM_EDIT_PASTE 40031
#define IDM_EDIT_COPY_RESULT 40032
#define IDM_HELP_ABOUT 40040
#define IDM_HELP_HELP 40040
#define IDM_HELP_PROJECT_PAGE 40041
#define IDM_HELP_ABOUT 40049
// about dialog
#define IDC_ABOUT_TEXT 1200

View File

@ -35,7 +35,10 @@ BEGIN
END
POPUP "&Help"
BEGIN
MENUITEM "&About", 40040
MENUITEM "&Help", 40040
MENUITEM "&Project page", 40041
MENUITEM SEPARATOR
MENUITEM "&About", 40049
END
END
@ -43,11 +46,11 @@ END
STYLE DS_SETFONT |DS_CENTER |WS_POPUP |WS_SYSMENU |WS_THICKFRAME |WS_MAXIMIZEBOX |WS_MINIMIZEBOX |WS_CAPTION
MENU 200
CAPTION "TTCalc"
FONT 8, "MS Sans Serif"
FONT 8, "Ms Shell Dlg"
BEGIN
CONTROL "",1000,"EDIT",ES_AUTOHSCROLL |ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,0,6,260,14
CONTROL "",1001,"EDIT",ES_READONLY |ES_AUTOHSCROLL |ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,0,21,260,14
CONTROL "",1010,"SysTabControl32",WS_CHILD |WS_TABSTOP | WS_VISIBLE ,0,39,261,110, WS_EX_CONTROLPARENT
CONTROL "",1010,"SysTabControl32",WS_CHILD |WS_TABSTOP |WS_GROUP| WS_VISIBLE ,0,39,261,110, WS_EX_CONTROLPARENT
END
@ -80,9 +83,8 @@ BEGIN
LTEXT "param:",1148,7,30,33,8
END
110 DIALOGEX 0, 0, 264, 90
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_TABSTOP
EXSTYLE WS_EX_CONTROLPARENT
110 DIALOGEX 0, 0, 287, 90
STYLE DS_3DLOOK | DS_FIXEDSYS |DS_SETFONT | WS_CHILD| WS_TABSTOP |WS_GROUP
FONT 8, "Ms Shell Dlg"
BEGIN
PUSHBUTTON "Clear",1110,3,3,26,14,BS_CENTER | BS_VCENTER
@ -113,8 +115,8 @@ BEGIN
PUSHBUTTON "tan",1122,131,37,26,14,BS_CENTER | BS_VCENTER
PUSHBUTTON "atan",1073,160,37,26,14,BS_CENTER | BS_VCENTER
PUSHBUTTON "exp",1131,189,37,26,14,BS_CENTER | BS_VCENTER
PUSHBUTTON "ctan",1123,131,54,26,14,BS_CENTER | BS_VCENTER
PUSHBUTTON "actan",1074,160,54,26,14,BS_CENTER | BS_VCENTER
PUSHBUTTON "cot",1123,131,54,26,14,BS_CENTER | BS_VCENTER
PUSHBUTTON "acot",1074,160,54,26,14,BS_CENTER | BS_VCENTER
PUSHBUTTON "abs",1126,189,54,26,14,BS_CENTER | BS_VCENTER
PUSHBUTTON "int",1129,131,71,26,14,BS_CENTER | BS_VCENTER
PUSHBUTTON "round",1130,160,71,26,14,BS_CENTER | BS_VCENTER
@ -128,8 +130,7 @@ END
111 DIALOG 0, 0, 287, 90
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
CAPTION "tab2"
FONT 8, "Ms Shell Dlg"
BEGIN
@ -140,8 +141,7 @@ BEGIN
END
112 DIALOG 0, 0, 287, 90
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
CAPTION "tab3"
FONT 8, "Ms Shell Dlg"
BEGIN
@ -152,22 +152,20 @@ BEGIN
END
113 DIALOG 0, 0, 287, 90
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
CAPTION "tab4"
FONT 8, "Ms Shell Dlg"
BEGIN
CONTROL "precision 1",1150,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD |WS_GROUP|WS_TABSTOP |WS_VISIBLE ,15,4,252,10
CONTROL "precision 2",1151,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD | WS_VISIBLE ,15,33,252,10
CONTROL "precision 3",1152,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD | WS_VISIBLE ,15,62,252,10
CONTROL "precision 1",1150,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD |WS_GROUP|WS_TABSTOP | WS_VISIBLE ,15,4,252,10
CONTROL "precision 2",1151,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD |WS_TABSTOP | WS_VISIBLE ,15,33,252,10
CONTROL "precision 3",1152,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD |WS_TABSTOP | WS_VISIBLE ,15,62,252,10
CONTROL "info 1",1153,"STATIC",SS_LEFT |WS_CHILD |WS_VISIBLE ,28,17,245,8
CONTROL "info 2",1154,"STATIC",SS_LEFT |WS_CHILD |WS_VISIBLE ,28,46,245,8
CONTROL "info 3",1155,"STATIC",SS_LEFT |WS_CHILD |WS_VISIBLE ,28,74,245,8
END
114 DIALOG DISCARDABLE 0, 0, 255, 90
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION
EXSTYLE WS_EX_CONTROLPARENT
STYLE DS_3DLOOK | DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
CAPTION "tab5"
FONT 8, "Ms Shell Dlg"
BEGIN
@ -178,11 +176,10 @@ BEGIN
LTEXT "Rounding",1164,11,36,43,8
COMBOBOX 1159,58,33,121,200,CBS_DROPDOWNLIST | WS_TABSTOP
CONTROL "Always",1160,"Button",BS_AUTORADIOBUTTON | BS_LEFT | WS_GROUP | WS_TABSTOP,19,65,44,10
CONTROL "When exp greater than:",1161,"Button", BS_AUTORADIOBUTTON | BS_LEFT ,77,65,112,10
EDITTEXT 1166,194,63,29,14,WS_GROUP | WS_TABSTOP | ES_NUMBER
CONTROL "When the exponent is greater than:",1161,"Button", BS_AUTORADIOBUTTON | BS_LEFT ,77,65,130,10
EDITTEXT 1166,211,63,29,14,WS_GROUP | WS_TABSTOP | ES_NUMBER
CONTROL "",1165,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS ,213,37,11,14
GROUPBOX "Print scientific value",1168,11,51,240,31
LTEXT "Digit",1167,227,65,20,8
END
200 DIALOG DISCARDABLE 0, 0, 349, 202

View File

@ -138,9 +138,9 @@ return true;
}
BOOL WmTabCommand_Press_ctan(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
BOOL WmTabCommand_Press_cot(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("ctan()",-1);
InsertText("cot()",-1);
return true;
}
@ -261,9 +261,9 @@ BOOL WmTabCommand_Press_atan(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
return true;
}
BOOL WmTabCommand_Press_actan(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
BOOL WmTabCommand_Press_acot(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("actan()",-1);
InsertText("acot()",-1);
return true;
}
@ -313,7 +313,7 @@ return true;
}
BOOL WmTabCommand_Ok(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
BOOL WmTabCommand_IDOK(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND main = GetPrgRes()->GetMainWindow();
HWND tab = GetDlgItem(main, IDC_TAB);
@ -335,6 +335,12 @@ int sel = TabCtrl_GetCurSel(tab);
return true;
}
BOOL WmTabCommand_IDCANCEL(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
SendMessage(GetPrgRes()->GetMainWindow(), WM_COMMAND, IDCANCEL, 0);
return true;
}
void SetLanguageTabStandard(HWND hWnd)
{
@ -431,7 +437,6 @@ int i;
SetDlgItemText(hWnd, IDC_RADIO_DISPLAY_ALWAYS_SCIENTIFIC, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_always_scientific));
SetDlgItemText(hWnd, IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_not_always_scientific));
SetDlgItemText(hWnd, IDC_LABEL_DIGIT, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_digit));
SetDlgItemText(hWnd, IDC_LABEL_GROUP_SCIENTIFIC, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_group_scientific));
}
@ -557,13 +562,11 @@ void SetDisablingDisplayWhenScientific(HWND hWnd)
{
EnableWindow(GetDlgItem(hWnd, IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC), false);
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC), false);
EnableWindow(GetDlgItem(hWnd, IDC_LABEL_DIGIT), false);
}
else
{
EnableWindow(GetDlgItem(hWnd, IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC), true);
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC), true);
EnableWindow(GetDlgItem(hWnd, IDC_LABEL_DIGIT), true);
}
}
@ -656,7 +659,7 @@ void CreateTabCommandMessagesTable(Messages & cmessages)
cmessages.Associate(IDC_BUTTON_SIN, WmTabCommand_Press_sin);
cmessages.Associate(IDC_BUTTON_COS, WmTabCommand_Press_cos);
cmessages.Associate(IDC_BUTTON_TAN, WmTabCommand_Press_tan);
cmessages.Associate(IDC_BUTTON_CTAN, WmTabCommand_Press_ctan);
cmessages.Associate(IDC_BUTTON_COT, WmTabCommand_Press_cot);
cmessages.Associate(IDC_BUTTON_LN, WmTabCommand_Press_ln);
cmessages.Associate(IDC_BUTTON_LOG, WmTabCommand_Press_log);
cmessages.Associate(IDC_BUTTON_ABS, WmTabCommand_Press_abs);
@ -677,7 +680,7 @@ void CreateTabCommandMessagesTable(Messages & cmessages)
cmessages.Associate(IDC_BUTTON_ASIN, WmTabCommand_Press_asin);
cmessages.Associate(IDC_BUTTON_ACOS, WmTabCommand_Press_acos);
cmessages.Associate(IDC_BUTTON_ATAN, WmTabCommand_Press_atan);
cmessages.Associate(IDC_BUTTON_ACTAN, WmTabCommand_Press_actan);
cmessages.Associate(IDC_BUTTON_ACOT, WmTabCommand_Press_acot);
cmessages.Associate(IDC_BUTTON_SGN, WmTabCommand_Press_sgn);
cmessages.Associate(IDC_BUTTON_MOD, WmTabCommand_Press_mod);
@ -691,7 +694,8 @@ void CreateTabCommandMessagesTable(Messages & cmessages)
cmessages.Associate(IDC_BUTTON_EDIT_VARIABLE, Variables::WmTabCommand_EditVariable);
cmessages.Associate(IDC_BUTTON_DELETE_VARIABLE, Variables::WmTabCommand_DeleteVariable);
cmessages.Associate(IDOK, WmTabCommand_Ok);
cmessages.Associate(IDOK, WmTabCommand_IDOK);
cmessages.Associate(IDCANCEL, WmTabCommand_IDCANCEL);
cmessages.Associate(IDC_BUTTON_ADD_FUNCTION, Functions::WmTabCommand_AddFunction);
cmessages.Associate(IDC_BUTTON_EDIT_FUNCTION, Functions::WmTabCommand_EditFunction);
@ -861,7 +865,7 @@ LVCOLUMN column;
SetDisablingEditDeleteVariableButtons(hWnd);
if( FillUpVariableList(list) > 0 )
ListView_SetItemState(list, 0, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(list, 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
return true;
}
@ -892,8 +896,7 @@ LVCOLUMN column;
SetDisablingEditDeleteFunctionButtons(hWnd);
if( FillUpFunctionList(list) > 0 )
ListView_SetItemState(list, 0, LVIS_SELECTED, LVIS_SELECTED);
ListView_SetItemState(list, 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
return true;
}
@ -1116,6 +1119,28 @@ void SetSizeOfFunctionsList()
}
void SetSizeOfDialogs()
{
const int cy_std = 19;
int cy_caption = GetSystemMetrics(SM_CYCAPTION);
if( cy_caption <= cy_std )
return;
int len = GetPrgRes()->HowManyTabWindows();
RECT r;
for(int i = 0 ; i<len ; ++i )
{
HWND dialog = GetPrgRes()->GetTabWindow(i);
GetWindowRect( dialog, &r);
SetWindowPos( dialog,0, 0,0, r.right-r.left, r.bottom-r.top+(cy_caption-cy_std),
SWP_NOZORDER |SWP_NOMOVE);
GetWindowRect( dialog, &r);
}
}
} // namespace TabWindowFunctions

View File

@ -74,16 +74,16 @@ extern ttmath::ErrorCode last_code;
void SetSizeOfVariablesList();
void SetSizeOfFunctionsList();
BOOL WmTabCommand(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void SetSizeOfDialogs();
namespace Variables
{
extern std::string caption,name,value;
extern bool adding;
char * ChangeToSmallLetters(char * string);
char * StripWhiteCharacters(char * string);
void AddNewItemToVariableList(HWND list, const std::string & name, const std::string & value);
int AddNewItemToVariableList(HWND list, const std::string & name, const std::string & value);
int GetSelectedItem(HWND list);
void SelectOnlyOneItem(HWND list, int id);
BOOL WmTabCommand_AddVariable(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
BOOL WmTabCommand_EditVariable(HWND hWnd, UINT message, WPARAM wParam, LPARAM);
@ -92,10 +92,7 @@ extern ttmath::ErrorCode last_code;
namespace Functions
{
extern std::string caption,name,value;
extern bool adding;
void AddNewItemToFunctionList(HWND list, const std::string & name, const std::string & value, int parameters);
int AddNewItemToFunctionList(HWND list, const std::string & name, const std::string & value, int parameters);
BOOL WmTabCommand_AddFunction(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
BOOL WmTabCommand_EditFunction(HWND hWnd, UINT message, WPARAM wParam, LPARAM);

View File

@ -46,23 +46,25 @@ namespace Variables
std::string caption,name,value;
bool adding;
/*!
this method changes the whole string into a string consists of small letters
this function changes the whole string into a string consists of small letters
(it returns the same pointer)
*/
char * ChangeToSmallLetters(char * string)
{
char * p;
for( p = string ; *p>='A' && *p<='Z' ; ++p )
for( char * p = string ; *p>='A' && *p<='Z' ; ++p )
*p = *p - 'A' + 'a';
return string;
}
/*!
this function deletes white characters at the beginning and at the end of a string
it doesn't actually erase them but returns the pointer at the first
non-white character and sets '\0' before the last white character
*/
char * StripWhiteCharacters(char * string)
{
char * start, * end;
@ -94,15 +96,10 @@ char * pchar;
SetDlgItemText(hWnd,IDC_EDIT_VARIABLE_NAME, name.c_str());
SetDlgItemText(hWnd,IDC_EDIT_VARIABLE_VALUE, value.c_str());
if( adding )
{
if( adding)
SetFocus(GetDlgItem(hWnd,IDC_EDIT_VARIABLE_NAME));
}
else
{
SendDlgItemMessage(hWnd, IDC_EDIT_VARIABLE_NAME, EM_SETREADONLY, 1, 0);
SetFocus(GetDlgItem(hWnd,IDC_EDIT_VARIABLE_VALUE));
}
return false;
@ -134,49 +131,7 @@ char * pchar;
return false;
}
void AddNewItemToVariableList(HWND list, const std::string & name, const std::string & value)
{
LVITEM item;
item.mask = LVIF_TEXT;
item.pszText = const_cast<char*>( name.c_str() );
item.iSubItem = 0;
int id = ListView_InsertItem(list, &item);
ListView_SetItemText(list,id,1,const_cast<char*>( value.c_str() ));
}
void SetNewVariableValueIntoList(HWND list, int id)
{
ttmath::ErrorCode code;
GetPrgRes()->GetThreadController()->StopCalculating();
code = GetPrgRes()->GetVariables()->Edit(name, value);
GetPrgRes()->GetThreadController()->StartCalculating();
if( code == ttmath::err_unknown_object )
{
// there is probably an internal error
// because we should have had this variable
MessageBox( list,
GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_edit_variable_unknown_variable),
GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption),
MB_ICONERROR);
return;
}
ListView_SetItemText(list,id,1,const_cast<char*>( value.c_str() ));
}
void WmTabCommand_AddVariableShowError(HWND hWnd, ttmath::ErrorCode error)
void ShowError(HWND hWnd, ttmath::ErrorCode error)
{
const char * message;
@ -190,6 +145,10 @@ const char * message;
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_variable_incorrect_name);
break;
case ttmath::err_unknown_object:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_edit_variable_unknown_variable);
break;
default:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::unknown_error);
break;
@ -203,6 +162,79 @@ const char * message;
int AddNewItemToVariableList(HWND list, const std::string & name, const std::string & value)
{
LVITEM item;
item.mask = LVIF_TEXT;
item.pszText = const_cast<char*>( name.c_str() );
item.iSubItem = 0;
int id = ListView_InsertItem(list, &item);
ListView_SetItemText(list,id,1,const_cast<char*>( value.c_str() ));
return id;
}
void ChangeItemInVariableList(HWND list, int id, const std::string & old_name,
const std::string & new_name, const std::string & value)
{
if( old_name != new_name )
{
ListView_DeleteItem(list, id);
// as we're using ListView_DeleteItem here the WM_NOTIFY is generated
// and system will call SetDisablingEditDeleteVariableButtons
// and eventually the focus will be changed into the 'add' button
// (it's a small inconvenience)
int new_id = AddNewItemToVariableList(list, new_name, value);
ListView_SetItemState(list, new_id, LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED);
}
else
{
ListView_SetItemText(list,id,1,const_cast<char*>( value.c_str() ));
}
}
/*!
this functions returns the first item which is selected on a given list
we don't use ListView_GetSelectionMark because it sometimes returns
a wrong value especially when we have set an item as to be focused
on the list ourselves
*/
int GetSelectedItem(HWND list)
{
int id;
int len = ListView_GetItemCount(list);
for(id = 0 ; id<len ; ++id)
if( ListView_GetItemState(list, id, LVIS_SELECTED) == LVIS_SELECTED )
return id;
return -1;
}
/*!
this function removes the selection from all items
and sets the selection only on to the one given
*/
void SelectOnlyOneItem(HWND list, int id)
{
int len = ListView_GetItemCount(list);
for(int i = 0 ; i<len ; ++i)
ListView_SetItemState(list, i, 0, LVIS_FOCUSED|LVIS_SELECTED);
ListView_SetItemState(list, id, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
}
BOOL WmTabCommand_AddVariable(HWND, UINT message, WPARAM wParam, LPARAM lParam)
{
@ -210,22 +242,29 @@ BOOL WmTabCommand_AddVariable(HWND, UINT message, WPARAM wParam, LPARAM lParam)
caption = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_variable_caption);
name = "";
value = "";
adding = true;
ttmath::ErrorCode code;
adding = true;
if( DialogBox(GetPrgRes()->GetInstance(), MAKEINTRESOURCE(IDD_DIALOG_ADD_VARIABLE), hWnd, DialogProcVariables) )
do
{
if( !DialogBox(GetPrgRes()->GetInstance(), MAKEINTRESOURCE(IDD_DIALOG_ADD_VARIABLE), hWnd, DialogProcVariables) )
break;
HWND list = GetDlgItem(hWnd, IDC_VARIABLES_LIST);
ttmath::ErrorCode code;
GetPrgRes()->GetThreadController()->StopCalculating();
code = GetPrgRes()->GetVariables()->Add(name, value);
GetPrgRes()->GetThreadController()->StartCalculating();
if( code != ttmath::err_ok )
WmTabCommand_AddVariableShowError(hWnd, code);
ShowError(hWnd, code);
else
AddNewItemToVariableList(list, name, value);
{
int id = AddNewItemToVariableList(list, name, value);
SelectOnlyOneItem(list,id);
}
}
while( code != ttmath::err_ok );
return true;
}
@ -240,32 +279,52 @@ BOOL WmTabCommand_EditVariable(HWND, UINT message, WPARAM wParam, LPARAM)
{
HWND hWnd = GetPrgRes()->GetTabWindow(TabWindowFunctions::tab_variables);
HWND list = GetDlgItem(hWnd, IDC_VARIABLES_LIST);
adding = false;
if( ListView_GetSelectedCount(list) != 1 )
// there must be only one item selected
return true;
int id = ListView_GetSelectionMark(list);
int id = GetSelectedItem(list);
if( id == -1 )
return true;
const int buffer_size = 300;
char * buffer = new char[buffer_size];
std::string old_name;
ttmath::ErrorCode code;
caption = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_edit_variable_caption);
ListView_GetItemText(list,id,0,buffer, buffer_size);
name = buffer;
old_name = name = buffer;
ListView_GetItemText(list,id,1,buffer, buffer_size);
value = buffer;
delete [] buffer;
adding = false;
if( DialogBox(GetPrgRes()->GetInstance(), MAKEINTRESOURCE(IDD_DIALOG_ADD_VARIABLE), hWnd, DialogProcVariables) )
do
{
SetNewVariableValueIntoList(list, id);
if( !DialogBox(GetPrgRes()->GetInstance(), MAKEINTRESOURCE(IDD_DIALOG_ADD_VARIABLE), hWnd, DialogProcVariables) )
break;
GetPrgRes()->GetThreadController()->StopCalculating();
// firstly we're trying to change the name
code = GetPrgRes()->GetVariables()->EditName(old_name, name);
if( code == ttmath::err_ok )
// if we've changed the name then we're changing the value
code = GetPrgRes()->GetVariables()->EditValue(name, value);
// the code should be err_ok here
GetPrgRes()->GetThreadController()->StartCalculating();
if( code != ttmath::err_ok )
ShowError(list, code);
else
ChangeItemInVariableList(list, id, old_name, name, value);
}
while( code != ttmath::err_ok );
return true;
}
@ -303,7 +362,7 @@ int items = ListView_GetSelectedCount(list);
if( ListView_GetItemState(list, id, LVIS_SELECTED) == LVIS_SELECTED )
{
ListView_GetItemText(list,id,0,buffer,buffer_size);
if( GetPrgRes()->GetVariables()->Delete(buffer) == ttmath::err_unknown_object )
if( GetPrgRes()->GetVariables()->Delete(buffer) != ttmath::err_ok )
all_deleted = false;
else
ListView_DeleteItem(list, id);

View File

@ -45,10 +45,6 @@
#include <string>
#include <ttmath/ttmath.h>
/*!
here our application starts