mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Added ValueViewer,DataViewer,CardViewer and made related changes
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@49 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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
|
||||
@@ -0,0 +1,45 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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
|
||||
@@ -0,0 +1,78 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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
|
||||
Reference in New Issue
Block a user