1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 194312: Hover Background Color

This commit is contained in:
Anton Leherbauer 2007-12-12 13:34:28 +00:00
parent eff6754c12
commit 1d3da89cf0
8 changed files with 415 additions and 278 deletions

View file

@ -572,8 +572,8 @@
contentTypeId="org.eclipse.cdt.core.binaryFile">
</contentTypeBinding>
</editor>
</extension>
<extension
point="org.eclipse.ui.themes">
<themeElementCategory label="%CPresentation.label" id="org.eclipse.cdt.ui.presentation"/>
@ -614,8 +614,51 @@
%asmCompareFontDefiniton.description
</description>
</fontDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.content_assist_proposals_background"
isEditable="false"
label="%Dummy.label"
value="255,255,255">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.content_assist_proposals_foreground"
isEditable="false"
label="%Dummy.label"
value="0,0,0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.content_assist_parameters_background"
isEditable="false"
label="%Dummy.label"
value="255,255,255">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.content_assist_parameters_foreground"
isEditable="false"
label="%Dummy.label"
value="0,0,0">
</colorDefinition>
<theme
id="org.eclipse.ui.ide.systemDefault">
<colorOverride
id="org.eclipse.cdt.ui.content_assist_proposals_background"
value="COLOR_LIST_BACKGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.content_assist_proposals_foreground"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.content_assist_parameters_background"
value="COLOR_LIST_BACKGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.content_assist_parameters_foreground"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
</theme>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page

View file

@ -29,4 +29,15 @@ public interface ICThemeConstants {
* A theme constant that holds the foreground color used in the code assist selection dialog.
*/
public final String CODEASSIST_PROPOSALS_FOREGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND;
/**
* A theme constant that holds the background color used for parameter hints.
*/
public final String CODEASSIST_PARAMETERS_BACKGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND;
/**
* A theme constant that holds the foreground color used for parameter hints.
*/
public final String CODEASSIST_PARAMETERS_FOREGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND;
}

View file

@ -54,6 +54,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
{PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor, ContentAssistPreference.PROPOSALS_FOREGROUND, null },
{PreferencesMessages.CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor, ContentAssistPreference.PARAMETERS_BACKGROUND, null },
{PreferencesMessages.CEditorPreferencePage_ContentAssistPage_parameterForegroundColor, ContentAssistPreference.PARAMETERS_FOREGROUND, null },
{PreferencesMessages.CEditorPreferencePage_sourceHoverBackgroundColor, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT},
};
private List fAppearanceColorList;
@ -78,6 +79,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_FOREGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT));
OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
@ -92,11 +95,6 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
store.setDefault(CEditor.INACTIVE_CODE_ENABLE, true);
PreferenceConverter.setDefault(store, CEditor.INACTIVE_CODE_COLOR, new RGB(224, 224, 224));
PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_BACKGROUND, new RGB(254, 241, 233));
PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_FOREGROUND, new RGB(0, 0, 0));
PreferenceConverter.setDefault(store, ContentAssistPreference.PARAMETERS_BACKGROUND, new RGB(254, 241, 233));
PreferenceConverter.setDefault(store, ContentAssistPreference.PARAMETERS_FOREGROUND, new RGB(0, 0, 0));
}
/*
@ -266,7 +264,6 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
* @see PreferencePage#createContents(Composite)
*/
protected Control createContents(Composite parent) {
fOverlayStore.load();
fOverlayStore.start();
@ -280,8 +277,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
}
private void initialize() {
initializeFields();
initializeDefaultColors();
for (int i = 0; i < fAppearanceColorListModel.length; i++) {
fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
@ -292,14 +289,16 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
handleAppearanceColorListSelection();
}
});
}
/*
* @see org.eclipse.cdt.internal.ui.preferences.AbstractPreferencePage#performOk()
/**
* Initializes the default colors.
*/
public boolean performOk() {
return super.performOk();
private void initializeDefaultColors() {
if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) {
RGB rgb= fAppearanceColorList.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB();
PreferenceConverter.setValue(getPreferenceStore(), PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, rgb);
}
}
/*
@ -307,15 +306,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
*/
protected void performDefaults() {
super.performDefaults();
initializeDefaultColors();
handleAppearanceColorListSelection();
}
/*
* @see org.eclipse.cdt.internal.ui.preferences.AbstractPreferencePage#dispose()
*/
public void dispose() {
super.dispose();
}
}

View file

@ -57,6 +57,7 @@ public final class PreferencesMessages extends NLS {
public static String CEditorPreferencePage_ContentAssistPage_parameterForegroundColor;
public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon;
public static String CEditorPreferencePage_ContentAssistPage_sortingSection_title;
public static String CEditorPreferencePage_sourceHoverBackgroundColor;
public static String CEditorColoringConfigurationBlock_MultiLine;
public static String CEditorColoringConfigurationBlock_singleLine;
public static String CEditorColoringConfigurationBlock_keywords;

View file

@ -39,6 +39,7 @@ CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor=Parameter hint
CEditorPreferencePage_ContentAssistPage_parameterForegroundColor=Parameter hint foreground
CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon=Enable "::" as trigger
CEditorPreferencePage_ContentAssistPage_sortingSection_title=Sorting and Filtering
CEditorPreferencePage_sourceHoverBackgroundColor=Source hover background
# {0} will be replaced by the keyboard shortcut for the command (e.g. "Ctrl+Space", or "no shortcut")
CodeAssistAdvancedConfigurationBlock_page_description=Configure the behavior of the content assist ({0}) command.

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2006 QNX Software Systems and others.
* Copyright (c) 2002, 2007 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -13,6 +13,7 @@
package org.eclipse.cdt.internal.ui.text.c.hover;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
@ -31,6 +32,7 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@ -41,6 +43,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
import org.eclipse.cdt.internal.ui.text.CTextTools;
@ -91,6 +94,9 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
*/
private int fMaxHeight= SWT.DEFAULT;
private Color fBackgroundColor;
private boolean fIsSystemBackgroundColor= true;
/**
* Creates a default information control with the given shell as parent. The given
* information presenter is used to process the information to be displayed. The given
@ -124,6 +130,8 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
Display display= fShell.getDisplay();
fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
initializeColors();
Composite composite= fShell;
layout= new GridLayout(1, false);
int border= ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER;
@ -142,21 +150,21 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
gd= new GridData(GridData.FILL_BOTH);
composite.setLayoutData(gd);
composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
composite.setBackground(fBackgroundColor);
}
// Source viewer
IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
fViewer= new CSourceViewer(composite, null, null, false, style, store);
CTextTools tools= CUIPlugin.getDefault().getTextTools();
fViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, tools.getDocumentPartitioning(), false));
fViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false));
fViewer.setEditable(false);
fText= fViewer.getTextWidget();
gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
fText.setLayoutData(gd);
fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
fText.setBackground(fBackgroundColor);
initializeFont();
@ -191,13 +199,30 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
// Regarding the color see bug 41128
fStatusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
fStatusField.setBackground(fBackgroundColor);
}
addDisposeListener(this);
}
private void initializeColors() {
RGB bgRGB= getHoverBackgroundColorRGB();
if (bgRGB != null) {
fBackgroundColor= new Color(fShell.getDisplay(), bgRGB);
fIsSystemBackgroundColor= false;
} else {
fBackgroundColor= fShell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
fIsSystemBackgroundColor= true;
}
}
private RGB getHoverBackgroundColorRGB() {
IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
return store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)
? null
: PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
}
/**
* Creates a default information control with the given shell as parent. The given
* information presenter is used to process the information to be displayed. The given
@ -207,7 +232,7 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
* @param style the additional styles for the styled text widget
*/
public SourceViewerInformationControl(Shell parent,int style) {
this(parent, SWT.NO_TRIM, style);
this(parent, SWT.NO_TRIM | SWT.TOOL, style);
}
/**
@ -222,7 +247,7 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
* @since 3.0
*/
public SourceViewerInformationControl(Shell parent,int style, String statusFieldText) {
this(parent, SWT.NO_TRIM, style, statusFieldText);
this(parent, SWT.NO_TRIM | SWT.TOOL, style, statusFieldText);
}
/**
@ -309,6 +334,8 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
* {@inheritDoc}
*/
public final void dispose() {
if (!fIsSystemBackgroundColor)
fBackgroundColor.dispose();
if (fShell != null && !fShell.isDisposed())
fShell.dispose();
else
@ -336,10 +363,6 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
* @see IInformationControl#setLocation(Point)
*/
public void setLocation(Point location) {
Rectangle trim= fShell.computeTrim(0, 0, 0, 0);
Point textLocation= fText.getLocation();
location.x += trim.x - textLocation.x;
location.y += trim.y - textLocation.y;
fShell.setLocation(location);
}

View file

@ -17,6 +17,8 @@ import org.eclipse.swt.graphics.RGB;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.IColorManager;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.text.IDocument;
@ -35,13 +37,13 @@ public class ContentAssistPreference {
/** Preference key for content assist timeout delay (unused) */
public final static String TIMEOUT_DELAY= "content_assist_timeout_delay"; //$NON-NLS-1$
/** Preference key for content assist proposal color */
public final static String PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$
public final static String PROPOSALS_FOREGROUND= PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND;
/** Preference key for content assist proposal color */
public final static String PROPOSALS_BACKGROUND= "content_assist_proposals_background"; //$NON-NLS-1$
public final static String PROPOSALS_BACKGROUND= PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND;
/** Preference key for content assist parameters color */
public final static String PARAMETERS_FOREGROUND= "content_assist_parameters_foreground"; //$NON-NLS-1$
public final static String PARAMETERS_FOREGROUND= PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND;
/** Preference key for content assist parameters color */
public final static String PARAMETERS_BACKGROUND= "content_assist_parameters_background"; //$NON-NLS-1$
public final static String PARAMETERS_BACKGROUND= PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND;
/** Preference key for content assist auto insert */
public final static String AUTOINSERT= "content_assist_autoinsert"; //$NON-NLS-1$
/** Preference key for content assist to insert the common prefix */

View file

@ -1022,6 +1022,34 @@ public class PreferenceConstants {
*/
public final static String CODEASSIST_PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$
/**
* A named preference that holds the background color used for parameter hints.
* <p>
* Value is of type <code>String</code>. A RGB color value encoded as a string
* using class <code>PreferenceConverter</code>
* </p>
*
* @see org.eclipse.jface.resource.StringConverter
* @see org.eclipse.jface.preference.PreferenceConverter
*
* @since 5.0
*/
public final static String CODEASSIST_PARAMETERS_BACKGROUND= "content_assist_parameters_background"; //$NON-NLS-1$
/**
* A named preference that holds the foreground color used in the code assist selection dialog.
* <p>
* Value is of type <code>String</code>. A RGB color value encoded as a string
* using class <code>PreferenceConverter</code>
* </p>
*
* @see org.eclipse.jface.resource.StringConverter
* @see org.eclipse.jface.preference.PreferenceConverter
*
* @since 5.0
*/
public final static String CODEASSIST_PARAMETERS_FOREGROUND= "content_assist_parameters_foreground"; //$NON-NLS-1$
/**
* A named preference that controls whether words containing digits should
* be skipped during spell checking.
@ -1185,6 +1213,33 @@ public class PreferenceConstants {
*/
public static final String CODEGEN_ADD_COMMENTS= "org.eclipse.cdt.ui.add_comments"; //$NON-NLS-1$
/**
* A named preference that holds the source hover background color.
* <p>
* Value is of type <code>String</code>. A RGB color value encoded as a string
* using class <code>PreferenceConverter</code>
* </p>
*
* @see org.eclipse.jface.resource.StringConverter
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 5.0
*/
public final static String EDITOR_SOURCE_HOVER_BACKGROUND_COLOR= "sourceHoverBackgroundColor"; //$NON-NLS-1$
/**
* A named preference that tells whether to use the system
* default color ({@link SWT#COLOR_INFO_BACKGROUND}) for
* the source hover background color.
* <p>
* Value is of type <code>Boolean</code>.
* </p>
*
* @see org.eclipse.jface.resource.StringConverter
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 5.0
*/
public final static String EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT= "sourceHoverBackgroundColor.SystemDefault"; //$NON-NLS-1$
/**
* Returns the CDT-UI preference store.
*
@ -1215,6 +1270,8 @@ public class PreferenceConstants {
store.setDefault(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS, "org.eclipse.cdt.ui.BestMatchHover;0;org.eclipse.cdt.ui.CSourceHover;" + sourceHoverModifierName); //$NON-NLS-1$
store.setDefault(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS, "org.eclipse.cdt.ui.BestMatchHover;0;org.eclipse.cdt.ui.CSourceHover;" + sourceHoverModifier); //$NON-NLS-1$
store.setDefault(EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT, true);
// coloring
PreferenceConverter.setDefault(store, EDITOR_MULTI_LINE_COMMENT_COLOR, new RGB(63, 127, 95));
store.setDefault(EDITOR_MULTI_LINE_COMMENT_BOLD, false);
@ -1304,7 +1361,6 @@ public class PreferenceConstants {
store.setDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES, "org.eclipse.cdt.ui.textProposalCategory\0"); //$NON-NLS-1$
store.setDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER, "org.eclipse.cdt.ui.parserProposalCategory:65539\0org.eclipse.cdt.ui.textProposalCategory:65541\0org.eclipse.cdt.ui.templateProposalCategory:2\0"); //$NON-NLS-1$
setDefaultAndFireEvent(
store,
PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND,
@ -1313,6 +1369,14 @@ public class PreferenceConstants {
store,
PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND,
findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_FOREGROUND, new RGB(0, 0, 0)));
setDefaultAndFireEvent(
store,
PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND,
findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_BACKGROUND, new RGB(255, 255, 255)));
setDefaultAndFireEvent(
store,
PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND,
findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_FOREGROUND, new RGB(0, 0, 0)));
// spell checking
store.setDefault(PreferenceConstants.SPELLING_LOCALE, "en_US"); //$NON-NLS-1$