int m_min;
int m_max;
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
};
#endif // _WX_GENERIC_SPINCTRL_H_
#define wxMulDivInt32( a , b , c ) ::MulDiv( a , b , c )
#elif defined( __WXMAC__ )
#ifdef __WXMAC_X__
- #include <CarbonCore/Math64.h>
+ #include <CoreServices/CoreServices.h>
#else
#include "Math64.h"
#endif
// This must be part of the module you want to force:
#define FORCE_LINK_ME(module_name) \
+ int _link_dummy_func_##module_name (); \
int _link_dummy_func_##module_name () \
{ \
return 1; \
bool Create(const wxBitmap& bitmap);
// Implementation
+ bool PointMasked(int x, int y);
inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
protected:
wxBitmap(int width, int height, int depth = -1);
~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(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 SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL);
- inline bool Ok() const { return (M_BITMAPDATA && M_BITMAPDATA->m_ok); }
- inline int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); }
- inline int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); }
- inline int GetDepth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_depth : 0); }
- inline int GetQuality() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_quality : 0); }
+ bool Ok() const;
+ int GetWidth() const;
+ int GetHeight() const;
+ int GetDepth() const;
+ int GetQuality() const;
void SetWidth(int w);
void SetHeight(int h);
void SetDepth(int d);
void SetQuality(int q);
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);
- inline wxMask *GetMask() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_bitmapMask : (wxMask*) NULL); }
+ wxMask *GetMask() const;
void SetMask(wxMask *mask) ;
+ int GetBitmapType() const;
+
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; }
// TODO: Implementation
public:
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);
};
#endif
public:
wxChoice() {}
- ~wxChoice() ;
+ virtual ~wxChoice() ;
wxChoice(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxValidator& validator = wxDefaultValidator,
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 Clear();
+
virtual int GetCount() const ;
virtual int GetSelection() const ;
virtual void SetSelection(int n);
+
virtual int FindString(const wxString& s) const;
virtual wxString GetString(int n) const ;
virtual void SetString( int , const wxString& s ) ;
virtual wxString GetStringSelection() const ;
virtual bool SetStringSelection(const wxString& sel);
- virtual inline int Number() const { return m_strings.GetCount(); }
- virtual inline int GetCount() const { return m_strings.GetCount(); }
+ // Mac specific
virtual void Command(wxCommandEvent& event);
+ void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
virtual inline int GetColumns() const { return 1 ; };
*/
virtual void OnEnter() { }
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:
public:
wxTextDropTarget() {};
- virtual bool OnDrop( long x, long y, const void *pData );
- virtual bool OnDropText( long x, long y, const char *psz );
+ virtual bool OnDrop( wxCoord x, wxCoord y, const void *pData );
+ virtual bool OnDropText( wxCoord x, wxCoord y, const char *psz );
protected:
wxFileDropTarget() {};
- virtual bool OnDrop(long x, long y, const void *pData);
- virtual bool OnDropFiles( long x, long y,
+ virtual bool OnDrop(wxCoord x, wxCoord y, const void *pData);
+ virtual bool OnDropFiles( wxCoord x, wxCoord y,
size_t nFiles, const char * const aszFiles[]);
protected:
#include "wx/gdiobj.h"
#if wxUSE_DRAG_AND_DROP
-#include "wx/dataobj.h" wx/defs.h
+#include "wx/dataobj.h"
#endif
/*
// for compatibility with wxMSW
void SetIcon(const wxIcon& icon)
{
- SetBitmap( icon );
+ SetBitmap( (const wxBitmap&) icon );
}
// overriden base class virtuals
#pragma interface "statbar.h"
#endif
-#include "wx/generic/statusbr.h"
-
class WXDLLEXPORT wxStatusBarMac : public wxStatusBarGeneric
{
DECLARE_DYNAMIC_CLASS(wxStatusBarMac);
};
#endif
- // _WX_STATBAR_H_
\ No newline at end of file
+ // _WX_STATBAR_H_
virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ;
virtual void MacDoGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ;
MacWindowData* MacGetWindowData() { return m_macWindowData ; }
- static WindowRef MacGetWindowInUpdate() { return s_macWindowInUpdate ; }
bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
static wxWindow* s_lastMouseWindow ;
private:
protected:
MacWindowData* m_macWindowData ;
- static WindowRef s_macWindowInUpdate ;
RgnHandle m_macUpdateRgn ;
int m_x ;
// Single inheritance with one base class
#define IMPLEMENT_DYNAMIC_CLASS(name, basename) \
+wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void); \
wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \
{ return new name; }\
wxClassInfo name::sm_class##name((wxChar *) wxT(#name), (wxChar *) wxT(#basename), (wxChar *) NULL, (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name);
#define _WX_SPINBUTT_H_BASE_
#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"
- #endif // Motif
+ #endif
#endif
// ----------------------------------------------------------------------------
#include "wx/msw/statbr95.h"
typedef wxStatusBar95 wxStatusBarReal;
-#elif defined(__WXMAC__) && !defined(__UNIX__)
+#elif defined(__WXMAC__) /* && !defined(__UNIX__) */
+ #include "wx/generic/statusbr.h"
#include "wx/mac/statusbr.h"
typedef wxStatusBarMac wxStatusBarReal;
wxEVT_COMMAND_TREE_KEY_DOWN
*/
+#ifndef __WXMAC_X__
class WXDLLEXPORT wxTreeEvent: public wxCommandEvent
{
DECLARE_DYNAMIC_CLASS(wxTreeEvent)
};
typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
+#endif
#endif
// _WX_TREECTRL_H_
char zError[256] = "";
wxDllOpen(zError, libname, handle);
#else // !Mac
- handle = wxDllOpen(libname);
+ handle = wxDllOpen((char *)libname);
#endif // OS
if ( !handle )
wxDllGetSymbol(dllHandle, symbol);
#else
// mb_str() is necessary in Unicode build
- symbol = wxDllGetSymbol(dllHandle, name.mb_str());
+ symbol = wxDllGetSymbol(dllHandle, (char *)name.mb_str());
#endif
if ( !symbol )
tmp_fname = new char[fname_len];
wxWX2MB(tmp_fname, filename, fname_len);
-#ifdef __WXMAC__
+#if defined(__WXMAC__) && !defined(__UNIX__)
m_fp = fopen(wxUnix2MacFilename( tmp_fname ), mode);
#else
m_fp = fopen(tmp_fname, mode);
delete tmp_fname;
#else
-#ifdef __WXMAC__
+#if defined(__WXMAC__) && !defined(__UNIX__)
m_fp = fopen(wxUnix2MacFilename( filename ), mode);
#else
m_fp = fopen(filename, mode);
#if wxUSE_UNICODE && wxMBFILES
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);
#else
return !wxAccess(fname, 0) &&
(st.st_mode & S_IFREG);
#endif
#else
-#ifdef __WXMAC__
+#if defined(__WXMAC__) && !defined(__UNIX__)
return !access(wxUnix2MacFilename( name ) , 0) && !stat(wxUnix2MacFilename( name ), &st) && (st.st_mode & S_IFREG);
#else
return !wxAccess(name, 0) &&
{
// if bOverwrite we create a new file or truncate the existing one,
// otherwise we only create the new file and fail if it already exists
-#ifdef __WXMAC__
+#if defined(__WXMAC__) && !defined(__UNIX__)
// Dominic Mazzoni [dmazzoni+@cs.cmu.edu] reports that open is still broken on the mac, so we replace
// int fd = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
int fd = creat(wxUnix2MacFilename( szFileName ), accessMode);
break;
}
-#ifdef __WXMAC__
+#if defined(__WXMAC__) && !defined(__UNIX__)
int fd = open(wxUnix2MacFilename( szFileName ), flags, access);
#else
int fd = wxOpen(wxFNCONV(szFileName), flags ACCESS(accessMode));
{
m_file.Close();
-#ifndef __WXMAC__
+#if !defined(__WXMAC__) || defined(__UNIX__)
if ( wxFile::Exists(m_strName) && wxRemove(m_strName) != 0 ) {
wxLogSysError(_("can't remove file '%s'"), m_strName.c_str());
return FALSE;
void wxTempFile::Discard()
{
m_file.Close();
-#ifndef __WXMAC__
+#if !defined(__WXMAC__) || defined(__UNIX__)
if ( wxRemove(m_strTemp) != 0 )
wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str());
#else
bool ret = file.Commit();
-#ifdef __WXMAC__
+#if defined(__WXMAC__) && !defined(__UNIX__)
if ( ret )
{
FSSpec spec ;
FSpSetFInfo( &spec , &finfo ) ;
}
}
-#endif // __WXMAC__
+#endif // __WXMAC__ && !__UNIX__
#ifdef __UNIX__
// restore the old umask if we changed it
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
if ( chmod(OS_FILENAME(file2), fbuf.st_mode) != 0 )
{
bool wxMkdir(const wxString& dir, int perm)
{
-#if defined( __WXMAC__ )
+#if defined(__WXMAC__) && !defined(__UNIX__)
return (mkdir(wxUnix2MacFilename( dir ) , 0 ) == 0);
#else // !Mac
const wxChar *dirname = dir.c_str();
char *cbuf = new char[sz+1];
#ifdef _MSC_VER
if (_getcwd(cbuf, sz) == NULL) {
-#elif defined( __WXMAC__)
+#elif defined(__WXMAC__) && !defined(__UNIX__)
enum
{
SFSaveDisk = 0x214, CurDirStore = 0x398
#else // wxUnicode
#ifdef _MSC_VER
if (_getcwd(buf, sz) == NULL) {
-#elif defined( __WXMAC__)
+#elif defined(__WXMAC__) && !defined(__UNIX__)
FSSpec cwdSpec ;
FCBPBRec pb;
OSErr error;
#ifdef __WXMAC__
#ifdef __UNIX__
- #include <QD/PictUtils.h>
+ #include <ApplicationServices/ApplicationServices.h>
#else
#include <PictUtils.h>
#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
{
// width and height of the device-dependent bitmap
// Create picture
- wxBitmap bitmap( width , height , wxDisplayDepth() ) ;
-
- // Create mask
-
- if (HasMask())
- {
- /*
- unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height );
-
- mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height );
-
- wxMask *mask = new wxMask();
- mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 );
-
- bitmap.SetMask( mask );
- */
- }
-
- // Render
-
- int r_mask = GetMaskRed();
- int g_mask = GetMaskGreen();
- int b_mask = GetMaskBlue();
+ wxBitmap bitmap;
+ wxCHECK_MSG( Ok(), bitmap, wxT("invalid image") );
+
+ bitmap.Create( width , height , wxDisplayDepth() ) ;
+ wxBitmap maskBitmap( width, height, 1);
+
CGrafPtr origPort ;
GDHandle origDevice ;
+ LockPixels( GetGWorldPixMap(bitmap.GetHBITMAP()) );
+ LockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) );
+
GetGWorld( &origPort , &origDevice ) ;
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();
{
for (int x = 0; x < width; x++)
{
- unsigned char r = data[index++];
- unsigned char g = data[index++];
- unsigned char b = data[index++];
- RGBColor color ;
- color.red = ( r << 8 ) + r ;
- color.green = ( g << 8 ) + g ;
- color.blue = ( b << 8 ) + b ;
+ rgb.Set(data[index++], data[index++], data[index++]);
+ color = rgb.GetPixel();
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
- SetGWorld( origPort , origDevice ) ;
-
- if ( HasMask() )
- {
- wxColour colour( GetMaskRed(), GetMaskGreen(), GetMaskBlue());
- wxMask *mask = new wxMask( bitmap, colour );
- bitmap.SetMask( mask );
+ // Create mask
+ if ( HasMask() ) {
+ wxMask *mask = new wxMask( maskBitmap );
}
- return bitmap;
+
+ UnlockPixels( GetGWorldPixMap(bitmap.GetHBITMAP()) );
+ UnlockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) );
+ SetGWorld( origPort, origDevice );
+ return bitmap;
}
wxImage::wxImage( const wxBitmap &bitmap )
{
// check the bitmap
- if( !bitmap.Ok() )
- {
- wxFAIL_MSG( "invalid bitmap" );
- return;
- }
+ wxCHECK_RET( bitmap.Ok(), wxT("Invalid bitmap") );
// create an wxImage object
int width = bitmap.GetWidth();
int height = bitmap.GetHeight();
Create( width, height );
- /*
+
unsigned char *data = GetData();
- if( !data )
- {
- wxFAIL_MSG( "could not allocate data for image" );
- return;
- }
- // calc the number of bytes per scanline and padding in the DIB
- int bytePerLine = width*3;
- int sizeDWORD = sizeof( DWORD );
- div_t lineBoundary = div( bytePerLine, sizeDWORD );
- int padding = 0;
- if( lineBoundary.rem > 0 )
- {
- padding = sizeDWORD - lineBoundary.rem;
- bytePerLine += padding;
- }
+ wxCHECK_RET( data, wxT("Could not allocate data for image") );
- // create a DIB header
- int headersize = sizeof(BITMAPINFOHEADER);
- LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize );
- if( !lpDIBh )
- {
- wxFAIL_MSG( "could not allocate data for DIB header" );
- free( data );
- return;
- }
- // Fill in the DIB header
- lpDIBh->bmiHeader.biSize = headersize;
- lpDIBh->bmiHeader.biWidth = width;
- lpDIBh->bmiHeader.biHeight = -height;
- lpDIBh->bmiHeader.biSizeImage = bytePerLine * height;
- lpDIBh->bmiHeader.biPlanes = 1;
- lpDIBh->bmiHeader.biBitCount = 24;
- lpDIBh->bmiHeader.biCompression = BI_RGB;
- lpDIBh->bmiHeader.biClrUsed = 0;
- // These seem not really needed for our purpose here.
- lpDIBh->bmiHeader.biClrImportant = 0;
- lpDIBh->bmiHeader.biXPelsPerMeter = 0;
- lpDIBh->bmiHeader.biYPelsPerMeter = 0;
- // memory for DIB data
- unsigned char *lpBits;
- lpBits = (unsigned char *) malloc( lpDIBh->bmiHeader.biSizeImage );
- if( !lpBits )
- {
- wxFAIL_MSG( "could not allocate data for DIB" );
- free( data );
- free( lpDIBh );
- return;
- }
+ WXHBITMAP origPort;
+ GDHandle origDevice;
+ int index;
+ RGBColor color;
+ // background color set to RGB(16,16,16) in consistent with wxGTK
+ unsigned char mask_r=16, mask_g=16, mask_b=16;
+ SInt16 r,g,b;
+ wxMask *mask = bitmap.GetMask();
- // copy data from the device-dependent bitmap to the DIB
- HDC hdc = ::GetDC(NULL);
- HBITMAP hbitmap;
- hbitmap = (HBITMAP) bitmap.GetHBITMAP();
- ::GetDIBits( hdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS );
-
- // copy DIB data into the wxImage object
- int i, j;
- unsigned char *ptdata = data;
- unsigned char *ptbits = lpBits;
- for( i=0; i<height; i++ )
- {
- for( j=0; j<width; j++ )
- {
- *(ptdata++) = *(ptbits+2);
- *(ptdata++) = *(ptbits+1);
- *(ptdata++) = *(ptbits );
- ptbits += 3;
- }
- ptbits += padding;
- }
+ GetGWorld( &origPort, &origDevice );
+ LockPixels(GetGWorldPixMap(bitmap.GetHBITMAP()));
+ SetGWorld( bitmap.GetHBITMAP(), NULL);
- // similarly, set data according to the possible mask bitmap
- if( bitmap.GetMask() && bitmap.GetMask()->GetMaskBitmap() )
+ // Copy data into image
+ index = 0;
+ for (int yy = 0; yy < height; yy++)
{
- 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 (int xx = 0; xx < width; xx++)
{
- for( j=0; j<width; j++ )
+ GetCPixel(xx,yy, &color);
+ r = ((color.red ) >> 8);
+ g = ((color.green ) >> 8);
+ b = ((color.blue ) >> 8);
+ data[index ] = r;
+ data[index + 1] = g;
+ data[index + 2] = b;
+ if (mask)
{
- if( *ptbits != 0 )
- ptdata += 3;
- else
+ if (mask->PointMasked(xx,yy))
{
- *(ptdata++) = r;
- *(ptdata++) = g;
- *(ptdata++) = b;
+ data[index ] = mask_r;
+ data[index + 1] = mask_g;
+ 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(lpDIBh);
- free(lpBits);
- */
+
+ // Free resources
+ UnlockPixels(GetGWorldPixMap(bitmap.GetHBITMAP()));
+ SetGWorld(origPort, origDevice);
}
#endif
// implementation classes:
#if defined(__WXMSW__)
#include "wx/msw/mimetype.h"
-#elif defined (__WXMAC__)
+#elif defined(__WXMAC__)
#include "wx/mac/mimetype.h"
-#elif defined (__WXPM__)
+#elif defined(__WXPM__)
#include "wx/os2/mimetype.h"
#else // Unix
#include "wx/unix/mimetype.h"
{
wxExprDatabase db;
-#ifdef __WXMAC__
+#if defined(__WXMAC__) && !defined(__UNIX__)
FILE *fd = fopen(wxUnix2MacFilename(filename.fn_str()), "r");
#else
FILE *fd = wxFopen(filename, _T("r"));
return uPosFound;
}
-#ifdef __WXMAC__
+#if defined(__WXMAC__) && !defined(__UNIX__)
void wxUnix2MacFilename (char *s) ;
void
wxUnix2MacFilename (char *s)
if (unz_copyright[0]!=' ')
return NULL;
-#ifdef __WXMAC__
+#if defined(__WXMAC__) && !defined(__UNIX__)
strcpy( wxBuffer , path ) ;
wxUnix2MacFilename( wxBuffer ) ;
- fin=fopen(wxBuffer,"rb");
+ fin=fopen(wxBuffer,"rb");
#else
fin=fopen(path,"rb");
#endif
#if defined(__WXMSW__) && !defined(__WX_SETUP_H__) && !defined(wxUSE_ZLIB_H_IN_PATH)
#include "../zlib/zlib.h"
#elif defined(__WXMAC__) && defined(__UNIX__)
- #include <Zip/zlib.h>
+ #include <Kernel/net/zlib.h>
#else
#include <zlib.h>
#endif
+#include "wx/dc.h"
#include "wx/mac/uma.h"
#include "wx/mac/aga.h"
#if wxUSE_SOCKETS
#ifdef __APPLE__
- #include <OT/OpenTransport.h>
+ #include <CoreServices/CoreServices.h>
#else
#include <OpenTransport.h>
#include <OpenTptInternet.h>
long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
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 ;
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 ;
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 ;
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 ;
return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ;
case suspendResumeMessage :
{
bool isResuming = ev->message & resumeFlag ;
+#if !TARGET_CARBON
bool convertClipboard = ev->message & convertClipboardFlag ;
+#else
+ bool convertClipboard = false;
+#endif
bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
if ( isResuming )
{
#endif
#ifdef __UNIX__
- #include <QD/PictUtils.h>
+ #include <ApplicationServices/ApplicationServices.h>
#else
#include <PictUtils.h>
#endif
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()
{
m_ok = FALSE;
GetGWorld( &origPort , &origDevice ) ;
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
unsigned char* linestart = (unsigned char*) bits ;
{
linesize += 2 ;
}
+#endif
RGBColor colors[2] = {
{ 0xFFFF , 0xFFFF , 0xFFFF } ,
}
}
- UnlockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ;
+ UnlockPixels( GetGWorldPixMap( M_BITMAPDATA->m_hBitmap ) ) ;
SetGWorld( origPort , origDevice ) ;
}
(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)
{
UnRef();
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)
{
M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
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)
{
if (!M_BITMAPDATA)
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)
{
if (!M_BITMAPDATA)
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)
{
sm_handlers.Append(handler);
// Create a mask from a mono bitmap (copies the bitmap).
bool wxMask::Create(const wxBitmap& bitmap)
{
-// TODO
- return FALSE;
+ if ( m_maskBitmap )
+ {
+ 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
bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
{
// TODO
+ wxCHECK_MSG( 0, false, wxT("Not implemented"));
return FALSE;
}
wxMacDestroyGWorld( m_maskBitmap ) ;
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
- if (!bitmap.Ok())
- {
- return FALSE;
- }
+ wxCHECK_MSG( bitmap.Ok(), false, wxT("Illigal bitmap"));
- m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 ) ;
- LockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
- LockPixels( GetGWorldPixMap( (CGrafPtr) ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap ) ) ;
- RGBColor maskColor = colour.GetPixel() ;
+ m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 );
+ LockPixels( GetGWorldPixMap( m_maskBitmap ) );
+ LockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) );
+ RGBColor maskColor = colour.GetPixel();
// this is not very efficient, but I can't think
// of a better way of doing it
CGrafPtr origPort ;
GDHandle origDevice ;
+ RGBColor col;
+ RGBColor colors[2] = {
+ { 0xFFFF, 0xFFFF, 0xFFFF },
+ { 0, 0, 0 }};
GetGWorld( &origPort , &origDevice ) ;
for (int w = 0; w < bitmap.GetWidth(); w++)
{
for (int h = 0; h < bitmap.GetHeight(); h++)
{
- RGBColor colors[2] = {
- { 0xFFFF , 0xFFFF , 0xFFFF } ,
- { 0, 0 , 0 }
- } ;
-
- SetGWorld( ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap , NULL ) ;
- RGBColor col ;
+ SetGWorld( bitmap.GetHBITMAP(), NULL ) ;
GetCPixel( w , h , &col ) ;
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] ) ;
}
}
}
UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
- UnlockPixels( GetGWorldPixMap( ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap ) ) ;
+ UnlockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) ) ;
SetGWorld( origPort , origDevice ) ;
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
*/
+#include "wx/dc.h"
#include "wx/mac/uma.h"
#include "wx/mac/aga.h"
#if wxUSE_SOCKETS
#ifdef __APPLE__
- #include <OT/OpenTransport.h>
+ #include <CoreServices/CoreServices.h>
#else
#include <OpenTransport.h>
#include <OpenTptInternet.h>
long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
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 ;
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 ;
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 ;
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 ;
return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ;
case suspendResumeMessage :
{
bool isResuming = ev->message & resumeFlag ;
+#if !TARGET_CARBON
bool convertClipboard = ev->message & convertClipboardFlag ;
+#else
+ bool convertClipboard = false;
+#endif
bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
if ( isResuming )
{
#endif
#ifdef __UNIX__
- #include <QD/PictUtils.h>
+ #include <ApplicationServices/ApplicationServices.h>
#else
#include <PictUtils.h>
#endif
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()
{
m_ok = FALSE;
GetGWorld( &origPort , &origDevice ) ;
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
unsigned char* linestart = (unsigned char*) bits ;
{
linesize += 2 ;
}
+#endif
RGBColor colors[2] = {
{ 0xFFFF , 0xFFFF , 0xFFFF } ,
}
}
- UnlockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ;
+ UnlockPixels( GetGWorldPixMap( M_BITMAPDATA->m_hBitmap ) ) ;
SetGWorld( origPort , origDevice ) ;
}
(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)
{
UnRef();
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)
{
M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
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)
{
if (!M_BITMAPDATA)
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)
{
if (!M_BITMAPDATA)
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)
{
sm_handlers.Append(handler);
// Create a mask from a mono bitmap (copies the bitmap).
bool wxMask::Create(const wxBitmap& bitmap)
{
-// TODO
- return FALSE;
+ if ( m_maskBitmap )
+ {
+ 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
bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
{
// TODO
+ wxCHECK_MSG( 0, false, wxT("Not implemented"));
return FALSE;
}
wxMacDestroyGWorld( m_maskBitmap ) ;
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
- if (!bitmap.Ok())
- {
- return FALSE;
- }
+ wxCHECK_MSG( bitmap.Ok(), false, wxT("Illigal bitmap"));
- m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 ) ;
- LockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
- LockPixels( GetGWorldPixMap( (CGrafPtr) ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap ) ) ;
- RGBColor maskColor = colour.GetPixel() ;
+ m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 );
+ LockPixels( GetGWorldPixMap( m_maskBitmap ) );
+ LockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) );
+ RGBColor maskColor = colour.GetPixel();
// this is not very efficient, but I can't think
// of a better way of doing it
CGrafPtr origPort ;
GDHandle origDevice ;
+ RGBColor col;
+ RGBColor colors[2] = {
+ { 0xFFFF, 0xFFFF, 0xFFFF },
+ { 0, 0, 0 }};
GetGWorld( &origPort , &origDevice ) ;
for (int w = 0; w < bitmap.GetWidth(); w++)
{
for (int h = 0; h < bitmap.GetHeight(); h++)
{
- RGBColor colors[2] = {
- { 0xFFFF , 0xFFFF , 0xFFFF } ,
- { 0, 0 , 0 }
- } ;
-
- SetGWorld( ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap , NULL ) ;
- RGBColor col ;
+ SetGWorld( bitmap.GetHBITMAP(), NULL ) ;
GetCPixel( w , h , &col ) ;
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] ) ;
}
}
}
UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
- UnlockPixels( GetGWorldPixMap( ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap ) ) ;
+ UnlockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) ) ;
SetGWorld( origPort , origDevice ) ;
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
*/
#include "wx/utils.h"
#include "wx/metafile.h"
#include "wx/clipbrd.h"
+#include "wx/intl.h"
#define wxUSE_DATAOBJ 1
#include "wx/control.h"
#include "wx/panel.h"
#include "wx/app.h"
+#include "wx/dc.h"
#include "wx/notebook.h"
#include "wx/tabctrl.h"
#include "wx/radiobox.h"
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: msw/dir.cpp
-// Purpose: wxDir implementation for Mac
-// Author: Stefan Csomor
-// Modified by:
-// Created: 08.12.99
-// RCS-ID: $Id$
-// Copyright: (c) 1999 Stefan Csomor <csomor@advanced.ch>
-// Licence: wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-#ifdef __GNUG__
- #pragma implementation "dir.h"
-#endif
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/intl.h"
- #include "wx/log.h"
-#endif // PCH
-
-#include "wx/dir.h"
-#include "wx/filefn.h" // for wxPathExists()
-
-#ifndef __WXMAC_X__
- #include <windows.h>
-#endif
-
-#if defined(__WXMAC__) && !defined(__UNIX__)
- #include "morefile.h"
- #include "moreextr.h"
- #include "fullpath.h"
- #include "fspcompa.h"
-#endif
-
-// ----------------------------------------------------------------------------
-// constants
-// ----------------------------------------------------------------------------
-
-#ifndef MAX_PATH
- #define MAX_PATH 260 // from VC++ headers
-#endif
-
-// ----------------------------------------------------------------------------
-// macros
-// ----------------------------------------------------------------------------
-
-#define M_DIR ((wxDirData *)m_data)
-
-// ----------------------------------------------------------------------------
-// private classes
-// ----------------------------------------------------------------------------
-
-// this class stores everything we need to enumerate the files
-class wxDirData
-{
-public:
- wxDirData(const wxString& dirname);
- ~wxDirData();
-
- void SetFileSpec(const wxString& filespec) { m_filespec = filespec; }
- void SetFlags(int flags) { m_flags = flags; }
-
- bool Read(wxString *filename); // reads the next
- void Rewind() ;
-
-private:
- CInfoPBRec m_CPB ;
- wxInt16 m_index ;
- long m_dirId ;
- Str255 m_name ;
- Boolean m_isDir ;
-
- wxString m_dirname;
- wxString m_filespec;
-
- int m_flags;
-};
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxDirData
-// ----------------------------------------------------------------------------
-
-wxDirData::wxDirData(const wxString& dirname)
- : m_dirname(dirname)
-{
- // throw away the trailing slashes
- size_t n = m_dirname.length();
- wxCHECK_RET( n, _T("empty dir name in wxDir") );
-
- while ( n > 0 && wxIsPathSeparator(m_dirname[--n]) )
- ;
-
- m_dirname.Truncate(n + 1);
-
- FSSpec fsspec ;
-
- wxUnixFilename2FSSpec( m_dirname , &fsspec ) ;
- m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
- m_CPB.hFileInfo.ioNamePtr = m_name ;
- m_index = 0 ;
-
-#ifdef __WXMAC_X__
- // TODO: what are we supposed to do for Mac OS X
-#else
- FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
-#endif
-}
-
-wxDirData::~wxDirData()
-{
-}
-
-void wxDirData::Rewind()
-{
- m_index = 0 ;
-}
-
-bool wxDirData::Read(wxString *filename)
-{
- if ( !m_isDir )
- return FALSE ;
-
-#if TARGET_CARBON
- char c_name[256] ;
-#endif
- wxString result;
-
- short err = noErr ;
-
- while ( err == noErr )
- {
- m_index++ ;
- m_CPB.dirInfo.ioFDirIndex = m_index;
- m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */
- err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB);
- if ( err != noErr )
- break ;
-
-#if TARGET_CARBON
- p2cstrcpy( c_name, m_name ) ;
- strcpy( (char *)m_name, c_name);
-#else
- p2cstr( m_name ) ;
-#endif
- if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory
- break ;
-
- if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) ) // its a file but we don't want it
- continue ;
-
- if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) // its hidden but we don't want it
- continue ;
-
- wxString file( m_name ) ;
- if ( m_filespec.IsEmpty() || m_filespec == "*.*" )
- {
- }
- else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" )
- {
- if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
- {
- continue ;
- }
- }
- else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" )
- {
- if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
- {
- continue ;
- }
- }
- else if ( file.Upper() != m_filespec.Upper() )
- {
- continue ;
- }
-
- break ;
- }
- if ( err != noErr )
- {
- return FALSE ;
- }
-
- *filename = (char*) m_name ;
-
- return TRUE;
-}
-
-// ----------------------------------------------------------------------------
-// wxDir helpers
-// ----------------------------------------------------------------------------
-
-/* static */
-bool wxDir::Exists(const wxString& dir)
-{
- return wxPathExists(dir);
-}
-
-// ----------------------------------------------------------------------------
-// wxDir construction/destruction
-// ----------------------------------------------------------------------------
-
-wxDir::wxDir(const wxString& dirname)
-{
- m_data = NULL;
-
- (void)Open(dirname);
-}
-
-bool wxDir::Open(const wxString& dirname)
-{
- delete M_DIR;
- m_data = new wxDirData(dirname);
-
- return TRUE;
-}
-
-bool wxDir::IsOpened() const
-{
- return m_data != NULL;
-}
-
-wxDir::~wxDir()
-{
- delete M_DIR;
-}
-
-// ----------------------------------------------------------------------------
-// wxDir enumerating
-// ----------------------------------------------------------------------------
-
-bool wxDir::GetFirst(wxString *filename,
- const wxString& filespec,
- int flags) const
-{
- wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") );
-
- M_DIR->Rewind();
-
- M_DIR->SetFileSpec(filespec);
- M_DIR->SetFlags(flags);
-
- return GetNext(filename);
-}
-
-bool wxDir::GetNext(wxString *filename) const
-{
- wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") );
-
- wxCHECK_MSG( filename, FALSE, _T("bad pointer in wxDir::GetNext()") );
-
- return M_DIR->Read(filename);
-}
#include "wx/cmndata.h"
#if defined(__UNIX__)
- #include <NavigationServices/Navigation.h>
+ #include <Carbon/Carbon.h>
#else
#include <Navigation.h>
#endif
// flashing of the button when the key is hit
static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec,
- short *item, Ptr dataPtr)
+ short *item, void *dataPtr)
{
#pragma unused (dataPtr)
// MyDlgHook is a hook routine that maps the select button to Open
// 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;
long desktopDirID;
}
}
-static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr)
+static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
{
#pragma unused (dataPtr)
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: msw/dir.cpp
+// Purpose: wxDir implementation for Mac
+// Author: Stefan Csomor
+// Modified by:
+// Created: 08.12.99
+// RCS-ID: $Id$
+// Copyright: (c) 1999 Stefan Csomor <csomor@advanced.ch>
+// Licence: wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#ifdef __GNUG__
+ #pragma implementation "dir.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/intl.h"
+ #include "wx/log.h"
+#endif // PCH
+
+#include "wx/dir.h"
+#include "wx/filefn.h" // for wxPathExists()
+
+#ifndef __WXMAC_X__
+ #include <windows.h>
+#endif
+
+#if defined(__WXMAC__) && !defined(__UNIX__)
+ #include "morefile.h"
+ #include "moreextr.h"
+ #include "fullpath.h"
+ #include "fspcompa.h"
+#endif
+
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+#ifndef MAX_PATH
+ #define MAX_PATH 260 // from VC++ headers
+#endif
+
+// ----------------------------------------------------------------------------
+// macros
+// ----------------------------------------------------------------------------
+
+#define M_DIR ((wxDirData *)m_data)
+
+// ----------------------------------------------------------------------------
+// private classes
+// ----------------------------------------------------------------------------
+
+// this class stores everything we need to enumerate the files
+class wxDirData
+{
+public:
+ wxDirData(const wxString& dirname);
+ ~wxDirData();
+
+ void SetFileSpec(const wxString& filespec) { m_filespec = filespec; }
+ void SetFlags(int flags) { m_flags = flags; }
+
+ bool Read(wxString *filename); // reads the next
+ void Rewind() ;
+
+private:
+ CInfoPBRec m_CPB ;
+ wxInt16 m_index ;
+ long m_dirId ;
+ Str255 m_name ;
+ Boolean m_isDir ;
+
+ wxString m_dirname;
+ wxString m_filespec;
+
+ int m_flags;
+};
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxDirData
+// ----------------------------------------------------------------------------
+
+wxDirData::wxDirData(const wxString& dirname)
+ : m_dirname(dirname)
+{
+ // throw away the trailing slashes
+ size_t n = m_dirname.length();
+ wxCHECK_RET( n, _T("empty dir name in wxDir") );
+
+ while ( n > 0 && wxIsPathSeparator(m_dirname[--n]) )
+ ;
+
+ m_dirname.Truncate(n + 1);
+
+ FSSpec fsspec ;
+
+ wxUnixFilename2FSSpec( m_dirname , &fsspec ) ;
+ m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
+ m_CPB.hFileInfo.ioNamePtr = m_name ;
+ m_index = 0 ;
+
+#ifdef __WXMAC_X__
+ // TODO: what are we supposed to do for Mac OS X
+#else
+ FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
+#endif
+}
+
+wxDirData::~wxDirData()
+{
+}
+
+void wxDirData::Rewind()
+{
+ m_index = 0 ;
+}
+
+bool wxDirData::Read(wxString *filename)
+{
+ if ( !m_isDir )
+ return FALSE ;
+
+#if TARGET_CARBON
+ char c_name[256] ;
+#endif
+ wxString result;
+
+ short err = noErr ;
+
+ while ( err == noErr )
+ {
+ m_index++ ;
+ m_CPB.dirInfo.ioFDirIndex = m_index;
+ m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */
+ err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB);
+ if ( err != noErr )
+ break ;
+
+#if TARGET_CARBON
+ p2cstrcpy( c_name, m_name ) ;
+ strcpy( (char *)m_name, c_name);
+#else
+ p2cstr( m_name ) ;
+#endif
+ if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory
+ break ;
+
+ if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) ) // its a file but we don't want it
+ continue ;
+
+ if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) // its hidden but we don't want it
+ continue ;
+
+ wxString file( m_name ) ;
+ if ( m_filespec.IsEmpty() || m_filespec == "*.*" )
+ {
+ }
+ else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" )
+ {
+ if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
+ {
+ continue ;
+ }
+ }
+ else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" )
+ {
+ if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
+ {
+ continue ;
+ }
+ }
+ else if ( file.Upper() != m_filespec.Upper() )
+ {
+ continue ;
+ }
+
+ break ;
+ }
+ if ( err != noErr )
+ {
+ return FALSE ;
+ }
+
+ *filename = (char*) m_name ;
+
+ return TRUE;
+}
+
+// ----------------------------------------------------------------------------
+// wxDir helpers
+// ----------------------------------------------------------------------------
+
+/* static */
+bool wxDir::Exists(const wxString& dir)
+{
+ return wxPathExists(dir);
+}
+
+// ----------------------------------------------------------------------------
+// wxDir construction/destruction
+// ----------------------------------------------------------------------------
+
+wxDir::wxDir(const wxString& dirname)
+{
+ m_data = NULL;
+
+ (void)Open(dirname);
+}
+
+bool wxDir::Open(const wxString& dirname)
+{
+ delete M_DIR;
+ m_data = new wxDirData(dirname);
+
+ return TRUE;
+}
+
+bool wxDir::IsOpened() const
+{
+ return m_data != NULL;
+}
+
+wxDir::~wxDir()
+{
+ delete M_DIR;
+}
+
+// ----------------------------------------------------------------------------
+// wxDir enumerating
+// ----------------------------------------------------------------------------
+
+bool wxDir::GetFirst(wxString *filename,
+ const wxString& filespec,
+ int flags) const
+{
+ wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") );
+
+ M_DIR->Rewind();
+
+ M_DIR->SetFileSpec(filespec);
+ M_DIR->SetFlags(flags);
+
+ return GetNext(filename);
+}
+
+bool wxDir::GetNext(wxString *filename) const
+{
+ wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") );
+
+ wxCHECK_MSG( filename, FALSE, _T("bad pointer in wxDir::GetNext()") );
+
+ return M_DIR->Read(filename);
+}
// ----------------------------------------------------------------------------
// wxTextDropTarget
// ----------------------------------------------------------------------------
-
-bool wxTextDropTarget::OnDrop( long x, long y, const void *pData )
+#ifndef __WXMAC_X__
+bool wxTextDropTarget::OnDrop( wxCoord x, wxCoord y, const void *pData )
{
OnDropText( x, y, (const char*)pData );
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 );
return TRUE;
};
+#ifndef __WXMAC_X__
size_t wxTextDropTarget::GetFormatCount() const
{
return 1;
{
return wxDF_TEXT;
}
+#endif
// ----------------------------------------------------------------------------
// 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( "At x: %d, y: %d.\n", (int)x, (int)y );
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, &str );
+ return OnDropFiles(x, y, 1, &filenames);
}
+#ifndef __WXMAC_X__
size_t wxFileDropTarget::GetFormatCount() const
{
return 1;
{
return wxDF_FILENAME;
}
+#endif
//-------------------------------------------------------------------------
// wxDropSource
#endif
#include "wx/defs.h"
+#include "wx/app.h"
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/filedlg.h"
// begin wxmac
#if defined(__UNIX__)
- #include <NavigationServices/Navigation.h>
+ #include <Carbon/Carbon.h>
#else
#include <Navigation.h>
#endif
#endif
*/
+ wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event);
}
}
// flashing of the button when the key is hit
static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec,
- short *item, Ptr dataPtr)
+ short *item, void *dataPtr)
{
#pragma unused (dataPtr)
}
}
-static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr)
+static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
{
Str255 filename ;
OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ;
#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
-#define OTUNIXERRORS 1
#ifdef __UNIX__
- #include <CarbonCore/CarbonCore.h>
- #include <OT/OpenTransport.h>
- #include <OT/OpenTransportProviders.h>
+ #include <CoreServices/CoreServices.h>
#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif
#else
+ #define OTUNIXERRORS 1
#include <OpenTransport.h>
#include <OpenTransportProviders.h>
#include <OpenTptInternet.h>
ret.opt.maxlen = kOTFourByteOptionSize;
opt->level = INET_IP; // dealing with an IP Level function
+#ifdef __UNIX__
+ opt->name = kIP_REUSEADDR;
+#else
opt->name = IP_REUSEADDR;
+#endif
opt->len = kOTFourByteOptionSize;
opt->status = 0;
*(UInt32*)opt->value = enableReuseIPMode; // set the desired option level, true or false
{
OTFlags flags ;
OTResult res ;
+ OTByteCount sz = 0 ;
- size_t sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ;
res = OTRcv( socket->m_endpoint , buffer , size , &flags ) ;
if ( res < 0 )
// we simulate another read event if there are still bytes
if ( socket->m_takesEvents )
{
- size_t sz = 0 ;
+ OTByteCount sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ;
if ( sz > 0 )
{
assert(address != NULL);
CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
- OTInetAddressToName( gInetSvcRef , address->m_host , &name ) ;
+ OTInetAddressToName( gInetSvcRef , address->m_host , name ) ;
strncpy( hostname , name , sbuf ) ;
return GSOCK_NOERROR;
}
state = OTGetEndpointState(socket->m_endpoint);
{
- size_t sz = 0 ;
+ OTByteCount sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ;
if ( state == T_INCON || sz > 0 )
{
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < socket->m_timeout * 1000.0 )
{
OTResult state ;
- size_t sz = 0 ;
+ OTByteCount sz = 0 ;
state = OTGetEndpointState(socket->m_endpoint);
OTCountDataBytes( socket->m_endpoint , &sz ) ;
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: mac/mimetype.cpp
+// Purpose: classes and functions to manage MIME types
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 23.09.98
+// RCS-ID: $Id$
+// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence: wxWindows license (part of wxExtra library)
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "mimetype.h"
+#endif
+
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/defs.h"
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/string.h"
+ #if wxUSE_GUI
+ #include "wx/icon.h"
+ #endif
+#endif //WX_PRECOMP
+
+
+#include "wx/log.h"
+#include "wx/file.h"
+#include "wx/intl.h"
+#include "wx/dynarray.h"
+#include "wx/confbase.h"
+
+#include "wx/mac/mimetype.h"
+
+// other standard headers
+#include <ctype.h>
+
+// in case we're compiling in non-GUI mode
+class WXDLLEXPORT wxIcon;
+
+
+
+
+
+
+bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
+{
+ return FALSE;
+}
+
+// @@ this function is half implemented
+bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
+{
+ return FALSE;
+}
+
+bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
+{
+ if ( m_strFileType.Length() > 0 )
+ {
+ *mimeType = m_strFileType ;
+ return TRUE ;
+ }
+ else
+ return FALSE;
+}
+
+bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
+{
+ wxString s;
+
+ if (GetMimeType(&s))
+ {
+ mimeTypes.Clear();
+ mimeTypes.Add(s);
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
+{
+ // no such file type or no value or incorrect icon entry
+ return FALSE;
+}
+
+bool wxFileTypeImpl::GetDescription(wxString *desc) const
+{
+ return FALSE;
+}
+
+// extension -> file type
+wxFileType *
+wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
+{
+ wxString ext = e ;
+ ext = ext.Lower() ;
+ if ( ext == "txt" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("text/text");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "htm" || ext == "html" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("text/html");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "gif" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/gif");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "png" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/png");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "jpg" || ext == "jpeg" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/jpeg");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "bmp" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/bmp");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "tif" || ext == "tiff" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/tiff");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "xpm" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/xpm");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "xbm" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/xbm");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+
+ // unknown extension
+ return NULL;
+}
+
+// MIME type -> extension -> file type
+wxFileType *
+wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
+{
+ return NULL;
+}
+
+size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
+{
+ wxFAIL_MSG( _T("TODO") ); // VZ: don't know anything about this for Mac
+
+ return 0;
+}
+
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: mac/mimetype.cpp
-// Purpose: classes and functions to manage MIME types
-// Author: Vadim Zeitlin
-// Modified by:
-// Created: 23.09.98
-// RCS-ID: $Id$
-// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence: wxWindows license (part of wxExtra library)
-/////////////////////////////////////////////////////////////////////////////
-
-#ifdef __GNUG__
-#pragma implementation "mimetype.h"
-#endif
-
-// for compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/defs.h"
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/string.h"
- #if wxUSE_GUI
- #include "wx/icon.h"
- #endif
-#endif //WX_PRECOMP
-
-
-#include "wx/log.h"
-#include "wx/file.h"
-#include "wx/intl.h"
-#include "wx/dynarray.h"
-#include "wx/confbase.h"
-
-#include "wx/mac/mimetype.h"
-
-// other standard headers
-#include <ctype.h>
-
-// in case we're compiling in non-GUI mode
-class WXDLLEXPORT wxIcon;
-
-
-
-
-
-
-bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
-{
- return FALSE;
-}
-
-// @@ this function is half implemented
-bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
-{
- return FALSE;
-}
-
-bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
-{
- if ( m_strFileType.Length() > 0 )
- {
- *mimeType = m_strFileType ;
- return TRUE ;
- }
- else
- return FALSE;
-}
-
-bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
-{
- wxString s;
-
- if (GetMimeType(&s))
- {
- mimeTypes.Clear();
- mimeTypes.Add(s);
- return TRUE;
- }
- else
- return FALSE;
-}
-
-bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
-{
- // no such file type or no value or incorrect icon entry
- return FALSE;
-}
-
-bool wxFileTypeImpl::GetDescription(wxString *desc) const
-{
- return FALSE;
-}
-
-// extension -> file type
-wxFileType *
-wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
-{
- wxString ext = e ;
- ext = ext.Lower() ;
- if ( ext == "txt" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("text/text");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "htm" || ext == "html" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("text/html");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "gif" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/gif");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "png" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/png");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "jpg" || ext == "jpeg" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/jpeg");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "bmp" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/bmp");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "tif" || ext == "tiff" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/tiff");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "xpm" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/xpm");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "xbm" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/xbm");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
-
- // unknown extension
- return NULL;
-}
-
-// MIME type -> extension -> file type
-wxFileType *
-wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
-{
- return NULL;
-}
-
-size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
-{
- wxFAIL_MSG( _T("TODO") ); // VZ: don't know anything about this for Mac
-
- return 0;
-}
-
wxPNGReaderIter iter(this);
/* open the file */
+#ifndef __UNIX__
fp = fopen(wxUnix2MacFilename( ImageFileName ), "rb");
+#else
+ fp = fopen( ImageFileName , "rb" );
+#endif
if (!fp)
return FALSE;
// 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)
- EVT_SIZE(wxStatusBarXX::OnSize)
+BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBar)
+ EVT_SIZE(wxStatusBarMac::OnSize)
END_EVENT_TABLE()
// ============================================================================
// ----------------------------------------------------------------------------
-// wxStatusBarXX class
+// wxStatusBarMac class
// ----------------------------------------------------------------------------
-wxStatusBarXX::wxStatusBarXX()
+wxStatusBarMac::wxStatusBarMac()
{
SetParent(NULL);
}
-wxStatusBarXX::wxStatusBarXX(wxWindow *parent, wxWindowID id, long style)
-{
- Create(parent, id, style);
-}
-
-bool wxStatusBarXX::Create(wxWindow *parent, wxWindowID id, long style)
+bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name = wxPanelNameStr)
{
SetParent(parent);
return FALSE;
}
-void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[])
+void wxStatusBarMac::SetFieldsCount(int nFields, const int widths[])
{
wxASSERT( (nFields > 0) && (nFields < 255) );
SetFieldsWidth();
}
-void wxStatusBarXX::SetStatusWidths(int n, const int widths[])
+void wxStatusBarMac::SetStatusWidths(int n, const int widths[])
{
wxASSERT( n == m_nFields );
SetFieldsWidth();
}
-void wxStatusBarXX::CopyFieldsWidth(const int widths[])
+void wxStatusBarMac::CopyFieldsWidth(const int widths[])
{
if (widths && !m_statusWidths)
m_statusWidths = new int[m_nFields];
}
}
-void wxStatusBarXX::SetFieldsWidth()
+void wxStatusBarMac::SetFieldsWidth()
{
int *pWidths = new int[m_nFields];
delete [] pWidths;
}
-void wxStatusBarXX::SetStatusText(const wxString& strText, int nField)
+void wxStatusBarMac::SetStatusText(const wxString& strText, int nField)
{
// TODO
}
-wxString wxStatusBarXX::GetStatusText(int nField) const
+wxString wxStatusBarMac::GetStatusText(int nField) const
{
wxASSERT( (nField > -1) && (nField < m_nFields) );
return wxString("");
}
-void wxStatusBarXX::OnSize(wxSizeEvent& event)
+void wxStatusBarMac::OnSize(wxSizeEvent& event)
{
// adjust fields widths to the new size
SetFieldsWidth();
#include <fstream.h>
#include "wx/app.h"
+#include "wx/dc.h"
#include "wx/button.h"
#include "wx/panel.h"
#include "wx/textctrl.h"
#if wxUSE_TOOLTIPS
#include "wx/app.h"
+#include "wx/dc.h"
#include "wx/window.h"
#include "wx/tooltip.h"
#include "wx/timer.h"
#include "wx/defs.h"
+#include "wx/dc.h"
#include "wx/mac/uma.h"
#include "wx/mac/aga.h"
#ifdef __UNIX__
- #include <NavigationServices/Navigation.h>
+ #include <Carbon/Carbon.h>
#else
#include <Navigation.h>
#endif
return (wxBusyCursorCount > 0);
}
+#ifndef __UNIX__
wxString wxMacFindFolder( short vol,
OSType folderType,
Boolean createFolder)
}
return strDir ;
}
+#endif
#ifndef __UNIX__
char *wxGetUserHome (const wxString& user)
#endif
}
+void wxDisplaySizeMM(int *width, int *height)
+{
+ wxDisplaySize(width, height);
+}
+
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{
return wxGenericFindWindowAtPoint(pt);
#endif
#include "wx/utils.h"
+#ifdef __UNIX__
+#include "wx/unix/execute.h"
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifndef __UNIX__
#define wxEXECUTE_WIN_MESSAGE 10000
long wxExecute(const wxString& command, bool sync, wxProcess *handler)
// TODO
return 0;
}
+#endif
+
+#ifdef __UNIX__
+int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
+{
+ wxFAIL_MSG(wxT("wxAddProcessCallback() function not ready"));
+ return 0;
+}
+#endif
\ No newline at end of file
if (m_isResource)
{
- strcpy(lpSnd, m_sndname);
- c2pstr((char *) lpSnd);
- SndListHandle hSnd;
-
- hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd);
+#if TARGET_CARBON
+ c2pstrcpy((unsigned char *)lpSnd, m_sndname);
+#else
+ strcpy(lpSnd, m_sndname);
+ c2pstr((char *) lpSnd);
+#endif
+ SndListHandle hSnd;
+
+ hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd);
- if ((hSnd != NULL) && (SndPlay(m_sndChan, hSnd, async) == noErr))
- ret = true;
+ if ((hSnd != NULL) && (SndPlay(m_sndChan, hSnd, async) == noErr))
+ ret = true;
}
return ret;
#include "wx/setup.h"
#include "wx/menu.h"
+#include "wx/window.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
#include "wx/utils.h"
#include "wx/tabctrl.h"
#include "wx/tooltip.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/log.h"
bool wxWindow::MacIsReallyShown() const
{
+ if ( m_isShown && (m_parent != NULL) ) {
+ return m_parent->MacIsReallyShown();
+ }
+ return m_isShown;
+/*
bool status = m_isShown ;
wxWindow * win = this ;
while ( status && win->m_parent != NULL )
status = win->m_isShown ;
}
return status ;
+*/
}
int wxWindow::GetCharHeight() const
wxClientDC dc( (wxWindow*) this ) ;
long lx,ly,ld,le ;
- dc.GetTextExtent( string , &lx , &ly , &ld, &le, fontToUse ) ;
+ dc.GetTextExtent( string , &lx , &ly , &ld, &le, (wxFont *)fontToUse ) ;
if ( externalLeading )
*externalLeading = le ;
if ( descent )
{
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 )
{
#include "wx/utils.h"
#include "wx/metafile.h"
#include "wx/clipbrd.h"
+#include "wx/intl.h"
#define wxUSE_DATAOBJ 1
#include "wx/control.h"
#include "wx/panel.h"
#include "wx/app.h"
+#include "wx/dc.h"
#include "wx/notebook.h"
#include "wx/tabctrl.h"
#include "wx/radiobox.h"
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: msw/dir.cpp
-// Purpose: wxDir implementation for Mac
-// Author: Stefan Csomor
-// Modified by:
-// Created: 08.12.99
-// RCS-ID: $Id$
-// Copyright: (c) 1999 Stefan Csomor <csomor@advanced.ch>
-// Licence: wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-#ifdef __GNUG__
- #pragma implementation "dir.h"
-#endif
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/intl.h"
- #include "wx/log.h"
-#endif // PCH
-
-#include "wx/dir.h"
-#include "wx/filefn.h" // for wxPathExists()
-
-#ifndef __WXMAC_X__
- #include <windows.h>
-#endif
-
-#if defined(__WXMAC__) && !defined(__UNIX__)
- #include "morefile.h"
- #include "moreextr.h"
- #include "fullpath.h"
- #include "fspcompa.h"
-#endif
-
-// ----------------------------------------------------------------------------
-// constants
-// ----------------------------------------------------------------------------
-
-#ifndef MAX_PATH
- #define MAX_PATH 260 // from VC++ headers
-#endif
-
-// ----------------------------------------------------------------------------
-// macros
-// ----------------------------------------------------------------------------
-
-#define M_DIR ((wxDirData *)m_data)
-
-// ----------------------------------------------------------------------------
-// private classes
-// ----------------------------------------------------------------------------
-
-// this class stores everything we need to enumerate the files
-class wxDirData
-{
-public:
- wxDirData(const wxString& dirname);
- ~wxDirData();
-
- void SetFileSpec(const wxString& filespec) { m_filespec = filespec; }
- void SetFlags(int flags) { m_flags = flags; }
-
- bool Read(wxString *filename); // reads the next
- void Rewind() ;
-
-private:
- CInfoPBRec m_CPB ;
- wxInt16 m_index ;
- long m_dirId ;
- Str255 m_name ;
- Boolean m_isDir ;
-
- wxString m_dirname;
- wxString m_filespec;
-
- int m_flags;
-};
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxDirData
-// ----------------------------------------------------------------------------
-
-wxDirData::wxDirData(const wxString& dirname)
- : m_dirname(dirname)
-{
- // throw away the trailing slashes
- size_t n = m_dirname.length();
- wxCHECK_RET( n, _T("empty dir name in wxDir") );
-
- while ( n > 0 && wxIsPathSeparator(m_dirname[--n]) )
- ;
-
- m_dirname.Truncate(n + 1);
-
- FSSpec fsspec ;
-
- wxUnixFilename2FSSpec( m_dirname , &fsspec ) ;
- m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
- m_CPB.hFileInfo.ioNamePtr = m_name ;
- m_index = 0 ;
-
-#ifdef __WXMAC_X__
- // TODO: what are we supposed to do for Mac OS X
-#else
- FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
-#endif
-}
-
-wxDirData::~wxDirData()
-{
-}
-
-void wxDirData::Rewind()
-{
- m_index = 0 ;
-}
-
-bool wxDirData::Read(wxString *filename)
-{
- if ( !m_isDir )
- return FALSE ;
-
-#if TARGET_CARBON
- char c_name[256] ;
-#endif
- wxString result;
-
- short err = noErr ;
-
- while ( err == noErr )
- {
- m_index++ ;
- m_CPB.dirInfo.ioFDirIndex = m_index;
- m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */
- err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB);
- if ( err != noErr )
- break ;
-
-#if TARGET_CARBON
- p2cstrcpy( c_name, m_name ) ;
- strcpy( (char *)m_name, c_name);
-#else
- p2cstr( m_name ) ;
-#endif
- if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory
- break ;
-
- if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) ) // its a file but we don't want it
- continue ;
-
- if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) // its hidden but we don't want it
- continue ;
-
- wxString file( m_name ) ;
- if ( m_filespec.IsEmpty() || m_filespec == "*.*" )
- {
- }
- else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" )
- {
- if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
- {
- continue ;
- }
- }
- else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" )
- {
- if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
- {
- continue ;
- }
- }
- else if ( file.Upper() != m_filespec.Upper() )
- {
- continue ;
- }
-
- break ;
- }
- if ( err != noErr )
- {
- return FALSE ;
- }
-
- *filename = (char*) m_name ;
-
- return TRUE;
-}
-
-// ----------------------------------------------------------------------------
-// wxDir helpers
-// ----------------------------------------------------------------------------
-
-/* static */
-bool wxDir::Exists(const wxString& dir)
-{
- return wxPathExists(dir);
-}
-
-// ----------------------------------------------------------------------------
-// wxDir construction/destruction
-// ----------------------------------------------------------------------------
-
-wxDir::wxDir(const wxString& dirname)
-{
- m_data = NULL;
-
- (void)Open(dirname);
-}
-
-bool wxDir::Open(const wxString& dirname)
-{
- delete M_DIR;
- m_data = new wxDirData(dirname);
-
- return TRUE;
-}
-
-bool wxDir::IsOpened() const
-{
- return m_data != NULL;
-}
-
-wxDir::~wxDir()
-{
- delete M_DIR;
-}
-
-// ----------------------------------------------------------------------------
-// wxDir enumerating
-// ----------------------------------------------------------------------------
-
-bool wxDir::GetFirst(wxString *filename,
- const wxString& filespec,
- int flags) const
-{
- wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") );
-
- M_DIR->Rewind();
-
- M_DIR->SetFileSpec(filespec);
- M_DIR->SetFlags(flags);
-
- return GetNext(filename);
-}
-
-bool wxDir::GetNext(wxString *filename) const
-{
- wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") );
-
- wxCHECK_MSG( filename, FALSE, _T("bad pointer in wxDir::GetNext()") );
-
- return M_DIR->Read(filename);
-}
#include "wx/cmndata.h"
#if defined(__UNIX__)
- #include <NavigationServices/Navigation.h>
+ #include <Carbon/Carbon.h>
#else
#include <Navigation.h>
#endif
// flashing of the button when the key is hit
static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec,
- short *item, Ptr dataPtr)
+ short *item, void *dataPtr)
{
#pragma unused (dataPtr)
// MyDlgHook is a hook routine that maps the select button to Open
// 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;
long desktopDirID;
}
}
-static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr)
+static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
{
#pragma unused (dataPtr)
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: msw/dir.cpp
+// Purpose: wxDir implementation for Mac
+// Author: Stefan Csomor
+// Modified by:
+// Created: 08.12.99
+// RCS-ID: $Id$
+// Copyright: (c) 1999 Stefan Csomor <csomor@advanced.ch>
+// Licence: wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#ifdef __GNUG__
+ #pragma implementation "dir.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/intl.h"
+ #include "wx/log.h"
+#endif // PCH
+
+#include "wx/dir.h"
+#include "wx/filefn.h" // for wxPathExists()
+
+#ifndef __WXMAC_X__
+ #include <windows.h>
+#endif
+
+#if defined(__WXMAC__) && !defined(__UNIX__)
+ #include "morefile.h"
+ #include "moreextr.h"
+ #include "fullpath.h"
+ #include "fspcompa.h"
+#endif
+
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+#ifndef MAX_PATH
+ #define MAX_PATH 260 // from VC++ headers
+#endif
+
+// ----------------------------------------------------------------------------
+// macros
+// ----------------------------------------------------------------------------
+
+#define M_DIR ((wxDirData *)m_data)
+
+// ----------------------------------------------------------------------------
+// private classes
+// ----------------------------------------------------------------------------
+
+// this class stores everything we need to enumerate the files
+class wxDirData
+{
+public:
+ wxDirData(const wxString& dirname);
+ ~wxDirData();
+
+ void SetFileSpec(const wxString& filespec) { m_filespec = filespec; }
+ void SetFlags(int flags) { m_flags = flags; }
+
+ bool Read(wxString *filename); // reads the next
+ void Rewind() ;
+
+private:
+ CInfoPBRec m_CPB ;
+ wxInt16 m_index ;
+ long m_dirId ;
+ Str255 m_name ;
+ Boolean m_isDir ;
+
+ wxString m_dirname;
+ wxString m_filespec;
+
+ int m_flags;
+};
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxDirData
+// ----------------------------------------------------------------------------
+
+wxDirData::wxDirData(const wxString& dirname)
+ : m_dirname(dirname)
+{
+ // throw away the trailing slashes
+ size_t n = m_dirname.length();
+ wxCHECK_RET( n, _T("empty dir name in wxDir") );
+
+ while ( n > 0 && wxIsPathSeparator(m_dirname[--n]) )
+ ;
+
+ m_dirname.Truncate(n + 1);
+
+ FSSpec fsspec ;
+
+ wxUnixFilename2FSSpec( m_dirname , &fsspec ) ;
+ m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
+ m_CPB.hFileInfo.ioNamePtr = m_name ;
+ m_index = 0 ;
+
+#ifdef __WXMAC_X__
+ // TODO: what are we supposed to do for Mac OS X
+#else
+ FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
+#endif
+}
+
+wxDirData::~wxDirData()
+{
+}
+
+void wxDirData::Rewind()
+{
+ m_index = 0 ;
+}
+
+bool wxDirData::Read(wxString *filename)
+{
+ if ( !m_isDir )
+ return FALSE ;
+
+#if TARGET_CARBON
+ char c_name[256] ;
+#endif
+ wxString result;
+
+ short err = noErr ;
+
+ while ( err == noErr )
+ {
+ m_index++ ;
+ m_CPB.dirInfo.ioFDirIndex = m_index;
+ m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */
+ err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB);
+ if ( err != noErr )
+ break ;
+
+#if TARGET_CARBON
+ p2cstrcpy( c_name, m_name ) ;
+ strcpy( (char *)m_name, c_name);
+#else
+ p2cstr( m_name ) ;
+#endif
+ if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory
+ break ;
+
+ if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) ) // its a file but we don't want it
+ continue ;
+
+ if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) // its hidden but we don't want it
+ continue ;
+
+ wxString file( m_name ) ;
+ if ( m_filespec.IsEmpty() || m_filespec == "*.*" )
+ {
+ }
+ else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" )
+ {
+ if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
+ {
+ continue ;
+ }
+ }
+ else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" )
+ {
+ if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
+ {
+ continue ;
+ }
+ }
+ else if ( file.Upper() != m_filespec.Upper() )
+ {
+ continue ;
+ }
+
+ break ;
+ }
+ if ( err != noErr )
+ {
+ return FALSE ;
+ }
+
+ *filename = (char*) m_name ;
+
+ return TRUE;
+}
+
+// ----------------------------------------------------------------------------
+// wxDir helpers
+// ----------------------------------------------------------------------------
+
+/* static */
+bool wxDir::Exists(const wxString& dir)
+{
+ return wxPathExists(dir);
+}
+
+// ----------------------------------------------------------------------------
+// wxDir construction/destruction
+// ----------------------------------------------------------------------------
+
+wxDir::wxDir(const wxString& dirname)
+{
+ m_data = NULL;
+
+ (void)Open(dirname);
+}
+
+bool wxDir::Open(const wxString& dirname)
+{
+ delete M_DIR;
+ m_data = new wxDirData(dirname);
+
+ return TRUE;
+}
+
+bool wxDir::IsOpened() const
+{
+ return m_data != NULL;
+}
+
+wxDir::~wxDir()
+{
+ delete M_DIR;
+}
+
+// ----------------------------------------------------------------------------
+// wxDir enumerating
+// ----------------------------------------------------------------------------
+
+bool wxDir::GetFirst(wxString *filename,
+ const wxString& filespec,
+ int flags) const
+{
+ wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") );
+
+ M_DIR->Rewind();
+
+ M_DIR->SetFileSpec(filespec);
+ M_DIR->SetFlags(flags);
+
+ return GetNext(filename);
+}
+
+bool wxDir::GetNext(wxString *filename) const
+{
+ wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") );
+
+ wxCHECK_MSG( filename, FALSE, _T("bad pointer in wxDir::GetNext()") );
+
+ return M_DIR->Read(filename);
+}
// ----------------------------------------------------------------------------
// wxTextDropTarget
// ----------------------------------------------------------------------------
-
-bool wxTextDropTarget::OnDrop( long x, long y, const void *pData )
+#ifndef __WXMAC_X__
+bool wxTextDropTarget::OnDrop( wxCoord x, wxCoord y, const void *pData )
{
OnDropText( x, y, (const char*)pData );
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 );
return TRUE;
};
+#ifndef __WXMAC_X__
size_t wxTextDropTarget::GetFormatCount() const
{
return 1;
{
return wxDF_TEXT;
}
+#endif
// ----------------------------------------------------------------------------
// 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( "At x: %d, y: %d.\n", (int)x, (int)y );
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, &str );
+ return OnDropFiles(x, y, 1, &filenames);
}
+#ifndef __WXMAC_X__
size_t wxFileDropTarget::GetFormatCount() const
{
return 1;
{
return wxDF_FILENAME;
}
+#endif
//-------------------------------------------------------------------------
// wxDropSource
#endif
#include "wx/defs.h"
+#include "wx/app.h"
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/filedlg.h"
// begin wxmac
#if defined(__UNIX__)
- #include <NavigationServices/Navigation.h>
+ #include <Carbon/Carbon.h>
#else
#include <Navigation.h>
#endif
#endif
*/
+ wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event);
}
}
// flashing of the button when the key is hit
static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec,
- short *item, Ptr dataPtr)
+ short *item, void *dataPtr)
{
#pragma unused (dataPtr)
}
}
-static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr)
+static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
{
Str255 filename ;
OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ;
#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
-#define OTUNIXERRORS 1
#ifdef __UNIX__
- #include <CarbonCore/CarbonCore.h>
- #include <OT/OpenTransport.h>
- #include <OT/OpenTransportProviders.h>
+ #include <CoreServices/CoreServices.h>
#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif
#else
+ #define OTUNIXERRORS 1
#include <OpenTransport.h>
#include <OpenTransportProviders.h>
#include <OpenTptInternet.h>
ret.opt.maxlen = kOTFourByteOptionSize;
opt->level = INET_IP; // dealing with an IP Level function
+#ifdef __UNIX__
+ opt->name = kIP_REUSEADDR;
+#else
opt->name = IP_REUSEADDR;
+#endif
opt->len = kOTFourByteOptionSize;
opt->status = 0;
*(UInt32*)opt->value = enableReuseIPMode; // set the desired option level, true or false
{
OTFlags flags ;
OTResult res ;
+ OTByteCount sz = 0 ;
- size_t sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ;
res = OTRcv( socket->m_endpoint , buffer , size , &flags ) ;
if ( res < 0 )
// we simulate another read event if there are still bytes
if ( socket->m_takesEvents )
{
- size_t sz = 0 ;
+ OTByteCount sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ;
if ( sz > 0 )
{
assert(address != NULL);
CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
- OTInetAddressToName( gInetSvcRef , address->m_host , &name ) ;
+ OTInetAddressToName( gInetSvcRef , address->m_host , name ) ;
strncpy( hostname , name , sbuf ) ;
return GSOCK_NOERROR;
}
state = OTGetEndpointState(socket->m_endpoint);
{
- size_t sz = 0 ;
+ OTByteCount sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ;
if ( state == T_INCON || sz > 0 )
{
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < socket->m_timeout * 1000.0 )
{
OTResult state ;
- size_t sz = 0 ;
+ OTByteCount sz = 0 ;
state = OTGetEndpointState(socket->m_endpoint);
OTCountDataBytes( socket->m_endpoint , &sz ) ;
#pragma once
#if defined(__UNIX__)
- #include <HIToolbox/lists.h>
+ #include <Carbon/Carbon.h>
#else
#include <Lists.h>
#endif
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: mac/mimetype.cpp
+// Purpose: classes and functions to manage MIME types
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 23.09.98
+// RCS-ID: $Id$
+// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence: wxWindows license (part of wxExtra library)
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "mimetype.h"
+#endif
+
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/defs.h"
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/string.h"
+ #if wxUSE_GUI
+ #include "wx/icon.h"
+ #endif
+#endif //WX_PRECOMP
+
+
+#include "wx/log.h"
+#include "wx/file.h"
+#include "wx/intl.h"
+#include "wx/dynarray.h"
+#include "wx/confbase.h"
+
+#include "wx/mac/mimetype.h"
+
+// other standard headers
+#include <ctype.h>
+
+// in case we're compiling in non-GUI mode
+class WXDLLEXPORT wxIcon;
+
+
+
+
+
+
+bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
+{
+ return FALSE;
+}
+
+// @@ this function is half implemented
+bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
+{
+ return FALSE;
+}
+
+bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
+{
+ if ( m_strFileType.Length() > 0 )
+ {
+ *mimeType = m_strFileType ;
+ return TRUE ;
+ }
+ else
+ return FALSE;
+}
+
+bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
+{
+ wxString s;
+
+ if (GetMimeType(&s))
+ {
+ mimeTypes.Clear();
+ mimeTypes.Add(s);
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
+{
+ // no such file type or no value or incorrect icon entry
+ return FALSE;
+}
+
+bool wxFileTypeImpl::GetDescription(wxString *desc) const
+{
+ return FALSE;
+}
+
+// extension -> file type
+wxFileType *
+wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
+{
+ wxString ext = e ;
+ ext = ext.Lower() ;
+ if ( ext == "txt" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("text/text");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "htm" || ext == "html" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("text/html");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "gif" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/gif");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "png" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/png");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "jpg" || ext == "jpeg" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/jpeg");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "bmp" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/bmp");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "tif" || ext == "tiff" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/tiff");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "xpm" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/xpm");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "xbm" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/xbm");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+
+ // unknown extension
+ return NULL;
+}
+
+// MIME type -> extension -> file type
+wxFileType *
+wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
+{
+ return NULL;
+}
+
+size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
+{
+ wxFAIL_MSG( _T("TODO") ); // VZ: don't know anything about this for Mac
+
+ return 0;
+}
+
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: mac/mimetype.cpp
-// Purpose: classes and functions to manage MIME types
-// Author: Vadim Zeitlin
-// Modified by:
-// Created: 23.09.98
-// RCS-ID: $Id$
-// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence: wxWindows license (part of wxExtra library)
-/////////////////////////////////////////////////////////////////////////////
-
-#ifdef __GNUG__
-#pragma implementation "mimetype.h"
-#endif
-
-// for compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/defs.h"
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/string.h"
- #if wxUSE_GUI
- #include "wx/icon.h"
- #endif
-#endif //WX_PRECOMP
-
-
-#include "wx/log.h"
-#include "wx/file.h"
-#include "wx/intl.h"
-#include "wx/dynarray.h"
-#include "wx/confbase.h"
-
-#include "wx/mac/mimetype.h"
-
-// other standard headers
-#include <ctype.h>
-
-// in case we're compiling in non-GUI mode
-class WXDLLEXPORT wxIcon;
-
-
-
-
-
-
-bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
-{
- return FALSE;
-}
-
-// @@ this function is half implemented
-bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
-{
- return FALSE;
-}
-
-bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
-{
- if ( m_strFileType.Length() > 0 )
- {
- *mimeType = m_strFileType ;
- return TRUE ;
- }
- else
- return FALSE;
-}
-
-bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
-{
- wxString s;
-
- if (GetMimeType(&s))
- {
- mimeTypes.Clear();
- mimeTypes.Add(s);
- return TRUE;
- }
- else
- return FALSE;
-}
-
-bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
-{
- // no such file type or no value or incorrect icon entry
- return FALSE;
-}
-
-bool wxFileTypeImpl::GetDescription(wxString *desc) const
-{
- return FALSE;
-}
-
-// extension -> file type
-wxFileType *
-wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
-{
- wxString ext = e ;
- ext = ext.Lower() ;
- if ( ext == "txt" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("text/text");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "htm" || ext == "html" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("text/html");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "gif" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/gif");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "png" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/png");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "jpg" || ext == "jpeg" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/jpeg");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "bmp" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/bmp");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "tif" || ext == "tiff" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/tiff");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "xpm" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/xpm");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == "xbm" )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType("image/xbm");
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
-
- // unknown extension
- return NULL;
-}
-
-// MIME type -> extension -> file type
-wxFileType *
-wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
-{
- return NULL;
-}
-
-size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
-{
- wxFAIL_MSG( _T("TODO") ); // VZ: don't know anything about this for Mac
-
- return 0;
-}
-
wxPNGReaderIter iter(this);
/* open the file */
+#ifndef __UNIX__
fp = fopen(wxUnix2MacFilename( ImageFileName ), "rb");
+#else
+ fp = fopen( ImageFileName , "rb" );
+#endif
if (!fp)
return FALSE;
// 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)
- EVT_SIZE(wxStatusBarXX::OnSize)
+BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBar)
+ EVT_SIZE(wxStatusBarMac::OnSize)
END_EVENT_TABLE()
// ============================================================================
// ----------------------------------------------------------------------------
-// wxStatusBarXX class
+// wxStatusBarMac class
// ----------------------------------------------------------------------------
-wxStatusBarXX::wxStatusBarXX()
+wxStatusBarMac::wxStatusBarMac()
{
SetParent(NULL);
}
-wxStatusBarXX::wxStatusBarXX(wxWindow *parent, wxWindowID id, long style)
-{
- Create(parent, id, style);
-}
-
-bool wxStatusBarXX::Create(wxWindow *parent, wxWindowID id, long style)
+bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name = wxPanelNameStr)
{
SetParent(parent);
return FALSE;
}
-void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[])
+void wxStatusBarMac::SetFieldsCount(int nFields, const int widths[])
{
wxASSERT( (nFields > 0) && (nFields < 255) );
SetFieldsWidth();
}
-void wxStatusBarXX::SetStatusWidths(int n, const int widths[])
+void wxStatusBarMac::SetStatusWidths(int n, const int widths[])
{
wxASSERT( n == m_nFields );
SetFieldsWidth();
}
-void wxStatusBarXX::CopyFieldsWidth(const int widths[])
+void wxStatusBarMac::CopyFieldsWidth(const int widths[])
{
if (widths && !m_statusWidths)
m_statusWidths = new int[m_nFields];
}
}
-void wxStatusBarXX::SetFieldsWidth()
+void wxStatusBarMac::SetFieldsWidth()
{
int *pWidths = new int[m_nFields];
delete [] pWidths;
}
-void wxStatusBarXX::SetStatusText(const wxString& strText, int nField)
+void wxStatusBarMac::SetStatusText(const wxString& strText, int nField)
{
// TODO
}
-wxString wxStatusBarXX::GetStatusText(int nField) const
+wxString wxStatusBarMac::GetStatusText(int nField) const
{
wxASSERT( (nField > -1) && (nField < m_nFields) );
return wxString("");
}
-void wxStatusBarXX::OnSize(wxSizeEvent& event)
+void wxStatusBarMac::OnSize(wxSizeEvent& event)
{
// adjust fields widths to the new size
SetFieldsWidth();
#include <fstream.h>
#include "wx/app.h"
+#include "wx/dc.h"
#include "wx/button.h"
#include "wx/panel.h"
#include "wx/textctrl.h"
#if wxUSE_TOOLTIPS
#include "wx/app.h"
+#include "wx/dc.h"
#include "wx/window.h"
#include "wx/tooltip.h"
#include "wx/timer.h"
#include "wx/defs.h"
+#include "wx/dc.h"
#include "wx/mac/uma.h"
#include "wx/mac/aga.h"
#ifdef __UNIX__
- #include <NavigationServices/Navigation.h>
+ #include <Carbon/Carbon.h>
#else
#include <Navigation.h>
#endif
return (wxBusyCursorCount > 0);
}
+#ifndef __UNIX__
wxString wxMacFindFolder( short vol,
OSType folderType,
Boolean createFolder)
}
return strDir ;
}
+#endif
#ifndef __UNIX__
char *wxGetUserHome (const wxString& user)
#endif
}
+void wxDisplaySizeMM(int *width, int *height)
+{
+ wxDisplaySize(width, height);
+}
+
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{
return wxGenericFindWindowAtPoint(pt);
#endif
#include "wx/utils.h"
+#ifdef __UNIX__
+#include "wx/unix/execute.h"
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifndef __UNIX__
#define wxEXECUTE_WIN_MESSAGE 10000
long wxExecute(const wxString& command, bool sync, wxProcess *handler)
// TODO
return 0;
}
+#endif
+
+#ifdef __UNIX__
+int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
+{
+ wxFAIL_MSG(wxT("wxAddProcessCallback() function not ready"));
+ return 0;
+}
+#endif
\ No newline at end of file
if (m_isResource)
{
- strcpy(lpSnd, m_sndname);
- c2pstr((char *) lpSnd);
- SndListHandle hSnd;
-
- hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd);
+#if TARGET_CARBON
+ c2pstrcpy((unsigned char *)lpSnd, m_sndname);
+#else
+ strcpy(lpSnd, m_sndname);
+ c2pstr((char *) lpSnd);
+#endif
+ SndListHandle hSnd;
+
+ hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd);
- if ((hSnd != NULL) && (SndPlay(m_sndChan, hSnd, async) == noErr))
- ret = true;
+ if ((hSnd != NULL) && (SndPlay(m_sndChan, hSnd, async) == noErr))
+ ret = true;
}
return ret;
#include "wx/setup.h"
#include "wx/menu.h"
+#include "wx/window.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
#include "wx/utils.h"
#include "wx/tabctrl.h"
#include "wx/tooltip.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/log.h"
bool wxWindow::MacIsReallyShown() const
{
+ if ( m_isShown && (m_parent != NULL) ) {
+ return m_parent->MacIsReallyShown();
+ }
+ return m_isShown;
+/*
bool status = m_isShown ;
wxWindow * win = this ;
while ( status && win->m_parent != NULL )
status = win->m_isShown ;
}
return status ;
+*/
}
int wxWindow::GetCharHeight() const
wxClientDC dc( (wxWindow*) this ) ;
long lx,ly,ld,le ;
- dc.GetTextExtent( string , &lx , &ly , &ld, &le, fontToUse ) ;
+ dc.GetTextExtent( string , &lx , &ly , &ld, &le, (wxFont *)fontToUse ) ;
if ( externalLeading )
*externalLeading = le ;
if ( descent )
{
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 )
{
+++ /dev/null
-/*
- * 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.
- */
-
-/*****************************************************************************\
-* Image.c: *
-* *
-* XPM library *
-* Functions to init and free the XpmImage structure. *
-* *
-* Developed by Arnaud Le Hors *
-\*****************************************************************************/
-
-#include "XpmI.h"
-
-/*
- * Init returned data to free safely later on
- */
-void
-xpmInitXpmImage(image)
- XpmImage *image;
-{
- image->ncolors = 0;
- image->colorTable = NULL;
- image->data = NULL;
-}
-
-/*
- * Free the XpmImage data which have been allocated
- */
-void
-XpmFreeXpmImage(image)
- XpmImage *image;
-{
- if (image->colorTable)
- xpmFreeColorTable(image->colorTable, image->ncolors);
- if (image->data)
- XpmFree(image->data);
- image->data = NULL;
-}
#include "wx/setup.h"
#ifdef macintosh
- #ifdef __std
- #undef __std
- #define __std()
- #endif
#include <stat.h>
#include <unix.h>
#include <unistd.h>
#include "wx/setup.h"
#ifdef macintosh
- #ifdef __std
- #undef __std
- #define __std()
- #endif
#include <stat.h>
#include <unix.h>
#include <unistd.h>
+++ /dev/null
-/*
- * 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;
-}
--- /dev/null
+/*
+ * 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.
+ */
+
+/*****************************************************************************\
+* Image.c: *
+* *
+* XPM library *
+* Functions to init and free the XpmImage structure. *
+* *
+* Developed by Arnaud Le Hors *
+\*****************************************************************************/
+
+#include "XpmI.h"
+
+/*
+ * Init returned data to free safely later on
+ */
+void
+xpmInitXpmImage(image)
+ XpmImage *image;
+{
+ image->ncolors = 0;
+ image->colorTable = NULL;
+ image->data = NULL;
+}
+
+/*
+ * Free the XpmImage data which have been allocated
+ */
+void
+XpmFreeXpmImage(image)
+ XpmImage *image;
+{
+ if (image->colorTable)
+ xpmFreeColorTable(image->colorTable, image->ncolors);
+ if (image->data)
+ XpmFree(image->data);
+ image->data = NULL;
+}
cmd << " -a";
#elif defined(__LINUX__) || defined(__SGI__)
// nothing to be added to ifconfig
-#elif defined(__FREEBSD__)
+#elif defined(__FREEBSD__) || defined(__WXMAC__)
// add -l flag
cmd << " -l";
#elif defined(__HPUX__)
cmd << m_PingPath << ' ';
#if defined(__SOLARIS__) || defined (__SUNOS__)
// nothing to add to ping command
-#elif defined(__LINUX__) || defined ( __FREEBSD__)
+#elif defined(__LINUX__) || defined ( __FREEBSD__) || defined(__WXMAC__)
cmd << "-c 1 "; // only ping once
#elif defined(__HPUX__)
cmd << "64 1 "; // only ping once (need also specify the packet size)