Mercurial > projects > dynamin
comparison dynamin/gui/list_box.d @ 106:acdbb30fee7e
Port to D2.
Most of the effort was dealing with immutable and const.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Mon, 17 Dec 2012 23:41:50 -0600 |
parents | 73060bc3f004 |
children |
comparison
equal
deleted
inserted
replaced
105:97997a544ac0 | 106:acdbb30fee7e |
---|---|
21 * | 21 * |
22 * $(IMAGE ../web/example_list_box.png) | 22 * $(IMAGE ../web/example_list_box.png) |
23 */ | 23 */ |
24 class ListBox : Scrollable { | 24 class ListBox : Scrollable { |
25 protected: | 25 protected: |
26 List!(string, true) _items; | 26 List!(mstring, true) _items; |
27 int _selectedIndex = -1; | 27 int _selectedIndex = -1; |
28 | 28 |
29 override void whenKeyDown(KeyEventArgs e) { | 29 override void whenKeyDown(KeyEventArgs e) { |
30 if(e.key == Key.Down) { | 30 if(e.key == Key.Down) { |
31 if(selectedIndex + 1 < _items.count) | 31 if(selectedIndex + 1 < _items.count) |
66 /// Override this method in a subclass to handle the selectionChanged event. | 66 /// Override this method in a subclass to handle the selectionChanged event. |
67 protected void whenSelectionChanged(EventArgs e) { } | 67 protected void whenSelectionChanged(EventArgs e) { } |
68 /// This event occurs after the selection has changed. | 68 /// This event occurs after the selection has changed. |
69 Event!(whenSelectionChanged) selectionChanged; | 69 Event!(whenSelectionChanged) selectionChanged; |
70 | 70 |
71 void whenListItemsChanged(ListChangeType, string, string, uint) { | 71 void whenListItemsChanged(ListChangeType, mstring, mstring, uint) { |
72 super.layout(); | 72 super.layout(); |
73 repaint(); | 73 repaint(); |
74 } | 74 } |
75 | 75 |
76 /// | 76 /// |
77 this() { | 77 this() { |
78 selectionChanged.setUp(&whenSelectionChanged); | 78 selectionChanged.setUp(&whenSelectionChanged); |
79 _items = new List!(string, true)(&whenListItemsChanged); | 79 _items = new List!(mstring, true)(&whenListItemsChanged); |
80 | 80 |
81 super(); | 81 super(); |
82 _focusable = true; | 82 _focusable = true; |
83 // TODO: hack | 83 // TODO: hack |
84 backColor = WindowsTheme.getColor(5); | 84 backColor = WindowsTheme.getColor(5); |
85 } | 85 } |
86 /// | 86 /// |
87 List!(string, true) items() { | 87 List!(mstring, true) items() { |
88 return _items; | 88 return _items; |
89 } | 89 } |
90 /// | 90 /// |
91 int selectedIndex() { return _selectedIndex; } | 91 int selectedIndex() { return _selectedIndex; } |
92 /// ditto | 92 /// ditto |