From 19c5250edbca4aa4ab57629bcd8815011a1e4542 Mon Sep 17 00:00:00 2001 From: twanvl Date: Sun, 22 Apr 2007 23:04:49 +0000 Subject: [PATCH] Copy&paste for keywords panel; Fixed: initialization of 'direction' for TextStyle git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@292 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/field/text.cpp | 1 + src/gui/set/keywords_panel.cpp | 30 ++++++++++++++++++++++++++---- src/gui/set/keywords_panel.hpp | 8 ++++++++ src/util/window_id.hpp | 2 +- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/data/field/text.cpp b/src/data/field/text.cpp index 459b3c39..6393daba 100644 --- a/src/data/field/text.cpp +++ b/src/data/field/text.cpp @@ -53,6 +53,7 @@ TextStyle::TextStyle(const TextFieldP& field) , line_height_soft(1.0) , line_height_hard(1.0) , line_height_line(1.0) + , direction(LEFT_TO_RIGHT) {} bool TextStyle::update(Context& ctx) { diff --git a/src/gui/set/keywords_panel.cpp b/src/gui/set/keywords_panel.cpp index 985553e2..f2e19a26 100644 --- a/src/gui/set/keywords_panel.cpp +++ b/src/gui/set/keywords_panel.cpp @@ -35,10 +35,10 @@ KeywordsPanel::KeywordsPanel(Window* parent, int id) splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0); list = new KeywordList(splitter, wxID_ANY); panel = new Panel(splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 /* no tab traversal*/); - keyword = new TextCtrl(panel, wxID_ANY, false); - match = new TextCtrl(panel, wxID_ANY, false); - reminder = new TextCtrl(panel, wxID_ANY, true); // allow multiline for wordwrap - rules = new TextCtrl(panel, wxID_ANY, true); + keyword = new TextCtrl(panel, ID_KEYWORD, false); + match = new TextCtrl(panel, ID_MATCH, false); + reminder = new TextCtrl(panel, ID_REMINDER, true); // allow multiline for wordwrap + rules = new TextCtrl(panel, ID_RULES, true); errors = new wxStaticText(panel, wxID_ANY, _("")); errors->SetForegroundColour(*wxRED); mode = new wxChoice(panel, ID_KEYWORD_MODE, wxDefaultPosition, wxDefaultSize, 0, nullptr); @@ -222,6 +222,28 @@ String KeywordsPanel::runRefScript(int find_i) { return wxEmptyString; } +// ----------------------------------------------------------------------------- : Clipboard + +// determine what control to use for clipboard actions +#define CUT_COPY_PASTE(op,return) \ + int id = focused_control(this); \ + if (id == ID_KEYWORD && keyword ->IsEnabled()) { return keyword ->op(); } \ + else if (id == ID_MATCH && match ->IsEnabled()) { return match ->op(); } \ + else if (id == ID_REMINDER && reminder->IsEnabled()) { return reminder->op(); } \ + else if (id == ID_RULES && rules ->IsEnabled()) { return rules ->op(); } \ + else { return false; } + +bool KeywordsPanel::canCopy() const { CUT_COPY_PASTE(canCopy, return) } +bool KeywordsPanel::canCut() const { if (!list->getKeyword() || list->getKeyword()->fixed) return false; + CUT_COPY_PASTE(canCut, return) } +bool KeywordsPanel::canPaste() const { if (!list->getKeyword() || list->getKeyword()->fixed) return false; + CUT_COPY_PASTE(canPaste, return) } +void KeywordsPanel::doCopy() { CUT_COPY_PASTE(doCopy, ;) } +void KeywordsPanel::doCut() { if (!list->getKeyword() || list->getKeyword()->fixed) return; + CUT_COPY_PASTE(doCut, ;) } +void KeywordsPanel::doPaste() { if (!list->getKeyword() || list->getKeyword()->fixed) return; + CUT_COPY_PASTE(doPaste, ;) } + // ----------------------------------------------------------------------------- : Events void KeywordsPanel::onChangeSet() { diff --git a/src/gui/set/keywords_panel.hpp b/src/gui/set/keywords_panel.hpp index 7f4d46b6..d2e54557 100644 --- a/src/gui/set/keywords_panel.hpp +++ b/src/gui/set/keywords_panel.hpp @@ -36,6 +36,14 @@ class KeywordsPanel : public SetWindowPanel { virtual void onUpdateUI(wxUpdateUIEvent&); virtual void onCommand(int id); + // --------------------------------------------------- : Clipboard + virtual bool canCut() const; + virtual bool canCopy() const; + virtual bool canPaste() const; + virtual void doCut(); + virtual void doCopy(); + virtual void doPaste(); + private: DECLARE_EVENT_TABLE(); diff --git a/src/util/window_id.hpp b/src/util/window_id.hpp index 53bddca9..23daeebb 100644 --- a/src/util/window_id.hpp +++ b/src/util/window_id.hpp @@ -191,7 +191,7 @@ enum ControlID { , ID_STYLESHEET_LIST , ID_NOTES , ID_KEYWORD -, ID_PARAMETER +, ID_MATCH , ID_REMINDER , ID_RULES // Card list column select