• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeutils
  • Sitemap
  • Contact Us
 

superkaramba

input.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 *  input_python.cpp  -  Functions for input box 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� <damu@iki.fi>
00007 *  Copyright (c) 2005 Alexander Wiedenbruch <mail@wiedenbruch.de>
00008 *
00009 *  This file is part of SuperKaramba.
00010 *
00011 *  SuperKaramba is free software; you can redistribute it and/or modify
00012 *  it under the terms of the GNU General Public License as published by
00013 *  the Free Software Foundation; either version 2 of the License, or
00014 *  (at your option) any later version.
00015 *
00016 *  SuperKaramba is distributed in the hope that it will be useful,
00017 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 *  GNU General Public License for more details.
00020 *
00021 *  You should have received a copy of the GNU General Public License
00022 *  along with SuperKaramba; if not, write to the Free Software
00023 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00024 ****************************************************************************/
00025 
00026 #ifdef _XOPEN_SOURCE
00027 #undef _XOPEN_SOURCE
00028 #endif
00029 
00030 #include <Python.h>
00031 
00032 #include <QObject>
00033 #include <QGraphicsScene>
00034 
00035 #include "meters/meter.h"
00036 #include "meters/input.h"
00037 
00038 #include "python/meter.h"
00039 #include "python/input.h"
00040 
00041 #include "../karamba.h"
00042 
00043 PyObject* py_createInputBox(PyObject *, PyObject *args)
00044 {
00045     long widget, x, y, w, h;
00046     PyObject *text;
00047     if (!PyArg_ParseTuple(args, (char*)"lllllO:createInputBox", &widget, &x, &y, &w, &h, &text))
00048         return NULL;
00049 
00050     if (!checkKaramba(widget))
00051         return NULL;
00052 
00053     Input *tmp = new Input((Karamba*)widget, (int)x, (int)y, (int)w, (int)h);
00054     tmp->setValue(PyString2QString(text));
00055     tmp->setTextProps(((Karamba*)widget)->getDefaultTextProps());
00056     ((Karamba*)widget)->addToGroup(tmp);
00057     tmp->show();
00058 
00059     return (Py_BuildValue((char*)"l", (long)tmp));
00060 }
00061 
00062 PyObject* py_deleteInputBox(PyObject *, PyObject *args)
00063 {
00064     long widget, meter;
00065     if (!PyArg_ParseTuple(args, (char*)"ll:deleteInputBox", &widget, &meter))
00066         return NULL;
00067 
00068     if (!checkKarambaAndMeter(widget, meter, "Input"))
00069         return NULL;
00070 
00071     bool result = ((Karamba*)widget)->removeMeter((Meter*)meter);
00072 
00073     return Py_BuildValue((char*)"l", result);
00074 }
00075 
00076 PyObject* py_getThemeInputBox(PyObject *self, PyObject *args)
00077 {
00078     return py_getThemeMeter(self, args, "Input");
00079 }
00080 
00081 PyObject* py_getInputBoxValue(PyObject *self, PyObject *args)
00082 {
00083     return py_getStringValue(self, args, "Input");
00084 }
00085 
00086 PyObject* py_setInputBoxValue(PyObject *self, PyObject *args)
00087 {
00088     return py_setStringValue(self, args, "Input");
00089 }
00090 
00091 PyObject* py_hideInputBox(PyObject *self, PyObject *args)
00092 {
00093     return py_hide(self, args, "Input");
00094 }
00095 
00096 PyObject* py_showInputBox(PyObject *self, PyObject *args)
00097 {
00098     return py_show(self, args, "Input");
00099 }
00100 
00101 PyObject* py_getInputBoxPos(PyObject *self, PyObject *args)
00102 {
00103     return py_getPos(self, args, "Input");
00104 }
00105 
00106 PyObject* py_moveInputBox(PyObject *self, PyObject *args)
00107 {
00108     return py_move(self, args, "Input");
00109 }
00110 
00111 PyObject* py_getInputBoxSize(PyObject *self, PyObject *args)
00112 {
00113     return py_getSize(self, args, "Input");
00114 }
00115 
00116 PyObject* py_resizeInputBox(PyObject *self, PyObject *args)
00117 {
00118     return py_resize(self, args, "Input");
00119 }
00120 
00121 PyObject* py_setInputBoxFont(PyObject *, PyObject *args)
00122 {
00123     long widget, inputBox;
00124     char* text;
00125     if (!PyArg_ParseTuple(args, (char*)"lls:changeInputBoxFont",
00126                           &widget, &inputBox, &text))
00127         return NULL;
00128 
00129     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00130         return NULL;
00131 
00132     ((Input*)inputBox)->setFont(text);
00133     return Py_BuildValue((char*)"l", 1);
00134 }
00135 
00136 PyObject* py_getInputBoxFont(PyObject *, PyObject *args)
00137 {
00138     long widget, inputBox;
00139     if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxFont", &widget, &inputBox))
00140         return NULL;
00141 
00142     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00143         return NULL;
00144 
00145     return Py_BuildValue((char*)"s", ((Input*)inputBox)->getFont().toAscii().constData());
00146 }
00147 
00148 PyObject* py_setInputBoxFontColor(PyObject *, PyObject *args)
00149 {
00150     long widget, inputBox;
00151     long r, g, b;
00152     if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxFontColor", &widget, &inputBox, &r, &g, &b))
00153         return NULL;
00154 
00155     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00156         return NULL;
00157 
00158     ((Input*)inputBox)->setFontColor(QColor(r, g, b));
00159     return Py_BuildValue((char*)"l", 1);
00160 }
00161 
00162 PyObject* py_getInputBoxFontColor(PyObject *, PyObject *args)
00163 {
00164     long widget, inputBox;
00165     if (!PyArg_ParseTuple(args, (char*)"ll:changeInputBoxFontColor", &widget, &inputBox))
00166         return NULL;
00167 
00168     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00169         return NULL;
00170 
00171     QColor color = ((Input*)inputBox)->getFontColor();
00172     return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
00173 }
00174 
00175 PyObject* py_setInputBoxSelectionColor(PyObject *, PyObject *args)
00176 {
00177     long widget, inputBox;
00178     long r, g, b;
00179     if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxSelectionColor", &widget, &inputBox, &r, &g, &b))
00180         return NULL;
00181 
00182     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00183         return NULL;
00184 
00185     ((Input*)inputBox)->setSelectionColor(QColor(r, g, b));
00186     return Py_BuildValue((char*)"l", 1);
00187 }
00188 
00189 PyObject* py_getInputBoxSelectionColor(PyObject *, PyObject *args)
00190 {
00191     long widget, inputBox;
00192     if (!PyArg_ParseTuple(args, (char*)"ll:changeInputBoxSelectionColor", &widget, &inputBox))
00193         return NULL;
00194 
00195     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00196         return NULL;
00197 
00198     QColor color = ((Input*)inputBox)->getSelectionColor();
00199     return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
00200 }
00201 
00202 PyObject* py_setInputBoxBGColor(PyObject *, PyObject *args)
00203 {
00204     long widget, inputBox;
00205     long r, g, b;
00206     if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxBackgroundColor", &widget, &inputBox, &r, &g, &b))
00207         return NULL;
00208 
00209     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00210         return NULL;
00211 
00212     ((Input*)inputBox)->setBGColor(QColor(r, g, b));
00213     return Py_BuildValue((char*)"l", 1);
00214 }
00215 
00216 PyObject* py_getInputBoxBGColor(PyObject *, PyObject *args)
00217 {
00218     long widget, inputBox;
00219     if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxBackgroundColor", &widget, &inputBox))
00220         return NULL;
00221 
00222     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00223         return NULL;
00224 
00225     QColor color = ((Input*)inputBox)->getBGColor();
00226     return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
00227 }
00228 
00229 PyObject* py_setInputBoxFrameColor(PyObject *, PyObject *args)
00230 {
00231     long widget, inputBox;
00232     long r, g, b;
00233     if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxFrameColor", &widget, &inputBox, &r, &g, &b))
00234         return NULL;
00235 
00236     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00237         return NULL;
00238 
00239     ((Input*)inputBox)->setColor(QColor(r, g, b));
00240     return Py_BuildValue((char*)"l", 1);
00241 }
00242 
00243 PyObject* py_getInputBoxFrameColor(PyObject *, PyObject *args)
00244 {
00245     long widget, inputBox;
00246     if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxFrameColor", &widget, &inputBox))
00247         return NULL;
00248 
00249     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00250         return NULL;
00251 
00252     QColor color = ((Input*)inputBox)->getColor();
00253     return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
00254 }
00255 
00256 PyObject* py_setInputBoxSelectedTextColor(PyObject *, PyObject *args)
00257 {
00258     long widget, inputBox;
00259     long r, g, b;
00260     if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxSelectedTextColor", &widget, &inputBox, &r, &g, &b))
00261         return NULL;
00262 
00263     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00264         return NULL;
00265 
00266     ((Input*)inputBox)->setSelectedTextColor(QColor(r, g, b));
00267     return Py_BuildValue((char*)"l", 1);
00268 }
00269 
00270 PyObject* py_getInputBoxSelectedTextColor(PyObject *, PyObject *args)
00271 {
00272     long widget, inputBox;
00273     if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxSelectedTextColor", &widget, &inputBox))
00274         return NULL;
00275 
00276     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00277         return NULL;
00278 
00279     QColor color = ((Input*)inputBox)->getSelectedTextColor();
00280     return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
00281 }
00282 
00283 PyObject* py_setInputBoxFontSize(PyObject *, PyObject *args)
00284 {
00285     long widget, inputBox;
00286     long size;
00287     if (!PyArg_ParseTuple(args, (char*)"lll:changeInputBoxFontSize",
00288                           &widget, &inputBox, &size))
00289         return NULL;
00290 
00291     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00292         return NULL;
00293 
00294     ((Input*)inputBox)->setFontSize(size);
00295     return Py_BuildValue((char*)"l", 1);
00296 }
00297 
00298 PyObject* py_getInputBoxFontSize(PyObject *, PyObject *args)
00299 {
00300     long widget, inputBox;
00301     if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxFontSize", &widget, &inputBox))
00302         return NULL;
00303 
00304     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00305         return NULL;
00306 
00307     return Py_BuildValue((char*)"l", ((Input*)inputBox)->getFontSize());
00308 }
00309 
00310 PyObject* py_setInputFocus(PyObject *, PyObject *args)
00311 {
00312     long widget, inputBox;
00313     if (!PyArg_ParseTuple(args, (char*)"ll:setInputFocus", &widget, &inputBox))
00314         return NULL;
00315 
00316     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00317         return NULL;
00318 
00319     //((Karamba*)widget)->setActiveWindow();
00320 
00321     ((Input*)inputBox)->setInputFocus();
00322     return Py_BuildValue((char*)"l", 1);
00323 }
00324 
00325 PyObject* py_clearInputFocus(PyObject *, PyObject *args)
00326 {
00327     long widget, inputBox;
00328     if (!PyArg_ParseTuple(args, (char*)"ll:clearInputFocus", &widget, &inputBox))
00329         return NULL;
00330 
00331     if (!checkKarambaAndMeter(widget, inputBox, "Input"))
00332         return NULL;
00333 
00334     ((Input*)inputBox)->clearInputFocus();
00335     return Py_BuildValue((char*)"l", 1);
00336 }
00337 
00338 PyObject* py_getInputFocus(PyObject *, PyObject *args)
00339 {
00340     long widget;
00341     if (!PyArg_ParseTuple(args, (char*)"l:getInputFocus", &widget))
00342         return NULL;
00343 
00344     if (!checkKaramba(widget))
00345         return NULL;
00346 
00347     Karamba *k = (Karamba*)widget;
00348     QGraphicsItem *focusItem = k->getScene()->focusItem();
00349     if (Input *input = dynamic_cast<Input*>(focusItem))
00350         return Py_BuildValue((char*)"l", input);
00351 
00352     return Py_BuildValue((char*)"l", 0);
00353 }

superkaramba

Skip menu "superkaramba"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdelirc
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • kjots
  • klaptopdaemon
  • kmilo
  • ksim
  • ktimer
  • kwallet
  • superkaramba
Generated for kdeutils by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal