Esempio n. 1
0
ItemRecord * ArmoryImporter::importItem(std::string url) const
{
  wxInitialize();

  wxJSONValue root;
  ItemRecord * result = NULL;

  if (readJSONValues(ITEM,url,root) == 0 && root.Size() != 0)
  {
    // No Gathering Errors Detected.
    result = new ItemRecord();

    // Gather Race & Gender
    result->id = root[wxT("id")].AsInt();
    result->model = root[wxT("displayInfoId")].AsInt();
    wxString name;
    root[wxT("name")].AsString(name);
    result->name = name.mb_str();
    result->itemclass = root[wxT("itemClass")].AsInt();
    result->subclass = root[wxT("itemSubClass")].AsInt();
    result->quality = root[wxT("quality")].AsInt();
    result->type = root[wxT("inventoryType")].AsInt();
  }

  wxUninitialize();
  return result;
}
Esempio n. 2
0
int main( int argc, char* argv[] )
{
    int ret = boost::unit_test::unit_test_main( &init_unit_test, argc, argv );

    // This causes some glib warnings on GTK3 (http://trac.wxwidgets.org/ticket/18274)
    // but without it, Valgrind notices a lot of leaks from WX
    wxUninitialize();

    return ret;
}
int main(int argc, char* argv[]) {
    wxInitialize();
    wxSocketBase::Initialize();
    CppUnit::TextUi::TestRunner runner;
    CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
    runner.addTest(registry.makeTest());
    runner.run("",true);
    wxUninitialize();
    return 0;
}
Esempio n. 4
0
int main(int argc, char* const* argv)
{
	if (wxInitialize())
	{
		int rc = StateChartDrawer::doit(argc, argv);
		wxUninitialize();
		return rc;
	}
	return EXIT_FAILURE;
}
Esempio n. 5
0
int main(int argc, char* const* argv)
{
	if (wxInitialize())
	{
		CSDgenerator csd;
		int rc = csd.doit(argc, argv);
		wxUninitialize();
		return rc;
	}
	return EXIT_FAILURE;
}
Esempio n. 6
0
int main(int argc, char* const* argv)
{
	if (wxInitialize())
	{
		CppGenerator gen;
		int rc = gen.doit(argc, argv);
		wxUninitialize();
		return rc;
	}
	return EXIT_FAILURE;
}
Esempio n. 7
0
int main(int argc, char* const* argv)
{
	if (wxInitialize())
	{
		StateChartCoderCdSys Coder;
		int rc = Coder.DoIt(argc, argv);
		wxUninitialize();
		return rc;
	}
	return EXIT_FAILURE;
}
Esempio n. 8
0
int main(int , char**)
{
    unsigned long ulElapsedTime = 0;

    wxInitialize();

    wxPrintf(wxT("Task Instance Performance Measurement...\n"));
    ParserTaskInstances(ulElapsedTime);
    wxPrintf(wxT("Task Instance 100000 Records: '%d' milliseconds\n"), ulElapsedTime);

    wxUninitialize();

    return 0;
}
Esempio n. 9
0
int main(int, char*[])
{
	setlocale(LC_ALL, "");

	if (!wxInitialize())
	{
		std::cout << "Failed to initialize wxWidgets" << std::endl;
		return 1;
	}

	CppUnit::TextUi::TestRunner runner;
	CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
	runner.addTest(registry.makeTest());
	bool wasSuccessful = runner.run("", false);

	wxUninitialize();
	return wasSuccessful ? 0 : 1;
}
Esempio n. 10
0
/*--------------------------------------------------------------------------
 *  void plD_tidy_wxwidgets( PLStream *pls )
 *
 *  This function is called, if all plots are done.
 *--------------------------------------------------------------------------*/
void plD_tidy_wxwidgets( PLStream *pls )
{
  // Log_Verbose( "plD_tidy_wxwidgets()" );

  wxPLDevBase* dev = (wxPLDevBase*)pls->dev;

#ifdef HAVE_FREETYPE
  if( dev->freetype ) {
    FT_Data *FT=(FT_Data *)pls->FT;
    plscmap0n( FT->ncol0_org );
    plD_FreeType_Destroy( pls );
  }
#endif

  if( dev->ownGUI ) {
    wxPLGetApp().RemoveFrame( dev->m_frame );
		if( !wxPLGetApp().FrameCount() )
    	wxUninitialize();
  }

  delete dev;
  pls->dev=NULL;  /* since in plcore.c pls->dev is free_mem'd */
}
Esempio n. 11
0
CharInfos * ArmoryImporter::importChar(std::string url) const
{
  wxInitialize();

  CharInfos * result = new CharInfos();
  wxJSONValue root;

  int readStatus = readJSONValues(CHARACTER,url,root);

  if (readStatus == 0 && root.Size() != 0)
  {
    // No Gathering Errors Detected.
    result->equipment.resize(NUM_CHAR_SLOTS);

    // Gather Race & Gender
    result->raceId = root[wxT("race")].AsInt();
    result->gender = (root[wxT("gender")].AsInt() == 0) ? wxT("Male") : wxT("Female");

    wxJSONValue app = root[wxT("appearance")];
    result->skinColor = app[wxT("skinColor")].AsInt();
    result->faceType = app[wxT("faceVariation")].AsInt();
    result->hairColor = app[wxT("hairColor")].AsInt();
    result->hairStyle = app[wxT("hairVariation")].AsInt();
    result->facialHair = app[wxT("featureVariation")].AsInt();

    // Gather Items
    result->hasTransmogGear = false;
    wxJSONValue items = root[wxT("items")];

    if (items[wxT("back")].Size()>0)
    {
      result->equipment[CS_CAPE] = items[wxT("back")][wxT("id")].AsInt();
      if (items[wxT("back")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_CAPE] = items[wxT("back")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }
    if (items[wxT("chest")].Size()>0)
    {
      result->equipment[CS_CHEST] = items[wxT("chest")][wxT("id")].AsInt();
      if (items[wxT("chest")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_CHEST] = items[wxT("chest")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }
    if (items[wxT("feet")].Size()>0)
    {
      result->equipment[CS_BOOTS] = items[wxT("feet")][wxT("id")].AsInt();
      if (items[wxT("feet")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_BOOTS] = items[wxT("feet")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }
    if (items[wxT("hands")].Size()>0)
    {
      result->equipment[CS_GLOVES] = items[wxT("hands")][wxT("id")].AsInt();
      if (items[wxT("hands")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_GLOVES] = items[wxT("hands")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }
    if (items[wxT("head")].Size()>0)
    {
      result->equipment[CS_HEAD] = items[wxT("head")][wxT("id")].AsInt();
      if (items[wxT("head")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_HEAD] = items[wxT("head")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }
    if (items[wxT("legs")].Size()>0)
    {
      result->equipment[CS_PANTS] = items[wxT("legs")][wxT("id")].AsInt();
      if (items[wxT("legs")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_PANTS] = items[wxT("legs")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }
    if (items[wxT("mainHand")].Size()>0)
    {
      result->equipment[CS_HAND_RIGHT] = items[wxT("mainHand")][wxT("id")].AsInt();
      if (items[wxT("mainHand")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_HAND_RIGHT] = items[wxT("mainHand")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }
    if (items[wxT("offHand")].Size()>0)
    {
      result->equipment[CS_HAND_LEFT] = items[wxT("offHand")][wxT("id")].AsInt();
      if (items[wxT("offHand")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_HAND_LEFT] = items[wxT("offHand")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }
    if (items[wxT("shirt")].Size()>0)
    {
      result->equipment[CS_SHIRT] = items[wxT("shirt")][wxT("id")].AsInt();
      if (items[wxT("shirt")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_SHIRT] = items[wxT("shirt")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }
    if (items[wxT("shoulder")].Size()>0)
    {
      result->equipment[CS_SHOULDER] = items[wxT("shoulder")][wxT("id")].AsInt();
      if (items[wxT("shoulder")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_SHOULDER] = items[wxT("shoulder")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }
    if (items[wxT("tabard")].Size()>0)
    {
      result->equipment[CS_TABARD] = items[wxT("tabard")][wxT("id")].AsInt();
      if (items[wxT("tabard")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_TABARD] = items[wxT("tabard")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }
    if (items[wxT("waist")].Size()>0)
    {
      result->equipment[CS_BELT] = items[wxT("waist")][wxT("id")].AsInt();
      if (items[wxT("waist")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_BELT] = items[wxT("waist")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }
    if (items[wxT("wrist")].Size()>0)
    {
      result->equipment[CS_BRACERS] = items[wxT("wrist")][wxT("id")].AsInt();
      if (items[wxT("wrist")][wxT("tooltipParams")].HasMember(wxT("transmogItem")))
      {
        result->equipment[CS_BRACERS] = items[wxT("wrist")][wxT("tooltipParams")][wxT("transmogItem")].AsInt();
        result->hasTransmogGear = true;
      }
    }

    // Set proper eyeglow
    if (root[wxT("class")].AsInt() == 6) // 6 = DEATH KNIGHT
      result->eyeGlowType = EGT_DEATHKNIGHT;
    else
      result->eyeGlowType = EGT_DEFAULT;

    // tabard (useful if guild tabard)
    wxJSONValue guild = root[wxT("guild")];
    if(guild.Size() > 0)
    {
      wxJSONValue tabard = guild[wxT("emblem")];
      if(tabard.Size() > 0)
      {
        result->tabardIcon = tabard[wxT("icon")].AsInt();
        result->tabardBorder = tabard[wxT("border")].AsInt();
        result->BorderColor = TabardDetails::borderColorToIndex(QString(tabard[wxT("borderColor")].AsString().Lower().mb_str()));
        result->Background = TabardDetails::backgroundColorToIndex(QString(tabard[wxT("backgroundColor")].AsString().Lower().mb_str()));
        result->IconColor = TabardDetails::iconColorToIndex(QString(tabard[wxT("iconColor")].AsString().Lower().mb_str()));
        result->customTabard = true;
      }
    }
    wxUninitialize();
    result->valid = true;
  }

  return result;
}
Esempio n. 12
0
int main(int , char**)
{
    CBOINCXMLStream oBOINCXML;
    CBSLXMLDocumentEx oDocument;
    std::vector<CBSLTaskInstance*> oNewTaskInstances;
#ifndef BOINCSENTINELPARSERONLY
    std::vector<TASKINSTANCE*> oOldTaskInstances;
    wxChar* pCurrentPosition;
#endif
    wxDateTime dtStart;
    wxTimeSpan tsDuration;


    wxInitialize();

#if 0
#ifndef BOINCSENTINELPARSERONLY
    wxPrintf(wxT("Memory scan speed...\n"));
    if (oDocument.SetDocumentFromFile(wxT("get_results.xml")))
    {
        wxPrintf(wxT("    Super sizing task instance list...\n"));
        CBSLXMLTestUtil::ReplicateDocument(oDocument, REPLICATIONFACTOR);

        dtStart = wxDateTime::UNow();

        pCurrentPosition = oDocument.GetPosition();
        while (*pCurrentPosition)
        {
            ++pCurrentPosition;
        }

        tsDuration = wxDateTime::UNow() - dtStart;
        wxPrintf(wxT("    Elapsed Time: %llu milliseconds\n"), tsDuration.GetMilliseconds());
        wxPrintf(wxT("    Array Size: %d \n"), (int)(pCurrentPosition - oDocument.GetPosition()));
    }
#endif

#ifndef BOINCSENTINELPARSERONLY
    wxPrintf(wxT("XML Stream Line Scan speed...\n"));
    if (oDocument.SetDocumentFromFile(wxT("get_results.xml")))
    {
        wxPrintf(wxT("    Super sizing task instance list...\n"));
        CBSLXMLTestUtil::ReplicateDocument(oDocument, REPLICATIONFACTOR);

        dtStart = wxDateTime::UNow();

        pCurrentPosition = 0;;
        while (oDocument.GetNextElement())
        {
            ++pCurrentPosition;
        }

        tsDuration = wxDateTime::UNow() - dtStart;
        wxPrintf(wxT("    Elapsed Time: %llu milliseconds\n"), tsDuration.GetMilliseconds());
        wxPrintf(wxT("    Line Count: %d \n"), (int)pCurrentPosition);
    }
#endif
#endif

    wxPrintf(wxT("BOINC Sentinels XML parser v2 (FNV1 Static Hash Map) speed...\n"));
    if (BSLXMLERR_SUCCESS == oDocument.SetDocumentFromFile(wxT("get_results.xml")))
    {
        wxPrintf(wxT("    Super sizing task instance list...\n"));
        CBSLXMLTestUtil::ReplicateDocument(oDocument, REPLICATIONFACTOR);

        dtStart = wxDateTime::UNow();

        BOINCSentinelsParserExTaskInstances(oDocument, oNewTaskInstances);

        tsDuration = wxDateTime::UNow() - dtStart;
        wxPrintf(wxT("    Elapsed Time: %llu milliseconds\n"), tsDuration.GetMilliseconds());
        wxPrintf(wxT("    Result Count: %d \n"), (int)oNewTaskInstances.size());

        for (size_t i = 0; i < oNewTaskInstances.size(); ++i)
        {
            delete oNewTaskInstances[i];
        }
        oNewTaskInstances.clear();
    }


#ifndef BOINCSENTINELPARSERONLY
    wxPrintf(wxT("BOINC XML parser v1 speed...\n"));
    if (oBOINCXML.StreamFromFile(wxT("get_results.xml")))
    {
        wxPrintf(wxT("    Super sizing task instance list...\n"));
        CBSLXMLTestUtil::ReplicateDocument(oDocument, REPLICATIONFACTOR);

        dtStart = wxDateTime::UNow();

        BOINCV1ParserTaskInstances(oBOINCXML, oOldTaskInstances);

        tsDuration = wxDateTime::UNow() - dtStart;
        wxPrintf(wxT("    Elapsed Time: %llu milliseconds\n"), tsDuration.GetMilliseconds());
        wxPrintf(wxT("    Result Count: %d \n"), (int)oOldTaskInstances.size());
        for (size_t i = 0; i < oOldTaskInstances.size(); ++i)
        {
            delete oOldTaskInstances[i];
        }
        oOldTaskInstances.clear();
    }
#endif


#ifndef BOINCSENTINELPARSERONLY
    wxPrintf(wxT("BOINC XML parser v2 (XML_PARSER) speed...\n"));
    if (oBOINCXML.StreamFromFile(wxT("get_results.xml")))
    {
        wxPrintf(wxT("    Super sizing task instance list...\n"));
        CBSLXMLTestUtil::ReplicateDocument(oDocument, REPLICATIONFACTOR);

        dtStart = wxDateTime::UNow();

        BOINCV2ParserTaskInstances(oBOINCXML, oOldTaskInstances);

        tsDuration = wxDateTime::UNow() - dtStart;
        wxPrintf(wxT("    Elapsed Time: %llu milliseconds\n"), tsDuration.GetMilliseconds());
        wxPrintf(wxT("    Result Count: %d \n"), (int)oOldTaskInstances.size());
        for (size_t i = 0; i < oOldTaskInstances.size(); ++i)
        {
            delete oOldTaskInstances[i];
        }
        oOldTaskInstances.clear();
    }
#endif


    wxUninitialize();


    return EXIT_SUCCESS;
}
Esempio n. 13
0
File: wx.hpp Progetto: rsenn/libborg
//---------------------------------------------------------------------------
inline static
void terminate()
{
  wxUninitialize();
}
Esempio n. 14
0
int main(int argc, char *argv[])
{
  // Initialization of wxWindows library
  if( !wxInitialize() ) {
    puts("Failed to initialize the wxWidgets library.");
    return -1;
  }

  // message_logger is an auxiliary object defined in file logexc.h
  // it is used for the error handling
  message_logger::global().set_throw(true);  // run-time errors will generate exceptions

  try{
    int res;

    // Error handling class message_logger contains definitions
    // of errors, warnings and messages. Errors (vblOERR level) occur in
    // the case of incorrect input parameters of library functions,
    // incorrect function call sequence, impossibility to access the
    // remote system. Warnings (vblWARN level) occur due to the failure of
    // file copying, remote command execution, job duplication.
    //
    // The following command enables output of all messages (vblALL)
    // and sets program interruption on errors and warnings (vblALLBAD)
    message_logger::global().set_levels(vblALL,vblALLBAD);

    // Initialization of the shell
    gmShellUnix shell;

    // Creation of the persistent remote directory
    // (needed for the first run only)
    puts("Copying permanent files to the remote system ...");
    shell.MkDir("tmp/remote_dir");

    // Copying of the persistent files
    shell.StageIn("../input/permfile.txt", "tmp/remote_dir");
    // For text files the full remote file name should be specified ("tmp/remote_dir/prog.sh")!
    shell.StageIn("text:../input/prog.sh", "tmp/remote_dir/prog.sh");

    // Attribute for execution of the script prog.sh
    shell.Execute("chmod u+x tmp/remote_dir/prog.sh");

    // The following command enables output of all messages (vblALL)
    // and sets program interruption only on errors (vblERR)
    message_logger::global().set_levels(vblALL,vblERR);

    // Initialization of the job manager
    gmPBSManager mngr(shell);  // use the second argument to select the PBS queue
    mngr.SetParam("/usr/local/bin", "GMD"); // "GMD" is the prefix for the PBS jobs

    // Initialization of the job
    gmJob* job = mngr.CreateJob();
    job->command = "$HOME/tmp/remote_dir/prog.sh 1 2"; // execution command path and arguments
    // Input files and directories
    job->AddInFile("../input/infile1.txt", "", gmJob::TEXT);
    job->AddInFile("../input/infile2.txt", "", gmJob::TEXT);
    job->AddInFile("../input/indir", "");
    job->AddInFile("tmp/remote_dir/permfile.txt", "", gmJob::REMOTE); // этот файл будет взят из каталога на удаленной системе

    printf("State before submission: %s\n", gmJob::StateName(job->GetState()));

    // Job submission
    res = job->Submit("test");
    wxString id = job->GetID();
    printf("State after submission: %s, id = %s\n", gmJob::StateName(res), id.c_str());

    wxSleep(2);  // Usually after 2 seconds the jobs is started

    // Copying of an intermediate result (a file from the working directory)
    res = job->StageOut("../example1-out-inter", "outfile.txt", gmJob::TEXT | gmJob::CREATEPATH);
    printf("File uploaded with the exit code: %d\n", res);

    // Detaching from the job manager. After Detach the remote job is still
    // running while the job object is deleted.
    job->Detach();

    // Restoring the job object (attaching to the working remote job)
    // using the saved id
    job = mngr.Restore(id);
    res = job->LastState();  // LastState returns here the status obtained by Restore
                             // without extra remote system calls
    printf("State after Attach: %s\n", gmJob::StateName(res));

    if(res && res != JOB_FAILED) {
      // Output files and directories
      job->AddOutFile("../example1-out-final", "outfile.txt", gmJob::TEXT | gmJob::CREATEPATH);
      job->AddOutFile("../example1-out-final", "outdir");
      job->AddOutFile("tmp/remote_dir", "permfile.txt", gmJob::REMOTE); // этот файл будет скопирован в каталог на удаленной системе
      // Files to store stdout and stderr
      job->AddOutFile("../example1-out-final/out", "STDOUT");
      job->AddOutFile("../example1-out-final/err", "STDERR");

      // Waiting for the job completion and fetching the results
      //mngr.wait_timeout = 15000;  // uncommend this to set a timeout
      res = job->FetchResult();  // use the secong arg to prevent waiting
      printf("State after FetchResult: %s\n", gmJob::StateName(res));
    }

    // Removing the temporary directory on the remote source and the job object
    job->Clear();
  }
  catch(gmJobException &e){ (void)e; }

  wxUninitialize();

  return 0;
}
Esempio n. 15
0
int main(int argv, char* argc[])
{
	bool good = wxInitialize();
	if(!good)
	{
		printf("wx could not be initialized, aborting.\n");
		exit(-1);
	}
	else
	{
		printf("wx initialized succesfully!\n");
		wxFFileOutputStream MYoutput( stderr );
		wxTextOutputStream MYcout( MYoutput );		
		wxString string = wxT(" a test yo ");
		MYcout << wxT("Before: '") << string << wxT("'\n");
		string = string.Trim(true);
		MYcout << wxT("AfterT: '") << string << wxT("'\n");
		string = string.Trim(false);
		MYcout << wxT("AfterF: '") << string << wxT("'\n");
	}
#if 1
	if(argv>1)
	{
		initLexer(argc[1]);
	}
	else
	{
		initLexer("input");
	}

	yyparse();

	printf("============= RESULT =============\n");
	for(int i = 0; i < TheOutput.size(); i++)
	{
		printf("%s\n", TheOutput[i].c_str());
	}

	printf("============ UNMATCHED ===========\n");
	for(int i = 0; i < TheUnmatched.size(); i++)
	{
		printf("%s\n", TheUnmatched[i].c_str());
	}

	printf("============== ERROR =============\n");
	for(int i = 0; i < TheError.size(); i++)
	{
		printf("%s\n", TheError[i].c_str());
	}

	printf("============= TOKENS =============\n");
        for(Itokens it = TheTokens.begin(); it != TheTokens.end(); it++)
        {
         	printf("'%s'='%s'\n", it->first.c_str(), it->second.c_str());
        }

	printf("=============== DONE =============\n");
	wxUninitialize();
	return 0;
#endif
}
Esempio n. 16
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
}
Esempio n. 17
0
void f0r_deinit()
{
#ifdef USEWX
wxUninitialize();
#endif
}