Compare commits

...

19 Commits

Author SHA1 Message Date
Tomasz Sowa d54ebd1ae7 changed: names of locale files (in creating the setup program)
git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@452 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-05-20 15:35:39 +00:00
Tomasz Sowa af26634fb7 changed: some paths in the setup config file (for locale files)
git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@440 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-06-03 11:29:40 +00:00
Tomasz Sowa 89741a880e changed: the version of the program: 0.9.3 now
git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@354 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-04 00:12:11 +00:00
Tomasz Sowa 14f987012d changed: the way how the mouse selection works when you have clicked a button (sin/cos/..)
now if there is no selection and the last character is an operator: + - / * % ^ (
         then the text is append at the end (instead of looking for beginning of the expression)
         this seems to be more comfortable


git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@353 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-03 23:24:32 +00:00
Tomasz Sowa c4f316d7d3 changed: now ttcalc only once a three days checks for an update
fixed:   option: "parameters separated by" was not correctly read from the config file
added:   the setup program now addes language.setup key to the ttcalc.ini
         (it creates ttcalc.ini if it doesn't exist)
         so when ttcalc starts for the first time it can choose the same language



git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@352 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-03 22:41:55 +00:00
Tomasz Sowa 547f01bf34 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



git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@347 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-05-28 23:53:03 +00:00
Tomasz Sowa c4bcecc029 updated: Chinese translation
changed: release script now creates *.zip files instead of *.tar.gz


git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@346 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-05-28 22:43:35 +00:00
Tomasz Sowa af2f173a82 changed: the way how buttons on display tab work
suppose we have "123+34+56" in the first edit, then select
         (bo 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"



git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@343 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-03-07 20:36:25 +00:00
Tomasz Sowa 6c0a4b110e added: ttcalc can be start with option: createconfig, e.g.
./ttcalc createconfig
       it creates a config file in the current directory and exists
added: on variables and functions tab the carret is set at the end
       of a variable/function value (when edit)
changed: column 'parameters' on functions tab has been enlarged
changed: locales: "param." to "parameters" (english and german)



git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@341 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-02-08 16:15:35 +00:00
Tomasz Sowa 8e9a459c9c added makerelease.sh
a shell script for making release packages



git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@339 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-30 21:07:50 +00:00
Tomasz Sowa 844f79b793 added: on display tab: an option how many digits should be grouped
git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@337 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-30 17:30:10 +00:00
Tomasz Sowa 21372faa56 changed: translation: "pad" to "calcpad"
git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@336 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-30 15:22:27 +00:00
Tomasz Sowa ac8574e9da changed Changelog and other docs
git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@335 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-30 15:01:57 +00:00
Tomasz Sowa 7c62d9eae0 added: a new language: German
translation made by: Moritz Beleites <morbel at gmx dot net>


git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@334 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-01-30 15:00:07 +00:00
Tomasz Sowa e87308c721 added: blocks try{} catch(...) to first and second thread
changed: version of the program: 0.9.2 now



git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@322 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-09-23 22:52:28 +00:00
Tomasz Sowa eb7cec8ecc updated italian translation and about dialog (portable version)
git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@308 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-09-15 12:19:09 +00:00
Tomasz Sowa f67657c026 corrected the italian translation
git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@307 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-09-14 19:03:18 +00:00
Tomasz Sowa 300f1aaa5f added: Italian translation made by
Damiano Monaco   <dmonax AnTispam gmail.com>
added:   menu: edit->swap (ctrl+W)
         swapping the input for the output edit



git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@306 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-09-14 16:45:31 +00:00
Tomasz Sowa cfcb654e53 added into the repository: src/threadcontroller.cpp
this file was out of controll by subversion (I forgot to add it)

added: the update can only download files from urles which begin with:
 http://downloads.sourceforge.net/
 ftp://ttmath.org/
this is in the case of someone hacked the server with *.ini file



git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@293 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-02-17 17:05:00 +00:00
35 changed files with 2163 additions and 515 deletions

View File

@ -1,4 +1,33 @@
Version 0.9.1 (2009.02.07):
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

View File

@ -1,4 +1,4 @@
Copyright (c) 2006-2010, Tomasz Sowa
Copyright (c) 2006-2011, Tomasz Sowa
All rights reserved.
Redistribution and use in source and binary forms, with or without

3
README
View File

@ -17,7 +17,8 @@ display values with the base (radix) from two to sixteen.
Author: Tomasz Sowa
Contact: t.sowa@ttmath.org
Licence: BSD (open source)
Interface: English, Polish, Spanish, Danish, Chinese, Russian, Swedish
Interface: English, Polish, Spanish, Danish, Chinese, Russian,
Swedish, Italian, German
Project page: http://ttcalc.sourceforge.net/
Bignum library: TTMath http://www.ttmath.org/
Operating systems: Microsoft Windows 9x/Me/NT/2000/XP/Vista/7

View File

@ -44,7 +44,7 @@ display values with the base (radix) from two to sixteen.
<tr><td>Author:</td><td>Tomasz Sowa</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>Interface:</td><td>English, Polish, Spanish, Danish, Chinese, Russian, Swedish</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>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/7</td></tr>

View File

@ -62,13 +62,13 @@ sgn(5)=1</dd>
<dt>max(x1; x2; ...)</dt>
<dd>This functions takes any number of arguments. It returns the max value of them. If there aren't arguments
<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>
max(2;5;8;3)=8<br>
max()=6.97846825730330952352039893e+646457021 (assuming the small precision is selected)</dd>
<dt>min(x1; x2; ...)</dt>
<dd>This functions takes any number of arguments. It returns the min value of them. If there aren't arguments
<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>
min(45;-23;18;19)=-23<br>
min()=-6.97846825730330952352039893e+646457021 (assuming the small precision is selected)

268
makerelease.sh Normal file
View File

@ -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: 205 KiB

After

Width:  |  Height:  |  Size: 227 KiB

View File

@ -1,4 +1,4 @@
Copyright (c) 2006-2010, Tomasz Sowa
Copyright (c) 2006-2011, Tomasz Sowa
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@ -1,10 +1,9 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
; innosetup script
[Setup]
AppName=TTCalc
AppVerName=TTCalc 0.9.1
AppVersion=0.9.1
AppVerName=TTCalc 0.9.3
AppVersion=0.9.3
AppPublisher=Tomasz Sowa
AppPublisherURL=http://ttcalc.sourceforge.net
AppSupportURL=http://ttcalc.sourceforge.net
@ -12,7 +11,7 @@ AppUpdatesURL=http://ttcalc.sourceforge.net
DefaultDirName={pf}\TTCalc
DefaultGroupName=TTCalc
AllowNoIcons=yes
; special COPYRIGHT version (without a new line characters in the clause -- it is better displayed in the setup window)
; special COPYRIGHT version (without new line characters in the clause -- it is better displayed in the setup window)
LicenseFile=COPYRIGHT
OutputDir=..\setup
OutputBaseFilename=ttcalc-setup
@ -24,12 +23,14 @@ UsePreviousAppDir=yes
[Languages]
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: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
Name: "chinese"; MessagesFile: "compiler:Languages\ChineseSimp-12-5.1.11.isl"
Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
Name: "chinese"; MessagesFile: "compiler:Languages\ChineseSimplified.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]
; prior to 0.8.3 we were using mingwm10.dll (now it is not needed and will be deleted if exists)
@ -40,16 +41,22 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{
[Files]
Source: "..\src\ttcalc.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\help\ttcalc.chm"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\COPYRIGHT"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\CHANGELOG"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\README"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\help\ttcalc.chm"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\COPYRIGHT"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\CHANGELOG"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\README"; DestDir: "{app}"; Flags: ignoreversion
; now we do not use *.ini file in the installer
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Dirs]
Name: "{userappdata}/TTCalc" ; Flags: uninsneveruninstall
[INI]
Filename: "{userappdata}/TTCalc/ttcalc.ini"; Section: "GLOBAL"; Key: "language.setup"; String: "{language}"
[Icons]
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: "{commondesktop}\TTCalc"; Filename: "{app}\ttcalc.exe"; WorkingDir: "{app}"; Tasks: desktopicon

View File

@ -1,6 +1,9 @@
include Makefile.o.dep
include Makefile.help.dep
CC = g++
#CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../ttmath -DTTMATH_RELEASE -DTTCALC_CONVERT
CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../ttmath -DTTMATH_RELEASE
#CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../ttmath -DTTCALC_CONVERT
CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../ttmath -DTTMATH_DONT_USE_WCHAR
name = ttcalc.exe
# the name of the help is also set in the html help workshop project file
@ -14,10 +17,14 @@ setupname = ttcalc-setup.exe
all: ttcalc
include Makefile.dep
%.o: %.cpp
$(CC) -c $(CFLAGS) $<
ttcalc: $(o)
ttcalc: $(name)
$(name): $(o)
$(CC) -o $(name) $(CFLAGS) $(o) -lcomctl32 -lwininet
@ -26,18 +33,34 @@ resource.o: resource.rc
windres resource.rc resource.o
help: $(helpdep)
help: ../help/$(helpname)
../help/$(helpname): $(helpsrc)
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
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:
rm -f *.o
rm -f $(name)
rm -f ttcalcp.exe
rm -f ../help/$(helpname)
rm -f ../setup/$(setupname)
include Makefile.cpp.dep

176
src/Makefile.cpp.dep Normal file
View File

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

View File

@ -1,48 +0,0 @@
o = resource.o calculation.o convert.o download.o functions.o iniparser.o languages.o mainwindow.o pad.o parsermanager.o programresources.o tabs.o threadcontroller.o update.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
download.o: download.cpp compileconfig.h download.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 pad.h update.h download.h
pad.o: pad.cpp programresources.h compileconfig.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h pad.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
threadcontroller.o: threadcontroller.cpp threadcontroller.h stopcalculating.h compileconfig.h
update.o: update.cpp compileconfig.h update.h download.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h messages.h resource.h winmain.h tabs.h pad.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 pad.h update.h download.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

1
src/Makefile.help.dep Normal file
View File

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

1
src/Makefile.o.dep Normal file
View File

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

View File

@ -1,21 +1,31 @@
include Makefile.o.dep
include Makefile.help.dep
CC = g++
CFLAGS = -Wall -pedantic -s -Os -fno-default-inline -mwindows -I../../ttmath -DTTMATH_RELEASE -DTTCALC_PORTABLE
CFLAGS = -Wall -pedantic -s -Os -fno-default-inline -mwindows -I../../ttmath -DTTCALC_PORTABLE -DTTMATH_DONT_USE_WCHAR
name = ttcalcp.exe
compressor = upx
all: ttcalc
include Makefile.dep
ttcalc: $(o)
%.o: %.cpp
$(CC) -c $(CFLAGS) $<
ttcalc: $(name)
$(name): $(o)
$(CC) -o $(name) $(CFLAGS) $(o) -lcomctl32 -lwininet
$(compressor) -7 $(name)
resource.o: resource.rc
windres -DTTCALC_PORTABLE resource.rc resource.o
clean:
rm -f *.o
rm -f $(name)
rm -f ../help/$(helpname)
include Makefile.cpp.dep

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2010, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -55,7 +55,7 @@
*/
#define TTCALC_MAJOR_VER 0
#define TTCALC_MINOR_VER 9
#define TTCALC_REVISION_VER 1
#define TTCALC_REVISION_VER 3
#define TTCALC_PRERELEASE_VER 0

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* 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);
if( adding )
{
SetFocus(GetDlgItem(hWnd,IDC_EDIT_FUNCTION_NAME));
}
else
{
SetFocus(GetDlgItem(hWnd,IDC_EDIT_FUNCTION_VALUE));
SendDlgItemMessage(hWnd, IDC_EDIT_FUNCTION_VALUE, EM_SETSEL, value.size(), value.size());
}
return false;
@ -232,6 +237,8 @@ BOOL WmTabCommand_AddFunction(HWND, UINT message, WPARAM wParam, LPARAM lParam)
{
int id = AddNewItemToFunctionList(list, name, value, parameters);
Variables::SelectOnlyOneItem(list,id);
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->SaveToFile();
}
}
@ -297,7 +304,11 @@ adding = false;
if( code != ttmath::err_ok )
ShowError(list, code);
else
{
ChangeItemInFunctionList(list, id, old_name, name, value, parameters);
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->SaveToFile();
}
}
while( code != ttmath::err_ok );
@ -330,6 +341,7 @@ int items = ListView_GetSelectedCount(list);
char * buffer = new char[buffer_size];
bool all_deleted = true;
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->GetThreadController()->StopCalculating();
for( id = ListView_GetItemCount(list)-1 ; id!=-1 ; --id )
@ -348,6 +360,7 @@ int items = ListView_GetSelectedCount(list);
GetPrgRes()->GetThreadController()->StartCalculating();
GetPrgRes()->SaveToFile();
delete [] buffer;

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -105,6 +105,7 @@ public:
display_grouping,
display_grouping_none,
display_grouping_space,
display_grouping_digits,
display_input_decimal_point,
display_input_decimal_point_item1,
display_output_decimal_point,
@ -131,6 +132,8 @@ public:
menu_view_lang_chinese,
menu_view_lang_russian,
menu_view_lang_swedish,
menu_view_lang_italian,
menu_view_lang_german,
menu_view_close_program,
menu_edit_undo,
menu_edit_cut,
@ -142,6 +145,7 @@ public:
menu_edit_copy_both,
menu_edit_select_all,
menu_edit_bracket,
menu_edit_swap,
menu_help_help,
menu_help_project_page,
menu_help_check_update,
@ -173,7 +177,7 @@ public:
about_text_exe_packer,
about_box_title,
about_box_button_close,
display_group_scientific,
display_as_scientific,
pad_title,
pad_menu_file,
pad_menu_edit,
@ -187,15 +191,21 @@ public:
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
};
// the first item must be with zero index
// and next items must be about one greater (0,1,2,3..)
// (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
{
en = 0, pl, sp, da, chn, ru, swe
en = 0, pl, sp, da, chn, ru, swe, it, ger, lastnotexisting
};
@ -230,9 +240,18 @@ public:
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;
}
void SelectCurrentLanguage(const std::string & lang);
Country GetCurrentLanguage()
{
return current_country;

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -41,33 +41,14 @@
#include "update.h"
#include "pad.h"
#include "bigtypes.h"
#include "misc.h"
namespace MainWindowFunctions
{
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;
}
/*!
@ -426,6 +407,8 @@ HMENU menu = GetMenu(hWnd);
SetMenuLanguageItem(menu, IDM_LANGUAGE_CHINESE, Languages::menu_view_lang_chinese);
SetMenuLanguageItem(menu, IDM_LANGUAGE_RUSSIAN, Languages::menu_view_lang_russian);
SetMenuLanguageItem(menu, IDM_LANGUAGE_SWEDISH, Languages::menu_view_lang_swedish);
SetMenuLanguageItem(menu, IDM_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_EDIT_UNDO, Languages::menu_edit_undo);
SetMenuLanguageItem(menu, IDM_EDIT_CUT, Languages::menu_edit_cut);
@ -437,6 +420,7 @@ HMENU menu = GetMenu(hWnd);
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_PROJECT_PAGE, Languages::menu_help_project_page);
SetMenuLanguageItem(menu, IDM_HELP_CHECK_UPDATE, Languages::menu_help_check_update);
@ -833,6 +817,12 @@ void WmInitMenuPopUpView(HMENU menu)
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);
}
@ -921,6 +911,11 @@ bool edit_readonly = false; // the edit is read only
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);
}
@ -1127,6 +1122,24 @@ 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;
}
BOOL WmCommand_EditCopyResult(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
CopyResult();
@ -1134,6 +1147,7 @@ BOOL WmCommand_EditCopyResult(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
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);
@ -1329,6 +1343,30 @@ BOOL WmCommand_LanguageSwedish(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
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;
}
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)
{
@ -1391,10 +1429,13 @@ MENUITEMINFO mi;
mi.dwTypeData = const_cast<char*>(GetPrgRes()->GetLanguages()->GuiMessage(Languages::menu_update_available));
mi.cch = 0;
mi.wID = IDM_UPDATE_AVAILABLE;
HMENU menu = GetMenu(hWnd);
InsertMenuItem(menu, IDM_UPDATE_AVAILABLE_INDEX, true, &mi);
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);
@ -1423,6 +1464,7 @@ void CreateCommandMessagesTable(Messages<BOOL> & cmessages)
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(IDM_EDIT_SELECT_ALL, WmCommand_IDCANCEL);
cmessages.Associate(IDM_LANGUAGE_ENGLISH, WmCommand_LanguageEnglish);
@ -1432,6 +1474,8 @@ void CreateCommandMessagesTable(Messages<BOOL> & cmessages)
cmessages.Associate(IDM_LANGUAGE_CHINESE, WmCommand_LanguageChinese);
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_PROJECT_PAGE, WmProjectPage);
}

78
src/misc.cpp Normal file
View File

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

47
src/misc.h Normal file
View File

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

View File

@ -68,6 +68,8 @@ char input_comma1;
char input_comma2;
char param_sep;
int grouping_digits;
Languages::Country country;
int last_variables_id;
@ -133,6 +135,7 @@ unsigned int i = 0;
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);
@ -263,6 +266,7 @@ void SetParameters()
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);
@ -571,11 +575,12 @@ LRESULT PadOpen(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
std::ifstream file(file_name.c_str(), std::ios_base::in | std::ios_base::binary);
Languages * lang = GetPrgRes()->GetLanguages();
if( !file )
{
MessageBox(hwnd, "I cannot open the file", "TTcalc", MB_ICONERROR);
MessageBox(hwnd, lang->GuiMessage(Languages::cannot_open_file),
lang->GuiMessage(Languages::message_box_error_caption), MB_ICONERROR);
return 0;
}
@ -584,7 +589,8 @@ LRESULT PadOpen(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if( pos > 65530 )
{
MessageBox(hwnd, "The file is too long", "TTcalc", MB_ICONERROR);
MessageBox(hwnd, lang->GuiMessage(Languages::file_too_long),
lang->GuiMessage(Languages::message_box_error_caption), MB_ICONERROR);
return 0;
}
@ -644,7 +650,9 @@ void SaveBuffer(HWND hwnd, const char * buf)
if( !file )
{
MessageBox(hwnd, "I cannot open the file for saving", "TTCalc", MB_ICONERROR);
Languages * lang = GetPrgRes()->GetLanguages();
MessageBox(hwnd, lang->GuiMessage(Languages::cannot_save_file),
lang->GuiMessage(Languages::message_box_error_caption), MB_ICONERROR);
return;
}
@ -661,12 +669,13 @@ 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, "There was a problem with saving", "TTCalc", MB_ICONERROR);
MessageBox(hwnd, lang->GuiMessage(Languages::other_error),
lang->GuiMessage(Languages::message_box_error_caption), MB_ICONERROR);
return 0;
}
@ -675,7 +684,8 @@ LRESULT PadSave(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if( buf )
SaveBuffer(hwnd, buf);
else
MessageBox(hwnd, "There was a problem with saving", "TTCalc", MB_ICONERROR);
MessageBox(hwnd, lang->GuiMessage(Languages::other_error),
lang->GuiMessage(Languages::message_box_error_caption), MB_ICONERROR);
LocalUnlock(handle);

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -45,11 +45,6 @@
ParserManager::ParserManager() : buffer_len(20480)
{
buffer = 0;
base_input = base_output = 10;
always_scientific = 0;
when_scientific = 15;
rounding = -1;
remove_zeroes = true;
last_variables_id = 0;
last_functions_id = 0;
}
@ -57,15 +52,7 @@ ParserManager::ParserManager() : buffer_len(20480)
ParserManager::ParserManager(const ParserManager & p) : buffer_len(p.buffer_len)
{
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;
buffer = 0;
}
@ -164,6 +151,7 @@ unsigned int i;
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);

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2010, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -142,6 +142,8 @@ private:
char input_comma2;
char param_sep;
int grouping_digits;
/*
some buffers which we use in some method in the second thread,
it's better to have those buffers outside those methods -
@ -206,6 +208,7 @@ private:
conv.trim_zeroes = remove_zeroes;
conv.comma = decimal_point;
conv.group = grouping;
conv.group_digits = grouping_digits;
if( result.ToString(buffer2, conv) )
{

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -614,6 +614,22 @@ int ProgramResources::GetGrouping()
}
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;
@ -683,8 +699,8 @@ time_t ProgramResources::GetLastUpdate()
ProgramResources::ProgramResources()
{
// if you want to change the input buffer you have also to change
// ParserManager::ParserManager() : buffer_len(2048) in parsermanager.cpp
// if you want to change the input buffer you have to also change
// ParserManager::ParserManager() : buffer_len(20480) in parsermanager.cpp
buffer_size = 20480;
buffer = new char[buffer_size];
@ -740,6 +756,7 @@ ProgramResources::ProgramResources()
decimal_point = 0; // output decimal point
angle_deg_rad_grad = 1; // rad is default
grouping = 0;
grouping_digits = 3;
input_decimal_point = 0; // dot or comma
param_sep = 0;
@ -896,6 +913,9 @@ static const char help_name[] = "ttcalc.chm";
// which can be, for instance, as:
// "C:\Documents and Settings\user\data application" on WinNT
// or "C:\Windows\Data Application\" on Win9x
// we don't use SHGetFolderLocation() because it is not available on Win9x
if( ReadTextValueFromRegistry(
HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
@ -913,6 +933,17 @@ static const char help_name[] = "ttcalc.chm";
/*
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;
@ -1075,6 +1106,7 @@ IniParser iparser;
IniParser::Section temp_variables, temp_functions;
IniParser::Section::iterator ic;
std::string ini_value[30];
std::string language_setup;
iparser.ConvertValueToSmallLetters(false);
iparser.SectionCaseSensitive(false);
@ -1082,6 +1114,7 @@ std::string ini_value[30];
// we have variables and functions case-sensitive
iparser.PatternCaseSensitive(true);
iparser.Associate( "global|language.setup", &language_setup );
iparser.Associate( "global|always.on.top", &ini_value[0] );
iparser.Associate( "global|view", &ini_value[1] );
iparser.Associate( "global|maximized", &ini_value[2] );
@ -1110,6 +1143,7 @@ std::string ini_value[30];
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( "functions", &temp_functions );
@ -1120,81 +1154,94 @@ std::string ini_value[30];
if( err == IniParser::err_cant_open_file )
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()) );
// remove zeroes - in there is not in the config then will be true by default
// (from the constructor)
if( !ini_value[15].empty() )
SetRemovingZeroes( bool(atoi(ini_value[15].c_str())) );
if( ini_value[13] == "6" )
languages.SetCurrentLanguage(Languages::swe);
else
if( ini_value[13] == "5" )
languages.SetCurrentLanguage(Languages::ru);
else
if( ini_value[13] == "4" )
languages.SetCurrentLanguage(Languages::chn);
else
if( ini_value[13] == "3" )
languages.SetCurrentLanguage(Languages::da);
else
if( ini_value[13] == "2" )
languages.SetCurrentLanguage(Languages::sp);
else
if( ini_value[13] == "1" )
languages.SetCurrentLanguage(Languages::pl);
else
languages.SetCurrentLanguage(Languages::en);
SetDecimalPoint( atoi(ini_value[14].c_str()) );
SetDegRadGrad( atoi(ini_value[16].c_str()) );
pad_x_pos = atoi( ini_value[17].c_str() );
pad_y_pos = atoi( ini_value[18].c_str() );
pad_x_size = atoi( ini_value[19].c_str() );
pad_y_size = atoi( ini_value[20].c_str() );
pad_maximized = bool( atoi(ini_value[21].c_str()) );
show_pad = bool( atoi(ini_value[22].c_str()) );
CheckPadCoordinates();
SetGrouping( atoi(ini_value[23].c_str()) );
SetInputDecimalPoint( atoi(ini_value[24].c_str()) );
SetParamSep( atoi(ini_value[24].c_str()) );
if( err != IniParser::err_ok )
bad_line = iparser.GetBadLine();
// check update at startup - true by default (if there is not in the config)
// (default from the constructor)
if( !ini_value[26].empty() )
check_update_startup = bool( atoi(ini_value[26].c_str()) );
AddVariablesFunctions(temp_variables, temp_functions, false);
last_update = (time_t)atol(ini_value[27].c_str());
// 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;
}
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()
{
@ -1235,6 +1282,7 @@ std::ofstream file( configuration_file.c_str() );
file << "disp.output_comma = " << decimal_point << 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;

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -336,6 +336,12 @@ public:
*/
void SetNameOfFiles();
/*!
it is used when 'createconfig' parameter has been passed to the ttcalc program
*/
void SetConfigName();
/*!
returning the name of the help file
@ -410,6 +416,14 @@ public:
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
*/
@ -491,7 +505,9 @@ private:
void CheckCoordinates();
void CheckPadCoordinates();
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 functions;
@ -546,6 +562,7 @@ private:
bool remove_zeroes;
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

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -176,18 +176,19 @@
#define IDC_LABEL_DISPLAY_ROUNDING 1163
#define IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC 1164
#define IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC 1165
#define IDC_LABEL_GROUP_SCIENTIFIC 1166
#define IDC_LABEL_DISPLAY_SCIENTIFIC 1166
#define IDC_LABEL_OUTPUT_DECIMAL_POINT 1167
#define IDC_COMBO_OUTPUT_DECIMAL_POINT 1168
#define IDC_CHECK_REMOVE_ZEROES 1169
#define IDC_LABEL_DISPLAY_DEG_RAD_GRAD 1170
#define IDC_COMBO_DEG_RAD_GRAD 1171
#define IDC_COMBO_DISPLAY_GROUPING 1172
#define IDC_LABEL_DISPLAY_GROUPING 1173
#define IDC_COMBO_INPUT_DECIMAL_POINT 1174
#define IDC_LABEL_INPUT_DECIMAL_POINT 1175
#define IDC_LABEL_PARAM_SEPARATE 1176
#define IDC_COMBO_PARAM_SEPARATE 1177
#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
#define IDC_LIST_UNIT_TYPE 1200
@ -222,6 +223,8 @@
#define IDM_LANGUAGE_CHINESE 40014
#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_EDIT_UNDO 40030
@ -234,6 +237,7 @@
#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

View File

@ -34,6 +34,8 @@ BEGIN
MENUITEM "Chinese", IDM_LANGUAGE_CHINESE
MENUITEM "Russian", IDM_LANGUAGE_RUSSIAN
MENUITEM "Swedish", IDM_LANGUAGE_SWEDISH
MENUITEM "Italian", IDM_LANGUAGE_ITALIAN
MENUITEM "German", IDM_LANGUAGE_GERMAN
END
MENUITEM SEPARATOR
MENUITEM "Close", IDM_CLOSE_PROGRAM
@ -53,6 +55,7 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "Select all", IDM_EDIT_SELECT_ALL
MENUITEM "Bracket", IDM_EDIT_BRACKET
MENUITEM "Swap", IDM_EDIT_SWAP
END
POPUP "Help"
BEGIN
@ -90,7 +93,7 @@ BEGIN
END
101 DIALOGEX 0, 0, 295, 189
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"
@ -104,7 +107,7 @@ BEGIN
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 |
WS_CAPTION | WS_SYSMENU
CAPTION "Add a new variable"
@ -118,7 +121,7 @@ BEGIN
LTEXT "value:",IDC_STATIC_VARIABLE_VALUE,7,30,38,8
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 |
WS_CAPTION | WS_SYSMENU
FONT 8, "Ms Shell Dlg"
@ -134,7 +137,7 @@ BEGIN
END
110 DIALOG DISCARDABLE 0, 0, 288, 107
IDD_DIALOG_STANDARD DIALOG DISCARDABLE 0, 0, 288, 107
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_GROUP | WS_TABSTOP
FONT 8, "Ms Shell Dlg"
BEGIN
@ -193,7 +196,7 @@ BEGIN
END
111 DIALOG 0, 0, 288, 107
IDD_DIALOG_VARIABLES DIALOG 0, 0, 288, 107
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
CAPTION "tab2"
FONT 8, "Ms Shell Dlg"
@ -204,7 +207,7 @@ BEGIN
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
112 DIALOG 0, 0, 288, 107
IDD_DIALOG_FUNCTIONS DIALOG 0, 0, 288, 107
STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD | WS_TABSTOP |WS_GROUP
CAPTION "tab3"
FONT 8, "Ms Shell Dlg"
@ -217,7 +220,7 @@ END
#ifndef TTCALC_PORTABLE
113 DIALOG DISCARDABLE 0, 0, 288, 107
IDD_DIALOG_PRECISION DIALOG DISCARDABLE 0, 0, 288, 107
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | WS_GROUP |
WS_TABSTOP
CAPTION "tab4"
@ -241,7 +244,7 @@ END
#endif
114 DIALOG DISCARDABLE 0, 0, 288, 107
IDD_DIALOG_DISPLAY DIALOG DISCARDABLE 0, 0, 288, 107
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | WS_GROUP |
WS_TABSTOP
CAPTION "tab5"
@ -269,7 +272,9 @@ BEGIN
WS_TABSTOP
COMBOBOX IDC_COMBO_DISPLAY_ROUNDING,61,30,59,200,CBS_DROPDOWNLIST |
WS_TABSTOP
COMBOBOX IDC_COMBO_DISPLAY_GROUPING,61,44,59,112,CBS_DROPDOWNLIST |
COMBOBOX IDC_COMBO_DISPLAY_GROUPING,61,44,59,100,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO_DISPLAY_GROUPING_DIGITS,61,58,59,100,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO_INPUT_DECIMAL_POINT,234,2,49,56,
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
@ -293,14 +298,13 @@ BEGIN
CONTROL "",IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC,"msctls_updown32",
UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS,276,84,
11,14
GROUPBOX "Print scientific value",IDC_LABEL_GROUP_SCIENTIFIC,8,75,
275,27
GROUPBOX "Print scientific value",IDC_LABEL_DISPLAY_SCIENTIFIC,8,76,275,26
END
#ifdef TTCALC_CONVERT
115 DIALOG DISCARDABLE 0, 0, 288, 107
IDD_DIALOG_CONVERT DIALOG DISCARDABLE 0, 0, 288, 107
STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | WS_GROUP |
WS_TABSTOP
CAPTION "tab6"
@ -333,44 +337,44 @@ END
#endif
#ifndef TTCALC_PORTABLE
200 DIALOG DISCARDABLE 0, 0, 349, 256
IDD_ABOUT_DIALOG DIALOG DISCARDABLE 0, 0, 349, 284
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "About"
FONT 8, "MS Sans Serif"
BEGIN
CONTROL IDB_BITMAP_ABOUT,0,"Static",SS_BITMAP | SS_REALSIZEIMAGE,3,3,115,250
EDITTEXT IDC_ABOUT_TEXT,128,11,215,212,ES_MULTILINE | ES_READONLY | NOT
WS_BORDER | NOT WS_TABSTOP
DEFPUSHBUTTON "Close",IDOK,191,231,86,14
CONTROL 1201,0,"Static",SS_BITMAP | SS_REALSIZEIMAGE,3,3,115,277
EDITTEXT IDC_ABOUT_TEXT,128,11,215,243,ES_MULTILINE | ES_READONLY |
NOT WS_BORDER | NOT WS_TABSTOP
DEFPUSHBUTTON "Close",IDOK,191,259,86,14
END
#else
200 DIALOG DISCARDABLE 0, 0, 268, 301
IDD_ABOUT_DIALOG DIALOG DISCARDABLE 0, 0, 268, 362
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "About"
FONT 8, "MS Sans Serif"
BEGIN
EDITTEXT IDC_ABOUT_TEXT,16,18,234,245,ES_MULTILINE | ES_READONLY |
EDITTEXT IDC_ABOUT_TEXT,16,18,234,315,ES_MULTILINE | ES_READONLY |
NOT WS_BORDER | NOT WS_TABSTOP
DEFPUSHBUTTON "Close",IDOK,90,274,86,14
DEFPUSHBUTTON "Close",IDOK,90,339,86,14
END
#endif
IDD_UPDATE_DIALOG DIALOG DISCARDABLE 0, 0, 357, 86
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,343,10
CTEXT "Checking for update",IDC_UPDATE_INFO1,7,15,394,10
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,
38,343,14
DEFPUSHBUTTON "Next",IDC_BUTTON_NEXT,226,65,60,14
PUSHBUTTON "Cancel",IDC_BUTTON_CANCEL,290,65,60,14
CTEXT "url",IDC_UPDATE_INFO2,7,26,343,8
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,206,10
WS_TABSTOP,7,67,269,10
END
#ifndef TTCALC_PORTABLE

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -56,6 +56,176 @@ void PrintErrorCode()
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
and then moves the caret
@ -117,7 +287,7 @@ return true;
BOOL WmTabCommand_Press_sin(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("sin()",-1);
InsertText("sin(", ")");
return true;
}
@ -125,7 +295,7 @@ return true;
BOOL WmTabCommand_Press_cos(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("cos()",-1);
InsertText("cos(", ")");
return true;
}
@ -133,7 +303,7 @@ return true;
BOOL WmTabCommand_Press_tan(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("tan()",-1);
InsertText("tan(", ")");
return true;
}
@ -141,7 +311,7 @@ return true;
BOOL WmTabCommand_Press_cot(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("cot()",-1);
InsertText("cot(", ")");
return true;
}
@ -149,7 +319,7 @@ return true;
BOOL WmTabCommand_Press_ln(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("ln()",-1);
InsertText("ln(", ")");
return true;
}
@ -157,7 +327,7 @@ return true;
BOOL WmTabCommand_Press_log(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("log( ; 2)",-5);
InsertText("log(", " ; )", 1);
return true;
}
@ -165,7 +335,7 @@ return true;
BOOL WmTabCommand_Press_abs(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("abs()",-1);
InsertText("abs(", ")");
return true;
}
@ -173,7 +343,7 @@ return true;
BOOL WmTabCommand_Press_factorial(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("factorial()",-1);
InsertText("factorial(", ")");
return true;
}
@ -251,38 +421,42 @@ return true;
BOOL WmTabCommand_Press_asin(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("asin()",-1);
InsertText("asin(", ")");
return true;
}
BOOL WmTabCommand_Press_acos(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("acos()",-1);
InsertText("acos(", ")");
return true;
}
BOOL WmTabCommand_Press_atan(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("atan()",-1);
InsertText("atan(", ")");
return true;
}
BOOL WmTabCommand_Press_acot(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("acot()",-1);
InsertText("acot(", ")");
return true;
}
BOOL WmTabCommand_Press_sgn(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("sgn()",-1);
InsertText("sgn(", ")");
return true;
}
BOOL WmTabCommand_Press_mod(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("mod(;)",-2);
InsertText("mod(", " ; )", 1);
return true;
}
@ -298,7 +472,7 @@ return true;
BOOL WmTabCommand_Press_int(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("int()",-1);
InsertText("int(", ")");
return true;
}
@ -306,7 +480,7 @@ return true;
BOOL WmTabCommand_Press_round(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("round()",-1);
InsertText("round(", ")");
return true;
}
@ -314,7 +488,7 @@ return true;
BOOL WmTabCommand_Press_exp(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("exp()",-1);
InsertText("exp(", ")");
return true;
}
@ -349,6 +523,24 @@ BOOL WmTabCommand_IDCANCEL(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
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)
{
SetDlgItemText( hWnd,IDC_BUTTON_CLEAR, GetPrgRes()->GetLanguages()->GuiMessage(Languages::button_clear) );
@ -412,19 +604,18 @@ void SetLanguageTabPrecision(HWND hWnd)
}
void SetLanguageTabDisplay(HWND hWnd)
void SetLanguageTabDisplayComboRounding(HWND hWnd)
{
char buffer[50];
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_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) );
const int max_r = 9;
for(i=1 ; i<=max_r ; ++i)
{
sprintf(buffer,"%s %d %s",
@ -436,12 +627,58 @@ int i;
}
int r = GetPrgRes()->GetDisplayRounding();
if( r > max_r )
r = max_r;
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_ROUNDING, CB_SETCURSEL, r+1, 0);
}
void SetLanguageTabDisplayComboGrouping(HWND hWnd)
{
char buffer[50];
int i;
const int max_r = 9;
Languages * pl = GetPrgRes()->GetLanguages();
// 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);
// grouping digits
SendDlgItemMessage(hWnd, IDC_COMBO_DISPLAY_GROUPING_DIGITS, CB_RESETCONTENT, 0, 0);
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));
@ -453,19 +690,10 @@ int i;
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_GROUP_SCIENTIFIC, pl->GuiMessage(Languages::display_group_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_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);
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)" .");
@ -730,6 +958,7 @@ TCITEM tab;
}
BOOL WmTabCommand_SetPrecision1(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
#ifndef TTCALC_PORTABLE
@ -866,6 +1095,23 @@ return true;
}
void SetDisablingDisplayWhenScientific(HWND hWnd)
{
if( IsDlgButtonChecked(hWnd, IDC_RADIO_DISPLAY_ALWAYS_SCIENTIFIC) == BST_CHECKED )
{
EnableWindow(GetDlgItem(hWnd, IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC), false);
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC), false);
}
else
{
EnableWindow(GetDlgItem(hWnd, IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC), true);
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC), true);
}
}
BOOL WmTabCommand_DisplayGrouping(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if( HIWORD(wParam) != CBN_SELCHANGE )
@ -873,8 +1119,11 @@ BOOL WmTabCommand_DisplayGrouping(HWND hWnd, UINT message, WPARAM wParam, LPARAM
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;
}
@ -906,19 +1155,6 @@ return true;
}
void SetDisablingDisplayWhenScientific(HWND hWnd)
{
if( IsDlgButtonChecked(hWnd, IDC_RADIO_DISPLAY_ALWAYS_SCIENTIFIC) == BST_CHECKED )
{
EnableWindow(GetDlgItem(hWnd, IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC), false);
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC), false);
}
else
{
EnableWindow(GetDlgItem(hWnd, IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC), true);
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC), true);
}
}
BOOL WmTabCommand_SetDisplayAlwaysScientific(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@ -990,140 +1226,11 @@ return true;
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;
}
}
}
}
void CalcBracketsPos(HWND input, int & start, int & end)
{
DWORD sel_start, sel_end;
SendMessage(input, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
if( sel_start != sel_end )
{
start = sel_start;
end = sel_end;
return;
}
start = 0;
end = SendMessage(input, EM_LINELENGTH, 0, 0);
if( end > 0 )
{
const char * buf = new char[end+sizeof(WORD)];
*(WORD*)(buf) = end;
SendMessage(input, EM_GETLINE, 0, (LPARAM)buf);
start = CalcBracketsPrev(buf, sel_start);
end = CalcBracketsNext(buf, end, sel_start);
delete [] buf;
}
}
BOOL WmTabCommand_Press_bracketsall(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND main = GetPrgRes()->GetMainWindow();
HWND input = GetDlgItem(main, IDC_INPUT_EDIT);
int start, end;
CalcBracketsPos(input, start, end);
SendMessage(input, EM_SETSEL, start, start);
SendMessage(input, EM_REPLACESEL, 1, LPARAM("("));
SendMessage(input, EM_SETSEL, end+1, end+1);
SendMessage(input, EM_REPLACESEL, 1, LPARAM(")"));
if( start == end )
// was empty string - we're setting the cursor inside the brackets
SendMessage(input, EM_SETSEL, end+1, end+1);
SetFocus(input);
InsertText("(", ")");
return true;
}
@ -1131,23 +1238,7 @@ return true;
BOOL WmTabCommand_Press_1div_bracketsall(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND main = GetPrgRes()->GetMainWindow();
HWND input = GetDlgItem(main, IDC_INPUT_EDIT);
int start, end;
CalcBracketsPos(input, start, end);
SendMessage(input, EM_SETSEL, start, start);
SendMessage(input, EM_REPLACESEL, 1, LPARAM("1/("));
SendMessage(input, EM_SETSEL, end+3, end+3);
SendMessage(input, EM_REPLACESEL, 1, LPARAM(")"));
if( start == end )
// was empty string - we're setting the cursor inside the brackets
SendMessage(input, EM_SETSEL, end+3, end+3);
SetFocus(input);
InsertText("1/(", ")");
return true;
}
@ -1171,7 +1262,7 @@ return true;
BOOL WmTabCommand_Press_floor(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("floor()", -1);
InsertText("floor(", ")");
return true;
}
@ -1179,7 +1270,7 @@ return true;
BOOL WmTabCommand_Press_ceil(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("ceil()", -1);
InsertText("ceil(", ")");
return true;
}
@ -1187,7 +1278,7 @@ return true;
BOOL WmTabCommand_Press_min(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("min()", -1);
InsertText("min(", ")");
return true;
}
@ -1195,7 +1286,7 @@ return true;
BOOL WmTabCommand_Press_max(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("max()", -1);
InsertText("max(", ")");
return true;
}
@ -1203,7 +1294,7 @@ return true;
BOOL WmTabCommand_Press_avg(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("avg()", -1);
InsertText("avg(", ")");
return true;
}
@ -1211,7 +1302,7 @@ return true;
BOOL WmTabCommand_Press_sum(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("sum()", -1);
InsertText("sum(", ")");
return true;
}
@ -1219,7 +1310,7 @@ return true;
BOOL WmTabCommand_Press_root(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("root( ; 2)", -5);
InsertText("root(", " ; )", 1);
return true;
}
@ -1227,14 +1318,14 @@ return true;
BOOL WmTabCommand_Press_gamma(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("gamma()", -1);
InsertText("gamma(", ")");
return true;
}
BOOL WmTabCommand_Press_sqrt(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
InsertText("sqrt()", -1);
InsertText("sqrt(", ")");
return true;
}
@ -1333,6 +1424,7 @@ void CreateTabCommandMessagesTable(Messages<BOOL> & cmessages)
cmessages.Associate(IDC_COMBO_OUTPUT_DECIMAL_POINT, WmTabCommand_DisplayDecimalPointChanged);
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);
}
@ -1471,16 +1563,19 @@ BOOL WmInitTabVariables(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND list = GetDlgItem(hWnd, IDC_VARIABLES_LIST);
LVCOLUMN column;
RECT r;
//int list_cx = SetSizeOfList(list);
int list_cx = 280;
GetWindowRect(list, &r);
int list_cx = r.right - r.left;
int header1_cx = 70;
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) );
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) );
ListView_InsertColumn(list, 1, &column);
@ -1497,20 +1592,24 @@ BOOL WmInitTabFunctions(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND list = GetDlgItem(hWnd, IDC_FUNCTIONS_LIST);
LVCOLUMN column;
RECT r;
//int list_cx = SetSizeOfList(list);
int list_cx = 280;
GetWindowRect(list, &r);
int list_cx = r.right - r.left;
int header1_cx = 70;
int header2_cx = 70;
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) );
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) );
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) );
ListView_InsertColumn(list, 2, &column);
@ -1579,6 +1678,7 @@ char buffer[20];
CheckDlgButton(hWnd, IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC, BST_CHECKED);
SetDisablingDisplayWhenScientific(hWnd);
SetDisablingGroupingDigits(hWnd);
SendDlgItemMessage(hWnd, IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC, UDM_SETBASE, 10,0);
SendDlgItemMessage(hWnd, IDC_UPDOWN_DISPLAY_WHEN_SCIENTIFIC, UDM_SETRANGE, 0, MAKELONG(99,1));

151
src/threadcontroller.cpp Normal file
View File

@ -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 &)
{
}

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -48,6 +48,8 @@
#include "resource.h"
#include "languages.h"
#include "winmain.h"
#include "misc.h"
namespace Update
@ -258,6 +260,20 @@ void DownloadProgram::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
@ -298,7 +314,7 @@ DownloadIni down_ini;
IniParser::Error err = iparser.ReadFromFile( down_ini.GetFileName() );
if( err == IniParser::err_ok )
if( err == IniParser::err_ok && IsServerCorrect(url_) )
{
major_ = atoi(ini_value[0].c_str());
minor_ = atoi(ini_value[1].c_str());
@ -578,10 +594,16 @@ unsigned __stdcall UpdateBackgroundProc(void *)
{
using namespace Background;
if( CheckUpdateFromIni(0, url_, remote_file_name_, major_, minor_, revision_, prerelease_, 0) )
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(...)
{
HWND main = GetPrgRes()->GetMainWindow();
SendMessage(main, WM_UPDATE_EXISTS, 0, 0);
}
_endthreadex(0);
@ -636,8 +658,8 @@ void CheckUpdateInBackground()
time_t last = GetPrgRes()->GetLastUpdate();
time_t now = time(0);
// testing only once a day (86400 = 60*60*24)
if( GetPrgRes()->GetCheckUpdateStartup() && last+86400 < now )
// 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);

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* 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());
if( adding)
{
SetFocus(GetDlgItem(hWnd,IDC_EDIT_VARIABLE_NAME));
}
else
{
SetFocus(GetDlgItem(hWnd,IDC_EDIT_VARIABLE_VALUE));
SendDlgItemMessage(hWnd, IDC_EDIT_VARIABLE_VALUE, EM_SETSEL, value.size(), value.size());
}
return false;
@ -263,6 +268,8 @@ BOOL WmTabCommand_AddVariable(HWND, UINT message, WPARAM wParam, LPARAM lParam)
{
int id = AddNewItemToVariableList(list, name, value);
SelectOnlyOneItem(list,id);
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->SaveToFile();
}
}
while( code != ttmath::err_ok );
@ -324,7 +331,11 @@ adding = false;
if( code != ttmath::err_ok )
ShowError(list, code);
else
{
ChangeItemInVariableList(list, id, old_name, name, value);
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->SaveToFile();
}
}
while( code != ttmath::err_ok );
@ -357,6 +368,7 @@ int items = ListView_GetSelectedCount(list);
char * buffer = new char[buffer_size];
bool all_deleted = true;
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->GetThreadController()->StopCalculating();
for( id = ListView_GetItemCount(list)-1 ; id!=-1 ; --id )
@ -375,6 +387,7 @@ int items = ListView_GetSelectedCount(list);
GetPrgRes()->GetThreadController()->StartCalculating();
GetPrgRes()->SaveToFile();
delete [] buffer;

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* Copyright (c) 2006-2011, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -51,8 +51,17 @@
/*!
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);
// we're using GetLanguages() simultaneously in two threads, this is to be sure
@ -107,11 +116,17 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
// there can be another variables/functions saved by other instantion of TTCalc
// we're reading them now
GetPrgRes()->ReadVariablesFunctionsFromFile();
GetPrgRes()->SaveToFile();
DestroyPadWindow();
CloseHandle( (HANDLE)thread_handle );
}
catch(...)
{
ShowError( Languages::unknown_error );
}
return 0;
}
@ -152,6 +167,10 @@ bool sent = true;
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;

View File

@ -1,19 +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.1/ttcalc-0.9.1-setup.exe?use_mirror=dfn
filename = ttcalc-0.9.1-setup.exe
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 = 1
version.revision = 3
version.prerelease = 0
[portable]
url = http://downloads.sourceforge.net/project/ttcalc/ttcalc/ttcalc-0.9.1/ttcalc-portable-0.9.1-bin.tar.gz?use_mirror=dfn
filename = ttcalc-portable-0.9.1-bin.tar.gz
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 = 1
version.revision = 3
version.prerelease = 0