432 lines
13 KiB
C++
432 lines
13 KiB
C++
#include "stdafx.h"
|
|
#include "KUIWndManager.h"
|
|
//#include "KUIControlButton.h"
|
|
#include "KUIControlStatic.h"
|
|
#include "KUIControlList.h"
|
|
|
|
#include <toolkit/nsl.h>
|
|
#include <toolkit/nsluni.h>
|
|
|
|
//#include "Util.h"
|
|
//#include "KResourceManager.h"
|
|
#include "CInput.h"
|
|
|
|
using namespace KUI_MESSAGE;
|
|
|
|
namespace
|
|
{
|
|
//배경이 없어야 한다. 각 리스트 칸에 대한 배경은 KUIControlList에서 관리한다.
|
|
//SetShow(false)하면 자식 컨트롤들도 랜더링이 안걸리기 때문에 이렇게 처리해야 한다.
|
|
// const char* c_lpNoneBackGroundAni = "static_common_background00";
|
|
const char* c_lpFrameSpriteName = "ui_frame.spr";
|
|
}
|
|
|
|
//이 함수는 public이지만 KUIControlList에서 Item을 생성할때말고는 절대 호출해서는 안된다.
|
|
//friend를 사용하는 것도 나쁘지는 않지만 흠...
|
|
/// 2011.07.11 wndManager 추가 - prodongi
|
|
bool KUIControlListItem::ItemCreate( KUIControlList* pParent, const char* lpClassName, const char* lpCtrID, KUIWndManager* wndManager )
|
|
{
|
|
if( m_bCreate ) return false;
|
|
|
|
KUIWND_CREATE_ARG arg;
|
|
arg.lpszSprName = c_lpFrameSpriteName;
|
|
//arg.pWndManager = m_pManager;
|
|
arg.pWndManager = wndManager; /// 2011.07.11 m_pManager가 null이기 때문에 직접 입력 받은걸 세팅해 준다 - prodongi
|
|
// arg.lpszAniName = c_lpNoneBackGroundAni;
|
|
arg.lpszClassName = lpClassName;
|
|
arg.lpszID = lpCtrID;
|
|
arg.pParent = (KUIWnd*)pParent;
|
|
arg.dwStyle = 0;
|
|
arg.rcRect = pParent->GetRect();
|
|
|
|
if( m_nDefaultGap )
|
|
{
|
|
if( pParent->IsHorizon() )
|
|
arg.rcRect.bottom = arg.rcRect.top+m_nDefaultGap;
|
|
else arg.rcRect.right = arg.rcRect.left+m_nDefaultGap;
|
|
}
|
|
|
|
KUIControl::Create(arg);
|
|
return true;
|
|
}
|
|
|
|
void KUIControlListItem::SetIconCtr( KUIControlIconStatic* pIcon, const char* pAni )
|
|
{
|
|
if( pIcon == NULL ) return;
|
|
|
|
if( pAni == NULL || ::strlen(pAni) <= 0 )
|
|
pIcon->SetShow(false);
|
|
else
|
|
{
|
|
pIcon->SetIcon(m_sSprName.c_str(), pAni);
|
|
pIcon->SetShow(true);
|
|
}
|
|
}
|
|
|
|
void KUIControlListItem::SetStaticCaption( KUIControlStatic* pStatic, const char* lpCaption )
|
|
{
|
|
if( pStatic == NULL ) return;
|
|
|
|
if( lpCaption == NULL || ::strlen(lpCaption) <= 0 )
|
|
{
|
|
pStatic->SetCaption("");
|
|
pStatic->SetShow(false);
|
|
}
|
|
else
|
|
{
|
|
pStatic->SetCaption(lpCaption);
|
|
pStatic->SetShow(true);
|
|
}
|
|
}
|
|
|
|
void KUIControlListItem::CuttingText( KUIControlStatic* pNameText, const char* lpCaption, std::string& rOutCutName )
|
|
{
|
|
if( !pNameText || !lpCaption || ::strlen(lpCaption)==0 ) return;
|
|
const char* szFontName = "<font:\"Tahoma\">";
|
|
rOutCutName = lpCaption;
|
|
|
|
KSize size = KTextPhrase::GetStringSize( rOutCutName.c_str(), 1024 );
|
|
if( size.width >= pNameText->GetRect().GetWidth() )
|
|
{
|
|
STRING_VECTOR vecLineList;
|
|
pNameText->SplitLine( vecLineList, rOutCutName.c_str(), szFontName, 10 );
|
|
|
|
if( vecLineList.size() > 0 )
|
|
{
|
|
/*
|
|
wchar_t wtempCmpStr[1024] ={NULL,};
|
|
DWORD CodePage = GetCodePageFromLang((LANGID)GetSystemDefaultLangID()); //이것을 삭제할때는 위의 #include "CInput.h"도 삭제할 것
|
|
MultiByteToWideChar(CodePage, 0, vecLineList[0].c_str(), vecLineList[0].length(), wtempCmpStr, 1024);
|
|
|
|
std::wstring wCmpStr = wtempCmpStr;
|
|
wCmpStr += L"..";
|
|
|
|
char tempCutStr[1024] = {NULL,};
|
|
ConvertString(CodePage, wCmpStr.c_str(), wCmpStr.length(), tempCutStr, 1024);
|
|
rOutCutName = tempCutStr;*/
|
|
|
|
//유코드 변환 과정에서 윈도우 로컬 관련 문제점을 iconv로 수정
|
|
//2009-06-24: hunee
|
|
std::wstring wstr = nsl::uni::conv(vecLineList[0].c_str());
|
|
wstr += L"..";
|
|
|
|
std::string str = nsl::uni::conv(wstr.c_str());
|
|
rOutCutName = str;
|
|
}
|
|
}
|
|
}
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
namespace StringItem
|
|
{
|
|
KUIWnd* DungeonLaidItemCreator()
|
|
{
|
|
return new KUIControlStringItem;
|
|
}
|
|
bool bDungeonLaidItemRegister = KUIFactory::GetInstance()->RegisterCreator( DungeonLaidItemCreator, c_lpStrListItemCtrName );
|
|
|
|
// const char* c_lpStaticStringAni = "static_common_windowboundary";
|
|
const char* c_lpStaticStrCtrName = "static_string";
|
|
|
|
}
|
|
|
|
void KUIControlStringItem::_initControl()
|
|
{
|
|
KUIWnd::_ClearChildList();
|
|
|
|
KUIWND_CREATE_ARG arg;
|
|
arg.lpszSprName = m_sSprName.c_str();
|
|
arg.pWndManager = m_pManager;
|
|
// arg.lpszAniName = c_lpStaticStringAni;
|
|
arg.lpszClassName = "static";
|
|
arg.lpszID = StringItem::c_lpStaticStrCtrName;
|
|
arg.pParent = this;
|
|
arg.dwStyle = 0;
|
|
arg.rcRect = m_rcRegion;
|
|
|
|
m_pManager->CreateControl( arg );
|
|
|
|
KUIControlListItem::_initControl();
|
|
}
|
|
|
|
void KUIControlStringItem::SetItem( Item* pItemData )
|
|
{
|
|
if( pItemData )
|
|
{
|
|
StrItem* pStrData = (StrItem*)pItemData;
|
|
if( !pStrData->strCaption.empty() )
|
|
{
|
|
KUIControlStatic* pIcon = (KUIControlStatic*)GetChild( StringItem::c_lpStaticStrCtrName );
|
|
if( pIcon )
|
|
{
|
|
// sonador 3.1.8 경매장 카테고리 표시 트리 SINLE_LINE 속성 적용
|
|
//std::string strCapTion;
|
|
//CuttingText(pIcon, pStrData->strCaption.c_str(), strCapTion);
|
|
//SetChildCaption( StringItem::c_lpStaticStrCtrName, strCapTion.c_str() );
|
|
/// 2010.12.23 - prodongi
|
|
if (pItemData->uiFlag)
|
|
pIcon->SetFlag(pItemData->uiFlag);
|
|
SetChildCaption( StringItem::c_lpStaticStrCtrName, pStrData->strCaption.c_str() );
|
|
}
|
|
}
|
|
else SetChildCaption( StringItem::c_lpStaticStrCtrName, "" );
|
|
}
|
|
else SetChildCaption( StringItem::c_lpStaticStrCtrName, "" );
|
|
}
|
|
|
|
void KUIControlStringItem::ResizeListItemRect( KRect rt )
|
|
{
|
|
Resize( rt );
|
|
SetChildresize( StringItem::c_lpStaticStrCtrName, rt );
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
namespace IconString
|
|
{
|
|
KUIWnd* IconNStringItemCreator()
|
|
{
|
|
return new KUIControlIconNStringItem;
|
|
}
|
|
bool bIconNStringItemRegister = KUIFactory::GetInstance()->RegisterCreator( IconNStringItemCreator, c_lpIconStrListItemCtrName );
|
|
|
|
const char* c_lpStaticIconAni = "";
|
|
const char* c_lpStaticStrCtrName = "static_string";
|
|
const char* c_lpIconCtrName = "icon";
|
|
}
|
|
|
|
void KUIControlIconNStringItem::_initControl()
|
|
{
|
|
KUIWnd::_ClearChildList();
|
|
|
|
KUIWND_CREATE_ARG arg;
|
|
//스트링 컨트롤 생성
|
|
arg.lpszSprName = m_sSprName.c_str();
|
|
arg.pWndManager = m_pManager;
|
|
// arg.lpszAniName = c_lpStaticStringAni;
|
|
arg.lpszClassName = "static";
|
|
arg.lpszID = IconString::c_lpStaticStrCtrName;
|
|
arg.pParent = this;
|
|
arg.dwStyle = 0;
|
|
{
|
|
arg.rcRect = m_rcRegion;
|
|
arg.rcRect.left = 33;
|
|
}
|
|
// sonador 3.1.8 경매장 카테고리 표시 트리 SINLE_LINE 속성 적용
|
|
arg.dwFlag = KFLAG_SINGLE_LINE;
|
|
m_pManager->CreateControl( arg );
|
|
|
|
//아이콘 생성
|
|
arg.lpszSprName = m_sSprName.c_str();
|
|
arg.pWndManager = m_pManager;
|
|
arg.lpszAniName = IconString::c_lpStaticIconAni;
|
|
arg.lpszClassName = "iconstatic";
|
|
arg.lpszID = IconString::c_lpIconCtrName;
|
|
arg.pParent = this;
|
|
arg.dwFlag = KFLAG_NO_GET_MESSAGE;
|
|
arg.dwStyle = 0;
|
|
{ arg.rcRect = KRect(m_rcRegion.left+5, m_rcRegion.top+5, 0, 0);
|
|
arg.rcRect.right = arg.rcRect.left + 19;
|
|
arg.rcRect.bottom = arg.rcRect.top + 19;
|
|
}
|
|
m_pManager->CreateControl( arg );
|
|
|
|
KUIControlListItem::_initControl();
|
|
}
|
|
|
|
void KUIControlIconNStringItem::SetItem( Item* pItemData )
|
|
{
|
|
KUIControlIconStatic* pIcon = (KUIControlIconStatic*)GetChild( IconString::c_lpIconCtrName );
|
|
KUIControlStatic* pStatic = (KUIControlStatic*)GetChild( IconString::c_lpStaticStrCtrName );
|
|
|
|
if( pItemData )
|
|
{
|
|
IconStrItem* pIconStrData = (IconStrItem*)pItemData;
|
|
if( !pIconStrData->strIconAni.empty() )
|
|
{
|
|
if( pIcon )
|
|
{
|
|
if( pIconStrData->strIconAni.empty() )
|
|
pIcon->SetShow(false);
|
|
else
|
|
{
|
|
pIcon->SetIcon(m_sSprName.c_str(), pIconStrData->strIconAni.c_str());
|
|
pIcon->SetShow(true);
|
|
}
|
|
|
|
}
|
|
}
|
|
if( !pIconStrData->strCaption.empty() )
|
|
{
|
|
if( pIcon )
|
|
{
|
|
KRect rcIcon = pIcon->GetRect();
|
|
KRect rcStatic = pStatic->GetRect();
|
|
pStatic->Resize( KRect(rcIcon.right+5, rcStatic.top, rcStatic.right, rcStatic.bottom) );
|
|
}
|
|
if( pStatic )
|
|
{
|
|
// sonador 3.1.8 경매장 카테고리 표시 트리 SINLE_LINE 속성 적용
|
|
//std::string strCapTion;
|
|
//CuttingText(pStatic, pIconStrData->strCaption.c_str(), strCapTion);
|
|
//pStatic->SetCaption( strCapTion.c_str() );
|
|
pStatic->SetCaption( pIconStrData->strCaption.c_str() );
|
|
pStatic->SetShow(true);
|
|
|
|
}
|
|
}
|
|
else SetChildCaption( IconString::c_lpStaticStrCtrName, "" );
|
|
}
|
|
else
|
|
{
|
|
if( pIcon ) pIcon->SetShow(false);
|
|
if( pStatic )
|
|
{
|
|
pStatic->SetCaption("");
|
|
pStatic->SetShow(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
void KUIControlIconNStringItem::ResizeListItemRect( KRect rt )
|
|
{
|
|
Resize( rt );
|
|
|
|
KUIControlIconStatic* pIcon = (KUIControlIconStatic*)GetChild( IconString::c_lpIconCtrName );
|
|
KUIControlStatic* pStatic = (KUIControlStatic*)GetChild( IconString::c_lpStaticStrCtrName );
|
|
if( pIcon && pStatic )
|
|
{
|
|
KRect rcIcon = pIcon->GetRect();
|
|
KRect rcStatic = pStatic->GetRect();
|
|
pStatic->Resize( KRect(rcIcon.right+5, rcStatic.top, rcStatic.right, rcStatic.bottom) );
|
|
}
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
namespace Community
|
|
{
|
|
KUIWnd* CommunityItemCreator()
|
|
{
|
|
return new KUIControlCommunityItem;
|
|
}
|
|
bool bCommunityItemRegister = KUIFactory::GetInstance()->RegisterCreator( CommunityItemCreator, c_lpCommunityListItemCtrName );
|
|
|
|
const char* c_lpStaticIconAni = "static_job_unknownicon";
|
|
|
|
const char* c_lpLoginIconCtrName = "login_icon";
|
|
const char* c_lpJopIconCtrName = "Jop_icon";
|
|
const char* c_lpLvStaticStrCtrName = "static_lv_string";
|
|
const char* c_lpNameStaticStrCtrName = "static_name_string";
|
|
|
|
const int c_nLoginIconSize = 15;
|
|
const int c_nJopIconSize = 19;
|
|
const int c_nWinGap = 4;
|
|
const int c_nCtrGap = 2;
|
|
}
|
|
|
|
void KUIControlCommunityItem::_initControl()
|
|
{
|
|
KUIWnd::_ClearChildList();
|
|
|
|
//로그인 아이콘 생성
|
|
KUIWND_CREATE_ARG argIcon;
|
|
argIcon.lpszSprName = m_sSprName.c_str();
|
|
argIcon.pWndManager = m_pManager;
|
|
argIcon.lpszAniName = Community::c_lpStaticIconAni;
|
|
argIcon.lpszClassName = "iconstatic";
|
|
argIcon.lpszID = Community::c_lpLoginIconCtrName;
|
|
argIcon.pParent = this;
|
|
argIcon.dwFlag = KFLAG_NO_GET_MESSAGE;
|
|
argIcon.dwStyle = 0;
|
|
{ argIcon.rcRect = KRect(m_rcRegion.left+Community::c_nWinGap, m_rcRegion.top+Community::c_nCtrGap+3, 0, 0);
|
|
argIcon.rcRect.right = argIcon.rcRect.left + Community::c_nLoginIconSize;
|
|
argIcon.rcRect.bottom = argIcon.rcRect.top + Community::c_nLoginIconSize +3;
|
|
}
|
|
m_pManager->CreateControl( argIcon );
|
|
|
|
//아이콘 생성
|
|
argIcon.lpszID = Community::c_lpJopIconCtrName;
|
|
{ KRect rt(argIcon.rcRect);
|
|
argIcon.rcRect = KRect(rt.right+Community::c_nCtrGap, rt.top-2, 0, 0);
|
|
argIcon.rcRect.right = argIcon.rcRect.left + Community::c_nJopIconSize;
|
|
argIcon.rcRect.bottom = argIcon.rcRect.top + Community::c_nJopIconSize;
|
|
}
|
|
m_pManager->CreateControl( argIcon );
|
|
|
|
//스트링 컨트롤 생성
|
|
KUIWND_CREATE_ARG argStatic;
|
|
argStatic.lpszSprName = m_sSprName.c_str();
|
|
argStatic.pWndManager = m_pManager;
|
|
argStatic.lpszClassName = "static";
|
|
argStatic.lpszID = Community::c_lpLvStaticStrCtrName;
|
|
argStatic.pParent = this;
|
|
argIcon.dwFlag = KFLAG_NO_GET_MESSAGE;
|
|
argStatic.dwStyle = 0;
|
|
{ KRect rt(argIcon.rcRect);
|
|
argStatic.rcRect = KRect(rt.right+Community::c_nCtrGap, rt.top, 0, 0);
|
|
argStatic.rcRect.right = argStatic.rcRect.left+30;
|
|
argStatic.rcRect.bottom = argStatic.rcRect.top+20;
|
|
}
|
|
m_pManager->CreateControl( argStatic );
|
|
|
|
//스트링 컨트롤 생성
|
|
argStatic.lpszID = Community::c_lpNameStaticStrCtrName;
|
|
{ KRect rt(argStatic.rcRect);
|
|
argStatic.rcRect = KRect(rt.right+Community::c_nCtrGap, rt.top, 0, 0);
|
|
argStatic.rcRect.right = m_rcRegion.right-Community::c_nWinGap;
|
|
argStatic.rcRect.bottom = argStatic.rcRect.top+20;
|
|
}
|
|
m_pManager->CreateControl( argStatic );
|
|
|
|
KUIControlListItem::_initControl();
|
|
}
|
|
|
|
void KUIControlCommunityItem::SetItem( Item* pItemData )
|
|
{
|
|
if( pItemData )
|
|
{
|
|
CommunityItem* pCommunityData = (CommunityItem*)pItemData;
|
|
|
|
KUIControlIconStatic* pOnlineIcon = (KUIControlIconStatic*)GetChild( Community::c_lpLoginIconCtrName );
|
|
KUIControlIconStatic* pJopIcon = (KUIControlIconStatic*)GetChild( Community::c_lpJopIconCtrName );
|
|
KUIControlStatic* pLvStatic = (KUIControlStatic*)GetChild( Community::c_lpLvStaticStrCtrName );
|
|
KUIControlStatic* pNameStatic = (KUIControlStatic*)GetChild( Community::c_lpNameStaticStrCtrName );
|
|
if( !pOnlineIcon && !pJopIcon && !pLvStatic && !pNameStatic ) return;
|
|
|
|
KUIControlListItem::SetIconCtr( pOnlineIcon, pCommunityData->strOnlineIcon.c_str() );
|
|
KUIControlListItem::SetIconCtr( pJopIcon, pCommunityData->strJopIcon.c_str() );
|
|
KUIControlListItem::SetStaticCaption( pLvStatic, pCommunityData->strLV.c_str() );
|
|
KUIControlListItem::SetStaticCaption( pNameStatic, pCommunityData->strName.c_str() );
|
|
}
|
|
else
|
|
{
|
|
KUIControlIconStatic* pIcon = (KUIControlIconStatic*)GetChild( IconString::c_lpIconCtrName );
|
|
if( pIcon ) pIcon->SetShow(false);
|
|
}
|
|
}
|
|
|
|
void KUIControlCommunityItem::ResizeListItemRect( KRect rt )
|
|
{
|
|
Resize( rt );
|
|
|
|
KUIControlStatic* pNameStatic = (KUIControlStatic*)GetChild( Community::c_lpNameStaticStrCtrName );
|
|
if( pNameStatic )
|
|
{
|
|
KRect rcName = pNameStatic->GetRect();
|
|
rcName.right = rt.right-Community::c_nWinGap;
|
|
pNameStatic->Resize(rcName);
|
|
}
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|