/* ============================================================================== This file is part of the JUCE library. Copyright (c) 2013 - Raw Material Software Ltd. Permission is granted to use this software under the terms of either: a) the GPL v2 (or any later version) b) the Affero GPL v3 Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.juce.com for more information. ============================================================================== */ //============================================================================== static Typeface::Ptr getTypefaceForFontFromLookAndFeel (const Font& font) { return LookAndFeel::getDefaultLookAndFeel().getTypefaceForFont (font); } typedef Typeface::Ptr (*GetTypefaceForFont) (const Font&); extern GetTypefaceForFont juce_getTypefaceForFont; //============================================================================== LookAndFeel::LookAndFeel() : useNativeAlertWindows (false) { /* if this fails it means you're trying to create a LookAndFeel object before the static Colours have been initialised. That ain't gonna work. It probably means that you're using a static LookAndFeel object and that your compiler has decided to intialise it before the Colours class. */ jassert (Colours::white == Colour (0xffffffff)); // set up the standard set of colours.. const uint32 textButtonColour = 0xffbbbbff; const uint32 textHighlightColour = 0x401111ee; const uint32 standardOutlineColour = 0xb2808080; static const uint32 standardColours[] = { TextButton::buttonColourId, textButtonColour, TextButton::buttonOnColourId, 0xff4444ff, TextButton::textColourOnId, 0xff000000, TextButton::textColourOffId, 0xff000000, ToggleButton::textColourId, 0xff000000, TextEditor::backgroundColourId, 0xffffffff, TextEditor::textColourId, 0xff000000, TextEditor::highlightColourId, textHighlightColour, TextEditor::highlightedTextColourId, 0xff000000, TextEditor::outlineColourId, 0x00000000, TextEditor::focusedOutlineColourId, textButtonColour, TextEditor::shadowColourId, 0x38000000, CaretComponent::caretColourId, 0xff000000, Label::backgroundColourId, 0x00000000, Label::textColourId, 0xff000000, Label::outlineColourId, 0x00000000, ScrollBar::backgroundColourId, 0x00000000, ScrollBar::thumbColourId, 0xffffffff, TreeView::linesColourId, 0x4c000000, TreeView::backgroundColourId, 0x00000000, TreeView::dragAndDropIndicatorColourId, 0x80ff0000, TreeView::selectedItemBackgroundColourId, 0x00000000, PopupMenu::backgroundColourId, 0xffffffff, PopupMenu::textColourId, 0xff000000, PopupMenu::headerTextColourId, 0xff000000, PopupMenu::highlightedTextColourId, 0xffffffff, PopupMenu::highlightedBackgroundColourId, 0x991111aa, ComboBox::buttonColourId, 0xffbbbbff, ComboBox::outlineColourId, standardOutlineColour, ComboBox::textColourId, 0xff000000, ComboBox::backgroundColourId, 0xffffffff, ComboBox::arrowColourId, 0x99000000, TextPropertyComponent::backgroundColourId, 0xffffffff, TextPropertyComponent::textColourId, 0xff000000, TextPropertyComponent::outlineColourId, standardOutlineColour, ListBox::backgroundColourId, 0xffffffff, ListBox::outlineColourId, standardOutlineColour, ListBox::textColourId, 0xff000000, Slider::backgroundColourId, 0x00000000, Slider::thumbColourId, textButtonColour, Slider::trackColourId, 0x7fffffff, Slider::rotarySliderFillColourId, 0x7f0000ff, Slider::rotarySliderOutlineColourId, 0x66000000, Slider::textBoxTextColourId, 0xff000000, Slider::textBoxBackgroundColourId, 0xffffffff, Slider::textBoxHighlightColourId, textHighlightColour, Slider::textBoxOutlineColourId, standardOutlineColour, ResizableWindow::backgroundColourId, 0xff777777, //DocumentWindow::textColourId, 0xff000000, // (this is deliberately not set) AlertWindow::backgroundColourId, 0xffededed, AlertWindow::textColourId, 0xff000000, AlertWindow::outlineColourId, 0xff666666, ProgressBar::backgroundColourId, 0xffeeeeee, ProgressBar::foregroundColourId, 0xffaaaaee, TooltipWindow::backgroundColourId, 0xffeeeebb, TooltipWindow::textColourId, 0xff000000, TooltipWindow::outlineColourId, 0x4c000000, TabbedComponent::backgroundColourId, 0x00000000, TabbedComponent::outlineColourId, 0xff777777, TabbedButtonBar::tabOutlineColourId, 0x80000000, TabbedButtonBar::frontOutlineColourId, 0x90000000, Toolbar::backgroundColourId, 0xfff6f8f9, Toolbar::separatorColourId, 0x4c000000, Toolbar::buttonMouseOverBackgroundColourId, 0x4c0000ff, Toolbar::buttonMouseDownBackgroundColourId, 0x800000ff, Toolbar::labelTextColourId, 0xff000000, Toolbar::editingModeOutlineColourId, 0xffff0000, DrawableButton::textColourId, 0xff000000, DrawableButton::textColourOnId, 0xff000000, DrawableButton::backgroundColourId, 0x00000000, DrawableButton::backgroundOnColourId, 0xaabbbbff, HyperlinkButton::textColourId, 0xcc1111ee, GroupComponent::outlineColourId, 0x66000000, GroupComponent::textColourId, 0xff000000, BubbleComponent::backgroundColourId, 0xeeeeeebb, BubbleComponent::outlineColourId, 0x77000000, DirectoryContentsDisplayComponent::highlightColourId, textHighlightColour, DirectoryContentsDisplayComponent::textColourId, 0xff000000, 0x1000440, /*LassoComponent::lassoFillColourId*/ 0x66dddddd, 0x1000441, /*LassoComponent::lassoOutlineColourId*/ 0x99111111, 0x1005000, /*MidiKeyboardComponent::whiteNoteColourId*/ 0xffffffff, 0x1005001, /*MidiKeyboardComponent::blackNoteColourId*/ 0xff000000, 0x1005002, /*MidiKeyboardComponent::keySeparatorLineColourId*/ 0x66000000, 0x1005003, /*MidiKeyboardComponent::mouseOverKeyOverlayColourId*/ 0x80ffff00, 0x1005004, /*MidiKeyboardComponent::keyDownOverlayColourId*/ 0xffb6b600, 0x1005005, /*MidiKeyboardComponent::textLabelColourId*/ 0xff000000, 0x1005006, /*MidiKeyboardComponent::upDownButtonBackgroundColourId*/ 0xffd3d3d3, 0x1005007, /*MidiKeyboardComponent::upDownButtonArrowColourId*/ 0xff000000, 0x1004500, /*CodeEditorComponent::backgroundColourId*/ 0xffffffff, 0x1004502, /*CodeEditorComponent::highlightColourId*/ textHighlightColour, 0x1004503, /*CodeEditorComponent::defaultTextColourId*/ 0xff000000, 0x1004504, /*CodeEditorComponent::lineNumberBackgroundId*/ 0x44999999, 0x1004505, /*CodeEditorComponent::lineNumberTextId*/ 0x44000000, 0x1007000, /*ColourSelector::backgroundColourId*/ 0xffe5e5e5, 0x1007001, /*ColourSelector::labelTextColourId*/ 0xff000000, 0x100ad00, /*KeyMappingEditorComponent::backgroundColourId*/ 0x00000000, 0x100ad01, /*KeyMappingEditorComponent::textColourId*/ 0xff000000, FileSearchPathListComponent::backgroundColourId, 0xffffffff, FileChooserDialogBox::titleTextColourId, 0xff000000, }; for (int i = 0; i < numElementsInArray (standardColours); i += 2) setColour ((int) standardColours [i], Colour ((uint32) standardColours [i + 1])); juce_getTypefaceForFont = getTypefaceForFontFromLookAndFeel; } LookAndFeel::~LookAndFeel() { masterReference.clear(); } //============================================================================== Colour LookAndFeel::findColour (int colourID) const noexcept { const ColourSetting c = { colourID, Colour() }; const int index = colours.indexOf (c); if (index >= 0) return colours.getReference (index).colour; jassertfalse; return Colours::black; } void LookAndFeel::setColour (int colourID, Colour newColour) noexcept { const ColourSetting c = { colourID, newColour }; const int index = colours.indexOf (c); if (index >= 0) colours.getReference (index).colour = newColour; else colours.add (c); } bool LookAndFeel::isColourSpecified (const int colourID) const noexcept { const ColourSetting c = { colourID, Colour() }; return colours.contains (c); } //============================================================================== LookAndFeel& LookAndFeel::getDefaultLookAndFeel() noexcept { return Desktop::getInstance().getDefaultLookAndFeel(); } void LookAndFeel::setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel) noexcept { Desktop::getInstance().setDefaultLookAndFeel (newDefaultLookAndFeel); } //============================================================================== Typeface::Ptr LookAndFeel::getTypefaceForFont (const Font& font) { if (defaultSans.isNotEmpty() && font.getTypefaceName() == Font::getDefaultSansSerifFontName()) { Font f (font); f.setTypefaceName (defaultSans); return Typeface::createSystemTypefaceFor (f); } return Font::getDefaultTypefaceForFont (font); } void LookAndFeel::setDefaultSansSerifTypefaceName (const String& newName) { if (defaultSans != newName) { Typeface::clearTypefaceCache(); defaultSans = newName; } } //============================================================================== MouseCursor LookAndFeel::getMouseCursorFor (Component& component) { MouseCursor m (component.getMouseCursor()); Component* parent = component.getParentComponent(); while (parent != nullptr && m == MouseCursor::ParentCursor) { m = parent->getMouseCursor(); parent = parent->getParentComponent(); } return m; } LowLevelGraphicsContext* LookAndFeel::createGraphicsContext (const Image& imageToRenderOn, const Point& origin, const RectangleList& initialClip) { return new LowLevelGraphicsSoftwareRenderer (imageToRenderOn, origin, initialClip); } //============================================================================== void LookAndFeel::setUsingNativeAlertWindows (bool shouldUseNativeAlerts) { useNativeAlertWindows = shouldUseNativeAlerts; } bool LookAndFeel::isUsingNativeAlertWindows() { #if JUCE_LINUX return false; // not available currently.. #else return useNativeAlertWindows; #endif }