00001 #ifndef XFLTK__GUI_H_
00002 #define XFLTK__GUI_H_
00003
00004 #include <map>
00005 #include <istream>
00006 #include <fltk/widget.h>
00007 #include <fltk/window.h>
00008
00009 #include <istream>
00010 #include <expat.h>
00011
00012 #include "Error.h"
00013
00014 #include "utils.h"
00015
00016 namespace xfltk {
00017
00018 class GUI {
00019
00020 friend void XMLCALL startElement(void *userData, const char *name, const char **atts);
00021
00022 typedef std::map<const char*, fltk::Widget*, utils::ltstr> widget_map_type;
00023
00024 widget_map_type widget_map;
00025
00026 fltk::Widget* _root;
00027
00028 public:
00029
00034 Errors errors;
00035
00039 GUI(): _root(0) {};
00040
00045 GUI(std::istream& in_stream);
00046
00051 GUI(const char* file_name);
00052
00056 virtual ~GUI();
00057
00061 fltk::Widget* operator[](const char* name);
00062
00068 void setWidget(const char* id, fltk::Widget* w) {
00069 widget_map[id] = w;
00070 };
00071
00075 fltk::Widget* root() {
00076 return _root;
00077 }
00078
00082 fltk::Window* rootAsWindow() {
00083 return dynamic_cast<fltk::Window*>(_root);
00084 }
00085
00091 friend std::istream& operator>>(std::istream& in_stream, GUI& g);
00092
00097 void readFromFile(const char* file_name);
00098
00103 void clear();
00104
00105 };
00106
00107 }
00108
00109 #endif