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.

155 lines
5.1KB

  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. //==============================================================================
  19. String hexString8Digits (int value);
  20. String createAlphaNumericUID();
  21. String createGUID (const String& seed); // Turns a seed into a windows GUID
  22. String escapeSpaces (const String& text); // replaces spaces with blackslash-space
  23. String addQuotesIfContainsSpaces (const String& text);
  24. StringPairArray parsePreprocessorDefs (const String& defs);
  25. StringPairArray mergePreprocessorDefs (StringPairArray inheritedDefs, const StringPairArray& overridingDefs);
  26. String createGCCPreprocessorFlags (const StringPairArray& defs);
  27. String replacePreprocessorDefs (const StringPairArray& definitions, String sourceString);
  28. StringArray getSearchPathsFromString (const String& searchPath);
  29. void setValueIfVoid (Value value, const var& defaultValue);
  30. //==============================================================================
  31. int indexOfLineStartingWith (const StringArray& lines, const String& text, int startIndex);
  32. void autoScrollForMouseEvent (const MouseEvent& e, bool scrollX = true, bool scrollY = true);
  33. void drawComponentPlaceholder (Graphics& g, int w, int h, const String& text);
  34. void drawRecessedShadows (Graphics& g, int w, int h, int shadowSize);
  35. void showUTF8ToolWindow();
  36. // Start a callout modally, which will delete the content comp when it's dismissed.
  37. void launchAsyncCallOutBox (Component& attachTo, Component* content);
  38. bool cancelAnyModalComponents();
  39. bool reinvokeCommandAfterCancellingModalComps (const ApplicationCommandTarget::InvocationInfo&);
  40. //==============================================================================
  41. class RolloverHelpComp : public Component,
  42. private Timer
  43. {
  44. public:
  45. RolloverHelpComp();
  46. void paint (Graphics& g);
  47. void timerCallback();
  48. private:
  49. Component* lastComp;
  50. String lastTip;
  51. static String findTip (Component*);
  52. };
  53. //==============================================================================
  54. class PropertyPanelWithTooltips : public Component
  55. {
  56. public:
  57. PropertyPanelWithTooltips();
  58. void resized();
  59. PropertyPanel panel;
  60. RolloverHelpComp rollover;
  61. };
  62. //==============================================================================
  63. class PropertyListBuilder
  64. {
  65. public:
  66. PropertyListBuilder() {}
  67. void add (PropertyComponent* propertyComp)
  68. {
  69. components.add (propertyComp);
  70. }
  71. void add (PropertyComponent* propertyComp, const String& tooltip)
  72. {
  73. propertyComp->setTooltip (tooltip);
  74. add (propertyComp);
  75. }
  76. void setPreferredHeight (int height)
  77. {
  78. for (int j = components.size(); --j >= 0;)
  79. components.getUnchecked(j)->setPreferredHeight (height);
  80. }
  81. Array <PropertyComponent*> components;
  82. private:
  83. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertyListBuilder);
  84. };
  85. //==============================================================================
  86. class FloatingLabelComponent : public Component
  87. {
  88. public:
  89. FloatingLabelComponent();
  90. void remove();
  91. void update (Component* parent, const String& text, const Colour& textColour,
  92. int x, int y, bool toRight, bool below);
  93. void paint (Graphics& g);
  94. private:
  95. Font font;
  96. Colour colour;
  97. GlyphArrangement glyphs;
  98. };
  99. //==============================================================================
  100. // A ValueSource which takes an input source, and forwards any changes in it.
  101. // This class is a handy way to create sources which re-map a value.
  102. class ValueSourceFilter : public Value::ValueSource,
  103. public Value::Listener
  104. {
  105. public:
  106. ValueSourceFilter (const Value& source) : sourceValue (source)
  107. {
  108. sourceValue.addListener (this);
  109. }
  110. void valueChanged (Value&) { sendChangeMessage (true); }
  111. protected:
  112. Value sourceValue;
  113. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ValueSourceFilter);
  114. };