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

superkaramba

  • sources
  • kde-4.12
  • kdeutils
  • superkaramba
  • src
  • python
python/input.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 * input_python.cpp - Functions for input box 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 * Copyright (c) 2005 Alexander Wiedenbruch <mail@wiedenbruch.de>
8 *
9 * This file is part of SuperKaramba.
10 *
11 * SuperKaramba is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * SuperKaramba is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with SuperKaramba; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 ****************************************************************************/
25 
26 #if defined(_XOPEN_SOURCE) && !defined(__SUNPRO_CC)
27 #undef _XOPEN_SOURCE
28 #endif
29 
30 #include "python/input.h"
31 
32 #include <Python.h>
33 
34 #include <QObject>
35 #include <QGraphicsScene>
36 
37 #include "meters/meter.h"
38 #include "meters/input.h"
39 
40 #include "python/meter.h"
41 
42 #include "../karamba.h"
43 
44 PyObject* py_createInputBox(PyObject *, PyObject *args)
45 {
46  long widget, x, y, w, h;
47  PyObject *text;
48  if (!PyArg_ParseTuple(args, (char*)"lllllO:createInputBox", &widget, &x, &y, &w, &h, &text))
49  return NULL;
50 
51  if (!checkKaramba(widget))
52  return NULL;
53 
54  Input *tmp = new Input((Karamba*)widget, (int)x, (int)y, (int)w, (int)h);
55  tmp->setValue(PyString2QString(text));
56  tmp->setTextProps(((Karamba*)widget)->getDefaultTextProps());
57  ((Karamba*)widget)->addToGroup(tmp);
58  tmp->show();
59 
60  return (Py_BuildValue((char*)"l", (long)tmp));
61 }
62 
63 PyObject* py_deleteInputBox(PyObject *, PyObject *args)
64 {
65  long widget, meter;
66  if (!PyArg_ParseTuple(args, (char*)"ll:deleteInputBox", &widget, &meter))
67  return NULL;
68 
69  if (!checkKarambaAndMeter(widget, meter, "Input"))
70  return NULL;
71 
72  bool result = ((Karamba*)widget)->removeMeter((Meter*)meter);
73 
74  return Py_BuildValue((char*)"l", result);
75 }
76 
77 PyObject* py_getThemeInputBox(PyObject *self, PyObject *args)
78 {
79  return py_getThemeMeter(self, args, "Input");
80 }
81 
82 PyObject* py_getInputBoxValue(PyObject *self, PyObject *args)
83 {
84  return py_getStringValue(self, args, "Input");
85 }
86 
87 PyObject* py_setInputBoxValue(PyObject *self, PyObject *args)
88 {
89  return py_setStringValue(self, args, "Input");
90 }
91 
92 PyObject* py_hideInputBox(PyObject *self, PyObject *args)
93 {
94  return py_hide(self, args, "Input");
95 }
96 
97 PyObject* py_showInputBox(PyObject *self, PyObject *args)
98 {
99  return py_show(self, args, "Input");
100 }
101 
102 PyObject* py_getInputBoxPos(PyObject *self, PyObject *args)
103 {
104  return py_getPos(self, args, "Input");
105 }
106 
107 PyObject* py_moveInputBox(PyObject *self, PyObject *args)
108 {
109  return py_move(self, args, "Input");
110 }
111 
112 PyObject* py_getInputBoxSize(PyObject *self, PyObject *args)
113 {
114  return py_getSize(self, args, "Input");
115 }
116 
117 PyObject* py_resizeInputBox(PyObject *self, PyObject *args)
118 {
119  return py_resize(self, args, "Input");
120 }
121 
122 PyObject* py_setInputBoxFont(PyObject *, PyObject *args)
123 {
124  long widget, inputBox;
125  char* text;
126  if (!PyArg_ParseTuple(args, (char*)"lls:changeInputBoxFont",
127  &widget, &inputBox, &text))
128  return NULL;
129 
130  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
131  return NULL;
132 
133  ((Input*)inputBox)->setFont(text);
134  return Py_BuildValue((char*)"l", 1);
135 }
136 
137 PyObject* py_getInputBoxFont(PyObject *, PyObject *args)
138 {
139  long widget, inputBox;
140  if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxFont", &widget, &inputBox))
141  return NULL;
142 
143  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
144  return NULL;
145 
146  return Py_BuildValue((char*)"s", ((Input*)inputBox)->getFont().toAscii().constData());
147 }
148 
149 PyObject* py_setInputBoxFontColor(PyObject *, PyObject *args)
150 {
151  long widget, inputBox;
152  long r, g, b;
153  if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxFontColor", &widget, &inputBox, &r, &g, &b))
154  return NULL;
155 
156  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
157  return NULL;
158 
159  ((Input*)inputBox)->setFontColor(QColor(r, g, b));
160  return Py_BuildValue((char*)"l", 1);
161 }
162 
163 PyObject* py_getInputBoxFontColor(PyObject *, PyObject *args)
164 {
165  long widget, inputBox;
166  if (!PyArg_ParseTuple(args, (char*)"ll:changeInputBoxFontColor", &widget, &inputBox))
167  return NULL;
168 
169  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
170  return NULL;
171 
172  QColor color = ((Input*)inputBox)->getFontColor();
173  return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
174 }
175 
176 PyObject* py_setInputBoxSelectionColor(PyObject *, PyObject *args)
177 {
178  long widget, inputBox;
179  long r, g, b;
180  if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxSelectionColor", &widget, &inputBox, &r, &g, &b))
181  return NULL;
182 
183  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
184  return NULL;
185 
186  ((Input*)inputBox)->setSelectionColor(QColor(r, g, b));
187  return Py_BuildValue((char*)"l", 1);
188 }
189 
190 PyObject* py_getInputBoxSelectionColor(PyObject *, PyObject *args)
191 {
192  long widget, inputBox;
193  if (!PyArg_ParseTuple(args, (char*)"ll:changeInputBoxSelectionColor", &widget, &inputBox))
194  return NULL;
195 
196  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
197  return NULL;
198 
199  QColor color = ((Input*)inputBox)->getSelectionColor();
200  return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
201 }
202 
203 PyObject* py_setInputBoxBGColor(PyObject *, PyObject *args)
204 {
205  long widget, inputBox;
206  long r, g, b;
207  if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxBackgroundColor", &widget, &inputBox, &r, &g, &b))
208  return NULL;
209 
210  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
211  return NULL;
212 
213  ((Input*)inputBox)->setBGColor(QColor(r, g, b));
214  return Py_BuildValue((char*)"l", 1);
215 }
216 
217 PyObject* py_getInputBoxBGColor(PyObject *, PyObject *args)
218 {
219  long widget, inputBox;
220  if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxBackgroundColor", &widget, &inputBox))
221  return NULL;
222 
223  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
224  return NULL;
225 
226  QColor color = ((Input*)inputBox)->getBGColor();
227  return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
228 }
229 
230 PyObject* py_setInputBoxFrameColor(PyObject *, PyObject *args)
231 {
232  long widget, inputBox;
233  long r, g, b;
234  if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxFrameColor", &widget, &inputBox, &r, &g, &b))
235  return NULL;
236 
237  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
238  return NULL;
239 
240  ((Input*)inputBox)->setColor(QColor(r, g, b));
241  return Py_BuildValue((char*)"l", 1);
242 }
243 
244 PyObject* py_getInputBoxFrameColor(PyObject *, PyObject *args)
245 {
246  long widget, inputBox;
247  if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxFrameColor", &widget, &inputBox))
248  return NULL;
249 
250  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
251  return NULL;
252 
253  QColor color = ((Input*)inputBox)->getColor();
254  return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
255 }
256 
257 PyObject* py_setInputBoxSelectedTextColor(PyObject *, PyObject *args)
258 {
259  long widget, inputBox;
260  long r, g, b;
261  if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxSelectedTextColor", &widget, &inputBox, &r, &g, &b))
262  return NULL;
263 
264  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
265  return NULL;
266 
267  ((Input*)inputBox)->setSelectedTextColor(QColor(r, g, b));
268  return Py_BuildValue((char*)"l", 1);
269 }
270 
271 PyObject* py_getInputBoxSelectedTextColor(PyObject *, PyObject *args)
272 {
273  long widget, inputBox;
274  if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxSelectedTextColor", &widget, &inputBox))
275  return NULL;
276 
277  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
278  return NULL;
279 
280  QColor color = ((Input*)inputBox)->getSelectedTextColor();
281  return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
282 }
283 
284 PyObject* py_setInputBoxFontSize(PyObject *, PyObject *args)
285 {
286  long widget, inputBox;
287  long size;
288  if (!PyArg_ParseTuple(args, (char*)"lll:changeInputBoxFontSize",
289  &widget, &inputBox, &size))
290  return NULL;
291 
292  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
293  return NULL;
294 
295  ((Input*)inputBox)->setFontSize(size);
296  return Py_BuildValue((char*)"l", 1);
297 }
298 
299 PyObject* py_getInputBoxFontSize(PyObject *, PyObject *args)
300 {
301  long widget, inputBox;
302  if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxFontSize", &widget, &inputBox))
303  return NULL;
304 
305  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
306  return NULL;
307 
308  return Py_BuildValue((char*)"l", ((Input*)inputBox)->getFontSize());
309 }
310 
311 PyObject* py_setInputFocus(PyObject *, PyObject *args)
312 {
313  long widget, inputBox;
314  if (!PyArg_ParseTuple(args, (char*)"ll:setInputFocus", &widget, &inputBox))
315  return NULL;
316 
317  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
318  return NULL;
319 
320  //((Karamba*)widget)->setActiveWindow();
321 
322  ((Input*)inputBox)->setInputFocus();
323  return Py_BuildValue((char*)"l", 1);
324 }
325 
326 PyObject* py_clearInputFocus(PyObject *, PyObject *args)
327 {
328  long widget, inputBox;
329  if (!PyArg_ParseTuple(args, (char*)"ll:clearInputFocus", &widget, &inputBox))
330  return NULL;
331 
332  if (!checkKarambaAndMeter(widget, inputBox, "Input"))
333  return NULL;
334 
335  ((Input*)inputBox)->clearInputFocus();
336  return Py_BuildValue((char*)"l", 1);
337 }
338 
339 PyObject* py_getInputFocus(PyObject *, PyObject *args)
340 {
341  long widget;
342  if (!PyArg_ParseTuple(args, (char*)"l:getInputFocus", &widget))
343  return NULL;
344 
345  if (!checkKaramba(widget))
346  return NULL;
347 
348  Karamba *k = (Karamba*)widget;
349  QGraphicsItem *focusItem = k->getScene()->focusItem();
350  if (Input *input = dynamic_cast<Input*>(focusItem))
351  return Py_BuildValue((char*)"l", input);
352 
353  return Py_BuildValue((char*)"l", 0);
354 }
py_getThemeMeter
PyObject * py_getThemeMeter(PyObject *, PyObject *args, QString type)
Definition: python/meter.cpp:161
input.h
Input::show
void show()
Definition: meters/input.cpp:368
py_moveInputBox
PyObject * py_moveInputBox(PyObject *self, PyObject *args)
InputBox/moveInputBox.
Definition: python/input.cpp:107
Karamba::getScene
QGraphicsScene * getScene() const
Definition: karamba.cpp:2017
py_getInputBoxSize
PyObject * py_getInputBoxSize(PyObject *self, PyObject *args)
InputBox/getInputBoxSize.
Definition: python/input.cpp:112
py_move
PyObject * py_move(PyObject *, PyObject *args, QString type)
Definition: python/meter.cpp:212
PyObject
struct _object PyObject
Definition: python/karamba.h:35
py_getInputFocus
PyObject * py_getInputFocus(PyObject *, PyObject *args)
InputBox/getInputFocus.
Definition: python/input.cpp:339
PyString2QString
QString PyString2QString(PyObject *text)
Definition: python/meter.cpp:92
py_createInputBox
PyObject * py_createInputBox(PyObject *, PyObject *args)
InputBox/createInputBox.
Definition: python/input.cpp:44
meter.h
py_getInputBoxValue
PyObject * py_getInputBoxValue(PyObject *self, PyObject *args)
InputBox/getInputBoxValue.
Definition: python/input.cpp:82
py_resizeInputBox
PyObject * py_resizeInputBox(PyObject *self, PyObject *args)
InputBox/resizeInputBox.
Definition: python/input.cpp:117
meter.h
py_hide
PyObject * py_hide(PyObject *, PyObject *args, QString type)
Definition: python/meter.cpp:225
QGraphicsItem
py_setInputBoxSelectedTextColor
PyObject * py_setInputBoxSelectedTextColor(PyObject *, PyObject *args)
InputBox/changeInputBoxSelectedTextColor.
Definition: python/input.cpp:257
py_getInputBoxFontColor
PyObject * py_getInputBoxFontColor(PyObject *, PyObject *args)
InputBox/getInputBoxFontColor.
Definition: python/input.cpp:163
py_setInputBoxSelectionColor
PyObject * py_setInputBoxSelectionColor(PyObject *, PyObject *args)
InputBox/changeInputBoxSelectionColor.
Definition: python/input.cpp:176
py_getSize
PyObject * py_getSize(PyObject *, PyObject *args, QString type)
Definition: python/meter.cpp:177
Input::setTextProps
void setTextProps(TextField *)
Definition: meters/input.cpp:454
Karamba
Definition: karamba.h:52
py_resize
PyObject * py_resize(PyObject *, PyObject *args, QString type)
Definition: python/meter.cpp:189
Input::setValue
void setValue(const QString &text)
Definition: meters/input.cpp:329
py_getInputBoxPos
PyObject * py_getInputBoxPos(PyObject *self, PyObject *args)
InputBox/getInputBoxPos.
Definition: python/input.cpp:102
py_setInputBoxFontColor
PyObject * py_setInputBoxFontColor(PyObject *, PyObject *args)
InputBox/changeInputBoxFontColor.
Definition: python/input.cpp:149
py_getInputBoxFont
PyObject * py_getInputBoxFont(PyObject *, PyObject *args)
InputBox/getInputBoxFont.
Definition: python/input.cpp:137
py_deleteInputBox
PyObject * py_deleteInputBox(PyObject *, PyObject *args)
InputBox/deleteInputBox.
Definition: python/input.cpp:63
py_setInputBoxFrameColor
PyObject * py_setInputBoxFrameColor(PyObject *, PyObject *args)
InputBox/changeInputBoxFrameColor.
Definition: python/input.cpp:230
py_setInputBoxBGColor
PyObject * py_setInputBoxBGColor(PyObject *, PyObject *args)
InputBox/changeInputBoxBackgroundColor.
Definition: python/input.cpp:203
py_getInputBoxSelectionColor
PyObject * py_getInputBoxSelectionColor(PyObject *, PyObject *args)
InputBox/getInputBoxSelectionColor.
Definition: python/input.cpp:190
py_showInputBox
PyObject * py_showInputBox(PyObject *self, PyObject *args)
InputBox/showInputBox.
Definition: python/input.cpp:97
py_setInputFocus
PyObject * py_setInputFocus(PyObject *, PyObject *args)
InputBox/setInputFocus.
Definition: python/input.cpp:311
py_setInputBoxFont
PyObject * py_setInputBoxFont(PyObject *, PyObject *args)
InputBox/changeInputBoxFont.
Definition: python/input.cpp:122
py_clearInputFocus
PyObject * py_clearInputFocus(PyObject *, PyObject *args)
InputBox/clearInputFocus.
Definition: python/input.cpp:326
py_hideInputBox
PyObject * py_hideInputBox(PyObject *self, PyObject *args)
InputBox/hideInputBox.
Definition: python/input.cpp:92
checkKaramba
bool checkKaramba(long widget)
Definition: python/meter.cpp:26
Input
Definition: meters/input.h:32
checkKarambaAndMeter
bool checkKarambaAndMeter(long widget, long meter, const char *type)
Definition: python/meter.cpp:74
py_show
PyObject * py_show(PyObject *, PyObject *args, QString type)
Definition: python/meter.cpp:236
py_getPos
PyObject * py_getPos(PyObject *, PyObject *args, QString type)
Definition: python/meter.cpp:201
py_getInputBoxBGColor
PyObject * py_getInputBoxBGColor(PyObject *, PyObject *args)
InputBox/getInputBoxBackgroundColor.
Definition: python/input.cpp:217
input.h
py_getInputBoxSelectedTextColor
PyObject * py_getInputBoxSelectedTextColor(PyObject *, PyObject *args)
InputBox/getInputBoxSelectedTextColor.
Definition: python/input.cpp:271
Meter
Definition: meters/meter.h:23
py_setStringValue
PyObject * py_setStringValue(PyObject *, PyObject *args, QString type)
Definition: python/meter.cpp:279
py_setInputBoxFontSize
PyObject * py_setInputBoxFontSize(PyObject *, PyObject *args)
InputBox/changeInputBoxFontSize.
Definition: python/input.cpp:284
py_getInputBoxFrameColor
PyObject * py_getInputBoxFrameColor(PyObject *, PyObject *args)
InputBox/getInputBoxFrameColor.
Definition: python/input.cpp:244
py_setInputBoxValue
PyObject * py_setInputBoxValue(PyObject *self, PyObject *args)
InputBox/changeInputBox.
Definition: python/input.cpp:87
py_getStringValue
PyObject * py_getStringValue(PyObject *, PyObject *args, QString type)
Definition: python/meter.cpp:268
py_getInputBoxFontSize
PyObject * py_getInputBoxFontSize(PyObject *, PyObject *args)
InputBox/getInputBoxFontSize.
Definition: python/input.cpp:299
py_getThemeInputBox
PyObject * py_getThemeInputBox(PyObject *self, PyObject *args)
InputBox/getThemeInputBox.
Definition: python/input.cpp:77
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

superkaramba

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

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal