]> git.mxchange.org Git - flightgear.git/blob - src/GUI/prop_picker.hxx
make FGFontCache independent of NewGUI and allow early construction in
[flightgear.git] / src / GUI / prop_picker.hxx
1 #ifndef _PROP_PICKER_HXX
2 #define _PROP_PICKER_HXX
3
4 #include <plib/pu.h>
5
6 #include <stdio.h>
7 #include "gui.h"
8 #include "dialog.hxx"
9 #include <simgear/props/props.hxx>
10
11 // A local alternative name, for use when a variable called "string"
12 // is in scope - e.g. in classes derived from puInput.
13 typedef string stdString;
14
15
16 void prop_pickerInit();
17 void prop_pickerView( puObject * );
18 void prop_pickerRefresh();
19 void prop_editOpen(SGPropertyNode *);
20
21
22 class fgPropPicker : public fgPopup, public SGPropertyChangeListener {
23 public:
24     fgPropPicker ( int x, int y, int w, int h, int arrows,
25                    SGPropertyNode *, const char *title = "Pick a file" );
26
27     void find_props ( bool restore_slider_pos = false );
28     SGPropertyNode *getCurrent () const { return curr; }
29     void setCurrent(SGPropertyNode *p) { curr = p; }
30
31     // over-ride the method from SGPropertyNodeListener
32     virtual void valueChanged (SGPropertyNode * node);
33
34     puText *proppath;
35
36 private:
37     static void handle_select ( puObject *b );
38     static void input_entered ( puObject *b );
39     static void fgPropPickerHandleSlider ( puObject * slider );
40     static void fgPropPickerHandleArrow ( puObject *arrow );
41     static void fgPropPickerHandleOk ( puObject* b );
42
43     void delete_arrays ();
44
45     // update the text string in the puList using the given node and
46     // updating the requested offset. The value of dotFiles is taken
47     // into account before the index is applied, i.e this should be
48     // an index into 'children' */
49     void updateTextForEntry(int index);
50
51     char** files;
52     int num_files;
53     int arrow_count;
54
55     SGPropertyNode_ptr curr;
56     SGPropertyNode_ptr flags;
57     SGPropertyNode_ptr* children;
58     int num_children;
59
60     // set if we're displaying the . and .. entries at the start of the
61     // list
62     bool dotFiles;
63
64 protected:
65     puFrame *frame;
66     puListBox *list_box;
67     puSlider *slider;
68     puOneShot *cancel_button;
69     puOneShot *ok_button;
70     puArrowButton *down_arrow;
71     puArrowButton *up_arrow;
72
73     NewGUI * _gui;
74 };
75
76
77
78 class fgPropEdit : public fgPopup {
79 public:
80     fgPropEdit ( SGPropertyNode *node );
81
82     SGPropertyNode *getEditNode() const { return node; }
83     void setEditNode(SGPropertyNode *p) { node = p; }
84
85     static void fgPropEditHandleCancel ( puObject *b );
86     static void fgPropEditHandleOK ( puObject* b );
87
88 protected:
89     puFrame *frame;
90     puOneShot *cancel_button;
91     puOneShot *ok_button;
92     SGPropertyNode_ptr node;
93     NewGUI * _gui;
94
95 public:
96     stdString namestring;                                       // FIXME make setters/getters
97     puText *propname;
98     puInput *propinput;
99 };
100
101 #endif // _PROP_PICKER_HXX