]> git.saurik.com Git - wxWidgets.git/blob - samples/db/listdb.h
440ad92f3b8bbe57ae23bdc47a4294f26dd12f2b
[wxWidgets.git] / samples / db / listdb.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: listdb.h
3 // Purpose: wxWindows 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 #ifdef __GNUG__
13 #pragma interface "listdb.h"
14 #endif
15
16 /*
17 Contains dialog class for creating a data table lookup listbox
18 */
19
20 #ifndef LISTDB_DOT_H
21 #define LISTDB_DOT_H
22
23
24 #include <wx/dbtable.h>
25
26 const int LOOKUP_COL_LEN = 250;
27
28 // Global database connection
29 extern wxDB *READONLY_DB;
30
31 // Clookup class
32 class Clookup : public wxTable
33 {
34 public:
35
36 char lookupCol[LOOKUP_COL_LEN+1];
37
38 Clookup(char *tblName, char *colName);
39
40 }; // Clookup
41
42 // Clookup2 class
43 class Clookup2 : public wxTable
44 {
45 public:
46
47 char lookupCol1[LOOKUP_COL_LEN+1];
48 char lookupCol2[LOOKUP_COL_LEN+1];
49
50 Clookup2(char *tblName, char *colName1, char *colName2, wxDB *pDb);
51
52 }; // Clookup2
53
54 class ClookUpDlg : public wxDialog
55 {
56 private:
57 bool widgetPtrsSet;
58 int currentCursor;
59 Clookup *lookup;
60 Clookup2 *lookup2;
61 int noDisplayCols;
62 int col1Len;
63
64 wxListBox *pLookUpSelectList;
65 wxButton *pLookUpOkBtn;
66 wxButton *pLookUpCancelBtn;
67
68 public:
69
70 // This is a generic lookup constructor that will work with any table and any column
71 ClookUpDlg(wxWindow *parent,
72 char *windowTitle,
73 char *tableName,
74 char *colName,
75 char *where,
76 char *orderBy);
77
78 //
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:
81 //
82 // 1) 2 columns rather than one
83 // 2) The ability to select DISTINCT column values
84 //
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.
89 //
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
92 // same table.
93 //
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.
96 //
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.
101 //
102 ClookUpDlg(wxWindow *parent,
103 char *windowTitle,
104 char *tableName,
105 char *dispCol1, // Must have at least 1 display column
106 char *dispCol2, // Optional
107 char *where,
108 char *orderBy,
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
114
115 void OnCommand(wxWindow& win, wxCommandEvent& event);
116 bool OnClose();
117 void OnActivate(bool) {}; // necessary for hot keys
118 };
119
120 #define LOOKUP_DIALOG 500
121
122 #define LOOKUP_DIALOG_SELECT 501
123 #define LOOKUP_DIALOG_OK 502
124 #define LOOKUP_DIALOG_CANCEL 503
125
126 #endif // LISTDB_DOT_H
127
128 // ************************************ listdb.h *********************************