Program: bbtk
Module: $RCSfile: bbtkWxGUITextEditor.cxx,v $
Language: C++
- Date: $Date: 2008/03/25 10:31:18 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2008/03/25 15:47:54 $
+ Version: $Revision: 1.4 $
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_run.xpm"
#include "icons/cc_exit.xpm"
+#include "../data/icons/wxart_new.xpm"
+#include "../data/icons/wxart_fileopen.xpm"
+#include "../data/icons/wxart_filesave.xpm"
+#include "../data/icons/wxart_filesaveas.xpm"
+#include "../data/icons/wxart_exefile.xpm"
+#include "../data/icons/wxart_delete.xpm"
+#include "../data/icons/wxart_down.xpm"
+#include "../data/icons/wxart_eldel.xpm"
namespace bbtk
{
// BUTTONS
wxPanel *btnsCtrlPanel = new wxPanel(this,-1);
wxBoxSizer *btnsSizer = new wxBoxSizer(wxHORIZONTAL);
-
+
+ /*
wxBitmap bmp_new(cc_new_xpm);
- mwxButtonNew = new wxBitmapButton( btnsCtrlPanel,ID_ButtonNew,bmp_new);//_T("New") );
- btnsSizer->Add( mwxButtonNew );
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") );
+ wxBitmap bmp_run(cc_run_xpm);
+ */
+ wxBitmap bmp_new(new_xpm);
+ wxBitmap bmp_open(fileopen_xpm);
+ wxBitmap bmp_close(eldel_xpm);
+ wxBitmap bmp_save(filesave_xpm);
+ wxBitmap bmp_saveas(filesaveas_xpm);
+ wxBitmap bmp_run(down_xpm);
+
+
+ wxSize btn_size(32,32);
+ mwxButtonNew = new wxBitmapButton( btnsCtrlPanel,ID_ButtonNew,bmp_new
+ ,wxDefaultPosition, btn_size);
+ btnsSizer->Add( mwxButtonNew );
+
+ mwxButtonOpen = new wxBitmapButton( btnsCtrlPanel,ID_ButtonOpen,bmp_open ,wxDefaultPosition, btn_size);//,_T("Open") );
+ btnsSizer->Add( mwxButtonOpen );
+
+ mwxButtonClose = new wxBitmapButton( btnsCtrlPanel,ID_ButtonClose,bmp_close ,wxDefaultPosition, btn_size);//,_T("Open") );
+ btnsSizer->Add( mwxButtonClose );
+
+ mwxButtonSave = new wxBitmapButton( btnsCtrlPanel,ID_ButtonSave,bmp_save ,wxDefaultPosition, btn_size);//_T("Save") );
+ btnsSizer->Add( mwxButtonSave );
+
+ mwxButtonSaveAs = new wxBitmapButton( btnsCtrlPanel,ID_ButtonSaveAs,bmp_saveas ,wxDefaultPosition, btn_size);//_T("Save") );
btnsSizer->Add( mwxButtonSaveAs );
- wxBitmap bmp_run(cc_run_xpm);
- mwxButtonRun = new wxBitmapButton( btnsCtrlPanel,ID_ButtonRun,bmp_run);//_T("Run") );
+
+ mwxButtonRun = new wxBitmapButton( btnsCtrlPanel,ID_ButtonRun,bmp_run ,wxDefaultPosition, btn_size);//_T("Run") );
btnsSizer->Add( mwxButtonRun );
/*
wxBitmap bmp_quit(cc_exit_xpm);
WxGUITextEditor::~WxGUITextEditor()
{
m_mgr.UnInit();
+
// delete mInterpreter;
}
//================================================================
//================================================================
void WxGUITextEditor::OnButtonClose(wxCommandEvent& event)
{
+ CloseCurrentPage();
+ }
+ //================================================================
+
+ //================================================================
+ bool WxGUITextEditor::CloseCurrentPage()
+ {
std::cout << "-------------- CLOSE ---------------"<<std::endl;
- if (mwxNotebook->GetPageCount()==0) return;
+ if (mwxNotebook->GetPageCount()==0) return true;
if (GetCurrentPage()->IsModified())
{
+ wxString mess = std2wx(GetCurrentPage()->GetPageName());
+ mess += _T(" modified. Save it ?");
wxMessageDialog* d =
new wxMessageDialog(this,
- _T("Buffer modified. Save it ?"),
+ mess,
_T("Save buffer"),
wxYES_NO | wxCANCEL | wxICON_QUESTION);
switch (d->ShowModal())
{
case wxID_CANCEL :
- return;
+ return false;
break;
case wxID_YES :
GetCurrentPage()->Save(mFileNameFilter);
}
mwxNotebook->DeletePage(mwxNotebook->GetSelection());
FocusOnCurrentPage();
- }
+ return true;
+ }
+ //================================================================
+
+ //================================================================
+ bool WxGUITextEditor::CloseAllPages()
+ {
+ bool ok = true;
+ while (mwxNotebook->GetPageCount()!=0)
+ {
+ if (!CloseCurrentPage())
+ {
+ ok = false;
+ break;
+ }
+ }
+ return ok;
+ }
//================================================================
//================================================================
void WxGUITextEditor::OnButtonSave(wxCommandEvent& event)
{
- Save();
+ SaveCurrentPage();
}
- void WxGUITextEditor::Save()
+ void WxGUITextEditor::SaveCurrentPage()
{
- std::cout << "-------------- SAVE ---------------"<<std::endl;
if (mwxNotebook->GetPageCount()==0) return;
GetCurrentPage()->Save(mFileNameFilter);
mwxNotebook->SetPageText(mwxNotebook->GetSelection(),
{
if (mwxNotebook->GetPageCount()==0) return;
GetCurrentPage()->SetAskFilename(true);
- Save();
+ SaveCurrentPage();
}
//================================================================
void WxGUITextEditor::OnPageClose(wxAuiNotebookEvent& evt)
{
std::cout << "-------------- CLOSE ---------------"<<std::endl;
+ if (!CloseCurrentPage()) evt.Veto();
+
+ /*
if (mwxNotebook->GetPageCount()==0) return;
if (GetCurrentPage()->IsModified())
{
case wxID_NO : ;
}
}
-
+ */
}
//================================================================
switch (event.GetKeyCode())
{
case 'n': case 'N' : New(); break;
- case 's': case 'S' : Save(); break;
+ case 's': case 'S' : SaveCurrentPage(); break;
case 'o': case 'O' : Open(); break;
// case 'r': case 'R' : Run(); break;
// case 'q': case 'Q' : Quit(); break;