2012-11-21 01:40:15 +01:00
|
|
|
// Copyright (c) 2011 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.
|
|
|
|
|
|
|
|
#ifndef CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_WIN_H_
|
|
|
|
#define CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_WIN_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "include/cef_render_handler.h"
|
2013-01-24 23:33:23 +01:00
|
|
|
#include "cefclient/client_handler.h"
|
|
|
|
#include "cefclient/osrenderer.h"
|
2012-11-21 01:40:15 +01:00
|
|
|
|
|
|
|
class OSRBrowserProvider {
|
|
|
|
public:
|
|
|
|
virtual CefRefPtr<CefBrowser> GetBrowser() =0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~OSRBrowserProvider() {}
|
|
|
|
};
|
|
|
|
|
2012-12-04 02:16:13 +01:00
|
|
|
class OSRWindow : public ClientHandler::RenderHandler {
|
2012-11-21 01:40:15 +01:00
|
|
|
public:
|
|
|
|
// Create a new OSRWindow instance. |browser_provider| must outlive this
|
|
|
|
// object.
|
|
|
|
static CefRefPtr<OSRWindow> Create(OSRBrowserProvider* browser_provider,
|
|
|
|
bool transparent);
|
|
|
|
|
2012-12-04 02:16:13 +01:00
|
|
|
static CefRefPtr<OSRWindow> From(
|
|
|
|
CefRefPtr<ClientHandler::RenderHandler> renderHandler);
|
2012-11-21 01:40:15 +01:00
|
|
|
|
|
|
|
// Create the underlying window.
|
|
|
|
bool CreateWidget(HWND hWndParent, const RECT& rect,
|
|
|
|
HINSTANCE hInst, LPCTSTR className);
|
|
|
|
|
|
|
|
// Destroy the underlying window.
|
|
|
|
void DestroyWidget();
|
|
|
|
|
|
|
|
HWND hwnd() const {
|
|
|
|
return hWnd_;
|
|
|
|
}
|
|
|
|
|
2012-12-04 02:16:13 +01:00
|
|
|
// ClientHandler::RenderHandler methods
|
|
|
|
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
|
|
|
|
2012-11-21 01:40:15 +01:00
|
|
|
// CefRenderHandler methods
|
|
|
|
virtual bool GetRootScreenRect(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRect& rect) OVERRIDE;
|
|
|
|
virtual bool GetViewRect(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRect& rect) OVERRIDE;
|
|
|
|
virtual bool GetScreenPoint(CefRefPtr<CefBrowser> browser,
|
|
|
|
int viewX,
|
|
|
|
int viewY,
|
|
|
|
int& screenX,
|
|
|
|
int& screenY) OVERRIDE;
|
|
|
|
virtual void OnPopupShow(CefRefPtr<CefBrowser> browser,
|
|
|
|
bool show) OVERRIDE;
|
|
|
|
virtual void OnPopupSize(CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefRect& rect) OVERRIDE;
|
|
|
|
virtual void OnPaint(CefRefPtr<CefBrowser> browser,
|
|
|
|
PaintElementType type,
|
|
|
|
const RectList& dirtyRects,
|
|
|
|
const void* buffer,
|
|
|
|
int width,
|
|
|
|
int height) OVERRIDE;
|
|
|
|
virtual void OnCursorChange(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefCursorHandle cursor) OVERRIDE;
|
|
|
|
|
2013-01-12 00:00:39 +01:00
|
|
|
void Invalidate();
|
|
|
|
|
2012-11-21 01:40:15 +01:00
|
|
|
private:
|
|
|
|
OSRWindow(OSRBrowserProvider* browser_provider, bool transparent);
|
|
|
|
virtual ~OSRWindow();
|
|
|
|
|
2013-01-12 00:00:39 +01:00
|
|
|
void Render();
|
2012-11-21 01:40:15 +01:00
|
|
|
void EnableGL();
|
|
|
|
void DisableGL();
|
2012-12-04 02:16:13 +01:00
|
|
|
void OnDestroyed();
|
2012-11-21 01:40:15 +01:00
|
|
|
static ATOM RegisterOSRClass(HINSTANCE hInstance, LPCTSTR className);
|
|
|
|
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
2013-01-12 00:00:39 +01:00
|
|
|
static int GetCefKeyboardModifiers(WPARAM wparam, LPARAM lparam);
|
|
|
|
static int GetCefMouseModifiers(WPARAM wparam);
|
|
|
|
static bool isKeyDown(WPARAM wparam);
|
|
|
|
bool IsOverPopupWidget(int x, int y) const;
|
|
|
|
int GetPopupXOffset() const;
|
|
|
|
int GetPopupYOffset() const;
|
|
|
|
void ApplyPopupOffset(int& x, int& y) const;
|
2012-11-21 01:40:15 +01:00
|
|
|
|
|
|
|
ClientOSRenderer renderer_;
|
|
|
|
OSRBrowserProvider* browser_provider_;
|
|
|
|
HWND hWnd_;
|
|
|
|
HDC hDC_;
|
|
|
|
HGLRC hRC_;
|
|
|
|
|
2013-01-12 00:00:39 +01:00
|
|
|
bool painting_popup_;
|
|
|
|
bool render_task_pending_;
|
|
|
|
|
2012-11-21 01:40:15 +01:00
|
|
|
IMPLEMENT_REFCOUNTING(OSRWindow);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_WIN_H_
|