From 275f7154634a8ff0ac7dae1901d8bc0ed510918b Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 27 Oct 2006 22:55:40 +0000 Subject: [PATCH] ImageValueViewer now works and the viewer control is refreshed git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@55 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/gui/control/card_viewer.cpp | 4 ++++ src/gui/control/card_viewer.hpp | 2 ++ src/render/card/viewer.cpp | 1 + src/render/card/viewer.hpp | 3 +++ src/script/scriptable.hpp | 4 ++-- src/util/string.cpp | 2 +- 6 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gui/control/card_viewer.cpp b/src/gui/control/card_viewer.cpp index 4846585a..2ec56109 100644 --- a/src/gui/control/card_viewer.cpp +++ b/src/gui/control/card_viewer.cpp @@ -25,6 +25,10 @@ wxSize CardViewer::DoGetBestSize() const { } } +void CardViewer::onChange() { + Refresh(false); +} + void CardViewer::onPaint(wxPaintEvent&) { wxBufferedPaintDC dc(this); dc.BeginDrawing(); diff --git a/src/gui/control/card_viewer.hpp b/src/gui/control/card_viewer.hpp index 6ff329fd..58210961 100644 --- a/src/gui/control/card_viewer.hpp +++ b/src/gui/control/card_viewer.hpp @@ -23,6 +23,8 @@ class CardViewer : public wxControl, public DataViewer { /// Return the desired size of control virtual wxSize DoGetBestSize() const; + virtual void onChange(); + private: DECLARE_EVENT_TABLE(); diff --git a/src/render/card/viewer.cpp b/src/render/card/viewer.cpp index e939c4f8..4342ac3d 100644 --- a/src/render/card/viewer.cpp +++ b/src/render/card/viewer.cpp @@ -88,6 +88,7 @@ void DataViewer::setData(IndexMap& values) { FOR_EACH(v, viewers) { v->setValue(values[v->getField()]); } + onChange(); } diff --git a/src/render/card/viewer.hpp b/src/render/card/viewer.hpp index ce880941..f87e56d9 100644 --- a/src/render/card/viewer.hpp +++ b/src/render/card/viewer.hpp @@ -67,6 +67,9 @@ class DataViewer : public SetView { /// Update the viewers and forward actions virtual void onAction(const Action&, bool undone); + /// Notification that the total image has changed + virtual void onChange() {} + private: vector viewers; ///< The viewers for the different values in the data }; diff --git a/src/script/scriptable.hpp b/src/script/scriptable.hpp index fdbdfb1a..2308cdba 100644 --- a/src/script/scriptable.hpp +++ b/src/script/scriptable.hpp @@ -84,8 +84,8 @@ class Scriptable { } private: + T value; ///< The actual value OptionalScript script; ///< The optional script - T value; ///< The scripted value DECLARE_REFLECTION(); }; @@ -100,7 +100,7 @@ void Reader::handle(Scriptable& s) { s.script.unparsed = s.script.unparsed.substr(7); s.script.parse(*this); } else { - handle(value); + handle(s.value); } } template diff --git a/src/util/string.cpp b/src/util/string.cpp index b5cb4762..f29ca99d 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -53,7 +53,7 @@ String trim(const String& s){ } String trim_left(const String& s) { - size_t start = s.find_first_not_of(_(' ')); + size_t start = s.find_first_not_of(_(" \t")); if (start == String::npos) { return String(); } else {