CW Win32 and Mac adaptions

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1680 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 1999-02-11 16:56:43 +00:00
parent 5664fc3253
commit 8be97d65a6
13 changed files with 394 additions and 611 deletions

View File

@ -49,6 +49,8 @@
#endif // Sun CC
#endif
#endif // Sun
#elif defined(applec) || defined(THINK_C) || ( defined( __MWERKS__ ) && !defined(__INTEL__) )
// MacOS
#else // Windows
#ifndef __WINDOWS__
#define __WINDOWS__

View File

@ -29,12 +29,14 @@
typedef long off_t;
#endif
#if defined(__VISUALC__) || defined(__MWERKS__)
#if defined(__VISUALC__) || ( defined(__MWERKS__) && defined( __INTEL__) )
typedef _off_t off_t;
#elif defined(__BORLANDC__) && defined(__WIN16__)
typedef long off_t;
#elif defined(__SC__)
typedef long off_t;
#elif defined(__MWERKS__) && !defined(__INTEL__)
typedef long off_t;
#endif
const off_t wxInvalidOffset = (off_t)-1;

View File

@ -141,6 +141,27 @@ public:
protected:
bool m_keepGoing ;
// mac specifics
public :
void MacDoOneEvent() ;
void MacHandleOneEvent( EventRecord *ev ) ;
void MacHandleNullEvent( EventRecord *ev ) ;
void MacHandleHighLevelEvent( EventRecord *ev ) ;
void MacHandleMouseDownEvent( EventRecord *ev ) ;
void MacHandleMouseUpEvent( EventRecord *ev ) ;
void MacHandleKeyDownEvent( EventRecord *ev ) ;
void MacHandleKeyUpEvent( EventRecord *ev ) ;
void MacHandleAutoKeyEvent( EventRecord *ev ) ;
void MacHandleActivateEvent( EventRecord *ev ) ;
void MacHandleUpdateEvent( EventRecord *ev ) ;
void MacHandleDiskEvent( EventRecord *ev ) ;
void MacHandleOSEvent( EventRecord *ev ) ;
DECLARE_EVENT_TABLE()
};

View File

@ -67,7 +67,6 @@ public:
#define wxHIDE_READONLY 0x0008
#define wxFILE_MUST_EXIST 0x0010
/*
// File selector - backward compatibility
WXDLLEXPORT wxString wxFileSelector(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL,
const char *default_filename = NULL, const char *default_extension = NULL,
@ -86,7 +85,5 @@ WXDLLEXPORT wxString wxLoadFileSelector(const char *what, const char *extension,
// Generic file save dialog
WXDLLEXPORT wxString wxSaveFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL);
*/
#endif
// _WX_FILEDLG_H_

View File

@ -32,42 +32,42 @@
#define wxUSE_AUTOTRANS 0
// Define wxTString
#define wxUSE_POSTSCRIPT 1
#define wxUSE_POSTSCRIPT 0
// 0 for no PostScript device context
#define wxUSE_AFM_FOR_POSTSCRIPT 0
// 1 to use font metric files in GetTextExtent
#define wxUSE_METAFILE 1
#define wxUSE_METAFILE 0
// 0 for no Metafile and metafile device context
#define wxUSE_FORM 0
// 0 for no wxForm
#define wxUSE_IPC 1
#define wxUSE_IPC 0
// 0 for no interprocess comms
#define wxUSE_HELP 1
#define wxUSE_HELP 0
// 0 for no help facility
#define wxUSE_RESOURCES 1
#define wxUSE_RESOURCES 0
// 0 for no wxGetResource/wxWriteResource
#define wxUSE_CLIPBOARD 1
#define wxUSE_CLIPBOARD 0
// 0 for no clipboard functions
#define wxUSE_SPLINES 1
#define wxUSE_SPLINES 0
// 0 for no splines
#define wxUSE_XFIG_SPLINE_CODE 1
#define wxUSE_XFIG_SPLINE_CODE 0
// 1 for XFIG spline code, 0 for AIAI spline code.
// AIAI spline code is slower, but freer of copyright issues.
// 0 for no splines
#define wxUSE_TOOLBAR 1
#define wxUSE_TOOLBAR 0
// Use toolbars
#define wxUSE_DRAG_AND_DROP 1
#define wxUSE_DRAG_AND_DROP 0
// 0 for no drag and drop
#define wxUSE_WX_RESOURCES 1
#define wxUSE_WX_RESOURCES 0
// Use .wxr resource mechanism (requires PrologIO library)
#define wxUSE_DOC_VIEW_ARCHITECTURE 1
// Set to 0 to disable document/view architecture
#define wxUSE_PRINTING_ARCHITECTURE 1
#define wxUSE_PRINTING_ARCHITECTURE 0
// Set to 0 to disable print/preview architecture code
#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 1
#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 0
// Set to 0 to disable PostScript print/preview architecture code
// under Windows (just use Windows printing).
#define wxUSE_DYNAMIC_CLASSES 1
@ -111,7 +111,7 @@
// but you can't mix them. Set to 1 for <iostream.h>,
// 0 for <iostream>
#define wxUSE_WXCONFIG 1
#define wxUSE_WXCONFIG 0
// if enabled, compiles built-in OS independent wxConfig
// class and it's file (any platform) and registry (Win)
// based implementations

View File

@ -189,26 +189,49 @@ public:
// Get overall window size
virtual void GetSize(int *width, int *height) const;
wxSize GetSize() const { int w, h; GetSize(& w, & h); return wxSize(w, h); }
// Get window position, relative to parent (or screen if no parent)
virtual void GetPosition(int *x, int *y) const;
wxPoint GetPosition() const
{ int x, y; GetPosition(&x, &y); return wxPoint(x, y); }
// Get size and position
wxRect GetRect() const
{ int x, y, w, h; GetPosition(& x, & y); GetSize(& w, & h); return wxRect(x, y, w, h); }
// Get client (application-useable) size
virtual void GetClientSize(int *width, int *height) const;
wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); }
// Set overall size and position
virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
inline virtual void SetSize(int width, int height) { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); }
inline virtual void Move(int x, int y) { SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING); }
void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
{ SetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); }
// set size only
void SetSize(int width, int height)
{ SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); }
void SetSize(const wxSize& size)
{ SetSize(-1, -1, size.x, size.y, wxSIZE_USE_EXISTING); }
// set position only
virtual void Move(int x, int y) { SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING); }
void Move(const wxPoint& pt) { SetSize(pt.x, pt.y, -1, -1, wxSIZE_USE_EXISTING); }
// Set client size
virtual void SetClientSize(int width, int size);
virtual void SetClientSize(int width, int height);
void SetClientSize(const wxSize& sz) { SetClientSize(sz.x, sz.y); }
// Convert client to screen coordinates
virtual void ClientToScreen(int *x, int *y) const;
wxPoint ClientToScreen(const wxPoint& pt) const
{ int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); }
// Convert screen to client coordinates
virtual void ScreenToClient(int *x, int *y) const;
wxPoint ScreenToClient(const wxPoint& pt) const
{ int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); }
// Set the focus to this window
virtual void SetFocus();

View File

@ -79,7 +79,7 @@ inline size_t WXDLLEXPORT Strlen(const char *psz)
// portable strcasecmp/_stricmp
inline int WXDLLEXPORT Stricmp(const char *psz1, const char *psz2)
{
#if defined(__VISUALC__) || defined(__MWERKS__)
#if defined(__VISUALC__) || ( defined(__MWERKS__) && defined(__INTEL__) )
return _stricmp(psz1, psz2);
#elif defined(__SC__)
return _stricmp(psz1, psz2);
@ -91,7 +91,7 @@ inline int WXDLLEXPORT Stricmp(const char *psz1, const char *psz2)
return stricmp(psz1, psz2);
#elif defined(__UNIX__) || defined(__GNUWIN32__)
return strcasecmp(psz1, psz2);
#elif defined(__MWERKS__) && !defined(_MSC_VER)
#elif defined(__MWERKS__) && !defined(__INTEL__)
register char c1, c2;
do {
c1 = tolower(*psz1++);

View File

@ -35,6 +35,10 @@
#include <string.h>
// mac
#include "apprsrc.h"
extern char *wxBuffer;
extern wxList wxPendingDelete;
@ -47,41 +51,116 @@ BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
END_EVENT_TABLE()
#endif
// platform layer
typedef void * PLEventHandle ;
int PLTestMinimalRequirements() ;
void PLErrorMessage( int errorCode ) ;
int PLStartupPhase1() ;
int PLStartupPhase2() ;
void PLCleanup() ;
bool PLDoOneEvent() ;
bool PLHandleOneEvent( PLEventHandle event ) ; // true if really event
bool PLCallbackIdle() ;
bool PLCallbackRepeat() ;
long wxApp::sm_lastMessageTime = 0;
const short kMacMinHeap = (29 * 1024) ;
// platform specific static variables
bool gMacHasAppearance = false ;
long gMacAppearanceVersion = 0 ;
RgnHandle gMacCursorRgn = NULL ;
bool wxApp::Initialize()
{
int error = 0 ;
error = PLStartupPhase1() ;
if ( !error )
{
error = PLTestMinimalRequirements() ;
if ( !error )
error = PLStartupPhase2() ;
}
// Mac-specific
long total,contig;
// init all managers
::InitGraf(&qd.thePort);
::InitFonts();
::InitWindows();
::InitMenus();
::TEInit();
::InitDialogs(0L);
::InitCursor();
CursHandle aCursHandle = ::GetCursor(watchCursor); // Watch should be in system
if (aCursHandle)
::SetCursor(*aCursHandle);
::FlushEvents(everyEvent, 0);
// setup memory of application
::MaxApplZone();
for (long i = 1; i <= 4; i++)
::MoreMasters();
PurgeSpace(&total, &contig);
::SetCursor( &qd.arrow ) ;
#if 0
InitAEHandlers();
InitializeAECore() ;
GUSISetup(GUSIwithInternetSockets);
#endif
// test the minimal configuration necessary
long theSystem ;
long theMachine;
long theAppearance ;
if (Gestalt(gestaltMachineType, &theMachine) != noErr)
{
error = kMacSTRWrongMachine;
}
else if (theMachine < gestaltMacPlus)
{
error = kMacSTRWrongMachine;
}
else if (Gestalt(gestaltSystemVersion, &theSystem) != noErr )
{
error = kMacSTROldSystem ;
}
else if ( theSystem < 0x0700 )
{
error = kMacSTROldSystem ;
}
else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap)
{
error = kMacSTRSmallSize;
}
else
{
if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr )
{
gMacHasAppearance = true ;
RegisterAppearanceClient();
if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr )
{
gMacAppearanceVersion = theAppearance ;
}
else
{
gMacAppearanceVersion = 0x0100 ;
}
}
else
error = kMacSTRNoPre8Yet ;
}
// if we encountered any problems so far, give the error code and exit immediately
if ( error )
{
PLErrorMessage( error ) ;
return FALSE ;
{
short itemHit;
Str255 message;
SetCursor(&qd.arrow);
GetIndString(message, 128, error);
ParamText(message, (ConstStr255Param)"\p", (ConstStr255Param)"\p", (ConstStr255Param)"\p");
itemHit = Alert(129, nil);
return FALSE ;
}
// now avoid exceptions thrown for new (bad_alloc)
std::__throws_bad_alloc = FALSE ;
gMacCursorRgn = ::NewRgn() ;
#ifdef __WXMSW__
wxBuffer = new char[1500];
#else
@ -173,7 +252,12 @@ void wxApp::CleanUp()
// do it as the very last thing because everything else can log messages
delete wxLog::SetActiveTarget(NULL);
PLCleanup() ;
::PrClose() ;
if (gMacCursorRgn)
::DisposeRgn(gMacCursorRgn);
#if 0
TerminateAE() ;
#endif
}
int wxEntry( int argc, char *argv[] )
@ -264,7 +348,7 @@ int wxApp::MainLoop()
while (m_keepGoing)
{
PLDoOneEvent() ;
MacDoOneEvent() ;
}
return 0;
@ -403,354 +487,127 @@ wxWindow* wxApp::GetTopWindow() const
void wxExit()
{
wxApp::CleanUp();
/*
* TODO: Exit in some platform-specific way. Not recommended that the app calls this:
* only for emergencies.
*/
::ExitToShell() ;
}
// Yield to other processes
bool wxYield()
{
/*
* TODO
*/
#if 0
::YieldToOtherThreads() ;
::SystemTime() ;
#endif
return TRUE;
}
// -------------------------------------------------------------------
// Portability Layer PL
// -------------------------------------------------------------------
// this is the c-api part, the only part of this file that needs to be
// adapted for supporting a new platform
// there are two flavours of PL... functions, Callbacks and normal functions
// Callbacks are called by other PLxxx functions and allow to trigger idle
// processing etc. the callbacks don't have to be adapted for every platform
// but only in case of changes to the underlying wx framework
// platform specifics
// callbacks
bool PLCallbackIdle()
{
return wxTheApp->ProcessIdle() ;
}
bool PLCallbackRepeat()
{
// wxMacProcessSocketEvents() ;
return false ;
}
// platform specific static variables
bool gMacHasAppearance = false ;
long gMacAppearanceVersion = 0 ;
RgnHandle gMacCursorRgn = NULL ;
#define kMinHeap (29 * 1024)
#define kMinSpace (20 * 1024)
#define eWrongMachine 1
#define eSmallSize 2
#define eNoMemory 3
#define eOldSystem 4
#define eGenericAbout 5
// platform specific prototypes
void DoMacNullEvent( EventRecord *ev ) ;
void DoMacHighLevelEvent( EventRecord *ev ) ;
void DoMacMouseDownEvent( EventRecord *ev ) ;
void DoMacMouseUpEvent( EventRecord *ev ) ;
void DoMacKeyDownEvent( EventRecord *ev ) ;
void DoMacKeyUpEvent( EventRecord *ev ) ;
void DoMacAutoKeyEvent( EventRecord *ev ) ;
void DoMacActivateEvent( EventRecord *ev ) ;
void DoMacUpdateEvent( EventRecord *ev ) ;
void DoMacDiskEvent( EventRecord *ev ) ;
void DoMacOSEvent( EventRecord *ev ) ;
// platform specific functions
// -------------------------------------------------------------------
// PLStartupPhase1
// -------------------------------------------------------------------
// Initializes the system so that at least the requirements can be tested
// and that error messages will shop up at all ;-)
//
// parameters : none
// return value : non zero for a implementation specific error code
int PLStartupPhase1()
{
::InitGraf(&qd.thePort);
::InitFonts();
::InitWindows();
::InitMenus();
::TEInit();
::InitDialogs(0L);
::InitCursor();
CursHandle aCursHandle = ::GetCursor(watchCursor); // Watch should be in system
if (aCursHandle)
::SetCursor(*aCursHandle); // Change cursor to watch
::FlushEvents(everyEvent, 0);
gMacCursorRgn = ::NewRgn() ;
return 0 ;
}
// -------------------------------------------------------------------
// PLStartupPhase2
// -------------------------------------------------------------------
// booting the system further until all subsystems are running
//
// parameters : none
// return value : non zero for a implementation specific error code
int PLStartupPhase2()
{
long total,contig;
::MaxApplZone();
for (long i = 1; i <= 4; i++)
::MoreMasters();
PurgeSpace(&total, &contig);
::SetCursor( &qd.arrow ) ;
#if 0
InitAEHandlers();
InitializeAECore() ;
GUSISetup(GUSIwithInternetSockets);
#endif
return 0 ;
}
// -------------------------------------------------------------------
// PLErrorMessage
// -------------------------------------------------------------------
// notifies the user of a implementation specific error
// is useful for messages before the wx System is up and running
//
// parameters : int error = error code (implementation specific)
// return value : none
void PLErrorMessage( int error )
{
short itemHit;
Str255 message;
SetCursor(&qd.arrow);
GetIndString(message, 128, error);
ParamText(message, (ConstStr255Param)"\p", (ConstStr255Param)"\p", (ConstStr255Param)"\p");
itemHit = Alert(129, nil);
}
// -------------------------------------------------------------------
// PLCleanup
// -------------------------------------------------------------------
// notifies the user of a implementation specific error
// is useful for messages before the wx System is up and running
//
// parameters : int error = error code (implementation specific)
// return value : none
void PLCleanup()
{
::PrClose() ;
if (gMacCursorRgn)
::DisposeRgn(gMacCursorRgn);
#if 0
TerminateAE() ;
#endif
}
// -------------------------------------------------------------------
// PLTestMinimalRequirements
// -------------------------------------------------------------------
// test whether we are on the correct runnable system and read out any
// useful informations from the system
//
// parameters : none
// return value : non zero for a implementation specific error code
int PLTestMinimalRequirements()
{
long theSystem ;
long theMachine;
long theAppearance ;
if (Gestalt(gestaltMachineType, &theMachine) != noErr)
{
return(eWrongMachine);
}
if (theMachine < gestaltMacPlus)
{
return(eWrongMachine);
}
if (Gestalt(gestaltSystemVersion, &theSystem) != noErr )
{
return( eOldSystem ) ;
}
if ( theSystem < 0x0700 )
{
return( eOldSystem ) ;
}
if ((long)GetApplLimit() - (long)ApplicationZone() < kMinHeap)
{
return(eSmallSize);
}
if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr )
{
gMacHasAppearance = true ;
RegisterAppearanceClient();
if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr )
{
gMacAppearanceVersion = theAppearance ;
}
else
{
gMacAppearanceVersion = 0x0100 ;
}
}
return 0 ;
}
// -------------------------------------------------------------------
// PLDoOneEvent
// -------------------------------------------------------------------
//
// parameters : none
// return value : returns true if a real event occured (no null or timeout event)
bool PLDoOneEvent()
void wxApp::MacDoOneEvent()
{
EventRecord event ;
long sleepTime = 60;
bool gotEvent = false ;
if (WaitNextEvent(everyEvent, &event,sleepTime, gMacCursorRgn))
{
gotEvent = PLHandleOneEvent( &event );
MacHandleOneEvent( &event );
}
else
{
PLCallbackIdle();
// idlers
wxTheApp->ProcessIdle() ;
}
PLCallbackRepeat() ;
return gotEvent ;
// repeaters
#if 0
wxMacProcessSocketEvents() ;
#endif
}
// -------------------------------------------------------------------
// PLHandleOneEvent
// -------------------------------------------------------------------
//
// parameters : event = event handle of the platform specific event to be handled
// return value : returns true if a real event occured (no null or timeout event)
bool PLHandleOneEvent( PLEventHandle event )
void wxApp::MacHandleOneEvent( EventRecord *ev )
{
bool realEvent = true ;
EventRecord* ev = (EventRecord*) event ;
switch (ev->what)
{
case nullEvent:
DoMacNullEvent( ev ) ;
realEvent = false ;
MacHandleNullEvent( ev ) ;
break ;
case kHighLevelEvent:
DoMacHighLevelEvent( ev ) ;
MacHandleHighLevelEvent( ev ) ;
break;
case mouseDown:
DoMacMouseDownEvent( ev ) ;
MacHandleMouseDownEvent( ev ) ;
wxTheApp->ExitMainLoop() ;
break;
case mouseUp:
DoMacMouseUpEvent( ev ) ;
MacHandleMouseUpEvent( ev ) ;
break;
case keyDown:
DoMacKeyDownEvent( ev ) ;
MacHandleKeyDownEvent( ev ) ;
break;
case autoKey:
DoMacAutoKeyEvent( ev ) ;
MacHandleAutoKeyEvent( ev ) ;
break;
case keyUp:
DoMacKeyUpEvent( ev ) ;
MacHandleKeyUpEvent( ev ) ;
break;
case activateEvt:
DoMacActivateEvent( ev ) ;
MacHandleActivateEvent( ev ) ;
break;
case updateEvt:
DoMacUpdateEvent( ev ) ;
MacHandleUpdateEvent( ev ) ;
break;
case diskEvt:
DoMacDiskEvent( ev ) ;
MacHandleDiskEvent( ev ) ;
break;
case osEvt:
DoMacOSEvent( ev ) ;
MacHandleOSEvent( ev ) ;
break;
default:
break;
}
return realEvent ;
}
// platform specific functions (non PLxxx functions)
void DoMacNullEvent( EventRecord *ev )
void wxApp::MacHandleNullEvent( EventRecord *ev )
{
}
void DoMacHighLevelEvent( EventRecord *ev )
void wxApp::MacHandleHighLevelEvent( EventRecord *ev )
{
}
void DoMacMouseDownEvent( EventRecord *ev )
void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
{
}
void DoMacMouseUpEvent( EventRecord *ev )
void wxApp::MacHandleMouseUpEvent( EventRecord *ev )
{
}
void DoMacKeyDownEvent( EventRecord *ev )
void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
{
}
void DoMacKeyUpEvent( EventRecord *ev )
void wxApp::MacHandleKeyUpEvent( EventRecord *ev )
{
}
void DoMacAutoKeyEvent( EventRecord *ev )
void wxApp::MacHandleAutoKeyEvent( EventRecord *ev )
{
}
void DoMacActivateEvent( EventRecord *ev )
void wxApp::MacHandleActivateEvent( EventRecord *ev )
{
}
void DoMacUpdateEvent( EventRecord *ev )
void wxApp::MacHandleUpdateEvent( EventRecord *ev )
{
}
void DoMacDiskEvent( EventRecord *ev )
void wxApp::MacHandleDiskEvent( EventRecord *ev )
{
}
void DoMacOSEvent( EventRecord *ev )
void wxApp::MacHandleOSEvent( EventRecord *ev )
{
}

View File

@ -1,4 +1,16 @@
#include <Types.r>
#include "apprsrc.h"
resource 'STR#' ( 128 , "Simple Alert Messages" )
{
{
"This application needs at least a MacPlus" ,
"This application needs more memory" ,
"This application is out of memory" ,
"This application needs at least System 7" ,
"This application needs Appearance extension (built in with System 8) - this restriction will be relieved in the final release"
}
} ;
data 'alis' (128, "Libs alias") {
$"0000 0000 00CE 0002 0001 0A58 5858 5858"

View File

@ -35,6 +35,10 @@
#include <string.h>
// mac
#include "apprsrc.h"
extern char *wxBuffer;
extern wxList wxPendingDelete;
@ -47,41 +51,116 @@ BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
END_EVENT_TABLE()
#endif
// platform layer
typedef void * PLEventHandle ;
int PLTestMinimalRequirements() ;
void PLErrorMessage( int errorCode ) ;
int PLStartupPhase1() ;
int PLStartupPhase2() ;
void PLCleanup() ;
bool PLDoOneEvent() ;
bool PLHandleOneEvent( PLEventHandle event ) ; // true if really event
bool PLCallbackIdle() ;
bool PLCallbackRepeat() ;
long wxApp::sm_lastMessageTime = 0;
const short kMacMinHeap = (29 * 1024) ;
// platform specific static variables
bool gMacHasAppearance = false ;
long gMacAppearanceVersion = 0 ;
RgnHandle gMacCursorRgn = NULL ;
bool wxApp::Initialize()
{
int error = 0 ;
error = PLStartupPhase1() ;
if ( !error )
{
error = PLTestMinimalRequirements() ;
if ( !error )
error = PLStartupPhase2() ;
}
// Mac-specific
long total,contig;
// init all managers
::InitGraf(&qd.thePort);
::InitFonts();
::InitWindows();
::InitMenus();
::TEInit();
::InitDialogs(0L);
::InitCursor();
CursHandle aCursHandle = ::GetCursor(watchCursor); // Watch should be in system
if (aCursHandle)
::SetCursor(*aCursHandle);
::FlushEvents(everyEvent, 0);
// setup memory of application
::MaxApplZone();
for (long i = 1; i <= 4; i++)
::MoreMasters();
PurgeSpace(&total, &contig);
::SetCursor( &qd.arrow ) ;
#if 0
InitAEHandlers();
InitializeAECore() ;
GUSISetup(GUSIwithInternetSockets);
#endif
// test the minimal configuration necessary
long theSystem ;
long theMachine;
long theAppearance ;
if (Gestalt(gestaltMachineType, &theMachine) != noErr)
{
error = kMacSTRWrongMachine;
}
else if (theMachine < gestaltMacPlus)
{
error = kMacSTRWrongMachine;
}
else if (Gestalt(gestaltSystemVersion, &theSystem) != noErr )
{
error = kMacSTROldSystem ;
}
else if ( theSystem < 0x0700 )
{
error = kMacSTROldSystem ;
}
else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap)
{
error = kMacSTRSmallSize;
}
else
{
if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr )
{
gMacHasAppearance = true ;
RegisterAppearanceClient();
if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr )
{
gMacAppearanceVersion = theAppearance ;
}
else
{
gMacAppearanceVersion = 0x0100 ;
}
}
else
error = kMacSTRNoPre8Yet ;
}
// if we encountered any problems so far, give the error code and exit immediately
if ( error )
{
PLErrorMessage( error ) ;
return FALSE ;
{
short itemHit;
Str255 message;
SetCursor(&qd.arrow);
GetIndString(message, 128, error);
ParamText(message, (ConstStr255Param)"\p", (ConstStr255Param)"\p", (ConstStr255Param)"\p");
itemHit = Alert(129, nil);
return FALSE ;
}
// now avoid exceptions thrown for new (bad_alloc)
std::__throws_bad_alloc = FALSE ;
gMacCursorRgn = ::NewRgn() ;
#ifdef __WXMSW__
wxBuffer = new char[1500];
#else
@ -173,7 +252,12 @@ void wxApp::CleanUp()
// do it as the very last thing because everything else can log messages
delete wxLog::SetActiveTarget(NULL);
PLCleanup() ;
::PrClose() ;
if (gMacCursorRgn)
::DisposeRgn(gMacCursorRgn);
#if 0
TerminateAE() ;
#endif
}
int wxEntry( int argc, char *argv[] )
@ -264,7 +348,7 @@ int wxApp::MainLoop()
while (m_keepGoing)
{
PLDoOneEvent() ;
MacDoOneEvent() ;
}
return 0;
@ -403,354 +487,127 @@ wxWindow* wxApp::GetTopWindow() const
void wxExit()
{
wxApp::CleanUp();
/*
* TODO: Exit in some platform-specific way. Not recommended that the app calls this:
* only for emergencies.
*/
::ExitToShell() ;
}
// Yield to other processes
bool wxYield()
{
/*
* TODO
*/
#if 0
::YieldToOtherThreads() ;
::SystemTime() ;
#endif
return TRUE;
}
// -------------------------------------------------------------------
// Portability Layer PL
// -------------------------------------------------------------------
// this is the c-api part, the only part of this file that needs to be
// adapted for supporting a new platform
// there are two flavours of PL... functions, Callbacks and normal functions
// Callbacks are called by other PLxxx functions and allow to trigger idle
// processing etc. the callbacks don't have to be adapted for every platform
// but only in case of changes to the underlying wx framework
// platform specifics
// callbacks
bool PLCallbackIdle()
{
return wxTheApp->ProcessIdle() ;
}
bool PLCallbackRepeat()
{
// wxMacProcessSocketEvents() ;
return false ;
}
// platform specific static variables
bool gMacHasAppearance = false ;
long gMacAppearanceVersion = 0 ;
RgnHandle gMacCursorRgn = NULL ;
#define kMinHeap (29 * 1024)
#define kMinSpace (20 * 1024)
#define eWrongMachine 1
#define eSmallSize 2
#define eNoMemory 3
#define eOldSystem 4
#define eGenericAbout 5
// platform specific prototypes
void DoMacNullEvent( EventRecord *ev ) ;
void DoMacHighLevelEvent( EventRecord *ev ) ;
void DoMacMouseDownEvent( EventRecord *ev ) ;
void DoMacMouseUpEvent( EventRecord *ev ) ;
void DoMacKeyDownEvent( EventRecord *ev ) ;
void DoMacKeyUpEvent( EventRecord *ev ) ;
void DoMacAutoKeyEvent( EventRecord *ev ) ;
void DoMacActivateEvent( EventRecord *ev ) ;
void DoMacUpdateEvent( EventRecord *ev ) ;
void DoMacDiskEvent( EventRecord *ev ) ;
void DoMacOSEvent( EventRecord *ev ) ;
// platform specific functions
// -------------------------------------------------------------------
// PLStartupPhase1
// -------------------------------------------------------------------
// Initializes the system so that at least the requirements can be tested
// and that error messages will shop up at all ;-)
//
// parameters : none
// return value : non zero for a implementation specific error code
int PLStartupPhase1()
{
::InitGraf(&qd.thePort);
::InitFonts();
::InitWindows();
::InitMenus();
::TEInit();
::InitDialogs(0L);
::InitCursor();
CursHandle aCursHandle = ::GetCursor(watchCursor); // Watch should be in system
if (aCursHandle)
::SetCursor(*aCursHandle); // Change cursor to watch
::FlushEvents(everyEvent, 0);
gMacCursorRgn = ::NewRgn() ;
return 0 ;
}
// -------------------------------------------------------------------
// PLStartupPhase2
// -------------------------------------------------------------------
// booting the system further until all subsystems are running
//
// parameters : none
// return value : non zero for a implementation specific error code
int PLStartupPhase2()
{
long total,contig;
::MaxApplZone();
for (long i = 1; i <= 4; i++)
::MoreMasters();
PurgeSpace(&total, &contig);
::SetCursor( &qd.arrow ) ;
#if 0
InitAEHandlers();
InitializeAECore() ;
GUSISetup(GUSIwithInternetSockets);
#endif
return 0 ;
}
// -------------------------------------------------------------------
// PLErrorMessage
// -------------------------------------------------------------------
// notifies the user of a implementation specific error
// is useful for messages before the wx System is up and running
//
// parameters : int error = error code (implementation specific)
// return value : none
void PLErrorMessage( int error )
{
short itemHit;
Str255 message;
SetCursor(&qd.arrow);
GetIndString(message, 128, error);
ParamText(message, (ConstStr255Param)"\p", (ConstStr255Param)"\p", (ConstStr255Param)"\p");
itemHit = Alert(129, nil);
}
// -------------------------------------------------------------------
// PLCleanup
// -------------------------------------------------------------------
// notifies the user of a implementation specific error
// is useful for messages before the wx System is up and running
//
// parameters : int error = error code (implementation specific)
// return value : none
void PLCleanup()
{
::PrClose() ;
if (gMacCursorRgn)
::DisposeRgn(gMacCursorRgn);
#if 0
TerminateAE() ;
#endif
}
// -------------------------------------------------------------------
// PLTestMinimalRequirements
// -------------------------------------------------------------------
// test whether we are on the correct runnable system and read out any
// useful informations from the system
//
// parameters : none
// return value : non zero for a implementation specific error code
int PLTestMinimalRequirements()
{
long theSystem ;
long theMachine;
long theAppearance ;
if (Gestalt(gestaltMachineType, &theMachine) != noErr)
{
return(eWrongMachine);
}
if (theMachine < gestaltMacPlus)
{
return(eWrongMachine);
}
if (Gestalt(gestaltSystemVersion, &theSystem) != noErr )
{
return( eOldSystem ) ;
}
if ( theSystem < 0x0700 )
{
return( eOldSystem ) ;
}
if ((long)GetApplLimit() - (long)ApplicationZone() < kMinHeap)
{
return(eSmallSize);
}
if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr )
{
gMacHasAppearance = true ;
RegisterAppearanceClient();
if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr )
{
gMacAppearanceVersion = theAppearance ;
}
else
{
gMacAppearanceVersion = 0x0100 ;
}
}
return 0 ;
}
// -------------------------------------------------------------------
// PLDoOneEvent
// -------------------------------------------------------------------
//
// parameters : none
// return value : returns true if a real event occured (no null or timeout event)
bool PLDoOneEvent()
void wxApp::MacDoOneEvent()
{
EventRecord event ;
long sleepTime = 60;
bool gotEvent = false ;
if (WaitNextEvent(everyEvent, &event,sleepTime, gMacCursorRgn))
{
gotEvent = PLHandleOneEvent( &event );
MacHandleOneEvent( &event );
}
else
{
PLCallbackIdle();
// idlers
wxTheApp->ProcessIdle() ;
}
PLCallbackRepeat() ;
return gotEvent ;
// repeaters
#if 0
wxMacProcessSocketEvents() ;
#endif
}
// -------------------------------------------------------------------
// PLHandleOneEvent
// -------------------------------------------------------------------
//
// parameters : event = event handle of the platform specific event to be handled
// return value : returns true if a real event occured (no null or timeout event)
bool PLHandleOneEvent( PLEventHandle event )
void wxApp::MacHandleOneEvent( EventRecord *ev )
{
bool realEvent = true ;
EventRecord* ev = (EventRecord*) event ;
switch (ev->what)
{
case nullEvent:
DoMacNullEvent( ev ) ;
realEvent = false ;
MacHandleNullEvent( ev ) ;
break ;
case kHighLevelEvent:
DoMacHighLevelEvent( ev ) ;
MacHandleHighLevelEvent( ev ) ;
break;
case mouseDown:
DoMacMouseDownEvent( ev ) ;
MacHandleMouseDownEvent( ev ) ;
wxTheApp->ExitMainLoop() ;
break;
case mouseUp:
DoMacMouseUpEvent( ev ) ;
MacHandleMouseUpEvent( ev ) ;
break;
case keyDown:
DoMacKeyDownEvent( ev ) ;
MacHandleKeyDownEvent( ev ) ;
break;
case autoKey:
DoMacAutoKeyEvent( ev ) ;
MacHandleAutoKeyEvent( ev ) ;
break;
case keyUp:
DoMacKeyUpEvent( ev ) ;
MacHandleKeyUpEvent( ev ) ;
break;
case activateEvt:
DoMacActivateEvent( ev ) ;
MacHandleActivateEvent( ev ) ;
break;
case updateEvt:
DoMacUpdateEvent( ev ) ;
MacHandleUpdateEvent( ev ) ;
break;
case diskEvt:
DoMacDiskEvent( ev ) ;
MacHandleDiskEvent( ev ) ;
break;
case osEvt:
DoMacOSEvent( ev ) ;
MacHandleOSEvent( ev ) ;
break;
default:
break;
}
return realEvent ;
}
// platform specific functions (non PLxxx functions)
void DoMacNullEvent( EventRecord *ev )
void wxApp::MacHandleNullEvent( EventRecord *ev )
{
}
void DoMacHighLevelEvent( EventRecord *ev )
void wxApp::MacHandleHighLevelEvent( EventRecord *ev )
{
}
void DoMacMouseDownEvent( EventRecord *ev )
void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
{
}
void DoMacMouseUpEvent( EventRecord *ev )
void wxApp::MacHandleMouseUpEvent( EventRecord *ev )
{
}
void DoMacKeyDownEvent( EventRecord *ev )
void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
{
}
void DoMacKeyUpEvent( EventRecord *ev )
void wxApp::MacHandleKeyUpEvent( EventRecord *ev )
{
}
void DoMacAutoKeyEvent( EventRecord *ev )
void wxApp::MacHandleAutoKeyEvent( EventRecord *ev )
{
}
void DoMacActivateEvent( EventRecord *ev )
void wxApp::MacHandleActivateEvent( EventRecord *ev )
{
}
void DoMacUpdateEvent( EventRecord *ev )
void wxApp::MacHandleUpdateEvent( EventRecord *ev )
{
}
void DoMacDiskEvent( EventRecord *ev )
void wxApp::MacHandleDiskEvent( EventRecord *ev )
{
}
void DoMacOSEvent( EventRecord *ev )
void wxApp::MacHandleOSEvent( EventRecord *ev )
{
}

View File

@ -1,4 +1,16 @@
#include <Types.r>
#include "apprsrc.h"
resource 'STR#' ( 128 , "Simple Alert Messages" )
{
{
"This application needs at least a MacPlus" ,
"This application needs more memory" ,
"This application is out of memory" ,
"This application needs at least System 7" ,
"This application needs Appearance extension (built in with System 8) - this restriction will be relieved in the final release"
}
} ;
data 'alis' (128, "Libs alias") {
$"0000 0000 00CE 0002 0001 0A58 5858 5858"

View File

@ -57,7 +57,7 @@ WXDLLEXPORT wxString wxFileSelector(const char *title,
return wxBuffer;
}
else
return NULL;
return wxGetEmptyString();
}
WXDLLEXPORT wxString wxFileSelectorEx(const char *title,
@ -81,7 +81,7 @@ WXDLLEXPORT wxString wxFileSelectorEx(const char *title,
return wxBuffer;
}
else
return NULL;
return wxGetEmptyString();
}
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,

View File

@ -57,7 +57,7 @@ WXDLLEXPORT wxString wxFileSelector(const char *title,
return wxBuffer;
}
else
return NULL;
return wxGetEmptyString();
}
WXDLLEXPORT wxString wxFileSelectorEx(const char *title,
@ -81,7 +81,7 @@ WXDLLEXPORT wxString wxFileSelectorEx(const char *title,
return wxBuffer;
}
else
return NULL;
return wxGetEmptyString();
}
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,