cleanup - reformat

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36879 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2006-01-15 07:20:59 +00:00
parent 619996567a
commit f3078f075b
8 changed files with 1109 additions and 1103 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: checkbox.cpp // Name: src/mac/carbon/checkbox.cpp
// Purpose: wxCheckBox // Purpose: wxCheckBox
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: cursor.cpp // Name: src/mac/carbon/cursor.cpp
// Purpose: wxCursor class // Purpose: wxCursor class
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
@@ -19,14 +19,17 @@
#include "wx/mac/private.h" #include "wx/mac/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
{ {
DECLARE_NO_COPY_CLASS(wxCursorRefData) DECLARE_NO_COPY_CLASS(wxCursorRefData)
friend class WXDLLEXPORT wxBitmap; friend class WXDLLEXPORT wxBitmap;
friend class WXDLLEXPORT wxCursor; friend class WXDLLEXPORT wxCursor;
public: public:
wxCursorRefData(); wxCursorRefData();
~wxCursorRefData(); ~wxCursorRefData();
@@ -35,29 +38,29 @@ protected:
WXHCURSOR m_hCursor; WXHCURSOR m_hCursor;
bool m_disposeHandle; bool m_disposeHandle;
bool m_releaseHandle; bool m_releaseHandle;
bool m_isColorCursor ; bool m_isColorCursor;
long m_themeCursor ; long m_themeCursor;
}; };
#define M_CURSORDATA ((wxCursorRefData *)m_refData) #define M_CURSORDATA ((wxCursorRefData *)m_refData)
#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData) #define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
const short kwxCursorBullseye = 0 ; const short kwxCursorBullseye = 0;
const short kwxCursorBlank = 1 ; const short kwxCursorBlank = 1;
const short kwxCursorPencil = 2 ; const short kwxCursorPencil = 2;
const short kwxCursorMagnifier = 3 ; const short kwxCursorMagnifier = 3;
const short kwxCursorNoEntry = 4 ; const short kwxCursorNoEntry = 4;
const short kwxCursorPaintBrush = 5 ; const short kwxCursorPaintBrush = 5;
const short kwxCursorPointRight = 6 ; const short kwxCursorPointRight = 6;
const short kwxCursorPointLeft = 7 ; const short kwxCursorPointLeft = 7;
const short kwxCursorQuestionArrow = 8 ; const short kwxCursorQuestionArrow = 8;
const short kwxCursorRightArrow = 9 ; const short kwxCursorRightArrow = 9;
const short kwxCursorSizeNS = 10 ; const short kwxCursorSizeNS = 10;
const short kwxCursorSize = 11 ; const short kwxCursorSize = 11;
const short kwxCursorSizeNESW = 12 ; const short kwxCursorSizeNESW = 12;
const short kwxCursorSizeNWSE = 13 ; const short kwxCursorSizeNWSE = 13;
const short kwxCursorRoller = 14 ; const short kwxCursorRoller = 14;
const short kwxCursorLast = kwxCursorRoller ; const short kwxCursorLast = kwxCursorRoller;
Cursor gMacCursors[kwxCursorLast+1] = Cursor gMacCursors[kwxCursorLast+1] =
{ {
@@ -182,7 +185,7 @@ Cursor gMacCursors[kwxCursorLast+1] =
{0x000A, 0x0006} {0x000A, 0x0006}
}, },
} ; };
wxCursor gMacCurrentCursor ; wxCursor gMacCurrentCursor ;
@@ -190,7 +193,8 @@ CursHandle wxGetStockCursor( int number )
{ {
wxASSERT_MSG( number >= 0 && number <=kwxCursorLast , wxT("invalid stock cursor id") ) ; wxASSERT_MSG( number >= 0 && number <=kwxCursorLast , wxT("invalid stock cursor id") ) ;
CursHandle c = (CursHandle) NewHandle( sizeof(Cursor) ) ; CursHandle c = (CursHandle) NewHandle( sizeof(Cursor) ) ;
memcpy( *c , &gMacCursors[number] , sizeof( Cursor ) ) ; memcpy( *c, &gMacCursors[number], sizeof(Cursor) ) ;
return c ; return c ;
} }
@@ -198,11 +202,11 @@ wxCursorRefData::wxCursorRefData()
{ {
SetWidth( 16 ); SetWidth( 16 );
SetHeight( 16 ); SetHeight( 16 );
m_hCursor = NULL ; m_hCursor = NULL;
m_disposeHandle = false ; m_disposeHandle = false;
m_releaseHandle = false ; m_releaseHandle = false;
m_isColorCursor = false ; m_isColorCursor = false;
m_themeCursor = -1 ; m_themeCursor = -1;
} }
wxCursorRefData::~wxCursorRefData() wxCursorRefData::~wxCursorRefData()
@@ -222,7 +226,6 @@ wxCursorRefData::~wxCursorRefData()
} }
} }
// Cursors
wxCursor::wxCursor() wxCursor::wxCursor()
{ {
} }
@@ -252,14 +255,14 @@ wxCursor::wxCursor(char **bits)
bool wxCursor::CreateFromXpm(const char **bits) bool wxCursor::CreateFromXpm(const char **bits)
{ {
#if wxUSE_IMAGE #if wxUSE_IMAGE
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid cursor data") ) wxCHECK_MSG( bits != NULL, false, wxT("invalid cursor data") )
wxXPMDecoder decoder; wxXPMDecoder decoder;
wxImage img = decoder.ReadData(bits); wxImage img = decoder.ReadData(bits);
wxCHECK_MSG( img.Ok(), FALSE, wxT("invalid cursor data") ) wxCHECK_MSG( img.Ok(), false, wxT("invalid cursor data") )
CreateFromImage( img ) ; CreateFromImage( img ) ;
return TRUE; return true;
#else #else
return FALSE; return false;
#endif #endif
} }
@@ -277,17 +280,20 @@ short GetCTabIndex( CTabHandle colors , RGBColor *col )
{ {
short retval = 0 ; short retval = 0 ;
unsigned long bestdiff = 0xFFFF ; unsigned long bestdiff = 0xFFFF ;
for ( int i = 0 ; i < (**colors).ctSize ; ++i ) for ( int i = 0 ; i < (**colors).ctSize ; ++i )
{ {
unsigned long diff = abs(col->red - (**colors).ctTable[i].rgb.red ) + unsigned long diff = abs(col->red - (**colors).ctTable[i].rgb.red ) +
abs(col->green - (**colors).ctTable[i].rgb.green ) + abs(col->green - (**colors).ctTable[i].rgb.green ) +
abs(col->blue - (**colors).ctTable[i].rgb.blue ) ; abs(col->blue - (**colors).ctTable[i].rgb.blue ) ;
if ( diff < bestdiff ) if ( diff < bestdiff )
{ {
bestdiff = diff ; bestdiff = diff ;
retval = (**colors).ctTable[i].value ; retval = (**colors).ctTable[i].value ;
} }
} }
return retval ; return retval ;
} }
@@ -307,14 +313,14 @@ void wxCursor::CreateFromImage(const wxImage & image)
wxASSERT_MSG( hotSpotX >= 0 && hotSpotX < image_w && wxASSERT_MSG( hotSpotX >= 0 && hotSpotX < image_w &&
hotSpotY >= 0 && hotSpotY < image_h, hotSpotY >= 0 && hotSpotY < image_h,
_T("invalid cursor hot spot coordinates") ); wxT("invalid cursor hot spot coordinates") );
wxImage image16(image); // final image of correct size wxImage image16(image); // final image of correct size
// if image is too small then place it in the center, resize it if too big // if image is too small then place it in the center, resize it if too big
if ((w > image_w) && (h > image_h)) if ((w > image_w) && (h > image_h))
{ {
wxPoint offset((w - image_w)/2, (h - image_h)/2); wxPoint offset((w - image_w) / 2, (h - image_h) / 2);
hotSpotX = hotSpotX + offset.x; hotSpotX = hotSpotX + offset.x;
hotSpotY = hotSpotY + offset.y; hotSpotY = hotSpotY + offset.y;
@@ -331,24 +337,25 @@ void wxCursor::CreateFromImage(const wxImage & image)
unsigned char * rgbBits = image16.GetData(); unsigned char * rgbBits = image16.GetData();
bool bHasMask = image16.HasMask() ; bool bHasMask = image16.HasMask() ;
PixMapHandle pm = (PixMapHandle) NewHandleClear( sizeof(PixMap) ) ;
PixMapHandle pm = (PixMapHandle) NewHandleClear( sizeof (PixMap)) ;
short extent = 16 ; short extent = 16 ;
short bytesPerPixel = 1 ; short bytesPerPixel = 1 ;
short depth = 8 ; short depth = 8 ;
Rect bounds = { 0 , 0 , extent , extent } ; Rect bounds = { 0 , 0 , extent , extent } ;
CCrsrHandle ch = (CCrsrHandle) NewHandleClear ( sizeof( CCrsr ) ) ; CCrsrHandle ch = (CCrsrHandle) NewHandleClear( sizeof(CCrsr) ) ;
CTabHandle newColors = GetCTable( 8 ) ; CTabHandle newColors = GetCTable( 8 ) ;
HandToHand((Handle *) &newColors); HandToHand( (Handle *) &newColors );
// set the values to the indices // set the values to the indices
for ( int i = 0 ; i < (**newColors).ctSize ; ++i ) for ( int i = 0 ; i < (**newColors).ctSize ; ++i )
{ {
(**newColors).ctTable[i].value = i ; (**newColors).ctTable[i].value = i ;
} }
HLock( (Handle) ch) ;
(**ch).crsrType = 0x8001 ; // color cursors HLock( (Handle)ch );
(**ch).crsrMap = pm ; (**ch).crsrType = 0x8001; // color cursors
short bytesPerRow = bytesPerPixel * extent ; (**ch).crsrMap = pm;
short bytesPerRow = bytesPerPixel * extent;
(**pm).baseAddr = 0; (**pm).baseAddr = 0;
(**pm).rowBytes = bytesPerRow | 0x8000; (**pm).rowBytes = bytesPerRow | 0x8000;
@@ -356,8 +363,8 @@ void wxCursor::CreateFromImage(const wxImage & image)
(**pm).pmVersion = 0; (**pm).pmVersion = 0;
(**pm).packType = 0; (**pm).packType = 0;
(**pm).packSize = 0; (**pm).packSize = 0;
(**pm).hRes = 0x00480000; /* 72 DPI default res */ (**pm).hRes = 0x00480000; // 72 DPI default res
(**pm).vRes = 0x00480000; /* 72 DPI default res */ (**pm).vRes = 0x00480000; // 72 DPI default res
(**pm).pixelSize = depth; (**pm).pixelSize = depth;
(**pm).pixelType = 0; (**pm).pixelType = 0;
(**pm).cmpCount = 1; (**pm).cmpCount = 1;
@@ -380,46 +387,46 @@ void wxCursor::CreateFromImage(const wxImage & image)
unsigned char mr = image16.GetMaskRed() ; unsigned char mr = image16.GetMaskRed() ;
unsigned char mg = image16.GetMaskGreen() ; unsigned char mg = image16.GetMaskGreen() ;
unsigned char mb = image16.GetMaskBlue() ; unsigned char mb = image16.GetMaskBlue() ;
for ( int y = 0 ; y < h ; ++y ) for ( int y = 0 ; y < h ; ++y )
{ {
short rowbits = 0 ; short rowbits = 0, maskbits = 0 ;
short maskbits = 0 ;
for ( int x = 0 ; x < w ; ++x ) for ( int x = 0 ; x < w ; ++x )
{ {
long pos = (y * w + x) * 3; long pos = (y * w + x) * 3;
unsigned char r = rgbBits[pos] ; unsigned char r = rgbBits[pos] ;
unsigned char g = rgbBits[pos+1] ; unsigned char g = rgbBits[pos + 1] ;
unsigned char b = rgbBits[pos+2] ; unsigned char b = rgbBits[pos + 2] ;
RGBColor col = { 0xFFFF ,0xFFFF, 0xFFFF } ; RGBColor col = { 0xFFFF, 0xFFFF, 0xFFFF } ;
if ( bHasMask && r==mr && g==mg && b==mb ) if ( bHasMask && r == mr && g == mg && b == mb )
{ {
// masked area, does not appear anywhere // masked area, does not appear anywhere
} }
else else
{ {
if ( (int)r + (int)g + (int)b < 0x0200 ) if ( (int)r + (int)g + (int)b < 0x0200 )
{ rowbits |= ( 1 << (15 - x) ) ;
rowbits |= ( 1 << (15-x) ) ;
} maskbits |= ( 1 << (15 - x) ) ;
maskbits |= ( 1 << (15-x) ) ;
col = *((RGBColor*) wxColor( r , g , b ).GetPixel()) ; col = *((RGBColor*) wxColor( r , g , b ).GetPixel()) ;
} }
*((*(**ch).crsrData) + y * bytesPerRow + x) = *((*(**ch).crsrData) + y * bytesPerRow + x) =
GetCTabIndex( newColors , &col) ; GetCTabIndex( newColors , &col) ;
} }
(**ch).crsr1Data[y] = rowbits ; (**ch).crsr1Data[y] = rowbits ;
(**ch).crsrMask[y] = maskbits ; (**ch).crsrMask[y] = maskbits ;
} }
if ( !bHasMask )
{
memcpy( (**ch).crsrMask , (**ch).crsr1Data , sizeof( Bits16) ) ;
}
HUnlock((Handle) ch) ; if ( !bHasMask )
memcpy( (**ch).crsrMask , (**ch).crsr1Data , sizeof( Bits16) ) ;
HUnlock( (Handle)ch ) ;
M_CURSORDATA->m_hCursor = ch ; M_CURSORDATA->m_hCursor = ch ;
M_CURSORDATA->m_isColorCursor = true ; M_CURSORDATA->m_isColorCursor = true ;
} }
@@ -439,8 +446,10 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho
{ {
short theId = -1 ; short theId = -1 ;
OSType theType ; OSType theType ;
GetResInfo( resHandle , &theId , &theType , theName ) ; GetResInfo( resHandle , &theId , &theType , theName ) ;
ReleaseResource( resHandle ) ; ReleaseResource( resHandle ) ;
M_CURSORDATA->m_hCursor = GetCCursor( theId ) ; M_CURSORDATA->m_hCursor = GetCCursor( theId ) ;
if ( M_CURSORDATA->m_hCursor ) if ( M_CURSORDATA->m_hCursor )
M_CURSORDATA->m_isColorCursor = true ; M_CURSORDATA->m_isColorCursor = true ;
@@ -452,8 +461,10 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho
{ {
short theId = -1 ; short theId = -1 ;
OSType theType ; OSType theType ;
GetResInfo( resHandle , &theId , &theType , theName ) ; GetResInfo( resHandle , &theId , &theType , theName ) ;
ReleaseResource( resHandle ) ; ReleaseResource( resHandle ) ;
M_CURSORDATA->m_hCursor = GetCursor( theId ) ; M_CURSORDATA->m_hCursor = GetCursor( theId ) ;
if ( M_CURSORDATA->m_hCursor ) if ( M_CURSORDATA->m_hCursor )
M_CURSORDATA->m_releaseHandle = true ; M_CURSORDATA->m_releaseHandle = true ;
@@ -464,13 +475,13 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho
{ {
#if wxUSE_IMAGE #if wxUSE_IMAGE
wxImage image ; wxImage image ;
image.LoadFile( cursor_file , flags ) ; image.LoadFile( cursor_file, flags ) ;
if( image.Ok() ) if ( image.Ok() )
{ {
image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X,hotSpotX ) ; image.SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_X, hotSpotX ) ;
image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y,hotSpotY ) ; image.SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotSpotY ) ;
delete m_refData ; delete m_refData ;
CreateFromImage(image) ; CreateFromImage( image ) ;
} }
#endif #endif
} }
@@ -484,118 +495,105 @@ wxCursor::wxCursor(int cursor_type)
switch (cursor_type) switch (cursor_type)
{ {
case wxCURSOR_COPY_ARROW: case wxCURSOR_COPY_ARROW:
M_CURSORDATA->m_themeCursor = kThemeCopyArrowCursor ; M_CURSORDATA->m_themeCursor = kThemeCopyArrowCursor;
break; break;
case wxCURSOR_WAIT: case wxCURSOR_WAIT:
M_CURSORDATA->m_themeCursor = kThemeWatchCursor ; M_CURSORDATA->m_themeCursor = kThemeWatchCursor;
break; break;
case wxCURSOR_IBEAM: case wxCURSOR_IBEAM:
M_CURSORDATA->m_themeCursor = kThemeIBeamCursor ; M_CURSORDATA->m_themeCursor = kThemeIBeamCursor;
break; break;
case wxCURSOR_CROSS: case wxCURSOR_CROSS:
M_CURSORDATA->m_themeCursor = kThemeCrossCursor; M_CURSORDATA->m_themeCursor = kThemeCrossCursor;
break; break;
case wxCURSOR_SIZENWSE: case wxCURSOR_SIZENWSE:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNWSE); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNWSE);
}
break; break;
case wxCURSOR_SIZENESW: case wxCURSOR_SIZENESW:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNESW); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNESW);
}
break; break;
case wxCURSOR_SIZEWE: case wxCURSOR_SIZEWE:
{
M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor; M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor;
}
break; break;
case wxCURSOR_SIZENS: case wxCURSOR_SIZENS:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNS); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNS);
}
break; break;
case wxCURSOR_SIZING: case wxCURSOR_SIZING:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSize); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSize);
}
break; break;
case wxCURSOR_HAND: case wxCURSOR_HAND:
{
M_CURSORDATA->m_themeCursor = kThemePointingHandCursor; M_CURSORDATA->m_themeCursor = kThemePointingHandCursor;
}
break; break;
case wxCURSOR_BULLSEYE: case wxCURSOR_BULLSEYE:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorBullseye); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorBullseye);
}
break; break;
case wxCURSOR_PENCIL: case wxCURSOR_PENCIL:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPencil); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPencil);
}
break; break;
case wxCURSOR_MAGNIFIER: case wxCURSOR_MAGNIFIER:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorMagnifier); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorMagnifier);
}
break; break;
case wxCURSOR_NO_ENTRY: case wxCURSOR_NO_ENTRY:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorNoEntry); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorNoEntry);
}
break; break;
case wxCURSOR_WATCH: case wxCURSOR_WATCH:
{
M_CURSORDATA->m_themeCursor = kThemeWatchCursor; M_CURSORDATA->m_themeCursor = kThemeWatchCursor;
break; break;
}
case wxCURSOR_PAINT_BRUSH: case wxCURSOR_PAINT_BRUSH:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPaintBrush); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPaintBrush);
break; break;
}
case wxCURSOR_POINT_LEFT: case wxCURSOR_POINT_LEFT:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPointLeft); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPointLeft);
break; break;
}
case wxCURSOR_POINT_RIGHT: case wxCURSOR_POINT_RIGHT:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPointRight); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPointRight);
break; break;
}
case wxCURSOR_QUESTION_ARROW: case wxCURSOR_QUESTION_ARROW:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorQuestionArrow); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorQuestionArrow);
break; break;
}
case wxCURSOR_BLANK: case wxCURSOR_BLANK:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorBlank); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorBlank);
break; break;
}
case wxCURSOR_RIGHT_ARROW: case wxCURSOR_RIGHT_ARROW:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRightArrow); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRightArrow);
break; break;
}
case wxCURSOR_SPRAYCAN: case wxCURSOR_SPRAYCAN:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRoller); M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRoller);
break; break;
}
case wxCURSOR_CHAR: case wxCURSOR_CHAR:
case wxCURSOR_ARROW: case wxCURSOR_ARROW:
case wxCURSOR_LEFT_BUTTON: case wxCURSOR_LEFT_BUTTON:
case wxCURSOR_RIGHT_BUTTON: case wxCURSOR_RIGHT_BUTTON:
case wxCURSOR_MIDDLE_BUTTON: case wxCURSOR_MIDDLE_BUTTON:
default: default:
M_CURSORDATA->m_themeCursor = kThemeArrowCursor ; M_CURSORDATA->m_themeCursor = kThemeArrowCursor;
break; break;
} }
if ( M_CURSORDATA->m_themeCursor == -1 ) if ( M_CURSORDATA->m_themeCursor == -1 )
M_CURSORDATA->m_releaseHandle = true ; M_CURSORDATA->m_releaseHandle = true;
} }
void wxCursor::MacInstall() const void wxCursor::MacInstall() const
@@ -627,5 +625,3 @@ void wxSetCursor(const wxCursor& cursor)
{ {
cursor.MacInstall() ; cursor.MacInstall() ;
} }

View File

@@ -19,23 +19,18 @@
#include "wx/tokenzr.h" #include "wx/tokenzr.h"
#include "wx/filename.h" #include "wx/filename.h"
#ifndef __DARWIN__
#include "PLStringFuncs.h"
#endif
IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
// begin wxmac
#include "wx/mac/private.h" #include "wx/mac/private.h"
#ifndef __DARWIN__ #ifndef __DARWIN__
#include <Navigation.h> #include <Navigation.h>
#include "PLStringFuncs.h"
#endif #endif
#include "MoreFilesX.h" #include "MoreFilesX.h"
extern bool gUseNavServices ; IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
extern bool gUseNavServices;
// the data we need to pass to our standard file hook routine // the data we need to pass to our standard file hook routine
// includes a pointer to the dialog, a pointer to the standard // includes a pointer to the dialog, a pointer to the standard
@@ -43,7 +38,8 @@ extern bool gUseNavServices ;
// and a copy of the "previous" file spec of the reply record // and a copy of the "previous" file spec of the reply record
// so we can see if the selection has changed // so we can see if the selection has changed
struct OpenUserDataRec { struct OpenUserDataRec
{
int currentfilter ; int currentfilter ;
bool saveMode ; bool saveMode ;
wxArrayString name ; wxArrayString name ;
@@ -59,18 +55,18 @@ OpenUserDataRec, *OpenUserDataRecPtr;
static pascal void NavEventProc( static pascal void NavEventProc(
NavEventCallbackMessage inSelector, NavEventCallbackMessage inSelector,
NavCBRecPtr ioParams, NavCBRecPtr ioParams,
NavCallBackUserData ioUserData); NavCallBackUserData ioUserData );
static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc); static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc);
static pascal void static pascal void NavEventProc(
NavEventProc(
NavEventCallbackMessage inSelector, NavEventCallbackMessage inSelector,
NavCBRecPtr ioParams, NavCBRecPtr ioParams,
NavCallBackUserData ioUserData ) NavCallBackUserData ioUserData )
{ {
OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ; OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ;
if (inSelector == kNavCBEvent) { if (inSelector == kNavCBEvent)
{
} }
else if ( inSelector == kNavCBStart ) else if ( inSelector == kNavCBStart )
{ {
@@ -80,7 +76,7 @@ NavEventProc(
// Apple Technical Q&A 1151 // Apple Technical Q&A 1151
FSSpec theFSSpec; FSSpec theFSSpec;
wxMacFilename2FSSpec(data->defaultLocation, &theFSSpec); wxMacFilename2FSSpec(data->defaultLocation, &theFSSpec);
AEDesc theLocation = {typeNull, NULL}; AEDesc theLocation = { typeNull, NULL };
if (noErr == ::AECreateDesc(typeFSS, &theFSSpec, sizeof(FSSpec), &theLocation)) if (noErr == ::AECreateDesc(typeFSS, &theFSSpec, sizeof(FSSpec), &theLocation))
::NavCustomControl(ioParams->context, kNavCtlSetLocation, (void *) &theLocation); ::NavCustomControl(ioParams->context, kNavCtlSetLocation, (void *) &theLocation);
} }
@@ -122,7 +118,6 @@ NavEventProc(
} }
} }
void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
{ {
myData->menuitems = NULL ; myData->menuitems = NULL ;
@@ -135,17 +130,21 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
int filterIndex = 0; int filterIndex = 0;
bool isName = true ; bool isName = true ;
wxString current ; wxString current ;
for( unsigned int i = 0; i < filter2.Len() ; i++ )
for ( unsigned int i = 0; i < filter2.Len() ; i++ )
{ {
if( filter2.GetChar(i) == wxT('|') ) if ( filter2.GetChar(i) == wxT('|') )
{
if ( isName )
{ {
if( isName ) {
myData->name.Add( current ) ; myData->name.Add( current ) ;
} }
else { else
{
myData->extensions.Add( current.MakeUpper() ) ; myData->extensions.Add( current.MakeUpper() ) ;
++filterIndex ; ++filterIndex ;
} }
isName = !isName ; isName = !isName ;
current = wxEmptyString ; current = wxEmptyString ;
} }
@@ -170,26 +169,21 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
const size_t extCount = myData->extensions.GetCount(); const size_t extCount = myData->extensions.GetCount();
for ( size_t i = 0 ; i < extCount; i++ ) for ( size_t i = 0 ; i < extCount; i++ )
{ {
wxUint32 fileType; wxUint32 fileType, creator;
wxUint32 creator;
wxString extension = myData->extensions[i]; wxString extension = myData->extensions[i];
// Remove leading '*'
if (extension.GetChar(0) == '*') if (extension.GetChar(0) == '*')
extension = extension.Mid(1); // Remove leading * extension = extension.Mid( 1 );
// Remove leading '.'
if (extension.GetChar(0) == '.') if (extension.GetChar(0) == '.')
{ extension = extension.Mid( 1 );
extension = extension.Mid(1); // Remove leading .
}
if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator )) if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator ))
{
myData->filtermactypes.Add( (OSType)fileType ); myData->filtermactypes.Add( (OSType)fileType );
}
else else
{ myData->filtermactypes.Add( '****' ); // We'll fail safe if it's not recognized
myData->filtermactypes.Add( '****' ) ; // We'll fail safe if it's not recognized
}
} }
} }
} }
@@ -211,7 +205,7 @@ static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataR
return true ; return true ;
wxStringTokenizer tokenizer( data->extensions[i] , wxT(";") ) ; wxStringTokenizer tokenizer( data->extensions[i] , wxT(";") ) ;
while( tokenizer.HasMoreTokens() ) while ( tokenizer.HasMoreTokens() )
{ {
wxString extension = tokenizer.GetNextToken() ; wxString extension = tokenizer.GetNextToken() ;
if ( extension.GetChar(0) == '*' ) if ( extension.GetChar(0) == '*' )
@@ -221,8 +215,10 @@ static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataR
return true ; return true ;
} }
} }
return false ; return false ;
} }
return true ; return true ;
} }
@@ -256,20 +252,20 @@ static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dat
// end wxmac // end wxmac
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, wxFileDialog::wxFileDialog(
wxWindow *parent, const wxString& message,
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard, const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
long style, const wxPoint& pos) long style, const wxPoint& pos)
:wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos) : wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos)
{ {
wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ; wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
} }
pascal Boolean CrossPlatformFilterCallback ( pascal Boolean CrossPlatformFilterCallback(
AEDesc *theItem, AEDesc *theItem,
void *info, void *info,
void *callBackUD, void *callBackUD,
NavFilterModes filterMode NavFilterModes filterMode )
)
{ {
bool display = true; bool display = true;
OpenUserDataRecPtr data = (OpenUserDataRecPtr) callBackUD ; OpenUserDataRecPtr data = (OpenUserDataRecPtr) callBackUD ;
@@ -279,7 +275,7 @@ pascal Boolean CrossPlatformFilterCallback (
NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ; NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ;
if ( !theInfo->isFolder ) if ( !theInfo->isFolder )
{ {
if (theItem->descriptorType == typeFSS ) if (theItem->descriptorType == typeFSS)
{ {
FSSpec spec; FSSpec spec;
memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ; memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
@@ -303,6 +299,7 @@ int wxFileDialog::ShowModal()
{ {
OSErr err; OSErr err;
NavDialogCreationOptions dialogCreateOptions; NavDialogCreationOptions dialogCreateOptions;
// set default options // set default options
::NavGetDefaultDialogCreationOptions(&dialogCreateOptions); ::NavGetDefaultDialogCreationOptions(&dialogCreateOptions);
@@ -341,12 +338,10 @@ int wxFileDialog::ShowModal()
{ {
myData.saveMode = true; myData.saveMode = true;
if (!numFilters)
{
dialogCreateOptions.optionFlags |= kNavNoTypePopup;
}
dialogCreateOptions.optionFlags |= kNavDontAutoTranslate; dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems; dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
if (!numFilters)
dialogCreateOptions.optionFlags |= kNavNoTypePopup;
// The extension is important // The extension is important
if (numFilters < 2) if (numFilters < 2)
@@ -354,31 +349,31 @@ int wxFileDialog::ShowModal()
#if TARGET_API_MAC_OSX #if TARGET_API_MAC_OSX
if (!(m_dialogStyle & wxOVERWRITE_PROMPT)) if (!(m_dialogStyle & wxOVERWRITE_PROMPT))
{
dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement; dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement;
}
#endif #endif
err = ::NavCreatePutFileDialog(&dialogCreateOptions,
// Suppresses the 'Default' (top) menu item err = ::NavCreatePutFileDialog(
kNavGenericSignature, kNavGenericSignature, &dialogCreateOptions,
kNavGenericSignature, // Suppresses the 'Default' (top) menu item
kNavGenericSignature,
sStandardNavEventFilter, sStandardNavEventFilter,
&myData, // for defaultLocation &myData, // for defaultLocation
&dialog); &dialog );
} }
else else
{ {
// let the user select bundles/programs in dialogs
//let people select bundles/programs in dialogs
dialogCreateOptions.optionFlags |= kNavSupportPackages; dialogCreateOptions.optionFlags |= kNavSupportPackages;
navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback); navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
err = ::NavCreateGetFileDialog(&dialogCreateOptions, err = ::NavCreateGetFileDialog(
&dialogCreateOptions,
NULL, // NavTypeListHandle NULL, // NavTypeListHandle
sStandardNavEventFilter, sStandardNavEventFilter,
NULL, // NavPreviewUPP NULL, // NavPreviewUPP
navFilterUPP, navFilterUPP,
(void *) &myData, // inClientData (void *) &myData, // inClientData
&dialog); &dialog );
} }
if (err == noErr) if (err == noErr)
@@ -402,38 +397,41 @@ int wxFileDialog::ShowModal()
Size actualSize; Size actualSize;
FSRef theFSRef; FSRef theFSRef;
wxString thePath ; wxString thePath ;
m_filterIndex = myData.currentfilter ;
long count; long count;
::AECountItems(&navReply.selection , &count);
m_filterIndex = myData.currentfilter;
::AECountItems( &navReply.selection, &count );
for (long i = 1; i <= count; ++i) for (long i = 1; i <= count; ++i)
{ {
err = ::AEGetNthPtr(&(navReply.selection), i, typeFSRef, &theKeyword, &actualType, err = ::AEGetNthPtr(
&theFSRef, sizeof(theFSRef), &actualSize); &(navReply.selection), i, typeFSRef, &theKeyword, &actualType,
&theFSRef, sizeof(theFSRef), &actualSize );
if (err != noErr) if (err != noErr)
break; break;
if (m_dialogStyle & wxSAVE) if (m_dialogStyle & wxSAVE)
thePath = wxMacFSRefToPath( &theFSRef , navReply.saveFileName ) ; thePath = wxMacFSRefToPath( &theFSRef, navReply.saveFileName );
else else
thePath = wxMacFSRefToPath( &theFSRef ) ; thePath = wxMacFSRefToPath( &theFSRef );
if (!thePath) if (!thePath)
{ {
::NavDisposeReply(&navReply); ::NavDisposeReply(&navReply);
return wxID_CANCEL; return wxID_CANCEL;
} }
m_path = thePath; m_path = thePath;
m_paths.Add(m_path); m_paths.Add(m_path);
m_fileName = wxFileNameFromPath(m_path); m_fileName = wxFileNameFromPath(m_path);
m_fileNames.Add(m_fileName); m_fileNames.Add(m_fileName);
} }
// set these to the first hit // set these to the first hit
m_path = m_paths[0]; m_path = m_paths[0];
m_fileName = wxFileNameFromPath(m_path); m_fileName = wxFileNameFromPath(m_path);
m_dir = wxPathOnly(m_path); m_dir = wxPathOnly(m_path);
} }
::NavDisposeReply(&navReply); ::NavDisposeReply(&navReply);
return (err == noErr) ? wxID_OK : wxID_CANCEL; return (err == noErr) ? wxID_OK : wxID_CANCEL;

View File

@@ -9,15 +9,6 @@
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__ #ifdef __BORLANDC__
@@ -28,32 +19,24 @@
#include "wx/string.h" #include "wx/string.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/intl.h" #include "wx/intl.h"
#endif //WX_PRECOMP #endif
#include "wx/fontutil.h" #include "wx/fontutil.h"
#include "wx/fontmap.h" #include "wx/fontmap.h"
#include "wx/encinfo.h" #include "wx/encinfo.h"
#include "wx/tokenzr.h" #include "wx/tokenzr.h"
// ============================================================================
// implementation
// ============================================================================
// ---------------------------------------------------------------------------- // convert to/from the string representation:
// wxNativeEncodingInfo // format is facename[;charset]
// ---------------------------------------------------------------------------- //
bool wxNativeEncodingInfo::FromString( const wxString& s )
// convert to/from the string representation: format is
// facename[;charset]
bool wxNativeEncodingInfo::FromString(const wxString& s)
{ {
wxStringTokenizer tokenizer(s, _T(";")); wxStringTokenizer tokenizer(s, wxT(";"));
facename = tokenizer.GetNextToken(); facename = tokenizer.GetNextToken();
if ( !facename ) if ( !facename )
return FALSE; return false;
wxString tmp = tokenizer.GetNextToken(); wxString tmp = tokenizer.GetNextToken();
if ( !tmp ) if ( !tmp )
@@ -64,23 +47,19 @@ bool wxNativeEncodingInfo::FromString(const wxString& s)
} }
else else
{ {
if ( wxSscanf(tmp, _T("%u"), &charset) != 1 ) if ( wxSscanf( tmp, wxT("%u"), &charset ) != 1 )
{
// should be a number! // should be a number!
return FALSE; return false;
}
} }
return TRUE; return true;
} }
wxString wxNativeEncodingInfo::ToString() const wxString wxNativeEncodingInfo::ToString() const
{ {
wxString s(facename); wxString s(facename);
if ( charset != 0 ) if ( charset != 0 )
{ s << wxT(';') << charset;
s << _T(';') << charset;
}
return s; return s;
} }
@@ -89,25 +68,20 @@ wxString wxNativeEncodingInfo::ToString() const
// helper functions // helper functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxGetNativeFontEncoding(wxFontEncoding encoding, bool wxGetNativeFontEncoding( wxFontEncoding encoding, wxNativeEncodingInfo *info )
wxNativeEncodingInfo *info)
{ {
wxCHECK_MSG( info, FALSE, _T("bad pointer in wxGetNativeFontEncoding") ); wxCHECK_MSG( info, false, wxT("bad pointer in wxGetNativeFontEncoding") );
if ( encoding == wxFONTENCODING_DEFAULT ) if ( encoding == wxFONTENCODING_DEFAULT )
{
encoding = wxFont::GetDefaultEncoding(); encoding = wxFont::GetDefaultEncoding();
}
info->encoding = encoding ; info->encoding = encoding;
return TRUE; return true;
} }
bool wxTestFontEncoding(const wxNativeEncodingInfo& info) bool wxTestFontEncoding( const wxNativeEncodingInfo& info )
{ {
// basically we should be able to support every encoding via the OS // basically we should be able to support every encoding via the OS
return true ; return true;
} }

File diff suppressed because it is too large Load Diff