View | Details | Raw Unified | Return to bug 10434
Collapse All | Expand All

(-)Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java (+30 lines)
Lines 38-43 Link Here
38
	TableColumn [] columns;
38
	TableColumn [] columns;
39
	ImageList imageList;
39
	ImageList imageList;
40
	boolean ignoreSelect, dragStarted, ignoreResize, mouseDown;
40
	boolean ignoreSelect, dragStarted, ignoreResize, mouseDown;
41
	boolean hasColorItem = false;
41
	static final int TableProc;
42
	static final int TableProc;
42
	static final TCHAR TableClass = new TCHAR (0, OS.WC_LISTVIEW, true);
43
	static final TCHAR TableClass = new TCHAR (0, OS.WC_LISTVIEW, true);
43
	static {
44
	static {
Lines 2292-2297 Link Here
2292
	NMHDR hdr = new NMHDR ();
2293
	NMHDR hdr = new NMHDR ();
2293
	OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
2294
	OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
2294
	switch (hdr.code) {
2295
	switch (hdr.code) {
2296
		case OS.NM_CUSTOMDRAW:
2297
			if(!hasColorItem)
2298
				return new LRESULT (OS.CDRF_DODEFAULT);
2299
			NMLVCUSTOMDRAW nmcd = new NMLVCUSTOMDRAW();
2300
			OS.MoveMemory (nmcd, lParam, NMLVCUSTOMDRAW.sizeof);
2301
			if (nmcd.dwDrawStage == OS.CDDS_PREPAINT) {
2302
				return new LRESULT (OS.CDRF_NOTIFYITEMDRAW);
2303
			}	
2304
			if (nmcd.dwDrawStage == OS.CDDS_ITEMPREPAINT) { 
2305
				return new LRESULT (OS.CDRF_NOTIFYSUBITEMDRAW);
2306
			}
2307
			if (nmcd.dwDrawStage == (OS.CDDS_ITEM | OS.CDDS_SUBITEM | OS.CDDS_PREPAINT)) { 
2308
				TableItem item = items[nmcd.dwItemSpec];
2309
				Color frColor = item.getForeground();
2310
				if (frColor != null) {
2311
					nmcd.clrText = frColor.handle;
2312
				} else {
2313
					nmcd.clrText = getForegroundPixel();
2314
				}
2315
				Color bgColor = item.getBackground();
2316
				if (item.getBackground()!=null) {
2317
					nmcd.clrTextBk = bgColor.handle;
2318
				} else {
2319
					nmcd.clrTextBk = getBackgroundPixel();
2320
				}
2321
				OS.MoveMemory (lParam, nmcd, nmcd.sizeof);
2322
				return new LRESULT (OS.CDRF_NEWFONT);
2323
			}
2324
			break;
2295
		case OS.LVN_MARQUEEBEGIN: return LRESULT.ONE;
2325
		case OS.LVN_MARQUEEBEGIN: return LRESULT.ONE;
2296
		case OS.LVN_BEGINDRAG:
2326
		case OS.LVN_BEGINDRAG:
2297
		case OS.LVN_BEGINRDRAG:
2327
		case OS.LVN_BEGINRDRAG:
(-)Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java (-1 / +82 lines)
Lines 27-32 Link Here
27
public class TableItem extends Item {
27
public class TableItem extends Item {
28
	Table parent;
28
	Table parent;
29
	
29
	
30
	Color bgColor = null;
31
	Color frColor = null;
32
33
	
30
/**
34
/**
31
 * Constructs a new instance of this class given its parent
35
 * Constructs a new instance of this class given its parent
32
 * (which must be a <code>Table</code>) and a style value
36
 * (which must be a <code>Table</code>) and a style value
Lines 103-109 Link Here
103
protected void checkSubclass () {
107
protected void checkSubclass () {
104
	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
108
	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
105
}
109
}
106
110
/**
111
 * Returns the receiver's background color.
112
 *
113
 * @return the background color
114
 *
115
 * @exception SWTException <ul>
116
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
117
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
118
 * </ul>
119
 */
120
public Color getBackground(){
121
	checkWidget();
122
	return bgColor;
123
}
107
/**
124
/**
108
 * Returns a rectangle describing the receiver's size and location
125
 * Returns a rectangle describing the receiver's size and location
109
 * relative to its parent at a column in the table.
126
 * relative to its parent at a column in the table.
Lines 183-188 Link Here
183
}
200
}
184
201
185
/**
202
/**
203
 * Returns the foreground color that the receiver will use to draw.
204
 *
205
 * @return the receiver's foreground color
206
 *
207
 * @exception SWTException <ul>
208
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
209
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
210
 * </ul>
211
 */
212
public Color getForeground(){
213
	checkWidget();
214
	return frColor;
215
}
216
217
/**
186
 * Returns <code>true</code> if the receiver is grayed,
218
 * Returns <code>true</code> if the receiver is grayed,
187
 * and false otherwise. When the parent does not have
219
 * and false otherwise. When the parent does not have
188
 * the <code>CHECK style, return false.
220
 * the <code>CHECK style, return false.
Lines 343-348 Link Here
343
}
375
}
344
376
345
/**
377
/**
378
 * Sets the receiver's background color to the color specified
379
 * by the argument, or to the default system color for the item
380
 * if the argument is null.
381
 *
382
 * @param color the new color (or null)
383
 *
384
 * @exception IllegalArgumentException <ul>
385
 *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
386
 * </ul>
387
 * @exception SWTException <ul>
388
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
389
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
390
 * </ul>
391
 */
392
public void setBackground(Color color){
393
	checkWidget();
394
	if(color != null && color.isDisposed())
395
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
396
	bgColor = color;
397
	if(color != null && color.handle != parent.getBackgroundPixel())	
398
		parent.hasColorItem = true;
399
}
400
401
/**
346
 * Sets the checked state of the receiver.
402
 * Sets the checked state of the receiver.
347
 *
403
 *
348
 * @param checked the new checked state
404
 * @param checked the new checked state
Lines 374-379 Link Here
374
	OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
430
	OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
375
	parent.ignoreSelect = false;
431
	parent.ignoreSelect = false;
376
}
432
}
433
434
/**
435
 * Sets the receiver's foreground color to the color specified
436
 * by the argument, or to the default system color for the item
437
 * if the argument is null.
438
 *
439
 * @param color the new color (or null)
440
 *
441
 * @exception IllegalArgumentException <ul>
442
 *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
443
 * </ul>
444
 * @exception SWTException <ul>
445
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
446
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
447
 * </ul>
448
 */
449
public void setForeground(Color color){
450
	checkWidget();
451
	if(color != null && color.isDisposed())
452
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
453
	frColor = color;	
454
	if(color != null && color.handle != parent.getForegroundPixel())	
455
		parent.hasColorItem = true;	
456
}
457
377
458
378
/**
459
/**
379
 * Sets the grayed state of the receiver.
460
 * Sets the grayed state of the receiver.
(-)Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java (+34 lines)
Lines 38-43 Link Here
38
	ImageList imageList;
38
	ImageList imageList;
39
	boolean dragStarted;
39
	boolean dragStarted;
40
	boolean ignoreSelect, ignoreExpand, ignoreDeselect;
40
	boolean ignoreSelect, ignoreExpand, ignoreDeselect;
41
	boolean hasColorItem = false;
41
	static final int TreeProc;
42
	static final int TreeProc;
42
	static final TCHAR TreeClass = new TCHAR (0, OS.WC_TREEVIEW, true);
43
	static final TCHAR TreeClass = new TCHAR (0, OS.WC_TREEVIEW, true);
43
	static {
44
	static {
Lines 1587-1592 Link Here
1587
	OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
1588
	OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
1588
	int code = hdr.code;
1589
	int code = hdr.code;
1589
	switch (code) {
1590
	switch (code) {
1591
		case OS.NM_CUSTOMDRAW:
1592
			if(!hasColorItem)
1593
				return new LRESULT (OS.CDRF_DODEFAULT);
1594
			NMTVCUSTOMDRAW nmcd = new NMTVCUSTOMDRAW();
1595
			OS.MoveMemory(nmcd,lParam,NMTVCUSTOMDRAW.sizeof);
1596
			int dwDrawStage = nmcd.dwDrawStage;
1597
			if (dwDrawStage == OS.CDDS_PREPAINT) { 
1598
				return new LRESULT (OS.CDRF_NOTIFYITEMDRAW);
1599
			}	
1600
			if (dwDrawStage == OS.CDDS_ITEMPREPAINT) {
1601
				if(items==null) 
1602
					return new LRESULT (OS.CDRF_NOTIFYITEMDRAW); //bug in disposed (WinXP)
1603
				TreeItem item = items[nmcd.iLevel];
1604
				if(item==null) 
1605
					return new LRESULT (OS.CDRF_NOTIFYITEMDRAW); //bug first call (WinXP)				
1606
1607
				Color frColor = item.getForeground();
1608
				if (frColor != null) {
1609
					nmcd.clrText = frColor.handle;
1610
				} else {
1611
					nmcd.clrText = getForegroundPixel();
1612
				}
1613
				Color bgColor = item.getBackground();
1614
				if (item.getBackground() != null) {
1615
					nmcd.clrTextBk = bgColor.handle;
1616
				} else {
1617
					nmcd.clrTextBk = getBackgroundPixel();
1618
				}
1619
				
1620
				OS.MoveMemory (lParam, nmcd, NMTVCUSTOMDRAW.sizeof);
1621
				return new LRESULT (OS.CDRF_NEWFONT);
1622
			}
1623
			break;
1590
		case OS.NM_DBLCLK:
1624
		case OS.NM_DBLCLK:
1591
			int pos = OS.GetMessagePos ();
1625
			int pos = OS.GetMessagePos ();
1592
			TVHITTESTINFO lpht = new TVHITTESTINFO ();
1626
			TVHITTESTINFO lpht = new TVHITTESTINFO ();
(-)Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java (+84 lines)
Lines 28-33 Link Here
28
public class TreeItem extends Item {
28
public class TreeItem extends Item {
29
	public int handle;
29
	public int handle;
30
	Tree parent;
30
	Tree parent;
31
	private Color bgColor = null;
32
	private Color frColor = null;	
31
	
33
	
32
/**
34
/**
33
 * Constructs a new instance of this class given its parent
35
 * Constructs a new instance of this class given its parent
Lines 214-219 Link Here
214
}
216
}
215
217
216
/**
218
/**
219
 * Returns the receiver's background color.
220
 *
221
 * @return the background color
222
 *
223
 * @exception SWTException <ul>
224
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
225
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
226
 * </ul>
227
 */
228
public Color getBackground(){
229
	checkWidget();
230
	return bgColor;
231
}
232
233
234
/**
217
 * Returns a rectangle describing the receiver's size and location
235
 * Returns a rectangle describing the receiver's size and location
218
 * relative to its parent.
236
 * relative to its parent.
219
 *
237
 *
Lines 289-294 Link Here
289
}
307
}
290
308
291
/**
309
/**
310
 * Returns the foreground color that the receiver will use to draw.
311
 *
312
 * @return the receiver's foreground color
313
 *
314
 * @exception SWTException <ul>
315
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
316
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
317
 * </ul>
318
 */
319
public Color getForeground(){
320
	checkWidget();
321
	return frColor;
322
}
323
324
325
/**
292
 * Returns <code>true</code> if the receiver is grayed,
326
 * Returns <code>true</code> if the receiver is grayed,
293
 * and false otherwise. When the parent does not have
327
 * and false otherwise. When the parent does not have
294
 * the <code>CHECK style, return false.
328
 * the <code>CHECK style, return false.
Lines 427-432 Link Here
427
}
461
}
428
462
429
/**
463
/**
464
 * Sets the receiver's background color to the color specified
465
 * by the argument, or to the default system color for the item
466
 * if the argument is null.
467
 *
468
 * @param color the new color (or null)
469
 *
470
 * @exception IllegalArgumentException <ul>
471
 *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
472
 * </ul>
473
 * @exception SWTException <ul>
474
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
475
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
476
 * </ul>
477
 */
478
public void setBackground(Color color){
479
	checkWidget();
480
	if(color != null && color.isDisposed())
481
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
482
	bgColor = color;	
483
	if(color != null && color.handle != parent.getBackgroundPixel())	
484
		parent.hasColorItem = true;
485
}
486
487
488
/**
430
 * Sets the checked state of the receiver.
489
 * Sets the checked state of the receiver.
431
 * <p>
490
 * <p>
432
 *
491
 *
Lines 499-504 Link Here
499
		parent.sendEvent (SWT.Selection, event);
558
		parent.sendEvent (SWT.Selection, event);
500
	}
559
	}
501
}
560
}
561
562
/**
563
 * Sets the receiver's foreground color to the color specified
564
 * by the argument, or to the default system color for the item
565
 * if the argument is null.
566
 *
567
 * @param color the new color (or null)
568
 *
569
 * @exception IllegalArgumentException <ul>
570
 *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
571
 * </ul>
572
 * @exception SWTException <ul>
573
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
574
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
575
 * </ul>
576
 */
577
public void setForeground(Color color){
578
	checkWidget();
579
	if(color != null && color.isDisposed())
580
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
581
	frColor = color;		
582
	if(color != null && color.handle != parent.getForegroundPixel())	
583
		parent.hasColorItem = true;
584
}
585
502
586
503
/**
587
/**
504
 * Sets the grayed state of the receiver.
588
 * Sets the grayed state of the receiver.
(-)Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java (+15 lines)
Lines 182-187 Link Here
182
	public static final int CC_ANYCOLOR = 0x100;
182
	public static final int CC_ANYCOLOR = 0x100;
183
	public static final int CC_ENABLEHOOK = 0x10;
183
	public static final int CC_ENABLEHOOK = 0x10;
184
	public static final int CC_RGBINIT = 0x1;
184
	public static final int CC_RGBINIT = 0x1;
185
	public static final int CDDS_PREPAINT = 0x00000001;
186
	public static final int CDDS_ITEM = 0x00010000;
187
	public static final int CDDS_ITEMPREPAINT = CDDS_ITEM | CDDS_PREPAINT;
188
	public static final int CDDS_SUBITEM = 0x00020000;
189
	public static final int CDRF_DODEFAULT = 0x00000000;
190
	public static final int CDRF_NEWFONT = 0x00000002;
191
	public static final int CDRF_NOTIFYITEMDRAW = 0x00000020;
192
	public static final int CDRF_NOTIFYSUBITEMDRAW = 0x00000020;
185
	public static final int CFE_AUTOCOLOR = 0x40000000;
193
	public static final int CFE_AUTOCOLOR = 0x40000000;
186
	public static final int CFE_ITALIC = 0x2;
194
	public static final int CFE_ITALIC = 0x2;
187
	public static final int CFE_STRIKEOUT = 0x8;
195
	public static final int CFE_STRIKEOUT = 0x8;
Lines 589-594 Link Here
589
	public static final int MNC_CLOSE = 0x1;
597
	public static final int MNC_CLOSE = 0x1;
590
	public static final int MNS_CHECKORBMP = 0x4000000;
598
	public static final int MNS_CHECKORBMP = 0x4000000;
591
	public static final int NM_CLICK = 0xfffffffe;
599
	public static final int NM_CLICK = 0xfffffffe;
600
	public static final int NM_CUSTOMDRAW = OS.NM_FIRST - 12;
592
	public static final int NM_DBLCLK = 0xfffffffd;
601
	public static final int NM_DBLCLK = 0xfffffffd;
593
	public static final int NM_FIRST = 0x0;
602
	public static final int NM_FIRST = 0x0;
594
	public static final int NM_RETURN = 0xfffffffc;
603
	public static final int NM_RETURN = 0xfffffffc;
Lines 2104-2109 Link Here
2104
public static final native void MoveMemoryA (LOGFONT Destination, int Source, int Length);
2113
public static final native void MoveMemoryA (LOGFONT Destination, int Source, int Length);
2105
public static final native void MoveMemory (MEASUREITEMSTRUCT Destination, int Source, int Length);
2114
public static final native void MoveMemory (MEASUREITEMSTRUCT Destination, int Source, int Length);
2106
public static final native void MoveMemory (NMHDR Destination, int Source, int Length);
2115
public static final native void MoveMemory (NMHDR Destination, int Source, int Length);
2116
public static final native void MoveMemory (NMCUSTOMDRAW Destination, int Source, int Length);
2117
public static final native void MoveMemory (NMLVCUSTOMDRAW Destination, int Source, int Length);
2118
public static final native void MoveMemory (NMTVCUSTOMDRAW Destination, int Source, int Length);
2119
public static final native void MoveMemory (int Destination, NMCUSTOMDRAW Source, int Length);
2120
public static final native void MoveMemory (int Destination, NMLVCUSTOMDRAW Source, int Length);
2121
public static final native void MoveMemory (int Destination, NMTVCUSTOMDRAW Source, int Length);
2107
public static final native void MoveMemory (NMHEADER Destination, int Source, int Length);
2122
public static final native void MoveMemory (NMHEADER Destination, int Source, int Length);
2108
public static final native void MoveMemory (NMLISTVIEW Destination, int Source, int Length);
2123
public static final native void MoveMemory (NMLISTVIEW Destination, int Source, int Length);
2109
public static final native void MoveMemory (NMTOOLBAR Destination, int Source, int Length);
2124
public static final native void MoveMemory (NMTOOLBAR Destination, int Source, int Length);

Return to bug 10434