Changeset 45:f4a025bb42e9
- Timestamp:
- 02/02/08 12:33:51
(1 year ago)
- Author:
- Frank Benoit <benoit@tionex.de>
- branch:
- default
- Message:
CoolBar?
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r44 |
r45 |
|
| 1405 | 1405 | public static const int RDW_UPDATENOW = 0x100; |
|---|
| 1406 | 1406 | public static const int READ_CONTROL = 0x20000; |
|---|
| 1407 | | public static const char[] REBARCLASSNAME = "ReBarWindow32"; //$NON-NLS-1$ |
|---|
| | 1407 | public static const TCHAR[] REBARCLASSNAME = "ReBarWindow32"; //$NON-NLS-1$ |
|---|
| 1408 | 1408 | public static const int RGN_AND = 0x1; |
|---|
| 1409 | 1409 | public static const int RGN_COPY = 5; |
|---|
| r44 |
r45 |
|
| 37 | 37 | alias HANDLE HTHEME; |
|---|
| 38 | 38 | |
|---|
| | 39 | struct NMREBARCHILDSIZE { |
|---|
| | 40 | NMHDR hdr; |
|---|
| | 41 | UINT uBand; |
|---|
| | 42 | UINT wID; |
|---|
| | 43 | RECT rcChild; |
|---|
| | 44 | RECT rcBand; |
|---|
| | 45 | } |
|---|
| 39 | 46 | // .... |
|---|
| 40 | 47 | //-------------------------------------------------------------------------------- |
|---|
| r31 |
r45 |
|
| 15 | 15 | import dwt.widgets.Composite; |
|---|
| 16 | 16 | |
|---|
| 17 | | class CoolBar : Composite { |
|---|
| 18 | | } |
|---|
| 19 | | /++ |
|---|
| | 17 | |
|---|
| 20 | 18 | import dwt.DWT; |
|---|
| 21 | 19 | import dwt.DWTException; |
|---|
| 22 | 20 | import dwt.graphics.Point; |
|---|
| 23 | 21 | import dwt.graphics.Rectangle; |
|---|
| 24 | | import dwt.internal.win32.INITCOMMONCONTROLSEX; |
|---|
| 25 | | import dwt.internal.win32.LRESULT; |
|---|
| 26 | | import dwt.internal.win32.MARGINS; |
|---|
| 27 | | import dwt.internal.win32.NMCUSTOMDRAW; |
|---|
| 28 | | import dwt.internal.win32.NMHDR; |
|---|
| 29 | | import dwt.internal.win32.NMREBARCHEVRON; |
|---|
| 30 | | import dwt.internal.win32.NMREBARCHILDSIZE; |
|---|
| 31 | 22 | import dwt.internal.win32.OS; |
|---|
| 32 | | import dwt.internal.win32.POINT; |
|---|
| 33 | | import dwt.internal.win32.REBARBANDINFO; |
|---|
| 34 | | import dwt.internal.win32.RECT; |
|---|
| 35 | | import dwt.internal.win32.TCHAR; |
|---|
| 36 | | import dwt.internal.win32.WNDCLASS; |
|---|
| | 23 | |
|---|
| | 24 | import dwt.widgets.Composite; |
|---|
| | 25 | import dwt.widgets.Control; |
|---|
| | 26 | import dwt.widgets.CoolItem; |
|---|
| | 27 | import dwt.widgets.Event; |
|---|
| | 28 | |
|---|
| | 29 | import dwt.dwthelper.utils; |
|---|
| 37 | 30 | |
|---|
| 38 | 31 | /** |
|---|
| … | … | |
| 60 | 53 | */ |
|---|
| 61 | 54 | |
|---|
| 62 | | public class CoolBar extends Composite { |
|---|
| | 55 | public class CoolBar : Composite { |
|---|
| | 56 | |
|---|
| 63 | 57 | CoolItem [] items; |
|---|
| 64 | 58 | CoolItem [] originalItems; |
|---|
| 65 | 59 | bool locked; |
|---|
| 66 | 60 | bool ignoreResize; |
|---|
| 67 | | static final int ReBarProc; |
|---|
| 68 | | static final TCHAR ReBarClass = new TCHAR (0, OS.REBARCLASSNAME, true); |
|---|
| 69 | | static { |
|---|
| 70 | | INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX (); |
|---|
| | 61 | static const WNDPROC ReBarProc; |
|---|
| | 62 | static const TCHAR* ReBarClass = OS.REBARCLASSNAME.ptr; |
|---|
| | 63 | static this() { |
|---|
| | 64 | INITCOMMONCONTROLSEX icex; |
|---|
| 71 | 65 | icex.dwSize = INITCOMMONCONTROLSEX.sizeof; |
|---|
| 72 | 66 | icex.dwICC = OS.ICC_COOL_CLASSES; |
|---|
| 73 | | OS.InitCommonControlsEx (icex); |
|---|
| 74 | | WNDCLASS lpWndClass = new WNDCLASS (); |
|---|
| 75 | | OS.GetClassInfo (0, ReBarClass, lpWndClass); |
|---|
| | 67 | OS.InitCommonControlsEx (&icex); |
|---|
| | 68 | WNDCLASS lpWndClass; |
|---|
| | 69 | OS.GetClassInfo (null, ReBarClass, &lpWndClass); |
|---|
| 76 | 70 | ReBarProc = lpWndClass.lpfnWndProc; |
|---|
| 77 | 71 | } |
|---|
| 78 | | static final int SEPARATOR_WIDTH = 2; |
|---|
| 79 | | static final int MAX_WIDTH = 0x7FFF; |
|---|
| 80 | | static final int DEFAULT_COOLBAR_WIDTH = 0; |
|---|
| 81 | | static final int DEFAULT_COOLBAR_HEIGHT = 0; |
|---|
| | 72 | static const int SEPARATOR_WIDTH = 2; |
|---|
| | 73 | static const int MAX_WIDTH = 0x7FFF; |
|---|
| | 74 | static const int DEFAULT_COOLBAR_WIDTH = 0; |
|---|
| | 75 | static const int DEFAULT_COOLBAR_HEIGHT = 0; |
|---|
| 82 | 76 | |
|---|
| 83 | 77 | /** |
|---|
| … | … | |
| 109 | 103 | * @see Widget#getStyle |
|---|
| 110 | 104 | */ |
|---|
| 111 | | public CoolBar (Composite parent, int style) { |
|---|
| | 105 | public this (Composite parent, int style) { |
|---|
| 112 | 106 | super (parent, checkStyle (style)); |
|---|
| 113 | 107 | /* |
|---|
| … | … | |
| 131 | 125 | } |
|---|
| 132 | 126 | |
|---|
| 133 | | int callWindowProc (int hwnd, int msg, int wParam, int lParam) { |
|---|
| 134 | | if (handle is 0) return 0; |
|---|
| 135 | | return OS.CallWindowProc (ReBarProc, hwnd, msg, wParam, lParam); |
|---|
| | 127 | LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { |
|---|
| | 128 | if (handle is null) return LRESULT.NULL; |
|---|
| | 129 | return cast(LRESULT) OS.CallWindowProc (ReBarProc, hwnd, msg, wParam, lParam); |
|---|
| 136 | 130 | } |
|---|
| 137 | 131 | |
|---|
| … | … | |
| 175 | 169 | } |
|---|
| 176 | 170 | } |
|---|
| 177 | | RECT oldRect = new RECT (); |
|---|
| 178 | | OS.GetWindowRect (handle, oldRect); |
|---|
| | 171 | RECT oldRect; |
|---|
| | 172 | OS.GetWindowRect (handle, &oldRect); |
|---|
| 179 | 173 | int oldWidth = oldRect.right - oldRect.left; |
|---|
| 180 | 174 | int oldHeight = oldRect.bottom - oldRect.top; |
|---|
| 181 | 175 | int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOREDRAW | OS.SWP_NOZORDER; |
|---|
| 182 | | SetWindowPos (handle, 0, 0, 0, newWidth, newHeight, flags); |
|---|
| 183 | | RECT rect = new RECT (); |
|---|
| 184 | | OS.SendMessage (handle, OS.RB_GETRECT, count - 1, rect); |
|---|
| | 176 | SetWindowPos (handle, null, 0, 0, newWidth, newHeight, flags); |
|---|
| | 177 | RECT rect; |
|---|
| | 178 | OS.SendMessage (handle, OS.RB_GETRECT, count - 1, &rect); |
|---|
| 185 | 179 | height = Math.max (height, rect.bottom); |
|---|
| 186 | | SetWindowPos (handle, 0, 0, 0, oldWidth, oldHeight, flags); |
|---|
| 187 | | REBARBANDINFO rbBand = new REBARBANDINFO (); |
|---|
| | 180 | SetWindowPos (handle, null, 0, 0, oldWidth, oldHeight, flags); |
|---|
| | 181 | REBARBANDINFO rbBand; |
|---|
| 188 | 182 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 189 | 183 | rbBand.fMask = OS.RBBIM_IDEALSIZE | OS.RBBIM_STYLE; |
|---|
| 190 | 184 | int rowWidth = 0; |
|---|
| 191 | 185 | for (int i = 0; i < count; i++) { |
|---|
| 192 | | OS.SendMessage(handle, OS.RB_GETBANDINFO, i, rbBand); |
|---|
| | 186 | OS.SendMessage(handle, OS.RB_GETBANDINFO, i, &rbBand); |
|---|
| 193 | 187 | if ((rbBand.fStyle & OS.RBBS_BREAK) !is 0) { |
|---|
| 194 | 188 | width = Math.max(width, rowWidth); |
|---|
| … | … | |
| 237 | 231 | * create. |
|---|
| 238 | 232 | */ |
|---|
| 239 | | int hFont = OS.GetStockObject (OS.SYSTEM_FONT); |
|---|
| | 233 | auto hFont = OS.GetStockObject (OS.SYSTEM_FONT); |
|---|
| 240 | 234 | OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0); |
|---|
| 241 | 235 | } |
|---|
| … | … | |
| 251 | 245 | items = newItems; |
|---|
| 252 | 246 | } |
|---|
| 253 | | int hHeap = OS.GetProcessHeap (); |
|---|
| 254 | | int lpText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof); |
|---|
| 255 | | REBARBANDINFO rbBand = new REBARBANDINFO (); |
|---|
| | 247 | auto hHeap = OS.GetProcessHeap (); |
|---|
| | 248 | auto lpText = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof); |
|---|
| | 249 | REBARBANDINFO rbBand; |
|---|
| 256 | 250 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 257 | 251 | rbBand.fMask = OS.RBBIM_TEXT | OS.RBBIM_STYLE | OS.RBBIM_ID; |
|---|
| … | … | |
| 290 | 284 | |
|---|
| 291 | 285 | /* Insert the item */ |
|---|
| 292 | | if (OS.SendMessage (handle, OS.RB_INSERTBAND, index, rbBand) is 0) { |
|---|
| | 286 | if (OS.SendMessage (handle, OS.RB_INSERTBAND, index, &rbBand) is 0) { |
|---|
| 293 | 287 | error (DWT.ERROR_ITEM_NOT_ADDED); |
|---|
| 294 | 288 | } |
|---|
| … | … | |
| 381 | 375 | } |
|---|
| 382 | 376 | |
|---|
| 383 | | void drawThemeBackground (int hDC, int hwnd, RECT rect) { |
|---|
| | 377 | void drawThemeBackground (HDC hDC, HWND hwnd, RECT* rect) { |
|---|
| 384 | 378 | if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { |
|---|
| 385 | 379 | if (background is -1 && (style & DWT.FLAT) !is 0) { |
|---|
| … | … | |
| 391 | 385 | } |
|---|
| 392 | 386 | } |
|---|
| 393 | | RECT rect2 = new RECT (); |
|---|
| 394 | | OS.GetClientRect (handle, rect2); |
|---|
| 395 | | OS.MapWindowPoints (handle, hwnd, rect2, 2); |
|---|
| 396 | | POINT lpPoint = new POINT (); |
|---|
| 397 | | OS.SetWindowOrgEx (hDC, -rect2.left, -rect2.top, lpPoint); |
|---|
| | 387 | RECT rect2; |
|---|
| | 388 | OS.GetClientRect (handle, &rect2); |
|---|
| | 389 | OS.MapWindowPoints (handle, hwnd, cast(POINT*) &rect2, 2); |
|---|
| | 390 | POINT lpPoint; |
|---|
| | 391 | OS.SetWindowOrgEx (hDC, -rect2.left, -rect2.top, &lpPoint); |
|---|
| 398 | 392 | OS.SendMessage (handle, OS.WM_PRINT, hDC, OS.PRF_CLIENT | OS.PRF_ERASEBKGND); |
|---|
| 399 | 393 | OS.SetWindowOrgEx (hDC, lpPoint.x, lpPoint.y, null); |
|---|
| … | … | |
| 408 | 402 | int margin = 0; |
|---|
| 409 | 403 | if (OS.COMCTL32_MAJOR >= 6) { |
|---|
| 410 | | MARGINS margins = new MARGINS (); |
|---|
| 411 | | OS.SendMessage (handle, OS.RB_GETBANDMARGINS, 0, margins); |
|---|
| | 404 | MARGINS margins; |
|---|
| | 405 | OS.SendMessage (handle, OS.RB_GETBANDMARGINS, 0, &margins); |
|---|
| 412 | 406 | margin += margins.cxLeftWidth + margins.cxRightWidth; |
|---|
| 413 | 407 | } |
|---|
| 414 | | RECT rect = new RECT (); |
|---|
| 415 | | OS.SendMessage (handle, OS.RB_GETBANDBORDERS, index, rect); |
|---|
| | 408 | RECT rect; |
|---|
| | 409 | OS.SendMessage (handle, OS.RB_GETBANDBORDERS, index, &rect); |
|---|
| 416 | 410 | if ((style & DWT.FLAT) !is 0) { |
|---|
| 417 | 411 | /* |
|---|
| … | … | |
| 460 | 454 | int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0); |
|---|
| 461 | 455 | if (!(0 <= index && index < count)) error (DWT.ERROR_INVALID_RANGE); |
|---|
| 462 | | REBARBANDINFO rbBand = new REBARBANDINFO (); |
|---|
| | 456 | REBARBANDINFO rbBand; |
|---|
| 463 | 457 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 464 | 458 | rbBand.fMask = OS.RBBIM_ID; |
|---|
| 465 | | OS.SendMessage (handle, OS.RB_GETBANDINFO, index, rbBand); |
|---|
| | 459 | OS.SendMessage (handle, OS.RB_GETBANDINFO, index, &rbBand); |
|---|
| 466 | 460 | return items [rbBand.wID]; |
|---|
| 467 | 461 | } |
|---|
| … | … | |
| 507 | 501 | int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0); |
|---|
| 508 | 502 | int [] indices = new int [count]; |
|---|
| 509 | | REBARBANDINFO rbBand = new REBARBANDINFO (); |
|---|
| | 503 | REBARBANDINFO rbBand; |
|---|
| 510 | 504 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 511 | 505 | rbBand.fMask = OS.RBBIM_ID; |
|---|
| 512 | 506 | for (int i=0; i<count; i++) { |
|---|
| 513 | | OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand); |
|---|
| | 507 | OS.SendMessage (handle, OS.RB_GETBANDINFO, i, &rbBand); |
|---|
| 514 | 508 | CoolItem item = items [rbBand.wID]; |
|---|
| 515 | 509 | int index = 0; |
|---|
| … | … | |
| 544 | 538 | int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0); |
|---|
| 545 | 539 | CoolItem [] result = new CoolItem [count]; |
|---|
| 546 | | REBARBANDINFO rbBand = new REBARBANDINFO (); |
|---|
| | 540 | REBARBANDINFO rbBand; |
|---|
| 547 | 541 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 548 | 542 | rbBand.fMask = OS.RBBIM_ID; |
|---|
| 549 | 543 | for (int i=0; i<count; i++) { |
|---|
| 550 | | OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand); |
|---|
| | 544 | OS.SendMessage (handle, OS.RB_GETBANDINFO, i, &rbBand); |
|---|
| 551 | 545 | result [i] = items [rbBand.wID]; |
|---|
| 552 | 546 | } |
|---|
| … | … | |
| 570 | 564 | int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0); |
|---|
| 571 | 565 | Point [] sizes = new Point [count]; |
|---|
| 572 | | REBARBANDINFO rbBand = new REBARBANDINFO (); |
|---|
| | 566 | REBARBANDINFO rbBand; |
|---|
| 573 | 567 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 574 | 568 | rbBand.fMask = OS.RBBIM_CHILDSIZE; |
|---|
| 575 | 569 | int separator = (style & DWT.FLAT) is 0 ? SEPARATOR_WIDTH : 0; |
|---|
| 576 | | MARGINS margins = new MARGINS (); |
|---|
| | 570 | MARGINS margins; |
|---|
| 577 | 571 | for (int i=0; i<count; i++) { |
|---|
| 578 | | RECT rect = new RECT (); |
|---|
| 579 | | OS.SendMessage (handle, OS.RB_GETRECT, i, rect); |
|---|
| 580 | | OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand); |
|---|
| | 572 | RECT rect; |
|---|
| | 573 | OS.SendMessage (handle, OS.RB_GETRECT, i, &rect); |
|---|
| | 574 | OS.SendMessage (handle, OS.RB_GETBANDINFO, i, &rbBand); |
|---|
| 581 | 575 | if (OS.COMCTL32_MAJOR >= 6) { |
|---|
| 582 | | OS.SendMessage (handle, OS.RB_GETBANDMARGINS, 0, margins); |
|---|
| | 576 | OS.SendMessage (handle, OS.RB_GETBANDMARGINS, 0, &margins); |
|---|
| 583 | 577 | rect.left -= margins.cxLeftWidth; |
|---|
| 584 | 578 | rect.right += margins.cxRightWidth; |
|---|
| … | … | |
| 597 | 591 | int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0); |
|---|
| 598 | 592 | if (count is 0) return -1; |
|---|
| 599 | | REBARBANDINFO rbBand = new REBARBANDINFO (); |
|---|
| | 593 | REBARBANDINFO rbBand; |
|---|
| 600 | 594 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 601 | 595 | rbBand.fMask = OS.RBBIM_STYLE; |
|---|
| 602 | 596 | for (int i=index + 1; i<count; i++) { |
|---|
| 603 | | OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand); |
|---|
| | 597 | OS.SendMessage (handle, OS.RB_GETBANDINFO, i, &rbBand); |
|---|
| 604 | 598 | if ((rbBand.fStyle & OS.RBBS_BREAK) !is 0) { |
|---|
| 605 | 599 | return i - 1; |
|---|
| … | … | |
| 612 | 606 | int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0); |
|---|
| 613 | 607 | if (index + 1 is count) return true; |
|---|
| 614 | | REBARBANDINFO rbBand = new REBARBANDINFO (); |
|---|
| | 608 | REBARBANDINFO rbBand; |
|---|
| 615 | 609 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 616 | 610 | rbBand.fMask = OS.RBBIM_STYLE; |
|---|
| 617 | | OS.SendMessage (handle, OS.RB_GETBANDINFO, index + 1, rbBand); |
|---|
| | 611 | OS.SendMessage (handle, OS.RB_GETBANDINFO, index + 1, &rbBand); |
|---|
| 618 | 612 | return (rbBand.fStyle & OS.RBBS_BREAK) !is 0; |
|---|
| 619 | 613 | } |
|---|
| … | … | |
| 696 | 690 | int count = OS.SendMessage(handle, OS.RB_GETBANDCOUNT, 0, 0); |
|---|
| 697 | 691 | if (0 <= index && index < count) { |
|---|
| 698 | | REBARBANDINFO rbBand = new REBARBANDINFO(); |
|---|
| | 692 | REBARBANDINFO rbBand; |
|---|
| 699 | 693 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 700 | 694 | rbBand.fMask = OS.RBBIM_IDEALSIZE; |
|---|
| 701 | | OS.SendMessage (handle, OS.RB_GETBANDINFO, index, rbBand); |
|---|
| 702 | | RECT rect = new RECT (); |
|---|
| 703 | | OS.SendMessage (handle, OS.RB_GETBANDBORDERS, index, rect); |
|---|
| | 695 | OS.SendMessage (handle, OS.RB_GETBANDINFO, index, &rbBand); |
|---|
| | 696 | RECT rect; |
|---|
| | 697 | OS.SendMessage (handle, OS.RB_GETBANDBORDERS, index, &rect); |
|---|
| 704 | 698 | rbBand.cx = rbBand.cxIdeal + rect.left; |
|---|
| 705 | 699 | if ((style & DWT.FLAT) is 0) rbBand.cx += rect.right; |
|---|
| 706 | 700 | rbBand.fMask = OS.RBBIM_SIZE; |
|---|
| 707 | | OS.SendMessage (handle, OS.RB_SETBANDINFO, index, rbBand); |
|---|
| | 701 | OS.SendMessage (handle, OS.RB_SETBANDINFO, index, &rbBand); |
|---|
| 708 | 702 | } |
|---|
| 709 | 703 | } |
|---|
| 710 | 704 | |
|---|
| 711 | 705 | void resizeToMaximumWidth (int index) { |
|---|
| 712 | | REBARBANDINFO rbBand = new REBARBANDINFO(); |
|---|
| | 706 | REBARBANDINFO rbBand; |
|---|
| 713 | 707 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 714 | 708 | rbBand.fMask = OS.RBBIM_SIZE; |
|---|
| 715 | 709 | rbBand.cx = MAX_WIDTH; |
|---|
| 716 | | OS.SendMessage (handle, OS.RB_SETBANDINFO, index, rbBand); |
|---|
| | 710 | OS.SendMessage (handle, OS.RB_SETBANDINFO, index, &rbBand); |
|---|
| 717 | 711 | } |
|---|
| 718 | 712 | |
|---|
| … | … | |
| 755 | 749 | } else { |
|---|
| 756 | 750 | int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN; |
|---|
| 757 | | OS.RedrawWindow (handle, null, 0, flags); |
|---|
| | 751 | OS.RedrawWindow (handle, null, null, flags); |
|---|
| 758 | 752 | } |
|---|
| 759 | 753 | } |
|---|
| … | … | |
| 767 | 761 | void setItemColors (int foreColor, int backColor) { |
|---|
| 768 | 762 | int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0); |
|---|
| 769 | | REBARBANDINFO rbBand = new REBARBANDINFO (); |
|---|
| | 763 | REBARBANDINFO rbBand; |
|---|
| 770 | 764 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 771 | 765 | rbBand.fMask = OS.RBBIM_COLORS; |
|---|
| … | … | |
| 773 | 767 | rbBand.clrBack = backColor; |
|---|
| 774 | 768 | for (int i=0; i<count; i++) { |
|---|
| 775 | | OS.SendMessage (handle, OS.RB_SETBANDINFO, i, rbBand); |
|---|
| | 769 | OS.SendMessage (handle, OS.RB_SETBANDINFO, i, &rbBand); |
|---|
| 776 | 770 | } |
|---|
| 777 | 771 | } |
|---|
| … | … | |
| 850 | 844 | } |
|---|
| 851 | 845 | |
|---|
| 852 | | REBARBANDINFO rbBand = new REBARBANDINFO (); |
|---|
| 853 | | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| | 846 | //REBARBANDINFO rbBand; |
|---|
| | 847 | //rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 854 | 848 | for (int i=0; i<itemOrder.length; i++) { |
|---|
| 855 | 849 | int id = originalItems [itemOrder [i]].id; |
|---|
| … | … | |
| 899 | 893 | int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0); |
|---|
| 900 | 894 | if (sizes.length !is count) error (DWT.ERROR_INVALID_ARGUMENT); |
|---|
| 901 | | REBARBANDINFO rbBand = new REBARBANDINFO (); |
|---|
| | 895 | REBARBANDINFO rbBand; |
|---|
| 902 | 896 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 903 | 897 | rbBand.fMask = OS.RBBIM_ID; |
|---|
| 904 | 898 | for (int i=0; i<count; i++) { |
|---|
| 905 | | OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand); |
|---|
| | 899 | OS.SendMessage (handle, OS.RB_GETBANDINFO, i, &rbBand); |
|---|
| 906 | 900 | items [rbBand.wID].setSize (sizes [i].x, sizes [i].y); |
|---|
| 907 | 901 | } |
|---|
| … | … | |
| 925 | 919 | this.locked = locked; |
|---|
| 926 | 920 | int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0); |
|---|
| 927 | | REBARBANDINFO rbBand = new REBARBANDINFO (); |
|---|
| | 921 | REBARBANDINFO rbBand; |
|---|
| 928 | 922 | rbBand.cbSize = REBARBANDINFO.sizeof; |
|---|
| 929 | 923 | rbBand.fMask = OS.RBBIM_STYLE; |
|---|
| 930 | 924 | for (int i=0; i<count; i++) { |
|---|
| 931 | | OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand); |
|---|
| | 925 | OS.SendMessage (handle, OS.RB_GETBANDINFO, i, &rbBand); |
|---|
| 932 | 926 | if (locked) { |
|---|
| 933 | 927 | rbBand.fStyle |= OS.RBBS_NOGRIPPER; |
|---|
| … | … | |
| 935 | 929 | rbBand.fStyle &= ~OS.RBBS_NOGRIPPER; |
|---|
| 936 | 930 | } |
|---|
| 937 | | OS.SendMessage (handle, OS.RB_SETBANDINFO, i, rbBand); |
|---|
| | 931 | OS.SendMessage (handle, OS.RB_SETBANDINFO, i, &rbBand); |
|---|
| 938 | 932 | } |
|---|
| 939 | 933 | } |
|---|
| … | … | |
| 991 | 985 | } |
|---|
| 992 | 986 | |
|---|
| 993 | | TCHAR windowClass () { |
|---|
| 994 | | return ReBarClass; |
|---|
| | 987 | char[] windowClass () { |
|---|
| | 988 | return TCHARzToStr( ReBarClass ); |
|---|
| 995 | 989 | } |
|---|
| 996 | 990 | |
|---|
| 997 | 991 | int windowProc () { |
|---|
| 998 | | return ReBarProc; |
|---|
| | 992 | return cast(int) ReBarProc; |
|---|
| 999 | 993 | } |
|---|
| 1000 | 994 | |
|---|
| … | … | |
| 1019 | 1013 | */ |
|---|
| 1020 | 1014 | LRESULT result = super.WM_COMMAND (wParam, lParam); |
|---|
| 1021 | | if (result !is null) return result; |
|---|
| | 1015 | if (result !is LRESULT.NULL) return result; |
|---|
| 1022 | 1016 | return LRESULT.ZERO; |
|---|
| 1023 | 1017 | } |
|---|
| … | … | |
| 1039 | 1033 | */ |
|---|
| 1040 | 1034 | if (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ()) { |
|---|
| 1041 | | drawBackground (wParam); |
|---|
| 1042 | | return null; |
|---|
| | 1035 | drawBackground ( cast(HDC) wParam); |
|---|
| | 1036 | return LRESULT.NULL; |
|---|
| 1043 | 1037 | } |
|---|
| 1044 | 1038 | return result; |
|---|
| … | … | |
| 1065 | 1059 | */ |
|---|
| 1066 | 1060 | LRESULT result = super.WM_NOTIFY (wParam, lParam); |
|---|
| 1067 | | if (result !is null) return result; |
|---|
| | 1061 | if (result !is LRESULT.NULL) return result; |
|---|
| 1068 | 1062 | return LRESULT.ZERO; |
|---|
| 1069 | 1063 | } |
|---|
| … | … | |
| 1071 | 1065 | LRESULT WM_SETREDRAW (int wParam, int lParam) { |
|---|
| 1072 | 1066 | LRESULT result = super.WM_SETREDRAW (wParam, lParam); |
|---|
| 1073 | | if (result !is null) return result; |
|---|
| | 1067 | if (result !is LRESULT.NULL) return result; |
|---|
| 1074 | 1068 | /* |
|---|
| 1075 | 1069 | * Feature in Windows. When redraw is turned off, the rebar |
|---|
| … | … | |
| 1095 | 1089 | int code = callWindowProc (handle, OS.WM_SETREDRAW, wParam, lParam); |
|---|
| 1096 | 1090 | OS.DefWindowProc (handle, OS.WM_SETREDRAW, wParam, lParam); |
|---|
| 1097 | | if (!rect.equals (getBounds ())) { |
|---|
| | 1091 | if ( rect != getBounds ()) { |
|---|
| 1098 | 1092 | parent.redraw (rect.x, rect.y, rect.width, rect.height, true); |
|---|
| 1099 | 1093 | } |
|---|
| 1100 | | return new LRESULT (code); |
|---|
| | 1094 | return cast( LRESULT )(code); |
|---|
| 1101 | 1095 | } |
|---|
| 1102 | 1096 | |
|---|
| … | … | |
| 1105 | 1099 | int code = callWindowProc (handle, OS.WM_SIZE, wParam, lParam); |
|---|
| 1106 | 1100 | if (code is 0) return LRESULT.ZERO; |
|---|
| 1107 | | return new LRESULT (code); |
|---|
| | 1101 | return cast( LRESULT )(code); |
|---|
| 1108 | 1102 | } |
|---|
| 1109 | 1103 | //TEMPORARY CODE |
|---|
| … | … | |
| 1116 | 1110 | } |
|---|
| 1117 | 1111 | |
|---|
| 1118 | | LRESULT wmNotifyChild (NMHDR hdr, int wParam, int lParam) { |
|---|
| | 1112 | LRESULT wmNotifyChild (NMHDR* hdr, int wParam, int lParam) { |
|---|
| 1119 | 1113 | switch (hdr.code) { |
|---|
| 1120 | 1114 | case OS.RBN_BEGINDRAG: { |
|---|
| 1121 | 1115 | int pos = OS.GetMessagePos (); |
|---|
| 1122 | | POINT pt = new POINT (); |
|---|
| 1123 | | pt.x = (short) (pos & 0xFFFF); |
|---|
| 1124 | | pt.y = (short) (pos >> 16); |
|---|
| 1125 | | OS.ScreenToClient (handle, pt); |
|---|
| | 1116 | POINT pt; |
|---|
| | 1117 | pt.x = cast(short) (pos & 0xFFFF); |
|---|
| | 1118 | pt.y = cast(short) (pos >> 16); |
|---|
| | 1119 | OS.ScreenToClient (handle, &pt); |
|---|
| 1126 | 1120 | int button = display.lastButton !is 0 ? display.lastButton : 1; |
|---|
| 1127 | 1121 | if (!sendDragEvent (button, pt.x, pt.y)) return LRESULT.ONE; |
|---|
| … | … | |
| 1138 | 1132 | * recalculated. |
|---|
| 1139 | 1133 | */ |
|---|
| 1140 | | NMREBARCHILDSIZE lprbcs = new NMREBARCHILDSIZE (); |
|---|
| 1141 | | OS.MoveMemory (lprbcs, lParam, NMREBARCHILDSIZE.sizeof); |
|---|
| | 1134 | NMREBARCHILDSIZE* lprbcs = cast(NMREBARCHILDSIZE*)lParam; |
|---|
| | 1135 | //OS.MoveMemory (lprbcs, lParam, NMREBARCHILDSIZE.sizeof); |
|---|
| 1142 | 1136 | if (lprbcs.uBand !is -1) { |
|---|
| 1143 | 1137 | CoolItem item = items [lprbcs.wID]; |
|---|
| 1144 | 1138 | Control control = item.control; |
|---|
| 1145 | 1139 | if (control !is null) { |
|---|
| 1146 | | int width = lprbcs.rcChild_right - lprbcs.rcChild_left; |
|---|
| 1147 | | int height = lprbcs.rcChild_bottom - lprbcs.rcChild_top; |
|---|
| 1148 | | control.setBounds (lprbcs.rcChild_left, lprbcs.rcChild_top, width, height); |
|---|
| | 1140 | int width = lprbcs.rcChild.right - lprbcs.rcChild.left; |
|---|
| | 1141 | int height = lprbcs.rcChild.bottom - lprbcs.rcChild.top; |
|---|
| | 1142 | control.setBounds (lprbcs.rcChild.left, lprbcs.rcChild.top, width, height); |
|---|
| 1149 | 1143 | } |
|---|
| 1150 | 1144 | } |
|---|
| … | … | |
| 1165 | 1159 | } |
|---|
| 1166 | 1160 | case OS.RBN_CHEVRONPUSHED: { |
|---|
| 1167 | | NMREBARCHEVRON lpnm = new NMREBARCHEVRON (); |
|---|
| 1168 | | OS.MoveMemory (lpnm, lParam, NMREBARCHEVRON.sizeof); |
|---|
| | 1161 | NMREBARCHEVRON* lpnm = cast(NMREBARCHEVRON*)lParam; |
|---|
| | 1162 | //OS.MoveMemory (lpnm, lParam, NMREBARCHEVRON.sizeof); |
|---|
| 1169 | 1163 | CoolItem item = items [lpnm.wID]; |
|---|
| 1170 | 1164 | if (item !is null) { |
|---|
| … | … | |
| 1172 | 1166 | event.detail = DWT.ARROW; |
|---|
| 1173 | 1167 | if ((style & DWT.VERTICAL) !is 0) { |
|---|
| 1174 | | event.x = lpnm.right; |
|---|
| 1175 | | event.y = lpnm.top; |
|---|
| | 1168 | event.x = lpnm.rc.right; |
|---|
| | 1169 | event.y = lpnm.rc.top; |
|---|
| 1176 | 1170 | } else { |
|---|
| 1177 | | event.x = lpnm.left; |
|---|
| 1178 | | event.y = lpnm.bottom; |
|---|
| | 1171 | event.x = lpnm.rc.left; |
|---|
| | 1172 | event.y = lpnm.rc.bottom; |
|---|
| 1179 | 1173 | } |
|---|
| 1180 | 1174 | item.postEvent (DWT.Selection, event); |
|---|
| … | … | |
| 1191 | 1185 | if (OS.COMCTL32_MAJOR < 6) break; |
|---|
| 1192 | 1186 | if (findBackgroundControl () !is null || (style & DWT.FLAT) !is 0) { |
|---|
| 1193 | | NMCUSTOMDRAW nmcd = new NMCUSTOMDRAW (); |
|---|
| 1194 | | OS.MoveMemory (nmcd, lParam, NMCUSTOMDRAW.sizeof); |
|---|
| | 1187 | NMCUSTOMDRAW* nmcd = cast(NMCUSTOMDRAW*)lParam; |
|---|
| | 1188 | //OS.MoveMemory (nmcd, lParam, NMCUSTOMDRAW.sizeof); |
|---|
| 1195 | 1189 | switch (nmcd.dwDrawStage) { |
|---|
| 1196 | 1190 | case OS.CDDS_PREERASE: |
|---|
| 1197 | | return new LRESULT (OS.CDRF_SKIPDEFAULT | OS.CDRF_NOTIFYPOSTERASE); |
|---|
| | 1191 | return cast(LRESULT) (OS.CDRF_SKIPDEFAULT | OS.CDRF_NOTIFYPOSTERASE); |
|---|
| 1198 | 1192 | case OS.CDDS_POSTERASE: |
|---|
| 1199 | 1193 | drawBackground (nmcd.hdc); |
|---|
| … | … | |
| 1207 | 1201 | } |
|---|
| 1208 | 1202 | } |
|---|
| 1209 | | ++/ |
|---|
| r31 |
r45 |
|
| 16 | 16 | import dwt.widgets.Widget; |
|---|
| 17 | 17 | |
|---|
| 18 | | class CoolItem : Item { |
|---|
| | 18 | import dwt.events.SelectionListener; |
|---|
| | 19 | import dwt.graphics.Point; |
|---|
| | 20 | import dwt.graphics.Rectangle; |
|---|
| | 21 | import dwt.widgets.Control; |
|---|
| | 22 | import dwt.widgets.CoolBar; |
|---|
| | 23 | import dwt.widgets.Item; |
|---|
| | 24 | class CoolItem : Item { |
|---|
| 19 | 25 | public this (Widget parent, int style) { |
|---|
| 20 | 26 | super (parent, style); |
|---|
| 21 | 27 | } |
|---|
| | 28 | Rectangle getClientArea(); |
|---|
| | 29 | override void checkSubclass(); |
|---|
| | 30 | Point computeSize(int, int); |
|---|
| | 31 | override void destroyWidget(); |
|---|
| | 32 | override void releaseHandle(); |
|---|
| | 33 | void setControl(Control); |
|---|
| | 34 | bool getWrap(); |
|---|
| | 35 | void setWrap(bool); |
|---|
| | 36 | CoolBar getParent(); |
|---|
| | 37 | Point getSize(); |
|---|
| | 38 | void setSize(int, int); |
|---|
| | 39 | void setSize(Point); |
|---|
| | 40 | Rectangle getBounds(); |
|---|
| | 41 | Point getMinimumSize(); |
|---|
| | 42 | Point getPreferredSize(); |
|---|
| | 43 | void setMinimumSize(int, int); |
|---|
| | 44 | void setMinimumSize(Point); |
|---|
| | 45 | void setPreferredSize(int, int); |
|---|
| | 46 | void setPreferredSize(Point); |
|---|
| | 47 | Control getControl(); |
|---|
| | 48 | void addSelectionListener(SelectionListener); |
|---|
| | 49 | void removeSelectionListener(SelectionListener); |
|---|
| | 50 | CoolBar parent; |
|---|
| | 51 | Control control; |
|---|
| | 52 | int id; |
|---|
| | 53 | bool ideal; |
|---|
| | 54 | bool minimum; |
|---|
| 22 | 55 | } |
|---|
| 23 | 56 | /++ |
|---|
| r31 |
r45 |
|
| 16 | 16 | import dwt.widgets.Widget; |
|---|
| 17 | 17 | |
|---|
| 18 | | class ExpandItem : Item { |
|---|
| | 18 | import dwt.graphics.GC; |
|---|
| | 19 | import dwt.graphics.Image; |
|---|
| | 20 | import dwt.internal.win32.OS; |
|---|
| | 21 | import dwt.widgets.Control; |
|---|
| | 22 | import dwt.widgets.ExpandBar; |
|---|
| | 23 | import dwt.widgets.Item; |
|---|
| | 24 | class ExpandItem : Item { |
|---|
| 19 | 25 | public this (Widget parent, int style) { |
|---|
| 20 | 26 | super (parent, style); |
|---|
| 21 | 27 | } |
|---|
| 22 | | } |
|---|
| | 28 | void redraw(bool); |
|---|
| | 29 | override void releaseWidget(); |
|---|
| | 30 | override void destroyWidget(); |
|---|
| | 31 | override void releaseHandle(); |
|---|
| | 32 | bool getExpanded(); |
|---|
| | 33 | void setControl(Control); |
|---|
| | 34 | void drawItem(GC, int, RECT, bool); |
|---|
| | 35 | bool isHover(int, int); |
|---|
| | 36 | void setExpanded(bool); |
|---|
| | 37 | ExpandBar getParent(); |
|---|
| | 38 | void setBounds(int, int, int, int, bool, bool); |
|---|
| | 39 | int getHeight(); |
|---|
| | 40 | override void setText(char[]); |
|---|
| | 41 | Control getControl(); |
|---|
| | 42 | void setHeight(int); |
|---|
| | 43 | override void setImage(Image); |
|---|
| | 44 | int getPreferredWidth(int, int); |
|---|
| | 45 | int getHeaderHeight(); |
|---|
| | 46 | ExpandBar parent; |
|---|
| | 47 | Control control; |
|---|
| | 48 | bool expanded; |
|---|
| | 49 | bool hover; |
|---|
| | 50 | int x; |
|---|
| | 51 | int y; |
|---|
| | 52 | int width; |
|---|
| | 53 | int height; |
|---|
| | 54 | int imageHeight; |
|---|
| | 55 | int imageWidth; |
|---|
| | 56 | static int TEXT_INSET; |
|---|
| | 57 | static int BORDER; |
|---|
| | 58 | static int CHEVRON_SIZE; |
|---|
| | 59 | } |
|---|
| | 60 | |
|---|
| 23 | 61 | /++ |
|---|
| 24 | 62 | import dwt.DWT; |
|---|