Program: bbtk
Module: $RCSfile: bbtkWxGUITextEditor.cxx,v $
Language: C++
- Date: $Date: 2008/03/21 14:59:39 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/03/25 10:31:18 $
+ Version: $Revision: 1.3 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "icons/cc_new.xpm"
#include "icons/cc_open.xpm"
+#include "icons/cc_stop.xpm"
#include "icons/cc_save.xpm"
+#include "icons/cc_save_as.xpm"
#include "icons/cc_run.xpm"
#include "icons/cc_exit.xpm"
wxBitmap bmp_open(cc_open_xpm);
mwxButtonOpen = new wxBitmapButton( btnsCtrlPanel,ID_ButtonOpen,bmp_open);//,_T("Open") );
btnsSizer->Add( mwxButtonOpen );
+ wxBitmap bmp_close(cc_stop_xpm);
+ mwxButtonClose = new wxBitmapButton( btnsCtrlPanel,ID_ButtonClose,bmp_close);//,_T("Open") );
+ btnsSizer->Add( mwxButtonClose );
wxBitmap bmp_save(cc_save_xpm);
mwxButtonSave = new wxBitmapButton( btnsCtrlPanel,ID_ButtonSave,bmp_save);//_T("Save") );
btnsSizer->Add( mwxButtonSave );
+ wxBitmap bmp_saveas(cc_save_as_xpm);
+ mwxButtonSaveAs = new wxBitmapButton( btnsCtrlPanel,ID_ButtonSaveAs,bmp_saveas);//_T("Save") );
+ btnsSizer->Add( mwxButtonSaveAs );
wxBitmap bmp_run(cc_run_xpm);
mwxButtonRun = new wxBitmapButton( btnsCtrlPanel,ID_ButtonRun,bmp_run);//_T("Run") );
}
//================================================================
+ //================================================================
+ void WxGUITextEditor::OnButtonClose(wxCommandEvent& event)
+ {
+ std::cout << "-------------- CLOSE ---------------"<<std::endl;
+ if (mwxNotebook->GetPageCount()==0) return;
+ if (GetCurrentPage()->IsModified())
+ {
+ wxMessageDialog* d =
+ new wxMessageDialog(this,
+ _T("Buffer modified. Save it ?"),
+ _T("Save buffer"),
+ wxYES_NO | wxCANCEL | wxICON_QUESTION);
+ switch (d->ShowModal())
+ {
+ case wxID_CANCEL :
+ return;
+ break;
+ case wxID_YES :
+ GetCurrentPage()->Save(mFileNameFilter);
+ break;
+ case wxID_NO : ;
+ }
+ }
+ mwxNotebook->DeletePage(mwxNotebook->GetSelection());
+ FocusOnCurrentPage();
+ }
+ //================================================================
+
//================================================================
void WxGUITextEditor::OnButtonSave(wxCommandEvent& event)
{
}
//================================================================
+ //================================================================
+ void WxGUITextEditor::OnButtonSaveAs(wxCommandEvent& event)
+ {
+ if (mwxNotebook->GetPageCount()==0) return;
+ GetCurrentPage()->SetAskFilename(true);
+ Save();
+ }
+ //================================================================
+
//================================================================
void WxGUITextEditor::OnPageClose(wxAuiNotebookEvent& evt)
{
//================================================================
+
/*
//================================================================
void WxGUITextEditor::OnButtonQuit(wxCommandEvent& event)
//================================================================
void WxGUITextEditor::OnButtonRun(wxCommandEvent& event)
{
- if (mUser!=0) mUser->WxGUITextEditorRun();
+ if ((mUser!=0) && (mwxNotebook->GetPageCount()>0))
+ mUser->WxGUITextEditorRun();
FocusOnCurrentPage();
}
// EVT_CHAR(WxGUITextEditor::OnKeyPress)
EVT_BUTTON(WxGUITextEditor::ID_ButtonNew, WxGUITextEditor::OnButtonNew)
EVT_BUTTON(WxGUITextEditor::ID_ButtonOpen, WxGUITextEditor::OnButtonOpen)
+ EVT_BUTTON(WxGUITextEditor::ID_ButtonClose, WxGUITextEditor::OnButtonClose)
EVT_BUTTON(WxGUITextEditor::ID_ButtonSave, WxGUITextEditor::OnButtonSave)
+ EVT_BUTTON(WxGUITextEditor::ID_ButtonSaveAs, WxGUITextEditor::OnButtonSaveAs)
EVT_BUTTON(WxGUITextEditor::ID_ButtonRun, WxGUITextEditor::OnButtonRun)
// EVT_BUTTON(WxGUITextEditor::ID_ButtonQuit, WxGUITextEditor::OnButtonQuit)
EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, WxGUITextEditor::OnPageClose)