bar_python.cpp
00001 /**************************************************************************** 00002 * bar_python.cpp - Functions for bar python api 00003 * 00004 * Copyright (c) 2004 Petri Damstén <damu@iki.fi> 00005 * 00006 * This file is part of SuperKaramba. 00007 * 00008 * SuperKaramba is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * SuperKaramba is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with SuperKaramba; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 ****************************************************************************/ 00022 00023 #ifdef _XOPEN_SOURCE 00024 #undef _XOPEN_SOURCE 00025 #endif 00026 00027 #include <Python.h> 00028 #include <tqobject.h> 00029 #include "karamba.h" 00030 #include "meter.h" 00031 #include "meter_python.h" 00032 #include "bar_python.h" 00033 00034 PyObject* py_createBar(PyObject *, PyObject *args) 00035 { 00036 long widget, x, y, w, h; 00037 char *text; 00038 if (!PyArg_ParseTuple(args, (char*)"lllll|s", &widget, &x, &y, &w, &h, &text)) 00039 return NULL; 00040 if (!checkKaramba(widget)) 00041 return NULL; 00042 00043 Bar *tmp = new Bar((karamba*)widget, x,y,w,h); 00044 if (text && text[0] != '\0') 00045 tmp->setImage(text); 00046 ((karamba*)widget)->meterList->append(tmp); 00047 return (Py_BuildValue((char*)"l", (long)tmp)); 00048 } 00049 00050 PyObject* py_deleteBar(PyObject *, PyObject *args) 00051 { 00052 long widget, meter; 00053 if (!PyArg_ParseTuple(args, (char*)"ll", &widget, &meter)) 00054 return NULL; 00055 if (!checkKarambaAndMeter(widget, meter, "Bar")) 00056 return NULL; 00057 00058 ((karamba*)widget)->deleteMeterFromSensors((Meter*)meter); 00059 return Py_BuildValue((char*)"l", 00060 ((karamba*)widget)->meterList->removeRef((Meter*)meter)); 00061 } 00062 00063 PyObject* py_getThemeBar(PyObject *self, PyObject *args) 00064 { 00065 return py_getThemeMeter(self, args, "Bar"); 00066 } 00067 00068 PyObject* py_getBarSize(PyObject *self, PyObject *args) 00069 { 00070 return py_getSize(self, args, "Bar"); 00071 } 00072 00073 PyObject* py_resizeBar(PyObject *self, PyObject *args) 00074 { 00075 return py_resize(self, args, "Bar"); 00076 } 00077 00078 PyObject* py_getBarPos(PyObject *self, PyObject *args) 00079 { 00080 return py_getPos(self, args, "Bar"); 00081 } 00082 00083 PyObject* py_moveBar(PyObject *self, PyObject *args) 00084 { 00085 return py_move(self, args, "Bar"); 00086 } 00087 00088 PyObject* py_hideBar(PyObject *self, PyObject *args) 00089 { 00090 return py_hide(self, args, "Bar"); 00091 } 00092 00093 PyObject* py_showBar(PyObject *self, PyObject *args) 00094 { 00095 return py_show(self, args, "Bar"); 00096 } 00097 00098 PyObject* py_getBarMinMax(PyObject *self, PyObject *args) 00099 { 00100 return py_getMinMax(self, args, "Bar"); 00101 } 00102 00103 PyObject* py_setBarMinMax(PyObject *self, PyObject *args) 00104 { 00105 return py_setMinMax(self, args, "Bar"); 00106 } 00107 00108 PyObject* py_getBarValue(PyObject *self, PyObject *args) 00109 { 00110 return py_getValue(self, args, "Bar"); 00111 } 00112 00113 PyObject* py_setBarValue(PyObject *self, PyObject *args) 00114 { 00115 return py_setValue(self, args, "Bar"); 00116 } 00117 00118 PyObject* py_getBarSensor(PyObject *self, PyObject *args) 00119 { 00120 return py_getSensor(self, args, "Bar"); 00121 } 00122 00123 PyObject* py_setBarSensor(PyObject *self, PyObject *args) 00124 { 00125 return py_setSensor(self, args, "Bar"); 00126 } 00127 00128 PyObject* py_getBarImage(PyObject *, PyObject *args) 00129 { 00130 long widget, meter; 00131 if (!PyArg_ParseTuple(args, (char*)"ll", &widget, &meter)) 00132 return NULL; 00133 if (!checkKarambaAndMeter(widget, meter, "Bar")) 00134 return NULL; 00135 return Py_BuildValue((char*)"s", ((Bar*)meter)->getImage().ascii()); 00136 } 00137 00138 PyObject* py_setBarImage(PyObject *, PyObject *args) 00139 { 00140 long widget, meter; 00141 char* s; 00142 if (!PyArg_ParseTuple(args, (char*)"lls", &widget, &meter, &s)) 00143 return NULL; 00144 if (!checkKarambaAndMeter(widget, meter, "Bar")) 00145 return NULL; 00146 return Py_BuildValue((char*)"l", ((Bar*)meter)->setImage(s)); 00147 } 00148 00149 PyObject* py_getBarVertical(PyObject *, PyObject *args) 00150 { 00151 long widget, meter; 00152 if (!PyArg_ParseTuple(args, (char*)"ll", &widget, &meter)) 00153 return NULL; 00154 if (!checkKarambaAndMeter(widget, meter, "Bar")) 00155 return NULL; 00156 return Py_BuildValue((char*)"l", ((Bar*)meter)->getVertical()); 00157 } 00158 00159 PyObject* py_setBarVertical(PyObject *, PyObject *args) 00160 { 00161 long widget, meter, l; 00162 if (!PyArg_ParseTuple(args, (char*)"lll", &widget, &meter, &l)) 00163 return NULL; 00164 if (!checkKarambaAndMeter(widget, meter, "Bar")) 00165 return NULL; 00166 ((Bar*)meter)->setVertical(l); 00167 return Py_BuildValue((char*)"l", 1); 00168 }