dialogs.h
1 /*************************************************************************/
2 /* dialogs.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
9 /* */
10 /* Permission is hereby granted, free of charge, to any person obtaining */
11 /* a copy of this software and associated documentation files (the */
12 /* "Software"), to deal in the Software without restriction, including */
13 /* without limitation the rights to use, copy, modify, merge, publish, */
14 /* distribute, sublicense, and/or sell copies of the Software, and to */
15 /* permit persons to whom the Software is furnished to do so, subject to */
16 /* the following conditions: */
17 /* */
18 /* The above copyright notice and this permission notice shall be */
19 /* included in all copies or substantial portions of the Software. */
20 /* */
21 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
22 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
23 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
24 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
25 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
26 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
27 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28 /*************************************************************************/
29 #ifndef DIALOGS_H
30 #define DIALOGS_H
31 
32 #include "scene/gui/label.h"
33 #include "scene/gui/button.h"
34 #include "scene/gui/texture_button.h"
35 #include "scene/gui/panel.h"
36 #include "scene/gui/popup.h"
37 #include "box_container.h"
43 class WindowDialog : public Popup {
44 
45  OBJ_TYPE(WindowDialog,Popup);
46 
47  TextureButton *close_button;
48  String title;
49  bool dragging;
50 
51  void _input_event(const InputEvent& p_event);
52  void _closed();
53 protected:
54  virtual void _post_popup();
55 
56  virtual void _close_pressed() {}
57  virtual bool has_point(const Point2& p_point) const;
58  void _notification(int p_what);
59  static void _bind_methods();
60 public:
61 
62  TextureButton *get_close_button();
63 
64  void set_title(const String& p_title);
65  String get_title() const;
66 
67  WindowDialog();
68  ~WindowDialog();
69 
70 };
71 
72 class PopupDialog : public Popup {
73 
74  OBJ_TYPE(PopupDialog,Popup);
75 
76 protected:
77  void _notification(int p_what);
78 public:
79 
80  PopupDialog();
81  ~PopupDialog();
82 
83 };
84 
85 
86 class LineEdit;
87 
88 class AcceptDialog : public WindowDialog {
89 
90  OBJ_TYPE(AcceptDialog,WindowDialog);
91 
92  HBoxContainer *hbc;
93  Label *label;
94  Button *ok;
95 // Button *cancel; no more cancel (there is X on tht titlebar)
96  bool hide_on_ok;
97 
98 
99  void _custom_action(const String& p_action);
100  void _ok_pressed();
101  void _close_pressed();
102  void _builtin_text_entered(const String& p_text);
103 
104  static bool swap_ok_cancel;
105 
106 
107 
108 
109 protected:
110 
111  virtual void _post_popup();
112  void _notification(int p_what);
113  static void _bind_methods();
114  virtual void ok_pressed() {}
115  virtual void cancel_pressed() {}
116  virtual void custom_action(const String&) {}
117 public:
118 
119  Label *get_label() { return label; }
120  static void set_swap_ok_cancel(bool p_swap);
121 
122 
123  void register_text_enter(Node *p_line_edit);
124 
125  Button *get_ok() { return ok; }
126  Button* add_button(const String& p_text,bool p_right=false,const String& p_action="");
127  Button* add_cancel(const String &p_cancel="");
128 
129 
130  void set_hide_on_ok(bool p_hide);
131  bool get_hide_on_ok() const;
132 
133  void set_text(String p_text);
134  String get_text() const;
135 
136  void set_child_rect(Control *p_child);
137 
138  AcceptDialog();
139  ~AcceptDialog();
140 
141 };
142 
143 
145 
147  Button *cancel;
148 protected:
149  static void _bind_methods();
150 public:
151 
152  Button *get_cancel();
154 
155 };
156 
157 #endif
Definition: dialogs.h:72
Definition: node.h:42
Definition: texture_button.h:34
Definition: box_container.h:69
Definition: dialogs.h:144
Definition: input_event.h:263
Definition: popup.h:37
Definition: dialogs.h:88
Definition: math_2d.h:65
Definition: control.h:47
Definition: ustring.h:64
Definition: button.h:36
Definition: line_edit.h:36
Definition: label.h:36
Definition: dialogs.h:43