X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5921f83f7382082cd66936f2a678827317c55b1e..39c0acb66674c5e0424633cf162e6c10c92178d4:/include/wx/mac/private.h diff --git a/include/wx/mac/private.h b/include/wx/mac/private.h index b2ad16aff3..7c50c1f2fe 100644 --- a/include/wx/mac/private.h +++ b/include/wx/mac/private.h @@ -5,20 +5,20 @@ // with "wx". // Author: Stefan Csomor // Modified by: -// Created: ??/??/98 +// Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_PRIVATE_H_ #define _WX_PRIVATE_H_ #include "wx/defs.h" +#include "wx/app.h" -#if defined(__POWERPC__) && defined(__DARWIN__) +#ifdef __DARWIN__ # include -# define TARGET_CARBON 1 #else # include # include @@ -33,63 +33,88 @@ #error "please update to Apple's lastest universal headers from http://developer.apple.com/sdk/" #endif +#if wxUSE_GUI + #include "wx/window.h" class wxMacPortStateHelper { -public : - wxMacPortStateHelper( GrafPtr newport) ; - wxMacPortStateHelper() ; - ~wxMacPortStateHelper() ; - - void Setup( GrafPtr newport ) ; - void Clear() ; - bool IsCleared() { return m_clip == NULL ; } - GrafPtr GetCurrentPort() { return m_currentPort ; } - -private : - GrafPtr m_currentPort ; - GrafPtr m_oldPort ; - RgnHandle m_clip ; - ThemeDrawingState m_drawingState ; - short m_textFont ; - short m_textSize ; - short m_textStyle ; - short m_textMode ; + DECLARE_NO_COPY_CLASS(wxMacPortStateHelper) + +public: + wxMacPortStateHelper( GrafPtr newport) ; + wxMacPortStateHelper() ; + ~wxMacPortStateHelper() ; + + void Setup( GrafPtr newport ) ; + void Clear() ; + bool IsCleared() { return m_clip == NULL ; } + GrafPtr GetCurrentPort() { return m_currentPort ; } + +private: + GrafPtr m_currentPort ; + GrafPtr m_oldPort ; + RgnHandle m_clip ; + ThemeDrawingState m_drawingState ; + short m_textFont ; + short m_textSize ; + short m_textStyle ; + short m_textMode ; } ; class WXDLLEXPORT wxMacPortSetter { -public : - wxMacPortSetter( const wxDC* dc ) ; - ~wxMacPortSetter() ; -private : - wxMacPortStateHelper m_ph ; - wxDC* m_dc ; + DECLARE_NO_COPY_CLASS(wxMacPortSetter) + +public: + wxMacPortSetter( const wxDC* dc ) ; + ~wxMacPortSetter() ; +private: + wxMacPortStateHelper m_ph ; + const wxDC* m_dc ; +} ; + +class WXDLLEXPORT wxMacWindowClipper +{ + DECLARE_NO_COPY_CLASS(wxMacWindowClipper) + +public: + wxMacWindowClipper( const wxWindow* win ) ; + ~wxMacWindowClipper() ; +private: + RgnHandle m_formerClip ; + RgnHandle m_newClip ; } ; class wxMacDrawingHelper { -public : - wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false ) ; - ~wxMacDrawingHelper() ; - bool Ok() { return m_ok ; } - void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ) ; } - void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ) ; } - void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ) ; } - const Point& GetOrigin() { return m_origin ; } -private : - Point m_origin ; - GrafPtr m_formerPort ; - GrafPtr m_currentPort ; - PenState m_savedPenState ; - bool m_ok ; + DECLARE_NO_COPY_CLASS(wxMacDrawingHelper) + +public: + wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false ) ; + ~wxMacDrawingHelper() ; + bool Ok() { return m_ok ; } + void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ) ; } + void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ) ; } + void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ) ; } + const Point& GetOrigin() { return m_origin ; } +private: + Point m_origin ; + GrafPtr m_formerPort ; + GrafPtr m_currentPort ; + PenState m_savedPenState ; + bool m_ok ; } ; +// app.h +bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ; + +#endif // wxUSE_GUI // filefn.h WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ; WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ; +WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec ) ; # ifndef __DARWIN__ // Mac file names are POSIX (Unix style) under Darwin, so these are not needed WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ; @@ -103,12 +128,15 @@ WXDLLEXPORT wxString wxMacFindFolder(short vRefNum, OSType folderType, Boolean createFolder); -GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ; -void wxMacDestroyGWorld( GWorldPtr gw ) ; -PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ; +#if wxUSE_GUI + +GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ; +void wxMacDestroyGWorld( GWorldPtr gw ) ; +PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ; CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ; -void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ; -CTabHandle wxMacCreateColorTable( int numColors ) ; +void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ; +CTabHandle wxMacCreateColorTable( int numColors ) ; +void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ; #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a))) #define MAC_WXHBITMAP(a) (GWorldPtr(a)) @@ -120,5 +148,91 @@ CTabHandle wxMacCreateColorTable( int numColors ) ; #define MAC_WXRECPTR(a) ((Rect*)a) #define MAC_WXPOINTPTR(a) ((Point*)a) #define MAC_WXHMENU(a) ((MenuHandle)a) + +#endif // wxUSE_GUI + +//--------------------------------------------------------------------------- +// wxMac string conversions +//--------------------------------------------------------------------------- + +void wxMacSetupConverters() ; +void wxMacCleanupConverters() ; + +void wxMacStringToPascal( const wxString&from , StringPtr to ) ; +wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ; + +void wxMacConvertNewlines13To10( char * data ) ; +void wxMacConvertNewlines10To13( char * data ) ; +void wxMacConvertNewlines13To10( wxString *data ) ; +void wxMacConvertNewlines10To13( wxString *data ) ; + +#if wxUSE_UNICODE +void wxMacConvertNewlines13To10( wxChar * data ) ; +void wxMacConvertNewlines10To13( wxChar * data ) ; +#endif + +#if TARGET_CARBON + +class wxMacCFStringHolder +{ +public: + wxMacCFStringHolder() + { + m_cfs = NULL ; + m_release = false ; + } + + wxMacCFStringHolder(const wxString &str) + { + m_cfs = NULL ; + m_release = false ; + Assign( str ) ; + } + + wxMacCFStringHolder(CFStringRef ref , bool release = true ) + { + m_cfs = ref ; + m_release = release ; + } + + ~wxMacCFStringHolder() + { + Release() ; + } + + wxMacCFStringHolder& operator=(const wxString& str) + { + Release() ; + Assign( str ) ; + return *this; + } + + CFStringRef Detach() + { + CFStringRef retval = m_cfs ; + m_release = false ; + m_cfs = NULL ; + return retval ; + } + + void Release() + { + if ( m_release && m_cfs) + CFRelease( m_cfs ) ; + m_cfs = NULL ; + } + + operator CFStringRef () { return m_cfs; } + wxString AsString() ; + +private: + void Assign( const wxString &str ) ; + + CFStringRef m_cfs; + bool m_release ; +} ; + +#endif + #endif // _WX_PRIVATE_H_