]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/utils.cpp
Fixing compilation on Mac, and attempting to better calculate the bottom position...
[wxWidgets.git] / src / mac / carbon / utils.cpp
CommitLineData
e9576ca5 1/////////////////////////////////////////////////////////////////////////////
fb5246be 2// Name: src/mac/carbon/utils.cpp
e9576ca5 3// Purpose: Various utilities
a31a5f85 4// Author: Stefan Csomor
e9576ca5 5// Modified by:
a31a5f85 6// Created: 1998-01-01
e9576ca5 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
88a7a4e1 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878
SC
12#include "wx/wxprec.h"
13
e9576ca5 14#include "wx/utils.h"
88a7a4e1
WS
15
16#ifndef WX_PRECOMP
17 #include "wx/intl.h"
670f9935 18 #include "wx/app.h"
1832043f
WS
19 #if wxUSE_GUI
20 #include "wx/toplevel.h"
48a1108e 21 #include "wx/font.h"
1832043f 22 #endif
88a7a4e1
WS
23#endif
24
2bf2d09e 25#include "wx/apptrait.h"
b6ed2b86
VZ
26
27#if wxUSE_GUI
28 #include "wx/mac/uma.h"
29#endif
e9576ca5
SC
30
31#include <ctype.h>
32
33#include <stdio.h>
34#include <stdlib.h>
35#include <string.h>
36#include <stdarg.h>
37
a2b77260 38#include "MoreFilesX.h"
518af45b 39
66a09d47 40#ifndef __DARWIN__
8638e69b
DS
41 #include <Threads.h>
42 #include <Sound.h>
66a09d47
SC
43#endif
44
7d9bf1f1 45#if wxUSE_GUI
29d91661 46#if TARGET_API_MAC_OSX
8638e69b 47 #include <CoreServices/CoreServices.h>
29d91661 48#else
8638e69b
DS
49 #include <DriverServices.h>
50 #include <Multiprocessing.h>
29d91661
SC
51#endif
52
768c6e8b 53#ifdef __DARWIN__
8638e69b 54 #include <Carbon/Carbon.h>
768c6e8b 55#else
8638e69b
DS
56 #include <ATSUnicode.h>
57 #include <TextCommon.h>
58 #include <TextEncodingConverter.h>
768c6e8b 59#endif
7d9bf1f1 60#endif // wxUSE_GUI
427ff662 61
8638e69b 62#include "wx/mac/private.h"
a434b43f
VZ
63
64#if defined(__MWERKS__) && wxUSE_UNICODE
6cce68ea 65#if __MWERKS__ < 0x4100 || !defined(__DARWIN__)
a434b43f
VZ
66 #include <wtime.h>
67#endif
6cce68ea 68#endif
a434b43f 69
c655557f 70#if wxUSE_BASE
659b3e8b
VZ
71
72// our OS version is the same in non GUI and GUI cases
c655557f 73wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
659b3e8b 74{
6cce68ea 75 long theSystem;
6cce68ea 76 Gestalt(gestaltSystemVersion, &theSystem);
8638e69b 77
c655557f 78 if ( majorVsn != NULL )
6cce68ea 79 *majorVsn = (theSystem >> 8);
8638e69b 80
c655557f
VZ
81 if ( minorVsn != NULL )
82 *minorVsn = (theSystem & 0xFF);
83
8bb6b2c0
VZ
84#if defined( __DARWIN__ )
85 return wxOS_MAC_OSX_DARWIN;
659b3e8b 86#else
8bb6b2c0 87 return wxOS_MAC_OS;
659b3e8b
VZ
88#endif
89}
90
e5a9c663
SC
91// ----------------------------------------------------------------------------
92// debugging support
93// ----------------------------------------------------------------------------
94
e2fccedf 95#if defined(__WXDEBUG__) && defined(__WXMAC__) && !defined(__DARWIN__) && defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
e5a9c663
SC
96
97// MetroNub stuff doesn't seem to work in CodeWarrior 5.3 Carbon builds...
98
99#ifndef __MetroNubUtils__
100#include "MetroNubUtils.h"
101#endif
102
103#ifndef __GESTALT__
104#include <Gestalt.h>
105#endif
106
107#if TARGET_API_MAC_CARBON
108
8638e69b 109#include <CodeFragments.h>
e5a9c663 110
8638e69b 111extern "C" long CallUniversalProc(UniversalProcPtr theProcPtr, ProcInfoType procInfo, ...);
e5a9c663 112
8638e69b 113ProcPtr gCallUniversalProc_Proc = NULL;
e5a9c663
SC
114
115#endif
116
117static MetroNubUserEntryBlock* gMetroNubEntry = NULL;
118
119static long fRunOnce = false;
120
e5a9c663
SC
121
122Boolean IsMetroNubInstalled()
123{
124 if (!fRunOnce)
125 {
126 long result, value;
127
128 fRunOnce = true;
129 gMetroNubEntry = NULL;
130
131 if (Gestalt(gestaltSystemVersion, &value) == noErr && value < 0x1000)
132 {
8638e69b 133 // look for MetroNub's Gestalt selector
e5a9c663
SC
134 if (Gestalt(kMetroNubUserSignature, &result) == noErr)
135 {
8638e69b 136#if TARGET_API_MAC_CARBON
e5a9c663
SC
137 if (gCallUniversalProc_Proc == NULL)
138 {
139 CFragConnectionID connectionID;
140 Ptr mainAddress;
141 Str255 errorString;
142 ProcPtr symbolAddress;
143 OSErr err;
144 CFragSymbolClass symbolClass;
145
146 symbolAddress = NULL;
147 err = GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch, kFindCFrag,
148 &connectionID, &mainAddress, errorString);
149
150 if (err != noErr)
151 {
152 gCallUniversalProc_Proc = NULL;
153 goto end;
154 }
155
156 err = FindSymbol(connectionID, "\pCallUniversalProc",
157 (Ptr *) &gCallUniversalProc_Proc, &symbolClass);
158
159 if (err != noErr)
160 {
161 gCallUniversalProc_Proc = NULL;
162 goto end;
163 }
164 }
8638e69b 165#endif
e5a9c663
SC
166
167 {
168 MetroNubUserEntryBlock* block = (MetroNubUserEntryBlock *)result;
169
8638e69b 170 // make sure the version of the API is compatible
e5a9c663
SC
171 if (block->apiLowVersion <= kMetroNubUserAPIVersion &&
172 kMetroNubUserAPIVersion <= block->apiHiVersion)
8638e69b
DS
173 {
174 // success!
88a7a4e1 175 gMetroNubEntry = block;
8638e69b 176 }
e5a9c663 177 }
e5a9c663
SC
178 }
179 }
180 }
181
182end:
183
184#if TARGET_API_MAC_CARBON
185 return (gMetroNubEntry != NULL && gCallUniversalProc_Proc != NULL);
186#else
187 return (gMetroNubEntry != NULL);
188#endif
189}
190
e5a9c663
SC
191Boolean IsMWDebuggerRunning()
192{
193 if (IsMetroNubInstalled())
194 return CallIsDebuggerRunningProc(gMetroNubEntry->isDebuggerRunning);
e5a9c663 195
8638e69b
DS
196 return false;
197}
e5a9c663
SC
198
199Boolean AmIBeingMWDebugged()
200{
201 if (IsMetroNubInstalled())
202 return CallAmIBeingDebuggedProc(gMetroNubEntry->amIBeingDebugged);
8638e69b
DS
203
204 return false;
e5a9c663
SC
205}
206
207extern bool WXDLLEXPORT wxIsDebuggerRunning()
208{
209 return IsMWDebuggerRunning() && AmIBeingMWDebugged();
210}
211
212#else
213
214extern bool WXDLLEXPORT wxIsDebuggerRunning()
215{
216 return false;
217}
218
219#endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ >= 0x2400)
220
a434b43f 221
f5c6eb5c 222#ifndef __DARWIN__
03e11df5
GD
223// defined in unix/utilsunx.cpp for Mac OS X
224
2f1ae414
SC
225// get full hostname (with domain name if possible)
226bool wxGetFullHostName(wxChar *buf, int maxSize)
227{
228 return wxGetHostName(buf, maxSize);
229}
230
8638e69b
DS
231// Get user ID e.g. jacs
232bool wxGetUserId(wxChar *buf, int maxSize)
233{
6cce68ea 234 return wxGetUserName( buf , maxSize );
8638e69b
DS
235}
236
237const wxChar* wxGetHomeDir(wxString *pstr)
238{
6cce68ea
SC
239 *pstr = wxMacFindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder );
240 return pstr->c_str();
8638e69b
DS
241}
242
2f1ae414 243// Get hostname only (without domain name)
427ff662 244bool wxGetHostName(wxChar *buf, int maxSize)
e9576ca5 245{
e40298d5 246 // Gets Chooser name of user by examining a System resource.
6cce68ea 247 buf[0] = 0;
e40298d5
JS
248
249 const short kComputerNameID = -16413;
5be55d56 250
6cce68ea 251 short oldResFile = CurResFile();
e40298d5
JS
252 UseResFile(0);
253 StringHandle chooserName = (StringHandle)::GetString(kComputerNameID);
254 UseResFile(oldResFile);
255
256 if (chooserName && *chooserName)
257 {
6cce68ea
SC
258 HLock( (Handle) chooserName );
259 wxString name = wxMacMakeStringFromPascal( *chooserName );
260 HUnlock( (Handle) chooserName );
261 ReleaseResource( (Handle) chooserName );
262 wxStrncpy( buf , name , maxSize - 1 );
e40298d5 263 }
0a67a93b 264
9d8aca48 265 return true;
e9576ca5
SC
266}
267
a31a5f85 268// Get user name e.g. Stefan Csomor
427ff662 269bool wxGetUserName(wxChar *buf, int maxSize)
e9576ca5 270{
e40298d5 271 // Gets Chooser name of user by examining a System resource.
6cce68ea 272 buf[0] = 0;
e40298d5
JS
273
274 const short kChooserNameID = -16096;
5be55d56 275
6cce68ea 276 short oldResFile = CurResFile();
e40298d5
JS
277 UseResFile(0);
278 StringHandle chooserName = (StringHandle)::GetString(kChooserNameID);
279 UseResFile(oldResFile);
280
281 if (chooserName && *chooserName)
282 {
6cce68ea
SC
283 HLock( (Handle) chooserName );
284 wxString name = wxMacMakeStringFromPascal( *chooserName );
285 HUnlock( (Handle) chooserName );
286 ReleaseResource( (Handle) chooserName );
287 wxStrncpy( buf , name , maxSize - 1 );
e40298d5 288 }
0a67a93b 289
9d8aca48 290 return true;
e9576ca5
SC
291}
292
e0f6b731 293int wxKill(long pid, wxSignal sig , wxKillError *rc, int flags)
e9576ca5
SC
294{
295 // TODO
296 return 0;
297}
298
5dbb17e2
SC
299WXDLLEXPORT bool wxGetEnv(const wxString& var, wxString *value)
300{
e40298d5 301 // TODO : under classic there is no environement support, under X yes
6cce68ea 302 return false;
5dbb17e2
SC
303}
304
9d8aca48 305// set the env var name to the given value, return true on success
5dbb17e2
SC
306WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value)
307{
e40298d5 308 // TODO : under classic there is no environement support, under X yes
6cce68ea 309 return false;
5dbb17e2
SC
310}
311
e9576ca5 312// Execute a program in an Interactive Shell
e9576ca5
SC
313bool wxShell(const wxString& command)
314{
315 // TODO
9d8aca48 316 return false;
e9576ca5
SC
317}
318
5be55d56 319// Shutdown or reboot the PC
f6ba47d9
VZ
320bool wxShutdown(wxShutdownFlags wFlags)
321{
322 // TODO
9d8aca48 323 return false;
f6ba47d9
VZ
324}
325
e9576ca5 326// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
9d8aca48 327wxMemorySize wxGetFreeMemory()
e9576ca5 328{
6cce68ea 329 return (wxMemorySize)FreeMem();
0a67a93b
SC
330}
331
7f7b52b4
SC
332#ifndef __DARWIN__
333
334void wxMicroSleep(unsigned long microseconds)
0a67a93b 335{
9d8aca48
WS
336 AbsoluteTime wakeup = AddDurationToAbsolute( microseconds * durationMicrosecond , UpTime());
337 MPDelayUntil( & wakeup);
7f7b52b4
SC
338}
339
340void wxMilliSleep(unsigned long milliseconds)
341{
9d8aca48
WS
342 AbsoluteTime wakeup = AddDurationToAbsolute( milliseconds, UpTime());
343 MPDelayUntil( & wakeup);
e9576ca5
SC
344}
345
346void wxSleep(int nSecs)
347{
7f7b52b4 348 wxMilliSleep(1000*nSecs);
e9576ca5
SC
349}
350
7f7b52b4
SC
351#endif
352
e9576ca5
SC
353// Consume all events until no more left
354void wxFlushEvents()
355{
356}
357
f5c6eb5c 358#endif // !__DARWIN__
e9576ca5
SC
359
360// Emit a beeeeeep
361void wxBell()
362{
0a67a93b 363 SysBeep(30);
e9576ca5
SC
364}
365
29c99ad3 366
b6ed2b86
VZ
367#endif // wxUSE_BASE
368
369#if wxUSE_GUI
536732e4 370
8bb6b2c0 371wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
29c99ad3 372{
8bb6b2c0
VZ
373 // We suppose that toolkit version is the same as OS version under Mac
374 wxGetOsVersion(verMaj, verMin);
8638e69b 375
8bb6b2c0 376 return wxPORT_MAC;
29c99ad3
VZ
377}
378
e9576ca5
SC
379// Reading and writing resources (eg WIN.INI, .Xdefaults)
380#if wxUSE_RESOURCES
381bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
382{
383 // TODO
9d8aca48 384 return false;
e9576ca5
SC
385}
386
387bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
388{
427ff662
SC
389 wxString buf;
390 buf.Printf(wxT("%.4f"), value);
391
e40298d5 392 return wxWriteResource(section, entry, buf, file);
e9576ca5
SC
393}
394
395bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file)
396{
427ff662
SC
397 wxString buf;
398 buf.Printf(wxT("%ld"), value);
399
e40298d5 400 return wxWriteResource(section, entry, buf, file);
e9576ca5
SC
401}
402
403bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file)
404{
427ff662
SC
405 wxString buf;
406 buf.Printf(wxT("%d"), value);
407
e40298d5 408 return wxWriteResource(section, entry, buf, file);
e9576ca5
SC
409}
410
411bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file)
412{
413 // TODO
9d8aca48 414 return false;
e9576ca5
SC
415}
416
417bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
418{
e40298d5
JS
419 char *s = NULL;
420 bool succ = wxGetResource(section, entry, (char **)&s, file);
421 if (succ)
422 {
423 *value = (float)strtod(s, NULL);
424 delete[] s;
e40298d5 425 }
8638e69b
DS
426
427 return succ;
e9576ca5
SC
428}
429
430bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
431{
e40298d5
JS
432 char *s = NULL;
433 bool succ = wxGetResource(section, entry, (char **)&s, file);
434 if (succ)
435 {
436 *value = strtol(s, NULL, 10);
437 delete[] s;
e40298d5 438 }
8638e69b
DS
439
440 return succ;
e9576ca5
SC
441}
442
443bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
444{
e40298d5
JS
445 char *s = NULL;
446 bool succ = wxGetResource(section, entry, (char **)&s, file);
447 if (succ)
448 {
449 *value = (int)strtol(s, NULL, 10);
450 delete[] s;
e40298d5 451 }
8638e69b
DS
452
453 return succ;
e9576ca5
SC
454}
455#endif // wxUSE_RESOURCES
456
6b57b49a 457int gs_wxBusyCursorCount = 0;
6cce68ea
SC
458extern wxCursor gMacCurrentCursor;
459wxCursor gMacStoredActiveCursor;
e9576ca5
SC
460
461// Set the cursor to the busy cursor for all windows
f516d986 462void wxBeginBusyCursor(const wxCursor *cursor)
e9576ca5 463{
e40298d5
JS
464 if (gs_wxBusyCursorCount++ == 0)
465 {
6cce68ea
SC
466 gMacStoredActiveCursor = gMacCurrentCursor;
467 cursor->MacInstall();
e40298d5
JS
468 }
469 //else: nothing to do, already set
e9576ca5
SC
470}
471
472// Restore cursor to normal
473void wxEndBusyCursor()
474{
6b57b49a 475 wxCHECK_RET( gs_wxBusyCursorCount > 0,
e40298d5 476 wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") );
5be55d56 477
e40298d5
JS
478 if (--gs_wxBusyCursorCount == 0)
479 {
6cce68ea
SC
480 gMacStoredActiveCursor.MacInstall();
481 gMacStoredActiveCursor = wxNullCursor;
e40298d5 482 }
e9576ca5
SC
483}
484
9d8aca48 485// true if we're between the above two calls
e9576ca5
SC
486bool wxIsBusy()
487{
e40298d5 488 return (gs_wxBusyCursorCount > 0);
ec5d7799 489}
e9576ca5 490
2dbc444a
RD
491#endif // wxUSE_GUI
492
493#if wxUSE_BASE
494
17af82fb 495wxString wxMacFindFolderNoSeparator( short vol,
e40298d5
JS
496 OSType folderType,
497 Boolean createFolder)
2f1ae414 498{
6cce68ea
SC
499 FSRef fsRef;
500 wxString strDir;
5be55d56 501
a2b77260 502 if ( FSFindFolder( vol, folderType, createFolder, &fsRef) == noErr)
17af82fb
VZ
503 {
504 strDir = wxMacFSRefToPath( &fsRef );
505 }
a2b77260 506
6cce68ea 507 return strDir;
2f1ae414
SC
508}
509
17af82fb
VZ
510wxString wxMacFindFolder( short vol,
511 OSType folderType,
512 Boolean createFolder)
513{
514 return wxMacFindFolderNoSeparator(vol, folderType, createFolder) + wxFILE_SEP_PATH;
515}
516
2dbc444a
RD
517#endif // wxUSE_BASE
518
519#if wxUSE_GUI
520
e9576ca5
SC
521// Check whether this window wants to process messages, e.g. Stop button
522// in long calculations.
523bool wxCheckForInterrupt(wxWindow *wnd)
524{
525 // TODO
9d8aca48 526 return false;
e9576ca5
SC
527}
528
529void wxGetMousePosition( int* x, int* y )
530{
6cce68ea 531 Point pt;
ec5d7799 532
6cce68ea
SC
533 GetMouse( &pt );
534 LocalToGlobal( &pt );
535 *x = pt.h;
536 *y = pt.v;
e9576ca5
SC
537};
538
9d8aca48 539// Return true if we have a colour display
e9576ca5
SC
540bool wxColourDisplay()
541{
9d8aca48 542 return true;
e9576ca5
SC
543}
544
545// Returns depth of screen
546int wxDisplayDepth()
547{
6cce68ea 548 Rect globRect;
e40298d5
JS
549 SetRect(&globRect, -32760, -32760, 32760, 32760);
550 GDHandle theMaxDevice;
2f1ae414 551
e40298d5
JS
552 int theDepth = 8;
553 theMaxDevice = GetMaxDevice(&globRect);
8638e69b 554 if (theMaxDevice != NULL)
e40298d5 555 theDepth = (**(**theMaxDevice).gdPMap).pixelSize;
ec5d7799 556
6cce68ea 557 return theDepth;
e9576ca5
SC
558}
559
560// Get size of display
561void wxDisplaySize(int *width, int *height)
562{
e40298d5
JS
563 BitMap screenBits;
564 GetQDGlobalsScreenBits( &screenBits );
5be55d56 565
8638e69b 566 if (width != NULL)
6cce68ea 567 *width = screenBits.bounds.right - screenBits.bounds.left;
8638e69b
DS
568
569 if (height != NULL)
6cce68ea 570 *height = screenBits.bounds.bottom - screenBits.bounds.top;
e9576ca5
SC
571}
572
5fde6fcc
GD
573void wxDisplaySizeMM(int *width, int *height)
574{
5b028d57 575 wxDisplaySize(width, height);
6cce68ea 576 // on mac 72 is fixed (at least now;-)
5b028d57 577 float cvPt2Mm = 25.4 / 72;
e8ca7105 578
8638e69b 579 if (width != NULL)
e8ca7105 580 *width = int( *width * cvPt2Mm );
8638e69b
DS
581
582 if (height != NULL)
e8ca7105 583 *height = int( *height * cvPt2Mm );
5fde6fcc
GD
584}
585
ec5d7799
RD
586void wxClientDisplayRect(int *x, int *y, int *width, int *height)
587{
6cce68ea 588 Rect r;
8638e69b 589
6cce68ea 590 GetAvailableWindowPositioningBounds( GetMainDevice() , &r );
ee658398 591 if ( x )
6cce68ea 592 *x = r.left;
ee658398 593 if ( y )
6cce68ea 594 *y = r.top;
ee658398 595 if ( width )
6cce68ea 596 *width = r.right - r.left;
ee658398 597 if ( height )
6cce68ea 598 *height = r.bottom - r.top;
ec5d7799
RD
599}
600
57591e0e
JS
601wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
602{
603 return wxGenericFindWindowAtPoint(pt);
604}
5dbb17e2 605
b6ed2b86
VZ
606#endif // wxUSE_GUI
607
608#if wxUSE_BASE
609
5dbb17e2
SC
610wxString wxGetOsDescription()
611{
6e73695c
GD
612#ifdef WXWIN_OS_DESCRIPTION
613 // use configure generated description if available
5f3f0f17 614 return wxString(wxT("MacOS (")) + wxT(WXWIN_OS_DESCRIPTION) + wxString(wxT(")"));
6e73695c 615#else
6cce68ea 616 return wxT("MacOS"); //TODO:define further
6e73695c
GD
617#endif
618}
619
b6ed2b86
VZ
620#ifndef __DARWIN__
621wxChar *wxGetUserHome (const wxString& user)
622{
623 // TODO
624 return NULL;
625}
626
7ba7c4e6 627bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal, wxDiskspaceSize_t *pFree)
b6ed2b86
VZ
628{
629 if ( path.empty() )
9d8aca48 630 return false;
b6ed2b86 631
6cce68ea 632 wxString p = path;
8638e69b 633 if (p[0u] == ':' )
6cce68ea 634 p = wxGetCwd() + p;
b6ed2b86 635
6cce68ea 636 int pos = p.Find(':');
8638e69b 637 if ( pos != wxNOT_FOUND )
6cce68ea 638 p = p.Mid(1,pos);
b6ed2b86 639
6cce68ea 640 p = p + wxT(":");
b6ed2b86 641
6cce68ea 642 OSErr err = noErr;
9d8aca48 643
6cce68ea
SC
644 FSRef fsRef;
645 err = wxMacPathToFSRef( p , &fsRef );
a2b77260
SC
646 if ( noErr == err )
647 {
6cce68ea
SC
648 FSVolumeRefNum vRefNum;
649 err = FSGetVRefNum( &fsRef , &vRefNum );
a2b77260
SC
650 if ( noErr == err )
651 {
6cce68ea
SC
652 UInt64 freeBytes , totalBytes;
653 err = FSGetVInfo( vRefNum , NULL , &freeBytes , &totalBytes );
a2b77260
SC
654 if ( noErr == err )
655 {
9d8aca48 656 if ( pTotal )
6cce68ea 657 *pTotal = wxDiskspaceSize_t( totalBytes );
a2b77260 658 if ( pFree )
6cce68ea 659 *pFree = wxDiskspaceSize_t( freeBytes );
a2b77260
SC
660 }
661 }
b6ed2b86 662 }
9d8aca48 663
6cce68ea 664 return err == noErr;
b6ed2b86
VZ
665}
666#endif // !__DARWIN__
667
3d963f81
SC
668//---------------------------------------------------------------------------
669// wxMac Specific utility functions
670//---------------------------------------------------------------------------
671
5be55d56 672void wxMacStringToPascal( const wxString&from , StringPtr to )
427ff662 673{
6cce68ea
SC
674 wxCharBuffer buf = from.mb_str( wxConvLocal );
675 int len = strlen(buf);
427ff662
SC
676
677 if ( len > 255 )
6cce68ea
SC
678 len = 255;
679 to[0] = len;
680 memcpy( (char*) &to[1] , buf , len );
427ff662
SC
681}
682
5be55d56 683wxString wxMacMakeStringFromPascal( ConstStringPtr from )
427ff662 684{
6cce68ea 685 return wxString( (char*) &from[1] , wxConvLocal , from[0] );
427ff662
SC
686}
687
73280e05
SC
688// ----------------------------------------------------------------------------
689// Common Event Support
690// ----------------------------------------------------------------------------
691
6cce68ea 692extern ProcessSerialNumber gAppProcess;
73280e05
SC
693
694void wxMacWakeUp()
695{
6cce68ea
SC
696 ProcessSerialNumber psn;
697 Boolean isSame;
698 psn.highLongOfPSN = 0;
699 psn.lowLongOfPSN = kCurrentProcess;
700 SameProcess( &gAppProcess , &psn , &isSame );
73280e05
SC
701 if ( isSame )
702 {
703#if TARGET_CARBON
6cce68ea 704 OSStatus err = noErr;
8638e69b 705
41ab357e
SC
706#if 0
707 // lead sometimes to race conditions, although all calls used should be thread safe ...
6cce68ea 708 static wxMacCarbonEvent s_wakeupEvent;
8dfef0c2 709 if ( !s_wakeupEvent.IsValid() )
d6c69b17 710 {
8dfef0c2 711 err = s_wakeupEvent.Create( 'WXMC', 'WXMC', GetCurrentEventTime(),
6cce68ea 712 kEventAttributeNone );
d6c69b17 713 }
8dfef0c2 714 if ( err == noErr )
73280e05 715 {
88a7a4e1 716
8dfef0c2 717 if ( IsEventInQueue( GetMainEventQueue() , s_wakeupEvent ) )
6cce68ea
SC
718 return;
719 s_wakeupEvent.SetCurrentTime();
d6c69b17 720 err = PostEventToQueue(GetMainEventQueue(), s_wakeupEvent,
41ab357e 721 kEventPriorityHigh );
8dfef0c2 722 }
41ab357e 723#else
6cce68ea 724 wxMacCarbonEvent wakeupEvent;
41ab357e 725 wakeupEvent.Create( 'WXMC', 'WXMC', GetCurrentEventTime(),
6cce68ea 726 kEventAttributeNone );
41ab357e
SC
727 err = PostEventToQueue(GetMainEventQueue(), wakeupEvent,
728 kEventPriorityHigh );
729#endif
73280e05 730#else
6cce68ea 731 PostEvent( nullEvent , 0 );
73280e05
SC
732#endif
733 }
734 else
735 {
6cce68ea 736 WakeUpProcess( &gAppProcess );
73280e05
SC
737 }
738}
739
d13ea1bd
RD
740#endif // wxUSE_BASE
741
742#if wxUSE_GUI
743
1f1c8bd4
SC
744// ----------------------------------------------------------------------------
745// Native Struct Conversions
746// ----------------------------------------------------------------------------
747
fb5246be 748void wxMacRectToNative( const wxRect *wx , Rect *n )
1f1c8bd4 749{
6cce68ea
SC
750 n->left = wx->x;
751 n->top = wx->y;
752 n->right = wx->x + wx->width;
753 n->bottom = wx->y + wx->height;
1f1c8bd4
SC
754}
755
fb5246be 756void wxMacNativeToRect( const Rect *n , wxRect* wx )
1f1c8bd4 757{
6cce68ea
SC
758 wx->x = n->left;
759 wx->y = n->top;
760 wx->width = n->right - n->left;
761 wx->height = n->bottom - n->top;
1f1c8bd4
SC
762}
763
fb5246be 764void wxMacPointToNative( const wxPoint* wx , Point *n )
1f1c8bd4 765{
6cce68ea
SC
766 n->h = wx->x;
767 n->v = wx->y;
1f1c8bd4
SC
768}
769
fb5246be 770void wxMacNativeToPoint( const Point *n , wxPoint* wx )
1f1c8bd4 771{
6cce68ea
SC
772 wx->x = n->h;
773 wx->y = n->v;
1f1c8bd4 774}
d13ea1bd 775
facd6764
SC
776// ----------------------------------------------------------------------------
777// Carbon Event Support
778// ----------------------------------------------------------------------------
779
facd6764
SC
780OSStatus wxMacCarbonEvent::GetParameter(EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData)
781{
6cce68ea 782 return ::GetEventParameter( m_eventRef , inName , inDesiredType , NULL , inBufferSize , NULL , outData );
facd6764
SC
783}
784
21fd5529 785OSStatus wxMacCarbonEvent::SetParameter(EventParamName inName, EventParamType inType, UInt32 inBufferSize, const void * inData)
facd6764 786{
6cce68ea 787 return ::SetEventParameter( m_eventRef , inName , inType , inBufferSize , inData );
facd6764
SC
788}
789
86d8b744
SC
790// ----------------------------------------------------------------------------
791// Control Access Support
792// ----------------------------------------------------------------------------
793
1f1c8bd4 794wxMacControl::wxMacControl(wxWindow* peer , bool isRootControl )
9b89f11a 795{
6cce68ea
SC
796 Init();
797 m_peer = peer;
798 m_isRootControl = isRootControl;
9b89f11a
SC
799}
800
fb5246be 801wxMacControl::wxMacControl( wxWindow* peer , ControlRef control )
9b89f11a 802{
6cce68ea
SC
803 Init();
804 m_peer = peer;
6cce68ea 805 m_controlRef = control;
9b89f11a
SC
806}
807
808wxMacControl::wxMacControl( wxWindow* peer , WXWidget control )
809{
6cce68ea
SC
810 Init();
811 m_peer = peer;
6cce68ea 812 m_controlRef = (ControlRef) control;
9b89f11a
SC
813}
814
815wxMacControl::~wxMacControl()
816{
817}
818
819void wxMacControl::Init()
820{
6cce68ea
SC
821 m_peer = NULL;
822 m_controlRef = NULL;
823 m_needsFocusRect = false;
6cce68ea 824 m_isRootControl = false;
9b89f11a
SC
825}
826
5ca0d812
SC
827void wxMacControl::Dispose()
828{
8c981ec6
SC
829 wxASSERT_MSG( IsValidControlHandle(m_controlRef) , wxT("Invalid Control Handle (maybe already released) in Dispose") );
830
831 CFIndex count = CFGetRetainCount( m_controlRef ) ;
832 wxASSERT_MSG( count == 1 , wxT("Reference Count of native control was not 1 in Dispose") );
833
6cce68ea
SC
834 ::DisposeControl( m_controlRef );
835 m_controlRef = NULL;
5ca0d812
SC
836}
837
9d8aca48 838void wxMacControl::SetReference( SInt32 data )
5ca0d812 839{
6cce68ea 840 SetControlReference( m_controlRef , data );
5ca0d812
SC
841}
842
29d91661 843OSStatus wxMacControl::GetData(ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const
86d8b744 844{
6cce68ea 845 return ::GetControlData( m_controlRef , inPartCode , inTag , inBufferSize , inOutBuffer , outActualSize );
86d8b744
SC
846}
847
29d91661 848OSStatus wxMacControl::GetDataSize(ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const
86d8b744 849{
6cce68ea 850 return ::GetControlDataSize( m_controlRef , inPartCode , inTag , outActualSize );
86d8b744
SC
851}
852
853OSStatus wxMacControl::SetData(ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData)
854{
6cce68ea 855 return ::SetControlData( m_controlRef , inPartCode , inTag , inSize , inData );
86d8b744
SC
856}
857
8638e69b 858OSStatus wxMacControl::SendEvent( EventRef event , OptionBits inOptions )
21fd5529 859{
e996f509 860#if TARGET_API_MAC_OSX
9d8aca48 861 return SendEventToEventTargetWithOptions( event,
8638e69b 862 HIObjectGetEventTarget( (HIObjectRef) m_controlRef ), inOptions );
e996f509 863#else
9d8aca48 864 #pragma unused(inOptions)
6cce68ea 865 return SendEventToEventTarget(event,GetControlEventTarget( m_controlRef ) );
e996f509 866#endif
21fd5529
SC
867}
868
9d8aca48 869OSStatus wxMacControl::SendHICommand( HICommand &command , OptionBits inOptions )
21fd5529 870{
6cce68ea 871 wxMacCarbonEvent event( kEventClassCommand , kEventCommandProcess );
8638e69b 872
6cce68ea 873 event.SetParameter<HICommand>(kEventParamDirectObject,command);
8638e69b 874
6cce68ea 875 return SendEvent( event , inOptions );
21fd5529
SC
876}
877
9d8aca48 878OSStatus wxMacControl::SendHICommand( UInt32 commandID , OptionBits inOptions )
21fd5529 879{
6cce68ea 880 HICommand command;
8638e69b 881
6cce68ea
SC
882 memset( &command, 0 , sizeof(command) );
883 command.commandID = commandID;
884 return SendHICommand( command , inOptions );
21fd5529
SC
885}
886
9d8aca48 887void wxMacControl::Flash( ControlPartCode part , UInt32 ticks )
21fd5529 888{
6cce68ea 889 unsigned long finalTicks;
8638e69b 890
6cce68ea
SC
891 HiliteControl( m_controlRef , part );
892 Delay( ticks , &finalTicks );
893 HiliteControl( m_controlRef , kControlNoPart );
21fd5529
SC
894}
895
7f7b52b4 896SInt32 wxMacControl::GetValue() const
9d8aca48 897{
6cce68ea 898 return ::GetControl32BitValue( m_controlRef );
7f7b52b4
SC
899}
900
901SInt32 wxMacControl::GetMaximum() const
9d8aca48 902{
6cce68ea 903 return ::GetControl32BitMaximum( m_controlRef );
7f7b52b4
SC
904}
905
906SInt32 wxMacControl::GetMinimum() const
9d8aca48 907{
6cce68ea 908 return ::GetControl32BitMinimum( m_controlRef );
7f7b52b4
SC
909}
910
9d8aca48
WS
911void wxMacControl::SetValue( SInt32 v )
912{
6cce68ea 913 ::SetControl32BitValue( m_controlRef , v );
7f7b52b4
SC
914}
915
9d8aca48
WS
916void wxMacControl::SetMinimum( SInt32 v )
917{
6cce68ea 918 ::SetControl32BitMinimum( m_controlRef , v );
7f7b52b4
SC
919}
920
9d8aca48
WS
921void wxMacControl::SetMaximum( SInt32 v )
922{
6cce68ea 923 ::SetControl32BitMaximum( m_controlRef , v );
7f7b52b4
SC
924}
925
926void wxMacControl::SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum )
927{
6cce68ea
SC
928 ::SetControl32BitMinimum( m_controlRef , minimum );
929 ::SetControl32BitMaximum( m_controlRef , maximum );
930 ::SetControl32BitValue( m_controlRef , value );
7f7b52b4
SC
931}
932
9d8aca48 933OSStatus wxMacControl::SetFocus( ControlFocusPart focusPart )
5ca0d812 934{
6cce68ea 935 return SetKeyboardFocus( GetControlOwner( m_controlRef ), m_controlRef, focusPart );
5ca0d812
SC
936}
937
9d8aca48 938bool wxMacControl::HasFocus() const
5ca0d812 939{
6cce68ea
SC
940 ControlRef control;
941 GetKeyboardFocus( GetUserFocusWindow() , &control );
942 return control == m_controlRef;
5ca0d812
SC
943}
944
fb5246be 945void wxMacControl::SetNeedsFocusRect( bool needs )
9b89f11a 946{
6cce68ea 947 m_needsFocusRect = needs;
9b89f11a
SC
948}
949
9d8aca48 950bool wxMacControl::NeedsFocusRect() const
5ca0d812 951{
6cce68ea 952 return m_needsFocusRect;
5ca0d812
SC
953}
954
9d8aca48 955void wxMacControl::VisibilityChanged(bool shown)
29d91661
SC
956{
957}
958
89a66f11
SC
959void wxMacControl::SuperChangedPosition()
960{
961}
962
9d8aca48 963void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle )
29d91661 964{
6cce68ea 965 m_font = font;
9d8aca48
WS
966 ControlFontStyleRec fontStyle;
967 if ( font.MacGetThemeFontID() != kThemeCurrentPortFont )
968 {
8638e69b 969 switch ( font.MacGetThemeFontID() )
9d8aca48 970 {
8638e69b 971 case kThemeSmallSystemFont :
6cce68ea
SC
972 fontStyle.font = kControlFontSmallSystemFont;
973 break;
8638e69b
DS
974
975 case 109 : // mini font
6cce68ea
SC
976 fontStyle.font = -5;
977 break;
8638e69b
DS
978
979 case kThemeSystemFont :
6cce68ea
SC
980 fontStyle.font = kControlFontBigSystemFont;
981 break;
8638e69b
DS
982
983 default :
6cce68ea
SC
984 fontStyle.font = kControlFontBigSystemFont;
985 break;
9d8aca48 986 }
8638e69b 987
6cce68ea 988 fontStyle.flags = kControlUseFontMask;
9d8aca48
WS
989 }
990 else
991 {
6cce68ea
SC
992 fontStyle.font = font.MacGetFontNum();
993 fontStyle.style = font.MacGetFontStyle();
994 fontStyle.size = font.MacGetFontSize();
995 fontStyle.flags = kControlUseFontMask | kControlUseFaceMask | kControlUseSizeMask;
9d8aca48 996 }
29d91661 997
6cce68ea
SC
998 fontStyle.just = teJustLeft;
999 fontStyle.flags |= kControlUseJustMask;
29d91661 1000 if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_CENTER_HORIZONTAL )
6cce68ea 1001 fontStyle.just = teJustCenter;
29d91661 1002 else if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_RIGHT )
6cce68ea 1003 fontStyle.just = teJustRight;
29d91661 1004
9d8aca48 1005
29d91661
SC
1006 // we only should do this in case of a non-standard color, as otherwise 'disabled' controls
1007 // won't get grayed out by the system anymore
9d8aca48 1008
29d91661
SC
1009 if ( foreground != *wxBLACK )
1010 {
6cce68ea
SC
1011 fontStyle.foreColor = MAC_WXCOLORREF( foreground.GetPixel() );
1012 fontStyle.flags |= kControlUseForeColorMask;
29d91661 1013 }
9d8aca48
WS
1014
1015 ::SetControlFontStyle( m_controlRef , &fontStyle );
29d91661
SC
1016}
1017
9d8aca48 1018void wxMacControl::SetBackground( const wxBrush &WXUNUSED(brush) )
7ea087b7 1019{
9d8aca48 1020 // TODO
7ea087b7
SC
1021 // setting up a color proc is not recommended anymore
1022}
1023
7f7b52b4
SC
1024void wxMacControl::SetRange( SInt32 minimum , SInt32 maximum )
1025{
6cce68ea
SC
1026 ::SetControl32BitMinimum( m_controlRef , minimum );
1027 ::SetControl32BitMaximum( m_controlRef , maximum );
7f7b52b4
SC
1028}
1029
8638e69b 1030short wxMacControl::HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers )
5ca0d812 1031{
6cce68ea 1032 return HandleControlKey( m_controlRef , keyCode , charCode , modifiers );
5ca0d812
SC
1033}
1034
1035void wxMacControl::SetActionProc( ControlActionUPP actionProc )
1036{
6cce68ea 1037 SetControlAction( m_controlRef , actionProc );
5ca0d812
SC
1038}
1039
1040void wxMacControl::SetViewSize( SInt32 viewSize )
1041{
6cce68ea 1042 SetControlViewSize(m_controlRef , viewSize );
5ca0d812
SC
1043}
1044
1045SInt32 wxMacControl::GetViewSize() const
1046{
6cce68ea 1047 return GetControlViewSize( m_controlRef );
5ca0d812
SC
1048}
1049
9d8aca48 1050bool wxMacControl::IsVisible() const
5ca0d812 1051{
6cce68ea 1052 return IsControlVisible( m_controlRef );
5ca0d812
SC
1053}
1054
9d8aca48 1055void wxMacControl::SetVisibility( bool visible , bool redraw )
5ca0d812 1056{
6cce68ea 1057 SetControlVisibility( m_controlRef , visible , redraw );
5ca0d812
SC
1058}
1059
9d8aca48 1060bool wxMacControl::IsEnabled() const
5ca0d812
SC
1061{
1062#if TARGET_API_MAC_OSX
6cce68ea 1063 return IsControlEnabled( m_controlRef );
5ca0d812 1064#else
6cce68ea 1065 return IsControlActive( m_controlRef );
5ca0d812
SC
1066#endif
1067}
1068
9d8aca48 1069bool wxMacControl::IsActive() const
5ca0d812 1070{
6cce68ea 1071 return IsControlActive( m_controlRef );
5ca0d812
SC
1072}
1073
9d8aca48 1074void wxMacControl::Enable( bool enable )
5ca0d812 1075{
5ca0d812 1076 if ( enable )
6cce68ea 1077 EnableControl( m_controlRef );
5ca0d812 1078 else
6cce68ea 1079 DisableControl( m_controlRef );
5ca0d812
SC
1080}
1081
9d8aca48 1082void wxMacControl::SetDrawingEnabled( bool enable )
5ca0d812 1083{
6cce68ea 1084 HIViewSetDrawingEnabled( m_controlRef , enable );
5ca0d812
SC
1085}
1086
9d8aca48 1087bool wxMacControl::GetNeedsDisplay() const
5ca0d812 1088{
e779b609 1089 return HIViewGetNeedsDisplay( m_controlRef );
5ca0d812
SC
1090}
1091
1f1c8bd4 1092void wxMacControl::SetNeedsDisplay( RgnHandle where )
5ca0d812 1093{
1f1c8bd4 1094 if ( !IsVisible() )
6cce68ea 1095 return;
fb5246be 1096
e779b609 1097 HIViewSetNeedsDisplayInRegion( m_controlRef , where , true );
5ca0d812 1098}
1f1c8bd4
SC
1099
1100void wxMacControl::SetNeedsDisplay( Rect* where )
1101{
1102 if ( !IsVisible() )
6cce68ea 1103 return;
1f1c8bd4 1104
e779b609 1105 if ( where != NULL )
1f1c8bd4 1106 {
e779b609
SC
1107 RgnHandle update = NewRgn();
1108 RectRgn( update , where );
1109 HIViewSetNeedsDisplayInRegion( m_controlRef , update , true );
1110 DisposeRgn( update );
1f1c8bd4
SC
1111 }
1112 else
e779b609 1113 HIViewSetNeedsDisplay( m_controlRef , true );
1f1c8bd4 1114}
5ca0d812 1115
9d8aca48 1116void wxMacControl::Convert( wxPoint *pt , wxMacControl *from , wxMacControl *to )
5ca0d812 1117{
e779b609 1118 HIPoint hiPoint;
8638e69b 1119
e779b609
SC
1120 hiPoint.x = pt->x;
1121 hiPoint.y = pt->y;
1122 HIViewConvertPoint( &hiPoint , from->m_controlRef , to->m_controlRef );
1123 pt->x = (int)hiPoint.x;
1124 pt->y = (int)hiPoint.y;
5ca0d812
SC
1125}
1126
9d8aca48 1127void wxMacControl::SetRect( Rect *r )
5ca0d812 1128{
9b89f11a
SC
1129 //A HIRect is actually a CGRect on OSX - which consists of two structures -
1130 //CGPoint and CGSize, which have two floats each
6cce68ea
SC
1131 HIRect hir = { { r->left , r->top }, { r->right - r->left , r->bottom - r->top } };
1132 HIViewSetFrame ( m_controlRef , &hir );
1133 // eventuall we might have to do a SetVisibility( false , true );
1134 // before and a SetVisibility( true , true ); after
8bb6b2c0 1135}
5ca0d812 1136
9d8aca48 1137void wxMacControl::GetRect( Rect *r )
5ca0d812 1138{
6cce68ea 1139 GetControlBounds( m_controlRef , r );
5ca0d812
SC
1140}
1141
9d8aca48 1142void wxMacControl::GetRectInWindowCoords( Rect *r )
5ca0d812 1143{
6cce68ea 1144 UMAGetControlBoundsInWindowCoords( m_controlRef , r );
5ca0d812
SC
1145}
1146
9d8aca48 1147void wxMacControl::GetBestRect( Rect *r )
5ca0d812 1148{
6cce68ea 1149 short baselineoffset;
8638e69b 1150
6cce68ea 1151 GetBestControlRect( m_controlRef , r , &baselineoffset );
5ca0d812
SC
1152}
1153
fb5246be 1154void wxMacControl::SetLabel( const wxString &title )
5ca0d812 1155{
10a59880
RD
1156 wxFontEncoding encoding;
1157
1158 if ( m_font.Ok() )
1159 encoding = m_font.GetEncoding();
1160 else
1161 encoding = wxFont::GetDefaultEncoding();
9d8aca48 1162
6cce68ea 1163 UMASetControlTitle( m_controlRef , title , encoding );
5ca0d812
SC
1164}
1165
1166void wxMacControl::GetFeatures( UInt32 * features )
1167{
6cce68ea 1168 GetControlFeatures( m_controlRef , features );
5ca0d812
SC
1169}
1170
9d8aca48 1171OSStatus wxMacControl::GetRegion( ControlPartCode partCode , RgnHandle region )
5ca0d812 1172{
6cce68ea 1173 OSStatus err = GetControlRegion( m_controlRef , partCode , region );
6cce68ea 1174 return err;
5ca0d812
SC
1175}
1176
9d8aca48 1177OSStatus wxMacControl::SetZOrder( bool above , wxMacControl* other )
5ca0d812
SC
1178{
1179#if TARGET_API_MAC_OSX
9d8aca48 1180 return HIViewSetZOrder( m_controlRef,above ? kHIViewZOrderAbove : kHIViewZOrderBelow,
6cce68ea 1181 (other != NULL) ? other->m_controlRef : NULL);
5ca0d812 1182#else
6cce68ea 1183 return 0;
5ca0d812
SC
1184#endif
1185}
1186
5ca0d812
SC
1187#if TARGET_API_MAC_OSX
1188// SetNeedsDisplay would not invalidate the children
1189static void InvalidateControlAndChildren( HIViewRef control )
1190{
6cce68ea
SC
1191 HIViewSetNeedsDisplay( control , true );
1192 UInt16 childrenCount = 0;
1193 OSStatus err = CountSubControls( control , &childrenCount );
5ca0d812 1194 if ( err == errControlIsNotEmbedder )
6cce68ea 1195 return;
8638e69b 1196
6cce68ea 1197 wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") );
5ca0d812 1198
6cce68ea 1199 for ( UInt16 i = childrenCount; i >=1; --i )
5ca0d812 1200 {
6cce68ea 1201 HIViewRef child;
8638e69b 1202
6cce68ea 1203 err = GetIndexedSubControl( control , i , & child );
5ca0d812 1204 if ( err == errControlIsNotEmbedder )
6cce68ea 1205 return;
8638e69b 1206
6cce68ea 1207 InvalidateControlAndChildren( child );
5ca0d812
SC
1208 }
1209}
1210#endif
1211
9d8aca48 1212void wxMacControl::InvalidateWithChildren()
5ca0d812
SC
1213{
1214#if TARGET_API_MAC_OSX
6cce68ea 1215 InvalidateControlAndChildren( m_controlRef );
5ca0d812
SC
1216#endif
1217}
1218
fb5246be 1219void wxMacControl::ScrollRect( wxRect *r , int dx , int dy )
5ca0d812 1220{
6cce68ea 1221 wxASSERT( r != NULL );
8638e69b 1222
e779b609
SC
1223 HIRect scrollarea = CGRectMake( r->x , r->y , r->width , r->height);
1224 HIViewScrollRect ( m_controlRef , &scrollarea , dx ,dy );
5ca0d812
SC
1225}
1226
6cce68ea
SC
1227OSType wxMacCreator = 'WXMC';
1228OSType wxMacControlProperty = 'MCCT';
1229
88a7a4e1 1230void wxMacControl::SetReferenceInNativeControl()
6cce68ea
SC
1231{
1232 void * data = this;
1233 verify_noerr( SetControlProperty ( m_controlRef ,
1234 wxMacCreator,wxMacControlProperty, sizeof(data), &data ) );
1235}
1236
88a7a4e1 1237wxMacControl* wxMacControl::GetReferenceFromNativeControl(ControlRef control)
6cce68ea
SC
1238{
1239 wxMacControl* ctl = NULL;
1240 UInt32 actualSize;
1241 if ( GetControlProperty( control ,wxMacCreator,wxMacControlProperty, sizeof(ctl) ,
1242 &actualSize , &ctl ) == noErr )
1243 {
1244 return ctl;
1245 }
1246 return NULL;
1247}
1248
1249// ============================================================================
1250// DataBrowser Wrapper
1251// ============================================================================
1252//
1253// basing on DataBrowserItemIDs
1254//
1255
1256pascal void wxMacDataBrowserControl::DataBrowserItemNotificationProc(
1257 ControlRef browser,
1258 DataBrowserItemID itemID,
1259 DataBrowserItemNotification message,
1260 DataBrowserItemDataRef itemData )
1261{
1262 wxMacDataBrowserControl* ctl = dynamic_cast<wxMacDataBrowserControl*>( wxMacControl::GetReferenceFromNativeControl( browser ) );
1263 if ( ctl != 0 )
1264 {
1265 ctl->ItemNotification(itemID, message, itemData);
1266 }
1267}
1268
1269pascal OSStatus wxMacDataBrowserControl::DataBrowserGetSetItemDataProc(
1270 ControlRef browser,
1271 DataBrowserItemID itemID,
1272 DataBrowserPropertyID property,
1273 DataBrowserItemDataRef itemData,
1274 Boolean changeValue )
1275{
1276 OSStatus err = errDataBrowserPropertyNotSupported;
6cce68ea
SC
1277 wxMacDataBrowserControl* ctl = dynamic_cast<wxMacDataBrowserControl*>( wxMacControl::GetReferenceFromNativeControl( browser ) );
1278 if ( ctl != 0 )
1279 {
1280 err = ctl->GetSetItemData(itemID, property, itemData, changeValue);
1281 }
1282 return err;
1283}
1284
1285pascal Boolean wxMacDataBrowserControl::DataBrowserCompareProc(
88a7a4e1
WS
1286 ControlRef browser,
1287 DataBrowserItemID itemOneID,
1288 DataBrowserItemID itemTwoID,
1289 DataBrowserPropertyID sortProperty)
6cce68ea
SC
1290{
1291 wxMacDataBrowserControl* ctl = dynamic_cast<wxMacDataBrowserControl*>( wxMacControl::GetReferenceFromNativeControl( browser ) );
1292 if ( ctl != 0 )
1293 {
1294 return ctl->CompareItems(itemOneID, itemTwoID, sortProperty);
1295 }
1296 return false;
1297}
1298
1299DataBrowserItemDataUPP gDataBrowserItemDataUPP = NULL;
1300DataBrowserItemNotificationUPP gDataBrowserItemNotificationUPP = NULL;
1301DataBrowserItemCompareUPP gDataBrowserItemCompareUPP = NULL;
1302
1303wxMacDataBrowserControl::wxMacDataBrowserControl( wxWindow* peer, const wxPoint& pos, const wxSize& size, long style) : wxMacControl( peer )
88a7a4e1 1304{
6cce68ea
SC
1305 Rect bounds = wxMacGetBoundsForControl( peer, pos, size );
1306 OSStatus err = ::CreateDataBrowserControl(
1307 MAC_WXHWND(peer->MacGetTopLevelWindowRef()),
1308 &bounds, kDataBrowserListView, &m_controlRef );
1309 SetReferenceInNativeControl();
1310 verify_noerr( err );
1311 if ( gDataBrowserItemCompareUPP == NULL )
1312 gDataBrowserItemCompareUPP = NewDataBrowserItemCompareUPP(DataBrowserCompareProc);
1313 if ( gDataBrowserItemDataUPP == NULL )
1314 gDataBrowserItemDataUPP = NewDataBrowserItemDataUPP(DataBrowserGetSetItemDataProc);
1315 if ( gDataBrowserItemNotificationUPP == NULL )
1316 {
1317 gDataBrowserItemNotificationUPP =
1318#if TARGET_API_MAC_OSX
1319 (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc);
1320#else
1321 NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc);
1322#endif
1323 }
1324
1325 DataBrowserCallbacks callbacks;
1326 InitializeDataBrowserCallbacks( &callbacks, kDataBrowserLatestCallbacks );
1327
1328 callbacks.u.v1.itemDataCallback = gDataBrowserItemDataUPP;
1329 callbacks.u.v1.itemCompareCallback = gDataBrowserItemCompareUPP;
1330 callbacks.u.v1.itemNotificationCallback = gDataBrowserItemNotificationUPP;
1331 SetCallbacks( &callbacks );
1332
1333}
1334
1335OSStatus wxMacDataBrowserControl::GetItemCount( DataBrowserItemID container,
1336 Boolean recurse,
1337 DataBrowserItemState state,
88a7a4e1 1338 UInt32 *numItems) const
6cce68ea 1339{
88a7a4e1 1340 return GetDataBrowserItemCount( m_controlRef, container, recurse, state, numItems );
6cce68ea
SC
1341}
1342
1343OSStatus wxMacDataBrowserControl::GetItems( DataBrowserItemID container,
1344 Boolean recurse,
1345 DataBrowserItemState state,
88a7a4e1 1346 Handle items) const
6cce68ea 1347{
88a7a4e1 1348 return GetDataBrowserItems( m_controlRef, container, recurse, state, items );
6cce68ea
SC
1349}
1350
1351OSStatus wxMacDataBrowserControl::SetSelectionFlags( DataBrowserSelectionFlags options )
1352{
1353 return SetDataBrowserSelectionFlags( m_controlRef, options );
1354}
1355
1356OSStatus wxMacDataBrowserControl::AddColumn( DataBrowserListViewColumnDesc *columnDesc,
1357 DataBrowserTableViewColumnIndex position )
1358{
1359 return AddDataBrowserListViewColumn( m_controlRef, columnDesc, position );
1360}
1361
e2bc1d69
KO
1362OSStatus wxMacDataBrowserControl::GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id ){
1363 return GetDataBrowserTableViewColumnProperty( m_controlRef, position, id );
1364}
1365
1366OSStatus wxMacDataBrowserControl::RemoveColumn( DataBrowserTableViewColumnIndex position )
1367{
1368 DataBrowserTableViewColumnID id;
1369 GetColumnIDFromIndex( position, &id );
1370 return RemoveDataBrowserTableViewColumn( m_controlRef, id );
1371}
1372
6cce68ea
SC
1373OSStatus wxMacDataBrowserControl::AutoSizeColumns()
1374{
1375 return AutoSizeDataBrowserListViewColumns(m_controlRef);
1376}
1377
1378OSStatus wxMacDataBrowserControl::SetHasScrollBars( bool horiz, bool vert )
1379{
1380 return SetDataBrowserHasScrollBars( m_controlRef, horiz, vert );
1381}
1382
1383OSStatus wxMacDataBrowserControl::SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle )
1384{
1385 return SetDataBrowserTableViewHiliteStyle( m_controlRef, hiliteStyle );
1386}
1387
1388OSStatus wxMacDataBrowserControl::SetHeaderButtonHeight(UInt16 height)
1389{
1390 return SetDataBrowserListViewHeaderBtnHeight( m_controlRef, height );
1391}
1392
1393OSStatus wxMacDataBrowserControl::GetHeaderButtonHeight(UInt16 *height)
1394{
1395 return GetDataBrowserListViewHeaderBtnHeight( m_controlRef, height );
1396}
1397
1398OSStatus wxMacDataBrowserControl::SetCallbacks(const DataBrowserCallbacks *callbacks)
1399{
1400 return SetDataBrowserCallbacks( m_controlRef, callbacks );
1401}
1402
88a7a4e1 1403OSStatus wxMacDataBrowserControl::UpdateItems(
6cce68ea
SC
1404 DataBrowserItemID container,
1405 UInt32 numItems,
1406 const DataBrowserItemID *items,
1407 DataBrowserPropertyID preSortProperty,
1408 DataBrowserPropertyID propertyID ) const
1409{
1410 return UpdateDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty, propertyID );
1411}
1412
1413bool wxMacDataBrowserControl::IsItemSelected( DataBrowserItemID item ) const
1414{
1415 return IsDataBrowserItemSelected( m_controlRef, item );
1416}
1417
1418OSStatus wxMacDataBrowserControl::AddItems(
1419 DataBrowserItemID container,
1420 UInt32 numItems,
1421 const DataBrowserItemID *items,
1422 DataBrowserPropertyID preSortProperty )
1423{
1424 return AddDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
1425}
1426
1427OSStatus wxMacDataBrowserControl::RemoveItems(
1428 DataBrowserItemID container,
1429 UInt32 numItems,
1430 const DataBrowserItemID *items,
1431 DataBrowserPropertyID preSortProperty )
1432{
1433 return RemoveDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
1434}
1435
1436OSStatus wxMacDataBrowserControl::RevealItem(
1437 DataBrowserItemID item,
1438 DataBrowserPropertyID propertyID,
1439 DataBrowserRevealOptions options ) const
1440{
1441 return RevealDataBrowserItem( m_controlRef, item, propertyID, options );
1442}
1443
1444OSStatus wxMacDataBrowserControl::SetSelectedItems(
1445 UInt32 numItems,
1446 const DataBrowserItemID *items,
1447 DataBrowserSetOption operation )
1448{
1449 return SetDataBrowserSelectedItems( m_controlRef, numItems, items, operation );
1450}
1451
1452OSStatus wxMacDataBrowserControl::GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const
1453{
1454 return GetDataBrowserSelectionAnchor( m_controlRef, first, last );
1455}
1456
1457OSStatus wxMacDataBrowserControl::GetItemID( DataBrowserTableViewRowIndex row, DataBrowserItemID * item ) const
1458{
1459 return GetDataBrowserTableViewItemID( m_controlRef, row, item );
1460}
1461
1462OSStatus wxMacDataBrowserControl::GetItemRow( DataBrowserItemID item, DataBrowserTableViewRowIndex * row ) const
1463{
1464 return GetDataBrowserTableViewItemRow( m_controlRef, item, row );
1465}
1466
88a7a4e1 1467OSStatus wxMacDataBrowserControl::SetDefaultRowHeight( UInt16 height )
6cce68ea 1468{
88a7a4e1 1469 return SetDataBrowserTableViewRowHeight( m_controlRef , height );
6cce68ea
SC
1470}
1471
88a7a4e1 1472OSStatus wxMacDataBrowserControl::GetDefaultRowHeight( UInt16 * height ) const
6cce68ea 1473{
88a7a4e1 1474 return GetDataBrowserTableViewRowHeight( m_controlRef, height );
6cce68ea 1475}
88a7a4e1
WS
1476
1477OSStatus wxMacDataBrowserControl::SetRowHeight( DataBrowserItemID item , UInt16 height)
6cce68ea
SC
1478{
1479 return SetDataBrowserTableViewItemRowHeight( m_controlRef, item , height );
1480}
1481
88a7a4e1 1482OSStatus wxMacDataBrowserControl::GetRowHeight( DataBrowserItemID item , UInt16 *height) const
6cce68ea
SC
1483{
1484 return GetDataBrowserTableViewItemRowHeight( m_controlRef, item , height);
1485}
1486
88a7a4e1 1487OSStatus wxMacDataBrowserControl::GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const
6cce68ea
SC
1488{
1489 return GetDataBrowserTableViewNamedColumnWidth( m_controlRef , column , width );
1490}
1491
88a7a4e1 1492OSStatus wxMacDataBrowserControl::SetColumnWidth( DataBrowserPropertyID column , UInt16 width )
6cce68ea
SC
1493{
1494 return SetDataBrowserTableViewNamedColumnWidth( m_controlRef , column , width );
1495}
1496
88a7a4e1 1497OSStatus wxMacDataBrowserControl::GetDefaultColumnWidth( UInt16 *width ) const
6cce68ea
SC
1498{
1499 return GetDataBrowserTableViewColumnWidth( m_controlRef , width );
1500}
1501
88a7a4e1 1502OSStatus wxMacDataBrowserControl::SetDefaultColumnWidth( UInt16 width )
6cce68ea
SC
1503{
1504 return SetDataBrowserTableViewColumnWidth( m_controlRef , width );
1505}
1506
88a7a4e1 1507OSStatus wxMacDataBrowserControl::GetColumnCount(UInt32* numColumns) const
6cce68ea
SC
1508{
1509 return GetDataBrowserTableViewColumnCount( m_controlRef, numColumns);
1510}
1511
88a7a4e1 1512OSStatus wxMacDataBrowserControl::GetColumnPosition( DataBrowserPropertyID column,
6cce68ea
SC
1513 UInt32 *position) const
1514{
1515 return GetDataBrowserTableViewColumnPosition( m_controlRef , column , position);
1516}
1517
88a7a4e1 1518OSStatus wxMacDataBrowserControl::SetColumnPosition( DataBrowserPropertyID column, UInt32 position)
6cce68ea
SC
1519{
1520 return SetDataBrowserTableViewColumnPosition( m_controlRef , column , position);
1521}
1522
88a7a4e1 1523OSStatus wxMacDataBrowserControl::GetScrollPosition( UInt32 *top , UInt32 *left ) const
6cce68ea
SC
1524{
1525 return GetDataBrowserScrollPosition( m_controlRef , top , left );
1526}
1527
88a7a4e1 1528OSStatus wxMacDataBrowserControl::SetScrollPosition( UInt32 top , UInt32 left )
6cce68ea
SC
1529{
1530 return SetDataBrowserScrollPosition( m_controlRef , top , left );
1531}
1532
88a7a4e1 1533OSStatus wxMacDataBrowserControl::GetSortProperty( DataBrowserPropertyID *column ) const
6cce68ea
SC
1534{
1535 return GetDataBrowserSortProperty( m_controlRef , column );
1536}
1537
88a7a4e1 1538OSStatus wxMacDataBrowserControl::SetSortProperty( DataBrowserPropertyID column )
6cce68ea
SC
1539{
1540 return SetDataBrowserSortProperty( m_controlRef , column );
1541}
88a7a4e1
WS
1542
1543OSStatus wxMacDataBrowserControl::GetSortOrder( DataBrowserSortOrder *order ) const
6cce68ea
SC
1544{
1545 return GetDataBrowserSortOrder( m_controlRef , order );
1546}
1547
88a7a4e1 1548OSStatus wxMacDataBrowserControl::SetSortOrder( DataBrowserSortOrder order )
6cce68ea
SC
1549{
1550 return SetDataBrowserSortOrder( m_controlRef , order );
1551}
1552
88a7a4e1
WS
1553OSStatus wxMacDataBrowserControl::GetPropertyFlags( DataBrowserPropertyID property,
1554 DataBrowserPropertyFlags *flags ) const
6cce68ea
SC
1555{
1556 return GetDataBrowserPropertyFlags( m_controlRef , property , flags );
1557}
1558
88a7a4e1
WS
1559OSStatus wxMacDataBrowserControl::SetPropertyFlags( DataBrowserPropertyID property,
1560 DataBrowserPropertyFlags flags )
6cce68ea
SC
1561{
1562 return SetDataBrowserPropertyFlags( m_controlRef , property , flags );
1563}
1564
88a7a4e1
WS
1565OSStatus wxMacDataBrowserControl::GetHeaderDesc( DataBrowserPropertyID property,
1566 DataBrowserListViewHeaderDesc *desc ) const
6cce68ea
SC
1567{
1568 return GetDataBrowserListViewHeaderDesc( m_controlRef , property , desc );
1569}
1570
88a7a4e1
WS
1571OSStatus wxMacDataBrowserControl::SetHeaderDesc( DataBrowserPropertyID property,
1572 DataBrowserListViewHeaderDesc *desc )
6cce68ea 1573{
88a7a4e1 1574 return SetDataBrowserListViewHeaderDesc( m_controlRef , property , desc );
6cce68ea
SC
1575}
1576
88a7a4e1
WS
1577OSStatus wxMacDataBrowserControl::SetDisclosureColumn( DataBrowserPropertyID property ,
1578 Boolean expandableRows )
6cce68ea
SC
1579{
1580 return SetDataBrowserListViewDisclosureColumn( m_controlRef, property, expandableRows);
1581}
1582
1583// ============================================================================
88a7a4e1 1584// Higher-level Databrowser
6cce68ea
SC
1585// ============================================================================
1586//
1587// basing on data item objects
1588//
1589
1590wxMacDataItem::wxMacDataItem()
88a7a4e1 1591{
e2bc1d69
KO
1592 m_data = NULL;
1593 m_order = 0;
1594 m_colId = kTextColumnId; // for compat with existing wx*ListBox impls.
6cce68ea
SC
1595}
1596
88a7a4e1
WS
1597wxMacDataItem::~wxMacDataItem()
1598{
6cce68ea 1599}
88a7a4e1 1600
e2bc1d69 1601void wxMacDataItem::SetOrder( SInt32 order )
6cce68ea 1602{
e2bc1d69
KO
1603 m_order = order;
1604}
1605
1606SInt32 wxMacDataItem::GetOrder() const
1607{
1608 return m_order;
1609}
1610
1611void wxMacDataItem::SetData( void* data)
1612{
1613 m_data = data;
1614}
1615
1616void* wxMacDataItem::GetData() const
1617{
1618 return m_data;
1619}
1620
1621short wxMacDataItem::GetColumn()
1622{
1623 return m_colId;
1624}
1625
1626void wxMacDataItem::SetColumn( short col )
1627{
1628 m_colId = col;
1629}
1630
1631void wxMacDataItem::SetLabel( const wxString& str)
1632{
1633 m_label = str;
1634 m_cfLabel.Assign( str , wxLocale::GetSystemEncoding());
6cce68ea
SC
1635}
1636
e2bc1d69
KO
1637const wxString& wxMacDataItem::GetLabel() const
1638{
1639 return m_label;
1640}
1641
1642bool wxMacDataItem::IsLessThan(wxMacDataItemBrowserControl *owner ,
1643 const wxMacDataItem* rhs,
1644 DataBrowserPropertyID sortProperty) const
1645{
1646 const wxMacDataItem* otherItem = dynamic_cast<const wxMacDataItem*>(rhs);
1647 bool retval = false;
1648
1649 if ( sortProperty == m_colId ){
1650 retval = m_label.CmpNoCase( otherItem->m_label) < 0;
1651 }
1652
1653 else if ( sortProperty == kNumericOrderColumnId )
1654 retval = m_order < otherItem->m_order;
1655
1656 return retval;
1657}
1658
1659OSStatus wxMacDataItem::GetSetData( wxMacDataItemBrowserControl *owner ,
6cce68ea
SC
1660 DataBrowserPropertyID property,
1661 DataBrowserItemDataRef itemData,
88a7a4e1 1662 bool changeValue )
6cce68ea 1663{
e2bc1d69
KO
1664 OSStatus err = errDataBrowserPropertyNotSupported;
1665 if ( !changeValue )
1666 {
1667 if ( property == m_colId ){
1668 err = ::SetDataBrowserItemDataText( itemData, m_cfLabel );
1669 err = noErr;
1670 }
1671 else if ( property == kNumericOrderColumnId ){
1672 err = ::SetDataBrowserItemDataValue( itemData, m_order );
1673 err = noErr;
1674 }
1675 else{
1676 }
1677 }
1678 else
1679 {
1680 switch (property)
1681 {
1682 // no editable props here
1683 default:
1684 break;
1685 }
1686 }
1687
1688 return err;
6cce68ea
SC
1689}
1690
88a7a4e1 1691void wxMacDataItem::Notification(wxMacDataItemBrowserControl *owner ,
6cce68ea
SC
1692 DataBrowserItemNotification message,
1693 DataBrowserItemDataRef itemData ) const
1694{
1695}
1696
1697
88a7a4e1 1698wxMacDataItemBrowserControl::wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style) :
6cce68ea 1699 wxMacDataBrowserControl( peer, pos, size, style )
88a7a4e1 1700{
6cce68ea 1701 m_suppressSelection = false;
e2bc1d69
KO
1702 m_sortOrder = SortOrder_None;
1703 m_clientDataItemsType = wxClientData_None;
1704}
1705
1706wxMacDataItem* wxMacDataItemBrowserControl::CreateItem()
1707{
1708 return new wxMacDataItem();
6cce68ea 1709}
88a7a4e1
WS
1710
1711wxMacDataItemBrowserSelectionSuppressor::wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser)
6cce68ea
SC
1712{
1713 m_former = browser->SuppressSelection(true);
1714 m_browser = browser;
1715}
1716
1717wxMacDataItemBrowserSelectionSuppressor::~wxMacDataItemBrowserSelectionSuppressor()
1718{
1719 m_browser->SuppressSelection(m_former);
1720}
1721
1722bool wxMacDataItemBrowserControl::SuppressSelection( bool suppress )
1723{
1724 bool former = m_suppressSelection;
1725 m_suppressSelection = suppress;
1726
1727 return former;
1728}
1729
88a7a4e1
WS
1730Boolean wxMacDataItemBrowserControl::CompareItems(DataBrowserItemID itemOneID,
1731 DataBrowserItemID itemTwoID,
1732 DataBrowserPropertyID sortProperty)
6cce68ea
SC
1733{
1734 wxMacDataItem* itemOne = (wxMacDataItem*) itemOneID;
1735 wxMacDataItem* itemTwo = (wxMacDataItem*) itemTwoID;
1736 return CompareItems( itemOne , itemTwo , sortProperty );
1737}
1738
88a7a4e1
WS
1739Boolean wxMacDataItemBrowserControl::CompareItems(const wxMacDataItem* itemOne,
1740 const wxMacDataItem* itemTwo,
1741 DataBrowserPropertyID sortProperty)
6cce68ea
SC
1742{
1743 Boolean retval = false;
1744 if ( itemOne != NULL )
1745 retval = itemOne->IsLessThan( this , itemTwo , sortProperty);
1746 return retval;
1747}
1748
1749OSStatus wxMacDataItemBrowserControl::GetSetItemData(
1750 DataBrowserItemID itemID,
1751 DataBrowserPropertyID property,
1752 DataBrowserItemDataRef itemData,
88a7a4e1 1753 Boolean changeValue )
6cce68ea
SC
1754{
1755 wxMacDataItem* item = (wxMacDataItem*) itemID;
1756 return GetSetItemData(item, property, itemData , changeValue );
1757}
1758
1759OSStatus wxMacDataItemBrowserControl::GetSetItemData(
1760 wxMacDataItem* item,
1761 DataBrowserPropertyID property,
1762 DataBrowserItemDataRef itemData,
88a7a4e1 1763 Boolean changeValue )
6cce68ea
SC
1764{
1765 OSStatus err = errDataBrowserPropertyNotSupported;
1766 switch( property )
1767 {
1768 case kDataBrowserContainerIsClosableProperty :
1769 case kDataBrowserContainerIsSortableProperty :
1770 case kDataBrowserContainerIsOpenableProperty :
1771 // right now default behaviour on these
1772 break;
1773 default :
e2bc1d69
KO
1774
1775 if ( item != NULL ){
6cce68ea 1776 err = item->GetSetData( this, property , itemData , changeValue );
e2bc1d69 1777 }
6cce68ea 1778 break;
88a7a4e1 1779
6cce68ea
SC
1780 }
1781 return err;
1782}
1783
1784void wxMacDataItemBrowserControl::ItemNotification(
1785 DataBrowserItemID itemID,
1786 DataBrowserItemNotification message,
88a7a4e1 1787 DataBrowserItemDataRef itemData)
6cce68ea 1788{
88a7a4e1 1789 wxMacDataItem* item = (wxMacDataItem*) itemID;
6cce68ea
SC
1790 ItemNotification( item , message, itemData);
1791}
1792
1793void wxMacDataItemBrowserControl::ItemNotification(
1794 const wxMacDataItem* item,
1795 DataBrowserItemNotification message,
88a7a4e1 1796 DataBrowserItemDataRef itemData)
6cce68ea
SC
1797{
1798 if (item != NULL)
1799 item->Notification( this, message, itemData);
1800}
1801
88a7a4e1
WS
1802unsigned int wxMacDataItemBrowserControl::GetItemCount(const wxMacDataItem* container,
1803 bool recurse , DataBrowserItemState state) const
6cce68ea
SC
1804{
1805 UInt32 numItems = 0;
88a7a4e1
WS
1806 verify_noerr( wxMacDataBrowserControl::GetItemCount( (DataBrowserItemID)container,
1807 recurse, state, &numItems ) );
6cce68ea
SC
1808 return numItems;
1809}
1810
e2bc1d69
KO
1811unsigned int wxMacDataItemBrowserControl::GetSelectedItemCount( const wxMacDataItem* container,
1812 bool recurse ) const
1813{
1814 return GetItemCount( container, recurse, kDataBrowserItemIsSelected );
1815
1816}
1817
88a7a4e1
WS
1818void wxMacDataItemBrowserControl::GetItems(const wxMacDataItem* container,
1819 bool recurse , DataBrowserItemState state, wxArrayMacDataItemPtr &items) const
6cce68ea
SC
1820{
1821 Handle handle = NewHandle(0);
88a7a4e1
WS
1822 verify_noerr( wxMacDataBrowserControl::GetItems( (DataBrowserItemID)container ,
1823 recurse , state, handle) );
6cce68ea
SC
1824
1825 int itemCount = GetHandleSize(handle)/sizeof(DataBrowserItemID);
1826 HLock( handle );
1827 wxMacDataItemPtr* itemsArray = (wxMacDataItemPtr*) *handle;
1828 for ( int i = 0; i < itemCount; ++i)
1829 {
1830 items.Add(itemsArray[i]);
1831 }
1832 HUnlock( handle );
1833 DisposeHandle( handle );
1834}
1835
1836unsigned int wxMacDataItemBrowserControl::GetLineFromItem(const wxMacDataItem* item) const
1837{
1838 DataBrowserTableViewRowIndex row;
1839 OSStatus err = GetItemRow( (DataBrowserItemID) item , &row);
1840 wxASSERT( err == noErr);
1841 return row;
1842}
1843
1844wxMacDataItem* wxMacDataItemBrowserControl::GetItemFromLine(unsigned int n) const
1845{
1846 DataBrowserItemID id;
1847 OSStatus err = GetItemID( (DataBrowserTableViewRowIndex) n , &id);
1848 wxASSERT( err == noErr);
88a7a4e1 1849 return (wxMacDataItem*) id;
6cce68ea
SC
1850}
1851
88a7a4e1 1852void wxMacDataItemBrowserControl::UpdateItem(const wxMacDataItem *container,
6cce68ea
SC
1853 const wxMacDataItem *item , DataBrowserPropertyID property) const
1854{
88a7a4e1 1855 verify_noerr( wxMacDataBrowserControl::UpdateItems((DataBrowserItemID)container, 1,
6cce68ea
SC
1856 (DataBrowserItemID*) &item, kDataBrowserItemNoProperty /* notSorted */, property ) );
1857}
1858
88a7a4e1 1859void wxMacDataItemBrowserControl::UpdateItems(const wxMacDataItem *container,
6cce68ea
SC
1860 wxArrayMacDataItemPtr &itemArray , DataBrowserPropertyID property) const
1861{
1862 unsigned int noItems = itemArray.GetCount();
1863 DataBrowserItemID *items = new DataBrowserItemID[noItems];
1864 for ( unsigned int i = 0; i < noItems; ++i )
1865 items[i] = (DataBrowserItemID) itemArray[i];
1866
88a7a4e1 1867 verify_noerr( wxMacDataBrowserControl::UpdateItems((DataBrowserItemID)container, noItems,
6cce68ea
SC
1868 items, kDataBrowserItemNoProperty /* notSorted */, property ) );
1869 delete [] items;
1870}
1871
e2bc1d69
KO
1872void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyType colType,
1873 const wxString& title, SInt16 just, int minWidth, int maxWidth)
1874{
1875 DataBrowserListViewColumnDesc columnDesc;
1876 columnDesc.headerBtnDesc.titleOffset = 0;
1877 columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
1878
1879 columnDesc.headerBtnDesc.btnFontStyle.flags =
1880 kControlUseFontMask | kControlUseJustMask;
1881
1882 columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlContentTextOnly;
1883 columnDesc.headerBtnDesc.btnFontStyle.just = just;
1884 columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
1885 columnDesc.headerBtnDesc.btnFontStyle.style = normal;
1886
1887 // TODO: Why is m_font not defined when we enter wxLC_LIST mode, but is
1888 // defined for other modes?
1889 wxFontEncoding enc;
1890 if ( m_font.Ok() )
1891 enc = m_font.GetEncoding();
1892 else
1893 enc = wxLocale::GetSystemEncoding();
1894 wxMacCFStringHolder cfTitle;
1895 cfTitle.Assign( title, enc );
1896 columnDesc.headerBtnDesc.titleString = cfTitle;
1897
1898 int colMinWidth = 0;
1899 if (minWidth != -1)
1900 colMinWidth = minWidth;
1901 columnDesc.headerBtnDesc.minimumWidth = colMinWidth;
1902
1903 int colMaxWidth = 500;
1904 if (maxWidth != -1)
1905 colMaxWidth = maxWidth;
1906 columnDesc.headerBtnDesc.maximumWidth = colMaxWidth;
1907
1908 columnDesc.propertyDesc.propertyID = (kMinColumnId + colId);
1909 columnDesc.propertyDesc.propertyType = colType;
1910 columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewDefaultColumnFlags | kDataBrowserListViewNoGapForIconInHeaderButton;
1911#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
1912 columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
1913#endif
1914
1915 verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
1916}
1917
1918void wxMacDataItemBrowserControl::SetColumnWidth(int colId, int width)
1919{
1920 DataBrowserPropertyID id;
1921 GetColumnIDFromIndex(colId, &id);
1922 verify_noerr( wxMacDataBrowserControl::SetColumnWidth(id, width));
1923}
1924
1925int wxMacDataItemBrowserControl::GetColumnWidth(int colId)
1926{
1927 DataBrowserPropertyID id;
1928 GetColumnIDFromIndex(colId, &id);
1929 UInt16 result;
1930 verify_noerr( wxMacDataBrowserControl::GetColumnWidth(id, &result));
1931 return result;
1932}
1933
6cce68ea
SC
1934void wxMacDataItemBrowserControl::AddItem(wxMacDataItem *container, wxMacDataItem *item)
1935{
88a7a4e1 1936 verify_noerr( wxMacDataBrowserControl::AddItems( (DataBrowserItemID)container, 1,
6cce68ea
SC
1937 (DataBrowserItemID*) &item, kDataBrowserItemNoProperty ) );
1938}
1939
88a7a4e1 1940void wxMacDataItemBrowserControl::AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &itemArray )
6cce68ea
SC
1941{
1942 unsigned int noItems = itemArray.GetCount();
1943 DataBrowserItemID *items = new DataBrowserItemID[noItems];
1944 for ( unsigned int i = 0; i < noItems; ++i )
1945 items[i] = (DataBrowserItemID) itemArray[i];
1946
88a7a4e1 1947 verify_noerr( wxMacDataBrowserControl::AddItems( (DataBrowserItemID)container, noItems,
6cce68ea
SC
1948 (DataBrowserItemID*) items, kDataBrowserItemNoProperty ) );
1949 delete [] items;
1950}
1951
88a7a4e1 1952void wxMacDataItemBrowserControl::RemoveItem(wxMacDataItem *container, wxMacDataItem* item)
6cce68ea 1953{
88a7a4e1 1954 OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, 1,
6cce68ea
SC
1955 (UInt32*) &item, kDataBrowserItemNoProperty );
1956 verify_noerr( err );
1957}
1958
88a7a4e1 1959void wxMacDataItemBrowserControl::RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &itemArray)
6cce68ea
SC
1960{
1961 unsigned int noItems = itemArray.GetCount();
1962 DataBrowserItemID *items = new DataBrowserItemID[noItems];
1963 for ( unsigned int i = 0; i < noItems; ++i )
1964 items[i] = (DataBrowserItemID) itemArray[i];
1965
88a7a4e1 1966 OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, noItems,
6cce68ea
SC
1967 (UInt32*) items, kDataBrowserItemNoProperty );
1968 verify_noerr( err );
1969 delete [] items;
1970}
1971
88a7a4e1 1972void wxMacDataItemBrowserControl::RemoveAllItems(wxMacDataItem *container)
6cce68ea
SC
1973{
1974 OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, 0 , NULL , kDataBrowserItemNoProperty );
1975 verify_noerr( err );
1976}
1977
88a7a4e1 1978void wxMacDataItemBrowserControl::SetSelectedItem(wxMacDataItem* item , DataBrowserSetOption option)
6cce68ea
SC
1979{
1980 verify_noerr(wxMacDataBrowserControl::SetSelectedItems( 1, (DataBrowserItemID*) &item, option ));
1981}
1982
88a7a4e1 1983void wxMacDataItemBrowserControl::SetSelectedAllItems(DataBrowserSetOption option)
6cce68ea
SC
1984{
1985 verify_noerr(wxMacDataBrowserControl::SetSelectedItems( 0 , NULL , option ));
1986}
1987
88a7a4e1 1988void wxMacDataItemBrowserControl::SetSelectedItems(wxArrayMacDataItemPtr &itemArray , DataBrowserSetOption option)
6cce68ea
SC
1989{
1990 unsigned int noItems = itemArray.GetCount();
1991 DataBrowserItemID *items = new DataBrowserItemID[noItems];
1992 for ( unsigned int i = 0; i < noItems; ++i )
1993 items[i] = (DataBrowserItemID) itemArray[i];
1994
1995 verify_noerr(wxMacDataBrowserControl::SetSelectedItems( noItems, (DataBrowserItemID*) items, option ));
1996 delete [] items;
1997}
1998
1999Boolean wxMacDataItemBrowserControl::IsItemSelected( const wxMacDataItem* item) const
2000{
2001 return wxMacDataBrowserControl::IsItemSelected( (DataBrowserItemID) item);
2002}
2003
88a7a4e1 2004void wxMacDataItemBrowserControl::RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options)
6cce68ea
SC
2005{
2006 verify_noerr(wxMacDataBrowserControl::RevealItem( (DataBrowserItemID) item, kDataBrowserNoItem , options ) );
2007}
2008
88a7a4e1 2009void wxMacDataItemBrowserControl::GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const
6cce68ea 2010{
88a7a4e1 2011 verify_noerr(wxMacDataBrowserControl::GetSelectionAnchor( (DataBrowserItemID*) first, (DataBrowserItemID*) last) );
6cce68ea
SC
2012}
2013
e2bc1d69
KO
2014wxClientDataType wxMacDataItemBrowserControl::GetClientDataType() const
2015{
2016 return m_clientDataItemsType;
2017}
2018void wxMacDataItemBrowserControl::SetClientDataType(wxClientDataType clientDataItemsType)
2019{
2020 m_clientDataItemsType = clientDataItemsType;
2021}
2022
2023unsigned int wxMacDataItemBrowserControl::MacGetCount() const
2024{
2025 return GetItemCount(wxMacDataBrowserRootContainer,false,kDataBrowserItemAnyState);
2026}
2027
2028void wxMacDataItemBrowserControl::MacDelete( unsigned int n )
2029{
2030 wxMacDataItem* item = (wxMacDataItem*)GetItemFromLine( n );
2031 RemoveItem( wxMacDataBrowserRootContainer, item );
2032}
2033
2034void wxMacDataItemBrowserControl::MacInsert( unsigned int n, const wxString& text, int column )
2035{
2036 wxMacDataItem* newItem = CreateItem();
2037 newItem->SetLabel( text );
2038 if ( column != -1 )
2039 newItem->SetColumn( kMinColumnId + column );
2040
2041 if ( m_sortOrder == SortOrder_None )
2042 {
2043 // increase the order of the lines to be shifted
2044 unsigned int lines = MacGetCount();
2045 for ( unsigned int i = n; i < lines; ++i)
2046 {
2047 wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(i);
2048 iter->SetOrder( iter->GetOrder() + 1 );
2049 }
2050
2051 SInt32 frontLineOrder = 0;
2052 if ( n > 0 )
2053 {
2054 wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(n-1);
2055 frontLineOrder = iter->GetOrder();
2056 }
2057 newItem->SetOrder( frontLineOrder + 1 );
2058 }
2059
2060 AddItem( wxMacDataBrowserRootContainer, newItem );
2061}
2062
2063void wxMacDataItemBrowserControl::MacInsert( unsigned int n, const wxArrayString& items, int column )
2064{
2065 size_t itemsCount = items.GetCount();
2066 if ( itemsCount == 0 )
2067 return;
2068
2069 SInt32 frontLineOrder = 0;
2070
2071 if ( m_sortOrder == SortOrder_None )
2072 {
2073 // increase the order of the lines to be shifted
2074 unsigned int lines = MacGetCount();
2075 for ( unsigned int i = n; i < lines; ++i)
2076 {
2077 wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(i);
2078 iter->SetOrder( iter->GetOrder() + itemsCount );
2079 }
2080 if ( n > 0 )
2081 {
2082 wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(n-1);
2083 frontLineOrder = iter->GetOrder();
2084 }
2085 }
2086
2087 wxArrayMacDataItemPtr ids;
2088 ids.SetCount( itemsCount );
2089
2090 for ( unsigned int i = 0; i < itemsCount; ++i )
2091 {
2092 wxMacDataItem* item = CreateItem();
2093 item->SetLabel( items[i]);
2094 if ( column != -1 )
2095 item->SetColumn( kMinColumnId + column );
2096
2097 if ( m_sortOrder == SortOrder_None )
2098 item->SetOrder( frontLineOrder + 1 + i );
2099
2100 ids[i] = item;
2101 }
2102
2103 AddItems( wxMacDataBrowserRootContainer, ids );
2104}
2105
2106int wxMacDataItemBrowserControl::MacAppend( const wxString& text)
2107{
2108 wxMacDataItem* item = CreateItem();
2109 item->SetLabel( text );
2110 if ( m_sortOrder == SortOrder_None )
2111 {
2112 unsigned int lines = MacGetCount();
2113 if ( lines == 0 )
2114 item->SetOrder( 1 );
2115 else
2116 {
2117 wxMacDataItem* frontItem = (wxMacDataItem*) GetItemFromLine(lines-1);
2118 item->SetOrder( frontItem->GetOrder() + 1 );
2119 }
2120 }
2121 AddItem( wxMacDataBrowserRootContainer, item );
2122
2123 return GetLineFromItem(item);
2124}
2125
2126void wxMacDataItemBrowserControl::MacClear()
2127{
2128 wxMacDataItemBrowserSelectionSuppressor suppressor(this);
2129 RemoveAllItems(wxMacDataBrowserRootContainer);
2130}
2131
2132void wxMacDataItemBrowserControl::MacDeselectAll()
2133{
2134 wxMacDataItemBrowserSelectionSuppressor suppressor(this);
2135 SetSelectedAllItems( kDataBrowserItemsRemove );
2136}
2137
2138void wxMacDataItemBrowserControl::MacSetSelection( unsigned int n, bool select, bool multi )
2139{
2140 wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine(n);
2141 wxMacDataItemBrowserSelectionSuppressor suppressor(this);
2142
2143 if ( IsItemSelected( item ) != select )
2144 {
2145 if ( select )
2146 SetSelectedItem( item, multi ? kDataBrowserItemsAdd : kDataBrowserItemsAssign );
2147 else
2148 SetSelectedItem( item, kDataBrowserItemsRemove );
2149 }
2150
2151 MacScrollTo( n );
2152}
2153
2154bool wxMacDataItemBrowserControl::MacIsSelected( unsigned int n ) const
2155{
2156 wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine(n);
2157 return IsItemSelected( item );
2158}
2159
2160int wxMacDataItemBrowserControl::MacGetSelection() const
2161{
2162 wxMacDataItemPtr first, last;
2163 GetSelectionAnchor( &first, &last );
2164
2165 if ( first != NULL )
2166 {
2167 return GetLineFromItem( first );
2168 }
2169
2170 return -1;
2171}
2172
2173int wxMacDataItemBrowserControl::MacGetSelections( wxArrayInt& aSelections ) const
2174{
2175 aSelections.Empty();
2176 wxArrayMacDataItemPtr selectedItems;
2177 GetItems( wxMacDataBrowserRootContainer, false , kDataBrowserItemIsSelected, selectedItems);
2178
2179 int count = selectedItems.GetCount();
2180
2181 for ( int i = 0; i < count; ++i)
2182 {
2183 aSelections.Add(GetLineFromItem(selectedItems[i]));
2184 }
2185
2186 return count;
2187}
2188
2189void wxMacDataItemBrowserControl::MacSetString( unsigned int n, const wxString& text )
2190{
2191 // as we don't store the strings we only have to issue a redraw
2192 wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine( n);
2193 item->SetLabel( text );
2194 UpdateItem( wxMacDataBrowserRootContainer, item , kTextColumnId );
2195}
2196
2197wxString wxMacDataItemBrowserControl::MacGetString( unsigned int n ) const
2198{
2199 wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
2200 return item->GetLabel();
2201}
2202
2203void wxMacDataItemBrowserControl::MacSetClientData( unsigned int n, void * data)
2204{
2205 wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine( n);
2206 item->SetData( data );
2207 // not displayed, therefore no Update infos to DataBrowser
2208}
2209
2210void * wxMacDataItemBrowserControl::MacGetClientData( unsigned int n) const
2211{
2212 wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
2213 return item->GetData();
2214}
2215
2216void wxMacDataItemBrowserControl::MacScrollTo( unsigned int n )
2217{
2218 RevealItem( GetItemFromLine( n) , kDataBrowserRevealWithoutSelecting );
2219}
2220
88a7a4e1 2221
6cce68ea 2222
5ca0d812
SC
2223//
2224// Tab Control
2225//
9d8aca48
WS
2226
2227OSStatus wxMacControl::SetTabEnabled( SInt16 tabNo , bool enable )
5ca0d812 2228{
6cce68ea 2229 return ::SetTabEnabled( m_controlRef , tabNo , enable );
5ca0d812 2230}
9d8aca48 2231
30e77b5c
SC
2232//
2233// Quartz Support
2234//
2235
2236#ifdef __WXMAC_OSX__
2237// snippets from Sketch Sample from Apple :
2238
8638e69b
DS
2239#define kGenericRGBProfilePathStr "/System/Library/ColorSync/Profiles/Generic RGB Profile.icc"
2240
30e77b5c 2241/*
fb5246be 2242 This function locates, opens, and returns the profile reference for the calibrated
30e77b5c
SC
2243 Generic RGB color space. It is up to the caller to call CMCloseProfile when done
2244 with the profile reference this function returns.
2245*/
8638e69b 2246CMProfileRef wxMacOpenGenericProfile()
30e77b5c
SC
2247{
2248 static CMProfileRef cachedRGBProfileRef = NULL;
fb5246be 2249
30e77b5c
SC
2250 // we only create the profile reference once
2251 if (cachedRGBProfileRef == NULL)
2252 {
fb5246be
WS
2253 CMProfileLocation loc;
2254
2255 loc.locType = cmPathBasedProfile;
2256 strcpy(loc.u.pathLoc.path, kGenericRGBProfilePathStr);
2257
2258 verify_noerr( CMOpenProfile(&cachedRGBProfileRef, &loc) );
30e77b5c
SC
2259 }
2260
8638e69b 2261 // clone the profile reference so that the caller has their own reference, not our cached one
30e77b5c 2262 if (cachedRGBProfileRef)
fb5246be 2263 CMCloneProfileRef(cachedRGBProfileRef);
30e77b5c
SC
2264
2265 return cachedRGBProfileRef;
2266}
2267
2268/*
2269 Return the generic RGB color space. This is a 'get' function and the caller should
2270 not release the returned value unless the caller retains it first. Usually callers
2271 of this routine will immediately use the returned colorspace with CoreGraphics
2272 so they typically do not need to retain it themselves.
fb5246be 2273
30e77b5c
SC
2274 This function creates the generic RGB color space once and hangs onto it so it can
2275 return it whenever this function is called.
2276*/
2277
2278CGColorSpaceRef wxMacGetGenericRGBColorSpace()
2279{
6cce68ea 2280 static wxMacCFRefHolder<CGColorSpaceRef> genericRGBColorSpace;
fb5246be 2281
8638e69b
DS
2282 if (genericRGBColorSpace == NULL)
2283 {
26a2f914 2284 if ( UMAGetSystemVersion() >= 0x1040 )
fb5246be 2285 {
6cce68ea 2286 genericRGBColorSpace.Set( CGColorSpaceCreateWithName( CFSTR("kCGColorSpaceGenericRGB") ) );
fb5246be 2287 }
26a2f914
SC
2288 else
2289 {
2290 CMProfileRef genericRGBProfile = wxMacOpenGenericProfile();
8638e69b 2291
26a2f914
SC
2292 if (genericRGBProfile)
2293 {
6cce68ea 2294 genericRGBColorSpace.Set( CGColorSpaceCreateWithPlatformColorSpace(genericRGBProfile) );
8638e69b 2295
6cce68ea 2296 wxASSERT_MSG( genericRGBColorSpace != NULL, wxT("couldn't create the generic RGB color space") );
8638e69b 2297
26a2f914 2298 // we opened the profile so it is up to us to close it
88a7a4e1 2299 CMCloseProfile(genericRGBProfile);
26a2f914
SC
2300 }
2301 }
8638e69b
DS
2302 }
2303
30e77b5c
SC
2304 return genericRGBColorSpace;
2305}
2306#endif
2307
54ce9ebb
JS
2308wxMacPortSaver::wxMacPortSaver( GrafPtr port )
2309{
6cce68ea
SC
2310 ::GetPort( &m_port );
2311 ::SetPort( port );
54ce9ebb
JS
2312}
2313
2314wxMacPortSaver::~wxMacPortSaver()
2315{
6cce68ea 2316 ::SetPort( m_port );
54ce9ebb
JS
2317}
2318
b6ed2b86 2319#endif // wxUSE_GUI