本文整理汇总了C++中ContextMenuItem::setEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ ContextMenuItem::setEnabled方法的具体用法?C++ ContextMenuItem::setEnabled怎么用?C++ ContextMenuItem::setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContextMenuItem
的用法示例。
在下文中一共展示了ContextMenuItem::setEnabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertItem
//! 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;
}
示例2: toWebCoreStringWithNullCheck
v8::Handle<v8::Value> V8InspectorFrontendHost::showContextMenuCallback(const v8::Arguments& args)
{
if (args.Length() < 2)
return v8::Undefined();
v8::Local<v8::Object> eventWrapper = v8::Local<v8::Object>::Cast(args[0]);
if (!V8MouseEvent::info.equals(V8DOMWrapper::domWrapperType(eventWrapper)))
return v8::Undefined();
Event* event = V8Event::toNative(eventWrapper);
if (!args[1]->IsArray())
return v8::Undefined();
v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(args[1]);
Vector<ContextMenuItem*> items;
for (size_t i = 0; i < array->Length(); ++i) {
v8::Local<v8::Object> item = v8::Local<v8::Object>::Cast(array->Get(v8::Integer::New(i)));
v8::Local<v8::Value> type = item->Get(v8::String::New("type"));
v8::Local<v8::Value> id = item->Get(v8::String::New("id"));
v8::Local<v8::Value> label = item->Get(v8::String::New("label"));
v8::Local<v8::Value> enabled = item->Get(v8::String::New("enabled"));
v8::Local<v8::Value> checked = item->Get(v8::String::New("checked"));
if (!type->IsString())
continue;
String typeString = toWebCoreStringWithNullCheck(type);
if (typeString == "separator") {
items.append(new ContextMenuItem(SeparatorType,
ContextMenuItemCustomTagNoAction,
String()));
} else {
ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + id->ToInt32()->Value());
ContextMenuItem* menuItem = new ContextMenuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, toWebCoreStringWithNullCheck(label));
if (checked->IsBoolean())
menuItem->setChecked(checked->ToBoolean()->Value());
if (enabled->IsBoolean())
menuItem->setEnabled(enabled->ToBoolean()->Value());
items.append(menuItem);
}
}
InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toNative(args.Holder());
frontendHost->showContextMenu(event, items);
return v8::Undefined();
}
示例3: showContextMenu
JSValue JSInspectorFrontendHost::showContextMenu(ExecState* exec)
{
if (exec->argumentCount() < 2)
return jsUndefined();
#if ENABLE(CONTEXT_MENUS)
Event* event = toEvent(exec->argument(0));
JSArray* array = asArray(exec->argument(1));
Vector<ContextMenuItem*> items;
for (size_t i = 0; i < array->length(); ++i) {
JSObject* item = asObject(array->getIndex(i));
JSValue label = item->get(exec, Identifier(exec, "label"));
JSValue type = item->get(exec, Identifier(exec, "type"));
JSValue id = item->get(exec, Identifier(exec, "id"));
JSValue enabled = item->get(exec, Identifier(exec, "enabled"));
JSValue checked = item->get(exec, Identifier(exec, "checked"));
if (!type.isString())
continue;
String typeString = ustringToString(type.toString(exec)->value(exec));
if (typeString == "separator") {
items.append(new ContextMenuItem(SeparatorType,
ContextMenuItemCustomTagNoAction,
String()));
} else {
ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + id.toInt32(exec));
ContextMenuItem* menuItem = new ContextMenuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, ustringToString(label.toString(exec)->value(exec)));
if (!enabled.isUndefined())
menuItem->setEnabled(enabled.toBoolean(exec));
if (!checked.isUndefined())
menuItem->setChecked(checked.toBoolean(exec));
items.append(menuItem);
}
}
impl()->showContextMenu(event, items);
#endif
return jsUndefined();
}
示例4: checkOrEnableIfNeeded
//.........这里部分代码省略.........
case ContextMenuItemTagItalic: {
ExceptionCode ec = 0;
RefPtr<CSSStyleDeclaration> style = frame->document()->createCSSStyleDeclaration();
style->setProperty(CSSPropertyFontStyle, "italic", false, ec);
shouldCheck = frame->editor()->selectionHasStyle(style.get()) != FalseTriState;
shouldEnable = frame->editor()->canEditRichly();
break;
}
case ContextMenuItemTagBold: {
ExceptionCode ec = 0;
RefPtr<CSSStyleDeclaration> style = frame->document()->createCSSStyleDeclaration();
style->setProperty(CSSPropertyFontWeight, "bold", false, ec);
shouldCheck = frame->editor()->selectionHasStyle(style.get()) != FalseTriState;
shouldEnable = frame->editor()->canEditRichly();
break;
}
case ContextMenuItemTagOutline:
shouldEnable = false;
break;
case ContextMenuItemTagShowSpellingPanel:
#ifndef BUILDING_ON_TIGER
if (frame->editor()->spellingPanelIsShowing())
item.setTitle(contextMenuItemTagShowSpellingPanel(false));
else
item.setTitle(contextMenuItemTagShowSpellingPanel(true));
#endif
shouldEnable = frame->editor()->canEdit();
break;
case ContextMenuItemTagNoGuessesFound:
shouldEnable = false;
break;
case ContextMenuItemTagCheckSpellingWhileTyping:
shouldCheck = frame->editor()->isContinuousSpellCheckingEnabled();
break;
#if PLATFORM(GTK)
case ContextMenuItemTagGoBack:
shouldEnable = frame->loader()->canGoBackOrForward(-1);
break;
case ContextMenuItemTagGoForward:
shouldEnable = frame->loader()->canGoBackOrForward(1);
break;
case ContextMenuItemTagStop:
shouldEnable = frame->loader()->documentLoader()->isLoadingInAPISense();
break;
case ContextMenuItemTagReload:
shouldEnable = !frame->loader()->documentLoader()->isLoadingInAPISense();
break;
case ContextMenuItemTagFontMenu:
shouldEnable = frame->editor()->canEditRichly();
break;
#else
case ContextMenuItemTagGoBack:
case ContextMenuItemTagGoForward:
case ContextMenuItemTagStop:
case ContextMenuItemTagReload:
case ContextMenuItemTagFontMenu:
#endif
case ContextMenuItemTagNoAction:
case ContextMenuItemTagOpenLinkInNewWindow:
case ContextMenuItemTagDownloadLinkToDisk:
case ContextMenuItemTagCopyLinkToClipboard:
case ContextMenuItemTagOpenImageInNewWindow:
case ContextMenuItemTagDownloadImageToDisk:
case ContextMenuItemTagCopyImageToClipboard:
case ContextMenuItemTagOpenFrameInNewWindow:
case ContextMenuItemTagSpellingGuess:
case ContextMenuItemTagOther:
case ContextMenuItemTagSearchInSpotlight:
case ContextMenuItemTagSearchWeb:
case ContextMenuItemTagOpenWithDefaultApplication:
case ContextMenuItemPDFActualSize:
case ContextMenuItemPDFZoomIn:
case ContextMenuItemPDFZoomOut:
case ContextMenuItemPDFAutoSize:
case ContextMenuItemPDFSinglePage:
case ContextMenuItemPDFFacingPages:
case ContextMenuItemPDFContinuous:
case ContextMenuItemPDFNextPage:
case ContextMenuItemPDFPreviousPage:
case ContextMenuItemTagOpenLink:
case ContextMenuItemTagIgnoreGrammar:
case ContextMenuItemTagSpellingMenu:
case ContextMenuItemTagShowFonts:
case ContextMenuItemTagStyles:
case ContextMenuItemTagShowColors:
case ContextMenuItemTagSpeechMenu:
case ContextMenuItemTagStartSpeaking:
case ContextMenuItemTagStopSpeaking:
case ContextMenuItemTagWritingDirectionMenu:
case ContextMenuItemTagTextDirectionMenu:
case ContextMenuItemTagPDFSinglePageScrolling:
case ContextMenuItemTagPDFFacingPagesScrolling:
case ContextMenuItemTagInspectElement:
case ContextMenuItemBaseApplicationTag:
break;
}
item.setChecked(shouldCheck);
item.setEnabled(shouldEnable);
}