corrections for final release of Mac OS X

applied patches proposed by Mark Newsam


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9625 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Gilles Depeyrot
2001-04-01 20:42:05 +00:00
parent 67bd5bad04
commit 5fde6fcc9b
73 changed files with 1242 additions and 872 deletions

View File

@@ -77,6 +77,9 @@ protected:
int m_min; int m_min;
int m_max; int m_max;
private:
DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
}; };
#endif // _WX_GENERIC_SPINCTRL_H_ #endif // _WX_GENERIC_SPINCTRL_H_

View File

@@ -32,7 +32,7 @@
#define wxMulDivInt32( a , b , c ) ::MulDiv( a , b , c ) #define wxMulDivInt32( a , b , c ) ::MulDiv( a , b , c )
#elif defined( __WXMAC__ ) #elif defined( __WXMAC__ )
#ifdef __WXMAC_X__ #ifdef __WXMAC_X__
#include <CarbonCore/Math64.h> #include <CoreServices/CoreServices.h>
#else #else
#include "Math64.h" #include "Math64.h"
#endif #endif

View File

@@ -44,6 +44,7 @@ See mod_*.cpp and htmlwin.cpp for example :-)
// This must be part of the module you want to force: // This must be part of the module you want to force:
#define FORCE_LINK_ME(module_name) \ #define FORCE_LINK_ME(module_name) \
int _link_dummy_func_##module_name (); \
int _link_dummy_func_##module_name () \ int _link_dummy_func_##module_name () \
{ \ { \
return 1; \ return 1; \

View File

@@ -61,6 +61,7 @@ public:
bool Create(const wxBitmap& bitmap); bool Create(const wxBitmap& bitmap);
// Implementation // Implementation
bool PointMasked(int x, int y);
inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; } inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; } inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
protected: protected:
@@ -153,28 +154,33 @@ public:
wxBitmap(int width, int height, int depth = -1); wxBitmap(int width, int height, int depth = -1);
~wxBitmap(); ~wxBitmap();
// get the given part of bitmap
wxBitmap GetSubBitmap( const wxRect& rect ) const;
virtual bool Create(int width, int height, int depth = -1); virtual bool Create(int width, int height, int depth = -1);
virtual bool Create(void *data, long type, int width, int height, int depth = 1); virtual bool Create(void *data, long type, int width, int height, int depth = 1);
virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE); virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE);
virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL); virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL);
inline bool Ok() const { return (M_BITMAPDATA && M_BITMAPDATA->m_ok); } bool Ok() const;
inline int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); } int GetWidth() const;
inline int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); } int GetHeight() const;
inline int GetDepth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_depth : 0); } int GetDepth() const;
inline int GetQuality() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_quality : 0); } int GetQuality() const;
void SetWidth(int w); void SetWidth(int w);
void SetHeight(int h); void SetHeight(int h);
void SetDepth(int d); void SetDepth(int d);
void SetQuality(int q); void SetQuality(int q);
void SetOk(bool isOk); void SetOk(bool isOk);
inline wxPalette* GetPalette() const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : (wxPalette*) NULL); } wxPalette* GetPalette() const;
void SetPalette(const wxPalette& palette); void SetPalette(const wxPalette& palette);
inline wxMask *GetMask() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_bitmapMask : (wxMask*) NULL); } wxMask *GetMask() const;
void SetMask(wxMask *mask) ; void SetMask(wxMask *mask) ;
int GetBitmapType() const;
inline wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; } inline wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; }
inline bool operator == (const wxBitmap& bitmap) { return m_refData == bitmap.m_refData; } inline bool operator == (const wxBitmap& bitmap) { return m_refData == bitmap.m_refData; }
inline bool operator != (const wxBitmap& bitmap) { return m_refData != bitmap.m_refData; } inline bool operator != (const wxBitmap& bitmap) { return m_refData != bitmap.m_refData; }
@@ -196,8 +202,10 @@ protected:
// TODO: Implementation // TODO: Implementation
public: public:
void SetHBITMAP(WXHBITMAP bmp); void SetHBITMAP(WXHBITMAP bmp);
inline WXHBITMAP GetHBITMAP() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_hBitmap : 0); } WXHBITMAP GetHBITMAP() const;
PicHandle GetPict() const;
bool FreeResource(bool force = FALSE); bool FreeResource(bool force = FALSE);
}; };
#endif #endif

View File

@@ -31,7 +31,7 @@ class WXDLLEXPORT wxChoice: public wxChoiceBase
public: public:
wxChoice() {} wxChoice() {}
~wxChoice() ; virtual ~wxChoice() ;
wxChoice(wxWindow *parent, wxWindowID id, wxChoice(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
@@ -52,12 +52,15 @@ class WXDLLEXPORT wxChoice: public wxChoiceBase
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr); const wxString& name = wxChoiceNameStr);
virtual int DoAppend(const wxString& item); // implement base class pure virtuals
virtual int DoAppend(const wxString& item);
virtual void Delete(int n); virtual void Delete(int n);
virtual void Clear(); virtual void Clear();
virtual int GetCount() const ; virtual int GetCount() const ;
virtual int GetSelection() const ; virtual int GetSelection() const ;
virtual void SetSelection(int n); virtual void SetSelection(int n);
virtual int FindString(const wxString& s) const; virtual int FindString(const wxString& s) const;
virtual wxString GetString(int n) const ; virtual wxString GetString(int n) const ;
virtual void SetString( int , const wxString& s ) ; virtual void SetString( int , const wxString& s ) ;
@@ -73,9 +76,9 @@ class WXDLLEXPORT wxChoice: public wxChoiceBase
virtual wxString GetStringSelection() const ; virtual wxString GetStringSelection() const ;
virtual bool SetStringSelection(const wxString& sel); virtual bool SetStringSelection(const wxString& sel);
virtual inline int Number() const { return m_strings.GetCount(); } // Mac specific
virtual inline int GetCount() const { return m_strings.GetCount(); }
virtual void Command(wxCommandEvent& event); virtual void Command(wxCommandEvent& event);
void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
virtual inline int GetColumns() const { return 1 ; }; virtual inline int GetColumns() const { return 1 ; };
*/ */

View File

@@ -156,7 +156,7 @@ class WXDLLEXPORT wxDropTarget: public wxObject
virtual void OnEnter() { } virtual void OnEnter() { }
virtual void OnLeave() { } virtual void OnLeave() { }
virtual bool OnDrop( long x, long y, const void *pData ) = 0; virtual bool OnDrop( wxCoord x, wxCoord y, const void *pData ) = 0;
// protected: // protected:
@@ -178,8 +178,8 @@ class WXDLLEXPORT wxTextDropTarget: public wxDropTarget
public: public:
wxTextDropTarget() {}; wxTextDropTarget() {};
virtual bool OnDrop( long x, long y, const void *pData ); virtual bool OnDrop( wxCoord x, wxCoord y, const void *pData );
virtual bool OnDropText( long x, long y, const char *psz ); virtual bool OnDropText( wxCoord x, wxCoord y, const char *psz );
protected: protected:
@@ -197,8 +197,8 @@ class WXDLLEXPORT wxFileDropTarget: public wxDropTarget
wxFileDropTarget() {}; wxFileDropTarget() {};
virtual bool OnDrop(long x, long y, const void *pData); virtual bool OnDrop(wxCoord x, wxCoord y, const void *pData);
virtual bool OnDropFiles( long x, long y, virtual bool OnDropFiles( wxCoord x, wxCoord y,
size_t nFiles, const char * const aszFiles[]); size_t nFiles, const char * const aszFiles[]);
protected: protected:

View File

@@ -20,7 +20,7 @@
#include "wx/gdiobj.h" #include "wx/gdiobj.h"
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
#include "wx/dataobj.h" wx/defs.h #include "wx/dataobj.h"
#endif #endif
/* /*

View File

@@ -63,7 +63,7 @@ class WXDLLEXPORT wxStaticBitmap: public wxControl
// for compatibility with wxMSW // for compatibility with wxMSW
void SetIcon(const wxIcon& icon) void SetIcon(const wxIcon& icon)
{ {
SetBitmap( icon ); SetBitmap( (const wxBitmap&) icon );
} }
// overriden base class virtuals // overriden base class virtuals

View File

@@ -17,8 +17,6 @@
#pragma interface "statbar.h" #pragma interface "statbar.h"
#endif #endif
#include "wx/generic/statusbr.h"
class WXDLLEXPORT wxStatusBarMac : public wxStatusBarGeneric class WXDLLEXPORT wxStatusBarMac : public wxStatusBarGeneric
{ {
DECLARE_DYNAMIC_CLASS(wxStatusBarMac); DECLARE_DYNAMIC_CLASS(wxStatusBarMac);
@@ -50,4 +48,4 @@ protected:
}; };
#endif #endif
// _WX_STATBAR_H_ // _WX_STATBAR_H_

View File

@@ -270,7 +270,6 @@ public :
virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ; virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ;
virtual void MacDoGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ; virtual void MacDoGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ;
MacWindowData* MacGetWindowData() { return m_macWindowData ; } MacWindowData* MacGetWindowData() { return m_macWindowData ; }
static WindowRef MacGetWindowInUpdate() { return s_macWindowInUpdate ; }
bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; } bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
static wxWindow* s_lastMouseWindow ; static wxWindow* s_lastMouseWindow ;
private: private:
@@ -278,7 +277,6 @@ private:
protected: protected:
MacWindowData* m_macWindowData ; MacWindowData* m_macWindowData ;
static WindowRef s_macWindowInUpdate ;
RgnHandle m_macUpdateRgn ; RgnHandle m_macUpdateRgn ;
int m_x ; int m_x ;

View File

@@ -115,6 +115,7 @@ WXDLLEXPORT wxObject* wxCreateStoredObject( wxInputStream& stream );
// Single inheritance with one base class // Single inheritance with one base class
#define IMPLEMENT_DYNAMIC_CLASS(name, basename) \ #define IMPLEMENT_DYNAMIC_CLASS(name, basename) \
wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void); \
wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \ wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \
{ return new name; }\ { return new name; }\
wxClassInfo name::sm_class##name((wxChar *) wxT(#name), (wxChar *) wxT(#basename), (wxChar *) NULL, (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name); wxClassInfo name::sm_class##name((wxChar *) wxT(#name), (wxChar *) wxT(#basename), (wxChar *) NULL, (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name);

View File

@@ -13,9 +13,9 @@
#define _WX_SPINBUTT_H_BASE_ #define _WX_SPINBUTT_H_BASE_
#ifdef __GNUG__ #ifdef __GNUG__
#ifndef __WXMOTIF__ // because there is no matching .cpp for Motif #if !defined(__WXMOTIF__) && !defined(__WXMAC__) // because there is no matching .cpp
#pragma interface "spinbutbase.h" #pragma interface "spinbutbase.h"
#endif // Motif #endif
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -54,7 +54,8 @@ protected:
#include "wx/msw/statbr95.h" #include "wx/msw/statbr95.h"
typedef wxStatusBar95 wxStatusBarReal; typedef wxStatusBar95 wxStatusBarReal;
#elif defined(__WXMAC__) && !defined(__UNIX__) #elif defined(__WXMAC__) /* && !defined(__UNIX__) */
#include "wx/generic/statusbr.h"
#include "wx/mac/statusbr.h" #include "wx/mac/statusbr.h"
typedef wxStatusBarMac wxStatusBarReal; typedef wxStatusBarMac wxStatusBarReal;

View File

@@ -256,6 +256,7 @@ protected:
wxEVT_COMMAND_TREE_KEY_DOWN wxEVT_COMMAND_TREE_KEY_DOWN
*/ */
#ifndef __WXMAC_X__
class WXDLLEXPORT wxTreeEvent: public wxCommandEvent class WXDLLEXPORT wxTreeEvent: public wxCommandEvent
{ {
DECLARE_DYNAMIC_CLASS(wxTreeEvent) DECLARE_DYNAMIC_CLASS(wxTreeEvent)
@@ -275,6 +276,7 @@ class WXDLLEXPORT wxTreeEvent: public wxCommandEvent
}; };
typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&); typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
#endif
#endif #endif
// _WX_TREECTRL_H_ // _WX_TREECTRL_H_

View File

@@ -247,7 +247,7 @@ wxDllLoader::LoadLibrary(const wxString & libname, bool *success)
char zError[256] = ""; char zError[256] = "";
wxDllOpen(zError, libname, handle); wxDllOpen(zError, libname, handle);
#else // !Mac #else // !Mac
handle = wxDllOpen(libname); handle = wxDllOpen((char *)libname);
#endif // OS #endif // OS
if ( !handle ) if ( !handle )
@@ -321,7 +321,7 @@ wxDllLoader::GetSymbol(wxDllType dllHandle, const wxString &name)
wxDllGetSymbol(dllHandle, symbol); wxDllGetSymbol(dllHandle, symbol);
#else #else
// mb_str() is necessary in Unicode build // mb_str() is necessary in Unicode build
symbol = wxDllGetSymbol(dllHandle, name.mb_str()); symbol = wxDllGetSymbol(dllHandle, (char *)name.mb_str());
#endif #endif
if ( !symbol ) if ( !symbol )

View File

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

View File

@@ -136,7 +136,7 @@ bool wxFile::Exists(const wxChar *name)
#if wxUSE_UNICODE && wxMBFILES #if wxUSE_UNICODE && wxMBFILES
wxCharBuffer fname = wxConvFile.cWC2MB(name); wxCharBuffer fname = wxConvFile.cWC2MB(name);
#ifdef __WXMAC__ #if defined(__WXMAC__) && !defined(__UNIX__)
return !access(wxUnix2MacFilename( name ) , 0) && !stat(wxUnix2MacFilename( name ), &st) && (st.st_mode & S_IFREG); return !access(wxUnix2MacFilename( name ) , 0) && !stat(wxUnix2MacFilename( name ), &st) && (st.st_mode & S_IFREG);
#else #else
return !wxAccess(fname, 0) && return !wxAccess(fname, 0) &&
@@ -144,7 +144,7 @@ bool wxFile::Exists(const wxChar *name)
(st.st_mode & S_IFREG); (st.st_mode & S_IFREG);
#endif #endif
#else #else
#ifdef __WXMAC__ #if defined(__WXMAC__) && !defined(__UNIX__)
return !access(wxUnix2MacFilename( name ) , 0) && !stat(wxUnix2MacFilename( name ), &st) && (st.st_mode & S_IFREG); return !access(wxUnix2MacFilename( name ) , 0) && !stat(wxUnix2MacFilename( name ), &st) && (st.st_mode & S_IFREG);
#else #else
return !wxAccess(name, 0) && return !wxAccess(name, 0) &&
@@ -192,7 +192,7 @@ bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode)
{ {
// if bOverwrite we create a new file or truncate the existing one, // 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 // otherwise we only create the new file and fail if it already exists
#ifdef __WXMAC__ #if defined(__WXMAC__) && !defined(__UNIX__)
// Dominic Mazzoni [dmazzoni+@cs.cmu.edu] reports that open is still broken on the mac, so we replace // 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 = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
int fd = creat(wxUnix2MacFilename( szFileName ), accessMode); int fd = creat(wxUnix2MacFilename( szFileName ), accessMode);
@@ -240,7 +240,7 @@ bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode)
break; break;
} }
#ifdef __WXMAC__ #if defined(__WXMAC__) && !defined(__UNIX__)
int fd = open(wxUnix2MacFilename( szFileName ), flags, access); int fd = open(wxUnix2MacFilename( szFileName ), flags, access);
#else #else
int fd = wxOpen(wxFNCONV(szFileName), flags ACCESS(accessMode)); int fd = wxOpen(wxFNCONV(szFileName), flags ACCESS(accessMode));
@@ -555,7 +555,7 @@ bool wxTempFile::Commit()
{ {
m_file.Close(); m_file.Close();
#ifndef __WXMAC__ #if !defined(__WXMAC__) || defined(__UNIX__)
if ( wxFile::Exists(m_strName) && wxRemove(m_strName) != 0 ) { if ( wxFile::Exists(m_strName) && wxRemove(m_strName) != 0 ) {
wxLogSysError(_("can't remove file '%s'"), m_strName.c_str()); wxLogSysError(_("can't remove file '%s'"), m_strName.c_str());
return FALSE; return FALSE;
@@ -583,7 +583,7 @@ bool wxTempFile::Commit()
void wxTempFile::Discard() void wxTempFile::Discard()
{ {
m_file.Close(); m_file.Close();
#ifndef __WXMAC__ #if !defined(__WXMAC__) || defined(__UNIX__)
if ( wxRemove(m_strTemp) != 0 ) if ( wxRemove(m_strTemp) != 0 )
wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str()); wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str());
#else #else

View File

@@ -797,7 +797,7 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */)
bool ret = file.Commit(); bool ret = file.Commit();
#ifdef __WXMAC__ #if defined(__WXMAC__) && !defined(__UNIX__)
if ( ret ) if ( ret )
{ {
FSSpec spec ; FSSpec spec ;
@@ -811,7 +811,7 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */)
FSpSetFInfo( &spec , &finfo ) ; FSpSetFInfo( &spec , &finfo ) ;
} }
} }
#endif // __WXMAC__ #endif // __WXMAC__ && !__UNIX__
#ifdef __UNIX__ #ifdef __UNIX__
// restore the old umask if we changed it // restore the old umask if we changed it

View File

@@ -1058,7 +1058,7 @@ wxCopyFile (const wxString& file1, const wxString& file2)
return FALSE; return FALSE;
} }
#if !defined(__VISAGECPP__) && !defined(__WXMAC__) #if !defined(__VISAGECPP__) && !defined(__WXMAC__) || defined(__UNIX__)
// no chmod in VA. SHould be some permission API for HPFS386 partitions however // no chmod in VA. SHould be some permission API for HPFS386 partitions however
if ( chmod(OS_FILENAME(file2), fbuf.st_mode) != 0 ) if ( chmod(OS_FILENAME(file2), fbuf.st_mode) != 0 )
{ {
@@ -1099,7 +1099,7 @@ bool wxRemoveFile(const wxString& file)
bool wxMkdir(const wxString& dir, int perm) bool wxMkdir(const wxString& dir, int perm)
{ {
#if defined( __WXMAC__ ) #if defined(__WXMAC__) && !defined(__UNIX__)
return (mkdir(wxUnix2MacFilename( dir ) , 0 ) == 0); return (mkdir(wxUnix2MacFilename( dir ) , 0 ) == 0);
#else // !Mac #else // !Mac
const wxChar *dirname = dir.c_str(); const wxChar *dirname = dir.c_str();
@@ -1664,7 +1664,7 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
char *cbuf = new char[sz+1]; char *cbuf = new char[sz+1];
#ifdef _MSC_VER #ifdef _MSC_VER
if (_getcwd(cbuf, sz) == NULL) { if (_getcwd(cbuf, sz) == NULL) {
#elif defined( __WXMAC__) #elif defined(__WXMAC__) && !defined(__UNIX__)
enum enum
{ {
SFSaveDisk = 0x214, CurDirStore = 0x398 SFSaveDisk = 0x214, CurDirStore = 0x398
@@ -1682,7 +1682,7 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
#else // wxUnicode #else // wxUnicode
#ifdef _MSC_VER #ifdef _MSC_VER
if (_getcwd(buf, sz) == NULL) { if (_getcwd(buf, sz) == NULL) {
#elif defined( __WXMAC__) #elif defined(__WXMAC__) && !defined(__UNIX__)
FSSpec cwdSpec ; FSSpec cwdSpec ;
FCBPBRec pb; FCBPBRec pb;
OSErr error; OSErr error;

View File

@@ -1402,17 +1402,11 @@ wxImage::wxImage( const wxBitmap &bitmap )
#ifdef __WXMAC__ #ifdef __WXMAC__
#ifdef __UNIX__ #ifdef __UNIX__
#include <QD/PictUtils.h> #include <ApplicationServices/ApplicationServices.h>
#else #else
#include <PictUtils.h> #include <PictUtils.h>
#endif #endif
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 width , int height , int depth ) ;
extern void wxMacDestroyGWorld( GWorldPtr gw ) ;
wxBitmap wxImage::ConvertToBitmap() const wxBitmap wxImage::ConvertToBitmap() const
{ {
// width and height of the device-dependent bitmap // width and height of the device-dependent bitmap
@@ -1421,35 +1415,27 @@ wxBitmap wxImage::ConvertToBitmap() const
// Create picture // Create picture
wxBitmap bitmap( width , height , wxDisplayDepth() ) ; wxBitmap bitmap;
// 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();
wxCHECK_MSG( Ok(), bitmap, wxT("invalid image") );
bitmap.Create( width , height , wxDisplayDepth() ) ;
wxBitmap maskBitmap( width, height, 1);
CGrafPtr origPort ; CGrafPtr origPort ;
GDHandle origDevice ; GDHandle origDevice ;
LockPixels( GetGWorldPixMap(bitmap.GetHBITMAP()) );
LockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) );
GetGWorld( &origPort , &origDevice ) ; GetGWorld( &origPort , &origDevice ) ;
SetGWorld( bitmap.GetHBITMAP() , NULL ) ; SetGWorld( bitmap.GetHBITMAP() , NULL ) ;
// Render image
wxColour rgb, maskcolor(GetMaskRed(), GetMaskGreen(), GetMaskBlue());
RGBColor color;
RGBColor white = { 0xffff, 0xffff, 0xffff };
RGBColor black = { 0 , 0 , 0 };
register unsigned char* data = GetData(); register unsigned char* data = GetData();
@@ -1458,158 +1444,96 @@ wxBitmap wxImage::ConvertToBitmap() const
{ {
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned char r = data[index++]; rgb.Set(data[index++], data[index++], data[index++]);
unsigned char g = data[index++]; color = rgb.GetPixel();
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 ) ; SetCPixel( x , y , &color ) ;
if (HasMask())
{
SetGWorld(maskBitmap.GetHBITMAP(), NULL);
if (rgb == maskcolor) {
SetCPixel(x,y, &white);
}
else {
SetCPixel(x,y, &black);
}
SetGWorld(bitmap.GetHBITMAP(), NULL);
}
} }
} // for height } // for height
SetGWorld( origPort , origDevice ) ; // Create mask
if ( HasMask() ) {
if ( HasMask() ) wxMask *mask = new wxMask( maskBitmap );
{
wxColour colour( GetMaskRed(), GetMaskGreen(), GetMaskBlue());
wxMask *mask = new wxMask( bitmap, colour );
bitmap.SetMask( mask );
} }
return bitmap;
UnlockPixels( GetGWorldPixMap(bitmap.GetHBITMAP()) );
UnlockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) );
SetGWorld( origPort, origDevice );
return bitmap;
} }
wxImage::wxImage( const wxBitmap &bitmap ) wxImage::wxImage( const wxBitmap &bitmap )
{ {
// check the bitmap // check the bitmap
if( !bitmap.Ok() ) wxCHECK_RET( bitmap.Ok(), wxT("Invalid bitmap") );
{
wxFAIL_MSG( "invalid bitmap" );
return;
}
// create an wxImage object // create an wxImage object
int width = bitmap.GetWidth(); int width = bitmap.GetWidth();
int height = bitmap.GetHeight(); int height = bitmap.GetHeight();
Create( width, height ); Create( width, height );
/*
unsigned char *data = GetData(); 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 wxCHECK_RET( data, wxT("Could not allocate data for image") );
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 WXHBITMAP origPort;
int headersize = sizeof(BITMAPINFOHEADER); GDHandle origDevice;
LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize ); int index;
if( !lpDIBh ) RGBColor color;
{ // background color set to RGB(16,16,16) in consistent with wxGTK
wxFAIL_MSG( "could not allocate data for DIB header" ); unsigned char mask_r=16, mask_g=16, mask_b=16;
free( data ); SInt16 r,g,b;
return; wxMask *mask = bitmap.GetMask();
}
// 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 GetGWorld( &origPort, &origDevice );
HDC hdc = ::GetDC(NULL); LockPixels(GetGWorldPixMap(bitmap.GetHBITMAP()));
HBITMAP hbitmap; SetGWorld( bitmap.GetHBITMAP(), NULL);
hbitmap = (HBITMAP) bitmap.GetHBITMAP();
::GetDIBits( hdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS );
// copy DIB data into the wxImage object // Copy data into image
int i, j; index = 0;
unsigned char *ptdata = data; for (int yy = 0; yy < height; yy++)
unsigned char *ptbits = lpBits;
for( i=0; i<height; i++ )
{ {
for( j=0; j<width; j++ ) for (int xx = 0; xx < width; xx++)
{ {
*(ptdata++) = *(ptbits+2); GetCPixel(xx,yy, &color);
*(ptdata++) = *(ptbits+1); r = ((color.red ) >> 8);
*(ptdata++) = *(ptbits ); g = ((color.green ) >> 8);
ptbits += 3; b = ((color.blue ) >> 8);
} data[index ] = r;
ptbits += padding; data[index + 1] = g;
} data[index + 2] = b;
if (mask)
// 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 ) if (mask->PointMasked(xx,yy))
ptdata += 3;
else
{ {
*(ptdata++) = r; data[index ] = mask_r;
*(ptdata++) = g; data[index + 1] = mask_g;
*(ptdata++) = b; data[index + 2] = mask_b;
} }
ptbits += 3;
} }
ptbits += padding; index += 3;
} }
SetMaskColour( r, g, b );
SetMask( TRUE );
} }
else if (mask)
{ {
SetMask( FALSE ); SetMaskColour( mask_r, mask_g, mask_b );
SetMask( true );
} }
// free allocated resources
::ReleaseDC(NULL, hdc); // Free resources
free(lpDIBh); UnlockPixels(GetGWorldPixMap(bitmap.GetHBITMAP()));
free(lpBits); SetGWorld(origPort, origDevice);
*/
} }
#endif #endif

View File

@@ -55,9 +55,9 @@
// implementation classes: // implementation classes:
#if defined(__WXMSW__) #if defined(__WXMSW__)
#include "wx/msw/mimetype.h" #include "wx/msw/mimetype.h"
#elif defined (__WXMAC__) #elif defined(__WXMAC__)
#include "wx/mac/mimetype.h" #include "wx/mac/mimetype.h"
#elif defined (__WXPM__) #elif defined(__WXPM__)
#include "wx/os2/mimetype.h" #include "wx/os2/mimetype.h"
#else // Unix #else // Unix
#include "wx/unix/mimetype.h" #include "wx/unix/mimetype.h"

View File

@@ -227,7 +227,7 @@ bool wxResourceTable::ParseResourceFile(const wxString& filename)
{ {
wxExprDatabase db; wxExprDatabase db;
#ifdef __WXMAC__ #if defined(__WXMAC__) && !defined(__UNIX__)
FILE *fd = fopen(wxUnix2MacFilename(filename.fn_str()), "r"); FILE *fd = fopen(wxUnix2MacFilename(filename.fn_str()), "r");
#else #else
FILE *fd = wxFopen(filename, _T("r")); FILE *fd = wxFopen(filename, _T("r"));

View File

@@ -358,7 +358,7 @@ local uLong unzlocal_SearchCentralDir(fin)
return uPosFound; return uPosFound;
} }
#ifdef __WXMAC__ #if defined(__WXMAC__) && !defined(__UNIX__)
void wxUnix2MacFilename (char *s) ; void wxUnix2MacFilename (char *s) ;
void void
wxUnix2MacFilename (char *s) wxUnix2MacFilename (char *s)
@@ -430,10 +430,10 @@ extern unzFile ZEXPORT unzOpen (path)
if (unz_copyright[0]!=' ') if (unz_copyright[0]!=' ')
return NULL; return NULL;
#ifdef __WXMAC__ #if defined(__WXMAC__) && !defined(__UNIX__)
strcpy( wxBuffer , path ) ; strcpy( wxBuffer , path ) ;
wxUnix2MacFilename( wxBuffer ) ; wxUnix2MacFilename( wxBuffer ) ;
fin=fopen(wxBuffer,"rb"); fin=fopen(wxBuffer,"rb");
#else #else
fin=fopen(path,"rb"); fin=fopen(path,"rb");
#endif #endif

View File

@@ -34,7 +34,7 @@
#if defined(__WXMSW__) && !defined(__WX_SETUP_H__) && !defined(wxUSE_ZLIB_H_IN_PATH) #if defined(__WXMSW__) && !defined(__WX_SETUP_H__) && !defined(wxUSE_ZLIB_H_IN_PATH)
#include "../zlib/zlib.h" #include "../zlib/zlib.h"
#elif defined(__WXMAC__) && defined(__UNIX__) #elif defined(__WXMAC__) && defined(__UNIX__)
#include <Zip/zlib.h> #include <Kernel/net/zlib.h>
#else #else
#include <zlib.h> #include <zlib.h>
#endif #endif

View File

@@ -1,3 +1,4 @@
#include "wx/dc.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#include "wx/mac/aga.h" #include "wx/mac/aga.h"

View File

@@ -53,7 +53,7 @@
#if wxUSE_SOCKETS #if wxUSE_SOCKETS
#ifdef __APPLE__ #ifdef __APPLE__
#include <OT/OpenTransport.h> #include <CoreServices/CoreServices.h>
#else #else
#include <OpenTransport.h> #include <OpenTransport.h>
#include <OpenTptInternet.h> #include <OpenTptInternet.h>
@@ -95,25 +95,25 @@ bool wxApp::s_macSupportPCMenuShortcuts = true ;
long wxApp::s_macAboutMenuItemId = wxID_ABOUT ; long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
wxString wxApp::s_macHelpMenuTitleName = "&Help" ; wxString wxApp::s_macHelpMenuTitleName = "&Help" ;
pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon ) pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEODoc( (AppleEvent*) event , reply) ; return wxTheApp->MacHandleAEODoc( (AppleEvent*) event , reply) ;
} }
pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , unsigned long refcon ) pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEOApp( (AppleEvent*) event , reply ) ; return wxTheApp->MacHandleAEOApp( (AppleEvent*) event , reply ) ;
} }
pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon ) pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEPDoc( (AppleEvent*) event , reply ) ; return wxTheApp->MacHandleAEPDoc( (AppleEvent*) event , reply ) ;
} }
pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , unsigned long refcon ) pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ; return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ;
@@ -1469,7 +1469,11 @@ void wxApp::MacHandleOSEvent( EventRecord *ev )
case suspendResumeMessage : case suspendResumeMessage :
{ {
bool isResuming = ev->message & resumeFlag ; bool isResuming = ev->message & resumeFlag ;
#if !TARGET_CARBON
bool convertClipboard = ev->message & convertClipboardFlag ; bool convertClipboard = ev->message & convertClipboardFlag ;
#else
bool convertClipboard = false;
#endif
bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ; bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
if ( isResuming ) if ( isResuming )
{ {

View File

@@ -36,7 +36,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
#endif #endif
#ifdef __UNIX__ #ifdef __UNIX__
#include <QD/PictUtils.h> #include <ApplicationServices/ApplicationServices.h>
#else #else
#include <PictUtils.h> #include <PictUtils.h>
#endif #endif
@@ -97,6 +97,97 @@ void wxMacDestroyGWorld( GWorldPtr gw )
DisposeGWorld( gw ) ; DisposeGWorld( gw ) ;
} }
PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
{
CGrafPtr origPort ;
GDHandle origDev ;
PicHandle pict; // this is the Picture we give back
RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ;
RGBColor white = { 0xffff ,0xffff , 0xffff } ;
RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;
unsigned char *maskimage = NULL ;
Rect portRect ;
GetPortBounds( wp , &portRect ) ;
int width = portRect.right - portRect.left ;
int height = portRect.bottom - portRect.top ;
LockPixels( GetGWorldPixMap( wp ) ) ;
GetGWorld( &origPort , &origDev ) ;
if ( mask )
{
maskimage = (unsigned char*) malloc( width * height ) ;
SetGWorld( mask , NULL ) ;
LockPixels( GetGWorldPixMap( mask ) ) ;
for ( int y = 0 ; y < height ; y++ )
{
for( int x = 0 ; x < width ; x++ )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
maskimage[y*width + x] = ( col.red == 0 ) ; // for monochrome masks
}
}
UnlockPixels( GetGWorldPixMap( mask ) ) ;
}
SetGWorld( wp , NULL ) ;
pict = OpenPicture(&portRect); // open a picture, this disables drawing
if(!pict)
return NULL;
if ( maskimage )
{
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
PenMode(transparent);
for ( int y = 0 ; y < height ; ++y )
{
for( int x = 0 ; x < width ; ++x )
{
if ( maskimage[y*width + x] )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
SetCPixel( x + portRect.left , y + portRect.top , &col ) ;
}
else {
// With transparency set this sets a blank pixel not a white one
SetCPixel( x + portRect.left , y + portRect.top , &white);
}
}
}
free( maskimage ) ;
maskimage = NULL ;
}
else
{
RGBBackColor( &gray ) ;
EraseRect(&portRect);
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
CopyBits(GetPortBitMapForCopyBits(wp), /* src PixMap - we copy image over
* itself - */
GetPortBitMapForCopyBits(wp), // dst PixMap - no drawing occurs
&portRect, // srcRect - it will be recorded and compressed -
&portRect, // dstRect - into the picture that is open -
srcCopy,NULL); // copyMode and no clip region
}
ClosePicture(); // We are done recording the picture
UnlockPixels( GetGWorldPixMap( wp ) ) ;
SetGWorld( origPort , origDev ) ;
return pict; // return our groovy pict handle
}
wxBitmapRefData::wxBitmapRefData() wxBitmapRefData::wxBitmapRefData()
{ {
m_ok = FALSE; m_ok = FALSE;
@@ -180,8 +271,18 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
GetGWorld( &origPort , &origDevice ) ; GetGWorld( &origPort , &origDevice ) ;
SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ; SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
LockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ; LockPixels( GetGWorldPixMap( M_BITMAPDATA->m_hBitmap ) ) ;
#ifdef __UNIX__
// bits is a word aligned array?? Don't think so
// bits is a char array on MAC OS X however using the benefit of the
// doubt I replaced references to 16 with sizeof(unsigned char)*8
unsigned char* linestart = (unsigned char*) bits ;
int linesize = ( the_width / (sizeof(unsigned char) * 8)) ;
if ( the_width % (sizeof(unsigned char) * 8) ) {
linesize += sizeof(unsigned char);
}
#else
// bits is a word aligned array // bits is a word aligned array
unsigned char* linestart = (unsigned char*) bits ; unsigned char* linestart = (unsigned char*) bits ;
@@ -190,6 +291,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
{ {
linesize += 2 ; linesize += 2 ;
} }
#endif
RGBColor colors[2] = { RGBColor colors[2] = {
{ 0xFFFF , 0xFFFF , 0xFFFF } , { 0xFFFF , 0xFFFF , 0xFFFF } ,
@@ -214,7 +316,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
} }
} }
UnlockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ; UnlockPixels( GetGWorldPixMap( M_BITMAPDATA->m_hBitmap ) ) ;
SetGWorld( origPort , origDevice ) ; SetGWorld( origPort , origDevice ) ;
} }
@@ -261,6 +363,95 @@ wxBitmap::wxBitmap(char **data)
(void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); (void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
} }
wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
{
wxCHECK_MSG( Ok() &&
(rect.x >= 0) && (rect.y >= 0) &&
(rect.x+rect.width <= GetWidth()) &&
(rect.y+rect.height <= GetHeight()),
wxNullBitmap, wxT("invalid bitmap or bitmap region") );
wxBitmap ret( rect.width, rect.height, GetDepth() );
wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") );
WXHBITMAP origPort;
GDHandle origDevice;
GetGWorld( &origPort, &origDevice );
// Update the subbitmaps reference data
wxBitmapRefData *ref = (wxBitmapRefData *)ret.GetRefData();
ref->m_numColors = M_BITMAPDATA->m_numColors;
ref->m_bitmapPalette = M_BITMAPDATA->m_bitmapPalette;
ref->m_bitmapType = M_BITMAPDATA->m_bitmapType;
// Copy sub region of this bitmap
if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypePict)
{
printf("GetSubBitmap: Copy a region of a Pict structure - TODO\n");
}
else if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypeGrafWorld)
{
// Copy mask
if(GetMask())
{
WXHBITMAP submask, mask;
RGBColor color;
mask = GetMask()->GetMaskBitmap();
submask = wxMacCreateGWorld(rect.width, rect.height, 1);
LockPixels(GetGWorldPixMap(mask));
LockPixels(GetGWorldPixMap(submask));
for(int yy = 0; yy < rect.height; yy++)
{
for(int xx = 0; xx < rect.width; xx++)
{
SetGWorld(mask, NULL);
GetCPixel(rect.x + xx, rect.y + yy, &color);
SetGWorld(submask, NULL);
SetCPixel(xx,yy, &color);
}
}
UnlockPixels(GetGWorldPixMap(mask));
UnlockPixels(GetGWorldPixMap(submask));
ref->m_bitmapMask = new wxMask;
ref->m_bitmapMask->SetMaskBitmap(submask);
}
// Copy bitmap
if(GetHBITMAP())
{
WXHBITMAP subbitmap, bitmap;
RGBColor color;
bitmap = GetHBITMAP();
subbitmap = wxMacCreateGWorld(rect.width, rect.height, GetDepth());
LockPixels(GetGWorldPixMap(bitmap));
LockPixels(GetGWorldPixMap(subbitmap));
for(int yy = 0; yy < rect.height; yy++)
{
for(int xx = 0; xx < rect.width; xx++)
{
SetGWorld(bitmap, NULL);
GetCPixel(rect.x + xx, rect.y + yy, &color);
SetGWorld(subbitmap, NULL);
SetCPixel(xx, yy, &color);
}
}
UnlockPixels(GetGWorldPixMap(bitmap));
UnlockPixels(GetGWorldPixMap(subbitmap));
ret.SetHBITMAP(subbitmap);
}
}
SetGWorld( origPort, origDevice );
return ret;
}
bool wxBitmap::Create(int w, int h, int d) bool wxBitmap::Create(int w, int h, int d)
{ {
UnRef(); UnRef();
@@ -277,6 +468,13 @@ bool wxBitmap::Create(int w, int h, int d)
return M_BITMAPDATA->m_ok; return M_BITMAPDATA->m_ok;
} }
int wxBitmap::GetBitmapType() const
{
wxCHECK_MSG( Ok(), kMacBitmapTypeUnknownType, wxT("invalid bitmap") );
return M_BITMAPDATA->m_bitmapType;
}
void wxBitmap::SetHBITMAP(WXHBITMAP bmp) void wxBitmap::SetHBITMAP(WXHBITMAP bmp)
{ {
M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ; M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
@@ -331,6 +529,46 @@ bool wxBitmap::SaveFile(const wxString& filename, int type, const wxPalette *pal
return handler->SaveFile(this, filename, type, palette); return handler->SaveFile(this, filename, type, palette);
} }
bool wxBitmap::Ok() const
{
return (M_BITMAPDATA && M_BITMAPDATA->m_ok);
}
int wxBitmap::GetHeight() const
{
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
return M_BITMAPDATA->m_height;
}
int wxBitmap::GetWidth() const
{
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
return M_BITMAPDATA->m_width;
}
int wxBitmap::GetDepth() const
{
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
return M_BITMAPDATA->m_depth;
}
int wxBitmap::GetQuality() const
{
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
return M_BITMAPDATA->m_quality;
}
wxMask *wxBitmap::GetMask() const
{
wxCHECK_MSG( Ok(), (wxMask *) NULL, wxT("invalid bitmap") );
return M_BITMAPDATA->m_bitmapMask;
}
void wxBitmap::SetWidth(int w) void wxBitmap::SetWidth(int w)
{ {
if (!M_BITMAPDATA) if (!M_BITMAPDATA)
@@ -371,6 +609,13 @@ void wxBitmap::SetOk(bool isOk)
M_BITMAPDATA->m_ok = isOk; M_BITMAPDATA->m_ok = isOk;
} }
wxPalette *wxBitmap::GetPalette() const
{
wxCHECK_MSG( Ok(), NULL, wxT("Invalid bitmap GetPalette()") );
return &M_BITMAPDATA->m_bitmapPalette;
}
void wxBitmap::SetPalette(const wxPalette& palette) void wxBitmap::SetPalette(const wxPalette& palette)
{ {
if (!M_BITMAPDATA) if (!M_BITMAPDATA)
@@ -387,6 +632,105 @@ void wxBitmap::SetMask(wxMask *mask)
M_BITMAPDATA->m_bitmapMask = mask ; M_BITMAPDATA->m_bitmapMask = mask ;
} }
WXHBITMAP wxBitmap::GetHBITMAP() const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
return M_BITMAPDATA->m_hBitmap;
}
PicHandle wxBitmap::GetPict() const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
PicHandle picture; // This is the returned picture
// If bitmap already in Pict format return pointer
if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypePict) {
return M_BITMAPDATA->m_hPict;
}
else if(M_BITMAPDATA->m_bitmapType != kMacBitmapTypeGrafWorld) {
// Invalid bitmap
return NULL;
}
RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ;
RGBColor white = { 0xffff ,0xffff , 0xffff } ;
RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;
CGrafPtr origPort;
GDHandle origDev ;
wxMask *mask;
Rect portRect ;
GetPortBounds( GetHBITMAP() , &portRect ) ;
int width = portRect.right - portRect.left ;
int height = portRect.bottom - portRect.top ;
LockPixels( GetGWorldPixMap( GetHBITMAP() ) ) ;
GetGWorld( &origPort , &origDev ) ;
mask = GetMask();
SetGWorld( GetHBITMAP() , NULL ) ;
picture = OpenPicture(&portRect); // open a picture, this disables drawing
if(!picture) {
return NULL;
}
if( mask )
{
#ifdef __UNIX__
RGBColor trans = white;
#else
RGBBackColor( &gray );
EraseRect( &portRect );
RGBColor trans = gray;
#endif
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
PenMode(transparent);
for ( int y = 0 ; y < height ; ++y )
{
for( int x = 0 ; x < width ; ++x )
{
if ( !mask->PointMasked(x,y) )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
SetCPixel( x + portRect.left , y + portRect.top , &col ) ;
}
else {
// With transparency this sets a blank pixel
SetCPixel( x + portRect.left , y + portRect.top , &trans);
}
}
}
}
else
{
RGBBackColor( &gray ) ;
EraseRect(&portRect);
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
CopyBits(GetPortBitMapForCopyBits(GetHBITMAP()),
// src PixMap - we copy image over itself -
GetPortBitMapForCopyBits(GetHBITMAP()),
// dst PixMap - no drawing occurs
&portRect, // srcRect - it will be recorded and compressed -
&portRect, // dstRect - into the picture that is open -
srcCopy,NULL); // copyMode and no clip region
}
ClosePicture(); // We are done recording the picture
UnlockPixels( GetGWorldPixMap( GetHBITMAP() ) ) ;
SetGWorld( origPort , origDev ) ;
return picture; // return our groovy pict handle
}
void wxBitmap::AddHandler(wxBitmapHandler *handler) void wxBitmap::AddHandler(wxBitmapHandler *handler)
{ {
sm_handlers.Append(handler); sm_handlers.Append(handler);
@@ -493,8 +837,32 @@ wxMask::~wxMask()
// Create a mask from a mono bitmap (copies the bitmap). // Create a mask from a mono bitmap (copies the bitmap).
bool wxMask::Create(const wxBitmap& bitmap) bool wxMask::Create(const wxBitmap& bitmap)
{ {
// TODO if ( m_maskBitmap )
return FALSE; {
wxMacDestroyGWorld( m_maskBitmap ) ;
m_maskBitmap = NULL ;
}
wxCHECK_MSG( bitmap.GetBitmapType() == kMacBitmapTypeGrafWorld, false,
wxT("Cannot create mask from this bitmap type (TODO)"));
// other types would require a temporary bitmap. not yet implemented
wxCHECK_MSG( bitmap.Ok(), false, wxT("Invalid bitmap"));
wxCHECK_MSG(bitmap.GetDepth() == 1, false,
wxT("Cannot create mask from colour bitmap"));
m_maskBitmap = wxMacCreateGWorld(bitmap.GetWidth(), bitmap.GetHeight(), 1);
Rect rect = { 0,0, bitmap.GetHeight(), bitmap.GetWidth() };
LockPixels( GetGWorldPixMap(m_maskBitmap) );
LockPixels( GetGWorldPixMap(bitmap.GetHBITMAP()) );
CopyBits(GetPortBitMapForCopyBits(bitmap.GetHBITMAP()),
GetPortBitMapForCopyBits(m_maskBitmap),
&rect, &rect, srcCopy, 0);
UnlockPixels( GetGWorldPixMap(m_maskBitmap) );
UnlockPixels( GetGWorldPixMap(bitmap.GetHBITMAP()) );
return FALSE;
} }
// Create a mask from a bitmap and a palette index indicating // Create a mask from a bitmap and a palette index indicating
@@ -502,6 +870,7 @@ bool wxMask::Create(const wxBitmap& bitmap)
bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
{ {
// TODO // TODO
wxCHECK_MSG( 0, false, wxT("Not implemented"));
return FALSE; return FALSE;
} }
@@ -514,39 +883,35 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
wxMacDestroyGWorld( m_maskBitmap ) ; wxMacDestroyGWorld( m_maskBitmap ) ;
m_maskBitmap = NULL ; m_maskBitmap = NULL ;
} }
wxASSERT( ((wxBitmapRefData*) bitmap.GetRefData())->m_bitmapType == kMacBitmapTypeGrafWorld ) ; wxCHECK_MSG( bitmap.GetBitmapType() == kMacBitmapTypeGrafWorld, false,
wxT("Cannot create mask from this bitmap type (TODO)"));
// other types would require a temporary bitmap. not yet implemented // other types would require a temporary bitmap. not yet implemented
if (!bitmap.Ok()) wxCHECK_MSG( bitmap.Ok(), false, wxT("Illigal bitmap"));
{
return FALSE;
}
m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 ) ; m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 );
LockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ; LockPixels( GetGWorldPixMap( m_maskBitmap ) );
LockPixels( GetGWorldPixMap( (CGrafPtr) ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap ) ) ; LockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) );
RGBColor maskColor = colour.GetPixel() ; RGBColor maskColor = colour.GetPixel();
// this is not very efficient, but I can't think // this is not very efficient, but I can't think
// of a better way of doing it // of a better way of doing it
CGrafPtr origPort ; CGrafPtr origPort ;
GDHandle origDevice ; GDHandle origDevice ;
RGBColor col;
RGBColor colors[2] = {
{ 0xFFFF, 0xFFFF, 0xFFFF },
{ 0, 0, 0 }};
GetGWorld( &origPort , &origDevice ) ; GetGWorld( &origPort , &origDevice ) ;
for (int w = 0; w < bitmap.GetWidth(); w++) for (int w = 0; w < bitmap.GetWidth(); w++)
{ {
for (int h = 0; h < bitmap.GetHeight(); h++) for (int h = 0; h < bitmap.GetHeight(); h++)
{ {
RGBColor colors[2] = { SetGWorld( bitmap.GetHBITMAP(), NULL ) ;
{ 0xFFFF , 0xFFFF , 0xFFFF } ,
{ 0, 0 , 0 }
} ;
SetGWorld( ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap , NULL ) ;
RGBColor col ;
GetCPixel( w , h , &col ) ; GetCPixel( w , h , &col ) ;
SetGWorld( m_maskBitmap , NULL ) ; SetGWorld( m_maskBitmap , NULL ) ;
if (col.red == maskColor.red && col.blue == maskColor.blue && col.green == maskColor.green) if (col.red == maskColor.red && col.green == maskColor.green && col.blue == maskColor.blue)
{ {
SetCPixel( w , h , &colors[0] ) ; SetCPixel( w , h , &colors[0] ) ;
} }
@@ -557,12 +922,33 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
} }
} }
UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ; UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
UnlockPixels( GetGWorldPixMap( ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap ) ) ; UnlockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) ) ;
SetGWorld( origPort , origDevice ) ; SetGWorld( origPort , origDevice ) ;
return TRUE; return TRUE;
} }
bool wxMask::PointMasked(int x, int y)
{
WXHBITMAP origPort;
GDHandle origDevice;
RGBColor color;
bool masked = true;
GetGWorld( &origPort, &origDevice);
//Set port to mask and see if it masked (1) or not ( 0 )
SetGWorld(m_maskBitmap, NULL);
LockPixels(GetGWorldPixMap(m_maskBitmap));
GetCPixel(x,y, &color);
masked = !(color.red == 0 && color.green == 0 && color.blue == 0);
UnlockPixels(GetGWorldPixMap(m_maskBitmap));
SetGWorld( origPort, origDevice);
return masked;
}
/* /*
* wxBitmapHandler * wxBitmapHandler
*/ */

View File

@@ -1,3 +1,4 @@
#include "wx/dc.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#include "wx/mac/aga.h" #include "wx/mac/aga.h"

View File

@@ -53,7 +53,7 @@
#if wxUSE_SOCKETS #if wxUSE_SOCKETS
#ifdef __APPLE__ #ifdef __APPLE__
#include <OT/OpenTransport.h> #include <CoreServices/CoreServices.h>
#else #else
#include <OpenTransport.h> #include <OpenTransport.h>
#include <OpenTptInternet.h> #include <OpenTptInternet.h>
@@ -95,25 +95,25 @@ bool wxApp::s_macSupportPCMenuShortcuts = true ;
long wxApp::s_macAboutMenuItemId = wxID_ABOUT ; long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
wxString wxApp::s_macHelpMenuTitleName = "&Help" ; wxString wxApp::s_macHelpMenuTitleName = "&Help" ;
pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon ) pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEODoc( (AppleEvent*) event , reply) ; return wxTheApp->MacHandleAEODoc( (AppleEvent*) event , reply) ;
} }
pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , unsigned long refcon ) pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEOApp( (AppleEvent*) event , reply ) ; return wxTheApp->MacHandleAEOApp( (AppleEvent*) event , reply ) ;
} }
pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon ) pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEPDoc( (AppleEvent*) event , reply ) ; return wxTheApp->MacHandleAEPDoc( (AppleEvent*) event , reply ) ;
} }
pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , unsigned long refcon ) pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ; return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ;
@@ -1469,7 +1469,11 @@ void wxApp::MacHandleOSEvent( EventRecord *ev )
case suspendResumeMessage : case suspendResumeMessage :
{ {
bool isResuming = ev->message & resumeFlag ; bool isResuming = ev->message & resumeFlag ;
#if !TARGET_CARBON
bool convertClipboard = ev->message & convertClipboardFlag ; bool convertClipboard = ev->message & convertClipboardFlag ;
#else
bool convertClipboard = false;
#endif
bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ; bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
if ( isResuming ) if ( isResuming )
{ {

View File

@@ -36,7 +36,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
#endif #endif
#ifdef __UNIX__ #ifdef __UNIX__
#include <QD/PictUtils.h> #include <ApplicationServices/ApplicationServices.h>
#else #else
#include <PictUtils.h> #include <PictUtils.h>
#endif #endif
@@ -97,6 +97,97 @@ void wxMacDestroyGWorld( GWorldPtr gw )
DisposeGWorld( gw ) ; DisposeGWorld( gw ) ;
} }
PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
{
CGrafPtr origPort ;
GDHandle origDev ;
PicHandle pict; // this is the Picture we give back
RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ;
RGBColor white = { 0xffff ,0xffff , 0xffff } ;
RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;
unsigned char *maskimage = NULL ;
Rect portRect ;
GetPortBounds( wp , &portRect ) ;
int width = portRect.right - portRect.left ;
int height = portRect.bottom - portRect.top ;
LockPixels( GetGWorldPixMap( wp ) ) ;
GetGWorld( &origPort , &origDev ) ;
if ( mask )
{
maskimage = (unsigned char*) malloc( width * height ) ;
SetGWorld( mask , NULL ) ;
LockPixels( GetGWorldPixMap( mask ) ) ;
for ( int y = 0 ; y < height ; y++ )
{
for( int x = 0 ; x < width ; x++ )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
maskimage[y*width + x] = ( col.red == 0 ) ; // for monochrome masks
}
}
UnlockPixels( GetGWorldPixMap( mask ) ) ;
}
SetGWorld( wp , NULL ) ;
pict = OpenPicture(&portRect); // open a picture, this disables drawing
if(!pict)
return NULL;
if ( maskimage )
{
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
PenMode(transparent);
for ( int y = 0 ; y < height ; ++y )
{
for( int x = 0 ; x < width ; ++x )
{
if ( maskimage[y*width + x] )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
SetCPixel( x + portRect.left , y + portRect.top , &col ) ;
}
else {
// With transparency set this sets a blank pixel not a white one
SetCPixel( x + portRect.left , y + portRect.top , &white);
}
}
}
free( maskimage ) ;
maskimage = NULL ;
}
else
{
RGBBackColor( &gray ) ;
EraseRect(&portRect);
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
CopyBits(GetPortBitMapForCopyBits(wp), /* src PixMap - we copy image over
* itself - */
GetPortBitMapForCopyBits(wp), // dst PixMap - no drawing occurs
&portRect, // srcRect - it will be recorded and compressed -
&portRect, // dstRect - into the picture that is open -
srcCopy,NULL); // copyMode and no clip region
}
ClosePicture(); // We are done recording the picture
UnlockPixels( GetGWorldPixMap( wp ) ) ;
SetGWorld( origPort , origDev ) ;
return pict; // return our groovy pict handle
}
wxBitmapRefData::wxBitmapRefData() wxBitmapRefData::wxBitmapRefData()
{ {
m_ok = FALSE; m_ok = FALSE;
@@ -180,8 +271,18 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
GetGWorld( &origPort , &origDevice ) ; GetGWorld( &origPort , &origDevice ) ;
SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ; SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
LockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ; LockPixels( GetGWorldPixMap( M_BITMAPDATA->m_hBitmap ) ) ;
#ifdef __UNIX__
// bits is a word aligned array?? Don't think so
// bits is a char array on MAC OS X however using the benefit of the
// doubt I replaced references to 16 with sizeof(unsigned char)*8
unsigned char* linestart = (unsigned char*) bits ;
int linesize = ( the_width / (sizeof(unsigned char) * 8)) ;
if ( the_width % (sizeof(unsigned char) * 8) ) {
linesize += sizeof(unsigned char);
}
#else
// bits is a word aligned array // bits is a word aligned array
unsigned char* linestart = (unsigned char*) bits ; unsigned char* linestart = (unsigned char*) bits ;
@@ -190,6 +291,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
{ {
linesize += 2 ; linesize += 2 ;
} }
#endif
RGBColor colors[2] = { RGBColor colors[2] = {
{ 0xFFFF , 0xFFFF , 0xFFFF } , { 0xFFFF , 0xFFFF , 0xFFFF } ,
@@ -214,7 +316,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
} }
} }
UnlockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ; UnlockPixels( GetGWorldPixMap( M_BITMAPDATA->m_hBitmap ) ) ;
SetGWorld( origPort , origDevice ) ; SetGWorld( origPort , origDevice ) ;
} }
@@ -261,6 +363,95 @@ wxBitmap::wxBitmap(char **data)
(void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); (void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
} }
wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
{
wxCHECK_MSG( Ok() &&
(rect.x >= 0) && (rect.y >= 0) &&
(rect.x+rect.width <= GetWidth()) &&
(rect.y+rect.height <= GetHeight()),
wxNullBitmap, wxT("invalid bitmap or bitmap region") );
wxBitmap ret( rect.width, rect.height, GetDepth() );
wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") );
WXHBITMAP origPort;
GDHandle origDevice;
GetGWorld( &origPort, &origDevice );
// Update the subbitmaps reference data
wxBitmapRefData *ref = (wxBitmapRefData *)ret.GetRefData();
ref->m_numColors = M_BITMAPDATA->m_numColors;
ref->m_bitmapPalette = M_BITMAPDATA->m_bitmapPalette;
ref->m_bitmapType = M_BITMAPDATA->m_bitmapType;
// Copy sub region of this bitmap
if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypePict)
{
printf("GetSubBitmap: Copy a region of a Pict structure - TODO\n");
}
else if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypeGrafWorld)
{
// Copy mask
if(GetMask())
{
WXHBITMAP submask, mask;
RGBColor color;
mask = GetMask()->GetMaskBitmap();
submask = wxMacCreateGWorld(rect.width, rect.height, 1);
LockPixels(GetGWorldPixMap(mask));
LockPixels(GetGWorldPixMap(submask));
for(int yy = 0; yy < rect.height; yy++)
{
for(int xx = 0; xx < rect.width; xx++)
{
SetGWorld(mask, NULL);
GetCPixel(rect.x + xx, rect.y + yy, &color);
SetGWorld(submask, NULL);
SetCPixel(xx,yy, &color);
}
}
UnlockPixels(GetGWorldPixMap(mask));
UnlockPixels(GetGWorldPixMap(submask));
ref->m_bitmapMask = new wxMask;
ref->m_bitmapMask->SetMaskBitmap(submask);
}
// Copy bitmap
if(GetHBITMAP())
{
WXHBITMAP subbitmap, bitmap;
RGBColor color;
bitmap = GetHBITMAP();
subbitmap = wxMacCreateGWorld(rect.width, rect.height, GetDepth());
LockPixels(GetGWorldPixMap(bitmap));
LockPixels(GetGWorldPixMap(subbitmap));
for(int yy = 0; yy < rect.height; yy++)
{
for(int xx = 0; xx < rect.width; xx++)
{
SetGWorld(bitmap, NULL);
GetCPixel(rect.x + xx, rect.y + yy, &color);
SetGWorld(subbitmap, NULL);
SetCPixel(xx, yy, &color);
}
}
UnlockPixels(GetGWorldPixMap(bitmap));
UnlockPixels(GetGWorldPixMap(subbitmap));
ret.SetHBITMAP(subbitmap);
}
}
SetGWorld( origPort, origDevice );
return ret;
}
bool wxBitmap::Create(int w, int h, int d) bool wxBitmap::Create(int w, int h, int d)
{ {
UnRef(); UnRef();
@@ -277,6 +468,13 @@ bool wxBitmap::Create(int w, int h, int d)
return M_BITMAPDATA->m_ok; return M_BITMAPDATA->m_ok;
} }
int wxBitmap::GetBitmapType() const
{
wxCHECK_MSG( Ok(), kMacBitmapTypeUnknownType, wxT("invalid bitmap") );
return M_BITMAPDATA->m_bitmapType;
}
void wxBitmap::SetHBITMAP(WXHBITMAP bmp) void wxBitmap::SetHBITMAP(WXHBITMAP bmp)
{ {
M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ; M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
@@ -331,6 +529,46 @@ bool wxBitmap::SaveFile(const wxString& filename, int type, const wxPalette *pal
return handler->SaveFile(this, filename, type, palette); return handler->SaveFile(this, filename, type, palette);
} }
bool wxBitmap::Ok() const
{
return (M_BITMAPDATA && M_BITMAPDATA->m_ok);
}
int wxBitmap::GetHeight() const
{
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
return M_BITMAPDATA->m_height;
}
int wxBitmap::GetWidth() const
{
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
return M_BITMAPDATA->m_width;
}
int wxBitmap::GetDepth() const
{
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
return M_BITMAPDATA->m_depth;
}
int wxBitmap::GetQuality() const
{
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
return M_BITMAPDATA->m_quality;
}
wxMask *wxBitmap::GetMask() const
{
wxCHECK_MSG( Ok(), (wxMask *) NULL, wxT("invalid bitmap") );
return M_BITMAPDATA->m_bitmapMask;
}
void wxBitmap::SetWidth(int w) void wxBitmap::SetWidth(int w)
{ {
if (!M_BITMAPDATA) if (!M_BITMAPDATA)
@@ -371,6 +609,13 @@ void wxBitmap::SetOk(bool isOk)
M_BITMAPDATA->m_ok = isOk; M_BITMAPDATA->m_ok = isOk;
} }
wxPalette *wxBitmap::GetPalette() const
{
wxCHECK_MSG( Ok(), NULL, wxT("Invalid bitmap GetPalette()") );
return &M_BITMAPDATA->m_bitmapPalette;
}
void wxBitmap::SetPalette(const wxPalette& palette) void wxBitmap::SetPalette(const wxPalette& palette)
{ {
if (!M_BITMAPDATA) if (!M_BITMAPDATA)
@@ -387,6 +632,105 @@ void wxBitmap::SetMask(wxMask *mask)
M_BITMAPDATA->m_bitmapMask = mask ; M_BITMAPDATA->m_bitmapMask = mask ;
} }
WXHBITMAP wxBitmap::GetHBITMAP() const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
return M_BITMAPDATA->m_hBitmap;
}
PicHandle wxBitmap::GetPict() const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
PicHandle picture; // This is the returned picture
// If bitmap already in Pict format return pointer
if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypePict) {
return M_BITMAPDATA->m_hPict;
}
else if(M_BITMAPDATA->m_bitmapType != kMacBitmapTypeGrafWorld) {
// Invalid bitmap
return NULL;
}
RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ;
RGBColor white = { 0xffff ,0xffff , 0xffff } ;
RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;
CGrafPtr origPort;
GDHandle origDev ;
wxMask *mask;
Rect portRect ;
GetPortBounds( GetHBITMAP() , &portRect ) ;
int width = portRect.right - portRect.left ;
int height = portRect.bottom - portRect.top ;
LockPixels( GetGWorldPixMap( GetHBITMAP() ) ) ;
GetGWorld( &origPort , &origDev ) ;
mask = GetMask();
SetGWorld( GetHBITMAP() , NULL ) ;
picture = OpenPicture(&portRect); // open a picture, this disables drawing
if(!picture) {
return NULL;
}
if( mask )
{
#ifdef __UNIX__
RGBColor trans = white;
#else
RGBBackColor( &gray );
EraseRect( &portRect );
RGBColor trans = gray;
#endif
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
PenMode(transparent);
for ( int y = 0 ; y < height ; ++y )
{
for( int x = 0 ; x < width ; ++x )
{
if ( !mask->PointMasked(x,y) )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
SetCPixel( x + portRect.left , y + portRect.top , &col ) ;
}
else {
// With transparency this sets a blank pixel
SetCPixel( x + portRect.left , y + portRect.top , &trans);
}
}
}
}
else
{
RGBBackColor( &gray ) ;
EraseRect(&portRect);
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
CopyBits(GetPortBitMapForCopyBits(GetHBITMAP()),
// src PixMap - we copy image over itself -
GetPortBitMapForCopyBits(GetHBITMAP()),
// dst PixMap - no drawing occurs
&portRect, // srcRect - it will be recorded and compressed -
&portRect, // dstRect - into the picture that is open -
srcCopy,NULL); // copyMode and no clip region
}
ClosePicture(); // We are done recording the picture
UnlockPixels( GetGWorldPixMap( GetHBITMAP() ) ) ;
SetGWorld( origPort , origDev ) ;
return picture; // return our groovy pict handle
}
void wxBitmap::AddHandler(wxBitmapHandler *handler) void wxBitmap::AddHandler(wxBitmapHandler *handler)
{ {
sm_handlers.Append(handler); sm_handlers.Append(handler);
@@ -493,8 +837,32 @@ wxMask::~wxMask()
// Create a mask from a mono bitmap (copies the bitmap). // Create a mask from a mono bitmap (copies the bitmap).
bool wxMask::Create(const wxBitmap& bitmap) bool wxMask::Create(const wxBitmap& bitmap)
{ {
// TODO if ( m_maskBitmap )
return FALSE; {
wxMacDestroyGWorld( m_maskBitmap ) ;
m_maskBitmap = NULL ;
}
wxCHECK_MSG( bitmap.GetBitmapType() == kMacBitmapTypeGrafWorld, false,
wxT("Cannot create mask from this bitmap type (TODO)"));
// other types would require a temporary bitmap. not yet implemented
wxCHECK_MSG( bitmap.Ok(), false, wxT("Invalid bitmap"));
wxCHECK_MSG(bitmap.GetDepth() == 1, false,
wxT("Cannot create mask from colour bitmap"));
m_maskBitmap = wxMacCreateGWorld(bitmap.GetWidth(), bitmap.GetHeight(), 1);
Rect rect = { 0,0, bitmap.GetHeight(), bitmap.GetWidth() };
LockPixels( GetGWorldPixMap(m_maskBitmap) );
LockPixels( GetGWorldPixMap(bitmap.GetHBITMAP()) );
CopyBits(GetPortBitMapForCopyBits(bitmap.GetHBITMAP()),
GetPortBitMapForCopyBits(m_maskBitmap),
&rect, &rect, srcCopy, 0);
UnlockPixels( GetGWorldPixMap(m_maskBitmap) );
UnlockPixels( GetGWorldPixMap(bitmap.GetHBITMAP()) );
return FALSE;
} }
// Create a mask from a bitmap and a palette index indicating // Create a mask from a bitmap and a palette index indicating
@@ -502,6 +870,7 @@ bool wxMask::Create(const wxBitmap& bitmap)
bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
{ {
// TODO // TODO
wxCHECK_MSG( 0, false, wxT("Not implemented"));
return FALSE; return FALSE;
} }
@@ -514,39 +883,35 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
wxMacDestroyGWorld( m_maskBitmap ) ; wxMacDestroyGWorld( m_maskBitmap ) ;
m_maskBitmap = NULL ; m_maskBitmap = NULL ;
} }
wxASSERT( ((wxBitmapRefData*) bitmap.GetRefData())->m_bitmapType == kMacBitmapTypeGrafWorld ) ; wxCHECK_MSG( bitmap.GetBitmapType() == kMacBitmapTypeGrafWorld, false,
wxT("Cannot create mask from this bitmap type (TODO)"));
// other types would require a temporary bitmap. not yet implemented // other types would require a temporary bitmap. not yet implemented
if (!bitmap.Ok()) wxCHECK_MSG( bitmap.Ok(), false, wxT("Illigal bitmap"));
{
return FALSE;
}
m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 ) ; m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 );
LockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ; LockPixels( GetGWorldPixMap( m_maskBitmap ) );
LockPixels( GetGWorldPixMap( (CGrafPtr) ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap ) ) ; LockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) );
RGBColor maskColor = colour.GetPixel() ; RGBColor maskColor = colour.GetPixel();
// this is not very efficient, but I can't think // this is not very efficient, but I can't think
// of a better way of doing it // of a better way of doing it
CGrafPtr origPort ; CGrafPtr origPort ;
GDHandle origDevice ; GDHandle origDevice ;
RGBColor col;
RGBColor colors[2] = {
{ 0xFFFF, 0xFFFF, 0xFFFF },
{ 0, 0, 0 }};
GetGWorld( &origPort , &origDevice ) ; GetGWorld( &origPort , &origDevice ) ;
for (int w = 0; w < bitmap.GetWidth(); w++) for (int w = 0; w < bitmap.GetWidth(); w++)
{ {
for (int h = 0; h < bitmap.GetHeight(); h++) for (int h = 0; h < bitmap.GetHeight(); h++)
{ {
RGBColor colors[2] = { SetGWorld( bitmap.GetHBITMAP(), NULL ) ;
{ 0xFFFF , 0xFFFF , 0xFFFF } ,
{ 0, 0 , 0 }
} ;
SetGWorld( ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap , NULL ) ;
RGBColor col ;
GetCPixel( w , h , &col ) ; GetCPixel( w , h , &col ) ;
SetGWorld( m_maskBitmap , NULL ) ; SetGWorld( m_maskBitmap , NULL ) ;
if (col.red == maskColor.red && col.blue == maskColor.blue && col.green == maskColor.green) if (col.red == maskColor.red && col.green == maskColor.green && col.blue == maskColor.blue)
{ {
SetCPixel( w , h , &colors[0] ) ; SetCPixel( w , h , &colors[0] ) ;
} }
@@ -557,12 +922,33 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
} }
} }
UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ; UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
UnlockPixels( GetGWorldPixMap( ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap ) ) ; UnlockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) ) ;
SetGWorld( origPort , origDevice ) ; SetGWorld( origPort , origDevice ) ;
return TRUE; return TRUE;
} }
bool wxMask::PointMasked(int x, int y)
{
WXHBITMAP origPort;
GDHandle origDevice;
RGBColor color;
bool masked = true;
GetGWorld( &origPort, &origDevice);
//Set port to mask and see if it masked (1) or not ( 0 )
SetGWorld(m_maskBitmap, NULL);
LockPixels(GetGWorldPixMap(m_maskBitmap));
GetCPixel(x,y, &color);
masked = !(color.red == 0 && color.green == 0 && color.blue == 0);
UnlockPixels(GetGWorldPixMap(m_maskBitmap));
SetGWorld( origPort, origDevice);
return masked;
}
/* /*
* wxBitmapHandler * wxBitmapHandler
*/ */

View File

@@ -20,6 +20,7 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/metafile.h" #include "wx/metafile.h"
#include "wx/clipbrd.h" #include "wx/clipbrd.h"
#include "wx/intl.h"
#define wxUSE_DATAOBJ 1 #define wxUSE_DATAOBJ 1

View File

@@ -16,6 +16,7 @@
#include "wx/control.h" #include "wx/control.h"
#include "wx/panel.h" #include "wx/panel.h"
#include "wx/app.h" #include "wx/app.h"
#include "wx/dc.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/tabctrl.h" #include "wx/tabctrl.h"
#include "wx/radiobox.h" #include "wx/radiobox.h"

View File

@@ -21,7 +21,7 @@
#include "wx/cmndata.h" #include "wx/cmndata.h"
#if defined(__UNIX__) #if defined(__UNIX__)
#include <NavigationServices/Navigation.h> #include <Carbon/Carbon.h>
#else #else
#include <Navigation.h> #include <Navigation.h>
#endif #endif
@@ -182,7 +182,7 @@ static Boolean SameFSSpec(FSSpecPtr spec1, FSSpecPtr spec2)
// flashing of the button when the key is hit // flashing of the button when the key is hit
static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec, static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec,
short *item, Ptr dataPtr) short *item, void *dataPtr)
{ {
#pragma unused (dataPtr) #pragma unused (dataPtr)
@@ -210,7 +210,7 @@ static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRec
// MyDlgHook is a hook routine that maps the select button to Open // MyDlgHook is a hook routine that maps the select button to Open
// and sets the Select button name // and sets the Select button name
static pascal short SFGetFolderDialogHook(short item, DialogPtr theDlgPtr, Ptr dataPtr) static pascal short SFGetFolderDialogHook(short item, DialogPtr theDlgPtr, void *dataPtr)
{ {
UserDataRecPtr theUserDataRecPtr; UserDataRecPtr theUserDataRecPtr;
long desktopDirID; long desktopDirID;
@@ -422,7 +422,7 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
} }
} }
static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr) static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
{ {
#pragma unused (dataPtr) #pragma unused (dataPtr)

View File

@@ -39,20 +39,22 @@ wxDropTarget::~wxDropTarget()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTextDropTarget // wxTextDropTarget
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef __WXMAC_X__
bool wxTextDropTarget::OnDrop( long x, long y, const void *pData ) bool wxTextDropTarget::OnDrop( wxCoord x, wxCoord y, const void *pData )
{ {
OnDropText( x, y, (const char*)pData ); OnDropText( x, y, (const char*)pData );
return TRUE; return TRUE;
}; };
#endif
bool wxTextDropTarget::OnDropText( long x, long y, const char *psz ) bool wxTextDropTarget::OnDropText( wxCoord x, wxCoord y, const wxString &psz )
{ {
printf( "Got dropped text: %s.\n", psz ); printf( "Got dropped text: %s.\n", (char *)psz );
printf( "At x: %d, y: %d.\n", (int)x, (int)y ); printf( "At x: %d, y: %d.\n", (int)x, (int)y );
return TRUE; return TRUE;
}; };
#ifndef __WXMAC_X__
size_t wxTextDropTarget::GetFormatCount() const size_t wxTextDropTarget::GetFormatCount() const
{ {
return 1; return 1;
@@ -62,25 +64,27 @@ wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
{ {
return wxDF_TEXT; return wxDF_TEXT;
} }
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxFileDropTarget // wxFileDropTarget
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const WXUNUSED(aszFiles)[] ) #ifndef __WXMAC_X__
bool wxFileDropTarget::OnDropFiles( wxCoord x, wxCoord y, size_t nFiles, const char * const WXUNUSED(aszFiles)[] )
{ {
printf( "Got %d dropped files.\n", (int)nFiles ); printf( "Got %d dropped files.\n", (int)nFiles );
printf( "At x: %d, y: %d.\n", (int)x, (int)y ); printf( "At x: %d, y: %d.\n", (int)x, (int)y );
return TRUE; return TRUE;
} }
#endif
bool wxFileDropTarget::OnDrop(long x, long y, const void *WXUNUSED(pData) ) bool wxFileDropTarget::OnDrop(wxCoord x, wxCoord y, const wxArrayString& filenames)
{ {
char *str = "/this/is/a/path.txt"; return OnDropFiles(x, y, 1, &filenames);
return OnDropFiles(x, y, 1, &str );
} }
#ifndef __WXMAC_X__
size_t wxFileDropTarget::GetFormatCount() const size_t wxFileDropTarget::GetFormatCount() const
{ {
return 1; return 1;
@@ -90,6 +94,7 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
{ {
return wxDF_FILENAME; return wxDF_FILENAME;
} }
#endif
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// wxDropSource // wxDropSource

View File

@@ -14,6 +14,7 @@
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/app.h"
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/filedlg.h" #include "wx/filedlg.h"
@@ -30,7 +31,7 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog)
// begin wxmac // begin wxmac
#if defined(__UNIX__) #if defined(__UNIX__)
#include <NavigationServices/Navigation.h> #include <Carbon/Carbon.h>
#else #else
#include <Navigation.h> #include <Navigation.h>
#endif #endif
@@ -73,6 +74,7 @@ NavEventProc(
#endif #endif
*/ */
wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event);
} }
} }
@@ -210,7 +212,7 @@ static Boolean SameFSSpec(FSSpecPtr spec1, FSSpecPtr spec2)
// flashing of the button when the key is hit // flashing of the button when the key is hit
static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec, static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec,
short *item, Ptr dataPtr) short *item, void *dataPtr)
{ {
#pragma unused (dataPtr) #pragma unused (dataPtr)
@@ -371,7 +373,7 @@ void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const
} }
} }
static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr) static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
{ {
Str255 filename ; Str255 filename ;
OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ; OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ;

View File

@@ -19,11 +19,8 @@
#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
#define OTUNIXERRORS 1
#ifdef __UNIX__ #ifdef __UNIX__
#include <CarbonCore/CarbonCore.h> #include <CoreServices/CoreServices.h>
#include <OT/OpenTransport.h>
#include <OT/OpenTransportProviders.h>
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0
@@ -32,6 +29,7 @@
#define TRUE 1 #define TRUE 1
#endif #endif
#else #else
#define OTUNIXERRORS 1
#include <OpenTransport.h> #include <OpenTransport.h>
#include <OpenTransportProviders.h> #include <OpenTransportProviders.h>
#include <OpenTptInternet.h> #include <OpenTptInternet.h>
@@ -123,7 +121,11 @@ OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode)
ret.opt.maxlen = kOTFourByteOptionSize; ret.opt.maxlen = kOTFourByteOptionSize;
opt->level = INET_IP; // dealing with an IP Level function opt->level = INET_IP; // dealing with an IP Level function
#ifdef __UNIX__
opt->name = kIP_REUSEADDR;
#else
opt->name = IP_REUSEADDR; opt->name = IP_REUSEADDR;
#endif
opt->len = kOTFourByteOptionSize; opt->len = kOTFourByteOptionSize;
opt->status = 0; opt->status = 0;
*(UInt32*)opt->value = enableReuseIPMode; // set the desired option level, true or false *(UInt32*)opt->value = enableReuseIPMode; // set the desired option level, true or false
@@ -1043,8 +1045,8 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size)
{ {
OTFlags flags ; OTFlags flags ;
OTResult res ; OTResult res ;
OTByteCount sz = 0 ;
size_t sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ; OTCountDataBytes( socket->m_endpoint , &sz ) ;
res = OTRcv( socket->m_endpoint , buffer , size , &flags ) ; res = OTRcv( socket->m_endpoint , buffer , size , &flags ) ;
if ( res < 0 ) if ( res < 0 )
@@ -1055,7 +1057,7 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size)
// we simulate another read event if there are still bytes // we simulate another read event if there are still bytes
if ( socket->m_takesEvents ) if ( socket->m_takesEvents )
{ {
size_t sz = 0 ; OTByteCount sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ; OTCountDataBytes( socket->m_endpoint , &sz ) ;
if ( sz > 0 ) if ( sz > 0 )
{ {
@@ -1365,7 +1367,7 @@ GSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, size_t
assert(address != NULL); assert(address != NULL);
CHECK_ADDRESS(address, INET, GSOCK_INVADDR); CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
OTInetAddressToName( gInetSvcRef , address->m_host , &name ) ; OTInetAddressToName( gInetSvcRef , address->m_host , name ) ;
strncpy( hostname , name , sbuf ) ; strncpy( hostname , name , sbuf ) ;
return GSOCK_NOERROR; return GSOCK_NOERROR;
} }
@@ -1397,7 +1399,7 @@ void _GSocket_Enable_Events(GSocket *socket)
state = OTGetEndpointState(socket->m_endpoint); state = OTGetEndpointState(socket->m_endpoint);
{ {
size_t sz = 0 ; OTByteCount sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ; OTCountDataBytes( socket->m_endpoint , &sz ) ;
if ( state == T_INCON || sz > 0 ) if ( state == T_INCON || sz > 0 )
{ {
@@ -1437,7 +1439,7 @@ GSocketError _GSocket_Input_Timeout(GSocket *socket)
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < socket->m_timeout * 1000.0 ) while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < socket->m_timeout * 1000.0 )
{ {
OTResult state ; OTResult state ;
size_t sz = 0 ; OTByteCount sz = 0 ;
state = OTGetEndpointState(socket->m_endpoint); state = OTGetEndpointState(socket->m_endpoint);
OTCountDataBytes( socket->m_endpoint , &sz ) ; OTCountDataBytes( socket->m_endpoint , &sz ) ;

View File

@@ -414,7 +414,11 @@ bool wxPNGReader::ReadFile(char * ImageFileName)
wxPNGReaderIter iter(this); wxPNGReaderIter iter(this);
/* open the file */ /* open the file */
#ifndef __UNIX__
fp = fopen(wxUnix2MacFilename( ImageFileName ), "rb"); fp = fopen(wxUnix2MacFilename( ImageFileName ), "rb");
#else
fp = fopen( ImageFileName , "rb" );
#endif
if (!fp) if (!fp)
return FALSE; return FALSE;

View File

@@ -17,12 +17,13 @@
// headers // headers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include "wx/mac/statusbr.h" #include "wx/defs.h"
#include "wx/statusbr.h"
IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXX, wxStatusBar); IMPLEMENT_DYNAMIC_CLASS(wxStatusBarMac, wxStatusBar);
BEGIN_EVENT_TABLE(wxStatusBarXX, wxStatusBar) BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBar)
EVT_SIZE(wxStatusBarXX::OnSize) EVT_SIZE(wxStatusBarMac::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -31,20 +32,15 @@ END_EVENT_TABLE()
// ============================================================================ // ============================================================================
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxStatusBarXX class // wxStatusBarMac class
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxStatusBarXX::wxStatusBarXX() wxStatusBarMac::wxStatusBarMac()
{ {
SetParent(NULL); SetParent(NULL);
} }
wxStatusBarXX::wxStatusBarXX(wxWindow *parent, wxWindowID id, long style) bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name = wxPanelNameStr)
{
Create(parent, id, style);
}
bool wxStatusBarXX::Create(wxWindow *parent, wxWindowID id, long style)
{ {
SetParent(parent); SetParent(parent);
@@ -57,7 +53,7 @@ bool wxStatusBarXX::Create(wxWindow *parent, wxWindowID id, long style)
return FALSE; return FALSE;
} }
void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[]) void wxStatusBarMac::SetFieldsCount(int nFields, const int widths[])
{ {
wxASSERT( (nFields > 0) && (nFields < 255) ); wxASSERT( (nFields > 0) && (nFields < 255) );
@@ -67,7 +63,7 @@ void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[])
SetFieldsWidth(); SetFieldsWidth();
} }
void wxStatusBarXX::SetStatusWidths(int n, const int widths[]) void wxStatusBarMac::SetStatusWidths(int n, const int widths[])
{ {
wxASSERT( n == m_nFields ); wxASSERT( n == m_nFields );
@@ -75,7 +71,7 @@ void wxStatusBarXX::SetStatusWidths(int n, const int widths[])
SetFieldsWidth(); SetFieldsWidth();
} }
void wxStatusBarXX::CopyFieldsWidth(const int widths[]) void wxStatusBarMac::CopyFieldsWidth(const int widths[])
{ {
if (widths && !m_statusWidths) if (widths && !m_statusWidths)
m_statusWidths = new int[m_nFields]; m_statusWidths = new int[m_nFields];
@@ -90,7 +86,7 @@ void wxStatusBarXX::CopyFieldsWidth(const int widths[])
} }
} }
void wxStatusBarXX::SetFieldsWidth() void wxStatusBarMac::SetFieldsWidth()
{ {
int *pWidths = new int[m_nFields]; int *pWidths = new int[m_nFields];
@@ -140,12 +136,12 @@ void wxStatusBarXX::SetFieldsWidth()
delete [] pWidths; delete [] pWidths;
} }
void wxStatusBarXX::SetStatusText(const wxString& strText, int nField) void wxStatusBarMac::SetStatusText(const wxString& strText, int nField)
{ {
// TODO // TODO
} }
wxString wxStatusBarXX::GetStatusText(int nField) const wxString wxStatusBarMac::GetStatusText(int nField) const
{ {
wxASSERT( (nField > -1) && (nField < m_nFields) ); wxASSERT( (nField > -1) && (nField < m_nFields) );
@@ -153,7 +149,7 @@ wxString wxStatusBarXX::GetStatusText(int nField) const
return wxString(""); return wxString("");
} }
void wxStatusBarXX::OnSize(wxSizeEvent& event) void wxStatusBarMac::OnSize(wxSizeEvent& event)
{ {
// adjust fields widths to the new size // adjust fields widths to the new size
SetFieldsWidth(); SetFieldsWidth();

View File

@@ -22,6 +22,7 @@
#include <fstream.h> #include <fstream.h>
#include "wx/app.h" #include "wx/app.h"
#include "wx/dc.h"
#include "wx/button.h" #include "wx/button.h"
#include "wx/panel.h" #include "wx/panel.h"
#include "wx/textctrl.h" #include "wx/textctrl.h"

View File

@@ -16,6 +16,7 @@
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
#include "wx/app.h" #include "wx/app.h"
#include "wx/dc.h"
#include "wx/window.h" #include "wx/window.h"
#include "wx/tooltip.h" #include "wx/tooltip.h"
#include "wx/timer.h" #include "wx/timer.h"

View File

@@ -1,9 +1,10 @@
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/dc.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#include "wx/mac/aga.h" #include "wx/mac/aga.h"
#ifdef __UNIX__ #ifdef __UNIX__
#include <NavigationServices/Navigation.h> #include <Carbon/Carbon.h>
#else #else
#include <Navigation.h> #include <Navigation.h>
#endif #endif

View File

@@ -260,6 +260,7 @@ bool wxIsBusy()
return (wxBusyCursorCount > 0); return (wxBusyCursorCount > 0);
} }
#ifndef __UNIX__
wxString wxMacFindFolder( short vol, wxString wxMacFindFolder( short vol,
OSType folderType, OSType folderType,
Boolean createFolder) Boolean createFolder)
@@ -278,6 +279,7 @@ wxString wxMacFindFolder( short vol,
} }
return strDir ; return strDir ;
} }
#endif
#ifndef __UNIX__ #ifndef __UNIX__
char *wxGetUserHome (const wxString& user) char *wxGetUserHome (const wxString& user)
@@ -343,6 +345,11 @@ void wxDisplaySize(int *width, int *height)
#endif #endif
} }
void wxDisplaySizeMM(int *width, int *height)
{
wxDisplaySize(width, height);
}
wxWindow* wxFindWindowAtPoint(const wxPoint& pt) wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{ {
return wxGenericFindWindowAtPoint(pt); return wxGenericFindWindowAtPoint(pt);

View File

@@ -14,11 +14,15 @@
#endif #endif
#include "wx/utils.h" #include "wx/utils.h"
#ifdef __UNIX__
#include "wx/unix/execute.h"
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifndef __UNIX__
#define wxEXECUTE_WIN_MESSAGE 10000 #define wxEXECUTE_WIN_MESSAGE 10000
long wxExecute(const wxString& command, bool sync, wxProcess *handler) long wxExecute(const wxString& command, bool sync, wxProcess *handler)
@@ -26,3 +30,12 @@ long wxExecute(const wxString& command, bool sync, wxProcess *handler)
// TODO // TODO
return 0; return 0;
} }
#endif
#ifdef __UNIX__
int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
{
wxFAIL_MSG(wxT("wxAddProcessCallback() function not ready"));
return 0;
}
#endif

View File

@@ -126,14 +126,18 @@ bool wxWave::Play(bool async, bool looped) const
if (m_isResource) if (m_isResource)
{ {
strcpy(lpSnd, m_sndname); #if TARGET_CARBON
c2pstr((char *) lpSnd); c2pstrcpy((unsigned char *)lpSnd, m_sndname);
SndListHandle hSnd; #else
strcpy(lpSnd, m_sndname);
hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd); c2pstr((char *) lpSnd);
#endif
SndListHandle hSnd;
hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd);
if ((hSnd != NULL) && (SndPlay(m_sndChan, hSnd, async) == noErr)) if ((hSnd != NULL) && (SndPlay(m_sndChan, hSnd, async) == noErr))
ret = true; ret = true;
} }
return ret; return ret;

View File

@@ -15,6 +15,7 @@
#include "wx/setup.h" #include "wx/setup.h"
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/window.h"
#include "wx/dc.h" #include "wx/dc.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/utils.h" #include "wx/utils.h"
@@ -33,9 +34,6 @@
#include "wx/tabctrl.h" #include "wx/tabctrl.h"
#include "wx/tooltip.h" #include "wx/tooltip.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
// TODO remove the line below, just for lookup-up convenience CS
#include "wx/window.h"
#include "wx/menuitem.h" #include "wx/menuitem.h"
#include "wx/log.h" #include "wx/log.h"
@@ -763,6 +761,11 @@ void wxWindow::MacSuperShown( bool show )
bool wxWindow::MacIsReallyShown() const bool wxWindow::MacIsReallyShown() const
{ {
if ( m_isShown && (m_parent != NULL) ) {
return m_parent->MacIsReallyShown();
}
return m_isShown;
/*
bool status = m_isShown ; bool status = m_isShown ;
wxWindow * win = this ; wxWindow * win = this ;
while ( status && win->m_parent != NULL ) while ( status && win->m_parent != NULL )
@@ -771,6 +774,7 @@ bool wxWindow::MacIsReallyShown() const
status = win->m_isShown ; status = win->m_isShown ;
} }
return status ; return status ;
*/
} }
int wxWindow::GetCharHeight() const int wxWindow::GetCharHeight() const
@@ -794,7 +798,7 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
wxClientDC dc( (wxWindow*) this ) ; wxClientDC dc( (wxWindow*) this ) ;
long lx,ly,ld,le ; long lx,ly,ld,le ;
dc.GetTextExtent( string , &lx , &ly , &ld, &le, fontToUse ) ; dc.GetTextExtent( string , &lx , &ly , &ld, &le, (wxFont *)fontToUse ) ;
if ( externalLeading ) if ( externalLeading )
*externalLeading = le ; *externalLeading = le ;
if ( descent ) if ( descent )
@@ -2306,7 +2310,37 @@ long wxWindow::MacRemoveBordersFromStyle( long style )
{ {
return style & ~( wxDOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxBORDER | wxSTATIC_BORDER ) ; return style & ~( wxDOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxBORDER | wxSTATIC_BORDER ) ;
} }
/*
wxMacFocusHelper::wxMacFocusHelper( wxWindow * theWindow )
{
m_ok = false ;
Point localOrigin ;
Rect clipRect ;
WindowRef window ;
wxWindow *rootwin ;
m_currentPort = NULL ;
GetPort( &m_formerPort ) ;
if ( theWindow )
{
theWindow->MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ;
m_currentPort = UMAGetWindowPort( window ) ;
theWindow->MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ;
m_ok = true ;
}
}
wxMacFocusHelper::~wxMacFocusHelper()
{
if ( m_ok )
{
SetPort( m_currentPort ) ;
SetOrigin( 0 , 0 ) ;
}
if ( m_formerPort != m_currentPort )
SetPort( m_formerPort ) ;
}
*/
wxMacDrawingHelper::wxMacDrawingHelper( wxWindow * theWindow ) wxMacDrawingHelper::wxMacDrawingHelper( wxWindow * theWindow )
{ {

Binary file not shown.

View File

@@ -20,6 +20,7 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/metafile.h" #include "wx/metafile.h"
#include "wx/clipbrd.h" #include "wx/clipbrd.h"
#include "wx/intl.h"
#define wxUSE_DATAOBJ 1 #define wxUSE_DATAOBJ 1

View File

@@ -16,6 +16,7 @@
#include "wx/control.h" #include "wx/control.h"
#include "wx/panel.h" #include "wx/panel.h"
#include "wx/app.h" #include "wx/app.h"
#include "wx/dc.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/tabctrl.h" #include "wx/tabctrl.h"
#include "wx/radiobox.h" #include "wx/radiobox.h"

View File

@@ -21,7 +21,7 @@
#include "wx/cmndata.h" #include "wx/cmndata.h"
#if defined(__UNIX__) #if defined(__UNIX__)
#include <NavigationServices/Navigation.h> #include <Carbon/Carbon.h>
#else #else
#include <Navigation.h> #include <Navigation.h>
#endif #endif
@@ -182,7 +182,7 @@ static Boolean SameFSSpec(FSSpecPtr spec1, FSSpecPtr spec2)
// flashing of the button when the key is hit // flashing of the button when the key is hit
static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec, static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec,
short *item, Ptr dataPtr) short *item, void *dataPtr)
{ {
#pragma unused (dataPtr) #pragma unused (dataPtr)
@@ -210,7 +210,7 @@ static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRec
// MyDlgHook is a hook routine that maps the select button to Open // MyDlgHook is a hook routine that maps the select button to Open
// and sets the Select button name // and sets the Select button name
static pascal short SFGetFolderDialogHook(short item, DialogPtr theDlgPtr, Ptr dataPtr) static pascal short SFGetFolderDialogHook(short item, DialogPtr theDlgPtr, void *dataPtr)
{ {
UserDataRecPtr theUserDataRecPtr; UserDataRecPtr theUserDataRecPtr;
long desktopDirID; long desktopDirID;
@@ -422,7 +422,7 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
} }
} }
static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr) static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
{ {
#pragma unused (dataPtr) #pragma unused (dataPtr)

View File

@@ -39,20 +39,22 @@ wxDropTarget::~wxDropTarget()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTextDropTarget // wxTextDropTarget
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef __WXMAC_X__
bool wxTextDropTarget::OnDrop( long x, long y, const void *pData ) bool wxTextDropTarget::OnDrop( wxCoord x, wxCoord y, const void *pData )
{ {
OnDropText( x, y, (const char*)pData ); OnDropText( x, y, (const char*)pData );
return TRUE; return TRUE;
}; };
#endif
bool wxTextDropTarget::OnDropText( long x, long y, const char *psz ) bool wxTextDropTarget::OnDropText( wxCoord x, wxCoord y, const wxString &psz )
{ {
printf( "Got dropped text: %s.\n", psz ); printf( "Got dropped text: %s.\n", (char *)psz );
printf( "At x: %d, y: %d.\n", (int)x, (int)y ); printf( "At x: %d, y: %d.\n", (int)x, (int)y );
return TRUE; return TRUE;
}; };
#ifndef __WXMAC_X__
size_t wxTextDropTarget::GetFormatCount() const size_t wxTextDropTarget::GetFormatCount() const
{ {
return 1; return 1;
@@ -62,25 +64,27 @@ wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
{ {
return wxDF_TEXT; return wxDF_TEXT;
} }
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxFileDropTarget // wxFileDropTarget
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const WXUNUSED(aszFiles)[] ) #ifndef __WXMAC_X__
bool wxFileDropTarget::OnDropFiles( wxCoord x, wxCoord y, size_t nFiles, const char * const WXUNUSED(aszFiles)[] )
{ {
printf( "Got %d dropped files.\n", (int)nFiles ); printf( "Got %d dropped files.\n", (int)nFiles );
printf( "At x: %d, y: %d.\n", (int)x, (int)y ); printf( "At x: %d, y: %d.\n", (int)x, (int)y );
return TRUE; return TRUE;
} }
#endif
bool wxFileDropTarget::OnDrop(long x, long y, const void *WXUNUSED(pData) ) bool wxFileDropTarget::OnDrop(wxCoord x, wxCoord y, const wxArrayString& filenames)
{ {
char *str = "/this/is/a/path.txt"; return OnDropFiles(x, y, 1, &filenames);
return OnDropFiles(x, y, 1, &str );
} }
#ifndef __WXMAC_X__
size_t wxFileDropTarget::GetFormatCount() const size_t wxFileDropTarget::GetFormatCount() const
{ {
return 1; return 1;
@@ -90,6 +94,7 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
{ {
return wxDF_FILENAME; return wxDF_FILENAME;
} }
#endif
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// wxDropSource // wxDropSource

View File

@@ -14,6 +14,7 @@
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/app.h"
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/filedlg.h" #include "wx/filedlg.h"
@@ -30,7 +31,7 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog)
// begin wxmac // begin wxmac
#if defined(__UNIX__) #if defined(__UNIX__)
#include <NavigationServices/Navigation.h> #include <Carbon/Carbon.h>
#else #else
#include <Navigation.h> #include <Navigation.h>
#endif #endif
@@ -73,6 +74,7 @@ NavEventProc(
#endif #endif
*/ */
wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event);
} }
} }
@@ -210,7 +212,7 @@ static Boolean SameFSSpec(FSSpecPtr spec1, FSSpecPtr spec2)
// flashing of the button when the key is hit // flashing of the button when the key is hit
static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec, static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec,
short *item, Ptr dataPtr) short *item, void *dataPtr)
{ {
#pragma unused (dataPtr) #pragma unused (dataPtr)
@@ -371,7 +373,7 @@ void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const
} }
} }
static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr) static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
{ {
Str255 filename ; Str255 filename ;
OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ; OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ;

View File

@@ -19,11 +19,8 @@
#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
#define OTUNIXERRORS 1
#ifdef __UNIX__ #ifdef __UNIX__
#include <CarbonCore/CarbonCore.h> #include <CoreServices/CoreServices.h>
#include <OT/OpenTransport.h>
#include <OT/OpenTransportProviders.h>
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0
@@ -32,6 +29,7 @@
#define TRUE 1 #define TRUE 1
#endif #endif
#else #else
#define OTUNIXERRORS 1
#include <OpenTransport.h> #include <OpenTransport.h>
#include <OpenTransportProviders.h> #include <OpenTransportProviders.h>
#include <OpenTptInternet.h> #include <OpenTptInternet.h>
@@ -123,7 +121,11 @@ OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode)
ret.opt.maxlen = kOTFourByteOptionSize; ret.opt.maxlen = kOTFourByteOptionSize;
opt->level = INET_IP; // dealing with an IP Level function opt->level = INET_IP; // dealing with an IP Level function
#ifdef __UNIX__
opt->name = kIP_REUSEADDR;
#else
opt->name = IP_REUSEADDR; opt->name = IP_REUSEADDR;
#endif
opt->len = kOTFourByteOptionSize; opt->len = kOTFourByteOptionSize;
opt->status = 0; opt->status = 0;
*(UInt32*)opt->value = enableReuseIPMode; // set the desired option level, true or false *(UInt32*)opt->value = enableReuseIPMode; // set the desired option level, true or false
@@ -1043,8 +1045,8 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size)
{ {
OTFlags flags ; OTFlags flags ;
OTResult res ; OTResult res ;
OTByteCount sz = 0 ;
size_t sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ; OTCountDataBytes( socket->m_endpoint , &sz ) ;
res = OTRcv( socket->m_endpoint , buffer , size , &flags ) ; res = OTRcv( socket->m_endpoint , buffer , size , &flags ) ;
if ( res < 0 ) if ( res < 0 )
@@ -1055,7 +1057,7 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size)
// we simulate another read event if there are still bytes // we simulate another read event if there are still bytes
if ( socket->m_takesEvents ) if ( socket->m_takesEvents )
{ {
size_t sz = 0 ; OTByteCount sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ; OTCountDataBytes( socket->m_endpoint , &sz ) ;
if ( sz > 0 ) if ( sz > 0 )
{ {
@@ -1365,7 +1367,7 @@ GSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, size_t
assert(address != NULL); assert(address != NULL);
CHECK_ADDRESS(address, INET, GSOCK_INVADDR); CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
OTInetAddressToName( gInetSvcRef , address->m_host , &name ) ; OTInetAddressToName( gInetSvcRef , address->m_host , name ) ;
strncpy( hostname , name , sbuf ) ; strncpy( hostname , name , sbuf ) ;
return GSOCK_NOERROR; return GSOCK_NOERROR;
} }
@@ -1397,7 +1399,7 @@ void _GSocket_Enable_Events(GSocket *socket)
state = OTGetEndpointState(socket->m_endpoint); state = OTGetEndpointState(socket->m_endpoint);
{ {
size_t sz = 0 ; OTByteCount sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ; OTCountDataBytes( socket->m_endpoint , &sz ) ;
if ( state == T_INCON || sz > 0 ) if ( state == T_INCON || sz > 0 )
{ {
@@ -1437,7 +1439,7 @@ GSocketError _GSocket_Input_Timeout(GSocket *socket)
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < socket->m_timeout * 1000.0 ) while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < socket->m_timeout * 1000.0 )
{ {
OTResult state ; OTResult state ;
size_t sz = 0 ; OTByteCount sz = 0 ;
state = OTGetEndpointState(socket->m_endpoint); state = OTGetEndpointState(socket->m_endpoint);
OTCountDataBytes( socket->m_endpoint , &sz ) ; OTCountDataBytes( socket->m_endpoint , &sz ) ;

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#if defined(__UNIX__) #if defined(__UNIX__)
#include <HIToolbox/lists.h> #include <Carbon/Carbon.h>
#else #else
#include <Lists.h> #include <Lists.h>
#endif #endif

Binary file not shown.

View File

@@ -414,7 +414,11 @@ bool wxPNGReader::ReadFile(char * ImageFileName)
wxPNGReaderIter iter(this); wxPNGReaderIter iter(this);
/* open the file */ /* open the file */
#ifndef __UNIX__
fp = fopen(wxUnix2MacFilename( ImageFileName ), "rb"); fp = fopen(wxUnix2MacFilename( ImageFileName ), "rb");
#else
fp = fopen( ImageFileName , "rb" );
#endif
if (!fp) if (!fp)
return FALSE; return FALSE;

View File

@@ -17,12 +17,13 @@
// headers // headers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include "wx/mac/statusbr.h" #include "wx/defs.h"
#include "wx/statusbr.h"
IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXX, wxStatusBar); IMPLEMENT_DYNAMIC_CLASS(wxStatusBarMac, wxStatusBar);
BEGIN_EVENT_TABLE(wxStatusBarXX, wxStatusBar) BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBar)
EVT_SIZE(wxStatusBarXX::OnSize) EVT_SIZE(wxStatusBarMac::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -31,20 +32,15 @@ END_EVENT_TABLE()
// ============================================================================ // ============================================================================
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxStatusBarXX class // wxStatusBarMac class
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxStatusBarXX::wxStatusBarXX() wxStatusBarMac::wxStatusBarMac()
{ {
SetParent(NULL); SetParent(NULL);
} }
wxStatusBarXX::wxStatusBarXX(wxWindow *parent, wxWindowID id, long style) bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name = wxPanelNameStr)
{
Create(parent, id, style);
}
bool wxStatusBarXX::Create(wxWindow *parent, wxWindowID id, long style)
{ {
SetParent(parent); SetParent(parent);
@@ -57,7 +53,7 @@ bool wxStatusBarXX::Create(wxWindow *parent, wxWindowID id, long style)
return FALSE; return FALSE;
} }
void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[]) void wxStatusBarMac::SetFieldsCount(int nFields, const int widths[])
{ {
wxASSERT( (nFields > 0) && (nFields < 255) ); wxASSERT( (nFields > 0) && (nFields < 255) );
@@ -67,7 +63,7 @@ void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[])
SetFieldsWidth(); SetFieldsWidth();
} }
void wxStatusBarXX::SetStatusWidths(int n, const int widths[]) void wxStatusBarMac::SetStatusWidths(int n, const int widths[])
{ {
wxASSERT( n == m_nFields ); wxASSERT( n == m_nFields );
@@ -75,7 +71,7 @@ void wxStatusBarXX::SetStatusWidths(int n, const int widths[])
SetFieldsWidth(); SetFieldsWidth();
} }
void wxStatusBarXX::CopyFieldsWidth(const int widths[]) void wxStatusBarMac::CopyFieldsWidth(const int widths[])
{ {
if (widths && !m_statusWidths) if (widths && !m_statusWidths)
m_statusWidths = new int[m_nFields]; m_statusWidths = new int[m_nFields];
@@ -90,7 +86,7 @@ void wxStatusBarXX::CopyFieldsWidth(const int widths[])
} }
} }
void wxStatusBarXX::SetFieldsWidth() void wxStatusBarMac::SetFieldsWidth()
{ {
int *pWidths = new int[m_nFields]; int *pWidths = new int[m_nFields];
@@ -140,12 +136,12 @@ void wxStatusBarXX::SetFieldsWidth()
delete [] pWidths; delete [] pWidths;
} }
void wxStatusBarXX::SetStatusText(const wxString& strText, int nField) void wxStatusBarMac::SetStatusText(const wxString& strText, int nField)
{ {
// TODO // TODO
} }
wxString wxStatusBarXX::GetStatusText(int nField) const wxString wxStatusBarMac::GetStatusText(int nField) const
{ {
wxASSERT( (nField > -1) && (nField < m_nFields) ); wxASSERT( (nField > -1) && (nField < m_nFields) );
@@ -153,7 +149,7 @@ wxString wxStatusBarXX::GetStatusText(int nField) const
return wxString(""); return wxString("");
} }
void wxStatusBarXX::OnSize(wxSizeEvent& event) void wxStatusBarMac::OnSize(wxSizeEvent& event)
{ {
// adjust fields widths to the new size // adjust fields widths to the new size
SetFieldsWidth(); SetFieldsWidth();

View File

@@ -22,6 +22,7 @@
#include <fstream.h> #include <fstream.h>
#include "wx/app.h" #include "wx/app.h"
#include "wx/dc.h"
#include "wx/button.h" #include "wx/button.h"
#include "wx/panel.h" #include "wx/panel.h"
#include "wx/textctrl.h" #include "wx/textctrl.h"

View File

@@ -16,6 +16,7 @@
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
#include "wx/app.h" #include "wx/app.h"
#include "wx/dc.h"
#include "wx/window.h" #include "wx/window.h"
#include "wx/tooltip.h" #include "wx/tooltip.h"
#include "wx/timer.h" #include "wx/timer.h"

View File

@@ -1,9 +1,10 @@
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/dc.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#include "wx/mac/aga.h" #include "wx/mac/aga.h"
#ifdef __UNIX__ #ifdef __UNIX__
#include <NavigationServices/Navigation.h> #include <Carbon/Carbon.h>
#else #else
#include <Navigation.h> #include <Navigation.h>
#endif #endif

View File

@@ -260,6 +260,7 @@ bool wxIsBusy()
return (wxBusyCursorCount > 0); return (wxBusyCursorCount > 0);
} }
#ifndef __UNIX__
wxString wxMacFindFolder( short vol, wxString wxMacFindFolder( short vol,
OSType folderType, OSType folderType,
Boolean createFolder) Boolean createFolder)
@@ -278,6 +279,7 @@ wxString wxMacFindFolder( short vol,
} }
return strDir ; return strDir ;
} }
#endif
#ifndef __UNIX__ #ifndef __UNIX__
char *wxGetUserHome (const wxString& user) char *wxGetUserHome (const wxString& user)
@@ -343,6 +345,11 @@ void wxDisplaySize(int *width, int *height)
#endif #endif
} }
void wxDisplaySizeMM(int *width, int *height)
{
wxDisplaySize(width, height);
}
wxWindow* wxFindWindowAtPoint(const wxPoint& pt) wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{ {
return wxGenericFindWindowAtPoint(pt); return wxGenericFindWindowAtPoint(pt);

View File

@@ -14,11 +14,15 @@
#endif #endif
#include "wx/utils.h" #include "wx/utils.h"
#ifdef __UNIX__
#include "wx/unix/execute.h"
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifndef __UNIX__
#define wxEXECUTE_WIN_MESSAGE 10000 #define wxEXECUTE_WIN_MESSAGE 10000
long wxExecute(const wxString& command, bool sync, wxProcess *handler) long wxExecute(const wxString& command, bool sync, wxProcess *handler)
@@ -26,3 +30,12 @@ long wxExecute(const wxString& command, bool sync, wxProcess *handler)
// TODO // TODO
return 0; return 0;
} }
#endif
#ifdef __UNIX__
int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
{
wxFAIL_MSG(wxT("wxAddProcessCallback() function not ready"));
return 0;
}
#endif

View File

@@ -126,14 +126,18 @@ bool wxWave::Play(bool async, bool looped) const
if (m_isResource) if (m_isResource)
{ {
strcpy(lpSnd, m_sndname); #if TARGET_CARBON
c2pstr((char *) lpSnd); c2pstrcpy((unsigned char *)lpSnd, m_sndname);
SndListHandle hSnd; #else
strcpy(lpSnd, m_sndname);
hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd); c2pstr((char *) lpSnd);
#endif
SndListHandle hSnd;
hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd);
if ((hSnd != NULL) && (SndPlay(m_sndChan, hSnd, async) == noErr)) if ((hSnd != NULL) && (SndPlay(m_sndChan, hSnd, async) == noErr))
ret = true; ret = true;
} }
return ret; return ret;

View File

@@ -15,6 +15,7 @@
#include "wx/setup.h" #include "wx/setup.h"
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/window.h"
#include "wx/dc.h" #include "wx/dc.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/utils.h" #include "wx/utils.h"
@@ -33,9 +34,6 @@
#include "wx/tabctrl.h" #include "wx/tabctrl.h"
#include "wx/tooltip.h" #include "wx/tooltip.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
// TODO remove the line below, just for lookup-up convenience CS
#include "wx/window.h"
#include "wx/menuitem.h" #include "wx/menuitem.h"
#include "wx/log.h" #include "wx/log.h"
@@ -763,6 +761,11 @@ void wxWindow::MacSuperShown( bool show )
bool wxWindow::MacIsReallyShown() const bool wxWindow::MacIsReallyShown() const
{ {
if ( m_isShown && (m_parent != NULL) ) {
return m_parent->MacIsReallyShown();
}
return m_isShown;
/*
bool status = m_isShown ; bool status = m_isShown ;
wxWindow * win = this ; wxWindow * win = this ;
while ( status && win->m_parent != NULL ) while ( status && win->m_parent != NULL )
@@ -771,6 +774,7 @@ bool wxWindow::MacIsReallyShown() const
status = win->m_isShown ; status = win->m_isShown ;
} }
return status ; return status ;
*/
} }
int wxWindow::GetCharHeight() const int wxWindow::GetCharHeight() const
@@ -794,7 +798,7 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
wxClientDC dc( (wxWindow*) this ) ; wxClientDC dc( (wxWindow*) this ) ;
long lx,ly,ld,le ; long lx,ly,ld,le ;
dc.GetTextExtent( string , &lx , &ly , &ld, &le, fontToUse ) ; dc.GetTextExtent( string , &lx , &ly , &ld, &le, (wxFont *)fontToUse ) ;
if ( externalLeading ) if ( externalLeading )
*externalLeading = le ; *externalLeading = le ;
if ( descent ) if ( descent )
@@ -2306,7 +2310,37 @@ long wxWindow::MacRemoveBordersFromStyle( long style )
{ {
return style & ~( wxDOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxBORDER | wxSTATIC_BORDER ) ; return style & ~( wxDOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxBORDER | wxSTATIC_BORDER ) ;
} }
/*
wxMacFocusHelper::wxMacFocusHelper( wxWindow * theWindow )
{
m_ok = false ;
Point localOrigin ;
Rect clipRect ;
WindowRef window ;
wxWindow *rootwin ;
m_currentPort = NULL ;
GetPort( &m_formerPort ) ;
if ( theWindow )
{
theWindow->MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ;
m_currentPort = UMAGetWindowPort( window ) ;
theWindow->MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ;
m_ok = true ;
}
}
wxMacFocusHelper::~wxMacFocusHelper()
{
if ( m_ok )
{
SetPort( m_currentPort ) ;
SetOrigin( 0 , 0 ) ;
}
if ( m_formerPort != m_currentPort )
SetPort( m_formerPort ) ;
}
*/
wxMacDrawingHelper::wxMacDrawingHelper( wxWindow * theWindow ) wxMacDrawingHelper::wxMacDrawingHelper( wxWindow * theWindow )
{ {

View File

@@ -40,10 +40,6 @@
#include "wx/setup.h" #include "wx/setup.h"
#ifdef macintosh #ifdef macintosh
#ifdef __std
#undef __std
#define __std()
#endif
#include <stat.h> #include <stat.h>
#include <unix.h> #include <unix.h>
#include <unistd.h> #include <unistd.h>

View File

@@ -35,10 +35,6 @@
#include "wx/setup.h" #include "wx/setup.h"
#ifdef macintosh #ifdef macintosh
#ifdef __std
#undef __std
#define __std()
#endif
#include <stat.h> #include <stat.h>
#include <unix.h> #include <unix.h>
#include <unistd.h> #include <unistd.h>

View File

@@ -1,487 +0,0 @@
/*
* Copyright (C) 1989-95 GROUPE BULL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of GROUPE BULL shall not be
* used in advertising or otherwise to promote the sale, use or other dealings
* in this Software without prior written authorization from GROUPE BULL.
*/
/*****************************************************************************\
* data.c: *
* *
* XPM library *
* IO utilities *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifndef CXPMPROG
/* Official version number */
static char *RCS_Version = "$XpmVersion: 3.4k $";
/* Internal version number */
static char *RCS_Id = "$Id$";
#include "XpmI.h"
#endif
#include <ctype.h>
#ifndef CXPMPROG
#define Getc(data, file) getc(file)
#define Ungetc(data, c, file) ungetc(c, file)
#endif
static int
ParseComment(data)
xpmData *data;
{
if (data->type == XPMBUFFER) {
register char c;
register unsigned int n = 0;
unsigned int notend;
char *s, *s2;
s = data->Comment;
*s = data->Bcmt[0];
/* skip the string beginning comment */
s2 = data->Bcmt;
do {
c = *data->cptr++;
*++s = c;
n++;
s2++;
} while (c == *s2 && *s2 != '\0' && c);
if (*s2 != '\0') {
/* this wasn't the beginning of a comment */
data->cptr -= n;
return 0;
}
/* store comment */
data->Comment[0] = *s;
s = data->Comment;
notend = 1;
n = 0;
while (notend) {
s2 = data->Ecmt;
while (*s != *s2 && c) {
c = *data->cptr++;
if (n == XPMMAXCMTLEN - 1) { /* forget it */
s = data->Comment;
n = 0;
}
*++s = c;
n++;
}
data->CommentLength = n;
do {
c = *data->cptr++;
if (n == XPMMAXCMTLEN - 1) { /* forget it */
s = data->Comment;
n = 0;
}
*++s = c;
n++;
s2++;
} while (c == *s2 && *s2 != '\0' && c);
if (*s2 == '\0') {
/* this is the end of the comment */
notend = 0;
data->cptr--;
}
}
return 0;
} else {
FILE *file = data->stream.file;
register int c;
register unsigned int n = 0, a;
unsigned int notend;
char *s, *s2;
s = data->Comment;
*s = data->Bcmt[0];
/* skip the string beginning comment */
s2 = data->Bcmt;
do {
c = Getc(data, file);
*++s = c;
n++;
s2++;
} while (c == *s2 && *s2 != '\0' && c != EOF);
if (*s2 != '\0') {
/* this wasn't the beginning of a comment */
/* put characters back in the order that we got them */
for (a = n; a > 0; a--, s--)
Ungetc(data, *s, file);
return 0;
}
/* store comment */
data->Comment[0] = *s;
s = data->Comment;
notend = 1;
n = 0;
while (notend) {
s2 = data->Ecmt;
while (*s != *s2 && c != EOF) {
c = Getc(data, file);
if (n == XPMMAXCMTLEN - 1) { /* forget it */
s = data->Comment;
n = 0;
}
*++s = c;
n++;
}
data->CommentLength = n;
do {
c = Getc(data, file);
if (n == XPMMAXCMTLEN - 1) { /* forget it */
s = data->Comment;
n = 0;
}
*++s = c;
n++;
s2++;
} while (c == *s2 && *s2 != '\0' && c != EOF);
if (*s2 == '\0') {
/* this is the end of the comment */
notend = 0;
Ungetc(data, *s, file);
}
}
return 0;
}
}
/*
* skip to the end of the current string and the beginning of the next one
*/
int
xpmNextString(data)
xpmData *data;
{
if (!data->type)
data->cptr = (data->stream.data)[++data->line];
else if (data->type == XPMBUFFER) {
register char c;
/* get to the end of the current string */
if (data->Eos)
while ((c = *data->cptr++)!=NULL && c != data->Eos)
{}
/*
* then get to the beginning of the next string looking for possible
* comment
*/
if (data->Bos) {
while ((c = *data->cptr++)!=NULL && c != data->Bos)
if (data->Bcmt && c == data->Bcmt[0])
ParseComment(data);
} else if (data->Bcmt) { /* XPM2 natural */
while ((c = *data->cptr++) == data->Bcmt[0])
ParseComment(data);
data->cptr--;
}
} else {
register int c;
FILE *file = data->stream.file;
/* get to the end of the current string */
if (data->Eos)
while ((c = Getc(data, file))!=NULL != data->Eos && c != EOF)
{}
/*
* then get to the beginning of the next string looking for possible
* comment
*/
if (data->Bos) {
while ((c = Getc(data, file)) != data->Bos && c != EOF)
if (data->Bcmt && c == data->Bcmt[0])
ParseComment(data);
} else if (data->Bcmt) { /* XPM2 natural */
while ((c = Getc(data, file)) == data->Bcmt[0])
ParseComment(data);
Ungetc(data, c, file);
}
}
return 0;
}
/*
* skip whitespace and return the following word
*/
unsigned int
xpmNextWord(data, buf, buflen)
xpmData *data;
char *buf;
unsigned int buflen;
{
register unsigned int n = 0;
int c;
if (!data->type || data->type == XPMBUFFER) {
while (isspace(c = *data->cptr) && c != data->Eos)
data->cptr++;
do {
c = *data->cptr++;
*buf++ = c;
n++;
} while (!isspace(c) && c != data->Eos && n < buflen);
n--;
data->cptr--;
} else {
FILE *file = data->stream.file;
while ((c = Getc(data, file)) != EOF && isspace(c) && c != data->Eos)
{
}
while (!isspace(c) && c != data->Eos && c != EOF && n < buflen) {
*buf++ = c;
n++;
c = Getc(data, file);
}
Ungetc(data, c, file);
}
return (n);
}
/*
* skip whitespace and compute the following unsigned int,
* returns 1 if one is found and 0 if not
*/
int
xpmNextUI(data, ui_return)
xpmData *data;
unsigned int *ui_return;
{
char buf[BUFSIZ];
int l;
l = xpmNextWord(data, buf, BUFSIZ);
return xpmatoui(buf, l, ui_return);
}
/*
* return end of string - WARNING: malloc!
*/
int
xpmGetString(data, sptr, l)
xpmData *data;
char **sptr;
unsigned int *l;
{
unsigned int i, n = 0;
int c;
char *p = NULL, *q, buf[BUFSIZ];
if (!data->type || data->type == XPMBUFFER) {
if (data->cptr) {
char *start = data->cptr;
while ((c = *data->cptr)!=NULL && c != data->Eos)
data->cptr++;
n = data->cptr - start + 1;
p = (char *) XpmMalloc(n);
if (!p)
return (XpmNoMemory);
strncpy(p, start, n);
if (data->type) /* XPMBUFFER */
p[n - 1] = '\0';
}
} else {
FILE *file = data->stream.file;
if ((c = Getc(data, file)) == EOF)
return (XpmFileInvalid);
i = 0;
q = buf;
p = (char *) XpmMalloc(1);
while (c != data->Eos && c != EOF) {
if (i == BUFSIZ) {
/* get to the end of the buffer */
/* malloc needed memory */
q = (char *) XpmRealloc(p, n + i);
if (!q) {
XpmFree(p);
return (XpmNoMemory);
}
p = q;
q += n;
/* and copy what we already have */
strncpy(q, buf, i);
n += i;
i = 0;
q = buf;
}
*q++ = c;
i++;
c = Getc(data, file);
}
if (c == EOF) {
XpmFree(p);
return (XpmFileInvalid);
}
if (n + i != 0) {
/* malloc needed memory */
q = (char *) XpmRealloc(p, n + i + 1);
if (!q) {
XpmFree(p);
return (XpmNoMemory);
}
p = q;
q += n;
/* and copy the buffer */
strncpy(q, buf, i);
n += i;
p[n++] = '\0';
} else {
*p = '\0';
n = 1;
}
Ungetc(data, c, file);
}
*sptr = p;
*l = n;
return (XpmSuccess);
}
/*
* get the current comment line
*/
int
xpmGetCmt(data, cmt)
xpmData *data;
char **cmt;
{
if (!data->type)
*cmt = NULL;
else if (data->CommentLength) {
*cmt = (char *) XpmMalloc(data->CommentLength + 1);
strncpy(*cmt, data->Comment, data->CommentLength);
(*cmt)[data->CommentLength] = '\0';
data->CommentLength = 0;
} else
*cmt = NULL;
return 0;
}
xpmDataType xpmDataTypes[] =
{
"", "!", "\n", '\0', '\n', "", "", "", "", /* Natural type */
"C", "/*", "*/", '"', '"', ",\n", "static char *", "[] = {\n", "};\n",
"Lisp", ";", "\n", '"', '"', "\n", "(setq ", " '(\n", "))\n",
#ifdef VMS
NULL
#else
NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL
#endif
};
/*
* parse xpm header
*/
int
xpmParseHeader(data)
xpmData *data;
{
char buf[BUFSIZ];
int l, n = 0;
if (data->type) {
data->Bos = '\0';
data->Eos = '\n';
data->Bcmt = data->Ecmt = NULL;
l = xpmNextWord(data, buf, BUFSIZ);
if (l == 7 && !strncmp("#define", buf, 7)) {
/* this maybe an XPM 1 file */
char *ptr;
l = xpmNextWord(data, buf, BUFSIZ);
if (!l)
return (XpmFileInvalid);
buf[l] = '\0';
#if defined(macintosh) || defined(__APPLE__)
ptr = strrchr(buf, '_');
#else
ptr = rindex(buf, '_');
#endif
if (!ptr || strncmp("_format", ptr, l - (ptr - buf)))
return XpmFileInvalid;
/* this is definitely an XPM 1 file */
data->format = 1;
n = 1; /* handle XPM1 as mainly XPM2 C */
} else {
/*
* skip the first word, get the second one, and see if this is
* XPM 2 or 3
*/
l = xpmNextWord(data, buf, BUFSIZ);
if ((l == 3 && !strncmp("XPM", buf, 3)) ||
(l == 4 && !strncmp("XPM2", buf, 4))) {
if (l == 3)
n = 1; /* handle XPM as XPM2 C */
else {
/* get the type key word */
l = xpmNextWord(data, buf, BUFSIZ);
/*
* get infos about this type
*/
while (xpmDataTypes[n].type
&& strncmp(xpmDataTypes[n].type, buf, l))
n++;
}
data->format = 0;
} else
/* nope this is not an XPM file */
return XpmFileInvalid;
}
if (xpmDataTypes[n].type) {
if (n == 0) { /* natural type */
data->Bcmt = xpmDataTypes[n].Bcmt;
data->Ecmt = xpmDataTypes[n].Ecmt;
xpmNextString(data); /* skip the end of the headerline */
data->Bos = xpmDataTypes[n].Bos;
data->Eos = xpmDataTypes[n].Eos;
} else {
data->Bcmt = xpmDataTypes[n].Bcmt;
data->Ecmt = xpmDataTypes[n].Ecmt;
if (!data->format) { /* XPM 2 or 3 */
data->Bos = xpmDataTypes[n].Bos;
data->Eos = '\0';
/* get to the beginning of the first string */
xpmNextString(data);
data->Eos = xpmDataTypes[n].Eos;
} else /* XPM 1 skip end of line */
xpmNextString(data);
}
} else
/* we don't know about that type of XPM file... */
return XpmFileInvalid;
}
return XpmSuccess;
}

Binary file not shown.

View File

@@ -680,7 +680,7 @@ wxDialUpManagerImpl::CheckIfconfig()
cmd << " -a"; cmd << " -a";
#elif defined(__LINUX__) || defined(__SGI__) #elif defined(__LINUX__) || defined(__SGI__)
// nothing to be added to ifconfig // nothing to be added to ifconfig
#elif defined(__FREEBSD__) #elif defined(__FREEBSD__) || defined(__WXMAC__)
// add -l flag // add -l flag
cmd << " -l"; cmd << " -l";
#elif defined(__HPUX__) #elif defined(__HPUX__)
@@ -775,7 +775,7 @@ wxDialUpManagerImpl::NetConnection wxDialUpManagerImpl::CheckPing()
cmd << m_PingPath << ' '; cmd << m_PingPath << ' ';
#if defined(__SOLARIS__) || defined (__SUNOS__) #if defined(__SOLARIS__) || defined (__SUNOS__)
// nothing to add to ping command // nothing to add to ping command
#elif defined(__LINUX__) || defined ( __FREEBSD__) #elif defined(__LINUX__) || defined ( __FREEBSD__) || defined(__WXMAC__)
cmd << "-c 1 "; // only ping once cmd << "-c 1 "; // only ping once
#elif defined(__HPUX__) #elif defined(__HPUX__)
cmd << "64 1 "; // only ping once (need also specify the packet size) cmd << "64 1 "; // only ping once (need also specify the packet size)