From f915a491a804d86ce307f415a017558d9a356865 Mon Sep 17 00:00:00 2001 From: twanvl Date: Thu, 12 Apr 2007 19:39:08 +0000 Subject: [PATCH] fixed: "Double click to select image" text now always shown when editing; Correct control used for clipboard actions in CardsPanel git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@253 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/gui/control/card_editor.cpp | 3 +++ src/gui/control/card_editor.hpp | 1 + src/gui/set/cards_panel.cpp | 20 ++++++++++++++------ src/render/card/viewer.cpp | 1 + src/render/card/viewer.hpp | 3 +++ src/render/value/text.cpp | 4 ++-- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/gui/control/card_editor.cpp b/src/gui/control/card_editor.cpp index fca66645..c94b792c 100644 --- a/src/gui/control/card_editor.cpp +++ b/src/gui/control/card_editor.cpp @@ -39,6 +39,9 @@ bool DataEditor::drawBorders() const { settings.stylesheetSettingsFor(*set->stylesheetFor(card)).card_borders(); } bool DataEditor::drawEditing() const { + return true; +} +bool DataEditor::drawFocus() const { return FindFocus() == this; } diff --git a/src/gui/control/card_editor.hpp b/src/gui/control/card_editor.hpp index 3d9cdf1b..474c5ee3 100644 --- a/src/gui/control/card_editor.hpp +++ b/src/gui/control/card_editor.hpp @@ -26,6 +26,7 @@ class DataEditor : public CardViewer { virtual bool drawBorders() const; virtual bool drawEditing() const; + virtual bool drawFocus() const; virtual wxPen borderPen(bool active) const; virtual ValueViewer* focusedViewer() const; diff --git a/src/gui/set/cards_panel.cpp b/src/gui/set/cards_panel.cpp index e4cc0cb0..111b644a 100644 --- a/src/gui/set/cards_panel.cpp +++ b/src/gui/set/cards_panel.cpp @@ -249,12 +249,20 @@ bool CardsPanel::wantsToHandle(const Action&, bool undone) const { // ----------------------------------------------------------------------------- : Clipboard -bool CardsPanel::canCut() const { return focused_control(this) == ID_EDITOR ? editor->canCut() : card_list->canCut(); } -bool CardsPanel::canCopy() const { return focused_control(this) == ID_EDITOR ? editor->canCopy() : card_list->canCopy(); } -bool CardsPanel::canPaste() const { return focused_control(this) == ID_EDITOR ? editor->canPaste() : card_list->canPaste(); } -void CardsPanel::doCut() { if (focused_control(this) == ID_EDITOR) editor->doCut(); else card_list->doCut(); } -void CardsPanel::doCopy() { if (focused_control(this) == ID_EDITOR) editor->doCopy(); else card_list->doCopy(); } -void CardsPanel::doPaste() { if (focused_control(this) == ID_EDITOR) editor->doPaste(); else card_list->doPaste(); } +// determine what control to use for clipboard actions +#define CUT_COPY_PASTE(op,return) \ + int id = focused_control(this); \ + if (id == ID_EDITOR) { return editor->op(); } \ + else if (id == ID_CARD_LIST) { return card_list->op(); } \ + else if (id == ID_NOTES) { return notes->op(); } \ + else { return false; } + +bool CardsPanel::canCut() const { CUT_COPY_PASTE(canCut, return) } +bool CardsPanel::canCopy() const { CUT_COPY_PASTE(canCopy, return) } +bool CardsPanel::canPaste() const { CUT_COPY_PASTE(canPaste, return) } +void CardsPanel::doCut() { CUT_COPY_PASTE(doCut, ;) } +void CardsPanel::doCopy() { CUT_COPY_PASTE(doCopy, ;) } +void CardsPanel::doPaste() { CUT_COPY_PASTE(doPaste, ;) } // ----------------------------------------------------------------------------- : Searching diff --git a/src/render/card/viewer.cpp b/src/render/card/viewer.cpp index 81da0492..9ba805ad 100644 --- a/src/render/card/viewer.cpp +++ b/src/render/card/viewer.cpp @@ -54,6 +54,7 @@ void DataViewer::drawViewer(RotatedDC& dc, ValueViewer& v) { bool DataViewer::nativeLook() const { return false; } bool DataViewer::drawBorders() const { return false; } bool DataViewer::drawEditing() const { return false; } +bool DataViewer::drawFocus() const { return false; } wxPen DataViewer::borderPen(bool) const { return wxPen(); } ValueViewer* DataViewer::focusedViewer() const { return nullptr; } Context& DataViewer::getContext() const { return set->getContext(); } diff --git a/src/render/card/viewer.hpp b/src/render/card/viewer.hpp index 1b2dc0b9..89556a81 100644 --- a/src/render/card/viewer.hpp +++ b/src/render/card/viewer.hpp @@ -42,6 +42,9 @@ class DataViewer : public SetView { /// Should editing specific things be drawn? /** false by default, can be overloaded */ virtual bool drawEditing() const; + /// Should focus only editing specific things be drawn? + /** false by default, can be overloaded */ + virtual bool drawFocus() const; /// Pens for drawing field borders (only called if drawBorders()) virtual wxPen borderPen(bool active) const; /// The viewer that is currently focused, may be null diff --git a/src/render/value/text.cpp b/src/render/value/text.cpp index 52f1eb4b..ce3cc569 100644 --- a/src/render/value/text.cpp +++ b/src/render/value/text.cpp @@ -25,8 +25,8 @@ void TextValueViewer::draw(RotatedDC& dc) { v.prepare(dc, value().value(), style(), viewer.getContext()); v.draw(dc, style(), (DrawWhat)( DRAW_NORMAL - | (viewer.drawBorders() ? DRAW_BORDERS : 0) - | (viewer.drawEditing() && isCurrent() ? DRAW_ACTIVE : 0) + | (viewer.drawBorders() ? DRAW_BORDERS : 0) + | (viewer.drawFocus() && isCurrent() ? DRAW_ACTIVE : 0) )); }