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
@@ -14,6 +14,8 @@
#include <data/field.hpp>
DECLARE_TYPEOF_COLLECTION(ValueViewerP);
typedef IndexMap<FieldP,StyleP> IndexMap_FieldP_StyleP;
DECLARE_TYPEOF_NO_REV(IndexMap_FieldP_StyleP);
// ----------------------------------------------------------------------------- : DataViewer
@@ -21,16 +23,31 @@ DECLARE_TYPEOF_COLLECTION(ValueViewerP);
// ----------------------------------------------------------------------------- : Drawing
void DataViewer::draw(DC& dc) {
// RotatedDC rdc(dc, rotation, settings.styleSettingsFor(*style).cardAntiAlias && !nativeLook())
RotatedDC rdc(dc, 0, RealRect(0,0,400,400), 1.0, false);
draw(rdc);
}
void DataViewer::draw(RotatedDC& dc) {
if (!set) return; // no set specified, don't draw anything
// fill with background color
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(set->stylesheet->card_background);
dc.DrawRectangle(dc.getInternalRect());
// draw values
FOR_EACH(v, viewers) { // draw low z index fields first
if (v->getStyle()->visible) {// visible
v->draw(dc);
}
}
}
// ----------------------------------------------------------------------------- : Utility for ValueViewers
bool DataViewer::nativeLook() const { return false; }
bool DataViewer::drawBorders() const { return false; }
bool DataViewer::drawEditing() const { return false; }
wxPen DataViewer::borderPen(bool) const { return wxPen(); }
Value* DataViewer::focusedValue() const { return nullptr; }
ValueViewer* DataViewer::focusedViewer() const { return nullptr; }
// ----------------------------------------------------------------------------- : Setting data
@@ -42,7 +59,29 @@ void DataViewer::setCard(Card& card) {
// ----------------------------------------------------------------------------- : Viewers
struct CompareViewer {
bool operator() (const ValueViewerP& a, const ValueViewerP& b) {
return a->getStyle()->z_index < b->getStyle()->z_index;
}
};
void DataViewer::setStyles(IndexMap<FieldP,StyleP>& styles) {
if (!viewers.empty() && styles.contains(viewers.front()->getStyle())) {
// already using these styles
return;
}
// create viewers
viewers.clear();
FOR_EACH(s, styles) {
if (s->visible || s->visible.isScripted()) {
// no need to make a viewer for things that are always invisible
viewers.push_back(makeViewer(s));
// REMOVEME //TODO //%%%
if (!viewers.back()) viewers.pop_back();
}
}
// sort viewers by z-index of style
stable_sort(viewers.begin(), viewers.end(), CompareViewer());
}
void DataViewer::setData(IndexMap<FieldP,ValueP>& values) {