/
control.h
283 lines (239 loc) · 8.43 KB
/
control.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include <Python.h>
#include "../XBPythonDll.h"
#include "listitem.h"
#include "guilib/GUIColorManager.h"
#pragma once
class CGUIControl;
// python type checking
#define Control_Check(op) PyObject_TypeCheck(op, &Control_Type)
#define Control_CheckExact(op) ((op)->ob_type == &Control_Type)
#define ControlButton_Check(op) PyObject_TypeCheck(op, &ControlButton_Type)
#define ControlButton_CheckExact(op) ((op)->ob_type == &ControlButton_Type)
#define ControlCheckMark_Check(op) PyObject_TypeCheck(op, &ControlCheckMark_Type)
#define ControlCheckMark_CheckExact(op) ((op)->ob_type == &ControlCheckMark_Type)
#define ControlProgress_Check(op) PyObject_TypeCheck(op, &ControlProgress_Type)
#define ControlProgress__CheckExact(op) ((op)->ob_type == &ControlProgress_Type)
#define ControlList_Check(op) PyObject_TypeCheck(op, &ControlList_Type)
#define ControlList_CheckExact(op) ((op)->ob_type == &ControlList_Type)
#define ControlSpin_Check(op) PyObject_TypeCheck(op, &ControlSpin_Type)
#define ControlSpin_CheckExact(op) ((op)->ob_type == &ControlSpin_Type)
#define ControlLabel_Check(op) PyObject_TypeCheck(op, &ControlLabel_Type)
#define ControlLabel_CheckExact(op) ((op)->ob_type == &ControlLabel_Type)
#define ControlFadeLabel_Check(op) PyObject_TypeCheck(op, &ControlFadeLabel_Type)
#define ControlFadeLabel_CheckExact(op) ((op)->ob_type == &ControlFadeLabel_Type)
#define ControlTextBox_Check(op) PyObject_TypeCheck(op, &ControlTextBox_Type)
#define ControlTextBox_CheckExact(op) ((op)->ob_type == &ControlTextBox_Type)
#define ControlImage_Check(op) PyObject_TypeCheck(op, &ControlImage_Type)
#define ControlImage_CheckExact(op) ((op)->ob_type == &ControlImage_Type)
#define ControlGroup_Check(op) PyObject_TypeCheck(op, &ControlGroup_Type)
#define ControlGroup_CheckExact(op) ((op)->ob_type == &ControlGroup_Type)
#define ControlRadioButton_Check(op) PyObject_TypeCheck(op, &ControlRadioButton_Type)
#define ControlRadioButton_CheckExact(op) ((op)->ob_type == &ControlRadioButton_Type)
#define ControlSlider_Check(op) PyObject_TypeCheck(op, &ControlSlider_Type)
#define ControlSlider_CheckExact(op) ((op)->ob_type == &ControlSlider_Type)
// -----------------
// hardcoded offsets for button controls (and controls that use button controls)
// ideally they should be dynamically read in as with all the other properties.
#define CONTROL_TEXT_OFFSET_X 10
#define CONTROL_TEXT_OFFSET_Y 2
#define PyObject_HEAD_XBMC_CONTROL \
PyObject_HEAD \
int iControlId; \
int iParentId; \
int dwPosX; \
int dwPosY; \
int dwWidth; \
int dwHeight; \
int iControlUp; \
int iControlDown; \
int iControlLeft; \
int iControlRight; \
CGUIControl* pGUIControl;
#ifdef __cplusplus
extern "C" {
#endif
namespace PYXBMC
{
typedef struct {
PyObject_HEAD_XBMC_CONTROL
} Control;
typedef struct {
PyObject_HEAD_XBMC_CONTROL
color_t color;
std::string strTextureUp;
std::string strTextureDown;
std::string strTextureUpFocus;
std::string strTextureDownFocus;
} ControlSpin;
typedef struct {
PyObject_HEAD_XBMC_CONTROL
std::string strFont;
std::string strText;
color_t textColor;
color_t disabledColor;
uint32_t align;
bool bHasPath;
int iAngle;
} ControlLabel;
typedef struct {
PyObject_HEAD_XBMC_CONTROL
std::string strFont;
color_t textColor;
std::vector<std::string> vecLabels;
uint32_t align;
} ControlFadeLabel;
typedef struct {
PyObject_HEAD_XBMC_CONTROL
std::string strFont;
color_t textColor;
} ControlTextBox;
typedef struct {
PyObject_HEAD_XBMC_CONTROL
std::string strFileName;
int aspectRatio;
color_t colorDiffuse;
} ControlImage;
typedef struct {
PyObject_HEAD_XBMC_CONTROL
std::string strTextureLeft;
std::string strTextureMid;
std::string strTextureRight;
std::string strTextureBg;
std::string strTextureOverlay;
int aspectRatio;
color_t colorDiffuse;
} ControlProgress;
typedef struct {
PyObject_HEAD_XBMC_CONTROL
std::string strFont;
std::string strText;
std::string strText2;
std::string strTextureFocus;
std::string strTextureNoFocus;
color_t textColor;
color_t disabledColor;
int textOffsetX;
int textOffsetY;
color_t align;
int iAngle;
int shadowColor;
int focusedColor;
} ControlButton;
typedef struct {
PyObject_HEAD_XBMC_CONTROL
std::string strFont;
std::string strText;
std::string strTextureFocus;
std::string strTextureNoFocus;
color_t textColor;
color_t disabledColor;
int checkWidth;
int checkHeight;
uint32_t align;
} ControlCheckMark;
typedef struct {
PyObject_HEAD_XBMC_CONTROL
std::vector<PYXBMC::ListItem*> vecItems;
std::string strFont;
ControlSpin* pControlSpin;
color_t textColor;
color_t selectedColor;
std::string strTextureButton;
std::string strTextureButtonFocus;
int imageHeight;
int imageWidth;
int itemHeight;
int space;
int itemTextOffsetX;
int itemTextOffsetY;
uint32_t alignmentY;
} ControlList;
typedef struct {
PyObject_HEAD_XBMC_CONTROL
} ControlGroup;
typedef struct {
PyObject_HEAD_XBMC_CONTROL
std::string strFont;
std::string strText;
std::string strTextureFocus;
std::string strTextureNoFocus;
std::string strTextureRadioFocus;
std::string strTextureRadioNoFocus;
color_t textColor;
color_t disabledColor;
int textOffsetX;
int textOffsetY;
uint32_t align;
int iAngle;
color_t shadowColor;
color_t focusedColor;
} ControlRadioButton;
typedef struct {
PyObject_HEAD_XBMC_CONTROL
std::string strTextureBack;
std::string strTexture;
std::string strTextureFoc;
} ControlSlider;
extern void Control_Dealloc(Control* self);
extern PyMethodDef Control_methods[];
extern PyTypeObject Control_Type;
extern PyTypeObject ControlSpin_Type;
extern PyTypeObject ControlLabel_Type;
extern PyTypeObject ControlFadeLabel_Type;
extern PyTypeObject ControlTextBox_Type;
extern PyTypeObject ControlImage_Type;
extern PyTypeObject ControlGroup_Type;
extern PyTypeObject ControlButton_Type;
extern PyTypeObject ControlCheckMark_Type;
extern PyTypeObject ControlList_Type;
extern PyTypeObject ControlProgress_Type;
extern PyTypeObject ControlRadioButton_Type;
extern PyTypeObject ControlSlider_Type;
CGUIControl* ControlLabel_Create(ControlLabel* pControl);
CGUIControl* ControlFadeLabel_Create(ControlFadeLabel* pControl);
CGUIControl* ControlTextBox_Create(ControlTextBox* pControl);
CGUIControl* ControlButton_Create(ControlButton* pControl);
CGUIControl* ControlCheckMark_Create(ControlCheckMark* pControl);
CGUIControl* ControlImage_Create(ControlImage* pControl);
CGUIControl* ControlGroup_Create(ControlGroup* pControl);
CGUIControl* ControlList_Create(ControlList* pControl);
CGUIControl* ControlProgress_Create(ControlProgress* pControl);
CGUIControl* ControlRadioButton_Create(ControlRadioButton* pControl);
CGUIControl* ControlSlider_Create(ControlSlider* pControl);
void initControl_Type();
void initControlSpin_Type();
void initControlLabel_Type();
void initControlFadeLabel_Type();
void initControlTextBox_Type();
void initControlButton_Type();
void initControlCheckMark_Type();
void initControlList_Type();
void initControlImage_Type();
void initControlGroup_Type();
void initControlProgress_Type();
void initControlRadioButton_Type();
void initControlSlider_Type();
}
#ifdef __cplusplus
}
#endif