*/JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetCheckBoxesSelection( JNIEnv* env, jclass clazz, jint handle, jint idx) { if (handle) { IrrlichtDevice* device = (IrrlichtDevice*) handle; IGUIEnvironment* irrenv = device->getGUIEnvironment(); IGUIElement* element = irrenv->getFocus(); if (element) { IGUIWindow* window = (IGUIWindow*) (element); core::list<IGUIElement*> children = window->getChildren(); core::list<IGUIElement*>::Iterator current = children.begin(); int i = 0; do { if ((*current)->getType() == EGUIET_CHECK_BOX && i++ == idx) { break; } current++; } while (current != children.end()); if (current == children.end()) { return; } IGUICheckBox* checkbox = (IGUICheckBox*) *current; checkbox->setChecked(true); SEvent e; e.EventType = EET_GUI_EVENT; e.GUIEvent.Caller = checkbox; e.GUIEvent.Element = 0; e.GUIEvent.EventType = EGET_CHECKBOX_CHANGED; window->OnEvent(e); irrenv->setFocus(window); } } }
int main(int argc,char **argv) { IrrlichtDevice* device =createDevice(video::EDT_OPENGL, core::dimension2du(800, 600)); video::IVideoDriver* driver = device->getVideoDriver(); scene::ISceneManager* smgr = device->getSceneManager(); gui::IGUIEnvironment *env = device->getGUIEnvironment(); // create font tool CFontTool *fc = new CFontTool(device); CVectorFontTool *vc = 0; MyEventReceiver events(device,fc,vc); device->setEventReceiver(&events); createGUI(device, fc); for(int i=1; i<argc; i++) { if(!strcmp(argv[i],"-c") && i<argc-1) { i++; if(setUsedCharacters(argv[i])) { IGUICheckBox *box = dynamic_cast<IGUICheckBox*>(device->getGUIEnvironment() ->getRootGUIElement() ->getElementFromId(201, true)); box->setChecked(true); } } else { // Old style: just a single parameter, assume it's a file name with pot files in it if(LoadPoFiles(argv[i])) { IGUICheckBox *box = dynamic_cast<IGUICheckBox*>(device->getGUIEnvironment() ->getRootGUIElement() ->getElementFromId(201, true)); box->setChecked(true); } } } // for i <argc while(device->run()) { device->sleep(50); if (device->isWindowActive()) { driver->beginScene(true, true, video::SColor(0,200,200,200)); smgr->drawAll(); env->drawAll(); driver->endScene(); } } // drop the font tool and resources fc->drop(); device->drop(); return 0; }