View | Details | Raw Unified | Return to bug 171276 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/forms/widgets/FormUtil.java (-4 / +12 lines)
Lines 130-136 Link Here
130
		int last = 0;
130
		int last = 0;
131
		int height = lineHeight;
131
		int height = lineHeight;
132
		int maxWidth = 0;
132
		int maxWidth = 0;
133
134
		for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) {
133
		for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) {
135
			String word = text.substring(saved, loc);
134
			String word = text.substring(saved, loc);
136
			Point extent = gc.textExtent(word);
135
			Point extent = gc.textExtent(word);
Lines 138-148 Link Here
138
				// overflow
137
				// overflow
139
				saved = last;
138
				saved = last;
140
				height += extent.y;
139
				height += extent.y;
141
			} else {
140
				// switch to current word so maxWidth will accommodate very long single words
142
				maxWidth = Math.max(maxWidth, extent.x);
141
				word = text.substring(last, loc);
142
				extent = gc.textExtent(word);
143
			}
143
			}
144
			maxWidth = Math.max(maxWidth, extent.x);
144
			last = loc;
145
			last = loc;
145
		}
146
		}
147
		/*
148
		 * Correct the height attribute in case it was calculated wrong due to wHint being less than maxWidth.
149
		 * The recursive call proved to be the only thing that worked in all cases. Some attempts can be made
150
		 * to estimate the height, but the algorithm needs to be run again to be sure.
151
		 */
152
		if (maxWidth > wHint)
153
			return computeWrapSize(gc, text, maxWidth);
146
		return new Point(maxWidth, height);
154
		return new Point(maxWidth, height);
147
	}
155
	}
148
156
Lines 387-393 Link Here
387
		}
395
		}
388
	}
396
	}
389
397
390
	static boolean isWrapControl(Control c) {
398
	public static boolean isWrapControl(Control c) {
391
		if ((c.getStyle() & SWT.WRAP) != 0)
399
		if ((c.getStyle() & SWT.WRAP) != 0)
392
			return true;
400
			return true;
393
		if (c instanceof Composite) {
401
		if (c instanceof Composite) {
(-)src/org/eclipse/ui/forms/widgets/ExpandableComposite.java (-10 / +37 lines)
Lines 260-272 Link Here
260
					- thmargin - thmargin;
260
					- thmargin - thmargin;
261
			if (tsize.x > 0)
261
			if (tsize.x > 0)
262
				twidth -= tsize.x + IGAP;
262
				twidth -= tsize.x + IGAP;
263
			if (textClient != null)
263
			if (textClient != null) {
264
				tcsize = textClientCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
264
				tcsize = textClientCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
265
			if (tcsize.x > 0)
265
			}
266
				twidth -= tcsize.x + IGAP;
267
			Point size = NULL_SIZE;
266
			Point size = NULL_SIZE;
268
			if (textLabel != null)
267
			if (textLabel != null) {
269
				size = textLabelCache.computeSize(twidth, SWT.DEFAULT);
268
				if (tcsize.x > 0 && FormUtil.isWrapControl(textClient)) {
269
					size = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
270
					if (twidth < size.x + IGAP + tcsize.x) {
271
						twidth -= IGAP;
272
						if (textLabel instanceof Label)
273
							size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x))));
274
						else
275
							size = textLabelCache.computeSize(Math.round(twidth*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT);
276
						tcsize = textClientCache.computeSize(twidth-size.x, SWT.DEFAULT);
277
					}
278
				}
279
				else {
280
					twidth -= tcsize.x + IGAP;
281
					size = textLabelCache.computeSize(twidth, SWT.DEFAULT);
282
				}
283
			}
270
			if (textLabel instanceof Label) {
284
			if (textLabel instanceof Label) {
271
				Point defSize = textLabelCache.computeSize(SWT.DEFAULT,
285
				Point defSize = textLabelCache.computeSize(SWT.DEFAULT,
272
						SWT.DEFAULT);
286
						SWT.DEFAULT);
Lines 386-398 Link Here
386
			Point tcsize = NULL_SIZE;
400
			Point tcsize = NULL_SIZE;
387
			if (textClient != null) {
401
			if (textClient != null) {
388
				tcsize = textClientCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
402
				tcsize = textClientCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
389
				if (innertHint != SWT.DEFAULT)
390
					innertHint -= IGAP + tcsize.x;
391
			}
403
			}
392
			Point size = NULL_SIZE;
404
			Point size = NULL_SIZE;
393
405
394
			if (textLabel != null)
406
			if (textLabel != null) {
395
				size = textLabelCache.computeSize(innertHint, SWT.DEFAULT);
407
				if (tcsize.x > 0 && FormUtil.isWrapControl(textClient)) {
408
					size = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
409
					if (innertHint != SWT.DEFAULT && innertHint < size.x + IGAP + tcsize.x) {
410
						innertHint -= IGAP;
411
						if (textLabel instanceof Label)
412
							size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))));
413
						else
414
							size = textLabelCache.computeSize(Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT);
415
						tcsize = textClientCache.computeSize(innertHint-size.x, SWT.DEFAULT);
416
					}
417
				} else {
418
					if (innertHint != SWT.DEFAULT)
419
						innertHint -= IGAP + tcsize.x;
420
					size = textLabelCache.computeSize(innertHint, SWT.DEFAULT);
421
				}
422
			}
396
			if (textLabel instanceof Label) {
423
			if (textLabel instanceof Label) {
397
				Point defSize = textLabelCache.computeSize(SWT.DEFAULT,
424
				Point defSize = textLabelCache.computeSize(SWT.DEFAULT,
398
						SWT.DEFAULT);
425
						SWT.DEFAULT);
Lines 450-456 Link Here
450
			}
477
			}
451
			if (toggle != null) {
478
			if (toggle != null) {
452
				height = height - size.y + Math.max(size.y, tsize.y);
479
				height = height - size.y + Math.max(size.y, tsize.y);
453
				width += twidth;
480
				width += twidth +IGAP;
454
			}
481
			}
455
482
456
			Point result = new Point(width + marginWidth + marginWidth
483
			Point result = new Point(width + marginWidth + marginWidth
(-)src/org/eclipse/help/ui/internal/views/SearchPart.java (-1 / +1 lines)
Lines 302-308 Link Here
302
	}
302
	}
303
303
304
	private void createScopeSet(Section section, FormToolkit toolkit) {
304
	private void createScopeSet(Section section, FormToolkit toolkit) {
305
		scopeSetLink = toolkit.createHyperlink(section, null, SWT.NULL);
305
		scopeSetLink = toolkit.createHyperlink(section, null, SWT.WRAP);
306
		scopeSetLink.addHyperlinkListener(new HyperlinkAdapter() {
306
		scopeSetLink.addHyperlinkListener(new HyperlinkAdapter() {
307
307
308
			public void linkActivated(HyperlinkEvent e) {
308
			public void linkActivated(HyperlinkEvent e) {

Return to bug 171276