]> git.mxchange.org Git - flightgear.git/blob - src/GUI/property_list.hxx
- Added ultra-light traffic is now a separate traffic class that can have its
[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
27 #include <plib/pu.h>
28 #include <simgear/props/props.hxx>
29 #include "dialog.hxx"
30
31 #include "puList.hxx"
32
33 class PropertyList : public puList, 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 *getListStringValue() { return (char *)(_return ? _return->getPath(true) : ""); }
46     //virtual char *getStringValue(void) { return (char *)(_return ? _return->getPath(true) : ""); }
47     virtual void setValue(const char *);
48
49     // listener method
50     virtual void valueChanged(SGPropertyNode *node);
51
52 private:
53     struct NodeData {
54         NodeData() : listener(0) {}
55         ~NodeData() {
56             if (listener)
57                 node->removeChangeListener(listener);
58         }
59         void setListener(SGPropertyChangeListener *l) {
60             node->addChangeListener(listener = l);
61         }
62         SGPropertyNode_ptr node;
63         SGPropertyChangeListener *listener;
64         char **text;
65     };
66
67     // update the text string in the puList using the given node and
68     // updating the requested offset.
69     void updateTextForEntry(NodeData&);
70     void delete_arrays();
71     static void handle_select(puObject *b);
72     static int nodeNameCompare(const void *, const void *);
73
74     SGPropertyNode_ptr _curr;
75     SGPropertyNode_ptr _return;
76
77     char **_entries;
78     int _num_entries;
79
80     NodeData *_children;
81     int _num_children;
82
83     bool _dot_files;      // . and .. pseudo-dirs currently shown?
84     bool _verbose;        // show SGPropertyNode flags
85 };
86
87
88 #endif // _PROP_PICKER_HXX