comparison os2/dw.c @ 123:63f61a702b17

Updates to use floats to save the splitbar percentage.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 20 Oct 2002 01:32:08 +0000
parents 1cad81b7cc4c
children edf615d8266e
comparison
equal deleted inserted replaced
122:a05b6fb9c545 123:63f61a702b17
2304 } 2304 }
2305 2305
2306 /* This handles any activity on the splitbars (sizers) */ 2306 /* This handles any activity on the splitbars (sizers) */
2307 MRESULT EXPENTRY _splitwndproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 2307 MRESULT EXPENTRY _splitwndproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2308 { 2308 {
2309 int percent = (int)dw_window_get_data(hwnd, "_dw_percent"); 2309 float *percent = (float *)dw_window_get_data(hwnd, "_dw_percent");
2310 int type = (int)dw_window_get_data(hwnd, "_dw_type"); 2310 int type = (int)dw_window_get_data(hwnd, "_dw_type");
2311 2311
2312 switch (msg) 2312 switch (msg)
2313 { 2313 {
2314 case WM_ACTIVATE: 2314 case WM_ACTIVATE:
2322 if(x > 0 && y > 0) 2322 if(x > 0 && y > 0)
2323 { 2323 {
2324 if(type == BOXHORZ) 2324 if(type == BOXHORZ)
2325 { 2325 {
2326 int newx = x - SPLITBAR_WIDTH, newy = y; 2326 int newx = x - SPLITBAR_WIDTH, newy = y;
2327 float ratio = (float)percent/(float)100; 2327 float ratio = (float)*percent/(float)100.0;
2328 HWND handle = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); 2328 HWND handle = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
2329 Box *tmp = WinQueryWindowPtr(handle, QWP_USER); 2329 Box *tmp = WinQueryWindowPtr(handle, QWP_USER);
2330 2330
2331 newx = (int)((float)newx * ratio); 2331 newx = (int)((float)newx * ratio);
2332 2332
2344 dw_window_set_data(hwnd, "_dw_start", (void *)newx); 2344 dw_window_set_data(hwnd, "_dw_start", (void *)newx);
2345 } 2345 }
2346 else 2346 else
2347 { 2347 {
2348 int newx = x, newy = y - SPLITBAR_WIDTH; 2348 int newx = x, newy = y - SPLITBAR_WIDTH;
2349 float ratio = (float)percent/(float)100; 2349 float ratio = (float)*percent/(float)100.0;
2350 HWND handle = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); 2350 HWND handle = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
2351 Box *tmp = WinQueryWindowPtr(handle, QWP_USER); 2351 Box *tmp = WinQueryWindowPtr(handle, QWP_USER);
2352 2352
2353 newy = (int)((float)newy * ratio); 2353 newy = (int)((float)newy * ratio);
2354 2354
6716 NULL, 6716 NULL,
6717 NULL); 6717 NULL);
6718 if(tmp) 6718 if(tmp)
6719 { 6719 {
6720 HWND tmpbox = dw_box_new(BOXVERT, 0); 6720 HWND tmpbox = dw_box_new(BOXVERT, 0);
6721 float *percent = malloc(sizeof(float));
6721 6722
6722 dw_box_pack_start(tmpbox, topleft, 1, 1, TRUE, TRUE, 0); 6723 dw_box_pack_start(tmpbox, topleft, 1, 1, TRUE, TRUE, 0);
6723 WinSetParent(tmpbox, tmp, FALSE); 6724 WinSetParent(tmpbox, tmp, FALSE);
6724 dw_window_set_data(tmp, "_dw_topleft", (void *)tmpbox); 6725 dw_window_set_data(tmp, "_dw_topleft", (void *)tmpbox);
6725 6726
6726 tmpbox = dw_box_new(BOXVERT, 0); 6727 tmpbox = dw_box_new(BOXVERT, 0);
6727 dw_box_pack_start(tmpbox, bottomright, 1, 1, TRUE, TRUE, 0); 6728 dw_box_pack_start(tmpbox, bottomright, 1, 1, TRUE, TRUE, 0);
6728 WinSetParent(tmpbox, tmp, FALSE); 6729 WinSetParent(tmpbox, tmp, FALSE);
6730 *percent = 50.0;
6729 dw_window_set_data(tmp, "_dw_bottomright", (void *)tmpbox); 6731 dw_window_set_data(tmp, "_dw_bottomright", (void *)tmpbox);
6730 dw_window_set_data(tmp, "_dw_percent", (void *)50); 6732 dw_window_set_data(tmp, "_dw_percent", (void *)percent);
6731 dw_window_set_data(tmp, "_dw_type", (void *)type); 6733 dw_window_set_data(tmp, "_dw_type", (void *)type);
6732 } 6734 }
6733 return tmp; 6735 return tmp;
6734 } 6736 }
6735 6737
6736 /* 6738 /*
6737 * Sets the position of a splitbar (pecentage). 6739 * Sets the position of a splitbar (pecentage).
6738 * Parameters: 6740 * Parameters:
6739 * handle: The handle to the splitbar returned by dw_splitbar_new(). 6741 * handle: The handle to the splitbar returned by dw_splitbar_new().
6740 */ 6742 */
6741 void dw_splitbar_set(HWND handle, int percent) 6743 void dw_splitbar_set(HWND handle, float percent)
6742 { 6744 {
6743 /* We probably need to force a redraw here */ 6745 /* We probably need to force a redraw here */
6744 dw_window_set_data(handle, "_dw_percent", (void *)percent); 6746 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
6747
6748 if(mypercent)
6749 *mypercent = percent;
6745 } 6750 }
6746 6751
6747 /* 6752 /*
6748 * Gets the position of a splitbar (pecentage). 6753 * Gets the position of a splitbar (pecentage).
6749 * Parameters: 6754 * Parameters:
6750 * handle: The handle to the splitbar returned by dw_splitbar_new(). 6755 * handle: The handle to the splitbar returned by dw_splitbar_new().
6751 */ 6756 */
6752 int dw_splitbar_get(HWND handle) 6757 float dw_splitbar_get(HWND handle)
6753 { 6758 {
6754 return (int)dw_window_get_data(handle, "_dw_percent"); 6759 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
6760
6761 if(percent)
6762 return *percent;
6763 return 0.0;
6755 } 6764 }
6756 6765
6757 /* 6766 /*
6758 * Pack windows (widgets) into a box from the start (or top). 6767 * Pack windows (widgets) into a box from the start (or top).
6759 * Parameters: 6768 * Parameters: