]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/utils.cpp
allow using both char* and wchar_t* in wxFileConfig and wxConfigBase, too
[wxWidgets.git] / src / cocoa / utils.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/utils.cpp
3 // Purpose: Various utilities
4 // Author: AUTHOR
5 // Modified by:
6 // Created: 2003/??/??
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/utils.h"
15
16 #ifndef WX_PRECOMP
17 #include "wx/app.h"
18 #endif // WX_PRECOMP
19
20 #include "wx/apptrait.h"
21 #include "wx/display.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 void wxDisplaySize(int *width, int *height)
31 {
32 // TODO
33 if(width)
34 *width = 1024;
35 if(height)
36 *height = 768;
37 }
38
39 void wxDisplaySizeMM(int*,int*)
40 {
41 // TODO
42 }
43
44 void wxClientDisplayRect(int *x,int *y,int *width,int *height)
45 {
46 // TODO
47 if(x)
48 *x = 0;
49 if(y)
50 *y = 0;
51 if(width)
52 *width=1024;
53 if(height)
54 *height=768;
55 }
56
57 wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
58 {
59 // We suppose that toolkit version is the same as OS version under Mac
60 wxGetOsVersion(verMaj, verMin);
61
62 return wxPORT_COCOA;
63 }
64
65 wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
66 {
67 return wxGenericFindWindowAtPoint(pt);
68 }
69
70 // Return true if we have a colour display
71 bool wxColourDisplay()
72 {
73 // TODO
74 return true;
75 }
76
77 void wxGetMousePosition( int* x, int* y )
78 {
79 // TODO
80 };
81
82 // Returns depth of screen
83 int wxDisplayDepth()
84 {
85 // TODO
86 return 0;
87 }
88
89 // Emit a beeeeeep
90 void wxBell()
91 {
92 // TODO
93 }
94
95 #if 0
96 // DFE: These aren't even implemented by wxGTK, and no wxWidgets code calls
97 // them. If someone needs them, then they'll get a link error
98
99 // Consume all events until no more left
100 void wxFlushEvents()
101 {
102 }
103
104 // Check whether this window wants to process messages, e.g. Stop button
105 // in long calculations.
106 bool wxCheckForInterrupt(wxWindow *wnd)
107 {
108 // TODO
109 return false;
110 }
111
112 #endif
113
114 // Reading and writing resources (eg WIN.INI, .Xdefaults)
115 #if wxUSE_RESOURCES
116 bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
117 {
118 // TODO
119 return false;
120 }
121
122 bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
123 {
124 char buf[50];
125 sprintf(buf, "%.4f", value);
126 return wxWriteResource(section, entry, buf, file);
127 }
128
129 bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file)
130 {
131 char buf[50];
132 sprintf(buf, "%ld", value);
133 return wxWriteResource(section, entry, buf, file);
134 }
135
136 bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file)
137 {
138 char buf[50];
139 sprintf(buf, "%d", value);
140 return wxWriteResource(section, entry, buf, file);
141 }
142
143 bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file)
144 {
145 // TODO
146 return false;
147 }
148
149 bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
150 {
151 char *s = NULL;
152 bool succ = wxGetResource(section, entry, (char **)&s, file);
153 if (succ)
154 {
155 *value = (float)strtod(s, NULL);
156 delete[] s;
157 return true;
158 }
159 else return false;
160 }
161
162 bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
163 {
164 char *s = NULL;
165 bool succ = wxGetResource(section, entry, (char **)&s, file);
166 if (succ)
167 {
168 *value = strtol(s, NULL, 10);
169 delete[] s;
170 return true;
171 }
172 else return false;
173 }
174
175 bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
176 {
177 char *s = NULL;
178 bool succ = wxGetResource(section, entry, (char **)&s, file);
179 if (succ)
180 {
181 *value = (int)strtol(s, NULL, 10);
182 delete[] s;
183 return true;
184 }
185 else return false;
186 }
187 #endif // wxUSE_RESOURCES