From: Markus R. <rol...@us...> - 2007-04-29 16:32:18
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv12531 Modified Files: Tag: RSGEDIT_FILEREF mainframe.cpp mainframe.h Log Message: - handle ID_CONTEXT_COPY_FILENAME and ID_CONTEXT_COPY_PATH - copy full node path and filename of associated rsg file to clipboard Index: mainframe.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.h,v retrieving revision 1.12.2.2 retrieving revision 1.12.2.3 diff -C2 -d -r1.12.2.2 -r1.12.2.3 *** mainframe.h 29 Apr 2007 16:13:10 -0000 1.12.2.2 --- mainframe.h 29 Apr 2007 16:32:15 -0000 1.12.2.3 *************** *** 28,31 **** --- 28,32 ---- #include "sparktree.h" #include "propertylist.h" + #include <oxygen/sceneserver/scenedict.h> #ifndef MAINFRAME_H *************** *** 103,106 **** --- 104,109 ---- void OnContextProperties(wxCommandEvent& event); void OnContextEditSource(wxCommandEvent& event); + void OnContextCopyFileName(wxCommandEvent& event); + void OnContextCopyPath(wxCommandEvent& event); void OnExit(wxCommandEvent& event); *************** *** 151,154 **** --- 154,163 ---- void EditFile(const wxString& fname, int line); + /** lookup the FileRef for the context node */ + const oxygen::SceneDict::FileRef* GetContextFileRef(); + + /** copy the given string to the sytem clipboard */ + void CopyToClipboard(const wxString& str) const; + protected: // begin wxGlade: mainframe::attributes Index: mainframe.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.cpp,v retrieving revision 1.16.2.2 retrieving revision 1.16.2.3 diff -C2 -d -r1.16.2.2 -r1.16.2.3 *** mainframe.cpp 29 Apr 2007 16:13:09 -0000 1.16.2.2 --- mainframe.cpp 29 Apr 2007 16:32:15 -0000 1.16.2.3 *************** *** 28,31 **** --- 28,32 ---- #include <wx/mimetype.h> #include <wx/filedlg.h> + #include <wx/clipbrd.h> #include <rsgedit/res/xpm_play.xpm> *************** *** 46,50 **** #include <oxygen/sceneserver/sceneserver.h> #include <oxygen/sceneserver/fpscontroller.h> - #include <oxygen/sceneserver/scenedict.h> #include <kerosin/inputserver/inputcontrol.h> #include "simspark.h" --- 47,50 ---- *************** *** 82,85 **** --- 82,87 ---- EVT_MENU(ID_CONTEXT_PROPERTIES, mainframe::OnContextProperties) EVT_MENU(ID_CONTEXT_EDIT_SOURCE, mainframe::OnContextEditSource) + EVT_MENU(ID_CONTEXT_COPY_FILENAME, mainframe::OnContextCopyFileName) + EVT_MENU(ID_CONTEXT_COPY_PATH, mainframe::OnContextCopyPath) EVT_TIMER(TI_LOG, mainframe::OnLogTimer) *************** *** 648,651 **** --- 650,679 ---- void mainframe::OnContextEditSource(wxCommandEvent& event) { + const SceneDict::FileRef* ref = GetContextFileRef(); + if (ref == 0) + { + assert(false); + return; + } + + EditFile(ref->fname, ref->line); + } + + void mainframe::OnContextCopyFileName(wxCommandEvent& event) + { + const SceneDict::FileRef* ref = GetContextFileRef(); + if (ref == 0) + { + assert(false); + return; + } + + wxFileName fn(ref->fname.c_str()); + fn.Normalize(); + CopyToClipboard(fn.GetFullPath()); + } + + void mainframe::OnContextCopyPath(wxCommandEvent& event) + { weak_ptr<Leaf> leaf = SparkContext::GetInstance().GetContextNode(); if (leaf.expired()) *************** *** 655,667 **** } ! const SceneDict::FileRef* ref = SceneDict::GetInstance().Lookup(leaf); ! if (ref == 0) ! { ! assert(false); ! return; ! } ! EditFile(ref->fname, ref->line); } --- 683,706 ---- } + CopyToClipboard(leaf.lock()->GetFullPath()); + } ! const SceneDict::FileRef* mainframe::GetContextFileRef() ! { ! weak_ptr<Leaf> leaf = SparkContext::GetInstance().GetContextNode(); ! if (leaf.expired()) ! { ! assert(false); ! return 0; ! } ! return SceneDict::GetInstance().Lookup(leaf); ! } ! ! void mainframe::CopyToClipboard(const wxString& str) const ! { ! wxTheClipboard->Open(); ! wxTheClipboard->SetData(new wxTextDataObject(str)); ! wxTheClipboard->Close(); } |