Changeset 62:7757dae4f29f
- Timestamp:
- 02/04/08 08:32:57 (1 year ago)
- Files:
-
- dwt/widgets/Sash.d (modified) (20 diffs)
- dwt/widgets/Scale.d (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/widgets/Sash.d
r54 r62 11 11 module dwt.widgets.Sash; 12 12 13 import dwt.widgets.Control; 14 class Sash : Control { 15 } 16 /++ 13 14 17 15 import dwt.DWT; 18 16 import dwt.DWTException; … … 20 18 import dwt.events.SelectionListener; 21 19 import dwt.graphics.Point; 22 import dwt.internal.win32.LRESULT;23 20 import dwt.internal.win32.OS; 24 import dwt.internal.win32.POINT; 25 import dwt.internal.win32.RECT; 26 import dwt.internal.win32.TCHAR; 21 22 import dwt.widgets.Control; 23 import dwt.widgets.Composite; 24 import dwt.widgets.TypedListener; 25 import dwt.widgets.Event; 26 27 import dwt.dwthelper.utils; 27 28 28 29 /** … … 43 44 * </p> 44 45 */ 45 public class Sash extendsControl {46 public class Sash : Control { 46 47 47 48 alias Control.computeSize computeSize; … … 50 51 bool dragging; 51 52 int startX, startY, lastX, lastY; 52 finalstatic int INCREMENT = 1;53 finalstatic int PAGE_INCREMENT = 9;53 const static int INCREMENT = 1; 54 const static int PAGE_INCREMENT = 9; 54 55 55 56 /** … … 82 83 * @see Widget#getStyle 83 84 */ 84 public Sash(Composite parent, int style) {85 public this (Composite parent, int style) { 85 86 super (parent, checkStyle (style)); 86 87 } … … 119 120 } 120 121 121 override int callWindowProc (inthwnd, int msg, int wParam, int lParam) {122 if (handle is 0) return 0;123 return OS.DefWindowProc (hwnd, msg, wParam, lParam);122 override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 123 if (handle is null) return LRESULT.ZERO; 124 return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); 124 125 } 125 126 … … 149 150 void drawBand (int x, int y, int width, int height) { 150 151 if ((style & DWT.SMOOTH) !is 0) return; 151 inthwndTrack = parent.handle;152 byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};153 int stippleBitmap = OS.CreateBitmap (8, 8, 1, 1, bits);154 intstippleBrush = OS.CreatePatternBrush (stippleBitmap);155 int hDC = OS.GetDCEx (hwndTrack, 0, OS.DCX_CACHE);156 intoldBrush = OS.SelectObject (hDC, stippleBrush);152 HWND hwndTrack = parent.handle; 153 byte [] bits = [-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0]; 154 auto stippleBitmap = OS.CreateBitmap (8, 8, 1, 1, bits.ptr); 155 auto stippleBrush = OS.CreatePatternBrush (stippleBitmap); 156 auto hDC = OS.GetDCEx (hwndTrack, null, OS.DCX_CACHE); 157 auto oldBrush = OS.SelectObject (hDC, stippleBrush); 157 158 OS.PatBlt (hDC, x, y, width, height, OS.PATINVERT); 158 159 OS.SelectObject (hDC, oldBrush); … … 187 188 } 188 189 189 override TCHARwindowClass () {190 return display.windowClass ;190 override char[] windowClass () { 191 return display.windowClass(); 191 192 } 192 193 193 194 override int windowProc () { 194 return display.windowProc ;195 return display.windowProc(); 195 196 } 196 197 197 198 override LRESULT WM_ERASEBKGND (int wParam, int lParam) { 198 199 super.WM_ERASEBKGND (wParam, lParam); 199 drawBackground ( wParam);200 drawBackground (cast(HANDLE) wParam); 200 201 return LRESULT.ONE; 201 202 } … … 203 204 override LRESULT WM_KEYDOWN (int wParam, int lParam) { 204 205 LRESULT result = super.WM_KEYDOWN (wParam, lParam); 205 if (result !is null) return result;206 if (result !is LRESULT.NULL) return result; 206 207 switch (wParam) { 207 208 case OS.VK_LEFT: … … 213 214 if (OS.GetKeyState (OS.VK_LBUTTON) < 0) return result; 214 215 int step = OS.GetKeyState (OS.VK_CONTROL) < 0 ? INCREMENT : PAGE_INCREMENT; 215 POINT pt = new POINT ();216 POINT pt; 216 217 if ((style & DWT.VERTICAL) !is 0) { 217 218 if (wParam is OS.VK_UP || wParam is OS.VK_DOWN) break; … … 221 222 pt.y = wParam is OS.VK_UP ? -step : step; 222 223 } 223 inthwndTrack = parent.handle;224 OS.MapWindowPoints (handle, hwndTrack, pt, 1);225 RECT rect = new RECT (), clientRect = new RECT ();226 OS.GetWindowRect (handle, rect);224 auto hwndTrack = parent.handle; 225 OS.MapWindowPoints (handle, hwndTrack, &pt, 1); 226 RECT rect, clientRect; 227 OS.GetWindowRect (handle, &rect); 227 228 int width = rect.right - rect.left; 228 229 int height = rect.bottom - rect.top; 229 OS.GetClientRect (hwndTrack, clientRect);230 OS.GetClientRect (hwndTrack, &clientRect); 230 231 int clientWidth = clientRect.right - clientRect.left; 231 232 int clientHeight = clientRect.bottom - clientRect.top; … … 239 240 240 241 /* Update the pointer position */ 241 POINT cursorPt = new POINT ();242 POINT cursorPt; 242 243 cursorPt.x = pt.x; cursorPt.y = pt.y; 243 OS.ClientToScreen (hwndTrack, cursorPt);244 OS.ClientToScreen (hwndTrack, &cursorPt); 244 245 if ((style & DWT.VERTICAL) !is 0) { 245 246 cursorPt.y += height / 2; … … 268 269 269 270 override LRESULT WM_GETDLGCODE (int wParam, int lParam) { 270 return new LRESULT(OS.DLGC_STATIC);271 return cast(LRESULT)(OS.DLGC_STATIC); 271 272 } 272 273 … … 276 277 277 278 /* Compute the banding rectangle */ 278 inthwndTrack = parent.handle;279 POINT pt = new POINT ();280 pt.x = (short) (lParam & 0xFFFF);281 pt.y = (short) (lParam >> 16);282 RECT rect = new RECT ();283 OS.GetWindowRect (handle, rect);284 OS.MapWindowPoints (handle, 0,pt, 1);279 auto hwndTrack = parent.handle; 280 POINT pt; 281 pt.x = cast(short) (lParam & 0xFFFF); 282 pt.y = cast(short) (lParam >> 16); 283 RECT rect; 284 OS.GetWindowRect (handle, &rect); 285 OS.MapWindowPoints (handle, null, &pt, 1); 285 286 startX = pt.x - rect.left; 286 287 startY = pt.y - rect.top; 287 OS.MapWindowPoints ( 0, hwndTrack,rect, 2);288 OS.MapWindowPoints (null, hwndTrack, cast(POINT*) &rect, 2); 288 289 lastX = rect.left; 289 290 lastY = rect.top; … … 314 315 } else { 315 316 int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN; 316 OS.RedrawWindow (hwndTrack, null, 0, flags);317 OS.RedrawWindow (hwndTrack, null, null, flags); 317 318 } 318 319 drawBand (event.x, event.y, width, height); … … 332 333 if (!dragging) return result; 333 334 dragging = false; 334 RECT rect = new RECT ();335 OS.GetWindowRect (handle, rect);335 RECT rect; 336 OS.GetWindowRect (handle, &rect); 336 337 int width = rect.right - rect.left; 337 338 int height = rect.bottom - rect.top; … … 357 358 override LRESULT WM_MOUSEMOVE (int wParam, int lParam) { 358 359 LRESULT result = super.WM_MOUSEMOVE (wParam, lParam); 359 if (result !is null) return result;360 if (result !is LRESULT.NULL) return result; 360 361 if (!dragging || (wParam & OS.MK_LBUTTON) is 0) return result; 361 362 362 363 /* Compute the banding rectangle */ 363 POINT pt = new POINT ();364 pt.x = (short) (lParam & 0xFFFF);365 pt.y = (short) (lParam >> 16);366 inthwndTrack = parent.handle;367 OS.MapWindowPoints (handle, hwndTrack, pt, 1);368 RECT rect = new RECT (), clientRect = new RECT ();369 OS.GetWindowRect (handle, rect);364 POINT pt; 365 pt.x = cast(short) (lParam & 0xFFFF); 366 pt.y = cast(short) (lParam >> 16); 367 auto hwndTrack = parent.handle; 368 OS.MapWindowPoints (handle, hwndTrack, &pt, 1); 369 RECT rect, clientRect; 370 OS.GetWindowRect (handle, &rect); 370 371 int width = rect.right - rect.left; 371 372 int height = rect.bottom - rect.top; 372 OS.GetClientRect (hwndTrack, clientRect);373 OS.GetClientRect (hwndTrack, &clientRect); 373 374 int newX = lastX, newY = lastY; 374 375 if ((style & DWT.VERTICAL) !is 0) { … … 401 402 } else { 402 403 int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN; 403 OS.RedrawWindow (hwndTrack, null, 0, flags);404 OS.RedrawWindow (hwndTrack, null, null, flags); 404 405 } 405 406 drawBand (lastX, lastY, width, height); … … 413 414 override LRESULT WM_SETCURSOR (int wParam, int lParam) { 414 415 LRESULT result = super.WM_SETCURSOR (wParam, lParam); 415 if (result !is null) return result;416 if (result !is LRESULT.NULL) return result; 416 417 int hitTest = lParam & 0xFFFF; 417 418 if (hitTest is OS.HTCLIENT) { 418 int hCursor = 0;419 HCURSOR hCursor; 419 420 if ((style & DWT.HORIZONTAL) !is 0) { 420 hCursor = OS.LoadCursor ( 0,OS.IDC_SIZENS);421 hCursor = OS.LoadCursor (null, cast(TCHAR*)OS.IDC_SIZENS); 421 422 } else { 422 hCursor = OS.LoadCursor ( 0,OS.IDC_SIZEWE);423 hCursor = OS.LoadCursor (null, cast(TCHAR*)OS.IDC_SIZEWE); 423 424 } 424 425 OS.SetCursor (hCursor); … … 429 430 430 431 } 431 ++/ 432 dwt/widgets/Scale.d
r54 r62 11 11 module dwt.widgets.Scale; 12 12 13 import dwt.widgets.Control;14 import dwt.widgets.Composite;15 16 class Scale : Control {17 this (Composite parent, int style) ;18 }19 /++20 13 import dwt.DWT; 21 14 import dwt.DWTException; … … 27 20 import dwt.internal.win32.TCHAR; 28 21 import dwt.internal.win32.WNDCLASS; 22 23 import dwt.widgets.Control; 24 import dwt.widgets.Composite; 25 26 import dwt.dwthelper.utils; 29 27 30 28 /** … … 47 45 */ 48 46 49 public class Scale extendsControl {47 public class Scale : Control { 50 48 51 49 alias Control.computeSize computeSize; … … 54 52 55 53 bool ignoreResize; 56 static final intTrackBarProc;57 static final TCHAR TrackBarClass = new TCHAR (0, OS.TRACKBAR_CLASS, true);58 static {59 WNDCLASS lpWndClass = new WNDCLASS ();60 OS.GetClassInfo ( 0, TrackBarClass,lpWndClass);54 static const WNDPROC TrackBarProc; 55 static const TCHAR[] TrackBarClass = OS.TRACKBAR_CLASS; 56 static this() { 57 WNDCLASS lpWndClass; 58 OS.GetClassInfo (null, TrackBarClass.ptr, &lpWndClass); 61 59 TrackBarProc = lpWndClass.lpfnWndProc; 62 60 /* … … 77 75 * this class name, and fail unexpectedly. 78 76 */ 79 inthInstance = OS.GetModuleHandle (null);80 inthHeap = OS.GetProcessHeap ();77 auto hInstance = OS.GetModuleHandle (null); 78 auto hHeap = OS.GetProcessHeap (); 81 79 lpWndClass.hInstance = hInstance; 82 80 lpWndClass.style &= ~OS.CS_GLOBALCLASS; 83 81 lpWndClass.style |= OS.CS_DBLCLKS; 84 82 int byteCount = TrackBarClass.length () * TCHAR.sizeof; 85 int lpszClassName =OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);83 auto lpszClassName = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 86 84 OS.MoveMemory (lpszClassName, TrackBarClass, byteCount); 87 85 lpWndClass.lpszClassName = lpszClassName; … … 119 117 * @see Widget#getStyle 120 118 */ 121 public Scale(Composite parent, int style) {119 public this (Composite parent, int style) { 122 120 super (parent, checkStyle (style)); 123 121 } … … 154 152 } 155 153 156 override int callWindowProc (inthwnd, int msg, int wParam, int lParam) {157 if (handle is 0) return 0;158 return OS.CallWindowProc (TrackBarProc, hwnd, msg, wParam, lParam);154 override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 155 if (handle is null) return LRESULT.ZERO; 156 return cast(LRESULT)OS.CallWindowProc (TrackBarProc, hwnd, msg, wParam, lParam); 159 157 } 160 158 … … 167 165 int border = getBorderWidth (); 168 166 int width = border * 2, height = border * 2; 169 RECT rect = new RECT ();170 OS.SendMessage (handle, OS.TBM_GETTHUMBRECT, 0, rect);167 RECT rect; 168 OS.SendMessage (handle, OS.TBM_GETTHUMBRECT, 0, &rect); 171 169 if ((style & DWT.HORIZONTAL) !is 0) { 172 170 width += OS.GetSystemMetrics (OS.SM_CXHSCROLL) * 10; … … 486 484 case OS.TB_ENDTRACK: 487 485 case OS.TB_THUMBPOSITION: 488 return null;486 return LRESULT.NULL; 489 487 } 490 488 … … 511 509 sendEvent (DWT.Selection, event); 512 510 // widget could be disposed at this point 513 return null;514 } 515 516 } 517 ++/ 511 return LRESULT.NULL; 512 } 513 514 } 515
