Dynamic Types

Gadget items are dynamically typed and can therefore be subclassed, saved, and read easily.

The following code lets you access class information:

IlvClassInfo* classInfo = item->getClassInfo();

To check the type of an item, use:

if (item->isSubtypeOf(IlvTreeGadgetItem::ClassInfo())) {

// The item is an IlvTreeGadgetItem.

}

Using Palettes with Gadget Items

Several palettes are used to draw a gadget item:

  • The palette returned by getSelectionPalette is used to draw the background of a selected gadget item.

  • The palette returned by getNormalTextPalette is used to draw the text of a gadget item that is not selected.

By default, a gadget item uses the palettes of its holder. You can, however, modify the palettes associated with a gadget item, thus making it possible to have gadget items with different palettes inside the same gadget.

To change the palettes assigned to a given gadget item, use the following member functions:

  • IlvGadgetItem::setNormalTextPalette

  • IlvGadgetItem::setSelectionTextPalette

  • IlvGadgetItem::setHighlightTextPalette

  • IlvGadgetItem::setOpaquePalette

Drawing a Gadget Item

To draw a gadget item, the virtual member function draw is called. You can override it in a subclass to customize the way a gadget item is drawn.