changeset 1625:50856987e794

Fixed value changed events on spinbuttons for OS/2. Not sure about this fix, was running into problems with it... but it seems to be working now... keep an eye on it. Ownership needs to be set for the spinbutton for the events to be handled, but ownership sometimes seems to cause loops.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 28 Mar 2012 02:14:38 +0000
parents c5aab296fba3
children fdeeba6c6d09
files os2/dw.c
diffstat 1 files changed, 67 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/os2/dw.c	Tue Mar 27 23:07:09 2012 +0000
+++ b/os2/dw.c	Wed Mar 28 02:14:38 2012 +0000
@@ -2281,11 +2281,11 @@
       }
       break;
    case WM_CONTROL:
-      {
-         if(strncmp(tmpbuf, "#38", 4)==0)
-            _run_event(hWnd, msg, mp1, mp2);
-      }
-      break;
+       {
+           if(strncmp(tmpbuf, "#38", 4)==0)
+               _run_event(hWnd, msg, mp1, mp2);
+       }
+       break;
    case WM_SETFOCUS:
       _run_event(hWnd, msg, mp1, mp2);
       break;
@@ -2406,7 +2406,7 @@
       break;
    case WM_CONTEXTMENU:
    case WM_COMMAND:
-      return _entryproc(hWnd, msg, mp1, mp2);
+       return _entryproc(hWnd, msg, mp1, mp2);
    }
 
    if(oldproc)
@@ -2879,14 +2879,18 @@
             break;
          case WM_CONTROL:
             if(origmsg == WM_VSCROLL || origmsg == WM_HSCROLL || tmp->message == SHORT2FROMMP(mp1) ||
-               (tmp->message == SLN_SLIDERTRACK && SHORT2FROMMP(mp1) == SLN_CHANGE))
+               (tmp->message == SLN_SLIDERTRACK && (SHORT2FROMMP(mp1) == SLN_CHANGE || SHORT2FROMMP(mp1) == SPBN_CHANGE)))
             {
                int svar = SLN_SLIDERTRACK;
                int id = SHORT1FROMMP(mp1);
-               HWND notifyhwnd = dw_window_from_id(hWnd, id);
-
-               if(origmsg == WM_CONTROL)
-                  svar = SHORT2FROMMP(mp1);
+			   HWND notifyhwnd = dw_window_from_id(hWnd, id);
+
+			   if(origmsg == WM_CONTROL)
+			   {
+				   svar = SHORT2FROMMP(mp1);
+				   if(!notifyhwnd && WinIsWindow(dwhab, mp2))
+                       notifyhwnd = mp2;
+			   }
 
                switch(svar)
                {
@@ -3077,6 +3081,22 @@
                      }
                   }
                   break;
+               case SPBN_CHANGE:
+                  {
+                     int (API_FUNC valuechangedfunc)(HWND, int, void *) = (int (API_FUNC)(HWND, int, void *))tmp->signalfunction;
+
+                     if(origmsg == WM_CONTROL && tmp->message == SLN_SLIDERTRACK)
+                     {
+                        /* Handle Spinbutton control */
+                        if(tmp->window == hWnd || tmp->window == notifyhwnd)
+                        {
+                            int position = dw_spinbutton_get_pos(tmp->window);
+                            result = valuechangedfunc(tmp->window, position, tmp->data);
+                            tmp = NULL;
+                        }
+                     }
+                  }
+                  break;
                case SLN_SLIDERTRACK:
                   {
                      int (API_FUNC valuechangedfunc)(HWND, int, void *) = (int (API_FUNC)(HWND, int, void *))tmp->signalfunction;
@@ -3215,20 +3235,35 @@
             _dw_color_spin_set(window, DW_RGB((val & 0xFF0000) >> 16, (val & 0xFF00) >> 8, val & 0xFF));
       }
       break;
+   case WM_USER:
+       _run_event(hWnd, WM_CONTROL, mp1, mp2);
+       break;
    case WM_CONTROL:
-      if((SHORT2FROMMP(mp1) == SPBN_CHANGE || SHORT2FROMMP(mp1) == SPBN_ENDSPIN))
-      {
-         HWND window = (HWND)dw_window_get_data(hWnd, "_dw_window");
-
-         if(window && !dw_window_get_data(window, "_dw_updating"))
-         {
-            unsigned long val = _dw_color_spin_get(window);
-            HWND col = (HWND)dw_window_get_data(window, "_dw_col");
-
-            _dw_col_set(col, val);
-         }
-      }
-      _run_event(hWnd, msg, mp1, mp2);
+       {
+           char tmpbuf[100];
+
+           WinQueryClassName(mp2, 99, (PCH)tmpbuf);
+           /* Don't set the ownership if it's an entryfield or spinbutton  */
+           if(strncmp(tmpbuf, "#32", 4)==0)
+           {
+               if((SHORT2FROMMP(mp1) == SPBN_CHANGE || SHORT2FROMMP(mp1) == SPBN_ENDSPIN))
+               {
+                   HWND window = (HWND)dw_window_get_data(hWnd, "_dw_window");
+
+                   if(window && !dw_window_get_data(window, "_dw_updating"))
+                   {
+                       unsigned long val = _dw_color_spin_get(window);
+                       HWND col = (HWND)dw_window_get_data(window, "_dw_col");
+
+                       _dw_col_set(col, val);
+                   }
+               }
+               if(!dw_window_get_data(mp2, "_dw_updating"))
+                   WinPostMsg(hWnd, WM_USER, mp1, mp2);
+           }
+		   else
+			   _run_event(hWnd, msg, mp1, mp2);
+      }
       break;
    }
 
@@ -7111,9 +7146,12 @@
       thisbox->count++;
 
       WinQueryClassName(item, 99, (PCH)tmpbuf);
-      /* Don't set the ownership if it's an entryfield or spinbutton */
-      if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0)
-         WinSetOwner(item, box);
+      /* Don't set the ownership if it's an entryfield
+       * NOTE: spinbutton used to be in this list but it was preventing value change events
+       * from firing, so I removed it.  If spinbuttons cause problems revisit this.
+       */
+      if(strncmp(tmpbuf, "#6", 3)!=0 && /*strncmp(tmpbuf, "#32", 4)!=0 &&*/ strncmp(tmpbuf, "#2", 3)!=0)
+          WinSetOwner(item, box);
       WinSetParent(frame ? frame : item, box, FALSE);
       _handle_transparent(box);
       /* Queue a redraw on the top-level window */
@@ -8073,7 +8111,9 @@
  */
 void API dw_spinbutton_set_pos(HWND handle, long position)
 {
+   dw_window_set_data(handle, "_dw_updating", (void *)1);
    WinSendMsg(handle, SPBM_SETCURRENTVALUE, MPFROMLONG((long)position), 0L);
+   dw_window_set_data(handle, "_dw_updating", NULL);
 }
 
 /*