static void editBoxCallbackFunc(const char* pText, void* ctx)
{
    EditBoxImplAndroid* thiz = (EditBoxImplAndroid*)ctx;
    bool isBack = strlen(pText) == 1 && pText[0] == '\b';
    if(!isBack)
        thiz->setText(pText);
	
    if (thiz->getDelegate() != NULL)
    {
        if(!isBack)
            thiz->getDelegate()->editBoxTextChanged(thiz->getEditBox(), thiz->getText());
        thiz->getDelegate()->editBoxEditingDidEnd(thiz->getEditBox());
        thiz->getDelegate()->editBoxReturn(thiz->getEditBox());
    }
    
#if CC_ENABLE_SCRIPT_BINDING
    EditBox* pEditBox = thiz->getEditBox();
    if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
    {        
        CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox);
        ScriptEvent event(kCommonEvent,(void*)&data);
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
        memset(data.eventName, 0, sizeof(data.eventName));
        strncpy(data.eventName, "ended", sizeof(data.eventName));
        event.data = (void*)&data;
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
        memset(data.eventName, 0, sizeof(data.eventName));
        strncpy(data.eventName, "return", sizeof(data.eventName));
        event.data = (void*)&data;
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
    }
#endif
}
Beispiel #2
0
static void editBoxCallbackFunc(const char* pText, void* ctx)
{
    EditBoxImplWin* thiz = (EditBoxImplWin*)ctx;
    thiz->setText(pText);

    if (thiz->getDelegate() != NULL)
    {
        thiz->getDelegate()->editBoxTextChanged(thiz->getEditBox(), thiz->getText());
        thiz->getDelegate()->editBoxEditingDidEnd(thiz->getEditBox());
        thiz->getDelegate()->editBoxReturn(thiz->getEditBox());
    }
    
    EditBox* pEditBox = thiz->getEditBox();
    if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
    {
        CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox);
        ScriptEvent event(kCommonEvent,(void*)&data);
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
        memset(data.eventName,0,64*sizeof(char));
        strncpy(data.eventName,"ended",64);
        event.data = (void*)&data;
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
        memset(data.eventName,0,64*sizeof(char));
        strncpy(data.eventName,"return",64);
        event.data = (void*)&data;
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
    }
}
Beispiel #3
0
void EditBoxImplWin::openKeyboard()
{
    if (_delegate != NULL)
    {
        _delegate->editBoxEditingDidBegin(_editBox);
    }
    
    EditBox* pEditBox = this->getEditBox();
    if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
    {
        CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "began",pEditBox);
        ScriptEvent event(kCommonEvent,(void*)&data);
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
    }
    
	std::string placeHolder = _labelPlaceHolder->getString();
	if (placeHolder.length() == 0)
		placeHolder = "Enter value";

	char pText[100]= {0};
	std::string text = getText();
	if (text.length())
		strncpy(pText, text.c_str(), 100);
	bool didChange = CWin32InputBox::InputBox("Input", placeHolder.c_str(), pText, 100, false) == IDOK;
	
	if (didChange) 	
		setText(pText);

	if (_delegate != NULL) {
		if (didChange)
			_delegate->editBoxTextChanged(_editBox, getText());
		_delegate->editBoxEditingDidEnd(_editBox);
		_delegate->editBoxReturn(_editBox);
	}
}
Beispiel #4
0
void init_home_screen()
{
	//strcpy(CommandText, "connect to 192.168.2.14, Robot, show me the accuracy of your positioning. Show me a histogram for right leg positions.\
	// Lift your left leg.  Raise both arms.  Go to the bedroom and get my shoes." );	
	strcpy (CommandText, "what time?");
	ClientInputEdit.set_text			( CommandText );
	ClientInputEdit.set_text_size 		( 16.0 			);	
	ClientInputEdit.set_return_key_listener( send_to_viki, &ClientInputEdit );
	
	//printf("init_home_screen() ClientInput text setup\n");
	
	RobotResponse.set_text				( "Not Connected" );				// ConnectionStatus	
	if (ipc_memory_client) {
		//printf("init_home_screen() RobotResponse text %s\n", ipc_memory_client->Sentence );
		RobotResponse.set_text			( ipc_memory_client->Sentence );	// ConnectionStatus		
	}
	RobotResponse.set_text_size 		( 16.0 		 );
	RobotResponse.set_text_color		( 0xCFFF0000 );
	RobotResponse.set_background_color  ( 0xFFFFFf00 );
	
	// This should be hidden until asked for via voice.
	//AvailClients.move_to( 20, 75 );

	// Add to display manager:
	MainDisplay.remove_all_objects(		  );
	MainDisplay.add_object( &ClientInputEdit);
	MainDisplay.add_object( &RobotResponse 	);
	MainDisplay.add_object( &AvailClients 	);
//	MainDisplay.add_object( &adren_board_list );
//	MainDisplay.load_resources();
}
Beispiel #5
0
EditBox * TDDHelper::createEditBox(Node *parent, Point position, Size size)
{
	Scale9Sprite *bg = Scale9Sprite::create();	// empty sprite 9
	bg->addChild(LayerColor::create(Color4B::WHITE, size.width, size.height));
	
	// Add the background layer
	Point layerPos = Point(position);
	layerPos.x -= size.width / 2;
	layerPos.y -= size.height / 2;
	
	float scale = getBestScale();
	
	// Add the Edit box
	EditBox *edit = EditBox::create(size, bg);
	edit->setPosition(position);
	
	edit->setFont(TDD_FONT_NAME, (int)(scale * TDD_EDITBOX_FONT_SIZE));
	edit->setFontColor(TDD_EDITBOX_TEXT_COLOR);
	
	if(parent != NULL) {
		parent->addChild(edit);
	}
	
	return edit;
}
Beispiel #6
0
void EditBoxImplAndroid::openKeyboard()
{
    if (_delegate != NULL)
    {
        _delegate->editBoxEditingDidBegin(_editBox);
    }
    
#if CC_ENABLE_SCRIPT_BINDING
    EditBox* pEditBox = this->getEditBox();
    if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
    {        
        CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "began",pEditBox);
        ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
    }
#endif
	
    showEditTextDialogJNI(  _placeHolder.c_str(),
						  _text.c_str(),
						  (int)_editBoxInputMode,
						  (int)_editBoxInputFlag,
						  (int)_keyboardReturnType,
						  _maxLength,
						  editBoxCallbackFunc,
						  (void*)this  );
	
}
void EditBoxImplWin::openKeyboard()
{
    if (_delegate != nullptr)
    {
        _delegate->editBoxEditingDidBegin(_editBox);
    }
    
    EditBox* pEditBox = this->getEditBox();
    if (nullptr != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
    {
        CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "began",pEditBox);
        ScriptEvent event(kCommonEvent,(void*)&data);
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
    }
    
	std::string placeHolder = _labelPlaceHolder->getString();
	if (placeHolder.length() == 0)
		placeHolder = "Enter value";

	char pText[100]= {0};
	std::string text = getText();
	if (text.length())
		strncpy(pText, text.c_str(), 100);
	GLView *glView = Director::getInstance()->getOpenGLView();
	GLFWwindow *glfwWindow = glView->getWindow();
	HWND hwnd = glfwGetWin32Window(glfwWindow);
	bool didChange = CWin32InputBox::InputBox("Input", placeHolder.c_str(), pText, 100, false, hwnd) == IDOK;
	
	if (didChange) 	
		setText(pText);

	if (_delegate != nullptr) {
		if (didChange)
			_delegate->editBoxTextChanged(_editBox, getText());
		_delegate->editBoxEditingDidEnd(_editBox);
		_delegate->editBoxReturn(_editBox);
	}
    
#if CC_ENABLE_SCRIPT_BINDING
    if (nullptr != _editBox && 0 != _editBox->getScriptEditBoxHandler())
    {
        CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed",_editBox);
        ScriptEvent event(kCommonEvent,(void*)&data);
        if (didChange)
        {
            ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
        }
        memset(data.eventName,0,sizeof(data.eventName));
        strncpy(data.eventName,"ended",sizeof(data.eventName));
        event.data = (void*)&data;
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
        memset(data.eventName,0,sizeof(data.eventName));
        strncpy(data.eventName,"return",sizeof(data.eventName));
        event.data = (void*)&data;
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
    }
#endif // #if CC_ENABLE_SCRIPT_BINDING
}
//  gui change val events
//-----------------------------------------------------------------
void CGui::slTweak(Slider* sl, float val)
{
	std::string name = sl->getName();

	EditBox* edit = fEd(name + "E");
	if (edit)
		edit->setCaption(fToStr(val,3,6));

	TweakSetMtrPar(name, val);
}
void TDDHelperTest::testCreateEditBox(Ref *sender)
{
	log("testCreateEditBox");
	
	Point pos = Point(50, 100);
	Size size = Size(200, 60);
	
	EditBox *edit = TDDHelper::createEditBox(this, pos, size);
	edit->setAnchorPoint(Point(0, 0));
	edit->setText("Testing!!!");
}
Beispiel #10
0
void send_to_viki( void* mEditBoxPtr )
{
	printf("send_to_viki() callback reached!\n");
	
	EditBox* eb = 	(EditBox*)mEditBoxPtr;
	char* str = eb->get_text();
	if (is_client_ipc_memory_available()==false)
		RobotResponse.set_text("Viki is down.");
		
	cli_ipc_write_sentence( str );
}
Beispiel #11
0
void MyDialog::HandleEvent(Widget &obj, int msg, intptr_t arg1, intptr_t arg2) {
	Dialog::HandleEvent(obj, msg, arg1, arg2);

	switch (msg) {
		case MSG_ACTIVATE:
			if (obj == buttonPlay) {
				buttonPlay.Disable();
				MoveFocusTo(&map);
				map.Play((int)eLevel.GetPosition());
				eLevel.Disable();
				Settings::showMouse = false;
			}
			else if (obj == bScores) {
				ShowScores();
			}
		break;

		case MSG_GAMEOVER: {
			Settings::showMouse = true;

			if (hsc->CanAdd(eScore.GetInt())) {
				GetHiscoreName();
				ShowScores();
			}
			else {
//TODO
#if 0
				MessageBox dlg("Message", "Game over! You lose!", NULL, NULL, "OK", NULL, NULL);
				dlg.Popup(this);
#endif
			}
			buttonPlay.Enable();
			eLevel.Enable();
			nextPiece.piece = NULL;
		}
		break;

		case MSG_UPDATESCORE: {
			eLines.SetNumber((int)arg1);
			eScore.SetNumber((int)arg2);
		}
		break;

		case MSG_INCREASELEVEL: {
			eLevel.Increment();
		}
		break;

		case MSG_NEWPIECE: {
			nextPiece.piece = map.GetNextPiece();
		}
		break;
	};
}
Beispiel #12
0
void Meal(void* args) {
    //Disable buttons/settings
    cButton.SetText("End Meal");
    cEditDelay.SetEnabled(0);
    cComboDate.SetEnabled(0);
    cComboRecord.SetEnabled(0);
    cComboSensitivity.SetEnabled(0);
    mScale.EditItem(ID_SCALE_ZERO, "&Zero", MF_DISABLED);

    //Get Variables
    char* tmpWait = new char[255];
    cEditDelay.GetText(tmpWait);
    iMealWait = atoi(tmpWait);
    if (iMealWait==0) iMealWait = 10;

    mCompare = cComboRecord.GetSelectedItem();
    mSensitivity = ((float)cComboSensitivity.GetSelectedItem()+1.0)/100.0;

    //Initialize the first weight
    AddCurrentValue();

    //Activate the meal
    bMealActive = true;

    while(bMealActive) {
        //So if the scale is not stable, set the current time to when the scale was last stable
        if (!scale->IsStable()) uLastStable = time(0);

        if (time(0) - uLastStable >= iMealWait) {
            if (scale!=NULL && scale->IsConnected()) {
                if (fabs(scale->GetWeight() - fLastWeight) >= mSensitivity) {
                    if ((mCompare == 0 || mCompare == 2) && scale->GetWeight() > fLastWeight) AddCurrentValue();
                    if ((mCompare == 1 || mCompare == 2) && scale->GetWeight() < fLastWeight) AddCurrentValue();
                }
            }
        }

        //Sleep for .1 second
        Sleep(100);
    }

    //Check and see if the person saved the file
    CheckAndSave();

    //Enable them
    cButton.SetText("New Meal");
    cEditDelay.SetEnabled(1);
    cComboDate.SetEnabled(1);
    cComboRecord.SetEnabled(1);
    cComboSensitivity.SetEnabled(1);
    mScale.EditItem(ID_SCALE_ZERO, "&Zero", 0);
}
///  Championships list  sel changed,  fill Stages list
//----------------------------------------------------------------------------------------------------------------------
void App::listChampChng(MyGUI::MultiList2* chlist, size_t id)
{
	if (id==ITEM_NONE || liChamps->getItemCount() == 0)  return;
	
	//  update champ stages
	liStages->removeAllItems();

	int pos = s2i(liChamps->getItemNameAt(id).substr(7))-1;
	if (pos < 0 || pos >= champs.champs.size())  {  LogO("Error champ sel > size.");  return;  }

	int n = 1, p = pSet->gui.champ_rev ? 1 : 0;
	const Champ& ch = champs.champs[pos];
	for (int i=0; i < ch.trks.size(); ++i,++n)
	{
		const ChampTrack& trk = ch.trks[i];
		String clr = GetSceneryColor(trk.name);
		liStages->addItem(clr+ toStr(n/10)+toStr(n%10), 0);  int l = liStages->getItemCount()-1;
		liStages->setSubItemNameAt(1,l, clr+ trk.name.c_str());

		int id = tracksXml.trkmap[trk.name];  // if (id > 0)
		const TrackInfo& ti = tracksXml.trks[id-1];

		float carMul = GetCarTimeMul(pSet->game.car[0], pSet->game.sim_mode);
		float time = (times.trks[trk.name] * trk.laps /*+ 2*/) / carMul;

		liStages->setSubItemNameAt(2,l, clr+ ti.scenery);
		liStages->setSubItemNameAt(3,l, clrsDiff[ti.diff]+ TR("#{Diff"+toStr(ti.diff)+"}"));

		liStages->setSubItemNameAt(4,l, "#80C0F0"+GetTimeShort(time));  //toStr(trk.laps)
		liStages->setSubItemNameAt(5,l, "#E0F0FF"+fToStr(progress[p].champs[pos].trks[i].points,1,3));
	}
	//  descr
	EditBox* ed = mGUI->findWidget<EditBox>("ChampDescr");
	if (ed)  ed->setCaption(ch.descr);

	//  update champ details (on stages tab)
	TextBox* txt;
	txt = (TextBox*)mWndGame->findWidget("valChDiff");
	if (txt)  txt->setCaption(TR("#{Diff"+toStr(ch.diff)+"}"));
	txt = (TextBox*)mWndGame->findWidget("valChTracks");
	if (txt)  txt->setCaption(toStr(ch.trks.size()));

	txt = (TextBox*)mWndGame->findWidget("valChDist");
	if (txt)  txt->setCaption(/*toStr(ch.length)*/"-");  // sum from find tracks..
	txt = (TextBox*)mWndGame->findWidget("valChTime");
	if (txt)  txt->setCaption(GetTimeString(ch.time));

	txt = (TextBox*)mWndGame->findWidget("valChProgress");
	if (txt)  txt->setCaption(fToStr(100.f * progress[p].champs[pos].curTrack / champs.champs[pos].trks.size(),1,5));
	txt = (TextBox*)mWndGame->findWidget("valChScore");
	if (txt)  txt->setCaption(fToStr(progress[p].champs[pos].points,1,5));
}
void PersonalityQuiz::createnamecap(){
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    
    std::string abc("ENTER YOUR NAME!");
    
    ui::Text* EnterNameText = ui::Text::create(abc, "Arial", 30);
    EnterNameText->setColor(Color3B::BLACK);
    EnterNameText->setPosition(Point(visibleSize.width/2 + 150, visibleSize.height/2 - 100));
    EnterNameText->setName("ResultDesc");
    EnterNameText->setTextAreaSize(Size(600,200));
    EnterNameText->setVisible(true);
    this->addChild(EnterNameText,2);
    
    EditBox *EnterName = EditBox::create(Size(350,50), Scale9Sprite::create("New-Game-textbox.png"));
    EnterName->setPosition(Vec2(visibleSize.width / 2, + visibleSize.height / 2 - 130));
    EnterName->setInputMode(cocos2d::extension::EditBox::InputMode::SINGLE_LINE);
    EnterName->setMaxLength(20);
    EnterName->setFontColor(Color3B::BLACK);
    EnterName->setPlaceHolder("   ");
    EnterName->setReturnType(EditBox::KeyboardReturnType::DONE);
    EnterName->setName("NameBox");
    this->addChild(EnterName,3);

    
}
Beispiel #15
0
///  Championships list  sel changed,  fill Stages list
//---------------------------------------------------------------------
void App::listChampChng(MyGUI::MultiList2* chlist, size_t pos)
{
	if (pos==ITEM_NONE)  return;
	if (pos >= champs.champs.size())  {  LogO("Error champ sel > size.");  return;  }
	
	//  update champ stages
	liStages->removeAllItems();
	float allTime = 0.f;  int n=1;
	const Champ& ch = champs.champs[pos];
	for (int i=0; i < ch.trks.size(); ++i,++n)
	{
		const ChampTrack& trk = ch.trks[i];
		String clr = GetSceneryColor(trk.name);
		liStages->addItem(clr+ toStr(n/10)+toStr(n%10), 0);  int l = liStages->getItemCount()-1;
		liStages->setSubItemNameAt(1,l, clr+ trk.name.c_str());

		int id = tracksXml.trkmap[trk.name];  // if (id > 0)
		const TrackInfo& ti = tracksXml.trks[id-1];

		float time = (champs.trkTimes[trk.name] * trk.laps + 2) * (1.f - trk.factor);
		allTime += time;  // sum trk time, total champ time

		liStages->setSubItemNameAt(2,l, clr+ ti.scenery);
		liStages->setSubItemNameAt(3,l, clrDiff[ti.diff]+ TR("#{Diff"+toStr(ti.diff)+"}"));

		liStages->setSubItemNameAt(4,l, "#80C0F0"+GetTimeString(time));  //toStr(trk.laps)
		liStages->setSubItemNameAt(5,l, "#E0F0FF"+fToStr(progress.champs[pos].trks[i].score,1,5));
	}
	//  descr
	EditBox* ed = mGUI->findWidget<EditBox>("ChampDescr");
	if (ed)  ed->setCaption(ch.descr);

	//  update champ details (on stages tab)
	TextBox* txt;
	txt = (TextBox*)mWndGame->findWidget("valChDiff");
	if (txt)  txt->setCaption(TR("#{Diff"+toStr(ch.diff)+"}"));
	txt = (TextBox*)mWndGame->findWidget("valChTracks");
	if (txt)  txt->setCaption(toStr(ch.trks.size()));

	txt = (TextBox*)mWndGame->findWidget("valChDist");
	if (txt)  txt->setCaption(/*toStr(ch.length)*/"-");  // sum from find tracks..
	txt = (TextBox*)mWndGame->findWidget("valChTime");
	if (txt)  txt->setCaption(GetTimeString(allTime));

	txt = (TextBox*)mWndGame->findWidget("valChProgress");
	if (txt)  txt->setCaption(fToStr(100.f * progress.champs[pos].curTrack / champs.champs[pos].trks.size(),1,5));
	txt = (TextBox*)mWndGame->findWidget("valChScore");
	if (txt)  txt->setCaption(fToStr(progress.champs[pos].score,1,5));
}
Beispiel #16
0
EditBox* EditBox::create(const cocos2d::Size &size, cocos2d::ui::Scale9Sprite *normalSprite, ui::Scale9Sprite *pressedSprite, Scale9Sprite* disabledSprite)
{
    EditBox* pRet = new (std::nothrow) EditBox();
    
    if (pRet != nullptr && pRet->initWithSizeAndBackgroundSprite(size, normalSprite))
    {
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
    
    return pRet;
}
static int tolua_cocos2d_EditBox_registerScriptEditBoxHandler(lua_State* L)
{
    if (NULL == L)
        return 0;
    
    int argc = 0;
    EditBox* self = nullptr;
    
#if COCOS2D_DEBUG >= 1
    tolua_Error tolua_err;
	if (!tolua_isusertype(L,1,"ccui.EditBox",0,&tolua_err)) goto tolua_lerror;
#endif
    
    self = static_cast<EditBox*>(tolua_tousertype(L,1,0));
    
#if COCOS2D_DEBUG >= 1
	if (nullptr == self) {
		tolua_error(L,"invalid 'self' in function 'tolua_cocos2d_EditBox_registerScriptEditBoxHandler'\n", NULL);
		return 0;
	}
#endif
    
    argc = lua_gettop(L) - 1;
    
    if (1 == argc)
    {
#if COCOS2D_DEBUG >= 1
        if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err))
        {
            goto tolua_lerror;
        }
#endif
        LUA_FUNCTION handler = (  toluafix_ref_function(L,2,0));
        self->registerScriptEditBoxHandler(handler);
        return 0;
    }
    
    luaL_error(L, "%s function of EditBox  has wrong number of arguments: %d, was expecting %d\n", "ccui.EditBox:registerScriptEditBoxHandler", argc, 1);
    return 0;
    
#if COCOS2D_DEBUG >= 1
tolua_lerror:
    tolua_error(L,"#ferror in function 'tolua_cocos2d_EditBox_registerScriptEditBoxHandler'.",&tolua_err);
    return 0;
#endif
    
}
Beispiel #18
0
EditBox* EditBox::create(const Size& size,
                         const std::string& normalSprite,
                        TextureResType texType /*= TextureResType::LOCAL*/)
{
    EditBox* pRet = new EditBox();
    
    if (pRet != nullptr && pRet->initWithSizeAndBackgroundSprite(size, normalSprite, texType))
    {
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
    
    return pRet;
}
Beispiel #19
0
void GuiPopup::ButtonClick(MyGUI::WidgetPtr wp)
{
	//  get result button id
	btnResult = -1;
	sscanf(wp->getName().c_str(), "PopBtn%d", &btnResult);

	//  save return fields from edits
	EditBox* ed;
	ed = (EditBox*)mWnd->findWidget("PopEdit0");  if (ed)  edit0 = ed->getCaption();
	ed = (EditBox*)mWnd->findWidget("PopEdit1");  if (ed)  edit1 = ed->getCaption();
	ed = (EditBox*)mWnd->findWidget("PopEdit2");  if (ed)  edit2 = ed->getCaption();
	ed = (EditBox*)mWnd->findWidget("PopEdit3");  if (ed)  edit3 = ed->getCaption();

	//Hide();  // done in delegate
	
	mDelegates();
}
EditBox*
FormWindow::CreateEditBox(const char* lbl_text, int ax, int ay, int aw, int ah, DWORD aid, DWORD pid)
{
	EditBox*       edit   = 0;
	ActiveWindow*  parent = this;

	if (pid)
	parent = FindControl(pid);

	edit = new(__FILE__,__LINE__) EditBox(parent, ax, ay, aw, ah, aid);

	if (edit) {
		edit->SetForm(this);
		edit->SetText(lbl_text);

		if (!shown)
		edit->Hide();
	}

	return edit;
}
static void editBoxCallbackFunc(const char* pText, void* ctx)
{
    EditBoxImplAndroid* thiz = (EditBoxImplAndroid*)ctx;
    thiz->setText(pText);
	
    if (thiz->getDelegate() != NULL)
    {
        thiz->getDelegate()->editBoxTextChanged(thiz->getEditBox(), thiz->getText());
        thiz->getDelegate()->editBoxEditingDidEnd(thiz->getEditBox());
        thiz->getDelegate()->editBoxReturn(thiz->getEditBox());
    }
    
    EditBox* pEditBox = thiz->getEditBox();
    if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
    {
        cocos2d::ScriptEngineProtocol* pEngine = cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine();
        pEngine->executeEvent(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox);
        pEngine->executeEvent(pEditBox->getScriptEditBoxHandler(), "ended",pEditBox);
        pEngine->executeEvent(pEditBox->getScriptEditBoxHandler(), "return",pEditBox);
    }
}
Beispiel #22
0
void MyDialog::GetHiscoreName() {
	MAS::Window win;
	Dialog clientArea;
	ClearScreen clr;
	EditBox edit;
	Label l1, l2;
	Button but;

	clientArea.Add(clr);
	win.title.SetText("Game Over!");
	clientArea.Resize(278, 98);

	l1.Setup(10, 10, 200, 16, 0, 0, "You have a high score!", 0);
	l2.Setup(10, 38, 128, 16, 0, 0, "Enter your name:", 0);
	edit.Setup(150, 26, 100, 28, 0, D_EXIT, "player", 8);
	but.Setup(50, 60, 130, 24, ALLEGRO_KEY_O, D_EXIT, "&OK");

	clientArea.Add(l1);
	clientArea.Add(l2);
	clientArea.Add(edit);
	clientArea.Add(but);

	win.SetClientArea(&clientArea);
	win.Centre();
	edit.Select();
   //TODO
	//win.Popup(this, win.x(), win.y(), &edit);
	hsc->Add(edit.GetText(), eScore.GetInt(), eLines.GetInt());
}
static int tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler(lua_State* tolua_S)
{
    
    if (NULL == tolua_S)
        return 0;
    
    int argc = 0;
    EditBox* self = nullptr;
    
#if COCOS2D_DEBUG >= 1
    tolua_Error tolua_err;
	if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror;
#endif
    
    self = static_cast<EditBox*>(tolua_tousertype(tolua_S,1,0));
    
#if COCOS2D_DEBUG >= 1
	if (nullptr == self) {
		tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler'\n", NULL);
		return 0;
	}
#endif
    
    argc = lua_gettop(tolua_S) - 1;
    
    if (0 == argc)
    {
        self->unregisterScriptEditBoxHandler();
        return 0;
    }
    
    CCLOG("'unregisterScriptEditBoxHandler' function of EditBox  has wrong number of arguments: %d, was expecting %d\n", argc, 0);
    return 0;
    
#if COCOS2D_DEBUG >= 1
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'unregisterScriptEditBoxHandler'.",&tolua_err);
    return 0;
#endif
}
Beispiel #24
0
void HandleMenu(HWND hWnd, DWORD opt) {
    switch(opt) {
        case ID_SCALE_CONNECT:
            cEditBox.SetText("Trying to communicate with the scale...");
            mScale.EditItem(ID_SCALE_CONNECT, "&Connecting...", MF_DISABLED);
            _beginthread(ScaleConnect, 0, (void*) hWnd);
        break;

        case ID_FILE_NEW:
            if (!bSaved && vMealItems.size() > 0) {
                switch(MessageBox(hWnd, "You haven't saved the current meal, would you like to?","Hold Up!", MB_YESNOCANCEL | MB_ICONINFORMATION)) {
                    case IDYES:
                        if (CheckAndSave()==-1) break;
                    case IDNO:
                        cListBox.Clear();
                        vMealItems.clear();
                        strcpy(cSaveName, "");
                        cWindow.SetTitle("MealTrack - Untitled");
                        cButton.SetText("Start Meal");
                    break;

                    case IDCANCEL:
                    default:
                    break;
                }
            } else {
                cListBox.Clear();
                vMealItems.clear();
                strcpy(cSaveName, "");
                cWindow.SetTitle("MealTrack - Untitled");
                cButton.SetText("Start Meal");
            }
        break;

        case ID_FILE_SAVE:
            GetSaveFile(hWnd);
            if (vMealItems.size() >= 1) CheckAndSave();

            char tmp[313];
            sprintf(tmp, "MealTrack - %s", strrchr(cSaveName,'\\') + 1);
            cWindow.SetTitle(tmp);
        break;

        case ID_FILE_EXIT:
            PostMessage(hWnd, WM_CLOSE, 0, 0);
        break;

        case ID_SCALE_ZERO:
            if (scale != NULL) scale->Zero();
        break;
    }
}
void EditBoxImplAndroid::openKeyboard()
{
    if (_delegate != NULL)
    {
        _delegate->editBoxEditingDidBegin(_editBox);
    }
    EditBox* pEditBox = this->getEditBox();
    if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
    {
        cocos2d::ScriptEngineProtocol* pEngine = cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine();
        pEngine->executeEvent(pEditBox->getScriptEditBoxHandler(), "began",pEditBox);
    }
	
    showEditTextDialogJNI(  _placeHolder.c_str(),
						  _text.c_str(),
						  _editBoxInputMode,
						  _editBoxInputFlag,
						  _keyboardReturnType,
						  _maxLength,
						  editBoxCallbackFunc,
						  (void*)this  );
	
}
EditBox* EditBox::create(const Size& size, Scale9Sprite* pNormal9SpriteBg, Scale9Sprite* pPressed9SpriteBg/* = nullptr*/, Scale9Sprite* pDisabled9SpriteBg/* = nullptr*/)
{
    EditBox* pRet = new EditBox();
    
    if (pRet != nullptr && pRet->initWithSizeAndBackgroundSprite(size, pNormal9SpriteBg))
    {
        if (pPressed9SpriteBg != nullptr)
        {
            pRet->setBackgroundSpriteForState(pPressed9SpriteBg, Control::State::HIGH_LIGHTED);
        }
        
        if (pDisabled9SpriteBg != nullptr)
        {
            pRet->setBackgroundSpriteForState(pDisabled9SpriteBg, Control::State::DISABLED);
        }
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
    
    return pRet;
}
Beispiel #27
0
EditBox* TuiManager::createEditBox(float tag, const char* placeHolder, const char* file, int inputMode, int inputFlag, float x, float y, float w, float h, float rotation, int isUseFrame){
	EditBox *pEditBox = NULL;
	if(isUseFrame){
		pEditBox = EditBox::create(Size(w,h),Scale9Sprite::createWithSpriteFrameName(file));
	}else{
		pEditBox = EditBox::create(Size(w,h),Scale9Sprite::create(file));
	}
	pEditBox->setPlaceHolder(placeHolder);
	pEditBox->setInputMode((EditBox::InputMode)inputMode);
	pEditBox->setInputFlag((EditBox::InputFlag)inputFlag);
	pEditBox->setRotation(rotation);
	pEditBox->setPosition(Vec2(x,-y));
	pEditBox->setTag(tag);
	return pEditBox;
}
Beispiel #28
0
void ScaleConnect(void* args) {
    //If we aren't connected, connect!
    if (scale == NULL) {
        //Create a new scale and attempt to connect
        scale = new Scale("COM1");
        if (!scale->IsConnected()) {
            delete scale;
            scale = new Scale();
        }

        if (!scale->IsConnected()) {
            char err[256];
            sprintf(err, "Failed to connect! ERROR: %i", scale->GetError());

            mScale.EditItem(ID_SCALE_CONNECT, "&Connect");
            cEditBox.SetText(err);
            delete scale;
            scale = NULL;
            return;
        }

        //Begin the thread which sends a message to the Window's event and loops it
        hScaleThread = (HANDLE)_beginthread(GetScaleReading, 0, args);

        //Switch the menu to allow for disconnect & other features
        SendMessage((HWND)args, WM_SCALE_CONNECTED, 0, 0);
    } else {
        //Deactivate the meal
        bMealActive = 0;

        //Delete the scale which will disconnect it
        delete scale;
        scale = NULL;

        SendMessage((HWND)args, WM_SCALE_DISCONNECTED, 0, 0);
    }
}
void
FormWindow::CreateDefEdit(CtrlDef& def)
{
	EditBox* ctrl = CreateEditBox(def.GetText(),
	def.GetX(),
	def.GetY(),
	def.GetW(),
	def.GetH(),
	def.GetID(),
	def.GetParentID());

	ctrl->SetAltText(def.GetAltText());
	ctrl->SetEnabled(def.IsEnabled());
	ctrl->SetBackColor(def.GetBackColor());
	ctrl->SetForeColor(def.GetForeColor());
	ctrl->SetStyle(def.GetStyle());
	ctrl->SetSingleLine(def.GetSingleLine());
	ctrl->SetTextAlign(def.GetTextAlign());
	ctrl->SetTransparent(def.GetTransparent());
	ctrl->SetHidePartial(def.GetHidePartial());
	ctrl->SetPasswordChar(def.GetPasswordChar());

	ctrl->SetMargins(def.GetMargins());
	ctrl->SetTextInsets(def.GetTextInsets());
	ctrl->SetCellInsets(def.GetCellInsets());
	ctrl->SetCells(def.GetCells());
	ctrl->SetFixedWidth(def.GetFixedWidth());
	ctrl->SetFixedHeight(def.GetFixedHeight());

	ctrl->SetLineHeight(def.GetLineHeight());
	ctrl->SetScrollBarVisible(def.GetScrollBarVisible());
	ctrl->SetSmoothScroll(def.GetSmoothScroll());

	if (def.GetTexture().length() > 0) {
		Bitmap*     ctrl_tex = 0;
		DataLoader* loader   = DataLoader::GetLoader();
		loader->SetDataPath("Screens/");
		loader->LoadTexture(def.GetTexture(), ctrl_tex);
		loader->SetDataPath("");

		ctrl->SetTexture(ctrl_tex);
	}

	Font* f = FontMgr::Find(def.GetFont());
	if (f) ctrl->SetFont(f);
}
Beispiel #30
0
bool GuiPopup::Show(
	PopupDelegate* delegate, const UString& title, bool modal,
	const MyGUI::UString& text0, const MyGUI::UString& text1, const MyGUI::UString& text2, const MyGUI::UString& text3,
	const MyGUI::UString& edit0, const MyGUI::UString& edit1, const MyGUI::UString& edit2, const MyGUI::UString& edit3,
	const MyGUI::UString& button0, const MyGUI::UString& button1, const MyGUI::UString& button2, const MyGUI::UString& button3)
{
	if (isVisible)
		return false;
	isVisible = true;
	btnResult = -1;

	//  window    -----------------------
	int numEdits = 0;
	if (!text0.empty())  ++numEdits;  if (!text1.empty())  ++numEdits;
	if (!text2.empty())  ++numEdits;  if (!text3.empty())  ++numEdits;

	int scr_w = mPlatform->getRenderManagerPtr()->getViewSize().width, scr_h = mPlatform->getRenderManagerPtr()->getViewSize().height;
	int wnd_w = 392, wnd_h = 140 + numEdits * 80,
		wnd_x = (scr_w - wnd_w)/2, wnd_y = (scr_h - wnd_h)/2;  // center

	mWnd = mGUI->createWidget<Window>("WindowC", wnd_x,wnd_y, wnd_w,wnd_h, Align::Center, "Popup", "WndPop");
	mWnd->setColour(Colour(0.8f,0.96f,1.f));
	mWnd->setAlpha(0.9f);
	mWnd->setCaption(title);

	mDelegates.clear();  // add delegate
	mDelegates += delegate;

	if (modal)
		InputManager::getInstance().addWidgetModal(mWnd);


	//  text, edit  -----------------------
	int y = 24,  yadd = 80;
	if (!text0.empty())  {
		TextBox* text = mWnd->createWidget<TextBox>("TextBox", 16,    y, 352,28, Align::Default, "PopText0");	text->setCaption(text0);
		EditBox* edit = mWnd->createWidget<EditBox>("EditBox", 16, 32+y, 352,28, Align::Default, "PopEdit0");	edit->setCaption(edit0);
		y += yadd;
	}
	if (!text1.empty())  {
		TextBox* text = mWnd->createWidget<TextBox>("TextBox", 16,    y, 352,28, Align::Default, "PopText1");	text->setCaption(text1);
		EditBox* edit = mWnd->createWidget<EditBox>("EditBox", 16, 32+y, 352,28, Align::Default, "PopEdit1");	edit->setCaption(edit1);
		y += yadd;
	}
	if (!text2.empty())  {
		TextBox* text = mWnd->createWidget<TextBox>("TextBox", 16,    y, 352,28, Align::Default, "PopText2");	text->setCaption(text2);
		EditBox* edit = mWnd->createWidget<EditBox>("EditBox", 16, 32+y, 352,28, Align::Default, "PopEdit2");	edit->setCaption(edit2);
		y += yadd;
	}
	if (!text3.empty())  {
		TextBox* text = mWnd->createWidget<TextBox>("TextBox", 16,    y, 352,28, Align::Default, "PopText3");	text->setCaption(text3);
		EditBox* edit = mWnd->createWidget<EditBox>("EditBox", 16, 32+y, 352,28, Align::Default, "PopEdit3");	edit->setCaption(edit3);
		y += yadd;
	}

	//  buttons  -----------------------
	y += 12;
	int numBtns = 0;
	if (!button0.empty())  ++numBtns;  if (!button1.empty())  ++numBtns;
	if (!button2.empty())  ++numBtns;  if (!button3.empty())  ++numBtns;

	if (numBtns == 0)  ++numBtns;  // at least 1
	int xmarg = 20, w = (wnd_w - xmarg*2) / numBtns;
	int x = wnd_w - xmarg - w;

	if (!button0.empty())  {
		Button* btn = mWnd->createWidget<Button>("Button",  x,y, w-16,36, Align::Default, "PopBtn0");  btn->setCaption(button0);
		btn->setColour(Colour(0.7f,0.85f,1.0f));
		btn->eventMouseButtonClick += newDelegate(this, &GuiPopup::ButtonClick);  x -= w;
	}
	if (!button1.empty())  {
		Button* btn = mWnd->createWidget<Button>("Button",  x,y, w-16,36, Align::Default, "PopBtn1");  btn->setCaption(button1);
		btn->setColour(Colour(0.6f,0.8f,1.0f));
		btn->eventMouseButtonClick += newDelegate(this, &GuiPopup::ButtonClick);  x -= w;
	}
	if (!button2.empty())  {
		Button* btn = mWnd->createWidget<Button>("Button",  x,y, w-16,36, Align::Default, "PopBtn2");  btn->setCaption(button2);
		btn->setColour(Colour(0.6f,0.8f,1.0f));
		btn->eventMouseButtonClick += newDelegate(this, &GuiPopup::ButtonClick);  x -= w;
	}
	if (!button3.empty())  {
		Button* btn = mWnd->createWidget<Button>("Button",  x,y, w-16,36, Align::Default, "PopBtn3");  btn->setCaption(button3);
		btn->setColour(Colour(0.6f,0.8f,1.0f));
		btn->eventMouseButtonClick += newDelegate(this, &GuiPopup::ButtonClick);  x -= w;
	}

	return true;
}