本文整理汇总了C++中ListboxItem类的典型用法代码示例。如果您正苦于以下问题:C++ ListboxItem类的具体用法?C++ ListboxItem怎么用?C++ ListboxItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ListboxItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetClientSize
void Listbox::Layout()
{
int w, h, y = 0, index = 0;
GetClientSize(w, h);
w--;
std::vector<Control*>::iterator i;
/*for (i=childs.begin(); i!=childs.end(); i++)
{
ListboxItem *child = (ListboxItem*)(*i);
if ((int)child->minimumWidth > w)
w = child->minimumWidth;
}*/
for (i=childs.begin(); i!=childs.end(); i++)
{
ListboxItem *child = (ListboxItem*)(*i);
child->index = index++;
child->Place(0, y, w, y + child->itemHeight - 1);
y += child->itemHeight;
}
//if (!active)
// active = (ListboxItem*)*(childs.begin());
Scrollbox::Layout();
}
示例2: ListboxTextItem
void GameSettings::setOption(const ConfigOptionMap& configuration, const Ogre::String& option, Combobox* combobox)
{
ConfigOptionMap::const_iterator cfi = configuration.find(option);
if (cfi != configuration.end())
{
ConfigOption curOption = cfi->second;
int delta = curOption.possibleValues.size() - combobox->getItemCount();
if (delta > 0)
{
for (int i = 0; i < delta; ++i)
{
combobox->addItem(new ListboxTextItem(""));
}
}
else if (delta < 0)
{
for (int i = 0; i < -delta; ++i)
{
ListboxItem* item = combobox->getListboxItemFromIndex(combobox->getItemCount() - 1);
combobox->removeItem(item);
delete item;
}
}
for (unsigned int i = 0; i < combobox->getItemCount(); ++i)
{
ListboxItem* item = combobox->getListboxItemFromIndex(i);
item->setText(curOption.possibleValues[i]);
}
}
}
示例3: args
/*************************************************************************
Set whether the list should allow multiple selections or just a
single selection
*************************************************************************/
void Listbox::setMultiselectEnabled(bool setting)
{
// only react if the setting is changed
if (d_multiselect != setting)
{
d_multiselect = setting;
// if we change to single-select, deselect all except the first selected item.
WindowEventArgs args(this);
if ((!d_multiselect) && (getSelectedCount() > 1))
{
ListboxItem* itm = getFirstSelectedItem();
while ((itm = getNextSelected(itm)))
{
itm->setSelected(false);
}
onSelectionChanged(args);
}
onMultiselectModeChanged(args);
}
}
示例4: getItemAtPoint
/*************************************************************************
Handler for mouse movement
*************************************************************************/
void Listbox::onMouseMove(MouseEventArgs& e)
{
if (d_itemTooltips)
{
static ListboxItem* lastItem = 0;
ListboxItem* item = getItemAtPoint(e.position);
if (item != lastItem)
{
if (item)
{
setTooltipText(item->getTooltipText());
}
else
{
setTooltipText("");
}
lastItem = item;
}
// must check the result from getTooltip(), as the tooltip object could
// be 0 at any time for various reasons.
Tooltip* tooltip = getTooltip();
if (tooltip)
{
if (tooltip->getTargetWindow() != this)
tooltip->setTargetWindow(this);
else
tooltip->positionSelf();
}
}
Window::onMouseMove(e);
}
示例5: handleDSActivation
bool GUIManager::handleDSActivation ( CEGUI::EventArgs const & e )
{
CEGUI::Window *tab =
static_cast<CEGUI::WindowEventArgs const &>(e).window->getParent();
CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(tab->getChild(0));
ListboxItem *item = static_cast<ListboxItem *>(lb->getFirstSelectedItem());
if (item != NULL) {
DataManager *dm = static_cast<DataManager *>(item->getUserData());
CEGUI::Scrollbar *sb = static_cast<CEGUI::Scrollbar *>(tab->getChild(2));
std::vector<unsigned int> const & dims = dm->getDimensions();
unsigned int dim = dims[int(sb->getScrollPosition()*(dims.size()-1))];
float scrollPos = sb->getScrollPosition();
dm->activate(dim);
// Enable global scrollbar
CEGUI::WindowManager & wm = CEGUI::WindowManager::getSingleton();
sb = static_cast<CEGUI::Scrollbar *>(wm.getWindow("Sheet/DimensionSlider"));
sb->enable();
CEGUI::WindowEventArgs w(sb);
sb->fireEvent(CEGUI::Scrollbar::EventScrollPositionChanged, w);
// Set the global scrollbar to the right position.
sb->setScrollPosition(scrollPos);
CEGUI::Window *desc = wm.getWindow("Sheet/DimensionText");
desc->show();
}
// TODO handle else-error
return true;
}
示例6: droplist_SelectionAcceptedHandler
/*************************************************************************
Handler for selections made in the drop-list
*************************************************************************/
bool Combobox::droplist_SelectionAcceptedHandler(const EventArgs& e)
{
// copy the text from the selected item into the edit box
ListboxItem* item = ((ComboDropList*)((WindowEventArgs&)e).window)->getFirstSelectedItem();
if (item != NULL)
{
// Put the text from the list item into the edit box
d_editbox->setText(item->getText());
// select text if it's editable, and move carat to end
if (!isReadOnly())
{
d_editbox->setSelection(0, item->getText().length());
d_editbox->setCaratIndex(item->getText().length());
}
d_editbox->setCaratIndex(0);
// fire off an event of our own
WindowEventArgs args(this);
onListSelectionAccepted(args);
// finally, activate the edit box
d_editbox->activate();
}
return true;
}
示例7: cacheListboxBaseImagery
void FalagardListbox::render()
{
Listbox* lb = (Listbox*)d_window;
// render frame and stuff before we handle the items
cacheListboxBaseImagery();
//
// Render list items
//
Vector3 itemPos;
Size itemSize;
Rect itemClipper, itemRect;
float widest = lb->getWidestItemWidth();
// calculate position of area we have to render into
Rect itemsArea(getListRenderArea());
// set up some initial positional details for items
itemPos.d_x = itemsArea.d_left - lb->getHorzScrollbar()->getScrollPosition();
itemPos.d_y = itemsArea.d_top - lb->getVertScrollbar()->getScrollPosition();
itemPos.d_z = System::getSingleton().getRenderer()->getZLayer(3) - System::getSingleton().getRenderer()->getCurrentZ();
float alpha = lb->getEffectiveAlpha();
// loop through the items
size_t itemCount = lb->getItemCount();
for (size_t i = 0; i < itemCount; ++i)
{
ListboxItem* listItem = lb->getListboxItemFromIndex(i);
itemSize.d_height = listItem->getPixelSize().d_height;
// allow item to have full width of box if this is wider than items
itemSize.d_width = ceguimax(itemsArea.getWidth(), widest);
// calculate destination area for this item.
itemRect.d_left = itemPos.d_x;
itemRect.d_top = itemPos.d_y;
itemRect.setSize(itemSize);
itemClipper = itemRect.getIntersection(itemsArea);
// skip this item if totally clipped
if (itemClipper.getWidth() == 0)
{
itemPos.d_y += itemSize.d_height;
continue;
}
// draw this item
listItem->draw(lb->getRenderCache(), itemRect, itemPos.d_z, alpha, &itemClipper);
// update position ready for next item
itemPos.d_y += itemSize.d_height;
}
}
示例8: clearAllSelections_impl
/*************************************************************************
Handler for when mouse button is pressed
*************************************************************************/
void Listbox::onMouseButtonDown(MouseEventArgs& e)
{
// base class processing
Window::onMouseButtonDown(e);
if (e.button == LeftButton)
{
bool modified = false;
// clear old selections if no control key is pressed or if multi-select is off
if (!(e.sysKeys & Control) || !d_multiselect)
{
modified = clearAllSelections_impl();
}
Point localPos(screenToWindow(e.position));
if (getMetricsMode() == Relative)
{
localPos = relativeToAbsolute(localPos);
}
ListboxItem* item = getItemAtPoint(localPos);
if (item != NULL)
{
modified = true;
// select range or item, depending upon keys and last selected item
if (((e.sysKeys & Shift) && (d_lastSelected != NULL)) && d_multiselect)
{
selectRange(getItemIndex(item), getItemIndex(d_lastSelected));
}
else
{
item->setSelected(item->isSelected() ^ true);
}
// update last selected item
d_lastSelected = item->isSelected() ? item : NULL;
}
// fire event if needed
if (modified)
{
WindowEventArgs args(this);
onSelectionChanged(args);
}
e.handled = true;
}
}
示例9: BookmarkSelect
bool BookmarkSelect(const CEGUI::EventArgs& event)
{
using namespace CEGUI;
dbg(0,"1\n");
MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Bookmarks/Listbox"));
dbg(0,"2\n");
ListboxItem * item = mcl->getFirstSelectedItem();
if(item){
dbg(0,"item %s is at row %i\n",item->getText().c_str(),mcl->getItemRowIndex(item));
BookmarkGo(item->getText().c_str());
}
WindowManager::getSingleton().getWindow("BookmarkSelection")->hide();
}
示例10: getDropList
/*************************************************************************
Set the select state of an attached ListboxItem.
*************************************************************************/
void Combobox::setItemSelectState(size_t item_index, bool state)
{
ComboDropList* droplist = getDropList();
ListboxItem* item = (droplist->getItemCount() > item_index) ?
droplist->getListboxItemFromIndex(item_index) :
0;
bool was_selected = (item && item->isSelected());
droplist->setItemSelectState(item_index, state);
itemSelectChangeTextUpdate(item, state, was_selected);
}
示例11: createElements
void GameSettings::update()
{
Root* root = Ogre::Root::getSingletonPtr();
Ogre::RenderSystem* renderer = root->getRenderSystem();
#if OGRE_VERSION_MINOR == 7 || OGRE_VERSION_MINOR == 8
const RenderSystemList& renderers = root->getAvailableRenderers();
#else
const RenderSystemList renderers = *root->getAvailableRenderers();
#endif
createElements(mVideoRenderer, renderers.size());
for (unsigned int i = 0; i < renderers.size(); ++i)
{
Ogre::RenderSystem* cur = renderers[i];
ListboxItem* item = mVideoRenderer->getListboxItemFromIndex(i);
item->setText(cur->getName());
if (cur == renderer)
{
mVideoRenderer->setItemSelectState(item, true);
}
}
ConfigOptionMap config = renderer->getConfigOptions();
setOption(config, "Full Screen", mVideoFullscreen);
std::vector<RadioButton*> videoColorDepth;
videoColorDepth.push_back(mVideoColorDepth32);
videoColorDepth.push_back(mVideoColorDepth16);
setOption(config, "Colour Depth", videoColorDepth);
std::vector<RadioButton*> videoAntiAliasing;
videoAntiAliasing.push_back(mVideoFsaa0);
videoAntiAliasing.push_back(mVideoFsaa2);
videoAntiAliasing.push_back(mVideoFsaa4);
videoAntiAliasing.push_back(mVideoFsaa8);
setOption(config, "FSAA", videoAntiAliasing);
std::vector<RadioButton*> videoRttMode;
videoRttMode.push_back(mVideoRttModeFBO);
videoRttMode.push_back(mVideoRttModePBuffer);
videoRttMode.push_back(mVideoRttModeCopy);
setOption(config, "RTT Preferred Mode", videoRttMode);
setOption(config, "Video Mode", mVideoResolution);
}
示例12: handleDSDeactivation
bool GUIManager::handleDSDeactivation ( CEGUI::EventArgs const & e )
{
CEGUI::Window *tab =
static_cast<CEGUI::WindowEventArgs const &>(e).window->getParent();
CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(tab->getChild(0));
ListboxItem *item = static_cast<ListboxItem *>(lb->getFirstSelectedItem());
if (item != NULL) {
DataManager *dm = static_cast<DataManager *>(item->getUserData());
dm->deactivate();
// Enable global scrollbar
CEGUI::WindowManager & wm = CEGUI::WindowManager::getSingleton();
CEGUI::Scrollbar *sb = static_cast<CEGUI::Scrollbar *>(tab->getChild(2));
sb = static_cast<CEGUI::Scrollbar *>(wm.getWindow("Sheet/DimensionSlider"));
sb->disable();
CEGUI::Window *desc = wm.getWindow("Sheet/DimensionText");
desc->hide();
}
// TODO handle else-error
return true;
}
示例13: ListboxItem
void GUIManager::populateDatalists ( std::vector<DataManager *> const & list )
{
CEGUI::WindowManager & wm = CEGUI::WindowManager::getSingleton();
auto populate = [&]( std::string const & name,
DataManagerType const & type ) {
CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(wm.getWindow(
"Sheet/DatasetFrame/TabControl/"+name+"/Listbox"));
unsigned int i = 0;
for (DataManager *p : list) {
if (p != NULL && p->type == type) {
ListboxItem *item = new ListboxItem(p->name, i);
item->setUserData(p);
lb->addItem(item);
}
i++;
}
};
populate("HTab", DM_Height);
populate("PTab", DM_Pattern);
populate("CTab", DM_Color);
}
示例14: handleItemSelect
bool handleItemSelect(int r)
{
using namespace CEGUI;
MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("AdressSearch/Listbox"));
ListboxItem * item = mcl->getItemAtGridReference(MCLGridRef(r,0));
ListboxItem * itemid = mcl->getItemAtGridReference(MCLGridRef(r,1));
ListboxItem * item_assoc = mcl->getItemAtGridReference(MCLGridRef(r,2));
Window* country_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/CountryEditbox"));
Window* twn_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/TownEditbox"));
Window* street_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/StreetEditbox"));
if(SDL_dest.current_search==SRCH_COUNTRY){
country_edit->setText(item->getText());
twn_edit->activate();
SDL_dest.current_search=SRCH_TOWN;
WindowManager::getSingleton().getWindow("Navit/Keyboard/Input")->setText("");
} else if(SDL_dest.current_search==SRCH_TOWN){
twn_edit->setText(item->getText());
ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3));
ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4));
Window* Dest_x = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_x"));
Dest_x->setText(itemx->getText().c_str());
Window* Dest_y = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_y"));
Dest_y->setText(itemy->getText().c_str());
mcl->resetList();
SDL_dest.current_search=SRCH_STREET;
street_edit->activate();
WindowManager::getSingleton().getWindow("Navit/Keyboard/Input")->setText("");
} else if(SDL_dest.current_search==SRCH_STREET){
street_edit->setText(item->getText());
WindowManager::getSingleton().getWindow("Navit/Keyboard")->hide();
ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3));
ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4));
Window* Dest_x = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_x"));
Dest_x->setText(itemx->getText().c_str());
Window* Dest_y = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_y"));
Dest_y->setText(itemy->getText().c_str());
mcl->resetList();
SDL_dest.current_search=SRCH_STREET;
WindowManager::getSingleton().getWindow("Navit/Keyboard/Input")->setText("");
} else if (SDL_dest.current_search==SRCH_NUMBER){
struct coord pos;
ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3));
ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4));
pos.x=atoi(itemx->getText().c_str());
pos.y=atoi(itemy->getText().c_str());
route_to(pos.x,pos.y);
}
return true;
}
示例15: switch
bool Demo6Sample::handleSelectModeChanged(const CEGUI::EventArgs& e)
{
using namespace CEGUI;
// get access to list
MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Demo6/MainList"));
// get access to the combobox
Combobox* combo = static_cast<Combobox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/SelModeBox"));
// find the selected item in the combobox
ListboxItem* item = combo->findItemWithText(combo->getText(), 0);
// set new selection mode according to ID of selected ListboxItem
if (item)
{
switch (item->getID())
{
case 0:
mcl->setSelectionMode(MultiColumnList::RowSingle);
break;
case 1:
mcl->setSelectionMode(MultiColumnList::RowMultiple);
break;
case 2:
mcl->setSelectionMode(MultiColumnList::ColumnSingle);
break;
case 3:
mcl->setSelectionMode(MultiColumnList::ColumnMultiple);
break;
case 4:
mcl->setSelectionMode(MultiColumnList::CellSingle);
break;
case 5:
mcl->setSelectionMode(MultiColumnList::CellMultiple);
break;
case 6:
mcl->setSelectionMode(MultiColumnList::NominatedColumnSingle);
break;
case 7:
mcl->setSelectionMode(MultiColumnList::NominatedColumnMultiple);
break;
case 8:
mcl->setSelectionMode(MultiColumnList::NominatedRowSingle);
break;
case 9:
mcl->setSelectionMode(MultiColumnList::NominatedRowMultiple);
break;
default:
mcl->setSelectionMode(MultiColumnList::RowSingle);
break;
}
}
// event was handled.
return true;
}