Reduce coupling between ValueEditors/Viewers and Set and StyleSheet.

- Adding of actions is done with an addAction function
 - Files are read from
     - getStylePackage for styling stuff (this is stylesheet)
     - getLocalPackage for symbol and image values (this was the set)


git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@970 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-06-04 00:21:06 +00:00
parent 6b0a0fd098
commit ae14784fd6
50 changed files with 413 additions and 184 deletions
+4 -7
View File
@@ -11,7 +11,6 @@
#include <gui/util.hpp>
#include <gui/thumbnail_thread.hpp>
#include <data/action/value.hpp>
#include <data/stylesheet.hpp>
#include <script/image.hpp>
#include <wx/imaglist.h>
@@ -28,7 +27,6 @@ class ChoiceThumbnailRequest : public ThumbnailRequest {
bool isThreadSafe;
virtual bool threadSafe() const {return isThreadSafe;}
private:
StyleSheetP stylesheet;
int id;
inline ChoiceStyle& style() { return *static_cast<ChoiceStyle*>(viewer().getStyle().get()); }
@@ -38,12 +36,11 @@ class ChoiceThumbnailRequest : public ThumbnailRequest {
ChoiceThumbnailRequest::ChoiceThumbnailRequest(ValueViewer* viewer, int id, bool from_disk, bool thread_safe)
: ThumbnailRequest(
static_cast<void*>(viewer),
viewer->viewer.stylesheet->name() + _("/") + viewer->getField()->name + _("/") << id,
from_disk ? viewer->viewer.stylesheet->lastModified()
viewer->getStylePackage().name() + _("/") + viewer->getField()->name + _("/") << id,
from_disk ? viewer->getStylePackage().lastModified()
: wxDateTime::Now()
)
, isThreadSafe(thread_safe)
, stylesheet(viewer->viewer.stylesheet)
, id(id)
{}
@@ -52,7 +49,7 @@ Image ChoiceThumbnailRequest::generate() {
String name = cannocial_name_form(s.field().choices->choiceName(id));
ScriptableImage& img = s.choice_images[name];
return img.isReady()
? img.generate(GeneratedImage::Options(16,16, stylesheet.get(), viewer().viewer.getSet().get(), ASPECT_BORDER, true))
? img.generate(GeneratedImage::Options(16,16, &viewer().getStylePackage(), &viewer().getLocalPackage(), ASPECT_BORDER, true))
: wxImage();
}
@@ -308,5 +305,5 @@ void ChoiceValueEditor::determineSize(bool) {
}
void ChoiceValueEditor::change(const Defaultable<String>& c) {
perform(value_action(card(), valueP(), c));
addAction(value_action(valueP(), c));
}