Mercurial > projects > doodle
view tk/types.d @ 26:06c30d250c0a
Cleanup
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Thu, 16 Jul 2009 00:12:02 +0930 |
parents | 9e63308b749c |
children |
line wrap: on
line source
module tk.types; public { import std.string; } private { import std.typecons; import std.algorithm; } mixin(defineEnum!("ButtonAction", "SINGLE_PRESS", "DOUBLE_PRESS", "TRIPLE_PRESS", "RELEASE")); mixin(defineEnum!("ButtonName", "LEFT", "MIDDLE", "RIGHT", "FOUR", "FIVE")); mixin(defineEnum!("ScrollDirection", "UP", "DOWN", "LEFT", "RIGHT")); mixin(defineEnum!("Modifier", "SHIFT", "CAPS_LOCK", "CONTROL", "ALT", "NUM_LOCK", "META", "SCROLL_LOCK", "LEFT_BUTTON", "MIDDLE_BUTTON", "RIGHT_BUTTON", "UNUSED_BUTTON_1", "UNUSED_BUTTON_2")); struct Mask { this(in Modifier[] modifiers) { foreach (ref m; modifiers) { _bits |= 1 << m; } } string toString() { string s; // FIXME this is terrible for (int i = 0; i < uint.sizeof * 8; ++i) { if (_bits & (1 << i)) { if (s != "") s ~= "|"; s ~= enumToString(cast(Modifier)i); } } return s; } bool is_set(in Modifier m) const { return _bits & (1 << m); } bool is_unset(in Modifier m) const { return !is_set(m); } private { uint _bits; } }