Skip to content

Commit a1dce0e

Browse files
committed
Adapt Table and Tree to new GC#drawImage API
This change replaces the old drawImage API call in Table and tree with the newer, simplified drawImage overload that takes fewer parameters.
1 parent 2b3501a commit a1dce0e

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7302,8 +7302,7 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) {
73027302
Point size = imageList == null ? new Point (rect.width, rect.height) : Win32DPIUtils.pointToPixelAsSize(imageList.getImageSize(), getZoom());
73037303
int y = imageRect.top + Math.max (0, (imageRect.bottom - imageRect.top - size.y) / 2);
73047304
int zoom = getZoom();
7305-
rect = Win32DPIUtils.pixelToPoint(rect, zoom);
7306-
gc.drawImage (image, rect.x, rect.y, rect.width, rect.height, DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom), DPIUtil.pixelToPoint(size.x, zoom), DPIUtil.pixelToPoint(size.y, zoom));
7305+
gc.drawImage (image, DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom), DPIUtil.pixelToPoint(size.x, zoom), DPIUtil.pixelToPoint(size.y, zoom));
73077306
x += size.x + INSET + (pinfo.iSubItem == 0 ? -2 : 4);
73087307
} else {
73097308
x += INSET + 2;

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -522,15 +522,14 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
522522
if (images != null) image = images [index];
523523
}
524524
if (image != null) {
525-
Rectangle bounds = image.getBounds (); // Points
526525
if (size == null) size = Win32DPIUtils.pixelToPointAsSize (getImageSize (), zoom); // To Points
527526
if (!ignoreDrawForeground) {
528527
GCData data = new GCData();
529528
data.device = display;
530529
GC gc = createNewGC(hDC, data);
531530
RECT iconRect = item.getBounds (index, false, true, false, false, true, hDC); // Pixels
532531
gc.setClipping (Win32DPIUtils.pixelToPoint(new Rectangle(iconRect.left, iconRect.top, iconRect.right - iconRect.left, iconRect.bottom - iconRect.top), zoom));
533-
gc.drawImage (image, 0, 0, bounds.width, bounds.height, DPIUtil.pixelToPoint(iconRect.left, zoom), DPIUtil.pixelToPoint(iconRect.top, zoom), size.x, size.y);
532+
gc.drawImage (image, DPIUtil.pixelToPoint(iconRect.left, zoom), DPIUtil.pixelToPoint(iconRect.top, zoom), size.x, size.y);
534533
OS.SelectClipRgn (hDC, 0);
535534
gc.dispose ();
536535
}
@@ -760,7 +759,6 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
760759
int inset = i != 0 ? INSET : 0;
761760
int offset = i != 0 ? INSET : INSET + 2;
762761
if (image != null) {
763-
Rectangle bounds = image.getBounds (); // Points
764762
if (size == null) size = Win32DPIUtils.pixelToPointAsSize (getImageSize (), zoom); // To Points
765763
if (!ignoreDrawForeground) {
766764
//int y1 = rect.top + (index == 0 ? (getItemHeight () - size.y) / 2 : 0);
@@ -770,7 +768,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
770768
data.device = display;
771769
GC gc = createNewGC(hDC, data);
772770
gc.setClipping (Win32DPIUtils.pixelToPoint(new Rectangle(x1, rect.top, rect.right - x1, rect.bottom - rect.top), zoom));
773-
gc.drawImage (image, 0, 0, bounds.width, bounds.height, DPIUtil.pixelToPoint(x1, zoom), DPIUtil.pixelToPoint(y1, zoom), size.x, size.y);
771+
gc.drawImage (image, DPIUtil.pixelToPoint(x1, zoom), DPIUtil.pixelToPoint(y1, zoom), size.x, size.y);
774772
OS.SelectClipRgn (hDC, 0);
775773
gc.dispose ();
776774
}
@@ -8256,9 +8254,8 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) {
82568254
RECT imageRect = item [0].getBounds (index [0], false, true, false, false, false, hDC);
82578255
if (imageList == null) size.x = imageRect.right - imageRect.left;
82588256
if (image != null) {
8259-
Rectangle rect = image.getBounds (); // Points
82608257
int zoom = getZoom();
8261-
gc.drawImage (image, rect.x, rect.y, rect.width, rect.height, DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(imageRect.top, zoom), DPIUtil.pixelToPoint(size.x, zoom), DPIUtil.pixelToPoint(size.y, zoom));
8258+
gc.drawImage (image, DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(imageRect.top, zoom), DPIUtil.pixelToPoint(size.x, zoom), DPIUtil.pixelToPoint(size.y, zoom));
82628259
x += INSET + (index [0] == 0 ? 1 : 0);
82638260
}
82648261
x += size.x;

0 commit comments

Comments
 (0)