comparison os2/dw.c @ 561:c0a708e2cba3

Removed dw_percent_get_range() to simplify coding. The range is now always 0 to 100 no matter what platform or widget size.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 21 Apr 2004 05:33:51 +0000
parents 841445b0b457
children 1b709b879181
comparison
equal deleted inserted replaced
560:7ca86c417a58 561:c0a708e2cba3
248 if(z > 5000000) 248 if(z > 5000000)
249 return (MRESULT)failure; 249 return (MRESULT)failure;
250 dw_main_sleep(1); 250 dw_main_sleep(1);
251 } 251 }
252 return res; 252 return res;
253 }
254
255 /* Used in the slider and percent classes internally */
256 unsigned int _dw_percent_get_range(HWND handle)
257 {
258 return SHORT2FROMMP(WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0));
253 } 259 }
254 260
255 /* Return the entryfield child of a window */ 261 /* Return the entryfield child of a window */
256 HWND _find_entryfield(HWND handle) 262 HWND _find_entryfield(HWND handle)
257 { 263 {
1810 } 1816 }
1811 1817
1812 int _dw_int_pos(HWND hwnd) 1818 int _dw_int_pos(HWND hwnd)
1813 { 1819 {
1814 int pos = (int)dw_window_get_data(hwnd, "_dw_percent_value"); 1820 int pos = (int)dw_window_get_data(hwnd, "_dw_percent_value");
1815 int range = dw_percent_get_range(hwnd); 1821 int range = _dw_percent_get_range(hwnd);
1816 float fpos = (float)pos; 1822 float fpos = (float)pos;
1817 float frange = (float)range; 1823 float frange = (float)range;
1818 float fnew = (fpos/1000.0)*frange; 1824 float fnew = (fpos/1000.0)*frange;
1819 return (int)fnew; 1825 return (int)fnew;
1820 } 1826 }
1821 1827
1822 void _dw_int_set(HWND hwnd, int pos) 1828 void _dw_int_set(HWND hwnd, int pos)
1823 { 1829 {
1824 int inew, range = dw_percent_get_range(hwnd); 1830 int inew, range = _dw_percent_get_range(hwnd);
1825 if(range) 1831 if(range)
1826 { 1832 {
1827 float fpos = (float)pos; 1833 float fpos = (float)pos;
1828 float frange = (float)range; 1834 float frange = (float)range;
1829 float fnew = (fpos/frange)*1000.0; 1835 float fnew = (fpos/frange)*1000.0;
5946 { 5952 {
5947 WinSendMsg(handle, MLM_ENABLEREFRESH, 0, 0); 5953 WinSendMsg(handle, MLM_ENABLEREFRESH, 0, 0);
5948 } 5954 }
5949 5955
5950 /* 5956 /*
5951 * Returns the range of the percent bar.
5952 * Parameters:
5953 * handle: Handle to the percent bar to be queried.
5954 */
5955 unsigned int API dw_percent_get_range(HWND handle)
5956 {
5957 return SHORT2FROMMP(WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0));
5958 }
5959
5960 /*
5961 * Sets the percent bar position. 5957 * Sets the percent bar position.
5962 * Parameters: 5958 * Parameters:
5963 * handle: Handle to the percent bar to be set. 5959 * handle: Handle to the percent bar to be set.
5964 * position: Position of the percent bar withing the range. 5960 * position: Position of the percent bar withing the range.
5965 */ 5961 */
5966 void API dw_percent_set_pos(HWND handle, unsigned int position) 5962 void API dw_percent_set_pos(HWND handle, unsigned int position)
5967 { 5963 {
5968 _dw_int_set(handle, position); 5964 int range = _dw_percent_get_range(handle);
5969 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)position); 5965 int mypos = ((float)position/100)*range;
5966
5967 if(range)
5968 {
5969 _dw_int_set(handle, mypos);
5970 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)mypos);
5971 }
5970 } 5972 }
5971 5973
5972 /* 5974 /*
5973 * Returns the position of the slider. 5975 * Returns the position of the slider.
5974 * Parameters: 5976 * Parameters: