예제 #1
0
// -------------------------------------------------------------------------------- //
int guGoogleCoverFetcher::ExtractImagesInfo( wxString &content, int count )
{
    int ImageIndex = 0;
    while( !m_MainThread->TestDestroy() )
    {
        //guLogMessage( wxT( "%s\n" ), content.c_str() );

        int FindPos = content.Find( wxT( "{\"GsearchResultClass\":" ) );
        if( FindPos == wxNOT_FOUND )
        {
            break;
        }
        content = content.Mid( FindPos );

        FindPos = content.Find( wxT( "}," ) );
        if( FindPos == wxNOT_FOUND )
            break;

        ExtractImageInfo( content.Mid( 0, FindPos + 1 ) );
        ImageIndex++;
        if( ImageIndex > count )
            break;

        content = content.Mid( FindPos + 1 );
        if( content.IsEmpty() )
            break;
    }

    return ( ImageIndex == GOOGLE_COVERS_PER_PAGE ) ? ImageIndex : 0;
}
예제 #2
0
파일: SbModel.cpp 프로젝트: genua/anoubis
inline bool
SbModel::comparePermission(const wxString &ps, SbEntry::Permission p) const
{
	return ((ps.Find(wxT("r")) != wxNOT_FOUND) && (p == SbEntry::READ)) ||
	    ((ps.Find(wxT("w")) != wxNOT_FOUND) && (p == SbEntry::WRITE)) ||
	    ((ps.Find(wxT("x")) != wxNOT_FOUND) && (p == SbEntry::EXECUTE));
}
예제 #3
0
bool frmMain::reportError(const wxString &error, const wxString &msgToIdentify, const wxString &hint)
{
    bool identified=false;

    wxString translated=wxGetTranslation(msgToIdentify);
    if (translated != msgToIdentify)
    {
        identified = (error.Find(translated) >= 0);
    }

    if (!identified)
    {
        if (msgToIdentify.Left(20) == wxT("Translator attention"))
            identified = (error.Find(msgToIdentify.Mid(msgToIdentify.Find('!')+1)) >= 0);
        else
            identified = (error.Find(msgToIdentify) >= 0);
    }

    if (identified)
    {
        if (frmHint::WantHint(hint))
            frmHint::ShowHint(this, hint, error);
    }
    return identified;
}
예제 #4
0
파일: mtgui.cpp 프로젝트: nuin/MrMTgui
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;
}
예제 #5
0
/** This function determines the caracteristics of a given line (code line, comment line etc...).
 *  It is called by the "CountLines" function.
 *  @see CountLines
 */
void CodeStatExecDlg::AnalyseLine(LanguageDef &language, wxString line, bool &comment, bool &code, bool &multi_line_comment)
{
   int first_single_line_comment, first_multi_line_comment_begin, first_multi_line_comment_end;

   // Delete first and trailing spaces
   line = line.Trim(true);
   line = line.Trim(false);

	if (line.IsEmpty())
	   return;

	// Searching for single and multi-lines comment signs
	if (language.single_line_comment.Length() > 0)
      first_single_line_comment = line.Find(language.single_line_comment);
   else first_single_line_comment = -1;
   if (language.multiple_line_comment[0].Length() > 0)
      first_multi_line_comment_begin = line.Find(language.multiple_line_comment[0]);
   else first_multi_line_comment_begin = -1;
   if (language.multiple_line_comment[1].Length() > 0)
      first_multi_line_comment_end = line.Find(language.multiple_line_comment[1]);
   else first_multi_line_comment_end = -1;

   // We are in a multiple line comment => finding the "end of multiple line comment" sign
   if (multi_line_comment)
   {
      comment = true;
   	if (first_multi_line_comment_end > -1)
   	{
   		multi_line_comment = false;
   		if (first_multi_line_comment_end+language.multiple_line_comment[1].Length() < line.Length())
   		   AnalyseLine(language, line.Mid(first_multi_line_comment_end+language.multiple_line_comment[1].Length()), comment, code, multi_line_comment);
   	}
   }
   // We are not in a multiple line comment
   else if (!multi_line_comment)
   {
   	// First comment sign found is a single line comment sign
      if ( (first_single_line_comment>-1)
         &&((first_multi_line_comment_begin==-1)||((first_multi_line_comment_begin>-1)&&(first_single_line_comment<first_multi_line_comment_begin))) )
      {
      	comment = true;
         if (first_single_line_comment > 0)
            code = true;
      }
      // First comment sign found is a multi-line comment begin sign
      else if (first_multi_line_comment_begin>-1)
      {
         multi_line_comment = true;
         comment = true;
         if (first_multi_line_comment_begin > 0)
            code = true;
         if (first_multi_line_comment_begin+language.multiple_line_comment[0].Length() < line.Length())
   		   AnalyseLine(language, line.Mid(first_multi_line_comment_begin+language.multiple_line_comment[0].Length()), comment, code, multi_line_comment);
      }
      else
      {
      	code = true;
      }
   }
}
예제 #6
0
wxString wxWidgetsGUI::GetAppClassName(const wxString& Source,wxsCodingLang Lang)
{
    switch ( Lang )
    {
    case wxsCPP:
    {
        // Doing some trick - searching for IMPLEMENT_APP macro followed
        // by '(' and class name - here we can fetch name of application class
        int Pos = Source.Find(_T("IMPLEMENT_APP"));
        if ( Pos<0 ) return wxEmptyString;
        Pos += 13;// strlen("IMPLEMENT_APP")
        while ( IsWhite(Source,Pos) ) Pos++;
        if ( Pos >= (int)Source.Length() ) return wxEmptyString;
        if ( Source[Pos++] != _T('(') ) return wxEmptyString;
        while ( IsWhite(Source,Pos) ) Pos++;
        wxString ClassName;
        static const wxString AllowedChars(_T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"));
        while ( (Pos < (int)Source.Length()) && (AllowedChars.Find(Source[Pos])>=0) )
        {
            ClassName += Source[Pos];
            Pos++;
        }
        while ( IsWhite(Source,Pos) ) Pos++;
        if ( Pos >= (int)Source.Length() ) return wxEmptyString;
        if ( Source[Pos] != _T(')') ) return wxEmptyString;
        return ClassName;
    }
    default:
        ;
    }
    return wxEmptyString;
}
예제 #7
0
void QuoteStringIfNeeded(wxString& str)
{
    bool hasSpace = str.Find(_T(' ')) != -1;
    bool hasParen = !platform::windows && (str.Find(_T('(')) != -1 || str.Find(_T(')')) != -1);
    if (!str.IsEmpty() && str.GetChar(0) != _T('"') && (hasSpace || hasParen))
        str = wxString(_T("\"")) + str + _T("\"");
}
예제 #8
0
static wxString GetLocaleFile(const wxString& localesDir, wxString name)
{
	if (wxFileName::FileExists(localesDir + name + _T("/filezilla.mo")))
		return name;
	if (wxFileName::FileExists(localesDir + name + _T("/LC_MESSAGES/filezilla.mo")))
		return name + _T("/LC_MESSAGES");

	size_t pos = name.Find('@');
	if (pos > 0)
	{
		name = name.Left(pos);
		if (wxFileName::FileExists(localesDir + name + _T("/filezilla.mo")))
			return name;
		if (wxFileName::FileExists(localesDir + name + _T("/LC_MESSAGES/filezilla.mo")))
			return name + _T("/LC_MESSAGES");
	}

	pos = name.Find('_');
	if (pos > 0)
	{
		name = name.Left(pos);
		if (wxFileName::FileExists(localesDir + name + _T("/filezilla.mo")))
			return name;
		if (wxFileName::FileExists(localesDir + name + _T("/LC_MESSAGES/filezilla.mo")))
			return name + _T("/LC_MESSAGES");
	}

	return _T("");
}
//---------------------------------------------------------
bool CActive_Attributes_Control::_Get_DataSource(wxString &Source)
{
	if( Source.Find("PGSQL:"  ) == 0
	||	Source.Find("ftp://"  ) == 0
	||	Source.Find("http://" ) == 0
	||	Source.Find("https://") == 0
	||	Source.Find("file://" ) == 0
	||  wxFileExists(Source)  )
	{
		return( true );
	}

	if( g_pActive->Get_Active_Data_Item() && g_pActive->Get_Active_Data_Item()->Get_Object()->Get_File_Name(false) )
	{
		wxFileName	fn(Source), dir(g_pActive->Get_Active_Data_Item()->Get_Object()->Get_File_Name(false));

		if( fn.MakeAbsolute(dir.GetPath()) && fn.Exists() )
		{
			Source	= fn.GetFullPath();

			return( true );
		}
	}

	return( false );
}
예제 #10
0
wxString interprete::ObtenerPolinomioDesComa(wxString DespuesComa, usi it)
{
    wxString obpa="error";
    usi DondeComa=DespuesComa.Find(',');
    usi DondeP=DespuesComa.Find(')');
    DondeComa++;
    DondeP--;
    obpa=DespuesComa.Mid(DondeComa,DondeP);
    return obpa;
}
예제 #11
0
void frmHbaConfig::DisplayFile(const wxString &str)
{
	lines.Empty();

	filetype = wxTextFileType_Unix;
	wxStringTokenizer strtok;

	if (str.Find('\r') >= 0)
	{
		if (str.Find(wxT("\n\r")) >= 0 || str.Find(wxT("\r\n")))
			filetype = wxTextFileType_Dos;
		else
			filetype = wxTextFileType_Mac;

		strtok.SetString(wxTextBuffer::Translate(str, wxTextFileType_Unix), wxT("\n"), wxTOKEN_RET_EMPTY);
	}
	else
		strtok.SetString(str, wxT("\n"), wxTOKEN_RET_EMPTY);

	while (strtok.HasMoreTokens())
	{
		pgHbaConfigLine *line = new pgHbaConfigLine(strtok.GetNextToken());
		lines.Add(line);
	}

	listEdit->DeleteAllItems();

	size_t i = lines.GetCount();

	// make sure the last line is empty

	for (i = 0 ; i < lines.GetCount() ; i++)
	{
		pgHbaConfigLine &line = lines.Item(i);
		const wxChar *connTypeStr = line.GetConnectType();
		if ((line.isValid || (!line.isValid && !line.isComment)) && !line.GetText().IsEmpty())
		{
			int imgIndex = 0;
			if (!line.isComment)
				imgIndex = 1;
			long pos = listEdit->AppendItem(imgIndex, connTypeStr, line.database, line.user);
			listEdit->SetItem(pos, 3, line.ipaddress);
			listEdit->SetItem(pos, 4, line.GetMethod());
			listEdit->SetItem(pos, 5, line.option);

			line.item = pos;
		}
	}
	if (!i || !lines.Item(i - 1).text.IsEmpty())
	{
		pgHbaConfigLine *line = new pgHbaConfigLine();
		lines.Add(line);
		line->item = listEdit->AppendItem(0, wxString(wxEmptyString));
	}
}
예제 #12
0
bool
wxPdfBarCodeCreator::I25(double xpos, double ypos, const wxString& code, double basewidth, double height)
{
    // wide/narrow codes for the digits
    wxString locCode = code;
    double wide = basewidth;
    double narrow = basewidth / 3 ;
    double lineWidth;

    if ((locCode.Length() > 0 && !wxIsdigit(locCode[0])) || !locCode.IsNumber())
    {
        return false;
    }

    // add leading zero if code-length is odd
    if (locCode.Length() % 2 != 0)
    {
        locCode = wxT("0") + locCode;
    }

    m_document->SetFont(wxT("Helvetica"), wxT(""), 10);
    m_document->Text(xpos, ypos + height + 4, locCode);
    m_document->SetFillColour(0);

    // add start and stop codes
    locCode = wxT("AA") + locCode + wxT("ZA");

    size_t i;
    for (i = 0; i < locCode.Length(); i += 2)
    {
        // choose next pair of digits
        int digitBar = i25_chars.Find(locCode[i]);
        int digitSpace = i25_chars.Find(locCode[i+1]);

        // create a wide/narrow-sequence (first digit=bars, second digit=spaces)
        wxString seq = wxT("");
        size_t j;
        for (j = 0; j < i25_barChar[digitBar].Length(); j++)
        {
            seq += wxString(i25_barChar[digitBar][j]) + wxString(i25_barChar[digitSpace][j]);
        }
        for (j = 0; j < seq.Length(); j++)
        {
            // set lineWidth depending on value
            lineWidth = (seq[j] == wxT('n')) ? narrow : wide;
            // draw every second value, because the second digit of the pair is represented by the spaces
            if (j % 2 == 0)
            {
                m_document->Rect(xpos, ypos, lineWidth, height, wxPDF_STYLE_FILL);
            }
            xpos += lineWidth;
        }
    }
    return true;
}
예제 #13
0
wxTreeItemId CLocalTreeView::GetNearestParent(wxString& localDir)
{
	const wxString separator = wxFileName::GetPathSeparator();
#ifdef __WXMSW__
	int pos = localDir.Find(separator);
	if (pos == -1)
		return wxTreeItemId();

	wxString drive = localDir.Left(pos);
	localDir = localDir.Mid(pos + 1);

	wxTreeItemIdValue value;
	wxTreeItemId root = GetFirstChild(m_drives, value);
	while (root)
	{
		if (!GetItemText(root).Left(drive.Length()).CmpNoCase(drive))
			break;

		root = GetNextSibling(root);
	}
	if (!root)
	{
		if (drive[1] == ':')
			return AddDrive(drive[0]);
		return wxTreeItemId();
	}
#else
		if (localDir[0] == '/')
			localDir = localDir.Mid(1);
		wxTreeItemId root = GetRootItem();
#endif

	while (localDir != _T(""))
	{
		wxString subDir;
		int pos = localDir.Find(separator);
		if (pos == -1)
			subDir = localDir;
		else
			subDir = localDir.Left(pos);

		wxTreeItemId child = GetSubdir(root, subDir);
		if (!child)
			return root;

		if (!pos)
			return child;

		root = child;
		localDir = localDir.Mid(pos + 1);
	}

	return root;
}
예제 #14
0
void SPICE_VALUE::stripZeros( wxString& aString )
{
    if ( aString.Find( ',' ) >= 0 || aString.Find( '.' ) >= 0 )
    {
        while( aString.EndsWith( '0' ) )
            aString.RemoveLast();

        if( aString.EndsWith( '.' ) || aString.EndsWith( ',' ) )
            aString.RemoveLast();
    }
}
예제 #15
0
void CLocalPath::AddSegment(const wxString& segment)
{
	wxASSERT(!m_path.empty());
	wxASSERT(segment.Find(_T("/")) == -1);
#ifdef __WXMSW__
	wxASSERT(segment.Find(_T("\\")) == -1);
#endif

	m_path += segment;
	m_path += path_separator;
}
예제 #16
0
wxString CommandManager::GetKey(wxString label)
{
   int loc = -1;

   loc = label.Find(wxT('\t'));
   if (loc == -1)
      loc = label.Find(wxT("\\t"));

   if (loc == -1)
      return wxT("");

   return label.Right(label.Length() - (loc+1));
}
예제 #17
0
bool CControlSocket::ParsePwdReply(wxString reply, bool unquoted /*=false*/, const CServerPath& defaultPath /*=CServerPath()*/)
{
	if (!unquoted)
	{
		int pos1 = reply.Find('"');
		int pos2 = reply.Find('"', true);
		if (pos1 == -1 || pos1 >= pos2)
		{
			int pos1 = reply.Find('\'');
			int pos2 = reply.Find('\'', true);

			if (pos1 != -1 && pos1 < pos2)
				LogMessage(__TFILE__, __LINE__, this, Debug_Info, _T("Broken server sending single-quoted path instead of double-quoted path."));
		}
		if (pos1 == -1 || pos1 >= pos2)
		{
			LogMessage(__TFILE__, __LINE__, this, Debug_Info, _T("No quoted path found in pwd reply, trying first token as path"));
			pos1 = reply.Find(' ');
			if (pos1 != -1)
			{
				pos2 = reply.Mid(pos1 + 1).Find(' ');
				if (pos2 == -1)
					pos2 = (int)reply.Length();
				reply = reply.Mid(pos1 + 1, pos2 - pos1 - 1);
			}
			else
				reply = _T("");
		}
		else
			reply = reply.Mid(pos1 + 1, pos2 - pos1 - 1);
	}

	m_CurrentPath.SetType(m_pCurrentServer->GetType());
	if (reply == _T("") || !m_CurrentPath.SetPath(reply))
	{
		if (reply != _T(""))
			LogMessage(__TFILE__, __LINE__, this, Debug_Warning, _T("Failed to parse returned path."));
		else
			LogMessage(__TFILE__, __LINE__, this, Debug_Warning, _T("Server returned empty path."));

		if (!defaultPath.IsEmpty())
		{
			LogMessage(Debug_Warning, _T("Assuming path is '%s'."), defaultPath.GetPath().c_str());
			m_CurrentPath = defaultPath;
			return true;
		}
		return false;
	}

	return true;
}
예제 #18
0
void CLogging::LogMessage(wxString SourceFile, int nSourceLine, void *pInstance, MessageType nMessageType, const wxChar *msgFormat, ...) const
{
	InitLogFile();

	const int debugLevel = m_pEngine->GetOptions()->GetOptionVal(OPTION_LOGGING_DEBUGLEVEL);
	switch (nMessageType)
	{
	case Debug_Warning:
		if (!debugLevel)
			return;
		break;
	case Debug_Info:
		if (debugLevel < 2)
			return;
		break;
	case Debug_Verbose:
		if (debugLevel < 3)
			return;
		break;
	case Debug_Debug:
		if (debugLevel != 4)
			return;
		break;
	default:
		break;
	}

	int pos = SourceFile.Find('\\', true);
	if (pos != -1)
		SourceFile = SourceFile.Mid(pos+1);

	pos = SourceFile.Find('/', true);
	if (pos != -1)
		SourceFile = SourceFile.Mid(pos+1);

	va_list ap;
    
	va_start(ap, msgFormat);
	wxString text = wxString::FormatV(msgFormat, ap);
	va_end(ap);

	wxString msg = wxString::Format(_T("%s(%d): %s   caller=%p"), SourceFile.c_str(), nSourceLine, text.c_str(), this);

	LogToFile(nMessageType, msg);

	CLogmsgNotification *notification = new CLogmsgNotification;
	notification->msgType = nMessageType;
	notification->msg = msg;
	m_pEngine->AddNotification(notification);
}
예제 #19
0
bool RenameFile(wxWindow* parent, wxString dir, wxString from, wxString to)
{
	if (dir.Right(1) != _T("\\") && dir.Right(1) != _T("/"))
		dir += wxFileName::GetPathSeparator();

#ifdef __WXMSW__
	to = to.Left(255);

	if ((to.Find('/') != -1) ||
		(to.Find('\\') != -1) ||
		(to.Find(':') != -1) ||
		(to.Find('*') != -1) ||
		(to.Find('?') != -1) ||
		(to.Find('"') != -1) ||
		(to.Find('<') != -1) ||
		(to.Find('>') != -1) ||
		(to.Find('|') != -1))
	{
		wxMessageBox(_("Filenames may not contain any of the following characters: / \\ : * ? \" < > |"), _("Invalid filename"), wxICON_EXCLAMATION);
		return false;
	}

	SHFILEOPSTRUCT op;
	memset(&op, 0, sizeof(op));

	from = dir + from + _T(" ");
	from.SetChar(from.Length() - 1, '\0');
	op.pFrom = from;
	to = dir + to + _T(" ");
	to.SetChar(to.Length()-1, '\0');
	op.pTo = to;
	op.hwnd = (HWND)parent->GetHandle();
	op.wFunc = FO_RENAME;
	op.fFlags = FOF_ALLOWUNDO;
	return SHFileOperation(&op) == 0;
#else
	if ((to.Find('/') != -1) ||
		(to.Find('*') != -1) ||
		(to.Find('?') != -1) ||
		(to.Find('<') != -1) ||
		(to.Find('>') != -1) ||
		(to.Find('|') != -1))
	{
		wxMessageBox(_("Filenames may not contain any of the following characters: / * ? < > |"), _("Invalid filename"), wxICON_EXCLAMATION);
		return false;
	}

	return wxRename(dir + from, dir + to) == 0;
#endif
}
예제 #20
0
void frmPgpassConfig::DisplayFile(const wxString &str)
{
	lines.Empty();

	filetype = wxTextFileType_Unix;
	wxStringTokenizer strtok;

	if (str.Find('\r') >= 0)
	{
		if (str.Find(wxT("\n\r")) >= 0 || str.Find(wxT("\r\n")))
			filetype = wxTextFileType_Dos;
		else
			filetype = wxTextFileType_Mac;

		strtok.SetString(wxTextBuffer::Translate(str, wxTextFileType_Unix), wxT("\n"), wxTOKEN_RET_EMPTY);
	}
	else
		strtok.SetString(str, wxT("\n"), wxTOKEN_RET_EMPTY);

	while (strtok.HasMoreTokens())
	{
		pgPassConfigLine *line = new pgPassConfigLine(strtok.GetNextToken());
		lines.Add(line);
	}

	listEdit->DeleteAllItems();

	size_t i;

	for (i = 0 ; i < lines.GetCount() ; i++)
	{
		pgPassConfigLine &line = lines.Item(i);
		int imgIndex = 0;
		if (!line.isComment)
			imgIndex = 1;
		long pos = listEdit->AppendItem(imgIndex, line.hostname);

		listEdit->SetItem(pos, 1, line.port);
		listEdit->SetItem(pos, 2, line.database);
		listEdit->SetItem(pos, 3, line.username);
		listEdit->SetItem(pos, 4, line.password.IsEmpty() ? wxT("") : wxT("*********"));
		line.item = pos;
	}
	if (!i || !lines.Item(i - 1).text.IsEmpty())
	{
		pgPassConfigLine *line = new pgPassConfigLine();
		lines.Add(line);
		line->item = listEdit->AppendItem(0, wxString(wxEmptyString));
	}
}
bool EDA_PATTERN_MATCH_WILDCARD::SetPattern( const wxString& aPattern )
{
    // Compile the wildcard string to a regular expression
    wxString regex;
    regex.Alloc( 2 * aPattern.Length() );   // no need to keep resizing, we know the size roughly

    const wxString to_replace = wxT( ".*+?^${}()|[]/\\" );

    for( wxString::const_iterator it = aPattern.begin(); it < aPattern.end(); ++it )
    {
        wxUniChar c = *it;
        if( c == '?' )
        {
            regex += wxT( "." );
        }
        else if( c == '*' )
        {
            regex += wxT( ".*" );
        }
        else if( to_replace.Find( c ) != wxNOT_FOUND )
        {
            regex += "\\";
            regex += c;
        }
        else
        {
            regex += c;
        }
    }

    return EDA_PATTERN_MATCH_REGEX::SetPattern( regex );
}
예제 #22
0
파일: Options.cpp 프로젝트: Typz/FileZilla
bool COptions::GetServer(wxString path, CServer& server)
{
	if (path.empty())
		return false;

	if (!m_pXmlFile)
		return false;
	TiXmlElement *element = m_pXmlFile->GetElement();

	while (!path.empty()) {
		wxString sub;
		int pos = path.Find('/');
		if (pos != -1) {
			sub = path.Left(pos);
			path = path.Mid(pos + 1);
		}
		else {
			sub = path;
			path = _T("");
		}
		wxScopedCharBuffer utf8 = sub.utf8_str();
		if (!utf8)
			return false;
		element = element->FirstChildElement(utf8);
		if (!element)
			return false;
	}

	bool res = ::GetServer(element, server);

	return res;
}
예제 #23
0
wxString wxHtmlBookRecord::GetFullPath(const wxString &page) const
{
    if (wxIsAbsolutePath(page) || page.Find(wxT("file:")) == 0)
        return page;
    else
        return m_BasePath + page;
}
static bool hasOneOf( const wxString& str, const wxString& chars )
{
    for( unsigned i=0; i<chars.Len();  ++i )
        if( str.Find( chars[i] ) != wxNOT_FOUND )
            return true;
    return false;
}
예제 #25
0
wxTreeItemId CLocalTreeView::MakeSubdirs(wxTreeItemId parent, wxString dirname, wxString subDir)
{
	const wxString& separator = wxFileName::GetPathSeparator();

	while (subDir != _T(""))
	{
		int pos = subDir.Find(separator);
		wxString segment;
		if (pos == -1)
		{
			segment = subDir;
			subDir = _T("");
		}
		else
		{
			segment = subDir.Left(pos);
			subDir = subDir.Mid(pos + 1);
		}

		DisplayDir(parent, dirname, segment);

		wxTreeItemId item = GetSubdir(parent, segment);
		if (!item)
			return wxTreeItemId();

		parent = item;
		dirname += segment + separator;
	}

	// Not needed, stays unexpanded by default
	// DisplayDir(parent, dirname);
	return parent;
}
예제 #26
0
bool wxTerminal::CheckForCD( const wxString &command, wxString &path )
{
	if ( command.IsEmpty() )               return false; // Returning true tells caller there's nothing else to do
	if ( command.Left(2) != wxT("cd") )    return false; // Not a cd attempt so return false so that RunCommand takes over
	if ( wxIsalpha( command.GetChar(2) ) ) return false; // This must be a real command beginning with cd???

	if ( command == wxT("cd.") || command == wxT("cd .") )  {
		path = wxGetCwd();
		return true;
	}

	if ( command == wxT("cd") || command == wxT("cd~") || command == wxT("cd ~") ) {
		path = wxGetHomeDir();
		return true;

	} else if ( command.Find(wxT("&&")) != wxNOT_FOUND ) {
		// a complex command: cd <somewhere> && ...
		return false;

	} else {
		// Otherwise it should be a real dir. Remove the initial cd, plus any white-space
		path = command.Mid( 2 );
		path << wxFileName::GetPathSeparator();
		path.Trim(false);
		wxFileName fn(path);
		fn.MakeAbsolute(m_workingDir);
		fn.Normalize();
		if( fn.DirExists() ) {
			path = fn.GetFullPath();
			return true;
		}
		return false;
	}
}
예제 #27
0
long CMuleListCtrl::InsertColumn(long col, const wxString& heading, int format, int width, const wxString& name)
{
	if (!name.IsEmpty()) {
#ifdef __DEBUG__
		// Check for valid names
		wxASSERT_MSG(name.Find(wxT(':')) == wxNOT_FOUND, wxT("Column name \"") + name + wxT("\" contains invalid characters!"));
		wxASSERT_MSG(name.Find(wxT(',')) == wxNOT_FOUND, wxT("Column name \"") + name + wxT("\" contains invalid characters!"));

		// Check for uniqueness of names.
		for (ColNameList::const_iterator it = m_column_names.begin(); it != m_column_names.end(); ++it) {
			if (name == it->name) {
				wxFAIL_MSG(wxT("Column name \"") + name + wxT("\" is not unique!"));
			}
		}
#endif
		// Insert name at position col.
		ColNameList::iterator it = m_column_names.begin();
		while (it != m_column_names.end() && it->index < col) {
			++it;
		}
		m_column_names.insert(it, ColNameEntry(col, width, name));
		while (it != m_column_names.end()) {
			++it;
			++(it->index);
		}
	}

	return MuleExtern::wxGenericListCtrl::InsertColumn(col, heading, format, width);
}
예제 #28
0
void EventWatcherFrame::addEvents(wxString& s)
{
    // deselect all items so user can cleanly see what is added
    for (int ix = 0; ix < (int)listbox_monitored->GetCount(); ++ix)
    {
        if (listbox_monitored->IsSelected(ix))
            listbox_monitored->Deselect(ix);
    }
    while (true)
    {
        int p = s.Find("\n");
        wxString s2;
        if (p == -1)
            s2 = s.Strip();
        else
        {
            s2 = s.Left(p).Strip(wxString::both);
            s.Remove(0, p);
            s.Trim(false);
        }
        if (!s2.IsEmpty() && listbox_monitored->FindString(s2) == wxNOT_FOUND)
            listbox_monitored->Select(listbox_monitored->Append(s2));
        if (p == -1)
            break;
    }
    updateControls();
}
예제 #29
0
bool XMLValueChecker::IsGoodFileString(wxString str)
{
   return (IsGoodString(str) && 
            !str.IsEmpty() && 
            (str.Length() <= 260) && // FILENAME_MAX is 260 in MSVC, but inconsistent across platforms, sometimes huge.
            (str.Find(wxFileName::GetPathSeparator()) == -1)); // No path separator characters. //vvv (this won't work on CVS HEAD)
}
예제 #30
0
/* checks if the value is a valid time interval, format HH:MM-HH:MM */
bool CDlgAdvPreferences::IsValidTimeIntervalValue(const wxString& value) {
    for(unsigned int i=0; i < value.Length();i++) {
        if(!IsValidTimeIntervalChar(value[i])) {
            return false;
        }
    }
    //all chars are valid, now what is with the value as a whole ?
    //check for -
    if(value.Find('-')<0) {
        return false;
    }
    //split up into start and stop
    wxString start = value.BeforeFirst('-');
    wxString stop = value.AfterFirst('-');
    //validate start and stop parts
    if(!IsValidTimeValue(start) || !IsValidTimeValue(stop)) {
        return false;
    }
    //ensure that start is lower than stop
    wxDateTime dtStart,dtStop;
    dtStart.ParseFormat(start,wxT("%H:%M"));
    dtStop.ParseFormat(stop,wxT("%H:%M"));
    //
    /*if(dtStart>=dtStop) {
        return false;
    }*/
    return true;
}