• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • superkaramba
 

superkaramba

widget_python.cpp
00001 /****************************************************************************
00002 *  widget_python.h  -  Functions for widget 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 "meter.h"
00033 #include "meter_python.h"
00034 #include "widget_python.h"
00035 
00036 /* now a method we need to expose to Python */
00037 int getWidgetXCoordinate(long widget)
00038 {
00039   karamba* currTheme = (karamba*)widget;
00040   return currTheme->x();
00041 }
00042 
00043 /* now a method we need to expose to Python */
00044 int getWidgetYCoordinate(long widget)
00045 {
00046   karamba* currTheme = (karamba*)widget;
00047   return currTheme->y();
00048 }
00049 
00050 PyObject* py_get_widget_position(PyObject *, PyObject *args)
00051 {
00052   long widget;
00053   if(!PyArg_ParseTuple(args, (char*)"l:getWidgetPosition", &widget))
00054     return NULL;
00055   if (!checkKaramba(widget))
00056     return NULL;
00057   return Py_BuildValue((char*)"(i,i)", getWidgetXCoordinate(widget),
00058                                 getWidgetYCoordinate(widget));
00059 }
00060 
00061 /* now a method we need to expose to Python */
00062 long createWidgetMask(long widget, char* path)
00063 {
00064   karamba* currTheme = (karamba*)widget;
00065   TQBitmap bm;
00066   TQString maskpath;
00067   TQString rootPath;
00068   rootPath.setAscii(currTheme->theme().path().ascii());
00069 
00070   currTheme->clearMask();
00071 
00072   maskpath.setAscii(path);
00073   rootPath.append(maskpath.ascii());
00074 
00075   if(currTheme->theme().isZipTheme())
00076   {
00077     TQByteArray ba = currTheme->theme().readThemeFile(path);
00078     bm.loadFromData(ba);
00079   }
00080   else
00081   {
00082     bm.load(rootPath);
00083   }
00084   currTheme->setMask(bm);
00085 
00086   return (long)currTheme->widgetMask;
00087 }
00088 
00089 PyObject* py_create_widget_mask(PyObject *, PyObject *args)
00090 {
00091   long widget;
00092   char *text;
00093   if (!PyArg_ParseTuple(args, (char*)"ls:createWidgetMask", &widget, &text))
00094     return NULL;
00095   if (!checkKaramba(widget))
00096     return NULL;
00097   return Py_BuildValue((char*)"l", createWidgetMask(widget, text));
00098 }
00099 
00100 /* now a method we need to expose to Python */
00101 long redrawWidgetBackground(long widget)
00102 {
00103   karamba* currTheme = (karamba*)widget;
00104   currTheme->kroot->repaint(true);
00105   return 1;
00106 }
00107 
00108 PyObject* py_redraw_widget_background(PyObject *, PyObject *args)
00109 {
00110   long widget;
00111   if (!PyArg_ParseTuple(args, (char*)"l:redrawWidgetBackground", &widget))
00112     return NULL;
00113   if (!checkKaramba(widget))
00114     return NULL;
00115   return Py_BuildValue((char*)"l", redrawWidgetBackground(widget));
00116 }
00117 
00118 /* now a method we need to expose to Python */
00119 long redrawWidget(long widget)
00120 {
00121   karamba* currTheme = (karamba*)widget;
00122   currTheme->externalStep();
00123   return 1;
00124 }
00125 
00126 PyObject* py_redraw_widget(PyObject *, PyObject *args)
00127 {
00128   long widget;
00129   if (!PyArg_ParseTuple(args, (char*)"l:redrawWidget", &widget))
00130     return NULL;
00131   if (!checkKaramba(widget))
00132     return NULL;
00133   return Py_BuildValue((char*)"l", redrawWidget(widget));
00134 }
00135 
00136 /* now a method we need to expose to Python */
00137 long resizeWidget(long widget, long x, long y)
00138 {
00139   karamba* currTheme = (karamba*)widget;
00140   //currTheme->test = true;
00141   currTheme->setFixedSize((int)x,(int)y);
00142   //currTheme->test = false;
00143   return 1;
00144 }
00145 
00146 PyObject* py_resize_widget(PyObject *, PyObject *args)
00147 {
00148   long widget, x, y;
00149   if (!PyArg_ParseTuple(args, (char*)"lll:resizeWidget", &widget, &x, &y))
00150     return NULL;
00151   if (!checkKaramba(widget))
00152     return NULL;
00153   return Py_BuildValue((char*)"l", resizeWidget(widget, x, y));
00154 }
00155 
00156 /* now a method we need to expose to Python */
00157 long moveWidget(long widget, long x, long y)
00158 {
00159   karamba* currTheme = (karamba*)widget;
00160   currTheme->move((int)x, (int)y);
00161   return 1;
00162 }
00163 
00164 PyObject* py_move_widget(PyObject *, PyObject *args)
00165 {
00166   long widget, x, y;
00167   if (!PyArg_ParseTuple(args, (char*)"lll:moveWidget", &widget, &x, &y))
00168     return NULL;
00169   if (!checkKaramba(widget))
00170     return NULL;
00171   return Py_BuildValue((char*)"l", moveWidget(widget, x, y));
00172 }
00173 
00174 /* now a method we need to expose to Python */
00175 long widgetSetOnTop(long widget, bool b) {
00176   karamba* currTheme = (karamba*)widget;
00177 
00178   if (currTheme != 0)
00179   {
00180     currTheme->setAlwaysOnTop(b);
00181   }
00182   return 1;
00183 }
00184 
00185 PyObject* py_set_widget_on_top(PyObject *, PyObject *args)
00186 {
00187   long widget;
00188   long b;
00189   if (!PyArg_ParseTuple(args, (char*)"ll:setWidgetOnTop", &widget, &b ))
00190     return NULL;
00191   return Py_BuildValue((char*)"l", widgetSetOnTop(widget, b));
00192 }
00193 
00194 /* now a method we need to expose to Python */
00195 long toggleWidgetRedraw(long widget, bool b)
00196 {
00197   karamba* currTheme = (karamba*)widget;
00198   if (currTheme != 0)
00199   {
00200     currTheme->toggleWidgetUpdate( b );
00201   }
00202   return 0;
00203 }
00204 
00205 PyObject* py_toggle_widget_redraw(PyObject *, PyObject *args)
00206 {
00207   long widget, b;
00208 
00209   if (!PyArg_ParseTuple(args, (char*)"ll:toggleWidgetRedraw", &widget, &b ))
00210     return NULL;
00211   if (!checkKaramba(widget))
00212     return NULL;
00213   return Py_BuildValue((char*)"l", toggleWidgetRedraw(widget, b));
00214 }

superkaramba

Skip menu "superkaramba"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

superkaramba

Skip menu "superkaramba"
  • kcalc
  •   knumber
  • superkaramba
Generated for superkaramba by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |