projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* Changed char to wxChar in operators.
[wxWidgets.git]
/
src
/
common
/
utilscmn.cpp
diff --git
a/src/common/utilscmn.cpp
b/src/common/utilscmn.cpp
index 52b8878187060f46b40e249b37de2a950de351bb..4b6e87cbce6b3cb833e1c02acf1973ef5c4d0cfe 100644
(file)
--- a/
src/common/utilscmn.cpp
+++ b/
src/common/utilscmn.cpp
@@
-30,14
+30,6
@@
#include "wx/textdlg.h"
#endif
#include "wx/textdlg.h"
#endif
-#include "wx/ioswrap.h"
-
-#if wxUSE_IOSTREAMH
- #include <fstream.h>
-#else
- #include <fstream>
-#endif
-
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@
-71,7
+63,7
@@
#define _MAXPATHLEN 500
#define _MAXPATHLEN 500
-extern
c
har *wxBuffer;
+extern
wxC
har *wxBuffer;
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
// private functions
@@
-168,6
+160,12
@@
int strncasecmp(const char *str_1, const char *str_2, size_t maxchar)
#endif
#else
#endif
#else
+
+#ifdef __EMX__
+#define strcasecmp stricmp
+#define strncasecmp strnicmp
+#endif
+
// This declaration is missing in SunOS!
// (Yes, I know it is NOT ANSI-C but its in BSD libc)
#if defined(__xlC) || defined(__AIX__) || defined(__GNUG__)
// This declaration is missing in SunOS!
// (Yes, I know it is NOT ANSI-C but its in BSD libc)
#if defined(__xlC) || defined(__AIX__) || defined(__GNUG__)
@@
-180,14
+178,14
@@
extern "C"
#endif /* __WXMSW__ */
#endif /* __WXMSW__ */
-
c
har *
-copystring (const
c
har *s)
+
wxC
har *
+copystring (const
wxC
har *s)
{
{
- if (s == NULL) s =
""
;
- size_t len =
s
trlen (s) + 1;
+ if (s == NULL) s =
_T("")
;
+ size_t len =
wxS
trlen (s) + 1;
-
char *news = new c
har[len];
- memcpy (news, s, len); // Should be the fastest
+
wxChar *news = new wxC
har[len];
+ memcpy (news, s, len
* sizeof(wxChar)
); // Should be the fastest
return news;
}
return news;
}
@@
-212,94
+210,93
@@
wxRegisterId (long id)
}
void
}
void
-StringToFloat (
c
har *s, float *number)
+StringToFloat (
wxC
har *s, float *number)
{
if (s && *s && number)
{
if (s && *s && number)
- *number = (float)
strtod (s, (c
har **) NULL);
+ *number = (float)
wxStrtod (s, (wxC
har **) NULL);
}
void
}
void
-StringToDouble (
c
har *s, double *number)
+StringToDouble (
wxC
har *s, double *number)
{
if (s && *s && number)
{
if (s && *s && number)
- *number =
strtod (s, (c
har **) NULL);
+ *number =
wxStrtod (s, (wxC
har **) NULL);
}
}
-
c
har *
-FloatToString (float number, const
c
har *fmt)
+
wxC
har *
+FloatToString (float number, const
wxC
har *fmt)
{
{
- static
c
har buf[256];
+ static
wxC
har buf[256];
// sprintf (buf, "%.2f", number);
// sprintf (buf, "%.2f", number);
-
s
printf (buf, fmt, number);
+
wxS
printf (buf, fmt, number);
return buf;
}
return buf;
}
-
c
har *
-DoubleToString (double number, const
c
har *fmt)
+
wxC
har *
+DoubleToString (double number, const
wxC
har *fmt)
{
{
- static
c
har buf[256];
+ static
wxC
har buf[256];
-
s
printf (buf, fmt, number);
+
wxS
printf (buf, fmt, number);
return buf;
}
void
return buf;
}
void
-StringToInt (
c
har *s, int *number)
+StringToInt (
wxC
har *s, int *number)
{
if (s && *s && number)
{
if (s && *s && number)
- *number = (int)
strtol (s, (c
har **) NULL, 10);
+ *number = (int)
wxStrtol (s, (wxC
har **) NULL, 10);
}
void
}
void
-StringToLong (
c
har *s, long *number)
+StringToLong (
wxC
har *s, long *number)
{
if (s && *s && number)
{
if (s && *s && number)
- *number =
strtol (s, (c
har **) NULL, 10);
+ *number =
wxStrtol (s, (wxC
har **) NULL, 10);
}
}
-
c
har *
+
wxC
har *
IntToString (int number)
{
IntToString (int number)
{
- static
c
har buf[20];
+ static
wxC
har buf[20];
-
sprintf (buf, "%d"
, number);
+
wxSprintf (buf, _T("%d")
, number);
return buf;
}
return buf;
}
-
c
har *
+
wxC
har *
LongToString (long number)
{
LongToString (long number)
{
- static
c
har buf[20];
+ static
wxC
har buf[20];
-
sprintf (buf, "%ld"
, number);
+
wxSprintf (buf, _T("%ld")
, number);
return buf;
}
// Array used in DecToHex conversion routine.
return buf;
}
// Array used in DecToHex conversion routine.
-static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
- 'C', 'D', 'E', 'F' };
+static wxChar hexArray[] = _T("0123456789ABCDEF");
// Convert 2-digit hex number to decimal
int wxHexToDec(const wxString& buf)
{
int firstDigit, secondDigit;
// Convert 2-digit hex number to decimal
int wxHexToDec(const wxString& buf)
{
int firstDigit, secondDigit;
- if (buf.GetChar(0) >=
'A'
)
- firstDigit = buf.GetChar(0) -
'A'
+ 10;
+ if (buf.GetChar(0) >=
_T('A')
)
+ firstDigit = buf.GetChar(0) -
_T('A')
+ 10;
else
else
- firstDigit = buf.GetChar(0) -
'0'
;
+ firstDigit = buf.GetChar(0) -
_T('0')
;
- if (buf.GetChar(1) >=
'A'
)
- secondDigit = buf.GetChar(1) -
'A'
+ 10;
+ if (buf.GetChar(1) >=
_T('A')
)
+ secondDigit = buf.GetChar(1) -
_T('A')
+ 10;
else
else
- secondDigit = buf.GetChar(1) -
'0'
;
+ secondDigit = buf.GetChar(1) -
_T('0')
;
return firstDigit * 16 + secondDigit;
}
// Convert decimal integer to 2-character hex string
return firstDigit * 16 + secondDigit;
}
// Convert decimal integer to 2-character hex string
-void wxDecToHex(int dec,
c
har *buf)
+void wxDecToHex(int dec,
wxC
har *buf)
{
int firstDigit = (int)(dec/16.0);
int secondDigit = (int)(dec - (firstDigit*16.0));
{
int firstDigit = (int)(dec/16.0);
int secondDigit = (int)(dec - (firstDigit*16.0));
@@
-311,7
+308,7
@@
void wxDecToHex(int dec, char *buf)
// Convert decimal integer to 2-character hex string
wxString wxDecToHex(int dec)
{
// Convert decimal integer to 2-character hex string
wxString wxDecToHex(int dec)
{
-
c
har buf[3];
+
wxC
har buf[3];
wxDecToHex(dec, buf);
return wxString(buf);
}
wxDecToHex(dec, buf);
return wxString(buf);
}
@@
-356,6
+353,16
@@
StringMatch (char *str1, char *str2, bool subString, bool exact)
return FALSE;
}
return FALSE;
}
+// Don't synthesize KeyUp events holding down a key and producing
+// KeyDown events with autorepeat. On by default and always on
+// on in wxMSW. wxGTK version in utilsgtk.cpp.
+#ifndef __WXGTK__
+bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
+{
+ return TRUE; // detectable auto-repeat is the only mode MSW supports
+}
+#endif
+
// Return the current date/time
// [volatile]
wxString wxNow( void )
// Return the current date/time
// [volatile]
wxString wxNow( void )
@@
-370,25
+377,25
@@
wxString wxNow( void )
* Strip out any menu codes
*/
* Strip out any menu codes
*/
-
char *wxStripMenuCodes (char *in, c
har *out)
+
wxChar *wxStripMenuCodes (wxChar *in, wxC
har *out)
{
if (!in)
{
if (!in)
- return (
c
har *) NULL;
+ return (
wxC
har *) NULL;
if (!out)
out = copystring(in);
if (!out)
out = copystring(in);
-
c
har *tmpOut = out;
+
wxC
har *tmpOut = out;
while (*in)
{
while (*in)
{
- if (*in ==
'&'
)
+ if (*in ==
_T('&')
)
{
// Check && -> &, &x -> x
{
// Check && -> &, &x -> x
- if (*++in ==
'&'
)
+ if (*++in ==
_T('&')
)
*out++ = *in++;
}
*out++ = *in++;
}
- else if (*in ==
'\t'
)
+ else if (*in ==
_T('\t')
)
{
// Remove all stuff after \t in X mode, and let the stuff as is
// in Windows mode.
{
// Remove all stuff after \t in X mode, and let the stuff as is
// in Windows mode.
@@
-400,15
+407,15
@@
char *wxStripMenuCodes (char *in, char *out)
*out++ = *in++;
} // while
*out++ = *in++;
} // while
- *out =
'\0'
;
+ *out =
_T('\0')
;
return tmpOut;
}
wxString wxStripMenuCodes(const wxString& str)
{
return tmpOut;
}
wxString wxStripMenuCodes(const wxString& str)
{
-
char *buf = new c
har[str.Length() + 1];
- wxStripMenuCodes(
(char*) (const char*)
str, buf);
+
wxChar *buf = new wxC
har[str.Length() + 1];
+ wxStripMenuCodes(
WXSTRINGCAST
str, buf);
wxString str1(buf);
delete[] buf;
return str1;
wxString str1(buf);
delete[] buf;
return str1;
@@
-460,7
+467,7
@@
wxFindWindowByLabel1 (const wxString& title, wxWindow * parent)
if (parent)
{
if (parent)
{
- for ( wxNode * node = parent->GetChildren().GetFirst();
+ for ( wx
WindowList::
Node * node = parent->GetChildren().GetFirst();
node;
node = node->GetNext() )
{
node;
node = node->GetNext() )
{
@@
-734,28
+741,23
@@
whereami(name)
}
#endif
}
#endif
-
+void wxEnableTopLevelWindows(bool enable)
+{
+ wxWindowList::Node *node;
+ for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
+ node->GetData()->Enable(enable);
+}
// Yield to other apps/messages and disable user input
bool wxSafeYield(wxWindow *win)
{
// Yield to other apps/messages and disable user input
bool wxSafeYield(wxWindow *win)
{
- wxWindowList::Node *node;
- for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
- {
- node->GetData()->Enable(FALSE);
- }
-
- // always enable ourselves
- if ( win )
- win->Enable(TRUE);
- bool rc = wxYield();
-
- for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
- {
- node->GetData()->Enable(TRUE);
- }
-
- return rc;
+ wxEnableTopLevelWindows(FALSE);
+ // always enable ourselves
+ if ( win )
+ win->Enable(TRUE);
+ bool rc = wxYield();
+ wxEnableTopLevelWindows(TRUE);
+ return rc;
}
/*
}
/*
@@
-788,6
+790,7
@@
int wxMessageBox(const wxString& message, const wxString& caption, long style,
return ans;
}
return ans;
}
+#if wxUSE_TEXTDLG
wxString wxGetTextFromUser(const wxString& message, const wxString& caption,
const wxString& defaultValue, wxWindow *parent,
int x, int y, bool WXUNUSED(centre) )
wxString wxGetTextFromUser(const wxString& message, const wxString& caption,
const wxString& defaultValue, wxWindow *parent,
int x, int y, bool WXUNUSED(centre) )
@@
-798,6
+801,7
@@
wxString wxGetTextFromUser(const wxString& message, const wxString& caption,
else
return wxString("");
}
else
return wxString("");
}
+#endif // wxUSE_TEXTDLG
#ifdef __MWERKS__
char *strdup(const char *s)
#ifdef __MWERKS__
char *strdup(const char *s)
@@
-816,14
+820,14
@@
int isascii( int c )
// ----------------------------------------------------------------------------
// Get Full RFC822 style email address
// ----------------------------------------------------------------------------
// Get Full RFC822 style email address
-bool wxGetEmailAddress(
c
har *address, int maxSize)
+bool wxGetEmailAddress(
wxC
har *address, int maxSize)
{
wxString email = wxGetEmailAddress();
if ( !email )
return FALSE;
{
wxString email = wxGetEmailAddress();
if ( !email )
return FALSE;
-
s
trncpy(address, email, maxSize - 1);
- address[maxSize - 1] =
'\0'
;
+
wxS
trncpy(address, email, maxSize - 1);
+ address[maxSize - 1] =
_T('\0')
;
return TRUE;
}
return TRUE;
}
@@
-839,7
+843,7
@@
wxString wxGetEmailAddress()
if ( !!user )
{
wxString email(user);
if ( !!user )
{
wxString email(user);
- email <<
'@'
<< host;
+ email <<
_T('@')
<< host;
}
}
}
}
@@
-889,3
+893,18
@@
wxString wxGetHostName()
return buf;
}
return buf;
}
+wxString wxGetFullHostName()
+{
+ static const size_t hostnameSize = 257;
+
+ wxString buf;
+ bool ok = wxGetFullHostName(buf.GetWriteBuf(hostnameSize), hostnameSize);
+
+ buf.UngetWriteBuf();
+
+ if ( !ok )
+ buf.Empty();
+
+ return buf;
+}
+