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

superkaramba

  • superkaramba
  • src
input_python.cpp
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#ifdef _XOPEN_SOURCE
27#undef _XOPEN_SOURCE
28#endif
29
30#include <Python.h>
31#include <tqobject.h>
32#include "karamba.h"
33#include "meter.h"
34#include "meter_python.h"
35#include "input_python.h"
36
37PyObject* py_createInputBox(PyObject *, PyObject *args)
38{
39 long widget, x, y, w, h;
40 PyObject *text;
41 if (!PyArg_ParseTuple(args, (char*)"lllllO:createInputBox", &widget, &x, &y, &w, &h, &text))
42 return NULL;
43
44 if (!checkKaramba(widget))
45 return NULL;
46
47 Input *tmp = new Input((karamba*)widget, (int)x, (int)y, (int)w, (int)h);
48 tmp->setValue(PyString2TQString(text));
49 tmp->setTextProps(((karamba*)widget)->getDefaultTextProps());
50 ((karamba*)widget)->meterList->append(tmp);
51 tmp->show();
52
53 ((karamba*)widget)->makeActive();
54
55 return (Py_BuildValue((char*)"l", (long)tmp));
56}
57
58PyObject* py_deleteInputBox(PyObject *, PyObject *args)
59{
60 long widget, meter;
61 if (!PyArg_ParseTuple(args, (char*)"ll:deleteInputBox", &widget, &meter))
62 return NULL;
63
64 if (!checkKarambaAndMeter(widget, meter, "Input"))
65 return NULL;
66
67 bool result = ((karamba*)widget)->meterList->removeRef((Meter*)meter);
68
69 ((karamba*)widget)->makePassive();
70
71 return Py_BuildValue((char*)"l", result);
72}
73
74PyObject* py_getThemeInputBox(PyObject *self, PyObject *args)
75{
76 return py_getThemeMeter(self, args, "Input");
77}
78
79PyObject* py_getInputBoxValue(PyObject *self, PyObject *args)
80{
81 return py_getStringValue(self, args, "Input");
82}
83
84PyObject* py_setInputBoxValue(PyObject *self, PyObject *args)
85{
86 return py_setStringValue(self, args, "Input");
87}
88
89PyObject* py_hideInputBox(PyObject *self, PyObject *args)
90{
91 return py_hide(self, args, "Input");
92}
93
94PyObject* py_showInputBox(PyObject *self, PyObject *args)
95{
96 return py_show(self, args, "Input");
97}
98
99PyObject* py_getInputBoxPos(PyObject *self, PyObject *args)
100{
101 return py_getPos(self, args, "Input");
102}
103
104PyObject* py_moveInputBox(PyObject *self, PyObject *args)
105{
106 return py_move(self, args, "Input");
107}
108
109PyObject* py_getInputBoxSize(PyObject *self, PyObject *args)
110{
111 return py_getSize(self, args, "Input");
112}
113
114PyObject* py_resizeInputBox(PyObject *self, PyObject *args)
115{
116 return py_resize(self, args, "Input");
117}
118
119PyObject* py_setInputBoxFont(PyObject *, PyObject *args)
120{
121 long widget, inputBox;
122 char* text;
123 if (!PyArg_ParseTuple(args, (char*)"lls:changeInputBoxFont",
124 &widget, &inputBox, &text))
125 return NULL;
126
127 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
128 return NULL;
129
130 ((Input*)inputBox)->setFont(text);
131 return Py_BuildValue((char*)"l", 1);
132}
133
134PyObject* py_getInputBoxFont(PyObject *, PyObject *args)
135{
136 long widget, inputBox;
137 if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxFont", &widget, &inputBox))
138 return NULL;
139
140 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
141 return NULL;
142
143 return Py_BuildValue((char*)"s", ((Input*)inputBox)->getFont().ascii());
144}
145
146PyObject* py_setInputBoxFontColor(PyObject *, PyObject *args)
147{
148 long widget, inputBox;
149 long r, g, b;
150 if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxFontColor", &widget, &inputBox, &r, &g, &b))
151 return NULL;
152
153 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
154 return NULL;
155
156 ((Input*)inputBox)->setFontColor(TQColor(r, g, b));
157 return Py_BuildValue((char*)"l", 1);
158}
159
160PyObject* py_getInputBoxFontColor(PyObject *, PyObject *args)
161{
162 long widget, inputBox;
163 if (!PyArg_ParseTuple(args, (char*)"ll:changeInputBoxFontColor", &widget, &inputBox))
164 return NULL;
165
166 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
167 return NULL;
168
169 TQColor color = ((Input*)inputBox)->getFontColor();
170 return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
171}
172
173PyObject* py_setInputBoxSelectionColor(PyObject *, PyObject *args)
174{
175 long widget, inputBox;
176 long r, g, b;
177 if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxSelectionColor", &widget, &inputBox, &r, &g, &b))
178 return NULL;
179
180 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
181 return NULL;
182
183 ((Input*)inputBox)->setSelectionColor(TQColor(r, g, b));
184 return Py_BuildValue((char*)"l", 1);
185}
186
187PyObject* py_getInputBoxSelectionColor(PyObject *, PyObject *args)
188{
189 long widget, inputBox;
190 if (!PyArg_ParseTuple(args, (char*)"ll:changeInputBoxSelectionColor", &widget, &inputBox))
191 return NULL;
192
193 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
194 return NULL;
195
196 TQColor color = ((Input*)inputBox)->getSelectionColor();
197 return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
198}
199
200PyObject* py_setInputBoxBGColor(PyObject *, PyObject *args)
201{
202 long widget, inputBox;
203 long r, g, b;
204 if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxBackgroundColor", &widget, &inputBox, &r, &g, &b))
205 return NULL;
206
207 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
208 return NULL;
209
210 ((Input*)inputBox)->setBGColor(TQColor(r, g, b));
211 return Py_BuildValue((char*)"l", 1);
212}
213
214PyObject* py_getInputBoxBGColor(PyObject *, PyObject *args)
215{
216 long widget, inputBox;
217if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxBackgroundColor", &widget, &inputBox))
218 return NULL;
219
220 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
221 return NULL;
222
223 TQColor color = ((Input*)inputBox)->getBGColor();
224 return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
225}
226
227PyObject* py_setInputBoxFrameColor(PyObject *, PyObject *args)
228{
229 long widget, inputBox;
230 long r, g, b;
231if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxFrameColor", &widget, &inputBox, &r, &g, &b))
232 return NULL;
233
234 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
235 return NULL;
236
237 ((Input*)inputBox)->setColor(TQColor(r, g, b));
238 return Py_BuildValue((char*)"l", 1);
239}
240
241PyObject* py_getInputBoxFrameColor(PyObject *, PyObject *args)
242{
243 long widget, inputBox;
244if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxFrameColor", &widget, &inputBox))
245 return NULL;
246
247 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
248 return NULL;
249
250 TQColor color = ((Input*)inputBox)->getColor();
251 return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
252}
253
254PyObject* py_setInputBoxSelectedTextColor(PyObject *, PyObject *args)
255{
256 long widget, inputBox;
257 long r, g, b;
258if (!PyArg_ParseTuple(args, (char*)"lllll:changeInputBoxSelectedTextColor", &widget, &inputBox, &r, &g, &b))
259 return NULL;
260
261 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
262 return NULL;
263
264 ((Input*)inputBox)->setSelectedTextColor(TQColor(r, g, b));
265 return Py_BuildValue((char*)"l", 1);
266}
267
268PyObject* py_getInputBoxSelectedTextColor(PyObject *, PyObject *args)
269{
270 long widget, inputBox;
271if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxSelectedTextColor", &widget, &inputBox))
272 return NULL;
273
274 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
275 return NULL;
276
277 TQColor color = ((Input*)inputBox)->getSelectedTextColor();
278 return Py_BuildValue((char*)"(i,i,i)", color.red(), color.green(), color.blue());
279}
280
281PyObject* py_setInputBoxFontSize(PyObject *, PyObject *args)
282{
283 long widget, inputBox;
284 long size;
285 if (!PyArg_ParseTuple(args, (char*)"lll:changeInputBoxFontSize",
286 &widget, &inputBox, &size))
287 return NULL;
288
289 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
290 return NULL;
291
292 ((Input*)inputBox)->setFontSize( size );
293 return Py_BuildValue((char*)"l", 1);
294}
295
296PyObject* py_getInputBoxFontSize(PyObject *, PyObject *args)
297{
298 long widget, inputBox;
299 if (!PyArg_ParseTuple(args, (char*)"ll:getInputBoxFontSize", &widget, &inputBox))
300 return NULL;
301
302 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
303 return NULL;
304
305 return Py_BuildValue((char*)"l", ((Input*)inputBox)->getFontSize());
306}
307
308PyObject* py_setInputFocus(PyObject *, PyObject *args)
309{
310 long widget, inputBox;
311 if (!PyArg_ParseTuple(args, (char*)"ll:setInputFocus", &widget, &inputBox))
312 return NULL;
313
314 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
315 return NULL;
316
317 //((karamba*)widget)->setActiveWindow();
318
319 ((Input*)inputBox)->setInputFocus();
320 return Py_BuildValue((char*)"l", 1);
321}
322
323PyObject* py_clearInputFocus(PyObject *, PyObject *args)
324{
325 long widget, inputBox;
326 if (!PyArg_ParseTuple(args, (char*)"ll:clearInputFocus", &widget, &inputBox))
327 return NULL;
328
329 if (!checkKarambaAndMeter(widget, inputBox, "Input"))
330 return NULL;
331
332 ((Input*)inputBox)->clearInputFocus();
333 return Py_BuildValue((char*)"l", 1);
334}
335
336PyObject* py_getInputFocus(PyObject *, PyObject *args)
337{
338 long widget;
339 if (!PyArg_ParseTuple(args, (char*)"l:getInputFocus", &widget))
340 return NULL;
341
342 if (!checkKaramba(widget))
343 return NULL;
344
345 //
346 // FocusWidget() returns the currently focused line edit,
347 // but unfortunately we need an 'Input' object here.
348 //
349 TQWidget *obj = ((karamba*)widget)->focusWidget();
350
351 if(obj->isA("TQLineEdit")) // SKLineEdit is no TQ_Object, but TQLineEdit can only be here as a SKLineEdit
352 return Py_BuildValue((char*)"l", ((SKLineEdit*)obj)->getInput());
353
354 return Py_BuildValue((char*)"l", 0);
355}
py_show
PyObject * py_show(PyObject *self, PyObject *args)
Misc/show.
Definition: misc_python.cpp:623
py_hide
PyObject * py_hide(PyObject *self, PyObject *args)
Misc/hide.
Definition: misc_python.cpp:641

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