本文整理汇总了C++中NativeWindow类的典型用法代码示例。如果您正苦于以下问题:C++ NativeWindow类的具体用法?C++ NativeWindow怎么用?C++ NativeWindow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NativeWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// synchronously send a string from Node to browser, then return string result from browser to Node
Handle<Value> Window::SendSync(const Arguments& args) {
HandleScope scope;
NativeWindow *window = ObjectWrap::Unwrap<NativeWindow> (args.This());
if (window->GetBrowser()) {
// find browser's v8 context
CefRefPtr<CefV8Context> context = window->GetBrowser()->GetMainFrame()->GetV8Context();
// ensure it's usable and enter
if (context.get() && context->Enter()) {
// try to get "appjs.onmessage" function
CefRefPtr<CefV8Value> appjsObject = context->GetGlobal()->GetValue("appjs");
CefRefPtr<CefV8Value> callback = appjsObject->GetValue("onmessage");
if (callback.get()) {
// convert Node V8 string to Cef V8 string
CefV8ValueList argsOut;
argsOut.push_back(CefV8Value::CreateString(V8StringToChar(args[0]->ToString())));
// execute window.appjs fuction, passing in the string,
// then convert the return value from a CefValue to a Node V8 string
Handle<String> ret = CefStringToV8(callback->ExecuteFunction(appjsObject, argsOut)->GetStringValue());
// exit browser v8 context, return string result to Node caller
context->Exit();
return scope.Close(ret);
}
}
}
// likely error condition
return scope.Close(Undefined());
}
示例2: REQUIRE_UI_THREAD
void ClientHandler::OnContentsSizeChange(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int width, int height) {
REQUIRE_UI_THREAD();
if (!browser->IsPopup() && frame->IsMain()) {
NativeWindow* window = NativeWindow::GetWindow(browser);
if (window != NULL && window->GetAutoResize()) {
window->Resize(width, height);
}
}
}
示例3: Settings
Handle<Value> Window::New(const Arguments& args) {
HandleScope scope;
Persistent<Object> options = Persistent<Object>::New(args[0]->ToObject());
Settings* settings = new Settings(options);
NativeWindow* window = new NativeWindow(settings);
Persistent<Object> self = Persistent<Object>::New(args.This());
window->SetV8Handle(self);
self->SetPointerInInternalField(0, window);
return scope.Close(args.This());
}
示例4: SetState
void Window::SetState(Local<String> property, Local<Value> value, const AccessorInfo& info) {
NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(info.Holder());
Local<String> val = value->ToString();
if (val->Equals(String::New("normal"))) {
window->SetState(NW_STATE_NORMAL);
} else if (val->Equals(String::New("minimized"))) {
window->SetState(NW_STATE_MINIMIZED);
} else if (val->Equals(String::New("maximized"))) {
window->SetState(NW_STATE_MAXIMIZED);
} else if (val->Equals(String::New("fullscreen"))) {
window->SetState(NW_STATE_FULLSCREEN);
}
}
示例5: V8StringToChar
Handle<Value> Window::New(const Arguments& args) {
HandleScope scope;
Handle<Object> self = Persistent<Object>::New(args.This());
char* url = (args[0]->IsString()) ? V8StringToChar(args[0]->ToString()) : (char*) "/";
Persistent<Object> windowSettings = Persistent<Object>::New((args[1]->IsObject()) ? args[1]->ToObject() : Object::New());
Settings* settings = new Settings(windowSettings);
NativeWindow* window = new NativeWindow(url, settings);
window->SetV8Handle(self);
self->SetPointerInInternalField (0, window);
return scope.Close(args.This());
}
示例6:
Handle<Value> Window::SetNonclientWidth(const Arguments& args) {
HandleScope scope;
NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(args.This());
if (args.Length() == 4) {
int top = args[0]->Int32Value();
int left = args[1]->Int32Value();
int right = args[2]->Int32Value();
int bottom = args[3]->Int32Value();
window->SetNonclientWidth(top, left, right, bottom);
} else {
window->SetNonclientWidth(args[0]->Int32Value());
}
return scope.Close(args.This());
}
示例7: switch
Handle<Value> Window::Style(const Arguments& args) {
HandleScope scope;
NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(args.This());
switch (args.Length()) {
case 0:
return scope.Close(Integer::New(window->GetStyle(false)));
case 1:
if (args[0]->IsBoolean()) {
return scope.Close(Integer::New(window->GetStyle(args[0]->BooleanValue())));
} else {
window->SetStyle(args[0]->Int32Value(), false);
}
break;
case 2:
window->SetStyle(args[0]->Int32Value(), args[1]->BooleanValue());
break;
}
return scope.Close(args.This());
}
示例8: createWindowSurface
//! Create EGL window surface using eglCreateWindowSurface() or eglCreatePlatformWindowSurfaceEXT()
EGLSurface createWindowSurface (NativeDisplay& nativeDisplay, NativeWindow& window, EGLDisplay display, EGLConfig config, const EGLAttrib* attribList)
{
const Library& egl = nativeDisplay.getLibrary();
const bool supportsLegacyCreate = (window.getCapabilities() & NativeWindow::CAPABILITY_CREATE_SURFACE_LEGACY) != 0;
const bool supportsPlatformCreate = (window.getCapabilities() & NativeWindow::CAPABILITY_CREATE_SURFACE_PLATFORM) != 0;
bool usePlatformExt = false;
EGLSurface surface = EGL_NO_SURFACE;
TCU_CHECK_INTERNAL(supportsLegacyCreate || supportsPlatformCreate);
if (supportsPlatformCreate)
{
const vector<string> platformExts = getPlatformExtensions(egl);
usePlatformExt = de::contains(platformExts.begin(), platformExts.end(), string("EGL_EXT_platform_base")) &&
de::contains(platformExts.begin(), platformExts.end(), string(nativeDisplay.getPlatformExtensionName()));
}
// \todo [2014-03-13 pyry] EGL 1.5 core support
if (usePlatformExt)
{
const vector<EGLint> legacyAttribs = toLegacyAttribList(attribList);
surface = egl.createPlatformWindowSurfaceEXT(display, config, window.getPlatformNative(), &legacyAttribs[0]);
EGLU_CHECK_MSG(egl, "eglCreatePlatformWindowSurfaceEXT()");
TCU_CHECK(surface != EGL_NO_SURFACE);
}
else if (supportsLegacyCreate)
{
const vector<EGLint> legacyAttribs = toLegacyAttribList(attribList);
surface = egl.createWindowSurface(display, config, window.getLegacyNative(), &legacyAttribs[0]);
EGLU_CHECK_MSG(egl, "eglCreateWindowSurface()");
TCU_CHECK(surface != EGL_NO_SURFACE);
}
else
throw tcu::InternalError("No supported way to create EGL window surface", DE_NULL, __FILE__, __LINE__);
DE_ASSERT(surface != EGL_NO_SURFACE);
return surface;
}
示例9: SetTopmost
void Window::SetTopmost(Local<String> property, Local<Value> value, const AccessorInfo& info) {
NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(info.Holder());
window->SetTopmost(value->BooleanValue());
}
示例10: SetTitle
void Window::SetTitle(Local<String> property, Local<Value> value, const AccessorInfo& info) {
NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(info.Holder());
window->SetTitle(V8StringToChar(value->ToString()));
}
示例11: ANKI_TEST
ANKI_TEST(Ui, Ui)
{
Config cfg;
initConfig(cfg);
cfg.set("window.vsync", 1);
cfg.set("window.debugContext", 0);
cfg.set("width", 1024);
cfg.set("height", 760);
cfg.set("rsrc.dataPaths", "engine_data");
NativeWindow* win = createWindow(cfg);
Input* in = new Input();
GrManager* gr = createGrManager(cfg, win);
PhysicsWorld* physics;
ResourceFilesystem* fs;
ResourceManager* resource = createResourceManager(cfg, gr, physics, fs);
UiManager* ui = new UiManager();
ANKI_TEST_EXPECT_NO_ERR(in->init(win));
StagingGpuMemoryManager* stagingMem = new StagingGpuMemoryManager();
ANKI_TEST_EXPECT_NO_ERR(stagingMem->init(gr, cfg));
HeapAllocator<U8> alloc(allocAligned, nullptr);
ANKI_TEST_EXPECT_NO_ERR(ui->init(allocAligned, nullptr, resource, gr, stagingMem, in));
{
FontPtr font;
ANKI_TEST_EXPECT_NO_ERR(ui->newInstance(font, "UbuntuRegular.ttf", std::initializer_list<U32>{10, 20, 30, 60}));
CanvasPtr canvas;
ANKI_TEST_EXPECT_NO_ERR(ui->newInstance(canvas, font, 20, win->getWidth(), win->getHeight()));
IntrusivePtr<Label> label;
ANKI_TEST_EXPECT_NO_ERR(ui->newInstance(label));
Bool done = false;
while(!done)
{
ANKI_TEST_EXPECT_NO_ERR(in->handleEvents());
HighRezTimer timer;
timer.start();
canvas->handleInput();
if(in->getKey(KeyCode::ESCAPE))
{
done = true;
}
canvas->beginBuilding();
label->build(canvas);
TexturePtr presentTex = gr->acquireNextPresentableTexture();
FramebufferPtr fb;
{
TextureViewInitInfo init;
init.m_texture = presentTex;
TextureViewPtr view = gr->newTextureView(init);
FramebufferInitInfo fbinit;
fbinit.m_colorAttachmentCount = 1;
fbinit.m_colorAttachments[0].m_clearValue.m_colorf = {{1.0, 0.0, 1.0, 1.0}};
fbinit.m_colorAttachments[0].m_textureView = view;
fb = gr->newFramebuffer(fbinit);
}
CommandBufferInitInfo cinit;
cinit.m_flags = CommandBufferFlag::GRAPHICS_WORK | CommandBufferFlag::SMALL_BATCH;
CommandBufferPtr cmdb = gr->newCommandBuffer(cinit);
cmdb->setTextureBarrier(presentTex,
TextureUsageBit::NONE,
TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE,
TextureSubresourceInfo());
cmdb->beginRenderPass(fb, {{TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE}}, {});
canvas->appendToCommandBuffer(cmdb);
cmdb->endRenderPass();
cmdb->setTextureBarrier(presentTex,
TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE,
TextureUsageBit::PRESENT,
TextureSubresourceInfo());
cmdb->flush();
gr->swapBuffers();
stagingMem->endFrame();
timer.stop();
const F32 TICK = 1.0 / 30.0;
if(timer.getElapsedTime() < TICK)
{
HighRezTimer::sleep(TICK - timer.getElapsedTime());
}
}
}
delete ui;
//.........这里部分代码省略.........
示例12: WndProc
// Processes messages for the main window.
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
// Callback for the main window
switch (message) {
case WM_CREATE: {
NativeWindow* window = ClientHandler::GetWindow(hwnd);
RECT rect;
GetClientRect(hwnd, &rect);
Cef::AddWebView(hwnd, rect, url_, browserSettings);
return 0;
}
case WM_PAINT: {
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
return 0;
}
/*case WM_SETFOCUS:
if (g_handler.get() && g_handler->GetBrowserHwnd()) {
// Pass focus to the browser window
PostMessage(g_handler->GetBrowserHwnd(), WM_SETFOCUS, wParam, NULL);
}
return 0;*/
case WM_SIZE: {
NativeWindow* window = ClientHandler::GetWindow(hwnd);
if (window->GetBrowser()) {
RECT r;
GetClientRect(hwnd, &r);
HDWP hdwp = BeginDeferWindowPos(1);
hdwp = DeferWindowPos(hdwp, window->GetBrowser()->GetWindowHandle(), NULL, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER);
EndDeferWindowPos(hdwp);
}
window->UpdatePosition();
break;
}
case WM_MOVE:
ClientHandler::GetWindow(hwnd)->UpdatePosition();
break;
case WM_ERASEBKGND:
return 1;
// case WM_ERASEBKGND: {
// NativeWindow* window = ClientHandler::GetWindow(hwnd);
// if (window->GetBrowser()) {
// // Dont erase the background if the browser window has been loaded
// // (this avoids flashing)
// return 0;
// }
case WM_CLOSE: {
NativeWindow* window = ClientHandler::GetWindow(hwnd);
if (window->GetBrowser()) {
window->GetBrowser()->ParentWindowWillClose();
}
}
break;
//case WM_DESTROY:
// PostQuitMessage(0);
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
示例13: SetWidth
void Window::SetWidth(Local<String> property, Local<Value> value, const AccessorInfo& info) {
NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(info.Holder());
window->SetWidth(value->Int32Value());
}
示例14: WndProc
// Processes messages for the main window.
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
NativeWindow* window = NativeWindow::GetWindow(hwnd);
CefRefPtr<CefBrowser> browser;
if (window) {
browser = window->GetBrowser();
}
switch (message) {
case WM_CREATE: {
RECT rect;
GetClientRect(hwnd, &rect);
Cef::AddWebView(hwnd, rect, url_, browserSettings);
return 0;
}
case WM_PAINT: {
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
return 0;
}
case WM_SETFOCUS:
if (browser.get()) {
PostMessage(browser->GetWindowHandle(), WM_SETFOCUS, wParam, NULL);
return 0;
}
case WM_SIZE: {
window->UpdatePosition();
if (browser.get()) {
RECT rect;
GetClientRect(hwnd, &rect);
HDWP hdwp = BeginDeferWindowPos(1);
hdwp = DeferWindowPos(hdwp, browser->GetWindowHandle(), NULL,
rect.left, rect.top, rect.right - rect.left,
rect.bottom - rect.top, SWP_NOZORDER);
EndDeferWindowPos(hdwp);
if (emitFullscreen) {
emitFullscreen = false;
window->Emit("fullscreen");
} else {
window->Emit("resize", (int)LOWORD(lParam), (int)HIWORD(lParam));
}
}
break;
}
case WM_WINDOWPOSCHANGING: {
WINDOWPOS *position;
position = (WINDOWPOS*)lParam;
if (position->flags & SWP_STATECHANGED) {
if (IsIconic(window->handle_)) {
window->Emit("minimize");
} else if (IsZoomed(window->handle_)) {
window->Emit("maximize");
} else {
window->Emit("restore");
}
}
break;
}
case WM_MOVE:
window->UpdatePosition();
if (browser.get()) {
window->Emit("move", (int)LOWORD(lParam), (int)HIWORD(lParam));
}
break;
case WM_NCHITTEST: {
LRESULT result;
if (DwmDefWindowProc != NULL) {
if (DwmDefWindowProc(hwnd, message, wParam, lParam, &result)) {
return result;
}
}
break;
}
case WM_ERASEBKGND:
if (browser.get()) {
return 0;
}
break;
case WM_CLOSE:
if (browser.get()) {
browser->ParentWindowWillClose();
}
break;
//case WM_DESTROY:
// PostQuitMessage(0);
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
示例15: GetWindow
Handle<Object> ClientHandler::CreatedBrowser(CefRefPtr<CefBrowser> browser) {
NativeWindow* window = GetWindow(browser);
window->SetBrowser(browser);
return window->GetV8Handle();
}