From: Markus R. <rol...@us...> - 2007-06-21 18:43:18
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv9861 Modified Files: Tag: RSGEDIT_SCINTILLA mainframe.cpp mainframe.h sparkedit.cpp sparkedit.h Log Message: - track modified state of scintilla tabs and indicate it with an asterisk in the tab label Index: mainframe.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.h,v retrieving revision 1.15.2.1 retrieving revision 1.15.2.2 diff -C2 -d -r1.15.2.1 -r1.15.2.2 *** mainframe.h 21 Jun 2007 17:55:43 -0000 1.15.2.1 --- mainframe.h 21 Jun 2007 18:42:41 -0000 1.15.2.2 *************** *** 29,32 **** --- 29,33 ---- #include <wx/image.h> #include <wx/wxflatnotebook/wxflatnotebook.h> + #include <wx/wxscintilla.h> #include "constants.h" #include "sparktree.h" *************** *** 152,155 **** --- 153,159 ---- void OnTabClosing(wxFlatNotebookEvent& event); + void OnEditSavePointReached(wxScintillaEvent& event); + void OnEditSavePointLeft(wxScintillaEvent& event); + void OnSparkContext(SparkContextEvent& event); Index: sparkedit.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/Attic/sparkedit.cpp,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** sparkedit.cpp 21 Jun 2007 18:22:39 -0000 1.1.2.2 --- sparkedit.cpp 21 Jun 2007 18:42:41 -0000 1.1.2.3 *************** *** 46,49 **** --- 46,62 ---- } + wxString SparkEdit::GetTitle(wxScintilla* edit, const EditEntry& entry) + { + + wxString title(wxFileName(entry.fname).GetFullName()); + + if (edit->GetModify()) + { + title += "*"; + } + + return title; + } + wxScintilla* SparkEdit::GetEdit(const wxString& fname, wxFlatNotebook* notebook) { *************** *** 87,91 **** bool select = true; ! notebook->AddPage(edit,wxFileName(fname).GetFullName(), select); edit->SetFocus(); --- 100,105 ---- bool select = true; ! wxString title(GetTitle(edit, entry)); ! notebook->AddPage(edit,title,select); edit->SetFocus(); *************** *** 207,208 **** --- 221,240 ---- mEditMap.erase(iter); } + + void SparkEdit::UpdateTitle(wxFlatNotebook* notebook, wxScintilla* edit) + { + if (notebook == 0) + { + assert(false); + return; + } + + TEditMap::iterator iter = mEditMap.find(edit); + if (iter == mEditMap.end()) + { + return; + } + + const EditEntry& entry = (*iter).second; + notebook->SetPageText(entry.page, GetTitle(edit, entry)); + } Index: mainframe.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.cpp,v retrieving revision 1.21.2.2 retrieving revision 1.21.2.3 diff -C2 -d -r1.21.2.2 -r1.21.2.3 *** mainframe.cpp 21 Jun 2007 18:22:39 -0000 1.21.2.2 --- mainframe.cpp 21 Jun 2007 18:42:41 -0000 1.21.2.3 *************** *** 105,108 **** --- 105,111 ---- EVT_FLATNOTEBOOK_PAGE_CLOSING(wxID_ANY, mainframe::OnTabClosing) + EVT_SCI_SAVEPOINTREACHED(wxID_ANY, mainframe::OnEditSavePointReached) + EVT_SCI_SAVEPOINTLEFT(wxID_ANY, mainframe::OnEditSavePointLeft) + EVT_SPARK_CONTEXT(ID_SPARK_CONTEXT, mainframe::OnSparkContext) END_EVENT_TABLE() *************** *** 1105,1106 **** --- 1108,1122 ---- event.Skip(); } + + void mainframe::OnEditSavePointReached(wxScintillaEvent& event) + { + SparkEdit::UpdateTitle(mCtrNotebook,static_cast<wxScintilla*>(event.GetEventObject())); + event.Skip(); + } + + void mainframe::OnEditSavePointLeft(wxScintillaEvent& event) + { + SparkEdit::UpdateTitle(mCtrNotebook,static_cast<wxScintilla*>(event.GetEventObject())); + event.Skip(); + } + Index: sparkedit.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/Attic/sparkedit.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** sparkedit.h 21 Jun 2007 17:56:39 -0000 1.1.2.1 --- sparkedit.h 21 Jun 2007 18:42:41 -0000 1.1.2.2 *************** *** 50,53 **** --- 50,54 ---- static wxScintilla* GetEdit(const wxString& fname, wxFlatNotebook* notebook); static void PutEdit(wxScintilla* edit); + static void UpdateTitle(wxFlatNotebook* notebook, wxScintilla* edit); protected: *************** *** 55,58 **** --- 56,60 ---- static bool LoadFile(wxScintilla* edit, EditEntry& entry); static void PrepareEdit(wxScintilla* edit, const EditEntry& entry); + static wxString GetTitle(wxScintilla* edit, const EditEntry& entry); protected: |