开发者

Modifying old Windows program for Mac OS X

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.

★✩


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.


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


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.


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! :-)


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++.


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜