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.

106 lines
3.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #pragma once
  18. String hexString8Digits (int value);
  19. String createAlphaNumericUID();
  20. String createGUID (const String& seed); // Turns a seed into a windows GUID
  21. String escapeSpaces (const String& text); // replaces spaces with blackslash-space
  22. String addQuotesIfContainsSpaces (const String& text);
  23. StringPairArray parsePreprocessorDefs (const String& defs);
  24. StringPairArray mergePreprocessorDefs (StringPairArray inheritedDefs, const StringPairArray& overridingDefs);
  25. String createGCCPreprocessorFlags (const StringPairArray& defs);
  26. String replacePreprocessorDefs (const StringPairArray& definitions, String sourceString);
  27. StringArray getCleanedStringArray (StringArray);
  28. StringArray getSearchPathsFromString (const String& searchPath);
  29. StringArray getCommaOrWhitespaceSeparatedItems (const String&);
  30. void setValueIfVoid (Value value, const var& defaultValue);
  31. void addPlistDictionaryKey (XmlElement* xml, const String& key, const String& value);
  32. void addPlistDictionaryKeyBool (XmlElement* xml, const String& key, bool value);
  33. void addPlistDictionaryKeyInt (XmlElement* xml, const String& key, int value);
  34. bool fileNeedsCppSyntaxHighlighting (const File& file);
  35. //==============================================================================
  36. int indexOfLineStartingWith (const StringArray& lines, const String& text, int startIndex);
  37. void autoScrollForMouseEvent (const MouseEvent& e, bool scrollX = true, bool scrollY = true);
  38. //==============================================================================
  39. struct PropertyListBuilder
  40. {
  41. void add (PropertyComponent* propertyComp)
  42. {
  43. components.add (propertyComp);
  44. }
  45. void add (PropertyComponent* propertyComp, const String& tooltip)
  46. {
  47. propertyComp->setTooltip (tooltip);
  48. add (propertyComp);
  49. }
  50. void addSearchPathProperty (const Value& value, const String& name, const String& mainHelpText)
  51. {
  52. add (new TextPropertyComponent (value, name, 16384, true),
  53. mainHelpText + " Use semi-colons or new-lines to separate multiple paths.");
  54. }
  55. void setPreferredHeight (int height)
  56. {
  57. for (int j = components.size(); --j >= 0;)
  58. components.getUnchecked(j)->setPreferredHeight (height);
  59. }
  60. Array<PropertyComponent*> components;
  61. };
  62. //==============================================================================
  63. // A ValueSource which takes an input source, and forwards any changes in it.
  64. // This class is a handy way to create sources which re-map a value.
  65. class ValueSourceFilter : public Value::ValueSource,
  66. public Value::Listener
  67. {
  68. public:
  69. ValueSourceFilter (const Value& source) : sourceValue (source)
  70. {
  71. sourceValue.addListener (this);
  72. }
  73. void valueChanged (Value&) override { sendChangeMessage (true); }
  74. protected:
  75. Value sourceValue;
  76. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ValueSourceFilter)
  77. };