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.

148 lines
4.8KB

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