[osx/ios] remove unused function
[vuplus_xbmc] / xbmc / interfaces / python / xbmcmodule / controlspin.cpp
1 /*
2  *      Copyright (C) 2005-2008 Team XBMC
3  *      http://www.xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, write to
17  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18  *  http://www.gnu.org/copyleft/gpl.html
19  *
20  */
21
22 #if (defined HAVE_CONFIG_H) && (!defined WIN32)
23   #include "config.h"
24 #endif
25 #if (defined USE_EXTERNAL_PYTHON)
26   #if (defined HAVE_LIBPYTHON2_6)
27     #include <python2.6/Python.h>
28   #elif (defined HAVE_LIBPYTHON2_5)
29     #include <python2.5/Python.h>
30   #elif (defined HAVE_LIBPYTHON2_4)
31     #include <python2.4/Python.h>
32   #else
33     #error "Could not determine version of Python to use."
34   #endif
35 #else
36   #include "python/Include/Python.h"
37 #endif
38 #include "../XBPythonDll.h"
39 #include "guilib/GUISpinControl.h"
40 #include "control.h"
41 #include "pyutil.h"
42
43 using namespace std;
44
45 #ifndef __GNUC__
46 #pragma code_seg("PY_TEXT")
47 #pragma data_seg("PY_DATA")
48 #pragma bss_seg("PY_BSS")
49 #pragma const_seg("PY_RDATA")
50 #endif
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
56 namespace PYXBMC
57 {
58   /*
59   // not used for now
60   PyObject* ControlSpin_New(PyTypeObject *type, PyObject *args, PyObject *kwds)
61   {
62     ControlSpin *self;
63     char* cTextureFocus = NULL;
64     char* cTextureNoFocus = NULL;
65
66     PyObject* pObjectText;
67
68     self = (ControlSpin*)type->tp_alloc(type, 0);
69     if (!self) return NULL;
70     new(&self->strTextureUp) string();
71     new(&self->strTextureDown) string();
72     new(&self->strTextureUpFocus) string();
73     new(&self->strTextureDownFocus) string();
74
75     if (!PyArg_ParseTuple(args, "llll|Oss", &self->dwPosX, &self->dwPosY, &self->dwWidth, &self->dwHeight,
76       &pObjectText, &cTextureFocus, &cTextureNoFocus)) return NULL;
77     if (!PyXBMCGetUnicodeString(self->strText, pObjectText, 5)) return NULL;
78
79     // SetLabel(const CStdString& strFontName,const CStdString& strLabel,D3DCOLOR dwColor)
80     self->strFont = "font13";
81     self->textColor = 0xffffffff;
82     self->disabledColor = 0x60ffffff;
83
84     self->strTextureFocus = cTextureFocus ? cTextureFocus : "button-focus.png";
85     self->strTextureNoFocus = cTextureNoFocus ? cTextureNoFocus : "button-nofocus.jpg";
86
87     return (PyObject*)self;
88   }
89 */
90   /*
91    * allocate a new controlspin. Used for c++ and not the python user
92    */
93   PyObject* ControlSpin_New()
94   {
95     //ControlSpin* self = (ControlSpin*)_PyObject_New(&ControlSpin_Type);
96     ControlSpin*self = (ControlSpin*)ControlSpin_Type.tp_alloc(&ControlSpin_Type, 0);
97     if (!self) return NULL;
98     new(&self->strTextureUp) string();
99     new(&self->strTextureDown) string();
100     new(&self->strTextureUpFocus) string();
101     new(&self->strTextureDownFocus) string();
102
103     // default values for spin control
104     self->color = 0xffffffff;
105     self->dwPosX = 0;
106     self->dwPosY = 0;
107     self->dwWidth = 16;
108     self->dwHeight = 16;
109
110     // get default images
111     self->strTextureUp = PyXBMCGetDefaultImage((char*)"listcontrol", (char*)"textureup", (char*)"scroll-up.png");
112     self->strTextureDown = PyXBMCGetDefaultImage((char*)"listcontrol", (char*)"texturedown", (char*)"scroll-down.png");
113     self->strTextureUpFocus = PyXBMCGetDefaultImage((char*)"listcontrol", (char*)"textureupfocus", (char*)"scroll-up-focus.png");
114     self->strTextureDownFocus = PyXBMCGetDefaultImage((char*)"listcontrol", (char*)"texturedownfocus", (char*)"scroll-down-focus.png");
115
116     return (PyObject*)self;
117   }
118
119   void ControlSpin_Dealloc(ControlSpin* self)
120   {
121     self->strTextureUp.~string();
122     self->strTextureDown.~string();
123     self->strTextureUpFocus.~string();
124     self->strTextureDownFocus.~string();
125     self->ob_type->tp_free((PyObject*)self);
126   }
127
128   PyObject* ControlSpin_SetColor(ControlSpin *self, PyObject *args)
129   {
130     char *cColor = NULL;
131
132     if (!PyArg_ParseTuple(args, (char*)"s", &cColor)) return NULL;
133
134     if (cColor) sscanf(cColor, "%x", &self->color);
135
136     PyXBMCGUILock();
137     //if (self->pGUIControl)
138       //((CGUISpinControl*)self->pGUIControl)->SetColor(self->dwDColor);
139     PyXBMCGUIUnlock();
140
141     Py_INCREF(Py_None);
142     return Py_None;
143   }
144
145   /*
146    * set textures
147    * (string textureUp, string textureDown, string textureUpFocus, string textureDownFocus)
148    */
149   PyDoc_STRVAR(setTextures__doc__,
150     "setTextures(up, down, upFocus, downFocus) -- Set's textures for this control.\n"
151     "\n"
152     "texture are image files that are used for example in the skin");
153
154   PyObject* ControlSpin_SetTextures(ControlSpin *self, PyObject *args)
155   {
156     char *cLine[4];
157
158     if (!PyArg_ParseTuple(args, (char*)"ssss", &cLine[0], &cLine[1], &cLine[2], &cLine[3])) return NULL;
159
160     self->strTextureUp = cLine[0];
161     self->strTextureDown = cLine[1];
162     self->strTextureUpFocus = cLine[2];
163     self->strTextureDownFocus = cLine[3];
164     /*
165     PyXBMCGUILock();
166     if (self->pGUIControl)
167     {
168       CGUISpinControl* pControl = (CGUISpinControl*)self->pGUIControl;
169       pControl->se
170     PyXBMCGUIUnlock();
171     */
172     Py_INCREF(Py_None);
173     return Py_None;
174   }
175
176   PyMethodDef ControlSpin_methods[] = {
177     //{(char*)"setColor", (PyCFunction)ControlSpin_SetColor, METH_VARARGS, ""},
178     {(char*)"setTextures", (PyCFunction)ControlSpin_SetTextures, METH_VARARGS, setTextures__doc__},
179     {NULL, NULL, 0, NULL}
180   };
181
182   PyDoc_STRVAR(controlSpin__doc__,
183     "ControlSpin class.\n"
184     "\n"
185     " - Not working yet -.\n"
186     "\n"
187     "you can't create this object, it is returned by objects like ControlTextBox and ControlList.");
188
189 // Restore code and data sections to normal.
190 #ifndef __GNUC__
191 #pragma code_seg()
192 #pragma data_seg()
193 #pragma bss_seg()
194 #pragma const_seg()
195 #endif
196
197   PyTypeObject ControlSpin_Type;
198
199   void initControlSpin_Type()
200   {
201     PyXBMCInitializeTypeObject(&ControlSpin_Type);
202
203     ControlSpin_Type.tp_name = (char*)"xbmcgui.ControlSpin";
204     ControlSpin_Type.tp_basicsize = sizeof(ControlSpin);
205     ControlSpin_Type.tp_dealloc = (destructor)ControlSpin_Dealloc;
206     ControlSpin_Type.tp_compare = 0;
207     ControlSpin_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
208     ControlSpin_Type.tp_doc = controlSpin__doc__;
209     ControlSpin_Type.tp_methods = ControlSpin_methods;
210     ControlSpin_Type.tp_base = &Control_Type;
211     ControlSpin_Type.tp_new = 0; //ControlSpin_New
212   }
213 }
214
215 #ifdef __cplusplus
216 }
217 #endif