Add missing methods to IMenuModel

This commit is contained in:
amaitland
2016-02-18 12:49:41 +10:00
parent ae3bc589e5
commit 40b36aec5e
4 changed files with 697 additions and 0 deletions
@@ -89,6 +89,352 @@ namespace CefSharp
return _menu->AddItem((int)commandId, StringUtils::ToNative(label));
}
virtual bool AddCheckItem(CefMenuCommand commandId, String^ label)
{
ThrowIfDisposed();
return _menu->AddCheckItem((int)commandId, StringUtils::ToNative(label));
}
virtual bool AddRadioItem(CefMenuCommand commandId, String^ label, int groupId)
{
ThrowIfDisposed();
return _menu->AddRadioItem((int)commandId, StringUtils::ToNative(label), groupId);
}
virtual IMenuModel^ AddSubMenu(CefMenuCommand commandId, String^ label)
{
ThrowIfDisposed();
auto subMenu =_menu->AddSubMenu((int)commandId, StringUtils::ToNative(label));
if (subMenu.get())
{
return gcnew CefMenuModelWrapper(subMenu);
}
return nullptr;
}
virtual bool InsertSeparatorAt(int index)
{
ThrowIfDisposed();
return _menu->InsertSeparatorAt(index);
}
virtual bool InsertItemAt(int index, CefMenuCommand commandId, String^ label)
{
ThrowIfDisposed();
return _menu->InsertItemAt(index, (int)commandId, StringUtils::ToNative(label));
}
virtual bool InsertCheckItemAt(int index, CefMenuCommand commandId, String^ label)
{
ThrowIfDisposed();
return _menu->InsertCheckItemAt(index, (int)commandId, StringUtils::ToNative(label));
}
virtual bool InsertRadioItemAt(int index, CefMenuCommand commandId, String^ label, int groupId)
{
ThrowIfDisposed();
return _menu->InsertRadioItemAt(index, (int)commandId, StringUtils::ToNative(label), groupId);
}
virtual IMenuModel^ InsertSubMenuAt(int index, CefMenuCommand commandId, String^ label)
{
ThrowIfDisposed();
auto subMenu = _menu->InsertSubMenuAt(index, (int)commandId, StringUtils::ToNative(label));
if (subMenu.get())
{
return gcnew CefMenuModelWrapper(subMenu);
}
return nullptr;
}
virtual bool RemoveAt(int index)
{
ThrowIfDisposed();
return _menu->RemoveAt(index);
}
virtual int GetIndexOf(CefMenuCommand commandId)
{
ThrowIfDisposed();
return _menu->GetIndexOf((int)commandId);
}
virtual bool SetCommandIdAt(int index, CefMenuCommand commandId)
{
ThrowIfDisposed();
return _menu->SetCommandIdAt(index, (int)commandId);
}
virtual String^ GetLabel(CefMenuCommand commandId)
{
ThrowIfDisposed();
return StringUtils::ToClr(_menu->GetLabel((int)commandId));
}
virtual bool SetLabel(CefMenuCommand commandId, String^ label)
{
ThrowIfDisposed();
return _menu->SetLabel((int)commandId, StringUtils::ToNative(label));
}
virtual bool SetLabelAt(int index, String^ label)
{
ThrowIfDisposed();
return _menu->SetLabelAt(index, StringUtils::ToNative(label));
}
virtual MenuItemType GetType(CefMenuCommand commandId)
{
ThrowIfDisposed();
return (CefSharp::MenuItemType)_menu->GetType((int)commandId);
}
virtual MenuItemType GetTypeAt(int index)
{
ThrowIfDisposed();
return (MenuItemType)_menu->GetTypeAt(index);
}
virtual int GetGroupId(CefMenuCommand commandId)
{
ThrowIfDisposed();
return _menu->GetGroupId((int)commandId);
}
virtual int GetGroupIdAt(int index)
{
ThrowIfDisposed();
return _menu->GetGroupIdAt(index);
}
virtual bool SetGroupId(CefMenuCommand commandId, int groupId)
{
ThrowIfDisposed();
return _menu->SetGroupId((int)commandId, groupId);
}
virtual bool SetGroupIdAt(int index, int groupId)
{
ThrowIfDisposed();
return _menu->SetGroupIdAt(index, groupId);
}
virtual IMenuModel^ GetSubMenu(CefMenuCommand commandId)
{
ThrowIfDisposed();
auto subMenu =_menu->GetSubMenu((int)commandId);
if (subMenu.get())
{
return gcnew CefMenuModelWrapper(subMenu);
}
return nullptr;
}
virtual IMenuModel^ GetSubMenuAt(int index)
{
ThrowIfDisposed();
auto subMenu = _menu->GetSubMenuAt(index);
if (subMenu.get())
{
return gcnew CefMenuModelWrapper(subMenu);
}
return nullptr;
}
virtual bool IsVisible(CefMenuCommand commandId)
{
ThrowIfDisposed();
return _menu->IsVisible((int)commandId);
}
virtual bool IsVisibleAt(int index)
{
ThrowIfDisposed();
return _menu->IsVisibleAt(index);
}
virtual bool SetVisible(CefMenuCommand commandId, bool visible)
{
ThrowIfDisposed();
return _menu->SetVisible((int)commandId, visible);
}
virtual bool SetVisibleAt(int index, bool visible)
{
ThrowIfDisposed();
return _menu->SetVisibleAt(index, visible);
}
virtual bool IsEnabled(CefMenuCommand commandId)
{
ThrowIfDisposed();
return _menu->IsEnabled((int)commandId);
}
virtual bool IsEnabledAt(int index)
{
ThrowIfDisposed();
return _menu->IsEnabledAt(index);
}
virtual bool SetEnabled(CefMenuCommand commandId, bool enabled)
{
ThrowIfDisposed();
return _menu->SetEnabled((int)commandId, enabled);
}
virtual bool SetEnabledAt(int index, bool enabled)
{
ThrowIfDisposed();
return _menu->SetEnabledAt(index, enabled);
}
virtual bool IsChecked(CefMenuCommand commandId)
{
ThrowIfDisposed();
return _menu->IsChecked((int)commandId);
}
virtual bool IsCheckedAt(int index)
{
ThrowIfDisposed();
return _menu->IsCheckedAt(index);
}
virtual bool SetChecked(CefMenuCommand commandId, bool isChecked)
{
ThrowIfDisposed();
return _menu->SetChecked((int)commandId, isChecked);
}
virtual bool SetCheckedAt(int index, bool isChecked)
{
ThrowIfDisposed();
return _menu->SetCheckedAt(index, isChecked);
}
virtual bool HasAccelerator(CefMenuCommand commandId)
{
ThrowIfDisposed();
return _menu->HasAccelerator((int)commandId);
}
virtual bool HasAcceleratorAt(int index)
{
ThrowIfDisposed();
return _menu->HasAcceleratorAt(index);
}
virtual bool SetAccelerator(CefMenuCommand commandId, int keyCode, bool shiftPressed, bool ctrlPressed, bool altPressed)
{
ThrowIfDisposed();
return _menu->SetAccelerator((int)commandId, keyCode, shiftPressed, ctrlPressed, altPressed);
}
virtual bool SetAcceleratorAt(int index, int keyCode, bool shiftPressed, bool ctrlPressed, bool altPressed)
{
ThrowIfDisposed();
return _menu->SetAcceleratorAt(index, keyCode, shiftPressed, ctrlPressed, altPressed);
}
virtual bool RemoveAccelerator(CefMenuCommand commandId)
{
ThrowIfDisposed();
return _menu->RemoveAccelerator((int)commandId);
}
virtual bool RemoveAcceleratorAt(int index)
{
ThrowIfDisposed();
return _menu->RemoveAcceleratorAt(index);
}
virtual bool GetAccelerator(CefMenuCommand commandId, int% keyCode, bool% shiftPressed, bool% ctrlPressed, bool% altPressed)
{
ThrowIfDisposed();
int key;
bool shift;
bool ctrl;
bool alt;
auto result = _menu->GetAccelerator((int)commandId, key, shift, ctrl, alt);
keyCode = key;
shiftPressed = shift;
ctrlPressed = ctrl;
altPressed = alt;
return result;
}
virtual bool GetAcceleratorAt(int index, int% keyCode, bool% shiftPressed, bool% ctrlPressed, bool% altPressed)
{
ThrowIfDisposed();
int key;
bool shift;
bool ctrl;
bool alt;
auto result = _menu->GetAcceleratorAt(index, key, shift, ctrl, alt);
keyCode = key;
shiftPressed = shift;
ctrlPressed = ctrl;
altPressed = alt;
return result;
}
};
}
}
+1
View File
@@ -90,6 +90,7 @@
<Compile Include="IRenderProcessMessageHandler.cs" />
<Compile Include="IRequestContext.cs" />
<Compile Include="IRunContextMenuCallback.cs" />
<Compile Include="MenuItemType.cs" />
<Compile Include="PdfPrintSettings.cs" />
<Compile Include="ICookieManager.cs" />
<Compile Include="ILoadHandler.cs" />
+334
View File
@@ -52,5 +52,339 @@ namespace CefSharp
/// </summary>
/// <returns>Returns true on success.</returns>
bool AddSeparator();
/// <summary>
/// Add a check item to the menu.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <param name="label">the label of the item</param>
/// <returns>Returns true on success.</returns>
bool AddCheckItem(CefMenuCommand commandId, string label);
/// <summary>
/// Add a radio item to the menu. Only a single item with the specified groupId can be checked at a time.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <param name="label">the label of the item</param>
/// <returns>Returns true on success.</returns>
bool AddRadioItem(CefMenuCommand commandId, string label, int groupId);
/// <summary>
/// Add a sub-menu to the menu. The new sub-menu is returned.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <param name="label">the label of the item</param>
/// <returns>Returns the newly created <see cref="IMenuModel"/>.</returns>
IMenuModel AddSubMenu(CefMenuCommand commandId, string label);
/// <summary>
/// Insert a separator in the menu at the specified index.
/// </summary>
/// <param name="index">index</param>
/// <returns>Returns true on success.</returns>
bool InsertSeparatorAt(int index);
/// <summary>
/// Insert an item in the menu at the specified index.
/// </summary>
/// <param name="index">index</param>
/// <param name="commandId">the command Id</param>
/// <param name="label">the label of the item</param>
/// <returns>Returns true on success.</returns>
bool InsertItemAt(int index, CefMenuCommand commandId, string label);
/// <summary>
/// Insert a check item in the menu at the specified index.
/// </summary>
/// <param name="index">index</param>
/// <param name="commandId">the command Id</param>
/// <param name="label">the label of the item</param>
/// <returns>Returns true on success.</returns>
bool InsertCheckItemAt(int index, CefMenuCommand commandId, string label);
/// <summary>
/// Insert a radio item in the menu at the specified index.
/// Only a single item with the specified groupId can be checked at a time.
/// </summary>
/// <param name="index">index</param>
/// <param name="commandId">the command Id</param>
/// <param name="label">the label of the item</param>
/// <param name="groupId">the group id</param>
/// <returns>Returns true on success.</returns>
bool InsertRadioItemAt(int index, CefMenuCommand commandId, string label, int groupId);
/// <summary>
/// Insert a sub-menu in the menu at the specified index.
/// </summary>
/// <param name="index">index</param>
/// <param name="commandId">the command Id</param>
/// <param name="label">the label of the item</param>
/// <returns>Returns the newly created <see cref="IMenuModel"/>.</returns>
IMenuModel InsertSubMenuAt(int index, CefMenuCommand commandId, string label);
/// <summary>
/// Removes the item at the specified index.
/// </summary>
/// <param name="index">index</param>
/// <returns>Returns true on success.</returns>
bool RemoveAt(int index);
/// <summary>
/// Returns the index associated with the specified commandId or -1 if not found due to the command id not existing in the menu.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <returns>Returns the index associated with the specified commandId or -1 if not found due to the command id not existing in the menu.</returns>
int GetIndexOf(CefMenuCommand commandId);
/// <summary>
/// Sets the command id at the specified index.
/// </summary>
/// <param name="index">index</param>
/// <param name="commandId">the command Id</param>
/// <returns>Returns true on success.</returns>
bool SetCommandIdAt(int index, CefMenuCommand commandId);
/// <summary>
/// Returns the label for the specified commandId or empty if not found.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <returns>Returns the label for the specified commandId or empty if not found.</returns>
string GetLabel(CefMenuCommand commandId);
/// <summary>
/// Sets the label for the specified commandId.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <param name="label">the label</param>
/// <returns>Returns true on success.</returns>
bool SetLabel(CefMenuCommand commandId, string label);
/// <summary>
/// Set the label at the specified index.
/// </summary>
/// <param name="index">index</param>
/// <param name="label">the label</param>
/// <returns>Returns true on success.</returns>
bool SetLabelAt(int index, string label);
/// <summary>
/// Returns the item type for the specified commandId.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <returns>Returns the item type for the specified commandId.</returns>
MenuItemType GetType(CefMenuCommand commandId);
/// <summary>
/// Returns the item type at the specified index.
/// </summary>
/// <param name="index">index</param>
/// <returns>Returns the item type at the specified index.</returns>
MenuItemType GetTypeAt(int index);
/// <summary>
/// Returns the group id for the specified commandId or -1 if invalid.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <returns>Returns the group id for the specified commandId or -1 if invalid.</returns>
int GetGroupId(CefMenuCommand commandId);
/// <summary>
/// Returns the group id at the specified index or -1 if invalid.
/// </summary>
/// <param name="index">index</param>
/// <returns>Returns the group id at the specified index or -1 if invalid.</returns>
int GetGroupIdAt(int index);
/// <summary>
/// Sets the group id for the specified commandId.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <param name="groupId">the group id</param>
/// <returns>Returns true on success.</returns>
bool SetGroupId(CefMenuCommand commandId, int groupId);
/// <summary>
/// Sets the group id at the specified index.
/// </summary>
/// <param name="index">index</param>
/// <param name="groupId">the group id</param>
/// <returns>Returns true on success.</returns>
bool SetGroupIdAt(int index, int groupId);
/// <summary>
/// Returns the <see cref="IMenuModel"/> for the specified commandId or null if invalid.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <returns>Returns the <see cref="IMenuModel"/> for the specified commandId or null if invalid.</returns>
IMenuModel GetSubMenu(CefMenuCommand commandId);
/// <summary>
/// Returns the <see cref="IMenuModel"/> at the specified index or empty if invalid.
/// </summary>
/// <param name="index">index</param>
/// <returns>Returns the <see cref="IMenuModel"/> for the specified commandId or null if invalid.</returns>
IMenuModel GetSubMenuAt(int index);
/// <summary>
/// Returns true if the specified commandId is visible.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <returns>Returns true if the specified commandId is visible.</returns>
bool IsVisible(CefMenuCommand commandId);
/// <summary>
/// Returns true if the specified index is visible.
/// </summary>
/// <param name="index">index</param>
/// <returns>Returns true if the specified index is visible.</returns>
bool IsVisibleAt(int index);
/// <summary>
/// Change the visibility of the specified commandId.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <param name="visible">visible</param>
/// <returns>Returns true on success.</returns>
bool SetVisible(CefMenuCommand commandId, bool visible);
/// <summary>
/// Change the visibility at the specified index.
/// </summary>
/// <param name="index">index</param>
/// <param name="visible">visible</param>
/// <returns>Returns true on success.</returns>
bool SetVisibleAt(int index, bool visible);
/// <summary>
/// Returns true if the specified commandId is enabled.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <returns>Returns true if the specified commandId is enabled.</returns>
bool IsEnabled(CefMenuCommand commandId);
/// <summary>
/// Returns true if the specified index is enabled.
/// </summary>
/// <param name="index">index</param>
/// <returns>Returns true if the specified index is enabled.</returns>
bool IsEnabledAt(int index);
/// <summary>
/// Change the enabled status of the specified commandId.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <param name="enabled">is enabled</param>
/// <returns>Returns true on success.</returns>
bool SetEnabled(CefMenuCommand commandId, bool enabled);
/// <summary>
/// Change the enabled status at the specified index.
/// </summary>
/// <param name="index">index</param>
/// <param name="enabled">is enabled</param>
/// <returns>Returns true on success.</returns>
bool SetEnabledAt(int index, bool enabled);
/// <summary>
/// Returns true if the specified commandId is checked. Only applies to check and radio items.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <returns>Returns true if the specified commandId is checked. Only applies to check and radio items.</returns>
bool IsChecked(CefMenuCommand commandId);
/// <summary>
/// Returns true if the specified index is checked. Only applies to check and radio items.
/// </summary>
/// <param name="index">index</param>
/// <returns>Returns true if the specified index is checked. Only applies to check and radio items.</returns>
bool IsCheckedAt(int index);
/// <summary>
/// Check the specified commandId. Only applies to check and radio items.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <param name="isChecked">set checked</param>
/// <returns>Returns true on success.</returns>
bool SetChecked(CefMenuCommand commandId, bool isChecked);
/// <summary>
/// Check the specified index. Only applies to check and radio items.
/// </summary>
/// <param name="index">index</param>
/// <param name="isChecked">set checked</param>
/// <returns>Returns true on success.</returns>
bool SetCheckedAt(int index, bool isChecked);
/// <summary>
/// Returns true if the specified commandId has a keyboard accelerator assigned.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <returns>Returns true if the specified commandId has a keyboard accelerator assigned.</returns>
bool HasAccelerator(CefMenuCommand commandId);
/// <summary>
/// Returns true if the specified index has a keyboard accelerator assigned.
/// </summary>
/// <param name="index">index</param>
/// <returns>Returns true if the specified index has a keyboard accelerator assigned.</returns>
bool HasAcceleratorAt(int index);
/// <summary>
/// Set the keyboard accelerator for the specified commandId.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <param name="keyCode">keyCode can be any key or character value. </param>
/// <param name="shiftPressed">shift key pressed</param>
/// <param name="ctrlPressed">ctrl key pressed</param>
/// <param name="altPressed">alt key pressed</param>
/// <returns>Returns true on success.</returns>
bool SetAccelerator(CefMenuCommand commandId, int keyCode, bool shiftPressed, bool ctrlPressed, bool altPressed);
/// <summary>
/// Set the keyboard accelerator at the specified index. keyCode can be any key or character value.
/// </summary>
/// <param name="index">index</param>
/// <param name="keyCode">keyCode can be any key or character value. </param>
/// <param name="shiftPressed">shift key pressed</param>
/// <param name="ctrlPressed">ctrl key pressed</param>
/// <param name="altPressed">alt key pressed</param>
/// <returns>Returns true on success.</returns>
bool SetAcceleratorAt(int index, int keyCode, bool shiftPressed, bool ctrlPressed, bool altPressed);
/// <summary>
/// Remove the keyboard accelerator for the specified commandId.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <returns>Returns true on success.</returns>
bool RemoveAccelerator(CefMenuCommand commandId);
/// <summary>
/// Remove the keyboard accelerator at the specified index.
/// </summary>
/// <param name="index">index</param>
/// <returns>Returns true on success.</returns>
bool RemoveAcceleratorAt(int index);
/// <summary>
/// Retrieves the keyboard accelerator for the specified commandId.
/// </summary>
/// <param name="commandId">the command Id</param>
/// <param name="keyCode">keyCode can be any key or character value. </param>
/// <param name="shiftPressed">shift key pressed</param>
/// <param name="ctrlPressed">ctrl key pressed</param>
/// <param name="altPressed">alt key pressed</param>
/// <returns>Returns true on success.</returns>
bool GetAccelerator(CefMenuCommand commandId, out int keyCode, out bool shiftPressed, out bool ctrlPressed, out bool altPressed);
/// <summary>
/// Retrieves the keyboard accelerator for the specified index.
/// </summary>
/// <param name="index">index</param>
/// <param name="keyCode">keyCode can be any key or character value. </param>
/// <param name="shiftPressed">shift key pressed</param>
/// <param name="ctrlPressed">ctrl key pressed</param>
/// <param name="altPressed">alt key pressed</param>
/// <returns>Returns true on success.</returns>
bool GetAcceleratorAt(int index, out int keyCode, out bool shiftPressed, out bool ctrlPressed, out bool altPressed);
}
}
+16
View File
@@ -0,0 +1,16 @@
// Copyright © 2010-2016 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
namespace CefSharp
{
public enum MenuItemType
{
None = 0,
Command,
Check,
Radio,
Separator,
SubMenu
}
}