itom  3.0.0
pythonUi.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef PYTHONUI_H
24 #define PYTHONUI_H
25 
26 #include "pythonCommon.h"
27 #include "pythonQtConversion.h"
28 #include "pythonQtSignalMapper.h"
29 #include "pythonItomMetaObject.h"
30 
31 #include <qstring.h>
32 #include <qvariant.h>
33 #include <qobject.h>
34 #include <qhash.h>
35 
36 namespace ito
37 {
38 
39 class PythonUi
40 {
41 public:
42 
43  //#################################################################################################
44  // UiItem
45  //#################################################################################################
46 
47  //-------------------------------------------------------------------------------------------------
48  // typedefs
49  //-------------------------------------------------------------------------------------------------
50  typedef struct
51  {
52  PyObject_HEAD
53  PyObject *baseItem; //parent UiItem (e.g. the whole dialog), NULL if no parent.
54  char* objName; //object name of corresponding widget in UI
55  char* widgetClassName; //class name of corresponding widget in UI
56  unsigned int objectID; //itom internal ID of hashed meta object of this widget (for communication with uiOrganizer)
57  const MethodDescriptionList* methodList; //borrowed pointer to an item in methodDescriptionListStorage.
58  PyObject *weakreflist;
59  }
60  PyUiItem;
61 
62  typedef struct
63  {
64  PyUiItem uiItem;
65  int uiHandle;
66  int winType;
67  int buttonBarType;
68  bool childOfMainWindow;
69  bool deleteOnClose;
70  PyObject *dialogButtons;
71  char* filename;
72  PythonQtSignalMapper *signalMapper;
73  }
74  PyUi;
75 
76 
77  //-------------------------------------------------------------------------------------------------
78  // constructor, deconstructor, alloc, dellaoc
79  //-------------------------------------------------------------------------------------------------
80  static void PyUiItem_dealloc(PyUiItem *self);
81  static PyObject *PyUiItem_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
82  static int PyUiItem_init(PyUiItem *self, PyObject *args, PyObject *kwds);
83 
84  //-------------------------------------------------------------------------------------------------
85  // mapping members
86  //-------------------------------------------------------------------------------------------------
87  static int PyUiItem_mappingLength(PyUiItem* self);
88  static PyObject* PyUiItem_mappingGetElem(PyUiItem* self, PyObject* key);
89  static int PyUiItem_mappingSetElem(PyUiItem* self, PyObject* key, PyObject* value);
90 
91  //-------------------------------------------------------------------------------------------------
92  // general members
93  //-------------------------------------------------------------------------------------------------
94  static PyObject* PyUiItem_repr(PyUiItem *self);
95  static PyObject* PyUiItem_call(PyUiItem *self, PyObject* args);
96  static PyObject* PyUiItem_connect(PyUiItem *self, PyObject* args);
97  static PyObject* PyUiItem_connectKeyboardInterrupt(PyUiItem *self, PyObject* args);
98  static PyObject* PyUiItem_disconnect(PyUiItem *self, PyObject* args);
99  static PyObject* PyUiItem_getProperties(PyUiItem *self, PyObject *args);
100  static PyObject* PyUiItem_setProperties(PyUiItem *self, PyObject *args);
101  static PyObject *PyUiItem_getPropertyInfo(PyUiItem *self, PyObject *args);
102  static PyObject* PyUiItem_getattro(PyUiItem *self, PyObject *name);
103  static int PyUiItem_setattro(PyUiItem *self, PyObject *name, PyObject *value);
104 
105  static PyObject* PyUiItem_setAttribute(PyUiItem *self, PyObject *args);
106  static PyObject* PyUiItem_getAttribute(PyUiItem *self, PyObject *args);
107 
108  static PyObject* PyUiItem_setWindowFlags(PyUiItem *self, PyObject *args);
109  static PyObject* PyUiItem_getWindowFlags(PyUiItem *self);
110 
111  static PyObject* PyUiItem_info(PyUiItem *self, PyObject *args);
112  static PyObject* PyUiItem_exists(PyUiItem *self);
113  static PyObject* PyUiItem_children(PyUiItem *self, PyObject *args, PyObject *kwds);
114 
115  //-------------------------------------------------------------------------------------------------
116  // helpers
117  //-------------------------------------------------------------------------------------------------
118  static bool loadMethodDescriptionList(PyUiItem *self);
119  static PythonQtSignalMapper* PyUiItem_getTopLevelSignalMapper(PyUiItem *self);
120 
121  //-------------------------------------------------------------------------------------------------
122  // type structures
123  //-------------------------------------------------------------------------------------------------
124  static PyMemberDef PyUiItem_members[];
125  static PyGetSetDef PyUiItem_getseters[];
126  static PyMethodDef PyUiItem_methods[];
127  static PyTypeObject PyUiItemType;
128  static PyModuleDef PyUiItemModule;
129  static PyMappingMethods PyUiItem_mappingProtocol;
130  static void PyUiItem_addTpDict(PyObject *tp_dict);
131 
132 
133 
134  //#################################################################################################
135  // Ui
136  //#################################################################################################
137 
138 
139  //-------------------------------------------------------------------------------------------------
140  // constructor, deconstructor, alloc, dellaoc
141  //-------------------------------------------------------------------------------------------------
142  static void PyUi_dealloc(PyUi *self);
143  static PyObject *PyUi_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
144  static int PyUi_init(PyUi *self, PyObject *args, PyObject *kwds);
145 
146  //-------------------------------------------------------------------------------------------------
147  // general members
148  //-------------------------------------------------------------------------------------------------
149  static PyObject* PyUi_repr(PyUi *self);
150 
151  static PyObject *PyUi_show(PyUi *self, PyObject *args);
152  static PyObject *PyUi_hide(PyUi *self);
153  static PyObject *PyUi_isVisible(PyUi *self);
154 
155  static PyObject *PyUi_getPropertyInfo(PyUi *self, PyObject *args);
156  static PyObject *PyUi_getProperties(PyUi *self, PyObject *args);
157  static PyObject *PyUi_setProperties(PyUi *self, PyObject *args);
158 
159  //-------------------------------------------------------------------------------------------------
160  // static members
161  //-------------------------------------------------------------------------------------------------
162  static PyObject* PyUi_getDouble(PyUi *self, PyObject *args, PyObject *kwds);
163  static PyObject* PyUi_getInt(PyUi *self, PyObject *args, PyObject *kwds);
164  static PyObject* PyUi_getItem(PyUi *self, PyObject *args, PyObject *kwds);
165  static PyObject* PyUi_getText(PyUi *self, PyObject *args, PyObject *kwds);
166 
167  static PyObject* PyUi_msgInformation(PyUi *self, PyObject *args, PyObject *kwds);
168  static PyObject* PyUi_msgQuestion(PyUi *self, PyObject *args, PyObject *kwds);
169  static PyObject* PyUi_msgWarning(PyUi *self, PyObject *args, PyObject *kwds);
170  static PyObject* PyUi_msgCritical(PyUi *self, PyObject *args, PyObject *kwds);
171  static PyObject* PyUi_msgGeneral(PyUi *self, PyObject *args, PyObject *kwds, int type);
172 
173  static PyObject* PyUi_getExistingDirectory(PyUi *self, PyObject *args, PyObject *kwds);
174  static PyObject* PyUi_getOpenFileNames(PyUi *self, PyObject *args, PyObject *kwds);
175  static PyObject* PyUi_getOpenFileName(PyUi *self, PyObject *args, PyObject *kwds);
176  static PyObject* PyUi_getSaveFileName(PyUi *self, PyObject *args, PyObject *kwds);
177 
178  static PyObject* PyUi_createNewAlgoWidget(PyUi *self, PyObject *args, PyObject *kwds);
179  static PyObject* PyUi_createNewAlgoWidget2(PyUi *self, PyObject *args, PyObject *kwds);
180  static PyObject *PyUi_availableWidgets(PyUi *self);
181 
182  //-------------------------------------------------------------------------------------------------
183  // type structures
184  //-------------------------------------------------------------------------------------------------
185  static PyGetSetDef PyUi_getseters[];
186  static PyMemberDef PyUi_members[];
187  static PyMethodDef PyUi_methods[];
188  static PyTypeObject PyUiType;
189  static PyModuleDef PyUiModule;
190  static void PyUi_addTpDict(PyObject *tp_dict);
191 
192  //-------------------------------------------------------------------------------------------------
193  // macros
194  //-------------------------------------------------------------------------------------------------
195  #define PyUiItem_Check(op) PyObject_TypeCheck(op, &ito::PythonUi::PyUiItemType)
196  #define PyUi_Check(op) PyObject_TypeCheck(op, &ito::PythonUi::PyUiType)
197 
198 private:
199  static QHash<QByteArray, QSharedPointer<ito::MethodDescriptionList> > methodDescriptionListStorage; //key is a widget-className, every PyUiItem which needs a methodDescriptionList gets it from this storage or if not available from UiOrganizer and puts it then to this storage
200 };
201 
202 }; //end namespace ito
203 
204 
205 #endif
static PyObject * PyUiItem_info(PyUiItem *self, PyObject *args)
Definition: pythonUi.cpp:1370
Definition: apiFunctionsGraph.cpp:39
static PyObject * PyUiItem_children(PyUiItem *self, PyObject *args, PyObject *kwds)
Definition: pythonUi.cpp:1478
static PyObject * PyUiItem_exists(PyUiItem *self)
Definition: pythonUi.cpp:1430
Definition: pythonUi.h:62
This class provides the possibility to redirect any signal emitted in an user-defined GUI to differen...
Definition: pythonQtSignalMapper.h:203
Definition: pythonUi.h:50
Definition: pythonUi.h:39