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_Dialog: public Qt4_W_Widget {
00015 public:
00016 Qt4_W_Dialog(GWEN_WIDGET *w):Qt4_W_Widget(w) {
00017 }
00018
00019
00020
00021 ~Qt4_W_Dialog() {
00022 }
00023
00024
00025
00026 virtual int setup() {
00027 QWidget *qw;
00028 uint32_t flags;
00029 GWEN_WIDGET *wParent;
00030 QLayout *qLayout;
00031 QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
00032 QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
00033
00034 flags=GWEN_Widget_GetFlags(_widget);
00035 wParent=GWEN_Widget_Tree_GetParent(_widget);
00036
00037 qw=new QT4_DialogBox(dynamic_cast<QT4_GuiDialog*>(getDialog()), QApplication::activeModalWidget());
00038 qLayout=new QVBoxLayout(qw);
00039
00040
00041 if (flags & GWEN_WIDGET_FLAGS_FILLX)
00042 hpolicy=QSizePolicy::Expanding;
00043 if (flags & GWEN_WIDGET_FLAGS_FILLY)
00044 vpolicy=QSizePolicy::Expanding;
00045 qw->setSizePolicy(hpolicy, vpolicy);
00046
00047
00048 GWEN_Widget_SetImplData(_widget, QT4_DIALOG_WIDGET_REAL, (void*) qw);
00049 GWEN_Widget_SetImplData(_widget, QT4_DIALOG_WIDGET_LAYOUT, (void*) qLayout);
00050
00051 if (wParent)
00052 GWEN_Widget_AddChildGuiWidget(wParent, _widget);
00053 return 0;
00054 }
00055
00056
00057
00058 int addChildGuiWidget(GWEN_WIDGET *wChild) {
00059 QWidget *qw;
00060 QBoxLayout *qLayout;
00061 QWidget *qChild;
00062
00063 qw=(QT4_DialogBox*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00064 assert(qw);
00065
00066 qLayout=(QBoxLayout*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_LAYOUT);
00067 assert(qLayout);
00068
00069 qChild=getQWidget(wChild);
00070 assert(qChild);
00071
00072 qChild->setParent(qw);
00073 qLayout->addWidget(qChild);
00074
00075 return 0;
00076 }
00077
00078
00079
00080 int setCharProperty(GWEN_DIALOG_PROPERTY prop,
00081 int index,
00082 const char *value,
00083 int doSignal) {
00084 QWidget *qw;
00085
00086 qw=(QWidget*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00087 assert(qw);
00088
00089 switch(prop) {
00090 case GWEN_DialogProperty_Title:
00091 qw->setWindowTitle(value);
00092 return 0;
00093 default:
00094 break;
00095 }
00096
00097 DBG_WARN(GWEN_LOGDOMAIN,
00098 "Function is not appropriate for this type of widget (%s)",
00099 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00100 return GWEN_ERROR_INVALID;
00101 };
00102
00103
00104
00105 const char *getCharProperty(GWEN_DIALOG_PROPERTY prop,
00106 int index,
00107 const char *defaultValue) {
00108 QWidget *qw;
00109 QString str;
00110
00111 qw=(QWidget*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00112 assert(qw);
00113
00114 switch(prop) {
00115 case GWEN_DialogProperty_Title:
00116 str=qw->windowTitle();
00117 if (str.isEmpty())
00118 return defaultValue;
00119 else {
00120 GWEN_Widget_SetText(_widget, QT4_DIALOG_STRING_TITLE, str.toUtf8());
00121 return GWEN_Widget_GetText(_widget, QT4_DIALOG_STRING_TITLE);
00122 }
00123 break;
00124
00125 default:
00126 break;
00127 }
00128
00129 DBG_WARN(GWEN_LOGDOMAIN,
00130 "Function is not appropriate for this type of widget (%s)",
00131 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00132 return defaultValue;
00133 };
00134
00135 };
00136
00137
00138
00139
00140
00141
00142