File: export_main_area.cc

package info (click to toggle)
openstructure 2.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 206,240 kB
  • sloc: cpp: 188,571; python: 36,686; ansic: 34,298; fortran: 3,275; sh: 312; xml: 146; makefile: 29
file content (188 lines) | stat: -rw-r--r-- 6,910 bytes parent folder | download | duplicates (4)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-2020 by the OpenStructure authors
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3.0 of the License, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//------------------------------------------------------------------------------
#include <boost/python.hpp>

#include <QObject>
#include <QMdiArea>

#include <ost/gui/main_area.hh>

#include "transfer_ownership.hh"
#include "sip_handler.hh"

using namespace boost::python;
using namespace ost;
using namespace ost::gui;

namespace {

void main_area_add_widget_a(MainArea* m, const QString& title,
                          const SipHandlerBase& sh)
{
  m->AddWidget(title, reinterpret_cast<QWidget*>(sh.GetSipHandle()));
}

void main_area_add_widget_b(MainArea* m, const QString& title, QObject* obj)
{
  if(QWidget* widget = reinterpret_cast<QWidget*>(obj)){
    m->AddWidget(title, widget);
  }
}

void main_area_add_widget_c(MainArea* m, const QString& title, object py_object)
{
  if(QWidget* widget = get_cpp_qobject<QWidget>(py_object)){
    m->AddWidget(title, widget);
  }
}

void main_area_add_pers_widget_a(MainArea* m, const QString& title,
                               const QString& name,
                               const SipHandlerBase& sh)
{
  m->AddPersistentWidget(title, name, 
                         reinterpret_cast<QWidget*>(sh.GetSipHandle()));
}

void main_area_add_pers_widget_b(MainArea* m, const QString& title,
                               const QString& name,
                               QWidget* widget)
{
  TransferOwnership(widget);
  m->AddPersistentWidget(title, name, 
                         reinterpret_cast<QWidget*>(widget));
}

void main_area_add_pers_widget_c(MainArea* m, const QString& title,
                               const QString& name,
                               object py_object)
{
  if(QWidget* widget = get_cpp_qobject<QWidget>(py_object)){
    m->AddPersistentWidget(title, name, widget);
  }
}

void main_area_add_pers_widget_d(MainArea* m, const QString& title,
                               const QString& name,
                               const SipHandlerBase& sh, int width, int height, int x, int y)
{
  m->AddPersistentWidget(title, name,
                         reinterpret_cast<QWidget*>(sh.GetSipHandle()), width, height, x, y);
}

void main_area_add_pers_widget_e(MainArea* m, const QString& title,
                               const QString& name,
                               QWidget* widget, int width, int height, int x, int y)
{
  TransferOwnership(widget);
  m->AddPersistentWidget(title, name,
                         reinterpret_cast<QWidget*>(widget), width, height, x, y);
}

void main_area_add_pers_widget_f(MainArea* m, const QString& title,
                               const QString& name,
                               object py_object, int width, int height, int x, int y)
{
  if(QWidget* widget = get_cpp_qobject<QWidget>(py_object)){
    m->AddPersistentWidget(title, name, widget, width, height, x, y);
  }
}

void main_area_add_pers_widget_g(MainArea* m, const QString& title,
                               const QString& name, const SipHandlerBase& sh, int window_states)
{
  Qt::WindowStates q_window_states =Qt::WindowStates(window_states);
  m->AddPersistentWidget(title, name,
                         reinterpret_cast<QWidget*>(sh.GetSipHandle()), q_window_states);
}

void main_area_add_pers_widget_h(MainArea* m, const QString& title,
                               const QString& name, QWidget* widget, int window_states)
{
  TransferOwnership(widget);
  Qt::WindowStates q_window_states =Qt::WindowStates(window_states);
  m->AddPersistentWidget(title, name,
                         reinterpret_cast<QWidget*>(widget), q_window_states);
}

void main_area_add_pers_widget_i(MainArea* m, const QString& title,
    const QString& name, object py_object, int window_states)
{
  if(QWidget* widget = get_cpp_qobject<QWidget>(py_object)){
    Qt::WindowStates q_window_states = Qt::WindowStates(window_states);
    m->AddPersistentWidget(title, name, widget, q_window_states);
  }
}

void main_area_show_sub_window(MainArea* m, const SipHandlerBase& sh)
{
  m->ShowSubWindow(reinterpret_cast<QWidget*>(sh.GetSipHandle()));
}

void main_area_hide_sub_window(MainArea* m, const SipHandlerBase& sh)
{
  m->HideSubWindow(reinterpret_cast<QWidget*>(sh.GetSipHandle()));
}

}

void main_area_show_sub_window_b(MainArea* m, object py_object)
{
  if(QWidget* widget = get_cpp_qobject<QWidget>(py_object)){
    m->ShowSubWindow(widget);
  }
}

void main_area_hide_sub_window_b(MainArea* m, object py_object)
{
  if(QWidget* widget = get_cpp_qobject<QWidget>(py_object)){
    m->HideSubWindow(widget);
  }
}

void export_MainArea()
{  
  class_<MainArea, boost::noncopyable>("MainArea", no_init)
    .def("AddWidget", &MainArea::AddWidget)
    .def("AddWidget", &main_area_add_widget_a)
    .def("AddWidget", &main_area_add_widget_b)
    .def("AddWidget", &main_area_add_widget_c)
    .def("AddPersistentWidget", &main_area_add_pers_widget_a)    
    .def("AddPersistentWidget", &main_area_add_pers_widget_b)
    .def("AddPersistentWidget", &main_area_add_pers_widget_c)
    .def("AddPersistentWidget", &main_area_add_pers_widget_d)
    .def("AddPersistentWidget", &main_area_add_pers_widget_e)
    .def("AddPersistentWidget", &main_area_add_pers_widget_f)
    .def("AddPersistentWidget", &main_area_add_pers_widget_g)
    .def("AddPersistentWidget", &main_area_add_pers_widget_h)
    .def("AddPersistentWidget", &main_area_add_pers_widget_i)
    .def("width", &MainArea::width)
    .def("height", &MainArea::height)
    .def("ShowSubWindow", &MainArea::ShowSubWindow)
    .def("ShowSubWindow", &main_area_show_sub_window)
    .def("ShowSubWindow", &main_area_show_sub_window_b)
    .def("HideSubWindow", &MainArea::HideSubWindow)
    .def("HideSubWindow", &main_area_hide_sub_window_b)
    .def("HideSubWindow", &main_area_hide_sub_window)            
    .def("EnableTabbedMode", &MainArea::EnableTabbedMode, arg("flag")=true)
    .def("GetQObject",&get_py_qobject<MainArea>)
    .add_property("qobject", &get_py_qobject<MainArea>)
  ;
}