Changeset 36:ceb20ad6c0f8
- Timestamp:
- 01/28/08 18:52:45 (1 year ago)
- Files:
-
- dwt/widgets/Control.d (modified) (2 diffs)
- dwt/widgets/Display.d (modified) (7 diffs)
- dwt/widgets/ScrollBar.d (modified) (1 diff)
- dwt/widgets/Scrollable.d (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/widgets/Control.d
r35 r36 13 13 module dwt.widgets.Control; 14 14 15 /+16 import dwt.widgets.Widget;17 import dwt.widgets.Composite;18 import dwt.widgets.Event;19 import dwt.widgets.Shell;20 import dwt.graphics.Drawable;21 import dwt.graphics.Rectangle;22 import dwt.graphics.Point;23 import dwt.graphics.GCData;24 import dwt.internal.win32.OS;25 26 class Control : Widget, Drawable {27 public HANDLE handle;28 this();29 this( Widget, int );30 public HDC internal_new_GC (GCData data) ;31 public void internal_dispose_GC (HDC hDC, GCData data) ;32 public Point computeSize (int wHint, int hHint) ;33 public Point computeSize (int wHint, int hHint, bool changed) ;34 public Composite getParent () ;35 public Object getLayoutData () ;36 public int getBorderWidth () ;37 public void setLayoutData (Object layoutData) ;38 public void setBounds (int x, int y, int width, int height) ;39 void setBounds (int x, int y, int width, int height, int flags) ;40 void setBounds (int x, int y, int width, int height, int flags, bool defer) ;41 public void setBounds (Rectangle rect) ;42 Shell getShell();43 bool checkHandle (HWND hwnd) ;44 bool translateAccelerator (MSG* msg) ;45 bool translateMnemonic (Event event, Control control) ;46 bool translateMnemonic (MSG* msg) ;47 bool translateTraversal (MSG* msg) ;48 public void update () ;49 void update (bool all) ;50 void updateImages () ;51 int windowProc (HWND hwnd, int msg, int wParam, int lParam) ;52 53 }54 +/55 15 import dwt.DWT; 56 16 import dwt.DWTException; … … 115 75 116 76 alias Widget.dragDetect dragDetect; 77 alias Widget.callWindowProc callWindowProc; 117 78 118 79 /** dwt/widgets/Display.d
r35 r36 186 186 //int windowProc_; 187 187 int threadId; 188 TCHAR* windowClass , windowShadowClass;188 TCHAR* windowClass_, windowShadowClass; 189 189 static int WindowClassCount; 190 190 static const char[] WindowName = "SWT_Window"; //$NON-NLS-1$ … … 2006 2006 auto hInstance = OS.GetModuleHandle (null); 2007 2007 embeddedHwnd = OS.CreateWindowEx (0, 2008 windowClass ,2008 windowClass_, 2009 2009 null, 2010 2010 OS.WS_OVERLAPPED, … … 2503 2503 2504 2504 /* Use the character encoding for the default locale */ 2505 windowClass = StrToTCHARz ( WindowName ~ to!(char[])(WindowClassCount));2505 windowClass_ = StrToTCHARz ( WindowName ~ to!(char[])(WindowClassCount)); 2506 2506 windowShadowClass = StrToTCHARz ( WindowShadowName ~ to!(char[])(WindowClassCount)); 2507 2507 WindowClassCount++; … … 2515 2515 lpWndClass.style = OS.CS_BYTEALIGNWINDOW | OS.CS_DBLCLKS; 2516 2516 lpWndClass.hCursor = OS.LoadCursor (null, cast(wchar*)OS.IDC_ARROW); 2517 int len = strlenz( windowClass );2517 int len = strlenz( windowClass_ ); 2518 2518 int byteCount = len * TCHAR.sizeof; 2519 2519 lpWndClass.lpszClassName = cast(wchar*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 2520 lpWndClass.lpszClassName[ 0 .. len ] = windowClass [ 0 .. len ];2520 lpWndClass.lpszClassName[ 0 .. len ] = windowClass_[ 0 .. len ]; 2521 2521 OS.RegisterClass (&lpWndClass); 2522 2522 OS.HeapFree (hHeap, 0, lpWndClass.lpszClassName); … … 2533 2533 /* Create the message only HWND */ 2534 2534 hwndMessage = OS.CreateWindowEx (0, 2535 windowClass ,2535 windowClass_, 2536 2536 null, 2537 2537 OS.WS_OVERLAPPED, … … 3506 3506 auto hHeap = OS.GetProcessHeap (); 3507 3507 auto hInstance = OS.GetModuleHandle (null); 3508 OS.UnregisterClass (windowClass , hInstance);3508 OS.UnregisterClass (windowClass_, hInstance); 3509 3509 3510 3510 /* Unregister the DWT drop shadow window class */ 3511 3511 OS.UnregisterClass (windowShadowClass, hInstance); 3512 windowClass = windowShadowClass = null;3512 windowClass_ = windowShadowClass = null; 3513 3513 //windowCallback.dispose (); 3514 3514 //windowCallback = null; … … 4531 4531 } 4532 4532 4533 } 4533 char[] windowClass(){ 4534 return TCHARzToStr( windowClass_ ); 4535 } 4536 4537 } dwt/widgets/ScrollBar.d
r31 r36 14 14 class ScrollBar : Widget { 15 15 this( Widget, int ); 16 public void setMaximum (int value) ; 17 public void setThumb (int value) ; 18 public int getThumb () ; 19 public bool getEnabled () ; 20 public int getSelection () ; 21 public int getIncrement () ; 22 public int getPageIncrement () ; 23 LRESULT wmScrollChild (int wParam, int lParam) ; 16 24 } 17 25 /++ dwt/widgets/Scrollable.d
r31 r36 11 11 module dwt.widgets.Scrollable; 12 12 13 import dwt.widgets.Widget; 14 import dwt.widgets.Event; 13 15 import dwt.widgets.Control; 16 import dwt.widgets.ScrollBar; 14 17 import dwt.widgets.Composite; 15 import dwt.graphics.Rectangle;16 17 class Scrollable : Control {18 this();19 this( Composite, int );20 public Rectangle computeTrim (int x, int y, int width, int height) ;21 public Rectangle getClientArea () ;22 }23 24 /++25 18 import dwt.DWT; 26 19 import dwt.DWTException; 27 20 import dwt.graphics.Rectangle; 28 import dwt.internal.win32.LRESULT;29 21 import dwt.internal.win32.OS; 30 import dwt.internal.win32.RECT; 31 import dwt.internal.win32.SCROLLINFO; 32 import dwt.internal.win32.TCHAR; 22 23 import dwt.dwthelper.utils; 33 24 34 25 /** … … 47 38 */ 48 39 49 public abstract class Scrollable extendsControl {40 public abstract class Scrollable : Control { 50 41 ScrollBar horizontalBar, verticalBar; 51 42 … … 53 44 * Prevents uninitialized instances from being created outside the package. 54 45 */ 55 Scrollable() {46 this () { 56 47 } 57 48 … … 85 76 * @see Widget#getStyle 86 77 */ 87 public Scrollable(Composite parent, int style) {78 public this (Composite parent, int style) { 88 79 super (parent, style); 89 80 } 90 81 91 int callWindowProc (inthwnd, int msg, int wParam, int lParam) {92 if (handle is 0) return 0;93 return OS.DefWindowProc (hwnd, msg, wParam, lParam);82 override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 83 if (handle is null) return LRESULT.ZERO; 84 return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); 94 85 } 95 86 … … 123 114 public Rectangle computeTrim (int x, int y, int width, int height) { 124 115 checkWidget (); 125 int scrolledHandle= scrolledHandle ();126 RECT rect = new RECT ();127 OS.SetRect ( rect, x, y, x + width, y + height);128 int bits1 = OS.GetWindowLong (scrolledHandle , OS.GWL_STYLE);129 int bits2 = OS.GetWindowLong (scrolledHandle , OS.GWL_EXSTYLE);130 OS.AdjustWindowRectEx ( rect, bits1, false, bits2);116 auto scrolledHandle_ = scrolledHandle (); 117 RECT rect; 118 OS.SetRect (&rect, x, y, x + width, y + height); 119 int bits1 = OS.GetWindowLong (scrolledHandle_, OS.GWL_STYLE); 120 int bits2 = OS.GetWindowLong (scrolledHandle_, OS.GWL_EXSTYLE); 121 OS.AdjustWindowRectEx (&rect, bits1, false, bits2); 131 122 if (horizontalBar !is null) rect.bottom += OS.GetSystemMetrics (OS.SM_CYHSCROLL); 132 123 if (verticalBar !is null) rect.right += OS.GetSystemMetrics (OS.SM_CXVSCROLL); … … 167 158 checkWidget (); 168 159 forceResize (); 169 RECT rect = new RECT ();170 int scrolledHandle= scrolledHandle ();171 OS.GetClientRect (scrolledHandle ,rect);160 RECT rect; 161 auto scrolledHandle_ = scrolledHandle (); 162 OS.GetClientRect (scrolledHandle_, &rect); 172 163 int x = rect.left, y = rect.top; 173 164 int width = rect.right - rect.left; 174 165 int height = rect.bottom - rect.top; 175 if (scrolledHandle !is handle) {176 OS.GetClientRect (handle, rect);177 OS.MapWindowPoints(handle, scrolledHandle ,rect, 2);166 if (scrolledHandle_ !is handle) { 167 OS.GetClientRect (handle, &rect); 168 OS.MapWindowPoints(handle, scrolledHandle_, cast(POINT*)&rect, 2); 178 169 x = -rect.left; 179 170 y = -rect.top; … … 226 217 } 227 218 228 intscrolledHandle () {219 HANDLE scrolledHandle () { 229 220 return handle; 230 221 } … … 251 242 } 252 243 253 TCHARwindowClass () {254 return display.windowClass ;255 } 256 257 int windowProc () {244 override char[] windowClass () { 245 return display.windowClass(); 246 } 247 248 override int windowProc () { 258 249 return display.windowProc; 259 250 } 260 251 261 LRESULT WM_HSCROLL (int wParam, int lParam) {252 override LRESULT WM_HSCROLL (int wParam, int lParam) { 262 253 LRESULT result = super.WM_HSCROLL (wParam, lParam); 263 if (result !is null) return result;254 if (result !is 0) return result; 264 255 265 256 /* … … 270 261 * both. 271 262 */ 272 if (horizontalBar !is null && (lParam is 0 || lParam is handle)) {263 if (horizontalBar !is null && (lParam is 0 || lParam is cast(int)handle)) { 273 264 return wmScroll (horizontalBar, (state & CANVAS) !is 0, handle, OS.WM_HSCROLL, wParam, lParam); 274 265 } … … 276 267 } 277 268 278 LRESULT WM_MOUSEWHEEL (int wParam, int lParam) {269 override LRESULT WM_MOUSEWHEEL (int wParam, int lParam) { 279 270 LRESULT result = super.WM_MOUSEWHEEL (wParam, lParam); 280 if (result !is null) return result;271 if (result !is 0) return result; 281 272 282 273 /* … … 289 280 int msg = (vertical) ? OS.WM_VSCROLL : (horizontal) ? OS.WM_HSCROLL : 0; 290 281 if (msg is 0) return result; 291 int [] value = new int [1];292 OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, value, 0);293 int delta = (short) (wParam >> 16);282 int value; 283 OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, &value, 0); 284 int delta = cast(short) (wParam >> 16); 294 285 int code = 0, count = 0; 295 if (value [0]is OS.WHEEL_PAGESCROLL) {286 if (value is OS.WHEEL_PAGESCROLL) { 296 287 code = delta < 0 ? OS.SB_PAGEDOWN : OS.SB_PAGEUP; 297 288 count = Math.abs (delta / OS.WHEEL_DELTA); … … 301 292 if (delta < OS.WHEEL_DELTA) return result; 302 293 if (msg is OS.WM_VSCROLL) { 303 count = value [0]* delta / OS.WHEEL_DELTA;294 count = value * delta / OS.WHEEL_DELTA; 304 295 } else { 305 296 count = delta / OS.WHEEL_DELTA; … … 325 316 int vPosition = verticalBar is null ? 0 : verticalBar.getSelection (); 326 317 int hPosition = horizontalBar is null ? 0 : horizontalBar.getSelection (); 327 intcode = callWindowProc (handle, OS.WM_MOUSEWHEEL, wParam, lParam);318 LRESULT code = callWindowProc (handle, OS.WM_MOUSEWHEEL, wParam, lParam); 328 319 if (verticalBar !is null) { 329 320 int position = verticalBar.getSelection (); … … 342 333 } 343 334 } 344 return new LRESULT (code);345 } 346 347 LRESULT WM_SIZE (int wParam, int lParam) {348 intcode = callWindowProc (handle, OS.WM_SIZE, wParam, lParam);335 return code; 336 } 337 338 override LRESULT WM_SIZE (int wParam, int lParam) { 339 LRESULT code = callWindowProc (handle, OS.WM_SIZE, wParam, lParam); 349 340 super.WM_SIZE (wParam, lParam); 350 341 // widget may be disposed at this point 351 342 if (code is 0) return LRESULT.ZERO; 352 return new LRESULT (code);353 } 354 355 LRESULT WM_VSCROLL (int wParam, int lParam) {343 return code; 344 } 345 346 override LRESULT WM_VSCROLL (int wParam, int lParam) { 356 347 LRESULT result = super.WM_VSCROLL (wParam, lParam); 357 if (result !is null) return result;348 if (result !is 0) return result; 358 349 /* 359 350 * Bug on WinCE. lParam should be NULL when the message is not sent … … 363 354 * both. 364 355 */ 365 if (verticalBar !is null && (lParam is 0 || lParam is handle)) {356 if (verticalBar !is null && (lParam is 0 || lParam is cast(int)handle)) { 366 357 return wmScroll (verticalBar, (state & CANVAS) !is 0, handle, OS.WM_VSCROLL, wParam, lParam); 367 358 } … … 369 360 } 370 361 371 LRESULT wmScroll (ScrollBar bar, bool update, inthwnd, int msg, int wParam, int lParam) {372 LRESULT result = null;362 LRESULT wmScroll (ScrollBar bar, bool update, HWND hwnd, int msg, int wParam, int lParam) { 363 LRESULT result = LRESULT.NULL; 373 364 if (update) { 374 365 int type = msg is OS.WM_HSCROLL ? OS.SB_HORZ : OS.SB_VERT; 375 SCROLLINFO info = new SCROLLINFO ();366 SCROLLINFO info; 376 367 info.cbSize = SCROLLINFO.sizeof; 377 368 info.fMask = OS.SIF_TRACKPOS | OS.SIF_POS | OS.SIF_RANGE; 378 OS.GetScrollInfo (hwnd, type, info);369 OS.GetScrollInfo (hwnd, type, &info); 379 370 info.fMask = OS.SIF_POS; 380 371 int code = wParam & 0xFFFF; 381 372 switch (code) { 382 case OS.SB_ENDSCROLL: return null;373 case OS.SB_ENDSCROLL: return LRESULT.NULL; 383 374 case OS.SB_THUMBPOSITION: 384 375 case OS.SB_THUMBTRACK: … … 412 403 break; 413 404 } 414 OS.SetScrollInfo (hwnd, type, info, true);405 OS.SetScrollInfo (hwnd, type, &info, true); 415 406 } else { 416 intcode = callWindowProc (hwnd, msg, wParam, lParam);417 result = code is 0 ? LRESULT.ZERO : new LRESULT (code);407 LRESULT code = callWindowProc (hwnd, msg, wParam, lParam); 408 result = code is 0 ? LRESULT.ZERO : code; 418 409 } 419 410 bar.wmScrollChild (wParam, lParam); … … 422 413 423 414 } 424 ++/ 415
