本文整理汇总了C++中editor::Command::isEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ Command::isEnabled方法的具体用法?C++ Command::isEnabled怎么用?C++ Command::isEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类editor::Command
的用法示例。
在下文中一共展示了Command::isEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkOrEnableIfNeeded
void ContextMenu::checkOrEnableIfNeeded(ContextMenuItem& item) const
{
if (item.type() == SeparatorType)
return;
Frame* frame = m_hitTestResult.innerNonSharedNode()->document()->frame();
if (!frame)
return;
bool shouldEnable = true;
bool shouldCheck = false;
switch (item.action()) {
case ContextMenuItemTagCheckSpelling:
shouldEnable = frame->editor()->canEdit();
break;
case ContextMenuItemTagDefaultDirection:
shouldCheck = false;
shouldEnable = false;
break;
case ContextMenuItemTagLeftToRight:
case ContextMenuItemTagRightToLeft: {
ExceptionCode ec = 0;
RefPtr<CSSStyleDeclaration> style = frame->document()->createCSSStyleDeclaration();
String direction = item.action() == ContextMenuItemTagLeftToRight ? "ltr" : "rtl";
style->setProperty(CSSPropertyDirection, direction, false, ec);
shouldCheck = frame->editor()->selectionHasStyle(style.get()) != FalseTriState;
shouldEnable = true;
break;
}
case ContextMenuItemTagTextDirectionDefault: {
Editor::Command command = frame->editor()->command("MakeTextWritingDirectionNatural");
shouldCheck = command.state() == TrueTriState;
shouldEnable = command.isEnabled();
break;
}
case ContextMenuItemTagTextDirectionLeftToRight: {
Editor::Command command = frame->editor()->command("MakeTextWritingDirectionLeftToRight");
shouldCheck = command.state() == TrueTriState;
shouldEnable = command.isEnabled();
break;
}
case ContextMenuItemTagTextDirectionRightToLeft: {
Editor::Command command = frame->editor()->command("MakeTextWritingDirectionRightToLeft");
shouldCheck = command.state() == TrueTriState;
shouldEnable = command.isEnabled();
break;
}
case ContextMenuItemTagCopy:
shouldEnable = frame->editor()->canDHTMLCopy() || frame->editor()->canCopy();
break;
case ContextMenuItemTagCut:
shouldEnable = frame->editor()->canDHTMLCut() || frame->editor()->canCut();
break;
case ContextMenuItemTagIgnoreSpelling:
case ContextMenuItemTagLearnSpelling:
shouldEnable = frame->selection()->isRange();
break;
case ContextMenuItemTagPaste:
shouldEnable = frame->editor()->canDHTMLPaste() || frame->editor()->canPaste();
break;
#if PLATFORM(GTK)
case ContextMenuItemTagDelete:
shouldEnable = frame->editor()->canDelete();
break;
case ContextMenuItemTagSelectAll:
case ContextMenuItemTagInputMethods:
case ContextMenuItemTagUnicode:
shouldEnable = true;
break;
#endif
case ContextMenuItemTagUnderline: {
ExceptionCode ec = 0;
RefPtr<CSSStyleDeclaration> style = frame->document()->createCSSStyleDeclaration();
style->setProperty(CSSPropertyWebkitTextDecorationsInEffect, "underline", false, ec);
shouldCheck = frame->editor()->selectionHasStyle(style.get()) != FalseTriState;
shouldEnable = frame->editor()->canEditRichly();
break;
}
case ContextMenuItemTagLookUpInDictionary:
shouldEnable = frame->selection()->isRange();
break;
case ContextMenuItemTagCheckGrammarWithSpelling:
#ifndef BUILDING_ON_TIGER
if (frame->editor()->isGrammarCheckingEnabled())
shouldCheck = true;
shouldEnable = true;
#endif
break;
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();
//.........这里部分代码省略.........