1999-01-01 11:05:26 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: private.h
|
2002-01-04 12:13:39 -05:00
|
|
|
// Purpose: Private declarations: as this header is only included by
|
|
|
|
// wxWindows itself, it may contain identifiers which don't start
|
|
|
|
// with "wx".
|
|
|
|
// Author: Stefan Csomor
|
1999-01-01 11:05:26 -05:00
|
|
|
// Modified by:
|
2003-02-28 16:54:04 -05:00
|
|
|
// Created: 1998-01-01
|
1999-01-01 11:05:26 -05:00
|
|
|
// RCS-ID: $Id$
|
2002-01-04 12:13:39 -05:00
|
|
|
// Copyright: (c) Stefan Csomor
|
2003-02-28 18:48:13 -05:00
|
|
|
// Licence: wxWindows licence
|
1999-01-01 11:05:26 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_PRIVATE_H_
|
|
|
|
#define _WX_PRIVATE_H_
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
2003-01-17 05:27:48 -05:00
|
|
|
#include "wx/app.h"
|
1999-01-01 11:05:26 -05:00
|
|
|
|
2003-01-28 17:23:02 -05:00
|
|
|
#ifdef __DARWIN__
|
2002-01-06 10:42:13 -05:00
|
|
|
# include <Carbon/Carbon.h>
|
2002-01-04 12:13:39 -05:00
|
|
|
#else
|
2002-01-11 09:01:42 -05:00
|
|
|
# include <Quickdraw.h>
|
|
|
|
# include <Appearance.h>
|
|
|
|
# include <Folders.h>
|
|
|
|
# include <Controls.h>
|
|
|
|
# include <ControlDefinitions.h>
|
|
|
|
# include <LowMem.h>
|
|
|
|
# include <Gestalt.h>
|
2002-01-04 12:13:39 -05:00
|
|
|
#endif
|
2002-01-11 09:01:42 -05:00
|
|
|
|
2002-01-04 12:13:39 -05:00
|
|
|
#if UNIVERSAL_INTERFACES_VERSION < 0x0340
|
|
|
|
#error "please update to Apple's lastest universal headers from http://developer.apple.com/sdk/"
|
|
|
|
#endif
|
|
|
|
|
2003-06-28 20:32:06 -04:00
|
|
|
#if wxUSE_GUI
|
|
|
|
|
2002-01-06 10:42:13 -05:00
|
|
|
#include "wx/window.h"
|
|
|
|
|
2002-01-04 12:13:39 -05:00
|
|
|
class wxMacPortStateHelper
|
|
|
|
{
|
2002-05-07 17:58:27 -04:00
|
|
|
DECLARE_NO_COPY_CLASS(wxMacPortStateHelper)
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxMacPortStateHelper( GrafPtr newport) ;
|
|
|
|
wxMacPortStateHelper() ;
|
|
|
|
~wxMacPortStateHelper() ;
|
2002-01-04 12:13:39 -05:00
|
|
|
|
2002-05-07 17:58:27 -04:00
|
|
|
void Setup( GrafPtr newport ) ;
|
|
|
|
void Clear() ;
|
|
|
|
bool IsCleared() { return m_clip == NULL ; }
|
|
|
|
GrafPtr GetCurrentPort() { return m_currentPort ; }
|
2002-01-04 12:13:39 -05:00
|
|
|
|
2002-05-07 17:58:27 -04:00
|
|
|
private:
|
2003-02-28 18:48:13 -05:00
|
|
|
GrafPtr m_currentPort ;
|
|
|
|
GrafPtr m_oldPort ;
|
|
|
|
RgnHandle m_clip ;
|
2002-05-07 17:58:27 -04:00
|
|
|
ThemeDrawingState m_drawingState ;
|
2003-02-28 18:48:13 -05:00
|
|
|
short m_textFont ;
|
|
|
|
short m_textSize ;
|
|
|
|
short m_textStyle ;
|
|
|
|
short m_textMode ;
|
2002-01-04 12:13:39 -05:00
|
|
|
} ;
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxMacPortSetter
|
|
|
|
{
|
2002-05-07 17:58:27 -04:00
|
|
|
DECLARE_NO_COPY_CLASS(wxMacPortSetter)
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxMacPortSetter( const wxDC* dc ) ;
|
|
|
|
~wxMacPortSetter() ;
|
|
|
|
private:
|
|
|
|
wxMacPortStateHelper m_ph ;
|
|
|
|
const wxDC* m_dc ;
|
2002-01-04 12:13:39 -05:00
|
|
|
} ;
|
|
|
|
|
2002-08-10 05:36:09 -04:00
|
|
|
class WXDLLEXPORT wxMacWindowClipper
|
|
|
|
{
|
|
|
|
DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxMacWindowClipper( const wxWindow* win ) ;
|
|
|
|
~wxMacWindowClipper() ;
|
|
|
|
private:
|
|
|
|
RgnHandle m_formerClip ;
|
|
|
|
RgnHandle m_newClip ;
|
|
|
|
} ;
|
|
|
|
|
2002-01-04 12:13:39 -05:00
|
|
|
class wxMacDrawingHelper
|
|
|
|
{
|
2002-05-07 17:58:27 -04:00
|
|
|
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 ;
|
2002-01-04 12:13:39 -05:00
|
|
|
} ;
|
|
|
|
|
2002-05-20 16:33:13 -04:00
|
|
|
// app.h
|
|
|
|
bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ;
|
2002-01-04 12:13:39 -05:00
|
|
|
|
2003-06-28 20:32:06 -04:00
|
|
|
#endif // wxUSE_GUI
|
|
|
|
|
2002-01-04 12:13:39 -05:00
|
|
|
// filefn.h
|
|
|
|
WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
|
|
|
|
WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ;
|
2003-03-27 15:14:39 -05:00
|
|
|
WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec ) ;
|
2002-01-04 12:13:39 -05:00
|
|
|
# ifndef __DARWIN__
|
|
|
|
// Mac file names are POSIX (Unix style) under Darwin, so these are not needed
|
|
|
|
WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ;
|
|
|
|
WXDLLEXPORT void wxUnixFilename2FSSpec( const char *path , FSSpec *spec ) ;
|
|
|
|
WXDLLEXPORT wxString wxMac2UnixFilename( const char *s) ;
|
|
|
|
WXDLLEXPORT wxString wxUnix2MacFilename( const char *s);
|
|
|
|
# endif
|
|
|
|
|
|
|
|
// utils.h
|
|
|
|
WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
|
|
|
|
OSType folderType,
|
|
|
|
Boolean createFolder);
|
|
|
|
|
2003-06-28 20:32:06 -04:00
|
|
|
#if wxUSE_GUI
|
|
|
|
|
2003-02-28 18:48:13 -05:00
|
|
|
GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
|
|
|
|
void wxMacDestroyGWorld( GWorldPtr gw ) ;
|
|
|
|
PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
|
2002-01-04 12:13:39 -05:00
|
|
|
CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
|
2003-02-28 18:48:13 -05:00
|
|
|
void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
|
|
|
|
CTabHandle wxMacCreateColorTable( int numColors ) ;
|
2002-12-04 09:11:26 -05:00
|
|
|
void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ;
|
1999-01-01 11:05:26 -05:00
|
|
|
|
2002-01-04 12:13:39 -05:00
|
|
|
#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
|
|
|
|
#define MAC_WXHBITMAP(a) (GWorldPtr(a))
|
|
|
|
#define MAC_WXHMETAFILE(a) (PicHandle(a))
|
|
|
|
#define MAC_WXHICON(a) (CIconHandle(a))
|
|
|
|
#define MAC_WXHCURSOR(a) (CursHandle(a))
|
|
|
|
#define MAC_WXHRGN(a) (RgnHandle(a))
|
|
|
|
#define MAC_WXHWND(a) (WindowPtr(a))
|
|
|
|
#define MAC_WXRECPTR(a) ((Rect*)a)
|
|
|
|
#define MAC_WXPOINTPTR(a) ((Point*)a)
|
|
|
|
#define MAC_WXHMENU(a) ((MenuHandle)a)
|
2003-01-11 06:56:48 -05:00
|
|
|
|
2003-06-28 20:32:06 -04:00
|
|
|
#endif // wxUSE_GUI
|
|
|
|
|
2003-01-29 09:58:01 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// wxMac string conversions
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2003-03-27 15:14:39 -05:00
|
|
|
void wxMacSetupConverters() ;
|
|
|
|
void wxMacCleanupConverters() ;
|
|
|
|
|
|
|
|
void wxMacStringToPascal( const wxString&from , StringPtr to ) ;
|
|
|
|
wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ;
|
|
|
|
|
|
|
|
wxCharBuffer wxMacStringToCString( const wxString &from ) ;
|
|
|
|
wxWCharBuffer wxMacStringToWString( const wxString &from ) ;
|
|
|
|
wxString wxMacMakeStringFromCString( const char * from , int len ) ;
|
|
|
|
wxString wxMacMakeStringFromCString( const char * from ) ;
|
|
|
|
|
|
|
|
#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 ;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
// CFStringRef wxMacStringToCFString( const wxString &str ) ;
|
|
|
|
// wxString wxMacMakeStringFromCFString( CFStringRef cf ) ;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
2003-01-29 09:58:01 -05:00
|
|
|
void wxMacConvertToPC( const char *from , char *to , int len ) ;
|
|
|
|
void wxMacConvertFromPC( const char *from , char *to , int len ) ;
|
|
|
|
void wxMacConvertToPC( const char *from , char *to , int len ) ;
|
|
|
|
|
2003-03-27 15:14:39 -05:00
|
|
|
wxString wxMacMakeMacStringFromPC( const wxChar * p ) ;
|
|
|
|
|
|
|
|
wxString wxMacMakePCStringFromMac( const wxChar * p ) ;
|
|
|
|
|
|
|
|
|
|
|
|
// converts this c string into a wxString with optional mac 2 pc encoding
|
|
|
|
wxString wxMacMakeStringFromMacString( const wxChar* from , bool mac2pcEncoding ) ;
|
|
|
|
|
|
|
|
// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
|
|
|
|
inline wxString wxMacMakeStringFromMacString( const wxChar* from )
|
|
|
|
{ return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
|
|
|
|
|
|
|
|
#if wxUSE_UNICODE
|
|
|
|
|
2003-01-29 09:58:01 -05:00
|
|
|
wxString wxMacMakeMacStringFromPC( const char * p ) ;
|
|
|
|
|
|
|
|
wxString wxMacMakePCStringFromMac( const char * p ) ;
|
|
|
|
|
|
|
|
// converts this c string into a wxString with optional mac 2 pc encoding
|
|
|
|
wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ;
|
|
|
|
|
|
|
|
// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
|
|
|
|
inline wxString wxMacMakeStringFromMacString( const char* from )
|
|
|
|
{ return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
|
|
|
|
|
2003-03-27 15:14:39 -05:00
|
|
|
#endif
|
|
|
|
|
2003-01-29 09:58:01 -05:00
|
|
|
// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
|
|
|
|
inline wxString wxMacMakeStringFromMacString( const wxString& from )
|
|
|
|
{ return wxApp::s_macDefaultEncodingIsPC ?
|
2003-02-28 18:48:13 -05:00
|
|
|
wxMacMakeStringFromMacString( from.c_str() , true ) : from ; }
|
2003-01-29 09:58:01 -05:00
|
|
|
|
|
|
|
//
|
|
|
|
// Pascal Strings
|
|
|
|
//
|
|
|
|
|
|
|
|
// converts this string into a pascal with optional pc 2 mac encoding
|
2003-03-27 15:14:39 -05:00
|
|
|
void wxMacStringToPascal( const wxChar * from , StringPtr to , bool pc2macEncoding ) ;
|
2003-01-29 09:58:01 -05:00
|
|
|
|
|
|
|
// converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
|
2003-03-27 15:14:39 -05:00
|
|
|
inline void wxMacStringToPascal( const wxChar * from , StringPtr to )
|
2003-01-29 09:58:01 -05:00
|
|
|
{ wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; }
|
|
|
|
|
|
|
|
// converts this string into a pascal with optional mac 2 pc encoding
|
|
|
|
wxString wxMacMakeStringFromPascal( ConstStringPtr from , bool mac2pcEncoding ) ;
|
|
|
|
|
|
|
|
// converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
|
|
|
|
inline wxString wxMacMakeStringFromPascal( ConstStringPtr from )
|
|
|
|
{ return wxMacMakeStringFromPascal( from , wxApp::s_macDefaultEncodingIsPC ) ; }
|
|
|
|
|
|
|
|
//
|
|
|
|
// CFStringRefs (Carbon only)
|
|
|
|
//
|
2003-01-28 02:00:57 -05:00
|
|
|
|
2003-01-11 06:56:48 -05:00
|
|
|
#if TARGET_CARBON
|
|
|
|
// converts this string into a carbon foundation string with optional pc 2 mac encoding
|
2003-03-27 15:14:39 -05:00
|
|
|
CFStringRef wxMacStringToCFString( const wxString &str , bool pc2macEncoding ) ;
|
2003-01-11 06:56:48 -05:00
|
|
|
|
|
|
|
// converts this string into a carbon foundation string with optional pc 2 mac encoding
|
2003-03-27 15:14:39 -05:00
|
|
|
inline CFStringRef wxMacStringToCFString( const wxString &str )
|
|
|
|
{ return wxMacStringToCFString( str , wxApp::s_macDefaultEncodingIsPC ) ; }
|
2003-01-11 06:56:48 -05:00
|
|
|
|
|
|
|
#endif //TARGET_CARBON
|
|
|
|
|
2003-06-28 20:32:06 -04:00
|
|
|
#endif // 0
|
2003-01-28 02:00:57 -05:00
|
|
|
|
1999-01-01 11:05:26 -05:00
|
|
|
#endif
|
|
|
|
// _WX_PRIVATE_H_
|