WidgetCreator.cpp

00001 #include "WidgetCreator.h"
00002 
00003 #include <fltk/Widget.h>
00004 
00005 #include <fltk/Button.h>
00006 #include <fltk/CheckButton.h>
00007 #include <fltk/LightButton.h>
00008 #include <fltk/RadioLightButton.h>
00009 #include <fltk/HighlightButton.h>
00010 #include <fltk/RepeatButton.h>
00011 #include <fltk/ReturnButton.h>
00012 #include <fltk/ToggleButton.h>
00013 
00014 #include <fltk/Clock.h>
00015 
00016 #include <fltk/Divider.h>
00017 
00018 #include <fltk/Input.h>
00019 #include <fltk/NumericInput.h>
00020 #include <fltk/FloatInput.h>
00021 #include <fltk/IntInput.h>
00022 #include <fltk/Output.h>
00023 #include <fltk/MultiLineOutput.h>
00024 #include <fltk/WordwrapOutput.h>
00025 
00026 #include <fltk/InvisibleBox.h>
00027 
00028 #include <fltk/Item.h>
00029 
00030 #include <fltk/Valuator.h>
00031 #include <fltk/Adjuster.h>
00032 #include <fltk/Dial.h>
00033 #include <fltk/FillDial.h>
00034 #include <fltk/LineDial.h>
00035 #include <fltk/Slider.h>
00036 #include <fltk/FillSlider.h>
00037 #include <fltk/Scrollbar.h>
00038 #include <fltk/ValueSlider.h>
00039 #include <fltk/ThumbWheel.h>
00040 #include <fltk/ValueInput.h>
00041 #include <fltk/ValueOutput.h>
00042 
00043 #include <fltk/Group.h>
00044 #include <fltk/Menu.h>
00045 #include <fltk/Browser.h>
00046 #include <fltk/MultiBrowser.h>
00047 #include <fltk/Choice.h>
00048 #include <fltk/CycleButton.h>
00049 #include <fltk/ItemGroup.h>
00050 #include <fltk/PopupMenu.h>
00051 #include <fltk/MenuBar.h>
00052 #include <fltk/PackedGroup.h>
00053 #include <fltk/ScrollGroup.h>
00054 #include <fltk/TabGroup.h>
00055 #include <fltk/Window.h>
00056 #include <fltk/ShapedWindow.h>
00057 
00058 #include <fltk/Style.h>
00059 #include <fltk/Symbol.h>
00060 #include <fltk/LabelType.h>
00061 
00062 #include <fltk/Font.h>
00063 #include <fltk/LabelType.h>
00064 
00065 #include "utils.h"
00066 
00067 namespace xfltk {
00068         
00069 //---=== WidgetFactory ===---
00070         
00071 WidgetFactory::widget_factories_map WidgetFactory::widget_factories;
00072 
00073 WidgetFactory::WidgetFactory(const char* name) {
00074         if (name)
00075                 widget_factories[name] = this;
00076 }
00077 
00078 WidgetFactory* WidgetFactory::find(const char* name) {
00079         widget_factories_map::iterator res = widget_factories.find(name);
00080         return (res == widget_factories.end()) ? 0 : res->second;
00081 }
00082 
00083 WidgetCreator* WidgetFactory::getCreator(const char* name, GUI& gui) {
00084         WidgetFactory* f = find(name);
00085         return f ? f->getCreator(gui) : 0;
00086 }
00087 
00088 //---=== HierarhyWidgetCreator ===---
00089 
00090 HierarhyWidgetFactory::HierarhyWidgetFactory(const char* name, HierarhyWidgetFactory* parent)
00091 : WidgetFactory(name), parent(parent) {}
00092 
00093 HierarhyWidgetFactory::widget_property_setters_map& HierarhyWidgetFactory::getWidgetPropertySetters() {
00094         /*if (!widget_property_setters) {
00095                 widget_property_setters = new widget_property_setters_map();
00096                 fill_property_setters();
00097         }*/
00098         return widget_property_setters;
00099 }
00100 
00101 void HierarhyWidgetFactory::setProperty(fltk::Widget* obj, const char* name, const char* value, WidgetCreator& creator) {
00102         widget_property_setters_map::iterator res = getWidgetPropertySetters().find(name);
00103         if (res != getWidgetPropertySetters().end())
00104                 res->second(obj, value, creator);
00105         else
00106                 if (parent)
00107                         parent->setProperty(obj, name, value, creator);
00108                 //TODO else rzu� wyj�tek: z�a nazwa w�a�ciwo�ci
00109 }
00110 
00111 void HierarhyWidgetFactory::setProperties(fltk::Widget* obj, const char** attr, WidgetCreator& creator) {
00112         for (; *attr; attr += 2)
00113                 if (!utils::eqstr()(attr[0], "id"))
00114                         setProperty(obj, attr[0], attr[1], creator);
00115 }
00116 
00117 void HierarhyWidgetFactory::addPropertySetter(const char* name, property_setter setter) {
00118         getWidgetPropertySetters()[name] = setter;
00119 }
00120 
00121 //---=== Standart widget factories ===---
00122 
00127 template <typename CLASS_TYPE, typename PARSE_PARAMETER_TYPE, typename PARAMETER_TYPE, void (CLASS_TYPE::*method)(PARAMETER_TYPE)>
00128 void cast_cast_caller(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00129         (((CLASS_TYPE*)obj)->*method)((PARAMETER_TYPE) utils::cast<PARSE_PARAMETER_TYPE>(value));
00130 }
00131 
00135 template <typename CLASS_TYPE, typename PARAMETER_TYPE, void (CLASS_TYPE::*method)(PARAMETER_TYPE)>
00136 void cast_caller(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00137         (((CLASS_TYPE*)obj)->*method)(utils::cast<PARAMETER_TYPE>(value));
00138 }
00139 
00144 template <typename CLASS_TYPE, typename PARAMETER_TYPE, PARAMETER_TYPE (CLASS_TYPE::*method)(PARAMETER_TYPE)>
00145 void cast_caller(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00146         (((CLASS_TYPE*)obj)->*method)(utils::cast<PARAMETER_TYPE>(value));
00147 }
00148 
00152 template <typename CLASS_TYPE, void (CLASS_TYPE::*method)(const char*)>
00153 void string_caller(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00154         (((CLASS_TYPE*)obj)->*method)(value);
00155 }
00156 
00161 template <typename CLASS_TYPE, void (CLASS_TYPE::*method)(fltk::Color)>
00162 void color_caller(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00163         (((CLASS_TYPE*)obj)->*method)(utils::cast<fltk::Color>(value));
00164 }
00165 
00170 template <typename CLASS_TYPE, void (CLASS_TYPE::*method_true)(void), void (CLASS_TYPE::*method_false)(void)>
00171 void bool_caller(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00172         if (utils::cast<bool>(value))
00173                 (((CLASS_TYPE*)obj)->*method_true)();
00174         else
00175                 (((CLASS_TYPE*)obj)->*method_false)();
00176 }
00177 
00183 template <typename CLASS_TYPE, bool (CLASS_TYPE::*method_true)(void), bool (CLASS_TYPE::*method_false)(void)>
00184 void bool_caller(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00185         if (utils::cast<bool>(value))
00186                 (((CLASS_TYPE*)obj)->*method_true)();
00187         else
00188                 (((CLASS_TYPE*)obj)->*method_false)();
00189 }
00190 
00191 template <typename CLASS_TYPE, void (CLASS_TYPE::*method)(fltk::Font* v)>
00192 void font_caller(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00193         fltk::Font* font = fltk::font(value);
00194         if (font)
00195                 (((CLASS_TYPE*)obj)->*method)(font);
00196         //TODO else error
00197 }
00198 
00199 /*template <typename CLASS_TYPE, void (CLASS_TYPE::*method)(fltk::LabelType* v)>
00200 void labeltype_caller(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00201         fltk::LabelType* label_type = fltk::LabelType::find(value);
00202         if (label_type)
00203                 (((CLASS_TYPE*)obj)->*method)(label_type);
00204 }*/
00205 
00206 template <typename CLASS_TYPE, void (CLASS_TYPE::*method)(const fltk::Symbol* s)>
00207 void symbol_caller(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00208         const fltk::Symbol* symbol = fltk::Symbol::find(value);
00209         if (symbol)
00210                 (((CLASS_TYPE*)obj)->*method)(symbol);
00211         //TODO else error
00212 }
00213 
00214 //----------========== fltk::Widget ==========----------//
00215 
00216 struct FactoryWidget: public HierarhyWidgetFactory {
00217         
00218         FactoryWidget();
00219         
00220         WidgetCreator* getCreator(GUI& gui) { return new HierarhyWidgetCreator<fltk::Widget>(gui, *this); };
00221         
00222 };
00223 
00224 static FactoryWidget factory_fltk_widget;
00225 
00226 void set_style(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00227         obj->copy_style(fltk::Style::find(value));
00228 }
00229 
00230 /*void set_image(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00231         obj->image(fltk::Symbol::find(value));
00232 }*/
00233 
00234 void set_labeltype(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00235         obj->labeltype(fltk::LabelType::find(value));
00236         //TODO error if find return 0
00237 }
00238 
00239 FactoryWidget::FactoryWidget(): HierarhyWidgetFactory("widget", 0) {
00240         
00241         widget_property_setters_map& property = getWidgetPropertySetters();
00242         
00243         property["rectangle.x"] = property["x"] = cast_caller<fltk::Rectangle, int, &fltk::Rectangle::x>;
00244         property["rectangle.y"] = property["y"] = cast_caller<fltk::Rectangle, int, &fltk::Rectangle::y>;
00245         property["rectangle.w"] = property["w"] = cast_caller<fltk::Rectangle, int, &fltk::Rectangle::w>;
00246         property["rectangle.h"] = property["h"] = cast_caller<fltk::Rectangle, int, &fltk::Rectangle::h>;
00247         
00248         property["widget.activate"] = property["activate"] = bool_caller<fltk::Widget, &fltk::Widget::activate, &fltk::Widget::deactivate>;
00249         //TODO ? activate(int b)
00250         //TODO flags, align
00251         
00252         //TODO box, buttonbox, focusbox fix??
00253         /*property["widget.box"] = property["box"] = symbol_caller<fltk::Widget, &fltk::Widget::box>;
00254         property["widget.buttonbox"] = property["buttonbox"] = symbol_caller<fltk::Widget, &fltk::Widget::buttonbox>;
00255         property["widget.focusbox"] = property["focusbox"] = symbol_caller<fltk::Widget, &fltk::Widget::focusbox>;      */
00256         
00257         property["widget.changed"] = property["changed"] = bool_caller<fltk::Widget, &fltk::Widget::set_changed, &fltk::Widget::clear_changed>;
00258         property["widget.click_to_focus"] = property["click_to_focus"] = bool_caller<fltk::Widget, &fltk::Widget::set_click_to_focus, &fltk::Widget::clear_click_to_focus>;
00259         property["widget.output"] = property["output"] = bool_caller<fltk::Widget, &fltk::Widget::set_output, &fltk::Widget::clear_output>;
00260         property["widget.selected"] = property["selected"] = bool_caller<fltk::Widget, &fltk::Widget::set_selected, &fltk::Widget::clear_selected>;
00261         property["widget.tab_to_focus"] = property["tab_to_focus"] = bool_caller<fltk::Widget, &fltk::Widget::set_tab_to_focus, &fltk::Widget::clear_tab_to_focus>;
00262         property["widget.value"] = property["value"] = bool_caller<fltk::Widget, &fltk::Widget::set_value, &fltk::Widget::clear_value>;
00263         property["widget.visible"] = property["visible"] = bool_caller<fltk::Widget, &fltk::Widget::set_visible, &fltk::Widget::clear_visible>;
00264         property["widget.style"] = property["style"] = set_style;
00265         property["widget.image"] = property["image"] = symbol_caller<fltk::Widget, &fltk::Widget::image>;
00266         property["widget.tooltip"] = property["tooltip"] = string_caller<fltk::Widget, &fltk::Widget::tooltip>;
00267         //TODO ? when
00268         //TODO ? take_focus
00269         //TODO cursor
00270         //TODO ? measure_label
00271         //TODO glyph
00272         property["widget.labelfont"] = property["labelfont"] = font_caller<fltk::Widget, &fltk::Widget::labelfont>;
00273         property["widget.textfont"] = property["textfont"] = font_caller<fltk::Widget, &fltk::Widget::textfont>;
00274         //TODO position 
00275         //TODO resize(w, h) resize(x, y, w, h) (-> size)
00276         property["widget.labeltype"] = property["labeltype"] = set_labeltype;
00277         property["widget.color"] = property["color"] = color_caller<fltk::Widget, &fltk::Widget::color>;
00278         property["widget.textcolor"] = property["textcolor"] = color_caller<fltk::Widget, &fltk::Widget::textcolor>;
00279         property["widget.selection_color"] = property["selection_color"] = color_caller<fltk::Widget, &fltk::Widget::selection_color>;
00280         property["widget.selection_textcolor"] = property["selection_textcolor"] = color_caller<fltk::Widget, &fltk::Widget::selection_textcolor>;
00281         property["widget.buttoncolor"] = property["buttoncolor"] = color_caller<fltk::Widget, &fltk::Widget::buttoncolor>;
00282         property["widget.labelcolor"] = property["labelcolor"] = color_caller<fltk::Widget, &fltk::Widget::labelcolor>;
00283         property["widget.highlight_color"] = property["highlight_color"] = color_caller<fltk::Widget, &fltk::Widget::highlight_color>;
00284         property["widget.highlight_textcolor"] = property["highlight_textcolor"] = color_caller<fltk::Widget, &fltk::Widget::highlight_textcolor>;
00285         property["widget.labelsize"] = property["labelsize"] = cast_caller<fltk::Widget, float, &fltk::Widget::labelsize>;
00286         property["widget.textsize"] = property["textsize"] = cast_caller<fltk::Widget, float, &fltk::Widget::textsize>;
00287         property["widget.leading"] = property["leading"] = cast_caller<fltk::Widget, float, &fltk::Widget::leading>;
00288         //TODO scrollbar_align
00289         property["widget.scrollbar_width"] = property["scrollbar_width"] = cast_cast_caller<fltk::Widget, unsigned, unsigned char, &fltk::Widget::scrollbar_width>;
00290         property["widget.vertical"] = property["vertical"] = bool_caller<fltk::Widget, &fltk::Widget::set_vertical, &fltk::Widget::set_horizontal>;
00291         property["widget.horizontal"] = property["horizontal"] = bool_caller<fltk::Widget, &fltk::Widget::set_horizontal, &fltk::Widget::set_vertical>;
00292         //TODO shortcut
00293         property["widget.label"] = property["label"] = string_caller<fltk::Widget, &fltk::Widget::copy_label>;
00294 }
00295 
00296 //----------========== fltk::Button ==========----------//
00297 
00298 static struct FactoryButton: public HierarhyWidgetFactory {
00299         
00300         FactoryButton();
00301         
00302         WidgetCreator* getCreator(GUI& gui) { return new HierarhyWidgetCreator<fltk::Button>(gui, *this); };
00303         
00304 } factory_fltk_button;
00305 
00306 
00307 FactoryButton::FactoryButton(): HierarhyWidgetFactory("button", &factory_fltk_widget) {
00308         widget_property_setters_map& property = getWidgetPropertySetters();
00309         property["button.set"] = property["set"] = bool_caller<fltk::Button, &fltk::Button::set, &fltk::Button::clear>;
00310         property["button.value"] = property["value"] = cast_caller<fltk::Button, bool, &fltk::Button::value>;
00311 }
00312 
00313 // TODO ? fltk::BButton
00314 
00315 //----------========== fltk::CheckButton ==========----------//
00316 
00317 static struct CheckButtonFactory: public HierarhyWidgetFactory {
00318         
00319         CheckButtonFactory(): HierarhyWidgetFactory("checkButton", &factory_fltk_button) {}
00320         
00321         virtual WidgetCreator* getCreator(GUI& gui) {
00322                 return new HierarhyWidgetCreator<fltk::CheckButton>(gui, *this);
00323         }
00324         
00325 } factory_fltk_checkButton;
00326 
00327 //----------========== fltk::LightButton ==========----------//
00328 
00329 static struct LightButtonFactory: public HierarhyWidgetFactory {
00330         
00331         LightButtonFactory(): HierarhyWidgetFactory("lightButton", &factory_fltk_checkButton) {}
00332         
00333         virtual WidgetCreator* getCreator(GUI& gui) {
00334                 return new HierarhyWidgetCreator<fltk::LightButton>(gui, *this);
00335         }
00336         
00337 } factory_fltk_lightButton;
00338 
00339 
00340 //----------========== fltk::RadioLightButton ==========----------//
00341 
00342 static struct RadioLightButtonFactory: public HierarhyWidgetFactory {
00343         
00344         RadioLightButtonFactory(): HierarhyWidgetFactory("radioLightButton", &factory_fltk_lightButton) {}
00345         
00346         virtual WidgetCreator* getCreator(GUI& gui) {
00347                 return new HierarhyWidgetCreator<fltk::RadioLightButton>(gui, *this);
00348         }
00349         
00350 } factory_fltk_radioLightButton;
00351 
00352 //----------========== fltk::HighlightButton ==========----------//
00353 
00354 static struct HighlightButtonFactory: public HierarhyWidgetFactory {
00355         
00356         HighlightButtonFactory(): HierarhyWidgetFactory("highlightButton", &factory_fltk_button) {}
00357         
00358         virtual WidgetCreator* getCreator(GUI& gui) {
00359                 return new HierarhyWidgetCreator<fltk::HighlightButton>(gui, *this);
00360         }
00361         
00362 } factory_fltk_highlightButton;
00363 
00364 
00365 //----------========== fltk::RepeatButton ==========----------//
00366 
00367 static struct RepeatButtonFactory: public HierarhyWidgetFactory {
00368         
00369         RepeatButtonFactory(): HierarhyWidgetFactory("repeatButton", &factory_fltk_button) {}
00370         
00371         virtual WidgetCreator* getCreator(GUI& gui) {
00372                 return new HierarhyWidgetCreator<fltk::RepeatButton>(gui, *this);
00373         }
00374         
00375 } factory_fltk_repeatButton;
00376 
00377 //----------========== fltk::ReturnButton ==========----------//
00378 
00379 static struct ReturnButtonFactory: public HierarhyWidgetFactory {
00380         
00381         ReturnButtonFactory(): HierarhyWidgetFactory("returnButton", &factory_fltk_button) {}
00382         
00383         virtual WidgetCreator* getCreator(GUI& gui) {
00384                 return new HierarhyWidgetCreator<fltk::ReturnButton>(gui, *this);
00385         }
00386         
00387 } factory_fltk_returnButton;
00388 
00389 //----------========== fltk::ToggleButton ==========----------//
00390 
00391 static struct ToggleButtonFactory: public HierarhyWidgetFactory {
00392         
00393         ToggleButtonFactory(): HierarhyWidgetFactory("toggleButton", &factory_fltk_button) {}
00394         
00395         virtual WidgetCreator* getCreator(GUI& gui) {
00396                 return new HierarhyWidgetCreator<fltk::ToggleButton>(gui, *this);
00397         }
00398         
00399 } factory_fltk_toggleButton;
00400 
00401 //----------========== fltk::ClockOutput ==========----------//
00402 
00403 static struct ClockOutputFactory: public HierarhyWidgetFactory {
00404         
00405         ClockOutputFactory(): HierarhyWidgetFactory("clockOutput", &factory_fltk_widget) {
00406                 getWidgetPropertySetters()["clockOutput.value"] = getWidgetPropertySetters()["value"] = cast_caller<fltk::ClockOutput, time_t, &fltk::ClockOutput::value>;
00407                 //TODO value (int, int, int)
00408                 //TODO type (enum)
00409         }
00410 
00411         virtual WidgetCreator* getCreator(GUI& gui) {
00412                 return new HierarhyWidgetCreator<fltk::ClockOutput>(gui, *this);
00413         }
00414 
00415 } factory_fltk_clockOutput;
00416 
00417 //----------========== fltk::Clock ==========----------//
00418 
00419 static struct ClockFactory: public HierarhyWidgetFactory {
00420         
00421         ClockFactory(): HierarhyWidgetFactory("clock", &factory_fltk_clockOutput) {}
00422         
00423         virtual WidgetCreator* getCreator(GUI& gui) {
00424                 return new HierarhyWidgetCreator<fltk::Clock>(gui, *this);
00425         }       
00426         
00427 } factory_fltk_clock;
00428 
00429 //----------========== fltk::Divider ==========----------//
00430 
00431 static struct DividerFactory: public HierarhyWidgetFactory {
00432         
00433         DividerFactory(): HierarhyWidgetFactory("divider", &factory_fltk_widget) {}
00434         
00435         virtual WidgetCreator* getCreator(GUI& gui) {
00436                 return new HierarhyWidgetCreator0<fltk::Divider>(gui, *this);
00437         }
00438         
00439 } factory_fltk_divider;
00440 
00441 //----------========== fltk::Input ==========----------//
00442 
00443 static struct InputFactory: public HierarhyWidgetFactory {
00444                 
00445         InputFactory(): HierarhyWidgetFactory("input", &factory_fltk_widget) {
00446                 //TODO all properties
00447         }
00448         
00449         virtual WidgetCreator* getCreator(GUI& gui) {
00450                 return new HierarhyWidgetCreator<fltk::Input>(gui, *this);
00451         }
00452         
00453 } factory_fltk_input;
00454 
00455 //----------========== fltk::NumericInput ==========----------//
00456 
00457 static struct NumericInputFactory: public HierarhyWidgetFactory {
00458         
00459         NumericInputFactory(): HierarhyWidgetFactory("numericInput", &factory_fltk_input) {
00460                 //TODO all properties
00461         }
00462         
00463         virtual WidgetCreator* getCreator(GUI& gui) {
00464                 return new HierarhyWidgetCreator<fltk::NumericInput>(gui, *this);
00465         }
00466         
00467 } factory_fltk_numericInput;
00468 
00469 //----------========== fltk::FloatInput ==========----------//
00470 
00471 static struct FloatInputFactory: public HierarhyWidgetFactory {
00472         
00473         FloatInputFactory(): HierarhyWidgetFactory("floatInput", &factory_fltk_numericInput) {
00474                 //TODO all properties
00475         }
00476         
00477         virtual WidgetCreator* getCreator(GUI& gui) {
00478                 return new HierarhyWidgetCreator<fltk::FloatInput>(gui, *this);
00479         }
00480         
00481 } factory_fltk_floatInput;
00482 
00483 //----------========== fltk::IntInput ==========----------//
00484 
00485 static struct IntInputFactory: public HierarhyWidgetFactory {
00486         
00487         IntInputFactory(): HierarhyWidgetFactory("intInput", &factory_fltk_floatInput) {}
00488         
00489         virtual WidgetCreator* getCreator(GUI& gui) {
00490                 return new HierarhyWidgetCreator<fltk::IntInput>(gui, *this);
00491         }
00492         
00493 } factory_fltk_intInput;
00494 
00495 //----------========== fltk::Output ==========----------//
00496 
00497 static struct OutputFactory: public HierarhyWidgetFactory {
00498         
00499         OutputFactory(): HierarhyWidgetFactory("output", &factory_fltk_input) {}
00500         
00501         virtual WidgetCreator* getCreator(GUI& gui) {
00502                 return new HierarhyWidgetCreator<fltk::Output>(gui, *this);
00503         }
00504         
00505 } factory_fltk_output;
00506 
00507 //----------========== fltk::MultiLineOutput ==========----------//
00508 
00509 static struct MultiLineOutputFactory: public HierarhyWidgetFactory {
00510         
00511         MultiLineOutputFactory(): HierarhyWidgetFactory("multiLineOutput", &factory_fltk_output) {}
00512         
00513         virtual WidgetCreator* getCreator(GUI& gui) {
00514                 return new HierarhyWidgetCreator<fltk::MultiLineOutput>(gui, *this);
00515         }
00516         
00517 } factory_fltk_multiLineOutput;
00518 
00519 //----------========== fltk::WordwrapOutput ==========----------//
00520 
00521 static struct WordwrapOutputFactory: public HierarhyWidgetFactory {
00522         
00523         WordwrapOutputFactory(): HierarhyWidgetFactory("wordwrapOutput", &factory_fltk_output) {}
00524         
00525         virtual WidgetCreator* getCreator(GUI& gui) {
00526                 return new HierarhyWidgetCreator<fltk::WordwrapOutput>(gui, *this);
00527         }
00528         
00529 } factory_fltk_wordwrapOutput;
00530 
00531 //----------========== fltk::InvisibleBox ==========----------//
00532 
00533 static struct InvisibleBoxFactory: public HierarhyWidgetFactory {
00534         
00535         InvisibleBoxFactory(): HierarhyWidgetFactory("invisibleBox", &factory_fltk_widget) {}
00536         
00537         virtual WidgetCreator* getCreator(GUI& gui) {
00538                 return new HierarhyWidgetCreator<fltk::InvisibleBox>(gui, *this);
00539         }
00540         
00541 } factory_fltk_invisibleBox;
00542 
00543 //----------========== fltk::Item ==========----------//
00544 
00545 static struct ItemFactory: public HierarhyWidgetFactory {
00546         
00547         ItemFactory(): HierarhyWidgetFactory("item", &factory_fltk_widget) {
00548                 //TODO type
00549                 //TODO set_style
00550         }
00551         
00552         virtual WidgetCreator* getCreator(GUI& gui) {
00553                 return new HierarhyWidgetCreator0<fltk::Item>(gui, *this);
00554         }
00555         
00556 } factory_fltk_item;
00557 
00558 //----------========== TODO fltk::RadioItem ?? ==========----------//
00559 
00560 //----------========== fltk::Valuator ==========----------//
00561 
00562 static struct ValuatorFactory: public HierarhyWidgetFactory {
00563         
00564         ValuatorFactory(): HierarhyWidgetFactory(0, &factory_fltk_widget) {
00565                 //TODO property set
00566         }
00567         
00568         virtual WidgetCreator* getCreator(GUI& gui) {
00569                 //schould never called
00570                 return 0;
00571         }
00572         
00573 } factory_fltk_valuator;
00574 
00575 //----------========== fltk::Adjuster ==========----------//
00576 
00577 static struct AdjusterFactory: public HierarhyWidgetFactory {
00578         
00579         AdjusterFactory(): HierarhyWidgetFactory("adjuster", &factory_fltk_valuator) {
00580                 getWidgetPropertySetters()["adjuster.soft"] = getWidgetPropertySetters()["soft"] = cast_caller<fltk::Adjuster, int, &fltk::Adjuster::soft>;
00581         }
00582         
00583         virtual WidgetCreator* getCreator(GUI& gui) {
00584                 return new HierarhyWidgetCreator<fltk::Adjuster>(gui, *this);
00585         }
00586         
00587 } factory_fltk_adjuster;        //Depreciated!
00588 
00589 //----------========== fltk::Dial ==========----------//
00590 
00591 static struct DialFactory: public HierarhyWidgetFactory {
00592         
00593         DialFactory(): HierarhyWidgetFactory("dial", &factory_fltk_valuator) {
00594                 getWidgetPropertySetters()["dial.angle1"] = getWidgetPropertySetters()["angle1"] = cast_caller<fltk::Dial, short, &fltk::Dial::angle1>;
00595                 getWidgetPropertySetters()["dial.angle2"] = getWidgetPropertySetters()["angle1"] = cast_caller<fltk::Dial, short, &fltk::Dial::angle2>;
00596                 //TODO ? angels
00597                 //TODO type
00598         }
00599         
00600         virtual WidgetCreator* getCreator(GUI& gui) {
00601                 return new HierarhyWidgetCreator<fltk::Dial>(gui, *this);
00602         }
00603         
00604 } factory_fltk_dial;
00605 
00606 //----------========== fltk::FillDial ==========----------//
00607 
00608 static struct FillDialFactory: public HierarhyWidgetFactory {
00609         
00610         FillDialFactory(): HierarhyWidgetFactory("fillDial", &factory_fltk_dial) {}
00611         
00612         virtual WidgetCreator* getCreator(GUI& gui) {
00613                 return new HierarhyWidgetCreator<fltk::FillDial>(gui, *this);
00614         }
00615         
00616 } factory_fltk_fillDial;
00617 
00618 //----------========== fltk::LineDial  ==========----------//
00619 
00620 static struct LineDialFactory: public HierarhyWidgetFactory {
00621         
00622         LineDialFactory(): HierarhyWidgetFactory("lineDial", &factory_fltk_dial) {}
00623         
00624         virtual WidgetCreator* getCreator(GUI& gui) {
00625                 return new HierarhyWidgetCreator<fltk::LineDial>(gui, *this);
00626         }
00627         
00628 } factory_fltk_lineDial;
00629 
00630 //----------========== fltk::Slider ==========----------//
00631 
00632 static struct SliderFactory: public HierarhyWidgetFactory {
00633         
00634         SliderFactory(): HierarhyWidgetFactory("slider", &factory_fltk_valuator) {
00635                 //TODO ? type
00636                 getWidgetPropertySetters()["slider.slider_size"] = getWidgetPropertySetters()["slider_size"] = cast_caller<fltk::Slider, int, &fltk::Slider::slider_size>;
00637                 getWidgetPropertySetters()["slider.tick_size"] = getWidgetPropertySetters()["tick_size"] = cast_caller<fltk::Slider, int, &fltk::Slider::tick_size>;
00638         }
00639         
00640         virtual WidgetCreator* getCreator(GUI& gui) {
00641                 return new HierarhyWidgetCreator<fltk::Slider>(gui, *this);
00642         }
00643         
00644 } factory_fltk_slider;
00645 
00646 //----------========== fltk::FillSlider ==========----------//
00647 
00648 static struct FillSliderFactory: public HierarhyWidgetFactory {
00649         
00650         FillSliderFactory(): HierarhyWidgetFactory("fillSlider", &factory_fltk_slider) {}
00651         
00652         virtual WidgetCreator* getCreator(GUI& gui) {
00653                 return new HierarhyWidgetCreator<fltk::FillSlider>(gui, *this);
00654         }
00655         
00656 } factory_fltk_fillSlider;
00657 
00658 //----------========== fltk::Scrollbar ==========----------//
00659 
00660 static struct ScrollbarFactory: public HierarhyWidgetFactory {
00661         
00662         ScrollbarFactory(): HierarhyWidgetFactory("scrollbar", &factory_fltk_slider) {
00663                 getWidgetPropertySetters()["scrollbar.pagesize"] = getWidgetPropertySetters()["scrollbar"] = cast_caller<fltk::Scrollbar, int, &fltk::Scrollbar::pagesize>;             
00664         }
00665         
00666         virtual WidgetCreator* getCreator(GUI& gui) {
00667                 return new HierarhyWidgetCreator<fltk::Scrollbar>(gui, *this);
00668         }
00669         
00670 } factory_fltk_scrollbar;
00671 
00672 //----------========== fltk::ValueSlider ==========----------//
00673 
00674 static struct ValueSliderFactory: public HierarhyWidgetFactory {
00675         
00676         ValueSliderFactory(): HierarhyWidgetFactory("valueSlider", &factory_fltk_slider) {
00677                 //TODO input (do new creator and factory and use factory_fltk_floatInput)
00678                 //"input.*"
00679         }
00680         
00681         virtual WidgetCreator* getCreator(GUI& gui) {
00682                 return new HierarhyWidgetCreator<fltk::ValueSlider>(gui, *this);
00683         }
00684         
00685 } factory_fltk_valueSlider;
00686 
00687 //----------========== fltk::ThumbWheel ==========----------//
00688 
00689 static struct ThumbWheelFactory: public HierarhyWidgetFactory {
00690         
00691         ThumbWheelFactory(): HierarhyWidgetFactory("thumbWheel", &factory_fltk_valuator) {}
00692         
00693         virtual WidgetCreator* getCreator(GUI& gui) {
00694                 return new HierarhyWidgetCreator<fltk::ThumbWheel>(gui, *this);
00695         }
00696         
00697 } factory_fltk_thumbWheel;
00698 
00699 //----------========== fltk::ValueInput ==========----------//
00700 
00701 static struct ValueInputFactory: public HierarhyWidgetFactory {
00702         
00703         ValueInputFactory(): HierarhyWidgetFactory("valueInput", &factory_fltk_valuator) {
00704                 //TODO input (do new creator and factory and use factory_fltk_floatInput)
00705                 //"input.*"
00706         }
00707         
00708         virtual WidgetCreator* getCreator(GUI& gui) {
00709                 return new HierarhyWidgetCreator<fltk::ValueInput>(gui, *this);
00710         }
00711         
00712 } factory_fltk_valueInput;
00713 
00714 //----------========== fltk::ValueOutput ==========----------//
00715 
00716 static struct ValueOutputFactory: public HierarhyWidgetFactory {
00717         
00718         ValueOutputFactory(): HierarhyWidgetFactory("valueOutput", &factory_fltk_valuator) {}
00719         
00720         virtual WidgetCreator* getCreator(GUI& gui) {
00721                 return new HierarhyWidgetCreator<fltk::ValueOutput>(gui, *this);
00722         }
00723         
00724 } factory_fltk_valueOutput;
00725 
00726 //----------========== fltk::Group ==========----------//
00727 
00728 class GroupWidgetCreatorBase: public WidgetCreator {
00729         
00730         protected:
00731         
00732         HierarhyWidgetFactory& factory;
00733         
00734         fltk::Group* g;
00735         
00736         public:
00737         
00738         const char* resizable_name;
00739 
00740         virtual fltk::Group* new_widget() {
00741                 return new fltk::Group(0, 0, 0, 0);
00742         }
00743         
00744         GroupWidgetCreatorBase(GUI& gui, HierarhyWidgetFactory& factory): WidgetCreator(gui), factory(factory), resizable_name(0) {}
00745         
00746         virtual fltk::Widget* create_begin(const char** attr) {
00747                 g = new_widget();
00748                 factory.setProperties(g, attr, *this);
00749                 g->begin();
00750                 return g;
00751         }
00752         
00753         virtual void create_end() {
00754                 fltk::Group::current(fltk::Group::current()->parent());
00755                 if (resizable_name)     //TODO error check, resizable_name exist?
00756                         g->resizable(gui()[resizable_name]);
00757         };
00758         
00759         virtual ~GroupWidgetCreatorBase() {
00760                 delete[] resizable_name;
00761         }
00762         
00763 };
00764 
00765 template <typename fltkGroup>
00766 struct GroupWidgetCreator: public GroupWidgetCreatorBase {
00767         
00768         GroupWidgetCreator(GUI& gui, HierarhyWidgetFactory& factory): GroupWidgetCreatorBase(gui, factory) {}
00769         
00770         virtual fltk::Group* new_widget() {
00771                 return new fltkGroup(0, 0, 0, 0);
00772         }
00773 };
00774 
00775 template <typename fltkGroup>
00776 struct GroupWidgetCreator0: public GroupWidgetCreatorBase {
00777         
00778         GroupWidgetCreator0(GUI& gui, HierarhyWidgetFactory& factory): GroupWidgetCreatorBase(gui, factory) {}
00779         
00780         virtual fltk::Group* new_widget() {
00781                 return new fltkGroup();
00782         }
00783 };
00784 
00785 void resizable(fltk::Widget* obj, const char* value, WidgetCreator& creator) {
00786         GroupWidgetCreatorBase& c = dynamic_cast<GroupWidgetCreatorBase&>(creator);
00787         delete[] c.resizable_name;
00788         c.resizable_name = utils::strcopy(value);
00789 }
00790 
00791 static struct FactoryGroup: public HierarhyWidgetFactory {
00792         
00793         FactoryGroup(): HierarhyWidgetFactory("group", &factory_fltk_widget) {
00794                 getWidgetPropertySetters()["group.resizable"] = getWidgetPropertySetters()["resizable"] = resizable;
00795         }
00796         
00797         WidgetCreator* getCreator(GUI& gui) { return new GroupWidgetCreatorBase(gui, *this); };
00798         
00799 } factory_fltk_group;
00800 
00801 //----------========== fltk::Menu ==========----------//
00802 
00803 static struct FactoryMenu: public HierarhyWidgetFactory {
00804         
00805         FactoryMenu(): HierarhyWidgetFactory("menu", &factory_fltk_group) {
00806                 //TODO all properties
00807         }
00808         
00809         WidgetCreator* getCreator(GUI& gui) { return new GroupWidgetCreator<fltk::Menu>(gui, *this); };
00810         
00811 } factory_fltk_menu;
00812 
00813 //----------========== fltk::Browser ==========----------//
00814 
00815 static struct FactoryBrowser: public HierarhyWidgetFactory {
00816         
00817         FactoryBrowser(): HierarhyWidgetFactory("browser", &factory_fltk_menu) {
00818                 //TODO all properties
00819         }
00820         
00821         WidgetCreator* getCreator(GUI& gui) { return new GroupWidgetCreator<fltk::Browser>(gui, *this); };
00822         
00823 } factory_fltk_browser;
00824 
00825 //----------========== fltk::MultiBrowser ==========----------//
00826 
00827 static struct FactoryMultiBrowser: public HierarhyWidgetFactory {
00828         
00829         FactoryMultiBrowser(): HierarhyWidgetFactory("multiBrowser", &factory_fltk_browser) {}
00830         
00831         WidgetCreator* getCreator(GUI& gui) { return new GroupWidgetCreator<fltk::MultiBrowser>(gui, *this); };
00832         
00833 } factory_fltk_multiBrowser;
00834 
00835 //----------========== fltk::Choice ==========----------//
00836 
00837 static struct FactoryChoice: public HierarhyWidgetFactory {
00838         
00839         FactoryChoice(): HierarhyWidgetFactory("choice", &factory_fltk_menu) {}
00840         
00841         WidgetCreator* getCreator(GUI& gui) { return new GroupWidgetCreator<fltk::Choice>(gui, *this); };
00842         
00843 } factory_fltk_choice;
00844 
00845 //----------========== fltk::CycleButton ==========----------//
00846 
00847 static struct FactoryCycleButton: public HierarhyWidgetFactory {
00848         
00849         FactoryCycleButton(): HierarhyWidgetFactory("cycleButton", &factory_fltk_menu) {}
00850         
00851         WidgetCreator* getCreator(GUI& gui) { return new GroupWidgetCreator<fltk::CycleButton>(gui, *this); };
00852         
00853 } factory_fltk_cycleButton;
00854 
00855 //----------========== fltk::InputBrowser ?? ==========----------//
00856 
00857 //----------========== fltk::ItemGroup ==========----------//
00858 
00859 static struct FactoryItemGroup: public HierarhyWidgetFactory {
00860         
00861         FactoryItemGroup(): HierarhyWidgetFactory("itemGroup", &factory_fltk_menu) {
00862                 //TODO all properties
00863         }
00864         
00865         WidgetCreator* getCreator(GUI& gui) { return new GroupWidgetCreator0<fltk::ItemGroup>(gui, *this); };
00866         
00867 } factory_fltk_itemGroup;
00868 
00869 //----------========== fltk::MenuBar ==========----------//
00870 
00871 static struct FactoryMenuBar: public HierarhyWidgetFactory {
00872         
00873         FactoryMenuBar(): HierarhyWidgetFactory("menuBar", &factory_fltk_menu) {
00874                 //TODO all properties
00875         }
00876         
00877         WidgetCreator* getCreator(GUI& gui) { return new GroupWidgetCreator<fltk::MenuBar>(gui, *this); };
00878         
00879 } factory_fltk_menuBar;
00880 
00881 //----------========== fltk::PopupMenu ==========----------//
00882 
00883 static struct FactoryPopupMenu: public HierarhyWidgetFactory {
00884         
00885         FactoryPopupMenu(): HierarhyWidgetFactory("popupMenu", &factory_fltk_menu) {
00886                 //TODO type
00887         }
00888         
00889         WidgetCreator* getCreator(GUI& gui) { return new GroupWidgetCreator<fltk::PopupMenu>(gui, *this); };
00890         
00891 } factory_fltk_popupMenu;
00892 
00893 //----------========== fltk::PacketGroup ==========----------//
00894 
00895 static struct FactoryPackedGroup: public HierarhyWidgetFactory {
00896         
00897         FactoryPackedGroup(): HierarhyWidgetFactory("packedGroup", &factory_fltk_group) {
00898                 //TODO type
00899                 getWidgetPropertySetters()["packedGroup.spacing"] = getWidgetPropertySetters()["spacing"] = cast_caller<fltk::PackedGroup, int, &fltk::PackedGroup::spacing>;
00900         }
00901         
00902         WidgetCreator* getCreator(GUI& gui) { return new GroupWidgetCreator<fltk::PackedGroup>(gui, *this); };
00903         
00904 } factory_fltk_packedGroup;
00905 
00906 //----------========== fltk::ScrollGroup ==========----------//
00907 
00908 static struct FactoryScrollGroup: public HierarhyWidgetFactory {
00909         
00910         FactoryScrollGroup(): HierarhyWidgetFactory("scrollGroup", &factory_fltk_group) {
00911                 //TODO all properties
00912         }
00913         
00914         WidgetCreator* getCreator(GUI& gui) { return new GroupWidgetCreator<fltk::ScrollGroup>(gui, *this); };
00915         
00916 } factory_fltk_scrollGroup;
00917 
00918 //----------========== fltk::TabGroup ==========----------//
00919 
00920 static struct FactoryTabGroup: public HierarhyWidgetFactory {
00921         
00922         FactoryTabGroup(): HierarhyWidgetFactory("tabGroup", &factory_fltk_group) {
00923                 //TODO all properties
00924         }
00925         
00926         WidgetCreator* getCreator(GUI& gui) { return new GroupWidgetCreator<fltk::TabGroup>(gui, *this); };
00927         
00928 } factory_fltk_tabGroup;
00929 
00930 //----------========== fltk::Window ==========----------//
00931 
00932 struct WindowCreator: public GroupWidgetCreatorBase {
00933         
00934         WindowCreator(GUI& gui, HierarhyWidgetFactory& factory): GroupWidgetCreatorBase(gui, factory) {}
00935         
00936         virtual fltk::Group* new_widget() {
00937                 return new fltk::Window(0, 0);
00938         }
00939 };
00940 
00941 struct FactoryWindow: public HierarhyWidgetFactory {
00942         
00943         FactoryWindow(): HierarhyWidgetFactory("window", &factory_fltk_group) {};
00944         
00945         WidgetCreator* getCreator(GUI& gui) { return new WindowCreator(gui, *this); };
00946         
00947 } factory_fltk_window;
00948 
00949 //----------========== fltk::MenuWindow ?? ==========----------//
00950 
00951 //----------========== fltk::Tooltip ?? ==========----------//
00952 
00953 //----------========== fltk::ShapedWindow ==========----------//
00954 
00955 static struct FactoryShapedWindow: public HierarhyWidgetFactory {
00956         
00957         FactoryShapedWindow(): HierarhyWidgetFactory("shapedWindow", &factory_fltk_window) {};
00958         
00959         WidgetCreator* getCreator(GUI& gui) { return new WindowCreator(gui, *this); };
00960         
00961 } factory_fltk_shapedWindow;
00962 
00963 
00964 
00965 } //namespace xfltk

Generated on Tue Jan 3 14:32:37 2006 for xfltk by  doxygen 1.4.6-NO