Example #1
0
wxString modeltest::checkBlock(wxString block)
{
	int lsetPos, semiPos;
	wxString fblock;

	if(block.Contains("Lset") || block.Contains("lset") || block.Contains("LSET"))
	{
		int pB = wxMessageBox("LSET command found on your PAUP block.\nDo you want to comment it?", "Paup Block", wxYES | wxNO);
		if(pB == wxYES)
		{
			lsetPos = block.Find("LSET");
			block.Replace("LSET", "[LSET", false);
			if(lsetPos == -1)
			{
				lsetPos = block.Find("Lset");
				block.Replace("Lset", "[Lset", false);
			}
			if(lsetPos == -1)
			{
				lsetPos = block.Find("lset");
				block.Replace("lset", "[lset", false);
			}
			if(lsetPos == 0)
			{
				semiPos = block.First(";");
				block.Replace(";", ";]", false);
			}
		}
	}
	return block;
}
Example #2
0
/// Helper function to translate the two color string representations:
/// "255 128 64" (cmap file) and "(255,128,64)" (wxPropertyGrid)
/// If wxColourObj is true, the function will create a string that can be used to create a wxColour object from it.
/// Beware: Strings that are not in one of the formats above are not caught and might result in strange return values.
static wxString TranslateColorString(wxString colorstring, bool wxColourObj=false)
{
    if (colorstring.StartsWith("("))
    {
        // wxPropertyGrid representation.
        if (wxColourObj)
        {
            colorstring="RGB"+colorstring;
        }
        else
        {
            colorstring.Replace("(", "");
            colorstring.Replace(")", "");
            colorstring.Replace(",", " ");
        }
    }
    else
    {
        // cmap file representation.
        colorstring.Replace(" ", ",");
        colorstring="("+colorstring+")";
        if (wxColourObj) colorstring="RGB"+colorstring;
    }

    return colorstring;
}
Example #3
0
wxArrayString SQLCommandPanel::ParseSql(const wxString& sql) const
{
    // filter out comments
    wxString noCommentsSql;
    wxArrayString lines = ::wxStringTokenize(sql, "\n", wxTOKEN_STRTOK);
    for(size_t i=0; i<lines.GetCount(); ++i) {
        lines.Item(i).Trim().Trim(false);
        if ( lines.Item(i).StartsWith("--") ) {
            continue;
        }
        noCommentsSql << lines.Item(i) << "\n";
    }
    
    // Split by semi-colon
    wxArrayString tmpSqls = ::wxStringTokenize(noCommentsSql, ";", wxTOKEN_STRTOK);
    wxArrayString sqls;
    for(size_t i=0; i<tmpSqls.GetCount(); ++i) {
        
        wxString sql = tmpSqls.Item(i);
        sql.Trim().Trim(false);
        if ( sql.IsEmpty() )
            continue;
            
        sql.Replace("\n", " ");
        sql.Replace("\r", "");
        sqls.Add( sql );
    }
    return sqls;
}
Example #4
0
void TestClassDlg::EscapeName(wxString& name)
{
    name.Replace(wxT(" "), wxEmptyString);
    name.Replace(wxT("~"), wxT("Tilda"));
    name.Replace(wxT("="), wxT("Shave"));
    name.Replace(wxT(">"), wxT("Gadol"));
    name.Replace(wxT("<"), wxT("Katan"));
}
/*
 * some characters cannot be used in filenames,
 * this function change them to "_"
 */
static void ChangeIllegalCharacters( wxString& aFileName, bool aDirSepIsIllegal )
{
    if( aDirSepIsIllegal )
        aFileName.Replace( wxT( "/" ), wxT( "_" ) );

    aFileName.Replace( wxT( " " ), wxT( "_" ) );
    aFileName.Replace( wxT( ":" ), wxT( "_" ) );
}
wxString LogbookHTML::replaceNewLine(wxString s, bool mode)
{
	if(mode == 0) // HTML
		s.Replace(wxT("\n"),wxT("<br>"));
	else // ODT
		s.Replace(wxT("\n"),wxT("<text:line-break/>"));

	return s;
}
Example #7
0
wxString GEUIDialog::encodeXMLEntities(wxString str)
{
      str.Replace(_T("<"),_T("&lt;"));
      str.Replace(_T(">"),_T("&gt;"));
      str.Replace(_T("&"),_T("&amp;"));
      str.Replace(_T("\""),_T("&#34;"));
      str.Replace(_T("\\"),_T("&#39;"));
      return str;
}
Example #8
0
// Check if, TABLE (tblname) has column with name colname
bool pgConn::TableHasColumn(wxString schemaname, wxString tblname, const wxString &colname)
{
	//
	// SELECT a.attname
	// FROM pg_catalog.pg_attribute a
	// WHERE a.attrelid = (SELECT c.oid
	//                     FROM pg_catalog.pg_class c
	//                          LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
	//                     WHERE c.relname ~ '^(TABLENAME)$' AND
	//                           pg_catalog.pg_table_is_visible(c.oid) AND
	//                           n.nspname ~ '^(SCHEMANAME)$') AND
	//       a.attnum > 0 AND NOT a.attisdropped
	// ORDER BY a.attnum
	//

	if (tblname.IsEmpty() || colname.IsEmpty())
		return false;

	if (schemaname.IsEmpty())
		schemaname = wxT("public");

	if (this && GetStatus() == PGCONN_OK)
	{
		tblname.Replace(wxT("\\"), wxT("\\\\"));
		tblname.Replace(wxT("'"), wxT("''"));
		schemaname.Replace(wxT("\\"), wxT("\\\\"));
		schemaname.Replace(wxT("'"), wxT("''"));

		wxString sql
		    = wxT("SELECT a.attname AS colname FROM pg_catalog.pg_attribute a ") \
		      wxT("WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.pg_class c ") \
		      wxT("                    LEFT JOIN pg_catalog.pg_namespace n ON ") \
		      wxT("                                    n.oid = c.relnamespace ") \
		      wxT("                    WHERE c.relname ~ '^(") + tblname + wxT(")$' AND ") \
		      wxT("                          n.nspname ~ '^(") + schemaname + wxT(")$') AND ") \
		      wxT("      a.attnum > 0 AND NOT a.attisdropped ") \
		      wxT("ORDER BY a.attnum");

		pgSet *set = ExecuteSet(sql);
		if (set)
		{
			while (!set->Eof())
			{
				if (set->GetVal(wxT("colname")) == colname)
				{
					delete set;
					return true;
				}
				set->MoveNext();
			}
		}
		delete set;
	}

	return false;
}
    void SetHtmlKeywords()
    {
        wxString keywords = m_part->GetKeyWords();

        if( keywords.empty() )
            m_html.Replace( "__KEY__", wxEmptyString );
        else
            m_html.Replace( "__KEY__",
                    wxString::Format( KeywordsFormat, EscapedHTML( keywords ) ) );
    }
jewel::Decimal
wx_to_decimal
(   wxString wxs,
    wxLocale const& loc,
    DecimalParsingFlags p_flags
)
{
    bool const allow_parens =
        p_flags.test(string_flags::allow_negative_parens);
    wxs = wxs.Trim().Trim(false);  // trim both right and left.
    typedef wxChar CharT;
    static CharT const open_paren = wxChar('(');
    static CharT const close_paren = wxChar(')');
    static CharT const minus_sign = wxChar('-');
    wxString const decimal_point_s = loc.GetInfo
    (   wxLOCALE_DECIMAL_POINT,
        wxLOCALE_CAT_MONEY
    );
    wxString const thousands_sep_s = loc.GetInfo
    (   wxLOCALE_THOUSANDS_SEP,
        wxLOCALE_CAT_MONEY
    );
    if (wxs.IsEmpty())
    {
        return Decimal(0, 0);
    }
    JEWEL_ASSERT (wxs.Len() >= 1);
    if ((wxs.Len() == 1) && (*(wxs.begin()) == minus_sign))
    {
        return Decimal(0, 0);
    }

    // We first convert wxs into a canonical form in which there are no
    // thousands separators, negativity is indicated only by a minus
    // sign, and the decimal point is '.'.
    if (allow_parens && (wxs[0] == open_paren) && (wxs.Last() == close_paren))
    {
        wxs[0] = minus_sign;  // Replace left parenthesis with minus sign
        wxs.RemoveLast();  // Drop right parenthesis
    }
    wxs.Replace(thousands_sep_s, wxEmptyString);

    // We need to get the std::locale (not wxLocale) related decimal point
    // character, so that we can ensure the Decimal constructor-from-string
    // sees that appropriate decimal point character.
    locale const gloc;  // global locale
    char const spot_char = use_facet<numpunct<char> >(gloc).decimal_point();
    char const spot_str[] = { spot_char, '\0' };
    wxs.Replace(decimal_point_s, wxString(spot_str));

    string const s = wx_to_std8(wxs);
    Decimal const ret(s);
    return ret;
}
Example #11
0
void MSVC10Loader::ReplaceConfigMacros(const SProjectConfiguration &pc, wxString &str)
{
    str.Replace(_T("$(Configuration)"),pc.sConf);
    str.Replace(_T("$(Platform)"),pc.sPlatform);

    str.Replace(_T("$(OutDir)"),pc.sOutDir);
    str.Replace(_T("$(IntDir)"),pc.sIntDir);
    str.Replace(_T("$(TargetName)"),pc.sTargetName);
    str.Replace(_T("$(TargetExt)"),pc.sTargetExt);
    str = ReplaceMSVCMacros(str);
}
wxString DescriptorFrame::edit_partit(wxString partit)
{
	
	int erase_s=partit.Replace("<partitioning>","");
	int erase_e=partit.Replace("</partitioning>","");


	int erase_start=partit.find("<hostcollocation>");
		while (erase_start>0)
		{
			erase_start=partit.find("<hostcollocation>");
			int erase_end=partit.find("</hostcollocation>")+18;
			if (erase_end>18) 
			{
				partit.Remove(erase_start,erase_end-erase_start);
			}

		} 

		

	erase_start=0;
	erase_start=partit.find("<processcollocation");
		while (erase_start>0)
		{
			erase_start=partit.find("<processcollocation");
			int erase_end=partit.find("</processcollocation>")+21;

			if (erase_end>21)
			{
				partit.Remove(erase_start,erase_end-erase_start);
			}
			
		}	

		
	erase_start=0;
	erase_start=partit.find("<homeplacement");
		while (erase_start>0)
		{
			erase_start=1;
			erase_start=partit.find("<homeplacement");
			int erase_end=partit.find("</homeplacement>")+16;
			if (erase_end>16)
			{
				partit.Remove(erase_start,erase_end-erase_start);
			}
						
		}
		
	
	return partit;

}
Example #13
0
// Removes MI additional characters from string
static void StripString(wxString &string)
{
	string.Replace(wxT("\\n\""), wxT("\""));
	string = string.AfterFirst(wxT('"'));
	string = string.BeforeLast(wxT('"'));
	string.Replace(wxT("\\\""), wxT("\""));
	string.Replace(wxT("\\\\"), wxT("\\"));
	string.Replace(wxT("\\\\r\\\\n"), wxT("\r\n"));
	string.Replace(wxT("\\\\n"), wxT("\n"));
	string.Replace(wxT("\\\\r"), wxT("\r"));
	string = string.Trim();
}
Example #14
0
bool wxExLink::SetLink(
    wxString& link,
    int& line_no,
    int& column_no) const
{
    if (link.size() < 2)
    {
        return false;
    }

    // Using backslash as separator does not yet work.
    link.Replace("\\\\", "/");
    link.Replace("\\", "/");

    // The harddrive letter is filtererd, it does not work
    // when adding it to wxExMatch.
    wxString prefix;

#ifdef __WXMSW__
    if (isalpha(link[0]) && link[1] == ':')
    {
        prefix = link.SubString(0,1);
        link = link.Mid(2);
    }
#endif

    // file[:line[:column]]
    std::vector <wxString> v;

    if (wxExMatch("([0-9A-Za-z _/.-]+):([0-9]*):?([0-9]*)", link, v))
    {
        link = v[0];
        line_no = 0;
        column_no = 0;

        if (v.size() > 1)
        {
            line_no = atoi(v[1]);

            if (v.size() > 2)
            {
                column_no = atoi(v[2]);
            }
        }

        link = prefix + link;

        return true;
    }

    return false;
}
 void SetHtmlAliasOf()
 {
     if( m_part->IsRoot() )
     {
         m_html.Replace( "__ALIASOF__", wxEmptyString );
     }
     else
     {
         LIB_PART* root = m_part->GetPart();
         const wxString root_name = ( root ? root->GetName() : _( "Unknown" ) );
         m_html.Replace(
             "__ALIASOF__", wxString::Format( AliasOfFormat, EscapedHTML( root_name ) ) );
     }
 }
Example #16
0
int CatalogItemsComparator::CompareStrings(wxString a, wxString b) const
{
    // TODO: * use ICU for correct ordering
    //       * use natural sort (for numbers)
    //       * use ICU for correct case insensitivity

    a.Replace("&", "");
    a.Replace("_", "");

    b.Replace("&", "");
    b.Replace("_", "");

    return a.CmpNoCase(b);
}
wxString Maintenance::replaceNewLine(int mode, wxString str)
{
	switch(mode)
	{
	case 0:
		 // HTML
		 str.Replace(wxT("\n"),wxT("<br>"));
		 break;
	case 1: // ODT
		 str.Replace(wxT("\n"),wxT("<text:line-break/>"));
		 break;
	}

	return str;
}
Example #18
0
void QuickFindBar::DoFixRegexParen(wxString& findwhat)
{
    // Scintilla's REGEX group markers are \( and \)
    // while wxRegEx is usig bare ( and ) and the escaped version for
    // non regex manner
    findwhat.Replace("\\(", "/<!@#$");
    findwhat.Replace("\\)", "/>!@#$");
    findwhat.Replace("(", "<!@#$");
    findwhat.Replace(")", ">!@#$");

    findwhat.Replace("/<!@#$", "(");
    findwhat.Replace("/>!@#$", ")");
    findwhat.Replace("<!@#$", "\\(");
    findwhat.Replace(">!@#$", "\\)");
}
Example #19
0
// Removes MI additional characters from string
static void StripString( wxString &string )
{
    string.Replace( wxT( "\\n\"" ), wxT( "\"" ) );
    string = string.AfterFirst( wxT( '"' ) );
    string = string.BeforeLast( wxT( '"' ) );
    string.Replace( wxT( "\\\"" ), wxT( "\"" ) );
    string.Replace( wxT( "\\\\" ), wxT( "\\" ) );
    string.Replace( wxT( "\\\\r\\\\n" ), wxT( "\r\n" ) );
    string.Replace( wxT( "\\\\n" ), wxT( "\n" ) );
    string.Replace( wxT( "\\\\r" ), wxT( "\r" ) );
#ifdef __WXMSW__
    string.Replace("\\r\\n", "\r\n");
#endif
    string = string.Trim();
}
Example #20
0
/**
    If the locale settings indicate that floating point numbers use a comma (,) as
    a decimal point then we're going to have a problem reading in the CXF font files.
    The CXF font files use commas as field separators and dots (.) as decimal
    points.  In order that the strtod() conversion work correctly, convert all the
    dot characters in the attached string into a comma so that the conversion
    to a floating point number works correctly.
    NOTE: This routine must not be called with a comma-separated list of
    values.  This list of values should be separated and each individual value
    passed in here separately.
 */
wxString VectorFont::Glyph::PrepareStringForConversion( wxString &value ) const
{
    typedef enum
    {
        eUnknown = 0,
        eConvertDotToComma,
        eNoConversionRequired
    } FloatingPointConversion_t;

    static FloatingPointConversion_t   floating_point_conversion = eUnknown;

    if (floating_point_conversion == eUnknown)
    {
        // We need to figure out if the local computer's locale settings use a comma
        // as a decimal point.
        wxString test;
        test << 3.1415;
        if (test.Find(',') != -1)
        {
            floating_point_conversion = eConvertDotToComma;
        }
        else
        {
            floating_point_conversion = eNoConversionRequired;
        }
    }

    if (floating_point_conversion == eConvertDotToComma)
    {
        value.Replace(_T("."), _T(","));
    }

    return(value);
}
    void SetHtmlDesc()
    {
        wxString raw_desc;

        if( m_part->IsRoot() )
        {
            raw_desc = m_part->GetDescription();
        }
        else
        {
            LIB_PART* root = m_part->GetPart();

            for( size_t i = 0; i < root->GetAliasCount(); ++i )
            {
                LIB_ALIAS* alias = root->GetAlias( i );

                if( alias && !alias->GetDescription().empty() )
                {
                    raw_desc = alias->GetDescription();
                    break;
                }
            }
        }

        m_html.Replace( "__DESC__", wxString::Format( DescFormat, EscapedHTML( raw_desc ) ) );
    }
void ctlDefaultPrivilegesPanel::Update(wxString strDefPrivs)
{
	unsigned int index = 0;

	cbGroups->Clear();
	lbPrivileges->DeleteAllItems();

	m_privileges.clear();

	cbGroups->Append(wxT("public"));

	for (; index < m_defSecurityPanel->m_groups.GetCount(); index++)
		cbGroups->Append(m_defSecurityPanel->m_groups[index]);

	if (!strDefPrivs.IsEmpty())
	{
		wxString strRole, strPriv;
		strDefPrivs.Replace(wxT("\\\""), wxT("\""), true);
		strDefPrivs.Replace(wxT("\\\\"), wxT("\\"), true);

		// Removing starting brace '{' and ending brace '}'
		strDefPrivs = strDefPrivs.SubString(1, strDefPrivs.Length() - 1);

		long pos = 0;

		while (pgObject::findUserPrivs(strDefPrivs, strRole, strPriv))
		{
			int icon;
			if (strRole.IsSameAs(wxT("public"), true))
				icon = PGICON_PUBLIC;
			else if (cbGroups->FindString(strRole) != wxNOT_FOUND)
				icon = userFactory.GetIconId();
			else if (cbGroups->FindString(wxT("group ") + strRole) != wxNOT_FOUND)
			{
				icon = groupFactory.GetIconId();
				strRole = wxT("group ") + strRole;
			}
			else
				continue;

			defPrivilege priv;
			priv.m_username = strRole;
			priv.m_origPriv = strPriv;
			priv.m_modified = false;
			priv.m_newPriv  = wxT("");

			wxString strKey = strRole;
			m_privileges[strKey] = priv;

			pos = lbPrivileges->GetItemCount();

			lbPrivileges->InsertItem(pos, strRole, icon);
			lbPrivileges->SetItem(pos, 1, strPriv);

			strRole = wxT("");
			strPriv = wxT("");
			pos++;
		}
	}
}
Example #23
0
//---------------------------------------------------------
bool DLG_Get_FILE_Filter_GDAL_Read(int Type, wxString &Filter)
{
	bool		bResult;
	CSG_Table	Formats;

	SG_UI_ProgressAndMsg_Lock(true);

	SG_RUN_TOOL(bResult, "io_gdal", 10,	// GDAL Formats
		SG_TOOL_PARAMETER_SET("FORMATS"   , &Formats)
	&&	SG_TOOL_PARAMETER_SET("TYPE"      , Type    )	// all (rasters and vectors)
	&&	SG_TOOL_PARAMETER_SET("ACCESS"    , 0       )	// read
	&&	SG_TOOL_PARAMETER_SET("RECOGNIZED", true    )	// add an entry for all recognized files
	);

	SG_UI_ProgressAndMsg_Lock(false);

	if( bResult && Formats.Get_Count() > 0 )
	{
		Filter	+= Formats[Formats.Get_Count() - 1].asString(2);

		Filter.Replace("*.sdat;", "");	// we go for *.sgrd
		Filter.Replace("*.xml;" , "");	// too much noise
	}

	return( bResult );
}
Example #24
0
// this function replaces Microsoft %1 with Unix-like %s
static bool CanonicalizeParams(wxString& command)
{
    // transform it from '%1' to '%s' style format string (now also test for %L
    // as apparently MS started using it as well for the same purpose)

    // NB: we don't make any attempt to verify that the string is valid, i.e.
    //     doesn't contain %2, or second %1 or .... But we do make sure that we
    //     return a string with _exactly_ one '%s'!
    bool foundFilename = false;
    size_t len = command.length();
    for ( size_t n = 0; (n < len) && !foundFilename; n++ )
    {
        if ( command[n] == wxT('%') &&
                (n + 1 < len) &&
                (command[n + 1] == wxT('1') || command[n + 1] == wxT('L')) )
        {
            // replace it with '%s'
            command[n + 1] = wxT('s');

            foundFilename = true;
        }
    }

    if ( foundFilename )
    {
        // Some values also contain an addition %* expansion string which is
        // presumably supposed to be replaced with the names of the other files
        // accepted by the command. As we don't support more than one file
        // anyhow, simply ignore it.
        command.Replace(" %*", "");
    }

    return foundFilename;
}
Example #25
0
void CServerPath::EscapeSeparators(ServerType type, wxString& subdir)
{
	if (traits[type].separatorEscape) {
		for (const wxChar* p = traits[type].separators; *p; ++p)
			subdir.Replace((wxString)*p, (wxString)traits[type].separatorEscape + traits[type].separators[0]);
	}
}
Example #26
0
bool Copyright::Validate(wxString& content)
{
    CopyrightsConfigData data;
    m_mgr->GetConfigTool()->ReadObject(wxT("CopyrightsConfig"), &data);

    // make sure that the template file exists
    if(!wxFileName::FileExists(data.GetTemplateFilename())) {
        wxMessageBox(
            wxString::Format(_("Template file name '%s', does not exist!"), data.GetTemplateFilename().GetData()),
            _("CodeLite"), wxICON_WARNING | wxOK);
        return false;
    }

    // read the copyrights file
    if(!ReadFileWithConversion(data.GetTemplateFilename(), content)) {
        wxMessageBox(wxString::Format(_("Failed to read template file '%s'"), data.GetTemplateFilename().c_str()),
                     _("CodeLite"), wxICON_WARNING | wxOK);
        return false;
    }

    // verify that the file consist only with comment code
    CppWordScanner scanner(data.GetTemplateFilename().mb_str().data());

    CppTokensMap l;
    scanner.FindAll(l);

    if(!l.is_empty()) {
        if(wxMessageBox(_("Template file contains text which is not comment, continue anyways?"), _("CodeLite"),
                        wxICON_QUESTION | wxYES_NO) == wxNO) {
            return false;
        }
    }
    content.Replace(wxT("`"), wxT("'"));
    return true;
}
void mxVarWindow::AddVar(wxString vname, wxChar type) {
	RegisterAutocompKey(vname.BeforeFirst('['));
	int icon = type-LV_BASE_CHAR;
	vname.Replace("-1","??",true);
	wxTreeItemId id=tree->AppendItem(tree_current,vname/*+stype*/,icon);
	if (vname.BeforeFirst('[')==last_sel && last_parent==tree->GetItemText(tree_current)) tree->SelectItem(id);
}
Example #28
0
void wxNumberFormatter::RemoveThousandsSeparators(wxString& s)
{
    wxChar thousandsSep;
    if ( !GetThousandsSeparatorIfUsed(&thousandsSep) )
        return;

    s.Replace(wxString(thousandsSep), wxString());
}
Example #29
0
long GetSpeedFromString(wxString label){
	long temp;
	label.Replace(_("kB/s"),wxT(""),TRUE);
	label.Trim(FALSE);
	label.Trim(TRUE);
	label.ToLong(&temp);
	return temp;
}
Example #30
0
// Add spaces into the displayed name so there are more wrapping opportunities
static wxString FormatTextureName(wxString name)
{
	if (name.Len())
		name[0] = wxToupper(name[0]);
	name.Replace(_T("_"), _T(" "));

	return name;
}