This repository has been archived by the owner on Aug 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqgtkbox.cpp
95 lines (78 loc) · 2.05 KB
/
qgtkbox.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "qgtkbox.h"
#include "qgtkvbox.h"
#include "qgtkhbox.h"
QGtkBox::QGtkBox(QGtkObject *parent)
: QGtkWidget(parent)
{
}
void QGtkBox::childCreated(QGtkObject *w)
{
QGtkWidget *cw = qobject_cast<QGtkWidget*>(w);
if (!cw)
return;
QGtkBoxPackAttached *pack = qobject_cast<QGtkBoxPackAttached*>(qmlAttachedPropertiesObject<QGtkHBox>(w, false));
if (!pack) {
// ### c'mon, why do we have to do this
pack = qobject_cast<QGtkBoxPackAttached*>(qmlAttachedPropertiesObject<QGtkVBox>(w, false));
}
qDebug() << "child added " << w << " with pack " << pack;
if (!pack) {
// let container handle it
QGtkWidget::childCreated(w);
return;
}
GtkBox *box = gtkBox();
GtkWidget *childWidget = cw->gtkWidget();
if (pack->packDirection() == QGtkBoxPackAttached::PackStart)
gtk_box_pack_start(box, childWidget, pack->expand() ? TRUE : FALSE, pack->fill() ? TRUE : FALSE, pack->padding());
else
gtk_box_pack_end(box, childWidget, pack->expand() ? TRUE : FALSE, pack->fill() ? TRUE : FALSE, pack->padding());
}
QGtkBoxPackAttached::QGtkBoxPackAttached(QObject *parent)
: QObject(parent)
{
}
bool QGtkBoxPackAttached::expand() const
{
return m_expand;
}
void QGtkBoxPackAttached::setExpand(bool e)
{
if (m_expand == e)
return;
m_expand = e;
emit expandChanged();
}
bool QGtkBoxPackAttached::fill() const
{
return m_fill;
}
void QGtkBoxPackAttached::setFill(bool f)
{
if (m_fill == f)
return;
m_fill = f;
emit fillChanged();
}
int QGtkBoxPackAttached::padding() const
{
return m_padding;
}
void QGtkBoxPackAttached::setPadding(int p)
{
if (m_padding == p)
return;
m_padding = p;
emit paddingChanged();
}
QGtkBoxPackAttached::PackDirection QGtkBoxPackAttached::packDirection() const
{
return m_packDirection;
}
void QGtkBoxPackAttached::setPackDirection(const QGtkBoxPackAttached::PackDirection &p)
{
if (m_packDirection == p)
return;
m_packDirection = p;
emit packDirectionChanged();
}