Provide wxLaunchDefaultBrowser implementation for wxCocoa.
[wxWidgets.git] / src / cocoa / utils.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        src/cocoa/utils.cpp
3 // Purpose:     Various utilities
4 // Author:      David Elliott
5 // Created:     2003/??/??
6 // RCS-ID:      $Id$
7 // Copyright:   (c) wxWidgets dev team
8 // Licence:     wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #include "wx/wxprec.h"
12
13 #include "wx/utils.h"
14
15 #ifndef WX_PRECOMP
16     #include "wx/app.h"
17 #endif // WX_PRECOMP
18
19 #include "wx/apptrait.h"
20 #include "wx/display.h"
21 #include "wx/cocoa/private/timer.h"
22
23 #include <ctype.h>
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <stdarg.h>
29
30 #include "wx/cocoa/string.h"
31
32 #import <Foundation/NSURL.h>
33 #import <AppKit/NSWorkspace.h>
34
35 void wxDisplaySize(int *width, int *height)
36 {
37     // TODO
38     if(width)
39         *width = 1024;
40     if(height)
41         *height = 768;
42 }
43
44 void wxDisplaySizeMM(int*,int*)
45 {
46     // TODO
47 }
48
49 void wxClientDisplayRect(int *x,int *y,int *width,int *height)
50 {
51     // TODO
52     if(x)
53         *x = 0;
54     if(y)
55         *y = 0;
56     if(width)
57         *width=1024;
58     if(height)
59         *height=768;
60 }
61
62 wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
63 {
64     // We suppose that toolkit version is the same as OS version under Mac
65     wxGetOsVersion(verMaj, verMin);
66
67     return wxPORT_COCOA;
68 }
69
70 wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer* timer)
71 {
72     return new wxCocoaTimerImpl(timer);
73 }
74
75 wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
76 {
77     return wxGenericFindWindowAtPoint(pt);
78 }
79
80 // Return true if we have a colour display
81 bool wxColourDisplay()
82 {
83     // TODO
84     return true;
85 }
86
87 void wxGetMousePosition( int* x, int* y )
88 {
89     // TODO
90 };
91
92 // Returns depth of screen
93 int wxDisplayDepth()
94 {
95     // TODO
96     return 0;
97 }
98
99 // Emit a beeeeeep
100 void wxBell()
101 {
102     // TODO
103 }
104
105 // Private helper method for wxLaunchDefaultBrowser
106 bool wxCocoaLaunchDefaultBrowser(const wxString& url, int flags)
107 {
108     // NOTE: We ignore the flags
109     return [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString:wxNSStringWithWxString(url)]] != NO;
110 }
111
112 #if 0
113 // DFE: These aren't even implemented by wxGTK, and no wxWidgets code calls
114 // them.  If someone needs them, then they'll get a link error
115
116 // Consume all events until no more left
117 void wxFlushEvents()
118 {
119 }
120
121 // Check whether this window wants to process messages, e.g. Stop button
122 // in long calculations.
123 bool wxCheckForInterrupt(wxWindow *wnd)
124 {
125     // TODO
126     return false;
127 }
128
129 #endif
130