예제 #1
0
// return true if the 2 strings refer to the same accel
//
// as accels can be either translated or not, check for both possibilities and
// also compare case-insensitively as the key names case doesn't count
static inline bool CompareAccelString(const wxString& str, const char *accel)
{
    return str.CmpNoCase(accel) == 0
#if wxUSE_INTL
            || str.CmpNoCase(wxGetTranslation(accel)) == 0
#endif
            ;
}
예제 #2
0
파일: nsismenu.cpp 프로젝트: gavioto/nsis
SPECIALURLTYPE GetSpecialUrlType(const wxString&Url)
{
  const wxString l4 = Url.Left(4);
  if (0 == l4.CmpNoCase(wxT("BIN:"))) return SUT_BIN;
  if (0 == l4.CmpNoCase(wxT("DOC:"))) return SUT_DOC;
  if (0 == l4.CmpNoCase(wxT("WEB:"))) return SUT_WEB;
  return SUT_UNKNOWN;
}
예제 #3
0
// Getter
bool Model_Infotable::GetBoolInfo(const wxString& key, bool default_value)
{
    const wxString value = this->GetStringInfo(key, "");
    if (value == "1" || value.CmpNoCase("TRUE") == 0)
        return true;
    else if (value == "0" || value.CmpNoCase("FALSE") == 0)
        return false;
    else
        return default_value;
}
예제 #4
0
파일: Ini.cpp 프로젝트: Ailick/rpcs3
static bool StringToBool(const wxString str)
{
	if(
		!str.CmpNoCase("enable") ||
		!str.CmpNoCase("e") ||
		!str.CmpNoCase("1") ||
		!str.CmpNoCase("true") ||
		!str.CmpNoCase("t") )
	{
		return true;
	}

	return false;
}
예제 #5
0
파일: DiffPanel.cpp 프로젝트: sapient/e
bool DiffPanel::CmpPaths(const wxString& path1, const wxString& path2) const {
#ifdef __WXMSW__
	// paths on windows are case-insensitive
	if (path1.CmpNoCase(m_leftEditor->GetPath()) == 0 &&
		path2.CmpNoCase(m_rightEditor->GetPath()) == 0) return true;
	if (path2.CmpNoCase(m_leftEditor->GetPath()) == 0 &&
		path1.CmpNoCase(m_rightEditor->GetPath()) == 0) return true;
#else
	if (path1 == m_leftEditor->GetPath() &&
		path2 == m_rightEditor->GetPath()) return true;
	if (path2 == m_leftEditor->GetPath() &&
		path1 == m_rightEditor->GetPath()) return true;
#endif

	return false;
}
예제 #6
0
//==========================================================================
// Class:			XMLConversionFactors
// Function:		GetNodeAfterAlphabetically
//
// Description:		Finds the node following the node to be added in order to
//					maintain alphabetical entry of nodes.
//
// Input Arguments:
//		name			= const wxString&
//		parent			= wxXmlNode*
//
// Output Arguments:
//		nodeAfterChild	= wxXmlNode*&
//
// Return Value:
//		bool, true if a following node was found OR the child will be the first
//		child for the parent (in the case of this node being the first child,
//		nodeAfterChild will be NULL), false if no following node was found
//		(indicating that the new node should be appended to the end of the
//		parent's children)
//
//==========================================================================
bool XMLConversionFactors::GetNodeAfterAlphabetically(const wxString &name,
	wxXmlNode *parent, wxXmlNode *&nodeAfterChild) const
{
	bool hasChildren = false;
	wxXmlNode *child = parent->GetChildren();
	while (child)
	{
		hasChildren = true;

		if (name.CmpNoCase(child->GetAttribute(nameAttr, wxEmptyString)) < 0)
		{
			nodeAfterChild = child;
			return true;
		}

		child = child->GetNext();
	}

	if (!hasChildren)
	{
		nodeAfterChild = NULL;
		return true;
	}

	return false;
}
예제 #7
0
int CComparisonManager::CompareFiles(const int dirSortMode, const wxString& local, const wxString& remote, bool localDir, bool remoteDir)
{
	switch (dirSortMode)
	{
	default:
		if (localDir)
		{
			if (!remoteDir)
				return -1;
		}
		else if (remoteDir)
			return 1;
		break;
	case 2:
		// Inline
		break;
	}

#ifdef __WXMSW__
	return local.CmpNoCase(remote);
#else
	return local.Cmp(remote);
#endif

	return 0;
}
예제 #8
0
int FindChannelAt(int x, int y, const wxString& model)
{
//get list of models:
    wxString buf;
    for (auto it = xLightsFrame::PreviewModels.begin(); it != xLightsFrame::PreviewModels.end(); ++it)
    {
        if (!model.IsEmpty() && model.CmpNoCase((*it)->name)) continue; //don't check this model
//        debug(1, "checking model '%s' ...", (const char*)(*it)->name.c_str());
//        buf = xLightsFrame::PreviewModels[0]->ChannelLayoutHtml();
//        if (buf.size() > 500) buf.resize(500);
//        debug(1, "first 500 char of layout html = %s", (const char*)buf);
//        wxString buf = (*it)->ChannelLayoutHtml();

//        for (size_t n = (*it)->GetNodeCount(); n > 0; --n)
//        {
//            Nodes[nodenum]->Coords.size()
//        }
//        size_t CoordCount=GetCoordCount(n);
//        for(size_t c=0; c < CoordCount; c++)
//        {
//            Nodes[n]->Coords[c].screenX = Nodes[n]->Coords[c].bufX - xoffset;
//            Nodes[n]->Coords[c].screenY = Nodes[n]->Coords[c].bufY;
//        }
        int ch = (*it)->FindChannelAt(x, y);
        if (ch != -1) return ch;
    }
    return -1; //pixel not found
}
void  t4p::RunBrowserFeatureClass::ExternalBrowser(const wxString& browserName, const wxURI& url) {
    wxFileName webBrowserPath;
    bool found = App.PhpModule.Environment.FindBrowserByName(browserName, webBrowserPath);
    if (!found || !webBrowserPath.IsOk()) {
        t4p::EditorLogWarning(t4p::ERR_BAD_WEB_BROWSER_EXECUTABLE, webBrowserPath.GetFullPath());
        return;
    }
    wxString cmd = wxT("\"") + webBrowserPath.GetFullPath() + wxT("\"");

    wxPlatformInfo info;
    if (info.GetOperatingSystemId() == wxOS_MAC_OSX_DARWIN && browserName.CmpNoCase(wxT("Safari")) == 0) {
        // safari on Mac does not handle command line URL arguments
        // need to use the "open" program
        // see http://superuser.com/questions/459268/run-safari-from-command-line-with-url-parameter
        cmd = wxT("open -a safari ");
    }
    cmd += wxT(" \"");
    cmd += url.BuildURI();
    cmd += wxT("\"");

    // dont track this PID, let the browser stay open if the editor is closed.
    // if we dont do pass the make group leader flag the browser thinks it crashed and will tell the user
    // that the browser crashed.
    long pid = wxExecute(cmd, wxEXEC_ASYNC | wxEXEC_MAKE_GROUP_LEADER);
    if (pid <= 0) {
        t4p::EditorLogWarning(t4p::ERR_BAD_WEB_BROWSER_EXECUTABLE, cmd);
    }
}
예제 #10
0
bool Identifier::equals(const wxString& rhs) const
{
    if (needsQuoting(textM))
        return (0 == rhs.Cmp(textM));
    else
        return (0 == rhs.CmpNoCase(textM));
}
예제 #11
0
파일: odcombo.cpp 프로젝트: beanhome/dev
int wxVListBoxComboPopup::Append(const wxString& item)
{
    int pos = (int)m_strings.GetCount();

    if ( m_combo->GetWindowStyle() & wxCB_SORT )
    {
        // Find position
        // TODO: Could be optimized with binary search
        wxArrayString strings = m_strings;
        unsigned int i;

        for ( i=0; i<strings.GetCount(); i++ )
        {
            if ( item.CmpNoCase(strings.Item(i)) <= 0 )
            {
                pos = (int)i;
                break;
            }
        }
    }

    Insert(item,pos);

    return pos;
}
예제 #12
0
static bool sortfunc(const wxString& a, const wxString& b)
{
#ifdef __WXMSW__
	return b.CmpNoCase(a) > 0;
#else
	return b.Cmp(a) > 0;
#endif
}
예제 #13
0
int FbCompare(const wxString& text1, const wxString& text2)
{
#ifdef wxHAVE_TCHAR_SUPPORT
	return wxStrcoll(text1, text2);
#else
	return text1.CmpNoCase(text2);
#endif
}
예제 #14
0
bool CUpdater::VerifyChecksum( wxString const& file, wxULongLong size, wxString const& checksum )
{
	if( file.empty() || checksum.empty() ) {
		return false;
	}

	wxLongLong filesize = CLocalFileSystem::GetSize(file);
	if( filesize < 0 || static_cast<unsigned long long>(filesize.GetValue()) != size ) {
		return false;
	}

	SHA512_State state;
	SHA512_Init(&state);

	{
		wxLogNull null;
		wxFile f;
		if (!f.Open(file)) {
			return false;
		}
		char buffer[65536];
		ssize_t read;
		while ((read = f.Read(buffer, sizeof(buffer))) > 0) {
			SHA512_Bytes(&state, buffer, read);
		}
		if (read < 0) {
			return false;
		}
	}

	unsigned char raw_digest[64];
	SHA512_Final(&state, raw_digest);

	wxString digest;
	for( unsigned int i = 0; i < sizeof(raw_digest); i++ ) {
		unsigned char l = raw_digest[i] >> 4;
		unsigned char r = raw_digest[i] & 0x0F;

		if (l > 9)
			digest += 'a' + l - 10;
		else
			digest += '0' + l;

		if (r > 9)
			digest += 'a' + r - 10;
		else
			digest += '0' + r;
	}

	if (checksum.CmpNoCase(digest)) {
		log_ += wxString::Format(_("Checksum mismatch on file %s\n"), file.c_str());
		return false;
	}

	log_ += wxString::Format(_("Checksum match on file %s\n"), file.c_str());
	return true;
}
int NoGuiSinglePlayerBattle::GetSideIndex( const wxString& name )
{
    wxArrayString sides = usync().GetSides( m_host_mod.name );
    for ( int i = 0; i < (int)sides.Count(); ++i ) {
        if ( name.CmpNoCase( sides[i] ) == 0 )
            return i;
    }
    return -1;
}
예제 #16
0
static bool sortfunc(const wxString& a, const wxString& b)
{
	int cmp = a.CmpNoCase(b);

	if (!cmp)
		cmp = a.Cmp(b);

	return cmp < 0;
}
예제 #17
0
/**
 * Compare two VALUE fields.
 * A value field can reasonably be expected to be one of:
 * a) Purely numerical e.g. '22'
 * b) Numerical with included units e.g. '15uF'
 * c) Numerical with included prefix but no units e.g. '20n'
 * d) Numerical with prefix inside number e.g. '4K7'
 * e) Other, e.g. 'MAX232'
 *
 * Cases a) to d) should be detected and converted to a common representation
 * Values that do not match this pattern should revert to standard string comparison
 */
int BOM_TABLE_GROUP::SortValues( const wxString& aFirst, const wxString& aSecond )
{
    //TODO - Intelligent comparison of component values
    // e.g. 4K > 499
    // e.g. 1nF < 0.1u

    // For now, just return default comparison

    return aFirst.CmpNoCase( aSecond );
}
예제 #18
0
bool CImportDialog::HasEntryWithName(TiXmlElement* pElement, const wxString& name)
{
	TiXmlElement* pChild;
	for (pChild = pElement->FirstChildElement("Server"); pChild; pChild = pChild->NextSiblingElement("Server")) {
		wxString childName = GetTextElement(pChild);
		childName.Trim(true);
		childName.Trim(false);
		if (!name.CmpNoCase(childName))
			return true;
	}
	for (pChild = pElement->FirstChildElement("Folder"); pChild; pChild = pChild->NextSiblingElement("Folder")) {
		wxString childName = GetTextElement(pChild);
		childName.Trim(true);
		childName.Trim(false);
		if (!name.CmpNoCase(childName))
			return true;
	}

	return false;
}
예제 #19
0
int IniParser::FindGroupByName(const wxString& name, bool caseSensitive) const
{
    for (int i = 0; i < GetGroupsCount(); ++i)
    {
        bool found = caseSensitive
                    ? name.Cmp(m_Array[i].name) == 0
                    : name.CmpNoCase(m_Array[i].name) == 0;
        if (found)
            return i;
    }
    return -1;
}
예제 #20
0
int Tags::GetGenre(const wxString & name)
{
   int cnt = WXSIZEOF(DefaultGenres);

   for (int i = 0; i < cnt; i++) {
      if (name.CmpNoCase(DefaultGenres[i])) {
         return i;
      }
   }

   return 255;
}
예제 #21
0
bool CBookmarksDialog::AddBookmark(const wxString &name, const wxString &local_dir, const CServerPath &remote_dir, bool sync)
{
	if (local_dir.empty() && remote_dir.empty())
		return false;
	if ((local_dir.empty() || remote_dir.empty()) && sync)
		return false;

	CInterProcessMutex mutex(MUTEX_GLOBALBOOKMARKS);

	CXmlFile file(wxGetApp().GetSettingsFile(_T("bookmarks")));
	TiXmlElement* pDocument = file.Load();
	if (!pDocument) {
		wxString msg = file.GetError() + _T("\n\n") + _("The bookmark could not be added.");
		wxMessageBoxEx(msg, _("Error loading xml file"), wxICON_ERROR);

		return false;
	}

	TiXmlElement *pInsertBefore = 0;
	TiXmlElement *pBookmark;
	for (pBookmark = pDocument->FirstChildElement("Bookmark"); pBookmark; pBookmark = pBookmark->NextSiblingElement("Bookmark")) {
		wxString remote_dir_raw;

		wxString old_name = GetTextElement(pBookmark, "Name");

		if (!name.CmpNoCase(old_name)) {
			wxMessageBoxEx(_("Name of bookmark already exists."), _("New bookmark"), wxICON_EXCLAMATION);
			return false;
		}
		if (name < old_name && !pInsertBefore)
			pInsertBefore = pBookmark;
	}

	if (pInsertBefore)
		pBookmark = pDocument->InsertBeforeChild(pInsertBefore, TiXmlElement("Bookmark"))->ToElement();
	else
		pBookmark = pDocument->LinkEndChild(new TiXmlElement("Bookmark"))->ToElement();
	AddTextElement(pBookmark, "Name", name);
	if (!local_dir.empty())
		AddTextElement(pBookmark, "LocalDir", local_dir);
	if (!remote_dir.empty())
		AddTextElement(pBookmark, "RemoteDir", remote_dir.GetSafePath());
	if (sync)
		AddTextElementRaw(pBookmark, "SyncBrowsing", "1");

	if (!file.Save(false)) {
		wxString msg = wxString::Format(_("Could not write \"%s\", the bookmark could not be added: %s"), file.GetFileName(), file.GetError());
		wxMessageBoxEx(msg, _("Error writing xml file"), wxICON_ERROR);
		return false;
	}

	return true;
}
예제 #22
0
int optionIndexInArray(const wxString * arr, size_t arr_len, const wxString &option)
{
    size_t i;
    for (i=0; i < arr_len; i++)
    {
        if (option.CmpNoCase(arr[i]) == 0)
        {
            return i;
        }
    }
    return -1;
}
예제 #23
0
void MyFrame::SetUrlBarValue(const wxString& str)
{
    // don't show 'about::blank'
    if (str.CmpNoCase(wxT("about:blank")) == 0)
        return;

    // set the value
    m_urlbar->SetValue(str);
    
    // save the value in the combo list values
    m_urlbar->AppendString(str);
}
예제 #24
0
int FbCyrillicCollation::Compare(const wxString& text1, const wxString& text2)
{
	icu::Collator * collator = (icu::Collator*) m_collator;
	if (collator) {
		UErrorCode status = U_ZERO_ERROR;
		wxCharBuffer buf1 = text1.mb_str();
		wxCharBuffer buf2 = text2.mb_str();
		return collator->compareUTF8(buf1.data(), buf2.data(), status);
	} else {
		return text1.CmpNoCase(text2);
	}
}
예제 #25
0
EDA_COLOR_T ColorByName( const wxString& aName )
{
    // look for a match in the palette itself
    for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
    {
        if( 0 == aName.CmpNoCase( ColorGetName( trying ) ) )
            return trying;
    }

    // Not found, no idea...
    return UNSPECIFIED_COLOR;
}
예제 #26
0
int szHelpController::GetId(const wxString& section)
{
	map_id *tmp=m_begin_id;
	while (tmp!=NULL)
	{ 
		if(section.CmpNoCase(tmp->section) == 0)
		{
			return tmp->id;
		}
		tmp=tmp->next;
	}
	return 1;
}
예제 #27
0
void CBookmarksDialog::OnCopy(wxCommandEvent& event)
{
	wxTreeItemId item = m_pTree->GetSelection();
	if (!item.IsOk())
		return;

	if (!Verify())
		return;

	CBookmarkItemData* data = reinterpret_cast<CBookmarkItemData *>(m_pTree->GetItemData(item));
	if (!data)
		return;

	UpdateBookmark();

	wxTreeItemId parent = m_pTree->GetItemParent(item);

	const wxString name = m_pTree->GetItemText(item);
	wxString newName = wxString::Format(_("Copy of %s"), name);
	int index = 2;
	for (;;)
	{
		wxTreeItemId child;
		wxTreeItemIdValue cookie;
		child = m_pTree->GetFirstChild(parent, cookie);
		bool found = false;
		while (child.IsOk())
		{
			wxString name = m_pTree->GetItemText(child);
			int cmp = name.CmpNoCase(newName);
			if (!cmp)
			{
				found = true;
				break;
			}

			child = m_pTree->GetNextChild(parent, cookie);
		}
		if (!found)
			break;

		newName = wxString::Format(_("Copy (%d) of %s"), index++, name);
	}

	CBookmarkItemData* newData = new CBookmarkItemData(*data);
	wxTreeItemId newItem = m_pTree->AppendItem(parent, newName, 1, 1, newData);

	m_pTree->SortChildren(parent);
	m_pTree->SelectItem(newItem);
	m_pTree->EditLabel(newItem);
}
예제 #28
0
//load start/stop times fort sprites:
//cues can overlap
void PianoRenderCache::Piano_load_cues(const wxString& filename)
{
    debug_function(10);
    debug(1, "load file %s", (const char*)filename.c_str());
    wxTextFile f;
    
    if (!CachedCueFilename.CmpNoCase(filename)) { debug_more(2, ", no change"); return; } //no change
    if (!wxFileExists(filename)) return;
    if (!f.Open(filename.c_str())) return;
    Piano_flush_cues(); //invalidate cached data
    debug(3, "read file");
    for (wxString linebuf = f.GetFirstLine(); !f.Eof(); linebuf = f.GetNextLine())
    {
        std::string::size_type ofs;
        if ((ofs = linebuf.find("#")) != std::string::npos) linebuf.erase(ofs); //remove comments
        while (!linebuf.empty() && (linebuf.Last() == '\\')) //line continuation
        {
            linebuf.RemoveLast(); //remove trailing "\"
            /*std::*/wxString morebuf = f.GetNextLine();
            if (f.Eof()) break;
            linebuf += morebuf;
        }
        while (!linebuf.empty() && isspace(linebuf.Last())) linebuf.RemoveLast(); //trim trailing spaces
        if (linebuf.empty()) continue; //skip blank lines
        
        //start-time    end-time    shape-name
        debug(20, "got line '%s'", (const char*)linebuf.c_str());
        //        linebuf += "\teol"; //end-of-line check for missing params
        wxStringTokenizer tkz(linebuf, "\t");
        Cue cue;
        cue.start_frame = Cue::Time2Frame(tkz.GetNextToken(), -1); //first column = start time (round down)
        cue.stop_frame = Cue::Time2Frame(tkz.GetNextToken(), +1); //second column = stop time (round up)
        //        wxString junk = tkz.GetNextToken();
        //        if (/* !junk.empty()*/ junk.Cmp("eol")) { debug.Append(": junk at end '%s'", (const char*)junk.c_str()).Flush(true); continue; } //TODO: show error messages?
        debug_more(10, " => start %d, stop %d, ok? %d", cue.start_frame, cue.stop_frame, cue.stop_frame >= cue.start_frame);
        if (cue.stop_frame < cue.start_frame) continue; //ignore null cues
        for (;;) //use remaining tokens as sprite names
        {
            wxString name = tkz.GetNextToken();
            if (name.empty()) break;
            if (name.find(".") == -1) name += ".000"; //kludge: change name to match Audacity Polyphonic nodes
            //            debug.Append("add cue for sprite '%s'? %d", /*(const char*)name.c_str()*/ (const char*)name.ToStdString().c_str(), AllSprites.find(name.ToStdString()) != AllSprites.end()).Flush(true);
            if (AllSprites.find(name.ToStdString()) == AllSprites.end()) continue; //ignore missing sprites
            cue.sprite = &AllSprites[name.ToStdString()];
            CuesByStart.push_back(cue);
        }
    }
    /*std::*/sort(CuesByStart.begin(), CuesByStart.end(), Cue::SortByStart);
    debug(3, "%d cues loaded, first '%s' starts/ends %d/%d, last '%s' starts/ends %d/%d", CuesByStart.size(), CuesByStart.size()? CuesByStart.front().sprite->name.ToStdString().c_str(): "", CuesByStart.size()? CuesByStart.front().start_frame: -1, CuesByStart.size()? CuesByStart.front().stop_frame: -1, CuesByStart.size()? CuesByStart.back().sprite->name.ToStdString().c_str(): "", CuesByStart.size()? CuesByStart.back().start_frame: -1, CuesByStart.size()? CuesByStart.back().stop_frame: -1);
    CachedCueFilename = filename; //don't load same file again
}
예제 #29
0
파일: i18n.cpp 프로젝트: tsiru/pcsx2
// warning: wxWidgets uses duplicated canonical codes for many languages, and has some bizarre
// matching heuristics.  Using this function doesn't really match the language and sublanguage
// (dialect) that the user selected.
bool i18n_SetLanguage( const wxString& langCode )
{
	if (langCode.IsEmpty() || langCode.CmpNoCase(L"default"))
	{
		wxLanguage sysLang = (wxLanguage)wxLocale::GetSystemLanguage();

		if (sysLang == wxLANGUAGE_UNKNOWN)
			sysLang = wxLANGUAGE_ENGLISH;
	}

	const wxLanguageInfo* woot = wxLocale::FindLanguageInfo( langCode );
	if (!woot) return false;
	return i18n_SetLanguage( woot->Language );
}
예제 #30
0
int IniParser::FindKeyByName(int groupIdx, const wxString& name, bool caseSensitive) const
{
    if (groupIdx == -1)
        return -1;
    for (int i = 0; i < GetKeysCount(groupIdx); ++i)
    {
        bool found = caseSensitive
                    ? name.Cmp(m_Array[groupIdx].pairs[i].key) == 0
                    : name.CmpNoCase(m_Array[groupIdx].pairs[i].key) == 0;
        if (found)
            return i;
    }
    return -1;
}