]> git.saurik.com Git - wxWidgets.git/commitdiff
add wxGet/Set/HasWindowExStyle() helpers and use them
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 2 Aug 2008 22:30:05 +0000 (22:30 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 2 Aug 2008 22:30:05 +0000 (22:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54937 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/private.h
src/msw/window.cpp

index 28ad14f14209b2df568c9ca61985c8384c307fd9..0c5c99ed2c409110020fcb198dad75f626c8b191 100644 (file)
 
 #include "wx/log.h"
 
+#if wxUSE_GUI
+    #include "wx/window.h"
+#endif // wxUSE_GUI
+
 class WXDLLIMPEXP_FWD_CORE wxFont;
 class WXDLLIMPEXP_FWD_CORE wxWindow;
 class WXDLLIMPEXP_FWD_CORE wxWindowBase;
@@ -900,6 +904,21 @@ inline bool wxStyleHasBorder(long style)
                      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
 // ----------------------------------------------------------------------------
index b5cd8d1f6f8316d78be6e684c8341331111f4ba1..7a81ded775d3a494a077a7c5d581211b2019e1cb 100644 (file)
@@ -281,12 +281,11 @@ static void EnsureParentHasControlParentStyle(wxWindow *parent)
      */
     while ( parent && !parent->IsTopLevel() )
     {
-        LONG exStyle = ::GetWindowLong(GetHwndOf(parent), GWL_EXSTYLE);
+        LONG exStyle = wxGetWindowExStyle(parent);
         if ( !(exStyle & WS_EX_CONTROLPARENT) )
         {
             // force the parent to have this style
-            ::SetWindowLong(GetHwndOf(parent), GWL_EXSTYLE,
-                            exStyle | WS_EX_CONTROLPARENT);
+            wxSetWindowExStyle(parent, exStyle | WS_EX_CONTROLPARENT);
         }
 
         parent = parent->GetParent();
@@ -1142,10 +1141,10 @@ void wxWindowMSW::SetLayoutDirection(wxLayoutDirection dir)
 #ifdef __WXWINCE__
     wxUnusedVar(dir);
 #else
-    const HWND hwnd = GetHwnd();
-    wxCHECK_RET( hwnd, _T("layout direction must be set after window creation") );
+    wxCHECK_RET( GetHwnd(),
+                 _T("layout direction must be set after window creation") );
 
-    LONG styleOld = ::GetWindowLong(hwnd, GWL_EXSTYLE);
+    LONG styleOld = wxGetWindowExStyle(this);
 
     LONG styleNew = styleOld;
     switch ( dir )
@@ -1165,7 +1164,7 @@ void wxWindowMSW::SetLayoutDirection(wxLayoutDirection dir)
 
     if ( styleNew != styleOld )
     {
-        ::SetWindowLong(hwnd, GWL_EXSTYLE, styleNew);
+        wxSetWindowExStyle(this, styleNew);
     }
 #endif
 }
@@ -1175,12 +1174,10 @@ wxLayoutDirection wxWindowMSW::GetLayoutDirection() const
 #ifdef __WXWINCE__
     return wxLayout_Default;
 #else
-    const HWND hwnd = GetHwnd();
-    wxCHECK_MSG( hwnd, wxLayout_Default, _T("invalid window") );
+    wxCHECK_MSG( GetHwnd(), wxLayout_Default, _T("invalid window") );
 
-    return ::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL
-                ? wxLayout_RightToLeft
-                : wxLayout_LeftToRight;
+    return wxHasWindowExStyle(this, WS_EX_LAYOUTRTL) ? wxLayout_RightToLeft
+                                                     : wxLayout_LeftToRight;
 #endif
 }
 
@@ -1391,14 +1388,14 @@ void wxWindowMSW::MSWUpdateStyle(long flagsOld, long exflagsOld)
     }
 
     // and the extended style
-    long exstyleReal = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
+    long exstyleReal = wxGetWindowExStyle(this);
 
     if ( exstyle != exstyleOld )
     {
         exstyleReal &= ~exstyleOld;
         exstyleReal |= exstyle;
 
-        ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyleReal);
+        wxSetWindowExStyle(this, exstyleReal);
 
         // ex style changes don't take effect without calling SetWindowPos
         callSWP = true;
@@ -1606,7 +1603,7 @@ bool wxWindowMSW::Reparent(wxWindowBase *parent)
     ::SetParent(hWndChild, hWndParent);
 
 #ifndef __WXWINCE__
-    if ( ::GetWindowLong(hWndChild, GWL_EXSTYLE) & WS_EX_CONTROLPARENT )
+    if ( wxHasWindowExStyle(this, WS_EX_CONTROLPARENT) )
     {
         EnsureParentHasControlParentStyle(GetParent());
     }
@@ -2550,8 +2547,7 @@ bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* msg)
         {
             wxWindow * const win = node->GetData();
             if ( win->CanAcceptFocus() &&
-                    !(::GetWindowLong(GetHwndOf(win), GWL_EXSTYLE) &
-                        WS_EX_CONTROLPARENT) )
+                    !wxHasWindowExStyle(win, WS_EX_CONTROLPARENT) )
             {
                 // it shouldn't hang...
                 canSafelyCallIsDlgMsg = true;
@@ -4267,20 +4263,20 @@ bool wxWindowMSW::HandlePower(WXWPARAM WXUNUSED_IN_WINCE(wParam),
 bool wxWindowMSW::IsDoubleBuffered() const
 {
     const wxWindowMSW *wnd = this;
-    do {
-        long style = ::GetWindowLong(GetHwndOf(wnd), GWL_EXSTYLE);
-        if ( (style & WS_EX_COMPOSITED) != 0 )
+    do
+    {
+        if ( wxHasWindowExStyle(wnd, WS_EX_COMPOSITED) )
             return true;
         wnd = wnd->GetParent();
     } while ( wnd && !wnd->IsTopLevel() );
-        
+
     return false;
 }
 
 void wxWindowMSW::SetDoubleBuffered(bool on)
 {
     // Get the current extended style bits
-    long exstyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
+    long exstyle = wxGetWindowExStyle(this);
 
     // Twiddle the bit as needed
     if ( on )
@@ -4289,7 +4285,7 @@ void wxWindowMSW::SetDoubleBuffered(bool on)
         exstyle &= ~WS_EX_COMPOSITED;
 
     // put it back
-    ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyle);
+    wxSetWindowExStyle(this, exstyle);
 }
 
 // ---------------------------------------------------------------------------