tags:

views:

151

answers:

8

This application was written for windows back in 1998, I loved using this program, Now I want to learn how to make it work on Mac, And maybe changing and adding functionality,

The problem is I don't know where to start, I Have studied C++ php, javascript, But don't really know how to read this code. or where to start.

Thanks for taking a look http://github.com/klanestro/textCalc

From http://www.atomixbuttons.com/textcalc/

What is TextCalc?

TextCalc is a combination of an expression calculator and a text editor. Being both, it has several advantages over conventional calculators.

1) You can evaluate expressions like 9*4-2+95-12 just the way you write them on paper.

2) You can put comments besides your answer and expressions.

3) You can save, reload, edit and print your results and expressions.

4) You do not need to write your answer down on a paper before computing another expression, as you can leave the previous result in the editor.

5) You can open an existing text data file and perform calculations on it.

6) You can apply an expression to many numbers at one go. For example, you can change the list 1 2 3 4 5 to 2 4 6 8 10 by multiplying each number by 2.

7) You can sum, average, convert into hex etc. a list of numbers easily.

The editor is capable of parsing numbers and strings enclosed in double quotes " ". Numbers will be colored blue and strings will be colored red. This makes it ideal for editing files containing numeric data.

★✩

+2  A: 

Check out the Calculator example from the second chapter of Stroustrup's "The C++ Programming Language".

Amit Kumar
+1  A: 

It looks like this application is written using MFC, which is quite Windows-centric. Translating this program to use a different API such as Cocoa would be a lot of work, and would require good familiarity with both MFC and Cocoa. Not to mention the work involved in translating the C++ to Objective-C, of course.

You may be better off running it as-is in a virtual machine such as VirtualBox, or under Wine. Unfortunately, the free version of Microsoft Visual C++ does not include MFC, so to modify this code you would have to either purchase a non-free version of MSVC, or translate the program to "bare bones" Win32, without using MFC.

Greg Hewgill
You wouldn't need to convert it to Objective-C if you used Carbon. Or is my knowledge of OS X too rusty and they dropped support for that? (IIRC part of OS X itself is written in C++, so I doubt that.)
sbi
A: 

The code looks to be in C++. C++ is available on Macs.

The code relies on MFC, which if course is not available on OS X. So you'll need to pick a framework like WxWidgets, Qt, FLTK, etc. that's available on both the Mac and Windows. Then you need to translate from MFC to your new framework.

In the process you'll learn more about MFC than you intend to.

Max Lybbert
MFC was available for Classic Mac.... Microsoft released a Cross Compiler - Visual C++ for Mac in 95/96. Its a version of the tools they used to put Office on Macintosh.
Tony Lambert
I didn't know that. Thanks. Edited.
Max Lybbert
+1  A: 

The core part of this program (Expression Evaluation) has been taken from this smaller program written by Zoly Farkas.

So I would suggest the following:

  • Learn Objective C.
  • As an exercise, port Zoly Farkas' Expression Evaluation to Objective-C, to use as a library or on the command line.
  • Learn Cocoa.
  • As an exercise, create a graphical interface for your library using Cocoa. You don't need MFC.

Should be fun! :-)

Nicolas Raoul
A: 

Why not rewrite it in C# .NET and use Mono to compile it on the Mac? You can rewrite the GUI parts in Native Cocoa from c# using a wrapper. Depends on your program but this program doesn't sound like your going to sell it to the public so L+F issues are probably not an issue.

Tony Lambert
relying on mono and it's winforms support is even worse than rewriting in objective-C
Wimmer
+3  A: 

Based on the screenshots and info on the TextCalc site, I think this is best implemented as a Mac OS X service. You can assign a hot key to trigger your service in the System Preferences -> Keyboard -> Services.

It would actually be rather easy. You don't need to write the text editor portion, it will be available in all text areas in all apps. You will be handed the text the user has selected, and all you need to do is evaluate it. There's a built-in command line tool, bc, that you should be able to delegate this to.

There is a guide to implementing services. You will need to read through the Cocoa intro material to understand it. This is a good first project, though.

I don't think there's any reason to try to read the source of the original app in this case. You just need to know what you want the behavior to be.

Ken
By far the best solution... this is the Mac way to do this one.
Andrew McGregor
If you do want to do a text editor, start from the TextEdit sample code. This is the source to the app that ships in /Applications. The modification to add math evaluation will be simple once you have some feel for Cocoa.
Ken
A: 

If you decide to re-write it, I recommend RealBasic. It has many components that will help shorten the development cycle and you can compile the program for Windows, Mac and Linux.

Easy to learn and very productive platform.

Square Rig Master
+1  A: 

I would not recommend to "port" such a old program using MFC which you cant use on a Mac anyway.

Rather i would recommend to create the skeleton of a new blank application and then to insert more or less large fragments from the old code. The skeleton may use whatever language is appropriate: C++, Objective-C, real Basic. But as the code to reuse is C++ its probably best to use C++.

RED SOFT ADAIR