Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2004, 2007 Mylyn project committers and others. |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
*******************************************************************************/ |
8 |
|
9 |
package org.eclipse.mylyn.internal.bugzilla.ui.editor; |
10 |
|
11 |
import org.eclipse.swt.SWT; |
12 |
import org.eclipse.swt.graphics.GC; |
13 |
import org.eclipse.swt.graphics.Point; |
14 |
import org.eclipse.swt.graphics.Rectangle; |
15 |
import org.eclipse.swt.widgets.Composite; |
16 |
import org.eclipse.ui.forms.widgets.Hyperlink; |
17 |
|
18 |
|
19 |
/** |
20 |
* Compleded Tasks should been shown strikethrough |
21 |
* @author Frank Becker |
22 |
* @since 2.3 |
23 |
*/ |
24 |
public class StrikethroughHyperlink extends Hyperlink { |
25 |
|
26 |
private boolean strikethrough; |
27 |
|
28 |
public StrikethroughHyperlink(Composite parent, int style) { |
29 |
super(parent, style); |
30 |
strikethrough = false; |
31 |
} |
32 |
|
33 |
public boolean isStrikethrough() { |
34 |
return strikethrough; |
35 |
} |
36 |
|
37 |
public void setStrikethrough(boolean strikethrough) { |
38 |
this.strikethrough = strikethrough; |
39 |
} |
40 |
|
41 |
@Override |
42 |
protected void paintText(GC gc, Rectangle bounds) { |
43 |
super.paintText(gc, bounds); |
44 |
|
45 |
if (strikethrough) { |
46 |
Point totalSize = computeTextSize(SWT.DEFAULT, SWT.DEFAULT); |
47 |
int textWidth = Math.min(bounds.width, totalSize.x); |
48 |
int textHeight = totalSize.y; |
49 |
|
50 |
// int descent = gc.getFontMetrics().getDescent(); |
51 |
int lineY = bounds.y + (textHeight / 2); // - descent + 1; |
52 |
gc.drawLine(bounds.x, lineY, bounds.x + textWidth, lineY); |
53 |
} |
54 |
} |
55 |
|
56 |
} |