Example #1
0
	GWEN_CONTROL_INLINE( ComboBox, GUnit )
	{

		{
			Gwen::Controls::ComboBox* combo = new Gwen::Controls::ComboBox( this );
			combo->SetPos( 50, 50 );
			combo->SetWidth( 200 );


			combo->AddItem( L"Option One", "one" );
			combo->AddItem( L"Number Two", "two" );
			combo->AddItem( L"Door Three", "three" );
			combo->AddItem( L"Four Legs", "four" );
			combo->AddItem( L"Five Birds", "five" );

			combo->onSelection.Add( this, &ComboBox::OnComboSelect );
		}

		{
			// Empty..
			Gwen::Controls::ComboBox* combo = new Gwen::Controls::ComboBox( this );
			combo->SetPos( 50, 80 );
			combo->SetWidth( 200 );
		}

		{
			// Empty..
			Gwen::Controls::ComboBox* combo = new Gwen::Controls::ComboBox( this );
			combo->SetPos( 50, 110 );
			combo->SetWidth( 200 );

			for (int i=0; i<500; i++ )
				combo->AddItem( L"Lots Of Options" );
		}

	}
void	GwenUserInterface::registerComboBox(int comboboxId, int numItems, const char** items)
{
	Gwen::Controls::ComboBox* combobox = new Gwen::Controls::ComboBox(m_data->m_demoPage->GetPage());
	MyComboBoxHander* handler = new MyComboBoxHander(m_data, comboboxId);
	m_data->m_handlers.push_back(handler);
	
	combobox->onSelection.Add(handler,&MyComboBoxHander::onSelect);
	int ypos = m_data->m_handlers.size()*20;
	combobox->SetPos(10, ypos );
	combobox->SetWidth( 100 );
	//box->SetPos(120,130);
	for (int i=0;i<numItems;i++)
		combobox->AddItem(Gwen::Utility::StringToUnicode(items[i]));
	
	
}
void	GwenUserInterface::registerComboBox2(int comboboxId, int numItems, const char** items, int startItem)
{
	Gwen::Controls::ComboBox* combobox = new Gwen::Controls::ComboBox(m_data->m_demoPage->GetPage());
	MyComboBoxHander* handler = new MyComboBoxHander(m_data, comboboxId);
	m_data->m_handlers.push_back(handler);

	combobox->onSelection.Add(handler,&MyComboBoxHander::onSelect);
	int ypos = m_data->m_curYposition;
	combobox->SetPos(10, ypos );
	combobox->SetWidth( 100 );
	//box->SetPos(120,130);
	for (int i=0;i<numItems;i++)
	{
		Gwen::Controls::MenuItem* item = combobox->AddItem(Gwen::Utility::StringToUnicode(items[i]));
		if (i==startItem)
			combobox->OnItemSelected(item);
	}

	m_data->m_curYposition+=22;



}
void GwenParameterInterface::registerComboBox(ComboBoxParams& params)
{
	Gwen::Controls::ComboBox* combobox = new Gwen::Controls::ComboBox(m_gwenInternalData->m_demoPage->GetPage());
	m_paramInternalData->m_comboBoxes.push_back(combobox);
	MyComboBoxHander2* handler = new MyComboBoxHander2(m_gwenInternalData, params.m_comboboxId,params.m_callback, params.m_userPointer);
	m_gwenInternalData->m_handlers.push_back(handler);

	combobox->onSelection.Add(handler,&MyComboBoxHander2::onSelect);
	int ypos = m_gwenInternalData->m_curYposition;
	m_gwenInternalData->m_curYposition+=22;
	combobox->SetPos(5, ypos );
	combobox->SetWidth( 220 );
	//box->SetPos(120,130);
	for (int i=0;i<params.m_numItems;i++)
	{
		Gwen::Controls::MenuItem* item = combobox->AddItem(Gwen::Utility::StringToUnicode(params.m_items[i]));
		if (i==params.m_startItem)
			combobox->OnItemSelected(item);
	}

    
	

}