Mercurial > projects > mde
annotate mde/content/IContent.d @ 170:e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Added files missing from previous commits.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Mon, 29 Jun 2009 21:20:16 +0200 |
parents | 620d4ea30228 |
children |
rev | line source |
---|---|
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:
diff
changeset
|
1 /* LICENSE BLOCK |
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:
diff
changeset
|
2 Part of mde: a Modular D game-oriented Engine |
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:
diff
changeset
|
3 Copyright © 2007-2008 Diggory Hardy |
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:
diff
changeset
|
4 |
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:
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify it under |
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:
diff
changeset
|
6 the terms of the GNU General Public License as published by the Free Software |
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:
diff
changeset
|
7 Foundation, either version 2 of the License, or (at your option) any later version. |
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:
diff
changeset
|
8 |
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:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
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:
diff
changeset
|
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
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:
diff
changeset
|
11 See the GNU General Public License for more details. |
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:
diff
changeset
|
12 |
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:
diff
changeset
|
13 You should have received a copy of the GNU General Public License |
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:
diff
changeset
|
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
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:
diff
changeset
|
15 |
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:
diff
changeset
|
16 /****************************************************************************** |
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:
diff
changeset
|
17 * The content system − interfaces. |
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:
diff
changeset
|
18 * |
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:
diff
changeset
|
19 * The IContentList interface is defined in the Content module to allow it to |
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:
diff
changeset
|
20 * use a Content[] type (since arrays of classes cannot have their type cast |
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:
diff
changeset
|
21 * directly, at least not to/from an interface). |
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:
diff
changeset
|
22 *****************************************************************************/ |
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:
diff
changeset
|
23 module mde.content.IContent; |
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:
diff
changeset
|
24 |
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:
diff
changeset
|
25 /** IContent − interface for all Content classes. |
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:
diff
changeset
|
26 * |
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:
diff
changeset
|
27 * Very little code uses IContent (except for passing opaquely). */ |
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:
diff
changeset
|
28 interface IContent |
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:
diff
changeset
|
29 { |
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:
diff
changeset
|
30 /** Generically return strings. |
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:
diff
changeset
|
31 * |
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:
diff
changeset
|
32 * This serves two purposes: generically returning a string of/related to the content (i == 0), |
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:
diff
changeset
|
33 * and returning associated descriptors. Functions should adhere to (or add to) this table. |
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:
diff
changeset
|
34 * |
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:
diff
changeset
|
35 * $(TABLE |
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:
diff
changeset
|
36 * $(TR $(TH i) $(TH returns)) |
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:
diff
changeset
|
37 * $(TR $(TD 0) $(TD 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:
diff
changeset
|
38 * $(TR $(TD 1) $(TD Translated name or null)) |
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:
diff
changeset
|
39 * $(TR $(TD 2) $(TD Translated description or null)) |
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:
diff
changeset
|
40 * $(TR $(TD other) $(TD null)) |
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:
diff
changeset
|
41 * ) */ |
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:
diff
changeset
|
42 char[] toString (uint i); |
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
|
43 |
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
|
44 /** Generic way to set content value. |
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
|
45 * |
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
|
46 * If cont's type is compatible, the method should set its instance's |
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
|
47 * value to that of cont and return true, otherwise it should 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
|
48 */ |
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
|
49 bool set (IContent); |
167
620d4ea30228
Context menus: added a clipboard (functions accessible from main menu rather than context menu).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
50 |
620d4ea30228
Context menus: added a clipboard (functions accessible from main menu rather than context menu).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
51 /** Similarly, try to set the value directly from a string. |
620d4ea30228
Context menus: added a clipboard (functions accessible from main menu rather than context menu).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
52 * Doesn't do anything for content not storing a value. */ |
620d4ea30228
Context menus: added a clipboard (functions accessible from main menu rather than context menu).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
53 void opAssign (char[]); |
170
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
167
diff
changeset
|
54 |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
167
diff
changeset
|
55 IContent addCallback (void delegate (IContent) cb); |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
167
diff
changeset
|
56 IContent addCallback (void function (IContent) cb); |
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:
diff
changeset
|
57 } |
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:
diff
changeset
|
58 |
167
620d4ea30228
Context menus: added a clipboard (functions accessible from main menu rather than context menu).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
59 /** Interface for content which should be interacted with as a button. |
620d4ea30228
Context menus: added a clipboard (functions accessible from main menu rather than context menu).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
60 * |
620d4ea30228
Context menus: added a clipboard (functions accessible from main menu rather than context menu).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
61 * Actually not used to provide extra methods, but to tell widget-choosing |
620d4ea30228
Context menus: added a clipboard (functions accessible from main menu rather than context menu).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
62 * functions a button is desired. */ |
620d4ea30228
Context menus: added a clipboard (functions accessible from main menu rather than context menu).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
63 interface IEventContent : IContent { |
620d4ea30228
Context menus: added a clipboard (functions accessible from main menu rather than context menu).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
64 } |
170
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
167
diff
changeset
|
65 |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
167
diff
changeset
|
66 /// Interface for boolean-value content |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
167
diff
changeset
|
67 interface IBoolContent : IContent { |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
167
diff
changeset
|
68 /// Return the value |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
167
diff
changeset
|
69 bool opCall (); |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
167
diff
changeset
|
70 /// Directly set the value |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
167
diff
changeset
|
71 void opAssign (bool val); |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
167
diff
changeset
|
72 } |