Mercurial > projects > mde
annotate mde/gui/widget/TextWidget.d @ 156:36df0ffe34d2
Fix to reload translations.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 18 Apr 2009 21:51:03 +0200 |
parents | 783969f4665c |
children | 2476790223b8 |
rev | line source |
---|---|
59
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
1 /* LICENSE BLOCK |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
2 Part of mde: a Modular D game-oriented Engine |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
3 Copyright © 2007-2008 Diggory Hardy |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
4 |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify it under the terms |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
6 of the GNU General Public License as published by the Free Software Foundation, either |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
7 version 2 of the License, or (at your option) any later version. |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
8 |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
11 See the GNU General Public License for more details. |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
12 |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
13 You should have received a copy of the GNU General Public License |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
15 |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
16 /** Simple text widgets. */ |
59
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
17 module mde.gui.widget.TextWidget; |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
18 |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
19 import mde.gui.widget.AChildWidget; |
59
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
20 import mde.gui.exception; |
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
21 import mde.gui.renderer.IRenderer; |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
22 import mde.content.AStringContent; |
59
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
23 |
103
42e241e7be3e
ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
99
diff
changeset
|
24 import tango.util.log.Log : Log, Logger; |
42e241e7be3e
ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
99
diff
changeset
|
25 private Logger logger; |
42e241e7be3e
ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
99
diff
changeset
|
26 static this () { |
42e241e7be3e
ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
99
diff
changeset
|
27 logger = Log.getLogger ("mde.gui.widget.TextWidget"); |
94
9520cc0448e5
Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
93
diff
changeset
|
28 } |
9520cc0448e5
Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
93
diff
changeset
|
29 |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
30 /** Base text widget. */ |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
31 class ATextWidget : AChildWidget |
59
672b6b162a36
Added very basic (and currently useless) content support.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
32 { |
95
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
33 /** Set the adapter first: |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
34 * adapter = mgr.renderer.getAdapter (...); */ |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
119
diff
changeset
|
35 protected this (IWidgetManager mgr, IParentWidget parent, widgetID id) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
119
diff
changeset
|
36 super (mgr, parent, id); |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
65
diff
changeset
|
37 } |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
65
diff
changeset
|
38 |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
39 /** Recalculates dims if the renderer changed. */ |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
40 override bool setup (uint,uint flags) { |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
41 if (flags & 1) { |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
42 adapter.getDimensions (mw, mh); |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
43 if (mw != w || mh != h) { |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
44 w = mw; |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
45 h = mh; |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
46 return true; |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
47 } |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
48 } |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
49 return false; |
110
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
50 } |
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
51 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
52 override void draw () { |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
65
diff
changeset
|
53 super.draw(); |
90
b525ff28774b
Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
77
diff
changeset
|
54 adapter.draw (x,y); |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
65
diff
changeset
|
55 } |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
65
diff
changeset
|
56 |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
65
diff
changeset
|
57 protected: |
93
08a4ae11454b
Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
91
diff
changeset
|
58 IRenderer.TextAdapter adapter; |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
65
diff
changeset
|
59 } |
91
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
60 |
95
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
61 |
145
1048b5c7cab1
Allow EventContent creation for translatable labels.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
62 /** Basic text widget. |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
63 * |
145
1048b5c7cab1
Allow EventContent creation for translatable labels.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
64 * Displays data.strings[0] directly (no translation). Using |
1048b5c7cab1
Allow EventContent creation for translatable labels.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
65 * DisplayContentWidget with a content is recommended to allow translation. |
1048b5c7cab1
Allow EventContent creation for translatable labels.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
66 * (Use EventContent if the content is not used for anything else; EventContent |
1048b5c7cab1
Allow EventContent creation for translatable labels.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
67 * is the simplest Content available.) */ |
95
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
68 class TextLabelWidget : ATextWidget |
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
69 { |
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
70 /** Constructor for a widget containing [fixed] content. |
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
71 * |
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
72 * Widget uses the initialisation data: |
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
73 * [widgetID, contentID, colour] |
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
74 * where contentID is an ID for the string ID of the contained content |
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
75 * and colour is an 8-bit-per-channel RGB colour of the form 0xRRGGBB. */ |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
119
diff
changeset
|
76 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data) { |
95
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
77 WDCheck (data, 2, 1); |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
119
diff
changeset
|
78 super (mgr, parent, id); |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
79 adapter = mgr.renderer.getAdapter (data.ints[1]); |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
80 adapter.text = data.strings[0]; |
95
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
81 } |
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
82 } |
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
94
diff
changeset
|
83 |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
84 /** Displays text from a content. |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
85 * |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
86 * Displays the value, name, description or possibly another field of a |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
87 * content, depending on data.ints[2]. */ |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
88 class DisplayContentWidget : ATextWidget |
91
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
89 { |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
119
diff
changeset
|
90 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent c) { |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
91 content_ = cast(Content) c; |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
92 WDCMinCheck (data, 1, 0, content_); |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
119
diff
changeset
|
93 super (mgr, parent, id); |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
94 |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
95 if (data.ints.length >= 3) |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
96 cIndex = data.ints[2]; // otherwise display '0', the value |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
97 if (cIndex == 0) |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
98 content_.addCallback (&updateVal); |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
99 |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
100 adapter = mgr.renderer.getAdapter (); |
91
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
101 } |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
102 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
103 override bool setup (uint n, uint flags) { |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
104 if (!(flags & 3)) return false; // string or renderer (and possibly font) changed |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
105 adapter.text = content_.toString(cIndex); |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
106 return super.setup (n, 3); // force redimensioning |
110
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
107 } |
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
108 |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
109 override IContent content () { |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
110 return content_; |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
111 } |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
112 |
91
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
113 protected: |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
114 void updateVal (Content) { // callback |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
115 adapter.text = content_.toString(cIndex); |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
116 wdim omw = mw, omh = mh; |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
117 adapter.getDimensions (mw, mh); |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
118 if (omw != mw) |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
119 parent.minWChange (this, mw); |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
120 if (omh != mh) |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
121 parent.minHChange (this, mh); |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
122 } |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
123 Content content_; |
156
36df0ffe34d2
Fix to reload translations.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
124 int cIndex = 0; |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
125 } |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
126 |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
127 /// Text-box for editing a content's value. Generic − any AStringContent. |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
128 class AStringContentWidget : ATextWidget |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
129 { |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
119
diff
changeset
|
130 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData, IContent c) { |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
131 content_ = cast(AStringContent) c; |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
132 if (content_ is null) throw new ContentException (this); |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
119
diff
changeset
|
133 super (mgr, parent, id); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
119
diff
changeset
|
134 |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
135 content_.addCallback (&update); |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
136 adapter = mgr.renderer.getAdapter (); |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
137 adapter.text = content_.toString(0); |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
138 } |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
139 |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
140 override IContent content () { |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
141 return content_; |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
142 } |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
143 |
130
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
144 override bool isWSizable () { |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
145 return true; |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
146 } |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
147 override bool isHSizable () { |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
148 return false; |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
149 } |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
150 |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
151 /** On click, request keyboard input. */ |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
152 override int clickEvent (wdabs cx, wdabs, ubyte, bool) { |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
153 //adapter.index = content_.editIndex; |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
154 content_.editIndex = adapter.setIndex (cx - x); |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
155 mgr.requestRedraw; |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
156 return 1; // get keyboard input via keyEvent |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
157 } |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
158 |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
159 override void keyEvent (ushort s, char[] i) { |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
160 adapter.text = content_.keyStroke (s, i); |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
161 adapter.index = content_.editIndex; |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
162 wdim omw = mw, omh = mh; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
163 adapter.getDimensions (mw, mh); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
164 if (omw != mw) |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
165 parent.minWChange (this, mw); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
166 if (omh != mh) |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
167 parent.minHChange (this, mh); |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
168 mgr.requestRedraw; |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
169 } |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
170 override void keyFocusLost () { |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
171 adapter.text = content_.endEdit; // update other users of content_ relying on callbacks |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
172 adapter.index; |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
173 mgr.requestRedraw; |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
174 } |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
175 |
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
176 protected: |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
177 void update (Content) { // callback |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
178 adapter.text = content_.toString(0); |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
179 wdim omw = mw, omh = mh; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
180 adapter.getDimensions (mw, mh); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
181 if (omw != mw) |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
182 parent.minWChange (this, mw); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
183 if (omh != mh) |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
184 parent.minHChange (this, mh); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
185 } |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
145
diff
changeset
|
186 AStringContent content_; |
119
d28aea50c6da
Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
187 } |