示例#1
0
int main(int & argc, char ** argv)
{
	int aargc = 0;
	char ** aargv = NULL;
	wxEntryStart(aargc, aargv);


	KinectDataSender * sender = new KinectDataSender(wxT("127.0.0.1"), 9500);
	if(sender->Create() != wxTHREAD_NO_ERROR)
	{
		wxDELETE(sender);
		return 1;
	}
	sender->Run();
	wxSleep(1);
	char * data = new char[10];
	sprintf(data, "12345");
	sender->SendKinectData(data, strlen(data), FRAME_COLOR);
	/*sprintf(data, "23456");
	sender->Send(data, strlen(data), FRAME_COLOR);
	sprintf(data, "34567");
	sender->Send(data, strlen(data), FRAME_COLOR);*/
	delete [] data;
	getchar();
	sender->Stop();
	sender->Delete();
	wxEntryCleanup();
	return 0;
}
示例#2
0
文件: mfctest.cpp 项目: nealey/vera
BOOL CTheApp::InitInstance()
{
    if ( !CWinApp::InitInstance() )
        return FALSE;

    // TODO: cmd line parsing
    WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
    wxSetInstance(m_hInstance);
    wxApp::m_nCmdShow = m_nCmdShow;
    int argc = 0;
    wxChar **argv = NULL;
    wxEntryStart(argc, argv);
    if ( !wxTheApp || !wxTheApp->CallOnInit() )
        return FALSE;

#if START_WITH_MFC_WINDOW
    // Demonstrate creation of an initial MFC main window.
    m_pMainWnd = new CMainWindow();
    m_pMainWnd->ShowWindow( m_nCmdShow );
    m_pMainWnd->UpdateWindow();
#else
    // Demonstrate creation of an initial wxWidgets main window.
    // Wrap wxWidgets window in a dummy MFC window and
    // make the main window.
    if (wxTheApp && wxTheApp->GetTopWindow())
    {
        m_pMainWnd = new CDummyWindow((HWND) wxTheApp->GetTopWindow()->GetHWND());
    }
#endif

    return TRUE;
}
示例#3
0
 virtual void SetUp(){
 char appname[] = "ClockTest.o";
 int argc = 1;
 char *argv[1] = {appname};
 app = new TimerApp();
 wxApp::SetInstance(app);
 wxEntryStart(argc,argv);
 app->OnInit();
 }
示例#4
0
int main(int argc, char** argv)
{
	wxApp::SetInstance(new gui_main());
	wxEntryStart(argc, argv);
	wxTheApp->OnInit();

	std::cout << "main test" << std::endl;

	wxTheApp->OnRun();
	wxTheApp->OnExit();
	wxEntryCleanup();

	/*
	std::cout << "main thread id = " << std::this_thread::get_id() << std::endl;

	try
	{
		actor_system as("client_system", 8558);
		std::string rpi_actor_ref = "[email protected]:8556";
		auto actor = std::shared_ptr<gpio_client_actor>(new gpio_client_actor(rpi_actor_ref, as, [](std::string msg)
		{
			std::cout << msg << std::endl;
		}));
		as.add_actor(actor);

		message response = actor->future(GPIO_CONNECT, 1000);
		if (response.type != GPIO_CONNECTED)
		{
			std::cout << "type is not GPIO_CONNECTED" << std::endl;
		}
		else if (response.type == GPIO_CONNECTED)
		{
			std::cout << "connect successed" << std::endl;
		}

		actor->tell(GPIO_REQUEST_PINS);

		_sleep(2000);
		//as.get_actor("test_actor");
	}
	catch (std::runtime_error)
	{
		std::cerr << "runtime error" << std::endl;
	}
	catch (std::exception& e)
	{
		std::cerr << e.what() << std::endl;
	}
	catch (...)
	{
		std::cout << "Got an exception!";
	}
	*/

	std::cout << "PROGRAM STOP" << std::endl;
	return 0;
}
示例#5
0
void PathView::init()
{
  //std::cout << "PathView init" << std::endl;
  argc = 0;
  argv = new char*[argc];
  wxEntryStart( argc, argv );
  wxTheApp->CallOnInit();
  wxTheApp->OnRun();
}
示例#6
0
文件: init.cpp 项目: gitrider/wxsj2
bool wxInitialize(int argc, wxChar **argv)
{
    wxCRIT_SECT_LOCKER(lockInit, gs_initData.csInit);

    if ( gs_initData.nInitCount++ )
    {
        // already initialized
        return true;
    }

    return wxEntryStart(argc, argv);
}
示例#7
0
文件: init.cpp 项目: gitrider/wxsj2
// we provide a wxEntryStart() wrapper taking "char *" pointer too
bool wxEntryStart(int& argc, char **argv)
{
    ConvertArgsToUnicode(argc, argv);

    if ( !wxEntryStart(argc, gs_initData.argv) )
    {
        FreeConvertedArgs();

        return false;
    }

    return true;
}
bool FileUniDialog (const std::string& sInitialDir, const std::string& sFilePattern, 
	const std::string& sTitle, std::string& sFilePath, bool open) {
	
	// store old working directory to restore it later
	char old_cwd[512];
	getcwd(old_cwd, 512);
	// and set cwd to the given one
	chdir(sInitialDir.c_str());
			
	// create minimal app and window
	wxApp *app = new wxApp();
	int args = 0;
	
	wxEntryStart(args,(wxChar **)0);

	wxWindow *mainWindow = new wxWindow();
	mainWindow->Show(FALSE);
	app->SetTopWindow(mainWindow);
	
	app->CallOnInit();
	
	// create and show dialog
	
	wxFileDialog* openFileDialog =
		new wxFileDialog( mainWindow, wxString::FromAscii(sTitle.c_str()), _(""), _(""), 
			wxString::FromAscii(sFilePattern.c_str()), 
			open ? (wxOPEN | wxFD_FILE_MUST_EXIST) : (wxSAVE | wxFD_OVERWRITE_PROMPT), 
			wxDefaultPosition);
 
 	bool ok = false;
 
	if ( openFileDialog->ShowModal() == wxID_OK ){
		sFilePath = openFileDialog->GetPath().ToAscii();
		ok = true;
	}

	wxEntryCleanup();
	
	delete mainWindow;

	// TODO manually delete app cause a segfault. unsure if this leads to a memory leak!
	//delete app;
	
	app = 0;
	mainWindow = 0;
	
	// restore working directory
	chdir(old_cwd);
	
	return ok;
}
示例#9
0
文件: init.cpp 项目: gitrider/wxsj2
int wxEntryReal(int& argc, wxChar **argv)
{
#if wxUSE_LOG
    // Create a non-GUI log target, to be used until GUI (if any) is ready.
    // Target will be reset by wxAppConsole::Initialize, when GUI logging will work.
    wxLog::GetActiveTarget();
#endif

    // library initialization
    if ( !wxEntryStart(argc, argv) )
    {
        return -1;
    }

    // if wxEntryStart succeeded, we must call wxEntryCleanup even if the code
    // below returns or throws
    wxCleanupOnExit cleanupOnExit;

    WX_SUPPRESS_UNUSED_WARN(cleanupOnExit);

    wxTRY
    {

        // app initialization
        if ( !wxTheApp->CallOnInit() )
        {
            // don't call OnExit() if OnInit() failed
            return -1;
        }

        // ensure that OnExit() is called if OnInit() had succeeded
        class CallOnExit
        {
        public:
            ~CallOnExit() { wxTheApp->OnExit(); }
        } callOnExit;

        WX_SUPPRESS_UNUSED_WARN(callOnExit);

        // app execution
        return wxTheApp->OnRun();
    }
    wxCATCH_ALL( wxTheApp->OnUnhandledException(); return -1; )
}
示例#10
0
文件: init.cpp 项目: madnessw/thesnow
int wxEntryReal(int& argc, wxChar **argv)
{
    // library initialization
    if ( !wxEntryStart(argc, argv) )
    {
#if wxUSE_LOG
        // flush any log messages explaining why we failed
        delete wxLog::SetActiveTarget(NULL);
#endif
        return -1;
    }

    // if wxEntryStart succeeded, we must call wxEntryCleanup even if the code
    // below returns or throws
    wxCleanupOnExit cleanupOnExit;

    WX_SUPPRESS_UNUSED_WARN(cleanupOnExit);

    wxTRY
    {

        // app initialization
        if ( !wxTheApp->CallOnInit() )
        {
            // don't call OnExit() if OnInit() failed
            return -1;
        }

        // ensure that OnExit() is called if OnInit() had succeeded
        class CallOnExit
        {
        public:
            ~CallOnExit() { wxTheApp->OnExit(); }
        } callOnExit;

        WX_SUPPRESS_UNUSED_WARN(callOnExit);

        // app execution
        return wxTheApp->OnRun();
    }
    wxCATCH_ALL( wxTheApp->OnUnhandledException(); return -1; )
}
static bool createWxAppInstance(void) {
   static int   argc   = 1;
   static char  arg0[] = "usbdm";
   static char *argv[] = {arg0, NULL};

   dummyApp = new MinimalApp();

   wxApp::SetInstance(dummyApp);

   wxInitializationSuccess = wxEntryStart(argc, argv);
   wxInitializationSuccess = wxInitializationSuccess && (wxTheApp != NULL) && wxTheApp->CallOnInit();
//   fprintf(logFile, "createWxAppInstance() - wxInitializationSuccess = %s\n", wxInitializationSuccess?"TRUE":"FALSE");
//   fflush(logFile);
   if (!wxInitializationSuccess) {
      return false;
   }
#ifndef _WIN32
   ((wxStandardPaths&)wxStandardPaths::Get()).SetInstallPrefix(_("/usr/local"));
#endif
   return true;
}
示例#12
0
文件: flybot.cpp 项目: jonny64/flybot
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID)
{
    int argc = 0;
    char **argv = NULL;
    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
            wxSetInstance((HINSTANCE)hModule);
            wxEntryStart(argc, argv);
            break;
        case DLL_THREAD_ATTACH:
            break;
        case DLL_THREAD_DETACH:
            break;
        case DLL_PROCESS_DETACH:
            if (wxTheApp)
                wxTheApp->OnExit();
            wxEntryCleanup();
            break;
    }
    return TRUE;
}
示例#13
0
void initPINCode(void) {
	int argc=0;
	char **argv = NULL;
	wxEntryStart(argc, argv);
	wxGetApp().CallOnInit();
}
示例#14
0
文件: cmgui.cpp 项目: A1kmm/libzinc
/*
Global functions
----------------
*/

#if defined (WX_USER_INTERFACE)

bool wxCmguiApp::OnInit()
{
	return (true);
}

wxAppTraits * wxCmguiApp::CreateTraits()
{
	return new wxGUIAppTraits;
}

void wxCmguiApp::OnIdle(wxIdleEvent& event)
{
	if (event_dispatcher)
	{
		if (Event_dispatcher_process_idle_event(event_dispatcher))
		{
			event.RequestMore();
		}
	}
}

void wxCmguiApp::SetEventDispatcher(Event_dispatcher *event_dispatcher_in)
{
	event_dispatcher = event_dispatcher_in;
}

BEGIN_EVENT_TABLE(wxCmguiApp, wxApp)
	EVT_IDLE(wxCmguiApp::OnIdle)
END_EVENT_TABLE()

IMPLEMENT_APP_NO_MAIN(wxCmguiApp)

#endif /*defined (WX_USER_INTERFACE)*/

#if !defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER)
int main(int argc,const char *argv[])
#else /* !defined (WIN32_USER_INTERFACE)  && !defined (_MSC_VER)*/
int WINAPI WinMain(HINSTANCE current_instance,HINSTANCE previous_instance,
	LPSTR command_line,int initial_main_window_state)
	/* using WinMain as the entry point tells Windows that it is a gui and to use
		the graphics device interface functions for I/O */
	/*???DB.  WINDOWS a zero return code if WinMain does get into the message
		loop.  Other application interfaces may expect something else.  Should this
		failure code be #define'd ? */
	/*???DB. Win32 SDK says that don't have to call it WinMain */
#endif /* !defined (WIN32_USER_INTERFACE)  && !defined (_MSC_VER)*/
/*******************************************************************************
LAST MODIFIED : 7 January 2003

DESCRIPTION :
Main program for the CMISS Graphical User Interface
==============================================================================*/
{
	int return_code = 0;
#if defined (WIN32_USER_INTERFACE) || defined (_MSC_VER)
	int argc = 1, i;
	const char **argv;
	char *p, *q;
#endif /* defined (WIN32_USER_INTERFACE) */
	struct Cmiss_context_app *context = NULL;
	struct User_interface_module *UI_module = NULL;
	struct Cmiss_command_data *command_data;

#if !defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER)
	ENTER(main);
#else /* !defined (WIN32_USER_INTERFACE)  && !defined (_MSC_VER)*/
	ENTER(WinMain);

	//_CrtSetBreakAlloc(28336);
	for (p = command_line; p != NULL && *p != 0;)
	{
		p = strchr(p, ' ');
		if (p != NULL)
			p++;
		argc++;
	}

	argv = (const char **)malloc(sizeof(*argv) * argc);

	argv[0] = "cmgui";

	for (i = 1, p = command_line; p != NULL && *p != 0;)
	{
		q = strchr(p, ' ');
		if (q != NULL)
			*q++ = 0;
		if (p != NULL)
			argv[i++] = p;
		p = q;
	}
#endif /* !defined (WIN32_USER_INTERFACE)  && !defined (_MSC_VER)*/

	/* display the version */
	display_message(INFORMATION_MESSAGE, "%s version %s\n%s\n"
		"Build information: %s %s\n", CMISS_NAME_STRING, CMISS_VERSION_STRING,
		CMISS_COPYRIGHT_STRING, CMISS_BUILD_STRING,
		CMISS_SVN_REVISION_STRING);

#if defined (CARBON_USER_INTERFACE) || (defined (WX_USER_INTERFACE) && defined (DARWIN))
	ProcessSerialNumber PSN;
	GetCurrentProcess(&PSN);
	TransformProcessType(&PSN,kProcessTransformToForegroundApplication);
#endif
	context = Cmiss_context_app_create("default");
#if defined (WX_USER_INTERFACE)
	int wx_entry_started = 0;
#endif
	if (context)
	{
#if defined (WX_USER_INTERFACE) || (!defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER))
		UI_module = Cmiss_context_create_user_interface(context, argc, argv, NULL);
#else /* !defined (WIN32_USER_INTERFACE)  && !defined (_MSC_VER)*/
		UI_module = Cmiss_context_create_user_interface(context, argc, argv, current_instance,
			previous_instance, command_line, initial_main_window_state, NULL);
#endif /* !defined (WIN32_USER_INTERFACE)  && !defined (_MSC_VER)*/
		if (UI_module)
		{
#if defined (WX_USER_INTERFACE)
			if (UI_module->user_interface)
			{
				char **temp_argv = NULL, **cleanup_argv = NULL;
				int temp_argc = argc, cleanup_argc = argc;
				if (cleanup_argc > 0)
				{
					ALLOCATE(temp_argv, char *, cleanup_argc);
					ALLOCATE(cleanup_argv, char *, cleanup_argc);
					for (int i = 0; i < cleanup_argc; i++)
					{
						cleanup_argv[i] = temp_argv[i] = duplicate_string(argv[i]);
					}
				}
				if (wxEntryStart(temp_argc, temp_argv))
				{
					wx_entry_started = 1;
					wxXmlResource::Get()->InitAllHandlers();
					wxCmguiApp &app = wxGetApp();
					if (&app)
					{
						app.SetEventDispatcher(UI_module->event_dispatcher);
					}
					else
					{
						display_message(ERROR_MESSAGE,
							"initialiseWxApp.  wxCmguiApp not initialised.");
					}
				}
				else
				{
					display_message(ERROR_MESSAGE,
						"initialiseWxApp.  Invalid arguments.");
				}
				if (cleanup_argv)
				{
					for (int i = 0; i < cleanup_argc; i++)
					{
						DEALLOCATE(cleanup_argv[i]);
					}
					DEALLOCATE(temp_argv);
					DEALLOCATE(cleanup_argv);
				}
			}
#endif
			Cmiss_graphics_module_id graphics_module = NULL;
			if (NULL != (graphics_module = Cmiss_context_get_default_graphics_module(Cmiss_context_app_get_core_context(context))))
			{
				Cmiss_graphics_module_define_standard_materials(graphics_module);
				Cmiss_graphics_module_destroy(&graphics_module);
			}
			if (NULL != (command_data = Cmiss_context_get_default_command_interpreter(context)))
			{
				Cmiss_command_data_set_cmgui_string(command_data, CMISS_NAME_STRING,
					CMISS_VERSION_STRING, "CMISS_DATE_STRING", CMISS_COPYRIGHT_STRING, CMISS_BUILD_STRING,
					CMISS_SVN_REVISION_STRING);
				Cmiss_command_data_main_loop(command_data);
				Cmiss_command_data_destroy(&command_data);
				return_code = 0;
			}
			else
			{
				return_code = 1;
			}
			User_interface_module_destroy(&UI_module);
		}
		else
		{
			return_code = 1;
		}
		Cmiss_context_app_destroy(&context);
		Context_internal_cleanup();
#if defined (WX_USER_INTERFACE)
		if (wx_entry_started)
			wxEntryCleanup();
#endif
		/* FieldML does not cleanup the global varaibles xmlParser, xmlSchematypes and
		 * xmlCatalog at this moment, so we clean it up here instead*/
		xmlCatalogCleanup();
		xmlSchemaCleanupTypes();
		xmlCleanupParser();
	}
	else
	{
		return_code = 1;
	}
#if defined (WIN32_USER_INTERFACE) || defined (_MSC_VER)
	free(argv)
#endif
	LEAVE;

	return (return_code);
} /* main */
示例#15
0
Lugre::eLugreMessageBoxResult		LugreMessageBox				(Lugre::eLugreMessageBoxType iType,std::string sTitle,std::string sText) {
	wxApp *app = new wxApp();
	int args = 0;
	wxEntryStart(args,(wxChar **)0);
	//~ wxWindow *mainWindow = new wxWindow();
	//~ mainWindow->Show(FALSE);
	//~ app->SetTopWindow(mainWindow);
	app->CallOnInit();
	
	int style = wxOK;
	switch (iType) {
		case kLugreMessageBoxType_Ok			: style = wxOK; break;
		case kLugreMessageBoxType_OkCancel		: style = wxOK | wxCANCEL ; break;
		case kLugreMessageBoxType_YesNo			: style = wxYES_NO ; break;
		case kLugreMessageBoxType_YesNoCancel	: style = wxYES_NO | wxCANCEL ; break;
	}
	int res = wxMessageBox(wxString::FromAscii(sText.c_str()),wxString::FromAscii(sTitle.c_str()),style);
	
	wxEntryCleanup();
	//~ delete app; // segfaults ? weird, oh well, better a small memleak than a crash
	
	switch (res) {
		case wxYES:		return kLugreMessageBoxResult_Yes;
		case wxNO:		return kLugreMessageBoxResult_No;
		case wxCANCEL:	return kLugreMessageBoxResult_Cancel;
		case wxOK:		return kLugreMessageBoxResult_Ok;
	}
	// deactivated, still crashing
	return kLugreMessageBoxResult_BoxNotImplemented;

	#if 0
	// second attempt, but still problems if executed twice 
	int style = wxOK;
	switch (iType) {
		case kLugreMessageBoxType_Ok			: style = wxOK; break;
		case kLugreMessageBoxType_OkCancel		: style = wxOK | wxCANCEL ; break;
		case kLugreMessageBoxType_YesNo			: style = wxYES_NO ; break;
		case kLugreMessageBoxType_YesNoCancel	: style = wxYES_NO | wxCANCEL ; break;
	}
	
	int res = 0;
	if (0) {
		// note : http://wiki.wxwidgets.org/Wx_In_Non-Wx_Applications
		// In short you should use wxInitialize and wxUninitialize with a message loop in between
		// http://wiki.wxwidgets.org/Creating_A_DLL_Of_An_Application
		// http://docs.wxwidgets.org/2.6.3/wx_wxapp.html
		/*
		class wxDLLApp : public wxApp
		{
			int res;
			std::string sTitle;
			std::string sText;
			int style;
			wxDLLApp(int style,std::string sTitle,std::string sText) : style(style),sTitle(sTitle),sText(sText),res(0) {}
			bool OnInit() {
				res = wxMessageBox(wxString::FromAscii(sText.c_str()),wxString::FromAscii(sTitle.c_str()),style);
				ExitMainLoop();
			}
		};
		*/

		wxInitialize(); // (instead of wxEntry)
		//~ wxDLLApp* wxTheApp = new wxDLLApp(style,sTitle,sText);
		
		wxWindow *mainWindow = new wxWindow();
		mainWindow->Show(FALSE);
		wxTheApp->SetTopWindow(mainWindow);
		
		res = wxMessageBox(wxString::FromAscii(sText.c_str()),wxString::FromAscii(sTitle.c_str()),style);
		
		wxTheApp->OnExit();
		//~ wxApp::CleanUp();
		wxUninitialize();
		//~ res = wxTheApp->res;
		//~ delete wxTheApp;
	} else {
		wxApp *app = new wxApp();
		//~ wxApp::SetInstance(app);
		int args = 0;
		wxEntryStart(args,(wxChar **)0);
		
		//~ wxWindow *mainWindow = new wxWindow();
		//~ mainWindow->Show(FALSE);
		//~ app->SetTopWindow(mainWindow);
		app->CallOnInit();
		
		res = wxMessageBox(wxString::FromAscii(sText.c_str()),wxString::FromAscii(sTitle.c_str()),style);
		
		wxEntryCleanup();
		//~ delete app; // segfaults ? weird, oh well, better a small memleak than a crash
		// deactivated, still crashing
	}
	
	switch (res) {
		case wxYES:		return kLugreMessageBoxResult_Yes;
		case wxNO:		return kLugreMessageBoxResult_No;
		case wxCANCEL:	return kLugreMessageBoxResult_Cancel;
		case wxOK:		return kLugreMessageBoxResult_Ok;
	}
	
	return kLugreMessageBoxResult_BoxNotImplemented;
	#endif
}