Added dummy CardEditor, implemented Stylesheet loading

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@50 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-26 22:46:28 +00:00
parent c8e8dd0220
commit 1459cd6d76
23 changed files with 252 additions and 42 deletions
+21
View File
@@ -7,8 +7,14 @@
// ----------------------------------------------------------------------------- : Includes
#include <render/card/viewer.hpp>
#include <render/value/viewer.hpp>
#include <data/set.hpp>
#include <data/stylesheet.hpp>
#include <data/card.hpp>
#include <data/field.hpp>
DECLARE_TYPEOF_COLLECTION(ValueViewerP);
// ----------------------------------------------------------------------------- : DataViewer
@@ -28,9 +34,24 @@ Value* DataViewer::focusedValue() const { return nullptr; }
// ----------------------------------------------------------------------------- : Setting data
void DataViewer::setCard(Card& card) {
assert(set);
setStyles(set->stylesheet->card_style);
setData(card.data);
}
// ----------------------------------------------------------------------------- : Viewers
void DataViewer::setStyles(IndexMap<FieldP,StyleP>& styles) {
}
void DataViewer::setData(IndexMap<FieldP,ValueP>& values) {
FOR_EACH(v, viewers) {
v->setValue(values[v->getField()]);
}
}
ValueViewerP DataViewer::makeViewer(const StyleP& style) {
return style->makeViewer(*this, style);
}
+5
View File
@@ -10,6 +10,11 @@
// ----------------------------------------------------------------------------- : ValueViewer
void ValueViewer::setValue(const ValueP& value) {
assert(value->fieldP == styleP->fieldP); // matching field
valueP = value;
onValueChange();
}
// ----------------------------------------------------------------------------- : Development/debug
+12 -8
View File
@@ -12,6 +12,7 @@
#include <util/prec.hpp>
#include <util/rotation.hpp>
#include <util/real_point.hpp>
#include <data/field.hpp>
class DataViewer;
class ValueAction;
@@ -26,7 +27,12 @@ class ValueViewer {
public:
/// Construct a ValueViewer, set the value at a later time
ValueViewer(DataViewer& parent, const StyleP& style);
virtual ~ValueViewer();
virtual ~ValueViewer() {}
/// Change the associated value
void setValue(const ValueP&);
/// Return the associated field
inline const FieldP& getField() const { return styleP->fieldP; }
// Draw this value
virtual void draw(RotatedDC& dc) = 0;
@@ -46,13 +52,10 @@ class ValueViewer {
/// 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
StyleP styleP; ///< The style of this viewer
ValueP valueP; ///< The value we are currently viewing
/// Should this viewer render using a platform native look?
bool nativeLook() const;
@@ -70,8 +73,9 @@ class ValueViewer {
public: \
Type(DataViewer& parent, const Type ## StyleP& style) \
private: \
inline Type##Style style() const { return *value_; } \
inline Type##Value value() const { return *value_; }
inline Type##Style& style() const { return *styleP; } \
inline Type##Value& value() const { return *valueP; } \
inline Type##Field& field() const { return styleP->field(); }
// ----------------------------------------------------------------------------- : EOF