/
LBoundComboBox.h
129 lines (123 loc) · 3.85 KB
/
LBoundComboBox.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* File: LBoundComboBox.h
* Author: Saleem Edah-Tally - nmset@yandex.com
* License : LGPL version 2.1
* Copyright Saleem Edah-Tally, M. D. - © 2014
*
* Created on 3 juin 2014, 19:00
*/
#ifndef LBOUNDCOMBOBOX_H
#define LBOUNDCOMBOBOX_H
#include <wx/combobox.h>
#include "LBoundControl.h"
#include "LResultSet.h"
/**
* The control is called 'translated' if its items have associated client data that are instances of LItemData.
* The item strings are then only descriptive.
*/
class LBoundComboBox : public wxComboBox, public LBoundControl
{
public:
LBoundComboBox(wxWindow* parent, wxWindowID id = wxID_ANY);
virtual ~LBoundComboBox();
/**
*
* @return true if any of the items is associated with an instance of LItemData
*/
bool IsTranslated() const;
bool SelectionIsTranslated() const;
/**
* If the control is not translated, returns the string item at idx.
*
* Else, returns the associated data of the item at idx, or wxEmptyString.
* @param idx
* @return
*/
const wxAny GetDataOfIndex(unsigned int idx) const;
/**
* If the control is not translated, calls FindString(idx).
*
* Else, returns the index of the item whose associated data equals the parameter, or wxNOT_FOUND.
* @param data
* @return
*/
const int GetIndexOfData(const wxAny& data) const;
/**
* If the control is not translated, returns wxEmptyString (there is no data associated with any item).
*
* Else, returns the item whose associated data equals the parameter, or wxEmptyString.
* @param data
* @return
*/
const wxString GetItemOfData(const wxAny& data) const;
/**
* If the control is not translated, returns the parameter itself.
*
* Else, returns the associated data of the parameter, or wxEmptyString.
* @param item
* @return
*/
const wxAny GetDataOfItem(const wxString& item) const;
/**
* If the control is not translated, returns wxEmptyString.
*
* Else, returns the first item that does not have an associated data, or wxEmptyString.
* @return
*/
const wxString GetItemOfNull() const;
/**
* If the control is not translated, returns wxNOT_FOUND.
*
* Else, returns the index of the first item that does not have an associated data, or wxNOT_FOUND.
* @return
*/
const int GetIndexOfNull() const;
/**
* Deletes all items, sets selection to wxNOT_FOUND and wxEmptyString.
*/
void Clear();
/**
* If IsNull() is true, returns literal NULL.
*
* If the control is not translated, returns GetValue().
*
* Else, returns the associated client data value of the selection.
* @return
*/
const wxAny GetData();
/**
* If the control is not translated, calls SetValue() and returns FindString().
*
* If newData is empty or literal NULL, calls SetNull().
* Else, selects the first item whose associated client data equals newData.
* @param newData
*/
void SetData(const wxAny& newData);
/**
* Sets the resultset member and registers the control in the resultset.
* @param newResultSet
*/
void SetResultSet(LResultSet * newResultSet);
/**
* If the control is not translated, returns true if the selected item is empty.
*
* Else, return true if the selected item does not have any associated client data.
* @return
*/
bool IsNull();
/**
* If the control is not translated, sets its value to wxEmptyString with wxNOT_FOUND selection.
*
* Else, selects the first item that does not have an associated client data.
* @return
*/
void SetNull();
bool IsDirty();
/**
* Alias for GetValue().
* @return
*/
const wxString GetDisplayedData();
private:
};
#endif /* LBOUNDCOMBOBOX_H */