Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 303883
Collapse All | Expand All

(-)src/org/eclipse/ui/internal/forms/widgets/ControlSegment.java (-8 / +3 lines)
Lines 13-21 Link Here
13
import java.util.Hashtable;
13
import java.util.Hashtable;
14
14
15
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
16
//RAP [if] GC not supported
16
import org.eclipse.swt.graphics.GC;
17
//import org.eclipse.swt.graphics.GC;
18
import org.eclipse.swt.graphics.Font;
19
import org.eclipse.swt.graphics.Point;
17
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.widgets.Canvas;
18
import org.eclipse.swt.widgets.Canvas;
21
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Composite;
Lines 66-77 Link Here
66
		return size;
64
		return size;
67
	}
65
	}
68
66
69
// RAP [if] changed method signature and implementation to cope with missing GC
67
	public void layout(GC gc, int width, Locator loc, Hashtable resourceTable,
70
//	public void layout(GC gc, int width, Locator loc, Hashtable resourceTable,
71
	public void layout(Font font, int width, Locator loc, Hashtable resourceTable,
72
			boolean selected) {
68
			boolean selected) {
73
//		super.layout(gc, width, loc, resourceTable, selected);
69
		super.layout(gc, width, loc, resourceTable, selected);		
74
		super.layout(font, width, loc, resourceTable, selected);
75
		Control control = getControl(resourceTable);
70
		Control control = getControl(resourceTable);
76
		if (control!=null)
71
		if (control!=null)
77
			control.setBounds(getBounds());
72
			control.setBounds(getBounds());
(-)src/org/eclipse/ui/internal/forms/widgets/TextSegment.java (-98 / +68 lines)
Lines 15-28 Link Here
15
import java.util.Vector;
15
import java.util.Vector;
16
16
17
import org.eclipse.rwt.Adaptable;
17
import org.eclipse.rwt.Adaptable;
18
import org.eclipse.rwt.graphics.Graphics;
19
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.SWT;
20
// RAP [if] unnecessary
19
// RAP [if] unnecessary
21
//import org.eclipse.swt.graphics.Color;
20
//import org.eclipse.swt.graphics.Color;
22
import org.eclipse.swt.graphics.Font;
21
import org.eclipse.swt.graphics.Font;
23
//RAP [if] GC/FontMetrics not supported
22
import org.eclipse.swt.graphics.FontMetrics;
24
//import org.eclipse.swt.graphics.FontMetrics;
23
import org.eclipse.swt.graphics.GC;
25
//import org.eclipse.swt.graphics.GC;
26
import org.eclipse.swt.graphics.Point;
24
import org.eclipse.swt.graphics.Point;
27
import org.eclipse.swt.graphics.Rectangle;
25
import org.eclipse.swt.graphics.Rectangle;
28
import org.eclipse.ui.forms.internal.widgets.ITextSegmentAdapter;
26
import org.eclipse.ui.forms.internal.widgets.ITextSegmentAdapter;
Lines 233-261 Link Here
233
		return new Rectangle(x, y, width, height);
231
		return new Rectangle(x, y, width, height);
234
	}
232
	}
235
233
236
// RAP [if] changed method signature and implementation to cope with missing GC
234
	public boolean advanceLocator(GC gc, int wHint, Locator locator,
237
//	public boolean advanceLocator(GC gc, int wHint, Locator locator,
238
	public boolean advanceLocator(Font font, int wHint, Locator locator,
239
			Hashtable objectTable, boolean computeHeightOnly) {
235
			Hashtable objectTable, boolean computeHeightOnly) {
240
	    Font gcFont = font;
236
  	    Font oldFont = null;
241
		Font oldFont = null;
237
        if (fontId != null) {
242
		if (fontId != null) {
238
            oldFont = gc.getFont();
243
//			oldFont = gc.getFont();
239
            Font newFont = (Font) objectTable.get(fontId);
244
		    oldFont = gcFont;
240
            if (newFont != null)
245
			Font newFont = (Font) objectTable.get(fontId);
241
                gc.setFont(newFont);
246
			if (newFont != null)
242
        }
247
//				gc.setFont(newFont);
243
		FontMetrics fm = gc.getFontMetrics();
248
			    gcFont = newFont;
244
		int lineHeight = fm.getHeight();
249
		}
245
		// RAP [if] fm.getLeading() is missing
250
//		FontMetrics fm = gc.getFontMetrics();
251
//		int lineHeight = fm.getHeight();
252
		int lineHeight = Graphics.getCharHeight( gcFont );
253
		int lineLeading = Math.round( lineHeight / LINE_LEADING_RATIO );
246
		int lineLeading = Math.round( lineHeight / LINE_LEADING_RATIO );
254
		boolean newLine = false;
247
		boolean newLine = false;
255
248
256
		if (wHint == SWT.DEFAULT || !wrapAllowed) {
249
		if (wHint == SWT.DEFAULT || !wrapAllowed) {
257
//			Point extent = gc.textExtent(text);
250
			Point extent = gc.textExtent(text);
258
		    Point extent = Graphics.stringExtent( gcFont, text );
259
			int totalExtent = locator.x+extent.x;
251
			int totalExtent = locator.x+extent.x;
260
			if (isSelectable())
252
			if (isSelectable())
261
				totalExtent+=1;
253
				totalExtent+=1;
Lines 276-288 Link Here
276
			locator.x += width;
268
			locator.x += width;
277
			locator.width = locator.indent + width;
269
			locator.width = locator.indent + width;
278
			locator.rowHeight = Math.max(locator.rowHeight, extent.y);
270
			locator.rowHeight = Math.max(locator.rowHeight, extent.y);
271
			// RAP [if] fm.getLeading() is missing
279
//			locator.leading = Math.max(locator.leading, fm.getLeading());
272
//			locator.leading = Math.max(locator.leading, fm.getLeading());
280
			locator.leading = Math.max(locator.leading, lineLeading);
273
			locator.leading = Math.max(locator.leading, lineLeading);
281
			return newLine;
274
			return newLine;
282
		}
275
		}
283
276
284
//		computeTextFragments(gc);
277
		computeTextFragments(gc);
285
		computeTextFragments(gcFont);
286
278
287
		int width = 0;
279
		int width = 0;
288
		Point lineExtent = new Point(0, 0);
280
		Point lineExtent = new Point(0, 0);
Lines 298-303 Link Here
298
				// overflow
290
				// overflow
299
				int lineWidth = currentExtent;
291
				int lineWidth = currentExtent;
300
				locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y);
292
				locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y);
293
				// RAP [if] fm.getLeading() is missing
301
//				locator.leading = Math.max(locator.leading, fm.getLeading());
294
//				locator.leading = Math.max(locator.leading, fm.getLeading());
302
				locator.leading = Math.max(locator.leading, lineLeading);
295
				locator.leading = Math.max(locator.leading, lineLeading);
303
				if (computeHeightOnly)
296
				if (computeHeightOnly)
Lines 320-330 Link Here
320
		locator.x += lineWidth;
313
		locator.x += lineWidth;
321
		locator.width = width;
314
		locator.width = width;
322
		locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y);
315
		locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y);
316
		// RAP [if] fm.getLeading() is missing
323
//		locator.leading = Math.max(locator.leading, fm.getLeading());
317
//		locator.leading = Math.max(locator.leading, fm.getLeading());
324
		locator.leading = Math.max(locator.leading, lineLeading);
318
		locator.leading = Math.max(locator.leading, lineLeading);
325
		if (oldFont != null) {
319
		if (oldFont != null) {
326
//			gc.setFont(oldFont);
320
			gc.setFont(oldFont);
327
		    gcFont = oldFont;
328
		}
321
		}
329
		return newLine;
322
		return newLine;
330
	}
323
	}
Lines 340-353 Link Here
340
	 * @param lineHeight
333
	 * @param lineHeight
341
	 * @param descent
334
	 * @param descent
342
	 */
335
	 */
343
// RAP [if] changed method signature and implementation to cope with missing GC
336
	private void layoutWithoutWrapping(GC gc, int width, Locator locator,
344
//	private void layoutWithoutWrapping(GC gc, int width, Locator locator,
337
			boolean selected, FontMetrics fm, int lineHeight, int descent) {	
345
//			boolean selected, FontMetrics fm, int lineHeight, int descent) {
338
		Point extent = gc.textExtent(text);	    
346
	private void layoutWithoutWrapping(Font font, int width, Locator locator,
347
	        boolean selected, int lineHeight, int descent) {
348
//		Point extent = gc.textExtent(text);
349
	    Point extent = Graphics.stringExtent( font, text );
350
	    int lineLeading = Math.round( lineHeight / LINE_LEADING_RATIO );
351
		int ewidth = extent.x;
339
		int ewidth = extent.x;
352
		if (isSelectable())
340
		if (isSelectable())
353
			ewidth += 1;
341
			ewidth += 1;
Lines 358-365 Link Here
358
			locator.rowHeight = 0;
346
			locator.rowHeight = 0;
359
			locator.rowCounter++;
347
			locator.rowCounter++;
360
		}
348
		}
349
		// RAP [if] fm.getLeading() is missing
361
//		int ly = locator.getBaseline(fm.getHeight() - fm.getLeading());
350
//		int ly = locator.getBaseline(fm.getHeight() - fm.getLeading());
362
		int ly = locator.getBaseline(Graphics.getCharHeight( font ) - lineLeading);
351
		int lineLeading = Math.round( lineHeight / LINE_LEADING_RATIO );
352
		int ly = locator.getBaseline(fm.getHeight() - lineLeading);
363
		//int lineY = ly + lineHeight - descent + 1;
353
		//int lineY = ly + lineHeight - descent + 1;
364
		Rectangle br = new Rectangle(locator.x, ly, ewidth,
354
		Rectangle br = new Rectangle(locator.x, ly, ewidth,
365
				lineHeight - descent + 3);
355
				lineHeight - descent + 3);
Lines 369-384 Link Here
369
		locator.rowHeight = Math.max(locator.rowHeight, extent.y);
359
		locator.rowHeight = Math.max(locator.rowHeight, extent.y);
370
	}
360
	}
371
361
372
// RAP [if] changed method signature and implementation to cope with missing GC
362
	protected int convertOffsetToStringIndex(GC gc, String s, int x,
373
//	protected int convertOffsetToStringIndex(GC gc, String s, int x,
374
	protected int convertOffsetToStringIndex(Font font, String s, int x,
375
			int swidth, int selOffset) {
363
			int swidth, int selOffset) {
376
		int index = s.length();
364
		int index = s.length();
377
		while (index > 0 && x + swidth > selOffset) {
365
		while (index > 0 && x + swidth > selOffset) {
378
			index--;
366
			index--;
379
			String ss = s.substring(0, index);
367
			String ss = s.substring(0, index);
380
//			swidth = gc.textExtent(ss).x;
368
			swidth = gc.textExtent(ss).x;
381
			swidth = Graphics.stringExtent( font, ss ).x;
382
		}
369
		}
383
		return index;
370
		return index;
384
	}
371
	}
Lines 479-513 Link Here
479
//		}
466
//		}
480
//	}
467
//	}
481
468
482
// RAP [if] changed method signature and implementation to cope with missing GC
469
	public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) {
483
//	public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) {
470
  	    Font oldFont = null;
484
	public void computeSelection(Font font, Hashtable resourceTable, SelectionData selData) {
471
  
485
		Font gcFont = font;
472
        if (fontId != null) {
486
	    Font oldFont = null;
473
            oldFont = gc.getFont();
487
474
            Font newFont = (Font) resourceTable.get(fontId);
488
		if (fontId != null) {
475
            if (newFont != null)
489
//			oldFont = gc.getFont();
476
                gc.setFont(newFont);
490
		    oldFont = gcFont;
477
        }
491
			Font newFont = (Font) resourceTable.get(fontId);
492
			if (newFont != null)
493
//				gc.setFont(newFont);
494
			    gcFont = newFont;
495
		}
496
478
497
		for (int i = 0; i < areaRectangles.size(); i++) {
479
		for (int i = 0; i < areaRectangles.size(); i++) {
498
			AreaRectangle areaRectangle = (AreaRectangle) areaRectangles.get(i);
480
			AreaRectangle areaRectangle = (AreaRectangle) areaRectangles.get(i);
499
			Rectangle rect = areaRectangle.rect;
481
			Rectangle rect = areaRectangle.rect;
500
			String text = areaRectangle.getText();
482
			String text = areaRectangle.getText();
501
//			Point extent = gc.textExtent(text);
483
			Point extent = gc.textExtent(text);
502
			Point extent = Graphics.stringExtent( gcFont, text );
484
			computeSelection(gc, text, extent.x, selData,
503
//			computeSelection(gc, text, extent.x, selData,
504
			computeSelection(gcFont, text, extent.x, selData,
505
					rect);
485
					rect);
506
		}
486
		}
507
		// restore GC resources
487
		// restore GC resources
508
		if (oldFont != null) {
488
		if (oldFont != null) {
509
//			gc.setFont(oldFont);
489
			gc.setFont(oldFont);
510
			gcFont = oldFont;
511
		}
490
		}
512
	}
491
	}
513
492
Lines 582-590 Link Here
582
//		}
561
//		}
583
//	}
562
//	}
584
563
585
// RAP [if] changed method signature and implementation to cope with missing GC
564
	private void computeSelection(GC gc, String s, int swidth, SelectionData selData, Rectangle bounds) {
586
//	private void computeSelection(GC gc, String s, int swidth, SelectionData selData, Rectangle bounds) {
587
	private void computeSelection(Font font, String s, int swidth, SelectionData selData, Rectangle bounds) {
588
		int leftOffset = selData.getLeftOffset(bounds.height);
565
		int leftOffset = selData.getLeftOffset(bounds.height);
589
		int rightOffset = selData.getRightOffset(bounds.height);
566
		int rightOffset = selData.getRightOffset(bounds.height);
590
		boolean firstRow = selData.isFirstSelectionRow(bounds.y, bounds.height);
567
		boolean firstRow = selData.isFirstSelectionRow(bounds.y, bounds.height);
Lines 595-607 Link Here
595
		int sstop = -1;
572
		int sstop = -1;
596
573
597
		if (firstRow && bounds.x + swidth > leftOffset) {
574
		if (firstRow && bounds.x + swidth > leftOffset) {
598
//			sstart = convertOffsetToStringIndex(gc, s, bounds.x, swidth,
575
			sstart = convertOffsetToStringIndex(gc, s, bounds.x, swidth,
599
		    sstart = convertOffsetToStringIndex(font, s, bounds.x, swidth,
600
					leftOffset);
576
					leftOffset);
601
		}
577
		}
602
		if (lastRow && bounds.x + swidth > rightOffset) {
578
		if (lastRow && bounds.x + swidth > rightOffset) {
603
//			sstop = convertOffsetToStringIndex(gc, s, bounds.x, swidth,
579
			sstop = convertOffsetToStringIndex(gc, s, bounds.x, swidth,
604
		    sstop = convertOffsetToStringIndex(font, s, bounds.x, swidth,
605
					rightOffset);
580
					rightOffset);
606
		}
581
		}
607
582
Lines 671-709 Link Here
671
	 *      java.util.Hashtable, boolean,
646
	 *      java.util.Hashtable, boolean,
672
	 *      org.eclipse.ui.internal.forms.widgets.SelectionData)
647
	 *      org.eclipse.ui.internal.forms.widgets.SelectionData)
673
	 */
648
	 */
674
// RAP [if] changed method signature and implementation to cope with missing GC
649
	public void layout(GC gc, int width, Locator locator,
675
//	public void layout(GC gc, int width, Locator locator,
676
	public void layout(Font font, int width, Locator locator,
677
			Hashtable resourceTable, boolean selected) {
650
			Hashtable resourceTable, boolean selected) {
678
	    Font gcFont = font;
651
  	    Font oldFont = null;
679
		Font oldFont = null;
652
  
680
653
        areaRectangles.clear();
681
		areaRectangles.clear();
654
  
682
655
        if (fontId != null) {
683
		if (fontId != null) {
656
            oldFont = gc.getFont();
684
//			oldFont = gc.getFont();
657
            Font newFont = (Font) resourceTable.get(fontId);
685
		    oldFont = gcFont;
658
            if (newFont != null)
686
			Font newFont = (Font) resourceTable.get(fontId);
659
                gc.setFont(newFont);
687
			if (newFont != null)
660
        }
688
//				gc.setFont(newFont);
661
		FontMetrics fm = gc.getFontMetrics();
689
			    gcFont = newFont;
662
		int lineHeight = fm.getHeight();		
690
		}
663
		// RAP [if] fm.getDescent() is missing
691
//		FontMetrics fm = gc.getFontMetrics();
664
//		int descent = fm.getDescent();
692
//		int lineHeight = fm.getHeight();
693
		int lineHeight = Graphics.getCharHeight( gcFont );
694
		int lineLeading = Math.round( lineHeight / LINE_LEADING_RATIO );
695
		int descent = Math.round( lineHeight / LINE_DESCENT_RATIO );
665
		int descent = Math.round( lineHeight / LINE_DESCENT_RATIO );
666
		// RAP [if] fm.getLeading() is missing
667
        int lineLeading = Math.round( lineHeight / LINE_LEADING_RATIO );
696
668
697
		if (!wrapAllowed) {
669
		if (!wrapAllowed) {
698
//			layoutWithoutWrapping(gc, width, locator, selected, fm, lineHeight,
670
			layoutWithoutWrapping(gc, width, locator, selected, fm, lineHeight,
699
		    layoutWithoutWrapping(gcFont, width, locator, selected, lineHeight,
700
					descent);
671
					descent);
701
		} else {
672
		} else {
702
			int lineStart = 0;
673
			int lineStart = 0;
703
			int lastLoc = 0;
674
			int lastLoc = 0;
704
			Point lineExtent = new Point(0, 0);
675
			Point lineExtent = new Point(0, 0);
705
//			computeTextFragments(gc);
676
			computeTextFragments(gc);
706
			computeTextFragments(gcFont);
707
			int rightEdge = width-locator.marginWidth;
677
			int rightEdge = width-locator.marginWidth;
708
			for (int i = 0; i < textFragments.length; i++) {
678
			for (int i = 0; i < textFragments.length; i++) {
709
				TextFragment fragment = textFragments[i];
679
				TextFragment fragment = textFragments[i];
Lines 715-720 Link Here
715
					int lineWidth = locator.x + lineExtent.x;
685
					int lineWidth = locator.x + lineExtent.x;
716
					if (isSelectable())
686
					if (isSelectable())
717
						lineWidth += 1;
687
						lineWidth += 1;
688
					// RAP [if] fm.getLeading() is missing
689
//					int ly = locator.getBaseline(lineHeight - fm.getLeading());					
718
					int ly = locator.getBaseline(lineHeight - lineLeading);
690
					int ly = locator.getBaseline(lineHeight - lineLeading);
719
					Rectangle br = new Rectangle(isSelectable()?
691
					Rectangle br = new Rectangle(isSelectable()?
720
							locator.x - 1:locator.x, ly,
692
							locator.x - 1:locator.x, ly,
Lines 739-744 Link Here
739
				lineExtent.y = Math.max(lineHeight, lineExtent.y);
711
				lineExtent.y = Math.max(lineHeight, lineExtent.y);
740
			}
712
			}
741
			//String lastLine = text.substring(lineStart, lastLoc);
713
			//String lastLine = text.substring(lineStart, lastLoc);
714
			// RAP [if] fm.getLeading() is missing
715
//			int ly = locator.getBaseline(lineHeight - fm.getLeading());
742
			int ly = locator.getBaseline(lineHeight - lineLeading);
716
			int ly = locator.getBaseline(lineHeight - lineLeading);
743
			int lastWidth = lineExtent.x;
717
			int lastWidth = lineExtent.x;
744
			if (isSelectable())
718
			if (isSelectable())
Lines 752-765 Link Here
752
			locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y);
726
			locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y);
753
		}
727
		}
754
		if (oldFont != null) {
728
		if (oldFont != null) {
755
//			gc.setFont(oldFont);
729
			gc.setFont(oldFont);
756
			gcFont = oldFont;
757
		}
730
		}
758
	}
731
	}
759
732
760
// RAP [if] changed method signature and implementation to cope with missing GC
733
	private void computeTextFragments(GC gc) {
761
//	private void computeTextFragments(GC gc) {
762
	private void computeTextFragments(Font font) {
763
		if (textFragments != null)
734
		if (textFragments != null)
764
			return;
735
			return;
765
		ArrayList list = new ArrayList();
736
		ArrayList list = new ArrayList();
Lines 770-777 Link Here
770
			if (loc == 0)
741
			if (loc == 0)
771
				continue;
742
				continue;
772
			String word = text.substring(cursor, loc);
743
			String word = text.substring(cursor, loc);
773
//			Point extent = gc.textExtent(word);
744
			Point extent = gc.textExtent(word);
774
			Point extent = Graphics.stringExtent( font, word );
775
			list.add(new TextFragment((short) loc, (short) extent.x));
745
			list.add(new TextFragment((short) loc, (short) extent.x));
776
			cursor = loc;
746
			cursor = loc;
777
		}
747
		}
(-)src/org/eclipse/ui/internal/forms/widgets/Paragraph.java (-19 / +7 lines)
Lines 16-23 Link Here
16
import java.util.Vector;
16
import java.util.Vector;
17
17
18
import org.eclipse.swt.graphics.*;
18
import org.eclipse.swt.graphics.*;
19
// RAP [if] GC not supported
20
//import org.eclipse.swt.graphics.GC;
21
import org.eclipse.ui.forms.HyperlinkSettings;
19
import org.eclipse.ui.forms.HyperlinkSettings;
22
20
23
/**
21
/**
Lines 115-123 Link Here
115
		addSegment(hs);
113
		addSegment(hs);
116
	}
114
	}
117
115
118
// RAP [if] changed method signature and implementation to cope with missing GC
116
	protected void computeRowHeights(GC gc, int width, Locator loc,	
119
//	protected void computeRowHeights(GC gc, int width, Locator loc,
120
	protected void computeRowHeights(Font font, int width, Locator loc,
121
			int lineHeight, Hashtable resourceTable) {
117
			int lineHeight, Hashtable resourceTable) {
122
		ParagraphSegment[] segments = getSegments();
118
		ParagraphSegment[] segments = getSegments();
123
		// compute heights
119
		// compute heights
Lines 128-144 Link Here
128
		int innerWidth = width - loc.marginWidth*2;
124
		int innerWidth = width - loc.marginWidth*2;
129
		for (int j = 0; j < segments.length; j++) {
125
		for (int j = 0; j < segments.length; j++) {
130
			ParagraphSegment segment = segments[j];
126
			ParagraphSegment segment = segments[j];
131
//			segment.advanceLocator(gc, innerWidth, hloc, resourceTable, true);
127
			segment.advanceLocator(gc, innerWidth, hloc, resourceTable, true);
132
			segment.advanceLocator(font, innerWidth, hloc, resourceTable, true);
133
		}
128
		}
134
		hloc.collectHeights();
129
		hloc.collectHeights();
135
		loc.heights = heights;
130
		loc.heights = heights;
136
		loc.rowCounter = 0;
131
		loc.rowCounter = 0;
137
	}
132
	}
138
133
139
// RAP [if] changed method signature and implementation to cope with missing GC
134
	public void layout(GC gc, int width, Locator loc, int lineHeight,	
140
//	public void layout(GC gc, int width, Locator loc, int lineHeight,
141
	public void layout(Font font, int width, Locator loc, int lineHeight,
142
			Hashtable resourceTable, IHyperlinkSegment selectedLink) {
135
			Hashtable resourceTable, IHyperlinkSegment selectedLink) {
143
		ParagraphSegment[] segments = getSegments();
136
		ParagraphSegment[] segments = getSegments();
144
		//int height;
137
		//int height;
Lines 150-164 Link Here
150
			*/
143
			*/
151
			// compute heights
144
			// compute heights
152
			if (loc.heights == null)
145
			if (loc.heights == null)
153
//				computeRowHeights(gc, width, loc, lineHeight, resourceTable);
146
				computeRowHeights(gc, width, loc, lineHeight, resourceTable);			    
154
			    computeRowHeights(font, width, loc, lineHeight, resourceTable);
155
			for (int j = 0; j < segments.length; j++) {
147
			for (int j = 0; j < segments.length; j++) {
156
				ParagraphSegment segment = segments[j];
148
				ParagraphSegment segment = segments[j];
157
				boolean doSelect = false;
149
				boolean doSelect = false;
158
				if (selectedLink != null && segment.equals(selectedLink))
150
				if (selectedLink != null && segment.equals(selectedLink))
159
					doSelect = true;
151
					doSelect = true;
160
//				segment.layout(gc, width, loc, resourceTable, doSelect);
152
				segment.layout(gc, width, loc, resourceTable, doSelect);				
161
				segment.layout(font, width, loc, resourceTable, doSelect);
162
			}
153
			}
163
			loc.heights = null;
154
			loc.heights = null;
164
			loc.y += loc.rowHeight;
155
			loc.y += loc.rowHeight;
Lines 184-192 Link Here
184
//		}
175
//		}
185
//	}
176
//	}
186
177
187
// RAP [if] changed method signature and implementation to cope with missing GC
178
	public void computeSelection(GC gc,	Hashtable resourceTable, IHyperlinkSegment selectedLink,	
188
//	public void computeSelection(GC gc,	Hashtable resourceTable, IHyperlinkSegment selectedLink,
189
	public void computeSelection(Font font, Hashtable resourceTable, IHyperlinkSegment selectedLink,
190
			SelectionData selData) {
179
			SelectionData selData) {
191
		ParagraphSegment[] segments = getSegments();
180
		ParagraphSegment[] segments = getSegments();
192
181
Lines 195-202 Link Here
195
			//boolean doSelect = false;
184
			//boolean doSelect = false;
196
			//if (selectedLink != null && segment.equals(selectedLink))
185
			//if (selectedLink != null && segment.equals(selectedLink))
197
				//doSelect = true;
186
				//doSelect = true;
198
//			segment.computeSelection(gc, resourceTable, selData);
187
			segment.computeSelection(gc, resourceTable, selData);
199
			segment.computeSelection(font, resourceTable, selData);
200
		}
188
		}
201
	}
189
	}
202
190
(-)src/org/eclipse/ui/internal/forms/widgets/BulletParagraph.java (-18 / +10 lines)
Lines 13-24 Link Here
13
import java.util.Hashtable;
13
import java.util.Hashtable;
14
14
15
import org.eclipse.rwt.Adaptable;
15
import org.eclipse.rwt.Adaptable;
16
import org.eclipse.rwt.graphics.Graphics;
17
// RAP [if] unnecessary
16
// RAP [if] unnecessary
18
//import org.eclipse.swt.graphics.Color;
17
//import org.eclipse.swt.graphics.Color;
19
// RAP [if] GC not supported
18
import org.eclipse.swt.graphics.GC;
20
//import org.eclipse.swt.graphics.GC;
19
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.swt.graphics.*;
20
import org.eclipse.swt.graphics.Point;
21
import org.eclipse.swt.graphics.Rectangle;
22
import org.eclipse.ui.forms.internal.widgets.IBulletParagraphAdapter;
22
import org.eclipse.ui.forms.internal.widgets.IBulletParagraphAdapter;
23
23
24
public class BulletParagraph extends Paragraph implements Adaptable {
24
public class BulletParagraph extends Paragraph implements Adaptable {
Lines 105-120 Link Here
105
		return text;
105
		return text;
106
	}
106
	}
107
107
108
// RAP [if] changed method signature and implementation to cope with missing GC
108
	public void layout(GC gc, int width, Locator loc, int lineHeight,	
109
//	public void layout(GC gc, int width, Locator loc, int lineHeight,
110
	public void layout(Font font, int width, Locator loc, int lineHeight,
111
			Hashtable resourceTable, IHyperlinkSegment selectedLink) {
109
			Hashtable resourceTable, IHyperlinkSegment selectedLink) {
112
//		computeRowHeights(gc, width, loc, lineHeight, resourceTable);
110
		computeRowHeights(gc, width, loc, lineHeight, resourceTable);
113
//		layoutBullet(gc, loc, lineHeight, resourceTable);
111
		layoutBullet(gc, loc, lineHeight, resourceTable);
114
//		super.layout(gc, width, loc, lineHeight, resourceTable, selectedLink);
112
		super.layout(gc, width, loc, lineHeight, resourceTable, selectedLink);		
115
		computeRowHeights(font, width, loc, lineHeight, resourceTable);
116
        layoutBullet(font, loc, lineHeight, resourceTable);
117
        super.layout(font, width, loc, lineHeight, resourceTable, selectedLink);
118
	}
113
	}
119
114
120
// RAP [if] paint unnecessary
115
// RAP [if] paint unnecessary
Lines 125-133 Link Here
125
//		super.paint(gc, repaintRegion, resourceTable, selectedLink, selData);
120
//		super.paint(gc, repaintRegion, resourceTable, selectedLink, selData);
126
//	}
121
//	}
127
122
128
// RAP [if] changed method signature and implementation to cope with missing GC
123
	private void layoutBullet(GC gc, Locator loc, int lineHeight,
129
//	private void layoutBullet(GC gc, Locator loc, int lineHeight,
130
	private void layoutBullet(Font font, Locator loc, int lineHeight,
131
			Hashtable resourceTable) {
124
			Hashtable resourceTable) {
132
		int x = loc.x - getIndent() + getBulletIndent();
125
		int x = loc.x - getIndent() + getBulletIndent();
133
		int rowHeight = ((int[]) loc.heights.get(0))[0];
126
		int rowHeight = ((int[]) loc.heights.get(0))[0];
Lines 136-143 Link Here
136
			bbounds = new Rectangle(x, y, CIRCLE_DIAM, CIRCLE_DIAM);
129
			bbounds = new Rectangle(x, y, CIRCLE_DIAM, CIRCLE_DIAM);
137
		} else if (style == TEXT && text != null) {
130
		} else if (style == TEXT && text != null) {
138
			//int height = gc.getFontMetrics().getHeight();
131
			//int height = gc.getFontMetrics().getHeight();
139
//			Point textSize = gc.textExtent(text);
132
			Point textSize = gc.textExtent(text);
140
		    Point textSize = Graphics.stringExtent( font, text );
141
			bbounds = new Rectangle(x, loc.y, textSize.x, textSize.y);
133
			bbounds = new Rectangle(x, loc.y, textSize.x, textSize.y);
142
		} else if (style == IMAGE && text != null) {
134
		} else if (style == IMAGE && text != null) {
143
			Image image = (Image) resourceTable.get(text);
135
			Image image = (Image) resourceTable.get(text);
(-)src/org/eclipse/ui/internal/forms/widgets/ObjectSegment.java (-9 / +3 lines)
Lines 46-54 Link Here
46
46
47
	protected abstract Point getObjectSize(Hashtable resourceTable, int wHint);
47
	protected abstract Point getObjectSize(Hashtable resourceTable, int wHint);
48
48
49
// RAP [if] changed method signature and implementation to cope with missing GC
49
	public boolean advanceLocator(GC gc, int wHint, Locator loc,
50
//	public boolean advanceLocator(GC gc, int wHint, Locator loc,
51
	public boolean advanceLocator(Font font, int wHint, Locator loc,
52
			Hashtable objectTable, boolean computeHeightOnly) {
50
			Hashtable objectTable, boolean computeHeightOnly) {
53
		Point objectSize = getObjectSize(objectTable, wHint);
51
		Point objectSize = getObjectSize(objectTable, wHint);
54
		int iwidth = 0;
52
		int iwidth = 0;
Lines 115-123 Link Here
115
	/* (non-Javadoc)
113
	/* (non-Javadoc)
116
	 * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#layout(org.eclipse.swt.graphics.GC, int, org.eclipse.ui.internal.forms.widgets.Locator, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData)
114
	 * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#layout(org.eclipse.swt.graphics.GC, int, org.eclipse.ui.internal.forms.widgets.Locator, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData)
117
	 */
115
	 */
118
// RAP [if] changed method signature and implementation to cope with missing GC
116
	public void layout(GC gc, int width, Locator loc, Hashtable resourceTable,
119
//	public void layout(GC gc, int width, Locator loc, Hashtable resourceTable,
120
	public void layout(Font font, int width, Locator loc, Hashtable resourceTable,
121
			boolean selected) {
117
			boolean selected) {
122
		Point size = getObjectSize(resourceTable, width);
118
		Point size = getObjectSize(resourceTable, width);
123
119
Lines 149-157 Link Here
149
	/* (non-Javadoc)
145
	/* (non-Javadoc)
150
	 * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#computeSelection(org.eclipse.swt.graphics.GC, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData)
146
	 * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#computeSelection(org.eclipse.swt.graphics.GC, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData)
151
	 */
147
	 */
152
// RAP [if] changed method signature and implementation to cope with missing GC
148
	public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) {
153
//	public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) {
154
	public void computeSelection(Font font, Hashtable resourceTable, SelectionData selData) {
155
		// TODO we should add this to the selection
149
		// TODO we should add this to the selection
156
		// if we want to support rich text
150
		// if we want to support rich text
157
	}
151
	}
(-)src/org/eclipse/ui/internal/forms/widgets/TitleRegion.java (-17 / +15 lines)
Lines 28-35 Link Here
28
//import org.eclipse.swt.events.PaintListener;
28
//import org.eclipse.swt.events.PaintListener;
29
import org.eclipse.swt.graphics.Color;
29
import org.eclipse.swt.graphics.Color;
30
import org.eclipse.swt.graphics.Font;
30
import org.eclipse.swt.graphics.Font;
31
//import org.eclipse.swt.graphics.FontMetrics;
31
import org.eclipse.swt.graphics.FontMetrics;
32
//import org.eclipse.swt.graphics.GC;
32
import org.eclipse.swt.graphics.GC;
33
import org.eclipse.swt.graphics.Image;
33
import org.eclipse.swt.graphics.Image;
34
import org.eclipse.swt.graphics.Point;
34
import org.eclipse.swt.graphics.Point;
35
import org.eclipse.swt.graphics.Rectangle;
35
import org.eclipse.swt.graphics.Rectangle;
Lines 462-475 Link Here
462
	 */
462
	 */
463
	public int getFontHeight() {
463
	public int getFontHeight() {
464
		if (fontHeight == -1) {
464
		if (fontHeight == -1) {
465
			Font font = getFont();
465
			Font font = getFont();		
466
		// RAP [rh] Changes due to different API for text size determination
466
			GC gc = new GC(getDisplay());
467
//			GC gc = new GC(getDisplay());
467
			gc.setFont(font);
468
//			gc.setFont(font);
468
			FontMetrics fm = gc.getFontMetrics();
469
//			FontMetrics fm = gc.getFontMetrics();
469
			fontHeight = fm.getHeight();
470
//			fontHeight = fm.getHeight();
470
			gc.dispose();
471
//			gc.dispose();
472
			fontHeight = Graphics.getCharHeight( font );
473
		}
471
		}
474
		return fontHeight;
472
		return fontHeight;
475
	}
473
	}
Lines 481-494 Link Here
481
	public int getFontBaselineHeight() {
479
	public int getFontBaselineHeight() {
482
		if (fontBaselineHeight == -1) {
480
		if (fontBaselineHeight == -1) {
483
			Font font = getFont();
481
			Font font = getFont();
484
// RAP [rh] Changed text size determination; inaccurate as baseline-height is
482
			GC gc = new GC(getDisplay());
485
//    faked by font-height 
483
			gc.setFont(font);
486
//			GC gc = new GC(getDisplay());
484
			FontMetrics fm = gc.getFontMetrics();
487
//			gc.setFont(font);
485
// RAP [if] FontMetrics#getDescent() is missing; inaccurate as baseline-height
488
//			FontMetrics fm = gc.getFontMetrics();
486
// is faked by font-height
489
//			fontBaselineHeight = fm.getHeight() - fm.getDescent();
487
//			fontBaselineHeight = fm.getHeight() - fm.getDescent();
490
//			gc.dispose();
488
			fontBaselineHeight = fm.getHeight();
491
      fontBaselineHeight = Graphics.getCharHeight( font );
489
			gc.dispose();
492
		}
490
		}
493
		return fontBaselineHeight;
491
		return fontBaselineHeight;
494
	}
492
	}
(-)src/org/eclipse/ui/internal/forms/widgets/ParagraphSegment.java (-11 / +4 lines)
Lines 13-20 Link Here
13
import java.util.Hashtable;
13
import java.util.Hashtable;
14
14
15
import org.eclipse.swt.graphics.*;
15
import org.eclipse.swt.graphics.*;
16
// RAP [if] GC not supported
16
import org.eclipse.swt.graphics.GC;
17
//import org.eclipse.swt.graphics.GC;
18
17
19
/**
18
/**
20
 * @version 	1.0
19
 * @version 	1.0
Lines 30-38 Link Here
30
	 * @param computeHeightOnly
29
	 * @param computeHeightOnly
31
	 * @return <code>true</code> if text wrapped to the new line, <code>false</code> otherwise.
30
	 * @return <code>true</code> if text wrapped to the new line, <code>false</code> otherwise.
32
	 */
31
	 */
33
// RAP [if] changed method signature and implementation to cope with missing GC
32
	public abstract boolean advanceLocator(GC gc, int wHint, Locator loc, Hashtable objectTable, boolean computeHeightOnly);	
34
//	public abstract boolean advanceLocator(GC gc, int wHint, Locator loc, Hashtable objectTable, boolean computeHeightOnly);
35
	public abstract boolean advanceLocator(Font font, int wHint, Locator loc, Hashtable objectTable, boolean computeHeightOnly);
36
	/**
33
	/**
37
	 * Computes bounding rectangles and row heights of this segments.
34
	 * Computes bounding rectangles and row heights of this segments.
38
	 * @param gc
35
	 * @param gc
Lines 41-49 Link Here
41
	 * @param resourceTable
38
	 * @param resourceTable
42
	 * @param selected
39
	 * @param selected
43
	 */
40
	 */
44
// RAP [if] changed method signature and implementation to cope with missing GC
41
	public abstract void layout(GC gc, int width, Locator loc, Hashtable resourceTable, boolean selected);	
45
//	public abstract void layout(GC gc, int width, Locator loc, Hashtable resourceTable, boolean selected);
46
	public abstract void layout(Font font, int width, Locator loc, Hashtable resourceTable, boolean selected);
47
// RAP [if] paint unnecessary
42
// RAP [if] paint unnecessary
48
//	/**
43
//	/**
49
//	 * Paints this segment.
44
//	 * Paints this segment.
Lines 61-69 Link Here
61
	 * @param resourceTable
56
	 * @param resourceTable
62
	 * @param selData
57
	 * @param selData
63
	 */
58
	 */
64
// RAP [if] changed method signature and implementation to cope with missing GC
59
	public abstract void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData);	
65
//	public abstract void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData);
66
	public abstract void computeSelection(Font font, Hashtable resourceTable, SelectionData selData);
67
	/**
60
	/**
68
	 * Tests if the coordinates are contained in one of the
61
	 * Tests if the coordinates are contained in one of the
69
	 * bounding rectangles of this segment.
62
	 * bounding rectangles of this segment.
(-)src/org/eclipse/ui/internal/forms/widgets/AggregateHyperlinkSegment.java (-18 / +7 lines)
Lines 16-24 Link Here
16
// RAP [if] unnecessary
16
// RAP [if] unnecessary
17
//import org.eclipse.swt.graphics.Color;
17
//import org.eclipse.swt.graphics.Color;
18
import org.eclipse.rwt.Adaptable;
18
import org.eclipse.rwt.Adaptable;
19
import org.eclipse.swt.graphics.Font;
19
import org.eclipse.swt.graphics.GC;
20
// RAP [if] GC not supported
21
//import org.eclipse.swt.graphics.GC;
22
import org.eclipse.swt.graphics.Rectangle;
20
import org.eclipse.swt.graphics.Rectangle;
23
import org.eclipse.ui.forms.internal.widgets.IAggregateHyperlinkSegmentAdapter;
21
import org.eclipse.ui.forms.internal.widgets.IAggregateHyperlinkSegmentAdapter;
24
22
Lines 72-86 Link Here
72
	 *      int, org.eclipse.ui.internal.forms.widgets.Locator,
70
	 *      int, org.eclipse.ui.internal.forms.widgets.Locator,
73
	 *      java.util.Hashtable, boolean)
71
	 *      java.util.Hashtable, boolean)
74
	 */
72
	 */
75
// RAP [if] changed method signature and implementation to cope with missing GC
73
	public boolean advanceLocator(GC gc, int wHint, Locator loc,
76
//	public boolean advanceLocator(GC gc, int wHint, Locator loc,
77
	public boolean advanceLocator(Font font, int wHint, Locator loc,
78
			Hashtable objectTable, boolean computeHeightOnly) {
74
			Hashtable objectTable, boolean computeHeightOnly) {
79
		boolean newLine = false;
75
		boolean newLine = false;
80
		for (int i = 0; i < segments.size(); i++) {
76
		for (int i = 0; i < segments.size(); i++) {
81
			ParagraphSegment segment = (ParagraphSegment) segments.get(i);
77
			ParagraphSegment segment = (ParagraphSegment) segments.get(i);
82
//			if (segment.advanceLocator(gc, wHint, loc, objectTable,
78
			if (segment.advanceLocator(gc, wHint, loc, objectTable,
83
			if (segment.advanceLocator(font, wHint, loc, objectTable,
84
					computeHeightOnly))
79
					computeHeightOnly))
85
				newLine = true;
80
				newLine = true;
86
		}
81
		}
Lines 189-202 Link Here
189
	 *      java.util.Hashtable, boolean,
184
	 *      java.util.Hashtable, boolean,
190
	 *      org.eclipse.ui.internal.forms.widgets.SelectionData)
185
	 *      org.eclipse.ui.internal.forms.widgets.SelectionData)
191
	 */
186
	 */
192
// RAP [if] changed method signature and implementation to cope with missing GC
187
	public void layout(GC gc, int width, Locator locator,
193
//	public void layout(GC gc, int width, Locator locator,
194
	public void layout(Font font, int width, Locator locator,
195
			Hashtable resourceTable, boolean selected) {
188
			Hashtable resourceTable, boolean selected) {
196
		for (int i = 0; i < segments.size(); i++) {
189
		for (int i = 0; i < segments.size(); i++) {
197
			ParagraphSegment segment = (ParagraphSegment) segments.get(i);
190
			ParagraphSegment segment = (ParagraphSegment) segments.get(i);
198
//			segment.layout(gc, width, locator, resourceTable, selected);
191
			segment.layout(gc, width, locator, resourceTable, selected);
199
			segment.layout(font, width, locator, resourceTable, selected);
200
		}
192
		}
201
	}
193
	}
202
194
Lines 207-220 Link Here
207
	 *      java.util.Hashtable, boolean,
199
	 *      java.util.Hashtable, boolean,
208
	 *      org.eclipse.ui.internal.forms.widgets.SelectionData)
200
	 *      org.eclipse.ui.internal.forms.widgets.SelectionData)
209
	 */
201
	 */
210
// RAP [if] changed method signature and implementation to cope with missing GC
202
	public void computeSelection(GC gc, Hashtable resourceTable,
211
//	public void computeSelection(GC gc, Hashtable resourceTable,
212
	public void computeSelection(Font font, Hashtable resourceTable,
213
			SelectionData selData) {
203
			SelectionData selData) {
214
		for (int i = 0; i < segments.size(); i++) {
204
		for (int i = 0; i < segments.size(); i++) {
215
			ParagraphSegment segment = (ParagraphSegment) segments.get(i);
205
			ParagraphSegment segment = (ParagraphSegment) segments.get(i);
216
//			segment.computeSelection(gc, resourceTable, selData);
206
			segment.computeSelection(gc, resourceTable, selData);
217
			segment.computeSelection(font, resourceTable, selData);
218
		}
207
		}
219
	}
208
	}
220
209
(-)src/org/eclipse/ui/internal/forms/widgets/FormHeading.java (-17 / +14 lines)
Lines 20-26 Link Here
20
import org.eclipse.jface.dialogs.Dialog;
20
import org.eclipse.jface.dialogs.Dialog;
21
import org.eclipse.jface.dialogs.IMessageProvider;
21
import org.eclipse.jface.dialogs.IMessageProvider;
22
import org.eclipse.jface.resource.JFaceResources;
22
import org.eclipse.jface.resource.JFaceResources;
23
import org.eclipse.rwt.graphics.Graphics;
24
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.custom.CLabel;
24
import org.eclipse.swt.custom.CLabel;
26
import org.eclipse.swt.dnd.DragSourceListener;
25
import org.eclipse.swt.dnd.DragSourceListener;
Lines 33-40 Link Here
33
//import org.eclipse.swt.events.MouseTrackListener;
32
//import org.eclipse.swt.events.MouseTrackListener;
34
import org.eclipse.swt.graphics.Color;
33
import org.eclipse.swt.graphics.Color;
35
import org.eclipse.swt.graphics.Font;
34
import org.eclipse.swt.graphics.Font;
36
//import org.eclipse.swt.graphics.FontMetrics;
35
import org.eclipse.swt.graphics.FontMetrics;
37
//import org.eclipse.swt.graphics.GC;
36
import org.eclipse.swt.graphics.GC;
38
import org.eclipse.swt.graphics.Image;
37
import org.eclipse.swt.graphics.Image;
39
import org.eclipse.swt.graphics.Point;
38
import org.eclipse.swt.graphics.Point;
40
import org.eclipse.swt.graphics.Rectangle;
39
import org.eclipse.swt.graphics.Rectangle;
Lines 388-400 Link Here
388
			if (fontHeight == -1) {
387
			if (fontHeight == -1) {
389
				Control c = getMessageControl();
388
				Control c = getMessageControl();
390
				if (c == null)
389
				if (c == null)
391
					return 0;
390
					return 0;				
392
				// RAP [rh] Changes due to different API for text size determination
391
				GC gc = new GC(c.getDisplay());
393
//				GC gc = new GC(c.getDisplay());
392
				gc.setFont(c.getFont());
394
//				gc.setFont(c.getFont());
393
				fontHeight = gc.getFontMetrics().getHeight();
395
//				fontHeight = gc.getFontMetrics().getHeight();
394
				gc.dispose();
396
//				gc.dispose();
397
				fontHeight = Graphics.getCharHeight( c.getFont() );
398
			}
395
			}
399
			return fontHeight;
396
			return fontHeight;
400
		}
397
		}
Lines 404-417 Link Here
404
				Control c = getMessageControl();
401
				Control c = getMessageControl();
405
				if (c == null)
402
				if (c == null)
406
					return 0;
403
					return 0;
407
// RAP [rh] Changed text size determination; inaccurate as baseline-height is
404
				GC gc = new GC(c.getDisplay());
408
//		 faked by font-height
405
				gc.setFont(c.getFont());
409
//				GC gc = new GC(c.getDisplay());
406
				FontMetrics fm = gc.getFontMetrics();
410
//				gc.setFont(c.getFont());
407
// RAP [if] FontMetrics#getDescent() is missing; inaccurate as baseline-height
411
//				FontMetrics fm = gc.getFontMetrics();
408
// is faked by font-height
412
//				fontBaselineHeight = fm.getHeight() - fm.getDescent();
409
//				fontBaselineHeight = fm.getHeight() - fm.getDescent();
413
//				gc.dispose();
410
				fontBaselineHeight = fm.getHeight();
414
				fontBaselineHeight = Graphics.getCharHeight( getFont() );
411
				gc.dispose();
415
			}
412
			}
416
			return fontBaselineHeight;
413
			return fontBaselineHeight;
417
		}
414
		}
(-)src/org/eclipse/ui/internal/forms/widgets/FormUtil.java (-36 / +35 lines)
Lines 11-21 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.ui.internal.forms.widgets;
12
package org.eclipse.ui.internal.forms.widgets;
13
13
14
import org.eclipse.rwt.graphics.Graphics;
15
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.custom.ScrolledComposite;
15
import org.eclipse.swt.custom.ScrolledComposite;
17
import org.eclipse.swt.events.MouseEvent;
16
import org.eclipse.swt.events.MouseEvent;
18
import org.eclipse.swt.graphics.*;
17
//import org.eclipse.swt.graphics.Device;
18
import org.eclipse.swt.graphics.FontMetrics;
19
import org.eclipse.swt.graphics.GC;
20
//import org.eclipse.swt.graphics.Image;
21
//import org.eclipse.swt.graphics.ImageData;
22
import org.eclipse.swt.graphics.Point;
23
import org.eclipse.swt.graphics.Rectangle;
19
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.layout.GridData;
20
//import org.eclipse.swt.widgets.Combo;
25
//import org.eclipse.swt.widgets.Combo;
21
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Composite;
Lines 24-30 Link Here
24
import org.eclipse.swt.widgets.Layout;
29
import org.eclipse.swt.widgets.Layout;
25
//import org.eclipse.swt.widgets.ScrollBar;
30
//import org.eclipse.swt.widgets.ScrollBar;
26
import org.eclipse.swt.widgets.Text;
31
import org.eclipse.swt.widgets.Text;
27
import org.eclipse.ui.forms.widgets.*;
32
import org.eclipse.ui.forms.widgets.ColumnLayout;
33
import org.eclipse.ui.forms.widgets.Form;
34
import org.eclipse.ui.forms.widgets.FormText;
28
import org.eclipse.ui.forms.widgets.FormToolkit;
35
import org.eclipse.ui.forms.widgets.FormToolkit;
29
import org.eclipse.ui.forms.widgets.ILayoutExtension;
36
import org.eclipse.ui.forms.widgets.ILayoutExtension;
30
37
Lines 92-125 Link Here
92
		return text;
99
		return text;
93
	}
100
	}
94
101
95
// RAP [rh] FormUtil#computeMinimumWidth unnecessary
102
	public static int computeMinimumWidth(GC gc, String text) {
96
//	public static int computeMinimumWidth(GC gc, String text) {
103
		BreakIterator wb = BreakIterator.getWordInstance();
97
//		BreakIterator wb = BreakIterator.getWordInstance();
104
		wb.setText(text);
98
//		wb.setText(text);
105
		int last = 0;
99
//		int last = 0;
106
100
//
107
		int width = 0;
101
//		int width = 0;
108
102
//
109
		for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) {
103
//		for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) {
110
			String word = text.substring(last, loc);
104
//			String word = text.substring(last, loc);
111
			Point extent = gc.textExtent(word);
105
//			Point extent = gc.textExtent(word);
112
			width = Math.max(width, extent.x);
106
//			width = Math.max(width, extent.x);
113
			last = loc;
107
//			last = loc;
114
		}
108
//		}
115
		String lastWord = text.substring(last);
109
//		String lastWord = text.substring(last);
116
		Point extent = gc.textExtent(lastWord);
110
//		Point extent = gc.textExtent(lastWord);
117
		width = Math.max(width, extent.x);
111
//		width = Math.max(width, extent.x);
118
		return width;
112
//		return width;
119
	}
113
//	}
114
	
120
	
115
// RAP [rh] changed method signature and implementation to cope with  missing GC
121
	public static Point computeWrapSize(GC gc, String text, int wHint) {	
116
//	public static Point computeWrapSize(GC gc, String text, int wHint) {
117
	public static Point computeWrapSize(Font font, String text, int wHint) {
118
		BreakIterator wb = BreakIterator.getWordInstance();
122
		BreakIterator wb = BreakIterator.getWordInstance();
119
		wb.setText(text);
123
		wb.setText(text);
120
//		FontMetrics fm = gc.getFontMetrics();
124
		FontMetrics fm = gc.getFontMetrics();
121
//		int lineHeight = fm.getHeight();
125
		int lineHeight = fm.getHeight();
122
		int lineHeight = Graphics.getCharHeight( font );
123
		
126
		
124
		int saved = 0;
127
		int saved = 0;
125
		int last = 0;
128
		int last = 0;
Lines 127-142 Link Here
127
		int maxWidth = 0;
130
		int maxWidth = 0;
128
		for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) {
131
		for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) {
129
			String word = text.substring(saved, loc);
132
			String word = text.substring(saved, loc);
130
//			Point extent = gc.textExtent(word);
133
			Point extent = gc.textExtent(word);
131
			Point extent = Graphics.stringExtent( font, word );
132
			if (extent.x > wHint) {
134
			if (extent.x > wHint) {
133
				// overflow
135
				// overflow
134
				saved = last;
136
				saved = last;
135
				height += extent.y;
137
				height += extent.y;
136
				// switch to current word so maxWidth will accommodate very long single words
138
				// switch to current word so maxWidth will accommodate very long single words
137
				word = text.substring(last, loc);
139
				word = text.substring(last, loc);
138
//				extent = gc.textExtent(word);
140
				extent = gc.textExtent(word);
139
				extent = Graphics.stringExtent( font, word );
140
			}
141
			}
141
			maxWidth = Math.max(maxWidth, extent.x);
142
			maxWidth = Math.max(maxWidth, extent.x);
142
			last = loc;
143
			last = loc;
Lines 146-155 Link Here
146
		 * The recursive call proved to be the only thing that worked in all cases. Some attempts can be made
147
		 * The recursive call proved to be the only thing that worked in all cases. Some attempts can be made
147
		 * to estimate the height, but the algorithm needs to be run again to be sure.
148
		 * to estimate the height, but the algorithm needs to be run again to be sure.
148
		 */
149
		 */
149
//		if (maxWidth > wHint)
150
		if (maxWidth > wHint)
150
//			return computeWrapSize(gc, text, maxWidth);
151
			return computeWrapSize(gc, text, maxWidth);		  
151
		  if (maxWidth > wHint)
152
	 	    return computeWrapSize(font, text, maxWidth);
153
		return new Point(maxWidth, height);
152
		return new Point(maxWidth, height);
154
	}
153
	}
155
154
(-)src/org/eclipse/ui/internal/forms/widgets/PixelConverter.java (-37 / +37 lines)
Lines 1-37 Link Here
1
///*******************************************************************************
1
/*******************************************************************************
2
// * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
// * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
// * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
// * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
// * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
// *
7
 *
8
// * Contributors:
8
 * Contributors:
9
// *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
// *******************************************************************************/
10
 *******************************************************************************/
11
//package org.eclipse.ui.internal.forms.widgets;
11
package org.eclipse.ui.internal.forms.widgets;
12
//
12
13
//import org.eclipse.swt.graphics.FontMetrics;
13
import org.eclipse.swt.graphics.FontMetrics;
14
//import org.eclipse.swt.graphics.GC;
14
import org.eclipse.swt.graphics.GC;
15
//import org.eclipse.swt.widgets.Control;
15
import org.eclipse.swt.widgets.Control;
16
//
16
17
//public class PixelConverter {
17
public class PixelConverter {
18
//	/**
18
	/**
19
//	 * Number of horizontal dialog units per character, value <code>4</code>.
19
	 * Number of horizontal dialog units per character, value <code>4</code>.
20
//	 */
20
	 */
21
//	private static final int HORIZONTAL_DIALOG_UNIT_PER_CHAR = 4;
21
	private static final int HORIZONTAL_DIALOG_UNIT_PER_CHAR = 4;
22
//
22
23
//	private FontMetrics fFontMetrics;
23
	private FontMetrics fFontMetrics;
24
//
24
25
//	public PixelConverter(Control control) {
25
	public PixelConverter(Control control) {
26
//		GC gc = new GC(control);
26
		GC gc = new GC(control);
27
//		gc.setFont(control.getFont());
27
		gc.setFont(control.getFont());
28
//		fFontMetrics = gc.getFontMetrics();
28
		fFontMetrics = gc.getFontMetrics();
29
//		gc.dispose();
29
		gc.dispose();
30
//	}
30
	}
31
//
31
32
//	public int convertHorizontalDLUsToPixels(int dlus) {
32
	public int convertHorizontalDLUsToPixels(int dlus) {
33
//		// round to the nearest pixel
33
		// round to the nearest pixel
34
//		return (fFontMetrics.getAverageCharWidth() * dlus + HORIZONTAL_DIALOG_UNIT_PER_CHAR / 2)
34
		return (fFontMetrics.getAverageCharWidth() * dlus + HORIZONTAL_DIALOG_UNIT_PER_CHAR / 2)
35
//				/ HORIZONTAL_DIALOG_UNIT_PER_CHAR;
35
				/ HORIZONTAL_DIALOG_UNIT_PER_CHAR;
36
//	}
36
	}
37
//}
37
}
(-)src/org/eclipse/ui/internal/forms/widgets/BreakSegment.java (-20 / +9 lines)
Lines 12-22 Link Here
12
12
13
import java.util.Hashtable;
13
import java.util.Hashtable;
14
14
15
//RAP [if] GC/FontMetrics not supported
15
import org.eclipse.swt.graphics.FontMetrics;
16
//import org.eclipse.swt.graphics.FontMetrics;
16
import org.eclipse.swt.graphics.GC;
17
//import org.eclipse.swt.graphics.GC;
18
import org.eclipse.rwt.graphics.Graphics;
19
import org.eclipse.swt.graphics.Font;
20
import org.eclipse.swt.graphics.Rectangle;
17
import org.eclipse.swt.graphics.Rectangle;
21
18
22
/**
19
/**
Lines 28-41 Link Here
28
	/* (non-Javadoc)
25
	/* (non-Javadoc)
29
	 * @see org.eclipse.ui.forms.internal.widgets.ParagraphSegment#advanceLocator(org.eclipse.swt.graphics.GC, int, org.eclipse.ui.forms.internal.widgets.Locator, java.util.Hashtable)
26
	 * @see org.eclipse.ui.forms.internal.widgets.ParagraphSegment#advanceLocator(org.eclipse.swt.graphics.GC, int, org.eclipse.ui.forms.internal.widgets.Locator, java.util.Hashtable)
30
	 */
27
	 */
31
// RAP [if] changed method signature and implementation to cope with missing GC
28
	public boolean advanceLocator(GC gc, int wHint, Locator locator,
32
//	public boolean advanceLocator(GC gc, int wHint, Locator locator,
33
  public boolean advanceLocator(Font font, int wHint, Locator locator,
34
			Hashtable objectTable, boolean computeHeightOnly) {
29
			Hashtable objectTable, boolean computeHeightOnly) {
35
		if (locator.rowHeight==0) {
30
		if (locator.rowHeight==0) {
36
//			FontMetrics fm = gc.getFontMetrics();
31
			FontMetrics fm = gc.getFontMetrics();
37
//			locator.rowHeight = fm.getHeight();
32
			locator.rowHeight = fm.getHeight();
38
		    locator.rowHeight = Graphics.getCharHeight( font );
39
		}
33
		}
40
		if (computeHeightOnly) locator.collectHeights();
34
		if (computeHeightOnly) locator.collectHeights();
41
		locator.x = locator.indent;
35
		locator.x = locator.indent;
Lines 58-72 Link Here
58
	/* (non-Javadoc)
52
	/* (non-Javadoc)
59
	 * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#layout(org.eclipse.swt.graphics.GC, int, org.eclipse.ui.internal.forms.widgets.Locator, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData)
53
	 * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#layout(org.eclipse.swt.graphics.GC, int, org.eclipse.ui.internal.forms.widgets.Locator, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData)
60
	 */
54
	 */
61
// RAP [if] changed method signature and implementation to cope with missing GC
55
	public void layout(GC gc, int width, Locator locator, Hashtable ResourceTable,
62
//	public void layout(GC gc, int width, Locator locator, Hashtable ResourceTable,
63
	public void layout(Font font, int width, Locator locator, Hashtable ResourceTable,
64
			boolean selected) {
56
			boolean selected) {
65
		locator.resetCaret();
57
		locator.resetCaret();
66
		if (locator.rowHeight==0) {
58
		if (locator.rowHeight==0) {
67
//			FontMetrics fm = gc.getFontMetrics();
59
			FontMetrics fm = gc.getFontMetrics();
68
//			locator.rowHeight = fm.getHeight();
60
			locator.rowHeight = fm.getHeight();
69
		    locator.rowHeight = Graphics.getCharHeight( font );
70
		}
61
		}
71
		locator.y += locator.rowHeight;
62
		locator.y += locator.rowHeight;
72
		locator.rowHeight = 0;
63
		locator.rowHeight = 0;
Lines 76-84 Link Here
76
	/* (non-Javadoc)
67
	/* (non-Javadoc)
77
	 * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#computeSelection(org.eclipse.swt.graphics.GC, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData)
68
	 * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#computeSelection(org.eclipse.swt.graphics.GC, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData)
78
	 */
69
	 */
79
// RAP [if] changed method signature and implementation to cope with missing GC
70
	public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) {
80
//	public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) {
81
	public void computeSelection(Font font, Hashtable resourceTable, SelectionData selData) {
82
		selData.markNewLine();
71
		selData.markNewLine();
83
	}
72
	}
84
}
73
}
(-)src/org/eclipse/ui/forms/widgets/FormText.java (-31 / +22 lines)
Lines 16-22 Link Here
16
import java.util.Hashtable;
16
import java.util.Hashtable;
17
17
18
import org.eclipse.core.runtime.ListenerList;
18
import org.eclipse.core.runtime.ListenerList;
19
import org.eclipse.rwt.graphics.Graphics;
20
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWTException;
20
import org.eclipse.swt.SWTException;
22
// RAP [if] accessibility not supported
21
// RAP [if] accessibility not supported
Lines 52-60 Link Here
52
import org.eclipse.swt.events.SelectionListener;
51
import org.eclipse.swt.events.SelectionListener;
53
import org.eclipse.swt.graphics.Color;
52
import org.eclipse.swt.graphics.Color;
54
import org.eclipse.swt.graphics.Font;
53
import org.eclipse.swt.graphics.Font;
55
// RAP [if] GC/FontMetrics not supported
54
import org.eclipse.swt.graphics.FontMetrics;
56
//import org.eclipse.swt.graphics.FontMetrics;
55
import org.eclipse.swt.graphics.GC;
57
//import org.eclipse.swt.graphics.GC;
58
import org.eclipse.swt.graphics.Image;
56
import org.eclipse.swt.graphics.Image;
59
import org.eclipse.swt.graphics.Point;
57
import org.eclipse.swt.graphics.Point;
60
import org.eclipse.swt.graphics.Rectangle;
58
import org.eclipse.swt.graphics.Rectangle;
Lines 272-287 Link Here
272
			return result;
270
			return result;
273
		}
271
		}
274
272
275
// RAP [if] changed implementation to cope with missing GC
276
		private Point computeTextSize(int wHint) {
273
		private Point computeTextSize(int wHint) {
277
			Paragraph[] paragraphs = model.getParagraphs();
274
			Paragraph[] paragraphs = model.getParagraphs();
278
//			GC gc = new GC(FormText.this);
275
			GC gc = new GC(FormText.this);
279
//			gc.setFont(getFont());
276
			gc.setFont(getFont());
280
			Locator loc = new Locator();
277
			Locator loc = new Locator();
281
			int width = wHint != SWT.DEFAULT ? wHint : 0;
278
			int width = wHint != SWT.DEFAULT ? wHint : 0;
282
//			FontMetrics fm = gc.getFontMetrics();
279
			FontMetrics fm = gc.getFontMetrics();
283
//			int lineHeight = fm.getHeight();
280
			int lineHeight = fm.getHeight();
284
			int lineHeight = Graphics.getCharHeight( getFont() );
285
			boolean selectableInTheLastRow = false;
281
			boolean selectableInTheLastRow = false;
286
			for (int i = 0; i < paragraphs.length; i++) {
282
			for (int i = 0; i < paragraphs.length; i++) {
287
				Paragraph p = paragraphs[i];
283
				Paragraph p = paragraphs[i];
Lines 297-304 Link Here
297
					int pwidth = 0;
293
					int pwidth = 0;
298
					for (int j = 0; j < segments.length; j++) {
294
					for (int j = 0; j < segments.length; j++) {
299
						ParagraphSegment segment = segments[j];
295
						ParagraphSegment segment = segments[j];
300
//						segment.advanceLocator(gc, wHint, loc, resourceTable,
296
						segment.advanceLocator(gc, wHint, loc, resourceTable,						
301
						segment.advanceLocator(getFont(), wHint, loc, resourceTable,
302
								false);
297
								false);
303
						if (wHint != SWT.DEFAULT) {
298
						if (wHint != SWT.DEFAULT) {
304
							width = Math.max(width, loc.width);
299
							width = Math.max(width, loc.width);
Lines 316-328 Link Here
316
					loc.y += lineHeight;
311
					loc.y += lineHeight;
317
				}
312
				}
318
			}
313
			}
319
//			gc.dispose();
314
			gc.dispose();
320
			if (selectableInTheLastRow)
315
			if (selectableInTheLastRow)
321
				loc.y += 1;
316
				loc.y += 1;
322
			return new Point(width, loc.y);
317
			return new Point(width, loc.y);
323
		}
318
		}
324
319
325
// RAP [if] changed implementation to cope with missing GC
326
		protected void layout(Composite composite, boolean flushCache) {
320
		protected void layout(Composite composite, boolean flushCache) {
327
  		    // RAP [if] Instruct LCA to relayout the segments to the client
321
  		    // RAP [if] Instruct LCA to relayout the segments to the client
328
		    model.clearCache( null );
322
		    model.clearCache( null );
Lines 339-358 Link Here
339
				System.out.println("FormText layout ("+model.getAccessibleText()+"), carea="+carea); //$NON-NLS-1$ //$NON-NLS-2$
333
				System.out.println("FormText layout ("+model.getAccessibleText()+"), carea="+carea); //$NON-NLS-1$ //$NON-NLS-2$
340
			}
334
			}
341
335
342
//			GC gc = new GC(composite);
336
			GC gc = new GC(composite);
343
//			gc.setFont(getFont());
337
			gc.setFont(getFont());
344
			ensureBoldFontPresent(getFont());
338
			ensureBoldFontPresent(getFont());
345
//			gc.setForeground(getForeground());
339
			gc.setForeground(getForeground());
346
//			gc.setBackground(getBackground());
340
			gc.setBackground(getBackground());
347
341
348
			Locator loc = new Locator();
342
			Locator loc = new Locator();
349
			loc.marginWidth = marginWidth;
343
			loc.marginWidth = marginWidth;
350
			loc.marginHeight = marginHeight;
344
			loc.marginHeight = marginHeight;
351
			loc.x = marginWidth;
345
			loc.x = marginWidth;
352
			loc.y = marginHeight;
346
			loc.y = marginHeight;
353
//			FontMetrics fm = gc.getFontMetrics();
347
			FontMetrics fm = gc.getFontMetrics();
354
//			int lineHeight = fm.getHeight();
348
			int lineHeight = fm.getHeight();
355
			int lineHeight = Graphics.getCharHeight( getFont() );
356
349
357
			Paragraph[] paragraphs = model.getParagraphs();
350
			Paragraph[] paragraphs = model.getParagraphs();
358
			IHyperlinkSegment selectedLink = getSelectedLink();
351
			IHyperlinkSegment selectedLink = getSelectedLink();
Lines 363-373 Link Here
363
				loc.indent = p.getIndent();
356
				loc.indent = p.getIndent();
364
				loc.resetCaret();
357
				loc.resetCaret();
365
				loc.rowHeight = 0;
358
				loc.rowHeight = 0;
366
//				p.layout(gc, carea.width, loc, lineHeight, resourceTable,
359
				p.layout(gc, carea.width, loc, lineHeight, resourceTable,				
367
				p.layout(getFont(), carea.width, loc, lineHeight, resourceTable,
368
						selectedLink);
360
						selectedLink);
369
			}
361
			}
370
//			gc.dispose();
362
			gc.dispose();
371
			if (DEBUG_TEXT) {
363
			if (DEBUG_TEXT) {
372
				long stop = System.currentTimeMillis();
364
				long stop = System.currentTimeMillis();
373
				System.out.println("FormText.layout: " + (stop - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
365
				System.out.println("FormText.layout: " + (stop - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
Lines 1064-1071 Link Here
1064
	 * @since 3.1
1056
	 * @since 3.1
1065
	 */
1057
	 */
1066
	public void addSelectionListener(SelectionListener listener) {
1058
	public void addSelectionListener(SelectionListener listener) {
1059
	    checkWidget();
1067
// RAP [if]
1060
// RAP [if]
1068
//		checkWidget();
1069
//		if (listener == null) {
1061
//		if (listener == null) {
1070
//			SWT.error(SWT.ERROR_NULL_ARGUMENT);
1062
//			SWT.error(SWT.ERROR_NULL_ARGUMENT);
1071
//		}
1063
//		}
Lines 1094-1101 Link Here
1094
	 * @since 3.1
1086
	 * @since 3.1
1095
	 */
1087
	 */
1096
	public void removeSelectionListener(SelectionListener listener) {
1088
	public void removeSelectionListener(SelectionListener listener) {
1097
// RAP [if]
1089
	    checkWidget();
1098
//		checkWidget();
1090
// RAP [if]		
1099
//		if (listener == null) {
1091
//		if (listener == null) {
1100
//			SWT.error(SWT.ERROR_NULL_ARGUMENT);
1092
//			SWT.error(SWT.ERROR_NULL_ARGUMENT);
1101
//		}
1093
//		}
Lines 1350-1356 Link Here
1350
	}
1342
	}
1351
1343
1352
	private void computeSelection() {
1344
	private void computeSelection() {
1353
//		GC gc = new GC(this);
1345
		GC gc = new GC(this);
1354
		Paragraph[] paragraphs = model.getParagraphs();
1346
		Paragraph[] paragraphs = model.getParagraphs();
1355
		IHyperlinkSegment selectedLink = getSelectedLink();
1347
		IHyperlinkSegment selectedLink = getSelectedLink();
1356
		if (getDisplay().getFocusControl() != this)
1348
		if (getDisplay().getFocusControl() != this)
Lines 1359-1368 Link Here
1359
			Paragraph p = paragraphs[i];
1351
			Paragraph p = paragraphs[i];
1360
			if (i > 0)
1352
			if (i > 0)
1361
				selData.markNewLine();
1353
				selData.markNewLine();
1362
//			p.computeSelection(gc, resourceTable, selectedLink, selData);
1354
			p.computeSelection(gc, resourceTable, selectedLink, selData);
1363
			p.computeSelection(getFont(), resourceTable, selectedLink, selData);
1364
		}
1355
		}
1365
//		gc.dispose();
1356
		gc.dispose();
1366
	}
1357
	}
1367
1358
1368
	void clearSelection() {
1359
	void clearSelection() {
(-)src/org/eclipse/ui/forms/widgets/ExpandableComposite.java (-16 / +9 lines)
Lines 13-19 Link Here
13
13
14
import org.eclipse.core.runtime.Assert;
14
import org.eclipse.core.runtime.Assert;
15
import org.eclipse.core.runtime.ListenerList;
15
import org.eclipse.core.runtime.ListenerList;
16
import org.eclipse.rwt.graphics.Graphics;
17
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.SWT;
18
//import org.eclipse.swt.events.FocusEvent;
17
//import org.eclipse.swt.events.FocusEvent;
19
//import org.eclipse.swt.events.FocusListener;
18
//import org.eclipse.swt.events.FocusListener;
Lines 25-32 Link Here
25
//import org.eclipse.swt.events.TraverseListener;
24
//import org.eclipse.swt.events.TraverseListener;
26
import org.eclipse.swt.graphics.Color;
25
import org.eclipse.swt.graphics.Color;
27
import org.eclipse.swt.graphics.Font;
26
import org.eclipse.swt.graphics.Font;
28
//import org.eclipse.swt.graphics.FontMetrics;
27
import org.eclipse.swt.graphics.FontMetrics;
29
//import org.eclipse.swt.graphics.GC;
28
import org.eclipse.swt.graphics.GC;
30
import org.eclipse.swt.graphics.Point;
29
import org.eclipse.swt.graphics.Point;
31
import org.eclipse.swt.graphics.Rectangle;
30
import org.eclipse.swt.graphics.Rectangle;
32
import org.eclipse.swt.widgets.Canvas;
31
import org.eclipse.swt.widgets.Canvas;
Lines 268-276 Link Here
268
					if (twidth < size.x + IGAP + tcsize.x) {
267
					if (twidth < size.x + IGAP + tcsize.x) {
269
						twidth -= IGAP;
268
						twidth -= IGAP;
270
						if (textLabel instanceof Label)
269
						if (textLabel instanceof Label)
271
// RAP [rh] Changes due to differences in text size determination
270
							size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x))));  						
272
//							size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x))));
273
  						size = FormUtil.computeWrapSize(textLabel.getFont(), ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x))));
274
						else
271
						else
275
							size = textLabelCache.computeSize(Math.round(twidth*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT);
272
							size = textLabelCache.computeSize(Math.round(twidth*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT);
276
						tcsize = textClientCache.computeSize(twidth-size.x, SWT.DEFAULT);
273
						tcsize = textClientCache.computeSize(twidth-size.x, SWT.DEFAULT);
Lines 291-303 Link Here
291
				}
288
				}
292
			}
289
			}
293
			if (toggle != null) {
290
			if (toggle != null) {
294
// RAP [rh] Chnages due to different text size calcuation
291
				GC gc = new GC(ExpandableComposite.this);
295
//				GC gc = new GC(ExpandableComposite.this);
292
				gc.setFont(getFont());
296
//				gc.setFont(getFont());
293
				FontMetrics fm = gc.getFontMetrics();
297
//				FontMetrics fm = gc.getFontMetrics();
294
				int textHeight = fm.getHeight();
298
//				int textHeight = fm.getHeight();
295
				gc.dispose();			  
299
//				gc.dispose();
300
			  int textHeight = Graphics.getCharHeight( getFont() );
301
				if (textClient != null
296
				if (textClient != null
302
						&& (expansionStyle & LEFT_TEXT_CLIENT_ALIGNMENT) != 0) {
297
						&& (expansionStyle & LEFT_TEXT_CLIENT_ALIGNMENT) != 0) {
303
					textHeight = Math.max(textHeight, tcsize.y);
298
					textHeight = Math.max(textHeight, tcsize.y);
Lines 412-420 Link Here
412
					if (innertHint != SWT.DEFAULT && innertHint < size.x + IGAP + tcsize.x) {
407
					if (innertHint != SWT.DEFAULT && innertHint < size.x + IGAP + tcsize.x) {
413
						innertHint -= IGAP;
408
						innertHint -= IGAP;
414
						if (textLabel instanceof Label)
409
						if (textLabel instanceof Label)
415
// RAP [rh] Changes due to differences in text size calculation
410
							size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))));  						
416
//							size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))));
417
  						size = FormUtil.computeWrapSize(textLabel.getFont(), ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))));
418
						else
411
						else
419
							size = textLabelCache.computeSize(Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT);
412
							size = textLabelCache.computeSize(Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT);
420
						tcsize = textClientCache.computeSize(innertHint-size.x, SWT.DEFAULT);
413
						tcsize = textClientCache.computeSize(innertHint-size.x, SWT.DEFAULT);

Return to bug 303883