]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed (?) problem in region handling which caused major redraw problems.
authorStefan Neis <Stefan.Neis@t-online.de>
Sun, 6 Aug 2006 22:00:10 +0000 (22:00 +0000)
committerStefan Neis <Stefan.Neis@t-online.de>
Sun, 6 Aug 2006 22:00:10 +0000 (22:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40497 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/os2/region.h
src/os2/region.cpp
src/os2/window.cpp

index 348f24008b87ce9f62bbde16c42fd171ab0ca616..d0b54162b4759c929c4f5ec083e9d643dae3c5dc 100644 (file)
@@ -170,10 +170,9 @@ public:
     // Tests
     // Does the region contain the point (x,y)?
     //
     // Tests
     // Does the region contain the point (x,y)?
     //
-    wxRegionContain Contains( wxCoord lX
-                             ,wxCoord lY
-                            ) const;
-
+    inline wxRegionContain Contains( wxCoord lX, wxCoord lY ) const{
+        return Contains( wxPoint( lX, lY ) );
+    }
     //
     // Convert the region to a B&W bitmap with the black pixels being inside
     // the region.
     //
     // Convert the region to a B&W bitmap with the black pixels being inside
     // the region.
@@ -206,7 +205,10 @@ public:
     //
     // Does the region contain the rectangle rect?
     //
     //
     // Does the region contain the rectangle rect?
     //
-    wxRegionContain Contains(const wxRect& rRect) const;
+    inline wxRegionContain Contains(const wxRect& rRect) const{
+         return Contains( rRect.x, rRect.y,
+                          rRect.GetWidth(), rRect.GetHeight());
+    }
 
     //
     // Internal
 
     //
     // Internal
index c575c4cdc61c6082963700adad4376c7f5baaf2b..0bf37cdcc3a822797528dcb263c3422ce2c79564 100644 (file)
@@ -5,7 +5,7 @@
 // Modified by:
 // Created:   10/15/99
 // RCS-ID:    $Id$
 // Modified by:
 // Created:   10/15/99
 // RCS-ID:    $Id$
-// Copyright: (c) Davdi Webster
+// Copyright: (c) David Webster
 // Licence:   wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:   wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
@@ -86,6 +86,13 @@ public:
 // wxRegion
 //-----------------------------------------------------------------------------
 
 // wxRegion
 //-----------------------------------------------------------------------------
 
+// General remark:
+// wxRegion is always basically stored in wx coordinates. However, since
+// OS/2's internal functions rely on "top > bottom", the values of top and
+// bottom values of a region need to be interchanged, as compared to wx.
+// This needs to be taken into account when feeding any rectangle to wx _or_
+// when accessing the region data via GetBox, wxRegionIterator or otherwise.
+
 /*!
  * Create an empty region.
  */
 /*!
  * Create an empty region.
  */
@@ -162,8 +169,8 @@ wxRegion::wxRegion(
 
     vRect.xLeft   = rTopLeft.x;
     vRect.xRight  = rBottomRight.x;
 
     vRect.xLeft   = rTopLeft.x;
     vRect.xRight  = rBottomRight.x;
-    vRect.yBottom = rBottomRight.y;
-    vRect.yTop    = rTopLeft.y;
+    vRect.yBottom = rTopLeft.y;
+    vRect.yTop    = rBottomRight.y;
 
     m_refData     = new wxRegionRefData;
 
 
     m_refData     = new wxRegionRefData;
 
@@ -428,47 +435,20 @@ bool wxRegion::Empty() const
 //-----------------------------------------------------------------------------
 // Tests
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 // Tests
 //-----------------------------------------------------------------------------
-
-//
-// Does the region contain the point (x,y)?
-wxRegionContain wxRegion::Contains(
-  wxCoord                           x
-, wxCoord                           y
-) const
-{
-    POINTL                          vPoint;
-
-    vPoint.x = x;
-    vPoint.y = y;
-
-    if (!m_refData)
-        return wxOutRegion;
-
-    LONG                            lInside = ::GpiPtInRegion( ((wxRegionRefData*)m_refData)->m_hPS
-                                                              ,M_REGION
-                                                              ,&vPoint
-                                                             );
-    if (lInside == PRGN_INSIDE)
-        return wxInRegion;
-    return wxOutRegion;
-} // end of wxRegion::Contains
-
 //
 // Does the region contain the point pt?
 //
 //
 // Does the region contain the point pt?
 //
-wxRegionContain wxRegion::Contains(
-  const wxPoint&                    rPoint
-) const
+wxRegionContain wxRegion::Contains( const wxPoint& rPoint ) const
 {
     POINTL                          vPoint = { rPoint.x, rPoint.y };
 
     if (!m_refData)
         return wxOutRegion;
 
 {
     POINTL                          vPoint = { rPoint.x, rPoint.y };
 
     if (!m_refData)
         return wxOutRegion;
 
-    LONG                            lInside = ::GpiPtInRegion( ((wxRegionRefData*)m_refData)->m_hPS
-                                                              ,M_REGION
-                                                              ,&vPoint
-                                                             );
+    LONG lInside = ::GpiPtInRegion( ((wxRegionRefData*)m_refData)->m_hPS,
+                                    M_REGION,
+                                    &vPoint
+                                 );
     if (lInside == PRGN_INSIDE)
         return wxInRegion;
     else
     if (lInside == PRGN_INSIDE)
         return wxInRegion;
     else
@@ -478,56 +458,31 @@ wxRegionContain wxRegion::Contains(
 //
 // Does the region contain the rectangle (x, y, w, h)?
 //
 //
 // Does the region contain the rectangle (x, y, w, h)?
 //
-wxRegionContain wxRegion::Contains(
-  wxCoord                           x
-, wxCoord                           y
-, wxCoord                           vWidth
-, wxCoord                           vHeight
-) const
+wxRegionContain wxRegion::Contains( wxCoord x,
+                                   wxCoord y,
+                                   wxCoord vWidth,
+                                   wxCoord vHeight ) const
 {
 {
-    RECTL                           vRect;
-
     if (!m_refData)
         return wxOutRegion;
 
     if (!m_refData)
         return wxOutRegion;
 
+    RECTL   vRect;
     vRect.xLeft   = x;
     vRect.xLeft   = x;
-    vRect.yTop    = y;
     vRect.xRight  = x + vWidth;
     vRect.xRight  = x + vWidth;
-    vRect.yBottom = y + vHeight;
-
-    if (PRGN_INSIDE == ::GpiRectInRegion( ((wxRegionRefData*)m_refData)->m_hPS
-                                         ,M_REGION
-                                         ,&vRect
-                                        ))
-        return wxInRegion;
-    else
-        return wxOutRegion;
-} // end of wxRegion::Contains
-
-//
-// Does the region contain the rectangle rect
-//
-wxRegionContain wxRegion::Contains(
-  const wxRect&                     rRect
-) const
-{
-    if (!m_refData)
-        return wxOutRegion;
+    vRect.yTop    = y + vHeight;
+    vRect.yBottom = y;
 
 
-    wxCoord                         x;
-    wxCoord                         y;
-    wxCoord                         vWidth;
-    wxCoord                         vHeight;
-
-    x       = rRect.x;
-    y       = rRect.y;
-    vWidth  = rRect.GetWidth();
-    vHeight = rRect.GetHeight();
-    return Contains( x
-                    ,y
-                    ,vWidth
-                    ,vHeight
-                   );
+    LONG lInside = ::GpiRectInRegion( ((wxRegionRefData*)m_refData)->m_hPS,
+                                      M_REGION,
+                                      &vRect    
+                                    );
+    switch (lInside)
+    {
+        case RRGN_INSIDE    :   return wxInRegion;
+        case RRGN_PARTIAL   :   return wxPartRegion;
+        case RRGN_ERROR     :
+        default             :   return wxOutRegion;
+    }
 } // end of wxRegion::Contains
 
 //
 } // end of wxRegion::Contains
 
 //
index 2db19422f6d64662e5e418efe2e6d06c5cf9e17a..c41347074c7625db76600473e21fded8c855bdbb 100644 (file)
@@ -2641,6 +2641,7 @@ MRESULT wxWindowOS2::OS2WindowProc( WXUINT uMsg,
                     }
                     break;
 
                     }
                     break;
 
+                case CBN_LBSELECT:
                 case BN_CLICKED: // Dups as LN_SELECT and CBN_LBSELECT
                     {
                         HWND                hWnd = ::WinWindowFromID((HWND)GetHwnd(), SHORT1FROMMP(wParam));
                 case BN_CLICKED: // Dups as LN_SELECT and CBN_LBSELECT
                     {
                         HWND                hWnd = ::WinWindowFromID((HWND)GetHwnd(), SHORT1FROMMP(wParam));
@@ -2697,11 +2698,19 @@ MRESULT wxWindowOS2::OS2WindowProc( WXUINT uMsg,
                                                   ,(WXWORD)SHORT1FROMMP(wParam)
                                                  );
                         }
                                                   ,(WXWORD)SHORT1FROMMP(wParam)
                                                  );
                         }
+                        if (pWin->IsKindOf(CLASSINFO(wxChoice)))
+                        {
+                            wxChoice*           pChoice = wxDynamicCast(pWin, wxChoice);
+
+                            pChoice->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
+                                                ,(WXWORD)SHORT1FROMMP(wParam)
+                                               );
+                        }
                         return 0;
                     }
                     // break;
 
                         return 0;
                     }
                     // break;
 
-                case LN_ENTER:   /* dups as CBN_EFCHANGE */
+                case LN_ENTER:
                     {
                         HWND                hWnd = HWNDFROMMP(lParam);
                         wxWindowOS2*        pWin = wxFindWinFromHandle(hWnd);
                     {
                         HWND                hWnd = HWNDFROMMP(lParam);
                         wxWindowOS2*        pWin = wxFindWinFromHandle(hWnd);
@@ -3568,15 +3577,10 @@ bool wxWindowOS2::HandlePaint()
          wxLogLastError(wxT("CreateRectRgn"));
          return false;
     }
          wxLogLastError(wxT("CreateRectRgn"));
          return false;
     }
-
     // Get all the rectangles from the region, convert the individual
     // rectangles to "the other" coordinate system and reassemble a
     // region from the rectangles, to be feed into m_updateRegion.
     //
     // Get all the rectangles from the region, convert the individual
     // rectangles to "the other" coordinate system and reassemble a
     // region from the rectangles, to be feed into m_updateRegion.
     //
-    // FIXME: This is a bad hack since OS/2 API specifies that rectangles
-    //        passed into GpiSetRegion must not have Bottom > Top,
-    //        however, at first sight, it _seems_ to work nonetheless.
-    //
     RGNRECT                     vRgnData;
     PRECTL                      pUpdateRects = NULL;
     vRgnData.ulDirection = RECTDIR_LFRT_TOPBOT;
     RGNRECT                     vRgnData;
     PRECTL                      pUpdateRects = NULL;
     vRgnData.ulDirection = RECTDIR_LFRT_TOPBOT;
@@ -3606,14 +3610,13 @@ bool wxWindowOS2::HandlePaint()
             {
                 int                 rectHeight;
                 rectHeight = pUpdateRects[i].yTop - pUpdateRects[i].yBottom;
             {
                 int                 rectHeight;
                 rectHeight = pUpdateRects[i].yTop - pUpdateRects[i].yBottom;
-                pUpdateRects[i].yTop = height - pUpdateRects[i].yTop;
-                pUpdateRects[i].yBottom = pUpdateRects[i].yTop + rectHeight;
+                pUpdateRects[i].yBottom = height - pUpdateRects[i].yTop;
+                pUpdateRects[i].yTop = pUpdateRects[i].yBottom + rectHeight;
             }
             ::GpiSetRegion(hPS, hRgn, vRgnData.crc, pUpdateRects);
             delete [] pUpdateRects;
         }
     }
             }
             ::GpiSetRegion(hPS, hRgn, vRgnData.crc, pUpdateRects);
             delete [] pUpdateRects;
         }
     }
-
     m_updateRegion = wxRegion(hRgn, hPS);
 
     vEvent.SetEventObject(this);
     m_updateRegion = wxRegion(hRgn, hPS);
 
     vEvent.SetEventObject(this);