JLNTotalBarTextCell

 

A simple, configurable NSTextFieldCell demo (Cocoa / Objective-C) that can be used to display “total bars” (single or double rules above and/or below the cell).

Details

The cell can be used in either a plain NSTextField “label” or as the data cell prototype in a table column. It was created purely as a quick demonstration on creating an NSCell subclass to do custom drawing. See the caution below.

I wrote a post titled “A Text Field Cell for Totals” with a full explanation of the design goals.

Usage

  1. Download the source using the link below.
  2. Copy JLNTotalBarTextFieldCell.m and JLNTotalBarTextFieldCell.h into your project.
  3. Include JLNTotalBarTextFieldCell.h wherever you intend to talk to it.
  4. Configure it as needed (see the demo application in the Xcode project for examples of how to use it).
  5. Set a field (or table column) cell’s class name to JLNTotalBarTextFieldCell to use its default configuration with no extra code.

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.

License

This source code is free to use in any private, public, or commercial software products, with attribution. See the full license included with the source code.

Source & Demo

[button link="http://media.nozzi.name/sourcecode/JLNTotalBarTextCellDemo.zip" style="green" size="large"]Download Source[/button]

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2011 Joshua NozziJoshua Nozzi is a Cocoa developer for hire.Suffusion theme by Sayontan Sinha