From: Markus R. <rol...@us...> - 2007-06-23 09:11:40
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv21173 Modified Files: Tag: RSGEDIT_SCINTILLA sparkedit.cpp sparkedit.h Log Message: - add the concept of a start script; associate a special icon - associate an icon with each edit control Index: sparkedit.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/Attic/sparkedit.cpp,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -C2 -d -r1.1.2.7 -r1.1.2.8 *** sparkedit.cpp 23 Jun 2007 07:28:04 -0000 1.1.2.7 --- sparkedit.cpp 23 Jun 2007 09:11:36 -0000 1.1.2.8 *************** *** 22,29 **** --- 22,36 ---- #include <wx/filename.h> + #include <rsgedit/res/xpm_play.xpm> + #include <rsgedit/res/xpm_spark.xpm> + #include <rsgedit/res/xpm_ruby.xpm> + #include <rsgedit/res/xpm_rsg.xpm> + static wxColour COL_COMMENT(0,128,0); static wxColour COL_KEYWORD(0,0,255); SparkEdit::TEditMap SparkEdit::mEditMap; + wxFlatNotebookImageList SparkEdit::mNotebookImgList; + wxScintilla* SparkEdit::mStartScript = 0; wxScintilla* SparkEdit::Create(wxWindow* parent) *************** *** 111,116 **** entry.page = static_cast<int>(notebook->GetPageCount() - 1); - mEditMap[edit] = entry; return edit; } --- 118,124 ---- entry.page = static_cast<int>(notebook->GetPageCount() - 1); mEditMap[edit] = entry; + + UpdateIcon(notebook, edit, entry); return edit; } *************** *** 226,232 **** --- 234,315 ---- } + if (edit == mStartScript) + { + mStartScript = 0; + } + mEditMap.erase(iter); } + int SparkEdit::GetImageIndex(const wxScintilla* edit, const EditEntry& entry) + { + if (edit == mStartScript) + { + return II_STARTSCRIPT; + } + + switch (entry.type) + { + default: + return -1; + + case ET_RB: + return II_RUBY; + + case ET_RSG: + return II_RSG; + } + } + + void SparkEdit::PrepareImageList(wxFlatNotebook* notebook) + { + if (notebook == 0) + { + assert(false); + return; + } + + mNotebookImgList.Clear(); + mNotebookImgList.Add(wxBitmap(xpm_spark)); // II_SIMSPARK + mNotebookImgList.Add(wxBitmap(xpm_play)); // II_STARTSCRIPT + mNotebookImgList.Add(wxBitmap(xpm_ruby)); // II_RUBY + mNotebookImgList.Add(wxBitmap(xpm_rsg)); // II_RSG + notebook->SetImageList(&mNotebookImgList); + } + + void SparkEdit::UpdateIcon(wxFlatNotebook* notebook, const wxScintilla* edit, const EditEntry& entry) + { + if ( + (notebook == 0) || + (edit == 0) + ) + { + assert(false); + return; + } + + notebook->SetPageImageIndex(entry.page, GetImageIndex(edit, entry)); + } + + void SparkEdit::UpdateIcons(wxFlatNotebook* notebook) + { + if (notebook == 0) + { + assert(false); + return; + } + + for ( + TEditMap::const_iterator iter = mEditMap.begin(); + iter != mEditMap.end(); + ++iter + ) + { + const EditEntry& entry = (*iter).second; + const wxScintilla* edit = (*iter).first; + UpdateIcon(notebook, edit, entry); + } + } + void SparkEdit::UpdateTitle(wxFlatNotebook* notebook, wxScintilla* edit) { *************** *** 258,259 **** --- 341,348 ---- edit->SaveFile(entry.fname); } + + void SparkEdit::SetStartScript(wxFlatNotebook* notebook, wxScintilla* edit) + { + mStartScript = edit; + UpdateIcons(notebook); + } Index: sparkedit.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/Attic/sparkedit.h,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** sparkedit.h 21 Jun 2007 19:26:38 -0000 1.1.2.4 --- sparkedit.h 23 Jun 2007 09:11:36 -0000 1.1.2.5 *************** *** 38,46 **** --- 38,62 ---- }; + enum EImgIndex + { + II_NONE = -1, + II_SIMSPARK = 0, + II_STARTSCRIPT, + II_RUBY, + II_RSG + }; + struct EditEntry { + public: EEditType type; wxString fname; int page; + + public: + EditEntry() + : type(ET_RSG), page(-1) + { + } }; *************** *** 51,55 **** --- 67,74 ---- static void PutEdit(wxScintilla* edit); static void UpdateTitle(wxFlatNotebook* notebook, wxScintilla* edit); + static void UpdateIcons(wxFlatNotebook* notebook); static void SaveFile(wxScintilla* edit); + static void SetStartScript(wxFlatNotebook* notebook, wxScintilla* edit); + static void PrepareImageList(wxFlatNotebook* notebook); protected: *************** *** 59,64 **** --- 78,90 ---- static wxString GetTitle(wxScintilla* edit, const EditEntry& entry); + static void UpdateIcon(wxFlatNotebook* notebook, const wxScintilla* edit, const EditEntry& entry); + static int GetImageIndex(const wxScintilla* edit, const EditEntry& entry); + protected: static TEditMap mEditMap; + static wxFlatNotebookImageList mNotebookImgList; + + //! the editor holding the simulation start script + static wxScintilla* mStartScript; }; |