1 /*************************************************************************** 2 begin : Mon Feb 15 2010 3 copyright : (C) 2010 by Martin Preuss 4 email : martin@libchipcard.de 5 6 *************************************************************************** 7 * Please see toplevel file COPYING for license details * 8 ***************************************************************************/ 9 10 11 #include <gwen-gui-cpp/cppwidget.hpp> 12 13 14 class Qt5_W_SpinBox: public Qt5_W_Widget { 15 public: Qt5_W_SpinBox(GWEN_WIDGET * w)16 Qt5_W_SpinBox(GWEN_WIDGET *w):Qt5_W_Widget(w) { 17 } 18 19 20 ~Qt5_W_SpinBox()21 ~Qt5_W_SpinBox() { 22 } 23 24 25 setup()26 virtual int setup() { 27 QSpinBox *qw; 28 uint32_t flags; 29 GWEN_WIDGET *wParent; 30 QSizePolicy::Policy hpolicy=QSizePolicy::Minimum; 31 QSizePolicy::Policy vpolicy=QSizePolicy::Minimum; 32 QT5_GuiDialog *qtDialog; 33 34 flags=GWEN_Widget_GetFlags(_widget); 35 wParent=GWEN_Widget_Tree_GetParent(_widget); 36 37 qw=new QSpinBox(); 38 39 /* handle flags */ 40 if (flags & GWEN_WIDGET_FLAGS_FILLX) 41 hpolicy=QSizePolicy::Expanding; 42 if (flags & GWEN_WIDGET_FLAGS_FILLY) 43 vpolicy=QSizePolicy::Expanding; 44 qw->setSizePolicy(hpolicy, vpolicy); 45 46 GWEN_Widget_SetImplData(_widget, QT5_DIALOG_WIDGET_REAL, (void*) qw); 47 48 qtDialog=dynamic_cast<QT5_GuiDialog*>(getDialog()); 49 assert(qtDialog); 50 51 qw->connect(qw, SIGNAL(valueChanged(int)), 52 qtDialog->getMainWindow(), 53 SLOT(slotValueChanged())); 54 55 56 if (wParent) 57 GWEN_Widget_AddChildGuiWidget(wParent, _widget); 58 return 0; 59 } 60 61 62 setIntProperty(GWEN_DIALOG_PROPERTY prop,int index,int value,int doSignal)63 int setIntProperty(GWEN_DIALOG_PROPERTY prop, 64 int index, 65 int value, 66 int doSignal) { 67 QSpinBox *qw; 68 69 qw=(QSpinBox*) GWEN_Widget_GetImplData(_widget, QT5_DIALOG_WIDGET_REAL); 70 assert(qw); 71 72 switch(prop) { 73 case GWEN_DialogProperty_Value: 74 qw->setValue(value); 75 return 0; 76 77 case GWEN_DialogProperty_MinValue: 78 qw->setMinimum(value); 79 return 0; 80 81 case GWEN_DialogProperty_MaxValue: 82 qw->setMaximum(value); 83 return 0; 84 85 default: 86 return Qt5_W_Widget::setIntProperty(prop, index, value, doSignal); 87 } 88 }; 89 90 91 getIntProperty(GWEN_DIALOG_PROPERTY prop,int index,int defaultValue)92 int getIntProperty(GWEN_DIALOG_PROPERTY prop, 93 int index, 94 int defaultValue) { 95 QSpinBox *qw; 96 97 qw=(QSpinBox*) GWEN_Widget_GetImplData(_widget, QT5_DIALOG_WIDGET_REAL); 98 assert(qw); 99 100 switch(prop) { 101 case GWEN_DialogProperty_Value: 102 return qw->value(); 103 104 case GWEN_DialogProperty_MinValue: 105 return qw->minimum(); 106 107 case GWEN_DialogProperty_MaxValue: 108 return qw->maximum(); 109 110 default: 111 return Qt5_W_Widget::getIntProperty(prop, index, defaultValue); 112 } 113 }; 114 115 116 }; 117 118 119 120 121 122 123 124