Accounting software helps tame the complex parts of running a business. Putting data into rows and columns is a good way to accomplish that, so our software uses spreadsheet-like tables almost everywhere.
When we first wrote Goldenseal in the mid to late 1990s, we had to build the table interface completely from scratch. There is code that fills in text, draws lines between cells, handles clicks and double-clicks, and deals with all the other little details. Altogether, it took about 2 programmer-years to write all the C++ code that runs Goldenseal’s tables.
Those handmade tables have not aged very well. Despite a few appearance updates, they still look “old”. On Windows, they flicker and flash. Even worse, it’s complicated code that is hard to maintain.
For Goldenseal Pro on Macintosh, we use Apple’s Cocoa library, which already contains a complete table system (NSTableView and helpers). That’s good news, and bad news.
The good news is that Cocoa table views handle most of the nitty-gritty details for drawing and behavior. It only takes a few lines of code to get a functioning table. Even better, when future OS updates change the interface appearance, the built-in tables will update too. 5 years from now, the tables in Goldenseal Pro for Mac won’t look like the spreadsheet equivalent of bell-bottom jeans.
The bad news is that Apple built Cocoa mostly to support their own apps, and they rarely make it easy for other programmers to understand and use. It’s kinda like buying something from Ikea, but without step-by-step instructions. Instead, there’s just a nice picture of the end product, and a list of parts. Where and how to use them? You need to figure that out on your own.
Usually there are sample apps, from Apple and others. Often they are outdated, but it still helps to see a working example. Stack Overflow usually has answers for specific error messages or problems. Still, getting Cocoa tables to work has required much trial-and-error.
Despite the obstacles, we’re making decent progress on the tables for the Macintosh version of Goldenseal Pro. Last week, they started showing columns and titles. This week they are filling in data, and giving a data entry field when you click on a cell. They look and act like tables now. Still some formatting and other details to finish, but it’s moving ahead at a decent pace.
The MFC library for Windows does not include a table class. That has the same good news/bad news as Cocoa, only reversed. Other people have put a few projects online that may work. We’re looking at them now. Also, we already have working table code, and maybe it just needs some updating.