本文整理汇总了C++中ContextMenuItem类的典型用法代码示例。如果您正苦于以下问题:C++ ContextMenuItem类的具体用法?C++ ContextMenuItem怎么用?C++ ContextMenuItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContextMenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendItem
void ContextMenu::appendItem(ContextMenuItem& item)
{
if (!m_platformDescription)
return;
PlatformMenuItemDescription itemDescription = item.releasePlatformDescription();
wxItemKind menuKindWx = ( itemDescription.type == CheckableActionType ) ? wxITEM_CHECK : wxITEM_NORMAL;
wxString titleWx(itemDescription.title);
int idWx = wxID_ANY;
wxMenuItem * itemWx;
ItemActionMap::const_iterator end = s_itemActions.end();
for (ItemActionMap::const_iterator it = s_itemActions.begin(); it != end; ++it) {
if (it->second == itemDescription.action)
idWx = it->first;
}
if (itemDescription.subMenu) {
itemWx = new wxMenuItem(m_platformDescription, idWx, titleWx, wxEmptyString, wxITEM_NORMAL, itemDescription.subMenu);
} else if (itemDescription.type != SeparatorType) {
itemWx = new wxMenuItem(m_platformDescription, idWx, titleWx, wxT(""), menuKindWx);
} else {
itemWx = new wxMenuItem(m_platformDescription);
}
s_itemActions.add(itemWx->GetId(), item.action());
m_platformDescription->Append(itemWx);
m_platformDescription->Enable(itemWx->GetId(), itemDescription.enabled);
if (menuKindWx == wxITEM_CHECK)
m_platformDescription->Check(itemWx->GetId(), itemDescription.checked);
}
示例2: wstring
bool ContextMenuUtil::InitMenus(void)
{
_menuList = new vector<ContextMenuItem*>();
Json::Value jsonRoot;
jsonRoot[NATIVITY_COMMAND] = NATIVITY_GET_CONTEXT_MENU_LIST;
for (vector<wstring>::iterator it = _selectedFiles->begin(); it != _selectedFiles->end(); it++)
{
jsonRoot[NATIVITY_VALUE].append(StringUtil::toString(*it));
}
Json::FastWriter jsonWriter;
wstring* getMenuMessage = new wstring();
getMenuMessage->append(StringUtil::toWstring(jsonWriter.write(jsonRoot)));
wstring* getMenuReceived = new wstring();
if (_communicationSocket->SendMessageReceiveResponse(getMenuMessage->c_str(), getMenuReceived))
{
Json::Reader jsonReader;
Json::Value jsonResponse;
if (!jsonReader.parse(StringUtil::toString(*getMenuReceived), jsonResponse))
{
delete getMenuReceived;
delete getMenuMessage;
return false;
}
Json::Value jsonContextMenuItemsList = jsonResponse.get(NATIVITY_VALUE, "");
for (unsigned int i = 0; i < jsonContextMenuItemsList.size(); i++)
{
Json::Value jsonContextMenuItem = jsonContextMenuItemsList[i];
ContextMenuItem* contextMenuItem = new ContextMenuItem();
contextMenuItem->SetId(i);
if (!_ParseContextMenuItem(jsonContextMenuItem, contextMenuItem))
{
delete getMenuReceived;
delete getMenuMessage;
return false;
}
_menuList->push_back(contextMenuItem);
}
}
delete getMenuReceived;
delete getMenuMessage;
return true;;
}
示例3: insertItem
void ContextMenu::insertItem(unsigned position, ContextMenuItem& item)
{
checkOrEnableIfNeeded( item );
if( item.releasePlatformDescription() != NULL )
m_platformDescription->AddItem( item.releasePlatformDescription(), position );
}
示例4: 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;
}
示例5: PerformAction
bool ContextMenuUtil::PerformAction(int command)
{
ContextMenuItem* item;
if(!GetContextMenuItem(command, &item))
{
return false;
}
wstring* list = new wstring();
if(!ParserUtil::SerializeList(_selectedFiles, list, true))
{
return false;
}
wchar_t* buffer = new wchar_t(10);
_itow_s(item->GetId(), buffer, 10, 10);
wstring* idString = new wstring(buffer);
map<wstring*, wstring*>* message = new map<wstring*, wstring*>();
wstring* id = new wstring(ID);
wstring* files = new wstring(FILES);
message->insert(make_pair(id, idString));
message->insert(make_pair(files, list));
wstring* messageString = new wstring();
if(!ParserUtil::SerializeMessage(message, messageString, true))
{
return false;
}
NativityMessage* nativityMessage = new NativityMessage();
wstring* title = new wstring(PERFORM_ACTION);
nativityMessage->SetCommand(title);
nativityMessage->SetValue(messageString);
wstring* nativityMessageString = new wstring();
if(!ParserUtil::SerializeMessage(nativityMessage, nativityMessageString))
{
return false;
}
wstring* response = new wstring();
if(!_communicationSocket->SendMessageReceiveResponse(nativityMessageString->c_str(), response))
{
return false;
}
return true;
}
示例6: populateCustomMenuItems
void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaultMenu, WebContextMenuData* data)
{
Vector<WebMenuItemInfo> customItems;
for (size_t i = 0; i < defaultMenu->itemCount(); ++i) {
ContextMenuItem* inputItem = defaultMenu->itemAtIndex(i, defaultMenu->platformDescription());
if (inputItem->action() < ContextMenuItemBaseCustomTag || inputItem->action() > ContextMenuItemLastCustomTag)
continue;
WebMenuItemInfo outputItem;
outputItem.label = inputItem->title();
outputItem.enabled = inputItem->enabled();
outputItem.checked = inputItem->checked();
outputItem.action = static_cast<unsigned>(inputItem->action() - ContextMenuItemBaseCustomTag);
switch (inputItem->type()) {
case ActionType:
outputItem.type = WebMenuItemInfo::Option;
break;
case CheckableActionType:
outputItem.type = WebMenuItemInfo::CheckableOption;
break;
case SeparatorType:
outputItem.type = WebMenuItemInfo::Separator;
break;
case SubmenuType:
outputItem.type = WebMenuItemInfo::Group;
break;
}
customItems.append(outputItem);
}
WebVector<WebMenuItemInfo> outputItems(customItems.size());
for (size_t i = 0; i < customItems.size(); ++i)
outputItems[i] = customItems[i];
data->customItems.swap(outputItems);
}
示例7: 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()));
}
示例8: addItem
ContextMenuItem* MainMenu::addItem(const std::string& text, int commandId, bool enabled, bool hasSubMenu, bool checked, bool autoChecking)
{
ContextMenuItem* ret = ContextMenu::addItem( text, commandId, enabled, hasSubMenu, checked, autoChecking );
if( ret && ret->getSubMenu() )
{
//ret->getSubMenu()->setStyle( getStyle().getSubStyle( NES_SUBMENU ).getName() );
ret->setFlag( ContextMenuItem::drawSubmenuSprite, false );
ret->setBackgroundMode( Label::bgNone );
}
//refItem.alignEnabled = true;
//refItem.horizontal = EGUIA_CENTER;
//refItem.vertical = EGUIA_CENTER;
return ret;
}
示例9: createAndAppendSpellingAndGrammarSubMenu
static void createAndAppendSpellingAndGrammarSubMenu(const HitTestResult& result, ContextMenuItem& spellingAndGrammarMenuItem)
{
ContextMenu spellingAndGrammarMenu(result);
ContextMenuItem showSpellingPanel(ActionType, ContextMenuItemTagShowSpellingPanel,
contextMenuItemTagShowSpellingPanel(true));
ContextMenuItem checkSpelling(ActionType, ContextMenuItemTagCheckSpelling,
contextMenuItemTagCheckSpelling());
ContextMenuItem checkAsYouType(CheckableActionType, ContextMenuItemTagCheckSpellingWhileTyping,
contextMenuItemTagCheckSpellingWhileTyping());
ContextMenuItem grammarWithSpelling(CheckableActionType, ContextMenuItemTagCheckGrammarWithSpelling,
contextMenuItemTagCheckGrammarWithSpelling());
#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
ContextMenuItem correctSpelling(CheckableActionType, ContextMenuItemTagCorrectSpellingAutomatically,
contextMenuItemTagCorrectSpellingAutomatically());
#endif
spellingAndGrammarMenu.appendItem(showSpellingPanel);
spellingAndGrammarMenu.appendItem(checkSpelling);
#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
spellingAndGrammarMenu.appendItem(*separatorItem());
#endif
spellingAndGrammarMenu.appendItem(checkAsYouType);
spellingAndGrammarMenu.appendItem(grammarWithSpelling);
#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
spellingAndGrammarMenu.appendItem(correctSpelling);
#endif
spellingAndGrammarMenuItem.setSubMenu(&spellingAndGrammarMenu);
}
示例10: createAndAppendFontSubMenu
static void createAndAppendFontSubMenu(const HitTestResult& result, ContextMenuItem& fontMenuItem)
{
ContextMenu fontMenu(result);
#if PLATFORM(MAC)
ContextMenuItem showFonts(ActionType, ContextMenuItemTagShowFonts, contextMenuItemTagShowFonts());
#endif
ContextMenuItem bold(CheckableActionType, ContextMenuItemTagBold, contextMenuItemTagBold());
ContextMenuItem italic(CheckableActionType, ContextMenuItemTagItalic, contextMenuItemTagItalic());
ContextMenuItem underline(CheckableActionType, ContextMenuItemTagUnderline, contextMenuItemTagUnderline());
ContextMenuItem outline(ActionType, ContextMenuItemTagOutline, contextMenuItemTagOutline());
#if PLATFORM(MAC)
ContextMenuItem styles(ActionType, ContextMenuItemTagStyles, contextMenuItemTagStyles());
ContextMenuItem showColors(ActionType, ContextMenuItemTagShowColors, contextMenuItemTagShowColors());
#endif
#if PLATFORM(MAC)
fontMenu.appendItem(showFonts);
#endif
fontMenu.appendItem(bold);
fontMenu.appendItem(italic);
fontMenu.appendItem(underline);
fontMenu.appendItem(outline);
#if PLATFORM(MAC)
fontMenu.appendItem(styles);
fontMenu.appendItem(*separatorItem());
fontMenu.appendItem(showColors);
#endif
fontMenuItem.setSubMenu(&fontMenu);
}
示例11: 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();
}
示例12: appendItem
void ContextMenu::appendItem(ContextMenuItem& item)
{
checkOrEnableIfNeeded(item);
BMenuItem* menuItem = item.releasePlatformDescription();
if (menuItem)
m_platformDescription->AddItem(menuItem);
}
示例13: GetContextMenuAction
bool ContextMenuUtil::GetContextMenuAction(int action, ContextMenuAction** item)
{
ContextMenuItem* contextMenuItem;
if (GetContextMenuItem(action, &contextMenuItem))
{
ContextMenuAction* action = new ContextMenuAction();
action->SetUuid(contextMenuItem->GetUuid());
action->SetFiles(_selectedFiles);
item = &action;
return true;
}
return false;
}
示例14: insertItem
void ContextMenu::insertItem(unsigned int position, ContextMenuItem& item)
{
if (!m_platformDescription)
return;
checkOrEnableIfNeeded(item);
::InsertMenuItem(m_platformDescription, position, TRUE, item.releasePlatformDescription());
}
示例15: appendItem
void ContextMenu::appendItem(ContextMenuItem& item)
{
ASSERT(m_platformDescription);
GtkMenuItem* platformItem = item.releasePlatformDescription();
ASSERT(platformItem);
gtk_menu_shell_append(GTK_MENU_SHELL(m_platformDescription), GTK_WIDGET(platformItem));
gtk_widget_show(GTK_WIDGET(platformItem));
}