]>
git.saurik.com Git - wxWidgets.git/blob - samples/db/listdb.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindows database demo app
4 // Author: George Tasker
8 // Copyright: (c) 1996 Remstar International, Inc.
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
13 #pragma interface "listdb.h"
17 Contains dialog class for creating a data table lookup listbox
24 #include <wx/dbtable.h>
26 const int LOOKUP_COL_LEN
= 250;
28 // Global database connection
29 extern wxDB
*READONLY_DB
;
32 class Clookup
: public wxTable
36 char lookupCol
[LOOKUP_COL_LEN
+1];
38 Clookup(char *tblName
, char *colName
);
43 class Clookup2
: public wxTable
47 char lookupCol1
[LOOKUP_COL_LEN
+1];
48 char lookupCol2
[LOOKUP_COL_LEN
+1];
50 Clookup2(char *tblName
, char *colName1
, char *colName2
, wxDB
*pDb
);
54 class ClookUpDlg
: public wxDialog
64 wxListBox
*pLookUpSelectList
;
65 wxButton
*pLookUpOkBtn
;
66 wxButton
*pLookUpCancelBtn
;
70 // This is a generic lookup constructor that will work with any table and any column
71 ClookUpDlg(wxWindow
*parent
,
79 // This is a generic lookup constructor that will work with any table and any column.
80 // It extends the capabilites of the lookup dialog in the following ways:
82 // 1) 2 columns rather than one
83 // 2) The ability to select DISTINCT column values
85 // Only set distinctValues equal to true if necessary. In many cases, the constraints
86 // of the index(es) will enforce this uniqueness. Selecting DISTINCT does require
87 // overhead by the database to ensure that all values returned are distinct. Therefore,
88 // use this ONLY when you need it.
90 // For complicated queries, you can pass in the sql select statement. This would be
91 // necessary if joins are involved since by default both columns must come from the
94 // If you do query by sql statement, you must pass in the maximum length of column1,
95 // since it cannot be derived when you query using your own sql statement.
97 // The optional database connection can be used if you'd like the lookup class
98 // to use a database pointer other than the global READONLY_DB. This is necessary if
99 // records are being saved, but not committed to the db, yet should be included
100 // in the lookup window.
102 ClookUpDlg(wxWindow
*parent
,
105 char *dispCol1
, // Must have at least 1 display column
106 char *dispCol2
, // Optional
109 bool distinctValues
, // e.g. SELECT DISTINCT ...
110 char *selectStmt
= 0, // If you wish to query by SQLstmt (complicated lookups)
111 int maxLenCol1
= 0, // Mandatory if querying by SQLstmt
112 wxDB
*pDb
= READONLY_DB
, // Database connection pointer
113 bool allowOk
= TRUE
); // is the OK button enabled
115 void OnButton( wxCommandEvent
&event
);
116 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
117 void OnClose(wxCloseEvent
& event
);
118 void OnActivate(bool) {}; // necessary for hot keys
120 DECLARE_EVENT_TABLE()
123 #define LOOKUP_DIALOG 500
125 #define LOOKUP_DIALOG_SELECT 501
126 #define LOOKUP_DIALOG_OK 502
127 #define LOOKUP_DIALOG_CANCEL 503
129 #endif // LISTDB_DOT_H
131 // ************************************ listdb.h *********************************