]>
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 ///////////////////////////////////////////////////////////////////////////////
12 #pragma interface "listdb.h"
18 Contains dialog class for creating a data table lookup listbox
27 #include <wx/dbtable.h>
29 const LOOKUP_COL_LEN
= 250;
31 // Global database connection
32 extern wxDB
*READONLY_DB
;
35 class Clookup
: public wxTable
39 char lookupCol
[LOOKUP_COL_LEN
+1];
41 Clookup(char *tblName
, char *colName
);
46 class Clookup2
: public wxTable
50 char lookupCol1
[LOOKUP_COL_LEN
+1];
51 char lookupCol2
[LOOKUP_COL_LEN
+1];
53 Clookup2(char *tblName
, char *colName1
, char *colName2
, wxDB
*pDb
);
57 class ClookUpDlg
: public wxDialogBox
67 wxListBox
*pLookUpSelectList
;
68 wxButton
*pLookUpOkBtn
;
69 wxButton
*pLookUpCancelBtn
;
73 // This is a generic lookup constructor that will work with any table and any column
74 ClookUpDlg(wxWindow
*parent
,
82 // This is a generic lookup constructor that will work with any table and any column.
83 // It extends the capabilites of the lookup dialog in the following ways:
85 // 1) 2 columns rather than one
86 // 2) The ability to select DISTINCT column values
88 // Only set distinctValues equal to true if necessary. In many cases, the constraints
89 // of the index(es) will enforce this uniqueness. Selecting DISTINCT does require
90 // overhead by the database to ensure that all values returned are distinct. Therefore,
91 // use this ONLY when you need it.
93 // For complicated queries, you can pass in the sql select statement. This would be
94 // necessary if joins are involved since by default both columns must come from the
97 // If you do query by sql statement, you must pass in the maximum length of column1,
98 // since it cannot be derived when you query using your own sql statement.
100 // The optional database connection can be used if you'd like the lookup class
101 // to use a database pointer other than the global READONLY_DB. This is necessary if
102 // records are being saved, but not committed to the db, yet should be included
103 // in the lookup window.
105 ClookUpDlg(wxWindow
*parent
,
108 char *dispCol1
, // Must have at least 1 display column
109 char *dispCol2
, // Optional
112 bool distinctValues
, // e.g. SELECT DISTINCT ...
113 char *selectStmt
= 0, // If you wish to query by SQLstmt (complicated lookups)
114 int maxLenCol1
= 0, // Mandatory if querying by SQLstmt
115 wxDB
*pDb
= READONLY_DB
, // Database connection pointer
116 bool allowOk
= TRUE
); // is the OK button enabled
118 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
120 void OnActivate(bool) {}; // necessary for hot keys
123 #endif // LISTDB_DOT_H
125 // ************************************ listdb.h *********************************