Mercurial > dwindows
comparison os2/dw.c @ 117:d785ee5adf02
Initial rewrite of the splitbar code on OS/2. Actually moving of the
splitbar disabled, but will be reenabled as soon as APIs are defined on
all platforms.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 19 Oct 2002 02:06:33 +0000 |
parents | bb039d7407f0 |
children | 1cad81b7cc4c |
comparison
equal
deleted
inserted
replaced
116:bb039d7407f0 | 117:d785ee5adf02 |
---|---|
69 DW_CLR_BLACK, | 69 DW_CLR_BLACK, |
70 DW_CLR_PALEGRAY, | 70 DW_CLR_PALEGRAY, |
71 DW_CLR_WHITE | 71 DW_CLR_WHITE |
72 }; | 72 }; |
73 | 73 |
74 #ifdef NO_SIGNALS | |
75 #define USE_FILTER | |
76 #else | |
77 typedef struct _sighandler | 74 typedef struct _sighandler |
78 { | 75 { |
79 struct _sighandler *next; | 76 struct _sighandler *next; |
80 ULONG message; | 77 ULONG message; |
81 HWND window; | 78 HWND window; |
118 */ | 115 */ |
119 void _new_signal(ULONG message, HWND window, void *signalfunction, void *data) | 116 void _new_signal(ULONG message, HWND window, void *signalfunction, void *data) |
120 { | 117 { |
121 SignalHandler *new = malloc(sizeof(SignalHandler)); | 118 SignalHandler *new = malloc(sizeof(SignalHandler)); |
122 | 119 |
123 #ifndef NO_SIGNALS | |
124 if(message == WM_COMMAND) | 120 if(message == WM_COMMAND) |
125 dw_signal_disconnect_by_window(window); | 121 dw_signal_disconnect_by_window(window); |
126 #endif | |
127 | 122 |
128 new->message = message; | 123 new->message = message; |
129 new->window = window; | 124 new->window = window; |
130 new->signalfunction = signalfunction; | 125 new->signalfunction = signalfunction; |
131 new->data = data; | 126 new->data = data; |
166 if(stricmp(signame, SignalTranslate[z].name) == 0) | 161 if(stricmp(signame, SignalTranslate[z].name) == 0) |
167 return SignalTranslate[z].message; | 162 return SignalTranslate[z].message; |
168 } | 163 } |
169 return 0L; | 164 return 0L; |
170 } | 165 } |
171 #endif | |
172 | 166 |
173 typedef struct _CNRITEM | 167 typedef struct _CNRITEM |
174 { | 168 { |
175 MINIRECORDCORE rc; | 169 MINIRECORDCORE rc; |
176 HPOINTER hptrIcon; | 170 HPOINTER hptrIcon; |
223 void _disconnect_windows(HWND handle) | 217 void _disconnect_windows(HWND handle) |
224 { | 218 { |
225 HENUM henum; | 219 HENUM henum; |
226 HWND child; | 220 HWND child; |
227 | 221 |
228 #ifndef NO_SIGNALS | |
229 dw_signal_disconnect_by_window(handle); | 222 dw_signal_disconnect_by_window(handle); |
230 #endif | |
231 | 223 |
232 henum = WinBeginEnumWindows(handle); | 224 henum = WinBeginEnumWindows(handle); |
233 while((child = WinGetNextWindow(henum)) != NULLHANDLE) | 225 while((child = WinGetNextWindow(henum)) != NULLHANDLE) |
234 _disconnect_windows(child); | 226 _disconnect_windows(child); |
235 | 227 |
243 { | 235 { |
244 HENUM henum; | 236 HENUM henum; |
245 HWND child; | 237 HWND child; |
246 void *ptr = (void *)WinQueryWindowPtr(handle, QWP_USER); | 238 void *ptr = (void *)WinQueryWindowPtr(handle, QWP_USER); |
247 | 239 |
248 #ifndef NO_SIGNALS | |
249 dw_signal_disconnect_by_window(handle); | 240 dw_signal_disconnect_by_window(handle); |
250 #endif | |
251 | 241 |
252 if(ptr) | 242 if(ptr) |
253 { | 243 { |
254 dw_window_set_data(handle, NULL, NULL); | 244 dw_window_set_data(handle, NULL, NULL); |
255 WinSetWindowPtr(handle, QWP_USER, 0); | 245 WinSetWindowPtr(handle, QWP_USER, 0); |
1721 handle = WinQueryWindow(handle, QW_PARENT); | 1711 handle = WinQueryWindow(handle, QW_PARENT); |
1722 } | 1712 } |
1723 return dw_screen_height(); | 1713 return dw_screen_height(); |
1724 } | 1714 } |
1725 | 1715 |
1726 #ifndef NO_SIGNALS | |
1727 MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 1716 MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
1728 { | 1717 { |
1729 int result = -1; | 1718 int result = -1; |
1730 SignalHandler *tmp = Root; | 1719 SignalHandler *tmp = Root; |
1731 ULONG origmsg = msg; | 1720 ULONG origmsg = msg; |
2100 | 2089 |
2101 } | 2090 } |
2102 | 2091 |
2103 return (MRESULT)result; | 2092 return (MRESULT)result; |
2104 } | 2093 } |
2105 #endif | |
2106 | 2094 |
2107 /* Handles control messages sent to the box (owner). */ | 2095 /* Handles control messages sent to the box (owner). */ |
2108 MRESULT EXPENTRY _controlproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 2096 MRESULT EXPENTRY _controlproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
2109 { | 2097 { |
2110 Box *blah = WinQueryWindowPtr(hWnd, QWP_USER); | 2098 Box *blah = WinQueryWindowPtr(hWnd, QWP_USER); |
2111 | 2099 |
2112 #ifndef NO_SIGNALS | |
2113 switch(msg) | 2100 switch(msg) |
2114 { | 2101 { |
2115 case WM_CONTROL: | 2102 case WM_CONTROL: |
2116 _run_event(hWnd, msg, mp1, mp2); | 2103 _run_event(hWnd, msg, mp1, mp2); |
2117 break; | 2104 break; |
2118 } | 2105 } |
2119 #endif | |
2120 | 2106 |
2121 if(blah && blah->oldproc) | 2107 if(blah && blah->oldproc) |
2122 return blah->oldproc(hWnd, msg, mp1, mp2); | 2108 return blah->oldproc(hWnd, msg, mp1, mp2); |
2123 | 2109 |
2124 return WinDefWindowProc(hWnd, msg, mp1, mp2); | 2110 return WinDefWindowProc(hWnd, msg, mp1, mp2); |
2132 void (* windowfunc)(PVOID) = 0L; | 2118 void (* windowfunc)(PVOID) = 0L; |
2133 | 2119 |
2134 if(filterfunc) | 2120 if(filterfunc) |
2135 result = filterfunc(hWnd, msg, mp1, mp2); | 2121 result = filterfunc(hWnd, msg, mp1, mp2); |
2136 | 2122 |
2137 #ifndef NO_SIGNALS | |
2138 if(result == -1 && !command_active) | 2123 if(result == -1 && !command_active) |
2139 { | 2124 { |
2140 /* Make sure we don't end up in infinite recursion */ | 2125 /* Make sure we don't end up in infinite recursion */ |
2141 command_active = 1; | 2126 command_active = 1; |
2142 | 2127 |
2143 result = (int)_run_event(hWnd, msg, mp1, mp2); | 2128 result = (int)_run_event(hWnd, msg, mp1, mp2); |
2144 | 2129 |
2145 command_active = 0; | 2130 command_active = 0; |
2146 } | 2131 } |
2147 #endif | |
2148 | 2132 |
2149 /* Now that any handlers are done... do normal processing */ | 2133 /* Now that any handlers are done... do normal processing */ |
2150 switch( msg ) | 2134 switch( msg ) |
2151 { | 2135 { |
2152 case WM_ERASEBACKGROUND: | 2136 case WM_ERASEBACKGROUND: |
2320 } | 2304 } |
2321 | 2305 |
2322 /* This handles any activity on the splitbars (sizers) */ | 2306 /* This handles any activity on the splitbars (sizers) */ |
2323 MRESULT EXPENTRY _splitwndproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 2307 MRESULT EXPENTRY _splitwndproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
2324 { | 2308 { |
2325 HWND hwndFrame = 0; | 2309 int percent = (int)dw_window_get_data(hwnd, "_dw_percent"); |
2326 Box *thisbox = 0; | 2310 int type = (int)dw_window_get_data(hwnd, "_dw_type"); |
2327 | |
2328 hwndFrame = WinQueryWindow(hwnd, QW_PARENT); | |
2329 if(hwndFrame) | |
2330 thisbox = WinQueryWindowPtr(hwndFrame, QWL_USER); | |
2331 | 2311 |
2332 switch (msg) | 2312 switch (msg) |
2333 { | 2313 { |
2334 case WM_ACTIVATE: | 2314 case WM_ACTIVATE: |
2335 case WM_SETFOCUS: | 2315 case WM_SETFOCUS: |
2336 return (MRESULT)(FALSE); | 2316 return (MRESULT)(FALSE); |
2337 | 2317 |
2318 case WM_SIZE: | |
2319 { | |
2320 int x = SHORT1FROMMP(mp2), y = SHORT2FROMMP(mp2); | |
2321 | |
2322 if(x > 0 && y > 0) | |
2323 { | |
2324 if(type == BOXHORZ) | |
2325 { | |
2326 int newx = x - SPLITBAR_WIDTH, newy = y; | |
2327 float ratio = (float)percent/(float)100; | |
2328 HWND handle = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); | |
2329 Box *tmp = WinQueryWindowPtr(handle, QWP_USER); | |
2330 | |
2331 newx = (int)((float)newx * ratio); | |
2332 | |
2333 WinSetWindowPos(handle, NULLHANDLE, 0, 0, newx, y, SWP_MOVE | SWP_SIZE | SWP_SHOW); | |
2334 _do_resize(tmp, newx, y); | |
2335 | |
2336 handle = (HWND)dw_window_get_data(hwnd, "_dw_bottomright"); | |
2337 tmp = WinQueryWindowPtr(handle, QWP_USER); | |
2338 | |
2339 newx = x - newx - SPLITBAR_WIDTH; | |
2340 | |
2341 WinSetWindowPos(handle, NULLHANDLE, x - newx, 0, newx, y, SWP_MOVE | SWP_SIZE | SWP_SHOW); | |
2342 _do_resize(tmp, newx, y); | |
2343 | |
2344 dw_window_set_data(hwnd, "_dw_start", (void *)newx); | |
2345 } | |
2346 else | |
2347 { | |
2348 int newx = x, newy = y - SPLITBAR_WIDTH; | |
2349 float ratio = (float)percent/(float)100; | |
2350 HWND handle = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); | |
2351 Box *tmp = WinQueryWindowPtr(handle, QWP_USER); | |
2352 | |
2353 newy = (int)((float)newy * ratio); | |
2354 | |
2355 WinSetWindowPos(handle, NULLHANDLE, 0, y - newy, x, newy, SWP_MOVE | SWP_SIZE | SWP_SHOW); | |
2356 _do_resize(tmp, x, newy); | |
2357 | |
2358 handle = (HWND)dw_window_get_data(hwnd, "_dw_bottomright"); | |
2359 tmp = WinQueryWindowPtr(handle, QWP_USER); | |
2360 | |
2361 newy = y - newy - SPLITBAR_WIDTH; | |
2362 | |
2363 WinSetWindowPos(handle, NULLHANDLE, 0, 0, x, newy, SWP_MOVE | SWP_SIZE | SWP_SHOW); | |
2364 _do_resize(tmp, x, newy); | |
2365 | |
2366 dw_window_set_data(hwnd, "_dw_start", (void *)newy); | |
2367 } | |
2368 } | |
2369 } | |
2370 break; | |
2338 case WM_PAINT: | 2371 case WM_PAINT: |
2339 { | 2372 { |
2340 HPS hpsPaint; | 2373 HPS hpsPaint; |
2341 RECTL rclPaint; | 2374 RECTL rclPaint; |
2342 POINTL ptlStart[SPLITBAR_WIDTH]; | 2375 POINTL ptlStart[SPLITBAR_WIDTH]; |
2343 POINTL ptlEnd[SPLITBAR_WIDTH]; | 2376 POINTL ptlEnd[SPLITBAR_WIDTH]; |
2344 USHORT i; | 2377 USHORT i; |
2378 int start = (int)dw_window_get_data(hwnd, "_dw_start"); | |
2345 | 2379 |
2346 hpsPaint = WinBeginPaint(hwnd, 0, 0); | 2380 hpsPaint = WinBeginPaint(hwnd, 0, 0); |
2347 WinQueryWindowRect(hwnd, &rclPaint); | 2381 WinQueryWindowRect(hwnd, &rclPaint); |
2348 | 2382 |
2349 if(thisbox->type == BOXHORZ) | 2383 if(type == BOXHORZ) |
2350 { | 2384 { |
2351 for(i = 0; i < SPLITBAR_WIDTH; i++) | 2385 for(i = 0; i < SPLITBAR_WIDTH; i++) |
2352 { | 2386 { |
2353 ptlStart[i].x = rclPaint.xLeft + i; | 2387 ptlStart[i].x = rclPaint.xLeft + i + start; |
2354 ptlStart[i].y = rclPaint.yTop; | 2388 ptlStart[i].y = rclPaint.yTop; |
2355 | 2389 |
2356 ptlEnd[i].x = rclPaint.xLeft + i; | 2390 ptlEnd[i].x = rclPaint.xLeft + i + start; |
2357 ptlEnd[i].y = rclPaint.yBottom; | 2391 ptlEnd[i].y = rclPaint.yBottom; |
2358 } | 2392 } |
2359 } | 2393 } |
2360 else | 2394 else |
2361 { | 2395 { |
2362 for(i = 0; i < SPLITBAR_WIDTH; i++) | 2396 for(i = 0; i < SPLITBAR_WIDTH; i++) |
2363 { | 2397 { |
2364 ptlStart[i].x = rclPaint.xLeft; | 2398 ptlStart[i].x = rclPaint.xLeft; |
2365 ptlStart[i].y = rclPaint.yBottom + i; | 2399 ptlStart[i].y = rclPaint.yBottom + i + start; |
2366 | 2400 |
2367 ptlEnd[i].x = rclPaint.xRight; | 2401 ptlEnd[i].x = rclPaint.xRight; |
2368 ptlEnd[i].y = rclPaint.yBottom + i; | 2402 ptlEnd[i].y = rclPaint.yBottom + i + start; |
2369 } | 2403 } |
2370 } | 2404 } |
2371 | 2405 |
2372 for(i = 0; i < SPLITBAR_WIDTH; i++) | 2406 for(i = 0; i < SPLITBAR_WIDTH; i++) |
2373 { | 2407 { |
2379 } | 2413 } |
2380 return MRFROMSHORT(FALSE); | 2414 return MRFROMSHORT(FALSE); |
2381 | 2415 |
2382 case WM_MOUSEMOVE: | 2416 case WM_MOUSEMOVE: |
2383 { | 2417 { |
2384 if(thisbox->type == BOXHORZ) | 2418 if(type == BOXHORZ) |
2385 WinSetPointer(HWND_DESKTOP, | 2419 WinSetPointer(HWND_DESKTOP, |
2386 WinQuerySysPointer(HWND_DESKTOP, | 2420 WinQuerySysPointer(HWND_DESKTOP, |
2387 SPTR_SIZEWE, | 2421 SPTR_SIZEWE, |
2388 FALSE)); | 2422 FALSE)); |
2389 else | 2423 else |
2393 FALSE)); | 2427 FALSE)); |
2394 } | 2428 } |
2395 return MRFROMSHORT(FALSE); | 2429 return MRFROMSHORT(FALSE); |
2396 case WM_BUTTON1DOWN: | 2430 case WM_BUTTON1DOWN: |
2397 { | 2431 { |
2432 #if 0 | |
2398 APIRET rc; | 2433 APIRET rc; |
2399 RECTL rclFrame; | 2434 RECTL rclFrame; |
2400 RECTL rclBounds; | 2435 RECTL rclBounds; |
2401 RECTL rclStart; | 2436 RECTL rclStart; |
2402 USHORT startSize, orig, actual; | 2437 USHORT startSize, orig, actual; |
2541 } | 2576 } |
2542 } | 2577 } |
2543 | 2578 |
2544 _ResetWindow(WinQueryWindow(hwnd, QW_OWNER)); | 2579 _ResetWindow(WinQueryWindow(hwnd, QW_OWNER)); |
2545 } | 2580 } |
2581 #endif | |
2546 } | 2582 } |
2547 return MRFROMSHORT(FALSE); | 2583 return MRFROMSHORT(FALSE); |
2548 } | 2584 } |
2549 return WinDefWindowProc(hwnd, msg, mp1, mp2); | 2585 return WinDefWindowProc(hwnd, msg, mp1, mp2); |
2550 } | 2586 } |
2619 | 2655 |
2620 oldproc = bubble->pOldProc; | 2656 oldproc = bubble->pOldProc; |
2621 | 2657 |
2622 switch(msg) | 2658 switch(msg) |
2623 { | 2659 { |
2624 #ifndef NO_SIGNALS | |
2625 case WM_SETFOCUS: | 2660 case WM_SETFOCUS: |
2626 if(mp2) | 2661 if(mp2) |
2627 _run_event(hwnd, msg, mp1, mp2); | 2662 _run_event(hwnd, msg, mp1, mp2); |
2628 else | 2663 else |
2629 WinSendMsg(hwnd, BM_SETDEFAULT, 0, 0); | 2664 WinSendMsg(hwnd, BM_SETDEFAULT, 0, 0); |
2669 | 2704 |
2670 clickfunc(tmp->window, tmp->data); | 2705 clickfunc(tmp->window, tmp->data); |
2671 } | 2706 } |
2672 } | 2707 } |
2673 break; | 2708 break; |
2674 #endif | |
2675 case WM_CHAR: | 2709 case WM_CHAR: |
2676 { | 2710 { |
2677 #ifndef NO_SIGNALS | |
2678 /* A button press should also occur for an ENTER or SPACE press | 2711 /* A button press should also occur for an ENTER or SPACE press |
2679 * while the button has the active input focus. | 2712 * while the button has the active input focus. |
2680 */ | 2713 */ |
2681 if(SHORT1FROMMP(mp2) == '\r' || SHORT1FROMMP(mp2) == ' ') | 2714 if(SHORT1FROMMP(mp2) == '\r' || SHORT1FROMMP(mp2) == ' ') |
2682 { | 2715 { |
2696 } | 2729 } |
2697 if(tmp) | 2730 if(tmp) |
2698 tmp= tmp->next; | 2731 tmp= tmp->next; |
2699 } | 2732 } |
2700 } | 2733 } |
2701 #endif | |
2702 if(SHORT1FROMMP(mp2) == '\t') | 2734 if(SHORT1FROMMP(mp2) == '\t') |
2703 { | 2735 { |
2704 if(CHARMSG(&msg)->fs & KC_SHIFT) | 2736 if(CHARMSG(&msg)->fs & KC_SHIFT) |
2705 _shift_focus_back(hwnd); | 2737 _shift_focus_back(hwnd); |
2706 else | 2738 else |
2817 } | 2849 } |
2818 | 2850 |
2819 MRESULT EXPENTRY _RendProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 2851 MRESULT EXPENTRY _RendProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
2820 { | 2852 { |
2821 int res = 0; | 2853 int res = 0; |
2822 #ifndef NO_SIGNALS | |
2823 res = (int)_run_event(hwnd, msg, mp1, mp2); | 2854 res = (int)_run_event(hwnd, msg, mp1, mp2); |
2824 #endif | |
2825 switch(msg) | 2855 switch(msg) |
2826 { | 2856 { |
2827 case WM_BUTTON1DOWN: | 2857 case WM_BUTTON1DOWN: |
2828 case WM_BUTTON2DOWN: | 2858 case WM_BUTTON2DOWN: |
2829 case WM_BUTTON3DOWN: | 2859 case WM_BUTTON3DOWN: |
2856 return FALSE; | 2886 return FALSE; |
2857 } | 2887 } |
2858 break; | 2888 break; |
2859 } | 2889 } |
2860 | 2890 |
2861 #ifndef NO_SIGNALS | |
2862 _run_event(hwnd, msg, mp1, mp2); | 2891 _run_event(hwnd, msg, mp1, mp2); |
2863 #endif | 2892 |
2864 if(oldproc) | 2893 if(oldproc) |
2865 return oldproc(hwnd, msg, mp1, mp2); | 2894 return oldproc(hwnd, msg, mp1, mp2); |
2866 | 2895 |
2867 return WinDefWindowProc(hwnd, msg, mp1, mp2); | 2896 return WinDefWindowProc(hwnd, msg, mp1, mp2); |
2868 } | 2897 } |
6658 { | 6687 { |
6659 /* In case we are in a signal handler, don't | 6688 /* In case we are in a signal handler, don't |
6660 * try to free memory that could possibly be | 6689 * try to free memory that could possibly be |
6661 * free()'d by the runtime already. | 6690 * free()'d by the runtime already. |
6662 */ | 6691 */ |
6663 #ifndef NO_SIGNALS | |
6664 Root = NULL; | 6692 Root = NULL; |
6665 #endif | 6693 |
6666 exit(exitcode); | 6694 exit(exitcode); |
6667 } | 6695 } |
6668 | 6696 |
6669 /* | 6697 /* |
6670 * Pack a splitbar (sizer) into the specified box from the start. | 6698 * Creates a splitbar window (widget) with given parameters. |
6671 * Parameters: | 6699 * Parameters: |
6672 * box: Window handle of the box to be packed into. | 6700 * type: Value can be BOXVERT or BOXHORZ. |
6673 */ | 6701 * topleft: Handle to the window to be top or left. |
6674 void dw_box_pack_splitbar_start(HWND box) | 6702 * bottomright: Handle to the window to be bottom or right. |
6675 { | 6703 * Returns: |
6676 Box *thisbox; | 6704 * A handle to a splitbar window or NULL on failure. |
6677 | 6705 */ |
6678 if(WinWindowFromID(box, FID_CLIENT)) | 6706 HWND dw_splitbar_new(int type, HWND topleft, HWND bottomright) |
6679 { | 6707 { |
6680 box = WinWindowFromID(box, FID_CLIENT); | 6708 HWND tmp = WinCreateWindow(HWND_OBJECT, |
6681 thisbox = WinQueryWindowPtr(box, QWP_USER); | 6709 SplitbarClassName, |
6682 } | 6710 NULL, |
6683 else | 6711 WS_VISIBLE, |
6684 thisbox = WinQueryWindowPtr(box, QWP_USER); | 6712 0,0,2000,1000, |
6685 if(thisbox) | 6713 NULLHANDLE, |
6686 { | 6714 HWND_TOP, |
6687 HWND tmp = WinCreateWindow(HWND_OBJECT, | 6715 0L, |
6688 SplitbarClassName, | 6716 NULL, |
6689 NULL, | 6717 NULL); |
6690 WS_VISIBLE, | 6718 if(tmp) |
6691 0,0,2000,1000, | 6719 { |
6692 NULLHANDLE, | 6720 HWND tmpbox = dw_box_new(BOXVERT, 0); |
6693 HWND_TOP, | 6721 |
6694 0L, | 6722 dw_box_pack_start(tmpbox, topleft, 1, 1, TRUE, TRUE, 0); |
6695 NULL, | 6723 WinSetParent(tmpbox, tmp, FALSE); |
6696 NULL); | 6724 dw_window_set_data(tmp, "_dw_topleft", (void *)tmpbox); |
6697 if(thisbox->type == BOXVERT) | 6725 |
6698 dw_box_pack_start(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0); | 6726 tmpbox = dw_box_new(BOXVERT, 0); |
6699 else | 6727 dw_box_pack_start(tmpbox, bottomright, 1, 1, TRUE, TRUE, 0); |
6700 dw_box_pack_start(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0); | 6728 WinSetParent(tmpbox, tmp, FALSE); |
6701 | 6729 dw_window_set_data(tmp, "_dw_bottomright", (void *)tmpbox); |
6702 } | 6730 dw_window_set_data(tmp, "_dw_percent", (void *)50); |
6703 } | 6731 dw_window_set_data(tmp, "_dw_type", (void *)type); |
6704 | 6732 } |
6705 /* | 6733 return tmp; |
6706 * Pack a splitbar (sizer) into the specified box from the end. | 6734 } |
6707 * Parameters: | 6735 |
6708 * box: Window handle of the box to be packed into. | 6736 /* |
6709 */ | 6737 * Sets the position of a splitbar (pecentage). |
6710 void dw_box_pack_splitbar_end(HWND box) | 6738 * Parameters: |
6711 { | 6739 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
6712 Box *thisbox; | 6740 */ |
6713 | 6741 void dw_splitbar_set(HWND handle, int percent) |
6714 if(WinWindowFromID(box, FID_CLIENT)) | 6742 { |
6715 { | 6743 /* We probably need to force a redraw here */ |
6716 box = WinWindowFromID(box, FID_CLIENT); | 6744 dw_window_set_data(handle, "_dw_percent", (void *)percent); |
6717 thisbox = WinQueryWindowPtr(box, QWP_USER); | 6745 } |
6718 } | 6746 |
6719 else | 6747 /* |
6720 thisbox = WinQueryWindowPtr(box, QWP_USER); | 6748 * Gets the position of a splitbar (pecentage). |
6721 if(thisbox) | 6749 * Parameters: |
6722 { | 6750 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
6723 HWND tmp = WinCreateWindow(HWND_OBJECT, | 6751 */ |
6724 SplitbarClassName, | 6752 int dw_splitbar_get(HWND handle) |
6725 NULL, | 6753 { |
6726 WS_VISIBLE, | 6754 return (int)dw_window_get_data(handle, "_dw_percent"); |
6727 0,0,2000,1000, | |
6728 NULLHANDLE, | |
6729 HWND_TOP, | |
6730 0L, | |
6731 NULL, | |
6732 NULL); | |
6733 if(thisbox->type == BOXVERT) | |
6734 dw_box_pack_end(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0); | |
6735 else | |
6736 dw_box_pack_end(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0); | |
6737 | |
6738 } | |
6739 } | 6755 } |
6740 | 6756 |
6741 /* | 6757 /* |
6742 * Pack windows (widgets) into a box from the start (or top). | 6758 * Pack windows (widgets) into a box from the start (or top). |
6743 * Parameters: | 6759 * Parameters: |
7244 */ | 7260 */ |
7245 void dw_window_set_data(HWND window, char *dataname, void *data) | 7261 void dw_window_set_data(HWND window, char *dataname, void *data) |
7246 { | 7262 { |
7247 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER); | 7263 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER); |
7248 | 7264 |
7249 if(blah) | 7265 if(!blah) |
7250 { | 7266 { |
7251 if(data) | 7267 blah = calloc(1, sizeof(WindowData)); |
7252 new_userdata(&(blah->root), dataname, data); | 7268 WinSetWindowPtr(window, QWP_USER, blah); |
7269 } | |
7270 | |
7271 if(data) | |
7272 new_userdata(&(blah->root), dataname, data); | |
7273 else | |
7274 { | |
7275 if(dataname) | |
7276 remove_userdata(&(blah->root), dataname, FALSE); | |
7253 else | 7277 else |
7254 { | 7278 remove_userdata(&(blah->root), NULL, TRUE); |
7255 if(dataname) | |
7256 remove_userdata(&(blah->root), dataname, FALSE); | |
7257 else | |
7258 remove_userdata(&(blah->root), NULL, TRUE); | |
7259 } | |
7260 } | 7279 } |
7261 } | 7280 } |
7262 | 7281 |
7263 /* | 7282 /* |
7264 * Gets a named user data item to a window handle. | 7283 * Gets a named user data item to a window handle. |
7278 return ud->data; | 7297 return ud->data; |
7279 } | 7298 } |
7280 return NULL; | 7299 return NULL; |
7281 } | 7300 } |
7282 | 7301 |
7283 #ifndef NO_SIGNALS | |
7284 /* | 7302 /* |
7285 * Add a callback to a window event. | 7303 * Add a callback to a window event. |
7286 * Parameters: | 7304 * Parameters: |
7287 * window: Window handle of signal to be called back. | 7305 * window: Window handle of signal to be called back. |
7288 * signame: A string pointer identifying which signal to be hooked. | 7306 * signame: A string pointer identifying which signal to be hooked. |
7419 prev = tmp; | 7437 prev = tmp; |
7420 tmp = tmp->next; | 7438 tmp = tmp->next; |
7421 } | 7439 } |
7422 } | 7440 } |
7423 } | 7441 } |
7424 #endif | |
7425 | 7442 |
7426 #ifdef TEST | 7443 #ifdef TEST |
7427 HWND mainwindow, | 7444 HWND mainwindow, |
7428 listbox, | 7445 listbox, |
7429 okbutton, | 7446 okbutton, |