wxMac fix for resetting the focus to the textctrl when the combo ctrl gets it.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43709
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// event handlers
void OnSizeEvent( wxSizeEvent& event );
void OnFocusEvent(wxFocusEvent& event);
// event handlers
void OnSizeEvent( wxSizeEvent& event );
void OnFocusEvent(wxFocusEvent& event);
+ void OnIdleEvent(wxIdleEvent& event);
void OnTextCtrlEvent(wxCommandEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnKeyEvent(wxKeyEvent& event);
void OnTextCtrlEvent(wxCommandEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnKeyEvent(wxKeyEvent& event);
// is the popup window currenty shown?
wxByte m_popupWinState;
// is the popup window currenty shown?
wxByte m_popupWinState;
+ // should the focus be reset to the textctrl in idle time?
+ bool m_resetFocus;
+
// native controls work on it like normal.
#define POPUPWIN_IS_PERFECT 0 // Same, but for non-transient popup window.
#define TEXTCTRL_TEXT_CENTERED 0 // 1 if text in textctrl is vertically centered
// native controls work on it like normal.
#define POPUPWIN_IS_PERFECT 0 // Same, but for non-transient popup window.
#define TEXTCTRL_TEXT_CENTERED 0 // 1 if text in textctrl is vertically centered
+#define FOCUS_RING 0 // No focus ring on wxMSW
//#undef wxUSE_POPUPWIN
//#define wxUSE_POPUPWIN 0
//#undef wxUSE_POPUPWIN
//#define wxUSE_POPUPWIN 0
// native controls work on it like normal.
#define POPUPWIN_IS_PERFECT 1 // Same, but for non-transient popup window.
#define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
// native controls work on it like normal.
#define POPUPWIN_IS_PERFECT 1 // Same, but for non-transient popup window.
#define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
+#define FOCUS_RING 0 // No focus ring on wxGTK
// native controls work on it like normal.
#define POPUPWIN_IS_PERFECT 0 // Same, but for non-transient popup window.
#define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
// native controls work on it like normal.
#define POPUPWIN_IS_PERFECT 0 // Same, but for non-transient popup window.
#define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
+#define FOCUS_RING 3 // Reserve room for the textctrl's focus ring to display
+
+#undef DEFAULT_DROPBUTTON_WIDTH
+#define DEFAULT_DROPBUTTON_WIDTH 22
+#undef COMBO_MARGIN
+#define COMBO_MARGIN FOCUS_RING
// native controls work on it like normal.
#define POPUPWIN_IS_PERFECT 0 // Same, but for non-transient popup window.
#define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
// native controls work on it like normal.
#define POPUPWIN_IS_PERFECT 0 // Same, but for non-transient popup window.
#define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
-
-#undef DEFAULT_DROPBUTTON_WIDTH
-#define DEFAULT_DROPBUTTON_WIDTH 22
EVT_SIZE(wxComboCtrlBase::OnSizeEvent)
EVT_SET_FOCUS(wxComboCtrlBase::OnFocusEvent)
EVT_KILL_FOCUS(wxComboCtrlBase::OnFocusEvent)
EVT_SIZE(wxComboCtrlBase::OnSizeEvent)
EVT_SET_FOCUS(wxComboCtrlBase::OnFocusEvent)
EVT_KILL_FOCUS(wxComboCtrlBase::OnFocusEvent)
+ EVT_IDLE(wxComboCtrlBase::OnIdleEvent)
//EVT_BUTTON(wxID_ANY,wxComboCtrlBase::OnButtonClickEvent)
EVT_KEY_DOWN(wxComboCtrlBase::OnKeyEvent)
EVT_TEXT_ENTER(wxID_ANY,wxComboCtrlBase::OnTextCtrlEvent)
//EVT_BUTTON(wxID_ANY,wxComboCtrlBase::OnButtonClickEvent)
EVT_KEY_DOWN(wxComboCtrlBase::OnKeyEvent)
EVT_TEXT_ENTER(wxID_ANY,wxComboCtrlBase::OnTextCtrlEvent)
m_absIndent = -1;
m_iFlags = 0;
m_timeCanAcceptClick = 0;
m_absIndent = -1;
m_iFlags = 0;
m_timeCanAcceptClick = 0;
+
+ m_resetFocus = false;
}
bool wxComboCtrlBase::Create(wxWindow *parent,
}
bool wxComboCtrlBase::Create(wxWindow *parent,
void wxComboCtrlBase::OnThemeChange()
{
void wxComboCtrlBase::OnThemeChange()
{
+ // Leave the default bg on the Mac so the area used by the focus ring will
+ // be the correct colour and themed brush. Instead we'll use
+ // wxSYS_COLOUR_WINDOW in the EVT_PAINT handler as needed.
+#ifndef __WXMAC__
SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
}
wxComboCtrlBase::~wxComboCtrlBase()
}
wxComboCtrlBase::~wxComboCtrlBase()
m_btnSize.y = butHeight;
m_btnArea.x = ( m_btnSide==wxRIGHT ? sz.x - butAreaWid - btnBorder : btnBorder );
m_btnSize.y = butHeight;
m_btnArea.x = ( m_btnSide==wxRIGHT ? sz.x - butAreaWid - btnBorder : btnBorder );
- m_btnArea.y = btnBorder;
+ m_btnArea.y = btnBorder + FOCUS_RING;
m_btnArea.width = butAreaWid;
m_btnArea.width = butAreaWid;
- m_btnArea.height = sz.y - (btnBorder*2);
+ m_btnArea.height = sz.y - ((btnBorder+FOCUS_RING)*2);
- m_tcArea.x = ( m_btnSide==wxRIGHT ? 0 : butAreaWid ) + customBorder;
- m_tcArea.y = customBorder;
- m_tcArea.width = sz.x - butAreaWid - (customBorder*2);
- m_tcArea.height = sz.y - (customBorder*2);
+ m_tcArea.x = ( m_btnSide==wxRIGHT ? 0 : butAreaWid ) + customBorder + FOCUS_RING;
+ m_tcArea.y = customBorder + FOCUS_RING;
+ m_tcArea.width = sz.x - butAreaWid - (customBorder*2) - (FOCUS_RING*2);
+ m_tcArea.height = sz.y - ((customBorder+FOCUS_RING)*2);
{
// If it has border, have textctrl will the entire text field.
m_text->SetSize( m_tcArea.x + m_widthCustomPaint,
{
// If it has border, have textctrl will the entire text field.
m_text->SetSize( m_tcArea.x + m_widthCustomPaint,
- customBorder,
- sz.x - m_btnArea.width - m_widthCustomPaint - customBorder,
- sz.y-(customBorder*2) );
+ m_tcArea.y,
+ m_tcArea.width - m_widthCustomPaint,
+ m_tcArea.height );
-
- wxSize ret(sizeText.x + COMBO_MARGIN + DEFAULT_DROPBUTTON_WIDTH,
- fhei);
+ fhei += 2 * FOCUS_RING;
+ int width = sizeText.x + FOCUS_RING + COMBO_MARGIN + DEFAULT_DROPBUTTON_WIDTH;
+
+ wxSize ret(width, fhei);
CacheBestSize(ret);
return ret;
}
CacheBestSize(ret);
return ret;
}
else
{
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );
else
{
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );
+#ifndef __WXMAC__ // see note in OnThemeChange
bgCol = GetBackgroundColour();
bgCol = GetBackgroundColour();
+#else
+ bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
+#endif
}
}
else
{
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT) );
}
}
else
{
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT) );
+#ifndef __WXMAC__ // see note in OnThemeChange
bgCol = GetBackgroundColour();
bgCol = GetBackgroundColour();
+#else
+ bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
+#endif
{
if ( event.GetEventType() == wxEVT_SET_FOCUS )
{
{
if ( event.GetEventType() == wxEVT_SET_FOCUS )
{
wxWindow* tc = GetTextCtrl();
if ( tc && tc != DoFindFocus() )
wxWindow* tc = GetTextCtrl();
if ( tc && tc != DoFindFocus() )
+#ifdef __WXMAC__
+ m_resetFocus = true;
+#else
+void wxComboCtrlBase::OnIdleEvent( wxIdleEvent& WXUNUSED(event) )
+{
+ if ( m_resetFocus )
+ {
+ m_resetFocus = false;
+ wxWindow* tc = GetTextCtrl();
+ if ( tc )
+ tc->SetFocus();
+ }
+}
+
void wxComboCtrlBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
{
OnThemeChange();
void wxComboCtrlBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
{
OnThemeChange();
dc.DrawRectangle(rect2);
}
dc.DrawRectangle(rect2);
}
+#ifndef __WXMAC__ // see note in OnThemeChange
wxColour winCol = GetBackgroundColour();
wxColour winCol = GetBackgroundColour();
+#else
+ wxColour winCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
+#endif
dc.SetBrush(winCol);
dc.SetPen(winCol);
dc.SetBrush(winCol);
dc.SetPen(winCol);
// clear main background
dc.DrawRectangle(rect);
// clear main background
dc.DrawRectangle(rect);
if ( !m_btn )
{
// Standard button rendering
if ( !m_btn )
{
// Standard button rendering