Mercurial > projects > mde
comparison mde/gui/content/Content.d @ 72:159775502bb4
The first dynamically generated widget lists, based on Options, are here!
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 05 Jul 2008 18:27:46 +0100 |
parents | 891211f034f2 |
children | b525ff28774b |
comparison
equal
deleted
inserted
replaced
71:77c7d3235114 | 72:159775502bb4 |
---|---|
27 * Currently Content instances can only have their data set on creation. | 27 * Currently Content instances can only have their data set on creation. |
28 * Each Content class should provide a method to get it's content, e.g. the method text(). | 28 * Each Content class should provide a method to get it's content, e.g. the method text(). |
29 */ | 29 */ |
30 // Don't include dimension/drawing stuff because it's renderer specific and content should not be! | 30 // Don't include dimension/drawing stuff because it's renderer specific and content should not be! |
31 // NOTE: an interface or a class? | 31 // NOTE: an interface or a class? |
32 alias IContent Content; // use either name until it's settled... | |
33 /** ditto */ | |
34 interface IContent | 32 interface IContent |
35 { | 33 { |
34 /+ NOTE: None of this is really used yet, but was (mostly) intended for clipboard copying. | |
36 /** Return a copy of self. */ | 35 /** Return a copy of self. */ |
37 IContent dup (); | 36 IContent dup (); |
38 | 37 |
39 /** Attempt to convert the content to a specific type (may simply return this if appropriate). | 38 /** Attempt to convert the content to a specific type (may simply return this if appropriate). |
40 * | 39 * |
41 * Annoyingly we can't use cast because overloading by return type isn't supported. */ | 40 * Annoyingly we can't use cast because overloading by return type isn't supported. */ |
42 // FIXME: throw or return null on error or unsupported conversion? | 41 // FIXME: throw or return null on error or unsupported conversion? |
43 ContentText toText (); | 42 ContentText toText (); |
44 ContentInt toInt (); /// ditto | 43 ContentInt toInt (); /// ditto |
44 +/ | |
45 | 45 |
46 /** Every Content should be convertible to a string, which, if possible, should be a sensible | 46 /** Every Content should be convertible to a string, which, if possible, should be a sensible |
47 * conversion of its content. */ | 47 * conversion of its content. */ |
48 char[] toString (); | 48 char[] toString (); |
49 } | 49 } |
64 * | 64 * |
65 * NOTE: Needs to be a reference type really. | 65 * NOTE: Needs to be a reference type really. |
66 * Could alternately be: | 66 * Could alternately be: |
67 * alias ContentTextStruct* ContentText | 67 * alias ContentTextStruct* ContentText |
68 * where ContentTextStruct is a struct. */ | 68 * where ContentTextStruct is a struct. */ |
69 class ContentText : Content | 69 class ContentText : IContent |
70 { | 70 { |
71 this () {} | 71 this () {} |
72 this (char[] text) { | 72 this (char[] text) { |
73 text_ = text; | 73 text_ = text; |
74 } | 74 } |
96 //NOTE: need to allow cache-invalidating when text changes! | 96 //NOTE: need to allow cache-invalidating when text changes! |
97 char[] text_; | 97 char[] text_; |
98 } | 98 } |
99 | 99 |
100 /** Integer content. */ | 100 /** Integer content. */ |
101 class ContentInt : Content | 101 class ContentInt : IContent |
102 { | 102 { |
103 this () {} | 103 this () {} |
104 this (int integer) { | 104 this (int integer) { |
105 int_ = integer; | 105 int_ = integer; |
106 } | 106 } |