Implemented ImageValueViewer, and more of the related classes

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@54 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-27 22:10:09 +00:00
parent d9c9c40adf
commit 7192361c36
35 changed files with 485 additions and 37 deletions
+40 -1
View File
@@ -7,15 +7,47 @@
// ----------------------------------------------------------------------------- : Includes
#include <render/value/viewer.hpp>
#include <render/value/text.hpp>
#include <render/value/choice.hpp>
#include <render/value/multiple_choice.hpp>
#include <render/value/boolean.hpp>
#include <render/value/image.hpp>
#include <render/value/symbol.hpp>
#include <render/value/color.hpp>
#include <render/card/viewer.hpp>
// ----------------------------------------------------------------------------- : ValueViewer
ValueViewer::ValueViewer(DataViewer& parent, const StyleP& style)
: viewer(parent), styleP(style)
{}
Set& ValueViewer::getSet() const { return *viewer.getSet(); }
void ValueViewer::setValue(const ValueP& value) {
assert(value->fieldP == styleP->fieldP); // matching field
valueP = value;
onValueChange();
}
bool ValueViewer::containsPoint(const RealPoint& p) const {
return p.x >= styleP->left
&& p.y >= styleP->top
&& p.x < styleP->left + (int)(styleP->width)
&& p.y < styleP->top + (int)(styleP->height);
}
RealRect ValueViewer::boundingBox() const {
return styleP->getRect().grow(1);
}
void ValueViewer::drawFieldBorder(RotatedDC& dc) {
if (viewer.drawBorders() && getField()->editable) {
dc.SetPen(viewer.borderPen(viewer.focusedViewer() == this));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRectangle(styleP->getRect().grow(dc.trInvS(1)));
}
}
// ----------------------------------------------------------------------------- : Development/debug
#ifdef _DEBUG
@@ -31,11 +63,18 @@ void ValueViewer::setValue(const ValueP& value) {
#include <data/field/symbol.hpp>
#include <data/field/text.hpp>
#define IMPLEMENT_MAKE_VIEWER(Type) \
ValueViewerP Type##Style::makeViewer(DataViewer& parent, const StyleP& thisP) { \
assert(thisP.get() == this); \
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(); }
//ValueViewerP ImageStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
IMPLEMENT_MAKE_VIEWER(Image);
ValueViewerP SymbolStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }
ValueViewerP TextStyle ::makeViewer(DataViewer& parent, const StyleP& thisP) { return ValueViewerP(); }