#include "wx/window.h"
#include "wx/menu.h"
#include "wx/frame.h"
+#include "wx/msgdlg.h"
+#include "wx/textdlg.h"
#endif
-#if USE_IOSTREAMH
+#if wxUSE_IOSTREAMH
#include <iostream.h>
+#include <fstream.h>
#else
#include <iostream>
+#include <fstream>
+# ifdef _MSC_VER
+ using namespace std;
+# endif
#endif
-#include <fstream.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
StringToFloat (char *s, float *number)
{
if (s && *s && number)
- *number = (float) strtod (s, NULL);
+ *number = (float) strtod (s, (char **) NULL);
}
void
StringToDouble (char *s, double *number)
{
if (s && *s && number)
- *number = strtod (s, NULL);
+ *number = strtod (s, (char **) NULL);
}
char *
StringToInt (char *s, int *number)
{
if (s && *s && number)
- *number = (int) strtol (s, NULL, 10);
+ *number = (int) strtol (s, (char **) NULL, 10);
}
void
StringToLong (char *s, long *number)
{
if (s && *s && number)
- *number = strtol (s, NULL, 10);
+ *number = strtol (s, (char **) NULL, 10);
}
char *
'C', 'D', 'E', 'F' };
// Convert 2-digit hex number to decimal
-int wxHexToDec(char *buf)
+int wxHexToDec(const wxString& buf)
{
int firstDigit, secondDigit;
- if (buf[0] >= 'A')
- firstDigit = buf[0] - 'A' + 10;
+ if (buf.GetChar(0) >= 'A')
+ firstDigit = buf.GetChar(0) - 'A' + 10;
else
- firstDigit = buf[0] - '0';
+ firstDigit = buf.GetChar(0) - '0';
- if (buf[1] >= 'A')
- secondDigit = buf[1] - 'A' + 10;
+ if (buf.GetChar(1) >= 'A')
+ secondDigit = buf.GetChar(1) - 'A' + 10;
else
- secondDigit = buf[1] - '0';
+ secondDigit = buf.GetChar(1) - '0';
return firstDigit * 16 + secondDigit;
}
buf[2] = 0;
}
+// Convert decimal integer to 2-character hex string
+wxString wxDecToHex(int dec)
+{
+ char buf[3];
+ wxDecToHex(dec, buf);
+ return wxString(buf);
+}
+
// Match a string INDEPENDENT OF CASE
bool
StringMatch (char *str1, char *str2, bool subString, bool exact)
// [volatile]
wxString wxNow( void )
{
- time_t now = time(NULL);
+ time_t now = time((time_t *) NULL);
char *date = ctime(&now);
date[24] = '\0';
return wxString(date);
char *wxStripMenuCodes (char *in, char *out)
{
if (!in)
- return NULL;
+ return (char *) NULL;
if (!out)
out = copystring(in);
return tmpOut;
}
+wxString wxStripMenuCodes(const wxString& str)
+{
+ char *buf = new char[str.Length() + 1];
+ wxStripMenuCodes((char*) (const char*) str, buf);
+ wxString str1(buf);
+ delete[] buf;
+ return str1;
+}
/*
* Window search functions
} // for()
}
- return NULL;
+ return (wxWindow *) NULL;
}
// Recursive
if (parent)
{
- for (wxNode * node = parent->GetChildren()->First (); node; node = node->Next ())
+ for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
{
wxWindow *win = (wxWindow *) node->Data ();
wxWindow *retwin = wxFindWindowByLabel1 (title, win);
}
- return NULL; // Not found
+ return (wxWindow *) NULL; // Not found
}
if (parent)
{
- for (wxNode * node = parent->GetChildren()->First (); node; node = node->Next ())
+ for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
{
wxWindow *win = (wxWindow *) node->Data ();
wxWindow *retwin = wxFindWindowByName1 (title, win);
}
- return NULL; // Not found
+ return (wxWindow *) NULL; // Not found
}
wxDebugStreamBuf::wxDebugStreamBuf(void)
{
- if (allocate()) setp(base(),ebuf());
+ // <iostream> usage doesn't need this, and i have no idea how to simulate it.
+#if wxUSE_IOSTREAMH
+ if (allocate())
+ setp(base(),ebuf());
+#endif
}
int wxDebugStreamBuf::overflow(int WXUNUSED(i))
#endif
+/*
+ * N.B. these convenience functions must be separate from msgdlgg.cpp, textdlgg.cpp
+ * since otherwise the generic code may be pulled in unnecessarily.
+ */
+
+int wxMessageBox(const wxString& message, const wxString& caption, long style,
+ wxWindow *parent, int WXUNUSED(x), int WXUNUSED(y) )
+{
+ wxMessageDialog dialog(parent, message, caption, style);
+
+ int ans = dialog.ShowModal();
+ switch ( ans )
+ {
+ case wxID_OK:
+ return wxOK;
+ break;
+ case wxID_YES:
+ return wxYES;
+ break;
+ case wxID_NO:
+ return wxNO;
+ break;
+ default:
+ case wxID_CANCEL:
+ return wxCANCEL;
+ break;
+ }
+ return ans;
+}
+
+wxString wxGetTextFromUser(const wxString& message, const wxString& caption,
+ const wxString& defaultValue, wxWindow *parent,
+ int x, int y, bool WXUNUSED(centre) )
+{
+ wxTextEntryDialog dialog(parent, message, caption, defaultValue, wxOK|wxCANCEL, wxPoint(x, y));
+ if (dialog.ShowModal() == wxID_OK)
+ return dialog.GetValue();
+ else
+ return wxString("");
+}
+