Compare commits
52 Commits
Author | SHA1 | Date |
---|---|---|
Tomasz Sowa | d54ebd1ae7 | |
Tomasz Sowa | af26634fb7 | |
Tomasz Sowa | 89741a880e | |
Tomasz Sowa | 14f987012d | |
Tomasz Sowa | c4f316d7d3 | |
Tomasz Sowa | 547f01bf34 | |
Tomasz Sowa | c4bcecc029 | |
Tomasz Sowa | af2f173a82 | |
Tomasz Sowa | 6c0a4b110e | |
Tomasz Sowa | 8e9a459c9c | |
Tomasz Sowa | 844f79b793 | |
Tomasz Sowa | 21372faa56 | |
Tomasz Sowa | ac8574e9da | |
Tomasz Sowa | 7c62d9eae0 | |
Tomasz Sowa | e87308c721 | |
Tomasz Sowa | eb7cec8ecc | |
Tomasz Sowa | f67657c026 | |
Tomasz Sowa | 300f1aaa5f | |
Tomasz Sowa | cfcb654e53 | |
Tomasz Sowa | 9e25a7bc7a | |
Tomasz Sowa | c3a35102a3 | |
Tomasz Sowa | 29f1aa1c8b | |
Tomasz Sowa | 56fea5a67c | |
Tomasz Sowa | 47e4d83eab | |
Tomasz Sowa | 48d182a05f | |
Tomasz Sowa | 6f6948087c | |
Tomasz Sowa | e6b64ccdad | |
Tomasz Sowa | 1f455925db | |
Tomasz Sowa | 6f48d6414f | |
Tomasz Sowa | 486c78d072 | |
Tomasz Sowa | eeb5930120 | |
Tomasz Sowa | 271db20fc5 | |
Tomasz Sowa | 3fd5347310 | |
Tomasz Sowa | 58069828e5 | |
Tomasz Sowa | c0a0660482 | |
Tomasz Sowa | ce272dcb1a | |
Tomasz Sowa | d3b0262244 | |
Tomasz Sowa | f3ee187413 | |
Tomasz Sowa | fbab1df13f | |
Tomasz Sowa | e7ec06ea9d | |
Tomasz Sowa | 4346383c57 | |
Tomasz Sowa | 19abe8ff12 | |
Tomasz Sowa | 2fd7432920 | |
Tomasz Sowa | 787557590a | |
Tomasz Sowa | fb04d22d14 | |
Tomasz Sowa | 8fa1a24350 | |
Tomasz Sowa | 59d24bf3ae | |
Tomasz Sowa | dbcfa526ec | |
Tomasz Sowa | ad3625deab | |
Tomasz Sowa | 637f82e5e2 | |
Tomasz Sowa | 85e16db946 | |
Tomasz Sowa | 8880e87af6 |
100
CHANGELOG
100
CHANGELOG
|
@ -1,3 +1,103 @@
|
||||||
|
Version 0.9.3 (2011.06.04):
|
||||||
|
* added: German translation made by
|
||||||
|
Moritz Beleites <morbel at gmx.net>
|
||||||
|
* added: on display tab: an option how many digits should be grouped
|
||||||
|
* changed: the way how buttons on display tab work
|
||||||
|
suppose we have "123+34+56" in the first edit, then select
|
||||||
|
(by mouse or a keyboard) "123+34" similar as you would like
|
||||||
|
to copy them to the clipboard, then press a button let we say
|
||||||
|
"sin" - the result is: "sin(123+34)+56"
|
||||||
|
* updated: Chinese translation
|
||||||
|
* fixed: ttcalc didn't correctly delete variables/functions from its config file
|
||||||
|
so when you restarted the program you still had the deleted variables/functions
|
||||||
|
* fixed: option: "parameters separated by" was not correctly read from the config file
|
||||||
|
|
||||||
|
|
||||||
|
Version 0.9.2 (2010.09.24):
|
||||||
|
* added: Italian translation made by
|
||||||
|
Damiano Monaco <dmonax at gmail.com>
|
||||||
|
* added: menu: edit->swap (ctrl+W)
|
||||||
|
swapping the input for the output edit
|
||||||
|
|
||||||
|
Changes from TTMath 0.9.2 relating to TTCalc:
|
||||||
|
* fixed: Big::Add() sometimes incorrectly rounded the last bit from its mantissa
|
||||||
|
* fixed: Big::ToString method
|
||||||
|
in some cases when in the output string the exponent should be equal zero
|
||||||
|
the method changes the exponent to one so the last digit from the mantissa
|
||||||
|
was lost
|
||||||
|
|
||||||
|
|
||||||
|
Version 0.9.1 (2010.02.07):
|
||||||
|
* fixed: the pad window didn't take into account following options (from display tab):
|
||||||
|
grouping, input commas and parameter separators
|
||||||
|
* updated: Chinese translation
|
||||||
|
|
||||||
|
Changes from TTMath 0.9.1 relating to TTCalc:
|
||||||
|
* fixed: the parser didn't use characters for changing the base (# and &)
|
||||||
|
those characters were skipped
|
||||||
|
(this bug was introduced in 0.9.0)
|
||||||
|
* fixed: added in the parser: operator's associativity
|
||||||
|
operator ^ (powering) is right-associative:
|
||||||
|
sample: 2^3^4 is equal 2^(3^4) and it is: 2.41e+24
|
||||||
|
previously was: 2^3^4 = (2^3)^4 = 4096
|
||||||
|
* changed: in Big::ToString() the base rounding is made only if the result value
|
||||||
|
would not be an integer, e.g. if the value is 1.999999999999 then
|
||||||
|
the base rounding will not be done - because as the result would be 2
|
||||||
|
* added: IEEE 754 half-to-even rounding (bankers' rounding) to the following
|
||||||
|
floating point algorithms: Big::Add, Big::Sub, Big::Mul, Big::Div
|
||||||
|
|
||||||
|
|
||||||
|
Version 0.9.0 (2009.11.25):
|
||||||
|
* fixed: when 'C' button was pressed, the cursor was not placed in the edit window
|
||||||
|
* added: Pad window - a multiline edit window
|
||||||
|
* added: Checking for update dialog box
|
||||||
|
also the program can check automatically for an update at startup
|
||||||
|
* added: there are some new buttons on the standard tab
|
||||||
|
- (...) - the whole expression is surrounded by brackets (ctrl+0 short cut)
|
||||||
|
- 1/(...)
|
||||||
|
- ;
|
||||||
|
- % - a new percentage operator
|
||||||
|
- floor/ceil/min/max/sqrt/root/gamma
|
||||||
|
* added: some new options on display tab:
|
||||||
|
- grouping
|
||||||
|
- input decimal point
|
||||||
|
- parameters separated by
|
||||||
|
* changed: precision:
|
||||||
|
Medium - 512 bits mantissa, 64 bits exponent
|
||||||
|
Big - 1024 bits mantissa, 128 bits exponent
|
||||||
|
|
||||||
|
Changes from TTMath 0.9.0 relating to TTCalc:
|
||||||
|
* added: operator percentage
|
||||||
|
e.g. 1000-50% = 1000-(1000*0,5) = 500
|
||||||
|
* added: function frac(x) - returns a value without the integer part
|
||||||
|
(only fraction remains)
|
||||||
|
* changed: algorithms in sqrt(x) and root(x ; n)
|
||||||
|
they were not too much accurate for some integers
|
||||||
|
e.g. Root(16;4) returned a value very closed to 2 but not exactly 2
|
||||||
|
* changed: added specializations to Big::ToString() when the base is equal 4, 8 or 16
|
||||||
|
the previous version was not accurate on some last digits (after the comma operator)
|
||||||
|
consider this binary value (32 bit mantissa):
|
||||||
|
base 2: 1.1111 1111 1111 1111 1111 1111 1110 101
|
||||||
|
previous ToString() gave:
|
||||||
|
base 4: 1.33333333333332
|
||||||
|
base 8: 1.777777777
|
||||||
|
base 16: 1.FFFFFF
|
||||||
|
now we have:
|
||||||
|
base 4: 1.3333333333333222
|
||||||
|
base 8: 1.77777777724
|
||||||
|
base 16: 1.FFFFFFEA
|
||||||
|
|
||||||
|
|
||||||
|
Version 0.8.7 prerelease (2009.09.16):
|
||||||
|
* added: new language: Swedish
|
||||||
|
translation made by: Lars 'Bafvert' Gafvert <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):
|
Version 0.8.6 (2009.06.30):
|
||||||
* added: new language: Russian
|
* added: new language: Russian
|
||||||
translation made by: Vladimir Gladilovich <vdgladilovich at gmail dot com>
|
translation made by: Vladimir Gladilovich <vdgladilovich at gmail dot com>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2006-2009, Tomasz Sowa
|
Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
5
README
5
README
|
@ -17,7 +17,8 @@ display values with the base (radix) from two to sixteen.
|
||||||
Author: Tomasz Sowa
|
Author: Tomasz Sowa
|
||||||
Contact: t.sowa@ttmath.org
|
Contact: t.sowa@ttmath.org
|
||||||
Licence: BSD (open source)
|
Licence: BSD (open source)
|
||||||
Interface: English, Polish, Spanish, Danish, Chinese, Russian
|
Interface: English, Polish, Spanish, Danish, Chinese, Russian,
|
||||||
|
Swedish, Italian, German
|
||||||
Project page: http://ttcalc.sourceforge.net/
|
Project page: http://ttcalc.sourceforge.net/
|
||||||
Bignum library: TTMath http://www.ttmath.org/
|
Bignum library: TTMath http://www.ttmath.org/
|
||||||
Operating systems: Microsoft Windows 9x/Me/NT/2000/XP/Vista
|
Operating systems: Microsoft Windows 9x/Me/NT/2000/XP/Vista/7
|
||||||
|
|
|
@ -28,7 +28,7 @@ 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
|
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
|
result was 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)).
|
a good approximation to the real zero (look at e-30 part which means 10^(-30)).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@
|
||||||
<li><a href="rounding_functions.html">round(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">ceil(x)</a></li>
|
||||||
<li><a href="rounding_functions.html">floor(x)</a></li>
|
<li><a href="rounding_functions.html">floor(x)</a></li>
|
||||||
|
<li><a href="rounding_functions.html">frac(x)</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,7 +100,8 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="other_functions.html">sqrt(x)</a></li>
|
<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">root(x ; n)</a></li>
|
||||||
<li><a href="other_functions.html">factorial(x)</a></li>
|
<li><a href="other_functions.html">factorial(n)</a></li>
|
||||||
|
<li><a href="other_functions.html">gamma(x)</a></li>
|
||||||
<li><a href="other_functions.html">abs(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">sgn(x)</a></li>
|
||||||
<li><a href="other_functions.html">mod(x; y)</a></li>
|
<li><a href="other_functions.html">mod(x; y)</a></li>
|
||||||
|
|
|
@ -33,9 +33,9 @@ variables and functions.
|
||||||
<p>
|
<p>
|
||||||
The program possesses an easy to use interface. Calculations are performed
|
The program possesses an easy to use interface. Calculations are performed
|
||||||
by using binary floating point numbers with three kinds of precision,
|
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
|
the biggest has 1024 bits for its mantissa and 128 bits for its exponent
|
||||||
that is about 6.70897699... * 10^51217599719369681875006054625051616609
|
that is about 9.80518... * 10^51217599719369681875006054625051616657
|
||||||
with 258 valid decimal digits. TTCalc independently allows to insert and
|
with 306 valid decimal digits. TTCalc independently allows to insert and
|
||||||
display values with the base (radix) from two to sixteen.
|
display values with the base (radix) from two to sixteen.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -44,10 +44,10 @@ display values with the base (radix) from two to sixteen.
|
||||||
<tr><td>Author:</td><td>Tomasz Sowa</td></tr>
|
<tr><td>Author:</td><td>Tomasz Sowa</td></tr>
|
||||||
<tr><td>Contact:</td><td>t.sowa@ttmath.org</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>Licence:</td><td>BSD (open source)</td></tr>
|
||||||
<tr><td>Interface:</td><td>English, Polish, Spanish, Danish, Chinese, Russian</td></tr>
|
<tr><td>Interface:</td><td>English, Polish, Spanish, Danish, Chinese, Russian, Swedish, Italian, German</td></tr>
|
||||||
<tr><td>Project page:</td><td><a href="http://ttcalc.sourceforge.net/">http://ttcalc.sourceforge.net/</a></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>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>
|
<tr><td>Operating systems:</td><td>Microsoft Windows 9x/Me/NT/2000/XP/Vista/7</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
<tr><td>Operator</td><td>Description</td><td>Sample</td></tr>
|
<tr><td>Operator</td><td>Description</td><td>Sample</td></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tr><td>( )</td><td>parentheses for grouping an expression</td><td>(1+3)*4</td></tr>
|
<tr><td>( )</td><td>parentheses for grouping an expression</td><td>(1+3)*4</td></tr>
|
||||||
<tr><td>- + # &</td><td>unary minus and plus, and operators for changing the base (radix)</td><td>-10</td></tr>
|
<tr><td>- + # &</td><td>unary minus and plus, and operators for changing the base (radix)</td><td>-10<br>&1111 (bin)<br>#ff (hex)</td></tr>
|
||||||
|
<tr><td>%</td><td>percentage from a previous value</td><td>100-30%</td></tr>
|
||||||
<tr><td>^</td><td>powering</td><td>3^2</td></tr>
|
<tr><td>^</td><td>powering</td><td>3^2</td></tr>
|
||||||
<tr><td>* /</td><td>multiplication and division</td><td>10*20</td></tr>
|
<tr><td>* /</td><td>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>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>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
<param name="Keyword" value="sqrt">
|
<param name="Keyword" value="sqrt">
|
||||||
<param name="Keyword" value="root">
|
<param name="Keyword" value="root">
|
||||||
<param name="Keyword" value="factorial">
|
<param name="Keyword" value="factorial">
|
||||||
|
<param name="Keyword" value="gamma">
|
||||||
<param name="Keyword" value="abs">
|
<param name="Keyword" value="abs">
|
||||||
<param name="Keyword" value="sgn">
|
<param name="Keyword" value="sgn">
|
||||||
<param name="Keyword" value="mod">
|
<param name="Keyword" value="mod">
|
||||||
|
@ -40,9 +41,12 @@ root(8;3)=2<br>
|
||||||
root(-8;3)=-2
|
root(-8;3)=-2
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>factorial(x)</dt>
|
<dt>factorial(n)</dt>
|
||||||
<dd>The factorial function<br>factorial(6)=1*2*3*4*5*6=720</dd>
|
<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>
|
<dt>abs(x)</dt>
|
||||||
<dd>The absolute value of x<br>abs(-10)=10</dd>
|
<dd>The absolute value of x<br>abs(-10)=10</dd>
|
||||||
|
|
||||||
|
@ -58,13 +62,13 @@ sgn(5)=1</dd>
|
||||||
|
|
||||||
|
|
||||||
<dt>max(x1; x2; ...)</dt>
|
<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
|
<dd>This functions takes any number of arguments. It returns the max value of them. If there are not any arguments
|
||||||
the function returns the max value which can be held in this precision.<br>
|
the function returns the max value which can be held in this precision.<br>
|
||||||
max(2;5;8;3)=8<br>
|
max(2;5;8;3)=8<br>
|
||||||
max()=6.97846825730330952352039893e+646457021 (assuming the small precision is selected)</dd>
|
max()=6.97846825730330952352039893e+646457021 (assuming the small precision is selected)</dd>
|
||||||
|
|
||||||
<dt>min(x1; x2; ...)</dt>
|
<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
|
<dd>This functions takes any number of arguments. It returns the min value of them. If there are not any arguments
|
||||||
the function returns the min value which can be held in this precision.<br>
|
the function returns the min value which can be held in this precision.<br>
|
||||||
min(45;-23;18;19)=-23<br>
|
min(45;-23;18;19)=-23<br>
|
||||||
min()=-6.97846825730330952352039893e+646457021 (assuming the small precision is selected)
|
min()=-6.97846825730330952352039893e+646457021 (assuming the small precision is selected)
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
<param name="Keyword" value="round">
|
<param name="Keyword" value="round">
|
||||||
<param name="Keyword" value="ceil">
|
<param name="Keyword" value="ceil">
|
||||||
<param name="Keyword" value="floor">
|
<param name="Keyword" value="floor">
|
||||||
|
<param name="Keyword" value="frac">
|
||||||
</object>
|
</object>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -57,6 +58,11 @@ floor(2)=2<br>
|
||||||
floor(-4.1)=-5<br>
|
floor(-4.1)=-5<br>
|
||||||
floor(-4.8)=-5</dd>
|
floor(-4.8)=-5</dd>
|
||||||
|
|
||||||
|
<dt>frac(x)</dt>
|
||||||
|
<dd>This function returns a value without the integer part - only fraction remains<br>
|
||||||
|
frac(45.789)=0.789<br>
|
||||||
|
frac(-2.267)=-0.267<br>
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
<param name="Keyword" value="#">
|
<param name="Keyword" value="#">
|
||||||
<param name="Keyword" value="&">
|
<param name="Keyword" value="&">
|
||||||
<param name="Keyword" value="global semicolon">
|
<param name="Keyword" value="global semicolon">
|
||||||
<param name="Keyword" value="CTRL+C">
|
|
||||||
<param name="Keyword" value="CTRL+V">
|
|
||||||
</object>
|
</object>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -35,18 +33,7 @@ then 'input' mode on the 'display' tab is ignored.
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
You can calculate more than one formula at the same time. To achive this use a semicolon
|
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'.
|
in the global space, for example type '2+4 ; 5*10' and the result will be '6 ; 50'.
|
||||||
</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>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -3,16 +3,14 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>TTCalc - numbers, standard operators and built-in variables</title>
|
<title>TTCalc - standard operators and built-in variables</title>
|
||||||
<link rel="stylesheet" href="styles.css" type="text/css">
|
<link rel="stylesheet" href="styles.css" type="text/css">
|
||||||
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
|
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
|
||||||
<param name="Keyword" value="numbers">
|
|
||||||
<param name="Keyword" value="comma">
|
|
||||||
<param name="Keyword" value="dot">
|
|
||||||
<param name="Keyword" value="standard operators">
|
<param name="Keyword" value="standard operators">
|
||||||
<param name="Keyword" value="builtin variables">
|
<param name="Keyword" value="builtin variables">
|
||||||
<param name="Keyword" value="e">
|
<param name="Keyword" value="e">
|
||||||
<param name="Keyword" value="pi">
|
<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="/">
|
||||||
|
@ -25,39 +23,34 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>Numbers</h1>
|
|
||||||
|
|
||||||
<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>
|
<h1>Standard operators</h1>
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>%</dt>
|
||||||
|
<dd>Percentage from a previous value: 1000-30% = 700</dd>
|
||||||
|
|
||||||
<dt>^</dt>
|
<dt>^</dt>
|
||||||
<dd>Powering, e.g.: 2^3=8</dd>
|
<dd>Powering: 2^3 = 8</dd>
|
||||||
|
|
||||||
<dt>*</dt>
|
<dt>*</dt>
|
||||||
<dd>Multiplication, e.g.: 2*3=6</dd>
|
<dd>Multiplication: 2*3 = 6</dd>
|
||||||
|
|
||||||
<dt>/</dt>
|
<dt>/</dt>
|
||||||
<dd>Division, e.g.: 2/3 = 0.6666...</dd>
|
<dd>Division: 2/3 = 0.6666...</dd>
|
||||||
|
|
||||||
<dt>+</dt>
|
<dt>+</dt>
|
||||||
<dd>Addition, e.g.: 2+3=5<br>
|
<dd>Addition: 2+3 = 5<br>
|
||||||
Unary plus, e.g.: +2</dd>
|
Unary plus: +2</dd>
|
||||||
|
|
||||||
<dt>-</dt>
|
<dt>-</dt>
|
||||||
<dd>Subtraction, e.g.: 2-3=-1<br>
|
<dd>Subtraction: 2-3 = -1<br>
|
||||||
Unary minus, e.g.: -2</dd>
|
Unary minus: -2</dd>
|
||||||
|
|
||||||
<dt>#</dt>
|
<dt>#</dt>
|
||||||
<dd>Operator for changing the base (radix) to 16 (hex), e.g.: #ff=255</dd>
|
<dd>Operator for changing the base (radix) to 16 (hex): #ff = 255</dd>
|
||||||
|
|
||||||
<dt>&</dt>
|
<dt>&</dt>
|
||||||
<dd>Operator for changing the base (radix) to 2 (bin), e.g.: -&110=-6</dd>
|
<dd>Operator for changing the base (radix) to 2 (bin): -&110 = -6</dd>
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,268 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
a=""
|
||||||
|
b=""
|
||||||
|
c=""
|
||||||
|
p=""
|
||||||
|
d=""
|
||||||
|
|
||||||
|
# reading until not empty
|
||||||
|
|
||||||
|
while [ -z $a ]
|
||||||
|
do
|
||||||
|
echo -n "Major: " ; read a
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
while [ -z $b ]
|
||||||
|
do
|
||||||
|
echo -n "Minor: " ; read b;
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
while [ -z $c ]
|
||||||
|
do
|
||||||
|
echo -n "Revision: " ; read c;
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
while [ -z $p ]
|
||||||
|
do
|
||||||
|
echo -n "Prerelease? (y/n): " ; read p;
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
while [ -z $d ]
|
||||||
|
do
|
||||||
|
echo -n "Add date? (y/n): " ; read d;
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
dir=$a.$b.$c
|
||||||
|
datestr=""
|
||||||
|
|
||||||
|
|
||||||
|
if [ $p = "y" -o $p = "Y" ]
|
||||||
|
then
|
||||||
|
dir=$dir.prerelease
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ $d = "y" -o $d = "Y" ]
|
||||||
|
then
|
||||||
|
datestr="("`/bin/date "+%G.%m.%d"`")";
|
||||||
|
dir=$dir.$datestr
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ -d $dir ]
|
||||||
|
then
|
||||||
|
echo "Directory $dir exists! (exiting)";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir $dir
|
||||||
|
|
||||||
|
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo "compiling normal version"
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
|
||||||
|
cd src
|
||||||
|
make clean
|
||||||
|
make
|
||||||
|
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo "creating help"
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
|
||||||
|
make help
|
||||||
|
|
||||||
|
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo "creating install program (setup)"
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
|
||||||
|
make setup
|
||||||
|
|
||||||
|
|
||||||
|
cd ../$dir
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo "making binary package"
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
|
||||||
|
n="ttcalc-$a.$b.$c";
|
||||||
|
|
||||||
|
if [ $p = "y" -o $p = "Y" ]
|
||||||
|
then
|
||||||
|
n="$n.prerelease"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $d = "y" -o $d = "Y" ]
|
||||||
|
then
|
||||||
|
ntar="$n-bin.$datestr.zip";
|
||||||
|
else
|
||||||
|
ntar="$n-bin.zip";
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir $n
|
||||||
|
cp ../help/ttcalc.chm $n
|
||||||
|
cp ../src/ttcalc.exe $n
|
||||||
|
cp ../COPYRIGHT $n
|
||||||
|
cp ../README $n
|
||||||
|
cp ../CHANGELOG $n
|
||||||
|
#tar -zcf $ntar $n
|
||||||
|
zip -r -9 $ntar $n
|
||||||
|
rm -r $n
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo "copying the setup program"
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
|
||||||
|
n="ttcalc-$a.$b.$c"
|
||||||
|
|
||||||
|
if [ $p = "y" -o $p = "Y" ]
|
||||||
|
then
|
||||||
|
n="$n.prerelease"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $d = "y" -o $d = "Y" ]
|
||||||
|
then
|
||||||
|
cp ../setup/ttcalc-setup.exe ./$n-setup.$datestr.exe
|
||||||
|
else
|
||||||
|
cp ../setup/ttcalc-setup.exe ./$n-setup.exe
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo "compiling portable version"
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
|
||||||
|
# preserve ttcalc.chm because would be erased by 'make clean'
|
||||||
|
cp ../help/ttcalc.chm ./
|
||||||
|
|
||||||
|
cd ../src/
|
||||||
|
make clean
|
||||||
|
make -f Makefileportable
|
||||||
|
|
||||||
|
|
||||||
|
cd ../$dir
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo "making portable binary package"
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
|
||||||
|
n="ttcalc-portable-$a.$b.$c";
|
||||||
|
|
||||||
|
if [ $p = "y" -o $p = "Y" ]
|
||||||
|
then
|
||||||
|
n="$n.prerelease"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $d = "y" -o $d = "Y" ]
|
||||||
|
then
|
||||||
|
ntar="$n-bin.$datestr.zip";
|
||||||
|
else
|
||||||
|
ntar="$n-bin.zip";
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir $n
|
||||||
|
cp ../src/ttcalcp.exe $n
|
||||||
|
$n/ttcalcp.exe createconfig
|
||||||
|
mv ttcalc.ini $n
|
||||||
|
mv ttcalc.chm $n
|
||||||
|
cp ../COPYRIGHT $n
|
||||||
|
cp ../README $n
|
||||||
|
cp ../CHANGELOG $n
|
||||||
|
#tar -zcf $ntar $n
|
||||||
|
zip -r -9 $ntar $n
|
||||||
|
rm -r $n
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo "creating source package"
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
|
||||||
|
|
||||||
|
n="ttcalc-$a.$b.$c";
|
||||||
|
|
||||||
|
|
||||||
|
if [ $p = "y" -o $p = "Y" ]
|
||||||
|
then
|
||||||
|
n="$n.prerelease"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ $d = "y" -o $d = "Y" ]
|
||||||
|
then
|
||||||
|
ntar="$n-src.$datestr.zip";
|
||||||
|
else
|
||||||
|
ntar="$n-src.zip";
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
mkdir $n
|
||||||
|
mkdir $n/ttmath
|
||||||
|
mkdir $n/ttcalc
|
||||||
|
|
||||||
|
mkdir $n/ttmath/ttmath
|
||||||
|
mkdir $n/ttmath/samples
|
||||||
|
|
||||||
|
mkdir $n/ttcalc/help
|
||||||
|
mkdir $n/ttcalc/res
|
||||||
|
mkdir $n/ttcalc/setup
|
||||||
|
mkdir $n/ttcalc/src
|
||||||
|
|
||||||
|
cp ../../ttmath/ttmath/* $n/ttmath/ttmath
|
||||||
|
cp ../../ttmath/samples/* $n/ttmath/samples
|
||||||
|
cp ../../ttmath/COPYRIGHT $n/ttmath
|
||||||
|
cp ../../ttmath/README $n/ttmath
|
||||||
|
cp ../../ttmath/CHANGELOG $n/ttmath
|
||||||
|
|
||||||
|
cd ../src
|
||||||
|
make clean
|
||||||
|
cd ../$dir
|
||||||
|
|
||||||
|
cp ../help/* $n/ttcalc/help
|
||||||
|
cp ../res/* $n/ttcalc/res
|
||||||
|
cp ../setup/* $n/ttcalc/setup
|
||||||
|
cp ../src/* $n/ttcalc/src
|
||||||
|
cp ../COPYRIGHT $n/ttcalc
|
||||||
|
cp ../README $n/ttcalc
|
||||||
|
cp ../CHANGELOG $n/ttcalc
|
||||||
|
|
||||||
|
#tar -zcf $ntar $n
|
||||||
|
zip -r -9 $ntar $n
|
||||||
|
rm -r $n
|
||||||
|
|
||||||
|
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo "calculating md5 hashes"
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
|
||||||
|
md5sum * > note.txt.md5
|
||||||
|
echo "MD5 SUMS" > note.txt
|
||||||
|
echo "--------" >> note.txt
|
||||||
|
cat note.txt.md5 >> note.txt
|
||||||
|
|
||||||
|
echo "" >> note.txt
|
||||||
|
echo "" >> note.txt
|
||||||
|
echo "CHANGELOG" >> note.txt
|
||||||
|
echo "---------" >> note.txt
|
||||||
|
cat ../CHANGELOG >> note.txt
|
||||||
|
|
||||||
|
rm note.txt.md5
|
||||||
|
unix2dos note.txt
|
||||||
|
|
||||||
|
echo "done"
|
||||||
|
exit 0
|
Binary file not shown.
Before Width: | Height: | Size: 143 KiB |
Binary file not shown.
After Width: | Height: | Size: 227 KiB |
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2006-2009, Tomasz Sowa
|
Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
; Script generated by the Inno Setup Script Wizard.
|
; innosetup script
|
||||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
|
||||||
|
|
||||||
[Setup]
|
[Setup]
|
||||||
AppName=TTCalc
|
AppName=TTCalc
|
||||||
AppVerName=TTCalc 0.8.6
|
AppVerName=TTCalc 0.9.3
|
||||||
AppVersion=0.8.6
|
AppVersion=0.9.3
|
||||||
AppPublisher=Tomasz Sowa
|
AppPublisher=Tomasz Sowa
|
||||||
AppPublisherURL=http://ttcalc.sourceforge.net
|
AppPublisherURL=http://ttcalc.sourceforge.net
|
||||||
AppSupportURL=http://ttcalc.sourceforge.net
|
AppSupportURL=http://ttcalc.sourceforge.net
|
||||||
|
@ -12,22 +11,26 @@ AppUpdatesURL=http://ttcalc.sourceforge.net
|
||||||
DefaultDirName={pf}\TTCalc
|
DefaultDirName={pf}\TTCalc
|
||||||
DefaultGroupName=TTCalc
|
DefaultGroupName=TTCalc
|
||||||
AllowNoIcons=yes
|
AllowNoIcons=yes
|
||||||
; special COPYRIGHT version (without a new line characters in the clause -- it is better displayed in the setup window)
|
; special COPYRIGHT version (without new line characters in the clause -- it is better displayed in the setup window)
|
||||||
LicenseFile=COPYRIGHT
|
LicenseFile=COPYRIGHT
|
||||||
OutputDir=..\setup
|
OutputDir=..\setup
|
||||||
OutputBaseFilename=ttcalc-setup
|
OutputBaseFilename=ttcalc-setup
|
||||||
Compression=lzma
|
Compression=lzma
|
||||||
SolidCompression=yes
|
SolidCompression=yes
|
||||||
ShowUndisplayableLanguages=yes
|
ShowUndisplayableLanguages=yes
|
||||||
PrivilegesRequired=none
|
PrivilegesRequired=admin
|
||||||
|
UsePreviousAppDir=yes
|
||||||
|
|
||||||
[Languages]
|
[Languages]
|
||||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||||
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
|
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
|
||||||
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
|
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
|
||||||
Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
|
Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
|
||||||
Name: "chinese"; MessagesFile: "compiler:Languages\ChineseSimp-12-5.1.11.isl"
|
Name: "chinese"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
|
||||||
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
|
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
|
||||||
|
Name: "swedish"; MessagesFile: "compiler:Languages\Swedish.isl"
|
||||||
|
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
|
||||||
|
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
|
||||||
|
|
||||||
[InstallDelete]
|
[InstallDelete]
|
||||||
; prior to 0.8.3 we were using mingwm10.dll (now it is not needed and will be deleted if exists)
|
; prior to 0.8.3 we were using mingwm10.dll (now it is not needed and will be deleted if exists)
|
||||||
|
@ -38,16 +41,22 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{
|
||||||
|
|
||||||
[Files]
|
[Files]
|
||||||
Source: "..\src\ttcalc.exe"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "..\src\ttcalc.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "..\help\ttcalc.chm"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "..\help\ttcalc.chm"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "..\COPYRIGHT"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "..\COPYRIGHT"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "..\CHANGELOG"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "..\CHANGELOG"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "..\README"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "..\README"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
; now we do not use *.ini file in the installer
|
; now we do not use *.ini file in the installer
|
||||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
|
||||||
|
[Dirs]
|
||||||
|
Name: "{userappdata}/TTCalc" ; Flags: uninsneveruninstall
|
||||||
|
|
||||||
|
[INI]
|
||||||
|
Filename: "{userappdata}/TTCalc/ttcalc.ini"; Section: "GLOBAL"; Key: "language.setup"; String: "{language}"
|
||||||
|
|
||||||
|
|
||||||
[Icons]
|
[Icons]
|
||||||
Name: "{group}\TTCalc"; Filename: "{app}\ttcalc.exe"; WorkingDir: "{app}"
|
Name: "{group}\TTCalc"; Filename: "{app}\ttcalc.exe"; WorkingDir: "{app}"
|
||||||
Name: "{group}\Help"; Filename: "{app}\ttcalc.chm"; WorkingDir: "{app}"
|
Name: "{group}\Help"; Filename: "{app}\ttcalc.chm"; WorkingDir: "{app}"
|
||||||
Name: "{group}\{cm:UninstallProgram,TTCalc}"; Filename: "{uninstallexe}"
|
Name: "{group}\{cm:UninstallProgram,TTCalc}"; Filename: "{uninstallexe}"
|
||||||
Name: "{commondesktop}\TTCalc"; Filename: "{app}\ttcalc.exe"; WorkingDir: "{app}"; Tasks: desktopicon
|
Name: "{commondesktop}\TTCalc"; Filename: "{app}\ttcalc.exe"; WorkingDir: "{app}"; Tasks: desktopicon
|
||||||
|
|
||||||
|
|
35
src/Makefile
35
src/Makefile
|
@ -1,6 +1,9 @@
|
||||||
|
include Makefile.o.dep
|
||||||
|
include Makefile.help.dep
|
||||||
|
|
||||||
CC = g++
|
CC = g++
|
||||||
#CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../ttmath -DTTCALC_CONVERT
|
#CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../ttmath -DTTCALC_CONVERT
|
||||||
CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../ttmath
|
CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../ttmath -DTTMATH_DONT_USE_WCHAR
|
||||||
name = ttcalc.exe
|
name = ttcalc.exe
|
||||||
|
|
||||||
# the name of the help is also set in the html help workshop project file
|
# the name of the help is also set in the html help workshop project file
|
||||||
|
@ -14,11 +17,15 @@ setupname = ttcalc-setup.exe
|
||||||
all: ttcalc
|
all: ttcalc
|
||||||
|
|
||||||
|
|
||||||
include Makefile.dep
|
%.o: %.cpp
|
||||||
|
$(CC) -c $(CFLAGS) $<
|
||||||
|
|
||||||
|
|
||||||
ttcalc: $(o)
|
ttcalc: $(name)
|
||||||
$(CC) -o $(name) $(CFLAGS) $(o) -lcomctl32
|
|
||||||
|
|
||||||
|
$(name): $(o)
|
||||||
|
$(CC) -o $(name) $(CFLAGS) $(o) -lcomctl32 -lwininet
|
||||||
|
|
||||||
|
|
||||||
resource.o: resource.rc
|
resource.o: resource.rc
|
||||||
|
@ -26,18 +33,34 @@ resource.o: resource.rc
|
||||||
windres resource.rc resource.o
|
windres resource.rc resource.o
|
||||||
|
|
||||||
|
|
||||||
help: $(helpdep)
|
help: ../help/$(helpname)
|
||||||
|
|
||||||
|
|
||||||
|
../help/$(helpname): $(helpsrc)
|
||||||
Makefile.help.sh
|
Makefile.help.sh
|
||||||
|
|
||||||
|
|
||||||
|
setup: ../setup/$(setupname)
|
||||||
|
|
||||||
setup: $(setupdep)
|
|
||||||
|
../setup/$(setupname): $(name) ../help/$(helpname) ../setup/innosetup.iss ../setup/COPYRIGHT ../COPYRIGHT ../CHANGELOG ../README
|
||||||
iscc ../setup/innosetup.iss
|
iscc ../setup/innosetup.iss
|
||||||
|
|
||||||
|
|
||||||
|
depend:
|
||||||
|
makedepend -Y. -I../../ttmath -f- *.cpp | sed "s/[\\]/\//g" > Makefile.cpp.dep
|
||||||
|
echo -n "o = resource.o " > Makefile.o.dep
|
||||||
|
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||||
|
echo -n "helpsrc = " > Makefile.help.dep
|
||||||
|
ls -1 ../help/*.html ../help/*.css ../help/*.hhp ../help/*.hhk ../help/*.hhc | xargs -I foo echo -n foo " " >> Makefile.help.dep
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
rm -f $(name)
|
rm -f $(name)
|
||||||
rm -f ttcalcp.exe
|
rm -f ttcalcp.exe
|
||||||
rm -f ../help/$(helpname)
|
rm -f ../help/$(helpname)
|
||||||
rm -f ../setup/$(setupname)
|
rm -f ../setup/$(setupname)
|
||||||
|
|
||||||
|
|
||||||
|
include Makefile.cpp.dep
|
||||||
|
|
|
@ -0,0 +1,176 @@
|
||||||
|
# DO NOT DELETE
|
||||||
|
|
||||||
|
calculation.o: compileconfig.h parsermanager.h resource.h programresources.h
|
||||||
|
calculation.o: iniparser.h languages.h bigtypes.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmath.h ../../ttmath/ttmath/ttmathbig.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmathint.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmathuint.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmathtypes.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmathmisc.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmathuint_x86.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmathuint_x86_64.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmathuint_noasm.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmaththreads.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmathparser.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmath.h threadcontroller.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmathobjects.h stopcalculating.h
|
||||||
|
calculation.o: ../../ttmath/ttmath/ttmathtypes.h convert.h tabs.h messages.h
|
||||||
|
convert.o: convert.h compileconfig.h bigtypes.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
convert.o: ../../ttmath/ttmath/ttmathbig.h ../../ttmath/ttmath/ttmathint.h
|
||||||
|
convert.o: ../../ttmath/ttmath/ttmathuint.h ../../ttmath/ttmath/ttmathtypes.h
|
||||||
|
convert.o: ../../ttmath/ttmath/ttmathmisc.h
|
||||||
|
convert.o: ../../ttmath/ttmath/ttmathuint_x86.h
|
||||||
|
convert.o: ../../ttmath/ttmath/ttmathuint_x86_64.h
|
||||||
|
convert.o: ../../ttmath/ttmath/ttmathuint_noasm.h
|
||||||
|
convert.o: ../../ttmath/ttmath/ttmaththreads.h
|
||||||
|
convert.o: ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
convert.o: ../../ttmath/ttmath/ttmathparser.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
download.o: compileconfig.h download.h
|
||||||
|
functions.o: compileconfig.h tabs.h resource.h messages.h
|
||||||
|
functions.o: ../../ttmath/ttmath/ttmathtypes.h programresources.h iniparser.h
|
||||||
|
functions.o: languages.h bigtypes.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
functions.o: ../../ttmath/ttmath/ttmathbig.h ../../ttmath/ttmath/ttmathint.h
|
||||||
|
functions.o: ../../ttmath/ttmath/ttmathuint.h
|
||||||
|
functions.o: ../../ttmath/ttmath/ttmathtypes.h
|
||||||
|
functions.o: ../../ttmath/ttmath/ttmathmisc.h
|
||||||
|
functions.o: ../../ttmath/ttmath/ttmathuint_x86.h
|
||||||
|
functions.o: ../../ttmath/ttmath/ttmathuint_x86_64.h
|
||||||
|
functions.o: ../../ttmath/ttmath/ttmathuint_noasm.h
|
||||||
|
functions.o: ../../ttmath/ttmath/ttmaththreads.h
|
||||||
|
functions.o: ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
functions.o: ../../ttmath/ttmath/ttmathparser.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
functions.o: threadcontroller.h ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
functions.o: stopcalculating.h convert.h
|
||||||
|
iniparser.o: compileconfig.h iniparser.h
|
||||||
|
languages.o: compileconfig.h languages.h bigtypes.h
|
||||||
|
languages.o: ../../ttmath/ttmath/ttmath.h ../../ttmath/ttmath/ttmathbig.h
|
||||||
|
languages.o: ../../ttmath/ttmath/ttmathint.h ../../ttmath/ttmath/ttmathuint.h
|
||||||
|
languages.o: ../../ttmath/ttmath/ttmathtypes.h
|
||||||
|
languages.o: ../../ttmath/ttmath/ttmathmisc.h
|
||||||
|
languages.o: ../../ttmath/ttmath/ttmathuint_x86.h
|
||||||
|
languages.o: ../../ttmath/ttmath/ttmathuint_x86_64.h
|
||||||
|
languages.o: ../../ttmath/ttmath/ttmathuint_noasm.h
|
||||||
|
languages.o: ../../ttmath/ttmath/ttmaththreads.h
|
||||||
|
languages.o: ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
languages.o: ../../ttmath/ttmath/ttmathparser.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
mainwindow.o: compileconfig.h winmain.h programresources.h iniparser.h
|
||||||
|
mainwindow.o: languages.h bigtypes.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
mainwindow.o: ../../ttmath/ttmath/ttmathbig.h ../../ttmath/ttmath/ttmathint.h
|
||||||
|
mainwindow.o: ../../ttmath/ttmath/ttmathuint.h
|
||||||
|
mainwindow.o: ../../ttmath/ttmath/ttmathtypes.h
|
||||||
|
mainwindow.o: ../../ttmath/ttmath/ttmathmisc.h
|
||||||
|
mainwindow.o: ../../ttmath/ttmath/ttmathuint_x86.h
|
||||||
|
mainwindow.o: ../../ttmath/ttmath/ttmathuint_x86_64.h
|
||||||
|
mainwindow.o: ../../ttmath/ttmath/ttmathuint_noasm.h
|
||||||
|
mainwindow.o: ../../ttmath/ttmath/ttmaththreads.h
|
||||||
|
mainwindow.o: ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
mainwindow.o: ../../ttmath/ttmath/ttmathparser.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
mainwindow.o: threadcontroller.h ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
mainwindow.o: stopcalculating.h ../../ttmath/ttmath/ttmathtypes.h convert.h
|
||||||
|
mainwindow.o: resource.h messages.h tabs.h pad.h update.h download.h misc.h
|
||||||
|
pad.o: ../../ttmath/ttmath/ttmath.h ../../ttmath/ttmath/ttmathbig.h
|
||||||
|
pad.o: ../../ttmath/ttmath/ttmathint.h ../../ttmath/ttmath/ttmathuint.h
|
||||||
|
pad.o: ../../ttmath/ttmath/ttmathtypes.h ../../ttmath/ttmath/ttmathmisc.h
|
||||||
|
pad.o: ../../ttmath/ttmath/ttmathuint_x86.h
|
||||||
|
pad.o: ../../ttmath/ttmath/ttmathuint_x86_64.h
|
||||||
|
pad.o: ../../ttmath/ttmath/ttmathuint_noasm.h
|
||||||
|
pad.o: ../../ttmath/ttmath/ttmaththreads.h
|
||||||
|
pad.o: ../../ttmath/ttmath/ttmathobjects.h ../../ttmath/ttmath/ttmathparser.h
|
||||||
|
pad.o: ../../ttmath/ttmath/ttmath.h programresources.h compileconfig.h
|
||||||
|
pad.o: iniparser.h languages.h bigtypes.h threadcontroller.h
|
||||||
|
pad.o: ../../ttmath/ttmath/ttmathobjects.h stopcalculating.h
|
||||||
|
pad.o: ../../ttmath/ttmath/ttmathtypes.h convert.h resource.h messages.h
|
||||||
|
pad.o: pad.h
|
||||||
|
parsermanager.o: compileconfig.h parsermanager.h resource.h
|
||||||
|
parsermanager.o: programresources.h iniparser.h languages.h bigtypes.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmath.h ../../ttmath/ttmath/ttmathbig.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmathint.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmathuint.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmathtypes.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmathmisc.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmathuint_x86.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmathuint_x86_64.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmathuint_noasm.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmaththreads.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmathparser.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmath.h threadcontroller.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmathobjects.h stopcalculating.h
|
||||||
|
parsermanager.o: ../../ttmath/ttmath/ttmathtypes.h convert.h tabs.h
|
||||||
|
parsermanager.o: messages.h
|
||||||
|
programresources.o: compileconfig.h programresources.h iniparser.h
|
||||||
|
programresources.o: languages.h bigtypes.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmathbig.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmathint.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmathuint.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmathtypes.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmathmisc.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmathuint_x86.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmathuint_x86_64.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmathuint_noasm.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmaththreads.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmathparser.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmath.h threadcontroller.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmathobjects.h stopcalculating.h
|
||||||
|
programresources.o: ../../ttmath/ttmath/ttmathtypes.h convert.h
|
||||||
|
tabs.o: compileconfig.h tabs.h resource.h messages.h
|
||||||
|
tabs.o: ../../ttmath/ttmath/ttmathtypes.h programresources.h iniparser.h
|
||||||
|
tabs.o: languages.h bigtypes.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
tabs.o: ../../ttmath/ttmath/ttmathbig.h ../../ttmath/ttmath/ttmathint.h
|
||||||
|
tabs.o: ../../ttmath/ttmath/ttmathuint.h ../../ttmath/ttmath/ttmathtypes.h
|
||||||
|
tabs.o: ../../ttmath/ttmath/ttmathmisc.h ../../ttmath/ttmath/ttmathuint_x86.h
|
||||||
|
tabs.o: ../../ttmath/ttmath/ttmathuint_x86_64.h
|
||||||
|
tabs.o: ../../ttmath/ttmath/ttmathuint_noasm.h
|
||||||
|
tabs.o: ../../ttmath/ttmath/ttmaththreads.h
|
||||||
|
tabs.o: ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
tabs.o: ../../ttmath/ttmath/ttmathparser.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
tabs.o: threadcontroller.h ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
tabs.o: stopcalculating.h convert.h
|
||||||
|
threadcontroller.o: threadcontroller.h ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
threadcontroller.o: stopcalculating.h compileconfig.h
|
||||||
|
threadcontroller.o: ../../ttmath/ttmath/ttmathtypes.h
|
||||||
|
update.o: compileconfig.h update.h download.h programresources.h iniparser.h
|
||||||
|
update.o: languages.h bigtypes.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
update.o: ../../ttmath/ttmath/ttmathbig.h ../../ttmath/ttmath/ttmathint.h
|
||||||
|
update.o: ../../ttmath/ttmath/ttmathuint.h ../../ttmath/ttmath/ttmathtypes.h
|
||||||
|
update.o: ../../ttmath/ttmath/ttmathmisc.h
|
||||||
|
update.o: ../../ttmath/ttmath/ttmathuint_x86.h
|
||||||
|
update.o: ../../ttmath/ttmath/ttmathuint_x86_64.h
|
||||||
|
update.o: ../../ttmath/ttmath/ttmathuint_noasm.h
|
||||||
|
update.o: ../../ttmath/ttmath/ttmaththreads.h
|
||||||
|
update.o: ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
update.o: ../../ttmath/ttmath/ttmathparser.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
update.o: threadcontroller.h ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
update.o: stopcalculating.h ../../ttmath/ttmath/ttmathtypes.h convert.h
|
||||||
|
update.o: messages.h resource.h winmain.h tabs.h pad.h misc.h
|
||||||
|
variables.o: compileconfig.h tabs.h resource.h messages.h
|
||||||
|
variables.o: ../../ttmath/ttmath/ttmathtypes.h programresources.h iniparser.h
|
||||||
|
variables.o: languages.h bigtypes.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
variables.o: ../../ttmath/ttmath/ttmathbig.h ../../ttmath/ttmath/ttmathint.h
|
||||||
|
variables.o: ../../ttmath/ttmath/ttmathuint.h
|
||||||
|
variables.o: ../../ttmath/ttmath/ttmathtypes.h
|
||||||
|
variables.o: ../../ttmath/ttmath/ttmathmisc.h
|
||||||
|
variables.o: ../../ttmath/ttmath/ttmathuint_x86.h
|
||||||
|
variables.o: ../../ttmath/ttmath/ttmathuint_x86_64.h
|
||||||
|
variables.o: ../../ttmath/ttmath/ttmathuint_noasm.h
|
||||||
|
variables.o: ../../ttmath/ttmath/ttmaththreads.h
|
||||||
|
variables.o: ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
variables.o: ../../ttmath/ttmath/ttmathparser.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
variables.o: threadcontroller.h ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
variables.o: stopcalculating.h convert.h
|
||||||
|
winmain.o: compileconfig.h winmain.h programresources.h iniparser.h
|
||||||
|
winmain.o: languages.h bigtypes.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
winmain.o: ../../ttmath/ttmath/ttmathbig.h ../../ttmath/ttmath/ttmathint.h
|
||||||
|
winmain.o: ../../ttmath/ttmath/ttmathuint.h ../../ttmath/ttmath/ttmathtypes.h
|
||||||
|
winmain.o: ../../ttmath/ttmath/ttmathmisc.h
|
||||||
|
winmain.o: ../../ttmath/ttmath/ttmathuint_x86.h
|
||||||
|
winmain.o: ../../ttmath/ttmath/ttmathuint_x86_64.h
|
||||||
|
winmain.o: ../../ttmath/ttmath/ttmathuint_noasm.h
|
||||||
|
winmain.o: ../../ttmath/ttmath/ttmaththreads.h
|
||||||
|
winmain.o: ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
winmain.o: ../../ttmath/ttmath/ttmathparser.h ../../ttmath/ttmath/ttmath.h
|
||||||
|
winmain.o: threadcontroller.h ../../ttmath/ttmath/ttmathobjects.h
|
||||||
|
winmain.o: stopcalculating.h ../../ttmath/ttmath/ttmathtypes.h convert.h
|
||||||
|
winmain.o: resource.h messages.h tabs.h pad.h update.h download.h
|
|
@ -1,45 +0,0 @@
|
||||||
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 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 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
|
|
|
@ -0,0 +1 @@
|
||||||
|
helpsrc = ../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
|
|
@ -0,0 +1 @@
|
||||||
|
o = resource.o calculation.o convert.o download.o functions.o iniparser.o languages.o mainwindow.o misc.o pad.o parsermanager.o programresources.o tabs.o threadcontroller.o update.o variables.o winmain.o
|
|
@ -1,21 +1,31 @@
|
||||||
|
include Makefile.o.dep
|
||||||
|
include Makefile.help.dep
|
||||||
|
|
||||||
|
|
||||||
CC = g++
|
CC = g++
|
||||||
CFLAGS = -Wall -pedantic -s -Os -fno-default-inline -mwindows -I../../ttmath -DTTCALC_PORTABLE
|
CFLAGS = -Wall -pedantic -s -Os -fno-default-inline -mwindows -I../../ttmath -DTTCALC_PORTABLE -DTTMATH_DONT_USE_WCHAR
|
||||||
name = ttcalcp.exe
|
name = ttcalcp.exe
|
||||||
compressor = upx
|
compressor = upx
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
all: ttcalc
|
all: ttcalc
|
||||||
|
|
||||||
include Makefile.dep
|
|
||||||
|
|
||||||
ttcalc: $(o)
|
%.o: %.cpp
|
||||||
$(CC) -o $(name) $(CFLAGS) $(o) -lcomctl32
|
$(CC) -c $(CFLAGS) $<
|
||||||
|
|
||||||
|
|
||||||
|
ttcalc: $(name)
|
||||||
|
|
||||||
|
|
||||||
|
$(name): $(o)
|
||||||
|
$(CC) -o $(name) $(CFLAGS) $(o) -lcomctl32 -lwininet
|
||||||
$(compressor) -7 $(name)
|
$(compressor) -7 $(name)
|
||||||
|
|
||||||
|
|
||||||
resource.o: resource.rc
|
resource.o: resource.rc
|
||||||
windres -DTTCALC_PORTABLE resource.rc resource.o
|
windres -DTTCALC_PORTABLE resource.rc resource.o
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o
|
|
||||||
rm -f $(name)
|
|
||||||
rm -f ../help/$(helpname)
|
|
||||||
|
|
||||||
|
include Makefile.cpp.dep
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -40,9 +40,16 @@
|
||||||
|
|
||||||
#include "compileconfig.h"
|
#include "compileconfig.h"
|
||||||
|
|
||||||
|
|
||||||
//#define TTMATH_RELEASE
|
//#define TTMATH_RELEASE
|
||||||
#include <ttmath/ttmath.h>
|
#include <ttmath/ttmath.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
//"warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)"
|
||||||
|
// (ttmath set it to default)
|
||||||
|
#pragma warning (disable : 4800)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef TTCALC_PORTABLE
|
#ifndef TTCALC_PORTABLE
|
||||||
|
|
||||||
|
@ -53,18 +60,24 @@
|
||||||
ttmath::Big<3,9>
|
ttmath::Big<3,9>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
typedef ttmath::Big<1,3> TTMathBig1;
|
typedef ttmath::Big<1,3> TTMathBig1;
|
||||||
typedef ttmath::Big<2,9> TTMathBig2;
|
typedef ttmath::Big<2,9> TTMathBig2;
|
||||||
typedef ttmath::Big<4,27> TTMathBig3;
|
typedef ttmath::Big<4,27> TTMathBig3;
|
||||||
typedef TTMathBig3 TTMathBigMax;
|
typedef TTMathBig3 TTMathBigMax;
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef ttmath::Big<TTMATH_BITS(32), TTMATH_BITS(96) > TTMathBig1;
|
||||||
|
typedef ttmath::Big<TTMATH_BITS(64), TTMATH_BITS(512) > TTMathBig2;
|
||||||
|
typedef ttmath::Big<TTMATH_BITS(128), TTMATH_BITS(1024)> TTMathBig3;
|
||||||
|
typedef TTMathBig3 TTMathBigMax;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* portable */
|
/* portable */
|
||||||
|
|
||||||
typedef ttmath::Big<1,3> TTMathBig1;
|
typedef ttmath::Big<TTMATH_BITS(32), TTMATH_BITS(96)> TTMathBig1;
|
||||||
typedef TTMathBig1 TTMathBigMax;
|
typedef TTMathBig1 TTMathBigMax;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -54,18 +54,24 @@
|
||||||
if zero that means this is the release version of the program
|
if zero that means this is the release version of the program
|
||||||
*/
|
*/
|
||||||
#define TTCALC_MAJOR_VER 0
|
#define TTCALC_MAJOR_VER 0
|
||||||
#define TTCALC_MINOR_VER 8
|
#define TTCALC_MINOR_VER 9
|
||||||
#define TTCALC_REVISION_VER 6
|
#define TTCALC_REVISION_VER 3
|
||||||
#define TTCALC_PRERELEASE_VER 0
|
#define TTCALC_PRERELEASE_VER 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
this disables a Visual C++ warning about converting int to bool
|
this disables a Visual C++ warning
|
||||||
"warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)"
|
|
||||||
*/
|
*/
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
//"warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)"
|
||||||
#pragma warning (disable : 4800)
|
#pragma warning (disable : 4800)
|
||||||
|
|
||||||
|
// warning C4996: 'sprintf': This function or variable may be unsafe.
|
||||||
|
#pragma warning (disable : 4996)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32_IE
|
#ifndef _WIN32_IE
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -0,0 +1,175 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
|
* and is distributed under the (new) BSD licence.
|
||||||
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 <cstdio>
|
||||||
|
#include "compileconfig.h"
|
||||||
|
#include "download.h"
|
||||||
|
|
||||||
|
|
||||||
|
Download::Download()
|
||||||
|
{
|
||||||
|
buffer_len = 128;
|
||||||
|
progress = 0;
|
||||||
|
|
||||||
|
buffer = new char[buffer_len];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Download::~Download()
|
||||||
|
{
|
||||||
|
if( buffer )
|
||||||
|
delete [] buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Download::SetProgress()
|
||||||
|
{
|
||||||
|
if( !progress )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SendMessage(progress, PBM_SETRANGE32, 0, all_len);
|
||||||
|
SendMessage(progress, PBM_SETPOS, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Download::ChangeProgress(size_t size)
|
||||||
|
{
|
||||||
|
if( !progress )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SendMessage(progress, PBM_SETPOS, size, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Download::ClearProgress()
|
||||||
|
{
|
||||||
|
if( !progress )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SendMessage(progress, PBM_SETPOS, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Download::DownloadLoop(HINTERNET conn)
|
||||||
|
{
|
||||||
|
DWORD read;
|
||||||
|
|
||||||
|
|
||||||
|
while( true )
|
||||||
|
{
|
||||||
|
bool res = InternetReadFile(conn, buffer, buffer_len, &read);
|
||||||
|
|
||||||
|
if( !res )
|
||||||
|
// some problems with downloading
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
if( read > 0 )
|
||||||
|
{
|
||||||
|
down_size += read;
|
||||||
|
ChangeProgress(down_size);
|
||||||
|
|
||||||
|
if( !Read(buffer, read) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// end
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Download::DownloadUrl(const char * url)
|
||||||
|
{
|
||||||
|
bool res = true;
|
||||||
|
char browser[100];
|
||||||
|
|
||||||
|
down_size = 0;
|
||||||
|
sprintf(browser, "TTCalc updater %d.%d.%d%s",
|
||||||
|
TTCALC_MAJOR_VER,
|
||||||
|
TTCALC_MINOR_VER,
|
||||||
|
TTCALC_REVISION_VER,
|
||||||
|
(TTCALC_PRERELEASE_VER>0)? " prerelease" : "");
|
||||||
|
|
||||||
|
|
||||||
|
HINTERNET hint = InternetOpen(browser,INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0);
|
||||||
|
if( !hint )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
HINTERNET conn = InternetOpenUrl(hint, url, 0, 0,
|
||||||
|
INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_UI, 0);
|
||||||
|
|
||||||
|
if( conn )
|
||||||
|
{
|
||||||
|
GetLen(conn);
|
||||||
|
SetProgress();
|
||||||
|
|
||||||
|
if( Init() )
|
||||||
|
{
|
||||||
|
res = DownloadLoop(conn);
|
||||||
|
Close();
|
||||||
|
ClearProgress();
|
||||||
|
}
|
||||||
|
|
||||||
|
InternetCloseHandle(conn);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
InternetCloseHandle(hint);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
|
* and is distributed under the (new) BSD licence.
|
||||||
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 headerfiledownload
|
||||||
|
#define headerfiledownload
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <wininet.h>
|
||||||
|
#include <commctrl.h>
|
||||||
|
|
||||||
|
class Download
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
Download();
|
||||||
|
~Download();
|
||||||
|
|
||||||
|
bool DownloadUrl(const char * url);
|
||||||
|
void AttachProgress(HWND p) { progress = p; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool DownloadLoop(HINTERNET conn);
|
||||||
|
virtual void GetLen(HINTERNET conn) { all_len = 0; }
|
||||||
|
virtual bool Init() { return false; }
|
||||||
|
virtual bool Read(char * buffer, size_t size) { return false; }
|
||||||
|
virtual void Close() {}
|
||||||
|
virtual void SetProgress();
|
||||||
|
virtual void ChangeProgress(size_t size);
|
||||||
|
virtual void ClearProgress();
|
||||||
|
|
||||||
|
char * buffer;
|
||||||
|
size_t buffer_len;
|
||||||
|
size_t all_len;
|
||||||
|
HWND progress;
|
||||||
|
size_t down_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -85,9 +85,14 @@ int i;
|
||||||
SendDlgItemMessage(hWnd,IDC_COMBO_FUNCTION_PARAM,CB_SETCURSEL,parameters,0);
|
SendDlgItemMessage(hWnd,IDC_COMBO_FUNCTION_PARAM,CB_SETCURSEL,parameters,0);
|
||||||
|
|
||||||
if( adding )
|
if( adding )
|
||||||
|
{
|
||||||
SetFocus(GetDlgItem(hWnd,IDC_EDIT_FUNCTION_NAME));
|
SetFocus(GetDlgItem(hWnd,IDC_EDIT_FUNCTION_NAME));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
SetFocus(GetDlgItem(hWnd,IDC_EDIT_FUNCTION_VALUE));
|
SetFocus(GetDlgItem(hWnd,IDC_EDIT_FUNCTION_VALUE));
|
||||||
|
SendDlgItemMessage(hWnd, IDC_EDIT_FUNCTION_VALUE, EM_SETSEL, value.size(), value.size());
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -232,6 +237,8 @@ BOOL WmTabCommand_AddFunction(HWND, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
int id = AddNewItemToFunctionList(list, name, value, parameters);
|
int id = AddNewItemToFunctionList(list, name, value, parameters);
|
||||||
Variables::SelectOnlyOneItem(list,id);
|
Variables::SelectOnlyOneItem(list,id);
|
||||||
|
GetPrgRes()->ReadVariablesFunctionsFromFile();
|
||||||
|
GetPrgRes()->SaveToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -297,7 +304,11 @@ adding = false;
|
||||||
if( code != ttmath::err_ok )
|
if( code != ttmath::err_ok )
|
||||||
ShowError(list, code);
|
ShowError(list, code);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ChangeItemInFunctionList(list, id, old_name, name, value, parameters);
|
ChangeItemInFunctionList(list, id, old_name, name, value, parameters);
|
||||||
|
GetPrgRes()->ReadVariablesFunctionsFromFile();
|
||||||
|
GetPrgRes()->SaveToFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while( code != ttmath::err_ok );
|
while( code != ttmath::err_ok );
|
||||||
|
|
||||||
|
@ -330,6 +341,7 @@ int items = ListView_GetSelectedCount(list);
|
||||||
char * buffer = new char[buffer_size];
|
char * buffer = new char[buffer_size];
|
||||||
bool all_deleted = true;
|
bool all_deleted = true;
|
||||||
|
|
||||||
|
GetPrgRes()->ReadVariablesFunctionsFromFile();
|
||||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||||
|
|
||||||
for( id = ListView_GetItemCount(list)-1 ; id!=-1 ; --id )
|
for( id = ListView_GetItemCount(list)-1 ; id!=-1 ; --id )
|
||||||
|
@ -348,6 +360,7 @@ int items = ListView_GetSelectedCount(list);
|
||||||
|
|
||||||
|
|
||||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||||
|
GetPrgRes()->SaveToFile();
|
||||||
|
|
||||||
delete [] buffer;
|
delete [] buffer;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
1542
src/languages.cpp
1542
src/languages.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -101,8 +101,17 @@ public:
|
||||||
display_rounding,
|
display_rounding,
|
||||||
display_always_scientific,
|
display_always_scientific,
|
||||||
display_not_always_scientific,
|
display_not_always_scientific,
|
||||||
display_decimal_point,
|
|
||||||
display_deg_rad_grad,
|
display_deg_rad_grad,
|
||||||
|
display_grouping,
|
||||||
|
display_grouping_none,
|
||||||
|
display_grouping_space,
|
||||||
|
display_grouping_digits,
|
||||||
|
display_input_decimal_point,
|
||||||
|
display_input_decimal_point_item1,
|
||||||
|
display_output_decimal_point,
|
||||||
|
display_param_sep,
|
||||||
|
display_param_sep_item2,
|
||||||
|
display_param_sep_item3,
|
||||||
convert_type,
|
convert_type,
|
||||||
convert_input,
|
convert_input,
|
||||||
convert_output,
|
convert_output,
|
||||||
|
@ -115,41 +124,88 @@ public:
|
||||||
menu_view_normal_view,
|
menu_view_normal_view,
|
||||||
menu_view_compact_view,
|
menu_view_compact_view,
|
||||||
menu_view_always_on_top,
|
menu_view_always_on_top,
|
||||||
|
menu_view_pad,
|
||||||
menu_view_lang_english,
|
menu_view_lang_english,
|
||||||
menu_view_lang_polish,
|
menu_view_lang_polish,
|
||||||
menu_view_lang_spanish,
|
menu_view_lang_spanish,
|
||||||
menu_view_lang_danish,
|
menu_view_lang_danish,
|
||||||
menu_view_lang_chinese,
|
menu_view_lang_chinese,
|
||||||
menu_view_lang_russian,
|
menu_view_lang_russian,
|
||||||
|
menu_view_lang_swedish,
|
||||||
|
menu_view_lang_italian,
|
||||||
|
menu_view_lang_german,
|
||||||
menu_view_close_program,
|
menu_view_close_program,
|
||||||
menu_edit_undo,
|
menu_edit_undo,
|
||||||
|
menu_edit_cut,
|
||||||
|
menu_edit_copy,
|
||||||
menu_edit_paste,
|
menu_edit_paste,
|
||||||
|
menu_edit_del,
|
||||||
|
menu_edit_paste_formula,
|
||||||
menu_edit_copy_result,
|
menu_edit_copy_result,
|
||||||
|
menu_edit_copy_both,
|
||||||
|
menu_edit_select_all,
|
||||||
|
menu_edit_bracket,
|
||||||
|
menu_edit_swap,
|
||||||
menu_help_help,
|
menu_help_help,
|
||||||
menu_help_project_page,
|
menu_help_project_page,
|
||||||
|
menu_help_check_update,
|
||||||
menu_help_about,
|
menu_help_about,
|
||||||
|
menu_update_available,
|
||||||
cant_init_calculations,
|
cant_init_calculations,
|
||||||
message_box_error_caption,
|
message_box_error_caption,
|
||||||
cant_create_thread,
|
cant_create_thread,
|
||||||
|
cant_create_pad,
|
||||||
cant_create_main_window,
|
cant_create_main_window,
|
||||||
cant_init_common_controls,
|
cant_init_common_controls,
|
||||||
cant_find_help,
|
cant_find_help,
|
||||||
cant_open_project_page,
|
cant_open_project_page,
|
||||||
|
update_title,
|
||||||
|
update_button_next,
|
||||||
|
update_button_finish,
|
||||||
|
update_button_cancel,
|
||||||
|
update_check_at_startup,
|
||||||
|
update_check_for_info,
|
||||||
|
update_is_new_version,
|
||||||
|
update_no_new_version1,
|
||||||
|
update_no_new_version2,
|
||||||
|
update_download_from,
|
||||||
|
update_downloaded_info1,
|
||||||
|
update_downloaded_info2,
|
||||||
|
update_download_error,
|
||||||
about_text,
|
about_text,
|
||||||
about_text_portable_version,
|
about_text_portable_version,
|
||||||
about_text_exe_packer,
|
about_text_exe_packer,
|
||||||
about_box_title,
|
about_box_title,
|
||||||
about_box_button_close,
|
about_box_button_close,
|
||||||
display_group_scientific,
|
display_as_scientific,
|
||||||
|
pad_title,
|
||||||
|
pad_menu_file,
|
||||||
|
pad_menu_edit,
|
||||||
|
pad_menu_file_new,
|
||||||
|
pad_menu_file_open,
|
||||||
|
pad_menu_file_saveas,
|
||||||
|
pad_menu_file_close,
|
||||||
|
pad_menu_edit_undo,
|
||||||
|
pad_menu_edit_cut,
|
||||||
|
pad_menu_edit_copy,
|
||||||
|
pad_menu_edit_paste,
|
||||||
|
pad_menu_edit_del,
|
||||||
|
pad_menu_edit_select_all,
|
||||||
|
cannot_open_file,
|
||||||
|
cannot_save_file,
|
||||||
|
file_too_long,
|
||||||
|
other_error,
|
||||||
unknown_error
|
unknown_error
|
||||||
};
|
};
|
||||||
|
|
||||||
// the first item must be with zero index
|
// the first item must be with zero index
|
||||||
// and next items must be about one greater (0,1,2,3..)
|
// and next items must be about one greater (0,1,2,3..)
|
||||||
// (after conversion to 'int' we pass it into the std::vector)
|
// (after conversion to 'int' we pass it into the std::vector)
|
||||||
|
// lastnotexisting should be the last item
|
||||||
|
// make sure SelectCurrentLanguage(const std::string & lang) is able to recognize a language
|
||||||
enum Country
|
enum Country
|
||||||
{
|
{
|
||||||
en = 0, pl, sp, da, chn, ru
|
en = 0, pl, sp, da, chn, ru, swe, it, ger, lastnotexisting
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,9 +240,18 @@ public:
|
||||||
|
|
||||||
void SetCurrentLanguage(Country c)
|
void SetCurrentLanguage(Country c)
|
||||||
{
|
{
|
||||||
|
// we are reading a language from *.ini file
|
||||||
|
// and it is stored as a number
|
||||||
|
|
||||||
|
if( int(c) < 0 || int(c) >= (int)Languages::lastnotexisting )
|
||||||
|
c = en;
|
||||||
|
|
||||||
current_country = c;
|
current_country = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SelectCurrentLanguage(const std::string & lang);
|
||||||
|
|
||||||
|
|
||||||
Country GetCurrentLanguage()
|
Country GetCurrentLanguage()
|
||||||
{
|
{
|
||||||
return current_country;
|
return current_country;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -35,9 +35,13 @@
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include "compileconfig.h"
|
#include "compileconfig.h"
|
||||||
#include "winmain.h"
|
#include "winmain.h"
|
||||||
|
#include "update.h"
|
||||||
|
#include "pad.h"
|
||||||
|
#include "bigtypes.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +50,24 @@ namespace MainWindowFunctions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returning true if hWnd is a handle of an edit control
|
||||||
|
*/
|
||||||
|
bool IsEditControl(HWND hWnd)
|
||||||
|
{
|
||||||
|
char buffer[30];
|
||||||
|
|
||||||
|
GetClassName( hWnd, buffer, sizeof(buffer)/sizeof(char) );
|
||||||
|
|
||||||
|
if( EqualStrings(buffer, "edit") )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Loop through all the controls and remove the
|
Loop through all the controls and remove the
|
||||||
dark border that the previous default push
|
dark border that the previous default push
|
||||||
|
@ -238,103 +260,68 @@ 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()
|
bool CopyResult()
|
||||||
{
|
{
|
||||||
char buffer[30];
|
HWND main_window = GetPrgRes()->GetMainWindow();
|
||||||
DWORD sel_start, sel_end;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
if the focus is not on an edit window
|
||||||
|
or it is on an edit but the edit has no selection
|
||||||
|
then we're copying the result
|
||||||
|
|
||||||
|
this is used when Ctrl+C is pressed
|
||||||
|
*/
|
||||||
|
bool CopySpecial()
|
||||||
|
{
|
||||||
HWND focus = GetFocus();
|
HWND focus = GetFocus();
|
||||||
bool copy = true;
|
|
||||||
|
|
||||||
GetClassName( focus, buffer, sizeof(buffer)/sizeof(char) );
|
if( IsEditControl(focus) )
|
||||||
|
|
||||||
if( EqualStrings(buffer, "edit") )
|
|
||||||
{
|
{
|
||||||
|
DWORD sel_start, sel_end;
|
||||||
SendMessage(focus, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
|
SendMessage(focus, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
|
||||||
|
|
||||||
if( sel_start != sel_end )
|
if( sel_start != sel_end ) // something is selected
|
||||||
// the control has a selection
|
return false;
|
||||||
copy = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CopyResult();
|
||||||
|
|
||||||
if( copy )
|
return true;
|
||||||
{
|
|
||||||
// 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
|
this function is called when CTRL+V has been pressed
|
||||||
|
this is not Paste but PasteFormula (everything is copied to the input edit, even
|
||||||
if a focus is not on an edit control (or it can be on an edit
|
if the focus is on an another 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()
|
bool PasteFormula()
|
||||||
{
|
{
|
||||||
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 main_window = GetPrgRes()->GetMainWindow();
|
||||||
HWND input_edit = GetDlgItem(main_window, IDC_INPUT_EDIT);
|
HWND input_edit = GetDlgItem(main_window, IDC_INPUT_EDIT);
|
||||||
|
|
||||||
|
@ -379,6 +366,8 @@ HMENU menu = GetMenu(hWnd);
|
||||||
if( !menu )
|
if( !menu )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Languages * pl = GetPrgRes()->GetLanguages();
|
||||||
|
|
||||||
MENUITEMINFO mi;
|
MENUITEMINFO mi;
|
||||||
mi.cbSize = sizeof(mi);
|
mi.cbSize = sizeof(mi);
|
||||||
mi.fMask = MIIM_TYPE;
|
mi.fMask = MIIM_TYPE;
|
||||||
|
@ -386,34 +375,55 @@ HMENU menu = GetMenu(hWnd);
|
||||||
|
|
||||||
// on popup menus we're using indexes because they don't want to work correctly
|
// on popup menus we're using indexes because they don't want to work correctly
|
||||||
// with the identifiers
|
// with the identifiers
|
||||||
mi.dwTypeData = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::menu_view) );
|
mi.dwTypeData = const_cast<char*>( pl->GuiMessage(Languages::menu_view) );
|
||||||
SetMenuItemInfo(menu, IDM_VIEW_INDEX, true, &mi);
|
SetMenuItemInfo(menu, IDM_VIEW_INDEX, true, &mi);
|
||||||
|
|
||||||
mi.dwTypeData = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::menu_edit) );
|
mi.dwTypeData = const_cast<char*>( pl->GuiMessage(Languages::menu_edit) );
|
||||||
SetMenuItemInfo(menu, IDM_EDIT_INDEX, true, &mi);
|
SetMenuItemInfo(menu, IDM_EDIT_INDEX, true, &mi);
|
||||||
|
|
||||||
mi.dwTypeData = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::menu_help) );
|
mi.dwTypeData = const_cast<char*>( pl->GuiMessage(Languages::menu_help) );
|
||||||
SetMenuItemInfo(menu, IDM_HELP_INDEX, true, &mi);
|
SetMenuItemInfo(menu, IDM_HELP_INDEX, true, &mi);
|
||||||
|
|
||||||
mi.dwTypeData = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::menu_language) );
|
if( GetPrgRes()->GetUpdateExists() )
|
||||||
|
{
|
||||||
|
mi.dwTypeData = const_cast<char*>( pl->GuiMessage(Languages::menu_update_available) );
|
||||||
|
SetMenuItemInfo(menu, IDM_UPDATE_AVAILABLE_INDEX, true, &mi);
|
||||||
|
}
|
||||||
|
|
||||||
|
mi.dwTypeData = const_cast<char*>( pl->GuiMessage(Languages::menu_language) );
|
||||||
SetMenuItemInfo(GetSubMenu(menu,IDM_VIEW_INDEX), IDM_LANGUAGE_INDEX, true, &mi);
|
SetMenuItemInfo(GetSubMenu(menu,IDM_VIEW_INDEX), IDM_LANGUAGE_INDEX, true, &mi);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SetMenuLanguageItem(menu, IDM_NEW_WINDOW, Languages::menu_view_new_window);
|
SetMenuLanguageItem(menu, IDM_NEW_WINDOW, Languages::menu_view_new_window);
|
||||||
SetMenuLanguageItem(menu, IDM_NORMAL_VIEW, Languages::menu_view_normal_view);
|
SetMenuLanguageItem(menu, IDM_NORMAL_VIEW, Languages::menu_view_normal_view);
|
||||||
SetMenuLanguageItem(menu, IDM_COMPACT_VIEW, Languages::menu_view_compact_view);
|
SetMenuLanguageItem(menu, IDM_COMPACT_VIEW, Languages::menu_view_compact_view);
|
||||||
SetMenuLanguageItem(menu, IDM_ALWAYS_ON_TOP, Languages::menu_view_always_on_top);
|
SetMenuLanguageItem(menu, IDM_ALWAYS_ON_TOP, Languages::menu_view_always_on_top);
|
||||||
|
SetMenuLanguageItem(menu, IDM_PAD, Languages::menu_view_pad);
|
||||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_ENGLISH, Languages::menu_view_lang_english);
|
SetMenuLanguageItem(menu, IDM_LANGUAGE_ENGLISH, Languages::menu_view_lang_english);
|
||||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_POLISH, Languages::menu_view_lang_polish);
|
SetMenuLanguageItem(menu, IDM_LANGUAGE_POLISH, Languages::menu_view_lang_polish);
|
||||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_SPANISH, Languages::menu_view_lang_spanish);
|
SetMenuLanguageItem(menu, IDM_LANGUAGE_SPANISH, Languages::menu_view_lang_spanish);
|
||||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_DANISH, Languages::menu_view_lang_danish);
|
SetMenuLanguageItem(menu, IDM_LANGUAGE_DANISH, Languages::menu_view_lang_danish);
|
||||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_CHINESE, Languages::menu_view_lang_chinese);
|
SetMenuLanguageItem(menu, IDM_LANGUAGE_CHINESE, Languages::menu_view_lang_chinese);
|
||||||
SetMenuLanguageItem(menu, IDM_LANGUAGE_RUSSIAN, Languages::menu_view_lang_russian);
|
SetMenuLanguageItem(menu, IDM_LANGUAGE_RUSSIAN, Languages::menu_view_lang_russian);
|
||||||
|
SetMenuLanguageItem(menu, IDM_LANGUAGE_SWEDISH, Languages::menu_view_lang_swedish);
|
||||||
|
SetMenuLanguageItem(menu, IDM_LANGUAGE_ITALIAN, Languages::menu_view_lang_italian);
|
||||||
|
SetMenuLanguageItem(menu, IDM_LANGUAGE_GERMAN, Languages::menu_view_lang_german);
|
||||||
SetMenuLanguageItem(menu, IDM_CLOSE_PROGRAM, Languages::menu_view_close_program);
|
SetMenuLanguageItem(menu, IDM_CLOSE_PROGRAM, Languages::menu_view_close_program);
|
||||||
SetMenuLanguageItem(menu, IDM_EDIT_UNDO, Languages::menu_edit_undo);
|
SetMenuLanguageItem(menu, IDM_EDIT_UNDO, Languages::menu_edit_undo);
|
||||||
|
SetMenuLanguageItem(menu, IDM_EDIT_CUT, Languages::menu_edit_cut);
|
||||||
|
SetMenuLanguageItem(menu, IDM_EDIT_COPY, Languages::menu_edit_copy);
|
||||||
SetMenuLanguageItem(menu, IDM_EDIT_PASTE, Languages::menu_edit_paste);
|
SetMenuLanguageItem(menu, IDM_EDIT_PASTE, Languages::menu_edit_paste);
|
||||||
|
SetMenuLanguageItem(menu, IDM_EDIT_DEL, Languages::menu_edit_del);
|
||||||
|
SetMenuLanguageItem(menu, IDM_EDIT_PASTE_FORMULA, Languages::menu_edit_paste_formula);
|
||||||
SetMenuLanguageItem(menu, IDM_EDIT_COPY_RESULT, Languages::menu_edit_copy_result);
|
SetMenuLanguageItem(menu, IDM_EDIT_COPY_RESULT, Languages::menu_edit_copy_result);
|
||||||
|
SetMenuLanguageItem(menu, IDM_EDIT_COPY_BOTH, Languages::menu_edit_copy_both);
|
||||||
|
SetMenuLanguageItem(menu, IDM_EDIT_SELECT_ALL, Languages::menu_edit_select_all);
|
||||||
|
SetMenuLanguageItem(menu, IDM_EDIT_BRACKET, Languages::menu_edit_bracket);
|
||||||
|
SetMenuLanguageItem(menu, IDM_EDIT_SWAP, Languages::menu_edit_swap);
|
||||||
SetMenuLanguageItem(menu, IDM_HELP_HELP, Languages::menu_help_help);
|
SetMenuLanguageItem(menu, IDM_HELP_HELP, Languages::menu_help_help);
|
||||||
SetMenuLanguageItem(menu, IDM_HELP_PROJECT_PAGE, Languages::menu_help_project_page);
|
SetMenuLanguageItem(menu, IDM_HELP_PROJECT_PAGE, Languages::menu_help_project_page);
|
||||||
|
SetMenuLanguageItem(menu, IDM_HELP_CHECK_UPDATE, Languages::menu_help_check_update);
|
||||||
SetMenuLanguageItem(menu, IDM_HELP_ABOUT, Languages::menu_help_about);
|
SetMenuLanguageItem(menu, IDM_HELP_ABOUT, Languages::menu_help_about);
|
||||||
|
|
||||||
DrawMenuBar(hWnd);
|
DrawMenuBar(hWnd);
|
||||||
|
@ -588,14 +598,15 @@ HWND hTab = GetDlgItem(hWnd,IDC_TAB);
|
||||||
SendMessage(hWnd,WM_SETICON,ICON_BIG,(LPARAM)program_icon);
|
SendMessage(hWnd,WM_SETICON,ICON_BIG,(LPARAM)program_icon);
|
||||||
|
|
||||||
GetPrgRes()->SetAlwaysOnTop( GetPrgRes()->GetAlwaysOnTop() );
|
GetPrgRes()->SetAlwaysOnTop( GetPrgRes()->GetAlwaysOnTop() );
|
||||||
GetPrgRes()->SetMaximized ( GetPrgRes()->GetMaximized() );
|
|
||||||
GetPrgRes()->SetView ( GetPrgRes()->GetView() );
|
GetPrgRes()->SetView ( GetPrgRes()->GetView() );
|
||||||
|
|
||||||
ShowWindow(hWnd,SW_SHOW);
|
|
||||||
|
|
||||||
SendDlgItemMessage(hWnd,IDC_INPUT_EDIT,EM_SETLIMITTEXT,GetPrgRes()->GetBufferSize()-1,0);
|
SendDlgItemMessage(hWnd,IDC_INPUT_EDIT,EM_SETLIMITTEXT,GetPrgRes()->GetBufferSize()-1,0);
|
||||||
SetMenuLanguage(hWnd);
|
SetMenuLanguage(hWnd);
|
||||||
|
|
||||||
|
#ifdef TTCALC_PORTABLE
|
||||||
|
SetWindowText(hWnd, "TTCalc portable");
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,7 +744,8 @@ POINT p;
|
||||||
TabWindowFunctions::SetSizeOfFunctionsList(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::SetSizeOfConvertingLists(tab, cx, cy-p.y, borderx, bordery);
|
||||||
|
|
||||||
if( fwSizeType != SIZE_MINIMIZED && GetPrgRes()->GetView() != ProgramResources::view_compact )
|
if( fwSizeType != SIZE_MINIMIZED && fwSizeType != SIZE_MAXIMIZED &&
|
||||||
|
GetPrgRes()->GetView() != ProgramResources::view_compact )
|
||||||
{
|
{
|
||||||
GetWindowRect(hWnd,&r);
|
GetWindowRect(hWnd,&r);
|
||||||
GetPrgRes()->SetXSize( r.right - r.left );
|
GetPrgRes()->SetXSize( r.right - r.left );
|
||||||
|
@ -763,6 +775,15 @@ void WmInitMenuPopUpView(HMENU menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( GetPrgRes()->IsPadVisible() )
|
||||||
|
{
|
||||||
|
CheckMenuItem(menu,IDM_PAD,MF_BYCOMMAND|MF_CHECKED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CheckMenuItem(menu,IDM_PAD,MF_BYCOMMAND|MF_UNCHECKED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// languages
|
// languages
|
||||||
|
|
||||||
|
@ -772,6 +793,7 @@ void WmInitMenuPopUpView(HMENU menu)
|
||||||
CheckMenuItem(menu, IDM_LANGUAGE_DANISH, 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_CHINESE, MF_BYCOMMAND|MF_UNCHECKED);
|
||||||
CheckMenuItem(menu, IDM_LANGUAGE_RUSSIAN, 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();
|
Languages::Country lang = GetPrgRes()->GetLanguages()->GetCurrentLanguage();
|
||||||
|
|
||||||
|
@ -792,33 +814,108 @@ void WmInitMenuPopUpView(HMENU menu)
|
||||||
else
|
else
|
||||||
if( lang == Languages::ru )
|
if( lang == Languages::ru )
|
||||||
CheckMenuItem(menu, IDM_LANGUAGE_RUSSIAN, MF_BYCOMMAND|MF_CHECKED);
|
CheckMenuItem(menu, IDM_LANGUAGE_RUSSIAN, MF_BYCOMMAND|MF_CHECKED);
|
||||||
|
else
|
||||||
|
if( lang == Languages::swe )
|
||||||
|
CheckMenuItem(menu, IDM_LANGUAGE_SWEDISH, MF_BYCOMMAND|MF_CHECKED);
|
||||||
|
else
|
||||||
|
if( lang == Languages::it )
|
||||||
|
CheckMenuItem(menu, IDM_LANGUAGE_ITALIAN, MF_BYCOMMAND|MF_CHECKED);
|
||||||
|
else
|
||||||
|
if( lang == Languages::ger )
|
||||||
|
CheckMenuItem(menu, IDM_LANGUAGE_GERMAN, MF_BYCOMMAND|MF_CHECKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WmInitMenuPopUpEdit(HWND hWnd, HMENU menu)
|
void WmInitMenuPopUpEdit(HWND hWnd, HMENU menu)
|
||||||
{
|
{
|
||||||
char buffer[5];
|
bool edit = false; // an edit control has the focus
|
||||||
|
bool edit_sel = false; // there is something selected on the edit
|
||||||
|
bool edit_readonly = false; // the edit is read only
|
||||||
|
|
||||||
bool can_undo = SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, EM_CANUNDO, 0 ,0);
|
HWND focus = GetFocus();
|
||||||
|
edit = IsEditControl(focus);
|
||||||
|
|
||||||
if( can_undo )
|
if( edit )
|
||||||
|
{
|
||||||
|
DWORD sel_start, sel_end;
|
||||||
|
SendMessage(focus, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
|
||||||
|
|
||||||
|
if( sel_start != sel_end )
|
||||||
|
edit_sel = true;
|
||||||
|
|
||||||
|
if( (GetWindowLong(focus, GWL_STYLE) & ES_READONLY) != 0 )
|
||||||
|
edit_readonly = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// undo
|
||||||
|
if( edit && !edit_readonly && SendMessage(focus, EM_CANUNDO, 0 ,0) )
|
||||||
EnableMenuItem(menu,IDM_EDIT_UNDO,MF_BYCOMMAND | MF_ENABLED);
|
EnableMenuItem(menu,IDM_EDIT_UNDO,MF_BYCOMMAND | MF_ENABLED);
|
||||||
else
|
else
|
||||||
EnableMenuItem(menu,IDM_EDIT_UNDO,MF_BYCOMMAND | MF_GRAYED);
|
EnableMenuItem(menu,IDM_EDIT_UNDO,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
|
||||||
|
// cut
|
||||||
|
if( edit && edit_sel && !edit_readonly )
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_CUT,MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
else
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_CUT,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
|
||||||
if( IsClipboardFormatAvailable(CF_TEXT) )
|
// paste
|
||||||
|
if( edit && !edit_readonly )
|
||||||
EnableMenuItem(menu,IDM_EDIT_PASTE,MF_BYCOMMAND | MF_ENABLED);
|
EnableMenuItem(menu,IDM_EDIT_PASTE,MF_BYCOMMAND | MF_ENABLED);
|
||||||
else
|
else
|
||||||
EnableMenuItem(menu,IDM_EDIT_PASTE,MF_BYCOMMAND | MF_GRAYED);
|
EnableMenuItem(menu,IDM_EDIT_PASTE,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
|
||||||
|
// del
|
||||||
GetDlgItemText(hWnd,IDC_OUTPUT_EDIT,buffer,sizeof(buffer));
|
if( edit && edit_sel && !edit_readonly )
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_DEL,MF_BYCOMMAND | MF_ENABLED);
|
||||||
if( buffer[0] == 0 )
|
|
||||||
EnableMenuItem(menu,IDM_EDIT_COPY_RESULT,MF_BYCOMMAND | MF_GRAYED);
|
|
||||||
else
|
else
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_DEL,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
|
||||||
|
// copy
|
||||||
|
if( edit && edit_sel )
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_COPY,MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
else
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_COPY,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
|
||||||
|
// copy result
|
||||||
|
int input_size = SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, EM_LINELENGTH, 0, 0);
|
||||||
|
int output_size = SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, EM_LINELENGTH, 0, 0);
|
||||||
|
|
||||||
|
if( output_size != 0 )
|
||||||
EnableMenuItem(menu,IDM_EDIT_COPY_RESULT,MF_BYCOMMAND | MF_ENABLED);
|
EnableMenuItem(menu,IDM_EDIT_COPY_RESULT,MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
else
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_COPY_RESULT,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
|
||||||
|
// copy both
|
||||||
|
if( input_size!=0 || output_size!=0 )
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_COPY_BOTH,MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
else
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_COPY_BOTH,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
|
||||||
|
// paste formula
|
||||||
|
if( IsClipboardFormatAvailable(CF_TEXT) )
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_PASTE_FORMULA,MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
else
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_PASTE_FORMULA,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
|
||||||
|
// select all, bracket
|
||||||
|
if( input_size > 0 )
|
||||||
|
{
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_SELECT_ALL,MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_BRACKET,MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_SELECT_ALL,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
EnableMenuItem(menu,IDM_EDIT_BRACKET,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// swap
|
||||||
|
if( output_size > 0 )
|
||||||
|
EnableMenuItem(menu, IDM_EDIT_SWAP, MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
else
|
||||||
|
EnableMenuItem(menu, IDM_EDIT_SWAP, MF_BYCOMMAND | MF_GRAYED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -886,6 +983,14 @@ return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmCommand_Pad(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
GetPrgRes()->ShowPad( !GetPrgRes()->IsPadVisible() );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL WmCommand_HelpAbout(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmCommand_HelpAbout(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
DialogBox(GetPrgRes()->GetInstance(),MAKEINTRESOURCE(IDD_ABOUT_DIALOG),hWnd,AboutProc);
|
DialogBox(GetPrgRes()->GetInstance(),MAKEINTRESOURCE(IDD_ABOUT_DIALOG),hWnd,AboutProc);
|
||||||
|
@ -894,6 +999,22 @@ return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmCommand_HelpCheckUpdate(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
ShowUpdateDialog(hWnd);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WmCommand_UpdateAvailable(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
ShowUpdateDialogAfterCheck(hWnd);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL WmCommand_NewWindow(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmCommand_NewWindow(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
STARTUPINFO si;
|
STARTUPINFO si;
|
||||||
|
@ -941,14 +1062,79 @@ return true;
|
||||||
|
|
||||||
BOOL WmCommand_EditUndo(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmCommand_EditUndo(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, EM_UNDO, 0, 0);
|
HWND focus = GetFocus();
|
||||||
|
SendMessage(focus, EM_UNDO, 0, 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmCommand_EditPasteFormula(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
HWND input_edit = GetDlgItem(hWnd, IDC_INPUT_EDIT);
|
||||||
|
SendMessage(input_edit, WM_PASTE, 0, 0);
|
||||||
|
SetFocus(input_edit);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmCommand_EditCopy(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
HWND focus = GetFocus();
|
||||||
|
SendMessage(focus, WM_COPY, 0, 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WmCommand_EditCut(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
HWND focus = GetFocus();
|
||||||
|
SendMessage(focus, WM_CUT, 0, 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WmCommand_EditPaste(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmCommand_EditPaste(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, WM_PASTE, 0, 0);
|
HWND focus = GetFocus();
|
||||||
|
SendMessage(focus, WM_PASTE, 0, 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmCommand_EditDel(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
HWND focus = GetFocus();
|
||||||
|
|
||||||
|
if( IsEditControl(focus) )
|
||||||
|
SendMessage(focus, EM_REPLACESEL, 1, (LPARAM)"");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WmCommand_EditBracket(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
SendMessage(GetPrgRes()->GetMainWindow(), WM_COMMAND, IDC_BUTTON_BRACKETS_ALL, 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmCommand_EditSwap(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
char * buf = GetPrgRes()->GetBufferTemp();
|
||||||
|
GetDlgItemText(hWnd, IDC_OUTPUT_EDIT, buf, GetPrgRes()->GetBufferSize());
|
||||||
|
|
||||||
|
if( buf[0] == 0 )
|
||||||
|
return true; // output edit is empty
|
||||||
|
|
||||||
|
SetDlgItemText(hWnd, IDC_INPUT_EDIT, buf);
|
||||||
|
|
||||||
|
// setting the caret at the end of the input edit
|
||||||
|
int len = SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, EM_LINELENGTH, 0, 0);
|
||||||
|
SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, EM_SETSEL, len, len);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -956,9 +1142,61 @@ return true;
|
||||||
|
|
||||||
BOOL WmCommand_EditCopyResult(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmCommand_EditCopyResult(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, EM_SETSEL, 0, LPARAM(-1));
|
CopyResult();
|
||||||
SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, WM_COPY, 0, 0);
|
|
||||||
SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, EM_SETSEL, WPARAM(-1), 0);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmCommand_EditCopyBoth(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
unsigned int in_len = SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, EM_LINELENGTH, 0, 0);
|
||||||
|
unsigned int out_len = SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, EM_LINELENGTH, 0, 0);
|
||||||
|
bool set_correct = false;
|
||||||
|
|
||||||
|
if( in_len >= GetPrgRes()->GetBufferSize() || out_len >= GetPrgRes()->GetBufferSize() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if( !OpenClipboard(hWnd) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
EmptyClipboard();
|
||||||
|
HGLOBAL global = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, in_len+out_len + 20);
|
||||||
|
|
||||||
|
if( global )
|
||||||
|
{
|
||||||
|
char * text = (char*)GlobalLock(global);
|
||||||
|
|
||||||
|
if( text )
|
||||||
|
{
|
||||||
|
char * buf = GetPrgRes()->GetBufferTemp();
|
||||||
|
|
||||||
|
*(WORD*)buf = in_len + 1;
|
||||||
|
SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, EM_GETLINE, 0, (LPARAM)buf);
|
||||||
|
sprintf(text, "%s = ", buf);
|
||||||
|
|
||||||
|
*(WORD*)buf = out_len + 1;
|
||||||
|
SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, EM_GETLINE, 0, (LPARAM)buf);
|
||||||
|
std::strcat(text, buf);
|
||||||
|
|
||||||
|
GlobalUnlock(global);
|
||||||
|
set_correct = (bool)SetClipboardData(CF_TEXT, global);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseClipboard();
|
||||||
|
|
||||||
|
/*
|
||||||
|
don't call GlobalFree(global) if SetClipboardData() returned true
|
||||||
|
|
||||||
|
http://msdn.microsoft.com/en-us/library/ms649051%28VS.85%29.aspx
|
||||||
|
If SetClipboardData succeeds, the system owns the object identified by the hMem parameter.
|
||||||
|
The application may not write to or free the data once ownership has been transferred to
|
||||||
|
the system, but it can lock and read from the data until the CloseClipboard function is called
|
||||||
|
*/
|
||||||
|
|
||||||
|
if( global && !set_correct )
|
||||||
|
GlobalFree(global);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1026,6 +1264,7 @@ BOOL WmCommand_LanguageEnglish(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
||||||
SetMenuLanguage(hWnd);
|
SetMenuLanguage(hWnd);
|
||||||
SetOutputEditLanguage(hWnd);
|
SetOutputEditLanguage(hWnd);
|
||||||
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||||
|
SetPadLanguage();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1038,6 +1277,7 @@ BOOL WmCommand_LanguagePolish(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
SetMenuLanguage(hWnd);
|
SetMenuLanguage(hWnd);
|
||||||
SetOutputEditLanguage(hWnd);
|
SetOutputEditLanguage(hWnd);
|
||||||
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||||
|
SetPadLanguage();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1050,6 +1290,7 @@ BOOL WmCommand_LanguageSpanish(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
||||||
SetMenuLanguage(hWnd);
|
SetMenuLanguage(hWnd);
|
||||||
SetOutputEditLanguage(hWnd);
|
SetOutputEditLanguage(hWnd);
|
||||||
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||||
|
SetPadLanguage();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1061,6 +1302,7 @@ BOOL WmCommand_LanguageDanish(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
SetMenuLanguage(hWnd);
|
SetMenuLanguage(hWnd);
|
||||||
SetOutputEditLanguage(hWnd);
|
SetOutputEditLanguage(hWnd);
|
||||||
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||||
|
SetPadLanguage();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1072,6 +1314,7 @@ BOOL WmCommand_LanguageChinese(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
||||||
SetMenuLanguage(hWnd);
|
SetMenuLanguage(hWnd);
|
||||||
SetOutputEditLanguage(hWnd);
|
SetOutputEditLanguage(hWnd);
|
||||||
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||||
|
SetPadLanguage();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1083,11 +1326,47 @@ BOOL WmCommand_LanguageRussian(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
||||||
SetMenuLanguage(hWnd);
|
SetMenuLanguage(hWnd);
|
||||||
SetOutputEditLanguage(hWnd);
|
SetOutputEditLanguage(hWnd);
|
||||||
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||||
|
SetPadLanguage();
|
||||||
|
|
||||||
|
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) );
|
||||||
|
SetPadLanguage();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WmCommand_LanguageItalian(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::it);
|
||||||
|
|
||||||
|
SetMenuLanguage(hWnd);
|
||||||
|
SetOutputEditLanguage(hWnd);
|
||||||
|
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||||
|
SetPadLanguage();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmCommand_LanguageGerman(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::ger);
|
||||||
|
|
||||||
|
SetMenuLanguage(hWnd);
|
||||||
|
SetOutputEditLanguage(hWnd);
|
||||||
|
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
|
||||||
|
SetPadLanguage();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL WmHelp(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmHelp(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -1097,7 +1376,7 @@ SHELLEXECUTEINFO exec;
|
||||||
exec.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS;
|
exec.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS;
|
||||||
exec.hwnd = 0;
|
exec.hwnd = 0;
|
||||||
exec.lpVerb = "open";
|
exec.lpVerb = "open";
|
||||||
exec.lpFile = "ttcalc.chm";
|
exec.lpFile = GetPrgRes()->GetHelpFile().c_str();
|
||||||
exec.lpParameters = 0;
|
exec.lpParameters = 0;
|
||||||
exec.lpDirectory = "";
|
exec.lpDirectory = "";
|
||||||
exec.nShow = SW_SHOWNORMAL;
|
exec.nShow = SW_SHOWNORMAL;
|
||||||
|
@ -1140,25 +1419,63 @@ return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CreateCommandMessagesTable(Messages & cmessages)
|
BOOL WmUpdateExists(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
MENUITEMINFO mi;
|
||||||
|
|
||||||
|
mi.cbSize = sizeof(mi);
|
||||||
|
mi.fMask = MIIM_TYPE | MIIM_ID;
|
||||||
|
mi.fType = MFT_STRING;
|
||||||
|
mi.dwTypeData = const_cast<char*>(GetPrgRes()->GetLanguages()->GuiMessage(Languages::menu_update_available));
|
||||||
|
mi.cch = 0;
|
||||||
|
mi.wID = IDM_UPDATE_AVAILABLE;
|
||||||
|
|
||||||
|
HMENU menu = GetMenu(hWnd);
|
||||||
|
|
||||||
|
if( !menu )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
InsertMenuItem(menu, IDM_UPDATE_AVAILABLE_INDEX, true, &mi);
|
||||||
|
GetPrgRes()->SetUpdateExists(true); // used for the dynamic menu (for changing languages)
|
||||||
|
DrawMenuBar(hWnd);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CreateCommandMessagesTable(Messages<BOOL> & cmessages)
|
||||||
{
|
{
|
||||||
cmessages.Associate(IDM_ALWAYS_ON_TOP, WmCommand_AlwaysOnTop);
|
cmessages.Associate(IDM_ALWAYS_ON_TOP, WmCommand_AlwaysOnTop);
|
||||||
cmessages.Associate(IDM_NORMAL_VIEW, WmCommand_NormalView);
|
cmessages.Associate(IDM_NORMAL_VIEW, WmCommand_NormalView);
|
||||||
cmessages.Associate(IDM_COMPACT_VIEW, WmCommand_CompactView);
|
cmessages.Associate(IDM_COMPACT_VIEW, WmCommand_CompactView);
|
||||||
|
cmessages.Associate(IDM_PAD, WmCommand_Pad);
|
||||||
cmessages.Associate(IDM_HELP_ABOUT, WmCommand_HelpAbout);
|
cmessages.Associate(IDM_HELP_ABOUT, WmCommand_HelpAbout);
|
||||||
|
cmessages.Associate(IDM_HELP_CHECK_UPDATE, WmCommand_HelpCheckUpdate);
|
||||||
|
cmessages.Associate(IDM_UPDATE_AVAILABLE, WmCommand_UpdateAvailable);
|
||||||
cmessages.Associate(IDM_NEW_WINDOW, WmCommand_NewWindow);
|
cmessages.Associate(IDM_NEW_WINDOW, WmCommand_NewWindow);
|
||||||
cmessages.Associate(IDM_CLOSE_PROGRAM, WmCommand_CloseProgram);
|
cmessages.Associate(IDM_CLOSE_PROGRAM, WmCommand_CloseProgram);
|
||||||
cmessages.Associate(IDC_INPUT_EDIT, WmCommand_InputEditNotify);
|
cmessages.Associate(IDC_INPUT_EDIT, WmCommand_InputEditNotify);
|
||||||
cmessages.Associate(IDM_EDIT_UNDO, WmCommand_EditUndo);
|
cmessages.Associate(IDM_EDIT_UNDO, WmCommand_EditUndo);
|
||||||
cmessages.Associate(IDM_EDIT_PASTE, WmCommand_EditPaste);
|
cmessages.Associate(IDM_EDIT_PASTE_FORMULA, WmCommand_EditPasteFormula);
|
||||||
cmessages.Associate(IDM_EDIT_COPY_RESULT, WmCommand_EditCopyResult);
|
cmessages.Associate(IDM_EDIT_COPY_RESULT, WmCommand_EditCopyResult);
|
||||||
|
cmessages.Associate(IDM_EDIT_COPY_BOTH, WmCommand_EditCopyBoth);
|
||||||
|
cmessages.Associate(IDM_EDIT_COPY, WmCommand_EditCopy);
|
||||||
|
cmessages.Associate(IDM_EDIT_CUT, WmCommand_EditCut);
|
||||||
|
cmessages.Associate(IDM_EDIT_PASTE, WmCommand_EditPaste);
|
||||||
|
cmessages.Associate(IDM_EDIT_DEL, WmCommand_EditDel);
|
||||||
|
cmessages.Associate(IDM_EDIT_BRACKET, WmCommand_EditBracket);
|
||||||
|
cmessages.Associate(IDM_EDIT_SWAP, WmCommand_EditSwap);
|
||||||
cmessages.Associate(IDCANCEL, WmCommand_IDCANCEL);
|
cmessages.Associate(IDCANCEL, WmCommand_IDCANCEL);
|
||||||
|
cmessages.Associate(IDM_EDIT_SELECT_ALL, WmCommand_IDCANCEL);
|
||||||
cmessages.Associate(IDM_LANGUAGE_ENGLISH, WmCommand_LanguageEnglish);
|
cmessages.Associate(IDM_LANGUAGE_ENGLISH, WmCommand_LanguageEnglish);
|
||||||
cmessages.Associate(IDM_LANGUAGE_POLISH, WmCommand_LanguagePolish);
|
cmessages.Associate(IDM_LANGUAGE_POLISH, WmCommand_LanguagePolish);
|
||||||
cmessages.Associate(IDM_LANGUAGE_SPANISH, WmCommand_LanguageSpanish);
|
cmessages.Associate(IDM_LANGUAGE_SPANISH, WmCommand_LanguageSpanish);
|
||||||
cmessages.Associate(IDM_LANGUAGE_DANISH, WmCommand_LanguageDanish);
|
cmessages.Associate(IDM_LANGUAGE_DANISH, WmCommand_LanguageDanish);
|
||||||
cmessages.Associate(IDM_LANGUAGE_CHINESE, WmCommand_LanguageChinese);
|
cmessages.Associate(IDM_LANGUAGE_CHINESE, WmCommand_LanguageChinese);
|
||||||
cmessages.Associate(IDM_LANGUAGE_RUSSIAN, WmCommand_LanguageRussian);
|
cmessages.Associate(IDM_LANGUAGE_RUSSIAN, WmCommand_LanguageRussian);
|
||||||
|
cmessages.Associate(IDM_LANGUAGE_SWEDISH, WmCommand_LanguageSwedish);
|
||||||
|
cmessages.Associate(IDM_LANGUAGE_ITALIAN, WmCommand_LanguageItalian);
|
||||||
|
cmessages.Associate(IDM_LANGUAGE_GERMAN, WmCommand_LanguageGerman);
|
||||||
cmessages.Associate(IDM_HELP_HELP, WmHelp);
|
cmessages.Associate(IDM_HELP_HELP, WmHelp);
|
||||||
cmessages.Associate(IDM_HELP_PROJECT_PAGE, WmProjectPage);
|
cmessages.Associate(IDM_HELP_PROJECT_PAGE, WmProjectPage);
|
||||||
}
|
}
|
||||||
|
@ -1166,7 +1483,7 @@ void CreateCommandMessagesTable(Messages & cmessages)
|
||||||
|
|
||||||
BOOL WmCommand(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmCommand(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
static Messages command_messages;
|
static Messages<BOOL> command_messages;
|
||||||
|
|
||||||
if( command_messages.Empty() )
|
if( command_messages.Empty() )
|
||||||
// initiation
|
// initiation
|
||||||
|
@ -1180,7 +1497,7 @@ static Messages command_messages;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CreateMainMessagesTable(Messages & messages)
|
void CreateMainMessagesTable(Messages<BOOL> & messages)
|
||||||
{
|
{
|
||||||
messages.Associate(WM_INITDIALOG, WmInitDialog);
|
messages.Associate(WM_INITDIALOG, WmInitDialog);
|
||||||
messages.Associate(WM_MOVE, WmMove);
|
messages.Associate(WM_MOVE, WmMove);
|
||||||
|
@ -1193,6 +1510,7 @@ void CreateMainMessagesTable(Messages & messages)
|
||||||
messages.Associate(WM_SIZING, WmSizing);
|
messages.Associate(WM_SIZING, WmSizing);
|
||||||
messages.Associate(WM_SET_LAST_ERROR, WmSetLastError);
|
messages.Associate(WM_SET_LAST_ERROR, WmSetLastError);
|
||||||
messages.Associate(WM_HELP, WmHelp);
|
messages.Associate(WM_HELP, WmHelp);
|
||||||
|
messages.Associate(WM_UPDATE_EXISTS, WmUpdateExists);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1260,9 +1578,10 @@ char compiler[50];
|
||||||
#else
|
#else
|
||||||
GetPrgRes()->GetLanguages()->GuiMessage(Languages::about_text_portable_version),
|
GetPrgRes()->GetLanguages()->GuiMessage(Languages::about_text_portable_version),
|
||||||
#endif
|
#endif
|
||||||
(TTCALC_PRERELEASE_VER!=0)? " (prerelease)" : "",
|
(TTCALC_PRERELEASE_VER!=0)? " prerelease" : "",
|
||||||
TTMATH_MAJOR_VER, TTMATH_MINOR_VER, TTMATH_REVISION_VER,
|
TTMATH_MAJOR_VER, TTMATH_MINOR_VER, TTMATH_REVISION_VER,
|
||||||
(TTMATH_PRERELEASE_VER!=0)? " (prerelease)" : "",
|
(TTMATH_PRERELEASE_VER!=0)? " prerelease" : "",
|
||||||
|
TTMathBigMax::LibTypeStr(),
|
||||||
compiler,
|
compiler,
|
||||||
#ifndef TTCALC_PORTABLE
|
#ifndef TTCALC_PORTABLE
|
||||||
""
|
""
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -42,10 +42,12 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<typename ProcReturnType>
|
||||||
class Messages
|
class Messages
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef BOOL (*MessageFunction)(HWND, UINT, WPARAM, LPARAM);
|
typedef ProcReturnType (*MessageFunction)(HWND, UINT, WPARAM, LPARAM);
|
||||||
typedef std::map<UINT, MessageFunction> MessageTable;
|
typedef std::map<UINT, MessageFunction> MessageTable;
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,19 +63,28 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Call(UINT key, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
ProcReturnType Call(UINT key, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool * method_exists = 0)
|
||||||
{
|
{
|
||||||
MessageTable::iterator i = message_table.find(key);
|
typename MessageTable::iterator i = message_table.find(key);
|
||||||
|
|
||||||
if( i == message_table.end() )
|
if( i == message_table.end() )
|
||||||
|
{
|
||||||
|
if( method_exists )
|
||||||
|
*method_exists = false;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( method_exists )
|
||||||
|
*method_exists = true;
|
||||||
|
|
||||||
return i->second(hWnd, message, wParam, lParam);
|
return i->second(hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool IsMessage(UINT key)
|
bool IsMessage(UINT key)
|
||||||
{
|
{
|
||||||
MessageTable::iterator i = message_table.find(key);
|
typename MessageTable::iterator i = message_table.find(key);
|
||||||
|
|
||||||
if( i == message_table.end() )
|
if( i == message_table.end() )
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
|
* and is distributed under the (new) BSD licence.
|
||||||
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2010, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returning true if short_str is a substring of long_str (no case-sensitive)
|
||||||
|
*/
|
||||||
|
bool IsSubStringNoCase(const char * short_str, const char * long_str)
|
||||||
|
{
|
||||||
|
while( *short_str && *long_str && ToLower(*short_str) == ToLower(*long_str) )
|
||||||
|
{
|
||||||
|
++short_str;
|
||||||
|
++long_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( *short_str == 0 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
|
* and is distributed under the (new) BSD licence.
|
||||||
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2010, 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 headerfilemisc
|
||||||
|
#define headerfilemisc
|
||||||
|
|
||||||
|
int ToLower(int c);
|
||||||
|
bool EqualStrings(const char * str1, const char * str2);
|
||||||
|
bool IsSubStringNoCase(const char * short_str, const char * long_str);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,943 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
|
* and is distributed under the (new) BSD licence.
|
||||||
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2010, 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 <windows.h>
|
||||||
|
#include <ttmath/ttmath.h>
|
||||||
|
#include <shlobj.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include "programresources.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#include "messages.h"
|
||||||
|
#include "bigtypes.h"
|
||||||
|
#include "pad.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Pad
|
||||||
|
{
|
||||||
|
HWND edit;
|
||||||
|
WNDPROC old_edit_proc;
|
||||||
|
std::string parse_string;
|
||||||
|
int precision;
|
||||||
|
HFONT font;
|
||||||
|
|
||||||
|
int base_input;
|
||||||
|
int base_output;
|
||||||
|
bool always_scientific;
|
||||||
|
int when_scientific;
|
||||||
|
int rounding;
|
||||||
|
bool remove_zeroes;
|
||||||
|
int angle_deg_rad_grad;
|
||||||
|
|
||||||
|
char decimal_point;
|
||||||
|
char grouping;
|
||||||
|
char input_comma1;
|
||||||
|
char input_comma2;
|
||||||
|
char param_sep;
|
||||||
|
|
||||||
|
int grouping_digits;
|
||||||
|
|
||||||
|
Languages::Country country;
|
||||||
|
|
||||||
|
int last_variables_id;
|
||||||
|
int last_functions_id;
|
||||||
|
ttmath::Objects * variables;
|
||||||
|
ttmath::Objects * functions;
|
||||||
|
|
||||||
|
ttmath::ErrorCode code;
|
||||||
|
bool calculated;
|
||||||
|
|
||||||
|
std::string res, res2;
|
||||||
|
std::string file_name;
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef TTCALC_PORTABLE
|
||||||
|
ttmath::Parser<TTMathBig1> parser1;
|
||||||
|
ttmath::Parser<TTMathBig2> parser2;
|
||||||
|
ttmath::Parser<TTMathBig3> parser3;
|
||||||
|
#else
|
||||||
|
ttmath::Parser<TTMathBig1> parser1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void PutChars(const char * str)
|
||||||
|
{
|
||||||
|
SendMessage(edit, EM_REPLACESEL, true, (LPARAM)str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PutChars(std::string & str)
|
||||||
|
{
|
||||||
|
PutChars(str.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PutOverflowMsg()
|
||||||
|
{
|
||||||
|
PutChars(GetPrgRes()->GetLanguages()->ErrorMessage(country, ttmath::err_overflow));
|
||||||
|
PutChars("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename ValueType>
|
||||||
|
void PutResultFromParser(ttmath::Parser<ValueType> & matparser)
|
||||||
|
{
|
||||||
|
unsigned int i = 0;
|
||||||
|
|
||||||
|
res.clear();
|
||||||
|
res2.clear();
|
||||||
|
|
||||||
|
for(i=0 ; i<matparser.stack.size() ; ++i)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ValueType result = matparser.stack[i].value;
|
||||||
|
|
||||||
|
ttmath::Conv conv;
|
||||||
|
|
||||||
|
conv.base = base_output;
|
||||||
|
conv.scient = always_scientific;
|
||||||
|
conv.scient_from = when_scientific;
|
||||||
|
conv.round = rounding;
|
||||||
|
conv.trim_zeroes = remove_zeroes;
|
||||||
|
conv.comma = decimal_point;
|
||||||
|
conv.group = grouping;
|
||||||
|
conv.group_digits = grouping_digits;
|
||||||
|
|
||||||
|
if( result.ToString(res2, conv) )
|
||||||
|
res2 = GetPrgRes()->GetLanguages()->GuiMessage(country, Languages::overflow_during_printing);
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
res2 = GetPrgRes()->GetLanguages()->ErrorMessage(country, ttmath::err_internal_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
res += res2;
|
||||||
|
|
||||||
|
if( i < matparser.stack.size()-1 )
|
||||||
|
res += "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
res += ' ';
|
||||||
|
PutChars(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PutResult()
|
||||||
|
{
|
||||||
|
#ifndef TTCALC_PORTABLE
|
||||||
|
|
||||||
|
switch( precision )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
PutResultFromParser(parser1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
PutResultFromParser(parser2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
PutResultFromParser(parser3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
PutResultFromParser(parser1);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// line - index of a line -- as you see it on the edit control
|
||||||
|
// (if the text is wrapped then the line is larger)
|
||||||
|
void GetParseString(const char * buf, int line)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = SendMessage(edit, EM_LINEINDEX, line, 0);
|
||||||
|
// first_line_char takes into consideration \r\n characters
|
||||||
|
|
||||||
|
if( i < 0 )
|
||||||
|
// something wrong
|
||||||
|
return;
|
||||||
|
|
||||||
|
// looking for the beginning of the line (lines can be wrapped)
|
||||||
|
for( ; i>0 && buf[i-1]!=10 ; --i);
|
||||||
|
|
||||||
|
// copying the whole line
|
||||||
|
for( ; buf[i]!=0 && buf[i]!='\r' && buf[i]!='\n' ; ++i )
|
||||||
|
parse_string += buf[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GetParseString()
|
||||||
|
{
|
||||||
|
int line;
|
||||||
|
|
||||||
|
parse_string.clear();
|
||||||
|
|
||||||
|
// index of a last line to parse (-1 because the ENTER has been put)
|
||||||
|
line = SendMessage(edit, EM_LINEFROMCHAR, -1, 0) - 1;
|
||||||
|
|
||||||
|
if( line < 0 )
|
||||||
|
// something wrong
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
HLOCAL handle = (HLOCAL)SendMessage(edit, EM_GETHANDLE, 0, 0);
|
||||||
|
|
||||||
|
if( handle == 0 )
|
||||||
|
// something wrong
|
||||||
|
return;
|
||||||
|
|
||||||
|
const char * buf = (const char*)LocalLock(handle);
|
||||||
|
|
||||||
|
if( buf )
|
||||||
|
GetParseString(buf, line);
|
||||||
|
|
||||||
|
LocalUnlock(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class ValueType>
|
||||||
|
void ParseString(ttmath::Parser<ValueType> & matparser)
|
||||||
|
{
|
||||||
|
matparser.SetBase(base_input);
|
||||||
|
matparser.SetDegRadGrad(angle_deg_rad_grad);
|
||||||
|
matparser.SetComma(input_comma1, input_comma2);
|
||||||
|
matparser.SetGroup(grouping);
|
||||||
|
matparser.SetParamSep(param_sep);
|
||||||
|
|
||||||
|
matparser.SetVariables(variables);
|
||||||
|
matparser.SetFunctions(functions);
|
||||||
|
|
||||||
|
code = matparser.Parse(parse_string.c_str());
|
||||||
|
|
||||||
|
calculated = matparser.Calculated();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SetParameters()
|
||||||
|
{
|
||||||
|
base_input = GetPrgRes()->GetBaseInput();
|
||||||
|
base_output = GetPrgRes()->GetBaseOutput();
|
||||||
|
always_scientific = GetPrgRes()->GetDisplayAlwaysScientific();
|
||||||
|
when_scientific = GetPrgRes()->GetDisplayWhenScientific();
|
||||||
|
rounding = GetPrgRes()->GetDisplayRounding();
|
||||||
|
precision = GetPrgRes()->GetPrecision();
|
||||||
|
remove_zeroes = GetPrgRes()->GetRemovingZeroes();
|
||||||
|
angle_deg_rad_grad = GetPrgRes()->GetDegRadGrad();
|
||||||
|
country = GetPrgRes()->GetLanguages()->GetCurrentLanguage();
|
||||||
|
decimal_point = GetPrgRes()->GetDecimalPointChar();
|
||||||
|
grouping = GetPrgRes()->GetGroupingChar();
|
||||||
|
grouping_digits = GetPrgRes()->GetGroupingDigits();
|
||||||
|
param_sep = GetPrgRes()->GetParamSepChar();
|
||||||
|
|
||||||
|
GetPrgRes()->GetInputDecimalPointChar(&input_comma1, &input_comma2);
|
||||||
|
|
||||||
|
variables = GetPrgRes()->GetVariables();
|
||||||
|
functions = GetPrgRes()->GetFunctions();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ParseString()
|
||||||
|
{
|
||||||
|
if( parse_string.empty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SetParameters();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
#ifndef TTCALC_PORTABLE
|
||||||
|
|
||||||
|
switch( precision )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
ParseString(parser1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
ParseString(parser2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ParseString(parser3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
ParseString(parser1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
code = ttmath::err_internal_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( code==ttmath::err_ok && calculated )
|
||||||
|
PutResult();
|
||||||
|
else
|
||||||
|
if( code==ttmath::err_overflow )
|
||||||
|
PutOverflowMsg();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT EditReturnPressed(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
DWORD sel_start, sel_end;
|
||||||
|
|
||||||
|
SendMessage(edit, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
|
||||||
|
|
||||||
|
// putting the ENTER
|
||||||
|
LRESULT res = CallWindowProc(old_edit_proc, hwnd, msg, wParam, lParam);
|
||||||
|
|
||||||
|
if( sel_start != sel_end )
|
||||||
|
// something was selected
|
||||||
|
return res;
|
||||||
|
|
||||||
|
GetParseString();
|
||||||
|
ParseString();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT EditSubclass(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch( msg )
|
||||||
|
{
|
||||||
|
case WM_CHAR:
|
||||||
|
if( wParam == VK_RETURN )
|
||||||
|
{
|
||||||
|
return EditReturnPressed(hwnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CallWindowProc(old_edit_proc, hwnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline void SetMenuLanguageItem(HMENU menu, DWORD menu_id, Languages::GuiMsg msg)
|
||||||
|
{
|
||||||
|
Languages * pLang = GetPrgRes()->GetLanguages();
|
||||||
|
|
||||||
|
ModifyMenu(menu, menu_id, MF_BYCOMMAND|MF_STRING, menu_id, pLang->GuiMessage(msg) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void SetPadMenuLanguage(HWND hWnd)
|
||||||
|
{
|
||||||
|
HMENU menu = GetMenu(hWnd);
|
||||||
|
|
||||||
|
if( !menu )
|
||||||
|
return;
|
||||||
|
|
||||||
|
MENUITEMINFO mi;
|
||||||
|
mi.cbSize = sizeof(mi);
|
||||||
|
mi.fMask = MIIM_TYPE;
|
||||||
|
mi.fType = MFT_STRING;
|
||||||
|
|
||||||
|
// on popup menus we're using indexes because they don't want to work correctly
|
||||||
|
// with the identifiers
|
||||||
|
mi.dwTypeData = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::pad_menu_file) );
|
||||||
|
SetMenuItemInfo(menu, MENUPAD_FILE_INDEX, true, &mi);
|
||||||
|
|
||||||
|
mi.dwTypeData = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::pad_menu_edit) );
|
||||||
|
SetMenuItemInfo(menu, MENUPAD_EDIT_INDEX, true, &mi);
|
||||||
|
|
||||||
|
SetMenuLanguageItem(menu, MENUPAD_FILE_OPEN, Languages::pad_menu_file_open);
|
||||||
|
SetMenuLanguageItem(menu, MENUPAD_FILE_SAVE, Languages::pad_menu_file_saveas);
|
||||||
|
SetMenuLanguageItem(menu, MENUPAD_FILE_CLOSE, Languages::pad_menu_file_close);
|
||||||
|
SetMenuLanguageItem(menu, MENUPAD_EDIT_UNDO, Languages::pad_menu_edit_undo);
|
||||||
|
SetMenuLanguageItem(menu, MENUPAD_EDIT_CUT, Languages::pad_menu_edit_cut);
|
||||||
|
SetMenuLanguageItem(menu, MENUPAD_EDIT_COPY, Languages::pad_menu_edit_copy);
|
||||||
|
SetMenuLanguageItem(menu, MENUPAD_EDIT_PASTE, Languages::pad_menu_edit_paste);
|
||||||
|
SetMenuLanguageItem(menu, MENUPAD_EDIT_DEL, Languages::pad_menu_edit_del);
|
||||||
|
SetMenuLanguageItem(menu, MENUPAD_EDIT_SELECTALL, Languages::pad_menu_edit_select_all);
|
||||||
|
|
||||||
|
DrawMenuBar(hWnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadCreate(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
edit = CreateWindow("edit", "",
|
||||||
|
WS_VISIBLE | WS_CHILD | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL,
|
||||||
|
0, 0, 100, 100, hwnd, 0, GetPrgRes()->GetInstance(), 0);
|
||||||
|
|
||||||
|
if( !edit )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
GetPrgRes()->SetPadEdit(edit);
|
||||||
|
|
||||||
|
old_edit_proc = (WNDPROC)SetWindowLong(edit, GWL_WNDPROC, (LONG)EditSubclass);
|
||||||
|
|
||||||
|
// 65535 - 64KB
|
||||||
|
// we're using some kind of messages which operates only on 64KB
|
||||||
|
SendMessage(edit, EM_SETLIMITTEXT, 65535 - 5, 0);
|
||||||
|
|
||||||
|
if( font != 0 )
|
||||||
|
SendMessage(edit, WM_SETFONT, (WPARAM)font, 0);
|
||||||
|
|
||||||
|
SetPadLanguage();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
RECT r;
|
||||||
|
|
||||||
|
GetWindowRect(hwnd,&r);
|
||||||
|
|
||||||
|
GetPrgRes()->SetPadXPos( r.left );
|
||||||
|
GetPrgRes()->SetPadYPos( r.top );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadSize(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
// client coordinates
|
||||||
|
int cx = LOWORD(lParam);
|
||||||
|
int cy = HIWORD(lParam);
|
||||||
|
int fwSizeType = int(wParam);
|
||||||
|
RECT r;
|
||||||
|
|
||||||
|
|
||||||
|
if( fwSizeType == SIZE_MAXIMIZED )
|
||||||
|
GetPrgRes()->SetPadMaximized(true);
|
||||||
|
else
|
||||||
|
if( fwSizeType == SIZE_RESTORED )
|
||||||
|
GetPrgRes()->SetPadMaximized(false);
|
||||||
|
|
||||||
|
MoveWindow(edit, 0, 0, cx, cy, true);
|
||||||
|
|
||||||
|
if( fwSizeType != SIZE_MINIMIZED && fwSizeType != SIZE_MAXIMIZED )
|
||||||
|
{
|
||||||
|
GetWindowRect(hwnd, &r);
|
||||||
|
GetPrgRes()->SetPadXSize( r.right - r.left );
|
||||||
|
GetPrgRes()->SetPadYSize( r.bottom - r.top );
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadClose(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
GetPrgRes()->ShowPad( false );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadFocus(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
SetFocus(edit);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenDialog(HWND hwnd)
|
||||||
|
{
|
||||||
|
OPENFILENAME o;
|
||||||
|
char buf[MAX_PATH];
|
||||||
|
|
||||||
|
buf[0] = 0;
|
||||||
|
|
||||||
|
o.lStructSize = sizeof(o);
|
||||||
|
o.hwndOwner = hwnd;
|
||||||
|
o.hInstance = GetPrgRes()->GetInstance();
|
||||||
|
o.lpstrFilter = "*.*\0*.*\0";
|
||||||
|
o.lpstrCustomFilter = 0;
|
||||||
|
o.nMaxCustFilter = 0;
|
||||||
|
o.nFilterIndex = 1;
|
||||||
|
o.lpstrFile = buf;
|
||||||
|
o.nMaxFile = MAX_PATH;
|
||||||
|
o.lpstrFileTitle = 0;
|
||||||
|
o.nMaxFileTitle = 0;
|
||||||
|
o.lpstrInitialDir = 0;
|
||||||
|
o.lpstrTitle = 0;
|
||||||
|
o.Flags = OFN_PATHMUSTEXIST;
|
||||||
|
o.nFileOffset = 0;
|
||||||
|
o.nFileExtension = 0;
|
||||||
|
o.lpstrDefExt = 0;
|
||||||
|
o.lCustData = 0;
|
||||||
|
o.lpfnHook = 0;
|
||||||
|
o.lpTemplateName = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if( GetOpenFileName(&o) )
|
||||||
|
{
|
||||||
|
file_name = buf;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// testing files which have only one 10 at the end of a line (unix mode)
|
||||||
|
void CorrectUnixMode()
|
||||||
|
{
|
||||||
|
bool was_r = false;
|
||||||
|
|
||||||
|
for(size_t i=0 ; i<res.size() ; ++i)
|
||||||
|
{
|
||||||
|
if( res[i]==10 && !was_r )
|
||||||
|
{
|
||||||
|
res.insert(res.begin()+i, 13);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
was_r = res[i] == 13;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LoadFromFile(HWND hwnd, std::ifstream & file)
|
||||||
|
{
|
||||||
|
char buf[64];
|
||||||
|
std::streamsize size;
|
||||||
|
|
||||||
|
res.clear();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
file.read(buf, sizeof(buf)-1);
|
||||||
|
|
||||||
|
size = file.gcount();
|
||||||
|
buf[size] = 0;
|
||||||
|
res += buf;
|
||||||
|
}
|
||||||
|
while( !file.eof() );
|
||||||
|
|
||||||
|
CorrectUnixMode();
|
||||||
|
SetWindowText(edit, res.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadOpen(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if( !OpenDialog(hwnd) )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
std::ifstream file(file_name.c_str(), std::ios_base::in | std::ios_base::binary);
|
||||||
|
Languages * lang = GetPrgRes()->GetLanguages();
|
||||||
|
|
||||||
|
if( !file )
|
||||||
|
{
|
||||||
|
MessageBox(hwnd, lang->GuiMessage(Languages::cannot_open_file),
|
||||||
|
lang->GuiMessage(Languages::message_box_error_caption), MB_ICONERROR);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.seekg(0, std::ios::end);
|
||||||
|
std::ifstream::pos_type pos = file.tellg();
|
||||||
|
|
||||||
|
if( pos > 65530 )
|
||||||
|
{
|
||||||
|
MessageBox(hwnd, lang->GuiMessage(Languages::file_too_long),
|
||||||
|
lang->GuiMessage(Languages::message_box_error_caption), MB_ICONERROR);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.seekg(0);
|
||||||
|
LoadFromFile(hwnd, file);
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool SaveDialog(HWND hwnd)
|
||||||
|
{
|
||||||
|
OPENFILENAME o;
|
||||||
|
char buf[MAX_PATH];
|
||||||
|
|
||||||
|
sprintf(buf, "ttcalc.txt");
|
||||||
|
|
||||||
|
o.lStructSize = sizeof(o);
|
||||||
|
o.hwndOwner = hwnd;
|
||||||
|
o.hInstance = GetPrgRes()->GetInstance();
|
||||||
|
o.lpstrFilter = "*.*\0*.*\0";
|
||||||
|
o.lpstrCustomFilter = 0;
|
||||||
|
o.nMaxCustFilter = 0;
|
||||||
|
o.nFilterIndex = 1;
|
||||||
|
o.lpstrFile = buf;
|
||||||
|
o.nMaxFile = MAX_PATH;
|
||||||
|
o.lpstrFileTitle = 0;
|
||||||
|
o.nMaxFileTitle = 0;
|
||||||
|
o.lpstrInitialDir = 0;
|
||||||
|
o.lpstrTitle = 0;
|
||||||
|
o.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
|
||||||
|
o.nFileOffset = 0;
|
||||||
|
o.nFileExtension = 0;
|
||||||
|
o.lpstrDefExt = 0;
|
||||||
|
o.lCustData = 0;
|
||||||
|
o.lpfnHook = 0;
|
||||||
|
o.lpTemplateName = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if( GetSaveFileName(&o) )
|
||||||
|
{
|
||||||
|
file_name = buf;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SaveBuffer(HWND hwnd, const char * buf)
|
||||||
|
{
|
||||||
|
std::ofstream file(file_name.c_str(), std::ios_base::out | std::ios_base::binary);
|
||||||
|
|
||||||
|
if( !file )
|
||||||
|
{
|
||||||
|
Languages * lang = GetPrgRes()->GetLanguages();
|
||||||
|
MessageBox(hwnd, lang->GuiMessage(Languages::cannot_save_file),
|
||||||
|
lang->GuiMessage(Languages::message_box_error_caption), MB_ICONERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( ; *buf ; ++buf )
|
||||||
|
file.put(*buf);
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadSave(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if( !SaveDialog(hwnd) )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
Languages * lang = GetPrgRes()->GetLanguages();
|
||||||
|
HLOCAL handle = (HLOCAL)SendMessage(edit, EM_GETHANDLE, 0, 0);
|
||||||
|
|
||||||
|
if( handle == 0 )
|
||||||
|
{
|
||||||
|
MessageBox(hwnd, lang->GuiMessage(Languages::other_error),
|
||||||
|
lang->GuiMessage(Languages::message_box_error_caption), MB_ICONERROR);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * buf = (const char*)LocalLock(handle);
|
||||||
|
|
||||||
|
if( buf )
|
||||||
|
SaveBuffer(hwnd, buf);
|
||||||
|
else
|
||||||
|
MessageBox(hwnd, lang->GuiMessage(Languages::other_error),
|
||||||
|
lang->GuiMessage(Languages::message_box_error_caption), MB_ICONERROR);
|
||||||
|
|
||||||
|
LocalUnlock(handle);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadNew(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
SetWindowText(edit, "");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadUndo(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
SendMessage(edit, WM_UNDO, 0, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT PadCut(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
SendMessage(edit, WM_CUT, 0, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
SendMessage(edit, WM_COPY, 0, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadPaste(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
SendMessage(edit, WM_PASTE, 0, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadDel(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
SendMessage(edit, EM_REPLACESEL, true, (LPARAM)"");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadSelectAll(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
SendMessage(edit, EM_SETSEL, 0, -1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PadInitMenuEdit(HMENU menu)
|
||||||
|
{
|
||||||
|
DWORD sel_start, sel_end;
|
||||||
|
bool can_undo = SendMessage(edit, EM_CANUNDO, 0 ,0);
|
||||||
|
|
||||||
|
if( can_undo )
|
||||||
|
EnableMenuItem(menu,MENUPAD_EDIT_UNDO,MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
else
|
||||||
|
EnableMenuItem(menu,MENUPAD_EDIT_UNDO,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
|
||||||
|
|
||||||
|
SendMessage(edit, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
|
||||||
|
|
||||||
|
if( sel_start == sel_end )
|
||||||
|
{
|
||||||
|
EnableMenuItem(menu,MENUPAD_EDIT_CUT, MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
EnableMenuItem(menu,MENUPAD_EDIT_COPY,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
EnableMenuItem(menu,MENUPAD_EDIT_DEL, MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnableMenuItem(menu,MENUPAD_EDIT_CUT, MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
EnableMenuItem(menu,MENUPAD_EDIT_COPY,MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
EnableMenuItem(menu,MENUPAD_EDIT_DEL, MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( IsClipboardFormatAvailable(CF_TEXT) )
|
||||||
|
EnableMenuItem(menu,MENUPAD_EDIT_PASTE,MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
else
|
||||||
|
EnableMenuItem(menu,MENUPAD_EDIT_PASTE,MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadInitMenuPopUp(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
HMENU menu = (HMENU) wParam;
|
||||||
|
int index = LOWORD(lParam);
|
||||||
|
|
||||||
|
if( index == MENUPAD_EDIT_INDEX )
|
||||||
|
PadInitMenuEdit(menu);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CreatePadCommandTable(Messages<LRESULT> & messages)
|
||||||
|
{
|
||||||
|
messages.Associate(MENUPAD_FILE_NEW, PadNew);
|
||||||
|
messages.Associate(MENUPAD_FILE_OPEN, PadOpen);
|
||||||
|
messages.Associate(MENUPAD_FILE_SAVE, PadSave);
|
||||||
|
messages.Associate(MENUPAD_FILE_CLOSE, PadClose);
|
||||||
|
messages.Associate(MENUPAD_EDIT_UNDO, PadUndo);
|
||||||
|
messages.Associate(MENUPAD_EDIT_CUT, PadCut);
|
||||||
|
messages.Associate(MENUPAD_EDIT_COPY, PadCopy);
|
||||||
|
messages.Associate(MENUPAD_EDIT_PASTE, PadPaste);
|
||||||
|
messages.Associate(MENUPAD_EDIT_DEL, PadDel);
|
||||||
|
messages.Associate(MENUPAD_EDIT_SELECTALL, PadSelectAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT PadCommand(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
static Messages<LRESULT> messages;
|
||||||
|
bool method_exists;
|
||||||
|
LRESULT res;
|
||||||
|
|
||||||
|
if( messages.Empty() )
|
||||||
|
// initiation
|
||||||
|
CreatePadCommandTable(messages);
|
||||||
|
|
||||||
|
res = messages.Call(LOWORD(wParam), hwnd, msg, wParam, lParam, &method_exists);
|
||||||
|
|
||||||
|
if( !method_exists )
|
||||||
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CreatePadMessagesTable(Messages<LRESULT> & messages)
|
||||||
|
{
|
||||||
|
messages.Associate(WM_CREATE, PadCreate);
|
||||||
|
messages.Associate(WM_MOVE, PadMove);
|
||||||
|
messages.Associate(WM_SIZE, PadSize);
|
||||||
|
messages.Associate(WM_CLOSE, PadClose);
|
||||||
|
messages.Associate(WM_SETFOCUS, PadFocus);
|
||||||
|
messages.Associate(WM_COMMAND, PadCommand);
|
||||||
|
messages.Associate(WM_INITMENUPOPUP, PadInitMenuPopUp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT CALLBACK WindowPadProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
static Messages<LRESULT> messages;
|
||||||
|
bool method_exists;
|
||||||
|
LRESULT res;
|
||||||
|
|
||||||
|
if( messages.Empty() )
|
||||||
|
// initiation
|
||||||
|
CreatePadMessagesTable(messages);
|
||||||
|
|
||||||
|
res = messages.Call(msg, hwnd, msg, wParam, lParam, &method_exists);
|
||||||
|
|
||||||
|
if( !method_exists )
|
||||||
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ATOM RegisterPadClass(const char * ttcalc_pad_class_name)
|
||||||
|
{
|
||||||
|
WNDCLASS w;
|
||||||
|
|
||||||
|
w.style = 0;
|
||||||
|
w.lpfnWndProc = WindowPadProc;
|
||||||
|
w.cbClsExtra = 0;
|
||||||
|
w.cbWndExtra = 0;
|
||||||
|
w.hInstance = GetPrgRes()->GetInstance();
|
||||||
|
w.hIcon = LoadIcon(GetPrgRes()->GetInstance(), MAKEINTRESOURCE(IDI_ICON2));
|
||||||
|
w.hCursor = 0;
|
||||||
|
w.hbrBackground = (HBRUSH)(COLOR_BACKGROUND+1);
|
||||||
|
w.lpszMenuName = MAKEINTRESOURCE(IDR_MENU2);
|
||||||
|
w.lpszClassName = ttcalc_pad_class_name;
|
||||||
|
|
||||||
|
return RegisterClass(&w);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Pad
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool CreatePadWindow()
|
||||||
|
{
|
||||||
|
using namespace Pad;
|
||||||
|
|
||||||
|
static char ttcalc_pad_class_name[] = "TTCalcPadWindow";
|
||||||
|
ATOM a = RegisterPadClass(ttcalc_pad_class_name);
|
||||||
|
|
||||||
|
if( a == 0 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool pad_maximized_from_file = GetPrgRes()->GetPadMaximized();
|
||||||
|
// CreateWindow() would change maximizing
|
||||||
|
|
||||||
|
Languages * pl = GetPrgRes()->GetLanguages();
|
||||||
|
|
||||||
|
font = CreateFont(0, 0, 0, 0, FW_NORMAL, false, false, false,
|
||||||
|
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||||
|
DEFAULT_QUALITY, DEFAULT_PITCH, "Ms Shell Dlg");
|
||||||
|
|
||||||
|
|
||||||
|
HWND pad = CreateWindowEx(WS_EX_CLIENTEDGE, ttcalc_pad_class_name,
|
||||||
|
pl->GuiMessage(Languages::pad_title),
|
||||||
|
WS_OVERLAPPEDWINDOW | WS_POPUPWINDOW ,
|
||||||
|
GetPrgRes()->GetPadXPos(), GetPrgRes()->GetPadYPos(),
|
||||||
|
GetPrgRes()->GetPadXSize(), GetPrgRes()->GetPadYSize(),
|
||||||
|
0 /*GetPrgRes()->GetMainWindow()*/, 0, GetPrgRes()->GetInstance(), 0);
|
||||||
|
|
||||||
|
GetPrgRes()->SetPadWindow(pad);
|
||||||
|
SetPadLanguage();
|
||||||
|
GetPrgRes()->SetPadMaximized( pad_maximized_from_file );
|
||||||
|
GetPrgRes()->ShowPad( GetPrgRes()->IsPadVisible() );
|
||||||
|
|
||||||
|
return pad!=0 && edit!=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DestroyPadWindow()
|
||||||
|
{
|
||||||
|
using namespace Pad;
|
||||||
|
|
||||||
|
DeleteObject(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SetPadLanguage()
|
||||||
|
{
|
||||||
|
using namespace Pad;
|
||||||
|
|
||||||
|
HWND pad = GetPrgRes()->GetPadWindow();
|
||||||
|
Languages * pl = GetPrgRes()->GetLanguages();
|
||||||
|
|
||||||
|
SetPadMenuLanguage(pad);
|
||||||
|
SetWindowText(pad, pl->GuiMessage(Languages::pad_title));
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
|
* and is distributed under the (new) BSD licence.
|
||||||
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 headerfilepad
|
||||||
|
#define headerfilepad
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool CreatePadWindow();
|
||||||
|
void DestroyPadWindow();
|
||||||
|
void SetPadLanguage();
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -42,14 +42,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ParserManager::ParserManager() : buffer_len(2048)
|
ParserManager::ParserManager() : buffer_len(20480)
|
||||||
{
|
{
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
base_input = base_output = 10;
|
|
||||||
always_scientific = 0;
|
|
||||||
when_scientific = 15;
|
|
||||||
rounding = -1;
|
|
||||||
remove_zeroes = true;
|
|
||||||
last_variables_id = 0;
|
last_variables_id = 0;
|
||||||
last_functions_id = 0;
|
last_functions_id = 0;
|
||||||
}
|
}
|
||||||
|
@ -57,15 +52,7 @@ ParserManager::ParserManager() : buffer_len(2048)
|
||||||
|
|
||||||
ParserManager::ParserManager(const ParserManager & p) : buffer_len(p.buffer_len)
|
ParserManager::ParserManager(const ParserManager & p) : buffer_len(p.buffer_len)
|
||||||
{
|
{
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
base_input = p.base_input;
|
|
||||||
base_output = p.base_output;
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,6 +76,8 @@ ttmath::ErrorCode ParserManager::GetLastCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ttmath::ErrorCode ParserManager::Parse()
|
ttmath::ErrorCode ParserManager::Parse()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -98,29 +87,21 @@ ttmath::ErrorCode ParserManager::Parse()
|
||||||
switch( precision )
|
switch( precision )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
parser1.SetBase(base_input);
|
Parse(parser1);
|
||||||
parser1.SetDegRadGrad(angle_deg_rad_grad);
|
|
||||||
code = parser1.Parse(buffer);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
parser2.SetBase(base_input);
|
Parse(parser2);
|
||||||
parser2.SetDegRadGrad(angle_deg_rad_grad);
|
|
||||||
code = parser2.Parse(buffer);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
parser3.SetBase(base_input);
|
Parse(parser3);
|
||||||
parser3.SetDegRadGrad(angle_deg_rad_grad);
|
|
||||||
code = parser3.Parse(buffer);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
parser1.SetBase(base_input);
|
Parse(parser1);
|
||||||
parser1.SetDegRadGrad(angle_deg_rad_grad);
|
|
||||||
code = parser1.Parse(buffer);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -158,10 +139,9 @@ unsigned int i;
|
||||||
last_functions_id = GetPrgRes()->GetFunctionsId();
|
last_functions_id = GetPrgRes()->GetFunctionsId();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
base_input = GetPrgRes()->GetBaseInput();
|
|
||||||
base_output = GetPrgRes()->GetBaseOutput();
|
|
||||||
|
|
||||||
|
base_input = GetPrgRes()->GetBaseInput();
|
||||||
|
base_output = GetPrgRes()->GetBaseOutput();
|
||||||
always_scientific = GetPrgRes()->GetDisplayAlwaysScientific();
|
always_scientific = GetPrgRes()->GetDisplayAlwaysScientific();
|
||||||
when_scientific = GetPrgRes()->GetDisplayWhenScientific();
|
when_scientific = GetPrgRes()->GetDisplayWhenScientific();
|
||||||
rounding = GetPrgRes()->GetDisplayRounding();
|
rounding = GetPrgRes()->GetDisplayRounding();
|
||||||
|
@ -169,14 +149,15 @@ unsigned int i;
|
||||||
remove_zeroes = GetPrgRes()->GetRemovingZeroes();
|
remove_zeroes = GetPrgRes()->GetRemovingZeroes();
|
||||||
angle_deg_rad_grad = GetPrgRes()->GetDegRadGrad();
|
angle_deg_rad_grad = GetPrgRes()->GetDegRadGrad();
|
||||||
country = GetPrgRes()->GetLanguages()->GetCurrentLanguage();
|
country = GetPrgRes()->GetLanguages()->GetCurrentLanguage();
|
||||||
|
decimal_point = GetPrgRes()->GetDecimalPointChar();
|
||||||
|
grouping = GetPrgRes()->GetGroupingChar();
|
||||||
|
grouping_digits = GetPrgRes()->GetGroupingDigits();
|
||||||
|
param_sep = GetPrgRes()->GetParamSepChar();
|
||||||
|
|
||||||
|
GetPrgRes()->GetInputDecimalPointChar(&input_comma1, &input_comma2);
|
||||||
|
|
||||||
conv_type = GetPrgRes()->GetConvert()->GetCurrentType();
|
conv_type = GetPrgRes()->GetConvert()->GetCurrentType();
|
||||||
GetPrgRes()->GetConvert()->GetCurrentUnit(conv_type, conv_input_unit, conv_output_unit);
|
GetPrgRes()->GetConvert()->GetCurrentUnit(conv_type, conv_input_unit, conv_output_unit);
|
||||||
|
|
||||||
if( GetPrgRes()->GetDecimalPoint() == 0 )
|
|
||||||
decimal_point = '.';
|
|
||||||
else
|
|
||||||
decimal_point = ',';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -110,7 +110,6 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#ifndef TTCALC_PORTABLE
|
#ifndef TTCALC_PORTABLE
|
||||||
|
|
||||||
ttmath::Parser<TTMathBig1> parser1;
|
ttmath::Parser<TTMathBig1> parser1;
|
||||||
ttmath::Parser<TTMathBig2> parser2;
|
ttmath::Parser<TTMathBig2> parser2;
|
||||||
ttmath::Parser<TTMathBig3> parser3;
|
ttmath::Parser<TTMathBig3> parser3;
|
||||||
|
@ -135,9 +134,16 @@ private:
|
||||||
int precision;
|
int precision;
|
||||||
Languages::Country country;
|
Languages::Country country;
|
||||||
ttmath::ErrorCode code;
|
ttmath::ErrorCode code;
|
||||||
char decimal_point;
|
|
||||||
int angle_deg_rad_grad;
|
int angle_deg_rad_grad;
|
||||||
|
|
||||||
|
char decimal_point;
|
||||||
|
char grouping;
|
||||||
|
char input_comma1;
|
||||||
|
char input_comma2;
|
||||||
|
char param_sep;
|
||||||
|
|
||||||
|
int grouping_digits;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
some buffers which we use in some method in the second thread,
|
some buffers which we use in some method in the second thread,
|
||||||
it's better to have those buffers outside those methods -
|
it's better to have those buffers outside those methods -
|
||||||
|
@ -193,7 +199,18 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( result.ToString(buffer2,base_output, always_scientific, when_scientific, rounding, remove_zeroes, decimal_point) )
|
ttmath::Conv conv;
|
||||||
|
|
||||||
|
conv.base = base_output;
|
||||||
|
conv.scient = always_scientific;
|
||||||
|
conv.scient_from = when_scientific;
|
||||||
|
conv.round = rounding;
|
||||||
|
conv.trim_zeroes = remove_zeroes;
|
||||||
|
conv.comma = decimal_point;
|
||||||
|
conv.group = grouping;
|
||||||
|
conv.group_digits = grouping_digits;
|
||||||
|
|
||||||
|
if( result.ToString(buffer2, conv) )
|
||||||
{
|
{
|
||||||
// we shouldn't have had this error in the new version of ToStrign(...)
|
// we shouldn't have had this error in the new version of ToStrign(...)
|
||||||
// (where we're using a bigger type for calculating)
|
// (where we're using a bigger type for calculating)
|
||||||
|
@ -209,7 +226,7 @@ private:
|
||||||
AddOutputSuffix(buffer1);
|
AddOutputSuffix(buffer1);
|
||||||
|
|
||||||
if( i < matparser.stack.size()-1 )
|
if( i < matparser.stack.size()-1 )
|
||||||
buffer1 += " ";
|
buffer1 += " ; ";
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDlgItemText(GetPrgRes()->GetMainWindow(),IDC_OUTPUT_EDIT,buffer1.c_str());
|
SetDlgItemText(GetPrgRes()->GetMainWindow(),IDC_OUTPUT_EDIT,buffer1.c_str());
|
||||||
|
@ -217,6 +234,18 @@ private:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class ValueType>
|
||||||
|
void Parse(ttmath::Parser<ValueType> & matparser)
|
||||||
|
{
|
||||||
|
matparser.SetBase(base_input);
|
||||||
|
matparser.SetDegRadGrad(angle_deg_rad_grad);
|
||||||
|
matparser.SetComma(input_comma1, input_comma2);
|
||||||
|
matparser.SetGroup(grouping);
|
||||||
|
matparser.SetParamSep(param_sep);
|
||||||
|
code = matparser.Parse(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -100,6 +100,50 @@ int ProgramResources::GetYSize()
|
||||||
return y_size;
|
return y_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::SetPadXPos(int x)
|
||||||
|
{
|
||||||
|
pad_x_pos = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgramResources::SetPadYPos(int y)
|
||||||
|
{
|
||||||
|
pad_y_pos = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ProgramResources::GetPadXPos()
|
||||||
|
{
|
||||||
|
return pad_x_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ProgramResources::GetPadYPos()
|
||||||
|
{
|
||||||
|
return pad_y_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgramResources::SetPadXSize(int x)
|
||||||
|
{
|
||||||
|
pad_x_size = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgramResources::SetPadYSize(int y)
|
||||||
|
{
|
||||||
|
pad_y_size = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ProgramResources::GetPadXSize()
|
||||||
|
{
|
||||||
|
return pad_x_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ProgramResources::GetPadYSize()
|
||||||
|
{
|
||||||
|
return pad_y_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ProgramResources::SetYSizeNormal(int y)
|
void ProgramResources::SetYSizeNormal(int y)
|
||||||
{
|
{
|
||||||
y_size_normal = y;
|
y_size_normal = y;
|
||||||
|
@ -151,11 +195,6 @@ ProgramResources::View ProgramResources::GetView()
|
||||||
void ProgramResources::SetMaximized(bool max)
|
void ProgramResources::SetMaximized(bool max)
|
||||||
{
|
{
|
||||||
maximized = max;
|
maximized = max;
|
||||||
|
|
||||||
if( maximized )
|
|
||||||
ShowWindow(main_window, SW_SHOWMAXIMIZED);
|
|
||||||
else
|
|
||||||
ShowWindow(main_window, SW_SHOWNORMAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -164,6 +203,42 @@ bool ProgramResources::GetMaximized()
|
||||||
return maximized;
|
return maximized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgramResources::SetPadMaximized(bool max)
|
||||||
|
{
|
||||||
|
pad_maximized = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ProgramResources::GetPadMaximized()
|
||||||
|
{
|
||||||
|
return pad_maximized;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::ShowPad(bool show)
|
||||||
|
{
|
||||||
|
show_pad = show;
|
||||||
|
|
||||||
|
if( show_pad )
|
||||||
|
{
|
||||||
|
if( pad_maximized )
|
||||||
|
ShowWindow(pad_window, SW_SHOWMAXIMIZED);
|
||||||
|
else
|
||||||
|
ShowWindow(pad_window, SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowWindow(pad_window, SW_HIDE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ProgramResources::IsPadVisible()
|
||||||
|
{
|
||||||
|
return show_pad;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ProgramResources::SetAlwaysOnTop(bool always)
|
void ProgramResources::SetAlwaysOnTop(bool always)
|
||||||
{
|
{
|
||||||
always_on_top = always;
|
always_on_top = always;
|
||||||
|
@ -306,8 +381,78 @@ int ProgramResources::GetDecimalPoint()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char ProgramResources::GetDecimalPointChar()
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
|
||||||
|
if( GetDecimalPoint() == 0 )
|
||||||
|
c = '.';
|
||||||
|
else
|
||||||
|
c = ',';
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char ProgramResources::GetGroupingChar()
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
|
||||||
|
// grouping
|
||||||
|
static char group_table[] = "\0 `'.,"; // 5 items
|
||||||
|
|
||||||
|
int g = GetGrouping();
|
||||||
|
|
||||||
|
if( g>=0 && g<=5 )
|
||||||
|
c = group_table[g];
|
||||||
|
else
|
||||||
|
c = 0;
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::GetInputDecimalPointChar(char * comma1, char * comma2)
|
||||||
|
{
|
||||||
|
// input decimal point
|
||||||
|
switch( GetInputDecimalPoint() )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
*comma1 = '.';
|
||||||
|
*comma2 = ',';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
*comma1 = '.';
|
||||||
|
*comma2 = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
default:
|
||||||
|
*comma1 = ',';
|
||||||
|
*comma2 = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char ProgramResources::GetParamSepChar()
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
|
||||||
|
// additional param separator
|
||||||
|
static char param_table[] = ";.,"; // 3 items
|
||||||
|
|
||||||
|
int sep = GetParamSep();
|
||||||
|
|
||||||
|
if( sep>=0 && sep<=3 )
|
||||||
|
c = param_table[sep];
|
||||||
|
else
|
||||||
|
c = ';';
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
ttmath::Objects * ProgramResources::GetVariables()
|
ttmath::Objects * ProgramResources::GetVariables()
|
||||||
{
|
{
|
||||||
|
@ -376,6 +521,26 @@ HWND ProgramResources::GetMainWindow()
|
||||||
return main_window;
|
return main_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgramResources::SetPadWindow(HWND h)
|
||||||
|
{
|
||||||
|
pad_window = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
HWND ProgramResources::GetPadWindow()
|
||||||
|
{
|
||||||
|
return pad_window;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgramResources::SetPadEdit(HWND h)
|
||||||
|
{
|
||||||
|
pad_edit = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
HWND ProgramResources::GetPadEdit()
|
||||||
|
{
|
||||||
|
return pad_edit;
|
||||||
|
}
|
||||||
|
|
||||||
void ProgramResources::SetTabWindow(unsigned int id, HWND h)
|
void ProgramResources::SetTabWindow(unsigned int id, HWND h)
|
||||||
{
|
{
|
||||||
if( id >= sizeof(tab_window) / sizeof(HWND) )
|
if( id >= sizeof(tab_window) / sizeof(HWND) )
|
||||||
|
@ -402,6 +567,11 @@ char * ProgramResources::GetBuffer()
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char * ProgramResources::GetBufferTemp()
|
||||||
|
{
|
||||||
|
return buffer_temp;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int ProgramResources::GetBufferSize()
|
unsigned int ProgramResources::GetBufferSize()
|
||||||
{
|
{
|
||||||
return buffer_size;
|
return buffer_size;
|
||||||
|
@ -429,16 +599,115 @@ int ProgramResources::GetPrecision()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::SetGrouping(int g)
|
||||||
|
{
|
||||||
|
grouping = g;
|
||||||
|
|
||||||
|
if( grouping<0 || grouping>5 )
|
||||||
|
g = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ProgramResources::GetGrouping()
|
||||||
|
{
|
||||||
|
return grouping;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::SetGroupingDigits(int digits)
|
||||||
|
{
|
||||||
|
grouping_digits = digits;
|
||||||
|
|
||||||
|
if( grouping_digits < 1 || grouping_digits > 9 )
|
||||||
|
grouping_digits = 3; // 3 by default
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ProgramResources::GetGroupingDigits()
|
||||||
|
{
|
||||||
|
return grouping_digits;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::SetInputDecimalPoint(int p)
|
||||||
|
{
|
||||||
|
input_decimal_point = p;
|
||||||
|
|
||||||
|
if( input_decimal_point<0 || input_decimal_point>2 )
|
||||||
|
decimal_point = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ProgramResources::GetInputDecimalPoint()
|
||||||
|
{
|
||||||
|
return input_decimal_point;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::SetParamSep(int s)
|
||||||
|
{
|
||||||
|
param_sep = s;
|
||||||
|
|
||||||
|
if( param_sep<0 || param_sep>2 )
|
||||||
|
param_sep = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ProgramResources::GetParamSep()
|
||||||
|
{
|
||||||
|
return param_sep;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::SetCheckUpdateStartup(bool s)
|
||||||
|
{
|
||||||
|
check_update_startup = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ProgramResources::GetCheckUpdateStartup()
|
||||||
|
{
|
||||||
|
return check_update_startup;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::SetUpdateExists(bool e)
|
||||||
|
{
|
||||||
|
update_exists = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ProgramResources::GetUpdateExists()
|
||||||
|
{
|
||||||
|
return update_exists;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::SetLastUpdate(time_t t)
|
||||||
|
{
|
||||||
|
last_update = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
time_t ProgramResources::GetLastUpdate()
|
||||||
|
{
|
||||||
|
return last_update;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ProgramResources::ProgramResources()
|
ProgramResources::ProgramResources()
|
||||||
{
|
{
|
||||||
// if you want to change the input buffer you have also to change
|
// if you want to change the input buffer you have to also change
|
||||||
// ParserManager::ParserManager() : buffer_len(2048) in parsermanager.cpp
|
// ParserManager::ParserManager() : buffer_len(20480) in parsermanager.cpp
|
||||||
buffer_size = 2048;
|
buffer_size = 20480;
|
||||||
|
|
||||||
buffer = new char[buffer_size];
|
buffer = new char[buffer_size];
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
|
|
||||||
|
buffer_temp = new char[buffer_size];
|
||||||
|
buffer_temp[0] = 0;
|
||||||
|
|
||||||
always_on_top = false;
|
always_on_top = false;
|
||||||
view = view_normal;
|
view = view_normal;
|
||||||
|
@ -449,6 +718,8 @@ ProgramResources::ProgramResources()
|
||||||
|
|
||||||
hInstance = 0;
|
hInstance = 0;
|
||||||
main_window = 0;
|
main_window = 0;
|
||||||
|
pad_window = 0;
|
||||||
|
pad_edit = 0;
|
||||||
|
|
||||||
base_input = 10;
|
base_input = 10;
|
||||||
base_output = 10;
|
base_output = 10;
|
||||||
|
@ -466,6 +737,12 @@ ProgramResources::ProgramResources()
|
||||||
x_size = 100;
|
x_size = 100;
|
||||||
y_size = 100;
|
y_size = 100;
|
||||||
|
|
||||||
|
pad_x_pos = 30;
|
||||||
|
pad_y_pos = 30;
|
||||||
|
pad_x_size = 600;
|
||||||
|
pad_y_size = 500;
|
||||||
|
pad_maximized = false;
|
||||||
|
|
||||||
y_size_normal = 0;
|
y_size_normal = 0;
|
||||||
y_size_compact = 0;
|
y_size_compact = 0;
|
||||||
x_size_min = 0;
|
x_size_min = 0;
|
||||||
|
@ -476,17 +753,29 @@ ProgramResources::ProgramResources()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
decimal_point = 0;
|
decimal_point = 0; // output decimal point
|
||||||
angle_deg_rad_grad = 1; // rad is default
|
angle_deg_rad_grad = 1; // rad is default
|
||||||
|
grouping = 0;
|
||||||
|
grouping_digits = 3;
|
||||||
|
|
||||||
|
input_decimal_point = 0; // dot or comma
|
||||||
|
param_sep = 0;
|
||||||
|
|
||||||
variables_id = 0;
|
variables_id = 0;
|
||||||
functions_id = 0;
|
functions_id = 0;
|
||||||
|
|
||||||
|
show_pad = false;
|
||||||
|
check_update_startup = true;
|
||||||
|
update_exists = false; // for dynamic menu
|
||||||
|
|
||||||
|
last_update = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ProgramResources::~ProgramResources()
|
ProgramResources::~ProgramResources()
|
||||||
{
|
{
|
||||||
delete [] buffer;
|
delete [] buffer;
|
||||||
|
delete [] buffer_temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -552,6 +841,12 @@ return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const std::string & ProgramResources::GetHelpFile()
|
||||||
|
{
|
||||||
|
return help_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ProgramResources::ReadTextValueFromRegistry(HKEY main_key, const char * sub_key, const char * value, std::string & result)
|
bool ProgramResources::ReadTextValueFromRegistry(HKEY main_key, const char * sub_key, const char * value, std::string & result)
|
||||||
{
|
{
|
||||||
HKEY reg_key;
|
HKEY reg_key;
|
||||||
|
@ -579,61 +874,95 @@ return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
void ProgramResources::SetNameOfConfigurationFile()
|
setting names of:
|
||||||
|
- configuration file
|
||||||
|
- help file
|
||||||
|
*/
|
||||||
|
void ProgramResources::SetNameOfFiles()
|
||||||
{
|
{
|
||||||
static const char simple_file_name[] = "ttcalc.ini";
|
char buffer[_MAX_PATH];
|
||||||
|
static const char conf_name[] = "ttcalc.ini";
|
||||||
|
static const char help_name[] = "ttcalc.chm";
|
||||||
|
|
||||||
// if there'll be an error we assume that the current directory will be used
|
// if there'll be an error we assume that the current directory will be used
|
||||||
// (in the portable version the configuration file is in a current directory)
|
configuration_file = ".\\";
|
||||||
configuration_file = std::string(".\\") + simple_file_name;
|
configuration_file += conf_name;
|
||||||
|
help_file = ".\\";
|
||||||
|
help_file += help_name;
|
||||||
|
|
||||||
#ifndef TTCALC_PORTABLE
|
if( !GetCurrentDirectory(_MAX_PATH, buffer) )
|
||||||
|
return;
|
||||||
|
|
||||||
static const char simple_directory_name[] = "TTCalc";
|
help_file = buffer;
|
||||||
std::string application_data;
|
help_file += '\\';
|
||||||
|
help_file += help_name;
|
||||||
|
|
||||||
|
#ifdef TTCALC_PORTABLE
|
||||||
|
|
||||||
|
configuration_file = buffer;
|
||||||
|
configuration_file += '\\';
|
||||||
|
configuration_file += conf_name;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static const char dir_name[] = "TTCalc";
|
||||||
|
std::string app_data;
|
||||||
|
|
||||||
// we're trying to read the value "AppData" from registry
|
// we're trying to read the value "AppData" from registry
|
||||||
// which can be, for instance, as:
|
// which can be, for instance, as:
|
||||||
// "C:\Documents and Settings\user\data application" on WinNT
|
// "C:\Documents and Settings\user\data application" on WinNT
|
||||||
// or "C:\Windows\Data Application\" on Win9x
|
// or "C:\Windows\Data Application\" on Win9x
|
||||||
|
|
||||||
|
// we don't use SHGetFolderLocation() because it is not available on Win9x
|
||||||
|
|
||||||
if( ReadTextValueFromRegistry(
|
if( ReadTextValueFromRegistry(
|
||||||
HKEY_CURRENT_USER,
|
HKEY_CURRENT_USER,
|
||||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
|
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
|
||||||
"AppData",
|
"AppData",
|
||||||
application_data) )
|
app_data) )
|
||||||
{
|
{
|
||||||
std::string application_directory = application_data + '\\' + simple_directory_name;
|
std::string app_dir = app_data + '\\' + dir_name;
|
||||||
bool success = false;
|
|
||||||
|
|
||||||
// we have to remember the currect directory
|
if( CreateDirIfNotExists(app_dir) )
|
||||||
// (because we're using it when we're opening the help)
|
configuration_file = app_dir + '\\' + conf_name;
|
||||||
char * buffer = new char[_MAX_PATH];
|
|
||||||
|
|
||||||
if( GetCurrentDirectory(_MAX_PATH, buffer) )
|
|
||||||
{
|
|
||||||
// we're testing whether we've got our directory or not
|
|
||||||
if( SetCurrentDirectory( application_directory.c_str() ) )
|
|
||||||
success = true;
|
|
||||||
else
|
|
||||||
// now we must create our directory inside it
|
|
||||||
if( CreateDirectory(application_directory.c_str(), 0) )
|
|
||||||
success = true;
|
|
||||||
|
|
||||||
if( success )
|
|
||||||
configuration_file = application_directory + '\\' + simple_file_name;
|
|
||||||
|
|
||||||
SetCurrentDirectory(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete [] buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
it is used when 'createconfig' parameter has been passed to the ttcalc program
|
||||||
|
*/
|
||||||
|
void ProgramResources::SetConfigName()
|
||||||
|
{
|
||||||
|
configuration_file = "ttcalc.ini";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool ProgramResources::CreateDirIfNotExists(const std::string & app_dir)
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
|
||||||
|
if( SetCurrentDirectory( app_dir.c_str() ) )
|
||||||
|
{
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( CreateDirectory(app_dir.c_str(), 0) )
|
||||||
|
{
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ProgramResources::CheckCoordinates()
|
void ProgramResources::CheckCoordinates()
|
||||||
{
|
{
|
||||||
if( x_pos < -50 )
|
if( x_pos < -50 )
|
||||||
|
@ -664,6 +993,35 @@ void ProgramResources::CheckCoordinates()
|
||||||
y_pos = cy - y_size;
|
y_pos = cy - y_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgramResources::CheckPadCoordinates()
|
||||||
|
{
|
||||||
|
if( pad_x_pos < -50 )
|
||||||
|
pad_x_pos = 0;
|
||||||
|
|
||||||
|
if( pad_y_pos < -50 )
|
||||||
|
pad_y_pos = 0;
|
||||||
|
|
||||||
|
if( pad_x_size < 30 )
|
||||||
|
pad_x_size = 600;
|
||||||
|
|
||||||
|
if( pad_y_size < 30 )
|
||||||
|
pad_y_size = 500;
|
||||||
|
|
||||||
|
int cx = GetSystemMetrics(SM_CXSCREEN);
|
||||||
|
int cy = GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
|
||||||
|
if( pad_x_size > cx+10 )
|
||||||
|
pad_x_size = cx;
|
||||||
|
|
||||||
|
if( pad_y_size > cy+10 )
|
||||||
|
pad_y_size = cy;
|
||||||
|
|
||||||
|
if( pad_x_pos > cx-50 )
|
||||||
|
pad_x_pos = cx - pad_x_size;
|
||||||
|
|
||||||
|
if( pad_y_pos > cy-50 )
|
||||||
|
pad_y_pos = cy - pad_y_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ProgramResources::AddVariablesFunctions( IniParser::Section & temp_variables,
|
void ProgramResources::AddVariablesFunctions( IniParser::Section & temp_variables,
|
||||||
|
@ -741,12 +1099,14 @@ return err;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IniParser::Error ProgramResources::ReadFromFile()
|
IniParser::Error ProgramResources::ReadFromFile()
|
||||||
{
|
{
|
||||||
IniParser iparser;
|
IniParser iparser;
|
||||||
IniParser::Section temp_variables, temp_functions;
|
IniParser::Section temp_variables, temp_functions;
|
||||||
IniParser::Section::iterator ic;
|
IniParser::Section::iterator ic;
|
||||||
std::string ini_value[20];
|
std::string ini_value[30];
|
||||||
|
std::string language_setup;
|
||||||
|
|
||||||
iparser.ConvertValueToSmallLetters(false);
|
iparser.ConvertValueToSmallLetters(false);
|
||||||
iparser.SectionCaseSensitive(false);
|
iparser.SectionCaseSensitive(false);
|
||||||
|
@ -754,6 +1114,7 @@ std::string ini_value[20];
|
||||||
// we have variables and functions case-sensitive
|
// we have variables and functions case-sensitive
|
||||||
iparser.PatternCaseSensitive(true);
|
iparser.PatternCaseSensitive(true);
|
||||||
|
|
||||||
|
iparser.Associate( "global|language.setup", &language_setup );
|
||||||
iparser.Associate( "global|always.on.top", &ini_value[0] );
|
iparser.Associate( "global|always.on.top", &ini_value[0] );
|
||||||
iparser.Associate( "global|view", &ini_value[1] );
|
iparser.Associate( "global|view", &ini_value[1] );
|
||||||
iparser.Associate( "global|maximized", &ini_value[2] );
|
iparser.Associate( "global|maximized", &ini_value[2] );
|
||||||
|
@ -768,9 +1129,21 @@ std::string ini_value[20];
|
||||||
iparser.Associate( "global|disp.rounding", &ini_value[11] );
|
iparser.Associate( "global|disp.rounding", &ini_value[11] );
|
||||||
iparser.Associate( "global|size.y", &ini_value[12] );
|
iparser.Associate( "global|size.y", &ini_value[12] );
|
||||||
iparser.Associate( "global|language", &ini_value[13] );
|
iparser.Associate( "global|language", &ini_value[13] );
|
||||||
iparser.Associate( "global|disp.dec.point", &ini_value[14] );
|
iparser.Associate( "global|disp.output_comma", &ini_value[14] );
|
||||||
iparser.Associate( "global|disp.remove.zeroes", &ini_value[15] );
|
iparser.Associate( "global|disp.remove.zeroes", &ini_value[15] );
|
||||||
iparser.Associate( "global|disp.deg_rad_grad", &ini_value[16] );
|
iparser.Associate( "global|disp.deg_rad_grad", &ini_value[16] );
|
||||||
|
iparser.Associate( "global|pad.x", &ini_value[17] );
|
||||||
|
iparser.Associate( "global|pad.y", &ini_value[18] );
|
||||||
|
iparser.Associate( "global|pad.size.x", &ini_value[19] );
|
||||||
|
iparser.Associate( "global|pad.size.y", &ini_value[20] );
|
||||||
|
iparser.Associate( "global|pad.maximized", &ini_value[21] );
|
||||||
|
iparser.Associate( "global|pad", &ini_value[22] );
|
||||||
|
iparser.Associate( "global|disp.grouping", &ini_value[23] );
|
||||||
|
iparser.Associate( "global|disp.input_comma", &ini_value[24] );
|
||||||
|
iparser.Associate( "global|disp.param_sep", &ini_value[25] );
|
||||||
|
iparser.Associate( "global|update.onstartup", &ini_value[26] );
|
||||||
|
iparser.Associate( "global|update.last", &ini_value[27] );
|
||||||
|
iparser.Associate( "global|disp.grouping.digits", &ini_value[28] );
|
||||||
|
|
||||||
iparser.Associate( "variables", &temp_variables );
|
iparser.Associate( "variables", &temp_variables );
|
||||||
iparser.Associate( "functions", &temp_functions );
|
iparser.Associate( "functions", &temp_functions );
|
||||||
|
@ -781,55 +1154,94 @@ std::string ini_value[20];
|
||||||
if( err == IniParser::err_cant_open_file )
|
if( err == IniParser::err_cant_open_file )
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
AddVariablesFunctions(temp_variables, temp_functions, false);
|
|
||||||
|
|
||||||
// we're setting various values
|
|
||||||
always_on_top = bool( atoi(ini_value[0].c_str()) );
|
|
||||||
view = atoi(ini_value[1].c_str()) == 0 ? view_normal : view_compact;
|
|
||||||
maximized = bool( atoi(ini_value[2].c_str()) );
|
|
||||||
|
|
||||||
x_pos = atoi( ini_value[3].c_str() );
|
|
||||||
y_pos = atoi( ini_value[4].c_str() );
|
|
||||||
x_size = atoi( ini_value[5].c_str() );
|
|
||||||
y_size = atoi( ini_value[12].c_str() );
|
|
||||||
CheckCoordinates();
|
|
||||||
|
|
||||||
SetPrecision( atoi(ini_value[6].c_str()) );
|
|
||||||
SetBaseInput( atoi(ini_value[7].c_str()) );
|
|
||||||
SetBaseOutput( atoi(ini_value[8].c_str()) );
|
|
||||||
|
|
||||||
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] == "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 )
|
if( err != IniParser::err_ok )
|
||||||
bad_line = iparser.GetBadLine();
|
bad_line = iparser.GetBadLine();
|
||||||
|
|
||||||
|
AddVariablesFunctions(temp_variables, temp_functions, false);
|
||||||
|
|
||||||
|
// the first file is created by the installer and has only language.setup option
|
||||||
|
// if the rest options are not set then we are not calling ReadGlobalSection()
|
||||||
|
if( IsGlobalSectionSet(ini_value, sizeof(ini_value)/sizeof(std::string)) )
|
||||||
|
ReadGlobalSection(ini_value);
|
||||||
|
|
||||||
|
if( !language_setup.empty() )
|
||||||
|
languages.SelectCurrentLanguage(language_setup); // we don't have to remember this variable
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ProgramResources::Int(const std::string & text)
|
||||||
|
{
|
||||||
|
return atoi(text.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ProgramResources::IsGlobalSectionSet(std::string * ini_value, size_t len)
|
||||||
|
{
|
||||||
|
for(size_t i=0 ; i<len ; ++i)
|
||||||
|
if( !ini_value[i].empty() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::ReadGlobalSection(std::string * ini_value)
|
||||||
|
{
|
||||||
|
always_on_top = Int(ini_value[0]) == 1;
|
||||||
|
view = Int(ini_value[1]) == 0 ? view_normal : view_compact;
|
||||||
|
maximized = Int(ini_value[2]) == 1;
|
||||||
|
|
||||||
|
x_pos = Int( ini_value[3] );
|
||||||
|
y_pos = Int( ini_value[4] );
|
||||||
|
x_size = Int( ini_value[5] );
|
||||||
|
y_size = Int( ini_value[12] );
|
||||||
|
CheckCoordinates();
|
||||||
|
|
||||||
|
SetPrecision( Int(ini_value[6]) );
|
||||||
|
SetBaseInput( Int(ini_value[7]) );
|
||||||
|
SetBaseOutput( Int(ini_value[8]) );
|
||||||
|
|
||||||
|
SetDisplayAlwaysScientific( Int(ini_value[9]) == 1 );
|
||||||
|
SetDisplayWhenScientific( Int(ini_value[10]) );
|
||||||
|
SetDisplayRounding( Int(ini_value[11]) );
|
||||||
|
|
||||||
|
languages.SetCurrentLanguage((Languages::Country)Int(ini_value[13]));
|
||||||
|
SetDecimalPoint( Int(ini_value[14]) );
|
||||||
|
|
||||||
|
// remove zeroes - if there is not in the config then will be true by default
|
||||||
|
// (from the constructor)
|
||||||
|
if( !ini_value[15].empty() )
|
||||||
|
SetRemovingZeroes( Int(ini_value[15]) == 1 );
|
||||||
|
|
||||||
|
SetDegRadGrad( Int(ini_value[16]) );
|
||||||
|
|
||||||
|
pad_x_pos = Int( ini_value[17] );
|
||||||
|
pad_y_pos = Int( ini_value[18] );
|
||||||
|
pad_x_size = Int( ini_value[19] );
|
||||||
|
pad_y_size = Int( ini_value[20] );
|
||||||
|
pad_maximized = Int(ini_value[21]) == 1;
|
||||||
|
show_pad = Int(ini_value[22]) == 1;
|
||||||
|
CheckPadCoordinates();
|
||||||
|
|
||||||
|
SetGrouping( Int(ini_value[23]) );
|
||||||
|
SetInputDecimalPoint( Int(ini_value[24]) );
|
||||||
|
SetParamSep( Int(ini_value[25]) );
|
||||||
|
|
||||||
|
// check update once a three day - true by default (if there is not in the config)
|
||||||
|
// (default from the constructor)
|
||||||
|
if( !ini_value[26].empty() )
|
||||||
|
check_update_startup = Int(ini_value[26]) == 1;
|
||||||
|
|
||||||
|
last_update = (time_t)atol(ini_value[27].c_str());
|
||||||
|
SetGroupingDigits( Int(ini_value[28]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ProgramResources::SaveToFile()
|
void ProgramResources::SaveToFile()
|
||||||
{
|
{
|
||||||
|
@ -843,24 +1255,36 @@ std::ofstream file( configuration_file.c_str() );
|
||||||
|
|
||||||
file << "always.on.top = " << (int)always_on_top << std::endl;
|
file << "always.on.top = " << (int)always_on_top << std::endl;
|
||||||
file << "view = " << (int)view << std::endl;
|
file << "view = " << (int)view << std::endl;
|
||||||
file << "maximized = " << (int)maximized << std::endl;
|
file << "language = " << (int)languages.GetCurrentLanguage()
|
||||||
|
<< std::endl;
|
||||||
file << "x = " << x_pos << std::endl;
|
file << "x = " << x_pos << std::endl;
|
||||||
file << "y = " << y_pos << std::endl;
|
file << "y = " << y_pos << std::endl;
|
||||||
file << "size.x = " << x_size << std::endl;
|
file << "size.x = " << x_size << std::endl;
|
||||||
file << "size.y = " << y_size << std::endl;
|
file << "size.y = " << y_size << std::endl;
|
||||||
|
file << "maximized = " << (int)maximized << std::endl;
|
||||||
|
file << "update.onstartup = " << (int)check_update_startup << std::endl;
|
||||||
|
file << "update.last = " << (long)last_update << std::endl;
|
||||||
|
file << "pad = " << (int)show_pad << std::endl;
|
||||||
|
file << "pad.x = " << pad_x_pos << std::endl;
|
||||||
|
file << "pad.y = " << pad_y_pos << std::endl;
|
||||||
|
file << "pad.size.x = " << pad_x_size << std::endl;
|
||||||
|
file << "pad.size.y = " << pad_y_size << std::endl;
|
||||||
|
file << "pad.maximized = " << (int)pad_maximized << std::endl;
|
||||||
file << "precision = " << precision << std::endl;
|
file << "precision = " << precision << std::endl;
|
||||||
file << "disp.input = " << base_input << std::endl;
|
file << "disp.input = " << base_input << std::endl;
|
||||||
file << "disp.output = " << base_output << std::endl;
|
file << "disp.output = " << base_output << std::endl;
|
||||||
file << "language = " << static_cast<int>(languages.GetCurrentLanguage())
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
file << "disp.alw.scientific = " << (int)display_always_scientific << std::endl;
|
file << "disp.alw.scientific = " << (int)display_always_scientific << std::endl;
|
||||||
file << "disp.when.scientific = " << display_when_scientific << std::endl;
|
file << "disp.when.scientific = " << display_when_scientific << std::endl;
|
||||||
file << "disp.rounding = " << display_rounding << std::endl;
|
file << "disp.rounding = " << display_rounding << std::endl;
|
||||||
file << "disp.remove.zeroes = " << (int)remove_zeroes << std::endl;
|
file << "disp.remove.zeroes = " << (int)remove_zeroes << std::endl;
|
||||||
file << "disp.dec.point = " << decimal_point << std::endl;
|
file << "disp.input_comma = " << input_decimal_point << std::endl;
|
||||||
|
file << "disp.output_comma = " << decimal_point << std::endl;
|
||||||
file << "disp.deg_rad_grad = " << angle_deg_rad_grad << std::endl;
|
file << "disp.deg_rad_grad = " << angle_deg_rad_grad << std::endl;
|
||||||
|
file << "disp.grouping = " << grouping << std::endl;
|
||||||
|
file << "disp.grouping.digits = " << grouping_digits << std::endl;
|
||||||
|
file << "disp.param_sep = " << param_sep << std::endl;
|
||||||
|
|
||||||
|
|
||||||
file << "\n[variables]\n";
|
file << "\n[variables]\n";
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -43,16 +43,30 @@
|
||||||
\brief various kinds of objects using by the application
|
\brief various kinds of objects using by the application
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ttmath/ttmathobjects.h>
|
#include "compileconfig.h"
|
||||||
#include "iniparser.h"
|
#include "iniparser.h"
|
||||||
#include "languages.h"
|
#include "languages.h"
|
||||||
#include "threadcontroller.h"
|
#include "threadcontroller.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
|
|
||||||
|
#include <ttmath/ttmathobjects.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
some messages
|
||||||
|
*/
|
||||||
|
#define WM_INIT_TAB_VARIABLES WM_APP
|
||||||
|
#define WM_INIT_TAB_FUNCTIONS WM_APP+1
|
||||||
|
#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
|
||||||
|
#define WM_UPDATE_EXISTS WM_APP+6
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -110,6 +124,19 @@ public:
|
||||||
int GetYSize();
|
int GetYSize();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
position of the left top corner of the pad window and its size
|
||||||
|
*/
|
||||||
|
void SetPadXPos(int x);
|
||||||
|
void SetPadYPos(int y);
|
||||||
|
int GetPadXPos();
|
||||||
|
int GetPadYPos();
|
||||||
|
void SetPadXSize(int x);
|
||||||
|
void SetPadYSize(int y);
|
||||||
|
int GetPadXSize();
|
||||||
|
int GetPadYSize();
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
size of the main window when 'normal view' is selected
|
size of the main window when 'normal view' is selected
|
||||||
*/
|
*/
|
||||||
|
@ -145,6 +172,12 @@ public:
|
||||||
bool GetMaximized();
|
bool GetMaximized();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
maximizing of the pad window
|
||||||
|
*/
|
||||||
|
void SetPadMaximized(bool max);
|
||||||
|
bool GetPadMaximized();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
the main window is always on top or not
|
the main window is always on top or not
|
||||||
*/
|
*/
|
||||||
|
@ -198,6 +231,12 @@ public:
|
||||||
HWND GetMainWindow();
|
HWND GetMainWindow();
|
||||||
|
|
||||||
|
|
||||||
|
void SetPadWindow(HWND h);
|
||||||
|
HWND GetPadWindow();
|
||||||
|
|
||||||
|
void SetPadEdit(HWND h);
|
||||||
|
HWND GetPadEdit();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
handles to the dialogs which are placed on the tab control
|
handles to the dialogs which are placed on the tab control
|
||||||
*/
|
*/
|
||||||
|
@ -261,6 +300,7 @@ public:
|
||||||
Languages * GetLanguages();
|
Languages * GetLanguages();
|
||||||
Convert * GetConvert();
|
Convert * GetConvert();
|
||||||
char * GetBuffer();
|
char * GetBuffer();
|
||||||
|
char * GetBufferTemp(); // this buffer can be used for temporary tasks
|
||||||
unsigned int GetBufferSize();
|
unsigned int GetBufferSize();
|
||||||
|
|
||||||
|
|
||||||
|
@ -294,9 +334,28 @@ public:
|
||||||
will be in a special directory for a particular user, for example:
|
will be in a special directory for a particular user, for example:
|
||||||
"C:\Documents and Settings\user\applitacion data"
|
"C:\Documents and Settings\user\applitacion data"
|
||||||
*/
|
*/
|
||||||
void SetNameOfConfigurationFile();
|
void SetNameOfFiles();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
it is used when 'createconfig' parameter has been passed to the ttcalc program
|
||||||
|
*/
|
||||||
|
void SetConfigName();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returning the name of the help file
|
||||||
|
SetNameOfFiles() should be used first
|
||||||
|
*/
|
||||||
|
const std::string & GetHelpFile();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returning true if such a dir exists
|
||||||
|
if not the method is trying to create it and returns true if it is created
|
||||||
|
*/
|
||||||
|
bool CreateDirIfNotExists(const std::string & app_dir);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
reading and writing to a file
|
reading and writing to a file
|
||||||
|
|
||||||
|
@ -313,14 +372,6 @@ public:
|
||||||
*/
|
*/
|
||||||
int GetBadLine();
|
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
|
setting and returning the state of removing trailing zeroes
|
||||||
|
@ -339,6 +390,112 @@ public:
|
||||||
void SetDegRadGrad(int angle);
|
void SetDegRadGrad(int angle);
|
||||||
int GetDegRadGrad();
|
int GetDegRadGrad();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
is the pad window is visible then the method hides it (and vice versa)
|
||||||
|
*/
|
||||||
|
void ShowPad(bool show);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returning true if the pad window is visible
|
||||||
|
*/
|
||||||
|
bool IsPadVisible();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
setting/getting the group character
|
||||||
|
0 - none
|
||||||
|
1 - space
|
||||||
|
2 - '`'
|
||||||
|
3 - '\''
|
||||||
|
4 - '.'
|
||||||
|
5 - ','
|
||||||
|
*/
|
||||||
|
void SetGrouping(int g);
|
||||||
|
int GetGrouping();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
setting/getting how many digits should be groupped
|
||||||
|
digits can be from 1 to 9
|
||||||
|
*/
|
||||||
|
void SetGroupingDigits(int digits);
|
||||||
|
int GetGroupingDigits();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returning the grouping character
|
||||||
|
*/
|
||||||
|
char GetGroupingChar();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
setting/getting the input decimal point
|
||||||
|
0 - dot or comma, 1 - dot, 2 - comma
|
||||||
|
*/
|
||||||
|
void SetInputDecimalPoint(int p);
|
||||||
|
int GetInputDecimalPoint();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returning the input decimal point characters
|
||||||
|
*/
|
||||||
|
void GetInputDecimalPointChar(char * comma1, char * comma2);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
setting and returning the decimal point used during printig values
|
||||||
|
0 - '.'
|
||||||
|
1 - ','
|
||||||
|
*/
|
||||||
|
void SetDecimalPoint(int decimal);
|
||||||
|
int GetDecimalPoint();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returning the decimal point char (used during printig values)
|
||||||
|
*/
|
||||||
|
char GetDecimalPointChar();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
setting/getting the separator of function arguments
|
||||||
|
0 - semicolon, 1 - semicolon or dot, 2 - semicolon or comma
|
||||||
|
*/
|
||||||
|
void SetParamSep(int s);
|
||||||
|
int GetParamSep();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returning the character of param separator
|
||||||
|
either a semicolon, dot or comma
|
||||||
|
*/
|
||||||
|
char GetParamSepChar();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
setting/getting the test which is made when the program starts
|
||||||
|
(testing for an update)
|
||||||
|
*/
|
||||||
|
void SetCheckUpdateStartup(bool s);
|
||||||
|
bool GetCheckUpdateStartup();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
true if there is an update available
|
||||||
|
(used only with the dynamic menu)
|
||||||
|
*/
|
||||||
|
void SetUpdateExists(bool e);
|
||||||
|
bool GetUpdateExists();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
setting/getting the time of the last update
|
||||||
|
*/
|
||||||
|
void SetLastUpdate(time_t t);
|
||||||
|
time_t GetLastUpdate();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool IsWhiteCharacter(int c);
|
bool IsWhiteCharacter(int c);
|
||||||
|
@ -346,8 +503,11 @@ private:
|
||||||
bool IsDecDigit(int c);
|
bool IsDecDigit(int c);
|
||||||
bool SplitFunction(const std::string & input, const char * * name, int * param);
|
bool SplitFunction(const std::string & input, const char * * name, int * param);
|
||||||
void CheckCoordinates();
|
void CheckCoordinates();
|
||||||
|
void CheckPadCoordinates();
|
||||||
void AddVariablesFunctions(IniParser::Section & temp_variables, IniParser::Section & temp_functions, bool if_not_exist);
|
void AddVariablesFunctions(IniParser::Section & temp_variables, IniParser::Section & temp_functions, bool if_not_exist);
|
||||||
|
void ReadGlobalSection(std::string * ini_value);
|
||||||
|
int Int(const std::string & text);
|
||||||
|
bool IsGlobalSectionSet(std::string * ini_value, size_t len);
|
||||||
|
|
||||||
ttmath::Objects variables;
|
ttmath::Objects variables;
|
||||||
ttmath::Objects functions;
|
ttmath::Objects functions;
|
||||||
|
@ -360,9 +520,12 @@ private:
|
||||||
|
|
||||||
unsigned int buffer_size;
|
unsigned int buffer_size;
|
||||||
char * buffer;
|
char * buffer;
|
||||||
|
char * buffer_temp;
|
||||||
|
|
||||||
HINSTANCE hInstance;
|
HINSTANCE hInstance;
|
||||||
HWND main_window;
|
HWND main_window;
|
||||||
|
HWND pad_window;
|
||||||
|
HWND pad_edit; // edit control on the pad window
|
||||||
HWND tab_window[6];
|
HWND tab_window[6];
|
||||||
|
|
||||||
int precision;
|
int precision;
|
||||||
|
@ -371,6 +534,7 @@ private:
|
||||||
View view;
|
View view;
|
||||||
|
|
||||||
std::string configuration_file;
|
std::string configuration_file;
|
||||||
|
std::string help_file;
|
||||||
|
|
||||||
int y_size_normal;
|
int y_size_normal;
|
||||||
int y_size_compact;
|
int y_size_compact;
|
||||||
|
@ -381,6 +545,12 @@ private:
|
||||||
int x_size;
|
int x_size;
|
||||||
int y_size;
|
int y_size;
|
||||||
|
|
||||||
|
int pad_x_pos;
|
||||||
|
int pad_y_pos;
|
||||||
|
int pad_x_size;
|
||||||
|
int pad_y_size;
|
||||||
|
bool pad_maximized;
|
||||||
|
|
||||||
int base_input;
|
int base_input;
|
||||||
int base_output;
|
int base_output;
|
||||||
|
|
||||||
|
@ -391,9 +561,17 @@ private:
|
||||||
int display_rounding;
|
int display_rounding;
|
||||||
bool remove_zeroes;
|
bool remove_zeroes;
|
||||||
int angle_deg_rad_grad;
|
int angle_deg_rad_grad;
|
||||||
|
int grouping; // 0 - none, 1 - space, 2 - '`', 3 - '\'', 4 - '.', 5 - ','
|
||||||
|
int grouping_digits; // from 1 to 9
|
||||||
|
int input_decimal_point; // 0 - dot or comma, 1 - dot, 2 - comma
|
||||||
|
int param_sep; // parameters separator: 0 - semicolon, 1 - dot, 2 - comma
|
||||||
|
|
||||||
int bad_line;
|
int bad_line;
|
||||||
|
bool show_pad;
|
||||||
|
|
||||||
|
bool check_update_startup;
|
||||||
|
bool update_exists;
|
||||||
|
time_t last_update;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
113
src/resource.h
113
src/resource.h
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -50,6 +50,7 @@
|
||||||
|
|
||||||
#define IDD_MAIN_DIALOG 101
|
#define IDD_MAIN_DIALOG 101
|
||||||
#define IDD_ABOUT_DIALOG 200
|
#define IDD_ABOUT_DIALOG 200
|
||||||
|
#define IDD_UPDATE_DIALOG 210
|
||||||
#define IDD_DIALOG_ADD_VARIABLE 102
|
#define IDD_DIALOG_ADD_VARIABLE 102
|
||||||
#define IDD_DIALOG_ADD_FUNCTION 103
|
#define IDD_DIALOG_ADD_FUNCTION 103
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@
|
||||||
#define IDD_DIALOG_CONVERT 115
|
#define IDD_DIALOG_CONVERT 115
|
||||||
|
|
||||||
#define IDR_MENU 200
|
#define IDR_MENU 200
|
||||||
|
#define IDR_MENU2 201
|
||||||
#define IDC_TAB 1010
|
#define IDC_TAB 1010
|
||||||
#define IDI_ICON2 104
|
#define IDI_ICON2 104
|
||||||
#define IDI_ICON1 105
|
#define IDI_ICON1 105
|
||||||
|
@ -82,7 +84,6 @@
|
||||||
#define IDC_BUTTON_SGN 1075
|
#define IDC_BUTTON_SGN 1075
|
||||||
#define IDC_BUTTON_MOD 1076
|
#define IDC_BUTTON_MOD 1076
|
||||||
|
|
||||||
|
|
||||||
// values from IDC_BUTTON_PRESS_0 to IDC_BUTTON_PRESS_9 should be with the step equal one
|
// values from IDC_BUTTON_PRESS_0 to IDC_BUTTON_PRESS_9 should be with the step equal one
|
||||||
#define IDC_BUTTON_PRESS_0 1100
|
#define IDC_BUTTON_PRESS_0 1100
|
||||||
#define IDC_BUTTON_PRESS_1 1101
|
#define IDC_BUTTON_PRESS_1 1101
|
||||||
|
@ -116,6 +117,19 @@
|
||||||
#define IDC_BUTTON_INT 1129
|
#define IDC_BUTTON_INT 1129
|
||||||
#define IDC_BUTTON_ROUND 1130
|
#define IDC_BUTTON_ROUND 1130
|
||||||
#define IDC_BUTTON_EXP 1131
|
#define IDC_BUTTON_EXP 1131
|
||||||
|
#define IDC_BUTTON_SQRT 1400
|
||||||
|
#define IDC_BUTTON_BRACKETS_ALL 1401
|
||||||
|
#define IDC_BUTTON_1DIV_BRACKETS_ALL 1402
|
||||||
|
#define IDC_BUTTON_SEMICOLON 1403
|
||||||
|
#define IDC_BUTTON_PERCENTAGE 1404
|
||||||
|
#define IDC_BUTTON_FLOOR 1405
|
||||||
|
#define IDC_BUTTON_CEIL 1406
|
||||||
|
#define IDC_BUTTON_MIN 1407
|
||||||
|
#define IDC_BUTTON_MAX 1408
|
||||||
|
#define IDC_BUTTON_AVG 1409
|
||||||
|
#define IDC_BUTTON_SUM 1410
|
||||||
|
#define IDC_BUTTON_ROOT 1411
|
||||||
|
#define IDC_BUTTON_GAMMA 1412
|
||||||
|
|
||||||
|
|
||||||
// variables tab
|
// variables tab
|
||||||
|
@ -154,21 +168,27 @@
|
||||||
// display tab
|
// display tab
|
||||||
#define IDC_COMBO_DISPLAY_INPUT 1156
|
#define IDC_COMBO_DISPLAY_INPUT 1156
|
||||||
#define IDC_COMBO_DISPLAY_OUTPUT 1157
|
#define IDC_COMBO_DISPLAY_OUTPUT 1157
|
||||||
#define IDC_COMBO_DISPLAY_ROUNDING 1159
|
#define IDC_COMBO_DISPLAY_ROUNDING 1158
|
||||||
#define IDC_RADIO_DISPLAY_ALWAYS_SCIENTIFIC 1160
|
#define IDC_RADIO_DISPLAY_ALWAYS_SCIENTIFIC 1159
|
||||||
#define IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC 1161
|
#define IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC 1160
|
||||||
#define IDC_LABEL_DISPLAY_INPUT 1162
|
#define IDC_LABEL_DISPLAY_INPUT 1161
|
||||||
#define IDC_LABEL_DISPLAY_OUTPUT 1163
|
#define IDC_LABEL_DISPLAY_OUTPUT 1162
|
||||||
#define IDC_LABEL_DISPLAY_ROUNDING 1164
|
#define IDC_LABEL_DISPLAY_ROUNDING 1163
|
||||||
#define IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC 1165
|
#define IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC 1164
|
||||||
#define IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC 1166
|
#define IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC 1165
|
||||||
#define IDC_LABEL_GROUP_SCIENTIFIC 1168
|
#define IDC_LABEL_DISPLAY_SCIENTIFIC 1166
|
||||||
#define IDC_LABEL_DECIMAL_POINT 1169
|
#define IDC_LABEL_OUTPUT_DECIMAL_POINT 1167
|
||||||
#define IDC_COMBO_DECIMAL_POINT 1170
|
#define IDC_COMBO_OUTPUT_DECIMAL_POINT 1168
|
||||||
#define IDC_CHECK_REMOVE_ZEROES 1171
|
#define IDC_CHECK_REMOVE_ZEROES 1169
|
||||||
#define IDC_LABEL_DISPLAY_DEG_RAD_GRAD 1172
|
#define IDC_LABEL_DISPLAY_DEG_RAD_GRAD 1170
|
||||||
#define IDC_COMBO_DEG_RAD_GRAD 1173
|
#define IDC_COMBO_DEG_RAD_GRAD 1171
|
||||||
|
#define IDC_COMBO_DISPLAY_GROUPING 1172
|
||||||
|
#define IDC_COMBO_DISPLAY_GROUPING_DIGITS 1173
|
||||||
|
#define IDC_LABEL_DISPLAY_GROUPING 1174
|
||||||
|
#define IDC_COMBO_INPUT_DECIMAL_POINT 1175
|
||||||
|
#define IDC_LABEL_INPUT_DECIMAL_POINT 1176
|
||||||
|
#define IDC_LABEL_PARAM_SEPARATE 1177
|
||||||
|
#define IDC_COMBO_PARAM_SEPARATE 1178
|
||||||
|
|
||||||
// convert tab
|
// convert tab
|
||||||
#define IDC_LIST_UNIT_TYPE 1200
|
#define IDC_LIST_UNIT_TYPE 1200
|
||||||
|
@ -187,27 +207,70 @@
|
||||||
#define IDM_VIEW_INDEX 0
|
#define IDM_VIEW_INDEX 0
|
||||||
#define IDM_EDIT_INDEX 1
|
#define IDM_EDIT_INDEX 1
|
||||||
#define IDM_HELP_INDEX 2
|
#define IDM_HELP_INDEX 2
|
||||||
#define IDM_LANGUAGE_INDEX 6
|
#define IDM_UPDATE_AVAILABLE_INDEX 3
|
||||||
|
|
||||||
|
#define IDM_LANGUAGE_INDEX 8
|
||||||
|
|
||||||
#define IDM_NEW_WINDOW 40001
|
#define IDM_NEW_WINDOW 40001
|
||||||
#define IDM_NORMAL_VIEW 40002
|
#define IDM_NORMAL_VIEW 40002
|
||||||
#define IDM_COMPACT_VIEW 40003
|
#define IDM_COMPACT_VIEW 40003
|
||||||
#define IDM_ALWAYS_ON_TOP 40004
|
#define IDM_PAD 40004
|
||||||
|
#define IDM_ALWAYS_ON_TOP 40005
|
||||||
#define IDM_LANGUAGE_ENGLISH 40010
|
#define IDM_LANGUAGE_ENGLISH 40010
|
||||||
#define IDM_LANGUAGE_POLISH 40011
|
#define IDM_LANGUAGE_POLISH 40011
|
||||||
#define IDM_LANGUAGE_SPANISH 40012
|
#define IDM_LANGUAGE_SPANISH 40012
|
||||||
#define IDM_LANGUAGE_DANISH 40013
|
#define IDM_LANGUAGE_DANISH 40013
|
||||||
#define IDM_LANGUAGE_CHINESE 40014
|
#define IDM_LANGUAGE_CHINESE 40014
|
||||||
#define IDM_LANGUAGE_RUSSIAN 40015
|
#define IDM_LANGUAGE_RUSSIAN 40015
|
||||||
|
#define IDM_LANGUAGE_SWEDISH 40016
|
||||||
|
#define IDM_LANGUAGE_ITALIAN 40017
|
||||||
|
#define IDM_LANGUAGE_GERMAN 40018
|
||||||
#define IDM_CLOSE_PROGRAM 40020
|
#define IDM_CLOSE_PROGRAM 40020
|
||||||
|
|
||||||
#define IDM_EDIT_UNDO 40030
|
#define IDM_EDIT_UNDO 40030
|
||||||
#define IDM_EDIT_PASTE 40031
|
#define IDM_EDIT_CUT 40031
|
||||||
#define IDM_EDIT_COPY_RESULT 40032
|
#define IDM_EDIT_COPY 40032
|
||||||
#define IDM_HELP_HELP 40040
|
#define IDM_EDIT_PASTE 40033
|
||||||
#define IDM_HELP_PROJECT_PAGE 40041
|
#define IDM_EDIT_DEL 40034
|
||||||
#define IDM_HELP_ABOUT 40049
|
#define IDM_EDIT_COPY_RESULT 40035
|
||||||
|
#define IDM_EDIT_COPY_BOTH 40036
|
||||||
|
#define IDM_EDIT_PASTE_FORMULA 40037
|
||||||
|
#define IDM_EDIT_SELECT_ALL 40038
|
||||||
|
#define IDM_EDIT_BRACKET 40039
|
||||||
|
#define IDM_EDIT_SWAP 40040
|
||||||
|
|
||||||
|
#define IDM_HELP_HELP 40050
|
||||||
|
#define IDM_HELP_PROJECT_PAGE 40051
|
||||||
|
#define IDM_HELP_CHECK_UPDATE 40052
|
||||||
|
#define IDM_HELP_ABOUT 40053
|
||||||
|
|
||||||
|
#define IDM_UPDATE_AVAILABLE 40060
|
||||||
|
|
||||||
|
// pad menu
|
||||||
|
#define MENUPAD_FILE_INDEX 0
|
||||||
|
#define MENUPAD_EDIT_INDEX 1
|
||||||
|
#define MENUPAD_FILE_NEW 40500
|
||||||
|
#define MENUPAD_FILE_OPEN 40501
|
||||||
|
#define MENUPAD_FILE_SAVE 40502
|
||||||
|
#define MENUPAD_FILE_CLOSE 40503
|
||||||
|
#define MENUPAD_EDIT_UNDO 40510
|
||||||
|
#define MENUPAD_EDIT_CUT 40511
|
||||||
|
#define MENUPAD_EDIT_COPY 40512
|
||||||
|
#define MENUPAD_EDIT_PASTE 40513
|
||||||
|
#define MENUPAD_EDIT_DEL 40514
|
||||||
|
#define MENUPAD_EDIT_SELECTALL 40515
|
||||||
|
|
||||||
|
|
||||||
// about dialog
|
// about dialog
|
||||||
#define IDC_ABOUT_TEXT 1200
|
#define IDC_ABOUT_TEXT 1200
|
||||||
#define IDB_BITMAP_ABOUT 1201
|
#define IDB_BITMAP_ABOUT 1201
|
||||||
|
|
||||||
|
// update dialog
|
||||||
|
#define IDC_UPDATE_INFO1 1300
|
||||||
|
#define IDC_UPDATE_INFO2 1301
|
||||||
|
#define IDC_PROGRESS 1302
|
||||||
|
#define IDC_BUTTON_NEXT 1303
|
||||||
|
#define IDC_BUTTON_CANCEL 1304
|
||||||
|
#define IDC_CHECK_UPDATE_STURTUP 1305
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
403
src/resource.rc
403
src/resource.rc
|
@ -1,228 +1,310 @@
|
||||||
#define APSTUDIO_READONLY_SYMBOLS
|
//#define APSTUDIO_READONLY_SYMBOLS
|
||||||
//#include "afxres.h"
|
//#include "afxres.h"
|
||||||
#undef APSTUDIO_READONLY_SYMBOLS
|
//#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
LANGUAGE LANG_POLISH, 1
|
LANGUAGE LANG_POLISH, 1
|
||||||
104 ICON "..\\res\\icon02.ico"
|
IDI_ICON2 ICON "..\\res\\icon02.ico"
|
||||||
|
|
||||||
LANGUAGE LANG_POLISH, 2
|
LANGUAGE LANG_POLISH, 2
|
||||||
105 ICON "..\\res\\icon01.ico"
|
IDI_ICON1 ICON "..\\res\\icon01.ico"
|
||||||
|
|
||||||
#include "resource.h"
|
|
||||||
|
|
||||||
LANGUAGE LANG_NEUTRAL, 0
|
LANGUAGE LANG_NEUTRAL, 0
|
||||||
200 MENU
|
200 MENU
|
||||||
FIXED IMPURE LOADONCALL DISCARDABLE
|
FIXED IMPURE LOADONCALL DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
POPUP "&View"
|
POPUP "View"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "&New window", 40001
|
MENUITEM "New window", IDM_NEW_WINDOW
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "No&rmal", 40002
|
MENUITEM "Normal", IDM_NORMAL_VIEW
|
||||||
MENUITEM "&Compact", 40003
|
MENUITEM "Compact", IDM_COMPACT_VIEW
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "&Always on top", 40004
|
MENUITEM "Pad", IDM_PAD
|
||||||
POPUP "&Language"
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "Always on top", IDM_ALWAYS_ON_TOP
|
||||||
|
POPUP "Language"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "&English", 40010
|
MENUITEM "English", IDM_LANGUAGE_ENGLISH
|
||||||
MENUITEM "&Polish", 40011
|
MENUITEM "Polish", IDM_LANGUAGE_POLISH
|
||||||
MENUITEM "&Spanish", 40012
|
MENUITEM "Spanish", IDM_LANGUAGE_SPANISH
|
||||||
MENUITEM "&Danish", 40013
|
MENUITEM "Danish", IDM_LANGUAGE_DANISH
|
||||||
MENUITEM "&Chinese", 40014
|
MENUITEM "Chinese", IDM_LANGUAGE_CHINESE
|
||||||
MENUITEM "&Russian", 40015
|
MENUITEM "Russian", IDM_LANGUAGE_RUSSIAN
|
||||||
|
MENUITEM "Swedish", IDM_LANGUAGE_SWEDISH
|
||||||
|
MENUITEM "Italian", IDM_LANGUAGE_ITALIAN
|
||||||
|
MENUITEM "German", IDM_LANGUAGE_GERMAN
|
||||||
END
|
END
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "&Close", 40020
|
MENUITEM "Close", IDM_CLOSE_PROGRAM
|
||||||
END
|
END
|
||||||
POPUP "&Edit"
|
POPUP "Edit"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "&Undo", 40030
|
MENUITEM "Undo", IDM_EDIT_UNDO
|
||||||
MENUITEM "&Paste", 40031
|
|
||||||
MENUITEM "&Copy the result", 40032
|
|
||||||
END
|
|
||||||
POPUP "&Help"
|
|
||||||
BEGIN
|
|
||||||
MENUITEM "&Help", 40040
|
|
||||||
MENUITEM "&Project page", 40041
|
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "&About", 40049
|
MENUITEM "Cut", IDM_EDIT_CUT
|
||||||
|
MENUITEM "Copy", IDM_EDIT_COPY
|
||||||
|
MENUITEM "Paste", IDM_EDIT_PASTE
|
||||||
|
MENUITEM "Delete", IDM_EDIT_DEL
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "Copy result", IDM_EDIT_COPY_RESULT
|
||||||
|
MENUITEM "Copy both", IDM_EDIT_COPY_BOTH
|
||||||
|
MENUITEM "Paste formula", IDM_EDIT_PASTE_FORMULA
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "Select all", IDM_EDIT_SELECT_ALL
|
||||||
|
MENUITEM "Bracket", IDM_EDIT_BRACKET
|
||||||
|
MENUITEM "Swap", IDM_EDIT_SWAP
|
||||||
|
END
|
||||||
|
POPUP "Help"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "Help", IDM_HELP_HELP
|
||||||
|
MENUITEM "Project page", IDM_HELP_PROJECT_PAGE
|
||||||
|
MENUITEM "Check update...", IDM_HELP_CHECK_UPDATE
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "About", IDM_HELP_ABOUT
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
101 DIALOG 0, 0, 265, 150
|
|
||||||
STYLE DS_SETFONT |DS_CENTER |WS_POPUP |WS_SYSMENU |WS_THICKFRAME |WS_MAXIMIZEBOX |WS_MINIMIZEBOX |WS_CAPTION
|
IDR_MENU2 MENU DISCARDABLE
|
||||||
MENU 200
|
BEGIN
|
||||||
#ifndef TTCALC_PORTABLE
|
POPUP "File"
|
||||||
|
BEGIN
|
||||||
|
// MENUITEM "New", MENUPAD_FILE_NEW
|
||||||
|
// temporarily this option is not available
|
||||||
|
MENUITEM "Open...", MENUPAD_FILE_OPEN
|
||||||
|
MENUITEM "Save as...", MENUPAD_FILE_SAVE
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "Close", MENUPAD_FILE_CLOSE
|
||||||
|
END
|
||||||
|
POPUP "Edit"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "Undo \tCtrl+Z", MENUPAD_EDIT_UNDO
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "Cut \tCtrl+X", MENUPAD_EDIT_CUT
|
||||||
|
MENUITEM "Copy \tCtrl+C", MENUPAD_EDIT_COPY
|
||||||
|
MENUITEM "Paste \tCtrl+V", MENUPAD_EDIT_PASTE
|
||||||
|
MENUITEM "Delete \tDel", MENUPAD_EDIT_DEL
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "Select all \tCtrl+A", MENUPAD_EDIT_SELECTALL
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
IDD_MAIN_DIALOG DIALOGEX 0, 0, 295, 189
|
||||||
|
STYLE DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION |
|
||||||
|
WS_SYSMENU | WS_THICKFRAME
|
||||||
CAPTION "TTCalc"
|
CAPTION "TTCalc"
|
||||||
#else
|
MENU 200
|
||||||
CAPTION "TTCalc portable"
|
|
||||||
#endif
|
|
||||||
FONT 8, "Ms Shell Dlg"
|
FONT 8, "Ms Shell Dlg"
|
||||||
BEGIN
|
BEGIN
|
||||||
CONTROL "",1000,"EDIT",ES_AUTOHSCROLL |ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,0,6,260,14
|
EDITTEXT IDC_INPUT_EDIT,0,6,260,14,ES_AUTOHSCROLL
|
||||||
CONTROL "",1001,"EDIT",ES_READONLY |ES_AUTOHSCROLL |ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,0,21,260,14
|
EDITTEXT IDC_OUTPUT_EDIT,0,21,260,14,ES_AUTOHSCROLL | ES_READONLY
|
||||||
CONTROL "",1010,"SysTabControl32",WS_CHILD |WS_TABSTOP |WS_GROUP| WS_VISIBLE ,0,39,261,106, WS_EX_CONTROLPARENT
|
CONTROL "",IDC_TAB,"SysTabControl32",WS_GROUP | WS_TABSTOP,0,39,
|
||||||
|
292,123,WS_EX_CONTROLPARENT
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
102 DIALOG DISCARDABLE 0, 0, 358, 61
|
IDD_DIALOG_ADD_VARIABLE DIALOG DISCARDABLE 0, 0, 358, 61
|
||||||
STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE |
|
STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE |
|
||||||
WS_CAPTION | WS_SYSMENU
|
WS_CAPTION | WS_SYSMENU
|
||||||
CAPTION "Add a new variable"
|
CAPTION "Add a new variable"
|
||||||
FONT 8, "Ms Shell Dlg"
|
FONT 8, "Ms Shell Dlg"
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "Ok",1,291,10,50,14,BS_CENTER | BS_VCENTER
|
DEFPUSHBUTTON "Ok",IDOK,291,10,50,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "Cancel",2,291,28,50,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "Cancel",IDCANCEL,291,28,50,14,BS_CENTER | BS_VCENTER
|
||||||
EDITTEXT 1134,47,10,67,14,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_VARIABLE_NAME,47,10,67,14,ES_AUTOHSCROLL
|
||||||
EDITTEXT 1135,47,28,226,14,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_VARIABLE_VALUE,47,28,226,14,ES_AUTOHSCROLL
|
||||||
LTEXT "name:",1136,7,12,38,8
|
LTEXT "name:",IDC_STATIC_VARIABLE_NAME,7,12,38,8
|
||||||
LTEXT "value:",1137,7,30,38,8
|
LTEXT "value:",IDC_STATIC_VARIABLE_VALUE,7,30,38,8
|
||||||
END
|
END
|
||||||
|
|
||||||
103 DIALOG DISCARDABLE 0, 0, 370, 74
|
IDD_DIALOG_ADD_FUNCTION DIALOG DISCARDABLE 0, 0, 370, 74
|
||||||
STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE |
|
STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE |
|
||||||
WS_CAPTION | WS_SYSMENU
|
WS_CAPTION | WS_SYSMENU
|
||||||
FONT 8, "Ms Shell Dlg"
|
FONT 8, "Ms Shell Dlg"
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "Ok",1,304,10,50,14,BS_CENTER | BS_VCENTER
|
DEFPUSHBUTTON "Ok",IDOK,304,10,50,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "Cancel",2,304,27,50,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "Cancel",IDCANCEL,304,27,50,14,BS_CENTER | BS_VCENTER
|
||||||
EDITTEXT 1144,55,10,67,14,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_FUNCTION_NAME,55,10,67,14,ES_AUTOHSCROLL
|
||||||
COMBOBOX 1146,55,29,67,130,CBS_DROPDOWNLIST | WS_TABSTOP
|
COMBOBOX IDC_COMBO_FUNCTION_PARAM,55,29,67,130,CBS_DROPDOWNLIST | WS_TABSTOP
|
||||||
EDITTEXT 1145,55,47,299,14,ES_AUTOHSCROLL
|
EDITTEXT IDC_EDIT_FUNCTION_VALUE,55,47,299,14,ES_AUTOHSCROLL
|
||||||
LTEXT "name:",1147,7,12,46,8
|
LTEXT "name:",IDC_STATIC_FUNCTION_NAME,7,12,46,8
|
||||||
LTEXT "value:",1149,7,49,46,8
|
LTEXT "value:",IDC_STATIC_FUNCTION_VALUE,7,49,46,8
|
||||||
LTEXT "param:",1148,7,30,46,8
|
LTEXT "param:",IDC_STATIC_FUNCTION_PARAM,7,30,46,8
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
110 DIALOGEX 0, 0, 287, 90
|
IDD_DIALOG_STANDARD DIALOG DISCARDABLE 0, 0, 288, 107
|
||||||
STYLE DS_3DLOOK | DS_FIXEDSYS |DS_SETFONT | WS_CHILD| WS_TABSTOP |WS_GROUP
|
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_GROUP | WS_TABSTOP
|
||||||
FONT 8, "Ms Shell Dlg"
|
FONT 8, "Ms Shell Dlg"
|
||||||
BEGIN
|
BEGIN
|
||||||
PUSHBUTTON "Clear",1110,3,3,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "Clear",IDC_BUTTON_CLEAR,4,3,55,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "(",1111,33,3,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "(",IDC_BUTTON_FIRST_BRACKET,62,3,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON ")",1112,62,3,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON ")",IDC_BUTTON_LAST_BRACKET,91,3,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "^",1128,91,3,26,14,BS_CENTER | BS_BOTTOM
|
PUSHBUTTON "(...)",IDC_BUTTON_BRACKETS_ALL,4,20,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "7",1107,3,20,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON ";",IDC_BUTTON_SEMICOLON,33,20,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "8",1108,33,20,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "%",IDC_BUTTON_PERCENTAGE,62,20,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "9",1109,62,20,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "^",IDC_BUTTON_POWER,91,20,26,14,BS_CENTER | BS_BOTTOM
|
||||||
PUSHBUTTON "/",1113,91,20,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "7",IDC_BUTTON_PRESS_7,4,37,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "4",1104,3,37,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "8",IDC_BUTTON_PRESS_8,33,37,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "5",1105,33,37,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "9",IDC_BUTTON_PRESS_9,62,37,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "6",1106,62,37,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "/",IDC_BUTTON_DIV,91,37,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "*",1114,91,37,26,14,BS_CENTER | BS_BOTTOM
|
PUSHBUTTON "4",IDC_BUTTON_PRESS_4,4,54,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "1",1101,3,54,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "5",IDC_BUTTON_PRESS_5,33,54,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "2",1102,33,54,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "6",IDC_BUTTON_PRESS_6,62,54,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "3",1103,62,54,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "*",IDC_BUTTON_MUL,91,54,26,14,BS_CENTER | BS_BOTTOM
|
||||||
PUSHBUTTON "-",1115,91,54,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "1",IDC_BUTTON_PRESS_1,4,71,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "0",1100,3,71,56,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "2",IDC_BUTTON_PRESS_2,33,71,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON ",",1117,62,71,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "3",IDC_BUTTON_PRESS_3,62,71,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "+",1116,91,71,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "-",IDC_BUTTON_SUB,91,71,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "sin",1120,131,3,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "0",IDC_BUTTON_PRESS_0,4,88,55,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "asin",1071,160,3,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON ",",IDC_BUTTON_COMMA,62,88,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "ln",1124,189,3,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "+",IDC_BUTTON_ADD,91,88,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "cos",1121,131,20,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "sin",IDC_BUTTON_SIN,131,3,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "acos",1072,160,20,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "asin",IDC_BUTTON_ASIN,160,3,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "log",1125,189,20,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "ln",IDC_BUTTON_LN,189,3,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "tan",1122,131,37,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "cos",IDC_BUTTON_COS,131,20,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "atan",1073,160,37,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "acos",IDC_BUTTON_ACOS,160,20,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "exp",1131,189,37,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "log",IDC_BUTTON_LOG,189,20,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "cot",1123,131,54,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "tan",IDC_BUTTON_TAN,131,37,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "acot",1074,160,54,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "atan",IDC_BUTTON_ATAN,160,37,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "abs",1126,189,54,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "exp",IDC_BUTTON_EXP,189,37,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "int",1129,131,71,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "cot",IDC_BUTTON_COT,131,54,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "round",1130,160,71,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "acot",IDC_BUTTON_ACOT,160,54,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "!",1127,189,71,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "abs",IDC_BUTTON_ABS,189,54,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "sgn",1075,229,3,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "int",IDC_BUTTON_INT,131,71,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "mod",1076,229,20,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "round",IDC_BUTTON_ROUND,160,71,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "e",1118,229,37,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "mod",IDC_BUTTON_MOD,189,71,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "pi",1119,229,54,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "floor",IDC_BUTTON_FLOOR,131,88,26,14,BS_CENTER | BS_VCENTER
|
||||||
PUSHBUTTON "err",1070,229,71,26,14,BS_CENTER | BS_VCENTER
|
PUSHBUTTON "ceil",IDC_BUTTON_CEIL,160,88,26,14,BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "sgn",IDC_BUTTON_SGN,189,88,26,14,BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "min",IDC_BUTTON_MIN,229,3,26,14,BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "max",IDC_BUTTON_MAX,258,3,26,14,BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "avg",IDC_BUTTON_AVG,229,20,26,14,BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "sum",IDC_BUTTON_SUM,258,20,26,14,BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "sqrt",IDC_BUTTON_SQRT,229,37,26,14, BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "root",IDC_BUTTON_ROOT,258,37,26,14,BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "!",IDC_BUTTON_FACTORIAL,229,54,26,14,BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "gamma",IDC_BUTTON_GAMMA,258,54,26,14,BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "e",IDC_BUTTON_E,229,71,26,14,BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "pi",IDC_BUTTON_PI,258,71,26,14,BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "1/(...)",IDC_BUTTON_1DIV_BRACKETS_ALL,229,88,26,14,BS_CENTER | BS_VCENTER
|
||||||
|
PUSHBUTTON "err",IDC_BUTTON_ERROR,258,88,26,14,BS_CENTER | BS_VCENTER
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
111 DIALOG 0, 0, 287, 90
|
IDD_DIALOG_VARIABLES DIALOG 0, 0, 288, 107
|
||||||
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
|
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
|
||||||
CAPTION "tab2"
|
CAPTION "tab2"
|
||||||
FONT 8, "Ms Shell Dlg"
|
FONT 8, "Ms Shell Dlg"
|
||||||
BEGIN
|
BEGIN
|
||||||
CONTROL "Add",1133,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,3,50,14
|
CONTROL "Add",IDC_BUTTON_ADD_VARIABLE,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,3,50,14
|
||||||
CONTROL "Edit",1138,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,21,50,14
|
CONTROL "Edit",IDC_BUTTON_EDIT_VARIABLE,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,21,50,14
|
||||||
CONTROL "Delete",1139,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,39,50,14
|
CONTROL "Delete",IDC_BUTTON_DELETE_VARIABLE,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,39,50,14
|
||||||
CONTROL "",1132,"SysListView32",LVS_REPORT |LVS_SHOWSELALWAYS |LVS_SORTASCENDING |LVS_ALIGNLEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,57,3,223,85
|
CONTROL "",IDC_VARIABLES_LIST,"SysListView32",LVS_REPORT |LVS_SHOWSELALWAYS |LVS_SORTASCENDING |LVS_ALIGNLEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,57,3,223,85
|
||||||
END
|
END
|
||||||
|
|
||||||
112 DIALOG 0, 0, 287, 90
|
IDD_DIALOG_FUNCTIONS DIALOG 0, 0, 288, 107
|
||||||
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
|
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
|
||||||
CAPTION "tab3"
|
CAPTION "tab3"
|
||||||
FONT 8, "Ms Shell Dlg"
|
FONT 8, "Ms Shell Dlg"
|
||||||
BEGIN
|
BEGIN
|
||||||
CONTROL "Add",1140,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,3,50,14
|
CONTROL "Add",IDC_BUTTON_ADD_FUNCTION,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,3,50,14
|
||||||
CONTROL "Edit",1141,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,21,50,14
|
CONTROL "Edit",IDC_BUTTON_EDIT_FUNCTION,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,21,50,14
|
||||||
CONTROL "Delete",1142,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,39,50,14
|
CONTROL "Delete",IDC_BUTTON_DELETE_FUNCTION,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,39,50,14
|
||||||
CONTROL "",1143,"SysListView32",LVS_REPORT |LVS_SHOWSELALWAYS |LVS_SORTASCENDING |LVS_ALIGNLEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,57,3,223,85
|
CONTROL "",IDC_FUNCTIONS_LIST,"SysListView32",LVS_REPORT |LVS_SHOWSELALWAYS |LVS_SORTASCENDING |LVS_ALIGNLEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,57,3,223,85
|
||||||
END
|
END
|
||||||
|
|
||||||
#ifndef TTCALC_PORTABLE
|
#ifndef TTCALC_PORTABLE
|
||||||
|
|
||||||
113 DIALOG 0, 0, 287, 90
|
IDD_DIALOG_PRECISION DIALOG DISCARDABLE 0, 0, 288, 107
|
||||||
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 "tab4"
|
CAPTION "tab4"
|
||||||
FONT 8, "Ms Shell Dlg"
|
FONT 8, "Ms Shell Dlg"
|
||||||
BEGIN
|
BEGIN
|
||||||
CONTROL "precision 1",1150,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD |WS_GROUP|WS_TABSTOP | WS_VISIBLE ,15,4,252,10
|
CONTROL "precision 1",IDC_RADIO_PRECISION_1,"Button",
|
||||||
CONTROL "precision 2",1151,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD |WS_TABSTOP | WS_VISIBLE ,15,33,252,10
|
BS_AUTORADIOBUTTON | BS_LEFT | WS_GROUP | WS_TABSTOP,21,
|
||||||
CONTROL "precision 3",1152,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD |WS_TABSTOP | WS_VISIBLE ,15,62,252,10
|
11,256,10
|
||||||
CONTROL "info 1",1153,"STATIC",SS_LEFT |WS_CHILD |WS_VISIBLE ,28,17,245,8
|
CONTROL "precision 2",IDC_RADIO_PRECISION_2,"Button",
|
||||||
CONTROL "info 2",1154,"STATIC",SS_LEFT |WS_CHILD |WS_VISIBLE ,28,46,245,8
|
BS_AUTORADIOBUTTON | BS_LEFT | WS_TABSTOP,21,42,256,10
|
||||||
CONTROL "info 3",1155,"STATIC",SS_LEFT |WS_CHILD |WS_VISIBLE ,28,74,245,8
|
CONTROL "precision 3",IDC_RADIO_PRECISION_3,"Button",
|
||||||
|
BS_AUTORADIOBUTTON | BS_LEFT | WS_TABSTOP,21,73,256,10
|
||||||
|
LTEXT "info 1",IDC_LABEL_PRECISION_1_INFO,34,24,243,8,NOT
|
||||||
|
WS_GROUP
|
||||||
|
LTEXT "info 2",IDC_LABEL_PRECISION_2_INFO,34,55,243,8,NOT
|
||||||
|
WS_GROUP
|
||||||
|
LTEXT "info 3",IDC_LABEL_PRECISION_3_INFO,34,85,243,8,NOT
|
||||||
|
WS_GROUP
|
||||||
END
|
END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
114 DIALOG DISCARDABLE 0, 0, 255, 90
|
IDD_DIALOG_DISPLAY DIALOG DISCARDABLE 0, 0, 288, 107
|
||||||
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | WS_GROUP |
|
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | WS_GROUP |
|
||||||
WS_TABSTOP
|
WS_TABSTOP
|
||||||
CAPTION "tab5"
|
CAPTION "tab5"
|
||||||
FONT 8, "Ms Shell Dlg"
|
FONT 8, "Ms Shell Dlg"
|
||||||
BEGIN
|
BEGIN
|
||||||
COMBOBOX 1156,58,5,58,200,CBS_DROPDOWNLIST | WS_GROUP |
|
CONTROL "Input base",IDC_LABEL_DISPLAY_INPUT,"Static",
|
||||||
|
SS_LEFTNOWORDWRAP | WS_GROUP,8,4,43,8
|
||||||
|
CONTROL "Output base",IDC_LABEL_DISPLAY_OUTPUT,"Static",
|
||||||
|
SS_LEFTNOWORDWRAP | WS_GROUP,8,18,43,8
|
||||||
|
CONTROL "Rounding",IDC_LABEL_DISPLAY_ROUNDING,"Static",
|
||||||
|
SS_LEFTNOWORDWRAP | WS_GROUP,8,32,43,8
|
||||||
|
CONTROL "Grouping",IDC_LABEL_DISPLAY_GROUPING,"Static",SS_LEFTNOWORDWRAP |
|
||||||
|
WS_GROUP,8,46,43,8
|
||||||
|
CONTROL "Input decimal point",IDC_LABEL_INPUT_DECIMAL_POINT,
|
||||||
|
"Static",SS_LEFTNOWORDWRAP | WS_GROUP,143,4,87,8
|
||||||
|
CONTROL "Output decimal point",IDC_LABEL_OUTPUT_DECIMAL_POINT,"Static",
|
||||||
|
SS_LEFTNOWORDWRAP | WS_GROUP,143,18,87,8
|
||||||
|
CONTROL "Parameters separated by",IDC_LABEL_PARAM_SEPARATE,
|
||||||
|
"Static",SS_LEFTNOWORDWRAP | WS_GROUP,143,32,87,8
|
||||||
|
CONTROL "trigonometric functions",IDC_LABEL_DISPLAY_DEG_RAD_GRAD,
|
||||||
|
"Static",SS_LEFTNOWORDWRAP | WS_GROUP,143,46,87,8
|
||||||
|
COMBOBOX IDC_COMBO_DISPLAY_INPUT,61,2,59,200,CBS_DROPDOWNLIST |
|
||||||
|
WS_GROUP | WS_TABSTOP
|
||||||
|
COMBOBOX IDC_COMBO_DISPLAY_OUTPUT,61,16,59,200,CBS_DROPDOWNLIST |
|
||||||
WS_TABSTOP
|
WS_TABSTOP
|
||||||
COMBOBOX 1157,58,19,58,200,CBS_DROPDOWNLIST | WS_TABSTOP
|
COMBOBOX IDC_COMBO_DISPLAY_ROUNDING,61,30,59,200,CBS_DROPDOWNLIST |
|
||||||
CONTROL "Input",1162,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,11,7,
|
WS_TABSTOP
|
||||||
43,8
|
COMBOBOX IDC_COMBO_DISPLAY_GROUPING,61,44,59,100,CBS_DROPDOWNLIST |
|
||||||
CONTROL "Output",1163,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,11,
|
WS_VSCROLL | WS_TABSTOP
|
||||||
22,43,8
|
COMBOBOX IDC_COMBO_DISPLAY_GROUPING_DIGITS,61,58,59,100,CBS_DROPDOWNLIST |
|
||||||
COMBOBOX 1159,58,33,58,200,CBS_DROPDOWNLIST | WS_TABSTOP
|
WS_VSCROLL | WS_TABSTOP
|
||||||
CONTROL "Rounding",1164,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,11,
|
COMBOBOX IDC_COMBO_INPUT_DECIMAL_POINT,234,2,49,56,
|
||||||
36,43,8
|
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||||
COMBOBOX 1173,213,5,38,54,CBS_DROPDOWNLIST | WS_TABSTOP
|
COMBOBOX IDC_COMBO_OUTPUT_DECIMAL_POINT,234,16,49,62,CBS_DROPDOWNLIST |
|
||||||
CONTROL "sin/cos asin/acos",1172,"Static",SS_LEFTNOWORDWRAP |
|
WS_TABSTOP
|
||||||
WS_GROUP,137,7,73,8
|
COMBOBOX IDC_COMBO_PARAM_SEPARATE,234,30,49,54,CBS_DROPDOWNLIST |
|
||||||
COMBOBOX 1170,213,19,38,62,CBS_DROPDOWNLIST | WS_TABSTOP
|
WS_VSCROLL | WS_TABSTOP
|
||||||
CONTROL "Decimal point",1169,"Static",SS_LEFTNOWORDWRAP |
|
COMBOBOX IDC_COMBO_DEG_RAD_GRAD,234,44,49,53,CBS_DROPDOWNLIST |
|
||||||
WS_GROUP,137,22,73,8
|
WS_TABSTOP
|
||||||
CONTROL "remove trailing zeroes",1171,"Button",BS_AUTOCHECKBOX |
|
CONTROL "remove trailing zeroes",IDC_CHECK_REMOVE_ZEROES,"Button",
|
||||||
BS_LEFTTEXT | BS_LEFT | WS_TABSTOP,136,36,115,10
|
BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_LEFT | WS_TABSTOP,142,
|
||||||
CONTROL "Always",1160,"Button",BS_AUTORADIOBUTTON | BS_LEFT |
|
60,140,10
|
||||||
WS_GROUP | WS_TABSTOP,19,65,54,10
|
CONTROL "Always",IDC_RADIO_DISPLAY_ALWAYS_SCIENTIFIC,"Button",
|
||||||
CONTROL "When the exponent is greater than:",1161,"Button",
|
BS_AUTORADIOBUTTON | BS_LEFT | WS_GROUP | WS_TABSTOP,14,
|
||||||
BS_AUTORADIOBUTTON | BS_LEFT,77,65,138,10
|
87,54,10
|
||||||
EDITTEXT 1166,217,63,29,14,ES_NUMBER | WS_GROUP
|
CONTROL "When the exponent is greater than:",
|
||||||
CONTROL "",1165,"msctls_updown32",UDS_SETBUDDYINT |
|
IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC,"Button",
|
||||||
UDS_ALIGNRIGHT | UDS_ARROWKEYS,201,73,11,14
|
BS_AUTORADIOBUTTON | BS_LEFT,90,87,151,10
|
||||||
GROUPBOX "Print scientific value",1168,11,51,240,31
|
EDITTEXT IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC,245,84,29,14,ES_NUMBER |
|
||||||
|
WS_GROUP
|
||||||
|
CONTROL "",IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC,"msctls_updown32",
|
||||||
|
UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS,276,84,
|
||||||
|
11,14
|
||||||
|
GROUPBOX "Print scientific value",IDC_LABEL_DISPLAY_SCIENTIFIC,8,76,275,26
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef TTCALC_CONVERT
|
#ifdef TTCALC_CONVERT
|
||||||
|
|
||||||
115 DIALOG DISCARDABLE 0, 0, 260, 90
|
IDD_DIALOG_CONVERT DIALOG DISCARDABLE 0, 0, 288, 107
|
||||||
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | WS_GROUP |
|
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | WS_GROUP |
|
||||||
WS_TABSTOP
|
WS_TABSTOP
|
||||||
CAPTION "tab6"
|
CAPTION "tab6"
|
||||||
|
@ -255,31 +337,46 @@ END
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TTCALC_PORTABLE
|
#ifndef TTCALC_PORTABLE
|
||||||
200 DIALOG DISCARDABLE 0, 0, 349, 202
|
IDD_ABOUT_DIALOG DIALOG DISCARDABLE 0, 0, 349, 284
|
||||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
|
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
|
||||||
WS_SYSMENU
|
WS_SYSMENU
|
||||||
CAPTION "About"
|
CAPTION "About"
|
||||||
FONT 8, "MS Sans Serif"
|
FONT 8, "MS Sans Serif"
|
||||||
BEGIN
|
BEGIN
|
||||||
CONTROL 1201,0,"Static",SS_BITMAP,3,3,101,197
|
CONTROL 1201,0,"Static",SS_BITMAP | SS_REALSIZEIMAGE,3,3,115,277
|
||||||
EDITTEXT 1200,112,3,231,158,ES_MULTILINE | ES_READONLY | NOT
|
EDITTEXT IDC_ABOUT_TEXT,128,11,215,243,ES_MULTILINE | ES_READONLY |
|
||||||
WS_BORDER | NOT WS_TABSTOP
|
NOT WS_BORDER | NOT WS_TABSTOP
|
||||||
DEFPUSHBUTTON "Close",IDOK,175,172,86,14
|
DEFPUSHBUTTON "Close",IDOK,191,259,86,14
|
||||||
END
|
END
|
||||||
#else
|
#else
|
||||||
200 DIALOG DISCARDABLE 0, 0, 268, 239
|
IDD_ABOUT_DIALOG DIALOG DISCARDABLE 0, 0, 268, 362
|
||||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
|
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
|
||||||
WS_SYSMENU
|
WS_SYSMENU
|
||||||
CAPTION "About"
|
CAPTION "About"
|
||||||
FONT 8, "MS Sans Serif"
|
FONT 8, "MS Sans Serif"
|
||||||
BEGIN
|
BEGIN
|
||||||
EDITTEXT 1200,16,18,234,183,ES_MULTILINE | ES_READONLY | NOT
|
EDITTEXT IDC_ABOUT_TEXT,16,18,234,315,ES_MULTILINE | ES_READONLY |
|
||||||
WS_BORDER | NOT WS_TABSTOP
|
NOT WS_BORDER | NOT WS_TABSTOP
|
||||||
DEFPUSHBUTTON "Close",IDOK,90,213,86,14
|
DEFPUSHBUTTON "Close",IDOK,90,339,86,14
|
||||||
END
|
END
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
IDD_UPDATE_DIALOG DIALOG DISCARDABLE 0, 0, 409, 87
|
||||||
|
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "Check for update"
|
||||||
|
FONT 8, "MS Sans Serif"
|
||||||
|
BEGIN
|
||||||
|
CTEXT "Checking for update",IDC_UPDATE_INFO1,7,15,394,10
|
||||||
|
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,
|
||||||
|
38,395,14
|
||||||
|
DEFPUSHBUTTON "Next",IDC_BUTTON_NEXT,279,65,60,14
|
||||||
|
PUSHBUTTON "Cancel",IDC_BUTTON_CANCEL,342,65,60,14
|
||||||
|
CTEXT "url",IDC_UPDATE_INFO2,7,26,394,8
|
||||||
|
CONTROL "Always check for the update on sturtup",
|
||||||
|
IDC_CHECK_UPDATE_STURTUP,"Button",BS_AUTOCHECKBOX |
|
||||||
|
WS_TABSTOP,7,67,269,10
|
||||||
|
END
|
||||||
|
|
||||||
#ifndef TTCALC_PORTABLE
|
#ifndef TTCALC_PORTABLE
|
||||||
1201 BITMAP "..\\res\\abacus_01.bmp"
|
IDB_BITMAP_ABOUT BITMAP "..\\res\\aboutbox.bmp"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,159 +1,161 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* * Redistributions of source code must retain the above copyright notice,
|
* * Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* * Neither the name Tomasz Sowa nor the names of contributors to this
|
* * Neither the name Tomasz Sowa nor the names of contributors to this
|
||||||
* project may be used to endorse or promote products derived
|
* project may be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef headerfilestopcalculating
|
#ifndef headerfilestopcalculating
|
||||||
#define headerfilestopcalculating
|
#define headerfilestopcalculating
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file stopcalculating.h
|
\file stopcalculating.h
|
||||||
\brief it tells us whether there was a stop signal or not
|
\brief it tells us whether there was a stop signal or not
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ttmath/ttmathtypes.h>
|
#include "compileconfig.h"
|
||||||
#include <windows.h>
|
#include <ttmath/ttmathtypes.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <cstdio>
|
||||||
/*!
|
|
||||||
\brief it tells us whether there was a stop signal or not
|
|
||||||
|
/*!
|
||||||
we can pass a pointer to the object of this class to the certain
|
\brief it tells us whether there was a stop signal or not
|
||||||
calculating methods especially for the method which calculates the
|
|
||||||
Factorial (1*2*3*4....), such methods as the Factorial takes a lot of time
|
we can pass a pointer to the object of this class to the certain
|
||||||
and sometimes we want to break the calculations for example when we've got
|
calculating methods especially for the method which calculates the
|
||||||
a new input string
|
Factorial (1*2*3*4....), such methods as the Factorial takes a lot of time
|
||||||
|
and sometimes we want to break the calculations for example when we've got
|
||||||
those methods which take a lot of time check the object of type NewStopCalculating
|
a new input string
|
||||||
and if there was a stop signal they stop and return immediately without returning
|
|
||||||
a correct result
|
those methods which take a lot of time check the object of type NewStopCalculating
|
||||||
|
and if there was a stop signal they stop and return immediately without returning
|
||||||
the stop signal can be caused by another thread in our case by the first (gui) thread
|
a correct result
|
||||||
|
|
||||||
there'll be only one object of this class
|
the stop signal can be caused by another thread in our case by the first (gui) thread
|
||||||
(it'll be as an variable of ThreadController class)
|
|
||||||
*/
|
there'll be only one object of this class
|
||||||
class NewStopCalculating : public ttmath::StopCalculating
|
(it'll be as an variable of ThreadController class)
|
||||||
{
|
*/
|
||||||
public:
|
class NewStopCalculating : public ttmath::StopCalculating
|
||||||
|
{
|
||||||
|
public:
|
||||||
/*!
|
|
||||||
the constructor
|
|
||||||
*/
|
/*!
|
||||||
NewStopCalculating()
|
the constructor
|
||||||
{
|
*/
|
||||||
stop = 0;
|
NewStopCalculating()
|
||||||
}
|
{
|
||||||
|
stop = 0;
|
||||||
|
}
|
||||||
/*!
|
|
||||||
the destructor
|
|
||||||
*/
|
/*!
|
||||||
~NewStopCalculating()
|
the destructor
|
||||||
{
|
*/
|
||||||
if(stop) CloseHandle(stop);
|
~NewStopCalculating()
|
||||||
}
|
{
|
||||||
|
if(stop) CloseHandle(stop);
|
||||||
|
}
|
||||||
/*!
|
|
||||||
it initializes an object of this class
|
|
||||||
|
/*!
|
||||||
this method will be called from Init() of the ThreadController object
|
it initializes an object of this class
|
||||||
*/
|
|
||||||
bool Init() volatile
|
this method will be called from Init() of the ThreadController object
|
||||||
{
|
*/
|
||||||
char buffer[80];
|
bool Init() volatile
|
||||||
|
{
|
||||||
// with 'GetTickCount()' we're generating an unique identifier of our event
|
char buffer[80];
|
||||||
// (there can be another window of ttcalc)
|
|
||||||
sprintf(buffer,"TTCalcStopEventForStoppingCalculations7756%u",
|
// with 'GetTickCount()' we're generating an unique identifier of our event
|
||||||
(unsigned int)GetTickCount());
|
// (there can be another window of ttcalc)
|
||||||
|
sprintf(buffer,"TTCalcStopEventForStoppingCalculations7756%u",
|
||||||
// 'stop' will be manual-reseted and initialized as non-signaled
|
(unsigned int)GetTickCount());
|
||||||
if( (stop = CreateEvent(0,true,false,buffer))==NULL)
|
|
||||||
return false;
|
// 'stop' will be manual-reseted and initialized as non-signaled
|
||||||
|
if( (stop = CreateEvent(0,true,false,buffer))==NULL)
|
||||||
return true;
|
return false;
|
||||||
}
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
/*!
|
|
||||||
when we want to stop the calculations for example when the user changed somewhat
|
|
||||||
we call the Stop() method from the first (gui) thread
|
/*!
|
||||||
*/
|
when we want to stop the calculations for example when the user changed somewhat
|
||||||
void Stop() volatile
|
we call the Stop() method from the first (gui) thread
|
||||||
{
|
*/
|
||||||
SetEvent(stop);
|
void Stop() volatile
|
||||||
}
|
{
|
||||||
|
SetEvent(stop);
|
||||||
|
}
|
||||||
/*!
|
|
||||||
when we start the calculations we call this method
|
|
||||||
|
/*!
|
||||||
(we call it from WaitForCalculatingAndBlockForStop() method of
|
when we start the calculations we call this method
|
||||||
ThreadController class)
|
|
||||||
*/
|
(we call it from WaitForCalculatingAndBlockForStop() method of
|
||||||
void Start() volatile
|
ThreadController class)
|
||||||
{
|
*/
|
||||||
ResetEvent(stop);
|
void Start() volatile
|
||||||
}
|
{
|
||||||
|
ResetEvent(stop);
|
||||||
|
}
|
||||||
/*!
|
|
||||||
it returns 'true' if there was a stop signal
|
|
||||||
|
/*!
|
||||||
it's useful for the second thread and functions which take plenty of time
|
it returns 'true' if there was a stop signal
|
||||||
for calculating, when this method returns 'true' those methods break the
|
|
||||||
calculations and return without returning a correct value
|
it's useful for the second thread and functions which take plenty of time
|
||||||
*/
|
for calculating, when this method returns 'true' those methods break the
|
||||||
virtual bool WasStopSignal() const volatile
|
calculations and return without returning a correct value
|
||||||
{
|
*/
|
||||||
if( WaitForSingleObject(stop,0) == WAIT_OBJECT_0 )
|
virtual bool WasStopSignal() const volatile
|
||||||
return true;
|
{
|
||||||
|
if( WaitForSingleObject(stop,0) == WAIT_OBJECT_0 )
|
||||||
return false;
|
return true;
|
||||||
}
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
private:
|
|
||||||
|
|
||||||
// manual-reset, initialized as non-signaled
|
private:
|
||||||
HANDLE stop;
|
|
||||||
|
// manual-reset, initialized as non-signaled
|
||||||
};
|
HANDLE stop;
|
||||||
|
|
||||||
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
552
src/tabs.cpp
552
src/tabs.cpp
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -56,6 +56,176 @@ void PrintErrorCode()
|
||||||
GetPrgRes()->GetLanguages()->ErrorMessage(last_code) );
|
GetPrgRes()->GetLanguages()->ErrorMessage(last_code) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int CalcBracketsPrev(const char * buf, int start)
|
||||||
|
{
|
||||||
|
int last;
|
||||||
|
int brackets;
|
||||||
|
|
||||||
|
last = start;
|
||||||
|
--start;
|
||||||
|
|
||||||
|
while( true )
|
||||||
|
{
|
||||||
|
for( ; start>=0 && buf[start]!=';' ; --start )
|
||||||
|
if( buf[start] != ' ' )
|
||||||
|
last = start;
|
||||||
|
|
||||||
|
if( start <= 0 )
|
||||||
|
return last;
|
||||||
|
|
||||||
|
--start; // skipping a semicolon
|
||||||
|
brackets = 0;
|
||||||
|
|
||||||
|
for( ; start>=0 ; --start )
|
||||||
|
{
|
||||||
|
if( buf[start] == '(' )
|
||||||
|
++brackets;
|
||||||
|
else
|
||||||
|
if( buf[start] == ')' )
|
||||||
|
--brackets;
|
||||||
|
|
||||||
|
if( brackets > 0 )
|
||||||
|
{
|
||||||
|
last = start;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int CalcBracketsNext(const char * buf, int size, int start)
|
||||||
|
{
|
||||||
|
int last;
|
||||||
|
int brackets;
|
||||||
|
|
||||||
|
if( start >= size )
|
||||||
|
return size;
|
||||||
|
|
||||||
|
last = start;
|
||||||
|
|
||||||
|
while( true )
|
||||||
|
{
|
||||||
|
for( ; start<size && buf[start]!=';' ; ++start )
|
||||||
|
if( buf[start] != ' ' )
|
||||||
|
last = start;
|
||||||
|
|
||||||
|
if( start >= size )
|
||||||
|
{
|
||||||
|
if( buf[last] == ';' || buf[last] == ' ' )
|
||||||
|
return last;
|
||||||
|
else
|
||||||
|
return last+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
++start; // skipping a semicolon
|
||||||
|
brackets = 0;
|
||||||
|
|
||||||
|
for( ; start<size ; ++start )
|
||||||
|
{
|
||||||
|
if( buf[start] == '(' )
|
||||||
|
++brackets;
|
||||||
|
else
|
||||||
|
if( buf[start] == ')' )
|
||||||
|
--brackets;
|
||||||
|
|
||||||
|
if( brackets < 0 )
|
||||||
|
{
|
||||||
|
last = start;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool IsWhite(int c)
|
||||||
|
{
|
||||||
|
return c==' ' || c=='\t';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool IsOpeningOperand(int c)
|
||||||
|
{
|
||||||
|
return c=='-' || c=='+' || c=='*' ||c=='/' || c=='%' ||c=='^' || c=='(';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool IsOpeningOperandBefore(const char * buf, int end)
|
||||||
|
{
|
||||||
|
while( end > 0 && IsWhite(buf[end-1]) )
|
||||||
|
end -= 1;
|
||||||
|
|
||||||
|
if( end == 0 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return IsOpeningOperand(buf[end-1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CalcBracketsPos(HWND input, int & start, int & end)
|
||||||
|
{
|
||||||
|
DWORD sel_start, sel_end;
|
||||||
|
|
||||||
|
SendMessage(input, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
|
||||||
|
|
||||||
|
start = sel_start;
|
||||||
|
end = sel_end;
|
||||||
|
|
||||||
|
if( start != end )
|
||||||
|
return;
|
||||||
|
|
||||||
|
char * buf = GetPrgRes()->GetBufferTemp();
|
||||||
|
int len = SendMessage(input, WM_GETTEXT, GetPrgRes()->GetBufferSize(), (LPARAM)buf);
|
||||||
|
|
||||||
|
if( len > 0 && !IsOpeningOperandBefore(buf, end) )
|
||||||
|
{
|
||||||
|
start = CalcBracketsPrev(buf, sel_start);
|
||||||
|
end = CalcBracketsNext(buf, len, sel_start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void InsertText(const char * first, const char * last, int cursor_back = 0)
|
||||||
|
{
|
||||||
|
HWND input = GetDlgItem(GetPrgRes()->GetMainWindow(), IDC_INPUT_EDIT);
|
||||||
|
|
||||||
|
int start, end;
|
||||||
|
CalcBracketsPos(input, start, end);
|
||||||
|
|
||||||
|
size_t len_first = strlen(first);
|
||||||
|
|
||||||
|
SendMessage(input, EM_SETSEL, start, start);
|
||||||
|
SendMessage(input, EM_REPLACESEL, 1, LPARAM(first));
|
||||||
|
|
||||||
|
SendMessage(input, EM_SETSEL, end+len_first, end+len_first);
|
||||||
|
SendMessage(input, EM_REPLACESEL, 1, LPARAM(last));
|
||||||
|
|
||||||
|
if( start == end )
|
||||||
|
{
|
||||||
|
// was empty string - we're setting the cursor inside the texts
|
||||||
|
SendMessage(input, EM_SETSEL, end+len_first, end+len_first);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t len_last = strlen(last);
|
||||||
|
SendMessage(input, EM_SETSEL, end+len_first+len_last-cursor_back, end+len_first+len_last-cursor_back);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetFocus(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
this functions inserts a given string into the first edit control
|
this functions inserts a given string into the first edit control
|
||||||
and then moves the caret
|
and then moves the caret
|
||||||
|
@ -117,7 +287,7 @@ return true;
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_sin(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_sin(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("sin()",-1);
|
InsertText("sin(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +295,7 @@ return true;
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_cos(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_cos(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("cos()",-1);
|
InsertText("cos(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +303,7 @@ return true;
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_tan(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_tan(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("tan()",-1);
|
InsertText("tan(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +311,7 @@ return true;
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_cot(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_cot(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("cot()",-1);
|
InsertText("cot(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +319,7 @@ return true;
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_ln(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_ln(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("ln()",-1);
|
InsertText("ln(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -157,7 +327,7 @@ return true;
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_log(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_log(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("log( ; )",-4);
|
InsertText("log(", " ; )", 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +335,7 @@ return true;
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_abs(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_abs(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("abs()",-1);
|
InsertText("abs(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +343,7 @@ return true;
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_factorial(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_factorial(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("factorial()",-1);
|
InsertText("factorial(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -227,6 +397,9 @@ return true;
|
||||||
BOOL WmTabCommand_Press_clear(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_clear(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
SetDlgItemText(GetPrgRes()->GetMainWindow(), IDC_INPUT_EDIT, "");
|
SetDlgItemText(GetPrgRes()->GetMainWindow(), IDC_INPUT_EDIT, "");
|
||||||
|
|
||||||
|
HWND input_edit = GetDlgItem( GetPrgRes()->GetMainWindow(), IDC_INPUT_EDIT );
|
||||||
|
SetFocus(input_edit);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -237,46 +410,53 @@ BOOL WmTabCommand_Press_error(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
if( last_code != ttmath::err_ok )
|
if( last_code != ttmath::err_ok )
|
||||||
{
|
{
|
||||||
PrintErrorCode();
|
PrintErrorCode();
|
||||||
|
HWND input_edit = GetDlgItem( GetPrgRes()->GetMainWindow(), IDC_INPUT_EDIT );
|
||||||
|
SetFocus(input_edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_asin(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_asin(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("asin()",-1);
|
InsertText("asin(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_acos(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_acos(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("acos()",-1);
|
InsertText("acos(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_atan(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_atan(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("atan()",-1);
|
InsertText("atan(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_acot(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_acot(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("acot()",-1);
|
InsertText("acot(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_sgn(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_sgn(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("sgn()",-1);
|
InsertText("sgn(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_mod(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_mod(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("mod(;)",-2);
|
InsertText("mod(", " ; )", 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -292,7 +472,7 @@ return true;
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_int(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_int(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("int()",-1);
|
InsertText("int(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -300,7 +480,7 @@ return true;
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_round(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_round(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("round()",-1);
|
InsertText("round(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -308,7 +488,7 @@ return true;
|
||||||
|
|
||||||
BOOL WmTabCommand_Press_exp(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_Press_exp(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
InsertText("exp()",-1);
|
InsertText("exp(", ")");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -343,6 +523,24 @@ BOOL WmTabCommand_IDCANCEL(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// pos is the 'grouping' position (0 means none)
|
||||||
|
void SetDisablingGroupingDigits(HWND hWnd, int pos = -1)
|
||||||
|
{
|
||||||
|
if( pos < 0 )
|
||||||
|
pos = SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING, CB_GETCURSEL, 0, 0);
|
||||||
|
|
||||||
|
if( pos <= 0 )
|
||||||
|
{
|
||||||
|
EnableWindow(GetDlgItem(hWnd, IDC_COMBO_DISPLAY_GROUPING_DIGITS), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnableWindow(GetDlgItem(hWnd, IDC_COMBO_DISPLAY_GROUPING_DIGITS), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SetLanguageTabStandard(HWND hWnd)
|
void SetLanguageTabStandard(HWND hWnd)
|
||||||
{
|
{
|
||||||
SetDlgItemText( hWnd,IDC_BUTTON_CLEAR, GetPrgRes()->GetLanguages()->GuiMessage(Languages::button_clear) );
|
SetDlgItemText( hWnd,IDC_BUTTON_CLEAR, GetPrgRes()->GetLanguages()->GuiMessage(Languages::button_clear) );
|
||||||
|
@ -406,48 +604,108 @@ void SetLanguageTabPrecision(HWND hWnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SetLanguageTabDisplay(HWND hWnd)
|
void SetLanguageTabDisplayComboRounding(HWND hWnd)
|
||||||
{
|
{
|
||||||
char buffer[50];
|
char buffer[50];
|
||||||
int i;
|
int i;
|
||||||
|
const int max_r = 9;
|
||||||
|
|
||||||
|
Languages * pl = GetPrgRes()->GetLanguages();
|
||||||
|
|
||||||
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_RESETCONTENT, 0, 0);
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_RESETCONTENT, 0, 0);
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_ADDSTRING, 0, (LPARAM)pl->GuiMessage(Languages::combo_rounding_none) );
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_ADDSTRING, 0, (LPARAM)pl->GuiMessage(Languages::combo_rounding_integer) );
|
||||||
|
|
||||||
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) );
|
|
||||||
|
|
||||||
const int max_r = 9;
|
|
||||||
for(i=1 ; i<=max_r ; ++i)
|
for(i=1 ; i<=max_r ; ++i)
|
||||||
{
|
{
|
||||||
sprintf(buffer,"%s %d %s",
|
sprintf(buffer,"%s %d %s",
|
||||||
GetPrgRes()->GetLanguages()->GuiMessage(Languages::combo_rounding_to_number),
|
pl->GuiMessage(Languages::combo_rounding_to_number),
|
||||||
i,
|
i,
|
||||||
GetPrgRes()->GetLanguages()->GuiMessage(Languages::combo_rounding_after_comma) );
|
pl->GuiMessage(Languages::combo_rounding_after_comma) );
|
||||||
|
|
||||||
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_ADDSTRING, 0, (LPARAM)buffer);
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_ADDSTRING, 0, (LPARAM)buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int r = GetPrgRes()->GetDisplayRounding();
|
int r = GetPrgRes()->GetDisplayRounding();
|
||||||
|
|
||||||
if( r > max_r )
|
if( r > max_r )
|
||||||
r = max_r;
|
r = max_r;
|
||||||
|
|
||||||
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_SETCURSEL, r+1, 0);
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_SETCURSEL, r+1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SetDlgItemText(hWnd, IDC_LABEL_DISPLAY_INPUT, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_input));
|
void SetLanguageTabDisplayComboGrouping(HWND hWnd)
|
||||||
SetDlgItemText(hWnd, IDC_LABEL_DISPLAY_OUTPUT, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_output));
|
{
|
||||||
SetDlgItemText(hWnd, IDC_LABEL_DISPLAY_ROUNDING, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_rounding));
|
char buffer[50];
|
||||||
|
int i;
|
||||||
|
const int max_r = 9;
|
||||||
|
|
||||||
SetDlgItemText(hWnd, IDC_RADIO_DISPLAY_ALWAYS_SCIENTIFIC, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_always_scientific));
|
Languages * pl = GetPrgRes()->GetLanguages();
|
||||||
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));
|
// grouping
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING, CB_RESETCONTENT, 0, 0);
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING, CB_ADDSTRING, 0, (LPARAM)pl->GuiMessage(Languages::display_grouping_none));
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING, CB_ADDSTRING, 0, (LPARAM)pl->GuiMessage(Languages::display_grouping_space));
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING, CB_ADDSTRING, 0, (LPARAM)" `");
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING, CB_ADDSTRING, 0, (LPARAM)" '");
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING, CB_ADDSTRING, 0, (LPARAM)" .");
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING, CB_ADDSTRING, 0, (LPARAM)" ,");
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING, CB_SETCURSEL, GetPrgRes()->GetGrouping(), 0);
|
||||||
|
|
||||||
SetDlgItemText(hWnd, IDC_LABEL_DECIMAL_POINT, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_decimal_point));
|
// grouping digits
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING_DIGITS, CB_RESETCONTENT, 0, 0);
|
||||||
|
|
||||||
SetDlgItemText(hWnd, IDC_CHECK_REMOVE_ZEROES, GetPrgRes()->GetLanguages()->GuiMessage(Languages::check_remove_zeroes));
|
for(i=1 ; i<=max_r ; ++i)
|
||||||
|
{
|
||||||
|
sprintf(buffer,"%d %s", i, pl->GuiMessage(Languages::display_grouping_digits) );
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING_DIGITS, CB_ADDSTRING, 0, (LPARAM)buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int r = GetPrgRes()->GetGroupingDigits();
|
||||||
|
|
||||||
|
if( r > max_r )
|
||||||
|
r = max_r;
|
||||||
|
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING_DIGITS, CB_SETCURSEL, r-1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SetLanguageTabDisplay(HWND hWnd)
|
||||||
|
{
|
||||||
|
Languages * pl = GetPrgRes()->GetLanguages();
|
||||||
|
|
||||||
|
SetLanguageTabDisplayComboRounding(hWnd);
|
||||||
|
SetLanguageTabDisplayComboGrouping(hWnd);
|
||||||
|
SetDisablingGroupingDigits(hWnd, GetPrgRes()->GetGrouping());
|
||||||
|
|
||||||
|
SetDlgItemText(hWnd, IDC_LABEL_DISPLAY_INPUT, pl->GuiMessage(Languages::display_input));
|
||||||
|
SetDlgItemText(hWnd, IDC_LABEL_DISPLAY_OUTPUT, pl->GuiMessage(Languages::display_output));
|
||||||
|
SetDlgItemText(hWnd, IDC_LABEL_DISPLAY_ROUNDING, pl->GuiMessage(Languages::display_rounding));
|
||||||
|
SetDlgItemText(hWnd, IDC_LABEL_DISPLAY_GROUPING, pl->GuiMessage(Languages::display_grouping));
|
||||||
|
SetDlgItemText(hWnd, IDC_LABEL_INPUT_DECIMAL_POINT, pl->GuiMessage(Languages::display_input_decimal_point));
|
||||||
|
SetDlgItemText(hWnd, IDC_LABEL_OUTPUT_DECIMAL_POINT, pl->GuiMessage(Languages::display_output_decimal_point));
|
||||||
|
SetDlgItemText(hWnd, IDC_LABEL_PARAM_SEPARATE, pl->GuiMessage(Languages::display_param_sep));
|
||||||
|
|
||||||
|
SetDlgItemText(hWnd, IDC_RADIO_DISPLAY_ALWAYS_SCIENTIFIC, pl->GuiMessage(Languages::display_always_scientific));
|
||||||
|
SetDlgItemText(hWnd, IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC, pl->GuiMessage(Languages::display_not_always_scientific));
|
||||||
|
|
||||||
|
SetDlgItemText(hWnd, IDC_LABEL_DISPLAY_SCIENTIFIC, pl->GuiMessage(Languages::display_as_scientific));
|
||||||
|
SetDlgItemText(hWnd, IDC_CHECK_REMOVE_ZEROES, pl->GuiMessage(Languages::check_remove_zeroes));
|
||||||
|
SetDlgItemText(hWnd, IDC_LABEL_DISPLAY_DEG_RAD_GRAD, pl->GuiMessage(Languages::display_deg_rad_grad));
|
||||||
|
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_INPUT_DECIMAL_POINT, CB_RESETCONTENT, 0, 0);
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_INPUT_DECIMAL_POINT, CB_ADDSTRING, 0, (LPARAM)pl->GuiMessage(Languages::display_input_decimal_point_item1));
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_INPUT_DECIMAL_POINT, CB_ADDSTRING, 0, (LPARAM)" .");
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_INPUT_DECIMAL_POINT, CB_ADDSTRING, 0, (LPARAM)" ,");
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_INPUT_DECIMAL_POINT, CB_SETCURSEL, GetPrgRes()->GetInputDecimalPoint(), 0);
|
||||||
|
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_PARAM_SEPARATE, CB_RESETCONTENT, 0, 0);
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_PARAM_SEPARATE, CB_ADDSTRING, 0, (LPARAM)" ;");
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_PARAM_SEPARATE, CB_ADDSTRING, 0, (LPARAM)pl->GuiMessage(Languages::display_param_sep_item2));
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_PARAM_SEPARATE, CB_ADDSTRING, 0, (LPARAM)pl->GuiMessage(Languages::display_param_sep_item3));
|
||||||
|
SendDlgItemMessage(hWnd, IDC_COMBO_PARAM_SEPARATE, CB_SETCURSEL, GetPrgRes()->GetParamSep(), 0);
|
||||||
|
|
||||||
SetDlgItemText(hWnd, IDC_LABEL_DISPLAY_DEG_RAD_GRAD, GetPrgRes()->GetLanguages()->GuiMessage(Languages::display_deg_rad_grad));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -700,6 +958,7 @@ TCITEM tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL WmTabCommand_SetPrecision1(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_SetPrecision1(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
#ifndef TTCALC_PORTABLE
|
#ifndef TTCALC_PORTABLE
|
||||||
|
@ -789,7 +1048,7 @@ BOOL WmTabCommand_DisplayDecimalPointChanged(HWND hWnd, UINT message, WPARAM wPa
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||||
GetPrgRes()->SetDecimalPoint( (int)SendDlgItemMessage(hWnd, IDC_COMBO_DECIMAL_POINT, CB_GETCURSEL, 0, 0) );
|
GetPrgRes()->SetDecimalPoint( (int)SendDlgItemMessage(hWnd, IDC_COMBO_OUTPUT_DECIMAL_POINT, CB_GETCURSEL, 0, 0) );
|
||||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -822,6 +1081,7 @@ BOOL WmTabCommand_RemoveZeroesChanged(HWND hWnd, UINT message, WPARAM wParam, LP
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL WmTabCommand_DisplayDegRadGradChanged(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_DisplayDegRadGradChanged(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if( HIWORD(wParam) != CBN_SELCHANGE )
|
if( HIWORD(wParam) != CBN_SELCHANGE )
|
||||||
|
@ -850,6 +1110,53 @@ void SetDisablingDisplayWhenScientific(HWND hWnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_DisplayGrouping(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if( HIWORD(wParam) != CBN_SELCHANGE )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||||
|
GetPrgRes()->SetGrouping( (int)SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING, CB_GETCURSEL, 0, 0) );
|
||||||
|
GetPrgRes()->SetGroupingDigits( (int)SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING_DIGITS, CB_GETCURSEL, 0, 0) + 1 );
|
||||||
|
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||||
|
|
||||||
|
SetDisablingGroupingDigits(hWnd, GetPrgRes()->GetGrouping());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_DisplayInputDecimalPoint(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if( HIWORD(wParam) != CBN_SELCHANGE )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||||
|
GetPrgRes()->SetInputDecimalPoint( (int)SendDlgItemMessage(hWnd, IDC_COMBO_INPUT_DECIMAL_POINT, CB_GETCURSEL, 0, 0) );
|
||||||
|
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_DisplayParamSep(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if( HIWORD(wParam) != CBN_SELCHANGE )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||||
|
GetPrgRes()->SetParamSep( (int)SendDlgItemMessage(hWnd, IDC_COMBO_PARAM_SEPARATE, CB_GETCURSEL, 0, 0) );
|
||||||
|
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL WmTabCommand_SetDisplayAlwaysScientific(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand_SetDisplayAlwaysScientific(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
// there are another messages besides that one
|
// there are another messages besides that one
|
||||||
|
@ -919,7 +1226,113 @@ return true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CreateTabCommandMessagesTable(Messages & cmessages)
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_bracketsall(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText("(", ")");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_1div_bracketsall(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText("1/(", ")");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_semicolon(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText(" ; ", 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_percentage(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText("%", 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_floor(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText("floor(", ")");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_ceil(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText("ceil(", ")");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_min(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText("min(", ")");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_max(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText("max(", ")");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_avg(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText("avg(", ")");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_sum(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText("sum(", ")");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_root(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText("root(", " ; )", 1);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_gamma(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText("gamma(", ")");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WmTabCommand_Press_sqrt(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
InsertText("sqrt(", ")");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CreateTabCommandMessagesTable(Messages<BOOL> & cmessages)
|
||||||
{
|
{
|
||||||
cmessages.Associate(IDC_BUTTON_PRESS_0, WmTabCommand_Press_0_9);
|
cmessages.Associate(IDC_BUTTON_PRESS_0, WmTabCommand_Press_0_9);
|
||||||
cmessages.Associate(IDC_BUTTON_PRESS_1, WmTabCommand_Press_0_9);
|
cmessages.Associate(IDC_BUTTON_PRESS_1, WmTabCommand_Press_0_9);
|
||||||
|
@ -943,6 +1356,16 @@ void CreateTabCommandMessagesTable(Messages & cmessages)
|
||||||
cmessages.Associate(IDC_BUTTON_LOG, WmTabCommand_Press_log);
|
cmessages.Associate(IDC_BUTTON_LOG, WmTabCommand_Press_log);
|
||||||
cmessages.Associate(IDC_BUTTON_ABS, WmTabCommand_Press_abs);
|
cmessages.Associate(IDC_BUTTON_ABS, WmTabCommand_Press_abs);
|
||||||
cmessages.Associate(IDC_BUTTON_FACTORIAL, WmTabCommand_Press_factorial);
|
cmessages.Associate(IDC_BUTTON_FACTORIAL, WmTabCommand_Press_factorial);
|
||||||
|
cmessages.Associate(IDC_BUTTON_SEMICOLON, WmTabCommand_Press_semicolon);
|
||||||
|
cmessages.Associate(IDC_BUTTON_PERCENTAGE, WmTabCommand_Press_percentage);
|
||||||
|
cmessages.Associate(IDC_BUTTON_FLOOR, WmTabCommand_Press_floor);
|
||||||
|
cmessages.Associate(IDC_BUTTON_CEIL, WmTabCommand_Press_ceil);
|
||||||
|
cmessages.Associate(IDC_BUTTON_MIN, WmTabCommand_Press_min);
|
||||||
|
cmessages.Associate(IDC_BUTTON_MAX, WmTabCommand_Press_max);
|
||||||
|
cmessages.Associate(IDC_BUTTON_AVG, WmTabCommand_Press_avg);
|
||||||
|
cmessages.Associate(IDC_BUTTON_SUM, WmTabCommand_Press_sum);
|
||||||
|
cmessages.Associate(IDC_BUTTON_ROOT, WmTabCommand_Press_root);
|
||||||
|
cmessages.Associate(IDC_BUTTON_GAMMA, WmTabCommand_Press_gamma);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -963,11 +1386,14 @@ void CreateTabCommandMessagesTable(Messages & cmessages)
|
||||||
cmessages.Associate(IDC_BUTTON_SGN, WmTabCommand_Press_sgn);
|
cmessages.Associate(IDC_BUTTON_SGN, WmTabCommand_Press_sgn);
|
||||||
cmessages.Associate(IDC_BUTTON_MOD, WmTabCommand_Press_mod);
|
cmessages.Associate(IDC_BUTTON_MOD, WmTabCommand_Press_mod);
|
||||||
|
|
||||||
|
|
||||||
cmessages.Associate(IDC_BUTTON_POWER, WmTabCommand_Press_power);
|
cmessages.Associate(IDC_BUTTON_POWER, WmTabCommand_Press_power);
|
||||||
cmessages.Associate(IDC_BUTTON_INT, WmTabCommand_Press_int);
|
cmessages.Associate(IDC_BUTTON_INT, WmTabCommand_Press_int);
|
||||||
cmessages.Associate(IDC_BUTTON_ROUND, WmTabCommand_Press_round);
|
cmessages.Associate(IDC_BUTTON_ROUND, WmTabCommand_Press_round);
|
||||||
cmessages.Associate(IDC_BUTTON_EXP, WmTabCommand_Press_exp);
|
cmessages.Associate(IDC_BUTTON_EXP, WmTabCommand_Press_exp);
|
||||||
|
cmessages.Associate(IDC_BUTTON_BRACKETS_ALL, WmTabCommand_Press_bracketsall);
|
||||||
|
cmessages.Associate(IDC_BUTTON_1DIV_BRACKETS_ALL, WmTabCommand_Press_1div_bracketsall);
|
||||||
|
cmessages.Associate(IDC_BUTTON_SQRT, WmTabCommand_Press_sqrt);
|
||||||
|
|
||||||
|
|
||||||
cmessages.Associate(IDC_BUTTON_ADD_VARIABLE, Variables::WmTabCommand_AddVariable);
|
cmessages.Associate(IDC_BUTTON_ADD_VARIABLE, Variables::WmTabCommand_AddVariable);
|
||||||
cmessages.Associate(IDC_BUTTON_EDIT_VARIABLE, Variables::WmTabCommand_EditVariable);
|
cmessages.Associate(IDC_BUTTON_EDIT_VARIABLE, Variables::WmTabCommand_EditVariable);
|
||||||
|
@ -992,13 +1418,15 @@ void CreateTabCommandMessagesTable(Messages & cmessages)
|
||||||
cmessages.Associate(IDC_COMBO_DISPLAY_OUTPUT, WmTabCommand_DisplayOutputChanged);
|
cmessages.Associate(IDC_COMBO_DISPLAY_OUTPUT, WmTabCommand_DisplayOutputChanged);
|
||||||
cmessages.Associate(IDC_COMBO_DISPLAY_ROUNDING, WmTabCommand_DisplayRoundingChanged);
|
cmessages.Associate(IDC_COMBO_DISPLAY_ROUNDING, WmTabCommand_DisplayRoundingChanged);
|
||||||
cmessages.Associate(IDC_CHECK_REMOVE_ZEROES, WmTabCommand_RemoveZeroesChanged);
|
cmessages.Associate(IDC_CHECK_REMOVE_ZEROES, WmTabCommand_RemoveZeroesChanged);
|
||||||
|
|
||||||
cmessages.Associate(IDC_RADIO_DISPLAY_ALWAYS_SCIENTIFIC, WmTabCommand_SetDisplayAlwaysScientific);
|
cmessages.Associate(IDC_RADIO_DISPLAY_ALWAYS_SCIENTIFIC, WmTabCommand_SetDisplayAlwaysScientific);
|
||||||
cmessages.Associate(IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC, WmTabCommand_SetDisplayNotAlwaysScientific);
|
cmessages.Associate(IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC, WmTabCommand_SetDisplayNotAlwaysScientific);
|
||||||
cmessages.Associate(IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC, WmTabCommand_SetDisplayWhenScientific);
|
cmessages.Associate(IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC, WmTabCommand_SetDisplayWhenScientific);
|
||||||
cmessages.Associate(IDC_COMBO_DECIMAL_POINT, WmTabCommand_DisplayDecimalPointChanged);
|
cmessages.Associate(IDC_COMBO_OUTPUT_DECIMAL_POINT, WmTabCommand_DisplayDecimalPointChanged);
|
||||||
cmessages.Associate(IDC_COMBO_DEG_RAD_GRAD, WmTabCommand_DisplayDegRadGradChanged);
|
cmessages.Associate(IDC_COMBO_DEG_RAD_GRAD, WmTabCommand_DisplayDegRadGradChanged);
|
||||||
|
cmessages.Associate(IDC_COMBO_DISPLAY_GROUPING, WmTabCommand_DisplayGrouping);
|
||||||
|
cmessages.Associate(IDC_COMBO_DISPLAY_GROUPING_DIGITS, WmTabCommand_DisplayGrouping);
|
||||||
|
cmessages.Associate(IDC_COMBO_INPUT_DECIMAL_POINT, WmTabCommand_DisplayInputDecimalPoint);
|
||||||
|
cmessages.Associate(IDC_COMBO_PARAM_SEPARATE, WmTabCommand_DisplayParamSep);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1006,7 +1434,7 @@ void CreateTabCommandMessagesTable(Messages & cmessages)
|
||||||
*/
|
*/
|
||||||
BOOL WmTabCommand(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmTabCommand(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
static Messages command_messages;
|
static Messages<BOOL> command_messages;
|
||||||
|
|
||||||
if( command_messages.Empty() )
|
if( command_messages.Empty() )
|
||||||
// initiation
|
// initiation
|
||||||
|
@ -1135,16 +1563,19 @@ BOOL WmInitTabVariables(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
HWND list = GetDlgItem(hWnd, IDC_VARIABLES_LIST);
|
HWND list = GetDlgItem(hWnd, IDC_VARIABLES_LIST);
|
||||||
LVCOLUMN column;
|
LVCOLUMN column;
|
||||||
|
RECT r;
|
||||||
|
|
||||||
//int list_cx = SetSizeOfList(list);
|
GetWindowRect(list, &r);
|
||||||
int list_cx = 280;
|
|
||||||
|
int list_cx = r.right - r.left;
|
||||||
|
int header1_cx = 70;
|
||||||
|
|
||||||
column.mask = LVCF_TEXT | LVCF_WIDTH;
|
column.mask = LVCF_TEXT | LVCF_WIDTH;
|
||||||
column.cx = 60;
|
column.cx = header1_cx;
|
||||||
column.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::list_variables_header_1) );
|
column.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::list_variables_header_1) );
|
||||||
ListView_InsertColumn(list, 0, &column);
|
ListView_InsertColumn(list, 0, &column);
|
||||||
|
|
||||||
column.cx = list_cx - 60 - 10;
|
column.cx = list_cx - header1_cx;
|
||||||
column.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::list_variables_header_2) );
|
column.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::list_variables_header_2) );
|
||||||
ListView_InsertColumn(list, 1, &column);
|
ListView_InsertColumn(list, 1, &column);
|
||||||
|
|
||||||
|
@ -1161,20 +1592,24 @@ BOOL WmInitTabFunctions(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
HWND list = GetDlgItem(hWnd, IDC_FUNCTIONS_LIST);
|
HWND list = GetDlgItem(hWnd, IDC_FUNCTIONS_LIST);
|
||||||
LVCOLUMN column;
|
LVCOLUMN column;
|
||||||
|
RECT r;
|
||||||
|
|
||||||
//int list_cx = SetSizeOfList(list);
|
GetWindowRect(list, &r);
|
||||||
int list_cx = 280;
|
|
||||||
|
int list_cx = r.right - r.left;
|
||||||
|
int header1_cx = 70;
|
||||||
|
int header2_cx = 70;
|
||||||
|
|
||||||
column.mask = LVCF_TEXT | LVCF_WIDTH;
|
column.mask = LVCF_TEXT | LVCF_WIDTH;
|
||||||
column.cx = 60;
|
column.cx = header1_cx;
|
||||||
column.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::list_functions_header_1) );
|
column.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::list_functions_header_1) );
|
||||||
ListView_InsertColumn(list, 0, &column);
|
ListView_InsertColumn(list, 0, &column);
|
||||||
|
|
||||||
column.cx = 40;
|
column.cx = header2_cx;
|
||||||
column.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::list_functions_header_2) );
|
column.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::list_functions_header_2) );
|
||||||
ListView_InsertColumn(list, 1, &column);
|
ListView_InsertColumn(list, 1, &column);
|
||||||
|
|
||||||
column.cx = list_cx - 60 - 40 - 10;
|
column.cx = list_cx - header1_cx - header2_cx;
|
||||||
column.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::list_functions_header_3) );
|
column.pszText = const_cast<char*>( GetPrgRes()->GetLanguages()->GuiMessage(Languages::list_functions_header_3) );
|
||||||
ListView_InsertColumn(list, 2, &column);
|
ListView_InsertColumn(list, 2, &column);
|
||||||
|
|
||||||
|
@ -1243,6 +1678,7 @@ char buffer[20];
|
||||||
CheckDlgButton(hWnd, IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC, BST_CHECKED);
|
CheckDlgButton(hWnd, IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC, BST_CHECKED);
|
||||||
|
|
||||||
SetDisablingDisplayWhenScientific(hWnd);
|
SetDisablingDisplayWhenScientific(hWnd);
|
||||||
|
SetDisablingGroupingDigits(hWnd);
|
||||||
|
|
||||||
SendDlgItemMessage(hWnd, IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC, UDM_SETBASE, 10,0);
|
SendDlgItemMessage(hWnd, IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC, UDM_SETBASE, 10,0);
|
||||||
SendDlgItemMessage(hWnd, IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC, UDM_SETRANGE, 0, MAKELONG(99,1));
|
SendDlgItemMessage(hWnd, IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC, UDM_SETRANGE, 0, MAKELONG(99,1));
|
||||||
|
@ -1253,21 +1689,17 @@ char buffer[20];
|
||||||
sprintf(buffer,"%d", GetPrgRes()->GetDisplayWhenScientific());
|
sprintf(buffer,"%d", GetPrgRes()->GetDisplayWhenScientific());
|
||||||
SetDlgItemText(hWnd, IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC, buffer);
|
SetDlgItemText(hWnd, IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC, buffer);
|
||||||
|
|
||||||
SendDlgItemMessage(hWnd, IDC_COMBO_DECIMAL_POINT, CB_ADDSTRING, 0, (LPARAM)" .");
|
SendDlgItemMessage(hWnd, IDC_COMBO_OUTPUT_DECIMAL_POINT, CB_ADDSTRING, 0, (LPARAM)" .");
|
||||||
SendDlgItemMessage(hWnd, IDC_COMBO_DECIMAL_POINT, CB_ADDSTRING, 0, (LPARAM)" ,");
|
SendDlgItemMessage(hWnd, IDC_COMBO_OUTPUT_DECIMAL_POINT, CB_ADDSTRING, 0, (LPARAM)" ,");
|
||||||
SendDlgItemMessage(hWnd, IDC_COMBO_DECIMAL_POINT, CB_SETCURSEL, GetPrgRes()->GetDecimalPoint(), 0);
|
SendDlgItemMessage(hWnd, IDC_COMBO_OUTPUT_DECIMAL_POINT, CB_SETCURSEL, GetPrgRes()->GetDecimalPoint(), 0);
|
||||||
|
|
||||||
if( GetPrgRes()->GetRemovingZeroes() )
|
if( GetPrgRes()->GetRemovingZeroes() )
|
||||||
CheckDlgButton(hWnd, IDC_CHECK_REMOVE_ZEROES, BST_CHECKED);
|
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)"deg");
|
||||||
SendDlgItemMessage(hWnd, IDC_COMBO_DEG_RAD_GRAD, CB_ADDSTRING, 0, (LPARAM)"rad");
|
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_ADDSTRING, 0, (LPARAM)"grad");
|
||||||
|
|
||||||
SendDlgItemMessage(hWnd, IDC_COMBO_DEG_RAD_GRAD, CB_SETCURSEL, GetPrgRes()->GetDegRadGrad(), 0);
|
SendDlgItemMessage(hWnd, IDC_COMBO_DEG_RAD_GRAD, CB_SETCURSEL, GetPrgRes()->GetDegRadGrad(), 0);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1388,7 +1820,7 @@ return false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CreateTabMessagesTable(Messages & messages)
|
void CreateTabMessagesTable(Messages<BOOL> & messages)
|
||||||
{
|
{
|
||||||
messages.Associate(WM_INITDIALOG, WmTabInitDialog);
|
messages.Associate(WM_INITDIALOG, WmTabInitDialog);
|
||||||
messages.Associate(WM_COMMAND, WmTabCommand);
|
messages.Associate(WM_COMMAND, WmTabCommand);
|
||||||
|
@ -1412,7 +1844,7 @@ void CreateTabMessagesTable(Messages & messages)
|
||||||
|
|
||||||
BOOL CALLBACK TabWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK TabWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
static Messages messages;
|
static Messages<BOOL> messages;
|
||||||
|
|
||||||
if( messages.Empty() )
|
if( messages.Empty() )
|
||||||
// initiation
|
// initiation
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -49,12 +49,6 @@
|
||||||
#include "programresources.h"
|
#include "programresources.h"
|
||||||
|
|
||||||
|
|
||||||
#define WM_INIT_TAB_VARIABLES WM_APP
|
|
||||||
#define WM_INIT_TAB_FUNCTIONS WM_APP+1
|
|
||||||
#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
|
namespace TabWindowFunctions
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
|
* and is distributed under the (new) BSD licence.
|
||||||
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2008, 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 "threadcontroller.h"
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ThreadController::ThreadController()
|
||||||
|
{
|
||||||
|
calculations = 0;
|
||||||
|
ready_for_stop = 0;
|
||||||
|
exit_thread = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ThreadController::~ThreadController()
|
||||||
|
{
|
||||||
|
if(calculations) CloseHandle(calculations);
|
||||||
|
if(ready_for_stop) CloseHandle(ready_for_stop);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ThreadController::Init() volatile
|
||||||
|
{
|
||||||
|
char * buffer = new char[300];
|
||||||
|
|
||||||
|
// with 'GetTickCount()' we're generating an unique identifier of our event
|
||||||
|
// (there can be another window of ttcalc)
|
||||||
|
sprintf((char*)buffer,"TTCalcEventForManagingThreads9928%u",
|
||||||
|
(unsigned int)GetTickCount());
|
||||||
|
|
||||||
|
// 'calculations' will be for auto-reseting and initialized as non-signaled
|
||||||
|
if( (calculations = CreateEvent(0,false,false,(char*)buffer))==NULL)
|
||||||
|
{
|
||||||
|
delete [] buffer;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf((char*)buffer,"TTCalcEventReadyForStop5567%u",
|
||||||
|
(unsigned int)GetTickCount());
|
||||||
|
|
||||||
|
// 'ready_for_stop' will be for manual-reseting and initialized as signaled
|
||||||
|
// 'manual-reset' means that we must call ResetEvent() function (from WinAPI)
|
||||||
|
// to manually reset the state to nonsignaled
|
||||||
|
if( (ready_for_stop = CreateEvent(0,true,true,(char*)buffer))==NULL)
|
||||||
|
{
|
||||||
|
delete [] buffer;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete [] buffer;
|
||||||
|
|
||||||
|
return stop_calculating.Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ThreadController::ReadyForStop() volatile
|
||||||
|
{
|
||||||
|
SetEvent( ready_for_stop );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ThreadController::StopCalculatingAndExitThread() volatile
|
||||||
|
{
|
||||||
|
WaitForSingleObject(ready_for_stop,INFINITE);
|
||||||
|
|
||||||
|
stop_calculating.Stop();
|
||||||
|
exit_thread = true;
|
||||||
|
SetEvent(calculations);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ThreadController::StopCalculating() volatile
|
||||||
|
{
|
||||||
|
WaitForSingleObject(ready_for_stop, INFINITE);
|
||||||
|
|
||||||
|
stop_calculating.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ThreadController::StartCalculating() volatile
|
||||||
|
{
|
||||||
|
SetEvent(calculations);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
volatile bool ThreadController::WaitForCalculatingAndBlockForStop() volatile
|
||||||
|
{
|
||||||
|
WaitForSingleObject(calculations,INFINITE);
|
||||||
|
ResetEvent(ready_for_stop);
|
||||||
|
|
||||||
|
stop_calculating.Start();
|
||||||
|
|
||||||
|
return !exit_thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const volatile ttmath::StopCalculating * ThreadController::GetStopObject() volatile const
|
||||||
|
{
|
||||||
|
return &stop_calculating;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ThreadController::WasStopSignal() volatile const
|
||||||
|
{
|
||||||
|
return stop_calculating.WasStopSignal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// private
|
||||||
|
ThreadController::ThreadController(const ThreadController &)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -80,22 +80,13 @@ public:
|
||||||
the default constructor
|
the default constructor
|
||||||
(notice that there'll be only one object of this class)
|
(notice that there'll be only one object of this class)
|
||||||
*/
|
*/
|
||||||
ThreadController()
|
ThreadController();
|
||||||
{
|
|
||||||
calculations = 0;
|
|
||||||
ready_for_stop = 0;
|
|
||||||
exit_thread = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
the destructor
|
the destructor
|
||||||
*/
|
*/
|
||||||
~ThreadController()
|
~ThreadController();
|
||||||
{
|
|
||||||
if(calculations) CloseHandle(calculations);
|
|
||||||
if(ready_for_stop) CloseHandle(ready_for_stop);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -103,38 +94,7 @@ public:
|
||||||
|
|
||||||
we create two system event and initialize the 'stop_calculating' object
|
we create two system event and initialize the 'stop_calculating' object
|
||||||
*/
|
*/
|
||||||
bool Init() volatile
|
bool Init() volatile;
|
||||||
{
|
|
||||||
char * buffer = new char[300];
|
|
||||||
|
|
||||||
// with 'GetTickCount()' we're generating an unique identifier of our event
|
|
||||||
// (there can be another window of ttcalc)
|
|
||||||
sprintf((char*)buffer,"TTCalcEventForManagingThreads9928%u",
|
|
||||||
(unsigned int)GetTickCount());
|
|
||||||
|
|
||||||
// 'calculations' will be for auto-reseting and initialized as non-signaled
|
|
||||||
if( (calculations = CreateEvent(0,false,false,(char*)buffer))==NULL)
|
|
||||||
{
|
|
||||||
delete [] buffer;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf((char*)buffer,"TTCalcEventReadyForStop5567%u",
|
|
||||||
(unsigned int)GetTickCount());
|
|
||||||
|
|
||||||
// 'ready_for_stop' will be for manual-reseting and initialized as signaled
|
|
||||||
// 'manual-reset' means that we must call ResetEvent() function (from WinAPI)
|
|
||||||
// to manually reset the state to nonsignaled
|
|
||||||
if( (ready_for_stop = CreateEvent(0,true,true,(char*)buffer))==NULL)
|
|
||||||
{
|
|
||||||
delete [] buffer;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete [] buffer;
|
|
||||||
|
|
||||||
return stop_calculating.Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -143,10 +103,7 @@ public:
|
||||||
string, user-defined variables, functions etc.) and when the second thread
|
string, user-defined variables, functions etc.) and when the second thread
|
||||||
will have finished that then it call ReadyForStop() method
|
will have finished that then it call ReadyForStop() method
|
||||||
*/
|
*/
|
||||||
void ReadyForStop() volatile
|
void ReadyForStop() volatile;
|
||||||
{
|
|
||||||
SetEvent( ready_for_stop );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -154,14 +111,7 @@ public:
|
||||||
close button we call StopCalculatingAndExitThread() from the first main thread (gui),
|
close button we call StopCalculatingAndExitThread() from the first main thread (gui),
|
||||||
it means that the second thread (calculations) will finish itself
|
it means that the second thread (calculations) will finish itself
|
||||||
*/
|
*/
|
||||||
void StopCalculatingAndExitThread() volatile
|
void StopCalculatingAndExitThread() volatile;
|
||||||
{
|
|
||||||
WaitForSingleObject(ready_for_stop,INFINITE);
|
|
||||||
|
|
||||||
stop_calculating.Stop();
|
|
||||||
exit_thread = true;
|
|
||||||
SetEvent(calculations);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -172,12 +122,7 @@ public:
|
||||||
of copying variables) then sets the 'stop object' for signaled and returns to
|
of copying variables) then sets the 'stop object' for signaled and returns to
|
||||||
the caller
|
the caller
|
||||||
*/
|
*/
|
||||||
void StopCalculating() volatile
|
void StopCalculating() volatile;
|
||||||
{
|
|
||||||
WaitForSingleObject(ready_for_stop, INFINITE);
|
|
||||||
|
|
||||||
stop_calculating.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -185,67 +130,49 @@ public:
|
||||||
in other words it means that the calculations will start
|
in other words it means that the calculations will start
|
||||||
(maybe now, maybe at once if the second thread is still working)
|
(maybe now, maybe at once if the second thread is still working)
|
||||||
*/
|
*/
|
||||||
void StartCalculating() volatile
|
void StartCalculating() volatile;
|
||||||
{
|
|
||||||
SetEvent(calculations);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
this is the main method which is used by the second thread,
|
this is the main method which is used by the second thread,
|
||||||
if there's nothing to do this method (and the second thread as well) waits
|
if there's nothing to do this method (and the second thread as well) waits
|
||||||
*/
|
*/
|
||||||
volatile bool WaitForCalculatingAndBlockForStop() volatile
|
volatile bool WaitForCalculatingAndBlockForStop() volatile;
|
||||||
{
|
|
||||||
WaitForSingleObject(calculations,INFINITE);
|
|
||||||
ResetEvent(ready_for_stop);
|
|
||||||
|
|
||||||
stop_calculating.Start();
|
|
||||||
|
|
||||||
return !exit_thread;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
this method returns the pointer to the 'stop object'
|
this method returns the pointer to the 'stop object'
|
||||||
it's used by the second thread during calculating
|
it's used by the second thread during calculating
|
||||||
*/
|
*/
|
||||||
const volatile ttmath::StopCalculating * GetStopObject() volatile const
|
const volatile ttmath::StopCalculating * GetStopObject() volatile const;
|
||||||
{
|
|
||||||
return &stop_calculating;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
it returns 'true' if there was a stop signal during calculating
|
it returns 'true' if there was a stop signal during calculating
|
||||||
the stop signal can be caused by the first thread (gui thread)
|
the stop signal can be caused by the first thread (gui thread)
|
||||||
*/
|
*/
|
||||||
bool WasStopSignal() volatile const
|
bool WasStopSignal() volatile const;
|
||||||
{
|
|
||||||
return stop_calculating.WasStopSignal();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// auto-reset, initialized as non-signaled
|
// auto-reset, initialized as non-signaled
|
||||||
HANDLE calculations;
|
HANDLE calculations;
|
||||||
|
|
||||||
// manual-reset, initialized as signaled
|
// manual-reset, initialized as signaled
|
||||||
HANDLE ready_for_stop;
|
HANDLE ready_for_stop;
|
||||||
|
|
||||||
bool exit_thread;
|
bool exit_thread;
|
||||||
|
|
||||||
NewStopCalculating stop_calculating;
|
NewStopCalculating stop_calculating;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
we make the copy-constructor private so that nobody will be able
|
we make the copy-constructor private so that nobody will be able
|
||||||
to make a copy of the one object of this class
|
to make a copy of the one object of this class
|
||||||
*/
|
*/
|
||||||
ThreadController(const ThreadController &)
|
ThreadController(const ThreadController &);
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,672 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
|
* and is distributed under the (new) BSD licence.
|
||||||
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2011, 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 "compileconfig.h"
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <shlobj.h>
|
||||||
|
#include <process.h>
|
||||||
|
|
||||||
|
#include "update.h"
|
||||||
|
#include "programresources.h"
|
||||||
|
#include "messages.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#include "languages.h"
|
||||||
|
#include "winmain.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace Update
|
||||||
|
{
|
||||||
|
bool continue_down;
|
||||||
|
int level;
|
||||||
|
std::string url;
|
||||||
|
std::string remote_file_name;
|
||||||
|
std::string local_file_name;
|
||||||
|
int major;
|
||||||
|
int minor;
|
||||||
|
int revision;
|
||||||
|
int prerelease;
|
||||||
|
|
||||||
|
// this is set by another thread at the beginning
|
||||||
|
namespace Background
|
||||||
|
{
|
||||||
|
std::string url_;
|
||||||
|
std::string remote_file_name_;
|
||||||
|
int major_;
|
||||||
|
int minor_;
|
||||||
|
int revision_;
|
||||||
|
int prerelease_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
DownloadIni::DownloadIni()
|
||||||
|
{
|
||||||
|
file = 0;
|
||||||
|
file_name = new char[MAX_PATH];
|
||||||
|
file_name[0] = 0;
|
||||||
|
continue_download = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DownloadIni::~DownloadIni()
|
||||||
|
{
|
||||||
|
if( file )
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
DeleteTmpFile();
|
||||||
|
|
||||||
|
delete [] file_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DownloadIni::DeleteTmpFile()
|
||||||
|
{
|
||||||
|
if( file_name[0] != 0 )
|
||||||
|
DeleteFile(file_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * DownloadIni::GetFileName()
|
||||||
|
{
|
||||||
|
return file_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FILE * DownloadIni::CreateTmpFile()
|
||||||
|
{
|
||||||
|
char buf[MAX_PATH];
|
||||||
|
|
||||||
|
file = 0;
|
||||||
|
file_name[0] = 0;
|
||||||
|
|
||||||
|
if( !GetTempPath(MAX_PATH, buf) )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
if( !GetTempFileName(buf, "ttcalc_", 0, file_name) )
|
||||||
|
{
|
||||||
|
file_name[0] = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
file = fopen(file_name, "wb");
|
||||||
|
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadIni::GetLen(HINTERNET conn)
|
||||||
|
{
|
||||||
|
char buf[100];
|
||||||
|
DWORD buf_len = sizeof(buf);
|
||||||
|
DWORD index = 0;
|
||||||
|
|
||||||
|
if( HttpQueryInfo(conn, HTTP_QUERY_CONTENT_LENGTH, buf, &buf_len, &index) )
|
||||||
|
all_len = atoi(buf);
|
||||||
|
else
|
||||||
|
all_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool DownloadIni::Init()
|
||||||
|
{
|
||||||
|
if( !CreateTmpFile() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool DownloadIni::Read(char * buffer, size_t size)
|
||||||
|
{
|
||||||
|
if( !file )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
fwrite(buffer, size, 1, file);
|
||||||
|
CheckMessages();
|
||||||
|
|
||||||
|
if( continue_download && !(*continue_download) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DownloadIni::DownloadUrl(const char * url, bool * c)
|
||||||
|
{
|
||||||
|
continue_download = c;
|
||||||
|
|
||||||
|
return Download::DownloadUrl(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DownloadIni::Close()
|
||||||
|
{
|
||||||
|
if( file )
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
file = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
DownloadProgram::DownloadProgram()
|
||||||
|
{
|
||||||
|
continue_download = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DownloadProgram::GetLen(HINTERNET conn)
|
||||||
|
{
|
||||||
|
char buf[100];
|
||||||
|
DWORD buf_len = sizeof(buf);
|
||||||
|
DWORD index = 0;
|
||||||
|
|
||||||
|
if( HttpQueryInfo(conn, HTTP_QUERY_CONTENT_LENGTH, buf, &buf_len, &index) )
|
||||||
|
all_len = atoi(buf);
|
||||||
|
else
|
||||||
|
all_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool DownloadProgram::Init()
|
||||||
|
{
|
||||||
|
file.open(Update::local_file_name.c_str(), std::ios_base::out | std::ios_base::binary);
|
||||||
|
|
||||||
|
if( !file )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool DownloadProgram::Read(char * buffer, size_t size)
|
||||||
|
{
|
||||||
|
file.write(buffer, size);
|
||||||
|
CheckMessages();
|
||||||
|
|
||||||
|
if( continue_download && !(*continue_download) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool DownloadProgram::DownloadUrl(const char * url, bool * c)
|
||||||
|
{
|
||||||
|
continue_download = c;
|
||||||
|
|
||||||
|
return Download::DownloadUrl(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DownloadProgram::Close()
|
||||||
|
{
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
we check whether the download url is correct
|
||||||
|
this is in the case of someone hacked the server with *.ini file
|
||||||
|
*/
|
||||||
|
bool IsServerCorrect(const std::string & url)
|
||||||
|
{
|
||||||
|
if( IsSubStringNoCase("http://downloads.sourceforge.net/", url.c_str()) ||
|
||||||
|
IsSubStringNoCase("ftp://ttmath.org/", url.c_str()) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
this method is called from the other thread too
|
||||||
|
make sure you don't write directly to any global variables (from Update namespace etc)
|
||||||
|
*/
|
||||||
|
bool CheckUpdateFromIni(HWND hwnd, std::string & url_, std::string & remote_file_name_,
|
||||||
|
int & major_, int & minor_, int & revision_, int & prerelease_,
|
||||||
|
bool * continue_download_)
|
||||||
|
{
|
||||||
|
DownloadIni down_ini;
|
||||||
|
|
||||||
|
if( hwnd )
|
||||||
|
down_ini.AttachProgress(GetDlgItem(hwnd, IDC_PROGRESS));
|
||||||
|
|
||||||
|
if( down_ini.DownloadUrl("http://update.ttmath.org/ttcalc_update.ini", continue_download_) )
|
||||||
|
{
|
||||||
|
IniParser iparser;
|
||||||
|
std::string ini_value[4];
|
||||||
|
|
||||||
|
iparser.SectionCaseSensitive(false);
|
||||||
|
|
||||||
|
#ifndef TTCALC_PORTABLE
|
||||||
|
iparser.Associate("normal|url", &url_ );
|
||||||
|
iparser.Associate("normal|filename", &remote_file_name_ );
|
||||||
|
iparser.Associate("normal|version.major", &ini_value[0] );
|
||||||
|
iparser.Associate("normal|version.minor", &ini_value[1] );
|
||||||
|
iparser.Associate("normal|version.revision", &ini_value[2] );
|
||||||
|
iparser.Associate("normal|version.prerelease", &ini_value[3] );
|
||||||
|
|
||||||
|
#else
|
||||||
|
iparser.Associate("portable|url", &url_ );
|
||||||
|
iparser.Associate("portable|filename", &remote_file_name_ );
|
||||||
|
iparser.Associate("portable|version.major", &ini_value[0] );
|
||||||
|
iparser.Associate("portable|version.minor", &ini_value[1] );
|
||||||
|
iparser.Associate("portable|version.revision", &ini_value[2] );
|
||||||
|
iparser.Associate("portable|version.prerelease",&ini_value[3] );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IniParser::Error err = iparser.ReadFromFile( down_ini.GetFileName() );
|
||||||
|
|
||||||
|
if( err == IniParser::err_ok && IsServerCorrect(url_) )
|
||||||
|
{
|
||||||
|
major_ = atoi(ini_value[0].c_str());
|
||||||
|
minor_ = atoi(ini_value[1].c_str());
|
||||||
|
revision_ = atoi(ini_value[2].c_str());
|
||||||
|
prerelease_ = atoi(ini_value[3].c_str());
|
||||||
|
|
||||||
|
if( major_ > TTCALC_MAJOR_VER )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
if( major_ == TTCALC_MAJOR_VER && minor_ > TTCALC_MINOR_VER )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
if( major_ == TTCALC_MAJOR_VER && minor_ == TTCALC_MINOR_VER && revision_ > TTCALC_REVISION_VER )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
if( major_ == TTCALC_MAJOR_VER && minor_ == TTCALC_MINOR_VER && revision_ == TTCALC_REVISION_VER &&
|
||||||
|
prerelease_ < TTCALC_PRERELEASE_VER )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace Update
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CheckUpdate(HWND hwnd)
|
||||||
|
{
|
||||||
|
char buffer[200];
|
||||||
|
|
||||||
|
level = -1; // nothing to do when Next is pressed
|
||||||
|
continue_down = true;
|
||||||
|
Languages * pl = GetPrgRes()->GetLanguages();
|
||||||
|
EnableWindow(GetDlgItem(hwnd, IDC_BUTTON_NEXT), false);
|
||||||
|
EnableWindow(GetDlgItem(hwnd, IDC_UPDATE_INFO1), false);
|
||||||
|
ShowWindow(GetDlgItem(hwnd, IDC_PROGRESS), SW_SHOW);
|
||||||
|
CheckMessages();
|
||||||
|
|
||||||
|
if( CheckUpdateFromIni(hwnd, url, remote_file_name, major, minor, revision, prerelease, &continue_down) )
|
||||||
|
{
|
||||||
|
level = 1;
|
||||||
|
sprintf(buffer, pl->GuiMessage(Languages::update_is_new_version), major, minor, revision);
|
||||||
|
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, buffer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
level = 100;
|
||||||
|
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, pl->GuiMessage(Languages::update_no_new_version1));
|
||||||
|
SetDlgItemText(hwnd, IDC_UPDATE_INFO2, pl->GuiMessage(Languages::update_no_new_version2));
|
||||||
|
SetDlgItemText(hwnd, IDC_BUTTON_NEXT, pl->GuiMessage(Languages::update_button_finish));
|
||||||
|
ShowWindow(GetDlgItem(hwnd, IDC_PROGRESS), SW_HIDE);
|
||||||
|
EnableWindow(GetDlgItem(hwnd, IDC_BUTTON_CANCEL), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
EnableWindow(GetDlgItem(hwnd, IDC_BUTTON_NEXT), true);
|
||||||
|
EnableWindow(GetDlgItem(hwnd, IDC_UPDATE_INFO1), true);
|
||||||
|
ShowWindow(GetDlgItem(hwnd, IDC_PROGRESS), SW_HIDE);
|
||||||
|
SetFocus(GetDlgItem(hwnd, IDC_BUTTON_NEXT));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SaveDialog(HWND hwnd)
|
||||||
|
{
|
||||||
|
OPENFILENAME o;
|
||||||
|
char buf[MAX_PATH], desktop[MAX_PATH];
|
||||||
|
|
||||||
|
if( !remote_file_name.empty() )
|
||||||
|
sprintf(buf, remote_file_name.c_str());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifndef TTCALC_PORTABLE
|
||||||
|
sprintf(buf, "ttcalc-%d.%d.%d-setup.exe", major, minor, revision);
|
||||||
|
#else
|
||||||
|
sprintf(buf, "ttcalc-portable-%d.%d.%d-bin.tar.gz", major, minor, revision);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !SHGetSpecialFolderPath(hwnd, desktop, CSIDL_DESKTOPDIRECTORY, 0) )
|
||||||
|
desktop[0] = 0;
|
||||||
|
|
||||||
|
o.lStructSize = sizeof(o);
|
||||||
|
o.hwndOwner = hwnd;
|
||||||
|
o.hInstance = GetPrgRes()->GetInstance();
|
||||||
|
o.lpstrFilter = "*.*\0*.*\0";
|
||||||
|
o.lpstrCustomFilter = 0;
|
||||||
|
o.nMaxCustFilter = 0;
|
||||||
|
o.nFilterIndex = 1;
|
||||||
|
o.lpstrFile = buf;
|
||||||
|
o.nMaxFile = MAX_PATH;
|
||||||
|
o.lpstrFileTitle = 0;
|
||||||
|
o.nMaxFileTitle = 0;
|
||||||
|
o.lpstrInitialDir = (desktop[0]) ? desktop : 0;
|
||||||
|
o.lpstrTitle = 0;
|
||||||
|
o.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
|
||||||
|
o.nFileOffset = 0;
|
||||||
|
o.nFileExtension = 0;
|
||||||
|
o.lpstrDefExt = 0;
|
||||||
|
o.lCustData = 0;
|
||||||
|
o.lpfnHook = 0;
|
||||||
|
o.lpTemplateName = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if( GetSaveFileName(&o) )
|
||||||
|
{
|
||||||
|
local_file_name = buf;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool DownloadUpdate(HWND hwnd)
|
||||||
|
{
|
||||||
|
DownloadProgram down;
|
||||||
|
|
||||||
|
level = -1; // nothing to do when Next is pressed
|
||||||
|
continue_down = true;
|
||||||
|
EnableWindow(GetDlgItem(hwnd, IDC_BUTTON_NEXT), false);
|
||||||
|
Languages * pl = GetPrgRes()->GetLanguages();
|
||||||
|
|
||||||
|
if( SaveDialog(hwnd) )
|
||||||
|
{
|
||||||
|
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, pl->GuiMessage(Languages::update_download_from));
|
||||||
|
SetDlgItemText(hwnd, IDC_UPDATE_INFO2, url.c_str());
|
||||||
|
ShowWindow(GetDlgItem(hwnd, IDC_PROGRESS), SW_SHOW);
|
||||||
|
|
||||||
|
down.AttachProgress(GetDlgItem(hwnd, IDC_PROGRESS));
|
||||||
|
CheckMessages();
|
||||||
|
|
||||||
|
if( down.DownloadUrl(url.c_str(), &continue_down) )
|
||||||
|
{
|
||||||
|
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, pl->GuiMessage(Languages::update_downloaded_info1));
|
||||||
|
SetDlgItemText(hwnd, IDC_UPDATE_INFO2, pl->GuiMessage(Languages::update_downloaded_info2));
|
||||||
|
|
||||||
|
#ifndef TTCALC_PORTABLE
|
||||||
|
level = 2;
|
||||||
|
#else
|
||||||
|
level = 100;
|
||||||
|
EnableWindow(GetDlgItem(hwnd, IDC_BUTTON_CANCEL), false);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
level = 100;
|
||||||
|
DeleteFile(local_file_name.c_str());
|
||||||
|
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, pl->GuiMessage(Languages::update_download_error));
|
||||||
|
SetDlgItemText(hwnd, IDC_UPDATE_INFO2, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWindow(GetDlgItem(hwnd, IDC_PROGRESS), SW_HIDE);
|
||||||
|
SetDlgItemText(hwnd, IDC_BUTTON_NEXT, pl->GuiMessage(Languages::update_button_finish));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
level = 100;
|
||||||
|
EndDialog(hwnd, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
EnableWindow(GetDlgItem(hwnd, IDC_BUTTON_NEXT), true);
|
||||||
|
SetFocus(GetDlgItem(hwnd, IDC_BUTTON_NEXT));
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BOOL UpdateInit(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
Languages * pl = GetPrgRes()->GetLanguages();
|
||||||
|
|
||||||
|
if( level == 0 )
|
||||||
|
{
|
||||||
|
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, pl->GuiMessage(Languages::update_check_for_info));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( level == 1 )
|
||||||
|
{
|
||||||
|
char buffer[200];
|
||||||
|
|
||||||
|
sprintf(buffer, pl->GuiMessage(Languages::update_is_new_version), major, minor, revision);
|
||||||
|
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDlgItemText(hwnd, IDC_UPDATE_INFO2, "");
|
||||||
|
SetDlgItemText(hwnd, IDC_BUTTON_NEXT, pl->GuiMessage(Languages::update_button_next));
|
||||||
|
SetDlgItemText(hwnd, IDC_BUTTON_CANCEL, pl->GuiMessage(Languages::update_button_cancel));
|
||||||
|
SetWindowText(hwnd, pl->GuiMessage(Languages::update_title));
|
||||||
|
SetDlgItemText(hwnd, IDC_CHECK_UPDATE_STURTUP, pl->GuiMessage(Languages::update_check_at_startup));
|
||||||
|
|
||||||
|
if( GetPrgRes()->GetCheckUpdateStartup() )
|
||||||
|
CheckDlgButton(hwnd, IDC_CHECK_UPDATE_STURTUP, BST_CHECKED);
|
||||||
|
|
||||||
|
ShowWindow(GetDlgItem(hwnd, IDC_PROGRESS), SW_HIDE);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL UpdateCommand(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if( LOWORD(wParam)==IDCANCEL || LOWORD(wParam)==IDC_BUTTON_CANCEL )
|
||||||
|
{
|
||||||
|
continue_down = false;
|
||||||
|
EndDialog(hwnd, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( LOWORD(wParam) == IDC_CHECK_UPDATE_STURTUP )
|
||||||
|
{
|
||||||
|
GetPrgRes()->SetCheckUpdateStartup( IsDlgButtonChecked(hwnd, IDC_CHECK_UPDATE_STURTUP)==BST_CHECKED );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( LOWORD(wParam) == IDC_BUTTON_NEXT )
|
||||||
|
{
|
||||||
|
switch(level)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
CheckUpdate(hwnd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
DownloadUpdate(hwnd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
ShellExecute(0, "open", local_file_name.c_str(), "", "", SW_SHOWNORMAL);
|
||||||
|
EndDialog(hwnd, 0);
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 100:
|
||||||
|
EndDialog(hwnd, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CreateUpdateMessagesTable(Messages<BOOL> & messages)
|
||||||
|
{
|
||||||
|
messages.Associate(WM_INITDIALOG, UpdateInit);
|
||||||
|
messages.Associate(WM_COMMAND, UpdateCommand);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CALLBACK UpdateProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
static Messages<BOOL> messages;
|
||||||
|
|
||||||
|
if( messages.Empty() )
|
||||||
|
// initiation
|
||||||
|
CreateUpdateMessagesTable(messages);
|
||||||
|
|
||||||
|
return messages.Call(msg, hwnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned __stdcall UpdateBackgroundProc(void *)
|
||||||
|
{
|
||||||
|
using namespace Background;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if( CheckUpdateFromIni(0, url_, remote_file_name_, major_, minor_, revision_, prerelease_, 0) )
|
||||||
|
{
|
||||||
|
HWND main = GetPrgRes()->GetMainWindow();
|
||||||
|
PostMessage(main, WM_UPDATE_EXISTS, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
_endthreadex(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ShowUpdateDialog(HWND hwnd)
|
||||||
|
{
|
||||||
|
using namespace Update;
|
||||||
|
|
||||||
|
level = 0;
|
||||||
|
local_file_name.clear();
|
||||||
|
remote_file_name.clear();
|
||||||
|
url.clear();
|
||||||
|
|
||||||
|
DialogBox(GetPrgRes()->GetInstance(), MAKEINTRESOURCE(IDD_UPDATE_DIALOG), hwnd, UpdateProc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ShowUpdateDialogAfterCheck(HWND hwnd)
|
||||||
|
{
|
||||||
|
using namespace Update;
|
||||||
|
|
||||||
|
level = 1;
|
||||||
|
local_file_name.clear();
|
||||||
|
|
||||||
|
// make sure that there is a memory barrier before reading next objects (those from Background::)
|
||||||
|
// objects from Background:: are set by an another thread at the beginning
|
||||||
|
// when we are here then the thread is not writing (it exited)
|
||||||
|
remote_file_name = Background::remote_file_name_;
|
||||||
|
url = Background::url_;
|
||||||
|
major = Background::major_;
|
||||||
|
minor = Background::minor_;
|
||||||
|
revision = Background::revision_;
|
||||||
|
|
||||||
|
DialogBox(GetPrgRes()->GetInstance(), MAKEINTRESOURCE(IDD_UPDATE_DIALOG), hwnd, UpdateProc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CheckUpdateInBackground()
|
||||||
|
{
|
||||||
|
time_t last = GetPrgRes()->GetLastUpdate();
|
||||||
|
time_t now = time(0);
|
||||||
|
|
||||||
|
// testing only once a three days (259200 = 60*60*24 * 3)
|
||||||
|
if( GetPrgRes()->GetCheckUpdateStartup() && last+259200 < now )
|
||||||
|
{
|
||||||
|
// this setting can be added also when a user selects manually the test for an update
|
||||||
|
GetPrgRes()->SetLastUpdate(now);
|
||||||
|
|
||||||
|
unsigned int thread_id;
|
||||||
|
_beginthreadex(0, 0, Update::UpdateBackgroundProc, 0, 0, &thread_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
|
* and is distributed under the (new) BSD licence.
|
||||||
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 headerfileupdate
|
||||||
|
#define headerfileupdate
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include <cstdio>
|
||||||
|
#include "download.h"
|
||||||
|
|
||||||
|
|
||||||
|
void ShowUpdateDialog(HWND hwnd);
|
||||||
|
void ShowUpdateDialogAfterCheck(HWND hwnd);
|
||||||
|
void CheckUpdateInBackground();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DownloadIni : public Download
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DownloadIni();
|
||||||
|
~DownloadIni();
|
||||||
|
void DeleteTmpFile();
|
||||||
|
const char * GetFileName();
|
||||||
|
bool DownloadUrl(const char * url, bool * continue_download = 0);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
FILE * CreateTmpFile();
|
||||||
|
virtual void GetLen(HINTERNET conn);
|
||||||
|
virtual bool Init();
|
||||||
|
virtual bool Read(char * buffer, size_t size);
|
||||||
|
virtual void Close();
|
||||||
|
|
||||||
|
char * file_name;
|
||||||
|
FILE * file;
|
||||||
|
bool * continue_download;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DownloadProgram : public Download
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DownloadProgram();
|
||||||
|
bool DownloadUrl(const char * url, bool * continue_download = 0);
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual void GetLen(HINTERNET conn);
|
||||||
|
virtual bool Init();
|
||||||
|
virtual bool Read(char * buffer, size_t size);
|
||||||
|
virtual void Close();
|
||||||
|
|
||||||
|
std::ofstream file;
|
||||||
|
bool * continue_download;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -97,9 +97,14 @@ char * pchar;
|
||||||
SetDlgItemText(hWnd,IDC_EDIT_VARIABLE_VALUE, value.c_str());
|
SetDlgItemText(hWnd,IDC_EDIT_VARIABLE_VALUE, value.c_str());
|
||||||
|
|
||||||
if( adding)
|
if( adding)
|
||||||
|
{
|
||||||
SetFocus(GetDlgItem(hWnd,IDC_EDIT_VARIABLE_NAME));
|
SetFocus(GetDlgItem(hWnd,IDC_EDIT_VARIABLE_NAME));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
SetFocus(GetDlgItem(hWnd,IDC_EDIT_VARIABLE_VALUE));
|
SetFocus(GetDlgItem(hWnd,IDC_EDIT_VARIABLE_VALUE));
|
||||||
|
SendDlgItemMessage(hWnd, IDC_EDIT_VARIABLE_VALUE, EM_SETSEL, value.size(), value.size());
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -263,6 +268,8 @@ BOOL WmTabCommand_AddVariable(HWND, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
int id = AddNewItemToVariableList(list, name, value);
|
int id = AddNewItemToVariableList(list, name, value);
|
||||||
SelectOnlyOneItem(list,id);
|
SelectOnlyOneItem(list,id);
|
||||||
|
GetPrgRes()->ReadVariablesFunctionsFromFile();
|
||||||
|
GetPrgRes()->SaveToFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while( code != ttmath::err_ok );
|
while( code != ttmath::err_ok );
|
||||||
|
@ -324,7 +331,11 @@ adding = false;
|
||||||
if( code != ttmath::err_ok )
|
if( code != ttmath::err_ok )
|
||||||
ShowError(list, code);
|
ShowError(list, code);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ChangeItemInVariableList(list, id, old_name, name, value);
|
ChangeItemInVariableList(list, id, old_name, name, value);
|
||||||
|
GetPrgRes()->ReadVariablesFunctionsFromFile();
|
||||||
|
GetPrgRes()->SaveToFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while( code != ttmath::err_ok );
|
while( code != ttmath::err_ok );
|
||||||
|
|
||||||
|
@ -357,6 +368,7 @@ int items = ListView_GetSelectedCount(list);
|
||||||
char * buffer = new char[buffer_size];
|
char * buffer = new char[buffer_size];
|
||||||
bool all_deleted = true;
|
bool all_deleted = true;
|
||||||
|
|
||||||
|
GetPrgRes()->ReadVariablesFunctionsFromFile();
|
||||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||||
|
|
||||||
for( id = ListView_GetItemCount(list)-1 ; id!=-1 ; --id )
|
for( id = ListView_GetItemCount(list)-1 ; id!=-1 ; --id )
|
||||||
|
@ -375,6 +387,7 @@ int items = ListView_GetSelectedCount(list);
|
||||||
|
|
||||||
|
|
||||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||||
|
GetPrgRes()->SaveToFile();
|
||||||
|
|
||||||
delete [] buffer;
|
delete [] buffer;
|
||||||
|
|
||||||
|
|
229
src/winmain.cpp
229
src/winmain.cpp
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "compileconfig.h"
|
#include "compileconfig.h"
|
||||||
#include "winmain.h"
|
#include "winmain.h"
|
||||||
|
#include "update.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file mainwin.cpp
|
\file mainwin.cpp
|
||||||
|
@ -44,13 +45,23 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <ttmath/ttmath.h>
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
the application starts here
|
the application starts here
|
||||||
*/
|
*/
|
||||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR par, int)
|
||||||
{
|
{
|
||||||
|
if( strcmp(par, "createconfig") == 0 )
|
||||||
|
{
|
||||||
|
GetPrgRes()->SetConfigName();
|
||||||
|
GetPrgRes()->SaveToFile();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
GetPrgRes()->SetInstance(hInstance);
|
GetPrgRes()->SetInstance(hInstance);
|
||||||
|
|
||||||
// we're using GetLanguages() simultaneously in two threads, this is to be sure
|
// we're using GetLanguages() simultaneously in two threads, this is to be sure
|
||||||
|
@ -58,7 +69,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||||
GetPrgRes()->GetLanguages()->InitAll();
|
GetPrgRes()->GetLanguages()->InitAll();
|
||||||
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::en);
|
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::en);
|
||||||
//GetPrgRes()->GetConvert()->Init();
|
//GetPrgRes()->GetConvert()->Init();
|
||||||
GetPrgRes()->SetNameOfConfigurationFile();
|
GetPrgRes()->SetNameOfFiles();
|
||||||
GetPrgRes()->ReadFromFile();
|
GetPrgRes()->ReadFromFile();
|
||||||
|
|
||||||
INITCOMMONCONTROLSEX common_ctrl;
|
INITCOMMONCONTROLSEX common_ctrl;
|
||||||
|
@ -76,21 +87,46 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||||
if( (thread_handle = _beginthreadex(0,0,CalculationsProcedure, 0, 0, &thread_id)) == 0 )
|
if( (thread_handle = _beginthreadex(0,0,CalculationsProcedure, 0, 0, &thread_id)) == 0 )
|
||||||
return ShowError( Languages::cant_create_thread );
|
return ShowError( Languages::cant_create_thread );
|
||||||
|
|
||||||
|
bool maximized_from_file = GetPrgRes()->GetMaximized();
|
||||||
CreateDialog( hInstance, MAKEINTRESOURCE(IDD_MAIN_DIALOG), 0, MainWindowProc);
|
CreateDialog( hInstance, MAKEINTRESOURCE(IDD_MAIN_DIALOG), 0, MainWindowProc);
|
||||||
|
|
||||||
if( !GetPrgRes()->GetMainWindow() )
|
if( !GetPrgRes()->GetMainWindow() )
|
||||||
return ShowError( Languages::cant_create_main_window );
|
return ShowError( Languages::cant_create_main_window );
|
||||||
|
|
||||||
// there's the main loop of messages here
|
if( maximized_from_file )
|
||||||
|
{
|
||||||
|
GetPrgRes()->SetMaximized(true);
|
||||||
|
ShowWindow(GetPrgRes()->GetMainWindow(), SW_SHOWMAXIMIZED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetPrgRes()->SetMaximized(false);
|
||||||
|
ShowWindow(GetPrgRes()->GetMainWindow(), SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !CreatePadWindow() )
|
||||||
|
return ShowError( Languages::cant_create_pad );
|
||||||
|
|
||||||
|
// checking for an update (in an another thread)
|
||||||
|
CheckUpdateInBackground();
|
||||||
|
|
||||||
|
// the main loop of messages
|
||||||
MainMessagesLoop();
|
MainMessagesLoop();
|
||||||
|
|
||||||
// there can be another variables/functions saved by other instantion of TTCalc
|
// there can be another variables/functions saved by other instantion of TTCalc
|
||||||
// we're reading them now
|
// we're reading them now
|
||||||
GetPrgRes()->ReadVariablesFunctionsFromFile();
|
GetPrgRes()->ReadVariablesFunctionsFromFile();
|
||||||
|
|
||||||
GetPrgRes()->SaveToFile();
|
GetPrgRes()->SaveToFile();
|
||||||
|
|
||||||
|
DestroyPadWindow();
|
||||||
CloseHandle( (HANDLE)thread_handle );
|
CloseHandle( (HANDLE)thread_handle );
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
ShowError( Languages::unknown_error );
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +145,111 @@ return static_cast<int>( error_code );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AcceleratorForMainWindow(MSG & msg)
|
||||||
|
{
|
||||||
|
bool sent = true;
|
||||||
|
|
||||||
|
switch( msg.wParam )
|
||||||
|
{
|
||||||
|
case 'C':
|
||||||
|
sent = MainWindowFunctions::CopySpecial();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'R':
|
||||||
|
sent = MainWindowFunctions::CopyResult();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'V':
|
||||||
|
sent = MainWindowFunctions::PasteFormula();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'B':
|
||||||
|
sent = SendMessage(GetPrgRes()->GetMainWindow(), WM_COMMAND, IDM_EDIT_COPY_BOTH, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'W':
|
||||||
|
sent = SendMessage(GetPrgRes()->GetMainWindow(), WM_COMMAND, IDM_EDIT_SWAP, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '0':
|
||||||
|
SendMessage(GetPrgRes()->GetMainWindow(), WM_COMMAND, IDC_BUTTON_BRACKETS_ALL, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AcceleratorForPadEdit(MSG & msg)
|
||||||
|
{
|
||||||
|
if( msg.wParam == 'A' )
|
||||||
|
{
|
||||||
|
SendMessage(GetPrgRes()->GetPadWindow(), WM_COMMAND, MENUPAD_EDIT_SELECTALL, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CheckAcceleratorKeys(MSG & msg)
|
||||||
|
{
|
||||||
|
if( msg.message != WM_KEYDOWN )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( (GetKeyState(VK_CONTROL) & 0xff00) == 0 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( msg.hwnd == GetPrgRes()->GetPadEdit() )
|
||||||
|
return AcceleratorForPadEdit(msg);
|
||||||
|
|
||||||
|
return AcceleratorForMainWindow(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SendMessage(MSG & msg)
|
||||||
|
{
|
||||||
|
bool sent = CheckAcceleratorKeys(msg);
|
||||||
|
|
||||||
|
// 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( !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) )
|
||||||
|
sent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// firt we try to send our message to dialogs
|
||||||
|
// (the dialogs on the tab control)
|
||||||
|
if( !sent )
|
||||||
|
{
|
||||||
|
for(unsigned int i=0 ; i<GetPrgRes()->HowManyTabWindows() && !sent ; ++i)
|
||||||
|
{
|
||||||
|
if( IsDialogMessage(GetPrgRes()->GetTabWindow(i), &msg) )
|
||||||
|
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( !sent )
|
||||||
|
{
|
||||||
|
if( !IsDialogMessage(GetPrgRes()->GetMainWindow(), &msg) )
|
||||||
|
{
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -119,72 +260,30 @@ void MainMessagesLoop()
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
while( GetMessage(&msg,0,0,0) )
|
while( GetMessage(&msg,0,0,0) )
|
||||||
{
|
SendMessage(msg);
|
||||||
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( !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) )
|
|
||||||
sent = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// firt we try to send our message to dialogs
|
|
||||||
// (the dialogs on the tab control)
|
|
||||||
if( !sent )
|
|
||||||
{
|
|
||||||
for(unsigned int i=0 ; i<GetPrgRes()->HowManyTabWindows() && !sent ; ++i)
|
|
||||||
{
|
|
||||||
if( IsDialogMessage(GetPrgRes()->GetTabWindow(i), &msg) )
|
|
||||||
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( !sent )
|
|
||||||
{
|
|
||||||
if( !IsDialogMessage(GetPrgRes()->GetMainWindow(), &msg) )
|
|
||||||
{
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
if there are some messages then they will be sent
|
||||||
|
*/
|
||||||
|
void CheckMessages()
|
||||||
|
{
|
||||||
|
MSG msg;
|
||||||
|
|
||||||
|
while( PeekMessage(&msg, 0, 0, 0, PM_REMOVE) )
|
||||||
|
SendMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
the window-procedure for the main window
|
the window-procedure for the main window
|
||||||
*/
|
*/
|
||||||
BOOL CALLBACK MainWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK MainWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
static Messages messages;
|
static Messages<BOOL> messages;
|
||||||
|
|
||||||
if( messages.Empty() )
|
if( messages.Empty() )
|
||||||
// initiation
|
// initiation
|
||||||
|
@ -194,3 +293,5 @@ static Messages messages;
|
||||||
// so that we have the logarythmic time to find the special function to call
|
// so that we have the logarythmic time to find the special function to call
|
||||||
return messages.Call(message, hWnd, message, wParam, lParam);
|
return messages.Call(message, hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This file is a part of TTCalc - a mathematical calculator
|
* This file is a part of TTCalc - a mathematical calculator
|
||||||
* and is distributed under the (new) BSD licence.
|
* and is distributed under the (new) BSD licence.
|
||||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -47,11 +47,11 @@
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
#include "tabs.h"
|
#include "tabs.h"
|
||||||
|
#include "pad.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,14 +59,16 @@ BOOL CALLBACK MainWindowProc(HWND hWnd, UINT messge, WPARAM wParam, LPARAM lPara
|
||||||
unsigned __stdcall CalculationsProcedure(void *);
|
unsigned __stdcall CalculationsProcedure(void *);
|
||||||
int ShowError( Languages::GuiMsg error_code );
|
int ShowError( Languages::GuiMsg error_code );
|
||||||
void MainMessagesLoop();
|
void MainMessagesLoop();
|
||||||
|
void CheckMessages();
|
||||||
|
|
||||||
namespace MainWindowFunctions
|
namespace MainWindowFunctions
|
||||||
{
|
{
|
||||||
bool SetNextFocus(WPARAM wParam);
|
bool SetNextFocus(WPARAM wParam);
|
||||||
bool CopyResult();
|
bool CopyResult();
|
||||||
bool Paste();
|
bool CopySpecial();
|
||||||
void CreateMainMessagesTable(Messages & messages);
|
bool PasteFormula();
|
||||||
|
BOOL WmCommand_EditCopyBoth(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
void CreateMainMessagesTable(Messages<BOOL> & messages);
|
||||||
BOOL CALLBACK AboutProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
BOOL CALLBACK AboutProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# this file is downloaded from a webserver during checking for an update
|
||||||
|
|
||||||
|
[normal]
|
||||||
|
url = http://downloads.sourceforge.net/project/ttcalc/ttcalc/ttcalc-0.9.3/ttcalc-0.9.3-setup.exe
|
||||||
|
filename = ttcalc-0.9.3-setup.exe
|
||||||
|
version.major = 0
|
||||||
|
version.minor = 9
|
||||||
|
version.revision = 3
|
||||||
|
version.prerelease = 0
|
||||||
|
|
||||||
|
[portable]
|
||||||
|
url = http://downloads.sourceforge.net/project/ttcalc/ttcalc/ttcalc-0.9.3/ttcalc-portable-0.9.3-bin.zip
|
||||||
|
filename = ttcalc-portable-0.9.3-bin.zip
|
||||||
|
version.major = 0
|
||||||
|
version.minor = 9
|
||||||
|
version.revision = 3
|
||||||
|
version.prerelease = 0
|
||||||
|
|
Loading…
Reference in New Issue