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 279663 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ui/forms/widgets/Section.java (-20 / +83 lines)
Lines 7-14 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Michael Williamson (eclipse-bugs@magnaworks.com) - patch (see Bugzilla #92545) 
10
 *     Michael Williamson (eclipse-bugs@magnaworks.com) - patch (see Bugzilla #92545)
11
 *       
11
 *
12
 *******************************************************************************/
12
 *******************************************************************************/
13
package org.eclipse.ui.forms.widgets;
13
package org.eclipse.ui.forms.widgets;
14
14
Lines 20-27 Link Here
20
import org.eclipse.swt.graphics.Color;
20
import org.eclipse.swt.graphics.Color;
21
//import org.eclipse.swt.graphics.GC;
21
//import org.eclipse.swt.graphics.GC;
22
import org.eclipse.swt.graphics.Image;
22
import org.eclipse.swt.graphics.Image;
23
//import org.eclipse.swt.graphics.Point;
23
import org.eclipse.swt.graphics.Point;
24
//import org.eclipse.swt.graphics.Rectangle;
24
import org.eclipse.swt.graphics.Rectangle;
25
import org.eclipse.swt.internal.widgets.IControlAdapter;
26
import org.eclipse.swt.internal.widgets.IWidgetGraphicsAdapter;
25
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.Control;
27
import org.eclipse.swt.widgets.Event;
29
import org.eclipse.swt.widgets.Event;
Lines 47-53 Link Here
47
 * typical way to take advantage of the new method is to set an instance of
49
 * typical way to take advantage of the new method is to set an instance of
48
 * <code>FormText</code> to provide for hyperlinks and images in the
50
 * <code>FormText</code> to provide for hyperlinks and images in the
49
 * description area.
51
 * description area.
50
 * 
52
 *
51
 * @since 1.0
53
 * @since 1.0
52
 */
54
 */
53
public class Section extends ExpandableComposite {
55
public class Section extends ExpandableComposite {
Lines 62-67 Link Here
62
64
63
	private Hashtable titleColors;
65
	private Hashtable titleColors;
64
66
67
// RAP [if] Title bar background gradient rendering
68
	private Composite titleBar;
69
65
	private static final String COLOR_BG = "bg"; //$NON-NLS-1$
70
	private static final String COLOR_BG = "bg"; //$NON-NLS-1$
66
71
67
	private static final String COLOR_GBG = "gbg"; //$NON-NLS-1$
72
	private static final String COLOR_GBG = "gbg"; //$NON-NLS-1$
Lines 70-76 Link Here
70
75
71
	/**
76
	/**
72
	 * Creates a new section instance in the provided parent.
77
	 * Creates a new section instance in the provided parent.
73
	 * 
78
	 *
74
	 * @param parent
79
	 * @param parent
75
	 *            the parent composite
80
	 *            the parent composite
76
	 * @param style
81
	 * @param style
Lines 88-93 Link Here
88
			descriptionControl = new Text(this, SWT.READ_ONLY | SWT.WRAP | rtl);
93
			descriptionControl = new Text(this, SWT.READ_ONLY | SWT.WRAP | rtl);
89
		}
94
		}
90
		if ((style & TITLE_BAR) != 0) {
95
		if ((style & TITLE_BAR) != 0) {
96
// RAP [if] Title bar background gradient rendering
97
		    titleBar = new Composite( this, SWT.NONE );
98
// ENDRAP [if]
91
			Listener listener = new Listener() {
99
			Listener listener = new Listener() {
92
				public void handleEvent(Event e) {
100
				public void handleEvent(Event e) {
93
					Image image = Section.super.getBackgroundImage();
101
					Image image = Section.super.getBackgroundImage();
Lines 95-100 Link Here
95
						FormImages.getInstance().markFinished(image);
103
						FormImages.getInstance().markFinished(image);
96
					}
104
					}
97
					Section.super.setBackgroundImage(null);
105
					Section.super.setBackgroundImage(null);
106
// RAP [if] Title bar background gradient rendering
107
					applyBackgroundGradient();
108
// ENDRAP [if]
98
				}
109
				}
99
			};
110
			};
100
			addListener(SWT.Dispose, listener);
111
			addListener(SWT.Dispose, listener);
Lines 152-158 Link Here
152
	/**
163
	/**
153
	 * Sets the description text. Has no effect if DESCRIPTION style was not
164
	 * Sets the description text. Has no effect if DESCRIPTION style was not
154
	 * used to create the control.
165
	 * used to create the control.
155
	 * 
166
	 *
156
	 * @param description
167
	 * @param description
157
	 */
168
	 */
158
	public void setDescription(String description) {
169
	public void setDescription(String description) {
Lines 162-168 Link Here
162
173
163
	/**
174
	/**
164
	 * Returns the current description text.
175
	 * Returns the current description text.
165
	 * 
176
	 *
166
	 * @return description text or <code>null</code> if DESCRIPTION style was
177
	 * @return description text or <code>null</code> if DESCRIPTION style was
167
	 *         not used to create the control.
178
	 *         not used to create the control.
168
	 */
179
	 */
Lines 177-183 Link Here
177
	 * <samp>null </samp> and must be a direct child of this container. If
188
	 * <samp>null </samp> and must be a direct child of this container. If
178
	 * defined, separator will be placed below the title text and will remain
189
	 * defined, separator will be placed below the title text and will remain
179
	 * visible regardless of the expansion state.
190
	 * visible regardless of the expansion state.
180
	 * 
191
	 *
181
	 * @param separator
192
	 * @param separator
182
	 *            the separator that will be placed below the title text.
193
	 *            the separator that will be placed below the title text.
183
	 */
194
	 */
Lines 189-195 Link Here
189
	/**
200
	/**
190
	 * Returns the control that is used as a separator betweeen the title and
201
	 * Returns the control that is used as a separator betweeen the title and
191
	 * the client, or <samp>null </samp> if not set.
202
	 * the client, or <samp>null </samp> if not set.
192
	 * 
203
	 *
193
	 * @return separator control or <samp>null </samp> if not set.
204
	 * @return separator control or <samp>null </samp> if not set.
194
	 */
205
	 */
195
	public Control getSeparatorControl() {
206
	public Control getSeparatorControl() {
Lines 198-204 Link Here
198
209
199
	/**
210
	/**
200
	 * Sets the background of the section.
211
	 * Sets the background of the section.
201
	 * 
212
	 *
202
	 * @param bg
213
	 * @param bg
203
	 *            the new background
214
	 *            the new background
204
	 */
215
	 */
Lines 207-217 Link Here
207
		if (descriptionControl != null
218
		if (descriptionControl != null
208
				&& (getExpansionStyle() & DESCRIPTION) != 0)
219
				&& (getExpansionStyle() & DESCRIPTION) != 0)
209
			descriptionControl.setBackground(bg);
220
			descriptionControl.setBackground(bg);
221
// RAP [if] Title bar background gradient rendering
222
        applyBackgroundGradient();
223
// ENDRAP [if]
210
	}
224
	}
211
225
212
	/**
226
	/**
213
	 * Sets the foreground of the section.
227
	 * Sets the foreground of the section.
214
	 * 
228
	 *
215
	 * @param fg
229
	 * @param fg
216
	 *            the new foreground.
230
	 *            the new foreground.
217
	 */
231
	 */
Lines 225-231 Link Here
225
	/**
239
	/**
226
	 * Returns the control used to render the description. In 3.1, this method
240
	 * Returns the control used to render the description. In 3.1, this method
227
	 * was promoted to public.
241
	 * was promoted to public.
228
	 * 
242
	 *
229
	 * @return description control or <code>null</code> if DESCRIPTION style
243
	 * @return description control or <code>null</code> if DESCRIPTION style
230
	 *         was not used to create the control and description control was
244
	 *         was not used to create the control and description control was
231
	 *         not set by the client.
245
	 *         not set by the client.
Lines 244-250 Link Here
244
	 * This method and <code>DESCRIPTION</code> style are mutually exclusive.
258
	 * This method and <code>DESCRIPTION</code> style are mutually exclusive.
245
	 * Use the method only if you want to create the description control
259
	 * Use the method only if you want to create the description control
246
	 * yourself.
260
	 * yourself.
247
	 * 
261
	 *
248
	 * @param descriptionControl
262
	 * @param descriptionControl
249
	 *            the control that will be placed below the title text.
263
	 *            the control that will be placed below the title text.
250
	 */
264
	 */
Lines 257-263 Link Here
257
271
258
	/**
272
	/**
259
	 * Sets the color of the title bar border when TITLE_BAR style is used.
273
	 * Sets the color of the title bar border when TITLE_BAR style is used.
260
	 * 
274
	 *
261
	 * @param color
275
	 * @param color
262
	 *            the title bar border color
276
	 *            the title bar border color
263
	 */
277
	 */
Lines 268-286 Link Here
268
	/**
282
	/**
269
	 * Sets the color of the title bar background when TITLE_BAR style is used.
283
	 * Sets the color of the title bar background when TITLE_BAR style is used.
270
	 * This color is used as a starting color for the vertical gradient.
284
	 * This color is used as a starting color for the vertical gradient.
271
	 * 
285
	 *
272
	 * @param color
286
	 * @param color
273
	 *            the title bar border background
287
	 *            the title bar border background
274
	 */
288
	 */
275
	public void setTitleBarBackground(Color color) {
289
	public void setTitleBarBackground(Color color) {
276
		putTitleBarColor(COLOR_BG, color);
290
		putTitleBarColor(COLOR_BG, color);
291
// RAP [if] Title bar background gradient rendering
292
		applyBackgroundGradient();
293
// ENDRAP [if]
277
	}
294
	}
278
295
279
	/**
296
	/**
280
	 * Sets the color of the title bar gradient background when TITLE_BAR style
297
	 * Sets the color of the title bar gradient background when TITLE_BAR style
281
	 * is used. This color is used at the height where title controls end
298
	 * is used. This color is used at the height where title controls end
282
	 * (toggle, tool bar).
299
	 * (toggle, tool bar).
283
	 * 
300
	 *
284
	 * @param color
301
	 * @param color
285
	 *            the title bar gradient background
302
	 *            the title bar gradient background
286
	 */
303
	 */
Lines 290-296 Link Here
290
307
291
	/**
308
	/**
292
	 * Returns the title bar border color when TITLE_BAR style is used.
309
	 * Returns the title bar border color when TITLE_BAR style is used.
293
	 * 
310
	 *
294
	 * @return the title bar border color
311
	 * @return the title bar border color
295
	 */
312
	 */
296
	public Color getTitleBarBorderColor() {
313
	public Color getTitleBarBorderColor() {
Lines 302-308 Link Here
302
	/**
319
	/**
303
	 * Returns the title bar gradient background color when TITLE_BAR style is
320
	 * Returns the title bar gradient background color when TITLE_BAR style is
304
	 * used.
321
	 * used.
305
	 * 
322
	 *
306
	 * @return the title bar gradient background
323
	 * @return the title bar gradient background
307
	 */
324
	 */
308
	public Color getTitleBarGradientBackground() {
325
	public Color getTitleBarGradientBackground() {
Lines 315-321 Link Here
315
332
316
	/**
333
	/**
317
	 * Returns the title bar background when TITLE_BAR style is used.
334
	 * Returns the title bar background when TITLE_BAR style is used.
318
	 * 
335
	 *
319
	 * @return the title bar background
336
	 * @return the title bar background
320
	 */
337
	 */
321
	public Color getTitleBarBackground() {
338
	public Color getTitleBarBackground() {
Lines 471-474 Link Here
471
	 */
488
	 */
472
	public final void setBackgroundImage(Image image) {
489
	public final void setBackgroundImage(Image image) {
473
	}
490
	}
491
492
// RAP [if] Title bar background gradient rendering
493
	private final void applyBackgroundGradient() {
494
	  if( titleBar != null ) {
495
	    // Code start - onPaint
496
	    Color bg = null;
497
  	    if (titleColors != null) {
498
  	        bg = (Color) titleColors.get(COLOR_BG);
499
  	    }
500
  	    if (bg == null)
501
  	        bg = getBackground();
502
	    Rectangle bounds = getClientArea();
503
	    int theight = 0;
504
        int gradientheight = 0;
505
        int tvmargin = IGAP;
506
        Point tsize = null;
507
        Point tcsize = null;
508
        if (toggle != null)
509
            tsize = toggle.getSize();
510
        int twidth = bounds.width - marginWidth - marginWidth;
511
        if (tsize != null)
512
            twidth -= tsize.x + IGAP;
513
        if (getTextClient() != null)
514
            tcsize = getTextClient().getSize();
515
        if (tcsize != null)
516
            twidth -= tcsize.x + IGAP;
517
        Point size = textLabel.getSize();
518
        if (tsize != null)
519
            theight += Math.max(theight, tsize.y);
520
        gradientheight = theight;
521
        if (tcsize != null) {
522
            theight = Math.max(theight, tcsize.y);
523
        }
524
        theight = Math.max(theight, size.y);
525
        gradientheight = Math.max(gradientheight, size.y);
526
        theight += tvmargin + tvmargin;
527
        gradientheight += tvmargin + tvmargin;
528
        // Code end - onPaint
529
530
	    titleBar.setBounds( 0, 0, bounds.width, gradientheight );
531
	    Object adapter = titleBar.getAdapter( IWidgetGraphicsAdapter.class );
532
        IWidgetGraphicsAdapter gfxAdapter = ( IWidgetGraphicsAdapter )adapter;
533
        gfxAdapter.setBackgroundGradient( bg, getBackground() );
534
	  }
535
	}
536
// ENDRAP [if]
474
}
537
}
(-)src/org/eclipse/ui/internal/forms/widgets/FormHeading.java (-1 / +11 lines)
Lines 38-43 Link Here
38
import org.eclipse.swt.graphics.Image;
38
import org.eclipse.swt.graphics.Image;
39
import org.eclipse.swt.graphics.Point;
39
import org.eclipse.swt.graphics.Point;
40
import org.eclipse.swt.graphics.Rectangle;
40
import org.eclipse.swt.graphics.Rectangle;
41
import org.eclipse.swt.internal.widgets.IControlAdapter;
42
import org.eclipse.swt.internal.widgets.IWidgetGraphicsAdapter;
41
import org.eclipse.swt.widgets.Canvas;
43
import org.eclipse.swt.widgets.Canvas;
42
import org.eclipse.swt.widgets.Composite;
44
import org.eclipse.swt.widgets.Composite;
43
import org.eclipse.swt.widgets.Control;
45
import org.eclipse.swt.widgets.Control;
Lines 864-870 Link Here
864
//			titleRegion.setHoverState(TitleRegion.STATE_NORMAL);
866
//			titleRegion.setHoverState(TitleRegion.STATE_NORMAL);
865
//	}
867
//	}
866
868
867
// RAP [rh] updateGradientImage: empty implementation
868
	private void updateGradientImage() {
869
	private void updateGradientImage() {
869
//		Rectangle rect = getBounds();
870
//		Rectangle rect = getBounds();
870
//		if (gradientImage != null) {
871
//		if (gradientImage != null) {
Lines 883-888 Link Here
883
//			gc.dispose();
884
//			gc.dispose();
884
//		}
885
//		}
885
//		setBackgroundImage(gradientImage);
886
//		setBackgroundImage(gradientImage);
887
// RAP [if] Background gradient rendering
888
	  if( gradientInfo != null ) {
889
	    Object adapter = getAdapter( IWidgetGraphicsAdapter.class );
890
        IWidgetGraphicsAdapter gfxAdapter = ( IWidgetGraphicsAdapter )adapter;
891
        Color top = gradientInfo.gradientColors[ 0 ];
892
        Color bot = gradientInfo.gradientColors[ 1 ];
893
        gfxAdapter.setBackgroundGradient( top, bot );
894
	  }
895
// RAPEND [if]
886
	}
896
	}
887
897
888
	public boolean isSeparatorVisible() {
898
	public boolean isSeparatorVisible() {

Return to bug 279663