CMainFrame::CMainFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxDefaultSize) { //wxDisplay Screen; //wxRect ClientRect = Screen.GetClientArea(); //this->SetSize(ClientRect); Maximize(true); m_panel = new wxPanel(this); initPanel(); wxMenu *fileMenu = new wxMenu(); wxMenu *helpMenu = new wxMenu(); helpMenu->Append(wxID_ABOUT, wxT("&About...\tF1"), wxT("Show about dialog")); fileMenu->Append(wxID_OPEN, wxT("&Open..."), wxT("Open Spell File")); fileMenu->Append(wxID_EXIT, wxT("&Quit...\tF2"), wxT("Quit App")); wxMenuBar *menuBar = new wxMenuBar(); menuBar->Append(fileMenu, wxT("&File")); menuBar->Append(helpMenu, wxT("&Help")); SetMenuBar(menuBar); CreateStatusBar(2); SetStatusText(wxT("Welcome to use spelleditor!")); }
PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* aModule, std::vector<MODULE_3D_SETTINGS> *aParentModelList ) : PANEL_PREV_3D_BASE( aParent, wxID_ANY ) { m_userUnits = aFrame->GetUserUnits(); initPanel(); // Initialize the color settings to draw the board and the footprint m_dummyBoard->SetColorsSettings( &aFrame->Settings().Colors() ); m_parentModelList = aParentModelList; m_dummyModule = new MODULE( *aModule ); m_dummyBoard->Add( m_dummyModule ); // Set 3d viewer configuration for preview m_settings3Dviewer = new CINFO3D_VISU(); bool option; Pgm().CommonSettings()->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false ); m_settings3Dviewer->SetFlag( FL_MOUSEWHEEL_PANNING, option ); // Create the 3D canvas m_previewPane = new EDA_3D_CANVAS( this, COGL_ATT_LIST::GetAttributesList( true ), m_dummyBoard, *m_settings3Dviewer, aFrame->Prj().Get3DCacheManager() ); m_SizerPanelView->Add( m_previewPane, 1, wxEXPAND, 5 ); }
bool LoginPanel::init() { if(!Layer::init())return false; CHILD_CLICK_CALLBACK { IF_CHILD_TOUCH_ENDED { if(ref == loginBtn) { if(isRemeberPassword) { LOCAL_SAVE->setStringForKey(PLAYER_NAME, nameTf->getStringValue()); LOCAL_SAVE->setStringForKey(PLAYER_PASSWORD, passwordTf->getStringValue()); CCLOG("save name is %s",nameTf->getStringValue().c_str()); CCLOG("save password is %s",passwordTf->getStringValue().c_str()); } publishEvent(LOGIN_GAME); } } }; //this->setAnchorPoint(cocos2d::Point(0.0f,0.0f)); new LoginMediator(this); //loading::PreLoader::getInstance()->loadLoginPanel([this](){initPanel();}); initPanel(); return true; }
int main (int argc, char * argv[]) { if (argc < 7) { printf("Usage : server config portnumber ttl infinity period isSplitHorizon\n"); printf("ttl should be less than 65536\n"); printf("infinity should be less than 65536\n"); printf("period should be less than 65536\n"); printf("isSplitHorizon is 0 or 1, 0 means to disable split horizon\n"); return 1; } char *config = argv[1]; int portNum = atoi(argv[2]); int ttl = atoi(argv[3]); int infinity = atoi(argv[4]); int period = atoi(argv[5]); int isSH = atoi(argv[6]); //create socket and bind to port int sockFd = socket(AF_INET, SOCK_DGRAM, 0); struct sockaddr_in addr_in; int addrin_len = sizeof(struct sockaddr_in); addr_in.sin_family = AF_INET; addr_in.sin_port = htons(portNum); addr_in.sin_addr.s_addr = INADDR_ANY; if (bind(sockFd, (struct sockaddr *) &addr_in, (socklen_t)addrin_len) == 0) { printf("bind successfully to port %u \n", portNum); } else { printf("failed to bind to port %u \n", portNum); return 1; } //test ip convert //char ipText[256] = "156.56.83.24"; //uint8_t ipResult[256] = {0}; //convertIpText(ipText, ipResult); //printf("%u, %u, %u, %u\n", ipResult[0], ipResult[1], ipResult[2], ipResult[3]); // read config file and initialize Panel dvPanel; dvPanel.port = portNum; dvPanel.sockFd = sockFd; dvPanel.ttl = ttl; dvPanel.infinity = infinity; dvPanel.isSH = isSH; dvPanel.period = period; initPanel(&dvPanel); if (initFromConfig(&dvPanel, config) == 0) { printf("initialize from config %s successfully\n", config); echoProfile(&dvPanel); } else { printf("failed to initialize from config %s\n", config); return 1; } // set up a new thread for periodically sending out update msg pthread_t updateThread; pthread_create(&updateThread, NULL, periodUpdate, (void *) &dvPanel); //set up a new thread for periodically minus ttl of forward records pthread_t ttlThread; pthread_create(&ttlThread, NULL, ttlCheck, (void *)&dvPanel); // recursively receive update msg and send trigger update msg while (1) { //recv update msg struct sockaddr_in tempAddr; int addr_len = sizeof(struct sockaddr_in); unsigned char buffer[2046] = {0}; int recvLen = 0; if ((recvLen = recvfrom(sockFd, buffer, sizeof buffer,0, (struct sockaddr *) &tempAddr, (socklen_t *)&addr_len)) <= 0) { printf("recv update msg failed\n"); close(sockFd); return 1; } //process update msg if (processUpdateMsg(&dvPanel, buffer, recvLen, (uint32_t) (tempAddr.sin_addr.s_addr)) != 0) { printf("process update msg error\n"); close(sockFd); return 1; } //trigger update msg sending if (triggerUpdateMsg(&dvPanel) != 0) { printf("trigger update msg error\n"); close(sockFd); return 1; } } }
int main(int argc, char **argv) { int ec = 0; struct usb_dev_handle *dev = initPanel(0); if(dev == NULL) { fprintf(stderr, "ERROR: Couldn't initialize USB button!\n"); return 2; } if(argc == 2){ unsigned char cmd = 64; if (!strcmp("close", argv[1])) { cmd = 96; //alternatively: 224 } else if(!strcmp("open", argv[1])) { cmd = 80; //alternatively: 208 } else { printf("Please specify a command (open/close)\n"); return 1; } if((ec = usb_interrupt_write(dev, 0x02, &cmd, 1, 10)) < 0){ printf("Error writing to USB device (%d): %s\n", ec, usb_strerror()); return 2; } }else if(argc == 1){ unsigned char data; unsigned char last = 0; unsigned int state = 0; fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) | O_NONBLOCK); while(1){ if(!usb_interrupt_read(dev, 0x01, &data, 1, 1)){ //printf("%x\n", data); unsigned char c = 64; if(last != data){ if((data & 0xF) == 5) printf("button pressed\n"); if(data & 0x2) printf("open button pressed\n"); if(data == 0x68) printf("opening\n"); if(data == 0x74) printf("closing\n"); if(data == 0x44 && last == 0x60) printf("open\n"); if(data == 0x58) printf("closed\n"); last = data; } if((ec = usb_interrupt_write(dev, 0x02, &c, 1, 1)) < 0){ printf("Error writing to USB device (%d): %s\n", ec, usb_strerror()); return 2; } } int len = read(0, &data, 1); if(len > 0){ char cmd; if(state == 0){ state = 1; if(data == 'c'){ cmd = 96; }else if(data == 'o'){ cmd = 80; } if((ec = usb_interrupt_write(dev, 0x02, &cmd, 1, 1)) < 0){ printf("Error writing to USB device (%d): %s\n", ec, usb_strerror()); return 2; } }else{ if(data == '\n'){ state = 0; } } } usleep(100000); } }else{ printf("Invalid argument. Specify open/close to open/close or nothing to listen.\n"); return 1; } usb_close(dev); return 0; }