itom 2.0.0
D:/git-itom/sources/itom/Qitom/python/pythonUi.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2013, Institut für Technische Optik (ITO),
00005     Universität 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 PythonUi::PyUi* PyUiItem_getParentUI(PyUiItem *self);
00120     static PythonQtSignalMapper* PyUiItem_getTopLevelSignalMapper(PyUiItem *self);
00121 
00122     //-------------------------------------------------------------------------------------------------
00123     // type structures
00124     //------------------------------------------------------------------------------------------------- 
00125     static PyMemberDef  PyUiItem_members[];
00126     static PyGetSetDef  PyUiItem_getseters[];
00127     static PyMethodDef  PyUiItem_methods[];
00128     static PyTypeObject PyUiItemType;
00129     static PyModuleDef  PyUiItemModule;
00130     static PyMappingMethods PyUiItem_mappingProtocol;
00131     static void PyUiItem_addTpDict(PyObject *tp_dict);
00132 
00133 
00134 
00135     //#################################################################################################
00136     // Ui
00137     //################################################################################################# 
00138     
00139 
00140     //-------------------------------------------------------------------------------------------------
00141     // constructor, deconstructor, alloc, dellaoc
00142     //------------------------------------------------------------------------------------------------- 
00143     static void PyUi_dealloc(PyUi *self);
00144     static PyObject *PyUi_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
00145     static int PyUi_init(PyUi *self, PyObject *args, PyObject *kwds);
00146 
00147     //-------------------------------------------------------------------------------------------------
00148     // general members
00149     //------------------------------------------------------------------------------------------------- 
00150     static PyObject* PyUi_repr(PyUi *self);
00151 
00152     static PyObject *PyUi_show(PyUi *self, PyObject *args);
00153     static PyObject *PyUi_hide(PyUi *self);
00154     static PyObject *PyUi_isVisible(PyUi *self);
00155 
00156     static PyObject *PyUi_getPropertyInfo(PyUi *self, PyObject *args);
00157     static PyObject *PyUi_getProperties(PyUi *self, PyObject *args);
00158     static PyObject *PyUi_setProperties(PyUi *self, PyObject *args);
00159 
00160     //-------------------------------------------------------------------------------------------------
00161     // static members
00162     //-------------------------------------------------------------------------------------------------
00163     static PyObject* PyUi_getDouble(PyUi *self, PyObject *args, PyObject *kwds);
00164     static PyObject* PyUi_getInt(PyUi *self, PyObject *args, PyObject *kwds);
00165     static PyObject* PyUi_getItem(PyUi *self, PyObject *args, PyObject *kwds);
00166     static PyObject* PyUi_getText(PyUi *self, PyObject *args, PyObject *kwds);
00167 
00168     static PyObject* PyUi_msgInformation(PyUi *self, PyObject *args, PyObject *kwds);
00169     static PyObject* PyUi_msgQuestion(PyUi *self, PyObject *args, PyObject *kwds);
00170     static PyObject* PyUi_msgWarning(PyUi *self, PyObject *args, PyObject *kwds);
00171     static PyObject* PyUi_msgCritical(PyUi *self, PyObject *args, PyObject *kwds);
00172     static PyObject* PyUi_msgGeneral(PyUi *self, PyObject *args, PyObject *kwds, int type);
00173 
00174     static PyObject* PyUi_getExistingDirectory(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 
00180     //-------------------------------------------------------------------------------------------------
00181     // type structures
00182     //------------------------------------------------------------------------------------------------- 
00183     static PyGetSetDef  PyUi_getseters[];
00184     static PyMemberDef  PyUi_members[];
00185     static PyMethodDef  PyUi_methods[];
00186     static PyTypeObject PyUiType;
00187     static PyModuleDef  PyUiModule;
00188     static void PyUi_addTpDict(PyObject *tp_dict);
00189 
00190     //-------------------------------------------------------------------------------------------------
00191     // macros
00192     //------------------------------------------------------------------------------------------------- 
00193     #define PyUiItem_Check(op) PyObject_TypeCheck(op, &ito::PythonUi::PyUiItemType)
00194     #define PyUi_Check(op) PyObject_TypeCheck(op, &ito::PythonUi::PyUiType)
00195 
00196 private:
00197     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
00198 };
00199 
00200 }; //end namespace ito
00201 
00202 
00203 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends