Using Gadget Items
This section covers the following topics:
Creating a Gadget Item
A gadget item can be represented by a label, a picture, or both. The picture can be a bitmap or a graphic object. See Setting a Label and Setting a Picture.
You define the way a gadget item appears when you create it. Here are a few examples:
item1 = new IlvGadgetItem("Item1"); // Creates an item with only a label.
item2 = new IlvGadgetItem("Item2", // Creates an item with a label
bitmap); // and a bitmap.
item3 = new IlvGadgetItem(bitmap); // Creates an item with a bitmap.
item4 = new IlvGadgetItem("Item 4", // Creates an item with a label
graphic); // and an IlvGraphic.
item5 = new IlvGadgetItem(graphic); // Creates an item with an IlvGraphic.
Setting a Label
A gadget item can be represented by a label. To associate a label with a gadget item, use the
When a gadget item label extends over several lines, you can
Message Labels with Various Alignments
Using the
Message Labels Displayed Vertically
Setting a Picture
A gadget item can include either an IlvBitmap or an IlvGraphic object. The following sections explain how gadget items handle these objects.
IlvBitmap Used as a Picture
Below are the symbol names associated with the various gadget item states a bitmap can represent:
To know how many bitmaps are associated with a gadget item, call the method
To set the bitmap that will be displayed by the gadget item when it is selected, call:
To retrieve the bitmap that is displayed when the gadget item is set to nonsensitive, call:
IlvBitmap* bitmap = item->getBitmap(IlvGadgetItem::InsensitiveBitmapSymbol());
IlvGraphic Used as a Picture
Specifying the Layout of a Gadget Item
You can define the position of a gadget item label relative to its picture using the member function setLabelPosition. For example, to place the label under the picture, call:
You can also fix the spacing between the label and the picture with setSpacing. For example, to set the spacing to 10 pixels, call:
A gadget item can be any size. Its dimensions are automatically computed from its label, its picture, the label position, and the spacing between the label and the picture. To retrieve the size of a gadget item, use the following methods:
The width and height of a gadget item should not exceed 65535 pixels. The member functions getWidth and getHeight return 0 if the item is not managed by a gadget.
To know the position of a label and a picture inside a gadget item, use the following member functions:
// in rect when the item is drawn in itembbox.
//in rect when the item is drawn in itembbox.
You can show or hide either the label or the picture that makes up a gadget item. To hide a gadget item label, use showLabel with its parameter set to IlFalse. If the gadget item contains no picture, it becomes invisible.
To make the picture visible,
Nonsensitive Gadget Items
If only a sensitive bitmap is provided, the insensitive bitmap is computed automatically. If a nonsensitive bitmap is provided, this bitmap is used.