]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/utils.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Various utilities
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 // Note: this is done in utilscmn.cpp now.
14 // #pragma implementation
15 // #pragma implementation "utils.h"
31 // Get full hostname (eg. DoDo.BSn-Germany.crg.de)
32 bool wxGetHostName(char *buf
, int maxSize
)
38 // Get user ID e.g. jacs
39 bool wxGetUserId(char *buf
, int maxSize
)
45 // Get user name e.g. Julian Smart
46 bool wxGetUserName(char *buf
, int maxSize
)
52 int wxKill(long pid
, int sig
)
59 // Execute a program in an Interactive Shell
61 bool wxShell(const wxString
& command
)
67 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
68 long wxGetFreeMemory()
74 void wxSleep(int nSecs
)
79 // Consume all events until no more left
84 // Output a debug message, in a system dependent fashion.
85 void wxDebugMsg(const char *fmt
...)
88 static char buffer
[512];
90 if (!wxTheApp
->GetWantDebugOutput())
95 // wvsprintf(buffer,fmt,ap) ;
96 // TODO: output buffer
101 // Non-fatal error: pop up message box and (possibly) continue
102 void wxError(const wxString
& msg
, const wxString
& title
)
108 // Fatal error: pop up message box and abort
109 void wxFatalError(const wxString
& msg
, const wxString
& title
)
120 int wxGetOsVersion(int *majorVsn
, int *minorVsn
)
126 // Reading and writing resources (eg WIN.INI, .Xdefaults)
128 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, const wxString
& value
, const wxString
& file
)
134 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, float value
, const wxString
& file
)
137 sprintf(buf
, "%.4f", value
);
138 return wxWriteResource(section
, entry
, buf
, file
);
141 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, long value
, const wxString
& file
)
144 sprintf(buf
, "%ld", value
);
145 return wxWriteResource(section
, entry
, buf
, file
);
148 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, int value
, const wxString
& file
)
151 sprintf(buf
, "%d", value
);
152 return wxWriteResource(section
, entry
, buf
, file
);
155 bool wxGetResource(const wxString
& section
, const wxString
& entry
, char **value
, const wxString
& file
)
161 bool wxGetResource(const wxString
& section
, const wxString
& entry
, float *value
, const wxString
& file
)
164 bool succ
= wxGetResource(section
, entry
, (char **)&s
, file
);
167 *value
= (float)strtod(s
, NULL
);
174 bool wxGetResource(const wxString
& section
, const wxString
& entry
, long *value
, const wxString
& file
)
177 bool succ
= wxGetResource(section
, entry
, (char **)&s
, file
);
180 *value
= strtol(s
, NULL
, 10);
187 bool wxGetResource(const wxString
& section
, const wxString
& entry
, int *value
, const wxString
& file
)
190 bool succ
= wxGetResource(section
, entry
, (char **)&s
, file
);
193 *value
= (int)strtol(s
, NULL
, 10);
199 #endif // USE_RESOURCES
201 static int wxBusyCursorCount
= 0;
203 // Set the cursor to the busy cursor for all windows
204 void wxBeginBusyCursor(wxCursor
*cursor
)
206 wxBusyCursorCount
++;
207 if (wxBusyCursorCount
== 1)
217 // Restore cursor to normal
218 void wxEndBusyCursor()
220 if (wxBusyCursorCount
== 0)
223 wxBusyCursorCount
--;
224 if (wxBusyCursorCount
== 0)
230 // TRUE if we're between the above two calls
233 return (wxBusyCursorCount
> 0);
236 char *wxGetUserHome (const wxString
& user
)
242 // Check whether this window wants to process messages, e.g. Stop button
243 // in long calculations.
244 bool wxCheckForInterrupt(wxWindow
*wnd
)
250 void wxGetMousePosition( int* x
, int* y
)
255 // Return TRUE if we have a colour display
256 bool wxColourDisplay()
262 // Returns depth of screen
269 // Get size of display
270 void wxDisplaySize(int *width
, int *height
)
275 /* Configurable display in Motif */
276 static WXDisplay
*gs_currentDisplay
= NULL
;
277 static wxString gs_displayName
;
279 WXDisplay
*wxGetDisplay()
281 if (gs_currentDisplay
)
282 return gs_currentDisplay
;
284 return XtDisplay ((Widget
) wxTheApp
->GetTopLevelWidget());
287 bool wxSetDisplay(const wxString
& display_name
)
289 gs_displayName
= display_name
;
291 if (display_name
.IsNull() || display_name
.IsEmpty())
293 gs_currentDisplay
= NULL
;
300 Display
*display
= XtOpenDisplay((XtAppContext
) wxTheApp
->GetAppContext(),
301 (const char*) display_name
,
302 (const char*) wxTheApp
->GetAppName(),
303 (const char*) wxTheApp
->GetClassName(),
305 # if XtSpecificationRelease < 5
308 0, (int *)&argc
, NULL
);
313 gs_currentDisplay
= (WXDisplay
*) display
;
321 wxString
wxGetDisplayName()
323 return gs_displayName
;