view mde/content/IContent.d @ 167:620d4ea30228

Context menus: added a clipboard (functions accessible from main menu rather than context menu).
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 27 Jun 2009 11:57:26 +0200
parents 24d77c52243f
children e45226d3deae
line wrap: on
line source

/* LICENSE BLOCK
Part of mde: a Modular D game-oriented Engine
Copyright © 2007-2008 Diggory Hardy

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>. */

/******************************************************************************
 * The content system − interfaces.
 * 
 * The IContentList interface is defined in the Content module to allow it to
 * use a Content[] type (since arrays of classes cannot have their type cast
 * directly, at least not to/from an interface).
 *****************************************************************************/
module mde.content.IContent;

/** IContent − interface for all Content classes.
 *
 * Very little code uses IContent (except for passing opaquely). */
interface IContent
{
    /** Generically return strings.
    *
    * This serves two purposes: generically returning a string of/related to the content (i == 0),
    * and returning associated descriptors. Functions should adhere to (or add to) this table.
    *
    *  $(TABLE
    *  $(TR $(TH i) $(TH returns))
    *  $(TR $(TD 0) $(TD value))
    *  $(TR $(TD 1) $(TD Translated name or null))
    *  $(TR $(TD 2) $(TD Translated description or null))
    *  $(TR $(TD other) $(TD null))
    *  ) */
    char[] toString (uint i);
    
    /** Generic way to set content value.
     *
     * If cont's type is compatible, the method should set its instance's
     * value to that of cont and return true, otherwise it should return false.
     */
    bool set (IContent);
    
    /** Similarly, try to set the value directly from a string.
     * Doesn't do anything for content not storing a value. */
    void opAssign (char[]);
}

/** Interface for content which should be interacted with as a button.
 *
 * Actually not used to provide extra methods, but to tell widget-choosing
 * functions a button is desired. */
interface IEventContent : IContent {
}