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:
twanvl
2006-11-20 18:51:11 +00:00
parent 3cbf2577c1
commit 23abbedcbd
46 changed files with 433 additions and 70 deletions
+2 -2
View File
@@ -83,7 +83,7 @@ class DataEditor : public CardViewer {
void onChar (wxKeyEvent&);
void onContextMenu(wxContextMenuEvent&);
void onMenu (wxCommandEvent& e);
void onMenu (wxCommandEvent&);
void onFocus (wxFocusEvent&);
void onLoseFocus(wxFocusEvent&);
@@ -96,7 +96,7 @@ class DataEditor : public CardViewer {
// selectField, but don't send events
void selectFieldNoEvents(const RealPoint& pos);
/// Convert mouse coordinates to internal coordinates
RealPoint mousePoint(const wxMouseEvent& e);
RealPoint mousePoint(const wxMouseEvent&);
// Create tab index ordering of the (editable) viewers
void createTabIndex();
+38 -1
View File
@@ -14,8 +14,10 @@
#include <data/set.hpp>
#include <data/card.hpp>
#include <data/settings.hpp>
#include <data/format/clipboard.hpp>
#include <data/action/set.hpp>
#include <util/window_id.hpp>
#include <wx/clipbrd.h>
DECLARE_TYPEOF_COLLECTION(CardP);
DECLARE_TYPEOF_COLLECTION(FieldP);
@@ -165,6 +167,41 @@ void CardListBase::selectCurrentCard() {
}
}
// ----------------------------------------------------------------------------- : CardListBase : Clipboard
bool CardListBase::canCopy() const { return !!selected_card; }
bool CardListBase::canCut() const { return canCopy() && allowModify(); }
bool CardListBase::canPaste() const {
return wxTheClipboard->IsSupported(CardDataObject::format);
}
void CardListBase::doCopy() {
if (!canCopy()) return;
if (!wxTheClipboard->Open()) return;
wxTheClipboard->SetData(new CardOnClipboard(set, selected_card)); // ignore result
wxTheClipboard->Close();
}
void CardListBase::doCut() {
// cut = copy + delete
if (!canCut()) return;
doCopy();
set->actions.add(new RemoveCardAction(*set, selected_card) );
}
void CardListBase::doPaste() {
// get data
if (!canPaste()) return;
if (!wxTheClipboard->Open()) return;
CardDataObject data;
bool ok = wxTheClipboard->GetData(data);
wxTheClipboard->Close();
if (!ok) return;
// add card to set
CardP card = data.getCard(set);
if (card) {
set->actions.add(new AddCardAction(*set, card));
}
}
// ----------------------------------------------------------------------------- : CardListBase : Building the list
// Comparison object for comparing cards
@@ -356,7 +393,7 @@ void CardListBase::onItemFocus(wxListEvent& ev) {
}
void CardListBase::onChar(wxKeyEvent& ev) {
if (ev.GetKeyCode() == WXK_DELETE) {
if (ev.GetKeyCode() == WXK_DELETE && allowModify()) {
set->actions.add(new RemoveCardAction(*set, selected_card));
} else if (ev.GetKeyCode() == WXK_TAB) {
// send a navigation event to our parent, to select another control
+2
View File
@@ -88,6 +88,8 @@ class CardListBase : public wxListView, public SetView {
void rebuild();
/// Do some additional updating before rebuilding the list
virtual void onRebuild() {}
/// Can the card list be modified?
virtual bool allowModify() const { return true; }
// --------------------------------------------------- : Item 'events'
+1 -1
View File
@@ -40,7 +40,7 @@ class FilteredCardList : public CardListBase {
/// Rebuild the filtered card list
virtual void onRebuild();
// /// Don't reorder
// virtual void onDrag(wxMouseEvent& e);
// virtual void onDrag(wxMouseEvent& ev);
private:
CardListFilterP filter; ///< Filter with which this.cards is made
+1 -1
View File
@@ -73,8 +73,8 @@ wxSize NativeLookEditor::DoGetBestSize() const {
return wxSize(200, 200);
}
void NativeLookEditor::onSize(wxSizeEvent& ev) {
// CardViewre::onSize(ev);
resizeViewers();
Refresh(false);
}
BEGIN_EVENT_TABLE(NativeLookEditor, DataEditor)