annotate mde/gui/content/Content.d @ 98:49e7cfed4b34

All types of Option have been converted to use ValueContent classes, and their values can be displayed.
author Diggory Hardy <diggory.hardy@gmail.com>
date Wed, 12 Nov 2008 13:18:51 +0000
parents 2a364c7d82c9
children 5de5810e3516
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
1 /* LICENSE BLOCK
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
2 Part of mde: a Modular D game-oriented Engine
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
3 Copyright © 2007-2008 Diggory Hardy
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
4
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
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
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
6 of the GNU General Public License as published by the Free Software Foundation, either
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
7 version 2 of the License, or (at your option) any later version.
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
8
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
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;
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
11 See the GNU General Public License for more details.
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
12
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
13 You should have received a copy of the GNU General Public License
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
15
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
16 /** The content system − common types.
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
17 */
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
18 module mde.gui.content.Content;
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
19
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
20 //FIXME: efficient conversions? Need to dup result when formatting a string anyway?
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
21 import Int = tango.text.convert.Integer;
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
22 import Float = tango.text.convert.Float;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
23
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
24 debug {
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
25 import tango.util.log.Log : Log, Logger;
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
26 private Logger logger;
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
27 static this () {
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
28 logger = Log.getLogger ("mde.gui.content.Content");
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
29 }
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
30 }
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
31
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
32 /** IContent − interface for all Content classes.
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
33 *
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
34 * Services like copy/paste could work on universal content. However, they would need to run a
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
35 * conversion to the appropriate type (or try next-oldest item on clipboard?).
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
36 *
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
37 * Currently Content instances can only have their data set on creation.
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
38 * Each Content class should provide a method to get it's content, e.g. the method text().
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
39 *
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
40 * Extensions to content:
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
41 *
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
42 * These extensions require that a content can notify any dependants of changes.
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
43 *
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
44 * Use as a state switch (one option from an enumeration). E.g. a button/selection box could set a
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
45 * state, and a tabbed box could show a tab based on this. Or could represent an option.
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
46 */
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
47 //TODO - write a generic IContent displaying widget. Also a generic editable?
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
48 // Don't include dimension/drawing stuff because it's renderer specific and content should not be!
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
49 // NOTE: an interface or a class?
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
50 interface IContent
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
51 {
72
159775502bb4 The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
52 /+ NOTE: None of this is really used yet, but was (mostly) intended for clipboard copying.
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
53 /** Return a copy of self. */
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
54 IContent dup ();
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
55
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
56 /** Attempt to convert the content to a specific type (may simply return this if appropriate).
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
57 *
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
58 * Annoyingly we can't use cast because overloading by return type isn't supported. */
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
59 // FIXME: throw or return null on error or unsupported conversion?
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
60 ContentText toText ();
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
61 ContentInt toInt (); /// ditto
72
159775502bb4 The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
62 +/
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
63
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
64
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
65
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
66 /** Generically return strings.
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
67 *
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
68 * This serves two purposes: generically returning a string of/related to the content (i == 0),
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
69 * and returning associated descriptors. Functions should adhere to (or add to) this table.
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
70 *
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
71 * $(TABLE
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
72 * $(TR $(TH i) $(TH returns))
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
73 * $(TR $(TD 0) $(TD value))
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
74 * $(TR $(TD 1) $(TD Translated name or null))
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
75 * $(TR $(TD 2) $(TD Translated description or null))
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
76 * $(TR $(TD other) $(TD null))
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
77 * ) */
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
78 char[] toString (uint i);
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
79 }
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
80
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
81 /** Base class for content containing a simple value.
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
82 *
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
83 * All derived classes should support functions to set/get any ValueContent type, but return the
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
84 * default value of any type other than it's own. */
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
85 abstract class ValueContent : IContent
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
86 {
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
87 protected this () {}
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
88
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
89 void name (char[] n, char[] d = null) {
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
90 name_ = n;
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
91 desc_ = d;
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
92 }
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
93 protected:
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
94 char[] name_, desc_;// name and description, loaded by lookup.Translation
65
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 61
diff changeset
95 }
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 61
diff changeset
96
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
97 template VContentN(T) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
98 static if (is(T == bool)) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
99 const char[] VContentN = "BoolContent";
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
100 } else static if (is(T == int)) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
101 const char[] VContentN = "IntContent";
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
102 } else static if (is(T == double)) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
103 const char[] VContentN = "DoubleContent";
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
104 } else static if (is(T == char[])) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
105 const char[] VContentN = "TextContent";
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
106 } else
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
107 static assert (false, "No ValueContent of type "~T.stringof);
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
108 }
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
109
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
110 class BoolContent : ValueContent
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
111 {
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
112 /** Create a content with _symbol name symbol. */
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
113 this (char[] symbol, bool val = false) {
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
114 symb = symbol;
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
115 v = val;
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
116 }
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
117
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
118 /** Adds cb to the list of callback functions called when the value is changed. Returns this. */
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
119 BoolContent addChangeCb (void delegate (char[] symbol,bool value) cb) {
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
120 cngCb ~= cb;
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
121 return this;
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
122 }
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
123
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
124 /// Get the text.
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
125 char[] toString (uint i) {
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
126 return (i == 0) ? v ? "true" : "false"
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
127 : (i == 1) ? name_
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
128 : (i == 2) ? desc_
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
129 : null;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
130 }
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
131
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
132 void opAssign (bool val) {
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
133 v = val;
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
134 foreach (cb; cngCb)
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
135 cb(symb, val);
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
136 }
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
137 bool opCall () {
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
138 return v;
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
139 }
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
140 alias opCall opCast;
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
141
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
142 bool v; //FIXME: should be protected but Options needs to set without calling callbacks
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
143 protected:
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
144 char[] symb;
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
145 void delegate (char[],bool)[] cngCb; // change callbacks
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
146 }
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
147
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
148 /** Text content. */
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
149 class TextContent : ValueContent
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
150 {
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
151 this (char[] symbol, char[] val = null) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
152 symb = symbol;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
153 v = val;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
154 }
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
155
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
156 /** Adds cb to the list of callback functions called when the value is changed. Returns this. */
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
157 TextContent addChangeCb (void delegate (char[] symbol,char[] value) cb) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
158 cngCb ~= cb;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
159 return this;
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
160 }
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
161
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
162 /// Get the text.
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
163 char[] toString (uint i) {
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
164 return (i == 0) ? v
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
165 : (i == 1) ? name_
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
166 : (i == 2) ? desc_
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
167 : null;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
168 }
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
169
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
170 void opAssign (char[] val) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
171 v = val;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
172 foreach (cb; cngCb)
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
173 cb(symb, val);
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
174 }
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
175 char[] opCall () {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
176 return v;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
177 }
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
178 alias opCall opCast;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
179
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
180 char[] v;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
181 protected:
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
182 char[] symb;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
183 void delegate (char[],char[])[] cngCb;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
184 }
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
185
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
186 /** Integer content. */
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
187 class IntContent : ValueContent
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
188 {
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
189 /** Create a content with _symbol name symbol. */
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
190 this (char[] symbol, int val = 0) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
191 symb = symbol;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
192 v = val;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
193 }
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
194
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
195 /** Adds cb to the list of callback functions called when the value is changed. Returns this. */
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
196 IntContent addChangeCb (void delegate (char[] symbol,int value) cb) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
197 cngCb ~= cb;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
198 return this;
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
199 }
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
200
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
201 /// Get the text.
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
202 char[] toString (uint i) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
203 return (i == 0) ? Int.toString (v)
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
204 : (i == 1) ? name_
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
205 : (i == 2) ? desc_
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
206 : null;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
207 }
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
208
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
209 void opAssign (int val) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
210 v = val;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
211 foreach (cb; cngCb)
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
212 cb(symb, val);
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
213 }
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
214 int opCall () {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
215 return v;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
216 }
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
217 alias opCall opCast;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
218
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
219 int v;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
220 protected:
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
221 char[] symb;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
222 void delegate (char[],int)[] cngCb;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
223 }
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
224
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
225 /** Double content. */
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
226 class DoubleContent : ValueContent
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
227 {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
228 /** Create a content with _symbol name symbol. */
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
229 this (char[] symbol, double val = 0) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
230 symb = symbol;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
231 v = val;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
232 }
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
233
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
234 /** Adds cb to the list of callback functions called when the value is changed. Returns this. */
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
235 DoubleContent addChangeCb (void delegate (char[] symbol,double value) cb) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
236 cngCb ~= cb;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
237 return this;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
238 }
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
239
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
240 /// Get the text.
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
241 char[] toString (uint i) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
242 return (i == 0) ? Float.toString (v)
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
243 : (i == 1) ? name_
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
244 : (i == 2) ? desc_
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
245 : null;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
246 }
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
247
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
248 void opAssign (double val) {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
249 v = val;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
250 foreach (cb; cngCb)
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
251 cb(symb, val);
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
252 }
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
253 double opCall () {
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
254 return v;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
255 }
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
256 alias opCall opCast;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
257
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
258 double v;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
259 protected:
98
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
260 char[] symb;
49e7cfed4b34 All types of Option have been converted to use ValueContent classes, and their values can be displayed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
261 void delegate (char[],double)[] cngCb;
61
7cab2af4ba21 A little bit of progress on the content handling system (relevent code is likely to be revised).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
262 }