This is a small set of very handy classes for implementing "Panes,"
i.e., drawn elements in a window. They are compatible with
PowerPlant, or any other C++ code, because they make no references
to objects or datatypes outside of themselves.
In keeping with my philosophy of non-monolithic classes, you are not required to use the whole batch when you only need one or two. The class diagram to the right shows which pane classes require which other ones; as you can see, you never need more than two other classes for any particular pane class. (Note: some of the newest pane classes are not shown.)
You can download the files individually below, or get the whole set
The descriptions below are a little brief, because the clases are
relatively simple. Please examine the header file for full member
- Pane.h defines the base
class for all the other classes described here. All panes have a
rectangular extent defined by mFrame which describes the
pane's size and position. Pane is an abstract base class; derived
classes must define at least the Draw method.
and TextPane.cpp define
a pane which draws a string on a single line. The string to be
drawn is contained by mText (a Pascal string). Various
other members allow you to set the text font, size, style, color,
alignment (within the mFrame), and shadow color (if any).
and UrlPane.cpp define
a subclass of TextPane which, when clicked, launches the URL via
Internet Config. The URL may be defined in the mURL
member variable, or if this is left empty, the text itself
(mText) will be used as the URL.
and IconPane.cpp define
a pane which draws itself as a color icon. You give the constructor
the resource number of the first 'cicn' resource to load, and the
quantity of icons that should be loaded. If this quantity is more
than one (it defaults to two), an IconPane can act like a button:
when you click it, the pane's state (i.e., which icon is drawn) is
incremented. If mPopBack is true, this increment
will be only temporary, thus giving you a standard push-button
behavior. If it is false (the default), then the button
stays in its new state until clicked again.
and PictPane.cpp define
a pane which draws a PICT resource. You pass the constructor the
ID number of the PICT to be drawn, and the frame will automatically
be set to the picture's size. The picture memory is released when
the pane is destroyed.
and Enclosure.cpp define
a pane contains (encloses) other panes. The contained panes are
stored in a
of pane pointers; add a new one with code such
as myEncl.mSubpanes.push_back( &myOtherPane ).
(Note: If an enclosed pane is
destroyed, then either its enclosure must also be destroyed, or the
pointer to the destroyed pane must be found and removed from
mSubpanes.) Enclosures have the following effects:
This is a very powerful mechanism for building a complex interface. Note
that if you use this class, you will also need to get
or else modify it to use some other vector class.
- Subpane drawing is clipped to the enclosure's bounds.
- Subpane coordinates are all relative to the enclosure's
- If the Enclosure's mOwnsSubpanes flag is true
(the default), then when the Enclosure dies, all of its
subpanes are destroyed as well.
and ScrollbarPane.cpp implement a scroll bar. You'd think that with the Toolbox, making a simple scroll bar would be easy, but in fact it's a major pain -- unless you use a class like this, which handles the ugly details for you. As a bonus, your scroll bar will be fully compliant with
Smart Scroll (though this is not required, by you or your users).
provide a scrolling view onto some other pane. You can have horizontal or vertical scrollbars (or both), and even reserve extra room to the left of the horizontal scroll bar or at the top of the vertical one if you need space for indicators, pop-up menus, etc. This class is simple to use but very powerful. You can place a ScrollPane in the middle of a dialog, or have one giant ScrollPane in your window, making it into a standard scrolling document window (great for use with
provide a TextEdit (input) field, usable in any window. To use this properly, you'll want to call its special methods to handle Cut, Copy, Paste, and window activation/deactivation.
and TwistPane.cpp, plus the resource file TwistPaneIcons.rsrc (which you may need to get from the full distribution),
provide a little twisty triangle like those in the Finder and the CodeWarrior group panes. It's not Appearance-savvy, but it works under all versions of MacOS.
Share and enjoy!
Please send bug reports, questions, or comments to
. . . . . Joe Strout