#define _PROPERTY_LIST_HXX
-#include <plib/pu.h>
+#include <plib/puAux.h>
#include <simgear/props/props.hxx>
+#include "dialog.hxx"
-#include "puList.hxx"
-
-class PropertyList : public puList, public SGPropertyChangeListener {
+class PropertyList : public puaList, public SGPropertyChangeListener, public GUI_ID {
public:
PropertyList(int minx, int miny, int maxx, int maxy, SGPropertyNode *);
~PropertyList();
void update (bool restore_slider_pos = false);
- void setCurrent(SGPropertyNode *p) { _curr = p; update(); publish(p); }
+ void setCurrent(SGPropertyNode *p);
SGPropertyNode *getCurrent() const { return _curr; }
void publish(SGPropertyNode *p) { _return = p; invokeCallback(); }
- void toggleFlags() { _flags->setBoolValue(!_flags->getBoolValue()); }
+ void toggleVerbosity() { _verbose = !_verbose; }
// overridden plib pui methods
virtual char *getStringValue(void) { return (char *)(_return ? _return->getPath(true) : ""); }
+ //virtual char *getListStringValue() { return (char *)(_return ? _return->getPath(true) : ""); }
virtual void setValue(const char *);
// listener method
virtual void valueChanged(SGPropertyNode *node);
private:
+ struct NodeData {
+ NodeData() : listener(0) {}
+ ~NodeData() {
+ if (listener)
+ node->removeChangeListener(listener);
+ }
+ void setListener(SGPropertyChangeListener *l) {
+ node->addChangeListener(listener = l);
+ }
+ SGPropertyNode_ptr node;
+ SGPropertyChangeListener *listener;
+ char **text;
+ };
+
// update the text string in the puList using the given node and
- // updating the requested offset. The value of dotFiles is taken
- // into account before the index is applied, i.e this should be
- // an index into 'children'
- void updateTextForEntry(int index);
+ // updating the requested offset.
+ void updateTextForEntry(NodeData&);
void delete_arrays();
static void handle_select(puObject *b);
+ static int nodeNameCompare(const void *, const void *);
SGPropertyNode_ptr _curr;
- SGPropertyNode_ptr _flags;
SGPropertyNode_ptr _return;
char **_entries;
int _num_entries;
- SGPropertyNode_ptr *_children;
+ NodeData *_children;
int _num_children;
- bool dotFiles; // . and .. pseudo-dirs currently shown?
+ bool _dot_files; // . and .. pseudo-dirs currently shown?
+ bool _verbose; // show SGPropertyNode flags
};