]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/window.cpp
removed conditional for Apple DevTools now that mac headers are not included
[wxWidgets.git] / src / mac / window.cpp
index 0917200b8acfc9d65bebed6001d4b819b1fec0c2..bd38b3ccd2c29ee7dc2fde22c389778a3908f33d 100644 (file)
@@ -120,10 +120,6 @@ void wxWindowMac::Init()
 
     m_hScrollBar = NULL ;
     m_vScrollBar = NULL ;
-
-#if  wxUSE_DRAG_AND_DROP
-  m_pDropTarget = NULL;
-#endif
 }
 
 // Destructor
@@ -209,7 +205,7 @@ void wxWindowMac::SetFocus()
             wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
             if ( control && control->GetMacControl() )
             {
-                UMASetKeyboardFocus( gFocusWindow->MacGetRootWindow() , control->GetMacControl()  , kControlFocusNoPart ) ;
+                UMASetKeyboardFocus( (WindowRef) gFocusWindow->MacGetRootWindow() , (ControlHandle) control->GetMacControl()  , kControlFocusNoPart ) ;
                 control->MacRedrawControl() ;
             }
             #endif
@@ -234,7 +230,7 @@ void wxWindowMac::SetFocus()
             wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
             if ( control && control->GetMacControl() )
             {
-                UMASetKeyboardFocus( gFocusWindow->MacGetRootWindow() , control->GetMacControl()  , kControlEditTextPart ) ;
+                UMASetKeyboardFocus( (WindowRef) gFocusWindow->MacGetRootWindow() , (ControlHandle) control->GetMacControl()  , kControlEditTextPart ) ;
             }
       #endif
             wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
@@ -273,12 +269,12 @@ void wxWindowMac::ReleaseMouse()
 
 void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget)
 {
-  if ( m_pDropTarget != 0 ) {
-    delete m_pDropTarget;
+  if ( m_dropTarget != 0 ) {
+    delete m_dropTarget;
   }
 
-  m_pDropTarget = pDropTarget;
-  if ( m_pDropTarget != 0 )
+  m_dropTarget = pDropTarget;
+  if ( m_dropTarget != 0 )
   {
     // TODO
   }
@@ -322,8 +318,8 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
     menu->UpdateUI();
     ClientToScreen( &x , &y ) ;
 
-    ::InsertMenu( menu->GetHMenu() , -1 ) ;
-    long menuResult = ::PopUpMenuSelect(menu->GetHMenu() ,y,x, 0) ;
+    ::InsertMenu( (MenuHandle) menu->GetHMenu() , -1 ) ;
+    long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() ,y,x, 0) ;
     menu->MacMenuSelect( this , TickCount() , HiWord(menuResult) , LoWord(menuResult) ) ;
     ::DeleteMenu( menu->MacGetMenuId() ) ;
     menu->SetInvokingWindow(NULL);
@@ -334,7 +330,7 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
 
 void wxWindowMac::DoScreenToClient(int *x, int *y) const
 {
-    WindowRef window = MacGetRootWindow() ;
+    WindowRef window = (WindowRef) MacGetRootWindow() ;
 
     Point       localwhere = {0,0} ;
 
@@ -355,7 +351,7 @@ void wxWindowMac::DoScreenToClient(int *x, int *y) const
 
 void wxWindowMac::DoClientToScreen(int *x, int *y) const
 {
-    WindowRef window = MacGetRootWindow() ;
+    WindowRef window = (WindowRef) MacGetRootWindow() ;
     
     MacClientToRootWindow( x , y ) ;
     
@@ -685,7 +681,7 @@ bool wxWindowMac::Show(bool show)
     MacSuperShown( show ) ;
     if ( !show )
     {
-        WindowRef window = MacGetRootWindow() ;
+        WindowRef window = (WindowRef) MacGetRootWindow() ;
         wxWindowMac* win = wxFindWinFromMacWindow( window ) ;
         if ( win && !win->m_isBeingDeleted )
             Refresh() ; 
@@ -873,7 +869,7 @@ const wxBrush& wxWindowMac::MacGetBackgroundBrush()
         // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
         // either a non gray background color or a non control window
         
-            WindowRef window = MacGetRootWindow() ;
+            WindowRef window = (WindowRef) MacGetRootWindow() ;
             
             wxWindowMac* parent = GetParent() ;
             while( parent )
@@ -906,7 +902,7 @@ const wxBrush& wxWindowMac::MacGetBackgroundBrush()
                         extent.top-- ;
                         extent.right = x + size.x ;
                         extent.bottom = y + size.y ;
-                        m_macBackgroundBrush.SetMacThemeBackground( kThemeBackgroundTabPane , extent ) ; // todo eventually change for inactive
+                        m_macBackgroundBrush.SetMacThemeBackground( kThemeBackgroundTabPane , (WXRECTPTR) &extent ) ; // todo eventually change for inactive
                         break ;
                     }
                 }
@@ -936,7 +932,7 @@ void wxWindowMac::OnNcPaint( wxNcPaintEvent& event )
     wxWindowDC dc(this) ;
     wxMacPortSetter helper(&dc) ;
     
-    MacPaintBorders( dc.m_macLocalOrigin.h , dc.m_macLocalOrigin.v) ;
+    MacPaintBorders( dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y) ;
 }
 
 int wxWindowMac::GetScrollPos(int orient) const
@@ -1124,7 +1120,7 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
             SectRect( &scrollrect , &r , &scrollrect ) ;        
         }
         ScrollRect( &scrollrect , dx , dy , updateRgn ) ;
-        InvalWindowRgn( MacGetRootWindow() ,  updateRgn ) ;
+        InvalWindowRgn( (WindowRef) MacGetRootWindow() ,  updateRgn ) ;
         DisposeRgn( updateRgn ) ;
     }
     
@@ -1300,16 +1296,28 @@ wxWindowMac* wxWindowMac::s_lastMouseWindow = NULL ;
 
 bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin ) 
 {
-    if ((point.x < m_x) || (point.y < m_y) ||
-        (point.x > (m_x + m_width)) || (point.y > (m_y + m_height)))
-        return FALSE;
+    if ( IsTopLevel() )
+    {
+      if ((point.x < 0) || (point.y < 0) ||
+          (point.x > (m_width)) || (point.y > (m_height)))
+          return FALSE;
+    }
+    else
+    {
+      if ((point.x < m_x) || (point.y < m_y) ||
+          (point.x > (m_x + m_width)) || (point.y > (m_y + m_height)))
+          return FALSE;
+    }
     
-    WindowRef window = MacGetRootWindow() ;
+    WindowRef window = (WindowRef) MacGetRootWindow() ;
 
     wxPoint newPoint( point ) ;
 
-    newPoint.x -= m_x;
-    newPoint.y -= m_y;
+    if ( !IsTopLevel() )
+    {
+      newPoint.x -= m_x;
+      newPoint.y -= m_y;
+    }
     
     for (wxNode *node = GetChildren().First(); node; node = node->Next())
     {
@@ -1332,13 +1340,13 @@ bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMa
     Point pt = { screenpoint.y , screenpoint.x } ;
     if ( ::FindWindow( pt , &window ) == 3 )
     {
-            wxPoint point( screenpoint ) ;
-            wxWindowMac* win = wxFindWinFromMacWindow( window ) ;
-            if ( win )
-            {
-            win->ScreenToClient( point ) ;
+        wxPoint point( screenpoint ) ;
+        wxWindowMac* win = wxFindWinFromMacWindow( window ) ;
+        if ( win )
+        {
+            point = win->ScreenToClient( point ) ;
             return win->MacGetWindowFromPointSub( point , outWin ) ;
-    }
+        }
     }
     return FALSE ;
 }
@@ -1355,7 +1363,7 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
     if ( IsKindOf( CLASSINFO ( wxStaticBox ) ) )
         return FALSE ; 
     
-    WindowRef window = MacGetRootWindow() ;
+    WindowRef window = (WindowRef) MacGetRootWindow() ;
 
     event.m_x -= m_x;
     event.m_y -= m_y;
@@ -1417,7 +1425,7 @@ void wxWindowMac::Update()
 wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const 
 {
     wxTopLevelWindowMac* win = NULL ;
-    WindowRef window = MacGetRootWindow() ;
+    WindowRef window = (WindowRef) MacGetRootWindow() ;
     if ( window )
     {
         win = wxFindWinFromMacWindow( window ) ;
@@ -1442,19 +1450,22 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion()
     DiffRgn( visRgn , tempRgn , visRgn ) ;
   }
 
-  wxWindow* parent = GetParent() ;
-  while( parent )
+  if ( !IsTopLevel() )
   {
-    wxSize size = parent->GetSize() ;
-    int x , y ;
-    x = y = 0 ;
-    parent->MacWindowToRootWindow( &x, &y ) ;
-    MacRootWindowToWindow( &x , &y ) ;
-    SetRectRgn( tempRgn , x , y , x + size.x , y + size.y ) ;
-    SectRgn( visRgn , tempRgn , visRgn ) ;
-    if ( parent->IsTopLevel() )
-      break ;
-    parent = parent->GetParent() ;
+    wxWindow* parent = GetParent() ;
+    while( parent )
+    {
+      wxSize size = parent->GetSize() ;
+      int x , y ;
+      x = y = 0 ;
+      parent->MacWindowToRootWindow( &x, &y ) ;
+      MacRootWindowToWindow( &x , &y ) ;
+      SetRectRgn( tempRgn , x , y , x + size.x , y + size.y ) ;
+      SectRgn( visRgn , tempRgn , visRgn ) ;
+      if ( parent->IsTopLevel() )
+        break ;
+      parent = parent->GetParent() ;
+    }
   }
   if ( GetWindowStyle() & wxCLIP_CHILDREN )
   {
@@ -1499,19 +1510,20 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion()
   return m_macVisibleRegion ;
 }
 
-void wxWindowMac::MacRedraw( RgnHandle updatergn , long time, bool erase)
+void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase)
 {
+    RgnHandle updatergn = (RgnHandle) updatergnr ;
     // updatergn is always already clipped to our boundaries
     // it is in window coordinates, not in client coordinates
     
-    WindowRef window = MacGetRootWindow() ;
+    WindowRef window = (WindowRef) MacGetRootWindow() ;
 
     {
         // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
         RgnHandle ownUpdateRgn = NewRgn() ;
         CopyRgn( updatergn , ownUpdateRgn ) ;
                 
-        SectRgn( ownUpdateRgn , MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn ) ;
+        SectRgn( ownUpdateRgn , (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn ) ;
         
         // newupdate is the update region in client coordinates
         RgnHandle newupdate = NewRgn() ;
@@ -1567,7 +1579,7 @@ void wxWindowMac::MacRedraw( RgnHandle updatergn , long time, bool erase)
  
 }
 
-WindowRef wxWindowMac::MacGetRootWindow() const
+WXHWND wxWindowMac::MacGetRootWindow() const
 {
     wxWindowMac *iter = (wxWindowMac*)this ;
     
@@ -1700,7 +1712,7 @@ bool wxWindowMac::AcceptsFocus() const
     return MacCanFocus() && wxWindowBase::AcceptsFocus();
 }
 
-ControlHandle wxWindowMac::MacGetContainerForEmbedding() 
+WXWidget wxWindowMac::MacGetContainerForEmbedding() 
 {
     return GetParent()->MacGetContainerForEmbedding() ;
 }