]> git.saurik.com Git - wxWidgets.git/blame - samples/db/listdb.h
Motif corrections in
[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
12#pragma interface "listdb.h"
13
14/*
15/*
16// SYNOPSIS START
17
18 Contains dialog class for creating a data table lookup listbox
19
20// SYNOPSIS STOP
21*/
22
23#ifndef LISTDB_DOT_H
24#define LISTDB_DOT_H
25
26
27#include <wx/dbtable.h>
28
29const LOOKUP_COL_LEN = 250;
30
31// Global database connection
32extern wxDB *READONLY_DB;
33
34// Clookup class
35class Clookup : public wxTable
36{
37 public:
38
39 char lookupCol[LOOKUP_COL_LEN+1];
40
41 Clookup(char *tblName, char *colName);
42
43}; // Clookup
44
45// Clookup2 class
46class Clookup2 : public wxTable
47{
48 public:
49
50 char lookupCol1[LOOKUP_COL_LEN+1];
51 char lookupCol2[LOOKUP_COL_LEN+1];
52
53 Clookup2(char *tblName, char *colName1, char *colName2, wxDB *pDb);
54
55}; // Clookup2
56
57class ClookUpDlg : public wxDialogBox
58{
59 private:
60 bool widgetPtrsSet;
61 int currentCursor;
62 Clookup *lookup;
63 Clookup2 *lookup2;
64 int noDisplayCols;
65 int col1Len;
66
67 wxListBox *pLookUpSelectList;
68 wxButton *pLookUpOkBtn;
69 wxButton *pLookUpCancelBtn;
70
71 public:
72
73 // This is a generic lookup constructor that will work with any table and any column
74 ClookUpDlg(wxWindow *parent,
75 char *windowTitle,
76 char *tableName,
77 char *colName,
78 char *where,
79 char *orderBy);
80
81 //
82 // This is a generic lookup constructor that will work with any table and any column.
83 // It extends the capabilites of the lookup dialog in the following ways:
84 //
85 // 1) 2 columns rather than one
86 // 2) The ability to select DISTINCT column values
87 //
88 // Only set distinctValues equal to true if necessary. In many cases, the constraints
89 // of the index(es) will enforce this uniqueness. Selecting DISTINCT does require
90 // overhead by the database to ensure that all values returned are distinct. Therefore,
91 // use this ONLY when you need it.
92 //
93 // For complicated queries, you can pass in the sql select statement. This would be
94 // necessary if joins are involved since by default both columns must come from the
95 // same table.
96 //
97 // If you do query by sql statement, you must pass in the maximum length of column1,
98 // since it cannot be derived when you query using your own sql statement.
99 //
100 // The optional database connection can be used if you'd like the lookup class
101 // to use a database pointer other than the global READONLY_DB. This is necessary if
102 // records are being saved, but not committed to the db, yet should be included
103 // in the lookup window.
104 //
105 ClookUpDlg(wxWindow *parent,
106 char *windowTitle,
107 char *tableName,
108 char *dispCol1, // Must have at least 1 display column
109 char *dispCol2, // Optional
110 char *where,
111 char *orderBy,
112 bool distinctValues, // e.g. SELECT DISTINCT ...
113 char *selectStmt = 0, // If you wish to query by SQLstmt (complicated lookups)
114 int maxLenCol1 = 0, // Mandatory if querying by SQLstmt
115 wxDB *pDb = READONLY_DB, // Database connection pointer
116 bool allowOk = TRUE); // is the OK button enabled
117
118 void OnCommand(wxWindow& win, wxCommandEvent& event);
119 bool OnClose();
120 void OnActivate(bool) {}; // necessary for hot keys
121};
122
123#endif // LISTDB_DOT_H
124
125// ************************************ listdb.h *********************************