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

View File

@@ -1207,14 +1207,14 @@ void wxApp::MacDoOneEvent()
switch (status)
{
case eventLoopTimedOutErr :
case eventLoopTimedOutErr :
if ( wxTheApp->ProcessIdle() )
sleepTime = kEventDurationNoWait ;
else
sleepTime = kEventDurationSecond;
break;
case eventLoopQuitErr :
case eventLoopQuitErr :
// according to QA1061 this may also occur
// when a WakeUp Process is executed
break;

View File

@@ -115,17 +115,17 @@ wxSize wxButton::DoGetBestSize() const
switch (GetWindowVariant())
{
case wxWINDOW_VARIANT_NORMAL:
case wxWINDOW_VARIANT_LARGE:
case wxWINDOW_VARIANT_NORMAL:
case wxWINDOW_VARIANT_LARGE:
sz.y = 20 ;
charspace = 10 ;
break;
case wxWINDOW_VARIANT_SMALL:
case wxWINDOW_VARIANT_SMALL:
sz.y = 17 ;
break;
case wxWINDOW_VARIANT_MINI:
case wxWINDOW_VARIANT_MINI:
sz.y = 15 ;
break;

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
// Author: Stefan Csomor
// Modified by:
@@ -98,21 +98,21 @@ wxInt32 wxCheckBox::MacControlHit( WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENT
switch (origState)
{
case wxCHK_UNCHECKED:
case wxCHK_UNCHECKED:
newState = wxCHK_CHECKED;
break;
case wxCHK_CHECKED:
case wxCHK_CHECKED:
// If the style flag to allow the user setting the undetermined state is set,
// then set the state to undetermined; otherwise set state to unchecked.
newState = Is3rdStateAllowedForUser() ? wxCHK_UNDETERMINED : wxCHK_UNCHECKED;
break;
case wxCHK_UNDETERMINED:
case wxCHK_UNDETERMINED:
newState = wxCHK_UNCHECKED;
break;
default:
default:
break;
}

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff