六 基于FreeRTOS与MQTT的物联网技术应用系列——步进电机控制基于Cr( 三 )


er.h:
#ifndef __SettingsViewController_h__#define __SettingsViewController_h__#include "CrossApp.h"USING_NS_CC;class SettingsViewController : public CAViewController,public CATextFieldDelegate{public:SettingsViewController();virtual ~SettingsViewController();void viewDidLoad();void viewDidUnload();public:CAWebView* p_webView;protected:virtual bool textFieldShouldBeginEditing(CATextField* sender);//If the sender doesn't want to detach from the IME, return true;virtual bool textFieldShouldEndEditing(CATextField* sender);//virtual void textFieldShouldReturn(CATextField* sender);virtual void keyBoardHeight(CATextField* sender, int height);//Warning!!! Warning!!! Warning!!!This method is not on the OpenGL thread.virtual bool textFieldShouldChangeCharacters(CATextField* sender,unsigned int location,unsigned int lenght,const std::string& changedText);void alertButtonCallBack(CAControl* btn,DPoint point);private:CATextField* m_textField_IP;CATextField* m_textField_Port;CATextField* m_textField_Username;CATextField* m_textField_Password;CAButton* m_SaveBtn;std::string m_strIPInput;std::string m_strPortInput;};#endif /* defined(__SettingsViewController__) */
er.cpp:
#include "SettingsViewController.h"SettingsViewController::SettingsViewController(){}SettingsViewController::~SettingsViewController(){this->getView()->removeSubview(p_webView);p_webView = NULL;}void SettingsViewController::viewDidLoad(){CAImageView* view1 = CAImageView::createWithImage(CAImage::create("image/motor_control_view.jpg"));view1->setLayout(DLayoutFill);this->getView()->addSubview(view1);CALabel* label = CALabel::create();label->setColor(ccc4(51, 204, 255, 255));label->setText( UTF8( "网络参数设置"));label->setFontSize(36);label->setTextAlignment(CATextAlignmentLeft);label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);label->setLayout(DLayout(DHorizontalLayout_W_C(240, 0.5), DVerticalLayout_H_C(40, 0.12)));this->getView()->addSubview(label);std::string ctn;m_textField_IP = CATextField::createWithLayout(DLayout(DHorizontalLayout_L_R(100, 100),