updated mac sources (CW 5.3 working , CW6 still having code gen problems)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9334 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2001-02-08 21:13:12 +00:00
parent 1db8dc4a2b
commit 5b781a6729
67 changed files with 1772 additions and 257 deletions

View File

@@ -172,6 +172,10 @@ wxPrintData::wxPrintData()
m_devMode = (void*) NULL;
m_devNames = (void*) NULL;
#elif defined( __WXMAC__ )
#if TARGET_CARBON
m_macPageFormat = kPMNoPageFormat;
m_macPrintSettings = kPMNoPrintSettings;
#else
m_macPrintInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ;
(**m_macPrintInfo).iPrVersion = 0; // something invalid
@@ -184,14 +188,7 @@ wxPrintData::wxPrintData()
(**m_macPrintInfo).rPaper = r2;
(**m_macPrintInfo).prStl.iPageV = 11 * 120 ; // 11 inches in 120th of an inch
(**m_macPrintInfo).prStl.iPageH = 8 * 120 ; // 8 inches in 120th of an inch
/*
UMAPrOpen() ;
m_macPrintInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ;
::PrintDefault( m_macPrintInfo ) ;
OSErr err = PrError() ;
UMAPrClose() ;
wxASSERT( err == noErr ) ;
*/
#endif
#endif
m_printOrientation = wxPORTRAIT;
m_printNoCopies = 1;
@@ -224,16 +221,12 @@ wxPrintData::wxPrintData(const wxPrintData& printData)
m_devMode = (void*) NULL;
m_devNames = (void*) NULL;
#elif defined( __WXMAC__ )
#if TARGET_CARBON
m_macPageFormat = kPMNoPageFormat;
m_macPrintSettings = kPMNoPrintSettings;
#else
m_macPrintInfo = NULL ;
/*
(THPrint) NewHandleClear( sizeof( TPrint ) ) ;
UMAPrOpen() ;
m_macPrintInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ;
::PrintDefault( m_macPrintInfo ) ;
OSErr err = PrError() ;
UMAPrClose() ;
wxASSERT( err == noErr ) ;
*/
#endif
#endif
(*this) = printData;
}
@@ -248,8 +241,22 @@ wxPrintData::~wxPrintData()
if ( hDevNames )
GlobalFree(hDevNames);
#elif defined(__WXMAC__)
#if TARGET_CARBON
if (m_macPageFormat != kPMNoPageFormat)
{
(void)PMDisposePageFormat(m_macPageFormat);
m_macPageFormat = kPMNoPageFormat;
}
if (m_macPrintSettings != kPMNoPrintSettings)
{
(void)PMDisposePrintSettings(m_macPrintSettings);
m_macPrintSettings = kPMNoPrintSettings;
}
#else
wxASSERT( m_macPrintInfo ) ;
// ::DisposeHandle( (Handle) m_macPrintInfo ) ;
// we should perhaps delete
#endif
#endif
}
@@ -432,6 +439,7 @@ void wxPrintData::ConvertToNative()
if (m_paperId == wxPAPER_NONE)
{
// DEVMODE is in tenths of a milimeter
devMode->dmPaperWidth = m_paperSize.x * 10;
devMode->dmPaperLength = m_paperSize.y * 10;
devMode->dmFields |= DM_PAPERWIDTH;
@@ -609,6 +617,7 @@ void wxPrintData::ConvertFromNative()
}
else if ((devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH))
{
// DEVMODE is in tenths of a milimeter
m_paperSize.x = devMode->dmPaperWidth / 10;
m_paperSize.y = devMode->dmPaperLength / 10;
m_paperId = wxPAPER_NONE;
@@ -709,20 +718,29 @@ void wxPrintData::ConvertFromNative()
#ifdef __WXMAC__
void wxPrintData::ConvertToNative()
{
#ifdef TARGET_CARBON
#else
(**m_macPrintInfo).prJob.iCopies = m_printNoCopies ;
#endif
}
void wxPrintData::ConvertFromNative()
{
#ifdef TARGET_CARBON
#else
m_printNoCopies = (**m_macPrintInfo).prJob.iCopies ;
#endif
}
#endif
void wxPrintData::operator=(const wxPrintData& data)
{
#ifdef __WXMAC__
#ifdef TARGET_CARBON
#else
m_macPrintInfo = data.m_macPrintInfo ;
HandToHand( (Handle*) &m_macPrintInfo ) ;
#endif
#endif
m_printNoCopies = data.m_printNoCopies;
m_printCollate = data.m_printCollate;
@@ -1019,16 +1037,22 @@ void wxPrintDialogData::SetOwnerWindow(wxWindow* win)
#ifdef __WXMAC__
void wxPrintDialogData::ConvertToNative()
{
#ifdef TARGET_CARBON
#else
(**m_printData.m_macPrintInfo).prJob.iFstPage = m_printFromPage ;
(**m_printData.m_macPrintInfo).prJob.iLstPage = m_printToPage ;
m_printData.ConvertToNative() ;
#endif
}
void wxPrintDialogData::ConvertFromNative()
{
#ifdef TARGET_CARBON
#else
m_printData.ConvertFromNative() ;
m_printFromPage = (**m_printData.m_macPrintInfo).prJob.iFstPage ;
m_printToPage = (**m_printData.m_macPrintInfo).prJob.iLstPage ;
#endif
}
#endif
@@ -1228,7 +1252,7 @@ void wxPageSetupDialogData::ConvertToNative()
pd->hwndOwner=(HWND)NULL;
// pd->hDevNames=(HWND)NULL;
pd->hInstance=(HINSTANCE)NULL;
// PAGESETUPDLG is in hundreds of a mm
pd->ptPaperSize.x = m_paperSize.x * 100;
pd->ptPaperSize.y = m_paperSize.y * 100;
@@ -1305,6 +1329,7 @@ void wxPageSetupDialogData::ConvertFromNative()
m_getDefaultInfo = ((pd->Flags & PSD_RETURNDEFAULT) == PSD_RETURNDEFAULT);
m_enableHelp = ((pd->Flags & PSD_SHOWHELP) == PSD_SHOWHELP);
// PAGESETUPDLG is in hundreds of a mm
m_paperSize.x = pd->ptPaperSize.x / 100;
m_paperSize.y = pd->ptPaperSize.y / 100;
@@ -1337,6 +1362,8 @@ void wxPageSetupDialogData::ConvertToNative()
{
m_printData.ConvertToNative() ;
// on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
#ifdef TARGET_CARBON
#else
(**m_printData.m_macPrintInfo).rPaper.left = int( ((double) m_minMarginTopLeft.x)*mm2pt ) ;
(**m_printData.m_macPrintInfo).rPaper.top = int( ((double) m_minMarginTopLeft.y)*mm2pt ) ;
@@ -1347,12 +1374,15 @@ void wxPageSetupDialogData::ConvertToNative()
(**m_printData.m_macPrintInfo).prInfo.rPage.top = 0 ;
(**m_printData.m_macPrintInfo).prInfo.rPage.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x - m_minMarginBottomRight.x)*mm2pt ) ;
(**m_printData.m_macPrintInfo).prInfo.rPage.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y - m_minMarginBottomRight.y)*mm2pt ) ;
#endif
}
void wxPageSetupDialogData::ConvertFromNative()
{
m_printData.ConvertFromNative () ;
#ifdef TARGET_CARBON
#else
m_paperSize.x = ((double) (**m_printData.m_macPrintInfo).rPaper.right - (**m_printData.m_macPrintInfo).rPaper.left ) * pt2mm ;
m_paperSize.y = ((double) (**m_printData.m_macPrintInfo).rPaper.bottom - (**m_printData.m_macPrintInfo).rPaper.top ) * pt2mm ;
@@ -1361,7 +1391,7 @@ void wxPageSetupDialogData::ConvertFromNative()
m_minMarginBottomRight.x = ((double) (**m_printData.m_macPrintInfo).rPaper.right - (**m_printData.m_macPrintInfo).prInfo.rPage.right ) * pt2mm ;
m_minMarginBottomRight.y = ((double)(**m_printData.m_macPrintInfo).rPaper.bottom - (**m_printData.m_macPrintInfo).prInfo.rPage.bottom ) * pt2mm ;
#endif
// adjust minimal values
//TODO add custom fields in dialog for margins

View File

@@ -69,7 +69,7 @@ char *malloc();
int free();
*/
int read();
//int read();
#endif

View File

@@ -22,10 +22,19 @@ int yylex(void);
int yylook(void);
int yywrap(void);
int yyback(int *, int);
#ifdef __WXMAC__
#if __MSL__ < 0x6000
int read( int , char * , int ) ;
#else
int _read( int , void * , size_t ) ;
#define read _read
#endif
#ifdef __WXMSW__
int fileno( FILE* ) ;
#else
#if __MSL__ < 0x6000
int fileno( void* ) ;
#endif
#endif
/* You may need to put /DLEX_SCANNER in your makefile
* if you're using LEX!

View File

@@ -68,12 +68,16 @@
// Have to ifdef this for different environments
#include <io.h>
#elif (defined(__WXMAC__))
#if __MSL__ < 0x6000
int access( const char *path, int mode ) { return 0 ; }
#else
int _access( const char *path, int mode ) { return 0 ; }
#endif
char* mktemp( char * path ) { return path ;}
#include <unistd.h>
#include <unix.h>
#include <stat.h>
#define W_OK 2
#define R_OK 4
#include <unistd.h>
#else
#error "Please specify the header with file functions declarations."
#endif //Win/UNIX
@@ -189,7 +193,9 @@ 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);
// Dominic Mazzoni [dmazzoni+@cs.cmu.edu] reports that open is still broken on the mac, so we replace
// int fd = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
int fd = creat(wxUnix2MacFilename( szFileName ), accessMode);
#else
int fd = wxOpen(wxFNCONV(szFileName),
O_BINARY | O_WRONLY | O_CREAT |
@@ -293,7 +299,11 @@ size_t wxFile::Write(const void *pBuf, size_t nCount)
wxCHECK( (pBuf != NULL) && IsOpened(), 0 );
#ifdef __MWERKS__
#if __MSL__ >= 0x6000
int iRc = ::write(m_fd, (void*) pBuf, nCount);
#else
int iRc = ::write(m_fd, (const char*) pBuf, nCount);
#endif
#else
int iRc = ::write(m_fd, pBuf, nCount);
#endif

View File

@@ -199,19 +199,7 @@ wxString wxFileConfig::GetGlobalDir()
#elif defined(__WXSTUBS__)
wxASSERT_MSG( FALSE, wxT("TODO") ) ;
#elif defined(__WXMAC__)
{
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 ) + "/" ;
}
}
}
strDir = wxMacFindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder ) ;
#else // Windows
wxChar szWinDir[MAX_PATH];
::GetWindowsDirectory(szWinDir, MAX_PATH);

View File

@@ -57,6 +57,7 @@
#else
#include <stat.h>
#include <unistd.h>
#include <unix.h>
#endif
#ifdef __UNIX__
@@ -1682,16 +1683,40 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
#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) {
FSSpec cwdSpec ;
FCBPBRec pb;
OSErr error;
Str255 fileName ;
pb.ioNamePtr = (StringPtr) &fileName;
pb.ioVRefNum = 0;
pb.ioRefNum = LMGetCurApRefNum();
pb.ioFCBIndx = 0;
error = PBGetFCBInfoSync(&pb);
if ( error == noErr )
{
cwdSpec.vRefNum = pb.ioFCBVRefNum;
cwdSpec.parID = pb.ioFCBParID;
cwdSpec.name[0] = 0 ;
wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
strcpy( buf , res ) ;
buf[res.length()-1]=0 ;
}
else
buf[0] = 0 ;
/*
this version will not always give back the application directory on mac
enum
{
SFSaveDisk = 0x214, CurDirStore = 0x398
};
FSSpec cwdSpec ;
FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
strcpy( buf , res ) ;
*/
if (0) {
#elif(__VISAGECPP__)
APIRET rc;
rc = ::DosQueryCurrentDir( 0 // current drive