Mercurial > projects > mde
comparison mde/gui/widget/textContent.d @ 99:5de5810e3516
Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
The widget supports moving the text entry-point using arrows and home/end, but there's no visual indicator or edit-point setting using the mouse.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Fri, 14 Nov 2008 12:44:32 +0000 |
parents | |
children | 0ea4a3e651ae |
comparison
equal
deleted
inserted
replaced
98:49e7cfed4b34 | 99:5de5810e3516 |
---|---|
1 /* LICENSE BLOCK | |
2 Part of mde: a Modular D game-oriented Engine | |
3 Copyright © 2007-2008 Diggory Hardy | |
4 | |
5 This program is free software: you can redistribute it and/or modify it under the terms | |
6 of the GNU General Public License as published by the Free Software Foundation, either | |
7 version 2 of the License, or (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | |
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
11 See the GNU General Public License for more details. | |
12 | |
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/>. */ | |
15 | |
16 /** Content widgets based on a text block. */ | |
17 module textContent; | |
18 | |
19 import mde.gui.widget.Widget; | |
20 import mde.gui.widget.TextWidget; | |
21 import mde.gui.exception; | |
22 import mde.gui.renderer.IRenderer; | |
23 | |
24 import mde.gui.content.Content; | |
25 | |
26 | |
27 class TextContentWidget : ATextWidget | |
28 { | |
29 this (IWidgetManager mgr, widgetID id, WidgetData data, IContent c) { | |
30 WDCheck(data, 1); | |
31 content = cast(TextContent) c; | |
32 if (!content) content = new TextContent (null, null); | |
33 //throw new ContentException (); | |
34 adapter = mgr.renderer.getAdapter (content.toString(0)); | |
35 super (mgr, id, data); | |
36 } | |
37 | |
38 /** On click, request keyboard input. */ | |
39 int clickEvent (wdabs, wdabs, ubyte, bool state) { | |
40 return 1; // get keyboard input via keyEvent | |
41 } | |
42 | |
43 void keyEvent (ushort s, char[] i) { | |
44 adapter.setText (content.keyStroke (s, i)); | |
45 adapter.getDimensions (mw, mh); // FIXME: only passively change size: next resize will see new minimal size | |
46 mgr.requestRedraw; | |
47 } | |
48 void keyFocusLost () { | |
49 content.endEdit; // update other users of content relying on callbacks | |
50 } | |
51 | |
52 protected: | |
53 TextContent content; | |
54 } |