Audio plugin host https://kx.studio/carla
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.

juce_LookAndFeel.h 11KB

9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. #ifndef JUCE_LOOKANDFEEL_H_INCLUDED
  18. #define JUCE_LOOKANDFEEL_H_INCLUDED
  19. //==============================================================================
  20. /** This class is used to hold a few look and feel base classes which are associated
  21. with classes that may not be present because they're from modules other than
  22. juce_gui_basics.
  23. */
  24. struct JUCE_API ExtraLookAndFeelBaseClasses
  25. {
  26. //==============================================================================
  27. /** This abstract base class is implemented by LookAndFeel classes. */
  28. struct JUCE_API LassoComponentMethods
  29. {
  30. virtual ~LassoComponentMethods() {}
  31. virtual void drawLasso (Graphics&, Component& lassoComp) = 0;
  32. };
  33. //==============================================================================
  34. /** This abstract base class is implemented by LookAndFeel classes. */
  35. struct JUCE_API KeyMappingEditorComponentMethods
  36. {
  37. virtual ~KeyMappingEditorComponentMethods() {}
  38. virtual void drawKeymapChangeButton (Graphics&, int width, int height, Button&, const String& keyDescription) = 0;
  39. };
  40. //==============================================================================
  41. /** This abstract base class is implemented by LookAndFeel classes. */
  42. struct JUCE_API AudioDeviceSelectorComponentMethods
  43. {
  44. virtual ~AudioDeviceSelectorComponentMethods() {}
  45. virtual void drawLevelMeter (Graphics&, int width, int height, float level) = 0;
  46. };
  47. };
  48. //==============================================================================
  49. /**
  50. LookAndFeel objects define the appearance of all the JUCE widgets, and subclasses
  51. can be used to apply different 'skins' to the application.
  52. This class is an abstract base-class - for actual look-and-feels that you can
  53. instantiate, see LookAndFeel_V1, LookAndFeel_V2 and LookAndFeel_V3.
  54. @see LookAndFeel_V1, LookAndFeel_V2, LookAndFeel_V3
  55. */
  56. class JUCE_API LookAndFeel : public ScrollBar::LookAndFeelMethods,
  57. public Button::LookAndFeelMethods,
  58. public ImageButton::LookAndFeelMethods,
  59. public TextEditor::LookAndFeelMethods,
  60. public FileBrowserComponent::LookAndFeelMethods,
  61. public TreeView::LookAndFeelMethods,
  62. public BubbleComponent::LookAndFeelMethods,
  63. public AlertWindow::LookAndFeelMethods,
  64. public PopupMenu::LookAndFeelMethods,
  65. public ComboBox::LookAndFeelMethods,
  66. public Label::LookAndFeelMethods,
  67. public Slider::LookAndFeelMethods,
  68. public ResizableWindow::LookAndFeelMethods,
  69. public DocumentWindow::LookAndFeelMethods,
  70. public TooltipWindow::LookAndFeelMethods,
  71. public TabbedButtonBar::LookAndFeelMethods,
  72. public PropertyComponent::LookAndFeelMethods,
  73. public FilenameComponent::LookAndFeelMethods,
  74. public GroupComponent::LookAndFeelMethods,
  75. public TableHeaderComponent::LookAndFeelMethods,
  76. public CallOutBox::LookAndFeelMethods,
  77. public Toolbar::LookAndFeelMethods,
  78. public ConcertinaPanel::LookAndFeelMethods,
  79. public ProgressBar::LookAndFeelMethods,
  80. public StretchableLayoutResizerBar::LookAndFeelMethods,
  81. public ExtraLookAndFeelBaseClasses::KeyMappingEditorComponentMethods,
  82. public ExtraLookAndFeelBaseClasses::AudioDeviceSelectorComponentMethods,
  83. public ExtraLookAndFeelBaseClasses::LassoComponentMethods
  84. {
  85. public:
  86. //==============================================================================
  87. /** Creates the default JUCE look and feel. */
  88. LookAndFeel();
  89. /** Destructor. */
  90. virtual ~LookAndFeel();
  91. //==============================================================================
  92. /** Returns the current default look-and-feel for a component to use when it
  93. hasn't got one explicitly set.
  94. @see setDefaultLookAndFeel
  95. */
  96. static LookAndFeel& getDefaultLookAndFeel() noexcept;
  97. /** Changes the default look-and-feel.
  98. @param newDefaultLookAndFeel the new look-and-feel object to use - if this is
  99. set to null, it will revert to using the default one. The
  100. object passed-in must be deleted by the caller when
  101. it's no longer needed.
  102. @see getDefaultLookAndFeel
  103. */
  104. static void setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel) noexcept;
  105. //==============================================================================
  106. /** Looks for a colour that has been registered with the given colour ID number.
  107. If a colour has been set for this ID number using setColour(), then it is
  108. returned. If none has been set, it will just return Colours::black.
  109. The colour IDs for various purposes are stored as enums in the components that
  110. they are relevent to - for an example, see Slider::ColourIds,
  111. Label::ColourIds, TextEditor::ColourIds, TreeView::ColourIds, etc.
  112. If you're looking up a colour for use in drawing a component, it's usually
  113. best not to call this directly, but to use the Component::findColour() method
  114. instead. That will first check whether a suitable colour has been registered
  115. directly with the component, and will fall-back on calling the component's
  116. LookAndFeel's findColour() method if none is found.
  117. @see setColour, Component::findColour, Component::setColour
  118. */
  119. Colour findColour (int colourId) const noexcept;
  120. /** Registers a colour to be used for a particular purpose.
  121. For more details, see the comments for findColour().
  122. @see findColour, Component::findColour, Component::setColour
  123. */
  124. void setColour (int colourId, Colour colour) noexcept;
  125. /** Returns true if the specified colour ID has been explicitly set using the
  126. setColour() method.
  127. */
  128. bool isColourSpecified (int colourId) const noexcept;
  129. //==============================================================================
  130. /** Returns the typeface that should be used for a given font.
  131. The default implementation just does what you'd expect it to, but you can override
  132. this if you want to intercept fonts and use your own custom typeface object.
  133. */
  134. virtual Typeface::Ptr getTypefaceForFont (const Font&);
  135. /** Allows you to change the default sans-serif font.
  136. If you need to supply your own Typeface object for any of the default fonts, rather
  137. than just supplying the name (e.g. if you want to use an embedded font), then
  138. you should instead override getTypefaceForFont() to create and return the typeface.
  139. */
  140. void setDefaultSansSerifTypefaceName (const String& newName);
  141. //==============================================================================
  142. /** Override this to get the chance to swap a component's mouse cursor for a
  143. customised one.
  144. */
  145. virtual MouseCursor getMouseCursorFor (Component&);
  146. //==============================================================================
  147. /** Creates a new graphics context object. */
  148. virtual LowLevelGraphicsContext* createGraphicsContext (const Image& imageToRenderOn,
  149. const Point<int>& origin,
  150. const RectangleList<int>& initialClip);
  151. void setUsingNativeAlertWindows (bool shouldUseNativeAlerts);
  152. bool isUsingNativeAlertWindows();
  153. //==============================================================================
  154. /** Draws a small image that spins to indicate that something's happening.
  155. This method should use the current time to animate itself, so just keep
  156. repainting it every so often.
  157. */
  158. virtual void drawSpinningWaitAnimation (Graphics&, const Colour& colour,
  159. int x, int y, int w, int h) = 0;
  160. //==============================================================================
  161. /** Returns a tick shape for use in yes/no boxes, etc. */
  162. virtual Path getTickShape (float height) = 0;
  163. /** Returns a cross shape for use in yes/no boxes, etc. */
  164. virtual Path getCrossShape (float height) = 0;
  165. //==============================================================================
  166. virtual DropShadower* createDropShadowerForComponent (Component*) = 0;
  167. //==============================================================================
  168. /** Plays the system's default 'beep' noise, to alert the user about something very important. */
  169. virtual void playAlertSound();
  170. private:
  171. //==============================================================================
  172. friend class WeakReference<LookAndFeel>;
  173. WeakReference<LookAndFeel>::Master masterReference;
  174. struct ColourSetting
  175. {
  176. int colourID;
  177. Colour colour;
  178. bool operator< (const ColourSetting& other) const noexcept { return colourID < other.colourID; }
  179. bool operator== (const ColourSetting& other) const noexcept { return colourID == other.colourID; }
  180. };
  181. SortedSet<ColourSetting> colours;
  182. String defaultSans, defaultSerif, defaultFixed;
  183. bool useNativeAlertWindows;
  184. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel)
  185. };
  186. #endif // JUCE_LOOKANDFEEL_H_INCLUDED