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_TextBrowser: public Qt5_W_Widget { 15 public: Qt5_W_TextBrowser(GWEN_WIDGET * w)16 Qt5_W_TextBrowser(GWEN_WIDGET *w):Qt5_W_Widget(w) { 17 } 18 19 20 ~Qt5_W_TextBrowser()21 ~Qt5_W_TextBrowser() { 22 } 23 24 25 setup()26 virtual int setup() { 27 QTextBrowser *qw; 28 uint32_t flags; 29 GWEN_WIDGET *wParent; 30 QSizePolicy::Policy hpolicy=QSizePolicy::Minimum; 31 QSizePolicy::Policy vpolicy=QSizePolicy::Minimum; 32 const char *s; 33 QString text; 34 35 flags=GWEN_Widget_GetFlags(_widget); 36 wParent=GWEN_Widget_Tree_GetParent(_widget); 37 s=GWEN_Widget_GetText(_widget, 0); 38 if (s) 39 text=QString::fromUtf8(s); 40 41 qw=new QTextBrowser(); 42 qw->setText(text); 43 44 /* handle flags */ 45 if (flags & GWEN_WIDGET_FLAGS_FILLX) 46 hpolicy=QSizePolicy::Expanding; 47 if (flags & GWEN_WIDGET_FLAGS_FILLY) 48 vpolicy=QSizePolicy::Expanding; 49 qw->setSizePolicy(hpolicy, vpolicy); 50 51 GWEN_Widget_SetImplData(_widget, QT5_DIALOG_WIDGET_REAL, (void*) qw); 52 53 if (wParent) 54 GWEN_Widget_AddChildGuiWidget(wParent, _widget); 55 return 0; 56 } 57 58 59 setCharProperty(GWEN_DIALOG_PROPERTY prop,GWEN_UNUSED int index,const char * value,GWEN_UNUSED int doSignal)60 int setCharProperty(GWEN_DIALOG_PROPERTY prop, 61 GWEN_UNUSED int index, 62 const char *value, 63 GWEN_UNUSED int doSignal) { 64 QTextBrowser *qw; 65 QString text; 66 67 qw=(QTextBrowser*) GWEN_Widget_GetImplData(_widget, QT5_DIALOG_WIDGET_REAL); 68 assert(qw); 69 70 if (value) 71 text=QT5_Gui::extractHtml(value); 72 73 switch(prop) { 74 case GWEN_DialogProperty_Value: 75 qw->setText(""); 76 qw->append(text); 77 return 0; 78 79 case GWEN_DialogProperty_AddValue: 80 qw->append(text); 81 return 0; 82 83 case GWEN_DialogProperty_ClearValues: 84 qw->setText(""); 85 return 0; 86 87 default: 88 break; 89 } 90 91 DBG_WARN(GWEN_LOGDOMAIN, 92 "Function is not appropriate for this type of widget (%s)", 93 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget))); 94 return GWEN_ERROR_INVALID; 95 }; 96 97 98 99 }; 100 101 102 103 104 105 106 107