Changeset 59
- Timestamp:
- 03/30/08 22:04:08 (7 months ago)
- Files:
-
- trunk/win32/dfl/imagelist.d (modified) (5 diffs)
- trunk/win32/dfl/internal/winapi.d (modified) (1 diff)
- trunk/win32/dfl/toolbar.d (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/win32/dfl/imagelist.d
r47 r59 34 34 35 35 36 final void addStrip(Image img) 37 { 38 HGDIOBJ hgo; 39 if(1 != img._imgtype(&hgo)) 40 { 41 debug 42 { 43 assert(0, "Image list: addStrip needs bitmap"); 44 } 45 _unableimg(); 46 } 47 48 auto sz = imageSize; 49 if(img.height != sz.height 50 || img.width % sz.width) 51 { 52 debug 53 { 54 assert(0, "Image list: invalid image size"); 55 } 56 _unableimg(); 57 } 58 int num = img.width / sz.width; 59 60 /+ 61 if(1 == num) 62 { 63 add(img); 64 return; 65 } 66 +/ 67 68 auto _hdl = handle; // _addhbitmap needs the handle! Could avoid this in the future. 69 _addhbitmap(hgo); 70 71 int x = 0; 72 for(; num; num--) 73 { 74 auto sp = new StripPart(); 75 sp.origImg = img; 76 sp.hbm = hgo; 77 sp.partBounds = Rect(x, 0, sz.width, sz.height); 78 79 _images ~= sp; 80 81 x += sz.width; 82 } 83 } 84 85 36 86 package: 37 87 38 88 Image[] _images; 89 90 91 static class StripPart: Image 92 { 93 override Size size() // getter 94 { 95 return partBounds.size; 96 } 97 98 99 override void draw(Graphics g, Point pt) 100 { 101 HDC memdc; 102 memdc = CreateCompatibleDC(g.handle); 103 try 104 { 105 HGDIOBJ hgo; 106 hgo = SelectObject(memdc, hbm); 107 BitBlt(g.handle, pt.x, pt.y, partBounds.width, partBounds.height, memdc, partBounds.x, partBounds.y, SRCCOPY); 108 SelectObject(memdc, hgo); // Old bitmap. 109 } 110 finally 111 { 112 DeleteDC(memdc); 113 } 114 } 115 116 117 override void drawStretched(Graphics g, Rect r) 118 { 119 HDC memdc; 120 memdc = CreateCompatibleDC(g.handle); 121 try 122 { 123 HGDIOBJ hgo; 124 int lstretch; 125 hgo = SelectObject(memdc, hbm); 126 lstretch = SetStretchBltMode(g.handle, COLORONCOLOR); 127 StretchBlt(g.handle, r.x, r.y, r.width, r.height, 128 memdc, partBounds.x, partBounds.y, partBounds.width, partBounds.height, SRCCOPY); 129 SetStretchBltMode(g.handle, lstretch); 130 SelectObject(memdc, hgo); // Old bitmap. 131 } 132 finally 133 { 134 DeleteDC(memdc); 135 } 136 } 137 138 139 Image origImg; // Hold this so the HBITMAP doesn't get collected. 140 HBITMAP hbm; 141 Rect partBounds; 142 } 39 143 40 144 … … 146 250 assert(!isHandleCreated); 147 251 252 assert(sz.width && sz.height); 253 148 254 _w = sz.width; 149 255 _h = sz.height; … … 298 404 299 405 300 void_addimg(Image img)406 int _addimg(Image img) 301 407 { 302 408 assert(isHandleCreated); … … 307 413 { 308 414 case 1: 309 { 310 COLORREF cr; 311 if(_transcolor == Color.empty 312 || _transcolor == Color.transparent) 313 { 314 cr = CLR_NONE; // ? 315 } 316 else 317 { 318 cr = _transcolor.toRgb(); 319 } 320 result = imageListAddMasked(_hil, cast(HBITMAP)hgo, cr); 321 } 415 result = _addhbitmap(hgo); 322 416 break; 323 417 … … 332 426 //if(-1 == result) 333 427 // _unableimg(); 428 return result; 429 } 430 431 int _addhbitmap(HBITMAP hbm) 432 { 433 assert(isHandleCreated); 434 435 COLORREF cr; 436 if(_transcolor == Color.empty 437 || _transcolor == Color.transparent) 438 { 439 cr = CLR_NONE; // ? 440 } 441 else 442 { 443 cr = _transcolor.toRgb(); 444 } 445 return imageListAddMasked(_hil, cast(HBITMAP)hbm, cr); 334 446 } 335 447 } trunk/win32/dfl/internal/winapi.d
r58 r59 2088 2088 TB_BUTTONSTRUCTSIZE = WM_USER + 30, 2089 2089 TB_SETBUTTONSIZE = WM_USER + 31, 2090 TB_AUTOSIZE = WM_USER + 33, 2090 2091 TB_SETIMAGELIST = WM_USER + 48, 2091 2092 TB_INSERTBUTTONW = WM_USER + 67, 2092 2093 TB_ADDBUTTONSW = WM_USER + 68, 2094 TB_SETPADDING = WM_USER + 87, 2093 2095 } 2094 2096 trunk/win32/dfl/toolbar.d
r58 r59 568 568 prevwproc(TB_BUTTONSTRUCTSIZE, TBBUTTON.sizeof, 0); 569 569 570 //prevwproc(TB_SETPADDING, 0, MAKELPARAM(0, 0)); 571 570 572 if(_imglist) 571 573 prevwproc(TB_SETIMAGELIST, 0, cast(WPARAM)_imglist.handle); … … 575 577 _ins(idx, tbb); 576 578 } 579 580 //prevwproc(TB_AUTOSIZE, 0, 0); 577 581 } 578 582 … … 619 623 if(dfl.internal.utf.useUnicode) 620 624 { 621 xtb.iString = cast(typeof(xtb.iString))dfl.internal.utf.toUnicodez(tbb._text); 625 if(tbb._text.length) 626 xtb.iString = cast(typeof(xtb.iString))dfl.internal.utf.toUnicodez(tbb._text); 622 627 //prevwproc(TB_ADDBUTTONSW, 1, cast(LPARAM)&xtb); 623 628 lresult = prevwproc(TB_INSERTBUTTONW, idx, cast(LPARAM)&xtb); … … 625 630 else 626 631 { 627 xtb.iString = cast(typeof(xtb.iString))dfl.internal.utf.toAnsiz(tbb._text); 632 if(tbb._text.length) 633 xtb.iString = cast(typeof(xtb.iString))dfl.internal.utf.toAnsiz(tbb._text); 628 634 //prevwproc(TB_ADDBUTTONSA, 1, cast(LPARAM)&xtb); 629 635 lresult = prevwproc(TB_INSERTBUTTONA, idx, cast(LPARAM)&xtb);
