X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2f6c54eb076d760cbb6fb15e899f15fbbd575850..c687b303a5040da07009ea93504121aeec56682a:/samples/db/dbtest.cpp diff --git a/samples/db/dbtest.cpp b/samples/db/dbtest.cpp index 3abb6ffb0c..8b91e280cd 100644 --- a/samples/db/dbtest.cpp +++ b/samples/db/dbtest.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Name: dbtest.cpp -// Purpose: wxWindows database demo app +// Purpose: wxWidgets database demo app // Author: George Tasker // Modified by: // Created: 1998 @@ -32,24 +32,24 @@ #endif //__BORLANDC__ #ifndef WX_PRECOMP -#include +#include "wx/wx.h" #endif //WX_PRECOMP -#ifdef __WXGTK__ +#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMAC__) #include "db.xpm" #endif #include /* Included strictly for reading the text file with the database parameters */ -//#include /* Required in the file which will get the data source connection */ -//#include /* Has the wxDbTable object from which all data objects will inherit their data table functionality */ +//#include "wx/db.h" /* Required in the file which will get the data source connection */ +//#include "wx/dbtable.h" /* Has the wxDbTable object from which all data objects will inherit their data table functionality */ //extern wxDbList WXDLLEXPORT *PtrBegDbList; /* from db.cpp, used in getting back error results from db connections */ -#if wxUSE_NEW_GRID -#include -#include -#include +#if wxUSE_GRID +#include "wx/grid.h" +#include "wx/generic/gridctrl.h" +#include "wx/dbgrid.h" #define CHOICEINT #endif @@ -62,20 +62,31 @@ IMPLEMENT_APP(DatabaseDemoApp) extern wxChar ListDB_Selection[]; /* Used to return the first column value for the selected line from the listDB routines */ extern wxChar ListDB_Selection2[]; /* Used to return the second column value for the selected line from the listDB routines */ +#ifdef wxODBC_BLOB_SUPPORT + #include "wx/file.h" + #include "wx/mstream.h" + #include "wx/image.h" + #include "wx/bitmap.h" + #include "wx/statbmp.h" +#endif #if !wxUSE_ODBC #error Sample cannot be compiled unless setup.h has wxUSE_ODBC set to 1 #endif -bool DataTypeSupported(wxDb *pDb, SWORD datatype) +bool DataTypeSupported(wxDb *pDb, SWORD datatype, wxString *nativeDataTypeName) { wxDbSqlTypeInfo sqlTypeInfo; - bool breakpoint = FALSE; + bool breakpoint = false; + *nativeDataTypeName = wxEmptyString; if (pDb->GetDataTypeInfo(datatype, sqlTypeInfo)) - breakpoint = TRUE; + { + *nativeDataTypeName = sqlTypeInfo.TypeName; + breakpoint = true; + } return breakpoint; @@ -85,266 +96,544 @@ bool DataTypeSupported(wxDb *pDb, SWORD datatype) void CheckSupportForAllDataTypes(wxDb *pDb) { - wxLogMessage("\nThe following datatypes are supported by the\ndatabase you are currently connected to:"); + wxString nativeDataTypeName; + + wxLogMessage(wxT("\nThe following datatypes are supported by the\ndatabase you are currently connected to:")); #ifdef SQL_C_BINARY - if (DataTypeSupported(pDb,SQL_C_BINARY)) - wxLogMessage("SQL_C_BINARY"); + if (DataTypeSupported(pDb,SQL_C_BINARY, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_BINARY (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_BIT - if (DataTypeSupported(pDb,SQL_C_BIT)) - wxLogMessage("SQL_C_BIT"); + if (DataTypeSupported(pDb,SQL_C_BIT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_BIT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_BOOKMARK - if (DataTypeSupported(pDb,SQL_C_BOOKMARK)) - wxLogMessage("SQL_C_BOOKMARK"); + if (DataTypeSupported(pDb,SQL_C_BOOKMARK, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_BOOKMARK (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_CHAR - if (DataTypeSupported(pDb,SQL_C_CHAR)) - wxLogMessage("SQL_C_CHAR"); + if (DataTypeSupported(pDb,SQL_C_CHAR, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_CHAR (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_DATE - if (DataTypeSupported(pDb,SQL_C_DATE)) - wxLogMessage("SQL_C_DATE"); + if (DataTypeSupported(pDb,SQL_C_DATE, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_DATE (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_DEFAULT - if (DataTypeSupported(pDb,SQL_C_DEFAULT)) - wxLogMessage("SQL_C_DEFAULT"); + if (DataTypeSupported(pDb,SQL_C_DEFAULT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_DEFAULT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_DOUBLE - if (DataTypeSupported(pDb,SQL_C_DOUBLE)) - wxLogMessage("SQL_C_DOUBLE"); + if (DataTypeSupported(pDb,SQL_C_DOUBLE, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_DOUBLE (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_FLOAT - if (DataTypeSupported(pDb,SQL_C_FLOAT)) - wxLogMessage("SQL_C_FLOAT"); + if (DataTypeSupported(pDb,SQL_C_FLOAT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_FLOAT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_GUID - if (DataTypeSupported(pDb,SQL_C_GUID)) - wxLogMessage("SQL_C_GUID"); + if (DataTypeSupported(pDb,SQL_C_GUID, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_GUID (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_DAY - if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY)) - wxLogMessage("SQL_C_INTERVAL_DAY"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_DAY (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_DAY_TO_HOUR - if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_HOUR)) - wxLogMessage("SQL_C_INTERVAL_DAY_TO_HOUR"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_HOUR, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_DAY_TO_HOUR (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_DAY_TO_MINUTE - if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_MINUTE)) - wxLogMessage("SQL_C_INTERVAL_DAY_TO_MINUTE"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_MINUTE, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_DAY_TO_MINUTE (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_DAY_TO_SECOND - if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_SECOND)) - wxLogMessage("SQL_C_INTERVAL_DAY_TO_SECOND"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_SECOND, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_DAY_TO_SECOND (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_HOUR - if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR)) - wxLogMessage("SQL_C_INTERVAL_HOUR"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_HOUR (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_HOUR_TO_MINUTE - if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR_TO_MINUTE)) - wxLogMessage("SQL_C_INTERVAL_HOUR_TO_MINUTE"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR_TO_MINUTE, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_HOUR_TO_MINUTE (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_HOUR_TO_SECOND - if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR_TO_SECOND)) - wxLogMessage("SQL_C_INTERVAL_HOUR_TO_SECOND"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR_TO_SECOND, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_HOUR_TO_SECOND (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_MINUTE - if (DataTypeSupported(pDb,SQL_C_INTERVAL_MINUTE)) - wxLogMessage("SQL_C_INTERVAL_MINUTE"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_MINUTE, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_MINUTE (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_MINUTE_TO_SECOND - if (DataTypeSupported(pDb,SQL_C_INTERVAL_MINUTE_TO_SECOND)) - wxLogMessage("SQL_C_INTERVAL_MINUTE_TO_SECOND"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_MINUTE_TO_SECOND, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_MINUTE_TO_SECOND (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_MONTH - if (DataTypeSupported(pDb,SQL_C_INTERVAL_MONTH)) - wxLogMessage("SQL_C_INTERVAL_MONTH"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_MONTH, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_MONTH (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_SECOND - if (DataTypeSupported(pDb,SQL_C_INTERVAL_SECOND)) - wxLogMessage("SQL_C_INTERVAL_SECOND"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_SECOND, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_SECOND (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_YEAR - if (DataTypeSupported(pDb,SQL_C_INTERVAL_YEAR)) - wxLogMessage("SQL_C_INTERVAL_YEAR"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_YEAR, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_YEAR (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_INTERVAL_YEAR_TO_MONTH - if (DataTypeSupported(pDb,SQL_C_INTERVAL_YEAR_TO_MONTH)) - wxLogMessage("SQL_C_INTERVAL_YEAR_TO_MONTH"); + if (DataTypeSupported(pDb,SQL_C_INTERVAL_YEAR_TO_MONTH, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_INTERVAL_YEAR_TO_MONTH (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_LONG - if (DataTypeSupported(pDb,SQL_C_LONG)) - wxLogMessage("SQL_C_LONG"); + if (DataTypeSupported(pDb,SQL_C_LONG, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_LONG (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_NUMERIC - if (DataTypeSupported(pDb,SQL_C_NUMERIC)) - wxLogMessage("SQL_C_NUMERIC"); + if (DataTypeSupported(pDb,SQL_C_NUMERIC, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_NUMERIC (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_SBIGINT - if (DataTypeSupported(pDb,SQL_C_SBIGINT)) - wxLogMessage("SQL_C_SBIGINT"); + if (DataTypeSupported(pDb,SQL_C_SBIGINT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_SBIGINT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_SHORT - if (DataTypeSupported(pDb,SQL_C_SHORT)) - wxLogMessage("SQL_C_SHORT"); + if (DataTypeSupported(pDb,SQL_C_SHORT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_SHORT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_SLONG - if (DataTypeSupported(pDb,SQL_C_SLONG)) - wxLogMessage("SQL_C_SLONG"); + if (DataTypeSupported(pDb,SQL_C_SLONG, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_SLONG (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_SSHORT - if (DataTypeSupported(pDb,SQL_C_SSHORT)) - wxLogMessage("SQL_C_SSHORT"); + if (DataTypeSupported(pDb,SQL_C_SSHORT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_SSHORT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_STINYINT - if (DataTypeSupported(pDb,SQL_C_STINYINT)) - wxLogMessage("SQL_C_STINYINT"); + if (DataTypeSupported(pDb,SQL_C_STINYINT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_STINYINT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_TIME - if (DataTypeSupported(pDb,SQL_C_TIME)) - wxLogMessage("SQL_C_TIME"); + if (DataTypeSupported(pDb,SQL_C_TIME, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_TIME (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_TIMESTAMP - if (DataTypeSupported(pDb,SQL_C_TIMESTAMP)) - wxLogMessage("SQL_C_TIMESTAMP"); + if (DataTypeSupported(pDb,SQL_C_TIMESTAMP, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_TIMESTAMP (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_TINYINT - if (DataTypeSupported(pDb,SQL_C_TINYINT)) - wxLogMessage("SQL_C_TINYINT"); + if (DataTypeSupported(pDb,SQL_C_TINYINT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_TINYINT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_TYPE_DATE - if (DataTypeSupported(pDb,SQL_C_TYPE_DATE)) - wxLogMessage("SQL_C_TYPE_DATE"); + if (DataTypeSupported(pDb,SQL_C_TYPE_DATE, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_TYPE_DATE (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_TYPE_TIME - if (DataTypeSupported(pDb,SQL_C_TYPE_TIME)) - wxLogMessage("SQL_C_TYPE_TIME"); + if (DataTypeSupported(pDb,SQL_C_TYPE_TIME, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_TYPE_TIME (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_TYPE_TIMESTAMP - if (DataTypeSupported(pDb,SQL_C_TYPE_TIMESTAMP)) - wxLogMessage("SQL_C_TYPE_TIMESTAMP"); + if (DataTypeSupported(pDb,SQL_C_TYPE_TIMESTAMP, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_TYPE_TIMESTAMP (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_UBIGINT - if (DataTypeSupported(pDb,SQL_C_UBIGINT)) - wxLogMessage("SQL_C_UBIGINT"); + if (DataTypeSupported(pDb,SQL_C_UBIGINT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_UBIGINT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_ULONG - if (DataTypeSupported(pDb,SQL_C_ULONG)) - wxLogMessage("SQL_C_ULONG"); + if (DataTypeSupported(pDb,SQL_C_ULONG, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_ULONG (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_USHORT - if (DataTypeSupported(pDb,SQL_C_USHORT)) - wxLogMessage("SQL_C_USHORT"); + if (DataTypeSupported(pDb,SQL_C_USHORT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_USHORT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_UTINYINT - if (DataTypeSupported(pDb,SQL_C_UTINYINT)) - wxLogMessage("SQL_C_UTINYINT"); + if (DataTypeSupported(pDb,SQL_C_UTINYINT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_UTINYINT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_C_VARBOOKMARK - if (DataTypeSupported(pDb,SQL_C_VARBOOKMARK)) - wxLogMessage("SQL_C_VARBOOKMARK"); + if (DataTypeSupported(pDb,SQL_C_VARBOOKMARK, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_VARBOOKMARK (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } +#endif +#ifdef SQL_C_WXCHAR + if (DataTypeSupported(pDb,SQL_C_WXCHAR, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_WXCHAR (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif // Extended SQL types #ifdef SQL_DATE - if (DataTypeSupported(pDb,SQL_DATE)) - wxLogMessage("SQL_DATE"); + if (DataTypeSupported(pDb,SQL_DATE, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_DATE (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_INTERVAL - if (DataTypeSupported(pDb,SQL_INTERVAL)) - wxLogMessage("SQL_INTERVAL"); + if (DataTypeSupported(pDb,SQL_INTERVAL, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_INTERVAL (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_TIME - if (DataTypeSupported(pDb,SQL_TIME)) - wxLogMessage("SQL_TIME"); + if (DataTypeSupported(pDb,SQL_TIME, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_TIME (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_TIMESTAMP - if (DataTypeSupported(pDb,SQL_TIMESTAMP)) - wxLogMessage("SQL_TIMESTAMP"); + if (DataTypeSupported(pDb,SQL_TIMESTAMP, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_TIMESTAMP (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_LONGVARCHAR - if (DataTypeSupported(pDb,SQL_LONGVARCHAR)) - wxLogMessage("SQL_LONGVARCHAR"); + if (DataTypeSupported(pDb,SQL_LONGVARCHAR, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_LONGVARCHAR (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_BINARY - if (DataTypeSupported(pDb,SQL_BINARY)) - wxLogMessage("SQL_BINARY"); + if (DataTypeSupported(pDb,SQL_BINARY, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_BINARY (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_VARBINARY - if (DataTypeSupported(pDb,SQL_VARBINARY)) - wxLogMessage("SQL_VARBINARY"); + if (DataTypeSupported(pDb,SQL_VARBINARY, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_VARBINARY (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_LONGVARBINARY - if (DataTypeSupported(pDb,SQL_LONGVARBINARY)) - wxLogMessage("SQL_LONGVARBINARY"); + if (DataTypeSupported(pDb,SQL_LONGVARBINARY, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_LOGVARBINARY (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_BIGINT - if (DataTypeSupported(pDb,SQL_BIGINT)) - wxLogMessage("SQL_BIGINT"); + if (DataTypeSupported(pDb,SQL_BIGINT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_BIGINT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_TINYINT - if (DataTypeSupported(pDb,SQL_TINYINT)) - wxLogMessage("SQL_TINYINT"); + if (DataTypeSupported(pDb,SQL_TINYINT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_TINYINT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_BIT - if (DataTypeSupported(pDb,SQL_BIT)) - wxLogMessage("SQL_BIT"); + if (DataTypeSupported(pDb,SQL_BIT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_BIT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_GUID - if (DataTypeSupported(pDb,SQL_GUID)) - wxLogMessage("SQL_GUID"); + if (DataTypeSupported(pDb,SQL_GUID, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_GUID (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_CHAR - if (DataTypeSupported(pDb,SQL_CHAR)) - wxLogMessage("SQL_CHAR"); + if (DataTypeSupported(pDb,SQL_CHAR, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_CHAR (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_INTEGER - if (DataTypeSupported(pDb,SQL_INTEGER)) - wxLogMessage("SQL_INTEGER"); + if (DataTypeSupported(pDb,SQL_INTEGER, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_INTEGER (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_SMALLINT - if (DataTypeSupported(pDb,SQL_SMALLINT)) - wxLogMessage("SQL_SMALLINT"); + if (DataTypeSupported(pDb,SQL_SMALLINT, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_SAMLLINT (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_REAL - if (DataTypeSupported(pDb,SQL_REAL)) - wxLogMessage("SQL_REAL"); + if (DataTypeSupported(pDb,SQL_REAL, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_REAL (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_DOUBLE - if (DataTypeSupported(pDb,SQL_DOUBLE)) - wxLogMessage("SQL_DOUBLE"); + if (DataTypeSupported(pDb,SQL_DOUBLE, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_DOUBLE (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_NUMERIC - if (DataTypeSupported(pDb,SQL_NUMERIC)) - wxLogMessage("SQL_NUMERIC"); + if (DataTypeSupported(pDb,SQL_NUMERIC, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_NUMERIC (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_DATE - if (DataTypeSupported(pDb,SQL_DATE)) - wxLogMessage("SQL_DATE"); + if (DataTypeSupported(pDb,SQL_DATE, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_DATE (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_TIME - if (DataTypeSupported(pDb,SQL_TIME)) - wxLogMessage("SQL_TIME"); + if (DataTypeSupported(pDb,SQL_TIME, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_TIME (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_TIMESTAMP - if (DataTypeSupported(pDb,SQL_TIMESTAMP)) - wxLogMessage("SQL_TIMESTAMP"); + if (DataTypeSupported(pDb,SQL_TIMESTAMP, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_TIMESTAMP (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif #ifdef SQL_VARCHAR - if (DataTypeSupported(pDb,SQL_VARCHAR)) - wxLogMessage("SQL_VARCHAR"); + if (DataTypeSupported(pDb,SQL_VARCHAR, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_VARCHAR (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif // UNICODE #ifdef SQL_C_TCHAR - if (DataTypeSupported(pDb,SQL_C_TCHAR)) - wxLogMessage("SQL_C_TCHAR (Unicode support is possible)"); + if (DataTypeSupported(pDb,SQL_C_TCHAR, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_C_TCHAR (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } +#endif +#ifdef SQL_WVARCHAR + if (DataTypeSupported(pDb,SQL_WVARCHAR, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_WVARCHAR (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } +#endif +#ifdef SQL_WCHAR + if (DataTypeSupported(pDb,SQL_WCHAR, &nativeDataTypeName)) + { + nativeDataTypeName = wxT("SQL_WCHAR (") + nativeDataTypeName; + nativeDataTypeName += wxT(")\n"); + wxLogMessage(nativeDataTypeName); + } #endif - wxLogMessage("\n"); + wxLogMessage(wxT("Done\n")); } // CheckSupportForAllDataTypes() @@ -354,17 +643,17 @@ bool DatabaseDemoApp::OnInit() Contact = NULL; // Create the main frame window - DemoFrame = new DatabaseDemoFrame(NULL, wxT("wxWindows Database Demo"), wxPoint(50, 50), wxSize(537, 480)); + DemoFrame = new DatabaseDemoFrame(NULL, wxT("wxWidgets Database Demo"), wxPoint(50, 50), wxSize(537, 530)); // Give it an icon DemoFrame->SetIcon(wxICON(db)); // Make a menubar wxMenu *file_menu = new wxMenu; - file_menu->Append(FILE_CREATE, wxT("&Create CONTACT table")); + file_menu->Append(FILE_CREATE_ID, wxT("&Create CONTACT table")); file_menu->Append(FILE_RECREATE_TABLE, wxT("&Recreate CONTACT table")); file_menu->Append(FILE_RECREATE_INDEXES, wxT("&Recreate CONTACT indexes")); -#if wxUSE_NEW_GRID +#if wxUSE_GRID file_menu->Append(FILE_DBGRID_TABLE, wxT("&Open DB Grid example")); #endif file_menu->Append(FILE_EXIT, wxT("E&xit")); @@ -386,8 +675,14 @@ bool DatabaseDemoApp::OnInit() params.Password[0] = 0; params.DirPath[0] = 0; +#ifdef wxODBC_BLOB_SUPPORT + wxInitAllImageHandlers(); + wxImage::InitStandardHandlers(); + wxBitmap::InitStandardHandlers(); +#endif + // Show the frame - DemoFrame->Show(TRUE); + DemoFrame->Show(true); // Passing NULL for the SQL environment handle causes // the wxDbConnectInf constructor to obtain a handle @@ -396,7 +691,7 @@ bool DatabaseDemoApp::OnInit() // WARNING: Be certain that you do not free this handle // directly with SQLFreeEnv(). Use either the // method ::FreeHenv() or delete the DbConnectInf. - DbConnectInf = new wxDbConnectInf(NULL, params.ODBCSource, params.UserName, + DbConnectInf = new wxDbConnectInf(NULL, params.ODBCSource, params.UserName, params.Password, params.DirPath); if (!DbConnectInf || !DbConnectInf->GetHenv()) @@ -411,7 +706,7 @@ bool DatabaseDemoApp::OnInit() if (!wxStrlen(params.ODBCSource)) { wxDELETE(DbConnectInf); - return(FALSE); + return(false); } DbConnectInf->SetDsn(params.ODBCSource); @@ -426,7 +721,7 @@ bool DatabaseDemoApp::OnInit() DemoFrame->BuildParameterDialog(NULL); wxDELETE(DbConnectInf); wxMessageBox(wxT("Now exiting program.\n\nRestart program to try any new settings."),wxT("Notice..."),wxOK | wxICON_INFORMATION); - return(FALSE); + return(false); } DemoFrame->BuildEditorDialog(); @@ -434,18 +729,18 @@ bool DatabaseDemoApp::OnInit() // Show the frame DemoFrame->Refresh(); - return TRUE; + return true; } // DatabaseDemoApp::OnInit() /* * Remove CR or CR/LF from a character string. */ -char* wxRemoveLineTerminator(char* aString) +wxChar* wxRemoveLineTerminator(wxChar* aString) { - int len = strlen(aString); - while (len > 0 && (aString[len-1] == '\r' || aString[len-1] == '\n')) { - aString[len-1] = '\0'; + int len = wxStrlen(aString); + while (len > 0 && (aString[len-1] == wxT('\r') || aString[len-1] == wxT('\n'))) { + aString[len-1] = wxT('\0'); len--; } return aString; @@ -455,66 +750,66 @@ char* wxRemoveLineTerminator(char* aString) bool DatabaseDemoApp::ReadParamFile(Cparameters ¶ms) { FILE *paramFile; - if ((paramFile = fopen(PARAM_FILENAME, wxT("r"))) == NULL) + if ((paramFile = wxFopen(PARAM_FILENAME, wxT("r"))) == NULL) { wxString tStr; - tStr.Printf(wxT("Unable to open the parameter file '%s' for reading.\n\nYou must specify the data source, user name, and\npassword that will be used and save those settings."),PARAM_FILENAME); + tStr.Printf(wxT("Unable to open the parameter file '%s' for reading.\n\nYou must specify the data source, user name, and\npassword that will be used and save those settings."),PARAM_FILENAME.c_str()); wxMessageBox(tStr,wxT("File I/O Error..."),wxOK | wxICON_EXCLAMATION); - return FALSE; + return false; } wxChar buffer[1000+1]; - fgets(buffer, sizeof(params.ODBCSource), paramFile); + wxFgets(buffer, sizeof(params.ODBCSource), paramFile); wxRemoveLineTerminator(buffer); wxStrcpy(params.ODBCSource,buffer); - fgets(buffer, sizeof(params.UserName), paramFile); + wxFgets(buffer, sizeof(params.UserName), paramFile); wxRemoveLineTerminator(buffer); wxStrcpy(params.UserName,buffer); - fgets(buffer, sizeof(params.Password), paramFile); + wxFgets(buffer, sizeof(params.Password), paramFile); wxRemoveLineTerminator(buffer); wxStrcpy(params.Password,buffer); - fgets(buffer, sizeof(params.DirPath), paramFile); + wxFgets(buffer, sizeof(params.DirPath), paramFile); wxRemoveLineTerminator(buffer); wxStrcpy(params.DirPath,buffer); fclose(paramFile); - return TRUE; + return true; } // DatabaseDemoApp::ReadParamFile() -bool DatabaseDemoApp::WriteParamFile(Cparameters ¶ms) +bool DatabaseDemoApp::WriteParamFile(Cparameters &WXUNUSED(params)) { FILE *paramFile; - if ((paramFile = fopen(PARAM_FILENAME, wxT("wt"))) == NULL) + if ((paramFile = wxFopen(PARAM_FILENAME, wxT("wt"))) == NULL) { wxString tStr; - tStr.Printf(wxT("Unable to write/overwrite '%s'."),PARAM_FILENAME); + tStr.Printf(wxT("Unable to write/overwrite '%s'."),PARAM_FILENAME.c_str()); wxMessageBox(tStr,wxT("File I/O Error..."),wxOK | wxICON_EXCLAMATION); - return FALSE; + return false; } - fputs(wxGetApp().params.ODBCSource, paramFile); - fputc(wxT('\n'), paramFile); - fputs(wxGetApp().params.UserName, paramFile); - fputc(wxT('\n'), paramFile); - fputs(wxGetApp().params.Password, paramFile); - fputc(wxT('\n'), paramFile); - fputs(wxGetApp().params.DirPath, paramFile); - fputc(wxT('\n'), paramFile); + wxFputs(wxGetApp().params.ODBCSource, paramFile); + wxFputc(wxT('\n'), paramFile); + wxFputs(wxGetApp().params.UserName, paramFile); + wxFputc(wxT('\n'), paramFile); + wxFputs(wxGetApp().params.Password, paramFile); + wxFputc(wxT('\n'), paramFile); + wxFputs(wxGetApp().params.DirPath, paramFile); + wxFputc(wxT('\n'), paramFile); fclose(paramFile); - return TRUE; + return true; } // DatabaseDemoApp::WriteParamFile() void DatabaseDemoApp::CreateDataTable(bool recreate) { - bool Ok = TRUE; + bool Ok = true; if (recreate) Ok = (wxMessageBox(wxT("Any data currently residing in the table will be erased.\n\nAre you sure?"),wxT("Confirm"),wxYES_NO|wxICON_QUESTION) == wxYES); @@ -523,7 +818,7 @@ void DatabaseDemoApp::CreateDataTable(bool recreate) wxBeginBusyCursor(); - bool success = TRUE; + bool success = true; Contact->GetDb()->RollbackTrans(); // Make sure the current cursor is in a known/stable state @@ -532,10 +827,10 @@ void DatabaseDemoApp::CreateDataTable(bool recreate) wxEndBusyCursor(); wxString tStr; tStr = wxT("Error creating CONTACTS table.\nTable was not created.\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); - success = FALSE; + success = false; } else { @@ -544,10 +839,10 @@ void DatabaseDemoApp::CreateDataTable(bool recreate) wxEndBusyCursor(); wxString tStr; tStr = wxT("Error creating CONTACTS indexes.\nIndexes will be unavailable.\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); - success = FALSE; + success = false; } } while (wxIsBusy()) @@ -559,10 +854,10 @@ void DatabaseDemoApp::CreateDataTable(bool recreate) BEGIN_EVENT_TABLE(DatabaseDemoFrame, wxFrame) - EVT_MENU(FILE_CREATE, DatabaseDemoFrame::OnCreate) + EVT_MENU(FILE_CREATE_ID, DatabaseDemoFrame::OnCreate) EVT_MENU(FILE_RECREATE_TABLE, DatabaseDemoFrame::OnRecreateTable) EVT_MENU(FILE_RECREATE_INDEXES, DatabaseDemoFrame::OnRecreateIndexes) -#if wxUSE_NEW_GRID +#if wxUSE_GRID EVT_MENU(FILE_DBGRID_TABLE, DatabaseDemoFrame::OnDbGridTable) #endif EVT_MENU(FILE_EXIT, DatabaseDemoFrame::OnExit) @@ -575,45 +870,49 @@ END_EVENT_TABLE() // DatabaseDemoFrame constructor DatabaseDemoFrame::DatabaseDemoFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size): - wxFrame(frame, -1, title, pos, size) + wxFrame(frame, wxID_ANY, title, pos, size) { // Put any code in necessary for initializing the main frame here pEditorDlg = NULL; pParamDlg = NULL; +#if wxUSE_LOG delete wxLog::SetActiveTarget(new wxLogStderr); +#endif // wxUSE_LOG } // DatabaseDemoFrame constructor DatabaseDemoFrame::~DatabaseDemoFrame() { +#if wxUSE_LOG delete wxLog::SetActiveTarget(NULL); +#endif // wxUSE_LOG } // DatabaseDemoFrame destructor -void DatabaseDemoFrame::OnCreate(wxCommandEvent& event) +void DatabaseDemoFrame::OnCreate(wxCommandEvent& WXUNUSED(event)) { - wxGetApp().CreateDataTable(FALSE); + wxGetApp().CreateDataTable(false); } // DatabaseDemoFrame::OnCreate() -void DatabaseDemoFrame::OnRecreateTable(wxCommandEvent& event) +void DatabaseDemoFrame::OnRecreateTable(wxCommandEvent& WXUNUSED(event)) { - wxGetApp().CreateDataTable(TRUE); + wxGetApp().CreateDataTable(true); } // DatabaseDemoFrame::OnRecreate() -void DatabaseDemoFrame::OnRecreateIndexes(wxCommandEvent& event) +void DatabaseDemoFrame::OnRecreateIndexes(wxCommandEvent& WXUNUSED(event)) { wxGetApp().Contact->GetDb()->RollbackTrans(); // Make sure the current cursor is in a known/stable state - if (!wxGetApp().Contact->CreateIndexes(TRUE)) + if (!wxGetApp().Contact->CreateIndexes(true)) { while (wxIsBusy()) wxEndBusyCursor(); wxString tStr; tStr = wxT("Error creating CONTACTS indexes.\nNew indexes will be unavailable.\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); } @@ -623,8 +922,8 @@ void DatabaseDemoFrame::OnRecreateIndexes(wxCommandEvent& event) } // DatabaseDemoFrame::OnRecreateIndexes() -#if wxUSE_NEW_GRID -void DatabaseDemoFrame::OnDbGridTable(wxCommandEvent& ) +#if wxUSE_GRID +void DatabaseDemoFrame::OnDbGridTable(wxCommandEvent& WXUNUSED(event)) { DbGridFrame *frame = new DbGridFrame(this); if (frame->Initialize()) @@ -634,13 +933,13 @@ void DatabaseDemoFrame::OnDbGridTable(wxCommandEvent& ) } #endif -void DatabaseDemoFrame::OnExit(wxCommandEvent& event) +void DatabaseDemoFrame::OnExit(wxCommandEvent& WXUNUSED(event)) { Close(); } // DatabaseDemoFrame::OnExit() -void DatabaseDemoFrame::OnEditParameters(wxCommandEvent& event) +void DatabaseDemoFrame::OnEditParameters(wxCommandEvent& WXUNUSED(event)) { if ((pEditorDlg->mode != mCreate) && (pEditorDlg->mode != mEdit)) BuildParameterDialog(this); @@ -649,9 +948,9 @@ void DatabaseDemoFrame::OnEditParameters(wxCommandEvent& event) } // DatabaseDemoFrame::OnEditParameters() -void DatabaseDemoFrame::OnAbout(wxCommandEvent& event) +void DatabaseDemoFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - wxMessageBox(wxT("wxWindows sample program for database classes\n\nContributed on 27 July 1998"),wxT("About..."),wxOK | wxICON_INFORMATION); + wxMessageBox(wxT("wxWidgets sample program for database classes\n\nContributed on 27 July 1998"),wxT("About..."),wxOK | wxICON_INFORMATION); } // DatabaseDemoFrame::OnAbout() @@ -701,7 +1000,7 @@ void DatabaseDemoFrame::BuildEditorDialog() wxMessageBox(wxT("Unable to initialize the editor dialog for some reason"),wxT("Error..."),wxOK | wxICON_EXCLAMATION); Close(); } - } + } else { wxMessageBox(wxT("Unable to create the editor dialog for some reason"),wxT("Error..."),wxOK | wxICON_EXCLAMATION); @@ -723,24 +1022,24 @@ void DatabaseDemoFrame::BuildParameterDialog(wxWindow *parent) * Constructor note: If no wxDb object is passed in, a new connection to the database * is created for this instance of Ccontact. This can be a slow process depending * on the database engine being used, and some database engines have a limit on the - * number of connections (either hard limits, or license restricted) so care should - * be used to use as few connections as is necessary. + * number of connections (either hard limits, or license restricted) so care should + * be used to use as few connections as is necessary. * - * IMPORTANT: Objects which share a wxDb pointer are ALL acted upon whenever a member - * function of pDb is called (i.e. CommitTrans() or RollbackTrans(), so if modifying + * IMPORTANT: Objects which share a wxDb pointer are ALL acted upon whenever a member + * function of pDb is called (i.e. CommitTrans() or RollbackTrans(), so if modifying * or creating a table objects which use the same pDb, know that all the objects * will be committed or rolled back when any of the objects has this function call made. */ Ccontact::Ccontact (wxDb *pwxDb) : wxDbTable(pwxDb ? pwxDb : wxDbGetConnection(wxGetApp().DbConnectInf), - CONTACT_TABLE_NAME, CONTACT_NO_COLS, wxT(""), + CONTACT_TABLE_NAME, CONTACT_NO_COLS, (const wxString &)wxEmptyString, !wxDB_QUERY_ONLY, wxGetApp().DbConnectInf->GetDefaultDir()) { // This is used to represent whether the database connection should be released // when this instance of the object is deleted. If using the same connection - // for multiple instance of database objects, then the connection should only be + // for multiple instance of database objects, then the connection should only be // released when the last database instance using the connection is deleted freeDbConn = !pwxDb; - + if (GetDb()) GetDb()->SetSqlLogging(sqlLogON); @@ -766,9 +1065,11 @@ void Ccontact::Initialize() JoinDate.second = 0; JoinDate.fraction = 0; NativeLanguage = langENGLISH; - IsDeveloper = FALSE; + IsDeveloper = false; Contributions = 0; LinesOfCode = 0L; + BlobSize = 0L; + memset(Picture, 0, MAX_PICTURE_SIZE); } // Ccontact::Initialize @@ -781,7 +1082,7 @@ Ccontact::~Ccontact() wxString tStr; tStr = wxT("Unable to Free the Ccontact data table handle\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); } } @@ -790,51 +1091,50 @@ Ccontact::~Ccontact() /* * Handles setting up all the connections for the interface from the wxDbTable - * functions to interface to the data structure used to store records in + * functions to interface to the data structure used to store records in * memory, and for all the column definitions that define the table structure */ void Ccontact::SetupColumns() { // NOTE: Columns now are 8 character names, as that is all dBase can support. Longer // names can be used for other database engines - SetColDefs ( 0,wxT("NAME"), DB_DATA_TYPE_VARCHAR, Name, SQL_C_CHAR, sizeof(Name), TRUE, TRUE); // Primary index - SetColDefs ( 1,wxT("ADDRESS1"), DB_DATA_TYPE_VARCHAR, Addr1, SQL_C_CHAR, sizeof(Addr1), FALSE,TRUE); - SetColDefs ( 2,wxT("ADDRESS2"), DB_DATA_TYPE_VARCHAR, Addr2, SQL_C_CHAR, sizeof(Addr2), FALSE,TRUE); - SetColDefs ( 3,wxT("CITY"), DB_DATA_TYPE_VARCHAR, City, SQL_C_CHAR, sizeof(City), FALSE,TRUE); - SetColDefs ( 4,wxT("STATE"), DB_DATA_TYPE_VARCHAR, State, SQL_C_CHAR, sizeof(State), FALSE,TRUE); - SetColDefs ( 5,wxT("POSTCODE"), DB_DATA_TYPE_VARCHAR, PostalCode, SQL_C_CHAR, sizeof(PostalCode), FALSE,TRUE); - SetColDefs ( 6,wxT("COUNTRY"), DB_DATA_TYPE_VARCHAR, Country, SQL_C_CHAR, sizeof(Country), FALSE,TRUE); - SetColDefs ( 7,wxT("JOINDATE"), DB_DATA_TYPE_DATE, &JoinDate, SQL_C_TIMESTAMP, sizeof(JoinDate), FALSE,TRUE); - SetColDefs ( 8,wxT("IS_DEV"), DB_DATA_TYPE_INTEGER, &IsDeveloper, SQL_C_BOOLEAN(IsDeveloper), sizeof(IsDeveloper), FALSE,TRUE); - SetColDefs ( 9,wxT("CONTRIBS"), DB_DATA_TYPE_INTEGER, &Contributions, SQL_C_UTINYINT, sizeof(Contributions), FALSE,TRUE); - SetColDefs (10,wxT("LINE_CNT"), DB_DATA_TYPE_INTEGER, &LinesOfCode, SQL_C_ULONG, sizeof(LinesOfCode), FALSE,TRUE); - SetColDefs (11,wxT("LANGUAGE"), DB_DATA_TYPE_INTEGER, &NativeLanguage, SQL_C_ENUM, sizeof(NativeLanguage), FALSE,TRUE); -#if wxODBC_BLOB_EXPERIMENT > 0 - SetColDefs (12,wxT("PICTURE"), DB_DATA_TYPE_BLOB, Picture, SQL_LONGVARBINARY, sizeof(Picture), FALSE,TRUE); + SetColDefs ( 0,wxT("NAME"), DB_DATA_TYPE_VARCHAR, Name, SQL_C_WXCHAR, sizeof(Name), true, true); // Primary index + SetColDefs ( 1,wxT("ADDRESS1"), DB_DATA_TYPE_VARCHAR, Addr1, SQL_C_WXCHAR, sizeof(Addr1), false,true); + SetColDefs ( 2,wxT("ADDRESS2"), DB_DATA_TYPE_VARCHAR, Addr2, SQL_C_WXCHAR, sizeof(Addr2), false,true); + SetColDefs ( 3,wxT("CITY"), DB_DATA_TYPE_VARCHAR, City, SQL_C_WXCHAR, sizeof(City), false,true); + SetColDefs ( 4,wxT("STATE"), DB_DATA_TYPE_VARCHAR, State, SQL_C_WXCHAR, sizeof(State), false,true); + SetColDefs ( 5,wxT("POSTCODE"), DB_DATA_TYPE_VARCHAR, PostalCode, SQL_C_WXCHAR, sizeof(PostalCode), false,true); + SetColDefs ( 6,wxT("COUNTRY"), DB_DATA_TYPE_VARCHAR, Country, SQL_C_WXCHAR, sizeof(Country), false,true); + SetColDefs ( 7,wxT("JOINDATE"), DB_DATA_TYPE_DATE, &JoinDate, SQL_C_TIMESTAMP, sizeof(JoinDate), false,true); + SetColDefs ( 8,wxT("IS_DEV"), DB_DATA_TYPE_INTEGER, &IsDeveloper, SQL_C_BOOLEAN(IsDeveloper), sizeof(IsDeveloper), false,true); + SetColDefs ( 9,wxT("CONTRIBS"), DB_DATA_TYPE_INTEGER, &Contributions, SQL_C_UTINYINT, sizeof(Contributions), false,true); + SetColDefs (10,wxT("LINE_CNT"), DB_DATA_TYPE_INTEGER, &LinesOfCode, SQL_C_ULONG, sizeof(LinesOfCode), false,true); + SetColDefs (11,wxT("LANGUAGE"), DB_DATA_TYPE_INTEGER, &NativeLanguage, SQL_C_ENUM, sizeof(NativeLanguage), false,true); +#ifdef wxODBC_BLOB_SUPPORT + SetColDefs (12,wxT("PICSIZE"), DB_DATA_TYPE_INTEGER, &BlobSize, SQL_C_ULONG, sizeof(BlobSize), false,true); + SetColDefs (13,wxT("PICTURE"), DB_DATA_TYPE_BLOB, Picture, SQL_C_BINARY, sizeof(Picture), false,true); #endif } // Ccontact::SetupColumns bool Ccontact::CreateIndexes(bool recreate) { - // This index could easily be accomplished with an "orderBy" clause, + // This index could easily be accomplished with an "orderBy" clause, // but is done to show how to construct a non-primary index. wxString indexName; wxDbIdxDef idxDef[2]; - bool Ok = TRUE; + wxStrcpy(idxDef[0].ColName, wxT("IS_DEV")); + idxDef[0].Ascending = true; - wxStrcpy(idxDef[0].ColName, "IS_DEV"); - idxDef[0].Ascending = TRUE; - - wxStrcpy(idxDef[1].ColName, "NAME"); - idxDef[1].Ascending = TRUE; + wxStrcpy(idxDef[1].ColName, wxT("NAME")); + idxDef[1].Ascending = true; indexName = GetTableName(); - indexName += "_IDX1"; - Ok = CreateIndex(indexName.c_str(), TRUE, 2, idxDef, recreate); + indexName += wxT("_IDX1"); + + return CreateIndex(indexName.c_str(), true, 2, idxDef, recreate); - return Ok; } // Ccontact::CreateIndexes() @@ -847,10 +1147,10 @@ bool Ccontact::FetchByName(const wxString &name) { whereStr.Printf(wxT("NAME = '%s'"),name.c_str()); SetWhereClause(whereStr.c_str()); - SetOrderByClause(wxT("")); + SetOrderByClause(wxEmptyString); if (!Query()) - return(FALSE); + return(false); // Fetch the record return(GetNext()); @@ -873,24 +1173,24 @@ bool Ccontact::FetchByName(const wxString &name) * An instance of Ccontact is created - "Contact" - which is used to hold the Ccontact * object that is currently being worked with. */ - + BEGIN_EVENT_TABLE(CeditorDlg, wxPanel) - EVT_BUTTON(-1, CeditorDlg::OnButton) + EVT_BUTTON(wxID_ANY, CeditorDlg::OnButton) EVT_CLOSE(CeditorDlg::OnCloseWindow) END_EVENT_TABLE() - -CeditorDlg::CeditorDlg(wxWindow *parent) : wxPanel (parent, 0, 0, 537, 480) + +CeditorDlg::CeditorDlg(wxWindow *parent) : wxPanel (parent, 0, 0, 537, 530) { // Since the ::OnCommand() function is overridden, this prevents the widget // detection in ::OnCommand() until all widgets have been initialized to prevent // uninitialized pointers from crashing the program - widgetPtrsSet = FALSE; + widgetPtrsSet = false; - initialized = FALSE; + initialized = false; SetMode(mView); - Show(FALSE); + Show(false); } // CeditorDlg constructor @@ -916,10 +1216,10 @@ void CeditorDlg::OnButton(wxCommandEvent &event) } // CeditorDlg::OnButton() -void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) +void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& WXUNUSED(event)) { wxString widgetName; - + widgetName = win.GetName(); if (!widgetPtrsSet) @@ -930,7 +1230,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) wxGetApp().Contact->Initialize(); PutData(); SetMode( mCreate ); - pNameTxt->SetValue(wxT("")); + pNameTxt->SetValue(wxEmptyString); pNameTxt->SetFocus(); return; } @@ -946,7 +1246,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) if (widgetName == pCopyBtn->GetName()) { SetMode(mCreate); - pNameTxt->SetValue(wxT("")); + pNameTxt->SetValue(wxEmptyString); pNameTxt->SetFocus(); return; } @@ -960,10 +1260,10 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) if (Ok && wxGetApp().Contact->Delete()) { - // NOTE: Deletions are not finalized until a CommitTrans() is performed. - // If the commit were not performed, the program will continue to + // NOTE: Deletions are not finalized until a CommitTrans() is performed. + // If the commit were not performed, the program will continue to // show the table contents as if they were deleted until this instance - // of Ccontact is deleted. If the Commit wasn't performed, the + // of Ccontact is deleted. If the Commit wasn't performed, the // database will automatically Rollback the changes when the database // connection is terminated wxGetApp().Contact->GetDb()->CommitTrans(); @@ -1003,7 +1303,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) if (!Ok) return; - if (saveName.IsEmpty()) + if (saveName.empty()) { wxGetApp().Contact->Initialize(); PutData(); @@ -1031,15 +1331,15 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) wxGetApp().Contact->SetWhereClause(wxGetApp().Contact->whereStr.c_str()); } else - wxGetApp().Contact->SetWhereClause(wxT("")); + wxGetApp().Contact->SetWhereClause(wxEmptyString); if (!wxGetApp().Contact->Query()) { wxString tStr; tStr = wxT("ODBC error during Query()\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); - + SetMode(mView); return; } @@ -1075,7 +1375,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) // Display the query dialog box wxChar qryWhere[DB_MAX_WHERE_CLAUSE_LEN+1]; wxStrcpy(qryWhere, (const wxChar*) wxGetApp().Contact->qryWhereStr); - wxChar *tblName[] = {(wxChar *)CONTACT_TABLE_NAME, 0}; + wxChar *tblName[] = {(wxChar *)CONTACT_TABLE_NAME.c_str(), 0}; new CqueryDlg(GetParent(), wxGetApp().Contact->GetDb(), tblName, qryWhere); // Query the first record in the new record set and @@ -1083,7 +1383,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) if (wxStrcmp(qryWhere, (const wxChar*) wxGetApp().Contact->qryWhereStr)) { wxGetApp().Contact->whereStr.Empty(); - wxGetApp().Contact->SetOrderByClause("NAME"); + wxGetApp().Contact->SetOrderByClause(wxT("NAME")); if (wxGetApp().Contact->GetDb()->Dbms() != dbmsPOSTGRES && wxGetApp().Contact->GetDb()->Dbms() != dbmsMY_SQL) @@ -1091,7 +1391,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) wxGetApp().Contact->whereStr = wxT("NAME = (SELECT MIN(NAME) FROM "); wxGetApp().Contact->whereStr += CONTACT_TABLE_NAME; } - + // Append the query where string (if there is one) wxGetApp().Contact->qryWhereStr = qryWhere; if (wxStrlen(qryWhere)) @@ -1107,7 +1407,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) { wxString tStr; tStr = wxT("ODBC error during Query()\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); return; @@ -1119,7 +1419,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) } // Enable/Disable the reset button - pResetBtn->Enable(!wxGetApp().Contact->qryWhereStr.IsEmpty()); + pResetBtn->Enable(!wxGetApp().Contact->qryWhereStr.empty()); return; } // Query button @@ -1128,7 +1428,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) if (widgetName == pResetBtn->GetName()) { // Clear the additional where criteria established by the query feature - wxGetApp().Contact->qryWhereStr = wxT(""); + wxGetApp().Contact->qryWhereStr = wxEmptyString; wxGetApp().Contact->SetOrderByClause(wxT("NAME")); if (wxGetApp().Contact->GetDb()->Dbms() != dbmsPOSTGRES && @@ -1144,14 +1444,14 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) { wxString tStr; tStr = wxT("ODBC error during Query()\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); return; } if (!wxGetApp().Contact->GetNext()) wxGetApp().Contact->Initialize(); PutData(); - pResetBtn->Enable(FALSE); + pResetBtn->Enable(false); return; } // Reset button @@ -1159,16 +1459,17 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) if (widgetName == pNameListBtn->GetName()) { - new ClookUpDlg(/* wxWindow *parent */ this, - /* wxChar *windowTitle */ wxT("Select contact name"), - /* wxChar *tableName */ (wxChar *) CONTACT_TABLE_NAME, - /* wxChar *dispCol1 */ wxT("NAME"), - /* wxChar *dispCol2 */ wxT("JOINDATE"), - /* wxChar *where */ wxT(""), - /* wxChar *orderBy */ wxT("NAME"), - /* wxDb *pDb */ wxGetApp().READONLY_DB, - /* const wxString &defDir */ wxGetApp().DbConnectInf->GetDefaultDir(), - /* bool distinctValues */ TRUE); + new ClookUpDlg(/* wxWindow *parent */ this, + /* const wxString &windowTitle */ wxT("Select contact name"), + /* const wxString &tableName */ CONTACT_TABLE_NAME, + /* const wxString &dispCol1 */ wxT("NAME"), + /* const wxString &dispCol2 */ wxT("JOINDATE"), + /* const wxString &where */ wxT(""), + /* const wxString &orderBy */ wxT("NAME"), + /* wxDb *pDb */ wxGetApp().READONLY_DB, + /* const wxString &defDir */ wxGetApp().DbConnectInf->GetDefaultDir(), + /* bool distinctValues*/ true, + wxEmptyString, 20); if (ListDB_Selection && wxStrlen(ListDB_Selection)) { @@ -1184,32 +1485,44 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) if (widgetName == pDataTypesBtn->GetName()) { CheckSupportForAllDataTypes(wxGetApp().READONLY_DB); - wxMessageBox("Support datatypes was dumped to stdout."); + wxMessageBox(wxT("Support datatypes was dumped to stdout.")); return; } // Data types Button if (widgetName == pDbDiagsBtn->GetName()) { DisplayDbDiagnostics(wxGetApp().READONLY_DB); - wxMessageBox("Diagnostics info was dumped to stdout."); + wxMessageBox(wxT("Diagnostics info was dumped to stdout.")); return; } if (widgetName == pCatalogBtn->GetName()) { - if (wxGetApp().Contact->GetDb()->Catalog("","catalog.txt")) - wxMessageBox("The file 'catalog.txt' was created."); + if (wxGetApp().Contact->GetDb()->Catalog(wxEmptyString, wxT("catalog.txt"))) + wxMessageBox(wxT("The file 'catalog.txt' was created.")); else - wxMessageBox("Creation of the file 'catalog.txt' was failed."); + wxMessageBox(wxT("Creation of the file 'catalog.txt' failed.")); return; } +#ifdef wxODBC_BLOB_SUPPORT + if (widgetName == pChooseImageBtn->GetName()) + { + OnSelectPict(); + } + + if (widgetName == pShowImageBtn->GetName()) + { + OnShowImage(); + } +#endif + } // CeditorDlg::OnCommand() bool CeditorDlg::Initialize() { - // Create the data structure and a new database connection. + // Create the data structure and a new database connection. // (As there is not a pDb being passed in the constructor, a new database // connection is created) wxGetApp().Contact = new Ccontact(); @@ -1217,26 +1530,26 @@ bool CeditorDlg::Initialize() if (!wxGetApp().Contact) { wxMessageBox(wxT("Unable to instantiate an instance of Ccontact"),wxT("Error..."),wxOK | wxICON_EXCLAMATION); - return FALSE; + return false; } - // Check if the table exists or not. If it doesn't, ask the user if they want to + // Check if the table exists or not. If it doesn't, ask the user if they want to // create the table. Continue trying to create the table until it exists, or user aborts - while (!wxGetApp().Contact->GetDb()->TableExists((wxChar *)CONTACT_TABLE_NAME, - wxGetApp().DbConnectInf->GetUserID(), + while (!wxGetApp().Contact->GetDb()->TableExists(CONTACT_TABLE_NAME, + wxGetApp().DbConnectInf->GetUserID(), wxGetApp().DbConnectInf->GetDefaultDir())) { wxString tStr; - tStr.Printf(wxT("Unable to open the table '%s'. The table may\nneed to be created.\n\nDo you wish to try to create/clear the table?\n\n"),CONTACT_TABLE_NAME); + tStr.Printf(wxT("Unable to open the table '%s'. The table may\nneed to be created.\n\nDo you wish to try to create/clear the table?\n\n"),CONTACT_TABLE_NAME.c_str()); bool createTable = (wxMessageBox(tStr.c_str(),wxT("Confirm"),wxYES_NO|wxICON_QUESTION) == wxYES); if (!createTable) { // Close(); - return FALSE; + return false; } else - wxGetApp().CreateDataTable(FALSE); + wxGetApp().CreateDataTable(false); } // Tables must be "opened" before anything other than creating/deleting table can be done @@ -1256,30 +1569,30 @@ bool CeditorDlg::Initialize() wxGetApp().DbConnectInf->GetDefaultDir())) { wxString tStr; - tStr.Printf(wxT("Unable to open the table '%s' (likely due to\ninsufficient privileges of the logged in user).\n\n"),CONTACT_TABLE_NAME); + tStr.Printf(wxT("Unable to open the table '%s' (likely due to\ninsufficient privileges of the logged in user).\n\n"),CONTACT_TABLE_NAME.c_str()); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); } - else + else #endif if (!wxGetApp().Contact->GetDb()->TableExists(CONTACT_TABLE_NAME, wxGetApp().Contact->GetDb()->GetUsername(), wxGetApp().DbConnectInf->GetDefaultDir())) { wxString tStr; - tStr.Printf(wxT("Unable to open the table '%s' as the table\ndoes not appear to exist in the tablespace available\nto the currently logged in user.\n\n"),CONTACT_TABLE_NAME); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + tStr.Printf(wxT("Unable to open the table '%s' as the table\ndoes not appear to exist in the tablespace available\nto the currently logged in user.\n\n"),CONTACT_TABLE_NAME.c_str()); + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); } - return FALSE; + return false; } // Build the dialog - (void)new wxStaticBox(this, EDITOR_DIALOG_FN_GROUP, wxT(""), wxPoint(15, 1), wxSize(497, 69), 0, wxT("FunctionGrp")); - (void)new wxStaticBox(this, EDITOR_DIALOG_SEARCH_GROUP, wxT(""), wxPoint(417, 1), wxSize(95, 242), 0, wxT("SearchGrp")); + (void)new wxStaticBox(this, EDITOR_DIALOG_FN_GROUP, wxEmptyString, wxPoint(15, 1), wxSize(497, 69), 0, wxT("FunctionGrp")); + (void)new wxStaticBox(this, EDITOR_DIALOG_SEARCH_GROUP, wxEmptyString, wxPoint(417, 1), wxSize(95, 242), 0, wxT("SearchGrp")); pCreateBtn = new wxButton(this, EDITOR_DIALOG_CREATE, wxT("&Create"), wxPoint( 25, 21), wxSize( 70, 35), 0, wxDefaultValidator, wxT("CreateBtn")); pEditBtn = new wxButton(this, EDITOR_DIALOG_EDIT, wxT("&Edit"), wxPoint(102, 21), wxSize( 70, 35), 0, wxDefaultValidator, wxT("EditBtn")); @@ -1291,21 +1604,21 @@ bool CeditorDlg::Initialize() pNextBtn = new wxButton(this, EDITOR_DIALOG_NEXT, wxT("&Next >>"), wxPoint(430, 121), wxSize( 70, 35), 0, wxDefaultValidator, wxT("NextBtn")); pQueryBtn = new wxButton(this, EDITOR_DIALOG_QUERY, wxT("&Query"), wxPoint(430, 161), wxSize( 70, 35), 0, wxDefaultValidator, wxT("QueryBtn")); pResetBtn = new wxButton(this, EDITOR_DIALOG_RESET, wxT("&Reset"), wxPoint(430, 200), wxSize( 70, 35), 0, wxDefaultValidator, wxT("ResetBtn")); - pNameMsg = new wxStaticText(this, EDITOR_DIALOG_NAME_MSG, wxT("Name:"), wxPoint( 17, 80), wxSize( -1, -1), 0, wxT("NameMsg")); - pNameTxt = new wxTextCtrl(this, EDITOR_DIALOG_NAME_TEXT, wxT(""), wxPoint( 17, 97), wxSize(308, 25), 0, wxDefaultValidator, wxT("NameTxt")); + pNameMsg = new wxStaticText(this, EDITOR_DIALOG_NAME_MSG, wxT("Name:"), wxPoint( 17, 80), wxDefaultSize, 0, wxT("NameMsg")); + pNameTxt = new wxTextCtrl(this, EDITOR_DIALOG_NAME_TEXT, wxEmptyString, wxPoint( 17, 97), wxSize(308, 25), 0, wxDefaultValidator, wxT("NameTxt")); pNameListBtn = new wxButton(this, EDITOR_DIALOG_LOOKUP, wxT("&Lookup"), wxPoint(333, 97), wxSize( 70, 24), 0, wxDefaultValidator, wxT("LookupBtn")); - pAddress1Msg = new wxStaticText(this, EDITOR_DIALOG_ADDRESS1_MSG, wxT("Address:"), wxPoint( 17, 130), wxSize( -1, -1), 0, wxT("Address1Msg")); - pAddress1Txt = new wxTextCtrl(this, EDITOR_DIALOG_ADDRESS2_TEXT, wxT(""), wxPoint( 17, 147), wxSize(308, 25), 0, wxDefaultValidator, wxT("Address1Txt")); - pAddress2Msg = new wxStaticText(this, EDITOR_DIALOG_ADDRESS2_MSG, wxT("Address:"), wxPoint( 17, 180), wxSize( -1, -1), 0, wxT("Address2Msg")); - pAddress2Txt = new wxTextCtrl(this, EDITOR_DIALOG_ADDRESS2_TEXT, wxT(""), wxPoint( 17, 197), wxSize(308, 25), 0, wxDefaultValidator, wxT("Address2Txt")); - pCityMsg = new wxStaticText(this, EDITOR_DIALOG_CITY_MSG, wxT("City:"), wxPoint( 17, 230), wxSize( -1, -1), 0, wxT("CityMsg")); - pCityTxt = new wxTextCtrl(this, EDITOR_DIALOG_CITY_TEXT, wxT(""), wxPoint( 17, 247), wxSize(225, 25), 0, wxDefaultValidator, wxT("CityTxt")); - pStateMsg = new wxStaticText(this, EDITOR_DIALOG_STATE_MSG, wxT("State:"), wxPoint(250, 230), wxSize( -1, -1), 0, wxT("StateMsg")); - pStateTxt = new wxTextCtrl(this, EDITOR_DIALOG_STATE_TEXT, wxT(""), wxPoint(250, 247), wxSize(153, 25), 0, wxDefaultValidator, wxT("StateTxt")); - pCountryMsg = new wxStaticText(this, EDITOR_DIALOG_COUNTRY_MSG, wxT("Country:"), wxPoint( 17, 280), wxSize( -1, -1), 0, wxT("CountryMsg")); - pCountryTxt = new wxTextCtrl(this, EDITOR_DIALOG_COUNTRY_TEXT, wxT(""), wxPoint( 17, 297), wxSize(225, 25), 0, wxDefaultValidator, wxT("CountryTxt")); - pPostalCodeMsg = new wxStaticText(this, EDITOR_DIALOG_POSTAL_MSG, wxT("Postal Code:"),wxPoint(250, 280), wxSize( -1, -1), 0, wxT("PostalCodeMsg")); - pPostalCodeTxt = new wxTextCtrl(this, EDITOR_DIALOG_POSTAL_TEXT, wxT(""), wxPoint(250, 297), wxSize(153, 25), 0, wxDefaultValidator, wxT("PostalCodeTxt")); + pAddress1Msg = new wxStaticText(this, EDITOR_DIALOG_ADDRESS1_MSG, wxT("Address:"), wxPoint( 17, 130), wxDefaultSize, 0, wxT("Address1Msg")); + pAddress1Txt = new wxTextCtrl(this, EDITOR_DIALOG_ADDRESS2_TEXT, wxEmptyString, wxPoint( 17, 147), wxSize(308, 25), 0, wxDefaultValidator, wxT("Address1Txt")); + pAddress2Msg = new wxStaticText(this, EDITOR_DIALOG_ADDRESS2_MSG, wxT("Address:"), wxPoint( 17, 180), wxDefaultSize, 0, wxT("Address2Msg")); + pAddress2Txt = new wxTextCtrl(this, EDITOR_DIALOG_ADDRESS2_TEXT, wxEmptyString, wxPoint( 17, 197), wxSize(308, 25), 0, wxDefaultValidator, wxT("Address2Txt")); + pCityMsg = new wxStaticText(this, EDITOR_DIALOG_CITY_MSG, wxT("City:"), wxPoint( 17, 230), wxDefaultSize, 0, wxT("CityMsg")); + pCityTxt = new wxTextCtrl(this, EDITOR_DIALOG_CITY_TEXT, wxEmptyString, wxPoint( 17, 247), wxSize(225, 25), 0, wxDefaultValidator, wxT("CityTxt")); + pStateMsg = new wxStaticText(this, EDITOR_DIALOG_STATE_MSG, wxT("State:"), wxPoint(250, 230), wxDefaultSize, 0, wxT("StateMsg")); + pStateTxt = new wxTextCtrl(this, EDITOR_DIALOG_STATE_TEXT, wxEmptyString, wxPoint(250, 247), wxSize(153, 25), 0, wxDefaultValidator, wxT("StateTxt")); + pCountryMsg = new wxStaticText(this, EDITOR_DIALOG_COUNTRY_MSG, wxT("Country:"), wxPoint( 17, 280), wxDefaultSize, 0, wxT("CountryMsg")); + pCountryTxt = new wxTextCtrl(this, EDITOR_DIALOG_COUNTRY_TEXT, wxEmptyString, wxPoint( 17, 297), wxSize(225, 25), 0, wxDefaultValidator, wxT("CountryTxt")); + pPostalCodeMsg = new wxStaticText(this, EDITOR_DIALOG_POSTAL_MSG, wxT("Postal Code:"),wxPoint(250, 280), wxDefaultSize, 0, wxT("PostalCodeMsg")); + pPostalCodeTxt = new wxTextCtrl(this, EDITOR_DIALOG_POSTAL_TEXT, wxEmptyString, wxPoint(250, 297), wxSize(153, 25), 0, wxDefaultValidator, wxT("PostalCodeTxt")); wxString choice_strings[5]; choice_strings[0] = wxT("English"); @@ -1314,32 +1627,40 @@ bool CeditorDlg::Initialize() choice_strings[3] = wxT("Spanish"); choice_strings[4] = wxT("Other"); - pNativeLangChoice = new wxChoice(this, EDITOR_DIALOG_LANG_CHOICE, wxPoint( 17, 346), wxSize(277, -1), 5, choice_strings); - pNativeLangMsg = new wxStaticText(this, EDITOR_DIALOG_LANG_MSG, wxT("Native language:"), wxPoint( 17, 330), wxSize( -1, -1), 0, wxT("NativeLangMsg")); + pNativeLangChoice = new wxChoice(this, EDITOR_DIALOG_LANG_CHOICE, wxPoint( 17, 346), wxSize(277, wxDefaultCoord), 5, choice_strings); + pNativeLangMsg = new wxStaticText(this, EDITOR_DIALOG_LANG_MSG, wxT("Native language:"), wxPoint( 17, 330), wxDefaultSize, 0, wxT("NativeLangMsg")); wxString radio_strings[2]; radio_strings[0] = wxT("No"); radio_strings[1] = wxT("Yes"); - pDeveloperRadio = new wxRadioBox(this,EDITOR_DIALOG_DEVELOPER, wxT("Developer:"), wxPoint(303, 330), wxSize( -1, -1), 2, radio_strings, 2, wxHORIZONTAL); - pJoinDateMsg = new wxStaticText(this, EDITOR_DIALOG_JOIN_MSG, wxT("Date joined:"), wxPoint( 17, 380), wxSize( -1, -1), 0, wxT("JoinDateMsg")); - pJoinDateTxt = new wxTextCtrl(this, EDITOR_DIALOG_JOIN_TEXT, wxT(""), wxPoint( 17, 397), wxSize(150, 25), 0, wxDefaultValidator, wxT("JoinDateTxt")); - pContribMsg = new wxStaticText(this, EDITOR_DIALOG_CONTRIB_MSG,wxT("Contributions:"), wxPoint(175, 380), wxSize( -1, -1), 0, wxT("ContribMsg")); - pContribTxt = new wxTextCtrl(this, EDITOR_DIALOG_CONTRIB_TEXT, wxT(""), wxPoint(175, 397), wxSize(120, 25), 0, wxDefaultValidator, wxT("ContribTxt")); - pLinesMsg = new wxStaticText(this, EDITOR_DIALOG_LINES_MSG, wxT("Lines of code:"), wxPoint(303, 380), wxSize( -1, -1), 0, wxT("LinesMsg")); - pLinesTxt = new wxTextCtrl(this, EDITOR_DIALOG_LINES_TEXT, wxT(""), wxPoint(303, 397), wxSize(100, 25), 0, wxDefaultValidator, wxT("LinesTxt")); + pDeveloperRadio = new wxRadioBox(this,EDITOR_DIALOG_DEVELOPER, wxT("Developer:"), wxPoint(303, 330), wxDefaultSize, 2, radio_strings, 2, wxHORIZONTAL); + pJoinDateMsg = new wxStaticText(this, EDITOR_DIALOG_JOIN_MSG, wxT("Date joined:"), wxPoint( 17, 380), wxDefaultSize, 0, wxT("JoinDateMsg")); + pJoinDateTxt = new wxTextCtrl(this, EDITOR_DIALOG_JOIN_TEXT, wxEmptyString, wxPoint( 17, 397), wxSize(150, 25), 0, wxDefaultValidator, wxT("JoinDateTxt")); + pContribMsg = new wxStaticText(this, EDITOR_DIALOG_CONTRIB_MSG,wxT("Contributions:"), wxPoint(175, 380), wxDefaultSize, 0, wxT("ContribMsg")); + pContribTxt = new wxTextCtrl(this, EDITOR_DIALOG_CONTRIB_TEXT, wxEmptyString, wxPoint(175, 397), wxSize(120, 25), 0, wxDefaultValidator, wxT("ContribTxt")); + pLinesMsg = new wxStaticText(this, EDITOR_DIALOG_LINES_MSG, wxT("Lines of code:"), wxPoint(303, 380), wxDefaultSize, 0, wxT("LinesMsg")); + pLinesTxt = new wxTextCtrl(this, EDITOR_DIALOG_LINES_TEXT, wxEmptyString, wxPoint(303, 397), wxSize(100, 25), 0, wxDefaultValidator, wxT("LinesTxt")); pCatalogBtn = new wxButton(this, EDITOR_DIALOG_CATALOG, wxT("Catalo&g"), wxPoint(430, 287), wxSize( 70, 35), 0, wxDefaultValidator, wxT("CatalogBtn")); pDataTypesBtn = new wxButton(this, EDITOR_DIALOG_DATATYPES, wxT("Data&types"), wxPoint(430, 337), wxSize( 70, 35), 0, wxDefaultValidator, wxT("DataTypesBtn")); pDbDiagsBtn = new wxButton(this, EDITOR_DIALOG_DB_DIAGS, wxT("DB Dia&gs"), wxPoint(430, 387), wxSize( 70, 35), 0, wxDefaultValidator, wxT("DbDiagsBtn")); - // Now that all the widgets on the panel are created, its safe to allow ::OnCommand() to +#ifdef wxODBC_BLOB_SUPPORT + pPictureMsg = new wxStaticText(this, EDITOR_DIALOG_PIC_MSG, wxT("Picture:"), wxPoint( 17,430), wxDefaultSize, 0, wxT("PicMsg")); + pPictSizeMsg = new wxStaticText(this, EDITOR_DIALOG_PICSIZE_MSG, wxT("Picture Bytes:"), wxPoint(175,430), wxDefaultSize, 0, wxT("PicSizeMsg")); + pChooseImageBtn = new wxButton(this, EDITOR_DIALOG_PIC_BROWSE, wxT("Select..."), wxPoint( 17,447), wxSize( 70, 24), 0, wxDefaultValidator, wxT("PicBrowseBtn")); + pShowImageBtn = new wxButton(this, EDITOR_DIALOG_PIC_SHOW, wxT("Show..."), wxPoint( 97,447), wxSize( 70, 24), 0, wxDefaultValidator, wxT("PictShowBtn")); + pPictSizeTxt = new wxTextCtrl(this, EDITOR_DIALOG_PIC_SIZE_TEXT, wxEmptyString, wxPoint(175,447), wxSize(120, 25), 0, wxDefaultValidator, wxT("PictSizeTxt")); +#endif + + // Now that all the widgets on the panel are created, its safe to allow ::OnCommand() to // handle all widget processing - widgetPtrsSet = TRUE; + widgetPtrsSet = true; - // Setup the orderBy and where clauses to return back a single record as the result set, + // Setup the orderBy and where clauses to return back a single record as the result set, // as there will only be one record being shown on the dialog at a time, this optimizes // network traffic by only returning a one row result - + wxGetApp().Contact->SetOrderByClause(wxT("NAME")); // field name to sort by // The wxString "whereStr" is not a member of the wxDbTable object, it is a member variable @@ -1347,9 +1668,9 @@ bool CeditorDlg::Initialize() // length string, and then after the string is built, the wxDbTable member variable "where" is // assigned the pointer to the constructed string. // - // The constructed where clause below has a sub-query within it "SELECT MIN(NAME) FROM %s" + // The constructed where clause below has a sub-query within it "SELECT MIN(NAME) FROM %s" // to achieve a single row (in this case the first name in alphabetical order). - + if (wxGetApp().Contact->GetDb()->Dbms() != dbmsPOSTGRES && wxGetApp().Contact->GetDb()->Dbms() != dbmsMY_SQL) { @@ -1359,24 +1680,24 @@ bool CeditorDlg::Initialize() wxGetApp().Contact->SetWhereClause(wxGetApp().Contact->whereStr); } else - wxGetApp().Contact->SetWhereClause(wxT("")); + wxGetApp().Contact->SetWhereClause(wxEmptyString); - // Perform the Query to get the result set. - // NOTE: If there are no rows returned, that is a valid result, so Query() would return TRUE. - // Only if there is a database error will Query() come back as FALSE + // Perform the Query to get the result set. + // NOTE: If there are no rows returned, that is a valid result, so Query() would return true. + // Only if there is a database error will Query() come back as false if (!wxGetApp().Contact->Query()) { wxString tStr; tStr = wxT("ODBC error during Query()\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); - return FALSE; + return false; } // Since Query succeeded, now get the row that was returned if (!wxGetApp().Contact->GetNext()) - // If the GetNext() failed at this point, then there are no rows to retrieve, - // so clear the values in the members of "Contact" so that PutData() blanks the + // If the GetNext() failed at this point, then there are no rows to retrieve, + // so clear the values in the members of "Contact" so that PutData() blanks the // widgets on the dialog wxGetApp().Contact->Initialize(); /* @@ -1385,12 +1706,61 @@ bool CeditorDlg::Initialize() SetMode(mView); PutData(); - Show(TRUE); + Show(true); - initialized = TRUE; - return TRUE; + initialized = true; + return true; } // CeditorDlg::Initialize() +#ifdef wxODBC_BLOB_SUPPORT + +void CeditorDlg::OnSelectPict() +{ + wxFileDialog dlg(this, wxT("Choose an image file less than 60K"), wxEmptyString, wxEmptyString, wxT("JPEG files (*.jpg)|*.jpg|GIF files (*.gif)|*.gif|BMP files (*.bmp)|*.bmp|All Files (*.*)|*.*"), wxOPEN); + + if (dlg.ShowModal() == wxID_OK) + { + wxFile file(dlg.GetPath()); + + if (file.IsOpened()) + { + // assume not huge file in sample + long iSize = (long)file.Length(); + + if ((iSize > 0) && (iSize < MAX_PICTURE_SIZE)) + { + wxGetApp().Contact->BlobSize = (size_t)iSize; + + memset(wxGetApp().Contact->Picture, 0, MAX_PICTURE_SIZE); + + wxFileOffset iReadSize = file.Read(wxGetApp().Contact->Picture, (size_t)iSize); + + if (iReadSize < iSize) + wxMessageBox(wxT("Something bad happened while reading..."), wxT("BLOB Loading Error"), wxOK | wxICON_EXCLAMATION); + + wxString tStr; + tStr.Printf(wxT("%ld"),iSize); + pPictSizeTxt->SetValue(tStr); + } + else + wxMessageBox(wxT("Selected File is TOO BIG. 60k is the max image size"), wxT("BLOB Loading Error"), wxOK | wxICON_EXCLAMATION); + } + else + wxMessageBox(wxT("Unable to open the requested image file"), wxT("File Access Error"), wxOK | wxICON_EXCLAMATION); + } +} + +void CeditorDlg::OnShowImage() +{ + if (wxGetApp().Contact->BlobSize > 0) + { + CimageDlg dlg(this, wxGetApp().Contact->Picture, wxGetApp().Contact->BlobSize); + + dlg.ShowModal(); + } +} + +#endif void CeditorDlg::FieldsEditable() { @@ -1411,23 +1781,29 @@ void CeditorDlg::FieldsEditable() pNativeLangChoice->Enable((mode == mCreate) || (mode == mEdit)); pDeveloperRadio->Enable((mode == mCreate) || (mode == mEdit)); +#ifdef wxODBC_BLOB_SUPPORT + pPictSizeTxt->Enable(false); + pChooseImageBtn->Enable((mode == mCreate) || (mode == mEdit)); + pShowImageBtn->Enable(wxGetApp().Contact && wxGetApp().Contact->BlobSize > 0); //((mode == mCreate) || (mode == mEdit)); +#endif + } // CeditorDlg::FieldsEditable() void CeditorDlg::SetMode(enum DialogModes m) { - bool edit = FALSE; + bool edit = false; mode = m; switch (mode) { case mCreate: case mEdit: - edit = TRUE; + edit = true; break; case mView: case mSearch: - edit = FALSE; + edit = false; break; default: break; @@ -1436,15 +1812,15 @@ void CeditorDlg::SetMode(enum DialogModes m) if (widgetPtrsSet) { pCreateBtn->Enable( !edit ); - pEditBtn->Enable( !edit && (wxStrcmp(wxGetApp().Contact->Name,wxT(""))!=0) ); - pDeleteBtn->Enable( !edit && (wxStrcmp(wxGetApp().Contact->Name,wxT(""))!=0) ); - pCopyBtn->Enable( !edit && (wxStrcmp(wxGetApp().Contact->Name,wxT(""))!=0) ); + pEditBtn->Enable( !edit && (wxStrcmp(wxGetApp().Contact->Name, wxEmptyString) != 0) ); + pDeleteBtn->Enable( !edit && (wxStrcmp(wxGetApp().Contact->Name, wxEmptyString)!=0) ); + pCopyBtn->Enable( !edit && (wxStrcmp(wxGetApp().Contact->Name, wxEmptyString)!=0) ); pSaveBtn->Enable( edit ); pCancelBtn->Enable( edit ); pPrevBtn->Enable( !edit ); pNextBtn->Enable( !edit ); pQueryBtn->Enable( !edit ); - pResetBtn->Enable( !edit && !wxGetApp().Contact->qryWhereStr.IsEmpty() ); + pResetBtn->Enable( !edit && !wxGetApp().Contact->qryWhereStr.empty() ); pNameListBtn->Enable( !edit ); } @@ -1477,7 +1853,13 @@ bool CeditorDlg::PutData() pDeveloperRadio->SetSelection(wxGetApp().Contact->IsDeveloper); - return TRUE; +#ifdef wxODBC_BLOB_SUPPORT + tStr.Printf(wxT("%lu"),wxGetApp().Contact->BlobSize); + pPictSizeTxt->SetValue(tStr); + pShowImageBtn->Enable(wxGetApp().Contact->BlobSize > 0); +#endif + + return true; } // Ceditor::PutData() @@ -1485,7 +1867,7 @@ bool CeditorDlg::PutData() * Reads the data out of all the widgets on the dialog. Some data evaluation is done * to ensure that there is a name entered and that the date field is valid. * - * A return value of TRUE means that valid data was retrieved from the dialog, otherwise + * A return value of true means that valid data was retrieved from the dialog, otherwise * invalid data was found (and a message was displayed telling the user what to fix), and * the data was not placed into the appropraite fields of Ccontact */ @@ -1495,19 +1877,19 @@ bool CeditorDlg::GetData() wxString tStr; tStr = pNameTxt->GetValue(); - if (!wxStrcmp((const wxChar*) tStr,wxT(""))) + if (!wxStrcmp((const wxChar*) tStr, wxEmptyString)) { - wxMessageBox(wxT("A name is required for entry into the contact table"),wxT("Notice..."),wxOK | wxICON_INFORMATION); - return FALSE; + wxMessageBox(wxT("A name is required for entry into the contact table"), wxT("Notice..."), wxOK | wxICON_INFORMATION); + return false; } - bool invalid = FALSE; + bool invalid = false; int mm = 1,dd = 1,yyyy = 2001; int first, second; tStr = pJoinDateTxt->GetValue(); if (tStr.Freq(wxT('/')) != 2) - invalid = TRUE; + invalid = true; // Find the month, day, and year tokens if (!invalid) @@ -1515,39 +1897,39 @@ bool CeditorDlg::GetData() first = tStr.First(wxT('/')); second = tStr.Last(wxT('/')); - mm = atoi(tStr.SubString(0,first)); - dd = atoi(tStr.SubString(first+1,second)); - yyyy = atoi(tStr.SubString(second+1,tStr.Length()-1)); + mm = wxAtoi(tStr.SubString(0,first)); + dd = wxAtoi(tStr.SubString(first+1,second)); + yyyy = wxAtoi(tStr.SubString(second+1,tStr.Length()-1)); invalid = !(mm && dd && yyyy); } // Force Year 2000 compliance if (!invalid && (yyyy < 1000)) - invalid = TRUE; + invalid = true; // Check the token ranges for validity if (!invalid) { if (yyyy > 9999) - invalid = TRUE; + invalid = true; else if ((mm < 1) || (mm > 12)) - invalid = TRUE; + invalid = true; else { if (dd < 1) - invalid = TRUE; + invalid = true; else { int days[12] = {31,28,31,30,31,30, 31,31,30,31,30,31}; if (dd > days[mm-1]) { - invalid = TRUE; + invalid = true; if ((dd == 29) && (mm == 2)) { if (((yyyy % 4) == 0) && (((yyyy % 100) != 0) || ((yyyy % 400) == 0))) - invalid = FALSE; + invalid = false; } } } @@ -1556,14 +1938,14 @@ bool CeditorDlg::GetData() if (!invalid) { - wxGetApp().Contact->JoinDate.month = mm; - wxGetApp().Contact->JoinDate.day = dd; - wxGetApp().Contact->JoinDate.year = yyyy; + wxGetApp().Contact->JoinDate.month = (unsigned short) mm; + wxGetApp().Contact->JoinDate.day = (unsigned short) dd; + wxGetApp().Contact->JoinDate.year = (short) yyyy; } else { wxMessageBox(wxT("Improper date format. Please check the date\nspecified and try again.\n\nNOTE: Dates are in american format (MM/DD/YYYY)"),wxT("Notice..."),wxOK | wxICON_INFORMATION); - return FALSE; + return false; } tStr = pNameTxt->GetValue(); @@ -1575,13 +1957,13 @@ bool CeditorDlg::GetData() wxStrcpy(wxGetApp().Contact->Country,pCountryTxt->GetValue()); wxStrcpy(wxGetApp().Contact->PostalCode,pPostalCodeTxt->GetValue()); - wxGetApp().Contact->Contributions = atoi(pContribTxt->GetValue()); - wxGetApp().Contact->LinesOfCode = atol(pLinesTxt->GetValue()); + wxGetApp().Contact->Contributions = (UCHAR)wxAtoi(pContribTxt->GetValue()); + wxGetApp().Contact->LinesOfCode = wxAtol(pLinesTxt->GetValue()); wxGetApp().Contact->NativeLanguage = (enum Language) pNativeLangChoice->GetSelection(); wxGetApp().Contact->IsDeveloper = pDeveloperRadio->GetSelection() > 0; - return TRUE; + return true; } // CeditorDlg::GetData() @@ -1590,17 +1972,17 @@ bool CeditorDlg::GetData() * try to insert/update the data to the table based on the current 'mode' the dialog * is set to. * - * A return value of TRUE means the insert/update was completed successfully, a return - * value of FALSE means that Save() failed. If returning FALSE, then this function + * A return value of true means the insert/update was completed successfully, a return + * value of false means that Save() failed. If returning false, then this function * has displayed a detailed error message for the user. */ bool CeditorDlg::Save() { - bool failed = FALSE; + bool failed = false; // Read the data in the widgets of the dialog to get the user's data if (!GetData()) - failed = TRUE; + failed = true; // Perform any other required validations necessary before saving if (!failed) @@ -1609,7 +1991,7 @@ bool CeditorDlg::Save() if (mode == mCreate) { - RETCODE result = wxGetApp().Contact->Insert(); + RETCODE result = (RETCODE)wxGetApp().Contact->Insert(); failed = (result != DB_SUCCESS); if (failed) @@ -1620,7 +2002,7 @@ bool CeditorDlg::Save() { wxString tStr; tStr = wxT("A duplicate key value already exists in the table.\nUnable to save record\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); } else @@ -1628,7 +2010,7 @@ bool CeditorDlg::Save() // Some other unexpected error occurred wxString tStr; tStr = wxT("Database insert failed\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); } } @@ -1636,14 +2018,14 @@ bool CeditorDlg::Save() else // mode == mEdit { wxGetApp().Contact->GetDb()->RollbackTrans(); - wxGetApp().Contact->whereStr.Printf("NAME = '%s'",saveName.c_str()); + wxGetApp().Contact->whereStr.Printf(wxT("NAME = '%s'"),saveName.c_str()); if (!wxGetApp().Contact->UpdateWhere(wxGetApp().Contact->whereStr)) { wxString tStr; tStr = wxT("Database update failed\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); - failed = TRUE; + failed = true; } } @@ -1685,7 +2067,7 @@ bool CeditorDlg::GetNextRec() w += wxT("'"); // If a query where string is currently set, append that criteria - if (!wxGetApp().Contact->qryWhereStr.IsEmpty()) + if (!wxGetApp().Contact->qryWhereStr.empty()) { w += wxT(" AND ("); w += wxGetApp().Contact->qryWhereStr; @@ -1721,7 +2103,7 @@ bool CeditorDlg::GetPrevRec() w += wxT("'"); // If a query where string is currently set, append that criteria - if (!wxGetApp().Contact->qryWhereStr.IsEmpty()) + if (!wxGetApp().Contact->qryWhereStr.empty()) { w += wxT(" AND ("); w += wxGetApp().Contact->qryWhereStr; @@ -1748,19 +2130,19 @@ bool CeditorDlg::GetRec(const wxString &whereStr) { wxString tStr; tStr = wxT("ODBC error during Query()\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); - return(FALSE); + return(false); } if (wxGetApp().Contact->GetNext()) { PutData(); - return(TRUE); + return(true); } else - return(FALSE); + return(false); } // CeditorDlg::GetRec() @@ -1775,29 +2157,29 @@ BEGIN_EVENT_TABLE(CparameterDlg, wxDialog) EVT_CLOSE(CparameterDlg::OnCloseWindow) END_EVENT_TABLE() -CparameterDlg::CparameterDlg(wxWindow *parent) : wxDialog (parent, PARAMETER_DIALOG, wxT("ODBC parameter settings"), wxPoint(-1, -1), wxSize(400, 325)) +CparameterDlg::CparameterDlg(wxWindow *parent) : wxDialog (parent, PARAMETER_DIALOG, wxT("ODBC parameter settings"), wxDefaultPosition, wxSize(400, 325)) { // Since the ::OnCommand() function is overridden, this prevents the widget // detection in ::OnCommand() until all widgets have been initialized to prevent // uninitialized pointers from crashing the program - widgetPtrsSet = FALSE; - - pParamODBCSourceMsg = new wxStaticText(this, PARAMETER_DIALOG_SOURCE_MSG, wxT("ODBC data sources:"), wxPoint( 10, 10), wxSize( -1, -1), 0, wxT("ParamODBCSourceMsg")); - pParamODBCSourceList = new wxListBox(this, PARAMETER_DIALOG_SOURCE_LISTBOX, wxPoint( 10, 29), wxSize(285, 150), 0, 0, wxLB_SINGLE|wxLB_ALWAYS_SB, wxDefaultValidator, wxT("ParamODBCSourceList")); - pParamUserNameMsg = new wxStaticText(this, PARAMETER_DIALOG_NAME_MSG, wxT("Database user name:"), wxPoint( 10, 193), wxSize( -1, -1), 0, wxT("ParamUserNameMsg")); - pParamUserNameTxt = new wxTextCtrl(this, PARAMETER_DIALOG_NAME_TEXT, wxT(""), wxPoint(10, 209), wxSize( 140, 25), 0, wxDefaultValidator, wxT("ParamUserNameTxt")); - pParamPasswordMsg = new wxStaticText(this, PARAMETER_DIALOG_PASSWORD_MSG, wxT("Password:"), wxPoint(156, 193), wxSize( -1, -1), 0, wxT("ParamPasswordMsg")); - pParamPasswordTxt = new wxTextCtrl(this, PARAMETER_DIALOG_PASSWORD_TEXT, wxT(""), wxPoint(156, 209), wxSize( 140, 25), 0, wxDefaultValidator, wxT("ParamPasswordTxt")); - pParamDirPathMsg = new wxStaticText(this, PARAMETER_DIALOG_DIRPATH_MSG, wxT("Directory:"), wxPoint( 10, 243), wxSize( -1, -1), 0, wxT("ParamDirPathMsg")); - pParamDirPathTxt = new wxTextCtrl(this, PARAMETER_DIALOG_DIRPATH_TEXT, wxT(""), wxPoint( 10, 259), wxSize(140, 25), 0, wxDefaultValidator, wxT("ParamDirPathTxt")); + widgetPtrsSet = false; + + pParamODBCSourceMsg = new wxStaticText(this, PARAMETER_DIALOG_SOURCE_MSG, wxT("ODBC data sources:"), wxPoint( 10, 10), wxDefaultSize, 0, wxT("ParamODBCSourceMsg")); + pParamODBCSourceList = new wxListBox(this, PARAMETER_DIALOG_SOURCE_LISTBOX, wxPoint( 10, 29), wxSize(285, 150), 0, 0, wxLB_SINGLE|wxLB_ALWAYS_SB, wxDefaultValidator, wxT("ParamODBCSourceList")); + pParamUserNameMsg = new wxStaticText(this, PARAMETER_DIALOG_NAME_MSG, wxT("Database user name:"), wxPoint( 10, 193), wxDefaultSize, 0, wxT("ParamUserNameMsg")); + pParamUserNameTxt = new wxTextCtrl(this, PARAMETER_DIALOG_NAME_TEXT, wxEmptyString, wxPoint(10, 209), wxSize( 140, 25), 0, wxDefaultValidator, wxT("ParamUserNameTxt")); + pParamPasswordMsg = new wxStaticText(this, PARAMETER_DIALOG_PASSWORD_MSG, wxT("Password:"), wxPoint(156, 193), wxDefaultSize, 0, wxT("ParamPasswordMsg")); + pParamPasswordTxt = new wxTextCtrl(this, PARAMETER_DIALOG_PASSWORD_TEXT, wxEmptyString, wxPoint(156, 209), wxSize( 140, 25), 0, wxDefaultValidator, wxT("ParamPasswordTxt")); + pParamDirPathMsg = new wxStaticText(this, PARAMETER_DIALOG_DIRPATH_MSG, wxT("Directory:"), wxPoint( 10, 243), wxDefaultSize, 0, wxT("ParamDirPathMsg")); + pParamDirPathTxt = new wxTextCtrl(this, PARAMETER_DIALOG_DIRPATH_TEXT, wxEmptyString, wxPoint( 10, 259), wxSize(140, 25), 0, wxDefaultValidator, wxT("ParamDirPathTxt")); pParamSaveBtn = new wxButton(this, PARAMETER_DIALOG_SAVE, wxT("&Save"), wxPoint(310, 21), wxSize( 70, 35), 0, wxDefaultValidator, wxT("ParamSaveBtn")); pParamCancelBtn = new wxButton(this, PARAMETER_DIALOG_CANCEL, wxT("C&ancel"), wxPoint(310, 66), wxSize( 70, 35), 0, wxDefaultValidator, wxT("ParamCancelBtn")); - // Now that all the widgets on the panel are created, its safe to allow ::OnCommand() to + // Now that all the widgets on the panel are created, its safe to allow ::OnCommand() to // handle all widget processing - widgetPtrsSet = TRUE; + widgetPtrsSet = true; - saved = FALSE; + saved = false; savedParamSettings = wxGetApp().params; Centre(wxBOTH); @@ -1813,13 +2195,13 @@ void CparameterDlg::OnCloseWindow(wxCloseEvent& event) if (!saved) { bool Ok = (wxMessageBox(wxT("No changes have been saved.\n\nAre you sure you wish exit the parameter screen?"),wxT("Confirm"),wxYES_NO|wxICON_QUESTION) == wxYES); - + if (!Ok) { event.Veto(); return; } - + wxGetApp().params = savedParamSettings; } @@ -1829,7 +2211,7 @@ void CparameterDlg::OnCloseWindow(wxCloseEvent& event) while (wxIsBusy()) wxEndBusyCursor(); - Show(FALSE); + Show(false); SetReturnCode(0); // added so BoundsChecker would not report use of uninitialized variable this->Destroy(); @@ -1843,10 +2225,10 @@ void CparameterDlg::OnButton( wxCommandEvent &event ) } -void CparameterDlg::OnCommand(wxWindow& win, wxCommandEvent& event) +void CparameterDlg::OnCommand(wxWindow& win, wxCommandEvent& WXUNUSED(event)) { wxString widgetName; - + widgetName = win.GetName(); if (!widgetPtrsSet) @@ -1861,7 +2243,7 @@ void CparameterDlg::OnCommand(wxWindow& win, wxCommandEvent& event) if (GetParent() != NULL) // The parameter dialog was not called during startup due to a missing cfg file tStr += wxT("\nNew parameters will take effect the next time the program is started."); wxMessageBox(tStr,wxT("Notice..."),wxOK | wxICON_INFORMATION); - saved = TRUE; + saved = true; Close(); } return; @@ -1884,65 +2266,65 @@ bool CparameterDlg::PutData() if (wxGetApp().params.ODBCSource && wxStrlen(wxGetApp().params.ODBCSource)) { int index = pParamODBCSourceList->FindString(wxGetApp().params.ODBCSource); - if (index != -1) + if (index != wxNOT_FOUND) pParamODBCSourceList->SetSelection(index); } pParamUserNameTxt->SetValue(wxGetApp().params.UserName); pParamPasswordTxt->SetValue(wxGetApp().params.Password); pParamDirPathTxt->SetValue(wxGetApp().params.DirPath); - return TRUE; + return true; } // CparameterDlg::PutData() bool CparameterDlg::GetData() { wxString tStr; - if (pParamODBCSourceList->GetStringSelection() != wxT("")) + if (pParamODBCSourceList->GetStringSelection() != wxEmptyString) { tStr = pParamODBCSourceList->GetStringSelection(); - if (tStr.Length() > (sizeof(wxGetApp().params.ODBCSource)-1)) + if (tStr.Length() > ((int)(sizeof(wxGetApp().params.ODBCSource) / sizeof(wxChar))-1)) { wxString errmsg; - errmsg.Printf(wxT("ODBC Data source name is longer than the data structure to hold it.\n'Cparameter.ODBCSource' must have a larger character array\nto handle a data source with this long of a name\n\nThe data source currently selected is %d characters long."),tStr.Length()); - wxMessageBox(errmsg,wxT("Internal program error..."),wxOK | wxICON_EXCLAMATION); - return FALSE; + errmsg.Printf(wxT("ODBC Data source name is longer than the data structure to hold it.\n'Cparameter.ODBCSource' must have a larger character array\nto handle a data source with this long of a name\n\nThe data source currently selected is %d characters long."), tStr.Length()); + wxMessageBox(errmsg, wxT("Internal program error..."), wxOK | wxICON_EXCLAMATION); + return false; } wxStrcpy(wxGetApp().params.ODBCSource, tStr); } else - return FALSE; - + return false; + tStr = pParamUserNameTxt->GetValue(); - if (tStr.Length() > (sizeof(wxGetApp().params.UserName)-1)) + if (tStr.Length() > ((int)(sizeof(wxGetApp().params.UserName) / sizeof(wxChar))-1)) { wxString errmsg; - errmsg.Printf(wxT("User name is longer than the data structure to hold it.\n'Cparameter.UserName' must have a larger character array\nto handle a data source with this long of a name\n\nThe user name currently specified is %d characters long."),tStr.Length()); - wxMessageBox(errmsg,wxT("Internal program error..."),wxOK | wxICON_EXCLAMATION); - return FALSE; + errmsg.Printf(wxT("User name is longer than the data structure to hold it.\n'Cparameter.UserName' must have a larger character array\nto handle a data source with this long of a name\n\nThe user name currently specified is %d characters long."), tStr.Length()); + wxMessageBox(errmsg, wxT("Internal program error..."), wxOK | wxICON_EXCLAMATION); + return false; } wxStrcpy(wxGetApp().params.UserName, tStr); tStr = pParamPasswordTxt->GetValue(); - if (tStr.Length() > (sizeof(wxGetApp().params.Password)-1)) + if (tStr.Length() > ((int)(sizeof(wxGetApp().params.Password) / sizeof(wxChar))-1)) { wxString errmsg; - errmsg.Printf(wxT("Password is longer than the data structure to hold it.\n'Cparameter.Password' must have a larger character array\nto handle a data source with this long of a name\n\nThe password currently specified is %d characters long."),tStr.Length()); - wxMessageBox(errmsg,wxT("Internal program error..."),wxOK | wxICON_EXCLAMATION); - return FALSE; + errmsg.Printf(wxT("Password is longer than the data structure to hold it.\n'Cparameter.Password' must have a larger character array\nto handle a data source with this long of a name\n\nThe password currently specified is %d characters long."), tStr.Length()); + wxMessageBox(errmsg, wxT("Internal program error..."), wxOK | wxICON_EXCLAMATION); + return false; } wxStrcpy(wxGetApp().params.Password,tStr); tStr = pParamDirPathTxt->GetValue(); tStr.Replace(wxT("\\"),wxT("/")); - if (tStr.Length() > (sizeof(wxGetApp().params.DirPath)-1)) + if (tStr.Length() > ((int)(sizeof(wxGetApp().params.DirPath) / sizeof(wxChar))-1)) { wxString errmsg; - errmsg.Printf(wxT("DirPath is longer than the data structure to hold it.\n'Cparameter.DirPath' must have a larger character array\nto handle a data source with this long of a name\n\nThe password currently specified is %d characters long."),tStr.Length()); - wxMessageBox(errmsg,wxT("Internal program error..."),wxOK | wxICON_EXCLAMATION); - return FALSE; + errmsg.Printf(wxT("DirPath is longer than the data structure to hold it.\n'Cparameter.DirPath' must have a larger character array\nto handle a data source with this long of a name\n\nThe password currently specified is %d characters long."), tStr.Length()); + wxMessageBox(errmsg, wxT("Internal program error..."), wxOK | wxICON_EXCLAMATION); + return false; } wxStrcpy(wxGetApp().params.DirPath,tStr); - return TRUE; + return true; } // CparameterDlg::GetData() @@ -1953,54 +2335,52 @@ bool CparameterDlg::Save() if (!GetData()) { wxGetApp().params = savedParamSettings; - return FALSE; + return false; } wxGetApp().WriteParamFile(wxGetApp().params); - return TRUE; + return true; } // CparameterDlg::Save() void CparameterDlg::FillDataSourceList() { - wxChar Dsn[SQL_MAX_DSN_LENGTH + 1]; - wxChar DsDesc[255]; - wxStringList strList; + wxChar Dsn[SQL_MAX_DSN_LENGTH+1]; + wxChar DsDesc[254+1]; + wxSortedArrayString strArr; while (wxDbGetDataSource(wxGetApp().DbConnectInf->GetHenv(), Dsn, - SQL_MAX_DSN_LENGTH+1, DsDesc, 255)) - strList.Add(Dsn); - - strList.Sort(); - strList.Add(wxT("")); - wxChar **p = strList.ListToArray(); + SQL_MAX_DSN_LENGTH, DsDesc, 254)) + { + strArr.Add(Dsn); + } - int i; - for (i = 0; wxStrlen(p[i]); i++) - pParamODBCSourceList->Append(p[i]); + for (size_t i=0; i < strArr.GetCount(); i++) + { + pParamODBCSourceList->Append(strArr[i].c_str()); + } - wxDELETEA(p); } // CparameterDlg::FillDataSourceList() BEGIN_EVENT_TABLE(CqueryDlg, wxDialog) - EVT_BUTTON(-1, CqueryDlg::OnButton) + EVT_BUTTON(wxID_ANY, CqueryDlg::OnButton) EVT_CLOSE(CqueryDlg::OnCloseWindow) END_EVENT_TABLE() - + // CqueryDlg() constructor -CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], +CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], const wxString &pWhereArg) : - wxDialog (parent, QUERY_DIALOG, wxT("Query"), wxPoint(-1, -1), wxSize(480, 360)) + wxDialog (parent, QUERY_DIALOG, wxT("Query"), wxDefaultPosition, wxSize(480, 360)) { wxBeginBusyCursor(); colInf = 0; dbTable = 0; masterTableName = tblName[0]; - widgetPtrsSet = FALSE; + widgetPtrsSet = false; pDB = pDb; // Initialize the WHERE clause from the string passed in @@ -2014,10 +2394,10 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], return; } - pQueryCol1Msg = new wxStaticText(this, QUERY_DIALOG_COL_MSG, wxT("Column 1:"), wxPoint( 10, 10), wxSize( 69, 16), 0, wxT("QueryCol1Msg")); - pQueryCol1Choice = new wxChoice(this, QUERY_DIALOG_COL_CHOICE, wxPoint( 10, 27), wxSize(250, 27), 0, 0, 0, wxDefaultValidator, wxT("QueryCol1Choice")); - pQueryNotMsg = new wxStaticText(this, QUERY_DIALOG_NOT_MSG, wxT("NOT"), wxPoint(268, 10), wxSize( -1, -1), 0, wxT("QueryNotMsg")); - pQueryNotCheck = new wxCheckBox(this, QUERY_DIALOG_NOT_CHECKBOX, wxT(""), wxPoint(275, 37), wxSize( 20, 20), 0, wxDefaultValidator, wxT("QueryNotCheck")); + pQueryCol1Msg = new wxStaticText(this, QUERY_DIALOG_COL_MSG, wxT("Column 1:"), wxPoint( 10, 10), wxSize( 69, 16), 0, wxT("QueryCol1Msg")); + pQueryCol1Choice = new wxChoice(this, QUERY_DIALOG_COL_CHOICE, wxPoint( 10, 27), wxSize(250, 27), 0, 0, 0, wxDefaultValidator, wxT("QueryCol1Choice")); + pQueryNotMsg = new wxStaticText(this, QUERY_DIALOG_NOT_MSG, wxT("NOT"), wxPoint(268, 10), wxDefaultSize, 0, wxT("QueryNotMsg")); + pQueryNotCheck = new wxCheckBox(this, QUERY_DIALOG_NOT_CHECKBOX, wxEmptyString, wxPoint(275, 37), wxSize( 20, 20), 0, wxDefaultValidator, wxT("QueryNotCheck")); wxString choice_strings[9]; choice_strings[0] = wxT("="); @@ -2030,12 +2410,12 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], choice_strings[7] = wxT("Like"); choice_strings[8] = wxT("Between"); - pQueryOperatorMsg = new wxStaticText(this, QUERY_DIALOG_OP_MSG, wxT("Operator:"), wxPoint(305, 10), wxSize( -1, -1), 0, wxT("QueryOperatorMsg")); + pQueryOperatorMsg = new wxStaticText(this, QUERY_DIALOG_OP_MSG, wxT("Operator:"), wxPoint(305, 10), wxDefaultSize, 0, wxT("QueryOperatorMsg")); pQueryOperatorChoice = new wxChoice(this, QUERY_DIALOG_OP_CHOICE, wxPoint(305, 27), wxSize( 80, 27), 9, choice_strings, 0, wxDefaultValidator, wxT("QueryOperatorChoice")); pQueryCol2Msg = new wxStaticText(this, QUERY_DIALOG_COL2_MSG, wxT("Column 2:"), wxPoint( 10, 65), wxSize( 69, 16), 0, wxT("QueryCol2Msg")); pQueryCol2Choice = new wxChoice(this, QUERY_DIALOG_COL2_CHOICE, wxPoint( 10, 82), wxSize(250, 27), 0, 0, 0, wxDefaultValidator, wxT("QueryCol2Choice")); - pQuerySqlWhereMsg = new wxStaticText(this, QUERY_DIALOG_WHERE_MSG, wxT("SQL where clause:"), wxPoint( 10, 141), wxSize( -1, -1), 0, wxT("QuerySqlWhereMsg")); - pQuerySqlWhereMtxt = new wxTextCtrl(this, QUERY_DIALOG_WHERE_TEXT, wxT(""), wxPoint( 10, 159), wxSize(377, 134), wxTE_MULTILINE, wxDefaultValidator, wxT("QuerySqlWhereMtxt")); + pQuerySqlWhereMsg = new wxStaticText(this, QUERY_DIALOG_WHERE_MSG, wxT("SQL where clause:"), wxPoint( 10, 141), wxDefaultSize, 0, wxT("QuerySqlWhereMsg")); + pQuerySqlWhereMtxt = new wxTextCtrl(this, QUERY_DIALOG_WHERE_TEXT, wxEmptyString, wxPoint( 10, 159), wxSize(377, 134), wxTE_MULTILINE, wxDefaultValidator, wxT("QuerySqlWhereMtxt")); pQueryAddBtn = new wxButton(this, QUERY_DIALOG_ADD, wxT("&Add"), wxPoint(406, 24), wxSize( 56, 26), 0, wxDefaultValidator, wxT("QueryAddBtn")); pQueryAndBtn = new wxButton(this, QUERY_DIALOG_AND, wxT("A&nd"), wxPoint(406, 58), wxSize( 56, 26), 0, wxDefaultValidator, wxT("QueryAndBtn")); pQueryOrBtn = new wxButton(this, QUERY_DIALOG_OR, wxT("&Or"), wxPoint(406, 92), wxSize( 56, 26), 0, wxDefaultValidator, wxT("QueryOrBtn")); @@ -2044,14 +2424,14 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], pQueryDoneBtn = new wxButton(this, QUERY_DIALOG_DONE, wxT("&Done"), wxPoint(406, 185), wxSize( 56, 26), 0, wxDefaultValidator, wxT("QueryDoneBtn")); pQueryClearBtn = new wxButton(this, QUERY_DIALOG_CLEAR, wxT("C&lear"), wxPoint(406, 218), wxSize( 56, 26), 0, wxDefaultValidator, wxT("QueryClearBtn")); pQueryCountBtn = new wxButton(this, QUERY_DIALOG_COUNT, wxT("&Count"), wxPoint(406, 252), wxSize( 56, 26), 0, wxDefaultValidator, wxT("QueryCountBtn")); - pQueryValue1Msg = new wxStaticText(this, QUERY_DIALOG_VALUE1_MSG, wxT("Value:"), wxPoint(277, 66), wxSize( -1, -1), 0, wxT("QueryValue1Msg")); - pQueryValue1Txt = new wxTextCtrl(this, QUERY_DIALOG_VALUE1_TEXT, wxT(""), wxPoint(277, 83), wxSize(108, 25), 0, wxDefaultValidator, wxT("QueryValue1Txt")); - pQueryValue2Msg = new wxStaticText(this, QUERY_DIALOG_VALUE2_MSG, wxT("AND"), wxPoint(238, 126), wxSize( -1, -1), 0, wxT("QueryValue2Msg")); - pQueryValue2Txt = new wxTextCtrl(this, QUERY_DIALOG_VALUE2_TEXT, wxT(""), wxPoint(277, 120), wxSize(108, 25), 0, wxDefaultValidator, wxT("QueryValue2Txt")); - pQueryHintGrp = new wxStaticBox(this, QUERY_DIALOG_HINT_GROUP, wxT(""), wxPoint( 10, 291), wxSize(377, 40), 0, wxT("QueryHintGrp")); - pQueryHintMsg = new wxStaticText(this, QUERY_DIALOG_HINT_MSG, wxT(""), wxPoint( 16, 306), wxSize( -1, -1), 0, wxT("QueryHintMsg")); - - widgetPtrsSet = TRUE; + pQueryValue1Msg = new wxStaticText(this, QUERY_DIALOG_VALUE1_MSG, wxT("Value:"), wxPoint(277, 66), wxDefaultSize, 0, wxT("QueryValue1Msg")); + pQueryValue1Txt = new wxTextCtrl(this, QUERY_DIALOG_VALUE1_TEXT, wxEmptyString, wxPoint(277, 83), wxSize(108, 25), 0, wxDefaultValidator, wxT("QueryValue1Txt")); + pQueryValue2Msg = new wxStaticText(this, QUERY_DIALOG_VALUE2_MSG, wxT("AND"), wxPoint(238, 126), wxDefaultSize, 0, wxT("QueryValue2Msg")); + pQueryValue2Txt = new wxTextCtrl(this, QUERY_DIALOG_VALUE2_TEXT, wxEmptyString, wxPoint(277, 120), wxSize(108, 25), 0, wxDefaultValidator, wxT("QueryValue2Txt")); + pQueryHintGrp = new wxStaticBox(this, QUERY_DIALOG_HINT_GROUP, wxEmptyString, wxPoint( 10, 291), wxSize(377, 40), 0, wxT("QueryHintGrp")); + pQueryHintMsg = new wxStaticText(this, QUERY_DIALOG_HINT_MSG, wxEmptyString, wxPoint( 16, 306), wxDefaultSize, 0, wxT("QueryHintMsg")); + + widgetPtrsSet = true; // Initialize the dialog wxString qualName; pQueryCol2Choice->Append(wxT("VALUE -->")); @@ -2062,7 +2442,7 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], wxEndBusyCursor(); wxString tStr; tStr = wxT("ODBC error during GetColumns()\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); return; } @@ -2089,8 +2469,8 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], pQueryCol2Choice->SetSelection(0); pQueryOperatorChoice->SetSelection(0); - pQueryValue2Msg->Show(FALSE); - pQueryValue2Txt->Show(FALSE); + pQueryValue2Msg->Show(false); + pQueryValue2Txt->Show(false); pQueryHintMsg->SetLabel(langQRY_EQ); @@ -2116,7 +2496,7 @@ void CqueryDlg::OnButton(wxCommandEvent &event) } // CqueryDlg::OnButton() -void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event) +void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& WXUNUSED(event)) { // Widget pointers won't be set when the dialog is constructed. // Control is passed through this function once for each widget on @@ -2162,8 +2542,8 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event) } // Hide the value2 widget - pQueryValue2Msg->Show(FALSE); // BETWEEN will show this widget - pQueryValue2Txt->Show(FALSE); // BETWEEN will show this widget + pQueryValue2Msg->Show(false); // BETWEEN will show this widget + pQueryValue2Txt->Show(false); // BETWEEN will show this widget // Disable the NOT operator for <, <=, >, >= switch((qryOp) pQueryOperatorChoice->GetSelection()) @@ -2173,10 +2553,10 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event) case qryOpLE: case qryOpGE: pQueryNotCheck->SetValue(0); - pQueryNotCheck->Enable(FALSE); + pQueryNotCheck->Enable(false); break; default: - pQueryNotCheck->Enable(TRUE); + pQueryNotCheck->Enable(true); break; } @@ -2188,16 +2568,16 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event) case qryOpGT: case qryOpLE: case qryOpGE: - pQueryCol2Choice->Enable(TRUE); + pQueryCol2Choice->Enable(true); if (pQueryCol2Choice->GetSelection()) // Column name is highlighted { - pQueryValue1Msg->Show(FALSE); - pQueryValue1Txt->Show(FALSE); + pQueryValue1Msg->Show(false); + pQueryValue1Txt->Show(false); } else // "Value" is highlighted { - pQueryValue1Msg->Show(TRUE); - pQueryValue1Txt->Show(TRUE); + pQueryValue1Msg->Show(true); + pQueryValue1Txt->Show(true); pQueryValue1Txt->SetFocus(); } break; @@ -2205,18 +2585,18 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event) case qryOpCONTAINS: case qryOpLIKE: pQueryCol2Choice->SetSelection(0); - pQueryCol2Choice->Enable(FALSE); - pQueryValue1Msg->Show(TRUE); - pQueryValue1Txt->Show(TRUE); + pQueryCol2Choice->Enable(false); + pQueryValue1Msg->Show(true); + pQueryValue1Txt->Show(true); pQueryValue1Txt->SetFocus(); break; case qryOpBETWEEN: pQueryCol2Choice->SetSelection(0); - pQueryCol2Choice->Enable(FALSE); - pQueryValue2Msg->Show(TRUE); - pQueryValue2Txt->Show(TRUE); - pQueryValue1Msg->Show(TRUE); - pQueryValue1Txt->Show(TRUE); + pQueryCol2Choice->Enable(false); + pQueryValue2Msg->Show(true); + pQueryValue2Txt->Show(true); + pQueryValue1Msg->Show(true); + pQueryValue1Txt->Show(true); pQueryValue1Txt->SetFocus(); break; } @@ -2230,13 +2610,13 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event) { if (pQueryCol2Choice->GetSelection()) // Column name is highlighted { - pQueryValue1Msg->Show(FALSE); - pQueryValue1Txt->Show(FALSE); + pQueryValue1Msg->Show(false); + pQueryValue1Txt->Show(false); } else // "Value" is highlighted { - pQueryValue1Msg->Show(TRUE); - pQueryValue1Txt->Show(TRUE); + pQueryValue1Msg->Show(true); + pQueryValue1Txt->Show(true); pQueryValue1Txt->SetFocus(); } return; @@ -2300,10 +2680,11 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event) // Clear button if (widgetName == pQueryClearBtn->GetName()) { - bool Ok = (wxMessageBox(wxT("Are you sure you wish to clear the Query?"),wxT("Confirm"),wxYES_NO|wxICON_QUESTION) == wxYES); + bool Ok = (wxMessageBox(wxT("Are you sure you wish to clear the Query?"), wxT("Confirm"), wxYES_NO|wxICON_QUESTION) == wxYES); if (Ok) - pQuerySqlWhereMtxt->SetValue(wxT("")); + pQuerySqlWhereMtxt->SetValue(wxEmptyString); + return; } // Clear button @@ -2319,7 +2700,7 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event) } // CqueryDlg::OnCommand -void CqueryDlg::OnCloseWindow(wxCloseEvent& event) +void CqueryDlg::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) { // Clean up wxDELETEA(colInf); @@ -2330,7 +2711,7 @@ void CqueryDlg::OnCloseWindow(wxCloseEvent& event) while (wxIsBusy()) wxEndBusyCursor(); - Show(FALSE); + Show(false); SetReturnCode(1); // added so BoundsChecker would not report use of uninitialized variable this->Destroy(); @@ -2371,10 +2752,10 @@ void CqueryDlg::ProcessAddBtn() // Build the expression and append it to the where clause window wxString s = pQueryCol1Choice->GetStringSelection(); - + if (pQueryNotCheck->GetValue() && (oper != qryOpEQ)) s += wxT(" NOT"); - + switch(oper) { case qryOpEQ: @@ -2409,12 +2790,12 @@ void CqueryDlg::ProcessAddBtn() int col1Idx = pQueryCol1Choice->GetSelection(); - bool quote = FALSE; + bool quote = false; if (colInf[col1Idx].sqlDataType == SQL_VARCHAR || oper == qryOpBEGINS || oper == qryOpCONTAINS || oper == qryOpLIKE) - quote = TRUE; + quote = true; if (pQueryCol2Choice->GetSelection()) // Column name s += pQueryCol2Choice->GetStringSelection(); @@ -2453,8 +2834,8 @@ void CqueryDlg::ProcessCountBtn() if (!dbTable) // wxDbTable object needs to be created and opened { - dbTable = new wxDbTable(pDB, masterTableName, 0, wxT(""), - !wxDB_QUERY_ONLY, + dbTable = new wxDbTable(pDB, masterTableName, 0, (const wxString &)wxEmptyString, + !wxDB_QUERY_ONLY, wxGetApp().DbConnectInf->GetDefaultDir()); if (!dbTable) { @@ -2465,7 +2846,7 @@ void CqueryDlg::ProcessCountBtn() { wxString tStr; tStr = wxT("ODBC error during Open()\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); return; } @@ -2480,7 +2861,7 @@ void CqueryDlg::ProcessCountBtn() ULONG whereCnt = dbTable->Count(); // Count() of all records in the table - dbTable->SetWhereClause(wxT("")); + dbTable->SetWhereClause(wxEmptyString); ULONG totalCnt = dbTable->Count(); if (whereCnt > 0 || totalCnt == 0) @@ -2511,74 +2892,124 @@ bool CqueryDlg::ValidateWhereClause() if (where.Freq(wxT('(')) != where.Freq(wxT(')'))) { wxMessageBox(wxT("There are mismatched parenthesis in the constructed where clause"),wxT("Error..."),wxOK | wxICON_EXCLAMATION); - return(FALSE); + return(false); } // After a wxMessageBox, the focus does not necessarily return to the // window which was the focus when the message box popped up, so return // focus to the Query dialog for certain SetFocus(); - return(TRUE); + return(true); } // CqueryDlg::ValidateWhereClause() +#ifdef wxODBC_BLOB_SUPPORT + +BEGIN_EVENT_TABLE(CimageDlg, wxDialog) + EVT_CLOSE(CimageDlg::OnCloseWindow) +END_EVENT_TABLE() + +CimageDlg::CimageDlg(wxWindow *parent, wxChar *pImageData, off_t iSize) +: wxDialog(parent, IMAGE_DIALOG, wxT("BLOB Image"), wxDefaultPosition, wxDefaultSize), +m_pDisplayBmp(NULL), +m_pBmp(NULL), +m_pImage(NULL) +{ + wxMemoryInputStream inStream(pImageData, iSize); + if(inStream.IsOk()) + { + m_pImage = new wxImage(inStream, wxBITMAP_TYPE_ANY); + + if(m_pImage->Ok()) + { + m_pBmp = new wxBitmap(m_pImage); + m_pDisplayBmp = new wxStaticBitmap(this, IMAGE_DIALOG_STATIC_BMP, *m_pBmp, wxPoint(5,5), wxDefaultSize); + + SetSize(m_pBmp->GetWidth() + 10, m_pBmp->GetHeight() + 30); + } + } +} + +CimageDlg::~CimageDlg() +{ + if(m_pImage) + delete m_pImage; + + if(m_pBmp) + delete m_pBmp; + + if(m_pDisplayBmp) + delete m_pDisplayBmp; +} + +void CimageDlg::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) +{ + GetParent()->SetFocus(); + + Show(false); + + this->Destroy(); +} + +#endif void DisplayDbDiagnostics(wxDb *pDb) { wxString s, t; - bool comma = FALSE; + bool comma; - s = langDBINF_DB_NAME; + s = wxT("Diagnostics Output\n"); + s += langDBINF_DB_NAME; s += pDb->dbInf.dbmsName; - s += "\n"; + s += wxT("\n"); s += langDBINF_DB_VER; s += pDb->dbInf.dbmsVer; - s += "\n"; + s += wxT("\n"); s += langDBINF_DRIVER_NAME; s += pDb->dbInf.driverName; - s += "\n"; + s += wxT("\n"); s += langDBINF_DRIVER_ODBC_VER; s += pDb->dbInf.odbcVer; - s += "\n"; + s += wxT("\n"); s += langDBINF_DRIVER_MGR_ODBC_VER; s += pDb->dbInf.drvMgrOdbcVer; - s += "\n"; + s += wxT("\n"); s += langDBINF_DRIVER_VER; s += pDb->dbInf.driverVer; - s += "\n"; + s += wxT("\n"); s += langDBINF_SERVER_NAME; s += pDb->dbInf.serverName; - s += "\n"; + s += wxT("\n"); s += langDBINF_FILENAME; s += pDb->dbInf.databaseName; - s += "\n"; + s += wxT("\n"); s += langDBINF_OUTER_JOINS; s += pDb->dbInf.outerJoins; - s += "\n"; + s += wxT("\n"); s += langDBINF_STORED_PROC; s += pDb->dbInf.procedureSupport; - s += "\n"; + s += wxT("\n"); if (pDb->dbInf.maxConnections) - t.sprintf("%s%d\n", langDBINF_MAX_HDBC, pDb->dbInf.maxConnections); + t.sprintf(wxT("%s%d\n"), langDBINF_MAX_HDBC, pDb->dbInf.maxConnections); else - t.sprintf("%s%s\n", langDBINF_MAX_HDBC, langDBINF_UNLIMITED); + t.sprintf(wxT("%s%s\n"), langDBINF_MAX_HDBC, langDBINF_UNLIMITED); s += t; if (pDb->dbInf.maxStmts) - t.sprintf("%s%d\n", langDBINF_MAX_HSTMT, pDb->dbInf.maxStmts); + t.sprintf(wxT("%s%d\n"), langDBINF_MAX_HSTMT, pDb->dbInf.maxStmts); else - t.sprintf("%s%s\n", langDBINF_MAX_HSTMT, langDBINF_UNLIMITED); + t.sprintf(wxT("%s%s\n"), langDBINF_MAX_HSTMT, langDBINF_UNLIMITED); s += t; s += langDBINF_API_LVL; @@ -2588,7 +3019,7 @@ void DisplayDbDiagnostics(wxDb *pDb) case SQL_OAC_LEVEL1: s += langDBINF_LEVEL1; break; case SQL_OAC_LEVEL2: s += langDBINF_LEVEL2; break; } - s += "\n"; + s += wxT("\n"); s += langDBINF_CLI_LVL; switch(pDb->dbInf.cliConfLvl) @@ -2596,7 +3027,7 @@ void DisplayDbDiagnostics(wxDb *pDb) case SQL_OSCC_NOT_COMPLIANT: s += langDBINF_NOT_COMPLIANT; break; case SQL_OSCC_COMPLIANT: s += langDBINF_COMPLIANT; break; } - s += "\n"; + s += wxT("\n"); s += langDBINF_SQL_LVL; switch(pDb->dbInf.sqlConfLvl) @@ -2605,7 +3036,7 @@ void DisplayDbDiagnostics(wxDb *pDb) case SQL_OSC_CORE: s += langDBINF_CORE_GRAMMAR; break; case SQL_OSC_EXTENDED: s += langDBINF_EXT_GRAMMAR; break; } - s += "\n"; + s += wxT("\n"); s += langDBINF_COMMIT_BEHAVIOR; switch(pDb->dbInf.cursorCommitBehavior) @@ -2614,7 +3045,7 @@ void DisplayDbDiagnostics(wxDb *pDb) case SQL_CB_CLOSE: s += langDBINF_CLOSE_CURSORS; break; case SQL_CB_PRESERVE: s += langDBINF_PRESERVE_CURSORS; break; } - s += "\n"; + s += wxT("\n"); s += langDBINF_ROLLBACK_BEHAVIOR; switch(pDb->dbInf.cursorRollbackBehavior) @@ -2623,7 +3054,7 @@ void DisplayDbDiagnostics(wxDb *pDb) case SQL_CB_CLOSE: s += langDBINF_CLOSE_CURSORS; break; case SQL_CB_PRESERVE: s += langDBINF_PRESERVE_CURSORS; break; } - s += "\n"; + s += wxT("\n"); s += langDBINF_SUPP_NOT_NULL; switch(pDb->dbInf.supportNotNullClause) @@ -2631,11 +3062,11 @@ void DisplayDbDiagnostics(wxDb *pDb) case SQL_NNC_NULL: s += langNO; break; case SQL_NNC_NON_NULL: s += langYES; break; } - s += "\n"; + s += wxT("\n"); s += langDBINF_SUPP_IEF; s += pDb->dbInf.supportIEF; - s += "\n"; + s += wxT("\n"); // DEFAULT setting for "Transaction Isolation Level" s += langDBINF_TXN_ISOLATION; @@ -2649,7 +3080,7 @@ void DisplayDbDiagnostics(wxDb *pDb) case SQL_TXN_VERSIONING: s += langDBINF_VERSIONING; break; #endif } - s += "\n"; + s += wxT("\n"); // CURRENT setting for "Transaction Isolation Level" long txnIsoLvl; @@ -2667,118 +3098,118 @@ void DisplayDbDiagnostics(wxDb *pDb) #endif } } - s += "\n"; + s += wxT("\n"); #ifdef __VMS__ #pragma message disable incboodep #endif - comma = FALSE; + comma = false; s += langDBINF_TXN_ISOLATION_OPTS; if (pDb->dbInf.txnIsolationOptions & SQL_TXN_READ_UNCOMMITTED) {s += langDBINF_READ_UNCOMMITTED; comma++;} if (pDb->dbInf.txnIsolationOptions & SQL_TXN_READ_COMMITTED) - {if (comma++) s += ", "; s += langDBINF_READ_COMMITTED;} + {if (comma++) s += wxT(", "); s += langDBINF_READ_COMMITTED;} if (pDb->dbInf.txnIsolationOptions & SQL_TXN_REPEATABLE_READ) - {if (comma++) s += ", "; s += langDBINF_REPEATABLE_READ;} + {if (comma++) s += wxT(", "); s += langDBINF_REPEATABLE_READ;} if (pDb->dbInf.txnIsolationOptions & SQL_TXN_SERIALIZABLE) - {if (comma++) s += ", "; s += langDBINF_SERIALIZABLE;} + {if (comma++) s += wxT(", "); s += langDBINF_SERIALIZABLE;} #ifdef ODBC_V20 if (pDb->dbInf.txnIsolationOptions & SQL_TXN_VERSIONING) - {if (comma++) s += ", "; s += langDBINF_VERSIONING;} + {if (comma++) s += wxT(", "); s += langDBINF_VERSIONING;} #endif - s += "\n"; + s += wxT("\n"); - comma = FALSE; + comma = false; s += langDBINF_FETCH_DIRS; if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_NEXT) {s += langDBINF_NEXT; comma++;} if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_PRIOR) - {if (comma++) s += ", "; s += langDBINF_PREV;} + {if (comma++) s += wxT(", "); s += langDBINF_PREV;} if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_FIRST) - {if (comma++) s += ", "; s += langDBINF_FIRST;} + {if (comma++) s += wxT(", "); s += langDBINF_FIRST;} if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_LAST) - {if (comma++) s += ", "; s += langDBINF_LAST;} + {if (comma++) s += wxT(", "); s += langDBINF_LAST;} if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_ABSOLUTE) - {if (comma++) s += ", "; s += langDBINF_ABSOLUTE;} + {if (comma++) s += wxT(", "); s += langDBINF_ABSOLUTE;} if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_RELATIVE) - {if (comma++) s += ", "; s += langDBINF_RELATIVE;} + {if (comma++) s += wxT(", "); s += langDBINF_RELATIVE;} #ifdef ODBC_V20 if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_RESUME) - {if (comma++) s += ", "; s += langDBINF_RESUME;} + {if (comma++) s += wxT(", "); s += langDBINF_RESUME;} #endif if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_BOOKMARK) - {if (comma++) s += ", "; s += langDBINF_BOOKMARK;} - s += "\n"; + {if (comma++) s += wxT(", "); s += langDBINF_BOOKMARK;} + s += wxT("\n"); - comma = FALSE; + comma = false; s += langDBINF_LOCK_TYPES; if (pDb->dbInf.lockTypes & SQL_LCK_NO_CHANGE) {s += langDBINF_NO_CHANGE; comma++;} if (pDb->dbInf.lockTypes & SQL_LCK_EXCLUSIVE) - {if (comma++) s += ", "; s += langDBINF_EXCLUSIVE;} + {if (comma++) s += wxT(", "); s += langDBINF_EXCLUSIVE;} if (pDb->dbInf.lockTypes & SQL_LCK_UNLOCK) - {if (comma++) s += ", "; s += langDBINF_UNLOCK;} - s += "\n"; + {if (comma++) s += wxT(", "); s += langDBINF_UNLOCK;} + s += wxT("\n"); - comma = FALSE; + comma = false; s += langDBINF_POS_OPERS; if (pDb->dbInf.posOperations & SQL_POS_POSITION) {s += langDBINF_POSITION; comma++;} if (pDb->dbInf.posOperations & SQL_POS_REFRESH) - {if (comma++) s += ", "; s += langDBINF_REFRESH;} + {if (comma++) s += wxT(", "); s += langDBINF_REFRESH;} if (pDb->dbInf.posOperations & SQL_POS_UPDATE) - {if (comma++) s += ", "; s += langDBINF_UPD;} + {if (comma++) s += wxT(", "); s += langDBINF_UPD;} if (pDb->dbInf.posOperations & SQL_POS_DELETE) - {if (comma++) s += ", "; s += langDBINF_DEL;} + {if (comma++) s += wxT(", "); s += langDBINF_DEL;} if (pDb->dbInf.posOperations & SQL_POS_ADD) - {if (comma++) s += ", "; s += langDBINF_ADD;} - s += "\n"; + {if (comma++) s += wxT(", "); s += langDBINF_ADD;} + s += wxT("\n"); - comma = FALSE; + comma = false; s += langDBINF_POS_STMTS; if (pDb->dbInf.posStmts & SQL_PS_POSITIONED_DELETE) {s += langDBINF_POS_DEL; comma++;} if (pDb->dbInf.posStmts & SQL_PS_POSITIONED_UPDATE) - {if (comma++) s += ", "; s += langDBINF_POS_UPD;} + {if (comma++) s += wxT(", "); s += langDBINF_POS_UPD;} if (pDb->dbInf.posStmts & SQL_PS_SELECT_FOR_UPDATE) - {if (comma++) s += ", "; s += langDBINF_SELECT_FOR_UPD;} - s += "\n"; + {if (comma++) s += wxT(", "); s += langDBINF_SELECT_FOR_UPD;} + s += wxT("\n"); - comma = FALSE; + comma = false; s += langDBINF_SCROLL_CONCURR; if (pDb->dbInf.scrollConcurrency & SQL_SCCO_READ_ONLY) {s += langDBINF_READ_ONLY; comma++;} if (pDb->dbInf.scrollConcurrency & SQL_SCCO_LOCK) - {if (comma++) s += ", "; s += langDBINF_LOCK;} + {if (comma++) s += wxT(", "); s += langDBINF_LOCK;} if (pDb->dbInf.scrollConcurrency & SQL_SCCO_OPT_ROWVER) - {if (comma++) s += ", "; s += langDBINF_OPT_ROWVER;} + {if (comma++) s += wxT(", "); s += langDBINF_OPT_ROWVER;} if (pDb->dbInf.scrollConcurrency & SQL_SCCO_OPT_VALUES) - {if (comma++) s += ", "; s += langDBINF_OPT_VALUES;} - s += "\n"; + {if (comma++) s += wxT(", "); s += langDBINF_OPT_VALUES;} + s += wxT("\n"); - comma = FALSE; + comma = false; s += langDBINF_SCROLL_OPTS; if (pDb->dbInf.scrollOptions & SQL_SO_FORWARD_ONLY) {s += langDBINF_FWD_ONLY; comma++;} if (pDb->dbInf.scrollOptions & SQL_SO_STATIC) - {if (comma++) s += ", "; s += langDBINF_STATIC;} + {if (comma++) s += wxT(", "); s += langDBINF_STATIC;} if (pDb->dbInf.scrollOptions & SQL_SO_KEYSET_DRIVEN) - {if (comma++) s += ", "; s += langDBINF_KEYSET_DRIVEN;} + {if (comma++) s += wxT(", "); s += langDBINF_KEYSET_DRIVEN;} if (pDb->dbInf.scrollOptions & SQL_SO_DYNAMIC) - {if (comma++) s += ", "; s += langDBINF_DYNAMIC;} + {if (comma++) s += wxT(", "); s += langDBINF_DYNAMIC;} if (pDb->dbInf.scrollOptions & SQL_SO_MIXED) - {if (comma++) s += ", "; s += langDBINF_MIXED;} - s += "\n"; + {if (comma++) s += wxT(", "); s += langDBINF_MIXED;} + s += wxT("\n"); - comma = FALSE; + comma = false; s += langDBINF_STATIC_SENS; if (pDb->dbInf.staticSensitivity & SQL_SS_ADDITIONS) {s += langDBINF_ADDITIONS; comma++;} if (pDb->dbInf.staticSensitivity & SQL_SS_DELETIONS) - {if (comma++) s += ", "; s += langDBINF_DELETIONS;} + {if (comma++) s += wxT(", "); s += langDBINF_DELETIONS;} if (pDb->dbInf.staticSensitivity & SQL_SS_UPDATES) - {if (comma++) s += ", "; s += langDBINF_UPDATES;} - s += "\n"; + {if (comma++) s += wxT(", "); s += langDBINF_UPDATES;} + s += wxT("\n"); #ifdef __VMS__ #pragma message enable incboodep #endif @@ -2789,80 +3220,81 @@ void DisplayDbDiagnostics(wxDb *pDb) { case SQL_TC_NONE: s += langNO; break; case SQL_TC_DML: s += langDBINF_DML_ONLY; break; - case SQL_TC_DDL_COMMIT: s += langDBINF_DDL_COMMIT; break; - case SQL_TC_DDL_IGNORE: s += langDBINF_DDL_IGNORE; break; + case SQL_TC_DDL_COMMIT: s += langDBINF_DDL_COMMIT; break; + case SQL_TC_DDL_IGNORE: s += langDBINF_DDL_IGNORE; break; case SQL_TC_ALL: s += langDBINF_DDL_AND_DML; break; } - s += "\n"; + s += wxT("\n"); - t.sprintf("%s%d\n", langDBINF_LOGIN_TIMEOUT, pDb->dbInf.loginTimeout); + t.sprintf(wxT("%s%lu\n"), langDBINF_LOGIN_TIMEOUT, pDb->dbInf.loginTimeout); s += t; // Oracle specific information if (pDb->Dbms() == dbmsORACLE) { - s += "\n"; + s += wxT("\n"); s += langDBINF_ORACLE_BANNER; - s += "\n"; + s += wxT("\n"); // Oracle cache hit ratio SDWORD cb; ULONG dbBlockGets; - pDb->ExecSql("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'db block gets'"); + pDb->ExecSql(wxT("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'db block gets'")); pDb->GetNext(); if (pDb->GetData(1, SQL_C_ULONG, &dbBlockGets, 0, &cb)) { - t.sprintf("%s: %lu\n", langDBINF_DB_BLOCK_GETS, dbBlockGets); + t.sprintf(wxT("%s: %lu\n"), langDBINF_DB_BLOCK_GETS, dbBlockGets); s += t; } ULONG consistentGets; - pDb->ExecSql("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'consistent gets'"); + pDb->ExecSql(wxT("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'consistent gets'")); pDb->GetNext(); if (pDb->GetData(1, SQL_C_ULONG, &consistentGets, 0, &cb)) { - t.sprintf("%s: %lu\n", langDBINF_CONSISTENT_GETS, consistentGets); + t.sprintf(wxT("%s: %lu\n"), langDBINF_CONSISTENT_GETS, consistentGets); s += t; } ULONG physReads; - pDb->ExecSql("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'physical reads'"); + pDb->ExecSql(wxT("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'physical reads'")); pDb->GetNext(); if (pDb->GetData(1, SQL_C_ULONG, &physReads, 0, &cb)) { - t.sprintf("%s: %lu\n", langDBINF_PHYSICAL_READS, physReads); + t.sprintf(wxT("%s: %lu\n"), langDBINF_PHYSICAL_READS, physReads); s += t; } ULONG hitRatio = (ULONG)((1.00 - ((float)physReads / (float)(dbBlockGets + consistentGets))) * 100.00); - t.sprintf("*** %s: %lu%%\n", langDBINF_CACHE_HIT_RATIO, hitRatio); + t.sprintf(wxT("*** %s: %lu%%\n"), langDBINF_CACHE_HIT_RATIO, hitRatio); s += t; // Tablespace information - s += "\n"; + s += wxT("\n"); s += langDBINF_TABLESPACE_IO; - s += "\n"; + s += wxT("\n"); ULONG physWrites; - char tablespaceName[257]; - pDb->ExecSql("SELECT NAME,PHYRDS,PHYWRTS FROM V$DATAFILE, V$FILESTAT WHERE V$DATAFILE.FILE# = V$FILESTAT.FILE#"); + char tablespaceName[256+1]; + pDb->ExecSql(wxT("SELECT NAME,PHYRDS,PHYWRTS FROM V$DATAFILE, V$FILESTAT WHERE V$DATAFILE.FILE# = V$FILESTAT.FILE#")); while (pDb->GetNext()) { - pDb->GetData(1, SQL_C_CHAR, tablespaceName, 257, &cb); - pDb->GetData(2, SQL_C_ULONG, &physReads, 0, &cb); - pDb->GetData(3, SQL_C_ULONG, &physWrites, 0, &cb); - t.sprintf("%s\n\t%s: %lu\t%s: %lu\n", tablespaceName, + pDb->GetData(1, SQL_C_WXCHAR, tablespaceName, 256, &cb); + pDb->GetData(2, SQL_C_ULONG, &physReads, 0, &cb); + pDb->GetData(3, SQL_C_ULONG, &physWrites, 0, &cb); + t.sprintf(wxT("%s\n\t%s: %lu\t%s: %lu\n"), tablespaceName, langDBINF_PHYSICAL_READS, physReads, langDBINF_PHYSICAL_WRITES, physWrites); s += t; } - s += "\n"; + s += wxT("\n"); } + s += wxT("End of Diagnostics\n"); wxLogMessage(s); } // DisplayDbDiagnostics() -#if wxUSE_NEW_GRID +#if wxUSE_GRID BEGIN_EVENT_TABLE(DbGridFrame, wxFrame) // EVT_CLOSE(DbGridFrame::OnCloseWindow) @@ -2870,14 +3302,14 @@ END_EVENT_TABLE() DbGridFrame::DbGridFrame(wxWindow *parent) - : wxFrame (parent, -1, wxT("Database Table"), + : wxFrame (parent, wxID_ANY, wxT("Database Table"), wxDefaultPosition, wxSize(400, 325)) { - initialized = FALSE; + initialized = false; } -void DbGridFrame::OnCloseWindow(wxCloseEvent& event) +void DbGridFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) { this->Destroy(); } @@ -2885,22 +3317,22 @@ void DbGridFrame::OnCloseWindow(wxCloseEvent& event) bool DbGridFrame::Initialize() { - wxGrid *grid = new wxGrid(this, -1, wxDefaultPosition); + wxGrid *grid = new wxGrid(this, wxID_ANY, wxDefaultPosition); grid->RegisterDataType(wxGRID_VALUE_DATETIME, - new wxGridCellDateTimeRenderer(_T("%d %b %Y")), + new wxGridCellDateTimeRenderer(wxT("%d %b %Y")), new wxGridCellTextEditor); #ifdef CHOICEINT grid->RegisterDataType(wxGRID_VALUE_CHOICEINT, new wxGridCellEnumRenderer, new wxGridCellEnumEditor); - - wxString NativeLangChoice( wxString::Format("%s:%s,%s,%s,%s,%s",wxGRID_VALUE_CHOICEINT, + + wxString NativeLangChoice( wxString::Format(wxT("%s:%s,%s,%s,%s,%s"),wxGRID_VALUE_CHOICEINT, wxT("English"), wxT("French"), wxT("German"), wxT("Spanish"), - wxT("Other") )); + wxT("Other") )); #endif // Columns must match the sequence specified in SetColDef() calls @@ -2918,7 +3350,7 @@ bool DbGridFrame::Initialize() new wxDbGridColInfo(10,wxGRID_VALUE_NUMBER,wxT("Lines Of Code"), #ifdef CHOICEINT new wxDbGridColInfo(11,NativeLangChoice, wxT("Native Language"),NULL)))))))))))); -#else +#else new wxDbGridColInfo(11,wxGRID_VALUE_NUMBER,wxT("Native Language"),NULL)))))))))))); #endif @@ -2928,7 +3360,7 @@ bool DbGridFrame::Initialize() if (!Contact) { wxMessageBox(wxT("Unable to instantiate an instance of Ccontact"), wxT("Error..."), wxOK | wxICON_EXCLAMATION); - return FALSE; + return false; } if (!Contact->Open()) @@ -2937,12 +3369,12 @@ bool DbGridFrame::Initialize() wxGetApp().DbConnectInf->GetDefaultDir())) { wxString tStr; - tStr.Printf(wxT("Unable to open the table '%s'.\n\n"),CONTACT_TABLE_NAME); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + tStr.Printf(wxT("Unable to open the table '%s'.\n\n"),CONTACT_TABLE_NAME.c_str()); + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); } - return FALSE; + return false; } // Execute the following query using the cursor designated @@ -2953,9 +3385,9 @@ bool DbGridFrame::Initialize() { wxString tStr; tStr = wxT("ODBC error during Query()\n\n"); - wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__), + wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__), wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION); - return FALSE; + return false; } // No data has been read in from the database yet, so @@ -2963,11 +3395,11 @@ bool DbGridFrame::Initialize() // so Fit() can correctly size the grid Contact->Initialize(); - wxDbGridTableBase* db = new wxDbGridTableBase(Contact, cols, wxUSE_QUERY, TRUE); + wxDbGridTableBase* db = new wxDbGridTableBase(Contact, cols, wxUSE_QUERY, true); delete cols; - grid->SetTable(db,TRUE); + grid->SetTable(db,true); grid->SetMargins(0, 0); grid->Fit(); @@ -2975,17 +3407,17 @@ bool DbGridFrame::Initialize() size.x += 10; size.y += 10; SetClientSize(size); - initialized = TRUE; - return TRUE; + initialized = true; + return true; } // DbGridFrame::Initialize() -#endif // #if wxUSE_NEW_GRID +#endif // #if wxUSE_GRID /* TEST CODE FOR TESTING THE wxDbCreateDataSource() FUNCTION int result = 0; - result = wxDbCreateDataSource(wxT("Microsoft Access Driver (*.mdb)"),wxT("GLT-TEST2"),wxT("GLT-Descrip"),FALSE,wxT(""),this); + result = wxDbCreateDataSource(wxT("Microsoft Access Driver (*.mdb)"), wxT("GLT-TEST2"), wxT("GLT-Descrip"), false, wxEmptyString, this); if (!result) { // check for errors caused by ConfigDSN based functions @@ -2994,12 +3426,12 @@ bool DbGridFrame::Initialize() wxChar errMsg[500+1]; errMsg[0] = wxT('\0'); - SQLInstallerError(1,&retcode,errMsg,500,&cb); + SQLInstallerError(1, &retcode, errMsg, 500, &cb); - wxMessageBox(wxT("FAILED creating data source"),wxT("FAILED")); + wxMessageBox(wxT("FAILED creating data source"), wxT("FAILED")); } else - wxMessageBox(wxT("SUCCEEDED creating data source"),wxT("SUCCESS")); + wxMessageBox(wxT("SUCCEEDED creating data source"), wxT("SUCCESS")); */