• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetCharWidth函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetCharWidth函数的典型用法代码示例。如果您正苦于以下问题:C++ GetCharWidth函数的具体用法?C++ GetCharWidth怎么用?C++ GetCharWidth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: str

wxSize wxListBox::DoGetBestClientSize() const
{
    // find the widest string
    int wLine;
    int wListbox = 0;
    for (unsigned int i = 0; i < m_noItems; i++)
    {
        wxString str(GetString(i));
        GetTextExtent(str, &wLine, NULL);
        if ( wLine > wListbox )
            wListbox = wLine;
    }

    // give it some reasonable default value if there are no strings in the
    // list
    if ( wListbox == 0 )
        wListbox = 6*GetCharWidth();

    // the listbox should be slightly larger than the widest string
    wListbox += 3*GetCharWidth();

    // add room for the scrollbar
    wListbox += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);

    // don't make the listbox too tall (limit height to 10 items) but don't
    // make it too small neither
    int hListbox = SendMessage(GetHwnd(), LB_GETITEMHEIGHT, 0, 0)*
                    wxMin(wxMax(m_noItems, 3), 10);

    return wxSize(wListbox, hListbox);
}
开发者ID:CodeTickler,项目名称:wxWidgets,代码行数:31,代码来源:listbox.cpp


示例2: StringToUTFCharList

void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::iterator format,
                       std::vector<FontMetaChar>::iterator end,
                       float size, Math::Point pos, float width, int eol, Color color)
{
    m_engine->SetState(ENG_RSTATE_TEXT);

    float start = pos.x;

    unsigned int fmtIndex = 0;

    std::vector<UTF8Char> chars;
    StringToUTFCharList(text, chars, format, end);
    for (auto it = chars.begin(); it != chars.end(); ++it)
    {
        FontType font = FONT_COLOBOT;
        if (format + fmtIndex != end)
            font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);

        UTF8Char ch = *it;

        float offset = pos.x - start;
        float cw = GetCharWidth(ch, font, size, offset);
        if (offset + cw > width)  // exceeds the maximum width?
        {
            ch = TranslateSpecialChar(CHAR_SKIP_RIGHT);
            cw = GetCharWidth(ch, font, size, offset);
            pos.x = start + width - cw;
            color = Color(1.0f, 0.0f, 0.0f);
            DrawCharAndAdjustPos(ch, font, size, pos, color);
            break;
        }

        FontHighlight hl = static_cast<FontHighlight>(format[fmtIndex] & FONT_MASK_HIGHLIGHT);
        if (hl != FONT_HIGHLIGHT_NONE)
        {
            Math::Point charSize;
            charSize.x = GetCharWidth(ch, font, size, offset);
            charSize.y = GetHeight(font, size);
            DrawHighlight(hl, pos, charSize);
        }

        DrawCharAndAdjustPos(ch, font, size, pos, color);

        // increment fmtIndex for each byte in multibyte character
        if ( ch.c1 != 0 )
            fmtIndex++;
        if ( ch.c2 != 0 )
            fmtIndex++;
        if ( ch.c3 != 0 )
            fmtIndex++;
    }

    if (eol != 0)
    {
        FontType font = FONT_COLOBOT;
        UTF8Char ch = TranslateSpecialChar(eol);
        color = Color(1.0f, 0.0f, 0.0f);
        DrawCharAndAdjustPos(ch, font, size, pos, color);
    }
}
开发者ID:Tellus,项目名称:colobot,代码行数:60,代码来源:text.cpp


示例3: WindowSetCursor

void WindowSetCursor (PCONINFO con, int x, int y, bool IsKanji)
{
    if (IsKanji)
        ChangeCaretSize (con->hWnd, GetCCharWidth (), GetCharHeight ());
    else
        ChangeCaretSize (con->hWnd, GetCharWidth (), GetCharHeight ());
    SetCaretPos (con->hWnd, x * GetCharWidth (), y * GetCharHeight ());
}
开发者ID:channinglan,项目名称:MINIGUI_1.3.3,代码行数:8,代码来源:paint.c


示例4: FPDFText_ProcessInterObj

int FPDFText_ProcessInterObj(const CPDF_TextObject* pPrevObj, const CPDF_TextObject* pObj)
{
    if(FPDFText_IsSameTextObject(pPrevObj, pObj)) {
        return -1;
    }
    CPDF_TextObjectItem item;
    int nItem = pPrevObj->CountItems();
    pPrevObj->GetItemInfo(nItem - 1, &item);
    FX_WCHAR preChar = 0, curChar = 0;
    CFX_WideString wstr = pPrevObj->GetFont()->UnicodeFromCharCode(item.m_CharCode);
    if(wstr.GetLength()) {
        preChar = wstr.GetAt(0);
    }
    FX_FLOAT last_pos = item.m_OriginX;
    int nLastWidth = GetCharWidth(item.m_CharCode, pPrevObj->GetFont());
    FX_FLOAT last_width = nLastWidth * pPrevObj->GetFontSize() / 1000;
    last_width = FXSYS_fabs(last_width);
    pObj->GetItemInfo(0, &item);
    wstr = pObj->GetFont()->UnicodeFromCharCode(item.m_CharCode);
    if(wstr.GetLength()) {
        curChar = wstr.GetAt(0);
    }
    int nThisWidth = GetCharWidth(item.m_CharCode, pObj->GetFont());
    FX_FLOAT this_width = nThisWidth * pObj->GetFontSize() / 1000;
    this_width = FXSYS_fabs(this_width);
    FX_FLOAT threshold = last_width > this_width ? last_width / 4 : this_width / 4;
    CFX_AffineMatrix prev_matrix, prev_reverse;
    pPrevObj->GetTextMatrix(&prev_matrix);
    prev_reverse.SetReverse(prev_matrix);
    FX_FLOAT x = pObj->GetPosX(), y = pObj->GetPosY();
    prev_reverse.Transform(x, y);
    if (FXSYS_fabs(y) > threshold * 2) {
        return 2;
    }
    threshold = (FX_FLOAT)(nLastWidth > nThisWidth ? nLastWidth : nThisWidth);
    threshold = threshold > 400 ? (threshold < 700 ? threshold / 4 :  threshold / 5) : (threshold / 2);
    threshold *= nLastWidth > nThisWidth ? FXSYS_fabs(pPrevObj->GetFontSize()) : FXSYS_fabs(pObj->GetFontSize());
    threshold /= 1000;
    if (FXSYS_fabs(last_pos + last_width - x) > threshold && curChar != L' ' && preChar != L' ')
        if(curChar != L' ' && preChar != L' ') {
            if((x - last_pos - last_width) > threshold || (last_pos - x - last_width) > threshold) {
                return 1;
            }
            if(x < 0 && (last_pos - x - last_width) > threshold) {
                return 1;
            }
            if((x - last_pos - last_width) > this_width || (x - last_pos - this_width) > last_width ) {
                return 1;
            }
        }
    if(last_pos + last_width > x + this_width && curChar == L' ') {
        return 3;
    }
    return 0;
}
开发者ID:151706061,项目名称:PDFium,代码行数:55,代码来源:fpdf_text_search.cpp


示例5: GetNumCols

RECT CBitmapFont::CalculateRect(int id)
{
	RECT rCell;
	rCell.left	= (id % GetNumCols()) * GetCharWidth();
	rCell.top	= (id / GetNumCols()) * GetCharHeight();

	rCell.right		= rCell.left + GetCharWidth();
	rCell.bottom	= rCell.top + GetCharHeight();

	return rCell;
}
开发者ID:jakneute,项目名称:Earthworm-Jim-Full-Sail-Game-Project,代码行数:11,代码来源:CBitmapFont.cpp


示例6: GetCharWidth

wxSize wxRadioBox::GetMaxButtonSize() const
{
    // We use GetCheckBox() because there is no dedicated GetRadioBox() method
    // in wxRendererNative, but check and radio boxes are usually of the same
    // size anyhow. We also add half a character of width to account for the
    // extra space after the radio box itself.
    const int radioWidth =
        wxRendererNative::Get().GetCheckBoxSize(
            reinterpret_cast<wxWindow*>(const_cast<wxRadioBox*>(this))).x
        + GetCharWidth() / 2;

    // calculate the max button size
    int widthMax = 0,
        heightMax = 0;
    const unsigned int count = GetCount();
    for ( unsigned int i = 0 ; i < count; i++ )
    {
        int width, height;
        GetTextExtent(wxGetWindowText((*m_radioButtons)[i]), &width, &height);

        // adjust the size to take into account the radio box itself
        width += radioWidth;
        height *= 3;
        height /= 2;

        if ( widthMax < width )
            widthMax = width;
        if ( heightMax < height )
            heightMax = height;
    }

    return wxSize(widthMax, heightMax);
}
开发者ID:CodeSmithyIDE,项目名称:wxWidgets,代码行数:33,代码来源:radiobox.cpp


示例7: SetExtraStyle

PathProp::PathProp( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos,
        const wxSize& size, long style )
{
    m_opList = NULL;
    m_nSelected = 0;
    m_pEnroutePoint = NULL;
    m_bStartNow = false;
    m_pPath = NULL;

    m_pEnroutePoint = NULL;
    m_bStartNow = false;
#ifdef __WXOSX__
    style |= wxSTAY_ON_TOP;
#endif

    SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS );
    wxDialog::Create( parent, id, caption, pos, size, style );

    wxFont *qFont = OCPNGetFont(_("Dialog"), 0);
    SetFont( *qFont );
        
    CreateControls();

    //  Make an estimate of the dialog size, without scrollbars showing
    wxSize esize;
    esize.x = GetCharWidth() * 110;
    esize.y = GetCharHeight() * 40;
    SetSize( esize );
    Centre();
}
开发者ID:ptulp,项目名称:ocpn_draw_pi,代码行数:30,代码来源:PathProp.cpp


示例8: GetCharWidth

void AISTargetListDialog::RecalculateSize()
{
    if(g_bresponsive){
        //  Make an estimate of the dialog size
        
        wxSize esize;
        esize.x = GetCharWidth() * 110;
        esize.y = GetCharHeight() * 40;
        
        wxSize dsize = gFrame->GetClientSize();
        esize.y = wxMin(esize.y, dsize.y - (4 * GetCharHeight()));
        esize.x = wxMin(esize.x, dsize.x - (2 * GetCharHeight()));
        SetClientSize(esize);
        
        wxSize fsize = GetSize();
        fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
        fsize.x = wxMin(fsize.x, dsize.x - (2 * GetCharHeight()));
        SetSize(fsize);
        
        if( m_pAuiManager ){
            wxAuiPaneInfo &pane = m_pAuiManager->GetPane(_T("AISTargetList"));
        
            if(pane.IsOk()){
                pane.FloatingSize(fsize.x, fsize.y);
                wxPoint pos = gFrame->GetScreenPosition();
                pane.FloatingPosition(pos.x + (dsize.x - fsize.x)/2, pos.y + (dsize.y - fsize.y)/2);
            }
            
            m_pAuiManager->Update();
        }
        
    }
    
}
开发者ID:jieter,项目名称:OpenCPN,代码行数:34,代码来源:AISTargetListDialog.cpp


示例9: GetLabel

wxSize wxRadioButton::DoGetBestSize() const
{
    static int s_radioSize = 0;

    if ( !s_radioSize )
    {
        wxScreenDC dc;
        dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));

        s_radioSize = dc.GetCharHeight();
    }

    wxString str = GetLabel();

    int wRadio, hRadio;
    if ( !str.empty() )
    {
        GetTextExtent(GetLabelText(str), &wRadio, &hRadio);
        wRadio += s_radioSize + GetCharWidth();

        if ( hRadio < s_radioSize )
            hRadio = s_radioSize;
    }
    else
    {
        wRadio = s_radioSize;
        hRadio = s_radioSize;
    }

    wxSize best(wRadio, hRadio);
    CacheBestSize(best);
    return best;
}
开发者ID:ACanadianKernel,项目名称:pcsx2,代码行数:33,代码来源:radiobut.cpp


示例10: zGetCharWidth

BOOL far pascal zGetCharWidth( HDC pp1, UINT pp2, UINT pp3, LPINT pp4 )
{
    BOOL r;

    SaveRegs();
    /*
    ** Log IN Parameters (No Create/Destroy Checking Yet!)
    */
    LogIn( (LPSTR)"APICALL:GetCharWidth HDC+UINT+UINT++",
        pp1, pp2, pp3, (short)0 );

    /*
    ** Call the API!
    */
    RestoreRegs();
    GrovelDS();
    r = GetCharWidth(pp1,pp2,pp3,pp4);
    UnGrovelDS();
    SaveRegs();
    /*
    ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!)
    */
    LogOut( (LPSTR)"APIRET:GetCharWidth BOOL++++ARRAYINT+",
        r, (short)0, (short)0, (short)0, pp4, 1 + pp3 - pp2 );

    RestoreRegs();
    return( r );
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:28,代码来源:trace.c


示例11: GetCount

wxSize wxChoice::DoGetBestSize() const
{
    // find the widest string
    int wChoice = 0;
    const unsigned int nItems = GetCount();
    for ( unsigned int i = 0; i < nItems; i++ )
    {
        int wLine;
        GetTextExtent(GetString(i), &wLine, NULL);
        if ( wLine > wChoice )
            wChoice = wLine;
    }

    // give it some reasonable default value if there are no strings in the
    // list
    if ( wChoice == 0 )
        wChoice = 100;

    // the combobox should be slightly larger than the widest string
    wChoice += 5*GetCharWidth();

    wxSize best(wChoice, EDIT_HEIGHT_FROM_CHAR_HEIGHT(GetCharHeight()));
    CacheBestSize(best);
    return best;
}
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:25,代码来源:choice.cpp


示例12: _InsertWidthArray

static void _InsertWidthArray(HDC hDC,
                              int start,
                              int end,
                              CPDF_Array* pWidthArray) {
  int size = end - start + 1;
  int* widths = FX_Alloc(int, size);
  GetCharWidth(hDC, start, end, widths);
  int i;
  for (i = 1; i < size; i++)
    if (widths[i] != *widths) {
      break;
    }
  if (i == size) {
    int first = pWidthArray->GetInteger(pWidthArray->GetCount() - 1);
    pWidthArray->AddInteger(first + size - 1);
    pWidthArray->AddInteger(*widths);
  } else {
    CPDF_Array* pWidthArray1 = new CPDF_Array;
    pWidthArray->Add(pWidthArray1);
    for (i = 0; i < size; i++) {
      pWidthArray1->AddInteger(widths[i]);
    }
  }
  FX_Free(widths);
}
开发者ID:primiano,项目名称:pdfium-merge,代码行数:25,代码来源:fpdf_edit_doc.cpp


示例13: assert

int CText::Detect(const std::string &text, FontType font, float size, float offset)
{
    assert(font != FONT_BUTTON);

    float pos = 0.0f;
    unsigned int index = 0;
    while (index < text.length())
    {
        UTF8Char ch;

        int len = StrUtils::Utf8CharSizeAt(text, index);
        if (len >= 1)
            ch.c1 = text[index];
        if (len >= 2)
            ch.c2 = text[index+1];
        if (len >= 3)
            ch.c3 = text[index+2];

        index += len;

        if (ch.c1 == '\n')
            return index;

        float width = GetCharWidth(ch, font, size, pos);
        if (offset <= pos + width/2.0f)
            return index;

        pos += width;
    }

    return index;
}
开发者ID:Tellus,项目名称:colobot,代码行数:32,代码来源:text.cpp


示例14: GetTextExtent

wxSize wxListBox::DoGetBestClientSize() const
{
    wxCoord width = 0,
            height = 0;

    size_t count = m_strings->GetCount();
    for ( size_t n = 0; n < count; n++ )
    {
        wxCoord w,h;
        GetTextExtent(this->GetString(n), &w, &h);

        if ( w > width )
            width = w;
        if ( h > height )
            height = h;
    }

    // if the listbox is empty, still give it some non zero (even if
    // arbitrary) size - otherwise, leave small margin around the strings
    if ( !width )
        width = 100;
    else
        width += 3*GetCharWidth();

    if ( !height )
        height = GetCharHeight();

    // we need the height of the entire listbox, not just of one line
    height *= wxMax(count, 7);

    return wxSize(width, height);
}
开发者ID:project-renard-survey,项目名称:chandler,代码行数:32,代码来源:listbox.cpp


示例15: GetCharWidth

wxSize wxRadioBox::GetTotalButtonSize( const wxSize& rSizeBtn ) const
{
    int    nCx1;
    int    nCy1;
    int    nHeight;
    int    nWidth;
    int    nWidthLabel = 0;

    nCx1 = GetCharWidth();
    nCy1 = GetCharHeight();
    nHeight = GetRowCount() * rSizeBtn.y + (2 * nCy1);
    nWidth  = GetColumnCount() * (rSizeBtn.x + nCx1) + nCx1;

    //
    // And also wide enough for its label
    //
    wxString sStr = wxGetWindowText(GetHwnd());
    if (!sStr.empty())
    {
        GetTextExtent( sStr
                      ,&nWidthLabel
                      ,NULL
                     );
        nWidthLabel += 2*nCx1;
    }
    if (nWidthLabel > nWidth)
        nWidth = nWidthLabel;

    wxSize total( nWidth, nHeight );
    return total;
} // end of wxRadioBox::GetTotalButtonSize
开发者ID:LuaDist,项目名称:wxwidgets,代码行数:31,代码来源:radiobox.cpp


示例16: while

float CText::GetStringWidth(const std::string &text,
                            std::vector<FontMetaChar>::iterator format,
                            std::vector<FontMetaChar>::iterator end, float size)
{
    float width = 0.0f;
    unsigned int index = 0;
    unsigned int fmtIndex = 0;
    while (index < text.length())
    {
        FontType font = FONT_COLOBOT;
        if (format + fmtIndex != end)
            font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);

        UTF8Char ch;

        int len = StrUtils::Utf8CharSizeAt(text, index);
        if (len >= 1)
            ch.c1 = text[index];
        if (len >= 2)
            ch.c2 = text[index+1];
        if (len >= 3)
            ch.c3 = text[index+2];

        width += GetCharWidth(ch, font, size, width);

        index += len;
        fmtIndex++;
    }

    return width;
}
开发者ID:Tellus,项目名称:colobot,代码行数:31,代码来源:text.cpp


示例17: dc

wxSize wxDateTimePickerCtrl::DoGetBestSize() const
{
    wxClientDC dc(const_cast<wxDateTimePickerCtrl *>(this));

    // Use the same native format as the underlying native control.
#if wxUSE_INTL
    wxString s = wxDateTime::Now().Format(wxLocale::GetInfo(MSWGetFormat()));
#else // !wxUSE_INTL
    wxString s("XXX-YYY-ZZZZ");
#endif // wxUSE_INTL/!wxUSE_INTL

    // the best size for the control is bigger than just the string
    // representation of the current value because the control must accommodate
    // any date and while the widths of all digits are usually about the same,
    // the width of the month string varies a lot, so try to account for it
    s += wxT("WW");

    int x, y;
    dc.GetTextExtent(s, &x, &y);

    // account for the drop-down arrow or spin arrows
    x += wxSystemSettings::GetMetric(wxSYS_HSCROLL_ARROW_X);

    // and for the checkbox if we have it
    if ( MSWAllowsNone() )
        x += 3*GetCharWidth();

    wxSize best(x, EDIT_HEIGHT_FROM_CHAR_HEIGHT(y));
    CacheBestSize(best);
    return best;
}
开发者ID:chromylei,项目名称:third_party,代码行数:31,代码来源:datetimectrl.cpp


示例18: RenderLine

		void RenderLine(uint8 *pStart, float xOff, float vLineTop, float vLineBottom, int nCursor, int nSelStart, int nSelEnd, View *pcView, bool bSelected)
		{			
			Color32_s sCursCol(40,40,40);
			Color32_s sCursLineCol(255,235,186);
			
			if( ! bSelected )
			{
				sCursCol = lighten_color(sCursCol);
				sCursLineCol = lighten_color(sCursLineCol);
			}
		
			float vCharWidth = GetCharWidth();
			float vCharHeight = GetCharHeight();
			
			uint8 *pEnd = GetBuffer() + GetBufferLength();
			static char zLine[(3 * BYTES_PER_LINE) + 1];
			uint8 *p = pStart;
			for( int x = 0; x < 3 * BYTES_PER_LINE; x+=3 )
			{
				if( p < pEnd )
				{
					zLine[x] = get_nibble_char(*p, true);
					zLine[x + 1] = get_nibble_char(*p, false);
					p++;
				} else {
					zLine[x] = ' ';
					zLine[x + 1] = ' ';
				}
				zLine[x + 2] = ' ';
			}
					
			Rect cRect(xOff + GetX() + 2, vLineTop, xOff + GetX() + GetWidth() - 2, vLineBottom);
			
			pcView->SetFgColor(Color32_s(0,0,0));
							
			if( nSelStart < 0 )
			{				
				if( nCursor >= 0 )
					pcView->FillRect(cRect, sCursLineCol);
				
				pcView->DrawText(cRect, zLine);

				if( nCursor >= 0 )
				{
					float vCursorX = cRect.left + (3 * vCharWidth * nCursor);
					if( m_bSecondChar )
						vCursorX += vCharWidth;
					pcView->SetFgColor(sCursCol);
					pcView->DrawLine(Point(vCursorX, vLineTop), Point(vCursorX, vLineBottom));
					vCursorX++;
					pcView->DrawLine(Point(vCursorX, vLineTop), Point(vCursorX, vLineBottom));
				}
			}
			else
			{
				IPoint cSel1((int)(nSelStart * 3 * vCharWidth), (int)vCharHeight);
				IPoint cSel2((int)((nSelEnd * 3 * vCharWidth) + (vCharWidth * 2)), (int)vCharHeight);
				pcView->DrawSelectedText(cRect, zLine, cSel1, cSel2, SEL_CHAR);
			}
		}
开发者ID:PyroOS,项目名称:Pyro,代码行数:60,代码来源:Column.cpp


示例19: toupper

void CBitmapFont::DrawString(const char* szText, int nPosX, int nPosY)
{
	CSGD_TextureManager* pTM = CSGD_TextureManager::GetInstance();

	//	iterate through the string 1 character at a time
	int length = (int)strlen(szText);

	for (int i=0; i < length; i++)
	{
		//	get ascii value of character
		char ch = szText[i];

		//	make sure character is uppercase
		ch = toupper(ch);

		//	calculate the id on the bitmap using the start char
		int id = ch - GetStartChar();

		//	Make a rect based on an ID
		RECT rLetter = CalculateRect(id);

		//	Draw it to the screen
		pTM->Draw(GetFontImageID(), nPosX + (i*GetCharWidth()), nPosY, 1.0f, 1.0f, &rLetter);
	}
}
开发者ID:jakneute,项目名称:Earthworm-Jim-Full-Sail-Game-Project,代码行数:25,代码来源:CBitmapFont.cpp


示例20: StringToUTFCharList

void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::iterator format,
                       std::vector<FontMetaChar>::iterator end,
                       float size, Math::Point pos, float width, int eol, Color color)
{
    m_engine->SetState(ENG_RSTATE_TEXT);

    float start = pos.x;

    unsigned int fmtIndex = 0;

    std::vector<UTF8Char> chars;
    StringToUTFCharList(text, chars);
    for (auto it = chars.begin(); it != chars.end(); ++it)
    {
        FontType font = FONT_COLOBOT;
        if (format + fmtIndex != end)
            font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);

        // TODO: if (font == FONT_BUTTON)
        if (font == FONT_BUTTON) continue;

        UTF8Char ch = *it;

        float offset = pos.x - start;
        float cw = GetCharWidth(ch, font, size, offset);
        if (offset + cw > width)  // exceeds the maximum width?
        {
            // TODO: special end-of-line char
            break;
        }

        FontHighlight hl = static_cast<FontHighlight>(format[fmtIndex] & FONT_MASK_HIGHLIGHT);
        if (hl != FONT_HIGHLIGHT_NONE)
        {
            Math::Point charSize;
            charSize.x = GetCharWidth(ch, font, size, offset);
            charSize.y = GetHeight(font, size);
            DrawHighlight(hl, pos, charSize);
        }

        DrawCharAndAdjustPos(ch, font, size, pos, color);

        fmtIndex++;
    }

    // TODO: eol
}
开发者ID:xiendev,项目名称:colobot,代码行数:47,代码来源:text.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetCharacterMovement函数代码示例发布时间:2022-05-30
下一篇:
C++ GetCharHeight函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap