]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
wxIniConfig added (pre-alpha quality, many functions not implemented), some
[wxWidgets.git] / src / msw / window.cpp
index 38fb38c0ef4359ca77c7a67b06c2b839c4bffec4..e594c9b07b20f728d08ae78ce81a0680db38cb29 100644 (file)
@@ -81,7 +81,7 @@
 #endif
 
 #ifdef  __WXDEBUG__
-  static const char *GetMessageName(int message);
+const char *wxGetMessageName(int message);
 #endif  //WXDEBUG
 
 #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
@@ -252,7 +252,7 @@ wxWindow::wxWindow(void)
   m_lastMsg = 0;
   m_lastWParam = 0;
   m_lastLParam = 0;
-  m_acceleratorTable = 0;
+//  m_acceleratorTable = 0;
   m_hMenu = 0;
 
   m_xThumbSize = 0;
@@ -434,7 +434,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
   m_lastMsg = 0;
   m_lastWParam = 0;
   m_lastLParam = 0;
-  m_acceleratorTable = 0;
+//  m_acceleratorTable = 0;
   m_hMenu = 0;
 
   m_xThumbSize = 0;
@@ -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();
@@ -900,7 +954,7 @@ LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
 long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
 {
   #ifdef __WXDEBUG__
-    wxLogTrace(wxTraceMessages, "Processing %s", GetMessageName(message));
+    wxLogTrace(wxTraceMessages, "Processing %s", wxGetMessageName(message));
   #endif // WXDEBUG
 
   HWND hWnd = (HWND)m_hWnd;
@@ -1312,6 +1366,16 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
             return MSWDefWindowProc(message, wParam, lParam );
           break;
         }
+        case WM_PALETTECHANGED:
+        {
+            return MSWOnPaletteChanged((WXHWND) (HWND) wParam);
+            break;
+        }
+        case WM_QUERYNEWPALETTE:
+        {
+            return MSWOnQueryNewPalette();
+            break;
+        }
         case WM_ERASEBKGND:
         {
           // Prevents flicker when dragging
@@ -1808,7 +1872,7 @@ WXHBRUSH wxWindow::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
 bool wxWindow::MSWOnColorChange(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
 {
   wxSysColourChangedEvent event;
-  event.m_eventObject = this;
+  event.SetEventObject(this);
 
   // Check if app handles this.
   if (GetEventHandler()->ProcessEvent(event))
@@ -1818,6 +1882,27 @@ bool wxWindow::MSWOnColorChange(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WX
   return 1;
 }
 
+long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange)
+{
+    wxPaletteChangedEvent event(GetId());
+    event.SetEventObject(this);
+    event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange));
+    GetEventHandler()->ProcessEvent(event);
+    return 0;
+}
+
+long wxWindow::MSWOnQueryNewPalette()
+{
+    wxQueryNewPaletteEvent event(GetId());
+    event.SetEventObject(this);
+    if (!GetEventHandler()->ProcessEvent(event) || !event.GetPaletteRealized())
+    {
+        return (long) FALSE;
+    }
+    else
+        return (long) TRUE;
+}
+
 // Responds to colour changes: passes event on to children.
 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
 {
@@ -1853,7 +1938,7 @@ long wxWindow::Default()
 
     #ifdef __WXDEBUG__
         wxLogTrace(wxTraceMessages, "Forwarding %s to DefWindowProc.",
-                  GetMessageName(m_lastMsg));
+                  wxGetMessageName(m_lastMsg));
     #endif // WXDEBUG
 
     return this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam);
@@ -1927,6 +2012,11 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
   return FALSE;
 }
 
+bool wxWindow::MSWTranslateMessage(WXMSG* WXUNUSED(pMsg))
+{
+    return FALSE;
+}
+
 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag), WXHWND WXUNUSED(activate), WXHWND WXUNUSED(deactivate))
 {
 #if WXDEBUG > 1
@@ -1956,6 +2046,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 +2969,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 +3058,7 @@ int wxUpdateIterator::GetH()
 {
   return ((RECT *)rp)[current].bottom-GetY();
 }
+#endif
 
 wxWindow *wxGetActiveWindow(void)
 {
@@ -4470,8 +4577,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)
+const char *wxGetMessageName(int message)
 {
   switch ( message ) {
     case 0x0000: return "WM_NULL";