Commit 06e03514 authored by twanvl's avatar twanvl

Added placeholder ValueEditors for all field types

parent 1f6d3118
...@@ -95,7 +95,7 @@ class Style { ...@@ -95,7 +95,7 @@ class Style {
virtual ValueViewerP makeViewer(DataViewer& parent, const StyleP& thisP) = 0; virtual ValueViewerP makeViewer(DataViewer& parent, const StyleP& thisP) = 0;
/// Make an editor object for values using this style /// Make an editor object for values using this style
/** thisP is a smart pointer to this */ /** thisP is a smart pointer to this */
virtual ValueEditorP makeEditor(DataEditor& parent, const StyleP& thisP) = 0; virtual ValueViewerP makeEditor(DataEditor& parent, const StyleP& thisP) = 0;
/// Update scripted values of this style, return true if anything has changed /// Update scripted values of this style, return true if anything has changed
virtual bool update(Context&); virtual bool update(Context&);
...@@ -157,7 +157,7 @@ template <> ValueP read_new<Value>(Reader&); ...@@ -157,7 +157,7 @@ template <> ValueP read_new<Value>(Reader&);
#define DECLARE_STYLE_TYPE(Type) \ #define DECLARE_STYLE_TYPE(Type) \
DECLARE_HAS_FIELD(Type) \ DECLARE_HAS_FIELD(Type) \
virtual ValueViewerP makeViewer(DataViewer& parent, const StyleP& thisP); \ virtual ValueViewerP makeViewer(DataViewer& parent, const StyleP& thisP); \
virtual ValueEditorP makeEditor(DataEditor& parent, const StyleP& thisP) virtual ValueViewerP makeEditor(DataEditor& parent, const StyleP& thisP)
// implement field() which returns a field with the right (derived) type // implement field() which returns a field with the right (derived) type
#define DECLARE_HAS_FIELD(Type) \ #define DECLARE_HAS_FIELD(Type) \
......
...@@ -36,7 +36,7 @@ class BooleanField : public ChoiceField { ...@@ -36,7 +36,7 @@ class BooleanField : public ChoiceField {
class BooleanStyle : public ChoiceStyle { class BooleanStyle : public ChoiceStyle {
public: public:
inline BooleanStyle(const ChoiceFieldP& field) : ChoiceStyle(field) {} inline BooleanStyle(const ChoiceFieldP& field) : ChoiceStyle(field) {}
DECLARE_STYLE_TYPE(Boolean); DECLARE_HAS_FIELD(Boolean); // not DECLARE_STYLE_TYPE, because we use a normal ChoiceValueViewer/Editor
// no extra data // no extra data
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#define FOR_EACH_EDITOR \ #define FOR_EACH_EDITOR \
FOR_EACH(v, viewers) \ FOR_EACH(v, viewers) \
if (ValueEditorP = static_pointer_cast<ValueEditor>(v)) if (ValueEditor* e = v->getEditor())
DataEditor::DataEditor(Window* parent, int id, long style) DataEditor::DataEditor(Window* parent, int id, long style)
: CardViewer(parent, id, style) : CardViewer(parent, id, style)
......
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <render/value/boolean.hpp> #include <gui/value/choice.hpp>
// ----------------------------------------------------------------------------- : // ----------------------------------------------------------------------------- :
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_GUI_VALUE_CHOICE
#define HEADER_GUI_VALUE_CHOICE
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/value/editor.hpp>
#include <render/value/choice.hpp>
// ----------------------------------------------------------------------------- : ChoiceValueEditor
/// An editor 'control' for editing ChoiceValues
class ChoiceValueEditor : public ChoiceValueViewer, public ValueEditor {
public:
DECLARE_VALUE_EDITOR(Choice);
};
// ----------------------------------------------------------------------------- : EOF
#endif
...@@ -4,15 +4,8 @@ ...@@ -4,15 +4,8 @@
//| License: GNU General Public License 2 or later (see file COPYING) | //| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+ //+----------------------------------------------------------------------------+
#ifndef HEADER_RENDER_VALUE_BOOLEAN
#define HEADER_RENDER_VALUE_BOOLEAN
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp> #include <gui/value/color.hpp>
// ----------------------------------------------------------------------------- : // ----------------------------------------------------------------------------- :
// ----------------------------------------------------------------------------- : EOF
#endif
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_GUI_VALUE_COLOR
#define HEADER_GUI_VALUE_COLOR
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/value/editor.hpp>
#include <render/value/color.hpp>
// ----------------------------------------------------------------------------- : ColorValueEditor
/// An editor 'control' for editing ColorValues
class ColorValueEditor : public ColorValueViewer, public ValueEditor {
public:
DECLARE_VALUE_EDITOR(Color);
};
// ----------------------------------------------------------------------------- : EOF
#endif
...@@ -7,5 +7,26 @@ ...@@ -7,5 +7,26 @@
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <gui/value/editor.hpp> #include <gui/value/editor.hpp>
#include <gui/value/text.hpp>
#include <gui/value/choice.hpp>
#include <gui/value/multiple_choice.hpp>
#include <gui/value/image.hpp>
#include <gui/value/symbol.hpp>
#include <gui/value/color.hpp>
// ----------------------------------------------------------------------------- : ValueEditor // ----------------------------------------------------------------------------- : ValueEditor
// ----------------------------------------------------------------------------- : Type dispatch
#define IMPLEMENT_MAKE_EDITOR(Type) \
ValueViewerP Type##Style::makeEditor(DataEditor& parent, const StyleP& thisP) { \
assert(thisP.get() == this); \
return ValueViewerP(new Type##ValueEditor(parent, static_pointer_cast<Type##Style>(thisP))); \
}
IMPLEMENT_MAKE_EDITOR(Text);
IMPLEMENT_MAKE_EDITOR(Choice);
IMPLEMENT_MAKE_EDITOR(MultipleChoice);
IMPLEMENT_MAKE_EDITOR(Color);
IMPLEMENT_MAKE_EDITOR(Image);
IMPLEMENT_MAKE_EDITOR(Symbol);
...@@ -10,32 +10,27 @@ ...@@ -10,32 +10,27 @@
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp> #include <util/prec.hpp>
#include <gui/control/card_editor.hpp>
#include <render/value/viewer.hpp> #include <render/value/viewer.hpp>
class DataEditor;
// ----------------------------------------------------------------------------- : ValueEditor // ----------------------------------------------------------------------------- : ValueEditor
/// An editor 'control' for a single value on a card /// An editor 'control' for a single value on a card
/** The inheritance diagram for derived editors looks like: /** The inheritance diagram for derived editors looks like:
* ValueViewer * ValueViewer
* ^ ^ * ^
* / . * /
* / . * /
* SomeViewer ValueEditor * SomeValueViewer ValueEditor
* ^ ^ * ^ ^
* \ / * \ /
* \ / * \ /
* SomeEditor * SomeValueEditor
* *
* Where ... is virtual inheritance and -- is normal inheritance. * Note that ValueEditor does NOT inherit from ValueViewer, because that leads to all kinds of problems
* This is slightly different from the usual virtual inheritance recipe, but it should still work.
*/ */
class ValueEditor : public virtual ValueViewer { class ValueEditor {
public: public:
/// Construct a ValueEditor, set the value at a later time
ValueEditor(DataEditor& parent, const StyleP& style);
// --------------------------------------------------- : Events // --------------------------------------------------- : Events
/// This editor gains focus /// This editor gains focus
...@@ -52,7 +47,7 @@ class ValueEditor : public virtual ValueViewer { ...@@ -52,7 +47,7 @@ class ValueEditor : public virtual ValueViewer {
virtual void onMouseWheel (RealPoint pos, wxMouseEvent& ev) {} virtual void onMouseWheel (RealPoint pos, wxMouseEvent& ev) {}
/// Key events /// Key events
virtual void onChar(wxKeyEvent ev); virtual void onChar(wxKeyEvent ev) {}
/// A menu item was selected /// A menu item was selected
virtual void onMenu(wxCommandEvent& ev) { ev.Skip(); } virtual void onMenu(wxCommandEvent& ev) { ev.Skip(); }
...@@ -102,5 +97,18 @@ class ValueEditor : public virtual ValueViewer { ...@@ -102,5 +97,18 @@ class ValueEditor : public virtual ValueViewer {
virtual wxCursor cursor() const { return wxCursor(); } virtual wxCursor cursor() const { return wxCursor(); }
}; };
// ----------------------------------------------------------------------------- : Utility
#define DECLARE_VALUE_EDITOR(Type) \
Type##ValueEditor(DataEditor& parent, const Type##StyleP& style) \
: Type##ValueViewer(parent, style) \
{} \
virtual ValueEditor* getEditor() { return this; } \
private: \
inline DataEditor& editor() const { \
return static_cast<DataEditor&>(viewer); \
} \
public:
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <gui/value/image.hpp>
// ----------------------------------------------------------------------------- :
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_GUI_VALUE_IMAGE
#define HEADER_GUI_VALUE_IMAGE
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/value/editor.hpp>
#include <render/value/image.hpp>
// ----------------------------------------------------------------------------- : ImageValueEditor
/// An editor 'control' for editing ImageValues
class ImageValueEditor : public ImageValueViewer, public ValueEditor {
public:
DECLARE_VALUE_EDITOR(Image);
};
// ----------------------------------------------------------------------------- : EOF
#endif
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <gui/value/multiple_choice.hpp>
// ----------------------------------------------------------------------------- :
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_GUI_VALUE_MULTIPLE_CHOICE
#define HEADER_GUI_VALUE_MULTIPLE_CHOICE
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/value/editor.hpp>
#include <render/value/multiple_choice.hpp>
// ----------------------------------------------------------------------------- : MultipleChoiceValueEditor
/// An editor 'control' for editing MultipleChoiceValues
class MultipleChoiceValueEditor : public MultipleChoiceValueViewer, public ValueEditor {
public:
DECLARE_VALUE_EDITOR(MultipleChoice);
};
// ----------------------------------------------------------------------------- : EOF
#endif
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <gui/value/symbol.hpp>
// ----------------------------------------------------------------------------- :
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_GUI_VALUE_SYMBOL
#define HEADER_GUI_VALUE_SYMBOL
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/value/editor.hpp>
#include <render/value/symbol.hpp>
// ----------------------------------------------------------------------------- : SymbolValueEditor
/// An editor 'control' for editing SymbolValues
class SymbolValueEditor : public SymbolValueViewer, public ValueEditor {
public:
DECLARE_VALUE_EDITOR(Symbol);
};
// ----------------------------------------------------------------------------- : EOF
#endif
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <gui/value/text.hpp>
// ----------------------------------------------------------------------------- :
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_GUI_VALUE_TEXT
#define HEADER_GUI_VALUE_TEXT
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/value/editor.hpp>
#include <render/value/text.hpp>
// ----------------------------------------------------------------------------- : TextValueEditor
/// An editor 'control' for editing TextValues
class TextValueEditor : public TextValueViewer, public ValueEditor {
public:
DECLARE_VALUE_EDITOR(Text);
};
// ----------------------------------------------------------------------------- : EOF
#endif
...@@ -578,6 +578,66 @@ ...@@ -578,6 +578,66 @@
<Filter <Filter
Name="value" Name="value"
Filter=""> Filter="">
<File
RelativePath=".\gui\value\choice.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\gui\value\choice.hpp">
</File>
<File
RelativePath=".\gui\value\color.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\gui\value\color.hpp">
</File>
<File <File
RelativePath=".\gui\value\editor.cpp"> RelativePath=".\gui\value\editor.cpp">
<FileConfiguration <FileConfiguration
...@@ -626,6 +686,96 @@ ...@@ -626,6 +686,96 @@
<File <File
RelativePath=".\gui\value\image.hpp"> RelativePath=".\gui\value\image.hpp">
</File> </File>
<File
RelativePath=".\gui\value\multiple_choice.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\gui\value\multiple_choice.hpp">
</File>
<File
RelativePath=".\gui\value\symbol.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\gui\value\symbol.hpp">
</File>
<File
RelativePath=".\gui\value\text.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\gui\value\text.hpp">
</File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
......
...@@ -48,4 +48,4 @@ void ChoiceValueViewer::draw(RotatedDC& dc) { ...@@ -48,4 +48,4 @@ void ChoiceValueViewer::draw(RotatedDC& dc) {
align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), style().getRect()) + RealSize(margin, 0) align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), style().getRect()) + RealSize(margin, 0)
); );
} }
} }
\ No newline at end of file
...@@ -24,6 +24,5 @@ class ColorValueViewer : public ValueViewer { ...@@ -24,6 +24,5 @@ class ColorValueViewer : public ValueViewer {
virtual bool containsPoint(const RealPoint& p) const; virtual bool containsPoint(const RealPoint& p) const;
}; };
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
...@@ -37,6 +37,5 @@ class ImageValueViewer : public ValueViewer { ...@@ -37,6 +37,5 @@ class ImageValueViewer : public ValueViewer {
static Bitmap imagePlaceholder(const Rotation& rot, UInt w, UInt h, bool editing); static Bitmap imagePlaceholder(const Rotation& rot, UInt w, UInt h, bool editing);
}; };
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
...@@ -8,4 +8,8 @@ ...@@ -8,4 +8,8 @@
#include <render/value/multiple_choice.hpp> #include <render/value/multiple_choice.hpp>
// ----------------------------------------------------------------------------- : // ----------------------------------------------------------------------------- : MultipleChoiceValueViewer
void MultipleChoiceValueViewer::draw(RotatedDC& dc) {
// TODO
}
...@@ -10,9 +10,18 @@ ...@@ -10,9 +10,18 @@
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp> #include <util/prec.hpp>
#include <render/value/viewer.hpp>
#include <data/field/multiple_choice.hpp>
// ----------------------------------------------------------------------------- : // ----------------------------------------------------------------------------- : MultipleChoiceValueViewer
/// Viewer that displays a multiple choice value
class MultipleChoiceValueViewer : public ValueViewer {
public:
DECLARE_VALUE_VIEWER(MultipleChoice) : ValueViewer(parent,style) {}
virtual void draw(RotatedDC& dc);
};
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
...@@ -8,4 +8,8 @@ ...@@ -8,4 +8,8 @@
#include <render/value/symbol.hpp> #include <render/value/symbol.hpp>
// ----------------------------------------------------------------------------- : // ----------------------------------------------------------------------------- : SymbolValueViewer
void SymbolValueViewer::draw(RotatedDC& dc) {
// TODO
}
...@@ -10,9 +10,18 @@ ...@@ -10,9 +10,18 @@
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp> #include <util/prec.hpp>
#include <render/value/viewer.hpp>
#include <data/field/symbol.hpp>
// ----------------------------------------------------------------------------- : // ----------------------------------------------------------------------------- : SymbolValueViewer
/// Viewer that displays a symbol value
class SymbolValueViewer : public ValueViewer {
public:
DECLARE_VALUE_VIEWER(Symbol) : ValueViewer(parent,style) {}
virtual void draw(RotatedDC& dc);
};
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <render/value/text.hpp> #include <render/value/text.hpp>
#include <render/value/choice.hpp> #include <render/value/choice.hpp>
#include <render/value/multiple_choice.hpp> #include <render/value/multiple_choice.hpp>
#include <render/value/boolean.hpp>
#include <render/value/image.hpp> #include <render/value/image.hpp>
#include <render/value/symbol.hpp> #include <render/value/symbol.hpp>
#include <render/value/color.hpp> #include <render/value/color.hpp>
...@@ -52,20 +51,7 @@ bool ValueViewer::nativeLook() const { ...@@ -52,20 +51,7 @@ bool ValueViewer::nativeLook() const {
return viewer.nativeLook(); return viewer.nativeLook();
} }
// ----------------------------------------------------------------------------- : Development/debug // ----------------------------------------------------------------------------- : Type dispatch
#ifdef _DEBUG
// REMOVEME
#include <data/field.hpp>
#include <data/field/choice.hpp>
#include <data/field/boolean.hpp>
#include <data/field/multiple_choice.hpp>
#include <data/field/color.hpp>
#include <data/field/image.hpp>
#include <data/field/symbol.hpp>
#include <data/field/text.hpp>
#define IMPLEMENT_MAKE_VIEWER(Type) \ #define IMPLEMENT_MAKE_VIEWER(Type) \
ValueViewerP Type##Style::makeViewer(DataViewer& parent, const StyleP& thisP) { \ ValueViewerP Type##Style::makeViewer(DataViewer& parent, const StyleP& thisP) { \
...@@ -73,24 +59,9 @@ bool ValueViewer::nativeLook() const { ...@@ -73,24 +59,9 @@ bool ValueViewer::nativeLook() const {
return ValueViewerP(new Type##ValueViewer(parent, static_pointer_cast<Type##Style>(thisP))); \ return ValueViewerP(new Type##ValueViewer(parent, static_pointer_cast<Type##Style>(thisP))); \
} }
//ValueViewerP ChoiceStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
ValueViewerP BooleanStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
ValueViewerP MultipleChoiceStyle::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
//ValueViewerP ColorStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
//ValueViewerP ImageStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
IMPLEMENT_MAKE_VIEWER(Text); IMPLEMENT_MAKE_VIEWER(Text);
IMPLEMENT_MAKE_VIEWER(Choice); IMPLEMENT_MAKE_VIEWER(Choice);
IMPLEMENT_MAKE_VIEWER(MultipleChoice);
IMPLEMENT_MAKE_VIEWER(Color); IMPLEMENT_MAKE_VIEWER(Color);
IMPLEMENT_MAKE_VIEWER(Image); IMPLEMENT_MAKE_VIEWER(Image);
ValueViewerP SymbolStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); } IMPLEMENT_MAKE_VIEWER(Symbol);
//ValueViewerP TextStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
ValueEditorP ChoiceStyle ::makeEditor(DataEditor& parent, const StyleP& thisP) { return ValueEditorP(); }
ValueEditorP BooleanStyle ::makeEditor(DataEditor& parent, const StyleP& thisP) { return ValueEditorP(); }
ValueEditorP MultipleChoiceStyle::makeEditor(DataEditor& parent, const StyleP& thisP) { return ValueEditorP(); }
ValueEditorP ColorStyle ::makeEditor(DataEditor& parent, const StyleP& thisP) { return ValueEditorP(); }
ValueEditorP ImageStyle ::makeEditor(DataEditor& parent, const StyleP& thisP) { return ValueEditorP(); }
ValueEditorP SymbolStyle ::makeEditor(DataEditor& parent, const StyleP& thisP) { return ValueEditorP(); }
ValueEditorP TextStyle ::makeEditor(DataEditor& parent, const StyleP& thisP) { return ValueEditorP(); }
#endif
\ No newline at end of file
...@@ -55,6 +55,9 @@ class ValueViewer { ...@@ -55,6 +55,9 @@ class ValueViewer {
/// Called when an action is performed on the associated value /// Called when an action is performed on the associated value
virtual void onAction(const ValueAction&, bool undone) { onValueChange(); } virtual void onAction(const ValueAction&, bool undone) { onValueChange(); }
/// Convert this viewer to an editor, if possible
virtual ValueEditor* getEditor() { return 0; }
protected: protected:
DataViewer& viewer; ///< Our parent object DataViewer& viewer; ///< Our parent object
StyleP styleP; ///< The style of this viewer StyleP styleP; ///< The style of this viewer
...@@ -75,7 +78,7 @@ class ValueViewer { ...@@ -75,7 +78,7 @@ class ValueViewer {
// ----------------------------------------------------------------------------- : Utility // ----------------------------------------------------------------------------- : Utility
#define DECLARE_VALUE_VIEWER(Type) \ #define DECLARE_VALUE_VIEWER(Type) \
private: \ protected: \
inline Type##Style& style() const { return static_cast< Type##Style&>(*styleP); } \ inline Type##Style& style() const { return static_cast< Type##Style&>(*styleP); } \
inline const Type##Value& value() const { return static_cast<const Type##Value&>(*valueP); } \ inline const Type##Value& value() const { return static_cast<const Type##Value&>(*valueP); } \
inline const Type##Field& field() const { return style().field(); } \ inline const Type##Field& field() const { return style().field(); } \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment