Page 1 of 6

New calculator for ReactOS

Posted: Tue Mar 13, 2007 3:41 pm
by Carlo Bramix
Hello,
I wrote another calculator for ReactOS because I don't like winecalc very much.
I did it with really few lines of source code and for this reason it's very light weight.
Its working system is almost based on the mechanisms of Win32 APIs (that's why it's so small).
It also implements some operators not available on winecalc because its engine uses a simple but robust RPN engine, which converts between infix and postfix notations (when I wrote this core, some idea has been taken from kcalc too).
Still some things need to be completed, but I can say it's eveolving well and I'm satisfied of the results I'm getting.
It's my intention to call it "ReactOS Calc" and I would like to release it under GNU GPL license. I hope the are no problems on the choice of the name and of course I would be happy if it could be included into ReactOS in the future.

While it seems to work fine on Microsoft's operating systems, it doesn't work well on ReactOS, even with the latest 0.3.1.

Here there is small list of my errors:
1) I create my dialogbox and then I call SetWindowsHookEx() for listening the keyboard inputs. Unfortunately, it doesn't work and it seems my keyboard handler is never called.
2) If I call ShowWindow() with SW_HIDE for hiding child controls on the dialog they won't disappear. A similar thing happens with SW_SHOW. I must do an action for forcing the entire window update, like minimizing and restoring my dialogbox, otherwise it won't work.
3) It seems that the group box control doesn't work.
You know, there are some radio buttons with HEX, DEC, OCT, etc and they are on the same line.
When I select, for example, the RADIANTS radio button, the one with DEC text loses its check.
I used BS_AUTOCHECKBOX and BS_AUTORADIOBUTTON styles.
4) Clipboard-out doesn't seem to work. If I write "12" and then I select "copy", when I try to paste into the notepad I get two characters, but I these characters are displayed as two empty rectangles.
5) Clipboard-in doesn't seem to work. I write into the notepad "1+2=", I copy and paste into the calculator, but the calculator crashes.
6) Into the aboutbox I put the ReactOS logo. But there is a GFX glitch.
The background around the image isn't cleaned.
In my opinion it wouldn't be too difficult to solve this issue if you know where to put your hands.
The solution is: read the pixel at coordinates (0,0) of the image, create a brush with that color and clean the space around the image with that. I tried to search where it's done, but it's not easy to find a small thing into 140 MB of sources, perhaps the man who knows that source better will be able to do this fix in few seconds.
7) Into the about box there is also a read only edit control with some text "This is ReactOS Calc... GNU GPL... etc..." but the vertical scrollbar doesn't work. My text is just one line bigger than the vertical size of the edit control.

I hope this will be help you and me too.

Sincerely,

Carlo Bramini.

EDIT: just corrected some syntax errors

Posted: Tue Mar 13, 2007 7:00 pm
by preston
Could you please provide a link to source code or compiled binary? I would like to try it since winecalc is really killing me. It's completely useless...

Posted: Fri Mar 16, 2007 8:59 pm
by Carlo Bramix
Hello,
I started the project "ReactOS Calc" at sourceforge.net
As soon as the sourceforge team will approve it, I will upload the files.
The binaries are available with italian and english languages.

At the moment, missing things are:
1) missing icon.
2) missing context help.
3) missing help file.
4) missing digit groups (I didn't understand exactly what it means...).

Unfortunately, it's not really useful on ReactOS at the moment, but I'm sure that things will change a lot in the near future.
Anyways, I hope this work will be appreciated by this nice community.

Sincerely,

Carlo Bramini

Posted: Tue Mar 20, 2007 6:30 am
by niteice
Carlo Bramix wrote:4) missing digit groups (I didn't understand exactly what it means...).
Writing numbers with seperators, i.e. 1,000,000 instead of 1000000.

Posted: Fri Mar 23, 2007 2:33 pm
by Carlo Bramix
Hello,
I released ReactOS Calc to the public.
You can find it here:

http://sourceforge.net/projects/reactos-calc/

I hope you will find it useful.

Sincerely,

Carlo Bramini

Posted: Fri Mar 23, 2007 5:09 pm
by counting_pine
Works quite well here on Windows. It doesn't work the same as calc in every respect, but it's pretty close. And, unlike winecalc, Exp does what you'd expect from the Windows version.

Posted: Fri Mar 23, 2007 7:02 pm
by dreams
Nice, it works in ReactOS 100%

Posted: Fri Mar 23, 2007 7:46 pm
by preston
finally calc worth of trying :)

no seriously winecalc is crap. reactos calc ftw

Posted: Fri Mar 23, 2007 8:19 pm
by ThePhysicist
Nice work.

But it's gradian not gradient, and it's radians, without t. ;-)
And a full circle is 400 grad, not 200!

An idea for a workaround to the keyboardhook prob:
You could create the main window as a modeless dialog and process the keyboard messages in the message queue.

Suggestion for an enhancement: When clicking inv, the buttons could change from ln to e^x, sin to sin^-1 etc.

Posted: Fri Mar 23, 2007 8:41 pm
by Carlo Bramix
ThePhysicist wrote:But it's gradian not gradient, and it's radians, without t. ;-)
Thank you, I corrected this translation error.
Hopefully, the italian names are right...
ThePhysicist wrote:And a full circle is 400 grad, not 200!
Ouch! you are right! Stupid mistake!
ThePhysicist wrote:An idea for a workaround to the keyboardhook prob:
You could create the main window as a modeless dialog and process the keyboard messages in the message queue.
Perhaps I could do something like "#ifdef KEYB_MODE==KEYB_POLL".
This will keep both solutions working.
However, I hope that the defect on SetWindowsHookEx() will be solved even if I will do this patch.
ThePhysicist wrote:Suggestion for an enhancement: When clicking inv, the buttons could change from ln to e^x, sin to sin^-1 etc.
Good idea, I could append it into the todo list.

Sincerely,

Carlo Bramini

Posted: Fri Mar 23, 2007 9:21 pm
by w3seek
keyboard hooks are overkill...

Posted: Sat Mar 24, 2007 12:35 pm
by Carlo Bramix
Hello,
I did these changes for now:

* Fixed english translation for "Radians" and "Gradians".
* Corrected conversion between radians and gradians angles.
* Added work-around for catching keys without the keyboard hook (selectable at compile time).
* The version number of the programme has been moved from the resource files to ABOUT.C.

I won't be able to test it with ReactOS until monday.
If it will work, I think I will release this bug-fixed version.

Sincerely,

Carlo Bramini

Posted: Mon Mar 26, 2007 11:09 am
by Carlo Bramix
Carlo Bramix wrote:I won't be able to test it with ReactOS until monday.
If it will work, I think I will release this bug-fixed version.
It doesn't work yet with ReactOS.
The MapVirtualKeyEx() and ToAsciiEx() fail during my tests.

Sincerely,

Carlo Bramini

Posted: Mon Mar 26, 2007 2:15 pm
by mvent2
Looks nice :)

I also have a suggestion. Wouldn't it be nice so that if you change between degrees, radians and gradians, the current number in the calculator gets converted automatically, similar to Hex/Dec/Oct/Bin?

eg, I type in 360 under degrees, then click on the gradians radio button, the calculator should say 400.

Posted: Mon Mar 26, 2007 7:16 pm
by counting_pine
The difference with Bin/Hex/Oct is that any operations done on a Hex number, are returned as a Hex number.
With angles, if you use a function such as Sin, then the angle is converted into a ratio (Opposite/Hypotenuse), which doesn't have units.

You convert a ratio back into an angle using Inv Sin. Of course, the unit of angle is important here too. But if you have a ratio in the calculator display, changing e.g. from degrees to radians, would multiply that ratio by Pi/180, which you wouldn't want.

So, an automatic conversion would cause a great inconvenience.
It might be an idea to have extra buttons to convert between the angle units, although adding more buttons means deviating from the original calc's layout. That would be a pretty big decision to make.