A Text Field Cell for Totals
October 15th, 2009
Someone asked me recently how to add visual elements to a text field. This someone had several ideas that were "creative" but bat-shit nuts. I'm always hesitant to "give a man a fish" but figured the example I was thinking of was not only a good lesson to Cocoa newbies but a useful bit of code for others to use. It's a text field cell subclass that draws "total bars" top and/or bottom in several styles and in any color.

The total bar cell can be used in a table, or in a label, in a house, or with a mouse. You can use it free of charge, I'd just like credit, by and large. See the license before you use it, or my friend, I just may lose it ...
Download
You can download a zip file containing the project (complete with a demo app), the license, and a brief description here. May its demonstration of Cocoa goodness bring you giggly happiness.
How To Use
To use the cell:
- Copy JLNTotalBarTextFieldCell.m and JLNTotalBarTextFieldCell.h into your project.
- Include JLNTotalBarTextFieldCell.h wherever you intend to talk to it.
- Configure it as needed (see the demo application in the Xcode project for examples of how to use it).
- Set a field (or table column) cell's class name to JLNTotalBarTextFieldCell to use its default configuration with no extra code.
A Few Words of Caution: Though tested thoroughly, there could still be bugs. Also, the drawing and positioning of the text isn't perfect. It depends on the height the cell is given (ie, row height in a table view, or height of the NSTextField in which it's hosted). Adjust to taste.