Ejemplo n.º 1
0
// Init wx-widgets thread 
bool WxeApp::OnInit()
{
  /* Create a dummy window so wxWidgets don't automagicly quits the main loop 
     after the last window */
  global_me = new wxeMemEnv();
  wxe_batch = new wxList;
  wxe_batch_cb_saved = new wxList;

  create_dummy_window();
  wxe_ps_init();

  wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED);

  this->Connect(wxID_ANY, wxEVT_IDLE, 
		(wxObjectEventFunction) (wxEventFunction) &WxeApp::idle);
  this->Connect(CREATE_PORT, wxeEVT_META_COMMAND, 
		(wxObjectEventFunction) (wxEventFunction) &WxeApp::newMemEnv);
  this->Connect(DELETE_PORT, wxeEVT_META_COMMAND, 
		(wxObjectEventFunction) (wxEventFunction) &WxeApp::destroyMemEnv);
  this->Connect(WXE_SHUTDOWN, wxeEVT_META_COMMAND, 
		(wxObjectEventFunction) (wxEventFunction) &WxeApp::shutdown);

//   fprintf(stderr, "Size void* %d: long %d long long %d int64 %d \r\n",
// 	  sizeof(void *), sizeof(long), sizeof(long long), sizeof(wxInt64));
  initEventTable();
  wxInitAllImageHandlers();
  init_nonconsts(global_me, init_caller);
  erl_drv_mutex_lock(wxe_status_m);
  wxe_status = WXE_INITIATED;
  gl_initiated = FALSE;   
  erl_drv_cond_signal(wxe_status_c);
  erl_drv_mutex_unlock(wxe_status_m);
  return TRUE;
}
Ejemplo n.º 2
0
void *wxe_main_loop(void *vpdl)
{
    int result;
    int  argc = 1;
    char * temp = (char *) "Erlang";
    char * argv[] = {temp,NULL};
    ErlDrvPDL pdl = (ErlDrvPDL) vpdl;

    driver_pdl_inc_refc(pdl);

    // Disable floating point execption if they are on.
    // This should be done in emulator but it's not in yet.
#ifndef _WIN32
    erts_thread_disable_fpe();
#else
    // Setup that wxWidgets should look for cursors and icons in
    // this dll and not in werl.exe (which is the default)
    HMODULE WXEHandle = GetModuleHandle(_T("wxe_driver"));
    wxSetInstance((HINSTANCE) WXEHandle);
#endif

    wxe_ps_init();
    result = wxEntry(argc, argv);
    // fprintf(stderr, "WXWidgets quits main loop %d \r\n", result);
    if(result >= 0 && wxe_status == WXE_INITIATED) {
        /* We are done try to make a clean exit */
        wxe_status = WXE_EXITED;
        driver_pdl_dec_refc(pdl);
#ifndef __DARWIN__
        erl_drv_thread_exit(NULL);
#endif
        return NULL;
    } else {
        erl_drv_mutex_lock(wxe_status_m);
        wxe_status = WXE_ERROR;
        erl_drv_cond_signal(wxe_status_c);
        erl_drv_mutex_unlock(wxe_status_m);
        driver_pdl_dec_refc(pdl);
        return NULL;
    }
}