| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ | 5 #ifndef UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
| 6 #define UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ | 6 #define UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
| 7 | 7 |
| 8 #include "ui/base/ui_base_types.h" | 8 #include "ui/base/ui_base_types.h" |
| 9 #include "ui/views/controls/button/button.h" | 9 #include "ui/views/controls/button/button.h" |
| 10 #include "ui/views/focus/focus_manager.h" | 10 #include "ui/views/focus/focus_manager.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // embedded contents view to provide extra UI to be shown in the row of | 28 // embedded contents view to provide extra UI to be shown in the row of |
| 29 // buttons. | 29 // buttons. |
| 30 // | 30 // |
| 31 // DialogClientView also provides the ability to set an arbitrary view that is | 31 // DialogClientView also provides the ability to set an arbitrary view that is |
| 32 // positioned beneath the buttons. | 32 // positioned beneath the buttons. |
| 33 // | 33 // |
| 34 class VIEWS_EXPORT DialogClientView : public ClientView, | 34 class VIEWS_EXPORT DialogClientView : public ClientView, |
| 35 public ButtonListener, | 35 public ButtonListener, |
| 36 public FocusChangeListener { | 36 public FocusChangeListener { |
| 37 public: | 37 public: |
| 38 // Parameters for the internal dialog styling. Default construction | 38 DialogClientView(Widget* widget, View* contents_view); |
| 39 // produces parameters for native dialog styling. | |
| 40 struct VIEWS_EXPORT StyleParams { | |
| 41 StyleParams(); | |
| 42 | |
| 43 int button_vedge_margin; | |
| 44 int button_hedge_margin; | |
| 45 int button_shadow_margin; | |
| 46 int button_content_spacing; | |
| 47 int related_button_hspacing; | |
| 48 }; | |
| 49 | |
| 50 DialogClientView(Widget* widget, | |
| 51 View* contents_view, | |
| 52 const StyleParams ¶ms); | |
| 53 virtual ~DialogClientView(); | 39 virtual ~DialogClientView(); |
| 54 | 40 |
| 55 // Adds the dialog buttons required by the supplied DialogDelegate to the | 41 // Adds the dialog buttons required by the supplied DialogDelegate to the |
| 56 // view. | 42 // view. |
| 57 void ShowDialogButtons(); | 43 void ShowDialogButtons(); |
| 58 | 44 |
| 59 // Updates the enabled state and label of the buttons required by the | 45 // Updates the enabled state and label of the buttons required by the |
| 60 // supplied DialogDelegate | 46 // supplied DialogDelegate |
| 61 void UpdateDialogButtons(); | 47 void UpdateDialogButtons(); |
| 62 | 48 |
| 63 // Accept the changes made in the window that contains this ClientView. | 49 // Accept the changes made in the window that contains this ClientView. |
| 64 void AcceptWindow(); | 50 void AcceptWindow(); |
| 65 | 51 |
| 66 // Cancel the changes made in the window that contains this ClientView. | 52 // Cancel the changes made in the window that contains this ClientView. |
| 67 void CancelWindow(); | 53 void CancelWindow(); |
| 68 | 54 |
| 69 // Accessors in case the user wishes to adjust these buttons. | 55 // Accessors in case the user wishes to adjust these buttons. |
| 70 TextButton* ok_button() const { return ok_button_; } | 56 TextButton* ok_button() const { return ok_button_; } |
| 71 TextButton* cancel_button() const { return cancel_button_; } | 57 TextButton* cancel_button() const { return cancel_button_; } |
| 72 | 58 |
| 73 // Creates a StyleParams struct in Chrome style (default is native style). | |
| 74 static StyleParams GetChromeStyleParams(); | |
| 75 | |
| 76 // Returns the number of pixels at the bottom of the dialog which are visually | 59 // Returns the number of pixels at the bottom of the dialog which are visually |
| 77 // part of the frame, but are actually rendered by the DialogClientView. | 60 // part of the frame, but are actually rendered by the DialogClientView. |
| 78 int GetBottomMargin(); | 61 int GetBottomMargin(); |
| 79 | 62 |
| 80 // Overridden from View: | 63 // Overridden from View: |
| 81 virtual void NativeViewHierarchyChanged( | 64 virtual void NativeViewHierarchyChanged( |
| 82 bool attached, | 65 bool attached, |
| 83 gfx::NativeView native_view, | 66 gfx::NativeView native_view, |
| 84 internal::RootView* root_view) OVERRIDE; | 67 internal::RootView* root_view) OVERRIDE; |
| 85 | 68 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 103 virtual void ViewHierarchyChanged(bool is_add, View* parent, | 86 virtual void ViewHierarchyChanged(bool is_add, View* parent, |
| 104 View* child) OVERRIDE; | 87 View* child) OVERRIDE; |
| 105 virtual gfx::Size GetPreferredSize() OVERRIDE; | 88 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 106 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 89 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
| 107 | 90 |
| 108 // ButtonListener implementation: | 91 // ButtonListener implementation: |
| 109 virtual void ButtonPressed(Button* sender, | 92 virtual void ButtonPressed(Button* sender, |
| 110 const ui::Event& event) OVERRIDE; | 93 const ui::Event& event) OVERRIDE; |
| 111 | 94 |
| 112 private: | 95 private: |
| 96 // Parameters for the internal dialog styling. |
| 97 struct StyleParams { |
| 98 StyleParams(); |
| 99 |
| 100 int button_vedge_margin; |
| 101 int button_hedge_margin; |
| 102 int button_shadow_margin; |
| 103 int button_content_spacing; |
| 104 int related_button_hspacing; |
| 105 }; |
| 106 |
| 113 // Create a dialog button of the appropriate type. | 107 // Create a dialog button of the appropriate type. |
| 114 TextButton* CreateDialogButton(ui::DialogButton type, const string16& title); | 108 TextButton* CreateDialogButton(ui::DialogButton type, const string16& title); |
| 115 | 109 |
| 116 // Paint the size box in the bottom right corner of the window if it is | 110 // Paint the size box in the bottom right corner of the window if it is |
| 117 // resizable. | 111 // resizable. |
| 118 void PaintSizeBox(gfx::Canvas* canvas); | 112 void PaintSizeBox(gfx::Canvas* canvas); |
| 119 | 113 |
| 120 // Returns the greater of ok and cancel button's preferred height. | 114 // Returns the greater of ok and cancel button's preferred height. |
| 121 int GetButtonsHeight() const; | 115 int GetButtonsHeight() const; |
| 122 | 116 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 171 |
| 178 // When ancestor gets changed focus manager gets changed as well. | 172 // When ancestor gets changed focus manager gets changed as well. |
| 179 FocusManager* saved_focus_manager_; | 173 FocusManager* saved_focus_manager_; |
| 180 | 174 |
| 181 DISALLOW_COPY_AND_ASSIGN(DialogClientView); | 175 DISALLOW_COPY_AND_ASSIGN(DialogClientView); |
| 182 }; | 176 }; |
| 183 | 177 |
| 184 } // namespace views | 178 } // namespace views |
| 185 | 179 |
| 186 #endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ | 180 #endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
| OLD | NEW |