gwenhywfar  5.10.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 
11 #include <gwen-gui-cpp/cppwidget.hpp>
12 
13 
15 public:
17  }
18 
19 
20 
22  }
23 
24 
25 
26  virtual int setup() {
27  QWidget *qw;
28  uint32_t flags;
29  GWEN_WIDGET *wParent;
30  QLayout *qLayout;
31  QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
32  QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
33 
35  wParent=GWEN_Widget_Tree_GetParent(_widget);
36 
37  qw=new QWidget();
38  qLayout=new QGridLayout(qw);
39 
40  /* handle flags */
41  if (flags & GWEN_WIDGET_FLAGS_FILLX)
42  hpolicy=QSizePolicy::Expanding;
43  if (flags & GWEN_WIDGET_FLAGS_FILLY)
44  vpolicy=QSizePolicy::Expanding;
45  qw->setSizePolicy(hpolicy, vpolicy);
46 
47 
50 
51  if (wParent)
53  return 0;
54  }
55 
56 
57 
59  QWidget *qw;
60  QGridLayout *qLayout;
61  QWidget *qChild;
62  GWEN_WIDGET *wt;
63  int idx=0;
64 
66  assert(qw);
67 
69  assert(qLayout);
70 
71  qChild=getQWidget(wChild);
72  assert(qChild);
73 
74  qChild->setParent(qw);
75 
76  /* get position of the child widget below myself */
77  wt=GWEN_Widget_Tree_GetFirstChild(_widget);
78  while(wt && wt!=wChild) {
79  idx++;
80  wt=GWEN_Widget_Tree_GetNext(wt);
81  }
82 
83  if (wt) {
84  int x=0, y=0;
85  int c;
86 
88  x=idx % c;
89  y=idx / c;
90  }
91  else if ((c=GWEN_Widget_GetRows(_widget))) {
92  x=idx / c;
93  y=idx % c ;
94  }
95 
96  qLayout->addWidget(qChild, y, x);
97  }
98 
99  return 0;
100  }
101 
102 };
103 
104 
105 
106 
107 
108 
109 
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:828
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)