Пример #1
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
}
Пример #2
0
bool wxInitialize()
{
    return wxInitialize(0, (wxChar**)NULL);
}
Пример #3
0
bool init_unit_test()
{
    boost::unit_test::framework::master_test_suite().p_name.value = "Common Pcbnew module tests";
    return wxInitialize();
}
Пример #4
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
}
Пример #5
0
void main(int argc, char **argv)
{
	// Statup wx
	wxInitialize();

	wxFileName file = wxString::FromAscii(*argv++);
	file.MakeAbsolute();
	wxString executable = file.GetFullPath();

	if (argc < 3)
	{
		usage(executable);
		return;
	}

	wxString command;
	command = wxString::FromAscii(*argv++);

	if (command != wxT("DEBUG"))
	{
		serviceName = wxString::FromAscii(*argv++);
		argc -= 3;
	}
	else
		argc -= 2;

	if (command == wxT("INSTALL"))
	{
		wxString displayname = _("PostgreSQL Scheduling Agent - ") + serviceName;
		wxString args = wxT("RUN ") + serviceName;

		while (argc-- > 0)
		{
			if (argv[0][0] == '-')
			{
				switch (argv[0][1])
				{
					case 'u':
					{
						user = getArg(argc, argv);
						break;
					}
					case 'p':
					{
						password = getArg(argc, argv);
						break;
					}
					case 'd':
					{
						displayname = getArg(argc, argv);
						break;
					}
					default:
					{
						args += wxT(" ") + wxString::FromAscii(*argv);
						break;
					}
				}
			}
			else
			{
				args += wxT(" ") + wxString::FromAscii(*argv);
			}

			argv++;
		}

		bool rc = installService(serviceName, executable, args, displayname, user, password);
	}
	else if (command == wxT("REMOVE"))
	{
		bool rc = removeService(serviceName);
	}
	else if (command == wxT("DEBUG"))
	{
		setupForRun(argc, argv, true, executable);

		initService();
#if START_SUSPENDED
		continueService();
#endif

		WaitForSingleObject(threadHandle, INFINITE);
	}
	else if (command == wxT("RUN"))
	{
		wxString app = _("pgAgent Service");

		SERVICE_TABLE_ENTRY serviceTable[] =
		{ (LPWSTR)app.wc_str(), serviceMain, 0, 0};

		setupForRun(argc, argv, false, executable);

		if (!StartServiceCtrlDispatcher(serviceTable))
		{
			DWORD rc = GetLastError();
			if (rc)
			{
			}
		}
	}
	else
	{
		usage(executable);
	}

	return;
}
Пример #6
0
//----------------------------------------------------------------------------
inline static
void initialize()
{
  wxInitialize();
}
Пример #7
0
bool init_unit_test()
{
    boost::unit_test::framework::master_test_suite().p_name.value = "S-expression module tests";
    return wxInitialize();
}
Пример #8
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;
}