2013-07-05 01:44:56 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/browser/api/atom_api_menu_win.h"
|
2013-07-05 01:44:56 +00:00
|
|
|
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/browser/native_window_win.h"
|
|
|
|
#include "atom/browser/ui/win/menu_2.h"
|
|
|
|
#include "atom/common/v8/native_type_conversions.h"
|
2013-08-06 13:08:52 +00:00
|
|
|
#include "ui/gfx/point.h"
|
2013-10-02 13:43:52 +00:00
|
|
|
#include "ui/gfx/screen.h"
|
2013-08-06 13:08:52 +00:00
|
|
|
|
2014-04-17 05:45:14 +00:00
|
|
|
#include "atom/common/node_includes.h"
|
2013-12-17 10:34:45 +00:00
|
|
|
|
2013-07-05 01:44:56 +00:00
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
|
|
|
MenuWin::MenuWin(v8::Handle<v8::Object> wrapper)
|
|
|
|
: Menu(wrapper) {
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuWin::~MenuWin() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuWin::Popup(NativeWindow* native_window) {
|
2013-10-02 13:43:52 +00:00
|
|
|
gfx::Point cursor = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
|
2013-08-17 08:45:21 +00:00
|
|
|
menu_.reset(new atom::Menu2(model_.get()));
|
2013-10-02 13:43:52 +00:00
|
|
|
menu_->RunContextMenuAt(cursor);
|
2013-07-05 01:44:56 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 13:24:21 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Menu::AttachToWindow(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-10-02 13:24:21 +00:00
|
|
|
Menu* self = ObjectWrap::Unwrap<Menu>(args.This());
|
|
|
|
if (self == NULL)
|
|
|
|
return node::ThrowError("Menu is already destroyed");
|
|
|
|
|
|
|
|
NativeWindow* native_window;
|
|
|
|
if (!FromV8Arguments(args, &native_window))
|
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
static_cast<NativeWindowWin*>(native_window)->SetMenu(self->model_.get());
|
|
|
|
}
|
|
|
|
|
2013-07-05 01:44:56 +00:00
|
|
|
// static
|
|
|
|
Menu* Menu::Create(v8::Handle<v8::Object> wrapper) {
|
|
|
|
return new MenuWin(wrapper);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|