Exemplo n.º 1
0
// Splits m_Word into up to three parts according to selection, returns
// substring before, in and after selection and the points (in relative coords)
// where s2 and s3 start:
void wxHtmlWordCell::Split(wxDC& dc,
                           const wxPoint& selFrom, const wxPoint& selTo,
                           unsigned& pos1, unsigned& pos2) const
{
    wxPoint pt1 = (selFrom == wxDefaultPosition) ?
                  wxDefaultPosition : selFrom - GetAbsPos();
    wxPoint pt2 = (selTo == wxDefaultPosition) ?
                  wxPoint(m_Width, wxDefaultCoord) : selTo - GetAbsPos();

    wxCoord charW, charH;
    unsigned len = m_Word.length();
    unsigned i = 0;
    pos1 = 0;

    // adjust for cases when the start/end position is completely
    // outside the cell:
    if ( pt1.y < 0 )
        pt1.x = 0;
    if ( pt2.y >= m_Height )
        pt2.x = m_Width;

    // before selection:
    while ( pt1.x > 0 && i < len )
    {
        dc.GetTextExtent(m_Word[i], &charW, &charH);
        pt1.x -= charW;
        if ( pt1.x >= 0 )
        {
            pos1 += charW;
            i++;
        }
    }

    // in selection:
    unsigned j = i;
    pos2 = pos1;
    pt2.x -= pos2;
    while ( pt2.x > 0 && j < len )
    {
        dc.GetTextExtent(m_Word[j], &charW, &charH);
        pt2.x -= charW;
        if ( pt2.x >= 0 )
        {
            pos2 += charW;
            j++;
        }
    }

    pos1 = i;
    pos2 = j;
}
Exemplo n.º 2
0
void CUITextBox::OnRender( CDrawPort* pDraw )
{
	if( m_bHide == TRUE )
		return;

	int		nX, nY;
	GetAbsPos( nX, nY );

	if (m_pTexData != NULL && m_pBackground != NULL)
	{
		pDraw->InitTextureData( m_pTexData );

		m_pBackground->SetPos(nX, nY);
		m_pBackground->RenderRectSurface( pDraw, DEF_UI_COLOR_WHITE );

		pDraw->FlushRenderingQueue();
	}

	if ( m_pScroll )
		m_pScroll->OnRender( pDraw );

	_RenderString(pDraw, nX, nY);

#ifdef UI_TOOL
	RenderBorder(pDraw);
#endif // UI_TOOL
}
Exemplo n.º 3
0
// ----------------------------------------------------------------------------
// Name : Render()
// Desc :
// ----------------------------------------------------------------------------
void CUICheckButton::Render()
{
	// Get position
	int	nX, nY;
	GetAbsPos( nX, nY );

	// Add render regions
	int	nUVIndex;
	if( m_bChecked )
		nUVIndex = UCBS_CHECK;
	else
		nUVIndex = UCBS_NONE;

	CDrawPort* pDrawPort = CUIManager::getSingleton()->GetDrawPort();

	if(m_bValidText)
	{
		if( IsEnabled() )
		{
			pDrawPort->PutTextEx( m_strText, nX + m_nTextSX, nY + m_nTextSY, m_colText[1] );
		}
		else
		{
			pDrawPort->PutTextEx( m_strText, nX + m_nTextSX, nY + m_nTextSY, m_colText[0] );
			nUVIndex += 2;
		}
	}

	pDrawPort->AddTexture( nX, nY, nX + m_nWidth, nY + m_nHeight,
										m_rtUV[nUVIndex].U0, m_rtUV[nUVIndex].V0,
										m_rtUV[nUVIndex].U1, m_rtUV[nUVIndex].V1,
										0xFFFFFFFF );
}
Exemplo n.º 4
0
void CUIImageSplit::OnRender( CDrawPort* pDraw )
{
	if( m_bHide == TRUE )
		return;

	if( m_pTexData == NULL )
	{
#ifdef UI_TOOL
		RenderBorder(pDraw);
#endif // UI_TOOL
		return;
	}

	pDraw->InitTextureData( m_pTexData );

	int	nX, nY;
	GetAbsPos( nX, nY );

	if (_pSurface != NULL)
	{
		_pSurface->SetPos(nX, nY);
		_pSurface->RenderRectSurface(pDraw, m_color);
	}

	pDraw->FlushRenderingQueue();
#ifdef UI_TOOL
	RenderBorder(pDraw);
#endif // UI_TOOL
}
Exemplo n.º 5
0
void CUIBase::RenderBorder(CDrawPort* pDraw)
{
    if (m_bSelect == false)
        return;

    int		nX, nY;
    GetAbsPos(nX, nY);

    pDraw->DrawBorder((PIX)nX - 1, (PIX)nY - 1, (PIX)m_nWidth + 1, (PIX)m_nHeight + 1, 0xFF0000FF);
}
Exemplo n.º 6
0
void CUIImageBox::PopupRender()
{
	CUIManager* pUIManager = CUIManager::getSingleton();
	CDrawPort* pDrawPort = CUIManager::getSingleton()->GetDrawPort();

	int	nX, nY;
	GetAbsPos( nX, nY );
	
	int nX0 = nX + m_rtRenderRegion.Left;
	int nX1 = nX + m_rtRenderRegion.Right;
	int nY0 = nY + m_rtRenderRegion.Top;
	int nY1 = nY + m_rtRenderRegion.Bottom;

	int rtRenderRegionMiddle = nX + (m_rtRenderRegion.Left + m_rtRenderRegion.Right) / 2;
	int nRegionHeight = m_rtRenderRegion.Bottom - m_rtRenderRegion.Top;
		
	if ( m_bShowPopup )	
	{
		pDrawPort->InitTextureData( m_ptdPopup );
		
		int nAlineSize	= m_vecString.size();
		int nPopHeight	= 10 - _pUIFontTexMgr->GetLineSpacing() + (nAlineSize+1) * _pUIFontTexMgr->GetLineHeight();
		int nPopX = rtRenderRegionMiddle - (m_nPopWidth/2);
		int nPopY = nY0 - nPopHeight;
	
		if( nPopX < pUIManager->GetMinI() )
		{
			nPopX = pUIManager->GetMinI();
		}
		else if (nPopX + m_nPopWidth > pUIManager->GetMaxI())
		{
			nPopX = pUIManager->GetMaxI() - m_nPopWidth;
		}
		
		if (nPopY < pUIManager->GetMinJ())
		{
			nPopY = nY + nRegionHeight;
		}
		
		m_bxPopupInfo.SetBoxPos(WRect(nPopX-nX, nPopY-nY, nPopX-nX+m_nPopWidth, nPopY-nY+nPopHeight ));
		m_bxPopupInfo.Render(nX,nY);

		std::vector<CTString>::iterator b = m_vecString.begin();
		
		for (int i = 0; b != m_vecString.end(); b++, i++)
		{
			pDrawPort->PutTextEx( *b, nPopX+20, nPopY+6+(i*14), m_colText );
		}
		pDrawPort->FlushRenderingQueue();
		pDrawPort->EndTextEx();		
	}
}
Exemplo n.º 7
0
void CUISpinControl::OnRender( CDrawPort* pDraw )
{
	
	if (m_pBackImage != NULL)
	{
		int nX, nY;
		GetAbsPos(nX, nY);

		m_pBackImage->SetPos(nX + m_rcBackPos.Left, nY + m_rcBackPos.Top);

		m_pBackImage->OnRender(pDraw);
	}

	CUIEditBox::OnRender(pDraw);
}
Exemplo n.º 8
0
void CUIImageArray::OnRender( CDrawPort* pDraw )
{
    if (m_bHide == TRUE)
        return;

    if (m_pTexData == NULL)
    {
#ifdef UI_TOOL
        RenderBorder(pDraw);
#endif // UI_TOOL
        return;
    }

    if (m_bDepthMode == TRUE)
        pDraw->InitTextureData( m_pTexData, FALSE, PBT_BLEND, TRUE );
    else
        pDraw->InitTextureData( m_pTexData);

    if (m_nRenderIdx >= 0 && m_nRenderIdx < m_vecData.size())
    {
        UIRect rc = m_vecData[m_nRenderIdx].rc;
        UIRectUV uv = m_vecData[m_nRenderIdx].uv;

        int	nX, nY;
        GetAbsPos( nX, nY );

        pDraw->AddTexture( nX + rc.Left, nY + rc.Top, nX + rc.Left + rc.Right, nY + rc.Top + rc.Bottom,
                           uv.U0, uv.V0, uv.U1, uv.V1, m_color, m_fDepth );

        pDraw->FlushRenderingQueue();
    }

#ifdef UI_TOOL
    RenderBorder(pDraw);
#endif // UI_TOOL
}
Exemplo n.º 9
0
void CUIImageBox::Render()
{
	// Get position
	int	nX, nY;
	GetAbsPos( nX, nY );

	int nX0 = nX + m_rtRenderRegion.Left;
	int nX1 = nX + m_rtRenderRegion.Right;
	int nY0 = nY + m_rtRenderRegion.Top;
	int nY1 = nY + m_rtRenderRegion.Bottom;
	float fU0 = m_rtUV.U0 + (m_rtUV.U1 - m_rtUV.U0) * m_rtRenderRegion.Left / float(m_nWidth);
	float fU1 = m_rtUV.U0 + (m_rtUV.U1 - m_rtUV.U0) * m_rtRenderRegion.Right / float(m_nWidth);
	float fV0 = m_rtUV.V0 + (m_rtUV.V1 - m_rtUV.V0) * m_rtRenderRegion.Top / float(m_nHeight);
	float fV1 = m_rtUV.V0 + (m_rtUV.V1 - m_rtUV.V0) * m_rtRenderRegion.Bottom / float(m_nHeight);

	CDrawPort* pDrawPort = CUIManager::getSingleton()->GetDrawPort();

	if(m_eImageType == IT_GENERAL)
	{
		pDrawPort->InitTextureData( m_ptdBaseTexture );
		pDrawPort->AddTexture(nX0, nY0, nX1, nY1,
											fU0, fV0,
											fU1, fV1,
											0xFFFFFFFF );
		pDrawPort->FlushRenderingQueue();
	}
	else if (m_eImageType == IT_CORPS)
	{
		pDrawPort->InitTextureData( m_ptdCorps );
		pDrawPort->AddTexture(nX0, nY0, nX1, nY1,
											fU0, fV0,
											fU1, fV1,
											0xFFFFFFFF );
		pDrawPort->FlushRenderingQueue();
	}
	else
	{
		UIBtnExType bet;
		switch(m_eImageType)
		{
			case IT_EXP:
			case IT_MONEY:
			case IT_ITEM:
			case IT_SP:		// [090617: selo] SP 이미지 타입
			case IT_RVR_POINT:
				bet = UBET_ITEM;
				break;
			case IT_SKILL:
			case IT_SSKILL:
			case IT_AFFINITY: // 친화도 개편2 친화도 타입 추가 [2/7/2013 Ranma]
				bet = UBET_SKILL;
				break;
			case IT_ACTION:
				bet = UBET_ACTION;
				break;
			case IT_AFFINITY_MONSTER:
				bet = UBET_COMBO;				
				break;
		}
		pDrawPort->AddBtnTexture(m_nTextureID, nX0, nY0, nX1, nY1,
											fU0, fV0,
											fU1, fV1,
											0xFFFFFFFF );
		pDrawPort->FlushBtnRenderingQueue( bet, PBT_BLEND );

		if(m_bHighlight)
		{
			pDrawPort->AddBtnTexture(m_nTextureID, nX0, nY0, nX1, nY1,
												fU0, fV0,
												fU1, fV1,
												m_colHighlight );

			// Render all button elements
			pDrawPort->FlushBtnRenderingQueue( bet, PBT_ADD );
		}
	}
}
Exemplo n.º 10
0
void CUITrackPopup::Render()
{
	if( !IsVisible() ) return;
	if( m_vecString.size() <= 0 ) return;

	CDrawPort* pDrawPort = CUIManager::getSingleton()->GetDrawPort();

#if defined G_RUSSIA
	// [2011/05/17 : Sora] 팝업창에서 스트링을 쓰지 않을 경우 글자 길이가 0이되어 팝업창 사이즈가 줄어든다
	if( m_strLongestStringInMenu.Length() > 0 )
	{
		Resize( pDrawPort->GetTextWidth( m_strLongestStringInMenu ) );		
	}
#endif

	// 배경 렌더
	int	nX, nY;
	UIRect m_rcBack;

	GetAbsPos( nX, nY );
	m_rcBack.SetRect( nX, nY, nX + m_nWidth, nY + m_nHeight );

	// Item Back region
	pDrawPort->AddTexture( m_rcBack.Left, m_rcBack.Top,
										m_rcBack.Left + 7, m_rcBack.Top + 7,
										m_rtBackUL.U0, m_rtBackUL.V0, m_rtBackUL.U1, m_rtBackUL.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Left + 7, m_rcBack.Top,
										m_rcBack.Right - 7, m_rcBack.Top + 7,
										m_rtBackUM.U0, m_rtBackUM.V0, m_rtBackUM.U1, m_rtBackUM.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Right - 7, m_rcBack.Top,
										m_rcBack.Right, m_rcBack.Top + 7,
										m_rtBackUR.U0, m_rtBackUR.V0, m_rtBackUR.U1, m_rtBackUR.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Left, m_rcBack.Top + 7,
										m_rcBack.Left + 7, m_rcBack.Bottom - 7,
										m_rtBackML.U0, m_rtBackML.V0, m_rtBackML.U1, m_rtBackML.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Left + 7, m_rcBack.Top + 7,
										m_rcBack.Right - 7, m_rcBack.Bottom - 7,
										m_rtBackMM.U0, m_rtBackMM.V0, m_rtBackMM.U1, m_rtBackMM.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Right - 7, m_rcBack.Top + 7,
										m_rcBack.Right, m_rcBack.Bottom - 7,
										m_rtBackMR.U0, m_rtBackMR.V0, m_rtBackMR.U1, m_rtBackMR.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Left, m_rcBack.Bottom - 7,
										m_rcBack.Left + 7, m_rcBack.Bottom,
										m_rtBackLL.U0, m_rtBackLL.V0, m_rtBackLL.U1, m_rtBackLL.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Left + 7, m_rcBack.Bottom - 7,
										m_rcBack.Right - 7, m_rcBack.Bottom,
										m_rtBackLM.U0, m_rtBackLM.V0, m_rtBackLM.U1, m_rtBackLM.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Right - 7, m_rcBack.Bottom - 7,
										m_rcBack.Right, m_rcBack.Bottom,
										m_rtBackLR.U0, m_rtBackLR.V0, m_rtBackLR.U1, m_rtBackLR.V1,
										0xFFFFFFFF );

	// 원래 리스트 박스에 대한 내용 랜더
	CUIListBox::Render();
	
}
Exemplo n.º 11
0
// ----------------------------------------------------------------------------
// Name : Render()
// Desc :
// ----------------------------------------------------------------------------
void CUIListBoxMultiCol::Render()
{
	// Get position
	int	nX, nY;
	GetAbsPos( nX, nY );

	// Add render regions
	// Selection bar
	if( m_bShowSelectBar && m_nSelectList >= 0 )
	{
		int	nSelLine = m_nSelectList - m_sbScrollBar.GetScrollPos();
		
		if( nSelLine >= 0 )
		{
			if( !m_bScrollBar || nSelLine < m_sbScrollBar.GetScrollRange() )
			{
				int	nBarY = nY + m_nTextSY + nSelLine * m_nLineHeight;
				CUIManager::getSingleton()->GetDrawPort()->AddTexture( nX + m_rcSelectOver.Left, nBarY + m_rcSelectOver.Top,
													nX + m_rcSelectOver.Right, nBarY + m_rcSelectOver.Bottom,
													m_rtSelectOver.U0, m_rtSelectOver.V0,
													m_rtSelectOver.U1, m_rtSelectOver.V1,
													0xFFFFFFFF );
			}
		}
	}

	// Scroll bar
	if( m_bScrollBar )
		m_sbScrollBar.Render();

	// Text in list box
	int		nTextY = nY;// + m_nTextSY;

	int	nRowS = m_sbScrollBar.GetScrollPos();
	int	nRowE = nRowS + m_nLinePerPage;
	if( nRowE > m_vecString.size())
		nRowE = m_vecString.size();

	for( int nCol = nRowS; nCol < nRowE; nCol++ )
	{
		if ( m_vecString[nCol].vecString.empty())
			continue;
		
		COLOR	colText = 0x00000000;		
		int		nSelList = -1, nOverList = -1;
		if( m_bSelectList )
		{
			nSelList = m_nSelectList;
			nOverList = nRowS + m_nOverList;
		}

		int		nTextX = nX;	

		for( int nList = 0; nList < m_nRowCount; nList++ )
		{
			if( !m_vecSelectable.empty() && m_vecSelectable.size () > nCol && IsSelectable(nCol) )
			{
				if( nCol == nSelList )
					colText = m_colSelectList;
				else if( nCol == nOverList )
					colText = m_colOverList;
				else
				{
					if ( nList < m_vecColor[nCol].vecColor.size())
						colText = m_vecColor[nCol].vecColor[nList];
					
				}
			}
			else
			{
				if ( nList < m_vecColor[nCol].vecColor.size())
						colText = m_vecColor[nCol].vecColor[nList];
			}

			if ( m_vecAlign.size() > nList )
			{			
				DrawText ( nCol, nList,nTextX, nTextY, m_vecAlign[nList], colText );
			}
			else
				DrawText ( nCol, nList,nTextX, nTextY, TEXT_LEFT, colText );
			
			if ( m_vecRowWidht.size () > nList )
				nTextX += m_vecRowWidht[nList];
			else 
				nTextX += _pUIFontTexMgr->GetFontWidth()* 20;
		}
		nTextY += m_nLineHeight;
	}
}
Exemplo n.º 12
0
void CUICheckButton::OnRender( CDrawPort* pDraw )
{
	if( m_pTexData == NULL )
	{
#ifdef UI_TOOL
		RenderBorder(pDraw);
#endif // UI_TOOL
		return;
	}

	// Add render regions
	int	nUVIndex;
	if( m_bChecked )
		nUVIndex = UCBS_CHECK;
	else
		nUVIndex = UCBS_NONE;

	// Get position
	int	nX, nY;
	GetAbsPos( nX, nY );

	pDraw->InitTextureData( m_pTexData );

	pDraw->AddTexture( nX, nY, nX + m_nWidth, nY + m_nHeight,
		m_rtUV[nUVIndex].U0, m_rtUV[nUVIndex].V0,
		m_rtUV[nUVIndex].U1, m_rtUV[nUVIndex].V1,
		0xFFFFFFFF );

	pDraw->FlushRenderingQueue();

	if (m_bHighlightOn == true)
	{
		pDraw->InitTextureData(m_pTexData, FALSE, PBT_ADD);
		
		pDraw->AddTexture( nX, nY, nX + m_nWidth, nY + m_nHeight,
			m_rtUV[nUVIndex].U0, m_rtUV[nUVIndex].V0,
			m_rtUV[nUVIndex].U1, m_rtUV[nUVIndex].V1,
			m_colHighlight );

		pDraw->FlushRenderingQueue();
	}

	int		outX = 0;

	if(m_bValidText)
	{
		if (m_eAlignText_h == eALIGN_H_CENTER)
		{
			int str_width = pDraw->GetTextWidth2(m_strText);
			outX += (m_nTextArea - str_width) / 2;
		}
		else if (m_eAlignText_h == eALIGN_H_RIGHT)
		{
			int str_width = pDraw->GetTextWidth2(m_strText);
			outX = m_nTextArea - str_width;
		}	

		if (m_bTextEdge == true)
		{
			pDraw->PutTextEx( m_strText, nX + m_nTextSX + outX-1, nY + m_nTextSY-1, DEF_UI_FONT_SHADOW_COLOR );
			pDraw->PutTextEx( m_strText, nX + m_nTextSX + outX+1, nY + m_nTextSY-1, DEF_UI_FONT_SHADOW_COLOR );
			pDraw->PutTextEx( m_strText, nX + m_nTextSX + outX+1, nY + m_nTextSY+1, DEF_UI_FONT_SHADOW_COLOR );
			pDraw->PutTextEx( m_strText, nX + m_nTextSX + outX-1, nY + m_nTextSY+1, DEF_UI_FONT_SHADOW_COLOR );
		}

		pDraw->PutTextEx( m_strText, nX + m_nTextSX + outX, nY + m_nTextSY, m_colText[nUVIndex] );

		pDraw->EndTextEx();
	}	
#ifdef UI_TOOL
	RenderBorder(pDraw);

	// Text Area
	if (m_bSelect)
		pDraw->DrawBorder( (PIX)(nX + m_nTextSX - 1), (PIX)(nY - 1), (PIX)m_nTextArea+1, (PIX)m_nHeight+1, 0xFFB90FFF );
#endif // UI_TOOL
}
Exemplo n.º 13
0
// ----------------------------------------------------------------------------
// Name : Render()
// Desc :
// ----------------------------------------------------------------------------
void CUIListBox::Render()
{
	// Get position
	int	nX, nY;
	GetAbsPos( nX, nY );

	CDrawPort* pDrawPort = CUIManager::getSingleton()->GetDrawPort();
	
	// Add render regions
	// Selection bar
	if( m_bShowSelectBar && m_nSelectList >= 0 )
	{
		int	nSelLine = m_nSelectList - m_sbScrollBar.GetScrollPos();
		
		if( nSelLine >= 0 )
		{
			if( !m_bScrollBar || nSelLine < m_sbScrollBar.GetScrollRange() )
			{
			
				int	nBarY = nY + m_nTextSY + nSelLine * m_nLineHeight;
				pDrawPort->AddTexture( nX + m_rcSelectOver.Left, nBarY + m_rcSelectOver.Top,
													nX + m_rcSelectOver.Right, nBarY + m_rcSelectOver.Bottom,
													m_rtSelectOver.U0, m_rtSelectOver.V0,
													m_rtSelectOver.U1, m_rtSelectOver.V1,
													0xFFFFFFFF );
			}
		}
	}

	// Scroll bar
	if( m_bScrollBar )
		m_sbScrollBar.Render();

	// Text in list box
	for( int nCol = 0; nCol < m_vecString.size(); nCol++ )
	{
		int	nRowS = m_sbScrollBar.GetScrollPos();
		int	nRowE = nRowS + m_nLinePerPage;
		if( nRowE > m_vecString[nCol].vecString.size() )
			nRowE = m_vecString[nCol].vecString.size();

		COLOR	colText;
		int		nTextX = nX + m_nTextSX + m_vecColumnSX[nCol];
		int		nTextY = nY + m_nTextSY;
		int		nSelList = -1, nOverList = -1;
		if( m_bSelectList )
		{
			nSelList = m_nSelectList;
			nOverList = nRowS + m_nOverList;
		}

		for( int nList = nRowS; nList < nRowE; nList++ )
		{
			if( m_vecSelectable[nList] )
			{
				if( nList == nSelList )
					colText = m_colSelectList;
				else if( nList == nOverList )
					colText = m_colOverList;
				else
					colText = m_vecColor[nCol].vecColor[nList];
			}
			else
				colText = m_vecColor[nCol].vecColor[nList];

			switch( m_vecAlign[nCol] )
			{
			case TEXT_LEFT:
				pDrawPort->PutTextEx( m_vecString[nCol].vecString[nList], nTextX, nTextY, colText );
				if (m_vecBold[nCol].vecBold[nList])
					pDrawPort->PutTextEx( m_vecString[nCol].vecString[nList], nTextX+1, nTextY, colText );
				break;
			case TEXT_CENTER:
				pDrawPort->PutTextExCX( m_vecString[nCol].vecString[nList], nTextX, nTextY, colText );
				if (m_vecBold[nCol].vecBold[nList])
					pDrawPort->PutTextExCX( m_vecString[nCol].vecString[nList], nTextX+1, nTextY, colText );
				break;
			case TEXT_RIGHT:
				pDrawPort->PutTextExRX( m_vecString[nCol].vecString[nList], nTextX, nTextY, colText );
				if (m_vecBold[nCol].vecBold[nList])
					pDrawPort->PutTextExRX( m_vecString[nCol].vecString[nList], nTextX+1, nTextY, colText );
				break;
			}

			nTextY += m_nLineHeight;
		}
	}
}
Exemplo n.º 14
0
// Splits m_Word into up to three parts according to selection, returns
// substring before, in and after selection and the points (in relative coords)
// where s2 and s3 start:
void wxHtmlWordCell::Split(const wxDC& dc,
                           const wxPoint& selFrom, const wxPoint& selTo,
                           unsigned& pos1, unsigned& pos2) const
{
    wxPoint pt1 = (selFrom == wxDefaultPosition) ?
                  wxDefaultPosition : selFrom - GetAbsPos();
    wxPoint pt2 = (selTo == wxDefaultPosition) ?
                  wxPoint(m_Width, wxDefaultCoord) : selTo - GetAbsPos();

    // if the selection is entirely within this cell, make sure pt1 < pt2 in
    // order to make the rest of this function simpler:
    if ( selFrom != wxDefaultPosition && selTo != wxDefaultPosition &&
            selFrom.x > selTo.x )
    {
        wxPoint tmp = pt1;
        pt1 = pt2;
        pt2 = tmp;
    }

    unsigned len = m_Word.length();
    unsigned i = 0;
    pos1 = 0;

    // adjust for cases when the start/end position is completely
    // outside the cell:
    if ( pt1.y < 0 )
        pt1.x = 0;
    if ( pt2.y >= m_Height )
        pt2.x = m_Width;

    // before selection:
    // (include character under caret only if in first half of width)
#ifdef __WXMAC__
    // implementation using PartialExtents to support fractional widths
    wxArrayInt widths ;
    dc.GetPartialTextExtents(m_Word,widths) ;
    while( i < len && pt1.x >= widths[i] )
        i++ ;
    if ( i < len )
    {
        int charW = (i > 0) ? widths[i] - widths[i-1] : widths[i];
        if ( widths[i] - pt1.x < charW/2 )
            i++;
    }
#else // !__WXMAC__
    wxCoord charW, charH;
    while ( pt1.x > 0 && i < len )
    {
        dc.GetTextExtent(m_Word[i], &charW, &charH);
        pt1.x -= charW;
        if ( pt1.x >= -charW/2 )
        {
            pos1 += charW;
            i++;
        }
    }
#endif // __WXMAC__/!__WXMAC__

    // in selection:
    // (include character under caret only if in first half of width)
    unsigned j = i;
#ifdef __WXMAC__
    while( j < len && pt2.x >= widths[j] )
        j++ ;
    if ( j < len )
    {
        int charW = (j > 0) ? widths[j] - widths[j-1] : widths[j];
        if ( widths[j] - pt2.x < charW/2 )
            j++;
    }
#else // !__WXMAC__
    pos2 = pos1;
    pt2.x -= pos2;
    while ( pt2.x > 0 && j < len )
    {
        dc.GetTextExtent(m_Word[j], &charW, &charH);
        pt2.x -= charW;
        if ( pt2.x >= -charW/2 )
        {
            pos2 += charW;
            j++;
        }
    }
#endif // __WXMAC__/!__WXMAC__

    pos1 = i;
    pos2 = j;

    wxASSERT( pos2 >= pos1 );
}
Exemplo n.º 15
0
void CUIText::OnRender( CDrawPort* pDraw )
{
    if( m_bHide == TRUE )
        return;

    int		nX, nY;
    GetAbsPos( nX, nY );

    if (m_pTexData != NULL)
    {
        if (m_pBackground != NULL)
        {
            pDraw->InitTextureData( m_pTexData );

            m_pBackground->SetPos(nX, nY);
            m_pBackground->RenderRectSurface( pDraw, DEF_UI_COLOR_WHITE );

            pDraw->FlushRenderingQueue();
        }
    }

    int		outX = nX;

    if (m_eAlignText_h == eALIGN_H_CENTER)
    {
        int str_width = pDraw->GetTextWidth2(m_strView);
        outX += (m_nWidth - str_width) / 2;
    }
    else if (m_eAlignText_h == eALIGN_H_RIGHT)
    {
        int str_width = pDraw->GetTextWidth2(m_strView);
        outX = outX + m_nWidth - str_width;
    }

    if (m_vecData.size() <= 0)
    {
        if (m_bShadow == FALSE && m_bEdge == TRUE)
        {
            pDraw->PutTextEx( m_strView, outX-1, nY-1, m_colShadow, m_fZ );
            pDraw->PutTextEx( m_strView, outX+1, nY-1, m_colShadow, m_fZ );
            pDraw->PutTextEx( m_strView, outX+1, nY+1, m_colShadow, m_fZ );
            pDraw->PutTextEx( m_strView, outX-1, nY+1, m_colShadow, m_fZ );
        }

        pDraw->PutTextEx( m_strView, outX, nY, m_color, m_fZ, m_bShadow, m_colShadow );
    }
    else
    {
        CTString str;
        COLOR col;

        for (int i = 0; i < m_vecData.size(); ++i)
        {
            str = m_vecData[i].str.c_str();
            col = m_vecData[i].col;

            if (i > 0)
                outX += pDraw->GetTextWidth2(m_vecData[i - 1].str.c_str());

            if (m_bShadow == FALSE && m_bEdge == TRUE)
            {
                pDraw->PutTextEx( str, outX-1, nY-1, m_colShadow, m_fZ );
                pDraw->PutTextEx( str, outX+1, nY-1, m_colShadow, m_fZ );
                pDraw->PutTextEx( str, outX+1, nY+1, m_colShadow, m_fZ );
                pDraw->PutTextEx( str, outX-1, nY+1, m_colShadow, m_fZ );
            }

            pDraw->PutTextEx( str, outX, nY, col, m_fZ, m_bShadow, m_colShadow );
        }
    }

    pDraw->EndTextEx();
#ifdef UI_TOOL
    RenderBorder(pDraw);
#endif // UI_TOOL
}