Ejemplo n.º 1
0
bool CTextGL::SetText(const char *pchText)
{
  unsigned int uiLength = (unsigned int) strlen(pchText);

  if (m_pchString && uiLength >= m_uiBufferLength)
    {
    // free the previous buffer
    free(m_pchString);
    m_pchString = NULL;
    m_uiBufferLength = 0;
    }

  if (!m_pchString)
    {
    // allocate a bigger buffer
    m_pchString = (char *) malloc(uiLength + 1);
    if (!m_pchString) return false;
    // set the new buffer length
    m_uiBufferLength = uiLength + 1;
    }

  // copy string text into our buffer
  memcpy(m_pchString, pchText, uiLength + 1);

  // calculate the width of this block
  CalculateWidth();

  // all done
  return true;
}
Ejemplo n.º 2
0
void Font::DrawString(int x,int y,int Space,float ext,string String,string Pass,int Position,float Alpha_Speed)
{
	bool isLoaded = false;
	
	int Length = FontIndexs.size();
	int i=0;
	for(i=0;i<Length;i++)
	{
		if(FontIndexs[i] == Pass)
		{
			isLoaded = true;
			break;
		}
	}

	if(!isLoaded)
	{//フォントデータの読み込み
		vector<int> Images;
		for(char Alphabet='A';Alphabet<='Z';Alphabet++)
		{
			char Str[7];
			sprintf_s(Str,7,"/%c.png",Alphabet);
			Images.push_back(LoadGraph((Pass + Str).c_str()));
		}
		FontData.push_back(Images);
		FontIndexs.push_back(Pass);
	}

	int Width = CalculateWidth(0,0,Space,ext,String.c_str(),i);
	DrawString_UseImage(x-(int)(Width * (Position / 2.0)),y,Space,ext,String.c_str(),i);
	
	return;
}
Ejemplo n.º 3
0
void CTextGL::SetFont(eFont eType)
{
  if ((int) eType < 0 || eType >= E_FONT_INVALID) return;

  m_eFont = eType;

  // re-calculate the width
  CalculateWidth();
}
Ejemplo n.º 4
0
bool CTextGL::SetHeight(float fHeight)
{
  if (fHeight <= 0.0f) return false;

  m_fHeight = fHeight;

  // re-calculate the width
  CalculateWidth();
  return true;
}
Ejemplo n.º 5
0
////////////////////
// Create event
int CScrollbar::DoCreate()
{
	CWidget::DoCreate();

	if (iDirection == scrVertical)
		Resize(getX(), getY(), CalculateWidth(), getHeight());
	else
		Resize(getX(), getY(), getWidth(), CalculateHeight());

	return WID_PROCESSED;
}
Ejemplo n.º 6
0
void CXTPPopupItem::FitToContent()
{
    if (m_pRichRender)
    {
        CWindowDC dc(NULL);
        CSize sz = m_pRichRender->GetTextExtent(&dc, m_rcItem.Width());
        m_rcItem.right = m_rcItem.left + sz.cx;
        m_rcItem.bottom = m_rcItem.top + sz.cy;
        return;
    }

    if (m_pUIElement)
    {
        XTPMarkupSetDefaultFont(m_pControl->GetMarkupContext(), (HFONT)GetTextFont()->GetSafeHandle(), COLORREF_NULL);

        CSize sz = XTPMarkupMeasureElement(m_pUIElement, m_rcItem.Width());
        m_rcItem.right = m_rcItem.left + sz.cx;
        m_rcItem.bottom = m_rcItem.top + sz.cy;
        return;
    }

    CalculateWidth();
    CalculateHeight();
}