Program: bbtk
Module: $RCSfile: bbtkWxGUITextEditor.cxx,v $
Language: C++
- Date: $Date: 2008/04/24 12:56:40 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2008/05/14 12:32:26 $
+ Version: $Revision: 1.12 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
}
//================================================================
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ //================================================================
+ // WxGUITextEditor
+ //================================================================
+
+
//================================================================
WxGUITextEditor::WxGUITextEditor( wxWindow *parent,
WxGUITextEditorUser* user )
mUser(user),
mFileNameFilter("*.*")
{
- // std::cout << "WxGUITextEditor::WxGUITextEditor"<<std::endl;
- // mInterpreter = new bbtk::Interpreter();
- //mInterpreter->SetWxGUITextEditor(this);
- // mInterpreter->SetCommandLine(true);
m_mgr.SetManagedWindow(this);
- //==============
- // Menu
- wxInitAllImageHandlers();
-
-
- // wxFlexGridSizer *sizer= new wxFlexGridSizer(2);
- wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-
+ // wxInitAllImageHandlers();
+
mwxNotebook = new wxAuiNotebook(this,
-1,
wxPoint(0, 0),
//| wxAUI_NB_CLOSE_ON_ALL_TABS
| wxNO_BORDER);
- sizer->Add(mwxNotebook,1,wxGROW);
+ m_mgr.AddPane(mwxNotebook,
+ wxAuiPaneInfo().Name(wxT("notebook"))
+ .Caption(wxT(""))
+ .CaptionVisible(false)
+ .MinimizeButton(false)
+ .MaximizeButton(false)
+ .CloseButton(false)
+ // .Dockable(false).Float()
+ .Center()
+ .MinSize(wxSize(100,50))
+ );
-
- // BUTTONS
- wxPanel *btnsCtrlPanel = new wxPanel(this,-1);
- wxBoxSizer *btnsSizer = new wxBoxSizer(wxHORIZONTAL);
/*
wxBitmap bmp_new(cc_new_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 );
-
-
- mwxButtonRun = new wxBitmapButton( btnsCtrlPanel,ID_ButtonRun,bmp_run ,wxDefaultPosition, btn_size);//_T("Run") );
- btnsSizer->Add( mwxButtonRun );
- /*
- wxBitmap bmp_quit(cc_exit_xpm);
- mwxButtonQuit = new wxBitmapButton( btnsCtrlPanel,ID_ButtonQuit,bmp_quit);//_T("Quit") );
- btnsSizer->Add( mwxButtonQuit );
- */
-
- mwxPosition = new wxStaticText ( btnsCtrlPanel, -1, _T(""));
- btnsSizer->Add( mwxPosition );
+ mwxToolBar = new wxToolBar(this, wxID_ANY,
+ wxDefaultPosition, wxDefaultSize,
+ wxTB_FLAT | wxTB_NODIVIDER);
- btnsCtrlPanel->SetSizer(btnsSizer);
- btnsCtrlPanel->SetAutoLayout(true);
- btnsCtrlPanel->Layout();
-
- sizer->Add ( btnsCtrlPanel, 0, wxLEFT | wxRIGHT | wxBOTTOM //| wxGROW
- , 10 );
-
+ mwxToolBar->AddTool(ID_ButtonNew, _T("New"),
+ bmp_new, wxNullBitmap, wxITEM_NORMAL,
+ _T("New file"), _T("Create a new file"));
+ mwxToolBar->AddTool(ID_ButtonOpen, _T("Open"),
+ bmp_open, wxNullBitmap, wxITEM_NORMAL,
+ _T("Open file"), _T("This is help for new file tool"));
+ mwxToolBar->AddTool(ID_ButtonClose, _T("Close"),
+ bmp_close, wxNullBitmap, wxITEM_NORMAL,
+ _T("Close file"), _T("Close current file"));
+ mwxToolBar->AddTool(ID_ButtonSave, _T("New"),
+ bmp_save, wxNullBitmap, wxITEM_NORMAL,
+ _T("Save file"), _T("Save current file"));
+ mwxToolBar->AddTool(ID_ButtonSaveAs, _T("New"),
+ bmp_saveas, wxNullBitmap, wxITEM_NORMAL,
+ _T("Save file as"), _T("Save current file as"));
+ mwxToolBar->AddTool(ID_ButtonRun, _T("Run"),
+ bmp_run, wxNullBitmap, wxITEM_NORMAL,
+ _T("Run file"), _T("Run current file"));
+
+ mwxToolBar->AddSeparator();
+ mwxPosition = new wxStaticText ( mwxToolBar, -1, _T(""));
+ mwxToolBar->AddControl(mwxPosition);
+ mwxToolBar->Realize();
+
+ m_mgr.AddPane(mwxToolBar,
+ wxAuiPaneInfo().Name(wxT("toolBar"))
+ .Caption(wxT(""))
+ .ToolbarPane()
+ .Bottom()
+ .MinSize(wxSize(100,50))
+ .LeftDockable(false).RightDockable(false)
+ );
NewPage("");
UpdateInfo();
- SetSizer(sizer);
+ m_mgr.Update();
SetAutoLayout(true);
Layout();
}
//================================================================
//================================================================
- void WxGUITextEditor::OnButtonOpen(wxCommandEvent& event)
- {
- Open();
- FocusOnCurrentPage();
- }
+ void WxGUITextEditor::OnToolLeftClick(wxCommandEvent& event)
+ {
+ switch (event.GetId())
+ {
+ case ID_ButtonNew :
+ New();
+ FocusOnCurrentPage();
+ break;
+ case ID_ButtonOpen :
+ Open();
+ FocusOnCurrentPage();
+ break;
+ case ID_ButtonClose :
+ CloseCurrentPage();
+ break;
+ case ID_ButtonSave :
+ SaveCurrentPage();
+ break;
+ case ID_ButtonSaveAs :
+ if (mwxNotebook->GetPageCount()==0) break;
+ GetCurrentPage()->SetAskFilename(true);
+ SaveCurrentPage();
+ break;
+ case ID_ButtonRun :
+ if ((mUser!=0) && (mwxNotebook->GetPageCount()>0))
+ mUser->WxGUITextEditorRun();
+ FocusOnCurrentPage();
+ break;
+ }
+ }
+ //================================================================
+
+ //================================================================
+ void WxGUITextEditor::OnToolRightClick(wxCommandEvent& event)
+ {
+ }
+ //================================================================
+
+ //================================================================
+ void WxGUITextEditor::New()
+ {
+ NewPage("");
+ UpdateInfo();
+ }
+ //================================================================
+
+ //================================================================
void WxGUITextEditor::Open()
{
// std::cout << "-------------- OPEN ---------------"<<std::endl;
}
//================================================================
- //================================================================
- void WxGUITextEditor::OnButtonClose(wxCommandEvent& event)
- {
- CloseCurrentPage();
- }
- //================================================================
//================================================================
bool WxGUITextEditor::CloseCurrentPage()
{
- // std::cout << "-------------- CLOSE ---------------"<<std::endl;
if (mwxNotebook->GetPageCount()==0) return true;
+
if (GetCurrentPage()->IsModified())
{
wxString mess = std2wx(GetCurrentPage()->GetPageName());
}
mwxNotebook->DeletePage(mwxNotebook->GetSelection());
FocusOnCurrentPage();
- return true;
+ return false;
}
//================================================================
//================================================================
//================================================================
- void WxGUITextEditor::OnButtonSave(wxCommandEvent& event)
- {
- SaveCurrentPage();
- }
void WxGUITextEditor::SaveCurrentPage()
{
if (mwxNotebook->GetPageCount()==0) return;
}
//================================================================
- //================================================================
- void WxGUITextEditor::OnButtonSaveAs(wxCommandEvent& event)
- {
- if (mwxNotebook->GetPageCount()==0) return;
- GetCurrentPage()->SetAskFilename(true);
- SaveCurrentPage();
- }
- //================================================================
//================================================================
void WxGUITextEditor::OnPageClose(wxAuiNotebookEvent& evt)
{
- // std::cout << "-------------- CLOSE ---------------"<<std::endl;
if (!CloseCurrentPage()) evt.Veto();
-
- /*
- 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 :
- evt.Veto();
- break;
- case wxID_YES :
- GetCurrentPage()->Save(mFileNameFilter);
- break;
- case wxID_NO : ;
- }
- }
- */
}
//================================================================
*/
//================================================================
- void WxGUITextEditor::OnButtonRun(wxCommandEvent& event)
- {
- if ((mUser!=0) && (mwxNotebook->GetPageCount()>0))
- mUser->WxGUITextEditorRun();
- FocusOnCurrentPage();
- }
/*
void WxGUITextEditor::Run()
//================================================================
- //================================================================
- void WxGUITextEditor::OnButtonNew(wxCommandEvent& event)
- {
- New();
- FocusOnCurrentPage();
- }
- void WxGUITextEditor::New()
- {
- /// std::cout << "-------------- NEW ---------------" << std::endl;
- NewPage("");
- UpdateInfo();
- }
- //================================================================
//================================================================
void WxGUITextEditor::UpdateInfo()
//================================================================
BEGIN_EVENT_TABLE(WxGUITextEditor, wxPanel)
- // 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_MENU(wxID_ANY, WxGUITextEditor::OnToolLeftClick)
+ EVT_TOOL_RCLICKED(wxID_ANY, WxGUITextEditor::OnToolRightClick)
EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, WxGUITextEditor::OnPageClose)
END_EVENT_TABLE()
//================================================================
Program: bbtk
Module: $RCSfile: bbwxvtkViewer2D.cxx,v $
Language: C++
- Date: $Date: 2008/05/14 07:01:00 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2008/05/14 12:32:26 $
+ Version: $Revision: 1.6 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// LG : because it has been allocated with operator new not method ::New
// we want to force its destruction without taking care of vtk ref counting
// on the contrary the following vtk objects are deleted with vtk Delete
- std::cout << "Viewer2DWidget::~Viewer2DWidget()" << std::endl;
+ // std::cout << "Viewer2DWidget::~Viewer2DWidget()" << std::endl;
if (backImageData)
{
// backImageData->UnRegister(NULL);
imageViewer->Delete();
}
delete wxvtkrenderwindowinteractor;
- std::cout << "Viewer2DWidget::~Viewer2DWidget() OK" << std::endl;
+ // std::cout << "Viewer2DWidget::~Viewer2DWidget() OK" << std::endl;
}
//-------------------------------------------------------------------------
void Viewer2DWidget::UpdateView()
{
- std::cout << "Viewer2DWidget::UpdateView() "<<mBox->bbGetFullName() << std::endl;
- std::cout << "slice="<<mBox->bbGetInputSlice()<<std::endl;
+ // std::cout << "Viewer2DWidget::UpdateView() "<<mBox->bbGetFullName() << std::endl;
+ // std::cout << "slice="<<mBox->bbGetInputSlice()<<std::endl;
+
if ( (mBox->bbGetInputIn()!=NULL) &&
(backImageData != mBox->bbGetInputIn()) )
{
imageViewer->SetupInteractor ( wxvtkrenderwindowinteractor );
}
- std::cout << "V2D b="<<backImageData<<std::endl;
+ // std::cout << "V2D b="<<backImageData<<std::endl;
if (backImageData)
{
- std::cout << "V2D r1="<<backImageData->GetReferenceCount()<<std::endl;
+ // std::cout << "V2D r1="<<backImageData->GetReferenceCount()<<std::endl;
// backImageData->DebugOn();
// backImageData->UnRegister(NULL);
}
backImageData = mBox->bbGetInputIn();
- std::cout << "V2D r2="<<backImageData->GetReferenceCount()<<std::endl;
+ // std::cout << "V2D r2="<<backImageData->GetReferenceCount()<<std::endl;
// backImageData->DebugOn();
// backImageData->PrintSelf(std::cout,0);
(mBox->bbIsShown()))
{
int z = mBox->bbGetInputSlice();
- std::cout << "slice = "<<z<<std::endl;
+ // std::cout << "slice = "<<z<<std::endl;
int ext[6];
backImageData->GetWholeExtent(ext);
- std::cout << "ext = "<<ext[4]<<" - "<<ext[5]<<std::endl;
+ // std::cout << "ext = "<<ext[4]<<" - "<<ext[5]<<std::endl;
if (z<ext[4]) { z=ext[4]; }
if (z>=ext[5]) { z=ext[5]-1; }
// I think there is a problem with rendering before window
// has been reparented ... we have to check this
- ((Viewer2DWidget*)bbGetOutputWidget())->UpdateView();
+ // ((Viewer2DWidget*)bbGetOutputWidget())->UpdateView();
bbSetOutputOut( bbGetInputSlice() );
}