views: Implement the window menu bar.

This commit is contained in:
Cheng Zhao 2014-07-17 14:23:28 +08:00
parent 2ee7caccfe
commit 0f18d63f7f
6 changed files with 310 additions and 6 deletions

View file

@ -5,21 +5,56 @@
#ifndef ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
#define ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/view.h"
namespace ui {
class MenuModel;
}
namespace views {
class MenuButton;
}
namespace atom {
class MenuBar : public views::View {
class MenuDelegate;
class MenuBar : public views::View,
public views::ButtonListener,
public views::MenuButtonListener {
public:
MenuBar();
virtual ~MenuBar();
// Replaces current menu with a new one.
void SetMenu(ui::MenuModel* menu_model);
// Returns there are how many items in the root menu.
int GetItemCount() const;
// Get the menu under specified screen point.
bool GetMenuButtonFromScreenPoint(const gfx::Point& point,
ui::MenuModel** menu_model,
views::MenuButton** button);
protected:
// views::View:
virtual void Paint(gfx::Canvas* canvas) OVERRIDE;
virtual const char* GetClassName() const OVERRIDE;
// views::ButtonListener:
virtual void ButtonPressed(views::Button* sender,
const ui::Event& event) OVERRIDE;
// views::MenuButtonListener:
virtual void OnMenuButtonClicked(views::View* source,
const gfx::Point& point) OVERRIDE;
private:
ui::MenuModel* menu_model_;
scoped_ptr<MenuDelegate> menu_delegate_;
DISALLOW_COPY_AND_ASSIGN(MenuBar);
};