Don't show wxDatePickerCtrl as being disabled when it isn't in wxOSX.

Use setDrawsBackground: to fix the background colour and adjust the text
colour whenever the control is enabled or disabled.

Closes #16807.

(this is a backport of 9bedba0bf3 from master)
This commit is contained in:
John Roberts
2015-07-18 15:15:51 +02:00
committed by Vadim Zeitlin
parent 9153da02e7
commit 3cae6b0b82
2 changed files with 24 additions and 0 deletions

View File

@@ -640,6 +640,7 @@ wxOSX:
- Fix handling of "Cancel" button in wxSearchCtrl (John Roberts).
- Generate correct events for WXK_NUMPAD_ENTER (John Roberts).
- Fix handling of WXK_NUMPAD_ENTER in wxTextCtrl (John Roberts).
- Don't show wxDatePickerCtrl as being disabled when it isn't (John Roberts).
- Generate wxEVT_TEXT_ENTER for wxTE_PASSWORD controls too (mj_smoker).
- Send wxIconizeEvent when a window is iconized/restore (Rob Krakora).
- Use correct colour for disabled wxStaticText (sbrowne).

View File

@@ -128,6 +128,26 @@ public:
}
}
virtual void Enable(bool enable = true)
{
wxNSDatePicker* const nsdatePicker = View();
[nsdatePicker setEnabled: enable];
if ( enable )
{
wxWindow* const wxpeer = GetWXPeer();
if ( wxpeer )
[nsdatePicker setTextColor: wxpeer->GetForegroundColour().OSXGetNSColor()];
else
[nsdatePicker setTextColor: [NSColor controlTextColor]];
}
else
{
[nsdatePicker setTextColor: [NSColor disabledControlTextColor]];
}
}
private:
wxNSDatePicker* View() const
{
@@ -170,6 +190,9 @@ wxDateTimeWidgetImpl::CreateDateTimePicker(wxDateTimePickerCtrl* wxpeer,
[v setDatePickerStyle: NSTextFieldAndStepperDatePickerStyle];
// Avoid a disabled looking transparent background for the text cells.
[v setDrawsBackground: YES];
if ( dt.IsValid() )
{
[v setDateValue: NSDateFromWX(dt)];