00001 #ifndef GSGL_FRAMEWORK_TREEBOX_H
00002 #define GSGL_FRAMEWORK_TREEBOX_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "framework/framework.hpp"
00038 #include "framework/widget.hpp"
00039 #include "framework/textbox.hpp"
00040 #include "framework/scrollbar.hpp"
00041 #include "data/array.hpp"
00042 #include "data/list.hpp"
00043
00044 namespace gsgl
00045 {
00046
00047 namespace platform
00048 {
00049 class font;
00050 }
00051
00052
00053 namespace framework
00054 {
00055
00056 class treebox;
00057 class treebox_plus;
00058
00059
00060 class FRAMEWORK_API treebox_node
00061 : public widget
00062 {
00063 treebox *parent_treebox;
00064 treebox_node *parent_node;
00065
00066 treebox_plus *plus_widget;
00067 textbox *text_widget;
00068
00069 bool expanded;
00070 int indent;
00071
00072 data::list<treebox_node *> tree_nodes;
00073
00074 void *user_data;
00075
00076 public:
00077
00078 treebox_node(treebox *parent_treebox, treebox_node *parent_node,
00079 const platform::color & fg, const platform::color & bg,
00080 const gsgl::string & text, void *user_data);
00081 virtual ~treebox_node();
00082
00083 treebox *get_parent_treebox() { return parent_treebox; }
00084
00085 bool & get_expanded() { return expanded; }
00086 int & get_indent() { return indent; }
00087
00088 data::list<treebox_node *> & get_tree_nodes() { return tree_nodes; }
00089 void clear_tree_nodes();
00090
00091
00092 void *& get_user_data() { return user_data; }
00093
00094
00095 virtual void draw();
00096 virtual bool handle_event(const SDL_Event &);
00097 };
00098
00099
00100 class FRAMEWORK_API treebox
00101 : public widget
00102 {
00103 platform::font *text_font;
00104
00105 scrollbar *side_scroll;
00106 data::list<treebox_node *> tree_nodes;
00107
00108 treebox_node *selected_node;
00109
00110 public:
00111 treebox(widget *parent, int x, int y, int w, int h, const platform::color & fg, const platform::color & bg, const gsgl::string & font_face, const int font_size);
00112 virtual ~treebox();
00113
00114 platform::font *get_text_font() { return text_font; }
00115 data::list<treebox_node *> & get_tree_nodes() { return tree_nodes; }
00116 void clear_tree_nodes();
00117
00118 treebox_node *& get_selected_node() { return selected_node; }
00119
00120 virtual void draw();
00121
00122 private:
00123 data::simple_array<treebox_node *> nodes_to_draw;
00124
00125 void mark_expanded_nodes(treebox_node *n, bool visible, int indent);
00126 };
00127
00128
00129 }
00130
00131 }
00132
00133 #endif