The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_TEXTPROPERTYCOMPONENT_JUCEHEADER__
  19. #define __JUCE_TEXTPROPERTYCOMPONENT_JUCEHEADER__
  20. #include "juce_PropertyComponent.h"
  21. #include "../widgets/juce_Label.h"
  22. //==============================================================================
  23. /**
  24. A PropertyComponent that shows its value as editable text.
  25. @see PropertyComponent
  26. */
  27. class JUCE_API TextPropertyComponent : public PropertyComponent
  28. {
  29. protected:
  30. //==============================================================================
  31. /** Creates a text property component.
  32. The maxNumChars is used to set the length of string allowable, and isMultiLine
  33. sets whether the text editor allows carriage returns.
  34. @see TextEditor
  35. */
  36. TextPropertyComponent (const String& propertyName,
  37. int maxNumChars,
  38. bool isMultiLine);
  39. public:
  40. /** Creates a text property component.
  41. The maxNumChars is used to set the length of string allowable, and isMultiLine
  42. sets whether the text editor allows carriage returns.
  43. @see TextEditor
  44. */
  45. TextPropertyComponent (const Value& valueToControl,
  46. const String& propertyName,
  47. int maxNumChars,
  48. bool isMultiLine);
  49. /** Destructor. */
  50. ~TextPropertyComponent();
  51. //==============================================================================
  52. /** Called when the user edits the text.
  53. Your subclass must use this callback to change the value of whatever item
  54. this property component represents.
  55. */
  56. virtual void setText (const String& newText);
  57. /** Returns the text that should be shown in the text editor.
  58. */
  59. virtual String getText() const;
  60. //==============================================================================
  61. /** @internal */
  62. void refresh();
  63. /** @internal */
  64. void textWasEdited();
  65. private:
  66. ScopedPointer<Label> textEditor;
  67. void createEditor (int maxNumChars, bool isMultiLine);
  68. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextPropertyComponent);
  69. };
  70. #endif // __JUCE_TEXTPROPERTYCOMPONENT_JUCEHEADER__