X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8cf73271dd6f442a98e86b559d4a55c37e25b99f..245c5d2e02f338927e4099adc56ece165aeb5924:/include/wx/mac/carbon/private.h diff --git a/include/wx/mac/carbon/private.h b/include/wx/mac/carbon/private.h index 97c0680bcf..b41aecbf20 100644 --- a/include/wx/mac/carbon/private.h +++ b/include/wx/mac/carbon/private.h @@ -20,6 +20,7 @@ #ifdef __DARWIN__ # include #else +# include # include # include # include @@ -62,6 +63,24 @@ private: short m_textMode ; } ; +class WXDLLEXPORT wxMacPortSaver +{ + DECLARE_NO_COPY_CLASS(wxMacPortSaver) + +public: + wxMacPortSaver( GrafPtr port ) + { + ::GetPort( &m_port ) ; + ::SetPort( port ) ; + } + ~wxMacPortSaver() + { + ::SetPort( m_port ) ; + } +private : + GrafPtr m_port ; +} ; + class WXDLLEXPORT wxMacPortSetter { DECLARE_NO_COPY_CLASS(wxMacPortSetter) @@ -74,7 +93,11 @@ private: const wxDC* m_dc ; } ; -class WXDLLEXPORT wxMacWindowClipper +/* + Clips to the visible region of a control within the current port + */ + +class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver { DECLARE_NO_COPY_CLASS(wxMacWindowClipper) @@ -82,10 +105,24 @@ public: wxMacWindowClipper( const wxWindow* win ) ; ~wxMacWindowClipper() ; private: + GrafPtr m_newPort ; RgnHandle m_formerClip ; RgnHandle m_newClip ; } ; +class WXDLLEXPORT wxMacWindowStateSaver : public wxMacWindowClipper +{ + DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver) + +public: + wxMacWindowStateSaver( const wxWindow* win ) ; + ~wxMacWindowStateSaver() ; +private: + GrafPtr m_newPort ; + ThemeDrawingState m_themeDrawingState ; +} ; + +/* class wxMacDrawingHelper { DECLARE_NO_COPY_CLASS(wxMacDrawingHelper) @@ -105,6 +142,7 @@ private: PenState m_savedPenState ; bool m_ok ; } ; +*/ // app.h bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ; @@ -149,6 +187,113 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi #define MAC_WXPOINTPTR(a) ((Point*)a) #define MAC_WXHMENU(a) ((MenuHandle)a) +struct wxOpaqueWindowRef +{ + wxOpaqueWindowRef( WindowRef ref ) { m_data = ref ; } + operator WindowRef() { return m_data ; } +private : + WindowRef m_data ; +} ; + +wxWindow *wxFindControlFromMacControl(ControlRef inControl ) ; +wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ) ; +extern wxWindow* g_MacLastWindow ; +pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ; +Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ) ; + +template EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ) ; return 0 ; } +template<> inline EventParamType wxMacGetEventParamType() { return typeQDRgnHandle ; } +template<> inline EventParamType wxMacGetEventParamType() { return typeControlRef ; } +template<> inline EventParamType wxMacGetEventParamType() { return typeWindowRef ; } +template<> inline EventParamType wxMacGetEventParamType() { return typeMenuRef ; } +template<> inline EventParamType wxMacGetEventParamType() { return typeEventRef ; } +template<> inline EventParamType wxMacGetEventParamType() { return typeQDPoint ; } +template<> inline EventParamType wxMacGetEventParamType() { return typeQDRectangle ; } +template<> inline EventParamType wxMacGetEventParamType() { return typeBoolean ; } +#if TARGET_API_MAC_OSX +template<> inline EventParamType wxMacGetEventParamType() { return typeHIPoint ; } +template<> inline EventParamType wxMacGetEventParamType() { return typeHISize ; } +template<> inline EventParamType wxMacGetEventParamType() { return typeHIRect ; } +template<> inline EventParamType wxMacGetEventParamType() { return typeVoidPtr ; } +#endif +template<> inline EventParamType wxMacGetEventParamType() { return typeCollection ; } +template<> inline EventParamType wxMacGetEventParamType() { return typeCGContextRef ; } +/* +These are ambiguous +template<> EventParamType wxMacGetEventParamType() { return typeGrafPtr ; } +template<> EventParamType wxMacGetEventParamType() { return typeOSStatus ; } +template<> EventParamType wxMacGetEventParamType() { return typeCFIndex ; } +template<> EventParamType wxMacGetEventParamType() { return typeGWorldPtr ; } +*/ + +class wxMacCarbonEvent +{ + +public : + wxMacCarbonEvent( EventRef event ) + { + m_eventRef = event ; + } + + OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData) ; + + template OSStatus GetParameter( EventParamName inName, EventParamType type , T *data ) + { + return GetParameter( inName, type , sizeof( T ) , data ) ; + } + template OSStatus GetParameter( EventParamName inName, T *data ) + { + return GetParameter( inName, wxMacGetEventParamType() , data ) ; + } + + template T GetParameter( EventParamName inName ) + { + T value ; + verify_noerr( GetParameter( inName, &value ) ) ; + return value ; + } + template T GetParameter( EventParamName inName, EventParamType inDesiredType ) + { + T value ; + verify_noerr( GetParameter( inName, inDesiredType , &value ) ) ; + return value ; + } + + + OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, void * inData) ; + template OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , T *data ) + { + return SetParameter( inName, inDesiredType , sizeof( T ) , data ) ; + } + template OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , T data ) + { + return SetParameter( inName, inDesiredType , &data ) ; + } + template OSStatus SetParameter( EventParamName inName, T *data ) + { + return SetParameter( inName, wxMacGetEventParamType() , data ) ; + } + template OSStatus SetParameter( EventParamName inName, T data ) + { + return SetParameter( inName, wxMacGetEventParamType() , &data ) ; + } + + EventKind GetKind() + { + return ::GetEventKind( m_eventRef ) ; + } + EventTime GetTime() + { + return ::GetEventTime( m_eventRef ) ; + } + UInt32 GetTicks() + { + return EventTimeToTicks( GetTime() ) ; + } +protected : + EventRef m_eventRef ; +} ; + #endif // wxUSE_GUI //--------------------------------------------------------------------------- @@ -228,11 +373,14 @@ private: #endif - +// utils.cpp wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ; wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ; +// toplevel.cpp + +ControlRef wxMacFindControlUnderMouse( Point location , WindowRef window , ControlPartCode *outPart ) ; #endif // _WX_PRIVATE_H_