本文整理汇总了C++中ContextMenu类的典型用法代码示例。如果您正苦于以下问题:C++ ContextMenu类的具体用法?C++ ContextMenu怎么用?C++ ContextMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContextMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void CustomContextMenuProvider::populateContextMenuItems(const HTMLMenuElement& menu, ContextMenu& contextMenu)
{
HTMLElement* nextElement = Traversal<HTMLElement>::firstWithin(menu);
while (nextElement) {
if (isHTMLHRElement(*nextElement)) {
appendSeparator(contextMenu);
nextElement = Traversal<HTMLElement>::next(*nextElement, &menu);
} else if (isHTMLMenuElement(*nextElement)) {
ContextMenu subMenu;
String labelString = nextElement->fastGetAttribute(labelAttr);
if (labelString.isNull()) {
appendSeparator(contextMenu);
populateContextMenuItems(*toHTMLMenuElement(nextElement), contextMenu);
appendSeparator(contextMenu);
} else if (!labelString.isEmpty()) {
populateContextMenuItems(*toHTMLMenuElement(nextElement), subMenu);
contextMenu.appendItem(ContextMenuItem(SubmenuType, ContextMenuItemCustomTagNoAction, labelString, String(), &subMenu));
}
nextElement = Traversal<HTMLElement>::nextSibling(*nextElement);
} else if (isHTMLMenuItemElement(*nextElement)) {
appendMenuItem(toHTMLMenuItemElement(nextElement), contextMenu);
if (ContextMenuItemBaseCustomTag + m_menuItems.size() >= ContextMenuItemLastCustomTag)
break;
nextElement = Traversal<HTMLElement>::next(*nextElement, &menu);
} else {
nextElement = Traversal<HTMLElement>::next(*nextElement, &menu);
}
}
// Remove separators at the end of the menu and any submenus.
while (contextMenu.items().size() && contextMenu.items().last().type() == SeparatorType)
contextMenu.removeLastItem();
}
示例2: populateContextMenuItems
static bool populateContextMenuItems(v8::Isolate* isolate,
const v8::Local<v8::Array>& itemArray,
ContextMenu& menu) {
v8::Local<v8::Context> context = isolate->GetCurrentContext();
for (size_t i = 0; i < itemArray->Length(); ++i) {
v8::Local<v8::Object> item =
itemArray->Get(context, i).ToLocalChecked().As<v8::Object>();
v8::Local<v8::Value> type;
v8::Local<v8::Value> id;
v8::Local<v8::Value> label;
v8::Local<v8::Value> enabled;
v8::Local<v8::Value> checked;
v8::Local<v8::Value> subItems;
if (!item->Get(context, v8AtomicString(isolate, "type")).ToLocal(&type) ||
!item->Get(context, v8AtomicString(isolate, "id")).ToLocal(&id) ||
!item->Get(context, v8AtomicString(isolate, "label")).ToLocal(&label) ||
!item->Get(context, v8AtomicString(isolate, "enabled"))
.ToLocal(&enabled) ||
!item->Get(context, v8AtomicString(isolate, "checked"))
.ToLocal(&checked) ||
!item->Get(context, v8AtomicString(isolate, "subItems"))
.ToLocal(&subItems))
return false;
if (!type->IsString())
continue;
String typeString = toCoreStringWithNullCheck(type.As<v8::String>());
if (typeString == "separator") {
ContextMenuItem item(ContextMenuItem(
SeparatorType, ContextMenuItemCustomTagNoAction, String(), String()));
menu.appendItem(item);
} else if (typeString == "subMenu" && subItems->IsArray()) {
ContextMenu subMenu;
v8::Local<v8::Array> subItemsArray = v8::Local<v8::Array>::Cast(subItems);
if (!populateContextMenuItems(isolate, subItemsArray, subMenu))
return false;
TOSTRING_DEFAULT(V8StringResource<TreatNullAsNullString>, labelString,
label, false);
ContextMenuItem item(SubmenuType, ContextMenuItemCustomTagNoAction,
labelString, String(), &subMenu);
menu.appendItem(item);
} else {
int32_t int32Id;
if (!v8Call(id->Int32Value(context), int32Id))
return false;
ContextMenuAction typedId = static_cast<ContextMenuAction>(
ContextMenuItemBaseCustomTag + int32Id);
TOSTRING_DEFAULT(V8StringResource<TreatNullAsNullString>, labelString,
label, false);
ContextMenuItem menuItem(
(typeString == "checkbox" ? CheckableActionType : ActionType),
typedId, labelString, String());
if (checked->IsBoolean())
menuItem.setChecked(checked.As<v8::Boolean>()->Value());
if (enabled->IsBoolean())
menuItem.setEnabled(enabled.As<v8::Boolean>()->Value());
menu.appendItem(menuItem);
}
}
return true;
}
示例3: populateContextMenuItems
static void populateContextMenuItems(ExecState* exec, JSArray* array, ContextMenu& menu)
{
for (size_t i = 0; i < array->length(); ++i) {
JSObject* item = asObject(array->getIndex(exec, i));
JSValue label = item->get(exec, Identifier::fromString(exec, "label"));
JSValue type = item->get(exec, Identifier::fromString(exec, "type"));
JSValue id = item->get(exec, Identifier::fromString(exec, "id"));
JSValue enabled = item->get(exec, Identifier::fromString(exec, "enabled"));
JSValue checked = item->get(exec, Identifier::fromString(exec, "checked"));
JSValue subItems = item->get(exec, Identifier::fromString(exec, "subItems"));
if (!type.isString())
continue;
String typeString = type.toWTFString(exec);
if (typeString == "separator") {
ContextMenuItem item(SeparatorType, ContextMenuItemTagNoAction, String());
menu.appendItem(item);
} else if (typeString == "subMenu" && subItems.inherits(JSArray::info())) {
ContextMenu subMenu;
JSArray* subItemsArray = asArray(subItems);
populateContextMenuItems(exec, subItemsArray, subMenu);
ContextMenuItem item(SubmenuType, ContextMenuItemTagNoAction, label.toWTFString(exec), &subMenu);
menu.appendItem(item);
} else {
ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + id.toInt32(exec));
ContextMenuItem menuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, label.toWTFString(exec));
if (!enabled.isUndefined())
menuItem.setEnabled(enabled.toBoolean(exec));
if (!checked.isUndefined())
menuItem.setChecked(checked.toBoolean(exec));
menu.appendItem(menuItem);
}
}
}
示例4: KURL
void CustomContextMenuProvider::appendMenuItem(HTMLMenuItemElement* menuItem,
ContextMenu& contextMenu) {
// Avoid menuitems with no label.
String labelString = menuItem->fastGetAttribute(labelAttr);
if (labelString.isEmpty())
return;
m_menuItems.append(menuItem);
bool enabled = !menuItem->fastHasAttribute(disabledAttr);
String icon = menuItem->fastGetAttribute(iconAttr);
if (!icon.isEmpty()) {
// To obtain the absolute URL of the icon when the attribute's value is not
// the empty string, the attribute's value must be resolved relative to the
// element.
KURL iconURL = KURL(menuItem->baseURI(), icon);
icon = iconURL.getString();
}
ContextMenuAction action = static_cast<ContextMenuAction>(
ContextMenuItemBaseCustomTag + m_menuItems.size() - 1);
if (equalIgnoringCase(menuItem->fastGetAttribute(typeAttr), "checkbox") ||
equalIgnoringCase(menuItem->fastGetAttribute(typeAttr), "radio"))
contextMenu.appendItem(
ContextMenuItem(CheckableActionType, action, labelString, icon, enabled,
menuItem->fastHasAttribute(checkedAttr)));
else
contextMenu.appendItem(
ContextMenuItem(ActionType, action, labelString, icon, enabled, false));
}
示例5: ContextMenuItem
//! Insert a menu item at specified position.
ContextMenuItem* ContextMenu::insertItem(unsigned int idx, const std::string& text, int commandId, bool enabled,
bool hasSubMenu, bool checked, bool autoChecking)
{
ContextMenuItem* newItem = new ContextMenuItem( this, text );
newItem->setEnabled( enabled );
newItem->setSubElement( true );
newItem->setChecked( checked );
newItem->setAutoChecking( autoChecking );
newItem->setText( text );
newItem->setFlag( ContextMenuItem::drawSubmenuSprite );
newItem->setIsSeparator( text.empty() );
newItem->setCommandId( commandId );
sendChildToBack( newItem );
if (hasSubMenu)
{
ContextMenu* subMenu = newItem->addSubMenu( commandId );
subMenu->setVisible( false );
}
if ( idx < _d->items.size() )
{
_d->items.insert( _d->items.begin() + idx, newItem );
}
else
{
_d->items.push_back( newItem );
}
return newItem;
}
示例6: MainWindow
MainWindow :: MainWindow(HINSTANCE instance, const wchar_t* caption, _Controller* controller, Model* model)
: SDIWindow(instance, caption), _windowList(10, IDM_WINDOW_WINDOWS), _recentFiles(10, IDM_FILE_FILES), _recentProjects(10, IDM_FILE_PROJECTS), _contextBrowser(model)
{
_controller = controller;
_model = model;
_tabTTHandle = NULL;
_controlCount = 14;
_controls = (_BaseControl**)malloc(_controlCount << 2);
_controls[0] = NULL;
_controls[CTRL_MENU] = new Menu(instance, IDR_IDE_ACCELERATORS, ::GetMenu(getHandle()));
_controls[CTRL_CONTEXTMENU] = new ContextMenu();
_windowList.assign((Menu*)_controls[CTRL_MENU]);
_recentFiles.assign((Menu*)_controls[CTRL_MENU]);
_recentProjects.assign((Menu*)_controls[CTRL_MENU]);
ContextMenu* contextMenu = (ContextMenu*)_controls[CTRL_CONTEXTMENU];
contextMenu->create(8, contextMenuInfo);
_controls[CTRL_STATUSBAR] = new StatusBar(this, 5, StatusBarWidths);
_controls[CTRL_TOOLBAR] = new ToolBar(this, 16, AppToolBarButtonNumber, AppToolBarButtons);
_controls[CTRL_EDITFRAME] = new EditFrame(this, true, contextMenu, model);
_controls[CTRL_TABBAR] = new TabBar(this, _model->tabWithAboveScore);
_controls[CTRL_OUTPUT] = new Output((Control*)_controls[CTRL_TABBAR], this);
_controls[CTRL_MESSAGELIST] = new MessageLog((Control*)_controls[CTRL_TABBAR]);
_controls[CTRL_CALLLIST] = new CallStackLog((Control*)_controls[CTRL_TABBAR]);
_controls[CTRL_BSPLITTER] = new Splitter(this, (Control*)_controls[CTRL_TABBAR], false, IDM_LAYOUT_CHANGED);
_controls[CTRL_CONTEXTBOWSER] = new TreeView((Control*)_controls[CTRL_TABBAR], true);
_controls[CTRL_PROJECTVIEW] = new TreeView(this, false);
_controls[CTRL_HSPLITTER] = new Splitter(this, (Control*)_controls[CTRL_PROJECTVIEW], true, IDM_LAYOUT_CHANGED);
((Control*)_controls[CTRL_TABBAR])->_setHeight(120);
((Control*)_controls[CTRL_BSPLITTER])->_setConstraint(60, 100);
((Control*)_controls[CTRL_PROJECTVIEW])->_setWidth(200);
_statusBar = (StatusBar*)_controls[CTRL_STATUSBAR];
EditFrame* frame = (EditFrame*)_controls[CTRL_EDITFRAME];
TextView* textView = new TextView(frame, 5, 28, 400, 400);
frame->populate(textView);
textView->setReceptor(this);
_contextBrowser.assign((Control*)_controls[CTRL_CONTEXTBOWSER]);
setLeft(CTRL_HSPLITTER);
setTop(CTRL_TOOLBAR);
setClient(CTRL_EDITFRAME);
setBottom(CTRL_BSPLITTER);
frame->init(model);
showControls(CTRL_STATUSBAR, CTRL_EDITFRAME);
showControls(CTRL_PROJECTVIEW, CTRL_PROJECTVIEW);
}
示例7: polishSessionExplorerContextMenu
void TimelineWidget::polishSessionExplorerContextMenu(Subject &subject, const std::string &signal, const boost::any &v)
{
SessionExplorer &ses = dynamic_cast<SessionExplorer&>(subject);
if(ses.getItemViewType() == SessionExplorer::ANIMATION_ITEMS)
{
ContextMenu *pMenu = boost::any_cast<ContextMenu*>(v);
VERIFYNRV(pMenu);
pMenu->addAction(mpNewAnimationAction, "TIMELINEWIDGET_NEW_ANIMATION_ACTION");
}
}
示例8: contextMenuEvent
void SceneGraphExplorerPanel::contextMenuEvent (QContextMenuEvent* event) {
QPoint globalPoint = event->globalPos();
QListWidgetItem* selectedItem = m_listWidget->itemAt(m_listWidget->mapFromGlobal(globalPoint));
GUIStateNode_ptr selectedGUIStateNode = m_guiStateNodesByItem[selectedItem];
if(selectedGUIStateNode != NULL && selectedGUIStateNode->getContextMenu() != NULL ) {
ContextMenu* contextMenu = selectedGUIStateNode->getContextMenu();
QAction* action = contextMenu->exec(globalPoint);
}
}
示例9: String
void CustomContextMenuProvider::appendSeparator(ContextMenu& contextMenu)
{
// Avoid separators at the start of any menu and submenu.
if (!contextMenu.items().size())
return;
// Collapse all sequences of two or more adjacent separators in the menu or
// any submenus to a single separator.
ContextMenuItem lastItem = contextMenu.items().last();
if (lastItem.type() == SeparatorType)
return;
contextMenu.appendItem(ContextMenuItem(SeparatorType, ContextMenuItemCustomTagNoAction, String(), String()));
}
示例10: exceptionState
void V8DevToolsHost::showContextMenuAtPointMethodCustom(
const v8::FunctionCallbackInfo<v8::Value>& info) {
if (info.Length() < 3)
return;
ExceptionState exceptionState(ExceptionState::ExecutionContext,
"showContextMenuAtPoint", "DevToolsHost",
info.Holder(), info.GetIsolate());
v8::Isolate* isolate = info.GetIsolate();
float x = toRestrictedFloat(isolate, info[0], exceptionState);
if (exceptionState.hadException())
return;
float y = toRestrictedFloat(isolate, info[1], exceptionState);
if (exceptionState.hadException())
return;
v8::Local<v8::Value> array = v8::Local<v8::Value>::Cast(info[2]);
if (!array->IsArray())
return;
ContextMenu menu;
if (!populateContextMenuItems(isolate, v8::Local<v8::Array>::Cast(array),
menu))
return;
Document* document = nullptr;
if (info.Length() >= 4 && v8::Local<v8::Value>::Cast(info[3])->IsObject()) {
v8::Local<v8::Object> documentWrapper =
v8::Local<v8::Object>::Cast(info[3]);
if (!V8HTMLDocument::wrapperTypeInfo.equals(
toWrapperTypeInfo(documentWrapper)))
return;
document = V8HTMLDocument::toImpl(documentWrapper);
} else {
v8::Local<v8::Object> windowWrapper =
V8Window::findInstanceInPrototypeChain(
isolate->GetEnteredContext()->Global(), isolate);
if (windowWrapper.IsEmpty())
return;
DOMWindow* window = V8Window::toImpl(windowWrapper);
document = window ? toLocalDOMWindow(window)->document() : nullptr;
}
if (!document || !document->frame())
return;
DevToolsHost* devtoolsHost = V8DevToolsHost::toImpl(info.Holder());
Vector<ContextMenuItem> items = menu.items();
devtoolsHost->showContextMenu(document->frame(), x, y, items);
}
示例11: ENABLE
JSValue JSInspectorFrontendHost::showContextMenu(ExecState& state)
{
#if ENABLE(CONTEXT_MENUS)
if (state.argumentCount() < 2)
return jsUndefined();
Event* event = JSEvent::toWrapped(state.argument(0));
JSArray* array = asArray(state.argument(1));
ContextMenu menu;
populateContextMenuItems(&state, array, menu);
wrapped().showContextMenu(event, menu.items());
#else
UNUSED_PARAM(state);
#endif
return jsUndefined();
}
示例12: updateContextMenu
void RangeProfilePlotManager::updateContextMenu(Subject& subject, const std::string& signal, const boost::any& value)
{
ContextMenu* pMenu = boost::any_cast<ContextMenu*>(value);
if (pMenu == NULL)
{
return;
}
QAction* pDiffAction = new QAction("Calculate Difference", pMenu->getActionParent());
VERIFYNRV(mpView);
int numSelectedObjects = mpView->getNumSelectedObjects(true);
if (numSelectedObjects != 2)
{
pDiffAction->setEnabled(false);
}
else
{
std::list<PlotObject*> objects;
mpView->getSelectedObjects(objects, true);
for (std::list<PlotObject*>::const_iterator obj = objects.begin(); obj != objects.end(); ++obj)
{
std::string name;
(*obj)->getObjectName(name);
if (name == "Difference")
{
pDiffAction->setEnabled(false);
break;
}
}
}
VERIFYNR(connect(pDiffAction, SIGNAL(triggered()), this, SLOT(calculateDifferences())));
pMenu->addActionBefore(pDiffAction, "SPECTRAL_RANGEPROFILEPLOT_DIFFERENCE_ACTION", APP_PLOTWIDGET_PRINT_ACTION);
QAction* pDelAction = new QAction(
(numSelectedObjects > 1) ? "Delete Plots" : "Delete Plot", pMenu->getActionParent());
if (mpView != NULL && numSelectedObjects == 0)
{
pDelAction->setEnabled(false);
}
VERIFYNR(connect(pDelAction, SIGNAL(triggered()), this, SLOT(deleteSelectedPlots())));
pMenu->addActionAfter(pDelAction, "SPECTRAL_RANGEPROFILEPLOT_DELETE_ACTION",
"SPECTRAL_RANGEPROFILEPLOT_DIFFERENCE_ACTION");
}
示例13: populateContextMenuItems
static bool populateContextMenuItems(v8::Local<v8::Array>& itemArray, ContextMenu& menu, v8::Isolate* isolate)
{
for (size_t i = 0; i < itemArray->Length(); ++i) {
v8::Local<v8::Object> item = v8::Local<v8::Object>::Cast(itemArray->Get(i));
v8::Local<v8::Value> type = item->Get(v8AtomicString(isolate, "type"));
v8::Local<v8::Value> id = item->Get(v8AtomicString(isolate, "id"));
v8::Local<v8::Value> label = item->Get(v8AtomicString(isolate, "label"));
v8::Local<v8::Value> enabled = item->Get(v8AtomicString(isolate, "enabled"));
v8::Local<v8::Value> checked = item->Get(v8AtomicString(isolate, "checked"));
v8::Local<v8::Value> subItems = item->Get(v8AtomicString(isolate, "subItems"));
if (!type->IsString())
continue;
String typeString = toCoreStringWithNullCheck(type.As<v8::String>());
if (typeString == "separator") {
ContextMenuItem item(ContextMenuItem(SeparatorType,
ContextMenuItemCustomTagNoAction,
String()));
menu.appendItem(item);
} else if (typeString == "subMenu" && subItems->IsArray()) {
ContextMenu subMenu;
v8::Local<v8::Array> subItemsArray = v8::Local<v8::Array>::Cast(subItems);
if (!populateContextMenuItems(subItemsArray, subMenu, isolate))
return false;
V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<WithNullCheck>, labelString, label, false);
ContextMenuItem item(SubmenuType,
ContextMenuItemCustomTagNoAction,
labelString,
&subMenu);
menu.appendItem(item);
} else {
ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + id->ToInt32()->Value());
V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<WithNullCheck>, labelString, label, false);
ContextMenuItem menuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, labelString);
if (checked->IsBoolean())
menuItem.setChecked(checked->ToBoolean()->Value());
if (enabled->IsBoolean())
menuItem.setEnabled(enabled->ToBoolean()->Value());
menu.appendItem(menuItem);
}
}
return true;
}
示例14: USE
void WebContextMenu::menuItemsWithUserData(Vector<WebContextMenuItemData> &menuItems, RefPtr<API::Object>& userData) const
{
ContextMenuController& controller = m_page->corePage()->contextMenuController();
ContextMenu* menu = controller.contextMenu();
if (!menu)
return;
// Give the bundle client a chance to process the menu.
#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
const Vector<ContextMenuItem>& coreItems = menu->items();
#else
Vector<ContextMenuItem> coreItems = contextMenuItemVector(menu->platformDescription());
#endif
Vector<WebContextMenuItemData> proposedMenu = kitItems(coreItems, menu);
Vector<WebContextMenuItemData> newMenu;
RefPtr<InjectedBundleHitTestResult> hitTestResult = InjectedBundleHitTestResult::create(controller.hitTestResult());
if (m_page->injectedBundleContextMenuClient().getCustomMenuFromDefaultItems(m_page, hitTestResult.get(), proposedMenu, newMenu, userData))
proposedMenu = newMenu;
menuItems = proposedMenu;
}
示例15: ENABLE
JSValue JSInspectorFrontendHost::showContextMenu(ExecState& state)
{
#if ENABLE(CONTEXT_MENUS)
if (state.argumentCount() < 2)
return jsUndefined();
Event* event = JSEvent::toWrapped(state.argument(0));
JSArray* array = asArray(state.argument(1));
ContextMenu menu;
populateContextMenuItems(&state, array, menu);
#if !USE(CROSS_PLATFORM_CONTEXT_MENUS)
Vector<ContextMenuItem> items = contextMenuItemVector(menu.platformDescription());
#else
Vector<ContextMenuItem> items = menu.items();
#endif
wrapped().showContextMenu(event, items);
#else
UNUSED_PARAM(state);
#endif
return jsUndefined();
}