#include "wx/caret.h"
#endif // wxUSE_CARET
-#define wxWINDOW_HSCROLL 5998
-#define wxWINDOW_VSCROLL 5997
-
#define MAC_SCROLLBAR_SIZE 15
#define MAC_SMALL_SCROLLBAR_SIZE 11
// implementation
// ===========================================================================
+#if KEY_wxList_DEPRECATED
wxList wxWinMacControlList(wxKEY_INTEGER);
wxWindow *wxFindControlFromMacControl(ControlRef inControl )
{
wxWinMacControlList.DeleteObject(control);
}
+#else
+
+WX_DECLARE_HASH_MAP(ControlRef, wxWindow*, wxPointerHash, wxPointerEqual, MacControlMap);
+
+static MacControlMap wxWinMacControlList;
+
+wxWindow *wxFindControlFromMacControl(ControlRef inControl )
+{
+ MacControlMap::iterator node = wxWinMacControlList.find(inControl);
+
+ return (node == wxWinMacControlList.end()) ? NULL : node->second;
+}
+
+void wxAssociateControlWithMacControl(ControlRef inControl, wxWindow *control)
+{
+ // adding NULL ControlRef is (first) surely a result of an error and
+ // (secondly) breaks native event processing
+ wxCHECK_RET( inControl != (ControlRef) NULL, wxT("attempt to add a NULL WindowRef to window list") );
+
+ wxWinMacControlList[inControl] = control;
+}
+
+void wxRemoveMacControlAssociation(wxWindow *control)
+{
+ // iterate over all the elements in the class
+ MacControlMap::iterator it;
+ for ( it = wxWinMacControlList.begin(); it != wxWinMacControlList.end(); ++it )
+ {
+ if ( it->second == control )
+ {
+ wxWinMacControlList.erase(it);
+ break;
+ }
+ }
+}
+#endif // deprecated wxList
// UPP functions
ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ;
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
return FALSE;
- parent->AddChild(this);
-
m_windowVariant = parent->GetWindowVariant() ;
if ( m_macIsUserPane )
return TRUE;
}
+void wxWindowMac::MacChildAdded()
+{
+ if ( m_vScrollBar )
+ {
+ m_vScrollBar->Raise() ;
+ }
+ if ( m_hScrollBar )
+ {
+ m_hScrollBar->Raise() ;
+ }
+
+}
+
void wxWindowMac::MacPostControlCreate(const wxPoint& pos, const wxSize& size)
{
wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid mac control") ) ;
m_peer->SetReference( (long) this ) ;
+ GetParent()->AddChild(this);
MacInstallEventHandler( (WXWidget) m_peer->GetControlRef() );
ControlRef container = (ControlRef) GetParent()->GetHandle() ;
wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
::EmbedControl( m_peer->GetControlRef() , container ) ;
+ GetParent()->MacChildAdded() ;
// adjust font, controlsize etc
DoSetWindowVariant( m_windowVariant ) ;
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
{
GetRegionBounds( rgn , &content ) ;
- DisposeRgn( rgn ) ;
}
else
{
m_peer->GetRect( &content ) ;
}
+ DisposeRgn( rgn ) ;
Rect structure ;
m_peer->GetRect( &structure ) ;
#if !TARGET_API_MAC_OSX
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
{
GetRegionBounds( rgn , &content ) ;
- DisposeRgn( rgn ) ;
}
else
{
m_peer->GetRect( &content ) ;
}
+ DisposeRgn( rgn ) ;
Rect structure ;
m_peer->GetRect( &structure ) ;
#if !TARGET_API_MAC_OSX
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
{
GetRegionBounds( rgn , &content ) ;
- DisposeRgn( rgn ) ;
}
else
{
m_peer->GetRect( &content ) ;
}
+ DisposeRgn( rgn ) ;
#if !TARGET_API_MAC_OSX
Rect structure ;
m_peer->GetRect( &structure ) ;
{
bestsize.bottom = 16 ;
}
+#if wxUSE_SPINBTN
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
{
bestsize.bottom = 24 ;
}
+#endif // wxUSE_SPINBTN
else
{
// return wxWindowBase::DoGetBestSize() ;
return FALSE;
// TODO use visibilityChanged Carbon Event for OSX
- bool former = MacIsReallyShown() ;
+ if ( m_peer )
+ {
+ bool former = MacIsReallyShown() ;
- m_peer->SetVisibility( show , true ) ;
- if ( former != MacIsReallyShown() )
- MacPropagateVisibilityChanged() ;
+ m_peer->SetVisibility( show , true ) ;
+ if ( former != MacIsReallyShown() )
+ MacPropagateVisibilityChanged() ;
+ }
return TRUE;
}
#if !TARGET_API_MAC_OSX
MacVisibilityChanged() ;
- wxWindowListNode *node = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
wxWindowMac *child = node->GetData();
#if !TARGET_API_MAC_OSX
MacEnabledStateChanged() ;
- wxWindowListNode *node = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
wxWindowMac *child = node->GetData();
#if !TARGET_API_MAC_OSX
MacHiliteChanged() ;
- wxWindowListNode *node = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
wxWindowMac *child = node->GetData();
bool wxWindowMac::MacIsReallyShown()
{
// only under OSX the visibility of the TLW is taken into account
+ if ( m_isBeingDeleted )
+ return false ;
+
#if TARGET_API_MAC_OSX
if ( m_peer && m_peer->Ok() )
return m_peer->IsVisible();
#endif
}
- for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
+ for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext())
{
wxWindowMac *child = node->GetData();
if (child == m_vScrollBar) continue;
void wxWindowMac::MacOnScroll(wxScrollEvent &event )
{
- if ( event.m_eventObject == m_vScrollBar || event.m_eventObject == m_hScrollBar )
+ if ( event.GetEventObject() == m_vScrollBar || event.GetEventObject() == m_hScrollBar )
{
wxScrollWinEvent wevent;
wevent.SetPosition(event.GetPosition());
wevent.SetOrientation(event.GetOrientation());
- wevent.m_eventObject = this;
-
- if (event.m_eventType == wxEVT_SCROLL_TOP)
- wevent.m_eventType = wxEVT_SCROLLWIN_TOP;
- else if (event.m_eventType == wxEVT_SCROLL_BOTTOM)
- wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM;
- else if (event.m_eventType == wxEVT_SCROLL_LINEUP)
- wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP;
- else if (event.m_eventType == wxEVT_SCROLL_LINEDOWN)
- wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN;
- else if (event.m_eventType == wxEVT_SCROLL_PAGEUP)
- wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP;
- else if (event.m_eventType == wxEVT_SCROLL_PAGEDOWN)
- wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN;
- else if (event.m_eventType == wxEVT_SCROLL_THUMBTRACK)
- wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK;
- else if (event.m_eventType == wxEVT_SCROLL_THUMBRELEASE)
- wevent.m_eventType = wxEVT_SCROLLWIN_THUMBRELEASE;
+ wevent.SetEventObject(this);
+
+ if (event.GetEventType() == wxEVT_SCROLL_TOP)
+ wevent.SetEventType( wxEVT_SCROLLWIN_TOP );
+ else if (event.GetEventType() == wxEVT_SCROLL_BOTTOM)
+ wevent.SetEventType( wxEVT_SCROLLWIN_BOTTOM );
+ else if (event.GetEventType() == wxEVT_SCROLL_LINEUP)
+ wevent.SetEventType( wxEVT_SCROLLWIN_LINEUP );
+ else if (event.GetEventType() == wxEVT_SCROLL_LINEDOWN)
+ wevent.SetEventType( wxEVT_SCROLLWIN_LINEDOWN );
+ else if (event.GetEventType() == wxEVT_SCROLL_PAGEUP)
+ wevent.SetEventType( wxEVT_SCROLLWIN_PAGEUP );
+ else if (event.GetEventType() == wxEVT_SCROLL_PAGEDOWN)
+ wevent.SetEventType( wxEVT_SCROLLWIN_PAGEDOWN );
+ else if (event.GetEventType() == wxEVT_SCROLL_THUMBTRACK)
+ wevent.SetEventType( wxEVT_SCROLLWIN_THUMBTRACK );
+ else if (event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE)
+ wevent.SetEventType( wxEVT_SCROLLWIN_THUMBRELEASE );
GetEventHandler()->ProcessEvent(wevent);
}
}
// Get the window with the focus
-wxWindowMac *wxWindowBase::FindFocus()
+wxWindowMac *wxWindowBase::DoFindFocus()
{
ControlRef control ;
GetKeyboardFocus( GetUserFocusWindow() , &control ) ;
Rect r ;
RgnHandle visRgn = NewRgn() ;
RgnHandle tempRgn = NewRgn() ;
- if ( m_peer->IsVisible())
+ if ( !m_isBeingDeleted && m_peer->IsVisible())
{
m_peer->GetRect( &r ) ;
r.left -= MacGetLeftBorderSize() ;
{
// paint the window itself
wxPaintEvent event;
- event.m_timeStamp = time ;
+ event.SetTimestamp(time);
event.SetEventObject(this);
handled = GetEventHandler()->ProcessEvent(event);
// in Composited windowing
wxPoint clientOrigin = GetClientAreaOrigin() ;
- for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
+ for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext())
{
wxWindowMac *child = node->GetData();
if (child == m_vScrollBar) continue;
if ( style & wxVSCROLL )
{
- m_vScrollBar = new wxScrollBar(this, wxWINDOW_VSCROLL, vPoint,
+ m_vScrollBar = new wxScrollBar(this, wxID_ANY, vPoint,
vSize , wxVERTICAL);
}
if ( style & wxHSCROLL )
{
- m_hScrollBar = new wxScrollBar(this, wxWINDOW_HSCROLL, hPoint,
+ m_hScrollBar = new wxScrollBar(this, wxID_ANY, hPoint,
hSize , wxHORIZONTAL);
}
}
{
// only window-absolute structures have to be moved i.e. controls
- wxWindowListNode *node = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
wxWindowMac *child = node->GetData();
{
// only screen-absolute structures have to be moved i.e. glcanvas
- wxWindowListNode *node = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
wxWindowMac *child = node->GetData();