add wxGet/Set/HasWindowExStyle() helpers and use them
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54937 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -23,6 +23,10 @@
|
|||||||
|
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
|
||||||
|
#if wxUSE_GUI
|
||||||
|
#include "wx/window.h"
|
||||||
|
#endif // wxUSE_GUI
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxFont;
|
class WXDLLIMPEXP_FWD_CORE wxFont;
|
||||||
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
||||||
class WXDLLIMPEXP_FWD_CORE wxWindowBase;
|
class WXDLLIMPEXP_FWD_CORE wxWindowBase;
|
||||||
@@ -900,6 +904,21 @@ inline bool wxStyleHasBorder(long style)
|
|||||||
wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0;
|
wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline long wxGetWindowExStyle(const wxWindow *win)
|
||||||
|
{
|
||||||
|
return ::GetWindowLong(GetHwndOf(win), GWL_EXSTYLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool wxHasWindowExStyle(const wxWindow *win, long style)
|
||||||
|
{
|
||||||
|
return (wxGetWindowExStyle(win) & style) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline long wxSetWindowExStyle(const wxWindow *win, long style)
|
||||||
|
{
|
||||||
|
return ::SetWindowLong(GetHwndOf(win), GWL_EXSTYLE, style);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// functions mapping HWND to wxWindow
|
// functions mapping HWND to wxWindow
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -281,12 +281,11 @@ static void EnsureParentHasControlParentStyle(wxWindow *parent)
|
|||||||
*/
|
*/
|
||||||
while ( parent && !parent->IsTopLevel() )
|
while ( parent && !parent->IsTopLevel() )
|
||||||
{
|
{
|
||||||
LONG exStyle = ::GetWindowLong(GetHwndOf(parent), GWL_EXSTYLE);
|
LONG exStyle = wxGetWindowExStyle(parent);
|
||||||
if ( !(exStyle & WS_EX_CONTROLPARENT) )
|
if ( !(exStyle & WS_EX_CONTROLPARENT) )
|
||||||
{
|
{
|
||||||
// force the parent to have this style
|
// force the parent to have this style
|
||||||
::SetWindowLong(GetHwndOf(parent), GWL_EXSTYLE,
|
wxSetWindowExStyle(parent, exStyle | WS_EX_CONTROLPARENT);
|
||||||
exStyle | WS_EX_CONTROLPARENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parent = parent->GetParent();
|
parent = parent->GetParent();
|
||||||
@@ -1142,10 +1141,10 @@ void wxWindowMSW::SetLayoutDirection(wxLayoutDirection dir)
|
|||||||
#ifdef __WXWINCE__
|
#ifdef __WXWINCE__
|
||||||
wxUnusedVar(dir);
|
wxUnusedVar(dir);
|
||||||
#else
|
#else
|
||||||
const HWND hwnd = GetHwnd();
|
wxCHECK_RET( GetHwnd(),
|
||||||
wxCHECK_RET( hwnd, _T("layout direction must be set after window creation") );
|
_T("layout direction must be set after window creation") );
|
||||||
|
|
||||||
LONG styleOld = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
LONG styleOld = wxGetWindowExStyle(this);
|
||||||
|
|
||||||
LONG styleNew = styleOld;
|
LONG styleNew = styleOld;
|
||||||
switch ( dir )
|
switch ( dir )
|
||||||
@@ -1165,7 +1164,7 @@ void wxWindowMSW::SetLayoutDirection(wxLayoutDirection dir)
|
|||||||
|
|
||||||
if ( styleNew != styleOld )
|
if ( styleNew != styleOld )
|
||||||
{
|
{
|
||||||
::SetWindowLong(hwnd, GWL_EXSTYLE, styleNew);
|
wxSetWindowExStyle(this, styleNew);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1175,11 +1174,9 @@ wxLayoutDirection wxWindowMSW::GetLayoutDirection() const
|
|||||||
#ifdef __WXWINCE__
|
#ifdef __WXWINCE__
|
||||||
return wxLayout_Default;
|
return wxLayout_Default;
|
||||||
#else
|
#else
|
||||||
const HWND hwnd = GetHwnd();
|
wxCHECK_MSG( GetHwnd(), wxLayout_Default, _T("invalid window") );
|
||||||
wxCHECK_MSG( hwnd, wxLayout_Default, _T("invalid window") );
|
|
||||||
|
|
||||||
return ::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL
|
return wxHasWindowExStyle(this, WS_EX_LAYOUTRTL) ? wxLayout_RightToLeft
|
||||||
? wxLayout_RightToLeft
|
|
||||||
: wxLayout_LeftToRight;
|
: wxLayout_LeftToRight;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1391,14 +1388,14 @@ void wxWindowMSW::MSWUpdateStyle(long flagsOld, long exflagsOld)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// and the extended style
|
// and the extended style
|
||||||
long exstyleReal = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
|
long exstyleReal = wxGetWindowExStyle(this);
|
||||||
|
|
||||||
if ( exstyle != exstyleOld )
|
if ( exstyle != exstyleOld )
|
||||||
{
|
{
|
||||||
exstyleReal &= ~exstyleOld;
|
exstyleReal &= ~exstyleOld;
|
||||||
exstyleReal |= exstyle;
|
exstyleReal |= exstyle;
|
||||||
|
|
||||||
::SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyleReal);
|
wxSetWindowExStyle(this, exstyleReal);
|
||||||
|
|
||||||
// ex style changes don't take effect without calling SetWindowPos
|
// ex style changes don't take effect without calling SetWindowPos
|
||||||
callSWP = true;
|
callSWP = true;
|
||||||
@@ -1606,7 +1603,7 @@ bool wxWindowMSW::Reparent(wxWindowBase *parent)
|
|||||||
::SetParent(hWndChild, hWndParent);
|
::SetParent(hWndChild, hWndParent);
|
||||||
|
|
||||||
#ifndef __WXWINCE__
|
#ifndef __WXWINCE__
|
||||||
if ( ::GetWindowLong(hWndChild, GWL_EXSTYLE) & WS_EX_CONTROLPARENT )
|
if ( wxHasWindowExStyle(this, WS_EX_CONTROLPARENT) )
|
||||||
{
|
{
|
||||||
EnsureParentHasControlParentStyle(GetParent());
|
EnsureParentHasControlParentStyle(GetParent());
|
||||||
}
|
}
|
||||||
@@ -2550,8 +2547,7 @@ bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* msg)
|
|||||||
{
|
{
|
||||||
wxWindow * const win = node->GetData();
|
wxWindow * const win = node->GetData();
|
||||||
if ( win->CanAcceptFocus() &&
|
if ( win->CanAcceptFocus() &&
|
||||||
!(::GetWindowLong(GetHwndOf(win), GWL_EXSTYLE) &
|
!wxHasWindowExStyle(win, WS_EX_CONTROLPARENT) )
|
||||||
WS_EX_CONTROLPARENT) )
|
|
||||||
{
|
{
|
||||||
// it shouldn't hang...
|
// it shouldn't hang...
|
||||||
canSafelyCallIsDlgMsg = true;
|
canSafelyCallIsDlgMsg = true;
|
||||||
@@ -4267,9 +4263,9 @@ bool wxWindowMSW::HandlePower(WXWPARAM WXUNUSED_IN_WINCE(wParam),
|
|||||||
bool wxWindowMSW::IsDoubleBuffered() const
|
bool wxWindowMSW::IsDoubleBuffered() const
|
||||||
{
|
{
|
||||||
const wxWindowMSW *wnd = this;
|
const wxWindowMSW *wnd = this;
|
||||||
do {
|
do
|
||||||
long style = ::GetWindowLong(GetHwndOf(wnd), GWL_EXSTYLE);
|
{
|
||||||
if ( (style & WS_EX_COMPOSITED) != 0 )
|
if ( wxHasWindowExStyle(wnd, WS_EX_COMPOSITED) )
|
||||||
return true;
|
return true;
|
||||||
wnd = wnd->GetParent();
|
wnd = wnd->GetParent();
|
||||||
} while ( wnd && !wnd->IsTopLevel() );
|
} while ( wnd && !wnd->IsTopLevel() );
|
||||||
@@ -4280,7 +4276,7 @@ bool wxWindowMSW::IsDoubleBuffered() const
|
|||||||
void wxWindowMSW::SetDoubleBuffered(bool on)
|
void wxWindowMSW::SetDoubleBuffered(bool on)
|
||||||
{
|
{
|
||||||
// Get the current extended style bits
|
// Get the current extended style bits
|
||||||
long exstyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
|
long exstyle = wxGetWindowExStyle(this);
|
||||||
|
|
||||||
// Twiddle the bit as needed
|
// Twiddle the bit as needed
|
||||||
if ( on )
|
if ( on )
|
||||||
@@ -4289,7 +4285,7 @@ void wxWindowMSW::SetDoubleBuffered(bool on)
|
|||||||
exstyle &= ~WS_EX_COMPOSITED;
|
exstyle &= ~WS_EX_COMPOSITED;
|
||||||
|
|
||||||
// put it back
|
// put it back
|
||||||
::SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyle);
|
wxSetWindowExStyle(this, exstyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user