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.

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