Mercurial > projects > dwt-win
diff dwt/widgets/Text.d @ 213:36f5cb12e1a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 17 May 2008 17:34:28 +0200 |
parents | ab60f3309436 |
children | a8fed3e56433 |
line wrap: on
line diff
--- a/dwt/widgets/Text.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/widgets/Text.d Sat May 17 17:34:28 2008 +0200 @@ -36,6 +36,13 @@ /** * Instances of this class are selectable user interface * objects that allow the user to enter and modify text. + * Text controls can be either single or multi-line. + * When a text control is created with a border, the + * operating system includes a platform specific inset + * around the contents of the control. When created + * without a border, an effort is made to remove the + * inset such that the preferred size of the control + * is the same size as the contents. * <p> * <dl> * <dt><b>Styles:</b></dt> @@ -166,7 +173,60 @@ override int callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { if (handle is null) return 0; - return OS.CallWindowProc (EditProc, hwnd, msg, wParam, lParam); + bool redraw = false; + switch (msg) { + case OS.WM_ERASEBKGND: { + if (findImageControl () !is null) return 0; + break; + } + case OS.WM_HSCROLL: + case OS.WM_VSCROLL: { + redraw = findImageControl () !is null && drawCount is 0 && OS.IsWindowVisible (handle); + if (redraw) OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0); + break; + } + case OS.WM_PAINT: { + if (findImageControl () !is null) { + PAINTSTRUCT ps; + auto paintDC = OS.BeginPaint (handle, &ps); + int width = ps.rcPaint.right - ps.rcPaint.left; + int height = ps.rcPaint.bottom - ps.rcPaint.top; + if (width !is 0 && height !is 0) { + auto hDC = OS.CreateCompatibleDC (paintDC); + POINT lpPoint1, lpPoint2; + OS.SetWindowOrgEx (hDC, ps.rcPaint.left, ps.rcPaint.top, &lpPoint1); + OS.SetBrushOrgEx (hDC, ps.rcPaint.left, ps.rcPaint.top, &lpPoint2); + auto hBitmap = OS.CreateCompatibleBitmap (paintDC, width, height); + auto hOldBitmap = OS.SelectObject (hDC, hBitmap); + RECT rect; + OS.SetRect (&rect, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); + drawBackground (hDC, &rect); + OS.CallWindowProc ( EditProc, hwnd, OS.WM_PAINT, cast(int)hDC, lParam); + OS.SetWindowOrgEx (hDC, lpPoint1.x, lpPoint1.y, null); + OS.SetBrushOrgEx (hDC, lpPoint2.x, lpPoint2.y, null); + OS.BitBlt (paintDC, ps.rcPaint.left, ps.rcPaint.top, width, height, hDC, 0, 0, OS.SRCCOPY); + OS.SelectObject (hDC, hOldBitmap); + OS.DeleteObject (hBitmap); + OS.DeleteObject (hDC); + } + OS.EndPaint (handle, &ps); + return 0; + } + break; + } + } + int /*long*/ code = OS.CallWindowProc (EditProc, hwnd, msg, wParam, lParam); + switch (msg) { + case OS.WM_HSCROLL: + case OS.WM_VSCROLL: { + if (redraw) { + OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0); + OS.InvalidateRect (handle, null, true); + } + break; + } + } + return code; } override void createHandle () { @@ -420,9 +480,9 @@ * the single-line text widget in an editable combo * box. */ - int margins = OS.SendMessage(handle, OS.EM_GETMARGINS, 0, 0); - rect.x -= margins & 0xFFFF; - rect.width += (margins & 0xFFFF) + ((margins >> 16) & 0xFFFF); + int /*long*/ margins = OS.SendMessage(handle, OS.EM_GETMARGINS, 0, 0); + rect.x -= OS.LOWORD (margins); + rect.width += OS.LOWORD (margins) + OS.HIWORD (margins); if ((style & DWT.H_SCROLL) !is 0) rect.width++; if ((style & DWT.BORDER) !is 0) { rect.x -= 1; @@ -485,8 +545,8 @@ int start, end; OS.SendMessage (handle, OS.EM_GETSEL, &start, &end); if (start !is end ) { - int lParam = (x & 0xFFFF) | ((y << 16) & 0xFFFF0000); - int position = OS.SendMessage (handle, OS.EM_CHARFROMPOS, 0, lParam) & 0xFFFF; + int /*long*/ lParam = OS.MAKELPARAM (x, y); + int position = OS.LOWORD (OS.SendMessage (handle, OS.EM_CHARFROMPOS, 0, lParam)); if (start <= position && position < end) { if (super.dragDetect (hwnd, x, y, filter, detect, consume)) { if (consume !is null) consume [0] = true; @@ -612,7 +672,7 @@ * pixel coordinates (0,0). */ int position = getCaretPosition (); - int caretPos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, position, 0); + int /*long*/ caretPos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, position, 0); if (caretPos is -1) { caretPos = 0; if (position >= OS.GetWindowTextLength (handle)) { @@ -641,7 +701,7 @@ OS.SendMessage (handle, OS.EM_SETSEL, start , end ); } } - return new Point (cast(short) (caretPos & 0xFFFF), cast(short) (caretPos >> 16)); + return new Point (OS.GET_X_LPARAM (caretPos), OS.GET_Y_LPARAM (caretPos)); } /** @@ -902,8 +962,8 @@ /*public*/ int getPosition (Point point) { checkWidget(); if (point is null) error (DWT.ERROR_NULL_ARGUMENT); - int lParam = (point.x & 0xFFFF) | ((point.y << 16) & 0xFFFF0000); - int position = OS.SendMessage (handle, OS.EM_CHARFROMPOS, 0, lParam) & 0xFFFF; + int /*long*/ lParam = OS.MAKELPARAM (point.x, point.y); + int position = OS.LOWORD (OS.SendMessage (handle, OS.EM_CHARFROMPOS, 0, lParam)); if (!OS.IsUnicode && OS.IsDBLocale) position = mbcsToWcsPos (position); return position; } @@ -1465,8 +1525,8 @@ if ((flags & OS.SWP_NOSIZE) is 0 && width !is 0) { RECT rect; OS.GetWindowRect (handle, &rect); - int margins = OS.SendMessage (handle, OS.EM_GETMARGINS, 0, 0); - int marginWidth = (margins & 0xFFFF) + ((margins >> 16) & 0xFFFF); + int /*long*/ margins = OS.SendMessage (handle, OS.EM_GETMARGINS, 0, 0); + int marginWidth = OS.LOWORD (margins) + OS.HIWORD (margins); if (rect.right - rect.left <= marginWidth) { int start, end; OS.SendMessage (handle, OS.EM_GETSEL, &start, &end); @@ -1804,7 +1864,7 @@ * to round off error, the tab spacing may not be the exact * number of space widths, depending on the font. */ - int width = (getTabWidth (tabs) * 4) / (OS.GetDialogBaseUnits () & 0xFFFF); + int width = (getTabWidth (tabs) * 4) / OS.LOWORD (OS.GetDialogBaseUnits ()); OS.SendMessage (handle, OS.EM_SETTABSTOPS, 1, &width); } @@ -2151,7 +2211,7 @@ * so DLGC_WANTARROWS should not be cleared. */ if ((style & DWT.READ_ONLY) !is 0) { - int code = callWindowProc (handle, OS.WM_GETDLGCODE, wParam, lParam); + int /*long*/ code = callWindowProc (handle, OS.WM_GETDLGCODE, wParam, lParam); code &= ~(OS.DLGC_WANTALLKEYS | OS.DLGC_WANTTAB); return new LRESULT (code); } @@ -2177,7 +2237,7 @@ * them to the application. */ ignoreCharacter = true; - int result = callWindowProc (handle, OS.WM_IME_CHAR, wParam, lParam); + int /*long*/ result = callWindowProc (handle, OS.WM_IME_CHAR, wParam, lParam); MSG msg; int flags = OS.PM_REMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE; while (OS.PeekMessage (&msg, handle, OS.WM_CHAR, OS.WM_CHAR, flags)) { @@ -2248,8 +2308,8 @@ */ bool hasMenu = menu !is null && !menu.isDisposed (); if (hasMenu || hooks (DWT.MenuDetect)) { - int x = cast(short) (lParam & 0xFFFF); - int y = cast(short) (lParam >> 16); + int x = OS.GET_X_LPARAM (lParam); + int y = OS.GET_Y_LPARAM (lParam); SHRGINFO shrg; shrg.cbSize = SHRGINFO.sizeof; shrg.hwndClient = handle; @@ -2287,7 +2347,7 @@ return wmClipboard (OS.WM_UNDO, wParam, lParam); } -LRESULT wmClipboard (int msg, int wParam, int lParam) { +LRESULT wmClipboard (int msg, int /*long*/ wParam, int /*long*/ lParam) { if ((style & DWT.READ_ONLY) !is 0) return null; if (!hooks (DWT.Verify) && !filters (DWT.Verify)) return null; bool call = false; @@ -2390,9 +2450,12 @@ } override LRESULT wmCommandChild (int wParam, int lParam) { - int code = wParam >> 16; + int code = OS.HIWORD (wParam); switch (code) { case OS.EN_CHANGE: + if (findImageControl () !is null) { + OS.InvalidateRect (handle, null, true); + } if (ignoreModify) break; /* * It is possible (but unlikely), that application