gwenhywfar  5.14.1
qt5/w_gridlayout.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 
12 public:
14  }
15 
16 
17 
19  }
20 
21 
22 
23  virtual int setup() {
24  QWidget *qw;
25  uint32_t flags;
26  GWEN_WIDGET *wParent;
27  QLayout *qLayout;
28  QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
29  QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
30 
32  wParent=GWEN_Widget_Tree_GetParent(_widget);
33 
34  qw=new QWidget();
35  qLayout=new QGridLayout(qw);
36 
37  /* handle flags */
38  if (flags & GWEN_WIDGET_FLAGS_FILLX)
39  hpolicy=QSizePolicy::Expanding;
40  if (flags & GWEN_WIDGET_FLAGS_FILLY)
41  vpolicy=QSizePolicy::Expanding;
42  qw->setSizePolicy(hpolicy, vpolicy);
43 
44 
47 
48  if (wParent)
50  return 0;
51  }
52 
53 
54 
56  QWidget *qw;
57  QGridLayout *qLayout;
58  QWidget *qChild;
59  GWEN_WIDGET *wt;
60  int idx=0;
61 
63  assert(qw);
64 
66  assert(qLayout);
67 
68  qChild=getQWidget(wChild);
69  assert(qChild);
70 
71  qChild->setParent(qw);
72 
73  /* get position of the child widget below myself */
74  wt=GWEN_Widget_Tree_GetFirstChild(_widget);
75  while(wt && wt!=wChild) {
76  idx++;
77  wt=GWEN_Widget_Tree_GetNext(wt);
78  }
79 
80  if (wt) {
81  int x=0, y=0;
82  int c;
83 
85  x=idx % c;
86  y=idx / c;
87  }
88  else if ((c=GWEN_Widget_GetRows(_widget))) {
89  x=idx / c;
90  y=idx % c ;
91  }
92 
93  qLayout->addWidget(qChild, y, x);
94  }
95 
96  return 0;
97  }
98 
99 };
100 
101 
102 
103 
104 
105 
106 
uint32_t GWEN_Widget_GetFlags(const GWEN_WIDGET *w)
Definition: widget.c:149
int GWEN_Widget_GetRows(const GWEN_WIDGET *w)
Definition: widget.c:221
void GWEN_Widget_SetImplData(GWEN_WIDGET *w, int index, void *ptr)
Store a pointer with the widget.
Definition: widget.c:136
void * GWEN_Widget_GetImplData(const GWEN_WIDGET *w, int index)
Definition: widget.c:122
int GWEN_Widget_GetColumns(const GWEN_WIDGET *w)
Definition: widget.c:203
#define QT5_DIALOG_WIDGET_LAYOUT
struct GWEN_WIDGET GWEN_WIDGET
Definition: widget_be.h:34
int GWEN_Widget_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
Definition: widget.c:836
Qt5_W_GridLayout(GWEN_WIDGET *w)
#define GWEN_WIDGET_FLAGS_FILLY
Definition: dialog.h:62
#define GWEN_WIDGET_FLAGS_FILLX
Definition: dialog.h:61
static QWidget * getQWidget(GWEN_WIDGET *w)
virtual int setup()
GWEN_WIDGET * _widget
Definition: cppwidget.hpp:66
#define QT5_DIALOG_WIDGET_REAL
int addChildGuiWidget(GWEN_WIDGET *wChild)