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.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_VIEWS_MENU_BUTTON_VIEW_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_VIEWS_MENU_BUTTON_VIEW_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "include/views/cef_menu_button.h"
|
|
|
|
#include "include/views/cef_menu_button_delegate.h"
|
|
|
|
|
|
|
|
#include "libcef/browser/views/label_button_view.h"
|
|
|
|
|
|
|
|
#include "ui/views/controls/button/menu_button.h"
|
|
|
|
|
|
|
|
// Extend views::LabelButton with a no-argument constructor as required by the
|
|
|
|
// CefViewView template and extend views::ButtonListener as required by the
|
|
|
|
// CefButtonView template.
|
2020-12-02 23:31:49 +01:00
|
|
|
class MenuButtonEx : public views::MenuButton {
|
2016-01-19 21:09:01 +01:00
|
|
|
public:
|
2020-12-02 23:31:49 +01:00
|
|
|
MenuButtonEx()
|
|
|
|
: views::MenuButton(base::BindRepeating(
|
|
|
|
[](MenuButtonEx* self, const ui::Event& event) {
|
|
|
|
self->ButtonPressed(event);
|
|
|
|
},
|
|
|
|
base::Unretained(this))) {}
|
|
|
|
|
|
|
|
virtual void ButtonPressed(const ui::Event& event) = 0;
|
2016-01-19 21:09:01 +01:00
|
|
|
};
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
class CefMenuButtonView
|
|
|
|
: public CefLabelButtonView<MenuButtonEx, CefMenuButtonDelegate> {
|
2016-01-19 21:09:01 +01:00
|
|
|
public:
|
2021-12-06 21:40:25 +01:00
|
|
|
using ParentClass = CefLabelButtonView<MenuButtonEx, CefMenuButtonDelegate>;
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
// |cef_delegate| must not be nullptr.
|
|
|
|
explicit CefMenuButtonView(CefMenuButtonDelegate* cef_delegate);
|
|
|
|
|
2021-12-06 21:40:25 +01:00
|
|
|
CefMenuButtonView(const CefMenuButtonView&) = delete;
|
|
|
|
CefMenuButtonView& operator=(const CefMenuButtonView&) = delete;
|
|
|
|
|
2017-02-23 21:24:45 +01:00
|
|
|
void Initialize() override;
|
|
|
|
|
2016-01-19 21:09:01 +01:00
|
|
|
// Returns the CefMenuButton associated with this view. See comments on
|
|
|
|
// CefViewView::GetCefView.
|
|
|
|
CefRefPtr<CefMenuButton> GetCefMenuButton() const;
|
|
|
|
|
2017-02-23 21:24:45 +01:00
|
|
|
// Set the flags that control display of accelerator characters.
|
|
|
|
void SetDrawStringsFlags(int flags);
|
|
|
|
|
2020-12-02 23:31:49 +01:00
|
|
|
// MenuButtonEx methods:
|
|
|
|
void ButtonPressed(const ui::Event& event) override;
|
2016-01-19 21:09:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_VIEWS_MENU_BUTTON_VIEW_H_
|