gwenhywfar  5.14.1
qt5/w_label.cpp
Go to the documentation of this file.
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 class Qt5_W_Label: public Qt5_W_Widget {
12 public:
14  }
15 
16 
17 
19  }
20 
21 
22 
23  virtual int setup() {
24  QLabel *qw;
25  uint32_t flags;
26  GWEN_WIDGET *wParent;
27  QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
28  QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
29  const char *s;
30  QString text;
31 
33  wParent=GWEN_Widget_Tree_GetParent(_widget);
35  if (s)
36  text=QT5_Gui::extractHtml(s);
37 
38  qw=new QLabel(text);
39  qw->setWordWrap(true);
40 
41  /* handle flags */
42  if (flags & GWEN_WIDGET_FLAGS_FILLX)
43  hpolicy=QSizePolicy::Expanding;
44  if (flags & GWEN_WIDGET_FLAGS_FILLY)
45  vpolicy=QSizePolicy::Expanding;
46  qw->setSizePolicy(hpolicy, vpolicy);
47 
49 
50  if (wParent)
52  return 0;
53  }
54 
55 
56 
58  GWEN_UNUSED int index,
59  const char *value,
60  GWEN_UNUSED int doSignal) {
61  QLabel *qw;
62  QString text;
63 
65  assert(qw);
66 
67  if (value)
68  text=QT5_Gui::extractHtml(value);
69 
70  switch(prop) {
72  qw->setText(text);
73  return 0;
74  default:
75  break;
76  }
77 
79  "Function is not appropriate for this type of widget (%s)",
81  return GWEN_ERROR_INVALID;
82  };
83 
84 
85 
87  GWEN_UNUSED int index,
88  const char *defaultValue) {
89  QLabel *qw;
90  QString str;
91 
93  assert(qw);
94 
95  switch(prop) {
97  str=qw->text();
98  if (str.isEmpty())
99  return defaultValue;
100  else {
103  }
104  break;
105 
106  default:
107  break;
108  }
109 
111  "Function is not appropriate for this type of widget (%s)",
113  return defaultValue;
114  };
115 
116 };
117 
118 
119 
120 
121 
122 
123 
GWEN_WIDGET_TYPE GWEN_Widget_GetType(const GWEN_WIDGET *w)
Definition: widget.c:185
void GWEN_Widget_SetText(GWEN_WIDGET *w, int idx, const char *s)
Definition: widget.c:304
#define GWEN_ERROR_INVALID
Definition: error.h:67
GWEN_DIALOG_PROPERTY
Definition: dialog.h:260
uint32_t GWEN_Widget_GetFlags(const GWEN_WIDGET *w)
Definition: widget.c:149
static QString extractHtml(const char *text)
Definition: qt5_gui.cpp:64
#define GWEN_LOGDOMAIN
Definition: logger.h:32
const char * getCharProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, const char *defaultValue)
Definition: qt5/w_label.cpp:86
void GWEN_Widget_SetImplData(GWEN_WIDGET *w, int index, void *ptr)
Store a pointer with the widget.
Definition: widget.c:136
Qt5_W_Label(GWEN_WIDGET *w)
Definition: qt5/w_label.cpp:13
#define DBG_WARN(dbg_logger, format,...)
Definition: debug.h:125
void * GWEN_Widget_GetImplData(const GWEN_WIDGET *w, int index)
Definition: widget.c:122
struct GWEN_WIDGET GWEN_WIDGET
Definition: widget_be.h:34
int GWEN_Widget_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
Definition: widget.c:836
#define GWEN_WIDGET_FLAGS_FILLY
Definition: dialog.h:62
#define GWEN_WIDGET_FLAGS_FILLX
Definition: dialog.h:61
#define QT5_DIALOG_STRING_TITLE
int setCharProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, const char *value, GWEN_UNUSED int doSignal)
Definition: qt5/w_label.cpp:57
const char * GWEN_Widget_Type_toString(GWEN_WIDGET_TYPE t)
Definition: widget.c:456
virtual int setup()
Definition: qt5/w_label.cpp:23
GWEN_WIDGET * _widget
Definition: cppwidget.hpp:66
#define QT5_DIALOG_WIDGET_REAL
const char * GWEN_Widget_GetText(const GWEN_WIDGET *w, int idx)
Definition: widget.c:293
#define GWEN_UNUSED