IlvButton* mybutton = new IlvButton(display, IlvPoint(20,20), "Quit"); IlvColor* color = display->getColor("gold"); if (color) mybutton->setBackground(color); |
IlInt index = 10; IlSymbol* key = IlGetSymbol("objectIndex"); mybutton->addProperty(key, (IlAny)index); |
IlvButton* button = new IlvButton(display, IlvPoint(10,10), "sample"); // Get the IlvClassInfo object associated with the button class. IlvClassInfo* classInfo = button->getClassInfo(); // Get the name of the IlvGraphic class and print it: "IlvButton" const char* name = classInfo->getClassName(); IlvPrint(name); // Get the name of the super class and print it: "IlvMessageLabel" name = classInfo->getSuperClass()->getClassName(); IlvPrint(name); IlBoolean isSubtype = classInfo->isSubtypeOf(IlvSimpleGraphic::ClassInfo()); name = isSubtype ? "It's a subtype" : "error"; IlvPrint(name); |
void AddProperty(const IlSymbol* key, IlAny value); void RemoveProperty(const IlSymbol* key); void ReplaceProperty(const IlSymbol* key, IlAny value); void GetProperty(const IlSymbol* key, IlBoolean checkSuperClass = IlFalse); const IlvClassInfo* HasProperty(const IlSymbol* key, IlBoolean checkSuperClass = IlFalse); void addClassProperty(const IlSymbol* key, IlAny value); IlBoolean removeClassProperty(const IlSymbol* key); IlBoolean replaceClassProperty(const IlSymbol* key, IlAny value); IlAny getClassProperty(const IlSymbol* key, IlBoolean checkSupCl = IlFalse) const; const IlvClassInfo* hasClassProperty(const IlSymbol* key, IlBoolean checkSupCl = IlFalse) const; |
// Add the class-level property myClass* obj = new myClass(display); obj->addClassProperty(IlGetSymbol("sensitive"), (IlAny)IlTrue); |
if (anyValue == IlTrue) { myClass::AddProperty(IlGetSymbol("sensitive"), (IlAny)IlFalse); } |
IlBoolean myInteractor::handleEvent(IlvGraphic* object, IlvEvent& event, IlvContainer* cont, IlvTransformer* transf) { // gets the sensitivity state IlSymbol* symbol = IlGetSymbol("sensitive"); if (object->hasClassProperty(symbol)) { if (!object->getClassProperty(symbol)) return IlFalse; } return IlvViewToggleInteractor::handleEvent(object, event, cont, transf); } |
// Open a file output stream fstream outstream("image.ilv", ios::out | ios::trunc); // Initialize the number of objects and their array of pointers const IlvUInt n = 10; IlvGraphic* outObjects[n]; for (IlvUInt i=0; i<n; i++) outObjects[i] = new IlvRectangle(display, IlvRect(0, 0, 200, 100)); // Create the IlvOutputFile IlvOutputFile outfile(outstream); // Write the objects and get in outTotalCount the number // of objects actually stored IlvUInt outTotalCount = 0; outfile.saveObjects(n, outObjects, outTotalCount); |
// Open a file input stream fstream instream("image.ilv", ios::in); // Create the IlvInputFile IlvInputFile infile(instream); // Get the number of created objects and their array of pointers IlUInt InTotalCount = 0; IlvGraphic* const* inObjects = infile.readObjects(display, InTotalCount); |