4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2012 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_DATA_FIELD_BASE_HPP
25 #define XCSOAR_DATA_FIELD_BASE_HPP
33 #define OUTBUFFERSIZE 128
35 class DataFieldListener
;
41 enum class Type
: uint8_t {
56 DataFieldListener
*listener
;
58 typedef void (*DataAccessCallback
)(DataField
*sender
, DataAccessMode mode
);
59 DataAccessCallback data_access_callback
;
61 // all Types dataField support combolist except DataFieldString.
62 const bool supports_combolist
;
67 bool item_help_enabled
;
73 DataField(Type type
, bool supports_combolist
,
74 DataAccessCallback data_access_callback
= NULL
);
77 virtual ~DataField() {}
79 void SetListener(DataFieldListener
*_listener
) {
80 assert(data_access_callback
== NULL
);
81 assert(listener
== NULL
);
82 assert(_listener
!= NULL
);
87 void SetDataAccessCallback(DataAccessCallback _data_access_callback
) {
88 assert(listener
== NULL
);
90 data_access_callback
= _data_access_callback
;
93 Type
GetType() const {
102 virtual int GetAsInteger() const;
105 virtual const TCHAR
*GetAsString() const;
108 virtual const TCHAR
*GetAsDisplayString() const;
110 virtual void SetAsInteger(int value
);
111 virtual void SetAsString(const TCHAR
*value
);
113 virtual void EnableItemHelp(bool value
) {};
115 // allows combolist to iterate all values w/out triggering external events
116 void SetDetachGUI(bool _detach_gui
) {
117 detach_gui
= _detach_gui
;
120 bool GetDetachGUI() {
125 virtual ComboList
*CreateComboList() const {
130 SetFromCombo(int iDataFieldIndex
, TCHAR
*sValue
)
132 SetAsInteger(iDataFieldIndex
);
135 bool GetItemHelpEnabled() {
136 return item_help_enabled
;
139 void CopyString(TCHAR
*buffer
, bool formatted
);
143 * Notify interested parties that the value of this object has