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:
@@ -17,7 +17,9 @@
|
||||
#include "wx/accel.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject)
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData
|
||||
{
|
||||
|
||||
149
src/mac/aga.cpp
149
src/mac/aga.cpp
@@ -1,3 +1,5 @@
|
||||
#if !TARGET_CARBON
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
#include <wx/mac/aga.h>
|
||||
#include <extcdef.h>
|
||||
@@ -600,6 +602,10 @@ void AGADeactivateControl( ControlHandle inControl )
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
::HiliteControl( inControl , 255 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void AGAActivateControl( ControlHandle inControl )
|
||||
@@ -615,6 +621,10 @@ void AGAActivateControl( ControlHandle inControl )
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
::HiliteControl( inControl , 0 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
OSErr AGASetKeyboardFocus (WindowPtr inWindow,
|
||||
@@ -718,6 +728,7 @@ void DisposeExtCDEFInfo( ControlHandle theControl)
|
||||
DisposeHandle( info->children ) ;
|
||||
info->children = NULL ;
|
||||
free( (void*) (**theControl).contrlRfCon ) ;
|
||||
(**theControl).contrlRfCon = NULL ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -922,51 +933,6 @@ void AGASetFontStyle( ControlFontStyleRec *fontstyle )
|
||||
::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)
|
||||
{
|
||||
switch( message )
|
||||
@@ -1079,7 +1045,7 @@ pascal SInt32 AGABevelButtonDefProc (SInt16 procID, ControlHandle theControl, Co
|
||||
return 0 ;
|
||||
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
Boolean mRadioBehavior = false ;
|
||||
|
||||
@@ -1219,7 +1185,7 @@ pascal SInt32 AGAButtonDefProc (SInt16 procID, ControlHandle theControl, Control
|
||||
return 0 ;
|
||||
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
Boolean mRadioBehavior = false ;
|
||||
|
||||
@@ -1456,7 +1422,7 @@ pascal SInt32 AGACheckBoxDefProc (SInt16 procID, ControlHandle theControl, Contr
|
||||
return 0 ;
|
||||
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
Rect frame = (**theControl).contrlRect ;
|
||||
Boolean hasColor = true;
|
||||
Boolean disabled = (*theControl)->contrlHilite == 255 ;
|
||||
@@ -1844,7 +1810,7 @@ pascal SInt32 AGAStaticGroupBoxTextDefProc (SInt16 procID, ControlHandle theCont
|
||||
{
|
||||
bool disabled = false ;
|
||||
bool hasColor = true ;
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
FontInfo fi ;
|
||||
::GetFontInfo( &fi ) ;
|
||||
@@ -1930,7 +1896,7 @@ pascal SInt32 AGAStaticTextDefProc (SInt16 procID, ControlHandle theControl, Con
|
||||
return 0 ;
|
||||
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
int x = (**theControl).contrlRect.left ;
|
||||
int y = (**theControl).contrlRect.top ;
|
||||
@@ -2125,7 +2091,7 @@ pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, Contr
|
||||
{
|
||||
case initCntl :
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
SetPort( (**theControl).contrlOwner ) ;
|
||||
::TextFont( kFontIDGeneva ) ;
|
||||
::TextSize( 10 ) ;
|
||||
@@ -2147,7 +2113,7 @@ pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, Contr
|
||||
break ;
|
||||
case drawCntl :
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
SetPort( (**theControl).contrlOwner ) ;
|
||||
RGBBackColor( &gAGARamp[ kAGAWhite ] ) ;
|
||||
@@ -2254,9 +2220,8 @@ pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, Contr
|
||||
break ;
|
||||
case kControlMsgKeyDown :
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help( (**theControl).contrlOwner ) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
SetPort( (**theControl).contrlOwner ) ;
|
||||
RGBBackColor( &gAGARamp[ kAGAWhite ] ) ;
|
||||
RGBForeColor( &gAGARamp[ kAGABlack ] ) ;
|
||||
ControlKeyDownRec * rec = (ControlKeyDownRec*) param ;
|
||||
@@ -2364,7 +2329,7 @@ pascal SInt32 AGAListControlDefProc (SInt16 procID, ControlHandle theControl, Co
|
||||
break ;
|
||||
case drawCntl :
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
RGBBackColor( &gAGARamp[ kAGAWhite ] ) ;
|
||||
EraseRect( &(**theControl).contrlRect ) ;
|
||||
@@ -2578,4 +2543,78 @@ void AGASetThemeWindowBackground (WindowRef inWindow,
|
||||
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 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
349
src/mac/app.cpp
349
src/mac/app.cpp
@@ -28,7 +28,7 @@
|
||||
#include "wx/log.h"
|
||||
#include "wx/module.h"
|
||||
#include "wx/memory.h"
|
||||
|
||||
#include "wx/tooltip.h"
|
||||
#if wxUSE_WX_RESOURCES
|
||||
#include "wx/resource.h"
|
||||
#endif
|
||||
@@ -44,6 +44,12 @@
|
||||
#include "apprsrc.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 wxList wxPendingDelete;
|
||||
@@ -52,10 +58,14 @@ extern wxList *wxWinMacControlList;
|
||||
|
||||
wxApp *wxTheApp = NULL;
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
|
||||
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
|
||||
EVT_IDLE(wxApp::OnIdle)
|
||||
EVT_END_SESSION(wxApp::OnEndSession)
|
||||
EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
|
||||
const short kMacMinHeap = (29 * 1024) ;
|
||||
@@ -76,25 +86,25 @@ bool wxApp::s_macSupportPCMenuShortcuts = true ;
|
||||
long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
|
||||
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 ;
|
||||
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 ;
|
||||
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 ;
|
||||
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 ;
|
||||
return wxTheApp->MacHandleAEQuit( event , reply) ;
|
||||
@@ -133,14 +143,14 @@ OSErr wxApp::MacHandleAEQuit(AppleEvent *event , AppleEvent *reply)
|
||||
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"
|
||||
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf"
|
||||
"\xb1\xb4\xb5\xb6\xbb\xbc\xbe\xbf"
|
||||
"\xc0\xc1\xc2\xc4\xc7\xc8\xc9\xcb\xcc\xcd\xce\xcf"
|
||||
"\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"
|
||||
"\x86\xBA\xA2\xA3\xA7\x95\xB6\xDF\xAE\xA9\x99\xB4\xA8\xC6\xD8"
|
||||
"\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 , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , (long) wxTheApp , FALSE ) ;
|
||||
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , (long) wxTheApp , FALSE ) ;
|
||||
#if 0
|
||||
GUSISetup(GUSIwithInternetSockets);
|
||||
#endif
|
||||
|
||||
|
||||
// test the minimal configuration necessary
|
||||
@@ -378,7 +385,7 @@ bool wxApp::Initialize()
|
||||
}
|
||||
|
||||
#if __option(profile)
|
||||
ProfilerInit( collectDetailed, bestTimeBase , 20000 , 30 ) ;
|
||||
ProfilerInit( collectDetailed, bestTimeBase , 20000 , 40 ) ;
|
||||
#endif
|
||||
|
||||
// now avoid exceptions thrown for new (bad_alloc)
|
||||
@@ -393,17 +400,15 @@ bool wxApp::Initialize()
|
||||
wxBuffer = new char[BUFSIZ + 512];
|
||||
#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();
|
||||
|
||||
#if wxUSE_RESOURCES
|
||||
// wxGetResource(wxT("wxWindows"), wxT("OsVersion"), &wxOsVersion);
|
||||
#endif
|
||||
|
||||
#if wxUSE_THREADS
|
||||
wxPendingEventsLocker = new wxCriticalSection;
|
||||
#endif
|
||||
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
|
||||
wxTheColourDatabase->Initialize();
|
||||
|
||||
@@ -423,13 +428,29 @@ bool wxApp::Initialize()
|
||||
wxWinMacWindowList = new wxList(wxKEY_INTEGER);
|
||||
wxWinMacControlList = new wxList(wxKEY_INTEGER);
|
||||
|
||||
UMAShowArrowCursor() ;
|
||||
wxMacCreateNotifierTable() ;
|
||||
|
||||
UMAShowArrowCursor() ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
#if wxUSE_WX_RESOURCES
|
||||
@@ -438,19 +459,8 @@ void wxApp::CleanUp()
|
||||
|
||||
wxDeleteStockObjects() ;
|
||||
|
||||
// Destroy all GDI lists, etc.
|
||||
|
||||
delete wxTheBrushList;
|
||||
wxTheBrushList = NULL;
|
||||
|
||||
delete wxThePenList;
|
||||
wxThePenList = NULL;
|
||||
|
||||
delete wxTheFontList;
|
||||
wxTheFontList = NULL;
|
||||
|
||||
delete wxTheBitmapList;
|
||||
wxTheBitmapList = NULL;
|
||||
// Destroy all GDI lists, etc.
|
||||
wxDeleteStockLists();
|
||||
|
||||
delete wxTheColourDatabase;
|
||||
wxTheColourDatabase = NULL;
|
||||
@@ -460,9 +470,17 @@ void wxApp::CleanUp()
|
||||
delete[] wxBuffer;
|
||||
wxBuffer = NULL;
|
||||
|
||||
wxMacDestroyNotifierTable() ;
|
||||
if (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();
|
||||
|
||||
#if __option(profile)
|
||||
@@ -474,33 +492,33 @@ void wxApp::CleanUp()
|
||||
wxTheApp = NULL;
|
||||
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
// At this point we want to check if there are any memory
|
||||
// blocks that aren't part of the wxDebugContext itself,
|
||||
// as a special case. Then when dumping we need to ignore
|
||||
// wxDebugContext, too.
|
||||
if (wxDebugContext::CountObjectsLeft() > 0)
|
||||
{
|
||||
wxTrace("There were memory leaks.\n");
|
||||
wxDebugContext::Dump();
|
||||
wxDebugContext::PrintStatistics();
|
||||
}
|
||||
// wxDebugContext::SetStream(NULL, NULL);
|
||||
// At this point we want to check if there are any memory
|
||||
// blocks that aren't part of the wxDebugContext itself,
|
||||
// as a special case. Then when dumping we need to ignore
|
||||
// wxDebugContext, too.
|
||||
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
|
||||
{
|
||||
wxLogDebug(wxT("There were memory leaks."));
|
||||
wxDebugContext::Dump();
|
||||
wxDebugContext::PrintStatistics();
|
||||
}
|
||||
// wxDebugContext::SetStream(NULL, NULL);
|
||||
#endif
|
||||
|
||||
// do it as the very last thing because everything else can log messages
|
||||
wxLog::DontCreateOnDemand();
|
||||
// do it as the very last thing because everything else can log messages
|
||||
delete wxLog::SetActiveTarget(NULL);
|
||||
#if wxUSE_LOG
|
||||
// do it as the very last thing because everything else can log messages
|
||||
delete wxLog::SetActiveTarget(NULL);
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
::PrClose() ;
|
||||
if (s_macCursorRgn)
|
||||
::DisposeRgn(s_macCursorRgn);
|
||||
|
||||
#if 0
|
||||
TerminateAE() ;
|
||||
#endif
|
||||
}
|
||||
|
||||
int wxEntry( int argc, char *argv[] )
|
||||
int wxEntry( int argc, char *argv[] , bool enterLoop )
|
||||
{
|
||||
#ifdef __MWERKS__
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
@@ -513,27 +531,24 @@ int wxEntry( int argc, char *argv[] )
|
||||
wxDebugContext::SetCheckpoint();
|
||||
#endif
|
||||
#endif
|
||||
if (!wxApp::Initialize())
|
||||
return FALSE;
|
||||
if (!wxTheApp)
|
||||
{
|
||||
if (!wxApp::GetInitializerFunction())
|
||||
if (!wxApp::Initialize())
|
||||
return 0;
|
||||
// create the application object or ensure that one already exists
|
||||
if (!wxTheApp)
|
||||
{
|
||||
printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" );
|
||||
return 0;
|
||||
};
|
||||
// The app may have declared a global application object, but we recommend
|
||||
// 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)
|
||||
{
|
||||
printf( "wxWindows error: wxTheApp == NULL\n" );
|
||||
return 0;
|
||||
};
|
||||
wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
|
||||
|
||||
#ifdef __WXMAC__
|
||||
argc = 1 ; // currently we don't support files as parameters
|
||||
argc = 0 ; // currently we don't support files as parameters
|
||||
#endif
|
||||
|
||||
wxTheApp->argc = argc;
|
||||
@@ -549,42 +564,58 @@ int wxEntry( int argc, char *argv[] )
|
||||
// into wxTopLevelWindows by getting created
|
||||
// in OnInit().
|
||||
|
||||
if (!wxTheApp->OnInit()) return 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())
|
||||
{
|
||||
delete wxTheApp->GetTopWindow();
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
}
|
||||
wxWindow *topWindow = wxTheApp->GetTopWindow();
|
||||
if ( topWindow )
|
||||
{
|
||||
// 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
|
||||
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||
|
||||
wxApp::wxApp()
|
||||
{
|
||||
m_topWindow = NULL;
|
||||
wxTheApp = this;
|
||||
m_className = "";
|
||||
|
||||
m_wantDebugOutput = TRUE ;
|
||||
m_appName = "";
|
||||
|
||||
argc = 0;
|
||||
argv = NULL;
|
||||
|
||||
m_printMode = wxPRINT_WINDOWS;
|
||||
|
||||
m_exitOnFrameDelete = TRUE;
|
||||
m_auto3D = TRUE;
|
||||
}
|
||||
@@ -640,13 +671,14 @@ void wxApp::Dispatch()
|
||||
|
||||
void wxApp::OnIdle(wxIdleEvent& event)
|
||||
{
|
||||
static bool inOnIdle = FALSE;
|
||||
static bool s_inOnIdle = FALSE;
|
||||
|
||||
// Avoid recursion (via ProcessEvent default case)
|
||||
if (inOnIdle)
|
||||
return;
|
||||
// Avoid recursion (via ProcessEvent default case)
|
||||
if ( s_inOnIdle )
|
||||
return;
|
||||
|
||||
inOnIdle = TRUE;
|
||||
|
||||
s_inOnIdle = TRUE;
|
||||
|
||||
// 'Garbage' collection of windows deleted with Close().
|
||||
DeletePendingObjects();
|
||||
@@ -662,13 +694,17 @@ void wxApp::OnIdle(wxIdleEvent& event)
|
||||
if (needMore)
|
||||
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()
|
||||
{
|
||||
// **** please implement me! ****
|
||||
// Wake up the idle handler processor, even if it is in another thread...
|
||||
wxMacWakeUp() ;
|
||||
}
|
||||
|
||||
// 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
|
||||
{
|
||||
if (m_topWindow)
|
||||
return m_topWindow;
|
||||
else if (wxTopLevelWindows.Number() > 0)
|
||||
return (wxWindow*) wxTopLevelWindows.First()->Data();
|
||||
else
|
||||
return NULL;
|
||||
case wxICON_QUESTION:
|
||||
return wxIcon("wxICON_QUESTION");
|
||||
|
||||
case wxICON_EXCLAMATION:
|
||||
return wxIcon("wxICON_WARNING");
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(wxT("requested non existent standard icon"));
|
||||
// still fall through
|
||||
|
||||
case wxICON_HAND:
|
||||
return wxIcon("wxICON_ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
void wxExit()
|
||||
{
|
||||
wxApp::CleanUp();
|
||||
wxLogError(_("Fatal error: exiting"));
|
||||
|
||||
wxApp::CleanUp();
|
||||
::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
|
||||
bool wxYield()
|
||||
{
|
||||
// YieldToAnyThread() ;
|
||||
SystemTask() ;
|
||||
#if wxUSE_THREADS
|
||||
YieldToAnyThread() ;
|
||||
#endif
|
||||
EventRecord event ;
|
||||
|
||||
long sleepTime = 0 ; //::GetCaretTime();
|
||||
|
||||
while ( !wxTheApp->IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, wxApp::s_macCursorRgn))
|
||||
{
|
||||
wxTheApp->MacHandleOneEvent( &event );
|
||||
}
|
||||
|
||||
wxMacProcessNotifierAndPendingEvents() ;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -762,6 +842,12 @@ bool wxYield()
|
||||
|
||||
void wxApp::MacSuspend( bool convertClipboard )
|
||||
{
|
||||
// we have to deactive the window manually
|
||||
|
||||
wxWindow* window = GetTopWindow() ;
|
||||
if ( window )
|
||||
window->MacActivate( MacGetCurrentEvent() , false ) ;
|
||||
|
||||
s_lastMouseDown = 0 ;
|
||||
if( convertClipboard )
|
||||
{
|
||||
@@ -784,13 +870,10 @@ void wxApp::MacResume( bool convertClipboard )
|
||||
|
||||
void wxApp::MacConvertPrivateToPublicScrap()
|
||||
{
|
||||
::ZeroScrap();
|
||||
::TEToScrap();
|
||||
}
|
||||
|
||||
void wxApp::MacConvertPublicToPrivateScrap()
|
||||
{
|
||||
::TEFromScrap() ;
|
||||
}
|
||||
|
||||
void wxApp::MacDoOneEvent()
|
||||
@@ -817,9 +900,7 @@ void wxApp::MacDoOneEvent()
|
||||
|
||||
// repeaters
|
||||
|
||||
#if 0
|
||||
wxMacProcessSocketEvents() ;
|
||||
#endif
|
||||
wxMacProcessNotifierAndPendingEvents() ;
|
||||
}
|
||||
|
||||
void wxApp::MacHandleOneEvent( EventRecord *ev )
|
||||
@@ -874,6 +955,7 @@ void wxApp::MacHandleOneEvent( EventRecord *ev )
|
||||
default:
|
||||
break;
|
||||
}
|
||||
wxMacProcessNotifierAndPendingEvents() ;
|
||||
}
|
||||
|
||||
void wxApp::MacHandleHighLevelEvent( EventRecord *ev )
|
||||
@@ -885,6 +967,8 @@ bool s_macIsInModalLoop = false ;
|
||||
|
||||
void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
{
|
||||
wxToolTip::RemoveToolTips() ;
|
||||
|
||||
WindowRef window;
|
||||
WindowRef frontWindow = UMAFrontNonFloatingWindow() ;
|
||||
WindowAttributes frontWindowAttributes = NULL ;
|
||||
@@ -894,6 +978,9 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
short windowPart = ::FindWindow(ev->where, &window);
|
||||
wxWindow* win = wxFindWinFromMacWindow( window ) ;
|
||||
|
||||
BitMap screenBits;
|
||||
GetQDGlobalsScreenBits( &screenBits );
|
||||
|
||||
switch (windowPart)
|
||||
{
|
||||
case inMenuBar :
|
||||
@@ -908,10 +995,12 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
s_lastMouseDown = 0;
|
||||
}
|
||||
break ;
|
||||
#if !TARGET_CARBON
|
||||
case inSysWindow :
|
||||
SystemClick( ev , window ) ;
|
||||
s_lastMouseDown = 0;
|
||||
break ;
|
||||
#endif
|
||||
case inDrag :
|
||||
if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) )
|
||||
{
|
||||
@@ -919,13 +1008,17 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
}
|
||||
else
|
||||
{
|
||||
DragWindow(window, ev->where, &qd.screenBits.bounds);
|
||||
DragWindow(window, ev->where, &screenBits.bounds);
|
||||
if (win)
|
||||
{
|
||||
GrafPtr port ;
|
||||
GetPort( &port ) ;
|
||||
Point pt = { 0, 0 } ;
|
||||
SetPort( window ) ;
|
||||
#if TARGET_CARBON
|
||||
SetPort( GetWindowPort(window) ) ;
|
||||
#else
|
||||
SetPort( (window) ) ;
|
||||
#endif
|
||||
SetOrigin( 0 , 0 ) ;
|
||||
LocalToGlobal( &pt ) ;
|
||||
SetPort( port ) ;
|
||||
@@ -944,7 +1037,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
s_lastMouseDown = 0;
|
||||
break;
|
||||
case inGrow:
|
||||
int growResult = GrowWindow(window , ev->where, &qd.screenBits.bounds);
|
||||
int growResult = GrowWindow(window , ev->where, &screenBits.bounds);
|
||||
if (growResult != 0)
|
||||
{
|
||||
int newWidth = LoWord(growResult);
|
||||
@@ -969,8 +1062,13 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
// TODO setup size event
|
||||
ZoomWindow( window , windowPart , false ) ;
|
||||
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;
|
||||
break;
|
||||
@@ -980,6 +1078,17 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
break ;
|
||||
|
||||
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 ( s_macIsInModalLoop )
|
||||
@@ -1140,6 +1249,8 @@ long wxMacTranslateKey(unsigned char key, unsigned char code)
|
||||
|
||||
void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
||||
{
|
||||
wxToolTip::RemoveToolTips() ;
|
||||
|
||||
UInt32 menuresult = UMAMenuEvent(ev) ;
|
||||
if ( HiWord( menuresult ) )
|
||||
MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
|
||||
@@ -1268,12 +1379,14 @@ void wxApp::MacHandleDiskEvent( EventRecord *ev )
|
||||
{
|
||||
if ( HiWord( ev->message ) != noErr )
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
OSErr err ;
|
||||
Point point ;
|
||||
SetPt( &point , 100 , 100 ) ;
|
||||
|
||||
err = DIBadMount( point , ev->message ) ;
|
||||
err = DIBadMount( point , ev->message ) ;
|
||||
wxASSERT( err == noErr ) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,10 @@ extern "C"
|
||||
#include "xpm.h"
|
||||
} ;
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
|
||||
#endif
|
||||
|
||||
#include <PictUtils.h>
|
||||
|
||||
@@ -69,16 +71,7 @@ GWorldPtr wxMacCreateGWorld( int height , int width , int depth )
|
||||
|
||||
if ( depth < 0 )
|
||||
{
|
||||
// get max pixel depth
|
||||
CGrafPtr port ;
|
||||
GetCWMgrPort( &port ) ;
|
||||
GDHandle maxDevice ;
|
||||
|
||||
maxDevice = GetMaxDevice( &port->portRect ) ;
|
||||
if ( maxDevice )
|
||||
depth = (**((**maxDevice).gdPMap)).pixelSize ;
|
||||
else
|
||||
depth = 8 ;
|
||||
depth = wxDisplayDepth() ;
|
||||
}
|
||||
|
||||
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 ) ;
|
||||
SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
|
||||
LockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ;
|
||||
|
||||
// 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 ) ;
|
||||
}
|
||||
@@ -514,6 +509,8 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
||||
}
|
||||
|
||||
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() ;
|
||||
|
||||
// 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 ) ;
|
||||
|
||||
return TRUE;
|
||||
@@ -712,8 +711,8 @@ bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
|
||||
if (dc)
|
||||
{
|
||||
if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap))
|
||||
{ /* for following SetPixel */
|
||||
/* fill the XImage struct 'by hand' */
|
||||
{
|
||||
|
||||
ximage.width = M_BITMAPHANDLERDATA->m_width;
|
||||
ximage.height = M_BITMAPHANDLERDATA->m_height;
|
||||
ximage.depth = M_BITMAPHANDLERDATA->m_depth;
|
||||
@@ -725,7 +724,7 @@ bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
|
||||
DeleteDC(dc);
|
||||
|
||||
if (errorStatus == XpmSuccess)
|
||||
return TRUE; /* no error */
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
} else return FALSE;
|
||||
@@ -809,19 +808,6 @@ bool wxBMPResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
// 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
|
||||
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
|
||||
wxPalette *palette = NULL;
|
||||
bool success = FALSE;
|
||||
/*
|
||||
if (type & wxBITMAP_DISCARD_COLOURMAP)
|
||||
success = wxLoadIntoBitmap(WXSTRINGCAST name, bitmap);
|
||||
else
|
||||
*/
|
||||
success = (wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0);
|
||||
if (!success && palette)
|
||||
{
|
||||
@@ -884,7 +865,6 @@ bool wxBMPFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxBitmap::CleanUpHandlers()
|
||||
{
|
||||
wxNode *node = sm_handlers.First();
|
||||
@@ -903,7 +883,7 @@ void wxBitmap::InitStandardHandlers()
|
||||
AddHandler( new wxPICTResourceHandler ) ;
|
||||
AddHandler( new wxICONResourceHandler ) ;
|
||||
AddHandler(new wxXPMFileHandler);
|
||||
AddHandler(new wxXPMDataHandler);
|
||||
AddHandler(new wxXPMDataHandler);
|
||||
AddHandler(new wxBMPResourceHandler);
|
||||
AddHandler(new wxBMPFileHandler);
|
||||
}
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
|
||||
#include "wx/bmpbuttn.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
|
||||
#endif
|
||||
|
||||
#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,
|
||||
const wxPoint& pos,
|
||||
@@ -48,8 +50,6 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
if ( height == -1 && bitmap.Ok())
|
||||
height = bitmap.GetHeight() + 2*m_marginY;
|
||||
|
||||
m_macHorizontalBorder = 0 ; // additional pixels around the real control
|
||||
m_macVerticalBorder = 0 ;
|
||||
Rect bounds ;
|
||||
Str255 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 ;
|
||||
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 ;
|
||||
@@ -94,7 +101,14 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||
icon = bmap->m_hPict ;
|
||||
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 ;
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include "wx/utils.h"
|
||||
#include "wx/brush.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
|
||||
#endif
|
||||
|
||||
wxBrushRefData::wxBrushRefData()
|
||||
{
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include "wx/button.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
|
||||
#endif
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
// Button
|
||||
@@ -29,8 +31,6 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
{
|
||||
Rect bounds ;
|
||||
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 ) ;
|
||||
|
||||
@@ -66,22 +66,32 @@ void wxButton::SetDefault()
|
||||
|
||||
wxSize wxButton::DoGetBestSize() const
|
||||
{
|
||||
int wBtn = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder;
|
||||
int hBtn = 13 + 2 * m_macVerticalBorder;
|
||||
int wBtn = m_label.Length() * 8 + 12 ;
|
||||
int hBtn = 20 ;
|
||||
|
||||
if ( wBtn < 80 )
|
||||
wBtn = 80 ;
|
||||
|
||||
return wxSize(wBtn, hBtn);
|
||||
}
|
||||
|
||||
wxSize wxButton::GetDefaultSize()
|
||||
{
|
||||
int wBtn = 15 * 8 + 12 + 2 * 2;
|
||||
int hBtn = 13 + 2 * 2;
|
||||
int wBtn = 80 /* + 2 * m_macHorizontalBorder */ ;
|
||||
int hBtn = 20 /* + 2 * m_macVerticalBorder */ ;
|
||||
|
||||
return wxSize(wBtn, hBtn);
|
||||
}
|
||||
|
||||
void wxButton::Command (wxCommandEvent & event)
|
||||
{
|
||||
if ( m_macControl )
|
||||
{
|
||||
HiliteControl( m_macControl , kControlButtonPart ) ;
|
||||
unsigned long finalTicks ;
|
||||
Delay( 8 , &finalTicks ) ;
|
||||
HiliteControl( m_macControl , 0 ) ;
|
||||
}
|
||||
ProcessCommand (event);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include "wx/accel.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject)
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData
|
||||
{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#if !TARGET_CARBON
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
#include <wx/mac/aga.h>
|
||||
#include <extcdef.h>
|
||||
@@ -600,6 +602,10 @@ void AGADeactivateControl( ControlHandle inControl )
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
::HiliteControl( inControl , 255 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void AGAActivateControl( ControlHandle inControl )
|
||||
@@ -615,6 +621,10 @@ void AGAActivateControl( ControlHandle inControl )
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
::HiliteControl( inControl , 0 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
OSErr AGASetKeyboardFocus (WindowPtr inWindow,
|
||||
@@ -718,6 +728,7 @@ void DisposeExtCDEFInfo( ControlHandle theControl)
|
||||
DisposeHandle( info->children ) ;
|
||||
info->children = NULL ;
|
||||
free( (void*) (**theControl).contrlRfCon ) ;
|
||||
(**theControl).contrlRfCon = NULL ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -922,51 +933,6 @@ void AGASetFontStyle( ControlFontStyleRec *fontstyle )
|
||||
::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)
|
||||
{
|
||||
switch( message )
|
||||
@@ -1079,7 +1045,7 @@ pascal SInt32 AGABevelButtonDefProc (SInt16 procID, ControlHandle theControl, Co
|
||||
return 0 ;
|
||||
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
Boolean mRadioBehavior = false ;
|
||||
|
||||
@@ -1219,7 +1185,7 @@ pascal SInt32 AGAButtonDefProc (SInt16 procID, ControlHandle theControl, Control
|
||||
return 0 ;
|
||||
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
Boolean mRadioBehavior = false ;
|
||||
|
||||
@@ -1456,7 +1422,7 @@ pascal SInt32 AGACheckBoxDefProc (SInt16 procID, ControlHandle theControl, Contr
|
||||
return 0 ;
|
||||
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
Rect frame = (**theControl).contrlRect ;
|
||||
Boolean hasColor = true;
|
||||
Boolean disabled = (*theControl)->contrlHilite == 255 ;
|
||||
@@ -1844,7 +1810,7 @@ pascal SInt32 AGAStaticGroupBoxTextDefProc (SInt16 procID, ControlHandle theCont
|
||||
{
|
||||
bool disabled = false ;
|
||||
bool hasColor = true ;
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
FontInfo fi ;
|
||||
::GetFontInfo( &fi ) ;
|
||||
@@ -1930,7 +1896,7 @@ pascal SInt32 AGAStaticTextDefProc (SInt16 procID, ControlHandle theControl, Con
|
||||
return 0 ;
|
||||
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
int x = (**theControl).contrlRect.left ;
|
||||
int y = (**theControl).contrlRect.top ;
|
||||
@@ -2125,7 +2091,7 @@ pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, Contr
|
||||
{
|
||||
case initCntl :
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
SetPort( (**theControl).contrlOwner ) ;
|
||||
::TextFont( kFontIDGeneva ) ;
|
||||
::TextSize( 10 ) ;
|
||||
@@ -2147,7 +2113,7 @@ pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, Contr
|
||||
break ;
|
||||
case drawCntl :
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
SetPort( (**theControl).contrlOwner ) ;
|
||||
RGBBackColor( &gAGARamp[ kAGAWhite ] ) ;
|
||||
@@ -2254,9 +2220,8 @@ pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, Contr
|
||||
break ;
|
||||
case kControlMsgKeyDown :
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help( (**theControl).contrlOwner ) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
SetPort( (**theControl).contrlOwner ) ;
|
||||
RGBBackColor( &gAGARamp[ kAGAWhite ] ) ;
|
||||
RGBForeColor( &gAGARamp[ kAGABlack ] ) ;
|
||||
ControlKeyDownRec * rec = (ControlKeyDownRec*) param ;
|
||||
@@ -2364,7 +2329,7 @@ pascal SInt32 AGAListControlDefProc (SInt16 procID, ControlHandle theControl, Co
|
||||
break ;
|
||||
case drawCntl :
|
||||
{
|
||||
AGAPortHelper help() ;
|
||||
AGAPortHelper help((**theControl).contrlOwner) ;
|
||||
AGASetFontStyle( &info->fontStyle ) ;
|
||||
RGBBackColor( &gAGARamp[ kAGAWhite ] ) ;
|
||||
EraseRect( &(**theControl).contrlRect ) ;
|
||||
@@ -2578,4 +2543,78 @@ void AGASetThemeWindowBackground (WindowRef inWindow,
|
||||
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 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "wx/log.h"
|
||||
#include "wx/module.h"
|
||||
#include "wx/memory.h"
|
||||
|
||||
#include "wx/tooltip.h"
|
||||
#if wxUSE_WX_RESOURCES
|
||||
#include "wx/resource.h"
|
||||
#endif
|
||||
@@ -44,6 +44,12 @@
|
||||
#include "apprsrc.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 wxList wxPendingDelete;
|
||||
@@ -52,10 +58,14 @@ extern wxList *wxWinMacControlList;
|
||||
|
||||
wxApp *wxTheApp = NULL;
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
|
||||
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
|
||||
EVT_IDLE(wxApp::OnIdle)
|
||||
EVT_END_SESSION(wxApp::OnEndSession)
|
||||
EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
|
||||
const short kMacMinHeap = (29 * 1024) ;
|
||||
@@ -76,25 +86,25 @@ bool wxApp::s_macSupportPCMenuShortcuts = true ;
|
||||
long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
|
||||
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 ;
|
||||
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 ;
|
||||
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 ;
|
||||
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 ;
|
||||
return wxTheApp->MacHandleAEQuit( event , reply) ;
|
||||
@@ -133,14 +143,14 @@ OSErr wxApp::MacHandleAEQuit(AppleEvent *event , AppleEvent *reply)
|
||||
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"
|
||||
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf"
|
||||
"\xb1\xb4\xb5\xb6\xbb\xbc\xbe\xbf"
|
||||
"\xc0\xc1\xc2\xc4\xc7\xc8\xc9\xcb\xcc\xcd\xce\xcf"
|
||||
"\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"
|
||||
"\x86\xBA\xA2\xA3\xA7\x95\xB6\xDF\xAE\xA9\x99\xB4\xA8\xC6\xD8"
|
||||
"\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 , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , (long) wxTheApp , FALSE ) ;
|
||||
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , (long) wxTheApp , FALSE ) ;
|
||||
#if 0
|
||||
GUSISetup(GUSIwithInternetSockets);
|
||||
#endif
|
||||
|
||||
|
||||
// test the minimal configuration necessary
|
||||
@@ -378,7 +385,7 @@ bool wxApp::Initialize()
|
||||
}
|
||||
|
||||
#if __option(profile)
|
||||
ProfilerInit( collectDetailed, bestTimeBase , 20000 , 30 ) ;
|
||||
ProfilerInit( collectDetailed, bestTimeBase , 20000 , 40 ) ;
|
||||
#endif
|
||||
|
||||
// now avoid exceptions thrown for new (bad_alloc)
|
||||
@@ -393,17 +400,15 @@ bool wxApp::Initialize()
|
||||
wxBuffer = new char[BUFSIZ + 512];
|
||||
#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();
|
||||
|
||||
#if wxUSE_RESOURCES
|
||||
// wxGetResource(wxT("wxWindows"), wxT("OsVersion"), &wxOsVersion);
|
||||
#endif
|
||||
|
||||
#if wxUSE_THREADS
|
||||
wxPendingEventsLocker = new wxCriticalSection;
|
||||
#endif
|
||||
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
|
||||
wxTheColourDatabase->Initialize();
|
||||
|
||||
@@ -423,13 +428,29 @@ bool wxApp::Initialize()
|
||||
wxWinMacWindowList = new wxList(wxKEY_INTEGER);
|
||||
wxWinMacControlList = new wxList(wxKEY_INTEGER);
|
||||
|
||||
UMAShowArrowCursor() ;
|
||||
wxMacCreateNotifierTable() ;
|
||||
|
||||
UMAShowArrowCursor() ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
#if wxUSE_WX_RESOURCES
|
||||
@@ -438,19 +459,8 @@ void wxApp::CleanUp()
|
||||
|
||||
wxDeleteStockObjects() ;
|
||||
|
||||
// Destroy all GDI lists, etc.
|
||||
|
||||
delete wxTheBrushList;
|
||||
wxTheBrushList = NULL;
|
||||
|
||||
delete wxThePenList;
|
||||
wxThePenList = NULL;
|
||||
|
||||
delete wxTheFontList;
|
||||
wxTheFontList = NULL;
|
||||
|
||||
delete wxTheBitmapList;
|
||||
wxTheBitmapList = NULL;
|
||||
// Destroy all GDI lists, etc.
|
||||
wxDeleteStockLists();
|
||||
|
||||
delete wxTheColourDatabase;
|
||||
wxTheColourDatabase = NULL;
|
||||
@@ -460,9 +470,17 @@ void wxApp::CleanUp()
|
||||
delete[] wxBuffer;
|
||||
wxBuffer = NULL;
|
||||
|
||||
wxMacDestroyNotifierTable() ;
|
||||
if (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();
|
||||
|
||||
#if __option(profile)
|
||||
@@ -474,33 +492,33 @@ void wxApp::CleanUp()
|
||||
wxTheApp = NULL;
|
||||
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
// At this point we want to check if there are any memory
|
||||
// blocks that aren't part of the wxDebugContext itself,
|
||||
// as a special case. Then when dumping we need to ignore
|
||||
// wxDebugContext, too.
|
||||
if (wxDebugContext::CountObjectsLeft() > 0)
|
||||
{
|
||||
wxTrace("There were memory leaks.\n");
|
||||
wxDebugContext::Dump();
|
||||
wxDebugContext::PrintStatistics();
|
||||
}
|
||||
// wxDebugContext::SetStream(NULL, NULL);
|
||||
// At this point we want to check if there are any memory
|
||||
// blocks that aren't part of the wxDebugContext itself,
|
||||
// as a special case. Then when dumping we need to ignore
|
||||
// wxDebugContext, too.
|
||||
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
|
||||
{
|
||||
wxLogDebug(wxT("There were memory leaks."));
|
||||
wxDebugContext::Dump();
|
||||
wxDebugContext::PrintStatistics();
|
||||
}
|
||||
// wxDebugContext::SetStream(NULL, NULL);
|
||||
#endif
|
||||
|
||||
// do it as the very last thing because everything else can log messages
|
||||
wxLog::DontCreateOnDemand();
|
||||
// do it as the very last thing because everything else can log messages
|
||||
delete wxLog::SetActiveTarget(NULL);
|
||||
#if wxUSE_LOG
|
||||
// do it as the very last thing because everything else can log messages
|
||||
delete wxLog::SetActiveTarget(NULL);
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
::PrClose() ;
|
||||
if (s_macCursorRgn)
|
||||
::DisposeRgn(s_macCursorRgn);
|
||||
|
||||
#if 0
|
||||
TerminateAE() ;
|
||||
#endif
|
||||
}
|
||||
|
||||
int wxEntry( int argc, char *argv[] )
|
||||
int wxEntry( int argc, char *argv[] , bool enterLoop )
|
||||
{
|
||||
#ifdef __MWERKS__
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
@@ -513,27 +531,24 @@ int wxEntry( int argc, char *argv[] )
|
||||
wxDebugContext::SetCheckpoint();
|
||||
#endif
|
||||
#endif
|
||||
if (!wxApp::Initialize())
|
||||
return FALSE;
|
||||
if (!wxTheApp)
|
||||
{
|
||||
if (!wxApp::GetInitializerFunction())
|
||||
if (!wxApp::Initialize())
|
||||
return 0;
|
||||
// create the application object or ensure that one already exists
|
||||
if (!wxTheApp)
|
||||
{
|
||||
printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" );
|
||||
return 0;
|
||||
};
|
||||
// The app may have declared a global application object, but we recommend
|
||||
// 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)
|
||||
{
|
||||
printf( "wxWindows error: wxTheApp == NULL\n" );
|
||||
return 0;
|
||||
};
|
||||
wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
|
||||
|
||||
#ifdef __WXMAC__
|
||||
argc = 1 ; // currently we don't support files as parameters
|
||||
argc = 0 ; // currently we don't support files as parameters
|
||||
#endif
|
||||
|
||||
wxTheApp->argc = argc;
|
||||
@@ -549,42 +564,58 @@ int wxEntry( int argc, char *argv[] )
|
||||
// into wxTopLevelWindows by getting created
|
||||
// in OnInit().
|
||||
|
||||
if (!wxTheApp->OnInit()) return 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())
|
||||
{
|
||||
delete wxTheApp->GetTopWindow();
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
}
|
||||
wxWindow *topWindow = wxTheApp->GetTopWindow();
|
||||
if ( topWindow )
|
||||
{
|
||||
// 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
|
||||
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||
|
||||
wxApp::wxApp()
|
||||
{
|
||||
m_topWindow = NULL;
|
||||
wxTheApp = this;
|
||||
m_className = "";
|
||||
|
||||
m_wantDebugOutput = TRUE ;
|
||||
m_appName = "";
|
||||
|
||||
argc = 0;
|
||||
argv = NULL;
|
||||
|
||||
m_printMode = wxPRINT_WINDOWS;
|
||||
|
||||
m_exitOnFrameDelete = TRUE;
|
||||
m_auto3D = TRUE;
|
||||
}
|
||||
@@ -640,13 +671,14 @@ void wxApp::Dispatch()
|
||||
|
||||
void wxApp::OnIdle(wxIdleEvent& event)
|
||||
{
|
||||
static bool inOnIdle = FALSE;
|
||||
static bool s_inOnIdle = FALSE;
|
||||
|
||||
// Avoid recursion (via ProcessEvent default case)
|
||||
if (inOnIdle)
|
||||
return;
|
||||
// Avoid recursion (via ProcessEvent default case)
|
||||
if ( s_inOnIdle )
|
||||
return;
|
||||
|
||||
inOnIdle = TRUE;
|
||||
|
||||
s_inOnIdle = TRUE;
|
||||
|
||||
// 'Garbage' collection of windows deleted with Close().
|
||||
DeletePendingObjects();
|
||||
@@ -662,13 +694,17 @@ void wxApp::OnIdle(wxIdleEvent& event)
|
||||
if (needMore)
|
||||
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()
|
||||
{
|
||||
// **** please implement me! ****
|
||||
// Wake up the idle handler processor, even if it is in another thread...
|
||||
wxMacWakeUp() ;
|
||||
}
|
||||
|
||||
// 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
|
||||
{
|
||||
if (m_topWindow)
|
||||
return m_topWindow;
|
||||
else if (wxTopLevelWindows.Number() > 0)
|
||||
return (wxWindow*) wxTopLevelWindows.First()->Data();
|
||||
else
|
||||
return NULL;
|
||||
case wxICON_QUESTION:
|
||||
return wxIcon("wxICON_QUESTION");
|
||||
|
||||
case wxICON_EXCLAMATION:
|
||||
return wxIcon("wxICON_WARNING");
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(wxT("requested non existent standard icon"));
|
||||
// still fall through
|
||||
|
||||
case wxICON_HAND:
|
||||
return wxIcon("wxICON_ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
void wxExit()
|
||||
{
|
||||
wxApp::CleanUp();
|
||||
wxLogError(_("Fatal error: exiting"));
|
||||
|
||||
wxApp::CleanUp();
|
||||
::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
|
||||
bool wxYield()
|
||||
{
|
||||
// YieldToAnyThread() ;
|
||||
SystemTask() ;
|
||||
#if wxUSE_THREADS
|
||||
YieldToAnyThread() ;
|
||||
#endif
|
||||
EventRecord event ;
|
||||
|
||||
long sleepTime = 0 ; //::GetCaretTime();
|
||||
|
||||
while ( !wxTheApp->IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, wxApp::s_macCursorRgn))
|
||||
{
|
||||
wxTheApp->MacHandleOneEvent( &event );
|
||||
}
|
||||
|
||||
wxMacProcessNotifierAndPendingEvents() ;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -762,6 +842,12 @@ bool wxYield()
|
||||
|
||||
void wxApp::MacSuspend( bool convertClipboard )
|
||||
{
|
||||
// we have to deactive the window manually
|
||||
|
||||
wxWindow* window = GetTopWindow() ;
|
||||
if ( window )
|
||||
window->MacActivate( MacGetCurrentEvent() , false ) ;
|
||||
|
||||
s_lastMouseDown = 0 ;
|
||||
if( convertClipboard )
|
||||
{
|
||||
@@ -784,13 +870,10 @@ void wxApp::MacResume( bool convertClipboard )
|
||||
|
||||
void wxApp::MacConvertPrivateToPublicScrap()
|
||||
{
|
||||
::ZeroScrap();
|
||||
::TEToScrap();
|
||||
}
|
||||
|
||||
void wxApp::MacConvertPublicToPrivateScrap()
|
||||
{
|
||||
::TEFromScrap() ;
|
||||
}
|
||||
|
||||
void wxApp::MacDoOneEvent()
|
||||
@@ -817,9 +900,7 @@ void wxApp::MacDoOneEvent()
|
||||
|
||||
// repeaters
|
||||
|
||||
#if 0
|
||||
wxMacProcessSocketEvents() ;
|
||||
#endif
|
||||
wxMacProcessNotifierAndPendingEvents() ;
|
||||
}
|
||||
|
||||
void wxApp::MacHandleOneEvent( EventRecord *ev )
|
||||
@@ -874,6 +955,7 @@ void wxApp::MacHandleOneEvent( EventRecord *ev )
|
||||
default:
|
||||
break;
|
||||
}
|
||||
wxMacProcessNotifierAndPendingEvents() ;
|
||||
}
|
||||
|
||||
void wxApp::MacHandleHighLevelEvent( EventRecord *ev )
|
||||
@@ -885,6 +967,8 @@ bool s_macIsInModalLoop = false ;
|
||||
|
||||
void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
{
|
||||
wxToolTip::RemoveToolTips() ;
|
||||
|
||||
WindowRef window;
|
||||
WindowRef frontWindow = UMAFrontNonFloatingWindow() ;
|
||||
WindowAttributes frontWindowAttributes = NULL ;
|
||||
@@ -894,6 +978,9 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
short windowPart = ::FindWindow(ev->where, &window);
|
||||
wxWindow* win = wxFindWinFromMacWindow( window ) ;
|
||||
|
||||
BitMap screenBits;
|
||||
GetQDGlobalsScreenBits( &screenBits );
|
||||
|
||||
switch (windowPart)
|
||||
{
|
||||
case inMenuBar :
|
||||
@@ -908,10 +995,12 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
s_lastMouseDown = 0;
|
||||
}
|
||||
break ;
|
||||
#if !TARGET_CARBON
|
||||
case inSysWindow :
|
||||
SystemClick( ev , window ) ;
|
||||
s_lastMouseDown = 0;
|
||||
break ;
|
||||
#endif
|
||||
case inDrag :
|
||||
if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) )
|
||||
{
|
||||
@@ -919,13 +1008,17 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
}
|
||||
else
|
||||
{
|
||||
DragWindow(window, ev->where, &qd.screenBits.bounds);
|
||||
DragWindow(window, ev->where, &screenBits.bounds);
|
||||
if (win)
|
||||
{
|
||||
GrafPtr port ;
|
||||
GetPort( &port ) ;
|
||||
Point pt = { 0, 0 } ;
|
||||
SetPort( window ) ;
|
||||
#if TARGET_CARBON
|
||||
SetPort( GetWindowPort(window) ) ;
|
||||
#else
|
||||
SetPort( (window) ) ;
|
||||
#endif
|
||||
SetOrigin( 0 , 0 ) ;
|
||||
LocalToGlobal( &pt ) ;
|
||||
SetPort( port ) ;
|
||||
@@ -944,7 +1037,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
s_lastMouseDown = 0;
|
||||
break;
|
||||
case inGrow:
|
||||
int growResult = GrowWindow(window , ev->where, &qd.screenBits.bounds);
|
||||
int growResult = GrowWindow(window , ev->where, &screenBits.bounds);
|
||||
if (growResult != 0)
|
||||
{
|
||||
int newWidth = LoWord(growResult);
|
||||
@@ -969,8 +1062,13 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
// TODO setup size event
|
||||
ZoomWindow( window , windowPart , false ) ;
|
||||
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;
|
||||
break;
|
||||
@@ -980,6 +1078,17 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
|
||||
break ;
|
||||
|
||||
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 ( s_macIsInModalLoop )
|
||||
@@ -1140,6 +1249,8 @@ long wxMacTranslateKey(unsigned char key, unsigned char code)
|
||||
|
||||
void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
||||
{
|
||||
wxToolTip::RemoveToolTips() ;
|
||||
|
||||
UInt32 menuresult = UMAMenuEvent(ev) ;
|
||||
if ( HiWord( menuresult ) )
|
||||
MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
|
||||
@@ -1268,12 +1379,14 @@ void wxApp::MacHandleDiskEvent( EventRecord *ev )
|
||||
{
|
||||
if ( HiWord( ev->message ) != noErr )
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
OSErr err ;
|
||||
Point point ;
|
||||
SetPt( &point , 100 , 100 ) ;
|
||||
|
||||
err = DIBadMount( point , ev->message ) ;
|
||||
err = DIBadMount( point , ev->message ) ;
|
||||
wxASSERT( err == noErr ) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,10 @@ extern "C"
|
||||
#include "xpm.h"
|
||||
} ;
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
|
||||
#endif
|
||||
|
||||
#include <PictUtils.h>
|
||||
|
||||
@@ -69,16 +71,7 @@ GWorldPtr wxMacCreateGWorld( int height , int width , int depth )
|
||||
|
||||
if ( depth < 0 )
|
||||
{
|
||||
// get max pixel depth
|
||||
CGrafPtr port ;
|
||||
GetCWMgrPort( &port ) ;
|
||||
GDHandle maxDevice ;
|
||||
|
||||
maxDevice = GetMaxDevice( &port->portRect ) ;
|
||||
if ( maxDevice )
|
||||
depth = (**((**maxDevice).gdPMap)).pixelSize ;
|
||||
else
|
||||
depth = 8 ;
|
||||
depth = wxDisplayDepth() ;
|
||||
}
|
||||
|
||||
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 ) ;
|
||||
SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
|
||||
LockPixels( GetGWorldPixMap( (CGrafPtr) M_BITMAPDATA->m_hBitmap ) ) ;
|
||||
|
||||
// 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 ) ;
|
||||
}
|
||||
@@ -514,6 +509,8 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
||||
}
|
||||
|
||||
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() ;
|
||||
|
||||
// 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 ) ;
|
||||
|
||||
return TRUE;
|
||||
@@ -712,8 +711,8 @@ bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
|
||||
if (dc)
|
||||
{
|
||||
if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap))
|
||||
{ /* for following SetPixel */
|
||||
/* fill the XImage struct 'by hand' */
|
||||
{
|
||||
|
||||
ximage.width = M_BITMAPHANDLERDATA->m_width;
|
||||
ximage.height = M_BITMAPHANDLERDATA->m_height;
|
||||
ximage.depth = M_BITMAPHANDLERDATA->m_depth;
|
||||
@@ -725,7 +724,7 @@ bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
|
||||
DeleteDC(dc);
|
||||
|
||||
if (errorStatus == XpmSuccess)
|
||||
return TRUE; /* no error */
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
} else return FALSE;
|
||||
@@ -809,19 +808,6 @@ bool wxBMPResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
// 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
|
||||
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
|
||||
wxPalette *palette = NULL;
|
||||
bool success = FALSE;
|
||||
/*
|
||||
if (type & wxBITMAP_DISCARD_COLOURMAP)
|
||||
success = wxLoadIntoBitmap(WXSTRINGCAST name, bitmap);
|
||||
else
|
||||
*/
|
||||
success = (wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0);
|
||||
if (!success && palette)
|
||||
{
|
||||
@@ -884,7 +865,6 @@ bool wxBMPFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxBitmap::CleanUpHandlers()
|
||||
{
|
||||
wxNode *node = sm_handlers.First();
|
||||
@@ -903,7 +883,7 @@ void wxBitmap::InitStandardHandlers()
|
||||
AddHandler( new wxPICTResourceHandler ) ;
|
||||
AddHandler( new wxICONResourceHandler ) ;
|
||||
AddHandler(new wxXPMFileHandler);
|
||||
AddHandler(new wxXPMDataHandler);
|
||||
AddHandler(new wxXPMDataHandler);
|
||||
AddHandler(new wxBMPResourceHandler);
|
||||
AddHandler(new wxBMPFileHandler);
|
||||
}
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
|
||||
#include "wx/bmpbuttn.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
|
||||
#endif
|
||||
|
||||
#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,
|
||||
const wxPoint& pos,
|
||||
@@ -48,8 +50,6 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
if ( height == -1 && bitmap.Ok())
|
||||
height = bitmap.GetHeight() + 2*m_marginY;
|
||||
|
||||
m_macHorizontalBorder = 0 ; // additional pixels around the real control
|
||||
m_macVerticalBorder = 0 ;
|
||||
Rect bounds ;
|
||||
Str255 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 ;
|
||||
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 ;
|
||||
@@ -94,7 +101,14 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||
icon = bmap->m_hPict ;
|
||||
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 ;
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include "wx/utils.h"
|
||||
#include "wx/brush.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
|
||||
#endif
|
||||
|
||||
wxBrushRefData::wxBrushRefData()
|
||||
{
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include "wx/button.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
|
||||
#endif
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
// Button
|
||||
@@ -29,8 +31,6 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
{
|
||||
Rect bounds ;
|
||||
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 ) ;
|
||||
|
||||
@@ -66,22 +66,32 @@ void wxButton::SetDefault()
|
||||
|
||||
wxSize wxButton::DoGetBestSize() const
|
||||
{
|
||||
int wBtn = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder;
|
||||
int hBtn = 13 + 2 * m_macVerticalBorder;
|
||||
int wBtn = m_label.Length() * 8 + 12 ;
|
||||
int hBtn = 20 ;
|
||||
|
||||
if ( wBtn < 80 )
|
||||
wBtn = 80 ;
|
||||
|
||||
return wxSize(wBtn, hBtn);
|
||||
}
|
||||
|
||||
wxSize wxButton::GetDefaultSize()
|
||||
{
|
||||
int wBtn = 15 * 8 + 12 + 2 * 2;
|
||||
int hBtn = 13 + 2 * 2;
|
||||
int wBtn = 80 /* + 2 * m_macHorizontalBorder */ ;
|
||||
int hBtn = 20 /* + 2 * m_macVerticalBorder */ ;
|
||||
|
||||
return wxSize(wBtn, hBtn);
|
||||
}
|
||||
|
||||
void wxButton::Command (wxCommandEvent & event)
|
||||
{
|
||||
if ( m_macControl )
|
||||
{
|
||||
HiliteControl( m_macControl , kControlButtonPart ) ;
|
||||
unsigned long finalTicks ;
|
||||
Delay( 8 , &finalTicks ) ;
|
||||
HiliteControl( m_macControl , 0 ) ;
|
||||
}
|
||||
ProcessCommand (event);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
|
||||
#include "wx/checkbox.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
|
||||
#endif
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// implementation of wxCheckListBox class
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include "wx/choice.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
|
||||
#endif
|
||||
|
||||
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
@@ -27,7 +29,6 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
m_noStrings = n;
|
||||
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
@@ -41,11 +42,15 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
|
||||
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 ) ;
|
||||
SetControlMaximum( m_macControl , m_noStrings) ;
|
||||
SetControlValue( m_macControl , 1 ) ;
|
||||
SetControlMaximum( m_macControl , Number()) ;
|
||||
if ( n > 0 )
|
||||
SetControlValue( m_macControl , 1 ) ;
|
||||
|
||||
MacPostControlCreate() ;
|
||||
|
||||
@@ -54,27 +59,28 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
void wxChoice::Append(const wxString& item)
|
||||
{
|
||||
appendmenu( m_macPopUpMenuHandle , item ) ;
|
||||
m_noStrings ++;
|
||||
SetControlMaximum( m_macControl , m_noStrings) ;
|
||||
Str255 label;
|
||||
wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false);
|
||||
AppendMenu( m_macPopUpMenuHandle , label ) ;
|
||||
m_strings.Add( item ) ;
|
||||
SetControlMaximum( m_macControl , Number()) ;
|
||||
}
|
||||
|
||||
void wxChoice::Delete(int n)
|
||||
{
|
||||
wxASSERT( n < m_noStrings ) ;
|
||||
::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ;
|
||||
m_noStrings --;
|
||||
SetControlMaximum( m_macControl , m_noStrings) ;
|
||||
m_strings.Remove( n ) ;
|
||||
SetControlMaximum( m_macControl , Number()) ;
|
||||
}
|
||||
|
||||
void wxChoice::Clear()
|
||||
{
|
||||
for ( int i = 0 ; i < m_noStrings ; i++ )
|
||||
for ( int i = 0 ; i < Number() ; i++ )
|
||||
{
|
||||
::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ;
|
||||
}
|
||||
m_noStrings = 0;
|
||||
SetControlMaximum( m_macControl , m_noStrings) ;
|
||||
m_strings.Clear() ;
|
||||
SetControlMaximum( m_macControl , Number()) ;
|
||||
}
|
||||
|
||||
int wxChoice::GetSelection() const
|
||||
@@ -99,7 +105,7 @@ void wxChoice::SetSelection(int n)
|
||||
|
||||
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 )
|
||||
return i ;
|
||||
@@ -109,10 +115,7 @@ int wxChoice::FindString(const wxString& s) const
|
||||
|
||||
wxString wxChoice::GetString(int n) const
|
||||
{
|
||||
Str255 text ;
|
||||
::GetMenuItemText( m_macPopUpMenuHandle , n+1 , text ) ;
|
||||
p2cstr( text ) ;
|
||||
return wxString( text );
|
||||
return m_strings[n] ;
|
||||
}
|
||||
|
||||
void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
|
||||
@@ -21,48 +21,214 @@
|
||||
#include "wx/metafile.h"
|
||||
#include "wx/clipbrd.h"
|
||||
|
||||
#define wxUSE_DATAOBJ 1
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// open/close
|
||||
|
||||
bool clipboard_opened = false ;
|
||||
|
||||
bool wxOpenClipboard()
|
||||
{
|
||||
clipboard_opened = true ;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxCloseClipboard()
|
||||
{
|
||||
clipboard_opened = false ;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxIsClipboardOpened()
|
||||
{
|
||||
return TRUE;
|
||||
return clipboard_opened;
|
||||
}
|
||||
|
||||
// get/set data
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool wxSetClipboardData(wxDataFormat dataFormat,const void *data,int width , int height)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// get/set data
|
||||
|
||||
// clipboard formats
|
||||
|
||||
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;
|
||||
#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)
|
||||
@@ -80,11 +246,17 @@ bool wxGetClipboardFormatName(wxDataFormat dataFormat, wxChar *formatName, int m
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Generalized clipboard implementation by Matthew Flatt
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxClipboardBase)
|
||||
|
||||
wxClipboard::wxClipboard()
|
||||
{
|
||||
@@ -143,9 +315,9 @@ bool wxClipboard::AddData( wxDataObject *data )
|
||||
#if wxUSE_DATAOBJ
|
||||
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_OEMTEXT:
|
||||
@@ -160,10 +332,10 @@ bool wxClipboard::AddData( wxDataObject *data )
|
||||
{
|
||||
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
|
||||
wxBitmap bitmap(bitmapDataObject->GetBitmap());
|
||||
return wxSetClipboardData(data->GetFormat(), &bitmap);
|
||||
return wxSetClipboardData(format, &bitmap);
|
||||
}
|
||||
|
||||
#if wxUSE_METAFILE
|
||||
#if 0 // wxUSE_METAFILE
|
||||
case wxDF_METAFILE:
|
||||
{
|
||||
wxMetafileDataObject* metaFileDataObject =
|
||||
@@ -176,11 +348,12 @@ bool wxClipboard::AddData( wxDataObject *data )
|
||||
#endif // wxUSE_METAFILE
|
||||
|
||||
default:
|
||||
return wxSetClipboardData(data);
|
||||
// return wxSetClipboardData(data);
|
||||
break ;
|
||||
}
|
||||
#else // !wxUSE_DATAOBJ
|
||||
return FALSE;
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxClipboard::Close()
|
||||
@@ -188,7 +361,7 @@ void wxClipboard::Close()
|
||||
wxCloseClipboard();
|
||||
}
|
||||
|
||||
bool wxClipboard::IsSupported( wxDataFormat format )
|
||||
bool wxClipboard::IsSupported( const wxDataFormat &format )
|
||||
{
|
||||
return wxIsClipboardFormatAvailable(format);
|
||||
}
|
||||
@@ -198,7 +371,7 @@ bool wxClipboard::GetData( wxDataObject& data )
|
||||
#if wxUSE_DATAOBJ
|
||||
wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
|
||||
|
||||
wxDataFormat format = data.GetFormat();
|
||||
wxDataFormat format = data.GetPreferredFormat();
|
||||
switch ( format )
|
||||
{
|
||||
case wxDF_TEXT:
|
||||
@@ -219,7 +392,7 @@ bool wxClipboard::GetData( wxDataObject& data )
|
||||
case wxDF_DIB:
|
||||
{
|
||||
wxBitmapDataObject& bitmapDataObject = (wxBitmapDataObject &)data;
|
||||
wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(data->GetFormat());
|
||||
wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(format );
|
||||
if ( !bitmap )
|
||||
return FALSE;
|
||||
|
||||
@@ -228,7 +401,7 @@ bool wxClipboard::GetData( wxDataObject& data )
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#if wxUSE_METAFILE
|
||||
#if 0 // wxUSE_METAFILE
|
||||
case wxDF_METAFILE:
|
||||
{
|
||||
wxMetafileDataObject& metaFileDataObject = (wxMetafileDataObject &)data;
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
#include "wx/mac/colordlg.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wxColourDialog
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/colour.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
|
||||
#endif
|
||||
|
||||
// Colour
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
#include "wx/combobox.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
|
||||
#endif
|
||||
|
||||
// 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) ;
|
||||
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 ) ;
|
||||
SetControlMaximum( m_macControl , m_noStrings) ;
|
||||
@@ -125,7 +129,9 @@ void wxComboBox::SetSelection(long from, long to)
|
||||
|
||||
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 ++;
|
||||
SetControlMaximum( m_macControl , m_noStrings) ;
|
||||
}
|
||||
|
||||
@@ -16,15 +16,18 @@
|
||||
#include "wx/control.h"
|
||||
#include "wx/notebook.h"
|
||||
#include "wx/tabctrl.h"
|
||||
#include "wx/radiobox.h"
|
||||
#include "wx/spinbutt.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxControl, wxControlBase)
|
||||
BEGIN_EVENT_TABLE(wxControl, wxWindow)
|
||||
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
|
||||
EVT_CHAR( wxControl::OnKeyDown )
|
||||
EVT_PAINT( wxControl::OnPaint )
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
|
||||
@@ -32,6 +35,7 @@ END_EVENT_TABLE()
|
||||
|
||||
ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ;
|
||||
|
||||
pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) ;
|
||||
pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode )
|
||||
{
|
||||
if ( partCode != 0)
|
||||
@@ -46,9 +50,9 @@ pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCod
|
||||
|
||||
wxControl::wxControl()
|
||||
{
|
||||
m_macControl = NULL ;
|
||||
m_macHorizontalBorder = 0 ; // additional pixels around the real control
|
||||
m_macVerticalBorder = 0 ;
|
||||
m_macControl = NULL ;
|
||||
m_macHorizontalBorder = 0 ; // additional pixels around the real control
|
||||
m_macVerticalBorder = 0 ;
|
||||
m_backgroundColour = *wxWHITE;
|
||||
m_foregroundColour = *wxBLACK;
|
||||
#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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
m_label = title ;
|
||||
@@ -222,7 +229,7 @@ void wxControl::MacPostControlCreate()
|
||||
{
|
||||
// no font
|
||||
}
|
||||
else if ( IsKindOf( CLASSINFO( wxStaticBox ) ) )
|
||||
else if ( IsKindOf( CLASSINFO( wxStaticBox ) ) || IsKindOf( CLASSINFO( wxRadioBox ) ) || IsKindOf( CLASSINFO( wxButton ) ) )
|
||||
{
|
||||
ControlFontStyleRec controlstyle ;
|
||||
controlstyle.flags = kControlUseFontMask ;
|
||||
@@ -275,14 +282,16 @@ void wxControl::MacAdjustControlRect()
|
||||
{
|
||||
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 ) ) )
|
||||
{
|
||||
m_width = m_label.Length() * 8 ;
|
||||
}
|
||||
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 )
|
||||
{
|
||||
@@ -296,7 +305,7 @@ void wxControl::MacAdjustControlRect()
|
||||
wxMacDrawingHelper helper ( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ;
|
||||
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 )
|
||||
{
|
||||
int former_mac_x = (**m_macControl).contrlRect.left ;
|
||||
int former_mac_y = (**m_macControl).contrlRect.top ;
|
||||
Rect contrlRect ;
|
||||
GetControlBounds( m_macControl , &contrlRect ) ;
|
||||
int former_mac_x = contrlRect.left ;
|
||||
int former_mac_y = contrlRect.top ;
|
||||
int mac_x = m_x ;
|
||||
int mac_y = m_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 } ;
|
||||
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 } ;
|
||||
InvalRect( &inval ) ;
|
||||
InvalWindowRect( rootwindow , &inval ) ;
|
||||
}
|
||||
}
|
||||
if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
|
||||
@@ -378,7 +389,7 @@ void wxControl::MacSuperEnabled( bool enabled )
|
||||
}
|
||||
}
|
||||
wxWindow::MacSuperEnabled( enabled ) ;
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
void wxControl::MacSuperShown( bool show )
|
||||
@@ -418,8 +429,10 @@ void wxControl::DoSetSize(int x, int y,
|
||||
int former_w = m_width ;
|
||||
int former_h = m_height ;
|
||||
|
||||
int former_mac_x = (**m_macControl).contrlRect.left ;
|
||||
int former_mac_y = (**m_macControl).contrlRect.top ;
|
||||
Rect contrlRect ;
|
||||
GetControlBounds( m_macControl , &contrlRect ) ;
|
||||
int former_mac_x = contrlRect.left ;
|
||||
int former_mac_y = contrlRect.top ;
|
||||
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
@@ -430,9 +443,9 @@ void wxControl::DoSetSize(int x, int y,
|
||||
int actualHeight = height;
|
||||
int actualX = x;
|
||||
int actualY = y;
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
if (x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
actualX = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
if (y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
actualY = currentY;
|
||||
if (width == -1)
|
||||
actualWidth = currentW ;
|
||||
@@ -443,7 +456,8 @@ void wxControl::DoSetSize(int x, int y,
|
||||
return ;
|
||||
|
||||
AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
|
||||
wxMacDrawingHelper focus( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ;
|
||||
WindowRef macrootwindow = GetMacRootWindow() ;
|
||||
wxMacDrawingHelper focus( wxFindWinFromMacWindow( macrootwindow ) ) ;
|
||||
|
||||
int mac_x = actualX ;
|
||||
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 } ;
|
||||
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 } ;
|
||||
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 } ;
|
||||
InvalRect( &inval ) ;
|
||||
InvalWindowRect( macrootwindow, &inval ) ;
|
||||
}
|
||||
m_width = actualWidth ;
|
||||
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 } ;
|
||||
InvalRect( &inval ) ;
|
||||
InvalWindowRect( macrootwindow , &inval ) ;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if ( m_macControl )
|
||||
@@ -566,6 +621,7 @@ void wxControl::OnPaint(wxPaintEvent& event)
|
||||
if ( win )
|
||||
{
|
||||
wxMacDrawingHelper help( win ) ;
|
||||
// the mac control manager always assumes to have the origin at 0,0
|
||||
SetOrigin( 0 , 0 ) ;
|
||||
|
||||
bool hasTabBehind = false ;
|
||||
@@ -629,7 +685,7 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
|
||||
return ;
|
||||
}
|
||||
|
||||
if (event.GetEventType() == wxEVT_LEFT_DOWN )
|
||||
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
|
||||
{
|
||||
|
||||
int x = event.m_x ;
|
||||
|
||||
@@ -16,17 +16,33 @@
|
||||
#include "wx/cursor.h"
|
||||
#include "wx/icon.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
|
||||
#endif
|
||||
|
||||
const short kwxCursorHandId = 9 ;
|
||||
const short kwxCursorSizeWEId = 10 ;
|
||||
const short kwxCursorSizeNSId = 11 ;
|
||||
#if !TARGET_CARBON
|
||||
Cursor* MacArrowCursorPtr = &qd.arrow ;
|
||||
CursHandle MacArrowCursor = &MacArrowCursorPtr ;
|
||||
#else
|
||||
bool MacArrowInstalled = false ;
|
||||
Cursor MacArrow ;
|
||||
Cursor* MacArrowCursorPtr = &MacArrow ;
|
||||
CursHandle MacArrowCursor = &MacArrowCursorPtr ;
|
||||
#endif
|
||||
CursHandle gMacCurrentCursor = NULL ;
|
||||
|
||||
wxCursorRefData::wxCursorRefData()
|
||||
{
|
||||
#if TARGET_CARBON
|
||||
if ( !MacArrowInstalled )
|
||||
{
|
||||
MacArrowCursorPtr = GetQDGlobalsArrow( &MacArrow ) ;
|
||||
MacArrowInstalled = true ;
|
||||
}
|
||||
#endif
|
||||
m_width = 32;
|
||||
m_height = 32;
|
||||
m_hCursor = NULL ;
|
||||
@@ -34,8 +50,8 @@ wxCursorRefData::wxCursorRefData()
|
||||
|
||||
wxCursorRefData::~wxCursorRefData()
|
||||
{
|
||||
if ( m_hCursor && ( m_hCursor != MacArrowCursor ) )
|
||||
::DisposeHandle( (Handle) m_hCursor ) ;
|
||||
// if ( m_hCursor && ( m_hCursor != MacArrowCursor ) )
|
||||
// ::ReleaseResource( (Handle) m_hCursor ) ;
|
||||
}
|
||||
|
||||
// Cursors
|
||||
|
||||
@@ -102,8 +102,8 @@ const wxChar *wxFrameNameStr = wxT("frame");
|
||||
const wxChar *wxGaugeNameStr = wxT("gauge");
|
||||
const wxChar *wxStaticBoxNameStr = wxT("groupBox");
|
||||
const wxChar *wxListBoxNameStr = wxT("listBox");
|
||||
const wxChar *wxStaticTextNameStr = wxT("message");
|
||||
const wxChar *wxStaticBitmapNameStr = wxT("message");
|
||||
const wxChar *wxStaticTextNameStr = wxT("statictext");
|
||||
const wxChar *wxStaticBitmapNameStr = wxT("staticbitmap");
|
||||
const wxChar *wxMultiTextNameStr = wxT("multitext");
|
||||
const wxChar *wxPanelNameStr = wxT("panel");
|
||||
const wxChar *wxRadioBoxNameStr = wxT("radioBox");
|
||||
@@ -134,5 +134,17 @@ const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
|
||||
const wxChar *wxFloatToStringStr = 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 wxPoint wxDefaultPosition(-1, -1);
|
||||
|
||||
@@ -44,56 +44,40 @@
|
||||
|
||||
wxDataFormat::wxDataFormat()
|
||||
{
|
||||
m_vType = wxDF_INVALID;
|
||||
m_vFormat = 0;
|
||||
m_type = wxDF_INVALID;
|
||||
m_format = 0;
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat(
|
||||
wxDataFormatId vType
|
||||
)
|
||||
wxDataFormat::wxDataFormat( wxDataFormatId vType )
|
||||
{
|
||||
PrepareFormats();
|
||||
SetType(vType);
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat(
|
||||
const wxChar* zId
|
||||
)
|
||||
wxDataFormat::wxDataFormat( const wxChar* zId)
|
||||
{
|
||||
PrepareFormats();
|
||||
SetId(zId);
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat(
|
||||
const wxString& rId
|
||||
)
|
||||
wxDataFormat::wxDataFormat( const wxString& rId)
|
||||
{
|
||||
PrepareFormats();
|
||||
SetId(rId);
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat(
|
||||
NativeFormat vFormat
|
||||
)
|
||||
wxDataFormat::wxDataFormat( NativeFormat vFormat)
|
||||
{
|
||||
PrepareFormats();
|
||||
SetId(vFormat);
|
||||
}
|
||||
|
||||
void wxDataFormat::SetType(
|
||||
wxDataFormatId vType
|
||||
)
|
||||
void wxDataFormat::SetType( wxDataFormatId Type )
|
||||
{
|
||||
m_vType = vType;
|
||||
m_type = Type;
|
||||
|
||||
if (m_vType == wxDF_TEXT)
|
||||
m_vFormat = 0;
|
||||
else
|
||||
if (m_vType == wxDF_BITMAP)
|
||||
m_vFormat = 0;
|
||||
else
|
||||
if (m_vType == wxDF_FILENAME)
|
||||
m_vFormat = 0;
|
||||
if (m_type == wxDF_TEXT)
|
||||
m_format = 'TEXT';
|
||||
else if (m_type == wxDF_BITMAP || m_type == wxDF_METAFILE )
|
||||
m_format = 'PICT';
|
||||
else if (m_type == wxDF_FILENAME)
|
||||
m_format = 'SPEC';
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG( wxT("invalid dataformat") );
|
||||
@@ -102,56 +86,37 @@ void wxDataFormat::SetType(
|
||||
|
||||
wxDataFormatId wxDataFormat::GetType() const
|
||||
{
|
||||
return m_vType;
|
||||
return m_type;
|
||||
}
|
||||
|
||||
wxString wxDataFormat::GetId() const
|
||||
{
|
||||
wxString sRet(""); // TODO: gdk_atom_name( m_format ) );
|
||||
wxString sRet(""); // TODO: to name of ( m_format ) );
|
||||
return sRet;
|
||||
}
|
||||
|
||||
void wxDataFormat::SetId(
|
||||
NativeFormat vFormat
|
||||
)
|
||||
void wxDataFormat::SetId( NativeFormat format )
|
||||
{
|
||||
m_vFormat = vFormat;
|
||||
// TODO:
|
||||
/*
|
||||
if (m_format == g_textAtom)
|
||||
m_format = format;
|
||||
|
||||
if (m_format == 'TEXT')
|
||||
m_type = wxDF_TEXT;
|
||||
else
|
||||
if (m_format == g_pngAtom)
|
||||
if (m_format == 'PICT')
|
||||
m_type = wxDF_BITMAP;
|
||||
else
|
||||
if (m_format == g_fileAtom)
|
||||
if (m_format == 'SPEC')
|
||||
m_type = wxDF_FILENAME;
|
||||
else
|
||||
m_type = wxDF_PRIVATE;
|
||||
*/
|
||||
}
|
||||
|
||||
void wxDataFormat::SetId(
|
||||
const wxChar* zId
|
||||
)
|
||||
void wxDataFormat::SetId( const wxChar* zId )
|
||||
{
|
||||
wxString tmp(zId);
|
||||
|
||||
m_vType = wxDF_PRIVATE;
|
||||
m_vFormat = 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 );
|
||||
*/
|
||||
m_type = wxDF_PRIVATE;
|
||||
m_format = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
@@ -14,8 +14,11 @@
|
||||
#endif
|
||||
|
||||
#include "wx/dc.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// constants
|
||||
@@ -34,7 +37,7 @@ long wxDC::m_macCurrentPortId = 1 ;
|
||||
// wxDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxDC::wxDC(void)
|
||||
wxDC::wxDC()
|
||||
{
|
||||
m_ok = FALSE;
|
||||
m_optimize = FALSE;
|
||||
@@ -42,8 +45,8 @@ wxDC::wxDC(void)
|
||||
m_colour = TRUE;
|
||||
m_clipping = FALSE;
|
||||
|
||||
m_mm_to_pix_x = 1.0;
|
||||
m_mm_to_pix_y = 1.0;
|
||||
m_mm_to_pix_x = mm2pt;
|
||||
m_mm_to_pix_y = mm2pt;
|
||||
|
||||
m_logicalOriginX = 0;
|
||||
m_logicalOriginY = 0;
|
||||
@@ -102,20 +105,32 @@ 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 )
|
||||
{
|
||||
::SetPort( m_macPort ) ;
|
||||
::SetOrigin( 0 , 0 ) ;
|
||||
::ClipRect( &m_macPort->portRect ) ;
|
||||
::PenNormal() ;
|
||||
::SetPort( m_macOrigPort ) ;
|
||||
}
|
||||
*/
|
||||
++m_macCurrentPortId ;
|
||||
};
|
||||
|
||||
void wxDC::MacSetupPort() const
|
||||
{
|
||||
AGAPortHelper* help = &m_macPortHelper ;
|
||||
help->Setup( m_macPort ) ;
|
||||
m_macPortId = ++m_macCurrentPortId ;
|
||||
::SetPort(m_macPort);
|
||||
::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v);
|
||||
::ClipRect(&m_macClipRect);
|
||||
|
||||
@@ -124,8 +139,10 @@ void wxDC::MacSetupPort() const
|
||||
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())
|
||||
return;
|
||||
MacVerifySetup() ;
|
||||
@@ -140,7 +157,7 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask )
|
||||
{
|
||||
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 ) ;
|
||||
::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 ;
|
||||
dest.top = YLOG2DEV(y) ;
|
||||
dest.left = XLOG2DEV(x) ;
|
||||
dest.bottom = YLOG2DEV(y + bmap->m_height ) ;
|
||||
dest.right = XLOG2DEV(x + bmap->m_width ) ;
|
||||
dest.bottom = YLOG2DEV(y + bmap->m_height * scale) ;
|
||||
dest.right = XLOG2DEV(x + bmap->m_width * scale ) ;
|
||||
|
||||
if ( useMask && bmp.GetMask() )
|
||||
{
|
||||
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 ) ;
|
||||
UnlockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
CopyBits( &GrafPtr( bmapworld )->portBits , &GrafPtr( m_macPort )->portBits ,
|
||||
CopyBits( GetPortBitMapForCopyBits( bmapworld ) , GetPortBitMapForCopyBits( m_macPort ),
|
||||
&source, &dest, srcCopy, NULL ) ;
|
||||
|
||||
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())
|
||||
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 );
|
||||
};
|
||||
|
||||
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() ;
|
||||
MacVerifySetup() ;
|
||||
if( m_clipping )
|
||||
{
|
||||
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 } ;
|
||||
|
||||
::ClipRect( &clip ) ;
|
||||
::ClipRect( &clip ) ;
|
||||
|
||||
};
|
||||
|
||||
void wxDC::SetClippingRegion(const wxRect& rect)
|
||||
void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion )
|
||||
{
|
||||
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)
|
||||
@@ -317,47 +286,13 @@ void wxDC::DestroyClippingRegion(void)
|
||||
::ClipRect(&m_macClipRect);
|
||||
};
|
||||
|
||||
void wxDC::GetClippingBox( wxCoord *x, wxCoord *y, wxCoord *width, wxCoord *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
|
||||
void wxDC::DoGetSize( int* width, int* height ) const
|
||||
{
|
||||
*width = m_maxX-m_minX;
|
||||
*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 h = 0;
|
||||
@@ -416,12 +351,6 @@ void wxDC::SetUserScale( double x, double y )
|
||||
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 )
|
||||
{
|
||||
// allow negative ?
|
||||
@@ -430,40 +359,20 @@ void wxDC::SetLogicalScale( double x, double y )
|
||||
ComputeScaleAndOrigin();
|
||||
};
|
||||
|
||||
void wxDC::GetLogicalScale( double *x, double *y )
|
||||
{
|
||||
if (x) *x = m_logicalScaleX;
|
||||
if (y) *y = m_logicalScaleY;
|
||||
};
|
||||
|
||||
void wxDC::SetLogicalOrigin( long x, long y )
|
||||
void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
|
||||
{
|
||||
m_logicalOriginX = x * m_signX; // is this still correct ?
|
||||
m_logicalOriginY = y * m_signY;
|
||||
ComputeScaleAndOrigin();
|
||||
};
|
||||
|
||||
void wxDC::GetLogicalOrigin( long *x, long *y )
|
||||
{
|
||||
if (x) *x = m_logicalOriginX;
|
||||
if (y) *y = m_logicalOriginY;
|
||||
};
|
||||
|
||||
void wxDC::SetDeviceOrigin( long x, long y )
|
||||
void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
|
||||
{
|
||||
m_externalDeviceOriginX = x;
|
||||
m_externalDeviceOriginY = y;
|
||||
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 )
|
||||
{
|
||||
m_internalDeviceOriginX = x;
|
||||
@@ -476,53 +385,14 @@ void wxDC::GetInternalDeviceOrigin( long *x, long *y )
|
||||
if (x) *x = m_internalDeviceOriginX;
|
||||
if (y) *y = m_internalDeviceOriginY;
|
||||
};
|
||||
|
||||
*/
|
||||
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
|
||||
{
|
||||
m_signX = (xLeftRight ? 1 : -1);
|
||||
m_signY = (yBottomUp ? -1 : 1);
|
||||
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 )
|
||||
{
|
||||
@@ -531,6 +401,16 @@ void wxDC::CalcBoundingBox( long x, long y )
|
||||
if (x > m_maxX) m_maxX = x;
|
||||
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)
|
||||
{
|
||||
@@ -547,12 +427,7 @@ void wxDC::ComputeScaleAndOrigin(void)
|
||||
// CMB: if scale has changed call SetPen to recalulate the line width
|
||||
if (m_scaleX != origScaleX || m_scaleY != origScaleY)
|
||||
{
|
||||
// this is a bit artificial, but we need to force wxDC to think
|
||||
// the pen has changed
|
||||
wxPen* pen = & GetPen();
|
||||
wxPen tempPen;
|
||||
m_pen = tempPen;
|
||||
SetPen(* pen);
|
||||
// TODO : set internal flags for recalc
|
||||
}
|
||||
};
|
||||
|
||||
@@ -634,16 +509,17 @@ void wxDC::SetLogicalFunction( int function )
|
||||
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 ;
|
||||
}
|
||||
|
||||
void wxDC::DrawLine( long x1, long y1, long x2, long y2 )
|
||||
void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
||||
{
|
||||
if (!Ok())
|
||||
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())
|
||||
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())
|
||||
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 ,
|
||||
int fillStyle )
|
||||
void wxDC::DoDrawPolygon(int n, wxPoint points[],
|
||||
wxCoord xoffset, wxCoord yoffset,
|
||||
int fillStyle )
|
||||
{
|
||||
if (!Ok())
|
||||
return;
|
||||
@@ -754,7 +635,7 @@ void wxDC::DrawPolygon( int n, wxPoint points[], long xoffset , long yoffset ,
|
||||
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())
|
||||
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())
|
||||
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())
|
||||
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;
|
||||
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,
|
||||
wxDC *source, long xsrc, long ysrc, int logical_func , bool useMask )
|
||||
bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
|
||||
wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask )
|
||||
{
|
||||
if (!Ok()) return FALSE;
|
||||
MacVerifySetup() ;
|
||||
@@ -1069,8 +952,8 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
|
||||
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
|
||||
RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
|
||||
RGBColor black = { 0,0,0} ;
|
||||
RGBForeColor( &m_textForegroundColour.GetPixel() ) ;
|
||||
RGBBackColor( &m_textBackgroundColour.GetPixel() ) ;
|
||||
RGBForeColor( &m_textForegroundColour.GetPixel() ) ;
|
||||
RGBBackColor( &m_textBackgroundColour.GetPixel() ) ;
|
||||
|
||||
if ( LockPixels(bmappixels) )
|
||||
{
|
||||
@@ -1094,7 +977,7 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
|
||||
logical_func == wxXOR ? srcXor :
|
||||
// logical_func == wxOR_REVERSE ? MERGEPAINT :
|
||||
// logical_func == wxAND_REVERSE ? SRCERASE :
|
||||
logical_func == wxSRC_OR ? srcOr :
|
||||
// logical_func == wxSRC_OR ? srcOr :
|
||||
// logical_func == wxSRC_AND ? SRCAND :
|
||||
srcCopy );
|
||||
|
||||
@@ -1103,14 +986,15 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
|
||||
wxASSERT( mode == srcCopy ) ;
|
||||
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 ) ;
|
||||
UnlockPixels( GetGWorldPixMap( source->m_macMask ) ) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyBits( &GrafPtr( sourcePort )->portBits , &GrafPtr( m_macPort )->portBits ,
|
||||
CopyBits( GetPortBitMapForCopyBits( sourcePort ) , GetPortBitMapForCopyBits( m_macPort ) ,
|
||||
&srcrect, &dstrect, mode, NULL ) ;
|
||||
}
|
||||
UnlockPixels( bmappixels ) ;
|
||||
@@ -1123,7 +1007,11 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
|
||||
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())
|
||||
return;
|
||||
@@ -1161,14 +1049,14 @@ void wxDC::DrawText( const wxString &string, long x, long y, bool use16)
|
||||
|
||||
if ( wxApp::s_macDefaultEncodingIsPC )
|
||||
{
|
||||
macText = wxMacMakeMacStringFromPC( string ) ;
|
||||
macText = wxMacMakeMacStringFromPC( strtext ) ;
|
||||
text = macText ;
|
||||
length = macText.Length() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = string ;
|
||||
length = string.Length() ;
|
||||
text = strtext ;
|
||||
length = strtext.Length() ;
|
||||
}
|
||||
|
||||
int laststop = 0 ;
|
||||
@@ -1200,9 +1088,9 @@ bool wxDC::CanGetTextExtent(void) const
|
||||
return true ;
|
||||
}
|
||||
|
||||
void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
|
||||
long *descent, long *externalLeading ,
|
||||
wxFont *theFont , bool use16 ) const
|
||||
void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height,
|
||||
wxCoord *descent, wxCoord *externalLeading ,
|
||||
wxFont *theFont ) const
|
||||
{
|
||||
if (!Ok())
|
||||
return;
|
||||
@@ -1217,11 +1105,8 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
|
||||
|
||||
if ( font )
|
||||
{
|
||||
long yy1 = YLOG2DEV(0);
|
||||
long yy2 = YLOG2DEV(font->m_macFontSize);
|
||||
|
||||
::TextFont( font->m_macFontNum ) ;
|
||||
::TextSize( abs( yy2-yy1) ) ;
|
||||
::TextSize( YLOG2DEVREL( font->m_macFontSize) ) ;
|
||||
::TextFace( font->m_macFontStyle ) ;
|
||||
}
|
||||
}
|
||||
@@ -1233,9 +1118,12 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
|
||||
FontInfo fi ;
|
||||
::GetFontInfo( &fi ) ;
|
||||
|
||||
*height = fi.descent + fi.ascent ;
|
||||
*descent = fi.descent ;
|
||||
*externalLeading = fi.leading ;
|
||||
if ( height )
|
||||
*height = YDEV2LOGREL( fi.descent + fi.ascent ) ;
|
||||
if ( descent )
|
||||
*descent =YDEV2LOGREL( fi.descent );
|
||||
if ( externalLeading )
|
||||
*externalLeading = YDEV2LOGREL( fi.leading ) ;
|
||||
|
||||
const char *text = NULL ;
|
||||
int length = 0 ;
|
||||
@@ -1255,24 +1143,28 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
|
||||
int laststop = 0 ;
|
||||
int i = 0 ;
|
||||
int curwidth = 0 ;
|
||||
*width = 0 ;
|
||||
|
||||
while( i < length )
|
||||
if ( width )
|
||||
{
|
||||
if( text[i] == 13 || text[i] == 10)
|
||||
{
|
||||
*height += fi.descent + fi.ascent + fi.leading;
|
||||
curwidth = ::TextWidth( text , laststop , i - laststop ) ;
|
||||
if ( curwidth > *width )
|
||||
*width = curwidth ;
|
||||
laststop = i+1 ;
|
||||
}
|
||||
i++ ;
|
||||
}
|
||||
*width = 0 ;
|
||||
|
||||
curwidth = ::TextWidth( text , laststop , i - laststop ) ;
|
||||
if ( curwidth > *width )
|
||||
*width = curwidth ;
|
||||
while( i < length )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
@@ -1292,7 +1184,7 @@ wxCoord wxDC::GetCharWidth(void) const
|
||||
FontInfo fi ;
|
||||
::GetFontInfo( &fi ) ;
|
||||
|
||||
return (fi.descent + fi.ascent) / 2 ;
|
||||
return YDEV2LOGREL((fi.descent + fi.ascent) / 2) ;
|
||||
}
|
||||
|
||||
wxCoord wxDC::GetCharHeight(void) const
|
||||
@@ -1307,7 +1199,7 @@ wxCoord wxDC::GetCharHeight(void) const
|
||||
FontInfo fi ;
|
||||
::GetFontInfo( &fi ) ;
|
||||
|
||||
return fi.descent + fi.ascent ;
|
||||
return YDEV2LOGREL( fi.descent + fi.ascent );
|
||||
}
|
||||
|
||||
void wxDC::Clear(void)
|
||||
@@ -1332,6 +1224,7 @@ void wxDC::MacInstallFont() const
|
||||
|
||||
if ( m_macFontInstalled )
|
||||
return ;
|
||||
Pattern blackColor ;
|
||||
|
||||
wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
|
||||
|
||||
@@ -1377,7 +1270,7 @@ void wxDC::MacInstallFont() const
|
||||
mode = patCopy ;
|
||||
break ;
|
||||
case wxINVERT: // NOT dst
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
mode = patXor ;
|
||||
break ;
|
||||
case wxXOR: // src XOR dst
|
||||
@@ -1403,8 +1296,8 @@ void wxDC::MacInstallFont() const
|
||||
case wxNAND: // (NOT src) OR (NOT dst)
|
||||
case wxOR: // src OR dst
|
||||
case wxSET: // 1
|
||||
case wxSRC_OR: // source _bitmap_ OR destination
|
||||
case wxSRC_AND: // source _bitmap_ AND destination
|
||||
// case wxSRC_OR: // source _bitmap_ OR destination
|
||||
// case wxSRC_AND: // source _bitmap_ AND destination
|
||||
break ;
|
||||
}
|
||||
::PenMode( mode ) ;
|
||||
@@ -1447,6 +1340,8 @@ void wxDC::MacInstallPen() const
|
||||
return;
|
||||
MacVerifySetup() ;
|
||||
|
||||
Pattern blackColor;
|
||||
|
||||
if ( m_macPenInstalled )
|
||||
return ;
|
||||
|
||||
@@ -1460,7 +1355,7 @@ void wxDC::MacInstallPen() const
|
||||
int penStyle = m_pen.GetStyle();
|
||||
|
||||
if (penStyle == wxSOLID)
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
else if (IS_HATCH(penStyle))
|
||||
{
|
||||
Pattern pat ;
|
||||
@@ -1469,7 +1364,7 @@ void wxDC::MacInstallPen() const
|
||||
}
|
||||
else
|
||||
{
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
}
|
||||
|
||||
short mode = patCopy ;
|
||||
@@ -1482,7 +1377,7 @@ void wxDC::MacInstallPen() const
|
||||
mode = patCopy ;
|
||||
break ;
|
||||
case wxINVERT: // NOT dst
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
mode = patXor ;
|
||||
break ;
|
||||
case wxXOR: // src XOR dst
|
||||
@@ -1508,8 +1403,8 @@ void wxDC::MacInstallPen() const
|
||||
case wxNAND: // (NOT src) OR (NOT dst)
|
||||
case wxOR: // src OR dst
|
||||
case wxSET: // 1
|
||||
case wxSRC_OR: // source _bitmap_ OR destination
|
||||
case wxSRC_AND: // source _bitmap_ AND destination
|
||||
// case wxSRC_OR: // source _bitmap_ OR destination
|
||||
// case wxSRC_AND: // source _bitmap_ AND destination
|
||||
break ;
|
||||
}
|
||||
::PenMode( mode ) ;
|
||||
@@ -1523,7 +1418,7 @@ void wxDC::MacInstallBrush() const
|
||||
if (!Ok())
|
||||
return;
|
||||
MacVerifySetup() ;
|
||||
|
||||
Pattern blackColor, whiteColor ;
|
||||
if ( m_macBrushInstalled )
|
||||
return ;
|
||||
|
||||
@@ -1534,7 +1429,7 @@ void wxDC::MacInstallBrush() const
|
||||
|
||||
int brushStyle = m_brush.GetStyle();
|
||||
if (brushStyle == wxSOLID)
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
else if (IS_HATCH(brushStyle))
|
||||
{
|
||||
Pattern pat ;
|
||||
@@ -1543,7 +1438,7 @@ void wxDC::MacInstallBrush() const
|
||||
}
|
||||
else
|
||||
{
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
}
|
||||
|
||||
|
||||
@@ -1551,7 +1446,7 @@ void wxDC::MacInstallBrush() const
|
||||
|
||||
brushStyle = m_backgroundBrush.GetStyle();
|
||||
if (brushStyle == wxSOLID)
|
||||
::BackPat(&qd.white);
|
||||
::BackPat(GetQDGlobalsWhite(&whiteColor));
|
||||
else if (IS_HATCH(brushStyle))
|
||||
{
|
||||
Pattern pat ;
|
||||
@@ -1560,7 +1455,7 @@ void wxDC::MacInstallBrush() const
|
||||
}
|
||||
else
|
||||
{
|
||||
::BackPat(&qd.white);
|
||||
::BackPat(GetQDGlobalsWhite(&whiteColor));
|
||||
}
|
||||
|
||||
short mode = patCopy ;
|
||||
@@ -1573,7 +1468,7 @@ void wxDC::MacInstallBrush() const
|
||||
mode = patCopy ;
|
||||
break ;
|
||||
case wxINVERT: // NOT dst
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
mode = patXor ;
|
||||
break ;
|
||||
case wxXOR: // src XOR dst
|
||||
@@ -1599,8 +1494,8 @@ void wxDC::MacInstallBrush() const
|
||||
case wxNAND: // (NOT src) OR (NOT dst)
|
||||
case wxOR: // src OR dst
|
||||
case wxSET: // 1
|
||||
case wxSRC_OR: // source _bitmap_ OR destination
|
||||
case wxSRC_AND: // source _bitmap_ AND destination
|
||||
// case wxSRC_OR: // source _bitmap_ OR destination
|
||||
// case wxSRC_AND: // source _bitmap_ AND destination
|
||||
break ;
|
||||
}
|
||||
::PenMode( mode ) ;
|
||||
@@ -1609,4 +1504,47 @@ void wxDC::MacInstallBrush() const
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,11 @@
|
||||
// wxPaintDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wxWindowDC
|
||||
@@ -38,7 +40,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
|
||||
|
||||
#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 );
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
m_minY = m_minX = 0;
|
||||
wxSize size = the_canvas->GetSize() ;
|
||||
m_maxX = size.x ;
|
||||
m_maxY = size.y ;
|
||||
|
||||
MacSetupPort() ;
|
||||
m_ok = TRUE ;
|
||||
}
|
||||
|
||||
wxWindowDC::~wxWindowDC(void)
|
||||
wxWindowDC::~wxWindowDC()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -63,7 +70,7 @@ wxWindowDC::~wxWindowDC(void)
|
||||
* wxClientDC
|
||||
*/
|
||||
|
||||
wxClientDC::wxClientDC(void)
|
||||
wxClientDC::wxClientDC()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -75,12 +82,16 @@ wxClientDC::wxClientDC(wxWindow *window)
|
||||
window->MacGetPortClientParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow );
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
MacSetupPort() ;
|
||||
m_minY = m_minX = 0;
|
||||
wxSize size = window->GetSize() ;
|
||||
m_maxX = size.x ;
|
||||
m_maxY = size.y ;
|
||||
m_ok = TRUE ;
|
||||
SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
|
||||
SetFont( window->GetFont() ) ;
|
||||
}
|
||||
|
||||
wxClientDC::~wxClientDC(void)
|
||||
wxClientDC::~wxClientDC()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -88,7 +99,7 @@ wxClientDC::~wxClientDC(void)
|
||||
* wxPaintDC
|
||||
*/
|
||||
|
||||
wxPaintDC::wxPaintDC(void)
|
||||
wxPaintDC::wxPaintDC()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -104,6 +115,10 @@ wxPaintDC::wxPaintDC(wxWindow *window)
|
||||
m_ok = TRUE ;
|
||||
long 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 ) ;
|
||||
SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
|
||||
SetFont(window->GetFont() ) ;
|
||||
|
||||
@@ -33,10 +33,20 @@ wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
|
||||
|
||||
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 )
|
||||
{
|
||||
if ( m_selected.Ok() )
|
||||
{
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
|
||||
UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ;
|
||||
}
|
||||
m_selected = bitmap;
|
||||
if (m_selected.Ok())
|
||||
{
|
||||
@@ -44,6 +54,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
||||
if ( bmap->m_hBitmap )
|
||||
{
|
||||
m_macPort = (GrafPtr) bmap->m_hBitmap ;
|
||||
LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
|
||||
wxMask * mask = bitmap.GetMask() ;
|
||||
if ( mask )
|
||||
{
|
||||
|
||||
@@ -25,31 +25,36 @@
|
||||
|
||||
#include "wx/dcprint.h"
|
||||
#include "math.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_CLASS(wxPrinterDC, wxDC)
|
||||
#endif
|
||||
|
||||
GrafPtr macPrintFormerPort = NULL ;
|
||||
|
||||
wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
OSErr err ;
|
||||
wxString message ;
|
||||
|
||||
m_printData = printdata ;
|
||||
m_printData.ConvertToNative() ;
|
||||
|
||||
::PrOpen() ;
|
||||
::UMAPrOpen() ;
|
||||
err = PrError() ;
|
||||
if ( err )
|
||||
{
|
||||
message.Printf( "Print Error %d", err ) ;
|
||||
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
|
||||
PrClose() ;
|
||||
UMAPrClose() ;
|
||||
}
|
||||
|
||||
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 ?
|
||||
}
|
||||
err = PrError() ;
|
||||
@@ -57,20 +62,31 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
|
||||
{
|
||||
message.Printf( "Print Error %d", err ) ;
|
||||
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
|
||||
PrClose() ;
|
||||
UMAPrClose() ;
|
||||
}
|
||||
::GetPort( &macPrintFormerPort ) ;
|
||||
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
|
||||
m_macPort = (GrafPtr ) m_macPrintPort ;
|
||||
m_ok = TRUE ;
|
||||
m_minY = m_minX = 0 ;
|
||||
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 ;
|
||||
#else
|
||||
#pragma warning "TODO:printing support for carbon"
|
||||
#endif
|
||||
}
|
||||
|
||||
wxPrinterDC::~wxPrinterDC(void)
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
if ( m_ok )
|
||||
{
|
||||
OSErr err ;
|
||||
@@ -91,11 +107,16 @@ wxPrinterDC::~wxPrinterDC(void)
|
||||
{
|
||||
message.Printf( "Print Error %d", err ) ;
|
||||
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
|
||||
PrClose() ;
|
||||
UMAPrClose() ;
|
||||
}
|
||||
::PrClose() ;
|
||||
::SetPort( macPrintFormerPort ) ;
|
||||
::UMAPrClose() ;
|
||||
// ::SetPort( macPrintFormerPort ) ;
|
||||
::SetPort( LMGetWMgrPort() ) ;
|
||||
m_macPortHelper.Clear() ;
|
||||
}
|
||||
#else
|
||||
#pragma warning "TODO:printing support for carbon"
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) )
|
||||
@@ -109,13 +130,30 @@ void wxPrinterDC::EndDoc(void)
|
||||
|
||||
void wxPrinterDC::StartPage(void)
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
if ( !m_ok )
|
||||
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 ;
|
||||
wxString message ;
|
||||
|
||||
PrOpenPage( m_macPrintPort , NULL ) ;
|
||||
PrOpenPage( m_macPrintPort , NULL ) ;
|
||||
SetOrigin( - (**m_printData.m_macPrintInfo).rPaper.left , - (**m_printData.m_macPrintInfo).rPaper.top ) ;
|
||||
Rect clip = { -32000 , -32000 , 32000 , 32000 } ;
|
||||
::ClipRect( &clip ) ;
|
||||
@@ -126,14 +164,18 @@ void wxPrinterDC::StartPage(void)
|
||||
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
|
||||
::PrClosePage( m_macPrintPort) ;
|
||||
::PrCloseDoc( m_macPrintPort ) ;
|
||||
::PrClose() ;
|
||||
::UMAPrClose() ;
|
||||
::SetPort( macPrintFormerPort ) ;
|
||||
m_ok = FALSE ;
|
||||
}
|
||||
#else
|
||||
#pragma warning "TODO:printing support for carbon"
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxPrinterDC::EndPage(void)
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
if ( !m_ok )
|
||||
return ;
|
||||
|
||||
@@ -147,8 +189,12 @@ void wxPrinterDC::EndPage(void)
|
||||
message.Printf( "Print Error %d", err ) ;
|
||||
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
|
||||
::PrCloseDoc( m_macPrintPort ) ;
|
||||
::PrClose() ;
|
||||
::UMAPrClose() ;
|
||||
::SetPort( macPrintFormerPort ) ;
|
||||
m_ok = FALSE ;
|
||||
}
|
||||
#else
|
||||
#pragma warning "TODO:printing support for carbon"
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -14,15 +14,34 @@
|
||||
#endif
|
||||
|
||||
#include "wx/dcscreen.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
|
||||
#endif
|
||||
|
||||
// Create a DC representing the whole screen
|
||||
wxScreenDC::wxScreenDC()
|
||||
{
|
||||
#if TARGET_CARBON
|
||||
m_macPort = GetQDGlobalsThePort() ;
|
||||
#else
|
||||
m_macPort = LMGetWMgrPort() ;
|
||||
#endif
|
||||
MacSetupPort() ;
|
||||
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()
|
||||
|
||||
@@ -27,6 +27,7 @@ wxList wxModalDialogs;
|
||||
wxList wxModelessWindows; // Frames and modeless dialogs
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog, wxPanel)
|
||||
@@ -39,11 +40,11 @@ BEGIN_EVENT_TABLE(wxDialog, wxPanel)
|
||||
EVT_CLOSE(wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#endif
|
||||
|
||||
wxDialog::wxDialog()
|
||||
{
|
||||
m_isShown = FALSE;
|
||||
m_modalShowing = FALSE;
|
||||
m_isShown = FALSE;
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
}
|
||||
|
||||
@@ -54,15 +55,8 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
||||
long style,
|
||||
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));
|
||||
SetName(name);
|
||||
|
||||
if (!parent)
|
||||
wxTopLevelWindows.Append(this);
|
||||
@@ -74,59 +68,26 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
||||
else
|
||||
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 ;
|
||||
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
|
||||
m_macWindowData->m_macFocus = NULL ;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxDialog::SetModal(bool flag)
|
||||
{
|
||||
if ( flag )
|
||||
m_windowStyle |= wxDIALOG_MODAL ;
|
||||
else
|
||||
if ( m_windowStyle & wxDIALOG_MODAL )
|
||||
m_windowStyle -= wxDIALOG_MODAL ;
|
||||
if ( flag )
|
||||
{
|
||||
m_windowStyle |= wxDIALOG_MODAL;
|
||||
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
if (!flag)
|
||||
wxModelessWindows.Append(this);
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_windowStyle &= ~wxDIALOG_MODAL;
|
||||
|
||||
wxModelessWindows.Append(this);
|
||||
}
|
||||
}
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
@@ -134,10 +95,10 @@ wxDialog::~wxDialog()
|
||||
m_isBeingDeleted = TRUE ;
|
||||
wxTopLevelWindows.DeleteObject(this);
|
||||
|
||||
m_modalShowing = FALSE;
|
||||
Show(FALSE);
|
||||
|
||||
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
if ( !IsModal() )
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
|
||||
// If this is the last top-level window, exit.
|
||||
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
|
||||
@@ -184,19 +145,20 @@ void wxDialog::DoSetClientSize(int width, int height)
|
||||
wxWindow::DoSetClientSize( width , height ) ;
|
||||
}
|
||||
|
||||
void wxDialog::GetPosition(int *x, int *y) const
|
||||
void wxDialog::DoGetPosition(int *x, int *y) const
|
||||
{
|
||||
DoGetPosition( x , y ) ;
|
||||
}
|
||||
|
||||
bool wxDialog::IsShown() const
|
||||
{
|
||||
return m_isShown;
|
||||
wxWindow::DoGetPosition( x , y ) ;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
m_isShown = show;
|
||||
|
||||
if (show)
|
||||
InitDialog();
|
||||
|
||||
bool modal = ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL) ;
|
||||
|
||||
#if WXGARBAGE_COLLECTION_ON /* MATTHEW: GC */
|
||||
if (!modal)
|
||||
{
|
||||
if (show)
|
||||
if ( !wxDialogBase::Show(show) )
|
||||
{
|
||||
if (!wxModelessWindows.Find(this))
|
||||
wxModelessWindows.Append(this);
|
||||
// nothing to do
|
||||
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 ;
|
||||
if (show)
|
||||
{
|
||||
if (m_modalShowing)
|
||||
{
|
||||
// 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 ;
|
||||
while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() )
|
||||
{
|
||||
}
|
||||
wxTheApp->MacDoOneEvent() ;
|
||||
}
|
||||
else // !modal
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
UMAShowWindow( m_macWindowData->m_macWindow ) ;
|
||||
UMASelectWindow( m_macWindowData->m_macWindow ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
UMAHideWindow( m_macWindowData->m_macWindow ) ;
|
||||
}
|
||||
}
|
||||
return TRUE ;
|
||||
|
||||
s_macIsInModalLoop = false ;
|
||||
|
||||
// TODO probably reenable the parent window if any
|
||||
|
||||
// and restore focus
|
||||
if ( winFocus )
|
||||
{
|
||||
winFocus->SetFocus();
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
int wxDialog::ShowModal()
|
||||
@@ -328,6 +245,8 @@ int wxDialog::ShowModal()
|
||||
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)
|
||||
{
|
||||
SetReturnCode(retCode);
|
||||
@@ -339,13 +258,7 @@ void wxDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
{
|
||||
if ( IsModal() )
|
||||
EndModal(wxID_OK);
|
||||
else
|
||||
{
|
||||
SetReturnCode(wxID_OK);
|
||||
this->Show(FALSE);
|
||||
}
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,20 +271,7 @@ void wxDialog::OnApply(wxCommandEvent& event)
|
||||
|
||||
void wxDialog::OnCancel(wxCommandEvent& event)
|
||||
{
|
||||
if ( IsModal() )
|
||||
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)
|
||||
@@ -407,30 +307,16 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event)
|
||||
// Destroy the window (delayed, if a managed window)
|
||||
bool wxDialog::Destroy()
|
||||
{
|
||||
if (!wxPendingDelete.Member(this))
|
||||
wxCHECK_MSG( !wxPendingDelete.Member(this), FALSE,
|
||||
_T("wxDialog destroyed twice") );
|
||||
|
||||
wxPendingDelete.Append(this);
|
||||
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)
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void wxDialog::Fit()
|
||||
{
|
||||
wxWindow::Fit();
|
||||
}
|
||||
|
||||
|
||||
@@ -147,6 +147,7 @@ bool wxDirData::Read(wxString *filename)
|
||||
if ( err != noErr )
|
||||
break ;
|
||||
|
||||
p2cstr( m_name ) ;
|
||||
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory
|
||||
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
|
||||
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 ;
|
||||
}
|
||||
if ( err != noErr )
|
||||
{
|
||||
return FALSE ;
|
||||
}
|
||||
FSSpec spec ;
|
||||
|
||||
FSMakeFSSpecCompat(m_CPB.hFileInfo.ioVRefNum, m_dirId, m_name,&spec) ;
|
||||
|
||||
*filename = wxMacFSSpec2UnixFilename( &spec ) ;
|
||||
*filename = (char*) m_name ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -20,19 +20,9 @@
|
||||
|
||||
#include "wx/cmndata.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_CLASS(wxDirDialog, wxDialog)
|
||||
|
||||
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
|
||||
};
|
||||
#endif
|
||||
|
||||
// the data we need to pass to our standard file hook routine
|
||||
// includes a pointer to the dialog, a pointer to the standard
|
||||
@@ -48,6 +38,21 @@ struct UserDataRec {
|
||||
typedef struct UserDataRec
|
||||
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)
|
||||
{
|
||||
GetIndString(theStr, kStrListID, stringNum);
|
||||
@@ -302,6 +307,7 @@ static pascal short SFGetFolderDialogHook(short item, DialogPtr theDlgPtr, Ptr d
|
||||
|
||||
return item;
|
||||
}
|
||||
#endif
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
@@ -329,6 +335,8 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
|
||||
|
||||
// display the dialog
|
||||
|
||||
#if !TARGET_CARBON
|
||||
|
||||
dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook);
|
||||
myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter);
|
||||
|
||||
@@ -350,6 +358,8 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
|
||||
|
||||
DisposeRoutineDescriptor(dlgHookUPP);
|
||||
DisposeRoutineDescriptor(myModalFilterUPP);
|
||||
#else
|
||||
#endif
|
||||
|
||||
// if cancel wasn't pressed and no fatal error occurred...
|
||||
|
||||
@@ -445,14 +455,18 @@ int wxDirDialog::ShowModal()
|
||||
strcpy((char *)path, m_path ) ;
|
||||
c2pstr((char *)path ) ;
|
||||
|
||||
FileFilterYDUPP invisiblesExcludedCustomFilterUPP;
|
||||
StandardFileReply reply ;
|
||||
FileFilterYDUPP invisiblesExcludedCustomFilterUPP = 0 ;
|
||||
#if !TARGET_CARBON
|
||||
invisiblesExcludedCustomFilterUPP =
|
||||
NewFileFilterYDProc(OnlyVisibleFoldersCustomFileFilter);
|
||||
#endif
|
||||
|
||||
StandardGetFolder( prompt , path , invisiblesExcludedCustomFilterUPP, &reply);
|
||||
|
||||
#if !TARGET_CARBON
|
||||
DisposeRoutineDescriptor(invisiblesExcludedCustomFilterUPP);
|
||||
#endif
|
||||
if ( reply.sfGood == false )
|
||||
{
|
||||
m_path = "" ;
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "wx/app.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -131,3 +133,4 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
||||
return wxDragError;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -19,7 +19,9 @@
|
||||
#include "wx/filedlg.h"
|
||||
#include "wx/intl.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_CLASS(wxFileDialog, wxDialog)
|
||||
#endif
|
||||
|
||||
// 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)
|
||||
{
|
||||
enum
|
||||
@@ -97,25 +120,6 @@ enum {
|
||||
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)
|
||||
{
|
||||
GetIndString(theStr, kStrListID, stringNum);
|
||||
@@ -185,6 +189,7 @@ static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRec
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
@@ -241,6 +246,8 @@ void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const
|
||||
}
|
||||
// display the dialog
|
||||
|
||||
#if !TARGET_CARBON
|
||||
|
||||
dlgHookUPP = NULL ;
|
||||
// dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook);
|
||||
myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter);
|
||||
@@ -263,7 +270,8 @@ void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const
|
||||
|
||||
DisposeRoutineDescriptor(dlgHookUPP);
|
||||
DisposeRoutineDescriptor(myModalFilterUPP);
|
||||
|
||||
#else
|
||||
#endif
|
||||
// if cancel wasn't pressed and no fatal error occurred...
|
||||
|
||||
if (theSFR->sfGood)
|
||||
@@ -454,8 +462,12 @@ int wxFileDialog::ShowModal()
|
||||
|
||||
strcpy((char *)filename, m_fileName) ;
|
||||
c2pstr((char *)filename ) ;
|
||||
#if !TARGET_CARBON
|
||||
|
||||
StandardPutFile( prompt , filename , &reply ) ;
|
||||
|
||||
#else
|
||||
#endif
|
||||
if ( reply.sfGood == false )
|
||||
{
|
||||
m_path = "" ;
|
||||
@@ -479,14 +491,17 @@ int wxFileDialog::ShowModal()
|
||||
strcpy((char *)path, m_path ) ;
|
||||
c2pstr((char *)path ) ;
|
||||
|
||||
FileFilterYDUPP crossPlatformFileFilterUPP;
|
||||
StandardFileReply reply ;
|
||||
FileFilterYDUPP crossPlatformFileFilterUPP = 0 ;
|
||||
#if !TARGET_CARBON
|
||||
crossPlatformFileFilterUPP =
|
||||
NewFileFilterYDProc(CrossPlatformFileFilter);
|
||||
#endif
|
||||
|
||||
ExtendedOpenFile( prompt , path , m_wildCard , crossPlatformFileFilterUPP, &reply);
|
||||
|
||||
DisposeRoutineDescriptor(crossPlatformFileFilterUPP);
|
||||
#if !TARGET_CARBON
|
||||
DisposeFileFilterYDUPP(crossPlatformFileFilterUPP);
|
||||
#endif
|
||||
if ( reply.sfGood == false )
|
||||
{
|
||||
m_path = "" ;
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
#include "wx/font.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -77,7 +79,7 @@ void wxFontRefData::MacFindFont()
|
||||
::GetFNum( "\pTimes" , &m_macFontNum) ;
|
||||
break ;
|
||||
case wxSWISS :
|
||||
::GetFNum( "\pHelvetica" , &m_macFontNum) ;
|
||||
::GetFNum( "\pGeneva" , &m_macFontNum) ;
|
||||
break ;
|
||||
case wxMODERN :
|
||||
::GetFNum( "\pMonaco" , &m_macFontNum) ;
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include "wx/mac/fontdlg.h"
|
||||
#include "wx/cmndata.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wxFontDialog
|
||||
|
||||
@@ -48,18 +48,12 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// convert to/from the string representation: format is
|
||||
// encodingid;facename[;charset]
|
||||
// facename[;charset]
|
||||
|
||||
bool wxNativeEncodingInfo::FromString(const wxString& s)
|
||||
{
|
||||
wxStringTokenizer tokenizer(s, _T(";"));
|
||||
|
||||
wxString encid = tokenizer.GetNextToken();
|
||||
long enc;
|
||||
if ( !encid.ToLong(&enc) )
|
||||
return FALSE;
|
||||
encoding = (wxFontEncoding)enc;
|
||||
|
||||
facename = tokenizer.GetNextToken();
|
||||
if ( !facename )
|
||||
return FALSE;
|
||||
@@ -85,10 +79,7 @@ bool wxNativeEncodingInfo::FromString(const wxString& s)
|
||||
|
||||
wxString wxNativeEncodingInfo::ToString() const
|
||||
{
|
||||
wxString s;
|
||||
|
||||
s << (long)encoding << _T(';') << facename;
|
||||
|
||||
wxString s(facename);
|
||||
if ( charset != 0 )
|
||||
{
|
||||
s << _T(';') << charset;
|
||||
@@ -159,8 +150,6 @@ bool wxGetNativeFontEncoding(wxFontEncoding encoding,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
info->encoding = encoding;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/frame.h"
|
||||
#include "wx/statusbr.h"
|
||||
#include "wx/mac/statusbr.h"
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/menuitem.h"
|
||||
#include "wx/menu.h"
|
||||
@@ -28,16 +28,18 @@
|
||||
extern wxList wxModelessWindows;
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
BEGIN_EVENT_TABLE(wxFrame, wxWindow)
|
||||
EVT_SIZE(wxFrame::OnSize)
|
||||
#if !USE_SHARED_LIBRARY
|
||||
BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
|
||||
// EVT_SIZE(wxFrame::OnSize)
|
||||
EVT_ACTIVATE(wxFrame::OnActivate)
|
||||
EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
|
||||
// EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
|
||||
EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
|
||||
EVT_IDLE(wxFrame::OnIdle)
|
||||
EVT_CLOSE(wxFrame::OnCloseWindow)
|
||||
// EVT_IDLE(wxFrame::OnIdle)
|
||||
// EVT_CLOSE(wxFrame::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
|
||||
#endif
|
||||
|
||||
#if wxUSE_NATIVE_STATUSBAR
|
||||
bool wxFrame::m_useNativeStatusBar = TRUE;
|
||||
@@ -45,17 +47,43 @@ bool wxFrame::m_useNativeStatusBar = TRUE;
|
||||
bool wxFrame::m_useNativeStatusBar = FALSE;
|
||||
#endif
|
||||
|
||||
wxFrame::wxFrame()
|
||||
{
|
||||
#if wxUSE_TOOLBAR
|
||||
m_frameToolBar = NULL ;
|
||||
#endif
|
||||
#define WX_MAC_STATUSBAR_HEIGHT 15
|
||||
// ----------------------------------------------------------------------------
|
||||
// creation/destruction
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// in order to be able to give size events on show
|
||||
m_frameMenuBar = NULL;
|
||||
m_frameStatusBar = NULL;
|
||||
m_iconized = FALSE;
|
||||
m_isShown = FALSE;
|
||||
void wxFrame::Init()
|
||||
{
|
||||
m_iconized = 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,
|
||||
@@ -66,13 +94,7 @@ bool wxFrame::Create(wxWindow *parent,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
if (!parent)
|
||||
wxTopLevelWindows.Append(this);
|
||||
|
||||
SetName(name);
|
||||
m_windowStyle = style;
|
||||
m_frameMenuBar = NULL;
|
||||
m_isShown = FALSE;
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
m_frameToolBar = NULL ;
|
||||
@@ -88,74 +110,24 @@ bool wxFrame::Create(wxWindow *parent,
|
||||
|
||||
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);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
wxFrame::~wxFrame()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
wxTopLevelWindows.DeleteObject(this);
|
||||
|
||||
if (m_frameStatusBar)
|
||||
delete m_frameStatusBar;
|
||||
if (m_frameMenuBar)
|
||||
delete m_frameMenuBar;
|
||||
DeleteAllBars();
|
||||
|
||||
/* 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
|
||||
void wxFrame::Maximize(bool maximize)
|
||||
{
|
||||
@@ -190,6 +172,11 @@ bool wxFrame::IsIconized() const
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxFrame::Iconize(bool iconize)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Is the frame maximized?
|
||||
bool wxFrame::IsMaximized(void) const
|
||||
{
|
||||
@@ -197,10 +184,14 @@ bool wxFrame::IsMaximized(void) const
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxFrame::Restore()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void wxFrame::SetIcon(const wxIcon& icon)
|
||||
{
|
||||
m_icon = icon;
|
||||
// TODO
|
||||
wxFrameBase::SetIcon(icon);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 17),
|
||||
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 = new wxStatusBar(this, id, style, name);
|
||||
|
||||
statusBar->SetFieldsCount(number);
|
||||
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()
|
||||
{
|
||||
if (m_frameStatusBar )
|
||||
@@ -274,7 +216,7 @@ void wxFrame::PositionStatusBar()
|
||||
|
||||
// Since we wish the status bar to be directly under the client area,
|
||||
// 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)
|
||||
{
|
||||
m_frameMenuBar = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
m_frameMenuBar = NULL;
|
||||
m_frameMenuBar = menuBar;
|
||||
// TODO : we move this into the app code
|
||||
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.
|
||||
void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
|
||||
@@ -337,217 +251,55 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& 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
|
||||
// subwindow found.
|
||||
void wxFrame::OnActivate(wxActivateEvent& event)
|
||||
{
|
||||
for(wxNode *node = GetChildren().First(); node; node = node->Next())
|
||||
{
|
||||
// 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)))
|
||||
if ( !event.GetActive() )
|
||||
{
|
||||
child->SetFocus();
|
||||
return;
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The default implementation for the close window event.
|
||||
void wxFrame::OnCloseWindow(wxCloseEvent& event)
|
||||
{
|
||||
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
|
||||
for ( wxWindowList::Node *node = GetChildren().GetFirst();
|
||||
node;
|
||||
node = node->GetNext() )
|
||||
{
|
||||
wxMenuBar *menuBar = GetMenuBar();
|
||||
if (menuBar)
|
||||
{
|
||||
wxString helpString(menuBar->GetHelpString(event.GetMenuId()));
|
||||
if (helpString != "")
|
||||
SetStatusText(helpString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// FIXME all this is totally bogus - we need to do the same as wxPanel,
|
||||
// but how to do it without duplicating the code?
|
||||
|
||||
wxMenuBar *wxFrame::GetMenuBar() const
|
||||
{
|
||||
return m_frameMenuBar;
|
||||
}
|
||||
// restore focus
|
||||
wxWindow *child = node->GetData();
|
||||
|
||||
|
||||
// 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 ( !child->IsTopLevel()
|
||||
#if wxUSE_TOOLBAR
|
||||
if (GetToolBar())
|
||||
{
|
||||
int w, h;
|
||||
GetToolBar()->GetSize(& w, & h);
|
||||
|
||||
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
|
||||
&& !wxDynamicCast(child, wxToolBar)
|
||||
#endif // wxUSE_TOOLBAR
|
||||
#if wxUSE_STATUSBAR
|
||||
&& !wxDynamicCast(child, wxStatusBar)
|
||||
#endif // wxUSE_STATUSBAR
|
||||
)
|
||||
{
|
||||
pt.x += w;
|
||||
}
|
||||
else
|
||||
{
|
||||
pt.y += h;
|
||||
child->SetFocus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return pt;
|
||||
}
|
||||
|
||||
void wxFrame::DoGetClientSize(int *x, int *y) const
|
||||
{
|
||||
wxWindow::DoGetClientSize( x , y ) ;
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
if ( GetStatusBar() )
|
||||
{
|
||||
int 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());
|
||||
*y -= pt.y;
|
||||
@@ -576,39 +328,20 @@ void wxFrame::DoSetClientSize(int clientwidth, int clientheight)
|
||||
#if wxUSE_TOOLBAR
|
||||
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
|
||||
{
|
||||
wxCHECK_MSG( m_frameToolBar == NULL, FALSE,
|
||||
"recreating toolbar in wxFrame" );
|
||||
|
||||
wxToolBar* toolBar = OnCreateToolBar(style, id, name);
|
||||
if (toolBar)
|
||||
if ( wxFrameBase::CreateToolBar(style, id, name) )
|
||||
{
|
||||
SetToolBar(toolBar);
|
||||
PositionToolBar();
|
||||
return toolBar;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name)
|
||||
{
|
||||
return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name);
|
||||
return m_frameToolBar;
|
||||
}
|
||||
|
||||
void wxFrame::PositionToolBar()
|
||||
{
|
||||
int cw, ch;
|
||||
|
||||
// TODO: we actually need to use the low-level client size, before
|
||||
// the toolbar/status bar were added.
|
||||
// So DEFINITELY replace the line below with something appropriate.
|
||||
|
||||
// GetClientSize(& cw, &ch);
|
||||
|
||||
cw = m_width ;
|
||||
ch = m_height ;
|
||||
cw = m_width ;
|
||||
ch = m_height ;
|
||||
|
||||
if ( GetStatusBar() )
|
||||
{
|
||||
@@ -627,12 +360,12 @@ void wxFrame::PositionToolBar()
|
||||
// Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
|
||||
// means, pretend we don't have toolbar/status bar, so we
|
||||
// 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
|
||||
{
|
||||
// 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include "wx/gauge.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
|
||||
#endif
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
|
||||
@@ -31,15 +33,13 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
m_rangeMax = range ;
|
||||
m_macHorizontalBorder = 2 ; // additional pixels around the real control
|
||||
m_macVerticalBorder = 2 ;
|
||||
|
||||
if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y)
|
||||
{
|
||||
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,
|
||||
kControlProgressBarProc , (long) this ) ;
|
||||
@@ -66,7 +66,7 @@ void wxGauge::SetRange(int r)
|
||||
void wxGauge::SetValue(int pos)
|
||||
{
|
||||
m_gaugePos = pos;
|
||||
::SetControlValue( m_macControl , m_gaugePos ) ;
|
||||
::SetControlValue( m_macControl , m_gaugePos ) ;
|
||||
}
|
||||
|
||||
int wxGauge::GetShadowWidth() const
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include "wx/gdiobj.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject)
|
||||
#endif
|
||||
|
||||
// TODO: Nothing to do, unless you want to.
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxXXXXHelpController, wxHelpControllerBase)
|
||||
#endif
|
||||
|
||||
wxXXXXHelpController::wxXXXXHelpController()
|
||||
{
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include "wx/icon.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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,
|
||||
int desiredWidth, int desiredHeight)
|
||||
|
||||
@@ -96,20 +106,23 @@ bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, lo
|
||||
c2pstr( (char*) theName ) ;
|
||||
|
||||
Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
|
||||
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
||||
ReleaseResource( resHandle ) ;
|
||||
|
||||
CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
|
||||
if ( theIcon )
|
||||
if ( resHandle != 0L )
|
||||
{
|
||||
M_ICONHANDLERDATA->m_hIcon = theIcon ;
|
||||
M_ICONHANDLERDATA->m_width = 32 ;
|
||||
M_ICONHANDLERDATA->m_height = 32 ;
|
||||
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
||||
ReleaseResource( resHandle ) ;
|
||||
|
||||
M_ICONHANDLERDATA->m_depth = 8 ;
|
||||
M_ICONHANDLERDATA->m_ok = true ;
|
||||
M_ICONHANDLERDATA->m_numColors = 256 ;
|
||||
return TRUE ;
|
||||
CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
|
||||
if ( theIcon )
|
||||
{
|
||||
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 ;
|
||||
}
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include "wx/stubs/imaglist.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject)
|
||||
#endif
|
||||
|
||||
wxImageList::wxImageList()
|
||||
{
|
||||
|
||||
@@ -21,11 +21,13 @@
|
||||
#include "wx/utils.h"
|
||||
#include "extldef.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxListBox, wxControl)
|
||||
EVT_SIZE( wxListBox::OnSize )
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
|
||||
@@ -41,6 +43,7 @@ wxListBox::wxListBox()
|
||||
{
|
||||
m_noItems = 0;
|
||||
m_selected = 0;
|
||||
m_macList = NULL ;
|
||||
}
|
||||
|
||||
bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
||||
@@ -56,8 +59,6 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
m_macHorizontalBorder = 5 ; // additional pixels around the real control
|
||||
m_macVerticalBorder = 5 ;
|
||||
|
||||
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
|
||||
|
||||
@@ -67,6 +68,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
||||
long result ;
|
||||
UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
|
||||
|
||||
HLock( (Handle) m_macList ) ;
|
||||
NewExtLDEFInfo( m_macList , MacDrawStringCell , (long) this ) ;
|
||||
(**m_macList).selFlags = 0 ;
|
||||
if ( style & wxLB_MULTIPLE )
|
||||
@@ -109,7 +111,11 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
||||
wxListBox::~wxListBox()
|
||||
{
|
||||
Free() ;
|
||||
DisposeExtLDEFInfo( m_macList ) ;
|
||||
if ( m_macList )
|
||||
{
|
||||
DisposeExtLDEFInfo( m_macList ) ;
|
||||
m_macList = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
void wxListBox::Free()
|
||||
@@ -156,7 +162,7 @@ void wxListBox::Delete(int N)
|
||||
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
|
||||
m_stringArray.Remove( N ) ;
|
||||
m_dataArray.Remove( N ) ;
|
||||
m_noItems --;
|
||||
m_noItems --;
|
||||
|
||||
MacDelete( N ) ;
|
||||
}
|
||||
@@ -236,19 +242,29 @@ int wxListBox::FindString(const wxString& st) const
|
||||
{
|
||||
wxString search = s.Left( s.Length() - 1 ) ;
|
||||
int len = search.Length() ;
|
||||
for ( int i = 0 ; i < m_noItems ; ++ i )
|
||||
{
|
||||
if ( equalstring( m_stringArray[i].Left( len ) , search , false , false ) )
|
||||
return i ;
|
||||
}
|
||||
Str255 s1 , s2 ;
|
||||
strcpy( (char*) s2 , search.c_str() ) ;
|
||||
c2pstr( (char*) s2 ) ;
|
||||
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
|
||||
{
|
||||
for ( int i = 0 ; i < m_noItems ; ++ i )
|
||||
{
|
||||
if ( equalstring( m_stringArray[i] , s , false , false ) )
|
||||
return i ;
|
||||
}
|
||||
Str255 s1 , s2 ;
|
||||
strcpy( (char*) s2 , s.c_str() ) ;
|
||||
c2pstr( (char*) s2 ) ;
|
||||
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;
|
||||
}
|
||||
@@ -308,7 +324,7 @@ void wxListBox::DoSetItemClientData(int N, void *Client_data)
|
||||
if ( m_dataArray.GetCount() > N )
|
||||
{
|
||||
m_dataArray[N] = (char*) Client_data ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
{
|
||||
m_stringArray[N] = s ;
|
||||
wxString str ;
|
||||
if( wxApp::s_macDefaultEncodingIsPC )
|
||||
{
|
||||
str = wxMacMakeMacStringFromPC( s ) ;
|
||||
}
|
||||
else
|
||||
str = s ;
|
||||
m_stringArray[N] = str ;
|
||||
MacSet( N , s ) ;
|
||||
}
|
||||
|
||||
@@ -539,7 +562,7 @@ void wxListBox::MacScrollTo( int n )
|
||||
void wxListBox::OnSize( const wxSizeEvent &event)
|
||||
{
|
||||
Point pt = (**m_macList).cellSize ;
|
||||
pt.h = m_width - 15 /* scrollbar */ - m_macHorizontalBorder * 2 ;
|
||||
pt.h = m_width - 15 ;
|
||||
LCellSize( pt , m_macList ) ;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
#include "wx/stubs/textctrl.h"
|
||||
#include "wx/stubs/listctrl.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
|
||||
|
||||
#endif
|
||||
|
||||
wxListCtrl::wxListCtrl()
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
extern wxList wxModelessWindows;
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow)
|
||||
@@ -33,6 +34,7 @@ BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow)
|
||||
EVT_SCROLL(wxMDIClientWindow::OnScroll)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#endif
|
||||
|
||||
// Parent frame
|
||||
|
||||
@@ -61,7 +63,7 @@ bool wxMDIParentFrame::Create(wxWindow *parent,
|
||||
else
|
||||
m_windowId = (int)NewControlId();
|
||||
|
||||
// TODO: create MDI parent frame
|
||||
// this window does not exist really
|
||||
|
||||
wxModelessWindows.Append(this);
|
||||
|
||||
@@ -75,7 +77,7 @@ wxMDIParentFrame::~wxMDIParentFrame()
|
||||
// Get size *available for subwindows* i.e. excluding menu bar.
|
||||
void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const
|
||||
{
|
||||
wxFrame::DoGetClientSize( x , y ) ;
|
||||
wxDisplaySize( x , y ) ;
|
||||
}
|
||||
|
||||
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
|
||||
@@ -175,7 +177,9 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
// TODO: create child frame
|
||||
MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
|
||||
|
||||
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
|
||||
|
||||
wxModelessWindows.Append(this);
|
||||
return FALSE;
|
||||
|
||||
@@ -33,8 +33,10 @@
|
||||
// ----------------------
|
||||
#include <string.h>
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler)
|
||||
#endif
|
||||
|
||||
// the (popup) menu title has this special id
|
||||
static const int idMenuTitle = -2;
|
||||
@@ -47,145 +49,6 @@ const short kwxMacAppleMenuId = 1 ;
|
||||
// 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
|
||||
|
||||
@@ -199,10 +62,10 @@ void wxMenu::Init()
|
||||
|
||||
// create the menu
|
||||
Str255 label;
|
||||
wxMacBuildMenuString( label, NULL , NULL , m_title , false );
|
||||
wxMenuItem::MacBuildMenuString( label, NULL , NULL , m_title , false );
|
||||
m_macMenuId = s_macNextMenuId++;
|
||||
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 )
|
||||
{
|
||||
@@ -220,7 +83,7 @@ void wxMenu::Init()
|
||||
wxMenu::~wxMenu()
|
||||
{
|
||||
if (m_hMenu)
|
||||
::DisposeMenu(m_hMenu);
|
||||
UMADisposeMenu(m_hMenu);
|
||||
|
||||
#if wxUSE_ACCEL
|
||||
// delete accels
|
||||
@@ -310,38 +173,28 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
|
||||
Str255 label;
|
||||
wxASSERT_MSG( pSubMenu->m_hMenu != NULL , "invalid submenu added");
|
||||
pSubMenu->m_menuParent = this ;
|
||||
wxMacBuildMenuString( 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;
|
||||
wxMenuItem::MacBuildMenuString( label , NULL , NULL , pItem->GetText() ,false);
|
||||
|
||||
if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar)
|
||||
{
|
||||
::InsertMenu( pSubMenu->m_hMenu , -1 ) ;
|
||||
UMAInsertMenu( pSubMenu->m_hMenu , -1 ) ;
|
||||
}
|
||||
|
||||
if ( pos == (size_t)-1 )
|
||||
{
|
||||
MacAppendMenu(m_hMenu, label);
|
||||
UMAAppendSubMenuItem(m_hMenu, label, pSubMenu->m_macMenuId);
|
||||
}
|
||||
else
|
||||
{
|
||||
MacInsertMenuItem(m_hMenu, label , pos);
|
||||
UMAInsertSubMenuItem(m_hMenu, label , pos, pSubMenu->m_macMenuId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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 )
|
||||
{
|
||||
// we cannot add empty menus on mac
|
||||
@@ -350,17 +203,17 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
|
||||
}
|
||||
if ( pos == (size_t)-1 )
|
||||
{
|
||||
MacAppendMenu(m_hMenu, label);
|
||||
UMAAppendMenuItem(m_hMenu, label,key,modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
MacInsertMenuItem(m_hMenu, label , pos);
|
||||
UMAInsertMenuItem(m_hMenu, label , pos,key,modifiers);
|
||||
}
|
||||
if ( pItem->GetId() == idMenuTitle )
|
||||
{
|
||||
if ( pos == (size_t)-1 )
|
||||
{
|
||||
UMADisableMenuItem( m_hMenu , CountMItems( m_hMenu ) ) ;
|
||||
UMADisableMenuItem( m_hMenu , CountMenuItems( m_hMenu ) ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -452,113 +305,9 @@ void wxMenu::SetTitle(const wxString& label)
|
||||
{
|
||||
Str255 title ;
|
||||
m_title = label ;
|
||||
wxMacBuildMenuString( title, NULL , NULL , label , false );
|
||||
wxMenuItem::MacBuildMenuString( title, NULL , NULL , label , false );
|
||||
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 processed = FALSE;
|
||||
@@ -679,6 +428,9 @@ bool wxMenu::MacMenuSelect( wxEvtHandler* handler, long when , int macMenuId, in
|
||||
{
|
||||
wxMenuItem *pItem = (wxMenuItem*)node->Data();
|
||||
|
||||
if (pItem->IsCheckable())
|
||||
pItem->Check(! pItem->IsChecked());
|
||||
|
||||
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, pItem->GetId());
|
||||
event.m_timeStamp = when;
|
||||
event.SetEventObject(handler);
|
||||
@@ -892,7 +644,8 @@ void wxMenuBar::MacInstallMenuBar()
|
||||
int pos ;
|
||||
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 )
|
||||
{
|
||||
MenuHandle mh = NULL ;
|
||||
@@ -906,8 +659,8 @@ void wxMenuBar::MacInstallMenuBar()
|
||||
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();
|
||||
subMenu = item->GetSubMenu() ;
|
||||
if (subMenu)
|
||||
@@ -919,12 +672,14 @@ void wxMenuBar::MacInstallMenuBar()
|
||||
if ( item->IsSeparator() )
|
||||
{
|
||||
if ( mh )
|
||||
::AppendMenu(mh, "\p-" );
|
||||
UMAAppendMenuItem(mh, "\p-" );
|
||||
}
|
||||
else
|
||||
{
|
||||
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 )
|
||||
{
|
||||
// we cannot add empty menus on mac
|
||||
@@ -933,36 +688,36 @@ void wxMenuBar::MacInstallMenuBar()
|
||||
}
|
||||
if ( item->GetId() == wxApp::s_macAboutMenuItemId )
|
||||
{
|
||||
::SetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , label );
|
||||
// ::EnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
|
||||
::EnableItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
|
||||
UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , label );
|
||||
UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mh )
|
||||
::AppendMenu(mh, label );
|
||||
UMAAppendMenuItem(mh, label , key , modifiers );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
wxMacBuildMenuString( label, NULL , NULL , m_titles[i] , false );
|
||||
wxMenuItem::MacBuildMenuString( label, NULL , NULL , m_titles[i] , false );
|
||||
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();
|
||||
subMenu = item->GetSubMenu() ;
|
||||
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;
|
||||
}
|
||||
@@ -1037,18 +792,18 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
|
||||
{
|
||||
if (s_macInstalledMenuBar == this)
|
||||
{
|
||||
::DeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
|
||||
UMADeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
|
||||
{
|
||||
Str255 label;
|
||||
wxMacBuildMenuString( label, NULL , NULL , title , false );
|
||||
wxMenuItem::MacBuildMenuString( label, NULL , NULL , title , false );
|
||||
UMASetMenuTitle( menu->GetHMenu() , label ) ;
|
||||
if ( pos == m_menus.GetCount() - 1)
|
||||
{
|
||||
::InsertMenu( menu->GetHMenu() , 0 ) ;
|
||||
UMAInsertMenu( menu->GetHMenu() , 0 ) ;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -25,19 +25,152 @@
|
||||
// dynamic classes implementation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
|
||||
|
||||
void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemName , bool useShortcuts ) ;
|
||||
|
||||
wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
|
||||
{
|
||||
return wxStripMenuCodes(text);
|
||||
}
|
||||
#endif //USE_SHARED_LIBRARY
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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
|
||||
// -----------
|
||||
|
||||
@@ -184,8 +317,8 @@ void wxMenuItem::SetText(const wxString& text)
|
||||
if ( index >= 1 )
|
||||
{
|
||||
Str255 label;
|
||||
wxMacBuildMenuString( label , NULL , NULL , text ,false);
|
||||
::SetMenuItemText( m_parentMenu->GetHMenu() , index , label ) ; // checkmark
|
||||
MacBuildMenuString( label , NULL , NULL , text ,false);
|
||||
UMASetMenuItemText( m_parentMenu->GetHMenu() , index , label ) ; // checkmark
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,6 +337,12 @@ void wxMenuItem::SetCheckable(bool checkable)
|
||||
// wxMenuItemBase
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* static */
|
||||
wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
|
||||
{
|
||||
return wxStripMenuCodes(text);
|
||||
}
|
||||
|
||||
wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
|
||||
int id,
|
||||
const wxString& name,
|
||||
|
||||
@@ -39,8 +39,10 @@
|
||||
|
||||
extern bool wxClipboardIsOpen;
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject)
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Metafiles
|
||||
@@ -57,7 +59,7 @@ wxMetafileRefData::~wxMetafileRefData(void)
|
||||
{
|
||||
if (m_metafile)
|
||||
{
|
||||
KillPicture( m_metafile ) ;
|
||||
KillPicture( m_metafile ) ;
|
||||
m_metafile = 0;
|
||||
}
|
||||
}
|
||||
@@ -83,7 +85,7 @@ bool wxMetaFile::SetClipboard(int width, int height)
|
||||
{
|
||||
if (!m_refData)
|
||||
return FALSE;
|
||||
/*
|
||||
|
||||
bool alreadyOpen=wxClipboardOpen();
|
||||
if (!alreadyOpen)
|
||||
{
|
||||
@@ -92,11 +94,19 @@ bool wxMetaFile::SetClipboard(int width, int height)
|
||||
}
|
||||
bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height);
|
||||
if (!alreadyOpen) wxCloseClipboard();
|
||||
return (bool) success;
|
||||
*/
|
||||
return (bool) success;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
void wxMetafile::SetHMETAFILE(PicHandle mf)
|
||||
{
|
||||
if (!m_refData)
|
||||
m_refData = new wxMetafileRefData;
|
||||
|
||||
M_METAFILEDATA->m_metafile = mf;
|
||||
}
|
||||
|
||||
bool wxMetaFile::Play(wxDC *dc)
|
||||
{
|
||||
if (!m_refData)
|
||||
@@ -142,11 +152,11 @@ wxMetaFileDC::wxMetaFileDC(const wxString& file)
|
||||
|
||||
wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ;
|
||||
|
||||
m_metaFile = new wxMetaFile("") ;
|
||||
Rect r={0,0,100,100} ;
|
||||
m_metaFile = new wxMetaFile("") ;
|
||||
Rect r={0,0,1000,1000} ;
|
||||
|
||||
m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
|
||||
::GetPort( &m_macPort ) ;
|
||||
m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
|
||||
::GetPort( &m_macPort ) ;
|
||||
m_ok = TRUE ;
|
||||
|
||||
SetMapMode(wxMM_TEXT);
|
||||
@@ -184,5 +194,4 @@ wxMetaFile *wxMetaFileDC::Close()
|
||||
return m_metaFile;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include "wx/minifram.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame, wxFrame)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
|
||||
#endif
|
||||
|
||||
#define kMacOKAlertResourceID 128
|
||||
#define kMacYesNoAlertResourceID 129
|
||||
@@ -70,7 +72,6 @@ int wxMessageDialog::ShowModal()
|
||||
Str255 pascalTitle ;
|
||||
Str255 pascalText ;
|
||||
|
||||
|
||||
if (wxApp::s_macDefaultEncodingIsPC)
|
||||
{
|
||||
strcpy( (char*) pascalTitle , wxMacMakeMacStringFromPC( m_caption ) ) ;
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include "wx/palette.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Palette
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include "wx/utils.h"
|
||||
#include "wx/pen.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
|
||||
#endif
|
||||
|
||||
wxPenRefData::wxPenRefData()
|
||||
{
|
||||
@@ -26,7 +28,7 @@ wxPenRefData::wxPenRefData()
|
||||
m_join = wxJOIN_ROUND ;
|
||||
m_cap = wxCAP_ROUND ;
|
||||
m_nbDash = 0 ;
|
||||
m_dash = (wxMACDash*)NULL;
|
||||
m_dash = 0 ;
|
||||
/* TODO: null data
|
||||
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_cap = wxCAP_ROUND ;
|
||||
M_PENDATA->m_nbDash = 0 ;
|
||||
M_PENDATA->m_dash = (wxMACDash*)NULL;
|
||||
M_PENDATA->m_dash = 0 ;
|
||||
|
||||
RealizeResource();
|
||||
|
||||
@@ -94,7 +96,7 @@ wxPen::wxPen(const wxBitmap& stipple, int Width)
|
||||
M_PENDATA->m_join = wxJOIN_ROUND ;
|
||||
M_PENDATA->m_cap = wxCAP_ROUND ;
|
||||
M_PENDATA->m_nbDash = 0 ;
|
||||
M_PENDATA->m_dash = (wxMACDash*)NULL;
|
||||
M_PENDATA->m_dash = 0 ;
|
||||
|
||||
RealizeResource();
|
||||
|
||||
@@ -168,7 +170,7 @@ void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
|
||||
Unshare();
|
||||
|
||||
M_PENDATA->m_nbDash = nb_dashes;
|
||||
M_PENDATA->m_dash = (wxMACDash *)Dash;
|
||||
M_PENDATA->m_dash = (wxDash *)Dash;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
@@ -16,11 +16,14 @@
|
||||
#include "wx/object.h"
|
||||
#include "wx/printdlg.h"
|
||||
#include "wx/dcprint.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
// Use generic page setup dialog: use your own native one if one exists.
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
|
||||
IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
|
||||
#endif
|
||||
|
||||
wxPrintDialog::wxPrintDialog()
|
||||
{
|
||||
@@ -64,15 +67,17 @@ wxPrintDialog::~wxPrintDialog()
|
||||
int wxPrintDialog::ShowModal()
|
||||
{
|
||||
int result = wxID_CANCEL ;
|
||||
#if !TARGET_CARBON
|
||||
|
||||
OSErr err ;
|
||||
wxString message ;
|
||||
::PrOpen() ;
|
||||
::UMAPrOpen() ;
|
||||
err = PrError() ;
|
||||
|
||||
if ( !err )
|
||||
{
|
||||
m_printDialogData.ConvertToNative() ;
|
||||
if ( m_printDialogData.m_macPrintInfo && ::PrJobDialog( m_printDialogData.m_macPrintInfo ) )
|
||||
if ( ::PrJobDialog( m_printDialogData.GetPrintData().m_macPrintInfo ) )
|
||||
{
|
||||
m_printDialogData.ConvertFromNative() ;
|
||||
result = wxID_OK ;
|
||||
@@ -84,8 +89,10 @@ int wxPrintDialog::ShowModal()
|
||||
message.Printf( "Print Error %d", err ) ;
|
||||
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
|
||||
}
|
||||
::PrClose() ;
|
||||
|
||||
::UMAPrClose() ;
|
||||
#else
|
||||
#pragma warning "TODO:Printing for carbon"
|
||||
#endif
|
||||
return result ;
|
||||
}
|
||||
|
||||
@@ -127,15 +134,17 @@ wxPageSetupDialog::~wxPageSetupDialog()
|
||||
int wxPageSetupDialog::ShowModal()
|
||||
{
|
||||
int result = wxID_CANCEL ;
|
||||
#if !TARGET_CARBON
|
||||
|
||||
OSErr err ;
|
||||
wxString message ;
|
||||
::PrOpen() ;
|
||||
::UMAPrOpen() ;
|
||||
err = PrError() ;
|
||||
|
||||
if ( !err )
|
||||
{
|
||||
m_pageSetupData.ConvertToNative() ;
|
||||
if ( m_pageSetupData.m_macPageSetupInfo && ::PrStlDialog( m_pageSetupData.m_macPageSetupInfo ) )
|
||||
if ( ::PrStlDialog( m_pageSetupData.GetPrintData().m_macPrintInfo ) )
|
||||
{
|
||||
m_pageSetupData.ConvertFromNative() ;
|
||||
result = wxID_OK ;
|
||||
@@ -147,8 +156,10 @@ int wxPageSetupDialog::ShowModal()
|
||||
message.Printf( "Print Error %d", err ) ;
|
||||
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
|
||||
}
|
||||
::PrClose() ;
|
||||
|
||||
::UMAPrClose() ;
|
||||
#else
|
||||
#pragma warning "TODO:printing for carbon"
|
||||
#endif
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,10 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMacPrinter, wxPrinterBase)
|
||||
IMPLEMENT_CLASS(wxMacPrintPreview, wxPrintPreviewBase)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Printer
|
||||
@@ -92,31 +94,16 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
|
||||
else
|
||||
m_printDialogData.EnablePageNumbers(FALSE);
|
||||
|
||||
// Create a suitable device context
|
||||
// Create a suitable device context
|
||||
wxDC *dc = NULL;
|
||||
if (prompt)
|
||||
{
|
||||
PrOpen() ;
|
||||
m_printDialogData.ConvertToNative() ; // make sure we have a valid handle
|
||||
if ( m_printDialogData.m_macPrintInfo )
|
||||
{
|
||||
// todo incorporate the changes from a global page setup
|
||||
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() ;
|
||||
}
|
||||
}
|
||||
wxPrintDialog dialog(parent, & m_printDialogData);
|
||||
if (dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
dc = dialog.GetPrintDC();
|
||||
m_printDialogData = dialog.GetPrintData();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -140,7 +127,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
|
||||
printout->SetDC(dc);
|
||||
|
||||
int w, h;
|
||||
long ww, hh;
|
||||
wxCoord ww, hh;
|
||||
dc->GetSize(&w, &h);
|
||||
printout->SetPageSizePixels((int)w, (int)h);
|
||||
dc->GetSizeMM(&ww, &hh);
|
||||
@@ -278,50 +265,35 @@ bool wxMacPrintPreview::Print(bool interactive)
|
||||
|
||||
void wxMacPrintPreview::DetermineScaling(void)
|
||||
{
|
||||
/*
|
||||
HDC dc = ::GetDC(NULL);
|
||||
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);
|
||||
int screenWidth , screenHeight ;
|
||||
wxDisplaySize( &screenWidth , &screenHeight ) ;
|
||||
|
||||
::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
|
||||
wxPrinterDC printerDC("", "", "", FALSE, m_printDialogData.GetOrientation());
|
||||
|
||||
int printerWidth = 150;
|
||||
int printerHeight = 250;
|
||||
int printerXRes = 1500;
|
||||
int printerYRes = 2500;
|
||||
|
||||
if (printerDC.GetHDC())
|
||||
wxPrinterDC printerDC(m_printDialogData.GetPrintData());
|
||||
if (printerDC.Ok())
|
||||
{
|
||||
printerWidth = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZSIZE);
|
||||
printerHeight = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTSIZE);
|
||||
printerXRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZRES);
|
||||
printerYRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTRES);
|
||||
|
||||
int logPPIPrinterX = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSX);
|
||||
int logPPIPrinterY = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSY);
|
||||
|
||||
m_previewPrintout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
|
||||
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;
|
||||
int x , y ;
|
||||
wxCoord ww, hh;
|
||||
printerDC.GetSizeMM(&ww, &hh);
|
||||
printerDC.GetSize( &x , &y ) ;
|
||||
m_previewPrintout->SetPageSizeMM((int)ww, (int)hh);
|
||||
m_previewPrintout->SetPageSizePixels( x , y) ;
|
||||
m_pageWidth = x ;
|
||||
m_pageHeight = y ;
|
||||
m_isOk = true ;
|
||||
|
||||
}
|
||||
// At 100%, the page should look about page-size on the screen.
|
||||
m_previewScale = (float)((float)screenWidth/(float)printerWidth);
|
||||
m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerYRes);
|
||||
*/
|
||||
// m_previewScale = (float)((float)screenWidth/(float)printerWidth);
|
||||
// m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerXRes);
|
||||
|
||||
m_previewScale = 1 ;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
#include "wx/radiobox.h"
|
||||
#include <wx/mac/uma.h>
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
|
||||
#endif
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark ### Constructors & destructor ###
|
||||
@@ -93,7 +95,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
Rect bounds ;
|
||||
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,
|
||||
kControlGroupBoxTextTitleProc , (long) this ) ;
|
||||
@@ -435,9 +437,9 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
x_offset = x;
|
||||
y_offset = y;
|
||||
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;
|
||||
if ((y == -1) || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
if ((y == -1)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y_offset = y_current;
|
||||
|
||||
// define size
|
||||
@@ -490,7 +492,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
|
||||
|
||||
x_start = charWidth;
|
||||
y_start = charHeight*3/2;
|
||||
y_start = 15 ;
|
||||
x_offset = x_start;
|
||||
y_offset = y_start;
|
||||
|
||||
@@ -507,7 +509,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
else
|
||||
{
|
||||
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();
|
||||
|
||||
if (m_windowStyle & wxRA_SPECIFY_ROWS)
|
||||
y_offset += maxHeight + charHeight/2;
|
||||
y_offset += maxHeight ; /*+ charHeight/2;*/
|
||||
else
|
||||
x_offset += maxWidth + charWidth;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include "wx/radiobut.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
|
||||
#endif
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
|
||||
@@ -48,7 +50,8 @@ void wxRadioButton::SetValue(bool val)
|
||||
|
||||
::SetControlValue( m_macControl , val ) ;
|
||||
|
||||
if (val) {
|
||||
if (val)
|
||||
{
|
||||
cycle=this->NextInCycle();
|
||||
if (cycle!=NULL) {
|
||||
while (cycle!=this) {
|
||||
@@ -94,4 +97,3 @@ wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
|
||||
return(cycle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,12 @@
|
||||
|
||||
#include "wx/region.h"
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxRegionRefData implementation
|
||||
@@ -195,7 +198,8 @@ void wxRegion::GetBox(long& x, long& y, long&w, long &h) const
|
||||
{
|
||||
if (m_refData)
|
||||
{
|
||||
Rect box = (**M_REGION).rgnBBox ;
|
||||
Rect box ;
|
||||
GetRegionBounds( M_REGION , &box ) ;
|
||||
x = box.left ;
|
||||
y = box.top ;
|
||||
w = box.right - box.left ;
|
||||
@@ -329,7 +333,8 @@ void wxRegionIterator::Reset(const wxRegion& region)
|
||||
{
|
||||
// we cannot dissolve it into rects on mac
|
||||
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].y = rect.top;
|
||||
m_rects[0].width = rect.right - rect.left;
|
||||
|
||||
@@ -16,11 +16,13 @@
|
||||
#include "wx/scrolbar.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxScrollBar, wxControl)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#endif
|
||||
|
||||
extern ControlActionUPP wxMacLiveScrollbarActionUPP ;
|
||||
|
||||
|
||||
@@ -74,7 +74,6 @@ wxColour wxSystemSettings::GetSystemColour(int index)
|
||||
break ;
|
||||
case wxSYS_COLOUR_INFOBK :
|
||||
case wxSYS_COLOUR_APPWORKSPACE:
|
||||
case wxSYS_COLOUR_LISTBOX:
|
||||
return *wxWHITE ;
|
||||
break ;
|
||||
}
|
||||
|
||||
@@ -16,10 +16,12 @@
|
||||
#include "wx/slider.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSlider, wxControl)
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
// wxWin macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent);
|
||||
#endif
|
||||
|
||||
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
||||
long style, const wxString& name)
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include "wx/statbmp.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wxStaticBitmap
|
||||
@@ -28,11 +30,12 @@ END_EVENT_TABLE()
|
||||
bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxBitmap& bitmap,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
const wxSize& s,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
wxSize size = s ;
|
||||
|
||||
m_backgroundColour = parent->GetBackgroundColour() ;
|
||||
m_foregroundColour = parent->GetForegroundColour() ;
|
||||
@@ -47,8 +50,7 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
||||
m_windowStyle = style;
|
||||
|
||||
bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
|
||||
|
||||
SetSizeOrDefault() ;
|
||||
SetSizeOrDefault( size ) ;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
#include "wx/statbox.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxStaticBox, wxControl)
|
||||
EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Static box
|
||||
@@ -37,7 +39,7 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
|
||||
Rect bounds ;
|
||||
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,
|
||||
kControlGroupBoxTextTitleProc , (long) this ) ;
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
|
||||
#endif
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
|
||||
@@ -51,69 +53,208 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
|
||||
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 )
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
PrepareDC(dc);
|
||||
dc.Clear() ;
|
||||
dc.DrawText( m_label , 0 , 0 ) ;
|
||||
OnDraw( dc ) ;
|
||||
}
|
||||
|
||||
wxSize wxStaticText::DoGetBestSize() const
|
||||
{
|
||||
int x , y ;
|
||||
GetTextExtent( m_label , &x , &y ) ;
|
||||
return wxSize( x , y ) ;
|
||||
int widthTextMax = 0, widthLine,
|
||||
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 ) ;
|
||||
m_label = st ;
|
||||
if ( resize )
|
||||
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
|
||||
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() ;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
#include "wx/tabctrl.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTabCtrl, wxControl)
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
wxTabCtrl::wxTabCtrl()
|
||||
{
|
||||
@@ -35,7 +37,7 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
|
||||
|
||||
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,
|
||||
kControlTabSmallProc , (long) this ) ;
|
||||
|
||||
@@ -38,22 +38,34 @@
|
||||
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
|
||||
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
|
||||
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()
|
||||
#endif
|
||||
|
||||
// Text item
|
||||
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,
|
||||
const wxString& st,
|
||||
const wxPoint& pos,
|
||||
@@ -61,10 +73,22 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
m_macHorizontalBorder = 2 ; // additional pixels around the real control
|
||||
m_macVerticalBorder = 2 ;
|
||||
// base initialization
|
||||
if ( !CreateBase(parent, id, pos, size, style, validator, name) )
|
||||
return FALSE;
|
||||
|
||||
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 ;
|
||||
Str255 title ;
|
||||
@@ -72,14 +96,17 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
if ( mySize.y == -1 )
|
||||
{
|
||||
if ( UMAHasAppearance() )
|
||||
mySize.y = 16 ;
|
||||
mySize.y = 13 ;
|
||||
else
|
||||
mySize.y = 24 ;
|
||||
|
||||
mySize.y += 2 * m_macVerticalBorder ;
|
||||
}
|
||||
|
||||
MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ;
|
||||
|
||||
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1,
|
||||
kControlEditTextProc , (long) this ) ;
|
||||
( style & wxTE_PASSWORD ) ? kControlEditTextPasswordProc : kControlEditTextProc , (long) this ) ;
|
||||
MacPostControlCreate() ;
|
||||
|
||||
wxString value ;
|
||||
@@ -88,7 +115,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
value = wxMacMakeMacStringFromPC( st ) ;
|
||||
else
|
||||
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;
|
||||
}
|
||||
@@ -96,7 +123,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
wxString wxTextCtrl::GetValue() const
|
||||
{
|
||||
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 ;
|
||||
if( wxApp::s_macDefaultEncodingIsPC )
|
||||
return wxMacMakePCStringFromMac( wxBuffer ) ;
|
||||
@@ -104,6 +131,18 @@ wxString wxTextCtrl::GetValue() const
|
||||
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)
|
||||
{
|
||||
wxString value ;
|
||||
@@ -112,44 +151,116 @@ void wxTextCtrl::SetValue(const wxString& st)
|
||||
value = wxMacMakeMacStringFromPC( st ) ;
|
||||
else
|
||||
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() ;
|
||||
// MacInvalidateControl() ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
wxControl::SetSize( x , y , width , height , sizeFlags ) ;
|
||||
}
|
||||
|
||||
// Clipboard operations
|
||||
void wxTextCtrl::Copy()
|
||||
{
|
||||
TEHandle teH ;
|
||||
long size ;
|
||||
if (CanCopy())
|
||||
{
|
||||
TEHandle teH ;
|
||||
long size ;
|
||||
|
||||
UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TECopy( teH ) ;
|
||||
UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TECopy( teH ) ;
|
||||
#if TARGET_CARBON
|
||||
OSStatus err ;
|
||||
err = ClearCurrentScrap( );
|
||||
#else
|
||||
OSErr err ;
|
||||
err = ZeroScrap( );
|
||||
#endif
|
||||
TEToScrap() ;
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextCtrl::Cut()
|
||||
{
|
||||
TEHandle teH ;
|
||||
long size ;
|
||||
if (CanCut())
|
||||
{
|
||||
TEHandle teH ;
|
||||
long size ;
|
||||
|
||||
UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TECut( teH ) ;
|
||||
// MacInvalidateControl() ;
|
||||
UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TECut( teH ) ;
|
||||
#if TARGET_CARBON
|
||||
OSStatus err ;
|
||||
err = ClearCurrentScrap( );
|
||||
#else
|
||||
OSErr err ;
|
||||
err = ZeroScrap( );
|
||||
#endif
|
||||
TEToScrap() ;
|
||||
// MacInvalidateControl() ;
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextCtrl::Paste()
|
||||
{
|
||||
TEHandle teH ;
|
||||
long size ;
|
||||
if (CanPaste())
|
||||
{
|
||||
TEHandle teH ;
|
||||
long size ;
|
||||
|
||||
UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TEPaste( teH ) ;
|
||||
UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TEFromScrap() ;
|
||||
TEPaste( teH ) ;
|
||||
// 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)
|
||||
@@ -243,65 +354,10 @@ void wxTextCtrl::SetSelection(long from, long to)
|
||||
|
||||
bool wxTextCtrl::LoadFile(const wxString& file)
|
||||
{
|
||||
if (!wxFileExists(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())
|
||||
if ( wxTextCtrlBase::LoadFile(file) )
|
||||
{
|
||||
struct stat stat_buf;
|
||||
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 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;
|
||||
}
|
||||
@@ -329,18 +385,8 @@ void wxTextCtrl::AppendText(const wxString& text)
|
||||
|
||||
void wxTextCtrl::Clear()
|
||||
{
|
||||
TEHandle teH ;
|
||||
long size ;
|
||||
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() ;
|
||||
UMASetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ;
|
||||
Refresh() ;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::IsModified() const
|
||||
@@ -348,6 +394,73 @@ bool wxTextCtrl::IsModified() const
|
||||
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'
|
||||
void wxTextCtrl::DiscardEdits()
|
||||
{
|
||||
@@ -366,9 +479,9 @@ long wxTextCtrl::XYToPosition(long x, long y) const
|
||||
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)
|
||||
@@ -407,204 +520,125 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
|
||||
|
||||
void wxTextCtrl::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
switch( event.KeyCode() )
|
||||
switch ( event.KeyCode() )
|
||||
{
|
||||
case WXK_RETURN:
|
||||
{
|
||||
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||
{
|
||||
if (m_windowStyle & wxPROCESS_ENTER)
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
|
||||
event.SetEventObject( this );
|
||||
if ( GetEventHandler()->ProcessEvent(event) )
|
||||
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
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WXK_TAB:
|
||||
// always produce navigation event - even if we process TAB
|
||||
// ourselves the fact that we got here means that the user code
|
||||
// decided to skip processing of this TAB - probably to let it
|
||||
// do its default job.
|
||||
//
|
||||
// NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
|
||||
// handled by Windows
|
||||
{
|
||||
wxNavigationKeyEvent eventNav;
|
||||
eventNav.SetDirection(!event.ShiftDown());
|
||||
eventNav.SetWindowChange(FALSE);
|
||||
eventNav.SetWindowChange(event.ControlDown());
|
||||
eventNav.SetEventObject(this);
|
||||
|
||||
if ( GetEventHandler()->ProcessEvent(eventNav) )
|
||||
if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
|
||||
return;
|
||||
event.Skip() ;
|
||||
return ;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
// don't just call event.Skip() because this will cause TABs and ENTERs
|
||||
// be passed upwards and we don't always want this - instead process it
|
||||
// right here
|
||||
EventRecord *ev = wxTheApp->MacGetCurrentEvent() ;
|
||||
short keycode ;
|
||||
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)
|
||||
// or when "endl" is output (Borland 4.5)
|
||||
//=========================================================================
|
||||
// Class declaration using multiple inheritance doesn't work properly for
|
||||
// Borland. See note in wb_text.h.
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
int wxTextCtrl::overflow(int c)
|
||||
// ----------------------------------------------------------------------------
|
||||
// standard handlers for standard edit menu events
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTextCtrl::OnCut(wxCommandEvent& event)
|
||||
{
|
||||
// Make sure there is a holding area
|
||||
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
|
||||
Cut();
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// called then "endl" is output (gcc) or then explicit sync is done (Borland)
|
||||
//=========================================================================
|
||||
int wxTextCtrl::sync()
|
||||
void wxTextCtrl::OnCopy(wxCommandEvent& event)
|
||||
{
|
||||
// Verify that there are no characters in get area
|
||||
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;
|
||||
*/
|
||||
Copy();
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// Should not be called by a "ostream". Used by a "istream"
|
||||
//=========================================================================
|
||||
int wxTextCtrl::underflow()
|
||||
void wxTextCtrl::OnPaste(wxCommandEvent& event)
|
||||
{
|
||||
return EOF;
|
||||
Paste();
|
||||
}
|
||||
#endif
|
||||
|
||||
wxTextCtrl& wxTextCtrl::operator<<(const wxString& s)
|
||||
void wxTextCtrl::OnUndo(wxCommandEvent& event)
|
||||
{
|
||||
AppendText(s);
|
||||
return *this;
|
||||
Undo();
|
||||
}
|
||||
|
||||
wxTextCtrl& wxTextCtrl::operator<<(float f)
|
||||
void wxTextCtrl::OnRedo(wxCommandEvent& event)
|
||||
{
|
||||
wxString str;
|
||||
str.Printf("%.2f", f);
|
||||
AppendText(str);
|
||||
return *this;
|
||||
Redo();
|
||||
}
|
||||
|
||||
wxTextCtrl& wxTextCtrl::operator<<(double d)
|
||||
void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
|
||||
{
|
||||
wxString str;
|
||||
str.Printf("%.2f", d);
|
||||
AppendText(str);
|
||||
return *this;
|
||||
event.Enable( CanCut() );
|
||||
}
|
||||
|
||||
wxTextCtrl& wxTextCtrl::operator<<(int i)
|
||||
void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
|
||||
{
|
||||
wxString str;
|
||||
str.Printf("%d", i);
|
||||
AppendText(str);
|
||||
return *this;
|
||||
event.Enable( CanCopy() );
|
||||
}
|
||||
|
||||
wxTextCtrl& wxTextCtrl::operator<<(long i)
|
||||
void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
|
||||
{
|
||||
wxString str;
|
||||
str.Printf("%ld", i);
|
||||
AppendText(str);
|
||||
return *this;
|
||||
event.Enable( CanPaste() );
|
||||
}
|
||||
|
||||
wxTextCtrl& wxTextCtrl::operator<<(const char c)
|
||||
void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
|
||||
{
|
||||
char buf[2];
|
||||
|
||||
buf[0] = c;
|
||||
buf[1] = 0;
|
||||
AppendText(buf);
|
||||
return *this;
|
||||
event.Enable( CanUndo() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanRedo() );
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,48 @@
|
||||
|
||||
#include "wx/timer.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
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()
|
||||
{
|
||||
m_milli = 0 ;
|
||||
m_id = 0;
|
||||
m_oneShot = FALSE;
|
||||
m_info.m_task.tmAddr = NULL ;
|
||||
m_info.m_task.tmWakeUp = 0 ;
|
||||
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()
|
||||
@@ -31,20 +66,31 @@ wxTimer::~wxTimer()
|
||||
|
||||
bool wxTimer::Start(int milliseconds,bool mode)
|
||||
{
|
||||
m_oneShot = mode ;
|
||||
if (milliseconds <= 0)
|
||||
return FALSE;
|
||||
(void)wxTimerBase::Start(milliseconds, mode);
|
||||
|
||||
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;
|
||||
|
||||
// TODO: set the timer going.
|
||||
m_info.m_task.tmAddr = NewTimerProc( MacTimerProc ) ;
|
||||
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;
|
||||
}
|
||||
|
||||
void wxTimer::Stop()
|
||||
{
|
||||
m_id = 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 ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) AUTHOR
|
||||
// Licence: wxWindows licence
|
||||
// Copyright: (c) AUTHORy
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
@@ -18,11 +17,17 @@
|
||||
#if wxUSE_TOOLBAR
|
||||
|
||||
#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)
|
||||
EVT_MOUSE_EVENTS( wxToolBar::OnMouse )
|
||||
EVT_PAINT( wxToolBar::OnPaint )
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
|
||||
@@ -45,14 +50,14 @@ public:
|
||||
clientData, shortHelpString, longHelpString)
|
||||
{
|
||||
m_nSepCount = 0;
|
||||
m_index = 0 ;
|
||||
m_index = -1 ;
|
||||
}
|
||||
|
||||
wxToolBarTool(wxToolBar *tbar, wxControl *control)
|
||||
: wxToolBarToolBase(tbar, control)
|
||||
{
|
||||
m_nSepCount = 1;
|
||||
m_index = 0 ;
|
||||
m_index = -1 ;
|
||||
}
|
||||
|
||||
// set/get the number of separators which we use to cover the space used by
|
||||
@@ -74,6 +79,9 @@ private:
|
||||
// wxToolBarTool
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
const short defwidth = 24 ;
|
||||
const short defheight = 22 ;
|
||||
|
||||
wxToolBarToolBase *wxToolBar::CreateTool(int id,
|
||||
const wxBitmap& bitmap1,
|
||||
const wxBitmap& bitmap2,
|
||||
@@ -91,16 +99,12 @@ wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control)
|
||||
return new wxToolBarTool(this, control);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxToolBar construction
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxToolBar::Init()
|
||||
{
|
||||
m_maxWidth = -1;
|
||||
m_maxHeight = -1;
|
||||
m_defaultWidth = 24;
|
||||
m_defaultHeight = 22;
|
||||
m_defaultWidth = defwidth;
|
||||
m_defaultHeight = defheight;
|
||||
// TODO
|
||||
}
|
||||
|
||||
@@ -109,8 +113,8 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
|
||||
{
|
||||
m_maxWidth = m_maxHeight = 0;
|
||||
|
||||
m_defaultWidth = 24;
|
||||
m_defaultHeight = 22;
|
||||
m_defaultWidth = defwidth;
|
||||
m_defaultHeight = defheight;
|
||||
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
@@ -125,16 +129,39 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
|
||||
x = 0;
|
||||
if (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 ;
|
||||
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,
|
||||
kControlPlacardProc , (long) this ) ;
|
||||
MacPostControlCreate() ;
|
||||
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -143,7 +170,8 @@ wxToolBar::~wxToolBar()
|
||||
// TODO
|
||||
}
|
||||
|
||||
PicHandle MakePict(GWorldPtr wp)
|
||||
PicHandle MakePict(GWorldPtr wp, GWorldPtr mask ) ;
|
||||
PicHandle MakePict(GWorldPtr wp, GWorldPtr mask )
|
||||
{
|
||||
CGrafPtr origPort ;
|
||||
GDHandle origDev ;
|
||||
@@ -151,52 +179,77 @@ PicHandle MakePict(GWorldPtr wp)
|
||||
PicHandle pict; // this is the Picture we give back
|
||||
|
||||
RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ;
|
||||
RGBColor white = { 0xffff ,0xffff , 0xffff } ;
|
||||
RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;
|
||||
|
||||
unsigned char *maskimage = NULL ;
|
||||
Rect portRect ;
|
||||
GetPortBounds( wp , &portRect ) ;
|
||||
int width = portRect.right - portRect.left ;
|
||||
int height = portRect.bottom - portRect.top ;
|
||||
|
||||
LockPixels( GetGWorldPixMap( wp ) ) ;
|
||||
GetGWorld( &origPort , &origDev ) ;
|
||||
|
||||
if ( mask )
|
||||
{
|
||||
|
||||
maskimage = (unsigned char*) malloc( width * height ) ;
|
||||
SetGWorld( mask , NULL ) ;
|
||||
LockPixels( GetGWorldPixMap( mask ) ) ;
|
||||
for ( int y = 0 ; y < height ; ++y )
|
||||
{
|
||||
for( int x = 0 ; x < width ; ++x )
|
||||
{
|
||||
RGBColor col ;
|
||||
|
||||
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
|
||||
maskimage[y*width + x] = ( col.red == 0 ) ; // for monochrome masks
|
||||
}
|
||||
}
|
||||
UnlockPixels( GetGWorldPixMap( mask ) ) ;
|
||||
}
|
||||
|
||||
SetGWorld( wp , NULL ) ;
|
||||
|
||||
pict = OpenPicture(&wp->portRect); // open a picture, this disables drawing
|
||||
pict = OpenPicture(&portRect); // open a picture, this disables drawing
|
||||
if(!pict)
|
||||
return NULL;
|
||||
|
||||
RGBBackColor( &gray ) ;
|
||||
EraseRect(&wp->portRect) ;
|
||||
CopyBits((BitMap*)*wp->portPixMap, // src PixMap - we copy image over itself -
|
||||
(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;
|
||||
|
||||
RGBForeColor( &black ) ;
|
||||
EraseRect(&portRect) ;
|
||||
RGBBackColor( &white ) ;
|
||||
EraseRect(&wp->portRect) ;
|
||||
CopyBits((BitMap*)*wp->portPixMap, // src PixMap - we copy image over itself -
|
||||
(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 -
|
||||
|
||||
if ( maskimage )
|
||||
{
|
||||
for ( int y = 0 ; y < height ; ++y )
|
||||
{
|
||||
for( int x = 0 ; x < width ; ++x )
|
||||
{
|
||||
if ( maskimage[y*width + x] )
|
||||
{
|
||||
RGBColor col ;
|
||||
|
||||
GetCPixel( x + portRect.left , y + portRect.top , &col ) ;
|
||||
SetCPixel( x + portRect.left , y + portRect.top , &col ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
}
|
||||
ClosePicture(); // We are done recording the picture
|
||||
UnlockPixels( GetGWorldPixMap( wp ) ) ;
|
||||
SetGWorld( origPort , origDev ) ;
|
||||
return pict; // return our groovy pict handle
|
||||
}
|
||||
@@ -226,7 +279,7 @@ bool wxToolBar::Realize()
|
||||
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->GetBitmap1().GetRefData()) ;
|
||||
|
||||
if( !tool->IsSeparator() )
|
||||
if( !tool->IsSeparator() )
|
||||
{
|
||||
Rect toolrect = { toolbarrect.top + kwxMacToolBarTopMargin , toolbarrect.left + x + kwxMacToolBarLeftMargin , 0 , 0 } ;
|
||||
toolrect.right = toolrect.left + toolSize.x ;
|
||||
@@ -239,7 +292,14 @@ bool wxToolBar::Realize()
|
||||
icon = bmap->m_hPict ;
|
||||
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 ) ;
|
||||
}
|
||||
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 ) ;
|
||||
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;
|
||||
noButtons ++;
|
||||
@@ -311,7 +382,7 @@ void wxToolBar::SetToolBitmapSize(const wxSize& size)
|
||||
// The button size is bigger than the bitmap size
|
||||
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 )
|
||||
@@ -321,7 +392,13 @@ void wxToolBar::MacHandleControlClick( ControlHandle control , SInt16 controlpar
|
||||
{
|
||||
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
|
||||
{
|
||||
MacClientToRootWindow( &x , &y ) ;
|
||||
Point pt = { x ,y } ;
|
||||
Point pt = { y ,x } ;
|
||||
|
||||
int index = 0 ;
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
wxToolBarTool *tool = (wxToolBarTool *)t;
|
||||
if ( tool->m_index < 0 )
|
||||
return ;
|
||||
|
||||
ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
if ( enable )
|
||||
::ActivateControl( control ) ;
|
||||
else
|
||||
::DeactivateControl( control ) ;
|
||||
}
|
||||
|
||||
if ( enable )
|
||||
UMAActivateControl( control ) ;
|
||||
else
|
||||
{
|
||||
if ( enable )
|
||||
::HiliteControl( control , 0 ) ;
|
||||
else
|
||||
::HiliteControl( control , 255 ) ;
|
||||
}
|
||||
UMADeactivateControl( control ) ;
|
||||
}
|
||||
|
||||
void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
|
||||
{
|
||||
wxToolBarTool *tool = (wxToolBarTool *)t;
|
||||
if ( tool->m_index < 0 )
|
||||
return ;
|
||||
|
||||
ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
|
||||
::SetControlValue( control , toggle ) ;
|
||||
@@ -402,5 +490,116 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
|
||||
{
|
||||
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
|
||||
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
#include "wx/stubs/textctrl.h"
|
||||
#include "wx/stubs/treectrl.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
|
||||
|
||||
#endif
|
||||
|
||||
wxTreeCtrl::wxTreeCtrl()
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls )
|
||||
long total,contig;
|
||||
PurgeSpace(&total, &contig);
|
||||
#else
|
||||
InitMenus() ;
|
||||
InitCursor();
|
||||
#endif
|
||||
|
||||
#if UMA_USE_APPEARANCE
|
||||
@@ -87,7 +87,7 @@ bool UMAGetProcessModeDoesActivateOnFGSwitch()
|
||||
|
||||
// menu manager
|
||||
|
||||
void UMASetMenuTitle( MenuRef menu , ConstStr255Param title )
|
||||
void UMASetMenuTitle( MenuRef menu , StringPtr title )
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
long size = GetHandleSize( (Handle) menu ) ;
|
||||
@@ -117,11 +117,13 @@ void UMASetMenuTitle( MenuRef menu , ConstStr255Param title )
|
||||
|
||||
UInt32 UMAMenuEvent( EventRecord *inEvent )
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return MenuEvent( inEvent ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if ( inEvent->what == keyDown && inEvent->modifiers & cmdKey)
|
||||
{
|
||||
@@ -133,7 +135,7 @@ UInt32 UMAMenuEvent( EventRecord *inEvent )
|
||||
|
||||
void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex inItem )
|
||||
{
|
||||
#if UMA_USE_8_6
|
||||
#if UMA_USE_8_6 || TARGET_CARBON
|
||||
EnableMenuItem( inMenu , inItem ) ;
|
||||
#else
|
||||
EnableItem( inMenu , inItem ) ;
|
||||
@@ -142,14 +144,145 @@ void UMAEnableMenuItem( 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 ) ;
|
||||
#else
|
||||
DisableItem( inMenu , inItem ) ;
|
||||
#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
|
||||
|
||||
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
|
||||
|
||||
pascal QDGlobalsPtr GetQDGlobalsPtr (void)
|
||||
@@ -260,77 +393,145 @@ void UMACloseWindow(WindowRef inWindowRef)
|
||||
|
||||
void UMAActivateControl( ControlHandle inControl )
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
::ActivateControl( inControl ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
AGAActivateControl( inControl ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UMADrawControl( ControlHandle inControl )
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
::DrawControlInCurrentPort( inControl ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
AGADrawControl( inControl ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UMAMoveControl( ControlHandle inControl , short x , short y )
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
::MoveControl( inControl , x , y ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
AGAMoveControl( inControl , x ,y ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UMASizeControl( ControlHandle inControl , short x , short y )
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
::SizeControl( inControl , x , y ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
AGASizeControl( inControl , x ,y ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UMADeactivateControl( ControlHandle inControl )
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
::DeactivateControl( inControl ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
AGADeactivateControl( inControl ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UMASetThemeWindowBackground (WindowRef inWindow,
|
||||
ThemeBrush inBrush,
|
||||
Boolean inUpdate){
|
||||
Boolean inUpdate)
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
::SetThemeWindowBackground( inWindow ,inBrush , inUpdate ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
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,
|
||||
const Rect * boundsRect,
|
||||
@@ -343,16 +544,23 @@ ControlHandle UMANewControl(WindowPtr owningWindow,
|
||||
SInt32 controlReference)
|
||||
{
|
||||
ControlHandle theControl = NULL ;
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
theControl = NewControl( owningWindow , boundsRect , controlTitle , initiallyVisible ,
|
||||
initialValue , minimumValue , maximumValue , procID , controlReference ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
theControl = AGANewControl( owningWindow , boundsRect , controlTitle , initiallyVisible ,
|
||||
initialValue , minimumValue , maximumValue , procID , controlReference ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
}
|
||||
#endif
|
||||
return theControl ;
|
||||
}
|
||||
|
||||
@@ -415,7 +623,9 @@ void UMASetControlVisibility (ControlHandle inControl,
|
||||
{
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
::SetControlVisibility( inControl , inIsVisible, inDoDraw ) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,21 +633,29 @@ void UMASetControlVisibility (ControlHandle inControl,
|
||||
|
||||
bool UMAIsControlActive (ControlHandle inControl)
|
||||
{
|
||||
#if TARGET_CARBON
|
||||
return IsControlActive( inControl ) ;
|
||||
#else
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return IsControlActive( inControl ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (**inControl).contrlHilite == 0 ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool UMAIsControlVisible (ControlHandle inControl)
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return IsControlVisible( inControl ) ;
|
||||
}
|
||||
#endif
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -445,26 +663,42 @@ OSErr UMAGetBestControlRect (ControlHandle inControl,
|
||||
Rect * outRect,
|
||||
SInt16 * outBaseLineOffset)
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return GetBestControlRect( inControl , outRect , outBaseLineOffset ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
return AGAGetBestControlRect( inControl , outRect , outBaseLineOffset ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
return noErr ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
OSErr UMASetControlFontStyle (ControlHandle inControl,
|
||||
const ControlFontStyleRec * inStyle)
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return ::SetControlFontStyle( inControl , inStyle ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
return AGASetControlFontStyle( inControl , inStyle ) ;
|
||||
#else
|
||||
{
|
||||
return noErr ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -474,12 +708,20 @@ OSErr UMASetControlFontStyle (ControlHandle inControl,
|
||||
OSErr UMACreateRootControl (WindowPtr inWindow,
|
||||
ControlHandle * outControl)
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return CreateRootControl( inWindow , outControl ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
return AGACreateRootControl( inWindow , outControl ) ;
|
||||
#else
|
||||
{
|
||||
return noErr ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -487,12 +729,20 @@ OSErr UMACreateRootControl (WindowPtr inWindow,
|
||||
OSErr UMAEmbedControl (ControlHandle inControl,
|
||||
ControlHandle inContainer)
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return EmbedControl( inControl , inContainer ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
return AGAEmbedControl( inControl , inContainer ) ; ;
|
||||
#else
|
||||
{
|
||||
return noErr ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -502,12 +752,30 @@ OSErr UMASetKeyboardFocus (WindowPtr inWindow,
|
||||
ControlHandle inControl,
|
||||
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() )
|
||||
{
|
||||
return SetKeyboardFocus( inWindow , inControl , inPart ) ;
|
||||
err = SetKeyboardFocus( inWindow , inControl , inPart ) ;
|
||||
}
|
||||
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,
|
||||
ControlActionUPP inAction)
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return HandleControlClick( inControl , inWhere , inModifiers , inAction ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
return AGAHandleControlClick( inControl , inWhere , inModifiers , inAction ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
return noErr ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -536,52 +812,82 @@ SInt16 UMAHandleControlKey (ControlHandle inControl,
|
||||
SInt16 inCharCode,
|
||||
SInt16 inModifiers)
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return HandleControlKey( inControl , inKeyCode , inCharCode , inModifiers ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
return AGAHandleControlKey(inControl , inKeyCode , inCharCode , inModifiers ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
return noErr ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void UMAIdleControls (WindowPtr inWindow)
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
IdleControls( inWindow ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
AGAIdleControls( inWindow ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn )
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
UpdateControls( inWindow , inRgn ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
AGAUpdateControls( inWindow , inRgn ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl )
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return GetRootControl( inWindow , outControl ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
return AGAGetRootControl( inWindow , outControl ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
return noErr ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -593,12 +899,20 @@ OSErr UMASetControlData (ControlHandle inControl,
|
||||
Size inSize,
|
||||
Ptr inData)
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return SetControlData( inControl , inPart , inTagName , inSize , inData ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
return AGASetControlData( inControl , inPart , inTagName , inSize , inData ) ;
|
||||
#else
|
||||
{
|
||||
return noErr ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -610,15 +924,22 @@ OSErr UMAGetControlData (ControlHandle inControl,
|
||||
Ptr outBuffer,
|
||||
Size * outActualSize)
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return ::GetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
return AGAGetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ;
|
||||
}
|
||||
|
||||
#else
|
||||
{
|
||||
return noErr ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -627,14 +948,22 @@ OSErr UMAGetControlDataSize (ControlHandle inControl,
|
||||
ResType inTagName,
|
||||
Size * outMaxSize)
|
||||
{
|
||||
#if UMA_USE_APPEARANCE
|
||||
if ( UMAHasAppearance() )
|
||||
{
|
||||
return GetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !TARGET_CARBON
|
||||
{
|
||||
return AGAGetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ;
|
||||
}
|
||||
#else
|
||||
{
|
||||
return noErr ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -711,11 +1040,70 @@ OSStatus UMACreateNewWindow( WindowClass windowClass , WindowAttributes attribu
|
||||
case kMovableModalWindowClass :
|
||||
procID = kWindowMovableModalDialogProc;
|
||||
break ;
|
||||
case kDocumentWindowClass :
|
||||
procID = kWindowFullZoomGrowDocumentProc;
|
||||
case kModalWindowClass :
|
||||
procID = kWindowShadowDialogProc;
|
||||
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 :
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
@@ -725,13 +1113,72 @@ OSStatus UMACreateNewWindow( WindowClass windowClass , WindowAttributes attribu
|
||||
{
|
||||
case kMovableModalWindowClass :
|
||||
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 ;
|
||||
case kDocumentWindowClass :
|
||||
procID = zoomDocProc;
|
||||
break ;
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
@@ -853,6 +1300,32 @@ void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate )
|
||||
// bool isHighlighted = IsWindowHighlited( inWindowRef ) ;
|
||||
// if ( inActivate != isHightlited )
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "wx/setup.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -26,7 +27,13 @@
|
||||
#include <string.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)
|
||||
{
|
||||
// TODO
|
||||
@@ -227,7 +234,10 @@ void wxEndBusyCursor()
|
||||
if ( gMacStoredActiveCursor )
|
||||
::SetCursor( *gMacStoredActiveCursor ) ;
|
||||
else
|
||||
::SetCursor( &qd.arrow ) ;
|
||||
{
|
||||
Cursor MacArrow ;
|
||||
::SetCursor( GetQDGlobalsArrow( &MacArrow ) ) ;
|
||||
}
|
||||
gMacStoredActiveCursor = NULL ;
|
||||
}
|
||||
}
|
||||
@@ -238,6 +248,25 @@ bool wxIsBusy()
|
||||
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)
|
||||
{
|
||||
// TODO
|
||||
@@ -271,23 +300,32 @@ bool wxColourDisplay()
|
||||
// Returns depth of screen
|
||||
int wxDisplayDepth()
|
||||
{
|
||||
// get max pixel depth
|
||||
CGrafPtr port ;
|
||||
GetCWMgrPort( &port ) ;
|
||||
GDHandle maxDevice ;
|
||||
Rect globRect ;
|
||||
SetRect(&globRect, -32760, -32760, 32760, 32760);
|
||||
GDHandle theMaxDevice;
|
||||
|
||||
maxDevice = GetMaxDevice( &port->portRect ) ;
|
||||
if ( maxDevice )
|
||||
return (**((**maxDevice).gdPMap)).pixelSize ;
|
||||
else
|
||||
return 8 ;
|
||||
int theDepth = 8;
|
||||
theMaxDevice = GetMaxDevice(&globRect);
|
||||
if (theMaxDevice != nil)
|
||||
theDepth = (**(**theMaxDevice).gdPMap).pixelSize;
|
||||
|
||||
return theDepth ;
|
||||
}
|
||||
|
||||
// Get size of display
|
||||
void wxDisplaySize(int *width, int *height)
|
||||
{
|
||||
*width = qd.screenBits.bounds.right - qd.screenBits.bounds.left ;
|
||||
*height = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top ;
|
||||
*height -= LMGetMBarHeight() ;
|
||||
BitMap screenBits;
|
||||
GetQDGlobalsScreenBits( &screenBits );
|
||||
|
||||
*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
@@ -15,8 +15,10 @@
|
||||
|
||||
#include "wx/checkbox.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
|
||||
#endif
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// implementation of wxCheckListBox class
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include "wx/choice.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
|
||||
#endif
|
||||
|
||||
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
@@ -27,7 +29,6 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
m_noStrings = n;
|
||||
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
@@ -41,11 +42,15 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
|
||||
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 ) ;
|
||||
SetControlMaximum( m_macControl , m_noStrings) ;
|
||||
SetControlValue( m_macControl , 1 ) ;
|
||||
SetControlMaximum( m_macControl , Number()) ;
|
||||
if ( n > 0 )
|
||||
SetControlValue( m_macControl , 1 ) ;
|
||||
|
||||
MacPostControlCreate() ;
|
||||
|
||||
@@ -54,27 +59,28 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
void wxChoice::Append(const wxString& item)
|
||||
{
|
||||
appendmenu( m_macPopUpMenuHandle , item ) ;
|
||||
m_noStrings ++;
|
||||
SetControlMaximum( m_macControl , m_noStrings) ;
|
||||
Str255 label;
|
||||
wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false);
|
||||
AppendMenu( m_macPopUpMenuHandle , label ) ;
|
||||
m_strings.Add( item ) ;
|
||||
SetControlMaximum( m_macControl , Number()) ;
|
||||
}
|
||||
|
||||
void wxChoice::Delete(int n)
|
||||
{
|
||||
wxASSERT( n < m_noStrings ) ;
|
||||
::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ;
|
||||
m_noStrings --;
|
||||
SetControlMaximum( m_macControl , m_noStrings) ;
|
||||
m_strings.Remove( n ) ;
|
||||
SetControlMaximum( m_macControl , Number()) ;
|
||||
}
|
||||
|
||||
void wxChoice::Clear()
|
||||
{
|
||||
for ( int i = 0 ; i < m_noStrings ; i++ )
|
||||
for ( int i = 0 ; i < Number() ; i++ )
|
||||
{
|
||||
::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ;
|
||||
}
|
||||
m_noStrings = 0;
|
||||
SetControlMaximum( m_macControl , m_noStrings) ;
|
||||
m_strings.Clear() ;
|
||||
SetControlMaximum( m_macControl , Number()) ;
|
||||
}
|
||||
|
||||
int wxChoice::GetSelection() const
|
||||
@@ -99,7 +105,7 @@ void wxChoice::SetSelection(int n)
|
||||
|
||||
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 )
|
||||
return i ;
|
||||
@@ -109,10 +115,7 @@ int wxChoice::FindString(const wxString& s) const
|
||||
|
||||
wxString wxChoice::GetString(int n) const
|
||||
{
|
||||
Str255 text ;
|
||||
::GetMenuItemText( m_macPopUpMenuHandle , n+1 , text ) ;
|
||||
p2cstr( text ) ;
|
||||
return wxString( text );
|
||||
return m_strings[n] ;
|
||||
}
|
||||
|
||||
void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
|
||||
@@ -21,48 +21,214 @@
|
||||
#include "wx/metafile.h"
|
||||
#include "wx/clipbrd.h"
|
||||
|
||||
#define wxUSE_DATAOBJ 1
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// open/close
|
||||
|
||||
bool clipboard_opened = false ;
|
||||
|
||||
bool wxOpenClipboard()
|
||||
{
|
||||
clipboard_opened = true ;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxCloseClipboard()
|
||||
{
|
||||
clipboard_opened = false ;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxIsClipboardOpened()
|
||||
{
|
||||
return TRUE;
|
||||
return clipboard_opened;
|
||||
}
|
||||
|
||||
// get/set data
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool wxSetClipboardData(wxDataFormat dataFormat,const void *data,int width , int height)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// get/set data
|
||||
|
||||
// clipboard formats
|
||||
|
||||
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;
|
||||
#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)
|
||||
@@ -80,11 +246,17 @@ bool wxGetClipboardFormatName(wxDataFormat dataFormat, wxChar *formatName, int m
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Generalized clipboard implementation by Matthew Flatt
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxClipboardBase)
|
||||
|
||||
wxClipboard::wxClipboard()
|
||||
{
|
||||
@@ -143,9 +315,9 @@ bool wxClipboard::AddData( wxDataObject *data )
|
||||
#if wxUSE_DATAOBJ
|
||||
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_OEMTEXT:
|
||||
@@ -160,10 +332,10 @@ bool wxClipboard::AddData( wxDataObject *data )
|
||||
{
|
||||
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
|
||||
wxBitmap bitmap(bitmapDataObject->GetBitmap());
|
||||
return wxSetClipboardData(data->GetFormat(), &bitmap);
|
||||
return wxSetClipboardData(format, &bitmap);
|
||||
}
|
||||
|
||||
#if wxUSE_METAFILE
|
||||
#if 0 // wxUSE_METAFILE
|
||||
case wxDF_METAFILE:
|
||||
{
|
||||
wxMetafileDataObject* metaFileDataObject =
|
||||
@@ -176,11 +348,12 @@ bool wxClipboard::AddData( wxDataObject *data )
|
||||
#endif // wxUSE_METAFILE
|
||||
|
||||
default:
|
||||
return wxSetClipboardData(data);
|
||||
// return wxSetClipboardData(data);
|
||||
break ;
|
||||
}
|
||||
#else // !wxUSE_DATAOBJ
|
||||
return FALSE;
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxClipboard::Close()
|
||||
@@ -188,7 +361,7 @@ void wxClipboard::Close()
|
||||
wxCloseClipboard();
|
||||
}
|
||||
|
||||
bool wxClipboard::IsSupported( wxDataFormat format )
|
||||
bool wxClipboard::IsSupported( const wxDataFormat &format )
|
||||
{
|
||||
return wxIsClipboardFormatAvailable(format);
|
||||
}
|
||||
@@ -198,7 +371,7 @@ bool wxClipboard::GetData( wxDataObject& data )
|
||||
#if wxUSE_DATAOBJ
|
||||
wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
|
||||
|
||||
wxDataFormat format = data.GetFormat();
|
||||
wxDataFormat format = data.GetPreferredFormat();
|
||||
switch ( format )
|
||||
{
|
||||
case wxDF_TEXT:
|
||||
@@ -219,7 +392,7 @@ bool wxClipboard::GetData( wxDataObject& data )
|
||||
case wxDF_DIB:
|
||||
{
|
||||
wxBitmapDataObject& bitmapDataObject = (wxBitmapDataObject &)data;
|
||||
wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(data->GetFormat());
|
||||
wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(format );
|
||||
if ( !bitmap )
|
||||
return FALSE;
|
||||
|
||||
@@ -228,7 +401,7 @@ bool wxClipboard::GetData( wxDataObject& data )
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#if wxUSE_METAFILE
|
||||
#if 0 // wxUSE_METAFILE
|
||||
case wxDF_METAFILE:
|
||||
{
|
||||
wxMetafileDataObject& metaFileDataObject = (wxMetafileDataObject &)data;
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
#include "wx/mac/colordlg.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wxColourDialog
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/colour.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
|
||||
#endif
|
||||
|
||||
// Colour
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
#include "wx/combobox.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
|
||||
#endif
|
||||
|
||||
// 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) ;
|
||||
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 ) ;
|
||||
SetControlMaximum( m_macControl , m_noStrings) ;
|
||||
@@ -125,7 +129,9 @@ void wxComboBox::SetSelection(long from, long to)
|
||||
|
||||
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 ++;
|
||||
SetControlMaximum( m_macControl , m_noStrings) ;
|
||||
}
|
||||
|
||||
@@ -16,15 +16,18 @@
|
||||
#include "wx/control.h"
|
||||
#include "wx/notebook.h"
|
||||
#include "wx/tabctrl.h"
|
||||
#include "wx/radiobox.h"
|
||||
#include "wx/spinbutt.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxControl, wxControlBase)
|
||||
BEGIN_EVENT_TABLE(wxControl, wxWindow)
|
||||
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
|
||||
EVT_CHAR( wxControl::OnKeyDown )
|
||||
EVT_PAINT( wxControl::OnPaint )
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
|
||||
@@ -32,6 +35,7 @@ END_EVENT_TABLE()
|
||||
|
||||
ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ;
|
||||
|
||||
pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) ;
|
||||
pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode )
|
||||
{
|
||||
if ( partCode != 0)
|
||||
@@ -46,9 +50,9 @@ pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCod
|
||||
|
||||
wxControl::wxControl()
|
||||
{
|
||||
m_macControl = NULL ;
|
||||
m_macHorizontalBorder = 0 ; // additional pixels around the real control
|
||||
m_macVerticalBorder = 0 ;
|
||||
m_macControl = NULL ;
|
||||
m_macHorizontalBorder = 0 ; // additional pixels around the real control
|
||||
m_macVerticalBorder = 0 ;
|
||||
m_backgroundColour = *wxWHITE;
|
||||
m_foregroundColour = *wxBLACK;
|
||||
#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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
m_label = title ;
|
||||
@@ -222,7 +229,7 @@ void wxControl::MacPostControlCreate()
|
||||
{
|
||||
// no font
|
||||
}
|
||||
else if ( IsKindOf( CLASSINFO( wxStaticBox ) ) )
|
||||
else if ( IsKindOf( CLASSINFO( wxStaticBox ) ) || IsKindOf( CLASSINFO( wxRadioBox ) ) || IsKindOf( CLASSINFO( wxButton ) ) )
|
||||
{
|
||||
ControlFontStyleRec controlstyle ;
|
||||
controlstyle.flags = kControlUseFontMask ;
|
||||
@@ -275,14 +282,16 @@ void wxControl::MacAdjustControlRect()
|
||||
{
|
||||
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 ) ) )
|
||||
{
|
||||
m_width = m_label.Length() * 8 ;
|
||||
}
|
||||
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 )
|
||||
{
|
||||
@@ -296,7 +305,7 @@ void wxControl::MacAdjustControlRect()
|
||||
wxMacDrawingHelper helper ( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ;
|
||||
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 )
|
||||
{
|
||||
int former_mac_x = (**m_macControl).contrlRect.left ;
|
||||
int former_mac_y = (**m_macControl).contrlRect.top ;
|
||||
Rect contrlRect ;
|
||||
GetControlBounds( m_macControl , &contrlRect ) ;
|
||||
int former_mac_x = contrlRect.left ;
|
||||
int former_mac_y = contrlRect.top ;
|
||||
int mac_x = m_x ;
|
||||
int mac_y = m_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 } ;
|
||||
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 } ;
|
||||
InvalRect( &inval ) ;
|
||||
InvalWindowRect( rootwindow , &inval ) ;
|
||||
}
|
||||
}
|
||||
if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
|
||||
@@ -378,7 +389,7 @@ void wxControl::MacSuperEnabled( bool enabled )
|
||||
}
|
||||
}
|
||||
wxWindow::MacSuperEnabled( enabled ) ;
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
void wxControl::MacSuperShown( bool show )
|
||||
@@ -418,8 +429,10 @@ void wxControl::DoSetSize(int x, int y,
|
||||
int former_w = m_width ;
|
||||
int former_h = m_height ;
|
||||
|
||||
int former_mac_x = (**m_macControl).contrlRect.left ;
|
||||
int former_mac_y = (**m_macControl).contrlRect.top ;
|
||||
Rect contrlRect ;
|
||||
GetControlBounds( m_macControl , &contrlRect ) ;
|
||||
int former_mac_x = contrlRect.left ;
|
||||
int former_mac_y = contrlRect.top ;
|
||||
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
@@ -430,9 +443,9 @@ void wxControl::DoSetSize(int x, int y,
|
||||
int actualHeight = height;
|
||||
int actualX = x;
|
||||
int actualY = y;
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
if (x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
actualX = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
if (y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
actualY = currentY;
|
||||
if (width == -1)
|
||||
actualWidth = currentW ;
|
||||
@@ -443,7 +456,8 @@ void wxControl::DoSetSize(int x, int y,
|
||||
return ;
|
||||
|
||||
AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
|
||||
wxMacDrawingHelper focus( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ;
|
||||
WindowRef macrootwindow = GetMacRootWindow() ;
|
||||
wxMacDrawingHelper focus( wxFindWinFromMacWindow( macrootwindow ) ) ;
|
||||
|
||||
int mac_x = actualX ;
|
||||
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 } ;
|
||||
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 } ;
|
||||
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 } ;
|
||||
InvalRect( &inval ) ;
|
||||
InvalWindowRect( macrootwindow, &inval ) ;
|
||||
}
|
||||
m_width = actualWidth ;
|
||||
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 } ;
|
||||
InvalRect( &inval ) ;
|
||||
InvalWindowRect( macrootwindow , &inval ) ;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if ( m_macControl )
|
||||
@@ -566,6 +621,7 @@ void wxControl::OnPaint(wxPaintEvent& event)
|
||||
if ( win )
|
||||
{
|
||||
wxMacDrawingHelper help( win ) ;
|
||||
// the mac control manager always assumes to have the origin at 0,0
|
||||
SetOrigin( 0 , 0 ) ;
|
||||
|
||||
bool hasTabBehind = false ;
|
||||
@@ -629,7 +685,7 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
|
||||
return ;
|
||||
}
|
||||
|
||||
if (event.GetEventType() == wxEVT_LEFT_DOWN )
|
||||
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
|
||||
{
|
||||
|
||||
int x = event.m_x ;
|
||||
|
||||
@@ -16,17 +16,33 @@
|
||||
#include "wx/cursor.h"
|
||||
#include "wx/icon.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
|
||||
#endif
|
||||
|
||||
const short kwxCursorHandId = 9 ;
|
||||
const short kwxCursorSizeWEId = 10 ;
|
||||
const short kwxCursorSizeNSId = 11 ;
|
||||
#if !TARGET_CARBON
|
||||
Cursor* MacArrowCursorPtr = &qd.arrow ;
|
||||
CursHandle MacArrowCursor = &MacArrowCursorPtr ;
|
||||
#else
|
||||
bool MacArrowInstalled = false ;
|
||||
Cursor MacArrow ;
|
||||
Cursor* MacArrowCursorPtr = &MacArrow ;
|
||||
CursHandle MacArrowCursor = &MacArrowCursorPtr ;
|
||||
#endif
|
||||
CursHandle gMacCurrentCursor = NULL ;
|
||||
|
||||
wxCursorRefData::wxCursorRefData()
|
||||
{
|
||||
#if TARGET_CARBON
|
||||
if ( !MacArrowInstalled )
|
||||
{
|
||||
MacArrowCursorPtr = GetQDGlobalsArrow( &MacArrow ) ;
|
||||
MacArrowInstalled = true ;
|
||||
}
|
||||
#endif
|
||||
m_width = 32;
|
||||
m_height = 32;
|
||||
m_hCursor = NULL ;
|
||||
@@ -34,8 +50,8 @@ wxCursorRefData::wxCursorRefData()
|
||||
|
||||
wxCursorRefData::~wxCursorRefData()
|
||||
{
|
||||
if ( m_hCursor && ( m_hCursor != MacArrowCursor ) )
|
||||
::DisposeHandle( (Handle) m_hCursor ) ;
|
||||
// if ( m_hCursor && ( m_hCursor != MacArrowCursor ) )
|
||||
// ::ReleaseResource( (Handle) m_hCursor ) ;
|
||||
}
|
||||
|
||||
// Cursors
|
||||
|
||||
@@ -102,8 +102,8 @@ const wxChar *wxFrameNameStr = wxT("frame");
|
||||
const wxChar *wxGaugeNameStr = wxT("gauge");
|
||||
const wxChar *wxStaticBoxNameStr = wxT("groupBox");
|
||||
const wxChar *wxListBoxNameStr = wxT("listBox");
|
||||
const wxChar *wxStaticTextNameStr = wxT("message");
|
||||
const wxChar *wxStaticBitmapNameStr = wxT("message");
|
||||
const wxChar *wxStaticTextNameStr = wxT("statictext");
|
||||
const wxChar *wxStaticBitmapNameStr = wxT("staticbitmap");
|
||||
const wxChar *wxMultiTextNameStr = wxT("multitext");
|
||||
const wxChar *wxPanelNameStr = wxT("panel");
|
||||
const wxChar *wxRadioBoxNameStr = wxT("radioBox");
|
||||
@@ -134,5 +134,17 @@ const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
|
||||
const wxChar *wxFloatToStringStr = 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 wxPoint wxDefaultPosition(-1, -1);
|
||||
|
||||
@@ -44,56 +44,40 @@
|
||||
|
||||
wxDataFormat::wxDataFormat()
|
||||
{
|
||||
m_vType = wxDF_INVALID;
|
||||
m_vFormat = 0;
|
||||
m_type = wxDF_INVALID;
|
||||
m_format = 0;
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat(
|
||||
wxDataFormatId vType
|
||||
)
|
||||
wxDataFormat::wxDataFormat( wxDataFormatId vType )
|
||||
{
|
||||
PrepareFormats();
|
||||
SetType(vType);
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat(
|
||||
const wxChar* zId
|
||||
)
|
||||
wxDataFormat::wxDataFormat( const wxChar* zId)
|
||||
{
|
||||
PrepareFormats();
|
||||
SetId(zId);
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat(
|
||||
const wxString& rId
|
||||
)
|
||||
wxDataFormat::wxDataFormat( const wxString& rId)
|
||||
{
|
||||
PrepareFormats();
|
||||
SetId(rId);
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat(
|
||||
NativeFormat vFormat
|
||||
)
|
||||
wxDataFormat::wxDataFormat( NativeFormat vFormat)
|
||||
{
|
||||
PrepareFormats();
|
||||
SetId(vFormat);
|
||||
}
|
||||
|
||||
void wxDataFormat::SetType(
|
||||
wxDataFormatId vType
|
||||
)
|
||||
void wxDataFormat::SetType( wxDataFormatId Type )
|
||||
{
|
||||
m_vType = vType;
|
||||
m_type = Type;
|
||||
|
||||
if (m_vType == wxDF_TEXT)
|
||||
m_vFormat = 0;
|
||||
else
|
||||
if (m_vType == wxDF_BITMAP)
|
||||
m_vFormat = 0;
|
||||
else
|
||||
if (m_vType == wxDF_FILENAME)
|
||||
m_vFormat = 0;
|
||||
if (m_type == wxDF_TEXT)
|
||||
m_format = 'TEXT';
|
||||
else if (m_type == wxDF_BITMAP || m_type == wxDF_METAFILE )
|
||||
m_format = 'PICT';
|
||||
else if (m_type == wxDF_FILENAME)
|
||||
m_format = 'SPEC';
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG( wxT("invalid dataformat") );
|
||||
@@ -102,56 +86,37 @@ void wxDataFormat::SetType(
|
||||
|
||||
wxDataFormatId wxDataFormat::GetType() const
|
||||
{
|
||||
return m_vType;
|
||||
return m_type;
|
||||
}
|
||||
|
||||
wxString wxDataFormat::GetId() const
|
||||
{
|
||||
wxString sRet(""); // TODO: gdk_atom_name( m_format ) );
|
||||
wxString sRet(""); // TODO: to name of ( m_format ) );
|
||||
return sRet;
|
||||
}
|
||||
|
||||
void wxDataFormat::SetId(
|
||||
NativeFormat vFormat
|
||||
)
|
||||
void wxDataFormat::SetId( NativeFormat format )
|
||||
{
|
||||
m_vFormat = vFormat;
|
||||
// TODO:
|
||||
/*
|
||||
if (m_format == g_textAtom)
|
||||
m_format = format;
|
||||
|
||||
if (m_format == 'TEXT')
|
||||
m_type = wxDF_TEXT;
|
||||
else
|
||||
if (m_format == g_pngAtom)
|
||||
if (m_format == 'PICT')
|
||||
m_type = wxDF_BITMAP;
|
||||
else
|
||||
if (m_format == g_fileAtom)
|
||||
if (m_format == 'SPEC')
|
||||
m_type = wxDF_FILENAME;
|
||||
else
|
||||
m_type = wxDF_PRIVATE;
|
||||
*/
|
||||
}
|
||||
|
||||
void wxDataFormat::SetId(
|
||||
const wxChar* zId
|
||||
)
|
||||
void wxDataFormat::SetId( const wxChar* zId )
|
||||
{
|
||||
wxString tmp(zId);
|
||||
|
||||
m_vType = wxDF_PRIVATE;
|
||||
m_vFormat = 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 );
|
||||
*/
|
||||
m_type = wxDF_PRIVATE;
|
||||
m_format = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
452
src/mac/dc.cpp
452
src/mac/dc.cpp
@@ -14,8 +14,11 @@
|
||||
#endif
|
||||
|
||||
#include "wx/dc.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// constants
|
||||
@@ -34,7 +37,7 @@ long wxDC::m_macCurrentPortId = 1 ;
|
||||
// wxDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxDC::wxDC(void)
|
||||
wxDC::wxDC()
|
||||
{
|
||||
m_ok = FALSE;
|
||||
m_optimize = FALSE;
|
||||
@@ -42,8 +45,8 @@ wxDC::wxDC(void)
|
||||
m_colour = TRUE;
|
||||
m_clipping = FALSE;
|
||||
|
||||
m_mm_to_pix_x = 1.0;
|
||||
m_mm_to_pix_y = 1.0;
|
||||
m_mm_to_pix_x = mm2pt;
|
||||
m_mm_to_pix_y = mm2pt;
|
||||
|
||||
m_logicalOriginX = 0;
|
||||
m_logicalOriginY = 0;
|
||||
@@ -102,20 +105,32 @@ 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 )
|
||||
{
|
||||
::SetPort( m_macPort ) ;
|
||||
::SetOrigin( 0 , 0 ) ;
|
||||
::ClipRect( &m_macPort->portRect ) ;
|
||||
::PenNormal() ;
|
||||
::SetPort( m_macOrigPort ) ;
|
||||
}
|
||||
*/
|
||||
++m_macCurrentPortId ;
|
||||
};
|
||||
|
||||
void wxDC::MacSetupPort() const
|
||||
{
|
||||
AGAPortHelper* help = &m_macPortHelper ;
|
||||
help->Setup( m_macPort ) ;
|
||||
m_macPortId = ++m_macCurrentPortId ;
|
||||
::SetPort(m_macPort);
|
||||
::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v);
|
||||
::ClipRect(&m_macClipRect);
|
||||
|
||||
@@ -124,8 +139,10 @@ void wxDC::MacSetupPort() const
|
||||
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())
|
||||
return;
|
||||
MacVerifySetup() ;
|
||||
@@ -140,7 +157,7 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask )
|
||||
{
|
||||
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 ) ;
|
||||
::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 ;
|
||||
dest.top = YLOG2DEV(y) ;
|
||||
dest.left = XLOG2DEV(x) ;
|
||||
dest.bottom = YLOG2DEV(y + bmap->m_height ) ;
|
||||
dest.right = XLOG2DEV(x + bmap->m_width ) ;
|
||||
dest.bottom = YLOG2DEV(y + bmap->m_height * scale) ;
|
||||
dest.right = XLOG2DEV(x + bmap->m_width * scale ) ;
|
||||
|
||||
if ( useMask && bmp.GetMask() )
|
||||
{
|
||||
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 ) ;
|
||||
UnlockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
CopyBits( &GrafPtr( bmapworld )->portBits , &GrafPtr( m_macPort )->portBits ,
|
||||
CopyBits( GetPortBitMapForCopyBits( bmapworld ) , GetPortBitMapForCopyBits( m_macPort ),
|
||||
&source, &dest, srcCopy, NULL ) ;
|
||||
|
||||
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())
|
||||
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 );
|
||||
};
|
||||
|
||||
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() ;
|
||||
MacVerifySetup() ;
|
||||
if( m_clipping )
|
||||
{
|
||||
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 } ;
|
||||
|
||||
::ClipRect( &clip ) ;
|
||||
::ClipRect( &clip ) ;
|
||||
|
||||
};
|
||||
|
||||
void wxDC::SetClippingRegion(const wxRect& rect)
|
||||
void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion )
|
||||
{
|
||||
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)
|
||||
@@ -317,47 +286,13 @@ void wxDC::DestroyClippingRegion(void)
|
||||
::ClipRect(&m_macClipRect);
|
||||
};
|
||||
|
||||
void wxDC::GetClippingBox( wxCoord *x, wxCoord *y, wxCoord *width, wxCoord *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
|
||||
void wxDC::DoGetSize( int* width, int* height ) const
|
||||
{
|
||||
*width = m_maxX-m_minX;
|
||||
*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 h = 0;
|
||||
@@ -416,12 +351,6 @@ void wxDC::SetUserScale( double x, double y )
|
||||
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 )
|
||||
{
|
||||
// allow negative ?
|
||||
@@ -430,40 +359,20 @@ void wxDC::SetLogicalScale( double x, double y )
|
||||
ComputeScaleAndOrigin();
|
||||
};
|
||||
|
||||
void wxDC::GetLogicalScale( double *x, double *y )
|
||||
{
|
||||
if (x) *x = m_logicalScaleX;
|
||||
if (y) *y = m_logicalScaleY;
|
||||
};
|
||||
|
||||
void wxDC::SetLogicalOrigin( long x, long y )
|
||||
void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
|
||||
{
|
||||
m_logicalOriginX = x * m_signX; // is this still correct ?
|
||||
m_logicalOriginY = y * m_signY;
|
||||
ComputeScaleAndOrigin();
|
||||
};
|
||||
|
||||
void wxDC::GetLogicalOrigin( long *x, long *y )
|
||||
{
|
||||
if (x) *x = m_logicalOriginX;
|
||||
if (y) *y = m_logicalOriginY;
|
||||
};
|
||||
|
||||
void wxDC::SetDeviceOrigin( long x, long y )
|
||||
void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
|
||||
{
|
||||
m_externalDeviceOriginX = x;
|
||||
m_externalDeviceOriginY = y;
|
||||
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 )
|
||||
{
|
||||
m_internalDeviceOriginX = x;
|
||||
@@ -476,53 +385,14 @@ void wxDC::GetInternalDeviceOrigin( long *x, long *y )
|
||||
if (x) *x = m_internalDeviceOriginX;
|
||||
if (y) *y = m_internalDeviceOriginY;
|
||||
};
|
||||
|
||||
*/
|
||||
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
|
||||
{
|
||||
m_signX = (xLeftRight ? 1 : -1);
|
||||
m_signY = (yBottomUp ? -1 : 1);
|
||||
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 )
|
||||
{
|
||||
@@ -531,6 +401,16 @@ void wxDC::CalcBoundingBox( long x, long y )
|
||||
if (x > m_maxX) m_maxX = x;
|
||||
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)
|
||||
{
|
||||
@@ -547,12 +427,7 @@ void wxDC::ComputeScaleAndOrigin(void)
|
||||
// CMB: if scale has changed call SetPen to recalulate the line width
|
||||
if (m_scaleX != origScaleX || m_scaleY != origScaleY)
|
||||
{
|
||||
// this is a bit artificial, but we need to force wxDC to think
|
||||
// the pen has changed
|
||||
wxPen* pen = & GetPen();
|
||||
wxPen tempPen;
|
||||
m_pen = tempPen;
|
||||
SetPen(* pen);
|
||||
// TODO : set internal flags for recalc
|
||||
}
|
||||
};
|
||||
|
||||
@@ -634,16 +509,17 @@ void wxDC::SetLogicalFunction( int function )
|
||||
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 ;
|
||||
}
|
||||
|
||||
void wxDC::DrawLine( long x1, long y1, long x2, long y2 )
|
||||
void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
||||
{
|
||||
if (!Ok())
|
||||
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())
|
||||
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())
|
||||
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 ,
|
||||
int fillStyle )
|
||||
void wxDC::DoDrawPolygon(int n, wxPoint points[],
|
||||
wxCoord xoffset, wxCoord yoffset,
|
||||
int fillStyle )
|
||||
{
|
||||
if (!Ok())
|
||||
return;
|
||||
@@ -754,7 +635,7 @@ void wxDC::DrawPolygon( int n, wxPoint points[], long xoffset , long yoffset ,
|
||||
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())
|
||||
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())
|
||||
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())
|
||||
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;
|
||||
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,
|
||||
wxDC *source, long xsrc, long ysrc, int logical_func , bool useMask )
|
||||
bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
|
||||
wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask )
|
||||
{
|
||||
if (!Ok()) return FALSE;
|
||||
MacVerifySetup() ;
|
||||
@@ -1069,8 +952,8 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
|
||||
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
|
||||
RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
|
||||
RGBColor black = { 0,0,0} ;
|
||||
RGBForeColor( &m_textForegroundColour.GetPixel() ) ;
|
||||
RGBBackColor( &m_textBackgroundColour.GetPixel() ) ;
|
||||
RGBForeColor( &m_textForegroundColour.GetPixel() ) ;
|
||||
RGBBackColor( &m_textBackgroundColour.GetPixel() ) ;
|
||||
|
||||
if ( LockPixels(bmappixels) )
|
||||
{
|
||||
@@ -1094,7 +977,7 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
|
||||
logical_func == wxXOR ? srcXor :
|
||||
// logical_func == wxOR_REVERSE ? MERGEPAINT :
|
||||
// logical_func == wxAND_REVERSE ? SRCERASE :
|
||||
logical_func == wxSRC_OR ? srcOr :
|
||||
// logical_func == wxSRC_OR ? srcOr :
|
||||
// logical_func == wxSRC_AND ? SRCAND :
|
||||
srcCopy );
|
||||
|
||||
@@ -1103,14 +986,15 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
|
||||
wxASSERT( mode == srcCopy ) ;
|
||||
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 ) ;
|
||||
UnlockPixels( GetGWorldPixMap( source->m_macMask ) ) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyBits( &GrafPtr( sourcePort )->portBits , &GrafPtr( m_macPort )->portBits ,
|
||||
CopyBits( GetPortBitMapForCopyBits( sourcePort ) , GetPortBitMapForCopyBits( m_macPort ) ,
|
||||
&srcrect, &dstrect, mode, NULL ) ;
|
||||
}
|
||||
UnlockPixels( bmappixels ) ;
|
||||
@@ -1123,7 +1007,11 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height,
|
||||
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())
|
||||
return;
|
||||
@@ -1161,14 +1049,14 @@ void wxDC::DrawText( const wxString &string, long x, long y, bool use16)
|
||||
|
||||
if ( wxApp::s_macDefaultEncodingIsPC )
|
||||
{
|
||||
macText = wxMacMakeMacStringFromPC( string ) ;
|
||||
macText = wxMacMakeMacStringFromPC( strtext ) ;
|
||||
text = macText ;
|
||||
length = macText.Length() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = string ;
|
||||
length = string.Length() ;
|
||||
text = strtext ;
|
||||
length = strtext.Length() ;
|
||||
}
|
||||
|
||||
int laststop = 0 ;
|
||||
@@ -1200,9 +1088,9 @@ bool wxDC::CanGetTextExtent(void) const
|
||||
return true ;
|
||||
}
|
||||
|
||||
void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
|
||||
long *descent, long *externalLeading ,
|
||||
wxFont *theFont , bool use16 ) const
|
||||
void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height,
|
||||
wxCoord *descent, wxCoord *externalLeading ,
|
||||
wxFont *theFont ) const
|
||||
{
|
||||
if (!Ok())
|
||||
return;
|
||||
@@ -1217,11 +1105,8 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
|
||||
|
||||
if ( font )
|
||||
{
|
||||
long yy1 = YLOG2DEV(0);
|
||||
long yy2 = YLOG2DEV(font->m_macFontSize);
|
||||
|
||||
::TextFont( font->m_macFontNum ) ;
|
||||
::TextSize( abs( yy2-yy1) ) ;
|
||||
::TextSize( YLOG2DEVREL( font->m_macFontSize) ) ;
|
||||
::TextFace( font->m_macFontStyle ) ;
|
||||
}
|
||||
}
|
||||
@@ -1233,9 +1118,12 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
|
||||
FontInfo fi ;
|
||||
::GetFontInfo( &fi ) ;
|
||||
|
||||
*height = fi.descent + fi.ascent ;
|
||||
*descent = fi.descent ;
|
||||
*externalLeading = fi.leading ;
|
||||
if ( height )
|
||||
*height = YDEV2LOGREL( fi.descent + fi.ascent ) ;
|
||||
if ( descent )
|
||||
*descent =YDEV2LOGREL( fi.descent );
|
||||
if ( externalLeading )
|
||||
*externalLeading = YDEV2LOGREL( fi.leading ) ;
|
||||
|
||||
const char *text = NULL ;
|
||||
int length = 0 ;
|
||||
@@ -1255,24 +1143,28 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height,
|
||||
int laststop = 0 ;
|
||||
int i = 0 ;
|
||||
int curwidth = 0 ;
|
||||
*width = 0 ;
|
||||
|
||||
while( i < length )
|
||||
if ( width )
|
||||
{
|
||||
if( text[i] == 13 || text[i] == 10)
|
||||
{
|
||||
*height += fi.descent + fi.ascent + fi.leading;
|
||||
curwidth = ::TextWidth( text , laststop , i - laststop ) ;
|
||||
if ( curwidth > *width )
|
||||
*width = curwidth ;
|
||||
laststop = i+1 ;
|
||||
}
|
||||
i++ ;
|
||||
}
|
||||
*width = 0 ;
|
||||
|
||||
curwidth = ::TextWidth( text , laststop , i - laststop ) ;
|
||||
if ( curwidth > *width )
|
||||
*width = curwidth ;
|
||||
while( i < length )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
@@ -1292,7 +1184,7 @@ wxCoord wxDC::GetCharWidth(void) const
|
||||
FontInfo fi ;
|
||||
::GetFontInfo( &fi ) ;
|
||||
|
||||
return (fi.descent + fi.ascent) / 2 ;
|
||||
return YDEV2LOGREL((fi.descent + fi.ascent) / 2) ;
|
||||
}
|
||||
|
||||
wxCoord wxDC::GetCharHeight(void) const
|
||||
@@ -1307,7 +1199,7 @@ wxCoord wxDC::GetCharHeight(void) const
|
||||
FontInfo fi ;
|
||||
::GetFontInfo( &fi ) ;
|
||||
|
||||
return fi.descent + fi.ascent ;
|
||||
return YDEV2LOGREL( fi.descent + fi.ascent );
|
||||
}
|
||||
|
||||
void wxDC::Clear(void)
|
||||
@@ -1332,6 +1224,7 @@ void wxDC::MacInstallFont() const
|
||||
|
||||
if ( m_macFontInstalled )
|
||||
return ;
|
||||
Pattern blackColor ;
|
||||
|
||||
wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
|
||||
|
||||
@@ -1377,7 +1270,7 @@ void wxDC::MacInstallFont() const
|
||||
mode = patCopy ;
|
||||
break ;
|
||||
case wxINVERT: // NOT dst
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
mode = patXor ;
|
||||
break ;
|
||||
case wxXOR: // src XOR dst
|
||||
@@ -1403,8 +1296,8 @@ void wxDC::MacInstallFont() const
|
||||
case wxNAND: // (NOT src) OR (NOT dst)
|
||||
case wxOR: // src OR dst
|
||||
case wxSET: // 1
|
||||
case wxSRC_OR: // source _bitmap_ OR destination
|
||||
case wxSRC_AND: // source _bitmap_ AND destination
|
||||
// case wxSRC_OR: // source _bitmap_ OR destination
|
||||
// case wxSRC_AND: // source _bitmap_ AND destination
|
||||
break ;
|
||||
}
|
||||
::PenMode( mode ) ;
|
||||
@@ -1447,6 +1340,8 @@ void wxDC::MacInstallPen() const
|
||||
return;
|
||||
MacVerifySetup() ;
|
||||
|
||||
Pattern blackColor;
|
||||
|
||||
if ( m_macPenInstalled )
|
||||
return ;
|
||||
|
||||
@@ -1460,7 +1355,7 @@ void wxDC::MacInstallPen() const
|
||||
int penStyle = m_pen.GetStyle();
|
||||
|
||||
if (penStyle == wxSOLID)
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
else if (IS_HATCH(penStyle))
|
||||
{
|
||||
Pattern pat ;
|
||||
@@ -1469,7 +1364,7 @@ void wxDC::MacInstallPen() const
|
||||
}
|
||||
else
|
||||
{
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
}
|
||||
|
||||
short mode = patCopy ;
|
||||
@@ -1482,7 +1377,7 @@ void wxDC::MacInstallPen() const
|
||||
mode = patCopy ;
|
||||
break ;
|
||||
case wxINVERT: // NOT dst
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
mode = patXor ;
|
||||
break ;
|
||||
case wxXOR: // src XOR dst
|
||||
@@ -1508,8 +1403,8 @@ void wxDC::MacInstallPen() const
|
||||
case wxNAND: // (NOT src) OR (NOT dst)
|
||||
case wxOR: // src OR dst
|
||||
case wxSET: // 1
|
||||
case wxSRC_OR: // source _bitmap_ OR destination
|
||||
case wxSRC_AND: // source _bitmap_ AND destination
|
||||
// case wxSRC_OR: // source _bitmap_ OR destination
|
||||
// case wxSRC_AND: // source _bitmap_ AND destination
|
||||
break ;
|
||||
}
|
||||
::PenMode( mode ) ;
|
||||
@@ -1523,7 +1418,7 @@ void wxDC::MacInstallBrush() const
|
||||
if (!Ok())
|
||||
return;
|
||||
MacVerifySetup() ;
|
||||
|
||||
Pattern blackColor, whiteColor ;
|
||||
if ( m_macBrushInstalled )
|
||||
return ;
|
||||
|
||||
@@ -1534,7 +1429,7 @@ void wxDC::MacInstallBrush() const
|
||||
|
||||
int brushStyle = m_brush.GetStyle();
|
||||
if (brushStyle == wxSOLID)
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
else if (IS_HATCH(brushStyle))
|
||||
{
|
||||
Pattern pat ;
|
||||
@@ -1543,7 +1438,7 @@ void wxDC::MacInstallBrush() const
|
||||
}
|
||||
else
|
||||
{
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
}
|
||||
|
||||
|
||||
@@ -1551,7 +1446,7 @@ void wxDC::MacInstallBrush() const
|
||||
|
||||
brushStyle = m_backgroundBrush.GetStyle();
|
||||
if (brushStyle == wxSOLID)
|
||||
::BackPat(&qd.white);
|
||||
::BackPat(GetQDGlobalsWhite(&whiteColor));
|
||||
else if (IS_HATCH(brushStyle))
|
||||
{
|
||||
Pattern pat ;
|
||||
@@ -1560,7 +1455,7 @@ void wxDC::MacInstallBrush() const
|
||||
}
|
||||
else
|
||||
{
|
||||
::BackPat(&qd.white);
|
||||
::BackPat(GetQDGlobalsWhite(&whiteColor));
|
||||
}
|
||||
|
||||
short mode = patCopy ;
|
||||
@@ -1573,7 +1468,7 @@ void wxDC::MacInstallBrush() const
|
||||
mode = patCopy ;
|
||||
break ;
|
||||
case wxINVERT: // NOT dst
|
||||
::PenPat(&qd.black);
|
||||
::PenPat(GetQDGlobalsBlack(&blackColor));
|
||||
mode = patXor ;
|
||||
break ;
|
||||
case wxXOR: // src XOR dst
|
||||
@@ -1599,8 +1494,8 @@ void wxDC::MacInstallBrush() const
|
||||
case wxNAND: // (NOT src) OR (NOT dst)
|
||||
case wxOR: // src OR dst
|
||||
case wxSET: // 1
|
||||
case wxSRC_OR: // source _bitmap_ OR destination
|
||||
case wxSRC_AND: // source _bitmap_ AND destination
|
||||
// case wxSRC_OR: // source _bitmap_ OR destination
|
||||
// case wxSRC_AND: // source _bitmap_ AND destination
|
||||
break ;
|
||||
}
|
||||
::PenMode( mode ) ;
|
||||
@@ -1609,4 +1504,47 @@ void wxDC::MacInstallBrush() const
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,11 @@
|
||||
// wxPaintDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wxWindowDC
|
||||
@@ -38,7 +40,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
|
||||
|
||||
#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 );
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
m_minY = m_minX = 0;
|
||||
wxSize size = the_canvas->GetSize() ;
|
||||
m_maxX = size.x ;
|
||||
m_maxY = size.y ;
|
||||
|
||||
MacSetupPort() ;
|
||||
m_ok = TRUE ;
|
||||
}
|
||||
|
||||
wxWindowDC::~wxWindowDC(void)
|
||||
wxWindowDC::~wxWindowDC()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -63,7 +70,7 @@ wxWindowDC::~wxWindowDC(void)
|
||||
* wxClientDC
|
||||
*/
|
||||
|
||||
wxClientDC::wxClientDC(void)
|
||||
wxClientDC::wxClientDC()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -75,12 +82,16 @@ wxClientDC::wxClientDC(wxWindow *window)
|
||||
window->MacGetPortClientParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow );
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
MacSetupPort() ;
|
||||
m_minY = m_minX = 0;
|
||||
wxSize size = window->GetSize() ;
|
||||
m_maxX = size.x ;
|
||||
m_maxY = size.y ;
|
||||
m_ok = TRUE ;
|
||||
SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
|
||||
SetFont( window->GetFont() ) ;
|
||||
}
|
||||
|
||||
wxClientDC::~wxClientDC(void)
|
||||
wxClientDC::~wxClientDC()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -88,7 +99,7 @@ wxClientDC::~wxClientDC(void)
|
||||
* wxPaintDC
|
||||
*/
|
||||
|
||||
wxPaintDC::wxPaintDC(void)
|
||||
wxPaintDC::wxPaintDC()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -104,6 +115,10 @@ wxPaintDC::wxPaintDC(wxWindow *window)
|
||||
m_ok = TRUE ;
|
||||
long 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 ) ;
|
||||
SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
|
||||
SetFont(window->GetFont() ) ;
|
||||
|
||||
@@ -33,10 +33,20 @@ wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
|
||||
|
||||
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 )
|
||||
{
|
||||
if ( m_selected.Ok() )
|
||||
{
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
|
||||
UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ;
|
||||
}
|
||||
m_selected = bitmap;
|
||||
if (m_selected.Ok())
|
||||
{
|
||||
@@ -44,6 +54,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
||||
if ( bmap->m_hBitmap )
|
||||
{
|
||||
m_macPort = (GrafPtr) bmap->m_hBitmap ;
|
||||
LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
|
||||
wxMask * mask = bitmap.GetMask() ;
|
||||
if ( mask )
|
||||
{
|
||||
|
||||
@@ -25,31 +25,36 @@
|
||||
|
||||
#include "wx/dcprint.h"
|
||||
#include "math.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_CLASS(wxPrinterDC, wxDC)
|
||||
#endif
|
||||
|
||||
GrafPtr macPrintFormerPort = NULL ;
|
||||
|
||||
wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
OSErr err ;
|
||||
wxString message ;
|
||||
|
||||
m_printData = printdata ;
|
||||
m_printData.ConvertToNative() ;
|
||||
|
||||
::PrOpen() ;
|
||||
::UMAPrOpen() ;
|
||||
err = PrError() ;
|
||||
if ( err )
|
||||
{
|
||||
message.Printf( "Print Error %d", err ) ;
|
||||
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
|
||||
PrClose() ;
|
||||
UMAPrClose() ;
|
||||
}
|
||||
|
||||
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 ?
|
||||
}
|
||||
err = PrError() ;
|
||||
@@ -57,20 +62,31 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
|
||||
{
|
||||
message.Printf( "Print Error %d", err ) ;
|
||||
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
|
||||
PrClose() ;
|
||||
UMAPrClose() ;
|
||||
}
|
||||
::GetPort( &macPrintFormerPort ) ;
|
||||
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
|
||||
m_macPort = (GrafPtr ) m_macPrintPort ;
|
||||
m_ok = TRUE ;
|
||||
m_minY = m_minX = 0 ;
|
||||
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 ;
|
||||
#else
|
||||
#pragma warning "TODO:printing support for carbon"
|
||||
#endif
|
||||
}
|
||||
|
||||
wxPrinterDC::~wxPrinterDC(void)
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
if ( m_ok )
|
||||
{
|
||||
OSErr err ;
|
||||
@@ -91,11 +107,16 @@ wxPrinterDC::~wxPrinterDC(void)
|
||||
{
|
||||
message.Printf( "Print Error %d", err ) ;
|
||||
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
|
||||
PrClose() ;
|
||||
UMAPrClose() ;
|
||||
}
|
||||
::PrClose() ;
|
||||
::SetPort( macPrintFormerPort ) ;
|
||||
::UMAPrClose() ;
|
||||
// ::SetPort( macPrintFormerPort ) ;
|
||||
::SetPort( LMGetWMgrPort() ) ;
|
||||
m_macPortHelper.Clear() ;
|
||||
}
|
||||
#else
|
||||
#pragma warning "TODO:printing support for carbon"
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) )
|
||||
@@ -109,13 +130,30 @@ void wxPrinterDC::EndDoc(void)
|
||||
|
||||
void wxPrinterDC::StartPage(void)
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
if ( !m_ok )
|
||||
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 ;
|
||||
wxString message ;
|
||||
|
||||
PrOpenPage( m_macPrintPort , NULL ) ;
|
||||
PrOpenPage( m_macPrintPort , NULL ) ;
|
||||
SetOrigin( - (**m_printData.m_macPrintInfo).rPaper.left , - (**m_printData.m_macPrintInfo).rPaper.top ) ;
|
||||
Rect clip = { -32000 , -32000 , 32000 , 32000 } ;
|
||||
::ClipRect( &clip ) ;
|
||||
@@ -126,14 +164,18 @@ void wxPrinterDC::StartPage(void)
|
||||
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
|
||||
::PrClosePage( m_macPrintPort) ;
|
||||
::PrCloseDoc( m_macPrintPort ) ;
|
||||
::PrClose() ;
|
||||
::UMAPrClose() ;
|
||||
::SetPort( macPrintFormerPort ) ;
|
||||
m_ok = FALSE ;
|
||||
}
|
||||
#else
|
||||
#pragma warning "TODO:printing support for carbon"
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxPrinterDC::EndPage(void)
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
if ( !m_ok )
|
||||
return ;
|
||||
|
||||
@@ -147,8 +189,12 @@ void wxPrinterDC::EndPage(void)
|
||||
message.Printf( "Print Error %d", err ) ;
|
||||
wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
|
||||
::PrCloseDoc( m_macPrintPort ) ;
|
||||
::PrClose() ;
|
||||
::UMAPrClose() ;
|
||||
::SetPort( macPrintFormerPort ) ;
|
||||
m_ok = FALSE ;
|
||||
}
|
||||
#else
|
||||
#pragma warning "TODO:printing support for carbon"
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -14,15 +14,34 @@
|
||||
#endif
|
||||
|
||||
#include "wx/dcscreen.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
|
||||
#endif
|
||||
|
||||
// Create a DC representing the whole screen
|
||||
wxScreenDC::wxScreenDC()
|
||||
{
|
||||
#if TARGET_CARBON
|
||||
m_macPort = GetQDGlobalsThePort() ;
|
||||
#else
|
||||
m_macPort = LMGetWMgrPort() ;
|
||||
#endif
|
||||
MacSetupPort() ;
|
||||
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()
|
||||
|
||||
@@ -27,6 +27,7 @@ wxList wxModalDialogs;
|
||||
wxList wxModelessWindows; // Frames and modeless dialogs
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog, wxPanel)
|
||||
@@ -39,11 +40,11 @@ BEGIN_EVENT_TABLE(wxDialog, wxPanel)
|
||||
EVT_CLOSE(wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#endif
|
||||
|
||||
wxDialog::wxDialog()
|
||||
{
|
||||
m_isShown = FALSE;
|
||||
m_modalShowing = FALSE;
|
||||
m_isShown = FALSE;
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
}
|
||||
|
||||
@@ -54,15 +55,8 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
||||
long style,
|
||||
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));
|
||||
SetName(name);
|
||||
|
||||
if (!parent)
|
||||
wxTopLevelWindows.Append(this);
|
||||
@@ -74,59 +68,26 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
||||
else
|
||||
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 ;
|
||||
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
|
||||
m_macWindowData->m_macFocus = NULL ;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxDialog::SetModal(bool flag)
|
||||
{
|
||||
if ( flag )
|
||||
m_windowStyle |= wxDIALOG_MODAL ;
|
||||
else
|
||||
if ( m_windowStyle & wxDIALOG_MODAL )
|
||||
m_windowStyle -= wxDIALOG_MODAL ;
|
||||
if ( flag )
|
||||
{
|
||||
m_windowStyle |= wxDIALOG_MODAL;
|
||||
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
if (!flag)
|
||||
wxModelessWindows.Append(this);
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_windowStyle &= ~wxDIALOG_MODAL;
|
||||
|
||||
wxModelessWindows.Append(this);
|
||||
}
|
||||
}
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
@@ -134,10 +95,10 @@ wxDialog::~wxDialog()
|
||||
m_isBeingDeleted = TRUE ;
|
||||
wxTopLevelWindows.DeleteObject(this);
|
||||
|
||||
m_modalShowing = FALSE;
|
||||
Show(FALSE);
|
||||
|
||||
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
if ( !IsModal() )
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
|
||||
// If this is the last top-level window, exit.
|
||||
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
|
||||
@@ -184,19 +145,20 @@ void wxDialog::DoSetClientSize(int width, int height)
|
||||
wxWindow::DoSetClientSize( width , height ) ;
|
||||
}
|
||||
|
||||
void wxDialog::GetPosition(int *x, int *y) const
|
||||
void wxDialog::DoGetPosition(int *x, int *y) const
|
||||
{
|
||||
DoGetPosition( x , y ) ;
|
||||
}
|
||||
|
||||
bool wxDialog::IsShown() const
|
||||
{
|
||||
return m_isShown;
|
||||
wxWindow::DoGetPosition( x , y ) ;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
m_isShown = show;
|
||||
|
||||
if (show)
|
||||
InitDialog();
|
||||
|
||||
bool modal = ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL) ;
|
||||
|
||||
#if WXGARBAGE_COLLECTION_ON /* MATTHEW: GC */
|
||||
if (!modal)
|
||||
{
|
||||
if (show)
|
||||
if ( !wxDialogBase::Show(show) )
|
||||
{
|
||||
if (!wxModelessWindows.Find(this))
|
||||
wxModelessWindows.Append(this);
|
||||
// nothing to do
|
||||
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 ;
|
||||
if (show)
|
||||
{
|
||||
if (m_modalShowing)
|
||||
{
|
||||
// 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 ;
|
||||
while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() )
|
||||
{
|
||||
}
|
||||
wxTheApp->MacDoOneEvent() ;
|
||||
}
|
||||
else // !modal
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
UMAShowWindow( m_macWindowData->m_macWindow ) ;
|
||||
UMASelectWindow( m_macWindowData->m_macWindow ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
UMAHideWindow( m_macWindowData->m_macWindow ) ;
|
||||
}
|
||||
}
|
||||
return TRUE ;
|
||||
|
||||
s_macIsInModalLoop = false ;
|
||||
|
||||
// TODO probably reenable the parent window if any
|
||||
|
||||
// and restore focus
|
||||
if ( winFocus )
|
||||
{
|
||||
winFocus->SetFocus();
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
int wxDialog::ShowModal()
|
||||
@@ -328,6 +245,8 @@ int wxDialog::ShowModal()
|
||||
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)
|
||||
{
|
||||
SetReturnCode(retCode);
|
||||
@@ -339,13 +258,7 @@ void wxDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
{
|
||||
if ( IsModal() )
|
||||
EndModal(wxID_OK);
|
||||
else
|
||||
{
|
||||
SetReturnCode(wxID_OK);
|
||||
this->Show(FALSE);
|
||||
}
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,20 +271,7 @@ void wxDialog::OnApply(wxCommandEvent& event)
|
||||
|
||||
void wxDialog::OnCancel(wxCommandEvent& event)
|
||||
{
|
||||
if ( IsModal() )
|
||||
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)
|
||||
@@ -407,30 +307,16 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event)
|
||||
// Destroy the window (delayed, if a managed window)
|
||||
bool wxDialog::Destroy()
|
||||
{
|
||||
if (!wxPendingDelete.Member(this))
|
||||
wxCHECK_MSG( !wxPendingDelete.Member(this), FALSE,
|
||||
_T("wxDialog destroyed twice") );
|
||||
|
||||
wxPendingDelete.Append(this);
|
||||
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)
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void wxDialog::Fit()
|
||||
{
|
||||
wxWindow::Fit();
|
||||
}
|
||||
|
||||
|
||||
@@ -147,6 +147,7 @@ bool wxDirData::Read(wxString *filename)
|
||||
if ( err != noErr )
|
||||
break ;
|
||||
|
||||
p2cstr( m_name ) ;
|
||||
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory
|
||||
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
|
||||
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 ;
|
||||
}
|
||||
if ( err != noErr )
|
||||
{
|
||||
return FALSE ;
|
||||
}
|
||||
FSSpec spec ;
|
||||
|
||||
FSMakeFSSpecCompat(m_CPB.hFileInfo.ioVRefNum, m_dirId, m_name,&spec) ;
|
||||
|
||||
*filename = wxMacFSSpec2UnixFilename( &spec ) ;
|
||||
*filename = (char*) m_name ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -20,19 +20,9 @@
|
||||
|
||||
#include "wx/cmndata.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_CLASS(wxDirDialog, wxDialog)
|
||||
|
||||
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
|
||||
};
|
||||
#endif
|
||||
|
||||
// the data we need to pass to our standard file hook routine
|
||||
// includes a pointer to the dialog, a pointer to the standard
|
||||
@@ -48,6 +38,21 @@ struct UserDataRec {
|
||||
typedef struct UserDataRec
|
||||
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)
|
||||
{
|
||||
GetIndString(theStr, kStrListID, stringNum);
|
||||
@@ -302,6 +307,7 @@ static pascal short SFGetFolderDialogHook(short item, DialogPtr theDlgPtr, Ptr d
|
||||
|
||||
return item;
|
||||
}
|
||||
#endif
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
@@ -329,6 +335,8 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
|
||||
|
||||
// display the dialog
|
||||
|
||||
#if !TARGET_CARBON
|
||||
|
||||
dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook);
|
||||
myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter);
|
||||
|
||||
@@ -350,6 +358,8 @@ void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileF
|
||||
|
||||
DisposeRoutineDescriptor(dlgHookUPP);
|
||||
DisposeRoutineDescriptor(myModalFilterUPP);
|
||||
#else
|
||||
#endif
|
||||
|
||||
// if cancel wasn't pressed and no fatal error occurred...
|
||||
|
||||
@@ -445,14 +455,18 @@ int wxDirDialog::ShowModal()
|
||||
strcpy((char *)path, m_path ) ;
|
||||
c2pstr((char *)path ) ;
|
||||
|
||||
FileFilterYDUPP invisiblesExcludedCustomFilterUPP;
|
||||
StandardFileReply reply ;
|
||||
FileFilterYDUPP invisiblesExcludedCustomFilterUPP = 0 ;
|
||||
#if !TARGET_CARBON
|
||||
invisiblesExcludedCustomFilterUPP =
|
||||
NewFileFilterYDProc(OnlyVisibleFoldersCustomFileFilter);
|
||||
#endif
|
||||
|
||||
StandardGetFolder( prompt , path , invisiblesExcludedCustomFilterUPP, &reply);
|
||||
|
||||
#if !TARGET_CARBON
|
||||
DisposeRoutineDescriptor(invisiblesExcludedCustomFilterUPP);
|
||||
#endif
|
||||
if ( reply.sfGood == false )
|
||||
{
|
||||
m_path = "" ;
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "wx/app.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -131,3 +133,4 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
||||
return wxDragError;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -19,7 +19,9 @@
|
||||
#include "wx/filedlg.h"
|
||||
#include "wx/intl.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_CLASS(wxFileDialog, wxDialog)
|
||||
#endif
|
||||
|
||||
// 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)
|
||||
{
|
||||
enum
|
||||
@@ -97,25 +120,6 @@ enum {
|
||||
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)
|
||||
{
|
||||
GetIndString(theStr, kStrListID, stringNum);
|
||||
@@ -185,6 +189,7 @@ static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRec
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
@@ -241,6 +246,8 @@ void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const
|
||||
}
|
||||
// display the dialog
|
||||
|
||||
#if !TARGET_CARBON
|
||||
|
||||
dlgHookUPP = NULL ;
|
||||
// dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook);
|
||||
myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter);
|
||||
@@ -263,7 +270,8 @@ void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const
|
||||
|
||||
DisposeRoutineDescriptor(dlgHookUPP);
|
||||
DisposeRoutineDescriptor(myModalFilterUPP);
|
||||
|
||||
#else
|
||||
#endif
|
||||
// if cancel wasn't pressed and no fatal error occurred...
|
||||
|
||||
if (theSFR->sfGood)
|
||||
@@ -454,8 +462,12 @@ int wxFileDialog::ShowModal()
|
||||
|
||||
strcpy((char *)filename, m_fileName) ;
|
||||
c2pstr((char *)filename ) ;
|
||||
#if !TARGET_CARBON
|
||||
|
||||
StandardPutFile( prompt , filename , &reply ) ;
|
||||
|
||||
#else
|
||||
#endif
|
||||
if ( reply.sfGood == false )
|
||||
{
|
||||
m_path = "" ;
|
||||
@@ -479,14 +491,17 @@ int wxFileDialog::ShowModal()
|
||||
strcpy((char *)path, m_path ) ;
|
||||
c2pstr((char *)path ) ;
|
||||
|
||||
FileFilterYDUPP crossPlatformFileFilterUPP;
|
||||
StandardFileReply reply ;
|
||||
FileFilterYDUPP crossPlatformFileFilterUPP = 0 ;
|
||||
#if !TARGET_CARBON
|
||||
crossPlatformFileFilterUPP =
|
||||
NewFileFilterYDProc(CrossPlatformFileFilter);
|
||||
#endif
|
||||
|
||||
ExtendedOpenFile( prompt , path , m_wildCard , crossPlatformFileFilterUPP, &reply);
|
||||
|
||||
DisposeRoutineDescriptor(crossPlatformFileFilterUPP);
|
||||
#if !TARGET_CARBON
|
||||
DisposeFileFilterYDUPP(crossPlatformFileFilterUPP);
|
||||
#endif
|
||||
if ( reply.sfGood == false )
|
||||
{
|
||||
m_path = "" ;
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
#include "wx/font.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -77,7 +79,7 @@ void wxFontRefData::MacFindFont()
|
||||
::GetFNum( "\pTimes" , &m_macFontNum) ;
|
||||
break ;
|
||||
case wxSWISS :
|
||||
::GetFNum( "\pHelvetica" , &m_macFontNum) ;
|
||||
::GetFNum( "\pGeneva" , &m_macFontNum) ;
|
||||
break ;
|
||||
case wxMODERN :
|
||||
::GetFNum( "\pMonaco" , &m_macFontNum) ;
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include "wx/mac/fontdlg.h"
|
||||
#include "wx/cmndata.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wxFontDialog
|
||||
|
||||
@@ -48,18 +48,12 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// convert to/from the string representation: format is
|
||||
// encodingid;facename[;charset]
|
||||
// facename[;charset]
|
||||
|
||||
bool wxNativeEncodingInfo::FromString(const wxString& s)
|
||||
{
|
||||
wxStringTokenizer tokenizer(s, _T(";"));
|
||||
|
||||
wxString encid = tokenizer.GetNextToken();
|
||||
long enc;
|
||||
if ( !encid.ToLong(&enc) )
|
||||
return FALSE;
|
||||
encoding = (wxFontEncoding)enc;
|
||||
|
||||
facename = tokenizer.GetNextToken();
|
||||
if ( !facename )
|
||||
return FALSE;
|
||||
@@ -85,10 +79,7 @@ bool wxNativeEncodingInfo::FromString(const wxString& s)
|
||||
|
||||
wxString wxNativeEncodingInfo::ToString() const
|
||||
{
|
||||
wxString s;
|
||||
|
||||
s << (long)encoding << _T(';') << facename;
|
||||
|
||||
wxString s(facename);
|
||||
if ( charset != 0 )
|
||||
{
|
||||
s << _T(';') << charset;
|
||||
@@ -159,8 +150,6 @@ bool wxGetNativeFontEncoding(wxFontEncoding encoding,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
info->encoding = encoding;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/frame.h"
|
||||
#include "wx/statusbr.h"
|
||||
#include "wx/mac/statusbr.h"
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/menuitem.h"
|
||||
#include "wx/menu.h"
|
||||
@@ -28,16 +28,18 @@
|
||||
extern wxList wxModelessWindows;
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
BEGIN_EVENT_TABLE(wxFrame, wxWindow)
|
||||
EVT_SIZE(wxFrame::OnSize)
|
||||
#if !USE_SHARED_LIBRARY
|
||||
BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
|
||||
// EVT_SIZE(wxFrame::OnSize)
|
||||
EVT_ACTIVATE(wxFrame::OnActivate)
|
||||
EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
|
||||
// EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
|
||||
EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
|
||||
EVT_IDLE(wxFrame::OnIdle)
|
||||
EVT_CLOSE(wxFrame::OnCloseWindow)
|
||||
// EVT_IDLE(wxFrame::OnIdle)
|
||||
// EVT_CLOSE(wxFrame::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
|
||||
#endif
|
||||
|
||||
#if wxUSE_NATIVE_STATUSBAR
|
||||
bool wxFrame::m_useNativeStatusBar = TRUE;
|
||||
@@ -45,17 +47,43 @@ bool wxFrame::m_useNativeStatusBar = TRUE;
|
||||
bool wxFrame::m_useNativeStatusBar = FALSE;
|
||||
#endif
|
||||
|
||||
wxFrame::wxFrame()
|
||||
{
|
||||
#if wxUSE_TOOLBAR
|
||||
m_frameToolBar = NULL ;
|
||||
#endif
|
||||
#define WX_MAC_STATUSBAR_HEIGHT 15
|
||||
// ----------------------------------------------------------------------------
|
||||
// creation/destruction
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// in order to be able to give size events on show
|
||||
m_frameMenuBar = NULL;
|
||||
m_frameStatusBar = NULL;
|
||||
m_iconized = FALSE;
|
||||
m_isShown = FALSE;
|
||||
void wxFrame::Init()
|
||||
{
|
||||
m_iconized = 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,
|
||||
@@ -66,13 +94,7 @@ bool wxFrame::Create(wxWindow *parent,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
if (!parent)
|
||||
wxTopLevelWindows.Append(this);
|
||||
|
||||
SetName(name);
|
||||
m_windowStyle = style;
|
||||
m_frameMenuBar = NULL;
|
||||
m_isShown = FALSE;
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
m_frameToolBar = NULL ;
|
||||
@@ -88,74 +110,24 @@ bool wxFrame::Create(wxWindow *parent,
|
||||
|
||||
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);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
wxFrame::~wxFrame()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
wxTopLevelWindows.DeleteObject(this);
|
||||
|
||||
if (m_frameStatusBar)
|
||||
delete m_frameStatusBar;
|
||||
if (m_frameMenuBar)
|
||||
delete m_frameMenuBar;
|
||||
DeleteAllBars();
|
||||
|
||||
/* 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
|
||||
void wxFrame::Maximize(bool maximize)
|
||||
{
|
||||
@@ -190,6 +172,11 @@ bool wxFrame::IsIconized() const
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxFrame::Iconize(bool iconize)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Is the frame maximized?
|
||||
bool wxFrame::IsMaximized(void) const
|
||||
{
|
||||
@@ -197,10 +184,14 @@ bool wxFrame::IsMaximized(void) const
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxFrame::Restore()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void wxFrame::SetIcon(const wxIcon& icon)
|
||||
{
|
||||
m_icon = icon;
|
||||
// TODO
|
||||
wxFrameBase::SetIcon(icon);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 17),
|
||||
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 = new wxStatusBar(this, id, style, name);
|
||||
|
||||
statusBar->SetFieldsCount(number);
|
||||
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()
|
||||
{
|
||||
if (m_frameStatusBar )
|
||||
@@ -274,7 +216,7 @@ void wxFrame::PositionStatusBar()
|
||||
|
||||
// Since we wish the status bar to be directly under the client area,
|
||||
// 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)
|
||||
{
|
||||
m_frameMenuBar = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
m_frameMenuBar = NULL;
|
||||
m_frameMenuBar = menuBar;
|
||||
// TODO : we move this into the app code
|
||||
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.
|
||||
void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
|
||||
@@ -337,217 +251,55 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& 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
|
||||
// subwindow found.
|
||||
void wxFrame::OnActivate(wxActivateEvent& event)
|
||||
{
|
||||
for(wxNode *node = GetChildren().First(); node; node = node->Next())
|
||||
{
|
||||
// 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)))
|
||||
if ( !event.GetActive() )
|
||||
{
|
||||
child->SetFocus();
|
||||
return;
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The default implementation for the close window event.
|
||||
void wxFrame::OnCloseWindow(wxCloseEvent& event)
|
||||
{
|
||||
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
|
||||
for ( wxWindowList::Node *node = GetChildren().GetFirst();
|
||||
node;
|
||||
node = node->GetNext() )
|
||||
{
|
||||
wxMenuBar *menuBar = GetMenuBar();
|
||||
if (menuBar)
|
||||
{
|
||||
wxString helpString(menuBar->GetHelpString(event.GetMenuId()));
|
||||
if (helpString != "")
|
||||
SetStatusText(helpString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// FIXME all this is totally bogus - we need to do the same as wxPanel,
|
||||
// but how to do it without duplicating the code?
|
||||
|
||||
wxMenuBar *wxFrame::GetMenuBar() const
|
||||
{
|
||||
return m_frameMenuBar;
|
||||
}
|
||||
// restore focus
|
||||
wxWindow *child = node->GetData();
|
||||
|
||||
|
||||
// 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 ( !child->IsTopLevel()
|
||||
#if wxUSE_TOOLBAR
|
||||
if (GetToolBar())
|
||||
{
|
||||
int w, h;
|
||||
GetToolBar()->GetSize(& w, & h);
|
||||
|
||||
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
|
||||
&& !wxDynamicCast(child, wxToolBar)
|
||||
#endif // wxUSE_TOOLBAR
|
||||
#if wxUSE_STATUSBAR
|
||||
&& !wxDynamicCast(child, wxStatusBar)
|
||||
#endif // wxUSE_STATUSBAR
|
||||
)
|
||||
{
|
||||
pt.x += w;
|
||||
}
|
||||
else
|
||||
{
|
||||
pt.y += h;
|
||||
child->SetFocus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return pt;
|
||||
}
|
||||
|
||||
void wxFrame::DoGetClientSize(int *x, int *y) const
|
||||
{
|
||||
wxWindow::DoGetClientSize( x , y ) ;
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
if ( GetStatusBar() )
|
||||
{
|
||||
int 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());
|
||||
*y -= pt.y;
|
||||
@@ -576,39 +328,20 @@ void wxFrame::DoSetClientSize(int clientwidth, int clientheight)
|
||||
#if wxUSE_TOOLBAR
|
||||
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
|
||||
{
|
||||
wxCHECK_MSG( m_frameToolBar == NULL, FALSE,
|
||||
"recreating toolbar in wxFrame" );
|
||||
|
||||
wxToolBar* toolBar = OnCreateToolBar(style, id, name);
|
||||
if (toolBar)
|
||||
if ( wxFrameBase::CreateToolBar(style, id, name) )
|
||||
{
|
||||
SetToolBar(toolBar);
|
||||
PositionToolBar();
|
||||
return toolBar;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name)
|
||||
{
|
||||
return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name);
|
||||
return m_frameToolBar;
|
||||
}
|
||||
|
||||
void wxFrame::PositionToolBar()
|
||||
{
|
||||
int cw, ch;
|
||||
|
||||
// TODO: we actually need to use the low-level client size, before
|
||||
// the toolbar/status bar were added.
|
||||
// So DEFINITELY replace the line below with something appropriate.
|
||||
|
||||
// GetClientSize(& cw, &ch);
|
||||
|
||||
cw = m_width ;
|
||||
ch = m_height ;
|
||||
cw = m_width ;
|
||||
ch = m_height ;
|
||||
|
||||
if ( GetStatusBar() )
|
||||
{
|
||||
@@ -627,12 +360,12 @@ void wxFrame::PositionToolBar()
|
||||
// Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
|
||||
// means, pretend we don't have toolbar/status bar, so we
|
||||
// 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
|
||||
{
|
||||
// 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include "wx/gauge.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
|
||||
#endif
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
|
||||
@@ -31,15 +33,13 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
m_rangeMax = range ;
|
||||
m_macHorizontalBorder = 2 ; // additional pixels around the real control
|
||||
m_macVerticalBorder = 2 ;
|
||||
|
||||
if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y)
|
||||
{
|
||||
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,
|
||||
kControlProgressBarProc , (long) this ) ;
|
||||
@@ -66,7 +66,7 @@ void wxGauge::SetRange(int r)
|
||||
void wxGauge::SetValue(int pos)
|
||||
{
|
||||
m_gaugePos = pos;
|
||||
::SetControlValue( m_macControl , m_gaugePos ) ;
|
||||
::SetControlValue( m_macControl , m_gaugePos ) ;
|
||||
}
|
||||
|
||||
int wxGauge::GetShadowWidth() const
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user