| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_VIEWS_EXAMPLES_DIALOG_EXAMPLE_H_ |
| 6 #define UI_VIEWS_EXAMPLES_DIALOG_EXAMPLE_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "ui/base/models/simple_combobox_model.h" |
| 10 #include "ui/views/controls/button/button.h" |
| 11 #include "ui/views/controls/combobox/combobox_listener.h" |
| 12 #include "ui/views/controls/textfield/textfield_controller.h" |
| 13 #include "ui/views/examples/example_base.h" |
| 14 |
| 15 namespace views { |
| 16 |
| 17 class Checkbox; |
| 18 class Combobox; |
| 19 class DialogDelegate; |
| 20 class GridLayout; |
| 21 class Label; |
| 22 class LabelButton; |
| 23 class Textfield; |
| 24 |
| 25 namespace examples { |
| 26 |
| 27 // An example that exercises BubbleDialogDelegateView or DialogDelegateView. |
| 28 class VIEWS_EXAMPLES_EXPORT DialogExample : public ExampleBase, |
| 29 public ButtonListener, |
| 30 public TextfieldController, |
| 31 public ComboboxListener { |
| 32 public: |
| 33 DialogExample(); |
| 34 ~DialogExample() override; |
| 35 |
| 36 // ExampleBase: |
| 37 void CreateExampleView(View* container) override; |
| 38 |
| 39 private: |
| 40 template <class> |
| 41 class Delegate; |
| 42 class Bubble; |
| 43 class Dialog; |
| 44 |
| 45 // Helper methods to setup the configuration Views. |
| 46 void StartRowWithLabel(GridLayout* layout, const char* label); |
| 47 void StartTextfieldRow(GridLayout* layout, |
| 48 Textfield** member, |
| 49 const char* label, |
| 50 const char* value); |
| 51 void AddCheckbox(GridLayout* layout, Checkbox** member); |
| 52 |
| 53 // Interrogates the configuration Views for DialogDelegate. |
| 54 ui::ModalType GetModalType() const; |
| 55 int GetDialogButtons() const; |
| 56 |
| 57 // Invoked when the dialog is closing. |
| 58 bool AllowDialogClose(bool accept); |
| 59 |
| 60 // Resize the dialog Widget to match the preferred size. Triggers Layout(). |
| 61 void ResizeDialog(); |
| 62 |
| 63 // ButtonListener: |
| 64 void ButtonPressed(Button* sender, const ui::Event& event) override; |
| 65 |
| 66 // TextfieldController: |
| 67 void ContentsChanged(Textfield* sender, |
| 68 const base::string16& new_contents) override; |
| 69 |
| 70 // ComboboxListener: |
| 71 void OnPerformAction(Combobox* combobox) override; |
| 72 |
| 73 DialogDelegate* last_dialog_ = nullptr; |
| 74 Label* last_body_label_ = nullptr; |
| 75 |
| 76 Textfield* title_; |
| 77 Textfield* body_; |
| 78 Textfield* ok_button_label_; |
| 79 Checkbox* has_ok_button_; |
| 80 Textfield* cancel_button_label_; |
| 81 Checkbox* has_cancel_button_; |
| 82 Textfield* extra_button_label_; |
| 83 Checkbox* has_extra_button_; |
| 84 Combobox* mode_; |
| 85 Checkbox* bubble_; |
| 86 Checkbox* persistent_bubble_; |
| 87 LabelButton* show_; |
| 88 ui::SimpleComboboxModel mode_model_; |
| 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(DialogExample); |
| 91 }; |
| 92 |
| 93 } // namespace examples |
| 94 } // namespace views |
| 95 |
| 96 #endif // UI_VIEWS_EXAMPLES_DIALOG_EXAMPLE_H_ |
| OLD | NEW |