1209 lines
29 KiB
C++
1209 lines
29 KiB
C++
#include "stdafx.h"
|
|
#include "KUIWnd.h"
|
|
#include "KRenderObject.h"
|
|
#include "KPrimitiveSprite.h"
|
|
#include "KResourceManager.h"
|
|
#include "KUITextureManager.h"
|
|
#include "KUIDefine.h"
|
|
#include "KUIWndManager.h"
|
|
#include "./Controls/KUIControl.h"
|
|
#include "./Controls/KUIControlNumber.h"
|
|
|
|
#include <toolkit/XStringUtil.h>
|
|
|
|
#ifndef WM_MOUSEWHEEL
|
|
#define WM_MOUSEWHEEL 0x020A
|
|
#endif
|
|
|
|
#ifdef _DEV
|
|
/// 2011.11.24 - prodongi
|
|
bool KUIValidChecker::isProcessingMsg = false;
|
|
#endif
|
|
|
|
#define BOUNDING_CONTROL_NAME "bounding_frame" /// 2011.02.16 - prodongi
|
|
|
|
using namespace KUI_MESSAGE;
|
|
|
|
bool KUIWnd::s_bIsEnterChatMode = false;
|
|
|
|
KUIWnd::KUIWnd(void)
|
|
{
|
|
|
|
m_bDestroy = false;
|
|
m_bShowFlag = true;
|
|
m_bEnable = true;
|
|
|
|
// { [sonador]
|
|
#ifdef _KUI_INVALIDATION
|
|
m_bValidation = false;
|
|
#endif
|
|
// }
|
|
|
|
m_dwFlag = 0;
|
|
m_dwStyle = 0;
|
|
m_dwAnchor = 0;
|
|
|
|
m_nSortValue = 0;
|
|
m_fZPos = 5.0f;
|
|
m_fAlpha = 1.0f;
|
|
|
|
m_dwCaptionAlign = KTextRender::KTALIGN_LEFT | KTextRender::KTALIGN_VCENTER;
|
|
|
|
m_pParent = NULL;
|
|
m_pCaptionPhrase = NULL;
|
|
|
|
m_pManager = NULL;
|
|
m_bHasFocus = false;
|
|
m_pMouseDownWnd = NULL;
|
|
|
|
// 기본적으론 무한대 -_-
|
|
m_rcClipArea = KRect(0,0,4096,4096);
|
|
|
|
m_rcCorrectionRect = KRect(0,0,0,0);
|
|
|
|
// MJ 2004/12/01 // alpha
|
|
m_bShowAlpha = false;
|
|
m_bCloseAlpha = false;
|
|
m_dwAlphaTime = 0;
|
|
m_bText = false;
|
|
|
|
m_pOnToolTipWnd = NULL;
|
|
|
|
m_bActivate = false;
|
|
#ifdef _KUI_INVALIDATION
|
|
m_bPopupWnd = false;
|
|
#endif
|
|
|
|
m_isMouseFocusOn = false;
|
|
|
|
m_boundingControl = NULL; /// 2011.02.16 - prodongi
|
|
/// 2011.06.14 mantis 13132 - prodongi
|
|
m_isWeb = false;
|
|
}
|
|
|
|
|
|
KUIWnd::~KUIWnd(void)
|
|
{
|
|
_ClearChildList();
|
|
}
|
|
|
|
void KUIWnd::Create(KUIWND_CREATE_ARG& CREATE_ARG)
|
|
{
|
|
|
|
m_dwFlag = CREATE_ARG.dwFlag;
|
|
m_dwStyle = CREATE_ARG.dwStyle;
|
|
m_dwAnchor = CREATE_ARG.dwAnchor;
|
|
|
|
m_sClassName = CREATE_ARG.lpszClassName;
|
|
m_sID = CREATE_ARG.lpszID;
|
|
m_rcRegion = CREATE_ARG.rcRect;
|
|
m_rcCaptionArea = CREATE_ARG.rcRect;
|
|
|
|
if( false == CREATE_ARG.lpszSprName.empty() )
|
|
m_sSprName = CREATE_ARG.lpszSprName;
|
|
|
|
if( false == CREATE_ARG.lpszAniName.empty() )
|
|
m_sAniName = CREATE_ARG.lpszAniName;
|
|
|
|
m_nFrameIndex = CREATE_ARG.nFrameIndex;
|
|
m_pManager = CREATE_ARG.pWndManager;
|
|
m_pParent = CREATE_ARG.pParent;
|
|
m_sCaption = CREATE_ARG.lpszCaption;
|
|
if( m_pCaptionHandler )
|
|
m_pCaptionHandler->onSetCaption( m_sCaption );
|
|
m_sTip = CREATE_ARG.lpszToolTip;
|
|
}
|
|
|
|
void KUIWnd::OnSizeChangeNofity(const KRect& rcNewRect)
|
|
{
|
|
int nXMove = rcNewRect.right - m_rcRegion.right;
|
|
int nYMove = rcNewRect.bottom - m_rcRegion.bottom;
|
|
|
|
m_rcRegion = rcNewRect;
|
|
m_rcCaptionArea = rcNewRect;
|
|
|
|
|
|
for (std::list< KUIWnd* >::reverse_iterator it = m_listChild.rbegin(); it != m_listChild.rend() ; ++it )
|
|
(*it)->OnParentSizeChangeNotify(rcNewRect, nXMove, nYMove, m_dwStyle);
|
|
|
|
#ifdef _KUI_INVALIDATION
|
|
// { [sonador]
|
|
InvalidateWnd();
|
|
// }
|
|
#endif
|
|
}
|
|
|
|
void KUIWnd::OnPosChangeNofity(int XOffset, int YOffset)
|
|
{
|
|
for (std::list< KUIWnd* >::reverse_iterator it = m_listChild.rbegin(); it != m_listChild.rend() ; ++it )
|
|
(*it)->OnParentPosChangeNotify(XOffset, YOffset);
|
|
}
|
|
|
|
void KUIWnd::OnClipChangeNotify(const KRect& rcClipRect)
|
|
{
|
|
m_rcClipArea = rcClipRect;
|
|
|
|
for (std::list< KUIWnd* >::reverse_iterator it = m_listChild.rbegin(); it != m_listChild.rend() ; ++it )
|
|
(*it)->OnParentClipChangeNotify(rcClipRect);
|
|
}
|
|
|
|
void KUIWnd::OnAlphaChangeNotify(float fAlpha)
|
|
{
|
|
fAlpha = min( 1.0f, fAlpha);
|
|
fAlpha = max( 0.0f, fAlpha);
|
|
|
|
float fAlphaDiff = fAlpha - m_fAlpha ;
|
|
m_fAlpha = fAlpha;
|
|
|
|
for (std::list< KUIWnd* >::reverse_iterator it = m_listChild.rbegin(); it != m_listChild.rend() ; ++it )
|
|
(*it)->OnParentAlphaChangeNotify( fAlphaDiff );
|
|
|
|
#ifdef _KUI_INVALIDATION
|
|
// { [sonador]
|
|
InvalidateWnd();
|
|
// }
|
|
#endif
|
|
}
|
|
|
|
void KUIWnd::OnParentSizeChangeNotify(const KRect& rcNewRect,int nXMove, int nYMove, int nResizeStyle)
|
|
{
|
|
#ifdef _KUI_INVALIDATION
|
|
// { [sonador]
|
|
InvalidateWnd();
|
|
// }
|
|
#endif
|
|
}
|
|
|
|
void KUIWnd::OnParentPosChangeNotify(int XOffset, int YOffset)
|
|
{
|
|
}
|
|
|
|
void KUIWnd::OnParentClipChangeNotify(const KRect& rcClipRect)
|
|
{
|
|
}
|
|
|
|
void KUIWnd::OnParentAlphaChangeNotify(float fAlphaDiff)
|
|
{
|
|
#ifdef _KUI_INVALIDATION
|
|
// { [sonador]
|
|
InvalidateWnd();
|
|
// }
|
|
#endif
|
|
}
|
|
|
|
void KUIWnd::OnChangeCaptionNotify()
|
|
{
|
|
#ifdef _KUI_INVALIDATION
|
|
// { [sonador]
|
|
InvalidateWnd();
|
|
// }
|
|
#endif
|
|
}
|
|
|
|
void KUIWnd::OnChangeAniNameNotify()
|
|
{
|
|
#ifdef _KUI_INVALIDATION
|
|
// { [sonador]
|
|
InvalidateWnd();
|
|
// }
|
|
#endif
|
|
}
|
|
|
|
void KUIWnd::OnChagneBackNotify()
|
|
{
|
|
#ifdef _KUI_INVALIDATION
|
|
// { [sonador]
|
|
InvalidateWnd();
|
|
// }
|
|
#endif
|
|
}
|
|
|
|
#ifdef _KUI_INVALIDATION
|
|
// { [sonador]
|
|
void KUIWnd::ValidateWnd()
|
|
{
|
|
if( false == m_bValidation )
|
|
{
|
|
SetValidation( true );
|
|
|
|
OnValidate();
|
|
|
|
if( !m_listChild.empty() )
|
|
{
|
|
//struct VWF { void operator () ( KUIWnd* window ) { window->ValidateWnd(); } };
|
|
//std::for_each( m_listChild.begin(), m_listChild.end(), VWF() );
|
|
std::for_each( m_listChild.begin(), m_listChild.end(),
|
|
std::mem_fun( &KUIWnd::ValidateWnd ) );
|
|
}
|
|
}
|
|
}
|
|
|
|
void KUIWnd::InvalidateWnd()
|
|
{
|
|
if( m_bValidation == true && m_bPopupWnd == false )
|
|
{
|
|
SetValidation( false );
|
|
|
|
OnInvalidate();
|
|
|
|
if( GetParent() )
|
|
GetParent()->InvalidateWnd();
|
|
}
|
|
}
|
|
// }
|
|
#endif
|
|
|
|
void KUIWnd::Process(DWORD dwTime)
|
|
{
|
|
// { [sonador] performance tunning
|
|
std::list< KUIWnd* >::reverse_iterator rend = m_listChild.rend();
|
|
// }
|
|
for ( std::list< KUIWnd* >::reverse_iterator it = m_listChild.rbegin(); it != rend ; ++it )
|
|
{
|
|
(*it)->Process( dwTime );
|
|
}
|
|
}
|
|
|
|
void KUIWnd::Render(KViewportObject * pViewport, bool isFront)
|
|
{
|
|
if ( m_bShowFlag )
|
|
{
|
|
// { [sonador] performance tunning
|
|
std::list< KUIWnd* >::iterator end = m_listChild.end();
|
|
// }
|
|
for (std::list< KUIWnd* >::iterator it = m_listChild.begin(); it != end ; ++it )
|
|
{
|
|
#ifdef _KUI_INVALIDATION
|
|
if( !(*it)->IsPopup() )
|
|
#endif
|
|
(*it)->Render( pViewport, isFront );
|
|
}
|
|
}
|
|
}
|
|
|
|
DWORD KUIWnd::OnMouseMessage(DWORD dwMessage, int x, int y)
|
|
{
|
|
// 메시지를 아예 안받는 Control
|
|
if( m_dwFlag & KFLAG_NO_GET_MESSAGE )
|
|
return KMR_NO_GET;
|
|
|
|
if ( !m_bShowFlag )
|
|
return KMR_NO_GET;
|
|
|
|
KUIWnd *pMouseWnd = NULL;
|
|
bool bFindGetChild = false;
|
|
|
|
DWORD dwChildRetMsg = 0;
|
|
DWORD dwAddMsg = 0;
|
|
|
|
#ifndef NDEBUG
|
|
if( dwMessage == KLBUTTON_DOWN )
|
|
{
|
|
int nDebug = 1;
|
|
}
|
|
#endif
|
|
|
|
|
|
//gmpbigsun( 20130228 ) : [주의!] m_listChild를 iterating하는 과정중에 pWnd->OnMouseMessage(dwMessage, x,y) 함수호출로 인하여
|
|
//부모(this)의 pumpupmessage가 불리면서 해당 클래서에서 만약 m_listChild에 대하여 삽입 삭제를 할경우 반복자가 무효화 되는경우가 생긴다.!!!!
|
|
|
|
// 뒤에서 부터 검사 (맨 위에 있는것 부터)
|
|
int k=0;
|
|
for ( std::list< KUIWnd* >::reverse_iterator it = m_listChild.rbegin(); it != m_listChild.rend() ; ++it, k++ )
|
|
{
|
|
KUIWnd *pWnd = (*it);
|
|
|
|
bool isInRect = pWnd->IsInRectWithChild( x, y );
|
|
checkMouseFocusOn(pWnd, isInRect);
|
|
|
|
if( (dwChildRetMsg & KMR_CHILD_IN_MSG) )
|
|
{
|
|
if(isInRect)
|
|
{
|
|
// 마우스 메시지가 이미 한번 갔으면 밑으로 겹친 녀석에게는 어이없는 좌표로 보내주자.
|
|
pWnd->OnMouseMessage( dwMessage, -65535, -65535);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
DWORD dwRet = pWnd->OnMouseMessage(dwMessage, x,y);
|
|
|
|
// 마우스 포인트가 컨트롤 안에 있고 메시지를 받는녀석의 Return 값을 사용하자.
|
|
if( (dwRet & KMR_CHILD_IN_MSG) && FALSE == (KMR_NO_GET & dwRet ) )
|
|
{
|
|
// 포커스 패널가능성이 존재 ( 메시지를 받으므로 )
|
|
if(false == bFindGetChild)
|
|
{
|
|
// 맨위에 있는 하나의 Control만 Return값을 체크한다.
|
|
dwChildRetMsg = dwRet;
|
|
dwAddMsg = KMR_CHILD_IN_MSG | KMR_CHILD_GET_MSG;
|
|
pMouseWnd = pWnd;
|
|
bFindGetChild = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
switch( dwMessage)
|
|
{
|
|
case KLBUTTON_DOWN:
|
|
{
|
|
m_ptMouseDown = KPoint(x,y);
|
|
m_pMouseDownWnd = pMouseWnd;
|
|
|
|
if(!pMouseWnd)
|
|
break;
|
|
|
|
if( !pMouseWnd->HasFocus() )
|
|
{
|
|
|
|
KUIWnd* pFocusWnd = GetFocusChild();
|
|
if( NULL != pFocusWnd ) pFocusWnd->SetFocus( false );
|
|
|
|
pMouseWnd->SetFocus( true );
|
|
}
|
|
}
|
|
break;
|
|
case KLBUTTON_UP:
|
|
m_pMouseDownWnd = NULL;
|
|
break;
|
|
case KMOUSE_MOVE:
|
|
{
|
|
if( m_pManager && m_pManager->GetDragObject() == NULL && m_pMouseDownWnd)
|
|
{
|
|
// 특정 픽셀이상 움직이지 않으면 드래그 안됨 (가로 , 세로 각각 3픽셀)
|
|
int nSum = (x - m_ptMouseDown.x) * (x - m_ptMouseDown.x) + (y - m_ptMouseDown.y) * (y - m_ptMouseDown.y);
|
|
|
|
if( nSum < 18)
|
|
break;
|
|
|
|
if(m_pMouseDownWnd->GetFlag() & KFLAG_CAN_DRAG && !m_pMouseDownWnd->IsDestroy()) // <= m_pMouseDownWnd 이미 삭제 되었는데, 들어오고 있다. 고쳐 주세요.
|
|
{
|
|
// 물체의 가운데로 셋팅
|
|
KPoint ptOffset( m_pMouseDownWnd->GetRect().GetWidth() * .5f, m_pMouseDownWnd->GetRect().GetHeight() * .5f);
|
|
m_pManager->SetDragObject( m_pMouseDownWnd->GetDragObject(), ptOffset );
|
|
}
|
|
else
|
|
m_pMouseDownWnd = NULL;
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
|
|
// 에디트 컨트롤은 예외적으로 메시지를 Pass안함.
|
|
//if( pMouseWnd && pMouseWnd->m_sClassName == "edit" )
|
|
// return KMR_NORMAL;
|
|
|
|
if( IsInRect(x, y ) )
|
|
dwAddMsg |= KMR_CHILD_IN_MSG;
|
|
|
|
// 윈도우 자체가 Message를 그냥 받고 Pass 하며, 마우스 포인트를 받은 차일드 또한 메시지를 받지 않았다면 Pass 를 넘기자.
|
|
if( (m_dwFlag & KFLAG_GET_PASS_MESSAGE) && FALSE == (KMR_NORMAL & dwChildRetMsg) )
|
|
{
|
|
/* 잘못된 수정인듯. 주석처리함. by Testors
|
|
// 마우스 휠의 경우는 정상 처리가 되어야 한다.
|
|
&& dwMessage != KWHEEL_UP && dwMessage != KWHEEL_DOWN
|
|
*/
|
|
return KMR_GET_PASS | dwAddMsg;
|
|
}
|
|
|
|
return KMR_NORMAL | dwAddMsg;
|
|
}
|
|
|
|
DWORD KUIWnd::OnKeyMessage(DWORD dwMessage, DWORD dwKeyCode)
|
|
{
|
|
if(m_dwFlag & KFLAG_NO_GET_MESSAGE)
|
|
return KMR_NO_GET;
|
|
|
|
if ( !m_bShowFlag )
|
|
return KMR_NO_GET;
|
|
|
|
KUIWnd* pFocusWnd = GetFocusChild();
|
|
|
|
//이부분에 에디트 컨트롤인지 확인하고 에디트 컨트롤이면 키 메세지 무시해야하는지 확인해 볼것
|
|
if( NULL != pFocusWnd )
|
|
pFocusWnd->OnKeyMessage( dwMessage, dwKeyCode );
|
|
|
|
return KMR_NORMAL;
|
|
}
|
|
|
|
void KUIWnd::SetRect(const KRect& rcRect)
|
|
{
|
|
// Region
|
|
m_rcRegion.left = rcRect.left ;
|
|
m_rcRegion.top = rcRect.top ;
|
|
m_rcRegion.right = rcRect.right ;
|
|
m_rcRegion.bottom = rcRect.bottom;
|
|
}
|
|
|
|
void KUIWnd::SetCorrectionRect(const KRect& rcRect, bool bWithChild /*= true*/ )
|
|
{
|
|
m_rcCorrectionRect = rcRect;
|
|
|
|
if( bWithChild )
|
|
{
|
|
for ( std::list< KUIWnd* >::reverse_iterator it = m_listChild.rbegin(); it != m_listChild.rend() ; ++it )
|
|
{
|
|
KUIWnd *pWnd = (*it);
|
|
pWnd->SetCorrectionRect( rcRect );
|
|
}
|
|
}
|
|
}
|
|
|
|
bool KUIWnd::IsInRect(int x, int y)
|
|
{
|
|
KRect rcNewRegion = m_rcRegion + m_rcCorrectionRect;
|
|
|
|
if(rcNewRegion.IsInRect( x, y ) && m_bShowFlag)
|
|
{
|
|
KRect rcNewClip = m_rcClipArea + m_rcCorrectionRect;
|
|
if(rcNewClip.IsInRect( x ,y ) )
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool KUIWnd::IsInRectWithChild(int x, int y)
|
|
{
|
|
if(!m_bShowFlag)
|
|
return false;
|
|
|
|
for ( std::list< KUIWnd* >::reverse_iterator it = m_listChild.rbegin(); it != m_listChild.rend() ; ++it )
|
|
{
|
|
KUIWnd *pWnd = (*it);
|
|
|
|
if( pWnd && pWnd->IsInRect(x, y ))
|
|
return true;
|
|
|
|
if( pWnd && pWnd->IsInRectWithChild(x, y ))
|
|
return true;
|
|
}
|
|
|
|
// by Testors
|
|
if( !(m_dwFlag & KFLAG_GET_PASS_MESSAGE) && IsInRect(x, y ) ) return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
void KUIWnd::MovePos( int x, int y )
|
|
{
|
|
int offsetx = x - m_rcRegion.left;
|
|
int offsety = y - m_rcRegion.top;
|
|
MovePosOffset( offsetx, offsety);
|
|
}
|
|
|
|
void KUIWnd::MovePosOffset(int offsetx, int offsety)
|
|
{
|
|
// Region
|
|
m_rcRegion.left += offsetx; m_rcRegion.top += offsety;
|
|
m_rcRegion.right += offsetx; m_rcRegion.bottom += offsety;
|
|
|
|
// Caption Rect
|
|
m_rcCaptionArea.left += offsetx; m_rcCaptionArea.top += offsety;
|
|
m_rcCaptionArea.right += offsetx; m_rcCaptionArea.bottom += offsety;
|
|
|
|
OnPosChangeNofity(offsetx,offsety);
|
|
}
|
|
|
|
void KUIWnd::SetSortValue( int nV )
|
|
{
|
|
int nOldValue = m_nSortValue;
|
|
m_nSortValue = nV;
|
|
|
|
m_pManager->onChangeSortValue( this, nOldValue );
|
|
}
|
|
|
|
const KRect &KUIWnd::Resize( const KRect &rcNewRect )
|
|
{
|
|
OnSizeChangeNofity(rcNewRect);
|
|
return m_rcRegion;
|
|
}
|
|
|
|
const KRect& KUIWnd::ClipRect( const KRect &newrect )
|
|
{
|
|
OnClipChangeNotify( newrect );
|
|
return m_rcClipArea;
|
|
}
|
|
|
|
void KUIWnd::SetShowChildAll( bool bShow )
|
|
{
|
|
for (std::list< KUIWnd* >::iterator it = m_listChild.begin(); it != m_listChild.end() ; ++it )
|
|
{
|
|
(*it)->SetShow( bShow );
|
|
}
|
|
}
|
|
|
|
void KUIWnd::ChangeAlpha(float fAlpha)
|
|
{
|
|
OnAlphaChangeNotify( fAlpha );
|
|
}
|
|
|
|
void KUIWnd::SetShow( bool showFlag )
|
|
{
|
|
#ifdef _KUI_INVALIDATION
|
|
// { [sonador]
|
|
if( m_bShowFlag != showFlag )
|
|
{
|
|
InvalidateWnd();
|
|
OnShowNotify( showFlag );
|
|
m_bShowFlag = showFlag;
|
|
}
|
|
// }
|
|
#else
|
|
m_bShowFlag = showFlag;
|
|
#endif
|
|
}
|
|
|
|
void KUIWnd::SetFocus( bool bFocus )
|
|
{
|
|
if ( m_bHasFocus != bFocus )
|
|
{
|
|
// _oprint( "void KUIWnd::SetFocus( %s ) : %s/%s\n", bFocus ? "true" : "false", GetClassName().c_str(), GetID() );
|
|
|
|
m_bHasFocus = bFocus;
|
|
if ( m_listChild.size() > 0 )
|
|
{
|
|
KUIWnd* pFocusWnd = GetFocusChild();
|
|
if( m_bHasFocus )
|
|
{
|
|
//EnterChatMode가 아닐 경우에만
|
|
if( !IsEnterChatMode() )
|
|
{
|
|
// 차일드 중에 아무도 포커스를 갖고 있지 않다면
|
|
if( NULL == pFocusWnd )
|
|
{
|
|
// tab stop플래그가 없으므로 무조건 첫번째 edit컨트롤에 포커스를 주도록 한다.
|
|
for( std::list<KUIWnd*>::iterator it = m_listChild.begin(); it != m_listChild.end(); it++ )
|
|
{
|
|
if( (*it)->m_sClassName == "edit" && (*it)->IsShow() )
|
|
{ (*it)->SetFocus( true ); break; }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 차일드 중 포커스를 가진 것이 있다면 없앤다.
|
|
if( NULL != pFocusWnd )
|
|
pFocusWnd->SetFocus( false );
|
|
}
|
|
}
|
|
OnFocusNotify();
|
|
}
|
|
}
|
|
|
|
bool KUIWnd::BuildPrimitive( KSpritePrimitive *pr, const char *ani_name, int nFrame, const K3DVertex &pos, float visibility )
|
|
{
|
|
|
|
KResSprite *sprres = KSpriteManager::GetManager()->GetResSprite(m_sSprName.c_str(), ani_name, nFrame);
|
|
|
|
if ( sprres )
|
|
{
|
|
pr->SetRes( sprres );
|
|
pr->SetVisibility( visibility * sprres->GetVisibility() );
|
|
float l,r,t,b;
|
|
sprres->GetSourceUVRect( l, t, r, b );
|
|
pr->SetSourceUVRect( l, t, r, b );
|
|
|
|
K3DMatrix mat = sprres->GetTransform();
|
|
K3DVertex p = pos;
|
|
p += sprres->GetOffset();
|
|
pr->SetTransform( mat );
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool KUIWnd::BuildPrimitive( KSpritePrimitive *pr, const char *ani_name, int nFrame, const K3DVertex &pos, float visibility, const KSize &target_size, bool tiling )
|
|
{
|
|
if( NULL == pr )
|
|
return false;
|
|
|
|
KResSprite *sprres = KSpriteManager::GetManager()->GetResSprite(m_sSprName.c_str(), ani_name, nFrame);
|
|
if ( sprres )
|
|
{
|
|
pr->SetRes( sprres );
|
|
KSize tsize;
|
|
tsize.width = (target_size.width <=0) ? sprres->GetSizeX() : target_size.width;
|
|
tsize.height = (target_size.height <=0) ? sprres->GetSizeY() : target_size.height;
|
|
pr->SetTargetSize( (float)tsize.width, (float)tsize.height );
|
|
pr->SetVisibility( visibility * sprres->GetVisibility() );
|
|
K3DMatrix mat = sprres->GetTransform();
|
|
K3DVertex p = pos;
|
|
p += sprres->GetOffset();
|
|
mat.SetPosVector( p );
|
|
pr->SetTransform( mat );
|
|
|
|
float l,r,t,b;
|
|
sprres->GetSourceUVRect( l, t, r, b );
|
|
if ( tiling )
|
|
{
|
|
float u,v;
|
|
u = target_size.width / sprres->GetSizeX();
|
|
if ( u > 1.0f ) r = u;
|
|
v = target_size.height / sprres->GetSizeY();
|
|
if ( v > 1.0f ) b = v;
|
|
}
|
|
pr->SetSourceUVRect( l, t, r, b );
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void KUIWnd::SetParent( KUIWnd *pParent )
|
|
{
|
|
m_pParent = pParent;
|
|
}
|
|
|
|
void KUIWnd::AddChild( KUIWnd *wnd )
|
|
{
|
|
#ifdef _DEV
|
|
/// 2011.11.24 - prodongi
|
|
if (KUIValidChecker::getIsProcessingMsg())
|
|
{
|
|
_oprint("\n***************************************************\n");
|
|
_oprint("current is processing message!!!!!!(%s)\n", m_sID.c_str());
|
|
_oprint("***************************************************\n\n");
|
|
|
|
//char str[MAX_PATH];
|
|
//sprintf(str, "current is processing message!!!!!!(%s)", m_sID.c_str());
|
|
//MessageBox(HWND_DESKTOP, str, "warning", MB_OK);
|
|
}
|
|
#endif
|
|
|
|
m_listChild.push_back( wnd );
|
|
wnd->MarkOriginalOffset();
|
|
#ifdef _KUI_INVALIDATION
|
|
// { [sonador]
|
|
wnd->SetParent( this );
|
|
// }
|
|
#endif
|
|
}
|
|
|
|
bool KUIWnd::RemoveChild( KUIWnd *wnd )
|
|
{
|
|
#ifdef _DEV
|
|
/// 2011.11.24 - prodongi
|
|
if (KUIValidChecker::getIsProcessingMsg())
|
|
{
|
|
_oprint("\n***************************************************\n");
|
|
_oprint("current is processing message!!!!!!(%s)\n", m_sID.c_str());
|
|
_oprint("***************************************************\n\n");
|
|
|
|
//char str[MAX_PATH];
|
|
//sprintf(str, "current is processing message!!!!!!(%s)", m_sID.c_str());
|
|
//MessageBox(HWND_DESKTOP, str, "warning", MB_OK);
|
|
}
|
|
#endif
|
|
|
|
std::list< KUIWnd* >::iterator it = std::find( m_listChild.begin(), m_listChild.end(), wnd );
|
|
if ( it != m_listChild.end() )
|
|
{
|
|
SAFE_DELETE( *it );
|
|
m_listChild.erase( it );
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void KUIWnd::MoveToOriginalPosition()
|
|
{
|
|
if( !GetParent() ) return;
|
|
if( GetAnchor() ) return;
|
|
KRect newRect = GetParent()->GetRect();
|
|
newRect.right = newRect.left;
|
|
newRect.bottom = newRect.top;
|
|
Resize( m_rcOriginalOffset + newRect );
|
|
//MovePos( newRect.left, newRect.top );
|
|
}
|
|
|
|
void KUIWnd::MarkOriginalOffset()
|
|
{
|
|
if( !GetParent() ) return;
|
|
|
|
KRect offset = GetParent()->GetRect();
|
|
offset.bottom = offset.top;
|
|
offset.right = offset.left;
|
|
m_rcOriginalOffset = GetRect() - offset;
|
|
}
|
|
|
|
KUIWnd* KUIWnd::GetChild( const char *_id ) const
|
|
{
|
|
std::list< KUIWnd* >::const_iterator it = m_listChild.begin();
|
|
for ( ; it != m_listChild.end(); ++it )
|
|
{
|
|
KUIWnd* pWnd = (*it);
|
|
if ( _stricmp( _id, pWnd->GetID() ) == 0 )
|
|
// if ( _stricmp( _id, (*it)->GetID() ) == 0 )
|
|
return (*it);
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
KUIWnd* KUIWnd::GetFocusChild() const
|
|
{
|
|
for( std::list<KUIWnd*>::const_iterator it = m_listChild.begin(); it != m_listChild.end(); it++ )
|
|
if( (*it)->HasFocus() ) return (*it);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void KUIWnd::SetBack(LPCSTR lpszSprName, LPCSTR lpszAniName, int nIndex)
|
|
{
|
|
if(lpszSprName == NULL)
|
|
m_sSprName = "";
|
|
else if(strlen(lpszSprName) != 0)
|
|
m_sSprName = lpszSprName;
|
|
|
|
if(lpszAniName == NULL)
|
|
m_sAniName = "";
|
|
else if(strlen(lpszAniName) != 0)
|
|
m_sAniName = lpszAniName;
|
|
|
|
m_nFrameIndex = nIndex;
|
|
OnChagneBackNotify();
|
|
}
|
|
|
|
|
|
void KUIWnd::SetFrameIndex(int nIndex)
|
|
{
|
|
SetBack(m_sSprName.c_str(), m_sAniName.c_str(), nIndex);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Name :
|
|
// Desc : Texture Animation. dwSpeed는 1초에 보여질 프레임수.
|
|
// bUnShowByEndFrame는 true일 경우 끝 프레임 지나면 show(false)해버린다.
|
|
//////////////////////////////////////////////////////////////////////////
|
|
int KUIWnd::SetFrameTextureAnim(DWORD dwElapsedTime, DWORD dwMaxFrame, DWORD dwSpeed, bool bLoop, bool bUnShowByEndFrame)
|
|
{
|
|
if ( dwMaxFrame <= 1 )
|
|
return 0;
|
|
|
|
DWORD dwFrame = ( dwSpeed * dwElapsedTime ) / 1000;
|
|
int nOver = dwFrame / dwMaxFrame;
|
|
int nIdex = dwFrame % dwMaxFrame;
|
|
|
|
if ( !bLoop && nOver )
|
|
{
|
|
if ( bUnShowByEndFrame )
|
|
{
|
|
SetFrameIndex(0);
|
|
SetShow(false);
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
SetFrameIndex(dwMaxFrame-1);
|
|
return dwMaxFrame-1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SetFrameIndex(nIdex);
|
|
return nIdex;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
SPRITE_SET* KUIWnd::_getSpriteSet()
|
|
{
|
|
return KSpriteManager::GetManager()->GetSpriteSet(m_sSprName.c_str());
|
|
}
|
|
|
|
#ifdef _KUI_INVALIDATION
|
|
// { [sonador]
|
|
K3DRenderTarget* KUIWnd::_getRenderTarget()
|
|
{
|
|
if( KUICachedTextureManager::SupportNonPow2() )
|
|
{
|
|
return KUICachedTextureManager::GetManager()->GetRenderTarget(
|
|
m_rcRegion.GetWidth(), m_rcRegion.GetHeight(), 1, K3DRenderTarget::DEPTH_DISABLE );
|
|
}
|
|
return 0;
|
|
}
|
|
// }
|
|
#endif
|
|
|
|
void KUIWnd::_ClearChildList()
|
|
{
|
|
for(std::list<KUIWnd*>::iterator it = m_listChild.begin(); it != m_listChild.end(); ++it)
|
|
SAFE_DELETE( *it );
|
|
|
|
m_listChild.clear();
|
|
}
|
|
|
|
void KUIWnd::ClearChild( const char* szName )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
std::list<KUIWnd*>::iterator it = std::find( m_listChild.begin(), m_listChild.end(), pWnd );
|
|
if( it != m_listChild.end() )
|
|
{
|
|
SAFE_DELETE( pWnd );
|
|
m_listChild.erase( it );
|
|
}
|
|
}
|
|
|
|
// MJ 2004/12/01 // alpha
|
|
void KUIWnd::SetAlphaOpen( DWORD dwTime )
|
|
{
|
|
for(std::list<KUIWnd*>::iterator it = m_listChild.begin(); it != m_listChild.end(); ++it)
|
|
{
|
|
(*it)->m_dwAlphaTime = dwTime;
|
|
(*it)->m_bShowAlpha = true;
|
|
}
|
|
}
|
|
void KUIWnd::SetAlphaClose( DWORD dwTime )
|
|
{
|
|
for(std::list<KUIWnd*>::iterator it = m_listChild.begin(); it != m_listChild.end(); ++it)
|
|
{
|
|
(*it)->m_dwAlphaTime = dwTime;
|
|
(*it)->m_bCloseAlpha = true;
|
|
}
|
|
|
|
m_dwAlphaTime = dwTime;
|
|
m_bCloseAlpha = true;
|
|
}
|
|
|
|
void KUIWnd::SetChildAsTop( const char* szName )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
|
|
std::list<KUIWnd*>::iterator it = std::find( m_listChild.begin(), m_listChild.end(), pWnd );
|
|
if( it != m_listChild.end() )
|
|
{
|
|
m_listChild.erase( it );
|
|
m_listChild.push_back( pWnd );
|
|
}
|
|
}
|
|
|
|
void KUIWnd::SetChildAsButtom( const char* szName )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
std::list<KUIWnd*>::iterator it = std::find( m_listChild.begin(), m_listChild.end(), pWnd );
|
|
if( it != m_listChild.end() )
|
|
{
|
|
m_listChild.erase( it );
|
|
|
|
std::list<KUIWnd*>::iterator it_begine = m_listChild.begin();
|
|
m_listChild.insert(it_begine, pWnd);
|
|
}
|
|
}
|
|
|
|
void KUIWnd::OnToolTipWnd( KUIWnd* pOnToolTipWnd )
|
|
{
|
|
if( m_pParent )
|
|
m_pParent->OnToolTipWnd( pOnToolTipWnd );
|
|
else
|
|
m_pOnToolTipWnd = pOnToolTipWnd;
|
|
}
|
|
|
|
void KUIWnd::OffToolTipWnd()
|
|
{
|
|
if( m_pOnToolTipWnd )
|
|
{
|
|
m_pOnToolTipWnd->SetTooltipOff();
|
|
m_pOnToolTipWnd = NULL;
|
|
//RefCnt == 1이면
|
|
// KUITipControl::SetToolTipOnOff( false );
|
|
}
|
|
}
|
|
|
|
void KUIWnd::SetChildToggleShow( const char* szName )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
if( pWnd ) pWnd->SetToggleShow();
|
|
}
|
|
|
|
void KUIWnd::SetChildAniName( const char* szName, const char* szValue )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
if( pWnd ) pWnd->SetAniName( szValue );
|
|
}
|
|
|
|
void KUIWnd::SetChildTooltip(const char *szName, char const* tooltip)
|
|
{
|
|
SetChildTooltip(GetChild(szName), tooltip);
|
|
}
|
|
|
|
void KUIWnd::SetChildTooltip(KUIWnd* child, char const* tooltip)
|
|
{
|
|
KUIControl* control = dynamic_cast<KUIControl*>(child);
|
|
if (!control)
|
|
{
|
|
assert(!control && "failed set child tooltip");
|
|
return ;
|
|
}
|
|
|
|
control->SetTooltip(tooltip);
|
|
}
|
|
|
|
KUIWnd::CaptionHandler* KUIWnd::m_pCaptionHandler;
|
|
|
|
// MJ 2004/12/02
|
|
void KUIWnd::SetChildCaption( const char* szName, const char* szValue )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
if( pWnd ) pWnd->SetCaption( szValue );
|
|
}
|
|
|
|
void KUIWnd::SetChildCaptionFormat(KUIWnd* child, char const* fmt, ...)
|
|
{
|
|
if (!child)
|
|
{
|
|
assert(!child && "child is null");
|
|
return ;
|
|
}
|
|
|
|
static char data[2048];
|
|
va_list args;
|
|
va_start(args, fmt);
|
|
_vsnprintf(data, 2048, fmt, args);
|
|
va_end(args);
|
|
|
|
child->SetCaption(data);
|
|
}
|
|
|
|
void KUIWnd::SetChildNumber( const char* szName, int nValue )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
if( pWnd ) static_cast< KUIControlNumber* >( pWnd )->SetNumber( (DWORD)nValue );
|
|
}
|
|
|
|
void KUIWnd::SetChildShow( const char* szName, bool bShow )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
if( pWnd ) pWnd->SetShow( bShow );
|
|
}
|
|
|
|
void KUIWnd::SetChildRect( const char* szName, KRect rc )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
if( pWnd ) pWnd->SetRect( rc );
|
|
}
|
|
|
|
void KUIWnd::SetChildClipRect( const char* szName, KRect rc )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
if( pWnd ) pWnd->ClipRect( rc );
|
|
}
|
|
|
|
void KUIWnd::SetChildresize( const char* szName, KRect rc )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
if( pWnd ) pWnd->Resize( rc );
|
|
}
|
|
|
|
void KUIWnd::SetMovePos( const char* szName, int nX, int nY )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
if( pWnd ) pWnd->MovePos( nX, nY );
|
|
}
|
|
|
|
void KUIWnd::SetMovePosOffset( const char* szName, int offsetx, int offsety )
|
|
{
|
|
KUIWnd* pWnd = GetChild( szName );
|
|
if( pWnd ) pWnd->MovePosOffset(offsetx, offsety);
|
|
}
|
|
|
|
KUIWnd* KUIWnd::CopyControl( const char* szName, const char* szNewName, RECT rc )
|
|
{
|
|
std::list< KUIWnd* >::iterator it = m_listChild.begin();
|
|
while( it != m_listChild.end() )
|
|
{
|
|
KUIWnd* pWnd = (*it);
|
|
if( pWnd && ::_stricmp( szName, pWnd->GetID() ) == 0 )
|
|
{
|
|
KRect rect = pWnd->GetRect();
|
|
rect.left += rc.left; rect.top += rc.top; rect.right += rc.right; rect.bottom += rc.bottom;
|
|
return m_pManager->CreateControl( KUIWND_CREATE_ARG( pWnd->m_sClassName.c_str(),
|
|
szNewName,
|
|
pWnd->GetCaption(),
|
|
rect,
|
|
pWnd->GetStyle(),
|
|
pWnd->GetFlag(),
|
|
this,
|
|
pWnd->GetAniName(),
|
|
pWnd->GetSprName(),
|
|
m_pManager,
|
|
pWnd->GetFrameIndex(),
|
|
"",
|
|
pWnd->GetAnchor() ) );
|
|
}
|
|
it++;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void KUIWnd::CopyControl( const char* szName, const char* szNewName, KRect rt )
|
|
{
|
|
RECT rc;
|
|
rc.left = rt.left;
|
|
rc.top = rt.top;
|
|
rc.right = rt.right;
|
|
rc.bottom = rt.bottom;
|
|
CopyControl( szName, szNewName, rc );
|
|
}
|
|
|
|
void KUIWnd::SetValidRect( const char* szName, KRect& rt )
|
|
{
|
|
std::list< KUIWnd* >::iterator it = m_listChild.begin();
|
|
while( it != m_listChild.end() )
|
|
{
|
|
KUIWnd* pWnd = (*it);
|
|
if( pWnd && ::_stricmp( szName, pWnd->GetID() ) == 0 )
|
|
{
|
|
pWnd->SetCorrectionRect( rt );
|
|
return;
|
|
}
|
|
it++;
|
|
}
|
|
}
|
|
void KUIWnd::SetChildAlpha( const char* szName, float fAlpha )
|
|
{
|
|
std::list< KUIWnd* >::iterator it = m_listChild.begin();
|
|
while( it != m_listChild.end() )
|
|
{
|
|
KUIWnd* pWnd = (*it);
|
|
if( pWnd && ::_stricmp( szName, pWnd->GetID() ) == 0 )
|
|
{
|
|
pWnd->ChangeAlpha( fAlpha );
|
|
return;
|
|
}
|
|
it++;
|
|
}
|
|
}
|
|
void KUIWnd::RemoveControl( const char* szName )
|
|
{
|
|
std::list< KUIWnd* >::iterator it = m_listChild.begin();
|
|
while( it != m_listChild.end() )
|
|
{
|
|
if( (*it) && ::_stricmp( szName, (*it)->GetID() ) == 0 )
|
|
{
|
|
delete (*it);
|
|
m_listChild.erase( it );
|
|
return;
|
|
}
|
|
it++;
|
|
}
|
|
}
|
|
|
|
void KUIWnd::SetTooltipOff()
|
|
{
|
|
// 뒤에서 부터 검사 (맨 위에 있는것 부터)
|
|
for ( std::list< KUIWnd* >::reverse_iterator it = m_listChild.rbegin(); it != m_listChild.rend() ; ++it )
|
|
{
|
|
KUIWnd *pWnd = (*it);
|
|
pWnd->SetTooltipOff();
|
|
}
|
|
}
|
|
void KUIWnd::InitFocusWnd()
|
|
{
|
|
m_pMouseDownWnd = NULL;
|
|
}
|
|
KUIWnd& KUIWnd::operator =( const KUIWnd & wnd )
|
|
{
|
|
m_dwFlag = wnd.m_dwFlag;
|
|
m_dwStyle = wnd.m_dwStyle;
|
|
m_dwAnchor = wnd.m_dwAnchor;
|
|
|
|
m_sClassName = wnd.m_sClassName;
|
|
m_sID = wnd.m_sID;
|
|
m_rcRegion = wnd.m_rcRegion;
|
|
m_rcCaptionArea = wnd.m_rcCaptionArea;
|
|
|
|
if( false == wnd.m_sSprName.empty() )
|
|
m_sSprName = wnd.m_sSprName;
|
|
|
|
if( false == wnd.m_sAniName.empty() )
|
|
m_sAniName = wnd.m_sAniName;
|
|
|
|
m_nFrameIndex = wnd.m_nFrameIndex;
|
|
m_pManager = wnd.m_pManager;
|
|
m_pParent = wnd.m_pParent;
|
|
m_sCaption = wnd.m_sCaption;
|
|
m_sTip = wnd.m_sTip;
|
|
|
|
return *this;
|
|
}
|
|
|
|
void KUIWnd::checkMouseFocusOn(KUIWnd* wnd, bool isInRect)
|
|
{
|
|
bool oldMouseFocusOn = wnd->m_isMouseFocusOn;
|
|
if(isInRect)
|
|
{
|
|
if (!oldMouseFocusOn)
|
|
{
|
|
wnd->m_isMouseFocusOn = true;
|
|
OnMouseFocusOnNotify(wnd, true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (oldMouseFocusOn)
|
|
{
|
|
wnd->m_isMouseFocusOn = false;
|
|
OnMouseFocusOnNotify(wnd, false);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// 2011.01.18 - prodongi
|
|
void KUIWnd::setCaptionScroll(bool scroll, bool updateCaption, DWORD type, float v, float margin)
|
|
{
|
|
m_pCaptionPhrase->setSpriteScroll(scroll, type, v, margin);
|
|
if (updateCaption)
|
|
SetCaption(m_sCaption.c_str(), true, true);
|
|
}
|
|
|
|
/// 2011.02.23 forceUpdate 추가 - prodongi
|
|
//void KUIWnd::SetCaption( const char *caption, bool bUseCaptionHandler )
|
|
void KUIWnd::SetCaption( const char *caption, bool bUseCaptionHandler, bool forceUpdate )
|
|
{
|
|
std::string strCaption( caption );
|
|
|
|
#ifdef _COUNTRY_ME_
|
|
|
|
// 2010.08.24 중동도 공백은 출력되야 된다고 합니다. - prodongi
|
|
// 중동의 경우 공백제거.
|
|
//XStringUtil::Replace( strCaption, " ", "" );
|
|
|
|
#endif
|
|
|
|
if( ( m_sOrgCaption == "" && strCaption == "" ) || // !::_stricmp( caption, "" )
|
|
m_sOrgCaption != strCaption || //) // 추가. bintitle. 2010.06.03.
|
|
forceUpdate) /// 2011.02.23 - prodongi
|
|
{
|
|
m_sOrgCaption = strCaption; // Tooltip 에 찍을 원본.
|
|
m_sCaption = strCaption;
|
|
if( m_pCaptionHandler ) m_pCaptionHandler->onSetCaption( m_sCaption );
|
|
OnChangeCaptionNotify();
|
|
}
|
|
|
|
|
|
//if( ( m_sOrgCaption == "" && !::_stricmp( caption, "" ) ) ||
|
|
// m_sOrgCaption != caption ) // 추가. bintitle. 2010.06.03.
|
|
//{
|
|
// m_sOrgCaption = caption; // Tooltip 에 찍을 원본.
|
|
// m_sCaption = caption;
|
|
// if( m_pCaptionHandler ) m_pCaptionHandler->onSetCaption( m_sCaption );
|
|
// OnChangeCaptionNotify();
|
|
//}
|
|
}
|
|
|
|
/// 2011.02.16 - prodongi
|
|
void KUIWnd::setBoundingControl()
|
|
{
|
|
m_boundingControl = GetChild(BOUNDING_CONTROL_NAME);
|
|
}
|
|
|
|
/// 2011.02.16 - prodongi
|
|
const KRect& KUIWnd::GetBoundingRect() const
|
|
{
|
|
return m_boundingControl ? m_boundingControl->GetRect() : GetRect();
|
|
}
|
|
|