electron/atom/browser/api/atom_api_menu_win.cc

39 lines
881 B
C++
Raw Normal View History

// 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"
2014-03-16 00:30:26 +00:00
#include "atom/browser/native_window_win.h"
#include "atom/browser/ui/win/menu_2.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
#include "atom/common/node_includes.h"
namespace atom {
namespace api {
2014-04-21 15:40:10 +00:00
MenuWin::MenuWin() {
}
void MenuWin::Popup(Window* 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);
}
void Menu::AttachToWindow(Window* window) {
static_cast<NativeWindowWin*>(window->window())->SetMenu(model_.get());
2013-10-02 13:24:21 +00:00
}
// static
2014-04-21 15:40:10 +00:00
mate::Wrappable* Menu::Create() {
return new MenuWin();
}
} // namespace api
} // namespace atom