mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
implemented clipboard handling for cards
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@83 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+36
-21
@@ -10,6 +10,7 @@
|
||||
#include <gui/control/card_list.hpp>
|
||||
#include <gui/control/card_editor.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/action/set.hpp>
|
||||
#include <data/settings.hpp>
|
||||
@@ -119,25 +120,25 @@ void CardsPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
delete mb->Remove(2);
|
||||
}
|
||||
|
||||
void CardsPanel::onUpdateUI(wxUpdateUIEvent& e) {
|
||||
switch (e.GetId()) {
|
||||
case ID_CARD_PREV: e.Enable(card_list->canSelectPrevious()); break;
|
||||
case ID_CARD_NEXT: e.Enable(card_list->canSelectNext()); break;
|
||||
/* case ID_CARD_ROTATE_0: e.Check(editor->rotation.angle == 0); break;
|
||||
case ID_CARD_ROTATE_90: e.Check(editor->rotation.angle == 90); break;
|
||||
case ID_CARD_ROTATE_180: e.Check(editor->rotation.angle == 180); break;
|
||||
case ID_CARD_ROTATE_270: e.Check(editor->rotation.angle == 270); break;
|
||||
case ID_CARD_REMOVE: e.Enable(set->cards.size() > 0); break;
|
||||
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: {
|
||||
if (focusedControl() == idEditor) {
|
||||
e.Enable(editor->canFormat(e.id));
|
||||
e.Check (editor->hasFormat(e.id));
|
||||
void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
switch (ev.GetId()) {
|
||||
case ID_CARD_PREV: ev.Enable(card_list->canSelectPrevious()); break;
|
||||
case ID_CARD_NEXT: ev.Enable(card_list->canSelectNext()); break;
|
||||
/* case ID_CARD_ROTATE_0: ev.Check(editor->rotation.angle == 0); break;
|
||||
case ID_CARD_ROTATE_90: ev.Check(editor->rotation.angle == 90); break;
|
||||
case ID_CARD_ROTATE_180: ev.Check(editor->rotation.angle == 180); break;
|
||||
case ID_CARD_ROTATE_270: ev.Check(editor->rotation.angle == 270); break;*/
|
||||
case ID_CARD_REMOVE: ev.Enable(set->cards.size() > 0); break;
|
||||
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
|
||||
if (focused_control(this) == ID_EDITOR) {
|
||||
ev.Enable(editor->canFormat(ev.GetId()));
|
||||
ev.Check (editor->hasFormat(ev.GetId()));
|
||||
} else {
|
||||
e.Enable(false);
|
||||
e.Check(false);
|
||||
ev.Enable(false);
|
||||
ev.Check(false);
|
||||
}
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,35 +160,41 @@ void CardsPanel::onCommand(int id) {
|
||||
StyleSettings& ss = settings.styleSettingsFor(*editor->style);
|
||||
ss.cardAngle = (ss.cardAngle + 90) % 360;
|
||||
onRenderSettingsChange();
|
||||
break;
|
||||
}
|
||||
case idCardRotate0 {
|
||||
StyleSettings& ss = settings.styleSettingsFor(*editor->style);
|
||||
ss.cardAngle = 0;
|
||||
onRenderSettingsChange();
|
||||
break;
|
||||
}
|
||||
case idCardRotate90 {
|
||||
StyleSettings& ss = settings.styleSettingsFor(*editor->style);
|
||||
ss.cardAngle = 90;
|
||||
onRenderSettingsChange();
|
||||
break;
|
||||
}
|
||||
case idCardRotate180 {
|
||||
StyleSettings& ss = settings.styleSettingsFor(*editor->style);
|
||||
ss.cardAngle = 180;
|
||||
onRenderSettingsChange();
|
||||
break;
|
||||
}
|
||||
case idCardRotate270 {
|
||||
StyleSettings& ss = settings.styleSettingsFor(*editor->style);
|
||||
ss.cardAngle = 270;
|
||||
onRenderSettingsChange();
|
||||
break;
|
||||
}
|
||||
case idSelectColumns {
|
||||
cardList->selectColumns();
|
||||
}
|
||||
case idFormatBold, idFormatItalic, idFormatSymbol, idFormatNoAuto {
|
||||
if (focusedControl() == idEditor) {
|
||||
editor->doFormat(id);
|
||||
}
|
||||
}*/
|
||||
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
|
||||
if (focused_control(this) == ID_EDITOR) {
|
||||
editor->doFormat(id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,6 +212,14 @@ void CardsPanel::onRenderSettingsChange() {
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : 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(); }
|
||||
|
||||
// ----------------------------------------------------------------------------- : Searching
|
||||
|
||||
// ----------------------------------------------------------------------------- : Selection
|
||||
|
||||
@@ -30,7 +30,7 @@ class CardsPanel : public SetWindowPanel {
|
||||
|
||||
virtual void initUI (wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void destroyUI(wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void onUpdateUI(wxUpdateUIEvent& e);
|
||||
virtual void onUpdateUI(wxUpdateUIEvent&);
|
||||
virtual void onCommand(int id);
|
||||
|
||||
// --------------------------------------------------- : Actions
|
||||
@@ -41,7 +41,7 @@ class CardsPanel : public SetWindowPanel {
|
||||
public:
|
||||
|
||||
// --------------------------------------------------- : Clipboard
|
||||
/* virtual bool canCut() const;
|
||||
virtual bool canCut() const;
|
||||
virtual bool canCopy() const;
|
||||
virtual bool canPaste() const;
|
||||
virtual void doCut();
|
||||
@@ -49,7 +49,7 @@ class CardsPanel : public SetWindowPanel {
|
||||
virtual void doPaste();
|
||||
|
||||
// --------------------------------------------------- : Searching (find/replace)
|
||||
virtual bool canFind() const;
|
||||
/* virtual bool canFind() const;
|
||||
virtual bool canReplace() const;
|
||||
virtual bool doFind(wxFindReplaceData& what);
|
||||
virtual bool doReplace(wxFindReplaceData& what);
|
||||
|
||||
+1
-17
@@ -39,7 +39,7 @@ class SetWindowPanel : public wxPanel, public SetView {
|
||||
/// Update the UI by enabling/disabling items.
|
||||
/** Note: copy/paste and find/replace are not handled here.
|
||||
*/
|
||||
virtual void onUpdateUI(wxUpdateUIEvent& e) {}
|
||||
virtual void onUpdateUI(wxUpdateUIEvent&) {}
|
||||
/// Respond to one of those extra menu/tool items
|
||||
virtual void onCommand(int id) {}
|
||||
|
||||
@@ -69,22 +69,6 @@ class SetWindowPanel : public wxPanel, public SetView {
|
||||
// --------------------------------------------------- : Selection
|
||||
virtual CardP selectedCard() const { return CardP(); } ///< Return the currently selected card, or CardP()
|
||||
virtual void selectCard(const CardP& card) {} ///< Switch the view to another card
|
||||
|
||||
protected:
|
||||
// --------------------------------------------------- : Helper functions for UI
|
||||
/// Enable/disable a tool or menu item
|
||||
// void enable(wxToolBar* tb, wxMenuBar* mb, int id, bool enable);
|
||||
// mb->Enable(id, enable)
|
||||
// tb->EnableTool(id, enable)
|
||||
|
||||
/// Id of the control that has the focus, or -1 if no control has the focus
|
||||
int focusedControl();
|
||||
// Window* focusedWindow = findFocus()
|
||||
// // is this window actually inside this panel?
|
||||
// if focusedWindow && findWindowById(focusedWindow->id, &this) == focusedWindow
|
||||
// return focusedWindow->id
|
||||
// else
|
||||
// return -1 // no window has the focus, or it has a different parent/ancestor
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
@@ -55,11 +55,11 @@ void SetInfoPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
delete mb->Remove(2);
|
||||
}
|
||||
|
||||
void SetInfoPanel::onUpdateUI(wxUpdateUIEvent& e) {
|
||||
switch (e.GetId()) {
|
||||
void SetInfoPanel::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
switch (ev.GetId()) {
|
||||
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: {
|
||||
e.Enable(editor->canFormat(e.GetId()));
|
||||
e.Check (editor->hasFormat(e.GetId()));
|
||||
ev.Enable(editor->canFormat(ev.GetId()));
|
||||
ev.Check (editor->hasFormat(ev.GetId()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,7 @@ void SetInfoPanel::onCommand(int id) {
|
||||
switch (id) {
|
||||
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: {
|
||||
editor->doFormat(id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class SetInfoPanel : public SetWindowPanel {
|
||||
|
||||
virtual void initUI (wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void destroyUI(wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void onUpdateUI(wxUpdateUIEvent& e);
|
||||
virtual void onUpdateUI(wxUpdateUIEvent&);
|
||||
virtual void onCommand(int id);
|
||||
|
||||
// --------------------------------------------------- : Clipboard
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <gui/control/graph.hpp>
|
||||
#include <gui/control/gallery_list.hpp>
|
||||
#include <gui/control/filtered_card_list.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
#include <wx/splitter.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : StatFieldList
|
||||
@@ -43,7 +44,7 @@ StatsPanel::StatsPanel(Window* parent, int id)
|
||||
{
|
||||
// init controls
|
||||
wxSplitterWindow* splitter;
|
||||
fields = new StatFieldList (this, wxID_ANY);
|
||||
fields = new StatFieldList (this, ID_FIELD_LIST);
|
||||
splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
|
||||
graph = new GraphControl (splitter, wxID_ANY);
|
||||
card_list = new FilteredCardList(splitter, wxID_ANY);
|
||||
@@ -58,3 +59,25 @@ StatsPanel::StatsPanel(Window* parent, int id)
|
||||
s->SetSizeHints(this);
|
||||
SetSizer(s);
|
||||
}
|
||||
|
||||
void StatsPanel::onChangeSet() {
|
||||
card_list->setSet(set);
|
||||
}
|
||||
|
||||
void StatsPanel::onCommand(int id) {
|
||||
switch (id) {
|
||||
case ID_FIELD_LIST: {
|
||||
// change graph data
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Selection
|
||||
|
||||
CardP StatsPanel::selectedCard() const {
|
||||
return card_list->getCard();
|
||||
}
|
||||
void StatsPanel::selectCard(const CardP& card) {
|
||||
card_list->setCard(card);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,16 @@ class StatsPanel : public SetWindowPanel {
|
||||
public:
|
||||
StatsPanel(Window* parent, int id);
|
||||
|
||||
// virtual void onUpdateUI(wxUpdateUIEvent& e);
|
||||
// virtual void onCommand(int id);
|
||||
// --------------------------------------------------- : UI
|
||||
|
||||
virtual void onChangeSet();
|
||||
virtual void onCommand(int id);
|
||||
|
||||
// --------------------------------------------------- : Selection
|
||||
virtual CardP selectedCard() const;
|
||||
virtual void selectCard(const CardP& card);
|
||||
|
||||
// --------------------------------------------------- : Data
|
||||
private:
|
||||
StatFieldList* fields;
|
||||
GraphControl* graph;
|
||||
|
||||
Reference in New Issue
Block a user