views: Show menubar's submenu when "Alt+Key" is pressed.
[platform/framework/web/crosswalk-tizen.git] / atom / browser / ui / views / submenu_button.h
1 // Copyright (c) 2014 GitHub, Inc. All rights reserved.
2 // Use of this source code is governed by the MIT license that can be
3 // found in the LICENSE file.
4
5 #ifndef ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
6 #define ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
7
8 #include "ui/views/controls/button/menu_button.h"
9
10 namespace atom {
11
12 // Special button that used by menu bar to show submenus.
13 class SubmenuButton : public views::MenuButton {
14  public:
15   SubmenuButton(views::ButtonListener* listener,
16                 const base::string16& title,
17                 views::MenuButtonListener* menu_button_listener);
18   virtual ~SubmenuButton();
19
20   void SetAcceleratorVisibility(bool visible);
21   void SetUnderlineColor(SkColor color);
22
23   base::char16 accelerator() const { return accelerator_; }
24
25   // views::MenuButton:
26   virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
27
28  private:
29   bool GetUnderlinePosition(
30       const base::string16& text, int* start, int* end);
31   void GetCharacterPosition(
32       const base::string16& text, int index, int* pos);
33
34   base::char16 accelerator_;
35
36   bool show_underline_;
37
38   int underline_start_;
39   int underline_end_;
40   int text_width_;
41   int text_height_;
42   SkColor underline_color_;
43
44   DISALLOW_COPY_AND_ASSIGN(SubmenuButton);
45 };
46
47 }  // namespace atom
48
49 #endif  // ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_