Downloading Horstmann's Graphics Libraries and Creating a Macintosh xCode project that Uses Them

for Macintosh OS X 10.4 (Tiger)
JL Popyack, v1.0 -- many thanks to Chris Bonhage for assistance with this!

So, you own a Macintosh and would like to use Horstmann's Graphics package with xCode. First of all, you are really cool and you know it, but try not to be too much of a pain about it.

One of the sad realities of the computer business is that each of the major platforms (Mac, Windows, UNIX) has produced its own distinct approach to graphics, so there is no 'graphics standard' for C++. People who write code that is supposed to be portable across platforms face the daunting task of implementing routines in unusual ways for the different platforms so that the same programmer interface can be used to do things that look the same on each one. In this writer's humble opinion, the Macintosh Toolbox utilities were the best of the three, but the marketplace has been dominated by the Windows platforms, so there you go.

Although Horstmann's Graphics package does not have modules for the Macintosh, it does have them for X11 graphics in UNIX, and therefore the package can be used successfully on a Macintosh running OS X, as described below:.

First, you will need to have xCode and the X11 libraries installed. Follow the for this.
Make sure you also install the X11 libraries
.

Download the following zip file: , which contains an xCode project, pre-configured for Horstmann's Graphics using X11.

Unzip these files in a reasonable spot on your hard drive.

Find the project file and open it. You should see the following:

The code for the sample file is replicated below:

#include "ccc_x11.h"
#include "ccc_shap.h"
using namespace std ;

int ccc_win_main()
{
  Point origin(0,0) ;
  Point p(4, 2.5);
  Line myLine(origin, p);
  Circle smallCircle(p, 2.2);
  Circle bigCircle(origin, 6);
  cwin << origin << p << myLine
       << smallCircle << bigCircle;

  return 0;
}

You can select "Build" from the project menu in order to compile and build an executable project. However, if you try selecting "Build and Go", you will (probably) get an error message saying something like the following:

[Session started at 2007-02-01 07:32:45 -0500.] /Users/you/Desktop/X11_OSX Folder/X11_OSX/build/Release/X11_OSX error: can't connect to server X11_OSX has exited with status 255.

Don't despair! Instead, go to the Finder, and find your executable code (it should be called "X11_OSX" and located in the "build" folder).

Double-clicking X11_OSX should automatically invoke the X11 server on your Mac ("Darwin"), which will present you with the following dialog:

We suggest choosing "Rootless", which will allow your X11 session to appear in overlapping windows with your Mac windows. ("Full screen" hides the Mac environment entirely.)

If you're lucky, all goes well, you should produce a graphics window with output similar to that shown below. A few other "X11 session" windows may also appear.

So that you don't have to go through this hassle every time you want to create a graphics program, you should save your entire project folder somewhere safe so that you can re-use it again and again. When you want to use it, simply remove your test program (e.g., you can select "sample.cpp" in the project window and hit the "Del" key) and add a new program to the project.