]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/utils.cpp
correcting system version compare
[wxWidgets.git] / src / mac / carbon / utils.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: utils.cpp
3 // Purpose: Various utilities
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 // Note: this is done in utilscmn.cpp now.
14 // #pragma implementation "utils.h"
15 #endif
16
17 #include "wx/setup.h"
18 #include "wx/utils.h"
19 #include "wx/app.h"
20 #include "wx/apptrait.h"
21
22 #if wxUSE_GUI
23 #include "wx/mac/uma.h"
24 #include "wx/font.h"
25 #else
26 #include "wx/intl.h"
27 #endif
28
29 #include <ctype.h>
30
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <stdarg.h>
35
36 #ifdef __DARWIN__
37 # include "MoreFilesX.h"
38 #else
39 # include "MoreFiles.h"
40 # include "MoreFilesExtras.h"
41 #endif
42
43 #ifndef __DARWIN__
44 #include <Threads.h>
45 #include <Sound.h>
46 #endif
47
48 #include <ATSUnicode.h>
49 #include <TextCommon.h>
50 #include <TextEncodingConverter.h>
51
52 #include "wx/mac/private.h" // includes mac headers
53
54 #if defined(__MWERKS__) && wxUSE_UNICODE
55 #include <wtime.h>
56 #endif
57
58 // ---------------------------------------------------------------------------
59 // code used in both base and GUI compilation
60 // ---------------------------------------------------------------------------
61
62 // our OS version is the same in non GUI and GUI cases
63 static int DoGetOSVersion(int *majorVsn, int *minorVsn)
64 {
65 long theSystem ;
66
67 // are there x-platform conventions ?
68
69 Gestalt(gestaltSystemVersion, &theSystem) ;
70 if (minorVsn != NULL) {
71 *minorVsn = (theSystem & 0xFF ) ;
72 }
73 if (majorVsn != NULL) {
74 *majorVsn = (theSystem >> 8 ) ;
75 }
76 #ifdef __DARWIN__
77 return wxMAC_DARWIN;
78 #else
79 return wxMAC;
80 #endif
81 }
82
83 #if wxUSE_BASE
84
85 #ifndef __DARWIN__
86 // defined in unix/utilsunx.cpp for Mac OS X
87
88 // get full hostname (with domain name if possible)
89 bool wxGetFullHostName(wxChar *buf, int maxSize)
90 {
91 return wxGetHostName(buf, maxSize);
92 }
93
94 // Get hostname only (without domain name)
95 bool wxGetHostName(wxChar *buf, int maxSize)
96 {
97 // Gets Chooser name of user by examining a System resource.
98
99 const short kComputerNameID = -16413;
100
101 short oldResFile = CurResFile() ;
102 UseResFile(0);
103 StringHandle chooserName = (StringHandle)::GetString(kComputerNameID);
104 UseResFile(oldResFile);
105
106 if (chooserName && *chooserName)
107 {
108 HLock( (Handle) chooserName ) ;
109 wxString name = wxMacMakeStringFromPascal( *chooserName ) ;
110 HUnlock( (Handle) chooserName ) ;
111 ReleaseResource( (Handle) chooserName ) ;
112 wxStrncpy( buf , name , maxSize - 1 ) ;
113 }
114 else
115 buf[0] = 0 ;
116
117 return TRUE;
118 }
119
120 // Get user ID e.g. jacs
121 bool wxGetUserId(wxChar *buf, int maxSize)
122 {
123 return wxGetUserName( buf , maxSize ) ;
124 }
125
126 const wxChar* wxGetHomeDir(wxString *pstr)
127 {
128 *pstr = wxMacFindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder ) ;
129 return pstr->c_str() ;
130 }
131
132 // Get user name e.g. Stefan Csomor
133 bool wxGetUserName(wxChar *buf, int maxSize)
134 {
135 // Gets Chooser name of user by examining a System resource.
136
137 const short kChooserNameID = -16096;
138
139 short oldResFile = CurResFile() ;
140 UseResFile(0);
141 StringHandle chooserName = (StringHandle)::GetString(kChooserNameID);
142 UseResFile(oldResFile);
143
144 if (chooserName && *chooserName)
145 {
146 HLock( (Handle) chooserName ) ;
147 wxString name = wxMacMakeStringFromPascal( *chooserName ) ;
148 HUnlock( (Handle) chooserName ) ;
149 ReleaseResource( (Handle) chooserName ) ;
150 wxStrncpy( buf , name , maxSize - 1 ) ;
151 }
152 else
153 buf[0] = 0 ;
154
155 return TRUE;
156 }
157
158 int wxKill(long pid, wxSignal sig , wxKillError *rc )
159 {
160 // TODO
161 return 0;
162 }
163
164 WXDLLEXPORT bool wxGetEnv(const wxString& var, wxString *value)
165 {
166 // TODO : under classic there is no environement support, under X yes
167 return false ;
168 }
169
170 // set the env var name to the given value, return TRUE on success
171 WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value)
172 {
173 // TODO : under classic there is no environement support, under X yes
174 return false ;
175 }
176
177 //
178 // Execute a program in an Interactive Shell
179 //
180 bool wxShell(const wxString& command)
181 {
182 // TODO
183 return FALSE;
184 }
185
186 // Shutdown or reboot the PC
187 bool wxShutdown(wxShutdownFlags wFlags)
188 {
189 // TODO
190 return FALSE;
191 }
192
193 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
194 long wxGetFreeMemory()
195 {
196 return FreeMem() ;
197 }
198
199 void wxUsleep(unsigned long milliseconds)
200 {
201 // TODO remove if we don't encounter any other problemsy
202 /*
203 clock_t start = clock() ;
204 do
205 {
206 YieldToAnyThread() ;
207 } while( clock() - start < milliseconds / 1000.0 * CLOCKS_PER_SEC ) ;
208 */
209 wxThread::Sleep( milliseconds ) ;
210 }
211
212 void wxSleep(int nSecs)
213 {
214 wxUsleep(1000*nSecs);
215 }
216
217 // Consume all events until no more left
218 void wxFlushEvents()
219 {
220 }
221
222 #endif // !__DARWIN__
223
224 // Emit a beeeeeep
225 void wxBell()
226 {
227 SysBeep(30);
228 }
229
230 wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo()
231 {
232 static wxToolkitInfo info;
233 info.os = DoGetOSVersion(&info.versionMajor, &info.versionMinor);
234 info.name = _T("wxBase");
235 return info;
236 }
237
238 #endif // wxUSE_BASE
239
240 #if wxUSE_GUI
241
242 wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
243 {
244 static wxToolkitInfo info;
245 info.os = DoGetOSVersion(&info.versionMajor, &info.versionMinor);
246 info.shortName = _T("mac");
247 info.name = _T("wxMac");
248 #ifdef __WXUNIVERSAL__
249 info.shortName << _T("univ");
250 info.name << _T("/wxUniversal");
251 #endif
252 return info;
253 }
254
255 // Reading and writing resources (eg WIN.INI, .Xdefaults)
256 #if wxUSE_RESOURCES
257 bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
258 {
259 // TODO
260 return FALSE;
261 }
262
263 bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
264 {
265 wxString buf;
266 buf.Printf(wxT("%.4f"), value);
267
268 return wxWriteResource(section, entry, buf, file);
269 }
270
271 bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file)
272 {
273 wxString buf;
274 buf.Printf(wxT("%ld"), value);
275
276 return wxWriteResource(section, entry, buf, file);
277 }
278
279 bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file)
280 {
281 wxString buf;
282 buf.Printf(wxT("%d"), value);
283
284 return wxWriteResource(section, entry, buf, file);
285 }
286
287 bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file)
288 {
289 // TODO
290 return FALSE;
291 }
292
293 bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
294 {
295 char *s = NULL;
296 bool succ = wxGetResource(section, entry, (char **)&s, file);
297 if (succ)
298 {
299 *value = (float)strtod(s, NULL);
300 delete[] s;
301 return TRUE;
302 }
303 else return FALSE;
304 }
305
306 bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
307 {
308 char *s = NULL;
309 bool succ = wxGetResource(section, entry, (char **)&s, file);
310 if (succ)
311 {
312 *value = strtol(s, NULL, 10);
313 delete[] s;
314 return TRUE;
315 }
316 else return FALSE;
317 }
318
319 bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
320 {
321 char *s = NULL;
322 bool succ = wxGetResource(section, entry, (char **)&s, file);
323 if (succ)
324 {
325 *value = (int)strtol(s, NULL, 10);
326 delete[] s;
327 return TRUE;
328 }
329 else return FALSE;
330 }
331 #endif // wxUSE_RESOURCES
332
333 int gs_wxBusyCursorCount = 0;
334 extern wxCursor gMacCurrentCursor ;
335 wxCursor gMacStoredActiveCursor ;
336
337 // Set the cursor to the busy cursor for all windows
338 void wxBeginBusyCursor(wxCursor *cursor)
339 {
340 if (gs_wxBusyCursorCount++ == 0)
341 {
342 gMacStoredActiveCursor = gMacCurrentCursor ;
343 cursor->MacInstall() ;
344 }
345 //else: nothing to do, already set
346 }
347
348 // Restore cursor to normal
349 void wxEndBusyCursor()
350 {
351 wxCHECK_RET( gs_wxBusyCursorCount > 0,
352 wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") );
353
354 if (--gs_wxBusyCursorCount == 0)
355 {
356 gMacStoredActiveCursor.MacInstall() ;
357 gMacStoredActiveCursor = wxNullCursor ;
358 }
359 }
360
361 // TRUE if we're between the above two calls
362 bool wxIsBusy()
363 {
364 return (gs_wxBusyCursorCount > 0);
365 }
366
367 #endif // wxUSE_GUI
368
369 #if wxUSE_BASE
370
371 wxString wxMacFindFolder( short vol,
372 OSType folderType,
373 Boolean createFolder)
374 {
375 short vRefNum ;
376 long dirID ;
377 wxString strDir ;
378
379 if ( FindFolder( vol, folderType, createFolder, &vRefNum, &dirID) == noErr)
380 {
381 FSSpec file ;
382 if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
383 {
384 strDir = wxMacFSSpec2MacFilename( &file ) + wxFILE_SEP_PATH ;
385 }
386 }
387 return strDir ;
388 }
389
390 #endif // wxUSE_BASE
391
392 #if wxUSE_GUI
393
394 // Check whether this window wants to process messages, e.g. Stop button
395 // in long calculations.
396 bool wxCheckForInterrupt(wxWindow *wnd)
397 {
398 // TODO
399 return FALSE;
400 }
401
402 void wxGetMousePosition( int* x, int* y )
403 {
404 Point pt ;
405
406 GetMouse( &pt ) ;
407 LocalToGlobal( &pt ) ;
408 *x = pt.h ;
409 *y = pt.v ;
410 };
411
412 // Return TRUE if we have a colour display
413 bool wxColourDisplay()
414 {
415 return TRUE;
416 }
417
418 // Returns depth of screen
419 int wxDisplayDepth()
420 {
421 Rect globRect ;
422 SetRect(&globRect, -32760, -32760, 32760, 32760);
423 GDHandle theMaxDevice;
424
425 int theDepth = 8;
426 theMaxDevice = GetMaxDevice(&globRect);
427 if (theMaxDevice != nil)
428 theDepth = (**(**theMaxDevice).gdPMap).pixelSize;
429
430 return theDepth ;
431 }
432
433 // Get size of display
434 void wxDisplaySize(int *width, int *height)
435 {
436 BitMap screenBits;
437 GetQDGlobalsScreenBits( &screenBits );
438
439 if (width != NULL) {
440 *width = screenBits.bounds.right - screenBits.bounds.left ;
441 }
442 if (height != NULL) {
443 *height = screenBits.bounds.bottom - screenBits.bounds.top ;
444 }
445 }
446
447 void wxDisplaySizeMM(int *width, int *height)
448 {
449 wxDisplaySize(width, height);
450 // on mac 72 is fixed (at least now ;-)
451 float cvPt2Mm = 25.4 / 72;
452
453 if (width != NULL) {
454 *width = int( *width * cvPt2Mm );
455 }
456 if (height != NULL) {
457 *height = int( *height * cvPt2Mm );
458 }
459 }
460
461 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
462 {
463 Rect r ;
464 GetAvailableWindowPositioningBounds( GetMainDevice() , &r ) ;
465 if ( x )
466 *x = r.left ;
467 if ( y )
468 *y = r.top ;
469 if ( width )
470 *width = r.right - r.left ;
471 if ( height )
472 *height = r.bottom - r.top ;
473 }
474
475 wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
476 {
477 return wxGenericFindWindowAtPoint(pt);
478 }
479
480 #endif // wxUSE_GUI
481
482 #if wxUSE_BASE
483
484 wxString wxGetOsDescription()
485 {
486 #ifdef WXWIN_OS_DESCRIPTION
487 // use configure generated description if available
488 return wxString(wxT("MacOS (")) + wxT(WXWIN_OS_DESCRIPTION) + wxString(wxT(")"));
489 #else
490 return wxT("MacOS") ; //TODO:define further
491 #endif
492 }
493
494 #ifndef __DARWIN__
495 wxChar *wxGetUserHome (const wxString& user)
496 {
497 // TODO
498 return NULL;
499 }
500
501 bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
502 {
503 if ( path.empty() )
504 return FALSE;
505
506 wxString p = path ;
507 if (p[0u] == ':' ) {
508 p = wxGetCwd() + p ;
509 }
510
511 int pos = p.Find(':') ;
512 if ( pos != wxNOT_FOUND ) {
513 p = p.Mid(1,pos) ;
514 }
515
516 p = p + wxT(":") ;
517
518 Str255 volumeName ;
519 XVolumeParam pb ;
520
521 wxMacStringToPascal( p , volumeName ) ;
522 OSErr err = XGetVolumeInfoNoName( volumeName , 0 , &pb ) ;
523 if ( err == noErr ) {
524 if ( pTotal ) {
525 (*pTotal) = wxLongLong( pb.ioVTotalBytes ) ;
526 }
527 if ( pFree ) {
528 (*pFree) = wxLongLong( pb.ioVFreeBytes ) ;
529 }
530 }
531
532 return err == noErr ;
533 }
534 #endif // !__DARWIN__
535
536 //---------------------------------------------------------------------------
537 // wxMac Specific utility functions
538 //---------------------------------------------------------------------------
539
540 void wxMacStringToPascal( const wxString&from , StringPtr to )
541 {
542 wxCharBuffer buf = from.mb_str( wxConvLocal ) ;
543 int len = strlen(buf) ;
544
545 if ( len > 255 )
546 len = 255 ;
547 to[0] = len ;
548 memcpy( (char*) &to[1] , buf , len ) ;
549 }
550
551 wxString wxMacMakeStringFromPascal( ConstStringPtr from )
552 {
553 return wxString( (char*) &from[1] , wxConvLocal , from[0] ) ;
554 }
555
556
557 wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding)
558 {
559 TextEncodingBase enc = 0 ;
560 if ( encoding == wxFONTENCODING_DEFAULT )
561 {
562 #if wxUSE_GUI
563 encoding = wxFont::GetDefaultEncoding() ;
564 #else
565 encoding = wxLocale::GetSystemEncoding() ;
566 #endif
567 }
568
569 switch( encoding)
570 {
571 case wxFONTENCODING_ISO8859_1 :
572 enc = kTextEncodingISOLatin1 ;
573 break ;
574 case wxFONTENCODING_ISO8859_2 :
575 enc = kTextEncodingISOLatin2;
576 break ;
577 case wxFONTENCODING_ISO8859_3 :
578 enc = kTextEncodingISOLatin3 ;
579 break ;
580 case wxFONTENCODING_ISO8859_4 :
581 enc = kTextEncodingISOLatin4;
582 break ;
583 case wxFONTENCODING_ISO8859_5 :
584 enc = kTextEncodingISOLatinCyrillic;
585 break ;
586 case wxFONTENCODING_ISO8859_6 :
587 enc = kTextEncodingISOLatinArabic;
588 break ;
589 case wxFONTENCODING_ISO8859_7 :
590 enc = kTextEncodingISOLatinGreek;
591 break ;
592 case wxFONTENCODING_ISO8859_8 :
593 enc = kTextEncodingISOLatinHebrew;
594 break ;
595 case wxFONTENCODING_ISO8859_9 :
596 enc = kTextEncodingISOLatin5;
597 break ;
598 case wxFONTENCODING_ISO8859_10 :
599 enc = kTextEncodingISOLatin6;
600 break ;
601 case wxFONTENCODING_ISO8859_13 :
602 enc = kTextEncodingISOLatin7;
603 break ;
604 case wxFONTENCODING_ISO8859_14 :
605 enc = kTextEncodingISOLatin8;
606 break ;
607 case wxFONTENCODING_ISO8859_15 :
608 enc = kTextEncodingISOLatin9;
609 break ;
610
611 case wxFONTENCODING_KOI8 :
612 enc = kTextEncodingKOI8_R;
613 break ;
614 case wxFONTENCODING_ALTERNATIVE : // MS-DOS CP866
615 enc = kTextEncodingDOSRussian;
616 break ;
617 /*
618 case wxFONTENCODING_BULGARIAN :
619 enc = ;
620 break ;
621 */
622 case wxFONTENCODING_CP437 :
623 enc =kTextEncodingDOSLatinUS ;
624 break ;
625 case wxFONTENCODING_CP850 :
626 enc = kTextEncodingDOSLatin1;
627 break ;
628 case wxFONTENCODING_CP852 :
629 enc = kTextEncodingDOSLatin2;
630 break ;
631 case wxFONTENCODING_CP855 :
632 enc = kTextEncodingDOSCyrillic;
633 break ;
634 case wxFONTENCODING_CP866 :
635 enc =kTextEncodingDOSRussian ;
636 break ;
637 case wxFONTENCODING_CP874 :
638 enc = kTextEncodingDOSThai;
639 break ;
640 case wxFONTENCODING_CP932 :
641 enc = kTextEncodingDOSJapanese;
642 break ;
643 case wxFONTENCODING_CP936 :
644 enc =kTextEncodingDOSChineseSimplif ;
645 break ;
646 case wxFONTENCODING_CP949 :
647 enc = kTextEncodingDOSKorean;
648 break ;
649 case wxFONTENCODING_CP950 :
650 enc = kTextEncodingDOSChineseTrad;
651 break ;
652
653 case wxFONTENCODING_CP1250 :
654 enc = kTextEncodingWindowsLatin2;
655 break ;
656 case wxFONTENCODING_CP1251 :
657 enc =kTextEncodingWindowsCyrillic ;
658 break ;
659 case wxFONTENCODING_CP1252 :
660 enc =kTextEncodingWindowsLatin1 ;
661 break ;
662 case wxFONTENCODING_CP1253 :
663 enc = kTextEncodingWindowsGreek;
664 break ;
665 case wxFONTENCODING_CP1254 :
666 enc = kTextEncodingWindowsLatin5;
667 break ;
668 case wxFONTENCODING_CP1255 :
669 enc =kTextEncodingWindowsHebrew ;
670 break ;
671 case wxFONTENCODING_CP1256 :
672 enc =kTextEncodingWindowsArabic ;
673 break ;
674 case wxFONTENCODING_CP1257 :
675 enc = kTextEncodingWindowsBalticRim;
676 break ;
677
678 case wxFONTENCODING_UTF7 :
679 enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicodeUTF7Format) ;
680 break ;
681 case wxFONTENCODING_UTF8 :
682 enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicodeUTF8Format) ;
683 break ;
684 case wxFONTENCODING_EUC_JP :
685 enc = kTextEncodingEUC_JP;
686 break ;
687 case wxFONTENCODING_UTF16BE :
688 enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode16BitFormat) ;
689 break ;
690 case wxFONTENCODING_UTF16LE :
691 enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode16BitFormat) ;
692 break ;
693 case wxFONTENCODING_UTF32BE :
694 enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode32BitFormat) ;
695 break ;
696 case wxFONTENCODING_UTF32LE :
697 enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode32BitFormat) ;
698 break ;
699
700 case wxFONTENCODING_MACROMAN :
701 enc = kTextEncodingMacRoman ;
702 break ;
703 case wxFONTENCODING_MACJAPANESE :
704 enc = kTextEncodingMacJapanese ;
705 break ;
706 case wxFONTENCODING_MACCHINESETRAD :
707 enc = kTextEncodingMacChineseTrad ;
708 break ;
709 case wxFONTENCODING_MACKOREAN :
710 enc = kTextEncodingMacKorean ;
711 break ;
712 case wxFONTENCODING_MACARABIC :
713 enc = kTextEncodingMacArabic ;
714 break ;
715 case wxFONTENCODING_MACHEBREW :
716 enc = kTextEncodingMacHebrew ;
717 break ;
718 case wxFONTENCODING_MACGREEK :
719 enc = kTextEncodingMacGreek ;
720 break ;
721 case wxFONTENCODING_MACCYRILLIC :
722 enc = kTextEncodingMacCyrillic ;
723 break ;
724 case wxFONTENCODING_MACDEVANAGARI :
725 enc = kTextEncodingMacDevanagari ;
726 break ;
727 case wxFONTENCODING_MACGURMUKHI :
728 enc = kTextEncodingMacGurmukhi ;
729 break ;
730 case wxFONTENCODING_MACGUJARATI :
731 enc = kTextEncodingMacGujarati ;
732 break ;
733 case wxFONTENCODING_MACORIYA :
734 enc = kTextEncodingMacOriya ;
735 break ;
736 case wxFONTENCODING_MACBENGALI :
737 enc = kTextEncodingMacBengali ;
738 break ;
739 case wxFONTENCODING_MACTAMIL :
740 enc = kTextEncodingMacTamil ;
741 break ;
742 case wxFONTENCODING_MACTELUGU :
743 enc = kTextEncodingMacTelugu ;
744 break ;
745 case wxFONTENCODING_MACKANNADA :
746 enc = kTextEncodingMacKannada ;
747 break ;
748 case wxFONTENCODING_MACMALAJALAM :
749 enc = kTextEncodingMacMalayalam ;
750 break ;
751 case wxFONTENCODING_MACSINHALESE :
752 enc = kTextEncodingMacSinhalese ;
753 break ;
754 case wxFONTENCODING_MACBURMESE :
755 enc = kTextEncodingMacBurmese ;
756 break ;
757 case wxFONTENCODING_MACKHMER :
758 enc = kTextEncodingMacKhmer ;
759 break ;
760 case wxFONTENCODING_MACTHAI :
761 enc = kTextEncodingMacThai ;
762 break ;
763 case wxFONTENCODING_MACLAOTIAN :
764 enc = kTextEncodingMacLaotian ;
765 break ;
766 case wxFONTENCODING_MACGEORGIAN :
767 enc = kTextEncodingMacGeorgian ;
768 break ;
769 case wxFONTENCODING_MACARMENIAN :
770 enc = kTextEncodingMacArmenian ;
771 break ;
772 case wxFONTENCODING_MACCHINESESIMP :
773 enc = kTextEncodingMacChineseSimp ;
774 break ;
775 case wxFONTENCODING_MACTIBETAN :
776 enc = kTextEncodingMacTibetan ;
777 break ;
778 case wxFONTENCODING_MACMONGOLIAN :
779 enc = kTextEncodingMacMongolian ;
780 break ;
781 case wxFONTENCODING_MACETHIOPIC :
782 enc = kTextEncodingMacEthiopic ;
783 break ;
784 case wxFONTENCODING_MACCENTRALEUR :
785 enc = kTextEncodingMacCentralEurRoman ;
786 break ;
787 case wxFONTENCODING_MACVIATNAMESE :
788 enc = kTextEncodingMacVietnamese ;
789 break ;
790 case wxFONTENCODING_MACARABICEXT :
791 enc = kTextEncodingMacExtArabic ;
792 break ;
793 case wxFONTENCODING_MACSYMBOL :
794 enc = kTextEncodingMacSymbol ;
795 break ;
796 case wxFONTENCODING_MACDINGBATS :
797 enc = kTextEncodingMacDingbats ;
798 break ;
799 case wxFONTENCODING_MACTURKISH :
800 enc = kTextEncodingMacTurkish ;
801 break ;
802 case wxFONTENCODING_MACCROATIAN :
803 enc = kTextEncodingMacCroatian ;
804 break ;
805 case wxFONTENCODING_MACICELANDIC :
806 enc = kTextEncodingMacIcelandic ;
807 break ;
808 case wxFONTENCODING_MACROMANIAN :
809 enc = kTextEncodingMacRomanian ;
810 break ;
811 case wxFONTENCODING_MACCELTIC :
812 enc = kTextEncodingMacCeltic ;
813 break ;
814 case wxFONTENCODING_MACGAELIC :
815 enc = kTextEncodingMacGaelic ;
816 break ;
817 case wxFONTENCODING_MACKEYBOARD :
818 enc = kTextEncodingMacKeyboardGlyphs ;
819 break ;
820 default :
821 // to make gcc happy
822 break ;
823 } ;
824 return enc ;
825 }
826
827 wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding)
828 {
829 wxFontEncoding enc = wxFONTENCODING_DEFAULT ;
830
831 switch( encoding)
832 {
833 case kTextEncodingISOLatin1 :
834 enc = wxFONTENCODING_ISO8859_1 ;
835 break ;
836 case kTextEncodingISOLatin2 :
837 enc = wxFONTENCODING_ISO8859_2;
838 break ;
839 case kTextEncodingISOLatin3 :
840 enc = wxFONTENCODING_ISO8859_3 ;
841 break ;
842 case kTextEncodingISOLatin4 :
843 enc = wxFONTENCODING_ISO8859_4;
844 break ;
845 case kTextEncodingISOLatinCyrillic :
846 enc = wxFONTENCODING_ISO8859_5;
847 break ;
848 case kTextEncodingISOLatinArabic :
849 enc = wxFONTENCODING_ISO8859_6;
850 break ;
851 case kTextEncodingISOLatinGreek :
852 enc = wxFONTENCODING_ISO8859_7;
853 break ;
854 case kTextEncodingISOLatinHebrew :
855 enc = wxFONTENCODING_ISO8859_8;
856 break ;
857 case kTextEncodingISOLatin5 :
858 enc = wxFONTENCODING_ISO8859_9;
859 break ;
860 case kTextEncodingISOLatin6 :
861 enc = wxFONTENCODING_ISO8859_10;
862 break ;
863 case kTextEncodingISOLatin7 :
864 enc = wxFONTENCODING_ISO8859_13;
865 break ;
866 case kTextEncodingISOLatin8 :
867 enc = wxFONTENCODING_ISO8859_14;
868 break ;
869 case kTextEncodingISOLatin9 :
870 enc =wxFONTENCODING_ISO8859_15 ;
871 break ;
872
873 case kTextEncodingKOI8_R :
874 enc = wxFONTENCODING_KOI8;
875 break ;
876 /*
877 case :
878 enc = wxFONTENCODING_BULGARIAN;
879 break ;
880 */
881 case kTextEncodingDOSLatinUS :
882 enc = wxFONTENCODING_CP437;
883 break ;
884 case kTextEncodingDOSLatin1 :
885 enc = wxFONTENCODING_CP850;
886 break ;
887 case kTextEncodingDOSLatin2 :
888 enc =wxFONTENCODING_CP852 ;
889 break ;
890 case kTextEncodingDOSCyrillic :
891 enc = wxFONTENCODING_CP855;
892 break ;
893 case kTextEncodingDOSRussian :
894 enc = wxFONTENCODING_CP866;
895 break ;
896 case kTextEncodingDOSThai :
897 enc =wxFONTENCODING_CP874 ;
898 break ;
899 case kTextEncodingDOSJapanese :
900 enc = wxFONTENCODING_CP932;
901 break ;
902 case kTextEncodingDOSChineseSimplif :
903 enc = wxFONTENCODING_CP936;
904 break ;
905 case kTextEncodingDOSKorean :
906 enc = wxFONTENCODING_CP949;
907 break ;
908 case kTextEncodingDOSChineseTrad :
909 enc = wxFONTENCODING_CP950;
910 break ;
911
912 case kTextEncodingWindowsLatin2 :
913 enc = wxFONTENCODING_CP1250;
914 break ;
915 case kTextEncodingWindowsCyrillic :
916 enc = wxFONTENCODING_CP1251;
917 break ;
918 case kTextEncodingWindowsLatin1 :
919 enc = wxFONTENCODING_CP1252;
920 break ;
921 case kTextEncodingWindowsGreek :
922 enc = wxFONTENCODING_CP1253;
923 break ;
924 case kTextEncodingWindowsLatin5 :
925 enc = wxFONTENCODING_CP1254;
926 break ;
927 case kTextEncodingWindowsHebrew :
928 enc = wxFONTENCODING_CP1255;
929 break ;
930 case kTextEncodingWindowsArabic :
931 enc = wxFONTENCODING_CP1256;
932 break ;
933 case kTextEncodingWindowsBalticRim :
934 enc =wxFONTENCODING_CP1257 ;
935 break ;
936 case kTextEncodingEUC_JP :
937 enc = wxFONTENCODING_EUC_JP;
938 break ;
939 /*
940 case wxFONTENCODING_UTF7 :
941 enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicodeUTF7Format) ;
942 break ;
943 case wxFONTENCODING_UTF8 :
944 enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicodeUTF8Format) ;
945 break ;
946 case wxFONTENCODING_UTF16BE :
947 enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode16BitFormat) ;
948 break ;
949 case wxFONTENCODING_UTF16LE :
950 enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode16BitFormat) ;
951 break ;
952 case wxFONTENCODING_UTF32BE :
953 enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode32BitFormat) ;
954 break ;
955 case wxFONTENCODING_UTF32LE :
956 enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode32BitFormat) ;
957 break ;
958 */
959 case kTextEncodingMacRoman :
960 enc = wxFONTENCODING_MACROMAN ;
961 break ;
962 case kTextEncodingMacJapanese :
963 enc = wxFONTENCODING_MACJAPANESE ;
964 break ;
965 case kTextEncodingMacChineseTrad :
966 enc = wxFONTENCODING_MACCHINESETRAD ;
967 break ;
968 case kTextEncodingMacKorean :
969 enc = wxFONTENCODING_MACKOREAN ;
970 break ;
971 case kTextEncodingMacArabic :
972 enc =wxFONTENCODING_MACARABIC ;
973 break ;
974 case kTextEncodingMacHebrew :
975 enc = wxFONTENCODING_MACHEBREW ;
976 break ;
977 case kTextEncodingMacGreek :
978 enc = wxFONTENCODING_MACGREEK ;
979 break ;
980 case kTextEncodingMacCyrillic :
981 enc = wxFONTENCODING_MACCYRILLIC ;
982 break ;
983 case kTextEncodingMacDevanagari :
984 enc = wxFONTENCODING_MACDEVANAGARI ;
985 break ;
986 case kTextEncodingMacGurmukhi :
987 enc = wxFONTENCODING_MACGURMUKHI ;
988 break ;
989 case kTextEncodingMacGujarati :
990 enc = wxFONTENCODING_MACGUJARATI ;
991 break ;
992 case kTextEncodingMacOriya :
993 enc =wxFONTENCODING_MACORIYA ;
994 break ;
995 case kTextEncodingMacBengali :
996 enc =wxFONTENCODING_MACBENGALI ;
997 break ;
998 case kTextEncodingMacTamil :
999 enc = wxFONTENCODING_MACTAMIL ;
1000 break ;
1001 case kTextEncodingMacTelugu :
1002 enc = wxFONTENCODING_MACTELUGU ;
1003 break ;
1004 case kTextEncodingMacKannada :
1005 enc = wxFONTENCODING_MACKANNADA ;
1006 break ;
1007 case kTextEncodingMacMalayalam :
1008 enc = wxFONTENCODING_MACMALAJALAM ;
1009 break ;
1010 case kTextEncodingMacSinhalese :
1011 enc = wxFONTENCODING_MACSINHALESE ;
1012 break ;
1013 case kTextEncodingMacBurmese :
1014 enc = wxFONTENCODING_MACBURMESE ;
1015 break ;
1016 case kTextEncodingMacKhmer :
1017 enc = wxFONTENCODING_MACKHMER ;
1018 break ;
1019 case kTextEncodingMacThai :
1020 enc = wxFONTENCODING_MACTHAI ;
1021 break ;
1022 case kTextEncodingMacLaotian :
1023 enc = wxFONTENCODING_MACLAOTIAN ;
1024 break ;
1025 case kTextEncodingMacGeorgian :
1026 enc = wxFONTENCODING_MACGEORGIAN ;
1027 break ;
1028 case kTextEncodingMacArmenian :
1029 enc = wxFONTENCODING_MACARMENIAN ;
1030 break ;
1031 case kTextEncodingMacChineseSimp :
1032 enc = wxFONTENCODING_MACCHINESESIMP ;
1033 break ;
1034 case kTextEncodingMacTibetan :
1035 enc = wxFONTENCODING_MACTIBETAN ;
1036 break ;
1037 case kTextEncodingMacMongolian :
1038 enc = wxFONTENCODING_MACMONGOLIAN ;
1039 break ;
1040 case kTextEncodingMacEthiopic :
1041 enc = wxFONTENCODING_MACETHIOPIC ;
1042 break ;
1043 case kTextEncodingMacCentralEurRoman:
1044 enc = wxFONTENCODING_MACCENTRALEUR ;
1045 break ;
1046 case kTextEncodingMacVietnamese:
1047 enc = wxFONTENCODING_MACVIATNAMESE ;
1048 break ;
1049 case kTextEncodingMacExtArabic :
1050 enc = wxFONTENCODING_MACARABICEXT ;
1051 break ;
1052 case kTextEncodingMacSymbol :
1053 enc = wxFONTENCODING_MACSYMBOL ;
1054 break ;
1055 case kTextEncodingMacDingbats :
1056 enc = wxFONTENCODING_MACDINGBATS ;
1057 break ;
1058 case kTextEncodingMacTurkish :
1059 enc = wxFONTENCODING_MACTURKISH ;
1060 break ;
1061 case kTextEncodingMacCroatian :
1062 enc = wxFONTENCODING_MACCROATIAN ;
1063 break ;
1064 case kTextEncodingMacIcelandic :
1065 enc = wxFONTENCODING_MACICELANDIC ;
1066 break ;
1067 case kTextEncodingMacRomanian :
1068 enc = wxFONTENCODING_MACROMANIAN ;
1069 break ;
1070 case kTextEncodingMacCeltic :
1071 enc = wxFONTENCODING_MACCELTIC ;
1072 break ;
1073 case kTextEncodingMacGaelic :
1074 enc = wxFONTENCODING_MACGAELIC ;
1075 break ;
1076 case kTextEncodingMacKeyboardGlyphs :
1077 enc = wxFONTENCODING_MACKEYBOARD ;
1078 break ;
1079 } ;
1080 return enc ;
1081 }
1082
1083 #endif // wxUSE_BASE
1084
1085 #if wxUSE_GUI
1086
1087
1088 //
1089 // CFStringRefs (Carbon only)
1090 //
1091
1092 #if TARGET_CARBON
1093
1094 // converts this string into a carbon foundation string with optional pc 2 mac encoding
1095 void wxMacCFStringHolder::Assign( const wxString &st , wxFontEncoding encoding )
1096 {
1097 Release() ;
1098
1099 wxString str = st ;
1100 wxMacConvertNewlines13To10( &str ) ;
1101 #if wxUSE_UNICODE
1102 #if SIZEOF_WCHAR_T == 2
1103 m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault,
1104 (UniChar*)str.wc_str() , str.Len() );
1105 #else
1106 wxMBConvUTF16BE converter ;
1107 size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
1108 UniChar *unibuf = new UniChar[ unicharlen / sizeof(UniChar) + 1 ] ;
1109 converter.WC2MB( (char*)unibuf , str.wc_str() , unicharlen ) ;
1110 m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault ,
1111 unibuf , unicharlen / sizeof(UniChar) ) ;
1112 delete[] unibuf ;
1113 #endif
1114 #else // not wxUSE_UNICODE
1115 m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() ,
1116 wxMacGetSystemEncFromFontEnc( encoding ) ) ;
1117 #endif
1118 m_release = true ;
1119 }
1120
1121 wxString wxMacCFStringHolder::AsString(wxFontEncoding encoding)
1122 {
1123 Size cflen = CFStringGetLength( m_cfs ) ;
1124 size_t noChars ;
1125 wxChar* buf = NULL ;
1126
1127 #if wxUSE_UNICODE
1128 #if SIZEOF_WCHAR_T == 2
1129 buf = new wxChar[ cflen + 1 ] ;
1130 CFStringGetCharacters( m_cfs , CFRangeMake( 0 , cflen ) , (UniChar*) buf ) ;
1131 noChars = cflen ;
1132 #else
1133 UniChar* unibuf = new UniChar[ cflen + 1 ] ;
1134 CFStringGetCharacters( m_cfs , CFRangeMake( 0 , cflen ) , (UniChar*) unibuf ) ;
1135 unibuf[cflen] = 0 ;
1136 wxMBConvUTF16BE converter ;
1137 noChars = converter.MB2WC( NULL , (const char*)unibuf , 0 ) ;
1138 buf = new wxChar[ noChars + 1 ] ;
1139 converter.MB2WC( buf , (const char*)unibuf , noChars ) ;
1140 delete[] unibuf ;
1141 #endif
1142 #else
1143 CFIndex cStrLen ;
1144 CFStringGetBytes( m_cfs , CFRangeMake(0, cflen) , wxMacGetSystemEncFromFontEnc( encoding ) ,
1145 '?' , false , NULL , 0 , &cStrLen ) ;
1146 buf = new wxChar[ cStrLen + 1 ] ;
1147 CFStringGetBytes( m_cfs , CFRangeMake(0, cflen) , wxMacGetSystemEncFromFontEnc( encoding ) ,
1148 '?' , false , (unsigned char*) buf , cStrLen , &cStrLen) ;
1149 noChars = cStrLen ;
1150 #endif
1151
1152 buf[noChars] = 0 ;
1153 wxMacConvertNewlines10To13( buf ) ;
1154 wxString result(buf) ;
1155 delete[] buf ;
1156 return result ;
1157 }
1158
1159 #endif //TARGET_CARBON
1160
1161 void wxMacConvertNewlines13To10( char * data )
1162 {
1163 char * buf = data ;
1164 while( (buf=strchr(buf,0x0d)) != NULL )
1165 {
1166 *buf = 0x0a ;
1167 buf++ ;
1168 }
1169 }
1170
1171 void wxMacConvertNewlines10To13( char * data )
1172 {
1173 char * buf = data ;
1174 while( (buf=strchr(buf,0x0a)) != NULL )
1175 {
1176 *buf = 0x0d ;
1177 buf++ ;
1178 }
1179 }
1180
1181 void wxMacConvertNewlines13To10( wxString * data )
1182 {
1183 size_t len = data->Length() ;
1184
1185 if ( len == 0 || wxStrchr(data->c_str(),0x0d)==NULL)
1186 return ;
1187
1188 wxString temp(*data) ;
1189 wxStringBuffer buf(*data,len ) ;
1190 memcpy( buf , temp.c_str() , (len+1)*sizeof(wxChar) ) ;
1191
1192 wxMacConvertNewlines13To10( buf ) ;
1193 }
1194
1195 void wxMacConvertNewlines10To13( wxString * data )
1196 {
1197 size_t len = data->Length() ;
1198
1199 if ( data->Length() == 0 || wxStrchr(data->c_str(),0x0a)==NULL)
1200 return ;
1201
1202 wxString temp(*data) ;
1203 wxStringBuffer buf(*data,len ) ;
1204 memcpy( buf , temp.c_str() , (len+1)*sizeof(wxChar) ) ;
1205 wxMacConvertNewlines10To13( buf ) ;
1206 }
1207
1208
1209 #if wxUSE_UNICODE
1210 void wxMacConvertNewlines13To10( wxChar * data )
1211 {
1212 wxChar * buf = data ;
1213 while( (buf=wxStrchr(buf,0x0d)) != NULL )
1214 {
1215 *buf = 0x0a ;
1216 buf++ ;
1217 }
1218 }
1219
1220 void wxMacConvertNewlines10To13( wxChar * data )
1221 {
1222 wxChar * buf = data ;
1223 while( (buf=wxStrchr(buf,0x0a)) != NULL )
1224 {
1225 *buf = 0x0d ;
1226 buf++ ;
1227 }
1228 }
1229 #endif
1230
1231 // ----------------------------------------------------------------------------
1232 // Common Event Support
1233 // ----------------------------------------------------------------------------
1234
1235 #endif // wxUSE_GUI
1236
1237 #if wxUSE_BASE
1238
1239 extern ProcessSerialNumber gAppProcess ;
1240
1241 void wxMacWakeUp()
1242 {
1243 ProcessSerialNumber psn ;
1244 Boolean isSame ;
1245 psn.highLongOfPSN = 0 ;
1246 psn.lowLongOfPSN = kCurrentProcess ;
1247 SameProcess( &gAppProcess , &psn , &isSame ) ;
1248 if ( isSame )
1249 {
1250 #if TARGET_CARBON
1251 EventRef dummyEvent ;
1252 OSStatus err = MacCreateEvent(nil, 'WXMC', 'WXMC', GetCurrentEventTime(),
1253 kEventAttributeNone, &dummyEvent);
1254 if (err == noErr)
1255 {
1256 err = PostEventToQueue(GetMainEventQueue(), dummyEvent,
1257 kEventPriorityHigh);
1258 }
1259 #else
1260 PostEvent( nullEvent , 0 ) ;
1261 #endif
1262 }
1263 else
1264 {
1265 WakeUpProcess( &gAppProcess ) ;
1266 }
1267 }
1268
1269 #endif // wxUSE_BASE
1270
1271 #if wxUSE_GUI
1272
1273
1274 // ----------------------------------------------------------------------------
1275 // Carbon Event Support
1276 // ----------------------------------------------------------------------------
1277
1278
1279 OSStatus wxMacCarbonEvent::GetParameter(EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData)
1280 {
1281 return ::GetEventParameter( m_eventRef , inName , inDesiredType , NULL , inBufferSize , NULL , outData ) ;
1282 }
1283
1284 OSStatus wxMacCarbonEvent::SetParameter(EventParamName inName, EventParamType inType, UInt32 inBufferSize, void * inData)
1285 {
1286 return ::SetEventParameter( m_eventRef , inName , inType , inBufferSize , inData ) ;
1287 }
1288
1289 // ----------------------------------------------------------------------------
1290 // debugging support
1291 // ----------------------------------------------------------------------------
1292
1293 #if defined(__WXMAC__) && !defined(__DARWIN__) && defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
1294
1295 // MetroNub stuff doesn't seem to work in CodeWarrior 5.3 Carbon builds...
1296
1297 #ifndef __MetroNubUtils__
1298 #include "MetroNubUtils.h"
1299 #endif
1300
1301 #ifndef __GESTALT__
1302 #include <Gestalt.h>
1303 #endif
1304
1305 #if TARGET_API_MAC_CARBON
1306
1307 #include <CodeFragments.h>
1308
1309 extern "C" long CallUniversalProc(UniversalProcPtr theProcPtr, ProcInfoType procInfo, ...);
1310
1311 ProcPtr gCallUniversalProc_Proc = NULL;
1312
1313 #endif
1314
1315 static MetroNubUserEntryBlock* gMetroNubEntry = NULL;
1316
1317 static long fRunOnce = false;
1318
1319 /* ---------------------------------------------------------------------------
1320 IsMetroNubInstalled
1321 --------------------------------------------------------------------------- */
1322
1323 Boolean IsMetroNubInstalled()
1324 {
1325 if (!fRunOnce)
1326 {
1327 long result, value;
1328
1329 fRunOnce = true;
1330 gMetroNubEntry = NULL;
1331
1332 if (Gestalt(gestaltSystemVersion, &value) == noErr && value < 0x1000)
1333 {
1334 /* look for MetroNub's Gestalt selector */
1335 if (Gestalt(kMetroNubUserSignature, &result) == noErr)
1336 {
1337
1338 #if TARGET_API_MAC_CARBON
1339 if (gCallUniversalProc_Proc == NULL)
1340 {
1341 CFragConnectionID connectionID;
1342 Ptr mainAddress;
1343 Str255 errorString;
1344 ProcPtr symbolAddress;
1345 OSErr err;
1346 CFragSymbolClass symbolClass;
1347
1348 symbolAddress = NULL;
1349 err = GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch, kFindCFrag,
1350 &connectionID, &mainAddress, errorString);
1351
1352 if (err != noErr)
1353 {
1354 gCallUniversalProc_Proc = NULL;
1355 goto end;
1356 }
1357
1358 err = FindSymbol(connectionID, "\pCallUniversalProc",
1359 (Ptr *) &gCallUniversalProc_Proc, &symbolClass);
1360
1361 if (err != noErr)
1362 {
1363 gCallUniversalProc_Proc = NULL;
1364 goto end;
1365 }
1366 }
1367 #endif
1368
1369 {
1370 MetroNubUserEntryBlock* block = (MetroNubUserEntryBlock *)result;
1371
1372 /* make sure the version of the API is compatible */
1373 if (block->apiLowVersion <= kMetroNubUserAPIVersion &&
1374 kMetroNubUserAPIVersion <= block->apiHiVersion)
1375 gMetroNubEntry = block; /* success! */
1376 }
1377
1378 }
1379 }
1380 }
1381
1382 end:
1383
1384 #if TARGET_API_MAC_CARBON
1385 return (gMetroNubEntry != NULL && gCallUniversalProc_Proc != NULL);
1386 #else
1387 return (gMetroNubEntry != NULL);
1388 #endif
1389 }
1390
1391 /* ---------------------------------------------------------------------------
1392 IsMWDebuggerRunning [v1 API]
1393 --------------------------------------------------------------------------- */
1394
1395 Boolean IsMWDebuggerRunning()
1396 {
1397 if (IsMetroNubInstalled())
1398 return CallIsDebuggerRunningProc(gMetroNubEntry->isDebuggerRunning);
1399 else
1400 return false;
1401 }
1402
1403 /* ---------------------------------------------------------------------------
1404 AmIBeingMWDebugged [v1 API]
1405 --------------------------------------------------------------------------- */
1406
1407 Boolean AmIBeingMWDebugged()
1408 {
1409 if (IsMetroNubInstalled())
1410 return CallAmIBeingDebuggedProc(gMetroNubEntry->amIBeingDebugged);
1411 else
1412 return false;
1413 }
1414
1415 extern bool WXDLLEXPORT wxIsDebuggerRunning()
1416 {
1417 return IsMWDebuggerRunning() && AmIBeingMWDebugged();
1418 }
1419
1420 #else
1421
1422 extern bool WXDLLEXPORT wxIsDebuggerRunning()
1423 {
1424 return false;
1425 }
1426
1427 #endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ >= 0x2400)
1428
1429 #endif // wxUSE_GUI
1430