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

superkaramba

  • superkaramba
  • src
widget_python.cpp
1 /****************************************************************************
2 * widget_python.h - Functions for widget python api
3 *
4 * Copyright (C) 2003 Hans Karlsson <karlsson.h@home.se>
5 * Copyright (C) 2003-2004 Adam Geitgey <adam@rootnode.org>
6 * Copyright (c) 2004 Petri Damstén <damu@iki.fi>
7 *
8 * This file is part of SuperKaramba.
9 *
10 * SuperKaramba is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * SuperKaramba is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with SuperKaramba; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 ****************************************************************************/
24 
25 #ifdef _XOPEN_SOURCE
26 #undef _XOPEN_SOURCE
27 #endif
28 
29 #include <Python.h>
30 #include <tqobject.h>
31 #include "karamba.h"
32 #include "meter.h"
33 #include "meter_python.h"
34 #include "widget_python.h"
35 
36 /* now a method we need to expose to Python */
37 int getWidgetXCoordinate(long widget)
38 {
39  karamba* currTheme = (karamba*)widget;
40  return currTheme->x();
41 }
42 
43 /* now a method we need to expose to Python */
44 int getWidgetYCoordinate(long widget)
45 {
46  karamba* currTheme = (karamba*)widget;
47  return currTheme->y();
48 }
49 
50 PyObject* py_get_widget_position(PyObject *, PyObject *args)
51 {
52  long widget;
53  if(!PyArg_ParseTuple(args, (char*)"l:getWidgetPosition", &widget))
54  return NULL;
55  if (!checkKaramba(widget))
56  return NULL;
57  return Py_BuildValue((char*)"(i,i)", getWidgetXCoordinate(widget),
58  getWidgetYCoordinate(widget));
59 }
60 
61 /* now a method we need to expose to Python */
62 long createWidgetMask(long widget, char* path)
63 {
64  karamba* currTheme = (karamba*)widget;
65  TQBitmap bm;
66  TQString maskpath;
67  TQString rootPath;
68  rootPath.setAscii(currTheme->theme().path().ascii());
69 
70  currTheme->clearMask();
71 
72  maskpath.setAscii(path);
73  rootPath.append(maskpath.ascii());
74 
75  if(currTheme->theme().isZipTheme())
76  {
77  TQByteArray ba = currTheme->theme().readThemeFile(path);
78  bm.loadFromData(ba);
79  }
80  else
81  {
82  bm.load(rootPath);
83  }
84  currTheme->setMask(bm);
85 
86  return (long)currTheme->widgetMask;
87 }
88 
89 PyObject* py_create_widget_mask(PyObject *, PyObject *args)
90 {
91  long widget;
92  char *text;
93  if (!PyArg_ParseTuple(args, (char*)"ls:createWidgetMask", &widget, &text))
94  return NULL;
95  if (!checkKaramba(widget))
96  return NULL;
97  return Py_BuildValue((char*)"l", createWidgetMask(widget, text));
98 }
99 
100 /* now a method we need to expose to Python */
101 long redrawWidgetBackground(long widget)
102 {
103  karamba* currTheme = (karamba*)widget;
104  currTheme->kroot->repaint(true);
105  return 1;
106 }
107 
108 PyObject* py_redraw_widget_background(PyObject *, PyObject *args)
109 {
110  long widget;
111  if (!PyArg_ParseTuple(args, (char*)"l:redrawWidgetBackground", &widget))
112  return NULL;
113  if (!checkKaramba(widget))
114  return NULL;
115  return Py_BuildValue((char*)"l", redrawWidgetBackground(widget));
116 }
117 
118 /* now a method we need to expose to Python */
119 long redrawWidget(long widget)
120 {
121  karamba* currTheme = (karamba*)widget;
122  currTheme->externalStep();
123  return 1;
124 }
125 
126 PyObject* py_redraw_widget(PyObject *, PyObject *args)
127 {
128  long widget;
129  if (!PyArg_ParseTuple(args, (char*)"l:redrawWidget", &widget))
130  return NULL;
131  if (!checkKaramba(widget))
132  return NULL;
133  return Py_BuildValue((char*)"l", redrawWidget(widget));
134 }
135 
136 /* now a method we need to expose to Python */
137 long resizeWidget(long widget, long x, long y)
138 {
139  karamba* currTheme = (karamba*)widget;
140  //currTheme->test = true;
141  currTheme->setFixedSize((int)x,(int)y);
142  //currTheme->test = false;
143  return 1;
144 }
145 
146 PyObject* py_resize_widget(PyObject *, PyObject *args)
147 {
148  long widget, x, y;
149  if (!PyArg_ParseTuple(args, (char*)"lll:resizeWidget", &widget, &x, &y))
150  return NULL;
151  if (!checkKaramba(widget))
152  return NULL;
153  return Py_BuildValue((char*)"l", resizeWidget(widget, x, y));
154 }
155 
156 /* now a method we need to expose to Python */
157 long moveWidget(long widget, long x, long y)
158 {
159  karamba* currTheme = (karamba*)widget;
160  currTheme->move((int)x, (int)y);
161  return 1;
162 }
163 
164 PyObject* py_move_widget(PyObject *, PyObject *args)
165 {
166  long widget, x, y;
167  if (!PyArg_ParseTuple(args, (char*)"lll:moveWidget", &widget, &x, &y))
168  return NULL;
169  if (!checkKaramba(widget))
170  return NULL;
171  return Py_BuildValue((char*)"l", moveWidget(widget, x, y));
172 }
173 
174 /* now a method we need to expose to Python */
175 long widgetSetOnTop(long widget, bool b) {
176  karamba* currTheme = (karamba*)widget;
177 
178  if (currTheme != 0)
179  {
180  currTheme->setAlwaysOnTop(b);
181  }
182  return 1;
183 }
184 
185 PyObject* py_set_widget_on_top(PyObject *, PyObject *args)
186 {
187  long widget;
188  long b;
189  if (!PyArg_ParseTuple(args, (char*)"ll:setWidgetOnTop", &widget, &b ))
190  return NULL;
191  return Py_BuildValue((char*)"l", widgetSetOnTop(widget, b));
192 }
193 
194 /* now a method we need to expose to Python */
195 long toggleWidgetRedraw(long widget, bool b)
196 {
197  karamba* currTheme = (karamba*)widget;
198  if (currTheme != 0)
199  {
200  currTheme->toggleWidgetUpdate( b );
201  }
202  return 0;
203 }
204 
205 PyObject* py_toggle_widget_redraw(PyObject *, PyObject *args)
206 {
207  long widget, b;
208 
209  if (!PyArg_ParseTuple(args, (char*)"ll:toggleWidgetRedraw", &widget, &b ))
210  return NULL;
211  if (!checkKaramba(widget))
212  return NULL;
213  return Py_BuildValue((char*)"l", toggleWidgetRedraw(widget, b));
214 }

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.8.13
This website is maintained by Timothy Pearson.