//---------------------------------------------------------------------------- UIMenuItem *UIMenu::AddMainItem(const std::string &name, const std::string &title, const std::string &scriptFun) { UIMenuItem *item = new0 UIMenuItem(name, title, scriptFun); item->SetBeMainItem(true); //UIPicBox *itemPicBox = item->CreateAddBackgroundPicBox(); //itemPicBox->SetTexture("Data/engine/white.png"); //itemPicBox->LocalTransform.SetTranslateY(-0.5f); item->LocalTransform.SetTranslateY(-1.0f); item->SetSize(mMainItemSize); item->SetAnchorHor(Float2(0.0f, 0.0f)); item->SetAnchorVer(Float2(0.5f, 0.5f)); item->SetPivot(0.5f, 0.5f); item->SetAnchorParamHor(Float2(mMainItemSize.Width/2.0f + mMainItemSize.Width*GetNunMainItems(), 0.0f)); item->GetText()->SetFontWidthHeight(mItemFontSize, mItemFontSize); item->GetText()->SetFontScale(0.5f); item->GetText()->LocalTransform.SetTranslateY(-1.0f); mMainItemsMap[name] = item; mMainItemsVec.push_back(item); AttachChild(item); return item; }
UIMenuItem *UIMenu::addOption(String label, String _id, void *data) { UIMenuItem *newItem = new UIMenuItem(label, _id, data, menuWidth, menuItemHeight); items.push_back(newItem); dropDownBox->addChild(newItem); newItem->setPosition(0,paddingY+nextItemHeight); nextItemHeight += menuItemHeight; dropDownBox->resizeBox(menuWidth, nextItemHeight + (paddingY * 2.0)); return newItem; }
UIMenuItem *UIMenu::addDivider() { Number newItemHeight = menuItemHeight; UIMenuItem *newItem = new UIMenuDivider(menuWidth, newItemHeight); items.push_back(newItem); dropDownBox->addChild(newItem); newItem->setPosition(0, paddingY+nextItemHeight); nextItemHeight += newItemHeight; dropDownBox->resizeBox(menuWidth, nextItemHeight + (paddingY*2.0)); return newItem; }
static void _UIMenuButtonCBK (Widget widget,XtPointer *menuData,XmAnyCallbackStruct *callData) { UIMenuItem *menuBut; XtVaGetValues (widget,XmNuserData, &menuBut, NULL); switch (callData->event->xbutton.button) { default: menuBut->CallMenu (widget,menuData,callData); break; case 3: menuBut->CallHelp (); break; } }
//---------------------------------------------------------------------------- UIMenuItem *UIMenu::AddMainItem(const std::string &name, const std::string &title, const std::string &scriptFun) { UIMenuItem *item = new0 UIMenuItem(name, title, scriptFun); item->SetBeMainItem(true); item->LocalTransform.SetTranslateY(-1.0f); item->GetText()->GetText()->SetFontWidthHeight(mItemFontSize, mItemFontSize); item->GetText()->GetText()->SetFontScale(0.5f); item->GetText()->LocalTransform.SetTranslateY(-1.0f); mMainItemsMap[name] = item; mMainItemsVec.push_back(item); AttachChild(item); return item; }
UIMenuItem *UIMenu::addOption(String label, String _id, void *data) { UIMenuItem *newItem = new UIMenuItem(label, _id, data, menuWidth, menuItemHeight); items.push_back(newItem); dropDownBox->addChild(newItem); newItem->setPosition(0,paddingY+nextItemHeight); nextItemHeight += menuItemHeight; dropDownBox->resizeBox(menuWidth, nextItemHeight + (paddingY * 2.0)); Number difference = CoreServices::getInstance()->getCore()->getYRes() - (getPosition().y + dropDownBox->getHeight()); if(difference < 0) { setPositionY(getPosition().y + difference); } difference = CoreServices::getInstance()->getCore()->getXRes() - (getPosition().x + dropDownBox->getWidth()); if(difference < 0) { setPositionX(getPosition().x + difference); } return newItem; }