]>
git.saurik.com Git - wxWidgets.git/blob - samples/db/listdb.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWidgets database demo app
4 // Author: George Tasker
8 // Copyright: (c) 1996 Remstar International, Inc.
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(__APPLE__)
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;
29 class Clookup
: public wxDbTable
33 wxChar lookupCol
[LOOKUP_COL_LEN
+1];
35 Clookup(wxChar
*tblName
, wxChar
*colName
, wxDb
*pDb
, const wxString
&defDir
=wxT(""));
41 class Clookup2
: public wxDbTable
45 wxChar lookupCol1
[LOOKUP_COL_LEN
+1];
46 wxChar lookupCol2
[LOOKUP_COL_LEN
+1];
48 Clookup2(wxChar
*tblName
, wxChar
*colName1
, wxChar
*colName2
, wxDb
*pDb
, const wxString
&defDir
=wxT(""));
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
,
78 const wxString
&defDir
);
81 // This is a generic lookup constructor that will work with any table and any column.
82 // It extends the capabilites of the lookup dialog in the following ways:
84 // 1) 2 columns rather than one
85 // 2) The ability to select DISTINCT column values
87 // Only set distinctValues equal to true if necessary. In many cases, the constraints
88 // of the index(es) will enforce this uniqueness. Selecting DISTINCT does require
89 // overhead by the database to ensure that all values returned are distinct. Therefore,
90 // use this ONLY when you need it.
92 // For complicated queries, you can pass in the sql select statement. This would be
93 // necessary if joins are involved since by default both columns must come from the
96 // If you do query by sql statement, you must pass in the maximum length of column1,
97 // since it cannot be derived when you query using your own sql statement.
99 // The optional database connection can be used if you'd like the lookup class
100 // to use a database pointer other than the READONLY_DB of the app. This is necessary
101 // if records are being saved, but not committed to the db, yet should be included
102 // in the lookup window.
104 ClookUpDlg(wxWindow
*parent
,
107 wxChar
*dispCol1
, // Must have at least 1 display column
108 wxChar
*dispCol2
, // Optional
111 wxDb
*pDb
, // Database connection pointer
112 const wxString
&defDir
,
113 bool distinctValues
, // e.g. SELECT DISTINCT ...
114 wxChar
*selectStmt
= 0, // If you wish to query by SQLstmt (complicated lookups)
115 int maxLenCol1
= 0, // Mandatory if querying by SQLstmt
116 bool allowOk
= true); // is the OK button enabled
118 void OnButton( wxCommandEvent
&event
);
119 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
120 void OnClose(wxCloseEvent
& event
);
121 void OnActivate(bool) {}; // necessary for hot keys
123 DECLARE_EVENT_TABLE()
124 }; // class ClookUpDlg
126 #define LOOKUP_DIALOG 500
128 #define LOOKUP_DIALOG_SELECT 501
129 #define LOOKUP_DIALOG_OK 502
130 #define LOOKUP_DIALOG_CANCEL 503
132 #endif // LISTDB_DOT_H
134 // ************************************ listdb.h *********************************