2 * Copyright (C) 2005-2008 Team XBMC
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)
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.
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
24 #include "../XBPythonDll.h"
26 #include "guilib/GUIColorManager.h"
32 // python type checking
33 #define Control_Check(op) PyObject_TypeCheck(op, &Control_Type)
34 #define Control_CheckExact(op) ((op)->ob_type == &Control_Type)
36 #define ControlButton_Check(op) PyObject_TypeCheck(op, &ControlButton_Type)
37 #define ControlButton_CheckExact(op) ((op)->ob_type == &ControlButton_Type)
39 #define ControlCheckMark_Check(op) PyObject_TypeCheck(op, &ControlCheckMark_Type)
40 #define ControlCheckMark_CheckExact(op) ((op)->ob_type == &ControlCheckMark_Type)
42 #define ControlProgress_Check(op) PyObject_TypeCheck(op, &ControlProgress_Type)
43 #define ControlProgress__CheckExact(op) ((op)->ob_type == &ControlProgress_Type)
45 #define ControlList_Check(op) PyObject_TypeCheck(op, &ControlList_Type)
46 #define ControlList_CheckExact(op) ((op)->ob_type == &ControlList_Type)
48 #define ControlSpin_Check(op) PyObject_TypeCheck(op, &ControlSpin_Type)
49 #define ControlSpin_CheckExact(op) ((op)->ob_type == &ControlSpin_Type)
51 #define ControlLabel_Check(op) PyObject_TypeCheck(op, &ControlLabel_Type)
52 #define ControlLabel_CheckExact(op) ((op)->ob_type == &ControlLabel_Type)
54 #define ControlFadeLabel_Check(op) PyObject_TypeCheck(op, &ControlFadeLabel_Type)
55 #define ControlFadeLabel_CheckExact(op) ((op)->ob_type == &ControlFadeLabel_Type)
57 #define ControlTextBox_Check(op) PyObject_TypeCheck(op, &ControlTextBox_Type)
58 #define ControlTextBox_CheckExact(op) ((op)->ob_type == &ControlTextBox_Type)
60 #define ControlImage_Check(op) PyObject_TypeCheck(op, &ControlImage_Type)
61 #define ControlImage_CheckExact(op) ((op)->ob_type == &ControlImage_Type)
63 #define ControlGroup_Check(op) PyObject_TypeCheck(op, &ControlGroup_Type)
64 #define ControlGroup_CheckExact(op) ((op)->ob_type == &ControlGroup_Type)
66 #define ControlRadioButton_Check(op) PyObject_TypeCheck(op, &ControlRadioButton_Type)
67 #define ControlRadioButton_CheckExact(op) ((op)->ob_type == &ControlRadioButton_Type)
69 #define ControlSlider_Check(op) PyObject_TypeCheck(op, &ControlSlider_Type)
70 #define ControlSlider_CheckExact(op) ((op)->ob_type == &ControlSlider_Type)
74 // hardcoded offsets for button controls (and controls that use button controls)
75 // ideally they should be dynamically read in as with all the other properties.
76 #define CONTROL_TEXT_OFFSET_X 10
77 #define CONTROL_TEXT_OFFSET_Y 2
79 #define PyObject_HEAD_XBMC_CONTROL \
91 CGUIControl* pGUIControl;
100 PyObject_HEAD_XBMC_CONTROL
104 PyObject_HEAD_XBMC_CONTROL
106 std::string strTextureUp;
107 std::string strTextureDown;
108 std::string strTextureUpFocus;
109 std::string strTextureDownFocus;
113 PyObject_HEAD_XBMC_CONTROL
117 color_t disabledColor;
125 PyObject_HEAD_XBMC_CONTROL
128 std::vector<std::string> vecLabels;
133 PyObject_HEAD_XBMC_CONTROL
139 PyObject_HEAD_XBMC_CONTROL
140 std::string strFileName;
142 color_t colorDiffuse;
146 PyObject_HEAD_XBMC_CONTROL
147 std::string strTextureLeft;
148 std::string strTextureMid;
149 std::string strTextureRight;
150 std::string strTextureBg;
151 std::string strTextureOverlay;
153 color_t colorDiffuse;
157 PyObject_HEAD_XBMC_CONTROL
160 std::string strText2;
161 std::string strTextureFocus;
162 std::string strTextureNoFocus;
164 color_t disabledColor;
174 PyObject_HEAD_XBMC_CONTROL
177 std::string strTextureFocus;
178 std::string strTextureNoFocus;
180 color_t disabledColor;
187 PyObject_HEAD_XBMC_CONTROL
188 std::vector<PYXBMC::ListItem*> vecItems;
190 ControlSpin* pControlSpin;
193 color_t selectedColor;
194 std::string strTextureButton;
195 std::string strTextureButtonFocus;
208 PyObject_HEAD_XBMC_CONTROL
212 PyObject_HEAD_XBMC_CONTROL
215 std::string strTextureFocus;
216 std::string strTextureNoFocus;
217 std::string strTextureRadioFocus;
218 std::string strTextureRadioNoFocus;
220 color_t disabledColor;
226 color_t focusedColor;
227 } ControlRadioButton;
230 PyObject_HEAD_XBMC_CONTROL
231 std::string strTextureBack;
232 std::string strTexture;
233 std::string strTextureFoc;
236 extern void Control_Dealloc(Control* self);
238 extern PyMethodDef Control_methods[];
240 extern PyTypeObject Control_Type;
241 extern PyTypeObject ControlSpin_Type;
242 extern PyTypeObject ControlLabel_Type;
243 extern PyTypeObject ControlFadeLabel_Type;
244 extern PyTypeObject ControlTextBox_Type;
245 extern PyTypeObject ControlImage_Type;
246 extern PyTypeObject ControlGroup_Type;
247 extern PyTypeObject ControlButton_Type;
248 extern PyTypeObject ControlCheckMark_Type;
249 extern PyTypeObject ControlList_Type;
250 extern PyTypeObject ControlProgress_Type;
251 extern PyTypeObject ControlRadioButton_Type;
252 extern PyTypeObject ControlSlider_Type;
254 CGUIControl* ControlLabel_Create(ControlLabel* pControl);
255 CGUIControl* ControlFadeLabel_Create(ControlFadeLabel* pControl);
256 CGUIControl* ControlTextBox_Create(ControlTextBox* pControl);
257 CGUIControl* ControlButton_Create(ControlButton* pControl);
258 CGUIControl* ControlCheckMark_Create(ControlCheckMark* pControl);
259 CGUIControl* ControlImage_Create(ControlImage* pControl);
260 CGUIControl* ControlGroup_Create(ControlGroup* pControl);
261 CGUIControl* ControlList_Create(ControlList* pControl);
262 CGUIControl* ControlProgress_Create(ControlProgress* pControl);
263 CGUIControl* ControlRadioButton_Create(ControlRadioButton* pControl);
264 CGUIControl* ControlSlider_Create(ControlSlider* pControl);
266 void initControl_Type();
267 void initControlSpin_Type();
268 void initControlLabel_Type();
269 void initControlFadeLabel_Type();
270 void initControlTextBox_Type();
271 void initControlButton_Type();
272 void initControlCheckMark_Type();
273 void initControlList_Type();
274 void initControlImage_Type();
275 void initControlGroup_Type();
276 void initControlProgress_Type();
277 void initControlRadioButton_Type();
278 void initControlSlider_Type();