git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43796
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
Sets the style of the window. Please note that some styles cannot be changed
after the window creation and that \helpref{Refresh()}{wxwindowrefresh} might
Sets the style of the window. Please note that some styles cannot be changed
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.
\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}
\func{virtual bool}{TransferDataFromWindow}{\void}
\membersection{wxWindow::TransferDataFromWindow}\label{wxwindowtransferdatafromwindow}
\func{virtual bool}{TransferDataFromWindow}{\void}
void SetWindowStyle( long style ) { SetWindowStyleFlag(style); }
long GetWindowStyle() const { return GetWindowStyleFlag(); }
void SetWindowStyle( long style ) { SetWindowStyleFlag(style); }
long GetWindowStyle() const { return GetWindowStyleFlag(); }
+ // check if the flag is set
bool HasFlag(int flag) const { return (m_windowStyle & flag) != 0; }
virtual bool IsRetained() const { return HasFlag(wxRETAINED); }
bool HasFlag(int flag) const { return (m_windowStyle & flag) != 0; }
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
// SetWindowStyleFlag()
virtual void SetExtraStyle(long exStyle) { m_exStyle = exStyle; }
// extra style: the less often used style bits which can't be set with
// SetWindowStyleFlag()
virtual void SetExtraStyle(long exStyle) { m_exStyle = exStyle; }
+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
// ----------------------------------------------------------------------------
{
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent((wxWindow*)this),
wxTopLevelWindow);
{
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent((wxWindow*)this),
wxTopLevelWindow);
if ( tlw && tlw->GetDefaultItem() == this )
tlw->SetDefaultItem(NULL);
if ( tlw && tlw->GetTmpDefaultItem() == this )
if ( tlw && tlw->GetDefaultItem() == this )
tlw->SetDefaultItem(NULL);
if ( tlw && tlw->GetTmpDefaultItem() == this )