]> git.saurik.com Git - wxWidgets.git/blob - samples/db/listdb.h
Bakefile and other changes for new locations of STC and wxSVGFileDC.
[wxWidgets.git] / samples / db / listdb.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: listdb.h
3 // Purpose: wxWidgets database demo app
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
12 /*
13 Contains dialog class for creating a data table lookup listbox
14 */
15
16 #ifndef LISTDB_DOT_H
17 #define LISTDB_DOT_H
18
19
20 #include "wx/dbtable.h"
21
22 const int LOOKUP_COL_LEN = 250;
23
24 // Clookup class
25 class Clookup : public wxDbTable
26 {
27 public:
28
29 wxChar lookupCol[LOOKUP_COL_LEN+1];
30
31 Clookup(wxString tblName, wxString colName, wxDb *pDb, const wxString &defDir=wxT(""));
32
33 }; // Clookup
34
35
36 // Clookup2 class
37 class Clookup2 : public wxDbTable
38 {
39 public:
40
41 wxChar lookupCol1[LOOKUP_COL_LEN+1];
42 wxChar lookupCol2[LOOKUP_COL_LEN+1];
43
44 Clookup2(wxString tblName, wxString colName1, wxString colName2, wxDb *pDb, const wxString &defDir=wxT(""));
45
46 }; // Clookup2
47
48
49 // ClookUpDlg class
50 class ClookUpDlg : public wxDialog
51 {
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
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);
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
81 // 2) The ability to select DISTINCT column values
82 //
83 // Only set distinctValues equal to true if necessary. In many cases, the constraints
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
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
98 // in the lookup window.
99 //
100 ClookUpDlg(wxWindow *parent,
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);
115 void OnCommand(wxWindow& win, wxCommandEvent& event);
116 void OnClose(wxCloseEvent& event);
117 void OnActivate(bool) {}; // necessary for hot keys
118 void OnDClick(wxCommandEvent &event);
119
120 DECLARE_EVENT_TABLE()
121 }; // class ClookUpDlg
122
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
129 #endif // LISTDB_DOT_H
130
131 // ************************************ listdb.h *********************************