itom 2.2.1
K:/git-itom/sources/itom/Qitom/python/pythonUi.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2016, Institut fuer Technische Optik (ITO),
00005     Universitaet Stuttgart, Germany
00006 
00007     This file is part of itom.
00008   
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013 
00014     itom is distributed in the hope that it will be useful, but
00015     WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00017     General Public Licence for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with itom. If not, see <http://www.gnu.org/licenses/>.
00021 *********************************************************************** */
00022 
00023 #ifndef PYTHONUI_H
00024 #define PYTHONUI_H
00025 
00026 #include "pythonCommon.h"
00027 #include "pythonQtConversion.h"
00028 #include "pythonQtSignalMapper.h"
00029 #include "pythonItomMetaObject.h"
00030 
00031 #include <qstring.h>
00032 #include <qvariant.h>
00033 #include <qobject.h>
00034 #include <qhash.h>
00035 
00036 namespace ito 
00037 {
00038 
00039 class PythonUi
00040 {
00041 public:
00042 
00043     //#################################################################################################
00044     // UiItem
00045     //################################################################################################# 
00046 
00047     //-------------------------------------------------------------------------------------------------
00048     // typedefs
00049     //------------------------------------------------------------------------------------------------- 
00050     typedef struct
00051     {
00052         PyObject_HEAD
00053         PyObject *baseItem; //parent UiItem (e.g. the whole dialog), NULL if no parent.
00054         char* objName;          //object name of corresponding widget in UI
00055         char* widgetClassName;  //class name of corresponding widget in UI
00056         unsigned int objectID;  //itom internal ID of hashed meta object of this widget (for communication with uiOrganizer)
00057         const MethodDescriptionList* methodList; //borrowed pointer to an item in methodDescriptionListStorage.
00058         PyObject *weakreflist;
00059     }
00060     PyUiItem;
00061 
00062     typedef struct
00063     {
00064         PyUiItem uiItem;
00065         int uiHandle;
00066         int winType;
00067         int buttonBarType;
00068         bool childOfMainWindow;
00069         bool deleteOnClose;
00070         PyObject *dialogButtons;
00071         char* filename;
00072         PythonQtSignalMapper *signalMapper;
00073     }
00074     PyUi;
00075     
00076 
00077     //-------------------------------------------------------------------------------------------------
00078     // constructor, deconstructor, alloc, dellaoc
00079     //------------------------------------------------------------------------------------------------- 
00080     static void PyUiItem_dealloc(PyUiItem *self);
00081     static PyObject *PyUiItem_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
00082     static int PyUiItem_init(PyUiItem *self, PyObject *args, PyObject *kwds);
00083 
00084     //-------------------------------------------------------------------------------------------------
00085     // mapping members
00086     //-------------------------------------------------------------------------------------------------
00087     static int PyUiItem_mappingLength(PyUiItem* self);
00088     static PyObject* PyUiItem_mappingGetElem(PyUiItem* self, PyObject* key);
00089     static int PyUiItem_mappingSetElem(PyUiItem* self, PyObject* key, PyObject* value);
00090 
00091     //-------------------------------------------------------------------------------------------------
00092     // general members
00093     //------------------------------------------------------------------------------------------------- 
00094     static PyObject* PyUiItem_repr(PyUiItem *self);
00095     static PyObject* PyUiItem_call(PyUiItem *self, PyObject* args);
00096     static PyObject* PyUiItem_connect(PyUiItem *self, PyObject* args);
00097     static PyObject* PyUiItem_connectKeyboardInterrupt(PyUiItem *self, PyObject* args);
00098     static PyObject* PyUiItem_disconnect(PyUiItem *self, PyObject* args);
00099     static PyObject* PyUiItem_getProperties(PyUiItem *self, PyObject *args);
00100     static PyObject* PyUiItem_setProperties(PyUiItem *self, PyObject *args);
00101     static PyObject *PyUiItem_getPropertyInfo(PyUiItem *self, PyObject *args);
00102     static PyObject* PyUiItem_getattro(PyUiItem *self, PyObject *name);
00103     static int       PyUiItem_setattro(PyUiItem *self, PyObject *name, PyObject *value);
00104 
00105     static PyObject* PyUiItem_setAttribute(PyUiItem *self, PyObject *args);
00106     static PyObject* PyUiItem_getAttribute(PyUiItem *self, PyObject *args);
00107 
00108     static PyObject* PyUiItem_setWindowFlags(PyUiItem *self, PyObject *args);
00109     static PyObject* PyUiItem_getWindowFlags(PyUiItem *self);
00110 
00111     static PyObject* PyUiItem_info(PyUiItem *self, PyObject *args);
00112     static PyObject* PyUiItem_exists(PyUiItem *self);
00113     static PyObject* PyUiItem_children(PyUiItem *self, PyObject *args, PyObject *kwds);
00114 
00115     //-------------------------------------------------------------------------------------------------
00116     // helpers
00117     //------------------------------------------------------------------------------------------------- 
00118     static bool loadMethodDescriptionList(PyUiItem *self);
00119     static PythonQtSignalMapper* PyUiItem_getTopLevelSignalMapper(PyUiItem *self);
00120 
00121     //-------------------------------------------------------------------------------------------------
00122     // type structures
00123     //------------------------------------------------------------------------------------------------- 
00124     static PyMemberDef  PyUiItem_members[];
00125     static PyGetSetDef  PyUiItem_getseters[];
00126     static PyMethodDef  PyUiItem_methods[];
00127     static PyTypeObject PyUiItemType;
00128     static PyModuleDef  PyUiItemModule;
00129     static PyMappingMethods PyUiItem_mappingProtocol;
00130     static void PyUiItem_addTpDict(PyObject *tp_dict);
00131 
00132 
00133 
00134     //#################################################################################################
00135     // Ui
00136     //################################################################################################# 
00137     
00138 
00139     //-------------------------------------------------------------------------------------------------
00140     // constructor, deconstructor, alloc, dellaoc
00141     //------------------------------------------------------------------------------------------------- 
00142     static void PyUi_dealloc(PyUi *self);
00143     static PyObject *PyUi_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
00144     static int PyUi_init(PyUi *self, PyObject *args, PyObject *kwds);
00145 
00146     //-------------------------------------------------------------------------------------------------
00147     // general members
00148     //------------------------------------------------------------------------------------------------- 
00149     static PyObject* PyUi_repr(PyUi *self);
00150 
00151     static PyObject *PyUi_show(PyUi *self, PyObject *args);
00152     static PyObject *PyUi_hide(PyUi *self);
00153     static PyObject *PyUi_isVisible(PyUi *self);
00154 
00155     static PyObject *PyUi_getPropertyInfo(PyUi *self, PyObject *args);
00156     static PyObject *PyUi_getProperties(PyUi *self, PyObject *args);
00157     static PyObject *PyUi_setProperties(PyUi *self, PyObject *args);
00158 
00159     //-------------------------------------------------------------------------------------------------
00160     // static members
00161     //-------------------------------------------------------------------------------------------------
00162     static PyObject* PyUi_getDouble(PyUi *self, PyObject *args, PyObject *kwds);
00163     static PyObject* PyUi_getInt(PyUi *self, PyObject *args, PyObject *kwds);
00164     static PyObject* PyUi_getItem(PyUi *self, PyObject *args, PyObject *kwds);
00165     static PyObject* PyUi_getText(PyUi *self, PyObject *args, PyObject *kwds);
00166 
00167     static PyObject* PyUi_msgInformation(PyUi *self, PyObject *args, PyObject *kwds);
00168     static PyObject* PyUi_msgQuestion(PyUi *self, PyObject *args, PyObject *kwds);
00169     static PyObject* PyUi_msgWarning(PyUi *self, PyObject *args, PyObject *kwds);
00170     static PyObject* PyUi_msgCritical(PyUi *self, PyObject *args, PyObject *kwds);
00171     static PyObject* PyUi_msgGeneral(PyUi *self, PyObject *args, PyObject *kwds, int type);
00172 
00173     static PyObject* PyUi_getExistingDirectory(PyUi *self, PyObject *args, PyObject *kwds);
00174     static PyObject* PyUi_getOpenFileNames(PyUi *self, PyObject *args, PyObject *kwds);
00175     static PyObject* PyUi_getOpenFileName(PyUi *self, PyObject *args, PyObject *kwds);
00176     static PyObject* PyUi_getSaveFileName(PyUi *self, PyObject *args, PyObject *kwds);
00177 
00178     static PyObject* PyUi_createNewAlgoWidget(PyUi *self, PyObject *args, PyObject *kwds);
00179     static PyObject* PyUi_createNewAlgoWidget2(PyUi *self, PyObject *args, PyObject *kwds);
00180     static PyObject *PyUi_availableWidgets(PyUi *self);
00181 
00182     //-------------------------------------------------------------------------------------------------
00183     // type structures
00184     //------------------------------------------------------------------------------------------------- 
00185     static PyGetSetDef  PyUi_getseters[];
00186     static PyMemberDef  PyUi_members[];
00187     static PyMethodDef  PyUi_methods[];
00188     static PyTypeObject PyUiType;
00189     static PyModuleDef  PyUiModule;
00190     static void PyUi_addTpDict(PyObject *tp_dict);
00191 
00192     //-------------------------------------------------------------------------------------------------
00193     // macros
00194     //------------------------------------------------------------------------------------------------- 
00195     #define PyUiItem_Check(op) PyObject_TypeCheck(op, &ito::PythonUi::PyUiItemType)
00196     #define PyUi_Check(op) PyObject_TypeCheck(op, &ito::PythonUi::PyUiType)
00197 
00198 private:
00199     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
00200 };
00201 
00202 }; //end namespace ito
00203 
00204 
00205 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Friends