Mercurial > dwindows
comparison os2/dw.c @ 37:360bc6a5f1c9
Sync with latest Dynamic Windows code.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 14 Oct 2001 23:27:37 +0000 |
parents | b03b24bb95f8 |
children | 538db2a48bac |
comparison
equal
deleted
inserted
replaced
36:cddb02f847e1 | 37:360bc6a5f1c9 |
---|---|
19 #include <stdio.h> | 19 #include <stdio.h> |
20 #include <stdarg.h> | 20 #include <stdarg.h> |
21 #include <stddef.h> | 21 #include <stddef.h> |
22 #include <ctype.h> | 22 #include <ctype.h> |
23 #include <process.h> | 23 #include <process.h> |
24 #include <time.h> | |
24 #include "dw.h" | 25 #include "dw.h" |
25 | 26 |
26 #define QWP_USER 0 | 27 #define QWP_USER 0 |
28 | |
29 MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2); | |
27 | 30 |
28 char ClassName[] = "dynamicwindows"; | 31 char ClassName[] = "dynamicwindows"; |
29 char SplitbarClassName[] = "dwsplitbar"; | 32 char SplitbarClassName[] = "dwsplitbar"; |
30 char DefaultFont[] = "9.WarpSans"; | 33 char DefaultFont[] = "9.WarpSans"; |
31 | 34 |
211 int _validate_focus(HWND handle) | 214 int _validate_focus(HWND handle) |
212 { | 215 { |
213 char tmpbuf[100]; | 216 char tmpbuf[100]; |
214 | 217 |
215 if(!handle) | 218 if(!handle) |
219 return 0; | |
220 | |
221 if(!WinIsWindowEnabled(handle)) | |
216 return 0; | 222 return 0; |
217 | 223 |
218 WinQueryClassName(handle, 99, tmpbuf); | 224 WinQueryClassName(handle, 99, tmpbuf); |
219 | 225 |
220 /* These are the window classes which can | 226 /* These are the window classes which can |
921 { | 927 { |
922 Box *boxinfo = WinQueryWindowPtr(handle, QWP_USER); | 928 Box *boxinfo = WinQueryWindowPtr(handle, QWP_USER); |
923 | 929 |
924 if(boxinfo && boxinfo->grouphwnd) | 930 if(boxinfo && boxinfo->grouphwnd) |
925 WinSetWindowPos(boxinfo->grouphwnd, HWND_TOP, 0, 0, | 931 WinSetWindowPos(boxinfo->grouphwnd, HWND_TOP, 0, 0, |
926 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); | 932 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE /*| SWP_ZORDER*/); |
927 | 933 |
928 } | 934 } |
929 | 935 |
930 } | 936 } |
931 | 937 |
1199 { | 1205 { |
1200 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); | 1206 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); |
1201 | 1207 |
1202 switch(msg) | 1208 switch(msg) |
1203 { | 1209 { |
1210 case WM_BUTTON1DOWN: | |
1211 case WM_BUTTON2DOWN: | |
1212 case WM_BUTTON3DOWN: | |
1213 { | |
1214 char tmpbuf[100]; | |
1215 | |
1216 WinQueryClassName(hWnd, 99, tmpbuf); | |
1217 | |
1218 if(strncmp(tmpbuf, "#32", 3)==0) | |
1219 _run_event(hWnd, WM_SETFOCUS, FALSE, TRUE); | |
1220 } | |
1221 break; | |
1222 case WM_SETFOCUS: | |
1223 _run_event(hWnd, msg, mp1, mp2); | |
1224 break; | |
1204 case WM_CHAR: | 1225 case WM_CHAR: |
1205 if(SHORT1FROMMP(mp2) == '\t') | 1226 if(SHORT1FROMMP(mp2) == '\t') |
1206 { | 1227 { |
1207 _shift_focus(hWnd); | 1228 _shift_focus(hWnd); |
1208 return FALSE; | 1229 return FALSE; |
2160 return WinDefWindowProc(hwnd, msg, mp1, mp2); | 2181 return WinDefWindowProc(hwnd, msg, mp1, mp2); |
2161 | 2182 |
2162 switch(msg) | 2183 switch(msg) |
2163 { | 2184 { |
2164 #ifndef NO_SIGNALS | 2185 #ifndef NO_SIGNALS |
2186 case WM_SETFOCUS: | |
2187 _wndproc(hwnd, msg, mp1, mp2); | |
2188 break; | |
2165 case WM_BUTTON1UP: | 2189 case WM_BUTTON1UP: |
2166 { | 2190 { |
2167 SignalHandler *tmp = Root; | 2191 SignalHandler *tmp = Root; |
2168 | 2192 |
2169 if(WinIsWindowEnabled(hwnd)) | 2193 if(WinIsWindowEnabled(hwnd)) |
2430 WinTerminate(dwhab); | 2454 WinTerminate(dwhab); |
2431 } | 2455 } |
2432 } | 2456 } |
2433 | 2457 |
2434 /* | 2458 /* |
2459 * Runs a message loop for Dynamic Windows, for a period of seconds. | |
2460 * Parameters: | |
2461 * seconds: Number of seconds to run the loop for. | |
2462 */ | |
2463 void dw_main_sleep(int seconds) | |
2464 { | |
2465 QMSG qmsg; | |
2466 time_t start = time(NULL); | |
2467 | |
2468 while(time(NULL) - start <= seconds) | |
2469 { | |
2470 if(WinPeekMsg(dwhab, &qmsg, 0, 0, 0, PM_NOREMOVE)) | |
2471 { | |
2472 WinGetMsg(dwhab, &qmsg, 0, 0, 0); | |
2473 WinDispatchMsg(dwhab, &qmsg); | |
2474 } | |
2475 else | |
2476 DosSleep(1); | |
2477 } | |
2478 } | |
2479 | |
2480 /* | |
2435 * Free's memory allocated by dynamic windows. | 2481 * Free's memory allocated by dynamic windows. |
2436 * Parameters: | 2482 * Parameters: |
2437 * ptr: Pointer to dynamic windows allocated | 2483 * ptr: Pointer to dynamic windows allocated |
2438 * memory to be free()'d. | 2484 * memory to be free()'d. |
2439 */ | 2485 */ |
3744 if(thisbox->count) | 3790 if(thisbox->count) |
3745 free(thisitem); | 3791 free(thisitem); |
3746 | 3792 |
3747 thisbox->count++; | 3793 thisbox->count++; |
3748 | 3794 |
3749 /* Don't set the ownership if it's an entryfield or combobox */ | 3795 /* Don't set the ownership if it's an entryfield or spinbutton */ |
3750 WinQueryClassName(item, 99, tmpbuf); | 3796 WinQueryClassName(item, 99, tmpbuf); |
3751 if(strncmp(tmpbuf, "#6", 3)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/) | 3797 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 3)!=0) |
3752 { | 3798 { |
3753 if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0) | 3799 if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0) |
3754 WinSetOwner(item, boxowner); | 3800 WinSetOwner(item, boxowner); |
3755 else | 3801 else |
3756 WinSetOwner(item, box); | 3802 WinSetOwner(item, box); |
5845 free(thisitem); | 5891 free(thisitem); |
5846 | 5892 |
5847 thisbox->count++; | 5893 thisbox->count++; |
5848 | 5894 |
5849 WinQueryClassName(item, 99, tmpbuf); | 5895 WinQueryClassName(item, 99, tmpbuf); |
5850 /* Don't set the ownership if it's an entryfield or combobox */ | 5896 /* Don't set the ownership if it's an entryfield or spinbutton */ |
5851 if(strncmp(tmpbuf, "#6", 3)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/) | 5897 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 3)!=0) |
5852 { | 5898 { |
5853 if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0) | 5899 if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0) |
5854 WinSetOwner(item, boxowner); | 5900 WinSetOwner(item, boxowner); |
5855 else | 5901 else |
5856 WinSetOwner(item, box); | 5902 WinSetOwner(item, box); |