comparison os2/dw.c @ 1404:56f311dc23f6

Changes to get the library building with Watcom on OS/2. These changes mean that VisualAge 3.0 will no longer build the library. Please use version 3.6 or higher.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 29 Nov 2011 15:25:41 +0000
parents ccd383e11ff8
children b7aaf06e9367
comparison
equal deleted inserted replaced
1403:20c6d0c50c94 1404:56f311dc23f6
1787 WinStartTimer(dwhab, hwnd, 2, 15000); 1787 WinStartTimer(dwhab, hwnd, 2, 15000);
1788 hend = hwnd; 1788 hend = hwnd;
1789 } 1789 }
1790 } 1790 }
1791 break; 1791 break;
1792 } 1792 }
1793 return (MRESULT)FALSE;
1793 } 1794 }
1794 1795
1795 #define CALENDAR_BORDER 3 1796 #define CALENDAR_BORDER 3
1796 #define CALENDAR_ARROW 8 1797 #define CALENDAR_ARROW 8
1797 1798
2245 /* Find any callbacks for this function */ 2246 /* Find any callbacks for this function */
2246 while(tmp) 2247 while(tmp)
2247 { 2248 {
2248 if(tmp->message == WM_COMMAND) 2249 if(tmp->message == WM_COMMAND)
2249 { 2250 {
2250 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))tmp->signalfunction; 2251 int (API * clickfunc)(HWND, void *) = (int (API *)(HWND, void *))tmp->signalfunction;
2251 2252
2252 /* Make sure it's the right window, and the right ID */ 2253 /* Make sure it's the right window, and the right ID */
2253 if(tmp->window == handle) 2254 if(tmp->window == handle)
2254 { 2255 {
2255 clickfunc(tmp->window, tmp->data); 2256 clickfunc(tmp->window, tmp->data);
2784 { 2785 {
2785 case WM_SETFOCUS: 2786 case WM_SETFOCUS:
2786 { 2787 {
2787 if((mp2 && tmp->message == WM_SETFOCUS) || (!mp2 && tmp->message == WM_USER+1)) 2788 if((mp2 && tmp->message == WM_SETFOCUS) || (!mp2 && tmp->message == WM_USER+1))
2788 { 2789 {
2789 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))tmp->signalfunction; 2790 int (API * setfocusfunc)(HWND, void *) = (int (API *)(HWND, void *))tmp->signalfunction;
2790 2791
2791 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd) 2792 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd)
2792 { 2793 {
2793 result = setfocusfunc(tmp->window, tmp->data); 2794 result = setfocusfunc(tmp->window, tmp->data);
2794 tmp = NULL; 2795 tmp = NULL;
2796 } 2797 }
2797 } 2798 }
2798 break; 2799 break;
2799 case WM_TIMER: 2800 case WM_TIMER:
2800 { 2801 {
2801 int (* API timerfunc)(void *) = (int (* API)(void *))tmp->signalfunction; 2802 int (API * timerfunc)(void *) = (int (API *)(void *))tmp->signalfunction;
2802 if(tmp->id == (int)mp1) 2803 if(tmp->id == (int)mp1)
2803 { 2804 {
2804 if(!timerfunc(tmp->data)) 2805 if(!timerfunc(tmp->data))
2805 dw_timer_disconnect(tmp->id); 2806 dw_timer_disconnect(tmp->id);
2806 tmp = NULL; 2807 tmp = NULL;
2808 result = 0; 2809 result = 0;
2809 } 2810 }
2810 break; 2811 break;
2811 case WM_SIZE: 2812 case WM_SIZE:
2812 { 2813 {
2813 int (* API sizefunc)(HWND, int, int, void *) = (int (* API)(HWND, int, int, void *))tmp->signalfunction; 2814 int (API * sizefunc)(HWND, int, int, void *) = (int (API *)(HWND, int, int, void *))tmp->signalfunction;
2814 2815
2815 if((hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd) && SHORT1FROMMP(mp2) && SHORT2FROMMP(mp2)) 2816 if((hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd) && SHORT1FROMMP(mp2) && SHORT2FROMMP(mp2))
2816 { 2817 {
2817 result = sizefunc(tmp->window, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), tmp->data); 2818 result = sizefunc(tmp->window, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), tmp->data);
2818 tmp = NULL; 2819 tmp = NULL;
2820 } 2821 }
2821 break; 2822 break;
2822 case WM_BUTTON1DOWN: 2823 case WM_BUTTON1DOWN:
2823 { 2824 {
2824 POINTS pts = (*((POINTS*)&mp1)); 2825 POINTS pts = (*((POINTS*)&mp1));
2825 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))tmp->signalfunction; 2826 int (API * buttonfunc)(HWND, int, int, int, void *) = (int (API *)(HWND, int, int, int, void *))tmp->signalfunction;
2826 2827
2827 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window) 2828 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window)
2828 { 2829 {
2829 int button = 0; 2830 int button = 0;
2830 2831
2847 } 2848 }
2848 break; 2849 break;
2849 case WM_BUTTON1UP: 2850 case WM_BUTTON1UP:
2850 { 2851 {
2851 POINTS pts = (*((POINTS*)&mp1)); 2852 POINTS pts = (*((POINTS*)&mp1));
2852 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))tmp->signalfunction; 2853 int (API * buttonfunc)(HWND, int, int, int, void *) = (int (API *)(HWND, int, int, int, void *))tmp->signalfunction;
2853 2854
2854 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window) 2855 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window)
2855 { 2856 {
2856 int button = 0; 2857 int button = 0;
2857 2858
2873 } 2874 }
2874 } 2875 }
2875 break; 2876 break;
2876 case WM_MOUSEMOVE: 2877 case WM_MOUSEMOVE:
2877 { 2878 {
2878 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))tmp->signalfunction; 2879 int (API * motionfunc)(HWND, int, int, int, void *) = (int (API *)(HWND, int, int, int, void *))tmp->signalfunction;
2879 2880
2880 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window) 2881 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window)
2881 { 2882 {
2882 int keys = 0; 2883 int keys = 0;
2883 SHORT x = SHORT1FROMMP(mp1), y = SHORT2FROMMP(mp1); 2884 SHORT x = SHORT1FROMMP(mp1), y = SHORT2FROMMP(mp1);
2894 } 2895 }
2895 } 2896 }
2896 break; 2897 break;
2897 case WM_CHAR: 2898 case WM_CHAR:
2898 { 2899 {
2899 int (* API keypressfunc)(HWND, char, int, int, void *) = (int (* API)(HWND, char, int, int, void *))tmp->signalfunction; 2900 int (API * keypressfunc)(HWND, char, int, int, void *) = (int (API *)(HWND, char, int, int, void *))tmp->signalfunction;
2900 2901
2901 if((hWnd == tmp->window || _toplevel_window(hWnd) == tmp->window) && !(SHORT1FROMMP(mp1) & KC_KEYUP)) 2902 if((hWnd == tmp->window || _toplevel_window(hWnd) == tmp->window) && !(SHORT1FROMMP(mp1) & KC_KEYUP))
2902 { 2903 {
2903 int vk; 2904 int vk;
2904 char ch = 0; 2905 char ch = 0;
2925 } 2926 }
2926 } 2927 }
2927 break; 2928 break;
2928 case WM_CLOSE: 2929 case WM_CLOSE:
2929 { 2930 {
2930 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))tmp->signalfunction; 2931 int (API * closefunc)(HWND, void *) = (int (API *)(HWND, void *))tmp->signalfunction;
2931 2932
2932 if(hWnd == tmp->window || hWnd == WinWindowFromID(tmp->window, FID_CLIENT)) 2933 if(hWnd == tmp->window || hWnd == WinWindowFromID(tmp->window, FID_CLIENT))
2933 { 2934 {
2934 result = closefunc(tmp->window, tmp->data); 2935 result = closefunc(tmp->window, tmp->data);
2935 if(result) 2936 if(result)
2940 break; 2941 break;
2941 case WM_PAINT: 2942 case WM_PAINT:
2942 { 2943 {
2943 HPS hps; 2944 HPS hps;
2944 DWExpose exp; 2945 DWExpose exp;
2945 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))tmp->signalfunction; 2946 int (API * exposefunc)(HWND, DWExpose *, void *) = (int (API *)(HWND, DWExpose *, void *))tmp->signalfunction;
2946 RECTL rc; 2947 RECTL rc;
2947 2948
2948 if(hWnd == tmp->window) 2949 if(hWnd == tmp->window)
2949 { 2950 {
2950 int height = _get_height(hWnd); 2951 int height = _get_height(hWnd);
2959 } 2960 }
2960 } 2961 }
2961 break; 2962 break;
2962 case WM_COMMAND: 2963 case WM_COMMAND:
2963 { 2964 {
2964 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))tmp->signalfunction; 2965 int (API * clickfunc)(HWND, void *) = (int (API *)(HWND, void *))tmp->signalfunction;
2965 ULONG command = COMMANDMSG(&msg)->cmd; 2966 ULONG command = COMMANDMSG(&msg)->cmd;
2966 2967
2967 if(tmp->id && command == tmp->id) 2968 if(tmp->id && command == tmp->id)
2968 { 2969 {
2969 HWND menuowner = _menu_owner(tmp->window); 2970 HWND menuowner = _menu_owner(tmp->window);
2994 2995
2995 switch(svar) 2996 switch(svar)
2996 { 2997 {
2997 case CN_ENTER: 2998 case CN_ENTER:
2998 { 2999 {
2999 int (* API containerselectfunc)(HWND, char *, void *) = (int (* API)(HWND, char *, void *))tmp->signalfunction; 3000 int (API * containerselectfunc)(HWND, char *, void *) = (int (API *)(HWND, char *, void *))tmp->signalfunction;
3000 char *text = NULL; 3001 char *text = NULL;
3001 3002
3002 if(mp2) 3003 if(mp2)
3003 { 3004 {
3004 PRECORDCORE pre; 3005 PRECORDCORE pre;
3015 } 3016 }
3016 } 3017 }
3017 break; 3018 break;
3018 case CN_EXPANDTREE: 3019 case CN_EXPANDTREE:
3019 { 3020 {
3020 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))tmp->signalfunction; 3021 int (API * treeexpandfunc)(HWND, HTREEITEM, void *) = (int (API *)(HWND, HTREEITEM, void *))tmp->signalfunction;
3021 3022
3022 if(tmp->window == notifyhwnd) 3023 if(tmp->window == notifyhwnd)
3023 { 3024 {
3024 result = treeexpandfunc(tmp->window, (HTREEITEM)mp2, tmp->data); 3025 result = treeexpandfunc(tmp->window, (HTREEITEM)mp2, tmp->data);
3025 tmp = NULL; 3026 tmp = NULL;
3026 } 3027 }
3027 } 3028 }
3028 break; 3029 break;
3029 case CN_CONTEXTMENU: 3030 case CN_CONTEXTMENU:
3030 { 3031 {
3031 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))tmp->signalfunction; 3032 int (API * containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (API *)(HWND, char *, int, int, void *, void *))tmp->signalfunction;
3032 char *text = NULL; 3033 char *text = NULL;
3033 void *user = NULL; 3034 void *user = NULL;
3034 LONG x,y; 3035 LONG x,y;
3035 3036
3036 if(mp2) 3037 if(mp2)
3091 { 3092 {
3092 PCNRITEM pci = (PCNRITEM)pre->pRecord; 3093 PCNRITEM pci = (PCNRITEM)pre->pRecord;
3093 3094
3094 if(pci && pre->fEmphasisMask & CRA_CURSORED && (pci->rc.flRecordAttr & CRA_CURSORED)) 3095 if(pci && pre->fEmphasisMask & CRA_CURSORED && (pci->rc.flRecordAttr & CRA_CURSORED))
3095 { 3096 {
3096 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))tmp->signalfunction; 3097 int (API * treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (API *)(HWND, HTREEITEM, char *, void *, void *))tmp->signalfunction;
3097 3098
3098 if(dw_window_get_data(tmp->window, "_dw_container")) 3099 if(dw_window_get_data(tmp->window, "_dw_container"))
3099 result = treeselectfunc(tmp->window, 0, (char *)pci->rc.pszIcon, tmp->data, 0); 3100 result = treeselectfunc(tmp->window, 0, (char *)pci->rc.pszIcon, tmp->data, 0);
3100 else 3101 else
3101 { 3102 {
3125 3126
3126 WinQueryClassName(tmp->window, 99, (PCH)classbuf); 3127 WinQueryClassName(tmp->window, 99, (PCH)classbuf);
3127 3128
3128 if(strncmp(classbuf, "#38", 4) == 0) 3129 if(strncmp(classbuf, "#38", 4) == 0)
3129 { 3130 {
3130 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))tmp->signalfunction; 3131 int (API * valuechangedfunc)(HWND, int, void *) = (int (API *)(HWND, int, void *))tmp->signalfunction;
3131 3132
3132 if(tmp->window == hWnd || tmp->window == notifyhwnd) 3133 if(tmp->window == hWnd || tmp->window == notifyhwnd)
3133 { 3134 {
3134 static int lastvalue = -1; 3135 static int lastvalue = -1;
3135 static HWND lasthwnd = NULLHANDLE; 3136 static HWND lasthwnd = NULLHANDLE;
3143 tmp = NULL; 3144 tmp = NULL;
3144 } 3145 }
3145 } 3146 }
3146 else 3147 else
3147 { 3148 {
3148 int (* API listboxselectfunc)(HWND, int, void *) = (int (* API )(HWND, int, void *))tmp->signalfunction; 3149 int (API * listboxselectfunc)(HWND, int, void *) = (int (API *)(HWND, int, void *))tmp->signalfunction;
3149 static int _recursing = 0; 3150 static int _recursing = 0;
3150 3151
3151 if(_recursing == 0 && (tmp->window == notifyhwnd || (!id && tmp->window == (HWND)mp2))) 3152 if(_recursing == 0 && (tmp->window == notifyhwnd || (!id && tmp->window == (HWND)mp2)))
3152 { 3153 {
3153 char buf1[500]; 3154 char buf1[500];
3181 } 3182 }
3182 } 3183 }
3183 break; 3184 break;
3184 case SLN_SLIDERTRACK: 3185 case SLN_SLIDERTRACK:
3185 { 3186 {
3186 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))tmp->signalfunction; 3187 int (API * valuechangedfunc)(HWND, int, void *) = (int (API *)(HWND, int, void *))tmp->signalfunction;
3187 3188
3188 if(origmsg == WM_CONTROL) 3189 if(origmsg == WM_CONTROL)
3189 { 3190 {
3190 /* Handle Slider control */ 3191 /* Handle Slider control */
3191 if(tmp->window == hWnd || tmp->window == notifyhwnd) 3192 if(tmp->window == hWnd || tmp->window == notifyhwnd)
3225 { 3226 {
3226 PAGESELECTNOTIFY *psn = (PAGESELECTNOTIFY *)mp2; 3227 PAGESELECTNOTIFY *psn = (PAGESELECTNOTIFY *)mp2;
3227 3228
3228 if(psn && tmp->window == psn->hwndBook) 3229 if(psn && tmp->window == psn->hwndBook)
3229 { 3230 {
3230 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))tmp->signalfunction; 3231 int (API * switchpagefunc)(HWND, unsigned long, void *) = (int (API *)(HWND, unsigned long, void *))tmp->signalfunction;
3231 3232
3232 result = switchpagefunc(tmp->window, psn->ulPageIdNew, tmp->data); 3233 result = switchpagefunc(tmp->window, psn->ulPageIdNew, tmp->data);
3233 tmp = NULL; 3234 tmp = NULL;
3234 } 3235 }
3235 } 3236 }
3339 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */ 3340 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */
3340 MRESULT EXPENTRY _wndproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 3341 MRESULT EXPENTRY _wndproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
3341 { 3342 {
3342 int result = -1; 3343 int result = -1;
3343 static int command_active = 0; 3344 static int command_active = 0;
3344 void (* API windowfunc)(PVOID) = 0L; 3345 void (API * windowfunc)(PVOID) = 0L;
3345 3346
3346 if(!command_active) 3347 if(!command_active)
3347 { 3348 {
3348 /* Make sure we don't end up in infinite recursion */ 3349 /* Make sure we don't end up in infinite recursion */
3349 command_active = 1; 3350 command_active = 1;
3489 return MRFROMSHORT(TRUE); 3490 return MRFROMSHORT(TRUE);
3490 } 3491 }
3491 } 3492 }
3492 return MRFROMSHORT(FALSE); 3493 return MRFROMSHORT(FALSE);
3493 case WM_USER: 3494 case WM_USER:
3494 windowfunc = (void (* API)(void *))mp1; 3495 windowfunc = (void (API *)(void *))mp1;
3495 3496
3496 if(windowfunc) 3497 if(windowfunc)
3497 windowfunc((void *)mp2); 3498 windowfunc((void *)mp2);
3498 break; 3499 break;
3499 case WM_CHAR: 3500 case WM_CHAR:
3896 } 3897 }
3897 break; 3898 break;
3898 case WM_USER: 3899 case WM_USER:
3899 { 3900 {
3900 SignalHandler *tmp = (SignalHandler *)mp1; 3901 SignalHandler *tmp = (SignalHandler *)mp1;
3901 int (* API clickfunc)(HWND, void *) = NULL; 3902 int (API * clickfunc)(HWND, void *) = NULL;
3902 3903
3903 if(tmp) 3904 if(tmp)
3904 { 3905 {
3905 clickfunc = (int (* API)(HWND, void *))tmp->signalfunction; 3906 clickfunc = (int (API *)(HWND, void *))tmp->signalfunction;
3906 3907
3907 clickfunc(tmp->window, tmp->data); 3908 clickfunc(tmp->window, tmp->data);
3908 } 3909 }
3909 } 3910 }
3910 break; 3911 break;
4266 * ...: Additional variables for use in the format. 4267 * ...: Additional variables for use in the format.
4267 */ 4268 */
4268 void API dw_debug(char *format, ...) 4269 void API dw_debug(char *format, ...)
4269 { 4270 {
4270 va_list args; 4271 va_list args;
4271 char outbuf[1024]; 4272 char outbuf[1025] = { 0 };
4272 4273
4273 va_start(args, format); 4274 va_start(args, format);
4275 #if defined(__IBMC__)
4274 vsprintf(outbuf, format, args); 4276 vsprintf(outbuf, format, args);
4277 #else
4278 vsnprintf(outbuf, 1024, format, args);
4279 #endif
4275 va_end(args); 4280 va_end(args);
4276 4281
4277 if(_PmPrintfString) 4282 if(_PmPrintfString)
4278 { 4283 {
4279 int len = strlen(outbuf); 4284 int len = strlen(outbuf);
4296 * ...: Additional variables for use in the format. 4301 * ...: Additional variables for use in the format.
4297 */ 4302 */
4298 int API dw_messagebox(char *title, int flags, char *format, ...) 4303 int API dw_messagebox(char *title, int flags, char *format, ...)
4299 { 4304 {
4300 va_list args; 4305 va_list args;
4301 char outbuf[1024]; 4306 char outbuf[1025] = { 0 };
4302 int rc; 4307 int rc;
4303 4308
4304 va_start(args, format); 4309 va_start(args, format);
4310 #if defined(__IBMC__)
4305 vsprintf(outbuf, format, args); 4311 vsprintf(outbuf, format, args);
4312 #else
4313 vsnprintf(outbuf, 1024, format, args);
4314 #endif
4306 va_end(args); 4315 va_end(args);
4307 4316
4308 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (PSZ)outbuf, (PSZ)title, 0, flags | MB_MOVEABLE); 4317 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (PSZ)outbuf, (PSZ)title, 0, flags | MB_MOVEABLE);
4309 if(rc == MBID_OK) 4318 if(rc == MBID_OK)
4310 return DW_MB_RETURN_OK; 4319 return DW_MB_RETURN_OK;
10090 */ 10099 */
10091 void _dwthreadstart(void *data) 10100 void _dwthreadstart(void *data)
10092 { 10101 {
10093 HAB thishab = WinInitialize(0); 10102 HAB thishab = WinInitialize(0);
10094 HMQ thishmq = WinCreateMsgQueue(dwhab, 0); 10103 HMQ thishmq = WinCreateMsgQueue(dwhab, 0);
10095 void (* API threadfunc)(void *) = NULL; 10104 void (API * threadfunc)(void *) = NULL;
10096 void **tmp = (void **)data; 10105 void **tmp = (void **)data;
10097 10106
10098 threadfunc = (void (* API)(void *))tmp[0]; 10107 threadfunc = (void (API *)(void *))tmp[0];
10099 threadfunc(tmp[1]); 10108 threadfunc(tmp[1]);
10100 10109
10101 free(tmp); 10110 free(tmp);
10102 10111
10103 WinDestroyMsgQueue(thishmq); 10112 WinDestroyMsgQueue(thishmq);