Files
MagicSetEditor2/src/data/field/multiple_choice.hpp
T
twanvl 97e0e8d6d6 Choice rendering now uses "style.image()" instead of "style.choice_images[value]";
Added script functions for working with multiple choice values;
Added in_context support for filter_rule;
Optimized toUpper/toLower because they are slow on windows (they use thread local storage and mutexes)

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@427 0fc631ac-6414-0410-93d0-97cfa31319b6
2007-06-17 13:13:56 +00:00

87 lines
3.0 KiB
C++

//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_DATA_FIELD_MULTIPLE_CHOICE
#define HEADER_DATA_FIELD_MULTIPLE_CHOICE
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field/choice.hpp>
// ----------------------------------------------------------------------------- : MultipleChoiceField
DECLARE_POINTER_TYPE(MultipleChoiceField);
DECLARE_POINTER_TYPE(MultipleChoiceStyle);
DECLARE_POINTER_TYPE(MultipleChoiceValue);
/// A ChoiceField where multiple choices can be selected simultaniously
class MultipleChoiceField : public ChoiceField {
public:
MultipleChoiceField();
DECLARE_FIELD_TYPE(MultipleChoiceField);
UInt minimum_selection, maximum_selection; ///< How many choices can be selected simultaniously?
String empty_choice; ///< Name to use when nothing is selected
private:
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : MultipleChoiceStyle
/// The Style for a MultipleChoiceField
class MultipleChoiceStyle : public ChoiceStyle {
public:
MultipleChoiceStyle(const MultipleChoiceFieldP& field);
DECLARE_STYLE_TYPE(MultipleChoice);
Direction direction; ///< In what direction are choices layed out?
double spacing; ///< Spacing between choices (images) in pixels
private:
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : MultipleChoiceValue
/// The Value in a MultipleChoiceField
/** The value is stored as "<choice>, <choice>, <choice>"
* The choices must be ordered by id
*/
class MultipleChoiceValue : public ChoiceValue {
public:
inline MultipleChoiceValue(const MultipleChoiceFieldP& field) : ChoiceValue(field, true) {}
DECLARE_HAS_FIELD(MultipleChoice);
String last_change; ///< Which of the choices was selected/deselected last?
// for SimpleValueAction
struct ValueType {
ChoiceValue::ValueType value;
String last_change;
};
/// Splits the value, stores the selected choices in the out parameter
void get(vector<String>& out) const;
virtual bool update(Context&);
private:
DECLARE_REFLECTION();
/// Put the value in normal form (all choices ordered, empty_name
void normalForm();
};
// ----------------------------------------------------------------------------- : Utilities
/// Is the given choice selected in the value?
bool chosen(const String& multiple_choice_value, const String& chioce);
// ----------------------------------------------------------------------------- : EOF
#endif