Mercurial > dwindows
comparison os2/dw.c @ 1198:1ef76e93db82
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.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 28 Sep 2011 17:46:49 +0000 |
parents | cad6f7aa421c |
children | af4ca6ccbdff |
comparison
equal
deleted
inserted
replaced
1197:cad6f7aa421c | 1198:1ef76e93db82 |
---|---|
133 USHORT _GlobalID(void) | 133 USHORT _GlobalID(void) |
134 { | 134 { |
135 static USHORT GlobalID = 9999; | 135 static USHORT GlobalID = 9999; |
136 | 136 |
137 GlobalID++; | 137 GlobalID++; |
138 if(GlobalID >= 65535) | 138 if(GlobalID >= 65534) |
139 { | 139 { |
140 GlobalID = 10000; | 140 GlobalID = 10000; |
141 } | 141 } |
142 return GlobalID; | 142 return GlobalID; |
143 } | 143 } |
6722 void API dw_mle_thaw(HWND handle) | 6722 void API dw_mle_thaw(HWND handle) |
6723 { | 6723 { |
6724 WinSendMsg(handle, MLM_ENABLEREFRESH, 0, 0); | 6724 WinSendMsg(handle, MLM_ENABLEREFRESH, 0, 0); |
6725 } | 6725 } |
6726 | 6726 |
6727 /* | 6727 /* Internal version that can be called from _percentthread */ |
6728 * Sets the percent bar position. | 6728 void _dw_percent_set_pos(HWND handle, unsigned int position) |
6729 * Parameters: | |
6730 * handle: Handle to the percent bar to be set. | |
6731 * position: Position of the percent bar withing the range. | |
6732 */ | |
6733 void API dw_percent_set_pos(HWND handle, unsigned int position) | |
6734 { | 6729 { |
6735 int range = _dw_percent_get_range(handle); | 6730 int range = _dw_percent_get_range(handle); |
6736 | 6731 |
6737 /* OS/2 doesn't really support indeterminate... */ | 6732 if(range) |
6738 if(position == DW_PERCENT_INDETERMINATE) | 6733 { |
6739 { | |
6740 /* So set the position to 0 */ | |
6741 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)0); | |
6742 } | |
6743 else if(range) | |
6744 { | |
6745 /* Otherwise set the position as usual */ | |
6746 int mypos = (((float)position)/100)*range; | 6734 int mypos = (((float)position)/100)*range; |
6747 | 6735 |
6748 if(mypos >= range) | 6736 if(mypos >= range) |
6749 mypos = range - 1; | 6737 mypos = range - 1; |
6750 | 6738 |
6751 _dw_int_set(handle, mypos); | 6739 _dw_int_set(handle, mypos); |
6752 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)mypos); | 6740 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)mypos); |
6741 } | |
6742 } | |
6743 | |
6744 /* Move the percentage bar backwards to simulate indeterminate */ | |
6745 void _percentthread(void *data) | |
6746 { | |
6747 HWND percent = (HWND)data; | |
6748 | |
6749 if(percent) | |
6750 { | |
6751 HAB thishab = WinInitialize(0); | |
6752 HMQ thishmq = WinCreateMsgQueue(dwhab, 0); | |
6753 | |
6754 int pos = 100; | |
6755 | |
6756 do | |
6757 { | |
6758 pos--; | |
6759 if(pos < 1) | |
6760 pos = 100; | |
6761 _dw_percent_set_pos(percent, pos); | |
6762 DosSleep(100); | |
6763 } | |
6764 while(dw_window_get_data(percent, "_dw_ind")); | |
6765 | |
6766 WinDestroyMsgQueue(thishmq); | |
6767 WinTerminate(thishab); | |
6768 } | |
6769 } | |
6770 | |
6771 /* | |
6772 * Sets the percent bar position. | |
6773 * Parameters: | |
6774 * handle: Handle to the percent bar to be set. | |
6775 * position: Position of the percent bar withing the range. | |
6776 */ | |
6777 void API dw_percent_set_pos(HWND handle, unsigned int position) | |
6778 { | |
6779 /* OS/2 doesn't really support indeterminate... */ | |
6780 if(position == DW_PERCENT_INDETERMINATE) | |
6781 { | |
6782 if(!dw_window_get_data(handle, "_dw_ind")) | |
6783 { | |
6784 /* So we fake it with a thread */ | |
6785 dw_window_set_data(handle, "_dw_ind", (void *)1); | |
6786 _beginthread(_percentthread, NULL, 100, (void *)handle); | |
6787 } | |
6788 } | |
6789 else | |
6790 { | |
6791 /* Make sure we are no longer indeterminate */ | |
6792 dw_window_set_data(handle, "_dw_ind", NULL); | |
6793 /* Otherwise set the position as usual */ | |
6794 _dw_percent_set_pos(handle, position); | |
6753 } | 6795 } |
6754 } | 6796 } |
6755 | 6797 |
6756 /* | 6798 /* |
6757 * Returns the position of the slider. | 6799 * Returns the position of the slider. |