- wxWindow *parent = GetParent();
- wxButton *btnOldDefault = NULL;
- wxPanel *panel = wxDynamicCast(parent, wxPanel);
- if (panel)
- panel->SetDefaultItem(this);
+ wxWindow* pParent = GetParent();
+
+ wxCHECK_RET( pParent, _T("button without parent?") );
+
+ //
+ // Set this one as the default button both for wxWindows and Windows
+ //
+ wxWindow* pWinOldDefault = pParent->SetDefaultItem(this);
+ UpdateDefaultStyle( this
+ ,pWinOldDefault
+ );
+} // end of wxButton::SetDefault
+
+void wxButton::SetTmpDefault()
+{
+ wxWindow* pParent = GetParent();
+
+ wxCHECK_RET( pParent, _T("button without parent?") );
+
+ wxWindow* pWinOldDefault = pParent->GetDefaultItem();
+ pParent->SetTmpDefaultItem(this);
+ if (pWinOldDefault != this)
+ {
+ UpdateDefaultStyle( this
+ ,pWinOldDefault
+ );
+ }
+ //else: no styles to update
+} // end of wxButton::SetTmpDefault
+
+void wxButton::UnsetTmpDefault()
+{
+ wxWindow* pParent = GetParent();
+
+ wxCHECK_RET( pParent, _T("button without parent?") );
+
+ pParent->SetTmpDefaultItem(NULL);
+
+ wxWindow* pWinOldDefault = pParent->GetDefaultItem();
+
+ if (pWinOldDefault != this)
+ {
+ UpdateDefaultStyle( pWinOldDefault
+ ,this
+ );
+ }
+ //else: we had been default before anyhow
+} // end of wxButton::UnsetTmpDefault
+
+void wxButton::UpdateDefaultStyle(
+ wxWindow* pWinDefault
+, wxWindow* pWinOldDefault)
+{
+ wxButton* pBtnOldDefault = wxDynamicCast(pWinOldDefault, wxButton);
+ long lStyle;