annotate mde/content/AStringContent.d @ 165:bb2f1a76346d

Fixed a few bugs; most notably changing the translation reloads the text on PopupMenuWidgets now.
author Diggory Hardy <diggory.hardy@gmail.com>
date Sun, 07 Jun 2009 16:20:16 +0200
parents c13bded1bed3
children 620d4ea30228
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
1 /* LICENSE BLOCK
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
2 Part of mde: a Modular D game-oriented Engine
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
3 Copyright © 2007-2008 Diggory Hardy
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
4
08651e8a8c51 Quit button, big changes to content system.
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
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
6 of the GNU General Public License as published by the Free Software Foundation, either
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
7 version 2 of the License, or (at your option) any later version.
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
8
08651e8a8c51 Quit button, big changes to content system.
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;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
11 See the GNU General Public License for more details.
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
12
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
13 You should have received a copy of the GNU General Public License
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
15
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
16 /** The content system − string-based editable content.
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
17 */
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
18 module mde.content.AStringContent;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
19 public import mde.content.Content;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
20
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
21 import Ascii = tango.text.Ascii;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
22 import Util = tango.text.Util;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
23 //FIXME: efficient conversions? Need to dup result when formatting a string anyway?
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
24 import Int = tango.text.convert.Integer;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
25 import Float = tango.text.convert.Float;
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
26 import Math = tango.math.Math;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
27 import derelict.sdl.keysym;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
28
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
29 import tango.util.log.Log : Log, Logger;
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
30 private Logger logger;
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
31 static this () {
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
32 logger = Log.getLogger ("mde.content.AStringContent");
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
33 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
34
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
35 private {
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
36 // Returns the length of memory to allocate, when len is the min required.
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
37 // Returns at least 66, since formatting from int/float requires this.
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
38 size_t allocLength (size_t len) {
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
39 return len < 33 ? 66 : len * 2;
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
40 }
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
41 }
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
42
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
43 /** Union of all content types here - for dynamic cast checking against several
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
44 * types. */
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
45 union UnionContent {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
46 AStringContent asc;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
47 BoolContent bc;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
48 StringContent sc;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
49 IntContent ic;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
50 DoubleContent dc;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
51 EnumContent ec;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
52 }
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
53
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
54 /** Base class for content containing a simple value editable as text.
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
55 *
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
56 * Derived classes should implement endEdit to convert sv and assign its value
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
57 * to self, then call endEvent.
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
58 *
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
59 * On assignation by this or opAssign the value should be converted to a string
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
60 * and assigned to sv, and pos should be clamped to [0,sv.length] (i.e. enforce
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
61 * pos <= sv.length). */
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
62 abstract class AStringContent : Content
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
63 {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
64 protected this (char[] symbol) {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
65 super (symbol);
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
66 svBuf.length = allocLength (0);
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
67 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
68
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
69 /// Get the text.
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
70 override char[] toString (uint i) {
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
71 return i == 0 ? sv
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
72 : i == 1 ? name_
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
73 : i == 2 ? desc_
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
74 : null;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
75 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
76
162
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 137
diff changeset
77 /** Set the content via conversion to/from string. */
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
78 override bool set (IContent c) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
79 if (c !is null) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
80 sv = c.toString (0).dup;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
81 return endEdit;
162
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 137
diff changeset
82 }
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 137
diff changeset
83 return false;
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 137
diff changeset
84 }
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 137
diff changeset
85
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
86 /** Acts on a keystroke to edit the value as a string.
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
87 *
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
88 * After this has been used to edit the string, endEdit should be called
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
89 * to convert back to the native value type.
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
90 *
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
91 * Supports one-line editing: left/right, home/end, backspace/delete. */
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
92 char[] keyStroke (ushort sym, char[] i) {
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
93 // This routine relies on the folowing: svBuf[0..sv.length] == sv
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
94 if (sv.ptr !is svBuf.ptr) {
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
95 // sv may be within svBuf but not starting at its beginning
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
96 //NOTE: to further optimise, try to avoid a realloc on the heap
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
97 svBuf = new char[allocLength (sv.length)];
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
98 svBuf[0..sv.length] = sv;
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
99 }
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
100 //NOTE (optimise): dup is used several times for temporary storage
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
101 //perhaps could be optimised by a dup func using thread-local buffer?
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
102 debug assert (i.length, "StringContent.keyStroke: no value (??)"); // impossible?
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
103 char k = *i;
123
d3b2cefd46c9 minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 119
diff changeset
104 if (k >= 0x20) {
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
105 if (k == 0x7f) { // delete
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
106 size_t p = pos;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
107 if (p < sv.length) ++p;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
108 while (p < sv.length && (sv[p] & 0x80) && !(sv[p] & 0x40))
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
109 ++p;
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
110 size_t l = sv.length - (p-pos);
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
111 sv[pos..l] = sv[p..$].dup;
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
112 sv = sv[0..l];
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
113 } else { // insert character
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
114 char[] tail = sv[pos..$];
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
115 size_t l = sv.length + i.length;
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
116 if (svBuf.length < l)
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
117 svBuf.length = allocLength (l);
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
118 size_t npos = pos+i.length;
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
119 if (tail) svBuf[npos..l] = tail.dup;
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
120 svBuf[pos..npos] = i;
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
121 sv = svBuf[0..l];
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
122 pos = npos;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
123 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
124 } else { // use sym; many keys output 0
123
d3b2cefd46c9 minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 119
diff changeset
125 if (sym >= SDLK_RSHIFT && (sym <= SDLK_COMPOSE || sym == SDLK_MENU)) {
d3b2cefd46c9 minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 119
diff changeset
126 } // all modifier keys and contect menu key; should be ignored
d3b2cefd46c9 minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 119
diff changeset
127 else if (sym == SDLK_BACKSPACE) { // backspace; k == 0x8
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
128 char[] tail = sv[pos..$];
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
129 size_t l = pos;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
130 if (pos) --pos;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
131 while (pos && (sv[pos] & 0x80) && !(sv[pos] & 0x40))
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
132 --pos;
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
133 l = sv.length - (l - pos);
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
134 sv[pos..l] = tail.dup;
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
135 sv = sv[0..l];
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
136 } else if (sym == SDLK_LEFT) {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
137 if (pos) --pos;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
138 while (pos && (sv[pos] & 0x80) && !(sv[pos] & 0x40))
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
139 --pos;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
140 } else if (sym == SDLK_RIGHT) {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
141 if (pos < sv.length) ++pos;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
142 while (pos < sv.length && (sv[pos] & 0x80) && !(sv[pos] & 0x40))
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
143 ++pos;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
144 } else if (sym == SDLK_HOME || sym == SDLK_UP) {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
145 pos = 0;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
146 } else if (sym == SDLK_END || sym == SDLK_DOWN) {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
147 pos = sv.length;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
148 } else
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
149 debug logger.trace ("Unhandled symbol: {}", sym);
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
150 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
151 return sv;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
152 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
153
119
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
154 /** Get the character the edit cursor is in front of.
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
155 *
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
156 * NOTE: unused. */
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
157 size_t editIndex () {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
158 size_t i = 0;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
159 for (size_t p = 0; p < pos; ++p)
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
160 if (!(sv[p] & 0x80) || sv[p] & 0x40)
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
161 ++i;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
162 return i;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
163 }
119
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
164 /** Set the edit position in front of i'th character.
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
165 *
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
166 * Assumes at least i characters are present; if not this will work but not be optimal. */
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
167 void editIndex (size_t i) {
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
168 pos = 0;
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
169 for (; i > 0; --i) { // NOTE: could be slightly optimised
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
170 if (pos < sv.length) ++pos;
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
171 while (pos < sv.length && (sv[pos] & 0x80) && !(sv[pos] & 0x40))
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
172 ++pos;
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
173 }
d28aea50c6da Basic edit cursor placement using the mouse.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
174 }
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
175
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
176 /** Call after editing a string.
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
177 *
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
178 * Returns: true if string successfully converted to value.
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
179 *
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
180 * Should never throw; should reset sv at least when returning false. */
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
181 bool endEdit ();
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
182
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
183 protected:
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
184 /* String version of value (for toString(0) and editing).
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
185 * WARNING: This must point to mutable memory (for endEdit), and
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
186 * when keyStroke can be called we must have svBuf[0..sv.length] == sv. */
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
187 char[] sv;
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
188 char[] svBuf; // buffer to reduce reallocs
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
189 size_t pos; // editing position; used by keyStroke
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
190 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
191
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
192 class BoolContent : AStringContent
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
193 {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
194 /** Create a content with _symbol name symbol. */
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
195 this (char[] symbol) {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
196 auto valp = symbol in changed.boolData;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
197 if (valp)
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
198 v = *valp;
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
199 sv = v ? "true" : "false";
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
200 super (symbol);
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
201 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
202
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
203 // Assign without adding change to save changeset
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
204 void assignNoCng (bool val) {
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
205 v = val;
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
206 sv = v ? "true" : "false";
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
207 if (pos > sv.length) pos = sv.length;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
208 endEvent;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
209 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
210 void opAssign (bool val) {
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
211 assignNoCng (val);
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
212 endCng;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
213 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
214 bool opCall () {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
215 return v;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
216 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
217 alias opCall opCast;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
218
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
219 override bool endEdit () {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
220 try {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
221 sv = Util.trim (Ascii.toLower (sv)); // NOTE: sv must be in mutable memory
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
222 if (sv == "false")
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
223 v = 0;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
224 else if (sv == "true")
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
225 v = 1;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
226 else // throws if can't convert to int:
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
227 v = (Int.toLong (sv) != 0);
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
228 } catch (Exception e) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
229 logger.error (e.msg);
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
230 sv = v ? "true" : "false";
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
231 return false;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
232 }
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
233 sv = v ? "true" : "false";
124
a2ef6b549101 Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 123
diff changeset
234 endEvent;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
235 endCng;
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
236 return true;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
237 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
238
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
239 // Add change to changeset
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
240 void endCng () {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
241 changed.boolData[symbol] = v;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
242 }
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
243
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
244 protected:
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
245 bool v;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
246 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
247
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
248 /** Text content. */
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
249 class StringContent : AStringContent
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
250 {
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
251 this (char[] symbol) {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
252 auto valp = symbol in changed.charAData;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
253 if (valp)
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
254 v = *valp;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
255 super (symbol);
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
256 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
257
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
258 void assignNoCng (char[] val) {
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
259 v = val;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
260 if (pos > sv.length) pos = sv.length;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
261 endEvent;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
262 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
263 void opAssign (char[] val) {
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
264 assignNoCng (val);
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
265 endCng;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
266 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
267 char[] opCall () {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
268 return v;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
269 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
270 alias opCall opCast;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
271
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
272 override bool endEdit () {
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
273 endEvent;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
274 endCng;
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
275 return true;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
276 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
277
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
278 void endCng () {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
279 changed.charAData[symbol] = v;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
280 }
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
281
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
282 protected:
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
283 alias sv v; // don't need separate v and sv in this case
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
284 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
285
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
286 /** Integer content. */
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
287 class IntContent : AStringContent
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
288 {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
289 /** Create a content with _symbol name symbol. */
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
290 this (char[] symbol) {
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
291 super (symbol);
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
292 auto valp = symbol in changed.intData;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
293 if (valp)
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
294 v = *valp;
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
295 sv = Int.format (svBuf, v);
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
296 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
297
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
298 override bool set (IContent c) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
299 UnionContent uc;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
300 uc.bc = cast (BoolContent) c;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
301 if (uc.bc !is null) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
302 this = uc.bc();
162
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 137
diff changeset
303 return true;
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 137
diff changeset
304 }
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
305 uc.ic = cast (IntContent) c;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
306 if (uc.ic !is null) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
307 this = uc.ic();
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
308 return true;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
309 }
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
310 uc.dc = cast (DoubleContent) c;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
311 if (uc.dc !is null) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
312 this = Math.rndint (uc.dc()); // round to nearest
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
313 return true;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
314 }
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
315 return super.set (c);
162
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 137
diff changeset
316 }
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 137
diff changeset
317
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
318 void assignNoCng (int val) {
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
319 v = val;
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
320 sv = Int.format (svBuf, v);
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
321 if (pos > sv.length) pos = sv.length;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
322 endEvent;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
323 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
324 void opAssign (int val) {
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
325 assignNoCng (val);
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
326 endCng;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
327 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
328 int opCall () {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
329 return v;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
330 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
331 alias opCall opCast;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
332
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
333 override bool endEdit () {
123
d3b2cefd46c9 minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 119
diff changeset
334 try {
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
335 // use toFloat to allow decimal points and exponents
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
336 v = Math.rndint (Float.toFloat (sv));
123
d3b2cefd46c9 minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 119
diff changeset
337 } catch (Exception e) {
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
338 logger.error (e.msg);
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
339 sv = Int.format (svBuf, v);
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
340 return false;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
341 }
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
342 sv = Int.format (svBuf, v);
124
a2ef6b549101 Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 123
diff changeset
343 endEvent;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
344 endCng;
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
345 return true;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
346 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
347
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
348 void endCng () {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
349 changed.intData[symbol] = v;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
350 }
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
351
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
352 protected:
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
353 int v;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
354 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
355
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
356 /** Floating-point content. */
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
357 class DoubleContent : AStringContent
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
358 {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
359 /** Create a content with _symbol name symbol. */
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
360 this (char[] symbol) {
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
361 super (symbol);
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
362 auto valp = symbol in changed.doubleData;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
363 if (valp)
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
364 v = *valp;
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
365 sv = Float.format (svBuf, v, 8, 4);
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
366 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
367
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
368 override bool set (IContent c) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
369 UnionContent uc;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
370 uc.bc = cast (BoolContent) c;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
371 if (uc.bc !is null) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
372 this = uc.bc();
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
373 return true;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
374 }
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
375 uc.ic = cast (IntContent) c;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
376 if (uc.ic !is null) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
377 this = uc.ic();
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
378 return true;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
379 }
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
380 uc.dc = cast (DoubleContent) c;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
381 if (uc.dc !is null) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
382 this = uc.dc();
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
383 return true;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
384 }
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
385 return super.set (c);
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
386 }
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
387
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
388 void assignNoCng (double val) {
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
389 v = val;
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
390 sv = Float.format (svBuf, v, 8, 4);
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
391 if (pos > sv.length) pos = sv.length;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
392 endEvent;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
393 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
394 void opAssign (double val) {
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
395 assignNoCng (val);
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
396 endCng;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
397 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
398 double opCall () {
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
399 return v;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
400 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
401 alias opCall opCast;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
402
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
403 override bool endEdit () {
123
d3b2cefd46c9 minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 119
diff changeset
404 try {
d3b2cefd46c9 minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 119
diff changeset
405 v = Float.toFloat (sv);
d3b2cefd46c9 minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 119
diff changeset
406 } catch (Exception e) {
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
407 logger.error (e.msg);
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
408 sv = Float.format (svBuf, v, 8, 4);
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
409 return false;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
410 }
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
411 sv = Float.format (svBuf, v, 8, 4);
124
a2ef6b549101 Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 123
diff changeset
412 endEvent;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
413 endCng;
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
414 return true;
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
415 }
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
416
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
417 void endCng () {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
418 changed.doubleData[symbol] = v;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
419 }
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
420
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
421 protected:
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
422 double v;
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
423 }
112
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
424
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
425 /** A content representing an enumeration. */
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
426 class EnumContent : AStringContent, IContentList
112
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
427 {
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
428 /** CTOR.
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
429 *
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
430 * Params:
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
431 * enumSymbols = Symbol names for each
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
432 * val = which value is active; must be in [0,length-1]
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
433 */
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
434 this (char[] symbol, char[][] enumSymbols) {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
435 super (symbol);
128
41582439a42b Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 126
diff changeset
436 this.enumSymbols = enumSymbols;
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
437 enums.length = enumSymbols.length;
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
438 char[] symPeriod = symbol~'.';
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
439 foreach (i, ref e; enums) {
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
440 e = new EnumValueContent (this, i, symPeriod~enumSymbols[i]);
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
441 }
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
442 enums[v].assignFromParent (true);
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
443 sv = enums[v].name_;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
444 // Re-set the value if a saved value is found:
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
445 auto valp = symbol in changed.enumValData;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
446 if (valp)
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
447 assignNoCng = *valp;
128
41582439a42b Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 126
diff changeset
448 }
41582439a42b Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 126
diff changeset
449
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
450 void opAssign (size_t val) {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
451 assignNoCng (val);
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
452 endCng;
128
41582439a42b Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 126
diff changeset
453 }
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
454 // Assign by enum symbol name (for ContentLoader)
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
455 void assignNoCng (char[] enumSym) {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
456 foreach (i,e; enumSymbols) {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
457 if (e == enumSym) {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
458 assignNoCng (i);
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
459 return;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
460 }
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
461 }
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
462 logger.error ("EnumContent {} assigned invalid enumeration: {}; valid: {}", symbol, enumSym, enumSymbols);
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
463 }
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
464 size_t opCall () {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
465 //debug logger.trace ("EnumContent {} returning value: {} ({})",symbol, enumSymbols[v], v);
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
466 return v;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
467 }
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
468 alias opCall opCast;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
469 void assignNoCng (size_t val) {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
470 if (val >= enums.length) {
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
471 logger.error ("EnumContent "~name_~" assigned invalid value; keeping value: "~sv);
112
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
472 return;
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
473 }
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
474 enums[v] .assignFromParent (false);
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
475 enums[val].assignFromParent (true);
112
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
476 v = val;
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
477 sv = enums[v].name_;
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
478 if (pos > sv.length) pos = sv.length;
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
479 endEvent;
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
480 }
112
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
481
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
482 override bool endEdit () {
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
483 foreach (i,e; enums)
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
484 if (sv == e.name_) {
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
485 assignNoCng (i);
112
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
486 goto break1;
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
487 }
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
488
164
c13bded1bed3 Some (somewhat pointless) memory optimisations for AStringContent.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 163
diff changeset
489 sv = enums[v].name_; // sv was edited; revert
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
490 logger.error ("EnumContent "~name_~" assigned invalid value; keeping value: "~sv);
112
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
491 if (pos > sv.length) pos = sv.length;
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
492 return false;
112
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
493
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
494 break1:
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
495 endCng;
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
496 return true;
112
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
497 }
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
498
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
499 void endCng () {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
500 changed.enumValData[symbol] = enumSymbols[v];
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
501 }
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
502
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
503 override Content[] list () {
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
504 return enums;
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
505 }
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
506
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
507 // Interface functions that don't make sense for an emuneration:
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
508 override void append (Content) {}
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
509
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
510 protected:
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
511 // Called by child; change this if true, assert current value if false
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
512 void childAssign (size_t val) {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
513 debug assert (val < enums.length, "cA out of bounds");
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
514 if (enums[val].v)
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
515 this = val;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
516 else
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
517 enums[val].assignFromParent (v == val);
128
41582439a42b Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 126
diff changeset
518 }
41582439a42b Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 126
diff changeset
519
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
520 size_t v; // value (i.e. enums[v] is value)
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
521 EnumValueContent[] enums;
128
41582439a42b Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 126
diff changeset
522 char[][] enumSymbols; // saved for getStructOf
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
523
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
524 /** Special version of BoolContent for each enumeration to update the
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
525 * parent Enum.
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
526 *
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
527 * Also should not save its value, since the parent stores the value. */
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
528 private class EnumValueContent : BoolContent {
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
529 /** New enumeration of parent with index num. */
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
530 this (EnumContent parent, size_t num, char[] symbol) {
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
531 this.parent = parent;
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
532 i = num;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
533 super (symbol);
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
534 }
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
535
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
536 override void assignNoCng (bool val) {
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
537 v = val;
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
538 parent.childAssign (i);
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
539 }
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
540 override void opAssign (bool val) {
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
541 assignNoCng (val);
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
542 }
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
543 void assignFromParent (bool val) { // don't call back to parent
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
544 super.assignNoCng (val);
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
545 }
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
546
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
547 override bool endEdit () {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
548 if (super.endEdit) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
549 parent.childAssign (i);
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
550 return true; // value accepted by BoolContent, not necessarily by EnumContent
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
551 }
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
552 return false;
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
553 }
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
554
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
555 protected:
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
556 EnumContent parent;
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 124
diff changeset
557 size_t i;
115
1b1e2297e2fc Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 112
diff changeset
558 }
112
fe061009029d EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
559 }
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
560
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
561 debug (mdeUnitTest) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
562 unittest {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
563 bool throws (void delegate() dg) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
564 bool r = false;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
565 try {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
566 dg();
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
567 } catch (Exception e) {
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
568 r = true;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
569 }
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
570 return r;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
571 }
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
572
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
573 StringContent sc = new StringContent ("unittest.sc");
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
574 IntContent ic = new IntContent ("unittest.ic");
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
575 BoolContent bc = new BoolContent ("unittest.bc");
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
576 DoubleContent dc = new DoubleContent ("unittest.dc");
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
577
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
578 logger.info ("You should see some \"invalid literal\" errors:");
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
579 sc = "16";
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
580 ic.set = sc;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
581 assert (ic() == 16);
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
582 sc = "five"; // fails
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
583 ic.set = sc;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
584 assert (ic.toString(0) == "16");
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
585
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
586 bc.set = ic;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
587 assert (bc());
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
588 sc = "fALse";
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
589 bc.set = sc;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
590 assert (!bc());
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
591
165
bb2f1a76346d Fixed a few bugs; most notably changing the translation reloads the text on PopupMenuWidgets now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 164
diff changeset
592 sc = "2.5";
bb2f1a76346d Fixed a few bugs; most notably changing the translation reloads the text on PopupMenuWidgets now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 164
diff changeset
593 ic.set = sc; // parses as float and rounds
bb2f1a76346d Fixed a few bugs; most notably changing the translation reloads the text on PopupMenuWidgets now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 164
diff changeset
594 assert (ic() == 2); // rounds to even
163
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
595 sc = "31.5";
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
596 dc.set = sc;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
597 ic.set = dc; // rounds to even
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
598 assert (ic() == 32);
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
599 dc = -1.5;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
600 ic.set = dc; // rounds to even
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
601 assert (ic() == -2);
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
602
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
603 bc.set = dc; // fails: not included conversion
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
604 assert (!bc());
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
605 bc.set = ic;
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
606 assert (bc());
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
607
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
608 logger.info ("Unittest complete.");
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
609 }
24d77c52243f Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
610 }