X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/111c1e2c200bf4f8e20073cbd9e263a077eace19..7de24929eb363ba8c52b68a04e20d2774dd0b6b2:/src/mac/carbon/control.cpp diff --git a/src/mac/carbon/control.cpp b/src/mac/carbon/control.cpp index 92e8cd3cc8..0ba0c06521 100644 --- a/src/mac/carbon/control.cpp +++ b/src/mac/carbon/control.cpp @@ -1,11 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// // Name: control.cpp // Purpose: wxControl class -// Author: AUTHOR +// Author: Stefan Csomor // Modified by: -// Created: ??/??/98 +// Created: 1998-01-01 // RCS-ID: $Id$ -// Copyright: (c) AUTHOR +// Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -36,7 +36,6 @@ IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow) BEGIN_EVENT_TABLE(wxControl, wxWindow) EVT_MOUSE_EVENTS( wxControl::OnMouseEvent ) -// EVT_CHAR( wxControl::OnKeyDown ) EVT_PAINT( wxControl::OnPaint ) END_EVENT_TABLE() #endif @@ -87,7 +86,7 @@ pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCod ControlColorUPP wxMacSetupControlBackgroundUPP = NULL ; ControlDefUPP wxMacControlActionUPP = NULL ; -pascal SInt32 wxMacControlDefintion(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param) +pascal SInt32 wxMacControlDefinition(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param) { wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ; @@ -115,7 +114,17 @@ pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessa if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) { wxDC::MacSetupBackgroundForCurrentPort( wx->MacGetBackgroundBrush() ) ; - // SetThemeBackground( iDepth , iIsColor ) ; +#if TARGET_CARBON + // under classic this would lead to partial redraws + RgnHandle clip = NewRgn() ; + int x = 0 , y = 0; + + wx->MacWindowToRootWindow( &x,&y ) ; + CopyRgn( (RgnHandle) wx->MacGetVisibleRegion(false).GetWXHRGN() , clip ) ; + OffsetRgn( clip , x , y ) ; + SetClip( clip ) ; + DisposeRgn( clip ) ; +#endif } else { @@ -295,7 +304,7 @@ wxControl *wxFindControlFromMacControl(ControlHandle inControl ) wxNode *node = wxWinMacControlList->Find((long)inControl); if (!node) return NULL; - return (wxControl *)node->Data(); + return (wxControl *)node->GetData(); } void wxAssociateControlWithMacControl(ControlHandle inControl, wxControl *control) @@ -347,19 +356,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l ((Rect*)outBounds)->bottom = 0; ((Rect*)outBounds)->right = 0; - char c_text[255]; - strcpy( c_text , label ) ; - if( wxApp::s_macDefaultEncodingIsPC ) - { - wxMacConvertFromPCForControls( c_text ) ; - } - -#if TARGET_CARBON - c2pstrcpy( (StringPtr) maclabel , c_text ) ; -#else - strcpy( (char *) maclabel , c_text ) ; - c2pstr( (char *) maclabel ) ; -#endif + wxMacStringToPascal( wxStripMenuCodes(label) , maclabel ) ; } void wxControl::MacPostControlCreate() @@ -398,7 +395,7 @@ void wxControl::MacPostControlCreate() } if ( wxMacControlActionUPP == NULL ) { - wxMacControlActionUPP = NewControlDefUPP( wxMacControlDefintion ) ; + wxMacControlActionUPP = NewControlDefUPP( wxMacControlDefinition ) ; } // The following block of code is responsible for crashes when switching // back to windows, which can be seen in the dialogs sample. @@ -594,6 +591,23 @@ void wxControl::DoSetSize(int x, int y, int sizeFlags ) { wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ; +#if 0 + { + Rect meta , control ; + GetControlBounds( (ControlHandle) m_macControl , &control ) ; + RgnHandle rgn = NewRgn() ; + GetControlRegion( (ControlHandle) m_macControl , kControlStructureMetaPart , rgn ) ; + GetRegionBounds( rgn , &meta ) ; + if ( !EmptyRect( &meta ) ) + { + wxASSERT( meta.left >= control.left - m_macHorizontalBorder ) ; + wxASSERT( meta.right <= control.right + m_macHorizontalBorder ) ; + wxASSERT( meta.top >= control.top - m_macVerticalBorder ) ; + wxASSERT( meta.bottom <= control.bottom + m_macVerticalBorder ) ; + } + DisposeRgn( rgn ) ; + } +#endif return ; /* @@ -793,12 +807,24 @@ void wxControl::OnEraseBackground(wxEraseEvent& event) wxWindow::OnEraseBackground( event ) ; } - void wxControl::OnKeyDown( wxKeyEvent &event ) { if ( (ControlHandle) m_macControl == NULL ) return ; +#if TARGET_CARBON + + char charCode ; + UInt32 keyCode ; + UInt32 modifiers ; + + GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); + GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); + GetEventParameter((EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); + + ::HandleControlKey( (ControlHandle) m_macControl , keyCode , charCode , modifiers ) ; + +#else EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ; short keycode ; short keychar ; @@ -806,6 +832,7 @@ void wxControl::OnKeyDown( wxKeyEvent &event ) keycode = short(ev->message & keyCodeMask) >> 8 ; ::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ; +#endif } void wxControl::OnMouseEvent( wxMouseEvent &event )