00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2011 by the OpenStructure authors 00005 // 00006 // This library is free software; you can redistribute it and/or modify it under 00007 // the terms of the GNU Lesser General Public License as published by the Free 00008 // Software Foundation; either version 3.0 of the License, or (at your option) 00009 // any later version. 00010 // This library is distributed in the hope that it will be useful, but WITHOUT 00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00013 // details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, Inc., 00017 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 //------------------------------------------------------------------------------ 00019 #ifndef OST_GUI_TOOL_OPTIONS_WIDGET_HH 00020 #define OST_GUI_TOOL_OPTIONS_WIDGET_HH 00021 00022 /* 00023 Author: Marco Biasini 00024 */ 00025 00026 #include <ost/gui/module_config.hh> 00027 00028 #include <ost/gui/tools/tool_options.hh> 00029 00030 #include <QWidget> 00031 00032 namespace ost { namespace gui { 00033 00034 class DLLEXPORT_OST_GUI EnumOptBinder : public QObject { 00035 Q_OBJECT 00036 public: 00037 EnumOptBinder() {} 00038 EnumOptBinder(QObject* parent, ToolOptionEnum* enum_opt): 00039 QObject(parent), enum_opt_(enum_opt) 00040 { } 00041 public slots: 00042 void IndexChanged(int index) 00043 { 00044 enum_opt_->SetIndex(index); 00045 } 00046 private: 00047 ToolOptionEnum* enum_opt_; 00048 }; 00049 00050 class DLLEXPORT_OST_GUI IntOptBinder : public QObject { 00051 Q_OBJECT 00052 public: 00053 IntOptBinder() {} 00054 IntOptBinder(QObject* parent, ToolOptionInt* int_opt): 00055 QObject(parent), int_opt_(int_opt) 00056 { } 00057 public slots: 00058 void TextChanged(const QString& text) 00059 { 00060 int_opt_->SetValue(text.toInt()); 00061 } 00062 private: 00063 ToolOptionInt* int_opt_; 00064 }; 00065 00066 class DLLEXPORT_OST_GUI FloatOptBinder : public QObject { 00067 Q_OBJECT 00068 public: 00069 FloatOptBinder() {} 00070 FloatOptBinder(QObject* parent, ToolOptionFloat* float_opt): 00071 QObject(parent), float_opt_(float_opt) 00072 { } 00073 public slots: 00074 void TextChanged(const QString& text) 00075 { 00076 float_opt_->SetValue(text.toFloat()); 00077 } 00078 private: 00079 ToolOptionFloat* float_opt_; 00080 }; 00081 00082 class DLLEXPORT_OST_GUI ToolOptionsWidget : public QWidget { 00083 public: 00084 ToolOptionsWidget(ToolOptions* options, QWidget* parent=NULL); 00085 private: 00086 void Populate(); 00087 QWidget* MakeIntWidget(ToolOptionInt* opts); 00088 QWidget* MakeEnumWidget(ToolOptionEnum* opts); 00089 QWidget* MakeFloatWidget(ToolOptionFloat* opts); 00090 QWidget* MakeButtonWidget(ToolOptionButton* opts); 00091 ToolOptions* options_; 00092 }; 00093 00094 }} 00095 00096 #endif