Copyright ©1995 by NeXT Computer, Inc.  All Rights Reserved.


Inherits From: Object
Declared In: apps/InterfaceBuilder.h

Class Description

The IBPalette class defines Interface Builder's link to a dynamically loaded palette.  Interface Builder uses the facilities of this class to load a custom palette's interface and executable code.

Each loadable palette must contain a subclass of IBPalette, and this class must be identified in the palette's palette.table file. Interface Builder creates an instance of this subclass when it loads the palette.  It then sends this object an originalWindow message to access the window that contains the objects to be loaded into the Palettes window.

If a palette contains non-View objects (MenuCells, Windows, or objects that will be deposited in the File window), the subclass must implement the finishInstantiate method to associate each View object that's displayed in the File window with the non-View object that should be created when the user instantiates the object by dragging it from the palette.

For example, consider a custom palette that provides an AddressBook object that manages people's names and addresses.  This object, a subclass of Object, is to be dragged into the File window.  Further, imagine that the subclass of IBPalette for this custom palette, AddressBookPalette, has two outlets:  addressBookObject and addressBookView.  When the palette was created, these outlets were connected to the AddressBook object and to a View object that will represent it in the Palette window.  Within the AddressBookPalette class implementation file, the finishInstantiate method would look like this:

- finishInstantiate
[self associateObject:addressBookObject
type:IBObjectPboardType with:addressBookView];
return self;

Notice that the subclass establishes an association by sending itself an associateObject:type:with: message.  IBPalette implements this method.  The second argument controls where the palette image may be deposited:

Type Usage
IBObjectPboardType For objects that the user must deposit in the File window
IBMenuCellPboardType For MenuCells without submenus; must be deposited in a menu
IBMenuPboardType For MenuCells that have submenus; must be deposited in a menu
IBWindowPboardType For Windows and Panels; must be deposited in the workspace

Instance Variables

id paletteDocument;

id originalWindow;

id paletteView;

id draggedView;

paletteDocument An object conforming to the IBDocuments protocol that represents the dynamically loaded palette.
originalWindow The window containing the interface objects that will be loaded into Interface Builder's Palettes window.
paletteView private
draggedView private

Method Types

Associating Views and Objects associateObject:type:with:
Initializing the palette finishInstantiate
Accessing related objects paletteDocument

Instance Methods


Establishes an association between a View in a palette (aView) and the object that should be instantiated when the user drags the View from the palette (anObject).  The type argument controls where the palette object may be deposited.  (See the "Class Description" above for more information.

If your custom palette provides non-View objects, override IBPalette's finishInstantiate method with an implementation that sends associateObject:type:with: messages to associate each View object in the palette with the non-View object that it represents.

findImageNamed:(const char *)name

Returns the NXImage instance associated with name.  If no such image can be found, this method returns nil.

Use this method to refer to images in your custom palette.  This method first tries to find the image by invoking NXImage's version of findImageNamed:.  If that's unsuccessful, it uses the facilities of the NXBundle class to check the ".palette" directory for this resource.  See getPath:forResource:ofType: for a description of NXBundle's search path.

See also:  findImageNamed:(NXImage class of the Application Kit), getPath:forResource:ofType: (NXBundle common class)


Implement to complete the initialization of your IBPalette object.  Interface Builder sends a finishInstantiate message to the IBPalette object after it has been unarchived from the palette file.  A typical use of this method is to associate a View object within the custom palette with a non-View object that is meant to represent it in the Palette window.  See "Class Description," above, for more information.

See also:   associateObject:type:with:


Returns the Window that contains the View objects to be loaded into Interface Builder's Palette window.  When it loads a custom palette, Interface Builder sends the IBPalette subclass an originalWindow message.  In your custom palette, you must connect the originalWindow outlet of your subclass of IBPalette to the Window that contains the Views that represent your palette objects.


Returns an object that represents the dynamically loaded palette.  This object is of unspecified class; however, it conforms to the IBDocuments protocol.