@@ -183,9 +183,13 @@ private void drawChevron (long hDC, RECT rect) {
183183
184184void drawItem (GC gc , long hTheme , RECT clipRect , boolean drawFocus ) {
185185 long hDC = gc .handle ;
186- int headerHeight = parent .getBandHeight ();
186+ int headerHeightinPixels = getHeaderHeightInPixels ();
187+ int zoom = getZoom ();
188+ int imageHeightInPixels = DPIUtil .scaleUp (imageHeight , zoom );
189+ int imageWidthInPixels = DPIUtil .scaleUp (imageWidth , zoom );
190+
187191 RECT rect = new RECT ();
188- OS .SetRect (rect , x , y , x + width , y + headerHeight );
192+ OS .SetRect (rect , x , y , x + width , y + headerHeightinPixels );
189193 if (hTheme != 0 ) {
190194 OS .DrawThemeBackground (hTheme , hDC , OS .EBP_NORMALGROUPHEAD , 0 , rect , clipRect );
191195 } else {
@@ -194,14 +198,10 @@ void drawItem (GC gc, long hTheme, RECT clipRect, boolean drawFocus) {
194198 OS .SelectObject (hDC , oldBrush );
195199 }
196200 if (image != null ) {
197- int zoom = getZoom ();
198201 rect .left += ExpandItem .TEXT_INSET ;
199- if (imageHeight > headerHeight ) {
200- gc .drawImage (image , DPIUtil .scaleDown (rect .left , zoom ), DPIUtil .scaleDown (rect .top + headerHeight - imageHeight , zoom ));
201- } else {
202- gc .drawImage (image , DPIUtil .scaleDown (rect .left , zoom ), DPIUtil .scaleDown (rect .top + (headerHeight - imageHeight ) / 2 , zoom ));
203- }
204- rect .left += imageWidth ;
202+ int yInPoints = DPIUtil .scaleDown (rect .top + ((headerHeightinPixels - imageHeightInPixels ) / 2 ), zoom );
203+ gc .drawImage (image , DPIUtil .scaleDown (rect .left , zoom ), yInPoints );
204+ rect .left += imageWidthInPixels ;
205205 }
206206 if (text .length () > 0 ) {
207207 rect .left += ExpandItem .TEXT_INSET ;
@@ -213,8 +213,7 @@ void drawItem (GC gc, long hTheme, RECT clipRect, boolean drawFocus) {
213213 } else {
214214 buffer = (RLE + text ).toCharArray ();
215215 }
216- }
217- else {
216+ } else {
218217 buffer = text .toCharArray ();
219218 }
220219 if (hTheme != 0 ) {
@@ -227,7 +226,7 @@ void drawItem (GC gc, long hTheme, RECT clipRect, boolean drawFocus) {
227226 }
228227 int chevronSize = ExpandItem .CHEVRON_SIZE ;
229228 rect .left = rect .right - chevronSize ;
230- rect .top = y + ( headerHeight - chevronSize ) / 2 ;
229+ rect .top = y ;
231230 rect .bottom = rect .top + chevronSize ;
232231 if (hTheme != 0 ) {
233232 int partID = expanded ? OS .EBP_NORMALGROUPCOLLAPSE : OS .EBP_NORMALGROUPEXPAND ;
@@ -237,18 +236,18 @@ void drawItem (GC gc, long hTheme, RECT clipRect, boolean drawFocus) {
237236 drawChevron (hDC , rect );
238237 }
239238 if (drawFocus ) {
240- OS .SetRect (rect , x + 1 , y + 1 , x + width - 2 , y + headerHeight - 2 );
239+ OS .SetRect (rect , x + 1 , y + 1 , x + width - 2 , y + headerHeightinPixels - 2 );
241240 OS .DrawFocusRect (hDC , rect );
242241 }
243242 if (expanded ) {
244243 if (!parent .isAppThemed ()) {
245244 long pen = OS .CreatePen (OS .PS_SOLID , 1 , OS .GetSysColor (OS .COLOR_BTNFACE ));
246245 long oldPen = OS .SelectObject (hDC , pen );
247246 int [] points = {
248- x , y + headerHeight ,
249- x , y + headerHeight + height ,
250- x + width - 1 , y + headerHeight + height ,
251- x + width - 1 , y + headerHeight - 1 };
247+ x , y + headerHeightinPixels ,
248+ x , y + headerHeightinPixels + height ,
249+ x + width - 1 , y + headerHeightinPixels + height ,
250+ x + width - 1 , y + headerHeightinPixels - 1 };
252251 OS .Polyline (hDC , points , points .length / 2 );
253252 OS .SelectObject (hDC , oldPen );
254253 OS .DeleteObject (pen );
@@ -310,7 +309,12 @@ public int getHeaderHeight () {
310309}
311310
312311int getHeaderHeightInPixels () {
313- return Math .max (parent .getBandHeight (), imageHeight );
312+ int headerHeightInPixels = parent .getBandHeight ();
313+ int imageHeightInPixels = DPIUtil .scaleUp (imageHeight , getZoom ());
314+ if (imageHeightInPixels > headerHeightInPixels ) {
315+ headerHeightInPixels = imageHeightInPixels + headerHeightInPixels ;
316+ }
317+ return headerHeightInPixels ;
314318}
315319
316320/**
@@ -372,17 +376,20 @@ boolean isHover (int x, int y) {
372376
373377void redraw (boolean all ) {
374378 long parentHandle = parent .handle ;
375- int headerHeight = parent .getBandHeight ();
379+ int headerHeightInPixels = getHeaderHeightInPixels ();
380+ int zoom = getZoom ();
381+ int imageHeightInPixels = DPIUtil .scaleUp (imageHeight , zoom );
382+ int imageWidthInPixels = DPIUtil .scaleUp (imageWidth , zoom );
376383 RECT rect = new RECT ();
377- int left = all ? x : x + width - headerHeight ;
378- OS .SetRect (rect , left , y , x + width , y + headerHeight );
384+ int left = all ? x : x + width - headerHeightInPixels ;
385+ OS .SetRect (rect , left , y , x + width , y + headerHeightInPixels );
379386 OS .InvalidateRect (parentHandle , rect , true );
380- if (imageHeight > headerHeight ) {
381- OS .SetRect (rect , x + ExpandItem .TEXT_INSET , y + headerHeight - imageHeight , x + ExpandItem .TEXT_INSET + imageWidth , y );
387+ if (imageHeightInPixels > headerHeightInPixels ) {
388+ OS .SetRect (rect , x + ExpandItem .TEXT_INSET , y + headerHeightInPixels - imageHeightInPixels , x + ExpandItem .TEXT_INSET + imageWidthInPixels , y );
382389 OS .InvalidateRect (parentHandle , rect , true );
383390 }
384391 if (!parent .isAppThemed ()) {
385- OS .SetRect (rect , x , y + headerHeight , x + width , y + headerHeight + height + 1 );
392+ OS .SetRect (rect , x , y + headerHeightInPixels , x + width , y + headerHeightInPixels + height + 1 );
386393 OS .InvalidateRect (parentHandle , rect , true );
387394 }
388395}
@@ -401,11 +408,8 @@ void releaseWidget () {
401408
402409void setBoundsInPixels (int x , int y , int width , int height , boolean move , boolean size ) {
403410 redraw (true );
404- int headerHeight = parent . getBandHeight ();
411+ int headerHeightInPixels = getHeaderHeightInPixels ();
405412 if (move ) {
406- if (imageHeight > headerHeight ) {
407- y += (imageHeight - headerHeight );
408- }
409413 this .x = x ;
410414 this .y = y ;
411415 redraw (true );
@@ -421,8 +425,8 @@ void setBoundsInPixels (int x, int y, int width, int height, boolean move, boole
421425 width = Math .max (0 , width - BORDER * 2 );
422426 height = Math .max (0 , height - BORDER );
423427 }
424- if (move && size ) control .setBoundsInPixels (x , y + headerHeight , width , height );
425- if (move && !size ) control .setLocationInPixels (x , y + headerHeight );
428+ if (move && size ) control .setBoundsInPixels (x , y + headerHeightInPixels , width , height );
429+ if (move && !size ) control .setLocationInPixels (x , y + headerHeightInPixels );
426430 if (!move && size ) control .setSizeInPixels (width , height );
427431 }
428432}
@@ -504,7 +508,7 @@ public void setImage (Image image) {
504508 super .setImage (image );
505509 int oldImageHeight = imageHeight ;
506510 if (image != null ) {
507- Rectangle bounds = image .getBoundsInPixels ();
511+ Rectangle bounds = image .getBounds ();
508512 imageHeight = bounds .height ;
509513 imageWidth = bounds .width ;
510514 } else {
0 commit comments