From 0a916f89bc3ea3baf417585d881a4388dbafdb7c Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 24 Nov 2006 16:36:17 +0000 Subject: [PATCH] Added value actions for common value types; drop down list is now correctly aligned git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@92 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/action/value.cpp | 62 ++++++++++++++ src/data/action/value.hpp | 72 +++++++++++++++++ src/data/field/choice.hpp | 3 +- src/data/field/color.hpp | 3 +- src/data/field/image.hpp | 3 +- src/data/field/symbol.hpp | 3 +- src/data/field/text.hpp | 3 +- src/gfx/color.cpp | 10 +++ src/gfx/gfx.hpp | 3 + src/gui/control/card_viewer.cpp | 6 +- src/gui/control/card_viewer.hpp | 1 - src/gui/control/gallery_list.cpp | 2 +- src/gui/control/native_look_editor.cpp | 6 +- src/gui/control/native_look_editor.hpp | 1 + src/gui/drop_down_list.cpp | 107 ++++++++++++------------- src/gui/drop_down_list.hpp | 3 + src/gui/set/window.cpp | 1 + src/gui/value/color.cpp | 3 +- src/gui/value/editor.hpp | 2 +- src/mse.vcproj | 30 +++++++ src/render/card/viewer.cpp | 6 ++ src/render/card/viewer.hpp | 2 + src/render/value/viewer.hpp | 2 +- 23 files changed, 268 insertions(+), 66 deletions(-) create mode 100644 src/data/action/value.cpp create mode 100644 src/data/action/value.hpp diff --git a/src/data/action/value.cpp b/src/data/action/value.cpp new file mode 100644 index 00000000..f5d053ec --- /dev/null +++ b/src/data/action/value.cpp @@ -0,0 +1,62 @@ +//+----------------------------------------------------------------------------+ +//| Description: Magic Set Editor - Program to make Magic (tm) cards | +//| Copyright: (C) 2001 - 2006 Twan van Laarhoven | +//| License: GNU General Public License 2 or later (see file COPYING) | +//+----------------------------------------------------------------------------+ + +// ----------------------------------------------------------------------------- : Includes + +#include +#include +#include +#include +#include +#include +#include +#include + +// ----------------------------------------------------------------------------- : ValueAction + +String ValueAction::getName(bool to_undo) const { + return _("Change ") + valueP->fieldP->name; +} + +// ----------------------------------------------------------------------------- : Simple + +/// A ValueAction that swaps between old and new values +template +class SimpleValueAction : public ValueAction { + public: + inline SimpleValueAction(const shared_ptr& value, const typename T::ValueType& new_value) + : ValueAction(value), new_value(new_value) + {} + + virtual void perform(bool to_undo) { + swap(static_cast(*valueP).*member, new_value); + } + + virtual bool merge(const Action* action) { + if (!ALLOW_MERGE) return false; + if (const SimpleValueAction* sva = dynamic_cast(action)) { + if (sva->valueP == valueP) { + // adjacent actions on the same value, discard the other one, + // because it only keeps an intermediate value + return true; + } + } else { + return false; + } + return false; + } + + private: + typename T::ValueType new_value; +}; + +ValueAction* value_action(const ChoiceValueP& value, const Defaultable& new_value) { return new SimpleValueAction (value, new_value); } +ValueAction* value_action(const ColorValueP& value, const Defaultable& new_value) { return new SimpleValueAction (value, new_value); } +ValueAction* value_action(const ImageValueP& value, const FileName& new_value) { return new SimpleValueAction(value, new_value); } +ValueAction* value_action(const SymbolValueP& value, const FileName& new_value) { return new SimpleValueAction(value, new_value); } + + +// ----------------------------------------------------------------------------- : Text diff --git a/src/data/action/value.hpp b/src/data/action/value.hpp new file mode 100644 index 00000000..10b87ef5 --- /dev/null +++ b/src/data/action/value.hpp @@ -0,0 +1,72 @@ +//+----------------------------------------------------------------------------+ +//| Description: Magic Set Editor - Program to make Magic (tm) cards | +//| Copyright: (C) 2001 - 2006 Twan van Laarhoven | +//| License: GNU General Public License 2 or later (see file COPYING) | +//+----------------------------------------------------------------------------+ + +#ifndef HEADER_DATA_ACTION_VALUE +#define HEADER_DATA_ACTION_VALUE + +/** @file data/action/set.hpp + * + * Actions operating on Values (and derived classes, "*Value") + */ + +// ----------------------------------------------------------------------------- : Includes + +#include +#include +#include + +DECLARE_POINTER_TYPE(Value); +DECLARE_POINTER_TYPE(TextValue); +DECLARE_POINTER_TYPE(ChoiceValue); +DECLARE_POINTER_TYPE(ColorValue); +DECLARE_POINTER_TYPE(ImageValue); +DECLARE_POINTER_TYPE(SymbolValue); + +// ----------------------------------------------------------------------------- : ValueAction (based class) + +/// An Action the changes a Value +class ValueAction : public Action { + public: + inline ValueAction(const ValueP& value) : valueP(value) {} + + virtual String getName(bool to_undo) const; + + const ValueP valueP; ///< The modified value +}; + +/// Utility macro for declaring classes derived from ValueAction +#define DECLARE_VALUE_ACTION(Type) \ + protected: \ + inline Type##Value& value() const { \ + return static_cast(*valueP); \ + } \ + public: \ + virtual void perform(bool to_undo) + + +// ----------------------------------------------------------------------------- : Simple + +ValueAction* value_action(const ChoiceValueP& value, const Defaultable& new_value); +ValueAction* value_action(const ColorValueP& value, const Defaultable& new_value); +ValueAction* value_action(const ImageValueP& value, const FileName& new_value); +ValueAction* value_action(const SymbolValueP& value, const FileName& new_value); + +// ----------------------------------------------------------------------------- : Text + +/* +class ColorValueAction : public ValueAction { + public: + ColorValueAction(const ColorValueP& value, const Defaultable& color); + + DECLARE_VALUE_ACTION(Color); + + private: + Defaultable color; ///< The new/old color +}; +*/ + +// ----------------------------------------------------------------------------- : EOF +#endif diff --git a/src/data/field/choice.hpp b/src/data/field/choice.hpp index 682f90bc..0f99c81c 100644 --- a/src/data/field/choice.hpp +++ b/src/data/field/choice.hpp @@ -143,7 +143,8 @@ class ChoiceValue : public Value { {} DECLARE_HAS_FIELD(Choice) - Defaultable value; /// The name of the selected choice + typedef Defaultable ValueType; + ValueType value; /// The name of the selected choice virtual String toString() const; virtual bool update(Context&); diff --git a/src/data/field/color.hpp b/src/data/field/color.hpp index af4ca2df..37ed4f38 100644 --- a/src/data/field/color.hpp +++ b/src/data/field/color.hpp @@ -76,7 +76,8 @@ class ColorValue : public Value { inline ColorValue(const ColorFieldP& field) : Value(field) {} DECLARE_HAS_FIELD(Color) - Defaultable value; ///< The value + typedef Defaultable ValueType; + ValueType value; ///< The value virtual String toString() const; virtual bool update(Context&); diff --git a/src/data/field/image.hpp b/src/data/field/image.hpp index 0212c254..2f96c1c2 100644 --- a/src/data/field/image.hpp +++ b/src/data/field/image.hpp @@ -50,7 +50,8 @@ class ImageValue : public Value { public: inline ImageValue(const ImageFieldP& field) : Value(field) {} - FileName filename; ///< Filename of the image (in the current package), or "" + typedef FileName ValueType; + ValueType filename; ///< Filename of the image (in the current package), or "" virtual String toString() const; diff --git a/src/data/field/symbol.hpp b/src/data/field/symbol.hpp index f57a42ec..27d97e19 100644 --- a/src/data/field/symbol.hpp +++ b/src/data/field/symbol.hpp @@ -65,7 +65,8 @@ class SymbolValue : public Value { inline SymbolValue(const SymbolFieldP& field) : Value(field) {} DECLARE_HAS_FIELD(Symbol) - FileName filename; ///< Filename of the symbol (in the current package) + typedef FileName ValueType; + ValueType filename; ///< Filename of the symbol (in the current package) virtual String toString() const; diff --git a/src/data/field/text.hpp b/src/data/field/text.hpp index d990794e..2864f1fa 100644 --- a/src/data/field/text.hpp +++ b/src/data/field/text.hpp @@ -80,7 +80,8 @@ class TextValue : public Value { inline TextValue(const TextFieldP& field) : Value(field) {} DECLARE_HAS_FIELD(Text) - Defaultable value; ///< The text of this value + typedef Defaultable ValueType; + ValueType value; ///< The text of this value virtual String toString() const; virtual bool update(Context&); diff --git a/src/gfx/color.cpp b/src/gfx/color.cpp index 1f56393f..3da043c6 100644 --- a/src/gfx/color.cpp +++ b/src/gfx/color.cpp @@ -46,3 +46,13 @@ Color darken(const Color& c) { c.Blue() * 8 / 10 ); } + +Color saturate(const Color& c, double amount) { + int r = c.Red(), g = c.Green(), b = c.Blue(); + double l = (r + g + b) / 3; + return Color( + col((r - amount * l) / (1 - amount)), + col((g - amount * l) / (1 - amount)), + col((b - amount * l) / (1 - amount)) + ); +} diff --git a/src/gfx/gfx.hpp b/src/gfx/gfx.hpp index 7b1445c4..cf355697 100644 --- a/src/gfx/gfx.hpp +++ b/src/gfx/gfx.hpp @@ -169,5 +169,8 @@ Color hsl2rgb(double h, double s, double l); /// A darker version of a color Color darken(const Color& c); +/// A saturated version of a color +Color saturate(const Color& c, double amount); + // ----------------------------------------------------------------------------- : EOF #endif diff --git a/src/gui/control/card_viewer.cpp b/src/gui/control/card_viewer.cpp index 9f80c571..8cea4f30 100644 --- a/src/gui/control/card_viewer.cpp +++ b/src/gui/control/card_viewer.cpp @@ -32,7 +32,11 @@ void CardViewer::onChange() { } void CardViewer::onPaint(wxPaintEvent&) { - wxBufferedPaintDC dc(this); + wxSize cs = GetClientSize(); + if (!buffer.Ok() || buffer.GetWidth() != cs.GetWidth() || buffer.GetHeight() != cs.GetHeight()) { + buffer = Bitmap(cs.GetWidth(), cs.GetHeight()); + } + wxBufferedPaintDC dc(this, buffer); dc.BeginDrawing(); draw(dc); dc.EndDrawing(); diff --git a/src/gui/control/card_viewer.hpp b/src/gui/control/card_viewer.hpp index 58210961..32a63bca 100644 --- a/src/gui/control/card_viewer.hpp +++ b/src/gui/control/card_viewer.hpp @@ -29,7 +29,6 @@ class CardViewer : public wxControl, public DataViewer { DECLARE_EVENT_TABLE(); void onPaint(wxPaintEvent&); - void onSize(wxSizeEvent&); Bitmap buffer; /// < Off-screen buffer we draw to }; diff --git a/src/gui/control/gallery_list.cpp b/src/gui/control/gallery_list.cpp index 72819273..9a7ced0d 100644 --- a/src/gui/control/gallery_list.cpp +++ b/src/gui/control/gallery_list.cpp @@ -159,7 +159,7 @@ void GalleryList::OnDraw(DC& dc) { bool selected = i == selection; Color c = selected ? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT) : unselected; dc.SetPen(c); - dc.SetBrush(lerp(background, c, 0.3)); + dc.SetBrush(saturate(lerp(background, c, 0.3), selected ? 0.5 : 0)); RealPoint pos = itemPos(i); dc.DrawRectangle(pos.x - BORDER, pos.y - BORDER, item_size.width + 2*BORDER, item_size.height + 2*BORDER); // draw item diff --git a/src/gui/control/native_look_editor.cpp b/src/gui/control/native_look_editor.cpp index dc7307f3..37d75ae5 100644 --- a/src/gui/control/native_look_editor.cpp +++ b/src/gui/control/native_look_editor.cpp @@ -21,8 +21,12 @@ NativeLookEditor::NativeLookEditor(Window* parent, int id, long style) : DataEditor(parent, id, style) {} +Rotation NativeLookEditor::getRotation() const { + return Rotation(0, RealRect(RealPoint(0,0),GetClientSize())); +} + void NativeLookEditor::draw(DC& dc) { - RotatedDC rdc(dc, 0, RealRect(RealPoint(0,0),GetClientSize()), 1, 0); + RotatedDC rdc(dc, getRotation(), false); DataViewer::draw(rdc, wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); } void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) { diff --git a/src/gui/control/native_look_editor.hpp b/src/gui/control/native_look_editor.hpp index 87ab7c2e..3b319d72 100644 --- a/src/gui/control/native_look_editor.hpp +++ b/src/gui/control/native_look_editor.hpp @@ -22,6 +22,7 @@ class NativeLookEditor : public DataEditor { /// Uses a native look virtual bool nativeLook() const { return true; } virtual bool drawBorders() const { return false; } + virtual Rotation getRotation() const; virtual void draw(DC& dc); virtual void drawViewer(RotatedDC& dc, ValueViewer& v); diff --git a/src/gui/drop_down_list.cpp b/src/gui/drop_down_list.cpp index 16b2c99f..48b11e82 100644 --- a/src/gui/drop_down_list.cpp +++ b/src/gui/drop_down_list.cpp @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include @@ -23,38 +25,31 @@ class DropDownHider : public wxEvtHandler { DropDownList& list; virtual bool ProcessEvent(wxEvent& ev) { - // close the list, and pass on the event - // don't just use ev.Skip(), because this event handler will be removed by hiding, - // so there will be no next handler to skip to - wxEvtHandler* nh = GetNextHandler(); - list.hide(false); - if (nh) nh->ProcessEvent(ev); + int t = ev.GetEventType(); + if ( t == wxEVT_LEFT_DOWN || t == wxEVT_RIGHT_DOWN + || t == wxEVT_MOVE || t == wxEVT_SIZE + || t == wxEVT_MENU_HIGHLIGHT || t == wxEVT_MENU_OPEN || t == wxEVT_MENU_OPEN + || t == wxEVT_ACTIVATE || t == wxEVT_CLOSE_WINDOW || t == wxEVT_KILL_FOCUS + || t == wxEVT_COMMAND_TOOL_CLICKED) + { + // close the list, and pass on the event + // don't just use ev.Skip(), because this event handler will be removed by hiding, + // so there will be no next handler to skip to + wxEvtHandler* nh = GetNextHandler(); + list.hide(false); + if (nh) nh->ProcessEvent(ev); + return false; + } else { +// if (t !=10093 && t !=10098 && t !=10097 && t !=10099 && t !=10004 && t !=10062 +// && t !=10025 && t !=10035 && t !=10034 && t !=10036 && t !=10042 && t !=10119) +// { +// t=t;//DEBUG +// } + return wxEvtHandler::ProcessEvent(ev); + } } }; -/*BEGIN_EVENT_TABLE(DropDownHider, wxEvtHandler) - EVT_CUSTOM(wxEVT_LEFT_DOWN, wxID_ANY, DropDownHider::onEvent) - EVT_CUSTOM(wxEVT_RIGHT_DOWN, wxID_ANY, DropDownHider::onEvent) - EVT_CUSTOM(wxEVT_MOVE, wxID_ANY, DropDownHider::onEvent) - EVT_CUSTOM(wxEVT_SIZE, wxID_ANY, DropDownHider::onEvent) - EVT_CUSTOM(wxEVT_MENU_HIGHLIGHT, wxID_ANY, DropDownHider::onEvent) - EVT_CUSTOM(wxEVT_MENU, wxID_ANY, DropDownHider::onEvent) - EVT_CUSTOM(wxEVT_MENU_OPEN, wxID_ANY, DropDownHider::onEvent) - EVT_CUSTOM(wxEVT_ACTIVATE, wxID_ANY, DropDownHider::onEvent) -// EVT_CUSTOM(wxEVT_CLOSE, wxID_ANY, DropDownHider::onEvent) - EVT_CUSTOM(wxEVT_KILL_FOCUS, wxID_ANY, DropDownHider::onEvent) -/* EVT_LEFT_DOWN ( (wxMouseEventFunction)&DropDownHider::onEvent) - EVT_RIGHT_DOWN ( DropDownHider::onMouseEvent) - EVT_MOVE ( DropDownHider::onMoveEvent) - EVT_SIZE ( DropDownHider::onSizeEvent) - EVT_MENU_HIGHLIGHT (wxID_ANY, DropDownHider::onMenuEvent) - EVT_MENU (wxID_ANY, DropDownHider::onCommandEvent) - EVT_MENU_OPEN ( DropDownHider::onMenuEvent) - EVT_ACTIVATE ( DropDownHider::onActivateEvent) - EVT_CLOSE ( DropDownHider::onCloseEvent) - EVT_KILL_FOCUS ( DropDownHider::onFocusEvent) -END_EVENT_TABLE () -*/ // ----------------------------------------------------------------------------- : DropDownList : Show/Hide @@ -64,6 +59,7 @@ DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer) , selected_item(NO_SELECTION) , open_sub_menu(nullptr) , parent_menu(is_submenu ? static_cast(GetParent()) : nullptr) + , hider(is_submenu ? nullptr : new DropDownHider(*this)) , viewer(viewer) , item_size(100,1) { @@ -75,6 +71,10 @@ DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer) item_size.height = h; } +DropDownList::~DropDownList() { + delete hider; +} + void DropDownList::show(bool in_place, wxPoint pos) { if (IsShown()) return; // find selection @@ -83,40 +83,38 @@ void DropDownList::show(bool in_place, wxPoint pos) { int line_count = 0; size_t count = itemCount(); for (size_t i = 0 ; i < count ; ++i) if (lineBelow(i)) line_count += 1; - wxSize size( + RealSize size( item_size.width + marginW * 2, item_size.height * count + marginH * 2 + line_count ); int parent_height = 0; - /*if (!in_place) { + if (!in_place && viewer) { // Position the drop down list below the editor control (based on the style) - RotatedObject rot(editor.rotation); - Rect r = rot.trNoNeg(style->rect); - if (editor.nativeLook()) { - pos = Point(r.left - 3, r.top - 3); - size.width = max(size.width, r.width + 6); - editorHeight = r.height + 6; + RealRect r = viewer->viewer.getRotation().trNoNeg(viewer->getStyle()->getRect()); + if (viewer->viewer.nativeLook()) { + pos = wxPoint(r.x - 3, r.y - 3); + size.width = max(size.width, r.width + 6); + parent_height = r.height + 6; } else { - pos = Point(r.left - 1, r.top - 1); - size.width = max(size.width, r.width + 2); - editorHeight = r.height; + pos = wxPoint(r.x - 1, r.y - 1); + size.width = max(size.width, r.width + 2); + parent_height = r.height; } } else if (parent_menu) { - parent_height = -item_height - 1; + parent_height = -item_size.height - 1; } - */ + pos = GetParent()->ClientToScreen(pos); // move & resize - item_size.width = size.GetWidth() - marginW * 2; + item_size.width = size.width - marginW * 2; SetSize(size); Position(pos, wxSize(0, parent_height)); // set event handler - if (!parent_menu) { -// Window* parent = wxGetTopLevelParent(this); -// parent->PushEventHandler(&hider); + if (hider) { + Window* parent = wxGetTopLevelParent(GetParent()); + parent->PushEventHandler(hider); } // show // oldSelectedItem = selectedItem; - if (selected_item == NO_SELECTION && itemCount() > 0) selected_item = 0; // select first item by default mouse_down = false; Window::Show(); @@ -143,10 +141,10 @@ void DropDownList::realHide() { if (parent_menu) { parent_menu->open_sub_menu = 0; } else { -// redrawDropDownArrowOnParent(); + redrawArrowOnParent(); // disconnect event handler -// Window* parent = getTopLevelParent(&editor); -// parent->RemoveEventHandler(&hider); + Window* parent = wxGetTopLevelParent(GetParent()); + parent->RemoveEventHandler(hider); } } @@ -306,7 +304,7 @@ void DropDownList::onCharInParent(wxKeyEvent& ev) { } else { switch (k) { case WXK_UP: - if (selected_item - 1 >= 0) { + if (selected_item > 0) { selected_item -= 1; Refresh(false); } @@ -332,11 +330,12 @@ void DropDownList::onCharInParent(wxKeyEvent& ev) { // match first character of an item, start searching just after the current selection size_t si = selected_item != NO_SELECTION ? selected_item + 1 : 0; size_t count = itemCount(); - for (size_t i = si ; i < count + si ; ++i) { - String c = itemText(i); + for (size_t i = 0 ; i < count ; ++i) { + size_t index = (si + i) % count; + String c = itemText(index); if (!c.empty() && toUpper(c.GetChar(0)) == toUpper(ev.GetUnicodeKey())) { // first character matches - selected_item = i; + selected_item = index; showSubMenu(); Refresh(false); return; diff --git a/src/gui/drop_down_list.hpp b/src/gui/drop_down_list.hpp index ab9384b0..fee013c2 100644 --- a/src/gui/drop_down_list.hpp +++ b/src/gui/drop_down_list.hpp @@ -14,6 +14,7 @@ #include // undocumented: wxPopupWindow class ValueViewer; +class DropDownHider; // ----------------------------------------------------------------------------- : DropDownList @@ -21,6 +22,7 @@ class ValueViewer; /** This class is an abstract base for various drop down lists */ class DropDownList : public wxPopupWindow { public: + ~DropDownList(); /// Create a drop down list, possibly a sub menu /** the viewer will be notified to redraw its drop down icon */ DropDownList(Window* parent, bool is_submenu = false, ValueViewer* viewer = nullptr); @@ -78,6 +80,7 @@ class DropDownList : public wxPopupWindow { DropDownList* open_sub_menu; ///< The sub menu that is currently shown, if any DropDownList* parent_menu; ///< The parent menu, only applies to sub menus ValueViewer* viewer; ///< The parent viewer object (optional) + DropDownHider* hider; ///< Class to hide this window when we lose focus // --------------------------------------------------- : Events DECLARE_EVENT_TABLE(); diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index 23549894..5642a0a2 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -96,6 +96,7 @@ SetWindow::SetWindow(Window* parent, const SetP& set) // tool bar wxToolBar* tb = CreateToolBar(wxTB_FLAT | wxNO_BORDER | wxTB_HORIZONTAL); + tb->SetToolBitmapSize(wxSize(18,18)); tb->AddTool(ID_FILE_NEW, _(""), Bitmap(_("TOOL_NEW")), wxNullBitmap, wxITEM_NORMAL, _("New set"), _("Creates a new set")); tb->AddTool(ID_FILE_OPEN, _(""), Bitmap(_("TOOL_OPEN")), wxNullBitmap, wxITEM_NORMAL, _("Open set"), _("Opens an existing set")); tb->AddTool(ID_FILE_SAVE, _(""), Bitmap(_("TOOL_SAVE")), wxNullBitmap, wxITEM_NORMAL, _("Save set"), _("Saves the current set")); diff --git a/src/gui/value/color.cpp b/src/gui/value/color.cpp index c13a728c..fa9bb876 100644 --- a/src/gui/value/color.cpp +++ b/src/gui/value/color.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include DECLARE_TYPEOF_COLLECTION(ColorField::ChoiceP); @@ -141,7 +142,7 @@ void ColorValueEditor::determineSize() { } void ColorValueEditor::change(const Defaultable& c) { -// getSet().actions.add(new ColorChangeAction(value(), c)); + getSet().actions.add(value_action(static_pointer_cast(valueP), c)); } void ColorValueEditor::changeCustom() { Color c = wxGetColourFromUser(0, value().value()); diff --git a/src/gui/value/editor.hpp b/src/gui/value/editor.hpp index 0d82c140..0bb37350 100644 --- a/src/gui/value/editor.hpp +++ b/src/gui/value/editor.hpp @@ -47,7 +47,7 @@ class ValueEditor { virtual void onMouseWheel (const RealPoint& pos, wxMouseEvent& ev) {} /// Key events - virtual void onChar(wxKeyEvent ev) {} + virtual void onChar(wxKeyEvent& ev) {} /// a context menu is requested, add extra items to the menu m /** return false to suppress menu */ diff --git a/src/mse.vcproj b/src/mse.vcproj index 289a3166..3e7dc3d4 100644 --- a/src/mse.vcproj +++ b/src/mse.vcproj @@ -984,6 +984,36 @@ + + + + + + + + + + + + + + + + getContext(); } +Rotation DataViewer::getRotation() const { + StyleSheetP stylesheet = set->stylesheetFor(card); + StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet); + return Rotation(ss.card_angle(), stylesheet->getCardRect(), ss.card_zoom()); +} + // ----------------------------------------------------------------------------- : Setting data void DataViewer::setCard(const CardP& card) { diff --git a/src/render/card/viewer.hpp b/src/render/card/viewer.hpp index 532f4aea..31aafe48 100644 --- a/src/render/card/viewer.hpp +++ b/src/render/card/viewer.hpp @@ -52,6 +52,8 @@ class DataViewer : public SetView { virtual ValueViewer* focusedViewer() const; /// Get a script context to use for scripts in the viewers Context& getContext() const; + /// The rotation to use + virtual Rotation getRotation() const; // --------------------------------------------------- : Setting data diff --git a/src/render/value/viewer.hpp b/src/render/value/viewer.hpp index d688efee..2c387a19 100644 --- a/src/render/value/viewer.hpp +++ b/src/render/value/viewer.hpp @@ -58,8 +58,8 @@ class ValueViewer { /// Convert this viewer to an editor, if possible virtual ValueEditor* getEditor() { return 0; } - protected: DataViewer& viewer; ///< Our parent object + protected: StyleP styleP; ///< The style of this viewer ValueP valueP; ///< The value we are currently viewing