comparison os2/dw.c @ 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 1795bd78207d
children 1d3013463204
comparison
equal deleted inserted replaced
1624:c5aab296fba3 1625:50856987e794
2279 if(strncmp(tmpbuf, "#32", 4)==0) 2279 if(strncmp(tmpbuf, "#32", 4)==0)
2280 _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE); 2280 _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE);
2281 } 2281 }
2282 break; 2282 break;
2283 case WM_CONTROL: 2283 case WM_CONTROL:
2284 { 2284 {
2285 if(strncmp(tmpbuf, "#38", 4)==0) 2285 if(strncmp(tmpbuf, "#38", 4)==0)
2286 _run_event(hWnd, msg, mp1, mp2); 2286 _run_event(hWnd, msg, mp1, mp2);
2287 } 2287 }
2288 break; 2288 break;
2289 case WM_SETFOCUS: 2289 case WM_SETFOCUS:
2290 _run_event(hWnd, msg, mp1, mp2); 2290 _run_event(hWnd, msg, mp1, mp2);
2291 break; 2291 break;
2292 case WM_CHAR: 2292 case WM_CHAR:
2293 if(_run_event(hWnd, msg, mp1, mp2) == (MRESULT)TRUE) 2293 if(_run_event(hWnd, msg, mp1, mp2) == (MRESULT)TRUE)
2404 if(_wndproc(hWnd, msg, mp1, mp2)) 2404 if(_wndproc(hWnd, msg, mp1, mp2))
2405 return MPFROMSHORT(FALSE); 2405 return MPFROMSHORT(FALSE);
2406 break; 2406 break;
2407 case WM_CONTEXTMENU: 2407 case WM_CONTEXTMENU:
2408 case WM_COMMAND: 2408 case WM_COMMAND:
2409 return _entryproc(hWnd, msg, mp1, mp2); 2409 return _entryproc(hWnd, msg, mp1, mp2);
2410 } 2410 }
2411 2411
2412 if(oldproc) 2412 if(oldproc)
2413 return oldproc(hWnd, msg, mp1, mp2); 2413 return oldproc(hWnd, msg, mp1, mp2);
2414 2414
2877 } 2877 }
2878 } 2878 }
2879 break; 2879 break;
2880 case WM_CONTROL: 2880 case WM_CONTROL:
2881 if(origmsg == WM_VSCROLL || origmsg == WM_HSCROLL || tmp->message == SHORT2FROMMP(mp1) || 2881 if(origmsg == WM_VSCROLL || origmsg == WM_HSCROLL || tmp->message == SHORT2FROMMP(mp1) ||
2882 (tmp->message == SLN_SLIDERTRACK && SHORT2FROMMP(mp1) == SLN_CHANGE)) 2882 (tmp->message == SLN_SLIDERTRACK && (SHORT2FROMMP(mp1) == SLN_CHANGE || SHORT2FROMMP(mp1) == SPBN_CHANGE)))
2883 { 2883 {
2884 int svar = SLN_SLIDERTRACK; 2884 int svar = SLN_SLIDERTRACK;
2885 int id = SHORT1FROMMP(mp1); 2885 int id = SHORT1FROMMP(mp1);
2886 HWND notifyhwnd = dw_window_from_id(hWnd, id); 2886 HWND notifyhwnd = dw_window_from_id(hWnd, id);
2887 2887
2888 if(origmsg == WM_CONTROL) 2888 if(origmsg == WM_CONTROL)
2889 svar = SHORT2FROMMP(mp1); 2889 {
2890 svar = SHORT2FROMMP(mp1);
2891 if(!notifyhwnd && WinIsWindow(dwhab, mp2))
2892 notifyhwnd = mp2;
2893 }
2890 2894
2891 switch(svar) 2895 switch(svar)
2892 { 2896 {
2893 case CN_ENTER: 2897 case CN_ENTER:
2894 { 2898 {
3075 tmp = NULL; 3079 tmp = NULL;
3076 } 3080 }
3077 } 3081 }
3078 } 3082 }
3079 break; 3083 break;
3084 case SPBN_CHANGE:
3085 {
3086 int (API_FUNC valuechangedfunc)(HWND, int, void *) = (int (API_FUNC)(HWND, int, void *))tmp->signalfunction;
3087
3088 if(origmsg == WM_CONTROL && tmp->message == SLN_SLIDERTRACK)
3089 {
3090 /* Handle Spinbutton control */
3091 if(tmp->window == hWnd || tmp->window == notifyhwnd)
3092 {
3093 int position = dw_spinbutton_get_pos(tmp->window);
3094 result = valuechangedfunc(tmp->window, position, tmp->data);
3095 tmp = NULL;
3096 }
3097 }
3098 }
3099 break;
3080 case SLN_SLIDERTRACK: 3100 case SLN_SLIDERTRACK:
3081 { 3101 {
3082 int (API_FUNC valuechangedfunc)(HWND, int, void *) = (int (API_FUNC)(HWND, int, void *))tmp->signalfunction; 3102 int (API_FUNC valuechangedfunc)(HWND, int, void *) = (int (API_FUNC)(HWND, int, void *))tmp->signalfunction;
3083 3103
3084 if(origmsg == WM_CONTROL) 3104 if(origmsg == WM_CONTROL)
3213 3233
3214 if(window) 3234 if(window)
3215 _dw_color_spin_set(window, DW_RGB((val & 0xFF0000) >> 16, (val & 0xFF00) >> 8, val & 0xFF)); 3235 _dw_color_spin_set(window, DW_RGB((val & 0xFF0000) >> 16, (val & 0xFF00) >> 8, val & 0xFF));
3216 } 3236 }
3217 break; 3237 break;
3238 case WM_USER:
3239 _run_event(hWnd, WM_CONTROL, mp1, mp2);
3240 break;
3218 case WM_CONTROL: 3241 case WM_CONTROL:
3219 if((SHORT2FROMMP(mp1) == SPBN_CHANGE || SHORT2FROMMP(mp1) == SPBN_ENDSPIN)) 3242 {
3220 { 3243 char tmpbuf[100];
3221 HWND window = (HWND)dw_window_get_data(hWnd, "_dw_window"); 3244
3222 3245 WinQueryClassName(mp2, 99, (PCH)tmpbuf);
3223 if(window && !dw_window_get_data(window, "_dw_updating")) 3246 /* Don't set the ownership if it's an entryfield or spinbutton */
3224 { 3247 if(strncmp(tmpbuf, "#32", 4)==0)
3225 unsigned long val = _dw_color_spin_get(window); 3248 {
3226 HWND col = (HWND)dw_window_get_data(window, "_dw_col"); 3249 if((SHORT2FROMMP(mp1) == SPBN_CHANGE || SHORT2FROMMP(mp1) == SPBN_ENDSPIN))
3227 3250 {
3228 _dw_col_set(col, val); 3251 HWND window = (HWND)dw_window_get_data(hWnd, "_dw_window");
3229 } 3252
3230 } 3253 if(window && !dw_window_get_data(window, "_dw_updating"))
3231 _run_event(hWnd, msg, mp1, mp2); 3254 {
3255 unsigned long val = _dw_color_spin_get(window);
3256 HWND col = (HWND)dw_window_get_data(window, "_dw_col");
3257
3258 _dw_col_set(col, val);
3259 }
3260 }
3261 if(!dw_window_get_data(mp2, "_dw_updating"))
3262 WinPostMsg(hWnd, WM_USER, mp1, mp2);
3263 }
3264 else
3265 _run_event(hWnd, msg, mp1, mp2);
3266 }
3232 break; 3267 break;
3233 } 3268 }
3234 3269
3235 if(blah && blah->oldproc) 3270 if(blah && blah->oldproc)
3236 return blah->oldproc(hWnd, msg, mp1, mp2); 3271 return blah->oldproc(hWnd, msg, mp1, mp2);
7109 free(thisitem); 7144 free(thisitem);
7110 7145
7111 thisbox->count++; 7146 thisbox->count++;
7112 7147
7113 WinQueryClassName(item, 99, (PCH)tmpbuf); 7148 WinQueryClassName(item, 99, (PCH)tmpbuf);
7114 /* Don't set the ownership if it's an entryfield or spinbutton */ 7149 /* Don't set the ownership if it's an entryfield
7115 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0) 7150 * NOTE: spinbutton used to be in this list but it was preventing value change events
7116 WinSetOwner(item, box); 7151 * from firing, so I removed it. If spinbuttons cause problems revisit this.
7152 */
7153 if(strncmp(tmpbuf, "#6", 3)!=0 && /*strncmp(tmpbuf, "#32", 4)!=0 &&*/ strncmp(tmpbuf, "#2", 3)!=0)
7154 WinSetOwner(item, box);
7117 WinSetParent(frame ? frame : item, box, FALSE); 7155 WinSetParent(frame ? frame : item, box, FALSE);
7118 _handle_transparent(box); 7156 _handle_transparent(box);
7119 /* Queue a redraw on the top-level window */ 7157 /* Queue a redraw on the top-level window */
7120 _dw_redraw(_toplevel_window(item), TRUE); 7158 _dw_redraw(_toplevel_window(item), TRUE);
7121 } 7159 }
8071 * handle: Handle to the spinbutton to be set. 8109 * handle: Handle to the spinbutton to be set.
8072 * position: Current value of the spinbutton. 8110 * position: Current value of the spinbutton.
8073 */ 8111 */
8074 void API dw_spinbutton_set_pos(HWND handle, long position) 8112 void API dw_spinbutton_set_pos(HWND handle, long position)
8075 { 8113 {
8114 dw_window_set_data(handle, "_dw_updating", (void *)1);
8076 WinSendMsg(handle, SPBM_SETCURRENTVALUE, MPFROMLONG((long)position), 0L); 8115 WinSendMsg(handle, SPBM_SETCURRENTVALUE, MPFROMLONG((long)position), 0L);
8116 dw_window_set_data(handle, "_dw_updating", NULL);
8077 } 8117 }
8078 8118
8079 /* 8119 /*
8080 * Sets the spinbutton limits. 8120 * Sets the spinbutton limits.
8081 * Parameters: 8121 * Parameters: