diff options
author | Silenio Quarti <ssq> | 2001-07-26 19:06:55 +0000 |
---|---|---|
committer | Silenio Quarti <ssq> | 2001-07-26 19:06:55 +0000 |
commit | c4386357939cb5968eee5a1eb5483f0ab8d5244e (patch) | |
tree | 0c1d4cec7e04a5acf7060ae1fc641a8895f08fc4 | |
parent | 7f4b3c8c903a375da9643be16ca896191929ce1e (diff) | |
download | eclipse.platform.swt-c4386357939cb5968eee5a1eb5483f0ab8d5244e.tar.gz eclipse.platform.swt-c4386357939cb5968eee5a1eb5483f0ab8d5244e.tar.xz eclipse.platform.swt-c4386357939cb5968eee5a1eb5483f0ab8d5244e.zip |
resources on Win98 fix R1.0NL
7 files changed, 270 insertions, 153 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java index d16ccefca2..84e7990643 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java @@ -113,6 +113,9 @@ public class Display extends Device { int lastKey, lastAscii, lastMouse;
byte [] keyboard = new byte [256];
boolean accelKeyHit, mnemonicKeyHit;
+
+ /* Image list cache */
+ ImageList[] imageList, toolImageList, toolHotImageList, toolDisabledImageList;
/* Key Mappings */
static final int [] [] KeyTable = {
@@ -729,6 +732,114 @@ public int getIconDepth () { return depth;
}
+ImageList getImageList (Point size) {
+ if (imageList == null) imageList = new ImageList [4];
+
+ int i = 0;
+ int length = imageList.length;
+ while (i < length) {
+ ImageList list = imageList [i];
+ if (list == null) break;
+ if (list.getImageSize().equals(size)) {
+ list.addRef();
+ return list;
+ }
+ i++;
+ }
+
+ if (i == length) {
+ ImageList [] newList = new ImageList [length + 4];
+ System.arraycopy (imageList, 0, newList, 0, length);
+ imageList = newList;
+ }
+
+ ImageList list = new ImageList();
+ imageList [i] = list;
+ list.addRef();
+ return list;
+}
+
+ImageList getToolImageList (Point size) {
+ if (toolImageList == null) toolImageList = new ImageList [4];
+
+ int i = 0;
+ int length = toolImageList.length;
+ while (i < length) {
+ ImageList list = toolImageList [i];
+ if (list == null) break;
+ if (list.getImageSize().equals(size)) {
+ list.addRef();
+ return list;
+ }
+ i++;
+ }
+
+ if (i == length) {
+ ImageList [] newList = new ImageList [length + 4];
+ System.arraycopy (toolImageList, 0, newList, 0, length);
+ toolImageList = newList;
+ }
+
+ ImageList list = new ImageList();
+ toolImageList [i] = list;
+ list.addRef();
+ return list;
+}
+
+ImageList getToolHotImageList (Point size) {
+ if (toolHotImageList == null) toolHotImageList = new ImageList [4];
+
+ int i = 0;
+ int length = toolHotImageList.length;
+ while (i < length) {
+ ImageList list = toolHotImageList [i];
+ if (list == null) break;
+ if (list.getImageSize().equals(size)) {
+ list.addRef();
+ return list;
+ }
+ i++;
+ }
+
+ if (i == length) {
+ ImageList [] newList = new ImageList [length + 4];
+ System.arraycopy (toolHotImageList, 0, newList, 0, length);
+ toolHotImageList = newList;
+ }
+
+ ImageList list = new ImageList();
+ toolHotImageList [i] = list;
+ list.addRef();
+ return list;
+}
+
+ImageList getToolDisabledImageList (Point size) {
+ if (toolDisabledImageList == null) toolDisabledImageList = new ImageList [4];
+
+ int i = 0;
+ int length = toolDisabledImageList.length;
+ while (i < length) {
+ ImageList list = toolDisabledImageList [i];
+ if (list == null) break;
+ if (list.getImageSize().equals(size)) {
+ list.addRef();
+ return list;
+ }
+ i++;
+ }
+
+ if (i == length) {
+ ImageList [] newList = new ImageList [length + 4];
+ System.arraycopy (toolDisabledImageList, 0, newList, 0, length);
+ toolDisabledImageList = newList;
+ }
+
+ ImageList list = new ImageList();
+ toolDisabledImageList [i] = list;
+ list.addRef();
+ return list;
+}
+
Shell getModalShell () {
if (ModalWidgets == null) return null;
int index = ModalWidgets.length;
@@ -1129,6 +1240,82 @@ void releaseDisplay () { values = null;
}
+void releaseImageList (ImageList list) {
+ int i = 0;
+ int length = imageList.length;
+ while (i < length) {
+ if (imageList [i] == list) {
+ if (list.removeRef () > 0) return;
+ list.dispose ();
+ System.arraycopy (imageList, i + 1, imageList, i, --length - i);
+ imageList [length] = null;
+ for (int j=0; j<length; j++) {
+ if (imageList [j] != null) return;
+ }
+ imageList = null;
+ return;
+ }
+ i++;
+ }
+}
+
+void releaseToolImageList (ImageList list) {
+ int i = 0;
+ int length = toolImageList.length;
+ while (i < length) {
+ if (toolImageList [i] == list) {
+ if (list.removeRef () > 0) return;
+ list.dispose ();
+ System.arraycopy (toolImageList, i + 1, toolImageList, i, --length - i);
+ toolImageList [length] = null;
+ for (int j=0; j<length; j++) {
+ if (toolImageList [j] != null) return;
+ }
+ toolImageList = null;
+ return;
+ }
+ i++;
+ }
+}
+
+void releaseToolHotImageList (ImageList list) {
+ int i = 0;
+ int length = toolHotImageList.length;
+ while (i < length) {
+ if (toolHotImageList [i] == list) {
+ if (list.removeRef () > 0) return;
+ list.dispose ();
+ System.arraycopy (toolHotImageList, i + 1, toolHotImageList, i, --length - i);
+ toolHotImageList [length] = null;
+ for (int j=0; j<length; j++) {
+ if (toolHotImageList [j] != null) return;
+ }
+ toolHotImageList = null;
+ return;
+ }
+ i++;
+ }
+}
+
+void releaseToolDisabledImageList (ImageList list) {
+ int i = 0;
+ int length = toolDisabledImageList.length;
+ while (i < length) {
+ if (toolDisabledImageList [i] == list) {
+ if (list.removeRef () > 0) return;
+ list.dispose ();
+ System.arraycopy (toolDisabledImageList, i + 1, toolDisabledImageList, i, --length - i);
+ toolDisabledImageList [length] = null;
+ for (int j=0; j<length; j++) {
+ if (toolDisabledImageList [j] != null) return;
+ }
+ toolDisabledImageList = null;
+ return;
+ }
+ i++;
+ }
+}
+
boolean runAsyncMessages () {
return synchronizer.runAsyncMessages ();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java index d44e28e1c5..a2bf7115a8 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java @@ -10,7 +10,7 @@ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*;
class ImageList {
- int handle, background;
+ int handle, refCount;
Image [] images;
static final int CREATE_FLAGS;
static {
@@ -45,7 +45,6 @@ class ImageList { public ImageList () {
handle = OS.ImageList_Create (32, 32, CREATE_FLAGS, 16, 16);
images = new Image [4];
- background = 0x00FFFFFF;
}
public int add (Image image) {
@@ -70,10 +69,13 @@ public int add (Image image) { OS.ImageList_SetIconSize (handle, cx [0], cy [0]);
}
int hBitmap = copyBitmap (hImage, cx [0], cy [0]);
+ int background = -1;
+ Color color = image.getBackground ();
+ if (color != null) background = color.handle;
if (index == count) {
OS.ImageList_AddMasked (handle, hBitmap, background);
} else {
- int hMask = createMask (hBitmap, cx [0], cy [0]);
+ int hMask = createMask (hBitmap, cx [0], cy [0], background);
OS.ImageList_Replace (handle, index, hBitmap, hMask);
OS.DeleteObject (hMask);
}
@@ -109,6 +111,10 @@ public int add (Image image) { return index;
}
+int addRef() {
+ return ++refCount;
+}
+
int copyBitmap (int hImage, int width, int height) {
BITMAP bm = new BITMAP ();
OS.GetObject (hImage, BITMAP.sizeof, bm);
@@ -131,18 +137,20 @@ int copyIcon (int hImage, int width, int height) { return hIcon;
}
-int createMask (int hBitmap, int width, int height) {
- int hDC = OS.GetDC (0);
- int hdc1 = OS.CreateCompatibleDC (hDC);
- OS.SelectObject (hdc1, hBitmap);
- int hdc2 = OS.CreateCompatibleDC (hDC);
+int createMask (int hBitmap, int width, int height, int background) {
int hMask = OS.CreateBitmap (width, height, 1, 1, null);
- OS.SelectObject (hdc2, hMask);
- OS.SetBkColor (hdc1, background);
- OS.BitBlt (hdc2, 0, 0, width, height, hdc1, 0, 0, OS.SRCCOPY);
- OS.ReleaseDC (0, hDC);
- OS.DeleteDC (hdc1);
- OS.DeleteDC (hdc2);
+ if (background != -1) {
+ int hDC = OS.GetDC (0);
+ int hdc1 = OS.CreateCompatibleDC (hDC);
+ OS.SelectObject (hdc1, hBitmap);
+ int hdc2 = OS.CreateCompatibleDC (hDC);
+ OS.SelectObject (hdc2, hMask);
+ OS.SetBkColor (hdc1, background);
+ OS.BitBlt (hdc2, 0, 0, width, height, hdc1, 0, 0, OS.SRCCOPY);
+ OS.ReleaseDC (0, hDC);
+ OS.DeleteDC (hdc1);
+ OS.DeleteDC (hdc2);
+ }
return hMask;
}
@@ -156,14 +164,16 @@ public Image get (int index) { return images [index];
}
-public int getBackground () {
- return background;
-}
-
public int getHandle () {
return handle;
}
+public Point getImageSize() {
+ int [] cx = new int [1], cy = new int [1];
+ OS.ImageList_GetIconSize (handle, cx, cy);
+ return new Point (cx [0], cy [0]);
+}
+
public int indexOf (Image image) {
int count = OS.ImageList_GetImageCount (handle);
for (int i=0; i<count; i++) {
@@ -184,8 +194,11 @@ public void put (int index, Image image) { int hImage = image.handle;
switch (image.type) {
case SWT.BITMAP:
+ int background = -1;
+ Color color = image.getBackground ();
+ if (color != null) background = color.handle;
int hBitmap = copyBitmap (hImage, cx [0], cy [0]);
- int hMask = createMask (hBitmap, cx [0], cy [0]);
+ int hMask = createMask (hBitmap, cx [0], cy [0], background);
OS.ImageList_Replace (handle, index, hBitmap, hMask);
OS.DeleteObject (hBitmap);
OS.DeleteObject (hMask);
@@ -208,51 +221,8 @@ public void remove (int index) { images [index] = null;
}
-public void setBackground (int color) {
- if (background == color) return;
- background = color;
- /*
- * This code is intentionally commented. When the background
- * color of the control changes, it is necessary to recompute
- * the masks for all bitmaps in the image list. This can look
- * really bad when the application program assumes the original
- * color of the control and makes bitmaps accordingly. Typically
- * this happens when the colors are change using the control panel.
- * Therefore, this code remains commented even though it is correct.
- */
-// int length = OS.ImageList_GetImageCount (handle);
-// if (length == 0) return;
-// int [] cx = new int [1], cy = new int [1];
-// OS.ImageList_GetIconSize (handle, cx, cy);
-// int width = cx [0], height = cy [0];
-// OS.ImageList_Destroy (handle);
-// handle = OS.ImageList_Create (width, height, CREATE_FLAGS, length, 16);
-// for (int i=0; i<length; i++) {
-// Image image = images [i];
-// if (image == null || image.isDisposed ()) {
-// images [i] = null;
-// int hBitmap = OS.CreateBitmap (width, height, 1, 1, null);
-// OS.ImageList_AddMasked (handle, hBitmap, background);
-// OS.DeleteObject (hBitmap);
-// } else {
-// int hImage = image.handle;
-// switch (image.type) {
-// case SWT.BITMAP:
-// int hBitmap = copyBitmap (hImage, width, height);
-// OS.ImageList_AddMasked (handle, hBitmap, background);
-// OS.DeleteObject (hBitmap);
-// break;
-// case SWT.ICON:
-// int hIcon = copyIcon (hImage, width, height);
-// OS.ImageList_ReplaceIcon (handle, -1, hIcon);
-// OS.DestroyIcon (hIcon);
-// break;
-// default:
-// SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
-// break;
-// }
-// }
-// }
+int removeRef() {
+ return --refCount;
}
public int size () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java index a768df1577..03e07f2264 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java @@ -221,7 +221,8 @@ void destroyItem (TabItem item) { if (count == 0) {
if (imageList != null) {
OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, 0);
- imageList.dispose ();
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
}
imageList = null;
items = new TabItem [4];
@@ -358,12 +359,13 @@ public int getSelectionIndex () { int imageIndex (Image image) {
if (image == null) return OS.I_IMAGENONE;
if (imageList == null) {
- imageList = new ImageList ();
- imageList.setBackground (getBackgroundPixel ());
- imageList.add (image);
+ Rectangle bounds = image.getBounds ();
+ imageList = getDisplay ().getImageList (new Point (bounds.width, bounds.height));
+ int index = imageList.indexOf (image);
+ if (index == -1) index = imageList.add (image);
int hImageList = imageList.getHandle ();
OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList);
- return 0;
+ return index;
}
int index = imageList.indexOf (image);
if (index != -1) return index;
@@ -404,12 +406,13 @@ void releaseWidget () { if (!item.isDisposed ()) item.releaseWidget ();
}
items = null;
- super.releaseWidget ();
if (imageList != null) {
OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, 0);
- imageList.dispose ();
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
}
imageList = null;
+ super.releaseWidget ();
}
/**
@@ -611,17 +614,6 @@ LRESULT WM_SIZE (int wParam, int lParam) { return result;
}
-LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
- LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
- if (result != null) return result;
- if (imageList != null && background == -1) {
- imageList.setBackground (defaultBackground ());
- int hImageList = imageList.getHandle ();
- OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList);
- }
- return result;
-}
-
LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) {
LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);
if (result != null) return result;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java index e467b2a1a3..cf48502923 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java @@ -484,7 +484,8 @@ void destroyItem (TableItem item) { if (count == 0) {
if (imageList != null) {
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
- imageList.dispose ();
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
}
imageList = null;
items = new TableItem [4];
@@ -860,12 +861,13 @@ public int getTopIndex () { int imageIndex (Image image) {
if (image == null) return OS.I_IMAGENONE;
if (imageList == null) {
- imageList = new ImageList ();
- imageList.setBackground (getBackgroundPixel ());
- imageList.add (image);
+ Rectangle bounds = image.getBounds ();
+ imageList = getDisplay ().getImageList (new Point (bounds.width, bounds.height));
+ int index = imageList.indexOf (image);
+ if (index == -1) index = imageList.add (image);
int hImageList = imageList.getHandle ();
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
- return 0;
+ return index;
}
int index = imageList.indexOf (image);
if (index != -1) return index;
@@ -992,15 +994,16 @@ void releaseWidget () { // }
items = null;
- super.releaseWidget ();
if (imageList != null) {
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
- imageList.dispose ();
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
}
imageList = null;
int hOldList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, 0);
if (hOldList != 0) OS.ImageList_Destroy (hOldList);
+ super.releaseWidget ();
}
/**
@@ -1195,7 +1198,8 @@ public void removeAll () { if (imageList != null) {
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
- imageList.dispose ();
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
}
imageList = null;
items = new TableItem [4];
@@ -1439,11 +1443,6 @@ void setBackgroundPixel (int pixel) { if (pixel == -1) pixel = defaultBackground ();
OS.SendMessage (handle, OS.LVM_SETBKCOLOR, 0, pixel);
OS.SendMessage (handle, OS.LVM_SETTEXTBKCOLOR, 0, pixel);
- if (imageList != null) {
- imageList.setBackground (pixel);
- int hImageList = imageList.getHandle ();
- OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
- }
if ((style & SWT.CHECK) != 0) setCheckboxImageList ();
/*
@@ -2146,11 +2145,6 @@ LRESULT WM_SETFOCUS (int wParam, int lParam) { LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
if (result != null) return result;
- if (imageList != null && background == -1) {
- imageList.setBackground (defaultBackground ());
- int hImageList = imageList.getHandle ();
- OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
- }
if ((style & SWT.CHECK) != 0) setCheckboxImageList ();
return result;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java index 8b5644cb7b..fe9afe02b8 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java @@ -272,17 +272,18 @@ void destroyItem (ToolItem item) { item.id = -1;
int count = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
if (count == 0) {
+ Display display = getDisplay ();
if (imageList != null) {
OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, 0);
- imageList.dispose ();
+ display.releaseToolImageList (imageList);
}
if (hotImageList != null) {
OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, 0);
- hotImageList.dispose ();
+ display.releaseToolHotImageList (hotImageList);
}
if (disabledImageList != null) {
OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, 0);
- disabledImageList.dispose ();
+ display.releaseToolDisabledImageList (disabledImageList);
}
imageList = hotImageList = disabledImageList = null;
items = new ToolItem [4];
@@ -448,20 +449,21 @@ void releaseWidget () { }
}
items = null;
- super.releaseWidget ();
+ Display display = getDisplay ();
if (imageList != null) {
OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, 0);
- imageList.dispose ();
+ display.releaseToolImageList (imageList);
}
if (hotImageList != null) {
OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, 0);
- hotImageList.dispose ();
+ display.releaseToolHotImageList (hotImageList);
}
if (disabledImageList != null) {
OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, 0);
- disabledImageList.dispose ();
+ display.releaseToolDisabledImageList (disabledImageList);
}
imageList = hotImageList = disabledImageList = null;
+ super.releaseWidget ();
}
void setDefaultFont () {
@@ -475,7 +477,6 @@ void setDisabledImageList (ImageList imageList) { int hImageList = 0;
if ((disabledImageList = imageList) != null) {
hImageList = disabledImageList.getHandle ();
- disabledImageList.setBackground (getBackgroundPixel ());
}
OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, hImageList);
}
@@ -490,7 +491,6 @@ void setHotImageList (ImageList imageList) { int hImageList = 0;
if ((hotImageList = imageList) != null) {
hImageList = hotImageList.getHandle ();
- hotImageList.setBackground (getBackgroundPixel ());
}
OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, hImageList);
}
@@ -500,7 +500,6 @@ void setImageList (ImageList imageList) { int hImageList = 0;
if ((this.imageList = imageList) != null) {
hImageList = imageList.getHandle ();
- imageList.setBackground (getBackgroundPixel ());
}
OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, hImageList);
}
@@ -620,27 +619,6 @@ LRESULT WM_SIZE (int wParam, int lParam) { return result;
}
-LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
- LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
- if (result != null) return result;
- if (imageList != null && background == -1) {
- imageList.setBackground (defaultBackground ());
- int hImageList = imageList.getHandle ();
- OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, hImageList);
- }
- if (hotImageList != null && background == -1) {
- hotImageList.setBackground (defaultBackground ());
- int hImageList = hotImageList.getHandle ();
- OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, hImageList);
- }
- if (disabledImageList != null && background == -1) {
- disabledImageList.setBackground (defaultBackground ());
- int hImageList = disabledImageList.getHandle ();
- OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, hImageList);
- }
- return result;
-}
-
LRESULT wmCommandChild (int wParam, int lParam) {
ToolItem child = items [wParam & 0xFFFF];
if (child == null) return null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java index 148304d8c2..b1bbcd10d9 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java @@ -546,10 +546,13 @@ void updateImages () { ImageList hotImageList = parent.getHotImageList ();
ImageList disabledImageList = parent.getDisabledImageList();
if (info.iImage == OS.I_IMAGENONE) {
- if (imageList == null) imageList = new ImageList ();
+ Display display = getDisplay ();
+ Rectangle bounds = image.getBounds ();
+ Point size = new Point (bounds.width, bounds.height);
+ if (imageList == null) imageList = display.getToolImageList (size);
info.iImage = imageList.add (image);
parent.setImageList (imageList);
- if (disabledImageList == null) disabledImageList = new ImageList ();
+ if (disabledImageList == null) disabledImageList = display.getToolDisabledImageList (size);
Image disabled = disabledImage;
if (disabledImage == null) {
disabled = image;
@@ -561,7 +564,7 @@ void updateImages () { disabledImageList.add (disabled);
parent.setDisabledImageList (disabledImageList);
if ((parent.style & SWT.FLAT) != 0) {
- if (hotImageList == null) hotImageList = new ImageList ();
+ if (hotImageList == null) hotImageList = display.getToolHotImageList (size);
hotImageList.add (hotImage != null ? hotImage : image);
parent.setHotImageList (hotImageList);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java index 3d47d53241..9605ccaf3f 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java @@ -337,7 +337,8 @@ void destroyItem (TreeItem item) { if (count == 0) {
if (imageList != null) {
OS.SendMessage (handle, OS.TVM_SETIMAGELIST, 0, 0);
- imageList.dispose ();
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
}
imageList = null;
items = new TreeItem [4];
@@ -586,12 +587,13 @@ int imageIndex (Image image) { if (imageList == null) {
int hOldList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);
if (hOldList != 0) OS.ImageList_Destroy (hOldList);
- imageList = new ImageList ();
- imageList.setBackground (getBackgroundPixel ());
- imageList.add (image);
+ Rectangle bounds = image.getBounds ();
+ imageList = getDisplay ().getImageList (new Point (bounds.width, bounds.height));
+ int index = imageList.indexOf (image);
+ if (index == -1) index = imageList.add (image);
int hImageList = imageList.getHandle ();
OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);
- return 0;
+ return index;
}
int index = imageList.indexOf (image);
if (index != -1) return index;
@@ -626,10 +628,10 @@ void releaseWidget () { }
}
items = null;
- super.releaseWidget ();
if (imageList != null) {
OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, 0);
- imageList.dispose ();
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
} else {
int hOldList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);
OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, 0);
@@ -639,6 +641,7 @@ void releaseWidget () { int hOldList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_STATE, 0);
OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_STATE, 0);
if (hOldList != 0) OS.ImageList_Destroy (hOldList);
+ super.releaseWidget ();
}
@@ -665,7 +668,8 @@ public void removeAll () { }
if (imageList != null) {
OS.SendMessage (handle, OS.TVM_SETIMAGELIST, 0, 0);
- imageList.dispose ();
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
}
imageList = null;
items = new TreeItem [4];
@@ -793,12 +797,6 @@ void setBackgroundPixel (int pixel) { int oldPixel = OS.SendMessage (handle, OS.TVM_GETBKCOLOR, 0, 0);
if (oldPixel != -1) OS.SendMessage (handle, OS.TVM_SETBKCOLOR, 0, -1);
OS.SendMessage (handle, OS.TVM_SETBKCOLOR, 0, pixel);
- if (pixel == -1) pixel = getBackgroundPixel ();
- if (imageList != null) {
- imageList.setBackground (pixel);
- int hImageList = imageList.getHandle ();
- OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);
- }
if ((style & SWT.CHECK) != 0) setCheckboxImageList ();
}
@@ -1337,11 +1335,6 @@ LRESULT WM_SETFOCUS (int wParam, int lParam) { LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
if (result != null) return result;
- if (imageList != null && background == -1) {
- imageList.setBackground (defaultBackground ());
- int hImageList = imageList.getHandle ();
- OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);
- }
if ((style & SWT.CHECK) != 0) setCheckboxImageList ();
return result;
}
|