1170 lines
27 KiB
C++
1170 lines
27 KiB
C++
#include "stdafx.h"
|
|
#ifndef _COUNTRY_ME_
|
|
|
|
#include "KViewport.h"
|
|
#include "KUIControlButton.h"
|
|
#include "KUIWndManager.h"
|
|
|
|
#include "KResourceManager.h"
|
|
|
|
#include <algorithm>
|
|
|
|
using namespace KUI_MESSAGE;
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// KUIControlSimpleButton Implement
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
namespace
|
|
{
|
|
KUIWnd* SimpleButtonCreator()
|
|
{
|
|
return new KUIControlSimpleButton;
|
|
}
|
|
bool bSimpleButtonRegister = KUIFactory::GetInstance()->RegisterCreator( SimpleButtonCreator, "simplebutton");
|
|
}
|
|
|
|
KUIControlSimpleButton::KUIControlSimpleButton()
|
|
:m_dwButtonState(KBUTTON_NORMAL)
|
|
,m_dwDisableButtonState(KBUTTON_DISABLE)
|
|
{
|
|
SetButtonState( KBUTTON_NORMAL );
|
|
|
|
m_bLeftButton = false;
|
|
|
|
for(int i = 0; i < KBUTTON_MAX; ++i)
|
|
{
|
|
_registerSprite( &m_ButtonSprite[i] );
|
|
}
|
|
}
|
|
|
|
KUIControlSimpleButton::~KUIControlSimpleButton()
|
|
{
|
|
}
|
|
|
|
DWORD KUIControlSimpleButton::OnMouseMessage(DWORD dwMessage, int x, int y)
|
|
{
|
|
DWORD dwRet = KUIControl::OnMouseMessage(dwMessage,x,y);
|
|
|
|
if(KMR_NO_GET & dwRet)
|
|
return dwRet;
|
|
|
|
if( IsDisable() ) return dwRet;
|
|
|
|
if(IsInRect(x,y) )
|
|
{
|
|
switch(dwMessage)
|
|
{
|
|
case KMOUSE_MOVE:
|
|
if(m_dwButtonState != KBUTTON_DOWN)
|
|
{
|
|
if ( m_bLeftButton )
|
|
SetButtonState( KBUTTON_DOWN );
|
|
else SetButtonState( KBUTTON_ACTIVATE );
|
|
}
|
|
break;
|
|
case KLBUTTON_DOWN:
|
|
m_bLeftButton = true;
|
|
PumpUpMessage(GetID(), KBUTTON_PRESSING, 0,0);
|
|
SetButtonState( KBUTTON_DOWN );
|
|
break;
|
|
case KLBUTTON_UP:
|
|
m_bLeftButton = false;
|
|
if(m_dwButtonState == KBUTTON_DOWN )
|
|
PumpUpMessage(GetID(), KBUTTON_CLICK, 0,0);
|
|
|
|
SetButtonState( KBUTTON_ACTIVATE );
|
|
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if ( dwMessage == KLBUTTON_UP )
|
|
{
|
|
m_bLeftButton = false;
|
|
m_pManager->ReleaseCapture( this );
|
|
}
|
|
// 마우스 범위를 벗어나면 Normal로 돌린다.
|
|
if(m_dwButtonState == KBUTTON_ACTIVATE || m_dwButtonState == KBUTTON_DOWN)
|
|
SetButtonState( KBUTTON_NORMAL );
|
|
}
|
|
|
|
return dwRet;
|
|
}
|
|
DWORD KUIControlSimpleButton::OnKeyMessage(DWORD dwMessage, DWORD dwKeyCode)
|
|
{
|
|
return KUIControl::OnKeyMessage(dwMessage, dwKeyCode);
|
|
}
|
|
|
|
void KUIControlSimpleButton::Render(KViewportObject * pViewport, bool isFront)
|
|
{
|
|
if ( m_bShowFlag )
|
|
{
|
|
// { 땜빵
|
|
int nSprite = m_dwButtonState;
|
|
if( IsDisable() )
|
|
nSprite = m_dwDisableButtonState; //2012. 5. 30 - marine
|
|
// }
|
|
|
|
pViewport->Register(&m_ButtonSprite[nSprite], isFront );
|
|
// Caption Render
|
|
_renderCaption(pViewport, isFront);
|
|
|
|
// ToolTip Render
|
|
#ifndef _KUI_INVALIDATION
|
|
_renderToolTip(pViewport, isFront);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
void KUIControlSimpleButton::Create(KUIWND_CREATE_ARG& CREATE_ARG)
|
|
{
|
|
KUIControl::Create(CREATE_ARG);
|
|
}
|
|
|
|
int KUIControlSimpleButton::GetButtonWidth()
|
|
{
|
|
KResSprite* pResSprite = _getSpriteSet()->GetSpriteRes(m_sAniName.c_str(),0);
|
|
|
|
if(!pResSprite)
|
|
return 0;
|
|
|
|
return pResSprite->GetSizeX();
|
|
}
|
|
|
|
void KUIControlSimpleButton::DisableAndButtonState(DWORD dwState)
|
|
{
|
|
KUIControl::Disable();
|
|
m_dwDisableButtonState = dwState;
|
|
}
|
|
|
|
void KUIControlSimpleButton::Enable()
|
|
{
|
|
KUIControl::Enable();
|
|
m_dwDisableButtonState = KBUTTON_DISABLE;
|
|
}
|
|
|
|
|
|
void KUIControlSimpleButton::_destroyControl()
|
|
{
|
|
KUIControl::_destroyControl();
|
|
|
|
for( int i = 0; i < KBUTTON_MAX; ++i )
|
|
{
|
|
m_ButtonSprite[i].SetRes( NULL );
|
|
}
|
|
}
|
|
|
|
void KUIControlSimpleButton::_initControl()
|
|
{
|
|
if( m_sAniName.empty() )
|
|
return;
|
|
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes(m_sAniName.c_str(),0);
|
|
|
|
if( !pFrame )
|
|
{
|
|
assert( false && "Cannot find Sprite Res Frame" );
|
|
return;
|
|
}
|
|
|
|
m_rcRegion.right = m_rcRegion.left + pFrame->GetSizeX();
|
|
m_rcRegion.bottom = m_rcRegion.top + pFrame->GetSizeY();
|
|
for( int i = 0; i < KBUTTON_MAX; ++i )
|
|
{
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), i );
|
|
|
|
if(!pFrame)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
m_ButtonSprite[i].SetRes( pFrame );
|
|
m_ButtonSprite[i].SetPosition( m_rcRegion.left , m_rcRegion.top , m_fZPos );
|
|
}
|
|
|
|
m_rcCaptionArea = m_rcRegion;
|
|
|
|
UpdateCaption();
|
|
}
|
|
|
|
void KUIControlSimpleButton::UpdateBack()
|
|
{
|
|
if( m_sAniName.empty() )
|
|
return;
|
|
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes(m_sAniName.c_str(),0);
|
|
|
|
if( !pFrame )
|
|
{
|
|
assert( false && "Cannot find Sprite Res Frame" );
|
|
return;
|
|
}
|
|
|
|
m_rcRegion.right = m_rcRegion.left + pFrame->GetSizeX();
|
|
m_rcRegion.bottom = m_rcRegion.top + pFrame->GetSizeY();
|
|
for( int i = 0; i < KBUTTON_MAX; ++i )
|
|
{
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), i );
|
|
|
|
if(!pFrame)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
m_ButtonSprite[i].SetRes( pFrame );
|
|
m_ButtonSprite[i].SetPosition( m_rcRegion.left , m_rcRegion.top , m_fZPos );
|
|
}
|
|
m_rcCaptionArea = m_rcRegion;
|
|
}
|
|
|
|
|
|
// 2011.03.22 - servantes
|
|
void KUIControlSimpleButton::OnChangeCaptionNotify()
|
|
{
|
|
if( !IsDisable() )
|
|
{
|
|
size_t cpos = 0;
|
|
while( ( cpos = m_sCaption.find( "<#" ) ) != m_sCaption.npos )
|
|
{
|
|
m_sCaption.erase( cpos, 9 );
|
|
}
|
|
|
|
std::string strNewCaption = m_strEnableColor.c_str();
|
|
strNewCaption += m_sCaption;
|
|
m_sCaption = strNewCaption;
|
|
}
|
|
|
|
KUIControl::OnChangeCaptionNotify();
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// KUIControlButton Implement
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
namespace
|
|
{
|
|
KUIWnd* ButtonCreator()
|
|
{
|
|
return new KUIControlButton;
|
|
}
|
|
bool bButtonRegister = KUIFactory::GetInstance()->RegisterCreator( ButtonCreator, "button");
|
|
}
|
|
|
|
|
|
KUIControlButton::KUIControlButton()
|
|
:m_dwButtonState(KBUTTON_NORMAL)
|
|
{
|
|
m_bLeftButton = false;
|
|
|
|
for(int i = 0; i < KBUTTON_MAX; ++i)
|
|
{
|
|
for(int k = 0; k < 3; ++k)
|
|
{
|
|
_registerSprite( &m_ButtonSprite[i][k]);
|
|
}
|
|
}
|
|
}
|
|
|
|
KUIControlButton::~KUIControlButton()
|
|
{
|
|
}
|
|
|
|
void KUIControlButton::OnChangeCaptionNotify()
|
|
{
|
|
if( !IsDisable() )
|
|
{
|
|
size_t cpos = 0;
|
|
while( ( cpos = m_sCaption.find( "<#" ) ) != m_sCaption.npos )
|
|
{
|
|
m_sCaption.erase( cpos, 9 );
|
|
}
|
|
|
|
std::string strNewCaption = m_strEnableColor.c_str();
|
|
strNewCaption += m_sCaption;
|
|
m_sCaption = strNewCaption;
|
|
}
|
|
|
|
KUIControl::OnChangeCaptionNotify();
|
|
}
|
|
|
|
void KUIControlButton::UpdateBack()
|
|
{
|
|
if( m_sAniName.empty() )
|
|
{
|
|
return;
|
|
}
|
|
KResSprite* pFrameLeft = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 0 );
|
|
KResSprite* pFrameCenter = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 1 );
|
|
KResSprite* pFrameRight = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 2 );
|
|
|
|
if( !pFrameLeft || !pFrameCenter || !pFrameRight )
|
|
{
|
|
return;
|
|
}
|
|
|
|
int nMinimunSize = pFrameLeft->GetSizeX() + pFrameRight->GetSizeX() + pFrameCenter->GetSizeX();
|
|
|
|
if ( m_rcRegion.GetWidth() < nMinimunSize)
|
|
m_rcRegion.right = m_rcRegion.left + nMinimunSize;
|
|
|
|
m_rcRegion.bottom = m_rcRegion.top + pFrameLeft->GetSizeY();
|
|
|
|
for( int i = 0; i < KBUTTON_MAX; ++i )
|
|
{
|
|
for ( int j = 0 ; j<3 ; ++j )
|
|
{
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), i*3 + j );
|
|
|
|
if(!pFrame)
|
|
continue;
|
|
|
|
m_ButtonSprite[i][j].SetRes( pFrame );
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
DWORD KUIControlButton::OnMouseMessage(DWORD dwMessage, int x, int y)
|
|
{
|
|
DWORD dwRet = KUIControl::OnMouseMessage(dwMessage,x,y);
|
|
|
|
if(KMR_NO_GET & dwRet)
|
|
return dwRet;
|
|
|
|
if( IsDisable() ) return dwRet;
|
|
|
|
if( m_pCaptionPhrase && m_dwButtonState != KBUTTON_DOWN )
|
|
m_pCaptionPhrase->SetPosition(m_rcCaptionArea.left, m_rcCaptionArea.top, m_fZPos);
|
|
|
|
if(IsInRect(x, y))
|
|
{
|
|
switch(dwMessage)
|
|
{
|
|
case KMOUSE_MOVE:
|
|
{
|
|
if(m_dwButtonState != KBUTTON_DOWN)
|
|
{
|
|
if ( m_bLeftButton )
|
|
SetButtonState( KBUTTON_DOWN );
|
|
else SetButtonState( KBUTTON_ACTIVATE );
|
|
}
|
|
}
|
|
break;
|
|
case KLBUTTON_DOWN:
|
|
{
|
|
if( m_pCaptionPhrase ) m_pCaptionPhrase->SetPosition(m_rcCaptionArea.left, m_rcCaptionArea.top+2, m_fZPos);
|
|
|
|
m_bLeftButton = true;
|
|
SetButtonState( KBUTTON_DOWN );
|
|
PumpUpMessage(GetID(), KBUTTON_PRESSING, 0,0);
|
|
}
|
|
break;
|
|
case KLBUTTON_UP:
|
|
{
|
|
m_bLeftButton = false;
|
|
|
|
if(m_dwButtonState == KBUTTON_DOWN )
|
|
PumpUpMessage(GetID(), KBUTTON_CLICK, 0,0);
|
|
|
|
SetButtonState( KBUTTON_ACTIVATE );
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if ( dwMessage == KLBUTTON_UP )
|
|
{
|
|
m_bLeftButton = false;
|
|
m_pManager->ReleaseCapture( this );
|
|
}
|
|
// 마우스 범위를 벗어나면 Normal로 돌린다.
|
|
if(m_dwButtonState == KBUTTON_ACTIVATE || m_dwButtonState == KBUTTON_DOWN)
|
|
SetButtonState( KBUTTON_NORMAL );
|
|
}
|
|
|
|
return dwRet;
|
|
}
|
|
|
|
DWORD KUIControlButton::OnKeyMessage(DWORD dwMessage, DWORD dwKeyCode)
|
|
{
|
|
return KUIControl::OnKeyMessage(dwMessage, dwKeyCode);
|
|
}
|
|
|
|
void KUIControlButton::Render(KViewportObject * pViewport, bool isFront )
|
|
{
|
|
if ( m_bShowFlag )
|
|
{
|
|
// { 땜빵
|
|
int nSprite = m_dwButtonState;
|
|
if( IsDisable() ) nSprite = 3;
|
|
// }
|
|
|
|
if ( !(m_dwStyle & KSTYLE_BUTTON_LEFTSIDE) )
|
|
pViewport->Register( &m_ButtonSprite[nSprite][0], isFront );
|
|
|
|
pViewport->Register( &m_ButtonSprite[nSprite][1], isFront );
|
|
|
|
if ( !(m_dwStyle & KSTYLE_BUTTON_RIGHTSIDE) )
|
|
pViewport->Register( &m_ButtonSprite[nSprite][2], isFront );
|
|
|
|
// Caption Render
|
|
_renderCaption(pViewport, isFront);
|
|
|
|
// ToolTip Render
|
|
#ifndef _KUI_INVALIDATION
|
|
_renderToolTip(pViewport, isFront);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
int KUIControlButton::GetButtonWidth()
|
|
{
|
|
KResSprite* pResSprite = _getSpriteSet()->GetSpriteRes(m_sAniName.c_str(),0);
|
|
|
|
if(!pResSprite)
|
|
return 0;
|
|
|
|
return pResSprite->GetSizeX();
|
|
}
|
|
|
|
void KUIControlButton::_initControl()
|
|
{
|
|
if( m_sAniName.empty() )
|
|
{
|
|
m_rcCaptionArea = m_rcRegion;
|
|
return;
|
|
}
|
|
|
|
if( m_dwStyle & KSTYLE_BUTTON_VERTICAL)
|
|
{
|
|
_initVertical();
|
|
}
|
|
else
|
|
{
|
|
_initHorizontal();
|
|
}
|
|
|
|
m_rcCaptionArea = m_rcRegion;
|
|
SetCaptionAlign( KTextRender::KTALIGN_HCENTER | KTextRender::KTALIGN_VCENTER );
|
|
UpdateCaption();
|
|
}
|
|
|
|
void KUIControlButton::_initHorizontal()
|
|
{
|
|
KResSprite* pFrameLeft = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 0 );
|
|
KResSprite* pFrameCenter = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 1 );
|
|
KResSprite* pFrameRight = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 2 );
|
|
|
|
if( !pFrameLeft || !pFrameRight )
|
|
{
|
|
assert( false && "Cannot find Sprite Res Frame" );
|
|
return;
|
|
}
|
|
|
|
|
|
int nMinWidth = pFrameLeft->GetSizeX() + pFrameRight->GetSizeX() + pFrameCenter->GetSizeX();
|
|
if ( m_rcRegion.GetWidth() < nMinWidth )
|
|
m_rcRegion.right = m_rcRegion.left + nMinWidth;
|
|
|
|
m_rcRegion.bottom = m_rcRegion.top + pFrameLeft->GetSizeY();
|
|
|
|
for( int i = 0; i < KBUTTON_MAX; ++i )
|
|
{
|
|
for ( int j = 0 ; j<3 ; ++j )
|
|
{
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), i*3 + j );
|
|
|
|
if(!pFrame) continue;
|
|
|
|
m_ButtonSprite[i][j].SetRes( pFrame );
|
|
if ( m_dwStyle & KSTYLE_BUTTON_LEFTSIDE )
|
|
{
|
|
switch( j )
|
|
{
|
|
case 0: break;
|
|
case 1:
|
|
m_ButtonSprite[i][j].SetPosition( m_rcRegion.left, m_rcRegion.top, m_fZPos );
|
|
m_ButtonSprite[i][j].SetTargetSize( m_rcRegion.GetWidth() - pFrameRight->GetSizeX(),
|
|
pFrameCenter->GetSizeY() );
|
|
break;
|
|
case 2:
|
|
m_ButtonSprite[i][j].SetPosition( m_rcRegion.left + m_rcRegion.GetWidth() - pFrameRight->GetSizeX(),
|
|
m_rcRegion.top, m_fZPos );
|
|
break;
|
|
}
|
|
}
|
|
else if ( m_dwStyle & KSTYLE_BUTTON_RIGHTSIDE )
|
|
{
|
|
switch( j )
|
|
{
|
|
case 0: m_ButtonSprite[i][j].SetPosition( m_rcRegion.left, m_rcRegion.top, m_fZPos ); break;
|
|
case 1:
|
|
m_ButtonSprite[i][j].SetPosition( pFrameLeft->GetSizeX() + m_rcRegion.left, m_rcRegion.top, m_fZPos );
|
|
m_ButtonSprite[i][j].SetTargetSize( m_rcRegion.GetWidth() - pFrameLeft->GetSizeX(),
|
|
pFrameCenter->GetSizeY() );
|
|
break;
|
|
case 2:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch( j )
|
|
{
|
|
case 0: m_ButtonSprite[i][j].SetPosition( m_rcRegion.left, m_rcRegion.top, m_fZPos ); break;
|
|
case 1:
|
|
m_ButtonSprite[i][j].SetPosition( pFrameLeft->GetSizeX() + m_rcRegion.left, m_rcRegion.top, m_fZPos );
|
|
m_ButtonSprite[i][j].SetTargetSize( m_rcRegion.GetWidth() - pFrameLeft->GetSizeX() - pFrameRight->GetSizeX(),
|
|
pFrameCenter->GetSizeY() );
|
|
break;
|
|
case 2:
|
|
m_ButtonSprite[i][j].SetPosition( m_rcRegion.left + m_rcRegion.GetWidth() - pFrameRight->GetSizeX(),
|
|
m_rcRegion.top, m_fZPos );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void KUIControlButton::_initVertical()
|
|
{
|
|
KResSprite* pFrameTop = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 0 );
|
|
KResSprite* pFrameCenter = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 1 );
|
|
KResSprite* pFrameBottom = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 2 );
|
|
|
|
if( !pFrameTop || !pFrameBottom )
|
|
{
|
|
assert( false && "Cannot find Sprite Res Frame" );
|
|
return;
|
|
}
|
|
|
|
|
|
int nMinHeight = pFrameTop->GetSizeY() + pFrameBottom->GetSizeY() + pFrameCenter->GetSizeY();
|
|
|
|
if ( m_rcRegion.GetHeight() < nMinHeight )
|
|
m_rcRegion.bottom = m_rcRegion.top + nMinHeight;
|
|
|
|
m_rcRegion.right = m_rcRegion.left + pFrameTop->GetSizeX();
|
|
|
|
for( int i = 0; i < KBUTTON_MAX; ++i )
|
|
{
|
|
for ( int j = 0 ; j<3 ; ++j )
|
|
{
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), i*3 + j );
|
|
|
|
if(!pFrame) continue;
|
|
|
|
m_ButtonSprite[i][j].SetRes( pFrame );
|
|
switch( j )
|
|
{
|
|
case 0:
|
|
m_ButtonSprite[i][j].SetPosition( m_rcRegion.left, m_rcRegion.top, m_fZPos );
|
|
break;
|
|
case 1:
|
|
m_ButtonSprite[i][j].SetPosition( m_rcRegion.left, pFrameTop->GetSizeY() + m_rcRegion.top, m_fZPos );
|
|
m_ButtonSprite[i][j].SetTargetSize( pFrameCenter->GetSizeX(),
|
|
m_rcRegion.GetHeight() - pFrameTop->GetSizeY() - pFrameBottom->GetSizeY());
|
|
break;
|
|
case 2:
|
|
m_ButtonSprite[i][j].SetPosition( m_rcRegion.left,
|
|
m_rcRegion.top + m_rcRegion.GetHeight() - pFrameBottom->GetSizeY(), m_fZPos );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// KUIControlCaptionButton Implement
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
namespace
|
|
{
|
|
KUIWnd* CaptionButtonCreator()
|
|
{
|
|
return new KUIControlCaptionButton;
|
|
}
|
|
bool bCaptionButtonRegister = KUIFactory::GetInstance()->RegisterCreator( CaptionButtonCreator, "captionbutton");
|
|
}
|
|
|
|
KUIControlCaptionButton::KUIControlCaptionButton()
|
|
{
|
|
for(int i = 0; i < KBUTTON_MAX; ++i)
|
|
{
|
|
_registerSprite( &m_CaptionSprite[i] );
|
|
}
|
|
}
|
|
|
|
KUIControlCaptionButton::~KUIControlCaptionButton()
|
|
{
|
|
}
|
|
|
|
void KUIControlCaptionButton::OnChangeCaptionNotify()
|
|
{
|
|
if( !IsDisable() )
|
|
{
|
|
size_t cpos = 0;
|
|
while( ( cpos = m_sCaption.find( "<#" ) ) != m_sCaption.npos )
|
|
{
|
|
m_sCaption.erase( cpos, 9 );
|
|
}
|
|
|
|
std::string strNewCaption = m_strEnableColor.c_str();
|
|
strNewCaption += m_sCaption;
|
|
m_sCaption = strNewCaption;
|
|
}
|
|
|
|
KUIControl::OnChangeCaptionNotify();
|
|
}
|
|
|
|
void KUIControlCaptionButton::Render(KViewportObject * pViewport, bool isFront )
|
|
{
|
|
|
|
if ( m_bShowFlag )
|
|
{
|
|
if ( !(m_dwStyle & KSTYLE_BUTTON_LEFTSIDE) )
|
|
pViewport->Register( &m_ButtonSprite[m_dwButtonState][0], isFront );
|
|
|
|
pViewport->Register( &m_ButtonSprite[m_dwButtonState][1], isFront );
|
|
|
|
if ( !(m_dwStyle & KSTYLE_BUTTON_RIGHTSIDE) )
|
|
pViewport->Register( &m_ButtonSprite[m_dwButtonState][2], isFront );
|
|
|
|
|
|
pViewport->Register(&m_CaptionSprite[m_dwButtonState], isFront );
|
|
|
|
// ToolTip Render
|
|
#ifndef _KUI_INVALIDATION
|
|
_renderToolTip(pViewport, isFront);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
void KUIControlCaptionButton::_initControl()
|
|
{
|
|
// Caption 생성을 막기 위해서..
|
|
m_sCaptionAniName = m_sCaption;
|
|
m_sCaption.erase();
|
|
|
|
KUIControlButton::_initControl();
|
|
|
|
if( m_sCaptionAniName.empty() )
|
|
return;
|
|
|
|
int nDelta = 0, nDeltaOffset = 0;
|
|
KResSprite* pFirstFrame = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 0 );
|
|
KResSprite* pLastFrame = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 2 );
|
|
if( pFirstFrame && pLastFrame )
|
|
{
|
|
// //|||||||||
|
|
if( ::_stricmp( m_sAniName.c_str(), "button01_right" ) == 0 || ::_stricmp( m_sAniName.c_str(), "window_button01_right" ) == 0 )
|
|
{
|
|
nDelta = pFirstFrame->GetSizeX();
|
|
nDeltaOffset = pFirstFrame->GetSizeX();
|
|
}
|
|
// |||||||||//
|
|
else if( ::_stricmp( m_sAniName.c_str(), "button01_left" ) == 0 || ::_stricmp( m_sAniName.c_str(), "window_button01_left" ) == 0 )
|
|
{
|
|
nDelta = pLastFrame->GetSizeX();
|
|
nDeltaOffset = 0;
|
|
}
|
|
else if( ::_stricmp( m_sAniName.c_str(), "button01_right2" ) == 0 ) // \\|||||||
|
|
{
|
|
nDelta = pFirstFrame->GetSizeX();
|
|
nDeltaOffset = pFirstFrame->GetSizeX();
|
|
}
|
|
}
|
|
for( int i = 0; i < KBUTTON_MAX; ++i )
|
|
{
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes( m_sCaptionAniName.c_str(), i );
|
|
|
|
if(!pFrame)
|
|
continue;
|
|
|
|
// 가운데 정렬?
|
|
int nOffsetX = std::max( ( m_rcRegion.GetWidth() - nDelta - pFrame->GetSizeX() ) * 0.5f, 0.0f);
|
|
int nOffsetY = std::max( ( m_rcRegion.GetHeight() - pFrame->GetSizeY() ) * 0.5f, 0.0f);
|
|
|
|
m_CaptionSprite[i].SetRes( pFrame );
|
|
|
|
m_CaptionSprite[i].SetPosition( m_rcRegion.left + nDeltaOffset + nOffsetX, m_rcRegion.top + nOffsetY, m_fZPos );
|
|
}
|
|
}
|
|
// 2010.09.03 - prodongi
|
|
void KUIControlCaptionButton::UpdateCaption(DWORD maxWidth)
|
|
{
|
|
// Caption 생성을 막기 위해서..
|
|
if( m_sCaption.empty() ) return;
|
|
|
|
m_sCaptionAniName = m_sCaption;
|
|
m_sCaption.erase();
|
|
|
|
if( m_sCaptionAniName.empty() )
|
|
return;
|
|
|
|
int nDelta = 0, nDeltaOffset = 0;
|
|
KResSprite* pFirstFrame = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 0 );
|
|
KResSprite* pLastFrame = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), 2 );
|
|
if( pFirstFrame && pLastFrame )
|
|
{
|
|
// //|||||||||
|
|
if( ::_stricmp( m_sAniName.c_str(), "button01_right" ) == 0 || ::_stricmp( m_sAniName.c_str(), "window_button01_right" ) == 0 )
|
|
{
|
|
nDelta = pFirstFrame->GetSizeX();
|
|
nDeltaOffset = pFirstFrame->GetSizeX();
|
|
}
|
|
// |||||||||//
|
|
else if( ::_stricmp( m_sAniName.c_str(), "button01_left" ) == 0 || ::_stricmp( m_sAniName.c_str(), "window_button01_left" ) == 0 )
|
|
{
|
|
nDelta = pLastFrame->GetSizeX();
|
|
nDeltaOffset = 0;
|
|
}
|
|
else if( ::_stricmp( m_sAniName.c_str(), "button01_right2" ) == 0 ) // \\|||||||
|
|
{
|
|
nDelta = pFirstFrame->GetSizeX();
|
|
nDeltaOffset = pFirstFrame->GetSizeX();
|
|
}
|
|
}
|
|
for( int i = 0; i < KBUTTON_MAX; ++i )
|
|
{
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes( m_sCaptionAniName.c_str(), i );
|
|
|
|
if(!pFrame)
|
|
continue;
|
|
|
|
// 가운데 정렬?
|
|
int nOffsetX = std::max( ( m_rcRegion.GetWidth() - nDelta - pFrame->GetSizeX() ) * 0.5f, 0.0f);
|
|
int nOffsetY = std::max( ( m_rcRegion.GetHeight() - pFrame->GetSizeY() ) * 0.5f, 0.0f);
|
|
|
|
m_CaptionSprite[i].SetRes( pFrame );
|
|
|
|
m_CaptionSprite[i].SetPosition( m_rcRegion.left + nDeltaOffset + nOffsetX, m_rcRegion.top + nOffsetY, m_fZPos );
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// KUIControlCheck Implement
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
namespace
|
|
{
|
|
KUIWnd* CheckCreator()
|
|
{
|
|
return new KUIControlCheck;
|
|
}
|
|
bool bCheckRegister = KUIFactory::GetInstance()->RegisterCreator( CheckCreator, "check");
|
|
}
|
|
|
|
KUIControlCheck::KUIControlCheck()
|
|
{
|
|
}
|
|
DWORD KUIControlCheck::OnMouseMessage(DWORD dwMessage, int x, int y)
|
|
{
|
|
DWORD dwRet = KUIControl::OnMouseMessage(dwMessage,x,y);
|
|
|
|
if(KMR_NO_GET & dwRet)
|
|
return dwRet;
|
|
|
|
if( IsDisable() ) return dwRet;
|
|
|
|
if(IsInRect(x, y))
|
|
{
|
|
switch(dwMessage)
|
|
{
|
|
case KMOUSE_MOVE:
|
|
if(m_dwButtonState != KBUTTON_DOWN)
|
|
SetButtonState( KBUTTON_ACTIVATE );
|
|
break;
|
|
case KLBUTTON_DOWN:
|
|
if( m_dwButtonState == KBUTTON_DOWN)
|
|
SetButtonState( KBUTTON_ACTIVATE );
|
|
else
|
|
SetButtonState( KBUTTON_DOWN );
|
|
|
|
PumpUpMessage(GetID(), KCHECK_CHANGE, 0,0);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
// 마우스 범위를 벗어나면 Normal로 돌린다.
|
|
if(m_dwButtonState == KBUTTON_ACTIVATE)
|
|
SetButtonState( KBUTTON_NORMAL );
|
|
}
|
|
|
|
return dwRet;
|
|
}
|
|
|
|
void KUIControlCheck::Process( DWORD dwTime )
|
|
{
|
|
_processToolTip();
|
|
}
|
|
|
|
void KUIControlCheck::Render(KViewportObject * pViewport, bool isFront)
|
|
{
|
|
if ( m_bShowFlag )
|
|
{
|
|
// { 땜빵
|
|
int nSprite = m_dwButtonState;
|
|
if( IsDisable() )
|
|
nSprite = 0;
|
|
// }
|
|
|
|
pViewport->Register(&m_ButtonSprite[nSprite], isFront );
|
|
// Caption Render
|
|
_renderCaption(pViewport, isFront);
|
|
|
|
// ToolTip Render
|
|
#ifndef _KUI_INVALIDATION
|
|
_renderToolTip(pViewport, isFront);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
bool KUIControlCheck::GetCheck()
|
|
{
|
|
return m_dwButtonState == KBUTTON_DOWN;
|
|
}
|
|
void KUIControlCheck::SetCheck(bool bCheck)
|
|
{
|
|
SetButtonState( bCheck ? KBUTTON_DOWN : KBUTTON_NORMAL );
|
|
}
|
|
|
|
void KUIControlCheck::_initControl()
|
|
{
|
|
if( m_sAniName.empty() )
|
|
return;
|
|
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes(m_sAniName.c_str(),0);
|
|
|
|
if( !pFrame )
|
|
{
|
|
assert( false && "Cannot find Sprite Res Frame" );
|
|
return;
|
|
}
|
|
|
|
for( int i = 0; i < KBUTTON_MAX; ++i )
|
|
{
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes( m_sAniName.c_str(), i );
|
|
|
|
if(!pFrame)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
m_ButtonSprite[i].SetRes( pFrame );
|
|
m_ButtonSprite[i].SetPosition( m_rcRegion.left, m_rcRegion.top, m_fZPos );
|
|
}
|
|
|
|
if( !( m_dwStyle & KSTYLE_CHECK_CAPTION_RIGHT) )
|
|
{
|
|
m_rcRegion.right = m_rcRegion.left + pFrame->GetSizeX();
|
|
m_rcRegion.bottom = m_rcRegion.top + pFrame->GetSizeY();
|
|
m_rcCaptionArea = m_rcRegion;
|
|
}
|
|
else
|
|
{
|
|
m_rcCaptionArea = m_rcRegion;
|
|
m_rcCaptionArea.left = m_rcRegion.left + pFrame->GetSizeX();
|
|
}
|
|
|
|
UpdateCaption();
|
|
}
|
|
void KUIControlCheck::SetDisableCheck()
|
|
{
|
|
Disable();
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// KUIControlButtonCheck Implement
|
|
// MJ 2004/11/30
|
|
// 12 프레임 상속받은 버튼을 상속받는 체크 버튼이라고나 할까~요~?
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
namespace
|
|
{
|
|
KUIWnd* CheckButtonCreator()
|
|
{
|
|
return new KUIControlButtonCheck;
|
|
}
|
|
bool bCheckButtonRegister = KUIFactory::GetInstance()->RegisterCreator( CheckButtonCreator, "buttoncheck");
|
|
}
|
|
|
|
KUIControlButtonCheck::KUIControlButtonCheck()
|
|
{
|
|
}
|
|
DWORD KUIControlButtonCheck::OnMouseMessage(DWORD dwMessage, int x, int y)
|
|
{
|
|
DWORD dwRet = KUIControl::OnMouseMessage(dwMessage,x,y);
|
|
|
|
if(KMR_NO_GET & dwRet)
|
|
return dwRet;
|
|
|
|
//if(m_dwButtonState == KBUTTON_DISABLE)
|
|
// return dwRet;
|
|
|
|
if(IsInRect(x, y))
|
|
{
|
|
switch(dwMessage)
|
|
{
|
|
case KMOUSE_MOVE:
|
|
if(m_dwButtonState != KBUTTON_DOWN)
|
|
{
|
|
if(m_dwButtonState != KBUTTON_DOWN)
|
|
SetButtonState( KBUTTON_ACTIVATE );
|
|
}
|
|
break;
|
|
case KLBUTTON_DOWN:
|
|
{
|
|
if( m_dwButtonState == KBUTTON_DOWN)
|
|
SetButtonState( KBUTTON_ACTIVATE );
|
|
else
|
|
{
|
|
m_bLeftButton = true;
|
|
SetButtonState( KBUTTON_DOWN );
|
|
}
|
|
|
|
PumpUpMessage(GetID(), KCHECK_CHANGE, 0,0);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
// 마우스 범위를 벗어나면 Normal로 돌린다.
|
|
if(m_dwButtonState == KBUTTON_ACTIVATE)
|
|
SetButtonState( KBUTTON_NORMAL );
|
|
}
|
|
|
|
return dwRet;
|
|
}
|
|
|
|
void KUIControlButtonCheck::Render(KViewportObject * pViewport, bool isFront)
|
|
{
|
|
KUIControlButton::Render( pViewport, isFront );
|
|
}
|
|
|
|
bool KUIControlButtonCheck::GetCheck()
|
|
{
|
|
return m_dwButtonState == KBUTTON_DOWN;
|
|
}
|
|
void KUIControlButtonCheck::SetCheck(bool bCheck)
|
|
{
|
|
SetButtonState( bCheck ? KBUTTON_DOWN : KBUTTON_NORMAL );
|
|
}
|
|
|
|
void KUIControlButtonCheck::_initControl()
|
|
{
|
|
if( m_sAniName.empty() )
|
|
{
|
|
m_rcCaptionArea = m_rcRegion;
|
|
return;
|
|
}
|
|
|
|
_initHorizontal();
|
|
|
|
m_rcCaptionArea = m_rcRegion;
|
|
|
|
SetCaptionAlign( KTextRender::KTALIGN_HCENTER | KTextRender::KTALIGN_VCENTER );
|
|
UpdateCaption();
|
|
}
|
|
void KUIControlButtonCheck::SetDisableCheck()
|
|
{
|
|
Disable();
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace
|
|
{
|
|
KUIWnd* CaptionCheckButtonCreator()
|
|
{
|
|
return new KUIControlCaptionCheck;
|
|
}
|
|
bool bCaptionCheckButtonRegister = KUIFactory::GetInstance()->RegisterCreator( CaptionCheckButtonCreator, "captionbuttoncheck");
|
|
}
|
|
|
|
KUIControlCaptionCheck::KUIControlCaptionCheck()
|
|
{
|
|
for(int i = 0; i < KBUTTON_MAX; ++i)
|
|
{
|
|
_registerSprite( &m_CaptionSprite[i] );
|
|
}
|
|
}
|
|
|
|
DWORD KUIControlCaptionCheck::OnMouseMessage(DWORD dwMessage, int x, int y)
|
|
{
|
|
DWORD dwRet = KUIControl::OnMouseMessage(dwMessage,x,y);
|
|
|
|
if(KMR_NO_GET & dwRet)
|
|
return dwRet;
|
|
|
|
//if(m_dwButtonState == KBUTTON_DISABLE)
|
|
// return dwRet;
|
|
|
|
if(IsInRect(x, y))
|
|
{
|
|
switch(dwMessage)
|
|
{
|
|
case KMOUSE_MOVE:
|
|
if(m_dwButtonState != KBUTTON_DOWN)
|
|
{
|
|
if(m_dwButtonState != KBUTTON_DOWN)
|
|
SetButtonState( KBUTTON_ACTIVATE );
|
|
}
|
|
break;
|
|
case KLBUTTON_DOWN:
|
|
{
|
|
if( m_dwButtonState == KBUTTON_DOWN)
|
|
SetButtonState( KBUTTON_ACTIVATE );
|
|
else
|
|
{
|
|
m_bLeftButton = true;
|
|
SetButtonState( KBUTTON_DOWN );
|
|
}
|
|
|
|
PumpUpMessage(GetID(), KCHECK_CHANGE, 0,0);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
// 마우스 범위를 벗어나면 Normal로 돌린다.
|
|
if(m_dwButtonState == KBUTTON_ACTIVATE)
|
|
SetButtonState( KBUTTON_NORMAL );
|
|
}
|
|
|
|
return dwRet;
|
|
}
|
|
|
|
void KUIControlCaptionCheck::Render(KViewportObject * pViewport, bool isFront )
|
|
{
|
|
//KUIControlButton::Render( pViewport );
|
|
|
|
// { 땜빵
|
|
int nSprite = m_dwButtonState;
|
|
if( IsDisable() ) nSprite = 3;
|
|
// }
|
|
|
|
if ( m_bShowFlag )
|
|
{
|
|
if ( !(m_dwStyle & KSTYLE_BUTTON_LEFTSIDE) )
|
|
pViewport->Register( &m_ButtonSprite[nSprite][0], isFront );
|
|
|
|
pViewport->Register( &m_ButtonSprite[nSprite][1], isFront );
|
|
|
|
if ( !(m_dwStyle & KSTYLE_BUTTON_RIGHTSIDE) )
|
|
pViewport->Register( &m_ButtonSprite[nSprite][2], isFront );
|
|
|
|
pViewport->Register(&m_CaptionSprite[nSprite], isFront );
|
|
|
|
// ToolTip Render
|
|
#ifndef _KUI_INVALIDATION
|
|
_renderToolTip(pViewport, isFront);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
bool KUIControlCaptionCheck::GetCheck()
|
|
{
|
|
return m_dwButtonState == KBUTTON_DOWN;
|
|
}
|
|
void KUIControlCaptionCheck::SetCheck(bool bCheck)
|
|
{
|
|
SetButtonState( bCheck ? KBUTTON_DOWN : KBUTTON_NORMAL );
|
|
}
|
|
|
|
void KUIControlCaptionCheck::_initControl()
|
|
{
|
|
// Caption 생성을 막기 위해서..
|
|
m_sCaptionAniName = m_sCaption;
|
|
m_sCaption.erase();
|
|
|
|
if( m_sAniName.empty() )
|
|
{
|
|
m_rcCaptionArea = m_rcRegion;
|
|
return;
|
|
}
|
|
|
|
_initHorizontal();
|
|
|
|
m_rcCaptionArea = m_rcRegion;
|
|
|
|
SetCaptionAlign( KTextRender::KTALIGN_HCENTER | KTextRender::KTALIGN_VCENTER );
|
|
UpdateCaption();
|
|
|
|
if( m_sCaptionAniName.empty() )
|
|
return;
|
|
|
|
for( int i = 0; i < KBUTTON_MAX; ++i )
|
|
{
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes( m_sCaptionAniName.c_str(), i );
|
|
|
|
if(!pFrame)
|
|
continue;
|
|
|
|
// 가운데 정렬?
|
|
int nOffsetX = std::max( ( m_rcRegion.GetWidth() - pFrame->GetSizeX() ) * 0.5f, 0.0f);
|
|
int nOffsetY = std::max( ( m_rcRegion.GetHeight() - pFrame->GetSizeY() ) * 0.5f, 0.0f);
|
|
|
|
m_CaptionSprite[i].SetRes( pFrame );
|
|
m_CaptionSprite[i].SetPosition( m_rcRegion.left + nOffsetX, m_rcRegion.top + nOffsetY, m_fZPos );
|
|
}
|
|
}
|
|
void KUIControlCaptionCheck::SetDisableCheck()
|
|
{
|
|
Disable();
|
|
}
|
|
// 2010.09.03 - prodongi
|
|
void KUIControlCaptionCheck::UpdateCaption(DWORD maxWidth)
|
|
{
|
|
// Caption 생성을 막기 위해서..
|
|
if( m_sCaption.empty() ) return;
|
|
|
|
m_sCaptionAniName = m_sCaption;
|
|
m_sCaption.erase();
|
|
|
|
if( m_sCaptionAniName.empty() )
|
|
return;
|
|
|
|
for( int i = 0; i < KBUTTON_MAX; ++i )
|
|
{
|
|
KResSprite* pFrame = _getSpriteSet()->GetSpriteRes( m_sCaptionAniName.c_str(), i );
|
|
|
|
if(!pFrame)
|
|
continue;
|
|
|
|
// 가운데 정렬?
|
|
int nOffsetX = std::max( ( m_rcRegion.GetWidth() - pFrame->GetSizeX() ) * 0.5f, 0.0f);
|
|
int nOffsetY = std::max( ( m_rcRegion.GetHeight() - pFrame->GetSizeY() ) * 0.5f, 0.0f);
|
|
|
|
m_CaptionSprite[i].SetRes( pFrame );
|
|
m_CaptionSprite[i].SetPosition( m_rcRegion.left + nOffsetX, m_rcRegion.top + nOffsetY, m_fZPos );
|
|
}
|
|
}
|
|
|
|
#endif |