Commit f79492cb authored by twanvl's avatar twanvl

Added ValueViewer,DataViewer,CardViewer and made related changes

parent e992cf8b
...@@ -18,6 +18,11 @@ DECLARE_POINTER_TYPE(Field); ...@@ -18,6 +18,11 @@ DECLARE_POINTER_TYPE(Field);
DECLARE_POINTER_TYPE(Style); DECLARE_POINTER_TYPE(Style);
DECLARE_POINTER_TYPE(Value); DECLARE_POINTER_TYPE(Value);
// for DataViewer/editor
class DataViewer; class DataEditor;
DECLARE_POINTER_TYPE(ValueViewer);
DECLARE_POINTER_TYPE(ValueEditor);
// ----------------------------------------------------------------------------- : Field // ----------------------------------------------------------------------------- : Field
/// Information on how to store a value /// Information on how to store a value
...@@ -74,6 +79,13 @@ class Style { ...@@ -74,6 +79,13 @@ class Style {
Scriptable<double> width, height; ///< Position of this field Scriptable<double> width, height; ///< Position of this field
Scriptable<bool> visible; ///< Is this field visible? Scriptable<bool> visible; ///< Is this field visible?
/// Make a viewer object for values using this style
/** thisP is a smart pointer to this */
virtual ValueViewerP makeViewer(DataViewer& parent, const StyleP& thisP) = 0;
/// Make an editor object for values using this style
/** thisP is a smart pointer to this */
virtual ValueEditorP makeEditor(DataEditor& parent, const StyleP& thisP) = 0;
private: private:
DECLARE_REFLECTION_VIRTUAL(); DECLARE_REFLECTION_VIRTUAL();
}; };
...@@ -107,8 +119,13 @@ template <> ValueP read_new<Value>(Reader&); ...@@ -107,8 +119,13 @@ template <> ValueP read_new<Value>(Reader&);
// ----------------------------------------------------------------------------- : Utilities // ----------------------------------------------------------------------------- : Utilities
#define DECLARE_FIELD_TYPE(Type) \
virtual ValueP newValue(const FieldP& thisP) const; \
virtual StyleP newStyle(const FieldP& thisP) const; \
virtual String typeName() const
// implement newStyle and newValue // implement newStyle and newValue
#define FIELD_TYPE(Type) \ #define IMPLEMENT_FIELD_TYPE(Type) \
StyleP Type ## Field::newStyle(const FieldP& thisP) const { \ StyleP Type ## Field::newStyle(const FieldP& thisP) const { \
assert(thisP.get() == this); \ assert(thisP.get() == this); \
return new_shared1<Type ## Style>(static_pointer_cast<Type ## Field>(thisP)); \ return new_shared1<Type ## Style>(static_pointer_cast<Type ## Field>(thisP)); \
...@@ -118,8 +135,13 @@ template <> ValueP read_new<Value>(Reader&); ...@@ -118,8 +135,13 @@ template <> ValueP read_new<Value>(Reader&);
return new_shared1<Type ## Value>(static_pointer_cast<Type ## Field>(thisP)); \ return new_shared1<Type ## Value>(static_pointer_cast<Type ## Field>(thisP)); \
} }
#define DECLARE_STYLE_TYPE(Type) \
DECLARE_HAS_FIELD(Type) \
virtual ValueViewerP makeViewer(DataViewer& parent, const StyleP& thisP); \
virtual ValueEditorP 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 HAS_FIELD(Type) \ #define DECLARE_HAS_FIELD(Type) \
inline Type ## Field& field() const { \ inline Type ## Field& field() const { \
return *static_cast<Type ## Field*>(fieldP.get()); \ return *static_cast<Type ## Field*>(fieldP.get()); \
} }
......
...@@ -16,7 +16,7 @@ BooleanField::BooleanField() { ...@@ -16,7 +16,7 @@ BooleanField::BooleanField() {
choices->initIds(); choices->initIds();
} }
FIELD_TYPE(Boolean) IMPLEMENT_FIELD_TYPE(Boolean)
String BooleanField::typeName() const { String BooleanField::typeName() const {
return _("boolean"); return _("boolean");
......
...@@ -20,13 +20,10 @@ DECLARE_POINTER_TYPE(BooleanField); ...@@ -20,13 +20,10 @@ DECLARE_POINTER_TYPE(BooleanField);
class BooleanField : public ChoiceField { class BooleanField : public ChoiceField {
public: public:
BooleanField(); BooleanField();
DECLARE_FIELD_TYPE(Boolean);
// no extra data // no extra data
virtual ValueP newValue(const FieldP& thisP) const;
virtual StyleP newStyle(const FieldP& thisP) const;
virtual String typeName() const;
private: private:
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
...@@ -37,7 +34,7 @@ class BooleanField : public ChoiceField { ...@@ -37,7 +34,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) {}
HAS_FIELD(Boolean) DECLARE_STYLE_TYPE(Boolean);
// no extra data // no extra data
...@@ -51,7 +48,7 @@ class BooleanStyle : public ChoiceStyle { ...@@ -51,7 +48,7 @@ class BooleanStyle : public ChoiceStyle {
class BooleanValue : public ChoiceValue { class BooleanValue : public ChoiceValue {
public: public:
inline BooleanValue(const ChoiceFieldP& field) : ChoiceValue(field) {} inline BooleanValue(const ChoiceFieldP& field) : ChoiceValue(field) {}
HAS_FIELD(Boolean) DECLARE_HAS_FIELD(Boolean);
// no extra data // no extra data
......
...@@ -17,7 +17,7 @@ ChoiceField::ChoiceField() ...@@ -17,7 +17,7 @@ ChoiceField::ChoiceField()
, default_name(_("Default")) , default_name(_("Default"))
{} {}
FIELD_TYPE(Choice) IMPLEMENT_FIELD_TYPE(Choice)
String ChoiceField::typeName() const { String ChoiceField::typeName() const {
return _("choice"); return _("choice");
......
...@@ -23,6 +23,7 @@ DECLARE_POINTER_TYPE(ChoiceField); ...@@ -23,6 +23,7 @@ DECLARE_POINTER_TYPE(ChoiceField);
class ChoiceField : public Field { class ChoiceField : public Field {
public: public:
ChoiceField(); ChoiceField();
DECLARE_FIELD_TYPE(Choice);
class Choice; class Choice;
typedef shared_ptr<Choice> ChoiceP; typedef shared_ptr<Choice> ChoiceP;
...@@ -32,11 +33,7 @@ class ChoiceField : public Field { ...@@ -32,11 +33,7 @@ class ChoiceField : public Field {
OptionalScript default_script; ///< Script that generates the default value OptionalScript default_script; ///< Script that generates the default value
String initial; ///< Initial choice of a new value, or "" String initial; ///< Initial choice of a new value, or ""
String default_name; ///< Name of "default" value String default_name; ///< Name of "default" value
virtual ValueP newValue(const FieldP& thisP) const;
virtual StyleP newStyle(const FieldP& thisP) const;
virtual String typeName() const;
private: private:
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
...@@ -111,7 +108,7 @@ enum ChoiceRenderStyle ...@@ -111,7 +108,7 @@ enum ChoiceRenderStyle
class ChoiceStyle : public Style { class ChoiceStyle : public Style {
public: public:
ChoiceStyle(const ChoiceFieldP& field); ChoiceStyle(const ChoiceFieldP& field);
HAS_FIELD(Choice) DECLARE_STYLE_TYPE(Choice);
ChoicePopupStyle popup_style; ///< Style of popups/menus ChoicePopupStyle popup_style; ///< Style of popups/menus
ChoiceRenderStyle render_style; ///< Style of rendering ChoiceRenderStyle render_style; ///< Style of rendering
...@@ -133,7 +130,7 @@ class ChoiceStyle : public Style { ...@@ -133,7 +130,7 @@ class ChoiceStyle : public Style {
class ChoiceValue : public Value { class ChoiceValue : public Value {
public: public:
inline ChoiceValue(const ChoiceFieldP& field) : Value(field) {} inline ChoiceValue(const ChoiceFieldP& field) : Value(field) {}
HAS_FIELD(Choice) DECLARE_HAS_FIELD(Choice)
Defaultable<String> value; /// The name of the selected choice Defaultable<String> value; /// The name of the selected choice
......
...@@ -17,7 +17,7 @@ ColorField::ColorField() ...@@ -17,7 +17,7 @@ ColorField::ColorField()
, allow_custom(true) , allow_custom(true)
{} {}
FIELD_TYPE(Color) IMPLEMENT_FIELD_TYPE(Color)
String ColorField::typeName() const { String ColorField::typeName() const {
return _("color"); return _("color");
......
...@@ -22,6 +22,7 @@ DECLARE_POINTER_TYPE(ColorField); ...@@ -22,6 +22,7 @@ DECLARE_POINTER_TYPE(ColorField);
class ColorField : public Field { class ColorField : public Field {
public: public:
ColorField(); ColorField();
DECLARE_FIELD_TYPE(Color);
class Choice; class Choice;
typedef shared_ptr<Choice> ChoiceP; typedef shared_ptr<Choice> ChoiceP;
...@@ -31,11 +32,7 @@ class ColorField : public Field { ...@@ -31,11 +32,7 @@ class ColorField : public Field {
vector<ChoiceP> choices; ///< Color choices available vector<ChoiceP> choices; ///< Color choices available
bool allow_custom; ///< Are colors not in the list of choices allowed? bool allow_custom; ///< Are colors not in the list of choices allowed?
String default_name; ///< Name of "default" value String default_name; ///< Name of "default" value
virtual ValueP newValue(const FieldP& thisP) const;
virtual StyleP newStyle(const FieldP& thisP) const;
virtual String typeName() const;
private: private:
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
...@@ -55,7 +52,7 @@ class ColorField::Choice { ...@@ -55,7 +52,7 @@ class ColorField::Choice {
class ColorStyle : public Style { class ColorStyle : public Style {
public: public:
ColorStyle(const ColorFieldP& field); ColorStyle(const ColorFieldP& field);
HAS_FIELD(Color) DECLARE_STYLE_TYPE(Color);
int radius; ///< Radius of round corners int radius; ///< Radius of round corners
UInt left_width; ///< Width of the colored region on the left side UInt left_width; ///< Width of the colored region on the left side
...@@ -73,7 +70,7 @@ class ColorStyle : public Style { ...@@ -73,7 +70,7 @@ class ColorStyle : public Style {
class ColorValue : public Value { class ColorValue : public Value {
public: public:
inline ColorValue(const ColorFieldP& field) : Value(field) {} inline ColorValue(const ColorFieldP& field) : Value(field) {}
HAS_FIELD(Color) DECLARE_HAS_FIELD(Color)
Defaultable<Color> value; ///< The value Defaultable<Color> value; ///< The value
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
// ----------------------------------------------------------------------------- : ImageField // ----------------------------------------------------------------------------- : ImageField
FIELD_TYPE(Image) IMPLEMENT_FIELD_TYPE(Image)
String ImageField::typeName() const { String ImageField::typeName() const {
return _("image"); return _("image");
......
...@@ -21,10 +21,7 @@ DECLARE_POINTER_TYPE(ImageField); ...@@ -21,10 +21,7 @@ DECLARE_POINTER_TYPE(ImageField);
class ImageField : public Field { class ImageField : public Field {
public: public:
// no extra data // no extra data
DECLARE_FIELD_TYPE(Image);
virtual ValueP newValue(const FieldP& thisP) const;
virtual StyleP newStyle(const FieldP& thisP) const;
virtual String typeName() const;
private: private:
DECLARE_REFLECTION(); DECLARE_REFLECTION();
...@@ -36,6 +33,7 @@ class ImageField : public Field { ...@@ -36,6 +33,7 @@ class ImageField : public Field {
class ImageStyle : public Style { class ImageStyle : public Style {
public: public:
inline ImageStyle(const ImageFieldP& field) : Style(field) {} inline ImageStyle(const ImageFieldP& field) : Style(field) {}
DECLARE_STYLE_TYPE(Image);
Scriptable<String> mask_filename; ///< Filename for a mask image Scriptable<String> mask_filename; ///< Filename for a mask image
......
...@@ -15,7 +15,7 @@ MultipleChoiceField::MultipleChoiceField() ...@@ -15,7 +15,7 @@ MultipleChoiceField::MultipleChoiceField()
, maximum_selection(1000000) , maximum_selection(1000000)
{} {}
FIELD_TYPE(MultipleChoice) IMPLEMENT_FIELD_TYPE(MultipleChoice)
String MultipleChoiceField::typeName() const { String MultipleChoiceField::typeName() const {
return _("multiple choice"); return _("multiple choice");
......
...@@ -20,13 +20,10 @@ DECLARE_POINTER_TYPE(MultipleChoiceField); ...@@ -20,13 +20,10 @@ DECLARE_POINTER_TYPE(MultipleChoiceField);
class MultipleChoiceField : public ChoiceField { class MultipleChoiceField : public ChoiceField {
public: public:
MultipleChoiceField(); MultipleChoiceField();
DECLARE_FIELD_TYPE(MultipleChoiceField);
UInt minimum_selection, maximum_selection; ///< How many choices can be selected simultaniously? UInt minimum_selection, maximum_selection; ///< How many choices can be selected simultaniously?
virtual ValueP newValue(const FieldP& thisP) const;
virtual StyleP newStyle(const FieldP& thisP) const;
virtual String typeName() const;
private: private:
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
...@@ -41,7 +38,7 @@ enum Direction { ...@@ -41,7 +38,7 @@ enum Direction {
class MultipleChoiceStyle : public ChoiceStyle { class MultipleChoiceStyle : public ChoiceStyle {
public: public:
MultipleChoiceStyle(const MultipleChoiceFieldP& field); MultipleChoiceStyle(const MultipleChoiceFieldP& field);
HAS_FIELD(MultipleChoice) DECLARE_STYLE_TYPE(MultipleChoice);
Direction direction; ///< In what direction are choices layed out? Direction direction; ///< In what direction are choices layed out?
double spacing; ///< Spacing between choices (images) in pixels double spacing; ///< Spacing between choices (images) in pixels
...@@ -59,7 +56,7 @@ class MultipleChoiceStyle : public ChoiceStyle { ...@@ -59,7 +56,7 @@ class MultipleChoiceStyle : public ChoiceStyle {
class MultipleChoiceValue : public ChoiceValue { class MultipleChoiceValue : public ChoiceValue {
public: public:
inline MultipleChoiceValue(const MultipleChoiceFieldP& field) : ChoiceValue(field) {} inline MultipleChoiceValue(const MultipleChoiceFieldP& field) : ChoiceValue(field) {}
HAS_FIELD(MultipleChoice) DECLARE_HAS_FIELD(MultipleChoice);
// no extra data // no extra data
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
// ----------------------------------------------------------------------------- : SymbolField // ----------------------------------------------------------------------------- : SymbolField
FIELD_TYPE(Symbol) IMPLEMENT_FIELD_TYPE(Symbol)
String SymbolField::typeName() const { String SymbolField::typeName() const {
return _("symbol"); return _("symbol");
......
...@@ -23,10 +23,7 @@ DECLARE_POINTER_TYPE(SymbolField); ...@@ -23,10 +23,7 @@ DECLARE_POINTER_TYPE(SymbolField);
class SymbolField : public Field { class SymbolField : public Field {
public: public:
// no extra data // no extra data
DECLARE_FIELD_TYPE(Symbol);
virtual ValueP newValue(const FieldP& thisP) const;
virtual StyleP newStyle(const FieldP& thisP) const;
virtual String typeName() const;
private: private:
DECLARE_REFLECTION(); DECLARE_REFLECTION();
...@@ -38,7 +35,7 @@ class SymbolField : public Field { ...@@ -38,7 +35,7 @@ class SymbolField : public Field {
class SymbolStyle : public Style { class SymbolStyle : public Style {
public: public:
inline SymbolStyle(const SymbolFieldP& field) : Style(field) {} inline SymbolStyle(const SymbolFieldP& field) : Style(field) {}
HAS_FIELD(Symbol) DECLARE_STYLE_TYPE(Symbol);
class Variation; class Variation;
typedef shared_ptr<Variation> VariationP; typedef shared_ptr<Variation> VariationP;
...@@ -64,7 +61,7 @@ class SymbolStyle::Variation { ...@@ -64,7 +61,7 @@ class SymbolStyle::Variation {
class SymbolValue : public Value { class SymbolValue : public Value {
public: public:
inline SymbolValue(const SymbolFieldP& field) : Value(field) {} inline SymbolValue(const SymbolFieldP& field) : Value(field) {}
HAS_FIELD(Symbol) DECLARE_HAS_FIELD(Symbol)
String filename; ///< Filename of the symbol (in the current package) String filename; ///< Filename of the symbol (in the current package)
......
...@@ -16,7 +16,7 @@ TextField::TextField() ...@@ -16,7 +16,7 @@ TextField::TextField()
, default_name(_("Default")) , default_name(_("Default"))
{} {}
FIELD_TYPE(Text) IMPLEMENT_FIELD_TYPE(Text)
String TextField::typeName() const { String TextField::typeName() const {
return _("text"); return _("text");
......
...@@ -22,17 +22,14 @@ DECLARE_POINTER_TYPE(TextField); ...@@ -22,17 +22,14 @@ DECLARE_POINTER_TYPE(TextField);
class TextField : public Field { class TextField : public Field {
public: public:
TextField(); TextField();
DECLARE_FIELD_TYPE(Text);
OptionalScript script; ///< Script to apply to all values OptionalScript script; ///< Script to apply to all values
OptionalScript default_script; ///< Script that generates the default value OptionalScript default_script; ///< Script that generates the default value
bool multi_line; ///< Are newlines allowed in the text? bool multi_line; ///< Are newlines allowed in the text?
bool move_cursor_with_sort; ///< When the text is reordered by a script should the cursor position be updated? bool move_cursor_with_sort; ///< When the text is reordered by a script should the cursor position be updated?
String default_name; ///< Name of "default" value String default_name; ///< Name of "default" value
virtual ValueP newValue(const FieldP& thisP) const;
virtual StyleP newStyle(const FieldP& thisP) const;
virtual String typeName() const;
private: private:
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
...@@ -43,7 +40,7 @@ class TextField : public Field { ...@@ -43,7 +40,7 @@ class TextField : public Field {
class TextStyle : public Style { class TextStyle : public Style {
public: public:
TextStyle(const TextFieldP&); TextStyle(const TextFieldP&);
HAS_FIELD(Text) DECLARE_STYLE_TYPE(Text);
// FontInfo font; ///< Font to use for the text // FontInfo font; ///< Font to use for the text
// SymbolFontInfo symbol_font; ///< Symbol font for symbols in the text // SymbolFontInfo symbol_font; ///< Symbol font for symbols in the text
...@@ -70,7 +67,7 @@ class TextStyle : public Style { ...@@ -70,7 +67,7 @@ class TextStyle : public Style {
class TextValue : public Value { class TextValue : public Value {
public: public:
inline TextValue(const TextFieldP& field) : Value(field) {} inline TextValue(const TextFieldP& field) : Value(field) {}
HAS_FIELD(Text) DECLARE_HAS_FIELD(Text)
Defaultable<String> value; ///< The text of this value Defaultable<String> value; ///< The text of this value
......
...@@ -20,6 +20,8 @@ DECLARE_POINTER_TYPE(Game); ...@@ -20,6 +20,8 @@ DECLARE_POINTER_TYPE(Game);
class StyleSheet : public Packaged { class StyleSheet : public Packaged {
public: public:
GameP game; GameP game;
double card_width; ///< The width of a card in pixels
double card_height; ///< The height of a card in pixels
static String typeNameStatic(); static String typeNameStatic();
virtual String typeName() const; virtual String typeName() const;
......
//+----------------------------------------------------------------------------+
//| 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/control/card_viewer.hpp>
#include <data/stylesheet.hpp>
#include <wx/dcbuffer.h>
// ----------------------------------------------------------------------------- : CardViewer
CardViewer::CardViewer(Window* parent, int id, int style)
: wxControl(parent, id, wxDefaultPosition, wxDefaultSize, style)
{}
wxSize CardViewer::DoGetBestSize() const {
wxSize ws = GetSize(), cs = GetClientSize();
return wxSize(set->stylesheet->card_width, set->stylesheet->card_height) + ws - cs;
}
void CardViewer::onPaint(wxPaintEvent&) {
wxBufferedPaintDC dc(this);
dc.BeginDrawing();
draw(dc);
dc.EndDrawing();
}
// ----------------------------------------------------------------------------- : Event table
BEGIN_EVENT_TABLE(CardViewer, wxControl)
EVT_PAINT (CardViewer::onPaint)
END_EVENT_TABLE ()
//+----------------------------------------------------------------------------+
//| 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_CONTROL_CARD_VIEWER
#define HEADER_GUI_CONTROL_CARD_VIEWER
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <render/card/viewer.hpp>
// ----------------------------------------------------------------------------- : CardViewer
/// A control to view a single card
class CardViewer : public wxControl, public DataViewer {
public:
CardViewer(Window* parent, int id, int style);
protected:
/// Return the desired size of control
virtual wxSize DoGetBestSize() const;
private:
DECLARE_EVENT_TABLE();
void onPaint(wxPaintEvent&);
void onSize(wxSizeEvent&);
Bitmap buffer; /// < Off-screen buffer we draw to
};
// ----------------------------------------------------------------------------- : EOF
#endif
...@@ -42,10 +42,10 @@ bool MSE::OnInit() { ...@@ -42,10 +42,10 @@ bool MSE::OnInit() {
settings.read(); settings.read();
//Window* wnd = new SymbolWindow(nullptr); //Window* wnd = new SymbolWindow(nullptr);
//GameP g = Game::byName(_("magic")) //GameP g = Game::byName(_("magic"))
//SetP s = new_shared<Set>(); SetP s = new_shared<Set>();
//s->open(_("test.mse-set")); s->open(_("test.mse-set"));
//Window* wnd = new SetWindow(nullptr, s); Window* wnd = new SetWindow(nullptr, s);
Window* wnd = new WelcomeWindow(); //Window* wnd = new WelcomeWindow();
wnd->Show(); wnd->Show();
return true; return true;
......
...@@ -368,6 +368,12 @@ ...@@ -368,6 +368,12 @@
<File <File
RelativePath=".\gui\control\card_list.hpp"> RelativePath=".\gui\control\card_list.hpp">
</File> </File>
<File
RelativePath=".\gui\control\card_viewer.cpp">
</File>
<File
RelativePath=".\gui\control\card_viewer.hpp">
</File>
<File <File
RelativePath=".\gui\control\gallery_list.cpp"> RelativePath=".\gui\control\gallery_list.cpp">
</File> </File>
...@@ -567,6 +573,58 @@ ...@@ -567,6 +573,58 @@
RelativePath=".\gui\welcome_window.hpp"> RelativePath=".\gui\welcome_window.hpp">
</File> </File>
</Filter> </Filter>
<Filter
Name="value"
Filter="">
<File
RelativePath=".\gui\value\editor.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\gui\value\editor.hpp">
</File>
<File
RelativePath=".\gui\value\image.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\image.hpp">
</File>
</Filter>
</Filter> </Filter>
<Filter <Filter
Name="resource" Name="resource"
...@@ -1074,6 +1132,96 @@ ...@@ -1074,6 +1132,96 @@
RelativePath=".\script\value.hpp"> RelativePath=".\script\value.hpp">
</File> </File>
</Filter> </Filter>
<Filter
Name="render"
Filter="">
<Filter
Name="value"
Filter="">
<File
RelativePath=".\render\value\image.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\render\value\image.hpp">
</File>
<File
RelativePath=".\render\value\viewer.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=".\render\value\viewer.hpp">
</File>
</Filter>
<Filter
Name="card"
Filter="">
<File
RelativePath=".\render\card\viewer.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\render\card\viewer.hpp">
</File>
</Filter>
</Filter>
<File <File
RelativePath=".\code_template.cpp"> RelativePath=".\code_template.cpp">
<FileConfiguration <FileConfiguration
......
//+----------------------------------------------------------------------------+
//| 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 <render/card/viewer.hpp>
#include <data/field.hpp>
// ----------------------------------------------------------------------------- : DataViewer
// ----------------------------------------------------------------------------- : Drawing
void DataViewer::draw(DC& dc) {
}
void DataViewer::draw(RotatedDC& dc) {
}
// ----------------------------------------------------------------------------- : Utility for ValueViewers
bool DataViewer::nativeLook() const { return false; }
bool DataViewer::drawBorders() const { return false; }
wxPen DataViewer::borderPen(bool) const { return wxPen(); }
Value* DataViewer::focusedValue() const { return nullptr; }
// ----------------------------------------------------------------------------- : Setting data
// ----------------------------------------------------------------------------- : Viewers
ValueViewerP DataViewer::makeViewer(const StyleP& style) {
return style->makeViewer(*this, style);
}
void DataViewer::onAction(const Action&, bool undone) {
// TODO
}
//+----------------------------------------------------------------------------+
//| 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_RENDER_CARD_VIEWER
#define HEADER_RENDER_CARD_VIEWER
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <util/rotation.hpp>
#include <data/set.hpp>
DECLARE_POINTER_TYPE(Style);
DECLARE_POINTER_TYPE(ValueViewer);
// ----------------------------------------------------------------------------- : DataViewer
/// A viewer can generate an image of some values, usually a card.
class DataViewer : public SetView {
public:
/// Rotation and zoom to use when drawing
// Rotation rotation;
// --------------------------------------------------- : Drawing
/// Draw the current (card/data) to the given dc
void draw(DC& dc);
/// Draw the current (card/data) to the given dc
virtual void draw(RotatedDC& dc);
// --------------------------------------------------- : Utility for ValueViewers
/// Should the ValueViewers use a platform native look and feel?
/** false by default, can be overloaded */
virtual bool nativeLook() const;
/// Should field borders be drawn?
/** false by default, can be overloaded */
virtual bool drawBorders() const;
/// Pens for drawing field borders (only called if drawBorders())
virtual wxPen borderPen(bool active) const;
/// The value of the field that is currently focused, may be null
/** null by default, can be overloaded */
virtual Value* focusedValue() const;
// --------------------------------------------------- : Setting data
/// Display a card in this viewer
void setCard(Card& card);
// --------------------------------------------------- : The viewers
protected:
/// Set the styles for the data to be shown, recreating the viewers
void setStyles(IndexMap<FieldP,StyleP>& styles);
/// Set the data to be shown in the viewers, refresh them
void setData(IndexMap<FieldP,ValueP>& values);
/// Create a viewer for the given style.
/** Can be overloaded to create a ValueEditor instead */
virtual ValueViewerP makeViewer(const StyleP&);
/// Update the viewers and forward actions
virtual void onAction(const Action&, bool undone);
private:
vector<ValueViewerP> viewers; ///< The viewers for the different values in the data
};
// ----------------------------------------------------------------------------- : 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 <render/value/viewer.hpp>
// ----------------------------------------------------------------------------- : ValueViewer
// ----------------------------------------------------------------------------- : Development/debug
#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>
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(); }
ValueViewerP SymbolStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
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
//+----------------------------------------------------------------------------+
//| 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_RENDER_VALUE_VIEWER
#define HEADER_RENDER_VALUE_VIEWER
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <util/rotation.hpp>
#include <util/real_point.hpp>
class DataViewer;
class ValueAction;
DECLARE_POINTER_TYPE(Style);
DECLARE_POINTER_TYPE(Value);
// ----------------------------------------------------------------------------- : ValueViewer
/// The virtual viewer control for a single field on a card (or in the set data)
/** A viewer can only display a value, not edit it, ValueEditor is used for that */
class ValueViewer {
public:
/// Construct a ValueViewer, set the value at a later time
ValueViewer(DataViewer& parent, const StyleP& style);
virtual ~ValueViewer();
// Draw this value
virtual void draw(RotatedDC& dc) = 0;
/// Does this field contian the given point?
virtual bool containsPoint(const RealPoint& p) const;
/// Get a bounding rectangle for this field (including any border it may have)
virtual RealRect boundingBox() const;
/// Called when the associated value is changed
/** Both when we are associated with another value,
* and by default when the value itself changes (called from onAction)
*/
virtual void onValueChange() {}
/// Called when a (scripted) property of the associated style has changed
virtual void onStyleChange() {}
/// Called when an action is performed on the associated value
virtual void onAction(const ValueAction&, bool undone) { onValueChange(); }
/// Change the associated value
void setValue(const ValueP&);
protected:
DataViewer& viewer; ///< Our parent object
StyleP style_; ///< The style of this viewer
ValueP value_; ///< The value we are currently viewing
/// Should this viewer render using a platform native look?
bool nativeLook() const;
/// Is this the currently selected viewer?
/** Usually only the editor allows selection of viewers */
bool isCurrent() const;
/// Draws a border around the field
void drawFieldBorder(RotatedDC& dc);
};
// ----------------------------------------------------------------------------- : Utility
#define VALUE_VIEWER(Base, Type) \
public: \
Type(DataViewer& parent, const Type ## StyleP& style) \
private: \
inline Type##Style style() const { return *value_; } \
inline Type##Value value() const { return *value_; }
// ----------------------------------------------------------------------------- : EOF
#endif
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