Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
dc56087444 | |||
eda79cdbe6 | |||
783bebc269 | |||
19f4177691 | |||
b668b3765c | |||
b3f25face3 | |||
34500e3a5e | |||
e841dcfa70 | |||
ebc5359953 | |||
dd32ebd6cd | |||
e89901bbab | |||
87abe4ce7e | |||
e960c2adea | |||
6555140b9a | |||
04fbbaceca | |||
ff62d833c9 | |||
2ff2aebbee | |||
ec87cd8054 | |||
b7b52c9ebe | |||
4e75bda5fc | |||
ee05abc94d | |||
01ad539107 | |||
ae0a8dc911 | |||
d33a6925b1 | |||
f59f1e1580 | |||
000d884d36 | |||
758d881510 | |||
c232565953 |
130
CHANGELOG
130
CHANGELOG
@@ -1,3 +1,110 @@
|
||||
Version 0.8.7 (2009.09.16):
|
||||
* added: new language: Swedish
|
||||
translation made by: Lars 'B<>fvert' G<>fvert <lars.gafvert at gmail dot com>
|
||||
* changed: version of the TTMath library: 0.9.0 prerelease now
|
||||
|
||||
Changes from TTMath 0.9.0 prerelease relating to TTCalc:
|
||||
* added: gamma() function
|
||||
* changed: factorial() function is very fast now
|
||||
|
||||
|
||||
Version 0.8.6 (2009.06.30):
|
||||
* added: new language: Russian
|
||||
translation made by: Vladimir Gladilovich <vdgladilovich at gmail dot com>
|
||||
|
||||
|
||||
Version 0.8.5 (2009.06.18):
|
||||
* added: new language: Chinese
|
||||
translation made by: Juis <zsyfly at gmail dot com>
|
||||
* changed: version of the TTMath library: 0.8.5 now
|
||||
|
||||
Changes from TTMath 0.8.5 relating to TTCalc:
|
||||
* fixed: Big::Mod(x) didn't correctly return a carry
|
||||
and the result was sometimes very big (even greater than x)
|
||||
* changed: factorial() function is much faster now
|
||||
|
||||
|
||||
Version 0.8.4 (2009.05.08):
|
||||
* added: new language: Danish
|
||||
translation made by: Rune Bisgaard Vammen <runebisgaard at gmail dot com>
|
||||
|
||||
|
||||
Version 0.8.3 (2009.04.06):
|
||||
* fixed: calculating the size of the main window
|
||||
now it looks good on MS Vista and when a user changes size of some
|
||||
widgets such as a border, font size, etc.
|
||||
* changed: variables and functions are case-sensitive now, e.g.
|
||||
'x' is not the same as 'X'
|
||||
* changed: precision:
|
||||
small - the same as previous
|
||||
medium - 288 bits for the mantissa, 64 bits for the exponent
|
||||
big - 864 bits for the mantissa, 128 bits for the exponent
|
||||
previous were:
|
||||
medium - 192 bits for the mantissa, 64 bits for the exponent
|
||||
big - 288 bits for the mantissa, 96 bits for the exponent
|
||||
* changed: new version of TTMath bignum library: 0.8.3
|
||||
* added: when a user presses CTRL+C then the result will be
|
||||
copied into the clipboard (if the current control which
|
||||
has a focus is not an edit control, or if it is an edit
|
||||
but has no selection)
|
||||
* added: when a user presses CTRL+V then the text from the clipboard
|
||||
will be copied into the edit control
|
||||
(the focus can be anywhere but it cannot be on another edit control)
|
||||
* added: 'decimal point' option on the display tab
|
||||
* added: variables and functions can have underline characters
|
||||
in their names
|
||||
* added: 'remove trailing zeroes' option on 'display' tab
|
||||
* added: new language: Spanish
|
||||
translation made by Alejandro S. Valdezate
|
||||
alesanval at gmail dot com
|
||||
* added: on display tab: we can select 'deg' 'rad' or 'grad' for calculating
|
||||
in such functions: sin,cos,tan,cot,asin,acos,atan,acot
|
||||
* added: when the program exits new variables and functions are read from
|
||||
the configuration file and then the file is saved
|
||||
(if you have inserted some variables or functions in a different
|
||||
instance of TTCalc those variables or functions were previously
|
||||
skipped)
|
||||
* removed: 'cut off last non valid digits' on 'rounding' option
|
||||
on 'display' tab
|
||||
|
||||
Changes from TTMath 0.8.3 relating to TTCalc:
|
||||
* fixed: Big::Add incorrectly rounded 'this' when both exponents were equal
|
||||
it caused that sometimes when adding a zero the result has changed
|
||||
this had impact among other things on FromString() method
|
||||
"0,8" had different binary representation from "0,80"
|
||||
* fixed: Big::Pow(const Big<exp, man> & pow)
|
||||
it's using PowInt() only when pow.exponent is in range (-man*TTMATH_BITS_PER_UINT; 0]
|
||||
previously the powering 'hung' on an input like this: "(1+ 1e-10000) ^ 10e100000000"
|
||||
(there was 10e100000000 iterations in PowInt())
|
||||
* fixed: in function DegToRad(const ValueType & x, ErrorCode * err = 0) it is better
|
||||
to make division first and then mutliplication -- the result is more
|
||||
accurate especially when x is: 90,180,270 or 360
|
||||
* fixed: the parser didn't correctly treat operators for changing the base
|
||||
(radix) -- operators '#' and '&', e.g.:
|
||||
'#sin(1)' was equal '0' -- there was a zero from '#' and then
|
||||
it was multiplied by 'sin(1)'
|
||||
the parser didn't check whether Big::FromString() has actually
|
||||
read a proper value -- the method Big::FromString() didn't have
|
||||
something to report such a situation
|
||||
* fixed: Big::FromString() when the base is 10, the method reads the scientific
|
||||
part only if such a part it correctly supplied, e.g:
|
||||
'1234e10', '1234e+10', '1234e-5'
|
||||
previous '1234e' was treated as: '1234e0' (now parsing stops on 'e' and
|
||||
the 'e' can be parsed by other parsers, e.g. the mathematical
|
||||
parser -- now in the parser would be: '1234e' = '1234 * e' = '3354,3597...' )
|
||||
* changed: in the parser: the form with operators '#' and '&' is as follows:
|
||||
[-|+][#|&]numeric_value
|
||||
previous was: [-|+][#|&][-|+]numeric_value
|
||||
* changed: the parser is allowed to recognize values which
|
||||
begin with a dot, e.g '.5' is treated as '0.5'
|
||||
* added: functions to the parser: gradtorad(grad), radtograd(rad), degtograd(deg),
|
||||
degtograd(d,m,s), gradtodeg(grad)
|
||||
* added: a short form of multiplication
|
||||
(without the '*' character) e.g. '5y'
|
||||
(it's used only if the second parameter is a variable
|
||||
or function)
|
||||
|
||||
|
||||
Version 0.8.2 portable (2007.07.01):
|
||||
* added: the portable version of the program TTCalc
|
||||
it uses *.ini config file from the same folder where
|
||||
@@ -7,6 +114,7 @@ Version 0.8.2 portable (2007.07.01):
|
||||
the Ultimate Packer for eXecutables)
|
||||
there are no other differences between version 0.8.1 and this one
|
||||
|
||||
|
||||
Version 0.8.1 (2007.04.17):
|
||||
* changed: on win9x the configuration file is in a folder like:
|
||||
"c:\windows\data application\ttcalc\" now
|
||||
@@ -19,6 +127,7 @@ Version 0.8.1 (2007.04.17):
|
||||
especially the factorial() function
|
||||
* changed: from TTMath 0.8.1: the way of parsing operators
|
||||
|
||||
|
||||
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)
|
||||
@@ -28,7 +137,7 @@ Version 0.8.0 (2007.04.02):
|
||||
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
|
||||
* added: help
|
||||
* changed: from TTMath 0.8.0:
|
||||
renamed: CTan() into Cot() or Ctg()
|
||||
renamed: ACTan() into ACot() or ACtg()
|
||||
@@ -41,6 +150,7 @@ Version 0.8.0 (2007.04.02):
|
||||
* 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
|
||||
@@ -52,18 +162,20 @@ Version 0.7.3 (2007.03.08):
|
||||
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
|
||||
* the button 'err' is active when there's actually an error now
|
||||
* added buttons: ASin, ACos, ATan, ACTan
|
||||
* added: buttons Sgn and Mod
|
||||
* changed: the button 'err' is active when there's actually an error now
|
||||
* added: buttons: ASin, ACos, ATan, ACTan
|
||||
* fixed: the program didn't save the current language into the configuration file
|
||||
* fixed: the second thread didn't read the main window correctly and it caused
|
||||
small problems when an user was typing into the first edit control
|
||||
|
||||
|
||||
Version 0.7.1 (2007.02.08):
|
||||
* added a button 'err' (error) on the first tab
|
||||
* the input edit can have 2048 characters now
|
||||
* added remembering the vertical size into the config file
|
||||
* fixed a problem with the 'tab' key
|
||||
* added a message 'Calculating...' when an user clicks on the 'err' button
|
||||
* added: button 'err' (error) on the first tab
|
||||
* changed: the input edit can have 2048 characters now
|
||||
* added: remembering the vertical size into the config file
|
||||
* fixed: a problem with the 'tab' key
|
||||
* added: a message 'Calculating...' when an user clicks on the 'err' button
|
||||
during calculating something
|
||||
|
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2006-2007, Tomasz Sowa
|
||||
Copyright (c) 2006-2009, Tomasz Sowa
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
34
README
34
README
@@ -1,19 +1,23 @@
|
||||
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.
|
||||
TTCalc is an open source bignum mathematical calculator. It features
|
||||
arithmetical functions, trigonometric functions, inverse trigonometric
|
||||
functions, hyperbolic functions, inverse hyperbolic functions, logical
|
||||
operators, logarithms, functions for converting between degrees and radians
|
||||
and so on. Additionally the program allows a user to define his own
|
||||
variables and functions.
|
||||
|
||||
Author: Tomasz Sowa <t.sowa AnTispam slimaczek.pl>
|
||||
Project page: http://sourceforge.net/projects/ttcalc
|
||||
The program possesses an easy to use interface. Calculations are performed
|
||||
by using binary floating point numbers with three kinds of precision,
|
||||
the biggest has 864 bits for its mantissa and 128 bits for its exponent
|
||||
that is about 6.70897699... * 10^51217599719369681875006054625051616609
|
||||
with 258 valid decimal digits. TTCalc independently allows to insert and
|
||||
display values with the base (radix) from two to sixteen.
|
||||
|
||||
Author: Tomasz Sowa
|
||||
Contact: t.sowa@ttmath.org
|
||||
Licence: BSD (open source)
|
||||
Interface: English, Polish, Spanish, Danish, Chinese, Russian, Swedish
|
||||
Project page: http://ttcalc.sourceforge.net/
|
||||
Bignum library: TTMath http://www.ttmath.org/
|
||||
Operating systems: Microsoft Windows 9x/Me/NT/2000/XP/Vista
|
||||
|
36
help/accuracy.html
Normal file
36
help/accuracy.html
Normal 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 - accuracy</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="accuracy">
|
||||
</object>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>Accuracy</h1>
|
||||
|
||||
<p>
|
||||
TTCalc uses binary floating point numbers. It means that your input values are first
|
||||
converted to a binary representation and then the calculations are performed. After
|
||||
calculating the result is again converted from the binary to the decimal (you can
|
||||
select the input and output format on the display tab). You must remember that not
|
||||
all values can be converted from binary to decimal (and vice versa) without loosing
|
||||
accuracy. For example decimal '5' can be converted to binary '101' and the '101' is
|
||||
exactly equal decimal 5. But decimal '0.3' has not a good binary representation, it
|
||||
is '0.010011001100110011.....'. And when you put decimal '0.3' the calculations are
|
||||
performed on an approximate value and the result is only an approximation too.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For example try to calculate: 0.204 - 0.34*0.80 + 0.068, you would expect that the
|
||||
result would be: 0 but TTCalc gives you: 3.15544362088404722164691426e-30 which is
|
||||
a good approximation to the real zero (look at e-30 part which means 10^(-30)).
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -6,48 +6,6 @@
|
||||
<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="asinh">
|
||||
<param name="Keyword" value="acosh">
|
||||
<param name="Keyword" value="atanh">
|
||||
<param name="Keyword" value="atgh">
|
||||
<param name="Keyword" value="acoth">
|
||||
<param name="Keyword" value="actgh">
|
||||
<param name="Keyword" value="degtodeg">
|
||||
<param name="Keyword" value="degtorad">
|
||||
<param name="Keyword" value="radtodeg">
|
||||
<param name="Keyword" value="sqrt">
|
||||
<param name="Keyword" value="root">
|
||||
<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>
|
||||
@@ -58,142 +16,98 @@
|
||||
|
||||
<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>
|
||||
<h2>Logarithm and Exponential</h2>
|
||||
|
||||
<dt>log(x; base)</dt>
|
||||
<dd>This function calculates the logarithm of x with a base equal 'base'<br>log(123; 4)=3.471...</dd>
|
||||
<ul>
|
||||
<li><a href="logarithm_exponential.html">ln(x)</a></li>
|
||||
<li><a href="logarithm_exponential.html">log(x; base)</a></li>
|
||||
<li><a href="logarithm_exponential.html">exp(x)</a></li>
|
||||
</ul>
|
||||
|
||||
<dt>exp(x)</dt>
|
||||
<dd>This function calculates the exponent of x<br>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>
|
||||
<h2>Trigonometric functions</h2>
|
||||
|
||||
<dt>cos(x)</dt>
|
||||
<dd>Cosine of x<br>cos(1.3)=0.267...<br>The argument x is in radians.</dd>
|
||||
<p><strong>Note:</strong> On the display tab you can select between degrees, radians and gradians. This affects the input value.</p>
|
||||
|
||||
<dt>tan(x) or tg(x)</dt>
|
||||
<dd>Tangent of x<br>tan(3.6)=0.493...<br>The argument x is in radians.</dd>
|
||||
<ul>
|
||||
<li><a href="trigonometric_functions.html">sin(x)</a></li>
|
||||
<li><a href="trigonometric_functions.html">cos(x)</a></li>
|
||||
<li><a href="trigonometric_functions.html">tan(x) or tg(x)</a></li>
|
||||
<li><a href="trigonometric_functions.html">cot(x) or ctg(x)</a></li>
|
||||
</ul>
|
||||
|
||||
<dt>cot(x) or ctg(x)</dt>
|
||||
<dd>Cotangent of x<br>cot(2.3)=-0.893...<br>The argument x is in radians.</dd>
|
||||
|
||||
<dt>asin(x)</dt>
|
||||
<dd>Inverse sine (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>
|
||||
<h2>Inverse trigonometric functions</h2>
|
||||
|
||||
<dt>acos(x)</dt>
|
||||
<dd>Inverse cosine (arc cosine) of x<br>acos(0.9)=0.451...<br>The result is in radians.</dd>
|
||||
<p><strong>Note:</strong> On the display tab you can select between degrees, radians and gradians. This affects the output (result) value.</p>
|
||||
|
||||
<dt>atan(x) or atg(x)</dt>
|
||||
<dd>Inverse tangent (arc tangent) of x<br>atan(3.3)=1.276...<br>The result is in radians.</dd>
|
||||
<ul>
|
||||
<li><a href="inverse_trigonometric_functions.html">asin(x)</a></li>
|
||||
<li><a href="inverse_trigonometric_functions.html">acos(x)</a></li>
|
||||
<li><a href="inverse_trigonometric_functions.html">atan(x) or atg(x)</a></li>
|
||||
<li><a href="inverse_trigonometric_functions.html">acot(x) or actg(x)</a></li>
|
||||
</ul>
|
||||
|
||||
<dt>acot(x) or actg(x)</dt>
|
||||
<dd>Inverse cotangent (arc cotangent) of x<br>acot(10)=0.099...<br>The result is in radians.</dd>
|
||||
|
||||
<dt>sinh(x)</dt>
|
||||
<dd>This function returns hyperbolic sine of x<br>sinh(12)=81377.395...</dd>
|
||||
<h2>Hyperbolic functions</h2>
|
||||
|
||||
<dt>cosh(x)</dt>
|
||||
<dd>Hyperbolic cosine of x<br>cosh(8.5)=2457.384...</dd>
|
||||
<ul>
|
||||
<li><a href="hyperbolic_functions.html">sinh(x)</a></li>
|
||||
<li><a href="hyperbolic_functions.html">cosh(x)</a></li>
|
||||
<li><a href="hyperbolic_functions.html">tanh(x) or tgh(x)</a></li>
|
||||
<li><a href="hyperbolic_functions.html">coth(x) or ctgh(x)</a></li>
|
||||
</ul>
|
||||
|
||||
<dt>tanh(x) or tgh(x)</dt>
|
||||
<dd>Hyperbolic tangent of x<br>tanh(0.67)=0.584...</dd>
|
||||
|
||||
<dt>coth(x) or ctgh(x)</dt>
|
||||
<dd>Hyperbolic cotangent of x<br>coth(1.67)=1.073...</dd>
|
||||
<h2>Inverse hyperbolic functions</h2>
|
||||
|
||||
<dt>asinh(x)</dt>
|
||||
<dd>This function returns inverse hyperbolic sine of x<br>asinh(3.6)=1.992...</dd>
|
||||
<ul>
|
||||
<li><a href="inverse_hyperbolic_functions.html">asinh(x)</a></li>
|
||||
<li><a href="inverse_hyperbolic_functions.html">acosh(x)</a></li>
|
||||
<li><a href="inverse_hyperbolic_functions.html">atanh(x) or atgh(x)</a></li>
|
||||
<li><a href="inverse_hyperbolic_functions.html">acoth(x) or actgh(x)</a></li>
|
||||
</ul>
|
||||
|
||||
<dt>acosh(x)</dt>
|
||||
<dd>This function returns inverse hyperbolic cosine of x<br>acosh(2.23)=1.440...</dd>
|
||||
|
||||
<dt>atanh(x) or atgh(x)</dt>
|
||||
<dd>This function returns inverse hyperbolic tangent of x<br>atanh(0.67)=0.810...</dd>
|
||||
<h2>Conversions between radians, degrees and gradians</h2>
|
||||
|
||||
<dt>acoth(x) or actgh(x)</dt>
|
||||
<dd>This function returns inverse hyperbolic cotangent of x<br>acoth(1.23)=1.135...</dd>
|
||||
<ul>
|
||||
<li><a href="conversions_deg_rad_grad.html">degtodeg(deg; min; sec)</a></li>
|
||||
<li><a href="conversions_deg_rad_grad.html">degtorad(deg; min; sec)</a></li>
|
||||
<li><a href="conversions_deg_rad_grad.html">degtograd(deg; min; sec)</a></li>
|
||||
<li><a href="conversions_deg_rad_grad.html">degtorad(deg)</a></li>
|
||||
<li><a href="conversions_deg_rad_grad.html">degtograd(deg)</a></li>
|
||||
<li><a href="conversions_deg_rad_grad.html">radtodeg(rad)</a></li>
|
||||
<li><a href="conversions_deg_rad_grad.html">radtograd(rad)</a></li>
|
||||
<li><a href="conversions_deg_rad_grad.html">gradtorad(grad)</a></li>
|
||||
<li><a href="conversions_deg_rad_grad.html">gradtodeg(grad)</a></li>
|
||||
</ul>
|
||||
|
||||
<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>degtorad(12.5)=0.218166...</dd>
|
||||
<h2>Rounding functions</h2>
|
||||
|
||||
<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>
|
||||
<ul>
|
||||
<li><a href="rounding_functions.html">int(x)</a></li>
|
||||
<li><a href="rounding_functions.html">round(x)</a></li>
|
||||
<li><a href="rounding_functions.html">ceil(x)</a></li>
|
||||
<li><a href="rounding_functions.html">floor(x)</a></li>
|
||||
</ul>
|
||||
|
||||
<dt>RadToDeg(rad)</dt>
|
||||
<dd>This function converts radians into degrees<br>radtodeg(pi)=180</dd>
|
||||
|
||||
<dt>sqrt(x)</dt>
|
||||
<dd>Sqrt returns the square root of x<br>sqrt(9)=3</dd>
|
||||
<h2>Other functions</h2>
|
||||
|
||||
<dt>root(x ; n)</dt>
|
||||
<dd>The nth root of a 'x', 'n' must be integer and not negative, if 'n' is zero the result is one,
|
||||
if 'x' is zero the result is zero and we assume that the root(0;0) is not defined, e.g.<br>
|
||||
root(8;3)=2<br>
|
||||
root(-8;3)=-2
|
||||
</dd>
|
||||
|
||||
<dt>factorial(x)</dt>
|
||||
<dd>The factorial function<br>factorial(6)=1*2*3*4*5*6=720</dd>
|
||||
|
||||
<dt>abs(x)</dt>
|
||||
<dd>The absolute value of x<br>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<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>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>int(2.7)=2</dd>
|
||||
|
||||
<dt>round(x)</dt>
|
||||
<dd>This method rounds the value of x to the nearest integer<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<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<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>
|
||||
<ul>
|
||||
<li><a href="other_functions.html">sqrt(x)</a></li>
|
||||
<li><a href="other_functions.html">root(x ; n)</a></li>
|
||||
<li><a href="other_functions.html">factorial(x)</a></li>
|
||||
<li><a href="other_functions.html">abs(x)</a></li>
|
||||
<li><a href="other_functions.html">sgn(x)</a></li>
|
||||
<li><a href="other_functions.html">mod(x; y)</a></li>
|
||||
<li><a href="other_functions.html">max(x1; x2; ...)</a></li>
|
||||
<li><a href="other_functions.html">min(x1; x2; ...)</a></li>
|
||||
<li><a href="other_functions.html">sum(x1; x2; ...)</a></li>
|
||||
<li><a href="other_functions.html">avg(x1; x2; ...)</a></li>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -28,17 +28,17 @@ We don't define the BitNot() function too.
|
||||
|
||||
<dl>
|
||||
|
||||
<dt>BitAnd(x ; y) or band(x ; y)</dt>
|
||||
<dt>bitand(x ; y) or band(x ; y)</dt>
|
||||
<dd>Bitwise AND. For example:<br>
|
||||
bitand(6; 2) = bitand(&110 ; &10) = &10 = 2<br>
|
||||
bitand(6.5; 2.5) = bitand(&110.1 ; &10.1) = &10.1 = 2.5</dd>
|
||||
|
||||
<dt>BitOr(x ; y) or bor(x ; y)</dt>
|
||||
<dt>bitor(x ; y) or bor(x ; y)</dt>
|
||||
<dd>Bitwise OR. For example:<br>
|
||||
bitor(6; 1) = bitor(&110 ; &1) = &111 = 7<br>
|
||||
bitor(6.5; 1.5) = bitor(&110.1 ; &1.1) = &111.1 = 7.5</dd>
|
||||
|
||||
<dt>BitXor(x ; y) or bxor(x ; y)</dt>
|
||||
<dt>bitxor(x ; y) or bxor(x ; y)</dt>
|
||||
<dd>Bitwise XOR. For example:<br>
|
||||
bitxor(6; 3) = bitxor(&110 ; &11) = &101 = 5<br>
|
||||
bitxor(6.5; 3.5) = bitxor(&110.1 ; &11.1) = &101.0 = 5</dd>
|
||||
|
64
help/conversions_deg_rad_grad.html
Normal file
64
help/conversions_deg_rad_grad.html
Normal file
@@ -0,0 +1,64 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>TTCalc - Conversions between radians, degrees and gradians</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="degtodeg">
|
||||
<param name="Keyword" value="degtorad">
|
||||
<param name="Keyword" value="degtograd">
|
||||
<param name="Keyword" value="radtodeg">
|
||||
<param name="Keyword" value="radtograd">
|
||||
<param name="Keyword" value="gradtorad">
|
||||
<param name="Keyword" value="gradtodeg">
|
||||
</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>
|
||||
|
||||
|
||||
<h2>Conversions between radians, degrees and gradians</h2>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt>degtodeg(deg; min; sec)</dt>
|
||||
<dd>This function converts degrees from the long format with degrees, minutes and seconds to degrees.<br>
|
||||
For example: degtodeg(12; 30; 0)=12.5</dd>
|
||||
|
||||
<dt>degtorad(deg; min; sec)</dt>
|
||||
<dd>This function converts degrees in the long format (degrees, minutes, seconds) to radians.<br>
|
||||
degtorad(12; 30; 0)=0.218166...</dd>
|
||||
|
||||
<dt>degtograd(deg; min; sec)</dt>
|
||||
<dd>This function converts degrees in the long format (degrees, minutes, seconds) to gradians<br>degtograd(12; 30; 0)=13.888...</dd>
|
||||
|
||||
<dt>degtorad(deg)</dt>
|
||||
<dd>This function converts degrees to radians<br>degtorad(12.5)=0.218166...</dd>
|
||||
|
||||
<dt>degtograd(deg)</dt>
|
||||
<dd>This function converts degrees to gradians<br>degtograd(12.5)=13.8888...</dd>
|
||||
|
||||
|
||||
<dt>radtodeg(rad)</dt>
|
||||
<dd>This function converts radians to degrees<br>radtodeg(pi)=180</dd>
|
||||
|
||||
<dt>radtograd(rad)</dt>
|
||||
<dd>This function converts radians to gradians<br>radtograd(pi)=200</dd>
|
||||
|
||||
<dt>gradtorad(grad)</dt>
|
||||
<dd>This function converts gradians to radians<br>gradtorad(400)=6.2831....=2*pi</dd>
|
||||
|
||||
<dt>gradtodeg(grad)</dt>
|
||||
<dd>This function converts gradians to degrees<br>gradtodeg(100)=90</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -1,7 +1,7 @@
|
||||
[OPTIONS]
|
||||
Auto Index=Yes
|
||||
Compatibility=1.1 or later
|
||||
Compiled file=..\..\output\ttcalc.chm
|
||||
Compiled file=ttcalc.chm
|
||||
Contents file=toc.hhc
|
||||
Default topic=index.html
|
||||
Display compile progress=No
|
||||
@@ -13,12 +13,21 @@ Title=TTCalc
|
||||
[FILES]
|
||||
values_and_std_operators.html
|
||||
arithmetic_functions.html
|
||||
bitwise_functions.html
|
||||
conversions_deg_rad_grad.html
|
||||
hyperbolic_functions.html
|
||||
index.html
|
||||
inverse_hyperbolic_functions.html
|
||||
inverse_trigonometric_functions.html
|
||||
logarithm_exponential.html
|
||||
logical_functions.html
|
||||
operators_priority.html
|
||||
userfunctions.html
|
||||
index.html
|
||||
other_functions.html
|
||||
rounding_functions.html
|
||||
tips.html
|
||||
bitwise_functions.html
|
||||
trigonometric_functions.html
|
||||
userfunctions.html
|
||||
accuracy.html
|
||||
|
||||
[INFOTYPES]
|
||||
|
||||
|
46
help/hyperbolic_functions.html
Normal file
46
help/hyperbolic_functions.html
Normal file
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>TTCalc - Hyperbolic 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="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">
|
||||
</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>
|
||||
|
||||
|
||||
<h2>Hyperbolic functions</h2>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt>sinh(x)</dt>
|
||||
<dd>This function returns hyperbolic sine of x<br>sinh(12)=81377.395...</dd>
|
||||
|
||||
<dt>cosh(x)</dt>
|
||||
<dd>Hyperbolic cosine of x<br>cosh(8.5)=2457.384...</dd>
|
||||
|
||||
<dt>tanh(x) or tgh(x)</dt>
|
||||
<dd>Hyperbolic tangent of x<br>tanh(0.67)=0.584...</dd>
|
||||
|
||||
<dt>coth(x) or ctgh(x)</dt>
|
||||
<dd>Hyperbolic cotangent of x<br>coth(1.67)=1.073...</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -7,9 +7,11 @@
|
||||
<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="TTMath">
|
||||
<param name="Keyword" value="author">
|
||||
<param name="Keyword" value="contact">
|
||||
<param name="Keyword" value="licence">
|
||||
<param name="Keyword" value="interface language">
|
||||
<param name="Keyword" value="operating systems">
|
||||
<param name="Keyword" value="project page">
|
||||
</object>
|
||||
@@ -20,28 +22,33 @@
|
||||
<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.
|
||||
TTCalc is an open source bignum mathematical calculator. It features
|
||||
arithmetical functions, trigonometric functions, inverse trigonometric
|
||||
functions, hyperbolic functions, inverse hyperbolic functions, logical
|
||||
operators, logarithms, functions for converting between degrees and radians
|
||||
and so on. Additionally the program allows a user to define his own
|
||||
variables and functions.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The program possesses an easy to use interface. Calculations are performed
|
||||
by using binary floating point numbers with three kinds of precision,
|
||||
the biggest has 864 bits for its mantissa and 128 bits for its exponent
|
||||
that is about 6.70897699... * 10^51217599719369681875006054625051616609
|
||||
with 258 valid decimal digits. TTCalc 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>Contact:</td><td>t.sowa@ttmath.org</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>
|
||||
<tr><td>Interface:</td><td>English, Polish, Spanish, Danish, Chinese, Russian, Swedish</td></tr>
|
||||
<tr><td>Project page:</td><td><a href="http://ttcalc.sourceforge.net/">http://ttcalc.sourceforge.net/</a></td></tr>
|
||||
<tr><td>Bignum library:</td><td>TTMath <a href="http://ttmath.org/">http://www.ttmath.org/</a></td></tr>
|
||||
<tr><td>Operating systems:</td><td>Microsoft Windows 9x/Me/NT/2000/XP/Vista</td></tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
47
help/inverse_hyperbolic_functions.html
Normal file
47
help/inverse_hyperbolic_functions.html
Normal 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 - Inverse hyperbolic 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="asinh">
|
||||
<param name="Keyword" value="acosh">
|
||||
<param name="Keyword" value="atanh">
|
||||
<param name="Keyword" value="atgh">
|
||||
<param name="Keyword" value="acoth">
|
||||
<param name="Keyword" value="actgh">
|
||||
</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>
|
||||
|
||||
|
||||
|
||||
<h2>Inverse hyperbolic functions</h2>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt>asinh(x)</dt>
|
||||
<dd>This function returns inverse hyperbolic sine of x<br>asinh(3.6)=1.992...</dd>
|
||||
|
||||
<dt>acosh(x)</dt>
|
||||
<dd>This function returns inverse hyperbolic cosine of x<br>acosh(2.23)=1.440...</dd>
|
||||
|
||||
<dt>atanh(x) or atgh(x)</dt>
|
||||
<dd>This function returns inverse hyperbolic tangent of x<br>atanh(0.67)=0.810...</dd>
|
||||
|
||||
<dt>acoth(x) or actgh(x)</dt>
|
||||
<dd>This function returns inverse hyperbolic cotangent of x<br>acoth(1.23)=1.135...</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
49
help/inverse_trigonometric_functions.html
Normal file
49
help/inverse_trigonometric_functions.html
Normal file
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>TTCalc - Inverse trigonometric 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="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">
|
||||
</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>
|
||||
|
||||
|
||||
<h2>Inverse trigonometric functions</h2>
|
||||
|
||||
<p><strong>Note:</strong> On the display tab you can select between degrees, radians and gradians. In these samples we assume that the 'rad' option is selected.
|
||||
This affects the output (result) value.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt>asin(x)</dt>
|
||||
<dd>Inverse sine (arc sine) of x<br>e.g. asin(0.7)=0.775...</dd>
|
||||
|
||||
<dt>acos(x)</dt>
|
||||
<dd>Inverse cosine (arc cosine) of x<br>acos(0.9)=0.451...</dd>
|
||||
|
||||
<dt>atan(x) or atg(x)</dt>
|
||||
<dd>Inverse tangent (arc tangent) of x<br>atan(3.3)=1.276...</dd>
|
||||
|
||||
<dt>acot(x) or actg(x)</dt>
|
||||
<dd>Inverse cotangent (arc cotangent) of x<br>acot(10)=0.099...</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
39
help/logarithm_exponential.html
Normal file
39
help/logarithm_exponential.html
Normal file
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>TTCalc - Logarithm and Exponential</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">
|
||||
</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>
|
||||
|
||||
<h2>Logarithm and Exponential</h2>
|
||||
|
||||
<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>
|
||||
It's using the formula: log(x; base) = ln(x) / ln(base)<br>
|
||||
log(123; 4)=3.471...</dd>
|
||||
|
||||
<dt>exp(x)</dt>
|
||||
<dd>This function calculates the exponential function of x<br>exp(20)=e^20=485165195.409...</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -16,7 +16,7 @@
|
||||
|
||||
<p>Below is a list of operators priority. At the top are operators with higher precedence.</p>
|
||||
|
||||
<table>
|
||||
<table class="operatorspriority">
|
||||
<thead>
|
||||
<tr><td>Operator</td><td>Description</td><td>Sample</td></tr>
|
||||
</thead>
|
||||
@@ -24,6 +24,7 @@
|
||||
<tr><td>- + # &</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>without an operator</td><td>short form of multiplication<br>(only if the second argument is a variable or function,<br>the same priority as a normal multiplication)</td><td>3y</td></tr>
|
||||
<tr><td>+ -</td><td>addition and subtraction</td><td>10-30</td></tr>
|
||||
<tr><td>== != < > <= >=</td><td>comparative operators</td><td>4<5</td></tr>
|
||||
<tr><td>&&</td><td>logical and</td><td>3>2 && 3<10</td></tr>
|
||||
|
91
help/other_functions.html
Normal file
91
help/other_functions.html
Normal file
@@ -0,0 +1,91 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>TTCalc - Other 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="sqrt">
|
||||
<param name="Keyword" value="root">
|
||||
<param name="Keyword" value="factorial">
|
||||
<param name="Keyword" value="gamma">
|
||||
<param name="Keyword" value="abs">
|
||||
<param name="Keyword" value="sgn">
|
||||
<param name="Keyword" value="mod">
|
||||
<param name="Keyword" value="max">
|
||||
<param name="Keyword" value="min">
|
||||
<param name="Keyword" value="sum">
|
||||
<param name="Keyword" value="avg">
|
||||
</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>
|
||||
|
||||
|
||||
<h2>Other functions</h2>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt>sqrt(x)</dt>
|
||||
<dd>Sqrt returns the square root of x<br>sqrt(9)=3</dd>
|
||||
|
||||
<dt>root(x ; n)</dt>
|
||||
<dd>The nth root of a 'x', 'n' must be integer and not negative, if 'n' is zero the result is one,
|
||||
if 'x' is zero the result is zero and we assume that the root(0;0) is not defined, e.g.<br>
|
||||
root(8;3)=2<br>
|
||||
root(-8;3)=-2
|
||||
</dd>
|
||||
|
||||
<dt>factorial(n)</dt>
|
||||
<dd>The factorial function<br>factorial(6)=1*2*3*4*5*6=720</dd>
|
||||
|
||||
<dt>gamma(x)</dt>
|
||||
<dd>The gamma function<br>gamma(45.89)=7,861174...e+55</dd>
|
||||
|
||||
<dt>abs(x)</dt>
|
||||
<dd>The absolute value of x<br>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<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>mod(10; 2.2)=1.2 because 10=2.2*4 + 1.2</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.<br>
|
||||
max(2;5;8;3)=8<br>
|
||||
max()=6.97846825730330952352039893e+646457021 (assuming the small precision is selected)</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.<br>
|
||||
min(45;-23;18;19)=-23<br>
|
||||
min()=-6.97846825730330952352039893e+646457021 (assuming the small precision is selected)
|
||||
</dd>
|
||||
|
||||
<dt>sum(x1; x2; ...)</dt>
|
||||
<dd>This functions takes one or more arguments. It returns the sum of them.<br>
|
||||
sum(4;2;9;3)=18
|
||||
</dd>
|
||||
|
||||
<dt>avg(x1; x2; ...)</dt>
|
||||
<dd>This functions takes one or more arguments. It returns the arithmetic mean. (The sum divided by
|
||||
the number of arguments)<br>
|
||||
avg(4;2;9;3)=4.5
|
||||
</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
</body>
|
||||
</html>
|
67
help/rounding_functions.html
Normal file
67
help/rounding_functions.html
Normal file
@@ -0,0 +1,67 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>TTCalc - Rounding 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="int">
|
||||
<param name="Keyword" value="round">
|
||||
<param name="Keyword" value="ceil">
|
||||
<param name="Keyword" value="floor">
|
||||
</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>
|
||||
|
||||
|
||||
<h2>Rounding functions</h2>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt>int(x)</dt>
|
||||
<dd>This method returns only the integer part of x.<br>
|
||||
int(2.8)=2<br>
|
||||
int(2.2)=2<br>
|
||||
int(2)=2<br>
|
||||
int(-4.1)=-4<br>
|
||||
int(-4.8)=-4<br>
|
||||
</dd>
|
||||
|
||||
<dt>round(x)</dt>
|
||||
<dd>This method rounds the value of x to the nearest integer<br>
|
||||
round(2.8)=3<br>
|
||||
round(2.2)=2<br>
|
||||
round(2)=2<br>
|
||||
round(-4.1)=-4<br>
|
||||
round(-4.8)=-5</dd>
|
||||
|
||||
<dt>ceil(x)</dt>
|
||||
<dd>This function returns a value representing the smallest integer that is greater than or equal to x<br>
|
||||
ceil(2.8)=3<br>
|
||||
ceil(2.2)=3<br>
|
||||
ceil(2)=2<br>
|
||||
ceil(-4.1)=-4<br>
|
||||
ceil(-4.8)=-4</dd>
|
||||
|
||||
<dt>floor(x)</dt>
|
||||
<dd>This function returns a value representing the largest integer that is less than or equal to x<br>
|
||||
floor(2.8)=2<br>
|
||||
floor(2.2)=2<br>
|
||||
floor(2)=2<br>
|
||||
floor(-4.1)=-5<br>
|
||||
floor(-4.8)=-5</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -7,23 +7,33 @@ padding: 0;
|
||||
|
||||
html, body {
|
||||
font-size: 14px;
|
||||
font-family: Tahoma, Arial, Sans-serif;
|
||||
font-family: Verdana, Tahoma, Arial, Sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0 0 20px 20px;
|
||||
margin: 0 20px 20px 20px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
font-family: Arial, Tahoma, Sans-serif;
|
||||
font-family: Arial, Tahoma, Verdana, Sans-serif;
|
||||
margin: 1.4em 0 1em 0;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.5em;
|
||||
font-family: Arial, Tahoma, Verdana, Sans-serif;
|
||||
margin: 2em 0 1em 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 1em 0 1em 0;
|
||||
}
|
||||
|
||||
dl {
|
||||
margin: 3em 0 3em 0;
|
||||
}
|
||||
|
||||
dt {
|
||||
font-size: 1.4em;
|
||||
margin-top: 1em;
|
||||
@@ -42,7 +52,27 @@ td {
|
||||
padding: 0 2em 0 0;
|
||||
}
|
||||
|
||||
table.operatorspriority {
|
||||
border: 1px solid black;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
|
||||
table.operatorspriority td {
|
||||
border: 1px solid black;
|
||||
padding: 0.5em 0.5em 0.5em 0.5em;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
|
||||
ul.tips {
|
||||
list-style-type: disc;
|
||||
margin-left: 3em;
|
||||
}
|
||||
|
||||
ul.tips li {
|
||||
padding: 1em 0 1em 0;
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@
|
||||
<param name="Keyword" value="#">
|
||||
<param name="Keyword" value="&">
|
||||
<param name="Keyword" value="global semicolon">
|
||||
<param name="Keyword" value="CTRL+C">
|
||||
<param name="Keyword" value="CTRL+V">
|
||||
</object>
|
||||
</head>
|
||||
|
||||
@@ -18,22 +20,36 @@
|
||||
|
||||
<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>
|
||||
<ul class="tips">
|
||||
<li>
|
||||
If you want to clear the input edit or if you want to put something in and the focus is not on the first edit — just type ESC,
|
||||
the entire edit will be selected and have a focus.
|
||||
</li>
|
||||
|
||||
<p>
|
||||
<li>
|
||||
If you want to insert a value with a base (radix) 2 or 16 use the unary operator & (for the base 2)
|
||||
or # (for the base 16).
|
||||
For example &10=2 (decimal), #10=16 (decimal). When you're using these operators
|
||||
then 'input' mode on the 'display' tab is ignored.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<p>
|
||||
<li>
|
||||
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 50'.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
You can use CTRL+C to copy the result from the output edit into the clipboard
|
||||
(if a control which has a focus is not an edit control, or if it is an edit but
|
||||
has no selection)
|
||||
</li>
|
||||
|
||||
<li>
|
||||
Also you can use CTRL+V to paste a text from the clipboard into the input control
|
||||
(if a control which has a focus is not an edit control)
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
38
help/toc.hhc
38
help/toc.hhc
@@ -21,6 +21,40 @@
|
||||
<param name="Name" value="Arithmetic functions">
|
||||
<param name="Local" value="arithmetic_functions.html">
|
||||
</OBJECT>
|
||||
<UL>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Logarithm and Exponential">
|
||||
<param name="Local" value="logarithm_exponential.html">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Trigonometric functions">
|
||||
<param name="Local" value="trigonometric_functions.html">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Inverse trigonometric functions">
|
||||
<param name="Local" value="inverse_trigonometric_functions.html">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Hyperbolic functions">
|
||||
<param name="Local" value="hyperbolic_functions.html">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Inverse hyperbolic functions">
|
||||
<param name="Local" value="inverse_hyperbolic_functions.html">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Conversions between radians, degrees and gradians">
|
||||
<param name="Local" value="conversions_deg_rad_grad.html">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Rounding functions">
|
||||
<param name="Local" value="rounding_functions.html">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Other functions">
|
||||
<param name="Local" value="other_functions.html">
|
||||
</OBJECT>
|
||||
</UL>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Logical operators and functions">
|
||||
<param name="Local" value="logical_functions.html">
|
||||
@@ -37,6 +71,10 @@
|
||||
<param name="Name" value="Operators priority">
|
||||
<param name="Local" value="operators_priority.html">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Accuracy">
|
||||
<param name="Local" value="accuracy.html">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Tips">
|
||||
<param name="Local" value="tips.html">
|
||||
|
48
help/trigonometric_functions.html
Normal file
48
help/trigonometric_functions.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>TTCalc - Trigonometric 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="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">
|
||||
</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>
|
||||
|
||||
|
||||
<h2>Trigonometric functions</h2>
|
||||
|
||||
<p><strong>Note:</strong> On the display tab you can select between degrees, radians and gradians. In these samples we assume that the 'rad' option is selected.
|
||||
This affects the input value.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt>sin(x)</dt>
|
||||
<dd>This function returns the sine of x.<br>For example sin(0.8)=0.717...</dd>
|
||||
|
||||
<dt>cos(x)</dt>
|
||||
<dd>Cosine of x<br>cos(1.3)=0.267...</dd>
|
||||
|
||||
<dt>tan(x) or tg(x)</dt>
|
||||
<dd>Tangent of x<br>tan(3.6)=0.493...</dd>
|
||||
|
||||
<dt>cot(x) or ctg(x)</dt>
|
||||
<dd>Cotangent of x<br>cot(2.3)=-0.893...</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -16,19 +16,24 @@
|
||||
<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.
|
||||
You are allowed to define your own variables and functions. As a name of a variable or function
|
||||
can be a name consists of letters, digits or an underline character (only the first character must be a letter).
|
||||
From version 0.8.3 names are case-sensitive that means 'name' is not the same as 'NaMe'. For example these
|
||||
are correct names: a, b, c3, MyName. During defining variables and functions you can call another
|
||||
variables and functions.
|
||||
</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.
|
||||
For example you can define a function 'xy' as 'x1*x2' (of course without apostrophes), set the 'parameters' to '2'
|
||||
and then put into the edit box expression 'xy(10;20)', the result will be '200'. Note that we use a semicolon
|
||||
to separate arguments in the function.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
More complex example: myfunction(x) which returns sin(x) when the x is negative, 0 when the x is 0, and cos(x) when the x is greater than 0: <br>
|
||||
myfunction(x)='if(x==0; 0; if(x<0; sin(x); cos(x)))'
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
@@ -12,11 +12,14 @@
|
||||
<param name="Keyword" value="standard operators">
|
||||
<param name="Keyword" value="builtin variables">
|
||||
<param name="Keyword" value="e">
|
||||
<param name="Keyword" value="pi">
|
||||
<param name="Keyword" value="^">
|
||||
<param name="Keyword" value="*">
|
||||
<param name="Keyword" value="/">
|
||||
<param name="Keyword" value="+">
|
||||
<param name="Keyword" value="-">
|
||||
<param name="Keyword" value="#">
|
||||
<param name="Keyword" value="&">
|
||||
</object>
|
||||
</head>
|
||||
|
||||
@@ -24,31 +27,41 @@
|
||||
|
||||
<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&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.
|
||||
<p>
|
||||
You can type numbers directly using your keyboard or insert them by a mouse. This is a simple edit window,
|
||||
you can use arrow keys etc. and copy&paste text by using standard shortcuts such as CTRL+C and CTRL+V.
|
||||
Decimal point can be either a comma or a dot that means 1,234 is the same as 1.234.
|
||||
</p>
|
||||
|
||||
<h1>Standard operators</h1>
|
||||
|
||||
<dl>
|
||||
<dt>^</dt>
|
||||
<dd>Powering</dd>
|
||||
<dd>Powering, e.g.: 2^3=8</dd>
|
||||
|
||||
<dt>*</dt>
|
||||
<dd>Multiplication</dd>
|
||||
<dd>Multiplication, e.g.: 2*3=6</dd>
|
||||
|
||||
<dt>/</dt>
|
||||
<dd>Division</dd>
|
||||
<dd>Division, e.g.: 2/3 = 0.6666...</dd>
|
||||
|
||||
<dt>+</dt>
|
||||
<dd>Addition</dd>
|
||||
<dd>Addition, e.g.: 2+3=5<br>
|
||||
Unary plus, e.g.: +2</dd>
|
||||
|
||||
<dt>-</dt>
|
||||
<dd>Subtraction</dd>
|
||||
<dd>Subtraction, e.g.: 2-3=-1<br>
|
||||
Unary minus, e.g.: -2</dd>
|
||||
|
||||
<dt>#</dt>
|
||||
<dd>Operator for changing the base (radix) to 16 (hex), e.g.: #ff=255</dd>
|
||||
|
||||
<dt>&</dt>
|
||||
<dd>Operator for changing the base (radix) to 2 (bin), e.g.: -&110=-6</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>
|
||||
<p>Of course you can use parentheses ( and ). Look at <a href="operators_priority.html">operators priority</a> as well.</p>
|
||||
|
||||
<h1>Built-in variables</h1>
|
||||
|
||||
|
BIN
res/icon02.ico
Normal file
BIN
res/icon02.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2006-2007, Tomasz Sowa
|
||||
Copyright (c) 2006-2009, Tomasz Sowa
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@@ -3,34 +3,47 @@
|
||||
|
||||
[Setup]
|
||||
AppName=TTCalc
|
||||
AppVerName=TTCalc 0.8.1
|
||||
AppVerName=TTCalc 0.8.7
|
||||
AppVersion=0.8.7
|
||||
AppPublisher=Tomasz Sowa
|
||||
AppPublisherURL=http://sourceforge.net/projects/ttcalc
|
||||
AppSupportURL=http://sourceforge.net/projects/ttcalc
|
||||
AppUpdatesURL=http://sourceforge.net/projects/ttcalc
|
||||
AppPublisherURL=http://ttcalc.sourceforge.net
|
||||
AppSupportURL=http://ttcalc.sourceforge.net
|
||||
AppUpdatesURL=http://ttcalc.sourceforge.net
|
||||
DefaultDirName={pf}\TTCalc
|
||||
DefaultGroupName=TTCalc
|
||||
AllowNoIcons=yes
|
||||
; special COPYRIGHT version (without a new line characters in the clause -- it is better displayed in the setup window)
|
||||
LicenseFile=COPYRIGHT
|
||||
OutputDir=..\..\output_setup
|
||||
OutputDir=..\setup
|
||||
OutputBaseFilename=ttcalc-setup
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
ShowUndisplayableLanguages=yes
|
||||
PrivilegesRequired=none
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
|
||||
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
|
||||
Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
|
||||
Name: "chinese"; MessagesFile: "compiler:Languages\ChineseSimp-12-5.1.11.isl"
|
||||
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
|
||||
Name: "swedish"; MessagesFile: "compiler:Languages\Swedish.isl"
|
||||
|
||||
[InstallDelete]
|
||||
; prior to 0.8.3 we were using mingwm10.dll (now it is not needed and will be deleted if exists)
|
||||
Type: files; Name: "{app}\mingwm10.dll"
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; 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: "..\src\ttcalc.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "..\help\ttcalc.chm"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "..\COPYRIGHT"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "ttcalc.ini"; DestDir: "{userappdata}\TTCalc"; Flags: onlyifdoesntexist
|
||||
Source: "..\CHANGELOG"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "..\README"; DestDir: "{app}"; Flags: ignoreversion
|
||||
; now we do not use *.ini file in the installer
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
[Icons]
|
||||
|
@@ -1,21 +0,0 @@
|
||||
# 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]
|
34
src/Makefile
34
src/Makefile
@@ -1,19 +1,43 @@
|
||||
CC = g++
|
||||
CFLAGS = -Wall -pedantic -s -O2 -mwindows -mthreads -I../../../ttmath
|
||||
#CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../ttmath -DTTCALC_CONVERT
|
||||
CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../ttmath
|
||||
name = ttcalc.exe
|
||||
dir_output = ../../output
|
||||
|
||||
# the name of the help is also set in the html help workshop project file
|
||||
helpname = ttcalc.chm
|
||||
|
||||
# the name of the setup is also set in the Inno Setup config file
|
||||
setupname = ttcalc-setup.exe
|
||||
|
||||
|
||||
|
||||
all: ttcalc
|
||||
|
||||
|
||||
include Makefile.dep
|
||||
|
||||
|
||||
ttcalc: $(o)
|
||||
$(CC) -o $(dir_output)/$(name) $(CFLAGS) $(o) -lcomctl32
|
||||
$(CC) -o $(name) $(CFLAGS) $(o) -lcomctl32
|
||||
|
||||
|
||||
resource.o: resource.rc
|
||||
#windres -DTTCALC_CONVERT resource.rc resource.o
|
||||
windres resource.rc resource.o
|
||||
|
||||
|
||||
help: $(helpdep)
|
||||
Makefile.help.sh
|
||||
|
||||
|
||||
|
||||
setup: $(setupdep)
|
||||
iscc ../setup/innosetup.iss
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f *.s
|
||||
rm -f $(dir_output)/$(name)
|
||||
rm -f $(name)
|
||||
rm -f ttcalcp.exe
|
||||
rm -f ../help/$(helpname)
|
||||
rm -f ../setup/$(setupname)
|
||||
|
@@ -1,17 +1,45 @@
|
||||
o = resource.o calculation.o functions.o iniparser.o languages.o mainwindow.o parsermanager.o programresources.o tabs.o variables.o winmain.o
|
||||
o = resource.o calculation.o convert.o functions.o iniparser.o languages.o mainwindow.o parsermanager.o programresources.o tabs.o variables.o winmain.o
|
||||
|
||||
calculation.o: calculation.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h tabs.h messages.h
|
||||
functions.o: functions.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h
|
||||
calculation.o: calculation.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h tabs.h messages.h
|
||||
convert.o: convert.cpp convert.h compileconfig.h bigtypes.h
|
||||
functions.o: functions.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
|
||||
iniparser.o: iniparser.cpp compileconfig.h iniparser.h
|
||||
languages.o: languages.cpp compileconfig.h languages.h
|
||||
mainwindow.o: mainwindow.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h resource.h messages.h tabs.h
|
||||
parsermanager.o: parsermanager.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h
|
||||
programresources.o: programresources.cpp compileconfig.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h
|
||||
tabs.o: tabs.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h
|
||||
variables.o: variables.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h
|
||||
winmain.o: winmain.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h resource.h messages.h tabs.h
|
||||
languages.o: languages.cpp compileconfig.h languages.h bigtypes.h
|
||||
mainwindow.o: mainwindow.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h tabs.h
|
||||
parsermanager.o: parsermanager.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h tabs.h messages.h
|
||||
programresources.o: programresources.cpp compileconfig.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
|
||||
tabs.o: tabs.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
|
||||
variables.o: variables.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
|
||||
winmain.o: winmain.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h tabs.h
|
||||
|
||||
|
||||
.SUFFIXES: .cpp .o
|
||||
|
||||
.cpp.o:
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
|
||||
helpdep = ../help/accuracy.html \
|
||||
../help/arithmetic_functions.html \
|
||||
../help/bitwise_functions.html \
|
||||
../help/conversions_deg_rad_grad.html \
|
||||
../help/help.hhp \
|
||||
../help/hyperbolic_functions.html \
|
||||
../help/index.hhk \
|
||||
../help/index.html \
|
||||
../help/inverse_hyperbolic_functions.html \
|
||||
../help/inverse_trigonometric_functions.html \
|
||||
../help/logarithm_exponential.html \
|
||||
../help/logical_functions.html \
|
||||
../help/operators_priority.html \
|
||||
../help/other_functions.html \
|
||||
../help/rounding_functions.html \
|
||||
../help/styles.css \
|
||||
../help/tips.html \
|
||||
../help/toc.hhc \
|
||||
../help/trigonometric_functions.html \
|
||||
../help/userfunctions.html \
|
||||
../help/values_and_std_operators.html
|
||||
|
||||
|
||||
setupdep = ttcalc help ../setup/innosetup.iss ../setup/COPYRIGHT ../COPYRIGHT ../CHANGELOG ../README
|
||||
|
16
src/Makefile.help.sh
Normal file
16
src/Makefile.help.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
# we provide a small wrapper for Html Help Workshop because the Html HW returns 1 when
|
||||
# it has compiled the help and the 'make' program then stops
|
||||
|
||||
hhc ../help/help.hhp
|
||||
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
# there was an error
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# there was a success
|
||||
|
||||
exit 0
|
@@ -1,7 +1,6 @@
|
||||
CC = g++
|
||||
CFLAGS = -Wall -pedantic -s -Os -fno-default-inline -mwindows -mthreads -I../../../ttmath -DTTCALC_PORTABLE
|
||||
CFLAGS = -Wall -pedantic -s -Os -fno-default-inline -mwindows -I../../ttmath -DTTCALC_PORTABLE
|
||||
name = ttcalcp.exe
|
||||
dir_output = ../../output
|
||||
compressor = upx
|
||||
|
||||
all: ttcalc
|
||||
@@ -9,13 +8,14 @@ all: ttcalc
|
||||
include Makefile.dep
|
||||
|
||||
ttcalc: $(o)
|
||||
$(CC) -o $(dir_output)/$(name) $(CFLAGS) $(o) -lcomctl32
|
||||
$(compressor) -7 $(dir_output)/$(name)
|
||||
$(CC) -o $(name) $(CFLAGS) $(o) -lcomctl32
|
||||
$(compressor) -7 $(name)
|
||||
|
||||
resource.o: resource.rc
|
||||
windres -DTTCALC_PORTABLE resource.rc resource.o
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f *.s
|
||||
rm -f $(dir_output)/$(name)
|
||||
rm -f $(name)
|
||||
rm -f ../help/$(helpname)
|
||||
|
||||
|
74
src/bigtypes.h
Normal file
74
src/bigtypes.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is a part of TTCalc - a mathematical calculator
|
||||
* and is distributed under the (new) BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2009, 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.
|
||||
*/
|
||||
|
||||
#ifndef bigtypesheader
|
||||
#define bigtypesheader
|
||||
|
||||
#include "compileconfig.h"
|
||||
|
||||
//#define TTMATH_RELEASE
|
||||
#include <ttmath/ttmath.h>
|
||||
|
||||
|
||||
#ifndef TTCALC_PORTABLE
|
||||
|
||||
/*
|
||||
// old ones
|
||||
ttmath::Big<1,3>
|
||||
ttmath::Big<2,6>
|
||||
ttmath::Big<3,9>
|
||||
*/
|
||||
|
||||
typedef ttmath::Big<1,3> TTMathBig1;
|
||||
typedef ttmath::Big<2,9> TTMathBig2;
|
||||
typedef ttmath::Big<4,27> TTMathBig3;
|
||||
typedef TTMathBig3 TTMathBigMax;
|
||||
|
||||
#else
|
||||
|
||||
/* portable */
|
||||
|
||||
typedef ttmath::Big<1,3> TTMathBig1;
|
||||
typedef TTMathBig1 TTMathBigMax;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -65,6 +65,9 @@ unsigned __stdcall CalculationsProcedure(void *)
|
||||
SetDlgItemText(main_window, IDC_OUTPUT_EDIT, "");
|
||||
PostMessage(main_window, WM_SET_LAST_ERROR, (WPARAM)ttmath::err_still_calculating, 0);
|
||||
|
||||
// we're showing info about converting
|
||||
parser_manager.ShowConvertingInfo();
|
||||
|
||||
// and finally we're parsing the input string
|
||||
parser_manager.Parse();
|
||||
|
||||
@@ -74,7 +77,10 @@ unsigned __stdcall CalculationsProcedure(void *)
|
||||
// at the end we're printing the result
|
||||
// if there was a stop signal we continue the main loop without printing any values
|
||||
if( ! GetPrgRes()->GetThreadController()->WasStopSignal() )
|
||||
parser_manager.PrintResult();
|
||||
if( parser_manager.PrintResult() )
|
||||
PostMessage(main_window, WM_SET_LAST_ERROR, (WPARAM)parser_manager.GetLastCode(), 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -55,7 +55,7 @@
|
||||
*/
|
||||
#define TTCALC_MAJOR_VER 0
|
||||
#define TTCALC_MINOR_VER 8
|
||||
#define TTCALC_REVISION_VER 2
|
||||
#define TTCALC_REVISION_VER 7
|
||||
#define TTCALC_PRERELEASE_VER 0
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@
|
||||
#pragma warning (disable : 4800)
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_IE
|
||||
#define _WIN32_IE 0x0501
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
444
src/convert.cpp
Normal file
444
src/convert.cpp
Normal file
@@ -0,0 +1,444 @@
|
||||
/*
|
||||
* This file is a part of TTCalc - a mathematical calculator
|
||||
* and is distributed under the (new) BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2009, 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.
|
||||
*/
|
||||
|
||||
#include "convert.h"
|
||||
|
||||
|
||||
|
||||
Convert::Convert()
|
||||
{
|
||||
Init();
|
||||
current_conv_type = 0;
|
||||
CheckCurrentUnits();
|
||||
}
|
||||
|
||||
|
||||
void Convert::AddType(const char * name)
|
||||
{
|
||||
if( type_tab.empty() )
|
||||
return;
|
||||
|
||||
Type temp;
|
||||
temp.name = name;
|
||||
|
||||
type_tab.back().push_back(temp);
|
||||
}
|
||||
|
||||
|
||||
void Convert::AddUnit(const char * name, const char * abbr, int numerator, int denominator)
|
||||
{
|
||||
if( type_tab.empty() || type_tab.back().empty() || unit_tab.empty() )
|
||||
return;
|
||||
|
||||
Unit temp;
|
||||
temp.name = name;
|
||||
|
||||
if( abbr != 0 )
|
||||
temp.abbr = abbr;
|
||||
|
||||
|
||||
temp.type = int(type_tab.back().size()-1);
|
||||
|
||||
|
||||
temp.value_numerator.FromInt(numerator);
|
||||
|
||||
if( denominator != 1 )
|
||||
{
|
||||
// value_denominator is set into one (default)
|
||||
temp.value_denominator.FromInt(denominator);
|
||||
}
|
||||
|
||||
unit_tab.back().push_back(temp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Convert::AddUnit(const char * name, const char * abbr, const char * v)
|
||||
{
|
||||
if( type_tab.empty() || type_tab.back().empty() || unit_tab.empty() )
|
||||
return;
|
||||
|
||||
Unit temp;
|
||||
temp.name = name;
|
||||
temp.abbr = abbr;
|
||||
temp.type = int(type_tab.back().size()-1);
|
||||
temp.value_numerator.FromString(v, 16);
|
||||
|
||||
unit_tab.back().push_back(temp);
|
||||
}
|
||||
|
||||
|
||||
void Convert::Init()
|
||||
{
|
||||
// en
|
||||
type_tab.push_back( std::vector<Type>() );
|
||||
unit_tab.push_back( std::vector<Unit>() );
|
||||
|
||||
AddType("none");
|
||||
|
||||
/*
|
||||
yard = 0.9144 metre
|
||||
foot = 1/3 yard = 0.3048 metre
|
||||
inch = 1/36 yard = 1/12 foot = 0.0254 metre
|
||||
|
||||
In 1958 the United States and countries of the Commonwealth of Nations
|
||||
defined the length of the international yard to be precisely 0.9144 metres.
|
||||
|
||||
1 point (Didot's system) = 1 / 2660 m
|
||||
1 point (pica - USA and UK) = 1 / 72 inch
|
||||
*/
|
||||
AddType("length"); // base: 10000 metre
|
||||
AddUnit("inch", "in", 254);
|
||||
AddUnit("foot", "ft", 3048);
|
||||
AddUnit("yard", "yd", 9144);
|
||||
AddUnit("metre", "m", 10000);
|
||||
AddUnit("mile (land)", "mi", 16093440); // 1 land mile = 1609.344 metres
|
||||
AddUnit("mile (nautical)", "nmi", 18520000); // 1 nautical mile = 1852 metres
|
||||
AddUnit("point (Didot)", "p", 10000, 2660);
|
||||
AddUnit("point (pica)", "p", 18288, 5184);
|
||||
AddUnit("light year", "ly", "520F0AA65AAEBAC00"); // 1 ly = 9 460 730 472 580 800 metres
|
||||
// 520F0AA65AAEBAC00 (hex) = 94607304725808000000 (dec)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
yard^2 = 0.83612736 metre^2
|
||||
foot^2 = 1/9 yard^2 = 0.09290304 metre^2
|
||||
inch^2 = 1/1296 yard^2 = 1/144 foot^ = 0.00064516 metre^2
|
||||
|
||||
ar = 100 metre^2
|
||||
hectere = 10000 metre^2
|
||||
*/
|
||||
|
||||
// !!! give a smaller base here
|
||||
AddType("area"); // base: 100 000 000 metre^2
|
||||
AddUnit("inch^2", "in^2", 64516);
|
||||
AddUnit("foot^2", "ft^2", 9290304);
|
||||
AddUnit("yard^2", "yd^2", 83612736);
|
||||
AddUnit("metre^2", "m^2", 100000000);
|
||||
AddUnit("are", "a", "2540BE400"); // 10000000000 (dec)
|
||||
AddUnit("hectare", "ha", "E8D4A51000"); // 1000000000000 (dec)
|
||||
AddUnit("mile (land)^2", "mi^2", "EB8EDC210000" ); // 258998811033600 (dec), 1 land mile^2 = 2589988.110336 metres^2
|
||||
AddUnit("mile (nautical)^2", "nmi^2", "137F2ACF41000"); // 342990400000000 (dec), 1 nautical mile^2 = 3429904 metres^2
|
||||
AddUnit("light year^2", "ly^2", "1A4DA3B4D207FB4C43D08391653B900000"); // 1 ly = 89505421074818927300612528640000 metres^2
|
||||
// 1A4DA3B4D207FB4C43D08391653B900000 (hex) = 8950542107481892730061252864000000000000 (dec)
|
||||
|
||||
|
||||
AddType("time"); // base: second
|
||||
AddUnit("second", "s", 1);
|
||||
AddUnit("minute", "m", 60);
|
||||
AddUnit("hour", "h", 3600);
|
||||
AddUnit("day", "d", 86400);
|
||||
AddUnit("week", "w", 604800);
|
||||
AddUnit("fortnight", "fn", 1209600);
|
||||
AddUnit("month", "m", 2592000);
|
||||
AddUnit("year", "y", 31536000);
|
||||
AddUnit("year (mean)", "my", 31557600);
|
||||
AddUnit("year (leap)", "ly", 31622400);
|
||||
AddUnit("decade", "dc", 315360000);
|
||||
|
||||
|
||||
|
||||
// pl
|
||||
// the 'value' param we're using only from the english
|
||||
type_tab.push_back( std::vector<Type>() );
|
||||
unit_tab.push_back( std::vector<Unit>() );
|
||||
|
||||
AddType("brak");
|
||||
|
||||
AddType("d<EFBFBD>ugo<EFBFBD><EFBFBD>");
|
||||
AddUnit("cal");
|
||||
AddUnit("stopa");
|
||||
AddUnit("jard");
|
||||
AddUnit("metr");
|
||||
AddUnit("mila (angielska)");
|
||||
AddUnit("mila (morska)");
|
||||
AddUnit("punkt (Didot)");
|
||||
AddUnit("punkt (pica)");
|
||||
AddUnit("rok <20>wietlny");
|
||||
|
||||
AddType("powierzchnia");
|
||||
AddUnit("cal^2");
|
||||
AddUnit("stopa^2");
|
||||
AddUnit("jard^2");
|
||||
AddUnit("metr^2");
|
||||
AddUnit("ar", "");
|
||||
AddUnit("hektar");
|
||||
AddUnit("mila (angielska)^2");
|
||||
AddUnit("mila (morska)^2");
|
||||
AddUnit("rok <20>wietlny^2");
|
||||
|
||||
|
||||
AddType("czas");
|
||||
AddUnit("sekunda");
|
||||
AddUnit("minuta");
|
||||
AddUnit("godzina");
|
||||
AddUnit("dzie<EFBFBD>");
|
||||
AddUnit("tydzie<EFBFBD>");
|
||||
AddUnit("dwa tygodnie");
|
||||
AddUnit("miesi<EFBFBD>c");
|
||||
AddUnit("rok");
|
||||
AddUnit("rok (<28>redni)");
|
||||
AddUnit("rok (przest<73>pny)");
|
||||
AddUnit("dekada");
|
||||
|
||||
CheckAfterInit();
|
||||
}
|
||||
|
||||
|
||||
void Convert::ErrorMessage()
|
||||
{
|
||||
MessageBox(0, "Internal error: tables for converting have incorrect values",
|
||||
"Internal error", MB_ICONERROR);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
void Convert::CheckAfterInit()
|
||||
{
|
||||
unsigned int i, len;
|
||||
|
||||
if( type_tab.size() != unit_tab.size() )
|
||||
return ErrorMessage();
|
||||
|
||||
if( type_tab.empty() )
|
||||
return;
|
||||
|
||||
len = (unsigned int)type_tab[0].size();
|
||||
for(i=1 ; i<type_tab.size() ; ++i)
|
||||
{
|
||||
if( len != type_tab[i].size() )
|
||||
return ErrorMessage();
|
||||
}
|
||||
|
||||
len = (unsigned int)unit_tab[0].size();
|
||||
for(i=1 ; i<unit_tab.size() ; ++i)
|
||||
{
|
||||
if( len != unit_tab[i].size() )
|
||||
return ErrorMessage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
cid - country id
|
||||
|
||||
*/
|
||||
const char * Convert::GetTypeName(int cid, int id)
|
||||
{
|
||||
const char * unk_err = "unknown";
|
||||
|
||||
if( type_tab.empty() )
|
||||
return unk_err;
|
||||
|
||||
if( cid >= (int)type_tab.size() )
|
||||
cid = 0;
|
||||
|
||||
if( id< 0 || id >= int(type_tab[cid].size()) )
|
||||
return unk_err;
|
||||
|
||||
return type_tab[cid][id].name.c_str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const char * Convert::GetUnitName(int cid, int id)
|
||||
{
|
||||
const char * unk_err = "unknown";
|
||||
|
||||
if( unit_tab.empty() )
|
||||
return unk_err;
|
||||
|
||||
if( cid >= (int)unit_tab.size() )
|
||||
cid = 0;
|
||||
|
||||
if( id < 0 || id >= int(unit_tab[cid].size()) )
|
||||
return unk_err;
|
||||
|
||||
return unit_tab[cid][id].name.c_str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const char * Convert::GetUnitAbbr(int cid, int id)
|
||||
{
|
||||
const char * unk_err = "unknown";
|
||||
|
||||
if( unit_tab.empty() )
|
||||
return unk_err;
|
||||
|
||||
if( cid >= (int)unit_tab.size() )
|
||||
cid = 0;
|
||||
|
||||
if( id < 0 || id >= int(unit_tab[cid].size()) )
|
||||
return unk_err;
|
||||
|
||||
if( !unit_tab[cid][id].abbr.empty() )
|
||||
return unit_tab[cid][id].abbr.c_str();
|
||||
|
||||
/*
|
||||
if there is no defined an abbreviation in the specific
|
||||
language, we return the abbreviation from english
|
||||
*/
|
||||
|
||||
return unit_tab[0][id].abbr.c_str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int Convert::GetTypeSize()
|
||||
{
|
||||
if( type_tab.empty() )
|
||||
return 0;
|
||||
|
||||
return int(type_tab[0].size());
|
||||
}
|
||||
|
||||
|
||||
int Convert::GetUnitSize()
|
||||
{
|
||||
if( unit_tab.empty() )
|
||||
return 0;
|
||||
|
||||
return int(unit_tab[0].size());
|
||||
}
|
||||
|
||||
|
||||
int Convert::GetUnitType(int id)
|
||||
{
|
||||
if( unit_tab.empty() )
|
||||
return -1;
|
||||
|
||||
if( id >= int(unit_tab[0].size()) )
|
||||
return -1;
|
||||
|
||||
return unit_tab[0][id].type;
|
||||
}
|
||||
|
||||
|
||||
// value is taken only from english
|
||||
bool Convert::GetUnitValue(int id, TTMathBigMax & numerator, TTMathBigMax & denominator)
|
||||
{
|
||||
if( unit_tab.empty() )
|
||||
return false;
|
||||
|
||||
if( id >= int(unit_tab[0].size()) )
|
||||
return false;
|
||||
|
||||
numerator = unit_tab[0][id].value_numerator;
|
||||
denominator = unit_tab[0][id].value_denominator;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// gui
|
||||
|
||||
void Convert::SetCurrentType(int c)
|
||||
{
|
||||
current_conv_type = c;
|
||||
}
|
||||
|
||||
|
||||
int Convert::GetCurrentType()
|
||||
{
|
||||
return current_conv_type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Convert::CheckUnitIndex(int type)
|
||||
{
|
||||
if( current_conv_unit[type].input < -1 || current_conv_unit[type].input >= GetUnitSize() )
|
||||
current_conv_unit[type].input = 0; // maybe better to -1 ?
|
||||
|
||||
if( current_conv_unit[type].output < -1 || current_conv_unit[type].output >= GetUnitSize() )
|
||||
current_conv_unit[type].output = 0; // the same
|
||||
}
|
||||
|
||||
|
||||
void Convert::CheckCurrentUnits()
|
||||
{
|
||||
int len = GetTypeSize();
|
||||
|
||||
if( static_cast<int>( current_conv_unit.size() ) != len )
|
||||
current_conv_unit.resize(len);
|
||||
|
||||
for(int i = 0 ; i<len ; ++i)
|
||||
CheckUnitIndex(i);
|
||||
}
|
||||
|
||||
|
||||
void Convert::SetCurrentUnit(int type, int input, int output)
|
||||
{
|
||||
int len = GetTypeSize();
|
||||
|
||||
if( type >= len )
|
||||
return;
|
||||
|
||||
current_conv_unit[type].input = input;
|
||||
current_conv_unit[type].output = output;
|
||||
CheckUnitIndex(type);
|
||||
}
|
||||
|
||||
|
||||
bool Convert::GetCurrentUnit(int type, int & input, int & output)
|
||||
{
|
||||
int len = GetTypeSize();
|
||||
|
||||
if( type >= len )
|
||||
{
|
||||
input = output = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
input = current_conv_unit[type].input;
|
||||
output = current_conv_unit[type].output;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
176
src/convert.h
Normal file
176
src/convert.h
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* This file is a part of TTCalc - a mathematical calculator
|
||||
* and is distributed under the (new) BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2009, 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.
|
||||
*/
|
||||
|
||||
#ifndef convertheader
|
||||
#define convertheader
|
||||
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
#include "compileconfig.h"
|
||||
#include "bigtypes.h"
|
||||
|
||||
|
||||
|
||||
class Convert
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Convert();
|
||||
|
||||
|
||||
/*
|
||||
none, length, area, time,
|
||||
*/
|
||||
struct Type
|
||||
{
|
||||
std::string name;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct Unit
|
||||
{
|
||||
std::string name, abbr;
|
||||
int type;
|
||||
TTMathBigMax value_numerator, value_denominator;
|
||||
|
||||
Unit()
|
||||
{
|
||||
type = -1;
|
||||
value_numerator.SetZero();
|
||||
value_denominator.SetOne();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
std::vector<std::vector<Type> > type_tab;
|
||||
std::vector<std::vector<Unit> > unit_tab;
|
||||
|
||||
|
||||
|
||||
|
||||
void AddType(const char * name);
|
||||
void AddUnit(const char * name, const char * abbr = 0, int numerator = 0, int denominator = 1);
|
||||
void AddUnit(const char * name, const char * abbr, const char * v);
|
||||
|
||||
void Init();
|
||||
|
||||
|
||||
const char * GetTypeName(int cid, int id);
|
||||
|
||||
const char * GetUnitName(int cid, int id);
|
||||
const char * GetUnitAbbr(int cid, int id);
|
||||
int GetUnitType(int id);
|
||||
|
||||
int GetTypeSize();
|
||||
int GetUnitSize();
|
||||
|
||||
|
||||
/*
|
||||
the return value is the same for all languages
|
||||
(in fact we're taking it from english)
|
||||
*/
|
||||
bool GetUnitValue(int id, TTMathBigMax & numerator, TTMathBigMax & denominator);
|
||||
|
||||
void ErrorMessage();
|
||||
void CheckAfterInit();
|
||||
|
||||
|
||||
template<class ValueType>
|
||||
int Conversion(int conv_input_unit, int conv_output_unit, ValueType & result)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
ValueType v1_n, v1_d; // input
|
||||
ValueType v2_n, v2_d; // output
|
||||
|
||||
TTMathBigMax v1_n_, v1_d_; // input
|
||||
TTMathBigMax v2_n_, v2_d_; // output
|
||||
|
||||
if( !GetUnitValue(conv_input_unit, v1_n_, v1_d_) )
|
||||
return 1;
|
||||
|
||||
if( !GetUnitValue(conv_output_unit, v2_n_, v2_d_) )
|
||||
return 1;
|
||||
|
||||
v1_n.FromBig( v1_n_ );
|
||||
v1_d.FromBig( v1_d_ );
|
||||
v2_n.FromBig( v2_n_ );
|
||||
v2_d.FromBig( v2_d_ );
|
||||
|
||||
// result = result * (v1_n * v2_d) / (v1_d * v2_n)
|
||||
c += result.Mul(v1_n);
|
||||
c += result.Mul(v2_d);
|
||||
c += v1_d.Mul(v2_n);
|
||||
c += result.Div(v1_d);
|
||||
|
||||
return (c==0)? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
for the interface
|
||||
*/
|
||||
|
||||
int current_conv_type; // selected type of converting: none, length, area, ...
|
||||
|
||||
struct CurrentConvUnit
|
||||
{
|
||||
int input, output;
|
||||
CurrentConvUnit() { input = output = -1; }
|
||||
};
|
||||
|
||||
std::vector<CurrentConvUnit> current_conv_unit;
|
||||
|
||||
|
||||
|
||||
void SetCurrentType(int c);
|
||||
int GetCurrentType();
|
||||
void CheckUnitIndex(int type);
|
||||
void CheckCurrentUnits();
|
||||
void SetCurrentUnit(int type, int input, int output);
|
||||
bool GetCurrentUnit(int type, int & input, int & output);
|
||||
|
||||
// end part of gui
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -97,10 +97,10 @@ int i;
|
||||
pchar = new char[temporary_buffer_size];
|
||||
|
||||
GetDlgItemText(hWnd, IDC_EDIT_FUNCTION_NAME, pchar, temporary_buffer_size);
|
||||
name = Variables::ChangeToSmallLetters( Variables::StripWhiteCharacters(pchar) );
|
||||
name = Variables::StripWhiteCharacters(pchar);
|
||||
|
||||
GetDlgItemText(hWnd, IDC_EDIT_FUNCTION_VALUE, pchar, temporary_buffer_size);
|
||||
value = Variables::ChangeToSmallLetters( Variables::StripWhiteCharacters(pchar) );
|
||||
value = Variables::StripWhiteCharacters(pchar);
|
||||
|
||||
parameters = (int)SendDlgItemMessage(hWnd,IDC_COMBO_FUNCTION_PARAM,CB_GETCURSEL,0,0);
|
||||
|
||||
@@ -223,6 +223,7 @@ BOOL WmTabCommand_AddFunction(HWND, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||
code = GetPrgRes()->GetFunctions()->Add(name, value, parameters);
|
||||
GetPrgRes()->FunctionsChanged();
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
if( code != ttmath::err_ok )
|
||||
@@ -290,6 +291,7 @@ adding = false;
|
||||
// if we've changed the name then we're changing the value and parameters
|
||||
code = GetPrgRes()->GetFunctions()->EditValue(name, value, parameters);
|
||||
|
||||
GetPrgRes()->FunctionsChanged();
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
if( code != ttmath::err_ok )
|
||||
@@ -339,9 +341,12 @@ int items = ListView_GetSelectedCount(list);
|
||||
all_deleted = false;
|
||||
else
|
||||
ListView_DeleteItem(list, id);
|
||||
|
||||
GetPrgRes()->FunctionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
delete [] buffer;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -44,6 +44,26 @@ IniParser::IniParser()
|
||||
{
|
||||
strip_white_characters_from_value = true;
|
||||
convert_value_to_small_letters = true;
|
||||
section_case_sensitive = false;
|
||||
pattern_case_sensitive = false;
|
||||
}
|
||||
|
||||
|
||||
void IniParser::ConvertValueToSmallLetters(bool conv)
|
||||
{
|
||||
convert_value_to_small_letters = conv;
|
||||
}
|
||||
|
||||
|
||||
void IniParser::SectionCaseSensitive(bool sens)
|
||||
{
|
||||
section_case_sensitive = sens;
|
||||
}
|
||||
|
||||
|
||||
void IniParser::PatternCaseSensitive(bool sens)
|
||||
{
|
||||
pattern_case_sensitive = sens;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +168,9 @@ IniParser::Error IniParser::ReadSection(std::string & section)
|
||||
}
|
||||
|
||||
while( IsSectionCharacter( (c = ReadCharacter()) ) )
|
||||
if( section_case_sensitive )
|
||||
section += c;
|
||||
else
|
||||
section += LowerCase(c);
|
||||
|
||||
if( c != ']' )
|
||||
@@ -220,7 +243,11 @@ IniParser::Error IniParser::ReadExpression(std::string & pattern, std::string &
|
||||
|
||||
while( IsPatternCharacter(c) )
|
||||
{
|
||||
if( pattern_case_sensitive )
|
||||
pattern += c;
|
||||
else
|
||||
pattern += LowerCase(c);
|
||||
|
||||
c = ReadCharacter();
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -133,6 +133,34 @@ public:
|
||||
Error ReadFromFile(const char * path);
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
when true the names of sections will be case-sensitive
|
||||
e.g.
|
||||
when true: '[foo]' is not equal '[Foo]'
|
||||
|
||||
default: false
|
||||
*/
|
||||
void SectionCaseSensitive(bool sens);
|
||||
|
||||
|
||||
/*!
|
||||
when true the names of patterns will be case-sensitive
|
||||
e.g.
|
||||
when true: 'foo = 4' is not equal 'Foo = 4'
|
||||
|
||||
default: false
|
||||
*/
|
||||
void PatternCaseSensitive(bool sens);
|
||||
|
||||
|
||||
/*!
|
||||
if conv=true (default) that the whole characters in a value
|
||||
will be changed into small letters
|
||||
*/
|
||||
void ConvertValueToSmallLetters(bool conv);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
typedef std::map<std::string, std::string *> Table;
|
||||
@@ -144,6 +172,8 @@ private:
|
||||
int line;
|
||||
bool strip_white_characters_from_value;
|
||||
bool convert_value_to_small_letters;
|
||||
bool section_case_sensitive;
|
||||
bool pattern_case_sensitive;
|
||||
|
||||
Error Read();
|
||||
Error ReadSection(std::string & section);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <ttmath/ttmathtypes.h>
|
||||
#include "bigtypes.h"
|
||||
|
||||
|
||||
class Languages
|
||||
@@ -83,6 +83,7 @@ public:
|
||||
tab_functions,
|
||||
tab_precision,
|
||||
tab_display,
|
||||
tab_convert,
|
||||
radio_precision_1,
|
||||
radio_precision_2,
|
||||
radio_precision_3,
|
||||
@@ -91,15 +92,21 @@ public:
|
||||
precision_3_info,
|
||||
overflow_during_printing,
|
||||
combo_rounding_none,
|
||||
combo_rounding_cut_last_digits,
|
||||
combo_rounding_integer,
|
||||
combo_rounding_to_number,
|
||||
combo_rounding_after_comma,
|
||||
check_remove_zeroes,
|
||||
display_input,
|
||||
display_output,
|
||||
display_rounding,
|
||||
display_always_scientific,
|
||||
display_not_always_scientific,
|
||||
display_decimal_point,
|
||||
display_deg_rad_grad,
|
||||
convert_type,
|
||||
convert_input,
|
||||
convert_output,
|
||||
convert_dynamic_output,
|
||||
menu_view,
|
||||
menu_edit,
|
||||
menu_help,
|
||||
@@ -110,6 +117,11 @@ public:
|
||||
menu_view_always_on_top,
|
||||
menu_view_lang_english,
|
||||
menu_view_lang_polish,
|
||||
menu_view_lang_spanish,
|
||||
menu_view_lang_danish,
|
||||
menu_view_lang_chinese,
|
||||
menu_view_lang_russian,
|
||||
menu_view_lang_swedish,
|
||||
menu_view_close_program,
|
||||
menu_edit_undo,
|
||||
menu_edit_paste,
|
||||
@@ -138,9 +150,14 @@ public:
|
||||
// (after conversion to 'int' we pass it into the std::vector)
|
||||
enum Country
|
||||
{
|
||||
en = 0, pl
|
||||
en = 0, pl, sp, da, chn, ru, swe
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// TTMathBigMax foo_return;
|
||||
|
||||
private:
|
||||
|
||||
Country current_country;
|
||||
@@ -154,13 +171,16 @@ private:
|
||||
void InsertGuiPair(GuiMsg code, const char * message);
|
||||
void InitGuiMessagesTab();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
Languages()
|
||||
{
|
||||
current_country = en;
|
||||
// foo_return = 0;
|
||||
}
|
||||
|
||||
void SetCurrentLanguage(Country c)
|
||||
@@ -173,11 +193,47 @@ public:
|
||||
return current_country;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
we're using some methods from this class simultaneously in two threads,
|
||||
this is to be sure that everything is initialized before the second thread is started
|
||||
|
||||
should be called before calling the second thread
|
||||
*/
|
||||
void InitAll()
|
||||
{
|
||||
InitErrorMessagesTab();
|
||||
InitGuiMessagesTab();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
long form of methods
|
||||
(with 'coutry')
|
||||
|
||||
these methods you can call from the second thread without having to
|
||||
calling StopCalculating() and StartCalculating() from the thread controller
|
||||
|
||||
the methods return only static value - remember to call InitAll() somewhere
|
||||
at the beginning e.g. in the first thread
|
||||
*/
|
||||
const char * ErrorMessage(Country country, ttmath::ErrorCode code);
|
||||
const char * ErrorMessage(ttmath::ErrorCode code);
|
||||
const char * GuiMessage(Country country, GuiMsg code);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
short form of methods
|
||||
(without 'country' - it's taken from a private variable 'current_country')
|
||||
|
||||
don't use these methods in the second thread - the parameter 'country' can be using
|
||||
by the first thread, although the 'country' is simply enum and should be atomic
|
||||
but in the future it may be changed
|
||||
*/
|
||||
const char * ErrorMessage(ttmath::ErrorCode code);
|
||||
const char * GuiMessage(GuiMsg code);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -238,6 +238,114 @@ return false;
|
||||
}
|
||||
|
||||
|
||||
int ToLower(int c)
|
||||
{
|
||||
if( c>='A' && c<='Z' )
|
||||
return c - 'A' + 'a';
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
this function compares two strings
|
||||
(case insensitive)
|
||||
*/
|
||||
bool EqualStrings(const char * str1, const char * str2)
|
||||
{
|
||||
for( ; ToLower(*str1) == ToLower(*str2) ; ++str1, ++str2 )
|
||||
if( *str1 == 0 )
|
||||
return true; // *str2 will be 0 too
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
this function is called when CTRL+C has been pressed
|
||||
|
||||
we're testing what type of control has a focus
|
||||
if it is not an edit control we will copy the result from the output edit
|
||||
and if is is an edit control we're checking whether the edit has a selecion or not,
|
||||
if it has not a selection we will copy the result otherwise we return 'false'
|
||||
and the CTRL+C will be passed into the standard procedure
|
||||
*/
|
||||
bool CopyResult()
|
||||
{
|
||||
char buffer[30];
|
||||
DWORD sel_start, sel_end;
|
||||
HWND focus = GetFocus();
|
||||
bool copy = true;
|
||||
|
||||
GetClassName( focus, buffer, sizeof(buffer)/sizeof(char) );
|
||||
|
||||
if( EqualStrings(buffer, "edit") )
|
||||
{
|
||||
SendMessage(focus, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
|
||||
|
||||
if( sel_start != sel_end )
|
||||
// the control has a selection
|
||||
copy = false;
|
||||
}
|
||||
|
||||
|
||||
if( copy )
|
||||
{
|
||||
// the control has no selection
|
||||
HWND main_window = GetPrgRes()->GetMainWindow();
|
||||
HWND output_edit = GetDlgItem(main_window, IDC_OUTPUT_EDIT);
|
||||
DWORD out_sel_start, out_sel_end;
|
||||
|
||||
// we're getting the selection on the output edit
|
||||
// there may be no selection
|
||||
SendMessage(output_edit, EM_GETSEL, (WPARAM)&out_sel_start, (LPARAM)&out_sel_end);
|
||||
// setting the selection for the whole control
|
||||
SendMessage(output_edit, EM_SETSEL, 0, -1);
|
||||
// copying the result
|
||||
SendMessage(output_edit, WM_COPY, 0, 0);
|
||||
// and restoring the selection to the previous state
|
||||
SendMessage(output_edit, EM_SETSEL, out_sel_start, out_sel_end);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
this function is called when CTRL+V has been pressed
|
||||
|
||||
if a focus is not on an edit control (or it can be on an edit
|
||||
but the edit must be read only) we're sending WM_PASTE into the
|
||||
input edit and setting a focus on it
|
||||
*/
|
||||
bool Paste()
|
||||
{
|
||||
char buffer[30];
|
||||
HWND focus = GetFocus();
|
||||
|
||||
GetClassName( focus, buffer, sizeof(buffer)/sizeof(char) );
|
||||
|
||||
if( EqualStrings(buffer, "edit") )
|
||||
{
|
||||
if( (GetWindowLong(focus, GWL_STYLE) & ES_READONLY) == 0 )
|
||||
return false;
|
||||
|
||||
// it's an edit but it has ES_READONLY style set
|
||||
}
|
||||
|
||||
HWND main_window = GetPrgRes()->GetMainWindow();
|
||||
HWND input_edit = GetDlgItem(main_window, IDC_INPUT_EDIT);
|
||||
|
||||
SendMessage(input_edit, WM_PASTE, 0, 0);
|
||||
SetFocus(input_edit);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SetActiveTab(unsigned int i)
|
||||
{
|
||||
static int last_shown_dialog = -1;
|
||||
@@ -296,6 +404,11 @@ HMENU menu = GetMenu(hWnd);
|
||||
SetMenuLanguageItem(menu, IDM_ALWAYS_ON_TOP, Languages::menu_view_always_on_top);
|
||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_ENGLISH, Languages::menu_view_lang_english);
|
||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_POLISH, Languages::menu_view_lang_polish);
|
||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_SPANISH, Languages::menu_view_lang_spanish);
|
||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_DANISH, Languages::menu_view_lang_danish);
|
||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_CHINESE, Languages::menu_view_lang_chinese);
|
||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_RUSSIAN, Languages::menu_view_lang_russian);
|
||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_SWEDISH, Languages::menu_view_lang_swedish);
|
||||
SetMenuLanguageItem(menu, IDM_CLOSE_PROGRAM, Languages::menu_view_close_program);
|
||||
SetMenuLanguageItem(menu, IDM_EDIT_UNDO, Languages::menu_edit_undo);
|
||||
SetMenuLanguageItem(menu, IDM_EDIT_PASTE, Languages::menu_edit_paste);
|
||||
@@ -310,21 +423,23 @@ HMENU menu = GetMenu(hWnd);
|
||||
|
||||
void WmInitDialogCalculateMainWindowSize(HWND hTab)
|
||||
{
|
||||
RECT r;
|
||||
RECT r_tab, r_main, r_edit2;
|
||||
|
||||
GetWindowRect(hTab, &r);
|
||||
GetWindowRect(hTab, &r_tab);
|
||||
|
||||
int cy_caption = GetSystemMetrics(SM_CYCAPTION);
|
||||
HWND main = GetPrgRes()->GetMainWindow();
|
||||
GetWindowRect(main, &r_main);
|
||||
|
||||
int cy_add = 2 * GetSystemMetrics(SM_CYDLGFRAME) +
|
||||
GetSystemMetrics(SM_CYMENU);
|
||||
HWND output_edit = GetDlgItem(main, IDC_OUTPUT_EDIT);
|
||||
GetWindowRect(output_edit, &r_edit2);
|
||||
|
||||
int cx_add = 2 * GetSystemMetrics(SM_CXDLGFRAME) +
|
||||
r.right - r.left;
|
||||
int cy_compact = (r_edit2.bottom - r_main.top) + GetSystemMetrics(SM_CYSIZEFRAME);
|
||||
int cy_normal = (r_tab.bottom - r_tab.top) + (r_tab.top - r_main.top) + GetSystemMetrics(SM_CYSIZEFRAME) + 8;
|
||||
int cx = r_tab.right - r_tab.left + 2 * GetSystemMetrics(SM_CXSIZEFRAME);
|
||||
|
||||
GetPrgRes()->SetYSizeNormal ( 225 + cy_add + cy_caption * 2);
|
||||
GetPrgRes()->SetYSizeCompact( 59 + cy_add + cy_caption );
|
||||
GetPrgRes()->SetXSizeMin ( 4 + cx_add );
|
||||
GetPrgRes()->SetYSizeNormal ( cy_normal );
|
||||
GetPrgRes()->SetYSizeCompact( cy_compact );
|
||||
GetPrgRes()->SetXSizeMin ( cx );
|
||||
}
|
||||
|
||||
|
||||
@@ -347,14 +462,18 @@ DLGTEMPLATE * tab1template = (DLGTEMPLATE*)LockResource(tab1global);
|
||||
|
||||
int frame_cx = GetSystemMetrics(SM_CXEDGE);
|
||||
int frame_cy = GetSystemMetrics(SM_CYEDGE);
|
||||
int caption_cy = GetSystemMetrics(SM_CYCAPTION)+10; // the caption plus some white space
|
||||
int space = 10; // some more space between the tab items and child tabs
|
||||
|
||||
RECT tab_item_r;
|
||||
TabCtrl_GetItemRect(hTab, 0, &tab_item_r);
|
||||
int tab_item = tab_item_r.bottom;
|
||||
|
||||
RECT r;
|
||||
GetWindowRect(hTab, &r);
|
||||
|
||||
SetWindowPos(hDialog, HWND_TOP, frame_cx, frame_cy + caption_cy,
|
||||
SetWindowPos(hDialog, HWND_TOP, frame_cx, frame_cy + tab_item + space,
|
||||
r.right-r.left- 2*frame_cx,
|
||||
r.bottom-r.top- 2*frame_cy - caption_cy, 0);
|
||||
r.bottom-r.top- 2*frame_cy - tab_item - space, 0);
|
||||
|
||||
return hDialog;
|
||||
}
|
||||
@@ -383,18 +502,25 @@ TCITEM tab_item;
|
||||
// the name of a tab we'll set when we call the 'SetLanguage()' function
|
||||
tab_item.mask = 0;
|
||||
|
||||
tab_standard = 0;
|
||||
tab_variables = 1;
|
||||
tab_functions = 2;
|
||||
int tab_inc = 0;
|
||||
|
||||
tab_standard = tab_inc++;
|
||||
tab_variables = tab_inc++;
|
||||
tab_functions = tab_inc++;
|
||||
|
||||
#ifndef TTCALC_PORTABLE
|
||||
tab_precision = 3;
|
||||
tab_display = 4;
|
||||
tab_precision = tab_inc++;
|
||||
#else
|
||||
tab_precision = -1; // this one will not be used
|
||||
tab_display = 3;
|
||||
#endif
|
||||
|
||||
tab_display = tab_inc++;
|
||||
|
||||
#ifdef TTCALC_CONVERT
|
||||
tab_convert = tab_inc++;
|
||||
#else
|
||||
tab_convert = -1;
|
||||
#endif
|
||||
|
||||
// this insertion must be in the ascending order
|
||||
// (the second parameter of 'TabCtrl_InsertItem')
|
||||
@@ -408,6 +534,10 @@ TCITEM tab_item;
|
||||
|
||||
TabCtrl_InsertItem(hTab, tab_display, &tab_item);
|
||||
|
||||
#ifdef TTCALC_CONVERT
|
||||
TabCtrl_InsertItem(hTab, tab_convert, &tab_item);
|
||||
#endif
|
||||
|
||||
WmInitDialogCreateTab(hTab, tab_standard, IDD_DIALOG_STANDARD, TabWindowProc);
|
||||
WmInitDialogCreateTab(hTab, tab_variables, IDD_DIALOG_VARIABLES, TabWindowProc);
|
||||
WmInitDialogCreateTab(hTab, tab_functions, IDD_DIALOG_FUNCTIONS, TabWindowProc);
|
||||
@@ -418,6 +548,10 @@ TCITEM tab_item;
|
||||
|
||||
WmInitDialogCreateTab(hTab, tab_display, IDD_DIALOG_DISPLAY, TabWindowProc);
|
||||
|
||||
#ifdef TTCALC_CONVERT
|
||||
WmInitDialogCreateTab(hTab, tab_convert, IDD_DIALOG_CONVERT, TabWindowProc);
|
||||
#endif
|
||||
|
||||
SetSizeOfDialogs();
|
||||
|
||||
SendMessage(GetPrgRes()->GetTabWindow(tab_variables), WM_INIT_TAB_VARIABLES, 0,0);
|
||||
@@ -429,6 +563,10 @@ TCITEM tab_item;
|
||||
|
||||
SendMessage(GetPrgRes()->GetTabWindow(tab_display), WM_INIT_TAB_DISPLAY, 0,0);
|
||||
|
||||
#ifdef TTCALC_CONVERT
|
||||
SendMessage(GetPrgRes()->GetTabWindow(tab_convert), WM_INIT_TAB_CONVERT, 0,0);
|
||||
#endif
|
||||
|
||||
TabWindowFunctions::SetLanguage(hTab);
|
||||
|
||||
TabCtrl_SetCurSel(hTab, tab_standard);
|
||||
@@ -446,7 +584,7 @@ HWND hTab = GetDlgItem(hWnd,IDC_TAB);
|
||||
WmInitDialogCalculateMainWindowSize(hTab);
|
||||
WmInitDialogCreateAndInitTabs(hTab);
|
||||
|
||||
HICON program_icon = LoadIcon(GetPrgRes()->GetInstance(),MAKEINTRESOURCE(IDI_ICON1));
|
||||
HICON program_icon = LoadIcon(GetPrgRes()->GetInstance(),MAKEINTRESOURCE(IDI_ICON2));
|
||||
if( program_icon )
|
||||
SendMessage(hWnd,WM_SETICON,ICON_BIG,(LPARAM)program_icon);
|
||||
|
||||
@@ -503,7 +641,6 @@ MINMAXINFO * lpmmi = (LPMINMAXINFO) lParam;
|
||||
if( GetPrgRes()->GetView() == ProgramResources::view_normal )
|
||||
{
|
||||
lpmmi->ptMinTrackSize.y = GetPrgRes()->GetYSizeNormal();
|
||||
//lpmmi->ptMaxTrackSize.y = cy_normalny;
|
||||
}
|
||||
else
|
||||
{// kompaktowy
|
||||
@@ -570,31 +707,34 @@ POINT p;
|
||||
if( fwSizeType == SIZE_RESTORED )
|
||||
GetPrgRes()->SetMaximized(false);
|
||||
|
||||
// client area
|
||||
int cx = LOWORD(lParam);
|
||||
int cy = HIWORD(lParam);
|
||||
int resize_flags = SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER;
|
||||
|
||||
GetWindowRect(GetDlgItem(hWnd,IDC_INPUT_EDIT),&r);
|
||||
HWND input_edit = GetDlgItem(hWnd, IDC_INPUT_EDIT);
|
||||
GetWindowRect(input_edit, &r);
|
||||
SetWindowPos(input_edit, 0, 0, 0, cx, r.bottom-r.top, resize_flags);
|
||||
|
||||
HWND output_edit = GetDlgItem(hWnd, IDC_OUTPUT_EDIT);
|
||||
GetWindowRect(output_edit, &r);
|
||||
SetWindowPos(output_edit, 0, 0, 0, cx, r.bottom-r.top, resize_flags);
|
||||
|
||||
HWND tab = GetDlgItem(hWnd, IDC_TAB);
|
||||
GetWindowRect(tab, &r);
|
||||
p.x = r.left;
|
||||
p.y = r.top;
|
||||
ScreenToClient(hWnd,&p);
|
||||
MoveWindow(GetDlgItem(hWnd,IDC_INPUT_EDIT),p.x, p.y, cx, r.bottom-r.top, true);
|
||||
SetWindowPos(tab, 0, 0, 0, cx, cy-p.y, resize_flags);
|
||||
|
||||
GetWindowRect(GetDlgItem(hWnd,IDC_OUTPUT_EDIT),&r);
|
||||
p.x = r.left;
|
||||
p.y = r.top;
|
||||
ScreenToClient(hWnd,&p);
|
||||
MoveWindow(GetDlgItem(hWnd,IDC_OUTPUT_EDIT),p.x, p.y, cx, r.bottom-r.top, true);
|
||||
int borderx = GetSystemMetrics(SM_CXDLGFRAME) * 2;
|
||||
int bordery = GetSystemMetrics(SM_CYDLGFRAME) * 2;
|
||||
|
||||
GetWindowRect(GetDlgItem(hWnd,IDC_TAB),&r);
|
||||
p.x = r.left;
|
||||
p.y = r.top;
|
||||
ScreenToClient(hWnd,&p);
|
||||
MoveWindow(GetDlgItem(hWnd,IDC_TAB),p.x, p.y, cx, cy-p.y, true);
|
||||
TabWindowFunctions::SetSizeOfVariablesList(tab, cx, cy-p.y, borderx, bordery);
|
||||
TabWindowFunctions::SetSizeOfFunctionsList(tab, cx, cy-p.y, borderx, bordery);
|
||||
TabWindowFunctions::SetSizeOfConvertingLists(tab, cx, cy-p.y, borderx, bordery);
|
||||
|
||||
TabWindowFunctions::SetSizeOfVariablesList();
|
||||
TabWindowFunctions::SetSizeOfFunctionsList();
|
||||
|
||||
if( fwSizeType != SIZE_MINIMIZED )
|
||||
if( fwSizeType != SIZE_MINIMIZED && GetPrgRes()->GetView() != ProgramResources::view_compact )
|
||||
{
|
||||
GetWindowRect(hWnd,&r);
|
||||
GetPrgRes()->SetXSize( r.right - r.left );
|
||||
@@ -623,16 +763,40 @@ void WmInitMenuPopUpView(HMENU menu)
|
||||
CheckMenuItem(menu,IDM_NORMAL_VIEW,MF_BYCOMMAND|MF_UNCHECKED);
|
||||
}
|
||||
|
||||
if( GetPrgRes()->GetLanguages()->GetCurrentLanguage() == Languages::en )
|
||||
{
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_ENGLISH, MF_BYCOMMAND|MF_CHECKED);
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_POLISH, MF_BYCOMMAND|MF_UNCHECKED);
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_POLISH, MF_BYCOMMAND|MF_CHECKED);
|
||||
|
||||
|
||||
// languages
|
||||
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_ENGLISH, MF_BYCOMMAND|MF_UNCHECKED);
|
||||
}
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_POLISH, MF_BYCOMMAND|MF_UNCHECKED);
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_SPANISH, MF_BYCOMMAND|MF_UNCHECKED);
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_DANISH, MF_BYCOMMAND|MF_UNCHECKED);
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_CHINESE, MF_BYCOMMAND|MF_UNCHECKED);
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_RUSSIAN, MF_BYCOMMAND|MF_UNCHECKED);
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_SWEDISH, MF_BYCOMMAND|MF_UNCHECKED);
|
||||
|
||||
Languages::Country lang = GetPrgRes()->GetLanguages()->GetCurrentLanguage();
|
||||
|
||||
if( lang == Languages::en )
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_ENGLISH, MF_BYCOMMAND|MF_CHECKED);
|
||||
else
|
||||
if( lang == Languages::pl )
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_POLISH, MF_BYCOMMAND|MF_CHECKED);
|
||||
else
|
||||
if( lang == Languages::sp )
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_SPANISH, MF_BYCOMMAND|MF_CHECKED);
|
||||
else
|
||||
if( lang == Languages::da )
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_DANISH, MF_BYCOMMAND|MF_CHECKED);
|
||||
else
|
||||
if( lang == Languages::chn )
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_CHINESE, MF_BYCOMMAND|MF_CHECKED);
|
||||
else
|
||||
if( lang == Languages::ru )
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_RUSSIAN, MF_BYCOMMAND|MF_CHECKED);
|
||||
else
|
||||
if( lang == Languages::swe )
|
||||
CheckMenuItem(menu, IDM_LANGUAGE_SWEDISH, MF_BYCOMMAND|MF_CHECKED);
|
||||
}
|
||||
|
||||
|
||||
@@ -740,12 +904,6 @@ BOOL WmCommand_NewWindow(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
GetPrgRes()->SetXPos( GetPrgRes()->GetXPos()+10 );
|
||||
GetPrgRes()->SetYPos( GetPrgRes()->GetYPos()+10 );
|
||||
GetPrgRes()->SaveToFile();
|
||||
GetPrgRes()->SetXPos( GetPrgRes()->GetXPos()-10 );
|
||||
GetPrgRes()->SetYPos( GetPrgRes()->GetYPos()-10 );
|
||||
|
||||
char * buffer = new char[MAX_PATH+1];
|
||||
|
||||
GetModuleFileName(GetPrgRes()->GetInstance(),buffer, MAX_PATH);
|
||||
@@ -890,6 +1048,62 @@ return true;
|
||||
}
|
||||
|
||||
|
||||
BOOL WmCommand_LanguageSpanish(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::sp);
|
||||
|
||||
SetMenuLanguage(hWnd);
|
||||
SetOutputEditLanguage(hWnd);
|
||||
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL WmCommand_LanguageDanish(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::da);
|
||||
|
||||
SetMenuLanguage(hWnd);
|
||||
SetOutputEditLanguage(hWnd);
|
||||
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL WmCommand_LanguageChinese(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::chn);
|
||||
|
||||
SetMenuLanguage(hWnd);
|
||||
SetOutputEditLanguage(hWnd);
|
||||
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL WmCommand_LanguageRussian(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::ru);
|
||||
|
||||
SetMenuLanguage(hWnd);
|
||||
SetOutputEditLanguage(hWnd);
|
||||
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL WmCommand_LanguageSwedish(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::swe);
|
||||
|
||||
SetMenuLanguage(hWnd);
|
||||
SetOutputEditLanguage(hWnd);
|
||||
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BOOL WmHelp(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
SHELLEXECUTEINFO exec;
|
||||
@@ -923,7 +1137,8 @@ SHELLEXECUTEINFO 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.lpFile = "http://sourceforge.net/projects/ttcalc";
|
||||
exec.lpFile = "http://ttcalc.sourceforge.net";
|
||||
exec.lpParameters = 0;
|
||||
exec.lpDirectory = "";
|
||||
exec.nShow = SW_SHOWNORMAL;
|
||||
@@ -955,6 +1170,11 @@ 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_LANGUAGE_SPANISH, WmCommand_LanguageSpanish);
|
||||
cmessages.Associate(IDM_LANGUAGE_DANISH, WmCommand_LanguageDanish);
|
||||
cmessages.Associate(IDM_LANGUAGE_CHINESE, WmCommand_LanguageChinese);
|
||||
cmessages.Associate(IDM_LANGUAGE_RUSSIAN, WmCommand_LanguageRussian);
|
||||
cmessages.Associate(IDM_LANGUAGE_SWEDISH, WmCommand_LanguageSwedish);
|
||||
cmessages.Associate(IDM_HELP_HELP, WmHelp);
|
||||
cmessages.Associate(IDM_HELP_PROJECT_PAGE, WmProjectPage);
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include "compileconfig.h"
|
||||
#include "parsermanager.h"
|
||||
#include "tabs.h"
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +48,10 @@ ParserManager::ParserManager() : buffer_len(2048)
|
||||
base_input = base_output = 10;
|
||||
always_scientific = 0;
|
||||
when_scientific = 15;
|
||||
rounding = -2;
|
||||
rounding = -1;
|
||||
remove_zeroes = true;
|
||||
last_variables_id = 0;
|
||||
last_functions_id = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,10 +63,13 @@ ParserManager::ParserManager(const ParserManager & p) : buffer_len(p.buffer_len)
|
||||
always_scientific = p.always_scientific;
|
||||
when_scientific = p.when_scientific;
|
||||
rounding = p.rounding;
|
||||
remove_zeroes = p.remove_zeroes;
|
||||
last_variables_id = p.last_variables_id;
|
||||
last_functions_id = p.last_functions_id;
|
||||
}
|
||||
|
||||
|
||||
ParserManager & ParserManager::operator=(const ParserManager & p)
|
||||
ParserManager & ParserManager::operator=(const ParserManager &)
|
||||
{
|
||||
buffer = 0;
|
||||
|
||||
@@ -92,16 +99,19 @@ ttmath::ErrorCode ParserManager::Parse()
|
||||
{
|
||||
case 0:
|
||||
parser1.SetBase(base_input);
|
||||
parser1.SetDegRadGrad(angle_deg_rad_grad);
|
||||
code = parser1.Parse(buffer);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
parser2.SetBase(base_input);
|
||||
parser2.SetDegRadGrad(angle_deg_rad_grad);
|
||||
code = parser2.Parse(buffer);
|
||||
break;
|
||||
|
||||
default:
|
||||
parser3.SetBase(base_input);
|
||||
parser3.SetDegRadGrad(angle_deg_rad_grad);
|
||||
code = parser3.Parse(buffer);
|
||||
break;
|
||||
}
|
||||
@@ -109,6 +119,7 @@ ttmath::ErrorCode ParserManager::Parse()
|
||||
#else
|
||||
|
||||
parser1.SetBase(base_input);
|
||||
parser1.SetDegRadGrad(angle_deg_rad_grad);
|
||||
code = parser1.Parse(buffer);
|
||||
|
||||
#endif
|
||||
@@ -135,8 +146,17 @@ unsigned int i;
|
||||
|
||||
//
|
||||
|
||||
if( GetPrgRes()->GetVariablesId() != last_variables_id )
|
||||
{
|
||||
variables = *GetPrgRes()->GetVariables();
|
||||
last_variables_id = GetPrgRes()->GetVariablesId();
|
||||
}
|
||||
|
||||
if( GetPrgRes()->GetFunctionsId() != last_functions_id )
|
||||
{
|
||||
functions = *GetPrgRes()->GetFunctions();
|
||||
last_functions_id = GetPrgRes()->GetFunctionsId();
|
||||
}
|
||||
|
||||
//
|
||||
base_input = GetPrgRes()->GetBaseInput();
|
||||
@@ -146,8 +166,17 @@ unsigned int i;
|
||||
when_scientific = GetPrgRes()->GetDisplayWhenScientific();
|
||||
rounding = GetPrgRes()->GetDisplayRounding();
|
||||
precision = GetPrgRes()->GetPrecision();
|
||||
|
||||
remove_zeroes = GetPrgRes()->GetRemovingZeroes();
|
||||
angle_deg_rad_grad = GetPrgRes()->GetDegRadGrad();
|
||||
country = GetPrgRes()->GetLanguages()->GetCurrentLanguage();
|
||||
|
||||
conv_type = GetPrgRes()->GetConvert()->GetCurrentType();
|
||||
GetPrgRes()->GetConvert()->GetCurrentUnit(conv_type, conv_input_unit, conv_output_unit);
|
||||
|
||||
if( GetPrgRes()->GetDecimalPoint() == 0 )
|
||||
decimal_point = '.';
|
||||
else
|
||||
decimal_point = ',';
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +203,7 @@ void ParserManager::Init()
|
||||
}
|
||||
|
||||
|
||||
void ParserManager::PrintResult()
|
||||
int ParserManager::PrintResult()
|
||||
{
|
||||
if( code == ttmath::err_ok )
|
||||
{
|
||||
@@ -193,33 +222,67 @@ void ParserManager::PrintResult()
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
return PrintResult(parser1);
|
||||
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void ParserManager::ShowConvertingInfo()
|
||||
{
|
||||
// we can call GetPrgRes() here because we're reading
|
||||
// static value like GetMainWindow() which are set only once
|
||||
// at the beginning of the program and will never be changed later
|
||||
// by the first thread
|
||||
HWND conv_tab = GetPrgRes()->GetTabWindow(TabWindowFunctions::tab_convert);
|
||||
|
||||
// note that we're using a long form of a method ErrorMessage i.g.
|
||||
// ErrorMessage(Country country, ttmath::ErrorCode code)
|
||||
// and not ErrorMessage(ttmath::ErrorCode code)
|
||||
// because someone can change the country when we're calling this method
|
||||
// (in the main thread) and the latter function would be using its own
|
||||
// 'current_country' value which could be inconsistent
|
||||
|
||||
// now, displying an error message is making in the main windows
|
||||
// (after pressing a special key)
|
||||
|
||||
/*
|
||||
SetDlgItemText(
|
||||
GetPrgRes()->GetMainWindow(),
|
||||
IDC_OUTPUT_EDIT,
|
||||
GetPrgRes()->GetLanguages()->ErrorMessage(country, code) );
|
||||
*/
|
||||
if( conv_type==0 || conv_input_unit==-1 || conv_output_unit==-1 ||
|
||||
conv_input_unit == conv_output_unit )
|
||||
{
|
||||
SetDlgItemText(conv_tab, IDC_EDIT_OUTPUT_INFO, "");
|
||||
return;
|
||||
}
|
||||
|
||||
Convert * pconv = GetPrgRes()->GetConvert();
|
||||
|
||||
// the first unit to the second
|
||||
|
||||
ttmath::Big<1,1> result;
|
||||
result.SetOne();
|
||||
std::string buffer1 = "1 ";
|
||||
buffer1 += pconv->GetUnitAbbr(country, conv_input_unit);
|
||||
buffer1 += " = ";
|
||||
|
||||
if( pconv->Conversion(conv_input_unit, conv_output_unit, result) )
|
||||
{
|
||||
SetDlgItemText(conv_tab, IDC_EDIT_OUTPUT_INFO, "overflow" );
|
||||
return;
|
||||
}
|
||||
|
||||
result.ToString(buffer2, 10, false, 3, -1, true);
|
||||
|
||||
buffer1 += buffer2;
|
||||
buffer1 += " ";
|
||||
buffer1 += pconv->GetUnitAbbr(country, conv_output_unit);
|
||||
|
||||
|
||||
// the second unit to the first
|
||||
|
||||
buffer1 += " 1 ";
|
||||
buffer1 += pconv->GetUnitAbbr(country, conv_output_unit);
|
||||
buffer1 += " = ";
|
||||
|
||||
result.SetOne();
|
||||
if( pconv->Conversion(conv_output_unit, conv_input_unit, result) )
|
||||
{
|
||||
SetDlgItemText(conv_tab, IDC_EDIT_OUTPUT_INFO, "overflow" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
result.ToString(buffer2, 10, false, 3, -1, true);
|
||||
|
||||
buffer1 += buffer2;
|
||||
buffer1 += " ";
|
||||
buffer1 += pconv->GetUnitAbbr(country, conv_input_unit);
|
||||
|
||||
SetDlgItemText(conv_tab, IDC_EDIT_OUTPUT_INFO, buffer1.c_str() );
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -44,9 +44,7 @@
|
||||
*/
|
||||
|
||||
#include "resource.h"
|
||||
#include <ttmath/ttmathparser.h>
|
||||
#include "programresources.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
@@ -100,64 +98,122 @@ public:
|
||||
this method prints result
|
||||
(a correct value if was or an error instead)
|
||||
*/
|
||||
void PrintResult();
|
||||
int PrintResult();
|
||||
|
||||
|
||||
/*!
|
||||
this method prints the info about converting (on the converting tab)
|
||||
*/
|
||||
void ShowConvertingInfo();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
#ifndef TTCALC_PORTABLE
|
||||
ttmath::Parser<ttmath::Big<1,3> > parser1;
|
||||
ttmath::Parser<ttmath::Big<2,6> > parser2;
|
||||
ttmath::Parser<ttmath::Big<3,9> > parser3;
|
||||
ttmath::Parser<TTMathBig1> parser1;
|
||||
ttmath::Parser<TTMathBig2> parser2;
|
||||
ttmath::Parser<TTMathBig3> parser3;
|
||||
#else
|
||||
ttmath::Parser<ttmath::Big<1,3> > parser1;
|
||||
ttmath::Parser<TTMathBig1> parser1;
|
||||
#endif
|
||||
|
||||
ttmath::Objects variables, functions;
|
||||
int last_variables_id;
|
||||
int last_functions_id;
|
||||
|
||||
const unsigned int buffer_len;
|
||||
char * buffer;
|
||||
|
||||
int base_input, base_output;
|
||||
int conv_type, conv_input_unit, conv_output_unit;
|
||||
|
||||
bool always_scientific;
|
||||
int when_scientific;
|
||||
int rounding;
|
||||
bool remove_zeroes;
|
||||
int precision;
|
||||
Languages::Country country;
|
||||
ttmath::ErrorCode code;
|
||||
char decimal_point;
|
||||
int angle_deg_rad_grad;
|
||||
|
||||
/*
|
||||
some buffers which we use in some method in the second thread,
|
||||
it's better to have those buffers outside those methods -
|
||||
if the buffers were in the methods there would be still allocating
|
||||
and deallocating memory
|
||||
*/
|
||||
std::string buffer1, buffer2;
|
||||
|
||||
|
||||
template<class ValueType>
|
||||
void PrintResult(ttmath::Parser<ValueType> & matparser)
|
||||
bool CanWeConvert() const
|
||||
{
|
||||
if( conv_type != 0 )
|
||||
if( conv_input_unit!=-1 && conv_output_unit!=-1 &&
|
||||
conv_input_unit!=conv_output_unit )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AddOutputSuffix(std::string & result)
|
||||
{
|
||||
if( CanWeConvert() )
|
||||
{
|
||||
result += " ";
|
||||
result += GetPrgRes()->GetConvert()->GetUnitAbbr(country, conv_output_unit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 1 if carry
|
||||
template<class ValueType>
|
||||
int PrintResult(ttmath::Parser<ValueType> & matparser)
|
||||
{
|
||||
std::string result, part;
|
||||
unsigned int i = 0;
|
||||
|
||||
buffer1.erase();
|
||||
buffer2.erase();
|
||||
|
||||
for(i=0 ; i<matparser.stack.size() ; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
if( matparser.stack[i].value.ToString(part,base_output, always_scientific, when_scientific, rounding) )
|
||||
ValueType result = matparser.stack[i].value;
|
||||
|
||||
if( CanWeConvert() )
|
||||
{
|
||||
if( GetPrgRes()->GetConvert()->Conversion(conv_input_unit, conv_output_unit, result) )
|
||||
{
|
||||
code = ttmath::err_overflow;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( result.ToString(buffer2,base_output, always_scientific, when_scientific, rounding, remove_zeroes, decimal_point) )
|
||||
{
|
||||
// we shouldn't have had this error in the new version of ToStrign(...)
|
||||
// (where we're using a bigger type for calculating)
|
||||
part = GetPrgRes()->GetLanguages()->GuiMessage(country, Languages::overflow_during_printing);
|
||||
buffer2 = GetPrgRes()->GetLanguages()->GuiMessage(country, Languages::overflow_during_printing);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
part = GetPrgRes()->GetLanguages()->ErrorMessage(country, ttmath::err_internal_error);
|
||||
buffer2 = GetPrgRes()->GetLanguages()->ErrorMessage(country, ttmath::err_internal_error);
|
||||
}
|
||||
|
||||
result += part;
|
||||
buffer1 += buffer2;
|
||||
AddOutputSuffix(buffer1);
|
||||
|
||||
if( i < matparser.stack.size()-1 )
|
||||
result += " ";
|
||||
buffer1 += " ";
|
||||
}
|
||||
|
||||
SetDlgItemText(GetPrgRes()->GetMainWindow(),IDC_OUTPUT_EDIT,result.c_str());
|
||||
SetDlgItemText(GetPrgRes()->GetMainWindow(),IDC_OUTPUT_EDIT,buffer1.c_str());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -182,8 +182,8 @@ bool ProgramResources::GetAlwaysOnTop()
|
||||
|
||||
void ProgramResources::SetDisplayRounding(int r)
|
||||
{
|
||||
if(r<-2)
|
||||
r = -2;
|
||||
if( r < -1 )
|
||||
r = -1;
|
||||
|
||||
if( r > 99 )
|
||||
r = 99;
|
||||
@@ -191,11 +191,42 @@ void ProgramResources::SetDisplayRounding(int r)
|
||||
display_rounding = r;
|
||||
}
|
||||
|
||||
|
||||
int ProgramResources::GetDisplayRounding()
|
||||
{
|
||||
return display_rounding;
|
||||
}
|
||||
|
||||
|
||||
void ProgramResources::SetRemovingZeroes(bool r)
|
||||
{
|
||||
remove_zeroes = r;
|
||||
}
|
||||
|
||||
bool ProgramResources::GetRemovingZeroes()
|
||||
{
|
||||
return remove_zeroes;
|
||||
}
|
||||
|
||||
|
||||
void ProgramResources::SetDegRadGrad(int angle)
|
||||
{
|
||||
if( angle < 0 || angle > 2 )
|
||||
angle = 1;
|
||||
|
||||
angle_deg_rad_grad = angle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ProgramResources::GetDegRadGrad()
|
||||
{
|
||||
return angle_deg_rad_grad;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ProgramResources::SetDisplayAlwaysScientific(bool a)
|
||||
{
|
||||
display_always_scientific = a;
|
||||
@@ -260,6 +291,21 @@ int ProgramResources::GetBaseOutput()
|
||||
}
|
||||
|
||||
|
||||
void ProgramResources::SetDecimalPoint(int decimal)
|
||||
{
|
||||
decimal_point = decimal;
|
||||
|
||||
if( decimal_point<0 || decimal_point>1 )
|
||||
decimal_point = 0;
|
||||
}
|
||||
|
||||
|
||||
int ProgramResources::GetDecimalPoint()
|
||||
{
|
||||
return decimal_point;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
@@ -273,11 +319,43 @@ ttmath::Objects * ProgramResources::GetFunctions()
|
||||
return &functions;
|
||||
}
|
||||
|
||||
|
||||
void ProgramResources::VariablesChanged()
|
||||
{
|
||||
++variables_id;
|
||||
}
|
||||
|
||||
|
||||
void ProgramResources::FunctionsChanged()
|
||||
{
|
||||
++functions_id;
|
||||
}
|
||||
|
||||
|
||||
int ProgramResources::GetVariablesId()
|
||||
{
|
||||
return variables_id;
|
||||
}
|
||||
|
||||
|
||||
int ProgramResources::GetFunctionsId()
|
||||
{
|
||||
return functions_id;
|
||||
}
|
||||
|
||||
|
||||
Languages * ProgramResources::GetLanguages()
|
||||
{
|
||||
return &languages;
|
||||
}
|
||||
|
||||
|
||||
Convert * ProgramResources::GetConvert()
|
||||
{
|
||||
return &convert;
|
||||
}
|
||||
|
||||
|
||||
void ProgramResources::SetInstance(HINSTANCE h)
|
||||
{
|
||||
hInstance = h;
|
||||
@@ -376,8 +454,9 @@ ProgramResources::ProgramResources()
|
||||
base_output = 10;
|
||||
|
||||
display_always_scientific = false;
|
||||
display_when_scientific = 15;
|
||||
display_rounding = -2;
|
||||
display_when_scientific = 8;
|
||||
display_rounding = -1;
|
||||
remove_zeroes = true;
|
||||
|
||||
for(int i=HowManyTabWindows()-1 ; i!=-1 ; --i)
|
||||
tab_window[i] = 0;
|
||||
@@ -390,6 +469,18 @@ ProgramResources::ProgramResources()
|
||||
y_size_normal = 0;
|
||||
y_size_compact = 0;
|
||||
x_size_min = 0;
|
||||
|
||||
// !!! put into Convert constructor
|
||||
#ifdef TTCALC_CONVERT
|
||||
convert.Init();
|
||||
#endif
|
||||
|
||||
|
||||
decimal_point = 0;
|
||||
angle_deg_rad_grad = 1; // rad is default
|
||||
|
||||
variables_id = 0;
|
||||
functions_id = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -574,6 +665,82 @@ void ProgramResources::CheckCoordinates()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ProgramResources::AddVariablesFunctions( IniParser::Section & temp_variables,
|
||||
IniParser::Section & temp_functions,
|
||||
bool if_not_exist)
|
||||
{
|
||||
IniParser::Section::iterator ic;
|
||||
|
||||
// we're adding variables
|
||||
|
||||
if( !if_not_exist )
|
||||
{
|
||||
variables.Clear();
|
||||
VariablesChanged();
|
||||
}
|
||||
|
||||
for( ic = temp_variables.begin() ; ic!=temp_variables.end() ; ++ic )
|
||||
if( !if_not_exist || !variables.IsDefined(ic->first) )
|
||||
{
|
||||
variables.Add(ic->first, ic->second);
|
||||
VariablesChanged();
|
||||
}
|
||||
|
||||
|
||||
// we're adding functions
|
||||
|
||||
if( !if_not_exist )
|
||||
{
|
||||
functions.Clear();
|
||||
FunctionsChanged();
|
||||
}
|
||||
|
||||
for( ic = temp_functions.begin() ; ic!=temp_functions.end() ; ++ic )
|
||||
{
|
||||
const char * name;
|
||||
int param;
|
||||
|
||||
if( !if_not_exist || !functions.IsDefined(ic->first) )
|
||||
if( SplitFunction(ic->second, &name, ¶m) )
|
||||
{
|
||||
functions.Add(ic->first, name, param);
|
||||
FunctionsChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IniParser::Error ProgramResources::ReadVariablesFunctionsFromFile()
|
||||
{
|
||||
IniParser iparser;
|
||||
IniParser::Section temp_variables, temp_functions;
|
||||
|
||||
iparser.ConvertValueToSmallLetters(false);
|
||||
iparser.SectionCaseSensitive(false);
|
||||
|
||||
// we have variables and functions case-sensitive
|
||||
iparser.PatternCaseSensitive(true);
|
||||
|
||||
iparser.Associate( "variables", &temp_variables );
|
||||
iparser.Associate( "functions", &temp_functions );
|
||||
|
||||
bad_line = -1;
|
||||
IniParser::Error err = iparser.ReadFromFile( configuration_file.c_str() );
|
||||
|
||||
if( err == IniParser::err_cant_open_file )
|
||||
return err;
|
||||
|
||||
AddVariablesFunctions(temp_variables, temp_functions, true);
|
||||
|
||||
if( err != IniParser::err_ok )
|
||||
bad_line = iparser.GetBadLine();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
IniParser::Error ProgramResources::ReadFromFile()
|
||||
{
|
||||
IniParser iparser;
|
||||
@@ -581,6 +748,11 @@ IniParser::Section temp_variables, temp_functions;
|
||||
IniParser::Section::iterator ic;
|
||||
std::string ini_value[20];
|
||||
|
||||
iparser.ConvertValueToSmallLetters(false);
|
||||
iparser.SectionCaseSensitive(false);
|
||||
|
||||
// we have variables and functions case-sensitive
|
||||
iparser.PatternCaseSensitive(true);
|
||||
|
||||
iparser.Associate( "global|always.on.top", &ini_value[0] );
|
||||
iparser.Associate( "global|view", &ini_value[1] );
|
||||
@@ -596,6 +768,9 @@ std::string ini_value[20];
|
||||
iparser.Associate( "global|disp.rounding", &ini_value[11] );
|
||||
iparser.Associate( "global|size.y", &ini_value[12] );
|
||||
iparser.Associate( "global|language", &ini_value[13] );
|
||||
iparser.Associate( "global|disp.dec.point", &ini_value[14] );
|
||||
iparser.Associate( "global|disp.remove.zeroes", &ini_value[15] );
|
||||
iparser.Associate( "global|disp.deg_rad_grad", &ini_value[16] );
|
||||
|
||||
iparser.Associate( "variables", &temp_variables );
|
||||
iparser.Associate( "functions", &temp_functions );
|
||||
@@ -606,21 +781,7 @@ std::string ini_value[20];
|
||||
if( err == IniParser::err_cant_open_file )
|
||||
return err;
|
||||
|
||||
// we're adding variables
|
||||
variables.Clear();
|
||||
for( ic = temp_variables.begin() ; ic!=temp_variables.end() ; ++ic )
|
||||
variables.Add(ic->first, ic->second);
|
||||
|
||||
// we're adding functions
|
||||
functions.Clear();
|
||||
for( ic = temp_functions.begin() ; ic!=temp_functions.end() ; ++ic )
|
||||
{
|
||||
const char * name;
|
||||
int param;
|
||||
|
||||
if( SplitFunction(ic->second, &name, ¶m) )
|
||||
functions.Add(ic->first, name, param);
|
||||
}
|
||||
AddVariablesFunctions(temp_variables, temp_functions, false);
|
||||
|
||||
// we're setting various values
|
||||
always_on_top = bool( atoi(ini_value[0].c_str()) );
|
||||
@@ -640,13 +801,30 @@ std::string ini_value[20];
|
||||
SetDisplayAlwaysScientific( bool(atoi(ini_value[9].c_str())) );
|
||||
SetDisplayWhenScientific( atoi(ini_value[10].c_str()) );
|
||||
SetDisplayRounding( atoi(ini_value[11].c_str()) );
|
||||
SetRemovingZeroes( bool(atoi(ini_value[15].c_str())) );
|
||||
|
||||
|
||||
if( ini_value[13] == "6" )
|
||||
languages.SetCurrentLanguage(Languages::swe);
|
||||
else
|
||||
if( ini_value[13] == "5" )
|
||||
languages.SetCurrentLanguage(Languages::ru);
|
||||
else
|
||||
if( ini_value[13] == "4" )
|
||||
languages.SetCurrentLanguage(Languages::chn);
|
||||
else
|
||||
if( ini_value[13] == "3" )
|
||||
languages.SetCurrentLanguage(Languages::da);
|
||||
else
|
||||
if( ini_value[13] == "2" )
|
||||
languages.SetCurrentLanguage(Languages::sp);
|
||||
else
|
||||
if( ini_value[13] == "1" )
|
||||
languages.SetCurrentLanguage(Languages::pl);
|
||||
else
|
||||
languages.SetCurrentLanguage(Languages::en);
|
||||
|
||||
SetDecimalPoint( atoi(ini_value[14].c_str()) );
|
||||
SetDegRadGrad( atoi(ini_value[16].c_str()) );
|
||||
|
||||
if( err != IniParser::err_ok )
|
||||
bad_line = iparser.GetBadLine();
|
||||
@@ -682,6 +860,10 @@ std::ofstream file( configuration_file.c_str() );
|
||||
file << "disp.alw.scientific = " << (int)display_always_scientific << std::endl;
|
||||
file << "disp.when.scientific = " << display_when_scientific << std::endl;
|
||||
file << "disp.rounding = " << display_rounding << std::endl;
|
||||
file << "disp.remove.zeroes = " << (int)remove_zeroes << std::endl;
|
||||
file << "disp.dec.point = " << decimal_point << std::endl;
|
||||
file << "disp.deg_rad_grad = " << angle_deg_rad_grad << std::endl;
|
||||
|
||||
|
||||
file << "\n[variables]\n";
|
||||
|
||||
@@ -705,5 +887,3 @@ int ProgramResources::GetBadLine()
|
||||
return bad_line;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -47,8 +47,10 @@
|
||||
#include "iniparser.h"
|
||||
#include "languages.h"
|
||||
#include "threadcontroller.h"
|
||||
#include "convert.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include <windows.h>
|
||||
|
||||
@@ -67,10 +69,14 @@
|
||||
GetPrgRes()->SetPrecision( new_precision );
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
if you change some variables by using GetVariable() method
|
||||
you should call VariablesChanged() in order to inform the second thread that variables have changed
|
||||
(variables_id will be increment), the same is for functions (FunctionsChanged() method)
|
||||
|
||||
methods which are used by the second thread:
|
||||
GetBuffer(), GetVariables(), GetFunctions(), GetBaseInput(), GetBaseOutput()
|
||||
GetDisplayAlwaysScientific(), GetDisplayWhenScientific(), GetDisplayRounding()
|
||||
GetCurrentLanguage(), GetPrecision()
|
||||
GetCurrentLanguage(), GetPrecision() ...
|
||||
|
||||
and if you're using methods which begin with Set..... you must call it
|
||||
between StopCalculating() and StartCalculating()
|
||||
@@ -217,12 +223,43 @@ public:
|
||||
|
||||
|
||||
/*!
|
||||
pointers to variables' table, functions' table, the language's object
|
||||
if you change some variables by using GetVariable() method
|
||||
you should call this method in order to inform the second thread that variables have changed
|
||||
(variables_id will be increment)
|
||||
*/
|
||||
void VariablesChanged();
|
||||
|
||||
|
||||
/*!
|
||||
if you change some functions by using GetFunction() method
|
||||
you should call this method in order to inform the second thread that functions have changed
|
||||
(functions_id will be increment)
|
||||
*/
|
||||
void FunctionsChanged();
|
||||
|
||||
|
||||
/*!
|
||||
returning the state of variables_id
|
||||
(used by the second thread)
|
||||
*/
|
||||
int GetVariablesId();
|
||||
|
||||
|
||||
/*!
|
||||
returning the state of functions_id
|
||||
(used by the second thread)
|
||||
*/
|
||||
int GetFunctionsId();
|
||||
|
||||
|
||||
/*!
|
||||
pointers to variables' table, functions' table, the languages' object, convert object
|
||||
and to the characters' buffer
|
||||
*/
|
||||
ttmath::Objects * GetVariables();
|
||||
ttmath::Objects * GetFunctions();
|
||||
Languages * GetLanguages();
|
||||
Convert * GetConvert();
|
||||
char * GetBuffer();
|
||||
unsigned int GetBufferSize();
|
||||
|
||||
@@ -262,17 +299,45 @@ public:
|
||||
|
||||
/*!
|
||||
reading and writing to a file
|
||||
|
||||
ReadVariablesFunctionsFromFile() reads variables/functions only when they are not exist (in this instance of TTCalc)
|
||||
*/
|
||||
IniParser::Error ReadVariablesFunctionsFromFile();
|
||||
IniParser::Error ReadFromFile();
|
||||
void SaveToFile();
|
||||
|
||||
|
||||
/*!
|
||||
it returns a number of line where there was an error
|
||||
it returns a number of a line where there was an error
|
||||
during last parsing
|
||||
*/
|
||||
int GetBadLine();
|
||||
|
||||
/*!
|
||||
setting and returning the decimal point used during printig values
|
||||
0 - '.'
|
||||
1 - ','
|
||||
*/
|
||||
void SetDecimalPoint(int decimal);
|
||||
int GetDecimalPoint();
|
||||
|
||||
|
||||
/*!
|
||||
setting and returning the state of removing trailing zeroes
|
||||
(used during printing values)
|
||||
*/
|
||||
void SetRemovingZeroes(bool r);
|
||||
bool GetRemovingZeroes();
|
||||
|
||||
|
||||
/*!
|
||||
setting and returning the unit of angle in which sin/cos/tan/ctg (arc sin...) operate
|
||||
0 - deg
|
||||
1 - red
|
||||
2 - grad
|
||||
*/
|
||||
void SetDegRadGrad(int angle);
|
||||
int GetDegRadGrad();
|
||||
|
||||
private:
|
||||
|
||||
@@ -281,18 +346,24 @@ private:
|
||||
bool IsDecDigit(int c);
|
||||
bool SplitFunction(const std::string & input, const char * * name, int * param);
|
||||
void CheckCoordinates();
|
||||
void AddVariablesFunctions(IniParser::Section & temp_variables, IniParser::Section & temp_functions, bool if_not_exist);
|
||||
|
||||
|
||||
ttmath::Objects variables;
|
||||
ttmath::Objects functions;
|
||||
Languages languages;
|
||||
Convert convert;
|
||||
volatile ThreadController thread_controller;
|
||||
|
||||
int variables_id;
|
||||
int functions_id;
|
||||
|
||||
unsigned int buffer_size;
|
||||
char * buffer;
|
||||
|
||||
HINSTANCE hInstance;
|
||||
HWND main_window;
|
||||
HWND tab_window[5];
|
||||
HWND tab_window[6];
|
||||
|
||||
int precision;
|
||||
bool always_on_top;
|
||||
@@ -313,11 +384,17 @@ private:
|
||||
int base_input;
|
||||
int base_output;
|
||||
|
||||
int decimal_point;
|
||||
|
||||
bool display_always_scientific;
|
||||
int display_when_scientific;
|
||||
int display_rounding;
|
||||
bool remove_zeroes;
|
||||
int angle_deg_rad_grad;
|
||||
|
||||
int bad_line;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -58,10 +58,12 @@
|
||||
#define IDD_DIALOG_FUNCTIONS 112
|
||||
#define IDD_DIALOG_PRECISION 113
|
||||
#define IDD_DIALOG_DISPLAY 114
|
||||
#define IDD_DIALOG_CONVERT 115
|
||||
|
||||
#define IDR_MENU 200
|
||||
#define IDC_TAB 1010
|
||||
#define IDI_ICON1 104
|
||||
#define IDI_ICON2 104
|
||||
#define IDI_ICON1 105
|
||||
#define IDC_INPUT_EDIT 1000
|
||||
#define IDC_OUTPUT_EDIT 1001
|
||||
|
||||
@@ -161,6 +163,25 @@
|
||||
#define IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC 1165
|
||||
#define IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC 1166
|
||||
#define IDC_LABEL_GROUP_SCIENTIFIC 1168
|
||||
#define IDC_LABEL_DECIMAL_POINT 1169
|
||||
#define IDC_COMBO_DECIMAL_POINT 1170
|
||||
#define IDC_CHECK_REMOVE_ZEROES 1171
|
||||
#define IDC_LABEL_DISPLAY_DEG_RAD_GRAD 1172
|
||||
#define IDC_COMBO_DEG_RAD_GRAD 1173
|
||||
|
||||
|
||||
// convert tab
|
||||
#define IDC_LIST_UNIT_TYPE 1200
|
||||
#define IDC_LIST_UNIT_INPUT1 1201
|
||||
#define IDC_LIST_UNIT_INPUT2 1202
|
||||
#define IDC_LIST_UNIT_OUTPUT1 1203
|
||||
#define IDC_LIST_UNIT_OUTPUT2 1204
|
||||
#define IDC_STATIC_UNIT_INPUT 1205
|
||||
#define IDC_STATIC_UNIT_OUTPUT 1206
|
||||
#define IDC_COMBO_DYNAMIC_OUTPUT 1207
|
||||
#define IDC_EDIT_OUTPUT_INFO 1208
|
||||
#define IDC_STATIC_UNIT_CONVERSION 1209
|
||||
|
||||
|
||||
// menu
|
||||
#define IDM_VIEW_INDEX 0
|
||||
@@ -173,6 +194,11 @@
|
||||
#define IDM_ALWAYS_ON_TOP 40004
|
||||
#define IDM_LANGUAGE_ENGLISH 40010
|
||||
#define IDM_LANGUAGE_POLISH 40011
|
||||
#define IDM_LANGUAGE_SPANISH 40012
|
||||
#define IDM_LANGUAGE_DANISH 40013
|
||||
#define IDM_LANGUAGE_CHINESE 40014
|
||||
#define IDM_LANGUAGE_RUSSIAN 40015
|
||||
#define IDM_LANGUAGE_SWEDISH 40016
|
||||
#define IDM_CLOSE_PROGRAM 40020
|
||||
#define IDM_EDIT_UNDO 40030
|
||||
#define IDM_EDIT_PASTE 40031
|
||||
|
117
src/resource.rc
117
src/resource.rc
@@ -1,11 +1,16 @@
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
#include "afxres.h"
|
||||
//#include "afxres.h"
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#include "windows.h"
|
||||
|
||||
LANGUAGE LANG_POLISH, 1
|
||||
104 ICON "..\\res\\icon01.ico"
|
||||
104 ICON "..\\res\\icon02.ico"
|
||||
|
||||
LANGUAGE LANG_POLISH, 2
|
||||
105 ICON "..\\res\\icon01.ico"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
LANGUAGE LANG_NEUTRAL, 0
|
||||
200 MENU
|
||||
@@ -23,6 +28,11 @@ BEGIN
|
||||
BEGIN
|
||||
MENUITEM "&English", 40010
|
||||
MENUITEM "&Polish", 40011
|
||||
MENUITEM "&Spanish", 40012
|
||||
MENUITEM "&Danish", 40013
|
||||
MENUITEM "&Chinese", 40014
|
||||
MENUITEM "&Russian", 40015
|
||||
MENUITEM "&Swedish", 40016
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Close", 40020
|
||||
@@ -54,7 +64,7 @@ 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_GROUP| WS_VISIBLE ,0,39,261,110, WS_EX_CONTROLPARENT
|
||||
CONTROL "",1010,"SysTabControl32",WS_CHILD |WS_TABSTOP |WS_GROUP| WS_VISIBLE ,0,39,261,106, WS_EX_CONTROLPARENT
|
||||
END
|
||||
|
||||
|
||||
@@ -66,10 +76,10 @@ FONT 8, "Ms Shell Dlg"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Ok",1,291,10,50,14,BS_CENTER | BS_VCENTER
|
||||
PUSHBUTTON "Cancel",2,291,28,50,14,BS_CENTER | BS_VCENTER
|
||||
EDITTEXT 1134,38,10,67,14,ES_AUTOHSCROLL
|
||||
EDITTEXT 1135,38,28,230,14,ES_AUTOHSCROLL
|
||||
LTEXT "name:",1136,7,12,27,8
|
||||
LTEXT "value:",1137,7,30,27,8
|
||||
EDITTEXT 1134,47,10,67,14,ES_AUTOHSCROLL
|
||||
EDITTEXT 1135,47,28,226,14,ES_AUTOHSCROLL
|
||||
LTEXT "name:",1136,7,12,38,8
|
||||
LTEXT "value:",1137,7,30,38,8
|
||||
END
|
||||
|
||||
103 DIALOG DISCARDABLE 0, 0, 370, 74
|
||||
@@ -77,16 +87,17 @@ STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE |
|
||||
WS_CAPTION | WS_SYSMENU
|
||||
FONT 8, "Ms Shell Dlg"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Ok",1,303,10,50,14,BS_CENTER | BS_VCENTER
|
||||
PUSHBUTTON "Cancel",2,303,27,50,14,BS_CENTER | BS_VCENTER
|
||||
EDITTEXT 1144,46,10,67,14,ES_AUTOHSCROLL
|
||||
COMBOBOX 1146,46,29,67,130,CBS_DROPDOWNLIST | WS_TABSTOP
|
||||
EDITTEXT 1145,46,47,308,14,ES_AUTOHSCROLL
|
||||
LTEXT "name:",1147,7,12,31,8
|
||||
LTEXT "value:",1149,7,49,33,8
|
||||
LTEXT "param:",1148,7,30,33,8
|
||||
DEFPUSHBUTTON "Ok",1,304,10,50,14,BS_CENTER | BS_VCENTER
|
||||
PUSHBUTTON "Cancel",2,304,27,50,14,BS_CENTER | BS_VCENTER
|
||||
EDITTEXT 1144,55,10,67,14,ES_AUTOHSCROLL
|
||||
COMBOBOX 1146,55,29,67,130,CBS_DROPDOWNLIST | WS_TABSTOP
|
||||
EDITTEXT 1145,55,47,299,14,ES_AUTOHSCROLL
|
||||
LTEXT "name:",1147,7,12,46,8
|
||||
LTEXT "value:",1149,7,49,46,8
|
||||
LTEXT "param:",1148,7,30,46,8
|
||||
END
|
||||
|
||||
|
||||
110 DIALOGEX 0, 0, 287, 90
|
||||
STYLE DS_3DLOOK | DS_FIXEDSYS |DS_SETFONT | WS_CHILD| WS_TABSTOP |WS_GROUP
|
||||
FONT 8, "Ms Shell Dlg"
|
||||
@@ -172,24 +183,78 @@ END
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
114 DIALOG DISCARDABLE 0, 0, 255, 90
|
||||
STYLE DS_3DLOOK | DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
|
||||
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | WS_GROUP |
|
||||
WS_TABSTOP
|
||||
CAPTION "tab5"
|
||||
FONT 8, "Ms Shell Dlg"
|
||||
BEGIN
|
||||
COMBOBOX 1156,58,5,63,200,CBS_DROPDOWNLIST | WS_TABSTOP | WS_GROUP
|
||||
COMBOBOX 1157,58,19,63,200,CBS_DROPDOWNLIST | WS_TABSTOP
|
||||
LTEXT "Input",1162,11,7,27,8
|
||||
LTEXT "Output",1163,11,22,29,8
|
||||
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 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
|
||||
COMBOBOX 1156,58,5,58,200,CBS_DROPDOWNLIST | WS_GROUP |
|
||||
WS_TABSTOP
|
||||
COMBOBOX 1157,58,19,58,200,CBS_DROPDOWNLIST | WS_TABSTOP
|
||||
CONTROL "Input",1162,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,11,7,
|
||||
43,8
|
||||
CONTROL "Output",1163,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,11,
|
||||
22,43,8
|
||||
COMBOBOX 1159,58,33,58,200,CBS_DROPDOWNLIST | WS_TABSTOP
|
||||
CONTROL "Rounding",1164,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,11,
|
||||
36,43,8
|
||||
COMBOBOX 1173,213,5,38,54,CBS_DROPDOWNLIST | WS_TABSTOP
|
||||
CONTROL "sin/cos asin/acos",1172,"Static",SS_LEFTNOWORDWRAP |
|
||||
WS_GROUP,137,7,73,8
|
||||
COMBOBOX 1170,213,19,38,62,CBS_DROPDOWNLIST | WS_TABSTOP
|
||||
CONTROL "Decimal point",1169,"Static",SS_LEFTNOWORDWRAP |
|
||||
WS_GROUP,137,22,73,8
|
||||
CONTROL "remove trailing zeroes",1171,"Button",BS_AUTOCHECKBOX |
|
||||
BS_LEFTTEXT | BS_LEFT | WS_TABSTOP,136,36,115,10
|
||||
CONTROL "Always",1160,"Button",BS_AUTORADIOBUTTON | BS_LEFT |
|
||||
WS_GROUP | WS_TABSTOP,19,65,54,10
|
||||
CONTROL "When the exponent is greater than:",1161,"Button",
|
||||
BS_AUTORADIOBUTTON | BS_LEFT,77,65,138,10
|
||||
EDITTEXT 1166,217,63,29,14,ES_NUMBER | WS_GROUP
|
||||
CONTROL "",1165,"msctls_updown32",UDS_SETBUDDYINT |
|
||||
UDS_ALIGNRIGHT | UDS_ARROWKEYS,201,73,11,14
|
||||
GROUPBOX "Print scientific value",1168,11,51,240,31
|
||||
END
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef TTCALC_CONVERT
|
||||
|
||||
115 DIALOG DISCARDABLE 0, 0, 260, 90
|
||||
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | WS_GROUP |
|
||||
WS_TABSTOP
|
||||
CAPTION "tab6"
|
||||
FONT 8, "Ms Shell Dlg"
|
||||
BEGIN
|
||||
LTEXT "Conversion type",IDC_STATIC_UNIT_CONVERSION,3,2,55,8
|
||||
LTEXT "Input",IDC_STATIC_UNIT_INPUT,60,2,73,8
|
||||
LTEXT "Output",IDC_STATIC_UNIT_OUTPUT,162,2,80,8
|
||||
CONTROL "List1",IDC_LIST_UNIT_TYPE,"SysListView32",LVS_REPORT |
|
||||
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER |
|
||||
WS_BORDER | WS_TABSTOP,3,12,50,56
|
||||
CONTROL "List2a",IDC_LIST_UNIT_INPUT1,"SysListView32",LVS_REPORT |
|
||||
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER |
|
||||
WS_BORDER | WS_TABSTOP,60,12,26,56
|
||||
CONTROL "List2b",IDC_LIST_UNIT_INPUT2,"SysListView32",LVS_REPORT |
|
||||
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER |
|
||||
WS_BORDER | WS_TABSTOP,90,12,65,56
|
||||
CONTROL "List3a",IDC_LIST_UNIT_OUTPUT1,"SysListView32",
|
||||
LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS |
|
||||
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,161,12,26,56
|
||||
CONTROL "List3b",IDC_LIST_UNIT_OUTPUT2,"SysListView32",
|
||||
LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS |
|
||||
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,190,12,65,56
|
||||
EDITTEXT IDC_EDIT_OUTPUT_INFO,3,72,152,14,ES_AUTOHSCROLL |
|
||||
ES_READONLY
|
||||
CONTROL "dynamically output",IDC_COMBO_DYNAMIC_OUTPUT,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,162,74,88,10
|
||||
END
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef TTCALC_PORTABLE
|
||||
200 DIALOG DISCARDABLE 0, 0, 349, 202
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
489
src/tabs.cpp
489
src/tabs.cpp
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,6 +45,7 @@ int tab_variables;
|
||||
int tab_functions;
|
||||
int tab_precision;
|
||||
int tab_display;
|
||||
int tab_convert;
|
||||
|
||||
ttmath::ErrorCode last_code = ttmath::err_ok;
|
||||
|
||||
@@ -412,7 +413,6 @@ int i;
|
||||
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_RESETCONTENT, 0, 0);
|
||||
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_ADDSTRING, 0, (LPARAM)GetPrgRes()->GetLanguages()->GuiMessage(Languages::combo_rounding_cut_last_digits) );
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_ADDSTRING, 0, (LPARAM)GetPrgRes()->GetLanguages()->GuiMessage(Languages::combo_rounding_none) );
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_ADDSTRING, 0, (LPARAM)GetPrgRes()->GetLanguages()->GuiMessage(Languages::combo_rounding_integer) );
|
||||
|
||||
@@ -431,7 +431,7 @@ int i;
|
||||
if( r > max_r )
|
||||
r = max_r;
|
||||
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_SETCURSEL, r+2, 0);
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_SETCURSEL, r+1, 0);
|
||||
|
||||
|
||||
SetDlgItemText(hWnd, IDC_LABEL_DISPLAY_INPUT, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_input));
|
||||
@@ -442,9 +442,218 @@ int i;
|
||||
SetDlgItemText(hWnd, IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_not_always_scientific));
|
||||
|
||||
SetDlgItemText(hWnd, IDC_LABEL_GROUP_SCIENTIFIC, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_group_scientific));
|
||||
|
||||
SetDlgItemText(hWnd, IDC_LABEL_DECIMAL_POINT, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_decimal_point));
|
||||
|
||||
SetDlgItemText(hWnd, IDC_CHECK_REMOVE_ZEROES, GetPrgRes()->GetLanguages()->GuiMessage(Languages::check_remove_zeroes));
|
||||
|
||||
SetDlgItemText(hWnd, IDC_LABEL_DISPLAY_DEG_RAD_GRAD, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_deg_rad_grad));
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
-1 if there's no such item
|
||||
*/
|
||||
int FindItem(HWND list, int i)
|
||||
{
|
||||
LVFINDINFO info;
|
||||
|
||||
info.flags = LVFI_PARAM;
|
||||
info.lParam = i;
|
||||
|
||||
return ListView_FindItem(list, -1, &info);
|
||||
}
|
||||
|
||||
|
||||
void TabConvertFillUpUnitList(HWND list, int conv_type)
|
||||
{
|
||||
Convert * pconv = GetPrgRes()->GetConvert();
|
||||
unsigned int len = pconv->GetUnitSize();
|
||||
unsigned int i, index;
|
||||
|
||||
ListView_DeleteAllItems(list);
|
||||
|
||||
LVITEM item;
|
||||
item.mask = LVIF_PARAM | LVIF_TEXT;
|
||||
item.iSubItem = 0;
|
||||
|
||||
for( i=index=0 ; i<len ; ++i )
|
||||
{
|
||||
if( pconv->GetUnitType(i) == conv_type )
|
||||
{
|
||||
item.lParam = i;
|
||||
item.iItem = index++;
|
||||
int country = static_cast<unsigned int>(GetPrgRes()->GetLanguages()->GetCurrentLanguage());
|
||||
item.pszText = const_cast<char*>(pconv->GetUnitName(country, i));
|
||||
|
||||
ListView_InsertItem(list, &item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TabConvertFillUpUnitLists(HWND hWnd)
|
||||
{
|
||||
HWND list2b = GetDlgItem(hWnd, IDC_LIST_UNIT_INPUT2);
|
||||
HWND list3b = GetDlgItem(hWnd, IDC_LIST_UNIT_OUTPUT2);
|
||||
int input, output;
|
||||
|
||||
int convtype = GetPrgRes()->GetConvert()->GetCurrentType();
|
||||
|
||||
TabConvertFillUpUnitList(list2b, convtype);
|
||||
TabConvertFillUpUnitList(list3b, convtype);
|
||||
GetPrgRes()->GetConvert()->GetCurrentUnit( convtype, input, output);
|
||||
|
||||
if( input >= 0 )
|
||||
{
|
||||
int i = FindItem(list2b, input);
|
||||
|
||||
if( i >= 0 )
|
||||
ListView_SetItemState(list2b, i, LVIS_SELECTED, LVIS_SELECTED); //LVIS_FOCUSED
|
||||
}
|
||||
|
||||
if( output >= 0 )
|
||||
{
|
||||
int i = FindItem(list3b, output);
|
||||
|
||||
if( i>=0 )
|
||||
ListView_SetItemState(list3b, i, LVIS_SELECTED, LVIS_SELECTED); //LVIS_FOCUSED
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
we must check whether the item id is really selected
|
||||
(this method is called from WM_NOTIFY and can be another states on the item)
|
||||
*/
|
||||
void TabConvertTypeChanged(HWND hWnd, int id)
|
||||
{
|
||||
HWND list1 = GetDlgItem(hWnd, IDC_LIST_UNIT_TYPE);
|
||||
|
||||
if( ListView_GetItemState(list1, id, LVIS_SELECTED | LVIS_FOCUSED) != (LVIS_SELECTED | LVIS_FOCUSED) )
|
||||
return;
|
||||
|
||||
|
||||
// the item is selected now
|
||||
LVITEM item;
|
||||
item.iItem = id;
|
||||
item.iSubItem = 0;
|
||||
item.mask = LVIF_PARAM;
|
||||
if( !ListView_GetItem(list1, &item) )
|
||||
return;
|
||||
|
||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||
GetPrgRes()->GetConvert()->SetCurrentType( (int)item.lParam );
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
TabConvertFillUpUnitLists(hWnd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
we must check whether the item id is really selected
|
||||
(this method is called from WM_NOTIFY and can be another states on the item)
|
||||
*/
|
||||
void TabConvertUnitInputChanged(HWND hWnd, int id)
|
||||
{
|
||||
HWND list2b = GetDlgItem(hWnd, IDC_LIST_UNIT_INPUT2);
|
||||
|
||||
if( ListView_GetItemState(list2b, id, LVIS_SELECTED | LVIS_FOCUSED) != (LVIS_SELECTED | LVIS_FOCUSED) )
|
||||
return;
|
||||
|
||||
// the item is selected
|
||||
LVITEM item;
|
||||
item.iItem = id;
|
||||
item.iSubItem = 0;
|
||||
item.mask = LVIF_PARAM;
|
||||
if( !ListView_GetItem(list2b, &item) )
|
||||
return;
|
||||
|
||||
int convtype = GetPrgRes()->GetConvert()->GetCurrentType();
|
||||
int input, output;
|
||||
|
||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||
GetPrgRes()->GetConvert()->GetCurrentUnit(convtype, input, output);
|
||||
GetPrgRes()->GetConvert()->SetCurrentUnit(convtype, (int)item.lParam, output );
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
we must check whether the item id is really selected
|
||||
(this method is called from WM_NOTIFY and can be another states on the item)
|
||||
*/
|
||||
void TabConvertUnitOutputChanged(HWND hWnd, int id)
|
||||
{
|
||||
HWND list3b = GetDlgItem(hWnd, IDC_LIST_UNIT_OUTPUT2);
|
||||
|
||||
if( ListView_GetItemState(list3b, id, LVIS_SELECTED | LVIS_FOCUSED) != (LVIS_SELECTED | LVIS_FOCUSED) )
|
||||
return;
|
||||
|
||||
|
||||
// the item is selected
|
||||
LVITEM item;
|
||||
item.iItem = id;
|
||||
item.iSubItem = 0;
|
||||
item.mask = LVIF_PARAM;
|
||||
if( !ListView_GetItem(list3b, &item) )
|
||||
return;
|
||||
|
||||
int convtype = GetPrgRes()->GetConvert()->GetCurrentType();
|
||||
int input, output;
|
||||
|
||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||
GetPrgRes()->GetConvert()->GetCurrentUnit(convtype, input, output);
|
||||
GetPrgRes()->GetConvert()->SetCurrentUnit(convtype, input, (int)item.lParam );
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void SetLanguageTabConvert(HWND hWnd)
|
||||
{
|
||||
Languages * plang = GetPrgRes()->GetLanguages();
|
||||
Convert * pconv = GetPrgRes()->GetConvert();
|
||||
|
||||
SetDlgItemText(hWnd, IDC_STATIC_UNIT_CONVERSION, plang->GuiMessage(Languages::convert_type) );
|
||||
SetDlgItemText(hWnd, IDC_STATIC_UNIT_INPUT, plang->GuiMessage(Languages::convert_input) );
|
||||
SetDlgItemText(hWnd, IDC_STATIC_UNIT_OUTPUT, plang->GuiMessage(Languages::convert_output) );
|
||||
SetDlgItemText(hWnd, IDC_COMBO_DYNAMIC_OUTPUT, plang->GuiMessage(Languages::convert_dynamic_output) );
|
||||
|
||||
HWND list1 = GetDlgItem(hWnd, IDC_LIST_UNIT_TYPE);
|
||||
|
||||
ListView_DeleteAllItems(list1);
|
||||
|
||||
LVITEM item;
|
||||
item.mask = LVIF_PARAM | LVIF_TEXT;
|
||||
item.iSubItem = 0;
|
||||
|
||||
unsigned int conv_type_size = pconv->GetTypeSize();
|
||||
|
||||
for(unsigned int i = 0 ; i<conv_type_size ; ++i)
|
||||
{
|
||||
item.lParam = i;
|
||||
item.iItem = i;
|
||||
int country = static_cast<unsigned int>(plang->GetCurrentLanguage());
|
||||
item.pszText = const_cast<char*>(pconv->GetTypeName(country, i));
|
||||
|
||||
ListView_InsertItem(list1, &item);
|
||||
}
|
||||
|
||||
int type = FindItem(list1, GetPrgRes()->GetConvert()->GetCurrentType() );
|
||||
if( type != -1 )
|
||||
ListView_SetItemState(list1, type, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
|
||||
// there'll be generated wm_notify message and the next lists will be changed then
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SetLanguage(HWND hTab)
|
||||
{
|
||||
TCITEM tab;
|
||||
@@ -461,15 +670,18 @@ TCITEM tab;
|
||||
TabCtrl_SetItem(hTab,tab_functions, &tab);
|
||||
|
||||
#ifndef TTCALC_PORTABLE
|
||||
|
||||
tab.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::tab_precision) );
|
||||
TabCtrl_SetItem(hTab,tab_precision, &tab);
|
||||
|
||||
#endif
|
||||
|
||||
tab.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::tab_display) );
|
||||
TabCtrl_SetItem(hTab,tab_display, &tab);
|
||||
|
||||
#ifdef TTCALC_CONVERT
|
||||
tab.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::tab_convert) );
|
||||
TabCtrl_SetItem(hTab,tab_convert, &tab);
|
||||
#endif
|
||||
|
||||
SetLanguageTabStandard( GetPrgRes()->GetTabWindow(tab_standard) );
|
||||
SetLanguageTabVariables( GetPrgRes()->GetTabWindow(tab_variables) );
|
||||
SetLanguageTabFunctions( GetPrgRes()->GetTabWindow(tab_functions) );
|
||||
@@ -480,6 +692,10 @@ TCITEM tab;
|
||||
|
||||
SetLanguageTabDisplay( GetPrgRes()->GetTabWindow(tab_display) );
|
||||
|
||||
#ifdef TTCALC_CONVERT
|
||||
SetLanguageTabConvert( GetPrgRes()->GetTabWindow(tab_convert) );
|
||||
#endif
|
||||
|
||||
InvalidateRect(hTab, 0, false);
|
||||
}
|
||||
|
||||
@@ -567,13 +783,52 @@ return true;
|
||||
}
|
||||
|
||||
|
||||
BOOL WmTabCommand_DisplayDecimalPointChanged(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if( HIWORD(wParam) != CBN_SELCHANGE )
|
||||
return false;
|
||||
|
||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||
GetPrgRes()->SetDecimalPoint( (int)SendDlgItemMessage(hWnd, IDC_COMBO_DECIMAL_POINT, CB_GETCURSEL, 0, 0) );
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BOOL WmTabCommand_DisplayRoundingChanged(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if( HIWORD(wParam) != CBN_SELCHANGE )
|
||||
return false;
|
||||
|
||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||
GetPrgRes()->SetDisplayRounding( (int)SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_GETCURSEL, 0, 0) - 2);
|
||||
GetPrgRes()->SetDisplayRounding( (int)SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_GETCURSEL, 0, 0) - 1);
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL WmTabCommand_RemoveZeroesChanged(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||
|
||||
if( IsDlgButtonChecked(hWnd, IDC_CHECK_REMOVE_ZEROES) == BST_CHECKED )
|
||||
GetPrgRes()->SetRemovingZeroes(true);
|
||||
else
|
||||
GetPrgRes()->SetRemovingZeroes(false);
|
||||
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL WmTabCommand_DisplayDegRadGradChanged(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if( HIWORD(wParam) != CBN_SELCHANGE )
|
||||
return false;
|
||||
|
||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||
GetPrgRes()->SetDegRadGrad( (int)SendDlgItemMessage(hWnd, IDC_COMBO_DEG_RAD_GRAD, CB_GETCURSEL, 0, 0) );
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
return true;
|
||||
@@ -736,9 +991,13 @@ void CreateTabCommandMessagesTable(Messages & cmessages)
|
||||
cmessages.Associate(IDC_COMBO_DISPLAY_INPUT, WmTabCommand_DisplayInputChanged);
|
||||
cmessages.Associate(IDC_COMBO_DISPLAY_OUTPUT, WmTabCommand_DisplayOutputChanged);
|
||||
cmessages.Associate(IDC_COMBO_DISPLAY_ROUNDING, WmTabCommand_DisplayRoundingChanged);
|
||||
cmessages.Associate(IDC_CHECK_REMOVE_ZEROES, WmTabCommand_RemoveZeroesChanged);
|
||||
|
||||
cmessages.Associate(IDC_RADIO_DISPLAY_ALWAYS_SCIENTIFIC, WmTabCommand_SetDisplayAlwaysScientific);
|
||||
cmessages.Associate(IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC, WmTabCommand_SetDisplayNotAlwaysScientific);
|
||||
cmessages.Associate(IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC, WmTabCommand_SetDisplayWhenScientific);
|
||||
cmessages.Associate(IDC_COMBO_DECIMAL_POINT, WmTabCommand_DisplayDecimalPointChanged);
|
||||
cmessages.Associate(IDC_COMBO_DEG_RAD_GRAD, WmTabCommand_DisplayDegRadGradChanged);
|
||||
|
||||
}
|
||||
|
||||
@@ -994,17 +1253,62 @@ char buffer[20];
|
||||
sprintf(buffer,"%d", GetPrgRes()->GetDisplayWhenScientific());
|
||||
SetDlgItemText(hWnd, IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC, buffer);
|
||||
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DECIMAL_POINT, CB_ADDSTRING, 0, (LPARAM)" .");
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DECIMAL_POINT, CB_ADDSTRING, 0, (LPARAM)" ,");
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DECIMAL_POINT, CB_SETCURSEL, GetPrgRes()->GetDecimalPoint(), 0);
|
||||
|
||||
if( GetPrgRes()->GetRemovingZeroes() )
|
||||
CheckDlgButton(hWnd, IDC_CHECK_REMOVE_ZEROES, BST_CHECKED);
|
||||
|
||||
|
||||
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DEG_RAD_GRAD, CB_ADDSTRING, 0, (LPARAM)"deg");
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DEG_RAD_GRAD, CB_ADDSTRING, 0, (LPARAM)"rad");
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DEG_RAD_GRAD, CB_ADDSTRING, 0, (LPARAM)"grad");
|
||||
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_DEG_RAD_GRAD, CB_SETCURSEL, GetPrgRes()->GetDegRadGrad(), 0);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL WmInitTabConvert(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND list1 = GetDlgItem(hWnd, IDC_LIST_UNIT_TYPE);
|
||||
HWND list2b = GetDlgItem(hWnd, IDC_LIST_UNIT_INPUT2);
|
||||
HWND list3b = GetDlgItem(hWnd, IDC_LIST_UNIT_OUTPUT2);
|
||||
|
||||
ListView_SetExtendedListViewStyle(list1, LVS_EX_FULLROWSELECT);
|
||||
ListView_SetExtendedListViewStyle(list2b, LVS_EX_FULLROWSELECT);
|
||||
ListView_SetExtendedListViewStyle(list3b, LVS_EX_FULLROWSELECT);
|
||||
|
||||
LVCOLUMN col;
|
||||
|
||||
col.mask = LVCF_FMT | LVCF_WIDTH;
|
||||
col.fmt = LVCFMT_LEFT;
|
||||
|
||||
col.cx = 70;
|
||||
ListView_InsertColumn(list1, 0, &col);
|
||||
|
||||
col.cx = 90;
|
||||
ListView_InsertColumn(list2b, 0, &col);
|
||||
|
||||
col.cx = 90;
|
||||
ListView_InsertColumn(list3b, 0, &col);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BOOL WmNotify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
NMHDR * pnmh = (LPNMHDR) lParam;
|
||||
HWND var_list = GetDlgItem(hWnd,IDC_VARIABLES_LIST);
|
||||
HWND fun_list = GetDlgItem(hWnd,IDC_FUNCTIONS_LIST);
|
||||
|
||||
|
||||
if( pnmh->hwndFrom == var_list )
|
||||
{
|
||||
if( pnmh->code == LVN_ITEMCHANGED )
|
||||
@@ -1052,6 +1356,32 @@ HWND fun_list = GetDlgItem(hWnd,IDC_FUNCTIONS_LIST);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef TTCALC_CONVERT
|
||||
HWND conv_list1 = GetDlgItem(hWnd,IDC_LIST_UNIT_TYPE);
|
||||
HWND conv_list2b = GetDlgItem(hWnd,IDC_LIST_UNIT_INPUT2);
|
||||
HWND conv_list3b = GetDlgItem(hWnd,IDC_LIST_UNIT_OUTPUT2);
|
||||
|
||||
if( pnmh->hwndFrom==conv_list1 || pnmh->hwndFrom==conv_list2b || pnmh->hwndFrom==conv_list3b )
|
||||
{
|
||||
if( pnmh->code == LVN_ITEMCHANGED )
|
||||
{
|
||||
NMLISTVIEW * pnmv = (NMLISTVIEW*) lParam;
|
||||
|
||||
if( pnmv->iItem != -1 )
|
||||
{
|
||||
if( pnmh->hwndFrom == conv_list1 )
|
||||
TabConvertTypeChanged(hWnd, pnmv->iItem);
|
||||
if( pnmh->hwndFrom == conv_list2b )
|
||||
TabConvertUnitInputChanged(hWnd, pnmv->iItem);
|
||||
else
|
||||
if( pnmh->hwndFrom == conv_list3b )
|
||||
TabConvertUnitOutputChanged(hWnd, pnmv->iItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1070,6 +1400,11 @@ void CreateTabMessagesTable(Messages & messages)
|
||||
#endif
|
||||
|
||||
messages.Associate(WM_INIT_TAB_DISPLAY, WmInitTabDisplay);
|
||||
|
||||
#ifdef TTCALC_CONVERT
|
||||
messages.Associate(WM_INIT_TAB_CONVERT, WmInitTabConvert);
|
||||
#endif
|
||||
|
||||
messages.Associate(WM_NOTIFY, WmNotify);
|
||||
}
|
||||
|
||||
@@ -1087,60 +1422,138 @@ return messages.Call(message, hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SetSizeOfFunctionVariableList(int tab_id, int list_id, int last_column)
|
||||
POINT ResizeTabDialog(HWND tab, HWND dialog, int tabx, int taby, int borderx, int bordery)
|
||||
{
|
||||
HWND main = GetPrgRes()->GetMainWindow();
|
||||
HWND tab = GetDlgItem(main, IDC_TAB);
|
||||
RECT r_dialog;
|
||||
POINT p, new_dialog_size;
|
||||
|
||||
POINT p,p2;
|
||||
RECT r_main, r;
|
||||
GetWindowRect(dialog, &r_dialog);
|
||||
p.x = r_dialog.left;
|
||||
p.y = r_dialog.top;
|
||||
ScreenToClient(tab,&p);
|
||||
new_dialog_size.x = tabx-borderx-p.x;
|
||||
new_dialog_size.y = taby-bordery-p.y;
|
||||
int resize_flags = SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER;
|
||||
SetWindowPos(dialog, 0, 0, 0, new_dialog_size.x, new_dialog_size.y, resize_flags);
|
||||
|
||||
return new_dialog_size;
|
||||
}
|
||||
|
||||
void SetSizeOfFunctionVariableList(HWND tab, int tabx, int taby, int borderx, int bordery, int tab_id, int list_id, int last_column)
|
||||
{
|
||||
RECT r;
|
||||
POINT p;
|
||||
|
||||
HWND dialog = GetPrgRes()->GetTabWindow(tab_id);
|
||||
HWND list = GetDlgItem(dialog, list_id);
|
||||
int resize_flags = SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER;
|
||||
|
||||
GetWindowRect(main, &r_main);
|
||||
int cx = r_main.right - r_main.left;
|
||||
int cy = r_main.bottom - r_main.top;
|
||||
int border_x = GetSystemMetrics(SM_CXDLGFRAME)*2;
|
||||
int border_y = GetSystemMetrics(SM_CYDLGFRAME)*2;
|
||||
|
||||
GetWindowRect(dialog, &r);
|
||||
p.x = r.left;
|
||||
p.y = r.top;
|
||||
p2 = p;
|
||||
p2.x -= r_main.left;
|
||||
p2.y -= r_main.top;
|
||||
ScreenToClient(tab, &p);
|
||||
MoveWindow(dialog, p.x, p.y, cx-p2.x-border_x-2, cy-p2.y-border_y-2, true);
|
||||
ResizeTabDialog(tab, dialog, tabx, taby, borderx, bordery);
|
||||
|
||||
GetWindowRect(list, &r);
|
||||
p.x = r.left;
|
||||
p.y = r.top;
|
||||
p2 = p;
|
||||
p2.x -= r_main.left;
|
||||
p2.y -= r_main.top;
|
||||
ScreenToClient(dialog, &p);
|
||||
int list_cx = cx-p2.x-border_x-2;
|
||||
MoveWindow(list, p.x, p.y, list_cx, cy-p2.y-border_y-2, true);
|
||||
ScreenToClient(tab,&p);
|
||||
int newx = tabx - borderx - p.x;
|
||||
int newy = taby - bordery - p.y;
|
||||
SetWindowPos(list, 0, 0, 0, newx, newy, resize_flags);
|
||||
|
||||
int sum = 0;
|
||||
for(int i=0 ; i<last_column ; ++i)
|
||||
sum += ListView_GetColumnWidth(list, i);
|
||||
|
||||
if( sum < list_cx - 30 )
|
||||
ListView_SetColumnWidth(list, last_column, list_cx-sum-25);
|
||||
if( sum < newx - 30 )
|
||||
ListView_SetColumnWidth(list, last_column, newx-sum-25);
|
||||
}
|
||||
|
||||
|
||||
void SetSizeOfVariablesList()
|
||||
void SetSizeOfVariablesList(HWND tab, int tabx, int taby, int borderx, int bordery)
|
||||
{
|
||||
SetSizeOfFunctionVariableList(TabWindowFunctions::tab_variables, IDC_VARIABLES_LIST, 1);
|
||||
SetSizeOfFunctionVariableList(tab, tabx, taby, borderx, bordery, TabWindowFunctions::tab_variables, IDC_VARIABLES_LIST, 1);
|
||||
}
|
||||
|
||||
void SetSizeOfFunctionsList()
|
||||
void SetSizeOfFunctionsList(HWND tab, int tabx, int taby, int borderx, int bordery)
|
||||
{
|
||||
SetSizeOfFunctionVariableList(TabWindowFunctions::tab_functions, IDC_FUNCTIONS_LIST, 2);
|
||||
SetSizeOfFunctionVariableList(tab, tabx, taby, borderx, bordery, TabWindowFunctions::tab_functions, IDC_FUNCTIONS_LIST, 2);
|
||||
}
|
||||
|
||||
|
||||
void SetSizeOfConvertingLists(HWND tab, int tabx, int taby, int borderx, int bordery)
|
||||
{
|
||||
RECT r_edit, r;
|
||||
POINT p;
|
||||
|
||||
HWND dialog = GetPrgRes()->GetTabWindow(tab_convert);
|
||||
HWND list1 = GetDlgItem(dialog, IDC_LIST_UNIT_TYPE);
|
||||
HWND info_edit = GetDlgItem(dialog, IDC_EDIT_OUTPUT_INFO);
|
||||
HWND check_dynamic_output = GetDlgItem(dialog, IDC_COMBO_DYNAMIC_OUTPUT);
|
||||
int move_flags = SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER;
|
||||
int move_resize_flags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER;
|
||||
|
||||
POINT dialog_new_size = ResizeTabDialog(tab, dialog, tabx, taby, borderx, bordery);
|
||||
|
||||
GetWindowRect(info_edit, &r_edit);
|
||||
|
||||
GetWindowRect(list1, &r);
|
||||
p.x = r.left;
|
||||
p.y = r.top;
|
||||
ScreenToClient(dialog,&p);
|
||||
|
||||
GetWindowRect(dialog, &r);
|
||||
int newy = (r.bottom-r.top) - bordery - (r_edit.bottom-r_edit.top) - p.y;
|
||||
int list1_x = p.x;
|
||||
|
||||
int list2a_cx = tabx/7;
|
||||
int list2b_cx = tabx/5;
|
||||
int list3a_cx = tabx/7;
|
||||
int list3b_cx = tabx/5;
|
||||
|
||||
int marginx = 4;
|
||||
int list1_cx = tabx - list2a_cx - list2b_cx - list3a_cx - list3b_cx - marginx*4 - borderx - 8;
|
||||
|
||||
SetWindowPos(list1, 0, list1_x, p.y, list1_cx, newy, move_resize_flags);
|
||||
|
||||
HWND list2a = GetDlgItem(dialog, IDC_LIST_UNIT_INPUT1);
|
||||
HWND list2b = GetDlgItem(dialog, IDC_LIST_UNIT_INPUT2);
|
||||
HWND list3a = GetDlgItem(dialog, IDC_LIST_UNIT_OUTPUT1);
|
||||
HWND list3b = GetDlgItem(dialog, IDC_LIST_UNIT_OUTPUT2);
|
||||
|
||||
int list2a_x = list1_x + list1_cx + marginx;
|
||||
int list2b_x = list2a_x + list2a_cx + marginx;
|
||||
int list3a_x = list2b_x + list2b_cx + marginx;
|
||||
int list3b_x = list3a_x + list3a_cx + marginx;
|
||||
|
||||
SetWindowPos(list2a, 0, list2a_x, p.y, list2a_cx, newy, move_resize_flags);
|
||||
SetWindowPos(list2b, 0, list2b_x, p.y, list2b_cx, newy, move_resize_flags);
|
||||
SetWindowPos(list3a, 0, list3a_x, p.y, list3a_cx, newy, move_resize_flags);
|
||||
SetWindowPos(list3b, 0, list3b_x, p.y, list3b_cx, newy, move_resize_flags);
|
||||
|
||||
newy = dialog_new_size.y -(r_edit.bottom-r_edit.top);
|
||||
int info_edit_cx = list1_cx + list2a_cx + list2b_cx + marginx*2;
|
||||
SetWindowPos(info_edit, 0, list1_x, newy, info_edit_cx, (r_edit.bottom-r_edit.top), move_resize_flags);
|
||||
|
||||
SetWindowPos(check_dynamic_output, 0, list1_x + info_edit_cx + marginx, newy, 0, 0, move_flags);
|
||||
|
||||
HWND static_type = GetDlgItem(dialog, IDC_STATIC_UNIT_CONVERSION);
|
||||
GetWindowRect(static_type, &r);
|
||||
p.x = r.left;
|
||||
p.y = r.top;
|
||||
ScreenToClient(dialog, &p);
|
||||
SetWindowPos(static_type, 0, list1_x, p.y, 0, 0, move_flags);
|
||||
|
||||
HWND static_input = GetDlgItem(dialog, IDC_STATIC_UNIT_INPUT);
|
||||
SetWindowPos(static_input, 0, list2a_x, p.y, 0, 0, move_flags);
|
||||
|
||||
HWND static_output = GetDlgItem(dialog, IDC_STATIC_UNIT_OUTPUT);
|
||||
SetWindowPos(static_output, 0, list3a_x, p.y, 0, 0, move_flags);
|
||||
|
||||
// setting width of colums inside the lists
|
||||
int vscroll_cx = GetSystemMetrics(SM_CXVSCROLL) + borderx;
|
||||
ListView_SetColumnWidth(list1, 0, list1_cx - vscroll_cx);
|
||||
ListView_SetColumnWidth(list2a, 0, list2a_cx - vscroll_cx);
|
||||
ListView_SetColumnWidth(list2b, 0, list2b_cx - vscroll_cx);
|
||||
ListView_SetColumnWidth(list3a, 0, list3a_cx - vscroll_cx);
|
||||
ListView_SetColumnWidth(list3b, 0, list3b_cx - vscroll_cx);
|
||||
}
|
||||
|
||||
|
||||
|
11
src/tabs.h
11
src/tabs.h
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -54,6 +54,7 @@
|
||||
#define WM_INIT_TAB_PRECISION WM_APP+2
|
||||
#define WM_INIT_TAB_DISPLAY WM_APP+3
|
||||
#define WM_SET_LAST_ERROR WM_APP+4
|
||||
#define WM_INIT_TAB_CONVERT WM_APP+5
|
||||
|
||||
namespace TabWindowFunctions
|
||||
{
|
||||
@@ -62,13 +63,15 @@ extern int tab_variables;
|
||||
extern int tab_functions;
|
||||
extern int tab_precision;
|
||||
extern int tab_display;
|
||||
extern int tab_convert;
|
||||
extern ttmath::ErrorCode last_code;
|
||||
|
||||
void PrintErrorCode();
|
||||
BOOL CALLBACK TabWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
void SetLanguage(HWND hTab);
|
||||
void SetSizeOfVariablesList();
|
||||
void SetSizeOfFunctionsList();
|
||||
void SetSizeOfVariablesList(HWND tab, int tabx, int taby, int borderx, int bordery);
|
||||
void SetSizeOfFunctionsList(HWND tab, int tabx, int taby, int borderx, int bordery);
|
||||
void SetSizeOfConvertingLists(HWND tab, int tabx, int taby, int borderx, int bordery);
|
||||
BOOL WmTabCommand(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
void SetSizeOfDialogs();
|
||||
|
||||
@@ -97,4 +100,6 @@ extern ttmath::ErrorCode last_code;
|
||||
}
|
||||
|
||||
|
||||
using TabWindowFunctions::Variables::GetSelectedItem;
|
||||
|
||||
#endif
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -243,7 +243,7 @@ NewStopCalculating stop_calculating;
|
||||
we make the copy-constructor private so that nobody will be able
|
||||
to make a copy of the one object of this class
|
||||
*/
|
||||
ThreadController(const ThreadController & c)
|
||||
ThreadController(const ThreadController &)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -109,10 +109,10 @@ char * pchar;
|
||||
pchar = new char[temporary_buffer_size];
|
||||
|
||||
GetDlgItemText(hWnd, IDC_EDIT_VARIABLE_NAME, pchar, temporary_buffer_size);
|
||||
name = ChangeToSmallLetters( StripWhiteCharacters(pchar) );
|
||||
name = StripWhiteCharacters(pchar);
|
||||
|
||||
GetDlgItemText(hWnd, IDC_EDIT_VARIABLE_VALUE, pchar, temporary_buffer_size);
|
||||
value = ChangeToSmallLetters( StripWhiteCharacters(pchar) );
|
||||
value = StripWhiteCharacters(pchar);
|
||||
|
||||
delete [] pchar;
|
||||
|
||||
@@ -254,6 +254,7 @@ BOOL WmTabCommand_AddVariable(HWND, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||
code = GetPrgRes()->GetVariables()->Add(name, value);
|
||||
GetPrgRes()->VariablesChanged();
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
if( code != ttmath::err_ok )
|
||||
@@ -317,6 +318,7 @@ adding = false;
|
||||
code = GetPrgRes()->GetVariables()->EditValue(name, value);
|
||||
// the code should be err_ok here
|
||||
|
||||
GetPrgRes()->VariablesChanged();
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
if( code != ttmath::err_ok )
|
||||
@@ -366,9 +368,12 @@ int items = ListView_GetSelectedCount(list);
|
||||
all_deleted = false;
|
||||
else
|
||||
ListView_DeleteItem(list, id);
|
||||
|
||||
GetPrgRes()->VariablesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
delete [] buffer;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -44,15 +44,21 @@
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <ttmath/ttmath.h>
|
||||
|
||||
|
||||
/*!
|
||||
here our application starts
|
||||
the application starts here
|
||||
*/
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||
{
|
||||
GetPrgRes()->SetInstance(hInstance);
|
||||
|
||||
// we're using GetLanguages() simultaneously in two threads, this is to be sure
|
||||
// that everything is initialized before the second thread is started
|
||||
GetPrgRes()->GetLanguages()->InitAll();
|
||||
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::en);
|
||||
//GetPrgRes()->GetConvert()->Init();
|
||||
GetPrgRes()->SetNameOfConfigurationFile();
|
||||
GetPrgRes()->ReadFromFile();
|
||||
|
||||
@@ -76,10 +82,13 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||
if( !GetPrgRes()->GetMainWindow() )
|
||||
return ShowError( Languages::cant_create_main_window );
|
||||
|
||||
|
||||
// there's the main loop of messages here
|
||||
MainMessagesLoop();
|
||||
|
||||
// there can be another variables/functions saved by other instantion of TTCalc
|
||||
// we're reading them now
|
||||
GetPrgRes()->ReadVariablesFunctionsFromFile();
|
||||
|
||||
GetPrgRes()->SaveToFile();
|
||||
CloseHandle( (HANDLE)thread_handle );
|
||||
|
||||
@@ -102,6 +111,7 @@ return static_cast<int>( error_code );
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
the main loop of messages
|
||||
*/
|
||||
@@ -111,36 +121,54 @@ MSG msg;
|
||||
|
||||
while( GetMessage(&msg,0,0,0) )
|
||||
{
|
||||
bool sended = false;
|
||||
bool sent = false;
|
||||
|
||||
// if there's CTRL+C or CTRL+V pressed we're trying to copy
|
||||
// a result from the output edit or trying to paste something from the clipboard
|
||||
if( msg.message==WM_KEYDOWN && (GetKeyState(VK_CONTROL) & 0xff00)!=0 )
|
||||
{
|
||||
if( msg.wParam == 'C' )
|
||||
{
|
||||
if( MainWindowFunctions::CopyResult() )
|
||||
sent = true;
|
||||
}
|
||||
else
|
||||
if( msg.wParam == 'V' )
|
||||
{
|
||||
if( MainWindowFunctions::Paste() )
|
||||
sent = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// we give our own special function for navigating from the keyboard
|
||||
// if our function returns false then we use a standard navigation
|
||||
// from the system
|
||||
if( msg.message == WM_KEYDOWN &&
|
||||
if( !sent && msg.message == WM_KEYDOWN &&
|
||||
( msg.wParam == VK_TAB ||
|
||||
msg.wParam == VK_DOWN || msg.wParam == VK_UP ||
|
||||
msg.wParam == VK_LEFT || msg.wParam == VK_DOWN ) )
|
||||
|
||||
{
|
||||
if( MainWindowFunctions::SetNextFocus(msg.wParam) )
|
||||
sended = true;
|
||||
sent = true;
|
||||
}
|
||||
|
||||
|
||||
// firt we try to send our message to dialogs
|
||||
// (the dialogs on the tab control)
|
||||
if( !sended )
|
||||
if( !sent )
|
||||
{
|
||||
for(unsigned int i=0 ; i<GetPrgRes()->HowManyTabWindows() && !sended ; ++i)
|
||||
for(unsigned int i=0 ; i<GetPrgRes()->HowManyTabWindows() && !sent ; ++i)
|
||||
{
|
||||
if( IsDialogMessage(GetPrgRes()->GetTabWindow(i), &msg) )
|
||||
sended = true;
|
||||
sent = true;
|
||||
}
|
||||
}
|
||||
|
||||
// if it's not a message to any of our dialogs we send it
|
||||
// to the main window (it's a dialog as well)
|
||||
if( !sended )
|
||||
if( !sent )
|
||||
{
|
||||
if( !IsDialogMessage(GetPrgRes()->GetMainWindow(), &msg) )
|
||||
{
|
||||
@@ -167,3 +195,5 @@ static Messages messages;
|
||||
// so that we have the logarythmic time to find the special function to call
|
||||
return messages.Call(message, hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -64,6 +64,8 @@ void MainMessagesLoop();
|
||||
namespace MainWindowFunctions
|
||||
{
|
||||
bool SetNextFocus(WPARAM wParam);
|
||||
bool CopyResult();
|
||||
bool Paste();
|
||||
void CreateMainMessagesTable(Messages & messages);
|
||||
BOOL CALLBACK AboutProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
}
|
||||
|
Reference in New Issue
Block a user