corrections for final release of Mac OS X

applied patches proposed by Mark Newsam


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

View File

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

View File

@@ -53,7 +53,7 @@
#if wxUSE_SOCKETS
#ifdef __APPLE__
#include <OT/OpenTransport.h>
#include <CoreServices/CoreServices.h>
#else
#include <OpenTransport.h>
#include <OpenTptInternet.h>
@@ -95,25 +95,25 @@ bool wxApp::s_macSupportPCMenuShortcuts = true ;
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) ;
@@ -1469,7 +1469,11 @@ void wxApp::MacHandleOSEvent( EventRecord *ev )
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 )
{

View File

@@ -36,7 +36,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
#endif
#ifdef __UNIX__
#include <QD/PictUtils.h>
#include <ApplicationServices/ApplicationServices.h>
#else
#include <PictUtils.h>
#endif
@@ -97,6 +97,97 @@ void wxMacDestroyGWorld( GWorldPtr gw )
DisposeGWorld( gw ) ;
}
PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
{
CGrafPtr origPort ;
GDHandle origDev ;
PicHandle pict; // this is the Picture we give back
RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ;
RGBColor white = { 0xffff ,0xffff , 0xffff } ;
RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;
unsigned char *maskimage = NULL ;
Rect portRect ;
GetPortBounds( wp , &portRect ) ;
int width = portRect.right - portRect.left ;
int height = portRect.bottom - portRect.top ;
LockPixels( GetGWorldPixMap( wp ) ) ;
GetGWorld( &origPort , &origDev ) ;
if ( mask )
{
maskimage = (unsigned char*) malloc( width * height ) ;
SetGWorld( mask , NULL ) ;
LockPixels( GetGWorldPixMap( mask ) ) ;
for ( int y = 0 ; y < height ; y++ )
{
for( int x = 0 ; x < width ; x++ )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
maskimage[y*width + x] = ( col.red == 0 ) ; // for monochrome masks
}
}
UnlockPixels( GetGWorldPixMap( mask ) ) ;
}
SetGWorld( wp , NULL ) ;
pict = OpenPicture(&portRect); // open a picture, this disables drawing
if(!pict)
return NULL;
if ( maskimage )
{
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
PenMode(transparent);
for ( int y = 0 ; y < height ; ++y )
{
for( int x = 0 ; x < width ; ++x )
{
if ( maskimage[y*width + x] )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
SetCPixel( x + portRect.left , y + portRect.top , &col ) ;
}
else {
// With transparency set this sets a blank pixel not a white one
SetCPixel( x + portRect.left , y + portRect.top , &white);
}
}
}
free( maskimage ) ;
maskimage = NULL ;
}
else
{
RGBBackColor( &gray ) ;
EraseRect(&portRect);
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
CopyBits(GetPortBitMapForCopyBits(wp), /* src PixMap - we copy image over
* itself - */
GetPortBitMapForCopyBits(wp), // dst PixMap - no drawing occurs
&portRect, // srcRect - it will be recorded and compressed -
&portRect, // dstRect - into the picture that is open -
srcCopy,NULL); // copyMode and no clip region
}
ClosePicture(); // We are done recording the picture
UnlockPixels( GetGWorldPixMap( wp ) ) ;
SetGWorld( origPort , origDev ) ;
return pict; // return our groovy pict handle
}
wxBitmapRefData::wxBitmapRefData()
{
m_ok = FALSE;
@@ -180,8 +271,18 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
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 ;
@@ -190,6 +291,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
{
linesize += 2 ;
}
#endif
RGBColor colors[2] = {
{ 0xFFFF , 0xFFFF , 0xFFFF } ,
@@ -214,7 +316,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
}
}
UnlockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ;
UnlockPixels( GetGWorldPixMap( M_BITMAPDATA->m_hBitmap ) ) ;
SetGWorld( origPort , origDevice ) ;
}
@@ -261,6 +363,95 @@ wxBitmap::wxBitmap(char **data)
(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();
@@ -277,6 +468,13 @@ bool wxBitmap::Create(int w, int h, int d)
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 ;
@@ -331,6 +529,46 @@ bool wxBitmap::SaveFile(const wxString& filename, int type, const wxPalette *pal
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)
@@ -371,6 +609,13 @@ void wxBitmap::SetOk(bool isOk)
M_BITMAPDATA->m_ok = isOk;
}
wxPalette *wxBitmap::GetPalette() const
{
wxCHECK_MSG( Ok(), NULL, wxT("Invalid bitmap GetPalette()") );
return &M_BITMAPDATA->m_bitmapPalette;
}
void wxBitmap::SetPalette(const wxPalette& palette)
{
if (!M_BITMAPDATA)
@@ -387,6 +632,105 @@ void wxBitmap::SetMask(wxMask *mask)
M_BITMAPDATA->m_bitmapMask = mask ;
}
WXHBITMAP wxBitmap::GetHBITMAP() const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
return M_BITMAPDATA->m_hBitmap;
}
PicHandle wxBitmap::GetPict() const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
PicHandle picture; // This is the returned picture
// If bitmap already in Pict format return pointer
if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypePict) {
return M_BITMAPDATA->m_hPict;
}
else if(M_BITMAPDATA->m_bitmapType != kMacBitmapTypeGrafWorld) {
// Invalid bitmap
return NULL;
}
RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ;
RGBColor white = { 0xffff ,0xffff , 0xffff } ;
RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;
CGrafPtr origPort;
GDHandle origDev ;
wxMask *mask;
Rect portRect ;
GetPortBounds( GetHBITMAP() , &portRect ) ;
int width = portRect.right - portRect.left ;
int height = portRect.bottom - portRect.top ;
LockPixels( GetGWorldPixMap( GetHBITMAP() ) ) ;
GetGWorld( &origPort , &origDev ) ;
mask = GetMask();
SetGWorld( GetHBITMAP() , NULL ) ;
picture = OpenPicture(&portRect); // open a picture, this disables drawing
if(!picture) {
return NULL;
}
if( mask )
{
#ifdef __UNIX__
RGBColor trans = white;
#else
RGBBackColor( &gray );
EraseRect( &portRect );
RGBColor trans = gray;
#endif
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
PenMode(transparent);
for ( int y = 0 ; y < height ; ++y )
{
for( int x = 0 ; x < width ; ++x )
{
if ( !mask->PointMasked(x,y) )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
SetCPixel( x + portRect.left , y + portRect.top , &col ) ;
}
else {
// With transparency this sets a blank pixel
SetCPixel( x + portRect.left , y + portRect.top , &trans);
}
}
}
}
else
{
RGBBackColor( &gray ) ;
EraseRect(&portRect);
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
CopyBits(GetPortBitMapForCopyBits(GetHBITMAP()),
// src PixMap - we copy image over itself -
GetPortBitMapForCopyBits(GetHBITMAP()),
// dst PixMap - no drawing occurs
&portRect, // srcRect - it will be recorded and compressed -
&portRect, // dstRect - into the picture that is open -
srcCopy,NULL); // copyMode and no clip region
}
ClosePicture(); // We are done recording the picture
UnlockPixels( GetGWorldPixMap( GetHBITMAP() ) ) ;
SetGWorld( origPort , origDev ) ;
return picture; // return our groovy pict handle
}
void wxBitmap::AddHandler(wxBitmapHandler *handler)
{
sm_handlers.Append(handler);
@@ -493,8 +837,32 @@ wxMask::~wxMask()
// 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
@@ -502,6 +870,7 @@ bool wxMask::Create(const wxBitmap& bitmap)
bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
{
// TODO
wxCHECK_MSG( 0, false, wxT("Not implemented"));
return FALSE;
}
@@ -514,39 +883,35 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
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] ) ;
}
@@ -557,12 +922,33 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
}
}
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
*/

View File

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

View File

@@ -53,7 +53,7 @@
#if wxUSE_SOCKETS
#ifdef __APPLE__
#include <OT/OpenTransport.h>
#include <CoreServices/CoreServices.h>
#else
#include <OpenTransport.h>
#include <OpenTptInternet.h>
@@ -95,25 +95,25 @@ bool wxApp::s_macSupportPCMenuShortcuts = true ;
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) ;
@@ -1469,7 +1469,11 @@ void wxApp::MacHandleOSEvent( EventRecord *ev )
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 )
{

View File

@@ -36,7 +36,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
#endif
#ifdef __UNIX__
#include <QD/PictUtils.h>
#include <ApplicationServices/ApplicationServices.h>
#else
#include <PictUtils.h>
#endif
@@ -97,6 +97,97 @@ void wxMacDestroyGWorld( GWorldPtr gw )
DisposeGWorld( gw ) ;
}
PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
{
CGrafPtr origPort ;
GDHandle origDev ;
PicHandle pict; // this is the Picture we give back
RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ;
RGBColor white = { 0xffff ,0xffff , 0xffff } ;
RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;
unsigned char *maskimage = NULL ;
Rect portRect ;
GetPortBounds( wp , &portRect ) ;
int width = portRect.right - portRect.left ;
int height = portRect.bottom - portRect.top ;
LockPixels( GetGWorldPixMap( wp ) ) ;
GetGWorld( &origPort , &origDev ) ;
if ( mask )
{
maskimage = (unsigned char*) malloc( width * height ) ;
SetGWorld( mask , NULL ) ;
LockPixels( GetGWorldPixMap( mask ) ) ;
for ( int y = 0 ; y < height ; y++ )
{
for( int x = 0 ; x < width ; x++ )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
maskimage[y*width + x] = ( col.red == 0 ) ; // for monochrome masks
}
}
UnlockPixels( GetGWorldPixMap( mask ) ) ;
}
SetGWorld( wp , NULL ) ;
pict = OpenPicture(&portRect); // open a picture, this disables drawing
if(!pict)
return NULL;
if ( maskimage )
{
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
PenMode(transparent);
for ( int y = 0 ; y < height ; ++y )
{
for( int x = 0 ; x < width ; ++x )
{
if ( maskimage[y*width + x] )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
SetCPixel( x + portRect.left , y + portRect.top , &col ) ;
}
else {
// With transparency set this sets a blank pixel not a white one
SetCPixel( x + portRect.left , y + portRect.top , &white);
}
}
}
free( maskimage ) ;
maskimage = NULL ;
}
else
{
RGBBackColor( &gray ) ;
EraseRect(&portRect);
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
CopyBits(GetPortBitMapForCopyBits(wp), /* src PixMap - we copy image over
* itself - */
GetPortBitMapForCopyBits(wp), // dst PixMap - no drawing occurs
&portRect, // srcRect - it will be recorded and compressed -
&portRect, // dstRect - into the picture that is open -
srcCopy,NULL); // copyMode and no clip region
}
ClosePicture(); // We are done recording the picture
UnlockPixels( GetGWorldPixMap( wp ) ) ;
SetGWorld( origPort , origDev ) ;
return pict; // return our groovy pict handle
}
wxBitmapRefData::wxBitmapRefData()
{
m_ok = FALSE;
@@ -180,8 +271,18 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
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 ;
@@ -190,6 +291,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
{
linesize += 2 ;
}
#endif
RGBColor colors[2] = {
{ 0xFFFF , 0xFFFF , 0xFFFF } ,
@@ -214,7 +316,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
}
}
UnlockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ;
UnlockPixels( GetGWorldPixMap( M_BITMAPDATA->m_hBitmap ) ) ;
SetGWorld( origPort , origDevice ) ;
}
@@ -261,6 +363,95 @@ wxBitmap::wxBitmap(char **data)
(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();
@@ -277,6 +468,13 @@ bool wxBitmap::Create(int w, int h, int d)
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 ;
@@ -331,6 +529,46 @@ bool wxBitmap::SaveFile(const wxString& filename, int type, const wxPalette *pal
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)
@@ -371,6 +609,13 @@ void wxBitmap::SetOk(bool isOk)
M_BITMAPDATA->m_ok = isOk;
}
wxPalette *wxBitmap::GetPalette() const
{
wxCHECK_MSG( Ok(), NULL, wxT("Invalid bitmap GetPalette()") );
return &M_BITMAPDATA->m_bitmapPalette;
}
void wxBitmap::SetPalette(const wxPalette& palette)
{
if (!M_BITMAPDATA)
@@ -387,6 +632,105 @@ void wxBitmap::SetMask(wxMask *mask)
M_BITMAPDATA->m_bitmapMask = mask ;
}
WXHBITMAP wxBitmap::GetHBITMAP() const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
return M_BITMAPDATA->m_hBitmap;
}
PicHandle wxBitmap::GetPict() const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
PicHandle picture; // This is the returned picture
// If bitmap already in Pict format return pointer
if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypePict) {
return M_BITMAPDATA->m_hPict;
}
else if(M_BITMAPDATA->m_bitmapType != kMacBitmapTypeGrafWorld) {
// Invalid bitmap
return NULL;
}
RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ;
RGBColor white = { 0xffff ,0xffff , 0xffff } ;
RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;
CGrafPtr origPort;
GDHandle origDev ;
wxMask *mask;
Rect portRect ;
GetPortBounds( GetHBITMAP() , &portRect ) ;
int width = portRect.right - portRect.left ;
int height = portRect.bottom - portRect.top ;
LockPixels( GetGWorldPixMap( GetHBITMAP() ) ) ;
GetGWorld( &origPort , &origDev ) ;
mask = GetMask();
SetGWorld( GetHBITMAP() , NULL ) ;
picture = OpenPicture(&portRect); // open a picture, this disables drawing
if(!picture) {
return NULL;
}
if( mask )
{
#ifdef __UNIX__
RGBColor trans = white;
#else
RGBBackColor( &gray );
EraseRect( &portRect );
RGBColor trans = gray;
#endif
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
PenMode(transparent);
for ( int y = 0 ; y < height ; ++y )
{
for( int x = 0 ; x < width ; ++x )
{
if ( !mask->PointMasked(x,y) )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
SetCPixel( x + portRect.left , y + portRect.top , &col ) ;
}
else {
// With transparency this sets a blank pixel
SetCPixel( x + portRect.left , y + portRect.top , &trans);
}
}
}
}
else
{
RGBBackColor( &gray ) ;
EraseRect(&portRect);
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
CopyBits(GetPortBitMapForCopyBits(GetHBITMAP()),
// src PixMap - we copy image over itself -
GetPortBitMapForCopyBits(GetHBITMAP()),
// dst PixMap - no drawing occurs
&portRect, // srcRect - it will be recorded and compressed -
&portRect, // dstRect - into the picture that is open -
srcCopy,NULL); // copyMode and no clip region
}
ClosePicture(); // We are done recording the picture
UnlockPixels( GetGWorldPixMap( GetHBITMAP() ) ) ;
SetGWorld( origPort , origDev ) ;
return picture; // return our groovy pict handle
}
void wxBitmap::AddHandler(wxBitmapHandler *handler)
{
sm_handlers.Append(handler);
@@ -493,8 +837,32 @@ wxMask::~wxMask()
// 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
@@ -502,6 +870,7 @@ bool wxMask::Create(const wxBitmap& bitmap)
bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
{
// TODO
wxCHECK_MSG( 0, false, wxT("Not implemented"));
return FALSE;
}
@@ -514,39 +883,35 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
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] ) ;
}
@@ -557,12 +922,33 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
}
}
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
*/

View File

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

View File

@@ -16,6 +16,7 @@
#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"

View File

@@ -21,7 +21,7 @@
#include "wx/cmndata.h"
#if defined(__UNIX__)
#include <NavigationServices/Navigation.h>
#include <Carbon/Carbon.h>
#else
#include <Navigation.h>
#endif
@@ -182,7 +182,7 @@ static Boolean SameFSSpec(FSSpecPtr spec1, FSSpecPtr spec2)
// 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)
@@ -210,7 +210,7 @@ static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRec
// 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;
@@ -422,7 +422,7 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
}
}
static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr)
static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
{
#pragma unused (dataPtr)

View File

@@ -39,20 +39,22 @@ wxDropTarget::~wxDropTarget()
// ----------------------------------------------------------------------------
// 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;
@@ -62,25 +64,27 @@ wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
{
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;
@@ -90,6 +94,7 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
{
return wxDF_FILENAME;
}
#endif
//-------------------------------------------------------------------------
// wxDropSource

View File

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

View File

@@ -19,11 +19,8 @@
#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
@@ -32,6 +29,7 @@
#define TRUE 1
#endif
#else
#define OTUNIXERRORS 1
#include <OpenTransport.h>
#include <OpenTransportProviders.h>
#include <OpenTptInternet.h>
@@ -123,7 +121,11 @@ OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode)
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
@@ -1043,8 +1045,8 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size)
{
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 )
@@ -1055,7 +1057,7 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size)
// 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 )
{
@@ -1365,7 +1367,7 @@ GSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, size_t
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;
}
@@ -1397,7 +1399,7 @@ void _GSocket_Enable_Events(GSocket *socket)
state = OTGetEndpointState(socket->m_endpoint);
{
size_t sz = 0 ;
OTByteCount sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ;
if ( state == T_INCON || sz > 0 )
{
@@ -1437,7 +1439,7 @@ GSocketError _GSocket_Input_Timeout(GSocket *socket)
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < socket->m_timeout * 1000.0 )
{
OTResult state ;
size_t sz = 0 ;
OTByteCount sz = 0 ;
state = OTGetEndpointState(socket->m_endpoint);
OTCountDataBytes( socket->m_endpoint , &sz ) ;

View File

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

View File

@@ -17,12 +17,13 @@
// 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()
@@ -31,20 +32,15 @@ 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);
@@ -57,7 +53,7 @@ bool wxStatusBarXX::Create(wxWindow *parent, wxWindowID id, long style)
return FALSE;
}
void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[])
void wxStatusBarMac::SetFieldsCount(int nFields, const int widths[])
{
wxASSERT( (nFields > 0) && (nFields < 255) );
@@ -67,7 +63,7 @@ void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[])
SetFieldsWidth();
}
void wxStatusBarXX::SetStatusWidths(int n, const int widths[])
void wxStatusBarMac::SetStatusWidths(int n, const int widths[])
{
wxASSERT( n == m_nFields );
@@ -75,7 +71,7 @@ void wxStatusBarXX::SetStatusWidths(int n, const int widths[])
SetFieldsWidth();
}
void wxStatusBarXX::CopyFieldsWidth(const int widths[])
void wxStatusBarMac::CopyFieldsWidth(const int widths[])
{
if (widths && !m_statusWidths)
m_statusWidths = new int[m_nFields];
@@ -90,7 +86,7 @@ void wxStatusBarXX::CopyFieldsWidth(const int widths[])
}
}
void wxStatusBarXX::SetFieldsWidth()
void wxStatusBarMac::SetFieldsWidth()
{
int *pWidths = new int[m_nFields];
@@ -140,12 +136,12 @@ void wxStatusBarXX::SetFieldsWidth()
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) );
@@ -153,7 +149,7 @@ wxString wxStatusBarXX::GetStatusText(int nField) const
return wxString("");
}
void wxStatusBarXX::OnSize(wxSizeEvent& event)
void wxStatusBarMac::OnSize(wxSizeEvent& event)
{
// adjust fields widths to the new size
SetFieldsWidth();

View File

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

View File

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

View File

@@ -1,9 +1,10 @@
#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

View File

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

View File

@@ -14,11 +14,15 @@
#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)
@@ -26,3 +30,12 @@ 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

View File

@@ -126,14 +126,18 @@ bool wxWave::Play(bool async, bool looped) const
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;

View File

@@ -15,6 +15,7 @@
#include "wx/setup.h"
#include "wx/menu.h"
#include "wx/window.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
#include "wx/utils.h"
@@ -33,9 +34,6 @@
#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"
@@ -763,6 +761,11 @@ void wxWindow::MacSuperShown( bool show )
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 )
@@ -771,6 +774,7 @@ bool wxWindow::MacIsReallyShown() const
status = win->m_isShown ;
}
return status ;
*/
}
int wxWindow::GetCharHeight() const
@@ -794,7 +798,7 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
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 )
@@ -2306,7 +2310,37 @@ long wxWindow::MacRemoveBordersFromStyle( long style )
{
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 )
{

Binary file not shown.

View File

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

View File

@@ -16,6 +16,7 @@
#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"

View File

@@ -21,7 +21,7 @@
#include "wx/cmndata.h"
#if defined(__UNIX__)
#include <NavigationServices/Navigation.h>
#include <Carbon/Carbon.h>
#else
#include <Navigation.h>
#endif
@@ -182,7 +182,7 @@ static Boolean SameFSSpec(FSSpecPtr spec1, FSSpecPtr spec2)
// 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)
@@ -210,7 +210,7 @@ static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRec
// 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;
@@ -422,7 +422,7 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
}
}
static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr)
static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
{
#pragma unused (dataPtr)

View File

@@ -39,20 +39,22 @@ wxDropTarget::~wxDropTarget()
// ----------------------------------------------------------------------------
// 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;
@@ -62,25 +64,27 @@ wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
{
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;
@@ -90,6 +94,7 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
{
return wxDF_FILENAME;
}
#endif
//-------------------------------------------------------------------------
// wxDropSource

View File

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

View File

@@ -19,11 +19,8 @@
#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
@@ -32,6 +29,7 @@
#define TRUE 1
#endif
#else
#define OTUNIXERRORS 1
#include <OpenTransport.h>
#include <OpenTransportProviders.h>
#include <OpenTptInternet.h>
@@ -123,7 +121,11 @@ OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode)
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
@@ -1043,8 +1045,8 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size)
{
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 )
@@ -1055,7 +1057,7 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size)
// 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 )
{
@@ -1365,7 +1367,7 @@ GSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, size_t
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;
}
@@ -1397,7 +1399,7 @@ void _GSocket_Enable_Events(GSocket *socket)
state = OTGetEndpointState(socket->m_endpoint);
{
size_t sz = 0 ;
OTByteCount sz = 0 ;
OTCountDataBytes( socket->m_endpoint , &sz ) ;
if ( state == T_INCON || sz > 0 )
{
@@ -1437,7 +1439,7 @@ GSocketError _GSocket_Input_Timeout(GSocket *socket)
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < socket->m_timeout * 1000.0 )
{
OTResult state ;
size_t sz = 0 ;
OTByteCount sz = 0 ;
state = OTGetEndpointState(socket->m_endpoint);
OTCountDataBytes( socket->m_endpoint , &sz ) ;

View File

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

Binary file not shown.

View File

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

View File

@@ -17,12 +17,13 @@
// 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()
@@ -31,20 +32,15 @@ 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);
@@ -57,7 +53,7 @@ bool wxStatusBarXX::Create(wxWindow *parent, wxWindowID id, long style)
return FALSE;
}
void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[])
void wxStatusBarMac::SetFieldsCount(int nFields, const int widths[])
{
wxASSERT( (nFields > 0) && (nFields < 255) );
@@ -67,7 +63,7 @@ void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[])
SetFieldsWidth();
}
void wxStatusBarXX::SetStatusWidths(int n, const int widths[])
void wxStatusBarMac::SetStatusWidths(int n, const int widths[])
{
wxASSERT( n == m_nFields );
@@ -75,7 +71,7 @@ void wxStatusBarXX::SetStatusWidths(int n, const int widths[])
SetFieldsWidth();
}
void wxStatusBarXX::CopyFieldsWidth(const int widths[])
void wxStatusBarMac::CopyFieldsWidth(const int widths[])
{
if (widths && !m_statusWidths)
m_statusWidths = new int[m_nFields];
@@ -90,7 +86,7 @@ void wxStatusBarXX::CopyFieldsWidth(const int widths[])
}
}
void wxStatusBarXX::SetFieldsWidth()
void wxStatusBarMac::SetFieldsWidth()
{
int *pWidths = new int[m_nFields];
@@ -140,12 +136,12 @@ void wxStatusBarXX::SetFieldsWidth()
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) );
@@ -153,7 +149,7 @@ wxString wxStatusBarXX::GetStatusText(int nField) const
return wxString("");
}
void wxStatusBarXX::OnSize(wxSizeEvent& event)
void wxStatusBarMac::OnSize(wxSizeEvent& event)
{
// adjust fields widths to the new size
SetFieldsWidth();

View File

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

View File

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

View File

@@ -1,9 +1,10 @@
#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

View File

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

View File

@@ -14,11 +14,15 @@
#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)
@@ -26,3 +30,12 @@ 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

View File

@@ -126,14 +126,18 @@ bool wxWave::Play(bool async, bool looped) const
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;

View File

@@ -15,6 +15,7 @@
#include "wx/setup.h"
#include "wx/menu.h"
#include "wx/window.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
#include "wx/utils.h"
@@ -33,9 +34,6 @@
#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"
@@ -763,6 +761,11 @@ void wxWindow::MacSuperShown( bool show )
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 )
@@ -771,6 +774,7 @@ bool wxWindow::MacIsReallyShown() const
status = win->m_isShown ;
}
return status ;
*/
}
int wxWindow::GetCharHeight() const
@@ -794,7 +798,7 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
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 )
@@ -2306,7 +2310,37 @@ long wxWindow::MacRemoveBordersFromStyle( long style )
{
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 )
{

View File

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

View File

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

View File

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