343 lines
9.4 KiB
C++
343 lines
9.4 KiB
C++
// KTextPhrase.h: interface for the KTextPhrase class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#if !defined(AFX_KTEXTPHRASE_H__A288181A_729C_4DAE_86B0_800C3D9FC440__INCLUDED_)
|
|
#define AFX_KTEXTPHRASE_H__A288181A_729C_4DAE_86B0_800C3D9FC440__INCLUDED_
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#endif // _MSC_VER > 1000
|
|
|
|
#include "K3DTypes.h"
|
|
#include "KTextRender.h"
|
|
|
|
#pragma warning(disable:4018)
|
|
#pragma warning(disable:4244)
|
|
#pragma warning(disable:40)
|
|
|
|
class KViewportObject;
|
|
class KTextParser;
|
|
class KTextPhrase
|
|
{
|
|
public:
|
|
struct KTEXT_LINE_OBJECT;
|
|
public:
|
|
|
|
// sonador #2.3.1.22 [라펠즈 0003413]: [UI/러시아] 캐릭터 생성화면의 캐릭터 직업 설명란의 글의 창을 벗어나는 문제
|
|
enum
|
|
{
|
|
KDEFAULT_LINE_GAP = 3,
|
|
};
|
|
|
|
enum
|
|
{
|
|
KRENDER_LAYER_DEFAULT = 80,
|
|
};
|
|
|
|
KTextPhrase();
|
|
KTextPhrase(DWORD dwWidth, DWORD dwHeight, DWORD dwLineGap = KDEFAULT_LINE_GAP, bool bStaticSize = false);
|
|
~KTextPhrase();
|
|
|
|
// pWidth 는 Input Argument
|
|
static DWORD GetOneLineStringByte(LPCSTR lpszText, DWORD dwWidth);
|
|
static KSize GetStringSize(LPCSTR lpszString, DWORD dwWidth, DWORD dwLineGap = KDEFAULT_LINE_GAP);
|
|
// 2010.08.26 가장 긴 문자라인의 길이를 구한다 - prodongi
|
|
static KSize GetLongestStringSize(LPCSTR lpszString, DWORD dwWidth, DWORD dwLineGap = KDEFAULT_LINE_GAP);
|
|
// 2010.08.26 문자열의 길이 정보를 계산한다 - prodongi
|
|
static void calculStringSize(LPCSTR lpszString, DWORD dwWidth, DWORD& totalWidth, DWORD& totalHeight, DWORD& longestWidth, DWORD dwLineGap = KDEFAULT_LINE_GAP);
|
|
static DWORD GetOneLineStringSize(LPCSTR lpszString, DWORD* pWidth = NULL, DWORD* pHeight = NULL);
|
|
|
|
static void GetSplitString(LPCSTR lpszString, DWORD dwWidth, std::vector<std::string>& splitList, bool bUseFontSize = false );
|
|
|
|
|
|
static void ConvertTag( std::string& rOutText, DWORD dwFlag );
|
|
static void AttachTag( std::string& rOutText, const char* lpStartTag, const char* lpEndTag );
|
|
static void AttachFontSizeAndColor( std::string& rOutText, const int& nSize, const KColor& color );
|
|
static void AttachOffSet( std::string& rOutText, const DWORD& nOffSet );
|
|
|
|
#ifdef _COUNTRY_ME_
|
|
static void GetStringSize(LPCSTR lpszFontName, int nFontSize, BOOL bBold, LPCSTR lpszString, int nStringLen,
|
|
DWORD * pStrWidth, DWORD * pStrHeight);
|
|
static void GetTextWidth( const wchar_t *text, size_t len, LPSIZE lpSize );
|
|
// 2010.08.24 - prodongi
|
|
static std::string GetSplitString2(char const* fontName, int fontSize, std::string const& oriStr, DWORD splitWidth);
|
|
|
|
void SetEllipsize( bool bEllipsize )
|
|
{
|
|
m_bEllipsize = bEllipsize;
|
|
}
|
|
|
|
bool GetEllipsize()
|
|
{
|
|
return m_bEllipsize;
|
|
}
|
|
|
|
bool m_bEllipsize;
|
|
#endif
|
|
|
|
void Clear();
|
|
void Initialize(DWORD dwWidth, DWORD dwHeight, DWORD dwLineGap = KDEFAULT_LINE_GAP);
|
|
|
|
// 2010.09.03 - prodongi
|
|
void AddString(LPCSTR lpszString, float fZPos=0.0f, bool bTagEnable = true, bool bStaticSize = false, bool bUseEmoticonFilter = true, bool scroll = false, DWORD maxWidth = 0);
|
|
//void AddString(LPCSTR lpszString, float fZPos=0.0f, bool bTagEnable = true, bool bStaticSize = false, bool bUseEmoticonFilter = true);
|
|
void SetMaxLine(DWORD dwMaxLine) {m_dwMaxLine = dwMaxLine; }
|
|
void SetLineGap(DWORD dwLineGap) { m_dwLineGap = dwLineGap; }
|
|
|
|
void SetReverseRender(bool bReverse) { m_bReverseRendering = bReverse; }
|
|
void SetVisibility(float fVisibility)
|
|
{
|
|
m_fVisibility = fVisibility;
|
|
}
|
|
float GetVisibility()
|
|
{
|
|
return m_fVisibility;
|
|
}
|
|
|
|
void SetCaptionRandomColor( bool bFlag );
|
|
|
|
void SetPosition( float x, float y, float z);
|
|
void SetAddPosition(float xAdd, float yAdd, float zAdd = 0.0f);
|
|
void SetZPosition(float fZPos);
|
|
const K3DVertex& GetPosition()
|
|
{
|
|
return m_vPosition;
|
|
}
|
|
|
|
void Render(KViewportObject * pViewport, bool isFront = false);
|
|
void SetClipRect(const KRect & rcRect);
|
|
|
|
void SetAlign(DWORD dwAlign);
|
|
DWORD GetAlign();
|
|
|
|
/// 총 Line의 수
|
|
DWORD GetLineNumber()
|
|
{
|
|
return DWORD( m_vtLineList.size() );
|
|
}
|
|
|
|
/// 총 Line중 m_dwHeight의 값을 넘어가게 되는 Line의 수
|
|
DWORD GetOverLineNumber();
|
|
/// 현재 총 Line의 Height의 합을 Return
|
|
DWORD GetTotalLineHeigt();
|
|
|
|
KTEXT_LINE_OBJECT * GetLineObject(DWORD dwLineIndex)
|
|
{
|
|
return m_vtLineList.at(dwLineIndex);
|
|
}
|
|
|
|
void SetFirstLine(float fFirstLine)
|
|
{
|
|
m_fFirstLine = fFirstLine;
|
|
SetAlign(m_dwAlign);
|
|
}
|
|
|
|
float GetFirstLine()
|
|
{
|
|
return m_fFirstLine;
|
|
}
|
|
|
|
/** 1Page에 표시될 수 있는 Line의 Index
|
|
(밑에서부터 시작된다)
|
|
ex : 채팅페이지에서 알아서 스크롤 되게 하려면 GetPageLineNumber() 를 통한 값을
|
|
SetFirstLine()으로 설정하면 됨 */
|
|
float GetPageLineNumber();
|
|
void SetCaretPos( int nPos ) { m_nCaretPos = nPos; }
|
|
void SetCaretEnable(bool bEnable) { m_bCaretEnable = bEnable; }
|
|
DWORD GetWidth()
|
|
{
|
|
return m_dwWidth;
|
|
}
|
|
DWORD GetHeight()
|
|
{
|
|
return m_dwHeight;
|
|
}
|
|
|
|
KTextParser * GetParser() { return m_pTextParser; }
|
|
|
|
/// MIMI 2005/08/16 이모티콘이 있는 경우 텍스트 길이 달라진다.
|
|
const int GetTextSize( const char* szBuf ) const;
|
|
const SIZE GetTextureSize() const { return m_sizeTexture; };
|
|
|
|
void SetEditMode( bool bFlag );
|
|
|
|
/// 2010.05.04 이모티콘 사이즈 변경 - prodongi
|
|
void modifyEmoticonSize(std::string const& aniName, int width, int height);
|
|
|
|
#ifndef _COUNTRY_ME_
|
|
/// 2011.02.23 스프라이트 스크롤 설정 정보를 저장하는 구조체 - prodongi
|
|
struct sSpriteScrollInfo
|
|
{
|
|
sSpriteScrollInfo() : m_scroll(false), m_type(0), m_v(0.0f), m_margin(0.0f) {}
|
|
void operator = (sSpriteScrollInfo const& info)
|
|
{
|
|
set(info.m_scroll, info.m_type, info.m_v, info.m_margin);
|
|
}
|
|
|
|
void set(bool scroll, DWORD type, float v, float margin)
|
|
{
|
|
m_scroll = scroll;
|
|
m_type = type;
|
|
m_v = v;
|
|
m_margin = margin;
|
|
}
|
|
bool m_scroll;
|
|
DWORD m_type;
|
|
float m_v;
|
|
float m_margin;
|
|
};
|
|
|
|
void setSpriteScroll(bool scroll, DWORD type, float v, float margin); /// 2011.01.18 - prodongi
|
|
void setSpriteScrollInfo(KTextPhrase::sSpriteScrollInfo const& info); /// 2011.02.23 - prodongi
|
|
void getSpriteScrollInfo(KTextPhrase::sSpriteScrollInfo& info); /// 2011.02.23 - prodongi
|
|
void updateSpriteScrollInfo(); /// 2011.02.23 - prodongi
|
|
std::vector<KTEXT_LINE_OBJECT *>* GetLineList() { return &m_vtLineList; } /// 2011.03.23 - servantes
|
|
sSpriteScrollInfo* GetSpriteScrollInfo() { return &m_spriteScrollInfo; } /// 2011.03.23 - servantes
|
|
#endif
|
|
|
|
private:
|
|
/// Evaulate default caret pos by align when lineobject vector is empty.
|
|
void _SetDefaultCaretPos(float* fXPos, float* fYPos);
|
|
|
|
K3DVertex m_vPosition;
|
|
|
|
float m_fVisibility;
|
|
|
|
DWORD m_dwWidth;
|
|
DWORD m_dwHeight;
|
|
|
|
DWORD m_dwMaxLine;
|
|
|
|
DWORD m_dwAlign; ///< KTextRender::KTALIGN_~ 을 사용
|
|
|
|
/** Align중에서 Y축 Align을 위해서 필요한 값
|
|
(SetAlign이 호출될때마다 매번 새로 계산한다)
|
|
(X축 Align은 m_vtLineList에 저장되어 있다) */
|
|
int m_nYAlignPos;
|
|
|
|
/** 각 Line 사이의 공간
|
|
(생성할때만 바꿀 수 있음) */
|
|
DWORD m_dwLineGap;
|
|
|
|
/** 처음으로 찍여야 할 Line
|
|
float이므로 line의 중간으로 찍히게 할 수도 있다. */
|
|
float m_fFirstLine;
|
|
|
|
int m_nCaretPos;
|
|
bool m_bCaretEnable;
|
|
|
|
/// If this flag is enable, render from vector's back to vector's front.
|
|
bool m_bReverseRendering;
|
|
|
|
public:
|
|
#ifdef _COUNTRY_ME_
|
|
struct KTEXT_OBJECT
|
|
{
|
|
union
|
|
{
|
|
KTextRender *pTextRender;
|
|
KTextEmoticon *pEmoticonRender;
|
|
};
|
|
int nType;
|
|
DWORD dwXPos;
|
|
DWORD dwXWidth;
|
|
};
|
|
|
|
struct KTEXT_LINE_OBJECT
|
|
{
|
|
// X축으로 보정해서 찍어줘야할 값이 들어감
|
|
DWORD dwXAlignPos;
|
|
// 현재 이 줄의 넓이
|
|
DWORD dwLineWidth;
|
|
// 현재 이 줄의 높이 (항상 Max값만 사용한다)
|
|
DWORD dwLineHeight;
|
|
|
|
std::vector<KTEXT_OBJECT> vtLineObject;
|
|
|
|
KTEXT_LINE_OBJECT()
|
|
{
|
|
dwXAlignPos = 0;
|
|
dwLineWidth = 0;
|
|
dwLineHeight = 0;
|
|
}
|
|
~KTEXT_LINE_OBJECT()
|
|
{
|
|
for(int i = 0; i < vtLineObject.size(); ++i)
|
|
{
|
|
if ( vtLineObject.at(i).nType == 0 )
|
|
{
|
|
if( vtLineObject.at(i).pTextRender )
|
|
delete vtLineObject.at(i).pTextRender;
|
|
}
|
|
else
|
|
{
|
|
if( vtLineObject.at(i).pEmoticonRender )
|
|
delete vtLineObject.at(i).pEmoticonRender;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
#else
|
|
|
|
struct KTEXT_OBJECT
|
|
{
|
|
KTextRender * pRender;
|
|
DWORD dwXPos;
|
|
short nOffsetY; ///< 그려질 오브젝트 y 오프셋
|
|
DWORD dwXWidth;
|
|
|
|
KTEXT_OBJECT()
|
|
: pRender(NULL), dwXPos(0), nOffsetY(0), dwXWidth(0)
|
|
{
|
|
}
|
|
};
|
|
|
|
struct KTEXT_LINE_OBJECT
|
|
{
|
|
DWORD dwXAlignPos; ///< X축으로 보정해서 찍어줘야할 값이 들어감
|
|
DWORD dwLineWidth; ///< 현재 이 줄의 넓이
|
|
DWORD dwLineHeight; ///< 현재 이 줄의 높이 (항상 Max값만 사용한다)
|
|
|
|
std::vector<KTEXT_OBJECT> vtLineObject;
|
|
|
|
KTEXT_LINE_OBJECT()
|
|
{
|
|
dwXAlignPos = 0;
|
|
dwLineWidth = 0;
|
|
dwLineHeight = 0;
|
|
}
|
|
~KTEXT_LINE_OBJECT()
|
|
{
|
|
for(int i = 0; i < vtLineObject.size(); ++i)
|
|
{
|
|
if( vtLineObject.at(i).pRender )
|
|
delete vtLineObject.at(i).pRender;
|
|
}
|
|
}
|
|
};
|
|
|
|
#endif
|
|
|
|
private:
|
|
|
|
KTextParser * m_pTextParser; ///< Parser
|
|
|
|
KTextRender * m_pCaretRender; ///< Caret
|
|
|
|
std::vector<KTEXT_LINE_OBJECT *> m_vtLineList; ///< 찍을 Object들
|
|
|
|
// MIMI 2005/08/16
|
|
/// edit box 는 고정된 크기(라인과 폰트크기)를 가지고 static control 은 이모티콘 원본 리소스 크기를 가진다.
|
|
bool m_bStaticSize;
|
|
SIZE m_sizeTexture;
|
|
|
|
bool m_bCaptionRandomColor;
|
|
|
|
#ifndef _COUNTRY_ME_
|
|
sSpriteScrollInfo m_spriteScrollInfo; /// 2011.02.23 - prodongi
|
|
#endif
|
|
};
|
|
|
|
#endif // !defined(AFX_KTEXTPHRASE_H__A288181A_729C_4DAE_86B0_800C3D9FC440__INCLUDED_)
|