Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/GradientToolTip.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/GradientToolTip.java81
1 files changed, 81 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/GradientToolTip.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/GradientToolTip.java
new file mode 100644
index 000000000..db3025698
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/GradientToolTip.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Tasktop Technologies 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.ui.discovery.util;
+
+import org.eclipse.equinox.internal.p2.ui.discovery.DiscoveryUi;
+import org.eclipse.jface.window.ToolTip;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * A custom {@link ToolTip} that applies a gradient to the contents.
+ *
+ * @author Shawn Minto
+ */
+public abstract class GradientToolTip extends ToolTip {
+
+ private CommonColors colors;
+
+ public GradientToolTip(Control control, int style, boolean manualActivation) {
+ super(control, style, manualActivation);
+ initResources(control);
+ }
+
+ public GradientToolTip(Control control) {
+ super(control);
+ initResources(control);
+ }
+
+ private void initResources(Control control) {
+ colors = DiscoveryUi.getCommonsColors();
+ }
+
+ @Override
+ protected final Composite createToolTipContentArea(Event event, final Composite parent) {
+ GradientCanvas gradient = new GradientCanvas(parent, SWT.NONE);
+ gradient.setSeparatorVisible(false);
+ GridLayout headLayout = new GridLayout();
+ headLayout.marginHeight = 0;
+ headLayout.marginWidth = 0;
+ headLayout.horizontalSpacing = 0;
+ headLayout.verticalSpacing = 0;
+ headLayout.numColumns = 1;
+ gradient.setLayout(headLayout);
+
+ gradient.setBackgroundGradient(new Color[] { colors.getGradientBegin(), colors.getGradientEnd() },
+ new int[] { 100 }, true);
+
+ createToolTipArea(event, gradient);
+
+ // force a null background so that the gradient shines through
+ for (Control c : gradient.getChildren()) {
+ setNullBackground(c);
+ }
+
+ return gradient;
+ }
+
+ private void setNullBackground(final Control outerCircle) {
+ outerCircle.setBackground(null);
+ if (outerCircle instanceof Composite) {
+ ((Composite) outerCircle).setBackgroundMode(SWT.INHERIT_FORCE);
+ for (Control c : ((Composite) outerCircle).getChildren()) {
+ setNullBackground(c);
+ }
+ }
+ }
+
+ protected abstract Composite createToolTipArea(Event event, Composite parent);
+}

Back to the top