Improve returning wxSYS_CARET_* metrics in wxMSW
The documentation stated that (a) wxSYS_CARET_{ON|OFF}_MSEC settings
were not supported on MSW and (b) if a setting was not supported a
negative value was returned. However, when calling
wxSystemSettings::GetMetric(wxSYS_CARET_{ON|OFF}_MSEC), not only the
method asserted but 0 was returned instead of a negative value.
Fix this by using the value returned by ::GetCaretBlinkTime() for
wxSYS_CARET_{ON|OFF}_MSEC.
The documentation for wxSYS_CARET_TIMEOUT_MSEC does not list any
platform limitations; however, attempting to obtain this value resulted
in an assert and 0 returned. Fix this by returning -1. Returning -1 may
not the be the ideal solution, but there is no value reserved for the
setting not being supported and the caret on MSW usually blinks.
Closes https://github.com/wxWidgets/wxWidgets/pull/1285
This commit is contained in:
@@ -253,7 +253,10 @@ static const int gs_metricsMap[] =
|
||||
SM_PENWINDOWS,
|
||||
SM_SHOWSOUNDS,
|
||||
SM_SWAPBUTTON,
|
||||
-1 // wxSYS_DCLICK_MSEC - not available as system metric
|
||||
-1, // wxSYS_DCLICK_MSEC - not available as system metric
|
||||
-1, // wxSYS_CARET_ON_MSEC - not available as system metric
|
||||
-1, // wxSYS_CARET_OFF_MSEC - not available as system metric
|
||||
-1 // wxSYS_CARET_TIMEOUT_MSEC - not available as system metric
|
||||
};
|
||||
|
||||
// Get a system metric, e.g. scrollbar size
|
||||
@@ -268,6 +271,25 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(w
|
||||
return ::GetDoubleClickTime();
|
||||
}
|
||||
|
||||
// return the caret blink time for both
|
||||
// wxSYS_CARET_ON_MSEC and wxSYS_CARET_OFF_MSEC
|
||||
if ( index == wxSYS_CARET_ON_MSEC || index == wxSYS_CARET_OFF_MSEC )
|
||||
{
|
||||
const UINT blinkTime = ::GetCaretBlinkTime();
|
||||
|
||||
if ( blinkTime == 0 ) // error
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( blinkTime == INFINITE ) // caret does not blink
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return blinkTime;
|
||||
}
|
||||
|
||||
int indexMSW = gs_metricsMap[index];
|
||||
if ( indexMSW == -1 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user