wxMac completed so far, generic listctrl extension

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4477 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
1999-11-11 16:11:14 +00:00
parent 8c651ab787
commit 7c74e7fe1d
51 changed files with 1069 additions and 144 deletions

View File

@@ -203,8 +203,9 @@ wxPrintData::wxPrintData(const wxPrintData& printData)
{
#ifdef __WXMSW__
m_devMode = NULL;
#elif defined( __WXMAC__ )
m_macPrintInfo = NULL ;
#endif
(*this) = printData;
}
@@ -692,6 +693,8 @@ wxPrintDialogData::wxPrintDialogData()
{
#ifdef __WXMSW__
m_printDlgData = NULL;
#elif defined( __WXMAC__ )
m_macPrintInfo = NULL ;
#endif
m_printFromPage = 0;
m_printToPage = 0;
@@ -711,6 +714,11 @@ wxPrintDialogData::wxPrintDialogData()
wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData)
{
#ifdef __WXMSW__
m_printDlgData = NULL;
#elif defined( __WXMAC__ )
m_macPrintInfo = NULL ;
#endif
(*this) = dialogData;
}
@@ -994,6 +1002,11 @@ wxPageSetupDialogData::wxPageSetupDialogData()
wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData)
{
#if defined(__WIN95__)
m_pageSetupData = NULL;
#elif defined( __WXMAC__ )
m_macPageSetupInfo = NULL ;
#endif
(*this) = dialogData;
}
@@ -1210,7 +1223,7 @@ void wxPageSetupDialogData::SetOwnerWindow(wxWindow* win)
#endif // Win95
#ifdef __WXMAC__
void wxPageSetupData::ConvertToNative()
void wxPageSetupDialogData::ConvertToNative()
{
if ( !m_macPageSetupInfo )
{
@@ -1239,7 +1252,7 @@ void wxPageSetupData::ConvertToNative()
}
}
void wxPageSetupData::ConvertFromNative()
void wxPageSetupDialogData::ConvertFromNative()
{
if ( m_macPageSetupInfo )
{

View File

@@ -196,6 +196,11 @@ bool wxConfigBase::Write(const wxString& key, bool value)
return Write(key, l);
}
bool wxConfigBase::Write( const wxString &key, const wxChar *text )
{
wxString str( text ) ;
return Write( key, str ) ;
}
wxString wxConfigBase::ExpandEnvVars(const wxString& str) const
{
wxString tmp; // Required for BC++

View File

@@ -64,12 +64,20 @@ bool wxFFile::Open(const wxChar *filename, const char *mode)
tmp_fname = new char[fname_len];
wxWX2MB(tmp_fname, filename, fname_len);
#ifdef __WXMAC__
m_fp = fopen(wxUnix2MacFilename( tmp_fname ), mode);
#else
m_fp = fopen(tmp_fname, mode);
#endif
delete tmp_fname;
#else
#ifdef __WXMAC__
m_fp = fopen(wxUnix2MacFilename( filename ), mode);
#else
m_fp = fopen(filename, mode);
#endif
#endif
if ( !m_fp )

View File

@@ -141,12 +141,6 @@
#define MAX_PATH 512
#endif
#ifdef __WXMAC__
char gwxMacFileName[ MAX_PATH ] ;
char gwxMacFileName2[ MAX_PATH ] ;
char gwxMacFileName3[ MAX_PATH ] ;
#endif
// some broken compilers don't have 3rd argument in open() and creat()
#ifdef __SALFORDC__
#define ACCESS(access)
@@ -168,14 +162,22 @@ bool wxFile::Exists(const wxChar *name)
#if wxUSE_UNICODE && wxMBFILES
wxCharBuffer fname = wxConvFile.cWC2MB(name);
#ifdef __WXMAC__
return !access(wxUnix2MacFilename( name ) , 0) && !stat(wxUnix2MacFilename( name ), &st) && (st.st_mode & S_IFREG);
#else
return !access(fname, 0) &&
!stat(wxMBSTRINGCAST fname, &st) &&
(st.st_mode & S_IFREG);
#endif
#else
#ifdef __WXMAC__
return !access(wxUnix2MacFilename( name ) , 0) && !stat(wxUnix2MacFilename( name ), &st) && (st.st_mode & S_IFREG);
#else
return !access(name, 0) &&
!stat((wxChar*) name, &st) &&
(st.st_mode & S_IFREG);
#endif
#endif
}
bool wxFile::Access(const wxChar *name, OpenMode mode)
@@ -216,10 +218,13 @@ bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode)
{
// if bOverwrite we create a new file or truncate the existing one,
// otherwise we only create the new file and fail if it already exists
#ifdef __WXMAC__
int fd = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
#else
int fd = open(wxFNCONV(szFileName),
O_WRONLY | O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL)
ACCESS(accessMode));
#endif
if ( fd == -1 ) {
wxLogSysError(_("can't create file '%s'"), szFileName);
return FALSE;
@@ -253,8 +258,11 @@ bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode)
break;
}
#ifdef __WXMAC__
int fd = open(wxUnix2MacFilename( szFileName ), flags, access);
#else
int fd = open(wxFNCONV(szFileName), flags ACCESS(accessMode));
#endif
if ( fd == -1 ) {
wxLogSysError(_("can't open file '%s'"), szFileName);
return FALSE;
@@ -562,6 +570,7 @@ bool wxTempFile::Commit()
{
m_file.Close();
#ifndef __WXMAC__
if ( wxFile::Exists(m_strName) && remove(m_strName.fn_str()) != 0 ) {
wxLogSysError(_("can't remove file '%s'"), m_strName.c_str());
return FALSE;
@@ -571,6 +580,17 @@ bool wxTempFile::Commit()
wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str());
return FALSE;
}
#else
if ( wxFile::Exists(m_strName) && remove(wxUnix2MacFilename( m_strName )) != 0 ) {
wxLogSysError(_("can't remove file '%s'"), m_strName.c_str());
return FALSE;
}
if ( rename(wxUnix2MacFilename( m_strTemp ), wxUnix2MacFilename( m_strName )) != 0 ) {
wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str());
return FALSE;
}
#endif
return TRUE;
}
@@ -578,8 +598,13 @@ bool wxTempFile::Commit()
void wxTempFile::Discard()
{
m_file.Close();
#ifndef __WXMAC__
if ( remove(m_strTemp.fn_str()) != 0 )
wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str());
#else
if ( remove( wxUnix2MacFilename(m_strTemp.fn_str())) != 0 )
wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str());
#endif
}
#endif

View File

@@ -194,7 +194,19 @@ wxString wxFileConfig::GetGlobalDir()
#elif defined(__WXSTUBS__)
wxASSERT_MSG( FALSE, wxT("TODO") ) ;
#elif defined(__WXMAC__)
wxASSERT_MSG( FALSE, wxT("TODO") ) ;
{
short vRefNum ;
long dirID ;
if ( FindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, &vRefNum, &dirID) == noErr)
{
FSSpec file ;
if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
{
strDir = wxMacFSSpec2UnixFilename( &file ) + "/" ;
}
}
}
#else // Windows
wxChar szWinDir[MAX_PATH];
::GetWindowsDirectory(szWinDir, MAX_PATH);
@@ -210,6 +222,7 @@ wxString wxFileConfig::GetLocalDir()
{
wxString strDir;
#ifndef __WXMAC__
wxGetHomeDir(&strDir);
#ifdef __UNIX__
@@ -217,6 +230,10 @@ wxString wxFileConfig::GetLocalDir()
#else
if (strDir.Last() != wxT('\\')) strDir << wxT('\\');
#endif
#else
// no local dir concept on mac
return GetGlobalDir() ;
#endif
return strDir;
}
@@ -229,6 +246,8 @@ wxString wxFileConfig::GetGlobalFileName(const wxChar *szFile)
if ( wxStrchr(szFile, wxT('.')) == NULL )
#ifdef __UNIX__
str << wxT(".conf");
#elif defined( __WXMAC__ )
str << " Preferences";
#else // Windows
str << wxT(".ini");
#endif // UNIX/Win
@@ -251,6 +270,10 @@ wxString wxFileConfig::GetLocalFileName(const wxChar *szFile)
str << wxT(".ini");
#endif
#ifdef __WXMAC__
str << " Preferences";
#endif
return str;
}
@@ -749,7 +772,25 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */)
}
}
#ifndef __WXMAC__
return file.Commit();
#else
bool ret = file.Commit();
if ( ret )
{
FSSpec spec ;
wxUnixFilename2FSSpec( m_strLocalFile , &spec ) ;
FInfo finfo ;
if ( FSpGetFInfo( &spec , &finfo ) == noErr )
{
finfo.fdType = 'TEXT' ;
finfo.fdCreator = 'ttxt' ;
FSpSetFInfo( &spec , &finfo ) ;
}
}
return ret ;
#endif
}
// ----------------------------------------------------------------------------

View File

@@ -1337,6 +1337,84 @@ wxString wxFindNextFile()
return result;
}
#elif defined(__WXMAC__)
struct MacDirectoryIterator
{
CInfoPBRec m_CPB ;
wxInt16 m_index ;
long m_dirId ;
Str255 m_name ;
} ;
static int g_iter_flags ;
static MacDirectoryIterator g_iter ;
wxString wxFindFirstFile(const wxChar *spec, int flags)
{
wxString result;
g_iter_flags = flags; /* MATTHEW: [5] Remember flags */
// Find path only so we can concatenate found file onto path
wxString path(wxPathOnly(spec));
if ( !path.IsEmpty() )
result << path << wxT('\\');
FSSpec fsspec ;
wxUnixFilename2FSSpec( result , &fsspec ) ;
g_iter.m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
g_iter.m_CPB.hFileInfo.ioNamePtr = g_iter.m_name ;
g_iter.m_index = 0 ;
Boolean isDir ;
FSpGetDirectoryID( &fsspec , &g_iter.m_dirId , &isDir ) ;
if ( !isDir )
return wxEmptyString ;
return wxFindNextFile( ) ;
}
wxString wxFindNextFile()
{
wxString result;
short err = noErr ;
while ( err == noErr )
{
g_iter.m_index++ ;
g_iter.m_CPB.dirInfo.ioFDirIndex = g_iter.m_index;
g_iter.m_CPB.dirInfo.ioDrDirID = g_iter.m_dirId; /* we need to do this every time */
err = PBGetCatInfoSync((CInfoPBPtr)&g_iter.m_CPB);
if ( err != noErr )
break ;
if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (g_iter_flags & wxDIR) ) // we have a directory
break ;
if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(g_iter_flags & wxFILE ) )
continue ;
// hit !
break ;
}
if ( err != noErr )
{
return wxEmptyString ;
}
FSSpec spec ;
FSMakeFSSpecCompat(g_iter.m_CPB.hFileInfo.ioVRefNum,
g_iter.m_dirId,
g_iter.m_name,
&spec) ;
return wxMacFSSpec2UnixFilename( &spec ) ;
}
#elif defined(__WXMSW__)
#ifdef __WIN32__
@@ -1521,14 +1599,25 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
strcpy( buf , res ) ;
if (0)
if (0) {
#else
if (getcwd(cbuf, sz) == NULL) {
#endif
delete [] cbuf;
#else
#else // wxUnicode
#ifdef _MSC_VER
if (_getcwd(buf, sz) == NULL) {
#elif defined( __WXMAC__)
enum
{
SFSaveDisk = 0x214, CurDirStore = 0x398
};
FSSpec cwdSpec ;
FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
strcpy( buf , res ) ;
if (0) {
#else
if (getcwd(buf, sz) == NULL) {
#endif

View File

@@ -1034,6 +1034,243 @@ wxImage::wxImage( const wxBitmap &bitmap )
#endif
#ifdef __WXMAC__
#include <PictUtils.h>
extern CTabHandle wxMacCreateColorTable( int numColors ) ;
extern void wxMacDestroyColorTable( CTabHandle colors ) ;
extern void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
extern GWorldPtr wxMacCreateGWorld( int height , int width , int depth ) ;
extern void wxMacDestroyGWorld( GWorldPtr gw ) ;
wxBitmap wxImage::ConvertToBitmap() const
{
// width and height of the device-dependent bitmap
int width = GetWidth();
int height = GetHeight();
// Create picture
wxBitmap bitmap( width , height , wxDisplayDepth() ) ;
// Create mask
if (HasMask())
{
/*
unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height );
mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height );
wxMask *mask = new wxMask();
mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 );
bitmap.SetMask( mask );
*/
}
// Render
int r_mask = GetMaskRed();
int g_mask = GetMaskGreen();
int b_mask = GetMaskBlue();
CGrafPtr origPort ;
GDHandle origDevice ;
GetGWorld( &origPort , &origDevice ) ;
SetGWorld( bitmap.GetHBITMAP() , NULL ) ;
register unsigned char* data = GetData();
int index = 0;
for (int y = 0; y < height; y++)
{
#if 0
unsigned char lastr = 0 ;
unsigned char lastg = 0 ;
unsigned char lastb = 0 ;
RGBColor lastcolor ;
MoveTo( 0 , y ) ;
for (int x = 0; x < width; x++)
{
unsigned char r = data[index++];
unsigned char g = data[index++];
unsigned char b = data[index++];
if ( r != lastr || g != lastg || b != lastb )
{
lastcolor.red = ( lastr << 8 ) + lastr ;
lastcolor.green = ( lastg << 8 ) + lastg ;
lastcolor.blue = ( lastb << 8 ) + lastb ;
RGBForeColor( &lastcolor ) ;
LineTo( x , y ) ;
lastr = r ;
lastg = g ;
lastb = b ;
}
} // for width
lastcolor.red = ( lastr << 8 ) + lastr ;
lastcolor.green = ( lastg << 8 ) + lastg ;
lastcolor.blue = ( lastb << 8 ) + lastb ;
RGBForeColor( &lastcolor ) ;
LineTo( width - 1 , y ) ;
#else
for (int x = 0; x < width; x++)
{
unsigned char r = data[index++];
unsigned char g = data[index++];
unsigned char b = data[index++];
RGBColor color ;
color.red = ( r << 8 ) + r ;
color.green = ( g << 8 ) + g ;
color.blue = ( b << 8 ) + b ;
SetCPixel( x , y , &color ) ;
}
#endif
} // for height
SetGWorld( origPort , origDevice ) ;
return bitmap;
}
wxImage::wxImage( const wxBitmap &bitmap )
{
// check the bitmap
if( !bitmap.Ok() )
{
wxFAIL_MSG( "invalid bitmap" );
return;
}
// create an wxImage object
int width = bitmap.GetWidth();
int height = bitmap.GetHeight();
Create( width, height );
/*
unsigned char *data = GetData();
if( !data )
{
wxFAIL_MSG( "could not allocate data for image" );
return;
}
// calc the number of bytes per scanline and padding in the DIB
int bytePerLine = width*3;
int sizeDWORD = sizeof( DWORD );
div_t lineBoundary = div( bytePerLine, sizeDWORD );
int padding = 0;
if( lineBoundary.rem > 0 )
{
padding = sizeDWORD - lineBoundary.rem;
bytePerLine += padding;
}
// create a DIB header
int headersize = sizeof(BITMAPINFOHEADER);
LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize );
if( !lpDIBh )
{
wxFAIL_MSG( "could not allocate data for DIB header" );
free( data );
return;
}
// Fill in the DIB header
lpDIBh->bmiHeader.biSize = headersize;
lpDIBh->bmiHeader.biWidth = width;
lpDIBh->bmiHeader.biHeight = -height;
lpDIBh->bmiHeader.biSizeImage = bytePerLine * height;
lpDIBh->bmiHeader.biPlanes = 1;
lpDIBh->bmiHeader.biBitCount = 24;
lpDIBh->bmiHeader.biCompression = BI_RGB;
lpDIBh->bmiHeader.biClrUsed = 0;
// These seem not really needed for our purpose here.
lpDIBh->bmiHeader.biClrImportant = 0;
lpDIBh->bmiHeader.biXPelsPerMeter = 0;
lpDIBh->bmiHeader.biYPelsPerMeter = 0;
// memory for DIB data
unsigned char *lpBits;
lpBits = (unsigned char *) malloc( lpDIBh->bmiHeader.biSizeImage );
if( !lpBits )
{
wxFAIL_MSG( "could not allocate data for DIB" );
free( data );
free( lpDIBh );
return;
}
// copy data from the device-dependent bitmap to the DIB
HDC hdc = ::GetDC(NULL);
HBITMAP hbitmap;
hbitmap = (HBITMAP) bitmap.GetHBITMAP();
::GetDIBits( hdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS );
// copy DIB data into the wxImage object
int i, j;
unsigned char *ptdata = data;
unsigned char *ptbits = lpBits;
for( i=0; i<height; i++ )
{
for( j=0; j<width; j++ )
{
*(ptdata++) = *(ptbits+2);
*(ptdata++) = *(ptbits+1);
*(ptdata++) = *(ptbits );
ptbits += 3;
}
ptbits += padding;
}
// similarly, set data according to the possible mask bitmap
if( bitmap.GetMask() && bitmap.GetMask()->GetMaskBitmap() )
{
hbitmap = (HBITMAP) bitmap.GetMask()->GetMaskBitmap();
// memory DC created, color set, data copied, and memory DC deleted
HDC memdc = ::CreateCompatibleDC( hdc );
::SetTextColor( memdc, RGB( 0, 0, 0 ) );
::SetBkColor( memdc, RGB( 255, 255, 255 ) );
::GetDIBits( memdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS );
::DeleteDC( memdc );
// background color set to RGB(16,16,16) in consistent with wxGTK
unsigned char r=16, g=16, b=16;
ptdata = data;
ptbits = lpBits;
for( i=0; i<height; i++ )
{
for( j=0; j<width; j++ )
{
if( *ptbits != 0 )
ptdata += 3;
else
{
*(ptdata++) = r;
*(ptdata++) = g;
*(ptdata++) = b;
}
ptbits += 3;
}
ptbits += padding;
}
SetMaskColour( r, g, b );
SetMask( TRUE );
}
else
{
SetMask( FALSE );
}
// free allocated resources
::ReleaseDC(NULL, hdc);
free(lpDIBh);
free(lpBits);
*/
}
#endif
//-----------------------------------------------------------------------------
// GTK conversion routines
//-----------------------------------------------------------------------------

View File

@@ -146,6 +146,59 @@ private:
wxArrayFileTypeInfo m_fallbacks;
};
#elif defined( __WXMAC__ )
WX_DECLARE_EXPORTED_OBJARRAY(wxFileTypeInfo, wxArrayFileTypeInfo);
#include "wx/arrimpl.cpp"
WX_DEFINE_OBJARRAY(wxArrayFileTypeInfo);
class wxMimeTypesManagerImpl
{
public :
wxMimeTypesManagerImpl() { }
// implement containing class functions
wxFileType *GetFileTypeFromExtension(const wxString& ext);
wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
// this are NOPs under MacOS
bool ReadMailcap(const wxString& filename, bool fallback = TRUE) { return TRUE; }
bool ReadMimeTypes(const wxString& filename) { return TRUE; }
void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); }
private:
wxArrayFileTypeInfo m_fallbacks;
};
class wxFileTypeImpl
{
public:
// initialize us with our file type name
void SetFileType(const wxString& strFileType)
{ m_strFileType = strFileType; }
void SetExt(const wxString& ext)
{ m_ext = ext; }
// implement accessor functions
bool GetExtensions(wxArrayString& extensions);
bool GetMimeType(wxString *mimeType) const;
bool GetIcon(wxIcon *icon) const;
bool GetDescription(wxString *desc) const;
bool GetOpenCommand(wxString *openCmd,
const wxFileType::MessageParameters&) const
{ return GetCommand(openCmd, "open"); }
bool GetPrintCommand(wxString *printCmd,
const wxFileType::MessageParameters&) const
{ return GetCommand(printCmd, "print"); }
private:
// helper function
bool GetCommand(wxString *command, const char *verb) const;
wxString m_strFileType, m_ext;
};
#else // Unix
// this class uses both mailcap and mime.types to gather information about file
@@ -876,6 +929,121 @@ wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
return NULL;
}
#elif defined ( __WXMAC__ )
bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
{
return FALSE;
}
// @@ this function is half implemented
bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
{
return FALSE;
}
bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
{
if ( m_strFileType.Length() > 0 )
{
*mimeType = m_strFileType ;
return TRUE ;
}
else
return FALSE;
}
bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
{
// no such file type or no value or incorrect icon entry
return FALSE;
}
bool wxFileTypeImpl::GetDescription(wxString *desc) const
{
return FALSE;
}
// extension -> file type
wxFileType *
wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
{
wxString ext = e ;
ext = ext.Lower() ;
if ( ext == "txt" )
{
wxFileType *fileType = new wxFileType;
fileType->m_impl->SetFileType("text/text");
fileType->m_impl->SetExt(ext);
return fileType;
}
else if ( ext == "htm" || ext == "html" )
{
wxFileType *fileType = new wxFileType;
fileType->m_impl->SetFileType("text/html");
fileType->m_impl->SetExt(ext);
return fileType;
}
else if ( ext == "gif" )
{
wxFileType *fileType = new wxFileType;
fileType->m_impl->SetFileType("image/gif");
fileType->m_impl->SetExt(ext);
return fileType;
}
else if ( ext == "png" )
{
wxFileType *fileType = new wxFileType;
fileType->m_impl->SetFileType("image/png");
fileType->m_impl->SetExt(ext);
return fileType;
}
else if ( ext == "jpg" || ext == "jpeg" )
{
wxFileType *fileType = new wxFileType;
fileType->m_impl->SetFileType("image/jpeg");
fileType->m_impl->SetExt(ext);
return fileType;
}
else if ( ext == "bmp" )
{
wxFileType *fileType = new wxFileType;
fileType->m_impl->SetFileType("image/bmp");
fileType->m_impl->SetExt(ext);
return fileType;
}
else if ( ext == "tif" || ext == "tiff" )
{
wxFileType *fileType = new wxFileType;
fileType->m_impl->SetFileType("image/tiff");
fileType->m_impl->SetExt(ext);
return fileType;
}
else if ( ext == "xpm" )
{
wxFileType *fileType = new wxFileType;
fileType->m_impl->SetFileType("image/xpm");
fileType->m_impl->SetExt(ext);
return fileType;
}
else if ( ext == "xbm" )
{
wxFileType *fileType = new wxFileType;
fileType->m_impl->SetFileType("image/xbm");
fileType->m_impl->SetExt(ext);
return fileType;
}
// unknown extension
return NULL;
}
// MIME type -> extension -> file type
wxFileType *
wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
{
return NULL;
}
#else // Unix
MailCapEntry *

View File

@@ -138,7 +138,7 @@ void wxObject::operator delete(void* pData, char* /* fileName */, int /* lineNum
#endif
// Cause problems for VC++ - crashes
#if !defined(__VISUALC__) && wxUSE_ARRAY_MEMORY_OPERATORS
#if (!defined(__VISUALC__) && wxUSE_ARRAY_MEMORY_OPERATORS ) || defined(__MWERKS__)
void * wxObject::operator new[] (size_t size, wxChar * fileName, int lineNum)
{
return wxDebugAlloc(size, fileName, lineNum, TRUE, TRUE);

View File

@@ -1545,6 +1545,10 @@ bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName,
SetClientSize(sz.x, sz.y);
wxPoint pt = ConvertDialogToPixels(wxPoint(x, y));
#ifdef __WXMAC__
int mbarheight = 2 * LMGetMBarHeight() ;
pt.y += mbarheight ;
#endif
Move(pt.x, pt.y);
}

View File

@@ -214,7 +214,11 @@ bool wxResourceTable::ParseResourceFile(const wxString& filename)
{
wxExprDatabase db;
#ifdef __WXMAC__
FILE *fd = fopen(wxUnix2MacFilename(filename.fn_str()), "r");
#else
FILE *fd = fopen(filename.fn_str(), "r");
#endif
if (!fd)
return FALSE;
bool eof = FALSE;

View File

@@ -351,6 +351,48 @@ local uLong unzlocal_SearchCentralDir(fin)
return uPosFound;
}
#ifdef __WXMAC__
void wxUnix2MacFilename (char *s) ;
void
wxUnix2MacFilename (char *s)
{
if (s)
{
if ( *s == '.' )
{
// relative path , since it goes on with slash which is translated to a :
memmove( s , s+1 ,strlen( s ) ) ;
}
else if ( *s == '/' )
{
// absolute path -> on mac just start with the drive name
memmove( s , s+1 ,strlen( s ) ) ;
}
else
{
// wxASSERT_MSG( 1 , "unkown path beginning" ) ;
}
while (*s)
{
if (*s == '/' || *s == '\\')
{
// convert any back-directory situations
if ( *(s+1) == '.' && *(s+2) == '.' && ( (*(s+3) == '/' || *(s+3) == '\\') ) )
{
*s = ':';
memmove( s+1 , s+3 ,strlen( s+3 ) + 1 ) ;
}
else
*s = ':';
}
s++ ;
}
}
}
extern char * wxBuffer ;
#endif
/*
Open a Zip file. path contain the full pathname (by example,
on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer
@@ -381,7 +423,13 @@ extern unzFile ZEXPORT unzOpen (path)
if (unz_copyright[0]!=' ')
return NULL;
#ifdef __WXMAC__
strcpy( wxBuffer , path ) ;
wxUnix2MacFilename( wxBuffer ) ;
fin=fopen(wxBuffer,"rb");
#else
fin=fopen(path,"rb");
#endif
if (fin==NULL)
return NULL;

View File

@@ -119,8 +119,11 @@ void wxWindowBase::InitBase()
m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_BTNFACE);
m_foregroundColour = *wxBLACK; // TODO take this from sys settings too?
#ifndef __WXMAC__
m_font = *wxSWISS_FONT; // and this?
#else
m_font = settings.GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
#endif
// no style bits
m_windowStyle = 0;