X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b8f2db1f34fcf92ad8a5cdf5334f2000c9f292f4..27f35b6674b796e61986681261ec7a96bef93502:/src/mac/control.cpp diff --git a/src/mac/control.cpp b/src/mac/control.cpp index fc90b8ea04..5998a660fc 100644 --- a/src/mac/control.cpp +++ b/src/mac/control.cpp @@ -46,7 +46,30 @@ END_EVENT_TABLE() // Item members + +#if PRAGMA_STRUCT_ALIGN + #pragma options align=mac68k +#elif PRAGMA_STRUCT_PACKPUSH + #pragma pack(push, 2) +#elif PRAGMA_STRUCT_PACK + #pragma pack(2) +#endif + +typedef struct { + unsigned short instruction; + void (*function)(); +} cdefRec, *cdefPtr, **cdefHandle; + +#if PRAGMA_STRUCT_ALIGN + #pragma options align=reset +#elif PRAGMA_STRUCT_PACKPUSH + #pragma pack(pop) +#elif PRAGMA_STRUCT_PACK + #pragma pack() +#endif + ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ; +wxControl *wxFindControlFromMacControl(ControlHandle inControl ) ; pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) ; pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) @@ -62,6 +85,24 @@ pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCod } ControlColorUPP wxMacSetupControlBackgroundUPP = NULL ; +ControlDefUPP wxMacControlActionUPP = NULL ; + +pascal SInt32 wxMacControlDefintion(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param) +{ + + wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ; + if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) + { + if( message == drawCntl ) + { + wxMacWindowClipper clip( wx ) ; + return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ; + } + else + return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ; + } + return NULL ; +} pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor ) { @@ -92,6 +133,7 @@ pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessa wxControl::wxControl() { m_macControl = NULL ; + m_macControlAction = NULL ; m_macHorizontalBorder = 0 ; // additional pixels around the real control m_macVerticalBorder = 0 ; m_backgroundColour = *wxWHITE; @@ -137,6 +179,7 @@ bool wxControl::Create(wxWindow *parent, wxWindowID id, wxControl::~wxControl() { m_isBeingDeleted = TRUE; + wxRemoveMacControlAssociation( this ) ; // If we delete an item, we should initialize the parent panel, // because it could now be invalid. wxWindow *parent = GetParent() ; @@ -349,11 +392,32 @@ void wxControl::MacPostControlCreate() m_macControlIsShown = true ; wxAssociateControlWithMacControl( (ControlHandle) m_macControl , this ) ; - if ( wxMacSetupControlBackgroundUPP == NULL ) { wxMacSetupControlBackgroundUPP = NewControlColorUPP( wxMacSetupControlBackground ) ; } + if ( wxMacControlActionUPP == NULL ) + { + wxMacControlActionUPP = NewControlDefUPP( wxMacControlDefintion ) ; + } +#if TARGET_CARBON +/* + only working under classic carbon + m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ; + (**(ControlHandle)m_macControl).contrlDefProc = (Handle) &wxMacControlActionUPP ; +*/ +#else + m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ; + + cdefHandle cdef ; + cdef = (cdefHandle) NewHandle( sizeof(cdefRec) ) ; + if ( (**(ControlHandle)m_macControl).contrlDefProc != NULL ) + { + (**cdef).instruction = 0x4EF9; /* JMP instruction */ + (**cdef).function = (void(*)()) wxMacControlActionUPP; + (**(ControlHandle)m_macControl).contrlDefProc = (Handle) cdef ; + } +#endif SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ; // Adjust the controls size and position @@ -691,31 +755,11 @@ void wxControl::Refresh(bool eraseBack, const wxRect *rect) void wxControl::MacRedrawControl() { - if ( (ControlHandle) m_macControl && MacGetRootWindow() ) + if ( (ControlHandle) m_macControl && MacGetRootWindow() && m_macControlIsShown ) { wxClientDC dc(this) ; wxMacPortSetter helper(&dc) ; -/* - Rect r = { 0 , 0 , 32000 , 32000 } ; - ClipRect( &r ) ; -*/ - int x = 0 , y = 0; - wxWindow *parent = GetParent() ; - parent->MacWindowToRootWindow( &x,&y ) ; - RgnHandle clrgn = NewRgn() ; - RgnHandle insidergn = NewRgn() ; - wxSize size = parent->GetSize() ; - SetRectRgn( insidergn , parent->MacGetLeftBorderSize() , parent->MacGetTopBorderSize() , - size.x - parent->MacGetLeftBorderSize() - parent->MacGetRightBorderSize(), - size.y - parent->MacGetTopBorderSize() - parent->MacGetBottomBorderSize()) ; - - CopyRgn( (RgnHandle) parent->MacGetVisibleRegion(false).GetWXHRGN() , clrgn ) ; - SectRgn( clrgn , insidergn , clrgn ) ; - OffsetRgn( clrgn , x , y ) ; - SetClip( clrgn ) ; - DisposeRgn( clrgn ) ; - DisposeRgn( insidergn ) ; - + wxMacWindowClipper clipper(this) ; wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; UMADrawControl( (ControlHandle) m_macControl ) ; } @@ -727,28 +771,7 @@ void wxControl::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this) ; wxMacPortSetter helper(&dc) ; -/* - Rect r = { 0 , 0 , 32000 , 32000 } ; - ClipRect( &r ) ; -*/ - - int x = 0 , y = 0; - wxWindow *parent = GetParent() ; - parent->MacWindowToRootWindow( &x,&y ) ; - RgnHandle clrgn = NewRgn() ; - RgnHandle insidergn = NewRgn() ; - wxSize size = parent->GetSize() ; - SetRectRgn( insidergn , parent->MacGetLeftBorderSize() , parent->MacGetTopBorderSize() , - size.x - parent->MacGetLeftBorderSize() - parent->MacGetRightBorderSize(), - size.y - parent->MacGetTopBorderSize() - parent->MacGetBottomBorderSize()) ; - - CopyRgn( (RgnHandle) parent->MacGetVisibleRegion(false).GetWXHRGN() , clrgn ) ; - SectRgn( clrgn , insidergn , clrgn ) ; - OffsetRgn( clrgn , x , y ) ; - SetClip( clrgn ) ; - DisposeRgn( clrgn ) ; - DisposeRgn( insidergn ) ; - + wxMacWindowClipper clipper(this) ; wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; UMADrawControl( (ControlHandle) m_macControl ) ; } @@ -796,7 +819,6 @@ void wxControl::OnMouseEvent( wxMouseEvent &event ) ControlHandle control ; Point localwhere ; SInt16 controlpart ; - WindowRef window = (WindowRef) MacGetRootWindow() ; localwhere.h = x ; localwhere.v = y ; @@ -817,20 +839,7 @@ void wxControl::OnMouseEvent( wxMouseEvent &event ) if ( event.m_metaDown ) modifiers |= cmdKey ; -/* -#if TARGET_CARBON - control = FindControlUnderMouse( localwhere , window , &controlpart ) ; -#else - controlpart = FindControl( localwhere , window , &control ) ; -#endif -*/ { - /* - if ( AcceptsFocus() && FindFocus() != this ) - { - SetFocus() ; - } - */ control = (ControlHandle) m_macControl ; if ( control && ::IsControlActive( control ) ) {