OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ | 5 #ifndef VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
6 #define VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ | 6 #define VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ui/gfx/font.h" | 9 #include "ui/gfx/font.h" |
10 #include "views/focus/focus_manager.h" | 10 #include "views/focus/focus_manager.h" |
11 #include "views/controls/button/button.h" | 11 #include "views/controls/button/button.h" |
12 #include "views/window/client_view.h" | 12 #include "views/window/client_view.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 | 15 |
16 class DialogDelegate; | 16 class DialogDelegate; |
17 class NativeButton; | 17 class NativeButton; |
18 class Window; | 18 class Widget; |
19 namespace internal { | 19 namespace internal { |
20 class RootView; | 20 class RootView; |
21 } | 21 } |
22 | 22 |
23 /////////////////////////////////////////////////////////////////////////////// | 23 /////////////////////////////////////////////////////////////////////////////// |
24 // DialogClientView | 24 // DialogClientView |
25 // | 25 // |
26 // This ClientView subclass provides the content of a typical dialog box, | 26 // This ClientView subclass provides the content of a typical dialog box, |
27 // including a strip of buttons at the bottom right of the window, default | 27 // including a strip of buttons at the bottom right of the window, default |
28 // accelerator handlers for accept and cancel, and the ability for the | 28 // accelerator handlers for accept and cancel, and the ability for the |
29 // embedded contents view to provide extra UI to be shown in the row of | 29 // embedded contents view to provide extra UI to be shown in the row of |
30 // buttons. | 30 // buttons. |
31 // | 31 // |
32 // DialogClientView also provides the ability to set an arbitrary view that is | 32 // DialogClientView also provides the ability to set an arbitrary view that is |
33 // positioned beneath the buttons. | 33 // positioned beneath the buttons. |
34 // | 34 // |
35 class DialogClientView : public ClientView, | 35 class DialogClientView : public ClientView, |
36 public ButtonListener, | 36 public ButtonListener, |
37 public FocusChangeListener { | 37 public FocusChangeListener { |
38 public: | 38 public: |
39 DialogClientView(Window* window, View* contents_view); | 39 DialogClientView(Widget* widget, View* contents_view); |
40 virtual ~DialogClientView(); | 40 virtual ~DialogClientView(); |
41 | 41 |
42 // Adds the dialog buttons required by the supplied WindowDelegate to the | 42 // Adds the dialog buttons required by the supplied DialogDelegate to the |
43 // view. | 43 // view. |
44 void ShowDialogButtons(); | 44 void ShowDialogButtons(); |
45 | 45 |
46 // Updates the enabled state and label of the buttons required by the | 46 // Updates the enabled state and label of the buttons required by the |
47 // supplied WindowDelegate | 47 // supplied DialogDelegate |
48 void UpdateDialogButtons(); | 48 void UpdateDialogButtons(); |
49 | 49 |
50 // Accept the changes made in the window that contains this ClientView. | 50 // Accept the changes made in the window that contains this ClientView. |
51 void AcceptWindow(); | 51 void AcceptWindow(); |
52 | 52 |
53 // Cancel the changes made in the window that contains this ClientView. | 53 // Cancel the changes made in the window that contains this ClientView. |
54 void CancelWindow(); | 54 void CancelWindow(); |
55 | 55 |
56 // Accessors in case the user wishes to adjust these buttons. | 56 // Accessors in case the user wishes to adjust these buttons. |
57 NativeButton* ok_button() const { return ok_button_; } | 57 NativeButton* ok_button() const { return ok_button_; } |
58 NativeButton* cancel_button() const { return cancel_button_; } | 58 NativeButton* cancel_button() const { return cancel_button_; } |
59 | 59 |
60 // Sets the view that is positioned along the bottom of the buttons. The | 60 // Sets the view that is positioned along the bottom of the buttons. The |
61 // bottom view is positioned beneath the buttons at the full width of the | 61 // bottom view is positioned beneath the buttons at the full width of the |
62 // dialog. If there is an existing bottom view it is removed and deleted. | 62 // dialog. If there is an existing bottom view it is removed and deleted. |
63 void SetBottomView(View* bottom_view); | 63 void SetBottomView(View* bottom_view); |
64 | 64 |
65 // Overridden from View: | 65 // Overridden from View: |
66 virtual void NativeViewHierarchyChanged( | 66 virtual void NativeViewHierarchyChanged( |
67 bool attached, | 67 bool attached, |
68 gfx::NativeView native_view, | 68 gfx::NativeView native_view, |
69 internal::RootView* root_view) OVERRIDE; | 69 internal::RootView* root_view) OVERRIDE; |
70 | 70 |
71 // Overridden from ClientView: | 71 // Overridden from ClientView: |
72 virtual bool CanClose() OVERRIDE; | 72 virtual bool CanClose() OVERRIDE; |
73 virtual void WindowClosing() OVERRIDE; | 73 virtual void WidgetClosing() OVERRIDE; |
74 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; | 74 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; |
75 virtual DialogClientView* AsDialogClientView() OVERRIDE; | 75 virtual DialogClientView* AsDialogClientView() OVERRIDE; |
76 | 76 |
77 // FocusChangeListener implementation: | 77 // FocusChangeListener implementation: |
78 virtual void FocusWillChange(View* focused_before, | 78 virtual void FocusWillChange(View* focused_before, |
79 View* focused_now) OVERRIDE; | 79 View* focused_now) OVERRIDE; |
80 | 80 |
81 protected: | 81 protected: |
82 // View overrides: | 82 // View overrides: |
83 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 83 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
(...skipping 25 matching lines...) Expand all Loading... |
109 void SetDefaultButton(NativeButton* button); | 109 void SetDefaultButton(NativeButton* button); |
110 | 110 |
111 bool has_dialog_buttons() const { return ok_button_ || cancel_button_; } | 111 bool has_dialog_buttons() const { return ok_button_ || cancel_button_; } |
112 | 112 |
113 // Create and add the extra view, if supplied by the delegate. | 113 // Create and add the extra view, if supplied by the delegate. |
114 void CreateExtraView(); | 114 void CreateExtraView(); |
115 | 115 |
116 // Returns the DialogDelegate for the window. | 116 // Returns the DialogDelegate for the window. |
117 DialogDelegate* GetDialogDelegate() const; | 117 DialogDelegate* GetDialogDelegate() const; |
118 | 118 |
119 // Closes the window. | 119 // Closes the widget. |
120 void Close(); | 120 void Close(); |
121 | 121 |
122 // Updates focus listener. | 122 // Updates focus listener. |
123 void UpdateFocusListener(); | 123 void UpdateFocusListener(); |
124 | 124 |
125 static void InitClass(); | 125 static void InitClass(); |
126 | 126 |
127 // The dialog buttons. | 127 // The dialog buttons. |
128 NativeButton* ok_button_; | 128 NativeButton* ok_button_; |
129 NativeButton* cancel_button_; | 129 NativeButton* cancel_button_; |
(...skipping 28 matching lines...) Expand all Loading... |
158 | 158 |
159 // Static resource initialization | 159 // Static resource initialization |
160 static gfx::Font* dialog_button_font_; | 160 static gfx::Font* dialog_button_font_; |
161 | 161 |
162 DISALLOW_COPY_AND_ASSIGN(DialogClientView); | 162 DISALLOW_COPY_AND_ASSIGN(DialogClientView); |
163 }; | 163 }; |
164 | 164 |
165 } // namespace views | 165 } // namespace views |
166 | 166 |
167 #endif // #ifndef VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ | 167 #endif // #ifndef VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
OLD | NEW |