- wxWindow *parent = GetParent();
- wxButton *btnOldDefault = NULL;
- wxPanel *panel = wxDynamicCast(parent, wxPanel);
- if (panel)
- panel->SetDefaultItem(this);
+ wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+
+ wxCHECK_RET( tlw, _T("button without top level window?") );
+
+ //
+ // Set this one as the default button both for wxWidgets and Windows
+ //
+ wxWindow* pWinOldDefault = tlw->SetDefaultItem(this);
+
+ SetDefaultStyle( wxDynamicCast(pWinOldDefault, wxButton), false);
+ SetDefaultStyle( this, true );
+} // end of wxButton::SetDefault
+
+void wxButton::SetTmpDefault()
+{
+ wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+
+ wxCHECK_RET( tlw, _T("button without top level window?") );
+
+ wxWindow* pWinOldDefault = tlw->GetDefaultItem();
+
+ tlw->SetTmpDefaultItem(this);
+ SetDefaultStyle( wxDynamicCast(pWinOldDefault, wxButton), false);
+ SetDefaultStyle( this, true );
+} // end of wxButton::SetTmpDefault
+
+void wxButton::UnsetTmpDefault()
+{
+ wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+
+ wxCHECK_RET( tlw, _T("button without top level window?") );