merge with latest sources

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7985 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2000-08-09 10:10:14 +00:00
parent 57681e5bfd
commit 2f1ae41432
176 changed files with 7712 additions and 5094 deletions

View File

@@ -17,7 +17,9 @@
#include "wx/accel.h" #include "wx/accel.h"
#include "wx/string.h" #include "wx/string.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject)
#endif
class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData
{ {

View File

@@ -1,3 +1,5 @@
#if !TARGET_CARBON
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
#include <wx/mac/aga.h> #include <wx/mac/aga.h>
#include <extcdef.h> #include <extcdef.h>
@@ -600,6 +602,10 @@ void AGADeactivateControl( ControlHandle inControl )
} }
} }
} }
else
{
::HiliteControl( inControl , 255 ) ;
}
} }
void AGAActivateControl( ControlHandle inControl ) void AGAActivateControl( ControlHandle inControl )
@@ -615,6 +621,10 @@ void AGAActivateControl( ControlHandle inControl )
} }
} }
} }
else
{
::HiliteControl( inControl , 0 ) ;
}
} }
OSErr AGASetKeyboardFocus (WindowPtr inWindow, OSErr AGASetKeyboardFocus (WindowPtr inWindow,
@@ -718,6 +728,7 @@ void DisposeExtCDEFInfo( ControlHandle theControl)
DisposeHandle( info->children ) ; DisposeHandle( info->children ) ;
info->children = NULL ; info->children = NULL ;
free( (void*) (**theControl).contrlRfCon ) ; free( (void*) (**theControl).contrlRfCon ) ;
(**theControl).contrlRfCon = NULL ;
} }
} }
} }
@@ -922,51 +933,6 @@ void AGASetFontStyle( ControlFontStyleRec *fontstyle )
::RGBBackColor( &fontstyle->backColor ) ; ::RGBBackColor( &fontstyle->backColor ) ;
} ; } ;
class AGAPortHelper
{
public :
AGAPortHelper()
{
GetPenState( &oldPenState ) ;
GetBackColor( &oldBackColor ) ;
GetForeColor( &oldForeColor ) ;
GetPort( &port ) ;
clip = NewRgn() ;
GetClip( clip );
font = port->txFont;
size = port->txSize;
style = port->txFace;
mode = port->txMode;
}
~AGAPortHelper()
{
SetPort( port ) ;
SetClip( clip ) ;
DisposeRgn( clip ) ;
RGBForeColor(&oldForeColor);
RGBBackColor(&oldBackColor);
SetPenState(&oldPenState);
TextFont( font );
TextSize( size );
TextFace( style );
TextMode( mode );
}
private :
GrafPtr port ;
PenState oldPenState ;
RGBColor oldForeColor ;
RGBColor oldBackColor ;
RgnHandle clip ;
short font ;
short size ;
short style ;
short mode ;
} ;
pascal SInt32 AGAProgressBarDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) pascal SInt32 AGAProgressBarDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param)
{ {
switch( message ) switch( message )
@@ -1079,7 +1045,7 @@ pascal SInt32 AGABevelButtonDefProc (SInt16 procID, ControlHandle theControl, Co
return 0 ; return 0 ;
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
Boolean mRadioBehavior = false ; Boolean mRadioBehavior = false ;
@@ -1219,7 +1185,7 @@ pascal SInt32 AGAButtonDefProc (SInt16 procID, ControlHandle theControl, Control
return 0 ; return 0 ;
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
Boolean mRadioBehavior = false ; Boolean mRadioBehavior = false ;
@@ -1456,7 +1422,7 @@ pascal SInt32 AGACheckBoxDefProc (SInt16 procID, ControlHandle theControl, Contr
return 0 ; return 0 ;
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
Rect frame = (**theControl).contrlRect ; Rect frame = (**theControl).contrlRect ;
Boolean hasColor = true; Boolean hasColor = true;
Boolean disabled = (*theControl)->contrlHilite == 255 ; Boolean disabled = (*theControl)->contrlHilite == 255 ;
@@ -1844,7 +1810,7 @@ pascal SInt32 AGAStaticGroupBoxTextDefProc (SInt16 procID, ControlHandle theCont
{ {
bool disabled = false ; bool disabled = false ;
bool hasColor = true ; bool hasColor = true ;
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
FontInfo fi ; FontInfo fi ;
::GetFontInfo( &fi ) ; ::GetFontInfo( &fi ) ;
@@ -1930,7 +1896,7 @@ pascal SInt32 AGAStaticTextDefProc (SInt16 procID, ControlHandle theControl, Con
return 0 ; return 0 ;
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
int x = (**theControl).contrlRect.left ; int x = (**theControl).contrlRect.left ;
int y = (**theControl).contrlRect.top ; int y = (**theControl).contrlRect.top ;
@@ -2125,7 +2091,7 @@ pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, Contr
{ {
case initCntl : case initCntl :
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
SetPort( (**theControl).contrlOwner ) ; SetPort( (**theControl).contrlOwner ) ;
::TextFont( kFontIDGeneva ) ; ::TextFont( kFontIDGeneva ) ;
::TextSize( 10 ) ; ::TextSize( 10 ) ;
@@ -2147,7 +2113,7 @@ pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, Contr
break ; break ;
case drawCntl : case drawCntl :
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
SetPort( (**theControl).contrlOwner ) ; SetPort( (**theControl).contrlOwner ) ;
RGBBackColor( &gAGARamp[ kAGAWhite ] ) ; RGBBackColor( &gAGARamp[ kAGAWhite ] ) ;
@@ -2254,9 +2220,8 @@ pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, Contr
break ; break ;
case kControlMsgKeyDown : case kControlMsgKeyDown :
{ {
AGAPortHelper help() ; AGAPortHelper help( (**theControl).contrlOwner ) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
SetPort( (**theControl).contrlOwner ) ;
RGBBackColor( &gAGARamp[ kAGAWhite ] ) ; RGBBackColor( &gAGARamp[ kAGAWhite ] ) ;
RGBForeColor( &gAGARamp[ kAGABlack ] ) ; RGBForeColor( &gAGARamp[ kAGABlack ] ) ;
ControlKeyDownRec * rec = (ControlKeyDownRec*) param ; ControlKeyDownRec * rec = (ControlKeyDownRec*) param ;
@@ -2364,7 +2329,7 @@ pascal SInt32 AGAListControlDefProc (SInt16 procID, ControlHandle theControl, Co
break ; break ;
case drawCntl : case drawCntl :
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
RGBBackColor( &gAGARamp[ kAGAWhite ] ) ; RGBBackColor( &gAGARamp[ kAGAWhite ] ) ;
EraseRect( &(**theControl).contrlRect ) ; EraseRect( &(**theControl).contrlRect ) ;
@@ -2578,4 +2543,78 @@ void AGASetThemeWindowBackground (WindowRef inWindow,
SetPort( port ) ; SetPort( port ) ;
} }
void AGAApplyThemeBackground(ThemeBackgroundKind inKind,
const Rect * bounds,
ThemeDrawState inState,
SInt16 inDepth,
Boolean inColorDev)
{
}
#endif
AGAPortHelper::AGAPortHelper( GrafPtr newport)
{
GetPort( &port ) ;
SetPort( newport ) ;
// wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ;
GetPenState( &oldPenState ) ;
GetBackColor( &oldBackColor ) ;
GetForeColor( &oldForeColor ) ;
clip = NewRgn() ;
GetClip( clip );
font = GetPortTextFont( newport);
size = GetPortTextSize( newport);
style = GetPortTextFace( newport);
mode = GetPortTextMode( newport);
nport = newport ;
}
AGAPortHelper::AGAPortHelper()
{
clip = NULL ;
}
void AGAPortHelper::Setup( GrafPtr newport )
{
GetPort( &port ) ;
SetPort( newport ) ;
// wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ;
GetPenState( &oldPenState ) ;
GetBackColor( &oldBackColor ) ;
GetForeColor( &oldForeColor ) ;
clip = NewRgn() ;
GetClip( clip );
font = GetPortTextFont( newport);
size = GetPortTextSize( newport);
style = GetPortTextFace( newport);
mode = GetPortTextMode( newport);
nport = newport ;
}
void AGAPortHelper::Clear()
{
if ( clip )
{
DisposeRgn( clip ) ;
clip = NULL ;
}
}
AGAPortHelper::~AGAPortHelper()
{
if ( clip )
{
SetPort( nport ) ;
SetClip( clip ) ;
DisposeRgn( clip ) ;
RGBForeColor(&oldForeColor);
RGBBackColor(&oldBackColor);
SetPenState(&oldPenState);
TextFont( font );
TextSize( size );
TextFace( style );
TextMode( mode );
SetPort( port ) ;
}
}

View File

@@ -28,7 +28,7 @@
#include "wx/log.h" #include "wx/log.h"
#include "wx/module.h" #include "wx/module.h"
#include "wx/memory.h" #include "wx/memory.h"
#include "wx/tooltip.h"
#if wxUSE_WX_RESOURCES #if wxUSE_WX_RESOURCES
#include "wx/resource.h" #include "wx/resource.h"
#endif #endif
@@ -44,6 +44,12 @@
#include "apprsrc.h" #include "apprsrc.h"
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
#include <wx/mac/macnotfy.h>
#if wxUSE_SOCKETS
#include <OpenTransport.h>
#include <OpenTptInternet.h>
#endif
extern char *wxBuffer; extern char *wxBuffer;
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
@@ -52,10 +58,14 @@ extern wxList *wxWinMacControlList;
wxApp *wxTheApp = NULL; wxApp *wxTheApp = NULL;
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle) EVT_IDLE(wxApp::OnIdle)
EVT_END_SESSION(wxApp::OnEndSession)
EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
const short kMacMinHeap = (29 * 1024) ; const short kMacMinHeap = (29 * 1024) ;
@@ -76,25 +86,25 @@ bool wxApp::s_macSupportPCMenuShortcuts = true ;
long wxApp::s_macAboutMenuItemId = wxID_ABOUT ; long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
wxString wxApp::s_macHelpMenuTitleName = "&Help" ; wxString wxApp::s_macHelpMenuTitleName = "&Help" ;
OSErr AEHandleODoc( AppleEvent *event , AppleEvent *reply , long refcon ) pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEODoc( event , reply) ; return wxTheApp->MacHandleAEODoc( event , reply) ;
} }
OSErr AEHandleOApp( AppleEvent *event , AppleEvent *reply , long refcon ) pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEOApp( event , reply ) ; return wxTheApp->MacHandleAEOApp( event , reply ) ;
} }
OSErr AEHandlePDoc( AppleEvent *event , AppleEvent *reply , long refcon ) pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEPDoc( event , reply ) ; return wxTheApp->MacHandleAEPDoc( event , reply ) ;
} }
OSErr AEHandleQuit( AppleEvent *event , AppleEvent *reply , long refcon ) pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEQuit( event , reply) ; return wxTheApp->MacHandleAEQuit( event , reply) ;
@@ -133,14 +143,14 @@ OSErr wxApp::MacHandleAEQuit(AppleEvent *event , AppleEvent *reply)
return noErr ; return noErr ;
} }
char StringMac[] = "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" char StringMac[] = "\x0d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf" "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf"
"\xb1\xb4\xb5\xb6\xbb\xbc\xbe\xbf" "\xb1\xb4\xb5\xb6\xbb\xbc\xbe\xbf"
"\xc0\xc1\xc2\xc4\xc7\xc8\xc9\xcb\xcc\xcd\xce\xcf" "\xc0\xc1\xc2\xc4\xc7\xc8\xc9\xcb\xcc\xcd\xce\xcf"
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xca\xdb" ; "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xca\xdb" ;
char StringANSI[] = "\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8" char StringANSI[] = "\x0a\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8"
"\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC" "\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC"
"\x86\xBA\xA2\xA3\xA7\x95\xB6\xDF\xAE\xA9\x99\xB4\xA8\xC6\xD8" "\x86\xBA\xA2\xA3\xA7\x95\xB6\xDF\xAE\xA9\x99\xB4\xA8\xC6\xD8"
"\xB1\xA5\xB5\xF0\xAA\xBA\xE6\xF8" "\xB1\xA5\xB5\xF0\xAA\xBA\xE6\xF8"
@@ -321,9 +331,6 @@ bool wxApp::Initialize()
AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) , (long) wxTheApp , FALSE ) ; AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) , (long) wxTheApp , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , (long) wxTheApp , FALSE ) ; AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , (long) wxTheApp , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , (long) wxTheApp , FALSE ) ; AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , (long) wxTheApp , FALSE ) ;
#if 0
GUSISetup(GUSIwithInternetSockets);
#endif
// test the minimal configuration necessary // test the minimal configuration necessary
@@ -378,7 +385,7 @@ bool wxApp::Initialize()
} }
#if __option(profile) #if __option(profile)
ProfilerInit( collectDetailed, bestTimeBase , 20000 , 30 ) ; ProfilerInit( collectDetailed, bestTimeBase , 20000 , 40 ) ;
#endif #endif
// now avoid exceptions thrown for new (bad_alloc) // now avoid exceptions thrown for new (bad_alloc)
@@ -393,17 +400,15 @@ bool wxApp::Initialize()
wxBuffer = new char[BUFSIZ + 512]; wxBuffer = new char[BUFSIZ + 512];
#endif #endif
/* No longer used
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
streambuf* sBuf = new wxDebugStreamBuf;
ostream* oStr = new ostream(sBuf) ;
wxDebugContext::SetStream(oStr, sBuf);
#endif
*/
wxClassInfo::InitializeClasses(); wxClassInfo::InitializeClasses();
#if wxUSE_RESOURCES
// wxGetResource(wxT("wxWindows"), wxT("OsVersion"), &wxOsVersion);
#endif
#if wxUSE_THREADS
wxPendingEventsLocker = new wxCriticalSection;
#endif
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
wxTheColourDatabase->Initialize(); wxTheColourDatabase->Initialize();
@@ -423,13 +428,29 @@ bool wxApp::Initialize()
wxWinMacWindowList = new wxList(wxKEY_INTEGER); wxWinMacWindowList = new wxList(wxKEY_INTEGER);
wxWinMacControlList = new wxList(wxKEY_INTEGER); wxWinMacControlList = new wxList(wxKEY_INTEGER);
UMAShowArrowCursor() ; wxMacCreateNotifierTable() ;
UMAShowArrowCursor() ;
return TRUE; return TRUE;
} }
void wxApp::CleanUp() void wxApp::CleanUp()
{ {
#if wxUSE_LOG
// flush the logged messages if any and install a 'safer' log target: the
// default one (wxLogGui) can't be used after the resources are freed just
// below and the user suppliedo ne might be even more unsafe (using any
// wxWindows GUI function is unsafe starting from now)
wxLog::DontCreateOnDemand();
// this will flush the old messages if any
delete wxLog::SetActiveTarget(new wxLogStderr);
#endif // wxUSE_LOG
// One last chance for pending objects to be cleaned up
wxTheApp->DeletePendingObjects();
wxModule::CleanUpModules(); wxModule::CleanUpModules();
#if wxUSE_WX_RESOURCES #if wxUSE_WX_RESOURCES
@@ -438,19 +459,8 @@ void wxApp::CleanUp()
wxDeleteStockObjects() ; wxDeleteStockObjects() ;
// Destroy all GDI lists, etc. // Destroy all GDI lists, etc.
wxDeleteStockLists();
delete wxTheBrushList;
wxTheBrushList = NULL;
delete wxThePenList;
wxThePenList = NULL;
delete wxTheFontList;
wxTheFontList = NULL;
delete wxTheBitmapList;
wxTheBitmapList = NULL;
delete wxTheColourDatabase; delete wxTheColourDatabase;
wxTheColourDatabase = NULL; wxTheColourDatabase = NULL;
@@ -460,9 +470,17 @@ void wxApp::CleanUp()
delete[] wxBuffer; delete[] wxBuffer;
wxBuffer = NULL; wxBuffer = NULL;
wxMacDestroyNotifierTable() ;
if (wxWinMacWindowList) if (wxWinMacWindowList)
delete wxWinMacWindowList ; delete wxWinMacWindowList ;
delete wxPendingEvents;
#if wxUSE_THREADS
delete wxPendingEventsLocker;
// If we don't do the following, we get an apparent memory leak.
((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
#endif
wxClassInfo::CleanUpClasses(); wxClassInfo::CleanUpClasses();
#if __option(profile) #if __option(profile)
@@ -474,33 +492,33 @@ void wxApp::CleanUp()
wxTheApp = NULL; wxTheApp = NULL;
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
// At this point we want to check if there are any memory // At this point we want to check if there are any memory
// blocks that aren't part of the wxDebugContext itself, // blocks that aren't part of the wxDebugContext itself,
// as a special case. Then when dumping we need to ignore // as a special case. Then when dumping we need to ignore
// wxDebugContext, too. // wxDebugContext, too.
if (wxDebugContext::CountObjectsLeft() > 0) if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
{ {
wxTrace("There were memory leaks.\n"); wxLogDebug(wxT("There were memory leaks."));
wxDebugContext::Dump(); wxDebugContext::Dump();
wxDebugContext::PrintStatistics(); wxDebugContext::PrintStatistics();
} }
// wxDebugContext::SetStream(NULL, NULL); // wxDebugContext::SetStream(NULL, NULL);
#endif #endif
// do it as the very last thing because everything else can log messages #if wxUSE_LOG
wxLog::DontCreateOnDemand(); // do it as the very last thing because everything else can log messages
// do it as the very last thing because everything else can log messages delete wxLog::SetActiveTarget(NULL);
delete wxLog::SetActiveTarget(NULL); #endif // wxUSE_LOG
::PrClose() ;
if (s_macCursorRgn) if (s_macCursorRgn)
::DisposeRgn(s_macCursorRgn); ::DisposeRgn(s_macCursorRgn);
#if 0 #if 0
TerminateAE() ; TerminateAE() ;
#endif #endif
} }
int wxEntry( int argc, char *argv[] ) int wxEntry( int argc, char *argv[] , bool enterLoop )
{ {
#ifdef __MWERKS__ #ifdef __MWERKS__
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
@@ -513,27 +531,24 @@ int wxEntry( int argc, char *argv[] )
wxDebugContext::SetCheckpoint(); wxDebugContext::SetCheckpoint();
#endif #endif
#endif #endif
if (!wxApp::Initialize()) if (!wxApp::Initialize())
return FALSE; return 0;
if (!wxTheApp) // create the application object or ensure that one already exists
{ if (!wxTheApp)
if (!wxApp::GetInitializerFunction())
{ {
printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" ); // The app may have declared a global application object, but we recommend
return 0; // the IMPLEMENT_APP macro is used instead, which sets an initializer
}; // function for delayed, dynamic app object construction.
wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
wxT("No initializer - use IMPLEMENT_APP macro.") );
wxTheApp = (wxApp*) (* wxApp::GetInitializerFunction()) (); wxTheApp = (wxApp*) (*wxApp::GetInitializerFunction()) ();
}; }
if (!wxTheApp) wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
{
printf( "wxWindows error: wxTheApp == NULL\n" );
return 0;
};
#ifdef __WXMAC__ #ifdef __WXMAC__
argc = 1 ; // currently we don't support files as parameters argc = 0 ; // currently we don't support files as parameters
#endif #endif
wxTheApp->argc = argc; wxTheApp->argc = argc;
@@ -549,42 +564,58 @@ int wxEntry( int argc, char *argv[] )
// into wxTopLevelWindows by getting created // into wxTopLevelWindows by getting created
// in OnInit(). // in OnInit().
if (!wxTheApp->OnInit()) return 0;
int retValue = 0; int retValue = 0;
if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun(); if ( wxTheApp->OnInit() )
{
if ( enterLoop )
{
retValue = wxTheApp->OnRun();
}
else
// We want to initialize, but not run or exit immediately.
return 1;
}
//else: app initialization failed, so we skipped OnRun()
if (wxTheApp->GetTopWindow()) wxWindow *topWindow = wxTheApp->GetTopWindow();
{ if ( topWindow )
delete wxTheApp->GetTopWindow(); {
wxTheApp->SetTopWindow(NULL); // Forcibly delete the window.
} if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
topWindow->IsKindOf(CLASSINFO(wxDialog)) )
{
topWindow->Close(TRUE);
wxTheApp->DeletePendingObjects();
}
else
{
delete topWindow;
wxTheApp->SetTopWindow(NULL);
}
}
wxTheApp->DeletePendingObjects(); wxTheApp->OnExit();
wxTheApp->OnExit(); wxApp::CleanUp();
wxApp::CleanUp(); return retValue;
return retValue;
}; };
// Static member initialization // Static member initialization
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL; wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
wxApp::wxApp() wxApp::wxApp()
{ {
m_topWindow = NULL; m_topWindow = NULL;
wxTheApp = this; wxTheApp = this;
m_className = "";
m_wantDebugOutput = TRUE ; m_wantDebugOutput = TRUE ;
m_appName = "";
argc = 0; argc = 0;
argv = NULL; argv = NULL;
m_printMode = wxPRINT_WINDOWS; m_printMode = wxPRINT_WINDOWS;
m_exitOnFrameDelete = TRUE; m_exitOnFrameDelete = TRUE;
m_auto3D = TRUE; m_auto3D = TRUE;
} }
@@ -640,13 +671,14 @@ void wxApp::Dispatch()
void wxApp::OnIdle(wxIdleEvent& event) void wxApp::OnIdle(wxIdleEvent& event)
{ {
static bool inOnIdle = FALSE; static bool s_inOnIdle = FALSE;
// Avoid recursion (via ProcessEvent default case) // Avoid recursion (via ProcessEvent default case)
if (inOnIdle) if ( s_inOnIdle )
return; return;
inOnIdle = TRUE;
s_inOnIdle = TRUE;
// 'Garbage' collection of windows deleted with Close(). // 'Garbage' collection of windows deleted with Close().
DeletePendingObjects(); DeletePendingObjects();
@@ -662,13 +694,17 @@ void wxApp::OnIdle(wxIdleEvent& event)
if (needMore) if (needMore)
event.RequestMore(TRUE); event.RequestMore(TRUE);
inOnIdle = FALSE; // If they are pending events, we must process them: pending events are
// either events to the threads other than main or events posted with
// wxPostEvent() functions
wxMacProcessNotifierAndPendingEvents();
s_inOnIdle = FALSE;
} }
void wxWakeUpIdle() void wxWakeUpIdle()
{ {
// **** please implement me! **** wxMacWakeUp() ;
// Wake up the idle handler processor, even if it is in another thread...
} }
// Send idle event to all top-level windows // Send idle event to all top-level windows
@@ -729,32 +765,76 @@ void wxApp::DeletePendingObjects()
} }
} }
wxLog* wxApp::CreateLogTarget() wxIcon
wxApp::GetStdIcon(int which) const
{ {
return new wxLogGui; switch(which)
} {
case wxICON_INFORMATION:
return wxIcon("wxICON_INFO");
wxWindow* wxApp::GetTopWindow() const case wxICON_QUESTION:
{ return wxIcon("wxICON_QUESTION");
if (m_topWindow)
return m_topWindow; case wxICON_EXCLAMATION:
else if (wxTopLevelWindows.Number() > 0) return wxIcon("wxICON_WARNING");
return (wxWindow*) wxTopLevelWindows.First()->Data();
else default:
return NULL; wxFAIL_MSG(wxT("requested non existent standard icon"));
// still fall through
case wxICON_HAND:
return wxIcon("wxICON_ERROR");
}
} }
void wxExit() void wxExit()
{ {
wxApp::CleanUp(); wxLogError(_("Fatal error: exiting"));
wxApp::CleanUp();
::ExitToShell() ; ::ExitToShell() ;
} }
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
{
if (GetTopWindow())
GetTopWindow()->Close(TRUE);
}
// Default behaviour: close the application with prompts. The
// user can veto the close, and therefore the end session.
void wxApp::OnQueryEndSession(wxCloseEvent& event)
{
if (GetTopWindow())
{
if (!GetTopWindow()->Close(!event.CanVeto()))
event.Veto(TRUE);
}
}
extern "C" void wxCYield() ;
void wxCYield()
{
wxYield() ;
}
// Yield to other processes // Yield to other processes
bool wxYield() bool wxYield()
{ {
// YieldToAnyThread() ; #if wxUSE_THREADS
SystemTask() ; YieldToAnyThread() ;
#endif
EventRecord event ;
long sleepTime = 0 ; //::GetCaretTime();
while ( !wxTheApp->IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, wxApp::s_macCursorRgn))
{
wxTheApp->MacHandleOneEvent( &event );
}
wxMacProcessNotifierAndPendingEvents() ;
return TRUE; return TRUE;
} }
@@ -762,6 +842,12 @@ bool wxYield()
void wxApp::MacSuspend( bool convertClipboard ) void wxApp::MacSuspend( bool convertClipboard )
{ {
// we have to deactive the window manually
wxWindow* window = GetTopWindow() ;
if ( window )
window->MacActivate( MacGetCurrentEvent() , false ) ;
s_lastMouseDown = 0 ; s_lastMouseDown = 0 ;
if( convertClipboard ) if( convertClipboard )
{ {
@@ -784,13 +870,10 @@ void wxApp::MacResume( bool convertClipboard )
void wxApp::MacConvertPrivateToPublicScrap() void wxApp::MacConvertPrivateToPublicScrap()
{ {
::ZeroScrap();
::TEToScrap();
} }
void wxApp::MacConvertPublicToPrivateScrap() void wxApp::MacConvertPublicToPrivateScrap()
{ {
::TEFromScrap() ;
} }
void wxApp::MacDoOneEvent() void wxApp::MacDoOneEvent()
@@ -817,9 +900,7 @@ void wxApp::MacDoOneEvent()
// repeaters // repeaters
#if 0 wxMacProcessNotifierAndPendingEvents() ;
wxMacProcessSocketEvents() ;
#endif
} }
void wxApp::MacHandleOneEvent( EventRecord *ev ) void wxApp::MacHandleOneEvent( EventRecord *ev )
@@ -874,6 +955,7 @@ void wxApp::MacHandleOneEvent( EventRecord *ev )
default: default:
break; break;
} }
wxMacProcessNotifierAndPendingEvents() ;
} }
void wxApp::MacHandleHighLevelEvent( EventRecord *ev ) void wxApp::MacHandleHighLevelEvent( EventRecord *ev )
@@ -885,6 +967,8 @@ bool s_macIsInModalLoop = false ;
void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
{ {
wxToolTip::RemoveToolTips() ;
WindowRef window; WindowRef window;
WindowRef frontWindow = UMAFrontNonFloatingWindow() ; WindowRef frontWindow = UMAFrontNonFloatingWindow() ;
WindowAttributes frontWindowAttributes = NULL ; WindowAttributes frontWindowAttributes = NULL ;
@@ -894,6 +978,9 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
short windowPart = ::FindWindow(ev->where, &window); short windowPart = ::FindWindow(ev->where, &window);
wxWindow* win = wxFindWinFromMacWindow( window ) ; wxWindow* win = wxFindWinFromMacWindow( window ) ;
BitMap screenBits;
GetQDGlobalsScreenBits( &screenBits );
switch (windowPart) switch (windowPart)
{ {
case inMenuBar : case inMenuBar :
@@ -908,10 +995,12 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
s_lastMouseDown = 0; s_lastMouseDown = 0;
} }
break ; break ;
#if !TARGET_CARBON
case inSysWindow : case inSysWindow :
SystemClick( ev , window ) ; SystemClick( ev , window ) ;
s_lastMouseDown = 0; s_lastMouseDown = 0;
break ; break ;
#endif
case inDrag : case inDrag :
if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) ) if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) )
{ {
@@ -919,13 +1008,17 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
} }
else else
{ {
DragWindow(window, ev->where, &qd.screenBits.bounds); DragWindow(window, ev->where, &screenBits.bounds);
if (win) if (win)
{ {
GrafPtr port ; GrafPtr port ;
GetPort( &port ) ; GetPort( &port ) ;
Point pt = { 0, 0 } ; Point pt = { 0, 0 } ;
SetPort( window ) ; #if TARGET_CARBON
SetPort( GetWindowPort(window) ) ;
#else
SetPort( (window) ) ;
#endif
SetOrigin( 0 , 0 ) ; SetOrigin( 0 , 0 ) ;
LocalToGlobal( &pt ) ; LocalToGlobal( &pt ) ;
SetPort( port ) ; SetPort( port ) ;
@@ -944,7 +1037,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
s_lastMouseDown = 0; s_lastMouseDown = 0;
break; break;
case inGrow: case inGrow:
int growResult = GrowWindow(window , ev->where, &qd.screenBits.bounds); int growResult = GrowWindow(window , ev->where, &screenBits.bounds);
if (growResult != 0) if (growResult != 0)
{ {
int newWidth = LoWord(growResult); int newWidth = LoWord(growResult);
@@ -969,8 +1062,13 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
// TODO setup size event // TODO setup size event
ZoomWindow( window , windowPart , false ) ; ZoomWindow( window , windowPart , false ) ;
if (win) if (win)
win->SetSize( -1, -1, window->portRect.right-window->portRect.left , {
window->portRect.bottom-window->portRect.top, wxSIZE_USE_EXISTING); Rect tempRect ;
GetWindowPortBounds(window, &tempRect ) ;
win->SetSize( -1, -1, tempRect.right-tempRect.left ,
tempRect.bottom-tempRect.top, wxSIZE_USE_EXISTING);
}
} }
s_lastMouseDown = 0; s_lastMouseDown = 0;
break; break;
@@ -980,6 +1078,17 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
break ; break ;
case inContent : case inContent :
{
GrafPtr port ;
GetPort( &port ) ;
#if TARGET_CARBON
SetPort( GetWindowPort(window) ) ;
#else
SetPort( (window) ) ;
#endif
SetOrigin( 0 , 0 ) ;
SetPort( port ) ;
}
if ( window != frontWindow ) if ( window != frontWindow )
{ {
if ( s_macIsInModalLoop ) if ( s_macIsInModalLoop )
@@ -1140,6 +1249,8 @@ long wxMacTranslateKey(unsigned char key, unsigned char code)
void wxApp::MacHandleKeyDownEvent( EventRecord *ev ) void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
{ {
wxToolTip::RemoveToolTips() ;
UInt32 menuresult = UMAMenuEvent(ev) ; UInt32 menuresult = UMAMenuEvent(ev) ;
if ( HiWord( menuresult ) ) if ( HiWord( menuresult ) )
MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ; MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
@@ -1268,12 +1379,14 @@ void wxApp::MacHandleDiskEvent( EventRecord *ev )
{ {
if ( HiWord( ev->message ) != noErr ) if ( HiWord( ev->message ) != noErr )
{ {
#if !TARGET_CARBON
OSErr err ; OSErr err ;
Point point ; Point point ;
SetPt( &point , 100 , 100 ) ; SetPt( &point , 100 , 100 ) ;
err = DIBadMount( point , ev->message ) ; err = DIBadMount( point , ev->message ) ;
wxASSERT( err == noErr ) ; wxASSERT( err == noErr ) ;
#endif
} }
} }

View File

@@ -25,8 +25,10 @@ extern "C"
#include "xpm.h" #include "xpm.h"
} ; } ;
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
#endif
#include <PictUtils.h> #include <PictUtils.h>
@@ -69,16 +71,7 @@ GWorldPtr wxMacCreateGWorld( int height , int width , int depth )
if ( depth < 0 ) if ( depth < 0 )
{ {
// get max pixel depth depth = wxDisplayDepth() ;
CGrafPtr port ;
GetCWMgrPort( &port ) ;
GDHandle maxDevice ;
maxDevice = GetMaxDevice( &port->portRect ) ;
if ( maxDevice )
depth = (**((**maxDevice).gdPMap)).pixelSize ;
else
depth = 8 ;
} }
err = NewGWorld( &port , depth , &rect , NULL , NULL , 0 ) ; err = NewGWorld( &port , depth , &rect , NULL , NULL , 0 ) ;
@@ -178,6 +171,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
GetGWorld( &origPort , &origDevice ) ; GetGWorld( &origPort , &origDevice ) ;
SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ; SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
LockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ;
// bits is a word aligned array // bits is a word aligned array
@@ -211,6 +205,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
} }
} }
UnlockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ;
SetGWorld( origPort , origDevice ) ; SetGWorld( origPort , origDevice ) ;
} }
@@ -514,6 +509,8 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
} }
m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 ) ; m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 ) ;
LockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
LockPixels( GetGWorldPixMap( (CGrafPtr) ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap ) ) ;
RGBColor maskColor = colour.GetPixel() ; RGBColor maskColor = colour.GetPixel() ;
// this is not very efficient, but I can't think // this is not very efficient, but I can't think
@@ -545,6 +542,8 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
} }
} }
} }
UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
UnlockPixels( GetGWorldPixMap( ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap ) ) ;
SetGWorld( origPort , origDevice ) ; SetGWorld( origPort , origDevice ) ;
return TRUE; return TRUE;
@@ -712,8 +711,8 @@ bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
if (dc) if (dc)
{ {
if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap)) if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap))
{ /* for following SetPixel */ {
/* fill the XImage struct 'by hand' */
ximage.width = M_BITMAPHANDLERDATA->m_width; ximage.width = M_BITMAPHANDLERDATA->m_width;
ximage.height = M_BITMAPHANDLERDATA->m_height; ximage.height = M_BITMAPHANDLERDATA->m_height;
ximage.depth = M_BITMAPHANDLERDATA->m_depth; ximage.depth = M_BITMAPHANDLERDATA->m_depth;
@@ -725,7 +724,7 @@ bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
DeleteDC(dc); DeleteDC(dc);
if (errorStatus == XpmSuccess) if (errorStatus == XpmSuccess)
return TRUE; /* no error */ return TRUE;
else else
return FALSE; return FALSE;
} else return FALSE; } else return FALSE;
@@ -809,19 +808,6 @@ bool wxBMPResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long
int desiredWidth, int desiredHeight) int desiredWidth, int desiredHeight)
{ {
// TODO: load colourmap. // TODO: load colourmap.
/*
M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ::LoadBitmap(wxGetInstance(), name);
if (M_BITMAPHANDLERDATA->m_hBitmap)
{
M_BITMAPHANDLERDATA->m_ok = TRUE;
BITMAP bm;
GetObject((HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap, sizeof(BITMAP), (LPSTR) &bm);
M_BITMAPHANDLERDATA->m_width = bm.bmWidth;
M_BITMAPHANDLERDATA->m_height = bm.bmHeight;
M_BITMAPHANDLERDATA->m_depth = bm.bmBitsPixel;
return TRUE;
}
*/
// it's probably not found // it's probably not found
wxLogError("Can't load bitmap '%s' from resources! Check .rc file.", name.c_str()); wxLogError("Can't load bitmap '%s' from resources! Check .rc file.", name.c_str());
@@ -852,11 +838,6 @@ bool wxBMPFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla
#if USE_IMAGE_LOADING_IN_MSW #if USE_IMAGE_LOADING_IN_MSW
wxPalette *palette = NULL; wxPalette *palette = NULL;
bool success = FALSE; bool success = FALSE;
/*
if (type & wxBITMAP_DISCARD_COLOURMAP)
success = wxLoadIntoBitmap(WXSTRINGCAST name, bitmap);
else
*/
success = (wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0); success = (wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0);
if (!success && palette) if (!success && palette)
{ {
@@ -884,7 +865,6 @@ bool wxBMPFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
} }
void wxBitmap::CleanUpHandlers() void wxBitmap::CleanUpHandlers()
{ {
wxNode *node = sm_handlers.First(); wxNode *node = sm_handlers.First();
@@ -903,7 +883,7 @@ void wxBitmap::InitStandardHandlers()
AddHandler( new wxPICTResourceHandler ) ; AddHandler( new wxPICTResourceHandler ) ;
AddHandler( new wxICONResourceHandler ) ; AddHandler( new wxICONResourceHandler ) ;
AddHandler(new wxXPMFileHandler); AddHandler(new wxXPMFileHandler);
AddHandler(new wxXPMDataHandler); AddHandler(new wxXPMDataHandler);
AddHandler(new wxBMPResourceHandler); AddHandler(new wxBMPResourceHandler);
AddHandler(new wxBMPFileHandler); AddHandler(new wxBMPFileHandler);
} }

View File

@@ -15,11 +15,13 @@
#include "wx/bmpbuttn.h" #include "wx/bmpbuttn.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton) IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
PicHandle MakePict(GWorldPtr wp) ; PicHandle MakePict(GWorldPtr wp, GWorldPtr mask ) ;
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
const wxPoint& pos, const wxPoint& pos,
@@ -48,8 +50,6 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
if ( height == -1 && bitmap.Ok()) if ( height == -1 && bitmap.Ok())
height = bitmap.GetHeight() + 2*m_marginY; height = bitmap.GetHeight() + 2*m_marginY;
m_macHorizontalBorder = 0 ; // additional pixels around the real control
m_macVerticalBorder = 0 ;
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
@@ -68,7 +68,14 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
icon = bmap->m_hPict ; icon = bmap->m_hPict ;
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld ) else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
{ {
icon = MakePict( bmap->m_hBitmap ) ; if ( m_buttonBitmap.GetMask() )
{
icon = MakePict( bmap->m_hBitmap , m_buttonBitmap.GetMask()->GetMaskBitmap() ) ;
}
else
{
icon = MakePict( bmap->m_hBitmap , NULL ) ;
}
} }
} }
ControlButtonContentInfo info ; ControlButtonContentInfo info ;
@@ -94,7 +101,14 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
icon = bmap->m_hPict ; icon = bmap->m_hPict ;
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld ) else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
{ {
icon = MakePict( bmap->m_hBitmap ) ; if ( m_buttonBitmap.GetMask() )
{
icon = MakePict( bmap->m_hBitmap , m_buttonBitmap.GetMask()->GetMaskBitmap() ) ;
}
else
{
icon = MakePict( bmap->m_hBitmap , NULL ) ;
}
} }
} }
ControlButtonContentInfo info ; ControlButtonContentInfo info ;

View File

@@ -17,7 +17,9 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/brush.h" #include "wx/brush.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
#endif
wxBrushRefData::wxBrushRefData() wxBrushRefData::wxBrushRefData()
{ {

View File

@@ -15,7 +15,9 @@
#include "wx/button.h" #include "wx/button.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
// Button // Button
@@ -29,8 +31,6 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
{ {
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
m_macHorizontalBorder = 2 ; // additional pixels around the real control
m_macVerticalBorder = 2 ;
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
@@ -66,22 +66,32 @@ void wxButton::SetDefault()
wxSize wxButton::DoGetBestSize() const wxSize wxButton::DoGetBestSize() const
{ {
int wBtn = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder; int wBtn = m_label.Length() * 8 + 12 ;
int hBtn = 13 + 2 * m_macVerticalBorder; int hBtn = 20 ;
if ( wBtn < 80 )
wBtn = 80 ;
return wxSize(wBtn, hBtn); return wxSize(wBtn, hBtn);
} }
wxSize wxButton::GetDefaultSize() wxSize wxButton::GetDefaultSize()
{ {
int wBtn = 15 * 8 + 12 + 2 * 2; int wBtn = 80 /* + 2 * m_macHorizontalBorder */ ;
int hBtn = 13 + 2 * 2; int hBtn = 20 /* + 2 * m_macVerticalBorder */ ;
return wxSize(wBtn, hBtn); return wxSize(wBtn, hBtn);
} }
void wxButton::Command (wxCommandEvent & event) void wxButton::Command (wxCommandEvent & event)
{ {
if ( m_macControl )
{
HiliteControl( m_macControl , kControlButtonPart ) ;
unsigned long finalTicks ;
Delay( 8 , &finalTicks ) ;
HiliteControl( m_macControl , 0 ) ;
}
ProcessCommand (event); ProcessCommand (event);
} }

View File

@@ -17,7 +17,9 @@
#include "wx/accel.h" #include "wx/accel.h"
#include "wx/string.h" #include "wx/string.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject)
#endif
class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData
{ {

View File

@@ -1,3 +1,5 @@
#if !TARGET_CARBON
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
#include <wx/mac/aga.h> #include <wx/mac/aga.h>
#include <extcdef.h> #include <extcdef.h>
@@ -600,6 +602,10 @@ void AGADeactivateControl( ControlHandle inControl )
} }
} }
} }
else
{
::HiliteControl( inControl , 255 ) ;
}
} }
void AGAActivateControl( ControlHandle inControl ) void AGAActivateControl( ControlHandle inControl )
@@ -615,6 +621,10 @@ void AGAActivateControl( ControlHandle inControl )
} }
} }
} }
else
{
::HiliteControl( inControl , 0 ) ;
}
} }
OSErr AGASetKeyboardFocus (WindowPtr inWindow, OSErr AGASetKeyboardFocus (WindowPtr inWindow,
@@ -718,6 +728,7 @@ void DisposeExtCDEFInfo( ControlHandle theControl)
DisposeHandle( info->children ) ; DisposeHandle( info->children ) ;
info->children = NULL ; info->children = NULL ;
free( (void*) (**theControl).contrlRfCon ) ; free( (void*) (**theControl).contrlRfCon ) ;
(**theControl).contrlRfCon = NULL ;
} }
} }
} }
@@ -922,51 +933,6 @@ void AGASetFontStyle( ControlFontStyleRec *fontstyle )
::RGBBackColor( &fontstyle->backColor ) ; ::RGBBackColor( &fontstyle->backColor ) ;
} ; } ;
class AGAPortHelper
{
public :
AGAPortHelper()
{
GetPenState( &oldPenState ) ;
GetBackColor( &oldBackColor ) ;
GetForeColor( &oldForeColor ) ;
GetPort( &port ) ;
clip = NewRgn() ;
GetClip( clip );
font = port->txFont;
size = port->txSize;
style = port->txFace;
mode = port->txMode;
}
~AGAPortHelper()
{
SetPort( port ) ;
SetClip( clip ) ;
DisposeRgn( clip ) ;
RGBForeColor(&oldForeColor);
RGBBackColor(&oldBackColor);
SetPenState(&oldPenState);
TextFont( font );
TextSize( size );
TextFace( style );
TextMode( mode );
}
private :
GrafPtr port ;
PenState oldPenState ;
RGBColor oldForeColor ;
RGBColor oldBackColor ;
RgnHandle clip ;
short font ;
short size ;
short style ;
short mode ;
} ;
pascal SInt32 AGAProgressBarDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) pascal SInt32 AGAProgressBarDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param)
{ {
switch( message ) switch( message )
@@ -1079,7 +1045,7 @@ pascal SInt32 AGABevelButtonDefProc (SInt16 procID, ControlHandle theControl, Co
return 0 ; return 0 ;
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
Boolean mRadioBehavior = false ; Boolean mRadioBehavior = false ;
@@ -1219,7 +1185,7 @@ pascal SInt32 AGAButtonDefProc (SInt16 procID, ControlHandle theControl, Control
return 0 ; return 0 ;
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
Boolean mRadioBehavior = false ; Boolean mRadioBehavior = false ;
@@ -1456,7 +1422,7 @@ pascal SInt32 AGACheckBoxDefProc (SInt16 procID, ControlHandle theControl, Contr
return 0 ; return 0 ;
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
Rect frame = (**theControl).contrlRect ; Rect frame = (**theControl).contrlRect ;
Boolean hasColor = true; Boolean hasColor = true;
Boolean disabled = (*theControl)->contrlHilite == 255 ; Boolean disabled = (*theControl)->contrlHilite == 255 ;
@@ -1844,7 +1810,7 @@ pascal SInt32 AGAStaticGroupBoxTextDefProc (SInt16 procID, ControlHandle theCont
{ {
bool disabled = false ; bool disabled = false ;
bool hasColor = true ; bool hasColor = true ;
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
FontInfo fi ; FontInfo fi ;
::GetFontInfo( &fi ) ; ::GetFontInfo( &fi ) ;
@@ -1930,7 +1896,7 @@ pascal SInt32 AGAStaticTextDefProc (SInt16 procID, ControlHandle theControl, Con
return 0 ; return 0 ;
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
int x = (**theControl).contrlRect.left ; int x = (**theControl).contrlRect.left ;
int y = (**theControl).contrlRect.top ; int y = (**theControl).contrlRect.top ;
@@ -2125,7 +2091,7 @@ pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, Contr
{ {
case initCntl : case initCntl :
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
SetPort( (**theControl).contrlOwner ) ; SetPort( (**theControl).contrlOwner ) ;
::TextFont( kFontIDGeneva ) ; ::TextFont( kFontIDGeneva ) ;
::TextSize( 10 ) ; ::TextSize( 10 ) ;
@@ -2147,7 +2113,7 @@ pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, Contr
break ; break ;
case drawCntl : case drawCntl :
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
SetPort( (**theControl).contrlOwner ) ; SetPort( (**theControl).contrlOwner ) ;
RGBBackColor( &gAGARamp[ kAGAWhite ] ) ; RGBBackColor( &gAGARamp[ kAGAWhite ] ) ;
@@ -2254,9 +2220,8 @@ pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, Contr
break ; break ;
case kControlMsgKeyDown : case kControlMsgKeyDown :
{ {
AGAPortHelper help() ; AGAPortHelper help( (**theControl).contrlOwner ) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
SetPort( (**theControl).contrlOwner ) ;
RGBBackColor( &gAGARamp[ kAGAWhite ] ) ; RGBBackColor( &gAGARamp[ kAGAWhite ] ) ;
RGBForeColor( &gAGARamp[ kAGABlack ] ) ; RGBForeColor( &gAGARamp[ kAGABlack ] ) ;
ControlKeyDownRec * rec = (ControlKeyDownRec*) param ; ControlKeyDownRec * rec = (ControlKeyDownRec*) param ;
@@ -2364,7 +2329,7 @@ pascal SInt32 AGAListControlDefProc (SInt16 procID, ControlHandle theControl, Co
break ; break ;
case drawCntl : case drawCntl :
{ {
AGAPortHelper help() ; AGAPortHelper help((**theControl).contrlOwner) ;
AGASetFontStyle( &info->fontStyle ) ; AGASetFontStyle( &info->fontStyle ) ;
RGBBackColor( &gAGARamp[ kAGAWhite ] ) ; RGBBackColor( &gAGARamp[ kAGAWhite ] ) ;
EraseRect( &(**theControl).contrlRect ) ; EraseRect( &(**theControl).contrlRect ) ;
@@ -2578,4 +2543,78 @@ void AGASetThemeWindowBackground (WindowRef inWindow,
SetPort( port ) ; SetPort( port ) ;
} }
void AGAApplyThemeBackground(ThemeBackgroundKind inKind,
const Rect * bounds,
ThemeDrawState inState,
SInt16 inDepth,
Boolean inColorDev)
{
}
#endif
AGAPortHelper::AGAPortHelper( GrafPtr newport)
{
GetPort( &port ) ;
SetPort( newport ) ;
// wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ;
GetPenState( &oldPenState ) ;
GetBackColor( &oldBackColor ) ;
GetForeColor( &oldForeColor ) ;
clip = NewRgn() ;
GetClip( clip );
font = GetPortTextFont( newport);
size = GetPortTextSize( newport);
style = GetPortTextFace( newport);
mode = GetPortTextMode( newport);
nport = newport ;
}
AGAPortHelper::AGAPortHelper()
{
clip = NULL ;
}
void AGAPortHelper::Setup( GrafPtr newport )
{
GetPort( &port ) ;
SetPort( newport ) ;
// wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ;
GetPenState( &oldPenState ) ;
GetBackColor( &oldBackColor ) ;
GetForeColor( &oldForeColor ) ;
clip = NewRgn() ;
GetClip( clip );
font = GetPortTextFont( newport);
size = GetPortTextSize( newport);
style = GetPortTextFace( newport);
mode = GetPortTextMode( newport);
nport = newport ;
}
void AGAPortHelper::Clear()
{
if ( clip )
{
DisposeRgn( clip ) ;
clip = NULL ;
}
}
AGAPortHelper::~AGAPortHelper()
{
if ( clip )
{
SetPort( nport ) ;
SetClip( clip ) ;
DisposeRgn( clip ) ;
RGBForeColor(&oldForeColor);
RGBBackColor(&oldBackColor);
SetPenState(&oldPenState);
TextFont( font );
TextSize( size );
TextFace( style );
TextMode( mode );
SetPort( port ) ;
}
}

View File

@@ -28,7 +28,7 @@
#include "wx/log.h" #include "wx/log.h"
#include "wx/module.h" #include "wx/module.h"
#include "wx/memory.h" #include "wx/memory.h"
#include "wx/tooltip.h"
#if wxUSE_WX_RESOURCES #if wxUSE_WX_RESOURCES
#include "wx/resource.h" #include "wx/resource.h"
#endif #endif
@@ -44,6 +44,12 @@
#include "apprsrc.h" #include "apprsrc.h"
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
#include <wx/mac/macnotfy.h>
#if wxUSE_SOCKETS
#include <OpenTransport.h>
#include <OpenTptInternet.h>
#endif
extern char *wxBuffer; extern char *wxBuffer;
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
@@ -52,10 +58,14 @@ extern wxList *wxWinMacControlList;
wxApp *wxTheApp = NULL; wxApp *wxTheApp = NULL;
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle) EVT_IDLE(wxApp::OnIdle)
EVT_END_SESSION(wxApp::OnEndSession)
EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
const short kMacMinHeap = (29 * 1024) ; const short kMacMinHeap = (29 * 1024) ;
@@ -76,25 +86,25 @@ bool wxApp::s_macSupportPCMenuShortcuts = true ;
long wxApp::s_macAboutMenuItemId = wxID_ABOUT ; long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
wxString wxApp::s_macHelpMenuTitleName = "&Help" ; wxString wxApp::s_macHelpMenuTitleName = "&Help" ;
OSErr AEHandleODoc( AppleEvent *event , AppleEvent *reply , long refcon ) pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEODoc( event , reply) ; return wxTheApp->MacHandleAEODoc( event , reply) ;
} }
OSErr AEHandleOApp( AppleEvent *event , AppleEvent *reply , long refcon ) pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEOApp( event , reply ) ; return wxTheApp->MacHandleAEOApp( event , reply ) ;
} }
OSErr AEHandlePDoc( AppleEvent *event , AppleEvent *reply , long refcon ) pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEPDoc( event , reply ) ; return wxTheApp->MacHandleAEPDoc( event , reply ) ;
} }
OSErr AEHandleQuit( AppleEvent *event , AppleEvent *reply , long refcon ) pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
{ {
wxApp* app = (wxApp*) refcon ; wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEQuit( event , reply) ; return wxTheApp->MacHandleAEQuit( event , reply) ;
@@ -133,14 +143,14 @@ OSErr wxApp::MacHandleAEQuit(AppleEvent *event , AppleEvent *reply)
return noErr ; return noErr ;
} }
char StringMac[] = "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" char StringMac[] = "\x0d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf" "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf"
"\xb1\xb4\xb5\xb6\xbb\xbc\xbe\xbf" "\xb1\xb4\xb5\xb6\xbb\xbc\xbe\xbf"
"\xc0\xc1\xc2\xc4\xc7\xc8\xc9\xcb\xcc\xcd\xce\xcf" "\xc0\xc1\xc2\xc4\xc7\xc8\xc9\xcb\xcc\xcd\xce\xcf"
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xca\xdb" ; "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xca\xdb" ;
char StringANSI[] = "\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8" char StringANSI[] = "\x0a\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8"
"\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC" "\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC"
"\x86\xBA\xA2\xA3\xA7\x95\xB6\xDF\xAE\xA9\x99\xB4\xA8\xC6\xD8" "\x86\xBA\xA2\xA3\xA7\x95\xB6\xDF\xAE\xA9\x99\xB4\xA8\xC6\xD8"
"\xB1\xA5\xB5\xF0\xAA\xBA\xE6\xF8" "\xB1\xA5\xB5\xF0\xAA\xBA\xE6\xF8"
@@ -321,9 +331,6 @@ bool wxApp::Initialize()
AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) , (long) wxTheApp , FALSE ) ; AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) , (long) wxTheApp , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , (long) wxTheApp , FALSE ) ; AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , (long) wxTheApp , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , (long) wxTheApp , FALSE ) ; AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , (long) wxTheApp , FALSE ) ;
#if 0
GUSISetup(GUSIwithInternetSockets);
#endif
// test the minimal configuration necessary // test the minimal configuration necessary
@@ -378,7 +385,7 @@ bool wxApp::Initialize()
} }
#if __option(profile) #if __option(profile)
ProfilerInit( collectDetailed, bestTimeBase , 20000 , 30 ) ; ProfilerInit( collectDetailed, bestTimeBase , 20000 , 40 ) ;
#endif #endif
// now avoid exceptions thrown for new (bad_alloc) // now avoid exceptions thrown for new (bad_alloc)
@@ -393,17 +400,15 @@ bool wxApp::Initialize()
wxBuffer = new char[BUFSIZ + 512]; wxBuffer = new char[BUFSIZ + 512];
#endif #endif
/* No longer used
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
streambuf* sBuf = new wxDebugStreamBuf;
ostream* oStr = new ostream(sBuf) ;
wxDebugContext::SetStream(oStr, sBuf);
#endif
*/
wxClassInfo::InitializeClasses(); wxClassInfo::InitializeClasses();
#if wxUSE_RESOURCES
// wxGetResource(wxT("wxWindows"), wxT("OsVersion"), &wxOsVersion);
#endif
#if wxUSE_THREADS
wxPendingEventsLocker = new wxCriticalSection;
#endif
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
wxTheColourDatabase->Initialize(); wxTheColourDatabase->Initialize();
@@ -423,13 +428,29 @@ bool wxApp::Initialize()
wxWinMacWindowList = new wxList(wxKEY_INTEGER); wxWinMacWindowList = new wxList(wxKEY_INTEGER);
wxWinMacControlList = new wxList(wxKEY_INTEGER); wxWinMacControlList = new wxList(wxKEY_INTEGER);
UMAShowArrowCursor() ; wxMacCreateNotifierTable() ;
UMAShowArrowCursor() ;
return TRUE; return TRUE;
} }
void wxApp::CleanUp() void wxApp::CleanUp()
{ {
#if wxUSE_LOG
// flush the logged messages if any and install a 'safer' log target: the
// default one (wxLogGui) can't be used after the resources are freed just
// below and the user suppliedo ne might be even more unsafe (using any
// wxWindows GUI function is unsafe starting from now)
wxLog::DontCreateOnDemand();
// this will flush the old messages if any
delete wxLog::SetActiveTarget(new wxLogStderr);
#endif // wxUSE_LOG
// One last chance for pending objects to be cleaned up
wxTheApp->DeletePendingObjects();
wxModule::CleanUpModules(); wxModule::CleanUpModules();
#if wxUSE_WX_RESOURCES #if wxUSE_WX_RESOURCES
@@ -438,19 +459,8 @@ void wxApp::CleanUp()
wxDeleteStockObjects() ; wxDeleteStockObjects() ;
// Destroy all GDI lists, etc. // Destroy all GDI lists, etc.
wxDeleteStockLists();
delete wxTheBrushList;
wxTheBrushList = NULL;
delete wxThePenList;
wxThePenList = NULL;
delete wxTheFontList;
wxTheFontList = NULL;
delete wxTheBitmapList;
wxTheBitmapList = NULL;
delete wxTheColourDatabase; delete wxTheColourDatabase;
wxTheColourDatabase = NULL; wxTheColourDatabase = NULL;
@@ -460,9 +470,17 @@ void wxApp::CleanUp()
delete[] wxBuffer; delete[] wxBuffer;
wxBuffer = NULL; wxBuffer = NULL;
wxMacDestroyNotifierTable() ;
if (wxWinMacWindowList) if (wxWinMacWindowList)
delete wxWinMacWindowList ; delete wxWinMacWindowList ;
delete wxPendingEvents;
#if wxUSE_THREADS
delete wxPendingEventsLocker;
// If we don't do the following, we get an apparent memory leak.
((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
#endif
wxClassInfo::CleanUpClasses(); wxClassInfo::CleanUpClasses();
#if __option(profile) #if __option(profile)
@@ -474,33 +492,33 @@ void wxApp::CleanUp()
wxTheApp = NULL; wxTheApp = NULL;
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
// At this point we want to check if there are any memory // At this point we want to check if there are any memory
// blocks that aren't part of the wxDebugContext itself, // blocks that aren't part of the wxDebugContext itself,
// as a special case. Then when dumping we need to ignore // as a special case. Then when dumping we need to ignore
// wxDebugContext, too. // wxDebugContext, too.
if (wxDebugContext::CountObjectsLeft() > 0) if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
{ {
wxTrace("There were memory leaks.\n"); wxLogDebug(wxT("There were memory leaks."));
wxDebugContext::Dump(); wxDebugContext::Dump();
wxDebugContext::PrintStatistics(); wxDebugContext::PrintStatistics();
} }
// wxDebugContext::SetStream(NULL, NULL); // wxDebugContext::SetStream(NULL, NULL);
#endif #endif
// do it as the very last thing because everything else can log messages #if wxUSE_LOG
wxLog::DontCreateOnDemand(); // do it as the very last thing because everything else can log messages
// do it as the very last thing because everything else can log messages delete wxLog::SetActiveTarget(NULL);
delete wxLog::SetActiveTarget(NULL); #endif // wxUSE_LOG
::PrClose() ;
if (s_macCursorRgn) if (s_macCursorRgn)
::DisposeRgn(s_macCursorRgn); ::DisposeRgn(s_macCursorRgn);
#if 0 #if 0
TerminateAE() ; TerminateAE() ;
#endif #endif
} }
int wxEntry( int argc, char *argv[] ) int wxEntry( int argc, char *argv[] , bool enterLoop )
{ {
#ifdef __MWERKS__ #ifdef __MWERKS__
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
@@ -513,27 +531,24 @@ int wxEntry( int argc, char *argv[] )
wxDebugContext::SetCheckpoint(); wxDebugContext::SetCheckpoint();
#endif #endif
#endif #endif
if (!wxApp::Initialize()) if (!wxApp::Initialize())
return FALSE; return 0;
if (!wxTheApp) // create the application object or ensure that one already exists
{ if (!wxTheApp)
if (!wxApp::GetInitializerFunction())
{ {
printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" ); // The app may have declared a global application object, but we recommend
return 0; // the IMPLEMENT_APP macro is used instead, which sets an initializer
}; // function for delayed, dynamic app object construction.
wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
wxT("No initializer - use IMPLEMENT_APP macro.") );
wxTheApp = (wxApp*) (* wxApp::GetInitializerFunction()) (); wxTheApp = (wxApp*) (*wxApp::GetInitializerFunction()) ();
}; }
if (!wxTheApp) wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
{
printf( "wxWindows error: wxTheApp == NULL\n" );
return 0;
};
#ifdef __WXMAC__ #ifdef __WXMAC__
argc = 1 ; // currently we don't support files as parameters argc = 0 ; // currently we don't support files as parameters
#endif #endif
wxTheApp->argc = argc; wxTheApp->argc = argc;
@@ -549,42 +564,58 @@ int wxEntry( int argc, char *argv[] )
// into wxTopLevelWindows by getting created // into wxTopLevelWindows by getting created
// in OnInit(). // in OnInit().
if (!wxTheApp->OnInit()) return 0;
int retValue = 0; int retValue = 0;
if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun(); if ( wxTheApp->OnInit() )
{
if ( enterLoop )
{
retValue = wxTheApp->OnRun();
}
else
// We want to initialize, but not run or exit immediately.
return 1;
}
//else: app initialization failed, so we skipped OnRun()
if (wxTheApp->GetTopWindow()) wxWindow *topWindow = wxTheApp->GetTopWindow();
{ if ( topWindow )
delete wxTheApp->GetTopWindow(); {
wxTheApp->SetTopWindow(NULL); // Forcibly delete the window.
} if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
topWindow->IsKindOf(CLASSINFO(wxDialog)) )
{
topWindow->Close(TRUE);
wxTheApp->DeletePendingObjects();
}
else
{
delete topWindow;
wxTheApp->SetTopWindow(NULL);
}
}
wxTheApp->DeletePendingObjects(); wxTheApp->OnExit();
wxTheApp->OnExit(); wxApp::CleanUp();
wxApp::CleanUp(); return retValue;
return retValue;
}; };
// Static member initialization // Static member initialization
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL; wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
wxApp::wxApp() wxApp::wxApp()
{ {
m_topWindow = NULL; m_topWindow = NULL;
wxTheApp = this; wxTheApp = this;
m_className = "";
m_wantDebugOutput = TRUE ; m_wantDebugOutput = TRUE ;
m_appName = "";
argc = 0; argc = 0;
argv = NULL; argv = NULL;
m_printMode = wxPRINT_WINDOWS; m_printMode = wxPRINT_WINDOWS;
m_exitOnFrameDelete = TRUE; m_exitOnFrameDelete = TRUE;
m_auto3D = TRUE; m_auto3D = TRUE;
} }
@@ -640,13 +671,14 @@ void wxApp::Dispatch()
void wxApp::OnIdle(wxIdleEvent& event) void wxApp::OnIdle(wxIdleEvent& event)
{ {
static bool inOnIdle = FALSE; static bool s_inOnIdle = FALSE;
// Avoid recursion (via ProcessEvent default case) // Avoid recursion (via ProcessEvent default case)
if (inOnIdle) if ( s_inOnIdle )
return; return;
inOnIdle = TRUE;
s_inOnIdle = TRUE;
// 'Garbage' collection of windows deleted with Close(). // 'Garbage' collection of windows deleted with Close().
DeletePendingObjects(); DeletePendingObjects();
@@ -662,13 +694,17 @@ void wxApp::OnIdle(wxIdleEvent& event)
if (needMore) if (needMore)
event.RequestMore(TRUE); event.RequestMore(TRUE);
inOnIdle = FALSE; // If they are pending events, we must process them: pending events are
// either events to the threads other than main or events posted with
// wxPostEvent() functions
wxMacProcessNotifierAndPendingEvents();
s_inOnIdle = FALSE;
} }
void wxWakeUpIdle() void wxWakeUpIdle()
{ {
// **** please implement me! **** wxMacWakeUp() ;
// Wake up the idle handler processor, even if it is in another thread...
} }
// Send idle event to all top-level windows // Send idle event to all top-level windows
@@ -729,32 +765,76 @@ void wxApp::DeletePendingObjects()
} }
} }
wxLog* wxApp::CreateLogTarget() wxIcon
wxApp::GetStdIcon(int which) const
{ {
return new wxLogGui; switch(which)
} {
case wxICON_INFORMATION:
return wxIcon("wxICON_INFO");
wxWindow* wxApp::GetTopWindow() const case wxICON_QUESTION:
{ return wxIcon("wxICON_QUESTION");
if (m_topWindow)
return m_topWindow; case wxICON_EXCLAMATION:
else if (wxTopLevelWindows.Number() > 0) return wxIcon("wxICON_WARNING");
return (wxWindow*) wxTopLevelWindows.First()->Data();
else default:
return NULL; wxFAIL_MSG(wxT("requested non existent standard icon"));
// still fall through
case wxICON_HAND:
return wxIcon("wxICON_ERROR");
}
} }
void wxExit() void wxExit()
{ {
wxApp::CleanUp(); wxLogError(_("Fatal error: exiting"));
wxApp::CleanUp();
::ExitToShell() ; ::ExitToShell() ;
} }
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
{
if (GetTopWindow())
GetTopWindow()->Close(TRUE);
}
// Default behaviour: close the application with prompts. The
// user can veto the close, and therefore the end session.
void wxApp::OnQueryEndSession(wxCloseEvent& event)
{
if (GetTopWindow())
{
if (!GetTopWindow()->Close(!event.CanVeto()))
event.Veto(TRUE);
}
}
extern "C" void wxCYield() ;
void wxCYield()
{
wxYield() ;
}
// Yield to other processes // Yield to other processes
bool wxYield() bool wxYield()
{ {
// YieldToAnyThread() ; #if wxUSE_THREADS
SystemTask() ; YieldToAnyThread() ;
#endif
EventRecord event ;
long sleepTime = 0 ; //::GetCaretTime();
while ( !wxTheApp->IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, wxApp::s_macCursorRgn))
{
wxTheApp->MacHandleOneEvent( &event );
}
wxMacProcessNotifierAndPendingEvents() ;
return TRUE; return TRUE;
} }
@@ -762,6 +842,12 @@ bool wxYield()
void wxApp::MacSuspend( bool convertClipboard ) void wxApp::MacSuspend( bool convertClipboard )
{ {
// we have to deactive the window manually
wxWindow* window = GetTopWindow() ;
if ( window )
window->MacActivate( MacGetCurrentEvent() , false ) ;
s_lastMouseDown = 0 ; s_lastMouseDown = 0 ;
if( convertClipboard ) if( convertClipboard )
{ {
@@ -784,13 +870,10 @@ void wxApp::MacResume( bool convertClipboard )
void wxApp::MacConvertPrivateToPublicScrap() void wxApp::MacConvertPrivateToPublicScrap()
{ {
::ZeroScrap();
::TEToScrap();
} }
void wxApp::MacConvertPublicToPrivateScrap() void wxApp::MacConvertPublicToPrivateScrap()
{ {
::TEFromScrap() ;
} }
void wxApp::MacDoOneEvent() void wxApp::MacDoOneEvent()
@@ -817,9 +900,7 @@ void wxApp::MacDoOneEvent()
// repeaters // repeaters
#if 0 wxMacProcessNotifierAndPendingEvents() ;
wxMacProcessSocketEvents() ;
#endif
} }
void wxApp::MacHandleOneEvent( EventRecord *ev ) void wxApp::MacHandleOneEvent( EventRecord *ev )
@@ -874,6 +955,7 @@ void wxApp::MacHandleOneEvent( EventRecord *ev )
default: default:
break; break;
} }
wxMacProcessNotifierAndPendingEvents() ;
} }
void wxApp::MacHandleHighLevelEvent( EventRecord *ev ) void wxApp::MacHandleHighLevelEvent( EventRecord *ev )
@@ -885,6 +967,8 @@ bool s_macIsInModalLoop = false ;
void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
{ {
wxToolTip::RemoveToolTips() ;
WindowRef window; WindowRef window;
WindowRef frontWindow = UMAFrontNonFloatingWindow() ; WindowRef frontWindow = UMAFrontNonFloatingWindow() ;
WindowAttributes frontWindowAttributes = NULL ; WindowAttributes frontWindowAttributes = NULL ;
@@ -894,6 +978,9 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
short windowPart = ::FindWindow(ev->where, &window); short windowPart = ::FindWindow(ev->where, &window);
wxWindow* win = wxFindWinFromMacWindow( window ) ; wxWindow* win = wxFindWinFromMacWindow( window ) ;
BitMap screenBits;
GetQDGlobalsScreenBits( &screenBits );
switch (windowPart) switch (windowPart)
{ {
case inMenuBar : case inMenuBar :
@@ -908,10 +995,12 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
s_lastMouseDown = 0; s_lastMouseDown = 0;
} }
break ; break ;
#if !TARGET_CARBON
case inSysWindow : case inSysWindow :
SystemClick( ev , window ) ; SystemClick( ev , window ) ;
s_lastMouseDown = 0; s_lastMouseDown = 0;
break ; break ;
#endif
case inDrag : case inDrag :
if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) ) if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) )
{ {
@@ -919,13 +1008,17 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
} }
else else
{ {
DragWindow(window, ev->where, &qd.screenBits.bounds); DragWindow(window, ev->where, &screenBits.bounds);
if (win) if (win)
{ {
GrafPtr port ; GrafPtr port ;
GetPort( &port ) ; GetPort( &port ) ;
Point pt = { 0, 0 } ; Point pt = { 0, 0 } ;
SetPort( window ) ; #if TARGET_CARBON
SetPort( GetWindowPort(window) ) ;
#else
SetPort( (window) ) ;
#endif
SetOrigin( 0 , 0 ) ; SetOrigin( 0 , 0 ) ;
LocalToGlobal( &pt ) ; LocalToGlobal( &pt ) ;
SetPort( port ) ; SetPort( port ) ;
@@ -944,7 +1037,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
s_lastMouseDown = 0; s_lastMouseDown = 0;
break; break;
case inGrow: case inGrow:
int growResult = GrowWindow(window , ev->where, &qd.screenBits.bounds); int growResult = GrowWindow(window , ev->where, &screenBits.bounds);
if (growResult != 0) if (growResult != 0)
{ {
int newWidth = LoWord(growResult); int newWidth = LoWord(growResult);
@@ -969,8 +1062,13 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
// TODO setup size event // TODO setup size event
ZoomWindow( window , windowPart , false ) ; ZoomWindow( window , windowPart , false ) ;
if (win) if (win)
win->SetSize( -1, -1, window->portRect.right-window->portRect.left , {
window->portRect.bottom-window->portRect.top, wxSIZE_USE_EXISTING); Rect tempRect ;
GetWindowPortBounds(window, &tempRect ) ;
win->SetSize( -1, -1, tempRect.right-tempRect.left ,
tempRect.bottom-tempRect.top, wxSIZE_USE_EXISTING);
}
} }
s_lastMouseDown = 0; s_lastMouseDown = 0;
break; break;
@@ -980,6 +1078,17 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
break ; break ;
case inContent : case inContent :
{
GrafPtr port ;
GetPort( &port ) ;
#if TARGET_CARBON
SetPort( GetWindowPort(window) ) ;
#else
SetPort( (window) ) ;
#endif
SetOrigin( 0 , 0 ) ;
SetPort( port ) ;
}
if ( window != frontWindow ) if ( window != frontWindow )
{ {
if ( s_macIsInModalLoop ) if ( s_macIsInModalLoop )
@@ -1140,6 +1249,8 @@ long wxMacTranslateKey(unsigned char key, unsigned char code)
void wxApp::MacHandleKeyDownEvent( EventRecord *ev ) void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
{ {
wxToolTip::RemoveToolTips() ;
UInt32 menuresult = UMAMenuEvent(ev) ; UInt32 menuresult = UMAMenuEvent(ev) ;
if ( HiWord( menuresult ) ) if ( HiWord( menuresult ) )
MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ; MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
@@ -1268,12 +1379,14 @@ void wxApp::MacHandleDiskEvent( EventRecord *ev )
{ {
if ( HiWord( ev->message ) != noErr ) if ( HiWord( ev->message ) != noErr )
{ {
#if !TARGET_CARBON
OSErr err ; OSErr err ;
Point point ; Point point ;
SetPt( &point , 100 , 100 ) ; SetPt( &point , 100 , 100 ) ;
err = DIBadMount( point , ev->message ) ; err = DIBadMount( point , ev->message ) ;
wxASSERT( err == noErr ) ; wxASSERT( err == noErr ) ;
#endif
} }
} }

View File

@@ -25,8 +25,10 @@ extern "C"
#include "xpm.h" #include "xpm.h"
} ; } ;
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
#endif
#include <PictUtils.h> #include <PictUtils.h>
@@ -69,16 +71,7 @@ GWorldPtr wxMacCreateGWorld( int height , int width , int depth )
if ( depth < 0 ) if ( depth < 0 )
{ {
// get max pixel depth depth = wxDisplayDepth() ;
CGrafPtr port ;
GetCWMgrPort( &port ) ;
GDHandle maxDevice ;
maxDevice = GetMaxDevice( &port->portRect ) ;
if ( maxDevice )
depth = (**((**maxDevice).gdPMap)).pixelSize ;
else
depth = 8 ;
} }
err = NewGWorld( &port , depth , &rect , NULL , NULL , 0 ) ; err = NewGWorld( &port , depth , &rect , NULL , NULL , 0 ) ;
@@ -178,6 +171,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
GetGWorld( &origPort , &origDevice ) ; GetGWorld( &origPort , &origDevice ) ;
SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ; SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
LockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ;
// bits is a word aligned array // bits is a word aligned array
@@ -211,6 +205,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
} }
} }
UnlockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ;
SetGWorld( origPort , origDevice ) ; SetGWorld( origPort , origDevice ) ;
} }
@@ -514,6 +509,8 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
} }
m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 ) ; m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 ) ;
LockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
LockPixels( GetGWorldPixMap( (CGrafPtr) ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap ) ) ;
RGBColor maskColor = colour.GetPixel() ; RGBColor maskColor = colour.GetPixel() ;
// this is not very efficient, but I can't think // this is not very efficient, but I can't think
@@ -545,6 +542,8 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
} }
} }
} }
UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
UnlockPixels( GetGWorldPixMap( ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap ) ) ;
SetGWorld( origPort , origDevice ) ; SetGWorld( origPort , origDevice ) ;
return TRUE; return TRUE;
@@ -712,8 +711,8 @@ bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
if (dc) if (dc)
{ {
if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap)) if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap))
{ /* for following SetPixel */ {
/* fill the XImage struct 'by hand' */
ximage.width = M_BITMAPHANDLERDATA->m_width; ximage.width = M_BITMAPHANDLERDATA->m_width;
ximage.height = M_BITMAPHANDLERDATA->m_height; ximage.height = M_BITMAPHANDLERDATA->m_height;
ximage.depth = M_BITMAPHANDLERDATA->m_depth; ximage.depth = M_BITMAPHANDLERDATA->m_depth;
@@ -725,7 +724,7 @@ bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
DeleteDC(dc); DeleteDC(dc);
if (errorStatus == XpmSuccess) if (errorStatus == XpmSuccess)
return TRUE; /* no error */ return TRUE;
else else
return FALSE; return FALSE;
} else return FALSE; } else return FALSE;
@@ -809,19 +808,6 @@ bool wxBMPResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long
int desiredWidth, int desiredHeight) int desiredWidth, int desiredHeight)
{ {
// TODO: load colourmap. // TODO: load colourmap.
/*
M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ::LoadBitmap(wxGetInstance(), name);
if (M_BITMAPHANDLERDATA->m_hBitmap)
{
M_BITMAPHANDLERDATA->m_ok = TRUE;
BITMAP bm;
GetObject((HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap, sizeof(BITMAP), (LPSTR) &bm);
M_BITMAPHANDLERDATA->m_width = bm.bmWidth;
M_BITMAPHANDLERDATA->m_height = bm.bmHeight;
M_BITMAPHANDLERDATA->m_depth = bm.bmBitsPixel;
return TRUE;
}
*/
// it's probably not found // it's probably not found
wxLogError("Can't load bitmap '%s' from resources! Check .rc file.", name.c_str()); wxLogError("Can't load bitmap '%s' from resources! Check .rc file.", name.c_str());
@@ -852,11 +838,6 @@ bool wxBMPFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla
#if USE_IMAGE_LOADING_IN_MSW #if USE_IMAGE_LOADING_IN_MSW
wxPalette *palette = NULL; wxPalette *palette = NULL;
bool success = FALSE; bool success = FALSE;
/*
if (type & wxBITMAP_DISCARD_COLOURMAP)
success = wxLoadIntoBitmap(WXSTRINGCAST name, bitmap);
else
*/
success = (wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0); success = (wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0);
if (!success && palette) if (!success && palette)
{ {
@@ -884,7 +865,6 @@ bool wxBMPFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
} }
void wxBitmap::CleanUpHandlers() void wxBitmap::CleanUpHandlers()
{ {
wxNode *node = sm_handlers.First(); wxNode *node = sm_handlers.First();
@@ -903,7 +883,7 @@ void wxBitmap::InitStandardHandlers()
AddHandler( new wxPICTResourceHandler ) ; AddHandler( new wxPICTResourceHandler ) ;
AddHandler( new wxICONResourceHandler ) ; AddHandler( new wxICONResourceHandler ) ;
AddHandler(new wxXPMFileHandler); AddHandler(new wxXPMFileHandler);
AddHandler(new wxXPMDataHandler); AddHandler(new wxXPMDataHandler);
AddHandler(new wxBMPResourceHandler); AddHandler(new wxBMPResourceHandler);
AddHandler(new wxBMPFileHandler); AddHandler(new wxBMPFileHandler);
} }

View File

@@ -15,11 +15,13 @@
#include "wx/bmpbuttn.h" #include "wx/bmpbuttn.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton) IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
PicHandle MakePict(GWorldPtr wp) ; PicHandle MakePict(GWorldPtr wp, GWorldPtr mask ) ;
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
const wxPoint& pos, const wxPoint& pos,
@@ -48,8 +50,6 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
if ( height == -1 && bitmap.Ok()) if ( height == -1 && bitmap.Ok())
height = bitmap.GetHeight() + 2*m_marginY; height = bitmap.GetHeight() + 2*m_marginY;
m_macHorizontalBorder = 0 ; // additional pixels around the real control
m_macVerticalBorder = 0 ;
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
@@ -68,7 +68,14 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
icon = bmap->m_hPict ; icon = bmap->m_hPict ;
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld ) else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
{ {
icon = MakePict( bmap->m_hBitmap ) ; if ( m_buttonBitmap.GetMask() )
{
icon = MakePict( bmap->m_hBitmap , m_buttonBitmap.GetMask()->GetMaskBitmap() ) ;
}
else
{
icon = MakePict( bmap->m_hBitmap , NULL ) ;
}
} }
} }
ControlButtonContentInfo info ; ControlButtonContentInfo info ;
@@ -94,7 +101,14 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
icon = bmap->m_hPict ; icon = bmap->m_hPict ;
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld ) else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
{ {
icon = MakePict( bmap->m_hBitmap ) ; if ( m_buttonBitmap.GetMask() )
{
icon = MakePict( bmap->m_hBitmap , m_buttonBitmap.GetMask()->GetMaskBitmap() ) ;
}
else
{
icon = MakePict( bmap->m_hBitmap , NULL ) ;
}
} }
} }
ControlButtonContentInfo info ; ControlButtonContentInfo info ;

View File

@@ -17,7 +17,9 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/brush.h" #include "wx/brush.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
#endif
wxBrushRefData::wxBrushRefData() wxBrushRefData::wxBrushRefData()
{ {

View File

@@ -15,7 +15,9 @@
#include "wx/button.h" #include "wx/button.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
// Button // Button
@@ -29,8 +31,6 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
{ {
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
m_macHorizontalBorder = 2 ; // additional pixels around the real control
m_macVerticalBorder = 2 ;
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
@@ -66,22 +66,32 @@ void wxButton::SetDefault()
wxSize wxButton::DoGetBestSize() const wxSize wxButton::DoGetBestSize() const
{ {
int wBtn = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder; int wBtn = m_label.Length() * 8 + 12 ;
int hBtn = 13 + 2 * m_macVerticalBorder; int hBtn = 20 ;
if ( wBtn < 80 )
wBtn = 80 ;
return wxSize(wBtn, hBtn); return wxSize(wBtn, hBtn);
} }
wxSize wxButton::GetDefaultSize() wxSize wxButton::GetDefaultSize()
{ {
int wBtn = 15 * 8 + 12 + 2 * 2; int wBtn = 80 /* + 2 * m_macHorizontalBorder */ ;
int hBtn = 13 + 2 * 2; int hBtn = 20 /* + 2 * m_macVerticalBorder */ ;
return wxSize(wBtn, hBtn); return wxSize(wBtn, hBtn);
} }
void wxButton::Command (wxCommandEvent & event) void wxButton::Command (wxCommandEvent & event)
{ {
if ( m_macControl )
{
HiliteControl( m_macControl , kControlButtonPart ) ;
unsigned long finalTicks ;
Delay( 8 , &finalTicks ) ;
HiliteControl( m_macControl , 0 ) ;
}
ProcessCommand (event); ProcessCommand (event);
} }

View File

@@ -15,8 +15,10 @@
#include "wx/checkbox.h" #include "wx/checkbox.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox) IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>

View File

@@ -23,7 +23,9 @@
// implementation // implementation
// ============================================================================ // ============================================================================
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox) IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// implementation of wxCheckListBox class // implementation of wxCheckListBox class

View File

@@ -17,7 +17,9 @@
#include "wx/choice.h" #include "wx/choice.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
#endif
bool wxChoice::Create(wxWindow *parent, wxWindowID id, bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
@@ -27,7 +29,6 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_noStrings = n;
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
@@ -41,11 +42,15 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
for ( int i = 0 ; i < n ; i++ ) for ( int i = 0 ; i < n ; i++ )
{ {
appendmenu( m_macPopUpMenuHandle , choices[i] ) ; Str255 label;
wxMenuItem::MacBuildMenuString( label , NULL , NULL , choices[i] ,false);
AppendMenu( m_macPopUpMenuHandle , label ) ;
m_strings.Add( choices[i] ) ;
} }
SetControlMinimum( m_macControl , 0 ) ; SetControlMinimum( m_macControl , 0 ) ;
SetControlMaximum( m_macControl , m_noStrings) ; SetControlMaximum( m_macControl , Number()) ;
SetControlValue( m_macControl , 1 ) ; if ( n > 0 )
SetControlValue( m_macControl , 1 ) ;
MacPostControlCreate() ; MacPostControlCreate() ;
@@ -54,27 +59,28 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
void wxChoice::Append(const wxString& item) void wxChoice::Append(const wxString& item)
{ {
appendmenu( m_macPopUpMenuHandle , item ) ; Str255 label;
m_noStrings ++; wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false);
SetControlMaximum( m_macControl , m_noStrings) ; AppendMenu( m_macPopUpMenuHandle , label ) ;
m_strings.Add( item ) ;
SetControlMaximum( m_macControl , Number()) ;
} }
void wxChoice::Delete(int n) void wxChoice::Delete(int n)
{ {
wxASSERT( n < m_noStrings ) ;
::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ; ::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ;
m_noStrings --; m_strings.Remove( n ) ;
SetControlMaximum( m_macControl , m_noStrings) ; SetControlMaximum( m_macControl , Number()) ;
} }
void wxChoice::Clear() void wxChoice::Clear()
{ {
for ( int i = 0 ; i < m_noStrings ; i++ ) for ( int i = 0 ; i < Number() ; i++ )
{ {
::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ; ::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ;
} }
m_noStrings = 0; m_strings.Clear() ;
SetControlMaximum( m_macControl , m_noStrings) ; SetControlMaximum( m_macControl , Number()) ;
} }
int wxChoice::GetSelection() const int wxChoice::GetSelection() const
@@ -99,7 +105,7 @@ void wxChoice::SetSelection(int n)
int wxChoice::FindString(const wxString& s) const int wxChoice::FindString(const wxString& s) const
{ {
for( int i = 0 ; i < m_noStrings ; i++ ) for( int i = 0 ; i < Number() ; i++ )
{ {
if ( GetString( i ) == s ) if ( GetString( i ) == s )
return i ; return i ;
@@ -109,10 +115,7 @@ int wxChoice::FindString(const wxString& s) const
wxString wxChoice::GetString(int n) const wxString wxChoice::GetString(int n) const
{ {
Str255 text ; return m_strings[n] ;
::GetMenuItemText( m_macPopUpMenuHandle , n+1 , text ) ;
p2cstr( text ) ;
return wxString( text );
} }
void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags) void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)

View File

@@ -21,48 +21,214 @@
#include "wx/metafile.h" #include "wx/metafile.h"
#include "wx/clipbrd.h" #include "wx/clipbrd.h"
#define wxUSE_DATAOBJ 1
#include <string.h> #include <string.h>
// open/close // open/close
bool clipboard_opened = false ;
bool wxOpenClipboard() bool wxOpenClipboard()
{ {
clipboard_opened = true ;
return TRUE; return TRUE;
} }
bool wxCloseClipboard() bool wxCloseClipboard()
{ {
clipboard_opened = false ;
return TRUE; return TRUE;
} }
bool wxIsClipboardOpened() bool wxIsClipboardOpened()
{ {
return TRUE; return clipboard_opened;
} }
// get/set data
bool wxEmptyClipboard() bool wxEmptyClipboard()
{ {
ZeroScrap() ;
#if TARGET_CARBON
OSStatus err ;
err = ClearCurrentScrap( );
#else
OSErr err ;
err = ZeroScrap( );
#endif
if ( err )
{
wxLogSysError(_("Failed to empty the clipboard."));
return FALSE ;
}
return TRUE; return TRUE;
} }
bool wxSetClipboardData(wxDataFormat dataFormat,const void *data,int width , int height) // get/set data
{
return FALSE;
}
void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
{
return NULL;
}
// clipboard formats // clipboard formats
bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat) bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{ {
#if TARGET_CARBON
OSStatus err = noErr;
ScrapRef scrapRef;
err = GetCurrentScrap( &scrapRef );
if ( err != noTypeErr && err != memFullErr )
{
ScrapFlavorFlags flavorFlags;
Size byteCount;
if (( err = GetScrapFlavorFlags( scrapRef, dataFormat.GetFormatId(), &flavorFlags )) == noErr)
{
if (( err = GetScrapFlavorSize( scrapRef, dataFormat.GetFormatId(), &byteCount )) == noErr)
{
return TRUE ;
}
}
}
return FALSE;
#else
long offset ;
if ( GetScrap( NULL , dataFormat.GetFormatId() , &offset ) > 0 )
{
return TRUE ;
}
return FALSE; return FALSE;
#endif
}
bool wxSetClipboardData(wxDataFormat dataFormat,const void *data,int width , int height)
{
#if !TARGET_CARBON
OSErr err = noErr ;
#else
OSStatus err = noErr ;
#endif
switch (dataFormat.GetType())
{
case wxDF_BITMAP:
{
/*
wxBitmap *bitmap = (wxBitmap *)data;
HDC hdcMem = CreateCompatibleDC((HDC) NULL);
HDC hdcSrc = CreateCompatibleDC((HDC) NULL);
HBITMAP old = (HBITMAP)
::SelectObject(hdcSrc, (HBITMAP)bitmap->GetHBITMAP());
HBITMAP hBitmap = CreateCompatibleBitmap(hdcSrc,
bitmap->GetWidth(),
bitmap->GetHeight());
if (!hBitmap)
{
SelectObject(hdcSrc, old);
DeleteDC(hdcMem);
DeleteDC(hdcSrc);
return FALSE;
}
HBITMAP old1 = (HBITMAP) SelectObject(hdcMem, hBitmap);
BitBlt(hdcMem, 0, 0, bitmap->GetWidth(), bitmap->GetHeight(),
hdcSrc, 0, 0, SRCCOPY);
// Select new bitmap out of memory DC
SelectObject(hdcMem, old1);
// Set the data
handle = ::SetClipboardData(CF_BITMAP, hBitmap);
// Clean up
SelectObject(hdcSrc, old);
DeleteDC(hdcSrc);
DeleteDC(hdcMem);
*/
break;
}
case wxDF_DIB:
{
/*
#if wxUSE_IMAGE_LOADING_IN_MSW
wxBitmap *bitmap = (wxBitmap *)data;
HBITMAP hBitmap = (HBITMAP)bitmap->GetHBITMAP();
// NULL palette means to use the system one
HANDLE hDIB = wxBitmapToDIB(hBitmap, (HPALETTE)NULL);
handle = SetClipboardData(CF_DIB, hDIB);
#endif // wxUSE_IMAGE_LOADING_IN_MSW
*/
break;
}
#if wxUSE_METAFILE
case wxDF_METAFILE:
{
wxMetafile *wxMF = (wxMetafile *)data;
PicHandle pict = wxMF->GetHMETAFILE() ;
HLock( (Handle) pict ) ;
#if !TARGET_CARBON
err = PutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ;
#else
ScrapRef scrap;
err = GetCurrentScrap (&scrap);
if ( !err )
{
err = PutScrapFlavor (scrap, 'PICT', 0, GetHandleSize((Handle) pict), *pict);
}
#endif
HUnlock( (Handle) pict ) ;
break;
}
#endif
case wxDF_SYLK:
case wxDF_DIF:
case wxDF_TIFF:
case wxDF_PALETTE:
default:
{
wxLogError(_("Unsupported clipboard format."));
return FALSE;
}
case wxDF_OEMTEXT:
dataFormat = wxDF_TEXT;
// fall through
case wxDF_TEXT:
{
wxString mac ;
if ( wxApp::s_macDefaultEncodingIsPC )
{
mac = wxMacMakeMacStringFromPC((char *)data) ;
}
else
{
mac = (char *)data ;
}
#if !TARGET_CARBON
err = PutScrap( mac.Length() , 'TEXT' , mac.c_str() ) ;
#else
ScrapRef scrap;
err = GetCurrentScrap (&scrap);
if ( !err )
{
err = PutScrapFlavor (scrap, 'TEXT', 0, mac.Length(), mac.c_str());
}
#endif
break;
}
}
if ( err )
{
wxLogSysError(_("Failed to set clipboard data."));
return FALSE;
}
return TRUE;
} }
wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat) wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
@@ -80,11 +246,17 @@ bool wxGetClipboardFormatName(wxDataFormat dataFormat, wxChar *formatName, int m
return FALSE; return FALSE;
} }
void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
{
return NULL;
}
/* /*
* Generalized clipboard implementation by Matthew Flatt * Generalized clipboard implementation by Matthew Flatt
*/ */
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxClipboardBase)
wxClipboard::wxClipboard() wxClipboard::wxClipboard()
{ {
@@ -143,9 +315,9 @@ bool wxClipboard::AddData( wxDataObject *data )
#if wxUSE_DATAOBJ #if wxUSE_DATAOBJ
wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") ); wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
wxDataFormat format = data->GetFormat(); wxDataFormat format = data->GetPreferredFormat();
switch ( format ) switch ( format.GetType() )
{ {
case wxDF_TEXT: case wxDF_TEXT:
case wxDF_OEMTEXT: case wxDF_OEMTEXT:
@@ -160,10 +332,10 @@ bool wxClipboard::AddData( wxDataObject *data )
{ {
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data; wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
wxBitmap bitmap(bitmapDataObject->GetBitmap()); wxBitmap bitmap(bitmapDataObject->GetBitmap());
return wxSetClipboardData(data->GetFormat(), &bitmap); return wxSetClipboardData(format, &bitmap);
} }
#if wxUSE_METAFILE #if 0 // wxUSE_METAFILE
case wxDF_METAFILE: case wxDF_METAFILE:
{ {
wxMetafileDataObject* metaFileDataObject = wxMetafileDataObject* metaFileDataObject =
@@ -176,11 +348,12 @@ bool wxClipboard::AddData( wxDataObject *data )
#endif // wxUSE_METAFILE #endif // wxUSE_METAFILE
default: default:
return wxSetClipboardData(data); // return wxSetClipboardData(data);
break ;
} }
#else // !wxUSE_DATAOBJ #else // !wxUSE_DATAOBJ
return FALSE;
#endif #endif
return FALSE;
} }
void wxClipboard::Close() void wxClipboard::Close()
@@ -188,7 +361,7 @@ void wxClipboard::Close()
wxCloseClipboard(); wxCloseClipboard();
} }
bool wxClipboard::IsSupported( wxDataFormat format ) bool wxClipboard::IsSupported( const wxDataFormat &format )
{ {
return wxIsClipboardFormatAvailable(format); return wxIsClipboardFormatAvailable(format);
} }
@@ -198,7 +371,7 @@ bool wxClipboard::GetData( wxDataObject& data )
#if wxUSE_DATAOBJ #if wxUSE_DATAOBJ
wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") ); wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
wxDataFormat format = data.GetFormat(); wxDataFormat format = data.GetPreferredFormat();
switch ( format ) switch ( format )
{ {
case wxDF_TEXT: case wxDF_TEXT:
@@ -219,7 +392,7 @@ bool wxClipboard::GetData( wxDataObject& data )
case wxDF_DIB: case wxDF_DIB:
{ {
wxBitmapDataObject& bitmapDataObject = (wxBitmapDataObject &)data; wxBitmapDataObject& bitmapDataObject = (wxBitmapDataObject &)data;
wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(data->GetFormat()); wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(format );
if ( !bitmap ) if ( !bitmap )
return FALSE; return FALSE;
@@ -228,7 +401,7 @@ bool wxClipboard::GetData( wxDataObject& data )
return TRUE; return TRUE;
} }
#if wxUSE_METAFILE #if 0 // wxUSE_METAFILE
case wxDF_METAFILE: case wxDF_METAFILE:
{ {
wxMetafileDataObject& metaFileDataObject = (wxMetafileDataObject &)data; wxMetafileDataObject& metaFileDataObject = (wxMetafileDataObject &)data;

View File

@@ -16,7 +16,9 @@
#include "wx/mac/colordlg.h" #include "wx/mac/colordlg.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog) IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
#endif
/* /*
* wxColourDialog * wxColourDialog

View File

@@ -16,7 +16,9 @@
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#include "wx/colour.h" #include "wx/colour.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
#endif
// Colour // Colour

View File

@@ -16,7 +16,9 @@
#include "wx/combobox.h" #include "wx/combobox.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
#endif
// right now we don't support editable comboboxes // right now we don't support editable comboboxes
@@ -44,7 +46,9 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
for ( int i = 0 ; i < n ; i++ ) for ( int i = 0 ; i < n ; i++ )
{ {
appendmenu( m_macPopUpMenuHandle , choices[i] ) ; Str255 label;
wxMenuItem::MacBuildMenuString( label , NULL , NULL , choices[i] ,false);
AppendMenu( m_macPopUpMenuHandle , label ) ;
} }
SetControlMinimum( m_macControl , 0 ) ; SetControlMinimum( m_macControl , 0 ) ;
SetControlMaximum( m_macControl , m_noStrings) ; SetControlMaximum( m_macControl , m_noStrings) ;
@@ -125,7 +129,9 @@ void wxComboBox::SetSelection(long from, long to)
void wxComboBox::Append(const wxString& item) void wxComboBox::Append(const wxString& item)
{ {
appendmenu( m_macPopUpMenuHandle , item ) ; Str255 label;
wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false);
AppendMenu( m_macPopUpMenuHandle , label ) ;
m_noStrings ++; m_noStrings ++;
SetControlMaximum( m_macControl , m_noStrings) ; SetControlMaximum( m_macControl , m_noStrings) ;
} }

View File

@@ -16,15 +16,18 @@
#include "wx/control.h" #include "wx/control.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/tabctrl.h" #include "wx/tabctrl.h"
#include "wx/radiobox.h"
#include "wx/spinbutt.h" #include "wx/spinbutt.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow) IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
BEGIN_EVENT_TABLE(wxControl, wxControlBase) BEGIN_EVENT_TABLE(wxControl, wxWindow)
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent ) EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
EVT_CHAR( wxControl::OnKeyDown ) EVT_CHAR( wxControl::OnKeyDown )
EVT_PAINT( wxControl::OnPaint ) EVT_PAINT( wxControl::OnPaint )
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
@@ -32,6 +35,7 @@ END_EVENT_TABLE()
ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ; ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ;
pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) ;
pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode )
{ {
if ( partCode != 0) if ( partCode != 0)
@@ -46,9 +50,9 @@ pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCod
wxControl::wxControl() wxControl::wxControl()
{ {
m_macControl = NULL ; m_macControl = NULL ;
m_macHorizontalBorder = 0 ; // additional pixels around the real control m_macHorizontalBorder = 0 ; // additional pixels around the real control
m_macVerticalBorder = 0 ; m_macVerticalBorder = 0 ;
m_backgroundColour = *wxWHITE; m_backgroundColour = *wxWHITE;
m_foregroundColour = *wxBLACK; m_foregroundColour = *wxBLACK;
#if WXWIN_COMPATIBILITY #if WXWIN_COMPATIBILITY
@@ -61,6 +65,24 @@ wxControl::wxControl()
} }
} }
bool wxControl::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name)
{
m_macControl = NULL ;
m_macHorizontalBorder = 0 ; // additional pixels around the real control
m_macVerticalBorder = 0 ;
bool rval = wxWindow::Create(parent, id, pos, size, style, name);
if (rval) {
#if wxUSE_VALIDATORS
SetValidator(validator);
#endif
}
return rval;
}
wxControl::~wxControl() wxControl::~wxControl()
{ {
m_isBeingDeleted = TRUE; m_isBeingDeleted = TRUE;
@@ -79,21 +101,6 @@ wxControl::~wxControl()
} }
} }
bool wxControl::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name)
{
bool rval = wxWindow::Create(parent, id, pos, size, style, name);
if (rval) {
#if wxUSE_VALIDATORS
SetValidator(validator);
#endif
}
return rval;
}
void wxControl::SetLabel(const wxString& title) void wxControl::SetLabel(const wxString& title)
{ {
m_label = title ; m_label = title ;
@@ -222,7 +229,7 @@ void wxControl::MacPostControlCreate()
{ {
// no font // no font
} }
else if ( IsKindOf( CLASSINFO( wxStaticBox ) ) ) else if ( IsKindOf( CLASSINFO( wxStaticBox ) ) || IsKindOf( CLASSINFO( wxRadioBox ) ) || IsKindOf( CLASSINFO( wxButton ) ) )
{ {
ControlFontStyleRec controlstyle ; ControlFontStyleRec controlstyle ;
controlstyle.flags = kControlUseFontMask ; controlstyle.flags = kControlUseFontMask ;
@@ -275,14 +282,16 @@ void wxControl::MacAdjustControlRect()
{ {
if ( IsKindOf( CLASSINFO( wxButton ) ) ) if ( IsKindOf( CLASSINFO( wxButton ) ) )
{ {
m_width = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder; m_width = m_label.Length() * 8 + 12 ;
} }
else if ( IsKindOf( CLASSINFO( wxStaticText ) ) ) else if ( IsKindOf( CLASSINFO( wxStaticText ) ) )
{ {
m_width = m_label.Length() * 8 ; m_width = m_label.Length() * 8 ;
} }
else else
m_width = bestsize.right - bestsize.left + 2 * m_macHorizontalBorder; m_width = bestsize.right - bestsize.left ;
m_width += 2 * m_macHorizontalBorder ;
} }
if ( m_height == -1 ) if ( m_height == -1 )
{ {
@@ -296,7 +305,7 @@ void wxControl::MacAdjustControlRect()
wxMacDrawingHelper helper ( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ; wxMacDrawingHelper helper ( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ;
if ( helper.Ok() ) if ( helper.Ok() )
{ {
UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ; UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
} }
} }
} }
@@ -312,8 +321,10 @@ void wxControl::MacSuperChangedPosition()
{ {
if ( m_macControl ) if ( m_macControl )
{ {
int former_mac_x = (**m_macControl).contrlRect.left ; Rect contrlRect ;
int former_mac_y = (**m_macControl).contrlRect.top ; GetControlBounds( m_macControl , &contrlRect ) ;
int former_mac_x = contrlRect.left ;
int former_mac_y = contrlRect.top ;
int mac_x = m_x ; int mac_x = m_x ;
int mac_y = m_y ; int mac_y = m_y ;
GetParent()->MacClientToRootWindow( & mac_x , & mac_y ) ; GetParent()->MacClientToRootWindow( & mac_x , & mac_y ) ;
@@ -327,12 +338,12 @@ void wxControl::MacSuperChangedPosition()
{ {
{ {
Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ; Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ;
InvalRect( &inval ) ; InvalWindowRect( rootwindow , &inval ) ;
} }
UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ; UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ;
{ {
Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
InvalRect( &inval ) ; InvalWindowRect( rootwindow , &inval ) ;
} }
} }
if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) ) if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
@@ -378,7 +389,7 @@ void wxControl::MacSuperEnabled( bool enabled )
} }
} }
wxWindow::MacSuperEnabled( enabled ) ; wxWindow::MacSuperEnabled( enabled ) ;
*/ */
} }
void wxControl::MacSuperShown( bool show ) void wxControl::MacSuperShown( bool show )
@@ -418,8 +429,10 @@ void wxControl::DoSetSize(int x, int y,
int former_w = m_width ; int former_w = m_width ;
int former_h = m_height ; int former_h = m_height ;
int former_mac_x = (**m_macControl).contrlRect.left ; Rect contrlRect ;
int former_mac_y = (**m_macControl).contrlRect.top ; GetControlBounds( m_macControl , &contrlRect ) ;
int former_mac_x = contrlRect.left ;
int former_mac_y = contrlRect.top ;
int currentX, currentY; int currentX, currentY;
GetPosition(&currentX, &currentY); GetPosition(&currentX, &currentY);
@@ -430,9 +443,9 @@ void wxControl::DoSetSize(int x, int y,
int actualHeight = height; int actualHeight = height;
int actualX = x; int actualX = x;
int actualY = y; int actualY = y;
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if (x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
actualX = currentX; actualX = currentX;
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if (y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
actualY = currentY; actualY = currentY;
if (width == -1) if (width == -1)
actualWidth = currentW ; actualWidth = currentW ;
@@ -443,7 +456,8 @@ void wxControl::DoSetSize(int x, int y,
return ; return ;
AdjustForParentClientOrigin(actualX, actualY, sizeFlags); AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
wxMacDrawingHelper focus( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ; WindowRef macrootwindow = GetMacRootWindow() ;
wxMacDrawingHelper focus( wxFindWinFromMacWindow( macrootwindow ) ) ;
int mac_x = actualX ; int mac_x = actualX ;
int mac_y = actualY ; int mac_y = actualY ;
@@ -453,12 +467,12 @@ void wxControl::DoSetSize(int x, int y,
{ {
{ {
Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ; Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ;
InvalRect( &inval ) ; InvalWindowRect( macrootwindow, &inval ) ;
} }
UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ; UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ;
{ {
Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
InvalRect( &inval ) ; InvalWindowRect(macrootwindow, &inval ) ;
} }
} }
@@ -477,15 +491,15 @@ void wxControl::DoSetSize(int x, int y,
{ {
{ {
Rect inval = { mac_y , mac_x , mac_y + former_h , mac_x + former_w } ; Rect inval = { mac_y , mac_x , mac_y + former_h , mac_x + former_w } ;
InvalRect( &inval ) ; InvalWindowRect( macrootwindow, &inval ) ;
} }
m_width = actualWidth ; m_width = actualWidth ;
m_height = actualHeight ; m_height = actualHeight ;
UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ; UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
{ {
Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
InvalRect( &inval ) ; InvalWindowRect( macrootwindow , &inval ) ;
} }
MacRepositionScrollBars() ; MacRepositionScrollBars() ;
@@ -555,6 +569,47 @@ void wxControl::Refresh(bool eraseBack, const wxRect *rect)
} }
} }
void wxControl::MacRedrawControl()
{
if ( m_macControl )
{
WindowRef window = GetMacRootWindow() ;
if ( window )
{
wxWindow* win = wxFindWinFromMacWindow( window ) ;
if ( win )
{
wxMacDrawingHelper help( win ) ;
// the mac control manager always assumes to have the origin at 0,0
SetOrigin( 0 , 0 ) ;
bool hasTabBehind = false ;
wxWindow* parent = GetParent() ;
while ( parent )
{
if( parent->MacGetWindowData() )
{
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
break ;
}
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
{
if ( ((wxControl*)parent)->m_macControl )
SetUpControlBackground( ((wxControl*)parent)->m_macControl , -1 , true ) ;
break ;
}
parent = parent->GetParent() ;
}
UMADrawControl( m_macControl ) ;
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
}
}
}
}
void wxControl::OnPaint(wxPaintEvent& event) void wxControl::OnPaint(wxPaintEvent& event)
{ {
if ( m_macControl ) if ( m_macControl )
@@ -566,6 +621,7 @@ void wxControl::OnPaint(wxPaintEvent& event)
if ( win ) if ( win )
{ {
wxMacDrawingHelper help( win ) ; wxMacDrawingHelper help( win ) ;
// the mac control manager always assumes to have the origin at 0,0
SetOrigin( 0 , 0 ) ; SetOrigin( 0 , 0 ) ;
bool hasTabBehind = false ; bool hasTabBehind = false ;
@@ -629,7 +685,7 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
return ; return ;
} }
if (event.GetEventType() == wxEVT_LEFT_DOWN ) if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
{ {
int x = event.m_x ; int x = event.m_x ;

View File

@@ -16,17 +16,33 @@
#include "wx/cursor.h" #include "wx/cursor.h"
#include "wx/icon.h" #include "wx/icon.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
#endif
const short kwxCursorHandId = 9 ; const short kwxCursorHandId = 9 ;
const short kwxCursorSizeWEId = 10 ; const short kwxCursorSizeWEId = 10 ;
const short kwxCursorSizeNSId = 11 ; const short kwxCursorSizeNSId = 11 ;
#if !TARGET_CARBON
Cursor* MacArrowCursorPtr = &qd.arrow ; Cursor* MacArrowCursorPtr = &qd.arrow ;
CursHandle MacArrowCursor = &MacArrowCursorPtr ; CursHandle MacArrowCursor = &MacArrowCursorPtr ;
#else
bool MacArrowInstalled = false ;
Cursor MacArrow ;
Cursor* MacArrowCursorPtr = &MacArrow ;
CursHandle MacArrowCursor = &MacArrowCursorPtr ;
#endif
CursHandle gMacCurrentCursor = NULL ; CursHandle gMacCurrentCursor = NULL ;
wxCursorRefData::wxCursorRefData() wxCursorRefData::wxCursorRefData()
{ {
#if TARGET_CARBON
if ( !MacArrowInstalled )
{
MacArrowCursorPtr = GetQDGlobalsArrow( &MacArrow ) ;
MacArrowInstalled = true ;
}
#endif
m_width = 32; m_width = 32;
m_height = 32; m_height = 32;
m_hCursor = NULL ; m_hCursor = NULL ;
@@ -34,8 +50,8 @@ wxCursorRefData::wxCursorRefData()
wxCursorRefData::~wxCursorRefData() wxCursorRefData::~wxCursorRefData()
{ {
if ( m_hCursor && ( m_hCursor != MacArrowCursor ) ) // if ( m_hCursor && ( m_hCursor != MacArrowCursor ) )
::DisposeHandle( (Handle) m_hCursor ) ; // ::ReleaseResource( (Handle) m_hCursor ) ;
} }
// Cursors // Cursors

View File

@@ -102,8 +102,8 @@ const wxChar *wxFrameNameStr = wxT("frame");
const wxChar *wxGaugeNameStr = wxT("gauge"); const wxChar *wxGaugeNameStr = wxT("gauge");
const wxChar *wxStaticBoxNameStr = wxT("groupBox"); const wxChar *wxStaticBoxNameStr = wxT("groupBox");
const wxChar *wxListBoxNameStr = wxT("listBox"); const wxChar *wxListBoxNameStr = wxT("listBox");
const wxChar *wxStaticTextNameStr = wxT("message"); const wxChar *wxStaticTextNameStr = wxT("statictext");
const wxChar *wxStaticBitmapNameStr = wxT("message"); const wxChar *wxStaticBitmapNameStr = wxT("staticbitmap");
const wxChar *wxMultiTextNameStr = wxT("multitext"); const wxChar *wxMultiTextNameStr = wxT("multitext");
const wxChar *wxPanelNameStr = wxT("panel"); const wxChar *wxPanelNameStr = wxT("panel");
const wxChar *wxRadioBoxNameStr = wxT("radioBox"); const wxChar *wxRadioBoxNameStr = wxT("radioBox");
@@ -134,5 +134,17 @@ const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
const wxChar *wxFloatToStringStr = wxT("%.2f"); const wxChar *wxFloatToStringStr = wxT("%.2f");
const wxChar *wxDoubleToStringStr = wxT("%.2f"); const wxChar *wxDoubleToStringStr = wxT("%.2f");
#if wxUSE_SHARED_LIBRARY
///// Event tables (also must be in one, statically-linked file for shared libraries)
// This is the base, wxEvtHandler 'bootstrap' code which is expanded manually here
const wxEventTable *wxEvtHandler::GetEventTable() const { return &wxEvtHandler::sm_eventTable; }
const wxEventTable wxEvtHandler::sm_eventTable =
{ NULL, &wxEvtHandler::sm_eventTableEntries[0] };
const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] = { { 0, 0, 0, NULL } };
#endif
const wxSize wxDefaultSize(-1, -1); const wxSize wxDefaultSize(-1, -1);
const wxPoint wxDefaultPosition(-1, -1); const wxPoint wxDefaultPosition(-1, -1);

View File

@@ -44,56 +44,40 @@
wxDataFormat::wxDataFormat() wxDataFormat::wxDataFormat()
{ {
m_vType = wxDF_INVALID; m_type = wxDF_INVALID;
m_vFormat = 0; m_format = 0;
} }
wxDataFormat::wxDataFormat( wxDataFormat::wxDataFormat( wxDataFormatId vType )
wxDataFormatId vType
)
{ {
PrepareFormats();
SetType(vType); SetType(vType);
} }
wxDataFormat::wxDataFormat( wxDataFormat::wxDataFormat( const wxChar* zId)
const wxChar* zId
)
{ {
PrepareFormats();
SetId(zId); SetId(zId);
} }
wxDataFormat::wxDataFormat( wxDataFormat::wxDataFormat( const wxString& rId)
const wxString& rId
)
{ {
PrepareFormats();
SetId(rId); SetId(rId);
} }
wxDataFormat::wxDataFormat( wxDataFormat::wxDataFormat( NativeFormat vFormat)
NativeFormat vFormat
)
{ {
PrepareFormats();
SetId(vFormat); SetId(vFormat);
} }
void wxDataFormat::SetType( void wxDataFormat::SetType( wxDataFormatId Type )
wxDataFormatId vType
)
{ {
m_vType = vType; m_type = Type;
if (m_vType == wxDF_TEXT) if (m_type == wxDF_TEXT)
m_vFormat = 0; m_format = 'TEXT';
else else if (m_type == wxDF_BITMAP || m_type == wxDF_METAFILE )
if (m_vType == wxDF_BITMAP) m_format = 'PICT';
m_vFormat = 0; else if (m_type == wxDF_FILENAME)
else m_format = 'SPEC';
if (m_vType == wxDF_FILENAME)
m_vFormat = 0;
else else
{ {
wxFAIL_MSG( wxT("invalid dataformat") ); wxFAIL_MSG( wxT("invalid dataformat") );
@@ -102,56 +86,37 @@ void wxDataFormat::SetType(
wxDataFormatId wxDataFormat::GetType() const wxDataFormatId wxDataFormat::GetType() const
{ {
return m_vType; return m_type;
} }
wxString wxDataFormat::GetId() const wxString wxDataFormat::GetId() const
{ {
wxString sRet(""); // TODO: gdk_atom_name( m_format ) ); wxString sRet(""); // TODO: to name of ( m_format ) );
return sRet; return sRet;
} }
void wxDataFormat::SetId( void wxDataFormat::SetId( NativeFormat format )
NativeFormat vFormat
)
{ {
m_vFormat = vFormat; m_format = format;
// TODO:
/* if (m_format == 'TEXT')
if (m_format == g_textAtom)
m_type = wxDF_TEXT; m_type = wxDF_TEXT;
else else
if (m_format == g_pngAtom) if (m_format == 'PICT')
m_type = wxDF_BITMAP; m_type = wxDF_BITMAP;
else else
if (m_format == g_fileAtom) if (m_format == 'SPEC')
m_type = wxDF_FILENAME; m_type = wxDF_FILENAME;
else else
m_type = wxDF_PRIVATE; m_type = wxDF_PRIVATE;
*/
} }
void wxDataFormat::SetId( void wxDataFormat::SetId( const wxChar* zId )
const wxChar* zId
)
{ {
wxString tmp(zId); wxString tmp(zId);
m_vType = wxDF_PRIVATE; m_type = wxDF_PRIVATE;
m_vFormat = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); m_format = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE );
}
void wxDataFormat::PrepareFormats()
{
// TODO:
/*
if (!g_textAtom)
g_textAtom = gdk_atom_intern( "STRING", FALSE );
if (!g_pngAtom)
g_pngAtom = gdk_atom_intern( "image/png", FALSE );
if (!g_fileAtom)
g_fileAtom = gdk_atom_intern( "file:ALL", FALSE );
*/
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------

View File

@@ -14,8 +14,11 @@
#endif #endif
#include "wx/dc.h" #include "wx/dc.h"
#include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// constants // constants
@@ -34,7 +37,7 @@ long wxDC::m_macCurrentPortId = 1 ;
// wxDC // wxDC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
wxDC::wxDC(void) wxDC::wxDC()
{ {
m_ok = FALSE; m_ok = FALSE;
m_optimize = FALSE; m_optimize = FALSE;
@@ -42,8 +45,8 @@ wxDC::wxDC(void)
m_colour = TRUE; m_colour = TRUE;
m_clipping = FALSE; m_clipping = FALSE;
m_mm_to_pix_x = 1.0; m_mm_to_pix_x = mm2pt;
m_mm_to_pix_y = 1.0; m_mm_to_pix_y = mm2pt;
m_logicalOriginX = 0; m_logicalOriginX = 0;
m_logicalOriginY = 0; m_logicalOriginY = 0;
@@ -102,20 +105,32 @@ wxDC::wxDC(void)
wxDC::~wxDC(void) wxDC::~wxDC(void)
{ {
if ( !m_macPortHelper.IsCleared() )
{
GrafPtr port ;
GetPort( &port ) ;
SetPort( m_macPortHelper.GetCurrentPort() ) ;
SetOrigin( 0 , 0 ) ;
SetPort( port ) ;
}
/*
if ( m_macPort ) if ( m_macPort )
{ {
::SetPort( m_macPort ) ;
::SetOrigin( 0 , 0 ) ; ::SetOrigin( 0 , 0 ) ;
::ClipRect( &m_macPort->portRect ) ; ::ClipRect( &m_macPort->portRect ) ;
::PenNormal() ; ::PenNormal() ;
::SetPort( m_macOrigPort ) ; ::SetPort( m_macOrigPort ) ;
} }
*/
++m_macCurrentPortId ; ++m_macCurrentPortId ;
}; };
void wxDC::MacSetupPort() const void wxDC::MacSetupPort() const
{ {
AGAPortHelper* help = &m_macPortHelper ;
help->Setup( m_macPort ) ;
m_macPortId = ++m_macCurrentPortId ; m_macPortId = ++m_macCurrentPortId ;
::SetPort(m_macPort);
::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v); ::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v);
::ClipRect(&m_macClipRect); ::ClipRect(&m_macClipRect);
@@ -124,8 +139,10 @@ void wxDC::MacSetupPort() const
m_macPenInstalled = false ; m_macPenInstalled = false ;
} }
void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask ) void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
{ {
float scale = 1.0 ;
if (!Ok()) if (!Ok())
return; return;
MacVerifySetup() ; MacVerifySetup() ;
@@ -140,7 +157,7 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask )
{ {
if ( bmap->m_bitmapType == kMacBitmapTypePict ) if ( bmap->m_bitmapType == kMacBitmapTypePict )
{ {
Rect bitmaprect = { 0 , 0 , bmap->m_height , bmap->m_width } ; Rect bitmaprect = { 0 , 0 , bmap->m_height * scale , bmap->m_width * scale} ;
::OffsetRect( &bitmaprect , xx1 , yy1 ) ; ::OffsetRect( &bitmaprect , xx1 , yy1 ) ;
::DrawPicture( bmap->m_hPict , &bitmaprect ) ; ::DrawPicture( bmap->m_hPict , &bitmaprect ) ;
} }
@@ -165,20 +182,21 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask )
source.bottom = bmap->m_height ; source.bottom = bmap->m_height ;
dest.top = YLOG2DEV(y) ; dest.top = YLOG2DEV(y) ;
dest.left = XLOG2DEV(x) ; dest.left = XLOG2DEV(x) ;
dest.bottom = YLOG2DEV(y + bmap->m_height ) ; dest.bottom = YLOG2DEV(y + bmap->m_height * scale) ;
dest.right = XLOG2DEV(x + bmap->m_width ) ; dest.right = XLOG2DEV(x + bmap->m_width * scale ) ;
if ( useMask && bmp.GetMask() ) if ( useMask && bmp.GetMask() )
{ {
if ( LockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ) if ( LockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) )
{ {
CopyMask( &GrafPtr( bmapworld )->portBits , &GrafPtr( bmp.GetMask()->GetMaskBitmap( ) )->portBits , &GrafPtr( m_macPort )->portBits , CopyMask( GetPortBitMapForCopyBits( bmapworld ) , GetPortBitMapForCopyBits( bmp.GetMask()->GetMaskBitmap( ) ) ,
GetPortBitMapForCopyBits( m_macPort ) ,
&source, &source , &dest ) ; &source, &source , &dest ) ;
UnlockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ; UnlockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ;
} }
} }
else else
CopyBits( &GrafPtr( bmapworld )->portBits , &GrafPtr( m_macPort )->portBits , CopyBits( GetPortBitMapForCopyBits( bmapworld ) , GetPortBitMapForCopyBits( m_macPort ),
&source, &dest, srcCopy, NULL ) ; &source, &dest, srcCopy, NULL ) ;
UnlockPixels( bmappixels ) ; UnlockPixels( bmappixels ) ;
@@ -192,7 +210,7 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask )
} }
} }
void wxDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask ) void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -213,69 +231,9 @@ void wxDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask )
} }
}; };
void wxDC::DrawPoint( wxPoint& point ) void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{ {
DrawPoint( point.x, point.y ); MacVerifySetup() ;
};
void wxDC::DrawPolygon( wxList *list, long xoffset, long yoffset, int fillStyle )
{
int n = list->Number();
wxPoint *points = new wxPoint[n];
int i = 0;
for( wxNode *node = list->First(); node; node = node->Next() )
{
wxPoint *point = (wxPoint *)node->Data();
points[i].x = point->x;
points[i++].y = point->y;
};
DrawPolygon( n, points, xoffset, yoffset, fillStyle );
delete[] points;
};
void wxDC::DrawLines( wxList *list, long xoffset, long yoffset )
{
int n = list->Number();
wxPoint *points = new wxPoint[n];
int i = 0;
for( wxNode *node = list->First(); node; node = node->Next() )
{
wxPoint *point = (wxPoint *)node->Data();
points[i].x = point->x;
points[i++].y = point->y;
};
DrawLines( n, points, xoffset, yoffset );
delete []points;
};
void wxDC::DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 )
{
wxList list;
list.Append( (wxObject*)new wxPoint(x1, y1) );
list.Append( (wxObject*)new wxPoint(x2, y2) );
list.Append( (wxObject*)new wxPoint(x3, y3) );
DrawSpline(&list);
wxNode *node = list.First();
while (node)
{
wxPoint *p = (wxPoint*)node->Data();
delete p;
node = node->Next();
};
};
void wxDC::DrawSpline( int n, wxPoint points[] )
{
wxList list;
for (int i = 0; i < n; i++) list.Append( (wxObject*)&points[i] );
DrawSpline( &list );
};
void wxDC::SetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
MacVerifySetup() ;
if( m_clipping ) if( m_clipping )
{ {
m_clipX1 = wxMax( m_clipX1 , x ) ; m_clipX1 = wxMax( m_clipX1 , x ) ;
@@ -300,13 +258,24 @@ void wxDC::SetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord heigh
Rect clip = { y1 , x1 , y2 , x2 } ; Rect clip = { y1 , x1 , y2 , x2 } ;
::ClipRect( &clip ) ; ::ClipRect( &clip ) ;
}; };
void wxDC::SetClippingRegion(const wxRect& rect) void wxDC::DoSetClippingRegionAsRegion( const wxRegion &region )
{ {
SetClippingRegion(rect.x, rect.y, rect.width, rect.height); wxCHECK_RET( Ok(), wxT("invalid window dc") );
MacVerifySetup() ;
if (region.Empty())
{
DestroyClippingRegion();
return;
}
wxCoord xx, yy, ww, hh;
region.GetBox( xx, yy, ww, hh );
wxDC::DoSetClippingRegion( xx, yy, ww, hh );
} }
void wxDC::DestroyClippingRegion(void) void wxDC::DestroyClippingRegion(void)
@@ -317,47 +286,13 @@ void wxDC::DestroyClippingRegion(void)
::ClipRect(&m_macClipRect); ::ClipRect(&m_macClipRect);
}; };
void wxDC::GetClippingBox( wxCoord *x, wxCoord *y, wxCoord *width, wxCoord *height ) const void wxDC::DoGetSize( int* width, int* height ) const
{
if (m_clipping)
{
if (x) *x = m_clipX1;
if (y) *y = m_clipY1;
if (width) *width = (m_clipX2 - m_clipX1);
if (height) *height = (m_clipY2 - m_clipY1);
}
else
*x = *y = *width = *height = 0;
};
void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const
{
if (m_clipping)
{
if (x) *x = m_clipX1;
if (y) *y = m_clipY1;
if (width) *width = (m_clipX2 - m_clipX1);
if (height) *height = (m_clipY2 - m_clipY1);
}
else
*x = *y = *width = *height = 0;
};
void wxDC::GetClippingBox(wxRect& rect) const
{
// Necessary to use intermediate variables for 16-bit compilation
wxCoord x, y, w, h;
GetClippingBox(&x, &y, &w, &h);
rect.x = x; rect.y = y; rect.width = w; rect.height = h;
}
void wxDC::GetSize( int* width, int* height ) const
{ {
*width = m_maxX-m_minX; *width = m_maxX-m_minX;
*height = m_maxY-m_minY; *height = m_maxY-m_minY;
}; };
void wxDC::GetSizeMM( long* width, long* height ) const void wxDC::DoGetSizeMM( int* width, int* height ) const
{ {
int w = 0; int w = 0;
int h = 0; int h = 0;
@@ -416,12 +351,6 @@ void wxDC::SetUserScale( double x, double y )
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
void wxDC::GetUserScale( double *x, double *y )
{
if (x) *x = m_userScaleX;
if (y) *y = m_userScaleY;
};
void wxDC::SetLogicalScale( double x, double y ) void wxDC::SetLogicalScale( double x, double y )
{ {
// allow negative ? // allow negative ?
@@ -430,40 +359,20 @@ void wxDC::SetLogicalScale( double x, double y )
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
void wxDC::GetLogicalScale( double *x, double *y ) void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
{
if (x) *x = m_logicalScaleX;
if (y) *y = m_logicalScaleY;
};
void wxDC::SetLogicalOrigin( long x, long y )
{ {
m_logicalOriginX = x * m_signX; // is this still correct ? m_logicalOriginX = x * m_signX; // is this still correct ?
m_logicalOriginY = y * m_signY; m_logicalOriginY = y * m_signY;
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
void wxDC::GetLogicalOrigin( long *x, long *y ) void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
{
if (x) *x = m_logicalOriginX;
if (y) *y = m_logicalOriginY;
};
void wxDC::SetDeviceOrigin( long x, long y )
{ {
m_externalDeviceOriginX = x; m_externalDeviceOriginX = x;
m_externalDeviceOriginY = y; m_externalDeviceOriginY = y;
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
/*
void wxDC::GetDeviceOrigin( long *x, long *y )
{
// if (x) *x = m_externalDeviceOriginX;
// if (y) *y = m_externalDeviceOriginY;
if (x) *x = m_deviceOriginX;
if (y) *y = m_deviceOriginY;
};
void wxDC::SetInternalDeviceOrigin( long x, long y ) void wxDC::SetInternalDeviceOrigin( long x, long y )
{ {
m_internalDeviceOriginX = x; m_internalDeviceOriginX = x;
@@ -476,53 +385,14 @@ void wxDC::GetInternalDeviceOrigin( long *x, long *y )
if (x) *x = m_internalDeviceOriginX; if (x) *x = m_internalDeviceOriginX;
if (y) *y = m_internalDeviceOriginY; if (y) *y = m_internalDeviceOriginY;
}; };
*/
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{ {
m_signX = (xLeftRight ? 1 : -1); m_signX = (xLeftRight ? 1 : -1);
m_signY = (yBottomUp ? -1 : 1); m_signY = (yBottomUp ? -1 : 1);
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
/*
long wxDC::DeviceToLogicalX(long x) const
{
return XDEV2LOG(x);
};
long wxDC::DeviceToLogicalY(long y) const
{
return YDEV2LOG(y);
};
long wxDC::DeviceToLogicalXRel(long x) const
{
return XDEV2LOGREL(x);
};
long wxDC::DeviceToLogicalYRel(long y) const
{
return YDEV2LOGREL(y);
};
long wxDC::LogicalToDeviceX(long x) const
{
return XLOG2DEV(x);
};
long wxDC::LogicalToDeviceY(long y) const
{
return YLOG2DEV(y);
};
long wxDC::LogicalToDeviceXRel(long x) const
{
return XLOG2DEVREL(x);
};
long wxDC::LogicalToDeviceYRel(long y) const
{
return YLOG2DEVREL(y);
};
void wxDC::CalcBoundingBox( long x, long y ) void wxDC::CalcBoundingBox( long x, long y )
{ {
@@ -531,6 +401,16 @@ void wxDC::CalcBoundingBox( long x, long y )
if (x > m_maxX) m_maxX = x; if (x > m_maxX) m_maxX = x;
if (y > m_maxY) m_maxY = y; if (y > m_maxY) m_maxY = y;
}; };
*/
wxSize wxDC::GetPPI() const
{
return wxSize(72, 72);
}
int wxDC::GetDepth() const
{
return wxDisplayDepth() ;
}
void wxDC::ComputeScaleAndOrigin(void) void wxDC::ComputeScaleAndOrigin(void)
{ {
@@ -547,12 +427,7 @@ void wxDC::ComputeScaleAndOrigin(void)
// CMB: if scale has changed call SetPen to recalulate the line width // CMB: if scale has changed call SetPen to recalulate the line width
if (m_scaleX != origScaleX || m_scaleY != origScaleY) if (m_scaleX != origScaleX || m_scaleY != origScaleY)
{ {
// this is a bit artificial, but we need to force wxDC to think // TODO : set internal flags for recalc
// the pen has changed
wxPen* pen = & GetPen();
wxPen tempPen;
m_pen = tempPen;
SetPen(* pen);
} }
}; };
@@ -634,16 +509,17 @@ void wxDC::SetLogicalFunction( int function )
m_macPenInstalled = false ; m_macPenInstalled = false ;
} }
void wxDC::FloodFill( long x1, long y1, const wxColour& col, int style ) void wxDC::DoFloodFill( wxCoord x, wxCoord y, const wxColour& col,
int style )
{ {
} }
bool wxDC::GetPixel( long x1, long y1, wxColour *col ) const bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
{ {
return true ; return true ;
} }
void wxDC::DrawLine( long x1, long y1, long x2, long y2 ) void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -664,19 +540,22 @@ void wxDC::DrawLine( long x1, long y1, long x2, long y2 )
}; };
} }
void wxDC::CrossHair( long x, long y ) void wxDC::DoCrossHair( wxCoord x, wxCoord y )
{ {
} }
void wxDC::DrawArc( long x1, long y1, long x2, long y2, long xc, long yc ) void wxDC::DoDrawArc( wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord xc, wxCoord yc )
{ {
} }
void wxDC::DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ) void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea )
{ {
} }
void wxDC::DrawPoint( long x, long y ) void wxDC::DoDrawPoint( wxCoord x, wxCoord y )
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -694,7 +573,8 @@ void wxDC::DrawPoint( long x, long y )
}; };
} }
void wxDC::DrawLines( int n, wxPoint points[], long xoffset , long yoffset ) void wxDC::DoDrawLines(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset)
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -719,8 +599,9 @@ void wxDC::DrawLines( int n, wxPoint points[], long xoffset , long yoffset )
} }
} }
void wxDC::DrawPolygon( int n, wxPoint points[], long xoffset , long yoffset , void wxDC::DoDrawPolygon(int n, wxPoint points[],
int fillStyle ) wxCoord xoffset, wxCoord yoffset,
int fillStyle )
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -754,7 +635,7 @@ void wxDC::DrawPolygon( int n, wxPoint points[], long xoffset , long yoffset ,
KillPoly( polygon ) ; KillPoly( polygon ) ;
} }
void wxDC::DrawRectangle( long x, long y, long width, long height ) void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -797,7 +678,9 @@ void wxDC::DrawRectangle( long x, long y, long width, long height )
}; };
} }
void wxDC::DrawRoundedRectangle( long x, long y, long width, long height, double radius ) void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
wxCoord width, wxCoord height,
double radius)
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -843,7 +726,7 @@ void wxDC::DrawRoundedRectangle( long x, long y, long width, long height, doubl
}; };
} }
void wxDC::DrawEllipse( long x, long y, long width, long height ) void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -1001,7 +884,7 @@ static void wx_spline_draw_point_array(wxDC *dc)
} }
} }
void wxDC::DrawSpline( wxList *points ) void wxDC::DoDrawSpline(wxList *points)
{ {
wxPoint *p; wxPoint *p;
double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4; double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
@@ -1059,8 +942,8 @@ bool wxDC::CanDrawBitmap(void) const
} }
bool wxDC::Blit( long xdest, long ydest, long width, long height, bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, long xsrc, long ysrc, int logical_func , bool useMask ) wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask )
{ {
if (!Ok()) return FALSE; if (!Ok()) return FALSE;
MacVerifySetup() ; MacVerifySetup() ;
@@ -1069,8 +952,8 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ; PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
RGBColor black = { 0,0,0} ; RGBColor black = { 0,0,0} ;
RGBForeColor( &m_textForegroundColour.GetPixel() ) ; RGBForeColor( &m_textForegroundColour.GetPixel() ) ;
RGBBackColor( &m_textBackgroundColour.GetPixel() ) ; RGBBackColor( &m_textBackgroundColour.GetPixel() ) ;
if ( LockPixels(bmappixels) ) if ( LockPixels(bmappixels) )
{ {
@@ -1094,7 +977,7 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
logical_func == wxXOR ? srcXor : logical_func == wxXOR ? srcXor :
// logical_func == wxOR_REVERSE ? MERGEPAINT : // logical_func == wxOR_REVERSE ? MERGEPAINT :
// logical_func == wxAND_REVERSE ? SRCERASE : // logical_func == wxAND_REVERSE ? SRCERASE :
logical_func == wxSRC_OR ? srcOr : // logical_func == wxSRC_OR ? srcOr :
// logical_func == wxSRC_AND ? SRCAND : // logical_func == wxSRC_AND ? SRCAND :
srcCopy ); srcCopy );
@@ -1103,14 +986,15 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
wxASSERT( mode == srcCopy ) ; wxASSERT( mode == srcCopy ) ;
if ( LockPixels( GetGWorldPixMap( source->m_macMask ) ) ) if ( LockPixels( GetGWorldPixMap( source->m_macMask ) ) )
{ {
CopyMask( &GrafPtr( sourcePort )->portBits , &GrafPtr( source->m_macMask )->portBits , &GrafPtr( m_macPort )->portBits , CopyMask( GetPortBitMapForCopyBits( sourcePort ) , GetPortBitMapForCopyBits( source->m_macMask ) ,
GetPortBitMapForCopyBits( m_macPort ) ,
&srcrect, &srcrect , &dstrect ) ; &srcrect, &srcrect , &dstrect ) ;
UnlockPixels( GetGWorldPixMap( source->m_macMask ) ) ; UnlockPixels( GetGWorldPixMap( source->m_macMask ) ) ;
} }
} }
else else
{ {
CopyBits( &GrafPtr( sourcePort )->portBits , &GrafPtr( m_macPort )->portBits , CopyBits( GetPortBitMapForCopyBits( sourcePort ) , GetPortBitMapForCopyBits( m_macPort ) ,
&srcrect, &dstrect, mode, NULL ) ; &srcrect, &dstrect, mode, NULL ) ;
} }
UnlockPixels( bmappixels ) ; UnlockPixels( bmappixels ) ;
@@ -1123,7 +1007,11 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
return TRUE; return TRUE;
} }
void wxDC::DrawText( const wxString &string, long x, long y, bool use16) void wxDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
double angle)
{
}
void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -1161,14 +1049,14 @@ void wxDC::DrawText( const wxString &string, long x, long y, bool use16)
if ( wxApp::s_macDefaultEncodingIsPC ) if ( wxApp::s_macDefaultEncodingIsPC )
{ {
macText = wxMacMakeMacStringFromPC( string ) ; macText = wxMacMakeMacStringFromPC( strtext ) ;
text = macText ; text = macText ;
length = macText.Length() ; length = macText.Length() ;
} }
else else
{ {
text = string ; text = strtext ;
length = string.Length() ; length = strtext.Length() ;
} }
int laststop = 0 ; int laststop = 0 ;
@@ -1200,9 +1088,9 @@ bool wxDC::CanGetTextExtent(void) const
return true ; return true ;
} }
void wxDC::GetTextExtent( const wxString &string, long *width, long *height, void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height,
long *descent, long *externalLeading , wxCoord *descent, wxCoord *externalLeading ,
wxFont *theFont , bool use16 ) const wxFont *theFont ) const
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -1217,11 +1105,8 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
if ( font ) if ( font )
{ {
long yy1 = YLOG2DEV(0);
long yy2 = YLOG2DEV(font->m_macFontSize);
::TextFont( font->m_macFontNum ) ; ::TextFont( font->m_macFontNum ) ;
::TextSize( abs( yy2-yy1) ) ; ::TextSize( YLOG2DEVREL( font->m_macFontSize) ) ;
::TextFace( font->m_macFontStyle ) ; ::TextFace( font->m_macFontStyle ) ;
} }
} }
@@ -1233,9 +1118,12 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
FontInfo fi ; FontInfo fi ;
::GetFontInfo( &fi ) ; ::GetFontInfo( &fi ) ;
*height = fi.descent + fi.ascent ; if ( height )
*descent = fi.descent ; *height = YDEV2LOGREL( fi.descent + fi.ascent ) ;
*externalLeading = fi.leading ; if ( descent )
*descent =YDEV2LOGREL( fi.descent );
if ( externalLeading )
*externalLeading = YDEV2LOGREL( fi.leading ) ;
const char *text = NULL ; const char *text = NULL ;
int length = 0 ; int length = 0 ;
@@ -1255,24 +1143,28 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
int laststop = 0 ; int laststop = 0 ;
int i = 0 ; int i = 0 ;
int curwidth = 0 ; int curwidth = 0 ;
*width = 0 ; if ( width )
while( i < length )
{ {
if( text[i] == 13 || text[i] == 10) *width = 0 ;
{
*height += fi.descent + fi.ascent + fi.leading;
curwidth = ::TextWidth( text , laststop , i - laststop ) ;
if ( curwidth > *width )
*width = curwidth ;
laststop = i+1 ;
}
i++ ;
}
curwidth = ::TextWidth( text , laststop , i - laststop ) ; while( i < length )
if ( curwidth > *width ) {
*width = curwidth ; if( text[i] == 13 || text[i] == 10)
{
if ( height )
*height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ;
curwidth = ::TextWidth( text , laststop , i - laststop ) ;
if ( curwidth > *width )
*width = XDEV2LOGREL( curwidth ) ;
laststop = i+1 ;
}
i++ ;
}
curwidth = ::TextWidth( text , laststop , i - laststop ) ;
if ( curwidth > *width )
*width = XDEV2LOGREL( curwidth ) ;
}
if ( theFont ) if ( theFont )
{ {
@@ -1292,7 +1184,7 @@ wxCoord wxDC::GetCharWidth(void) const
FontInfo fi ; FontInfo fi ;
::GetFontInfo( &fi ) ; ::GetFontInfo( &fi ) ;
return (fi.descent + fi.ascent) / 2 ; return YDEV2LOGREL((fi.descent + fi.ascent) / 2) ;
} }
wxCoord wxDC::GetCharHeight(void) const wxCoord wxDC::GetCharHeight(void) const
@@ -1307,7 +1199,7 @@ wxCoord wxDC::GetCharHeight(void) const
FontInfo fi ; FontInfo fi ;
::GetFontInfo( &fi ) ; ::GetFontInfo( &fi ) ;
return fi.descent + fi.ascent ; return YDEV2LOGREL( fi.descent + fi.ascent );
} }
void wxDC::Clear(void) void wxDC::Clear(void)
@@ -1332,6 +1224,7 @@ void wxDC::MacInstallFont() const
if ( m_macFontInstalled ) if ( m_macFontInstalled )
return ; return ;
Pattern blackColor ;
wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
@@ -1377,7 +1270,7 @@ void wxDC::MacInstallFont() const
mode = patCopy ; mode = patCopy ;
break ; break ;
case wxINVERT: // NOT dst case wxINVERT: // NOT dst
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
mode = patXor ; mode = patXor ;
break ; break ;
case wxXOR: // src XOR dst case wxXOR: // src XOR dst
@@ -1403,8 +1296,8 @@ void wxDC::MacInstallFont() const
case wxNAND: // (NOT src) OR (NOT dst) case wxNAND: // (NOT src) OR (NOT dst)
case wxOR: // src OR dst case wxOR: // src OR dst
case wxSET: // 1 case wxSET: // 1
case wxSRC_OR: // source _bitmap_ OR destination // case wxSRC_OR: // source _bitmap_ OR destination
case wxSRC_AND: // source _bitmap_ AND destination // case wxSRC_AND: // source _bitmap_ AND destination
break ; break ;
} }
::PenMode( mode ) ; ::PenMode( mode ) ;
@@ -1447,6 +1340,8 @@ void wxDC::MacInstallPen() const
return; return;
MacVerifySetup() ; MacVerifySetup() ;
Pattern blackColor;
if ( m_macPenInstalled ) if ( m_macPenInstalled )
return ; return ;
@@ -1460,7 +1355,7 @@ void wxDC::MacInstallPen() const
int penStyle = m_pen.GetStyle(); int penStyle = m_pen.GetStyle();
if (penStyle == wxSOLID) if (penStyle == wxSOLID)
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
else if (IS_HATCH(penStyle)) else if (IS_HATCH(penStyle))
{ {
Pattern pat ; Pattern pat ;
@@ -1469,7 +1364,7 @@ void wxDC::MacInstallPen() const
} }
else else
{ {
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
} }
short mode = patCopy ; short mode = patCopy ;
@@ -1482,7 +1377,7 @@ void wxDC::MacInstallPen() const
mode = patCopy ; mode = patCopy ;
break ; break ;
case wxINVERT: // NOT dst case wxINVERT: // NOT dst
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
mode = patXor ; mode = patXor ;
break ; break ;
case wxXOR: // src XOR dst case wxXOR: // src XOR dst
@@ -1508,8 +1403,8 @@ void wxDC::MacInstallPen() const
case wxNAND: // (NOT src) OR (NOT dst) case wxNAND: // (NOT src) OR (NOT dst)
case wxOR: // src OR dst case wxOR: // src OR dst
case wxSET: // 1 case wxSET: // 1
case wxSRC_OR: // source _bitmap_ OR destination // case wxSRC_OR: // source _bitmap_ OR destination
case wxSRC_AND: // source _bitmap_ AND destination // case wxSRC_AND: // source _bitmap_ AND destination
break ; break ;
} }
::PenMode( mode ) ; ::PenMode( mode ) ;
@@ -1523,7 +1418,7 @@ void wxDC::MacInstallBrush() const
if (!Ok()) if (!Ok())
return; return;
MacVerifySetup() ; MacVerifySetup() ;
Pattern blackColor, whiteColor ;
if ( m_macBrushInstalled ) if ( m_macBrushInstalled )
return ; return ;
@@ -1534,7 +1429,7 @@ void wxDC::MacInstallBrush() const
int brushStyle = m_brush.GetStyle(); int brushStyle = m_brush.GetStyle();
if (brushStyle == wxSOLID) if (brushStyle == wxSOLID)
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
else if (IS_HATCH(brushStyle)) else if (IS_HATCH(brushStyle))
{ {
Pattern pat ; Pattern pat ;
@@ -1543,7 +1438,7 @@ void wxDC::MacInstallBrush() const
} }
else else
{ {
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
} }
@@ -1551,7 +1446,7 @@ void wxDC::MacInstallBrush() const
brushStyle = m_backgroundBrush.GetStyle(); brushStyle = m_backgroundBrush.GetStyle();
if (brushStyle == wxSOLID) if (brushStyle == wxSOLID)
::BackPat(&qd.white); ::BackPat(GetQDGlobalsWhite(&whiteColor));
else if (IS_HATCH(brushStyle)) else if (IS_HATCH(brushStyle))
{ {
Pattern pat ; Pattern pat ;
@@ -1560,7 +1455,7 @@ void wxDC::MacInstallBrush() const
} }
else else
{ {
::BackPat(&qd.white); ::BackPat(GetQDGlobalsWhite(&whiteColor));
} }
short mode = patCopy ; short mode = patCopy ;
@@ -1573,7 +1468,7 @@ void wxDC::MacInstallBrush() const
mode = patCopy ; mode = patCopy ;
break ; break ;
case wxINVERT: // NOT dst case wxINVERT: // NOT dst
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
mode = patXor ; mode = patXor ;
break ; break ;
case wxXOR: // src XOR dst case wxXOR: // src XOR dst
@@ -1599,8 +1494,8 @@ void wxDC::MacInstallBrush() const
case wxNAND: // (NOT src) OR (NOT dst) case wxNAND: // (NOT src) OR (NOT dst)
case wxOR: // src OR dst case wxOR: // src OR dst
case wxSET: // 1 case wxSET: // 1
case wxSRC_OR: // source _bitmap_ OR destination // case wxSRC_OR: // source _bitmap_ OR destination
case wxSRC_AND: // source _bitmap_ AND destination // case wxSRC_AND: // source _bitmap_ AND destination
break ; break ;
} }
::PenMode( mode ) ; ::PenMode( mode ) ;
@@ -1609,4 +1504,47 @@ void wxDC::MacInstallBrush() const
m_macFontInstalled = false ; m_macFontInstalled = false ;
} }
// ---------------------------------------------------------------------------
// coordinates transformations
// ---------------------------------------------------------------------------
wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
{
return ((wxDC *)this)->XDEV2LOG(x);
}
wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
{
return ((wxDC *)this)->YDEV2LOG(y);
}
wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
{
return ((wxDC *)this)->XDEV2LOGREL(x);
}
wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
{
return ((wxDC *)this)->YDEV2LOGREL(y);
}
wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
{
return ((wxDC *)this)->XLOG2DEV(x);
}
wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
{
return ((wxDC *)this)->YLOG2DEV(y);
}
wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
{
return ((wxDC *)this)->XLOG2DEVREL(x);
}
wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
{
return ((wxDC *)this)->YLOG2DEVREL(y);
}

View File

@@ -28,9 +28,11 @@
// wxPaintDC // wxPaintDC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
#endif
/* /*
* wxWindowDC * wxWindowDC
@@ -38,7 +40,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
wxWindowDC::wxWindowDC(void) wxWindowDC::wxWindowDC()
{ {
} }
@@ -51,11 +53,16 @@ wxWindowDC::wxWindowDC(wxWindow *the_canvas)
the_canvas->MacGetPortParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow ); the_canvas->MacGetPortParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow );
m_macPort = UMAGetWindowPort( windowref ) ; m_macPort = UMAGetWindowPort( windowref ) ;
m_minY = m_minX = 0;
wxSize size = the_canvas->GetSize() ;
m_maxX = size.x ;
m_maxY = size.y ;
MacSetupPort() ; MacSetupPort() ;
m_ok = TRUE ; m_ok = TRUE ;
} }
wxWindowDC::~wxWindowDC(void) wxWindowDC::~wxWindowDC()
{ {
} }
@@ -63,7 +70,7 @@ wxWindowDC::~wxWindowDC(void)
* wxClientDC * wxClientDC
*/ */
wxClientDC::wxClientDC(void) wxClientDC::wxClientDC()
{ {
} }
@@ -75,12 +82,16 @@ wxClientDC::wxClientDC(wxWindow *window)
window->MacGetPortClientParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow ); window->MacGetPortClientParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow );
m_macPort = UMAGetWindowPort( windowref ) ; m_macPort = UMAGetWindowPort( windowref ) ;
MacSetupPort() ; MacSetupPort() ;
m_minY = m_minX = 0;
wxSize size = window->GetSize() ;
m_maxX = size.x ;
m_maxY = size.y ;
m_ok = TRUE ; m_ok = TRUE ;
SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID)); SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
SetFont( window->GetFont() ) ; SetFont( window->GetFont() ) ;
} }
wxClientDC::~wxClientDC(void) wxClientDC::~wxClientDC()
{ {
} }
@@ -88,7 +99,7 @@ wxClientDC::~wxClientDC(void)
* wxPaintDC * wxPaintDC
*/ */
wxPaintDC::wxPaintDC(void) wxPaintDC::wxPaintDC()
{ {
} }
@@ -104,6 +115,10 @@ wxPaintDC::wxPaintDC(wxWindow *window)
m_ok = TRUE ; m_ok = TRUE ;
long x , y ,w , h ; long x , y ,w , h ;
window->GetUpdateRegion().GetBox( x , y , w , h ) ; window->GetUpdateRegion().GetBox( x , y , w , h ) ;
m_minY = m_minX = 0;
wxSize size = window->GetSize() ;
m_maxX = size.x ;
m_maxY = size.y ;
SetClippingRegion( x , y , w , h ) ; SetClippingRegion( x , y , w , h ) ;
SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID)); SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
SetFont(window->GetFont() ) ; SetFont(window->GetFont() ) ;

View File

@@ -33,10 +33,20 @@ wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
wxMemoryDC::~wxMemoryDC(void) wxMemoryDC::~wxMemoryDC(void)
{ {
if ( m_selected.Ok() )
{
wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ;
}
}; };
void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
{ {
if ( m_selected.Ok() )
{
wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ;
}
m_selected = bitmap; m_selected = bitmap;
if (m_selected.Ok()) if (m_selected.Ok())
{ {
@@ -44,6 +54,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
if ( bmap->m_hBitmap ) if ( bmap->m_hBitmap )
{ {
m_macPort = (GrafPtr) bmap->m_hBitmap ; m_macPort = (GrafPtr) bmap->m_hBitmap ;
LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
wxMask * mask = bitmap.GetMask() ; wxMask * mask = bitmap.GetMask() ;
if ( mask ) if ( mask )
{ {

View File

@@ -25,31 +25,36 @@
#include "wx/dcprint.h" #include "wx/dcprint.h"
#include "math.h" #include "math.h"
#include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_CLASS(wxPrinterDC, wxDC) IMPLEMENT_CLASS(wxPrinterDC, wxDC)
#endif
GrafPtr macPrintFormerPort = NULL ; GrafPtr macPrintFormerPort = NULL ;
wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
{ {
#if !TARGET_CARBON
OSErr err ; OSErr err ;
wxString message ; wxString message ;
m_printData = printdata ; m_printData = printdata ;
m_printData.ConvertToNative() ; m_printData.ConvertToNative() ;
::PrOpen() ; ::UMAPrOpen() ;
err = PrError() ; err = PrError() ;
if ( err ) if ( err )
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
PrClose() ; UMAPrClose() ;
} }
if ( ::PrValidate( m_printData.m_macPrintInfo ) ) if ( ::PrValidate( m_printData.m_macPrintInfo ) )
{ {
::PrStlDialog( m_printData.m_macPrintInfo ) ;
// the driver has changed in the mean time, should we pop up a page setup dialog ? // the driver has changed in the mean time, should we pop up a page setup dialog ?
} }
err = PrError() ; err = PrError() ;
@@ -57,20 +62,31 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
PrClose() ; UMAPrClose() ;
} }
::GetPort( &macPrintFormerPort ) ; ::GetPort( &macPrintFormerPort ) ;
m_macPrintPort = ::PrOpenDoc( m_printData.m_macPrintInfo , NULL , NULL ) ; m_macPrintPort = ::PrOpenDoc( m_printData.m_macPrintInfo , NULL , NULL ) ;
err = PrError() ;
if ( err )
{
message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
UMAPrClose() ;
}
// sets current port // sets current port
m_macPort = (GrafPtr ) m_macPrintPort ; m_macPort = (GrafPtr ) m_macPrintPort ;
m_ok = TRUE ; m_ok = TRUE ;
m_minY = m_minX = 0 ; m_minY = m_minX = 0 ;
m_maxX = (**m_printData.m_macPrintInfo).rPaper.right - (**m_printData.m_macPrintInfo).rPaper.left ; m_maxX = (**m_printData.m_macPrintInfo).rPaper.right - (**m_printData.m_macPrintInfo).rPaper.left ;
m_maxY = (**m_printData.m_macPrintInfo).rPaper.bottom - (**m_printData.m_macPrintInfo).rPaper.top ; m_maxY = (**m_printData.m_macPrintInfo).rPaper.bottom - (**m_printData.m_macPrintInfo).rPaper.top ;
#else
#pragma warning "TODO:printing support for carbon"
#endif
} }
wxPrinterDC::~wxPrinterDC(void) wxPrinterDC::~wxPrinterDC(void)
{ {
#if !TARGET_CARBON
if ( m_ok ) if ( m_ok )
{ {
OSErr err ; OSErr err ;
@@ -91,11 +107,16 @@ wxPrinterDC::~wxPrinterDC(void)
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
PrClose() ; UMAPrClose() ;
} }
::PrClose() ; ::UMAPrClose() ;
::SetPort( macPrintFormerPort ) ; // ::SetPort( macPrintFormerPort ) ;
::SetPort( LMGetWMgrPort() ) ;
m_macPortHelper.Clear() ;
} }
#else
#pragma warning "TODO:printing support for carbon"
#endif
} }
bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) ) bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) )
@@ -109,13 +130,30 @@ void wxPrinterDC::EndDoc(void)
void wxPrinterDC::StartPage(void) void wxPrinterDC::StartPage(void)
{ {
#if !TARGET_CARBON
if ( !m_ok ) if ( !m_ok )
return ; return ;
m_logicalFunction = wxCOPY;
// m_textAlignment = wxALIGN_TOP_LEFT;
m_backgroundMode = wxTRANSPARENT;
m_textForegroundColour = *wxBLACK;
m_textBackgroundColour = *wxWHITE;
m_pen = *wxBLACK_PEN;
m_font = *wxNORMAL_FONT;
m_brush = *wxTRANSPARENT_BRUSH;
m_backgroundBrush = *wxWHITE_BRUSH;
m_macFontInstalled = false ;
m_macBrushInstalled = false ;
m_macPenInstalled = false ;
OSErr err ; OSErr err ;
wxString message ; wxString message ;
PrOpenPage( m_macPrintPort , NULL ) ; PrOpenPage( m_macPrintPort , NULL ) ;
SetOrigin( - (**m_printData.m_macPrintInfo).rPaper.left , - (**m_printData.m_macPrintInfo).rPaper.top ) ; SetOrigin( - (**m_printData.m_macPrintInfo).rPaper.left , - (**m_printData.m_macPrintInfo).rPaper.top ) ;
Rect clip = { -32000 , -32000 , 32000 , 32000 } ; Rect clip = { -32000 , -32000 , 32000 , 32000 } ;
::ClipRect( &clip ) ; ::ClipRect( &clip ) ;
@@ -126,14 +164,18 @@ void wxPrinterDC::StartPage(void)
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
::PrClosePage( m_macPrintPort) ; ::PrClosePage( m_macPrintPort) ;
::PrCloseDoc( m_macPrintPort ) ; ::PrCloseDoc( m_macPrintPort ) ;
::PrClose() ; ::UMAPrClose() ;
::SetPort( macPrintFormerPort ) ; ::SetPort( macPrintFormerPort ) ;
m_ok = FALSE ; m_ok = FALSE ;
} }
#else
#pragma warning "TODO:printing support for carbon"
#endif
} }
void wxPrinterDC::EndPage(void) void wxPrinterDC::EndPage(void)
{ {
#if !TARGET_CARBON
if ( !m_ok ) if ( !m_ok )
return ; return ;
@@ -147,8 +189,12 @@ void wxPrinterDC::EndPage(void)
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
::PrCloseDoc( m_macPrintPort ) ; ::PrCloseDoc( m_macPrintPort ) ;
::PrClose() ; ::UMAPrClose() ;
::SetPort( macPrintFormerPort ) ; ::SetPort( macPrintFormerPort ) ;
m_ok = FALSE ; m_ok = FALSE ;
} }
#else
#pragma warning "TODO:printing support for carbon"
#endif
} }

View File

@@ -14,15 +14,34 @@
#endif #endif
#include "wx/dcscreen.h" #include "wx/dcscreen.h"
#include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
#endif
// Create a DC representing the whole screen // Create a DC representing the whole screen
wxScreenDC::wxScreenDC() wxScreenDC::wxScreenDC()
{ {
#if TARGET_CARBON
m_macPort = GetQDGlobalsThePort() ;
#else
m_macPort = LMGetWMgrPort() ; m_macPort = LMGetWMgrPort() ;
#endif
MacSetupPort() ; MacSetupPort() ;
m_ok = TRUE ; m_ok = TRUE ;
BitMap screenBits;
GetQDGlobalsScreenBits( &screenBits );
m_minX = screenBits.bounds.left ;
#if TARGET_CARBON
SInt16 height ;
GetThemeMenuBarHeight( &height ) ;
m_minY = screenBits.bounds.top + height ;
#else
m_minY = screenBits.bounds.top + LMGetMBarHeight() ;
#endif
m_maxX = screenBits.bounds.right ;
m_maxY = screenBits.bounds.bottom ;
} }
wxScreenDC::~wxScreenDC() wxScreenDC::~wxScreenDC()

View File

@@ -27,6 +27,7 @@ wxList wxModalDialogs;
wxList wxModelessWindows; // Frames and modeless dialogs wxList wxModelessWindows; // Frames and modeless dialogs
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel) IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
BEGIN_EVENT_TABLE(wxDialog, wxPanel) BEGIN_EVENT_TABLE(wxDialog, wxPanel)
@@ -39,11 +40,11 @@ BEGIN_EVENT_TABLE(wxDialog, wxPanel)
EVT_CLOSE(wxDialog::OnCloseWindow) EVT_CLOSE(wxDialog::OnCloseWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
wxDialog::wxDialog() wxDialog::wxDialog()
{ {
m_isShown = FALSE; m_isShown = FALSE;
m_modalShowing = FALSE;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
} }
@@ -54,15 +55,8 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
long style, long style,
const wxString& name) const wxString& name)
{ {
m_windowStyle = style;
m_isShown = FALSE;
m_modalShowing = FALSE;
#if wxUSE_TOOLTIPS
m_hwndToolTip = 0;
#endif
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
SetName(name);
if (!parent) if (!parent)
wxTopLevelWindows.Append(this); wxTopLevelWindows.Append(this);
@@ -74,59 +68,26 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
else else
m_windowId = id; m_windowId = id;
Rect theBoundsRect; MacCreateRealWindow( title , pos , size , MacRemoveBordersFromStyle(style) , name ) ;
m_x = (int)pos.x;
m_y = (int)pos.y;
if ( m_y < 50 )
m_y = 50 ;
if ( m_x < 20 )
m_x = 20 ;
m_width = size.x;
if (m_width == -1)
m_width = 20;
m_height = size.y;
if (m_height == -1)
m_height = 20;
::SetRect(&theBoundsRect, m_x, m_y, m_x + m_width, m_y + m_height);
m_macWindowData = new MacWindowData() ;
WindowClass wclass = kMovableModalWindowClass ;
WindowAttributes attr = kWindowNoAttributes ;
if ( ( m_windowStyle & wxMINIMIZE_BOX ) || ( m_windowStyle & wxMAXIMIZE_BOX ) )
{
attr |= kWindowFullZoomAttribute ;
attr |= kWindowResizableAttribute ;
}
UMACreateNewWindow( wclass , attr , &theBoundsRect , &m_macWindowData->m_macWindow ) ;
wxAssociateWinWithMacWindow( m_macWindowData->m_macWindow , this ) ;
wxString label ;
if( wxApp::s_macDefaultEncodingIsPC )
label = wxMacMakeMacStringFromPC( title ) ;
else
label = title ;
UMASetWTitleC( m_macWindowData->m_macWindow , label ) ;
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ; m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ;
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
m_macWindowData->m_macFocus = NULL ;
return TRUE; return TRUE;
} }
void wxDialog::SetModal(bool flag) void wxDialog::SetModal(bool flag)
{ {
if ( flag ) if ( flag )
m_windowStyle |= wxDIALOG_MODAL ; {
else m_windowStyle |= wxDIALOG_MODAL;
if ( m_windowStyle & wxDIALOG_MODAL )
m_windowStyle -= wxDIALOG_MODAL ;
wxModelessWindows.DeleteObject(this); wxModelessWindows.DeleteObject(this);
if (!flag) }
wxModelessWindows.Append(this); else
{
m_windowStyle &= ~wxDIALOG_MODAL;
wxModelessWindows.Append(this);
}
} }
wxDialog::~wxDialog() wxDialog::~wxDialog()
@@ -134,10 +95,10 @@ wxDialog::~wxDialog()
m_isBeingDeleted = TRUE ; m_isBeingDeleted = TRUE ;
wxTopLevelWindows.DeleteObject(this); wxTopLevelWindows.DeleteObject(this);
m_modalShowing = FALSE; Show(FALSE);
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL ) if ( !IsModal() )
wxModelessWindows.DeleteObject(this); wxModelessWindows.DeleteObject(this);
// If this is the last top-level window, exit. // If this is the last top-level window, exit.
if (wxTheApp && (wxTopLevelWindows.Number() == 0)) if (wxTheApp && (wxTopLevelWindows.Number() == 0))
@@ -184,19 +145,20 @@ void wxDialog::DoSetClientSize(int width, int height)
wxWindow::DoSetClientSize( width , height ) ; wxWindow::DoSetClientSize( width , height ) ;
} }
void wxDialog::GetPosition(int *x, int *y) const void wxDialog::DoGetPosition(int *x, int *y) const
{ {
DoGetPosition( x , y ) ; wxWindow::DoGetPosition( x , y ) ;
}
bool wxDialog::IsShown() const
{
return m_isShown;
} }
bool wxDialog::IsModal() const bool wxDialog::IsModal() const
{ {
return wxModalDialogs.Find((wxDialog *)this) != 0; // const_cast return (GetWindowStyleFlag() & wxDIALOG_MODAL) != 0;
}
bool wxDialog::IsModalShowing() const
{
return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
} }
@@ -204,121 +166,76 @@ extern bool s_macIsInModalLoop ;
bool wxDialog::Show(bool show) bool wxDialog::Show(bool show)
{ {
m_isShown = show; if ( !wxDialogBase::Show(show) )
if (show)
InitDialog();
bool modal = ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL) ;
#if WXGARBAGE_COLLECTION_ON /* MATTHEW: GC */
if (!modal)
{
if (show)
{ {
if (!wxModelessWindows.Find(this)) // nothing to do
wxModelessWindows.Append(this); return FALSE;
} }
else
wxModelessWindows.DeleteObject(this);
}
if (show)
{
if (!wxTopLevelWindows.Find(this))
wxTopLevelWindows.Append(this);
}
else
wxTopLevelWindows.DeleteObject(this);
#endif
if ( modal ) if ( show )
{
// usually will result in TransferDataToWindow() being called
InitDialog();
}
if ( IsModal() )
{
if ( show )
{
DoShowModal();
}
else // end of modal dialog
{
// this will cause IsModalShowing() return FALSE and our local
// message loop will terminate
wxModalDialogs.DeleteObject(this);
}
}
return TRUE;
}
void wxDialog::DoShowModal()
{
wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );
wxModalDialogs.Append(this);
wxWindow *parent = GetParent();
// remember where the focus was
wxWindow *winFocus = FindFocus();
if ( !winFocus )
{
winFocus = parent;
}
if ( !winFocus )
{
winFocus = wxTheApp->GetTopWindow();
}
// TODO : test whether parent gets disabled
s_macIsInModalLoop = true ;
while ( IsModalShowing() )
{ {
s_macIsInModalLoop = true ; while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() )
if (show) {
{ }
if (m_modalShowing) wxTheApp->MacDoOneEvent() ;
{
// BringWindowToTop((HWND) GetHWND());
return TRUE;
}
m_modalShowing = TRUE;
// if we don't do it, some window might be deleted while we have pointers
// to them in our disabledWindows list and the program will crash when it
// will try to reenable them after the modal dialog end
wxTheApp->DeletePendingObjects();
UMAShowWindow( m_macWindowData->m_macWindow ) ;
UMASelectWindow( m_macWindowData->m_macWindow ) ;
if (!wxModalDialogs.Member(this))
wxModalDialogs.Append(this);
while (wxModalDialogs.Member(this) )
{
wxTheApp->MacDoOneEvent() ;
}
}
else
{
wxModalDialogs.DeleteObject(this);
UMAHideWindow( m_macWindowData->m_macWindow ) ;
}
s_macIsInModalLoop = false ;
} }
else // !modal
{ s_macIsInModalLoop = false ;
if (show)
{ // TODO probably reenable the parent window if any
UMAShowWindow( m_macWindowData->m_macWindow ) ;
UMASelectWindow( m_macWindowData->m_macWindow ) ; // and restore focus
} if ( winFocus )
else {
{ winFocus->SetFocus();
UMAHideWindow( m_macWindowData->m_macWindow ) ; }
}
}
return TRUE ;
} }
void wxDialog::SetTitle(const wxString& title)
{
wxWindow::SetTitle( title ) ;
}
wxString wxDialog::GetTitle() const
{
return wxWindow::GetTitle() ;
}
void wxDialog::Centre(int direction)
{
int x_offset,y_offset ;
int display_width, display_height;
int width, height, x, y;
wxWindow *parent = GetParent();
if ((direction & wxCENTER_FRAME) && parent)
{
parent->GetPosition(&x_offset,&y_offset) ;
parent->GetSize(&display_width,&display_height) ;
}
else
{
wxDisplaySize(&display_width, &display_height);
x_offset = 0 ;
y_offset = 0 ;
}
GetSize(&width, &height);
GetPosition(&x, &y);
if (direction & wxHORIZONTAL)
x = (int)((display_width - width)/2);
if (direction & wxVERTICAL)
y = (int)((display_height - height)/2);
SetSize(x+x_offset, y+y_offset, width, height);
}
// Replacement for Show(TRUE) for modal dialogs - returns return code // Replacement for Show(TRUE) for modal dialogs - returns return code
int wxDialog::ShowModal() int wxDialog::ShowModal()
@@ -328,6 +245,8 @@ int wxDialog::ShowModal()
return GetReturnCode(); return GetReturnCode();
} }
// NB: this function (surprizingly) may be called for both modal and modeless
// dialogs and should work for both of them
void wxDialog::EndModal(int retCode) void wxDialog::EndModal(int retCode)
{ {
SetReturnCode(retCode); SetReturnCode(retCode);
@@ -339,13 +258,7 @@ void wxDialog::OnOK(wxCommandEvent& event)
{ {
if ( Validate() && TransferDataFromWindow() ) if ( Validate() && TransferDataFromWindow() )
{ {
if ( IsModal() ) EndModal(wxID_OK);
EndModal(wxID_OK);
else
{
SetReturnCode(wxID_OK);
this->Show(FALSE);
}
} }
} }
@@ -358,20 +271,7 @@ void wxDialog::OnApply(wxCommandEvent& event)
void wxDialog::OnCancel(wxCommandEvent& event) void wxDialog::OnCancel(wxCommandEvent& event)
{ {
if ( IsModal() )
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
else
{
SetReturnCode(wxID_CANCEL);
this->Show(FALSE);
}
}
void wxDialog::OnPaint(wxPaintEvent& event)
{
// No: if you call the default procedure, it makes
// the following painting code not work.
// wxWindow::OnPaint(event);
} }
void wxDialog::OnCloseWindow(wxCloseEvent& event) void wxDialog::OnCloseWindow(wxCloseEvent& event)
@@ -407,30 +307,16 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event)
// Destroy the window (delayed, if a managed window) // Destroy the window (delayed, if a managed window)
bool wxDialog::Destroy() bool wxDialog::Destroy()
{ {
if (!wxPendingDelete.Member(this)) wxCHECK_MSG( !wxPendingDelete.Member(this), FALSE,
_T("wxDialog destroyed twice") );
wxPendingDelete.Append(this); wxPendingDelete.Append(this);
return TRUE; return TRUE;
} }
void wxDialog::OnSize(wxSizeEvent& WXUNUSED(event))
{
// if we're using constraints - do use them
#if wxUSE_CONSTRAINTS
if ( GetAutoLayout() )
{
Layout();
}
#endif
}
void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event)
{ {
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
Refresh(); Refresh();
} }
void wxDialog::Fit()
{
wxWindow::Fit();
}

View File

@@ -147,6 +147,7 @@ bool wxDirData::Read(wxString *filename)
if ( err != noErr ) if ( err != noErr )
break ; break ;
p2cstr( m_name ) ;
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory
break ; break ;
@@ -156,17 +157,37 @@ bool wxDirData::Read(wxString *filename)
if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) // its hidden but we don't want it if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) // its hidden but we don't want it
continue ; continue ;
wxString file( m_name ) ;
if ( m_filespec.IsEmpty() || m_filespec == "*.*" )
{
}
else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" )
{
if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
{
continue ;
}
}
else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" )
{
if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
{
continue ;
}
}
else if ( file.Upper() != m_filespec.Upper() )
{
continue ;
}
break ; break ;
} }
if ( err != noErr ) if ( err != noErr )
{ {
return FALSE ; return FALSE ;
} }
FSSpec spec ;
FSMakeFSSpecCompat(m_CPB.hFileInfo.ioVRefNum, m_dirId, m_name,&spec) ; *filename = (char*) m_name ;
*filename = wxMacFSSpec2UnixFilename( &spec ) ;
return TRUE; return TRUE;
} }

View File

@@ -20,19 +20,9 @@
#include "wx/cmndata.h" #include "wx/cmndata.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_CLASS(wxDirDialog, wxDialog) IMPLEMENT_CLASS(wxDirDialog, wxDialog)
#endif
enum {
kSelectItem = 10, // select button item number
kSFGetFolderDlgID = 250, // dialog resource number
kStrListID = 250, // our strings
kSelectStrNum = 1, // word 'Select: ' for button
kDesktopStrNum = 2, // word 'Desktop' for button
kSelectNoQuoteStrNum = 3, // word 'Select: ' for button
kUseQuotes = true, // parameter for SetButtonName
kDontUseQuotes = false
};
// 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
@@ -48,6 +38,21 @@ struct UserDataRec {
typedef struct UserDataRec typedef struct UserDataRec
UserDataRec, *UserDataRecPtr; UserDataRec, *UserDataRecPtr;
#if !TARGET_CARBON
enum {
kSelectItem = 10, // select button item number
kSFGetFolderDlgID = 250, // dialog resource number
kStrListID = 250, // our strings
kSelectStrNum = 1, // word 'Select: ' for button
kDesktopStrNum = 2, // word 'Desktop' for button
kSelectNoQuoteStrNum = 3, // word 'Select: ' for button
kUseQuotes = true, // parameter for SetButtonName
kDontUseQuotes = false
};
static void GetLabelString(StringPtr theStr, short stringNum) static void GetLabelString(StringPtr theStr, short stringNum)
{ {
GetIndString(theStr, kStrListID, stringNum); GetIndString(theStr, kStrListID, stringNum);
@@ -302,6 +307,7 @@ static pascal short SFGetFolderDialogHook(short item, DialogPtr theDlgPtr, Ptr d
return item; return item;
} }
#endif
void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileFilterYDUPP fileFilter, StandardFileReply *theSFR) void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileFilterYDUPP fileFilter, StandardFileReply *theSFR)
{ {
@@ -321,7 +327,7 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
// set initial contents of Select button to a space // set initial contents of Select button to a space
CopyPStr("\p ", theSFR->sfFile.name); memcpy(theSFR->sfFile.name, "\p ", 2);
// point the user data parameter at the reply record so we can get to it later // point the user data parameter at the reply record so we can get to it later
@@ -329,6 +335,8 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
// display the dialog // display the dialog
#if !TARGET_CARBON
dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook); dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook);
myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter); myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter);
@@ -350,6 +358,8 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
DisposeRoutineDescriptor(dlgHookUPP); DisposeRoutineDescriptor(dlgHookUPP);
DisposeRoutineDescriptor(myModalFilterUPP); DisposeRoutineDescriptor(myModalFilterUPP);
#else
#endif
// if cancel wasn't pressed and no fatal error occurred... // if cancel wasn't pressed and no fatal error occurred...
@@ -445,14 +455,18 @@ int wxDirDialog::ShowModal()
strcpy((char *)path, m_path ) ; strcpy((char *)path, m_path ) ;
c2pstr((char *)path ) ; c2pstr((char *)path ) ;
FileFilterYDUPP invisiblesExcludedCustomFilterUPP;
StandardFileReply reply ; StandardFileReply reply ;
FileFilterYDUPP invisiblesExcludedCustomFilterUPP = 0 ;
#if !TARGET_CARBON
invisiblesExcludedCustomFilterUPP = invisiblesExcludedCustomFilterUPP =
NewFileFilterYDProc(OnlyVisibleFoldersCustomFileFilter); NewFileFilterYDProc(OnlyVisibleFoldersCustomFileFilter);
#endif
StandardGetFolder( prompt , path , invisiblesExcludedCustomFilterUPP, &reply); StandardGetFolder( prompt , path , invisiblesExcludedCustomFilterUPP, &reply);
#if !TARGET_CARBON
DisposeRoutineDescriptor(invisiblesExcludedCustomFilterUPP); DisposeRoutineDescriptor(invisiblesExcludedCustomFilterUPP);
#endif
if ( reply.sfGood == false ) if ( reply.sfGood == false )
{ {
m_path = "" ; m_path = "" ;

View File

@@ -18,6 +18,8 @@
#include "wx/app.h" #include "wx/app.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#if wxUSE_DRAG_AND_DROP
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global // global
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -131,3 +133,4 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
return wxDragError; return wxDragError;
}; };
#endif

View File

@@ -19,7 +19,9 @@
#include "wx/filedlg.h" #include "wx/filedlg.h"
#include "wx/intl.h" #include "wx/intl.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_CLASS(wxFileDialog, wxDialog) IMPLEMENT_CLASS(wxFileDialog, wxDialog)
#endif
// begin wxmac // begin wxmac
@@ -43,6 +45,27 @@ OSType gfiltersmac[] =
'****' '****'
} ; } ;
// the data we need to pass to our standard file hook routine
// includes a pointer to the dialog, a pointer to the standard
// file reply record (so we can inspect the current selection)
// and a copy of the "previous" file spec of the reply record
// so we can see if the selection has changed
const int kwxMacFileTypes = 10 ;
struct OpenUserDataRec {
StandardFileReply *sfrPtr;
FSSpec oldSelectionFSSpec;
char filter[kwxMacFileTypes][10] ;
OSType filtermactypes[kwxMacFileTypes] ;
int numfilters ;
DialogPtr theDlgPtr;
};
typedef struct OpenUserDataRec
OpenUserDataRec, *OpenUserDataRecPtr;
#if !TARGET_CARBON
static void wxMacSetupStandardFile(short newVRefNum, long newDirID) static void wxMacSetupStandardFile(short newVRefNum, long newDirID)
{ {
enum enum
@@ -97,25 +120,6 @@ enum {
kDontUseQuotes = false kDontUseQuotes = false
}; };
// the data we need to pass to our standard file hook routine
// includes a pointer to the dialog, a pointer to the standard
// file reply record (so we can inspect the current selection)
// and a copy of the "previous" file spec of the reply record
// so we can see if the selection has changed
const int kwxMacFileTypes = 10 ;
struct OpenUserDataRec {
StandardFileReply *sfrPtr;
FSSpec oldSelectionFSSpec;
char filter[kwxMacFileTypes][10] ;
OSType filtermactypes[kwxMacFileTypes] ;
int numfilters ;
DialogPtr theDlgPtr;
};
typedef struct OpenUserDataRec
OpenUserDataRec, *OpenUserDataRecPtr;
static void GetLabelString(StringPtr theStr, short stringNum) static void GetLabelString(StringPtr theStr, short stringNum)
{ {
GetIndString(theStr, kStrListID, stringNum); GetIndString(theStr, kStrListID, stringNum);
@@ -185,6 +189,7 @@ static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRec
return false; return false;
} }
#endif
void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const char *filter , FileFilterYDUPP fileFilter, StandardFileReply *theSFR) void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const char *filter , FileFilterYDUPP fileFilter, StandardFileReply *theSFR)
{ {
@@ -204,7 +209,7 @@ void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const
// set initial contents of Select button to a space // set initial contents of Select button to a space
CopyPStr("\p ", theSFR->sfFile.name); memcpy( theSFR->sfFile.name , "\p " , 2 ) ;
// point the user data parameter at the reply record so we can get to it later // point the user data parameter at the reply record so we can get to it later
@@ -241,6 +246,8 @@ void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const
} }
// display the dialog // display the dialog
#if !TARGET_CARBON
dlgHookUPP = NULL ; dlgHookUPP = NULL ;
// dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook); // dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook);
myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter); myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter);
@@ -263,7 +270,8 @@ void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const
DisposeRoutineDescriptor(dlgHookUPP); DisposeRoutineDescriptor(dlgHookUPP);
DisposeRoutineDescriptor(myModalFilterUPP); DisposeRoutineDescriptor(myModalFilterUPP);
#else
#endif
// if cancel wasn't pressed and no fatal error occurred... // if cancel wasn't pressed and no fatal error occurred...
if (theSFR->sfGood) if (theSFR->sfGood)
@@ -454,8 +462,12 @@ int wxFileDialog::ShowModal()
strcpy((char *)filename, m_fileName) ; strcpy((char *)filename, m_fileName) ;
c2pstr((char *)filename ) ; c2pstr((char *)filename ) ;
#if !TARGET_CARBON
StandardPutFile( prompt , filename , &reply ) ; StandardPutFile( prompt , filename , &reply ) ;
#else
#endif
if ( reply.sfGood == false ) if ( reply.sfGood == false )
{ {
m_path = "" ; m_path = "" ;
@@ -479,14 +491,17 @@ int wxFileDialog::ShowModal()
strcpy((char *)path, m_path ) ; strcpy((char *)path, m_path ) ;
c2pstr((char *)path ) ; c2pstr((char *)path ) ;
FileFilterYDUPP crossPlatformFileFilterUPP;
StandardFileReply reply ; StandardFileReply reply ;
FileFilterYDUPP crossPlatformFileFilterUPP = 0 ;
#if !TARGET_CARBON
crossPlatformFileFilterUPP = crossPlatformFileFilterUPP =
NewFileFilterYDProc(CrossPlatformFileFilter); NewFileFilterYDProc(CrossPlatformFileFilter);
#endif
ExtendedOpenFile( prompt , path , m_wildCard , crossPlatformFileFilterUPP, &reply); ExtendedOpenFile( prompt , path , m_wildCard , crossPlatformFileFilterUPP, &reply);
#if !TARGET_CARBON
DisposeRoutineDescriptor(crossPlatformFileFilterUPP); DisposeFileFilterYDUPP(crossPlatformFileFilterUPP);
#endif
if ( reply.sfGood == false ) if ( reply.sfGood == false )
{ {
m_path = "" ; m_path = "" ;

View File

@@ -18,7 +18,9 @@
#include "wx/font.h" #include "wx/font.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
#endif
@@ -77,7 +79,7 @@ void wxFontRefData::MacFindFont()
::GetFNum( "\pTimes" , &m_macFontNum) ; ::GetFNum( "\pTimes" , &m_macFontNum) ;
break ; break ;
case wxSWISS : case wxSWISS :
::GetFNum( "\pHelvetica" , &m_macFontNum) ; ::GetFNum( "\pGeneva" , &m_macFontNum) ;
break ; break ;
case wxMODERN : case wxMODERN :
::GetFNum( "\pMonaco" , &m_macFontNum) ; ::GetFNum( "\pMonaco" , &m_macFontNum) ;

View File

@@ -17,7 +17,9 @@
#include "wx/mac/fontdlg.h" #include "wx/mac/fontdlg.h"
#include "wx/cmndata.h" #include "wx/cmndata.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog) IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
#endif
/* /*
* wxFontDialog * wxFontDialog

View File

@@ -48,18 +48,12 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// convert to/from the string representation: format is // convert to/from the string representation: format is
// encodingid;facename[;charset] // facename[;charset]
bool wxNativeEncodingInfo::FromString(const wxString& s) bool wxNativeEncodingInfo::FromString(const wxString& s)
{ {
wxStringTokenizer tokenizer(s, _T(";")); wxStringTokenizer tokenizer(s, _T(";"));
wxString encid = tokenizer.GetNextToken();
long enc;
if ( !encid.ToLong(&enc) )
return FALSE;
encoding = (wxFontEncoding)enc;
facename = tokenizer.GetNextToken(); facename = tokenizer.GetNextToken();
if ( !facename ) if ( !facename )
return FALSE; return FALSE;
@@ -85,10 +79,7 @@ bool wxNativeEncodingInfo::FromString(const wxString& s)
wxString wxNativeEncodingInfo::ToString() const wxString wxNativeEncodingInfo::ToString() const
{ {
wxString s; wxString s(facename);
s << (long)encoding << _T(';') << facename;
if ( charset != 0 ) if ( charset != 0 )
{ {
s << _T(';') << charset; s << _T(';') << charset;
@@ -159,8 +150,6 @@ bool wxGetNativeFontEncoding(wxFontEncoding encoding,
return FALSE; return FALSE;
} }
info->encoding = encoding;
return TRUE; return TRUE;
} }

View File

@@ -14,7 +14,7 @@
#endif #endif
#include "wx/frame.h" #include "wx/frame.h"
#include "wx/statusbr.h" #include "wx/mac/statusbr.h"
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/menuitem.h" #include "wx/menuitem.h"
#include "wx/menu.h" #include "wx/menu.h"
@@ -28,16 +28,18 @@
extern wxList wxModelessWindows; extern wxList wxModelessWindows;
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
BEGIN_EVENT_TABLE(wxFrame, wxWindow) #if !USE_SHARED_LIBRARY
EVT_SIZE(wxFrame::OnSize) BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
// EVT_SIZE(wxFrame::OnSize)
EVT_ACTIVATE(wxFrame::OnActivate) EVT_ACTIVATE(wxFrame::OnActivate)
EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) // EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
EVT_IDLE(wxFrame::OnIdle) // EVT_IDLE(wxFrame::OnIdle)
EVT_CLOSE(wxFrame::OnCloseWindow) // EVT_CLOSE(wxFrame::OnCloseWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
#endif
#if wxUSE_NATIVE_STATUSBAR #if wxUSE_NATIVE_STATUSBAR
bool wxFrame::m_useNativeStatusBar = TRUE; bool wxFrame::m_useNativeStatusBar = TRUE;
@@ -45,17 +47,43 @@ bool wxFrame::m_useNativeStatusBar = TRUE;
bool wxFrame::m_useNativeStatusBar = FALSE; bool wxFrame::m_useNativeStatusBar = FALSE;
#endif #endif
wxFrame::wxFrame() #define WX_MAC_STATUSBAR_HEIGHT 15
{ // ----------------------------------------------------------------------------
#if wxUSE_TOOLBAR // creation/destruction
m_frameToolBar = NULL ; // ----------------------------------------------------------------------------
#endif
// in order to be able to give size events on show void wxFrame::Init()
m_frameMenuBar = NULL; {
m_frameStatusBar = NULL; m_iconized = FALSE;
m_iconized = FALSE;
m_isShown = FALSE; #if wxUSE_TOOLTIPS
m_hwndToolTip = 0;
#endif
}
wxPoint wxFrame::GetClientAreaOrigin() const
{
// on mac we are at position -1,-1 with the control
wxPoint pt(0, 0);
#if wxUSE_TOOLBAR
if ( GetToolBar() )
{
int w, h;
GetToolBar()->GetSize(& w, & h);
if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
{
pt.x += w - 1;
}
else
{
pt.y += h - 1 ;
}
}
#endif // wxUSE_TOOLBAR
return pt;
} }
bool wxFrame::Create(wxWindow *parent, bool wxFrame::Create(wxWindow *parent,
@@ -66,13 +94,7 @@ bool wxFrame::Create(wxWindow *parent,
long style, long style,
const wxString& name) const wxString& name)
{ {
if (!parent)
wxTopLevelWindows.Append(this);
SetName(name);
m_windowStyle = style;
m_frameMenuBar = NULL; m_frameMenuBar = NULL;
m_isShown = FALSE;
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
m_frameToolBar = NULL ; m_frameToolBar = NULL ;
@@ -88,74 +110,24 @@ bool wxFrame::Create(wxWindow *parent,
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
if (!parent)
wxTopLevelWindows.Append(this);
MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
wxModelessWindows.Append(this); wxModelessWindows.Append(this);
// create frame.
Rect theBoundsRect;
m_x = (int)pos.x;
m_y = (int)pos.y;
if ( m_y < 50 )
m_y = 50 ;
if ( m_x < 20 )
m_x = 20 ;
m_width = size.x;
if (m_width == -1)
m_width = 20;
m_height = size.y;
if (m_height == -1)
m_height = 20;
m_macWindowData = new MacWindowData() ;
::SetRect(&theBoundsRect, m_x, m_y, m_x + m_width, m_y + m_height);
WindowClass wclass = kDocumentWindowClass ;
WindowAttributes attr = kWindowNoAttributes ;
if ( ( m_windowStyle & wxMINIMIZE_BOX ) || ( m_windowStyle & wxMAXIMIZE_BOX ) )
{
attr |= kWindowFullZoomAttribute ;
attr |= kWindowResizableAttribute ;
}
if ( m_windowStyle & wxSTAY_ON_TOP )
{
wclass = kFloatingWindowClass ;
// if ( m_windowStyle & wxCAPTION )
// attr |= kHasPaletteTitlebarMask ;
}
else
{
}
if ( m_windowStyle & wxSYSTEM_MENU )
{
attr |= kWindowCloseBoxAttribute ;
}
UMACreateNewWindow( wclass , attr , &theBoundsRect , &m_macWindowData->m_macWindow ) ;
wxAssociateWinWithMacWindow( m_macWindowData->m_macWindow , this ) ;
wxString label ;
if( wxApp::s_macDefaultEncodingIsPC )
label = wxMacMakeMacStringFromPC( title ) ;
else
label = title ;
UMASetWTitleC( m_macWindowData->m_macWindow , label ) ;
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
m_macWindowData->m_macFocus = NULL ;
return TRUE; return TRUE;
} }
wxFrame::~wxFrame() wxFrame::~wxFrame()
{ {
m_isBeingDeleted = TRUE;
wxTopLevelWindows.DeleteObject(this); wxTopLevelWindows.DeleteObject(this);
if (m_frameStatusBar) DeleteAllBars();
delete m_frameStatusBar;
if (m_frameMenuBar)
delete m_frameMenuBar;
/* Check if it's the last top-level window */ /* Check if it's the last top-level window */
@@ -173,11 +145,21 @@ wxFrame::~wxFrame()
} }
void wxFrame::Iconize(bool iconize) bool wxFrame::Enable(bool enable)
{ {
// TODO if ( !wxWindow::Enable(enable) )
} return FALSE;
if ( m_frameMenuBar && m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar() )
{
for ( int i = 0 ; i < m_frameMenuBar->GetMenuCount() ; ++ i )
{
m_frameMenuBar->EnableTop( i , enable ) ;
}
}
return TRUE;
}
// Equivalent to maximize/restore in Windows // Equivalent to maximize/restore in Windows
void wxFrame::Maximize(bool maximize) void wxFrame::Maximize(bool maximize)
{ {
@@ -190,6 +172,11 @@ bool wxFrame::IsIconized() const
return FALSE; return FALSE;
} }
void wxFrame::Iconize(bool iconize)
{
// TODO
}
// Is the frame maximized? // Is the frame maximized?
bool wxFrame::IsMaximized(void) const bool wxFrame::IsMaximized(void) const
{ {
@@ -197,10 +184,14 @@ bool wxFrame::IsMaximized(void) const
return FALSE; return FALSE;
} }
void wxFrame::Restore()
{
// TODO
}
void wxFrame::SetIcon(const wxIcon& icon) void wxFrame::SetIcon(const wxIcon& icon)
{ {
m_icon = icon; wxFrameBase::SetIcon(icon);
// TODO
} }
wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id, wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
@@ -208,61 +199,12 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
{ {
wxStatusBar *statusBar = NULL; wxStatusBar *statusBar = NULL;
statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 17), statusBar = new wxStatusBar(this, id, style, name);
style, name);
// Set the height according to the font and the border size
// we shouldn't do this on the mac, because we have to fit the grow box
/*
wxClientDC dc(statusBar);
dc.SetFont(statusBar->GetFont());
long x, y;
dc.GetTextExtent("X", &x, &y);
int height = (int)( (y * 1.1) + 2* statusBar->GetBorderY());
statusBar->SetSize(-1, -1, 100, height);
*/
statusBar->SetFieldsCount(number); statusBar->SetFieldsCount(number);
return statusBar; return statusBar;
} }
wxStatusBar* wxFrame::CreateStatusBar(int number, long style, wxWindowID id,
const wxString& name)
{
// Calling CreateStatusBar twice is an error.
wxCHECK_MSG( m_frameStatusBar == NULL, FALSE,
"recreating status bar in wxFrame" );
m_frameStatusBar = OnCreateStatusBar(number, style, id,
name);
if ( m_frameStatusBar )
{
PositionStatusBar();
return m_frameStatusBar;
}
else
return NULL;
}
void wxFrame::SetStatusText(const wxString& text, int number)
{
wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" );
m_frameStatusBar->SetStatusText(text, number);
}
void wxFrame::SetStatusWidths(int n, const int widths_field[])
{
wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" );
m_frameStatusBar->SetStatusWidths(n, widths_field);
PositionStatusBar();
}
void wxFrame::PositionStatusBar() void wxFrame::PositionStatusBar()
{ {
if (m_frameStatusBar ) if (m_frameStatusBar )
@@ -274,7 +216,7 @@ void wxFrame::PositionStatusBar()
// Since we wish the status bar to be directly under the client area, // Since we wish the status bar to be directly under the client area,
// we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
m_frameStatusBar->SetSize(0, h, w, sh); m_frameStatusBar->SetSize(0, h, w, WX_MAC_STATUSBAR_HEIGHT );
} }
} }
@@ -282,43 +224,15 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar)
{ {
if (!menuBar) if (!menuBar)
{ {
m_frameMenuBar = NULL;
return; return;
} }
m_frameMenuBar = NULL;
m_frameMenuBar = menuBar; m_frameMenuBar = menuBar;
// TODO : we move this into the app code
m_frameMenuBar->MacInstallMenuBar() ; m_frameMenuBar->MacInstallMenuBar() ;
m_frameMenuBar->Attach(this);
} }
void wxFrame::Fit()
{
// Work out max. size
wxNode *node = GetChildren().First();
int max_width = 0;
int max_height = 0;
while (node)
{
// Find a child that's a subwindow, but not a dialog box.
wxWindow *win = (wxWindow *)node->Data();
if (!win->IsKindOf(CLASSINFO(wxFrame)) &&
!win->IsKindOf(CLASSINFO(wxDialog)))
{
int width, height;
int x, y;
win->GetSize(&width, &height);
win->GetPosition(&x, &y);
if ((x + width) > max_width)
max_width = x + width;
if ((y + height) > max_height)
max_height = y + height;
}
node = node->Next();
}
SetClientSize(max_width, max_height);
}
// Responds to colour changes, and passes event on to children. // Responds to colour changes, and passes event on to children.
void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
@@ -337,217 +251,55 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
wxWindow::OnSysColourChanged(event); wxWindow::OnSysColourChanged(event);
} }
// Default resizing behaviour - if only ONE subwindow,
// resize to client rectangle size
void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) )
{
DoMenuUpdates();
}
// update all menus
void wxFrame::DoMenuUpdates()
{
wxMenuBar* bar = GetMenuBar();
if ( bar != NULL )
{
int nCount = bar->GetMenuCount();
for (int n = 0; n < nCount; n++)
DoMenuUpdates(bar->GetMenu(n), (wxWindow*) NULL);
}
}
// update a menu and all submenus recursively
void wxFrame::DoMenuUpdates(wxMenu* menu, wxWindow* WXUNUSED(focusWin))
{
wxEvtHandler* evtHandler = GetEventHandler();
wxMenuItemList::Node* node = menu->GetMenuItems().GetFirst();
while (node)
{
wxMenuItem* item = node->GetData();
if ( !item->IsSeparator() )
{
wxWindowID id = item->GetId();
wxUpdateUIEvent event(id);
event.SetEventObject( this );
if (evtHandler->ProcessEvent(event))
{
if (event.GetSetText())
menu->SetLabel(id, event.GetText());
if (event.GetSetChecked())
menu->Check(id, event.GetChecked());
if (event.GetSetEnabled())
menu->Enable(id, event.GetEnabled());
}
if (item->GetSubMenu())
DoMenuUpdates(item->GetSubMenu(), (wxWindow*) NULL);
}
node = node->GetNext();
}
}
void wxFrame::OnSize(wxSizeEvent& event)
{
// if we're using constraints - do use them
#if wxUSE_CONSTRAINTS
if ( GetAutoLayout() ) {
Layout();
return;
}
#endif
// do we have _exactly_ one child?
wxWindow *child = NULL;
for ( wxNode *node = GetChildren().First(); node; node = node->Next() )
{
wxWindow *win = (wxWindow *)node->Data();
if ( !win->IsKindOf(CLASSINFO(wxFrame)) &&
!win->IsKindOf(CLASSINFO(wxDialog)) &&
(win != GetStatusBar())
#if wxUSE_TOOLBAR
&&
(win != GetToolBar())
#endif
)
{
if ( child )
return; // it's our second subwindow - nothing to do
child = win;
}
}
if ( child ) {
// we have exactly one child - set it's size to fill the whole frame
int clientW, clientH;
GetClientSize(&clientW, &clientH);
int x = 0;
int y = 0;
child->SetSize(x, y, clientW, clientH);
}
}
// Default activation behaviour - set the focus for the first child // Default activation behaviour - set the focus for the first child
// subwindow found. // subwindow found.
void wxFrame::OnActivate(wxActivateEvent& event) void wxFrame::OnActivate(wxActivateEvent& event)
{ {
for(wxNode *node = GetChildren().First(); node; node = node->Next()) if ( !event.GetActive() )
{
// Find a child that's a subwindow, but not a dialog box.
wxWindow *child = (wxWindow *)node->Data();
if (!child->IsKindOf(CLASSINFO(wxFrame)) &&
!child->IsKindOf(CLASSINFO(wxDialog)))
{ {
child->SetFocus(); event.Skip();
return; return;
} }
}
}
// The default implementation for the close window event. for ( wxWindowList::Node *node = GetChildren().GetFirst();
void wxFrame::OnCloseWindow(wxCloseEvent& event) node;
{ node = node->GetNext() )
this->Destroy();
}
// Destroy the window (delayed, if a managed window)
bool wxFrame::Destroy()
{
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
return TRUE;
}
// Default menu selection behaviour - display a help string
void wxFrame::OnMenuHighlight(wxMenuEvent& event)
{
if (GetStatusBar())
{
if (event.GetMenuId() == -1)
SetStatusText("");
else
{ {
wxMenuBar *menuBar = GetMenuBar(); // FIXME all this is totally bogus - we need to do the same as wxPanel,
if (menuBar) // but how to do it without duplicating the code?
{
wxString helpString(menuBar->GetHelpString(event.GetMenuId()));
if (helpString != "")
SetStatusText(helpString);
}
}
}
}
wxMenuBar *wxFrame::GetMenuBar() const // restore focus
{ wxWindow *child = node->GetData();
return m_frameMenuBar;
}
if ( !child->IsTopLevel()
// Call this to simulate a menu command
void wxFrame::Command(int id)
{
ProcessCommand(id);
}
void wxFrame::ProcessCommand(int id)
{
wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id);
commandEvent.SetInt( id );
commandEvent.SetEventObject( this );
wxMenuBar *bar = GetMenuBar() ;
if (!bar)
return;
/* TODO: check the menu item if required
wxMenuItem *item = bar->FindItemForId(id) ;
if (item && item->IsCheckable())
{
bar->Check(id,!bar->Checked(id)) ;
}
*/
GetEventHandler()->ProcessEvent(commandEvent);
}
// Checks if there is a toolbar, and returns the first free client position
wxPoint wxFrame::GetClientAreaOrigin() const
{
wxPoint pt(0, 0);
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
if (GetToolBar()) && !wxDynamicCast(child, wxToolBar)
{ #endif // wxUSE_TOOLBAR
int w, h; #if wxUSE_STATUSBAR
GetToolBar()->GetSize(& w, & h); && !wxDynamicCast(child, wxStatusBar)
#endif // wxUSE_STATUSBAR
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) )
{ {
pt.x += w; child->SetFocus();
} return;
else
{
pt.y += h;
} }
} }
#endif
return pt;
} }
void wxFrame::DoGetClientSize(int *x, int *y) const void wxFrame::DoGetClientSize(int *x, int *y) const
{ {
wxWindow::DoGetClientSize( x , y ) ; wxWindow::DoGetClientSize( x , y ) ;
#if wxUSE_STATUSBAR
if ( GetStatusBar() ) if ( GetStatusBar() )
{ {
int statusX, statusY; int statusX, statusY;
GetStatusBar()->GetClientSize(&statusX, &statusY); GetStatusBar()->GetClientSize(&statusX, &statusY);
*y -= statusY; // right now this is a constant, this might change someday
*y -= WX_MAC_STATUSBAR_HEIGHT ;
} }
#endif // wxUSE_STATUSBAR
wxPoint pt(GetClientAreaOrigin()); wxPoint pt(GetClientAreaOrigin());
*y -= pt.y; *y -= pt.y;
@@ -576,39 +328,20 @@ void wxFrame::DoSetClientSize(int clientwidth, int clientheight)
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
{ {
wxCHECK_MSG( m_frameToolBar == NULL, FALSE, if ( wxFrameBase::CreateToolBar(style, id, name) )
"recreating toolbar in wxFrame" );
wxToolBar* toolBar = OnCreateToolBar(style, id, name);
if (toolBar)
{ {
SetToolBar(toolBar);
PositionToolBar(); PositionToolBar();
return toolBar;
} }
else
{
return NULL;
}
}
wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name) return m_frameToolBar;
{
return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name);
} }
void wxFrame::PositionToolBar() void wxFrame::PositionToolBar()
{ {
int cw, ch; int cw, ch;
// TODO: we actually need to use the low-level client size, before cw = m_width ;
// the toolbar/status bar were added. ch = m_height ;
// So DEFINITELY replace the line below with something appropriate.
// GetClientSize(& cw, &ch);
cw = m_width ;
ch = m_height ;
if ( GetStatusBar() ) if ( GetStatusBar() )
{ {
@@ -627,12 +360,12 @@ void wxFrame::PositionToolBar()
// Use the 'real' position. wxSIZE_NO_ADJUSTMENTS // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
// means, pretend we don't have toolbar/status bar, so we // means, pretend we don't have toolbar/status bar, so we
// have the original client size. // have the original client size.
GetToolBar()->SetSize(0, 0, tw, ch, wxSIZE_NO_ADJUSTMENTS); GetToolBar()->SetSize(-1, -1, tw, ch + 2 , wxSIZE_NO_ADJUSTMENTS | wxSIZE_ALLOW_MINUS_ONE );
} }
else else
{ {
// Use the 'real' position // Use the 'real' position
GetToolBar()->SetSize(0, 0, cw, th, wxSIZE_NO_ADJUSTMENTS); GetToolBar()->SetSize(-1, -1, cw + 2, th, wxSIZE_NO_ADJUSTMENTS | wxSIZE_ALLOW_MINUS_ONE );
} }
} }
} }

View File

@@ -15,7 +15,9 @@
#include "wx/gauge.h" #include "wx/gauge.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
@@ -31,15 +33,13 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
m_rangeMax = range ; m_rangeMax = range ;
m_macHorizontalBorder = 2 ; // additional pixels around the real control
m_macVerticalBorder = 2 ;
if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y) if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y)
{ {
size = wxSize( 200 , 16 ) ; size = wxSize( 200 , 16 ) ;
} }
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , "" , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ;
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , range, m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , range,
kControlProgressBarProc , (long) this ) ; kControlProgressBarProc , (long) this ) ;
@@ -66,7 +66,7 @@ void wxGauge::SetRange(int r)
void wxGauge::SetValue(int pos) void wxGauge::SetValue(int pos)
{ {
m_gaugePos = pos; m_gaugePos = pos;
::SetControlValue( m_macControl , m_gaugePos ) ; ::SetControlValue( m_macControl , m_gaugePos ) ;
} }
int wxGauge::GetShadowWidth() const int wxGauge::GetShadowWidth() const

View File

@@ -15,6 +15,8 @@
#include "wx/gdiobj.h" #include "wx/gdiobj.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject)
#endif
// TODO: Nothing to do, unless you want to. // TODO: Nothing to do, unless you want to.

View File

@@ -17,7 +17,9 @@
#include <string.h> #include <string.h>
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxXXXXHelpController, wxHelpControllerBase) IMPLEMENT_DYNAMIC_CLASS(wxXXXXHelpController, wxHelpControllerBase)
#endif
wxXXXXHelpController::wxXXXXHelpController() wxXXXXHelpController::wxXXXXHelpController()
{ {

View File

@@ -15,7 +15,9 @@
#include "wx/icon.h" #include "wx/icon.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
#endif
/* /*
* Icons * Icons
@@ -58,6 +60,14 @@ wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(he
{ {
} }
wxIcon::wxIcon( const char **bits, int width, int height )
{
}
wxIcon::wxIcon( char **bits, int width, int height )
{
}
wxIcon::wxIcon(const wxString& icon_file, long flags, wxIcon::wxIcon(const wxString& icon_file, long flags,
int desiredWidth, int desiredHeight) int desiredWidth, int desiredHeight)
@@ -96,20 +106,23 @@ bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, lo
c2pstr( (char*) theName ) ; c2pstr( (char*) theName ) ;
Handle resHandle = GetNamedResource( 'cicn' , theName ) ; Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
GetResInfo( resHandle , &theId , &theType , theName ) ; if ( resHandle != 0L )
ReleaseResource( resHandle ) ;
CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
if ( theIcon )
{ {
M_ICONHANDLERDATA->m_hIcon = theIcon ; GetResInfo( resHandle , &theId , &theType , theName ) ;
M_ICONHANDLERDATA->m_width = 32 ; ReleaseResource( resHandle ) ;
M_ICONHANDLERDATA->m_height = 32 ;
M_ICONHANDLERDATA->m_depth = 8 ; CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
M_ICONHANDLERDATA->m_ok = true ; if ( theIcon )
M_ICONHANDLERDATA->m_numColors = 256 ; {
return TRUE ; M_ICONHANDLERDATA->m_hIcon = theIcon ;
M_ICONHANDLERDATA->m_width = 32 ;
M_ICONHANDLERDATA->m_height = 32 ;
M_ICONHANDLERDATA->m_depth = 8 ;
M_ICONHANDLERDATA->m_ok = true ;
M_ICONHANDLERDATA->m_numColors = 256 ;
return TRUE ;
}
} }
return FALSE ; return FALSE ;
} }

View File

@@ -15,7 +15,9 @@
#include "wx/stubs/imaglist.h" #include "wx/stubs/imaglist.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject)
#endif
wxImageList::wxImageList() wxImageList::wxImageList()
{ {

View File

@@ -21,11 +21,13 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "extldef.h" #include "extldef.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
BEGIN_EVENT_TABLE(wxListBox, wxControl) BEGIN_EVENT_TABLE(wxListBox, wxControl)
EVT_SIZE( wxListBox::OnSize ) EVT_SIZE( wxListBox::OnSize )
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
@@ -41,6 +43,7 @@ wxListBox::wxListBox()
{ {
m_noItems = 0; m_noItems = 0;
m_selected = 0; m_selected = 0;
m_macList = NULL ;
} }
bool wxListBox::Create(wxWindow *parent, wxWindowID id, bool wxListBox::Create(wxWindow *parent, wxWindowID id,
@@ -56,8 +59,6 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
m_macHorizontalBorder = 5 ; // additional pixels around the real control
m_macVerticalBorder = 5 ;
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
@@ -67,6 +68,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
long result ; long result ;
UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ; UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
HLock( (Handle) m_macList ) ;
NewExtLDEFInfo( m_macList , MacDrawStringCell , (long) this ) ; NewExtLDEFInfo( m_macList , MacDrawStringCell , (long) this ) ;
(**m_macList).selFlags = 0 ; (**m_macList).selFlags = 0 ;
if ( style & wxLB_MULTIPLE ) if ( style & wxLB_MULTIPLE )
@@ -109,7 +111,11 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
wxListBox::~wxListBox() wxListBox::~wxListBox()
{ {
Free() ; Free() ;
DisposeExtLDEFInfo( m_macList ) ; if ( m_macList )
{
DisposeExtLDEFInfo( m_macList ) ;
m_macList = NULL ;
}
} }
void wxListBox::Free() void wxListBox::Free()
@@ -156,7 +162,7 @@ void wxListBox::Delete(int N)
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
m_stringArray.Remove( N ) ; m_stringArray.Remove( N ) ;
m_dataArray.Remove( N ) ; m_dataArray.Remove( N ) ;
m_noItems --; m_noItems --;
MacDelete( N ) ; MacDelete( N ) ;
} }
@@ -236,19 +242,29 @@ int wxListBox::FindString(const wxString& st) const
{ {
wxString search = s.Left( s.Length() - 1 ) ; wxString search = s.Left( s.Length() - 1 ) ;
int len = search.Length() ; int len = search.Length() ;
for ( int i = 0 ; i < m_noItems ; ++ i ) Str255 s1 , s2 ;
{ strcpy( (char*) s2 , search.c_str() ) ;
if ( equalstring( m_stringArray[i].Left( len ) , search , false , false ) ) c2pstr( (char*) s2 ) ;
return i ; for ( int i = 0 ; i < m_noItems ; ++ i )
} {
strcpy( (char*) s1 , m_stringArray[i].Left( len ).c_str() ) ;
c2pstr( (char*) s1 ) ;
if ( EqualString( s1 , s2 , false , false ) )
return i ;
}
} }
else else
{ {
for ( int i = 0 ; i < m_noItems ; ++ i ) Str255 s1 , s2 ;
{ strcpy( (char*) s2 , s.c_str() ) ;
if ( equalstring( m_stringArray[i] , s , false , false ) ) c2pstr( (char*) s2 ) ;
return i ; for ( int i = 0 ; i < m_noItems ; ++ i )
} {
strcpy( (char*) s1 , m_stringArray[i].c_str() ) ;
c2pstr( (char*) s1 ) ;
if ( EqualString( s1 , s2 , false , false ) )
return i ;
}
} }
return -1; return -1;
} }
@@ -308,7 +324,7 @@ void wxListBox::DoSetItemClientData(int N, void *Client_data)
if ( m_dataArray.GetCount() > N ) if ( m_dataArray.GetCount() > N )
{ {
m_dataArray[N] = (char*) Client_data ; m_dataArray[N] = (char*) Client_data ;
} }
else else
{ {
m_dataArray.Add( (char*) Client_data ) ; m_dataArray.Add( (char*) Client_data ) ;
@@ -379,7 +395,14 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
void wxListBox::SetString(int N, const wxString& s) void wxListBox::SetString(int N, const wxString& s)
{ {
m_stringArray[N] = s ; wxString str ;
if( wxApp::s_macDefaultEncodingIsPC )
{
str = wxMacMakeMacStringFromPC( s ) ;
}
else
str = s ;
m_stringArray[N] = str ;
MacSet( N , s ) ; MacSet( N , s ) ;
} }
@@ -539,7 +562,7 @@ void wxListBox::MacScrollTo( int n )
void wxListBox::OnSize( const wxSizeEvent &event) void wxListBox::OnSize( const wxSizeEvent &event)
{ {
Point pt = (**m_macList).cellSize ; Point pt = (**m_macList).cellSize ;
pt.h = m_width - 15 /* scrollbar */ - m_macHorizontalBorder * 2 ; pt.h = m_width - 15 ;
LCellSize( pt , m_macList ) ; LCellSize( pt , m_macList ) ;
} }

View File

@@ -16,9 +16,11 @@
#include "wx/stubs/textctrl.h" #include "wx/stubs/textctrl.h"
#include "wx/stubs/listctrl.h" #include "wx/stubs/listctrl.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
#endif
wxListCtrl::wxListCtrl() wxListCtrl::wxListCtrl()
{ {

View File

@@ -19,6 +19,7 @@
extern wxList wxModelessWindows; extern wxList wxModelessWindows;
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame) IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame)
IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame) IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow) IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow)
@@ -33,6 +34,7 @@ BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow)
EVT_SCROLL(wxMDIClientWindow::OnScroll) EVT_SCROLL(wxMDIClientWindow::OnScroll)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
// Parent frame // Parent frame
@@ -61,7 +63,7 @@ bool wxMDIParentFrame::Create(wxWindow *parent,
else else
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
// TODO: create MDI parent frame // this window does not exist really
wxModelessWindows.Append(this); wxModelessWindows.Append(this);
@@ -75,7 +77,7 @@ wxMDIParentFrame::~wxMDIParentFrame()
// Get size *available for subwindows* i.e. excluding menu bar. // Get size *available for subwindows* i.e. excluding menu bar.
void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const
{ {
wxFrame::DoGetClientSize( x , y ) ; wxDisplaySize( x , y ) ;
} }
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar) void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
@@ -175,7 +177,9 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
// TODO: create child frame MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
wxModelessWindows.Append(this); wxModelessWindows.Append(this);
return FALSE; return FALSE;

View File

@@ -33,8 +33,10 @@
// ---------------------- // ----------------------
#include <string.h> #include <string.h>
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler)
IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler)
#endif
// the (popup) menu title has this special id // the (popup) menu title has this special id
static const int idMenuTitle = -2; static const int idMenuTitle = -2;
@@ -47,145 +49,6 @@ const short kwxMacAppleMenuId = 1 ;
// implementation // implementation
// ============================================================================ // ============================================================================
//
// Helper Functions to get Mac Menus the way they should be ;-)
//
void wxMacCtoPString(const char* theCString, Str255 thePString);
// remove inappropriate characters, if useShortcuts is false, the ampersand will not auto-generate a mac menu-shortcut
void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemText , bool useShortcuts )
{
char *p = (char *) &outMacItemText[1] ;
short macModifiers = 0 ;
char macShortCut = 0 ;
const char *inItemName ;
wxString inItemTextMac ;
if (wxApp::s_macDefaultEncodingIsPC)
{
inItemTextMac = wxMacMakeMacStringFromPC( inItemText ) ;
inItemName = inItemTextMac ;
}
else
{
inItemName = inItemText ;
}
if ( useShortcuts && !wxApp::s_macSupportPCMenuShortcuts )
useShortcuts = false ;
// we have problems with a leading hypen - it will be taken as a separator
while ( *inItemName == '-' )
inItemName++ ;
while( *inItemName )
{
switch ( *inItemName )
{
// special characters for macintosh menus -> use some replacement
case ';' :
*p++ = ',' ;
break ;
case '^' :
*p++ = ' ' ;
break ;
case '!' :
*p++ = ' ' ;
break ;
case '<' :
*p++ = ' ' ;
break ;
case '/' :
*p++ = '|' ;
break ;
case '(' :
*p++ = '[' ;
break ;
case ')' :
*p++ = ']' ;
break ;
// shortcuts
case '&' :
{
++inItemName ;
if ( *inItemName )
{
*p++ = *inItemName ;
if ( useShortcuts )
macShortCut = *inItemName ;
}
else
--inItemName ;
}
break ;
// win-like accelerators
case '\t' :
{
++inItemName ;
while( *inItemName )
{
if (strncmp("Ctrl", inItemName, 4) == 0)
{
inItemName = inItemName + 5;
macShortCut = *inItemName;
}
else if (strncmp("Cntrl", inItemName, 5) == 0)
{
inItemName = inItemName + 6;
macShortCut = *inItemName;
}
else if (strncmp("Alt", inItemName, 3) == 0)
{
inItemName = inItemName + 4;
macModifiers |= kMenuOptionModifier ;
macShortCut = *inItemName ;
}
else if (strncmp("Shift", inItemName, 5) == 0)
{
inItemName = inItemName + 6;
macModifiers |= kMenuShiftModifier ;
macShortCut = *inItemName ;
}
else if (strncmp("F", inItemName, 1) == 0)
{
inItemName += strlen( inItemName ) ;
// no function keys at the moment
// macModifiers |= kMenuShiftModifier ;
// macShortCut = *inItemName ;
}
else
{
break ;
}
}
if ( *inItemName == 0 )
--inItemName ;
}
break ;
default :
*p++ = *inItemName ;
}
++inItemName ;
}
outMacItemText[0] = (p - (char *)outMacItemText) - 1;
if ( outMacShortcutChar )
*outMacShortcutChar = macShortCut ;
if ( outMacModifiers )
*outMacModifiers = macModifiers ;
if ( macShortCut )
{
int pos = outMacItemText[0] ;
outMacItemText[++pos] = '/';
outMacItemText[++pos] = toupper( macShortCut );
outMacItemText[0] = pos ;
}
}
// Menus // Menus
@@ -199,10 +62,10 @@ void wxMenu::Init()
// create the menu // create the menu
Str255 label; Str255 label;
wxMacBuildMenuString( label, NULL , NULL , m_title , false ); wxMenuItem::MacBuildMenuString( label, NULL , NULL , m_title , false );
m_macMenuId = s_macNextMenuId++; m_macMenuId = s_macNextMenuId++;
wxCHECK_RET( s_macNextMenuId < 236 , "menu ids > 235 cannot be used for submenus on mac" ); wxCHECK_RET( s_macNextMenuId < 236 , "menu ids > 235 cannot be used for submenus on mac" );
m_hMenu = ::NewMenu(m_macMenuId, label); m_hMenu = UMANewMenu(m_macMenuId, label);
if ( !m_hMenu ) if ( !m_hMenu )
{ {
@@ -220,7 +83,7 @@ void wxMenu::Init()
wxMenu::~wxMenu() wxMenu::~wxMenu()
{ {
if (m_hMenu) if (m_hMenu)
::DisposeMenu(m_hMenu); UMADisposeMenu(m_hMenu);
#if wxUSE_ACCEL #if wxUSE_ACCEL
// delete accels // delete accels
@@ -310,38 +173,28 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
Str255 label; Str255 label;
wxASSERT_MSG( pSubMenu->m_hMenu != NULL , "invalid submenu added"); wxASSERT_MSG( pSubMenu->m_hMenu != NULL , "invalid submenu added");
pSubMenu->m_menuParent = this ; pSubMenu->m_menuParent = this ;
wxMacBuildMenuString( label , NULL , NULL , pItem->GetText() ,false); wxMenuItem::MacBuildMenuString( label , NULL , NULL , pItem->GetText() ,false);
// hardcoded adding of the submenu combination for mac
int theEnd = label[0] + 1;
if (theEnd > 251)
theEnd = 251; // mac allows only 255 characters
label[theEnd++] = '/';
label[theEnd++] = hMenuCmd;
label[theEnd++] = '!';
label[theEnd++] = pSubMenu->m_macMenuId;
label[theEnd] = 0x00;
label[0] = theEnd;
if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar) if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar)
{ {
::InsertMenu( pSubMenu->m_hMenu , -1 ) ; UMAInsertMenu( pSubMenu->m_hMenu , -1 ) ;
} }
if ( pos == (size_t)-1 ) if ( pos == (size_t)-1 )
{ {
MacAppendMenu(m_hMenu, label); UMAAppendSubMenuItem(m_hMenu, label, pSubMenu->m_macMenuId);
} }
else else
{ {
MacInsertMenuItem(m_hMenu, label , pos); UMAInsertSubMenuItem(m_hMenu, label , pos, pSubMenu->m_macMenuId);
} }
} }
else else
{ {
Str255 label ; Str255 label ;
wxMacBuildMenuString( label , NULL , NULL , pItem->GetText(), pItem->GetId() == wxApp::s_macAboutMenuItemId); UInt8 modifiers ;
SInt16 key ;
wxMenuItem::MacBuildMenuString( label, &key , &modifiers , pItem->GetText(), pItem->GetId() == wxApp::s_macAboutMenuItemId);
if ( label[0] == 0 ) if ( label[0] == 0 )
{ {
// we cannot add empty menus on mac // we cannot add empty menus on mac
@@ -350,17 +203,17 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
} }
if ( pos == (size_t)-1 ) if ( pos == (size_t)-1 )
{ {
MacAppendMenu(m_hMenu, label); UMAAppendMenuItem(m_hMenu, label,key,modifiers);
} }
else else
{ {
MacInsertMenuItem(m_hMenu, label , pos); UMAInsertMenuItem(m_hMenu, label , pos,key,modifiers);
} }
if ( pItem->GetId() == idMenuTitle ) if ( pItem->GetId() == idMenuTitle )
{ {
if ( pos == (size_t)-1 ) if ( pos == (size_t)-1 )
{ {
UMADisableMenuItem( m_hMenu , CountMItems( m_hMenu ) ) ; UMADisableMenuItem( m_hMenu , CountMenuItems( m_hMenu ) ) ;
} }
else else
{ {
@@ -452,113 +305,9 @@ void wxMenu::SetTitle(const wxString& label)
{ {
Str255 title ; Str255 title ;
m_title = label ; m_title = label ;
wxMacBuildMenuString( title, NULL , NULL , label , false ); wxMenuItem::MacBuildMenuString( title, NULL , NULL , label , false );
UMASetMenuTitle( m_hMenu , title ) ; UMASetMenuTitle( m_hMenu , title ) ;
} }
/*
void wxMenu::SetLabel(int id, const wxString& label)
{
Str255 maclabel ;
int index ;
wxMenuItem *item = FindItemForId(id) ;
if (item==NULL)
return;
index = MacGetIndexFromItem( item ) ;
if (index < 1)
return;
if (item->GetSubMenu()==NULL)
{
wxMacBuildMenuString( maclabel , NULL , NULL , label , false );
::SetMenuItemText( m_hMenu , index , maclabel ) ;
}
else
{
wxMacBuildMenuString( maclabel , NULL , NULL , label , false );
::SetMenuItemText( m_hMenu , index , maclabel ) ;
}
item->SetName(label);
}
wxString wxMenu::GetLabel(int Id) const
{
wxMenuItem *pItem = FindItemForId(Id) ;
return pItem->GetName() ;
}
// Finds the item id matching the given string, -1 if not found.
int wxMenu::FindItem (const wxString& itemString) const
{
char buf1[200];
char buf2[200];
wxStripMenuCodes ((char *)(const char *)itemString, buf1);
for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
{
wxMenuItem *item = (wxMenuItem *) node->Data ();
if (item->GetSubMenu())
{
int ans = item->GetSubMenu()->FindItem(itemString);
if (ans > -1)
return ans;
}
if ( !item->IsSeparator() )
{
wxStripMenuCodes((char *)item->GetName().c_str(), buf2);
if (strcmp(buf1, buf2) == 0)
return item->GetId();
}
}
return -1;
}
wxMenuItem *wxMenu::FindItemForId(int itemId, wxMenu ** itemMenu) const
{
if (itemMenu)
*itemMenu = NULL;
for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
{
wxMenuItem *item = (wxMenuItem *) node->Data ();
if (item->GetId() == itemId)
{
if (itemMenu)
*itemMenu = (wxMenu *) this;
return item;
}
if (item->GetSubMenu())
{
wxMenuItem *ans = item->GetSubMenu()->FindItemForId (itemId, itemMenu);
if (ans)
return ans;
}
}
if (itemMenu)
*itemMenu = NULL;
return NULL;
}
void wxMenu::SetHelpString(int itemId, const wxString& helpString)
{
wxMenuItem *item = FindItemForId (itemId);
if (item)
item->SetHelp(helpString);
}
wxString wxMenu::GetHelpString (int itemId) const
{
wxMenuItem *item = FindItemForId (itemId);
wxString str("");
return (item == NULL) ? str : item->GetHelp();
}
*/
bool wxMenu::ProcessCommand(wxCommandEvent & event) bool wxMenu::ProcessCommand(wxCommandEvent & event)
{ {
bool processed = FALSE; bool processed = FALSE;
@@ -679,6 +428,9 @@ bool wxMenu::MacMenuSelect( wxEvtHandler* handler, long when , int macMenuId, in
{ {
wxMenuItem *pItem = (wxMenuItem*)node->Data(); wxMenuItem *pItem = (wxMenuItem*)node->Data();
if (pItem->IsCheckable())
pItem->Check(! pItem->IsChecked());
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, pItem->GetId()); wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, pItem->GetId());
event.m_timeStamp = when; event.m_timeStamp = when;
event.SetEventObject(handler); event.SetEventObject(handler);
@@ -892,7 +644,8 @@ void wxMenuBar::MacInstallMenuBar()
int pos ; int pos ;
wxMenu* menu = m_menus[i] , *subMenu = NULL ; wxMenu* menu = m_menus[i] , *subMenu = NULL ;
#if !TARGET_CARBON
/* the help menu does not exist in CARBON anymore */
if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName )
{ {
MenuHandle mh = NULL ; MenuHandle mh = NULL ;
@@ -906,8 +659,8 @@ void wxMenuBar::MacInstallMenuBar()
formerHelpMenuItems = CountMenuItems( mh ) ; formerHelpMenuItems = CountMenuItems( mh ) ;
} }
for (pos = 0 , node = menu->GetMenuItems().First(); node; node = node->Next(), pos++) for (pos = 0 , node = menu->GetMenuItems().First(); node; node = node->Next(), pos++)
{ {
item = (wxMenuItem *)node->Data(); item = (wxMenuItem *)node->Data();
subMenu = item->GetSubMenu() ; subMenu = item->GetSubMenu() ;
if (subMenu) if (subMenu)
@@ -919,12 +672,14 @@ void wxMenuBar::MacInstallMenuBar()
if ( item->IsSeparator() ) if ( item->IsSeparator() )
{ {
if ( mh ) if ( mh )
::AppendMenu(mh, "\p-" ); UMAAppendMenuItem(mh, "\p-" );
} }
else else
{ {
Str255 label ; Str255 label ;
wxMacBuildMenuString( label , NULL , NULL , item->GetText(), item->GetId() != wxApp::s_macAboutMenuItemId); // no shortcut in about menu UInt8 modifiers ;
SInt16 key ;
wxMenuItem::MacBuildMenuString( label, &key , &modifiers , item->GetText(), item->GetId() != wxApp::s_macAboutMenuItemId); // no shortcut in about menu
if ( label[0] == 0 ) if ( label[0] == 0 )
{ {
// we cannot add empty menus on mac // we cannot add empty menus on mac
@@ -933,36 +688,36 @@ void wxMenuBar::MacInstallMenuBar()
} }
if ( item->GetId() == wxApp::s_macAboutMenuItemId ) if ( item->GetId() == wxApp::s_macAboutMenuItemId )
{ {
::SetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , label ); UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , label );
// ::EnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 ); UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
::EnableItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
} }
else else
{ {
if ( mh ) if ( mh )
::AppendMenu(mh, label ); UMAAppendMenuItem(mh, label , key , modifiers );
} }
} }
} }
} }
} }
else else
#endif
{ {
wxMacBuildMenuString( label, NULL , NULL , m_titles[i] , false ); wxMenuItem::MacBuildMenuString( label, NULL , NULL , m_titles[i] , false );
UMASetMenuTitle( menu->GetHMenu() , label ) ; UMASetMenuTitle( menu->GetHMenu() , label ) ;
for (pos = 0, node = menu->GetMenuItems().First(); node; node = node->Next(), pos++) for (pos = 0, node = menu->GetMenuItems().First(); node; node = node->Next(), pos++)
{ {
item = (wxMenuItem *)node->Data(); item = (wxMenuItem *)node->Data();
subMenu = item->GetSubMenu() ; subMenu = item->GetSubMenu() ;
if (subMenu) if (subMenu)
{ {
::InsertMenu( subMenu->GetHMenu() , -1 ) ; UMAInsertMenu( subMenu->GetHMenu() , -1 ) ;
} }
} }
::InsertMenu(m_menus[i]->GetHMenu(), 0); UMAInsertMenu(m_menus[i]->GetHMenu(), 0);
} }
} }
::DrawMenuBar() ; UMADrawMenuBar() ;
s_macInstalledMenuBar = this; s_macInstalledMenuBar = this;
} }
@@ -1037,18 +792,18 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
{ {
if (s_macInstalledMenuBar == this) if (s_macInstalledMenuBar == this)
{ {
::DeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ; UMADeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
{ {
Str255 label; Str255 label;
wxMacBuildMenuString( label, NULL , NULL , title , false ); wxMenuItem::MacBuildMenuString( label, NULL , NULL , title , false );
UMASetMenuTitle( menu->GetHMenu() , label ) ; UMASetMenuTitle( menu->GetHMenu() , label ) ;
if ( pos == m_menus.GetCount() - 1) if ( pos == m_menus.GetCount() - 1)
{ {
::InsertMenu( menu->GetHMenu() , 0 ) ; UMAInsertMenu( menu->GetHMenu() , 0 ) ;
} }
else else
{ {
::InsertMenu( menu->GetHMenu() , m_menus[pos+1]->MacGetMenuId() ) ; UMAInsertMenu( menu->GetHMenu() , m_menus[pos+1]->MacGetMenuId() ) ;
} }
} }
} }
@@ -1206,6 +961,16 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
return TRUE; return TRUE;
} }
void wxMenuBar::Attach(wxFrame *frame)
{
// wxASSERT_MSG( !IsAttached(), wxT("menubar already attached!") );
m_menuBarFrame = frame;
#if wxUSE_ACCEL
RebuildAccelTable();
#endif // wxUSE_ACCEL
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// wxMenuBar searching for menu items // wxMenuBar searching for menu items
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -25,19 +25,152 @@
// dynamic classes implementation // dynamic classes implementation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
#endif //USE_SHARED_LIBRARY
void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemName , bool useShortcuts ) ;
wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
{
return wxStripMenuCodes(text);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxMenuItem // wxMenuItem
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
//
// Helper Functions to get Mac Menus the way they should be ;-)
//
void wxMacCtoPString(const char* theCString, Str255 thePString);
// remove inappropriate characters, if useShortcuts is false, the ampersand will not auto-generate a mac menu-shortcut
wxMenuItem::MacBuildMenuString(StringPtr outMacItemText, SInt16 *outMacShortcutChar , UInt8 *outMacModifiers , const char *inItemText , bool useShortcuts )
{
char *p = (char *) &outMacItemText[1] ;
short macModifiers = 0 ;
char macShortCut = 0 ;
const char *inItemName ;
wxString inItemTextMac ;
if (wxApp::s_macDefaultEncodingIsPC)
{
inItemTextMac = wxMacMakeMacStringFromPC( inItemText ) ;
inItemName = inItemTextMac ;
}
else
{
inItemName = inItemText ;
}
if ( useShortcuts && !wxApp::s_macSupportPCMenuShortcuts )
useShortcuts = false ;
// we have problems with a leading hypen - it will be taken as a separator
while ( *inItemName == '-' )
inItemName++ ;
while( *inItemName )
{
switch ( *inItemName )
{
// special characters for macintosh menus -> use some replacement
case ';' :
*p++ = ',' ;
break ;
case '^' :
*p++ = ' ' ;
break ;
case '!' :
*p++ = ' ' ;
break ;
case '<' :
*p++ = '[' ;
break ;
case '>' :
*p++ = ']' ;
break ;
case '/' :
*p++ = '|' ;
break ;
case '(' :
*p++ = '[' ;
break ;
case ')' :
*p++ = ']' ;
break ;
// shortcuts
case '&' :
{
++inItemName ;
if ( *inItemName )
{
*p++ = *inItemName ;
if ( useShortcuts )
macShortCut = *inItemName ;
}
else
--inItemName ;
}
break ;
// win-like accelerators
case '\t' :
{
++inItemName ;
while( *inItemName )
{
if (strncmp("Ctrl", inItemName, 4) == 0)
{
inItemName = inItemName + 5;
macShortCut = *inItemName;
}
else if (strncmp("Cntrl", inItemName, 5) == 0)
{
inItemName = inItemName + 6;
macShortCut = *inItemName;
}
else if (strncmp("Alt", inItemName, 3) == 0)
{
inItemName = inItemName + 4;
macModifiers |= kMenuOptionModifier ;
macShortCut = *inItemName ;
}
else if (strncmp("Shift", inItemName, 5) == 0)
{
inItemName = inItemName + 6;
macModifiers |= kMenuShiftModifier ;
macShortCut = *inItemName ;
}
else if (strncmp("F", inItemName, 1) == 0)
{
inItemName += strlen( inItemName ) ;
// no function keys at the moment
// macModifiers |= kMenuShiftModifier ;
// macShortCut = *inItemName ;
}
else
{
break ;
}
}
if ( *inItemName == 0 )
--inItemName ;
}
break ;
default :
*p++ = *inItemName ;
}
++inItemName ;
}
outMacItemText[0] = (p - (char *)outMacItemText) - 1;
if ( outMacShortcutChar )
*outMacShortcutChar = macShortCut ;
if ( outMacModifiers )
*outMacModifiers = macModifiers ;
return 0 ;
}
// ctor & dtor // ctor & dtor
// ----------- // -----------
@@ -184,8 +317,8 @@ void wxMenuItem::SetText(const wxString& text)
if ( index >= 1 ) if ( index >= 1 )
{ {
Str255 label; Str255 label;
wxMacBuildMenuString( label , NULL , NULL , text ,false); MacBuildMenuString( label , NULL , NULL , text ,false);
::SetMenuItemText( m_parentMenu->GetHMenu() , index , label ) ; // checkmark UMASetMenuItemText( m_parentMenu->GetHMenu() , index , label ) ; // checkmark
} }
} }
@@ -204,6 +337,12 @@ void wxMenuItem::SetCheckable(bool checkable)
// wxMenuItemBase // wxMenuItemBase
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/* static */
wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
{
return wxStripMenuCodes(text);
}
wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu, wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
int id, int id,
const wxString& name, const wxString& name,

View File

@@ -39,8 +39,10 @@
extern bool wxClipboardIsOpen; extern bool wxClipboardIsOpen;
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject)
IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC) IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC)
#endif
/* /*
* Metafiles * Metafiles
@@ -57,7 +59,7 @@ wxMetafileRefData::~wxMetafileRefData(void)
{ {
if (m_metafile) if (m_metafile)
{ {
KillPicture( m_metafile ) ; KillPicture( m_metafile ) ;
m_metafile = 0; m_metafile = 0;
} }
} }
@@ -83,7 +85,7 @@ bool wxMetaFile::SetClipboard(int width, int height)
{ {
if (!m_refData) if (!m_refData)
return FALSE; return FALSE;
/*
bool alreadyOpen=wxClipboardOpen(); bool alreadyOpen=wxClipboardOpen();
if (!alreadyOpen) if (!alreadyOpen)
{ {
@@ -92,11 +94,19 @@ bool wxMetaFile::SetClipboard(int width, int height)
} }
bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height); bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height);
if (!alreadyOpen) wxCloseClipboard(); if (!alreadyOpen) wxCloseClipboard();
return (bool) success; return (bool) success;
*/
return TRUE ; return TRUE ;
} }
void wxMetafile::SetHMETAFILE(PicHandle mf)
{
if (!m_refData)
m_refData = new wxMetafileRefData;
M_METAFILEDATA->m_metafile = mf;
}
bool wxMetaFile::Play(wxDC *dc) bool wxMetaFile::Play(wxDC *dc)
{ {
if (!m_refData) if (!m_refData)
@@ -142,11 +152,11 @@ wxMetaFileDC::wxMetaFileDC(const wxString& file)
wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ;
m_metaFile = new wxMetaFile("") ; m_metaFile = new wxMetaFile("") ;
Rect r={0,0,100,100} ; Rect r={0,0,1000,1000} ;
m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
::GetPort( &m_macPort ) ; ::GetPort( &m_macPort ) ;
m_ok = TRUE ; m_ok = TRUE ;
SetMapMode(wxMM_TEXT); SetMapMode(wxMM_TEXT);
@@ -184,5 +194,4 @@ wxMetaFile *wxMetaFileDC::Close()
return m_metaFile; return m_metaFile;
} }
#endif #endif

View File

@@ -15,6 +15,8 @@
#include "wx/minifram.h" #include "wx/minifram.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame, wxFrame) IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame, wxFrame)
#endif

View File

@@ -16,7 +16,9 @@
#include "wx/msgdlg.h" #include "wx/msgdlg.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_CLASS(wxMessageDialog, wxDialog) IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
#endif
#define kMacOKAlertResourceID 128 #define kMacOKAlertResourceID 128
#define kMacYesNoAlertResourceID 129 #define kMacYesNoAlertResourceID 129
@@ -70,7 +72,6 @@ int wxMessageDialog::ShowModal()
Str255 pascalTitle ; Str255 pascalTitle ;
Str255 pascalText ; Str255 pascalText ;
if (wxApp::s_macDefaultEncodingIsPC) if (wxApp::s_macDefaultEncodingIsPC)
{ {
strcpy( (char*) pascalTitle , wxMacMakeMacStringFromPC( m_caption ) ) ; strcpy( (char*) pascalTitle , wxMacMakeMacStringFromPC( m_caption ) ) ;

View File

@@ -15,7 +15,9 @@
#include "wx/palette.h" #include "wx/palette.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
#endif
/* /*
* Palette * Palette

View File

@@ -17,7 +17,9 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/pen.h" #include "wx/pen.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
#endif
wxPenRefData::wxPenRefData() wxPenRefData::wxPenRefData()
{ {
@@ -26,7 +28,7 @@ wxPenRefData::wxPenRefData()
m_join = wxJOIN_ROUND ; m_join = wxJOIN_ROUND ;
m_cap = wxCAP_ROUND ; m_cap = wxCAP_ROUND ;
m_nbDash = 0 ; m_nbDash = 0 ;
m_dash = (wxMACDash*)NULL; m_dash = 0 ;
/* TODO: null data /* TODO: null data
m_hPen = 0; m_hPen = 0;
*/ */
@@ -76,7 +78,7 @@ wxPen::wxPen(const wxColour& col, int Width, int Style)
M_PENDATA->m_join = wxJOIN_ROUND ; M_PENDATA->m_join = wxJOIN_ROUND ;
M_PENDATA->m_cap = wxCAP_ROUND ; M_PENDATA->m_cap = wxCAP_ROUND ;
M_PENDATA->m_nbDash = 0 ; M_PENDATA->m_nbDash = 0 ;
M_PENDATA->m_dash = (wxMACDash*)NULL; M_PENDATA->m_dash = 0 ;
RealizeResource(); RealizeResource();
@@ -94,7 +96,7 @@ wxPen::wxPen(const wxBitmap& stipple, int Width)
M_PENDATA->m_join = wxJOIN_ROUND ; M_PENDATA->m_join = wxJOIN_ROUND ;
M_PENDATA->m_cap = wxCAP_ROUND ; M_PENDATA->m_cap = wxCAP_ROUND ;
M_PENDATA->m_nbDash = 0 ; M_PENDATA->m_nbDash = 0 ;
M_PENDATA->m_dash = (wxMACDash*)NULL; M_PENDATA->m_dash = 0 ;
RealizeResource(); RealizeResource();
@@ -168,7 +170,7 @@ void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
Unshare(); Unshare();
M_PENDATA->m_nbDash = nb_dashes; M_PENDATA->m_nbDash = nb_dashes;
M_PENDATA->m_dash = (wxMACDash *)Dash; M_PENDATA->m_dash = (wxDash *)Dash;
RealizeResource(); RealizeResource();
} }

View File

@@ -16,11 +16,14 @@
#include "wx/object.h" #include "wx/object.h"
#include "wx/printdlg.h" #include "wx/printdlg.h"
#include "wx/dcprint.h" #include "wx/dcprint.h"
#include "wx/mac/uma.h"
// Use generic page setup dialog: use your own native one if one exists. // Use generic page setup dialog: use your own native one if one exists.
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog) IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog) IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
#endif
wxPrintDialog::wxPrintDialog() wxPrintDialog::wxPrintDialog()
{ {
@@ -64,15 +67,17 @@ wxPrintDialog::~wxPrintDialog()
int wxPrintDialog::ShowModal() int wxPrintDialog::ShowModal()
{ {
int result = wxID_CANCEL ; int result = wxID_CANCEL ;
#if !TARGET_CARBON
OSErr err ; OSErr err ;
wxString message ; wxString message ;
::PrOpen() ; ::UMAPrOpen() ;
err = PrError() ; err = PrError() ;
if ( !err ) if ( !err )
{ {
m_printDialogData.ConvertToNative() ; m_printDialogData.ConvertToNative() ;
if ( m_printDialogData.m_macPrintInfo && ::PrJobDialog( m_printDialogData.m_macPrintInfo ) ) if ( ::PrJobDialog( m_printDialogData.GetPrintData().m_macPrintInfo ) )
{ {
m_printDialogData.ConvertFromNative() ; m_printDialogData.ConvertFromNative() ;
result = wxID_OK ; result = wxID_OK ;
@@ -84,8 +89,10 @@ int wxPrintDialog::ShowModal()
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
} }
::PrClose() ; ::UMAPrClose() ;
#else
#pragma warning "TODO:Printing for carbon"
#endif
return result ; return result ;
} }
@@ -127,15 +134,17 @@ wxPageSetupDialog::~wxPageSetupDialog()
int wxPageSetupDialog::ShowModal() int wxPageSetupDialog::ShowModal()
{ {
int result = wxID_CANCEL ; int result = wxID_CANCEL ;
#if !TARGET_CARBON
OSErr err ; OSErr err ;
wxString message ; wxString message ;
::PrOpen() ; ::UMAPrOpen() ;
err = PrError() ; err = PrError() ;
if ( !err ) if ( !err )
{ {
m_pageSetupData.ConvertToNative() ; m_pageSetupData.ConvertToNative() ;
if ( m_pageSetupData.m_macPageSetupInfo && ::PrStlDialog( m_pageSetupData.m_macPageSetupInfo ) ) if ( ::PrStlDialog( m_pageSetupData.GetPrintData().m_macPrintInfo ) )
{ {
m_pageSetupData.ConvertFromNative() ; m_pageSetupData.ConvertFromNative() ;
result = wxID_OK ; result = wxID_OK ;
@@ -147,8 +156,10 @@ int wxPageSetupDialog::ShowModal()
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
} }
::PrClose() ; ::UMAPrClose() ;
#else
#pragma warning "TODO:printing for carbon"
#endif
return result ; return result ;
} }

View File

@@ -35,8 +35,10 @@
#include <stdlib.h> #include <stdlib.h>
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxMacPrinter, wxPrinterBase) IMPLEMENT_DYNAMIC_CLASS(wxMacPrinter, wxPrinterBase)
IMPLEMENT_CLASS(wxMacPrintPreview, wxPrintPreviewBase) IMPLEMENT_CLASS(wxMacPrintPreview, wxPrintPreviewBase)
#endif
/* /*
* Printer * Printer
@@ -92,31 +94,16 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
else else
m_printDialogData.EnablePageNumbers(FALSE); m_printDialogData.EnablePageNumbers(FALSE);
// Create a suitable device context
// Create a suitable device context // Create a suitable device context
wxDC *dc = NULL; wxDC *dc = NULL;
if (prompt) if (prompt)
{ {
PrOpen() ; wxPrintDialog dialog(parent, & m_printDialogData);
m_printDialogData.ConvertToNative() ; // make sure we have a valid handle if (dialog.ShowModal() == wxID_OK)
if ( m_printDialogData.m_macPrintInfo ) {
{ dc = dialog.GetPrintDC();
// todo incorporate the changes from a global page setup m_printDialogData = dialog.GetPrintData();
if ( ::PrStlDialog( m_printDialogData.m_macPrintInfo ) ) // we should have the page setup dialog }
{
PrClose() ;
wxPrintDialog dialog(parent, & m_printDialogData);
if (dialog.ShowModal() == wxID_OK)
{
dc = dialog.GetPrintDC();
m_printDialogData = dialog.GetPrintData();
}
}
else
{
PrClose() ;
}
}
} }
else else
{ {
@@ -140,7 +127,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
printout->SetDC(dc); printout->SetDC(dc);
int w, h; int w, h;
long ww, hh; wxCoord ww, hh;
dc->GetSize(&w, &h); dc->GetSize(&w, &h);
printout->SetPageSizePixels((int)w, (int)h); printout->SetPageSizePixels((int)w, (int)h);
dc->GetSizeMM(&ww, &hh); dc->GetSizeMM(&ww, &hh);
@@ -278,50 +265,35 @@ bool wxMacPrintPreview::Print(bool interactive)
void wxMacPrintPreview::DetermineScaling(void) void wxMacPrintPreview::DetermineScaling(void)
{ {
/* int screenWidth , screenHeight ;
HDC dc = ::GetDC(NULL); wxDisplaySize( &screenWidth , &screenHeight ) ;
int screenWidth = ::GetDeviceCaps(dc, HORZSIZE);
// int screenHeight = ::GetDeviceCaps(dc, VERTSIZE);
int screenXRes = ::GetDeviceCaps(dc, HORZRES);
// int screenYRes = ::GetDeviceCaps(dc, VERTRES);
int logPPIScreenX = ::GetDeviceCaps(dc, LOGPIXELSX);
int logPPIScreenY = ::GetDeviceCaps(dc, LOGPIXELSY);
m_previewPrintout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
::ReleaseDC(NULL, dc); m_previewPrintout->SetPPIScreen( 72 , 72 ) ;
m_previewPrintout->SetPPIPrinter( 72 , 72 ) ;
m_previewPrintout->SetPageSizeMM( 8 * 25.6 , 11 * 25.6 ) ;
m_previewPrintout->SetPageSizePixels( 8 * 72 , 11 * 72 ) ;
m_pageWidth = 8 * 72 ;
m_pageHeight = 11 * 72 ;
m_previewScale = 1 ;
// Get a device context for the currently selected printer // Get a device context for the currently selected printer
wxPrinterDC printerDC("", "", "", FALSE, m_printDialogData.GetOrientation()); wxPrinterDC printerDC(m_printDialogData.GetPrintData());
if (printerDC.Ok())
int printerWidth = 150;
int printerHeight = 250;
int printerXRes = 1500;
int printerYRes = 2500;
if (printerDC.GetHDC())
{ {
printerWidth = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZSIZE); int x , y ;
printerHeight = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTSIZE); wxCoord ww, hh;
printerXRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZRES); printerDC.GetSizeMM(&ww, &hh);
printerYRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTRES); printerDC.GetSize( &x , &y ) ;
m_previewPrintout->SetPageSizeMM((int)ww, (int)hh);
int logPPIPrinterX = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSX); m_previewPrintout->SetPageSizePixels( x , y) ;
int logPPIPrinterY = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSY); m_pageWidth = x ;
m_pageHeight = y ;
m_previewPrintout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY); m_isOk = true ;
m_previewPrintout->SetPageSizeMM(printerWidth, printerHeight);
if (logPPIPrinterX == 0 || logPPIPrinterY == 0 || printerWidth == 0 || printerHeight == 0)
m_isOk = FALSE;
}
else
m_isOk = FALSE;
m_pageWidth = printerXRes;
m_pageHeight = printerYRes;
}
// At 100%, the page should look about page-size on the screen. // At 100%, the page should look about page-size on the screen.
m_previewScale = (float)((float)screenWidth/(float)printerWidth); // m_previewScale = (float)((float)screenWidth/(float)printerWidth);
m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerYRes); // m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerXRes);
*/
m_previewScale = 1 ;
} }

View File

@@ -20,7 +20,9 @@
#include "wx/radiobox.h" #include "wx/radiobox.h"
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
#endif
#pragma mark - #pragma mark -
#pragma mark ### Constructors & destructor ### #pragma mark ### Constructors & destructor ###
@@ -93,7 +95,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
MacPreControlCreate( parent , id , label , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; MacPreControlCreate( parent , id , label , pos , size ,style, val , name , &bounds , title ) ;
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1,
kControlGroupBoxTextTitleProc , (long) this ) ; kControlGroupBoxTextTitleProc , (long) this ) ;
@@ -435,9 +437,9 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
x_offset = x; x_offset = x;
y_offset = y; y_offset = y;
GetPosition(&x_current, &y_current); GetPosition(&x_current, &y_current);
if ((x == -1) || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if ((x == -1) && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
x_offset = x_current; x_offset = x_current;
if ((y == -1) || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if ((y == -1)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
y_offset = y_current; y_offset = y_current;
// define size // define size
@@ -490,7 +492,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
x_start = charWidth; x_start = charWidth;
y_start = charHeight*3/2; y_start = 15 ;
x_offset = x_start; x_offset = x_start;
y_offset = y_start; y_offset = y_start;
@@ -507,7 +509,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
else else
{ {
x_offset = x_start; x_offset = x_start;
y_offset += maxHeight + charHeight/2; y_offset += maxHeight ; /*+ charHeight/2;*/
} }
} }
@@ -515,7 +517,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
current=current->NextInCycle(); current=current->NextInCycle();
if (m_windowStyle & wxRA_SPECIFY_ROWS) if (m_windowStyle & wxRA_SPECIFY_ROWS)
y_offset += maxHeight + charHeight/2; y_offset += maxHeight ; /*+ charHeight/2;*/
else else
x_offset += maxWidth + charWidth; x_offset += maxWidth + charWidth;
} }

View File

@@ -15,7 +15,9 @@
#include "wx/radiobut.h" #include "wx/radiobut.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
@@ -48,7 +50,8 @@ void wxRadioButton::SetValue(bool val)
::SetControlValue( m_macControl , val ) ; ::SetControlValue( m_macControl , val ) ;
if (val) { if (val)
{
cycle=this->NextInCycle(); cycle=this->NextInCycle();
if (cycle!=NULL) { if (cycle!=NULL) {
while (cycle!=this) { while (cycle!=this) {
@@ -94,4 +97,3 @@ wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
return(cycle); return(cycle);
} }
} }

View File

@@ -14,9 +14,12 @@
#include "wx/region.h" #include "wx/region.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxRegionRefData implementation // wxRegionRefData implementation
@@ -195,7 +198,8 @@ void wxRegion::GetBox(long& x, long& y, long&w, long &h) const
{ {
if (m_refData) if (m_refData)
{ {
Rect box = (**M_REGION).rgnBBox ; Rect box ;
GetRegionBounds( M_REGION , &box ) ;
x = box.left ; x = box.left ;
y = box.top ; y = box.top ;
w = box.right - box.left ; w = box.right - box.left ;
@@ -329,7 +333,8 @@ void wxRegionIterator::Reset(const wxRegion& region)
{ {
// we cannot dissolve it into rects on mac // we cannot dissolve it into rects on mac
m_rects = new wxRect[1]; m_rects = new wxRect[1];
Rect rect = (**OTHER_M_REGION( region )).rgnBBox ; Rect rect ;
GetRegionBounds( OTHER_M_REGION( region ) , &rect ) ;
m_rects[0].x = rect.left; m_rects[0].x = rect.left;
m_rects[0].y = rect.top; m_rects[0].y = rect.top;
m_rects[0].width = rect.right - rect.left; m_rects[0].width = rect.right - rect.left;

View File

@@ -16,11 +16,13 @@
#include "wx/scrolbar.h" #include "wx/scrolbar.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
BEGIN_EVENT_TABLE(wxScrollBar, wxControl) BEGIN_EVENT_TABLE(wxScrollBar, wxControl)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
extern ControlActionUPP wxMacLiveScrollbarActionUPP ; extern ControlActionUPP wxMacLiveScrollbarActionUPP ;

View File

@@ -74,7 +74,6 @@ wxColour wxSystemSettings::GetSystemColour(int index)
break ; break ;
case wxSYS_COLOUR_INFOBK : case wxSYS_COLOUR_INFOBK :
case wxSYS_COLOUR_APPWORKSPACE: case wxSYS_COLOUR_APPWORKSPACE:
case wxSYS_COLOUR_LISTBOX:
return *wxWHITE ; return *wxWHITE ;
break ; break ;
} }

View File

@@ -16,10 +16,12 @@
#include "wx/slider.h" #include "wx/slider.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl)
BEGIN_EVENT_TABLE(wxSlider, wxControl) BEGIN_EVENT_TABLE(wxSlider, wxControl)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif

View File

@@ -24,8 +24,10 @@
// wxWin macros // wxWin macros
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent); IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent);
#endif
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name) long style, const wxString& name)

View File

@@ -15,7 +15,9 @@
#include "wx/statbmp.h" #include "wx/statbmp.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
#endif
/* /*
* wxStaticBitmap * wxStaticBitmap
@@ -28,11 +30,12 @@ END_EVENT_TABLE()
bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
const wxBitmap& bitmap, const wxBitmap& bitmap,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& s,
long style, long style,
const wxString& name) const wxString& name)
{ {
SetName(name); SetName(name);
wxSize size = s ;
m_backgroundColour = parent->GetBackgroundColour() ; m_backgroundColour = parent->GetBackgroundColour() ;
m_foregroundColour = parent->GetForegroundColour() ; m_foregroundColour = parent->GetForegroundColour() ;
@@ -47,8 +50,7 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
m_windowStyle = style; m_windowStyle = style;
bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name ); bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
SetSizeOrDefault( size ) ;
SetSizeOrDefault() ;
return ret; return ret;
} }

View File

@@ -16,12 +16,14 @@
#include "wx/statbox.h" #include "wx/statbox.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
BEGIN_EVENT_TABLE(wxStaticBox, wxControl) BEGIN_EVENT_TABLE(wxStaticBox, wxControl)
EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground) EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
/* /*
* Static box * Static box
@@ -37,7 +39,7 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
MacPreControlCreate( parent , id , label , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; MacPreControlCreate( parent , id , label , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ;
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1,
kControlGroupBoxTextTitleProc , (long) this ) ; kControlGroupBoxTextTitleProc , (long) this ) ;

View File

@@ -18,7 +18,9 @@
#include <stdio.h> #include <stdio.h>
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
@@ -51,69 +53,208 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
return ret; return ret;
} }
void wxStaticText::OnDraw( wxDC &dc )
{
PrepareDC(dc);
dc.Clear() ;
int x = 0 ;
int y = 0 ;
wxString text = m_label ;
wxString paragraph ;
int i = 0 ;
int laststop = 0 ;
long width, height ;
while( i < text.Length() )
{
if( text[i] == 13 || text[i] == 10)
{
paragraph = text.Mid( laststop , i - laststop ) ;
while( paragraph.Length() > 0 )
{
dc.GetTextExtent( paragraph , &width , &height ) ;
if ( width > m_width )
{
for ( int p = paragraph.Length() -1 ; p > 0 ; --p )
{
if ( paragraph[p]=='.' )
{
dc.GetTextExtent( paragraph.Left(p+1) , &width , &height ) ;
if ( width <= m_width )
{
int pos = x ;
if ( HasFlag( wxALIGN_CENTER ) )
{
pos += ( m_width - width ) / 2 ;
}
else if ( HasFlag( wxALIGN_RIGHT ) )
{
pos += ( m_width - width ) ;
}
dc.DrawText( paragraph.Left(p+1), pos , y) ;
y += height ;
paragraph = paragraph.Mid(p+1) ;
break ;
}
}
if ( paragraph[p]==' ' )
{
dc.GetTextExtent( paragraph.Left(p) , &width , &height ) ;
if ( width <= m_width )
{
int pos = x ;
if ( HasFlag( wxALIGN_CENTER ) )
{
pos += ( m_width - width ) / 2 ;
}
else if ( HasFlag( wxALIGN_RIGHT ) )
{
pos += ( m_width - width ) ;
}
dc.DrawText( paragraph.Left(p), pos , y) ;
y += height ;
paragraph = paragraph.Mid(p+1) ;
break ;
}
}
}
}
else
{
dc.DrawText( paragraph, x , y) ;
paragraph="";
y += height ;
}
}
laststop = i+1 ;
}
++i ;
}
paragraph = text.Mid( laststop , text.Length() - laststop ) ;
while( paragraph.Length() > 0 )
{
dc.GetTextExtent( paragraph , &width , &height ) ;
if ( width > m_width )
{
for ( int p = paragraph.Length() -1 ; p > 0 ; --p )
{
if ( paragraph[p]=='.' )
{
dc.GetTextExtent( paragraph.Left(p+1) , &width , &height ) ;
if ( width <= m_width )
{
int pos = x ;
if ( HasFlag( wxALIGN_CENTER ) )
{
pos += ( m_width - width ) / 2 ;
}
else if ( HasFlag( wxALIGN_RIGHT ) )
{
pos += ( m_width - width ) ;
}
dc.DrawText( paragraph.Left(p+1), pos , y) ;
y += height ;
paragraph = paragraph.Mid(p+1) ;
break ;
}
}
if ( paragraph[p]==' ' )
{
dc.GetTextExtent( paragraph.Left(p) , &width , &height ) ;
if ( width <= m_width )
{
int pos = x ;
if ( HasFlag( wxALIGN_CENTER ) )
{
pos += ( m_width - width ) / 2 ;
}
else if ( HasFlag( wxALIGN_RIGHT ) )
{
pos += ( m_width - width ) ;
}
dc.DrawText( paragraph.Left(p), pos , y) ;
y += height ;
paragraph = paragraph.Mid(p+1) ;
break ;
}
}
}
}
else
{
int pos = x ;
if ( HasFlag( wxALIGN_CENTER ) )
{
pos += ( m_width - width ) / 2 ;
}
else if ( HasFlag( wxALIGN_RIGHT ) )
{
pos += ( m_width - width ) ;
}
dc.DrawText( paragraph, pos , y) ;
paragraph="";
y += height ;
}
}
}
void wxStaticText::OnPaint( wxPaintEvent &event ) void wxStaticText::OnPaint( wxPaintEvent &event )
{ {
wxPaintDC dc(this); wxPaintDC dc(this);
PrepareDC(dc); OnDraw( dc ) ;
dc.Clear() ;
dc.DrawText( m_label , 0 , 0 ) ;
} }
wxSize wxStaticText::DoGetBestSize() const wxSize wxStaticText::DoGetBestSize() const
{ {
int x , y ; int x , y ;
GetTextExtent( m_label , &x , &y ) ; int widthTextMax = 0, widthLine,
return wxSize( x , y ) ; heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;
wxString curLine;
for ( const wxChar *pc = m_label; ; pc++ ) {
if ( *pc == wxT('\n') || *pc == wxT('\0') ) {
if ( !curLine ) {
// we can't use GetTextExtent - it will return 0 for both width
// and height and an empty line should count in height
// calculation
if ( !heightLineDefault )
heightLineDefault = heightLine;
if ( !heightLineDefault )
GetTextExtent(_T("W"), NULL, &heightLineDefault);
heightTextTotal += heightLineDefault;
}
else {
GetTextExtent(curLine, &widthLine, &heightLine);
if ( widthLine > widthTextMax )
widthTextMax = widthLine;
heightTextTotal += heightLine;
}
if ( *pc == wxT('\n') ) {
curLine.Empty();
}
else {
// the end of string
break;
}
}
else {
curLine += *pc;
}
}
return wxSize(widthTextMax, heightTextTotal);
} }
void wxStaticText::SetLabel(const wxString& st , bool resize ) void wxStaticText::SetLabel(const wxString& st )
{ {
SetTitle( st ) ; SetTitle( st ) ;
m_label = st ; m_label = st ;
if ( resize ) if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
SetSizeOrDefault() ; SetSizeOrDefault() ;
else
Refresh() ; wxClientDC dc(this);
OnDraw( dc ) ;
} }
/*
void wxStaticText::SetSize(int x, int y, int width, int height, int sizeFlags)
{
wxControl::SetSize( x , y , width , height , sizeFlags ) ;
}
bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
Rect bounds ;
Str255 title ;
MacPreControlCreate( parent , id , label , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ;
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1,
kControlStaticTextProc , (long) this ) ;
::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) title[0] , (char*) &title[1] ) ;
MacPostControlCreate() ;
return TRUE;
}
void wxStaticText::SetLabel(const wxString& st , bool resize )
{
SetTitle( st ) ;
wxString label ;
if( wxApp::s_macDefaultEncodingIsPC )
label = wxMacMakeMacStringFromPC( st ) ;
else
label = st ;
::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) label.Length() , (char*)(const char*) label ) ;
Refresh() ;
}
*/

View File

@@ -17,10 +17,12 @@
#include "wx/tabctrl.h" #include "wx/tabctrl.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl)
BEGIN_EVENT_TABLE(wxTabCtrl, wxControl) BEGIN_EVENT_TABLE(wxTabCtrl, wxControl)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
wxTabCtrl::wxTabCtrl() wxTabCtrl::wxTabCtrl()
{ {
@@ -35,7 +37,7 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
m_imageList = NULL; m_imageList = NULL;
MacPreControlCreate( parent , id , "" , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ;
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1,
kControlTabSmallProc , (long) this ) ; kControlTabSmallProc , (long) this ) ;

View File

@@ -38,22 +38,34 @@
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
EVT_DROP_FILES(wxTextCtrl::OnDropFiles) EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
EVT_CHAR(wxTextCtrl::OnChar) EVT_CHAR(wxTextCtrl::OnChar)
EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
// Text item // Text item
wxTextCtrl::wxTextCtrl() wxTextCtrl::wxTextCtrl()
#ifndef NO_TEXT_WINDOW_STREAM
:streambuf()
#endif
{ {
m_fileName = "";
} }
const short kVerticalMargin = 2 ;
const short kHorizontalMargin = 2 ;
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
const wxString& st, const wxString& st,
const wxPoint& pos, const wxPoint& pos,
@@ -61,10 +73,22 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_macHorizontalBorder = 2 ; // additional pixels around the real control // base initialization
m_macVerticalBorder = 2 ; if ( !CreateBase(parent, id, pos, size, style, validator, name) )
return FALSE;
wxSize mySize = size ; wxSize mySize = size ;
if ( UMAHasAppearance() )
{
m_macHorizontalBorder = 5 ; // additional pixels around the real control
m_macVerticalBorder = 5 ;
}
else
{
m_macHorizontalBorder = 0 ; // additional pixels around the real control
m_macVerticalBorder = 0 ;
}
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
@@ -72,14 +96,17 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
if ( mySize.y == -1 ) if ( mySize.y == -1 )
{ {
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
mySize.y = 16 ; mySize.y = 13 ;
else else
mySize.y = 24 ; mySize.y = 24 ;
mySize.y += 2 * m_macVerticalBorder ;
} }
MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ;
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1,
kControlEditTextProc , (long) this ) ; ( style & wxTE_PASSWORD ) ? kControlEditTextPasswordProc : kControlEditTextProc , (long) this ) ;
MacPostControlCreate() ; MacPostControlCreate() ;
wxString value ; wxString value ;
@@ -88,7 +115,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
value = wxMacMakeMacStringFromPC( st ) ; value = wxMacMakeMacStringFromPC( st ) ;
else else
value = st ; value = st ;
UMASetControlData( m_macControl, 0, kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; UMASetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ;
return TRUE; return TRUE;
} }
@@ -96,7 +123,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
wxString wxTextCtrl::GetValue() const wxString wxTextCtrl::GetValue() const
{ {
Size actualsize; Size actualsize;
UMAGetControlData( m_macControl, 0, kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; UMAGetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
wxBuffer[actualsize] = 0 ; wxBuffer[actualsize] = 0 ;
if( wxApp::s_macDefaultEncodingIsPC ) if( wxApp::s_macDefaultEncodingIsPC )
return wxMacMakePCStringFromMac( wxBuffer ) ; return wxMacMakePCStringFromMac( wxBuffer ) ;
@@ -104,6 +131,18 @@ wxString wxTextCtrl::GetValue() const
return wxString(wxBuffer); return wxString(wxBuffer);
} }
void wxTextCtrl::GetSelection(long* from, long* to) const
{
ControlEditTextSelectionRec selection ;
TEHandle teH ;
long size ;
UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
*from = (**teH).selStart;
*to = (**teH).selEnd;
}
void wxTextCtrl::SetValue(const wxString& st) void wxTextCtrl::SetValue(const wxString& st)
{ {
wxString value ; wxString value ;
@@ -112,44 +151,116 @@ void wxTextCtrl::SetValue(const wxString& st)
value = wxMacMakeMacStringFromPC( st ) ; value = wxMacMakeMacStringFromPC( st ) ;
else else
value = st ; value = st ;
UMASetControlData( m_macControl, 0, kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; UMASetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ;
Refresh() ; Refresh() ;
// MacInvalidateControl() ; // MacInvalidateControl() ;
} }
void wxTextCtrl::SetSize(int x, int y, int width, int height, int sizeFlags)
{
wxControl::SetSize( x , y , width , height , sizeFlags ) ;
}
// Clipboard operations // Clipboard operations
void wxTextCtrl::Copy() void wxTextCtrl::Copy()
{ {
TEHandle teH ; if (CanCopy())
long size ; {
TEHandle teH ;
long size ;
UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TECopy( teH ) ; TECopy( teH ) ;
#if TARGET_CARBON
OSStatus err ;
err = ClearCurrentScrap( );
#else
OSErr err ;
err = ZeroScrap( );
#endif
TEToScrap() ;
}
} }
void wxTextCtrl::Cut() void wxTextCtrl::Cut()
{ {
TEHandle teH ; if (CanCut())
long size ; {
TEHandle teH ;
long size ;
UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TECut( teH ) ; TECut( teH ) ;
// MacInvalidateControl() ; #if TARGET_CARBON
OSStatus err ;
err = ClearCurrentScrap( );
#else
OSErr err ;
err = ZeroScrap( );
#endif
TEToScrap() ;
// MacInvalidateControl() ;
}
} }
void wxTextCtrl::Paste() void wxTextCtrl::Paste()
{ {
TEHandle teH ; if (CanPaste())
long size ; {
TEHandle teH ;
long size ;
UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TEPaste( teH ) ; TEFromScrap() ;
TEPaste( teH ) ;
// MacInvalidateControl() ; // MacInvalidateControl() ;
}
}
bool wxTextCtrl::CanCopy() const
{
// Can copy if there's a selection
long from, to;
GetSelection(& from, & to);
return (from != to);
}
bool wxTextCtrl::CanCut() const
{
// Can cut if there's a selection
long from, to;
GetSelection(& from, & to);
return (from != to);
}
bool wxTextCtrl::CanPaste() const
{
if (!IsEditable())
return FALSE;
long offset ;
#if TARGET_CARBON
OSStatus err = noErr;
ScrapRef scrapRef;
err = GetCurrentScrap( &scrapRef );
if ( err != noTypeErr && err != memFullErr )
{
ScrapFlavorFlags flavorFlags;
Size byteCount;
if (( err = GetScrapFlavorFlags( scrapRef, 'TEXT', &flavorFlags )) == noErr)
{
if (( err = GetScrapFlavorSize( scrapRef, 'TEXT', &byteCount )) == noErr)
{
return TRUE ;
}
}
}
return FALSE;
#else
if ( GetScrap( NULL , 'TEXT' , &offset ) > 0 )
{
return TRUE ;
}
#endif
return FALSE ;
} }
void wxTextCtrl::SetEditable(bool editable) void wxTextCtrl::SetEditable(bool editable)
@@ -243,65 +354,10 @@ void wxTextCtrl::SetSelection(long from, long to)
bool wxTextCtrl::LoadFile(const wxString& file) bool wxTextCtrl::LoadFile(const wxString& file)
{ {
if (!wxFileExists(file)) if ( wxTextCtrlBase::LoadFile(file) )
return FALSE;
m_fileName = file;
Clear();
#ifndef __WXMAC__
ifstream input((char*) (const char*) file, ios::nocreate | ios::in);
#else
ifstream input((char*) (const char*) file, ios::in);
#endif
if (!input.bad())
{ {
struct stat stat_buf; return TRUE;
if (stat(file, &stat_buf) < 0)
return FALSE;
// This may need to be a bigger buffer than the file size suggests,
// if it's a UNIX file. Give it an extra 1000 just in case.
char *tmp_buffer = (char*)malloc((size_t)(stat_buf.st_size+1+1000));
long no_lines = 0;
long pos = 0;
while (!input.eof() && input.peek() != EOF)
{
input.getline(wxBuffer, 500);
int len = strlen(wxBuffer);
wxBuffer[len] = 13;
wxBuffer[len+1] = 10;
wxBuffer[len+2] = 0;
strcpy(tmp_buffer+pos, wxBuffer);
pos += strlen(wxBuffer);
no_lines++;
}
// TODO add line
free(tmp_buffer);
return TRUE;
} }
return FALSE;
}
// If file is null, try saved file name first
// Returns TRUE if succeeds.
bool wxTextCtrl::SaveFile(const wxString& file)
{
wxString theFile(file);
if (theFile == "")
theFile = m_fileName;
if (theFile == "")
return FALSE;
m_fileName = theFile;
ofstream output((char*) (const char*) theFile);
if (output.bad())
return FALSE;
// TODO get and save text
return FALSE; return FALSE;
} }
@@ -329,18 +385,8 @@ void wxTextCtrl::AppendText(const wxString& text)
void wxTextCtrl::Clear() void wxTextCtrl::Clear()
{ {
TEHandle teH ; UMASetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ;
long size ; Refresh() ;
ControlEditTextSelectionRec selection ;
selection.selStart = 0 ;
selection.selEnd = 32767 ;
UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TECut( teH ) ;
// MacInvalidateControl() ;
} }
bool wxTextCtrl::IsModified() const bool wxTextCtrl::IsModified() const
@@ -348,6 +394,73 @@ bool wxTextCtrl::IsModified() const
return TRUE; return TRUE;
} }
bool wxTextCtrl::IsEditable() const
{
return IsEnabled();
}
bool wxTextCtrl::AcceptsFocus() const
{
// we don't want focus if we can't be edited
return IsEditable() && wxControl::AcceptsFocus();
}
wxSize wxTextCtrl::DoGetBestSize() const
{
int wText = 100 ;
int hText ;
if ( UMAHasAppearance() )
hText = 13 ;
else
hText = 24 ;
hText += 2 * m_macHorizontalBorder ;
/*
int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
int wText = DEFAULT_ITEM_WIDTH;
int hText = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
return wxSize(wText, hText);
*/
if ( m_windowStyle & wxTE_MULTILINE )
{
hText *= wxMin(GetNumberOfLines(), 5);
}
//else: for single line control everything is ok
return wxSize(wText, hText);
}
// ----------------------------------------------------------------------------
// Undo/redo
// ----------------------------------------------------------------------------
void wxTextCtrl::Undo()
{
if (CanUndo())
{
}
}
void wxTextCtrl::Redo()
{
if (CanRedo())
{
}
}
bool wxTextCtrl::CanUndo() const
{
return FALSE ;
}
bool wxTextCtrl::CanRedo() const
{
return FALSE ;
}
// Makes 'unmodified' // Makes 'unmodified'
void wxTextCtrl::DiscardEdits() void wxTextCtrl::DiscardEdits()
{ {
@@ -366,9 +479,9 @@ long wxTextCtrl::XYToPosition(long x, long y) const
return 0; return 0;
} }
void wxTextCtrl::PositionToXY(long pos, long *x, long *y) const bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
{ {
// TODO return FALSE ;
} }
void wxTextCtrl::ShowPosition(long pos) void wxTextCtrl::ShowPosition(long pos)
@@ -407,204 +520,125 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
void wxTextCtrl::OnChar(wxKeyEvent& event) void wxTextCtrl::OnChar(wxKeyEvent& event)
{ {
switch( event.KeyCode() ) switch ( event.KeyCode() )
{ {
case WXK_RETURN: case WXK_RETURN:
{ if (m_windowStyle & wxPROCESS_ENTER)
if ( !(m_windowStyle & wxTE_MULTILINE) ) {
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
event.SetEventObject( this ); event.SetEventObject( this );
if ( GetEventHandler()->ProcessEvent(event) ) if ( GetEventHandler()->ProcessEvent(event) )
return; return;
}
if ( !(m_windowStyle & wxTE_MULTILINE) )
{
wxWindow *parent = GetParent();
wxPanel *panel = wxDynamicCast(parent, wxPanel);
while ( parent != NULL && panel == NULL )
{
parent = parent->GetParent() ;
panel = wxDynamicCast(parent, wxPanel);
}
if ( panel && panel->GetDefaultItem() )
{
wxButton *def = panel->GetDefaultItem() ;
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
event.SetEventObject(def);
def->Command(event);
event.Skip() ;
return ;
}
} }
//else: multiline controls need Enter for themselves //else: multiline controls need Enter for themselves
break; break;
}
case WXK_TAB: case WXK_TAB:
// always produce navigation event - even if we process TAB // always produce navigation event - even if we process TAB
// ourselves the fact that we got here means that the user code // ourselves the fact that we got here means that the user code
// decided to skip processing of this TAB - probably to let it // decided to skip processing of this TAB - probably to let it
// do its default job. // do its default job.
//
// NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
// handled by Windows
{ {
wxNavigationKeyEvent eventNav; wxNavigationKeyEvent eventNav;
eventNav.SetDirection(!event.ShiftDown()); eventNav.SetDirection(!event.ShiftDown());
eventNav.SetWindowChange(FALSE); eventNav.SetWindowChange(event.ControlDown());
eventNav.SetEventObject(this); eventNav.SetEventObject(this);
if ( GetEventHandler()->ProcessEvent(eventNav) ) if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
return; return;
event.Skip() ;
return ;
} }
break; break;
default:
event.Skip();
return;
} }
// don't just call event.Skip() because this will cause TABs and ENTERs EventRecord *ev = wxTheApp->MacGetCurrentEvent() ;
// be passed upwards and we don't always want this - instead process it short keycode ;
// right here short keychar ;
keychar = short(ev->message & charCodeMask);
keycode = short(ev->message & keyCodeMask) >> 8 ;
UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ;
if ( keychar >= 0x20 || event.KeyCode() == WXK_RETURN)
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
event.SetString( GetValue() ) ;
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
}
// FIXME
event.Skip();
} }
// The streambuf code was partly taken from chapter 3 by Jerry Schwarz of
// AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers
//========================================================================= // ----------------------------------------------------------------------------
// Called then the buffer is full (gcc 2.6.3) // standard handlers for standard edit menu events
// or when "endl" is output (Borland 4.5) // ----------------------------------------------------------------------------
//=========================================================================
// Class declaration using multiple inheritance doesn't work properly for void wxTextCtrl::OnCut(wxCommandEvent& event)
// Borland. See note in wb_text.h.
#ifndef NO_TEXT_WINDOW_STREAM
int wxTextCtrl::overflow(int c)
{ {
// Make sure there is a holding area Cut();
if ( allocate()==EOF )
{
wxError("Streambuf allocation failed","Internal error");
return EOF;
}
// Verify that there are no characters in get area
if ( gptr() && gptr() < egptr() )
{
wxError("Who's trespassing my get area?","Internal error");
return EOF;
}
// Reset get area
setg(0,0,0);
// Make sure there is a put area
if ( ! pptr() )
{
/* This doesn't seem to be fatal so comment out error message */
// wxError("Put area not opened","Internal error");
setp( base(), base() );
}
// Determine how many characters have been inserted but no consumed
int plen = pptr() - pbase();
// Now Jerry relies on the fact that the buffer is at least 2 chars
// long, but the holding area "may be as small as 1" ???
// And we need an additional \0, so let's keep this inefficient but
// safe copy.
// If c!=EOF, it is a character that must also be comsumed
int xtra = c==EOF? 0 : 1;
// Write temporary C-string to wxTextWindow
{
char *txt = new char[plen+xtra+1];
memcpy(txt, pbase(), plen);
txt[plen] = (char)c; // append c
txt[plen+xtra] = '\0'; // append '\0' or overwrite c
// If the put area already contained \0, output will be truncated there
AppendText(txt);
delete[] txt;
}
// Reset put area
setp(pbase(), epptr());
#if defined(__WATCOMC__)
return __NOT_EOF;
#elif defined(zapeof) // HP-UX (all cfront based?)
return zapeof(c);
#else
return c!=EOF ? c : 0; // this should make everybody happy
#endif
} }
//========================================================================= void wxTextCtrl::OnCopy(wxCommandEvent& event)
// called then "endl" is output (gcc) or then explicit sync is done (Borland)
//=========================================================================
int wxTextCtrl::sync()
{ {
// Verify that there are no characters in get area Copy();
if ( gptr() && gptr() < egptr() )
{
wxError("Who's trespassing my get area?","Internal error");
return EOF;
}
if ( pptr() && pptr() > pbase() ) return overflow(EOF);
return 0;
/* OLD CODE
int len = pptr() - pbase();
char *txt = new char[len+1];
strncpy(txt, pbase(), len);
txt[len] = '\0';
(*this) << txt;
setp(pbase(), epptr());
delete[] txt;
return 0;
*/
} }
//========================================================================= void wxTextCtrl::OnPaste(wxCommandEvent& event)
// Should not be called by a "ostream". Used by a "istream"
//=========================================================================
int wxTextCtrl::underflow()
{ {
return EOF; Paste();
} }
#endif
wxTextCtrl& wxTextCtrl::operator<<(const wxString& s) void wxTextCtrl::OnUndo(wxCommandEvent& event)
{ {
AppendText(s); Undo();
return *this;
} }
wxTextCtrl& wxTextCtrl::operator<<(float f) void wxTextCtrl::OnRedo(wxCommandEvent& event)
{ {
wxString str; Redo();
str.Printf("%.2f", f);
AppendText(str);
return *this;
} }
wxTextCtrl& wxTextCtrl::operator<<(double d) void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
{ {
wxString str; event.Enable( CanCut() );
str.Printf("%.2f", d);
AppendText(str);
return *this;
} }
wxTextCtrl& wxTextCtrl::operator<<(int i) void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
{ {
wxString str; event.Enable( CanCopy() );
str.Printf("%d", i);
AppendText(str);
return *this;
} }
wxTextCtrl& wxTextCtrl::operator<<(long i) void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
{ {
wxString str; event.Enable( CanPaste() );
str.Printf("%ld", i);
AppendText(str);
return *this;
} }
wxTextCtrl& wxTextCtrl::operator<<(const char c) void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
{ {
char buf[2]; event.Enable( CanUndo() );
}
buf[0] = c;
buf[1] = 0; void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
AppendText(buf); {
return *this; event.Enable( CanRedo() );
} }

View File

@@ -15,13 +15,48 @@
#include "wx/timer.h" #include "wx/timer.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
#endif
static void wxProcessTimer( unsigned long event , void *data ) ;
pascal void MacTimerProc( TMTask * t )
{
MacTimerInfo * tm = (MacTimerInfo*) t ;
wxMacAddEvent( tm->m_table , wxProcessTimer, 0 , (void*) tm->m_timer , TRUE ) ;
}
void wxProcessTimer( unsigned long event , void *data )
{
if ( !data )
return ;
wxTimer* timer = (wxTimer*) data ;
if ( timer->IsOneShot() )
timer->Stop() ;
timer->Notify();
if ( timer->m_info.m_task.tmAddr && !timer->IsOneShot() )
{
PrimeTime( (QElemPtr) &timer->m_info.m_task , timer->GetInterval() ) ;
}
}
wxTimer::wxTimer() wxTimer::wxTimer()
{ {
m_milli = 0 ; m_info.m_task.tmAddr = NULL ;
m_id = 0; m_info.m_task.tmWakeUp = 0 ;
m_oneShot = FALSE; m_info.m_task.tmReserved = 0 ;
m_info.m_task.qType = 0 ;
m_info.m_table = wxMacGetNotifierTable() ;
m_info.m_timer = this ;
}
bool wxTimer::IsRunning() const
{
return ( m_info.m_task.qType & kTMTaskActive ) ;
} }
wxTimer::~wxTimer() wxTimer::~wxTimer()
@@ -31,20 +66,31 @@ wxTimer::~wxTimer()
bool wxTimer::Start(int milliseconds,bool mode) bool wxTimer::Start(int milliseconds,bool mode)
{ {
m_oneShot = mode ; (void)wxTimerBase::Start(milliseconds, mode);
if (milliseconds <= 0)
return FALSE; wxCHECK_MSG( m_milli > 0, FALSE, wxT("invalid value for timer timeour") );
wxCHECK_MSG( m_info.m_task.tmAddr == NULL , FALSE, wxT("attempting to restart a timer") );
m_milli = milliseconds; m_milli = milliseconds;
m_info.m_task.tmAddr = NewTimerProc( MacTimerProc ) ;
// TODO: set the timer going. m_info.m_task.tmWakeUp = 0 ;
m_info.m_task.tmReserved = 0 ;
InsXTime((QElemPtr) &m_info.m_task ) ;
PrimeTime( (QElemPtr) &m_info.m_task , m_milli ) ;
return FALSE; return FALSE;
} }
void wxTimer::Stop() void wxTimer::Stop()
{ {
m_id = 0 ;
m_milli = 0 ; m_milli = 0 ;
if ( m_info.m_task.tmAddr )
{
RmvTime( (QElemPtr) &m_info.m_task ) ;
DisposeTimerUPP(m_info.m_task.tmAddr) ;
m_info.m_task.tmAddr = NULL ;
}
wxMacRemoveAllNotifiersForData( wxMacGetNotifierTable() , this ) ;
} }

View File

@@ -5,8 +5,7 @@
// Modified by: // Modified by:
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) AUTHORy
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -18,11 +17,17 @@
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/notebook.h"
#include "wx/tabctrl.h"
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase) #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl)
BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase) BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
EVT_MOUSE_EVENTS( wxToolBar::OnMouse )
EVT_PAINT( wxToolBar::OnPaint )
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
@@ -45,14 +50,14 @@ public:
clientData, shortHelpString, longHelpString) clientData, shortHelpString, longHelpString)
{ {
m_nSepCount = 0; m_nSepCount = 0;
m_index = 0 ; m_index = -1 ;
} }
wxToolBarTool(wxToolBar *tbar, wxControl *control) wxToolBarTool(wxToolBar *tbar, wxControl *control)
: wxToolBarToolBase(tbar, control) : wxToolBarToolBase(tbar, control)
{ {
m_nSepCount = 1; m_nSepCount = 1;
m_index = 0 ; m_index = -1 ;
} }
// set/get the number of separators which we use to cover the space used by // set/get the number of separators which we use to cover the space used by
@@ -74,6 +79,9 @@ private:
// wxToolBarTool // wxToolBarTool
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
const short defwidth = 24 ;
const short defheight = 22 ;
wxToolBarToolBase *wxToolBar::CreateTool(int id, wxToolBarToolBase *wxToolBar::CreateTool(int id,
const wxBitmap& bitmap1, const wxBitmap& bitmap1,
const wxBitmap& bitmap2, const wxBitmap& bitmap2,
@@ -91,16 +99,12 @@ wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control)
return new wxToolBarTool(this, control); return new wxToolBarTool(this, control);
} }
// ----------------------------------------------------------------------------
// wxToolBar construction
// ----------------------------------------------------------------------------
void wxToolBar::Init() void wxToolBar::Init()
{ {
m_maxWidth = -1; m_maxWidth = -1;
m_maxHeight = -1; m_maxHeight = -1;
m_defaultWidth = 24; m_defaultWidth = defwidth;
m_defaultHeight = 22; m_defaultHeight = defheight;
// TODO // TODO
} }
@@ -109,8 +113,8 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
{ {
m_maxWidth = m_maxHeight = 0; m_maxWidth = m_maxHeight = 0;
m_defaultWidth = 24; m_defaultWidth = defwidth;
m_defaultHeight = 22; m_defaultHeight = defheight;
int x = pos.x; int x = pos.x;
int y = pos.y; int y = pos.y;
@@ -125,16 +129,39 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
x = 0; x = 0;
if (y < 0) if (y < 0)
y = 0; y = 0;
#if 1
{
SetName(name);
m_windowStyle = style;
parent->AddChild(this);
m_backgroundColour = parent->GetBackgroundColour() ;
m_foregroundColour = parent->GetForegroundColour() ;
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
m_width = size.x ;
m_height = size.y ;
int x = pos.x ;
int y = pos.y ;
AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING);
m_x = x ;
m_y = y ;
}
#else
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
MacPreControlCreate( parent , id , "" , wxPoint( x , y ) , wxSize( width , height ) ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; MacPreControlCreate( parent , id , "" , wxPoint( x , y ) , wxSize( width , height ) ,style, wxDefaultValidator , name , &bounds , title ) ;
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1,
kControlPlacardProc , (long) this ) ; kControlPlacardProc , (long) this ) ;
MacPostControlCreate() ; MacPostControlCreate() ;
#endif
return TRUE; return TRUE;
} }
@@ -143,7 +170,8 @@ wxToolBar::~wxToolBar()
// TODO // TODO
} }
PicHandle MakePict(GWorldPtr wp) PicHandle MakePict(GWorldPtr wp, GWorldPtr mask ) ;
PicHandle MakePict(GWorldPtr wp, GWorldPtr mask )
{ {
CGrafPtr origPort ; CGrafPtr origPort ;
GDHandle origDev ; GDHandle origDev ;
@@ -151,52 +179,77 @@ PicHandle MakePict(GWorldPtr wp)
PicHandle pict; // this is the Picture we give back PicHandle pict; // this is the Picture we give back
RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ; RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ;
RGBColor white = { 0xffff ,0xffff , 0xffff } ;
RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;
unsigned char *maskimage = NULL ;
Rect portRect ;
GetPortBounds( wp , &portRect ) ;
int width = portRect.right - portRect.left ;
int height = portRect.bottom - portRect.top ;
LockPixels( GetGWorldPixMap( wp ) ) ;
GetGWorld( &origPort , &origDev ) ; GetGWorld( &origPort , &origDev ) ;
if ( mask )
{
maskimage = (unsigned char*) malloc( width * height ) ;
SetGWorld( mask , NULL ) ;
LockPixels( GetGWorldPixMap( mask ) ) ;
for ( int y = 0 ; y < height ; ++y )
{
for( int x = 0 ; x < width ; ++x )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
maskimage[y*width + x] = ( col.red == 0 ) ; // for monochrome masks
}
}
UnlockPixels( GetGWorldPixMap( mask ) ) ;
}
SetGWorld( wp , NULL ) ; SetGWorld( wp , NULL ) ;
pict = OpenPicture(&wp->portRect); // open a picture, this disables drawing pict = OpenPicture(&portRect); // open a picture, this disables drawing
if(!pict) if(!pict)
return NULL; return NULL;
RGBBackColor( &gray ) ; RGBBackColor( &gray ) ;
EraseRect(&wp->portRect) ; RGBForeColor( &black ) ;
CopyBits((BitMap*)*wp->portPixMap, // src PixMap - we copy image over itself - EraseRect(&portRect) ;
(BitMap*)*wp->portPixMap, // dst PixMap - no drawing occurs -
&wp->portRect, // srcRect - it will be recorded and compressed -
&wp->portRect, // dstRect - into the picture that is open -
srcCopy,NULL); // copyMode and no clip region
ClosePicture(); // We are done recording the picture
SetGWorld( origPort , origDev ) ;
return pict; // return our groovy pict handle
}
PicHandle MakePictWhite(GWorldPtr wp)
{
CGrafPtr origPort ;
GDHandle origDev ;
PicHandle pict; // this is the Picture we give back
RGBColor white = { 0xFFFF ,0xFFFF , 0xFFFF } ;
GetGWorld( &origPort , &origDev ) ;
SetGWorld( wp , NULL ) ;
pict = OpenPicture(&wp->portRect); // open a picture, this disables drawing
if(!pict)
return NULL;
RGBBackColor( &white ) ; RGBBackColor( &white ) ;
EraseRect(&wp->portRect) ;
CopyBits((BitMap*)*wp->portPixMap, // src PixMap - we copy image over itself - if ( maskimage )
(BitMap*)*wp->portPixMap, // dst PixMap - no drawing occurs - {
&wp->portRect, // srcRect - it will be recorded and compressed - for ( int y = 0 ; y < height ; ++y )
&wp->portRect, // dstRect - into the picture that is open - {
for( int x = 0 ; x < width ; ++x )
{
if ( maskimage[y*width + x] )
{
RGBColor col ;
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
SetCPixel( x + portRect.left , y + portRect.top , &col ) ;
}
}
}
free( maskimage ) ;
maskimage = NULL ;
}
else
{
CopyBits(GetPortBitMapForCopyBits(wp), // src PixMap - we copy image over itself -
GetPortBitMapForCopyBits(wp), // dst PixMap - no drawing occurs -
&portRect, // srcRect - it will be recorded and compressed -
&portRect, // dstRect - into the picture that is open -
srcCopy,NULL); // copyMode and no clip region srcCopy,NULL); // copyMode and no clip region
}
ClosePicture(); // We are done recording the picture ClosePicture(); // We are done recording the picture
UnlockPixels( GetGWorldPixMap( wp ) ) ;
SetGWorld( origPort , origDev ) ; SetGWorld( origPort , origDev ) ;
return pict; // return our groovy pict handle return pict; // return our groovy pict handle
} }
@@ -226,7 +279,7 @@ bool wxToolBar::Realize()
wxToolBarTool *tool = (wxToolBarTool *)node->Data(); wxToolBarTool *tool = (wxToolBarTool *)node->Data();
wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->GetBitmap1().GetRefData()) ; wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->GetBitmap1().GetRefData()) ;
if( !tool->IsSeparator() ) if( !tool->IsSeparator() )
{ {
Rect toolrect = { toolbarrect.top + kwxMacToolBarTopMargin , toolbarrect.left + x + kwxMacToolBarLeftMargin , 0 , 0 } ; Rect toolrect = { toolbarrect.top + kwxMacToolBarTopMargin , toolbarrect.left + x + kwxMacToolBarLeftMargin , 0 , 0 } ;
toolrect.right = toolrect.left + toolSize.x ; toolrect.right = toolrect.left + toolSize.x ;
@@ -239,7 +292,14 @@ bool wxToolBar::Realize()
icon = bmap->m_hPict ; icon = bmap->m_hPict ;
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld ) else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
{ {
icon = MakePict( bmap->m_hBitmap ) ; if ( tool->GetBitmap1().GetMask() )
{
icon = MakePict( bmap->m_hBitmap , tool->GetBitmap1().GetMask()->GetMaskBitmap() ) ;
}
else
{
icon = MakePict( bmap->m_hBitmap , NULL ) ;
}
} }
} }
@@ -266,8 +326,19 @@ bool wxToolBar::Realize()
behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ; behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
} }
m_macToolHandles.Add( m_macToolHandle ) ; m_macToolHandles.Add( m_macToolHandle ) ;
tool->m_index = m_macToolHandles.Count() -1 ;
if ( !tool->IsEnabled() )
{
UMADeactivateControl( m_macToolHandle ) ;
}
if ( tool->CanBeToggled() && tool->IsToggled() )
{
::SetControlValue( m_macToolHandle , 1 ) ;
}
UMASetControlFontStyle( m_macToolHandle , &controlstyle ) ; UMASetControlFontStyle( m_macToolHandle , &controlstyle ) ;
UMAEmbedControl( m_macToolHandle , m_macControl ) ; ControlHandle container = GetParent()->MacGetContainerForEmbedding() ;
wxASSERT_MSG( container != NULL , "No valid mac container control" ) ;
UMAEmbedControl( m_macToolHandle , container ) ;
x += (int)toolSize.x; x += (int)toolSize.x;
noButtons ++; noButtons ++;
@@ -311,7 +382,7 @@ void wxToolBar::SetToolBitmapSize(const wxSize& size)
// The button size is bigger than the bitmap size // The button size is bigger than the bitmap size
wxSize wxToolBar::GetToolSize() const wxSize wxToolBar::GetToolSize() const
{ {
return wxSize(m_defaultWidth + 8, m_defaultHeight + 7); return wxSize(m_defaultWidth + 4, m_defaultHeight + 4);
} }
void wxToolBar::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) void wxToolBar::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
@@ -321,7 +392,13 @@ void wxToolBar::MacHandleControlClick( ControlHandle control , SInt16 controlpar
{ {
if ( m_macToolHandles[index] == (void*) control ) if ( m_macToolHandles[index] == (void*) control )
{ {
OnLeftClick( ( (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ) ->m_index , ( (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ) ->IsToggled() ) ; wxToolBarTool *tool = (wxToolBarTool *)m_tools.Nth( index )->Data();
if ( tool->CanBeToggled() )
{
tool->Toggle( GetControlValue( control ) ) ;
}
OnLeftClick( tool->GetId() , tool -> IsToggled() ) ;
break ;
} }
} }
} }
@@ -340,43 +417,54 @@ void wxToolBar::SetRows(int nRows)
wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
{ {
MacClientToRootWindow( &x , &y ) ; MacClientToRootWindow( &x , &y ) ;
Point pt = { x ,y } ; Point pt = { y ,x } ;
int index = 0 ; int index = 0 ;
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index ) for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
{ {
if ( PtInRect( pt , &(**(ControlHandle)(m_macToolHandles[index])).contrlRect) ) if ( m_macToolHandles[index] )
{ {
return (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ; Rect bounds ;
GetControlBounds((ControlHandle) m_macToolHandles[index], &bounds ) ;
if ( PtInRect( pt , &bounds ) )
{
return (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ;
}
} }
} }
return (wxToolBarToolBase *)NULL; return (wxToolBarToolBase *)NULL;
} }
wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
{
wxToolBarToolBase* tool = FindToolForPosition( pt.x , pt.y ) ;
if ( tool )
{
return tool->GetShortHelp() ;
}
return "" ;
}
void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable) void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
{ {
wxToolBarTool *tool = (wxToolBarTool *)t; wxToolBarTool *tool = (wxToolBarTool *)t;
if ( tool->m_index < 0 )
return ;
ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ; ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
if ( UMAHasAppearance() )
{ if ( enable )
if ( enable ) UMAActivateControl( control ) ;
::ActivateControl( control ) ;
else
::DeactivateControl( control ) ;
}
else else
{ UMADeactivateControl( control ) ;
if ( enable )
::HiliteControl( control , 0 ) ;
else
::HiliteControl( control , 255 ) ;
}
} }
void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle) void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
{ {
wxToolBarTool *tool = (wxToolBarTool *)t; wxToolBarTool *tool = (wxToolBarTool *)t;
if ( tool->m_index < 0 )
return ;
ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ; ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
::SetControlValue( control , toggle ) ; ::SetControlValue( control , toggle ) ;
@@ -402,5 +490,116 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
{ {
return TRUE ; return TRUE ;
} }
void wxToolBar::OnPaint(wxPaintEvent& event)
{
WindowRef window = GetMacRootWindow() ;
if ( window )
{
wxWindow* win = wxFindWinFromMacWindow( window ) ;
if ( win )
{
wxMacDrawingHelper help( win ) ;
// the mac control manager always assumes to have the origin at 0,0
SetOrigin( 0 , 0 ) ;
bool hasTabBehind = false ;
wxWindow* parent = GetParent() ;
while ( parent )
{
if( parent->MacGetWindowData() )
{
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
break ;
}
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
{
if ( ((wxControl*)parent)->GetMacControl() )
SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
break ;
}
parent = parent->GetParent() ;
}
Rect toolbarrect = { m_y , m_x , m_y + m_height , m_x + m_width } ;
UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
{
int index = 0 ;
for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
{
if ( m_macToolHandles[index] )
{
UMADrawControl( (ControlHandle) m_macToolHandles[index] ) ;
}
}
}
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
}
}
}
void wxToolBar::OnMouse( wxMouseEvent &event )
{
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
{
int x = event.m_x ;
int y = event.m_y ;
MacClientToRootWindow( &x , &y ) ;
ControlHandle control ;
Point localwhere ;
GrafPtr port ;
SInt16 controlpart ;
WindowRef window = GetMacRootWindow() ;
localwhere.h = x ;
localwhere.v = y ;
short modifiers = 0;
if ( !event.m_leftDown && !event.m_rightDown )
modifiers |= btnState ;
if ( event.m_shiftDown )
modifiers |= shiftKey ;
if ( event.m_controlDown )
modifiers |= controlKey ;
if ( event.m_altDown )
modifiers |= optionKey ;
if ( event.m_metaDown )
modifiers |= cmdKey ;
controlpart = FindControl( localwhere , window , &control ) ;
{
if ( AcceptsFocus() && FindFocus() != this )
{
SetFocus() ;
}
if ( control && UMAIsControlActive( control ) )
{
{
if ( controlpart == kControlIndicatorPart && !UMAHasAppearance() )
controlpart = UMAHandleControlClick( control , localwhere , modifiers , (ControlActionUPP) NULL ) ;
else
controlpart = UMAHandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
wxTheApp->s_lastMouseDown = 0 ;
if ( controlpart && ! ( ( UMAHasAppearance() || (controlpart != kControlIndicatorPart) )
&& (IsKindOf( CLASSINFO( wxScrollBar ) ) ) ) ) // otherwise we will get the event twice
{
MacHandleControlClick( control , controlpart ) ;
}
}
}
}
}
}
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR

View File

@@ -16,9 +16,11 @@
#include "wx/stubs/textctrl.h" #include "wx/stubs/textctrl.h"
#include "wx/stubs/treectrl.h" #include "wx/stubs/treectrl.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
#endif
wxTreeCtrl::wxTreeCtrl() wxTreeCtrl::wxTreeCtrl()
{ {

View File

@@ -33,7 +33,7 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls )
long total,contig; long total,contig;
PurgeSpace(&total, &contig); PurgeSpace(&total, &contig);
#else #else
InitMenus() ; InitCursor();
#endif #endif
#if UMA_USE_APPEARANCE #if UMA_USE_APPEARANCE
@@ -87,7 +87,7 @@ bool UMAGetProcessModeDoesActivateOnFGSwitch()
// menu manager // menu manager
void UMASetMenuTitle( MenuRef menu , ConstStr255Param title ) void UMASetMenuTitle( MenuRef menu , StringPtr title )
{ {
#if !TARGET_CARBON #if !TARGET_CARBON
long size = GetHandleSize( (Handle) menu ) ; long size = GetHandleSize( (Handle) menu ) ;
@@ -117,11 +117,13 @@ void UMASetMenuTitle( MenuRef menu , ConstStr255Param title )
UInt32 UMAMenuEvent( EventRecord *inEvent ) UInt32 UMAMenuEvent( EventRecord *inEvent )
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return MenuEvent( inEvent ) ; return MenuEvent( inEvent ) ;
} }
else else
#endif
{ {
if ( inEvent->what == keyDown && inEvent->modifiers & cmdKey) if ( inEvent->what == keyDown && inEvent->modifiers & cmdKey)
{ {
@@ -133,7 +135,7 @@ UInt32 UMAMenuEvent( EventRecord *inEvent )
void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex inItem ) void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex inItem )
{ {
#if UMA_USE_8_6 #if UMA_USE_8_6 || TARGET_CARBON
EnableMenuItem( inMenu , inItem ) ; EnableMenuItem( inMenu , inItem ) ;
#else #else
EnableItem( inMenu , inItem ) ; EnableItem( inMenu , inItem ) ;
@@ -142,14 +144,145 @@ void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex inItem )
void UMADisableMenuItem( MenuRef inMenu , MenuItemIndex inItem ) void UMADisableMenuItem( MenuRef inMenu , MenuItemIndex inItem )
{ {
#if UMA_USE_8_6 #if UMA_USE_8_6 || TARGET_CARBON
DisableMenuItem( inMenu , inItem ) ; DisableMenuItem( inMenu , inItem ) ;
#else #else
DisableItem( inMenu , inItem ) ; DisableItem( inMenu , inItem ) ;
#endif #endif
} }
void UMAAppendSubMenuItem( MenuRef menu , StringPtr l , SInt16 id )
{
Str255 label ;
memcpy( label , l , l[0]+1 ) ;
// hardcoded adding of the submenu combination for mac
int theEnd = label[0] + 1;
if (theEnd > 251)
theEnd = 251; // mac allows only 255 characters
label[theEnd++] = '/';
label[theEnd++] = hMenuCmd;
label[theEnd++] = '!';
label[theEnd++] = id ;
label[theEnd] = 0x00;
label[0] = theEnd;
MacAppendMenu(menu, label);
}
void UMAInsertSubMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 id )
{
Str255 label ;
memcpy( label , l , l[0]+1 ) ;
// hardcoded adding of the submenu combination for mac
int theEnd = label[0] + 1;
if (theEnd > 251)
theEnd = 251; // mac allows only 255 characters
label[theEnd++] = '/';
label[theEnd++] = hMenuCmd;
label[theEnd++] = '!';
label[theEnd++] = id;
label[theEnd] = 0x00;
label[0] = theEnd;
MacInsertMenuItem(menu, label , item);
}
void UMAAppendMenuItem( MenuRef menu , StringPtr l , SInt16 key, UInt8 modifiers )
{
Str255 label ;
memcpy( label , l , l[0]+1 ) ;
if ( key )
{
int pos = label[0] ;
label[++pos] = '/';
label[++pos] = toupper( key );
label[0] = pos ;
}
MacAppendMenu( menu , label ) ;
}
void UMAInsertMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 key, UInt8 modifiers )
{
Str255 label ;
memcpy( label , l , l[0]+1 ) ;
if ( key )
{
int pos = label[0] ;
label[++pos] = '/';
label[++pos] = toupper( key );
label[0] = pos ;
}
MacInsertMenuItem( menu , label , item) ;
}
void UMADrawMenuBar()
{
DrawMenuBar() ;
}
void UMASetMenuItemText( MenuRef menu , MenuItemIndex item , StringPtr label )
{
::SetMenuItemText( menu , item , label ) ;
}
MenuRef UMANewMenu( SInt16 menuid , StringPtr label )
{
return ::NewMenu(menuid, label);
}
void UMADisposeMenu( MenuRef menu )
{
DisposeMenu( menu ) ;
}
void UMADeleteMenu( SInt16 menuId )
{
::DeleteMenu( menuId ) ;
}
void UMAInsertMenu( MenuRef insertMenu , SInt16 afterId )
{
::InsertMenu( insertMenu , afterId ) ;
}
// quickdraw // quickdraw
int gPrOpenCounter = 0 ;
void UMAPrOpen()
{
#if !TARGET_CARBON
OSErr err = noErr ;
++gPrOpenCounter ;
if ( gPrOpenCounter == 1 )
{
PrOpen() ;
err = PrError() ;
wxASSERT( err == noErr ) ;
}
#else
#pragma warning "TODO Printing for Carbon"
#endif
}
void UMAPrClose()
{
#if !TARGET_CARBON
OSErr err = noErr ;
wxASSERT( gPrOpenCounter >= 1 ) ;
if ( gPrOpenCounter == 1 )
{
PrClose() ;
err = PrError() ;
wxASSERT( err == noErr ) ;
}
--gPrOpenCounter ;
#else
#pragma warning "TODO Printing for Carbon"
#endif
}
#if !TARGET_CARBON #if !TARGET_CARBON
pascal QDGlobalsPtr GetQDGlobalsPtr (void) pascal QDGlobalsPtr GetQDGlobalsPtr (void)
@@ -260,77 +393,145 @@ void UMACloseWindow(WindowRef inWindowRef)
void UMAActivateControl( ControlHandle inControl ) void UMAActivateControl( ControlHandle inControl )
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
::ActivateControl( inControl ) ; ::ActivateControl( inControl ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
AGAActivateControl( inControl ) ; AGAActivateControl( inControl ) ;
} }
#else
{
}
#endif
} }
void UMADrawControl( ControlHandle inControl ) void UMADrawControl( ControlHandle inControl )
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
::DrawControlInCurrentPort( inControl ) ; ::DrawControlInCurrentPort( inControl ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
AGADrawControl( inControl ) ; AGADrawControl( inControl ) ;
} }
#else
{
}
#endif
} }
void UMAMoveControl( ControlHandle inControl , short x , short y ) void UMAMoveControl( ControlHandle inControl , short x , short y )
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
::MoveControl( inControl , x , y ) ; ::MoveControl( inControl , x , y ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
AGAMoveControl( inControl , x ,y ) ; AGAMoveControl( inControl , x ,y ) ;
} }
#else
{
}
#endif
} }
void UMASizeControl( ControlHandle inControl , short x , short y ) void UMASizeControl( ControlHandle inControl , short x , short y )
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
::SizeControl( inControl , x , y ) ; ::SizeControl( inControl , x , y ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
AGASizeControl( inControl , x ,y ) ; AGASizeControl( inControl , x ,y ) ;
} }
#else
{
}
#endif
} }
void UMADeactivateControl( ControlHandle inControl ) void UMADeactivateControl( ControlHandle inControl )
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
::DeactivateControl( inControl ) ; ::DeactivateControl( inControl ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
AGADeactivateControl( inControl ) ; AGADeactivateControl( inControl ) ;
} }
#else
{
}
#endif
} }
void UMASetThemeWindowBackground (WindowRef inWindow, void UMASetThemeWindowBackground (WindowRef inWindow,
ThemeBrush inBrush, ThemeBrush inBrush,
Boolean inUpdate){ Boolean inUpdate)
{
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
::SetThemeWindowBackground( inWindow ,inBrush , inUpdate ) ; ::SetThemeWindowBackground( inWindow ,inBrush , inUpdate ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
AGASetThemeWindowBackground( inWindow , inBrush , inUpdate ) ; AGASetThemeWindowBackground( inWindow , inBrush , inUpdate ) ;
} }
#else
{
}
#endif
} }
void UMAApplyThemeBackground (ThemeBackgroundKind inKind,
const Rect * bounds,
ThemeDrawState inState,
SInt16 inDepth,
Boolean inColorDev)
{
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() )
{
/*
if ( sUMAAppearanceVersion >= 0x0110 )
::ApplyThemeBackground( inKind ,bounds , inState , inDepth , inColorDev ) ;
*/
}
else
#endif
#if !TARGET_CARBON
{
AGAApplyThemeBackground( inKind ,bounds , inState , inDepth , inColorDev ) ;
}
#else
{
}
#endif
}
ControlHandle UMANewControl(WindowPtr owningWindow, ControlHandle UMANewControl(WindowPtr owningWindow,
const Rect * boundsRect, const Rect * boundsRect,
@@ -343,16 +544,23 @@ ControlHandle UMANewControl(WindowPtr owningWindow,
SInt32 controlReference) SInt32 controlReference)
{ {
ControlHandle theControl = NULL ; ControlHandle theControl = NULL ;
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
theControl = NewControl( owningWindow , boundsRect , controlTitle , initiallyVisible , theControl = NewControl( owningWindow , boundsRect , controlTitle , initiallyVisible ,
initialValue , minimumValue , maximumValue , procID , controlReference ) ; initialValue , minimumValue , maximumValue , procID , controlReference ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
theControl = AGANewControl( owningWindow , boundsRect , controlTitle , initiallyVisible , theControl = AGANewControl( owningWindow , boundsRect , controlTitle , initiallyVisible ,
initialValue , minimumValue , maximumValue , procID , controlReference ) ; initialValue , minimumValue , maximumValue , procID , controlReference ) ;
} }
#else
{
}
#endif
return theControl ; return theControl ;
} }
@@ -415,7 +623,9 @@ void UMASetControlVisibility (ControlHandle inControl,
{ {
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
#if UMA_USE_APPEARANCE
::SetControlVisibility( inControl , inIsVisible, inDoDraw ) ; ::SetControlVisibility( inControl , inIsVisible, inDoDraw ) ;
#endif
} }
} }
@@ -423,21 +633,29 @@ void UMASetControlVisibility (ControlHandle inControl,
bool UMAIsControlActive (ControlHandle inControl) bool UMAIsControlActive (ControlHandle inControl)
{ {
#if TARGET_CARBON
return IsControlActive( inControl ) ;
#else
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return IsControlActive( inControl ) ; return IsControlActive( inControl ) ;
} }
else else
#endif
return (**inControl).contrlHilite == 0 ; return (**inControl).contrlHilite == 0 ;
#endif
} }
bool UMAIsControlVisible (ControlHandle inControl) bool UMAIsControlVisible (ControlHandle inControl)
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return IsControlVisible( inControl ) ; return IsControlVisible( inControl ) ;
} }
#endif
return true ; return true ;
} }
@@ -445,26 +663,42 @@ OSErr UMAGetBestControlRect (ControlHandle inControl,
Rect * outRect, Rect * outRect,
SInt16 * outBaseLineOffset) SInt16 * outBaseLineOffset)
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return GetBestControlRect( inControl , outRect , outBaseLineOffset ) ; return GetBestControlRect( inControl , outRect , outBaseLineOffset ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
return AGAGetBestControlRect( inControl , outRect , outBaseLineOffset ) ; return AGAGetBestControlRect( inControl , outRect , outBaseLineOffset ) ;
} }
#else
{
return noErr ;
}
#endif
} }
OSErr UMASetControlFontStyle (ControlHandle inControl, OSErr UMASetControlFontStyle (ControlHandle inControl,
const ControlFontStyleRec * inStyle) const ControlFontStyleRec * inStyle)
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return ::SetControlFontStyle( inControl , inStyle ) ; return ::SetControlFontStyle( inControl , inStyle ) ;
} }
else else
#endif
#if !TARGET_CARBON
return AGASetControlFontStyle( inControl , inStyle ) ; return AGASetControlFontStyle( inControl , inStyle ) ;
#else
{
return noErr ;
}
#endif
} }
@@ -474,12 +708,20 @@ OSErr UMASetControlFontStyle (ControlHandle inControl,
OSErr UMACreateRootControl (WindowPtr inWindow, OSErr UMACreateRootControl (WindowPtr inWindow,
ControlHandle * outControl) ControlHandle * outControl)
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return CreateRootControl( inWindow , outControl ) ; return CreateRootControl( inWindow , outControl ) ;
} }
else else
#endif
#if !TARGET_CARBON
return AGACreateRootControl( inWindow , outControl ) ; return AGACreateRootControl( inWindow , outControl ) ;
#else
{
return noErr ;
}
#endif
} }
@@ -487,12 +729,20 @@ OSErr UMACreateRootControl (WindowPtr inWindow,
OSErr UMAEmbedControl (ControlHandle inControl, OSErr UMAEmbedControl (ControlHandle inControl,
ControlHandle inContainer) ControlHandle inContainer)
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return EmbedControl( inControl , inContainer ) ; return EmbedControl( inControl , inContainer ) ;
} }
else else
#endif
#if !TARGET_CARBON
return AGAEmbedControl( inControl , inContainer ) ; ; return AGAEmbedControl( inControl , inContainer ) ; ;
#else
{
return noErr ;
}
#endif
} }
@@ -502,12 +752,30 @@ OSErr UMASetKeyboardFocus (WindowPtr inWindow,
ControlHandle inControl, ControlHandle inControl,
ControlFocusPart inPart) ControlFocusPart inPart)
{ {
OSErr err = noErr;
GrafPtr port ;
GetPort( &port ) ;
#if TARGET_CARBON
SetPort( GetWindowPort( inWindow ) ) ;
#else
SetPort( inWindow ) ;
#endif
SetOrigin( 0 , 0 ) ;
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return SetKeyboardFocus( inWindow , inControl , inPart ) ; err = SetKeyboardFocus( inWindow , inControl , inPart ) ;
} }
else else
return AGASetKeyboardFocus( inWindow , inControl , inPart ) ; #endif
#if !TARGET_CARBON
err = AGASetKeyboardFocus( inWindow , inControl , inPart ) ;
#else
{
}
#endif
SetPort( port ) ;
return err ;
} }
@@ -520,14 +788,22 @@ ControlPartCode UMAHandleControlClick (ControlHandle inControl,
SInt16 inModifiers, SInt16 inModifiers,
ControlActionUPP inAction) ControlActionUPP inAction)
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return HandleControlClick( inControl , inWhere , inModifiers , inAction ) ; return HandleControlClick( inControl , inWhere , inModifiers , inAction ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
return AGAHandleControlClick( inControl , inWhere , inModifiers , inAction ) ; return AGAHandleControlClick( inControl , inWhere , inModifiers , inAction ) ;
} }
#else
{
return noErr ;
}
#endif
} }
@@ -536,52 +812,82 @@ SInt16 UMAHandleControlKey (ControlHandle inControl,
SInt16 inCharCode, SInt16 inCharCode,
SInt16 inModifiers) SInt16 inModifiers)
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return HandleControlKey( inControl , inKeyCode , inCharCode , inModifiers ) ; return HandleControlKey( inControl , inKeyCode , inCharCode , inModifiers ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
return AGAHandleControlKey(inControl , inKeyCode , inCharCode , inModifiers ) ; return AGAHandleControlKey(inControl , inKeyCode , inCharCode , inModifiers ) ;
} }
#else
{
return noErr ;
}
#endif
} }
void UMAIdleControls (WindowPtr inWindow) void UMAIdleControls (WindowPtr inWindow)
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
IdleControls( inWindow ) ; IdleControls( inWindow ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
AGAIdleControls( inWindow ) ; AGAIdleControls( inWindow ) ;
} }
#else
{
}
#endif
} }
void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn )
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
UpdateControls( inWindow , inRgn ) ; UpdateControls( inWindow , inRgn ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
AGAUpdateControls( inWindow , inRgn ) ; AGAUpdateControls( inWindow , inRgn ) ;
} }
#else
{
}
#endif
} }
OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl ) OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl )
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return GetRootControl( inWindow , outControl ) ; return GetRootControl( inWindow , outControl ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
return AGAGetRootControl( inWindow , outControl ) ; return AGAGetRootControl( inWindow , outControl ) ;
} }
#else
{
return noErr ;
}
#endif
} }
@@ -593,12 +899,20 @@ OSErr UMASetControlData (ControlHandle inControl,
Size inSize, Size inSize,
Ptr inData) Ptr inData)
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return SetControlData( inControl , inPart , inTagName , inSize , inData ) ; return SetControlData( inControl , inPart , inTagName , inSize , inData ) ;
} }
else else
#endif
#if !TARGET_CARBON
return AGASetControlData( inControl , inPart , inTagName , inSize , inData ) ; return AGASetControlData( inControl , inPart , inTagName , inSize , inData ) ;
#else
{
return noErr ;
}
#endif
} }
@@ -610,15 +924,22 @@ OSErr UMAGetControlData (ControlHandle inControl,
Ptr outBuffer, Ptr outBuffer,
Size * outActualSize) Size * outActualSize)
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return ::GetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ; return ::GetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
return AGAGetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ; return AGAGetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ;
} }
#else
{
return noErr ;
}
#endif
} }
@@ -627,14 +948,22 @@ OSErr UMAGetControlDataSize (ControlHandle inControl,
ResType inTagName, ResType inTagName,
Size * outMaxSize) Size * outMaxSize)
{ {
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
return GetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ; return GetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ;
} }
else else
#endif
#if !TARGET_CARBON
{ {
return AGAGetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ; return AGAGetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ;
} }
#else
{
return noErr ;
}
#endif
} }
@@ -711,11 +1040,70 @@ OSStatus UMACreateNewWindow( WindowClass windowClass , WindowAttributes attribu
case kMovableModalWindowClass : case kMovableModalWindowClass :
procID = kWindowMovableModalDialogProc; procID = kWindowMovableModalDialogProc;
break ; break ;
case kDocumentWindowClass : case kModalWindowClass :
procID = kWindowFullZoomGrowDocumentProc; procID = kWindowShadowDialogProc;
break ; break ;
case kFloatingWindowClass :
if ( attributes & kWindowSideTitlebarAttribute )
{
if( ( attributes & kWindowResizableAttribute ) &&
( attributes & kWindowFullZoomAttribute ) )
{
procID = kWindowFloatSideFullZoomGrowProc ;
}
else if( attributes & kWindowFullZoomAttribute )
{
procID = kWindowFloatSideFullZoomProc;
}
else if ( attributes & kWindowResizableAttribute )
{
procID = kWindowFloatSideGrowProc;
}
else
{
procID = kWindowFloatSideProc;
}
}
else
{
if( ( attributes & kWindowResizableAttribute ) &&
( attributes & kWindowFullZoomAttribute ) )
{
procID = kWindowFloatFullZoomGrowProc ;
}
else if( attributes & kWindowFullZoomAttribute )
{
procID = kWindowFloatFullZoomProc;
}
else if ( attributes & kWindowResizableAttribute )
{
procID = kWindowFloatGrowProc;
}
else
{
procID = kWindowFloatProc;
}
}
break ;
case kDocumentWindowClass :
default : default :
procID = kWindowMovableModalDialogProc; if( ( attributes & kWindowResizableAttribute ) &&
( attributes & kWindowFullZoomAttribute ) )
{
procID = kWindowFullZoomGrowDocumentProc;
}
else if( attributes & kWindowFullZoomAttribute )
{
procID = kWindowFullZoomDocumentProc;
}
else if ( attributes & kWindowResizableAttribute )
{
procID = kWindowGrowDocumentProc;
}
else
{
procID = kWindowDocumentProc;
}
break ; break ;
} }
} }
@@ -725,13 +1113,72 @@ OSStatus UMACreateNewWindow( WindowClass windowClass , WindowAttributes attribu
{ {
case kMovableModalWindowClass : case kMovableModalWindowClass :
procID = movableDBoxProc; procID = movableDBoxProc;
// procID += kMovableModalDialogVariantCode; break ;
case kModalWindowClass :
procID = altDBoxProc;
break ;
case kFloatingWindowClass :
if ( attributes & kWindowSideTitlebarAttribute )
{
if( ( attributes & kWindowResizableAttribute ) &&
( attributes & kWindowFullZoomAttribute ) )
{
procID = floatSideZoomGrowProc ;
}
else if( attributes & kWindowFullZoomAttribute )
{
procID = floatSideZoomProc;
}
else if ( attributes & kWindowResizableAttribute )
{
procID = floatSideGrowProc;
}
else
{
procID = floatSideProc;
}
}
else
{
if( ( attributes & kWindowResizableAttribute ) &&
( attributes & kWindowFullZoomAttribute ) )
{
procID = floatZoomGrowProc ;
}
else if( attributes & kWindowFullZoomAttribute )
{
procID = floatZoomProc;
}
else if ( attributes & kWindowResizableAttribute )
{
procID = floatGrowProc;
}
else
{
procID = floatProc;
}
}
break ; break ;
case kDocumentWindowClass : case kDocumentWindowClass :
procID = zoomDocProc;
break ;
default : default :
procID = documentProc; if( ( attributes & kWindowResizableAttribute ) &&
( attributes & kWindowFullZoomAttribute ) )
{
procID = zoomDocProc;
}
else if( attributes & kWindowFullZoomAttribute )
{
procID = zoomNoGrow;
}
else if ( attributes & kWindowResizableAttribute )
{
procID = documentProc;
}
else
{
procID = noGrowDocProc;
}
break ;
break ; break ;
} }
} }
@@ -853,6 +1300,32 @@ void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate )
// bool isHighlighted = IsWindowHighlited( inWindowRef ) ; // bool isHighlighted = IsWindowHighlited( inWindowRef ) ;
// if ( inActivate != isHightlited ) // if ( inActivate != isHightlited )
HiliteWindow( inWindowRef , inActivate ) ; HiliteWindow( inWindowRef , inActivate ) ;
ControlHandle control = NULL ;
UMAGetRootControl( inWindowRef , & control ) ;
if ( control )
{
if ( inActivate )
UMAActivateControl( control ) ;
else
UMADeactivateControl( control ) ;
}
} }
} }
OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState )
{
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() )
{
::DrawThemePlacard( inRect , inState ) ;
}
else
#endif
#if !TARGET_CARBON
{
}
#else
{
}
#endif
}

View File

@@ -18,6 +18,7 @@
#include "wx/setup.h" #include "wx/setup.h"
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/app.h" #include "wx/app.h"
#include "wx/mac/uma.h"
#include <ctype.h> #include <ctype.h>
@@ -26,7 +27,13 @@
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
// Get full hostname (eg. DoDo.BSn-Germany.crg.de) // get full hostname (with domain name if possible)
bool wxGetFullHostName(wxChar *buf, int maxSize)
{
return wxGetHostName(buf, maxSize);
}
// Get hostname only (without domain name)
bool wxGetHostName(char *buf, int maxSize) bool wxGetHostName(char *buf, int maxSize)
{ {
// TODO // TODO
@@ -227,7 +234,10 @@ void wxEndBusyCursor()
if ( gMacStoredActiveCursor ) if ( gMacStoredActiveCursor )
::SetCursor( *gMacStoredActiveCursor ) ; ::SetCursor( *gMacStoredActiveCursor ) ;
else else
::SetCursor( &qd.arrow ) ; {
Cursor MacArrow ;
::SetCursor( GetQDGlobalsArrow( &MacArrow ) ) ;
}
gMacStoredActiveCursor = NULL ; gMacStoredActiveCursor = NULL ;
} }
} }
@@ -238,6 +248,25 @@ bool wxIsBusy()
return (wxBusyCursorCount > 0); return (wxBusyCursorCount > 0);
} }
wxString wxMacFindFolder( short vol,
OSType folderType,
Boolean createFolder)
{
short vRefNum ;
long dirID ;
wxString strDir ;
if ( FindFolder( vol, folderType, createFolder, &vRefNum, &dirID) == noErr)
{
FSSpec file ;
if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
{
strDir = wxMacFSSpec2UnixFilename( &file ) + "/" ;
}
}
return strDir ;
}
char *wxGetUserHome (const wxString& user) char *wxGetUserHome (const wxString& user)
{ {
// TODO // TODO
@@ -271,23 +300,32 @@ bool wxColourDisplay()
// Returns depth of screen // Returns depth of screen
int wxDisplayDepth() int wxDisplayDepth()
{ {
// get max pixel depth Rect globRect ;
CGrafPtr port ; SetRect(&globRect, -32760, -32760, 32760, 32760);
GetCWMgrPort( &port ) ; GDHandle theMaxDevice;
GDHandle maxDevice ;
maxDevice = GetMaxDevice( &port->portRect ) ; int theDepth = 8;
if ( maxDevice ) theMaxDevice = GetMaxDevice(&globRect);
return (**((**maxDevice).gdPMap)).pixelSize ; if (theMaxDevice != nil)
else theDepth = (**(**theMaxDevice).gdPMap).pixelSize;
return 8 ;
return theDepth ;
} }
// Get size of display // Get size of display
void wxDisplaySize(int *width, int *height) void wxDisplaySize(int *width, int *height)
{ {
*width = qd.screenBits.bounds.right - qd.screenBits.bounds.left ; BitMap screenBits;
*height = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top ; GetQDGlobalsScreenBits( &screenBits );
*height -= LMGetMBarHeight() ;
*width = screenBits.bounds.right - screenBits.bounds.left ;
*height = screenBits.bounds.bottom - screenBits.bounds.top ;
#if TARGET_CARBON
SInt16 mheight ;
GetThemeMenuBarHeight( &mheight ) ;
*height -= mheight ;
#else
*height -= LMGetMBarHeight() ;
#endif
} }

File diff suppressed because it is too large Load Diff

View File

@@ -15,8 +15,10 @@
#include "wx/checkbox.h" #include "wx/checkbox.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox) IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>

View File

@@ -23,7 +23,9 @@
// implementation // implementation
// ============================================================================ // ============================================================================
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox) IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// implementation of wxCheckListBox class // implementation of wxCheckListBox class

View File

@@ -17,7 +17,9 @@
#include "wx/choice.h" #include "wx/choice.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
#endif
bool wxChoice::Create(wxWindow *parent, wxWindowID id, bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
@@ -27,7 +29,6 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_noStrings = n;
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
@@ -41,11 +42,15 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
for ( int i = 0 ; i < n ; i++ ) for ( int i = 0 ; i < n ; i++ )
{ {
appendmenu( m_macPopUpMenuHandle , choices[i] ) ; Str255 label;
wxMenuItem::MacBuildMenuString( label , NULL , NULL , choices[i] ,false);
AppendMenu( m_macPopUpMenuHandle , label ) ;
m_strings.Add( choices[i] ) ;
} }
SetControlMinimum( m_macControl , 0 ) ; SetControlMinimum( m_macControl , 0 ) ;
SetControlMaximum( m_macControl , m_noStrings) ; SetControlMaximum( m_macControl , Number()) ;
SetControlValue( m_macControl , 1 ) ; if ( n > 0 )
SetControlValue( m_macControl , 1 ) ;
MacPostControlCreate() ; MacPostControlCreate() ;
@@ -54,27 +59,28 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
void wxChoice::Append(const wxString& item) void wxChoice::Append(const wxString& item)
{ {
appendmenu( m_macPopUpMenuHandle , item ) ; Str255 label;
m_noStrings ++; wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false);
SetControlMaximum( m_macControl , m_noStrings) ; AppendMenu( m_macPopUpMenuHandle , label ) ;
m_strings.Add( item ) ;
SetControlMaximum( m_macControl , Number()) ;
} }
void wxChoice::Delete(int n) void wxChoice::Delete(int n)
{ {
wxASSERT( n < m_noStrings ) ;
::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ; ::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ;
m_noStrings --; m_strings.Remove( n ) ;
SetControlMaximum( m_macControl , m_noStrings) ; SetControlMaximum( m_macControl , Number()) ;
} }
void wxChoice::Clear() void wxChoice::Clear()
{ {
for ( int i = 0 ; i < m_noStrings ; i++ ) for ( int i = 0 ; i < Number() ; i++ )
{ {
::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ; ::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ;
} }
m_noStrings = 0; m_strings.Clear() ;
SetControlMaximum( m_macControl , m_noStrings) ; SetControlMaximum( m_macControl , Number()) ;
} }
int wxChoice::GetSelection() const int wxChoice::GetSelection() const
@@ -99,7 +105,7 @@ void wxChoice::SetSelection(int n)
int wxChoice::FindString(const wxString& s) const int wxChoice::FindString(const wxString& s) const
{ {
for( int i = 0 ; i < m_noStrings ; i++ ) for( int i = 0 ; i < Number() ; i++ )
{ {
if ( GetString( i ) == s ) if ( GetString( i ) == s )
return i ; return i ;
@@ -109,10 +115,7 @@ int wxChoice::FindString(const wxString& s) const
wxString wxChoice::GetString(int n) const wxString wxChoice::GetString(int n) const
{ {
Str255 text ; return m_strings[n] ;
::GetMenuItemText( m_macPopUpMenuHandle , n+1 , text ) ;
p2cstr( text ) ;
return wxString( text );
} }
void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags) void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)

View File

@@ -21,48 +21,214 @@
#include "wx/metafile.h" #include "wx/metafile.h"
#include "wx/clipbrd.h" #include "wx/clipbrd.h"
#define wxUSE_DATAOBJ 1
#include <string.h> #include <string.h>
// open/close // open/close
bool clipboard_opened = false ;
bool wxOpenClipboard() bool wxOpenClipboard()
{ {
clipboard_opened = true ;
return TRUE; return TRUE;
} }
bool wxCloseClipboard() bool wxCloseClipboard()
{ {
clipboard_opened = false ;
return TRUE; return TRUE;
} }
bool wxIsClipboardOpened() bool wxIsClipboardOpened()
{ {
return TRUE; return clipboard_opened;
} }
// get/set data
bool wxEmptyClipboard() bool wxEmptyClipboard()
{ {
ZeroScrap() ;
#if TARGET_CARBON
OSStatus err ;
err = ClearCurrentScrap( );
#else
OSErr err ;
err = ZeroScrap( );
#endif
if ( err )
{
wxLogSysError(_("Failed to empty the clipboard."));
return FALSE ;
}
return TRUE; return TRUE;
} }
bool wxSetClipboardData(wxDataFormat dataFormat,const void *data,int width , int height) // get/set data
{
return FALSE;
}
void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
{
return NULL;
}
// clipboard formats // clipboard formats
bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat) bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{ {
#if TARGET_CARBON
OSStatus err = noErr;
ScrapRef scrapRef;
err = GetCurrentScrap( &scrapRef );
if ( err != noTypeErr && err != memFullErr )
{
ScrapFlavorFlags flavorFlags;
Size byteCount;
if (( err = GetScrapFlavorFlags( scrapRef, dataFormat.GetFormatId(), &flavorFlags )) == noErr)
{
if (( err = GetScrapFlavorSize( scrapRef, dataFormat.GetFormatId(), &byteCount )) == noErr)
{
return TRUE ;
}
}
}
return FALSE;
#else
long offset ;
if ( GetScrap( NULL , dataFormat.GetFormatId() , &offset ) > 0 )
{
return TRUE ;
}
return FALSE; return FALSE;
#endif
}
bool wxSetClipboardData(wxDataFormat dataFormat,const void *data,int width , int height)
{
#if !TARGET_CARBON
OSErr err = noErr ;
#else
OSStatus err = noErr ;
#endif
switch (dataFormat.GetType())
{
case wxDF_BITMAP:
{
/*
wxBitmap *bitmap = (wxBitmap *)data;
HDC hdcMem = CreateCompatibleDC((HDC) NULL);
HDC hdcSrc = CreateCompatibleDC((HDC) NULL);
HBITMAP old = (HBITMAP)
::SelectObject(hdcSrc, (HBITMAP)bitmap->GetHBITMAP());
HBITMAP hBitmap = CreateCompatibleBitmap(hdcSrc,
bitmap->GetWidth(),
bitmap->GetHeight());
if (!hBitmap)
{
SelectObject(hdcSrc, old);
DeleteDC(hdcMem);
DeleteDC(hdcSrc);
return FALSE;
}
HBITMAP old1 = (HBITMAP) SelectObject(hdcMem, hBitmap);
BitBlt(hdcMem, 0, 0, bitmap->GetWidth(), bitmap->GetHeight(),
hdcSrc, 0, 0, SRCCOPY);
// Select new bitmap out of memory DC
SelectObject(hdcMem, old1);
// Set the data
handle = ::SetClipboardData(CF_BITMAP, hBitmap);
// Clean up
SelectObject(hdcSrc, old);
DeleteDC(hdcSrc);
DeleteDC(hdcMem);
*/
break;
}
case wxDF_DIB:
{
/*
#if wxUSE_IMAGE_LOADING_IN_MSW
wxBitmap *bitmap = (wxBitmap *)data;
HBITMAP hBitmap = (HBITMAP)bitmap->GetHBITMAP();
// NULL palette means to use the system one
HANDLE hDIB = wxBitmapToDIB(hBitmap, (HPALETTE)NULL);
handle = SetClipboardData(CF_DIB, hDIB);
#endif // wxUSE_IMAGE_LOADING_IN_MSW
*/
break;
}
#if wxUSE_METAFILE
case wxDF_METAFILE:
{
wxMetafile *wxMF = (wxMetafile *)data;
PicHandle pict = wxMF->GetHMETAFILE() ;
HLock( (Handle) pict ) ;
#if !TARGET_CARBON
err = PutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ;
#else
ScrapRef scrap;
err = GetCurrentScrap (&scrap);
if ( !err )
{
err = PutScrapFlavor (scrap, 'PICT', 0, GetHandleSize((Handle) pict), *pict);
}
#endif
HUnlock( (Handle) pict ) ;
break;
}
#endif
case wxDF_SYLK:
case wxDF_DIF:
case wxDF_TIFF:
case wxDF_PALETTE:
default:
{
wxLogError(_("Unsupported clipboard format."));
return FALSE;
}
case wxDF_OEMTEXT:
dataFormat = wxDF_TEXT;
// fall through
case wxDF_TEXT:
{
wxString mac ;
if ( wxApp::s_macDefaultEncodingIsPC )
{
mac = wxMacMakeMacStringFromPC((char *)data) ;
}
else
{
mac = (char *)data ;
}
#if !TARGET_CARBON
err = PutScrap( mac.Length() , 'TEXT' , mac.c_str() ) ;
#else
ScrapRef scrap;
err = GetCurrentScrap (&scrap);
if ( !err )
{
err = PutScrapFlavor (scrap, 'TEXT', 0, mac.Length(), mac.c_str());
}
#endif
break;
}
}
if ( err )
{
wxLogSysError(_("Failed to set clipboard data."));
return FALSE;
}
return TRUE;
} }
wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat) wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
@@ -80,11 +246,17 @@ bool wxGetClipboardFormatName(wxDataFormat dataFormat, wxChar *formatName, int m
return FALSE; return FALSE;
} }
void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
{
return NULL;
}
/* /*
* Generalized clipboard implementation by Matthew Flatt * Generalized clipboard implementation by Matthew Flatt
*/ */
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxClipboardBase)
wxClipboard::wxClipboard() wxClipboard::wxClipboard()
{ {
@@ -143,9 +315,9 @@ bool wxClipboard::AddData( wxDataObject *data )
#if wxUSE_DATAOBJ #if wxUSE_DATAOBJ
wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") ); wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
wxDataFormat format = data->GetFormat(); wxDataFormat format = data->GetPreferredFormat();
switch ( format ) switch ( format.GetType() )
{ {
case wxDF_TEXT: case wxDF_TEXT:
case wxDF_OEMTEXT: case wxDF_OEMTEXT:
@@ -160,10 +332,10 @@ bool wxClipboard::AddData( wxDataObject *data )
{ {
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data; wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
wxBitmap bitmap(bitmapDataObject->GetBitmap()); wxBitmap bitmap(bitmapDataObject->GetBitmap());
return wxSetClipboardData(data->GetFormat(), &bitmap); return wxSetClipboardData(format, &bitmap);
} }
#if wxUSE_METAFILE #if 0 // wxUSE_METAFILE
case wxDF_METAFILE: case wxDF_METAFILE:
{ {
wxMetafileDataObject* metaFileDataObject = wxMetafileDataObject* metaFileDataObject =
@@ -176,11 +348,12 @@ bool wxClipboard::AddData( wxDataObject *data )
#endif // wxUSE_METAFILE #endif // wxUSE_METAFILE
default: default:
return wxSetClipboardData(data); // return wxSetClipboardData(data);
break ;
} }
#else // !wxUSE_DATAOBJ #else // !wxUSE_DATAOBJ
return FALSE;
#endif #endif
return FALSE;
} }
void wxClipboard::Close() void wxClipboard::Close()
@@ -188,7 +361,7 @@ void wxClipboard::Close()
wxCloseClipboard(); wxCloseClipboard();
} }
bool wxClipboard::IsSupported( wxDataFormat format ) bool wxClipboard::IsSupported( const wxDataFormat &format )
{ {
return wxIsClipboardFormatAvailable(format); return wxIsClipboardFormatAvailable(format);
} }
@@ -198,7 +371,7 @@ bool wxClipboard::GetData( wxDataObject& data )
#if wxUSE_DATAOBJ #if wxUSE_DATAOBJ
wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") ); wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
wxDataFormat format = data.GetFormat(); wxDataFormat format = data.GetPreferredFormat();
switch ( format ) switch ( format )
{ {
case wxDF_TEXT: case wxDF_TEXT:
@@ -219,7 +392,7 @@ bool wxClipboard::GetData( wxDataObject& data )
case wxDF_DIB: case wxDF_DIB:
{ {
wxBitmapDataObject& bitmapDataObject = (wxBitmapDataObject &)data; wxBitmapDataObject& bitmapDataObject = (wxBitmapDataObject &)data;
wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(data->GetFormat()); wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(format );
if ( !bitmap ) if ( !bitmap )
return FALSE; return FALSE;
@@ -228,7 +401,7 @@ bool wxClipboard::GetData( wxDataObject& data )
return TRUE; return TRUE;
} }
#if wxUSE_METAFILE #if 0 // wxUSE_METAFILE
case wxDF_METAFILE: case wxDF_METAFILE:
{ {
wxMetafileDataObject& metaFileDataObject = (wxMetafileDataObject &)data; wxMetafileDataObject& metaFileDataObject = (wxMetafileDataObject &)data;

View File

@@ -16,7 +16,9 @@
#include "wx/mac/colordlg.h" #include "wx/mac/colordlg.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog) IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
#endif
/* /*
* wxColourDialog * wxColourDialog

View File

@@ -16,7 +16,9 @@
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#include "wx/colour.h" #include "wx/colour.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
#endif
// Colour // Colour

View File

@@ -16,7 +16,9 @@
#include "wx/combobox.h" #include "wx/combobox.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
#endif
// right now we don't support editable comboboxes // right now we don't support editable comboboxes
@@ -44,7 +46,9 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
for ( int i = 0 ; i < n ; i++ ) for ( int i = 0 ; i < n ; i++ )
{ {
appendmenu( m_macPopUpMenuHandle , choices[i] ) ; Str255 label;
wxMenuItem::MacBuildMenuString( label , NULL , NULL , choices[i] ,false);
AppendMenu( m_macPopUpMenuHandle , label ) ;
} }
SetControlMinimum( m_macControl , 0 ) ; SetControlMinimum( m_macControl , 0 ) ;
SetControlMaximum( m_macControl , m_noStrings) ; SetControlMaximum( m_macControl , m_noStrings) ;
@@ -125,7 +129,9 @@ void wxComboBox::SetSelection(long from, long to)
void wxComboBox::Append(const wxString& item) void wxComboBox::Append(const wxString& item)
{ {
appendmenu( m_macPopUpMenuHandle , item ) ; Str255 label;
wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false);
AppendMenu( m_macPopUpMenuHandle , label ) ;
m_noStrings ++; m_noStrings ++;
SetControlMaximum( m_macControl , m_noStrings) ; SetControlMaximum( m_macControl , m_noStrings) ;
} }

View File

@@ -16,15 +16,18 @@
#include "wx/control.h" #include "wx/control.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/tabctrl.h" #include "wx/tabctrl.h"
#include "wx/radiobox.h"
#include "wx/spinbutt.h" #include "wx/spinbutt.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow) IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
BEGIN_EVENT_TABLE(wxControl, wxControlBase) BEGIN_EVENT_TABLE(wxControl, wxWindow)
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent ) EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
EVT_CHAR( wxControl::OnKeyDown ) EVT_CHAR( wxControl::OnKeyDown )
EVT_PAINT( wxControl::OnPaint ) EVT_PAINT( wxControl::OnPaint )
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
@@ -32,6 +35,7 @@ END_EVENT_TABLE()
ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ; ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ;
pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) ;
pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode )
{ {
if ( partCode != 0) if ( partCode != 0)
@@ -46,9 +50,9 @@ pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCod
wxControl::wxControl() wxControl::wxControl()
{ {
m_macControl = NULL ; m_macControl = NULL ;
m_macHorizontalBorder = 0 ; // additional pixels around the real control m_macHorizontalBorder = 0 ; // additional pixels around the real control
m_macVerticalBorder = 0 ; m_macVerticalBorder = 0 ;
m_backgroundColour = *wxWHITE; m_backgroundColour = *wxWHITE;
m_foregroundColour = *wxBLACK; m_foregroundColour = *wxBLACK;
#if WXWIN_COMPATIBILITY #if WXWIN_COMPATIBILITY
@@ -61,6 +65,24 @@ wxControl::wxControl()
} }
} }
bool wxControl::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name)
{
m_macControl = NULL ;
m_macHorizontalBorder = 0 ; // additional pixels around the real control
m_macVerticalBorder = 0 ;
bool rval = wxWindow::Create(parent, id, pos, size, style, name);
if (rval) {
#if wxUSE_VALIDATORS
SetValidator(validator);
#endif
}
return rval;
}
wxControl::~wxControl() wxControl::~wxControl()
{ {
m_isBeingDeleted = TRUE; m_isBeingDeleted = TRUE;
@@ -79,21 +101,6 @@ wxControl::~wxControl()
} }
} }
bool wxControl::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name)
{
bool rval = wxWindow::Create(parent, id, pos, size, style, name);
if (rval) {
#if wxUSE_VALIDATORS
SetValidator(validator);
#endif
}
return rval;
}
void wxControl::SetLabel(const wxString& title) void wxControl::SetLabel(const wxString& title)
{ {
m_label = title ; m_label = title ;
@@ -222,7 +229,7 @@ void wxControl::MacPostControlCreate()
{ {
// no font // no font
} }
else if ( IsKindOf( CLASSINFO( wxStaticBox ) ) ) else if ( IsKindOf( CLASSINFO( wxStaticBox ) ) || IsKindOf( CLASSINFO( wxRadioBox ) ) || IsKindOf( CLASSINFO( wxButton ) ) )
{ {
ControlFontStyleRec controlstyle ; ControlFontStyleRec controlstyle ;
controlstyle.flags = kControlUseFontMask ; controlstyle.flags = kControlUseFontMask ;
@@ -275,14 +282,16 @@ void wxControl::MacAdjustControlRect()
{ {
if ( IsKindOf( CLASSINFO( wxButton ) ) ) if ( IsKindOf( CLASSINFO( wxButton ) ) )
{ {
m_width = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder; m_width = m_label.Length() * 8 + 12 ;
} }
else if ( IsKindOf( CLASSINFO( wxStaticText ) ) ) else if ( IsKindOf( CLASSINFO( wxStaticText ) ) )
{ {
m_width = m_label.Length() * 8 ; m_width = m_label.Length() * 8 ;
} }
else else
m_width = bestsize.right - bestsize.left + 2 * m_macHorizontalBorder; m_width = bestsize.right - bestsize.left ;
m_width += 2 * m_macHorizontalBorder ;
} }
if ( m_height == -1 ) if ( m_height == -1 )
{ {
@@ -296,7 +305,7 @@ void wxControl::MacAdjustControlRect()
wxMacDrawingHelper helper ( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ; wxMacDrawingHelper helper ( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ;
if ( helper.Ok() ) if ( helper.Ok() )
{ {
UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ; UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
} }
} }
} }
@@ -312,8 +321,10 @@ void wxControl::MacSuperChangedPosition()
{ {
if ( m_macControl ) if ( m_macControl )
{ {
int former_mac_x = (**m_macControl).contrlRect.left ; Rect contrlRect ;
int former_mac_y = (**m_macControl).contrlRect.top ; GetControlBounds( m_macControl , &contrlRect ) ;
int former_mac_x = contrlRect.left ;
int former_mac_y = contrlRect.top ;
int mac_x = m_x ; int mac_x = m_x ;
int mac_y = m_y ; int mac_y = m_y ;
GetParent()->MacClientToRootWindow( & mac_x , & mac_y ) ; GetParent()->MacClientToRootWindow( & mac_x , & mac_y ) ;
@@ -327,12 +338,12 @@ void wxControl::MacSuperChangedPosition()
{ {
{ {
Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ; Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ;
InvalRect( &inval ) ; InvalWindowRect( rootwindow , &inval ) ;
} }
UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ; UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ;
{ {
Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
InvalRect( &inval ) ; InvalWindowRect( rootwindow , &inval ) ;
} }
} }
if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) ) if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
@@ -378,7 +389,7 @@ void wxControl::MacSuperEnabled( bool enabled )
} }
} }
wxWindow::MacSuperEnabled( enabled ) ; wxWindow::MacSuperEnabled( enabled ) ;
*/ */
} }
void wxControl::MacSuperShown( bool show ) void wxControl::MacSuperShown( bool show )
@@ -418,8 +429,10 @@ void wxControl::DoSetSize(int x, int y,
int former_w = m_width ; int former_w = m_width ;
int former_h = m_height ; int former_h = m_height ;
int former_mac_x = (**m_macControl).contrlRect.left ; Rect contrlRect ;
int former_mac_y = (**m_macControl).contrlRect.top ; GetControlBounds( m_macControl , &contrlRect ) ;
int former_mac_x = contrlRect.left ;
int former_mac_y = contrlRect.top ;
int currentX, currentY; int currentX, currentY;
GetPosition(&currentX, &currentY); GetPosition(&currentX, &currentY);
@@ -430,9 +443,9 @@ void wxControl::DoSetSize(int x, int y,
int actualHeight = height; int actualHeight = height;
int actualX = x; int actualX = x;
int actualY = y; int actualY = y;
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if (x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
actualX = currentX; actualX = currentX;
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if (y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
actualY = currentY; actualY = currentY;
if (width == -1) if (width == -1)
actualWidth = currentW ; actualWidth = currentW ;
@@ -443,7 +456,8 @@ void wxControl::DoSetSize(int x, int y,
return ; return ;
AdjustForParentClientOrigin(actualX, actualY, sizeFlags); AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
wxMacDrawingHelper focus( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ; WindowRef macrootwindow = GetMacRootWindow() ;
wxMacDrawingHelper focus( wxFindWinFromMacWindow( macrootwindow ) ) ;
int mac_x = actualX ; int mac_x = actualX ;
int mac_y = actualY ; int mac_y = actualY ;
@@ -453,12 +467,12 @@ void wxControl::DoSetSize(int x, int y,
{ {
{ {
Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ; Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ;
InvalRect( &inval ) ; InvalWindowRect( macrootwindow, &inval ) ;
} }
UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ; UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ;
{ {
Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
InvalRect( &inval ) ; InvalWindowRect(macrootwindow, &inval ) ;
} }
} }
@@ -477,15 +491,15 @@ void wxControl::DoSetSize(int x, int y,
{ {
{ {
Rect inval = { mac_y , mac_x , mac_y + former_h , mac_x + former_w } ; Rect inval = { mac_y , mac_x , mac_y + former_h , mac_x + former_w } ;
InvalRect( &inval ) ; InvalWindowRect( macrootwindow, &inval ) ;
} }
m_width = actualWidth ; m_width = actualWidth ;
m_height = actualHeight ; m_height = actualHeight ;
UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ; UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
{ {
Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
InvalRect( &inval ) ; InvalWindowRect( macrootwindow , &inval ) ;
} }
MacRepositionScrollBars() ; MacRepositionScrollBars() ;
@@ -555,6 +569,47 @@ void wxControl::Refresh(bool eraseBack, const wxRect *rect)
} }
} }
void wxControl::MacRedrawControl()
{
if ( m_macControl )
{
WindowRef window = GetMacRootWindow() ;
if ( window )
{
wxWindow* win = wxFindWinFromMacWindow( window ) ;
if ( win )
{
wxMacDrawingHelper help( win ) ;
// the mac control manager always assumes to have the origin at 0,0
SetOrigin( 0 , 0 ) ;
bool hasTabBehind = false ;
wxWindow* parent = GetParent() ;
while ( parent )
{
if( parent->MacGetWindowData() )
{
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
break ;
}
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
{
if ( ((wxControl*)parent)->m_macControl )
SetUpControlBackground( ((wxControl*)parent)->m_macControl , -1 , true ) ;
break ;
}
parent = parent->GetParent() ;
}
UMADrawControl( m_macControl ) ;
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
}
}
}
}
void wxControl::OnPaint(wxPaintEvent& event) void wxControl::OnPaint(wxPaintEvent& event)
{ {
if ( m_macControl ) if ( m_macControl )
@@ -566,6 +621,7 @@ void wxControl::OnPaint(wxPaintEvent& event)
if ( win ) if ( win )
{ {
wxMacDrawingHelper help( win ) ; wxMacDrawingHelper help( win ) ;
// the mac control manager always assumes to have the origin at 0,0
SetOrigin( 0 , 0 ) ; SetOrigin( 0 , 0 ) ;
bool hasTabBehind = false ; bool hasTabBehind = false ;
@@ -629,7 +685,7 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
return ; return ;
} }
if (event.GetEventType() == wxEVT_LEFT_DOWN ) if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
{ {
int x = event.m_x ; int x = event.m_x ;

View File

@@ -16,17 +16,33 @@
#include "wx/cursor.h" #include "wx/cursor.h"
#include "wx/icon.h" #include "wx/icon.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
#endif
const short kwxCursorHandId = 9 ; const short kwxCursorHandId = 9 ;
const short kwxCursorSizeWEId = 10 ; const short kwxCursorSizeWEId = 10 ;
const short kwxCursorSizeNSId = 11 ; const short kwxCursorSizeNSId = 11 ;
#if !TARGET_CARBON
Cursor* MacArrowCursorPtr = &qd.arrow ; Cursor* MacArrowCursorPtr = &qd.arrow ;
CursHandle MacArrowCursor = &MacArrowCursorPtr ; CursHandle MacArrowCursor = &MacArrowCursorPtr ;
#else
bool MacArrowInstalled = false ;
Cursor MacArrow ;
Cursor* MacArrowCursorPtr = &MacArrow ;
CursHandle MacArrowCursor = &MacArrowCursorPtr ;
#endif
CursHandle gMacCurrentCursor = NULL ; CursHandle gMacCurrentCursor = NULL ;
wxCursorRefData::wxCursorRefData() wxCursorRefData::wxCursorRefData()
{ {
#if TARGET_CARBON
if ( !MacArrowInstalled )
{
MacArrowCursorPtr = GetQDGlobalsArrow( &MacArrow ) ;
MacArrowInstalled = true ;
}
#endif
m_width = 32; m_width = 32;
m_height = 32; m_height = 32;
m_hCursor = NULL ; m_hCursor = NULL ;
@@ -34,8 +50,8 @@ wxCursorRefData::wxCursorRefData()
wxCursorRefData::~wxCursorRefData() wxCursorRefData::~wxCursorRefData()
{ {
if ( m_hCursor && ( m_hCursor != MacArrowCursor ) ) // if ( m_hCursor && ( m_hCursor != MacArrowCursor ) )
::DisposeHandle( (Handle) m_hCursor ) ; // ::ReleaseResource( (Handle) m_hCursor ) ;
} }
// Cursors // Cursors

View File

@@ -102,8 +102,8 @@ const wxChar *wxFrameNameStr = wxT("frame");
const wxChar *wxGaugeNameStr = wxT("gauge"); const wxChar *wxGaugeNameStr = wxT("gauge");
const wxChar *wxStaticBoxNameStr = wxT("groupBox"); const wxChar *wxStaticBoxNameStr = wxT("groupBox");
const wxChar *wxListBoxNameStr = wxT("listBox"); const wxChar *wxListBoxNameStr = wxT("listBox");
const wxChar *wxStaticTextNameStr = wxT("message"); const wxChar *wxStaticTextNameStr = wxT("statictext");
const wxChar *wxStaticBitmapNameStr = wxT("message"); const wxChar *wxStaticBitmapNameStr = wxT("staticbitmap");
const wxChar *wxMultiTextNameStr = wxT("multitext"); const wxChar *wxMultiTextNameStr = wxT("multitext");
const wxChar *wxPanelNameStr = wxT("panel"); const wxChar *wxPanelNameStr = wxT("panel");
const wxChar *wxRadioBoxNameStr = wxT("radioBox"); const wxChar *wxRadioBoxNameStr = wxT("radioBox");
@@ -134,5 +134,17 @@ const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
const wxChar *wxFloatToStringStr = wxT("%.2f"); const wxChar *wxFloatToStringStr = wxT("%.2f");
const wxChar *wxDoubleToStringStr = wxT("%.2f"); const wxChar *wxDoubleToStringStr = wxT("%.2f");
#if wxUSE_SHARED_LIBRARY
///// Event tables (also must be in one, statically-linked file for shared libraries)
// This is the base, wxEvtHandler 'bootstrap' code which is expanded manually here
const wxEventTable *wxEvtHandler::GetEventTable() const { return &wxEvtHandler::sm_eventTable; }
const wxEventTable wxEvtHandler::sm_eventTable =
{ NULL, &wxEvtHandler::sm_eventTableEntries[0] };
const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] = { { 0, 0, 0, NULL } };
#endif
const wxSize wxDefaultSize(-1, -1); const wxSize wxDefaultSize(-1, -1);
const wxPoint wxDefaultPosition(-1, -1); const wxPoint wxDefaultPosition(-1, -1);

View File

@@ -44,56 +44,40 @@
wxDataFormat::wxDataFormat() wxDataFormat::wxDataFormat()
{ {
m_vType = wxDF_INVALID; m_type = wxDF_INVALID;
m_vFormat = 0; m_format = 0;
} }
wxDataFormat::wxDataFormat( wxDataFormat::wxDataFormat( wxDataFormatId vType )
wxDataFormatId vType
)
{ {
PrepareFormats();
SetType(vType); SetType(vType);
} }
wxDataFormat::wxDataFormat( wxDataFormat::wxDataFormat( const wxChar* zId)
const wxChar* zId
)
{ {
PrepareFormats();
SetId(zId); SetId(zId);
} }
wxDataFormat::wxDataFormat( wxDataFormat::wxDataFormat( const wxString& rId)
const wxString& rId
)
{ {
PrepareFormats();
SetId(rId); SetId(rId);
} }
wxDataFormat::wxDataFormat( wxDataFormat::wxDataFormat( NativeFormat vFormat)
NativeFormat vFormat
)
{ {
PrepareFormats();
SetId(vFormat); SetId(vFormat);
} }
void wxDataFormat::SetType( void wxDataFormat::SetType( wxDataFormatId Type )
wxDataFormatId vType
)
{ {
m_vType = vType; m_type = Type;
if (m_vType == wxDF_TEXT) if (m_type == wxDF_TEXT)
m_vFormat = 0; m_format = 'TEXT';
else else if (m_type == wxDF_BITMAP || m_type == wxDF_METAFILE )
if (m_vType == wxDF_BITMAP) m_format = 'PICT';
m_vFormat = 0; else if (m_type == wxDF_FILENAME)
else m_format = 'SPEC';
if (m_vType == wxDF_FILENAME)
m_vFormat = 0;
else else
{ {
wxFAIL_MSG( wxT("invalid dataformat") ); wxFAIL_MSG( wxT("invalid dataformat") );
@@ -102,56 +86,37 @@ void wxDataFormat::SetType(
wxDataFormatId wxDataFormat::GetType() const wxDataFormatId wxDataFormat::GetType() const
{ {
return m_vType; return m_type;
} }
wxString wxDataFormat::GetId() const wxString wxDataFormat::GetId() const
{ {
wxString sRet(""); // TODO: gdk_atom_name( m_format ) ); wxString sRet(""); // TODO: to name of ( m_format ) );
return sRet; return sRet;
} }
void wxDataFormat::SetId( void wxDataFormat::SetId( NativeFormat format )
NativeFormat vFormat
)
{ {
m_vFormat = vFormat; m_format = format;
// TODO:
/* if (m_format == 'TEXT')
if (m_format == g_textAtom)
m_type = wxDF_TEXT; m_type = wxDF_TEXT;
else else
if (m_format == g_pngAtom) if (m_format == 'PICT')
m_type = wxDF_BITMAP; m_type = wxDF_BITMAP;
else else
if (m_format == g_fileAtom) if (m_format == 'SPEC')
m_type = wxDF_FILENAME; m_type = wxDF_FILENAME;
else else
m_type = wxDF_PRIVATE; m_type = wxDF_PRIVATE;
*/
} }
void wxDataFormat::SetId( void wxDataFormat::SetId( const wxChar* zId )
const wxChar* zId
)
{ {
wxString tmp(zId); wxString tmp(zId);
m_vType = wxDF_PRIVATE; m_type = wxDF_PRIVATE;
m_vFormat = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); m_format = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE );
}
void wxDataFormat::PrepareFormats()
{
// TODO:
/*
if (!g_textAtom)
g_textAtom = gdk_atom_intern( "STRING", FALSE );
if (!g_pngAtom)
g_pngAtom = gdk_atom_intern( "image/png", FALSE );
if (!g_fileAtom)
g_fileAtom = gdk_atom_intern( "file:ALL", FALSE );
*/
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------

View File

@@ -14,8 +14,11 @@
#endif #endif
#include "wx/dc.h" #include "wx/dc.h"
#include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// constants // constants
@@ -34,7 +37,7 @@ long wxDC::m_macCurrentPortId = 1 ;
// wxDC // wxDC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
wxDC::wxDC(void) wxDC::wxDC()
{ {
m_ok = FALSE; m_ok = FALSE;
m_optimize = FALSE; m_optimize = FALSE;
@@ -42,8 +45,8 @@ wxDC::wxDC(void)
m_colour = TRUE; m_colour = TRUE;
m_clipping = FALSE; m_clipping = FALSE;
m_mm_to_pix_x = 1.0; m_mm_to_pix_x = mm2pt;
m_mm_to_pix_y = 1.0; m_mm_to_pix_y = mm2pt;
m_logicalOriginX = 0; m_logicalOriginX = 0;
m_logicalOriginY = 0; m_logicalOriginY = 0;
@@ -102,20 +105,32 @@ wxDC::wxDC(void)
wxDC::~wxDC(void) wxDC::~wxDC(void)
{ {
if ( !m_macPortHelper.IsCleared() )
{
GrafPtr port ;
GetPort( &port ) ;
SetPort( m_macPortHelper.GetCurrentPort() ) ;
SetOrigin( 0 , 0 ) ;
SetPort( port ) ;
}
/*
if ( m_macPort ) if ( m_macPort )
{ {
::SetPort( m_macPort ) ;
::SetOrigin( 0 , 0 ) ; ::SetOrigin( 0 , 0 ) ;
::ClipRect( &m_macPort->portRect ) ; ::ClipRect( &m_macPort->portRect ) ;
::PenNormal() ; ::PenNormal() ;
::SetPort( m_macOrigPort ) ; ::SetPort( m_macOrigPort ) ;
} }
*/
++m_macCurrentPortId ; ++m_macCurrentPortId ;
}; };
void wxDC::MacSetupPort() const void wxDC::MacSetupPort() const
{ {
AGAPortHelper* help = &m_macPortHelper ;
help->Setup( m_macPort ) ;
m_macPortId = ++m_macCurrentPortId ; m_macPortId = ++m_macCurrentPortId ;
::SetPort(m_macPort);
::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v); ::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v);
::ClipRect(&m_macClipRect); ::ClipRect(&m_macClipRect);
@@ -124,8 +139,10 @@ void wxDC::MacSetupPort() const
m_macPenInstalled = false ; m_macPenInstalled = false ;
} }
void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask ) void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
{ {
float scale = 1.0 ;
if (!Ok()) if (!Ok())
return; return;
MacVerifySetup() ; MacVerifySetup() ;
@@ -140,7 +157,7 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask )
{ {
if ( bmap->m_bitmapType == kMacBitmapTypePict ) if ( bmap->m_bitmapType == kMacBitmapTypePict )
{ {
Rect bitmaprect = { 0 , 0 , bmap->m_height , bmap->m_width } ; Rect bitmaprect = { 0 , 0 , bmap->m_height * scale , bmap->m_width * scale} ;
::OffsetRect( &bitmaprect , xx1 , yy1 ) ; ::OffsetRect( &bitmaprect , xx1 , yy1 ) ;
::DrawPicture( bmap->m_hPict , &bitmaprect ) ; ::DrawPicture( bmap->m_hPict , &bitmaprect ) ;
} }
@@ -165,20 +182,21 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask )
source.bottom = bmap->m_height ; source.bottom = bmap->m_height ;
dest.top = YLOG2DEV(y) ; dest.top = YLOG2DEV(y) ;
dest.left = XLOG2DEV(x) ; dest.left = XLOG2DEV(x) ;
dest.bottom = YLOG2DEV(y + bmap->m_height ) ; dest.bottom = YLOG2DEV(y + bmap->m_height * scale) ;
dest.right = XLOG2DEV(x + bmap->m_width ) ; dest.right = XLOG2DEV(x + bmap->m_width * scale ) ;
if ( useMask && bmp.GetMask() ) if ( useMask && bmp.GetMask() )
{ {
if ( LockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ) if ( LockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) )
{ {
CopyMask( &GrafPtr( bmapworld )->portBits , &GrafPtr( bmp.GetMask()->GetMaskBitmap( ) )->portBits , &GrafPtr( m_macPort )->portBits , CopyMask( GetPortBitMapForCopyBits( bmapworld ) , GetPortBitMapForCopyBits( bmp.GetMask()->GetMaskBitmap( ) ) ,
GetPortBitMapForCopyBits( m_macPort ) ,
&source, &source , &dest ) ; &source, &source , &dest ) ;
UnlockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ; UnlockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ;
} }
} }
else else
CopyBits( &GrafPtr( bmapworld )->portBits , &GrafPtr( m_macPort )->portBits , CopyBits( GetPortBitMapForCopyBits( bmapworld ) , GetPortBitMapForCopyBits( m_macPort ),
&source, &dest, srcCopy, NULL ) ; &source, &dest, srcCopy, NULL ) ;
UnlockPixels( bmappixels ) ; UnlockPixels( bmappixels ) ;
@@ -192,7 +210,7 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask )
} }
} }
void wxDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask ) void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -213,69 +231,9 @@ void wxDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask )
} }
}; };
void wxDC::DrawPoint( wxPoint& point ) void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{ {
DrawPoint( point.x, point.y ); MacVerifySetup() ;
};
void wxDC::DrawPolygon( wxList *list, long xoffset, long yoffset, int fillStyle )
{
int n = list->Number();
wxPoint *points = new wxPoint[n];
int i = 0;
for( wxNode *node = list->First(); node; node = node->Next() )
{
wxPoint *point = (wxPoint *)node->Data();
points[i].x = point->x;
points[i++].y = point->y;
};
DrawPolygon( n, points, xoffset, yoffset, fillStyle );
delete[] points;
};
void wxDC::DrawLines( wxList *list, long xoffset, long yoffset )
{
int n = list->Number();
wxPoint *points = new wxPoint[n];
int i = 0;
for( wxNode *node = list->First(); node; node = node->Next() )
{
wxPoint *point = (wxPoint *)node->Data();
points[i].x = point->x;
points[i++].y = point->y;
};
DrawLines( n, points, xoffset, yoffset );
delete []points;
};
void wxDC::DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 )
{
wxList list;
list.Append( (wxObject*)new wxPoint(x1, y1) );
list.Append( (wxObject*)new wxPoint(x2, y2) );
list.Append( (wxObject*)new wxPoint(x3, y3) );
DrawSpline(&list);
wxNode *node = list.First();
while (node)
{
wxPoint *p = (wxPoint*)node->Data();
delete p;
node = node->Next();
};
};
void wxDC::DrawSpline( int n, wxPoint points[] )
{
wxList list;
for (int i = 0; i < n; i++) list.Append( (wxObject*)&points[i] );
DrawSpline( &list );
};
void wxDC::SetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
MacVerifySetup() ;
if( m_clipping ) if( m_clipping )
{ {
m_clipX1 = wxMax( m_clipX1 , x ) ; m_clipX1 = wxMax( m_clipX1 , x ) ;
@@ -300,13 +258,24 @@ void wxDC::SetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord heigh
Rect clip = { y1 , x1 , y2 , x2 } ; Rect clip = { y1 , x1 , y2 , x2 } ;
::ClipRect( &clip ) ; ::ClipRect( &clip ) ;
}; };
void wxDC::SetClippingRegion(const wxRect& rect) void wxDC::DoSetClippingRegionAsRegion( const wxRegion &region )
{ {
SetClippingRegion(rect.x, rect.y, rect.width, rect.height); wxCHECK_RET( Ok(), wxT("invalid window dc") );
MacVerifySetup() ;
if (region.Empty())
{
DestroyClippingRegion();
return;
}
wxCoord xx, yy, ww, hh;
region.GetBox( xx, yy, ww, hh );
wxDC::DoSetClippingRegion( xx, yy, ww, hh );
} }
void wxDC::DestroyClippingRegion(void) void wxDC::DestroyClippingRegion(void)
@@ -317,47 +286,13 @@ void wxDC::DestroyClippingRegion(void)
::ClipRect(&m_macClipRect); ::ClipRect(&m_macClipRect);
}; };
void wxDC::GetClippingBox( wxCoord *x, wxCoord *y, wxCoord *width, wxCoord *height ) const void wxDC::DoGetSize( int* width, int* height ) const
{
if (m_clipping)
{
if (x) *x = m_clipX1;
if (y) *y = m_clipY1;
if (width) *width = (m_clipX2 - m_clipX1);
if (height) *height = (m_clipY2 - m_clipY1);
}
else
*x = *y = *width = *height = 0;
};
void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const
{
if (m_clipping)
{
if (x) *x = m_clipX1;
if (y) *y = m_clipY1;
if (width) *width = (m_clipX2 - m_clipX1);
if (height) *height = (m_clipY2 - m_clipY1);
}
else
*x = *y = *width = *height = 0;
};
void wxDC::GetClippingBox(wxRect& rect) const
{
// Necessary to use intermediate variables for 16-bit compilation
wxCoord x, y, w, h;
GetClippingBox(&x, &y, &w, &h);
rect.x = x; rect.y = y; rect.width = w; rect.height = h;
}
void wxDC::GetSize( int* width, int* height ) const
{ {
*width = m_maxX-m_minX; *width = m_maxX-m_minX;
*height = m_maxY-m_minY; *height = m_maxY-m_minY;
}; };
void wxDC::GetSizeMM( long* width, long* height ) const void wxDC::DoGetSizeMM( int* width, int* height ) const
{ {
int w = 0; int w = 0;
int h = 0; int h = 0;
@@ -416,12 +351,6 @@ void wxDC::SetUserScale( double x, double y )
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
void wxDC::GetUserScale( double *x, double *y )
{
if (x) *x = m_userScaleX;
if (y) *y = m_userScaleY;
};
void wxDC::SetLogicalScale( double x, double y ) void wxDC::SetLogicalScale( double x, double y )
{ {
// allow negative ? // allow negative ?
@@ -430,40 +359,20 @@ void wxDC::SetLogicalScale( double x, double y )
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
void wxDC::GetLogicalScale( double *x, double *y ) void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
{
if (x) *x = m_logicalScaleX;
if (y) *y = m_logicalScaleY;
};
void wxDC::SetLogicalOrigin( long x, long y )
{ {
m_logicalOriginX = x * m_signX; // is this still correct ? m_logicalOriginX = x * m_signX; // is this still correct ?
m_logicalOriginY = y * m_signY; m_logicalOriginY = y * m_signY;
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
void wxDC::GetLogicalOrigin( long *x, long *y ) void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
{
if (x) *x = m_logicalOriginX;
if (y) *y = m_logicalOriginY;
};
void wxDC::SetDeviceOrigin( long x, long y )
{ {
m_externalDeviceOriginX = x; m_externalDeviceOriginX = x;
m_externalDeviceOriginY = y; m_externalDeviceOriginY = y;
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
/*
void wxDC::GetDeviceOrigin( long *x, long *y )
{
// if (x) *x = m_externalDeviceOriginX;
// if (y) *y = m_externalDeviceOriginY;
if (x) *x = m_deviceOriginX;
if (y) *y = m_deviceOriginY;
};
void wxDC::SetInternalDeviceOrigin( long x, long y ) void wxDC::SetInternalDeviceOrigin( long x, long y )
{ {
m_internalDeviceOriginX = x; m_internalDeviceOriginX = x;
@@ -476,53 +385,14 @@ void wxDC::GetInternalDeviceOrigin( long *x, long *y )
if (x) *x = m_internalDeviceOriginX; if (x) *x = m_internalDeviceOriginX;
if (y) *y = m_internalDeviceOriginY; if (y) *y = m_internalDeviceOriginY;
}; };
*/
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{ {
m_signX = (xLeftRight ? 1 : -1); m_signX = (xLeftRight ? 1 : -1);
m_signY = (yBottomUp ? -1 : 1); m_signY = (yBottomUp ? -1 : 1);
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
/*
long wxDC::DeviceToLogicalX(long x) const
{
return XDEV2LOG(x);
};
long wxDC::DeviceToLogicalY(long y) const
{
return YDEV2LOG(y);
};
long wxDC::DeviceToLogicalXRel(long x) const
{
return XDEV2LOGREL(x);
};
long wxDC::DeviceToLogicalYRel(long y) const
{
return YDEV2LOGREL(y);
};
long wxDC::LogicalToDeviceX(long x) const
{
return XLOG2DEV(x);
};
long wxDC::LogicalToDeviceY(long y) const
{
return YLOG2DEV(y);
};
long wxDC::LogicalToDeviceXRel(long x) const
{
return XLOG2DEVREL(x);
};
long wxDC::LogicalToDeviceYRel(long y) const
{
return YLOG2DEVREL(y);
};
void wxDC::CalcBoundingBox( long x, long y ) void wxDC::CalcBoundingBox( long x, long y )
{ {
@@ -531,6 +401,16 @@ void wxDC::CalcBoundingBox( long x, long y )
if (x > m_maxX) m_maxX = x; if (x > m_maxX) m_maxX = x;
if (y > m_maxY) m_maxY = y; if (y > m_maxY) m_maxY = y;
}; };
*/
wxSize wxDC::GetPPI() const
{
return wxSize(72, 72);
}
int wxDC::GetDepth() const
{
return wxDisplayDepth() ;
}
void wxDC::ComputeScaleAndOrigin(void) void wxDC::ComputeScaleAndOrigin(void)
{ {
@@ -547,12 +427,7 @@ void wxDC::ComputeScaleAndOrigin(void)
// CMB: if scale has changed call SetPen to recalulate the line width // CMB: if scale has changed call SetPen to recalulate the line width
if (m_scaleX != origScaleX || m_scaleY != origScaleY) if (m_scaleX != origScaleX || m_scaleY != origScaleY)
{ {
// this is a bit artificial, but we need to force wxDC to think // TODO : set internal flags for recalc
// the pen has changed
wxPen* pen = & GetPen();
wxPen tempPen;
m_pen = tempPen;
SetPen(* pen);
} }
}; };
@@ -634,16 +509,17 @@ void wxDC::SetLogicalFunction( int function )
m_macPenInstalled = false ; m_macPenInstalled = false ;
} }
void wxDC::FloodFill( long x1, long y1, const wxColour& col, int style ) void wxDC::DoFloodFill( wxCoord x, wxCoord y, const wxColour& col,
int style )
{ {
} }
bool wxDC::GetPixel( long x1, long y1, wxColour *col ) const bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
{ {
return true ; return true ;
} }
void wxDC::DrawLine( long x1, long y1, long x2, long y2 ) void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -664,19 +540,22 @@ void wxDC::DrawLine( long x1, long y1, long x2, long y2 )
}; };
} }
void wxDC::CrossHair( long x, long y ) void wxDC::DoCrossHair( wxCoord x, wxCoord y )
{ {
} }
void wxDC::DrawArc( long x1, long y1, long x2, long y2, long xc, long yc ) void wxDC::DoDrawArc( wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord xc, wxCoord yc )
{ {
} }
void wxDC::DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ) void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea )
{ {
} }
void wxDC::DrawPoint( long x, long y ) void wxDC::DoDrawPoint( wxCoord x, wxCoord y )
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -694,7 +573,8 @@ void wxDC::DrawPoint( long x, long y )
}; };
} }
void wxDC::DrawLines( int n, wxPoint points[], long xoffset , long yoffset ) void wxDC::DoDrawLines(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset)
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -719,8 +599,9 @@ void wxDC::DrawLines( int n, wxPoint points[], long xoffset , long yoffset )
} }
} }
void wxDC::DrawPolygon( int n, wxPoint points[], long xoffset , long yoffset , void wxDC::DoDrawPolygon(int n, wxPoint points[],
int fillStyle ) wxCoord xoffset, wxCoord yoffset,
int fillStyle )
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -754,7 +635,7 @@ void wxDC::DrawPolygon( int n, wxPoint points[], long xoffset , long yoffset ,
KillPoly( polygon ) ; KillPoly( polygon ) ;
} }
void wxDC::DrawRectangle( long x, long y, long width, long height ) void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -797,7 +678,9 @@ void wxDC::DrawRectangle( long x, long y, long width, long height )
}; };
} }
void wxDC::DrawRoundedRectangle( long x, long y, long width, long height, double radius ) void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
wxCoord width, wxCoord height,
double radius)
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -843,7 +726,7 @@ void wxDC::DrawRoundedRectangle( long x, long y, long width, long height, doubl
}; };
} }
void wxDC::DrawEllipse( long x, long y, long width, long height ) void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -1001,7 +884,7 @@ static void wx_spline_draw_point_array(wxDC *dc)
} }
} }
void wxDC::DrawSpline( wxList *points ) void wxDC::DoDrawSpline(wxList *points)
{ {
wxPoint *p; wxPoint *p;
double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4; double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
@@ -1059,8 +942,8 @@ bool wxDC::CanDrawBitmap(void) const
} }
bool wxDC::Blit( long xdest, long ydest, long width, long height, bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, long xsrc, long ysrc, int logical_func , bool useMask ) wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask )
{ {
if (!Ok()) return FALSE; if (!Ok()) return FALSE;
MacVerifySetup() ; MacVerifySetup() ;
@@ -1069,8 +952,8 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ; PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
RGBColor black = { 0,0,0} ; RGBColor black = { 0,0,0} ;
RGBForeColor( &m_textForegroundColour.GetPixel() ) ; RGBForeColor( &m_textForegroundColour.GetPixel() ) ;
RGBBackColor( &m_textBackgroundColour.GetPixel() ) ; RGBBackColor( &m_textBackgroundColour.GetPixel() ) ;
if ( LockPixels(bmappixels) ) if ( LockPixels(bmappixels) )
{ {
@@ -1094,7 +977,7 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
logical_func == wxXOR ? srcXor : logical_func == wxXOR ? srcXor :
// logical_func == wxOR_REVERSE ? MERGEPAINT : // logical_func == wxOR_REVERSE ? MERGEPAINT :
// logical_func == wxAND_REVERSE ? SRCERASE : // logical_func == wxAND_REVERSE ? SRCERASE :
logical_func == wxSRC_OR ? srcOr : // logical_func == wxSRC_OR ? srcOr :
// logical_func == wxSRC_AND ? SRCAND : // logical_func == wxSRC_AND ? SRCAND :
srcCopy ); srcCopy );
@@ -1103,14 +986,15 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
wxASSERT( mode == srcCopy ) ; wxASSERT( mode == srcCopy ) ;
if ( LockPixels( GetGWorldPixMap( source->m_macMask ) ) ) if ( LockPixels( GetGWorldPixMap( source->m_macMask ) ) )
{ {
CopyMask( &GrafPtr( sourcePort )->portBits , &GrafPtr( source->m_macMask )->portBits , &GrafPtr( m_macPort )->portBits , CopyMask( GetPortBitMapForCopyBits( sourcePort ) , GetPortBitMapForCopyBits( source->m_macMask ) ,
GetPortBitMapForCopyBits( m_macPort ) ,
&srcrect, &srcrect , &dstrect ) ; &srcrect, &srcrect , &dstrect ) ;
UnlockPixels( GetGWorldPixMap( source->m_macMask ) ) ; UnlockPixels( GetGWorldPixMap( source->m_macMask ) ) ;
} }
} }
else else
{ {
CopyBits( &GrafPtr( sourcePort )->portBits , &GrafPtr( m_macPort )->portBits , CopyBits( GetPortBitMapForCopyBits( sourcePort ) , GetPortBitMapForCopyBits( m_macPort ) ,
&srcrect, &dstrect, mode, NULL ) ; &srcrect, &dstrect, mode, NULL ) ;
} }
UnlockPixels( bmappixels ) ; UnlockPixels( bmappixels ) ;
@@ -1123,7 +1007,11 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
return TRUE; return TRUE;
} }
void wxDC::DrawText( const wxString &string, long x, long y, bool use16) void wxDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
double angle)
{
}
void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -1161,14 +1049,14 @@ void wxDC::DrawText( const wxString &string, long x, long y, bool use16)
if ( wxApp::s_macDefaultEncodingIsPC ) if ( wxApp::s_macDefaultEncodingIsPC )
{ {
macText = wxMacMakeMacStringFromPC( string ) ; macText = wxMacMakeMacStringFromPC( strtext ) ;
text = macText ; text = macText ;
length = macText.Length() ; length = macText.Length() ;
} }
else else
{ {
text = string ; text = strtext ;
length = string.Length() ; length = strtext.Length() ;
} }
int laststop = 0 ; int laststop = 0 ;
@@ -1200,9 +1088,9 @@ bool wxDC::CanGetTextExtent(void) const
return true ; return true ;
} }
void wxDC::GetTextExtent( const wxString &string, long *width, long *height, void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height,
long *descent, long *externalLeading , wxCoord *descent, wxCoord *externalLeading ,
wxFont *theFont , bool use16 ) const wxFont *theFont ) const
{ {
if (!Ok()) if (!Ok())
return; return;
@@ -1217,11 +1105,8 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
if ( font ) if ( font )
{ {
long yy1 = YLOG2DEV(0);
long yy2 = YLOG2DEV(font->m_macFontSize);
::TextFont( font->m_macFontNum ) ; ::TextFont( font->m_macFontNum ) ;
::TextSize( abs( yy2-yy1) ) ; ::TextSize( YLOG2DEVREL( font->m_macFontSize) ) ;
::TextFace( font->m_macFontStyle ) ; ::TextFace( font->m_macFontStyle ) ;
} }
} }
@@ -1233,9 +1118,12 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
FontInfo fi ; FontInfo fi ;
::GetFontInfo( &fi ) ; ::GetFontInfo( &fi ) ;
*height = fi.descent + fi.ascent ; if ( height )
*descent = fi.descent ; *height = YDEV2LOGREL( fi.descent + fi.ascent ) ;
*externalLeading = fi.leading ; if ( descent )
*descent =YDEV2LOGREL( fi.descent );
if ( externalLeading )
*externalLeading = YDEV2LOGREL( fi.leading ) ;
const char *text = NULL ; const char *text = NULL ;
int length = 0 ; int length = 0 ;
@@ -1255,24 +1143,28 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
int laststop = 0 ; int laststop = 0 ;
int i = 0 ; int i = 0 ;
int curwidth = 0 ; int curwidth = 0 ;
*width = 0 ; if ( width )
while( i < length )
{ {
if( text[i] == 13 || text[i] == 10) *width = 0 ;
{
*height += fi.descent + fi.ascent + fi.leading;
curwidth = ::TextWidth( text , laststop , i - laststop ) ;
if ( curwidth > *width )
*width = curwidth ;
laststop = i+1 ;
}
i++ ;
}
curwidth = ::TextWidth( text , laststop , i - laststop ) ; while( i < length )
if ( curwidth > *width ) {
*width = curwidth ; if( text[i] == 13 || text[i] == 10)
{
if ( height )
*height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ;
curwidth = ::TextWidth( text , laststop , i - laststop ) ;
if ( curwidth > *width )
*width = XDEV2LOGREL( curwidth ) ;
laststop = i+1 ;
}
i++ ;
}
curwidth = ::TextWidth( text , laststop , i - laststop ) ;
if ( curwidth > *width )
*width = XDEV2LOGREL( curwidth ) ;
}
if ( theFont ) if ( theFont )
{ {
@@ -1292,7 +1184,7 @@ wxCoord wxDC::GetCharWidth(void) const
FontInfo fi ; FontInfo fi ;
::GetFontInfo( &fi ) ; ::GetFontInfo( &fi ) ;
return (fi.descent + fi.ascent) / 2 ; return YDEV2LOGREL((fi.descent + fi.ascent) / 2) ;
} }
wxCoord wxDC::GetCharHeight(void) const wxCoord wxDC::GetCharHeight(void) const
@@ -1307,7 +1199,7 @@ wxCoord wxDC::GetCharHeight(void) const
FontInfo fi ; FontInfo fi ;
::GetFontInfo( &fi ) ; ::GetFontInfo( &fi ) ;
return fi.descent + fi.ascent ; return YDEV2LOGREL( fi.descent + fi.ascent );
} }
void wxDC::Clear(void) void wxDC::Clear(void)
@@ -1332,6 +1224,7 @@ void wxDC::MacInstallFont() const
if ( m_macFontInstalled ) if ( m_macFontInstalled )
return ; return ;
Pattern blackColor ;
wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
@@ -1377,7 +1270,7 @@ void wxDC::MacInstallFont() const
mode = patCopy ; mode = patCopy ;
break ; break ;
case wxINVERT: // NOT dst case wxINVERT: // NOT dst
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
mode = patXor ; mode = patXor ;
break ; break ;
case wxXOR: // src XOR dst case wxXOR: // src XOR dst
@@ -1403,8 +1296,8 @@ void wxDC::MacInstallFont() const
case wxNAND: // (NOT src) OR (NOT dst) case wxNAND: // (NOT src) OR (NOT dst)
case wxOR: // src OR dst case wxOR: // src OR dst
case wxSET: // 1 case wxSET: // 1
case wxSRC_OR: // source _bitmap_ OR destination // case wxSRC_OR: // source _bitmap_ OR destination
case wxSRC_AND: // source _bitmap_ AND destination // case wxSRC_AND: // source _bitmap_ AND destination
break ; break ;
} }
::PenMode( mode ) ; ::PenMode( mode ) ;
@@ -1447,6 +1340,8 @@ void wxDC::MacInstallPen() const
return; return;
MacVerifySetup() ; MacVerifySetup() ;
Pattern blackColor;
if ( m_macPenInstalled ) if ( m_macPenInstalled )
return ; return ;
@@ -1460,7 +1355,7 @@ void wxDC::MacInstallPen() const
int penStyle = m_pen.GetStyle(); int penStyle = m_pen.GetStyle();
if (penStyle == wxSOLID) if (penStyle == wxSOLID)
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
else if (IS_HATCH(penStyle)) else if (IS_HATCH(penStyle))
{ {
Pattern pat ; Pattern pat ;
@@ -1469,7 +1364,7 @@ void wxDC::MacInstallPen() const
} }
else else
{ {
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
} }
short mode = patCopy ; short mode = patCopy ;
@@ -1482,7 +1377,7 @@ void wxDC::MacInstallPen() const
mode = patCopy ; mode = patCopy ;
break ; break ;
case wxINVERT: // NOT dst case wxINVERT: // NOT dst
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
mode = patXor ; mode = patXor ;
break ; break ;
case wxXOR: // src XOR dst case wxXOR: // src XOR dst
@@ -1508,8 +1403,8 @@ void wxDC::MacInstallPen() const
case wxNAND: // (NOT src) OR (NOT dst) case wxNAND: // (NOT src) OR (NOT dst)
case wxOR: // src OR dst case wxOR: // src OR dst
case wxSET: // 1 case wxSET: // 1
case wxSRC_OR: // source _bitmap_ OR destination // case wxSRC_OR: // source _bitmap_ OR destination
case wxSRC_AND: // source _bitmap_ AND destination // case wxSRC_AND: // source _bitmap_ AND destination
break ; break ;
} }
::PenMode( mode ) ; ::PenMode( mode ) ;
@@ -1523,7 +1418,7 @@ void wxDC::MacInstallBrush() const
if (!Ok()) if (!Ok())
return; return;
MacVerifySetup() ; MacVerifySetup() ;
Pattern blackColor, whiteColor ;
if ( m_macBrushInstalled ) if ( m_macBrushInstalled )
return ; return ;
@@ -1534,7 +1429,7 @@ void wxDC::MacInstallBrush() const
int brushStyle = m_brush.GetStyle(); int brushStyle = m_brush.GetStyle();
if (brushStyle == wxSOLID) if (brushStyle == wxSOLID)
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
else if (IS_HATCH(brushStyle)) else if (IS_HATCH(brushStyle))
{ {
Pattern pat ; Pattern pat ;
@@ -1543,7 +1438,7 @@ void wxDC::MacInstallBrush() const
} }
else else
{ {
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
} }
@@ -1551,7 +1446,7 @@ void wxDC::MacInstallBrush() const
brushStyle = m_backgroundBrush.GetStyle(); brushStyle = m_backgroundBrush.GetStyle();
if (brushStyle == wxSOLID) if (brushStyle == wxSOLID)
::BackPat(&qd.white); ::BackPat(GetQDGlobalsWhite(&whiteColor));
else if (IS_HATCH(brushStyle)) else if (IS_HATCH(brushStyle))
{ {
Pattern pat ; Pattern pat ;
@@ -1560,7 +1455,7 @@ void wxDC::MacInstallBrush() const
} }
else else
{ {
::BackPat(&qd.white); ::BackPat(GetQDGlobalsWhite(&whiteColor));
} }
short mode = patCopy ; short mode = patCopy ;
@@ -1573,7 +1468,7 @@ void wxDC::MacInstallBrush() const
mode = patCopy ; mode = patCopy ;
break ; break ;
case wxINVERT: // NOT dst case wxINVERT: // NOT dst
::PenPat(&qd.black); ::PenPat(GetQDGlobalsBlack(&blackColor));
mode = patXor ; mode = patXor ;
break ; break ;
case wxXOR: // src XOR dst case wxXOR: // src XOR dst
@@ -1599,8 +1494,8 @@ void wxDC::MacInstallBrush() const
case wxNAND: // (NOT src) OR (NOT dst) case wxNAND: // (NOT src) OR (NOT dst)
case wxOR: // src OR dst case wxOR: // src OR dst
case wxSET: // 1 case wxSET: // 1
case wxSRC_OR: // source _bitmap_ OR destination // case wxSRC_OR: // source _bitmap_ OR destination
case wxSRC_AND: // source _bitmap_ AND destination // case wxSRC_AND: // source _bitmap_ AND destination
break ; break ;
} }
::PenMode( mode ) ; ::PenMode( mode ) ;
@@ -1609,4 +1504,47 @@ void wxDC::MacInstallBrush() const
m_macFontInstalled = false ; m_macFontInstalled = false ;
} }
// ---------------------------------------------------------------------------
// coordinates transformations
// ---------------------------------------------------------------------------
wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
{
return ((wxDC *)this)->XDEV2LOG(x);
}
wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
{
return ((wxDC *)this)->YDEV2LOG(y);
}
wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
{
return ((wxDC *)this)->XDEV2LOGREL(x);
}
wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
{
return ((wxDC *)this)->YDEV2LOGREL(y);
}
wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
{
return ((wxDC *)this)->XLOG2DEV(x);
}
wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
{
return ((wxDC *)this)->YLOG2DEV(y);
}
wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
{
return ((wxDC *)this)->XLOG2DEVREL(x);
}
wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
{
return ((wxDC *)this)->YLOG2DEVREL(y);
}

View File

@@ -28,9 +28,11 @@
// wxPaintDC // wxPaintDC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
#endif
/* /*
* wxWindowDC * wxWindowDC
@@ -38,7 +40,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
wxWindowDC::wxWindowDC(void) wxWindowDC::wxWindowDC()
{ {
} }
@@ -51,11 +53,16 @@ wxWindowDC::wxWindowDC(wxWindow *the_canvas)
the_canvas->MacGetPortParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow ); the_canvas->MacGetPortParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow );
m_macPort = UMAGetWindowPort( windowref ) ; m_macPort = UMAGetWindowPort( windowref ) ;
m_minY = m_minX = 0;
wxSize size = the_canvas->GetSize() ;
m_maxX = size.x ;
m_maxY = size.y ;
MacSetupPort() ; MacSetupPort() ;
m_ok = TRUE ; m_ok = TRUE ;
} }
wxWindowDC::~wxWindowDC(void) wxWindowDC::~wxWindowDC()
{ {
} }
@@ -63,7 +70,7 @@ wxWindowDC::~wxWindowDC(void)
* wxClientDC * wxClientDC
*/ */
wxClientDC::wxClientDC(void) wxClientDC::wxClientDC()
{ {
} }
@@ -75,12 +82,16 @@ wxClientDC::wxClientDC(wxWindow *window)
window->MacGetPortClientParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow ); window->MacGetPortClientParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow );
m_macPort = UMAGetWindowPort( windowref ) ; m_macPort = UMAGetWindowPort( windowref ) ;
MacSetupPort() ; MacSetupPort() ;
m_minY = m_minX = 0;
wxSize size = window->GetSize() ;
m_maxX = size.x ;
m_maxY = size.y ;
m_ok = TRUE ; m_ok = TRUE ;
SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID)); SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
SetFont( window->GetFont() ) ; SetFont( window->GetFont() ) ;
} }
wxClientDC::~wxClientDC(void) wxClientDC::~wxClientDC()
{ {
} }
@@ -88,7 +99,7 @@ wxClientDC::~wxClientDC(void)
* wxPaintDC * wxPaintDC
*/ */
wxPaintDC::wxPaintDC(void) wxPaintDC::wxPaintDC()
{ {
} }
@@ -104,6 +115,10 @@ wxPaintDC::wxPaintDC(wxWindow *window)
m_ok = TRUE ; m_ok = TRUE ;
long x , y ,w , h ; long x , y ,w , h ;
window->GetUpdateRegion().GetBox( x , y , w , h ) ; window->GetUpdateRegion().GetBox( x , y , w , h ) ;
m_minY = m_minX = 0;
wxSize size = window->GetSize() ;
m_maxX = size.x ;
m_maxY = size.y ;
SetClippingRegion( x , y , w , h ) ; SetClippingRegion( x , y , w , h ) ;
SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID)); SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
SetFont(window->GetFont() ) ; SetFont(window->GetFont() ) ;

View File

@@ -33,10 +33,20 @@ wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
wxMemoryDC::~wxMemoryDC(void) wxMemoryDC::~wxMemoryDC(void)
{ {
if ( m_selected.Ok() )
{
wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ;
}
}; };
void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
{ {
if ( m_selected.Ok() )
{
wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ;
}
m_selected = bitmap; m_selected = bitmap;
if (m_selected.Ok()) if (m_selected.Ok())
{ {
@@ -44,6 +54,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
if ( bmap->m_hBitmap ) if ( bmap->m_hBitmap )
{ {
m_macPort = (GrafPtr) bmap->m_hBitmap ; m_macPort = (GrafPtr) bmap->m_hBitmap ;
LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
wxMask * mask = bitmap.GetMask() ; wxMask * mask = bitmap.GetMask() ;
if ( mask ) if ( mask )
{ {

View File

@@ -25,31 +25,36 @@
#include "wx/dcprint.h" #include "wx/dcprint.h"
#include "math.h" #include "math.h"
#include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_CLASS(wxPrinterDC, wxDC) IMPLEMENT_CLASS(wxPrinterDC, wxDC)
#endif
GrafPtr macPrintFormerPort = NULL ; GrafPtr macPrintFormerPort = NULL ;
wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
{ {
#if !TARGET_CARBON
OSErr err ; OSErr err ;
wxString message ; wxString message ;
m_printData = printdata ; m_printData = printdata ;
m_printData.ConvertToNative() ; m_printData.ConvertToNative() ;
::PrOpen() ; ::UMAPrOpen() ;
err = PrError() ; err = PrError() ;
if ( err ) if ( err )
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
PrClose() ; UMAPrClose() ;
} }
if ( ::PrValidate( m_printData.m_macPrintInfo ) ) if ( ::PrValidate( m_printData.m_macPrintInfo ) )
{ {
::PrStlDialog( m_printData.m_macPrintInfo ) ;
// the driver has changed in the mean time, should we pop up a page setup dialog ? // the driver has changed in the mean time, should we pop up a page setup dialog ?
} }
err = PrError() ; err = PrError() ;
@@ -57,20 +62,31 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
PrClose() ; UMAPrClose() ;
} }
::GetPort( &macPrintFormerPort ) ; ::GetPort( &macPrintFormerPort ) ;
m_macPrintPort = ::PrOpenDoc( m_printData.m_macPrintInfo , NULL , NULL ) ; m_macPrintPort = ::PrOpenDoc( m_printData.m_macPrintInfo , NULL , NULL ) ;
err = PrError() ;
if ( err )
{
message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
UMAPrClose() ;
}
// sets current port // sets current port
m_macPort = (GrafPtr ) m_macPrintPort ; m_macPort = (GrafPtr ) m_macPrintPort ;
m_ok = TRUE ; m_ok = TRUE ;
m_minY = m_minX = 0 ; m_minY = m_minX = 0 ;
m_maxX = (**m_printData.m_macPrintInfo).rPaper.right - (**m_printData.m_macPrintInfo).rPaper.left ; m_maxX = (**m_printData.m_macPrintInfo).rPaper.right - (**m_printData.m_macPrintInfo).rPaper.left ;
m_maxY = (**m_printData.m_macPrintInfo).rPaper.bottom - (**m_printData.m_macPrintInfo).rPaper.top ; m_maxY = (**m_printData.m_macPrintInfo).rPaper.bottom - (**m_printData.m_macPrintInfo).rPaper.top ;
#else
#pragma warning "TODO:printing support for carbon"
#endif
} }
wxPrinterDC::~wxPrinterDC(void) wxPrinterDC::~wxPrinterDC(void)
{ {
#if !TARGET_CARBON
if ( m_ok ) if ( m_ok )
{ {
OSErr err ; OSErr err ;
@@ -91,11 +107,16 @@ wxPrinterDC::~wxPrinterDC(void)
{ {
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
PrClose() ; UMAPrClose() ;
} }
::PrClose() ; ::UMAPrClose() ;
::SetPort( macPrintFormerPort ) ; // ::SetPort( macPrintFormerPort ) ;
::SetPort( LMGetWMgrPort() ) ;
m_macPortHelper.Clear() ;
} }
#else
#pragma warning "TODO:printing support for carbon"
#endif
} }
bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) ) bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) )
@@ -109,13 +130,30 @@ void wxPrinterDC::EndDoc(void)
void wxPrinterDC::StartPage(void) void wxPrinterDC::StartPage(void)
{ {
#if !TARGET_CARBON
if ( !m_ok ) if ( !m_ok )
return ; return ;
m_logicalFunction = wxCOPY;
// m_textAlignment = wxALIGN_TOP_LEFT;
m_backgroundMode = wxTRANSPARENT;
m_textForegroundColour = *wxBLACK;
m_textBackgroundColour = *wxWHITE;
m_pen = *wxBLACK_PEN;
m_font = *wxNORMAL_FONT;
m_brush = *wxTRANSPARENT_BRUSH;
m_backgroundBrush = *wxWHITE_BRUSH;
m_macFontInstalled = false ;
m_macBrushInstalled = false ;
m_macPenInstalled = false ;
OSErr err ; OSErr err ;
wxString message ; wxString message ;
PrOpenPage( m_macPrintPort , NULL ) ; PrOpenPage( m_macPrintPort , NULL ) ;
SetOrigin( - (**m_printData.m_macPrintInfo).rPaper.left , - (**m_printData.m_macPrintInfo).rPaper.top ) ; SetOrigin( - (**m_printData.m_macPrintInfo).rPaper.left , - (**m_printData.m_macPrintInfo).rPaper.top ) ;
Rect clip = { -32000 , -32000 , 32000 , 32000 } ; Rect clip = { -32000 , -32000 , 32000 , 32000 } ;
::ClipRect( &clip ) ; ::ClipRect( &clip ) ;
@@ -126,14 +164,18 @@ void wxPrinterDC::StartPage(void)
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
::PrClosePage( m_macPrintPort) ; ::PrClosePage( m_macPrintPort) ;
::PrCloseDoc( m_macPrintPort ) ; ::PrCloseDoc( m_macPrintPort ) ;
::PrClose() ; ::UMAPrClose() ;
::SetPort( macPrintFormerPort ) ; ::SetPort( macPrintFormerPort ) ;
m_ok = FALSE ; m_ok = FALSE ;
} }
#else
#pragma warning "TODO:printing support for carbon"
#endif
} }
void wxPrinterDC::EndPage(void) void wxPrinterDC::EndPage(void)
{ {
#if !TARGET_CARBON
if ( !m_ok ) if ( !m_ok )
return ; return ;
@@ -147,8 +189,12 @@ void wxPrinterDC::EndPage(void)
message.Printf( "Print Error %d", err ) ; message.Printf( "Print Error %d", err ) ;
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
::PrCloseDoc( m_macPrintPort ) ; ::PrCloseDoc( m_macPrintPort ) ;
::PrClose() ; ::UMAPrClose() ;
::SetPort( macPrintFormerPort ) ; ::SetPort( macPrintFormerPort ) ;
m_ok = FALSE ; m_ok = FALSE ;
} }
#else
#pragma warning "TODO:printing support for carbon"
#endif
} }

View File

@@ -14,15 +14,34 @@
#endif #endif
#include "wx/dcscreen.h" #include "wx/dcscreen.h"
#include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
#endif
// Create a DC representing the whole screen // Create a DC representing the whole screen
wxScreenDC::wxScreenDC() wxScreenDC::wxScreenDC()
{ {
#if TARGET_CARBON
m_macPort = GetQDGlobalsThePort() ;
#else
m_macPort = LMGetWMgrPort() ; m_macPort = LMGetWMgrPort() ;
#endif
MacSetupPort() ; MacSetupPort() ;
m_ok = TRUE ; m_ok = TRUE ;
BitMap screenBits;
GetQDGlobalsScreenBits( &screenBits );
m_minX = screenBits.bounds.left ;
#if TARGET_CARBON
SInt16 height ;
GetThemeMenuBarHeight( &height ) ;
m_minY = screenBits.bounds.top + height ;
#else
m_minY = screenBits.bounds.top + LMGetMBarHeight() ;
#endif
m_maxX = screenBits.bounds.right ;
m_maxY = screenBits.bounds.bottom ;
} }
wxScreenDC::~wxScreenDC() wxScreenDC::~wxScreenDC()

View File

@@ -27,6 +27,7 @@ wxList wxModalDialogs;
wxList wxModelessWindows; // Frames and modeless dialogs wxList wxModelessWindows; // Frames and modeless dialogs
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel) IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
BEGIN_EVENT_TABLE(wxDialog, wxPanel) BEGIN_EVENT_TABLE(wxDialog, wxPanel)
@@ -39,11 +40,11 @@ BEGIN_EVENT_TABLE(wxDialog, wxPanel)
EVT_CLOSE(wxDialog::OnCloseWindow) EVT_CLOSE(wxDialog::OnCloseWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif
wxDialog::wxDialog() wxDialog::wxDialog()
{ {
m_isShown = FALSE; m_isShown = FALSE;
m_modalShowing = FALSE;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
} }
@@ -54,15 +55,8 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
long style, long style,
const wxString& name) const wxString& name)
{ {
m_windowStyle = style;
m_isShown = FALSE;
m_modalShowing = FALSE;
#if wxUSE_TOOLTIPS
m_hwndToolTip = 0;
#endif
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
SetName(name);
if (!parent) if (!parent)
wxTopLevelWindows.Append(this); wxTopLevelWindows.Append(this);
@@ -74,59 +68,26 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
else else
m_windowId = id; m_windowId = id;
Rect theBoundsRect; MacCreateRealWindow( title , pos , size , MacRemoveBordersFromStyle(style) , name ) ;
m_x = (int)pos.x;
m_y = (int)pos.y;
if ( m_y < 50 )
m_y = 50 ;
if ( m_x < 20 )
m_x = 20 ;
m_width = size.x;
if (m_width == -1)
m_width = 20;
m_height = size.y;
if (m_height == -1)
m_height = 20;
::SetRect(&theBoundsRect, m_x, m_y, m_x + m_width, m_y + m_height);
m_macWindowData = new MacWindowData() ;
WindowClass wclass = kMovableModalWindowClass ;
WindowAttributes attr = kWindowNoAttributes ;
if ( ( m_windowStyle & wxMINIMIZE_BOX ) || ( m_windowStyle & wxMAXIMIZE_BOX ) )
{
attr |= kWindowFullZoomAttribute ;
attr |= kWindowResizableAttribute ;
}
UMACreateNewWindow( wclass , attr , &theBoundsRect , &m_macWindowData->m_macWindow ) ;
wxAssociateWinWithMacWindow( m_macWindowData->m_macWindow , this ) ;
wxString label ;
if( wxApp::s_macDefaultEncodingIsPC )
label = wxMacMakeMacStringFromPC( title ) ;
else
label = title ;
UMASetWTitleC( m_macWindowData->m_macWindow , label ) ;
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ; m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ;
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
m_macWindowData->m_macFocus = NULL ;
return TRUE; return TRUE;
} }
void wxDialog::SetModal(bool flag) void wxDialog::SetModal(bool flag)
{ {
if ( flag ) if ( flag )
m_windowStyle |= wxDIALOG_MODAL ; {
else m_windowStyle |= wxDIALOG_MODAL;
if ( m_windowStyle & wxDIALOG_MODAL )
m_windowStyle -= wxDIALOG_MODAL ;
wxModelessWindows.DeleteObject(this); wxModelessWindows.DeleteObject(this);
if (!flag) }
wxModelessWindows.Append(this); else
{
m_windowStyle &= ~wxDIALOG_MODAL;
wxModelessWindows.Append(this);
}
} }
wxDialog::~wxDialog() wxDialog::~wxDialog()
@@ -134,10 +95,10 @@ wxDialog::~wxDialog()
m_isBeingDeleted = TRUE ; m_isBeingDeleted = TRUE ;
wxTopLevelWindows.DeleteObject(this); wxTopLevelWindows.DeleteObject(this);
m_modalShowing = FALSE; Show(FALSE);
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL ) if ( !IsModal() )
wxModelessWindows.DeleteObject(this); wxModelessWindows.DeleteObject(this);
// If this is the last top-level window, exit. // If this is the last top-level window, exit.
if (wxTheApp && (wxTopLevelWindows.Number() == 0)) if (wxTheApp && (wxTopLevelWindows.Number() == 0))
@@ -184,19 +145,20 @@ void wxDialog::DoSetClientSize(int width, int height)
wxWindow::DoSetClientSize( width , height ) ; wxWindow::DoSetClientSize( width , height ) ;
} }
void wxDialog::GetPosition(int *x, int *y) const void wxDialog::DoGetPosition(int *x, int *y) const
{ {
DoGetPosition( x , y ) ; wxWindow::DoGetPosition( x , y ) ;
}
bool wxDialog::IsShown() const
{
return m_isShown;
} }
bool wxDialog::IsModal() const bool wxDialog::IsModal() const
{ {
return wxModalDialogs.Find((wxDialog *)this) != 0; // const_cast return (GetWindowStyleFlag() & wxDIALOG_MODAL) != 0;
}
bool wxDialog::IsModalShowing() const
{
return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
} }
@@ -204,121 +166,76 @@ extern bool s_macIsInModalLoop ;
bool wxDialog::Show(bool show) bool wxDialog::Show(bool show)
{ {
m_isShown = show; if ( !wxDialogBase::Show(show) )
if (show)
InitDialog();
bool modal = ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL) ;
#if WXGARBAGE_COLLECTION_ON /* MATTHEW: GC */
if (!modal)
{
if (show)
{ {
if (!wxModelessWindows.Find(this)) // nothing to do
wxModelessWindows.Append(this); return FALSE;
} }
else
wxModelessWindows.DeleteObject(this);
}
if (show)
{
if (!wxTopLevelWindows.Find(this))
wxTopLevelWindows.Append(this);
}
else
wxTopLevelWindows.DeleteObject(this);
#endif
if ( modal ) if ( show )
{
// usually will result in TransferDataToWindow() being called
InitDialog();
}
if ( IsModal() )
{
if ( show )
{
DoShowModal();
}
else // end of modal dialog
{
// this will cause IsModalShowing() return FALSE and our local
// message loop will terminate
wxModalDialogs.DeleteObject(this);
}
}
return TRUE;
}
void wxDialog::DoShowModal()
{
wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );
wxModalDialogs.Append(this);
wxWindow *parent = GetParent();
// remember where the focus was
wxWindow *winFocus = FindFocus();
if ( !winFocus )
{
winFocus = parent;
}
if ( !winFocus )
{
winFocus = wxTheApp->GetTopWindow();
}
// TODO : test whether parent gets disabled
s_macIsInModalLoop = true ;
while ( IsModalShowing() )
{ {
s_macIsInModalLoop = true ; while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() )
if (show) {
{ }
if (m_modalShowing) wxTheApp->MacDoOneEvent() ;
{
// BringWindowToTop((HWND) GetHWND());
return TRUE;
}
m_modalShowing = TRUE;
// if we don't do it, some window might be deleted while we have pointers
// to them in our disabledWindows list and the program will crash when it
// will try to reenable them after the modal dialog end
wxTheApp->DeletePendingObjects();
UMAShowWindow( m_macWindowData->m_macWindow ) ;
UMASelectWindow( m_macWindowData->m_macWindow ) ;
if (!wxModalDialogs.Member(this))
wxModalDialogs.Append(this);
while (wxModalDialogs.Member(this) )
{
wxTheApp->MacDoOneEvent() ;
}
}
else
{
wxModalDialogs.DeleteObject(this);
UMAHideWindow( m_macWindowData->m_macWindow ) ;
}
s_macIsInModalLoop = false ;
} }
else // !modal
{ s_macIsInModalLoop = false ;
if (show)
{ // TODO probably reenable the parent window if any
UMAShowWindow( m_macWindowData->m_macWindow ) ;
UMASelectWindow( m_macWindowData->m_macWindow ) ; // and restore focus
} if ( winFocus )
else {
{ winFocus->SetFocus();
UMAHideWindow( m_macWindowData->m_macWindow ) ; }
}
}
return TRUE ;
} }
void wxDialog::SetTitle(const wxString& title)
{
wxWindow::SetTitle( title ) ;
}
wxString wxDialog::GetTitle() const
{
return wxWindow::GetTitle() ;
}
void wxDialog::Centre(int direction)
{
int x_offset,y_offset ;
int display_width, display_height;
int width, height, x, y;
wxWindow *parent = GetParent();
if ((direction & wxCENTER_FRAME) && parent)
{
parent->GetPosition(&x_offset,&y_offset) ;
parent->GetSize(&display_width,&display_height) ;
}
else
{
wxDisplaySize(&display_width, &display_height);
x_offset = 0 ;
y_offset = 0 ;
}
GetSize(&width, &height);
GetPosition(&x, &y);
if (direction & wxHORIZONTAL)
x = (int)((display_width - width)/2);
if (direction & wxVERTICAL)
y = (int)((display_height - height)/2);
SetSize(x+x_offset, y+y_offset, width, height);
}
// Replacement for Show(TRUE) for modal dialogs - returns return code // Replacement for Show(TRUE) for modal dialogs - returns return code
int wxDialog::ShowModal() int wxDialog::ShowModal()
@@ -328,6 +245,8 @@ int wxDialog::ShowModal()
return GetReturnCode(); return GetReturnCode();
} }
// NB: this function (surprizingly) may be called for both modal and modeless
// dialogs and should work for both of them
void wxDialog::EndModal(int retCode) void wxDialog::EndModal(int retCode)
{ {
SetReturnCode(retCode); SetReturnCode(retCode);
@@ -339,13 +258,7 @@ void wxDialog::OnOK(wxCommandEvent& event)
{ {
if ( Validate() && TransferDataFromWindow() ) if ( Validate() && TransferDataFromWindow() )
{ {
if ( IsModal() ) EndModal(wxID_OK);
EndModal(wxID_OK);
else
{
SetReturnCode(wxID_OK);
this->Show(FALSE);
}
} }
} }
@@ -358,20 +271,7 @@ void wxDialog::OnApply(wxCommandEvent& event)
void wxDialog::OnCancel(wxCommandEvent& event) void wxDialog::OnCancel(wxCommandEvent& event)
{ {
if ( IsModal() )
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
else
{
SetReturnCode(wxID_CANCEL);
this->Show(FALSE);
}
}
void wxDialog::OnPaint(wxPaintEvent& event)
{
// No: if you call the default procedure, it makes
// the following painting code not work.
// wxWindow::OnPaint(event);
} }
void wxDialog::OnCloseWindow(wxCloseEvent& event) void wxDialog::OnCloseWindow(wxCloseEvent& event)
@@ -407,30 +307,16 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event)
// Destroy the window (delayed, if a managed window) // Destroy the window (delayed, if a managed window)
bool wxDialog::Destroy() bool wxDialog::Destroy()
{ {
if (!wxPendingDelete.Member(this)) wxCHECK_MSG( !wxPendingDelete.Member(this), FALSE,
_T("wxDialog destroyed twice") );
wxPendingDelete.Append(this); wxPendingDelete.Append(this);
return TRUE; return TRUE;
} }
void wxDialog::OnSize(wxSizeEvent& WXUNUSED(event))
{
// if we're using constraints - do use them
#if wxUSE_CONSTRAINTS
if ( GetAutoLayout() )
{
Layout();
}
#endif
}
void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event)
{ {
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
Refresh(); Refresh();
} }
void wxDialog::Fit()
{
wxWindow::Fit();
}

View File

@@ -147,6 +147,7 @@ bool wxDirData::Read(wxString *filename)
if ( err != noErr ) if ( err != noErr )
break ; break ;
p2cstr( m_name ) ;
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory
break ; break ;
@@ -156,17 +157,37 @@ bool wxDirData::Read(wxString *filename)
if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) // its hidden but we don't want it if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) // its hidden but we don't want it
continue ; continue ;
wxString file( m_name ) ;
if ( m_filespec.IsEmpty() || m_filespec == "*.*" )
{
}
else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" )
{
if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
{
continue ;
}
}
else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" )
{
if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
{
continue ;
}
}
else if ( file.Upper() != m_filespec.Upper() )
{
continue ;
}
break ; break ;
} }
if ( err != noErr ) if ( err != noErr )
{ {
return FALSE ; return FALSE ;
} }
FSSpec spec ;
FSMakeFSSpecCompat(m_CPB.hFileInfo.ioVRefNum, m_dirId, m_name,&spec) ; *filename = (char*) m_name ;
*filename = wxMacFSSpec2UnixFilename( &spec ) ;
return TRUE; return TRUE;
} }

View File

@@ -20,19 +20,9 @@
#include "wx/cmndata.h" #include "wx/cmndata.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_CLASS(wxDirDialog, wxDialog) IMPLEMENT_CLASS(wxDirDialog, wxDialog)
#endif
enum {
kSelectItem = 10, // select button item number
kSFGetFolderDlgID = 250, // dialog resource number
kStrListID = 250, // our strings
kSelectStrNum = 1, // word 'Select: ' for button
kDesktopStrNum = 2, // word 'Desktop' for button
kSelectNoQuoteStrNum = 3, // word 'Select: ' for button
kUseQuotes = true, // parameter for SetButtonName
kDontUseQuotes = false
};
// 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
@@ -48,6 +38,21 @@ struct UserDataRec {
typedef struct UserDataRec typedef struct UserDataRec
UserDataRec, *UserDataRecPtr; UserDataRec, *UserDataRecPtr;
#if !TARGET_CARBON
enum {
kSelectItem = 10, // select button item number
kSFGetFolderDlgID = 250, // dialog resource number
kStrListID = 250, // our strings
kSelectStrNum = 1, // word 'Select: ' for button
kDesktopStrNum = 2, // word 'Desktop' for button
kSelectNoQuoteStrNum = 3, // word 'Select: ' for button
kUseQuotes = true, // parameter for SetButtonName
kDontUseQuotes = false
};
static void GetLabelString(StringPtr theStr, short stringNum) static void GetLabelString(StringPtr theStr, short stringNum)
{ {
GetIndString(theStr, kStrListID, stringNum); GetIndString(theStr, kStrListID, stringNum);
@@ -302,6 +307,7 @@ static pascal short SFGetFolderDialogHook(short item, DialogPtr theDlgPtr, Ptr d
return item; return item;
} }
#endif
void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileFilterYDUPP fileFilter, StandardFileReply *theSFR) void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileFilterYDUPP fileFilter, StandardFileReply *theSFR)
{ {
@@ -321,7 +327,7 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
// set initial contents of Select button to a space // set initial contents of Select button to a space
CopyPStr("\p ", theSFR->sfFile.name); memcpy(theSFR->sfFile.name, "\p ", 2);
// point the user data parameter at the reply record so we can get to it later // point the user data parameter at the reply record so we can get to it later
@@ -329,6 +335,8 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
// display the dialog // display the dialog
#if !TARGET_CARBON
dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook); dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook);
myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter); myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter);
@@ -350,6 +358,8 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
DisposeRoutineDescriptor(dlgHookUPP); DisposeRoutineDescriptor(dlgHookUPP);
DisposeRoutineDescriptor(myModalFilterUPP); DisposeRoutineDescriptor(myModalFilterUPP);
#else
#endif
// if cancel wasn't pressed and no fatal error occurred... // if cancel wasn't pressed and no fatal error occurred...
@@ -445,14 +455,18 @@ int wxDirDialog::ShowModal()
strcpy((char *)path, m_path ) ; strcpy((char *)path, m_path ) ;
c2pstr((char *)path ) ; c2pstr((char *)path ) ;
FileFilterYDUPP invisiblesExcludedCustomFilterUPP;
StandardFileReply reply ; StandardFileReply reply ;
FileFilterYDUPP invisiblesExcludedCustomFilterUPP = 0 ;
#if !TARGET_CARBON
invisiblesExcludedCustomFilterUPP = invisiblesExcludedCustomFilterUPP =
NewFileFilterYDProc(OnlyVisibleFoldersCustomFileFilter); NewFileFilterYDProc(OnlyVisibleFoldersCustomFileFilter);
#endif
StandardGetFolder( prompt , path , invisiblesExcludedCustomFilterUPP, &reply); StandardGetFolder( prompt , path , invisiblesExcludedCustomFilterUPP, &reply);
#if !TARGET_CARBON
DisposeRoutineDescriptor(invisiblesExcludedCustomFilterUPP); DisposeRoutineDescriptor(invisiblesExcludedCustomFilterUPP);
#endif
if ( reply.sfGood == false ) if ( reply.sfGood == false )
{ {
m_path = "" ; m_path = "" ;

View File

@@ -18,6 +18,8 @@
#include "wx/app.h" #include "wx/app.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#if wxUSE_DRAG_AND_DROP
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global // global
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -131,3 +133,4 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
return wxDragError; return wxDragError;
}; };
#endif

View File

@@ -19,7 +19,9 @@
#include "wx/filedlg.h" #include "wx/filedlg.h"
#include "wx/intl.h" #include "wx/intl.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_CLASS(wxFileDialog, wxDialog) IMPLEMENT_CLASS(wxFileDialog, wxDialog)
#endif
// begin wxmac // begin wxmac
@@ -43,6 +45,27 @@ OSType gfiltersmac[] =
'****' '****'
} ; } ;
// the data we need to pass to our standard file hook routine
// includes a pointer to the dialog, a pointer to the standard
// file reply record (so we can inspect the current selection)
// and a copy of the "previous" file spec of the reply record
// so we can see if the selection has changed
const int kwxMacFileTypes = 10 ;
struct OpenUserDataRec {
StandardFileReply *sfrPtr;
FSSpec oldSelectionFSSpec;
char filter[kwxMacFileTypes][10] ;
OSType filtermactypes[kwxMacFileTypes] ;
int numfilters ;
DialogPtr theDlgPtr;
};
typedef struct OpenUserDataRec
OpenUserDataRec, *OpenUserDataRecPtr;
#if !TARGET_CARBON
static void wxMacSetupStandardFile(short newVRefNum, long newDirID) static void wxMacSetupStandardFile(short newVRefNum, long newDirID)
{ {
enum enum
@@ -97,25 +120,6 @@ enum {
kDontUseQuotes = false kDontUseQuotes = false
}; };
// the data we need to pass to our standard file hook routine
// includes a pointer to the dialog, a pointer to the standard
// file reply record (so we can inspect the current selection)
// and a copy of the "previous" file spec of the reply record
// so we can see if the selection has changed
const int kwxMacFileTypes = 10 ;
struct OpenUserDataRec {
StandardFileReply *sfrPtr;
FSSpec oldSelectionFSSpec;
char filter[kwxMacFileTypes][10] ;
OSType filtermactypes[kwxMacFileTypes] ;
int numfilters ;
DialogPtr theDlgPtr;
};
typedef struct OpenUserDataRec
OpenUserDataRec, *OpenUserDataRecPtr;
static void GetLabelString(StringPtr theStr, short stringNum) static void GetLabelString(StringPtr theStr, short stringNum)
{ {
GetIndString(theStr, kStrListID, stringNum); GetIndString(theStr, kStrListID, stringNum);
@@ -185,6 +189,7 @@ static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRec
return false; return false;
} }
#endif
void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const char *filter , FileFilterYDUPP fileFilter, StandardFileReply *theSFR) void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const char *filter , FileFilterYDUPP fileFilter, StandardFileReply *theSFR)
{ {
@@ -204,7 +209,7 @@ void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const
// set initial contents of Select button to a space // set initial contents of Select button to a space
CopyPStr("\p ", theSFR->sfFile.name); memcpy( theSFR->sfFile.name , "\p " , 2 ) ;
// point the user data parameter at the reply record so we can get to it later // point the user data parameter at the reply record so we can get to it later
@@ -241,6 +246,8 @@ void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const
} }
// display the dialog // display the dialog
#if !TARGET_CARBON
dlgHookUPP = NULL ; dlgHookUPP = NULL ;
// dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook); // dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook);
myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter); myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter);
@@ -263,7 +270,8 @@ void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const
DisposeRoutineDescriptor(dlgHookUPP); DisposeRoutineDescriptor(dlgHookUPP);
DisposeRoutineDescriptor(myModalFilterUPP); DisposeRoutineDescriptor(myModalFilterUPP);
#else
#endif
// if cancel wasn't pressed and no fatal error occurred... // if cancel wasn't pressed and no fatal error occurred...
if (theSFR->sfGood) if (theSFR->sfGood)
@@ -454,8 +462,12 @@ int wxFileDialog::ShowModal()
strcpy((char *)filename, m_fileName) ; strcpy((char *)filename, m_fileName) ;
c2pstr((char *)filename ) ; c2pstr((char *)filename ) ;
#if !TARGET_CARBON
StandardPutFile( prompt , filename , &reply ) ; StandardPutFile( prompt , filename , &reply ) ;
#else
#endif
if ( reply.sfGood == false ) if ( reply.sfGood == false )
{ {
m_path = "" ; m_path = "" ;
@@ -479,14 +491,17 @@ int wxFileDialog::ShowModal()
strcpy((char *)path, m_path ) ; strcpy((char *)path, m_path ) ;
c2pstr((char *)path ) ; c2pstr((char *)path ) ;
FileFilterYDUPP crossPlatformFileFilterUPP;
StandardFileReply reply ; StandardFileReply reply ;
FileFilterYDUPP crossPlatformFileFilterUPP = 0 ;
#if !TARGET_CARBON
crossPlatformFileFilterUPP = crossPlatformFileFilterUPP =
NewFileFilterYDProc(CrossPlatformFileFilter); NewFileFilterYDProc(CrossPlatformFileFilter);
#endif
ExtendedOpenFile( prompt , path , m_wildCard , crossPlatformFileFilterUPP, &reply); ExtendedOpenFile( prompt , path , m_wildCard , crossPlatformFileFilterUPP, &reply);
#if !TARGET_CARBON
DisposeRoutineDescriptor(crossPlatformFileFilterUPP); DisposeFileFilterYDUPP(crossPlatformFileFilterUPP);
#endif
if ( reply.sfGood == false ) if ( reply.sfGood == false )
{ {
m_path = "" ; m_path = "" ;

View File

@@ -18,7 +18,9 @@
#include "wx/font.h" #include "wx/font.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
#endif
@@ -77,7 +79,7 @@ void wxFontRefData::MacFindFont()
::GetFNum( "\pTimes" , &m_macFontNum) ; ::GetFNum( "\pTimes" , &m_macFontNum) ;
break ; break ;
case wxSWISS : case wxSWISS :
::GetFNum( "\pHelvetica" , &m_macFontNum) ; ::GetFNum( "\pGeneva" , &m_macFontNum) ;
break ; break ;
case wxMODERN : case wxMODERN :
::GetFNum( "\pMonaco" , &m_macFontNum) ; ::GetFNum( "\pMonaco" , &m_macFontNum) ;

View File

@@ -17,7 +17,9 @@
#include "wx/mac/fontdlg.h" #include "wx/mac/fontdlg.h"
#include "wx/cmndata.h" #include "wx/cmndata.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog) IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
#endif
/* /*
* wxFontDialog * wxFontDialog

View File

@@ -48,18 +48,12 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// convert to/from the string representation: format is // convert to/from the string representation: format is
// encodingid;facename[;charset] // facename[;charset]
bool wxNativeEncodingInfo::FromString(const wxString& s) bool wxNativeEncodingInfo::FromString(const wxString& s)
{ {
wxStringTokenizer tokenizer(s, _T(";")); wxStringTokenizer tokenizer(s, _T(";"));
wxString encid = tokenizer.GetNextToken();
long enc;
if ( !encid.ToLong(&enc) )
return FALSE;
encoding = (wxFontEncoding)enc;
facename = tokenizer.GetNextToken(); facename = tokenizer.GetNextToken();
if ( !facename ) if ( !facename )
return FALSE; return FALSE;
@@ -85,10 +79,7 @@ bool wxNativeEncodingInfo::FromString(const wxString& s)
wxString wxNativeEncodingInfo::ToString() const wxString wxNativeEncodingInfo::ToString() const
{ {
wxString s; wxString s(facename);
s << (long)encoding << _T(';') << facename;
if ( charset != 0 ) if ( charset != 0 )
{ {
s << _T(';') << charset; s << _T(';') << charset;
@@ -159,8 +150,6 @@ bool wxGetNativeFontEncoding(wxFontEncoding encoding,
return FALSE; return FALSE;
} }
info->encoding = encoding;
return TRUE; return TRUE;
} }

View File

@@ -14,7 +14,7 @@
#endif #endif
#include "wx/frame.h" #include "wx/frame.h"
#include "wx/statusbr.h" #include "wx/mac/statusbr.h"
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/menuitem.h" #include "wx/menuitem.h"
#include "wx/menu.h" #include "wx/menu.h"
@@ -28,16 +28,18 @@
extern wxList wxModelessWindows; extern wxList wxModelessWindows;
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
BEGIN_EVENT_TABLE(wxFrame, wxWindow) #if !USE_SHARED_LIBRARY
EVT_SIZE(wxFrame::OnSize) BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
// EVT_SIZE(wxFrame::OnSize)
EVT_ACTIVATE(wxFrame::OnActivate) EVT_ACTIVATE(wxFrame::OnActivate)
EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) // EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
EVT_IDLE(wxFrame::OnIdle) // EVT_IDLE(wxFrame::OnIdle)
EVT_CLOSE(wxFrame::OnCloseWindow) // EVT_CLOSE(wxFrame::OnCloseWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
#endif
#if wxUSE_NATIVE_STATUSBAR #if wxUSE_NATIVE_STATUSBAR
bool wxFrame::m_useNativeStatusBar = TRUE; bool wxFrame::m_useNativeStatusBar = TRUE;
@@ -45,17 +47,43 @@ bool wxFrame::m_useNativeStatusBar = TRUE;
bool wxFrame::m_useNativeStatusBar = FALSE; bool wxFrame::m_useNativeStatusBar = FALSE;
#endif #endif
wxFrame::wxFrame() #define WX_MAC_STATUSBAR_HEIGHT 15
{ // ----------------------------------------------------------------------------
#if wxUSE_TOOLBAR // creation/destruction
m_frameToolBar = NULL ; // ----------------------------------------------------------------------------
#endif
// in order to be able to give size events on show void wxFrame::Init()
m_frameMenuBar = NULL; {
m_frameStatusBar = NULL; m_iconized = FALSE;
m_iconized = FALSE;
m_isShown = FALSE; #if wxUSE_TOOLTIPS
m_hwndToolTip = 0;
#endif
}
wxPoint wxFrame::GetClientAreaOrigin() const
{
// on mac we are at position -1,-1 with the control
wxPoint pt(0, 0);
#if wxUSE_TOOLBAR
if ( GetToolBar() )
{
int w, h;
GetToolBar()->GetSize(& w, & h);
if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
{
pt.x += w - 1;
}
else
{
pt.y += h - 1 ;
}
}
#endif // wxUSE_TOOLBAR
return pt;
} }
bool wxFrame::Create(wxWindow *parent, bool wxFrame::Create(wxWindow *parent,
@@ -66,13 +94,7 @@ bool wxFrame::Create(wxWindow *parent,
long style, long style,
const wxString& name) const wxString& name)
{ {
if (!parent)
wxTopLevelWindows.Append(this);
SetName(name);
m_windowStyle = style;
m_frameMenuBar = NULL; m_frameMenuBar = NULL;
m_isShown = FALSE;
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
m_frameToolBar = NULL ; m_frameToolBar = NULL ;
@@ -88,74 +110,24 @@ bool wxFrame::Create(wxWindow *parent,
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
if (!parent)
wxTopLevelWindows.Append(this);
MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
wxModelessWindows.Append(this); wxModelessWindows.Append(this);
// create frame.
Rect theBoundsRect;
m_x = (int)pos.x;
m_y = (int)pos.y;
if ( m_y < 50 )
m_y = 50 ;
if ( m_x < 20 )
m_x = 20 ;
m_width = size.x;
if (m_width == -1)
m_width = 20;
m_height = size.y;
if (m_height == -1)
m_height = 20;
m_macWindowData = new MacWindowData() ;
::SetRect(&theBoundsRect, m_x, m_y, m_x + m_width, m_y + m_height);
WindowClass wclass = kDocumentWindowClass ;
WindowAttributes attr = kWindowNoAttributes ;
if ( ( m_windowStyle & wxMINIMIZE_BOX ) || ( m_windowStyle & wxMAXIMIZE_BOX ) )
{
attr |= kWindowFullZoomAttribute ;
attr |= kWindowResizableAttribute ;
}
if ( m_windowStyle & wxSTAY_ON_TOP )
{
wclass = kFloatingWindowClass ;
// if ( m_windowStyle & wxCAPTION )
// attr |= kHasPaletteTitlebarMask ;
}
else
{
}
if ( m_windowStyle & wxSYSTEM_MENU )
{
attr |= kWindowCloseBoxAttribute ;
}
UMACreateNewWindow( wclass , attr , &theBoundsRect , &m_macWindowData->m_macWindow ) ;
wxAssociateWinWithMacWindow( m_macWindowData->m_macWindow , this ) ;
wxString label ;
if( wxApp::s_macDefaultEncodingIsPC )
label = wxMacMakeMacStringFromPC( title ) ;
else
label = title ;
UMASetWTitleC( m_macWindowData->m_macWindow , label ) ;
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
m_macWindowData->m_macFocus = NULL ;
return TRUE; return TRUE;
} }
wxFrame::~wxFrame() wxFrame::~wxFrame()
{ {
m_isBeingDeleted = TRUE;
wxTopLevelWindows.DeleteObject(this); wxTopLevelWindows.DeleteObject(this);
if (m_frameStatusBar) DeleteAllBars();
delete m_frameStatusBar;
if (m_frameMenuBar)
delete m_frameMenuBar;
/* Check if it's the last top-level window */ /* Check if it's the last top-level window */
@@ -173,11 +145,21 @@ wxFrame::~wxFrame()
} }
void wxFrame::Iconize(bool iconize) bool wxFrame::Enable(bool enable)
{ {
// TODO if ( !wxWindow::Enable(enable) )
} return FALSE;
if ( m_frameMenuBar && m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar() )
{
for ( int i = 0 ; i < m_frameMenuBar->GetMenuCount() ; ++ i )
{
m_frameMenuBar->EnableTop( i , enable ) ;
}
}
return TRUE;
}
// Equivalent to maximize/restore in Windows // Equivalent to maximize/restore in Windows
void wxFrame::Maximize(bool maximize) void wxFrame::Maximize(bool maximize)
{ {
@@ -190,6 +172,11 @@ bool wxFrame::IsIconized() const
return FALSE; return FALSE;
} }
void wxFrame::Iconize(bool iconize)
{
// TODO
}
// Is the frame maximized? // Is the frame maximized?
bool wxFrame::IsMaximized(void) const bool wxFrame::IsMaximized(void) const
{ {
@@ -197,10 +184,14 @@ bool wxFrame::IsMaximized(void) const
return FALSE; return FALSE;
} }
void wxFrame::Restore()
{
// TODO
}
void wxFrame::SetIcon(const wxIcon& icon) void wxFrame::SetIcon(const wxIcon& icon)
{ {
m_icon = icon; wxFrameBase::SetIcon(icon);
// TODO
} }
wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id, wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
@@ -208,61 +199,12 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
{ {
wxStatusBar *statusBar = NULL; wxStatusBar *statusBar = NULL;
statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 17), statusBar = new wxStatusBar(this, id, style, name);
style, name);
// Set the height according to the font and the border size
// we shouldn't do this on the mac, because we have to fit the grow box
/*
wxClientDC dc(statusBar);
dc.SetFont(statusBar->GetFont());
long x, y;
dc.GetTextExtent("X", &x, &y);
int height = (int)( (y * 1.1) + 2* statusBar->GetBorderY());
statusBar->SetSize(-1, -1, 100, height);
*/
statusBar->SetFieldsCount(number); statusBar->SetFieldsCount(number);
return statusBar; return statusBar;
} }
wxStatusBar* wxFrame::CreateStatusBar(int number, long style, wxWindowID id,
const wxString& name)
{
// Calling CreateStatusBar twice is an error.
wxCHECK_MSG( m_frameStatusBar == NULL, FALSE,
"recreating status bar in wxFrame" );
m_frameStatusBar = OnCreateStatusBar(number, style, id,
name);
if ( m_frameStatusBar )
{
PositionStatusBar();
return m_frameStatusBar;
}
else
return NULL;
}
void wxFrame::SetStatusText(const wxString& text, int number)
{
wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" );
m_frameStatusBar->SetStatusText(text, number);
}
void wxFrame::SetStatusWidths(int n, const int widths_field[])
{
wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" );
m_frameStatusBar->SetStatusWidths(n, widths_field);
PositionStatusBar();
}
void wxFrame::PositionStatusBar() void wxFrame::PositionStatusBar()
{ {
if (m_frameStatusBar ) if (m_frameStatusBar )
@@ -274,7 +216,7 @@ void wxFrame::PositionStatusBar()
// Since we wish the status bar to be directly under the client area, // Since we wish the status bar to be directly under the client area,
// we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
m_frameStatusBar->SetSize(0, h, w, sh); m_frameStatusBar->SetSize(0, h, w, WX_MAC_STATUSBAR_HEIGHT );
} }
} }
@@ -282,43 +224,15 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar)
{ {
if (!menuBar) if (!menuBar)
{ {
m_frameMenuBar = NULL;
return; return;
} }
m_frameMenuBar = NULL;
m_frameMenuBar = menuBar; m_frameMenuBar = menuBar;
// TODO : we move this into the app code
m_frameMenuBar->MacInstallMenuBar() ; m_frameMenuBar->MacInstallMenuBar() ;
m_frameMenuBar->Attach(this);
} }
void wxFrame::Fit()
{
// Work out max. size
wxNode *node = GetChildren().First();
int max_width = 0;
int max_height = 0;
while (node)
{
// Find a child that's a subwindow, but not a dialog box.
wxWindow *win = (wxWindow *)node->Data();
if (!win->IsKindOf(CLASSINFO(wxFrame)) &&
!win->IsKindOf(CLASSINFO(wxDialog)))
{
int width, height;
int x, y;
win->GetSize(&width, &height);
win->GetPosition(&x, &y);
if ((x + width) > max_width)
max_width = x + width;
if ((y + height) > max_height)
max_height = y + height;
}
node = node->Next();
}
SetClientSize(max_width, max_height);
}
// Responds to colour changes, and passes event on to children. // Responds to colour changes, and passes event on to children.
void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
@@ -337,217 +251,55 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
wxWindow::OnSysColourChanged(event); wxWindow::OnSysColourChanged(event);
} }
// Default resizing behaviour - if only ONE subwindow,
// resize to client rectangle size
void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) )
{
DoMenuUpdates();
}
// update all menus
void wxFrame::DoMenuUpdates()
{
wxMenuBar* bar = GetMenuBar();
if ( bar != NULL )
{
int nCount = bar->GetMenuCount();
for (int n = 0; n < nCount; n++)
DoMenuUpdates(bar->GetMenu(n), (wxWindow*) NULL);
}
}
// update a menu and all submenus recursively
void wxFrame::DoMenuUpdates(wxMenu* menu, wxWindow* WXUNUSED(focusWin))
{
wxEvtHandler* evtHandler = GetEventHandler();
wxMenuItemList::Node* node = menu->GetMenuItems().GetFirst();
while (node)
{
wxMenuItem* item = node->GetData();
if ( !item->IsSeparator() )
{
wxWindowID id = item->GetId();
wxUpdateUIEvent event(id);
event.SetEventObject( this );
if (evtHandler->ProcessEvent(event))
{
if (event.GetSetText())
menu->SetLabel(id, event.GetText());
if (event.GetSetChecked())
menu->Check(id, event.GetChecked());
if (event.GetSetEnabled())
menu->Enable(id, event.GetEnabled());
}
if (item->GetSubMenu())
DoMenuUpdates(item->GetSubMenu(), (wxWindow*) NULL);
}
node = node->GetNext();
}
}
void wxFrame::OnSize(wxSizeEvent& event)
{
// if we're using constraints - do use them
#if wxUSE_CONSTRAINTS
if ( GetAutoLayout() ) {
Layout();
return;
}
#endif
// do we have _exactly_ one child?
wxWindow *child = NULL;
for ( wxNode *node = GetChildren().First(); node; node = node->Next() )
{
wxWindow *win = (wxWindow *)node->Data();
if ( !win->IsKindOf(CLASSINFO(wxFrame)) &&
!win->IsKindOf(CLASSINFO(wxDialog)) &&
(win != GetStatusBar())
#if wxUSE_TOOLBAR
&&
(win != GetToolBar())
#endif
)
{
if ( child )
return; // it's our second subwindow - nothing to do
child = win;
}
}
if ( child ) {
// we have exactly one child - set it's size to fill the whole frame
int clientW, clientH;
GetClientSize(&clientW, &clientH);
int x = 0;
int y = 0;
child->SetSize(x, y, clientW, clientH);
}
}
// Default activation behaviour - set the focus for the first child // Default activation behaviour - set the focus for the first child
// subwindow found. // subwindow found.
void wxFrame::OnActivate(wxActivateEvent& event) void wxFrame::OnActivate(wxActivateEvent& event)
{ {
for(wxNode *node = GetChildren().First(); node; node = node->Next()) if ( !event.GetActive() )
{
// Find a child that's a subwindow, but not a dialog box.
wxWindow *child = (wxWindow *)node->Data();
if (!child->IsKindOf(CLASSINFO(wxFrame)) &&
!child->IsKindOf(CLASSINFO(wxDialog)))
{ {
child->SetFocus(); event.Skip();
return; return;
} }
}
}
// The default implementation for the close window event. for ( wxWindowList::Node *node = GetChildren().GetFirst();
void wxFrame::OnCloseWindow(wxCloseEvent& event) node;
{ node = node->GetNext() )
this->Destroy();
}
// Destroy the window (delayed, if a managed window)
bool wxFrame::Destroy()
{
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
return TRUE;
}
// Default menu selection behaviour - display a help string
void wxFrame::OnMenuHighlight(wxMenuEvent& event)
{
if (GetStatusBar())
{
if (event.GetMenuId() == -1)
SetStatusText("");
else
{ {
wxMenuBar *menuBar = GetMenuBar(); // FIXME all this is totally bogus - we need to do the same as wxPanel,
if (menuBar) // but how to do it without duplicating the code?
{
wxString helpString(menuBar->GetHelpString(event.GetMenuId()));
if (helpString != "")
SetStatusText(helpString);
}
}
}
}
wxMenuBar *wxFrame::GetMenuBar() const // restore focus
{ wxWindow *child = node->GetData();
return m_frameMenuBar;
}
if ( !child->IsTopLevel()
// Call this to simulate a menu command
void wxFrame::Command(int id)
{
ProcessCommand(id);
}
void wxFrame::ProcessCommand(int id)
{
wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id);
commandEvent.SetInt( id );
commandEvent.SetEventObject( this );
wxMenuBar *bar = GetMenuBar() ;
if (!bar)
return;
/* TODO: check the menu item if required
wxMenuItem *item = bar->FindItemForId(id) ;
if (item && item->IsCheckable())
{
bar->Check(id,!bar->Checked(id)) ;
}
*/
GetEventHandler()->ProcessEvent(commandEvent);
}
// Checks if there is a toolbar, and returns the first free client position
wxPoint wxFrame::GetClientAreaOrigin() const
{
wxPoint pt(0, 0);
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
if (GetToolBar()) && !wxDynamicCast(child, wxToolBar)
{ #endif // wxUSE_TOOLBAR
int w, h; #if wxUSE_STATUSBAR
GetToolBar()->GetSize(& w, & h); && !wxDynamicCast(child, wxStatusBar)
#endif // wxUSE_STATUSBAR
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) )
{ {
pt.x += w; child->SetFocus();
} return;
else
{
pt.y += h;
} }
} }
#endif
return pt;
} }
void wxFrame::DoGetClientSize(int *x, int *y) const void wxFrame::DoGetClientSize(int *x, int *y) const
{ {
wxWindow::DoGetClientSize( x , y ) ; wxWindow::DoGetClientSize( x , y ) ;
#if wxUSE_STATUSBAR
if ( GetStatusBar() ) if ( GetStatusBar() )
{ {
int statusX, statusY; int statusX, statusY;
GetStatusBar()->GetClientSize(&statusX, &statusY); GetStatusBar()->GetClientSize(&statusX, &statusY);
*y -= statusY; // right now this is a constant, this might change someday
*y -= WX_MAC_STATUSBAR_HEIGHT ;
} }
#endif // wxUSE_STATUSBAR
wxPoint pt(GetClientAreaOrigin()); wxPoint pt(GetClientAreaOrigin());
*y -= pt.y; *y -= pt.y;
@@ -576,39 +328,20 @@ void wxFrame::DoSetClientSize(int clientwidth, int clientheight)
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
{ {
wxCHECK_MSG( m_frameToolBar == NULL, FALSE, if ( wxFrameBase::CreateToolBar(style, id, name) )
"recreating toolbar in wxFrame" );
wxToolBar* toolBar = OnCreateToolBar(style, id, name);
if (toolBar)
{ {
SetToolBar(toolBar);
PositionToolBar(); PositionToolBar();
return toolBar;
} }
else
{
return NULL;
}
}
wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name) return m_frameToolBar;
{
return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name);
} }
void wxFrame::PositionToolBar() void wxFrame::PositionToolBar()
{ {
int cw, ch; int cw, ch;
// TODO: we actually need to use the low-level client size, before cw = m_width ;
// the toolbar/status bar were added. ch = m_height ;
// So DEFINITELY replace the line below with something appropriate.
// GetClientSize(& cw, &ch);
cw = m_width ;
ch = m_height ;
if ( GetStatusBar() ) if ( GetStatusBar() )
{ {
@@ -627,12 +360,12 @@ void wxFrame::PositionToolBar()
// Use the 'real' position. wxSIZE_NO_ADJUSTMENTS // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
// means, pretend we don't have toolbar/status bar, so we // means, pretend we don't have toolbar/status bar, so we
// have the original client size. // have the original client size.
GetToolBar()->SetSize(0, 0, tw, ch, wxSIZE_NO_ADJUSTMENTS); GetToolBar()->SetSize(-1, -1, tw, ch + 2 , wxSIZE_NO_ADJUSTMENTS | wxSIZE_ALLOW_MINUS_ONE );
} }
else else
{ {
// Use the 'real' position // Use the 'real' position
GetToolBar()->SetSize(0, 0, cw, th, wxSIZE_NO_ADJUSTMENTS); GetToolBar()->SetSize(-1, -1, cw + 2, th, wxSIZE_NO_ADJUSTMENTS | wxSIZE_ALLOW_MINUS_ONE );
} }
} }
} }

View File

@@ -15,7 +15,9 @@
#include "wx/gauge.h" #include "wx/gauge.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
#endif
#include <wx/mac/uma.h> #include <wx/mac/uma.h>
@@ -31,15 +33,13 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
m_rangeMax = range ; m_rangeMax = range ;
m_macHorizontalBorder = 2 ; // additional pixels around the real control
m_macVerticalBorder = 2 ;
if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y) if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y)
{ {
size = wxSize( 200 , 16 ) ; size = wxSize( 200 , 16 ) ;
} }
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , "" , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ;
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , range, m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , range,
kControlProgressBarProc , (long) this ) ; kControlProgressBarProc , (long) this ) ;
@@ -66,7 +66,7 @@ void wxGauge::SetRange(int r)
void wxGauge::SetValue(int pos) void wxGauge::SetValue(int pos)
{ {
m_gaugePos = pos; m_gaugePos = pos;
::SetControlValue( m_macControl , m_gaugePos ) ; ::SetControlValue( m_macControl , m_gaugePos ) ;
} }
int wxGauge::GetShadowWidth() const int wxGauge::GetShadowWidth() const

Some files were not shown because too many files have changed in this diff Show More