当前位置: 首页>>代码示例>>C++>>正文


C++ wxString::Mid方法代码示例

本文整理汇总了C++中wxString::Mid方法的典型用法代码示例。如果您正苦于以下问题:C++ wxString::Mid方法的具体用法?C++ wxString::Mid怎么用?C++ wxString::Mid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wxString的用法示例。


在下文中一共展示了wxString::Mid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawParagraph

void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y)
{
    long width, height ;
  
    if (paragraph.Length() == 0)
    {
        // empty line
        dc.GetTextExtent( wxT("H"), &width, &height );
        y += height;
        
        return;
    }

    int x = 0 ;

    bool linedrawn = true;
    while( paragraph.Length() > 0 )
    {
        dc.GetTextExtent( paragraph , &width , &height ) ;
        
        if ( width > m_width )
        {
            for ( size_t p = paragraph.Length() - 1 ; p > 0 ; --p )
            {
                if ((punct.Find(paragraph[p]) != wxNOT_FOUND) || !linedrawn)
                {
                    int blank = (paragraph[p] == ' ') ? 0 : 1;
                    
                    dc.GetTextExtent( paragraph.Left(p + blank) , &width , &height ) ;
                    
                    if ( width <= m_width )
                    {
                        int pos = x ;
                        if ( HasFlag( wxALIGN_CENTER ) )
                        {
                            pos += ( m_width - width ) / 2 ;
                        }
                        else if ( HasFlag( wxALIGN_RIGHT ) )
                        {
                            pos += ( m_width - width ) ;
                        }
                        
                        dc.DrawText( paragraph.Left(p + blank), pos , y) ;
                        y += height ;
                        paragraph = paragraph.Mid(p+1) ;
                        linedrawn = true;
                        break ;
                    }
                }
            }
            
            linedrawn = false;
        }
        else
        {
            int pos = x ;
            if ( HasFlag( wxALIGN_CENTER ) )
            {
                pos += ( m_width - width ) / 2 ;
            }
            else if ( HasFlag( wxALIGN_RIGHT ) )
            {
                pos += ( m_width - width ) ;
            }
            
            dc.DrawText( paragraph, pos , y) ;
            paragraph=wxEmptyString;
            y += height ;
        }
    }
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:71,代码来源:stattext.cpp

示例2: if

/** This function determines the caracteristics of a given strLine (bCode strLine, bComment strLine etc...).
 *  It is called by the "CountLines" function.
 *  @see CountLines
 */
void Counter::analyseLine2(CounterRule* pRule, wxString strLine, bool& bScriptMode, bool &bComment, bool &bCode, bool &bDelimitedCommentMode)
{
    int nIdxFirstScriptBegin, nIdxFirstScriptEnd;
    int nIdxFirstSglLnComm, nIdxFirstMltLnCommBegin, nIdxFirstMltLnCommEnd;

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

    if (strLine.IsEmpty())
        return;

    //
    // Searching for script signs
    //
    if (pRule->m_strScriptBegin.Len() > 0)
        nIdxFirstScriptBegin = strLine.Find(pRule->m_strScriptBegin);
    else nIdxFirstScriptBegin = -1;
    if (pRule->m_strScriptEnd.Len() > 0)
        nIdxFirstScriptEnd = strLine.Find(pRule->m_strScriptEnd);
    else nIdxFirstScriptEnd = -1;

    //
    // Searching for single and multi-lines bComment signs
    //
    if (pRule->m_strSglLnComm.Len() > 0)
        nIdxFirstSglLnComm = strLine.Find(pRule->m_strSglLnComm);
    else nIdxFirstSglLnComm = -1;
    if (pRule->m_strMltLnCommBegin.Len() > 0)
        nIdxFirstMltLnCommBegin = strLine.Find(pRule->m_strMltLnCommBegin);
    else nIdxFirstMltLnCommBegin = -1;
    if (pRule->m_strMltLnCommEnd.Len() > 0)
        nIdxFirstMltLnCommEnd = strLine.Find(pRule->m_strMltLnCommEnd);
    else nIdxFirstMltLnCommEnd = -1;

    //
    // Analyse
    //


    if (bScriptMode)
    {
        // We are in a multiple strLine Comment => finding the "end of multiple Line Comment" sign
        if (bDelimitedCommentMode)
        {
            bComment = true;
            if (nIdxFirstMltLnCommEnd > -1)
            {
                bDelimitedCommentMode = false;
                if (nIdxFirstMltLnCommEnd + pRule->m_strMltLnCommEnd.Len() < strLine.Length())
                    analyseLine2(pRule, strLine.Mid(nIdxFirstMltLnCommEnd + pRule->m_strMltLnCommEnd.Length()),
                                 bScriptMode, bComment, bCode, bDelimitedCommentMode);
            }
        }
        // We are not in a multiple strLine bComment
        else if (!bDelimitedCommentMode)
        {
            // First bComment sign found is a single strLine bComment sign
            if ( (nIdxFirstSglLnComm>-1)
                    &&((nIdxFirstMltLnCommBegin==-1)
                       ||((nIdxFirstMltLnCommBegin>-1)&&(nIdxFirstSglLnComm<nIdxFirstMltLnCommBegin))) )
            {
                bComment = true;
                if (nIdxFirstSglLnComm > 0)
                    bCode = true;
            }
            // First bComment sign found is a multi-strLine bComment begin sign
            else if (nIdxFirstMltLnCommBegin>-1)
            {
                bDelimitedCommentMode = true;
                bComment = true;
                if (nIdxFirstMltLnCommBegin > 0)
                    bCode = true;
                if (nIdxFirstMltLnCommBegin+pRule->m_strMltLnCommBegin.Len() < strLine.Length())
                    analyseLine2(pRule, strLine.Mid(nIdxFirstMltLnCommBegin + pRule->m_strMltLnCommBegin.Length()),
                                 bScriptMode, bComment, bCode, bDelimitedCommentMode);
            }
            else
            {
                bCode = true;
            }
        }

    }
    else if (!bScriptMode)
    {
        if (nIdxFirstScriptBegin > -1)
        {
            bScriptMode = true;

            if (nIdxFirstScriptEnd > -1)
            {
                bScriptMode = false;
                if (nIdxFirstScriptEnd + pRule->m_strScriptEnd.Len() < strLine.Len())
//.........这里部分代码省略.........
开发者ID:BrightFireOfCy001,项目名称:boomworks,代码行数:101,代码来源:Counter.cpp

示例3: Init

void pgHbaConfigLine::Init(const wxString &line)
{
	connectType = PGC_INVALIDCONF;
	changed = false;

	if (line.IsEmpty())
		return;

	text = line;

	const wxChar *p0 = line.c_str();

	if (*p0 == '#')
	{
		isComment = true;
		p0++;
		SkipSpace(p0);
	}
	else
		isComment = false;


	const wxChar *p1 = p0;
	SkipNonspace(p1);

	wxString str = line.Mid(p0 - line.c_str(), p1 - p0);

	int i = FindToken(str, pgHbaConnectTypeStrings);

	if (i >= 0)
		connectType = (pgHbaConnectType)i;
	else
	{
		connectType = PGC_INVALIDCONF;
		isComment = true;
		return;
	}

	SkipSpace(p1);

	const wxChar *p2 = p1;
	bool quoted = false;

	while (*p2)
	{
		if (!quoted && IsSpaceChar(*p2))
			break;
		if (*p2 == '"')
			quoted = !quoted;
		p2++;
	}

	database = line.Mid(p1 - line.c_str(), p2 - p1);

	SkipSpace(p2);

	const wxChar *p3 = p2;

	quoted = false;
	while (*p3)
	{
		if (!quoted && IsSpaceChar(*p3))
			break;
		if (*p3 == '"')
			quoted = !quoted;
		p3++;
	}

	user = line.Mid(p2 - line.c_str(), p3 - p2);

	SkipSpace(p3);

	const wxChar *p4 = p3;

	if (connectType == PGC_LOCAL)
	{
		// no ip address
	}
	else
	{
		bool hasCidr = false;
		while (*p4 && !IsSpaceChar(*p4))
		{
			if (*p4 == '/')
				hasCidr = true;
			p4++;
		}
		if (!hasCidr)
		{
			SkipSpace(p4);
			SkipNonspace(p4);
		}

		ipaddress = line.Mid(p3 - line.c_str(), p4 - p3);
		SkipSpace(p4);
	}

	const wxChar *p5 = p4;
	SkipNonspace(p5);

//.........这里部分代码省略.........
开发者ID:Timosha,项目名称:pgadmin3,代码行数:101,代码来源:pgconfig.cpp

示例4: MakeFirstCharLowerCase

wxString CRCppEmitter::MakeFirstCharLowerCase (const wxString &str) const
{
    wxString firstChar = str.Mid(0, 1).Lower();
    return firstChar + str.Mid(1);
}
开发者ID:cedrus-opensource,项目名称:build_oss_deps,代码行数:5,代码来源:CRCppEmitter.cpp

示例5: GetBookmarks

bool CSiteManager::GetBookmarks(wxString sitePath, std::list<wxString> &bookmarks)
{
	wxChar c = sitePath[0];
	if (c != '0' && c != '1')
		return false;

	sitePath = sitePath.Mid(1);

	// We have to synchronize access to sitemanager.xml so that multiple processed don't write
	// to the same file or one is reading while the other one writes.
	CInterProcessMutex mutex(MUTEX_SITEMANAGER);

	CXmlFile file;
	TiXmlElement* pDocument = 0;

	if (c == '0')
		pDocument = file.Load(_T("sitemanager"));
	else
	{
		const wxString& defaultsDir = wxGetApp().GetDefaultsDir();
		if (defaultsDir == _T(""))
			return false;
		pDocument = file.Load(wxFileName(defaultsDir, _T("fzdefaults.xml")));
	}

	if (!pDocument)
	{
		wxMessageBox(file.GetError(), _("Error loading xml file"), wxICON_ERROR);

		return false;
	}

	TiXmlElement* pElement = pDocument->FirstChildElement("Servers");
	if (!pElement)
		return false;

	std::list<wxString> segments;
	if (!UnescapeSitePath(sitePath, segments))
	{
		wxMessageBox(_("Site path is malformed."), _("Invalid site path"));
		return 0;
	}

	TiXmlElement* pChild = GetElementByPath(pElement, segments);
	if (!pChild || strcmp(pChild->Value(), "Server"))
		return 0;

	// Bookmarks
	for (TiXmlElement* pBookmark = pChild->FirstChildElement("Bookmark"); pBookmark; pBookmark = pBookmark->NextSiblingElement("Bookmark"))
	{
		TiXmlHandle handle(pBookmark);

		wxString name = GetTextElement_Trimmed(pBookmark, "Name");
		if (name.empty())
			continue;

		wxString localPath;
		CServerPath remotePath;
		TiXmlText* localDir = handle.FirstChildElement("LocalDir").FirstChild().Text();
		if (localDir)
			localPath = ConvLocal(localDir->Value());
		TiXmlText* remoteDir = handle.FirstChildElement("RemoteDir").FirstChild().Text();
		if (remoteDir)
			remotePath.SetSafePath(ConvLocal(remoteDir->Value()));

		if (localPath.empty() && remotePath.IsEmpty())
			continue;

		bookmarks.push_back(name);
	}

	return true;
}
开发者ID:Hellcenturion,项目名称:MILF,代码行数:73,代码来源:sitemanager.cpp

示例6: NaturalCompare

wxInt32 NaturalCompare(wxString String1, wxString String2, bool CaseSensitive = false)
{
    wxInt32 StringCounter1 = 0, StringCounter2 = 0;
    wxInt32 String1Zeroes = 0, String2Zeroes = 0;
    wxChar String1Char, String2Char;
    wxInt32 Result;

    if (!CaseSensitive)
    {
        String1.MakeLower();
        String2.MakeLower();
    }

    while (true)
    {
        String1Zeroes = 0;
        String2Zeroes = 0;

        String1Char = String1[StringCounter1];
        String2Char = String2[StringCounter2];

        // skip past whitespace or zeroes in first string
        while (wxIsspace(String1Char) || String1Char == '0' )
        {
            if (String1Char == '0')
            {
                String1Zeroes++;
            }
            else
            {
                String1Zeroes = 0;
            }

            String1Char = String1[++StringCounter1];
        }

        // skip past whitespace or zeroes in second string
        while (wxIsspace(String2Char) || String2Char == '0')
        {
            if (String2Char == '0')
            {
                String2Zeroes++;
            }
            else
            {
                String2Zeroes = 0;
            }

            String2Char = String2[++StringCounter2];
        }

        // We encountered some digits, compare these.
        if (wxIsdigit(String1Char) && wxIsdigit(String2Char))
        {
            if ((Result = NaturalCompareWorker(
                              String1.Mid(StringCounter1),
                              String2.Mid(StringCounter2))) != 0)
            {
                return Result;
            }
        }

        if ((String1Char == 0) && (String2Char == 0))
        {
            return (String1Zeroes - String2Zeroes);
        }

        if (String1Char < String2Char)
        {
            return -1;
        }
        else if (String1Char > String2Char)
        {
            return 1;
        }

        ++StringCounter1;
        ++StringCounter2;
    }
}
开发者ID:darkranger-red,项目名称:odamex-maemo5,代码行数:80,代码来源:lst_custom.cpp

示例7: PartialPacketDynamicString

 PartialPacketDynamicString( const wxString &pkt )
 {
     if( pkt.size() > 2 )
         Tokenize( pkt.Mid(1,pkt.size()-2) );
 }
开发者ID:GeorgeBenjaminBailey,项目名称:ripe,代码行数:5,代码来源:partialpacket.hpp

示例8: GetCountryCodeOnly

wxString Localization::GetCountryCodeOnly(const wxString& canonicalName) {
  if (canonicalName.Len() <= 2) return wxEmptyString;
  return canonicalName.Mid(3, 2);
}
开发者ID:DocWhoChat,项目名称:appetizer,代码行数:4,代码来源:Localization.cpp

示例9: SubstringCookie

     /**
      * COOKIE文字列の切り出し処理を行う
      */
     void SubstringCookie(wxString& cookie) {
	  if (cookie.Len() > 0) {
	       cookie = cookie.Mid(0, cookie.Find(wxT(";")));
	  }
     };
开发者ID:Hiroyuki-Nagata,项目名称:JaneClone,代码行数:8,代码来源:socketcommunication.hpp

示例10: hdrToke

myAttachment::myAttachment(wxString sData)
:   m_sContentType(wxT("text/html")),
    m_pData(0L),
    m_dataLen(0L)
{
    wxString sTmpFile;
    wxString        sHeader;
    wxArrayString   sHeadArray;
    wxString        sContentType;
    wxString        sTmp, sTmp2;

    size_t lastOffset;

#ifdef  ENABLE_FORM_DUMP
    /* Dump the file to temporary file */
    if (!(sTmpFile = wxFileName::CreateTempFileName(wxT("att"), &m_tmpFile)).IsEmpty()) {
        D(debug("Created temporary file %s\n", sTmpFile.c_str()));

        if (m_tmpFile.IsOpened()) {
            m_tmpFile.Write( sData.GetData(), sData.Length() );
            m_tmpFile.Close();
    }
}
#endif

    wxStringTokenizer       partToke( sData, wxT("\n"));

    while ((sHeader = partToke.GetNextToken()) != wxT("\r")) {
        //D(debug("-- header %s\n", sHeader.c_str()));

        sHeadArray.Add( sHeader );

        wxStringTokenizer hdrToke( sHeader, wxT(":") );

        sTmp = hdrToke.GetNextToken();
        //D(debug("-- sTMP %s\n", sTmp.c_str()));

        if (sTmp.CmpNoCase(wxT("content-disposition")) == 0) {
            wxString sFields = hdrToke.GetNextToken();
            //D(debug("-- found content disposition!\n"));

            sFields.Trim(true);
            sFields.Trim(false);

            //D(debug("fields = [%s]\n", sFields.c_str()));

            wxStringTokenizer attributes( sFields, wxT(";") );

            sTmp2 = attributes.GetNextToken();
            sTmp2.Trim(true);
            sTmp2.Trim(false);

//            D(debug("sTmp2 = [%s]\n", sTmp2.c_str()));

            if (sTmp2.CmpNoCase(wxT("form-data")) == 0) {
                while (attributes.HasMoreTokens()) {
                    wxString sAttName, sAttValue;
                    wxString subAttr = attributes.GetNextToken().Trim(false).Trim();

                    //D(debug("---- sub attribute = %s\n", subAttr.c_str()));

                    wxStringTokenizer subToke( subAttr, wxT("=") );

                    sAttName = subToke.GetNextToken().Trim(false).Trim();
                    sAttValue = subToke.GetNextToken().Trim(false).Trim();

                    D(debug("Attribute name [%s] value [%s]\n", sAttName.c_str(), sAttValue.c_str()));

                    if (sAttName.CmpNoCase(wxT("name")) == 0) {
                        m_sName = sAttValue;
                        m_sName.Replace(wxT("\""), wxEmptyString);
                    } else if (sAttName.CmpNoCase(wxT("filename")) == 0) {
                        m_sFilename = sAttValue;
                        m_sFilename.Replace(wxT("\""), wxEmptyString);
                    } else {
                        /* */
                    }
                }
            }
        } else if (sTmp.CmpNoCase(wxT("content-type"))  == 0) {
            m_sContentType = hdrToke.GetNextToken().Trim(false).Trim();
            D(debug("-- Found content type of %s\n", m_sContentType.c_str()));
        }

    }
    lastOffset = partToke.GetPosition();

    //D(debug("-- last offset @ %ld\n", lastOffset));

    sData = sData.Mid( lastOffset );

    m_pData     = (unsigned char*)malloc( sData.Length() );
    m_dataLen   = sData.Length();

    memcpy( m_pData, sData.GetData(), sData.Length() );

//  write_file();

    return;
}
开发者ID:,项目名称:,代码行数:100,代码来源:

示例11: GetLanguageCodeOnly

wxString Localization::GetLanguageCodeOnly(const wxString& canonicalName) {
  if (canonicalName.Len() < 2) return canonicalName;
  return canonicalName.Mid(0, 2);
}
开发者ID:DocWhoChat,项目名称:appetizer,代码行数:4,代码来源:Localization.cpp

示例12: DrawButtonBarButtonForeground

void wxRibbonMetroArtProvider::DrawButtonBarButtonForeground(
                        wxDC& dc,
                        const wxRect& rect,
                        wxRibbonButtonKind kind,
                        long state,
                        const wxString& label,
                        const wxBitmap& bitmap_large,
                        const wxBitmap& bitmap_small)
{
    switch(state & wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK)
    {
    case wxRIBBON_BUTTONBAR_BUTTON_LARGE:
        {
            const int padding = 2;
            dc.DrawBitmap(bitmap_large,
                rect.x + (rect.width - bitmap_large.GetWidth()) / 2,
                rect.y + padding, true);
            int ypos = rect.y + padding + bitmap_large.GetHeight() + padding;
            int arrow_width = kind == wxRIBBON_BUTTON_NORMAL ? 0 : 8;
            wxCoord label_w, label_h;
            dc.GetTextExtent(label, &label_w, &label_h);
            if(label_w + 2 * padding <= rect.width)
            {
                dc.DrawText(label, rect.x + (rect.width - label_w) / 2, ypos);
                if(arrow_width != 0)
                {
                    DrawDropdownArrow(dc, rect.x + rect.width / 2,
                        ypos + (label_h * 3) / 2,
                        m_button_bar_label_colour);
                }
            }
            else
            {
                size_t breaki = label.Len();
                do
                {
                    --breaki;
                    if(wxRibbonCanLabelBreakAtPosition(label, breaki))
                    {
                        wxString label_top = label.Mid(0, breaki);
                        dc.GetTextExtent(label_top, &label_w, &label_h);
                        if(label_w + 2 * padding <= rect.width)
                        {
                            dc.DrawText(label_top,
                                rect.x + (rect.width - label_w) / 2, ypos);
                            ypos += label_h;
                            wxString label_bottom = label.Mid(breaki + 1);
                            dc.GetTextExtent(label_bottom, &label_w, &label_h);
                            label_w += arrow_width;
                            int iX = rect.x + (rect.width - label_w) / 2;
                            dc.DrawText(label_bottom, iX, ypos);
                            if(arrow_width != 0)
                            {
                                DrawDropdownArrow(dc,
                                    iX + 2 +label_w - arrow_width,
                                    ypos + label_h / 2 + 1,
                                    m_button_bar_label_colour);
                            }
                            break;
                        }
                    }
                } while(breaki > 0);
            }
        }
        break;
    case wxRIBBON_BUTTONBAR_BUTTON_MEDIUM:
        {
            int x_cursor = rect.x + 2;
            dc.DrawBitmap(bitmap_small, x_cursor,
                    rect.y + (rect.height - bitmap_small.GetHeight())/2, true);
            x_cursor += bitmap_small.GetWidth() + 2;
            wxCoord label_w, label_h;
            dc.GetTextExtent(label, &label_w, &label_h);
            dc.DrawText(label, x_cursor,
                rect.y + (rect.height - label_h) / 2);
            x_cursor += label_w + 3;
            if(kind != wxRIBBON_BUTTON_NORMAL)
            {
                DrawDropdownArrow(dc, x_cursor, rect.y + rect.height / 2,
                    m_button_bar_label_colour);
            }
            break;
        }
    default:
        // TODO
        break;
    }
}
开发者ID:05storm26,项目名称:codelite,代码行数:88,代码来源:art_metro.cpp

示例13: DoSearchLine

void SearchThread::DoSearchLine(const wxString& line, const int lineNum, const int lineOffset, const wxString& fileName,
                                const SearchData* data, const wxString& findWhat, const wxArrayString& filters,
                                TextStatesPtr statesPtr)
{
    wxString modLine = line;

    if(!data->IsMatchCase()) { modLine.MakeLower(); }

    int pos = 0;
    int col = 0;
    int iCorrectedCol = 0;
    int iCorrectedLen = 0;
    while(pos != wxNOT_FOUND) {
        pos = modLine.Find(findWhat);
        if(pos != wxNOT_FOUND) {
            col += pos;

            // Pipe support
            bool allFiltersOK = true;
            if(!filters.IsEmpty()) {
                // Apply the filters
                for(size_t i = 0; i < filters.size() && allFiltersOK; ++i) {
                    allFiltersOK = (modLine.Find(filters.Item(i)) != wxNOT_FOUND);
                }
            }

            // Pipe filtes OK?
            if(!allFiltersOK) return;

            // we have a match
            if(data->IsMatchWholeWord()) {

                // make sure that the word before is not in the wordChars map
                if((pos > 0) && (m_wordCharsMap.find(modLine.GetChar(pos - 1)) != m_wordCharsMap.end())) {
                    if(!AdjustLine(modLine, pos, findWhat)) {

                        break;
                    } else {
                        col += (int)findWhat.Length();
                        continue;
                    }
                }
                // if we have more characters to the right, make sure that the first char does not match any
                // in the wordCharsMap
                if(pos + findWhat.Length() <= modLine.Length()) {
                    wxChar nextCh = modLine.GetChar(pos + findWhat.Length());
                    if(m_wordCharsMap.find(nextCh) != m_wordCharsMap.end()) {
                        if(!AdjustLine(modLine, pos, findWhat)) {

                            break;
                        } else {
                            col += (int)findWhat.Length();
                            continue;
                        }
                    }
                }
            }

            // Notify our match
            // correct search Pos and Length owing to non plain ASCII multibyte characters
            iCorrectedCol = FileUtils::UTF8Length(line.c_str(), col);
            iCorrectedLen = FileUtils::UTF8Length(findWhat.c_str(), findWhat.Length());
            SearchResult result;
            result.SetPosition(lineOffset + col);
            result.SetColumnInChars(col);
            result.SetColumn(iCorrectedCol);
            result.SetLineNumber(lineNum);
            // Dont use match pattern larger than 500 chars
            result.SetPattern(line.length() > 500 ? line.Mid(0, 500) : line);
            result.SetFileName(fileName);
            result.SetLenInChars((int)findWhat.Length());
            result.SetLen(iCorrectedLen);
            result.SetFindWhat(data->GetFindString());
            result.SetFlags(data->m_flags);

            int position(wxNOT_FOUND);
            bool canAdd(true);

            if(statesPtr) {
                position = statesPtr->LineToPos(lineNum - 1);
                position += iCorrectedCol;
            }

            // Make sure our match is not on a comment
            if(statesPtr && position != wxNOT_FOUND && data->GetSkipComments()) {
                if(statesPtr->states.size() > (size_t)position) {
                    short state = statesPtr->states.at(position).state;
                    if(state == CppWordScanner::STATE_CPP_COMMENT || state == CppWordScanner::STATE_C_COMMENT) {
                        canAdd = false;
                    }
                }
            }

            if(statesPtr && position != wxNOT_FOUND && data->GetSkipStrings()) {
                if(statesPtr->states.size() > (size_t)position) {
                    short state = statesPtr->states.at(position).state;
                    if(state == CppWordScanner::STATE_DQ_STRING || state == CppWordScanner::STATE_SINGLE_STRING) {
                        canAdd = false;
                    }
                }
//.........这里部分代码省略.........
开发者ID:eranif,项目名称:codelite,代码行数:101,代码来源:search_thread.cpp

示例14: WrapText

bool CWrapEngine::WrapText(wxWindow* parent, wxString& text, unsigned long maxLength)
{
	/*
	This function wraps the given string so that it's width in pixels does
	not exceed maxLength.
	In the general case, wrapping is done on word boundaries. Thus we scan the
	string for spaces, measuer the length of the words and wrap if line becomes
	too long.
	It has to be done wordwise, as with some languages/fonts, the width in
	pixels of a line is smaller than the sum of the widths of every character.

	A special case are some languages, e.g. Chinese, which don't separate words
	with spaces. In such languages it is allowed to break lines after any
	character.

	Though there are a few exceptions:
	- Don't wrap before punctuation marks
	- Wrap embedded English text fragments only on spaces

	For this kind of languages, a different wrapping algorithm is used.
	*/

	if (!m_font.IsOk())
		m_font = parent->GetFont();

#ifdef __WXDEBUG__
	const wxString original = text;
#endif

	if (m_wrapOnEveryChar)
	{
		bool res = WrapTextChinese(parent, text, maxLength);
#ifdef __WXDEBUG__
		wxString unwrapped = UnwrapText(text);
		wxASSERT(original == unwrapped);
#endif
		return res;
	}

	wxString wrappedText;

	int width = 0, height = 0;

	int spaceWidth = 0;
	parent->GetTextExtent(_T(" "), &spaceWidth, &height, 0, 0, &m_font);

	int strLen = text.Length();
	int wrapAfter = -1;
	int start = 0;
	unsigned int lineLength = 0;

	bool url = false;
	bool containsURL = false;
	for (int i = 0; i <= strLen; i++)
	{
		if ((text[i] == ':' && text[i + 1] == '/' && text[i + 2] == '/') || // absolute
			(text[i] == '/' && (!i || text[i - 1] == ' '))) // relative
		{
			url = true;
			containsURL = true;
		}
		if (text[i] != ' ' && text[i] != 0)
		{
			// If url, wrap on slashes and ampersands, but not first slash of something://
			if (!url ||
				 ((text[i] != '/' || text[i + 1] == '/') && (text[i] != '&' || text[i + 1] == '&') && text[i] != '?'))
			continue;
		}

		wxString segment;
		if (wrapAfter == -1)
		{
			if (text[i] == '/' || text[i] == '?' || text[i] == '&')
				segment = text.Mid(start, i - start + 1);
			else
				segment = text.Mid(start, i - start);
			wrapAfter = i;
		}
		else
		{
			if (text[i] == '/' || text[i] == '?' || text[i] == '&')
				segment = text.Mid(wrapAfter + 1, i - wrapAfter);
			else
				segment = text.Mid(wrapAfter + 1, i - wrapAfter - 1);
		}

		segment = wxStripMenuCodes(segment);
		parent->GetTextExtent(segment, &width, &height, 0, 0, &m_font);

		if (lineLength + spaceWidth + width > maxLength)
		{
			// Cannot be appended to current line without overflow, so start a new line
			if (wrappedText != _T(""))
				wrappedText += _T("\n");
			wrappedText += text.Mid(start, wrapAfter - start);
			if (text[wrapAfter] != ' ' && text[wrapAfter] != '\0')
				wrappedText += text[wrapAfter];

			if (width + spaceWidth >= (int)maxLength)
			{
//.........这里部分代码省略.........
开发者ID:madnessw,项目名称:thesnow,代码行数:101,代码来源:wrapengine.cpp

示例15: ProcSocketData

void DebugManager::ProcSocketData(wxString data) {
    if (data.StartsWith("subtitulo ")) {
        subtitles->AddMessage(current_line,current_inst,data.Mid(10));
    }
    if (data.StartsWith("proceso ")) {
        current_proc_name=data.Mid(8);
    } else if (data.StartsWith("linea ")) {
        long l=-1,i=-1;
        if (data.Contains(":")) {
            data.Mid(6).BeforeFirst(':').ToLong(&l);
            data.AfterLast(':').ToLong(&i);
        } else {
            data.Mid(6).ToLong(&l);
        }
        if (l>=0 && source!=NULL) source->SetDebugLine(l-1,i-1);
        if (do_desktop_test) desktop_test->SetLine(current_proc_name,l,i);
        current_line=l;
        current_inst=i;
    } else if (data.StartsWith("autoevaluacion ")) {
        long l=-1;
        data.Mid(15).BeforeFirst(' ').ToLong(&l);
        desktop_test->SetAutoevaluation(l,data.Mid(15).AfterFirst(' '));
    } else if (data.StartsWith("estado ")) {
        wxString state = data.AfterFirst(' ');
        if (state=="inicializado") {
            // cargar la prueba de escritorio
            do_desktop_test=debug_panel->IsDesktopTestEnabled();
            if (do_desktop_test) {
                const wxArrayString &vars  = desktop_test->GetDesktopVars();
                for (unsigned int i=0; i<vars.GetCount(); i++) {
                    wxString str(wxString("autoevaluar ")<<vars[i]<<"\n");
                    socket->Write(str.c_str(),str.Len());
                }
            }
            // configurar el tipo de paso a paso (step in o step over)
            wxString str1("subprocesos ");
            str1<<(step_in?1:0)<<"\n";
            socket->Write(str1.c_str(),str1.Len());
            wxString str2("subtitulos ");
            str2<<(subtitles_on?1:0)<<"\n";
            socket->Write(str2.c_str(),str2.Len());
            // iniciar la ejecución
            if ((paused=should_pause)) {
                wxString str("paso\n");
                socket->Write(str.c_str(),str.Len());
            }	else {
                wxString str("comenzar\n");
                socket->Write(str.c_str(),str.Len());
            }
        } else if (state=="pausa") {
            debug_panel->SetState(DS_PAUSED);
            if (source) source->SetDebugPause();
        } else if (state=="paso")
            debug_panel->SetState(DS_STEP);
        else if (state=="ejecutando")
            debug_panel->SetState(DS_RESUMED);
        else if (state=="finalizado") {
            debug_panel->SetState(DS_FINALIZED);
            if (source) source->SetDebugLine();
        } else {
            if (source) source->SetDebugLine();
            debug_panel->SetState(DS_NONE);
        }
    } else if (data.StartsWith("evaluacion ")) {
        RunLambda(data.AfterFirst(' ').BeforeFirst(' '),data.AfterFirst(' ').AfterFirst(' '));
    }
}
开发者ID:retrography,项目名称:git-import-test,代码行数:67,代码来源:DebugManager.cpp


注:本文中的wxString::Mid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。