]> git.mxchange.org Git - flightgear.git/blob - src/GUI/property_list.hxx
Merge branch 'jmt/navradio'
[flightgear.git] / src / GUI / property_list.hxx
1 // Implementation of the <property-list> widget.
2 //
3 // Copyright (C) 2001  Steve BAKER
4 // Copyright (C) 2001  Jim WILSON
5 // Copyright (C) 2006  Melchior FRANZ
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23 #ifndef _PROPERTY_LIST_HXX
24 #define _PROPERTY_LIST_HXX
25
26 #include <string>
27
28 #include <plib/puAux.h>
29 #include <simgear/props/props.hxx>
30 #include "dialog.hxx"
31
32
33 class PropertyList : public puaList, public SGPropertyChangeListener, public GUI_ID {
34 public:
35     PropertyList(int minx, int miny, int maxx, int maxy, SGPropertyNode *);
36     ~PropertyList();
37
38     void update (bool restore_slider_pos = false);
39     void setCurrent(SGPropertyNode *p);
40     SGPropertyNode *getCurrent() const { return _curr; }
41     void publish(SGPropertyNode *p) { _return = p; invokeCallback(); }
42     void toggleVerbosity() { _verbose = !_verbose; }
43
44     // overridden plib pui methods
45     virtual char *getStringValue(void)
46     {
47         _return_path.clear();
48         if (_return)
49             _return_path = _return->getPath(true);
50         return const_cast<char*>(_return_path.c_str());
51     }
52     //virtual char *getListStringValue() { return (char *)(_return ? _return->getPath(true) : ""); }
53     virtual void setValue(const char *);
54
55     // listener method
56     virtual void valueChanged(SGPropertyNode *node);
57
58 private:
59     struct NodeData {
60         NodeData() : listener(0) {}
61         ~NodeData() {
62             if (listener)
63                 node->removeChangeListener(listener);
64         }
65         void setListener(SGPropertyChangeListener *l) {
66             node->addChangeListener(listener = l);
67         }
68         SGPropertyNode_ptr node;
69         SGPropertyChangeListener *listener;
70         char **text;
71     };
72
73     // update the text string in the puList using the given node and
74     // updating the requested offset.
75     void updateTextForEntry(NodeData&);
76     void delete_arrays();
77     static void handle_select(puObject *b);
78     static int nodeNameCompare(const void *, const void *);
79
80     SGPropertyNode_ptr _curr;
81     SGPropertyNode_ptr _return;
82
83     char **_entries;
84     int _num_entries;
85
86     NodeData *_children;
87     int _num_children;
88
89     bool _dot_files;      // . and .. pseudo-dirs currently shown?
90     bool _verbose;        // show SGPropertyNode flags
91     std::string _return_path;
92 };
93
94
95 #endif // _PROP_PICKER_HXX