This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine::WidgetComboBox Class

Header:#include <UnigineWidgets.h>
Inherits:Widget

This class creates a combo box.

Example

The following code illustrates how to create a combobox widget and set its parameters.

Source code (UnigineScript)
#include <UnigineWidgets.h>
using namespace Unigine;

/* .. */

// event handler function
int onComboBoxChanged()
{
	/* .. */
	
	return 1;
}

/* .. */

// getting a pointer to the system GUI
GuiPtr gui = Gui::get();

// creating a combobox widget
WidgetComboBoxPtr widget_combo = WidgetComboBox::create(gui);

// adding items to the combobox
widget_combo->addItem("----ALL-----");
widget_combo->addItem("Item 1");
widget_combo->addItem("Item 2");
widget_combo->addItem("Item 3");

// setting a tooltip
widget_combo->setToolTip("This is a combo box");

// rearranging combobox size
widget_combo->arrange();

// setting combobox position
widget_combo->setPosition(10, 10);

// setting the first item as currently selected one
widget_combo->setCurrentItem(0);

// setting onComboBoxChanged function to handle CHANGED event
widget_combo->setCallback0(Gui::CHANGED, MakeCallback(onComboBoxChanged));

// adding created combobox widget to the system GUI
gui->addChild(widget_combo->getWidget(), Gui::ALIGN_OVERLAP | Gui::ALIGN_FIXED);

WidgetComboBox Class

Members


static WidgetComboBoxPtr create(const Ptr<Gui> & gui)

Constructor. Creates an empty combobox.

Arguments

  • const Ptr<Gui> & gui - GUI, to which the new combobox will belong.

Ptr<WidgetComboBox> cast(const Ptr<Widget> & widget)

Casts a WidgetComboBox out of the Widget instance.

Arguments

  • const Ptr<Widget> & widget - Pointer to Widget.

Return value

Pointer to WidgetComboBox.

void setCurrentItem(int item)

Sets a given item as selected.

Arguments

  • int item - Item number.

int getCurrentItem()

Returns the currently selected item.

Return value

Item number.

const char * getCurrentItemData()

Returns the data of the currently selected item. The data can be used as a text identifier of the item (instead of using the number of the item).

Return value

Item data.

const char * getCurrentItemText()

Returns a text value of the currently selected item.

Return value

Item text.

void setImage(const Ptr<Image> & image)

Sets an image with mini-icons to be used with items. The image is a vertical strip of square icons.

Arguments

  • const Ptr<Image> & image - Image to set.

void getImage(const Ptr<Image> & image)

Returns the image with mini-icons, which are used with the combobox items.

Arguments

  • const Ptr<Image> & image

void setItemData(int item, const char * str)

Sets the data for a given item. The data can be used as a text identifier of the item (instead of using the number of the item).

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • const char * str - Item data to set.

const char * getItemData(int item)

Returns the data of a given item. The data can be used as a text identifier of the item (instead of using the number of the item).

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Item data.

void setItemText(int item, const char * str)

Sets a text for a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • const char * str - Item text.

const char * getItemText(int item)

Returns the text of a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Item text.

void setItemTexture(int item, int texture)

Sets an icon for a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • int texture - Zero-based ID of the icon.

int getItemTexture(int item)

Returns the icon of a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Zero-based ID of the icon.

int getNumItems()

Returns the number of items in the combobox.

Return value

Number of items.

void setTexture(const char * texture)

Sets a texture with mini-icons to be used with items. The texture is a vertical strip of square icons.

Arguments

  • const char * texture - Path to a texture file.

const char * getTexture()

Returns path to the image with mini-icons, which are used with combobox items.

Return value

Path to the texture file.

int addItem(const char * str, int texture = -1)

Adds a new item with a given text and an icon.

Arguments

  • const char * str - Item text.
  • int texture - Zero-based ID of the icon.

Return value

Number of the added item.

void clear()

Removes all items from the combobox.

void removeItem(int num)

Removes a given item from the combobox.

Arguments

  • int num - Item number in range from 0 to the total number of items.

int type()

WidgetComboBox type.

Return value

WidgetComboBox type identifier.
Last update: 2018-08-10
Build: ()