line_edit.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*************************************************************************/
  2. /* line_edit.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2014 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 LINE_EDIT_H
  30. #define LINE_EDIT_H
  31. #include "scene/gui/control.h"
  32. /**
  33. @author Juan Linietsky <[email protected]>
  34. */
  35. class LineEdit : public Control {
  36. OBJ_TYPE( LineEdit, Control );
  37. bool editable;
  38. bool pass;
  39. String undo_text;
  40. String text;
  41. int cursor_pos;
  42. int window_pos;
  43. int max_length; // 0 for no maximum
  44. struct Selection {
  45. int begin;
  46. int end;
  47. int cursor_start;
  48. bool enabled;
  49. bool creating;
  50. bool old_shift;
  51. bool doubleclick;
  52. bool drag_attempt;
  53. } selection;
  54. void shift_selection_check_pre(bool);
  55. void shift_selection_check_post(bool);
  56. void selection_clear();
  57. void selection_fill_at_cursor();
  58. void selection_delete();
  59. void set_window_pos(int p_pos);
  60. void set_cursor_at_pixel_pos(int p_x);
  61. void clear_internal();
  62. void changed_internal();
  63. void copy_text();
  64. void cut_text();
  65. void paste_text();
  66. void _input_event(InputEvent p_event);
  67. void _notification(int p_what);
  68. protected:
  69. static void _bind_methods();
  70. public:
  71. virtual Variant get_drag_data(const Point2& p_point);
  72. virtual bool can_drop_data(const Point2& p_point,const Variant& p_data) const;
  73. virtual void drop_data(const Point2& p_point,const Variant& p_data);
  74. void select_all();
  75. void delete_char();
  76. void set_text(String p_text);
  77. String get_text() const;
  78. void set_cursor_pos(int p_pos);
  79. int get_cursor_pos() const;
  80. void set_max_length(int p_max_length);
  81. int get_max_length() const;
  82. void append_at_cursor(String p_text);
  83. void clear();
  84. void set_editable(bool p_editable);
  85. bool is_editable() const;
  86. void set_secret(bool p_secret);
  87. bool is_secret() const;
  88. void select(int p_from=0, int p_to=-1);
  89. virtual Size2 get_minimum_size() const;
  90. LineEdit();
  91. ~LineEdit();
  92. };
  93. #endif