2016-01-19 21:09:01 +01:00
|
|
|
// Copyright 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.
|
|
|
|
|
|
|
|
#include "libcef/browser/views/menu_button_view.h"
|
|
|
|
|
2017-02-23 21:24:45 +01:00
|
|
|
#include "ui/gfx/canvas.h"
|
2017-02-25 06:03:31 +01:00
|
|
|
#include "ui/views/controls/menu/menu_config.h"
|
2017-02-23 21:24:45 +01:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefMenuButtonView::CefMenuButtonView(CefMenuButtonDelegate* cef_delegate)
|
2016-01-19 21:09:01 +01:00
|
|
|
: ParentClass(cef_delegate) {
|
|
|
|
DCHECK(cef_delegate);
|
|
|
|
}
|
|
|
|
|
2017-02-23 21:24:45 +01:00
|
|
|
void CefMenuButtonView::Initialize() {
|
|
|
|
ParentClass::Initialize();
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
SetDrawStringsFlags(IsFocusable() ? gfx::Canvas::SHOW_PREFIX
|
|
|
|
: gfx::Canvas::HIDE_PREFIX);
|
2017-02-25 06:03:31 +01:00
|
|
|
|
|
|
|
// Use the same default font as MenuItemView.
|
|
|
|
SetFontList(views::MenuConfig::instance().font_list);
|
2017-02-23 21:24:45 +01:00
|
|
|
}
|
|
|
|
|
2016-01-19 21:09:01 +01:00
|
|
|
CefRefPtr<CefMenuButton> CefMenuButtonView::GetCefMenuButton() const {
|
|
|
|
CefRefPtr<CefMenuButton> menu_button = GetCefLabelButton()->AsMenuButton();
|
|
|
|
DCHECK(menu_button);
|
|
|
|
return menu_button;
|
|
|
|
}
|
|
|
|
|
2017-02-23 21:24:45 +01:00
|
|
|
void CefMenuButtonView::SetDrawStringsFlags(int flags) {
|
|
|
|
label()->SetDrawStringsFlags(flags);
|
|
|
|
}
|
|
|
|
|
2016-01-19 21:09:01 +01:00
|
|
|
void CefMenuButtonView::OnMenuButtonClicked(views::MenuButton* source,
|
|
|
|
const gfx::Point& point,
|
|
|
|
const ui::Event* event) {
|
|
|
|
cef_delegate()->OnMenuButtonPressed(GetCefMenuButton(),
|
|
|
|
CefPoint(point.x(), point.y()));
|
|
|
|
}
|