aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/XUI/XUI_Control_ComboBox.cpp
blob: 0096da4459974fc10897e0c0294cb01116f353e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "stdafx.h"
#include "XUI_Control_ComboBox.h"
#include "..\Xbox_App.h"

HRESULT CXuiControl4JComboBox::OnInit(XUIMessageInit *pInitData, BOOL& bHandled)
{
	m_ListData.nItems=0;
	m_ListData.pItems=NULL;

	return S_OK;
}

void CXuiControl4JComboBox::SetData(LIST_ITEM_INFO *pItems,int iCount)
{
	CXuiControl4JComboBox *pThis;
    HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);

	// copy the data in
	pThis->m_ListData.pItems= new LIST_ITEM_INFO [iCount] ;
	memcpy(pThis->m_ListData.pItems,pItems,sizeof(LIST_ITEM_INFO)*iCount);
	pThis->m_ListData.nItems=iCount;

	//InsertItems( 0, iCount );
}

int CXuiControl4JComboBox::GetSelectedIndex()
{
	return XuiListGetCurSel(GetListObject(),NULL);
}

// Gets called every frame
HRESULT CXuiControl4JComboBox::OnGetSourceDataText(XUIMessageGetSourceText *pGetSourceTextData,BOOL& bHandled)
{
	if( ( 0 == pGetSourceTextData->iData ) && ( ( pGetSourceTextData->bItemData ) ) ) 
	{
		pGetSourceTextData->szText = 
			m_ListData.pItems[pGetSourceTextData->iItem].pwszText;
		bHandled = TRUE;
	}
	return S_OK;
}

HRESULT CXuiControl4JComboBox::OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData,BOOL& bHandled)
{
	pGetItemCountData->cItems = m_ListData.nItems;
	bHandled = TRUE;
	return S_OK;
}

HRESULT CXuiControl4JComboBox::OnGetSourceDataImage(XUIMessageGetSourceImage *pGetSourceImageData,BOOL& bHandled)
{
	return S_OK;

	//if( ( 0 == pGetSourceImageData->iData ) && ( pGetSourceImageData->bItemData ) ) 
	//{
	//	// Check for a brush

	//	if(m_ListData.pItems[pGetSourceImageData->iItem].hXuiBrush!=NULL)
	//	{
	//		pGetSourceImageData->hBrush=m_ListData.pItems[pGetSourceImageData->iItem].hXuiBrush;
	//	}
	//	else
	//	{
	//		pGetSourceImageData->szPath = 
	//			m_ListData.pItems[pGetSourceImageData->iItem].pwszImage;
	//	}
	//	bHandled = TRUE;
	//}
	//return S_OK;
}

HRESULT CXuiControl4JComboBox::OnGetItemEnable(XUIMessageGetItemEnable *pGetItemEnableData,BOOL& bHandled)
{
	if(m_ListData.pItems!=NULL && m_ListData.nItems!=0)
	{
		pGetItemEnableData->bEnabled = 
			m_ListData.pItems[pGetItemEnableData->iItem].fEnabled;
	}
	bHandled = TRUE;
	return S_OK;
}

//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CXuiControl4JComboBox::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled)
{
	// This assumes all buttons can only be pressed with the A button
	CScene_Base::HandleKeyPress(pNotifyPressData->UserIndex, VK_PAD_A);
	
	if(hObjPressed==GetValueObject())
	{
		XuiElementSetShow(GetListObject(),TRUE);
		XuiElementSetFocus(GetListObject());
		rfHandled = TRUE;
	}
	return S_OK;
}