//============================================================================== AppearanceSettings::AppearanceSettings (bool updateAppWhenChanged) : settings ("COLOUR_SCHEME") { IntrojucerLookAndFeel lf; for (int i = 0; i < AppearanceColours::numColours; ++i) getColourValue (AppearanceColours::colours[i].name) = lf.findColour (AppearanceColours::colours[i].colourID).toString(); CodeDocument doc; CPlusPlusCodeTokeniser tokeniser; CodeEditorComponent editor (doc, &tokeniser); const CodeEditorComponent::ColourScheme cs (editor.getColourScheme()); for (int i = cs.types.size(); --i >= 0;) { CodeEditorComponent::ColourScheme::TokenType& t = cs.types.getReference(i); getColourValue (t.name) = t.colour.toString(); } getCodeFontValue() = getDefaultCodeFont().toString(); if (updateAppWhenChanged) settings.addListener (this); }
void AppearanceSettings::applyToCodeEditor (CodeEditorComponent& editor) const { CodeEditorComponent::ColourScheme cs (editor.getColourScheme()); for (int i = cs.types.size(); --i >= 0;) { CodeEditorComponent::ColourScheme::TokenType& t = cs.types.getReference(i); getColour (t.name, t.colour); } editor.setColourScheme (cs); editor.setFont (getCodeFont()); for (int i = 0; i < AppearanceColours::numColours; ++i) { if (AppearanceColours::colours[i].applyToEditorOnly) { Colour col; if (getColour (AppearanceColours::colours[i].name, col)) editor.setColour (AppearanceColours::colours[i].colourID, col); } } editor.setColour (ScrollBar::thumbColourId, IntrojucerLookAndFeel::getScrollbarColourForBackground (editor.findColour (CodeEditorComponent::backgroundColourId))); }