push 0f6a7ee30aa1574a9ae1569d743dbd53d0ff58b0
[tagua/yd.git] / src / luaapi / options.h
blob5297d44bd356c4d1ec22e91ec560822141975009
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
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 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef LUAAPI__OPTIONS_H
12 #define LUAAPI__OPTIONS_H
14 #include "option.h"
15 #include "luaapi/genericwrapper.h"
16 #include "luaapi/imaging.h"
18 namespace LuaApi {
20 //BEGIN Wrapper<OptList> -------------------------------------------------------
22 template <>
23 class Wrapper<OptList> : public GenericWrapperByValue<OptList> {
24 public:
25 static const char* class_name();
26 static int to_string(lua_State* l);
27 static void create_index_table(lua_State* l);
28 static int constructor(lua_State* l);
29 static int newindex_event(lua_State* l);
30 static int index_event(lua_State* l);
33 //END Wrapper<OptList> ---------------------------------------------------------
35 //BEGIN Wrapper<BoolOptList> -------------------------------------------------------
37 template <>
38 class Wrapper<BoolOptList> : public GenericWrapperByValue<BoolOptList> {
39 public:
40 static const char* class_name();
41 static int to_string(lua_State* l);
42 static void create_index_table(lua_State* l);
43 static int constructor(lua_State* l);
44 static int newindex_event(lua_State* l);
45 static int index_event(lua_State* l);
48 //END Wrapper<BoolOptList> ---------------------------------------------------------
50 //BEGIN Wrapper<BoolOptPtr> -------------------------------------------------------
52 template <>
53 class Wrapper<BoolOptPtr> : public GenericWrapperByValue<BoolOptPtr> {
54 public:
55 PROPERTY_RO_QSTRING(name, get()->name)
56 PROPERTY_RO_QSTRING(label, get()->label)
57 PROPERTY_RO_CLASS(sub_options, get()->subOptions, OptList)
58 PROPERTY_RW(value, get()->value, get()->setValue, boolean)
60 static const char* class_name();
61 static int to_string(lua_State* l);
62 static void create_index_table(lua_State* l);
63 static int constructor(lua_State* l);
66 //END Wrapper<BoolOptPtr> ---------------------------------------------------------
68 //BEGIN Wrapper<IntOptPtr> -------------------------------------------------------
70 template <>
71 class Wrapper<IntOptPtr> : public GenericWrapperByValue<IntOptPtr> {
72 public:
73 PROPERTY_RO_QSTRING(name, get()->name)
74 PROPERTY_RO_QSTRING(label, get()->label)
75 PROPERTY_RO_TYPE(min, get()->min, number, int)
76 PROPERTY_RO_TYPE(max, get()->max, number, int)
77 PROPERTY_RW_TYPE(value, get()->value, get()->setValue, number, int)
78 static int get_visualization(lua_State* l) {
79 IntOpt::Visualization vis = retrieve(l, 1, DontCheck)->get()->visualization();
80 switch (vis) {
81 case IntOpt::SpinBox:
82 lua_pushstring(l, "spinbox");
83 break;
84 case IntOpt::Slider:
85 lua_pushstring(l, "slider");
86 break;
88 return 1;
91 static const char* class_name();
92 static int to_string(lua_State* l);
93 static void create_index_table(lua_State* l);
94 static int constructor(lua_State* l);
97 //END Wrapper<IntOptPtr> ---------------------------------------------------------
100 //BEGIN Wrapper<StringOptPtr> -------------------------------------------------------
102 template <>
103 class Wrapper<StringOptPtr> : public GenericWrapperByValue<StringOptPtr> {
104 public:
105 PROPERTY_RO_QSTRING(name, get()->name)
106 PROPERTY_RO_QSTRING(label, get()->label)
107 PROPERTY_RW_QSTRING(value, get()->value, get()->setValue)
109 static const char* class_name();
110 static int to_string(lua_State* l);
111 static void create_index_table(lua_State* l);
112 static int constructor(lua_State* l);
115 //END Wrapper<StringOptPtr> ---------------------------------------------------------
118 //BEGIN Wrapper<UrlOptPtr> -------------------------------------------------------
120 template <>
121 class Wrapper<UrlOptPtr> : public GenericWrapperByValue<UrlOptPtr> {
122 public:
123 PROPERTY_RO_QSTRING(name, get()->name)
124 PROPERTY_RO_QSTRING(label, get()->label)
125 PROPERTY_RW_QSTRING(value, get()->value, get()->setValue)
127 static const char* class_name();
128 static int to_string(lua_State* l);
129 static void create_index_table(lua_State* l);
130 static int constructor(lua_State* l);
133 //END Wrapper<UrlOptPtr> ---------------------------------------------------------
136 //BEGIN Wrapper<ColorOptPtr> -------------------------------------------------------
138 template <>
139 class Wrapper<ColorOptPtr> : public GenericWrapperByValue<ColorOptPtr> {
140 public:
141 PROPERTY_RO_QSTRING(name, get()->name)
142 PROPERTY_RO_QSTRING(label, get()->label)
143 PROPERTY_RW_CLASS(value, get()->value, get()->setValue, QColor)
145 static const char* class_name();
146 static int to_string(lua_State* l);
147 static void create_index_table(lua_State* l);
148 static int constructor(lua_State* l);
151 //END Wrapper<ColorOptPtr> ---------------------------------------------------------
154 //BEGIN Wrapper<FontOptPtr> -------------------------------------------------------
156 template <>
157 class Wrapper<FontOptPtr> : public GenericWrapperByValue<FontOptPtr> {
158 public:
159 PROPERTY_RO_QSTRING(name, get()->name)
160 PROPERTY_RO_QSTRING(label, get()->label)
161 PROPERTY_RW_CLASS(value, get()->value, get()->setValue, QFont)
163 static const char* class_name();
164 static int to_string(lua_State* l);
165 static void create_index_table(lua_State* l);
166 static int constructor(lua_State* l);
169 //END Wrapper<FontOptPtr> ---------------------------------------------------------
172 //BEGIN Wrapper<ComboOptPtr> -------------------------------------------------------
174 template <>
175 class Wrapper<ComboOptPtr> : public GenericWrapperByValue<ComboOptPtr> {
176 public:
177 PROPERTY_RO_QSTRING(name, get()->name)
178 PROPERTY_RO_QSTRING(label, get()->label)
179 PROPERTY_RW_TYPE(selected, get()->selected, get()->setSelected, number, int)
181 static const char* class_name();
182 static int to_string(lua_State* l);
183 static void create_index_table(lua_State* l);
184 static int constructor(lua_State* l);
187 //END Wrapper<ComboOptPtr> ---------------------------------------------------------
190 //BEGIN Wrapper<SelectOptPtr> -------------------------------------------------------
192 template <>
193 class Wrapper<SelectOptPtr> : public GenericWrapperByValue<SelectOptPtr> {
194 public:
195 PROPERTY_RO_QSTRING(name, get()->name)
196 PROPERTY_RO_QSTRING(label, get()->label)
197 PROPERTY_RO_CLASS(options, get()->options, BoolOptList)
198 PROPERTY_RW_TYPE(selected, get()->selected, get()->setSelected, number, int)
200 static const char* class_name();
201 static int to_string(lua_State* l);
202 static void create_index_table(lua_State* l);
203 static int constructor(lua_State* l);
206 //END Wrapper<SelectOptPtr> ---------------------------------------------------------
208 } //end namespace luaapi
210 #endif //LUAAPI__OPTIONS_H