gwenhywfar  5.14.1
w_splitter.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Fri Jan 2 2026
3  copyright : (C) 2026 by Thomas Baumgart
4  email : tbaumgart@kde.org
5 
6  ***************************************************************************
7  * Please see toplevel file COPYING for license details *
8  ***************************************************************************/
9 
11 {
12 public:
13  Qt5_W_Splitter(Qt::Orientation orientation, GWEN_WIDGET* w)
14  : Qt5_W_Widget(w)
15  , m_orientation(orientation)
16  {
17  }
18 
20  {
21  }
22 
23 
24  virtual int setup()
25  {
26  QSplitter* qw;
27  uint32_t flags;
28  GWEN_WIDGET* wParent;
29 
30  QSizePolicy::Policy hpolicy = QSizePolicy::Minimum;
31  QSizePolicy::Policy vpolicy = QSizePolicy::Minimum;
32 
34  wParent = GWEN_Widget_Tree_GetParent(_widget);
35 
36  qw = new QSplitter(m_orientation);
37 
38  /* handle flags */
39  if (flags & GWEN_WIDGET_FLAGS_FILLX)
40  hpolicy=QSizePolicy::Expanding;
41  if (flags & GWEN_WIDGET_FLAGS_FILLY)
42  vpolicy=QSizePolicy::Expanding;
43  qw->setSizePolicy(hpolicy, vpolicy);
44 
46 
47  if (wParent) {
49  }
50  return 0;
51  }
52 
54  int index,
55  int value,
56  int doSignal) {
57  QSplitter* qw;
58  QList<int> sizes{0, 0};
59 
61  assert(qw);
62 
63  switch(prop) {
65  sizes.first() = value;
66  sizes.last() = (m_orientation == Qt::Vertical ? qw->height() : qw->width()) - value;
67  if (qw->count() < 2) {
68  DBG_WARN(GWEN_LOGDOMAIN, "Less than two children assigned to splitter. Additional data ignored.");
69  }
70  qw->setSizes(sizes);
71  return 0;
72 
73  default:
74  return Qt5_W_Widget::setIntProperty(prop, index, value, doSignal);
75  }
76  };
77 
79  int index,
80  int defaultValue) {
81  QSplitter* qw;
82 
84  assert(qw);
85 
86  switch(prop) {
88  return qw->sizes().first();
89 
90  default:
91  return Qt5_W_Widget::getIntProperty(prop, index, defaultValue);
92  }
93  };
94 
95 
97  {
98  QSplitter* qw;
99  QWidget* qChild;
100 
102  assert(qw);
103 
104  // even though Qt supports more than 2 children, we limit it to two
105  if (qw->count() < 2) {
106  qChild = getQWidget(wChild);
107  assert(qChild);
108 
109  qw->addWidget(qChild);
110  return 0;
111  }
112 
113  DBG_WARN(GWEN_LOGDOMAIN, "Qt Dialogs do not support more than two children for splitter");
114  return GWEN_ERROR_INVALID;
115  }
116 
117 private:
118  Qt::Orientation m_orientation;
119 };
120 
122 {
123 public:
125  : Qt5_W_Splitter(Qt::Horizontal, w)
126  {
127  }
128 
130  {
131  }
132 };
133 
135 {
136 public:
138  : Qt5_W_Splitter(Qt::Vertical, w)
139  {
140  }
141 
143  {
144  }
145 };
#define GWEN_ERROR_INVALID
Definition: error.h:67
Qt5_W_Splitter(Qt::Orientation orientation, GWEN_WIDGET *w)
Definition: w_splitter.cpp:13
GWEN_DIALOG_PROPERTY
Definition: dialog.h:260
uint32_t GWEN_Widget_GetFlags(const GWEN_WIDGET *w)
Definition: widget.c:149
#define GWEN_LOGDOMAIN
Definition: logger.h:32
void GWEN_Widget_SetImplData(GWEN_WIDGET *w, int index, void *ptr)
Store a pointer with the widget.
Definition: widget.c:136
int setIntProperty(GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
Definition: w_splitter.cpp:53
#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
int getIntProperty(GWEN_DIALOG_PROPERTY prop, int index, int defaultValue)
Definition: w_splitter.cpp:78
int setIntProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, int value, GWEN_UNUSED int doSignal)
virtual int setup()
Definition: w_splitter.cpp:24
static QWidget * getQWidget(GWEN_WIDGET *w)
int addChildGuiWidget(GWEN_WIDGET *wChild)
Definition: w_splitter.cpp:96
Qt5_W_HSplitter(GWEN_WIDGET *w)
Definition: w_splitter.cpp:124
GWEN_WIDGET * _widget
Definition: cppwidget.hpp:66
int getIntProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, int defaultValue)
Qt5_W_VSplitter(GWEN_WIDGET *w)
Definition: w_splitter.cpp:137
#define QT5_DIALOG_WIDGET_REAL