# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1317232009 0 # Node ID 1ef76e93db820b90a0410129628da85f29c04658 # Parent cad6f7aa421cea7958e401e0bd939594f7bf0b80 Added a simulated indeterminate state on OS/2. A thread just moves the percent bar backwards in a loop. This same solution can be done for old versions of Windows which don't support indeterminate, but I am not sure if it is worth doing. Also updated the readme with these changes. diff -r cad6f7aa421c -r 1ef76e93db82 os2/dw.c --- a/os2/dw.c Wed Sep 28 16:58:42 2011 +0000 +++ b/os2/dw.c Wed Sep 28 17:46:49 2011 +0000 @@ -135,7 +135,7 @@ static USHORT GlobalID = 9999; GlobalID++; - if(GlobalID >= 65535) + if(GlobalID >= 65534) { GlobalID = 10000; } @@ -6724,6 +6724,50 @@ WinSendMsg(handle, MLM_ENABLEREFRESH, 0, 0); } +/* Internal version that can be called from _percentthread */ +void _dw_percent_set_pos(HWND handle, unsigned int position) +{ + int range = _dw_percent_get_range(handle); + + if(range) + { + int mypos = (((float)position)/100)*range; + + if(mypos >= range) + mypos = range - 1; + + _dw_int_set(handle, mypos); + WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)mypos); + } +} + +/* Move the percentage bar backwards to simulate indeterminate */ +void _percentthread(void *data) +{ + HWND percent = (HWND)data; + + if(percent) + { + HAB thishab = WinInitialize(0); + HMQ thishmq = WinCreateMsgQueue(dwhab, 0); + + int pos = 100; + + do + { + pos--; + if(pos < 1) + pos = 100; + _dw_percent_set_pos(percent, pos); + DosSleep(100); + } + while(dw_window_get_data(percent, "_dw_ind")); + + WinDestroyMsgQueue(thishmq); + WinTerminate(thishab); + } +} + /* * Sets the percent bar position. * Parameters: @@ -6732,24 +6776,22 @@ */ void API dw_percent_set_pos(HWND handle, unsigned int position) { - int range = _dw_percent_get_range(handle); - /* OS/2 doesn't really support indeterminate... */ if(position == DW_PERCENT_INDETERMINATE) { - /* So set the position to 0 */ - WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)0); - } - else if(range) - { + if(!dw_window_get_data(handle, "_dw_ind")) + { + /* So we fake it with a thread */ + dw_window_set_data(handle, "_dw_ind", (void *)1); + _beginthread(_percentthread, NULL, 100, (void *)handle); + } + } + else + { + /* Make sure we are no longer indeterminate */ + dw_window_set_data(handle, "_dw_ind", NULL); /* Otherwise set the position as usual */ - int mypos = (((float)position)/100)*range; - - if(mypos >= range) - mypos = range - 1; - - _dw_int_set(handle, mypos); - WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)mypos); + _dw_percent_set_pos(handle, position); } } diff -r cad6f7aa421c -r 1ef76e93db82 readme --- a/readme Wed Sep 28 16:58:42 2011 +0000 +++ b/readme Wed Sep 28 17:46:49 2011 +0000 @@ -47,13 +47,14 @@ Added DW_TIMEOUT_INFINITE which can now be used with dw_event_wait() in addition to dw_named_event_wait(), to block until the event is posted. Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos(). - This should work on all platforms except old versions of Windows and OS/2. + This should work on all platforms except old versions of Windows. Added the subversion revision number as the third Dynamic Windows version - number when building from a subversion source tree. + number when building from a subversion source tree. Improved container optimization on Mac, header width now taken into account. Fixes for incorrect return codes from the dw_event_* functions on Windows. Fixes for incorrect behavior on key_press callbacks on Mac and Windows. Fixes for MDI support in GTK3. +Fixes for problems with multiple sliders/percent windows in a box on OS/2. Fixes for lots of GTK3 layout and window positioning issues... although minimum size issues are still present.