diff options
Diffstat (limited to 'src/ScreenPlacement.cc')
-rw-r--r-- | src/ScreenPlacement.cc | 143 |
1 files changed, 19 insertions, 124 deletions
diff --git a/src/ScreenPlacement.cc b/src/ScreenPlacement.cc index cd7ce15..2a743ce 100644 --- a/src/ScreenPlacement.cc +++ b/src/ScreenPlacement.cc | |||
@@ -182,133 +182,28 @@ void ScreenPlacement::placeAndShowMenu(FbTk::Menu& menu, int x, int y, bool resp | |||
182 | namespace FbTk { | 182 | namespace FbTk { |
183 | 183 | ||
184 | template <> | 184 | template <> |
185 | std::string FbTk::Resource<ScreenPlacement::PlacementPolicy>::getString() const { | 185 | const EnumTraits<ScreenPlacement::PlacementPolicy>::Pair EnumTraits<ScreenPlacement::PlacementPolicy>::s_map[] = { |
186 | switch (*(*this)) { | 186 | { "RowSmartPlacement", ScreenPlacement::ROWSMARTPLACEMENT }, |
187 | case ScreenPlacement::ROWSMARTPLACEMENT: | 187 | { "ColSmartPlacement", ScreenPlacement::COLSMARTPLACEMENT }, |
188 | return "RowSmartPlacement"; | 188 | { "RowMinOverlapPlacement", ScreenPlacement::ROWMINOVERLAPPLACEMENT }, |
189 | case ScreenPlacement::COLSMARTPLACEMENT: | 189 | { "ColMinOverlapPlacement", ScreenPlacement::COLMINOVERLAPPLACEMENT }, |
190 | return "ColSmartPlacement"; | 190 | { "UnderMousePlacement", ScreenPlacement::UNDERMOUSEPLACEMENT }, |
191 | case ScreenPlacement::ROWMINOVERLAPPLACEMENT: | 191 | { "CascadePlacement", ScreenPlacement::CASCADEPLACEMENT }, |
192 | return "RowMinOverlapPlacement"; | 192 | { NULL, ScreenPlacement::CASCADEPLACEMENT } |
193 | case ScreenPlacement::COLMINOVERLAPPLACEMENT: | 193 | }; |
194 | return "ColMinOverlapPlacement"; | ||
195 | case ScreenPlacement::UNDERMOUSEPLACEMENT: | ||
196 | return "UnderMousePlacement"; | ||
197 | case ScreenPlacement::CASCADEPLACEMENT: | ||
198 | return "CascadePlacement"; | ||
199 | } | ||
200 | |||
201 | return "RowSmartPlacement"; | ||
202 | } | ||
203 | 194 | ||
204 | template <> | 195 | template <> |
205 | void FbTk::Resource<ScreenPlacement::PlacementPolicy>::setFromString(const char *str) { | 196 | const EnumTraits<ScreenPlacement::RowDirection>::Pair EnumTraits<ScreenPlacement::RowDirection>::s_map[] = { |
206 | if (strcasecmp("RowSmartPlacement", str) == 0) | 197 | { "LeftToRight", ScreenPlacement::LEFTRIGHT }, |
207 | *(*this) = ScreenPlacement::ROWSMARTPLACEMENT; | 198 | { "RightToLeft", ScreenPlacement::RIGHTLEFT }, |
208 | else if (strcasecmp("ColSmartPlacement", str) == 0) | 199 | { NULL, ScreenPlacement::RIGHTLEFT }, |
209 | *(*this) = ScreenPlacement::COLSMARTPLACEMENT; | 200 | }; |
210 | else if (strcasecmp("RowMinOverlapPlacement", str) == 0) | ||
211 | *(*this) = ScreenPlacement::ROWMINOVERLAPPLACEMENT; | ||
212 | else if (strcasecmp("ColMinOverlapPlacement", str) == 0) | ||
213 | *(*this) = ScreenPlacement::COLMINOVERLAPPLACEMENT; | ||
214 | else if (strcasecmp("UnderMousePlacement", str) == 0) | ||
215 | *(*this) = ScreenPlacement::UNDERMOUSEPLACEMENT; | ||
216 | else if (strcasecmp("CascadePlacement", str) == 0) | ||
217 | *(*this) = ScreenPlacement::CASCADEPLACEMENT; | ||
218 | else | ||
219 | setDefaultValue(); | ||
220 | } | ||
221 | |||
222 | template<> | ||
223 | void FbTk::Resource<ScreenPlacement::PlacementPolicy>::setFromLua(lua::state &l) { | ||
224 | lua::stack_sentry s(l, -1); | ||
225 | if(l.isstring(-1)) | ||
226 | setFromString(l.tostring(-1).c_str()); | ||
227 | else | ||
228 | setDefaultValue(); | ||
229 | l.pop(); | ||
230 | } | ||
231 | |||
232 | template<> | ||
233 | void FbTk::Resource<ScreenPlacement::PlacementPolicy>::pushToLua(lua::state &l) const { | ||
234 | l.pushstring(getString()); | ||
235 | } | ||
236 | |||
237 | 201 | ||
238 | template <> | 202 | template <> |
239 | std::string FbTk::Resource<ScreenPlacement::RowDirection>::getString() const { | 203 | const EnumTraits<ScreenPlacement::ColumnDirection>::Pair EnumTraits<ScreenPlacement::ColumnDirection>::s_map[] = { |
240 | switch (*(*this)) { | 204 | { "TopToBottom", ScreenPlacement::TOPBOTTOM }, |
241 | case ScreenPlacement::LEFTRIGHT: | 205 | { "BottomToTop", ScreenPlacement::BOTTOMTOP }, |
242 | return "LeftToRight"; | 206 | { NULL, ScreenPlacement::BOTTOMTOP }, |
243 | case ScreenPlacement::RIGHTLEFT: | 207 | }; |
244 | return "RightToLeft"; | ||
245 | } | ||
246 | |||
247 | return "LeftToRight"; | ||
248 | } | ||
249 | |||
250 | |||
251 | template <> | ||
252 | void FbTk::Resource<ScreenPlacement::RowDirection>::setFromString(const char *str) { | ||
253 | if (strcasecmp("LeftToRight", str) == 0) | ||
254 | *(*this) = ScreenPlacement::LEFTRIGHT; | ||
255 | else if (strcasecmp("RightToLeft", str) == 0) | ||
256 | *(*this) = ScreenPlacement::RIGHTLEFT; | ||
257 | else | ||
258 | setDefaultValue(); | ||
259 | } | ||
260 | |||
261 | template<> | ||
262 | void FbTk::Resource<ScreenPlacement::RowDirection>::setFromLua(lua::state &l) { | ||
263 | lua::stack_sentry s(l, -1); | ||
264 | if(l.isstring(-1)) | ||
265 | setFromString(l.tostring(-1).c_str()); | ||
266 | else | ||
267 | setDefaultValue(); | ||
268 | l.pop(); | ||
269 | } | ||
270 | |||
271 | template<> | ||
272 | void FbTk::Resource<ScreenPlacement::RowDirection>::pushToLua(lua::state &l) const { | ||
273 | l.pushstring(getString()); | ||
274 | } | ||
275 | |||
276 | template <> | ||
277 | std::string FbTk::Resource<ScreenPlacement::ColumnDirection>::getString() const { | ||
278 | switch (*(*this)) { | ||
279 | case ScreenPlacement::TOPBOTTOM: | ||
280 | return "TopToBottom"; | ||
281 | case ScreenPlacement::BOTTOMTOP: | ||
282 | return "BottomToTop"; | ||
283 | } | ||
284 | |||
285 | return "TopToBottom"; | ||
286 | } | ||
287 | |||
288 | |||
289 | template <> | ||
290 | void FbTk::Resource<ScreenPlacement::ColumnDirection>::setFromString(const char *str) { | ||
291 | if (strcasecmp("TopToBottom", str) == 0) | ||
292 | *(*this) = ScreenPlacement::TOPBOTTOM; | ||
293 | else if (strcasecmp("BottomToTop", str) == 0) | ||
294 | *(*this) = ScreenPlacement::BOTTOMTOP; | ||
295 | else | ||
296 | setDefaultValue(); | ||
297 | } | ||
298 | |||
299 | template<> | ||
300 | void FbTk::Resource<ScreenPlacement::ColumnDirection>::setFromLua(lua::state &l) { | ||
301 | lua::stack_sentry s(l, -1); | ||
302 | if(l.isstring(-1)) | ||
303 | setFromString(l.tostring(-1).c_str()); | ||
304 | else | ||
305 | setDefaultValue(); | ||
306 | l.pop(); | ||
307 | } | ||
308 | |||
309 | template<> | ||
310 | void FbTk::Resource<ScreenPlacement::ColumnDirection>::pushToLua(lua::state &l) const { | ||
311 | l.pushstring(getString()); | ||
312 | } | ||
313 | 208 | ||
314 | } // end namespace FbTk | 209 | } // end namespace FbTk |