Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLQt/src/ICLQt/GUIWidget.h ** 00010 ** Module : ICLQt ** 00011 ** Authors: Christof Elbrechter ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 00033 #include <QWidget> 00034 #include <ICLUtils/Size.h> 00035 #include <ICLQt/GUI.h> 00036 #include <ICLUtils/Uncopyable.h> 00037 00039 class QGridLayout; 00040 class QLayout; 00044 namespace icl{ 00045 namespace qt{ 00047 class GUIDefinition; 00048 class ProxyLayout; 00051 00052 class ICLQt_API GUIWidget : public QWidget, public utils::Uncopyable{ 00053 Q_OBJECT; 00054 public: 00055 enum layoutType{ 00056 noLayout, // do not call setLayout(..) 00057 hboxLayout, // use a QHBoxLayout 00058 vboxLayout, // use a QVBoxLayout 00059 gridLayout // use the default GridLayout 00060 }; 00061 00063 00069 GUIWidget(const GUIDefinition &def, 00070 int minParamCount, 00071 int maxParamCount=-1, 00072 layoutType lt=gridLayout, 00073 const utils::Size &defMinSize=utils::Size(0,0)); 00074 00075 00077 virtual ~GUIWidget(); 00078 00079 public slots: 00081 00084 void ioSlot(); 00085 00087 00088 void addToGrid(QWidget *c, int x = 0, int y = 0, int width = 1, int height = 1); 00089 00091 virtual void processIO(){} 00092 00094 virtual QLayout *getGUIWidgetLayout() { return m_poGridLayout ? (QLayout*)m_poGridLayout : m_poOtherLayout; } 00095 00097 virtual ProxyLayout *getProxyLayout() { return 0; } 00098 00100 GUI *getGUI(){ return m_poGUI; } 00101 00103 void registerCallback(const GUI::Callback &cb){ 00104 m_vecCallbacks.push_back(cb); 00105 } 00107 void registerCallback(const GUI::ComplexCallback &cb){ 00108 m_vecComplexCallbacks.push_back(cb); 00109 } 00111 void removeCallbacks(){ 00112 m_vecCallbacks.clear(); 00113 m_vecComplexCallbacks.clear(); 00114 } 00115 00117 00120 void cb(); 00121 00123 virtual QSize sizeHint() const; 00124 00125 private: 00127 QGridLayout *m_poGridLayout; 00128 QLayout *m_poOtherLayout; 00129 GUI *m_poGUI; 00130 std::string *m_handle; 00131 std::vector<GUI::Callback> m_vecCallbacks; 00132 std::vector<GUI::ComplexCallback> m_vecComplexCallbacks; 00133 utils::Size m_preferredSize; 00134 }; 00135 } // namespace qt 00136 }