// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-#if defined(__GNUG__) && !defined(__APPLE__)
-#pragma interface "dbtest.h"
-#endif
-
#include "wx/string.h"
#include "wx/dbtable.h"
#if wxUSE_GRID
#define FILE_DBGRID_TABLE 130
#endif
-#define FILE_EXIT 199
+#define FILE_EXIT wxID_EXIT
#define EDIT_PARAMETERS 200
-#define HELP_ABOUT 300
+#define HELP_ABOUT wxID_ABOUT
// this seems to be missing, Robert Roebling (?)
#ifndef MAX_PATH
#endif
// Name of the table to be created/opened
-const wxChar CONTACT_TABLE_NAME[] = wxT("contacts");
+const wxString CONTACT_TABLE_NAME = wxT("CONTACTS");
#define wxODBC_BLOB_SUPPORT
+
// Number of columns in the CONTACT table
#ifdef wxODBC_BLOB_SUPPORT
- const int CONTACT_NO_COLS = 13; // 0-12
+ const int CONTACT_NO_COLS = 14; // 0-13
+ const int MAX_PICTURE_SIZE = 128000; // in bytes
#else
- const int CONTACT_NO_COLS = 12; // 0-11
+ const int CONTACT_NO_COLS = 12; // 0-11
#endif
-const wxChar PARAM_FILENAME[] = wxT("dbtest.cfg");
-
+const wxString PARAM_FILENAME = wxT("dbtest.cfg");
enum Language {langENGLISH, langFRENCH, langGERMAN, langSPANISH, langOTHER};
//
// This class contains the actual data members that are used for transferring
-// data back and forth from the database to the program.
+// data back and forth from the database to the program.
//
// NOTE: The object described in this class is just for example purposes, and has no
// real meaning other than to show each type of field being used by the database
wxChar Country[20+1];
TIMESTAMP_STRUCT JoinDate; // Date on which this person joined the wxWidgets project
Language NativeLanguage; // Enumerated type indicating person's native language
- wxChar Picture[50000];
+ ULONG BlobSize;
+ wxChar Picture[MAX_PICTURE_SIZE];
bool IsDeveloper; // Is this person a developer for wxWidgets, or just a subscriber
UCHAR Contributions; // Something to show off an integer field
ULONG LinesOfCode; // Something to show off a 'long' field
// all combined in this one class.
//
class Ccontact : public wxDbTable, public CstructContact
-{
+{
private:
// Used to keep track of whether this class had a wxDb instance
- // passed in to it or not. If an existing wxDb instance was not
+ // passed in to it or not. If an existing wxDb instance was not
// passed in at Ccontact creation time, then when the Ccontact
// instance is deleted, the connection will be freed as Ccontact
// created its own connection when it was created.
void SetupColumns();
public:
- // Used in places where we need to construct a WHERE clause to
+ // Used in places where we need to construct a WHERE clause to
// be passed to the SetWhereClause() function. From example,
// where building the WHERE clause requires using ::Printf()
// to build the string.
// Define a new frame type
class DatabaseDemoFrame: public wxFrame
-{
+{
private:
CeditorDlg *pEditorDlg;
CparameterDlg *pParamDlg;
void OnAbout(wxCommandEvent& event);
#if wxUSE_GRID
void OnDbGridTable( wxCommandEvent& );
-#endif
+#endif
void CreateDataTable(bool recreate);
void BuildEditorDialog();
void BuildParameterDialog(wxWindow *parent);
// Pointer to the main database connection used in the program. This
// pointer would normally be used for doing things as database lookups
// for user login names and passwords, getting workstation settings, etc.
- //
+ //
// ---> IMPORTANT <---
- //
+ //
// For each database object created which uses this wxDb pointer
// connection to the database, when a CommitTrans() or RollBackTrans()
// will commit or rollback EVERY object which uses this wxDb pointer.
- //
- // To allow each table object (those derived from wxDbTable) to be
+ //
+ // To allow each table object (those derived from wxDbTable) to be
// individually committed or rolled back, you MUST use a different
- // instance of wxDb in the constructor of the table. Doing so creates
+ // instance of wxDb in the constructor of the table. Doing so creates
// more overhead, and will use more database connections (some DBs have
// connection limits...), so use connections sparringly.
- //
+ //
// It is recommended that one "main" database connection be created for
// the entire program to use for READ-ONLY database accesses, but for each
// table object which will do a CommitTrans() or RollbackTrans() that a
// new wxDb object be created and used for it.
wxDb *READONLY_DB;
- // Contains the ODBC connection information used by
+ // Contains the ODBC connection information used by
// all database connections
wxDbConnectInf *DbConnectInf;
{
private:
// Used to indicate whether all of the widget pointers (defined
- // below) have been initialized to point to the memory for
+ // below) have been initialized to point to the memory for
// the named widget. Used as a safeguard from using the widget
// before it has been initialized.
bool widgetPtrsSet;
- // Used when the EDIT button has been pressed to maintain the
- // original name that was displayed in the editor before the
+ // Used when the EDIT button has been pressed to maintain the
+ // original name that was displayed in the editor before the
// EDIT button was pressed, so that if CANCEL is pressed, a
// FetchByName() can be done to retrieve the original data
// to repopulate the dialog.
wxRadioBox *pDeveloperRadio;
wxChoice *pNativeLangChoice;
wxStaticText *pNativeLangMsg;
+#ifdef wxODBC_BLOB_SUPPORT
+ wxStaticText *pPictureMsg, *pPictSizeMsg;
+ wxButton *pChooseImageBtn, *pShowImageBtn;
+ wxTextCtrl *pPictSizeTxt;
+#endif
public:
// Indicates if the editor dialog has been initialized yet (used to
bool Initialize();
+#ifdef wxODBC_BLOB_SUPPORT
+ // Methods for reading image file into current table, and
+ // also displaying the image.
+ void OnSelectPict();
+ void OnShowImage();
+#endif
+
// Sets wxStaticText fields to be editable or not depending
// on the current value of 'mode'
void FieldsEditable();
// retrieved from the editor dialog
bool Save();
- // Database functions for changing the data that is to
+ // Database functions for changing the data that is to
// be displayed on the dialog. GetNextRec()/GetPrevRec()
// provide database independent methods that do not require
// backward scrolling cursors to obtain the record that
bool GetNextRec();
bool GetPrevRec();
bool GetRec(const wxString &whereStr);
-
+
DECLARE_EVENT_TABLE()
}; // CeditorDlg
#define EDITOR_DIALOG_CATALOG 240
#define EDITOR_DIALOG_DATATYPES 250
#define EDITOR_DIALOG_DB_DIAGS 260
+#ifdef wxODBC_BLOB_SUPPORT
+ #define EDITOR_DIALOG_PIC_MSG 270
+ #define EDITOR_DIALOG_PICSIZE_MSG 271
+ #define EDITOR_DIALOG_PIC_BROWSE 272
+ #define EDITOR_DIALOG_PIC_SHOW 273
+ #define EDITOR_DIALOG_PIC_SIZE_TEXT 274
+#endif
// *************************** CparameterDlg ***************************
{
private:
// Used to indicate whether all of the widget pointers (defined
- // below) have been initialized to point to the memory for
+ // below) have been initialized to point to the memory for
// the named widget. Used as a safeguard from using the widget
// before it has been initialized.
bool widgetPtrsSet;
enum DialogModes mode;
- // Have the parameters been saved yet, or do they
+ // Have the parameters been saved yet, or do they
// need to be saved to update the params on disk
bool saved;
// Query strings
-wxChar * const langQRY_EQ = wxT("column = column | value");
-wxChar * const langQRY_LT = wxT("column < column | value");
-wxChar * const langQRY_GT = wxT("column > column | value");
-wxChar * const langQRY_LE = wxT("column <= column | value");
-wxChar * const langQRY_GE = wxT("column >= column | value");
-wxChar * const langQRY_BEGINS = wxT("columns that BEGIN with the string entered");
-wxChar * const langQRY_CONTAINS = wxT("columns that CONTAIN the string entered");
-wxChar * const langQRY_LIKE = wxT("% matches 0 or more of any char; _ matches 1 char");
-wxChar * const langQRY_BETWEEN = wxT("column BETWEEN value AND value");
+wxString const & langQRY_EQ = wxT("column = column | value");
+const wxString & langQRY_LT = wxT("column < column | value");
+const wxString & langQRY_GT = wxT("column > column | value");
+const wxString & langQRY_LE = wxT("column <= column | value");
+const wxString & langQRY_GE = wxT("column >= column | value");
+const wxString & langQRY_BEGINS = wxT("columns that BEGIN with the string entered");
+const wxString & langQRY_CONTAINS = wxT("columns that CONTAIN the string entered");
+const wxString & langQRY_LIKE = wxT("% matches 0 or more of any char; _ matches 1 char");
+const wxString & langQRY_BETWEEN = wxT("column BETWEEN value AND value");
class CqueryDlg : public wxDialog
public:
// Used to indicate whether all of the widget pointers (defined
- // below) have been initialized to point to the memory for
+ // below) have been initialized to point to the memory for
// the named widget. Used as a safeguard from using the widget
// before it has been initialized.
bool widgetPtrsSet;
#define QUERY_DIALOG_HINT_GROUP 323
#define QUERY_DIALOG_HINT_MSG 324
+#ifdef wxODBC_BLOB_SUPPORT
+
+class CimageDlg : public wxDialog
+{
+public:
+ CimageDlg(wxWindow *parent, wxChar *pImageData, off_t iSize);
+ ~CimageDlg();
+
+ void OnCloseWindow(wxCloseEvent &event);
+
+private:
+ wxStaticBitmap *m_pDisplayBmp;
+ wxBitmap *m_pBmp;
+ wxImage *m_pImage;
+
+protected:
+
+
+DECLARE_EVENT_TABLE()
+}; // CimageDlg
+
+#define IMAGE_DIALOG 400
+
+#define IMAGE_DIALOG_STATIC_BMP 401
+
+#endif
+
wxChar * const langNO = wxT("No");
wxChar * const langYES = wxT("Yes");
wxChar * const langDBINF_DB_NAME = wxT("Database Name = ");
wxChar * const langDBINF_STORED_PROC = wxT("Stored Procedures = ");
wxChar * const langDBINF_MAX_HDBC = wxT("Max # of Db connections = ");
wxChar * const langDBINF_MAX_HSTMT = wxT("Max # of cursors (per db connection) = ");
-wxChar * const langDBINF_UNLIMITED = wxT("Unlimited or Unknown");
+wxChar * const langDBINF_UNLIMITED = wxT("Unlimited or Unknown");
wxChar * const langDBINF_API_LVL = wxT("ODBC API conformance level = ");
wxChar * const langDBINF_CLI_LVL = wxT("Client (SAG) conformance level = ");
wxChar * const langDBINF_SQL_LVL = wxT("SQL conformance level = ");