2040 lines
48 KiB
C++
2040 lines
48 KiB
C++
|
|
#include "StdAfx.h"
|
|||
|
|
#include "EtUITextBox.h"
|
|||
|
|
#include "EtUIDialog.h"
|
|||
|
|
#include "StringUtil.h"
|
|||
|
|
#include "EtUINameLinkMgr.h"
|
|||
|
|
#include "EternityEngine.h"
|
|||
|
|
|
|||
|
|
#ifdef _DEBUG
|
|||
|
|
#define new new(_NORMAL_BLOCK,__FILE__,__LINE__)
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
CEtUITextBox::CEtUITextBox( CEtUIDialog *pParent )
|
|||
|
|
: CEtUIControl( pParent )
|
|||
|
|
, m_nStartLine(-1)
|
|||
|
|
, m_nEndLine(-1)
|
|||
|
|
, m_nCurLine(-1)
|
|||
|
|
, m_nVisibleCount(0)
|
|||
|
|
, m_bAutoScroll(true)
|
|||
|
|
, m_fSymbolWidth(0.0f)
|
|||
|
|
, m_fTextMargin(0.0f)
|
|||
|
|
, m_ScrollBar( pParent )
|
|||
|
|
, m_bUseWordBreak(true)
|
|||
|
|
, m_pNextPageTextBox(NULL)
|
|||
|
|
, m_eNextPageCondition(NextPage_DlgScreenHeight)
|
|||
|
|
, m_nNextPageLineCount(0)
|
|||
|
|
, m_nAdjustValue(0)
|
|||
|
|
, m_bAddTextToNextPage(false)
|
|||
|
|
, m_bNextPage(false)
|
|||
|
|
, m_nMaxLine(200)
|
|||
|
|
, m_RenderTextColor(0)
|
|||
|
|
, m_bUseSelect(false)
|
|||
|
|
{
|
|||
|
|
m_Property.UIType = UI_CONTROL_TEXTBOX;
|
|||
|
|
#ifdef TEXTBOX_RENDERLOCK
|
|||
|
|
m_nRenderingState = 0;
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CEtUITextBox::~CEtUITextBox(void)
|
|||
|
|
{
|
|||
|
|
SAFE_DELETE_PVEC( m_vecLine );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::Initialize( SUIControlProperty *pProperty )
|
|||
|
|
{
|
|||
|
|
CEtUIControl::Initialize( pProperty );
|
|||
|
|
|
|||
|
|
m_ScrollBar.Initialize( NULL );
|
|||
|
|
m_ScrollBar.SetParentControl( this );
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.nScrollBarTemplate != -1 )
|
|||
|
|
{
|
|||
|
|
m_ScrollBar.SetTemplate( m_Property.TextBoxProperty.nScrollBarTemplate );
|
|||
|
|
m_ScrollBar.UpdateRects();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Note : <20>ɺ<EFBFBD><C9BA><EFBFBD> ũ<>⸦ <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
CalcSymbolTextRect();
|
|||
|
|
|
|||
|
|
m_ScrollBar.SetTrackRange( 0, 0 );
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.VariableType == UI_TEXTBOX_HEIGHT ||
|
|||
|
|
m_Property.TextBoxProperty.VariableType == UI_TEXTBOX_BOTH )
|
|||
|
|
{
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ؽ<EFBFBD>Ʈ <20>ڽ<EFBFBD><DABD≯<EFBFBD> <20><>ũ<EFBFBD>ѹٴ<D1B9> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
m_Property.TextBoxProperty.bVerticalScrollBar = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SUIElement *pElement = GetElement(0);
|
|||
|
|
if( pElement )
|
|||
|
|
{
|
|||
|
|
pElement->ShadowFontColor.dwCurrentColor = pElement->ShadowFontColor.dwColor[UI_STATE_NORMAL];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::Render( float fElapsedTime )
|
|||
|
|
{
|
|||
|
|
//if( !IsShow() )
|
|||
|
|
// return;
|
|||
|
|
|
|||
|
|
SUIElement *pElement = GetElement(0);
|
|||
|
|
if( !pElement ) return;
|
|||
|
|
|
|||
|
|
if( m_bExistTemplateTexture )
|
|||
|
|
m_pParent->DrawSprite( m_Template.m_hTemplateTexture, pElement->TemplateUVCoord, pElement->TextureColor.dwCurrentColor, m_Property.UICoord, 0.0f, m_fZValue );
|
|||
|
|
else
|
|||
|
|
m_pParent->DrawSprite( pElement->UVCoord, pElement->TextureColor.dwCurrentColor, m_Property.UICoord, 0.0f, m_fZValue );
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߰<EFBFBD>
|
|||
|
|
//m_pParent->DrawRect( m_Property.UICoord, EtInterface::debug::BLUE );
|
|||
|
|
|
|||
|
|
#ifdef TEXTBOX_RENDERLOCK
|
|||
|
|
InterlockedExchange( &m_nRenderingState, 1 );
|
|||
|
|
#endif
|
|||
|
|
RenderText( fElapsedTime );
|
|||
|
|
#ifdef TEXTBOX_RENDERLOCK
|
|||
|
|
InterlockedExchange( &m_nRenderingState, 0 );
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.bVerticalScrollBar )
|
|||
|
|
{
|
|||
|
|
// Note : <20><><EFBFBD>콺<EFBFBD><ECBDBA> <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD>ϰ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9><EFBFBD><EFBFBD> <20>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
int nOldPosition=0, nCurPosition;
|
|||
|
|
|
|||
|
|
if( !m_ScrollBar.IsArrowStateClear() )
|
|||
|
|
{
|
|||
|
|
nOldPosition = m_ScrollBar.GetTrackPos();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_ScrollBar.Render( fElapsedTime );
|
|||
|
|
|
|||
|
|
if( !m_ScrollBar.IsArrowStateClear() )
|
|||
|
|
{
|
|||
|
|
nCurPosition = m_ScrollBar.GetTrackPos();
|
|||
|
|
Scroll( nCurPosition-nOldPosition );
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::RenderText( float fElapsedTime )
|
|||
|
|
{
|
|||
|
|
if( m_nCurLine == -1 )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
SUICoord sLineCoord;
|
|||
|
|
int nCount(0);
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
|
|||
|
|
for( int i=m_nCurLine; i<nVecSize; i++, nCount++ )
|
|||
|
|
{
|
|||
|
|
if( nCount >= m_nVisibleCount )
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.bRollOver )
|
|||
|
|
{
|
|||
|
|
if( IsMouseEnter() && m_vecLine[i]->IsMouseInLine() )
|
|||
|
|
{
|
|||
|
|
//sLineCoord = m_vecLine[i].m_uiCoord;
|
|||
|
|
//sLineCoord.fWidth = m_Property.UICoord.fWidth-m_Property.TextBoxProperty.fScrollBarSize;
|
|||
|
|
//m_pParent->DrawRect( sLineCoord, textcolor::DARKGRAY );
|
|||
|
|
|
|||
|
|
RenderLine( fElapsedTime, m_vecLine[i], true );
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
else if( m_vecLine[i]->IsSelected() )
|
|||
|
|
{
|
|||
|
|
RenderLine( fElapsedTime, m_vecLine[i], true );
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
RenderLine( fElapsedTime, m_vecLine[i] );
|
|||
|
|
//m_pParent->DrawRect( m_vecLine[i].m_uiCoord, EtInterface::debug::BLUE );
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::RenderLine( float fElapsedTime, CLine* sLine, bool bRollOver )
|
|||
|
|
{
|
|||
|
|
VECWORD & vecWord = sLine->m_vecWord;
|
|||
|
|
#ifdef TEXTBOX_RENDERLOCK
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Ǵٸ<C7B4>, <20><><EFBFBD><EFBFBD>ó<EFBFBD><C3B3> <20>ϴ°<CFB4> <20>ƴ϶<C6B4>
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD> AddText, SetText, AppendText<78><74><EFBFBD><EFBFBD> <20>ؽ<EFBFBD>Ʈ <20>߰<EFBFBD><DFB0>Լ<EFBFBD><D4BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ǵ<EFBFBD><C7B4>ؾ<EFBFBD><D8BE>Ѵ<EFBFBD>.
|
|||
|
|
// <20><EFBFBD><D7B7><EFBFBD> <20>̷<EFBFBD><CCB7><EFBFBD> <20>Ϸ<EFBFBD><CFB7><EFBFBD>,
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>θ<EFBFBD> <20>Ǵ<EFBFBD><C7B4>ϴ<EFBFBD> m_nRenderingState(0,1<><31>)<29><><EFBFBD>ٰ<EFBFBD> Add<64><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>˸<EFBFBD><CBB8><EFBFBD> <20><><EFBFBD>µ<EFBFBD> <20>߰<EFBFBD><DFB0>ؾ<EFBFBD><D8BE>ϰ<EFBFBD>
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3> <20>յڿ<D5B5><DABF>ٰ<EFBFBD><D9B0><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ɾ<EFBFBD><C9BE>߸<EFBFBD> <20>Ѵ<EFBFBD>.
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ȳ<EFBFBD><C8B3>鼭 <20><><EFBFBD><EFBFBD> <20>ּ<EFBFBD><D6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>̱<EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
int nBorderFlag = 0;
|
|||
|
|
for( int i=0; i<(int)vecWord.size(); i++ )
|
|||
|
|
#else
|
|||
|
|
int nWordSize = (int)vecWord.size();
|
|||
|
|
|
|||
|
|
for( int i=0; i<nWordSize; i++ )
|
|||
|
|
#endif
|
|||
|
|
{
|
|||
|
|
if( vecWord[i].m_sProperty.BgColor )
|
|||
|
|
{
|
|||
|
|
nBorderFlag = 0;
|
|||
|
|
if( i == 0 ) nBorderFlag |= 1;
|
|||
|
|
if( i == (int)vecWord.size()-1 ) nBorderFlag |= 2;
|
|||
|
|
nBorderFlag |= 4;
|
|||
|
|
nBorderFlag |= 8;
|
|||
|
|
}
|
|||
|
|
RenderWord( fElapsedTime, vecWord[i], bRollOver, nBorderFlag );
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::RenderWord( float fElapsedTime, CWord& sWord, bool bRollOver, int nBorderFlag )
|
|||
|
|
{
|
|||
|
|
std::wstring strRenderString;
|
|||
|
|
SUICoord uiRenderCoord;
|
|||
|
|
|
|||
|
|
strRenderString = sWord.m_strWord;
|
|||
|
|
uiRenderCoord = sWord.m_sProperty.uiCoord;
|
|||
|
|
|
|||
|
|
if( sWord.m_sProperty.bSymbol )
|
|||
|
|
{
|
|||
|
|
strRenderString += L"...";
|
|||
|
|
uiRenderCoord.fWidth += m_fSymbolWidth;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UI_CONTROL_STATE currentState = UI_STATE_NORMAL;
|
|||
|
|
|
|||
|
|
if( !IsShow() )
|
|||
|
|
{
|
|||
|
|
currentState = UI_STATE_HIDDEN;
|
|||
|
|
}
|
|||
|
|
else if( !IsEnable() )
|
|||
|
|
{
|
|||
|
|
currentState = UI_STATE_DISABLED;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
sWord.m_sProperty.uiColor.Blend( currentState, fElapsedTime, m_fBlendRate );
|
|||
|
|
|
|||
|
|
SUIElement *pElement = GetElement(0);
|
|||
|
|
if( !pElement ) return;
|
|||
|
|
|
|||
|
|
uiRenderCoord.fX += pElement->fFontHoriOffset;
|
|||
|
|
uiRenderCoord.fY += pElement->fFontVertOffset;
|
|||
|
|
|
|||
|
|
if( bRollOver )
|
|||
|
|
{
|
|||
|
|
m_pParent->DrawDlgText( strRenderString.c_str(), pElement, sWord.m_sProperty.uiColor.dwCurrentColor, uiRenderCoord, -1, -1, true, m_fZValue, sWord.m_sProperty.BgColor, nBorderFlag );
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_pParent->DrawDlgText( strRenderString.c_str(), pElement, sWord.m_sProperty.uiColor.dwCurrentColor, uiRenderCoord, -1, -1, true, m_fZValue, sWord.m_sProperty.BgColor, nBorderFlag );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//m_pParent->DrawRect( uiRenderCoord, EtInterface::debug::RED );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::UpdateRects()
|
|||
|
|
{
|
|||
|
|
//UpdateText();
|
|||
|
|
UpdateAlignText();
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.bVerticalScrollBar )
|
|||
|
|
{
|
|||
|
|
if( m_Property.TextBoxProperty.bLeftScrollBar )
|
|||
|
|
{
|
|||
|
|
m_ScrollBar.SetPosition( m_Property.UICoord.fX, m_Property.UICoord.fY );
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_ScrollBar.SetPosition( m_Property.UICoord.Right()-m_Property.TextBoxProperty.fScrollBarSize, m_Property.UICoord.fY );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_ScrollBar.SetSize( m_Property.TextBoxProperty.fScrollBarSize, m_Property.UICoord.fHeight );
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::UpdateText()
|
|||
|
|
{
|
|||
|
|
if( !UpdateVisibleCount() )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
float fX = m_Property.UICoord.fX;
|
|||
|
|
float fY = m_Property.UICoord.fY;
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.bVerticalScrollBar && m_Property.TextBoxProperty.bLeftScrollBar )
|
|||
|
|
{
|
|||
|
|
fX += m_Property.TextBoxProperty.fScrollBarSize + 0.004f;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
fY += m_fTextMargin;
|
|||
|
|
|
|||
|
|
int nCount(0);
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
|
|||
|
|
for( int i=m_nCurLine; i<nVecSize; i++, nCount++ )
|
|||
|
|
{
|
|||
|
|
if( nCount >= m_nVisibleCount )
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
m_vecLine[i]->UpdatePos( fX, fY );
|
|||
|
|
fY += m_vecLine[i]->m_uiCoord.fHeight;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::UpdateText( float fX, float fY )
|
|||
|
|
{
|
|||
|
|
//if( !UpdateVisibleCount() )
|
|||
|
|
// return;
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.bVerticalScrollBar && m_Property.TextBoxProperty.bLeftScrollBar )
|
|||
|
|
{
|
|||
|
|
fX += m_Property.TextBoxProperty.fScrollBarSize + 0.004f;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
fY += m_fTextMargin;
|
|||
|
|
|
|||
|
|
int nCount(0);
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
|
|||
|
|
for( int i=m_nCurLine; i<nVecSize; i++, nCount++ )
|
|||
|
|
{
|
|||
|
|
if( nCount >= m_nVisibleCount )
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
m_vecLine[i]->UpdatePos( fX, fY );
|
|||
|
|
fY += m_vecLine[i]->m_uiCoord.fHeight;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CEtUITextBox::UpdateVisibleCount()
|
|||
|
|
{
|
|||
|
|
if( m_vecLine.empty() )
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.AllignVert == AT_VERT_BOTTOM )
|
|||
|
|
{
|
|||
|
|
m_nVisibleCount = (int)(m_Property.UICoord.fHeight/m_vecLine[0]->m_uiCoord.fHeight);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// BOTTOM<4F>϶<EFBFBD><CFB6><EFBFBD> <20><EFBFBD> <20><>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD>ü Height <20><><EFBFBD>ؼ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʰ<EFBFBD>,
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD>ΰ<EFBFBD><CEB0><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>缭 <20><><EFBFBD>ؾ<EFBFBD><D8BE>Ѵ<EFBFBD>.
|
|||
|
|
float fUIHeight, fLineHeight(0.0f);
|
|||
|
|
fUIHeight = m_Property.UICoord.fHeight;
|
|||
|
|
|
|||
|
|
int nCount(0);
|
|||
|
|
for( int i=m_nCurLine; i<(int)m_vecLine.size(); i++, nCount++ )
|
|||
|
|
{
|
|||
|
|
fLineHeight += m_vecLine[i]->m_uiCoord.fHeight;
|
|||
|
|
|
|||
|
|
if( fLineHeight > fUIHeight )
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_nVisibleCount = nCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_ScrollBar.SetPageSize( m_nVisibleCount );
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::SetText( const LPCWSTR szText, const D3DCOLOR TextColor )
|
|||
|
|
{
|
|||
|
|
ASSERT( szText );
|
|||
|
|
|
|||
|
|
std::wstring strTemp(szText), strSubStr;
|
|||
|
|
std::wstring::size_type textSize, begIdx, endIdx;
|
|||
|
|
|
|||
|
|
textSize = strTemp.size();
|
|||
|
|
begIdx = 0;
|
|||
|
|
endIdx = strTemp.find_first_of(L"\n", begIdx);
|
|||
|
|
|
|||
|
|
while( begIdx < textSize )
|
|||
|
|
{
|
|||
|
|
if( endIdx != std::wstring::npos )
|
|||
|
|
{
|
|||
|
|
strSubStr = strTemp.substr(begIdx, endIdx-begIdx);
|
|||
|
|
endIdx++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
strSubStr = strTemp.substr(begIdx);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( strSubStr.empty() )
|
|||
|
|
{
|
|||
|
|
AddLine();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
DoAddText(strSubStr.c_str(), L"", TextColor);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
begIdx = endIdx;
|
|||
|
|
endIdx = strTemp.find_first_of(L"\n", begIdx);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::AddText( LPCWSTR szText, const D3DCOLOR TextColor, DWORD dwFormat, const D3DCOLOR BgColor )
|
|||
|
|
{
|
|||
|
|
if( m_bAddTextToNextPage ) {
|
|||
|
|
m_pNextPageTextBox->AddText( szText, TextColor, dwFormat, BgColor );
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AddLine();
|
|||
|
|
|
|||
|
|
SENTENCE curSentence;
|
|||
|
|
SWORD_PROPERTY basicProperty;
|
|||
|
|
basicProperty.uiColor.dwColor[UI_STATE_NORMAL] = TextColor;
|
|||
|
|
basicProperty.uiColor.dwCurrentColor = TextColor;
|
|||
|
|
basicProperty.dwFormat = dwFormat;
|
|||
|
|
basicProperty.bAdd = false;
|
|||
|
|
basicProperty.BgColor = BgColor;
|
|||
|
|
|
|||
|
|
const CEtUINameLinkMgr& nameLinkMgr = EtInterface::GetNameLinkMgr();
|
|||
|
|
nameLinkMgr.TranslateText(curSentence, basicProperty, szText);
|
|||
|
|
|
|||
|
|
m_OriginalStrings.push_back(curSentence);
|
|||
|
|
if( (int)m_OriginalStrings.size() > m_nMaxLine ) {
|
|||
|
|
m_OriginalStrings.pop_front();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::wstring translated;
|
|||
|
|
SENTENCE::const_iterator iter = curSentence.begin();
|
|||
|
|
for (; iter != curSentence.end(); ++iter)
|
|||
|
|
{
|
|||
|
|
const CWord& curWord = *iter;
|
|||
|
|
const SWORD_PROPERTY& prop = curWord.m_sProperty;
|
|||
|
|
if( m_Property.TextBoxProperty.VariableType == UI_TEXTBOX_WIDTH ||
|
|||
|
|
m_Property.TextBoxProperty.VariableType == UI_TEXTBOX_BOTH )
|
|||
|
|
{
|
|||
|
|
AppendTextV( curWord.m_strWord.c_str(), curWord.m_strWordWithTag.c_str(), prop.uiColor.dwCurrentColor, prop.dwFormat, true, prop.BgColor );
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
AppendTextF( curWord.m_strWord.c_str(), curWord.m_strWordWithTag.c_str(), prop.uiColor.dwCurrentColor, prop.dwFormat, true, prop.BgColor );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
translated += L"\n";
|
|||
|
|
m_szText = translated.c_str();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ClearLineData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::DoAddText( LPCWSTR szText, LPCWSTR szTextWithTag, const D3DCOLOR TextColor, DWORD dwFormat, const D3DCOLOR BgColor )
|
|||
|
|
{
|
|||
|
|
if( m_bAddTextToNextPage ) {
|
|||
|
|
m_pNextPageTextBox->DoAddText( szText, szTextWithTag, TextColor, dwFormat, BgColor );
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AddLine();
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.VariableType == UI_TEXTBOX_WIDTH ||
|
|||
|
|
m_Property.TextBoxProperty.VariableType == UI_TEXTBOX_BOTH )
|
|||
|
|
{
|
|||
|
|
AppendTextV( szText, szTextWithTag, TextColor, dwFormat, true, BgColor );
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
AppendTextF( szText, szTextWithTag, TextColor, dwFormat, true, BgColor );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ClearLineData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::AppendText( LPCWSTR szText, const D3DCOLOR TextColor, DWORD dwFormat, bool bAdd, const D3DCOLOR BgColor, LPCWSTR szTextWithTag )
|
|||
|
|
{
|
|||
|
|
if( m_bAddTextToNextPage ) {
|
|||
|
|
m_pNextPageTextBox->AppendText( szText, TextColor, dwFormat, bAdd, BgColor, szTextWithTag );
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.VariableType == UI_TEXTBOX_WIDTH ||
|
|||
|
|
m_Property.TextBoxProperty.VariableType == UI_TEXTBOX_BOTH )
|
|||
|
|
AppendTextV( szText, szTextWithTag, TextColor, dwFormat, bAdd, BgColor );
|
|||
|
|
else
|
|||
|
|
AppendTextF( szText, szTextWithTag, TextColor, dwFormat, bAdd, BgColor );
|
|||
|
|
|
|||
|
|
m_szText += szText;
|
|||
|
|
ClearLineData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::AppendTextF( const LPCWSTR szText, const LPCWSTR szTextWithTag, const D3DCOLOR TextColor, DWORD dwFormat, bool bAdd, const D3DCOLOR BgColor )
|
|||
|
|
{
|
|||
|
|
if( CEtFontMng::s_bUseUniscribe )
|
|||
|
|
{
|
|||
|
|
if( m_vecLine.empty() )
|
|||
|
|
{
|
|||
|
|
AddLine();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SUIElement *pElement;
|
|||
|
|
pElement = GetElement(0);
|
|||
|
|
|
|||
|
|
SUICoord sTextCoord;
|
|||
|
|
m_pParent->CalcTextRect( szText, pElement, sTextCoord );
|
|||
|
|
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
float fRemainWidth = m_Property.UICoord.fWidth;
|
|||
|
|
if( m_Property.TextBoxProperty.bLeftScrollBar || m_Property.TextBoxProperty.bVerticalScrollBar )
|
|||
|
|
fRemainWidth -= m_Property.TextBoxProperty.fScrollBarSize;
|
|||
|
|
float fOriginWidth = fRemainWidth;
|
|||
|
|
CLine* pLine = GetEndLine();
|
|||
|
|
if( pLine )
|
|||
|
|
fRemainWidth -= pLine->m_uiCoord.fWidth;
|
|||
|
|
|
|||
|
|
if( fRemainWidth <= 0.0f )
|
|||
|
|
{
|
|||
|
|
DoAddText( szText, szTextWithTag, TextColor, dwFormat );
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SWORD_PROPERTY wordProperty;
|
|||
|
|
wordProperty.uiColor.dwColor[UI_STATE_NORMAL] = TextColor;
|
|||
|
|
wordProperty.uiColor.dwCurrentColor = TextColor;
|
|||
|
|
wordProperty.dwFormat = dwFormat;
|
|||
|
|
wordProperty.bAdd = bAdd;
|
|||
|
|
wordProperty.BgColor = BgColor;
|
|||
|
|
if( dwFormat & UITEXT_SYMBOL )
|
|||
|
|
{
|
|||
|
|
fRemainWidth -= m_fSymbolWidth;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
vector<wstring> vecStrLine;
|
|||
|
|
int nMaxWidth;
|
|||
|
|
if( !CEtFontMng::GetInstance().GetWordBreakText( std::wstring( szText ), pElement->nFontIndex, pElement->nFontHeight,
|
|||
|
|
fRemainWidth * m_pParent->GetScreenWidth(), vecStrLine, nMaxWidth, true, fOriginWidth * m_pParent->GetScreenWidth() ) )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
bool bAddLine = false;
|
|||
|
|
if( static_cast<int>( vecStrLine.size() ) > 1 )
|
|||
|
|
bAddLine = true;
|
|||
|
|
|
|||
|
|
if( static_cast<int>( vecStrLine.size() ) > 0 && bAddLine && dwFormat & UITEXT_SYMBOL && !m_Property.TextBoxProperty.bVerticalScrollBar )
|
|||
|
|
{
|
|||
|
|
wordProperty.bSymbol = true;
|
|||
|
|
SetTooltipText( szText );
|
|||
|
|
AddWord( vecStrLine[0].c_str(), szTextWithTag, wordProperty );
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
for( int i=0; i<static_cast<int>( vecStrLine.size() ); i++ )
|
|||
|
|
{
|
|||
|
|
AddWord( vecStrLine[i].c_str(), szTextWithTag, wordProperty );
|
|||
|
|
if( bAddLine && i < static_cast<int>( vecStrLine.size() ) - 1 )
|
|||
|
|
AddLine();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if( m_vecLine.empty() )
|
|||
|
|
{
|
|||
|
|
AddLine();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SUIElement *pElement;
|
|||
|
|
pElement = GetElement(0);
|
|||
|
|
|
|||
|
|
SUICoord sTextCoord;
|
|||
|
|
m_pParent->CalcTextRect( szText, pElement, sTextCoord );
|
|||
|
|
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
float fRemainWidth = m_Property.UICoord.fWidth;
|
|||
|
|
fRemainWidth -= m_Property.TextBoxProperty.fScrollBarSize;
|
|||
|
|
CLine* pLine = GetEndLine();
|
|||
|
|
if( pLine )
|
|||
|
|
fRemainWidth -= pLine->m_uiCoord.fWidth;
|
|||
|
|
|
|||
|
|
if( fRemainWidth <= 0.0f )
|
|||
|
|
{
|
|||
|
|
DoAddText( szText, szTextWithTag, TextColor, dwFormat );
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SWORD_PROPERTY wordProperty;
|
|||
|
|
wordProperty.uiColor.dwColor[UI_STATE_NORMAL] = TextColor;
|
|||
|
|
wordProperty.uiColor.dwCurrentColor = TextColor;
|
|||
|
|
wordProperty.dwFormat = dwFormat;
|
|||
|
|
wordProperty.bAdd = bAdd;
|
|||
|
|
wordProperty.BgColor = BgColor;
|
|||
|
|
|
|||
|
|
if( sTextCoord.fWidth > fRemainWidth )
|
|||
|
|
{
|
|||
|
|
std::wstring strText, strSub;
|
|||
|
|
strText = szText;
|
|||
|
|
|
|||
|
|
if( dwFormat & UITEXT_SYMBOL )
|
|||
|
|
{
|
|||
|
|
fRemainWidth -= m_fSymbolWidth;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( fRemainWidth <= 0.0f )
|
|||
|
|
{
|
|||
|
|
DoAddText(szText, szTextWithTag, TextColor, dwFormat);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int nTrail = 0;
|
|||
|
|
int nCaret = CEtFontMng::GetInstance().GetCaretFromCaretPos( strText.c_str(), pElement->nFontIndex, pElement->nFontHeight,
|
|||
|
|
int(fRemainWidth*m_pParent->GetScreenWidth()), nTrail );
|
|||
|
|
|
|||
|
|
if( m_bUseWordBreak )
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20>극<EFBFBD><EAB7B9>ũ <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE>Ѵٸ<D1B4>, <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>. <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20>ؿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʰ<EFBFBD>, <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>쿣 ó<><C3B3><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ѵ<EFBFBD>.
|
|||
|
|
// FontMng<6E><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>극<EFBFBD><EAB7B9>ũ<EFBFBD><C5A9> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ػ<D8BB><F3B5B5B8><EFBFBD> <20><EFBFBD><DEB6><EFBFBD><EFBFBD><EFBFBD><E2B6A7><EFBFBD><EFBFBD> <20><><EFBFBD>̱ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20>־, <20>켱 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ϰڴ<CFB0>.
|
|||
|
|
bool bFirstWordInLine = ( pLine && pLine->m_uiCoord.fWidth == 0.0f );
|
|||
|
|
nCaret = GetCaretWithWordBreak( strText, nCaret, bFirstWordInLine );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( nCaret < (int)strText.size() )
|
|||
|
|
{
|
|||
|
|
if( dwFormat & UITEXT_SYMBOL )
|
|||
|
|
{
|
|||
|
|
wordProperty.bSymbol = true;
|
|||
|
|
SetTooltipText( strText.c_str() );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
strSub = strText.substr(0,nCaret+nTrail);
|
|||
|
|
AddWord( strSub.c_str(), szTextWithTag, wordProperty );
|
|||
|
|
|
|||
|
|
if( dwFormat & (UITEXT_CLIP|UITEXT_SYMBOL) )
|
|||
|
|
goto RETURN;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ѷ<EFBFBD><D1B7><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
if( nCaret+nTrail == 0 && pLine && pLine->m_uiCoord.fWidth == 0.0f )
|
|||
|
|
goto RETURN;
|
|||
|
|
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD> <20>ٸ<EFBFBD> <20><><EFBFBD>ο<EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ѵ<EFBFBD>.
|
|||
|
|
AddLine();
|
|||
|
|
wstring strLeftString = strText.substr( nCaret+nTrail );
|
|||
|
|
AppendTextF(strLeftString.c_str(), szTextWithTag, TextColor, dwFormat, bAdd, BgColor);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
AddWord( szText, szTextWithTag, wordProperty );
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
RETURN:
|
|||
|
|
|
|||
|
|
UpdateAlignText();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::AppendTextV( const LPCWSTR szText, const LPCWSTR szTextWithTag, const D3DCOLOR TextColor, DWORD dwFormat, bool bAdd, const D3DCOLOR BgColor )
|
|||
|
|
{
|
|||
|
|
if( m_vecLine.empty() )
|
|||
|
|
{
|
|||
|
|
AddLine();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SWORD_PROPERTY wordProperty;
|
|||
|
|
wordProperty.uiColor.dwColor[UI_STATE_NORMAL] = TextColor;
|
|||
|
|
wordProperty.uiColor.dwCurrentColor = TextColor;
|
|||
|
|
wordProperty.bAdd = bAdd;
|
|||
|
|
wordProperty.BgColor = BgColor;
|
|||
|
|
//wordProperty.dwFormat = dwFormat;
|
|||
|
|
|
|||
|
|
AddWord( szText, szTextWithTag, wordProperty );
|
|||
|
|
|
|||
|
|
UpdateAlignText();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::AddLine()
|
|||
|
|
{
|
|||
|
|
#ifdef TEXTBOX_RENDERLOCK
|
|||
|
|
while( m_nRenderingState == 1 ) {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
SUIElement *pElement = GetElement(0);
|
|||
|
|
if( !pElement ) return;
|
|||
|
|
|
|||
|
|
SUICoord sTextCoord;
|
|||
|
|
m_pParent->CalcTextRect( L"x", pElement, sTextCoord );
|
|||
|
|
|
|||
|
|
CLine *sLine = new CLine;
|
|||
|
|
|
|||
|
|
if( m_vecLine.empty() )
|
|||
|
|
{
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD>, ù<><C3B9>° <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ǥ<EFBFBD><C7A5> <20><><EFBFBD><EFBFBD>
|
|||
|
|
// <09><><EFBFBD>۶<EFBFBD><DBB6>ΰ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD> 0<><30><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
sLine->m_uiCoord = m_Property.UICoord;
|
|||
|
|
m_nStartLine = 0;
|
|||
|
|
m_nCurLine = 0;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
CLine* sCurLine = GetEndLine();
|
|||
|
|
if (sCurLine)
|
|||
|
|
{
|
|||
|
|
sLine->m_uiCoord.fX = sCurLine->m_uiCoord.fX;
|
|||
|
|
sLine->m_uiCoord.fY = sCurLine->m_uiCoord.Bottom();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
sLine->m_uiCoord.fWidth = 0.0f;
|
|||
|
|
sLine->m_uiCoord.fHeight = sTextCoord.fHeight;
|
|||
|
|
sLine->SetLineSpace( m_Property.TextBoxProperty.fLineSpace );
|
|||
|
|
sLine->SetLineData( GetLineData() );
|
|||
|
|
|
|||
|
|
m_vecLine.push_back( sLine );
|
|||
|
|
m_nEndLine++;
|
|||
|
|
|
|||
|
|
if( m_nEndLine >= m_nMaxLine ) {
|
|||
|
|
SAFE_DELETE( m_vecLine[0] );
|
|||
|
|
m_vecLine.erase( m_vecLine.begin() );
|
|||
|
|
m_nEndLine--;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_ScrollBar.SetTrackRange( 0, ( int )m_vecLine.size() );
|
|||
|
|
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ؽ<EFBFBD>Ʈ <20>ڽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ
|
|||
|
|
UpdateTextBox();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::AddImage( WCHAR *wszIamgeName, int nWidth, int nHeight )
|
|||
|
|
{
|
|||
|
|
#ifdef TEXTBOX_RENDERLOCK
|
|||
|
|
while( m_nRenderingState == 1 ) {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
SUIElement *pElement = GetElement(0);
|
|||
|
|
if( !pElement ) return;
|
|||
|
|
|
|||
|
|
SUICoord sTextCoord;
|
|||
|
|
m_pParent->CalcTextRect( L"x", pElement, sTextCoord );
|
|||
|
|
|
|||
|
|
std::string szTextureName;
|
|||
|
|
ToMultiString( wszIamgeName, szTextureName );
|
|||
|
|
EtTextureHandle hTexture = EternityEngine::LoadTexture( szTextureName.c_str() );
|
|||
|
|
if( !hTexture ) return;
|
|||
|
|
|
|||
|
|
SUICoord sUVCoord;
|
|||
|
|
int nWidthTemp = (int)( m_Property.UICoord.fWidth * DEFAULT_UI_SCREEN_WIDTH );
|
|||
|
|
int nHeightTemp = (int)( ( ( sTextCoord.fHeight + m_Property.TextBoxProperty.fLineSpace ) ) * DEFAULT_UI_SCREEN_HEIGHT );
|
|||
|
|
int nCount = (int)( nHeight / nHeightTemp );
|
|||
|
|
float fUVHeight = ( 1.f / (float)nHeight ) * (float)( ( ( sTextCoord.fHeight + m_Property.TextBoxProperty.fLineSpace ) ) * DEFAULT_UI_SCREEN_HEIGHT );
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><EFBFBD><D7B7><EFBFBD>ī<EFBFBD>忡<EFBFBD><E5BFA1> <20>ؽ<EFBFBD>ó<EFBFBD><C3B3> 2<><32> <20>¼<EFBFBD> <20>ƴѰͶ<D1B0><CDB6><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>´ٰ<C2B4> <20>ϸ<EFBFBD> <20>ؽ<EFBFBD>ó <20><><EFBFBD><EFBFBD> 2<><32> <20>¼<EFBFBD><C2BC><EFBFBD> <20>ٲٰ<D9B2> <20>Ʒ<EFBFBD><C6B7><EFBFBD> Ȱ<><C8B0>ȭ<EFBFBD><C8AD>Ű<EFBFBD><C5B0> <20>ȴ<EFBFBD>.
|
|||
|
|
//float fUVHeight = ( 1.f / (float)hTexture->OriginalHeight() ) * (float)( ( ( sTextCoord.fHeight + m_Property.TextBoxProperty.fLineSpace ) ) * DEFAULT_UI_SCREEN_HEIGHT );
|
|||
|
|
fUVHeight = ( (int)( fUVHeight * hTexture->OriginalHeight() ) / (float)hTexture->OriginalHeight() );
|
|||
|
|
if( nHeight % nHeightTemp != 0 ) nCount++;
|
|||
|
|
|
|||
|
|
float fCoordWidth = nWidth / (float)DEFAULT_UI_SCREEN_WIDTH;
|
|||
|
|
if( fCoordWidth > m_Property.UICoord.fWidth ) fCoordWidth = m_Property.UICoord.fWidth;
|
|||
|
|
|
|||
|
|
for( int i=0; i<nCount; i++ ) {
|
|||
|
|
CImageLine *sLine = new CImageLine;
|
|||
|
|
|
|||
|
|
if( m_vecLine.empty() )
|
|||
|
|
{
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD>, ù<><C3B9>° <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ǥ<EFBFBD><C7A5> <20><><EFBFBD><EFBFBD>
|
|||
|
|
// <09><><EFBFBD>۶<EFBFBD><DBB6>ΰ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD> 0<><30><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
sLine->m_uiCoord = m_Property.UICoord;
|
|||
|
|
m_nStartLine = 0;
|
|||
|
|
m_nCurLine = 0;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
CLine* sCurLine = GetEndLine();
|
|||
|
|
if (sCurLine)
|
|||
|
|
{
|
|||
|
|
sLine->m_uiCoord.fX = sCurLine->m_uiCoord.fX;
|
|||
|
|
sLine->m_uiCoord.fY = sCurLine->m_uiCoord.Bottom();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
sLine->m_uiCoord.fWidth = fCoordWidth;
|
|||
|
|
sLine->m_uiCoord.fHeight = sTextCoord.fHeight;
|
|||
|
|
sLine->SetLineSpace( m_Property.TextBoxProperty.fLineSpace );
|
|||
|
|
sLine->SetLineData( GetLineData() );
|
|||
|
|
|
|||
|
|
sUVCoord.fX = 0.f;
|
|||
|
|
sUVCoord.fY = fUVHeight * i;
|
|||
|
|
sUVCoord.fWidth = 1.f;
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><EFBFBD><D7B7><EFBFBD>ī<EFBFBD><C4AB> <20><>ü<EFBFBD><C3BC>.
|
|||
|
|
//sUVCoord.fWidth = (float)nWidth / (float)hTexture->OriginalWidth();
|
|||
|
|
sUVCoord.fHeight = fUVHeight;
|
|||
|
|
|
|||
|
|
sLine->SetImage( (char*)szTextureName.c_str(), sUVCoord );
|
|||
|
|
|
|||
|
|
m_vecLine.push_back( sLine );
|
|||
|
|
m_nEndLine++;
|
|||
|
|
|
|||
|
|
if( m_nEndLine >= m_nMaxLine ) {
|
|||
|
|
SAFE_DELETE( m_vecLine[0] );
|
|||
|
|
m_vecLine.erase( m_vecLine.begin() );
|
|||
|
|
m_nEndLine--;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
SAFE_RELEASE_SPTR( hTexture );
|
|||
|
|
AddLine();
|
|||
|
|
|
|||
|
|
m_ScrollBar.SetTrackRange( 0, ( int )m_vecLine.size() );
|
|||
|
|
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ؽ<EFBFBD>Ʈ <20>ڽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ
|
|||
|
|
UpdateTextBox();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::AddWord( const LPCWSTR szText, const LPCWSTR szTextWithTag, SWORD_PROPERTY &wordProperty )
|
|||
|
|
{
|
|||
|
|
#ifdef TEXTBOX_RENDERLOCK
|
|||
|
|
while( m_nRenderingState == 1 ) {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
SUICoord sTextCoord;
|
|||
|
|
m_pParent->CalcTextRect( szText, GetElement(0), sTextCoord );
|
|||
|
|
|
|||
|
|
CLine* pEndLine = GetEndLine();
|
|||
|
|
if (pEndLine == NULL)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
CLine& sEndLine = *pEndLine;
|
|||
|
|
|
|||
|
|
CWord sWord;
|
|||
|
|
sWord.m_strWord = szText;
|
|||
|
|
sWord.m_strWordWithTag = szTextWithTag;
|
|||
|
|
|
|||
|
|
if( wordProperty.dwFormat & UITEXT_RIGHT )
|
|||
|
|
{
|
|||
|
|
wordProperty.uiCoord.fX = m_Property.UICoord.fWidth - sTextCoord.fWidth;
|
|||
|
|
}
|
|||
|
|
else if( wordProperty.dwFormat & UITEXT_CENTER )
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>⼭ <20>̷<EFBFBD><CCB7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20>ص<EFBFBD>,
|
|||
|
|
// <20><><EFBFBD>߿<EFBFBD> UpdateText<78><74> ȣ<><C8A3><EFBFBD>Ǹ鼭 <20><> <20><><EFBFBD>κ<EFBFBD><CEBA><EFBFBD> void CLine::UpdatePos( float fX, float fY ) <20>Լ<EFBFBD><D4BC><EFBFBD> ȣ<><C8A3><EFBFBD>ȴ<EFBFBD>.
|
|||
|
|
// <20><> <20>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD> <20>ٽ<EFBFBD> <20>ѹ<EFBFBD> <20><>ġ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ϰ<EFBFBD> <20>ȴ<EFBFBD>.
|
|||
|
|
wordProperty.uiCoord.fX = (m_Property.UICoord.fWidth - sTextCoord.fWidth)*0.5f;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
wordProperty.uiCoord.fX = sEndLine.m_uiCoord.Right();
|
|||
|
|
}
|
|||
|
|
wordProperty.uiCoord.fY = sEndLine.m_uiCoord.fY+sEndLine.GetLineSpace();
|
|||
|
|
if( wordProperty.bSymbol ) sTextCoord.fWidth += m_fSymbolWidth;
|
|||
|
|
wordProperty.uiCoord.fWidth = sTextCoord.fWidth;
|
|||
|
|
wordProperty.uiCoord.fHeight = sTextCoord.fHeight;
|
|||
|
|
|
|||
|
|
sWord.m_sProperty = wordProperty;
|
|||
|
|
sEndLine.m_vecWord.push_back( sWord );
|
|||
|
|
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ũ<>⸦ <20>ؽ<EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD> ū <20><><EFBFBD>̷<EFBFBD> <20>Ѵ<EFBFBD>.
|
|||
|
|
if( sEndLine.m_uiCoord.fHeight < wordProperty.uiCoord.fHeight )
|
|||
|
|
sEndLine.m_uiCoord.fHeight = wordProperty.uiCoord.fHeight;
|
|||
|
|
|
|||
|
|
if( wordProperty.dwFormat & (UITEXT_RIGHT|UITEXT_CENTER) )
|
|||
|
|
{
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7>װ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>̴<EFBFBD> <20>ؽ<EFBFBD>Ʈ<EFBFBD>ڽ<EFBFBD><DABD><EFBFBD> ũ<>Ⱑ <20>ȴ<EFBFBD>.
|
|||
|
|
sEndLine.m_uiCoord.fWidth = m_Property.UICoord.fWidth;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
sEndLine.m_uiCoord.fWidth += wordProperty.uiCoord.fWidth;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ؽ<EFBFBD>Ʈ <20>ڽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ
|
|||
|
|
UpdateTextBox();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::AddColorText( LPCWSTR szText, const D3DCOLOR TextColor, const D3DCOLOR BgColor, const D3DCOLOR DecreaseColor )
|
|||
|
|
{
|
|||
|
|
DWORD dwFontColor = TextColor;
|
|||
|
|
std::wstring szStr = szText;
|
|||
|
|
|
|||
|
|
if( DecreaseColor ) {
|
|||
|
|
dwFontColor = CalcDecreaseColor( dwFontColor, DecreaseColor );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
while( !szStr.empty() )
|
|||
|
|
{
|
|||
|
|
bool bStringLF = true;
|
|||
|
|
std::wstring::size_type nPosInStr;
|
|||
|
|
std::wstring::size_type nPosInStr1 = szStr.find_first_of( L"\n" ); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E0B9AE><EFBFBD>ϼ<EFBFBD><CFBC><EFBFBD> <20>ְ<EFBFBD>,
|
|||
|
|
std::wstring::size_type nPosInStr2 = szStr.find( L"\\n" ); // <20><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Էµ<D4B7> <20><><EFBFBD><EFBFBD><E0B9AE><EFBFBD>ϼ<EFBFBD><CFBC><EFBFBD> <20>ִ<EFBFBD>. <20>α<EFBFBD><CEB1><EFBFBD> <20>̻<EFBFBD><CCBB>϶<EFBFBD> find <20>˻<EFBFBD>.
|
|||
|
|
|
|||
|
|
// <20><> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ó<><C3B3><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
if( nPosInStr1 < nPosInStr2 )
|
|||
|
|
bStringLF = false;
|
|||
|
|
nPosInStr = min(nPosInStr1, nPosInStr2);
|
|||
|
|
|
|||
|
|
std::wstring szCurLine = szStr.substr(0, nPosInStr);
|
|||
|
|
AddText( L"" );
|
|||
|
|
|
|||
|
|
while( !szCurLine.empty() )
|
|||
|
|
{
|
|||
|
|
std::wstring::size_type nLength = szCurLine.size();
|
|||
|
|
std::wstring::size_type nPosInLine = szCurLine.find_first_of( L"#" );
|
|||
|
|
std::wstring szCurWord = szCurLine.substr(0, nPosInLine);
|
|||
|
|
|
|||
|
|
if( !szCurWord.empty() )
|
|||
|
|
AppendText( szCurWord.c_str(), dwFontColor, UITEXT_NONE, false, BgColor );
|
|||
|
|
|
|||
|
|
if( nPosInLine != std::wstring::npos && nLength >= 2 )
|
|||
|
|
{
|
|||
|
|
wchar_t cColorValue = szCurLine[nPosInLine+1];
|
|||
|
|
switch(cColorValue)
|
|||
|
|
{
|
|||
|
|
case 'r': dwFontColor = descritioncolor::RED; break; // <20><><EFBFBD><EFBFBD>
|
|||
|
|
case 'g': dwFontColor = descritioncolor::GREEN; break; // <20><EFBFBD>
|
|||
|
|
case 'b': dwFontColor = descritioncolor::DODGERBLUE; break; // <20><><EFBFBD><EFBFBD>
|
|||
|
|
case 'y': dwFontColor = descritioncolor::YELLOW1; break; // <20><><EFBFBD><EFBFBD>
|
|||
|
|
case 'e': dwFontColor = descritioncolor::YELLOW2; break; // <20><><EFBFBD><EFBFBD>
|
|||
|
|
case 'v': dwFontColor = descritioncolor::VIOLET; break; // <20><><EFBFBD><EFBFBD>
|
|||
|
|
case 's': dwFontColor = descritioncolor::SKY; break; // <20>ϴ<EFBFBD>
|
|||
|
|
case 'j': dwFontColor = descritioncolor::ORANGE; break; // <20><>Ȳ
|
|||
|
|
case 'w': dwFontColor = descritioncolor::WHITE; break; // <20><>
|
|||
|
|
case 'h': dwFontColor = descritioncolor::GREY; break; // ȸ<><C8B8>
|
|||
|
|
case 'd': dwFontColor = TextColor; break; // ó<><C3B3> <20><><EFBFBD>ڷ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD>÷<EFBFBD>
|
|||
|
|
default: break; // <20>߸<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƹ<EFBFBD><C6B9><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
}
|
|||
|
|
if( DecreaseColor ) {
|
|||
|
|
dwFontColor = CalcDecreaseColor( dwFontColor, DecreaseColor );
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::wstring::size_type nNextPos = (nLength >= 2) ? nPosInLine+2 : nPosInLine+1;
|
|||
|
|
szCurLine = szCurLine.substr(nNextPos);
|
|||
|
|
if( nPosInLine == std::wstring::npos )
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
szStr = szStr.substr(nPosInStr+(bStringLF?2:1));
|
|||
|
|
if( nPosInStr == std::wstring::npos )
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int CEtUITextBox::Scroll( int nScrollAmount )
|
|||
|
|
{
|
|||
|
|
if( !IsScrollMode() || nScrollAmount == 0 )
|
|||
|
|
return 0;
|
|||
|
|
|
|||
|
|
int nScrollPos(0);
|
|||
|
|
|
|||
|
|
if( nScrollAmount < 0 )
|
|||
|
|
{
|
|||
|
|
nScrollAmount = -nScrollAmount;
|
|||
|
|
|
|||
|
|
if( m_nCurLine >= nScrollAmount )
|
|||
|
|
{
|
|||
|
|
m_nCurLine -= nScrollAmount;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_nCurLine = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
nScrollPos = m_nCurLine;
|
|||
|
|
}
|
|||
|
|
else if( nScrollAmount > 0 )
|
|||
|
|
{
|
|||
|
|
int nTemp = (int)m_vecLine.size() - m_nCurLine - m_nVisibleCount;
|
|||
|
|
|
|||
|
|
if( nTemp >= nScrollAmount )
|
|||
|
|
{
|
|||
|
|
m_nCurLine += nScrollAmount;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_nCurLine += nTemp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
nScrollPos = m_nCurLine+m_nVisibleCount-1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateText();
|
|||
|
|
return nScrollPos;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::ScrollLineUp()
|
|||
|
|
{
|
|||
|
|
if( !IsScrollMode() )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
if( m_nCurLine > 1 )
|
|||
|
|
{
|
|||
|
|
m_nCurLine -= 2;
|
|||
|
|
}
|
|||
|
|
else if( m_nCurLine > 0 )
|
|||
|
|
{
|
|||
|
|
m_nCurLine--;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateText();
|
|||
|
|
|
|||
|
|
m_ScrollBar.ShowItem( m_nCurLine );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::ScrollLineDown()
|
|||
|
|
{
|
|||
|
|
if( !IsScrollMode() )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
int nTemp = (int)m_vecLine.size() - m_nCurLine;
|
|||
|
|
nTemp -= m_nVisibleCount;
|
|||
|
|
|
|||
|
|
if( nTemp > 1 )
|
|||
|
|
{
|
|||
|
|
m_nCurLine += 2;
|
|||
|
|
}
|
|||
|
|
else if( nTemp > 0 )
|
|||
|
|
{
|
|||
|
|
m_nCurLine++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateText();
|
|||
|
|
|
|||
|
|
m_ScrollBar.ShowItem( m_nCurLine+m_nVisibleCount-1 );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::ScrollPageUp()
|
|||
|
|
{
|
|||
|
|
if( !IsScrollMode() )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
if( m_nCurLine > m_nVisibleCount )
|
|||
|
|
{
|
|||
|
|
m_nCurLine -= m_nVisibleCount;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_nCurLine = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateText();
|
|||
|
|
|
|||
|
|
m_ScrollBar.ShowItem( m_nCurLine );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::ScrollPageDown()
|
|||
|
|
{
|
|||
|
|
if( !IsScrollMode() )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
int nTemp = (int)m_vecLine.size() - m_nCurLine;
|
|||
|
|
nTemp -= m_nVisibleCount;
|
|||
|
|
|
|||
|
|
if( nTemp > m_nVisibleCount )
|
|||
|
|
{
|
|||
|
|
m_nCurLine += m_nVisibleCount;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_nCurLine += nTemp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateText();
|
|||
|
|
|
|||
|
|
m_ScrollBar.ShowItem( m_nCurLine+m_nVisibleCount-1 );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::ScrollHome()
|
|||
|
|
{
|
|||
|
|
if( !IsScrollMode() )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
m_nCurLine = 0;
|
|||
|
|
|
|||
|
|
UpdateText();
|
|||
|
|
|
|||
|
|
m_ScrollBar.ShowItem( m_nCurLine );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::ScrollEnd()
|
|||
|
|
{
|
|||
|
|
if( !IsScrollMode() )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
m_nCurLine = nVecSize - m_nVisibleCount;
|
|||
|
|
|
|||
|
|
UpdateText();
|
|||
|
|
|
|||
|
|
m_ScrollBar.ShowItem( nVecSize-1 );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::ScrollPageTurn()
|
|||
|
|
{
|
|||
|
|
if( !IsScrollMode() || IsLastPage() )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
m_nCurLine += m_nVisibleCount;
|
|||
|
|
|
|||
|
|
UpdateText();
|
|||
|
|
|
|||
|
|
m_ScrollBar.ShowItem( m_nCurLine );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CEtUITextBox::IsLastPage()
|
|||
|
|
{
|
|||
|
|
if( (int)m_vecLine.size()-m_nCurLine <= m_nVisibleCount )
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::SetLineSpace( float fSpace )
|
|||
|
|
{
|
|||
|
|
m_Property.TextBoxProperty.fLineSpace = fSpace;
|
|||
|
|
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
|
|||
|
|
for( int i=0; i<nVecSize; i++ )
|
|||
|
|
{
|
|||
|
|
m_vecLine[i]->SetLineSpace( fSpace );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateRects();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::UpdateAlignText()
|
|||
|
|
{
|
|||
|
|
if( !UpdateVisibleCount() )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
float fX = m_Property.UICoord.fX;
|
|||
|
|
float fY = m_Property.UICoord.fY;
|
|||
|
|
|
|||
|
|
switch( m_Property.TextBoxProperty.AllignVert )
|
|||
|
|
{
|
|||
|
|
case AT_VERT_NONE:
|
|||
|
|
break;
|
|||
|
|
case AT_VERT_TOP:
|
|||
|
|
break;
|
|||
|
|
case AT_VERT_CENTER:
|
|||
|
|
{
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
if( nVecSize < m_nVisibleCount )
|
|||
|
|
{
|
|||
|
|
CLine* pLine = GetEndLine();
|
|||
|
|
if (pLine)
|
|||
|
|
{
|
|||
|
|
float fTemp = (m_nVisibleCount - nVecSize) * pLine->m_uiCoord.fHeight;
|
|||
|
|
fTemp *= 0.5f;
|
|||
|
|
fY += fTemp;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case AT_VERT_BOTTOM:
|
|||
|
|
{
|
|||
|
|
if( m_bAutoScroll )
|
|||
|
|
{
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
|
|||
|
|
if( nVecSize > m_nVisibleCount )
|
|||
|
|
{
|
|||
|
|
m_nCurLine = nVecSize - m_nVisibleCount;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_nCurLine = 0;
|
|||
|
|
CLine* pLine = GetEndLine();
|
|||
|
|
if (pLine)
|
|||
|
|
fY += (m_nVisibleCount - nVecSize) * pLine->m_uiCoord.fHeight;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Note : <20>Ʒ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ʿ<EFBFBD> <20>־<EFBFBD><D6BE>ֱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
//
|
|||
|
|
m_fTextMargin = m_Property.UICoord.fHeight-(m_vecLine[0]->m_uiCoord.fHeight*m_nVisibleCount);
|
|||
|
|
|
|||
|
|
m_ScrollBar.ShowItem( nVecSize-1 );
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_ScrollBar.ShowItem( m_nCurLine + m_nVisibleCount - 1 );
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateText( fX, fY );
|
|||
|
|
|
|||
|
|
switch( m_Property.TextBoxProperty.AllignHori )
|
|||
|
|
{
|
|||
|
|
case AT_HORI_NONE:
|
|||
|
|
break;
|
|||
|
|
case AT_HORI_LEFT:
|
|||
|
|
break;
|
|||
|
|
case AT_HORI_CENTER:
|
|||
|
|
case AT_HORI_RIGHT:
|
|||
|
|
{
|
|||
|
|
CLine *pLine(NULL);
|
|||
|
|
float fGap;
|
|||
|
|
|
|||
|
|
SUICoord sTextBoxCoord;
|
|||
|
|
GetUICoord(sTextBoxCoord);
|
|||
|
|
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
for( int i=0; i<nVecSize; i++ )
|
|||
|
|
{
|
|||
|
|
pLine = m_vecLine[i];
|
|||
|
|
fGap = sTextBoxCoord.fWidth - pLine->m_uiCoord.fWidth;
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.bVerticalScrollBar )
|
|||
|
|
{
|
|||
|
|
if( !m_Property.TextBoxProperty.bLeftScrollBar )
|
|||
|
|
{
|
|||
|
|
fGap -= m_Property.TextBoxProperty.fScrollBarSize;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.AllignHori == AT_HORI_CENTER)
|
|||
|
|
{
|
|||
|
|
fGap *= 0.5f;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
pLine->UpdatePos(pLine->m_uiCoord.fX+fGap, pLine->m_uiCoord.fY);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::ClearText()
|
|||
|
|
{
|
|||
|
|
if( m_pNextPageTextBox && m_bAddTextToNextPage ) {
|
|||
|
|
m_pNextPageTextBox->ClearText();
|
|||
|
|
m_bAddTextToNextPage = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_szText.clear();
|
|||
|
|
SAFE_DELETE_PVEC( m_vecLine );
|
|||
|
|
// m_vecLine.clear();
|
|||
|
|
|
|||
|
|
m_nStartLine = -1;
|
|||
|
|
m_nEndLine = -1;
|
|||
|
|
m_nCurLine = -1;
|
|||
|
|
m_nVisibleCount = 0;
|
|||
|
|
m_ScrollBar.SetTrackRange( 0, 0 );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::CalcSymbolTextRect()
|
|||
|
|
{
|
|||
|
|
SUICoord sSymbolCoord;
|
|||
|
|
m_pParent->CalcTextRect( L"...", GetElement(0), sSymbolCoord );
|
|||
|
|
m_fSymbolWidth = sSymbolCoord.fWidth;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CEtUITextBox::HandleKeyboard( UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|||
|
|
{
|
|||
|
|
if( !IsEnable() || !IsShow() )
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( !m_Property.TextBoxProperty.bVerticalScrollBar )
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( m_ScrollBar.HandleKeyboard( uMsg, wParam, lParam ) )
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( uMsg == WM_KEYDOWN )
|
|||
|
|
{
|
|||
|
|
switch( wParam )
|
|||
|
|
{
|
|||
|
|
case VK_UP: ScrollLineUp(); return true;
|
|||
|
|
case VK_DOWN: ScrollLineDown(); return true;
|
|||
|
|
case VK_PRIOR: ScrollPageUp(); return true;
|
|||
|
|
case VK_NEXT: ScrollPageDown(); return true;
|
|||
|
|
case VK_HOME: ScrollHome(); return true;
|
|||
|
|
case VK_END: ScrollEnd(); return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CEtUITextBox::HandleMouse( UINT uMsg, float fX, float fY, WPARAM wParam, LPARAM lParam )
|
|||
|
|
{
|
|||
|
|
if( !IsEnable() || !IsShow() )
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( ( WM_LBUTTONDOWN == uMsg ) && ( !m_bFocus ) )
|
|||
|
|
{
|
|||
|
|
m_pParent->RequestFocus( this );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int nOldPosition = m_ScrollBar.GetTrackPos();
|
|||
|
|
|
|||
|
|
if( m_ScrollBar.HandleMouse( uMsg, fX, fY, wParam, lParam ) )
|
|||
|
|
{
|
|||
|
|
int nCurPosition = m_ScrollBar.GetTrackPos();
|
|||
|
|
Scroll( nCurPosition-nOldPosition );
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
switch( uMsg )
|
|||
|
|
{
|
|||
|
|
case WM_LBUTTONDOWN:
|
|||
|
|
case WM_LBUTTONDBLCLK:
|
|||
|
|
{
|
|||
|
|
if( IsInside( fX, fY ) )
|
|||
|
|
{
|
|||
|
|
m_bPressed = true;
|
|||
|
|
SetCapture( m_pParent->GetHWnd() );
|
|||
|
|
|
|||
|
|
if( !m_bFocus )
|
|||
|
|
{
|
|||
|
|
m_pParent->RequestFocus( this );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case WM_LBUTTONUP:
|
|||
|
|
{
|
|||
|
|
if( m_bPressed )
|
|||
|
|
{
|
|||
|
|
m_bPressed = false;
|
|||
|
|
ReleaseCapture();
|
|||
|
|
|
|||
|
|
if( IsInside( fX, fY ) )
|
|||
|
|
{
|
|||
|
|
UINT uMsgInner(WM_LBUTTONUP);
|
|||
|
|
if( wParam & MK_CONTROL )
|
|||
|
|
{
|
|||
|
|
uMsgInner |= 0x0100;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( m_Property.TextBoxProperty.bRollOver )
|
|||
|
|
{
|
|||
|
|
if( SelectWord( fX, fY ) )
|
|||
|
|
{
|
|||
|
|
m_pParent->ProcessCommand( EVENT_TEXTBOX_SELECTION, true, this, uMsgInner );
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case WM_MOUSEMOVE:
|
|||
|
|
{
|
|||
|
|
if( IsInside( fX, fY ) )
|
|||
|
|
{
|
|||
|
|
if( m_Property.TextBoxProperty.bRollOver )
|
|||
|
|
{
|
|||
|
|
SetMouseInWord(fX, fY);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case WM_MOUSEWHEEL:
|
|||
|
|
{
|
|||
|
|
UINT uLines;
|
|||
|
|
SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &uLines, 0 );
|
|||
|
|
int nScrollAmount = int( ( short )HIWORD( wParam ) ) / WHEEL_DELTA * uLines;
|
|||
|
|
int nScrollPos = Scroll( -nScrollAmount );
|
|||
|
|
m_ScrollBar.ShowItem( nScrollPos );
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::wstring CEtUITextBox::GetLineText(int nIndex)
|
|||
|
|
{
|
|||
|
|
if(nIndex >= (int)m_vecLine.size())
|
|||
|
|
return L"";
|
|||
|
|
|
|||
|
|
return m_vecLine[nIndex]->GetText();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CLine* CEtUITextBox::GetEndLine()
|
|||
|
|
{
|
|||
|
|
ASSERT(m_nEndLine>=0);
|
|||
|
|
ASSERT(!m_vecLine.empty());
|
|||
|
|
// <20><><EFBFBD>⼭ <20>״<EFBFBD> <20><><EFBFBD>찡 <20>־ <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD> <20>־<D6BE>ϴ<EFBFBD>.
|
|||
|
|
// <20><><EFBFBD>߿<EFBFBD> AddLine <20>Ѿ<D1BE><EEB0A1> return sLine <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ°<D6B4><C2B0>Դϴ<D4B4>.
|
|||
|
|
if( m_nEndLine < 0 || m_nEndLine >= (int)m_vecLine.size() ) {
|
|||
|
|
AddLine();
|
|||
|
|
if( m_nEndLine < 0 || m_nEndLine >= (int)m_vecLine.size() ) {
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return m_vecLine[m_nEndLine];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::SetMouseInLine( float fX, float fY )
|
|||
|
|
{
|
|||
|
|
ClearMouseEnteredLine();
|
|||
|
|
|
|||
|
|
if( m_nCurLine >= 0 )
|
|||
|
|
{
|
|||
|
|
int nCount(0);
|
|||
|
|
SUICoord uiLineCoord;
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
|
|||
|
|
for( int i=m_nCurLine; i<nVecSize; i++, nCount++ )
|
|||
|
|
{
|
|||
|
|
if( nCount >= m_nVisibleCount )
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
uiLineCoord = m_vecLine[i]->m_uiCoord;
|
|||
|
|
uiLineCoord.fWidth = m_Property.UICoord.fWidth;
|
|||
|
|
|
|||
|
|
if( uiLineCoord.IsInside( fX, fY ) )
|
|||
|
|
{
|
|||
|
|
if( (int)m_vecLine[i]->m_vecWord.size() > 0 )
|
|||
|
|
{
|
|||
|
|
m_vecLine[i]->SetMouseInLine(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::SetMouseInWord( float fX, float fY )
|
|||
|
|
{
|
|||
|
|
ClearMouseEnteredLine();
|
|||
|
|
|
|||
|
|
m_WordMouseOver.Clear();
|
|||
|
|
if( m_nCurLine >= 0 )
|
|||
|
|
{
|
|||
|
|
int nCount(0);
|
|||
|
|
SUICoord uiLineCoord;
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
|
|||
|
|
for( int i=m_nCurLine; i<nVecSize; i++, nCount++ )
|
|||
|
|
{
|
|||
|
|
if( nCount >= m_nVisibleCount )
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
uiLineCoord = m_vecLine[i]->m_uiCoord;
|
|||
|
|
uiLineCoord.fWidth = m_Property.UICoord.fWidth;
|
|||
|
|
|
|||
|
|
if( uiLineCoord.IsInside( fX, fY ) )
|
|||
|
|
{
|
|||
|
|
if( (int)m_vecLine[i]->m_vecWord.size() > 0 )
|
|||
|
|
{
|
|||
|
|
m_vecLine[i]->SetMouseInLine(true);
|
|||
|
|
|
|||
|
|
const VECWORD& wordList = m_vecLine[i]->m_vecWord;
|
|||
|
|
VECWORD::const_iterator iter = wordList.begin();
|
|||
|
|
for (; iter != wordList.end(); ++iter)
|
|||
|
|
{
|
|||
|
|
const CWord& word = *iter;
|
|||
|
|
if (word.m_sProperty.uiCoord.IsInside(fX, fY))
|
|||
|
|
{
|
|||
|
|
m_WordMouseOver = word;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int CEtUITextBox::GetMouseEnteredLine()
|
|||
|
|
{
|
|||
|
|
if( m_nCurLine >= 0 )
|
|||
|
|
{
|
|||
|
|
int nCount(0);
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
|
|||
|
|
for( int i=m_nCurLine; i<nVecSize; i++, nCount++ )
|
|||
|
|
{
|
|||
|
|
if( nCount >= m_nVisibleCount )
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
if( m_vecLine[i]->IsMouseInLine() )
|
|||
|
|
{
|
|||
|
|
return i;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CEtUITextBox::SelectLine( float fX, float fY )
|
|||
|
|
{
|
|||
|
|
// Note : <20><><EFBFBD>콺 Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
// <09>ѹ<EFBFBD><D1B9><EFBFBD> <20>ϳ<EFBFBD><CFB3><EFBFBD> <20><><EFBFBD>θ<EFBFBD> <20><><EFBFBD>õ<EFBFBD> <20><> <20>ִ<EFBFBD>.
|
|||
|
|
// <09><>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD> <20>Ѵ<EFBFBD>.
|
|||
|
|
ClearSelectedLine();
|
|||
|
|
|
|||
|
|
if( m_nCurLine >= 0 )
|
|||
|
|
{
|
|||
|
|
int nCount(0);
|
|||
|
|
SUICoord uiLineCoord;
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
|
|||
|
|
for( int i=m_nCurLine; i<nVecSize; i++, nCount++ )
|
|||
|
|
{
|
|||
|
|
if( nCount >= m_nVisibleCount )
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
// Note : m_Property<74><79> Width<74><68> <20><><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ü ũ<><C5A9><EFBFBD><EFBFBD> <20><>ǥ<EFBFBD><C7A5> <20>ȴ<EFBFBD>.
|
|||
|
|
// <09><EFBFBD><D7B7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ڰ<EFBFBD> <20><><EFBFBD>̴<EFBFBD> <20><>ŭ<EFBFBD><C5AD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD>.
|
|||
|
|
uiLineCoord = m_vecLine[i]->m_uiCoord;
|
|||
|
|
uiLineCoord.fWidth = m_Property.UICoord.fWidth;
|
|||
|
|
|
|||
|
|
if( uiLineCoord.IsInside( fX, fY ) )
|
|||
|
|
{
|
|||
|
|
if( (int)m_vecLine[i]->m_vecWord.size() > 0 )
|
|||
|
|
{
|
|||
|
|
int nCurSelLine = GetMouseEnteredLine();
|
|||
|
|
if( nCurSelLine == i )
|
|||
|
|
{
|
|||
|
|
m_vecLine[nCurSelLine]->Select(true);
|
|||
|
|
m_vecLine[nCurSelLine]->SetMouseInLine(false);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CEtUITextBox::SelectWord(float fX, float fY)
|
|||
|
|
{
|
|||
|
|
ClearSelectedLine();
|
|||
|
|
|
|||
|
|
m_WordSelected.Clear();
|
|||
|
|
|
|||
|
|
if( m_nCurLine >= 0 )
|
|||
|
|
{
|
|||
|
|
int nCount(0);
|
|||
|
|
SUICoord uiLineCoord;
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
|
|||
|
|
for( int i=m_nCurLine; i<nVecSize; i++, nCount++ )
|
|||
|
|
{
|
|||
|
|
if( nCount >= m_nVisibleCount )
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
// Note : m_Property<74><79> Width<74><68> <20><><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ü ũ<><C5A9><EFBFBD><EFBFBD> <20><>ǥ<EFBFBD><C7A5> <20>ȴ<EFBFBD>.
|
|||
|
|
// <09><EFBFBD><D7B7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ڰ<EFBFBD> <20><><EFBFBD>̴<EFBFBD> <20><>ŭ<EFBFBD><C5AD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD>.
|
|||
|
|
uiLineCoord = m_vecLine[i]->m_uiCoord;
|
|||
|
|
uiLineCoord.fWidth = m_Property.UICoord.fWidth;
|
|||
|
|
|
|||
|
|
if( uiLineCoord.IsInside( fX, fY ) )
|
|||
|
|
{
|
|||
|
|
if( (int)m_vecLine[i]->m_vecWord.size() > 0 )
|
|||
|
|
{
|
|||
|
|
int nCurSelLine = GetMouseEnteredLine();
|
|||
|
|
if( nCurSelLine == i )
|
|||
|
|
{
|
|||
|
|
m_vecLine[nCurSelLine]->Select(true);
|
|||
|
|
m_vecLine[nCurSelLine]->SetMouseInLine(false);
|
|||
|
|
|
|||
|
|
const VECWORD& wordList = m_vecLine[nCurSelLine]->m_vecWord;
|
|||
|
|
VECWORD::const_iterator iter = wordList.begin();
|
|||
|
|
for (; iter != wordList.end(); ++iter)
|
|||
|
|
{
|
|||
|
|
const CWord& word = *iter;
|
|||
|
|
if (word.m_sProperty.uiCoord.IsInside(fX, fY))
|
|||
|
|
{
|
|||
|
|
m_WordSelected = word;
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int CEtUITextBox::GetSelectedLineIndex( bool bClearSelection /* = true */ ) const
|
|||
|
|
{
|
|||
|
|
if( m_nCurLine >= 0 )
|
|||
|
|
{
|
|||
|
|
int nCount(0);
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
|
|||
|
|
for( int i=m_nCurLine; i<nVecSize; i++, nCount++ )
|
|||
|
|
{
|
|||
|
|
if( nCount >= m_nVisibleCount )
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
if( m_vecLine[i]->IsSelected() )
|
|||
|
|
{
|
|||
|
|
if( bClearSelection )
|
|||
|
|
m_vecLine[i]->Select(false);
|
|||
|
|
|
|||
|
|
return i;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::UpdateTextBoxHeight()
|
|||
|
|
{
|
|||
|
|
if( m_Property.TextBoxProperty.VariableType == UI_TEXTBOX_HEIGHT ||
|
|||
|
|
m_Property.TextBoxProperty.VariableType == UI_TEXTBOX_BOTH )
|
|||
|
|
{
|
|||
|
|
float fLineHeight(0);
|
|||
|
|
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
for( int i=0; i<nVecSize; i++ )
|
|||
|
|
{
|
|||
|
|
CLine *line = m_vecLine[i];
|
|||
|
|
fLineHeight += line->m_uiCoord.fHeight;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
float fBeforeHeight, fAfterHeight;
|
|||
|
|
SUICoord sTextBoxCoord;
|
|||
|
|
GetUICoord(sTextBoxCoord);
|
|||
|
|
fBeforeHeight = sTextBoxCoord.fHeight;
|
|||
|
|
sTextBoxCoord.fHeight = fLineHeight;
|
|||
|
|
fAfterHeight = sTextBoxCoord.fHeight;
|
|||
|
|
SetUICoord(sTextBoxCoord);
|
|||
|
|
|
|||
|
|
if( !m_bNextPage )
|
|||
|
|
m_pParent->UpdateDlgCoord( 0, 0, 0, (fAfterHeight-fBeforeHeight) );
|
|||
|
|
|
|||
|
|
// NextPage<67><65> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE>ϴ<EFBFBD><CFB4><EFBFBD> Ȯ<><C8AE>
|
|||
|
|
if( m_pNextPageTextBox ) // && m_bAddTextToNextPage == false ) Remove<76><65> <20>پ<EFBFBD><D9BE>鶧<EFBFBD><E9B6A7> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7><EFBFBD> <20>˻<EFBFBD><CBBB><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
{
|
|||
|
|
if( m_eNextPageCondition == NextPage_DlgScreenHeight )
|
|||
|
|
{
|
|||
|
|
// ù<><C3B9>° <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>쿣 <20>̷<EFBFBD><CCB7><EFBFBD> <20>˻<EFBFBD><CBBB>ϰ<EFBFBD>,
|
|||
|
|
if( !m_bNextPage )
|
|||
|
|
{
|
|||
|
|
SUIElement *pElement = GetElement(0);
|
|||
|
|
if( pElement ) {
|
|||
|
|
SUICoord sTextCoord, sDlgCoord;
|
|||
|
|
m_pParent->CalcTextRect( L"x", pElement, sTextCoord );
|
|||
|
|
m_pParent->GetDlgCoord( sDlgCoord );
|
|||
|
|
if( sDlgCoord.fHeight + sTextCoord.fHeight > m_pParent->GetScreenHeightRatio() ) {
|
|||
|
|
m_bAddTextToNextPage = true;
|
|||
|
|
m_pNextPageTextBox->SetNextPageLineCount( GetLineSize(), m_nAdjustValue );
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if( GetLineSize() >= m_nNextPageLineCount )
|
|||
|
|
m_bAddTextToNextPage = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::UpdateTextBoxWidth()
|
|||
|
|
{
|
|||
|
|
if( m_Property.TextBoxProperty.VariableType == UI_TEXTBOX_WIDTH ||
|
|||
|
|
m_Property.TextBoxProperty.VariableType == UI_TEXTBOX_BOTH )
|
|||
|
|
{
|
|||
|
|
float fLineWidth(0);
|
|||
|
|
|
|||
|
|
int nVecSize = (int)m_vecLine.size();
|
|||
|
|
for( int i=0; i<nVecSize; i++ )
|
|||
|
|
{
|
|||
|
|
CLine *line = m_vecLine[i];
|
|||
|
|
if( fLineWidth < line->m_uiCoord.fWidth )
|
|||
|
|
{
|
|||
|
|
// Note : <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
//
|
|||
|
|
fLineWidth = line->m_uiCoord.fWidth;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
float fBeforeWidth, fAfterWidth;
|
|||
|
|
SUICoord sTextBoxCoord;
|
|||
|
|
GetUICoord(sTextBoxCoord);
|
|||
|
|
fBeforeWidth = sTextBoxCoord.fWidth;
|
|||
|
|
sTextBoxCoord.fWidth = fLineWidth;
|
|||
|
|
fAfterWidth = sTextBoxCoord.fWidth;
|
|||
|
|
SetUICoord(sTextBoxCoord);
|
|||
|
|
|
|||
|
|
m_pParent->UpdateDlgCoord(0, 0, (fAfterWidth-fBeforeWidth), 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::FitTextBoxToLine()
|
|||
|
|
{
|
|||
|
|
if( m_vecLine.empty() )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
int nvecLineSize = (int)m_vecLine.size();
|
|||
|
|
int nTemp = nvecLineSize - m_nCurLine;
|
|||
|
|
if( nTemp < m_nVisibleCount )
|
|||
|
|
{
|
|||
|
|
int nLineHeight = (int)(m_vecLine[0]->m_uiCoord.fHeight*m_pParent->GetScreenHeight());
|
|||
|
|
|
|||
|
|
SUICoord uiCoord;
|
|||
|
|
GetUICoord(uiCoord);
|
|||
|
|
uiCoord.fHeight = (nTemp*nLineHeight)/m_pParent->GetScreenHeight();
|
|||
|
|
SetUICoord(uiCoord);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::ClearMouseEnteredLine()
|
|||
|
|
{
|
|||
|
|
int nCurSelLine = GetMouseEnteredLine();
|
|||
|
|
if( nCurSelLine != -1 )
|
|||
|
|
{
|
|||
|
|
m_vecLine[nCurSelLine]->SetMouseInLine(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::ClearSelectedLine()
|
|||
|
|
{
|
|||
|
|
int nCurSelLine = GetSelectedLineIndex();
|
|||
|
|
if( nCurSelLine != -1 )
|
|||
|
|
{
|
|||
|
|
m_vecLine[nCurSelLine]->Select(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::UpdateTextBox()
|
|||
|
|
{
|
|||
|
|
UpdateTextBoxWidth();
|
|||
|
|
UpdateTextBoxHeight();
|
|||
|
|
|
|||
|
|
UpdateVisibleCount();
|
|||
|
|
|
|||
|
|
// [5/1/2009 nextome]
|
|||
|
|
// <20>̰<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʱ <20><>ũ<EFBFBD>ѹ<EFBFBD> <20>ʿ<EFBFBD><CABF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> disable <20>ȴ<EFBFBD>.
|
|||
|
|
m_ScrollBar.SetPageSize( m_nVisibleCount );
|
|||
|
|
m_ScrollBar.SetTrackRange( 0, ( int )m_vecLine.size() );
|
|||
|
|
m_ScrollBar.UpdateRects();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CEtUITextBox::GetSelectedLineData( SLineData &sLineData, bool bClearSelect ) const
|
|||
|
|
{
|
|||
|
|
int nCurSelLine = GetSelectedLineIndex(bClearSelect);
|
|||
|
|
if( nCurSelLine != -1 )
|
|||
|
|
{
|
|||
|
|
sLineData = m_vecLine[nCurSelLine]->GetLineData();
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const CWord& CEtUITextBox::GetSelectedWordData() const
|
|||
|
|
{
|
|||
|
|
return m_WordSelected;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::wstring CEtUITextBox::GetLastLineText()
|
|||
|
|
{
|
|||
|
|
if( GetUsedNextPage() ) {
|
|||
|
|
return m_pNextPageTextBox->GetLastLineText();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( m_vecLine.size() )
|
|||
|
|
return m_vecLine[m_vecLine.size()-1]->GetText();
|
|||
|
|
|
|||
|
|
return L"";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CEtUITextBox::GetLastLineCoord( SUICoord &Coord )
|
|||
|
|
{
|
|||
|
|
if( GetUsedNextPage() ) {
|
|||
|
|
return m_pNextPageTextBox->GetLastLineCoord( Coord );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( m_vecLine.size() )
|
|||
|
|
{
|
|||
|
|
Coord = m_vecLine[m_vecLine.size()-1]->m_uiCoord;
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::RemoveLastLine()
|
|||
|
|
{
|
|||
|
|
if( GetUsedNextPage() ) {
|
|||
|
|
m_pNextPageTextBox->RemoveLastLine();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD> <20>ٸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD>Ʈ <20>غ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
if( m_vecLine.size() )
|
|||
|
|
{
|
|||
|
|
SAFE_DELETE( m_vecLine[m_vecLine.size() - 1] );
|
|||
|
|
m_vecLine.pop_back();
|
|||
|
|
|
|||
|
|
m_nEndLine--;
|
|||
|
|
int nCurLine = m_nCurLine;
|
|||
|
|
|
|||
|
|
std::wstring::size_type endIdx;
|
|||
|
|
endIdx = m_szText.find_last_of(L"\n");
|
|||
|
|
m_szText = m_szText.substr(0, endIdx);
|
|||
|
|
|
|||
|
|
m_ScrollBar.SetTrackRange( 0, (int)m_vecLine.size() );
|
|||
|
|
|
|||
|
|
UpdateTextBox();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::ResizeLineTextWithSymbol(int nLineSize , std::wstring wszSymbol)
|
|||
|
|
{
|
|||
|
|
int nSize = GetLineSize();
|
|||
|
|
|
|||
|
|
for(int i=0;i<nSize - nLineSize;i++)
|
|||
|
|
RemoveLastLine();
|
|||
|
|
|
|||
|
|
std::wstring wszString = GetLineText(nLineSize-1);
|
|||
|
|
std::wstring wszSubString;
|
|||
|
|
|
|||
|
|
wszSubString = wszString.substr(0, wszString.size() - wszSymbol.size() );
|
|||
|
|
wszSubString += wszSymbol;
|
|||
|
|
|
|||
|
|
ClearText();
|
|||
|
|
AppendText( wszSubString.c_str() );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
void CEtUITextBox::SetNextPageTextBox( CEtUITextBox *pControl, eNextPageCondition eCondition, int nAdjustValue )
|
|||
|
|
{
|
|||
|
|
m_pNextPageTextBox = pControl;
|
|||
|
|
m_eNextPageCondition = eCondition;
|
|||
|
|
m_nAdjustValue = nAdjustValue;
|
|||
|
|
pControl->SetNextPage( true );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::SetNextPageLineCount( int nCount, int nAdjustValue )
|
|||
|
|
{
|
|||
|
|
m_nNextPageLineCount = nCount + nAdjustValue;
|
|||
|
|
if( m_pNextPageTextBox ) m_pNextPageTextBox->SetNextPageLineCount( nCount, nAdjustValue );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int CEtUITextBox::GetUsedNextPage()
|
|||
|
|
{
|
|||
|
|
if( !m_pNextPageTextBox ) return 0;
|
|||
|
|
|
|||
|
|
if( m_pNextPageTextBox->IsEmpty() )
|
|||
|
|
return 0;
|
|||
|
|
|
|||
|
|
// NextPage<67><65> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD> 3<><33>, 4<><34> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>۵<EFBFBD><DBB5>ϵ<EFBFBD><CFB5><EFBFBD> <20><><EFBFBD>ͷ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD>.
|
|||
|
|
return m_pNextPageTextBox->GetUsedNextPage() + 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::Process( float fElapsedTime )
|
|||
|
|
{
|
|||
|
|
m_CurrentState = UI_STATE_NORMAL;
|
|||
|
|
|
|||
|
|
if( !IsShow() )
|
|||
|
|
{
|
|||
|
|
m_CurrentState = UI_STATE_HIDDEN;
|
|||
|
|
}
|
|||
|
|
else if( !IsEnable() )
|
|||
|
|
{
|
|||
|
|
m_CurrentState = UI_STATE_DISABLED;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SUIElement *pElement = GetElement(0);
|
|||
|
|
if( !pElement ) return;
|
|||
|
|
|
|||
|
|
pElement->TextureColor.Blend( m_CurrentState, fElapsedTime, m_fBlendRate );
|
|||
|
|
pElement->ShadowFontColor.Blend( m_CurrentState, fElapsedTime, m_fBlendRate );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int CEtUITextBox::GetCaretWithWordBreak( const std::wstring& strText, const int nOrigCaret, bool bFirstWordInLine )
|
|||
|
|
{
|
|||
|
|
int nNewCaret = nOrigCaret;
|
|||
|
|
|
|||
|
|
// <20><>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
|||
|
|
std::vector<std::wstring> tokens;
|
|||
|
|
TokenizeW( strText, tokens );
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD> nOrigCaret<65><74><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ó<><C3B3>.
|
|||
|
|
if ( tokens.size() == 0 )
|
|||
|
|
return nOrigCaret;
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ó<><C3B3><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD> <20><><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD> <20><EFBFBD><EEB0A1> <20><> <20>ִ<EFBFBD>.
|
|||
|
|
// 1. A A(A<><41><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD><CCBD><EFBFBD> <20><><EFBFBD>ٳѰ<D9B3> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> A)
|
|||
|
|
// 2. A
|
|||
|
|
// 3. A
|
|||
|
|
// 4. A (<28><><EFBFBD><EFBFBD> A <20><> <20><><EFBFBD><EFBFBD>)
|
|||
|
|
// <20>̷<EFBFBD> <20>͵<EFBFBD><CDB5><EFBFBD> <20><><EFBFBD><EFBFBD> ó<><C3B3><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>극<EFBFBD><EAB7B9>ũ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ó<EFBFBD><C3B3> <20><> <20><><EFBFBD>̴<EFBFBD>.
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE><EFBFBD>ȿ<EFBFBD> -<2D><> <20>ִ<EFBFBD><D6B4><EFBFBD> Ȯ<><C8AE><EFBFBD>Ѵ<EFBFBD>. <20>ִٸ<D6B4> <20>и<EFBFBD><D0B8>ؼ<EFBFBD> <20>ִ´<D6B4>. ex:knocked-down => knocked-, down
|
|||
|
|
for( std::vector<std::wstring>::iterator iter = tokens.begin(); iter != tokens.end(); ++iter )
|
|||
|
|
{
|
|||
|
|
std::wstring::size_type nPos;
|
|||
|
|
if( (nPos = iter->find_first_of( L"-" )) != std::wstring::npos )
|
|||
|
|
{
|
|||
|
|
std::wstring wszWord1 = iter->substr(0, nPos+1);
|
|||
|
|
std::wstring wszWord2 = iter->substr(nPos+1);
|
|||
|
|
iter = tokens.erase(iter);
|
|||
|
|
iter = tokens.insert(iter, wszWord2);
|
|||
|
|
iter = tokens.insert(iter, wszWord1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ, <20><><EFBFBD><EFBFBD>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
|||
|
|
std::vector<int> vecTokenBeginPos;
|
|||
|
|
int nBeginPos = 0;
|
|||
|
|
for(int i = 0; i < (int)tokens.size(); ++i)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ֱ<D6B1><E2B6A7><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>˻縦 <20><><EFBFBD><EFBFBD> <20>Ѵ<EFBFBD>.
|
|||
|
|
int nSpaceCount = 0;
|
|||
|
|
while( strText[nBeginPos+nSpaceCount] == L' ' )
|
|||
|
|
++nSpaceCount;
|
|||
|
|
|
|||
|
|
nBeginPos += nSpaceCount;
|
|||
|
|
|
|||
|
|
vecTokenBeginPos.push_back(nBeginPos);
|
|||
|
|
nBeginPos += (int)tokens[i].size();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ó<><C3B3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̹<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ѿ<D1BE>ٸ<EFBFBD> <20>׳<EFBFBD> <20><><EFBFBD><EFBFBD> ij<><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ó<EFBFBD><C3B3><EFBFBD>Ѵ<EFBFBD>. <20><><EFBFBD><EFBFBD> 3<><33> ó<><C3B3>.
|
|||
|
|
if( (int)vecTokenBeginPos.size() > 0 && nOrigCaret < vecTokenBeginPos[0] )
|
|||
|
|
return nOrigCaret;
|
|||
|
|
|
|||
|
|
// ù<><C3B9>° <20>ܾ<EFBFBD><DCBE><EFBFBD>ü<EFBFBD><C3BC> <20>ʹ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ѿ<D1BE><EEBCAD> Orig<69><67><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>.
|
|||
|
|
// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa <20>̷<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>Ȳ.
|
|||
|
|
if( bFirstWordInLine && (int)vecTokenBeginPos.size() > 0 && vecTokenBeginPos[0] < nOrigCaret && nOrigCaret < vecTokenBeginPos[0]+(int)tokens[0].size() )
|
|||
|
|
return nOrigCaret;
|
|||
|
|
|
|||
|
|
// ù<><C3B9>° <20>ܾ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD>,
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ѿ<D1BE><EEB0A1> <20><><EFBFBD><EFBFBD>+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ó<><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ij<><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߶<EFBFBD> ó<><C3B3><EFBFBD>Ѵ<EFBFBD>. <20><><EFBFBD><EFBFBD> 1,2<><32> ó<><C3B3>.
|
|||
|
|
int nFirstWordSpaceCount = 0;
|
|||
|
|
while( strText[vecTokenBeginPos[0]+(int)tokens[0].size()+nFirstWordSpaceCount] == L' ' )
|
|||
|
|
++nFirstWordSpaceCount;
|
|||
|
|
if( vecTokenBeginPos[0]+(int)tokens[0].size() < nOrigCaret &&
|
|||
|
|
nOrigCaret <= vecTokenBeginPos[0]+(int)tokens[0].size()+nFirstWordSpaceCount )
|
|||
|
|
return nOrigCaret;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>̷<EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
std::wstring strWord;
|
|||
|
|
for(int i = 0; i < (int)vecTokenBeginPos.size(); ++i)
|
|||
|
|
{
|
|||
|
|
if( nNewCaret < vecTokenBeginPos[i] )
|
|||
|
|
{
|
|||
|
|
nNewCaret = vecTokenBeginPos[i-1];
|
|||
|
|
strWord = tokens[i-1];
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( nNewCaret > vecTokenBeginPos[(int)vecTokenBeginPos.size()-1] )
|
|||
|
|
{
|
|||
|
|
nNewCaret = vecTokenBeginPos[(int)vecTokenBeginPos.size()-1];
|
|||
|
|
strWord = tokens[(int)vecTokenBeginPos.size()-1];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// word-break<61><6B> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ȯ<><C8AE><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
/*
|
|||
|
|
bool bWordBreakApply1 = false;
|
|||
|
|
bool bWordBreakApply2 = false;
|
|||
|
|
bool bWordBreakApply3 = true;
|
|||
|
|
// <20><><EFBFBD><EFBFBD>% <20><> <20><><EFBFBD>쿡<EFBFBD><ECBFA1> word-break<61><6B> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
if( strWord.size() > 1 && strWord[(int)strWord.size()-1] == L'%' )
|
|||
|
|
{
|
|||
|
|
bWordBreakApply1 = true;
|
|||
|
|
for( int i = 0; i < (int)strWord.size()-1; ++i )
|
|||
|
|
{
|
|||
|
|
if( L'0' <= strWord[i] && strWord[i] <= L'9' )
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
bWordBreakApply1 = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD>쿡<EFBFBD><ECBFA1> word-break<61><6B> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
if( strWord.size() > 1 && (strWord[(int)strWord.size()-1] == L'.' || strWord[(int)strWord.size()-1] == L','))
|
|||
|
|
{
|
|||
|
|
bWordBreakApply2 = true;
|
|||
|
|
for( int i = 0; i < (int)strWord.size()-1; ++i )
|
|||
|
|
{
|
|||
|
|
if( ((L'a' <= strWord[i] && strWord[i] <= L'z') ||
|
|||
|
|
(L'A' <= strWord[i] && strWord[i] <= L'Z') )
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
bWordBreakApply2 = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
bool bWordBreakApply = true;
|
|||
|
|
|
|||
|
|
// .<2E><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, ,<2C><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, %<25><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>˻<EFBFBD><CBBB>ϴ<EFBFBD> <20>ʹ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
|
// <20><EFBFBD><D7B7><EFBFBD> <20>׳<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ȿ<EFBFBD> <20><><EFBFBD>ԵǸ<D4B5> <20><> <20>Ǵ°ɷ<C2B0> ó<><C3B3><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
// 3th, 4m <20>̷<EFBFBD><CCB7>͵<EFBFBD> <20>ֱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>̴<EFBFBD>.
|
|||
|
|
for( int i = 0; i < (int)strWord.size(); ++i )
|
|||
|
|
{
|
|||
|
|
//if( iswalpha(strWord[i]) == false ) // iswalpha<68><61> <20>˻<EFBFBD><CBBB>ϸ<EFBFBD> <20>ѱ۵<D1B1> alpha<68><61> <20><><EFBFBD>´<EFBFBD>. <20>׳<EFBFBD> iswletter<65>ε<EFBFBD>.
|
|||
|
|
if( (L'a' <= strWord[i] && strWord[i] <= L'z') ||
|
|||
|
|
(L'A' <= strWord[i] && strWord[i] <= L'Z') ||
|
|||
|
|
(0x0400 <= strWord[i] && strWord[i] <= 0x052F) || // <20><><EFBFBD>þƾ<C3BE> <20>߰<EFBFBD>.
|
|||
|
|
(L'0' <= strWord[i] && strWord[i] <= L'9') ||
|
|||
|
|
strWord[i] == L'.' ||
|
|||
|
|
strWord[i] == L',' ||
|
|||
|
|
strWord[i] == L'*' ||
|
|||
|
|
strWord[i] == L'%' ||
|
|||
|
|
strWord[i] == L'-' ||
|
|||
|
|
strWord[i] == L'/' ||
|
|||
|
|
strWord[i] == L'(' ||
|
|||
|
|
strWord[i] == L')' ||
|
|||
|
|
strWord[i] == L'[' ||
|
|||
|
|
strWord[i] == L']' ||
|
|||
|
|
strWord[i] == L':' ||
|
|||
|
|
strWord[i] == L'!' ||
|
|||
|
|
strWord[i] == L'?' ||
|
|||
|
|
strWord[i] == L'\"' ||
|
|||
|
|
strWord[i] == L'\'' ) // I'll <20>Ǵ<EFBFBD> target's
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
bWordBreakApply = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//if( bWordBreakApply1 || bWordBreakApply2 || bWordBreakApply3 )
|
|||
|
|
if( bWordBreakApply )
|
|||
|
|
{
|
|||
|
|
return nNewCaret;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return nOrigCaret;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CEtUITextBox::FindInputPos( std::vector<EtVector2> &vecPos )
|
|||
|
|
{
|
|||
|
|
CEtUIDialog *pDialog = GetParent();
|
|||
|
|
if( !pDialog ) return;
|
|||
|
|
|
|||
|
|
if( m_vecLine.size() > 0 )
|
|||
|
|
{
|
|||
|
|
m_ScrollBar.FindInputPos( vecPos );
|
|||
|
|
}
|
|||
|
|
}
|