• 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
widget.cpp
Go to the documentation of this file.
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 #if defined(_XOPEN_SOURCE) && !defined(__SUNPRO_CC)
26 #undef _XOPEN_SOURCE
27 #endif
28 
29 #include "python/widget.h"
30 
31 #include <Python.h>
32 #include <qobject.h>
33 #include "../karamba.h"
34 #include "meters/meter.h"
35 #include "python/meter.h"
36 
37 PyObject* py_get_widget_position(PyObject *, PyObject *args)
38 {
39  long widget;
40  if (!PyArg_ParseTuple(args, (char*)"l:getWidgetPosition", &widget))
41  return NULL;
42  if (!checkKaramba(widget))
43  return NULL;
44 
45  QPoint pos = ((Karamba*)widget)->getPosition();
46  return Py_BuildValue((char*)"(i,i)", pos.x(), pos.y());
47 }
48 
49 // Keep compatibility
50 PyObject* py_create_widget_mask(PyObject *, PyObject *args)
51 {
52  long widget;
53  char *text;
54  if (!PyArg_ParseTuple(args, (char*)"ls:createWidgetMask", &widget, &text))
55  return NULL;
56  if (!checkKaramba(widget))
57  return NULL;
58  return Py_BuildValue((char*)"l", 1);
59 }
60 
61 // Keep compatibility
62 PyObject* py_redraw_widget_background(PyObject *, PyObject *args)
63 {
64  long widget;
65  if (!PyArg_ParseTuple(args, (char*)"l:redrawWidgetBackground", &widget))
66  return NULL;
67  if (!checkKaramba(widget))
68  return NULL;
69  return Py_BuildValue((char*)"l", 1);
70 }
71 
72 /* now a method we need to expose to Python */
73 long redrawWidget(long widget)
74 {
75  Karamba* currTheme = (Karamba*)widget;
76  foreach(QGraphicsItem *item, ((QGraphicsItemGroup*)currTheme)->children())
77  item->update();
78 
79  return 1;
80 }
81 
82 PyObject* py_redraw_widget(PyObject *, PyObject *args)
83 {
84  long widget;
85  if (!PyArg_ParseTuple(args, (char*)"l:redrawWidget", &widget))
86  return NULL;
87  if (!checkKaramba(widget))
88  return NULL;
89 
90  return Py_BuildValue((char*)"l", redrawWidget(widget));
91 }
92 
93 /* now a method we need to expose to Python */
94 long resizeWidget(long widget, long x, long y)
95 {
96  Karamba* currTheme = (Karamba*)widget;
97  //currTheme->test = true;
98  currTheme->resizeTo((int)x, (int)y);
99  //currTheme->test = false;
100  return 1;
101 }
102 
103 PyObject* py_resize_widget(PyObject *, PyObject *args)
104 {
105  long widget, x, y;
106  if (!PyArg_ParseTuple(args, (char*)"lll:resizeWidget", &widget, &x, &y))
107  return NULL;
108  if (!checkKaramba(widget))
109  return NULL;
110  return Py_BuildValue((char*)"l", resizeWidget(widget, x, y));
111 }
112 
113 /* now a method we need to expose to Python */
114 long moveWidget(long widget, long x, long y)
115 {
116  Karamba* currTheme = (Karamba*)widget;
117  currTheme->moveToPos(QPoint((int)x, (int)y));
118  return 1;
119 }
120 
121 PyObject* py_move_widget(PyObject *, PyObject *args)
122 {
123  long widget, x, y;
124  if (!PyArg_ParseTuple(args, (char*)"lll:moveWidget", &widget, &x, &y))
125  return NULL;
126  if (!checkKaramba(widget))
127  return NULL;
128  return Py_BuildValue((char*)"l", moveWidget(widget, x, y));
129 }
130 
131 /* now a method we need to expose to Python */
132 long widgetSetOnTop(long widget, bool b)
133 {
134  Karamba* currTheme = (Karamba*)widget;
135 
136  if (currTheme != 0)
137  {
138  currTheme->setOnTop(b);
139  }
140 
141  return 1;
142 }
143 
144 PyObject* py_set_widget_on_top(PyObject *, PyObject *args)
145 {
146  long widget;
147  long b;
148  if (!PyArg_ParseTuple(args, (char*)"ll:setWidgetOnTop", &widget, &b))
149  return NULL;
150  return Py_BuildValue((char*)"l", widgetSetOnTop(widget, b));
151 }
152 
153 // Keep compatibility
154 PyObject* py_toggle_widget_redraw(PyObject *, PyObject *args)
155 {
156  long widget, b;
157 
158  if (!PyArg_ParseTuple(args, (char*)"ll:toggleWidgetRedraw", &widget, &b))
159  return NULL;
160  if (!checkKaramba(widget))
161  return NULL;
162  return Py_BuildValue((char*)"l", 0);
163 }
py_create_widget_mask
PyObject * py_create_widget_mask(PyObject *, PyObject *args)
Widget/createWidgetMask.
Definition: widget.cpp:50
py_set_widget_on_top
PyObject * py_set_widget_on_top(PyObject *, PyObject *args)
Definition: widget.cpp:144
PyObject
struct _object PyObject
Definition: python/karamba.h:35
Karamba::moveToPos
void moveToPos(QPoint pos)
Definition: karamba.cpp:2148
meter.h
meter.h
QGraphicsItem
py_toggle_widget_redraw
PyObject * py_toggle_widget_redraw(PyObject *, PyObject *args)
Widget/toggleWidgetRedraw.
Definition: widget.cpp:154
redrawWidget
long redrawWidget(long widget)
Definition: widget.cpp:73
py_move_widget
PyObject * py_move_widget(PyObject *, PyObject *args)
Widget/moveWidget.
Definition: widget.cpp:121
widgetSetOnTop
long widgetSetOnTop(long widget, bool b)
Definition: widget.cpp:132
Karamba
Definition: karamba.h:52
py_resize_widget
PyObject * py_resize_widget(PyObject *, PyObject *args)
Widget/resizeWidget.
Definition: widget.cpp:103
Karamba::resizeTo
void resizeTo(int width, int height)
Definition: karamba.cpp:2163
py_redraw_widget_background
PyObject * py_redraw_widget_background(PyObject *, PyObject *args)
Widget/redrawWidgetBackground.
Definition: widget.cpp:62
Karamba::setOnTop
void setOnTop(bool stayOnTop)
Definition: karamba.cpp:1438
checkKaramba
bool checkKaramba(long widget)
Definition: python/meter.cpp:26
widget.h
moveWidget
long moveWidget(long widget, long x, long y)
Definition: widget.cpp:114
py_redraw_widget
PyObject * py_redraw_widget(PyObject *, PyObject *args)
Widget/redrawWidget.
Definition: widget.cpp:82
QGraphicsItemGroup
py_get_widget_position
PyObject * py_get_widget_position(PyObject *, PyObject *args)
Widget/getWidgetPosition.
Definition: widget.cpp:37
resizeWidget
long resizeWidget(long widget, long x, long y)
Definition: widget.cpp:94
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:20 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