void LoginForm::onLinkClick( wxCommandEvent& event ) { if ( event.GetId() == m_linkNewAccount->GetId() ) { onNewAccount(); } else if ( event.GetId() == m_linkLostPassword->GetId() ) { PasswordReminder wxPassReminderForm( this ); m_pNewAccount = &wxPassReminderForm; wxPassReminderForm.ShowModal(); m_pNewAccount = nullptr; } else if ( event.GetId() == m_linkOffline->GetId() ) { if ( GetParent() ) { Show( false ); MainApp* temp = dynamic_cast<MainApp*>(GetParent()); if ( temp ) temp->offlineMode(); } } }
void LoginForm::onLogin() { ASSERT_UITHREAD(); safe_delete(m_pLogThread); bool remPass = m_cbRemPass->GetValue(); gc_savelogin.setValue(remPass); if (gc_saveusername.getBool()) { wxString dastr = m_tbUsername->GetValue(); gc_lastusername.setValue(dastr.ToUTF8()); } SaveCVars(); if (m_comboProvider) gc_login_stage_last.setValue(m_comboProvider->GetStringSelection().ToUTF8()); Show(false); MainApp* temp = dynamic_cast<MainApp*>(GetParent()); if (temp) temp->onLoginAccepted(remPass, m_bAutoLogin); }
void SkypeWinClient::skypeAttachStatus (bool bOk) { MainApp *theApp = (MainApp *)qApp; bool bInWork = false; do // Begin cleanup block (not a loop) { if (!bOk) { theApp->clearSkypeHandle (); break; } QMutexLocker locker (&mutex); if (SW_Connect != workCurrent.whatwork) { qWarning ("SkypeWinClient: We're not in connection phase."); break; } bInWork = true; bOk = SkypeClient::ensureConnected (); } while (0); // End cleanup block (not a loop) }//SkypeWinClient::skypeAttachStatus
int main(int argc, char **argv) { int c; // Parse options while(1) { int option_index = 0; static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {0,0,0,0} }; c = getopt_long (argc, argv, "h", long_options, &option_index); if (c == -1) break; switch(c) { case 'h': case '?': Usage(argc,argv); return 0; default: printf ("?? getopt returned character code 0%o ??\n", c); } } MainApp myApplication; myApplication.Run(); return(0); }
int main( int argc, char **argv ) { MainApp app; // 打包时记得因为测试而关闭的等待连接响应包部分 app.InitMainApp(argc, argv); char *szrun = app.getArgv("r") ; char szlog[1024] = {0} ; if ( szrun != NULL ) sprintf( szlog, "%s/%s", szrun, RUN_LOG_PATH ) ; else getrunpath( MTRANS_ENV, szlog, ABS_LOG_PATH , LOG_PATH ) ; char szconf[1024] = {0} ; if ( szrun != NULL ) sprintf( szconf, "%s/%s/%s", szrun, RUN_CONF_PATH , CONFIG ) ; else getconfpath( MTRANS_ENV, szconf, ABS_CONF_PATH , CONF_PATH , CONFIG ) ; CSystemEnv env ; if ( ! env.Init( szconf, szlog , LOG_NAME ) ) { printf( "CSystemEnv init failed\n" ) ; return 0 ; } if ( ! env.Start() ) { printf( "CSystemEnv start failed\n" ) ; return 0 ; } int index = 0 ; CTruckUnPackMgr packer ; CPackFactory factory(&packer) ; IPlugWay *way = env.GetPlugWay() ; while (1) { SendMessage( way, index , factory ) ; index = (index) % 11; printf("index:%d\n",index); index++; sleep(1) ; } // pipe_server.Stop(); sleep(1); INFO_PRT("press enter to leave!"); getchar(); return 0; }
/// public global function. I hate globals but necessary I guess int getTaskReadFreqHz() { MainApp *app = mainApp(); ConfigureDialogController *cfgctl = 0; if ( app && (cfgctl = app->configureDialogController()) && cfgctl->acceptedParams.lowLatency ){ return DEF_TASK_READ_FREQ_HZ_*3; } return DEF_TASK_READ_FREQ_HZ_; }
void MainFrame::OnStartClick( wxCommandEvent& event ) { // TODO: Implement OnStartClick try { GeneAnc *rootnode= NULL; GeneAnc *tmpnode = NULL; int similarity = m_comboBox1->GetCurrentSelection(); int linkage = m_comboBox2->GetCurrentSelection(); wxString input = m_filePicker1->GetPath(); wxString output = m_textCtrl1->GetValue(); std::string input_clas,output_clas; input_clas.append((const char*)input.mb_str()); output_clas.append((const char*)output.mb_str()); m_spinCtrl1->GetValue(); MainApp *main = new MainApp(input_clas, output_clas, MainApp::converterCor(similarity), m_spinCtrl2->GetValue(), m_spinCtrl1->GetValue() ); int count = main->GenesCount(); main->SetLinkage(MainApp::converterLin(linkage)); m_textCtrl2->Clear(); wxString text1= wxT("Calculating similarity matrix ...\n"); m_textCtrl2->AppendText(text1); main->CalculateCorrelations(); wxString text2= wxT("Clustering ...\n"); m_textCtrl2->AppendText(text2); while ((tmpnode = main->DoClustering()) != NULL) { rootnode = tmpnode; } /* while (main->DoClustering(rootnode)) { tmp = rootnode; }*/ wxString text3= wxT("Saving to XML ...\n"); m_textCtrl2->AppendText(text3); main->saver->SaveDendrogram(rootnode); wxString text4= wxT("Done ...\n"); m_textCtrl2->AppendText(text4); delete main; } catch(std::exception &e) { std::cout << "problem" << std::endl; m_textCtrl2->AppendText(wxT("Error ocurred, is input file valid?")); } }
/* FUNCTION: main ARGS: arc number of command line arguments argv vector to arguments RETURN: Exit status DESCRIPTION: main program entry point */ int main(int argc, char **argv) { // Check if shape specified on command line MainWindow::SHAPE shape = MainWindow::BOOK; if (argc > 1) { int value = *argv[1] - '0'; if (value >= 0 && value < MainWindow::NUMBER_OF_SHAPES) shape = (MainWindow::SHAPE) value; } MainApp *app = new MainApp(shape); app->Run(); delete app; }
bool SkypeWinClient::ensureConnected () { MainApp *theApp = (MainApp *)qApp; bool rv = false; QString strResponse; do // Begin cleanup block (not a loop) { if (NULL == theApp->getSkypeHandle ()) { MainApp *theApp = (MainApp *)qApp; UINT ret = SendMessageTimeout (HWND_BROADCAST, theApp->getDiscover (), (WPARAM)mainwin.winId (), 0, SMTO_ABORTIFHUNG, 2 * 1000, // 2 sec per top level window NULL); if (1 != ret) { qWarning ("SkypeWinClient: Failed to send connect message"); break; } rv = true; break; } rv = SkypeClient::ensureConnected (); } while (0); // End cleanup block (not a loop) if (!rv) { completeCurrentWork (SW_Connect, false); } return (rv); }//SkypeWinClient::ensureConnected
bool SkypeWinClient::invoke (const QString &strCommand) { MainApp *theApp = (MainApp *)qApp; LRESULT lRet = FALSE; do // Begin cleanup block (not a loop) { qDebug () << "SkypeWinClient: Sending command" << strCommand; QMutexLocker locker (&mutex); bInvokeInProgress = true; COPYDATASTRUCT cds; memset (&cds, 0, sizeof (cds)); QByteArray ba = strCommand.toUtf8(); cds.cbData = ba.size () + 1; cds.lpData = ba.data (); lRet = SendMessage (theApp->getSkypeHandle (), WM_COPYDATA, (WPARAM) mainwin.winId (), (LPARAM) &cds); if (FALSE == lRet) { DWORD dw = GetLastError (); bInvokeInProgress = false; if (ERROR_INVALID_WINDOW_HANDLE == dw) { theApp->clearSkypeHandle (); } QString m = QString("Failed to Invoke. GetLastError = %1").arg(dw); emit internalCompleted (-1, m); break; } } while (0); // End cleanup block (not a loop) return (TRUE == lRet); }//SkypeWinClient::invoke
void Main_Msg::initMessenger( ConsoleWindow *cw ) { MainApp *app = mainApp(); // ----------- // Console log // ----------- this->cw = cw; defLogColor = cw->textEdit()->textColor(); // ----------- // System tray // ----------- QMenu *m = new QMenu( cw ); m->addAction( app->act.shwHidConsAct ); m->addAction( app->act.shwHidGrfsAct ); m->addSeparator(); m->addAction( app->act.aboutAct ); m->addSeparator(); m->addAction( app->act.quitAct ); sysTray = new QSystemTrayIcon( this ); sysTray->setContextMenu( m ); sysTray->setIcon( app->windowIcon() ); sysTray->show(); // ---------- // Status bar // ---------- QTimer *timer = new QTimer( this ); ConnectUI( timer, SIGNAL(timeout()), this, SLOT(timedStatusBarUpdate()) ); timer->start( 500 ); }
void LoginForm::onLogin() { safe_delete(m_pLogThread); #ifndef UI_HIDE_AUTOLOGIN bool remPass = m_cbRemPass->GetValue(); gc_savelogin.setValue(remPass); #else bool remPass = false; #endif if (gc_saveusername.getBool()) { wxString dastr = m_tbUsername->GetValue(); gc_lastusername.setValue((const char*)dastr.c_str()); } Show(false); MainApp* temp = dynamic_cast<MainApp*>(GetParent()); if (temp) temp->onLoginAccepted(remPass, m_bAutoLogin); }
int WINAPI WinMain( HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */ ) { HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); if (SUCCEEDED(CoInitialize(NULL))) { { MainApp app; if (SUCCEEDED(app.Initialize())) { app.RunMessageLoop(); } } CoUninitialize(); } return 0; }
void GLFWCALL mousebutton(int button, int action) { switch(action) { case GLFW_PRESS: if(button == GLFW_MOUSE_BUTTON_LEFT) { app.OnMouseDown(mouse_x, mouse_y, MainApp::MOUSE_LEFT); } if(button == GLFW_MOUSE_BUTTON_RIGHT) { app.OnMouseDown(mouse_x, mouse_y, MainApp::MOUSE_RIGHT); } if(button == GLFW_MOUSE_BUTTON_MIDDLE) { app.OnMouseDown(mouse_x, mouse_y, MainApp::MOUSE_MIDDLE); } break; case GLFW_RELEASE: if(button == GLFW_MOUSE_BUTTON_LEFT) { app.OnMouseUp(mouse_x, mouse_y, MainApp::MOUSE_LEFT); } if(button == GLFW_MOUSE_BUTTON_RIGHT) { app.OnMouseUp(mouse_x, mouse_y, MainApp::MOUSE_RIGHT); } if(button == GLFW_MOUSE_BUTTON_MIDDLE) { app.OnMouseUp(mouse_x, mouse_y, MainApp::MOUSE_MIDDLE); } break; } }
void GLFWCALL resize(int w, int h) { app.OnResize(w,h); }
int main(int argc, char *argv[]) { if(!glfwInit()) { return -1; } //Create GL context glfwOpenWindow(WINDOW_WIDTH, WINDOW_HEIGHT, 8, 8, 8, 8, 8, 8, GLFW_WINDOW); glEnable(GL_CULL_FACE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); //Initialize GLEW GLenum err = glewInit(); if(err != GLEW_NO_ERROR) { const unsigned char *str = glewGetErrorString(err); return -1; } //Callbacks glfwSetWindowSizeCallback(resize); glfwSetMouseButtonCallback(mousebutton); glfwSetMousePosCallback(mousepos); glClearColor(0.1,0.1,0.1,1.0); app.Init(); app.OnResize(WINDOW_WIDTH, WINDOW_HEIGHT); float start = 0; float end = 0; float delta = 0; while(1) { start = glfwGetTime(); if(glfwGetKey(GLFW_KEY_ESC)) break; //Clear the existing screen data glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(soundDoneFlag) { app.OnPlayComplete(); soundDoneFlag = false; } //Update app logic app.Update(delta); //Flip the screen buffer glfwSwapBuffers(); end = glfwGetTime(); delta = end - start; } app.ShutDown(); return 0; }
void mouse_callback(int event, int x, int y, int flags, void* param) { MainApp *app = ((MainApp *)param); switch (event) { case CV_EVENT_LBUTTONDBLCLK: app->mouseDoubleClick(x,y,APP_MOUSE_LEFT); break; case CV_EVENT_RBUTTONDBLCLK: app->mouseDoubleClick(x,y,APP_MOUSE_RIGHT); break; case CV_EVENT_MBUTTONDBLCLK: app->mouseDoubleClick(x,y,APP_MOUSE_MIDDLE); break; case CV_EVENT_LBUTTONDOWN: app->mousePressed(x,y,APP_MOUSE_LEFT); break; case CV_EVENT_RBUTTONDOWN: app->mousePressed(x,y,APP_MOUSE_RIGHT); break; case CV_EVENT_MBUTTONDOWN: app->mousePressed(x,y,APP_MOUSE_MIDDLE); break; case CV_EVENT_LBUTTONUP: app->mouseReleased(x,y,APP_MOUSE_LEFT); break; case CV_EVENT_RBUTTONUP: app->mouseReleased(x,y,APP_MOUSE_RIGHT); break; case CV_EVENT_MBUTTONUP: app->mouseReleased(x,y,APP_MOUSE_MIDDLE); break; case CV_EVENT_MOUSEMOVE: app->mouseMoved(x,y); break; } }
LRESULT CALLBACK MainApp::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT result = 0; if (message == WM_CREATE) { LPCREATESTRUCT pcs = (LPCREATESTRUCT)lParam; MainApp *pMainApp = (MainApp *)pcs->lpCreateParams; ::SetWindowLongPtrW( hwnd, GWLP_USERDATA, PtrToUlong(pMainApp) ); result = 1; } else { MainApp *pMainApp = reinterpret_cast<MainApp *>(static_cast<LONG_PTR>( ::GetWindowLongPtrW( hwnd, GWLP_USERDATA ))); bool wasHandled = false; if (pMainApp) { switch (message) { case WM_TIMER: { pMainApp->OnTimer(); } result = 0; wasHandled = true; break; case WM_SIZE: { UINT width = LOWORD(lParam); UINT height = HIWORD(lParam); pMainApp->OnResize(width, height); } result = 0; wasHandled = true; break; case WM_DISPLAYCHANGE: { InvalidateRect(hwnd, NULL, FALSE); } result = 0; wasHandled = true; break; case WM_PAINT: { pMainApp->OnRender(); ValidateRect(hwnd, NULL); } result = 0; wasHandled = true; break; case WM_DESTROY: { PostQuitMessage(0); } result = 1; wasHandled = true; break; case WM_KEYDOWN: { switch (wParam){ case VK_ESCAPE: ExitProcess(0); } } } } if (!wasHandled) { result = DefWindowProc(hwnd, message, wParam, lParam); } } return result; }
void GLFWCALL mousepos(int x, int y) { mouse_x = x; mouse_y = y; app.OnMouseMove(x, y); }