]>
Commit | Line | Data |
---|---|---|
108106cf JS |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: listdb.h | |
be5a51fb | 3 | // Purpose: wxWidgets database demo app |
108106cf JS |
4 | // Author: George Tasker |
5 | // Modified by: | |
6 | // Created: 1996 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1996 Remstar International, Inc. | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
108106cf | 12 | /* |
e70e8f4c | 13 | Contains dialog class for creating a data table lookup listbox |
108106cf JS |
14 | */ |
15 | ||
16 | #ifndef LISTDB_DOT_H | |
17 | #define LISTDB_DOT_H | |
18 | ||
19 | ||
fb86524f | 20 | #include "wx/dbtable.h" |
108106cf | 21 | |
5b077d48 | 22 | const int LOOKUP_COL_LEN = 250; |
108106cf | 23 | |
108106cf | 24 | // Clookup class |
f6bcfd97 | 25 | class Clookup : public wxDbTable |
108106cf | 26 | { |
e70e8f4c | 27 | public: |
108106cf | 28 | |
94613352 | 29 | wxChar lookupCol[LOOKUP_COL_LEN+1]; |
108106cf | 30 | |
da1e87c4 | 31 | Clookup(wxString tblName, wxString colName, wxDb *pDb, const wxString &defDir=wxT("")); |
108106cf JS |
32 | |
33 | }; // Clookup | |
34 | ||
049977d0 | 35 | |
108106cf | 36 | // Clookup2 class |
f6bcfd97 | 37 | class Clookup2 : public wxDbTable |
108106cf | 38 | { |
e70e8f4c | 39 | public: |
108106cf | 40 | |
94613352 GT |
41 | wxChar lookupCol1[LOOKUP_COL_LEN+1]; |
42 | wxChar lookupCol2[LOOKUP_COL_LEN+1]; | |
108106cf | 43 | |
da1e87c4 | 44 | Clookup2(wxString tblName, wxString colName1, wxString colName2, wxDb *pDb, const wxString &defDir=wxT("")); |
108106cf JS |
45 | |
46 | }; // Clookup2 | |
47 | ||
049977d0 GT |
48 | |
49 | // ClookUpDlg class | |
1fc5dd6f | 50 | class ClookUpDlg : public wxDialog |
108106cf | 51 | { |
e70e8f4c GT |
52 | private: |
53 | bool widgetPtrsSet; | |
54 | int currentCursor; | |
55 | Clookup *lookup; | |
56 | Clookup2 *lookup2; | |
57 | int noDisplayCols; | |
58 | int col1Len; | |
59 | ||
60 | wxListBox *pLookUpSelectList; | |
61 | wxButton *pLookUpOkBtn; | |
62 | wxButton *pLookUpCancelBtn; | |
63 | ||
64 | public: | |
65 | ||
66 | // This is a generic lookup constructor that will work with any table and any column | |
e689d52a GT |
67 | ClookUpDlg(wxWindow *parent, |
68 | const wxString &windowTitle, | |
69 | const wxString &tableName, | |
70 | const wxString &colName, | |
71 | const wxString &where, | |
72 | const wxString &orderBy, | |
73 | wxDb *pDb, | |
74 | const wxString &defDir); | |
e70e8f4c GT |
75 | |
76 | // | |
77 | // This is a generic lookup constructor that will work with any table and any column. | |
78 | // It extends the capabilites of the lookup dialog in the following ways: | |
79 | // | |
80 | // 1) 2 columns rather than one | |
049977d0 | 81 | // 2) The ability to select DISTINCT column values |
e70e8f4c | 82 | // |
6d841efd | 83 | // Only set distinctValues equal to true if necessary. In many cases, the constraints |
e70e8f4c GT |
84 | // of the index(es) will enforce this uniqueness. Selecting DISTINCT does require |
85 | // overhead by the database to ensure that all values returned are distinct. Therefore, | |
86 | // use this ONLY when you need it. | |
87 | // | |
88 | // For complicated queries, you can pass in the sql select statement. This would be | |
89 | // necessary if joins are involved since by default both columns must come from the | |
90 | // same table. | |
91 | // | |
92 | // If you do query by sql statement, you must pass in the maximum length of column1, | |
93 | // since it cannot be derived when you query using your own sql statement. | |
94 | // | |
95 | // The optional database connection can be used if you'd like the lookup class | |
049977d0 GT |
96 | // to use a database pointer other than the READONLY_DB of the app. This is necessary |
97 | // if records are being saved, but not committed to the db, yet should be included | |
e70e8f4c GT |
98 | // in the lookup window. |
99 | // | |
100 | ClookUpDlg(wxWindow *parent, | |
e689d52a GT |
101 | const wxString &windowTitle, |
102 | const wxString &tableName, | |
103 | const wxString &dispCol1, // Must have at least 1 display column | |
104 | const wxString &dispCol2, // Optional | |
105 | const wxString &where, | |
106 | const wxString &orderBy, | |
107 | wxDb *pDb, // Database connection pointer | |
108 | const wxString &defDir, | |
109 | bool distinctValues, // e.g. SELECT DISTINCT ... | |
110 | const wxString &selectStmt = wxEmptyString, // If you wish to query by SQLstmt (complicated lookups) | |
111 | int maxLenCol1 = 0, // Mandatory if querying by SQLstmt | |
112 | bool allowOk = true); // is the OK button enabled | |
113 | ||
114 | void OnButton(wxCommandEvent &event); | |
e70e8f4c GT |
115 | void OnCommand(wxWindow& win, wxCommandEvent& event); |
116 | void OnClose(wxCloseEvent& event); | |
117 | void OnActivate(bool) {}; // necessary for hot keys | |
e689d52a | 118 | void OnDClick(wxCommandEvent &event); |
65d7ddc4 GT |
119 | |
120 | DECLARE_EVENT_TABLE() | |
049977d0 | 121 | }; // class ClookUpDlg |
108106cf | 122 | |
1fc5dd6f JS |
123 | #define LOOKUP_DIALOG 500 |
124 | ||
125 | #define LOOKUP_DIALOG_SELECT 501 | |
126 | #define LOOKUP_DIALOG_OK 502 | |
127 | #define LOOKUP_DIALOG_CANCEL 503 | |
128 | ||
108106cf JS |
129 | #endif // LISTDB_DOT_H |
130 | ||
131 | // ************************************ listdb.h ********************************* |