Mercurial > projects > mde
comparison mde/gui/widget/miscContent.d @ 131:9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Moved Widget.AWidget to AChildWidget.AChildWidget and Widget.AParentWidget to AParentWidget.AParentWidget.
Removed ASingleParentWidget to improve code sharing.
AChildWidget doesn't implement IParentWidget like AWidget did.
New IPopupParentWidget extending IParentWidget for the WM and some widgets to handle popups.
Cut old popup management code.
New underMouse() function replacing highlight(); called on all widgets.
Separate menu-popup and button widgets aren't needed for menus now.
Functions returning content widgets have been moved to their own module.
Cleaned up jobs.txt.
Switched to 80 line length for Ddoc.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Wed, 21 Jan 2009 13:01:40 +0000 |
parents | c5c38eaadb64 |
children | 9f035cd139c6 |
comparison
equal
deleted
inserted
replaced
130:c5c38eaadb64 | 131:9cff74f68b84 |
---|---|
11 See the GNU General Public License for more details. | 11 See the GNU General Public License for more details. |
12 | 12 |
13 You should have received a copy of the GNU General Public License | 13 You should have received a copy of the GNU General Public License |
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
15 | 15 |
16 /************************************************************************************************* | 16 /****************************************************************************** |
17 * A function to return content widgets and some miscellaneous content display/editing widgets. | 17 * Widgets using content not organised into other modules. |
18 *************************************************************************************************/ | 18 *****************************************************************************/ |
19 module mde.gui.widget.miscContent; | 19 module mde.gui.widget.miscContent; |
20 | 20 |
21 import mde.gui.widget.Widget; | 21 import mde.gui.widget.AParentWidget; |
22 import mde.gui.exception; | 22 import mde.gui.exception; |
23 import mde.gui.widget.TextWidget; | |
24 import mde.gui.widget.layout; | |
25 import mde.gui.widget.PopupMenu; | |
26 | 23 |
27 import mde.gui.renderer.IRenderer; | |
28 import mde.content.AStringContent; | 24 import mde.content.AStringContent; |
29 import mde.content.miscContent; | 25 import mde.content.miscContent; |
30 import Items = mde.content.Items; | |
31 | 26 |
32 debug { | 27 debug { |
33 import tango.util.log.Log : Log, Logger; | 28 import tango.util.log.Log : Log, Logger; |
34 private Logger logger; | 29 private Logger logger; |
35 static this () { | 30 static this () { |
36 logger = Log.getLogger ("mde.gui.widget.miscContent"); | 31 logger = Log.getLogger ("mde.gui.widget.miscContent"); |
37 } | 32 } |
38 } | |
39 | |
40 /************************************************************************************************* | |
41 * A function which uses Items.get (data.strings[0]) to get a content and creates a widget from | |
42 * data.ints[1]. The first item in each ints and strings is removed before passing data to the new | |
43 * widget. | |
44 * | |
45 * The function only takes an IContent parameter to satisfy createWidget; it's value is ignored. | |
46 ************************************************************************************************/ | |
47 IChildWidget addContent (IWidgetManager mgr, IParentWidget parent, widgetID, WidgetData data, IContent) { | |
48 if (data.strings.length != 2) throw new WidgetDataException; | |
49 return mgr.makeWidget (parent, data.strings[1], Items.get (data.strings[0])); | |
50 } | |
51 | |
52 /************************************************************************************************* | |
53 * A function which returns the most appropriate content editing widget. | |
54 * | |
55 * Widgets which can be returned: BoolContentWidget (toggle button), ValueContentWidget (generic | |
56 * text-box editor), DisplayContentWidget (generic text label). | |
57 *************************************************************************************************/ | |
58 IChildWidget editContent (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent c) { | |
59 // Note: SAFE_RECURSION enabled | |
60 if (c is null) throw new ContentException; | |
61 if (cast(AStringContent) c) { | |
62 if (cast(EnumContent) c) // can be PopupMenuWidget or ContentListWidget | |
63 return new ContentListWidget(mgr,parent,id,data,c); | |
64 if (cast(BoolContent) c) | |
65 return new BoolContentWidget(mgr,parent,id,data,c); | |
66 return new AStringContentWidget(mgr,parent,id,data,c); | |
67 } | |
68 if (cast(IContentList) c) | |
69 return new ContentListWidget(mgr,parent,id,data,c); | |
70 if (cast(EventContent) c) | |
71 return new ButtonContentWidget(mgr,parent,id,data,c); | |
72 // generic uneditable option | |
73 return new DisplayContentWidget(mgr,parent,id,data,c); | |
74 } | 33 } |
75 | 34 |
76 /// Editable boolean widget | 35 /// Editable boolean widget |
77 class BoolContentWidget : AButtonWidget | 36 class BoolContentWidget : AButtonWidget |
78 { | 37 { |