gwenhywfar 4.0.3

w_textbrowser.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002     begin       : Mon Feb 15 2010
00003     copyright   : (C) 2010 by Martin Preuss
00004     email       : martin@libchipcard.de
00005 
00006  ***************************************************************************
00007  *          Please see toplevel file COPYING for license details           *
00008  ***************************************************************************/
00009 
00010 
00011 #include <gwen-gui-cpp/cppwidget.hpp>
00012 
00013 
00014 class Qt4_W_TextBrowser: public Qt4_W_Widget {
00015 public:
00016   Qt4_W_TextBrowser(GWEN_WIDGET *w):Qt4_W_Widget(w) {
00017   }
00018 
00019 
00020 
00021   ~Qt4_W_TextBrowser() {
00022   }
00023 
00024 
00025 
00026   virtual int setup() {
00027     QTextBrowser *qw;
00028     uint32_t flags;
00029     GWEN_WIDGET *wParent;
00030     QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
00031     QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
00032     const char *s;
00033     QString text;
00034 
00035     flags=GWEN_Widget_GetFlags(_widget);
00036     wParent=GWEN_Widget_Tree_GetParent(_widget);
00037     s=GWEN_Widget_GetText(_widget, 0);
00038     if (s)
00039       text=QString::fromUtf8(s);
00040 
00041     qw=new QTextBrowser();
00042     qw->setText(text);
00043 
00044     /* handle flags */
00045     if (flags & GWEN_WIDGET_FLAGS_FILLX)
00046       hpolicy=QSizePolicy::Expanding;
00047     if (flags & GWEN_WIDGET_FLAGS_FILLY)
00048       vpolicy=QSizePolicy::Expanding;
00049     qw->setSizePolicy(hpolicy, vpolicy);
00050 
00051     GWEN_Widget_SetImplData(_widget, QT4_DIALOG_WIDGET_REAL, (void*) qw);
00052 
00053     if (wParent)
00054       GWEN_Widget_AddChildGuiWidget(wParent, _widget);
00055     return 0;
00056   }
00057 
00058 
00059 
00060   int setCharProperty(GWEN_DIALOG_PROPERTY prop,
00061                       int index,
00062                       const char *value,
00063                       int doSignal) {
00064     QTextBrowser *qw;
00065     QString text;
00066 
00067     qw=(QTextBrowser*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00068     assert(qw);
00069 
00070     if (value)
00071       text=QT4_Gui::extractHtml(value);
00072 
00073     switch(prop) {
00074     case GWEN_DialogProperty_Value:
00075       qw->setText("");
00076       qw->append(text);
00077       return 0;
00078 
00079     case GWEN_DialogProperty_AddValue:
00080       qw->append(text);
00081       return 0;
00082 
00083     case GWEN_DialogProperty_ClearValues:
00084       qw->setText("");
00085       return 0;
00086 
00087     default:
00088       break;
00089     }
00090 
00091     DBG_WARN(GWEN_LOGDOMAIN,
00092              "Function is not appropriate for this type of widget (%s)",
00093              GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00094     return GWEN_ERROR_INVALID;
00095   };
00096 
00097 
00098 
00099 };
00100 
00101 
00102 
00103 
00104 
00105 
00106