itom 1.3.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);
00112 
00113     //-------------------------------------------------------------------------------------------------
00114     // helpers
00115     //------------------------------------------------------------------------------------------------- 
00116     static bool loadMethodDescriptionList(PyUiItem *self);
00117     //static PythonUi::PyUi* PyUiItem_getParentUI(PyUiItem *self);
00118     static PythonQtSignalMapper* PyUiItem_getTopLevelSignalMapper(PyUiItem *self);
00119 
00120     //-------------------------------------------------------------------------------------------------
00121     // type structures
00122     //------------------------------------------------------------------------------------------------- 
00123     static PyMemberDef  PyUiItem_members[];
00124     static PyGetSetDef  PyUiItem_getseters[];
00125     static PyMethodDef  PyUiItem_methods[];
00126     static PyTypeObject PyUiItemType;
00127     static PyModuleDef  PyUiItemModule;
00128     static PyMappingMethods PyUiItem_mappingProtocol;
00129     static void PyUiItem_addTpDict(PyObject *tp_dict);
00130 
00131 
00132 
00133     //#################################################################################################
00134     // Ui
00135     //################################################################################################# 
00136     
00137 
00138     //-------------------------------------------------------------------------------------------------
00139     // constructor, deconstructor, alloc, dellaoc
00140     //------------------------------------------------------------------------------------------------- 
00141     static void PyUi_dealloc(PyUi *self);
00142     static PyObject *PyUi_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
00143     static int PyUi_init(PyUi *self, PyObject *args, PyObject *kwds);
00144 
00145     //-------------------------------------------------------------------------------------------------
00146     // general members
00147     //------------------------------------------------------------------------------------------------- 
00148     static PyObject* PyUi_repr(PyUi *self);
00149 
00150     static PyObject *PyUi_show(PyUi *self, PyObject *args);
00151     static PyObject *PyUi_hide(PyUi *self);
00152     static PyObject *PyUi_isVisible(PyUi *self);
00153 
00154     static PyObject *PyUi_getPropertyInfo(PyUi *self, PyObject *args);
00155     static PyObject *PyUi_getProperties(PyUi *self, PyObject *args);
00156     static PyObject *PyUi_setProperties(PyUi *self, PyObject *args);
00157 
00158     //-------------------------------------------------------------------------------------------------
00159     // static members
00160     //-------------------------------------------------------------------------------------------------
00161     static PyObject* PyUi_getDouble(PyUi *self, PyObject *args, PyObject *kwds);
00162     static PyObject* PyUi_getInt(PyUi *self, PyObject *args, PyObject *kwds);
00163     static PyObject* PyUi_getItem(PyUi *self, PyObject *args, PyObject *kwds);
00164     static PyObject* PyUi_getText(PyUi *self, PyObject *args, PyObject *kwds);
00165 
00166     static PyObject* PyUi_msgInformation(PyUi *self, PyObject *args, PyObject *kwds);
00167     static PyObject* PyUi_msgQuestion(PyUi *self, PyObject *args, PyObject *kwds);
00168     static PyObject* PyUi_msgWarning(PyUi *self, PyObject *args, PyObject *kwds);
00169     static PyObject* PyUi_msgCritical(PyUi *self, PyObject *args, PyObject *kwds);
00170     static PyObject* PyUi_msgGeneral(PyUi *self, PyObject *args, PyObject *kwds, int type);
00171 
00172     static PyObject* PyUi_getExistingDirectory(PyUi *self, PyObject *args, PyObject *kwds);
00173     static PyObject* PyUi_getOpenFileName(PyUi *self, PyObject *args, PyObject *kwds);
00174     static PyObject* PyUi_getSaveFileName(PyUi *self, PyObject *args, PyObject *kwds);
00175 
00176     static PyObject* PyUi_createNewAlgoWidget(PyUi *self, PyObject *args, PyObject *kwds);
00177 
00178     //-------------------------------------------------------------------------------------------------
00179     // type structures
00180     //------------------------------------------------------------------------------------------------- 
00181     static PyGetSetDef  PyUi_getseters[];
00182     static PyMemberDef  PyUi_members[];
00183     static PyMethodDef  PyUi_methods[];
00184     static PyTypeObject PyUiType;
00185     static PyModuleDef  PyUiModule;
00186     static void PyUi_addTpDict(PyObject *tp_dict);
00187 
00188     //-------------------------------------------------------------------------------------------------
00189     // macros
00190     //------------------------------------------------------------------------------------------------- 
00191     #define PyUiItem_Check(op) PyObject_TypeCheck(op, &ito::PythonUi::PyUiItemType)
00192     #define PyUi_Check(op) PyObject_TypeCheck(op, &ito::PythonUi::PyUiType)
00193 
00194 private:
00195     static QHash<QByteArray, QSharedPointer<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
00196 };
00197 
00198 }; //end namespace ito
00199 
00200 
00201 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends