dialogs.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. #include "scene/gui/label.h"
  32. #include "scene/gui/button.h"
  33. #include "scene/gui/texture_button.h"
  34. #include "scene/gui/panel.h"
  35. #include "scene/gui/popup.h"
  36. #include "box_container.h"
  37. /**
  38. @author Juan Linietsky <reduzio@gmail.com>
  39. */
  40. class WindowDialog : public Popup {
  41. OBJ_TYPE(WindowDialog,Popup);
  42. TextureButton *close_button;
  43. String title;
  44. bool dragging;
  45. void _input_event(const InputEvent& p_event);
  46. void _closed();
  47. protected:
  48. virtual void _post_popup();
  49. virtual void _close_pressed() {}
  50. virtual bool has_point(const Point2& p_point) const;
  51. void _notification(int p_what);
  52. static void _bind_methods();
  53. public:
  54. TextureButton *get_close_button();
  55. void set_title(const String& p_title);
  56. String get_title() const;
  57. WindowDialog();
  58. ~WindowDialog();
  59. };
  60. class PopupDialog : public Popup {
  61. OBJ_TYPE(PopupDialog,Popup);
  62. protected:
  63. void _notification(int p_what);
  64. public:
  65. PopupDialog();
  66. ~PopupDialog();
  67. };
  68. class LineEdit;
  69. class AcceptDialog : public WindowDialog {
  70. OBJ_TYPE(AcceptDialog,WindowDialog);
  71. HBoxContainer *hbc;
  72. Label *label;
  73. Button *ok;
  74. // Button *cancel; no more cancel (there is X on tht titlebar)
  75. bool hide_on_ok;
  76. void _custom_action(const String& p_action);
  77. void _ok_pressed();
  78. void _close_pressed();
  79. void _builtin_text_entered(const String& p_text);
  80. static bool swap_ok_cancel;
  81. protected:
  82. virtual void _post_popup();
  83. void _notification(int p_what);
  84. static void _bind_methods();
  85. virtual void ok_pressed() {}
  86. virtual void cancel_pressed() {}
  87. virtual void custom_action(const String&) {}
  88. public:
  89. Label *get_label() { return label; }
  90. static void set_swap_ok_cancel(bool p_swap);
  91. void register_text_enter(Node *p_line_edit);
  92. Button *get_ok() { return ok; }
  93. Button* add_button(const String& p_text,bool p_right=false,const String& p_action="");
  94. Button* add_cancel(const String &p_cancel="");
  95. void set_hide_on_ok(bool p_hide);
  96. bool get_hide_on_ok() const;
  97. void set_text(String p_text);
  98. String get_text() const;
  99. void set_child_rect(Control *p_child);
  100. AcceptDialog();
  101. ~AcceptDialog();
  102. };
  103. class ConfirmationDialog : public AcceptDialog {
  104. OBJ_TYPE(ConfirmationDialog,AcceptDialog);
  105. Button *cancel;
  106. protected:
  107. static void _bind_methods();
  108. public:
  109. Button *get_cancel();
  110. ConfirmationDialog();
  111. };
  112. #endif