cef/libcef_dll/cpptoc/views/display_cpptoc.cc
Marshall Greenblatt 06e73fff15 Implement Views framework on Windows and Linux (issue #1749).
- Add Views header files in a new include/views directory.
- Add initial top-level window (CefWindow), control (CefBrowserView,
  CefLabelButton, CefMenuButton, CefPanel, CefScrollView,
  CefTextfield) and layout (CefBoxLayout, CefFlowLayout) support.
  See libcef/browser/views/view_impl.h comments for implementation
  details.
- Add Views example usage in cefclient and cefsimple and Views unit
  tests in cef_unittests. Pass the `--use-views` command-line flag to
  cefclient, cefsimple and cef_unittests to run using the Views
  framework instead of platform APIs. For cefclient and cefsimple
  this will create the browser window and all related functionality
  using the Views framework. For cef_unittests this will run all
  tests (except OSR tests) in a Views-based browser window. Views-
  specific unit tests (`--gtest_filter=Views*`) will be run even if
  the the `--use-views` flag is not specified.
- Pass the `--hide-frame` command-line flag to cefclient to demo a
  frameless Views-based browser window.
- Pass the `--hide-controls` command-line flag to cefclient to demo a
  browser window without top controls. This also works in non-Views
  mode.
- Pass the `--enable-high-dpi-support` command-line flag to
  cef_unittests on Windows to test high-DPI support on a display
  that supports it.
- Add CefImage for reading/writing image file formats.
- Add CefBrowser::DownloadImage() for downloading image URLs as a
  CefImage representation. This is primarily for loading favicons.
- Add CefMenuModel::CreateMenuModel() and CefMenuModelDelegate for
  creating custom menus. This is primarily for use with
  CefMenuButton.
- Add CefBrowser::TryCloseBrowser() helper for closing a browser.
  Also improve related documentation in cef_life_span_handler.h.
- Rename cef_page_range_t to cef_range_t. It is now also used by
  CefTextfield.
- Remove CefLifeSpanHandler::RunModal() which is never called.
- Add draggable regions example to cefclient.
2016-04-26 11:58:13 -04:00

265 lines
7.0 KiB
C++

// Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include <algorithm>
#include "libcef_dll/cpptoc/views/display_cpptoc.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_display_t* cef_display_get_primary() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
CefRefPtr<CefDisplay> _retval = CefDisplay::GetPrimaryDisplay();
// Return type: refptr_same
return CefDisplayCppToC::Wrap(_retval);
}
CEF_EXPORT cef_display_t* cef_display_get_nearest_point(
const cef_point_t* point, int input_pixel_coords) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: point; type: simple_byref_const
DCHECK(point);
if (!point)
return NULL;
// Translate param: point; type: simple_byref_const
CefPoint pointVal = point?*point:CefPoint();
// Execute
CefRefPtr<CefDisplay> _retval = CefDisplay::GetDisplayNearestPoint(
pointVal,
input_pixel_coords?true:false);
// Return type: refptr_same
return CefDisplayCppToC::Wrap(_retval);
}
CEF_EXPORT cef_display_t* cef_display_get_matching_bounds(
const cef_rect_t* bounds, int input_pixel_coords) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: bounds; type: simple_byref_const
DCHECK(bounds);
if (!bounds)
return NULL;
// Translate param: bounds; type: simple_byref_const
CefRect boundsVal = bounds?*bounds:CefRect();
// Execute
CefRefPtr<CefDisplay> _retval = CefDisplay::GetDisplayMatchingBounds(
boundsVal,
input_pixel_coords?true:false);
// Return type: refptr_same
return CefDisplayCppToC::Wrap(_retval);
}
CEF_EXPORT size_t cef_display_get_count() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
size_t _retval = CefDisplay::GetDisplayCount();
// Return type: simple
return _retval;
}
CEF_EXPORT void cef_display_get_alls(size_t* displaysCount,
cef_display_t** displays) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: displays; type: refptr_vec_same_byref
DCHECK(displaysCount && (*displaysCount == 0 || displays));
if (!displaysCount || (*displaysCount > 0 && !displays))
return;
// Translate param: displays; type: refptr_vec_same_byref
std::vector<CefRefPtr<CefDisplay> > displaysList;
if (displaysCount && *displaysCount > 0 && displays) {
for (size_t i = 0; i < *displaysCount; ++i) {
displaysList.push_back(CefDisplayCppToC::Unwrap(displays[i]));
}
}
// Execute
CefDisplay::GetAllDisplays(
displaysList);
// Restore param: displays; type: refptr_vec_same_byref
if (displaysCount && displays) {
*displaysCount = std::min(displaysList.size(), *displaysCount);
if (*displaysCount > 0) {
for (size_t i = 0; i < *displaysCount; ++i) {
displays[i] = CefDisplayCppToC::Wrap(displaysList[i]);
}
}
}
}
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
int64 CEF_CALLBACK display_get_id(struct _cef_display_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int64 _retval = CefDisplayCppToC::Get(self)->GetID();
// Return type: simple
return _retval;
}
float CEF_CALLBACK display_get_device_scale_factor(
struct _cef_display_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
float _retval = CefDisplayCppToC::Get(self)->GetDeviceScaleFactor();
// Return type: simple
return _retval;
}
void CEF_CALLBACK display_convert_point_to_pixels(struct _cef_display_t* self,
cef_point_t* point) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: point; type: simple_byref
DCHECK(point);
if (!point)
return;
// Translate param: point; type: simple_byref
CefPoint pointVal = point?*point:CefPoint();
// Execute
CefDisplayCppToC::Get(self)->ConvertPointToPixels(
pointVal);
// Restore param: point; type: simple_byref
if (point)
*point = pointVal;
}
void CEF_CALLBACK display_convert_point_from_pixels(struct _cef_display_t* self,
cef_point_t* point) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: point; type: simple_byref
DCHECK(point);
if (!point)
return;
// Translate param: point; type: simple_byref
CefPoint pointVal = point?*point:CefPoint();
// Execute
CefDisplayCppToC::Get(self)->ConvertPointFromPixels(
pointVal);
// Restore param: point; type: simple_byref
if (point)
*point = pointVal;
}
cef_rect_t CEF_CALLBACK display_get_bounds(struct _cef_display_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CefRect();
// Execute
cef_rect_t _retval = CefDisplayCppToC::Get(self)->GetBounds();
// Return type: simple
return _retval;
}
cef_rect_t CEF_CALLBACK display_get_work_area(struct _cef_display_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CefRect();
// Execute
cef_rect_t _retval = CefDisplayCppToC::Get(self)->GetWorkArea();
// Return type: simple
return _retval;
}
int CEF_CALLBACK display_get_rotation(struct _cef_display_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int _retval = CefDisplayCppToC::Get(self)->GetRotation();
// Return type: simple
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefDisplayCppToC::CefDisplayCppToC() {
GetStruct()->get_id = display_get_id;
GetStruct()->get_device_scale_factor = display_get_device_scale_factor;
GetStruct()->convert_point_to_pixels = display_convert_point_to_pixels;
GetStruct()->convert_point_from_pixels = display_convert_point_from_pixels;
GetStruct()->get_bounds = display_get_bounds;
GetStruct()->get_work_area = display_get_work_area;
GetStruct()->get_rotation = display_get_rotation;
}
template<> CefRefPtr<CefDisplay> CefCppToC<CefDisplayCppToC, CefDisplay,
cef_display_t>::UnwrapDerived(CefWrapperType type, cef_display_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return NULL;
}
#ifndef NDEBUG
template<> base::AtomicRefCount CefCppToC<CefDisplayCppToC, CefDisplay,
cef_display_t>::DebugObjCt = 0;
#endif
template<> CefWrapperType CefCppToC<CefDisplayCppToC, CefDisplay,
cef_display_t>::kWrapperType = WT_DISPLAY;