Added ScriptableImage plus the beginnings of dependency stuff

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@58 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-29 16:23:31 +00:00
parent 368082ade2
commit f46b0b6b7b
22 changed files with 533 additions and 18 deletions
+1
View File
@@ -48,6 +48,7 @@ bool DataViewer::drawBorders() const { return false; }
bool DataViewer::drawEditing() const { return false; }
wxPen DataViewer::borderPen(bool) const { return wxPen(); }
ValueViewer* DataViewer::focusedViewer() const { return nullptr; }
Context& DataViewer::getContext() const { return set->getContext(); }
// ----------------------------------------------------------------------------- : Setting data
+3
View File
@@ -15,6 +15,7 @@
DECLARE_POINTER_TYPE(Style);
DECLARE_POINTER_TYPE(ValueViewer);
class Context;
// ----------------------------------------------------------------------------- : DataViewer
@@ -47,6 +48,8 @@ class DataViewer : public SetView {
/// The viewer that is currently focused, may be null
/** null by default, can be overloaded */
virtual ValueViewer* focusedViewer() const;
/// Get a script context to use for scripts in the viewers
Context& getContext() const;
// --------------------------------------------------- : Setting data
+40 -1
View File
@@ -7,5 +7,44 @@
// ----------------------------------------------------------------------------- : Includes
#include <render/value/choice.hpp>
#include <render/card/viewer.hpp>
// ----------------------------------------------------------------------------- :
// ----------------------------------------------------------------------------- : ChoiceValueViewer
void ChoiceValueViewer::draw(RotatedDC& dc) {
drawFieldBorder(dc);
if (value().value().empty()) return;
double margin = 0;
if (style().render_style & RENDER_IMAGE) {
// draw image
map<String,ScriptableImage>::iterator it = style().choice_images.find(value().value());
if (it != style().choice_images.end()) {
ScriptableImage& img = it->second;
ScriptImageP i;
if (nativeLook()) {
i = img.update(viewer.getContext(), 16, 16, ASPECT_BORDER, false);
} else if(style().render_style & RENDER_TEXT) {
// also drawing text
i = img.update(viewer.getContext(), 0, 0);
} else {
i = img.update(viewer.getContext(),
dc.trS(style().width), dc.trS(style().height),
style().alignment == ALIGN_STRETCH ? ASPECT_STRETCH : ASPECT_FIT
);
}
if (i) {
dc.DrawImage(i->image,
align_in_rect(style().alignment, RealSize(i->image.GetWidth(), i->image.GetHeight()), style().getRect()),
i->combine == COMBINE_NORMAL ? style().combine : i->combine
);
margin = i->image.GetWidth() + 1;
}
}
}
if (style().render_style & RENDER_TEXT) {
// draw text
dc.DrawText(capitalize(value().value()),
align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), style().getRect()) + RealSize(margin, 0)
);
}
}
+10 -1
View File
@@ -10,9 +10,18 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <render/value/viewer.hpp>
#include <data/field/choice.hpp>
// ----------------------------------------------------------------------------- :
// ----------------------------------------------------------------------------- : ChoiceValueViewer
/// Viewer that displays a choice value
class ChoiceValueViewer : public ValueViewer {
public:
DECLARE_VALUE_VIEWER(Choice) : ValueViewer(parent,style) {}
virtual void draw(RotatedDC& dc);
};
// ----------------------------------------------------------------------------- : EOF
#endif
+1 -1
View File
@@ -15,7 +15,7 @@
// ----------------------------------------------------------------------------- : ColorValueViewer
/// Viewer that displays an color value
/// Viewer that displays a color value
class ColorValueViewer : public ValueViewer {
public:
DECLARE_VALUE_VIEWER(Color) : ValueViewer(parent,style) {}
+1 -1
View File
@@ -76,7 +76,7 @@ class ValueViewer {
#define DECLARE_VALUE_VIEWER(Type) \
private: \
inline const Type##Style& style() const { return static_cast<const 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##Field& field() const { return style().field(); } \
public: \