Merlin's Tower
Bill Catambay, Pascal Programmer

Source for Mac OS X

Below are some complete Pascal projects, including source code, resources, project file and running application. This source code is provided as-is, free of charge. If you have short questions about any of this code, you may e-mail the author, but please do not expect a tutorial on how to program.

NOTE: Merlin's Tower is now being used as a repository for Free Pascal (FPC) projects as well. "FPC" will be listed as a highlight for all FPC contributions.

Source Code Package Highlights
GNU Regex, by Ryan Joseph
Posted: 02-11-09
This is a FPC wrapper for the GNU regular expressions library. I didn't include a demo program because all that would contain are example expressions which one can find anywhere. I'm happy that after all my headache trying to get regular expressions in Pascal everyone can now use this.
- GNU expressions library
- Event processing
- Menu processing
- HIView
- Custom views
SkelView, by Ingemar Ragnemalm
Posted: 11-02-08
SkelView is intended as an addition to View Manager (and thereby TransSkel). It is a simple interface to a plain HIView, using callbacks for drawing, mouse clicks and keydowns, in order to implement simple views. The big difference to ViewManager is that SkelView is for building custom views in a simple way rather than handling the existing ones. Instead of implementing a big event central, you write a few callbacks and pass them to SkelView.
- Carbon Events
- Event processing
- Menu processing
- HIView
- Custom views
Toolbar Manager 1.0, by Ingemar Ragnemalm
Posted: 11-02-08
A module for simplifying toolbar programming. Application framework using the Carbon interface. Simplifies event processing, menus etc. It includes add-on units like TransDisplay (for logging) and ViewManager (for HIView management). Includes source and demo application.
- Carbon Events
- Event processing
- Menu processing
- Toolbar management
TranSkel 4.0.1, by Ingemar Ragnemalm
Posted: 11-02-08
Application framework using the Carbon interface. Simplifies event processing, menus etc. It includes add-on units like TransDisplay (for logging) and ViewManager (for HIView management). Originally written for very early MacOS, now modernized to modern Carbon. Includes a number of demo programs.
- Carbon Events
- Event processing
- Menu processing
- HIView
- TransDisplay
FPC Carbon Demos, by Richard Ward
Posted: 8-10-08
This package includes 10 demo applications sampling various features of OS X implemented in FreePascal. The package includes the source code, NIBs and executable universal applications.
- Carbon Events
- Core Graphics/Quartz
- NIBs
- File paths
- Resizing windows
HICascadingView, by Ryan Joseph
Posted: 7-9-08
HICascadingView creates a HIView like that found in the Finder's Get Info window. This example is written in MW Object-Pascal, and includes project file, source code, and demo application.
- Carbon events
- Cascading Views
- Various widgets
SplitView, by Ryan Joseph
Posted: 7-9-08
This is a small demo using HIViews which opens a window and sets the panes for split views. This example is written in MW Pascal, and includes project file, source code, and demo application.
- Carbon events
- Split view panes
- Resizable panes
- Pane toggle
New Skel, by Ingemar Ragnemalm
Posted: 7-14-07
Lookalike for the old Skel demo, but rewritten from the ground up for modern Carbon. Carbon Events, nibs, menus. A reasonable skeleton program to build from, including stubs for the most basic event types.
- Carbon events
- NIBs
- Menus
- Basic event types
API Wars, by Ingemar Ragnemalm
Posted: 7-14-07
Graphics demo with attitude. In particular it is a CG demo covering more than the usual trivial rectangles, including loading images from files. It also shows, for the record, that QuickDraw is not as old-fashioned and uncapable as some people try to tell us.
- Graphics
- Loading images from files
- QuickDraw
iSee Videots, by Christian Franz
Posted: 1-30-07
This is a small sample program that demonstrates accessing your iSight through the SequenceGrabber, and how to apply some video effects in real-time. Includes sample app that requires a video camera, as well as source code.
- Carbon events
- Sequence grabbing
- Video effects
- Grayscale
- Edge detection
HISimpleList, by Gale Paeper
Posted: 9-01-06
Pascal conversion of Apple's HISimpleList sample code. Shows how to use HIView related APIs to implement CarbonEvents based custom controls. Demonstrates using CFMLateImport sample code as an alternate method for calling CoreGraphics routines in a PPC CFM project without Mach-O function pointer hassles. Updated for compiling with Mac OS X Pascal Interfaces Version G and common source code building with CodeWarrior Pascal and GNU Pascal compilers. Includes projects for CW Pro 8.3 CW Pascal building, CW Pro 8.3 GNU Pascal plugin building, and Xcode 2.x GNU Pascal Xcode integration Kit building.
- HIView Custom
- Controls
- CoreGraphics Drawing
- CarbonEvents
- Event Handling
OpenAL Demo, by Christian Franz
Posted: 8-13-06
This demo is based loosely on Apple's Objective C OpenAL Demo, and sports four audio sources and one listener. Click with your mouse to re-position the listener. It includes the source code, application, and package bundle containing resources.
- Carbon events
- Sound playing
- 2D sound positioning
- Resources from bundles
Quartz Demo, by Christian Franz
Posted: 4-30-06
Demonstrates use of mixed QuickDraw and CoreGraphics. Also shows how to use Rotation, Blend Modes, Transparency, and mirroring an image. This XCode 2.1 demo project contains source code written in Free Pascal to demonstrate simple use of CoreGraphics in a Window along with QuickDraw.
- QuickDraw
- CoreGrahics
- Image Rotation
- Image Blend Modes
- Image Transparencies
CTRL Demo, by Christian Franz
Posted: 11-30-05
Demo application that installs two custom controls into a window and shows you how to handle direct control clicks and commands sent by the control. When you click into the control, you will be presented with a color picker. After picking a color, the control will send a command to your application.
- Carbon Custom Controls
- Carbon Event Handlers for windows and Applications
- Carbon Commands
GWorld Demos, by Ranko Bojanic
Posted: 10-2-05
This project uses GWorld mappings and linear interpolations between starting and ending colors (click on colored rectangles in bottom right corner to get new random starting and ending colors or use color picker to select these colors). Click on 'Copy from GWorld' button to see a gradual transition from one color into the other. Includes source code, executable, and CW Pro 7 project files.
- GWorld mappings
- Linear interpolations of colors
Makevc, by Willett Kempton
Posted: 4-17-05
Makevc is a Pascal program to make vCards, and is useful for converting a contact list or address book from an older program. Makevc does a good deal of recognizing (e.g., pulling street, PO Box, zip, country, etc., out of a unitary, undifferentiated address field. This project was compiled with GPC and Dr. Pascal, and includes source and executable (runs in Terminal mode on OS X and DOS mode on Windows).
- GPC Pascal example
- Creates vCards
- Interprets unitary, undifferentiated fields
RandomWalks, by F.C. Kuechmann
Posted: 2-15-05
This is a sample Pascal project that uses the GNU Pascal plug-in for CW Studio 8. This program displays a window with random walk paths drawn on screen, and includes source code, project, and executable.
- GNU Pascal plug-in
- Event Handling
- Graphics drawing
- Collision detection
Game of Life, by F.C. Kuechmann
Posted: 2-15-05
This is a sample Pascal project that uses Codewarrior Pro 8 with Metrowerks Pascal. This program is a Pascal version of Conway's "Game of Life", and includes source code, project, and executable.
- CW Pro 8
- Event Handling
- Graphics drawing
- Game of Life simulation
HIToolbar Pascal, by Ryan Joseph
Posted: 12-10-04
This is a unit and library that supports the port of HIToolbar to Pascal.
- HIToolbox functions
Call Mach-O Samples, by Adriaan van Os
Posted: 7-20-04
Samples that show how to call Mac OS X routines that are not in Carbon (Codewarrior and GNU Pascal), and how to write a Mac OS X framework in GNU Pascal (including integration with Codewarrior). Includes source code and project files.
- Mach-O Calls
- GNU Pascal
- Codewarrior GNU integration
Object Array Defs, by James Derrick
Posted: 7-17-04
In response to the recent query about arrays, here is a library which manages arrays of various sorts, including arrays of objects, and also has facilities for performing FFTs and plotting data. It includes the source code and project file.
- Array handling
- FFTs
- Data plotting
Bubul, by Jean-Claude Jesior
Updated: 6-24-04
This sample is mainly an illustration of the use of CopyBits in Carbon. It also shows how to handle movable dialogs and how to set their font. Project has been compiled with CodeWarrior 8.3 in Mac OS 10.3.2, and includes source code, project files, and executables for both OS 9 and OS X.
- Carbon Copybits
- Movable dialogs
- Setting fonts in buttons and static text
OGL Hovertank, by Christian Franz
Posted: 3-4-03
Shows how to use OpenGL camera, and some 3D movement transformations. Also shows some basic vehicle effects such as acceleration, inertia, and friction. Includes project file, executable and source (requires OpenGL libraries).
- OpenGL calls
- OpenGL camera
- OpenGL 3D movements
- Vehicle effects
GrabBag, by David Bainbridge
Posted: 7-31-02
This project contains the Pascal converted code for the GrabBag sample found in the CarbonLib 1.6 GM SDK. This conversion is not from Apple but from myself as an indepent contractor to help any Pascal programmers take full advantage of Carbon.
- CarbonEvents
- Sheets & Alerts
- Event Handlers
- Nib's
- Preferences
- Help book
TESample, by Bill Catambay
Posted: 11-28-01
This is the original TESample code that Apple created for the 68K machine. It has been drastically changed to work under Carbon.
- Event driven
- Resizable Window
- Text Edit
Traffic Lights, by Ranko Bojanic
Posted: 11-28-01
Simple Carbon app which displays red and green lights in a resizable window.
- Event driven
- Resizable Window
Battle Sea, by Matteo Varisco
Posted: 10-10-01
This page describes the game Battle Sea, a game similar to the board game Battleship, and provides the Pascal source code, a project file and a running application.
- Board Game
- Event driven
- Windows & Dialogs
- Game graphics
- Game AI
Coin RAEL, by Matteo Varisco
Posted: 9-26-01
This is a CodeWarrior Pro 4 project showing how to create a game in Pascal using the Carbon environment (it works with MacOS 9.0.4, 9.1 and 10.0.4). Includes source code, project file, and classic OS 9 executable.
- Board Game
- Event driven
- Windows & Dialogs
- Multiple Undos
- Offscreen drawing
- Game graphics
BasicAppCarbon, by Ron Drake
Posted: 9-21-00
This is a basic shell program simply to demonstrate a carbonized Pascal project.
- Menus
- AppleEvents

This page authored by Bill Catambay
Comments to: Pascal Central Editor