*/JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeInsertText(
		JNIEnv* env, jclass clazz, jint handle, jstring textString) {
	if (handle) {
		IrrlichtDevice* device = (IrrlichtDevice*) handle;
		IGUIEnvironment* irrenv = device->getGUIEnvironment();
		IGUIElement* element = irrenv->getFocus();
		if (element && element->getType() == EGUIET_EDIT_BOX) {
			IGUIEditBox* editbox = (IGUIEditBox*) element;
			const char* text = env->GetStringUTFChars(textString, NULL);
			wchar_t content[256];
			BufferIO::DecodeUTF8(text, content);
			editbox->setText(content);
			irrenv->removeFocus(editbox);
			irrenv->setFocus(editbox->getParent());
			SEvent changeEvent;
			changeEvent.EventType = EET_GUI_EVENT;
			changeEvent.GUIEvent.Caller = editbox;
			changeEvent.GUIEvent.Element = 0;
			changeEvent.GUIEvent.EventType = EGET_EDITBOX_CHANGED;
			editbox->getParent()->OnEvent(changeEvent);
			SEvent enterEvent;
			enterEvent.EventType = EET_GUI_EVENT;
			enterEvent.GUIEvent.Caller = editbox;
			enterEvent.GUIEvent.Element = 0;
			enterEvent.GUIEvent.EventType = EGET_EDITBOX_ENTER;
			editbox->getParent()->OnEvent(enterEvent);
			env->DeleteLocalRef(textString);
		}
	}
}
void NBEditor::fillProperties()
{
	IGUIStaticText *sidebar = state->menu->sidebar;
	Node *node = state->project->GetCurrentNode();

	if (!sidebar || !node) {
		return;
	}

	NodeBox *nb = node->GetCurrentNodeBox();

	if (!nb) {
		return;
	}

	sidebar->getElementFromId(ENB_GUI_PROP)->setVisible(true);
	fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_X1, nb->one.X);
	fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_Y1, nb->one.Y);
	fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_Z1, nb->one.Z);
	fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_X2, nb->two.X);
	fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_Y2, nb->two.Y);
	fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_Z2, nb->two.Z);

	IGUIElement* element = sidebar->getElementFromId(ENB_GUI_PROP)
			->getElementFromId(ENB_GUI_PROP_NAME);

	if (element) {
		IGUIEditBox* editbox = static_cast<IGUIEditBox*>(element);

		std::wstring wide = narrow_to_wide(nb->name);
		editbox->setText(wide.c_str());
	}
}
示例#3
0
文件: Universe.cpp 项目: insolite/RPG
void Universe::MenuGUIInit()
{
	menuEventReceiver = new MenuEventReceiver();
	render->device->setEventReceiver((IEventReceiver*)menuEventReceiver);

	guienv->addEditBox(L"admin", rect< s32 >(render->screenWidth / 2 - 64, render->screenHeight / 2 - 100, render->screenWidth / 2 + 64, render->screenHeight / 2 - 68), true, NULL, LoginEditBox);
	IGUIEditBox* eb = guienv->addEditBox(L"1234", rect< s32 >(render->screenWidth / 2 - 64, render->screenHeight / 2 - 60, render->screenWidth / 2 + 64, render->screenHeight / 2 - 28), true, NULL, PasswordEditBox);
	eb->setPasswordBox(true);
	guienv->addButton(rect< s32 >(render->screenWidth / 2 - 64, render->screenHeight / 2 - 20, render->screenWidth / 2 - 4, render->screenHeight / 2 + 12), NULL, LogInButton, L"Log in", L"Log in");
	guienv->addButton(rect< s32 >(render->screenWidth / 2 + 4, render->screenHeight / 2 - 20, render->screenWidth / 2 + 64, render->screenHeight / 2 + 12), NULL, RegisterButton, L"Register", L"Register");
}
void TextBoxWidget::setActive(bool active)
{
    Widget::setActive(active);

    if (m_element != NULL)
    {
        IGUIEditBox* textCtrl = Widget::getIrrlichtElement<IGUIEditBox>();
        assert(textCtrl != NULL);
        textCtrl->setEnabled(active);
    }
}   // setActive
//! Adds an edit box. The returned pointer must not be dropped.
IGUIEditBox* CGUIEnvironment::addEditBox(const wchar_t* text,
                                         const core::rect<s32>& rectangle,
                                         bool border, IGUIElement* parent,
                                         s32 id)
{
	IGUIEditBox* d = new CGUIEditBox(text, border, this,
	                                 parent ? parent : this, id, rectangle, Operator);

	d->drop();
	return d;
}
示例#6
0
void fillTB(IGUIElement* sidebar,int parentId,int id,float value){
	IGUIElement* e = sidebar->getElementFromId(parentId)->getElementFromId(id);

	if (e){
		IGUIEditBox* b = static_cast<IGUIEditBox*>(e);

		if (!b)
			return;

		b->setText(stringw(value).c_str());
	}
}
示例#7
0
	virtual bool OnEvent(const SEvent &event)
	{
		if (event.EventType == EET_GUI_EVENT)
		{
			s32 id = event.GUIEvent.Caller->getID();
			IGUIEnvironment* env = Device->getGUIEnvironment();

			switch(event.GUIEvent.EventType)
			{
			case EGET_SCROLL_BAR_CHANGED:
				if (id == MYGUI_CURRENTIMAGE)
				{
					IGUIImage* img = (IGUIImage*)env->getRootGUIElement()->getElementFromId(MYGUI_IMAGE,true);
					s32 i = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos();
					img->setImage(FontTool->currentTextures[i]);

					return true;
				}
				break;
			case EGET_COMBO_BOX_CHANGED:
				if (id == MYGUI_CHARSET)
				{
					IGUIComboBox* cbo = (IGUIComboBox*)event.GUIEvent.Caller;
					IGUIComboBox* cbo_1 = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_FONTNAME,true);
					core::stringw str=FontTool->FontNames[cbo_1->getSelected()];
					u32 j=0;
					FontTool->selectCharSet(cbo->getSelected());
					// rebuild font list
					cbo = cbo_1;
					cbo->clear();
					for (u32 i=0; i < FontTool->FontNames.size(); ++i){
						cbo->addItem(FontTool->FontNames[i].c_str());
						if(FontTool->FontNames[i]==str) j=i;
					}
					cbo->setSelected(j);
					return true;
				}
				else if(id==MYGUI_FONTNAME){
					IGUIComboBox* cbo = (IGUIComboBox*)event.GUIEvent.Caller;
					std::cout << FontTool->FontNames[cbo->getSelected()].c_str() << std::endl;
				}
				break;
			case EGET_CHECKBOX_CHANGED:
				if (id == MYGUI_VECTOR)
				{
					IGUICheckBox* chk = (IGUICheckBox*)event.GUIEvent.Caller;

					IGUIComboBox *cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_FORMAT,true);
					cbo->clear();

					if (chk->isChecked() && VecTool)
					{
						// vector formats
						for (s32 i=0; fileformats[i] != 0; ++i)
							cbo->addItem( core::stringw(vectorfileformats[i]).c_str());

					}
					else
					{

						// bitmap formats
						if (!FontTool->UseAlphaChannel)
						{
							// add non-alpha formats
							for (s32 i=0; fileformats[i] != 0; ++i)
								cbo->addItem( core::stringw(fileformats[i]).c_str());
						}
						// add formats which support alpha
						for (s32 i=0; alphafileformats[i] != 0; ++i)
							cbo->addItem( core::stringw(alphafileformats[i]).c_str());
					}

				}
				break;

			case EGET_BUTTON_CLICKED:

				if (id == MYGUI_CREATE)
				{
					// create the font with the params
					IGUIComboBox* cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_CHARSET, true);
					int charset = cbo->getSelected();

					cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_FONTNAME,true);
					int fontname = cbo->getSelected();

					/*
					cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_SIZE,true);
					int fontsize = cbo->getSelected();
					*/

					int fontsize=wcstol(((IGUIEditBox*)env->getRootGUIElement()->getElementFromId(MYGUI_SIZE,true))->getText(),NULL,10);

					cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_TEXWIDTH,true);
					int texwidth = cbo->getSelected();

					cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_TEXHEIGHT,true);
					int texheight = cbo->getSelected();

					IGUICheckBox* chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_BOLD,true);
					bool bold = chk->isChecked();
					chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_ITALIC,true);
					bool italic = chk->isChecked();

					chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_ALPHA,true);
					bool alpha = chk->isChecked();

					chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_ANTIALIAS,true);
					bool aa = chk->isChecked();

					chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(201,true);
					bool usedOnly = chk->isChecked();

					chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(202,true);
					bool excludeLatin = chk->isChecked();

					// vector fonts disabled
					//chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_VECTOR,true);
					bool vec = false;//chk->isChecked();

					FontTool->makeBitmapFont(fontname, charset, /*FontTool->FontSizes[fontsize]*/ fontsize, texturesizes[texwidth], texturesizes[texheight], bold, italic, aa, alpha, usedOnly, excludeLatin);

					IGUIScrollBar* scrl = (IGUIScrollBar*)env->getRootGUIElement()->getElementFromId(MYGUI_CURRENTIMAGE,true);
					scrl->setMax(FontTool->currentTextures.size() == 0 ? 0 : FontTool->currentTextures.size()-1);

					if (FontTool->currentTextures.size() > 0)
					{
						IGUIImage* img = (IGUIImage*)env->getRootGUIElement()->getElementFromId(MYGUI_IMAGE,true);
						img->setImage(FontTool->currentTextures[0]);
						scrl->setPos(0);
					}

					// make sure users pick a file format that supports alpha channel
					cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_FORMAT,true);
					cbo->clear();

					if (vec)
					{
						// add vector formats
						for (s32 i=0; fileformats[i] != 0; ++i)
							cbo->addItem( core::stringw(vectorfileformats[i]).c_str());
					}
					else
					{
						if (!alpha)
						{
							// add non-alpha formats
							for (s32 i=0; fileformats[i] != 0; ++i)
								cbo->addItem( core::stringw(fileformats[i]).c_str());
						}
						// add formats which support alpha
						for (s32 i=0; alphafileformats[i] != 0; ++i)
							cbo->addItem( core::stringw(alphafileformats[i]).c_str());
					}
					if (VecTool)
					{
						delete VecTool;
						VecTool = 0;
					}
					if (vec)
					{
						VecTool = new CVectorFontTool(FontTool);
					}

					/* Message box letting the user know the process is complete */
					env->addMessageBox(L"Create", completeText);

					return true;
				}

				if (id == MYGUI_SAVE)
				{
					IGUIEditBox *edt  = (IGUIEditBox*)env->getRootGUIElement()->getElementFromId(MYGUI_FILENAME,true);
					core::stringc name = edt->getText();

					IGUIComboBox *fmt  = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_FORMAT,true);
					core::stringc format = fmt->getItem(fmt->getSelected());

					// vector fonts disabled
					// IGUICheckBox *chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_VECTOR,true);
					// bool vec = chk->isChecked();
					bool vec = false;

					if (vec && VecTool)
						VecTool->saveVectorFont(name.c_str(), format.c_str());
					else
						FontTool->saveBitmapFont(name.c_str(), format.c_str());

					return true;
				}

				if (id == MYGUI_HELPBUTTON)
				{
					env->addMessageBox(L"Irrlicht Unicode Font Tool", helptext);
					return true;
				}

				break;

			default:
				break;
			}
		}

		return false;
	}
示例#8
0
 void cEditor::OnMenuItemSelected( IGUIContextMenu* menu )
{
	s32 id = menu->getItemCommandId(menu->getSelectedItem());
	IGUIEnvironment* env = device->getGUIEnvironment();
	switch(id)
	{
	case GUI_ID_EX_NODE:
		{
			stringc* res = nodes[curId]->build(NBT_FULL);
			IGUIWindow* win = guienv->addWindow(rect<irr::s32>(50,50,50+320,50+320),false,L"Raw Code");
			IGUIEditBox* codebox = guienv->addEditBox(convert(res->c_str()),rect<irr::s32>(10,30,310,310),true,win);
			codebox->setMultiLine(true);
			codebox->setTextAlignment(EGUIA_UPPERLEFT,EGUIA_UPPERLEFT);
			codebox->setToolTipText(L"Ctrl+A, Ctrl+C to copy");
		}
		break;
	case GUI_ID_EX_NBS:
		{
			stringc* res = nodes[curId]->build(NBT_NBS);
			IGUIWindow* win = guienv->addWindow(rect<irr::s32>(50,50,50+320,50+320),false,L"Raw Code");
			IGUIEditBox* codebox = guienv->addEditBox(convert(res->c_str()),rect<irr::s32>(10,30,310,310),true,win);
			codebox->setMultiLine(true);
			codebox->setTextAlignment(EGUIA_UPPERLEFT,EGUIA_UPPERLEFT);
			codebox->setToolTipText(L"Ctrl+A, Ctrl+C to copy");
		}
		break;
	case GUI_ID_EX_NB:
		{
			stringc* res = nodes[curId]->build(NBT_NB);
			IGUIWindow* win = guienv->addWindow(rect<irr::s32>(50,50,50+320,50+320),false,L"Raw Code");
			IGUIEditBox* codebox = guienv->addEditBox(convert(res->c_str()),rect<irr::s32>(10,30,310,310),true,win);
			codebox->setMultiLine(true);
			codebox->setTextAlignment(EGUIA_UPPERLEFT,EGUIA_UPPERLEFT);
			codebox->setToolTipText(L"Ctrl+A, Ctrl+C to copy");
		}
		break;
	case GUI_ID_TEXT:
		if (nodes[curId] && nodes[curId]->getCurrentNodeBox() && nodes[curId]->getCurrentNodeBox()->model)
		{
			IGUIWindow* win = guienv->addWindow(rect<irr::s32>(50,50,50+320,50+162),false,L"Properties");
			guienv->addEditBox(convert(nodes[curId]->getCurrentNodeBox()->model->getName()),rect<irr::s32>(32,32,290,52),true,win,GUI_ID_BOX_NAME);

			// Add the co-ordinate boxes
			{
				guienv->addEditBox(convert(stringc(nodes[curId]->getCurrentNodeBox()->position.X - ((float)nodes[curId]->getCurrentNodeBox()->size.X / (float)2)).c_str()),rect<irr::s32>(32,60,112,80),true,win,230);
				guienv->addEditBox(convert(stringc(nodes[curId]->getCurrentNodeBox()->position.Y - ((float)nodes[curId]->getCurrentNodeBox()->size.Y / (float)2)).c_str()),rect<irr::s32>(32+90,60,112+90,80),true,win,230);
				guienv->addEditBox(convert(stringc(nodes[curId]->getCurrentNodeBox()->position.Z - ((float)nodes[curId]->getCurrentNodeBox()->size.Z / (float)2)).c_str()),rect<irr::s32>(32+180,60,112+180,80),true,win,230);

				guienv->addEditBox(convert(stringc(nodes[curId]->getCurrentNodeBox()->position.X + ((float)nodes[curId]->getCurrentNodeBox()->size.X / (float)2)).c_str()),rect<irr::s32>(32,60+30,112,80+30),true,win,230);
				guienv->addEditBox(convert(stringc(nodes[curId]->getCurrentNodeBox()->position.Y + ((float)nodes[curId]->getCurrentNodeBox()->size.Y / (float)2)).c_str()),rect<irr::s32>(32+90,60+30,112+90,80+30),true,win,230);
				guienv->addEditBox(convert(stringc(nodes[curId]->getCurrentNodeBox()->position.Z + ((float)nodes[curId]->getCurrentNodeBox()->size.Z / (float)2)).c_str()),rect<irr::s32>(32+180,60+30,112+180,80+30),true,win,230);
			}
			guienv->addButton(rect<irr::s32>(100,120,220,152),win,GUI_ID_SUBMIT,L"Update");
		}
		break;
	case GUI_ID_DELETENB:
		nodes[curId]->deleteNodebox(nodes[curId]->getCurrentNodeBox());
		break;
	case GUI_ID_BOX:
		nodes[curId]->addNodeBox();
		break;
	case GUI_ID_ABOUT:
		guienv->addMessageBox(L"About",L"This node box generator was made by Rubenwardy in C++ and Irrlicht");
		break;	
	case GUI_ID_SP_ALL:
		printf("View mode changed to tiles\n");
		isSplitScreen=true;
		currentWindow=0;
		break;
	case GUI_ID_SP_PER:
		printf("View mode changed to perspective\n");
		isSplitScreen=false;
		currentWindow=0;
		break;
	case GUI_ID_SP_TOP:
		printf("View mode changed to top\n");
		isSplitScreen=false;
		currentWindow=1;
		break;
	case GUI_ID_SP_FRT:
		printf("View mode changed to front\n");
		isSplitScreen=false;
		currentWindow=2;
		break;
	case GUI_ID_SP_RHT:
		printf("View mode changed to right\n");
		isSplitScreen=false;
		currentWindow=3;
		break;
	case GUI_ID_SNAP:
		data->snapping = menu->isItemChecked(menu->getSelectedItem());
		break;
	case GUI_ID_LIMIT:
		data->limiting = menu->isItemChecked(menu->getSelectedItem());
		break;
	default:
		if (id>=230){
			int i = id - 230;
			nodes[curId]->changeID(i);
		}
	}
}
void TextBoxWidget::setPasswordBox(bool passwordBox, wchar_t passwordChar)
{
    IGUIEditBox* textCtrl =  Widget::getIrrlichtElement<IGUIEditBox>();
    assert(textCtrl != NULL);
    textCtrl->setPasswordBox(passwordBox, passwordChar);
}
示例#10
0
 stringw               getNextRoadName() { return m_text_field->getText();       }
示例#11
0
文件: LunaLobby.cpp 项目: tecan/Luna
int Luna::lobby() {
   // #ifndef NDEBUG
	// falsify the quit flags
	events.quit = false;
	events.login = false;
	// Flush the gui factory
	guienv->clear();
	smgr->clear();
    device->setEventReceiver ( &events );



	smgr->loadScene ( "./data/models/maps/lobby.irr" );
	//smgr->addCameraSceneNode(0, vector3df(20,100, 0), vector3df(0,100,0), -1);
	//smgr->addCameraSceneNodeFPS();

	ITexture *loginWindow = driver->getTexture ( "./data/textures/lobby/loginBg.png" );

	int buttonPosX = ( resolution[0] / 2 ) - 60;
	int buttonPosY = ( resolution[1] / 100 ) * 80;

	IGUIEditBox *uname = guienv->addEditBox ( L"", rect<s32> ( buttonPosX - 30, buttonPosY - 100, buttonPosX + 150, buttonPosY - 80 ), true, 0, -1 );
	IGUIEditBox *pword = guienv->addEditBox ( L"", rect<s32> ( buttonPosX - 30, buttonPosY - 60, buttonPosX + 150, buttonPosY - 40 ), true, 0, -1 );

	pword->setPasswordBox ( true, L'*' );

	// Load the button textures
	ITexture *menuButtonNormal = driver->getTexture ( "./data/textures/lobby/lobbyButtonNormal.png" );
	ITexture *menuButtonDepressed = driver->getTexture ( "./data/textures/lobby/lobbyButtonDepressed.png" );

	IGUIButton *exitButton = guienv->addButton ( rect<s32> ( buttonPosX, buttonPosY + 50, buttonPosX + 120, buttonPosY + 70 ), 0, 101, L"Exit" );
	exitButton->setImage ( menuButtonNormal );
	exitButton->setPressedImage ( menuButtonDepressed );

	IGUIButton *loginButton = guienv->addButton ( rect<s32> ( buttonPosX, buttonPosY + 0, buttonPosX + 120, buttonPosY + 20 ), 0, 102, L"Login" );
	loginButton->setImage ( menuButtonNormal );
	loginButton->setPressedImage ( menuButtonDepressed );

	IGUIButton *optionsButton = guienv->addButton ( rect<s32> ( buttonPosX, buttonPosY + 25, buttonPosX + 120, buttonPosY + 45 ), 0, 103, L"Options" );
	optionsButton->setImage ( menuButtonNormal );
	optionsButton->setPressedImage ( menuButtonDepressed );

	// Developers login box
#ifdef NDEBUG
	IGUIButton *devButton = guienv->addButton ( rect<s32> ( buttonPosX, buttonPosY - 25, buttonPosX + 120, buttonPosY-10 ), 0, 901, L"Dev Login" );
	devButton->setImage ( menuButtonNormal );
	devButton->setPressedImage ( menuButtonDepressed );
#endif

	// Do the text
	guienv->addStaticText ( L"Account Login.", rect<s32> ( buttonPosX - 60, buttonPosY - 148, buttonPosX + 120, buttonPosY - 138 ) );
	guienv->addStaticText ( L"Username:"******"Password:"******"returned -1\n");
                events.quit=true;
			//    break;
			return 1;
			}
			else if ( ret == 1 ) {
						printf ("returned 1\n");

				wrongPWMessage = guienv->addStaticText ( L"Incorrect username or password.", rect<s32> ( 0, 0, 130, 10 ) );
				wrongPWOK = guienv->addButton ( rect<s32> ( buttonPosX, resolution[1] / 2, buttonPosX + 120, ( resolution[1]/2 ) + 20 ), 0, 105, L"Wrong Password" );
				wrongPWOK->setImage ( menuButtonNormal );
				wrongPWOK->setPressedImage ( menuButtonDepressed );

				loginButton->setEnabled ( false );
				optionsButton->setEnabled ( false );
				exitButton->setEnabled ( false );

				uname->setEnabled ( false );    pword->setEnabled ( false );

				events.login = false;
				wrongPassOK = true;
			}
			else if ( ret == 0 ) {
						printf ("returned 0\n");

				conMessage = guienv->addStaticText ( L"Could not connect to the server, please see the status page", rect<s32> ( 0, 0, 130, 10 ) );
				conOK = guienv->addButton ( rect<s32> ( buttonPosX, resolution[1] / 2, buttonPosX + 120, ( resolution[1]/2 ) + 20 ), 0, 104, L"no server connection" );
				conOK->setImage ( menuButtonNormal );
				conOK->setPressedImage ( menuButtonDepressed );
				loginButton->setEnabled ( false );
				optionsButton->setEnabled ( false );
				exitButton->setEnabled ( false );
				uname->setEnabled ( false );
				pword->setEnabled ( false );
				events.login = false;
				//conRefOK = true;
			}

		}


		driver->beginScene ( true, true, SColor ( 0, 0, 0, 0 ) );
		smgr->drawAll();
            driver->draw2DImage ( loginWindow, core::position2d<s32> ( buttonPosX - 65, buttonPosY - 150 ) );
		guienv->drawAll();
		driver->endScene();

        device->sleep ( 10, true );


	}

	return 0;
//	#endif
}