Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: chrome/browser/chromeos/status/status_area_button.h

Issue 8438064: Separate StatusAreaView from StatusAreaViewChromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang fixes + fixup Delegate Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_
6 #define CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_ 6 #define CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "chrome/browser/chromeos/status/status_area_host.h"
11 #include "views/controls/button/menu_button.h" 10 #include "views/controls/button/menu_button.h"
12 #include "views/controls/menu/view_menu_delegate.h" 11 #include "views/controls/menu/view_menu_delegate.h"
13 12
14 namespace chromeos { 13 namespace gfx {
14 class Font;
15 }
15 16
16 // Button to be used to represent status and allow menus to be popped up. 17 // Button to be used to represent status and allow menus to be popped up.
17 // Shows current button state by drawing a border around the current icon. 18 // Shows current button state by drawing a border around the current icon.
18 class StatusAreaButton : public views::MenuButton { 19 class StatusAreaButton : public views::MenuButton {
19 public: 20 public:
20 StatusAreaButton(StatusAreaHost* host, 21 // Different text styles for different types of backgrounds.
22 enum TextStyle {
23 WHITE_PLAIN,
24 GRAY_PLAIN,
25 WHITE_HALOED,
26 GRAY_EMBOSSED
27 };
28
29 class Delegate {
30 public:
31 Delegate() {}
tfarina 2011/11/07 15:45:44 You don't need this.
stevenjb 2011/11/08 00:24:22 Was needed for DISALLOW_COPY_AND_ASSIGN, but see n
32
33 // |command_id| can be any int, passed from the button to the delegate.
34 virtual bool ShouldExecuteStatusAreaCommand(
35 const views::View* button_view, int command_id) const = 0;
36
37 virtual void ExecuteStatusAreaCommand(
38 const views::View* button_view, int command_id) = 0;
39
40 // Contextually adjust the button appearance.
41 virtual int GetFontStyle(const gfx::Font& font) const = 0;
DaveMoore 2011/11/07 15:36:18 This would read better as ModifyFont() and return
stevenjb 2011/11/08 00:24:22 Done, but named this GetStatusAreaFont(), and rena
42
43 virtual TextStyle GetTextStyle() const = 0;
44
45 // Handle visibility changes (e.g. resize the status area).
46 virtual void ButtonVisibilityChanged(views::View* button_view) = 0;
47
48 protected:
49 virtual ~Delegate() {}
DaveMoore 2011/11/07 15:36:18 The virtual destructor shouldn't be inlined...move
tfarina 2011/11/07 15:45:44 Why?
stevenjb 2011/11/08 00:24:22 After some discussion I believe that it is OK (and
50
51 private:
52 DISALLOW_COPY_AND_ASSIGN(Delegate);
tfarina 2011/11/07 15:45:44 Nor this.
stevenjb 2011/11/08 00:24:22 We are inconsistent as to whether we need this in
53 };
54
55 StatusAreaButton(Delegate* button_delegate,
21 views::ViewMenuDelegate* menu_delegate); 56 views::ViewMenuDelegate* menu_delegate);
22 virtual ~StatusAreaButton() {} 57 virtual ~StatusAreaButton() {}
23 virtual void PaintButton(gfx::Canvas* canvas, PaintButtonMode mode); 58 virtual void PaintButton(gfx::Canvas* canvas, PaintButtonMode mode);
24 59
25 // Overrides TextButton's SetText to clear max text size before seting new 60 // Overrides TextButton's SetText to clear max text size before seting new
26 // text content so that the button size would fit the new text size. 61 // text content so that the button size would fit the new text size.
27 virtual void SetText(const string16& text); 62 virtual void SetText(const string16& text);
28 63
29 void set_use_menu_button_paint(bool use_menu_button_paint) {
30 use_menu_button_paint_ = use_menu_button_paint;
31 }
32
33 // views::MenuButton overrides. 64 // views::MenuButton overrides.
34 virtual bool Activate() OVERRIDE; 65 virtual bool Activate() OVERRIDE;
35 66
36 // View overrides. 67 // View overrides.
37 virtual gfx::Size GetPreferredSize() OVERRIDE; 68 virtual gfx::Size GetPreferredSize() OVERRIDE;
38 virtual gfx::Insets GetInsets() const OVERRIDE; 69 virtual gfx::Insets GetInsets() const OVERRIDE;
39 virtual void OnThemeChanged() OVERRIDE; 70 virtual void OnThemeChanged() OVERRIDE;
40 virtual void SetVisible(bool visible) OVERRIDE; 71 virtual void SetVisible(bool visible) OVERRIDE;
41 virtual bool HitTest(const gfx::Point& l) const OVERRIDE; 72 virtual bool HitTest(const gfx::Point& l) const OVERRIDE;
42 73
43 // Controls whether or not this status area button is able to be pressed. 74 void set_menu_active(bool active) { menu_active_ = active; }
44 void set_active(bool active) { active_ = active; } 75 bool menu_active() const { return menu_active_; }
45 bool active() const { return active_; }
46 76
47 protected: 77 protected:
78 Delegate* delegate() { return delegate_; }
79 const Delegate* delegate() const { return delegate_; }
80
48 // Subclasses should override these methods to return the correct dimensions. 81 // Subclasses should override these methods to return the correct dimensions.
49 virtual int icon_height(); 82 virtual int icon_height();
50 virtual int icon_width(); 83 virtual int icon_width();
51 84
52 // Subclasses can override this method to return more or less padding. 85 // Subclasses can override this method to return more or less padding.
53 // The padding is added to both the left and right side. 86 // The padding is added to both the left and right side.
54 virtual int horizontal_padding(); 87 virtual int horizontal_padding();
55 88
56 // True if the button wants to use views::MenuButton drawings.
57 bool use_menu_button_paint_;
58
59 // Insets to use for this button. 89 // Insets to use for this button.
60 gfx::Insets insets_; 90 gfx::Insets insets_;
61 91
62 // Indicates when this button can be pressed. Independent of 92 // Controls whether or not the menu can be activated. This is independent of
63 // IsEnabled state, so that when IsEnabled is true, this can still 93 // IsEnabled state, so that we can prevent the menu from appearing without
64 // be false, and vice versa. 94 // affecting the appearance of the button.
65 bool active_; 95 bool menu_active_;
66
67 // The status area host,
68 StatusAreaHost* host_;
69 96
70 private: 97 private:
71 void UpdateTextStyle(); 98 void UpdateTextStyle();
72 99
100 Delegate* delegate_;
101
73 DISALLOW_COPY_AND_ASSIGN(StatusAreaButton); 102 DISALLOW_COPY_AND_ASSIGN(StatusAreaButton);
74 }; 103 };
75 104
76 } // namespace chromeos
77
78 #endif // CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_ 105 #endif // CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698