added a small helper ToggleWindowStyle() function

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43796 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-12-04 11:10:59 +00:00
parent 9ec927f89b
commit d63312a977
3 changed files with 47 additions and 2 deletions

View File

@@ -274,6 +274,28 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent,
return true;
}
bool wxWindowBase::ToggleWindowStyle(int flag)
{
wxASSERT_MSG( flag, _T("flags with 0 value can't be toggled") );
bool rc;
long style = GetWindowStyleFlag();
if ( style & flag )
{
style &= ~flag;
rc = false;
}
else // currently off
{
style |= flag;
rc = true;
}
SetWindowStyleFlag(style);
return rc;
}
// ----------------------------------------------------------------------------
// destruction
// ----------------------------------------------------------------------------
@@ -301,7 +323,7 @@ wxWindowBase::~wxWindowBase()
{
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent((wxWindow*)this),
wxTopLevelWindow);
if ( tlw && tlw->GetDefaultItem() == this )
tlw->SetDefaultItem(NULL);
if ( tlw && tlw->GetTmpDefaultItem() == this )