]>
Commit | Line | Data |
---|---|---|
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 | #include "MoreFilesX.h" | |
37 | ||
38 | #ifndef __DARWIN__ | |
39 | #include <Threads.h> | |
40 | #include <Sound.h> | |
41 | #endif | |
42 | ||
43 | #if wxUSE_GUI | |
44 | #if TARGET_API_MAC_OSX | |
45 | #include <CoreServices/CoreServices.h> | |
46 | #else | |
47 | #include <DriverServices.h> | |
48 | #include <Multiprocessing.h> | |
49 | #endif | |
50 | ||
51 | #include <ATSUnicode.h> | |
52 | #include <TextCommon.h> | |
53 | #include <TextEncodingConverter.h> | |
54 | #endif // wxUSE_GUI | |
55 | ||
56 | #include "wx/mac/private.h" // includes mac headers | |
57 | ||
58 | #if defined(__MWERKS__) && wxUSE_UNICODE | |
59 | #include <wtime.h> | |
60 | #endif | |
61 | ||
62 | // --------------------------------------------------------------------------- | |
63 | // code used in both base and GUI compilation | |
64 | // --------------------------------------------------------------------------- | |
65 | ||
66 | // our OS version is the same in non GUI and GUI cases | |
67 | static int DoGetOSVersion(int *majorVsn, int *minorVsn) | |
68 | { | |
69 | long theSystem ; | |
70 | ||
71 | // are there x-platform conventions ? | |
72 | ||
73 | Gestalt(gestaltSystemVersion, &theSystem) ; | |
74 | if (minorVsn != NULL) { | |
75 | *minorVsn = (theSystem & 0xFF ) ; | |
76 | } | |
77 | if (majorVsn != NULL) { | |
78 | *majorVsn = (theSystem >> 8 ) ; | |
79 | } | |
80 | #ifdef __DARWIN__ | |
81 | return wxMAC_DARWIN; | |
82 | #else | |
83 | return wxMAC; | |
84 | #endif | |
85 | } | |
86 | ||
87 | ||
88 | #if wxUSE_BASE | |
89 | ||
90 | // ---------------------------------------------------------------------------- | |
91 | // debugging support | |
92 | // ---------------------------------------------------------------------------- | |
93 | ||
94 | #if defined(__WXMAC__) && !defined(__DARWIN__) && defined(__MWERKS__) && (__MWERKS__ >= 0x2400) | |
95 | ||
96 | // MetroNub stuff doesn't seem to work in CodeWarrior 5.3 Carbon builds... | |
97 | ||
98 | #ifndef __MetroNubUtils__ | |
99 | #include "MetroNubUtils.h" | |
100 | #endif | |
101 | ||
102 | #ifndef __GESTALT__ | |
103 | #include <Gestalt.h> | |
104 | #endif | |
105 | ||
106 | #if TARGET_API_MAC_CARBON | |
107 | ||
108 | #include <CodeFragments.h> | |
109 | ||
110 | extern "C" long CallUniversalProc(UniversalProcPtr theProcPtr, ProcInfoType procInfo, ...); | |
111 | ||
112 | ProcPtr gCallUniversalProc_Proc = NULL; | |
113 | ||
114 | #endif | |
115 | ||
116 | static MetroNubUserEntryBlock* gMetroNubEntry = NULL; | |
117 | ||
118 | static long fRunOnce = false; | |
119 | ||
120 | /* --------------------------------------------------------------------------- | |
121 | IsMetroNubInstalled | |
122 | --------------------------------------------------------------------------- */ | |
123 | ||
124 | Boolean IsMetroNubInstalled() | |
125 | { | |
126 | if (!fRunOnce) | |
127 | { | |
128 | long result, value; | |
129 | ||
130 | fRunOnce = true; | |
131 | gMetroNubEntry = NULL; | |
132 | ||
133 | if (Gestalt(gestaltSystemVersion, &value) == noErr && value < 0x1000) | |
134 | { | |
135 | /* look for MetroNub's Gestalt selector */ | |
136 | if (Gestalt(kMetroNubUserSignature, &result) == noErr) | |
137 | { | |
138 | ||
139 | #if TARGET_API_MAC_CARBON | |
140 | if (gCallUniversalProc_Proc == NULL) | |
141 | { | |
142 | CFragConnectionID connectionID; | |
143 | Ptr mainAddress; | |
144 | Str255 errorString; | |
145 | ProcPtr symbolAddress; | |
146 | OSErr err; | |
147 | CFragSymbolClass symbolClass; | |
148 | ||
149 | symbolAddress = NULL; | |
150 | err = GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch, kFindCFrag, | |
151 | &connectionID, &mainAddress, errorString); | |
152 | ||
153 | if (err != noErr) | |
154 | { | |
155 | gCallUniversalProc_Proc = NULL; | |
156 | goto end; | |
157 | } | |
158 | ||
159 | err = FindSymbol(connectionID, "\pCallUniversalProc", | |
160 | (Ptr *) &gCallUniversalProc_Proc, &symbolClass); | |
161 | ||
162 | if (err != noErr) | |
163 | { | |
164 | gCallUniversalProc_Proc = NULL; | |
165 | goto end; | |
166 | } | |
167 | } | |
168 | #endif | |
169 | ||
170 | { | |
171 | MetroNubUserEntryBlock* block = (MetroNubUserEntryBlock *)result; | |
172 | ||
173 | /* make sure the version of the API is compatible */ | |
174 | if (block->apiLowVersion <= kMetroNubUserAPIVersion && | |
175 | kMetroNubUserAPIVersion <= block->apiHiVersion) | |
176 | gMetroNubEntry = block; /* success! */ | |
177 | } | |
178 | ||
179 | } | |
180 | } | |
181 | } | |
182 | ||
183 | end: | |
184 | ||
185 | #if TARGET_API_MAC_CARBON | |
186 | return (gMetroNubEntry != NULL && gCallUniversalProc_Proc != NULL); | |
187 | #else | |
188 | return (gMetroNubEntry != NULL); | |
189 | #endif | |
190 | } | |
191 | ||
192 | /* --------------------------------------------------------------------------- | |
193 | IsMWDebuggerRunning [v1 API] | |
194 | --------------------------------------------------------------------------- */ | |
195 | ||
196 | Boolean IsMWDebuggerRunning() | |
197 | { | |
198 | if (IsMetroNubInstalled()) | |
199 | return CallIsDebuggerRunningProc(gMetroNubEntry->isDebuggerRunning); | |
200 | else | |
201 | return false; | |
202 | } | |
203 | ||
204 | /* --------------------------------------------------------------------------- | |
205 | AmIBeingMWDebugged [v1 API] | |
206 | --------------------------------------------------------------------------- */ | |
207 | ||
208 | Boolean AmIBeingMWDebugged() | |
209 | { | |
210 | if (IsMetroNubInstalled()) | |
211 | return CallAmIBeingDebuggedProc(gMetroNubEntry->amIBeingDebugged); | |
212 | else | |
213 | return false; | |
214 | } | |
215 | ||
216 | extern bool WXDLLEXPORT wxIsDebuggerRunning() | |
217 | { | |
218 | return IsMWDebuggerRunning() && AmIBeingMWDebugged(); | |
219 | } | |
220 | ||
221 | #else | |
222 | ||
223 | extern bool WXDLLEXPORT wxIsDebuggerRunning() | |
224 | { | |
225 | return false; | |
226 | } | |
227 | ||
228 | #endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ >= 0x2400) | |
229 | ||
230 | ||
231 | #ifndef __DARWIN__ | |
232 | // defined in unix/utilsunx.cpp for Mac OS X | |
233 | ||
234 | // get full hostname (with domain name if possible) | |
235 | bool wxGetFullHostName(wxChar *buf, int maxSize) | |
236 | { | |
237 | return wxGetHostName(buf, maxSize); | |
238 | } | |
239 | ||
240 | // Get hostname only (without domain name) | |
241 | bool wxGetHostName(wxChar *buf, int maxSize) | |
242 | { | |
243 | // Gets Chooser name of user by examining a System resource. | |
244 | ||
245 | const short kComputerNameID = -16413; | |
246 | ||
247 | short oldResFile = CurResFile() ; | |
248 | UseResFile(0); | |
249 | StringHandle chooserName = (StringHandle)::GetString(kComputerNameID); | |
250 | UseResFile(oldResFile); | |
251 | ||
252 | if (chooserName && *chooserName) | |
253 | { | |
254 | HLock( (Handle) chooserName ) ; | |
255 | wxString name = wxMacMakeStringFromPascal( *chooserName ) ; | |
256 | HUnlock( (Handle) chooserName ) ; | |
257 | ReleaseResource( (Handle) chooserName ) ; | |
258 | wxStrncpy( buf , name , maxSize - 1 ) ; | |
259 | } | |
260 | else | |
261 | buf[0] = 0 ; | |
262 | ||
263 | return TRUE; | |
264 | } | |
265 | ||
266 | // Get user ID e.g. jacs | |
267 | bool wxGetUserId(wxChar *buf, int maxSize) | |
268 | { | |
269 | return wxGetUserName( buf , maxSize ) ; | |
270 | } | |
271 | ||
272 | const wxChar* wxGetHomeDir(wxString *pstr) | |
273 | { | |
274 | *pstr = wxMacFindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder ) ; | |
275 | return pstr->c_str() ; | |
276 | } | |
277 | ||
278 | // Get user name e.g. Stefan Csomor | |
279 | bool wxGetUserName(wxChar *buf, int maxSize) | |
280 | { | |
281 | // Gets Chooser name of user by examining a System resource. | |
282 | ||
283 | const short kChooserNameID = -16096; | |
284 | ||
285 | short oldResFile = CurResFile() ; | |
286 | UseResFile(0); | |
287 | StringHandle chooserName = (StringHandle)::GetString(kChooserNameID); | |
288 | UseResFile(oldResFile); | |
289 | ||
290 | if (chooserName && *chooserName) | |
291 | { | |
292 | HLock( (Handle) chooserName ) ; | |
293 | wxString name = wxMacMakeStringFromPascal( *chooserName ) ; | |
294 | HUnlock( (Handle) chooserName ) ; | |
295 | ReleaseResource( (Handle) chooserName ) ; | |
296 | wxStrncpy( buf , name , maxSize - 1 ) ; | |
297 | } | |
298 | else | |
299 | buf[0] = 0 ; | |
300 | ||
301 | return TRUE; | |
302 | } | |
303 | ||
304 | int wxKill(long pid, wxSignal sig , wxKillError *rc, int flags) | |
305 | { | |
306 | // TODO | |
307 | return 0; | |
308 | } | |
309 | ||
310 | WXDLLEXPORT bool wxGetEnv(const wxString& var, wxString *value) | |
311 | { | |
312 | // TODO : under classic there is no environement support, under X yes | |
313 | return false ; | |
314 | } | |
315 | ||
316 | // set the env var name to the given value, return TRUE on success | |
317 | WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value) | |
318 | { | |
319 | // TODO : under classic there is no environement support, under X yes | |
320 | return false ; | |
321 | } | |
322 | ||
323 | // | |
324 | // Execute a program in an Interactive Shell | |
325 | // | |
326 | bool wxShell(const wxString& command) | |
327 | { | |
328 | // TODO | |
329 | return FALSE; | |
330 | } | |
331 | ||
332 | // Shutdown or reboot the PC | |
333 | bool wxShutdown(wxShutdownFlags wFlags) | |
334 | { | |
335 | // TODO | |
336 | return FALSE; | |
337 | } | |
338 | ||
339 | // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) | |
340 | long wxGetFreeMemory() | |
341 | { | |
342 | return FreeMem() ; | |
343 | } | |
344 | ||
345 | #ifndef __DARWIN__ | |
346 | ||
347 | void wxMicroSleep(unsigned long microseconds) | |
348 | { | |
349 | AbsoluteTime wakeup = AddDurationToAbsolute( microseconds * durationMicrosecond , UpTime()); | |
350 | MPDelayUntil( & wakeup); | |
351 | } | |
352 | ||
353 | void wxMilliSleep(unsigned long milliseconds) | |
354 | { | |
355 | AbsoluteTime wakeup = AddDurationToAbsolute( milliseconds, UpTime()); | |
356 | MPDelayUntil( & wakeup); | |
357 | } | |
358 | ||
359 | void wxSleep(int nSecs) | |
360 | { | |
361 | wxMilliSleep(1000*nSecs); | |
362 | } | |
363 | ||
364 | #endif | |
365 | ||
366 | // Consume all events until no more left | |
367 | void wxFlushEvents() | |
368 | { | |
369 | } | |
370 | ||
371 | #endif // !__DARWIN__ | |
372 | ||
373 | // Emit a beeeeeep | |
374 | void wxBell() | |
375 | { | |
376 | SysBeep(30); | |
377 | } | |
378 | ||
379 | wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo() | |
380 | { | |
381 | static wxToolkitInfo info; | |
382 | info.os = DoGetOSVersion(&info.versionMajor, &info.versionMinor); | |
383 | info.name = _T("wxBase"); | |
384 | return info; | |
385 | } | |
386 | ||
387 | #endif // wxUSE_BASE | |
388 | ||
389 | #if wxUSE_GUI | |
390 | ||
391 | wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo() | |
392 | { | |
393 | static wxToolkitInfo info; | |
394 | info.os = DoGetOSVersion(&info.versionMajor, &info.versionMinor); | |
395 | info.shortName = _T("mac"); | |
396 | info.name = _T("wxMac"); | |
397 | #ifdef __WXUNIVERSAL__ | |
398 | info.shortName << _T("univ"); | |
399 | info.name << _T("/wxUniversal"); | |
400 | #endif | |
401 | return info; | |
402 | } | |
403 | ||
404 | // Reading and writing resources (eg WIN.INI, .Xdefaults) | |
405 | #if wxUSE_RESOURCES | |
406 | bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file) | |
407 | { | |
408 | // TODO | |
409 | return FALSE; | |
410 | } | |
411 | ||
412 | bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file) | |
413 | { | |
414 | wxString buf; | |
415 | buf.Printf(wxT("%.4f"), value); | |
416 | ||
417 | return wxWriteResource(section, entry, buf, file); | |
418 | } | |
419 | ||
420 | bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file) | |
421 | { | |
422 | wxString buf; | |
423 | buf.Printf(wxT("%ld"), value); | |
424 | ||
425 | return wxWriteResource(section, entry, buf, file); | |
426 | } | |
427 | ||
428 | bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file) | |
429 | { | |
430 | wxString buf; | |
431 | buf.Printf(wxT("%d"), value); | |
432 | ||
433 | return wxWriteResource(section, entry, buf, file); | |
434 | } | |
435 | ||
436 | bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file) | |
437 | { | |
438 | // TODO | |
439 | return FALSE; | |
440 | } | |
441 | ||
442 | bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file) | |
443 | { | |
444 | char *s = NULL; | |
445 | bool succ = wxGetResource(section, entry, (char **)&s, file); | |
446 | if (succ) | |
447 | { | |
448 | *value = (float)strtod(s, NULL); | |
449 | delete[] s; | |
450 | return TRUE; | |
451 | } | |
452 | else return FALSE; | |
453 | } | |
454 | ||
455 | bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file) | |
456 | { | |
457 | char *s = NULL; | |
458 | bool succ = wxGetResource(section, entry, (char **)&s, file); | |
459 | if (succ) | |
460 | { | |
461 | *value = strtol(s, NULL, 10); | |
462 | delete[] s; | |
463 | return TRUE; | |
464 | } | |
465 | else return FALSE; | |
466 | } | |
467 | ||
468 | bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file) | |
469 | { | |
470 | char *s = NULL; | |
471 | bool succ = wxGetResource(section, entry, (char **)&s, file); | |
472 | if (succ) | |
473 | { | |
474 | *value = (int)strtol(s, NULL, 10); | |
475 | delete[] s; | |
476 | return TRUE; | |
477 | } | |
478 | else return FALSE; | |
479 | } | |
480 | #endif // wxUSE_RESOURCES | |
481 | ||
482 | int gs_wxBusyCursorCount = 0; | |
483 | extern wxCursor gMacCurrentCursor ; | |
484 | wxCursor gMacStoredActiveCursor ; | |
485 | ||
486 | // Set the cursor to the busy cursor for all windows | |
487 | void wxBeginBusyCursor(wxCursor *cursor) | |
488 | { | |
489 | if (gs_wxBusyCursorCount++ == 0) | |
490 | { | |
491 | gMacStoredActiveCursor = gMacCurrentCursor ; | |
492 | cursor->MacInstall() ; | |
493 | } | |
494 | //else: nothing to do, already set | |
495 | } | |
496 | ||
497 | // Restore cursor to normal | |
498 | void wxEndBusyCursor() | |
499 | { | |
500 | wxCHECK_RET( gs_wxBusyCursorCount > 0, | |
501 | wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") ); | |
502 | ||
503 | if (--gs_wxBusyCursorCount == 0) | |
504 | { | |
505 | gMacStoredActiveCursor.MacInstall() ; | |
506 | gMacStoredActiveCursor = wxNullCursor ; | |
507 | } | |
508 | } | |
509 | ||
510 | // TRUE if we're between the above two calls | |
511 | bool wxIsBusy() | |
512 | { | |
513 | return (gs_wxBusyCursorCount > 0); | |
514 | } | |
515 | ||
516 | #endif // wxUSE_GUI | |
517 | ||
518 | #if wxUSE_BASE | |
519 | ||
520 | wxString wxMacFindFolder( short vol, | |
521 | OSType folderType, | |
522 | Boolean createFolder) | |
523 | { | |
524 | FSRef fsRef ; | |
525 | wxString strDir ; | |
526 | ||
527 | if ( FSFindFolder( vol, folderType, createFolder, &fsRef) == noErr) | |
528 | strDir = wxMacFSRefToPath( &fsRef ) + wxFILE_SEP_PATH ; | |
529 | ||
530 | return strDir ; | |
531 | } | |
532 | ||
533 | #endif // wxUSE_BASE | |
534 | ||
535 | #if wxUSE_GUI | |
536 | ||
537 | // Check whether this window wants to process messages, e.g. Stop button | |
538 | // in long calculations. | |
539 | bool wxCheckForInterrupt(wxWindow *wnd) | |
540 | { | |
541 | // TODO | |
542 | return FALSE; | |
543 | } | |
544 | ||
545 | void wxGetMousePosition( int* x, int* y ) | |
546 | { | |
547 | Point pt ; | |
548 | ||
549 | GetMouse( &pt ) ; | |
550 | LocalToGlobal( &pt ) ; | |
551 | *x = pt.h ; | |
552 | *y = pt.v ; | |
553 | }; | |
554 | ||
555 | // Return TRUE if we have a colour display | |
556 | bool wxColourDisplay() | |
557 | { | |
558 | return TRUE; | |
559 | } | |
560 | ||
561 | // Returns depth of screen | |
562 | int wxDisplayDepth() | |
563 | { | |
564 | Rect globRect ; | |
565 | SetRect(&globRect, -32760, -32760, 32760, 32760); | |
566 | GDHandle theMaxDevice; | |
567 | ||
568 | int theDepth = 8; | |
569 | theMaxDevice = GetMaxDevice(&globRect); | |
570 | if (theMaxDevice != nil) | |
571 | theDepth = (**(**theMaxDevice).gdPMap).pixelSize; | |
572 | ||
573 | return theDepth ; | |
574 | } | |
575 | ||
576 | // Get size of display | |
577 | void wxDisplaySize(int *width, int *height) | |
578 | { | |
579 | BitMap screenBits; | |
580 | GetQDGlobalsScreenBits( &screenBits ); | |
581 | ||
582 | if (width != NULL) { | |
583 | *width = screenBits.bounds.right - screenBits.bounds.left ; | |
584 | } | |
585 | if (height != NULL) { | |
586 | *height = screenBits.bounds.bottom - screenBits.bounds.top ; | |
587 | } | |
588 | } | |
589 | ||
590 | void wxDisplaySizeMM(int *width, int *height) | |
591 | { | |
592 | wxDisplaySize(width, height); | |
593 | // on mac 72 is fixed (at least now ;-) | |
594 | float cvPt2Mm = 25.4 / 72; | |
595 | ||
596 | if (width != NULL) { | |
597 | *width = int( *width * cvPt2Mm ); | |
598 | } | |
599 | if (height != NULL) { | |
600 | *height = int( *height * cvPt2Mm ); | |
601 | } | |
602 | } | |
603 | ||
604 | void wxClientDisplayRect(int *x, int *y, int *width, int *height) | |
605 | { | |
606 | Rect r ; | |
607 | GetAvailableWindowPositioningBounds( GetMainDevice() , &r ) ; | |
608 | if ( x ) | |
609 | *x = r.left ; | |
610 | if ( y ) | |
611 | *y = r.top ; | |
612 | if ( width ) | |
613 | *width = r.right - r.left ; | |
614 | if ( height ) | |
615 | *height = r.bottom - r.top ; | |
616 | } | |
617 | ||
618 | wxWindow* wxFindWindowAtPoint(const wxPoint& pt) | |
619 | { | |
620 | return wxGenericFindWindowAtPoint(pt); | |
621 | } | |
622 | ||
623 | #endif // wxUSE_GUI | |
624 | ||
625 | #if wxUSE_BASE | |
626 | ||
627 | wxString wxGetOsDescription() | |
628 | { | |
629 | #ifdef WXWIN_OS_DESCRIPTION | |
630 | // use configure generated description if available | |
631 | return wxString(wxT("MacOS (")) + wxT(WXWIN_OS_DESCRIPTION) + wxString(wxT(")")); | |
632 | #else | |
633 | return wxT("MacOS") ; //TODO:define further | |
634 | #endif | |
635 | } | |
636 | ||
637 | #ifndef __DARWIN__ | |
638 | wxChar *wxGetUserHome (const wxString& user) | |
639 | { | |
640 | // TODO | |
641 | return NULL; | |
642 | } | |
643 | ||
644 | bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) | |
645 | { | |
646 | if ( path.empty() ) | |
647 | return FALSE; | |
648 | ||
649 | wxString p = path ; | |
650 | if (p[0u] == ':' ) { | |
651 | p = wxGetCwd() + p ; | |
652 | } | |
653 | ||
654 | int pos = p.Find(':') ; | |
655 | if ( pos != wxNOT_FOUND ) { | |
656 | p = p.Mid(1,pos) ; | |
657 | } | |
658 | ||
659 | p = p + wxT(":") ; | |
660 | ||
661 | OSErr err = noErr ; | |
662 | ||
663 | FSRef fsRef ; | |
664 | err = wxMacPathToFSRef( p , &fsRef ) ; | |
665 | if ( noErr == err ) | |
666 | { | |
667 | FSVolumeRefNum vRefNum ; | |
668 | err = FSGetVRefNum( &fsRef , &vRefNum ) ; | |
669 | if ( noErr == err ) | |
670 | { | |
671 | UInt64 freeBytes , totalBytes ; | |
672 | err = FSGetVInfo( vRefNum , NULL , &freeBytes , &totalBytes ) ; | |
673 | if ( noErr == err ) | |
674 | { | |
675 | if ( pTotal ) | |
676 | *pTotal = wxLongLong( totalBytes ) ; | |
677 | if ( pFree ) | |
678 | *pFree = wxLongLong( freeBytes ) ; | |
679 | } | |
680 | } | |
681 | } | |
682 | ||
683 | return err == noErr ; | |
684 | } | |
685 | #endif // !__DARWIN__ | |
686 | ||
687 | //--------------------------------------------------------------------------- | |
688 | // wxMac Specific utility functions | |
689 | //--------------------------------------------------------------------------- | |
690 | ||
691 | void wxMacStringToPascal( const wxString&from , StringPtr to ) | |
692 | { | |
693 | wxCharBuffer buf = from.mb_str( wxConvLocal ) ; | |
694 | int len = strlen(buf) ; | |
695 | ||
696 | if ( len > 255 ) | |
697 | len = 255 ; | |
698 | to[0] = len ; | |
699 | memcpy( (char*) &to[1] , buf , len ) ; | |
700 | } | |
701 | ||
702 | wxString wxMacMakeStringFromPascal( ConstStringPtr from ) | |
703 | { | |
704 | return wxString( (char*) &from[1] , wxConvLocal , from[0] ) ; | |
705 | } | |
706 | ||
707 | ||
708 | // ---------------------------------------------------------------------------- | |
709 | // Common Event Support | |
710 | // ---------------------------------------------------------------------------- | |
711 | ||
712 | ||
713 | extern ProcessSerialNumber gAppProcess ; | |
714 | ||
715 | void wxMacWakeUp() | |
716 | { | |
717 | ProcessSerialNumber psn ; | |
718 | Boolean isSame ; | |
719 | psn.highLongOfPSN = 0 ; | |
720 | psn.lowLongOfPSN = kCurrentProcess ; | |
721 | SameProcess( &gAppProcess , &psn , &isSame ) ; | |
722 | if ( isSame ) | |
723 | { | |
724 | #if TARGET_CARBON | |
725 | // we keep the reference only as a weak ref, to avoid double posting | |
726 | // wakeups, so no problem if it is stale | |
727 | ||
728 | static EventRef s_wakeupEvent = 0 ; | |
729 | if ( s_wakeupEvent ) | |
730 | { | |
731 | // is our last wakeup still in the queue | |
732 | if ( IsEventInQueue( GetMainEventQueue() , s_wakeupEvent ) ) | |
733 | return ; | |
734 | // has been used already | |
735 | s_wakeupEvent = 0 ; | |
736 | } | |
737 | ||
738 | OSStatus err = MacCreateEvent(nil, 'WXMC', 'WXMC', GetCurrentEventTime(), | |
739 | kEventAttributeNone, &s_wakeupEvent); | |
740 | if (err == noErr) | |
741 | { | |
742 | err = PostEventToQueue(GetMainEventQueue(), s_wakeupEvent, | |
743 | kEventPriorityHigh); | |
744 | ReleaseEvent( s_wakeupEvent ) ; | |
745 | } | |
746 | #else | |
747 | PostEvent( nullEvent , 0 ) ; | |
748 | #endif | |
749 | } | |
750 | else | |
751 | { | |
752 | WakeUpProcess( &gAppProcess ) ; | |
753 | } | |
754 | } | |
755 | ||
756 | #endif // wxUSE_BASE | |
757 | ||
758 | #if wxUSE_GUI | |
759 | ||
760 | ||
761 | // ---------------------------------------------------------------------------- | |
762 | // Carbon Event Support | |
763 | // ---------------------------------------------------------------------------- | |
764 | ||
765 | ||
766 | OSStatus wxMacCarbonEvent::GetParameter(EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData) | |
767 | { | |
768 | return ::GetEventParameter( m_eventRef , inName , inDesiredType , NULL , inBufferSize , NULL , outData ) ; | |
769 | } | |
770 | ||
771 | OSStatus wxMacCarbonEvent::SetParameter(EventParamName inName, EventParamType inType, UInt32 inBufferSize, const void * inData) | |
772 | { | |
773 | return ::SetEventParameter( m_eventRef , inName , inType , inBufferSize , inData ) ; | |
774 | } | |
775 | ||
776 | // ---------------------------------------------------------------------------- | |
777 | // Control Access Support | |
778 | // ---------------------------------------------------------------------------- | |
779 | ||
780 | void wxMacControl::Dispose() | |
781 | { | |
782 | ::DisposeControl( m_controlRef ) ; | |
783 | m_controlRef = NULL ; | |
784 | } | |
785 | ||
786 | void wxMacControl::SetReference( SInt32 data ) | |
787 | { | |
788 | SetControlReference( m_controlRef , data ) ; | |
789 | } | |
790 | ||
791 | OSStatus wxMacControl::GetData(ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const | |
792 | { | |
793 | return ::GetControlData( m_controlRef , inPartCode , inTag , inBufferSize , inOutBuffer , outActualSize ) ; | |
794 | } | |
795 | ||
796 | OSStatus wxMacControl::GetDataSize(ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const | |
797 | { | |
798 | return ::GetControlDataSize( m_controlRef , inPartCode , inTag , outActualSize ) ; | |
799 | } | |
800 | ||
801 | OSStatus wxMacControl::SetData(ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData) | |
802 | { | |
803 | return ::SetControlData( m_controlRef , inPartCode , inTag , inSize , inData ) ; | |
804 | } | |
805 | ||
806 | OSStatus wxMacControl::SendEvent( EventRef event , OptionBits inOptions ) | |
807 | { | |
808 | #if TARGET_API_MAC_OSX | |
809 | return SendEventToEventTargetWithOptions( event, | |
810 | HIObjectGetEventTarget( (HIObjectRef) m_controlRef ), inOptions ); | |
811 | #else | |
812 | #pragma unused(inOptions) | |
813 | return SendEventToEventTarget(event,GetControlEventTarget( m_controlRef ) ) ; | |
814 | #endif | |
815 | } | |
816 | ||
817 | OSStatus wxMacControl::SendHICommand( HICommand &command , OptionBits inOptions ) | |
818 | { | |
819 | wxMacCarbonEvent event( kEventClassCommand , kEventCommandProcess ) ; | |
820 | event.SetParameter<HICommand>(kEventParamDirectObject,command) ; | |
821 | return SendEvent( event , inOptions ) ; | |
822 | } | |
823 | ||
824 | OSStatus wxMacControl::SendHICommand( UInt32 commandID , OptionBits inOptions ) | |
825 | { | |
826 | HICommand command ; | |
827 | memset( &command, 0 , sizeof(command) ) ; | |
828 | command.commandID = commandID ; | |
829 | return SendHICommand( command , inOptions ) ; | |
830 | } | |
831 | ||
832 | void wxMacControl::Flash( ControlPartCode part , UInt32 ticks ) | |
833 | { | |
834 | HiliteControl( m_controlRef , part ) ; | |
835 | unsigned long finalTicks ; | |
836 | Delay( ticks , &finalTicks ) ; | |
837 | HiliteControl( m_controlRef , kControlNoPart ) ; | |
838 | } | |
839 | ||
840 | SInt32 wxMacControl::GetValue() const | |
841 | { | |
842 | return ::GetControl32BitValue( m_controlRef ) ; | |
843 | } | |
844 | ||
845 | SInt32 wxMacControl::GetMaximum() const | |
846 | { | |
847 | return ::GetControl32BitMaximum( m_controlRef ) ; | |
848 | } | |
849 | ||
850 | SInt32 wxMacControl::GetMinimum() const | |
851 | { | |
852 | return ::GetControl32BitMinimum( m_controlRef ) ; | |
853 | } | |
854 | ||
855 | void wxMacControl::SetValue( SInt32 v ) | |
856 | { | |
857 | ::SetControl32BitValue( m_controlRef , v ) ; | |
858 | } | |
859 | ||
860 | void wxMacControl::SetMinimum( SInt32 v ) | |
861 | { | |
862 | ::SetControl32BitMinimum( m_controlRef , v ) ; | |
863 | } | |
864 | ||
865 | void wxMacControl::SetMaximum( SInt32 v ) | |
866 | { | |
867 | ::SetControl32BitMaximum( m_controlRef , v ) ; | |
868 | } | |
869 | ||
870 | void wxMacControl::SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum ) | |
871 | { | |
872 | ::SetControl32BitMinimum( m_controlRef , minimum ) ; | |
873 | ::SetControl32BitMaximum( m_controlRef , maximum ) ; | |
874 | ::SetControl32BitValue( m_controlRef , value ) ; | |
875 | } | |
876 | ||
877 | OSStatus wxMacControl::SetFocus( ControlFocusPart focusPart ) | |
878 | { | |
879 | return SetKeyboardFocus( GetControlOwner( m_controlRef ) , | |
880 | m_controlRef , focusPart ) ; | |
881 | } | |
882 | ||
883 | bool wxMacControl::HasFocus() const | |
884 | { | |
885 | ControlRef control ; | |
886 | GetKeyboardFocus( GetUserFocusWindow() , &control ) ; | |
887 | return control == m_controlRef ; | |
888 | } | |
889 | ||
890 | bool wxMacControl::NeedsFocusRect() const | |
891 | { | |
892 | return false ; | |
893 | } | |
894 | ||
895 | void wxMacControl::VisibilityChanged(bool shown) | |
896 | { | |
897 | } | |
898 | ||
899 | void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) | |
900 | { | |
901 | m_font = font ; | |
902 | ControlFontStyleRec fontStyle; | |
903 | if ( font.MacGetThemeFontID() != kThemeCurrentPortFont ) | |
904 | { | |
905 | switch( font.MacGetThemeFontID() ) | |
906 | { | |
907 | case kThemeSmallSystemFont : fontStyle.font = kControlFontSmallSystemFont ; break ; | |
908 | case 109 /*mini font */ : fontStyle.font = -5 ; break ; | |
909 | case kThemeSystemFont : fontStyle.font = kControlFontBigSystemFont ; break ; | |
910 | default : fontStyle.font = kControlFontBigSystemFont ; break ; | |
911 | } | |
912 | fontStyle.flags = kControlUseFontMask ; | |
913 | } | |
914 | else | |
915 | { | |
916 | fontStyle.font = font.MacGetFontNum() ; | |
917 | fontStyle.style = font.MacGetFontStyle() ; | |
918 | fontStyle.size = font.MacGetFontSize() ; | |
919 | fontStyle.flags = kControlUseFontMask | kControlUseFaceMask | kControlUseSizeMask ; | |
920 | } | |
921 | ||
922 | fontStyle.just = teJustLeft ; | |
923 | fontStyle.flags |= kControlUseJustMask ; | |
924 | if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_CENTER_HORIZONTAL ) | |
925 | fontStyle.just = teJustCenter ; | |
926 | else if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_RIGHT ) | |
927 | fontStyle.just = teJustRight ; | |
928 | ||
929 | ||
930 | // we only should do this in case of a non-standard color, as otherwise 'disabled' controls | |
931 | // won't get grayed out by the system anymore | |
932 | ||
933 | if ( foreground != *wxBLACK ) | |
934 | { | |
935 | fontStyle.foreColor = MAC_WXCOLORREF(foreground.GetPixel() ) ; | |
936 | fontStyle.flags |= kControlUseForeColorMask ; | |
937 | } | |
938 | ||
939 | ::SetControlFontStyle( m_controlRef , &fontStyle ); | |
940 | } | |
941 | ||
942 | void wxMacControl::SetBackground( const wxBrush &WXUNUSED(brush) ) | |
943 | { | |
944 | // TODO | |
945 | // setting up a color proc is not recommended anymore | |
946 | } | |
947 | ||
948 | void wxMacControl::SetRange( SInt32 minimum , SInt32 maximum ) | |
949 | { | |
950 | ::SetControl32BitMinimum( m_controlRef , minimum ) ; | |
951 | ::SetControl32BitMaximum( m_controlRef , maximum ) ; | |
952 | } | |
953 | ||
954 | short wxMacControl::HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers ) | |
955 | { | |
956 | return HandleControlKey( m_controlRef , keyCode , charCode , modifiers ) ; | |
957 | } | |
958 | ||
959 | void wxMacControl::SetActionProc( ControlActionUPP actionProc ) | |
960 | { | |
961 | SetControlAction( m_controlRef , actionProc ) ; | |
962 | } | |
963 | ||
964 | void wxMacControl::SetViewSize( SInt32 viewSize ) | |
965 | { | |
966 | SetControlViewSize(m_controlRef , viewSize ) ; | |
967 | } | |
968 | ||
969 | SInt32 wxMacControl::GetViewSize() const | |
970 | { | |
971 | return GetControlViewSize( m_controlRef ) ; | |
972 | } | |
973 | ||
974 | bool wxMacControl::IsVisible() const | |
975 | { | |
976 | return IsControlVisible( m_controlRef ) ; | |
977 | } | |
978 | ||
979 | void wxMacControl::SetVisibility( bool visible , bool redraw ) | |
980 | { | |
981 | SetControlVisibility( m_controlRef , visible , redraw ) ; | |
982 | } | |
983 | ||
984 | bool wxMacControl::IsEnabled() const | |
985 | { | |
986 | #if TARGET_API_MAC_OSX | |
987 | return IsControlEnabled( m_controlRef ) ; | |
988 | #else | |
989 | return IsControlActive( m_controlRef ) ; | |
990 | #endif | |
991 | } | |
992 | ||
993 | bool wxMacControl::IsActive() const | |
994 | { | |
995 | return IsControlActive( m_controlRef ) ; | |
996 | } | |
997 | ||
998 | void wxMacControl::Enable( bool enable ) | |
999 | { | |
1000 | #if TARGET_API_MAC_OSX | |
1001 | if ( enable ) | |
1002 | EnableControl( m_controlRef ) ; | |
1003 | else | |
1004 | DisableControl( m_controlRef ) ; | |
1005 | #else | |
1006 | if ( enable ) | |
1007 | ActivateControl( m_controlRef ) ; | |
1008 | else | |
1009 | DeactivateControl( m_controlRef ) ; | |
1010 | #endif | |
1011 | } | |
1012 | ||
1013 | void wxMacControl::SetDrawingEnabled( bool enable ) | |
1014 | { | |
1015 | #if TARGET_API_MAC_OSX | |
1016 | HIViewSetDrawingEnabled( m_controlRef , enable ) ; | |
1017 | #endif | |
1018 | } | |
1019 | ||
1020 | bool wxMacControl::GetNeedsDisplay() const | |
1021 | { | |
1022 | #if TARGET_API_MAC_OSX | |
1023 | return HIViewGetNeedsDisplay( m_controlRef ) ; | |
1024 | #else | |
1025 | return false ; | |
1026 | #endif | |
1027 | } | |
1028 | ||
1029 | void wxMacControl::SetNeedsDisplay( bool needsDisplay , RgnHandle where ) | |
1030 | { | |
1031 | #if TARGET_API_MAC_OSX | |
1032 | if ( where != NULL ) | |
1033 | HIViewSetNeedsDisplayInRegion( m_controlRef , where , needsDisplay ) ; | |
1034 | else | |
1035 | HIViewSetNeedsDisplay( m_controlRef , needsDisplay ) ; | |
1036 | #endif | |
1037 | } | |
1038 | ||
1039 | void wxMacControl::Convert( wxPoint *pt , wxMacControl *from , wxMacControl *to ) | |
1040 | { | |
1041 | #if TARGET_API_MAC_OSX | |
1042 | HIPoint hiPoint ; | |
1043 | hiPoint.x = pt->x ; | |
1044 | hiPoint.y = pt->y ; | |
1045 | HIViewConvertPoint( &hiPoint , from->m_controlRef , to->m_controlRef ) ; | |
1046 | pt->x = (int)hiPoint.x ; | |
1047 | pt->y = (int)hiPoint.y ; | |
1048 | #endif | |
1049 | } | |
1050 | ||
1051 | void wxMacControl::SetRect( Rect *r ) | |
1052 | { | |
1053 | #if TARGET_API_MAC_OSX | |
1054 | //A HIRect is actually a CGRect on OSX - which consists of two structures - | |
1055 | //CGPoint and CGSize, which have two floats each | |
1056 | HIRect hir = { { r->left , r->top }, { r->right - r->left , r->bottom - r->top } } ; | |
1057 | HIViewSetFrame ( m_controlRef , &hir ) ; | |
1058 | #else | |
1059 | SetControlBounds( m_controlRef , r ) ; | |
1060 | #endif | |
1061 | ||
1062 | } | |
1063 | ||
1064 | void wxMacControl::GetRect( Rect *r ) | |
1065 | { | |
1066 | GetControlBounds( m_controlRef , r ) ; | |
1067 | } | |
1068 | ||
1069 | void wxMacControl::GetRectInWindowCoords( Rect *r ) | |
1070 | { | |
1071 | UMAGetControlBoundsInWindowCoords( m_controlRef , r ) ; | |
1072 | } | |
1073 | ||
1074 | void wxMacControl::GetBestRect( Rect *r ) | |
1075 | { | |
1076 | short baselineoffset ; | |
1077 | GetBestControlRect( m_controlRef , r , &baselineoffset ) ; | |
1078 | } | |
1079 | ||
1080 | void wxMacControl::SetTitle( const wxString &title ) | |
1081 | { | |
1082 | wxFontEncoding encoding; | |
1083 | ||
1084 | if ( m_font.Ok() ) | |
1085 | encoding = m_font.GetEncoding(); | |
1086 | else | |
1087 | encoding = wxFont::GetDefaultEncoding(); | |
1088 | ||
1089 | UMASetControlTitle( m_controlRef , title , encoding ) ; | |
1090 | } | |
1091 | ||
1092 | void wxMacControl::GetFeatures( UInt32 * features ) | |
1093 | { | |
1094 | GetControlFeatures( m_controlRef , features ) ; | |
1095 | } | |
1096 | ||
1097 | OSStatus wxMacControl::GetRegion( ControlPartCode partCode , RgnHandle region ) | |
1098 | { | |
1099 | return GetControlRegion( m_controlRef , partCode , region ) ; | |
1100 | } | |
1101 | ||
1102 | OSStatus wxMacControl::SetZOrder( bool above , wxMacControl* other ) | |
1103 | { | |
1104 | #if TARGET_API_MAC_OSX | |
1105 | return HIViewSetZOrder( m_controlRef,above ? kHIViewZOrderAbove : kHIViewZOrderBelow, | |
1106 | (other != NULL) ? other->m_controlRef : NULL) ; | |
1107 | #else | |
1108 | return 0 ; | |
1109 | #endif | |
1110 | } | |
1111 | ||
1112 | ||
1113 | #if TARGET_API_MAC_OSX | |
1114 | // SetNeedsDisplay would not invalidate the children | |
1115 | static void InvalidateControlAndChildren( HIViewRef control ) | |
1116 | { | |
1117 | HIViewSetNeedsDisplay( control , true ) ; | |
1118 | UInt16 childrenCount = 0 ; | |
1119 | OSStatus err = CountSubControls( control , &childrenCount ) ; | |
1120 | if ( err == errControlIsNotEmbedder ) | |
1121 | return ; | |
1122 | wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") ) ; | |
1123 | ||
1124 | for ( UInt16 i = childrenCount ; i >=1 ; --i ) | |
1125 | { | |
1126 | HIViewRef child ; | |
1127 | err = GetIndexedSubControl( control , i , & child ) ; | |
1128 | if ( err == errControlIsNotEmbedder ) | |
1129 | return ; | |
1130 | InvalidateControlAndChildren( child ) ; | |
1131 | } | |
1132 | } | |
1133 | #endif | |
1134 | ||
1135 | void wxMacControl::InvalidateWithChildren() | |
1136 | { | |
1137 | #if TARGET_API_MAC_OSX | |
1138 | InvalidateControlAndChildren( m_controlRef ) ; | |
1139 | #endif | |
1140 | } | |
1141 | ||
1142 | void wxMacControl::ScrollRect( const wxRect &r , int dx , int dy ) | |
1143 | { | |
1144 | #if TARGET_API_MAC_OSX | |
1145 | HIRect scrollarea = CGRectMake( r.x , r.y , r.width , r.height) ; | |
1146 | HIViewScrollRect ( m_controlRef , &scrollarea , dx ,dy ) ; | |
1147 | #endif | |
1148 | } | |
1149 | ||
1150 | ||
1151 | // SetNeedsDisplay would not invalidate the children | |
1152 | ||
1153 | // | |
1154 | // Databrowser | |
1155 | // | |
1156 | ||
1157 | OSStatus wxMacControl::SetSelectionFlags( DataBrowserSelectionFlags options ) | |
1158 | { | |
1159 | return SetDataBrowserSelectionFlags( m_controlRef , options ) ; | |
1160 | } | |
1161 | ||
1162 | OSStatus wxMacControl::AddListViewColumn( DataBrowserListViewColumnDesc *columnDesc, | |
1163 | DataBrowserTableViewColumnIndex position ) | |
1164 | { | |
1165 | return AddDataBrowserListViewColumn( m_controlRef , columnDesc, position ) ; | |
1166 | } | |
1167 | ||
1168 | OSStatus wxMacControl::AutoSizeListViewColumns() | |
1169 | { | |
1170 | return AutoSizeDataBrowserListViewColumns(m_controlRef) ; | |
1171 | } | |
1172 | ||
1173 | OSStatus wxMacControl::SetHasScrollBars( bool horiz , bool vert ) | |
1174 | { | |
1175 | return SetDataBrowserHasScrollBars( m_controlRef , horiz , vert ) ; | |
1176 | } | |
1177 | ||
1178 | OSStatus wxMacControl::SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle ) | |
1179 | { | |
1180 | return SetDataBrowserTableViewHiliteStyle( m_controlRef , hiliteStyle ) ; | |
1181 | } | |
1182 | ||
1183 | OSStatus wxMacControl::SetListViewHeaderBtnHeight(UInt16 height) | |
1184 | { | |
1185 | return SetDataBrowserListViewHeaderBtnHeight( m_controlRef ,height ) ; | |
1186 | } | |
1187 | ||
1188 | OSStatus wxMacControl::SetCallbacks(const DataBrowserCallbacks * callbacks) | |
1189 | { | |
1190 | return SetDataBrowserCallbacks( m_controlRef , callbacks ) ; | |
1191 | } | |
1192 | ||
1193 | OSStatus wxMacControl::UpdateItems( DataBrowserItemID container, UInt32 numItems, | |
1194 | const DataBrowserItemID* items, | |
1195 | DataBrowserPropertyID preSortProperty, | |
1196 | DataBrowserPropertyID propertyID ) | |
1197 | { | |
1198 | return UpdateDataBrowserItems( m_controlRef , container, numItems, items, preSortProperty, propertyID ) ; | |
1199 | } | |
1200 | ||
1201 | bool wxMacControl::IsItemSelected( DataBrowserItemID item ) | |
1202 | { | |
1203 | return IsDataBrowserItemSelected( m_controlRef , item ) ; | |
1204 | } | |
1205 | ||
1206 | OSStatus wxMacControl::AddItems( DataBrowserItemID container, UInt32 numItems, | |
1207 | const DataBrowserItemID* items, | |
1208 | DataBrowserPropertyID preSortProperty ) | |
1209 | { | |
1210 | return AddDataBrowserItems( m_controlRef , container, numItems, items, preSortProperty ) ; | |
1211 | } | |
1212 | ||
1213 | OSStatus wxMacControl::RemoveItems( DataBrowserItemID container, UInt32 numItems, | |
1214 | const DataBrowserItemID* items, | |
1215 | DataBrowserPropertyID preSortProperty ) | |
1216 | { | |
1217 | return RemoveDataBrowserItems( m_controlRef , container, numItems, items, preSortProperty ) ; | |
1218 | } | |
1219 | ||
1220 | OSStatus wxMacControl::RevealItem( DataBrowserItemID item, | |
1221 | DataBrowserPropertyID propertyID, | |
1222 | DataBrowserRevealOptions options ) | |
1223 | { | |
1224 | return RevealDataBrowserItem( m_controlRef , item , propertyID , options ) ; | |
1225 | } | |
1226 | ||
1227 | OSStatus wxMacControl::SetSelectedItems(UInt32 numItems, | |
1228 | const DataBrowserItemID * items, | |
1229 | DataBrowserSetOption operation ) | |
1230 | { | |
1231 | return SetDataBrowserSelectedItems( m_controlRef , numItems , items, operation ) ; | |
1232 | } | |
1233 | ||
1234 | OSStatus wxMacControl::GetSelectionAnchor( DataBrowserItemID * first, DataBrowserItemID * last ) | |
1235 | { | |
1236 | return GetDataBrowserSelectionAnchor( m_controlRef , first , last ) ; | |
1237 | } | |
1238 | ||
1239 | // | |
1240 | // Tab Control | |
1241 | // | |
1242 | ||
1243 | OSStatus wxMacControl::SetTabEnabled( SInt16 tabNo , bool enable ) | |
1244 | { | |
1245 | return ::SetTabEnabled( m_controlRef , tabNo , enable ) ; | |
1246 | } | |
1247 | ||
1248 | #endif // wxUSE_GUI | |
1249 |