ElementFormControl.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * This source file is part of RmlUi, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://github.com/mikke89/RmlUi
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. * Copyright (c) 2019 The RmlUi Team, and contributors
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. *
  27. */
  28. #ifndef RMLUICONTROLSELEMENTFORMCONTROL_H
  29. #define RMLUICONTROLSELEMENTFORMCONTROL_H
  30. #include "../Core/Element.h"
  31. #include "Header.h"
  32. namespace Rml {
  33. namespace Controls {
  34. /**
  35. A generic specialisation of the generic Core::Element for all input controls.
  36. @author Peter Curry
  37. */
  38. class RMLUICONTROLS_API ElementFormControl : public Core::Element
  39. {
  40. public:
  41. /// Constructs a new ElementFormControl. This should not be called directly; use the Factory
  42. /// instead.
  43. /// @param[in] tag The tag the element was declared as in RML.
  44. ElementFormControl(const Rml::Core::String& tag);
  45. virtual ~ElementFormControl();
  46. /// Returns the name of the form control. This is not guaranteed to be unique, and in the case of some form
  47. /// controls (such as radio buttons) most likely will not be.
  48. /// @return The name of the form control.
  49. Rml::Core::String GetName() const;
  50. /// Sets the name of the form control.
  51. /// @param[in] name The new name of the form control.
  52. void SetName(const Rml::Core::String& name);
  53. /// Returns a string representation of the current value of the form control.
  54. /// @return The value of the form control.
  55. virtual Rml::Core::String GetValue() const = 0;
  56. /// Sets the current value of the form control.
  57. /// @param[in] value The new value of the form control.
  58. virtual void SetValue(const Rml::Core::String& value) = 0;
  59. /// Returns if this value should be submitted with the form.
  60. /// @return True if the value should be be submitted with the form, false otherwise.
  61. virtual bool IsSubmitted();
  62. /// Returns the disabled status of the form control.
  63. /// @return True if the element is disabled, false otherwise.
  64. bool IsDisabled() const;
  65. /// Sets the disabled status of the form control.
  66. /// @param[in] disable True to disable the element, false to enable.
  67. void SetDisabled(bool disable);
  68. protected:
  69. /// Checks for changes to the 'disabled' attribute.
  70. /// @param[in] changed_attributes List of changed attributes on the element.
  71. virtual void OnAttributeChange(const Core::AttributeNameList& changed_attributes);
  72. };
  73. }
  74. }
  75. #endif