mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 19:25:01 +00:00
8a367fbdc4
* Net Core - Rename CefSharp.Core.dll to CefSharp.Core.Runtime.dll Partial rename, only Net Core, folder not renamed * Net Core - Rename CefSharp.Core.RefAssembly to CefSharp.Core.netcore Remove GenApi * Core - Rename CefDragDataWrapper to DragData Move into CefSharp.Core namespace * WinForms/WPF/OffScreen - Migrate from GitLink command line to Nuget package * Net Core - Refactor to have CefSharp.Core.dll contain only public Api * Net Core - Remove CefSharp.Core.RefAssembly * Net Core - Change CefSharp.Core.netcore output folder * Net Core - Restructure nuget packages * Net Core - Add Cefsharp.Core.Runtime.RefAssembly * Net Core - Hide CLI/C++ classes from intellisense Make sure users don't attempt to load them directly * Rename CefSharp.Core to CefSharp.Core.Runtime * Core - Restructure Net 4.5.2 packages to use CefSharp.Core.dll anycpu variant Attempt to load CefSharp.Core.Runtime at runtime rather than having to use msbuild to copy the correct version * Rename CefSharp.Core.netcore to CefSharp.Core * WPF/WinForms/OffScreen - Change from x86/64 to AnyCPU As they are all managed assemblies they can target AnyCPU. Includes CefSharp.dll * Convert RequestContextBuilder from C++ to C# Now part of the CefSharp.Core PublicApi * Update version number to 87.1.11 * Migrate more of the public Api to C# * Net Core - Basic restructure complete * Net Core - ModuleInitializer (Doesn't work yet) * Remove direct references to BrowserSettings * Net Core - ModuleInitializer load CefShar.Core.Runtime.dl * Net Core - Load libcef.dll via CLR Module initializer If no RID is specified then we can load libcef.dll using the module initializer * Add version to CefSharp.Core * Remove dependency on CefSharp.Core.Runtime Rewrite common targets * AnyCPU app.config transform Improve AnyCPU support * Improve Net Core 3 support Only delete CefSharp.Core.Runtime.dll when AnyCPU * Nuget - Add CefSharp.Core.Runtime reference when TargetFramework = NetCore * Fix Typos Based on #3306 * Net Core - Rename CefSharp.Core.Runtime RefAssembly source file * Net Full - Generate CefSharp.Core.Runtime Ref Assembly For now the powershell build script generates the .cs file based on a x86 release build.ps1 It's not possible to directly install GenApi as it requires a Sdk style project * Net Core - Old packages copy files to required folders * Test - Install newer .Net Compiler and set Lang Version to 7.3 * Net Core - Exclude Net 452 Runtime generated reference source * Core - Add Refactoring TODO * Ref Assembly - Generate source as part of build - Move ref assembly source generate into GenerateRefAssemblySource.ps1 - Call before project build Runs locally, see if Appveyor has a problem with the powershell script execution * Core - Add more factory methods to create instances of managed wrappers * Net Core - Make Initialzier properties internal Not quite sure what the public API should look like as yet, so making internal for now.
440 lines
12 KiB
C++
440 lines
12 KiB
C++
// Copyright © 2015 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.
|
|
|
|
#pragma once
|
|
|
|
#include "Stdafx.h"
|
|
|
|
#include "include\cef_menu_model.h"
|
|
|
|
#include "CefWrapper.h"
|
|
|
|
namespace CefSharp
|
|
{
|
|
namespace Internals
|
|
{
|
|
private ref class CefMenuModelWrapper : public IMenuModel, public CefWrapper
|
|
{
|
|
private:
|
|
MCefRefPtr<CefMenuModel> _menu;
|
|
|
|
public:
|
|
CefMenuModelWrapper(CefRefPtr<CefMenuModel> &menu) :
|
|
_menu(menu)
|
|
{
|
|
|
|
}
|
|
|
|
!CefMenuModelWrapper()
|
|
{
|
|
_menu = NULL;
|
|
}
|
|
|
|
~CefMenuModelWrapper()
|
|
{
|
|
this->!CefMenuModelWrapper();
|
|
|
|
_disposed = true;
|
|
}
|
|
|
|
virtual property int Count
|
|
{
|
|
int get()
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
return _menu->GetCount();
|
|
}
|
|
}
|
|
|
|
virtual bool Clear()
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
return _menu->Clear();
|
|
}
|
|
|
|
virtual String^ GetLabelAt(int index)
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
return StringUtils::ToClr(_menu->GetLabelAt(index));
|
|
}
|
|
|
|
virtual CefMenuCommand GetCommandIdAt(int index)
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
return (CefMenuCommand)_menu->GetCommandIdAt(index);
|
|
}
|
|
|
|
virtual bool Remove(CefMenuCommand commandId)
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
return _menu->Remove((int)commandId);
|
|
}
|
|
|
|
virtual bool AddSeparator()
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
return _menu->AddSeparator();
|
|
}
|
|
|
|
virtual bool AddItem(CefMenuCommand commandId, String^ label)
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
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;
|
|
}
|
|
};
|
|
}
|
|
} |