Index: Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java,v
retrieving revision 1.23
diff -u -r1.23 Table.java
--- Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java 6 Feb 2002 22:06:45 -0000 1.23
+++ Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java 27 Feb 2002 16:55:50 -0000
@@ -38,6 +38,7 @@
TableColumn [] columns;
ImageList imageList;
boolean ignoreSelect, dragStarted, ignoreResize, mouseDown;
+ boolean hasColorItem = false;
static final int TableProc;
static final TCHAR TableClass = new TCHAR (0, OS.WC_LISTVIEW, true);
static {
@@ -2292,6 +2293,35 @@
NMHDR hdr = new NMHDR ();
OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
switch (hdr.code) {
+ case OS.NM_CUSTOMDRAW:
+ if(!hasColorItem)
+ return new LRESULT (OS.CDRF_DODEFAULT);
+ NMLVCUSTOMDRAW nmcd = new NMLVCUSTOMDRAW();
+ OS.MoveMemory (nmcd, lParam, NMLVCUSTOMDRAW.sizeof);
+ if (nmcd.dwDrawStage == OS.CDDS_PREPAINT) {
+ return new LRESULT (OS.CDRF_NOTIFYITEMDRAW);
+ }
+ if (nmcd.dwDrawStage == OS.CDDS_ITEMPREPAINT) {
+ return new LRESULT (OS.CDRF_NOTIFYSUBITEMDRAW);
+ }
+ if (nmcd.dwDrawStage == (OS.CDDS_ITEM | OS.CDDS_SUBITEM | OS.CDDS_PREPAINT)) {
+ TableItem item = items[nmcd.dwItemSpec];
+ Color frColor = item.getForeground();
+ if (frColor != null) {
+ nmcd.clrText = frColor.handle;
+ } else {
+ nmcd.clrText = getForegroundPixel();
+ }
+ Color bgColor = item.getBackground();
+ if (item.getBackground()!=null) {
+ nmcd.clrTextBk = bgColor.handle;
+ } else {
+ nmcd.clrTextBk = getBackgroundPixel();
+ }
+ OS.MoveMemory (lParam, nmcd, nmcd.sizeof);
+ return new LRESULT (OS.CDRF_NEWFONT);
+ }
+ break;
case OS.LVN_MARQUEEBEGIN: return LRESULT.ONE;
case OS.LVN_BEGINDRAG:
case OS.LVN_BEGINRDRAG:
Index: Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java,v
retrieving revision 1.8
diff -u -r1.8 TableItem.java
--- Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java 5 Feb 2002 14:53:49 -0000 1.8
+++ Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java 27 Feb 2002 16:55:51 -0000
@@ -27,6 +27,10 @@
public class TableItem extends Item {
Table parent;
+ Color bgColor = null;
+ Color frColor = null;
+
+
/**
* Constructs a new instance of this class given its parent
* (which must be a Table
) and a style value
@@ -103,7 +107,20 @@
protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
-
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException
true
if the receiver is grayed,
* and false otherwise. When the parent does not have
* the CHECK style, return false.
@@ -343,6 +375,30 @@
}
/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+public void setBackground(Color color){
+ checkWidget();
+ if(color != null && color.isDisposed())
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ bgColor = color;
+ if(color != null && color.handle != parent.getBackgroundPixel())
+ parent.hasColorItem = true;
+}
+
+/**
* Sets the checked state of the receiver.
*
* @param checked the new checked state
@@ -374,6 +430,31 @@
OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
parent.ignoreSelect = false;
}
+
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+public void setForeground(Color color){
+ checkWidget();
+ if(color != null && color.isDisposed())
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ frColor = color;
+ if(color != null && color.handle != parent.getForegroundPixel())
+ parent.hasColorItem = true;
+}
+
/**
* Sets the grayed state of the receiver.
Index: Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java,v
retrieving revision 1.20
diff -u -r1.20 Tree.java
--- Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java 12 Feb 2002 17:12:31 -0000 1.20
+++ Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java 27 Feb 2002 16:55:51 -0000
@@ -38,6 +38,7 @@
ImageList imageList;
boolean dragStarted;
boolean ignoreSelect, ignoreExpand, ignoreDeselect;
+ boolean hasColorItem = false;
static final int TreeProc;
static final TCHAR TreeClass = new TCHAR (0, OS.WC_TREEVIEW, true);
static {
@@ -1587,6 +1588,39 @@
OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
int code = hdr.code;
switch (code) {
+ case OS.NM_CUSTOMDRAW:
+ if(!hasColorItem)
+ return new LRESULT (OS.CDRF_DODEFAULT);
+ NMTVCUSTOMDRAW nmcd = new NMTVCUSTOMDRAW();
+ OS.MoveMemory(nmcd,lParam,NMTVCUSTOMDRAW.sizeof);
+ int dwDrawStage = nmcd.dwDrawStage;
+ if (dwDrawStage == OS.CDDS_PREPAINT) {
+ return new LRESULT (OS.CDRF_NOTIFYITEMDRAW);
+ }
+ if (dwDrawStage == OS.CDDS_ITEMPREPAINT) {
+ if(items==null)
+ return new LRESULT (OS.CDRF_NOTIFYITEMDRAW); //bug in disposed (WinXP)
+ TreeItem item = items[nmcd.iLevel];
+ if(item==null)
+ return new LRESULT (OS.CDRF_NOTIFYITEMDRAW); //bug first call (WinXP)
+
+ Color frColor = item.getForeground();
+ if (frColor != null) {
+ nmcd.clrText = frColor.handle;
+ } else {
+ nmcd.clrText = getForegroundPixel();
+ }
+ Color bgColor = item.getBackground();
+ if (item.getBackground() != null) {
+ nmcd.clrTextBk = bgColor.handle;
+ } else {
+ nmcd.clrTextBk = getBackgroundPixel();
+ }
+
+ OS.MoveMemory (lParam, nmcd, NMTVCUSTOMDRAW.sizeof);
+ return new LRESULT (OS.CDRF_NEWFONT);
+ }
+ break;
case OS.NM_DBLCLK:
int pos = OS.GetMessagePos ();
TVHITTESTINFO lpht = new TVHITTESTINFO ();
Index: Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java,v
retrieving revision 1.5
diff -u -r1.5 TreeItem.java
--- Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java 19 Oct 2001 21:00:21 -0000 1.5
+++ Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java 27 Feb 2002 16:55:51 -0000
@@ -28,6 +28,8 @@
public class TreeItem extends Item {
public int handle;
Tree parent;
+ private Color bgColor = null;
+ private Color frColor = null;
/**
* Constructs a new instance of this class given its parent
@@ -214,6 +216,22 @@
}
/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+public Color getBackground(){
+ checkWidget();
+ return bgColor;
+}
+
+
+/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent.
*
@@ -289,6 +307,22 @@
}
/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+public Color getForeground(){
+ checkWidget();
+ return frColor;
+}
+
+
+/**
* Returns true
if the receiver is grayed,
* and false otherwise. When the parent does not have
* the CHECK style, return false.
@@ -427,6 +461,31 @@
}
/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+public void setBackground(Color color){
+ checkWidget();
+ if(color != null && color.isDisposed())
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ bgColor = color;
+ if(color != null && color.handle != parent.getBackgroundPixel())
+ parent.hasColorItem = true;
+}
+
+
+/**
* Sets the checked state of the receiver.
*
*
@@ -499,6 +558,31 @@
parent.sendEvent (SWT.Selection, event);
}
}
+
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ * - ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ * - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ * - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+public void setForeground(Color color){
+ checkWidget();
+ if(color != null && color.isDisposed())
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ frColor = color;
+ if(color != null && color.handle != parent.getForegroundPixel())
+ parent.hasColorItem = true;
+}
+
/**
* Sets the grayed state of the receiver.
Index: Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java,v
retrieving revision 1.18
diff -u -r1.18 OS.java
--- Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java 4 Feb 2002 19:45:15 -0000 1.18
+++ Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java 27 Feb 2002 16:55:51 -0000
@@ -182,6 +182,14 @@
public static final int CC_ANYCOLOR = 0x100;
public static final int CC_ENABLEHOOK = 0x10;
public static final int CC_RGBINIT = 0x1;
+ public static final int CDDS_PREPAINT = 0x00000001;
+ public static final int CDDS_ITEM = 0x00010000;
+ public static final int CDDS_ITEMPREPAINT = CDDS_ITEM | CDDS_PREPAINT;
+ public static final int CDDS_SUBITEM = 0x00020000;
+ public static final int CDRF_DODEFAULT = 0x00000000;
+ public static final int CDRF_NEWFONT = 0x00000002;
+ public static final int CDRF_NOTIFYITEMDRAW = 0x00000020;
+ public static final int CDRF_NOTIFYSUBITEMDRAW = 0x00000020;
public static final int CFE_AUTOCOLOR = 0x40000000;
public static final int CFE_ITALIC = 0x2;
public static final int CFE_STRIKEOUT = 0x8;
@@ -589,6 +597,7 @@
public static final int MNC_CLOSE = 0x1;
public static final int MNS_CHECKORBMP = 0x4000000;
public static final int NM_CLICK = 0xfffffffe;
+ public static final int NM_CUSTOMDRAW = OS.NM_FIRST - 12;
public static final int NM_DBLCLK = 0xfffffffd;
public static final int NM_FIRST = 0x0;
public static final int NM_RETURN = 0xfffffffc;
@@ -2104,6 +2113,12 @@
public static final native void MoveMemoryA (LOGFONT Destination, int Source, int Length);
public static final native void MoveMemory (MEASUREITEMSTRUCT Destination, int Source, int Length);
public static final native void MoveMemory (NMHDR Destination, int Source, int Length);
+public static final native void MoveMemory (NMCUSTOMDRAW Destination, int Source, int Length);
+public static final native void MoveMemory (NMLVCUSTOMDRAW Destination, int Source, int Length);
+public static final native void MoveMemory (NMTVCUSTOMDRAW Destination, int Source, int Length);
+public static final native void MoveMemory (int Destination, NMCUSTOMDRAW Source, int Length);
+public static final native void MoveMemory (int Destination, NMLVCUSTOMDRAW Source, int Length);
+public static final native void MoveMemory (int Destination, NMTVCUSTOMDRAW Source, int Length);
public static final native void MoveMemory (NMHEADER Destination, int Source, int Length);
public static final native void MoveMemory (NMLISTVIEW Destination, int Source, int Length);
public static final native void MoveMemory (NMTOOLBAR Destination, int Source, int Length);