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:
@@ -3443,7 +3443,8 @@ Identical to \helpref{SetWindowStyleFlag}{wxwindowsetwindowstyleflag}.
|
|||||||
|
|
||||||
Sets the style of the window. Please note that some styles cannot be changed
|
Sets the style of the window. Please note that some styles cannot be changed
|
||||||
after the window creation and that \helpref{Refresh()}{wxwindowrefresh} might
|
after the window creation and that \helpref{Refresh()}{wxwindowrefresh} might
|
||||||
be called after changing the others for the change to take place immediately.
|
need to be be called after changing the others for the change to take place
|
||||||
|
immediately.
|
||||||
|
|
||||||
See \helpref{Window styles}{windowstyles} for more information about flags.
|
See \helpref{Window styles}{windowstyles} for more information about flags.
|
||||||
|
|
||||||
@@ -3523,6 +3524,23 @@ exactly the same number of times as \helpref{Freeze}{wxwindowfreeze}.
|
|||||||
\helpref{wxWindowUpdateLocker}{wxwindowupdatelocker}
|
\helpref{wxWindowUpdateLocker}{wxwindowupdatelocker}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxWindow::ToggleWindowStyle}\label{wxwindowtogglewindowstyle}
|
||||||
|
|
||||||
|
\func{void}{ToggleWindowStyle}{\param{int }{flag}}
|
||||||
|
|
||||||
|
Turns the given \arg{flag} on if it's currently turned off and vice versa.
|
||||||
|
This function cannot be used if the value of the flag is $0$ (which is often
|
||||||
|
the case for default flags).
|
||||||
|
|
||||||
|
Also, please notice that not all styles can be changed after the control
|
||||||
|
creation.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxWindow::SetWindowStyleFlag}{wxwindowsetwindowstyleflag},\rtfsp
|
||||||
|
\helpref{wxWindow::HasFlag}{wxwindowhasflag}
|
||||||
|
|
||||||
|
|
||||||
\membersection{wxWindow::TransferDataFromWindow}\label{wxwindowtransferdatafromwindow}
|
\membersection{wxWindow::TransferDataFromWindow}\label{wxwindowtransferdatafromwindow}
|
||||||
|
|
||||||
\func{virtual bool}{TransferDataFromWindow}{\void}
|
\func{virtual bool}{TransferDataFromWindow}{\void}
|
||||||
|
@@ -506,9 +506,14 @@ public:
|
|||||||
void SetWindowStyle( long style ) { SetWindowStyleFlag(style); }
|
void SetWindowStyle( long style ) { SetWindowStyleFlag(style); }
|
||||||
long GetWindowStyle() const { return GetWindowStyleFlag(); }
|
long GetWindowStyle() const { return GetWindowStyleFlag(); }
|
||||||
|
|
||||||
|
// check if the flag is set
|
||||||
bool HasFlag(int flag) const { return (m_windowStyle & flag) != 0; }
|
bool HasFlag(int flag) const { return (m_windowStyle & flag) != 0; }
|
||||||
virtual bool IsRetained() const { return HasFlag(wxRETAINED); }
|
virtual bool IsRetained() const { return HasFlag(wxRETAINED); }
|
||||||
|
|
||||||
|
// turn the flag on if it had been turned off before and vice versa,
|
||||||
|
// return true if the flag is currently turned on
|
||||||
|
bool ToggleWindowStyle(int flag);
|
||||||
|
|
||||||
// extra style: the less often used style bits which can't be set with
|
// extra style: the less often used style bits which can't be set with
|
||||||
// SetWindowStyleFlag()
|
// SetWindowStyleFlag()
|
||||||
virtual void SetExtraStyle(long exStyle) { m_exStyle = exStyle; }
|
virtual void SetExtraStyle(long exStyle) { m_exStyle = exStyle; }
|
||||||
|
@@ -274,6 +274,28 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent,
|
|||||||
return true;
|
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
|
// destruction
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -301,7 +323,7 @@ wxWindowBase::~wxWindowBase()
|
|||||||
{
|
{
|
||||||
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent((wxWindow*)this),
|
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent((wxWindow*)this),
|
||||||
wxTopLevelWindow);
|
wxTopLevelWindow);
|
||||||
|
|
||||||
if ( tlw && tlw->GetDefaultItem() == this )
|
if ( tlw && tlw->GetDefaultItem() == this )
|
||||||
tlw->SetDefaultItem(NULL);
|
tlw->SetDefaultItem(NULL);
|
||||||
if ( tlw && tlw->GetTmpDefaultItem() == this )
|
if ( tlw && tlw->GetTmpDefaultItem() == this )
|
||||||
|
Reference in New Issue
Block a user