X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7372fd0a3c5b84f7cbaaf37592f7d413a3e0372b..0f4930939e18a6c07ef303533329dd5334a65780:/src/mac/control.cpp diff --git a/src/mac/control.cpp b/src/mac/control.cpp index b3049043ee..9e6e919791 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 @@ -695,14 +759,7 @@ void wxControl::MacRedrawControl() { wxClientDC dc(this) ; wxMacPortSetter helper(&dc) ; - - int x = 0 , y = 0; - GetParent()->MacWindowToRootWindow( &x,&y ) ; - RgnHandle clrgn = NewRgn() ; - CopyRgn( (RgnHandle) GetParent()->MacGetVisibleRegion().GetWXHRGN() , clrgn ) ; - OffsetRgn( clrgn , x , y ) ; - SetClip( clrgn ) ; - + wxMacWindowClipper clipper(this) ; wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; UMADrawControl( (ControlHandle) m_macControl ) ; } @@ -714,14 +771,7 @@ void wxControl::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this) ; wxMacPortSetter helper(&dc) ; - - int x = 0 , y = 0; - GetParent()->MacWindowToRootWindow( &x,&y ) ; - RgnHandle clrgn = NewRgn() ; - CopyRgn( (RgnHandle) GetParent()->MacGetVisibleRegion().GetWXHRGN() , clrgn ) ; - OffsetRgn( clrgn , x , y ) ; - SetClip( clrgn ) ; - + wxMacWindowClipper clipper(this) ; wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; UMADrawControl( (ControlHandle) m_macControl ) ; }