Browse Source

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
0.8.x 0.8.0
Tomasz Sowa 15 years ago
parent
commit
b3d2fc5d24
  1. 32
      CHANGELOG
  2. 19
      README
  3. 4
      TODO
  4. 175
      help/arithmetic_functions.html
  5. 23
      help/help.hhp
  6. 9
      help/index.hhk
  7. 47
      help/index.html
  8. 103
      help/logical_functions.html
  9. 34
      help/operators_priority.html
  10. 48
      help/styles.css
  11. 40
      help/tips.html
  12. 42
      help/toc.hhc
  13. 36
      help/userfunctions.html
  14. 65
      help/values_and_std_operators.html
  15. 18
      setup/COPYRIGHT
  16. 45
      setup/innosetup.iss
  17. 21
      setup/ttcalc.ini
  18. 4
      src/compileconfig.h
  19. 164
      src/functions.cpp
  20. 55
      src/languages.cpp
  21. 13
      src/languages.h
  22. 234
      src/mainwindow.cpp
  23. 33
      src/programresources.cpp
  24. 1
      src/programresources.h
  25. 9
      src/resource.h
  26. 41
      src/resource.rc
  27. 53
      src/tabs.cpp
  28. 13
      src/tabs.h
  29. 189
      src/variables.cpp
  30. 6
      src/winmain.cpp

32
CHANGELOG

@ -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

@ -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

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

175
help/arithmetic_functions.html

@ -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

@ -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

@ -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

@ -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

@ -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>

34
help/operators_priority.html

@ -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

@ -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

@ -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

@ -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

@ -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>

65
help/values_and_std_operators.html

@ -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

@ -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

@ -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

@ -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]

4
src/compileconfig.h

@ -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

164
src/functions.cpp

@ -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,7 +122,39 @@ return false;
}
void AddNewItemToFunctionList(HWND list, const std::string & name, const std::string & value, int parameters)
void ShowError(HWND hWnd, ttmath::ErrorCode error)
{
const char * message;
switch( error )
{
case ttmath::err_object_exists:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_function_function_exists);
break;
case ttmath::err_incorrect_name:
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;
}
MessageBox( hWnd, message,
GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption),
MB_ICONERROR);
}
int AddNewItemToFunctionList(HWND list, const std::string & name,
const std::string & value, int parameters)
{
LVITEM item;
char buffer[20];
@ -142,66 +169,39 @@ char buffer[20];
ListView_SetItemText(list,id,1, buffer);
ListView_SetItemText(list,id,2,const_cast<char*>( value.c_str() ));
return id;
}
void SetNewFunctionValueIntoList(HWND list, int id)
void ChangeItemInFunctionList( HWND list, int id, const std::string & old_name,
const std::string & new_name, const std::string & value,
int parameters)
{
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 )
if( old_name != new_name )
{
// 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;
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);
}
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)
{
const char * message;
switch( error )
else
{
case ttmath::err_object_exists:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_function_function_exists);
break;
case ttmath::err_incorrect_name:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_function_incorrect_name);
break;
default:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::unknown_error);
break;
char buffer[20];
sprintf(buffer,"%u", parameters);
ListView_SetItemText(list,id,1, buffer);
ListView_SetItemText(list,id,2,const_cast<char*>( value.c_str() ));
}
}
MessageBox( hWnd, message,
GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption),
MB_ICONERROR);
}
BOOL WmTabCommand_AddFunction(HWND, UINT message, WPARAM wParam, LPARAM lParam)
@ -210,23 +210,31 @@ BOOL WmTabCommand_AddFunction(HWND, UINT message, WPARAM wParam, LPARAM lParam)
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);
delete [] buffer;
ListView_GetItemText(list,id,2,buffer, buffer_size);
value = buffer;
adding = false;
delete [] buffer;
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);

55
src/languages.cpp

@ -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");
}

13
src/languages.h

@ -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
};

234
src/mainwindow.cpp

@ -38,7 +38,7 @@
#include "compileconfig.h"
#include "winmain.h"
namespace MainWindowFunctions
@ -47,24 +47,24 @@ namespace MainWindowFunctions
/*!
Loop through all the controls and remove the
dark border that the previous default push
button has.
Loop through all the controls and remove the
dark border that the previous default push
button has.
*/
void ClearPushButtons(HWND hWnd)
{
HWND controls = GetWindow(hWnd, GW_CHILD);
LRESULT dlg_code;
while(controls)
{
dlg_code = SendMessage(controls, WM_GETDLGCODE, 0, 0);
if(dlg_code & DLGC_DEFPUSHBUTTON)
SendMessage(controls, BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, true);
controls = GetWindow(controls, GW_HWNDNEXT);
}
HWND controls = GetWindow(hWnd, GW_CHILD);
LRESULT dlg_code;
while(controls)
{
dlg_code = SendMessage(controls, WM_GETDLGCODE, 0, 0);
if(dlg_code & DLGC_DEFPUSHBUTTON)
SendMessage(controls, BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, true);
controls = GetWindow(controls, GW_HWNDNEXT);
}
}
@ -74,33 +74,110 @@ LRESULT dlg_code;
*/
void CheckAndSetDefPushButton(HWND button)
{
LRESULT dlg_code = SendMessage(button, WM_GETDLGCODE, 0, 0);
if(dlg_code & DLGC_UNDEFPUSHBUTTON)
SendMessage(button, BM_SETSTYLE, (WPARAM)BS_DEFPUSHBUTTON, true);
LRESULT dlg_code = SendMessage(button, WM_GETDLGCODE, 0, 0);
if(dlg_code & DLGC_UNDEFPUSHBUTTON)
SendMessage(button, BM_SETSTYLE, (WPARAM)BS_DEFPUSHBUTTON, true);
}
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 )
{