textlabel_python.cpp
00001 /**************************************************************************** 00002 * textlabel_python.cpp - Functions for textlabel python api 00003 * 00004 * Copyright (C) 2003 Hans Karlsson <karlsson.h@home.se> 00005 * Copyright (C) 2003-2004 Adam Geitgey <adam@rootnode.org> 00006 * Copyright (c) 2004 Petri Damstén <damu@iki.fi> 00007 * 00008 * This file is part of SuperKaramba. 00009 * 00010 * SuperKaramba is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * SuperKaramba is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with SuperKaramba; if not, write to the Free Software 00022 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00023 ****************************************************************************/ 00024 00025 #ifdef _XOPEN_SOURCE 00026 #undef _XOPEN_SOURCE 00027 #endif 00028 00029 #include <Python.h> 00030 #include <tqobject.h> 00031 #include "karamba.h" 00032 #include "textlabel.h" 00033 #include "meter_python.h" 00034 #include "textlabel_python.h" 00035 00036 PyObject* py_createText(PyObject *, PyObject *args) 00037 { 00038 long widget, x, y, w, h; 00039 PyObject *text; 00040 if (!PyArg_ParseTuple(args, (char*)"lllllO:createText", &widget, &x, &y, &w, &h, &text)) 00041 return NULL; 00042 if (!checkKaramba(widget)) 00043 return NULL; 00044 TextLabel *tmp = 00045 new TextLabel((karamba*)widget, (int)x, (int)y, (int)w, (int)h); 00046 tmp->setValue(PyString2TQString(text)); 00047 tmp->setTextProps(((karamba*)widget)->getDefaultTextProps()); 00048 ((karamba*)widget)->meterList->append(tmp); 00049 return (Py_BuildValue((char*)"l", (long)tmp)); 00050 } 00051 00052 PyObject* py_deleteText(PyObject *, PyObject *args) 00053 { 00054 long widget, meter; 00055 if (!PyArg_ParseTuple(args, (char*)"ll:deleteText", &widget, &meter)) 00056 return NULL; 00057 if (!checkKarambaAndMeter(widget, meter, "TextLabel")) 00058 return NULL; 00059 00060 ((karamba*)widget)->deleteMeterFromSensors((Meter*)meter); 00061 ((karamba*)widget)->clickList->removeRef((Meter*)meter); 00062 return Py_BuildValue((char*)"l", 00063 ((karamba*)widget)->meterList->removeRef((Meter*)meter)); 00064 } 00065 00066 PyObject* py_getThemeText(PyObject *self, PyObject *args) 00067 { 00068 return py_getThemeMeter(self, args, "TextLabel"); 00069 } 00070 00071 PyObject* py_getTextSize(PyObject *self, PyObject *args) 00072 { 00073 return py_getSize(self, args, "TextLabel"); 00074 } 00075 00076 PyObject* py_resizeText(PyObject *self, PyObject *args) 00077 { 00078 return py_resize(self, args, "TextLabel"); 00079 } 00080 00081 PyObject* py_getTextPos(PyObject *self, PyObject *args) 00082 { 00083 return py_getPos(self, args, "TextLabel"); 00084 } 00085 00086 PyObject* py_moveText(PyObject *self, PyObject *args) 00087 { 00088 return py_move(self, args, "TextLabel"); 00089 } 00090 00091 PyObject* py_hideText(PyObject *self, PyObject *args) 00092 { 00093 return py_hide(self, args, "TextLabel"); 00094 } 00095 00096 PyObject* py_showText(PyObject *self, PyObject *args) 00097 { 00098 return py_show(self, args, "TextLabel"); 00099 } 00100 00101 PyObject* py_getTextValue(PyObject *self, PyObject *args) 00102 { 00103 return py_getStringValue(self, args, "TextLabel"); 00104 } 00105 00106 PyObject* py_setTextValue(PyObject *self, PyObject *args) 00107 { 00108 return py_setStringValue(self, args, "TextLabel"); 00109 } 00110 00111 PyObject* py_getTextSensor(PyObject *self, PyObject *args) 00112 { 00113 return py_getSensor(self, args, "TextLabel"); 00114 } 00115 00116 PyObject* py_setTextSensor(PyObject *self, PyObject *args) 00117 { 00118 return py_setSensor(self, args, "TextLabel"); 00119 } 00120 00121 PyObject* py_getTextColor(PyObject *self, PyObject *args) 00122 { 00123 return py_getColor(self, args, "TextLabel"); 00124 } 00125 00126 PyObject* py_setTextColor(PyObject *self, PyObject *args) 00127 { 00128 return py_setColor(self, args, "TextLabel"); 00129 } 00130 00131 PyObject* py_setTextShadow(PyObject *, PyObject *args) 00132 { 00133 long widget, textSensor; 00134 long shadow; 00135 if (!PyArg_ParseTuple(args, (char*)"lll:changeTextShadow", 00136 &widget, &textSensor, &shadow)) 00137 return NULL; 00138 if (!checkKarambaAndMeter(widget, textSensor, "TextLabel")) 00139 return NULL; 00140 ((TextLabel*)textSensor)->setShadow( shadow ); 00141 return Py_BuildValue((char*)"l", 1); 00142 } 00143 00144 PyObject* py_getTextShadow(PyObject *, PyObject *args) 00145 { 00146 long widget, textSensor; 00147 if (!PyArg_ParseTuple(args, (char*)"ll:getTextShadow", &widget, &textSensor)) 00148 return NULL; 00149 if (!checkKarambaAndMeter(widget, textSensor, "TextLabel")) 00150 return NULL; 00151 return Py_BuildValue((char*)"l", ((TextLabel*)textSensor)->getShadow()); 00152 } 00153 00154 PyObject* py_setTextFontSize(PyObject *, PyObject *args) 00155 { 00156 long widget, textSensor; 00157 long size; 00158 if (!PyArg_ParseTuple(args, (char*)"lll:changeTextSize", 00159 &widget, &textSensor, &size)) 00160 return NULL; 00161 if (!checkKarambaAndMeter(widget, textSensor, "TextLabel")) 00162 return NULL; 00163 ((TextLabel*)textSensor)->setFontSize( size ); 00164 return Py_BuildValue((char*)"l", 1); 00165 } 00166 00167 PyObject* py_getTextFontSize(PyObject *, PyObject *args) 00168 { 00169 long widget, textSensor; 00170 if (!PyArg_ParseTuple(args, (char*)"ll:getTextSize", &widget, &textSensor)) 00171 return NULL; 00172 if (!checkKarambaAndMeter(widget, textSensor, "TextLabel")) 00173 return NULL; 00174 return Py_BuildValue((char*)"l", ((TextLabel*)textSensor)->getFontSize()); 00175 } 00176 00177 PyObject* py_setTextFont(PyObject *, PyObject *args) 00178 { 00179 long widget, textSensor; 00180 char* text; 00181 if (!PyArg_ParseTuple(args, (char*)"lls:changeTextFont", 00182 &widget, &textSensor, &text)) 00183 return NULL; 00184 if (!checkKarambaAndMeter(widget, textSensor, "TextLabel")) 00185 return NULL; 00186 ((TextLabel*)textSensor)->setFont( text ); 00187 return Py_BuildValue((char*)"l", 1); 00188 } 00189 00190 PyObject* py_getTextFont(PyObject *, PyObject *args) 00191 { 00192 long widget, textSensor; 00193 if (!PyArg_ParseTuple(args, (char*)"ll:getTextFont", &widget, &textSensor)) 00194 return NULL; 00195 if (!checkKarambaAndMeter(widget, textSensor, "TextLabel")) 00196 return NULL; 00197 return Py_BuildValue((char*)"s", ((TextLabel*)textSensor)->getFont().ascii()); 00198 } 00199 00200 PyObject* py_setTextAlign(PyObject *, PyObject *args) 00201 { 00202 long widget, textSensor; 00203 char* text; 00204 if (!PyArg_ParseTuple(args, (char*)"lls:changeTextFont", 00205 &widget, &textSensor, &text)) 00206 return NULL; 00207 if (!checkKarambaAndMeter(widget, textSensor, "TextLabel")) 00208 return NULL; 00209 ((TextLabel*)textSensor)->setAlignment( text ); 00210 return Py_BuildValue((char*)"l", 1); 00211 } 00212 00213 PyObject* py_getTextAlign(PyObject *, PyObject *args) 00214 { 00215 long widget, textSensor; 00216 if (!PyArg_ParseTuple(args, (char*)"ll:getTextFont", &widget, &textSensor)) 00217 return NULL; 00218 if (!checkKarambaAndMeter(widget, textSensor, "TextLabel")) 00219 return NULL; 00220 return Py_BuildValue((char*)"s", ((TextLabel*)textSensor)->getAlignment().ascii()); 00221 } 00222 00223 PyObject* py_setTextScroll(PyObject *, PyObject *args) 00224 { 00225 long widget, textSensor; 00226 char* type; 00227 int x=0, y=0, pause=0, gap=0; 00228 if (!PyArg_ParseTuple(args, (char*)"lls|llll:setScroll", 00229 &widget, &textSensor, &type, &x, &y, &gap, &pause)) 00230 return NULL; 00231 if (!checkKarambaAndMeter(widget, textSensor, "TextLabel")) 00232 return NULL; 00233 ((TextLabel*)textSensor)->setScroll(type, TQPoint(x,y), gap, pause); 00234 return Py_BuildValue((char*)"l", 1); 00235 }