po: update French translation
[xcsoar.git] / src / DataField / Base.hpp
blob986eab84b8cc5436121c193ad7d540ab68417a59
1 /*
2 Copyright_License {
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
27 #include "Compiler.h"
29 #include <assert.h>
30 #include <tchar.h>
31 #include <stdint.h>
33 #define OUTBUFFERSIZE 128
35 class DataFieldListener;
36 class ComboList;
38 class DataField
40 public:
41 enum class Type : uint8_t {
42 STRING,
43 BOOLEAN,
44 INTEGER,
45 REAL,
46 ENUM,
47 FILE,
48 TIME,
51 enum DataAccessMode {
52 daChange,
53 daSpecial,
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;
64 protected:
65 const Type type;
67 bool item_help_enabled;
69 private:
70 bool detach_gui;
72 protected:
73 DataField(Type type, bool supports_combolist,
74 DataAccessCallback data_access_callback = NULL);
76 public:
77 virtual ~DataField() {}
79 void SetListener(DataFieldListener *_listener) {
80 assert(data_access_callback == NULL);
81 assert(listener == NULL);
82 assert(_listener != NULL);
84 listener = _listener;
87 void SetDataAccessCallback(DataAccessCallback _data_access_callback) {
88 assert(listener == NULL);
90 data_access_callback = _data_access_callback;
93 Type GetType() const {
94 return type;
97 void Special();
98 virtual void Inc();
99 virtual void Dec();
101 gcc_pure
102 virtual int GetAsInteger() const;
104 gcc_pure
105 virtual const TCHAR *GetAsString() const;
107 gcc_pure
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() {
121 return detach_gui;
124 gcc_malloc
125 virtual ComboList *CreateComboList() const {
126 return NULL;
129 virtual void
130 SetFromCombo(int iDataFieldIndex, TCHAR *sValue)
132 SetAsInteger(iDataFieldIndex);
135 bool GetItemHelpEnabled() {
136 return item_help_enabled;
139 void CopyString(TCHAR *buffer, bool formatted);
141 protected:
143 * Notify interested parties that the value of this object has
144 * been modified.
146 void Modified();
149 #endif