]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
warning msgs
[wxWidgets.git] / src / msw / window.cpp
index 38fb38c0ef4359ca77c7a67b06c2b839c4bffec4..7bf3b752dacb46abd877340348e537e159d8fae3 100644 (file)
@@ -621,6 +621,16 @@ void wxWindow::GetPosition(int *x, int *y) const
   {
     ::ScreenToClient(hParentWnd, &point);
   }
+
+  // We may be faking the client origin.
+  // So a window that's really at (0, 30) may appear
+  // (to wxWin apps) to be at (0, 0).
+  if (GetParent())
+  {
+    wxPoint pt(GetParent()->GetClientAreaOrigin());
+    point.x -= pt.x;
+    point.y -= pt.y;
+  }
   *x = point.x;
   *y = point.y;
 }
@@ -633,6 +643,18 @@ void wxWindow::ScreenToClient(int *x, int *y) const
   pt.y = *y;
   ::ScreenToClient(hWnd, &pt);
 
+/*
+  // We may be faking the client origin.
+  // So a window that's really at (0, 30) may appear
+  // (to wxWin apps) to be at (0, 0).
+  if (GetParent())
+  {
+    wxPoint pt1(GetParent()->GetClientAreaOrigin());
+    pt.x -= pt1.x;
+    pt.y -= pt1.y;
+  }
+*/
+
   *x = pt.x;
   *y = pt.y;
 }
@@ -643,6 +665,19 @@ void wxWindow::ClientToScreen(int *x, int *y) const
   POINT pt;
   pt.x = *x;
   pt.y = *y;
+
+/*
+  // We may be faking the client origin.
+  // So a window that's really at (0, 30) may appear
+  // (to wxWin apps) to be at (0, 0).
+  if (GetParent())
+  {
+    wxPoint pt1(GetParent()->GetClientAreaOrigin());
+    pt.x += pt1.x;
+    pt.y += pt1.y;
+  }
+*/
+
   ::ClientToScreen(hWnd, &pt);
 
   *x = pt.x;
@@ -674,7 +709,6 @@ void wxWindow::SetCursor(const wxCursor& cursor)
 
 
 // Get size *available for subwindows* i.e. excluding menu bar etc.
-// For XView, this is the same as GetSize
 void wxWindow::GetClientSize(int *x, int *y) const
 {
   HWND hWnd = (HWND) GetHWND();
@@ -697,6 +731,8 @@ void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags)
   if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
     actualY = currentY;
 
+  AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
+
   int currentW,currentH;
   GetSize(&currentW, &currentH);
   if (width == -1)
@@ -745,6 +781,24 @@ void wxWindow::SetClientSize(int width, int height)
   GetEventHandler()->ProcessEvent(event);
 }
 
+// For implementation purposes - sometimes decorations make the client area
+// smaller
+wxPoint wxWindow::GetClientAreaOrigin() const
+{
+    return wxPoint(0, 0);
+}
+
+// Makes an adjustment to the window position (for example, a frame that has
+// a toolbar that it manages itself).
+void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags)
+{
+    if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent())
+    {
+        wxPoint pt(GetParent()->GetClientAreaOrigin());
+        x += pt.x; y += pt.y;
+    }
+}
+
 bool wxWindow::Show(bool show)
 {
   HWND hWnd = (HWND) GetHWND();
@@ -1956,6 +2010,19 @@ void wxWindow::MSWDetachWindowMenu(void)
 
 bool wxWindow::MSWOnPaint(void)
 {
+#ifdef __WIN32__
+  HRGN hRegion = ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
+  ::GetUpdateRgn((HWND) GetHWND(), hRegion, FALSE);
+
+  m_updateRegion = wxRegion((WXHRGN) hRegion);
+#else
+  RECT updateRect;
+  ::GetUpdateRect((HWND) GetHWND(), & updateRect, FALSE);
+
+  m_updateRegion = wxRegion(updateRect.left, updateRect.top,
+      updateRect.right - updateRect.left, updateRect.bottom - updateRect.top);
+#endif
+
   wxPaintEvent event(m_windowId);
   event.SetEventObject(this);
   if (!GetEventHandler()->ProcessEvent(event))
@@ -2866,6 +2933,9 @@ void wxWindow::GetCaretPos(int *x, int *y) const
   *y = point.y;
 }
 
+// OBSOLETE: use GetUpdateRegion instead.
+
+#if 0
 /*
  * Update iterator. Use from within OnPaint.
  */
@@ -2952,6 +3022,7 @@ int wxUpdateIterator::GetH()
 {
   return ((RECT *)rp)[current].bottom-GetY();
 }
+#endif
 
 wxWindow *wxGetActiveWindow(void)
 {
@@ -4470,6 +4541,29 @@ bool wxWindow::AcceptsFocus() const
   return IsShown() && IsEnabled();
 }
 
+// Update region access
+wxRegion wxWindow::GetUpdateRegion() const
+{
+    return m_updateRegion;
+}
+
+bool wxWindow::IsExposed(int x, int y, int w, int h) const
+{
+    return (m_updateRegion.Contains(x, y, w, h) != wxOutRegion);
+}
+
+bool wxWindow::IsExposed(const wxPoint& pt) const
+{
+    return (m_updateRegion.Contains(pt) != wxOutRegion);
+}
+
+bool wxWindow::IsExposed(const wxRect& rect) const
+{
+    return (m_updateRegion.Contains(rect) != wxOutRegion);
+}
+
+
+
 #ifdef __WXDEBUG__
 static const char *GetMessageName(int message)
 {