Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <gwen-gui-cpp/cppwidget.hpp>
00012
00013
00014 class Qt4_W_Label: public Qt4_W_Widget {
00015 public:
00016 Qt4_W_Label(GWEN_WIDGET *w):Qt4_W_Widget(w) {
00017 }
00018
00019
00020
00021 ~Qt4_W_Label() {
00022 }
00023
00024
00025
00026 virtual int setup() {
00027 QLabel *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=QT4_Gui::extractHtml(s);
00040
00041 qw=new QLabel(text);
00042 qw->setWordWrap(true);
00043
00044
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 QLabel *qw;
00065 QString text;
00066
00067 qw=(QLabel*) 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_Title:
00075 qw->setText(text);
00076 return 0;
00077 default:
00078 break;
00079 }
00080
00081 DBG_WARN(GWEN_LOGDOMAIN,
00082 "Function is not appropriate for this type of widget (%s)",
00083 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00084 return GWEN_ERROR_INVALID;
00085 };
00086
00087
00088
00089 const char *getCharProperty(GWEN_DIALOG_PROPERTY prop,
00090 int index,
00091 const char *defaultValue) {
00092 QLabel *qw;
00093 QString str;
00094
00095 qw=(QLabel*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00096 assert(qw);
00097
00098 switch(prop) {
00099 case GWEN_DialogProperty_Title:
00100 str=qw->text();
00101 if (str.isEmpty())
00102 return defaultValue;
00103 else {
00104 GWEN_Widget_SetText(_widget, QT4_DIALOG_STRING_TITLE, str.toUtf8());
00105 return GWEN_Widget_GetText(_widget, QT4_DIALOG_STRING_TITLE);
00106 }
00107 break;
00108
00109 default:
00110 break;
00111 }
00112
00113 DBG_WARN(GWEN_LOGDOMAIN,
00114 "Function is not appropriate for this type of widget (%s)",
00115 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00116 return defaultValue;
00117 };
00118
00119 };
00120
00121
00122
00123
00124
00125
00126