]> git.saurik.com Git - wxWidgets.git/blame - samples/db/listdb.h
added listbox test/demo
[wxWidgets.git] / samples / db / listdb.h
CommitLineData
108106cf
JS
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
1fc5dd6f 12#ifdef __GNUG__
108106cf 13#pragma interface "listdb.h"
1fc5dd6f 14#endif
108106cf
JS
15
16/*
e70e8f4c 17 Contains dialog class for creating a data table lookup listbox
108106cf
JS
18*/
19
20#ifndef LISTDB_DOT_H
21#define LISTDB_DOT_H
22
23
24#include <wx/dbtable.h>
25
5b077d48 26const int LOOKUP_COL_LEN = 250;
108106cf
JS
27
28// Global database connection
f6bcfd97 29extern wxDb *READONLY_DB;
108106cf
JS
30
31// Clookup class
f6bcfd97 32class Clookup : public wxDbTable
108106cf 33{
e70e8f4c 34 public:
108106cf 35
e70e8f4c 36 char lookupCol[LOOKUP_COL_LEN+1];
108106cf 37
e70e8f4c 38 Clookup(char *tblName, char *colName);
108106cf
JS
39
40}; // Clookup
41
42// Clookup2 class
f6bcfd97 43class Clookup2 : public wxDbTable
108106cf 44{
e70e8f4c 45 public:
108106cf 46
e70e8f4c
GT
47 char lookupCol1[LOOKUP_COL_LEN+1];
48 char lookupCol2[LOOKUP_COL_LEN+1];
108106cf 49
f6bcfd97 50 Clookup2(char *tblName, char *colName1, char *colName2, wxDb *pDb);
108106cf
JS
51
52}; // Clookup2
53
1fc5dd6f 54class ClookUpDlg : public wxDialog
108106cf 55{
e70e8f4c
GT
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
f6bcfd97 112 wxDb *pDb = READONLY_DB, // Database connection pointer
e70e8f4c
GT
113 bool allowOk = TRUE); // is the OK button enabled
114
115 void OnButton( wxCommandEvent &event );
116 void OnCommand(wxWindow& win, wxCommandEvent& event);
117 void OnClose(wxCloseEvent& event);
118 void OnActivate(bool) {}; // necessary for hot keys
65d7ddc4
GT
119
120DECLARE_EVENT_TABLE()
108106cf
JS
121};
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 *********************************