Added fields from NetBSD struct sigcontext on i386.
[wine] / controls / edit.c
index 9a19092..978914f 100644 (file)
@@ -44,6 +44,7 @@
 
 #include "winbase.h"
 #include "winnt.h"
+#include "wownt32.h"
 #include "win.h"
 #include "wine/winbase16.h"
 #include "wine/winuser16.h"
@@ -154,7 +155,7 @@ typedef struct
 #define EDIT_NOTIFY_PARENT(es, wNotifyCode, str) \
        do \
        { /* Notify parent which has created this edit control */ \
-           TRACE("notification " str " sent to hwnd=%08x\n", es->hwndParent); \
+           TRACE("notification " str " sent to hwnd=%p\n", es->hwndParent); \
            SendMessageW(es->hwndParent, WM_COMMAND, \
                     MAKEWPARAM(GetWindowLongW((es->hwndSelf),GWL_ID), wNotifyCode), \
                     (LPARAM)(es->hwndSelf)); \
@@ -419,7 +420,7 @@ static LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
        EDITSTATE *es = (EDITSTATE *)GetWindowLongW( hwnd, 0 );
        LRESULT result = 0;
 
-        TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, msg, wParam, lParam);
+        TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hwnd, msg, wParam, lParam);
        
        if (!es && msg != WM_NCCREATE)
                return DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
@@ -1270,9 +1271,6 @@ static void EDIT_CalcLineWidth_SL(EDITSTATE *es)
  *             the string under examination (we can decide this for ourselves).
  *
  */
-/* ### start build ### */
-extern WORD CALLBACK EDIT_CallTo16_word_lwww(EDITWORDBREAKPROC16,SEGPTR,WORD,WORD,WORD);
-/* ### stop build ### */
 static INT EDIT_CallWordBreakProc(EDITSTATE *es, INT start, INT index, INT count, INT action)
 {
     INT ret, iWndsLocks;
@@ -1285,13 +1283,20 @@ static INT EDIT_CallWordBreakProc(EDITSTATE *es, INT start, INT index, INT count
            HGLOBAL16 hglob16;
            SEGPTR segptr;
            INT countA;
+            WORD args[5];
+            DWORD result;
 
            countA = WideCharToMultiByte(CP_ACP, 0, es->text + start, count, NULL, 0, NULL, NULL);
            hglob16 = GlobalAlloc16(GMEM_MOVEABLE | GMEM_ZEROINIT, countA);
            segptr = K32WOWGlobalLock16(hglob16);
            WideCharToMultiByte(CP_ACP, 0, es->text + start, count, MapSL(segptr), countA, NULL, NULL);
-           ret = (INT)EDIT_CallTo16_word_lwww(es->word_break_proc16,
-                                               segptr, index, countA, action);
+            args[4] = SELECTOROF(segptr);
+            args[3] = OFFSETOF(segptr);
+            args[2] = index;
+            args[1] = countA;
+            args[0] = action;
+            WOWCallback16Ex((DWORD)es->word_break_proc16, WCB16_PASCAL, sizeof(args), args, &result);
+            ret = LOWORD(result);
            GlobalUnlock16(hglob16);
            GlobalFree16(hglob16);
        }
@@ -1710,7 +1715,7 @@ static BOOL EDIT_MakeFit(EDITSTATE *es, UINT size, BOOL honor_limit)
        if (es->hloc32W) {
            UINT alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
            if ((hNew32W = LocalReAlloc(es->hloc32W, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT))) {
-               TRACE("Old 32 bit handle %08x, new handle %08x\n", es->hloc32W, hNew32W);
+               TRACE("Old 32 bit handle %p, new handle %p\n", es->hloc32W, hNew32W);
                es->hloc32W = hNew32W;
                es->buffer_size = LocalSize(hNew32W)/sizeof(WCHAR) - 1;
            }
@@ -1747,7 +1752,7 @@ static BOOL EDIT_MakeUndoFit(EDITSTATE *es, UINT size)
 
        alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
        if ((es->undo_text = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, es->undo_text, alloc_size))) {
-               es->undo_buffer_size = alloc_size/sizeof(WCHAR);
+               es->undo_buffer_size = alloc_size/sizeof(WCHAR) - 1;
                return TRUE;
        }
        else
@@ -2169,7 +2174,7 @@ static void EDIT_SetRectNP(EDITSTATE *es, LPRECT rc)
                es->format_rect.bottom = es->format_rect.top + es->line_height;
 
        if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL))
-               EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, (HRGN)0);
+               EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, NULL);
 }
 
 
@@ -2185,7 +2190,7 @@ static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
        /* Edit window might be already destroyed */
        if(!IsWindow(es->hwndSelf))
        {
-           WARN("edit hwnd %04x already destroyed\n", es->hwndSelf);
+           WARN("edit hwnd %p already destroyed\n", es->hwndSelf);
            return;
        }
 
@@ -2468,7 +2473,7 @@ static HLOCAL EDIT_EM_GetHandle(EDITSTATE *es)
            hLocal = es->hloc32A;
        }
 
-       TRACE("Returning %04X, LocalSize() = %ld\n", hLocal, LocalSize(hLocal));
+       TRACE("Returning %p, LocalSize() = %ld\n", hLocal, LocalSize(hLocal));
        return hLocal;
 }
 
@@ -2779,7 +2784,7 @@ static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy)
                GetClientRect(es->hwndSelf, &rc1);
                IntersectRect(&rc, &rc1, &es->format_rect);
                ScrollWindowEx(es->hwndSelf, -dx, dy,
-                               NULL, &rc, (HRGN)NULL, NULL, SW_INVALIDATE);
+                               NULL, &rc, NULL, NULL, SW_INVALIDATE);
                /* force scroll info update */
                EDIT_UpdateScrollInfo(es);
        }
@@ -3143,7 +3148,7 @@ static void EDIT_EM_SetHandle(EDITSTATE *es, HLOCAL hloc)
            if(es->hloc32A)
            {
                LocalFree(es->hloc32A);
-               es->hloc32A = (HLOCAL)NULL;
+               es->hloc32A = NULL;
            }
            es->hloc32W = hloc;
        }
@@ -3183,7 +3188,7 @@ static void EDIT_EM_SetHandle(EDITSTATE *es, HLOCAL hloc)
        EDIT_EM_EmptyUndoBuffer(es);
        es->flags &= ~EF_MODIFIED;
        es->flags &= ~EF_UPDATE;
-       EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, (HRGN)0);
+       EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, NULL);
        EDIT_UpdateText(es, NULL, TRUE);
        EDIT_EM_ScrollCaret(es);
        /* force scroll info update */
@@ -3219,7 +3224,7 @@ static void EDIT_EM_SetHandle16(EDITSTATE *es, HLOCAL16 hloc)
        if(es->hloc32A)
        {
            LocalFree(es->hloc32A);
-           es->hloc32A = (HLOCAL)NULL;
+           es->hloc32A = NULL;
        }
 
        countA = LOCAL_Size(hInstance, hloc);
@@ -3250,7 +3255,7 @@ static void EDIT_EM_SetHandle16(EDITSTATE *es, HLOCAL16 hloc)
        EDIT_EM_EmptyUndoBuffer(es);
        es->flags &= ~EF_MODIFIED;
        es->flags &= ~EF_UPDATE;
-       EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, (HRGN)0);
+       EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, NULL);
        EDIT_UpdateText(es, NULL, TRUE);
        EDIT_EM_ScrollCaret(es);
        /* force scroll info update */
@@ -3460,7 +3465,7 @@ static void EDIT_EM_SetWordBreakProc(EDITSTATE *es, LPARAM lParam)
        es->word_break_proc16 = NULL;
 
        if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) {
-               EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, (HRGN)0);
+               EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, NULL);
                EDIT_UpdateText(es, NULL, TRUE);
        }
 }
@@ -3479,7 +3484,7 @@ static void EDIT_EM_SetWordBreakProc16(EDITSTATE *es, EDITWORDBREAKPROC16 wbp)
        es->word_break_proc = NULL;
        es->word_break_proc16 = wbp;
        if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) {
-               EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, (HRGN)0);
+               EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, NULL);
                EDIT_UpdateText(es, NULL, TRUE);
        }
 }
@@ -3981,8 +3986,7 @@ static BOOL EDIT_CheckCombo(EDITSTATE *es, UINT msg, INT key)
    bDropped = TRUE;
    nEUI     = 0;
 
-   TRACE_(combo)("[%04x]: handling msg %04x (%04x)\n",
-                            es->hwndSelf, (UINT16)msg, (UINT16)key);
+   TRACE_(combo)("[%p]: handling msg %x (%x)\n", es->hwndSelf, msg, key);
 
    if (key == VK_UP || key == VK_DOWN)
    {
@@ -4217,9 +4221,9 @@ static LRESULT EDIT_WM_LButtonDown(EDITSTATE *es, DWORD keys, INT x, INT y)
  */
 static LRESULT EDIT_WM_LButtonUp(EDITSTATE *es)
 {
-       if (es->bCaptureState && GetCapture() == es->hwndSelf) {
+       if (es->bCaptureState) {
                KillTimer(es->hwndSelf, 0);
-               ReleaseCapture();
+               if (GetCapture() == es->hwndSelf) ReleaseCapture();
        }
        es->bCaptureState = FALSE;
        return 0;
@@ -4528,7 +4532,7 @@ static void EDIT_WM_SetFont(EDITSTATE *es, HFONT font, BOOL redraw)
        EDIT_SetRectNP(es, &r);
 
        if (es->style & ES_MULTILINE)
-               EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, (HRGN)0);
+               EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, NULL);
        else
            EDIT_CalcLineWidth_SL(es);