// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && !defined(__EMX__)
+// Some older compilers (such as EMX) cannot handle
+// #pragma interface/implementation correctly, iff
+// #pragma implementation is used in _two_ translation
+// units (as created by e.g. event.cpp compiled for
+// libwx_base and event.cpp compiled for libwx_gui_core).
+// So we must not use those pragmas for those compilers in
+// such files.
#pragma implementation "utils.h"
#endif
#include "wx/process.h"
#include "wx/txtstrm.h"
+#if defined(__WXWINCE__) && wxUSE_DATETIME
+#include "wx/datetime.h"
+#endif
+
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include "wx/statusbr.h"
#endif // wxUSE_GUI
+#ifndef __WXWINCE__
#include <time.h>
+#else
+#include "wx/msw/wince/time.h"
+#endif
-#ifndef __MWERKS__
+#if !defined(__MWERKS__) && !defined(__WXWINCE__)
#include <sys/types.h>
#include <sys/stat.h>
#endif
-#ifdef __SALFORDC__
- #include <clib.h>
-#endif
-
#ifdef __WXMSW__
#include "wx/msw/private.h"
#endif
#endif // WXWIN_COMPATIBILITY_2_4
-// Id generation
-static long wxCurrentId = 100;
-
-long
-wxNewId (void)
-{
- return wxCurrentId++;
-}
-
-long
-wxGetCurrentId(void) { return wxCurrentId; }
-
-void
-wxRegisterId (long id)
-{
- if (id >= wxCurrentId)
- wxCurrentId = id + 1;
-}
-
// ----------------------------------------------------------------------------
// String <-> Number conversions (deprecated)
// ----------------------------------------------------------------------------
// Return the current date/time
wxString wxNow()
{
+#ifdef __WXWINCE__
+#if wxUSE_DATETIME
+ wxDateTime now = wxDateTime::Now();
+ return now.Format();
+#else
+ return wxEmptyString;
+#endif
+#else
time_t now = time((time_t *) NULL);
char *date = ctime(&now);
date[24] = '\0';
return wxString::FromAscii(date);
+#endif
}
const wxChar *wxGetInstallPrefix()
if ( ! traits )
traits = &traitsConsole;
- return traits->GetOSVersion(verMaj, verMin);
+ wxToolkitInfo& info = traits->GetToolkitInfo();
+ if ( verMaj )
+ *verMaj = info.versionMajor;
+ if ( verMin )
+ *verMin = info.versionMinor;
+ return info.os;
}
// ----------------------------------------------------------------------------
static const int maxLoginLen = 256; // FIXME arbitrary number
wxString buf;
- bool ok = wxGetUserId(buf.GetWriteBuf(maxLoginLen), maxLoginLen);
- buf.UngetWriteBuf();
+ bool ok = wxGetUserId(wxStringBuffer(buf, maxLoginLen), maxLoginLen);
if ( !ok )
buf.Empty();
static const int maxUserNameLen = 1024; // FIXME arbitrary number
wxString buf;
- bool ok = wxGetUserName(buf.GetWriteBuf(maxUserNameLen), maxUserNameLen);
- buf.UngetWriteBuf();
+ bool ok = wxGetUserName(wxStringBuffer(buf, maxUserNameLen), maxUserNameLen);
if ( !ok )
buf.Empty();
static const size_t hostnameSize = 257;
wxString buf;
- bool ok = wxGetHostName(buf.GetWriteBuf(hostnameSize), hostnameSize);
-
- buf.UngetWriteBuf();
+ bool ok = wxGetHostName(wxStringBuffer(buf, hostnameSize), hostnameSize);
if ( !ok )
buf.Empty();
static const size_t hostnameSize = 257;
wxString buf;
- bool ok = wxGetFullHostName(buf.GetWriteBuf(hostnameSize), hostnameSize);
-
- buf.UngetWriteBuf();
+ bool ok = wxGetFullHostName(wxStringBuffer(buf, hostnameSize), hostnameSize);
if ( !ok )
buf.Empty();
#if wxUSE_GUI
+// Id generation
+static long wxCurrentId = 100;
+
+long
+wxNewId (void)
+{
+ return wxCurrentId++;
+}
+
+long
+wxGetCurrentId(void) { return wxCurrentId; }
+
+void
+wxRegisterId (long id)
+{
+ if (id >= wxCurrentId)
+ wxCurrentId = id + 1;
+}
+
#if wxUSE_MENUS
// ----------------------------------------------------------------------------