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.

153 lines
5.0KB

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